@mycodemap/mycodemap 0.5.0 → 0.5.2-beta.1

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 (254) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +77 -9
  3. package/dist/cli/commands/analyze.d.ts +18 -0
  4. package/dist/cli/commands/analyze.d.ts.map +1 -1
  5. package/dist/cli/commands/analyze.js +239 -6
  6. package/dist/cli/commands/analyze.js.map +1 -1
  7. package/dist/cli/commands/check.d.ts +22 -0
  8. package/dist/cli/commands/check.d.ts.map +1 -0
  9. package/dist/cli/commands/check.js +168 -0
  10. package/dist/cli/commands/check.js.map +1 -0
  11. package/dist/cli/commands/ci.d.ts +25 -0
  12. package/dist/cli/commands/ci.d.ts.map +1 -1
  13. package/dist/cli/commands/ci.js +139 -36
  14. package/dist/cli/commands/ci.js.map +1 -1
  15. package/dist/cli/commands/complexity.d.ts.map +1 -1
  16. package/dist/cli/commands/complexity.js +6 -0
  17. package/dist/cli/commands/complexity.js.map +1 -1
  18. package/dist/cli/commands/design.d.ts +5 -0
  19. package/dist/cli/commands/design.d.ts.map +1 -1
  20. package/dist/cli/commands/design.js +6 -0
  21. package/dist/cli/commands/design.js.map +1 -1
  22. package/dist/cli/commands/generate.d.ts +1 -0
  23. package/dist/cli/commands/generate.d.ts.map +1 -1
  24. package/dist/cli/commands/generate.js +121 -8
  25. package/dist/cli/commands/generate.js.map +1 -1
  26. package/dist/cli/commands/history.d.ts +26 -0
  27. package/dist/cli/commands/history.d.ts.map +1 -0
  28. package/dist/cli/commands/history.js +92 -0
  29. package/dist/cli/commands/history.js.map +1 -0
  30. package/dist/cli/commands/mcp.d.ts +13 -0
  31. package/dist/cli/commands/mcp.d.ts.map +1 -0
  32. package/dist/cli/commands/mcp.js +108 -0
  33. package/dist/cli/commands/mcp.js.map +1 -0
  34. package/dist/cli/commands/workflow.d.ts.map +1 -1
  35. package/dist/cli/commands/workflow.js +22 -2
  36. package/dist/cli/commands/workflow.js.map +1 -1
  37. package/dist/cli/config-loader.d.ts.map +1 -1
  38. package/dist/cli/config-loader.js +3 -2
  39. package/dist/cli/config-loader.js.map +1 -1
  40. package/dist/cli/contract-checker.d.ts +33 -0
  41. package/dist/cli/contract-checker.d.ts.map +1 -0
  42. package/dist/cli/contract-checker.js +719 -0
  43. package/dist/cli/contract-checker.js.map +1 -0
  44. package/dist/cli/contract-diff-scope.d.ts +14 -0
  45. package/dist/cli/contract-diff-scope.d.ts.map +1 -0
  46. package/dist/cli/contract-diff-scope.js +127 -0
  47. package/dist/cli/contract-diff-scope.js.map +1 -0
  48. package/dist/cli/contract-gate-thresholds.d.ts +14 -0
  49. package/dist/cli/contract-gate-thresholds.d.ts.map +1 -0
  50. package/dist/cli/contract-gate-thresholds.js +19 -0
  51. package/dist/cli/contract-gate-thresholds.js.map +1 -0
  52. package/dist/cli/design-contract-loader.d.ts.map +1 -1
  53. package/dist/cli/design-contract-loader.js +355 -3
  54. package/dist/cli/design-contract-loader.js.map +1 -1
  55. package/dist/cli/design-scope-resolver.d.ts.map +1 -1
  56. package/dist/cli/design-scope-resolver.js +89 -41
  57. package/dist/cli/design-scope-resolver.js.map +1 -1
  58. package/dist/cli/index.js +18 -6
  59. package/dist/cli/index.js.map +1 -1
  60. package/dist/cli/paths.d.ts.map +1 -1
  61. package/dist/cli/paths.js +30 -7
  62. package/dist/cli/paths.js.map +1 -1
  63. package/dist/core/analyzer.d.ts.map +1 -1
  64. package/dist/core/analyzer.js +16 -0
  65. package/dist/core/analyzer.js.map +1 -1
  66. package/dist/domain/entities/CodeGraph.d.ts +5 -1
  67. package/dist/domain/entities/CodeGraph.d.ts.map +1 -1
  68. package/dist/domain/entities/CodeGraph.js +29 -12
  69. package/dist/domain/entities/CodeGraph.js.map +1 -1
  70. package/dist/domain/entities/Dependency.d.ts +8 -1
  71. package/dist/domain/entities/Dependency.d.ts.map +1 -1
  72. package/dist/domain/entities/Dependency.js +19 -4
  73. package/dist/domain/entities/Dependency.js.map +1 -1
  74. package/dist/domain/entities/Symbol.d.ts +2 -1
  75. package/dist/domain/entities/Symbol.d.ts.map +1 -1
  76. package/dist/domain/entities/Symbol.js +6 -3
  77. package/dist/domain/entities/Symbol.js.map +1 -1
  78. package/dist/infrastructure/storage/StorageFactory.d.ts +1 -0
  79. package/dist/infrastructure/storage/StorageFactory.d.ts.map +1 -1
  80. package/dist/infrastructure/storage/StorageFactory.js +7 -2
  81. package/dist/infrastructure/storage/StorageFactory.js.map +1 -1
  82. package/dist/infrastructure/storage/adapters/FileSystemStorage.d.ts +3 -1
  83. package/dist/infrastructure/storage/adapters/FileSystemStorage.d.ts.map +1 -1
  84. package/dist/infrastructure/storage/adapters/FileSystemStorage.js +10 -2
  85. package/dist/infrastructure/storage/adapters/FileSystemStorage.js.map +1 -1
  86. package/dist/infrastructure/storage/adapters/KuzuDBStorage.d.ts +3 -1
  87. package/dist/infrastructure/storage/adapters/KuzuDBStorage.d.ts.map +1 -1
  88. package/dist/infrastructure/storage/adapters/KuzuDBStorage.js +9 -1
  89. package/dist/infrastructure/storage/adapters/KuzuDBStorage.js.map +1 -1
  90. package/dist/infrastructure/storage/adapters/MemoryStorage.d.ts +3 -1
  91. package/dist/infrastructure/storage/adapters/MemoryStorage.d.ts.map +1 -1
  92. package/dist/infrastructure/storage/adapters/MemoryStorage.js +9 -1
  93. package/dist/infrastructure/storage/adapters/MemoryStorage.js.map +1 -1
  94. package/dist/infrastructure/storage/adapters/SQLiteStorage.d.ts +53 -0
  95. package/dist/infrastructure/storage/adapters/SQLiteStorage.d.ts.map +1 -0
  96. package/dist/infrastructure/storage/adapters/SQLiteStorage.js +879 -0
  97. package/dist/infrastructure/storage/adapters/SQLiteStorage.js.map +1 -0
  98. package/dist/infrastructure/storage/graph-helpers.d.ts +3 -1
  99. package/dist/infrastructure/storage/graph-helpers.d.ts.map +1 -1
  100. package/dist/infrastructure/storage/graph-helpers.js +90 -0
  101. package/dist/infrastructure/storage/graph-helpers.js.map +1 -1
  102. package/dist/infrastructure/storage/index.d.ts +1 -1
  103. package/dist/infrastructure/storage/index.d.ts.map +1 -1
  104. package/dist/infrastructure/storage/interfaces/StorageBase.d.ts +3 -1
  105. package/dist/infrastructure/storage/interfaces/StorageBase.d.ts.map +1 -1
  106. package/dist/infrastructure/storage/interfaces/StorageBase.js.map +1 -1
  107. package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.d.ts +27 -0
  108. package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.d.ts.map +1 -0
  109. package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.js +246 -0
  110. package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.js.map +1 -0
  111. package/dist/infrastructure/storage/sqlite/perf-thresholds.d.ts +25 -0
  112. package/dist/infrastructure/storage/sqlite/perf-thresholds.d.ts.map +1 -0
  113. package/dist/infrastructure/storage/sqlite/perf-thresholds.js +25 -0
  114. package/dist/infrastructure/storage/sqlite/perf-thresholds.js.map +1 -0
  115. package/dist/infrastructure/storage/sqlite/schema.d.ts +4 -0
  116. package/dist/infrastructure/storage/sqlite/schema.d.ts.map +1 -0
  117. package/dist/infrastructure/storage/sqlite/schema.js +111 -0
  118. package/dist/infrastructure/storage/sqlite/schema.js.map +1 -0
  119. package/dist/interface/types/design-check.d.ts +73 -0
  120. package/dist/interface/types/design-check.d.ts.map +1 -0
  121. package/dist/interface/types/design-check.js +4 -0
  122. package/dist/interface/types/design-check.js.map +1 -0
  123. package/dist/interface/types/design-contract.d.ts +56 -1
  124. package/dist/interface/types/design-contract.d.ts.map +1 -1
  125. package/dist/interface/types/history-risk.d.ts +90 -0
  126. package/dist/interface/types/history-risk.d.ts.map +1 -0
  127. package/dist/interface/types/history-risk.js +4 -0
  128. package/dist/interface/types/history-risk.js.map +1 -0
  129. package/dist/interface/types/index.d.ts +17 -2
  130. package/dist/interface/types/index.d.ts.map +1 -1
  131. package/dist/interface/types/storage.d.ts +28 -1
  132. package/dist/interface/types/storage.d.ts.map +1 -1
  133. package/dist/orchestrator/adapters/ast-grep-adapter.d.ts +10 -0
  134. package/dist/orchestrator/adapters/ast-grep-adapter.d.ts.map +1 -1
  135. package/dist/orchestrator/adapters/ast-grep-adapter.js +46 -17
  136. package/dist/orchestrator/adapters/ast-grep-adapter.js.map +1 -1
  137. package/dist/orchestrator/adapters/codemap-adapter.d.ts.map +1 -1
  138. package/dist/orchestrator/adapters/codemap-adapter.js +2 -22
  139. package/dist/orchestrator/adapters/codemap-adapter.js.map +1 -1
  140. package/dist/orchestrator/history-risk-service.d.ts +55 -0
  141. package/dist/orchestrator/history-risk-service.d.ts.map +1 -0
  142. package/dist/orchestrator/history-risk-service.js +680 -0
  143. package/dist/orchestrator/history-risk-service.js.map +1 -0
  144. package/dist/orchestrator/types.d.ts +19 -1
  145. package/dist/orchestrator/types.d.ts.map +1 -1
  146. package/dist/orchestrator/types.js +19 -0
  147. package/dist/orchestrator/types.js.map +1 -1
  148. package/dist/server/mcp/index.d.ts +4 -0
  149. package/dist/server/mcp/index.d.ts.map +1 -0
  150. package/dist/server/mcp/index.js +5 -0
  151. package/dist/server/mcp/index.js.map +1 -0
  152. package/dist/server/mcp/server.d.ts +17 -0
  153. package/dist/server/mcp/server.d.ts.map +1 -0
  154. package/dist/server/mcp/server.js +84 -0
  155. package/dist/server/mcp/server.js.map +1 -0
  156. package/dist/server/mcp/service.d.ts +22 -0
  157. package/dist/server/mcp/service.d.ts.map +1 -0
  158. package/dist/server/mcp/service.js +177 -0
  159. package/dist/server/mcp/service.js.map +1 -0
  160. package/dist/server/mcp/types.d.ts +56 -0
  161. package/dist/server/mcp/types.d.ts.map +1 -0
  162. package/dist/server/mcp/types.js +4 -0
  163. package/dist/server/mcp/types.js.map +1 -0
  164. package/docs/AI_ASSISTANT_SETUP.md +1 -1
  165. package/docs/PUBLISHING.md +41 -12
  166. package/docs/SETUP_GUIDE.md +6 -6
  167. package/docs/ai-guide/COMMANDS.md +98 -4
  168. package/docs/ai-guide/INTEGRATION.md +137 -433
  169. package/docs/ai-guide/OUTPUT.md +476 -6
  170. package/docs/ai-guide/PATTERNS.md +41 -11
  171. package/docs/ai-guide/PROMPTS.md +11 -6
  172. package/docs/backlog.md +177 -0
  173. package/docs/eatdogfood-reports/2026-04-17-eatdogfood-agent-experience.md +231 -0
  174. package/docs/exec-plans/completed/2026-04-17-eatdogfood-codemap-cli.md +103 -0
  175. package/docs/ideation/2026-04-15-executable-architecture-constitution-ideation.md +102 -0
  176. package/docs/product-specs/DESIGN_CONTRACT_TEMPLATE.md +47 -0
  177. package/docs/product-specs/MVP3-ARCHITECTURE-COMPARISON.md +11 -10
  178. package/docs/product-specs/MVP3-ARCHITECTURE-REDESIGN-PRD.md +10 -10
  179. package/docs/product-specs/MVP3-ARCHITECTURE-REDESIGN-TECH-PRD.md +17 -12
  180. package/docs/rules/README.md +16 -11
  181. package/docs/rules/architecture-guardrails.md +24 -336
  182. package/docs/rules/code-quality-redlines.md +25 -311
  183. package/docs/rules/engineering-with-codex-openai.md +14 -1
  184. package/docs/rules/pre-release-checklist.md +9 -4
  185. package/docs/rules/validation.md +91 -40
  186. package/mycodemap.config.schema.json +3 -3
  187. package/package.json +7 -2
  188. package/scripts/benchmark-governance-graph.mjs +132 -0
  189. package/scripts/calibrate-contract-gate.mjs +221 -0
  190. package/scripts/capability-report.py +255 -0
  191. package/scripts/pre-release-check.js +2 -2
  192. package/scripts/qa-rule-control.sh +254 -0
  193. package/scripts/report-high-risk-files.mjs +395 -0
  194. package/scripts/rule-context.mjs +155 -0
  195. package/scripts/smoke-sqlite-impact.mjs +85 -0
  196. package/scripts/sync-analyze-docs.js +1 -0
  197. package/scripts/tests/test_capability_report.py +89 -0
  198. package/scripts/tests/test_rule_control_workflow.py +51 -0
  199. package/scripts/tests/test_validate_rules.py +81 -0
  200. package/scripts/validate-ai-docs.js +283 -1
  201. package/scripts/validate-docs.js +249 -42
  202. package/scripts/validate-rules.py +254 -0
  203. package/dist/ai/claude.d.ts +0 -38
  204. package/dist/ai/claude.d.ts.map +0 -1
  205. package/dist/ai/claude.js +0 -169
  206. package/dist/ai/claude.js.map +0 -1
  207. package/dist/ai/codex.d.ts +0 -38
  208. package/dist/ai/codex.d.ts.map +0 -1
  209. package/dist/ai/codex.js +0 -169
  210. package/dist/ai/codex.js.map +0 -1
  211. package/dist/ai/factory.d.ts +0 -48
  212. package/dist/ai/factory.d.ts.map +0 -1
  213. package/dist/ai/factory.js +0 -95
  214. package/dist/ai/factory.js.map +0 -1
  215. package/dist/ai/index.d.ts +0 -12
  216. package/dist/ai/index.d.ts.map +0 -1
  217. package/dist/ai/index.js +0 -29
  218. package/dist/ai/index.js.map +0 -1
  219. package/dist/ai/provider.d.ts +0 -70
  220. package/dist/ai/provider.d.ts.map +0 -1
  221. package/dist/ai/provider.js +0 -31
  222. package/dist/ai/provider.js.map +0 -1
  223. package/dist/ai/subagent-caller.d.ts +0 -90
  224. package/dist/ai/subagent-caller.d.ts.map +0 -1
  225. package/dist/ai/subagent-caller.js +0 -280
  226. package/dist/ai/subagent-caller.js.map +0 -1
  227. package/dist/ai/types.d.ts +0 -70
  228. package/dist/ai/types.d.ts.map +0 -1
  229. package/dist/ai/types.js +0 -5
  230. package/dist/ai/types.js.map +0 -1
  231. package/dist/cli/commands/server.d.ts +0 -9
  232. package/dist/cli/commands/server.d.ts.map +0 -1
  233. package/dist/cli/commands/server.js +0 -65
  234. package/dist/cli/commands/server.js.map +0 -1
  235. package/dist/cli-new/commands/server.d.ts +0 -13
  236. package/dist/cli-new/commands/server.d.ts.map +0 -1
  237. package/dist/cli-new/commands/server.js +0 -90
  238. package/dist/cli-new/commands/server.js.map +0 -1
  239. package/dist/generator/ai-overview.d.ts +0 -51
  240. package/dist/generator/ai-overview.d.ts.map +0 -1
  241. package/dist/generator/ai-overview.js +0 -160
  242. package/dist/generator/ai-overview.js.map +0 -1
  243. package/dist/infrastructure/storage/adapters/Neo4jStorage.d.ts +0 -41
  244. package/dist/infrastructure/storage/adapters/Neo4jStorage.d.ts.map +0 -1
  245. package/dist/infrastructure/storage/adapters/Neo4jStorage.js +0 -162
  246. package/dist/infrastructure/storage/adapters/Neo4jStorage.js.map +0 -1
  247. package/dist/orchestrator/ai-feed-generator.d.ts +0 -210
  248. package/dist/orchestrator/ai-feed-generator.d.ts.map +0 -1
  249. package/dist/orchestrator/ai-feed-generator.js +0 -377
  250. package/dist/orchestrator/ai-feed-generator.js.map +0 -1
  251. package/docs/archive/test-report-symbol-search.md +0 -384
  252. package/docs/archive/test-scenario-4-complexity-analysis.md +0 -460
  253. package/docs/archive/test_report_scenario5.md +0 -615
  254. package/docs/archive/test_scenario_3_impact_analysis_report.md +0 -520
