@mycodemap/mycodemap 0.5.2-beta.1 → 2.0.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 (272) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +138 -854
  3. package/README.zh-CN.md +1096 -0
  4. package/dist/cli/commands/analyze-options.d.ts.map +1 -1
  5. package/dist/cli/commands/analyze-options.js +8 -0
  6. package/dist/cli/commands/analyze-options.js.map +1 -1
  7. package/dist/cli/commands/analyze.d.ts.map +1 -1
  8. package/dist/cli/commands/analyze.js +60 -41
  9. package/dist/cli/commands/analyze.js.map +1 -1
  10. package/dist/cli/commands/benchmark.d.ts +8 -0
  11. package/dist/cli/commands/benchmark.d.ts.map +1 -0
  12. package/dist/cli/commands/benchmark.js +150 -0
  13. package/dist/cli/commands/benchmark.js.map +1 -0
  14. package/dist/cli/commands/deps.d.ts +2 -1
  15. package/dist/cli/commands/deps.d.ts.map +1 -1
  16. package/dist/cli/commands/deps.js +107 -78
  17. package/dist/cli/commands/deps.js.map +1 -1
  18. package/dist/cli/commands/doctor.d.ts +3 -0
  19. package/dist/cli/commands/doctor.d.ts.map +1 -0
  20. package/dist/cli/commands/doctor.js +34 -0
  21. package/dist/cli/commands/doctor.js.map +1 -0
  22. package/dist/cli/commands/init.d.ts +7 -2
  23. package/dist/cli/commands/init.d.ts.map +1 -1
  24. package/dist/cli/commands/init.js +22 -34
  25. package/dist/cli/commands/init.js.map +1 -1
  26. package/dist/cli/commands/publish-status.d.ts +31 -0
  27. package/dist/cli/commands/publish-status.d.ts.map +1 -0
  28. package/dist/cli/commands/publish-status.js +101 -0
  29. package/dist/cli/commands/publish-status.js.map +1 -0
  30. package/dist/cli/commands/query.d.ts +1 -0
  31. package/dist/cli/commands/query.d.ts.map +1 -1
  32. package/dist/cli/commands/query.js +123 -140
  33. package/dist/cli/commands/query.js.map +1 -1
  34. package/dist/cli/commands/readiness-gate.d.ts +25 -0
  35. package/dist/cli/commands/readiness-gate.d.ts.map +1 -0
  36. package/dist/cli/commands/readiness-gate.js +197 -0
  37. package/dist/cli/commands/readiness-gate.js.map +1 -0
  38. package/dist/cli/commands/ship/checker.d.ts +4 -9
  39. package/dist/cli/commands/ship/checker.d.ts.map +1 -1
  40. package/dist/cli/commands/ship/checker.js +60 -22
  41. package/dist/cli/commands/ship/checker.js.map +1 -1
  42. package/dist/cli/commands/ship/monitor.d.ts +6 -1
  43. package/dist/cli/commands/ship/monitor.d.ts.map +1 -1
  44. package/dist/cli/commands/ship/monitor.js +223 -46
  45. package/dist/cli/commands/ship/monitor.js.map +1 -1
  46. package/dist/cli/commands/ship/pipeline.d.ts.map +1 -1
  47. package/dist/cli/commands/ship/pipeline.js +14 -5
  48. package/dist/cli/commands/ship/pipeline.js.map +1 -1
  49. package/dist/cli/commands/ship/rules/quality-rules.d.ts +12 -8
  50. package/dist/cli/commands/ship/rules/quality-rules.d.ts.map +1 -1
  51. package/dist/cli/commands/ship/rules/quality-rules.js +49 -34
  52. package/dist/cli/commands/ship/rules/quality-rules.js.map +1 -1
  53. package/dist/cli/config-loader.js +1 -1
  54. package/dist/cli/config-loader.js.map +1 -1
  55. package/dist/cli/doctor/check-agent.d.ts +3 -0
  56. package/dist/cli/doctor/check-agent.d.ts.map +1 -0
  57. package/dist/cli/doctor/check-agent.js +60 -0
  58. package/dist/cli/doctor/check-agent.js.map +1 -0
  59. package/dist/cli/doctor/check-ghost-commands.d.ts +3 -0
  60. package/dist/cli/doctor/check-ghost-commands.d.ts.map +1 -0
  61. package/dist/cli/doctor/check-ghost-commands.js +86 -0
  62. package/dist/cli/doctor/check-ghost-commands.js.map +1 -0
  63. package/dist/cli/doctor/check-native-deps.d.ts +3 -0
  64. package/dist/cli/doctor/check-native-deps.d.ts.map +1 -0
  65. package/dist/cli/doctor/check-native-deps.js +54 -0
  66. package/dist/cli/doctor/check-native-deps.js.map +1 -0
  67. package/dist/cli/doctor/check-workspace-drift.d.ts +3 -0
  68. package/dist/cli/doctor/check-workspace-drift.d.ts.map +1 -0
  69. package/dist/cli/doctor/check-workspace-drift.js +83 -0
  70. package/dist/cli/doctor/check-workspace-drift.js.map +1 -0
  71. package/dist/cli/doctor/formatter.d.ts +20 -0
  72. package/dist/cli/doctor/formatter.d.ts.map +1 -0
  73. package/dist/cli/doctor/formatter.js +91 -0
  74. package/dist/cli/doctor/formatter.js.map +1 -0
  75. package/dist/cli/doctor/index.d.ts +8 -0
  76. package/dist/cli/doctor/index.d.ts.map +1 -0
  77. package/dist/cli/doctor/index.js +9 -0
  78. package/dist/cli/doctor/index.js.map +1 -0
  79. package/dist/cli/doctor/orchestrator.d.ts +3 -0
  80. package/dist/cli/doctor/orchestrator.d.ts.map +1 -0
  81. package/dist/cli/doctor/orchestrator.js +37 -0
  82. package/dist/cli/doctor/orchestrator.js.map +1 -0
  83. package/dist/cli/doctor/types.d.ts +19 -0
  84. package/dist/cli/doctor/types.d.ts.map +1 -0
  85. package/dist/cli/doctor/types.js +4 -0
  86. package/dist/cli/doctor/types.js.map +1 -0
  87. package/dist/cli/first-run-guide.d.ts.map +1 -1
  88. package/dist/cli/first-run-guide.js +10 -12
  89. package/dist/cli/first-run-guide.js.map +1 -1
  90. package/dist/cli/index.js +80 -21
  91. package/dist/cli/index.js.map +1 -1
  92. package/dist/cli/init/hooks.d.ts +17 -0
  93. package/dist/cli/init/hooks.d.ts.map +1 -0
  94. package/dist/cli/init/hooks.js +220 -0
  95. package/dist/cli/init/hooks.js.map +1 -0
  96. package/dist/cli/init/receipt.d.ts +4 -0
  97. package/dist/cli/init/receipt.d.ts.map +1 -0
  98. package/dist/cli/init/receipt.js +117 -0
  99. package/dist/cli/init/receipt.js.map +1 -0
  100. package/dist/cli/init/reconciler.d.ts +44 -0
  101. package/dist/cli/init/reconciler.d.ts.map +1 -0
  102. package/dist/cli/init/reconciler.js +377 -0
  103. package/dist/cli/init/reconciler.js.map +1 -0
  104. package/dist/cli/init/rule-templates.d.ts +9 -0
  105. package/dist/cli/init/rule-templates.d.ts.map +1 -0
  106. package/dist/cli/init/rule-templates.js +105 -0
  107. package/dist/cli/init/rule-templates.js.map +1 -0
  108. package/dist/cli/init/rules.d.ts +13 -0
  109. package/dist/cli/init/rules.d.ts.map +1 -0
  110. package/dist/cli/init/rules.js +113 -0
  111. package/dist/cli/init/rules.js.map +1 -0
  112. package/dist/cli/interface-contract/commands/analyze.d.ts +3 -0
  113. package/dist/cli/interface-contract/commands/analyze.d.ts.map +1 -0
  114. package/dist/cli/interface-contract/commands/analyze.js +138 -0
  115. package/dist/cli/interface-contract/commands/analyze.js.map +1 -0
  116. package/dist/cli/interface-contract/commands/benchmark.d.ts +3 -0
  117. package/dist/cli/interface-contract/commands/benchmark.d.ts.map +1 -0
  118. package/dist/cli/interface-contract/commands/benchmark.js +107 -0
  119. package/dist/cli/interface-contract/commands/benchmark.js.map +1 -0
  120. package/dist/cli/interface-contract/commands/deps.d.ts +3 -0
  121. package/dist/cli/interface-contract/commands/deps.d.ts.map +1 -0
  122. package/dist/cli/interface-contract/commands/deps.js +129 -0
  123. package/dist/cli/interface-contract/commands/deps.js.map +1 -0
  124. package/dist/cli/interface-contract/commands/doctor.d.ts +3 -0
  125. package/dist/cli/interface-contract/commands/doctor.d.ts.map +1 -0
  126. package/dist/cli/interface-contract/commands/doctor.js +59 -0
  127. package/dist/cli/interface-contract/commands/doctor.js.map +1 -0
  128. package/dist/cli/interface-contract/commands/index.d.ts +9 -0
  129. package/dist/cli/interface-contract/commands/index.d.ts.map +1 -0
  130. package/dist/cli/interface-contract/commands/index.js +18 -0
  131. package/dist/cli/interface-contract/commands/index.js.map +1 -0
  132. package/dist/cli/interface-contract/commands/init.d.ts +3 -0
  133. package/dist/cli/interface-contract/commands/init.d.ts.map +1 -0
  134. package/dist/cli/interface-contract/commands/init.js +87 -0
  135. package/dist/cli/interface-contract/commands/init.js.map +1 -0
  136. package/dist/cli/interface-contract/commands/query.d.ts +3 -0
  137. package/dist/cli/interface-contract/commands/query.d.ts.map +1 -0
  138. package/dist/cli/interface-contract/commands/query.js +185 -0
  139. package/dist/cli/interface-contract/commands/query.js.map +1 -0
  140. package/dist/cli/interface-contract/index.d.ts +22 -0
  141. package/dist/cli/interface-contract/index.d.ts.map +1 -0
  142. package/dist/cli/interface-contract/index.js +41 -0
  143. package/dist/cli/interface-contract/index.js.map +1 -0
  144. package/dist/cli/interface-contract/schema.d.ts +30 -0
  145. package/dist/cli/interface-contract/schema.d.ts.map +1 -0
  146. package/dist/cli/interface-contract/schema.js +72 -0
  147. package/dist/cli/interface-contract/schema.js.map +1 -0
  148. package/dist/cli/interface-contract/types.d.ts +76 -0
  149. package/dist/cli/interface-contract/types.d.ts.map +1 -0
  150. package/dist/cli/interface-contract/types.js +4 -0
  151. package/dist/cli/interface-contract/types.js.map +1 -0
  152. package/dist/cli/output/apply-suggestion.d.ts +12 -0
  153. package/dist/cli/output/apply-suggestion.d.ts.map +1 -0
  154. package/dist/cli/output/apply-suggestion.js +29 -0
  155. package/dist/cli/output/apply-suggestion.js.map +1 -0
  156. package/dist/cli/output/error-codes.d.ts +22 -0
  157. package/dist/cli/output/error-codes.d.ts.map +1 -0
  158. package/dist/cli/output/error-codes.js +82 -0
  159. package/dist/cli/output/error-codes.js.map +1 -0
  160. package/dist/cli/output/errors.d.ts +14 -0
  161. package/dist/cli/output/errors.d.ts.map +1 -0
  162. package/dist/cli/output/errors.js +170 -0
  163. package/dist/cli/output/errors.js.map +1 -0
  164. package/dist/cli/output/index.d.ts +13 -0
  165. package/dist/cli/output/index.d.ts.map +1 -0
  166. package/dist/cli/output/index.js +11 -0
  167. package/dist/cli/output/index.js.map +1 -0
  168. package/dist/cli/output/mode.d.ts +12 -0
  169. package/dist/cli/output/mode.d.ts.map +1 -0
  170. package/dist/cli/output/mode.js +23 -0
  171. package/dist/cli/output/mode.js.map +1 -0
  172. package/dist/cli/output/progress.d.ts +9 -0
  173. package/dist/cli/output/progress.d.ts.map +1 -0
  174. package/dist/cli/output/progress.js +65 -0
  175. package/dist/cli/output/progress.js.map +1 -0
  176. package/dist/cli/output/render.d.ts +11 -0
  177. package/dist/cli/output/render.d.ts.map +1 -0
  178. package/dist/cli/output/render.js +18 -0
  179. package/dist/cli/output/render.js.map +1 -0
  180. package/dist/cli/output/types.d.ts +53 -0
  181. package/dist/cli/output/types.d.ts.map +1 -0
  182. package/dist/cli/output/types.js +14 -0
  183. package/dist/cli/output/types.js.map +1 -0
  184. package/dist/cli/output/wasm-fallback.d.ts +13 -0
  185. package/dist/cli/output/wasm-fallback.d.ts.map +1 -0
  186. package/dist/cli/output/wasm-fallback.js +92 -0
  187. package/dist/cli/output/wasm-fallback.js.map +1 -0
  188. package/dist/cli/paths.d.ts +4 -2
  189. package/dist/cli/paths.d.ts.map +1 -1
  190. package/dist/cli/paths.js +13 -5
  191. package/dist/cli/paths.js.map +1 -1
  192. package/dist/cli/tree-sitter-check.d.ts +6 -1
  193. package/dist/cli/tree-sitter-check.d.ts.map +1 -1
  194. package/dist/cli/tree-sitter-check.js +23 -1
  195. package/dist/cli/tree-sitter-check.js.map +1 -1
  196. package/dist/infrastructure/storage/adapters/SQLiteStorage.d.ts.map +1 -1
  197. package/dist/infrastructure/storage/adapters/SQLiteStorage.js +2 -2
  198. package/dist/infrastructure/storage/adapters/SQLiteStorage.js.map +1 -1
  199. package/dist/infrastructure/storage/adapters/sqlite-loader.d.ts +23 -0
  200. package/dist/infrastructure/storage/adapters/sqlite-loader.d.ts.map +1 -0
  201. package/dist/infrastructure/storage/adapters/sqlite-loader.js +210 -0
  202. package/dist/infrastructure/storage/adapters/sqlite-loader.js.map +1 -0
  203. package/dist/orchestrator/test-linker.d.ts.map +1 -1
  204. package/dist/orchestrator/test-linker.js +5 -36
  205. package/dist/orchestrator/test-linker.js.map +1 -1
  206. package/dist/orchestrator/types.d.ts +2 -0
  207. package/dist/orchestrator/types.d.ts.map +1 -1
  208. package/dist/orchestrator/types.js.map +1 -1
  209. package/dist/parser/implementations/tree-sitter-loader.d.ts +16 -0
  210. package/dist/parser/implementations/tree-sitter-loader.d.ts.map +1 -0
  211. package/dist/parser/implementations/tree-sitter-loader.js +105 -0
  212. package/dist/parser/implementations/tree-sitter-loader.js.map +1 -0
  213. package/dist/parser/implementations/tree-sitter-parser.d.ts +3 -0
  214. package/dist/parser/implementations/tree-sitter-parser.d.ts.map +1 -1
  215. package/dist/parser/implementations/tree-sitter-parser.js +8 -3
  216. package/dist/parser/implementations/tree-sitter-parser.js.map +1 -1
  217. package/dist/server/mcp/schema-adapter.d.ts +45 -0
  218. package/dist/server/mcp/schema-adapter.d.ts.map +1 -0
  219. package/dist/server/mcp/schema-adapter.js +290 -0
  220. package/dist/server/mcp/schema-adapter.js.map +1 -0
  221. package/dist/server/mcp/server.d.ts.map +1 -1
  222. package/dist/server/mcp/server.js +32 -2
  223. package/dist/server/mcp/server.js.map +1 -1
  224. package/docs/AI_ASSISTANT_SETUP.md +173 -14
  225. package/docs/README.md +40 -1
  226. package/docs/SETUP_GUIDE.md +23 -26
  227. package/docs/agents/domain.md +36 -0
  228. package/docs/agents/issue-tracker.md +22 -0
  229. package/docs/agents/triage-labels.md +15 -0
  230. package/docs/ai-guide/COMMANDS.md +125 -13
  231. package/docs/ai-guide/INTEGRATION.md +78 -11
  232. package/docs/ai-guide/OUTPUT.md +295 -2
  233. package/docs/ai-guide/PATTERNS.md +3 -3
  234. package/docs/ai-guide/PROMPTS.md +2 -2
  235. package/docs/ai-guide/QUICKSTART.md +41 -5
  236. package/docs/ai-guide/README.md +9 -9
  237. package/docs/archive/ideation/2026-04-15-executable-architecture-constitution-ideation-archive.md +70 -0
  238. package/docs/archive/ideation/2026-04-20-mycodemap-init-enhancements-ideation-archive.md +109 -0
  239. package/docs/archive/ideation/2026-04-22-harness-rules-entry-docs-optimization-ideation.md +102 -0
  240. package/docs/archive/ideation/2026-04-22-rules-claude-agents-optimization-ideation.md +107 -0
  241. package/docs/archive/ideation/2026-04-22-rules-entry-docs-optimization-consolidated-ideation-archive.md +54 -0
  242. package/docs/brainstorms/2026-04-22-rules-entry-docs-phase1-structure-consolidation-requirements.md +110 -0
  243. package/docs/brainstorms/999.1-mycodemap-init-enhancements-requirements.md +166 -0
  244. package/docs/exec-plans/README.md +3 -0
  245. package/docs/ideation/2026-04-15-executable-architecture-constitution-ideation.md +10 -22
  246. package/docs/ideation/2026-04-20-mycodemap-init-enhancements-ideation.md +51 -0
  247. package/docs/ideation/2026-04-22-rules-entry-docs-optimization-consolidated-ideation.md +114 -0
  248. package/docs/ideation/2026-04-29-ux-install-agent-experience-ideation.md +256 -0
  249. package/docs/lesson-learn/2026-04-19-prerelease-trusted-publishing-fix.md +119 -0
  250. package/docs/lesson-learn/image.png +0 -0
  251. package/docs/plans/2026-04-30-install-guide-and-repo-analyzer-design.md +394 -0
  252. package/docs/rules/README.md +5 -1
  253. package/docs/rules/architecture-guardrails.md +2 -1
  254. package/docs/rules/deployment.md +7 -0
  255. package/docs/rules/engineering-with-codex-openai.md +48 -9
  256. package/docs/rules/harness.md +106 -0
  257. package/docs/rules/pre-release-checklist.md +72 -33
  258. package/docs/rules/release.md +303 -0
  259. package/docs/rules/testing.md +70 -0
  260. package/docs/rules/validation.md +16 -7
  261. package/examples/claude/skills/mycodemap-repo-analyzer/SKILL.md +294 -0
  262. package/examples/claude/skills/mycodemap-repo-analyzer/references/analysis-guide.md +166 -0
  263. package/examples/claude/skills/mycodemap-repo-analyzer/references/module-analysis-guide.md +150 -0
  264. package/mycodemap.config.schema.json +1 -1
  265. package/package.json +9 -6
  266. package/scripts/hooks/templates/commit-msg +38 -0
  267. package/scripts/hooks/templates/pre-commit +224 -0
  268. package/scripts/pre-release-check.js +4 -4
  269. package/scripts/release.sh +1 -1
  270. package/scripts/sync-analyze-docs.js +2 -2
  271. package/scripts/validate-docs.js +395 -29
  272. package/docs/references/tmp.md +0 -527
