Commit Graph

112 Commits

Author SHA1 Message Date
Val-sss
fae093a8b8 test: add bench tasks t46-t49 (Go pubsub + TypeScript)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
v1.5.0
2026-05-06 18:41:06 +08:00
Val-sss
ac1463abaa test: add bench tasks t42-t56
Go: t42_http_middleware, t43_worker_pool, t44_cache, t45_pipeline, t46_pubsub
TypeScript: t47_validator, t48_state_manager, t49_event_emitter, t50_api_client, t51_form_validator
System: t52_observability, t53_retry_policy, t54_data_pipeline, t55_auth_system, t56_service_mesh

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-06 18:36:13 +08:00
Val-sss
2cad63a0c2 test: add remaining bench tasks t41-t49
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-06 18:34:11 +08:00
Val-sss
0f1c598ef1 test: add bench tasks t40-t49
t40-t41 frontend_backend (search/ws), t42-t46 Go tasks
(http_middleware/worker_pool/cache/pipeline/pubsub),
t47-t49 TypeScript tasks (validator/state_manager/event_emitter)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-06 18:33:32 +08:00
Val-sss
0419c2de5c test: add bench tasks t38-t39 (pagination + upload)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-06 18:32:55 +08:00
Val-sss
f392113541 test: add t37_frontend_backend_auth bench task
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-06 18:30:59 +08:00
Val-sss
79569851b1 test: add bench tasks t34-t36
t34_cache_invalidation, t35_api_gateway, t36_message_queue

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-06 18:30:09 +08:00
Val-sss
1b29e6e23b test: add bench tasks t33-t39
t33_circuit_breaker, t34_cache_invalidation, t35_api_gateway,
t36_message_queue, t37-t39_frontend_backend (auth/pagination/upload)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-06 18:28:00 +08:00
Val-sss
7ddfad8f38 test: add t32_rate_limiter bench task
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-06 18:27:20 +08:00
Val-sss
0485c8ab12 test: add t31_event_sourcing bench task
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-06 18:26:55 +08:00
Val-sss
85cfe87f8d style: unify remaining English comments to Chinese
Translate comments in locator/verifier/upstream_manifest/search_subagent/
task_compiler to Chinese. Preserve RED-X markers, type shape comments,
and docstrings in English.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-06 18:23:18 +08:00
ValHuang
94a9728184 Merge pull request #15 from YonghaoZhao722/feature/error-handling-improvements
fix: resolve path normalization issue in DocReader cache
2026-05-06 18:12:06 +08:00
Val-sss
4856d3a617 docs: mark TODO items 1-3 as completed in STATUS.md
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-06 18:04:00 +08:00
Val-sss
40edbf6076 docs: update README v1.5.0 + unify comments to Chinese
- README: add v1.5.0 changelog entry, SearchSubagent architecture section
- README: version badge 1.4.0 → 1.5.0, add contract_violation to error routes
- Comments: English → Chinese in orchestrator/context/generator/locator
- Comments: remove decorative # ── xxx ── separator lines

451/451 tests green.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-06 17:59:34 +08:00
Val-sss
0a386f5fae refactor: split CLI main.py (1861→173 lines) + expert EventBus emit
CLI restructure:
- kaiwu/cli/main.py: only app registration + entry point (173 lines)
- kaiwu/cli/commands/task.py: run/chat/vision/multi-task commands
- kaiwu/cli/commands/expert.py: expert list/info/export/install/remove
- kaiwu/cli/commands/config.py: init/api/model/setup-search/serve
- kaiwu/cli/formatters.py: Rich output formatting (spinner, summary, header)

Expert-level EventBus emit:
- locator.py: emit file reads and method type
- event_bus.py: singleton get_instance() for expert access
- orchestrator.py: pass bus to experts for fine-grained events