@@ -0,0 +1,102 @@
1
+ ---
2
+ date: 2026-04-15
3
+ topic: executable-architecture-constitution
4
+ focus: Pivot CodeMap to an "Executable Architecture Constitution" — making design.md a diff-aware, git-history-risk-weighted, CI-enforceable gate
5
+ ---
6
+
7
+ # Ideation: Executable Architecture Constitution
8
+
9
+ ## Codebase Context
10
+
11
+ **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.
12
+
13
+ **Key Assets**:
14
+ - MVP3 6-layer architecture is enforced (Interface → Infrastructure → Domain → Server → CLI)
15
+ - `design validate/map/handoff/verify` commands already exist with full JSON output contracts
16
+ - `docs/backlog.md` contains a v0.6 product重塑提案 to pivot to "architecture contract validation & guardrail system"
17
+ - Historical CI gateway exists (`codemap ci check-commits`, `check-headers`, `assess-risk`) but some are archived
18
+ - Git risk analyzer was designed and archived (GRAVITY/HEAT/IMPACT scoring formula exists in `src/orchestrator/workflow/git-analyzer.ts` but is dormant)
19
+ - Storage is currently KùzuDB; proposal suggests migrating to `better-sqlite3` + in-memory directed graph
20
+ - Tree-sitter parser exists for TS/Go/Python
21
+ - Current `design verify` only checks handoff drift; it does NOT scan actual `src/` code against architecture rules
22
+
23
+ **Pain Points**:
24
+ - `src/core/` and `src/parser/` migration debt
25
+ - Multiple temp output dirs
26
+ - Docs-sync pressure
27
+ - No diff-aware incremental validation exists yet
28
+
29
+ ## Ranked Ideas
30
+
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
40
+ **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
+ **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
+ **Downsides:** Must validate startup time and memory footprint against large codebases (target: <1s for 10K files, <200MB RAM).
43
+ **Confidence:** 85%
44
+ **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
54
+
55
+ ### 4. Auto-Generate design.md from Existing Codebase
56
+ **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
+ **Rationale:** Eliminates the root cause of "docs vs code divergence." If contract generation cost approaches zero, maintenance cost collapses too.
58
+ **Downsides:** Auto-generated rules may be too permissive or capture too many implementation details; needs smart UX to "lock" which rules matter.
59
+ **Confidence:** 75%
60
+ **Complexity:** Medium
61
+ **Status:** Unexplored
62
+
63
+ ### 5. Auto-Generate Architecture Remediation Patches
64
+ **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
+ **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
+ **Downsides:** Requires semantic understanding beyond import graphs; fully automated fixes risk introducing bugs.
67
+ **Confidence:** 65%
68
+ **Complexity:** High
69
+ **Status:** Unexplored
70
+
71
+ ### 6. Self-Healing Design Contract (Drift Approval)
72
+ **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
+ **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
+ **Downsides:** Requires strict versioning and multi-level approval, otherwise it becomes a channel for "legitimizing tech debt."
75
+ **Confidence:** 70%
76
+ **Complexity:** Medium
77
+ **Status:** Unexplored
78
+
79
+ ### 7. MCP `verify_contract` Tool
80
+ **Description:** Wrap the `design verify` JSON output contract as an MCP Server tool for Claude Code / Cursor to call before every code modification.
81
+ **Rationale:** Minimal engineering investment for maximum ecosystem leverage. Transforms CodeMap from "a CLI developers remember to run" into "infrastructure AI calls by default."
82
+ **Downsides:** The MCP ecosystem is still early; interface standardization may shift.
83
+ **Confidence:** 85%
84
+ **Complexity:** Low
85
+ **Status:** Unexplored
86
+
87
+ ## Rejection Summary
88
+
89
+ | # | Idea | Reason Rejected |
90
+ |---|------|-----------------|
91
+ | 1 | Zero-config CI Gateway | Too narrow; essentially a packaging simplification of existing `ci` subcommands, not a strategic improvement |
92
+ | 2 | Auto-sync docs guardrail | High engineering complexity for low leverage; contributes marginally to the pivot's core value |
93
+ | 3 | Architecture-as-Test-Suite | Functionally duplicates #1 with a different shape (Vitest vs CLI); drifts from CodeMap's CLI-native identity |
94
+ | 4 | GitHub Action as the only interface | Radical but too costly; conflicts with existing CLI investment and user base |
95
+ | 5 | Risk-weighted soft gate | Historically explored; soft thresholds rarely change developer behavior in practice |
96
+ | 6 | Commit message as architecture signal | Over-relies on LLM inference; high cost and unpredictable signal quality |
97
+ | 7 | TypeScript-only deep constitution | Strategic but would discard existing Go/Python parser work; unclear cost/benefit |
98
+ | 8 | One-shot removal of core/parser debt | A refactoring task, not a product improvement idea |
99
+
100
+ ## Session Log
101
+
102
+ - 2026-04-15: Initial ideation — ~40 candidates generated across 4 frames, 7 survived after adversarial filtering
@@ -23,9 +23,48 @@
23
23
  - `Non-Goals` 不能为空;它是防止越界实现的第一道护栏。
