@mycodemap/mycodemap 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (243) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/README.md +241 -67
  3. package/dist/cli/commands/ci.d.ts +7 -1
  4. package/dist/cli/commands/ci.d.ts.map +1 -1
  5. package/dist/cli/commands/ci.js +38 -0
  6. package/dist/cli/commands/ci.js.map +1 -1
  7. package/dist/cli/commands/export.d.ts +6 -0
  8. package/dist/cli/commands/export.d.ts.map +1 -0
  9. package/dist/cli/commands/export.js +108 -0
  10. package/dist/cli/commands/export.js.map +1 -0
  11. package/dist/cli/commands/generate.d.ts.map +1 -1
  12. package/dist/cli/commands/generate.js +96 -0
  13. package/dist/cli/commands/generate.js.map +1 -1
  14. package/dist/cli/commands/server.d.ts +9 -0
  15. package/dist/cli/commands/server.d.ts.map +1 -0
  16. package/dist/cli/commands/server.js +68 -0
  17. package/dist/cli/commands/server.js.map +1 -0
  18. package/dist/cli/index.js +22 -1
  19. package/dist/cli/index.js.map +1 -1
  20. package/dist/cli-new/commands/export.d.ts +15 -0
  21. package/dist/cli-new/commands/export.d.ts.map +1 -0
  22. package/dist/cli-new/commands/export.js +107 -0
  23. package/dist/cli-new/commands/export.js.map +1 -0
  24. package/dist/cli-new/commands/query.d.ts +14 -0
  25. package/dist/cli-new/commands/query.d.ts.map +1 -0
  26. package/dist/cli-new/commands/query.js +120 -0
  27. package/dist/cli-new/commands/query.js.map +1 -0
  28. package/dist/cli-new/commands/server.d.ts +13 -0
  29. package/dist/cli-new/commands/server.d.ts.map +1 -0
  30. package/dist/cli-new/commands/server.js +94 -0
  31. package/dist/cli-new/commands/server.js.map +1 -0
  32. package/dist/cli-new/index.d.ts +11 -0
  33. package/dist/cli-new/index.d.ts.map +1 -0
  34. package/dist/cli-new/index.js +63 -0
  35. package/dist/cli-new/index.js.map +1 -0
  36. package/dist/cli-new/types/index.d.ts +88 -0
  37. package/dist/cli-new/types/index.d.ts.map +1 -0
  38. package/dist/cli-new/types/index.js +7 -0
  39. package/dist/cli-new/types/index.js.map +1 -0
  40. package/dist/domain/entities/CodeGraph.d.ts +134 -0
  41. package/dist/domain/entities/CodeGraph.d.ts.map +1 -0
  42. package/dist/domain/entities/CodeGraph.js +316 -0
  43. package/dist/domain/entities/CodeGraph.js.map +1 -0
  44. package/dist/domain/entities/Dependency.d.ts +78 -0
  45. package/dist/domain/entities/Dependency.d.ts.map +1 -0
  46. package/dist/domain/entities/Dependency.js +132 -0
  47. package/dist/domain/entities/Dependency.js.map +1 -0
  48. package/dist/domain/entities/Module.d.ts +75 -0
  49. package/dist/domain/entities/Module.d.ts.map +1 -0
  50. package/dist/domain/entities/Module.js +151 -0
  51. package/dist/domain/entities/Module.js.map +1 -0
  52. package/dist/domain/entities/Project.d.ts +50 -0
  53. package/dist/domain/entities/Project.d.ts.map +1 -0
  54. package/dist/domain/entities/Project.js +99 -0
  55. package/dist/domain/entities/Project.js.map +1 -0
  56. package/dist/domain/entities/Symbol.d.ts +75 -0
  57. package/dist/domain/entities/Symbol.d.ts.map +1 -0
  58. package/dist/domain/entities/Symbol.js +130 -0
  59. package/dist/domain/entities/Symbol.js.map +1 -0
  60. package/dist/domain/events/DomainEvent.d.ts +76 -0
  61. package/dist/domain/events/DomainEvent.d.ts.map +1 -0
  62. package/dist/domain/events/DomainEvent.js +153 -0
  63. package/dist/domain/events/DomainEvent.js.map +1 -0
  64. package/dist/domain/index.d.ts +10 -0
  65. package/dist/domain/index.d.ts.map +1 -0
  66. package/dist/domain/index.js +18 -0
  67. package/dist/domain/index.js.map +1 -0
  68. package/dist/domain/repositories/CodeGraphRepository.d.ts +58 -0
  69. package/dist/domain/repositories/CodeGraphRepository.d.ts.map +1 -0
  70. package/dist/domain/repositories/CodeGraphRepository.js +37 -0
  71. package/dist/domain/repositories/CodeGraphRepository.js.map +1 -0
  72. package/dist/domain/services/CodeGraphBuilder.d.ts +50 -0
  73. package/dist/domain/services/CodeGraphBuilder.d.ts.map +1 -0
  74. package/dist/domain/services/CodeGraphBuilder.js +121 -0
  75. package/dist/domain/services/CodeGraphBuilder.js.map +1 -0
  76. package/dist/infrastructure/parser/implementations/GoParser.d.ts +25 -0
  77. package/dist/infrastructure/parser/implementations/GoParser.d.ts.map +1 -0
  78. package/dist/infrastructure/parser/implementations/GoParser.js +158 -0
  79. package/dist/infrastructure/parser/implementations/GoParser.js.map +1 -0
  80. package/dist/infrastructure/parser/implementations/PythonParser.d.ts +30 -0
  81. package/dist/infrastructure/parser/implementations/PythonParser.d.ts.map +1 -0
  82. package/dist/infrastructure/parser/implementations/PythonParser.js +201 -0
  83. package/dist/infrastructure/parser/implementations/PythonParser.js.map +1 -0
  84. package/dist/infrastructure/parser/implementations/TypeScriptParser.d.ts +63 -0
  85. package/dist/infrastructure/parser/implementations/TypeScriptParser.d.ts.map +1 -0
  86. package/dist/infrastructure/parser/implementations/TypeScriptParser.js +420 -0
  87. package/dist/infrastructure/parser/implementations/TypeScriptParser.js.map +1 -0
  88. package/dist/infrastructure/parser/index.d.ts +13 -0
  89. package/dist/infrastructure/parser/index.d.ts.map +1 -0
  90. package/dist/infrastructure/parser/index.js +32 -0
  91. package/dist/infrastructure/parser/index.js.map +1 -0
  92. package/dist/infrastructure/parser/interfaces/ParserBase.d.ts +124 -0
  93. package/dist/infrastructure/parser/interfaces/ParserBase.d.ts.map +1 -0
  94. package/dist/infrastructure/parser/interfaces/ParserBase.js +200 -0
  95. package/dist/infrastructure/parser/interfaces/ParserBase.js.map +1 -0
  96. package/dist/infrastructure/parser/registry/ParserRegistry.d.ts +68 -0
  97. package/dist/infrastructure/parser/registry/ParserRegistry.d.ts.map +1 -0
  98. package/dist/infrastructure/parser/registry/ParserRegistry.js +116 -0
  99. package/dist/infrastructure/parser/registry/ParserRegistry.js.map +1 -0
  100. package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.d.ts +44 -0
  101. package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.d.ts.map +1 -0
  102. package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.js +129 -0
  103. package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.js.map +1 -0
  104. package/dist/infrastructure/repositories/index.d.ts +3 -0
  105. package/dist/infrastructure/repositories/index.d.ts.map +1 -0
  106. package/dist/infrastructure/repositories/index.js +7 -0
  107. package/dist/infrastructure/repositories/index.js.map +1 -0
  108. package/dist/infrastructure/storage/StorageFactory.d.ts +53 -0
  109. package/dist/infrastructure/storage/StorageFactory.d.ts.map +1 -0
  110. package/dist/infrastructure/storage/StorageFactory.js +150 -0
  111. package/dist/infrastructure/storage/StorageFactory.js.map +1 -0
  112. package/dist/infrastructure/storage/adapters/FileSystemStorage.d.ts +52 -0
  113. package/dist/infrastructure/storage/adapters/FileSystemStorage.d.ts.map +1 -0
  114. package/dist/infrastructure/storage/adapters/FileSystemStorage.js +315 -0
  115. package/dist/infrastructure/storage/adapters/FileSystemStorage.js.map +1 -0
  116. package/dist/infrastructure/storage/adapters/KuzuDBStorage.d.ts +52 -0
  117. package/dist/infrastructure/storage/adapters/KuzuDBStorage.d.ts.map +1 -0
  118. package/dist/infrastructure/storage/adapters/KuzuDBStorage.js +235 -0
  119. package/dist/infrastructure/storage/adapters/KuzuDBStorage.js.map +1 -0
  120. package/dist/infrastructure/storage/adapters/MemoryStorage.d.ts +37 -0
  121. package/dist/infrastructure/storage/adapters/MemoryStorage.d.ts.map +1 -0
  122. package/dist/infrastructure/storage/adapters/MemoryStorage.js +229 -0
  123. package/dist/infrastructure/storage/adapters/MemoryStorage.js.map +1 -0
  124. package/dist/infrastructure/storage/adapters/Neo4jStorage.d.ts +49 -0
  125. package/dist/infrastructure/storage/adapters/Neo4jStorage.d.ts.map +1 -0
  126. package/dist/infrastructure/storage/adapters/Neo4jStorage.js +222 -0
  127. package/dist/infrastructure/storage/adapters/Neo4jStorage.js.map +1 -0
  128. package/dist/infrastructure/storage/index.d.ts +6 -0
  129. package/dist/infrastructure/storage/index.d.ts.map +1 -0
  130. package/dist/infrastructure/storage/index.js +13 -0
  131. package/dist/infrastructure/storage/index.js.map +1 -0
  132. package/dist/infrastructure/storage/interfaces/StorageBase.d.ts +76 -0
  133. package/dist/infrastructure/storage/interfaces/StorageBase.d.ts.map +1 -0
  134. package/dist/infrastructure/storage/interfaces/StorageBase.js +116 -0
  135. package/dist/infrastructure/storage/interfaces/StorageBase.js.map +1 -0
  136. package/dist/interface/config/index.d.ts +102 -0
  137. package/dist/interface/config/index.d.ts.map +1 -0
  138. package/dist/interface/config/index.js +7 -0
  139. package/dist/interface/config/index.js.map +1 -0
  140. package/dist/interface/types/index.d.ts +425 -0
  141. package/dist/interface/types/index.d.ts.map +1 -0
  142. package/dist/interface/types/index.js +8 -0
  143. package/dist/interface/types/index.js.map +1 -0
  144. package/dist/interface/types/parser.d.ts +103 -0
  145. package/dist/interface/types/parser.d.ts.map +1 -0
  146. package/dist/interface/types/parser.js +7 -0
  147. package/dist/interface/types/parser.js.map +1 -0
  148. package/dist/interface/types/storage.d.ts +98 -0
  149. package/dist/interface/types/storage.d.ts.map +1 -0
  150. package/dist/interface/types/storage.js +7 -0
  151. package/dist/interface/types/storage.js.map +1 -0
  152. package/dist/orchestrator/test-linker.js +1 -1
  153. package/dist/orchestrator/test-linker.js.map +1 -1
  154. package/dist/server/CodeMapServer.d.ts +51 -0
  155. package/dist/server/CodeMapServer.d.ts.map +1 -0
  156. package/dist/server/CodeMapServer.js +146 -0
  157. package/dist/server/CodeMapServer.js.map +1 -0
  158. package/dist/server/handlers/AnalysisHandler.d.ts +82 -0
  159. package/dist/server/handlers/AnalysisHandler.d.ts.map +1 -0
  160. package/dist/server/handlers/AnalysisHandler.js +196 -0
  161. package/dist/server/handlers/AnalysisHandler.js.map +1 -0
  162. package/dist/server/handlers/QueryHandler.d.ts +57 -0
  163. package/dist/server/handlers/QueryHandler.d.ts.map +1 -0
  164. package/dist/server/handlers/QueryHandler.js +260 -0
  165. package/dist/server/handlers/QueryHandler.js.map +1 -0
  166. package/dist/server/index.d.ts +7 -0
  167. package/dist/server/index.d.ts.map +1 -0
  168. package/dist/server/index.js +13 -0
  169. package/dist/server/index.js.map +1 -0
  170. package/dist/server/routes/api.d.ts +8 -0
  171. package/dist/server/routes/api.d.ts.map +1 -0
  172. package/dist/server/routes/api.js +372 -0
  173. package/dist/server/routes/api.js.map +1 -0
  174. package/dist/server/types/index.d.ts +171 -0
  175. package/dist/server/types/index.d.ts.map +1 -0
  176. package/dist/server/types/index.js +7 -0
  177. package/dist/server/types/index.js.map +1 -0
  178. package/dist/types/index.d.ts +6 -372
  179. package/dist/types/index.d.ts.map +1 -1
  180. package/dist/types/index.js +9 -3
  181. package/dist/types/index.js.map +1 -1
  182. package/docs/AI_ASSISTANT_SETUP.md +68 -0
  183. package/docs/PUBLISHING.md +162 -0
  184. package/docs/README.md +37 -0
  185. package/docs/SETUP_GUIDE.md +91 -5
  186. package/docs/ai-guide/COMMANDS.md +369 -0
  187. package/docs/ai-guide/INTEGRATION.md +513 -0
  188. package/docs/ai-guide/OUTPUT.md +465 -0
  189. package/docs/ai-guide/PATTERNS.md +409 -0
  190. package/docs/ai-guide/PROMPTS.md +414 -0
  191. package/docs/ai-guide/QUICKSTART.md +114 -0
  192. package/docs/ai-guide/README.md +66 -0
  193. package/docs/archive/AI_INTEGRATION_GUIDE_ARCHIVED.md +7 -1
  194. package/docs/archive/ARCHIVE.md +39 -0
  195. package/docs/archive/MYCLAUDE_GUIDE.md +305 -0
  196. package/docs/archive/PUBLISH_NPM_DESIGN_V1.md +6 -0
  197. package/docs/archive/PUBLISH_NPM_DESIGN_V2.md +6 -0
  198. package/docs/archive/README.md +29 -0
  199. package/docs/archive/TASK_DESIGN_COVERAGE_REPORT.md +6 -0
  200. package/docs/archive/TEST_SUMMARY.md +140 -0
  201. package/docs/archive/comprehensive_test_report.md +337 -0
  202. package/docs/{CI_GATEWAY_DESIGN.md → archive/design-docs/CI_GATEWAY_DESIGN.md} +6 -0
  203. package/docs/{PUBLISH_NPM_DESIGN_FINAL.md → archive/design-docs/PUBLISH_NPM_DESIGN_FINAL.md} +7 -1
  204. package/docs/{REFACTOR_ARCHITECTURE_OVERVIEW.md → archive/design-docs/REFACTOR_ARCHITECTURE_OVERVIEW.md} +8 -2
  205. package/docs/{REFACTOR_CONFIDENCE_DESIGN.md → archive/design-docs/REFACTOR_CONFIDENCE_DESIGN.md} +6 -0
  206. package/docs/{REFACTOR_GIT_ANALYZER_DESIGN.md → archive/design-docs/REFACTOR_GIT_ANALYZER_DESIGN.md} +8 -2
  207. package/docs/{REFACTOR_ORCHESTRATOR_DESIGN.md → archive/design-docs/REFACTOR_ORCHESTRATOR_DESIGN.md} +6 -0
  208. package/docs/{REFACTOR_RESULT_FUSION_DESIGN.md → archive/design-docs/REFACTOR_RESULT_FUSION_DESIGN.md} +6 -0
  209. package/docs/{REFACTOR_TEST_LINKER_DESIGN.md → archive/design-docs/REFACTOR_TEST_LINKER_DESIGN.md} +6 -0
  210. package/docs/archive/myclaude.md +1084 -0
  211. package/docs/archive/plans/2026-03-14-go-language-support-design.md +92 -0
  212. package/docs/{REFACTOR_REQUIREMENTS.md → archive/product-specs/REFACTOR_REQUIREMENTS.md} +11 -5
  213. package/docs/archive/scenario-2-deps-analysis.md +353 -0
  214. package/docs/archive/test-report-symbol-search.md +384 -0
  215. package/docs/archive/test-scenario-4-complexity-analysis.md +460 -0
  216. package/docs/archive/test_report_scenario5.md +615 -0
  217. package/docs/archive/test_scenario_3_impact_analysis_report.md +520 -0
  218. package/docs/design-docs/README.md +26 -0
  219. package/docs/exec-plans/MVP3-IMPLEMENTATION-ROADMAP.md +524 -0
  220. package/docs/exec-plans/README.md +29 -0
  221. package/docs/exec-plans/active/.gitkeep +0 -0
  222. package/docs/exec-plans/completed/.gitkeep +0 -0
  223. package/docs/{plans/POST_TASK_PLAN.md → exec-plans/completed/2026-03-03-post-task-plan.md} +9 -3
  224. package/docs/exec-plans/completed/harness-engineering-rollout.md +184 -0
  225. package/docs/exec-plans/tech-debt/.gitkeep +0 -0
  226. package/docs/exec-plans/tech-debt/2026-03-15-lint-guardrail-gap.md +30 -0
  227. package/docs/generated/README.md +19 -0
  228. package/docs/product-specs/MVP3-ARCHITECTURE-COMPARISON.md +504 -0
  229. package/docs/product-specs/MVP3-ARCHITECTURE-REDESIGN-PRD.md +322 -0
  230. package/docs/product-specs/MVP3-ARCHITECTURE-REDESIGN-TECH-PRD.md +1374 -0
  231. package/docs/product-specs/README.md +22 -0
  232. package/docs/references/README.md +15 -0
  233. package/docs/references/tmp.md +527 -0
  234. package/docs/rules/README.md +16 -0
  235. package/docs/rules/architecture-guardrails.md +349 -0
  236. package/docs/rules/code-quality-redlines.md +321 -0
  237. package/docs/rules/deployment.md +23 -0
  238. package/docs/rules/engineering-with-codex-openai.md +202 -0
  239. package/docs/rules/testing.md +73 -0
  240. package/docs/rules/validation.md +39 -0
  241. package/package.json +19 -6
  242. package/docs/OMC_TEAM_DEBUG_REPORT.md +0 -285
  243. /package/docs/{plans/archive → exec-plans/completed}/2026-03-03-deps-path-extension-fix.md +0 -0
