Val-sss
2162a9585e
feat: 三项框架优化 — 精准retry + ReAct首次启用 + 多文件batch
...
1. 精准Retry: 高通过率(差1-2个测试)时保留完整诊断不截断,
加聚焦指令"只修这个问题不要改其他代码"(原300字符截断→800)
2. ReAct首次启用: 多文件/rename/refactor任务首次attempt就用
ReAct循环探索,不再等retry才触发(_is_complex_task门控)
3. 多文件batch: ReactLoop增加rename专用策略指引(grep找引用→
逐文件修改→验证), 扩展rename任务文件数限制3→8
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-14 08:09:05 +08:00
Val-sss
5a6803fc30
release: v2.1.0 — ReAct多轮交互循环,Eval 22%→53% (26/50 PASS)
...
新增ReAct循环(kaiwu/agent/react_loop.py):
- 工具集: read_file/write_file/run_test/grep/list_dir/submit
- 门控: retry_count≥1时触发,小模型5步/中8步/大10步
- 上下文管理: 保留system+初始user+最近6轮,早期压缩
- 安全: 写入前Python语法检查,禁写测试文件,失败恢复
Eval结果 (qwen2.5-coder:32b-instruct-q4_K_M, 50题):
- 总通过率: 26/50 (53%), 对比v2.0.0的8/36(22%)提升141%
- Go题: 6/9 PASS (t42/t43/t44/t46/t56/t57)
- 多文件API: 3/3 全过 (t51/t52/t53)
- 综合题: t10_comprehensive PASS (425s, 之前timeout)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-14 07:11:38 +08:00
Val-sss
0d6a16b388
fix: eval-driven bugfixes — 20% → 47% PASS (same-task comparison)
...
Fixes verified by running 28 bench tasks on VPS with 32B model:
- TASK_TIMEOUT 300→600s: lets 32B complete 3x sampling + retry
- _run_stub_decomposed restored: was accidentally truncated in v2.0.0
- max_retries 1→3 for SMALL tier: 7B models generate fast, need more attempts
- bug_decomposed disabled: caused timeout on 32B, no benefit on 7B
- REASONING_TOKEN_MULTIPLIER_SMALL confirmed at 3x (2x/1.5x truncates code)
Results: 8/28 PASS (29%), same-task comparison 7/15 (47%) vs Round 46's 3/15 (20%)
New PASS: t01, t03, t05, t40
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-12 04:55:06 +08:00
Val-sss
01f8dccc06
release: v2.0.0 — Eval驱动架构升级,数据量化验证每个改动
...
核心成果:Eval 0%→20% (3/15 PASS),总测试通过数 294→377 (+28%)
新增:
- usage_finder: AST确定性调用关系传递
- bug_decomposed: 多bug任务逐TestClass拆解修复
- 新文件创建: _maybe_create_missing_module
- 工程约束注入: _detect_engineering_hints
- 自适应采样: 大文件1次/小文件3次
- bench诊断报告系统: bench_diagnose.py
实验验证(数据说话):
- diff格式对32B弊大于利(超时),已回滚
- 自适应采样解决超时但降低多样性
- usage_finder/bug_decomposed机制有效但受模型能力限制
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
v2.0.0
2026-05-10 15:59:59 +08:00
Val-sss
c32e423d04
feat: v1.9.0 — 9项架构优化,工程消化反馈替代raw输出注入
...
核心思路:32B模型无法有效整合raw pytest输出,工程把反馈解析成
LLM最容易理解的形式(结构化诊断句),同时加入执行反馈内循环、
docstring注入、批次拆解等机制提升通过率。
9项改动:
1. generate_diagnosis() 结构化诊断句
2. _run_execution_feedback() 内循环
3. usage_finder.py 调用关系注入
4. _extract_docstrings() + _inject_docstrings()
5. _maybe_create_missing_module() LLM生成缺失模块
6. _run_whole_file_refactor() 批次拆解
7. _build_retry_hint() delta反馈
8. _clean_code_output() 格式清理(已覆盖)
9. _inject_skill_context() SKILL.md注入
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-09 18:38:03 +08:00
Val-sss
c2cc7d6ae8
feat: 21-fix eval optimization — 0/3 → 3/15 PASS (+83 tests)
...
Core fixes:
- checkpoint.restore() no longer overwrites partial progress
- error[-3000:] captures FAILURES block (was [:3000] missing it)
- verifier: no rollback when tests partially pass
- LOGIC_ERROR tasks use whole_file_refactor (not hashline)
- retry preserves locator_output (avoids codegen from scratch)
- syntax errors don't consume retry budget (max 2 free)
D-step (context preparation):
- attribute_failures_to_files: test failure → source file attribution
- extract_fault_functions: function-level fault localization from stack trace
- ROOT CAUSE priority: test assertions rank above crash location
- _extract_failing_test_code: inject test source with expected values
- AST interface extraction for multi-file context
- Skip files without attributed failures
- Failure batching (max 3 per prompt)
Generator improvements:
- _run_whole_file_refactor with multi-file context
- _run_targeted_fix for retry (preserves progress)
- _clean_code_output: strip CJK explanation + markdown residue
- scope_check prevents whole-file overwrite of single function
- Minimal system prompt for multi-file tasks
Results: 3/15 PASS (t04/t06/t07), +83 tests across 15 tasks.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-09 14:03:56 +08:00
Val-sss
e8ab7a67c0
fix: _run_whole_file test failure injection — tail 2000 + remove retry_count gate
...
The last missed injection site: _run_whole_file was still using
initial_failure[:500] (head) with retry_count==0 guard. Changed to
[-2000:] (tail, where FAILURES live) and removed the retry_count
restriction so whole_file path in retries also sees failure details.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-08 12:40:33 +08:00
Val-sss
facfcd75aa
fix: inject raw test failure tail into prompt (no truncation logic)
...
Replace FAILURES-section extraction (which could produce empty output)
with simple tail-2000 of initial_test_failure. Applied to all three
injection sites (_generate_modified, _try_hashline, _run_whole_file).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-08 12:33:17 +08:00
Val-sss
6538822f8a
feat: inject raw FAILURES output into generator prompt
...
Pass pre_test FAILURES section directly to LLM on every attempt
(first and retry). No interpretation, no keywords, just the raw
test output truncated to 1500 chars.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-08 12:17:20 +08:00
Val-sss
9dca7da712
release: v1.8.0
...
- feat: trajectory attempts detailed logging (llm_prompt_tail, raw_output, patches_count, etc.)
- feat: regression guard — best_tests_passed tracking + rollback on regression
- feat: structured_failures in retry hint (test_name + expected/actual)
- fix: regression guard closure — best state written back before failure exit
- fix: hashline silent fallback to full-function (no retry consumed)
- fix: vision expert keyword matching (stricter single-word rejection)
- fix: audit logger tests (LOGS_DIR → LOGS_SUCCESS/LOGS_FAILED/LOGS_LEGACY)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
v1.8.0
2026-05-08 11:49:54 +08:00
Val-sss
4afe44f9fc
fix: regression guard closure + hashline silent fallback
...
1. Best state restore on failure: before _record_failure_result, write
best_code_snapshot back to disk so post-test sees the best intermediate
result (e.g. 21/25) instead of a regressed state (1/25). Not affected
by KWCODE_NO_RESTORE since this is proactive preservation, not checkpoint
restoration.
2. Hashline silent fallback: when _try_hashline returns None, the code
already falls through to full-function generation within the same
_generate_modified call. No retry is consumed — the fallback is
transparent to the orchestrator. Added explicit comment for clarity.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-08 11:27:12 +08:00
Val-sss
b3fb44da82
fix: vision expert keyword matching — stricter single-word rejection
...
- _should_execute_code: reject bare "执行"/"运行"/"run", require
code-related context (e.g. "运行一下这个代码", "execute the code")
- _is_codegen_task: add "写页面"/"write code", reject bare "生成"
- _vision_api_configured: require both URL and model (not just either)
All 109 tests pass.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-08 11:06:41 +08:00
Val-sss
478899ecd7
feat: regression guard + structured failures in retry hint
...
1. Regression guard: tracks best_tests_passed and best_code_snapshot
in TaskContext. After each verifier run, if tests_passed drops below
the best seen so far, rolls back modified files to the best snapshot
and sets retry_hint with specific failing tests. Worst case preserves
the best result instead of regressing to 0.
2. Structured failures: _build_retry_hint now parses test output via
parse_test_failures and appends specific test_name + expected/actual
values, giving the LLM precise targets for the next attempt.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-08 10:53:47 +08:00
Val-sss
8874de74a3
feat: add detailed attempts list to trajectory records
...
Each retry attempt now records llm_prompt_tail, llm_raw_output,
llm_caller, patches_count, patch_apply_ok/error, modified_lines,
tests_passed/total, test_output_tail, and error_type. This enables
precise post-hoc diagnosis without re-running benchmarks.
Also fixes test_audit_model.py to use correct module-level constants
(LOGS_SUCCESS/LOGS_FAILED/LOGS_LEGACY instead of removed LOGS_DIR).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-08 09:22:47 +08:00
Val-sss
5290dd117c
feat: best-of-N采样 — 多温度生成选语法正确的候选
...
Generator不再遇到第一个非空结果就返回,而是:
1. temperature=0.0/0.3/0.6依次生成
2. 每个候选做ast.parse语法检查
3. 第一个语法正确的直接返回(优先确定性低温结果)
4. 全部语法错误时返回第一个候选(让verifier报具体错误)
直接解决"语法错误导致circuit break":temp=0错了,temp=0.4可能对。
513 tests passed.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-07 18:37:35 +08:00
Val-sss
3c5441d6c4
docs: STATUS.md 更新到 v1.7.0
...
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-07 18:30:56 +08:00
Val-sss
2c4d792baa
feat: v1.7.0 KAIJU架构借鉴 — bounded context + sub-task decomposition + DetailedLogger
...
三个核心改动:
1. Generator bounded context: 只传当前函数代码+相关failing tests,不传完整历史
2. 存根任务sub-task decomposition: 多pass函数逐个独立实现,每个函数独立context
3. DetailedLogger完整流水线日志: 不截断LLM输入输出,记录各节点IO和工程决策
附带修复:
- OpenAI兼容API检测: localhost非标准端口探测/api/tags判断是否Ollama
- LLM Backend on_call钩子: 每次调用自动触发回调记录
513 tests passed.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
v1.7.0
2026-05-07 18:24:56 +08:00
Val-sss
ca55970ad8
release: v1.6.2 版本号统一 + README/CHANGELOG/STATUS更新
...
- 版本号统一到1.6.2(pyproject/__init__/formatters/telemetry/server)
- README: badge 1.6.2, License Apache-2.0, 更新日志加v1.6.2条目
- CHANGELOG: 完整v1.6.2变更记录
- STATUS: 当前版本更新到v1.6.2
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
v1.6.2
2026-05-07 14:42:21 +08:00
Val-sss
e4a65e5117
fix: 存根任务三个根本问题修复
...
1. gap_detector: TypeError/takes no arguments也识别为stub_returns_none
(之前只匹配assert None==和NoneType,漏掉了TypeError模式)
2. generator: 逐函数patch全失败时fallback到whole_file路径
(之前返回None导致patches=0)
3. generator: codegen路径文件已存在时走whole_file覆盖
(之前生成pipeline_1.py,测试跑的还是原文件)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-07 14:20:18 +08:00
Val-sss
106b1d2af1
feat: 完整信息传递路径审计 — LLM输入输出+各节点IO全记录
...
- audit/logger: 新增log_llm_call()记录每次LLM调用的prompt/output/caller
- audit/logger: write()输出node_io(locator/generator/verifier各节点输入输出)
- audit/logger: write()输出llm_calls列表(完整调用链)
- generator: 所有llm.generate()调用后记录到审计日志
- context: 新增_audit_logger字段,orchestrator注入引用
- orchestrator: ctx创建时注入_audit引用
日志现在能看到:谁调了LLM、给了什么prompt、LLM输出了什么、工程做了什么处理
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-07 13:45:19 +08:00
Val-sss
449959b76d
feat: 执行反馈深度升级 — pytest -v + 结构化失败首次/重试都注入
...
- verifier: pytest从-q改为-v(获取完整失败详情而非摘要)
- verifier: run_tests_only()也返回structured_failures
- generator: 结构化失败信息首次和重试都注入(不只是retry_hint)
- generator: 上限从5提到8个失败,含error_type
- fallback: 解析不出结构化时给raw output 800字符(之前500)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-07 13:33:24 +08:00
Val-sss
18d4403810
feat: mechanism_audit.py — 7个最小验证任务走查v1.6.2全部机制
...
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-07 13:23:09 +08:00
Val-sss
298fc98ffb
feat: 结构化测试失败解析 — LLM首次就看到精确的期望/实际值
...
- test_parser.py: 新增parse_test_failures(),从pytest输出提取每个失败测试的
test_name/expected/actual/error_type/file/line/snippet
- verifier.py: run()返回structured_failures字段
- generator.py: 首次生成prompt注入结构化失败信息(不只是raw output)
"test_guard_allows: 期望True,实际None"
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-07 13:16:25 +08:00
Val-sss
1046e65c04
feat: TraceCoder式历史教训累积 — 重试不再从零开始
...
- context.py: 新增attempt_history字段,每轮累积不重置
- orchestrator: 每次retry记录passed/failed/error到attempt_history
- _build_retry_hint: 携带最近3次历史教训摘要(20+20=40效果)
- 回归rollback: 携带具体regressed_tests信息,不是空白提示
- audit/logger: 写入attempt_history到日志,便于后续分析
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-07 13:08:09 +08:00
Val-sss
797549450e
feat: v1.6.2 初始测试失败注入Generator + Wink润滑增强
...
- Generator: 首次生成时注入initial_test_failure到prompt(LLM第一次就看到具体报错)
- Wink: 润滑规则增强
- Orchestrator: 重试逻辑优化
- pyproject.toml: 1.6.2
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-07 12:32:44 +08:00
Val-sss
44e1155032
feat: whole_file scope改用write_file直接写入,绕开patch缩进问题
...
- Generator._run_whole_file(): LLM返回完整文件内容,不走逐函数patch
- Verifier: write_mode=whole_file时读content字段直接写入
- 彻底解决5个pass函数连续apply_patch互相干扰的IndentationError
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-07 11:14:48 +08:00
Val-sss
e3befe5002
fix: pre_test输出截断导致存根检测失败
...
- verifier._run_tests() error截断从500→2000字符(500字符丢失assert None模式)
- gap_detector: files为空时扫描project_root非测试py文件
- 根因:pytest --tb=short输出>500字符时,"assert None =="被截掉
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-07 10:59:17 +08:00
Val-sss
54436c29c6
fix: 存根检测files为空时扫描project_root源文件
...
pre_test输出只含test文件路径时,_extract_error_files返回空。
新增_find_source_files():扫描project_root/*.py非测试文件,
让_scan_stubs_in_files能找到存根函数。
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-07 10:48:30 +08:00
Val-sss
5d6adfb745
fix: 扩展存根检测覆盖 assert None == X 模式
...
原检测只匹配NoneType+操作错误,漏掉pass函数被直接assert的场景。
新增:多个"assert None =="或"where None = func()"时识别为STUB_RETURNS_NONE。
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-07 10:41:48 +08:00
Val-sss
5d170c5a37
fix: 测试全通过时跳过Reviewer审查(防止LLM幻觉reject)
...
根因:Reviewer对已通过测试的代码产生幻觉(编造不存在的函数),
导致正确结果被reject+回滚,bench全军覆没。
修复:tests_passed == tests_total时直接确认成功,不走Reviewer。
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-07 10:37:35 +08:00
Val-sss
4fb5d5d4c1
feat: GapDetector AST存根扫描 + Generator whole_file 4096 tokens + Reviewer阈值0.7
...
- GapDetector._scan_stubs_in_files(): 纯AST扫描pass/raise存根,输出完整target_functions
- Generator: scope=whole_file时base_tokens提升到4096
- Reviewer闭环:confidence>=0.7时返回None重入retry,强制重新定位
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-07 10:11:12 +08:00
Val-sss
fa1390f8a9
release: v1.6.1 版本号统一 + README/STATUS更新 + License Apache-2.0
...
- pyproject.toml/formatters/telemetry/server/models/__init__ 全部统一到 1.6.1
- README: badge更新、更新日志加v1.6.0/v1.6.1条目
- STATUS: 版本号描述更新
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-07 09:23:19 +08:00
Val-sss
2861177ff0
Revert "feat: Blueprint两步生成流程(LLM施工图→模板填充→LLM fallback)"
...
This reverts commit a98e95fe61 .
2026-05-07 09:12:47 +08:00
Val-sss
3a21a607f3
chore: license MIT → Apache-2.0
...
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-07 09:02:33 +08:00
Val-sss
a98e95fe61
feat: Blueprint两步生成流程(LLM施工图→模板填充→LLM fallback)
...
- 新增 blueprint.py: Blueprint dataclass
- 新增 skill_parser.py: 解析SKILL.md模板块
- 新增 skill_executor.py: 确定性模板填充(零LLM)
- 新增 blueprint_collector.py: 成功施工图双写飞轮
- Generator插入两步流程:Step1生成施工图→Step2模板填充→fallback现有逻辑
- Orchestrator._record_blueprints()记录成功blueprint
- CLI: kwcode skill list-templates / promote
- bugfix/SKILL.md追加3个初始模板(null_check/stub_implement/add_return_guard)
- 542 tests green(+29新测试)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-07 09:00:23 +08:00
Val-sss
2d7abc8dda
v1.6.1: 删除WholeFileImplExpert/DependencyFixExpert,架构收敛到纯pipeline
...
- 存根实现由Generator通过ctx.gap scope=whole_file处理
- 依赖安装由EnvProber在Phase0处理
- Generator增强:upstream_constraints注入system prompt + retry_hint携带上次代码 + tier=small填空框架
- 513 tests green
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-07 08:38:14 +08:00
Val-sss
8f1cbe1f07
feat: MoE deterministic architecture v1.6.0
...
GapDetector + ExecutionStateTracker + EnvProber + enhanced audit logging.
Generator dynamically lifts function cap based on gap scope (stub tasks
no longer limited to 2 functions). Gate rewritten with deterministic-first
routing (gap → keywords → LLM fallback). 514 tests green + 63 diagnostic.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-05-07 08:16:25 +08:00
Val-sss
4bdd32bf00
docs: update STATUS with Reviewer/Verifier/syntax fixes
2026-05-07 03:01:03 +08:00
Val-sss
b73d37d1d1
fix: Reviewer now triggers retry + syntax tier-aware + 0/0 false success eliminated
...
Three pipeline-level fixes that close the feedback loop:
1. Reviewer triggers retry (was: log-only, no action):
- _record_success returns None when review finds gap (confidence≥0.6)
- retry loop catches None → resets generator/verifier output → retries
- review gap injected as retry_hint so Generator corrects next attempt
- Reviewer prompt enhanced with test context (initial_test_failure)
2. Syntax circuit-break now tier-aware:
- SMALL: break after 1 retry (unchanged, small models repeat same errors)
- MEDIUM/LARGE: break after 2 retries (32B often recovers on 2nd try)
3. tests_total=0 no longer passes:
- When syntax OK but 0 tests ran, check if test files exist in project
- If test files found but 0 executed → passed=False, error explains why
- Eliminates the "36 tasks audit-success but bench-fail" false positive
501 tests green, 0 regression.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-06 22:10:04 +08:00
Val-sss
1a6f6c635f
feat: Test-First Loop — pre-test locating + toolchain auto-install + 0/0 fix
...
Architecture change (CC-style test-first loop):
- orchestrator: pre-test before locator for repair/refactor tasks
verifier.run_tests_only() → ctx.initial_test_failure → locator reads it
- locator.locate_from_test_error(): extract File+line+function from test output
Priority: test_error > BM25+graph > LLM fallback
Skips test files and stdlib, only returns business code
Verifier P0 fixes:
- Test file discovery: scan *_test.py/test_*.py/*_test.go/*.test.ts recursively
(was: only check tests/ directory → 0/0 false success on 36 tasks)
- When test files found outside tests/, run pytest with file paths directly
- Toolchain auto-install: go/node/rust/java not found → apt-get install
(was: report as syntax error → useless retries → circuit break)
- Go syntax: "not found" → skip (not syntax error)
501 tests green, 0 regression.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-06 22:01:09 +08:00
Val-sss
892e8062bc
release: v1.5.1 — update docs, fix remaining audit issues
...
- GENERATOR_PROMPT: negative indent instruction → positive ("必须4空格,与原文件完全一致")
- ast_grep_engine: json.loads wrapped in try/except (5th JSON protection)
- STATUS.md: updated to reflect all v1.5.1 features (501 tests)
- CHANGELOG.md: full v1.5.1 release notes (flywheel, telemetry, hashline, adaptthink, audit, model_capability)
- README.md: version badge 1.5.1, updated changelog table
501 tests green, 0 regression.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-06 21:11:45 +08:00
Val-sss
0c1ed9d0c7
fix: complete fix_spec — prompts simplified, ctx 0.9 factor, cloud CTX table
...
Prompt cleanup per spec (positive instructions > negative):
- GENERATOR_PROMPT: removed tool description, simplified to 4 bullet points
- GENERATOR_NEWFILE_PROMPT: 6 negative rules → 2 positive bullets
- GENERATOR_TEST_PROMPT: removed tool description, simplified format
- All prompts now use "纯代码,无markdown,无解释" pattern
model_capability ctx adjustments per spec:
- Safety factor 0.8 → 0.9 (spec requirement)
- Added _CLOUD_CTX table for cloud API models (deepseek-v3/v4, qwen-max, glm-4, kimi)
- Cloud API fallback: substring match against _CLOUD_CTX before 128K default
- Ollama native ctx capped at 128K (was 64K)
context.py: added effective_ctx field (default 32768)
orchestrator: safe getattr for mock compatibility
501 tests green, 0 regression.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-06 20:54:14 +08:00
Val-sss
66ae607d74
feat: ctx auto-detect + model-adaptive prompts + P0 bug fixes
...
Ctx auto-detection (model_capability.get_effective_ctx):
- 4-layer probe: llama.cpp → vLLM → Ollama modelinfo.llama.context_length → offline
- Cloud API (non-localhost) → 128K; known models → exact values; tier → conservative
- User config.yaml ctx field has highest priority
- llama_backend: every Ollama call now includes num_ctx in options
(kwcode actively sets ctx, not relying on Ollama default 2048)
Model-adaptive prompts:
- SMALL: no tool descriptions (prevents confused tool-call text output),
strict format (1 func, ≤10 lines, preserve indent, no markdown)
- MEDIUM: concise tool note ("tools auto-called, just output code")
- LARGE: full tool description + auto-call note
- Removed tool descriptions from GENERATOR_PROMPT and TEST_PROMPT templates
P0 bug fixes:
- chat_expert: removed tool descriptions (chat has no tool access)
- debug_subagent: 2x json.loads wrapped in try/except (prevents crash on malformed LLM JSON)
- checkpoint: 2x json.loads wrapped in try/except (prevents crash on damaged manifest)
- _clean_code_output: added cat/echo/touch/hashline-instruction filters
501 tests green, 0 regression.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-06 20:47:16 +08:00
Val-sss
76fa84da08
feat: wire model_capability into pipeline — tier-adaptive prompts + ctx auto-detect
...
Model tier detection now active (was orphaned code):
- orchestrator.__init__: detect tier from generator.llm.ollama_model
- ctx.model_tier written at run() start, flows to Generator
- Generator._build_system(): SMALL gets strict format constraints
(1 function, ≤10 lines, preserve indent, no explanation, ≤15 words between tools)
LARGE gets minimal constraint; MEDIUM uses base rules as-is
- _get_max_retries() respects model_strategy.max_retries
Context window auto-detection (get_effective_ctx):
- 4-layer probe: llama.cpp /props → vLLM /v1/models → Ollama modelinfo.llama.context_length → tier default
- Passed to LLMBackend n_ctx in build_pipeline
- SMALL=16K, MEDIUM=32K, LARGE=64K defaults; native ctx capped at 64K×0.8
501 tests green, 0 regression.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-06 20:33:59 +08:00
Val-sss
739020a63c
fix: version tests use __version__, align_indentation strip before align
...
- kaiwu/__init__.py: add __version__ from importlib.metadata (single source)
- test_server.py: 2 hardcoded "1.5.0" → dynamic __version__ (fixes 2 test failures)
- generator.py: strip('\n') before _align_indentation to prevent empty-line indent miscalc
All 50+16=66 tests green, 0 failures.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-06 20:23:08 +08:00
Val-sss
7b61af7be3
feat: audit log + model cmd + indent alignment fix
...
Audit log (audit/logger.py):
- Persists task execution trace as human-readable JSON
- Storage: ~/.kaiwu/logs/, max 100, auto-cleanup
- Records: task, gate, experts, files, tests, retries (no code content)
- orchestrator._emit() now instance method, auto-logs to audit
- CLI: kwcode log / log show <id> / log clear
Model commands (cli/commands/model_cmd.py):
- kwcode model: show current config + tier
- kwcode model set <name>: switch model (writes config.yaml)
- kwcode model probe: detect family/params/quant/reasoning via Ollama API
Indent alignment fix (Generator._align_indentation):
- Fixes systematic bug: LLM returns class methods at 0-indent,
apply_patch replaces 4-indent original → method escapes class
- Aligns modified base indent to match original before apply_patch
Tests: 10 new (audit 4 + indent 5 + hashline prompt 1), 50 total green
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-06 20:13:26 +08:00
Val-sss
129eed76d0
feat: P0 Hashline anchors + P1 AdaptThink + P2 Fast/Slow dual-phase
...
P0 Hashline (tools/hashline.py):
- Content-hash anchored editing: 6-char MD5 per line
- Model outputs EDIT/DELETE/INSERT_AFTER instructions, not full functions
- Hash mismatch → reject entire edit batch (stale file protection)
- Generator tries hashline first, falls back to full-function on failure
P1 AdaptThink (core/think_config.py):
- Gate-driven think budget per expert_type × difficulty
- easy=off, medium=512, hard=2048-4096, chat=always off
- Generator adjusts max_tokens based on think_config
P2 Fast/Slow (orchestrator retry loop):
- First attempt: fast (think=off, low tokens)
- First failure: escalate to slow (think=on, budget=2048)
- Second failure: max budget (4096)
- Orthogonal to retry_strategy (0→1→2)
Tests: 21 new (12 hashline + 8 think + 1 fast/slow), 40 total green
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-06 20:00:11 +08:00
Val-sss
9a7f13dd60
docs: update STATUS.md with telemetry guards + version unification
...
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-06 19:51:07 +08:00
Val-sss
17b6076945
fix: unify version to 1.5.1 from single source (pyproject.toml)
...
- pyproject.toml: 1.4.0 → 1.5.1 (single source of truth)
- formatters.py: hardcoded 0.9.0 → importlib.metadata
- telemetry/client.py: hardcoded 1.5.0 → importlib.metadata
- server/models.py + app.py: hardcoded 1.5.0 → importlib.metadata
- All fallback to "1.5.1" if package not installed in editable mode
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-06 19:47:24 +08:00
Val-sss
53c08a4e28
feat: three flywheels + anonymous telemetry + prompt quantification
...
Flywheel system (all local):
- strategy_stats.py: error strategy effectiveness tracking per error_type
- user_pattern_memory.py: cross-project user error pattern warnings
- skill_drafter.py: auto-generate SKILL.md drafts from stats
Anonymous telemetry (opt-in, default off):
- telemetry/client.py: HMAC-signed fire-and-forget upload
- Only sends: error_type, retry_count, success, model
- Never sends: code, paths, descriptions, user identity
- onboarding asks opt-in, kwcode telemetry enable/disable
CLI commands:
- kwcode telemetry status/enable/disable
- kwcode skill review/accept/discard
- kwcode stats: enhanced with flywheel + telemetry status
Prompt quantification (CC-style):
- GENERATOR_BASE_SYSTEM: "only do what's asked" → "≤2 functions, ≤30 lines"
- RETRY_STRATEGIES hints: quantified line limits per error type
- CHAT_SYSTEM: "short friendly" → "≤100 chars, ≤3 sentences"
Server deployed: https://llmbbs.com (nginx → uvicorn:9753, 3 SQLite tables)
Tests: 19 new, 0 regression
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-05-06 19:39:17 +08:00