24
24
  - 如果某个关键决策尚未确定,写进 `Open Questions`,不要让 AI 自行猜测。
25
25
 
26
+ ## Frontmatter Rules
27
+
28
+ 把可执行规则写在文件开头的 YAML frontmatter 中。当前 Phase 25 只支持三种规则:
29
+
30
+ - `layer_direction`
31
+ - `forbidden_imports`
32
+ - `module_public_api_only`
33
+
34
+ ```yaml
35
+ ---
36
+ rules:
37
+ - type: layer_direction
38
+ name: "core 不可依赖 cli"
39
+ from: "src/core/**"
40
+ to: "src/cli/**"
41
+ severity: error
42
+ - type: forbidden_imports
43
+ name: "parser 禁止直接引用 fs"
44
+ module: "src/infrastructure/parser/**"
45
+ forbidden:
46
+ - fs
47
+ - path
48
+ severity: warn
49
+ - type: module_public_api_only
50
+ name: "domain 模块对外仅暴露 index.ts"
51
+ module: "src/domain/**"
52
+ public_api: "index.ts"
53
+ severity: error
54
+ ---
55
+ ```
56
+
26
57
  ## Copy-Paste Template
27
58
 
28
59
  ```markdown
60
+ ---
61
+ rules:
62
+ - type: layer_direction
63
+ name: "core 不可依赖 cli"
64
+ from: "src/core/**"
65
+ to: "src/cli/**"
66
+ severity: error
67
+ ---
29
68
  # Design Contract: <feature name>
30
69
 
31
70
  ## Goal
@@ -59,6 +98,14 @@
59
98
  ## Minimal Example
60
99
 
61
100
  ```markdown
