@laitszkin/apollo-toolkit 4.0.11 → 4.1.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 (145) hide show
  1. package/AGENTS.md +37 -27
  2. package/CHANGELOG.md +47 -0
  3. package/CLAUDE.md +37 -27
  4. package/README.md +15 -2
  5. package/assets/spec/rg13-1780435029246/test-questions.json +1 -0
  6. package/assets/spec/rg13-1780468345132/test-questions.json +1 -0
  7. package/package.json +3 -3
  8. package/packages/cli/dist/tool-registration.js +1 -0
  9. package/packages/cli/dist/tsconfig.tsbuildinfo +1 -1
  10. package/packages/cli/tool-registration.ts +1 -0
  11. package/packages/tools/architecture/dist/index.js +549 -2
  12. package/packages/tools/architecture/dist/index.test.d.ts +1 -0
  13. package/packages/tools/architecture/dist/index.test.js +229 -0
  14. package/packages/tools/architecture/dist/tsconfig.tsbuildinfo +1 -1
  15. package/packages/tools/architecture/index.test.ts +329 -0
  16. package/packages/tools/architecture/index.ts +613 -5
  17. package/packages/tools/codegraph/dist/index.d.ts +3 -0
  18. package/packages/tools/codegraph/dist/index.js +343 -0
  19. package/packages/tools/codegraph/dist/lib/cg-instance.d.ts +29 -0
  20. package/packages/tools/codegraph/dist/lib/cg-instance.js +59 -0
  21. package/packages/tools/codegraph/dist/lib/cg-instance.test.d.ts +1 -0
  22. package/packages/tools/codegraph/dist/lib/cg-instance.test.js +27 -0
  23. package/packages/tools/codegraph/dist/lib/cmd-explore.d.ts +5 -0
  24. package/packages/tools/codegraph/dist/lib/cmd-explore.js +95 -0
  25. package/packages/tools/codegraph/dist/lib/cmd-explore.test.d.ts +1 -0
  26. package/packages/tools/codegraph/dist/lib/cmd-explore.test.js +133 -0
  27. package/packages/tools/codegraph/dist/lib/cmd-flag-splice.test.d.ts +1 -0
  28. package/packages/tools/codegraph/dist/lib/cmd-flag-splice.test.js +83 -0
  29. package/packages/tools/codegraph/dist/lib/cmd-init.d.ts +5 -0
  30. package/packages/tools/codegraph/dist/lib/cmd-init.js +50 -0
  31. package/packages/tools/codegraph/dist/lib/cmd-init.test.d.ts +1 -0
  32. package/packages/tools/codegraph/dist/lib/cmd-init.test.js +51 -0
  33. package/packages/tools/codegraph/dist/lib/cmd-list-apis.d.ts +5 -0
  34. package/packages/tools/codegraph/dist/lib/cmd-list-apis.js +64 -0
  35. package/packages/tools/codegraph/dist/lib/cmd-list-apis.test.d.ts +1 -0
  36. package/packages/tools/codegraph/dist/lib/cmd-list-apis.test.js +69 -0
  37. package/packages/tools/codegraph/dist/lib/cmd-search.d.ts +5 -0
  38. package/packages/tools/codegraph/dist/lib/cmd-search.js +21 -0
  39. package/packages/tools/codegraph/dist/lib/cmd-search.test.d.ts +1 -0
  40. package/packages/tools/codegraph/dist/lib/cmd-search.test.js +30 -0
  41. package/packages/tools/codegraph/dist/lib/cmd-status.d.ts +4 -0
  42. package/packages/tools/codegraph/dist/lib/cmd-status.js +44 -0
  43. package/packages/tools/codegraph/dist/lib/cmd-status.test.d.ts +1 -0
  44. package/packages/tools/codegraph/dist/lib/cmd-status.test.js +72 -0
  45. package/packages/tools/codegraph/dist/lib/cmd-survey.d.ts +36 -0
  46. package/packages/tools/codegraph/dist/lib/cmd-survey.js +142 -0
  47. package/packages/tools/codegraph/dist/lib/cmd-survey.test.d.ts +1 -0
  48. package/packages/tools/codegraph/dist/lib/cmd-survey.test.js +136 -0
  49. package/packages/tools/codegraph/dist/lib/cmd-sync.d.ts +4 -0
  50. package/packages/tools/codegraph/dist/lib/cmd-sync.js +51 -0
  51. package/packages/tools/codegraph/dist/lib/cmd-sync.test.d.ts +1 -0
  52. package/packages/tools/codegraph/dist/lib/cmd-sync.test.js +30 -0
  53. package/packages/tools/codegraph/dist/lib/cmd-verify.d.ts +4 -0
  54. package/packages/tools/codegraph/dist/lib/cmd-verify.js +134 -0
  55. package/packages/tools/codegraph/dist/lib/cmd-verify.test.d.ts +1 -0
  56. package/packages/tools/codegraph/dist/lib/cmd-verify.test.js +139 -0
  57. package/packages/tools/codegraph/dist/lib/formatter.d.ts +67 -0
  58. package/packages/tools/codegraph/dist/lib/formatter.js +107 -0
  59. package/packages/tools/codegraph/dist/lib/formatter.test.d.ts +1 -0
  60. package/packages/tools/codegraph/dist/lib/formatter.test.js +41 -0
  61. package/packages/tools/codegraph/dist/lib/survey/grouper.d.ts +19 -0
  62. package/packages/tools/codegraph/dist/lib/survey/grouper.js +194 -0
  63. package/packages/tools/codegraph/dist/lib/survey/grouper.test.d.ts +1 -0
  64. package/packages/tools/codegraph/dist/lib/survey/grouper.test.js +62 -0
  65. package/packages/tools/codegraph/dist/lib/survey/scanner.d.ts +31 -0
  66. package/packages/tools/codegraph/dist/lib/survey/scanner.js +50 -0
  67. package/packages/tools/codegraph/dist/lib/verify/checker.d.ts +32 -0
  68. package/packages/tools/codegraph/dist/lib/verify/checker.js +146 -0
  69. package/packages/tools/codegraph/dist/lib/verify/checker.test.d.ts +1 -0
  70. package/packages/tools/codegraph/dist/lib/verify/checker.test.js +128 -0
  71. package/packages/tools/codegraph/dist/tsconfig.tsbuildinfo +1 -0
  72. package/packages/tools/codegraph/env.d.ts +56 -0
  73. package/packages/tools/codegraph/index.ts +362 -0
  74. package/packages/tools/codegraph/lib/cg-instance.test.ts +36 -0
  75. package/packages/tools/codegraph/lib/cg-instance.ts +66 -0
  76. package/packages/tools/codegraph/lib/cmd-explore.test.ts +195 -0
  77. package/packages/tools/codegraph/lib/cmd-explore.ts +129 -0
  78. package/packages/tools/codegraph/lib/cmd-flag-splice.test.ts +94 -0
  79. package/packages/tools/codegraph/lib/cmd-init.test.ts +68 -0
  80. package/packages/tools/codegraph/lib/cmd-init.ts +60 -0
  81. package/packages/tools/codegraph/lib/cmd-list-apis.test.ts +80 -0
  82. package/packages/tools/codegraph/lib/cmd-list-apis.ts +90 -0
  83. package/packages/tools/codegraph/lib/cmd-search.test.ts +37 -0
  84. package/packages/tools/codegraph/lib/cmd-search.ts +32 -0
  85. package/packages/tools/codegraph/lib/cmd-status.test.ts +86 -0
  86. package/packages/tools/codegraph/lib/cmd-status.ts +53 -0
  87. package/packages/tools/codegraph/lib/cmd-survey.test.ts +161 -0
  88. package/packages/tools/codegraph/lib/cmd-survey.ts +199 -0
  89. package/packages/tools/codegraph/lib/cmd-sync.test.ts +41 -0
  90. package/packages/tools/codegraph/lib/cmd-sync.ts +62 -0
  91. package/packages/tools/codegraph/lib/cmd-verify.test.ts +162 -0
  92. package/packages/tools/codegraph/lib/cmd-verify.ts +145 -0
  93. package/packages/tools/codegraph/lib/formatter.test.ts +47 -0
  94. package/packages/tools/codegraph/lib/formatter.ts +130 -0
  95. package/packages/tools/codegraph/lib/survey/grouper.test.ts +72 -0
  96. package/packages/tools/codegraph/lib/survey/grouper.ts +226 -0
  97. package/packages/tools/codegraph/lib/survey/scanner.ts +89 -0
  98. package/packages/tools/codegraph/lib/verify/checker.test.ts +140 -0
  99. package/packages/tools/codegraph/lib/verify/checker.ts +172 -0
  100. package/packages/tools/codegraph/package.json +23 -0
  101. package/packages/tools/codegraph/tsconfig.json +22 -0
  102. package/resources/project-architecture/atlas/atlas.history.log +32 -0
  103. package/resources/project-architecture/atlas/atlas.history.undo.json +356 -28
  104. package/resources/project-architecture/atlas/atlas.history.undo.stack.json +14350 -0
  105. package/resources/project-architecture/atlas/atlas.index.yaml +76 -12
  106. package/resources/project-architecture/atlas/features/codegraph.yaml +95 -0
  107. package/resources/project-architecture/atlas/features/eval-ci-gate.yaml +6 -1
  108. package/resources/project-architecture/atlas/features/eval-cli.yaml +16 -1
  109. package/resources/project-architecture/atlas/features/eval-executor.yaml +12 -2
  110. package/resources/project-architecture/atlas/features/eval-isolation.yaml +6 -1
  111. package/resources/project-architecture/atlas/features/eval-optimizer.yaml +17 -2
  112. package/resources/project-architecture/atlas/features/eval-question.yaml +12 -2
  113. package/resources/project-architecture/atlas/features/eval-reporter.yaml +6 -1
  114. package/resources/project-architecture/atlas/features/eval-scorer.yaml +12 -2
  115. package/resources/project-architecture/features/codegraph/cg-discovery.html +47 -0
  116. package/resources/project-architecture/features/codegraph/cg-lifecycle.html +48 -0
  117. package/resources/project-architecture/features/codegraph/cg-validation.html +47 -0
  118. package/resources/project-architecture/features/codegraph/index.html +58 -0
  119. package/resources/project-architecture/features/eval-ci-gate/workflow-trigger.html +6 -1
  120. package/resources/project-architecture/features/eval-cli/cli-handler.html +8 -1
  121. package/resources/project-architecture/features/eval-executor/exec-api-client.html +6 -1
  122. package/resources/project-architecture/features/eval-executor/trace-recorder.html +6 -1
  123. package/resources/project-architecture/features/eval-isolation/tool-dispatcher.html +6 -1
  124. package/resources/project-architecture/features/eval-optimizer/dedup-engine.html +6 -1
  125. package/resources/project-architecture/features/eval-optimizer/issue-extractor.html +7 -1
  126. package/resources/project-architecture/features/eval-question/question-loader.html +6 -1
  127. package/resources/project-architecture/features/eval-question/variant-generator.html +6 -1
  128. package/resources/project-architecture/features/eval-reporter/report-composer.html +6 -1
  129. package/resources/project-architecture/features/eval-scorer/judge-api-client.html +6 -1
  130. package/resources/project-architecture/features/eval-scorer/judge-prompt-builder.html +6 -1
  131. package/resources/project-architecture/index.html +200 -94
  132. package/scripts/test.sh +39 -0
  133. package/skills/design/SKILL.md +33 -0
  134. package/skills/init-project-html/SKILL.md +66 -56
  135. package/skills/init-project-html/lib/atlas/assets/architecture.css +2 -1
  136. package/skills/init-project-html/lib/atlas/render.js +11 -1
  137. package/skills/init-project-html/lib/atlas/schema.js +44 -7
  138. package/skills/init-project-html/references/TEMPLATE_SPEC.md +20 -0
  139. package/skills/init-project-html/references/architecture.md +35 -35
  140. package/skills/init-project-html/references/definition.md +12 -17
  141. package/skills/update-project-html/README.md +16 -27
  142. package/skills/update-project-html/SKILL.md +54 -41
  143. package/skills/update-project-html/references/architecture.md +35 -35
  144. package/skills/update-project-html/references/definition.md +12 -17
  145. package/tsconfig.json +1 -0
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env bash
2
+ # Split test runner — isolates mock.module tests from the rest to avoid
3
+ # a Node.js 24.x test runner IPC deserialization issue that can make
4
+ # tests flaky when --experimental-test-module-mocks is active globally.
5
+ # See: https://github.com/nodejs/node/issues (test_runner IPC clone)
6
+
7
+ EXIT=0
8
+
9
+ run_test_group() {
10
+ local label="$1"
11
+ shift
12
+ echo ""
13
+ echo "==> $label"
14
+ if "$@"; then
15
+ echo " PASS"
16
+ else
17
+ echo " FAIL"
18
+ EXIT=1
19
+ fi
20
+ }
21
+
22
+ # Group 1: stable non-mock tests (test/)
23
+ run_test_group "Stable tests (test/)" \
24
+ node --test 'test/**/*.test.js'
25
+
26
+ # Group 2: package .test.js files that do NOT need mock.module
27
+ EXCLUDE='(cmd-init|cmd-list-apis|cmd-survey)'
28
+ PACKAGE_TEST_FILES=$(find packages -name '*.test.js' -not -path '*/node_modules/*' | grep -v -E "$EXCLUDE" | sort | tr '\n' ' ')
29
+ run_test_group "Package tests (no mock.module)" \
30
+ node --test $PACKAGE_TEST_FILES
31
+
32
+ # Group 3: mock-dependent tests — isolated with --experimental-test-module-mocks
33
+ run_test_group "Package tests (mock.module)" \
34
+ node --experimental-test-module-mocks --test \
35
+ 'packages/tools/codegraph/dist/lib/cmd-init.test.js' \
36
+ 'packages/tools/codegraph/dist/lib/cmd-list-apis.test.js' \
37
+ 'packages/tools/codegraph/dist/lib/cmd-survey.test.js'
38
+
39
+ exit $EXIT
@@ -167,6 +167,10 @@ Each component should link to:
167
167
 