@@ -0,0 +1,202 @@
1
+ # 基于 Codex 的工程落地规则
2
+
3
+ > 目标:把 OpenAI《Engineering with Codex》里的高信号原则,转成当前 CodeMap 仓库可执行的开发与交付规则。
4
+ > 适用范围:本仓库内使用 Codex / Claude / 其他 agent 进行分析、修改、验证、提交流程。
5
+
6
+ ## 1. 先说边界
7
+
8
+ - 本项目当前主要交付形态是 npm 包与 CLI,不是长期运行的 Web 服务。
9
+ - 因此这里强调的是 `CLI` / `CI` 护栏,而不是 preview 环境或部署沙箱。
10
+ - 涉及长期稳定知识时,优先写入仓库文档与生成物;不要把关键约束留在聊天记录、口头约定或临时笔记里。
11
+
12
+ ## 2. 核心原则
13
+
14
+ - 人类掌舵,agent 执行:人类负责定义目标、限制、DoD、依赖和验收;agent 负责检索、实现、验证和补文档。
15
+ - 地图优于手册:入口文档保持短小,只做路由;细节下沉到 `ARCHITECTURE.md`、`docs/rules/`、`docs/design-docs/`、`docs/exec-plans/`。
16
+ - 仓库是记录系统:规则、设计权衡、执行计划、生成产物、失败复盘都应进入版本控制。
17
+ - 检索优先于记忆:优先使用 `node dist/cli/index.js query|analyze|deps|impact` 获取事实,再回退到 `rg`、`find`、直接读文件。
18
+ - 规则优先编码:重复出现的评审意见、输出约束、结构边界,优先落为 CLI 子命令、hook、CI 检查或生成契约,而不是停留在 prose。
19
+
20
+ ## 3. 渐进式上下文披露(Harness 规范)
21
+
22
+ **原则**:不向 AI 提供超过当前任务决策所需的信息,避免注意力稀释。
23
+
24
+ **上下文层级**(AI 按优先级读取):
25
+
26
+ 1. **T0-地图层**(始终提供):架构说明、类型定义、关键约束文件
27
+ - `AGENTS.md`(仓库级强约束)
28
+ - `CLAUDE.md`(执行手册)
29
+ - `src/types/index.ts`(核心类型)
30
+
31
+ 2. **T1-任务相关层**(动态检索):通过 CodeMap CLI 或文件路径匹配提供
32
+ - 当前修改文件的依赖图谱(直接上下游)
33
+ - 相关测试文件(同名 `.test.ts` 或 `.spec.ts`)
34
+ - 接口定义(如果实现类,提供接口)
35
+
36
+ 3. **T2-按需获取层**(工具调用):AI 明确请求时才提供
37
+ - 具体业务逻辑实现细节
38
+ - 历史提交记录
39
+ - 第三方库文档
40
+
41
+ **禁止行为**:不要将整个 `node_modules` 目录或上千行无关代码粘贴给 AI。
42
+
43
+ ## 4. 当前项目的 CLI 护栏
44
+
45
+ - 仓库内调试与验证优先使用 `node dist/cli/index.js <command>`,因为当前真实 CLI 入口是 `dist/cli/index.js`。
46
+ - 需求澄清、影响分析、引用定位优先走 `query`、`analyze`、`deps`、`impact`,不要直接全仓漫游。
47
+ - 修改 `analyze`、`query`、`ci`、`workflow` 等高影响命令时,至少验证:
48
+ - `--help` 输出与文档示例一致;
49
+ - 受影响的真实子命令可以在当前仓库运行;
50
+ - 若涉及机器输出,`--output-mode machine --json` 仍保持纯 JSON 契约。
51
+ - 若改动会影响 agent 执行手册、README 示例、测试事实或入口路由,先执行 `npm run docs:check`。
52
+ - 若希望通过统一 CLI 护栏入口执行同一检查,使用 `node dist/cli/index.js ci check-docs-sync`。
53
+ - 涉及发布边界时,再补 `npm run build` 与 `npm run validate-pack`;不要把本地临时产物当成发布事实。
54
+
55
+ ## 5. 当前项目的 CI 护栏
56
+
57
+ - 本地护栏:
58
+ - `.githooks/pre-commit` 会执行变更相关测试、文件头检查,并尝试生成 AI feed。
59
+ - 当变更涉及 README、`docs/`、CLI 入口、测试配置或 CI 配置时,`.githooks/pre-commit` 还会执行 `npm run docs:check`。
60
+ - `.githooks/commit-msg` 会校验 `[TAG] scope: message` 格式与单次 commit 文件数量。
61
+ - 服务端护栏:
62
+ - `.github/workflows/ci-gateway.yml` 会执行 `npm run docs:check`、`npm run typecheck`、`npm test`、`npm run build`,然后再通过 `node dist/cli/index.js ci ...` 执行 `check-docs-sync`、`check-commits`、`check-commit-size`、`check-headers`、`assess-risk`、`check-output-contract` 与 AI feed 同步检查。
63
+ - `.github/workflows/publish.yml` 会在发布前执行 `npm test` 与 `npm run build`。
64
+ - 仓库协议仍然禁止通过 `--no-verify`、关闭 hook、放宽阈值、删除检查项来"修复"问题。
65
+
66
+ ## 6. 代码生成红线详细规范(Harness 规范)
67
+
68
+ AI 生成代码时,以下模式触发**硬性阻断**:
69
+
70
+ | 红线规则 | 检测方式 | 阻断标准 | 修复策略 |
71
+ |---------|---------|---------|---------|
72
+ | **敏感信息硬编码** | 正则检测 `"password"`, `"secret"`, `"api_key"`, `"token"` 字面量 | 生产代码中出现明文凭证 | 替换为 `process.env.XXX` 读取 + env 类型声明 |
73
+ | **`any` 类型使用** | `tsc --noImplicitAny` + ESLint `@typescript-eslint/no-explicit-any` | 非边界文件使用 `any` | 推导具体类型或使用 `unknown` + 类型守卫 |
74
+ | **函数超过 50 行** | 代码行数统计(不含空行和注释) | 单函数 >50 行 | 拆分为子函数,保持单一职责 |
75
+ | **未处理 Promise** | ESLint `@typescript-eslint/no-floating-promises` | 异步调用无 `await` 或错误处理 | 添加 `await` 或 `.catch()` 处理 |
76
+ | **`console.log` 遗留** | ESLint `no-console` | 非调试代码包含 `console.log` | 使用 `src/cli/runtime-logger.ts` 替代 |
77
+ | **未使用 import** | ESLint `@typescript-eslint/no-unused-vars` | 存在未引用 import | 自动删除或标记为使用 |
78
+ | **缺少文件头** | `.githooks/pre-commit` 检查 | TS 源文件缺少 `[META]` 或 `[WHY]` | 添加标准文件头注释 |
79
+
80
+ ## 7. 依赖流向规则(Harness 规范)
81
+
82
+ **第一性原理**:业务逻辑必须与实现细节解耦,确保可测试性和技术栈可替换性。
83
+
84
+ 当前项目采用 **MVP3 分层架构**(从上至下依赖):
85
+
86
+ ```
87
+ ┌─────────────────────────────────────────────────────────────┐
88
+ │ CLI Layer │
89
+ │ src/cli/ - 命令行接口,注册命令、参数解析、用户交互 │
90
+ ├─────────────────────────────────────────────────────────────┤
91
+ │ Server Layer │
92
+ │ src/server/ - HTTP API 服务器,RESTful 端点,Handler 处理 │
93
+ ├─────────────────────────────────────────────────────────────┤
94
+ │ Domain Layer │
95
+ │ src/domain/ - 核心业务逻辑,领域实体与服务 │
96
+ │ - entities/: Project, Module, Symbol, Dependency, CodeGraph │
97
+ │ - services/: CodeGraphBuilder │
98
+ │ - events/: DomainEvent │
99
+ │ - repositories/: 仓库接口 │
100
+ ├─────────────────────────────────────────────────────────────┤
101
+ │ Infrastructure Layer │
102
+ │ src/infrastructure/ - 技术实现细节 │
103
+ │ - storage/: FileSystemStorage, MemoryStorage, KuzuDBStorage, Neo4jStorage
104
+ │ - parser/: TypeScriptParser, GoParser, PythonParser, ParserRegistry
105
+ │ - repositories/: CodeGraphRepositoryImpl │
106
+ ├─────────────────────────────────────────────────────────────┤
107
+ │ Interface Layer │
108
+ │ src/interface/ - 类型定义与契约,跨层共享的接口 │
109
+ │ - types/: 核心类型定义 │
110
+ │ - config/: 配置接口 │
111
+ └─────────────────────────────────────────────────────────────┘
112
+ ```
113
+
114
+ **分层依赖规则**(严格自上而下):
115
+ - CLI → Server → Domain → Infrastructure → Interface
116
+ - **禁止跨层依赖**(如 Domain 层不得导入 CLI 模块)
117
+ - 同层内可以相互依赖
118
+
119
+ **Enforcement 规则**:
120
+ 1. **Domain 层禁止导入**:CLI、Server 层模块
121
+ 2. **Infrastructure 层禁止导入**:CLI、Server、Domain 中的具体实现
122
+ 3. **Server 层禁止导入**:CLI 层模块
123
+ 4. **跨层调用必须通过接口**,依赖 Interface 层契约
124
+
125
+ **历史架构说明**:
126
+ - MVP3 之前的旧架构(cli→orchestrator→core→parser→generator)已完成迁移
127
+ - 原有 `src/orchestrator/` 部分功能已整合到 Server 层和 CLI 层
128
+ - 原有 `src/core/`、`src/parser/`、`src/generator/` 已迁移到 Domain/Infrastructure 层
129
+
130
+ **违规检测**:使用 `dependency-cruiser` 或 CodeMap 自身的 `deps` 命令检查跨层依赖。
131
+
132
+ **违规示例**:
133
+ ```typescript
134
+ // ❌ 违规:Domain 层直接依赖 Infrastructure 具体实现
135
+ // src/domain/services/CodeGraphBuilder.ts
136
+ import { FileSystemStorage } from '../infrastructure/storage/FileSystemStorage'; // 错误!
137
+
138
+ // ✅ 合规:通过 Interface 层契约依赖
139
+ // src/domain/services/CodeGraphBuilder.ts
140
+ import type { IStorage } from '../interface/types/storage'; // 正确:只依赖接口
141
+ ```
142
+
143
+ ## 8. 文档与知识落点
144
+
145
+ - 规则变化:写入 `docs/rules/`
146
+ - 设计权衡:写入 `docs/design-docs/`
147
+ - 执行计划、复盘、技术债:写入 `docs/exec-plans/`
148
+ - 生成物、快照、报告:写入 `docs/generated/`
149
+ - 外部资料摘要:写入 `docs/references/`
150
+
151
+ 如果一次任务无法在 1 天内稳定完成,先拆成更小的执行单元;复杂任务的过程信息不要只留在对话里。
152
+
153
+ ## 9. 失败预演
154
+
155
+ 至少预演一个失败模式,而不是只验证 happy path。当前仓库已经出现过两类高信号风险:
156
+
157
+ - 文档漂移:例如测试规则曾与真实 `vitest.config.ts` 不一致,导致 agent 按旧规则执行错误命令。
158
+ - 文档检索盲区:当 `analyze documentation` 无法命中文档时,agent 需要立即回退到 `rg` / 直接读文件,并在适用时记录 CodeMap 缺陷,而不是假装"没问题"。
159
+
160
+ ## 10. 最小交付清单(更新版 - Harness 规范)
161
+
162
+ ### 10.1 交付内容
163
+
164
+ 每次 agent 交付至少要说明:
165
+
166
+ 1. **改了什么**:文件清单 + 变更摘要
167
+ 2. **为什么改**:需求背景 + 设计决策
168
+ 3. **按什么护栏验证**:执行的检查命令和结果
169
+ 4. **失败场景或风险模式**:至少一个预演的失败场景
170
+ 5. **可信度自评**(见 AGENTS.md 5.1 格式):确定/推测/需验证/风险
171
+ 6. **文档同步说明**:是否更新了相关文档及原因
172
+
173
+ ### 10.2 必须同步文档的触发条件
174
+
175
+ 以下情况**必须**更新对应文档:
176
+
177
+ | 你的改动 | 必须更新的文档 |
178
+ |---------|--------------|
179
+ | 新增/修改 CLI 命令或参数 | `CLAUDE.md`、`docs/rules/engineering-with-codex-openai.md` |
180
+ | 新增/修改配置项或 Schema | `README.md`、相关配置示例 |
181
+ | 修改类型定义/公共接口 | 接口注释、`docs/rules/` 中相关文档 |
182
+ | 修改 CI/CD 流程 | `docs/rules/validation.md`、`.github/workflows/` |
183
+ | 修改 Git Hooks | `docs/rules/validation.md` |
184
+ | 修改测试规则/覆盖率要求 | `docs/rules/testing.md` |
185
+ | 修改架构分层或依赖规则 | `ARCHITECTURE.md`、`docs/rules/architecture-guardrails.md` |
186
+ | 新增代码质量红线 | `docs/rules/code-quality-redlines.md` |
187
+ | 修改提交格式规范 | `AGENTS.md` |
188
+ | 发现文档与代码不符 | 立即修复对应文档 |
189
+
190
+ **原则**:若改动会影响其他开发者或 AI 的行为,就必须更新文档。
191
+
192
+ ## 11. 参考来源
193
+
194
+ - OpenAI Engineering: https://openai.com/engineering/codex/
195
+ - Harness Engineering 方法论:`docs/references/tmp.md`
196
+ - 仓库入口协议:`AGENTS.md`
197
+ - 最小执行手册:`CLAUDE.md`
198
+ - 架构地图:`ARCHITECTURE.md`
199
+ - 当前验证规则:`docs/rules/validation.md`
200
+ - 当前发布规则:`docs/rules/deployment.md`
201
+ - 代码质量红线:`docs/rules/code-quality-redlines.md`
202
+ - 架构护栏:`docs/rules/architecture-guardrails.md`
@@ -0,0 +1,73 @@
1
+ # 测试规则
2
+
3
+ > 测试框架、覆盖率要求、基准测试
4
+
5
+ ---
6
+
7
+ ## 测试框架
8
+
9
+ | 项目 | 配置 |
10
+ |------|------|
11
+ | 框架 | Vitest |
12
+ | 覆盖率工具 | @vitest/coverage-v8 |
13
+ | 目标覆盖率 | >= 80% |
14
+
15
+ ## 测试文件位置
16
+
17
+ | 类型 | 路径 |
18
+ |------|------|
19
+ | 常规测试 | `src/**/*.test.ts` |
20
+ | 集成测试 | `tests/` 目录(如存在单独集成测试编排) |
21
+ | 基准测试 | `refer/benchmark-quality.test.ts` |
22
+
23
+ ## 测试配置
24
+
25
+ ```typescript
26
+ // vitest.config.ts
27
+ export default defineConfig({
28
+ test: {
29
+ globals: true,
30
+ environment: 'node',
31
+ include: ['src/**/*.test.ts'],
32
+ exclude: ['node_modules', 'dist', 'refer/**/*.test.ts'],
33
+ testTimeout: 10000,
34
+ hookTimeout: 10000,
35
+ pool: 'threads'
36
+ }
37
+ });
38
+ ```
39
+
40
+ ## 测试要求
41
+
42
+ - 所有新功能必须附带测试
43
+ - 测试文件命名:`* .test.ts`
44
+ - 使用 `describe` 和 `it` 组织测试用例
45
+ - 使用 `beforeEach`/`afterEach` 管理测试状态
46
+
47
+ ## 基准测试
48
+
49
+ - 基准查询集:`refer/benchmark-quality.ts`(30 条预定义查询)
50
+ - 基准测试配置:`vitest.benchmark.config.ts`
51
+ - 关键指标:
52
+ - Token 消耗降低 >= 40%
53
+ - Hit@8 >= 90%
54
+
55
+ ## 常用命令
56
+
57
+ ```bash
58
+ # 运行所有测试
59
+ npm test
60
+ npx vitest run
61
+
62
+ # 运行特定测试文件
63
+ npx vitest run src/orchestrator/__tests__/confidence.test.ts
64
+
65
+ # 运行与变更相关的测试
66
+ npx vitest run --changed
67
+
68
+ # 运行覆盖率
69
+ npx vitest run --coverage
70
+
71
+ # 监视模式
72
+ npx vitest watch
73
+ ```
@@ -0,0 +1,39 @@
1
+ # 验证规则
2
+
3
+ ## 最小验证顺序
4
+
5
+ 1. 先验证与你改动最相关的命令、测试或模块。
6
+ 2. 若改动影响 agent 路由、CLI 示例、规则文档或测试事实,先执行 `npm run docs:check`。
7
+ 3. 若改动同时影响 CLI 护栏入口,再补 `node dist/cli/index.js ci check-docs-sync`。
8
+ 4. 再扩大到 `npm run typecheck`、`npm run lint`、`npm test`。
9
+ 5. 涉及发布或打包时,再执行 `npm run build` 与 `npm run validate-pack`。
10
+
11
+ ## CI Gateway 验证流程
12
+
13
+ CI Gateway 已集成以下自动检查(按执行顺序):
14
+
15
+ 1. `npm run docs:check` - 文档护栏检查
16
+ 2. `npm run typecheck` - TypeScript 类型检查
17
+ 3. `npm run lint` - ESLint 代码质量检查(渐进式规则,0 error 通过)
18
+ 4. `npm test` - 单元测试
19
+ 5. `npm run build` - 构建验证
20
+ 6. CLI 相关检查(commit 格式、文件头等)
21
+
22
+ ## 强约束
23
+
24
+ - 没有验证,不得声称“已解决”。
25
+ - 失败时优先修根因,不绕过护栏。
26
+ - 涉及 CI / hooks / 输出契约时,必须给出失败场景与修复验证证据。
27
+ - 严禁使用 `--no-verify`、禁用 hooks、删除检查项规避失败。
28
+
29
+ ## 常用命令
30
+
31
+ ```bash
32
+ npm run docs:check
33
+ node dist/cli/index.js ci check-docs-sync
34
+ npm run typecheck
35
+ npm test
36
+ npm run lint
37
+ npm run build
38
+ npm run validate-pack
39
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycodemap/mycodemap",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "TypeScript 代码地图工具 - 为 AI 辅助开发提供结构化上下文",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",
@@ -24,13 +24,24 @@
24
24
  "scripts": {
25
25
  "build": "tsc",
26
26
  "dev": "tsc --watch",
27
+ "docs:check": "node scripts/validate-docs.js && node scripts/validate-ai-docs.js",
28
+ "docs:check:human": "node scripts/validate-docs.js",
29
+ "docs:check:ai": "node scripts/validate-ai-docs.js",
27
30
  "test": "vitest run",
28
- "lint": "eslint src --ext .ts",
31
+ "lint": "eslint src",
29
32
  "typecheck": "tsc --noEmit",
30
33
  "benchmark": "bash scripts/run-benchmark.sh",
31
34
  "test:all": "npm run test && npm run benchmark",
32
35
  "prepublishOnly": "npm run build && npm test",
33
- "validate-pack": "node scripts/validate-pack.js"
36
+ "validate-pack": "node scripts/validate-pack.js",
37
+ "release": "./scripts/release.sh",
38
+ "check:all": "npm run typecheck && npm run lint && npm test && npm run docs:check",
39
+ "check:architecture": "echo 'dependency-cruiser not installed, run: npm i -D dependency-cruiser'",
40
+ "check:security": "npm audit",
41
+ "check:unused": "echo 'knip not installed, run: npm i -D knip'",
42
+ "fix:all": "npm run lint -- --fix",
43
+ "ai:pre-task": "npm run check:all",
44
+ "ai:post-task": "npm run fix:all && npm run check:all"
34
45
  },
35
46
  "keywords": [
36
47
  "typescript",
@@ -42,10 +53,12 @@
42
53
  "author": "",
43
54
  "license": "MIT",
44
55
  "dependencies": {
56
+ "@hono/node-server": "^1.19.11",
45
57
  "chalk": "^5.3.0",
46
58
  "chokidar": "^3.5.3",
47
59
  "commander": "^11.1.0",
48
60
  "globby": "^14.0.0",
61
+ "hono": "^4.12.8",
49
62
  "ora": "^8.0.1",
50
63
  "tree-sitter": "^0.21.1",
51
64
  "tree-sitter-typescript": "^0.23.2",
@@ -55,10 +68,10 @@
55
68
  "devDependencies": {
56
69
  "@types/glob": "^8.1.0",
57
70
  "@types/node": "^20.10.0",
58
- "@typescript-eslint/eslint-plugin": "^6.15.0",
59
- "@typescript-eslint/parser": "^6.15.0",
71
+ "@typescript-eslint/eslint-plugin": "^6.21.0",
72
+ "@typescript-eslint/parser": "^6.21.0",
60
73
  "@vitest/coverage-v8": "^1.6.1",
61
- "eslint": "^8.55.0",
74
+ "eslint": "^8.57.1",
62
75
  "vitest": "^1.1.0"
63
76
  },
64
77
  "engines": {
@@ -1,285 +0,0 @@
1
- # OMC Team 模式与 Claude Code 不兼容问题分析报告
2
-
3
- > 生成时间:2026-03-07
4
- > 分析范围:OMC team 模式 + Claude Code 集成
5
-
6
- ---
7
-
8
- ## 1. 问题现象
9
-
10
- ### 1.1 观察到的症状
11
-
12
- 从 trace 数据显示:
13
- - **worker-1**: spawn 了 **11 次**
14
- - **worker-2**: spawn 了 **3 次**
15
- - 主 session 在 16:08 结束,reason: "other"
16
-
17
- ### 1.2 影响
18
-
19
- - 资源快速耗尽(内存、进程)
20
- - Claude Code 主进程可能因资源压力退出
21
- - 任务完成状态不稳定
22
-
23
- ---
24
-
25
- ## 2. 根本原因分析
26
-
27
- ### 2.1 架构问题:V1 Runtime 的 Watchdog 循环
28
-
29
- **问题位置**: `runtime.ts:518-647` (watchdogCliWorkers 函数)
30
-
31
- **问题描述**:
32
- ```
33
- watchdog tick 循环逻辑:
34
- 1. 检查 workers 的 done.json 信号
35
- 2. 如果有信号 -> markTaskFromDone -> killWorkerPane -> spawnWorkerForTask (如果有 pending 任务)
36
- 3. 如果 worker 死了 -> applyDeadPaneTransition -> requeue -> spawnWorkerForTask
37
- ```
38
-
39
- **Bug**: 当任务完成后,watchdog 会立即 spawn 新的 worker 来执行其他 pending 任务。这导致:
40
- - Worker 刚完成就被 kill
41
- - 立即创建新 worker
42
- - 如果任务列表只有 1 个任务,也会反复创建同一个 worker
43
-
44
- ### 2.2 状态同步问题
45
-
46
- **问题**: `markTaskFromDone()` 更新任务状态为 completed,但可能存在:
47
- - 文件系统写入延迟
48
- - 状态读取不一致
49
- - 导致 `allTasksTerminal()` 错误判断
50
-
51
- ### 2.3 Session 管理问题
52
-
53
- **观察**:
54
- - Session 在 16:08 结束 (reason: "other")
55
- - Workers 在 16:07 完成后反复重建
56
- - 主 session 可能因资源压力或错误退出
57
-
58
- ### 2.4 Claude Code 原生 team 集成问题
59
-
60
- 从 config.json 可见:
61
- - Workers 使用 `in-process` backend (`"backendType": "in-process"`)
62
- - 这意味着 workers 运行在同一个 Claude Code 进程内
63
- - 当 worker 完成后返回结果时,可能触发主进程重新 spawn
64
-
65
- ---
66
-
67
- ## 3. 具体问题点
68
-
69
- ### 问题 1: Watchdog 立即重新分配任务
70
-
71
- **代码位置**: `runtime.ts:559-565`
72
- ```typescript
73
- if (signal) {
74
- // ... 处理完成信号
75
- await killWorkerPane(runtime, wName, active.paneId);
76
- if (!(await allTasksTerminal(runtime))) {
77
- const nextTaskIndexValue = await nextPendingTaskIndex(runtime);
78
- if (nextTaskIndexValue != null) {
79
- await spawnWorkerForTask(runtime, wName, nextTaskIndexValue); // 立即 spawn!
80
- }
81
- }
82
- }
83
- ```
84
-
85
- **问题**: 任务完成后立即 spawn 新 worker,没有给主 session 任何喘息机会
86
-
87
- ### 问题 2: Worker 复用逻辑缺失
88
-
89
- **代码位置**: `runtime.ts:421-426`
90
- ```typescript
91
- const maxConcurrentWorkers = agentTypes.length;
92
- for (let i = 0; i < maxConcurrentWorkers; i++) {
93
- const taskIndex = await nextPendingTaskIndex(runtime);
94
- if (taskIndex == null) break;
95
- await spawnWorkerForTask(runtime, workerName(i), taskIndex);
96
- }
97
- ```
98
-
99
- **问题**: 每次都创建新的 workerName,而不是复用已有的 worker
100
-
101
- ### 问题 3: In-Process Workers 的状态管理
102
-
103
- **代码位置**: config.json
104
- ```json
105
- {
106
- "backendType": "in-process"
107
- }
108
- ```
109
-
110
- **问题**: in-process workers 完成后会返回结果给主 agent,这可能触发某种重新调度的 hook,导致反复 spawn
111
-
112
- ### 问题 4: 缺乏资源限制
113
-
114
- **问题**: 没有机制限制:
115
- - 单个 worker 的最大执行时间
116
- - 总 worker spawn 次数
117
- - 内存使用上限
118
-
119
- ---
120
-
121
- ## 4. 修复方案
122
-
123
- ### 4.1 方案 A: 启用 V2 Runtime (推荐)
124
-
125
- **原理**: V2 runtime 使用事件驱动架构,避免轮询问题
126
-
127
- **操作**:
128
- ```bash
129
- export OMC_RUNTIME_V2=1
130
- # 然后重新运行 team
131
- ```
132
-
133
- **预期效果**:
134
- - 更稳定的任务状态管理
135
- - 事件驱动而非轮询
136
- - 减少不必要的 worker 重建
137
-
138
- ### 4.2 方案 B: 修复 V1 Runtime
139
-
140
- #### B.1 添加冷却期
141
-
142
- **修改位置**: `runtime.ts:559-565`
143
-
144
- ```typescript
145
- // 在 killWorkerPane 后添加延迟
146
- await killWorkerPane(runtime, wName, active.paneId);
147
-
148
- // 添加冷却期,避免立即重新 spawn
149
- await new Promise(resolve => setTimeout(resolve, 2000));
150
-
151
- if (!(await allTasksTerminal(runtime))) {
152
- // ... existing logic
153
- }
154
- ```
155
-
156
- #### B.2 添加 Worker 池机制
157
-
158
- **修改位置**: `runtime.ts` - 新增 worker 池状态
159
-
160
- ```typescript
161
- interface WorkerPool {
162
- availableWorkers: string[]; // 可复用的 worker 名称
163
- activeWorkers: Map<string, ActiveWorkerState>;
164
- }
165
-
166
- // 在 spawnWorkerForTask 中复用
167
- async function spawnWorkerForTask(...) {
168
- // 先检查池中是否有可用 worker
169
- if (runtime.workerPool.availableWorkers.length > 0) {
170
- const reusableWorkerName = runtime.workerPool.availableWorkers.pop();
171
- // 复用该 worker
172
- }
173
- // 否则创建新 worker
174
- }
175
- ```
176
-
177
- #### B.3 添加资源限制
178
-
179
- **修改位置**: `runtime.ts` - 新增限制配置
180
-
181
- ```typescript
182
- const MAX_WORKER_SPAWNS = 20; // 最多 spawn 次数
183
- const WORKER_COOLDOWN_MS = 3000; // 冷却期
184
-
185
- // 在 watchdog 中跟踪 spawn 次数
186
- let workerSpawnCount = 0;
187
-
188
- async function spawnWorkerForTask(...) {
189
- if (workerSpawnCount >= MAX_WORKER_SPAWNS) {
190
- console.warn('[watchdog] Max worker spawn limit reached');
191
- return '';
192
- }
193
- workerSpawnCount++;
194
- // ... existing logic
195
- }
196
- ```
197
-
198
- ### 4.3 方案 C: 修复 Claude Code 集成
199
-
200
- #### C.1 修改 worker hook 逻辑
201
-
202
- **修改位置**: `src/hooks/team-worker-hook.ts`
203
-
204
- 确保 worker 完成后:
205
- 1. 写入 done.json
206
- 2. **不自动退出** (等待主 session 指示)
207
- 3. 进入空闲状态等待新任务
208
-
209
- #### C.2 添加状态一致性检查
210
-
211
- **修改位置**: `runtime.ts:allTasksTerminal()`
212
-
213
- ```typescript
214
- export async function allTasksTerminal(runtime: TeamRuntime): Promise<boolean> {
215
- const root = stateRoot(runtime.cwd, runtime.teamName);
216
-
217
- // 多次重试读取确保一致性
218
- for (let retry = 0; retry < 3; retry++) {
219
- let allTerminal = true;
220
- for (let i = 0; i < runtime.config.tasks.length; i++) {
221
- const task = await readTask(root, String(i + 1));
222
- if (!task) return false; // 任务文件不存在
223
- if (task.status !== 'completed' && task.status !== 'failed') {
224
- allTerminal = false;
225
- }
226
- }
227
- if (allTerminal) return true;
228
- await new Promise(r => setTimeout(r, 100)); // 等待状态稳定
229
- }
230
- return false;
231
- }
232
- ```
233
-
234
- ---
235
-
236
- ## 5. 实施建议
237
-
238
- ### 优先级
239
-
240
- | 优先级 | 修复项 | 难度 | 预期效果 |
241
- |--------|--------|------|----------|
242
- | P0 | 启用 V2 Runtime | 低 | 立即改善 |
243
- | P1 | 添加冷却期 | 中 | 减少频繁重建 |
244
- | P2 | Worker 池机制 | 高 | 根本解决 |
245
- | P3 | 资源限制 | 中 | 防止资源耗尽 |
246
-
247
- ### 验证方法
248
-
249
- ```bash
250
- # 1. 检查 OMC_RUNTIME_V2 是否启用
251
- echo $OMC_RUNTIME_V2
252
-
253
- # 2. 运行 team 并监控 spawn 次数
254
- /team 3:executor "test task"
255
-
256
- # 3. 观察日志中 worker spawn 次数
257
- # 修复前: worker-1 spawn 11 次
258
- # 修复后: worker-1 spawn 1-2 次
259
- ```
260
-
261
- ---
262
-
263
- ## 6. 附录:相关代码位置
264
-
265
- | 文件 | 说明 |
266
- |------|------|
267
- | `src/team/runtime.ts` | V1 runtime 核心逻辑 |
268
- | `src/team/runtime-v2.ts` | V2 runtime (事件驱动) |
269
- | `src/hooks/team-worker-hook.ts` | Worker 生命周期 hook |
270
- | `src/hooks/team-leader-nudge-hook.ts` | 主 session 状态 hook |
271
- | `src/team/tmux-session.ts` | tmux 会话管理 |
272
- | `src/team/task-file-ops.ts` | 任务文件操作 |
273
-
274
- ---
275
-
276
- ## 7. 结论
277
-
278
- OMC team 模式与 Claude Code 不兼容的主要原因是:
279
-
280
- 1. **V1 runtime 的 watchdog 逻辑缺陷** - 任务完成后立即重新 spawn worker
281
- 2. **缺乏 worker 复用机制** - 每次都创建新 worker
282
- 3. **资源限制缺失** - 没有防止无限 spawn 的保护
283
- 4. **In-process workers 状态同步问题** - 主进程可能因资源压力退出
284
-
285
- **推荐优先尝试方案 A (启用 V2 Runtime)**,这是最简单且最可能立即见效的方案。