@@ -1,11 +1,14 @@
1
1
  ---
2
2
  date: 2026-04-15
3
+ updated: 2026-04-29
3
4
  topic: executable-architecture-constitution
4
5
  focus: Pivot CodeMap to an "Executable Architecture Constitution" — making design.md a diff-aware, git-history-risk-weighted, CI-enforceable gate
5
6
  ---
6
7
 
7
8
  # Ideation: Executable Architecture Constitution
8
9
 
10
+ > **状态更新(2026-04-29)**:本文档原始包含 7 个想法,其中 #1(Diff-Aware Contract Enforcement)与 #3(Revive Git History Risk Scoring)已实现并归档至 `docs/archive/ideation/2026-04-15-executable-architecture-constitution-ideation-archive.md`。本文档保留剩余 5 项。
11
+
9
12
  ## Codebase Context
10
13
 
11
14
  **Project**: CodeMap — TypeScript CLI tool that generates structured code context for AI/Agents (dependency graphs, symbol maps, etc.). Currently pivoting from "AI code map tool" to "Executable Architecture Constitution" — an architecture contract governance engine.
@@ -28,31 +31,15 @@ focus: Pivot CodeMap to an "Executable Architecture Constitution" — making des
28
31
 
29
32
  ## Ranked Ideas
30
33
 