451/451 tests green.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-06 17:45:09 +08:00
Val-sss
d5ce4342f6 v1.5.0: SearchSubagent isolated search + UpstreamManifest cross-file contracts
Architecture upgrade to improve task completion for any model size:
- SearchSubagent: independent context window, parallel file reads, clean results only
- UpstreamManifest: deterministic AST extraction of signatures/constants, zero LLM
- PENCIL-style compression: subtask results compacted to structured artifacts
- Verifier pre-check: cross-file contract consistency before running tests
- Generator context slimmed: upstream_constraints + retry_hint injection

Code quality:
- orchestrator.py run() split into 5 private methods (410->253 lines)
- Full type annotations (Optional[DebugSubagent], Callable types)
- __all__ added to 7 core modules
- pyproject.toml: license fixed, ruff + mypy configured
- TUI: 30+ event icons, Server: /api/manifest endpoint
- STATUS.md rewritten: concise, English, professional format

451/451 tests green, 27 new tests for SearchSubagent+Manifest.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-06 17:08:08 +08:00
Val-sss
c072a40e11 feat: TaskCompiler WorktreeManager隔离执行
- task_compiler.py: 新增WorktreeManager,并行任务在独立工作目录执行

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-06 15:01:36 +08:00
Val-sss
64f1333750 feat: Generator upstream注入 + SearchSubagent错误驱动搜索
- generator.py: 注入upstream_summary结构化上下文到Generator prompt
- search_subagent.py: 错误驱动搜索子代理(按error_type精准搜索)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-06 15:00:56 +08:00
Val-sss
d00688728a feat: RIG模块补充 — upstream_summary结构化 + ConsistencyChecker + Gate/Locator rig引导
v1.3.0遗留的RIG模块代码,与v1.4.0一起提交:
- context.py: upstream_summary从str改为dict结构化
- gate.py: 新增rig.json引导提示
- orchestrator.py: 上游patch结构化提取+注入
- upstream_manifest.py: 上游结果结构化提取器
- consistency_checker.py: 前后端API一致性检查
- test_rig_modules.py: 29个RIG模块测试

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-06 14:59:57 +08:00
Val-sss
a502c9db63 feat: v1.4.0 多语言AST + FastAPI Server + Textual TUI + VSCode插件
三个模块按顺序实施,424测试全绿:

模块A - 多语言支持:
- ast-grep预定义模板查询(LLM只填参数不写pattern)
- TreeSitterParser扩展支持JS/TS/Go/Rust/Java(可选依赖)
- 多语言Verifier(jest/go test/cargo test/mvn test)
- 4个新SKILL.md(golang/typescript/rust/java)

模块B - Server + TUI:
- FastAPI + SSE事件流,端口7355
- kwcode serve命令 + kwcode --tui选项
- Textual TUI(文件树+事件流+输入框)
- pipeline_factory共享构建

模块C - VSCode插件:
- 薄客户端连接kwcode server
- SSE事件流 + Webview面板
- 文件保存触发RIG刷新

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-06 14:57:16 +08:00
YonghaoZhao722
dad0148950 fix: normalize file paths in DocReader cache for cross-platform compatibility
Resolves Windows test failure where short path format (RUNNER~1) didn't match
long path format (runneradmin) in cache lookups. Also fixes macOS symlink
issues (/var vs /private/var).

Changes:
- Use path.resolve() for cache keys in DocReader._read_file
- Update test to use resolved paths for assertion

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 14:02:35 +08:00
Val-sss
f6af3845df chore: bump version to 1.3.0 for PyPI release
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
v1.3.0
2026-05-06 13:42:59 +08:00
Val-sss
0f3c9e6e61 feat: v1.3.0 架构升级 — EventBus/ToolGateway/错误策略路由/认知门控/渐进压缩/Wink自修复/SearchRouter
10个模块实现:
- EventBus 统一事件总线(append-only日志+replay)
- ToolGateway 专家权限隔离(deny-first+文件缓存)
- 错误策略路由(按error_type切换重试序列+import_fixer确定性修复)
- CognitiveGate 认知门控(patch行数递减检测边际收益递减)
- GraduatedCompactor 3层渐进压缩(70%/85%/95%)
- Plan自动触发(hard任务自动生成计划)
- Worktree隔离(/multi并行任务文件隔离)
- Speculative Prefetch(Locator后台预读文件)
- SearchRouter意图感知搜索(arxiv/S2/GitHub/PyPI/Open-Meteo零key)
- Wink自修复监控(偏离检测+课程纠正)