101
+ ---
102
+ rules:
103
+ - type: layer_direction
104
+ name: "core 不可依赖 cli"
105
+ from: "src/core/**"
106
+ to: "src/cli/**"
107
+ severity: error
108
+ ---
62
109
  # Design Contract: Add design validate command
63
110
 
64
111
  ## Goal
@@ -22,7 +22,7 @@
22
22
  |------|--------|----------------|
23
23
  | CLI | 多个命令直接碰核心实现 | 公共 CLI 收口为分析优先的命令面,命名边界清晰 |
24
24
  | Server Layer | 设计概念模糊,易与公共 `server` 命令混淆 | `src/server/` 保留为**内部架构层**;公共 `server` 命令已移除 |
25
- | Storage | 以文件输出为中心,图存储路径不稳定 | `filesystem` / `memory` / `kuzudb` / `auto` 为正式 surface;`neo4j` 已退出正式支持 |
25
+ | Storage | 以文件输出为中心,图存储路径不稳定 | `filesystem` / `memory` / `sqlite` / `auto` 为正式 surface;`neo4j` 与 `kuzudb` 已退出正式支持 |
26
26
  | Parser | 以 TypeScript 逻辑为主,扩展能力弱 | `ParserRegistry` + `TypeScript/JavaScript`、`Go`、`Python` 三类已落地实现 |