31
- ### 1. Diff-Aware Contract Enforcement
32
- **Description:** Upgrade `mycodemap verify` into a true contract enforcer that scans `src/` code. By default, only validate files touched by `git diff` and their dependency chains. Return non-zero exit codes when `layer_direction`, `forbidden_imports`, or `module_public_api_only` rules are violated.
33
- **Rationale:** This is the core product soul of the pivot. Today `design verify` only checks handoff drift and never touches source code — creating a dangerous false sense of security for users.
34
- **Downsides:** Bridging design.md's text constraints with tree-sitter symbol extraction requires careful engineering for the first rule.
35
- **Confidence:** 90%
36
- **Complexity:** Medium
37
- **Status:** Unexplored
38
-
39
- ### 2. SQLite + In-Memory Graph Storage Migration
34
+ ### 1. SQLite + In-Memory Graph Storage Migration
40
35
  **Description:** Remove the KùzuDB adapter and replace it with `better-sqlite3` for persisting symbol relationships, plus a lightweight in-memory directed graph (Map/Set adjacency list) loaded at startup. The same storage layer should handle code graphs, git blame history, and contract metadata.
41
36
  **Rationale:** KùzuDB installation failures are the top onboarding friction. SQLite's single-file nature turns CodeMap into a version-controllable CLI tool rather than a system requiring database ops.
42
37
  **Downsides:** Must validate startup time and memory footprint against large codebases (target: <1s for 10K files, <200MB RAM).
43
38
  **Confidence:** 85%
44
39
  **Complexity:** Medium-High
45
- **Status:** Unexplored
46
-
47
- ### 3. Revive Git History Risk Scoring (GRAVITY/HEAT/IMPACT)
48
- **Description:** Harden the existing but dormant `calculateRiskScore` in `src/orchestrator/workflow/git-analyzer.ts` and rewire the GRAVITY/HEAT/IMPACT three-dimensional model into `verify` and `impact` outputs.
49
- **Rationale:** Competitors cannot replicate the causal narrative of "who changed this block, what regressions this dependency chain caused before." The formula is already designed — it just needs to be wired up.
50
- **Downsides:** Requires high-quality historical data (rollbacks, incident correlations); young codebases may have weak signal.
51
- **Confidence:** 80%
52
- **Complexity:** Medium
53
- **Status:** Unexplored
40
+ **Status:** Partially Implemented (`better-sqlite3` added to `package.json`, but KùzuDB adapter not yet removed)
54
41
 
55
- ### 4. Auto-Generate design.md from Existing Codebase
42
+ ### 2. Auto-Generate design.md from Existing Codebase
56
43
  **Description:** Instead of asking humans to write `design.md` from scratch, use the existing tree-sitter parser to scan `src/` for module boundaries and public APIs, then generate a baseline contract. Users only review and lock it.
57
44
  **Rationale:** Eliminates the root cause of "docs vs code divergence." If contract generation cost approaches zero, maintenance cost collapses too.
58
45
  **Downsides:** Auto-generated rules may be too permissive or capture too many implementation details; needs smart UX to "lock" which rules matter.
@@ -60,7 +47,7 @@ focus: Pivot CodeMap to an "Executable Architecture Constitution" — making des
60
47
  **Complexity:** Medium
61
48
  **Status:** Unexplored
62
49
 
63
- ### 5. Auto-Generate Architecture Remediation Patches
50
+ ### 3. Auto-Generate Architecture Remediation Patches
64
51
  **Description:** When `verify` finds a module boundary violation, don't just report it — generate a concrete refactoring patch (e.g., "move this import down to the adapter layer").
65
52
  **Rationale:** In the AI era, "errors without fixes" is a half-measure. This was also highlighted in Codex's second opinion as a core element of the coolest version.
66
53
  **Downsides:** Requires semantic understanding beyond import graphs; fully automated fixes risk introducing bugs.
@@ -68,7 +55,7 @@ focus: Pivot CodeMap to an "Executable Architecture Constitution" — making des
68
55
  **Complexity:** High
69
56
  **Status:** Unexplored
70
57
 
71
- ### 6. Self-Healing Design Contract (Drift Approval)
58
+ ### 4. Self-Healing Design Contract (Drift Approval)
72
59
  **Description:** Allow `design.md` to evolve with the code through an approval workflow. When drift is detected, provide `codemap design evolve --approve` to snapshot current code boundaries back into the contract as the new baseline.
73
60
  **Rationale:** Architecture decay is an organizational norm. If contracts forever forbid drift, they get abandoned. A reviewable, approvable evolution mechanism is the only way they survive long-term.
74
61
  **Downsides:** Requires strict versioning and multi-level approval, otherwise it becomes a channel for "legitimizing tech debt."
@@ -76,7 +63,7 @@ focus: Pivot CodeMap to an "Executable Architecture Constitution" — making des
76
63
  **Complexity:** Medium
77
64
  **Status:** Unexplored
78
65
 
79
- ### 7. MCP `verify_contract` Tool
66
+ ### 5. MCP `verify_contract` Tool
80
67
  **Description:** Wrap the `design verify` JSON output contract as an MCP Server tool for Claude Code / Cursor to call before every code modification.
81
68
  **Rationale:** Minimal engineering investment for maximum ecosystem leverage. Transforms CodeMap from "a CLI developers remember to run" into "infrastructure AI calls by default."
82
69
  **Downsides:** The MCP ecosystem is still early; interface standardization may shift.
@@ -100,3 +87,4 @@ focus: Pivot CodeMap to an "Executable Architecture Constitution" — making des
100
87
  ## Session Log
101
88
 
102
89
  - 2026-04-15: Initial ideation — ~40 candidates generated across 4 frames, 7 survived after adversarial filtering