168
168
  #### 5e. Generate the Diff and Validate
169
169
 
170
+ Two alternative workflows — use the **Classic flow** when `codegraph` is not installed, or the **CodeGraph-integrated flow** when it is available.
171
+
172
+ **Classic flow** (manual):
173
+
170
174
  ```bash
171
175
  apltk architecture --spec <spec_dir> render
172
176
  apltk architecture --spec <spec_dir> validate
@@ -178,6 +182,35 @@ Confirm validation passes, then use the diff command to produce a visual compari
178
182
  apltk architecture diff
179
183
  ```
180
184
 
185
+ **New flow (CodeGraph-integrated):**
186
+
187
+ 1. **Survey the existing API landscape**:
188
+ ```bash
189
+ apltk codegraph list-apis --all
190
+ ```
191
+ This returns the full project API directory (function names, file paths, callers) as a reference for integration points. Use this data to understand what existing modules, services, and functions your new feature will interact with.
192
+
193
+ 2. **Fill the proposal skeleton**: Based on your design decisions from steps 5a-5d,
194
+ fill in the `proposal.yaml` file generated by `apltk architecture template`.
195
+ Define the feature, its submodules, their functions, and cross-feature edges.
196
+
197
+ 3. **Apply batch mutations**:
198
+ ```bash
199
+ apltk architecture apply <spec_dir>/architecture_diff/atlas/proposal.yaml --spec <spec_dir>
200
+ ```
201
+ This processes all mutations in one call with undo protection.
202
+
203
+ 4. **Verify correctness**:
204
+ ```bash
205
+ apltk codegraph verify --spec <spec_dir>
206
+ ```
207
+ This confirms every symbol and edge reference in the spec overlay exists in the actual code.
208
+
209
+ 5. **Render and validate** (optional, for visual confirmation):
210
+ ```bash
211
+ apltk architecture diff --spec <spec_dir>
212
+ ```
213
+
181
214
  **Single spec**: Produce one Architecture Diff for one SPEC.md.