27
27
  | Workflow | 设计上曾试图扩到更多工程阶段 | 当前公开能力仅保留 analysis-only:`find → read → link → show` |
28
28
  | Docs / CI | 文档与实现容易漂移 | `docs:check` + `ci check-docs-sync` + CI gateway 固定当前契约 |
@@ -68,7 +68,7 @@ Domain Layer (`src/domain/`)
68
68
  └─ 面向业务模型,不直接暴露 CLI 细节
69
69
 
70
70
  Infrastructure Layer (`src/infrastructure/`)
71
- ├─ storage: FileSystem / Memory / KùzuDB
71
+ ├─ storage: FileSystem / SQLite / Memory
72
72
  ├─ parser: TypeScript(JS) / Go / Python
73
73
  └─ repositories / shared graph helpers
74
74
 
@@ -80,7 +80,7 @@ Interface Layer (`src/interface/`)
80
80
  ### 当前架构要点
81
81
 
82
82
  - `Server Layer` 是内部架构层,不等于公共 `mycodemap server`
83
- - 图存储正式产品面已收敛为 Kùzu-only 主线,不再把 `neo4j` 当成受支持 backend
83
+ - 图存储正式产品面已收敛为 `filesystem` / `sqlite` / `memory` / `auto`;旧 `neo4j` / `kuzudb` 配置只保留迁移诊断
84
84
  - `workflow` 是公开能力,但仅编排分析阶段,不再混入实现/提交/CI 阶段
