@laitszkin/apollo-toolkit 5.0.2 → 5.0.4

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/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  All notable changes to this repository are documented in this file.
4
4
 
5
+ ## [v5.0.4] - 2026-06-07
6
+
7
+ ### Added
8
+
9
+ - **design skill `references/` folder**: Design phase now populates `<spec_dir>/references/` with external method/API reference documents (name, purpose, required parameters), reducing hallucinated external code during implementation.
10
+ - **`apltk codegraph` as dedicated workflow step**: `spec` and `docs-project` skills now run `apltk codegraph survey` before reading requirements, ensuring BDD boundaries align with real code. `design` uses codegraph survey before architecture design.
11
+ - **Brownfield refactoring assessment**: `design` skill now includes explicit T1–T3 refactoring planning for brownfield changes as a standard workflow step.
12
+ - **Worker prompt separation**: `plan` and `qa` skills now store worker prompts in `plan/*.md` and `fix/*.md` files respectively, keeping coordinator prompts focused on strategy. PROMPT.md/FIX.md Reference sections cite all worker prompt paths and code file paths.
13
+ - **Prompt generation guidance consolidated**: Notes on writing quality worker prompts moved from PROMPT.md/FIX.md templates into `plan`/`qa` SKILL.md, aligning with the optimise-skill principle of behavioral guidance in SKILL.md.
14
+
15
+ ### Changed
16
+
17
+ - **Self-review renamed to Verification**: `design` and `spec` skills now use "Pre-delivery Verification" with explicit completeness and quality checks, plus code traceability validation.
18
+
19
+ ## [v5.0.3] - 2026-06-06
20
+
21
+ ### Added
22
+
23
+ - **codegraph integration across skills**: `init-project-html`, `update-project-html`, and `design` now run `apltk codegraph survey` as a prerequisite before architecture work. `commit` and `version-release` run `apltk codegraph sync` to keep the code graph index in sync after code changes.
24
+ - **References section in deliverable templates**: All planner deliverables (SPEC.md, DESIGN.md, CHECKLIST.md, PROMPT.md, REPORT.md, FIX.md) now include a References section populated with important project context files, reducing LLM search overhead.
25
+ - **Branch-aware version release**: `version-release` now detects non-default branches and follows a merge workflow (commit → merge to default → release → sync back).
26
+ - **maintain-project-constraints**: Generated CLAUDE.md/AGENTS.md now include `apltk codegraph` CLI commands and require codegraph investigation before starting work.
27
+ - **Worker prompt specificity**: `plan` and `qa` skill worker prompts now require exact file paths, function/line ranges, and specific change descriptions to reduce worker drift.
28
+ - **Worktree cleanup rule**: `plan` and `qa` PROMPT.md/FIX.md templates include an ALWAYS rule to clean up temporary worktrees after each batch.
29
+
5
30
  ## [v5.0.2] - 2026-06-06
6
31
 
7
32
  ### Fixed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laitszkin/apollo-toolkit",
3
- "version": "5.0.2",
3
+ "version": "5.0.4",
4
4
  "description": "Apollo Toolkit npm installer for managed skill copying across Codex, OpenClaw, and Trae.",
5
5
  "license": "MIT",
6
6
  "author": "LaiTszKin",
@@ -59,4 +59,4 @@
59
59
  "@types/node": "^25.9.1",
60
60
  "typescript": "^6.0.3"
61
61
  }
62
- }
62
+ }
@@ -34,7 +34,12 @@ description: 提交指引與提交前的必要品控閘門。將變更提交到
34
34
 
35
35
  若存在代碼變更,使用 `update-project-html` 檢查並更新項目架構圖。
36
36
 
37
- ### 5. 提交及推送變更
37
+ ### 5. 同步代碼圖索引
38
+
39
+ 若存在代碼變更,執行 `apltk codegraph sync` 確保代碼圖與實際代碼同步。
40
+ 若 `CLAUDE.md` 或 `AGENTS.md` 缺少 `apltk codegraph` 的引用,必須添加。
41
+
42
+ ### 6. 提交及推送變更
38
43
 
39
44
  依使用者的 staging 邊界建立 commit。
40
45
  提交訊息須遵循 `references/commit-messages.md`。
@@ -12,9 +12,13 @@ During architecture survey, identify and classify refactoring opportunities by m
12
12
  ## Acceptance Criteria
13
13
 
14
14
  - Three web research passes completed and recorded
15
+ - `apltk codegraph` survey run on affected modules, with findings recorded
16
+ - Brownfield assessment completed: T1–T3 refactoring opportunities identified and dispositioned
15
17
  - `docs/plans/<YYYY-MM-DD>/<spec_name>/DESIGN.md` produced, covering: architecture design, external dependencies (with API facts and limits), data persistence, invariants, technical trade-offs, design-time refactoring
16
18
  - `docs/plans/<YYYY-MM-DD>/<spec_name>/CHECKLIST.md` produced, covering: behavior-to-test mapping, hardening requirements, test level choices