182
215
  **Batch spec**: Produce **one** unified Architecture Diff covering all SPEC.md files in the batch.
183
216
 
@@ -1,31 +1,30 @@
1
1
  ---
2
2
  name: init-project-html
3
- description: 為項目初始化架構圖。透過 apltk CLI 將功能模塊與子模塊的關係轉化為可渲染的 HTML 架構圖,採用 C4 模型層級(Context → Container → Component → Code)。
3
+ description: Initialize the project architecture atlas. Use the apltk CLI to map feature and submodule relationships into a renderable HTML architecture diagram following the C4 model (Context → Container → Component → Code).
4
4
  ---
5
5
 
6
- ## 技能目標
6
+ ## Goal
7
7
 
8
- 透過 `apltk` CLI 製作項目架構圖。
9
- 幫助用戶理解專案的軟體架構。
8
+ Produce a project architecture diagram via the `apltk` CLI.
9
+ Help users understand the project's software architecture.
10
10
 
11
- ## 驗收條件
11
+ ## Acceptance Criteria
12
12
 
13
- - 所有子模塊之間的 edge 被完整定義
14
- - 所有子模塊內部的 edge 被完整定義
15
- - 架構圖完整展示整個系統之中子模塊之間的關係以及功能模塊之間的關係
16
- - 每個宣告的 component 皆附有來源程式碼證據;無法確定的標記為 inferred
17
- - 架構圖層級對應 C4 model:功能模塊(Container 層級)→ 子模塊(Component 層級)
13
+ - The diagram covers all four C4 levels: System Context → Container (feature) → Component (submodule) → Code (function row)
14
+ - All cross-module and intra-module edges are fully defined
15
+ - Every declared component is backed by source code evidence (`evidence.sourceFile:sourceLine`); unresolved ones are tagged `inferred`
16
+ - Every submodule must declare its `functions` and `variables` arrays (mandatory, may not be left empty)
18
17
 