85
85
 
86
86
  ---
@@ -103,7 +103,7 @@ await fs.writeFile(path.join(outputDir, 'AI_MAP.md'), markdown);
103
103
  ### After:存储契约已稳定,但产品面已收敛
104
104
 
105
105
  ```typescript
106
- export type StorageType = 'filesystem' | 'kuzudb' | 'memory';
106
+ export type StorageType = 'filesystem' | 'sqlite' | 'memory';
107
107
 
108
108
  export interface StorageConfig {
109
109
  type: StorageType | 'auto';
@@ -118,10 +118,11 @@ export interface StorageConfig {
118
118
 
119
119
  当前事实:
120
120
 
121
- - **正式支持**:`filesystem`、`memory`、`kuzudb`、`auto`
122
- - **不再正式支持**:`neo4j`
123
- - **迁移语义**:旧 `neo4j` 配置会返回显式错误,不会静默 fallback
124
- - **`auto` 现状**:配置面存在,但当前仍保守落到 `filesystem`;阈值字段是契约,不代表已完成智能切换
121
+ - **正式支持**:`filesystem`、`memory`、`sqlite`、`auto`
122
+ - **不再正式支持**:`neo4j`、`kuzudb`
123
+ - **迁移语义**:旧 `neo4j` / `kuzudb` 配置会返回显式错误,不会静默 fallback
124
+ - **`auto` 现状**:配置面存在,当前优先选择 `sqlite`;仅当 SQLite 运行时不可用时 warning 后回退 `filesystem`
125
+ - **SQLite runtime**:显式 `sqlite` 需要 `better-sqlite3` + Node.js `>=20`;否则返回 `SQLITE_NOT_AVAILABLE`
125
126
 
126
127
  ---
127
128
 
@@ -209,7 +210,7 @@ mycodemap ci check-docs-sync
209
210
  | 能力 | 当前状态 |
210
211
  |------|----------|
211
212
  | `neo4j` 正式支持 | 已移除出正式产品面 |
212
- | 更丰富的自动后端切换启发式 | 仍 deferred;`auto` 当前保守落到 `filesystem` |
213
+ | 更丰富的自动后端切换启发式 | 仍 deferred;`auto` 当前优先选择 `sqlite`,仅在 SQLite 不可用时回退 `filesystem` |
213
214
  | Java / Rust / C/C++ 等更多 parser 实现 | 接口预留,未作为当前 shipped reality |
214
215
  | `viz` / `tui` / CLI 可视化套件 | 未作为当前 public CLI 基线交付 |
215
216
  | 公共 HTTP API / `mycodemap server` 产品面 | 未开放;`Server Layer` 仍是 internal-only |
@@ -221,7 +222,7 @@ mycodemap ci check-docs-sync
221
222
  `MVP3` 的核心价值已经从“理想化设计图”收口成了当前可验证的产品基线:
222
223
 
223
224
  - 5 层架构已在目录结构与职责边界上落地
224
- - 存储面已稳定为 Kùzu-only 主线
225
+ - 存储面已稳定为 `filesystem` / `sqlite` / `memory` / `auto` 四态 surface
225
226
  - 解析器已具备可扩展注册机制,并落地 3 类实现
226
227
  - 公共 CLI 已回到分析优先的可维护命令面
227
228
  - 文档、测试与 CI 已能共同约束这些边界
@@ -54,9 +54,9 @@ MVP3 重构的原始目的,是把 CodeMap 从“CLI 直接拼接分析逻辑
54
54
  |------|------|------|
55
55
  | `filesystem` | shipped | 默认、最稳定 |
56
56
  | `memory` | shipped | 测试/内存场景 |
57
- | `kuzudb` | shipped | 当前图存储主线 |
58
- | `auto` | shipped surface | 配置面存在,但当前仍保守落到 `filesystem` |
59
- | `neo4j` | removed | 不再是正式支持 backend;旧配置返回显式迁移错误 |
57
+ | `sqlite` | shipped | 当前图存储主线 |
58
+ | `auto` | shipped surface | 配置面存在,当前优先选择 `sqlite`;SQLite 不可用时回退 `filesystem` |
59
+ | `neo4j` / `kuzudb` | removed | 不再是正式支持 backend;旧配置返回显式迁移错误 |
60
60
 
61
61
  ### 3.3 解析器能力
62
62
 
@@ -108,7 +108,7 @@ analyze / ci / workflow / export / ship
108
108
  | 需求 | 当前状态 |
109
109
  |------|----------|
110
110
  | 五层架构与命名边界稳定 | 已满足 |
111
- | Kùzu-only 图存储主线 | 已满足 |
111
+ | SQLite 图存储主线 + 显式迁移诊断 | 已满足 |
112
112
  | 历史 `neo4j` 配置迁移诊断 | 已满足 |
113
113
  | 解析器注册机制与 3 类实现 | 已满足 |
114
114
  | `analyze` / `workflow` / `server` 边界收口 | 已满足 |
@@ -122,7 +122,7 @@ analyze / ci / workflow / export / ship
122
122
  | Java / Rust / C/C++ 等更多 parser 实现 | Deferred |
123
123
  | `viz` / `tui` / 更丰富 CLI 可视化 | Deferred |
124
124
  | 公共 HTTP API / `mycodemap server` 产品面 | Deferred |
125
- | 更深的 Kùzu-native 查询优化 | Deferred |
125
+ | 更深的 SQLite / in-memory 协同查询优化 | Deferred |
126
126
 
127
127
  ### 4.3 明确不在当前基线内
128
128
 
@@ -170,8 +170,8 @@ analyze / ci / workflow / export / ship
170
170
 
171
171
  当前交付:
172
172
 
173
- - `filesystem` / `memory` / `kuzudb` / `auto` 为正式配置面
174
- - 旧 `neo4j` 配置会显式报错,不再静默 fallback
173
+ - `filesystem` / `memory` / `sqlite` / `auto` 为正式配置面
174
+ - 旧 `neo4j` / `kuzudb` 配置会显式报错,不再静默 fallback
175
175
 
176
176
  ---
177
177
 
@@ -194,7 +194,7 @@ analyze / ci / workflow / export / ship
194
194
 
195
195
  更准确的当前表达是:
196
196
 
197
- - Kùzu 路径已接入正式产品面
197
+ - SQLite 路径已接入正式产品面;显式 `sqlite` 缺少 `better-sqlite3` 或 Node.js `<20` 时会返回 `SQLITE_NOT_AVAILABLE`
198
198
  - 更激进的 DB-native 查询优化属于后续候选项,而非 `v1.3` 既成事实
199
199
 
200
200
  ---
@@ -206,7 +206,7 @@ analyze / ci / workflow / export / ship
206
206
  | `v1.0` | AI-first 定位、公共 CLI 收口、analyze/workflow/ship/docs guardrail 基线 |
207
207
  | `v1.1` | 插件扩展点产品化 |
208
208
  | `v1.2` | 图数据库后端生产化 |
209
- | `v1.3` | Kùzu-only 收敛、高信号 debt 清偿、docs/CI 自动验证闭环 |
209
+ | `v1.3` | SQLite 主线收口、高信号 debt 清偿、docs/CI 自动验证闭环 |
210
210
 
211
211
  ---
212
212
 
@@ -216,7 +216,7 @@ analyze / ci / workflow / export / ship
216
216
  |------|----------|----------|
217
217
  | 文档继续把历史设计写成当前现实 | 高信号风险 | 持续运行 `docs:check` 与 `ci check-docs-sync` |
218
218
  | `Server Layer` 与公共 `server` 命令再次混淆 | 高信号风险 | 在 README / AI docs / 架构文档统一措辞 |
219
- | `auto` 被误读为“已完成智能切换” | 中 | 文档明确写明当前仍保守落到 `filesystem` |
219
+ | `auto` 被误读为“已完成智能切换” | 中 | 文档明确写明当前优先选择 `sqlite`,仅在 SQLite 不可用时回退 `filesystem` |
220
220
  | repo-wide lint warnings 演变成阻断项 | 中 | 单独开新 milestone 清理 warning baseline |
221
221
 
222
222
  ---
@@ -87,7 +87,7 @@ src/
87
87
  ### 4.1 当前类型契约
88
88
 
89
89
  ```typescript