19
+ - `docs/plans/<YYYY-MM-DD>/<spec_name>/references/` populated with external method/API reference documents (name, purpose, required parameters)
17
20
  - Architecture Diff produced using the C4 model hierarchy
21
+ - DESIGN.md and CHECKLIST.md References sections cite all designed code file paths (not just project context files)
18
22
  - Design-time refactoring classified by module boundary scope (T1–T3) and dispositioned (refactored / scheduled / deferred with rationale)
19
23
 
20
24
  ## Workflow
@@ -72,9 +76,42 @@ Verify external dependency compatibility with the repo's existing dependencies:
72
76
 
73
77
  Output: Recommended tech stack + compatibility report
74
78
 
75
- ### 3. Design Architecture → DESIGN.md
79
+ ### 3. CodeGraph Survey
76
80
 
77
- Based on the research findings, design the architecture. Use `assets/templates/DESIGN.md`.
81
+ Deeply investigate the repo using `apltk codegraph` before designing.
82
+
83
+ #### 3a. Survey the Project
84
+
85
+ Run `apltk codegraph survey --json` to get entry points, function clusters, and cross-boundary edges.
86
+
87
+ Consult `references/codegraph.md` for detailed flags.
88
+
89
+ #### 3b. List APIs in Affected Areas
90
+
91
+ Use `apltk codegraph list-apis` to review the full project API directory in the affected modules — function names, file paths, callers. Understand what existing modules and functions the new feature will interact with.
92
+
93
+ #### 3c. Code Health Assessment
94
+
95
+ While reading code via codegraph, actively assess code quality:
96
+ - Identify code smells, dead code, legacy patterns, and unnecessary complexity in the affected modules
97
+ - Classify findings using the T1–T3 framework (see `references/code-smells.md` for patterns to recognize)
98
+ - T1 items (module-internal simplification) are safe to refactor immediately — existing tests validate behavioral preservation
99
+ - T2 and T3 items feed into the target architecture design
100
+
101
+ ### 4. Read Spec and Design Architecture → DESIGN.md
102
+
103
+ Based on web research (Step 2) and codegraph findings (Step 3), design the architecture. Use `assets/templates/DESIGN.md`.
104
+
105
+ #### 4a. Brownfield Assessment
106
+
107
+ If this is a brownfield change (modifying existing code), design a refactoring plan:
108
+ - Identify which existing modules need restructuring to accommodate the new feature
109
+ - Classify refactoring by T1–T3 scopes (see `references/code-smells.md`)
110
+ - T1: Safe to refactor inline — existing unit tests validate behavior
111
+ - T2: Schedule in task decomposition — existing integration tests validate
112
+ - T3: Define migration strategy with dedicated test coverage
113
+
114
+ #### 4b. Fill DESIGN.md
78
115
 
79
116
  Transfer the research outputs from Steps 2a-2c into the **Research Summary** section of DESIGN.md (feasibility table, reference patterns table, tech stack compatibility table).
80
117
 
@@ -87,16 +124,17 @@ Cover the following sections:
87
124
  - **System Invariants**: Architectural constraints that must not be violated, plus violation symptoms
88
125
  - **Technical Trade-offs**: Each decision with rejected alternatives and lock-in effects
89
126
  - **Design-Time Refactoring**: T1–T3 code health findings classified and dispositioned
127
+ - **References**: List designed code file paths, project context files, and related documents
90
128
 