搜索层网络保护:
- DDG为主SearXNG可选,不自动拉Docker
- search_enabled开关,内网用户可完全禁用网络请求
- 所有搜索异常静默处理不阻塞流水线

357/357 tests passing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-06 13:39:00 +08:00
Val-sss
955768f364 docs: update STATUS.md with P2 completion
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-06 12:10:16 +08:00
Val-sss
d3d85c804c feat: P2 watchdog + gate accuracy report; remove .bak file
- P2-1: Task-level watchdog (300s timeout via threading.Timer, auto-abort stuck tasks)
- P2-2: Gate routing accuracy report (/stats command, per-expert_type success rate)
- Remove vision_expert.py.bak (keep vision_expert.py as intended feature)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-06 11:54:18 +08:00
Val-sss
ce8646f57e feat: P0+P1 optimization — circuit breaker, gate confidence, experience replay, session state
- P0-1: Verifier structured error output (error_type/file/line/message extraction)
- P0-2: Circuit breaker + scope narrowing (syntax/import fast-break, 3x same-error hard-break, auto-narrow on 2nd failure)
- P0-3: Gate confidence estimation (keyword signal scoring, low-confidence retry reduction)
- P1-1: Experience Replay via BM25 trajectory similarity search
- P1-2: SessionState multi-turn coherence + attention decay countermeasure
- P1-3: Locator minimal context extraction (function boundary detection, comment stripping, 60-line cap)
- Add CONTRIBUTING.md with architecture red lines and PR standards
- Update README contributing section with quick reference

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-06 11:39:45 +08:00
ValHuang
e89a954d96 Merge pull request #4 from dashitongzhi/master
feat: add multimodal vision expert for image analysis
2026-05-06 10:00:20 +08:00
ValHuang
723bd54650 Merge pull request #9 from YonghaoZhao722/feature/ci-multiplatform-tests-v2
feat: add multi-platform CI testing matrix
2026-05-06 09:43:56 +08:00
dashitongzhi
d835d9b640 test: add unit tests for vision expert routing and config
- _should_execute_code: compound phrase matching (10 tests)
- _is_codegen_task: verb+target combos (10 tests)
- _vision_api_configured: requires URL AND MODEL (5 tests)
- temp directory lifecycle and cleanup (4 tests)
- media-type detection via magic bytes and base64 (12 tests)
- _validate_image edge cases (4 tests)
- run routing: no image / too many images (2 tests)
- LLM fallback to Anthropic API (2 tests)
- _media_type_for_path fallback chain (3 tests)
- init, validate_image_path, get_image_info (6 tests)

Total: 59 test cases, all passing.
2026-05-01 22:45:35 +08:00
dashitongzhi
b8d9abf630 docs: fix API docs and remove unused dependency
- README: remove misleading OpenAI /v1/chat/completions endpoint reference
  for gpt-4o vision example; code uses Anthropic Messages API format only
- pyproject.toml: remove unused pyperclip from multimodal extra
  (clipboard uses PIL.ImageGrab, not pyperclip)
2026-05-01 22:41:07 +08:00
dashitongzhi
a3a133df2a merge: sync with upstream/master 2026-05-01 22:40:47 +08:00
ValHuang
4989de3900 Merge pull request #8 from YonghaoZhao722/feature/mac-platform-support
feat: add macOS platform support with Apple Silicon GPU detection
2026-05-01 12:17:39 +08:00
ValHuang
3ebbc139bb Merge pull request #10 from YonghaoZhao722/feature/error-handling-improvements
feat: improve error handling user experience
2026-05-01 12:17:01 +08:00
YonghaoZhao722
0ee3d989a4 feat: improve error handling user experience
Enhanced 4 critical error messages with better context and actionable solutions:

1. Model call failure:
   - Add detailed error context
   - Provide 4 solution steps (check model, switch model, verify API, check network)
   - Include specific commands for each solution

2. Execution exception:
   - Add debugging suggestions
   - Show log file path (~/.kwcode/kwcode.log)
   - Include full stack trace for troubleshooting
   - Suggest /plan mode and GitHub issue reporting

3. Directory not found:
   - Show attempted path
   - Provide path checking tips
   - Display current directory for reference
   - Include usage example

4. API configuration error:
   - Show complete usage with examples
   - List common API endpoints (Ollama, DeepSeek, SiliconFlow)
   - Clarify temp vs default commands

All error messages now include:
- Clear context (what happened)
- Actionable solutions (what to do)
- Specific examples (how to do it)
- Visual improvements (icons and colors)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-30 19:23:26 +08:00
YonghaoZhao722
97e5709fbb feat: add multi-platform CI testing matrix
- Add GitHub Actions workflow for cross-platform testing
- Test matrix: Ubuntu/macOS/Windows × Python 3.10/3.11/3.12
- Run full test suite on all platforms
- Verify basic functionality (GPU detection, memory info)
- Update README badge to show CI status

Improves platform compatibility confidence and catches platform-specific issues early.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-30 19:23:08 +08:00
YonghaoZhao722
d9b51b4b29 feat: add macOS platform support with Apple Silicon GPU detection
- Add macOS GPU detection using sysctl hw.model
- Display "Apple Silicon GPU" for Mac users
- Preserve NVIDIA GPU detection for Windows/Linux
- Add macOS installation guide in README
- Document Apple Silicon unified memory architecture

Fixes platform compatibility issue where Mac users see no GPU info.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-30 19:21:52 +08:00
Val-sss
8b39161a44 docs: update README version badge to v1.0.9
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-30 12:44:38 +08:00
Val-sss
6f35ddbed9 fix: CI add --skip-existing and bump to v1.0.9
v1.0.8 was already uploaded manually, CI got 400 Bad Request.
Add --skip-existing flag and bump version for next release.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
v1.0.9
2026-04-30 12:42:08 +08:00
Val-sss
50e5b22a2e fix: pin setuptools<78 in CI to avoid license classifier error
GitHub Actions uses latest setuptools which rejects License classifiers.
Pin to <78 to maintain compatibility.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
v1.0.8
2026-04-30 12:39:32 +08:00
Val-sss
a99dcfe255 fix: move tree-sitter back to base deps (pre-built wheels available)
tree-sitter and tree-sitter-python provide pre-built wheels for
Windows/Mac/Linux on Python 3.10-3.12, so no compiler needed.
AST engine is now always installed with base package.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-30 12:16:23 +08:00
dashitongzhi
e9f3937369 refactor: vision expert second review + remove hardcoded credentials
- Remove hardcoded API URL and model defaults
- Require KWCODE_VISION_API_URL, _API_KEY, _MODEL env vars
- Clear error message with setup instructions when unconfigured
- README: add Vision API configuration guide with model examples
- VisionExpert.run() handles multi-image internally
- MAX_IMAGE_BYTES (20MB) and MAX_IMAGE_COUNT (20) limits
- Magic bytes detection for unknown image formats
- Subprocess-based code execution with proper error reporting
2026-04-30 12:10:14 +08:00
dashitongzhi
1488834e71 fix: vision expert improvements from code review
- Multi-image support: iterate all images, track failures per image
- Media type detection: suffix-based with base64 fallback
- Ollama native vision support (images field)
- URLError/TimeoutError handling in API calls
- Shell injection prevention (shlex.quote)
- Path validation: expanduser + is_file checks
- Gate: explicit [图片:] marker routing to vision
- Context: image_paths/image_path fields on TaskContext
- CLI: vision spinner, skip decompose/plan/search for vision
- CLI: resolve relative image paths against project root
- CLI: fix no_search propagation in REPL
2026-04-30 11:56:44 +08:00
dashitongzhi
b2e9d33164 feat: add multimodal vision expert for image analysis and code generation
- VisionExpert class: image analysis + code generation from images
- Anthropic Messages API integration (mimo-v2-omni model)
- Gate classifier: new 'vision' expert type
- Orchestrator: vision pipeline with image_paths support
- CLI: /paste (clipboard) and /image (file) commands
- Optional deps: pip install kwcode[multimodal] (Pillow + pyperclip)
- Architecture diagram in docs/
2026-04-30 11:46:49 +08:00
Val-sss
edd7e5d1ee feat: publish to PyPI + fix installation issues
- Restructure deps: move llama-cpp-python/tree-sitter to optional
  (base install is pure Python, no compiler needed)