90
- export type StorageType = 'filesystem' | 'kuzudb' | 'memory';
90
+ export type StorageType = 'filesystem' | 'sqlite' | 'memory';
91
91
 
92
92
  export interface StorageConfig {
93
93
  type: StorageType | 'auto';
@@ -106,27 +106,31 @@ export interface StorageConfig {
106
106
  |------|------|----------|
107
107
  | `filesystem` | `FileSystemStorage` | shipped |
108
108
  | `memory` | `MemoryStorage` | shipped |
109
- | `kuzudb` | `KuzuDBStorage` | shipped |
110
- | `auto` | `StorageFactory.determineStorageType()` | shipped surface,但当前保守返回 `filesystem` |
109
+ | `sqlite` | `SQLiteStorage` | shipped |
110
+ | `auto` | `StorageFactory.determineStorageType()` | shipped surface,当前优先返回 `sqlite`,不可用时 warning 后回退 `filesystem` |
111
111
 
112
112
  ### 4.3 已移除的正式产品面
113
113
 
114
- `neo4j` 已不再是正式支持 backend。
114
+ `neo4j` 与 `kuzudb` 已不再是正式支持 backend。
115
115
 
116
116
  当前技术语义:
117
117
 
118
118
  - 旧配置若出现 `neo4j`,`StorageFactory` 会抛出 `UNSUPPORTED_STORAGE_TYPE`
119
- - 文档和实现都不再承诺 Neo4j runtime surface
119
+ - 旧配置若出现 `kuzudb`,`StorageFactory` 会抛出 `STORAGE_BACKEND_MIGRATED`
120
+ - 显式选择 `sqlite` 且运行时缺少 `better-sqlite3` 或 Node.js `<20` 时,`StorageFactory` 会抛出 `SQLITE_NOT_AVAILABLE`
121
+ - 文档和实现都不再承诺 Neo4j / Kùzu runtime surface
120
122
 
121
123
  ### 4.4 `auto` 的真实状态
122
124
 
123
- `autoThresholds` 仍保留在契约里,但当前 `StorageFactory` 的保守行为是:
125
+ `autoThresholds` 仍保留在契约里,但当前 `StorageFactory` 的实际行为是:
124
126
 
125
127
  ```typescript
126
- const thresholds = config.autoThresholds ?? {
127
- useGraphDBWhenFileCount: 1000,
128
- useGraphDBWhenNodeCount: 10000,
129
- };
128
+ const sqliteAvailable = await this.checkSQLiteAvailability();
129
+ if (sqliteAvailable) {
130
+ return 'sqlite';
131
+ }
132
+
133
+ console.warn('[StorageFactory] SQLite unavailable, falling back to filesystem');
130
134
 
131
135
  return 'filesystem';
132
136
  ```
@@ -134,6 +138,7 @@ return 'filesystem';
134
138
  因此:
135
139
 
136
140
  - `auto` 是稳定配置面
141
+ - `auto` 会先探测 SQLite runtime,可用时返回 `sqlite`,不可用时 warning 后回退 `filesystem`
137
142
  - 但“按规模自动切到图数据库”的更强启发式仍是未来候选,而不是当前完成能力
138
143
 
139
144
  ---
@@ -279,11 +284,11 @@ find → read → link → show
279
284
 
280
285
  | 项目 | 说明 |
281
286
  |------|------|
282
- | 更强的 auto storage heuristic | 当前仍保守返回 `filesystem` |
287
+ | 更强的 auto storage heuristic | 当前仍只在 `sqlite` / `filesystem` 间切换,未按规模动态调度更多后端 |
283
288
  | 更多 parser 实现 | 接口预留,当前未交付 |
284
289
  | 公共 HTTP API 产品化 | 当前不在范围内 |
285
290
  | `viz` / `tui` / 更强交互可视化 | 当前不在公共 CLI 基线中 |
286
- | Kùzu-native 深度查询优化 | 后续候选,不属于 `v1.3` 已交付事实 |
291
+ | 更深的 SQLite / in-memory 协同查询优化 | 后续候选,不属于 `v1.3` 已交付事实 |
287
292
 
288
293
  ---
289
294
 
@@ -1,16 +1,21 @@
1
- # docs/rules/
1
+ # `docs/rules/` 速查索引
2
2
 
3
- 本目录存放会直接影响开发与交付行为的规则文档。
3
+ > 只保留会直接影响 agent / 人类开发行为的规则。每份文档都应短、可执行、可 grep。
4
4
 
5
- ## 当前文件
5
+ ## 先读哪份文档
6
6
 
7
- - `engineering-with-codex-openai.md`:面向 agent 的工程原则与当前仓库 CLI / CI 护栏。
8
- - `testing.md`:测试框架、覆盖率、测试文件位置。
9
- - `validation.md`:构建、类型检查、lint、CI 验证顺序。
10
- - `deployment.md`:打包、发布前检查与发布边界。
7
+ | 场景 | 文档 | 主命令 |
8
+ |---|---|---|
9
+ | 改 TypeScript / Python 实现,担心触发红线 | `code-quality-redlines.md` | `npm run typecheck` / `npm run lint` |
10
+ | 改分层、依赖方向、模块边界 | `architecture-guardrails.md` | `node dist/cli/index.js deps -m "<module>"` |
11
+ | 改测试、fixture、测试文件布局 | `testing.md` | `npm test` |
12
+ | 改 hooks、CI、验证顺序、repo-local guardrail | `validation.md` | `npm run docs:check` / `python3 scripts/validate-rules.py code --report-only` |
13
+ | 改 agent 执行协议、CLI/CI 工程护栏 | `engineering-with-codex-openai.md` | `node dist/cli/index.js ci check-docs-sync` |
14
+ | 改发布/打包流程 | `deployment.md` | `npm run build` / `npm run validate-pack` |
15
+ | 改发布前 checklist / 版本同步 | `pre-release-checklist.md` | `npm run docs:check:pre-release` |
11
16
 
12
- ## 写作边界
17
+ ## 使用规则
13
18
 
14
- - 写“必须怎么做”,不写长篇设计推演。
15
- - 若规则来自代码事实,优先引用 `package.json`、`tsconfig.json`、CI hooks。
16
- - 若规则变化会影响 agent 行为,应同步检查入口文档。
19
+ - 入口文档先路由,再按需下钻;不要一次性读完整个 `docs/rules/`。
20
+ - 若规则变化会影响 agent 行为,同步检查 `AGENTS.md`、`CLAUDE.md`、`AI_GUIDE.md` 与相关 `docs/ai-guide/*.md`。
21
+ - 若规则来自代码事实,优先用 `package.json`、`.githooks/*`、`.github/workflows/*`、`scripts/*` 作为真相来源。