91
129
  Use `Req 1`, `Req 2` numbering to reference SPEC.md requirements (matching the SPEC.md template's `Requirement 1`, `Requirement 2`).
92
130
 
93
131
  **Scale awareness** — Not every section applies at full depth. Adapt based on the change's scope:
94
132
 
95
- - **Interaction Design (Section 3)**: If the change is confined to a single module with no new cross-module coupling, mark this section as `None`. Do not fabricate INT-### entries.
96
- - **External Dependency deep-dives (Section 4.2)**: For simple utility libraries (e.g., date formatting, UUID generation) with no API quotas, authentication, or failure modes, skip the sub-tables. A one-line entry in Section 4.1 overview suffices.
97
- - **Target vs Baseline (Section 2.3)**: If the change touches multiple dimensions (new modules, removed modules, ownership shifts, deployment changes), expand to multiple rows. A single-dimension change needs only one row.
98
- - **System Invariants (Section 6)**: If the change does not modify any architectural constraint, explicitly write `None` with brief justification.
99
- - **Design-Time Refactoring (Section 8)**: If no code health issues were identified during the architecture survey, write `None`. Do not fabricate findings.
133
+ - **Interaction Design**: If the change is confined to a single module with no new cross-module coupling, mark this section as `None`. Do not fabricate INT-### entries.
134
+ - **External Dependency deep-dives**: For simple utility libraries (e.g., date formatting, UUID generation) with no API quotas, authentication, or failure modes, skip the sub-tables. A one-line entry in the overview suffices.
135
+ - **Target vs Baseline**: If the change touches multiple dimensions (new modules, removed modules, ownership shifts, deployment changes), expand to multiple rows. A single-dimension change needs only one row.
136
+ - **System Invariants**: If the change does not modify any architectural constraint, explicitly write `None` with brief justification.
137
+ - **Design-Time Refactoring**: If no code health issues were identified during the architecture survey, write `None`. Do not fabricate findings.
100
138
 
101
139
  **Design self-challenge** — Before finalizing the design, step back and ask three questions:
102
140
 
@@ -104,18 +142,10 @@ Use `Req 1`, `Req 2` numbering to reference SPEC.md requirements (matching the S
104
142
  2. **Is this the simplest viable design?** Have I introduced abstractions, indirections, or intermediate layers that are not justified by the current requirements? Prefer the simplest structure that works.
105
143
  3. **Are there rejected alternatives?** For every major architectural decision (module split, dependency choice, communication pattern), if you have not considered and explicitly rejected at least one alternative, you may be settling on the first workable solution rather than the best one.
106
144
 
107
- **Design-time refactoring** — While designing the target architecture, also assess code health in the affected modules:
108
-
109
- - **T1 (Module-internal simplification)**: Simplify control flow, remove dead code, inline unnecessary wrappers within a single function or file. Existing unit tests validate behavior — refactor directly.
110
- - **T2 (Module-internal restructuring)**: Extract shared logic, consolidate state, reorganize files within the same module boundary. Existing integration tests validate behavior — include in the design's task decomposition.
111
- - **T3 (Module boundary adjustment)**: Changes affecting a module's public API, data contract, or cross-module coupling. Requires dedicated test coverage — define test strategy in CHECKLIST.md.
112
-
113
- See `references/code-smells.md` for patterns to identify, and the module-specific reference files for detailed guidance per tier.
114
-
115
145
  **Single spec**: Produce one DESIGN.md for one SPEC.md.
116
146
  **Batch spec**: Produce **one** unified DESIGN.md covering the scope of all SPEC.md files in the batch.
117
147
 
118
- ### 4. Define Verification Strategy → CHECKLIST.md
148
+ ### 5. Define Verification Strategy → CHECKLIST.md
119
149
 
120
150
  Use the `test-case-strategy` skill to design the verification strategy.
121
151
  Use `assets/templates/CHECKLIST.md`.
@@ -127,6 +157,7 @@ Cover the following sections:
127
157
  - **Hardening Requirements**: Regression tests, drift checks, property-based tests, edge cases, authorization checks
128
158
  - **E2E / Integration Decisions**: Per flow, choose the appropriate test level with rationale
129
159
  - **Design-Time Refactoring (T3)**: If T3 refactoring is planned, define its test coverage requirements here
160
+ - **References**: List designed code file paths, project context files, and related documents
130
161
 
131
162
  **Mandatory test coverage** (applies when the SPEC.md describes changes other than pure documentation or pure test changes):
132
163
 
@@ -139,30 +170,24 @@ Risk definitions: **Medium risk** = paths involving I/O, external dependencies,
139
170
  **Single spec**: Produce one CHECKLIST.md for one SPEC.md.
140
171
  **Batch spec**: Produce **one** unified CHECKLIST.md covering the behavioral requirements of all SPEC.md files in the batch.
141
172
 
142
- ### 5. Generate Architecture Diff
173
+ ### 6. Generate Architecture Diff
143
174
 
144
175
  Use the `apltk architecture` CLI tool to generate the Architecture Diff, following the C4 model hierarchy.
145
176
 
146
- #### 5a. Read the Existing Architecture
177
+ #### 6a. Read the Existing Architecture
147
178
 
148
179
  Read the project's existing architecture files (`resources/project-architecture/atlas/atlas.index.yaml` + the affected feature YAML files).
149
180
  Do not read unrelated features or modules — maintain context economy.
150
181
 
151
182
  If no existing architecture exists, skip the baseline comparison and start defining the boundary from System Context level.
152
183
 
153
- **Code health assessment** While reading code to measure the baseline, actively assess code quality:
154
- - Identify code smells, dead code, legacy patterns, and unnecessary complexity in the affected modules
155
- - Classify findings using the T1–T3 framework (see `references/code-smells.md` for patterns to recognize)
156
- - T1 items (module-internal simplification) are safe to refactor immediately — existing tests validate behavioral preservation
157
- - T2 and T3 items feed into the target architecture design in Step 3
158
-
159
- #### 5b. Measure Baseline Drift
184
+ #### 6b. Measure Baseline Drift
160
185
 
161
186
  Compare the existing architecture diagram against the current code to assess its reliability:
162
187
  - If the baseline atlas differs significantly from the code (> 20% entries inconsistent), flag the risk in the architecture diff
163
188
  - If the baseline atlas is reliable, the diff can be layered directly on top of it
164
189
 
165
- #### 5c. Define the Diff by C4 Level
190
+ #### 6c. Define the Diff by C4 Level
166
191
 
167
192
  1. **System Context**: Define external actors, system boundaries, cross-system edges
168
193
  2. **Container level** (features): Define new or modified features and the edges between them
@@ -171,68 +196,92 @@ Compare the existing architecture diagram against the current code to assess its
171
196
 
172
197
  C4 level mapping: System Context → system boundary, Container → feature, Component → submodule, Code → function (selective). See `references/definition.md` for full definitions.
173
198
 
174
- #### 5d. Evidence Tracing
199
+ #### 6d. Evidence Tracing
175
200
 
176
201
  Each component should link to:
177
202
  - The requirement number from SPEC.md (requirement → module)
178
203
  - The technical decision from research findings (decision → dependency choice)
179
204
 
180
- #### 5e. Generate the Diff and Validate
205
+ #### 6e. Generate the Diff and Validate
181
206
 
182
207
  Two alternative workflows — use the **Classic flow** when `codegraph` is not installed, or the **CodeGraph-integrated flow** when it is available.
183
208
 
184
209
  **Classic flow** (manual):
185
210
  Generate and validate the architecture diff using `apltk architecture` commands. Confirm validation passes, then produce a visual comparison. See `references/architecture.md` for all CLI flags.
186
211
 
187
- **New flow (CodeGraph-integrated):**
188
-
189
- 1. **Survey the existing API landscape** — Use `apltk codegraph list-apis` to review the full project API directory (function names, file paths, callers). Understand what existing modules and functions your new feature will interact with.
212
+ **CodeGraph-integrated flow:**
190
213
 
191
- 2. **Fill the proposal skeleton** — Based on your design decisions from steps 5a5d, fill in the `proposal.yaml` file generated by `apltk architecture template`. Define the feature, its submodules, their functions, and cross-feature edges.
214
+ 1. **Fill the proposal skeleton** — Based on design decisions from steps 6a6d, fill in the `proposal.yaml` file generated by `apltk architecture template`. Define the feature, its submodules, their functions, and cross-feature edges.
192
215
 
193
- 3. **Apply and verify** — Apply the mutations and verify correctness:
216
+ 2. **Apply and verify** — Apply the mutations and verify correctness:
194
217
  - `apltk architecture apply` processes all mutations with undo protection
195
218
  - `apltk codegraph verify` confirms every symbol and edge reference exists in actual code
196
219
 
197
- 4. **Render diff** (optional) — `apltk architecture diff --spec <spec_dir>` for visual confirmation.
220
+ 3. **Render diff** (optional) — `apltk architecture diff --spec <spec_dir>` for visual confirmation.
198
221
 
199
222
  See `references/architecture.md` for exact CLI flags and mutation commands.
200
223
 
201
224
  **Single spec**: Produce one Architecture Diff for one SPEC.md.
202
225
  **Batch spec**: Produce **one** unified Architecture Diff covering all SPEC.md files in the batch.
203
226
 
204
- ### 6. Pre-delivery Self-Review
227
+ ### 7. Populate references/ Folder
228
+
229
+ Under `<spec_dir>/references/` (single spec) or `<batch_dir>/references/` (batch spec), create reference documents for every external method and API used in the design:
230
+
231
+ #### External Methods
232
+
233
+ For each external method referenced in the design, document:
234
+ - **Method name**: The method or function name
235
+ - **Purpose**: What it does, why it is needed
236
+ - **Required parameters**: Input parameters with types and descriptions
237
+ - **Source**: Where this method is documented (URL or code path)
238
+
239
+ #### External APIs
240
+
241
+ For each external API referenced in the design, document:
242
+ - **API name**: The API or service name
243
+ - **Purpose**: What it does, why it is needed
244
+ - **Required parameters**: Request payload structure, query parameters, headers
245
+ - **Authentication**: How to authenticate (key location, scope)
246
+ - **Rate limits / quotas**: Documented limits
247
+
248
+ **Why this step exists**: Explicit external method/API reference documentation reduces the chance of hallucinated code during implementation. Workers and coordinators can consult these files instead of guessing API shapes.
249
+
250
+ ### 8. Pre-delivery Verification
205
251
 
206
252
  Before delivering, run two passes — completeness then quality.
207
253
 
208
- **Completeness checks** (documentation integrity):
254
+ #### Completeness checks (documentation integrity)
209
255
 
210
256
  - Research results are recorded in DESIGN.md as evidence for technical decisions
211
257
  - Every architecture decision has a trade-off record (rejected alternatives + lock-in effects)
212
258
  - External dependency API facts are traceable to official documentation
213
259
  - CHECKLIST.md completely covers all BDD requirements from SPEC.md
214
260
  - Architecture Diff covers the full change scope
215
- - Design-time refactoring is documented in DESIGN.md Section 8, with T1–T3 findings classified and dispositioned (refactored / scheduled / deferred with rationale)
261
+ - Design-time refactoring is documented in DESIGN.md with T1–T3 findings classified and dispositioned
262
+ - `references/` folder exists with external method and API reference documents
263
+ - DESIGN.md and CHECKLIST.md References sections cite designed code file paths
216
264
 
217
- **Design quality checks** (architectural soundness):
265
+ #### Design quality checks (architectural soundness)
218
266
 
219
267
  - **Requirement traceability**: Can every BDD behavior from SPEC.md be traced to a module, interaction, data flow, or invariant in this design?
220
- - **Internal consistency**: Do the modules listed in Section 2 appear as callers or callees in Section 3? Do the dependencies in Section 4 correspond to module responsibilities in Section 2?
268
+ - **Internal consistency**: Do the modules listed in the architecture appear as callers or callees in the interaction design? Do the dependencies correspond to module responsibilities?
221
269
  - **Design simplicity**: Is this the simplest design that satisfies all requirements? Could any module, abstraction, or dependency be removed without breaking functionality?
222
- - **Risk transparency**: Are all feasibility risks, compatibility concerns, or uncertain technical points from Step 2 either addressed in the design or explicitly documented as accepted risks?
223
- - **Refactoring disposition**: Are all identified code health findings accounted for — either refactored, scheduled in the task plan, or explicitly deferred with rationale? Unaddressed T1/T2 findings represent missed opportunities to reduce technical debt at the cheapest possible time.
270
+ - **Risk transparency**: Are all feasibility risks, compatibility concerns, or uncertain technical points either addressed in the design or explicitly documented as accepted risks?
271
+ - **Refactoring disposition**: Are all identified code health findings accounted for — either refactored, scheduled in the task plan, or explicitly deferred with rationale?
224
272
 
225
273
  ## Examples
226
274
 
227
- - "SPEC.md defines a real-time messaging feature" → Research WebSocket vs SSE vs Polling → Confirm compatibility → Choose SSE → Design architecture → Produce DESIGN.md + CHECKLIST.md + Architecture Diff → During code survey, identify legacy socket wrapper (T2) → schedule extraction in task plan
228
- - "SPEC.md requires CSV export, repo has no CSV library" → Research Node.js CSV libraries (json2csv vs csv-writer vs papaparse) → Confirm compatibility → Choose the lightest option → Design export flow architecture
229
- - "Batch spec: docs/plans/2026-05-29/auth-redesign/ with 3 SPEC.md files (login, permissions, 2FA)" → Read all 3 SPEC.md files → Unified research → Produce **one** DESIGN.md + CHECKLIST.md + Architecture Diff → Identify dead auth middleware during survey (T1) → remove and verify with existing tests
275
+ - "SPEC.md defines a real-time messaging feature" → Research WebSocket vs SSE vs Polling → CodeGraph survey to find existing socket infrastructure → Confirm compatibility → Choose SSE → Design architecture → Produce DESIGN.md + CHECKLIST.md + Architecture Diff → During code survey, identify legacy socket wrapper (T2) → schedule extraction in task plan → Populate references/ with external API docs
276
+ - "SPEC.md requires CSV export, repo has no CSV library" → Research Node.js CSV libraries (json2csv vs csv-writer vs papaparse) → CodeGraph survey to understand export module boundaries → Confirm compatibility → Choose the lightest option → Design export flow architecture → Document CSV library API in references/
277
+ - "Batch spec: docs/plans/2026-05-29/auth-redesign/ with 3 SPEC.md files (login, permissions, 2FA)" → Read all 3 SPEC.md files → Unified research → CodeGraph survey of auth modules → Unified DESIGN.md + CHECKLIST.md + Architecture Diff → Brownfield assessment: identify dead auth middleware during survey (T1) → remove and verify with existing tests → Populate references/ with auth API docs
230
278
 
231
279
  ## References
232
280
 
233
281
  - `assets/templates/DESIGN.md` — DESIGN.md template
234
282
  - `assets/templates/CHECKLIST.md` — CHECKLIST.md template
235
283
  - `references/architecture.md` — `apltk architecture` CLI reference (all mutation commands)
284
+ - `references/codegraph.md` — `apltk codegraph` CLI reference (consult for subcommand flags)
236
285
  - `references/definition.md` — C4 model level definitions
237
286
  - `references/code-smells.md` — Common code smell patterns to spot during architecture survey
238
287
  - `references/module-internal-simplification.md` — T1: module-internal simplification patterns
@@ -37,3 +37,11 @@ Map each BDD requirement from SPEC.md to one or more tests:
37
37
  | Flow / Risk | Test Level | Rationale |
38
38
  |---|---|---|
39
39
  | [Flow description] | [E2E / Integration / Existing coverage / N/A] | [why] |
40
+
41
+ ---
42
+
43
+ ## References
44
+
45
+ - **Designed code file paths**: [List code file paths that this design touches or references — e.g., `src/auth/login.ts`, `src/api/routes.ts`]
46
+ - **Project context files**: [List important project files the LLM will need — e.g., `CLAUDE.md`, `AGENTS.md`, `resources/project-architecture/**`]
47
+ - **Related documents**: [Links to related SPEC.md, DESIGN.md, or external documentation]
@@ -151,3 +151,11 @@ Code health findings identified during architecture survey, classified by module
151
151
  | […] | […] | […] | […] | […] |
152
152
 
153
153
  If none, write **None**.
154
+
155
+ ---
156
+
157
+ ## 9. References
158
+
159
+ - **Designed code file paths**: [List code file paths that this design touches or references — e.g., `src/auth/login.ts`, `src/api/routes.ts`]
160
+ - **Project context files**: [List important project files the LLM will need — e.g., `CLAUDE.md`, `AGENTS.md`, `resources/project-architecture/**`]
161
+ - **Related documents**: [Links to related SPEC.md, other design docs, or external documentation]
@@ -0,0 +1,41 @@
1
+ # apltk codegraph — Code Intelligence CLI Reference
2
+
3
+ ## Purpose
4
+ Parse source code into a knowledge graph of symbols (functions, classes) and relationships (call edges), backed by a local SQLite database with FTS5 full-text search. Powered by @colbymchenry/codegraph (tree-sitter-backed code knowledge graph engine).
5
+
6
+ ## Usage
7
+ ```
8
+ apltk codegraph <subcommand> [options]
9
+ ```
10
+
11
+ ## Subcommands
12
+
13
+ ### Lifecycle
14
+
15
+ | Subcommand | Description | Key Flags |
16
+ |------------|-------------|-----------|
17
+ | `init` | Initialize CodeGraph for the project | `--index` (run initial indexing immediately), `--json` |
18
+ | `sync` | Sync index with current file state (incremental) | `--json` |
19
+ | `status` | Show index statistics (files, nodes, edges, languages) | `--json` |
20
+
21
+ ### Discovery
22
+
23
+ | Subcommand | Description | Key Flags |
24
+ |------------|-------------|-----------|
25
+ | `search <query>` | Search code graph for symbols via FTS5 | `--limit N` (default 20, max 100), `--json` |
26
+ | `explore <query>` | Deep-dive on a symbol — callers, callees, source | `--feature <name>`, `--json` |
27
+ | `survey [dir]` | Scan directory, suggest submodule groupings and edges | `--feature <name>`, `--json` |
28
+ | `list-apis [path]` | List public APIs in project or sub-path | `--all` (include internal symbols), `--json` |
29
+
30
+ ### Validation
31
+
32
+ | Subcommand | Description | Key Flags |
33
+ |------------|-------------|-----------|
34
+ | `verify --spec <dir>` | Verify a spec overlay against actual code | `--json` |
35
+
36
+ ## Common Workflows
37
+
38
+ - **Before atlas work**: `apltk codegraph init --index` (first time), then `apltk codegraph survey --json`
39
+ - **After code changes**: `apltk codegraph sync` to keep index current
40
+ - **Understanding a symbol**: `apltk codegraph explore <name>` to see callers and callees
41
+ - **Searching code**: `apltk codegraph search <query> --json --limit 30`
@@ -13,6 +13,8 @@ description: >-
13
13
 
14
14
  ## 驗收條件
15
15
 
16
+ - 使用 `apltk codegraph` 完成 repo 深度調查,產出模組邊界與 API 目錄分析
17
+ - 使用 subagents 閱讀關鍵程式碼片段,確保文檔記述可驗證
16
18
  - repo 的所有細節被仔細閱讀,並轉化為標準化的 `docs/features/`、`docs/architecture/`、`docs/principles/` 文檔
17
19
  - 每條文檔記述皆有可追溯的來源證據(檔案路徑 + 行號區間);無法證明的內容標記為 `[INFERRED]`
18
20
  - `AGENTS.md` / `CLAUDE.md` 已被同步更新
@@ -20,21 +22,36 @@ description: >-
20
22
 
21
23
  ## 工作流程
22
24
 
23
- ### 1. 建立對 repo 的基線認知
25
+ ### 1. 使用 CodeGraph 深入調查 Repo
24
26
 
25
- 閱讀項目現有文檔,建立對 repo 的基線認知,制定後續閱讀策略。
27
+ 在開始文檔工作前,先用 `apltk codegraph` 建立對 repo 的深度理解。
26
28
 
27
- ### 2. 比對 repo 及項目文檔
29
+ 1. 執行 `apltk codegraph survey --json` 取得專案的 entry points、function clusters、cross-boundary edges
30
+ 2. 使用 `apltk codegraph list-apis` 檢視完整 API 目錄(函式名稱、檔案路徑、呼叫者)
31
+ 3. 對關鍵模組使用 `apltk codegraph explore` 深入了解內部結構
32
+
33
+ 將調查結果記錄為結構化摘要,供後續文檔撰寫使用。
34
+
35
+ ### 2. 建立對 Repo 的基線認知
36
+
37
+ 閱讀項目現有文檔,並結合 CodeGraph 調查結果,建立對 repo 的基線認知,制定後續閱讀策略。
38
+
39
+ ### 3. 比對 Repo 及項目文檔
28
40
 
29
41
  按照上一步建立的閱讀策略,通過並行調度 subagents 全面搜索整個 repo,驗證並確保現有項目文檔的描述正確、無遺漏。
30
42
 
31
- ### 3. 制定文檔更新策略
43
+ 使用 subagents 深入閱讀關鍵程式碼片段:
44
+ - 每個 subagent 負責一個模組或檔案群組
45
+ - Subagent 閱讀原始碼後回報:模組職責、關鍵函式、資料流程、外部整合點
46
+ - 將 subagent 發現與現有文檔比對,標記差異
47
+
48
+ ### 4. 制定文檔更新策略
32
49
 
33
50
  根據上一步發現的文檔遺漏或脫節之處,制定文檔更新策略。
34
51
  閱讀模板文檔;使用模板規定的格式重寫所有項目文檔。
35
52
  移除舊有說明文檔(必要文檔如 `CHANGELOG.md`、`CONTRIBUTION.md` 除外)。
36
53
 
37
- ### 4. 後續維護指引
54
+ ### 5. 後續維護指引
38
55
 
39
56
  完成初始文檔後,在 `docs/README.md` 中記錄以下維護指引:
40
57
 
@@ -44,4 +61,4 @@ description: >-
44
61
  - **定期 drift detection**(建議):定期(每月或每季)比對文檔與實際程式碼,確認無重大偏離。發現 drift 時只修補受影響章節,不全面重寫。
45
62
 
46
63
  ## 參考資料
47
- - `assets/templates/standardized-docs-template.md` - 三類文檔的目標結構、分類規則與清理檢查表。
64
+ - `assets/templates/standardized-docs-template.md` - 三類文檔的目標結構、分類規則與清理檢查表。
@@ -59,7 +59,7 @@ Report to the user:
59
59
 
60
60
  ## Examples
61
61
 
62
- - FIX.md defines Batch 1 with 2 parallel fixes → Coordinator extracts FIX-01 and FIX-03 worker prompts from Section 6 → Dispatches 2 workers → Waits → Digests results → Runs gate verification → Proceeds to Batch 2
62
+ - FIX.md defines Batch 1 with 2 parallel fixes → Coordinator reads FIX-01 and FIX-03 worker prompts from `fix/` files listed in Section 6 (Worker Prompt Index) → Dispatches 2 workers → Waits → Digests results → Runs gate verification → Proceeds to Batch 2
63
63
  - Worker FIX-02 reports failure → Coordinator retries the worker with more specific guidance → Second attempt still fails → Pauses, preserves FIX-01's success, notifies the user
64
64
  - All batches complete → Regression tests pass → Commit → Cross-check REPORT.md → Report
65
65
 
@@ -56,7 +56,7 @@ Report to the user:
56
56
 
57
57
  ## Examples
58
58
 
59
- - PROMPT.md defines Batch 1 with 2 parallel tasks → Coordinator extracts T1.1 and T1.2 worker prompts from Section 6 → Dispatches 2 workers → Waits for both → Digests results → Runs gate verification → Proceeds to Batch 2
59
+ - PROMPT.md defines Batch 1 with 2 parallel tasks → Coordinator reads T1.1 and T1.2 worker prompts from `plan/` files listed in Section 6 (Worker Prompt Index) → Dispatches 2 workers → Waits for both → Digests results → Runs gate verification → Proceeds to Batch 2
60
60
  - Worker T2.1 reports failure → Coordinator retries the worker with more specific guidance → Second attempt still fails → Pauses, preserves T2.2's success, notifies the user
61
61
  - Merge conflict detected when combining worker results → Coordinator resolves the conflict markers → Re-runs batch gate verification → Proceeds
62
62
 
@@ -51,24 +51,20 @@ At load time, check the project state to select the correct mode:
51
51
 
52
52
  Applicable modes: design (full initialization), record (quick recording)
53
53
 
54
- ### 1. Survey the project with `apltk codegraph survey`
54
+ ### 1. Analyze the project with `apltk codegraph`
55
55
 
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
56
+ **Prerequisite** before any architecture work. The code graph provides the source-code evidence that powers the atlas.
59
57
 
60
- Then read `sample-demo/` to understand the expected output format and abstraction level.
58
+ 1. Initialize: `apltk codegraph init --index` (run once per project to build the symbol index).
59
+ 2. Survey: `apltk codegraph survey --json` for a structured report with file/function counts, entry points, and suggested submodule groupings.
61
60
 
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
67
-
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
61
+ Based on the survey, partition features (C4 Container level):
62
+ - Group interconnected function clusters into the same feature's submodules
70
63
  - Identify feature boundaries and cross-feature call relationships
71
- - Record the directory path and entry points for each feature
64
+
65
+ Then read `sample-demo/` to understand the expected output format and abstraction level before writing the atlas.
66
+
67
+ Consult `references/codegraph.md` for detailed flags.
72
68
 
73
69
  ### 2. Write the atlas with `apltk architecture apply`
74
70
 
@@ -107,7 +103,8 @@ If time or context constraints prevent full traceability, record the scanned sco
107
103
 
108
104
  ## References
109
105
 
110
- - `references/architecture.md` — Full parameter reference for the apltk architecture tool (consult when CLI flag details are needed).
106
+ - `references/codegraph.md` — `apltk codegraph` CLI reference (consult for subcommand flags).
107
+ - `references/architecture.md` — Full parameter reference for the `apltk architecture` tool (consult when CLI flag details are needed).
111
108
  - `references/TEMPLATE_SPEC.md` — Atlas field reference, enum values, and CLI shape cheat sheet.
112
109
  - `references/definition.md` — Detailed definitions of feature and submodule.
113
110
  - `assets/architecture-page.template.html` — HTML template.
@@ -0,0 +1,41 @@
1
+ # apltk codegraph — Code Intelligence CLI Reference
2
+
3
+ ## Purpose
4
+ Parse source code into a knowledge graph of symbols (functions, classes) and relationships (call edges), backed by a local SQLite database with FTS5 full-text search. Powered by @colbymchenry/codegraph (tree-sitter-backed code knowledge graph engine).
5
+
6
+ ## Usage
7
+ ```
8
+ apltk codegraph <subcommand> [options]
9
+ ```
10
+
11
+ ## Subcommands
12
+
13
+ ### Lifecycle
14
+
15
+ | Subcommand | Description | Key Flags |
16
+ |------------|-------------|-----------|
17
+ | `init` | Initialize CodeGraph for the project | `--index` (run initial indexing immediately), `--json` |
18
+ | `sync` | Sync index with current file state (incremental) | `--json` |
19
+ | `status` | Show index statistics (files, nodes, edges, languages) | `--json` |
20
+
21
+ ### Discovery
22
+
23
+ | Subcommand | Description | Key Flags |
24
+ |------------|-------------|-----------|
25
+ | `search <query>` | Search code graph for symbols via FTS5 | `--limit N` (default 20, max 100), `--json` |
26
+ | `explore <query>` | Deep-dive on a symbol — callers, callees, source | `--feature <name>`, `--json` |
27
+ | `survey [dir]` | Scan directory, suggest submodule groupings and edges | `--feature <name>`, `--json` |
28
+ | `list-apis [path]` | List public APIs in project or sub-path | `--all` (include internal symbols), `--json` |
29
+
30
+ ### Validation
31
+
32
+ | Subcommand | Description | Key Flags |
33
+ |------------|-------------|-----------|
34
+ | `verify --spec <dir>` | Verify a spec overlay against actual code | `--json` |
35
+
36
+ ## Common Workflows
37
+
38
+ - **Before atlas work**: `apltk codegraph init --index` (first time), then `apltk codegraph survey --json`
39
+ - **After code changes**: `apltk codegraph sync` to keep index current
40
+ - **Understanding a symbol**: `apltk codegraph explore <name>` to see callers and callees
41
+ - **Searching code**: `apltk codegraph search <query> --json --limit 30`
@@ -41,6 +41,16 @@ description: 基於 repo 最新程式碼與文檔,更新 CLAUDE.md 和 AGENTS.
41
41
 
42
42
  > 兩份檔案皆應維持在 100 行以內。若超過此限制,優先精煉而非擴充。
43
43
 
44
+ #### 加入 `apltk codegraph` 相關命令
45
+
46
+ 在兩份文檔的 `Common Development Commands` 區塊中,加入:
47
+
48
+ - `apltk codegraph <subcommand> [options]` — CodeGraph code intelligence CLI(init/sync/status/search/explore/survey/list-apis/verify)。由 tree-sitter 驅動的代碼知識圖譜引擎。
49
+
50
+ #### 加入代碼調查要求
51
+
52
+ 在兩份文檔中,明確要求 agent 在開始實作前,應先通過 `apltk codegraph` 進行代碼調查(如 `apltk codegraph survey`、`apltk codegraph explore`),確保變更基於對現有代碼的真實理解。此規則可放在 `Common Development Commands` 區塊的開頭作為前置條件說明,或放在 Prohibitions 區塊附近作為開發慣例。
53
+
44
54
  ## 參考資料
45
55
 
46
56
  - `references/constraint-file-reference.md`:三區塊契約、撰寫規則、AGENTS.md vs CLAUDE.md 區分指引、核對清單與輸出模板。
@@ -37,6 +37,8 @@ CLAUDE.md 可在這三個區塊之後額外加入 Claude Code 特有設定區塊
37
37
  - 只收錄能被當前倉庫驗證的命令。
38
38
  - 優先從 `package.json`、`Makefile`、`bin/`、`scripts/`、CI 設定或其他真實入口提取。
39
39
  - 每條命令附上一句簡短用途說明,避免捏造不存在的工作流。
40
+ - 若專案已安裝 `apltk codegraph`,必須在 Commands 區塊中包含該 CLI 的完整子命令列表(init/sync/status/search/explore/survey/list-apis/verify)。
41
+ - 在 Commands 區塊開頭或附近加入前置條件:要求 agent 在開始實作前,先通過 `apltk codegraph survey`(或 `explore`)進行代碼調查,確保變更基於對現有代碼的真實理解。
40
42
 
41
43
  ### `Project Business Goals`
42
44