@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.
- package/AGENTS.md +37 -27
- package/CHANGELOG.md +47 -0
- package/CLAUDE.md +37 -27
- package/README.md +15 -2
- package/assets/spec/rg13-1780435029246/test-questions.json +1 -0
- package/assets/spec/rg13-1780468345132/test-questions.json +1 -0
- package/package.json +3 -3
- package/packages/cli/dist/tool-registration.js +1 -0
- package/packages/cli/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/cli/tool-registration.ts +1 -0
- package/packages/tools/architecture/dist/index.js +549 -2
- package/packages/tools/architecture/dist/index.test.d.ts +1 -0
- package/packages/tools/architecture/dist/index.test.js +229 -0
- package/packages/tools/architecture/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/tools/architecture/index.test.ts +329 -0
- package/packages/tools/architecture/index.ts +613 -5
- package/packages/tools/codegraph/dist/index.d.ts +3 -0
- package/packages/tools/codegraph/dist/index.js +343 -0
- package/packages/tools/codegraph/dist/lib/cg-instance.d.ts +29 -0
- package/packages/tools/codegraph/dist/lib/cg-instance.js +59 -0
- package/packages/tools/codegraph/dist/lib/cg-instance.test.d.ts +1 -0
- package/packages/tools/codegraph/dist/lib/cg-instance.test.js +27 -0
- package/packages/tools/codegraph/dist/lib/cmd-explore.d.ts +5 -0
- package/packages/tools/codegraph/dist/lib/cmd-explore.js +95 -0
- package/packages/tools/codegraph/dist/lib/cmd-explore.test.d.ts +1 -0
- package/packages/tools/codegraph/dist/lib/cmd-explore.test.js +133 -0
- package/packages/tools/codegraph/dist/lib/cmd-flag-splice.test.d.ts +1 -0
- package/packages/tools/codegraph/dist/lib/cmd-flag-splice.test.js +83 -0
- package/packages/tools/codegraph/dist/lib/cmd-init.d.ts +5 -0
- package/packages/tools/codegraph/dist/lib/cmd-init.js +50 -0
- package/packages/tools/codegraph/dist/lib/cmd-init.test.d.ts +1 -0
- package/packages/tools/codegraph/dist/lib/cmd-init.test.js +51 -0
- package/packages/tools/codegraph/dist/lib/cmd-list-apis.d.ts +5 -0
- package/packages/tools/codegraph/dist/lib/cmd-list-apis.js +64 -0
- package/packages/tools/codegraph/dist/lib/cmd-list-apis.test.d.ts +1 -0
- package/packages/tools/codegraph/dist/lib/cmd-list-apis.test.js +69 -0
- package/packages/tools/codegraph/dist/lib/cmd-search.d.ts +5 -0
- package/packages/tools/codegraph/dist/lib/cmd-search.js +21 -0
- package/packages/tools/codegraph/dist/lib/cmd-search.test.d.ts +1 -0
- package/packages/tools/codegraph/dist/lib/cmd-search.test.js +30 -0
- package/packages/tools/codegraph/dist/lib/cmd-status.d.ts +4 -0
- package/packages/tools/codegraph/dist/lib/cmd-status.js +44 -0
- package/packages/tools/codegraph/dist/lib/cmd-status.test.d.ts +1 -0
- package/packages/tools/codegraph/dist/lib/cmd-status.test.js +72 -0
- package/packages/tools/codegraph/dist/lib/cmd-survey.d.ts +36 -0
- package/packages/tools/codegraph/dist/lib/cmd-survey.js +142 -0
- package/packages/tools/codegraph/dist/lib/cmd-survey.test.d.ts +1 -0
- package/packages/tools/codegraph/dist/lib/cmd-survey.test.js +136 -0
- package/packages/tools/codegraph/dist/lib/cmd-sync.d.ts +4 -0
- package/packages/tools/codegraph/dist/lib/cmd-sync.js +51 -0
- package/packages/tools/codegraph/dist/lib/cmd-sync.test.d.ts +1 -0
- package/packages/tools/codegraph/dist/lib/cmd-sync.test.js +30 -0
- package/packages/tools/codegraph/dist/lib/cmd-verify.d.ts +4 -0
- package/packages/tools/codegraph/dist/lib/cmd-verify.js +134 -0
- package/packages/tools/codegraph/dist/lib/cmd-verify.test.d.ts +1 -0
- package/packages/tools/codegraph/dist/lib/cmd-verify.test.js +139 -0
- package/packages/tools/codegraph/dist/lib/formatter.d.ts +67 -0
- package/packages/tools/codegraph/dist/lib/formatter.js +107 -0
- package/packages/tools/codegraph/dist/lib/formatter.test.d.ts +1 -0
- package/packages/tools/codegraph/dist/lib/formatter.test.js +41 -0
- package/packages/tools/codegraph/dist/lib/survey/grouper.d.ts +19 -0
- package/packages/tools/codegraph/dist/lib/survey/grouper.js +194 -0
- package/packages/tools/codegraph/dist/lib/survey/grouper.test.d.ts +1 -0
- package/packages/tools/codegraph/dist/lib/survey/grouper.test.js +62 -0
- package/packages/tools/codegraph/dist/lib/survey/scanner.d.ts +31 -0
- package/packages/tools/codegraph/dist/lib/survey/scanner.js +50 -0
- package/packages/tools/codegraph/dist/lib/verify/checker.d.ts +32 -0
- package/packages/tools/codegraph/dist/lib/verify/checker.js +146 -0
- package/packages/tools/codegraph/dist/lib/verify/checker.test.d.ts +1 -0
- package/packages/tools/codegraph/dist/lib/verify/checker.test.js +128 -0
- package/packages/tools/codegraph/dist/tsconfig.tsbuildinfo +1 -0
- package/packages/tools/codegraph/env.d.ts +56 -0
- package/packages/tools/codegraph/index.ts +362 -0
- package/packages/tools/codegraph/lib/cg-instance.test.ts +36 -0
- package/packages/tools/codegraph/lib/cg-instance.ts +66 -0
- package/packages/tools/codegraph/lib/cmd-explore.test.ts +195 -0
- package/packages/tools/codegraph/lib/cmd-explore.ts +129 -0
- package/packages/tools/codegraph/lib/cmd-flag-splice.test.ts +94 -0
- package/packages/tools/codegraph/lib/cmd-init.test.ts +68 -0
- package/packages/tools/codegraph/lib/cmd-init.ts +60 -0
- package/packages/tools/codegraph/lib/cmd-list-apis.test.ts +80 -0
- package/packages/tools/codegraph/lib/cmd-list-apis.ts +90 -0
- package/packages/tools/codegraph/lib/cmd-search.test.ts +37 -0
- package/packages/tools/codegraph/lib/cmd-search.ts +32 -0
- package/packages/tools/codegraph/lib/cmd-status.test.ts +86 -0
- package/packages/tools/codegraph/lib/cmd-status.ts +53 -0
- package/packages/tools/codegraph/lib/cmd-survey.test.ts +161 -0
- package/packages/tools/codegraph/lib/cmd-survey.ts +199 -0
- package/packages/tools/codegraph/lib/cmd-sync.test.ts +41 -0
- package/packages/tools/codegraph/lib/cmd-sync.ts +62 -0
- package/packages/tools/codegraph/lib/cmd-verify.test.ts +162 -0
- package/packages/tools/codegraph/lib/cmd-verify.ts +145 -0
- package/packages/tools/codegraph/lib/formatter.test.ts +47 -0
- package/packages/tools/codegraph/lib/formatter.ts +130 -0
- package/packages/tools/codegraph/lib/survey/grouper.test.ts +72 -0
- package/packages/tools/codegraph/lib/survey/grouper.ts +226 -0
- package/packages/tools/codegraph/lib/survey/scanner.ts +89 -0
- package/packages/tools/codegraph/lib/verify/checker.test.ts +140 -0
- package/packages/tools/codegraph/lib/verify/checker.ts +172 -0
- package/packages/tools/codegraph/package.json +23 -0
- package/packages/tools/codegraph/tsconfig.json +22 -0
- package/resources/project-architecture/atlas/atlas.history.log +32 -0
- package/resources/project-architecture/atlas/atlas.history.undo.json +356 -28
- package/resources/project-architecture/atlas/atlas.history.undo.stack.json +14350 -0
- package/resources/project-architecture/atlas/atlas.index.yaml +76 -12
- package/resources/project-architecture/atlas/features/codegraph.yaml +95 -0
- package/resources/project-architecture/atlas/features/eval-ci-gate.yaml +6 -1
- package/resources/project-architecture/atlas/features/eval-cli.yaml +16 -1
- package/resources/project-architecture/atlas/features/eval-executor.yaml +12 -2
- package/resources/project-architecture/atlas/features/eval-isolation.yaml +6 -1
- package/resources/project-architecture/atlas/features/eval-optimizer.yaml +17 -2
- package/resources/project-architecture/atlas/features/eval-question.yaml +12 -2
- package/resources/project-architecture/atlas/features/eval-reporter.yaml +6 -1
- package/resources/project-architecture/atlas/features/eval-scorer.yaml +12 -2
- package/resources/project-architecture/features/codegraph/cg-discovery.html +47 -0
- package/resources/project-architecture/features/codegraph/cg-lifecycle.html +48 -0
- package/resources/project-architecture/features/codegraph/cg-validation.html +47 -0
- package/resources/project-architecture/features/codegraph/index.html +58 -0
- package/resources/project-architecture/features/eval-ci-gate/workflow-trigger.html +6 -1
- package/resources/project-architecture/features/eval-cli/cli-handler.html +8 -1
- package/resources/project-architecture/features/eval-executor/exec-api-client.html +6 -1
- package/resources/project-architecture/features/eval-executor/trace-recorder.html +6 -1
- package/resources/project-architecture/features/eval-isolation/tool-dispatcher.html +6 -1
- package/resources/project-architecture/features/eval-optimizer/dedup-engine.html +6 -1
- package/resources/project-architecture/features/eval-optimizer/issue-extractor.html +7 -1
- package/resources/project-architecture/features/eval-question/question-loader.html +6 -1
- package/resources/project-architecture/features/eval-question/variant-generator.html +6 -1
- package/resources/project-architecture/features/eval-reporter/report-composer.html +6 -1
- package/resources/project-architecture/features/eval-scorer/judge-api-client.html +6 -1
- package/resources/project-architecture/features/eval-scorer/judge-prompt-builder.html +6 -1
- package/resources/project-architecture/index.html +200 -94
- package/scripts/test.sh +39 -0
- package/skills/design/SKILL.md +33 -0
- package/skills/init-project-html/SKILL.md +66 -56
- package/skills/init-project-html/lib/atlas/assets/architecture.css +2 -1
- package/skills/init-project-html/lib/atlas/render.js +11 -1
- package/skills/init-project-html/lib/atlas/schema.js +44 -7
- package/skills/init-project-html/references/TEMPLATE_SPEC.md +20 -0
- package/skills/init-project-html/references/architecture.md +35 -35
- package/skills/init-project-html/references/definition.md +12 -17
- package/skills/update-project-html/README.md +16 -27
- package/skills/update-project-html/SKILL.md +54 -41
- package/skills/update-project-html/references/architecture.md +35 -35
- package/skills/update-project-html/references/definition.md +12 -17
- package/tsconfig.json +1 -0
package/scripts/test.sh
ADDED
|
@@ -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
|
package/skills/design/SKILL.md
CHANGED
|
@@ -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:
|
|
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
|
-
|
|
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
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
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
|
-
|
|
20
|
+
This skill's "feature" and "submodule" map to the C4 model as follows:
|
|
22
21
|
|
|
23
|
-
| C4
|
|
24
|
-
|
|
25
|
-
| System Context |
|
|
26
|
-
| Container |
|
|
27
|
-
| Component |
|
|
28
|
-
| Code |
|
|
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
|
-
|
|
52
|
+
Applicable modes: design (full initialization), record (quick recording)
|
|
54
53
|
|
|
55
|
-
### 1.
|
|
54
|
+
### 1. Survey the project with `apltk codegraph survey`
|
|
56
55
|
|
|
57
|
-
|
|
58
|
-
-
|
|
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
|
-
|
|
60
|
+
Then read `sample-demo/` to understand the expected output format and abstraction level.
|
|
62
61
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
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
|
-
|
|
73
|
+
### 2. Write the atlas with `apltk architecture apply`
|
|
73
74
|
|
|
74
|
-
|
|
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
|
-
|
|
77
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
85
|
-
完成後驗證架構圖格式正確且可渲染。
|
|
87
|
+
### 3. Self-review
|
|
86
88
|
|
|
87
|
-
|
|
89
|
+
Confirm the following before finishing:
|
|
88
90
|
|
|
89
|
-
|
|
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
|
-
|
|
92
|
-
- 子模塊(submodule)→ 實作該模組的檔案列表
|
|
93
|
-
- function 行 → 函式定義的檔案與行號
|
|
94
|
-
- edge → 觸發該呼叫關係的程式碼位置
|
|
97
|
+
## Evidence Traceability
|
|
95
98
|
|
|
96
|
-
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
- `references/architecture.
|
|
105
|
-
- `
|
|
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
|
-
|
|
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
|
-
|
|
74
|
-
|
|
74
|
+
if (EVIDENCE_LEVELS.includes(str)) {
|
|
75
|
+
level = str;
|
|
76
|
+
source = '';
|
|
77
|
+
} else {
|
|
78
|
+
level = 'inferred';
|
|
79
|
+
source = str;
|
|
80
|
+
}
|
|
75
81
|
} else {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
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 —
|
|
1
|
+
# apltk architecture — Declarative Architecture Diagram CLI
|
|
2
2
|
|
|
3
|
-
##
|
|
4
|
-
|
|
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>` |
|
|
15
|
-
| `--spec <spec_dir>` |
|
|
16
|
-
| `--no-render` |
|
|
17
|
-
| `--no-open` | `open`
|
|
18
|
-
| `--dry-run` |
|
|
19
|
-
| `--out <dir>` | `diff`
|
|
20
|
-
| `--clean` |
|
|
21
|
-
| `--all` |
|
|
22
|
-
| `--json` | `status`
|
|
23
|
-
| `--evidence <level[:source]>` |
|
|
24
|
-
|
|
25
|
-
##
|
|
26
|
-
- **`open`** —
|
|
27
|
-
- **`diff`** —
|
|
28
|
-
- **`render`** —
|
|
29
|
-
- **`validate`** —
|
|
30
|
-
- **`status`** —
|
|
31
|
-
- **`scan --src <dir>`** —
|
|
32
|
-
- **`undo [--steps <n>]`** —
|
|
33
|
-
- **`merge --spec <dir> | --all`** —
|
|
34
|
-
|
|
35
|
-
## Mutation
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
-
|
|
97
|
-
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
-
|
|
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`
|
|
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
|
|
29
|
-
- Every mutation traces to a specific file + diff hunk; absent code never produces atlas entries
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
|
|
33
|
-
|
|
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) —
|
|
38
|
-
- [`../init-project-html/SKILL.md`](../init-project-html/SKILL.md) — semantic rulebook
|
|
39
|
-
- [`../
|
|
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
|
|