- Add __main__.py for pipx/python -m support
- Add GitHub Actions auto-publish on tag push
- Fix install scripts: correct package name, remove Ollama check,
  add pipx priority
- Wrap ast_engine imports in try/except for graceful degradation
- Published v1.0.7 to PyPI: pip install kwcode

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
v1.0.7
2026-04-30 11:45:56 +08:00
Val-sss
a88e0c18b3 docs: one line per day in README changelog 2026-04-30 08:31:15 +08:00
Val-sss
efa3b15183 docs: simplify README changelog to daily summary
Consolidate per-version entries into per-day summaries for readability.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-30 08:29:47 +08:00
Val-sss
314972b9b9 fix: PPT misclassification + SSH ops guidance
1. Gate _postprocess: expand OFFICE_FORMATS to include "ppt", "演示文稿", "汇报"
   (was only matching ".pptx" and "ppt模板", missing common Chinese expressions)

2. Gate prompt: add PPT/幻灯片 examples + negative example (HTML展示≠office)

3. ChatExpert system prompt: add ops guidance — when user asks SSH/docker/nginx,
   output command instructions with /bash hint instead of executing directly

Verified with qwen3:8b: 4/4 PPT cases now correctly route to office.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-30 08:26:53 +08:00
Val-sss
c316feb833 docs: add round 2 walkthrough report (10 new scenarios, no fixes)
Findings:
- 2 serious: SSH/ops not routable (design gap), PPT misclassified (prompt gap)
- 3 acceptable: search boundary, difficulty boundary, hint quality
- Framework mechanisms all working correctly (auto_decompose 4/4, Gate 8/10)
- Issues are coverage/prompt gaps, not architecture bugs

Decision needed from user:
1. SSH: new ops expert_type vs extend ChatExpert?
2. PPT: add trigger words to Gate prompt (risk of over-triggering)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-30 07:27:12 +08:00
Val-sss
7b6e853a55 docs: update CHANGELOG and README for v1.0.7
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-30 03:54:12 +08:00
Val-sss
e32a43982b fix: wire up 4 remaining walkthrough issues
1. TrajectoryCollector.get_by_expert() — method was missing, ab_tester
   called it on expert graduation. Added to trajectory_collector.py.

2. auto_decompose integrated into _run_task() — hard tasks now auto-split
   via Planner.auto_decompose() + _handle_multi_with_tasks() helper.

3. Pre-search (P1-B) wired into _run_task() — Gate needs_search=true
   triggers QueryGenerator + ddg_search before orchestrator.run(),
   results passed via pre_search_results parameter.

4. session_md.save_session() wired into REPL exit — SESSION.md now
   written on vram_watcher.stop() with recent task summaries.

All 4 issues from WALKTHROUGH_REPORT.md resolved.
311 tests passing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-30 03:52:33 +08:00