19
- ## C4 模型對照
18
+ ## C4 Mapping
20
19
 
21
- 本技能的「功能模塊」與「子模塊」對應到 C4 model 的以下層級:
20
+ This skill's "feature" and "submodule" map to the C4 model as follows:
22
21
 
23
- | C4 層級 | 本技能對應 | 說明 | 使用時機 |
24
- |---------|-----------|------|---------|
25
- | System Context | 整體系統 | 系統與外部 actor、外部系統的關係 | 步驟 1 建立基線認知 |
26
- | Container | 功能模塊 | 高階功能邊界(如登入功能、支付功能) | 主要抽象層級 |
27
- | Component | 子模塊 | 功能內部的實作單元(如 controllerservicerepository | 主要詳細層級 |
28
- | Code | function | 函式層級細節 | 只在特定關鍵路徑需要 |
22
+ | C4 Level | Skill Equivalent | Description | When to Use |
23
+ |----------|-----------------|-------------|-------------|
24
+ | System Context | Whole system | System boundaries, external actors, and external systems | Step 1 establish baseline awareness |
25
+ | Container | Feature | High-level functional boundary (e.g. Login, Payment) | Primary abstraction level |
26
+ | Component | Submodule | Implementation unit inside a feature (controller, service, repository) | Primary detail level |
27
+ | Code | Function row | Function-level detail with source file and line evidence | Mandatory — every submodule must declare its functions with `evidence.sourceFile:sourceLine` |
29
28
 
30
29
  ## Mode Detection
31
30
 
@@ -48,58 +47,69 @@ At load time, check the project state to select the correct mode:
48
47
  directory already exists and is non-empty, pause and ask the user whether to:
49
48
  (a) overwrite the existing atlas, (b) switch to update mode, or (c) abort.
50
49
 
51
- ## 工作流程
50
+ ## Workflow
52
51
 
53
- 適用模式:design(完整初始化)、record(快速記錄)
52
+ Applicable modes: design (full initialization), record (quick recording)
54
53
 
55
- ### 1. 閱讀並理解代碼庫 先建立 System Context
54
+ ### 1. Survey the project with `apltk codegraph survey`
56
55
 
57
- 在深入程式碼前,先建立系統的宏觀認知:
58
- - 系統與哪些外部 actor 互動(使用者、第三方服務、其他系統)
59
- - 系統提供哪些高階能力
56
+ Before diving into the code, establish a high-level understanding:
57
+ - Which external actors interact with the system (users, third-party services, other systems)
58
+ - What high-level capabilities the system provides
60
59
 
61
- 然後閱讀 `sample-demo/` 了解預期的輸出格式與抽象層級。
60
+ Then read `sample-demo/` to understand the expected output format and abstraction level.
62
61
 
63
- 按照功能模塊定義,全面檢索代碼庫。
64
- 將其拆分為單個或多個功能模塊(對應 C4 Container 層級)。
65
- 接著,識別功能模塊下的子模塊(對應 C4 Component 層級),並進行深度閱讀。
62
+ Next, run `apltk codegraph survey` to get a structured survey report:
63
+ - List of all files in the project directory with function counts
64
+ - Entry points (public functions called from external files)
65
+ - Suggested submodule groupings and cross-boundary edges
66
+ - Supports `--json` output for programmatic consumption by the LLM
66
67
 
67
- 並行調度 subagents,並為每一個功能模塊分配一個 subagent 進行深度閱讀,要求 subagents 完整列出:
68
- - 該功能模塊與其他功能模塊之間是否存在交互;如有,如何交互。
69
- - 該功能模塊內部存在哪些子模塊,這些子模塊之間如何交互並實現功能模塊的功能。
70
- - 該功能模塊及下屬子模塊的資料流、錯誤處理。
68
+ Based on the survey report, decide how to partition features (C4 Container level):
69
+ - Group closely interconnected function clusters into the same feature's submodules
70
+ - Identify feature boundaries and cross-feature call relationships
71
+ - Record the directory path and entry points for each feature
71
72
 
72
- > 每個 subagent 回報的每個宣告都應附上對應的程式碼檔案路徑與行號,作為證據追溯的基礎。
73
+ ### 2. Write the atlas with `apltk architecture apply`
73
74
 
74
- ### 2. 使用 `apltk` cli 工具協助生成架構圖
75
+ Generate the atlas incrementally by C4 level:
76
+ Consult `references/architecture.md` for CLI flag details when needed (parameter reference, mutation series).
75
77
 
76
- 依照 C4 層級逐步產生:
77
- 在操作 CLI 前先閱讀 `references/architecture.md` 了解所有參數與 mutation 系列的使用方式。
78
+ 1. **System Context**: Define external actors, system boundaries, and cross-system edges
79
+ 2. **Container level**: Define features and their inter-feature edges
80
+ 3. **Component level**: Define submodules with their internal elements (function, variable, dataflow, error)
81
+ 4. **Code level**: Declare `functions` and `variables` for every submodule, attaching `evidence` (source file and line number via `--evidence observed:path/file.ts:42`)
78
82
 
79
- 1. **System Context**:定義外部 actor、系統邊界、跨系統 edge
80
- 2. **Container 層級**:定義功能模塊(feature)及其之間的 edge
81
- 3. **Component 層級**:定義子模塊(submodule)及其內部元素(function、variable、dataflow、error)
82
- 4. **Code 層級**(選擇性):對關鍵路徑補充函式層級細節
83
+ Use `apltk architecture apply <proposal.yaml>` for batch atlas writes (replaces manual per-mutation CLI calls).
84
+ Transform the codebase knowledge gathered in the previous step into a clear architecture diagram.
85
+ After completion, verify the atlas format is valid and renders correctly.
83
86
 
84
- 將前一步獲取的代碼庫知識透過 CLI 工具轉化為清晰的架構圖。
85
- 完成後驗證架構圖格式正確且可渲染。
87
+ ### 3. Self-review
86
88
 
87
- ## 證據追溯
89
+ Confirm the following before finishing:
88
90
 
89
- 每個透過 CLI 宣告的 component 應附上對應的來源證據:
91
+ - [ ] All four C4 levels are populated (Context → Container → Component → Code)
92
+ - [ ] Every submodule has at least one function declared with source evidence
93
+ - [ ] All cross-feature and intra-feature edges are defined
94
+ - [ ] Evidence level is correctly set (`observed` for source-confirmed, `inferred` otherwise)
95
+ - [ ] Atlas passes `apltk architecture validate`
90
96
 
91
- - 功能模塊(feature)→ 對應的目錄路徑或 entry point 檔案
92
- - 子模塊(submodule)→ 實作該模組的檔案列表
93
- - function 行 → 函式定義的檔案與行號
94
- - edge → 觸發該呼叫關係的程式碼位置
97
+ ## Evidence Traceability
95
98
 
96
- 若因時間或上下文限制無法完整追溯,在 `meta.summary` 中記錄已掃描範圍與已知遺漏。
99
+ Every component declared via the CLI must carry source evidence:
97
100
 
98
- ## 參考資料
101
+ - Feature → corresponding directory path or entry point file
102
+ - Submodule → list of files implementing the module
103
+ - Function row → source file and line number (`evidence.sourceFile` + `evidence.sourceLine`)
104
+ - Edge → code location triggering the call relationship
99
105
 
100
- - `references/architecture.md` apltk architecture 工具的完整參數說明。在步驟 2 產生架構圖前閱讀。
101
- - `references/TEMPLATE_SPEC.md`:atlas 欄位、列舉和 CLI 寫入形狀速查表。
102
- - `references/definition.md`: 功能模塊和子模塊的詳細定義。
103
- - `assets/architecture-page.template.html`: 模板 html。
104
- - `references/architecture.css`: 風格模板。
105
- - `sample-demo/`:完整示例輸出,用於理解基礎 atlas 的最終形態與 C4 層級對應。
106
+ If time or context constraints prevent full traceability, record the scanned scope and known gaps in `meta.summary`.
107
+
108
+ ## References
109
+
110
+ - `references/architecture.md` — Full parameter reference for the apltk architecture tool (consult when CLI flag details are needed).
111
+ - `references/TEMPLATE_SPEC.md` Atlas field reference, enum values, and CLI shape cheat sheet.
112
+ - `references/definition.md` — Detailed definitions of feature and submodule.
113
+ - `assets/architecture-page.template.html` — HTML template.
114
+ - `references/architecture.css` — Style template.
115
+ - `sample-demo/` — Complete example output for understanding the final atlas shape and C4 level mapping.
@@ -759,7 +759,8 @@ p { line-height: 1.6; color: var(--vellum-soft); }
759
759
  /* =================================================================
760
760
  evidence badges
761
761
  ================================================================= */
762
- .evi { display: inline-block; padding: 0 6px; border-radius: 3px; font-size: 11px; font-weight: 600; line-height: 18px; cursor: help; }
762
+ .evi { display: inline-block; padding: 0 6px; border-radius: 3px; font-size: 11px; font-weight: 600; line-height: 18px; cursor: help; white-space: nowrap; }
763
+ .evi__source { font-size: 10px; font-weight: 400; margin-left: 4px; padding: 1px 5px; border-radius: 3px; background: rgba(0,0,0,0.15); color: inherit; }
763
764
  .evi--observed { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
764
765
  .evi--inferred { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
765
766
  .evi--assumed { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
@@ -309,7 +309,17 @@ function renderEvidenceBadge(ev) {
309
309
  const label = EVI_LABEL[ev.level] || ev.level;
310
310
  const title = ev.source ? htmlEscape(ev.source) : '';
311
311
  const titleAttr = title ? ` title="${title}"` : '';
312
- return `<span class="evi evi--${ev.level}"${titleAttr}>${label}</span>`;
312
+
313
+ // Append source location when structured file:line data is available
314
+ let locHtml = '';
315
+ if (ev.sourceFile && ev.sourceFile !== ev.source && /[/\\]|\.[a-zA-Z0-9]+$/.test(ev.sourceFile)) {
316
+ const loc = ev.sourceLine
317
+ ? `${htmlEscape(ev.sourceFile)}:${ev.sourceLine}`
318
+ : htmlEscape(ev.sourceFile);
319
+ locHtml = ` <code class="evi__source">${loc}</code>`;
320
+ }
321
+
322
+ return `<span class="evi evi--${ev.level}"${titleAttr}>${label}${locHtml}</span>`;
313
323
  }
314
324
 
315
325
  function renderSubmoduleTable(headers, rows, evidences) {
@@ -69,17 +69,54 @@ function parseEvidence(value) {
69
69
  const str = String(value);
70
70
  const colon = str.indexOf(':');
71
71
  let level, source;
72
+
72
73
  if (colon === -1) {
73
- level = 'inferred';
74
- source = str;
74
+ if (EVIDENCE_LEVELS.includes(str)) {
75
+ level = str;
76
+ source = '';
77
+ } else {
78
+ level = 'inferred';
79
+ source = str;
80
+ }
75
81
  } else {
76
- level = str.slice(0, colon);
77
- source = str.slice(colon + 1);
78
- if (!EVIDENCE_LEVELS.includes(level)) {
79
- throw new Error(`Invalid evidence level: "${level}". Must be one of: ${EVIDENCE_LEVELS.join(', ')}`);
82
+ const candidateLevel = str.slice(0, colon);
83
+ if (EVIDENCE_LEVELS.includes(candidateLevel)) {
84
+ level = candidateLevel;
85
+ source = str.slice(colon + 1);
86
+ } else {
87
+ level = 'inferred';
88
+ source = str;
89
+ }
90
+ }
91
+
92
+ // Extract structured sourceFile & sourceLine from the source string.
93
+ // Heuristic: source ends with ":<number>" and the part before the last
94
+ // colon resembles a file path (contains '/' or '.'), so parse it as
95
+ // "path/to/file.ext:lineNumber".
96
+ let sourceFile = null;
97
+ let sourceLine = null;
98
+ if (source) {
99
+ const lastColon = source.lastIndexOf(':');
100
+ if (lastColon !== -1) {
101
+ const afterColon = source.slice(lastColon + 1).trim();
102
+ const lineNum = parseInt(afterColon, 10);
103
+ const filePart = source.slice(0, lastColon);
104
+ if (
105
+ !isNaN(lineNum) && lineNum > 0 &&
106
+ String(lineNum) === afterColon &&
107
+ (/[/\\]/.test(filePart) || /\.[a-zA-Z0-9]+$/.test(filePart))
108
+ ) {
109
+ sourceFile = filePart;
110
+ sourceLine = lineNum;
111
+ } else {
112
+ sourceFile = source;
113
+ }
114
+ } else {
115
+ sourceFile = source;
80
116
  }
81
117
  }
82
- return { level, source };
118
+
119
+ return { level, source, sourceFile, sourceLine };
83
120
  }
84
121
 
85
122
  function noFix(message) {
@@ -129,6 +129,26 @@ CLI: `apltk architecture error add --feature X --submodule Y --name ErrCode --wh
129
129
 
130
130
  CLI: `apltk architecture edge add --from <feature>[/sub] --to <feature>[/sub] --kind call --label "..."`
131
131
 
132
+ ### `evidence` (shared, optional on every entity above)
133
+
134
+ | Field | Type | Required | Notes |
135
+ | ---------- | ---- | -------- | ----- |
136
+ | level | enum `observed` `inferred` `assumed` | yes | Quality tier — drives badge colour (green/amber/red). |
137
+ | source | string | no | Free-text evidence description. |
138
+ | sourceFile | string | no | Extracted file path (e.g. `src/auth/controller.ts`). Auto-parsed from `--evidence observed:path/file.ts:42`. |
139
+ | sourceLine | number | no | Extracted line number. Auto-parsed from `--evidence observed:path/file.ts:42`. |
140
+
141
+ CLI: `--evidence observed:path/to/file.ts:42` (line number parsed automatically when source ends with `:N` and the preceding segment resembles a file path).
142
+
143
+ In YAML:
144
+ ```yaml
145
+ evidence:
146
+ level: observed
147
+ sourceFile: src/auth/controller.ts
148
+ sourceLine: 42
149
+ source: src/auth/controller.ts:42
150
+ ```
151
+
132
152
  ## Class hooks on rendered HTML
133
153
 
134
154
  These are emitted automatically by `lib/atlas/render.js`. Agents do **not** write them by hand — they are listed here only so reviewers know which selectors are stable.
@@ -1,40 +1,40 @@
1
- # apltk architecture — 宣告式架構圖 CLI
1
+ # apltk architecture — Declarative Architecture Diagram CLI
2
2
 
3
- ## 用途
4
- 透過 YAML 狀態檔案管理 `resources/project-architecture/` 下的架構圖,支援基礎架構圖與 spec 覆蓋層的差異比對與合併。
3
+ ## Purpose
4
+ Manage architecture diagrams under `resources/project-architecture/` via YAML state files. Supports base atlas and spec overlay diff/merge comparison.
5
5
 
6
- ## 用法
6
+ ## Usage
7
7
  ```
8
8
  apltk architecture [verb] [options]
9
9
  ```
10
10
 
11
- ## 全局旗標
12
- | 旗標 | 效果 |
13
- |------|------|
14
- | `--project <root>` | 指定專案根目錄(預設從 cwd 向上搜尋) |
15
- | `--spec <spec_dir>` | 寫入 spec overlay 而非基礎架構圖 |
16
- | `--no-render` | 變更後略過自動重新渲染,可批次多條指令 |
17
- | `--no-open` | `open` `diff` 時不開啟瀏覽器 |
18
- | `--dry-run` | 預覽變更為 JSON diff,不實際寫入 |
19
- | `--out <dir>` | `diff` 的輸出目錄 |
20
- | `--clean` | `merge` 成功後移除 spec overlay 目錄 |
21
- | `--all` | `merge` 時選取所有 pending spec overlay |
22
- | `--json` | `status` 時輸出 JSON |
23
- | `--evidence <level[:source]>` | 為組件標記 observed/inferred/assumed 品質等級 |
24
-
25
- ## 頂層動詞
26
- - **`open`** — 開啟基礎架構圖 HTML,若未渲染則先 bootstrap
27
- - **`diff`** — 收集 `docs/plans/` 下所有 overlay,產生 before/after 檢視器
28
- - **`render`** — 從當前 YAML 狀態重新產生 HTML
29
- - **`validate`** — 驗證架構圖結構完整性(schema + referential integrity
30
- - **`status`** — 顯示摘要(feature/submodule/edge/actor 數量、時間戳、驗證狀態)
31
- - **`scan --src <dir>`** — 掃描目錄結構,輸出 JSON 候選 feature 列表
32
- - **`undo [--steps <n>]`** — 還原最近一次 mutation
33
- - **`merge --spec <dir> | --all`** — spec overlay 合併回基礎架構圖
34
-
35
- ## Mutation 系列
36
-
37
- 所有 mutation 共用 `--project`、`--spec`、`--no-render`、`--dry-run`、`--evidence` 旗標。
11
+ ## Global Flags
12
+ | Flag | Effect |
13
+ |------|--------|
14
+ | `--project <root>` | Specify project root (defaults to upward search from cwd) |
15
+ | `--spec <spec_dir>` | Write to spec overlay instead of base atlas |
16
+ | `--no-render` | Skip auto-render after mutations for batch operations |
17
+ | `--no-open` | Skip browser launch for `open` and `diff` |
18
+ | `--dry-run` | Preview changes as JSON diff without writing |
19
+ | `--out <dir>` | Output directory for `diff` |
20
+ | `--clean` | Remove spec overlay directory after successful `merge` |
21
+ | `--all` | Select all pending spec overlays for `merge` |
22
+ | `--json` | JSON output for `status` |
23
+ | `--evidence <level[:source]>` | Mark component quality tier (observed/inferred/assumed); source supports auto-parsed `file:line` (e.g. `observed:src/foo.ts:42`) |
24
+
25
+ ## Top-Level Verbs
26
+ - **`open`** — Open base atlas HTML in browser; bootstrap if not rendered
27
+ - **`diff`** — Collect all overlays under `docs/plans/`, generate before/after viewer
28
+ - **`render`** — Regenerate HTML from current YAML state
29
+ - **`validate`** — Validate atlas structural integrity (schema + referential integrity)
30
+ - **`status`** — Show summary (feature/submodule/edge/actor counts, timestamp, validation status)
31
+ - **`scan --src <dir>`** — Scan directory structure, output JSON candidate feature list
32
+ - **`undo [--steps <n>]`** — Revert the most recent mutation(s)
33
+ - **`merge --spec <dir> | --all`** — Merge spec overlay(s) into base atlas
34
+
35
+ ## Mutation Series
36
+
37
+ All mutations share `--project`, `--spec`, `--no-render`, `--dry-run`, `--evidence` flags.
38
38
 
39
39
  ### feature
40
40
  ```
@@ -92,7 +92,7 @@ apltk architecture actor add --id <actor-id> [--label "..."]
92
92
  apltk architecture actor remove --id <actor-id>
93
93
  ```
94
94
 
95
- ## 注意事項
96
- - 執行 mutation 後自動重新渲染(除非 `--no-render`)
97
- - 每個 mutation 建立 undo snapshot,可行 `undo` 還原
98
- - 驗證通過後才算架構圖工作完成
95
+ ## Notes
96
+ - Auto-render after every mutation (unless `--no-render`)
97
+ - Each mutation creates an undo snapshot — revert with `undo`
98
+ - Atlas work is not complete until validation passes
@@ -1,25 +1,20 @@
1
- ## 功能模塊
1
+ ## Feature
2
2
 
3
- 功能模塊是直接面向用戶的功能,如:
4
- - 登陸功能
5
- - 註冊功能
6
- - 邀請碼功能
3
+ A feature is a user-facing capability, such as:
4
+ - Login
5
+ - Registration
6
+ - Invite code management
7
7
 
8
- 功能模塊由子模塊的合作、交互實現
8
+ Features are realized through collaboration and interaction of their submodules.
9
9
 
10
- 功能模塊對應 C4 model **Container** 層級:高階功能邊界,可獨立部署或辨識的系統能力單元。
10
+ A feature maps to the C4 model's **Container** level: a high-level functional boundary, deployable or identifiable as a distinct system capability unit.
11
11
 
12
- ## 子模塊
12
+ ## Submodule
13
13
 
14
- 子模塊是功能模塊的關鍵組成部分。具體定義依照代碼的實作邊界得出。
14
+ A submodule is a key building block of a feature. Its exact definition follows the implementation boundaries in the code.
15
15
 
16
- 子模塊對應 C4 model **Component** 層級:功能內部的實作單元(如 controllerservicerepository)。
16
+ A submodule maps to the C4 model's **Component** level: an implementation unit inside a feature (e.g., controller, service, repository).
17
17
 
18
- ## C4 模型層級對照
18
+ ## C4 Level Mapping
19
19
 
20
- | C4 層級 | 對應概念 | 用途 |
21
- |---------|---------|------|
22
- | System Context | 整體系統 + 外部 actor | 定義系統邊界與外部依賴 |
23
- | Container | 功能模塊(feature) | 高階功能邊界 |
24
- | Component | 子模塊(submodule) | 功能內部的實作單元 |
25
- | Code | function 行 | 函式層級細節(選擇性) |
20
+ Refer to the C4 mapping table in `SKILL.md` it is not duplicated here.
@@ -1,42 +1,31 @@
1
1
  # update-project-html
2
2
 
3
- `update-project-html` refreshes the project HTML architecture atlas (`resources/project-architecture/`) so it reflects the latest code changes.
4
-
5
- ## What this skill does
6
-
7
- 1. Reads the current atlas (`atlas.index.yaml` + per-feature YAML) — only affected features (context economy).
8
- 2. Measures architecture drift: compares atlas entries against actual codebase structure.
9
- 3. Resolves the diff scope (`git diff --stat` + `git diff --cached --stat` by default, or `git diff --stat <base>..HEAD` when the user names a ref).
10
- 4. Filters out non-architecture changes (formatting, config-only, test-only, comments).
11
- 5. Maps filtered diff hunks to existing or new features.
12
- 6. Dispatches one write-capable subagent per affected feature to deep-read only its own changed files and apply every intra-feature mutation through `apltk architecture` (no `--spec`).
13
- 7. Waits until every subagent finishes, then declares cross-feature edges, runs `apltk architecture render`, and validates.
14
- 8. Re-measures drift to confirm it is within acceptable range.
3
+ Refreshes the project HTML architecture atlas (`resources/project-architecture/`) to reflect the latest code changes.
15
4
 
16
5
  ## When to use
17
6
 
18
- Use this skill when the task asks you to:
19
-
20
- - update or refresh the existing project architecture diagram after code changes,
21
- - bring `resources/project-architecture/` back in sync with the current branch or a specific commit range,
22
- - reflect a recent PR or batch of commits in the canonical atlas before merging or releasing.
7
+ - The existing atlas is out of sync with the current branch or working tree
8
+ - Code has changed (new routes, modules, service logic) and the atlas needs updating before a release
9
+ - You need to bring `resources/project-architecture/` back in sync after a PR or batch of commits
23
10
 
24
- If no atlas exists yet, use `init-project-html` to bootstrap one. For planned but unshipped work scoped to a `docs/plans/...` spec, use `spec-to-project-html` to write under `<spec_dir>/architecture_diff/` instead of the base atlas.
11
+ If no atlas exists yet, use [`init-project-html`](../init-project-html/SKILL.md) to bootstrap one first.
25
12
 
26
13
  ## Core principles
27
14
 
28
- - The CLI owns atlas state and renderer output; agents never hand-edit `resources/project-architecture/**/*.html`.
29
- - Every mutation traces to a specific file + diff hunk; absent code never produces atlas entries.
30
- - Subagent fan-out is the only safe read pattern: one feature per subagent, no shared source loading.
31
- - Cross-feature wiring happens **after** every subagent finishes never from partial summaries.
32
- - Measure drift before and after: confirm the atlas stays within an acceptable drift threshold.
33
- - Filter diff noise: formatting, config-only, test-only, and comment-only changes never drive atlas mutations.
15
+ - The CLI owns atlas state and rendered output; never hand-edit `resources/project-architecture/**/*.html`
16
+ - Every mutation traces to a specific file + diff hunk; absent code never produces atlas entries
17
+ - Measure drift **before and after**: confirm the atlas stays within acceptable thresholds
18
+ - Filter diff noise: formatting, config-only, test-only, and comment-only changes never drive atlas mutations
19
+
20
+ ## Workflow
21
+
22
+ See [`SKILL.md`](./SKILL.md) for the full 6-step workflow.
34
23
 
35
24
  ## References
36
25
 
37
- - [`SKILL.md`](./SKILL.md) — full workflow and execution rules.
38
- - [`../init-project-html/SKILL.md`](../init-project-html/SKILL.md) — semantic rulebook.
39
- - [`../spec-to-project-html/SKILL.md`](../spec-to-project-html/SKILL.md) — spec overlay flow.
26
+ - [`SKILL.md`](./SKILL.md) — Full workflow and execution rules
27
+ - [`../init-project-html/SKILL.md`](../init-project-html/SKILL.md) — C4 semantic rulebook
28
+ - [`../init-project-html/references/TEMPLATE_SPEC.md`](../init-project-html/references/TEMPLATE_SPEC.md) — Atlas field reference and schema
40
29
 
41
30
  ## License
42
31