90
+ - 2026-04-29: #1 and #3 verified as fully implemented and archived
@@ -0,0 +1,51 @@
1
+ ---
2
+ date: 2026-04-20
3
+ updated: 2026-04-29
4
+ topic: mycodemap-init-enhancements
5
+ focus: 把 mycodemap init 从"创建根目录配置文件"升级为"项目级 AI 助手基础设施初始化器"
6
+ mode: repo-grounded
7
+ ---
8
+
9
+ # Ideation: mycodemap init enhancements
10
+
11
+ > **状态更新(2026-04-29)**:本文档原始包含 6 个想法,其中 #1–#5 已实现并归档至 `docs/archive/ideation/2026-04-20-mycodemap-init-enhancements-ideation-archive.md`。本文档仅保留未实现项 #6 及其相关上下文。
12
+
13
+ ## Grounding Context
14
+
15
+ ### Codebase Context
16
+
17
+ - [证据] `src/cli/first-run-guide.ts` 已把 marker 放进 `.mycodemap/`,但欢迎语仍把 init 叙述成"初始化配置"而不是"初始化 AI 工作区"。
18
+ - [证据] 仓库已经拥有可复用的 `.githooks/`、规则校验脚本、first-run guide、chalk + emoji + 中文 CLI 风格。
19
+
20
+ ### Past Learnings
21
+
22
+ - [推论] 当前最大的产品问题不是"功能不存在",而是"看起来成功但其实只做了一部分"。
23
+ - [推论] 半迁移状态应该被显式解释、对账和修复,而不是继续依赖隐式 fallback。
24
+ - [证据] 本 phase 已锁定:不自动修改用户 `CLAUDE.md` / `AGENTS.md`,并要求在 `.mycodemap/` 中集中化 config、rules、workflow、logs 等资产。
25
+
26
+ ### External Context
27
+
28
+ - [推论] 2024–2026 的主流 AI / dev tooling 明显收敛到"双层结构":隐藏目录存放 tool-owned 资产,显式文件存放 team-owned / shared rules。
29
+ - [推论] 最贴近市场共识的做法不是自动改用户上下文文件,而是生成 tool-owned bundle + 明确的人工接入片段。
30
+
31
+ ## Ranked Ideas
32
+
33
+ ### 1. First-Run Concierge + Bootstrap Profiles
34
+ **Description:** [推论] 把 first-run guide 重写成状态驱动的 remediation concierge,并用少量 profile(如 Minimal / Guardrails / Team Ready)承载交互式一键选择。
35
+ **Rationale:** [推论] 这是最低成本修复 mental model 的方法:既改善第一分钟体验,也避免 init 变成一长串低层开关。
36
+ **Downsides:** [观点] profile 设计如果过粗,会掩盖复杂边界;如果过细,又会退化回问卷。
37
+ **Confidence:** 84%
38
+ **Complexity:** Low-Medium
39
+ **Status:** Unexplored
40
+
41
+ ## Rejection Summary
42
+
43
+ | # | Idea | Reason Rejected |
44
+ |---|------|-----------------|
45
+ | 1 | `Project Safety Contracts` framing | [观点] 叙事强但产品增量弱,更适合后续命名或定位文案 |
46
+ | 2 | `Board Game Setup Tray` | [推论] 是 Profiles 的隐喻版,没有新增结构价值 |
47
+
48
+ ## Session Log
49
+
50
+ - 2026-04-20: 初始 ideation,6 个候选想法
51
+ - 2026-04-29: #1–#5 已实现并归档;本文档收缩为仅保留未实现项 #6
@@ -0,0 +1,114 @@
1
+ ---
2
+ date: 2026-04-22
3
+ updated: 2026-04-29
4
+ topic: rules-entry-docs-optimization-consolidated
5
+ focus: 融合两份 2026-04-22 ideation 的最佳部分,形成更强的 rules / AGENTS.md / CLAUDE.md 终稿提案
6
+ mode: repo-grounded
7
+ sources:
8
+ - docs/archive/ideation/2026-04-22-harness-rules-entry-docs-optimization-ideation.md
9
+ - docs/archive/ideation/2026-04-22-rules-claude-agents-optimization-ideation.md
10
+ ---
11
+
12
+ # Ideation: Consolidated rules / AGENTS.md / CLAUDE.md optimization
13
+
14
+ > **状态更新(2026-04-29)**:本文档原始包含 6 个想法,其中 #1(One Constitution, Two Thin Adapters)已实现并归档至 `docs/archive/ideation/2026-04-22-rules-entry-docs-optimization-consolidated-ideation-archive.md`。本文档保留剩余 5 项。
15
+
16
+ ## Grounding Context
17
+
18
+ ### Codebase Context
19
+
20
+ - [证据] 仓库自我定义已经很清楚:`AGENTS.md` 应是"强约束 + 路由",`CLAUDE.md` 应是"启动清单、检索顺序、最小操作手册";而且入口文档应该保持短小:`AGENTS.md:3`、`AGENTS.md:14`、`AGENTS.md:15`、`AGENTS.md:329`。
21
+ - [证据] 但当前根 `CLAUDE.md` 同时承载了 post-edit 默认验证、路径路由、rule-system 默认值、CLI dogfood、交付清单,已经超过"薄入口"定位:`CLAUDE.md:25`、`CLAUDE.md:43`、`CLAUDE.md:57`、`CLAUDE.md:65`、`CLAUDE.md:80`。
22
+ - [证据] `.claude/CLAUDE.md` 又额外定义了任务开始前/结束后清单、TDD 流程、禁止行为、commit 策略和 `npm run check:all`,与根 `CLAUDE.md` 形成双入口:`.claude/CLAUDE.md:1`、`.claude/CLAUDE.md:7`、`.claude/CLAUDE.md:33`、`.claude/CLAUDE.md:51`。
23
+ - [证据] 文档已经主张"先路由、再按需下钻"和"按改动类型做最小验证",但根 `CLAUDE.md` 仍保留一套统一 post-edit 命令与固定 checklist,存在叙事冲突:`docs/rules/README.md:19`、`docs/rules/validation.md:5`、`docs/rules/validation.md:29`、`docs/rules/validation.md:31`、`CLAUDE.md:25`。
24
+ - [证据] 当前部分验证命令存在"文档真、脚本假"的信任问题:`docs/rules/architecture-guardrails.md` 把 `npm run check:architecture` 列为快速验证,但 `package.json` 中它仍是 `echo` stub;`check:unused` 也是同样情况:`docs/rules/architecture-guardrails.md:24`、`docs/rules/architecture-guardrails.md:29`、`package.json:45`、`package.json:46`、`package.json:48`。
25
+ - [证据] 仓库处于过渡态,文档体系与执行面并存新旧结构;历史归档仍在,少量指南仍在根层,官方要求"以实际存在的文件为准":`AGENTS.md:324`、`AGENTS.md:327`、`AGENTS.md:329`。
26
+ - [推论] 因此当前核心问题不是"规则数量不足",而是"shared truth source 不够清晰 + 入口过载 + 某些执行约束与真实自动化不一致"。
27
+
28
+ ### External Context
29
+
30
+ - [证据] OpenAI Codex 官方 `AGENTS.md` 指南强调:写长期稳定、项目特有、可快速扫读的指令;复杂说明应拆到配套 markdown,而不是把一切都塞进根入口。来源:https://developers.openai.com/codex/guides/agents-md
31
+ - [证据] OpenAI Codex best practices 还强调:应通过 retrospective 把重复失败模式沉淀为更专门的技能或流程,而不是继续膨胀通用指令文件。来源:https://developers.openai.com/codex/learn/best-practices
32
+ - [证据] Claude Code 官方 memory 文档建议共享 memory 维持在约 200 行以内;需要更长时,应拆文件并用 `@path` 导入,同时支持在 `CLAUDE.md` 中导入 `AGENTS.md` 与用 `.claude/rules/` 的 `paths:` 做路径作用域加载。来源:https://code.claude.com/docs/en/memory
33
+ - [证据] Claude Code 官方 best practices / hooks 文档强调:`CLAUDE.md` 更适合行为指导,hooks 与 settings 更适合确定性 enforcement;长会话和超长上下文会拖垮效果。来源:https://code.claude.com/docs/en/best-practices 、https://docs.anthropic.com/en/docs/claude-code/hooks
34
+ - [证据] 2026 社区与研究信号都在同一方向上收敛:instruction 文件过长、过泛、缺少可执行细节时会显著掉质;保留最小必要要求比堆叠规则更有效。来源:https://dev.to/reporails/the-state-of-ai-instruction-quality-35mn 、https://arxiv.org/abs/2602.11988
35
+
36
+ ### Synthesis
37
+
38
+ - [推论] 文档一的强项是"战略方向正确、外部 grounding 充分、结构完整",文档二的强项是"repo-specific 问题抓得具体、能直接落实施工项"。
39
+ - [推论] 更强的终稿不应在两者之间二选一,而应采用"文档一的治理框架 + 文档二的具体问题卡片"。
40
+
41
+ ## Ranked Ideas
42
+
43
+ ### 1. Validation Router + No Ghost Commands
44
+ **Description:** [推论] 把根 `CLAUDE.md` 中"修改后必须执行"改写为 1 屏验证决策树:按改动类型跳转到 `docs/rules/validation.md`;同时禁止在入口与规则文档中引用 `echo` stub 命令,所有写进 quick-start 的命令都必须是真实可运行命令。
45
+ **Rationale:** [推论] 这是把 harness 的"最小必要验证"从口号变成真正可信的路由;它还顺手修掉最伤信任的"跑了命令但其实没验证"的问题。
46
+ **Repo-Specific Leverage:** [证据] `docs/rules/architecture-guardrails.md:29` 当前推荐 `npm run check:architecture`,但 `package.json:46` 仍是提示安装 dependency-cruiser 的 `echo`;`check:unused` 在 `package.json:48` 也是同类问题。
47
+ **Downsides:** [观点] 若短期内不想落地真实检查,就必须先从入口与规则文档中移除这些命令,否则只会继续制造假安全感。
48
+ **Confidence:** 96%
49
+ **Complexity:** Medium
50
+ **Status:** Partially Implemented(根 `CLAUDE.md` 已改为纯路由,但 `package.json` 与 `docs/rules/architecture-guardrails.md` 中的 ghost commands 仍在)
51
+
52
+ ### 2. Behavior / Enforcement Split
53
+ **Description:** [推论] 明确分层:`AGENTS.md` / `CLAUDE.md` 负责行为与路由;`.claude/settings*.json`、hooks、`scripts/validate-rules.py`、CI 负责确定性 enforcement;`docs/rules/*` 只解释何时触发、如何恢复、失败后果是什么。
54
+ **Rationale:** [推论] 这既符合 Claude 官方"behavioral guidance vs technical enforcement"的划分,也与本仓库已有 `report-only` / `soft_gate` / `hard_gate` 设计天然一致。
55
+ **Repo-Specific Leverage:** [证据] 根 `CLAUDE.md` 现在同时扮演"行为协议""默认 gate 配置""交付 checklist"三种角色:`CLAUDE.md:57`、`CLAUDE.md:61`、`CLAUDE.md:62`、`CLAUDE.md:63`、`CLAUDE.md:80`。
56
+ **Downsides:** [观点] 需要重写措辞,让"默认路由/默认验证"与"真正 blocker"区分得非常清楚,否则用户会误会规则被放松。
57
+ **Confidence:** 93%
58
+ **Complexity:** Medium
59
+ **Status:** Partially Implemented(行为路由已分离,但缺少 `scripts/validate-rules.py` 等专门 enforcement 工具,部分 enforcement 仍由 `validate-docs.js` 兼任)
60
+
61
+ ### 3. Path-Scoped Governance for a Transitional Repo
62
+ **Description:** [推论] 根入口只维护"如何选规则"的导航,细节继续下沉到按路径加载的文档:Codex 依赖更近的 `AGENTS.md`,Claude 依赖 `.claude/rules/**` 的 `paths:`;同时在根入口显式声明"当前是迁移仓库,MVP3 层级优先,但历史目录仍可能存在"。
63
+ **Rationale:** [推论] 这把文档二的"路由覆盖不足"问题与文档一的"progressive disclosure"主张合并起来:根文件不需要越来越长,但路径规则必须覆盖真实项目形态。
64
+ **Repo-Specific Leverage:** [证据] 仓库已明确"过渡说明"和"入口文档应保持短小":`AGENTS.md:324`、`AGENTS.md:327`、`AGENTS.md:329`;根 `CLAUDE.md` 当前路由表仍是高度 layer-centric:`CLAUDE.md:43` 到 `CLAUDE.md:55`。
65
+ **Downsides:** [观点] 若没有命名约定和 archive discipline,路径化后会把问题从"根太长"转移成"子规则散落"。
66
+ **Confidence:** 91%
67
+ **Complexity:** Medium-High
68
+ **Status:** Unexplored(不存在 `.claude/rules/` 目录,无 `paths:` 配置)
69
+
70
+ ### 4. Live Rulebook + Archive Demotion
71
+ **Description:** [推论] 明确标注 live governance surface:只认 `AGENTS.md`、根 `CLAUDE.md`、`.claude/CLAUDE.md`、`docs/rules/README.md` 与活跃规则文档;历史 rollout、模板母本、迁移提案要统一降级为 reference/archive,并在文件头写明"不可作为当前执行真相"。
72
+ **Rationale:** [推论] 对 agent 来说,最贵的不是少一条规则,而是不知道哪份文档才是现在真的生效。
73
+ **Repo-Specific Leverage:** [证据] 仓库已承认"历史归档仍保留、少量操作指南仍在根层、执行时以实际存在文件为准":`AGENTS.md:327`。
74
+ **Downsides:** [观点] 这是文档身份治理,不是炫目的功能增强;但如果不做,后续所有瘦身都会被旧文档重新污染。
75
+ **Confidence:** 92%
76
+ **Complexity:** Low-Medium
77
+ **Status:** Partially Implemented(`docs/archive/` 目录存在,但并非所有历史文档都被显式标注"不可作为当前执行真相";`docs/ideation/` 中仍有未归档的历史文档)
78
+
79
+ ### 5. Governance Self-Audit + Generated Shared Tables
80
+ **Description:** [推论] 把"规则重复"和"规则自身腐烂"合并成一个治理能力:高频重复表格(如代码红线、职责映射、验证入口)应由单一结构化源生成;并定期审计链接、命令存在性、路径路由覆盖和 live/reference 身份是否一致。
81
+ **Rationale:** [推论] 文档二抓住了 repo 的真实维护痛点,而文档一提供了更高层的约束原则;把两者合并后,能防止"今天瘦身,明天重新 drift"。
82
+ **Repo-Specific Leverage:** [证据] 当前重复与漂移已在多处出现:`AGENTS.md:127`、`docs/rules/engineering-with-codex-openai.md:89`;而命令存在性问题已被 `package.json:46`、`package.json:48` 证明。
83
+ **Downsides:** [观点] 这已经逼近"小型文档治理系统"了;若一次做太大,容易反向过度工程化。
84
+ **Confidence:** 88%
85
+ **Complexity:** Medium
86
+ **Status:** Partially Implemented(`scripts/validate-docs.js` 已实现入口文档自动化审计,但无"从单一结构化源生成重复表格"的机制,也无定期审计 package.json stub 命令的能力)
87
+
88
+ ## Recommended Final Direction
89
+
90
+ - [观点] **当前首选主轴**:`#2 Validation Router + No Ghost Commands`
91
+ 在 #1 已完成后,这是最强的信任修复:把"文档说一套、命令做一套"的错位消掉。
92
+ - [观点] **第二优先级**:`#3 Behavior / Enforcement Split`
93
+ 这是最强的长期维护修复,防止入口文件再次被确定性流程污染。
94
+ - [观点] **第三优先级**:`#4 Path-Scoped Governance`
95
+ 把路由从根文件进一步下沉到路径作用域,是 progressive disclosure 的下一步。
96
+ - [推论] 若只允许保留一个总原则,应是:**根入口只负责"让 agent 知道去哪读、何时验证、谁在阻断",不负责承载全部细节、全部命令、全部历史。**
97
+
98
+ ## Rejection Summary
99
+
100
+ | # | Idea | Reason Rejected |
101
+ |---|------|-----------------|
102
+ | 1 | `Universal Mega Entry File` | [推论] 与 Codex / Claude 官方"短入口 + 路由 + 作用域加载"方向完全相反。 |
103
+ | 2 | `Per-Tool Twin Rulebooks` | [推论] 会把多 agent 共享规则重新复制成两套真相,长期必漂移。 |
104
+ | 3 | `Everything as Structured YAML First` | [观点] 对重复表格很有价值,但若把全部治理文档都数据化,会过早走向工具化治理。 |
105
+ | 4 | `Only Fix Ghost Commands` | [推论] 只能修补信任问题,不能解决入口过载与 shared truth source 不清晰。 |
106
+ | 5 | `Only Merge the Two CLAUDE Files` | [推论] 不触及 `AGENTS.md` / `docs/rules/*` 的职责划分,仍会留下多真相竞争。 |
107
+ | 6 | `Archive Nothing, Just Add More Cross Links` | [观点] 交叉链接能缓解迷路,不能解决"哪份文档是 live contract"的根问题。 |
108
+
109
+ ## Session Log
110
+
111
+ - [证据] 2026-04-22:对比 `docs/archive/ideation/2026-04-22-harness-rules-entry-docs-optimization-ideation.md` 与 `docs/archive/ideation/2026-04-22-rules-claude-agents-optimization-ideation.md`,确认前者更强在治理框架与外部 grounding,后者更强在 repo-specific 问题识别。
112
+ - [证据] 2026-04-22:补充校验根 `CLAUDE.md`、`.claude/CLAUDE.md`、`package.json`、`docs/rules/architecture-guardrails.md`,把"双入口""ghost commands""迁移仓库"三个具体问题收敛进统一提案。
113
+ - [推论] 2026-04-22:最终终稿选择"保留文档一的骨架,吸收文档二最具体的实施抓手",而不是继续保留两份并行 ideation。
114
+ - 2026-04-29:验证 #1 完全实现并归档;更新剩余项状态为 Partially Implemented / Unexplored
@@ -0,0 +1,256 @@
1
+ # Ideation: CodeMap User Experience, Installation/Configuration, and Human vs AI Agent Experience
2
+
3
+ **Date:** 2026-04-29
4
+ **Focus:** User experience, installation and configuration experience, human vs AI agent experience
5
+ **Run ID:** 9e3b69d4496d7cc8
6
+ **Agents dispatched:** 9 (codebase scan + learnings + web research + 6 ideation frames)
7
+
8
+ ---
9
+
10
+ ## Grounding Summary
11
+
12
+ ### Codebase Context
13
+ CodeMap is a TypeScript/Node.js ESM CLI tool generating structured code maps (`AI_MAP.md`, `codemap.json`) for AI/Agent consumption. Uses `commander`, `tree-sitter`, `better-sqlite3`, `hono`. Layered architecture with `src/cli-new/` coexisting alongside `src/cli/`, signaling migration in progress. Heavy AI-agent governance docs (`AGENTS.md`, `CLAUDE.md`, `.claude/`, `.kimi/`, `.agents/`).
14
+
15
+ ### Key Pain Points
16
+ - **Native dependency install friction** (`better-sqlite3`, `tree-sitter` often fail without build tools) — #1 drop-off point
17
+ - **Broken promises in `package.json`** (`check:architecture`, `check:unused` are no-ops)
18
+ - **Dual CLI confusion** (`cli/` + `cli-new/`)
19
+ - **MCP underpowered** (only 2 tools: `codemap_query`, `codemap_impact`)
20
+ - **Agent interface inconsistency** (`--json` not uniform, silent failures, low confidence on explicit paths)
21
+ - **Onboarding overload** — manual skill copying from `examples/`
22
+ - **Agent dogfood rated 6/10** agent-friendly (2026-04-17)
23
+
24
+ ### Past Learnings
25
+ - `init` redesigned as "project state reconciler" with `.mycodemap/` workspace (v1.7 shipped)
26
+ - v0.5.1 install bug: `devDependencies` used at runtime caused global install crashes
27
+ - CLI surface cleanup (v1.0): removed commands with explicit failure + migration messages
28
+ - Three-layer readiness gate (`hard`/`warn-only`/`fallback`) from v1.11
29
+
30
+ ### External Context
31
+ - CLI is beating MCP for coding agents in 2025-2026 due to token efficiency
32
+ - Agent-native patterns: JSON-first, structured errors, predictable exit codes, field filtering, `--help-json`, progress on stderr
33
+ - Prior art: `hubspot-cli` (dual entry point), `gdelt-cli` (machine-readable help), `discord-cli` (YAML structured output)
34
+ - Snyk praised for smoothest onboarding (`snyk test` = seconds)
35
+ - Research pain points: false positives up to 60%, lack of meaningful messages, configuration effort
36
+
37
+ ---
38
+
39
+ ## Raw Candidate Pool
40
+
41
+ 52 candidates generated across 6 ideation frames + 4 cross-cutting combinations. Full list preserved in checkpoint:
42
+ `/tmp/compound-engineering/ce-ideate/9e3b69d4496d7cc8/raw-candidates.md`
43
+
44
+ ### Frame Summary
45
+ | Frame | Count | Key Themes |
46
+ |-------|-------|------------|
47
+ | Pain and friction | 8 | Graceful degradation, presumptive onboarding, unified CLI, agent handshake, streaming MCP, confidence metadata, pre-install check, doctor |
48
+ | Inversion/removal/automation | 8 | Zero-command install, config-as-cache, honest CLI, intent router, JSON-RPC daemon, auto-provisioned skills, failure-to-action, CLI-as-MCP gateway |
49
+ | Assumption-breaking | 8 | Zero-install runtime, split human/agent interface, self-healing init, SDK mode, confidence-first output, progressive disclosure, git-native maps, declarative contract |
50
+ | Leverage/compounding | 8 | WASM-first build, auto-reconciling state, interface contract architecture, zero-config preview, structured errors, skill ecosystem, agent-native mode, uncertainty budget |
51
+ | Cross-domain analogy | 8 | Auto-mode installer, RPG onboarding, Netflix recommendations, language server daemon, tasting menu presets, accessibility profiles, pairing mode, confidence routing |
52
+ | Constraint-flipping | 8 | 100ms install, self-teaching CLI, AI-first default, fingerprint config, unconfigurable tool, MCP-primary, concierge daemon, self-healing promise |
53
+
54
+ ---
55
+
56
+ ## Explicit Rejections (Why These Did Not Survive)
57
+
58
+ ### Rejected: Incremental / Already In Progress
59
+ - **Unified CLI Surface with Subcommand Shadows** — Addresses real pain but is essentially "finish the cli-new migration," already in progress. Not an ideation breakthrough.
60
+ - **Presumptive Onboarding / Config Proposed Not Asked** — Overlaps with existing v1.7 init reconciler design; less precise than Zero-Config Preview.
61
+ - **Streaming MCP with Progress Tokens** — Good but naturally follows from CLI-as-MCP Gateway; not a standalone priority.
62
+
63
+ ### Rejected: Over-Engineered / Heavy Solutions to Simple Problems
64
+ - **Agent Handshake Protocol** — Over-engineered for the actual problem: inconsistent `--json` and silent failures. A formal pre-command negotiation adds complexity; explicit flags/env vars are simpler.
65
+ - **Smart Home "Pairing Mode" Auto-Negotiation** — Auto-detecting agent vs human is fragile (env vars, parent process names). Explicit `--agent` or `CODEMAP_MACHINE=1` is more reliable.
66
+ - **Intent-Based Unified Router / Natural Language** — "Map my backend API surface" is cool but adds NLP complexity for marginal gain over good subcommand naming.
67
+
68
+ ### Rejected: Too Speculative / Missing Prerequisites
69
+ - **100ms Install Mandate: Pure-JS Mode** — More extreme than WASM-first. Node 22+ `node:sqlite` is not universally available. Pure-JS tree-sitter grammar pack doesn't exist yet.
70
+ - **The Embedded CodeMap / SDK Mode** — Powerful but scope explosion. If WASM-first happens, SDK mode becomes natural. Doing both simultaneously is too much.
71
+ - **10x Budget: Agent Concierge Mode / Daemon + IDE Extension** — Visionary but the project already deferred viz/TUI/API (MVP3 PRD). A daemon is an architectural commitment for a future milestone.
72
+ - **No Users, Only Agents: MCP as Primary Interface** — Inverts reality: the CLI exists and works. Making MCP primary would discard human UX investment.
73
+
74
+ ### Rejected: Provocative but Not Actionable
75
+ - **Team of One: The Unconfigurable Tool** — Radical convention-over-configuration that would alienate power users and non-standard projects.
76
+ - **Self-Correcting CLI Surface / Honest CLI** — "CLI audits itself on startup" is harder to implement and explain than a `doctor` command. Overlaps with #7 survivor.
77
+ - **The Declarative Project Contract / codemap.yaml** — Overlaps with existing `.mycodemap/config.json` approach. YAML doesn't add enough value to justify migration.
78
+
79
+ ### Rejected: Framing Devices, Not Technical Directions
80
+ - **Video Game Accessibility Profiles** — Good analogy but essentially combines "split interface" + "AI-first default" into a framing device.
81
+ - **RPG "First Quest" Tutorial Onboarding** — UX polish framing of Zero-Config Preview. The tutorial aspect is surface, not architecture.
82
+ - **Fine Dining "Tasting Menu" Presets** — Same as accessibility profiles; a UX framing of modes that already exist in other forms.
83
+ - **Airport Customs "Green Lane / Red Lane"** — Clever analogy but confidence routing is already captured by Confidence-First Output.
84
+
85
+ ### Rejected: Overlap with Stronger Survivors
86
+ - **Pre-Install Environment Contract Check** — Narrower than WASM-first; solves same problem less completely.
87
+ - **The Self-Healing Init** — Covered by existing init reconciler + doctor command.
88
+ - **Auto-Reconciling Project State** — Extension of existing v1.7 init reconciler; incremental, not breakthrough.
89
+ - **Netflix "Because You Watched" Config Recommendations** — Incremental enhancement to init; not a distinct direction.
90
+ - **Structured Error Recovery Protocol** — Overlaps heavily with Failure-to-Action Protocol.
91
+ - **Configuration as a Cache, Not a Contract** — Interesting reframing but risks making configuration opaque and hard to debug.
92
+ - **Agent-Native Streaming Protocol / JSON-RPC Daemon** — High complexity; daemon mode deferred per project scope.
93
+ - **No Docs Allowed: The Self-Teaching CLI** — Framing device; interactive help is a feature, not a strategic direction.
94
+ - **1M Users, Zero Support: Auto-Configured by Fingerprint** — Overlaps with Zero-Config Preview + existing init reconciler.
95
+
96
+ ---
97
+
98
+ ## Top Survivors (Ranked)
99
+
100
+ ### 1. Machine-Readable Interface Contract as Core Architecture
101
+ **Source:** Leverage frame
102
+ **Idea:** Define the entire CLI surface as a formal schema (commands, args, flags, output shapes, error codes) in a single source-of-truth file. Generate the human CLI parser, the MCP server, `--help-json`, shell completions, and documentation from this schema. Never hand-write argument parsing or output formatting again.
103
+
104
+ **Why it survived:**
105
+ - **Highest leverage:** Every new command automatically gets full agent support, MCP exposure, and perfect consistency.
106
+ - **Addresses root cause:** `--json` inconsistency, MCP underpoweredness, and agent-friendly 6/10 rating all stem from hand-maintained dual surfaces.
107
+ - **Compounding:** As the CLI grows, the benefit multiplies. Adding one schema entry creates CLI flag, MCP tool, help text, and completion in one shot.
108
+ - **Grounded:** Agent-native patterns from external research explicitly demand JSON-first, structured errors, and `--help-json`. This makes them free.
109
+
110
+ **Risks:** Upfront schema design effort; migration of existing commands. Mitigation: incremental adoption, one command at a time.
111
+
112
+ ---
113
+
114
+ ### 2. WASM-First Build, Native-Opt-In Runtime
115
+ **Source:** Leverage frame / Constraint-flip frame
116
+ **Idea:** Ship `tree-sitter` and `better-sqlite3` as WASM modules by default; detect and opportunistically upgrade to native binaries only when the environment supports it and the user opts in. `npm install codemap` works on every platform, every CI image, every fresh laptop with zero build tools.
117
+
118
+ **Why it survived:**
119
+ - **#1 pain point killer:** Native dependency install friction is the top drop-off point. This eliminates it entirely.
120
+ - **Proven pattern:** esbuild's WASM fallback mode works in the same ecosystem. `web-tree-sitter` exists. Node 22 ships `node:sqlite` built-in.
121
+ - **Platform coverage:** Reaches 100% of users instead of 70% who have build tools installed.
122
+ - **Agent value:** Eliminates environment-dependent failures that break automated workflows.
123
+
124
+ **Risks:** Performance regression for very large repos. Mitigation: native opt-in for performance-sensitive users; benchmark WASM vs native.
125
+
126
+ ---
127
+
128
+ ### 3. CLI-as-MCP Automatic Gateway
129
+ **Source:** Inversion frame
130
+ **Idea:** Implement a generic `--mcp-stdio` adapter that dynamically exposes every CodeMap CLI subcommand as an MCP tool with auto-generated JSON schemas derived from TypeScript types (or the Interface Contract schema). Adding a new CLI command instantly creates a new MCP tool with zero extra work. The entire CLI surface becomes the MCP surface.
131
+
132
+ **Why it survived:**
133
+ - **Closes the integration gap:** MCP is currently underpowered (2 tools) while CLI has 20+ commands. Agents route around MCP to CLI because of this.
134
+ - **Eliminates drift:** No more hand-maintained MCP server that lags behind CLI features.
135
+ - **Depends on #1:** Best paired with Interface Contract architecture, but can start with TypeScript type reflection.
136
+ - **High agent impact:** Transforms MCP from a second-class citizen into a first-class, complete interface.
137
+
138
+ **Risks:** MCP schema generation must handle complex nested types. Mitigation: start with simple commands, iterate.
139
+
140
+ ---
141
+
142
+ ### 4. AI-First Default, Human-Pretty Optional
143
+ **Source:** Constraint-flip frame / Assumption-breaking frame
144
+ **Idea:** Flip the output paradigm. All commands emit structured JSON/NDJSON on stdout by default. A `--human` flag (or auto-detected TTY) pipes through a built-in renderer for tables, spinners, and color. Progress goes to stderr as structured events. This makes the CLI natively composable for agents without special flags.
145
+
146
+ **Why it survived:**
147
+ - **Directly fixes agent inconsistency:** The current `--json` bolt-on is inconsistent across commands. Making structured output the default forces consistency.
148
+ - **External evidence:** Research confirms CLI beats MCP for token efficiency when structured. This maximizes that advantage.
149
+ - **Low implementation risk:** TTY detection is standard; renderers can be built incrementally.
150
+ - **Composable:** `codemap analyze | jq '.findings[] | select(.severity=="high")'` works out of the box.
151
+
152
+ **Risks:** Breaking change for existing human users who expect pretty output. Mitigation: major version bump; TTY auto-detection preserves current behavior for interactive use.
153
+
154
+ ---
155
+
156
+ ### 5. Zero-Config Preview / Progressive Commitment Model
157
+ **Source:** Leverage frame / Cross-domain analogy
158
+ **Idea:** `npx codemap` with no config, no init, no flags performs a full analysis and emits a rich preview (top-level summary, detected project type, sample map). It then offers: "Looks good? Run `codemap --persist` to save configuration and generate full artifacts." No setup, no decisions, no config files until the user sees value.
159
+
160
+ **Why it survived:**
161
+ - **Snyk-inspired:** Snyk is praised for smoothest onboarding because `snyk test` demonstrates value in seconds.
162
+ - **Low implementation cost:** Can be built on top of existing init reconciler and analysis pipeline.
163
+ - **High conversion impact:** Removes the fear of side effects from trying the tool.
164
+ - **Dual audience:** Humans see a preview and decide; agents can run `--persist` non-interactively.
165
+
166
+ **Risks:** Preview must be fast (<5 seconds) or it backfires. Mitigation: default to shallow/symbolic scan for preview; deep analysis on demand.
167
+
168
+ ---
169
+
170
+ ### 6. Failure-to-Action Protocol
171
+ **Source:** Inversion frame / Leverage frame
172
+ **Idea:** Every error returns a structured document containing: what was attempted, the root cause, a machine-readable remediation plan, and a confidence score. For native dep failures: auto-suggest `--wasm-fallback` or a prebuilt binary URL. For agents, errors include the exact next command to try. Errors become state transitions, not dead ends.
173
+
174
+ **Why it survived:**
175
+ - **Addresses silent failures:** The dogfood report explicitly found `analyze -i find` failing silently with near-empty JSON. This makes every failure explicit and actionable.
176
+ - **Research-backed:** Studies cite "lack of meaningful messages" as a top pain point for code analysis tools.
177
+ - **Agent self-healing:** Agents can attempt remediation without human intervention.
178
+ - **Incremental:** Can be adopted command by command; doesn't require a big-bang rewrite.
179
+
180
+ **Risks:** Remediation suggestions can be wrong, creating cascading failures. Mitigation: confidence scoring on suggestions; never auto-execute without `--apply-suggestion`.
181
+
182
+ ---
183
+
184
+ ### 7. codemap doctor as Continuous Health Monitor
185
+ **Source:** Pain frame / Constraint-flip frame
186
+ **Idea:** A living diagnostics command that audits the entire CodeMap ecosystem: detects no-op scripts in `package.json` (`check:architecture`, `check:unused`), verifies native dep health, checks `.mycodemap/` workspace drift, validates CLI vs MCP version skew, and runs agent interface regression checks. Emits both human-readable reports and machine-readable diagnostics. Can run in CI as a health gate.
187
+
188
+ **Why it survived:**
189
+ - **Familiar pattern:** `npm doctor`, `brew doctor`, `flutter doctor` — users know what to expect.
190
+ - **Addresses broken promises directly:** Surfaces the no-op scripts and other latent brokenness that erodes trust.
191
+ - **CI-friendly:** Machine-readable output enables automated health checks in CI pipelines.
192
+ - **Incremental:** Each diagnostic is a small addition; the command grows over time.
193
+
194
+ **Risks:** Can become a dumping ground for random checks. Mitigation: categorize diagnostics (install, config, runtime, agent); require evidence tags for each check.
195
+
196
+ ---
197
+
198
+ ### 8. Auto-Provisioned Agent Skills / Self-Distributing Integration
199
+ **Source:** Inversion frame
200
+ **Idea:** When CodeMap detects it is being invoked by an AI agent (via `KIMI_`, `CLAUDE_`, or `CODEX_` env vars), it automatically writes or updates the appropriate skill files into the agent's skill directory (`.claude/skills/codemap/`, `.kimi/skills/codemap/`). The tool maintains its own bindings, ensuring agents always use the latest integration layer.
201
+
202
+ **Why it survived:**
203
+ - **Directly solves onboarding overload:** "Manual skill copying from `examples/`" is explicitly cited as a pain point.
204
+ - **Self-describing:** CodeMap knows its own CLI schema better than any human; it should generate its own agent integration.
205
+ - **Version safety:** Skills stay in sync with the installed CodeMap version.
206
+ - **Low cost if paired with #1 and #3:** If we have an interface contract and auto-generated MCP, skill generation is a thin layer on top.
207
+
208
+ **Risks:** Overwriting user-customized skill files. Mitigation: write to `.mycodemap/skills/` and symlink/copy to agent dirs; never modify existing files without `--force`.
209
+
210
+ ---
211
+
212
+ ## Cross-Cutting Synthesis
213
+
214
+ Three meta-patterns emerge from the survivors:
215
+
216
+ ### A. Self-Describing Universal API (#1 + #3 + #8)
217
+ If the CLI surface is defined as a machine-readable contract, then:
218
+ - The MCP server generates automatically (#3)
219
+ - Agent skills generate automatically (#8)
220
+ - `--help-json`, shell completions, and docs generate automatically (#1)
221
+ - Every new CLI command is instantly agent-ready
222
+
223
+ This is the **highest-compounding architectural bet** in the entire ideation set.
224
+
225
+ ### B. Zero-Friction Installation & Onboarding (#2 + #5)
226
+ WASM-first eliminates install failures (#2). Zero-config preview eliminates configuration anxiety (#5). Together they create a "Snyk-class" onboarding where a new user goes from "heard about it" to "seeing value" in under 10 seconds with zero prerequisites.
227
+
228
+ ### C. Trust Architecture (#6 + #7 + confidence implications of #1)
229
+ Failure-to-action protocol makes errors recoverable (#6). Doctor command continuously audits health (#7). Interface contract ensures output schemas are predictable (#1). Together they address the agent-friendly 6/10 rating by making the tool transparent, honest, and self-healing.
230
+
231
+ ---
232
+
233
+ ## Ideas by Dimension
234
+
235
+ | Dimension | Top Idea |
236
+ |-----------|----------|
237
+ | **Workflow / DX** | Zero-Config Preview (#5) — demonstrates value before asking commitment |
238
+ | **Reliability** | WASM-First Build (#2) — eliminates #1 source of install failures |
239
+ | **Extensibility** | Interface Contract Architecture (#1) — every new feature is agent-ready by construction |
240
+ | **Missing capabilities** | CLI-as-MCP Gateway (#3) — closes the 2-tool gap |
241
+ | **Docs / Knowledge compounding** | Auto-Provisioned Skills (#8) — self-generating agent integration |
242
+ | **Quality / Maintenance** | codemap doctor (#7) — continuous health monitoring |
243
+ | **Agent experience** | AI-First Default (#4) — JSON-first, consistent, composable |
244
+ | **Error handling** | Failure-to-Action Protocol (#6) — structured, recoverable errors |
245
+
246
+ ---
247
+
248
+ ## Next Steps Menu
249
+
250
+ This ideation artifact identifies promising directions. The next step depends on what you want to do with these ideas:
251
+
252
+ 1. **Refine** — Deep-dive into one or more survivors, exploring edge cases, implementation approaches, and interdependencies.
253
+ 2. **Brainstorm** — Select one survivor and define it precisely enough for planning (requirements, boundaries, acceptance criteria). This hands off to `ce:brainstorm`.
254
+ 3. **Save and end** — Archive this ideation and return to it later when priorities shift.
255
+
256
+ > **Routing note:** `ce:ideate` answers "What are the strongest ideas worth exploring?" `ce:brainstorm` answers "What exactly should one chosen idea mean?" `ce:plan` answers "How should it be built?" Do not skip to planning from ideation output.
@@ -0,0 +1,119 @@
1
+ # 预发布自动发布故障修复记录
2
+
3
+ > 日期:2026-04-19
4
+ > 状态:已修复
5
+ > 范围:npm Trusted Publishing / GitHub Actions 发布链路 / 发布前版本校验
6
+
7
+ ## 问题摘要
8
+
9
+ - [证据] `v0.5.2-beta.0` 首次真实自动发布失败,失败 run 为 `24632519866`。
10
+ - [证据] 失败并不是 npm Trusted Publisher 配置缺失,而是发布链路中有两个代码层问题:
11
+ 1. `scripts/pre-release-check.js:112` 的 YAML 版本提取正则不支持 prerelease 版本;
12
+ 2. `.github/workflows/publish.yml:124` 在发布 prerelease 版本时没有显式传 `npm publish --tag <preid>`。
13
+ - [证据] 修复后,`v0.5.2-beta.1` 的真实自动发布成功,成功 run 为 `24632744587`。
14
+ - [证据] 发布完成后,npm dist-tag 状态为:
15
+ - `latest -> 0.5.1`
16
+ - `beta -> 0.5.2-beta.1`
17
+
18
+ ## 现象
19
+
20
+ ### 现象 1:发布前检查误判版本不一致
21
+
22
+ - [证据] `package.json`、`llms.txt`、`AI_GUIDE.md`、`AI_DISCOVERY.md` 都是 `0.5.2-beta.0`。
23
+ - [证据] 但 `scripts/pre-release-check.js` 把 `ai-document-index.yaml` 的版本解析成了 `0.5.2`,导致 prerelease 版本无法被完整识别。
24
+ - [推论] 这会让发布前检查在 beta/rc 版本上产生错误噪音,阻断或误导发布判断。
25
+
26
+ ### 现象 2:GitHub Actions 在 npm publish 阶段失败
27
+
28
+ - [证据] `v0.5.2-beta.0` 的发布 run `24632519866` 在 `Publish to NPM` 步骤失败。
29
+ - [证据] 关键报错是:`You must specify a tag using --tag when publishing a prerelease version.`
30
+ - [推论] 这说明 Trusted Publishing 本身已经工作,问题不在 npm 仓库授权,而在 workflow 对 prerelease 版本没有传 dist-tag。
31
+
32
+ ## 根因分析
33
+
34
+ ### 根因 1:YAML prerelease 解析规则过窄
35
+
36
+ - [证据] `scripts/pre-release-check.js:114` 之前只匹配 `x.y.z`,不匹配 `x.y.z-beta.0` 这类版本。
37
+ - [证据] 修复提交:`73cf296 [BUGFIX] release: support prerelease YAML version checks`
38
+ - [推论] 只要版本同步文件里存在 prerelease,旧逻辑都会把它截断,导致版本一致性检查不可靠。
39
+
40
+ ### 根因 2:npm@11 对 prerelease 发布要求显式 dist-tag
41
+
42
+ - [证据] `.github/workflows/publish.yml:83` 现在新增 `Determine npm dist-tag` 步骤,从版本号推导 npm tag。
43
+ - [证据] `.github/workflows/publish.yml:128` 现在会在 OIDC 与 `NPM_TOKEN` fallback 两条路径上统一传 `--tag "$DIST_TAG"`。
44
+ - [证据] 修复提交:`93a1a7a [BUGFIX] release: publish prereleases with dist-tags`
45
+ - [推论] 升级到 `npm@11.5.1` 以后,prerelease 发布必须显式指定 `--tag beta` / `--tag rc` 等,否则 registry 会拒绝发布。
46
+
47
+ ## 修复方案
48
+
49
+ ### 修复 1:放宽 prerelease 版本匹配
50
+
51
+ - [证据] 在 `scripts/pre-release-check.js:112` 附近,把 YAML 版本提取规则改为支持 `(\d+\.\d+\.\d+(?:-[\w.]+)?)`。
52
+ - [结果] `npm run docs:check:pre-release` 现在可以正确识别 `0.5.2-beta.1`。
53
+
54
+ ### 修复 2:在 workflow 中显式推导并传递 npm dist-tag
55
+
56
+ - [证据] 在 `.github/workflows/publish.yml:83` 新增 `Determine npm dist-tag`:
57
+ - 稳定版默认 `latest`
58
+ - prerelease 从 preid 推导,例如 `beta`、`rc`
59
+ - [证据] 在 `.github/workflows/publish.yml:124` 的发布步骤中:
60
+ - OIDC 路径使用 `npx npm@11.5.1 publish --tag "$DIST_TAG"`
61
+ - Token fallback 路径使用 `npx npm@11.5.1 publish --tag "$DIST_TAG" --provenance`
62
+ - [结果] `v0.5.2-beta.1` 成功发布到 npm 的 `beta` dist-tag。
63
+
64
+ ### 修复 3:同步发布说明与验证规则
65
+
66
+ - [证据] 文档已同步到以下位置:
67
+ - `docs/PUBLISHING.md`
68
+ - `docs/rules/validation.md`
69
+ - `docs/rules/pre-release-checklist.md`
70
+ - [推论] 这一步是为了把“prerelease 必须显式传 dist-tag”的真实约束写回文档,避免下次再次按旧认知排障。
71
+
72
+ ## 处理过程
73
+
74
+ 1. [证据] 先完成 `0.5.2-beta.0` 版本准备并推送 tag,触发首次真实发布。
75
+ 2. [证据] 发现本地 `docs:check:pre-release` 被 YAML prerelease 解析问题阻断。
76
+ 3. [证据] 修复 `scripts/pre-release-check.js` 后,本地预检查、测试、构建、打包验证全部通过。
77
+ 4. [证据] 首次远端 run `24632519866` 仍在 `Publish to NPM` 失败,暴露 `npm publish --tag` 缺失问题。
78
+ 5. [证据] 修复 workflow 和文档后,准备 `0.5.2-beta.1` 并重新推送。
79
+ 6. [证据] 第二次远端 run `24632744587` 成功完成 `Publish to NPM`、`Generate Release Notes`、`Create GitHub Release`。
80
+
81
+ ## 验证结果
82
+
83
+ ### 本地验证
84
+
85
+ - [证据] `npm run docs:check:pre-release` 通过
86
+ - [证据] `npm test` 通过,`916/916` 测试通过
87
+ - [证据] `npm run build` 通过
88
+ - [证据] `npm run validate-pack` 通过
89
+
90
+ ### 远端验证
91
+
92
+ - [证据] GitHub Actions 成功 run:`24632744587`
93
+ - [证据] GitHub Release 已创建:`v0.5.2-beta.1`
94
+ - [证据] npm registry 已更新 `beta` dist-tag 到 `0.5.2-beta.1`
95
+
96
+ ## 相关提交
97
+
98
+ - [证据] `73cf296 [BUGFIX] release: support prerelease YAML version checks`
99
+ - [证据] `93a1a7a [BUGFIX] release: publish prereleases with dist-tags`
100
+ - [证据] `0d7e8c0 [CONFIG] release: prepare v0.5.2-beta.1`
101
+
102
+ ## 残留事项
103
+
104
+ - [证据] workflow 仍有非阻断告警:
105
+ - `actions/create-release@v1` 使用 Node 20,将来需要升级
106
+ - `set-output` 已废弃,后续应替换为环境文件方式
107
+ - 存在一个 `git exit code 128` 注解噪音,但不影响发布成功
108
+ - [观点] 这些问题不影响当前发布结果,但建议作为下一轮 release-infra 清理项集中处理。
109
+
110
+ ## 下次发布的最小检查清单
111
+
112
+ - [证据] 若版本是 prerelease,确认版本号包含 preid,例如 `0.5.2-beta.2`
113
+ - [证据] 先运行 `npm run docs:check:pre-release`
114
+ - [证据] 再运行 `npm test`、`npm run build`、`npm run validate-pack`
115
+ - [证据] 推送匹配版本的 tag,观察 `Publish to NPM` workflow
116
+ - [证据] 发布后检查:
117
+ - `npm view @mycodemap/mycodemap version dist-tags --json`
118
+ - `gh release view v<version>`
119
+
Binary file