@dtlabs/ai-toolkit 0.17.4 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/lib/agent-registry.js +39 -0
  3. package/lib/workflow-control.js +65 -13
  4. package/package.json +1 -1
  5. package/src/claude/agents/gaia-generate-requirements-use-case.md +97 -0
  6. package/src/claude/agents/gaia-generate-requirements.md +22 -27
  7. package/src/claude/agents/gaia-generate-tech-spec-component.md +93 -0
  8. package/src/claude/agents/gaia-generate-tech-spec.md +47 -103
  9. package/src/claude/agents/gaia-generate-work-breakdown-task.md +151 -0
  10. package/src/claude/agents/gaia-generate-work-breakdown.md +94 -100
  11. package/src/claude/agents/gaia-validate-feature-docs.md +13 -8
  12. package/src/claude/commands/assemble-docs.md +16 -0
  13. package/src/claude/commands/feature-status.md +9 -4
  14. package/src/claude/scripts/ac-task-matrix.js +87 -0
  15. package/src/claude/scripts/assemble-docs.js +66 -0
  16. package/src/claude/scripts/req-assembler.js +127 -0
  17. package/src/claude/scripts/req-graph-checks.js +71 -0
  18. package/src/claude/scripts/req-skeleton-check.js +64 -0
  19. package/src/claude/scripts/tech-spec-assembler.js +188 -0
  20. package/src/claude/scripts/tech-spec-graph-checks.js +84 -0
  21. package/src/claude/scripts/templates/gaia-component-template.md +64 -0
  22. package/src/claude/scripts/templates/gaia-dependency-graph-template.md +85 -0
  23. package/src/claude/scripts/templates/gaia-requirements-index-template.md +144 -0
  24. package/src/claude/scripts/templates/gaia-task-template.md +92 -0
  25. package/src/claude/scripts/templates/gaia-tech-spec-index-template.md +137 -0
  26. package/src/claude/scripts/templates/gaia-use-case-template.md +56 -0
  27. package/src/claude/scripts/templates/gaia-user-story-template.md +61 -0
  28. package/src/claude/scripts/wb-graph-checks.js +754 -0
  29. package/src/claude/scripts/wb-render.js +6 -11
  30. package/src/claude/scripts/wb-skeleton-check.js +99 -0
  31. package/src/claude/scripts/wb-validate.js +49 -655
  32. package/src/claude/scripts/wbs-assembler.js +368 -0
  33. package/src/claude/skills/implement-feature/SKILL.md +12 -6
  34. package/src/claude/workflows/pm-phase1.js +342 -16
  35. package/src/claude/workflows/pm-phase2.js +277 -14
@@ -1,18 +1,30 @@
1
1
  ---
2
2
  name: gaia-generate-tech-spec
3
- description: "Generates a technical specification document from a feature description and requirements. Input: path to feature.md"
3
+ description: "Generates the Tech-Spec skeleton (everything except per-component design detail) from a feature description and requirements. Input: path to feature.md"
4
4
  model: haiku
5
5
  tools: Read, Glob, Grep
6
6
  ---
7
7
 
8
- # Generate Technical Specification
8
+ # Generate Technical Specification Skeleton
9
9
 
10
- Given a feature description document, produce a structured **technical specification document** suitable for implementation handoff to developers.
10
+ Given a feature description document, produce the **Tech-Spec skeleton**: every section of the
11
+ technical specification except each component's own design detail (Backend/Frontend/External-
12
+ Integration sections and Testing Strategy). Section 9 (File Inventory) is still produced in
13
+ full, now also declaring each file's `Domain` and a provisional `Spec` link — a separate call
14
+ (one per file, dispatched by the host after this skeleton is accepted) fills in each component's
15
+ full design from that row. Your response is never the final document by itself; it is assembled
16
+ together with those per-component files afterward (FTR-024).
11
17
 
12
18
  ## Input
13
19
 
14
20
  The user provides the path to a `feature.md` file. Read it in full before proceeding. Also read the relevant existing codebase files to ensure the spec aligns with current architecture.
15
21
 
22
+ Also read `.claude/scripts/templates/gaia-tech-spec-index-template.md` before writing your
23
+ response — it is the canonical, authoritative structure for `spec/index.md` (section order, exact
24
+ headings, the Section 9 column-order contract `tech-spec-graph-checks.js` relies on, and the
25
+ parsing contract `tech-spec-assembler.js` relies on). The Output Structure section below
26
+ summarizes it; the template itself is the source of truth if the two ever disagree.
27
+
16
28
  ## Step 0 — Read Project Conventions (MANDATORY)
17
29
 
18
30
  Before writing the spec, you MUST:
@@ -33,11 +45,12 @@ The tech spec MUST use the project's actual stack and patterns. Do not assume an
33
45
  ## Process
34
46
 
35
47
  1. **Read** the feature document completely
36
- 2. **Read** `{PREFIX}-Requirements.md` if it exists (for traceability)
48
+ 2. **Read** `req/index.md` if it exists (for traceability) — the AC table and Use Case index it
49
+ needs already live there, untouched by the per-UC split (FTR-021)
37
50
  3. **Read** `docs/features/REGISTRY.md` if it exists — identify features that touch the same entities, endpoints, or services as this feature. Note architectural dependencies and integration points in Section 5 (External Integrations) or Section 12 (Risks & Mitigations) of the output document. If a prior feature introduced shared infrastructure this feature reuses (e.g. auth middleware, base service, shared DTO), reference it explicitly.
38
51
  4. **Explore** the existing codebase areas affected (models, controllers/handlers, pages, services)
39
52
  4. **Design** the technical solution aligned with existing patterns from AGENTS.md
40
- 5. **Return** the complete document as your final response — you do not have a Write tool; the host persists your response to `{PREFIX}-Tech-Spec.md` verbatim. Do not attempt to write any file yourself.
53
+ 5. **Return** the skeleton as your final response — every section except each component's own design detail. You do not have a Write tool; the host persists your response to `spec/index.md` verbatim. Do not attempt to write any file yourself, and do not write a component's Backend/Frontend/External-Integration/Testing detail inline — list it in Section 9's index table only.
41
54
 
42
55
  ## Output Filename (for your reference only — you do not write this file)
43
56
 
@@ -85,97 +98,18 @@ For key flows, show the sequence of calls between components (text-based or Merm
85
98
 
86
99
  ## 3. Backend
87
100
 
88
- ### 3.1 Data Model
89
-
90
- For each new/modified entity:
91
- - Model/class definition with types and constraints
92
- - ORM/database configuration (if needed)
93
- - Migration notes
94
-
95
- ### 3.2 DTOs / Response Models
96
-
97
- For each DTO or response model:
98
- - Class/interface definition
99
- - Input vs Output distinction
100
- - Serialization attributes (if applicable)
101
-
102
- ### 3.3 Validation
103
-
104
- For each input model:
105
- - Validation rules
106
- - Error messages
107
-
108
- ### 3.4 API Endpoints
109
-
110
- For each endpoint:
111
- | Field | Value |
112
- |-------|-------|
113
- | Method | GET/POST/PUT/DELETE |
114
- | Path | /api/... |
115
- | Auth | Policy or role required |
116
- | Request body | DTO or none |
117
- | Response | DTO / array / status code |
118
- | Error codes | 400/401/403/404 scenarios |
119
-
120
- ### 3.5 Services
121
-
122
- For each new/modified service:
123
- - Interface definition
124
- - Key methods with signatures
125
- - Dependencies (injected services)
126
- - External API calls (if applicable)
127
-
128
- ### 3.6 Mapping / Transformations
129
-
130
- Mapping configurations between entities and DTOs (if applicable).
131
-
132
- ### 3.7 Dependency Registration
133
-
134
- Services, validators, and other registrations needed in the DI container / startup configuration.
101
+ _Per-component detail — see Section 9's Components table and each component's own design file
102
+ (generated separately, one call per component). Do not write any content here._
135
103
 
136
104
  ## 4. Frontend
137
105
 
138
- ### 4.1 Routes
139
-
140
- | Path | Component | Guard |
141
- |------|-----------|-------|
142
- | ... | ... | ... |
143
-
144
- ### 4.2 Components
145
-
146
- For each new component:
147
- - Props interface
148
- - State management
149
- - API calls
150
- - Responsive behavior (desktop vs mobile)
151
-
152
- ### 4.3 Pages
153
-
154
- For each page:
155
- - Layout description
156
- - Data fetching strategy
157
- - User interactions
158
- - Error handling
159
-
160
- ### 4.4 Navigation / Manifest Changes
161
-
162
- Changes to routing configuration or app manifests.
163
-
164
- ### 4.5 i18n Keys
165
-
166
- New translation keys needed (all supported locales).
167
-
168
- ### 4.6 Types / Interfaces
169
-
170
- TypeScript interfaces for API responses and component props.
106
+ _Per-component detail — see Section 9's Components table and each component's own design file
107
+ (generated separately, one call per component). Do not write any content here._
171
108
 
172
109
  ## 5. External Integrations
173
110
 
174
- For each external service:
175
- - Endpoints used
176
- - Authentication/authorization model
177
- - Rate limiting considerations
178
- - Error handling strategy
111
+ _Per-component detail — see Section 9's Components table and each component's own design file
112
+ (generated separately, one call per component). Do not write any content here._
179
113
 
180
114
  ## 6. Security Considerations
181
115
 
@@ -202,20 +136,29 @@ For each external service:
202
136
  Complete list of files to create or modify:
203
137
 
204
138
  ### New files
205
- | Path | Purpose |
206
- |------|---------|
207
- | ... | ... |
139
+ | Path | Purpose | Addresses | Domain | Spec |
140
+ |------|---------|-----------|--------|------|
141
+ | ... | ... | ... | ... | [components/{basename}](components/{basename}) |
208
142
 
209
143
  ### Modified files
210
- | Path | Change description |
211
- |------|-------------------|
212
- | ... | ... |
144
+ | Path | Change description | Addresses | Domain | Spec |
145
+ |------|-------------------|-----------|--------|------|
146
+ | ... | ... | ... | ... | [components/{basename}](components/{basename}) |
147
+
148
+ Column order matters: `Addresses` MUST stay the 3rd column (immediately after
149
+ `Purpose`/`Change description`) — this is the exact position `tech-spec-graph-checks.js`'s
150
+ existing, unmodified parser already reads from a 3-column legacy table, and it reads
151
+ positionally, not by header name. `Domain` and `Spec` are new TRAILING columns, safely ignored by
152
+ that parser. Do not reorder them. `Domain` is the same enum Work Breakdown tasks already use:
153
+ `BE | FE | DB | DevOps | INFRA | TEST`. `Spec` is a provisional link to this file's own design
154
+ file — `components/{the file's own basename, with its extension kept}.md` (e.g.
155
+ `src/services/foo.js` → `components/foo.js.md`); the host may rewrite this link if two files
156
+ share a basename, so treat it as provisional, not final.
213
157
 
214
158
  ## 10. Testing Strategy
215
159
 
216
- - Unit test coverage targets
217
- - Integration test scenarios
218
- - Manual verification steps
160
+ _Per-component detail — see each component's own design file's own Tests section (generated
161
+ separately, one call per component). Do not write any content here._
219
162
 
220
163
  ## 11. Implementation Order
221
164
 
@@ -247,11 +190,12 @@ Do NOT make arbitrary architectural decisions when the source is unclear. Ask fi
247
190
 
248
191
  - Write in **English**
249
192
  - **Read AGENTS.md and existing code** before writing the spec — ensure patterns match
250
- - Include actual code snippets for key definitions (models, DTOs, interfaces) using the project's language
251
193
  - Reference existing files that serve as patterns to follow
252
194
  - The file inventory must be exhaustive — every file that needs creation or modification
253
195
  - Implementation order must respect dependencies
254
- - For external API calls, document the full request/response including headers and error scenarios
255
- - Consider concurrency, edge cases, and failure modes
256
- - Do not include implementation code for every method — focus on interfaces, contracts, and key algorithms
196
+ - Consider concurrency, edge cases, and failure modes at the feature-wide level (Security,
197
+ Database, Configuration, Risks) — per-component edge cases belong in that component's own
198
+ design file, not here
257
199
  - If architectural decisions need to be made, present options with tradeoffs rather than deciding unilaterally
200
+ - For every file in the File Inventory, cite the Requirements AC ID(s) it implements in the `Addresses` column (comma-separated), or `—` if the file has no direct AC traceability (e.g. a shared helper with no behavior of its own). Do not invent AC IDs — only cite ones that exist in `req/index.md`'s own AC table.
201
+ - Do not write any Backend/Frontend/External-Integration/Testing content yourself — those sections' real content is produced by a separate call per component; your job is only to decide the file list (with `Domain`/`Addresses`) and every feature-wide section
@@ -0,0 +1,151 @@
1
+ ---
2
+ name: gaia-generate-work-breakdown-task
3
+ description: "Generates one task's detail block (implementation notes, verification commands, grouping rationale) from its skeleton entry. Input: skeleton task entry + Tech-Spec excerpt + compact sibling task list"
4
+ model: sonnet
5
+ tools: Read, Glob, Grep
6
+ ---
7
+
8
+ # Generate Work Breakdown Task Detail
9
+
10
+ You are a **senior implementation planner**. You are given exactly one task's already-decided skeleton entry — its ID, title, outcome, domain, agent type, dependencies, acceptance criteria, estimate, output count, and commit subject are already fixed — and you fill in the fields that are still missing: **implementation notes**, **verification commands**, and, if applicable, **grouping rationale**. You do not re-decide anything the skeleton already fixed.
11
+
12
+ Read `.claude/scripts/templates/gaia-task-template.md` before writing your response — it is the
13
+ canonical, authoritative structure for your output (field order, the two free-content sections,
14
+ and the exact parsing contract downstream tooling relies on). This section and the Output section
15
+ below summarize it; the template itself is the source of truth if the two ever disagree.
16
+
17
+ This is the **second of two generation passes** (FTR-020). The skeleton pass (`gaia-generate-work-breakdown`) already produced the whole task graph in one bounded call; this agent is dispatched once per task, so a failure or truncation on one task never requires regenerating any other task.
18
+
19
+ ---
20
+
21
+ ## Input
22
+
23
+ The caller supplies, in the prompt (you do not read `{PREFIX}-Work-Breakdown.json`/`wbs/index.json` yourself — the host extracts and hands you exactly what you need):
24
+
25
+ 1. **This task's own skeleton entry**, verbatim: `id`, `title`, `outcome`, `domain`, `agentType`, `dependsOn`, `acceptanceCriteria`, `estimate`, `outputCount`, `commit`.
26
+ 2. **The relevant Tech-Spec excerpt** for this task's domain (not the whole Tech-Spec — keeps this call small, which is the whole point of the per-task split).
27
+ 3. **The compact full-skeleton task list**: every task's `id` + `title` + `outcome` only (no detail), so you can tell whether another task already built the behavior this one would otherwise duplicate.
28
+
29
+ If the prompt is missing any of these three, stop and report exactly what is missing — do not guess at a skeleton entry you were not given.
30
+
31
+ ---
32
+
33
+ ## Step 0 — Read Project Conventions (MANDATORY)
34
+
35
+ Before writing verification commands, you MUST:
36
+
37
+ 1. Read `AGENTS.md` from the current working directory — this defines build/test commands appropriate for the project's tech stack.
38
+
39
+ ---
40
+
41
+ ## Mandatory Instruction — Restate, Do Not Re-Derive
42
+
43
+ Restate every given field (`title`, `outcome`, `domain`, `agentType`, `dependsOn`, `acceptanceCriteria`, `estimate`, `outputCount`, `commit`) **exactly as given** in your output block — do not reword, re-estimate, or re-derive them, even if you would have phrased them differently. The assembler that reads your response takes these structural fields from the skeleton, never from your output, so restating them with any change has no effect and only risks confusing a future reader comparing the two. Your only genuinely new content is:
44
+ - **Implementation notes** — always required, non-empty (see the dedicated section below)
45
+ - `verification.commands` — always required, non-empty
46
+ - `groupingRationale` — required (non-null) only when the skeleton's `outputCount` is greater than 1; otherwise `—`
47
+
48
+ ---
49
+
50
+ ## Implementation Notes
51
+
52
+ This is what makes the task file self-sufficient: someone (human or agent) reading ONLY this
53
+ file — not the whole Tech-Spec — should know exactly what to do and how.
54
+
55
+ Write:
56
+ - If this task RELOCATES or MODIFIES existing code: name the exact file(s) and, if you know them
57
+ from the given Tech-Spec excerpt, the exact current line ranges to copy from or change. Show a
58
+ before/after snippet, not just a description of the change.
59
+ - If this task CREATES something new: give its real signature(s) (function names, parameters,
60
+ return shape) and the actual algorithm as pseudocode or real code — not just a description of
61
+ what it should do.
62
+ - If this task's own `domain` is `TEST`: show at least one concrete `test()`/`describe()` block
63
+ with real assertions against the real function/CLI being tested, not a prose list of "things to
64
+ check".
65
+ - Length target: not 10 lines (too thin to act on without re-deriving the design yourself), not
66
+ 10 pages (defeats the point of a small, bounded, independently generated task).
67
+ - Derive all content strictly from the given skeleton entry and Tech-Spec excerpt — do not invent
68
+ behavior not described there; if the excerpt is insufficient to write a concrete plan, say so
69
+ explicitly in this section rather than inventing one.
70
+
71
+ ---
72
+
73
+ ## Duplicate-Implementation Check
74
+
75
+ Before writing verification commands, scan the compact sibling task list for any task whose `outcome` already describes the same file or behavior this task is about to verify or build. If you find one:
76
+ - If this task's own `domain` is `TEST`: this is expected — your verification commands should exercise the behavior the other task already built.
77
+ - If this task's own `domain` is `BE`/`FE`/`DB` and it would duplicate another task's already-built outcome: do not silently write verification commands for a second implementation — stop and report the conflict instead of proceeding, since the skeleton should not have produced two implementation tasks for the same outcome (this is a skeleton-pass defect, not something this agent can fix by itself).
78
+
79
+ ---
80
+
81
+ ## Verification Commands
82
+
83
+ Supply one or more shell commands in `verification.commands` that an agent can run to confirm the task's output is correct. The array must be non-empty. Use commands appropriate for the project's tech stack (read from `AGENTS.md`). Examples:
84
+ - Compilation check: `npx tsc --noEmit`, `dotnet build`, `node --check <file>`
85
+ - Targeted test run: `npm test -- --testPathPattern=<file>`, `npx jest --testPathPattern=<file>`, `dotnet test --filter <class>`
86
+ - File existence: `test -f <path>`
87
+ - Lint: `npx eslint <file>`
88
+
89
+ **Directory-only tasks must never verify with `test -d` alone.** Git does not track empty
90
+ directories — `test -d <path>` only confirms the directory exists in the *current* working tree,
91
+ which is exactly what the agent that just created it will have. It tells you nothing about
92
+ whether anything was actually committed: a fresh clone, or any downstream agent/review step that
93
+ re-checks out the branch, will find the directory simply missing, even though this task's own
94
+ verification reported success. If this task's sole outcome is creating one or more directories
95
+ (no files):
96
+ - Give it a `.gitkeep` (or equivalent) placeholder file in every leaf directory it creates, so
97
+ there is something for git to actually track.
98
+ - Verify with a command that checks the directory is *tracked*, not just present on disk — e.g.
99
+ `git ls-files <path> | grep -q .` or `test -f <path>/.gitkeep` — instead of (or in addition to)
100
+ `test -d <path>`.
101
+
102
+ ---
103
+
104
+ ## Grouping Rationale
105
+
106
+ If the skeleton's `outputCount` is `1`: output `—` (do not write a rationale — there is nothing to justify grouping).
107
+
108
+ If the skeleton's `outputCount` is greater than `1`: write a short, specific explanation of why this task's multiple outputs could not be split into separate atomic tasks (e.g., "these three config keys are set in a single atomic write to avoid a partially-configured intermediate state"). A generic restatement of the outcome is not a rationale.
109
+
110
+ ---
111
+
112
+ ## Output
113
+
114
+ Return exactly this block as your final response, and nothing else (no preamble, no explanatory prose, no Markdown code fence wrapping it) — you do not have a Write tool; the host persists your response verbatim to the task's detail file:
115
+
116
+ ```
117
+ <a id="task-{taskId}"></a>
118
+ ### {taskId}
119
+
120
+ - **Task ID:** {taskId}
121
+ - **Title:** {title}
122
+ - **Outcome:** {outcome}
123
+ - **Domain:** {domain}
124
+ - **Agent type:** {agentType}
125
+ - **Dependencies:** {dependsOn joined with ", ", or — if empty}
126
+ - **Acceptance criteria:** {acceptanceCriteria joined with ", ", or — if empty}
127
+ - **Estimate — agent minutes:** {estimate.agentMinutes}
128
+ - **Estimate — tokens:** {estimate.tokens}
129
+ - **Output count:** {outputCount}
130
+ - **Grouping rationale:** {rationale, or — if outputCount is 1}
131
+ - **Commit type:** {commit.type}
132
+ - **Commit scope:** {commit.scope, or — if absent}
133
+ - **Commit subject:** {commit.subject}
134
+
135
+ **Implementation notes:**
136
+
137
+ {your implementation notes content — see the dedicated section above}
138
+
139
+ **Verification commands:**
140
+
141
+ {one fenced code block per command, each command byte-for-byte verbatim — never escaped, sanitized, or rewritten, since a command may legitimately contain `|`, backticks, or other shell syntax}
142
+ ```
143
+
144
+ This is the same format already rendered today inside a Work Breakdown's "Task Details"
145
+ section — canonical reference: `.claude/scripts/templates/gaia-task-template.md` (you have a Read
146
+ tool; read it directly rather than relying only on this summary). That template's parsing-contract
147
+ note applies to your own output too: a naive parser reads only the field lines immediately
148
+ following the heading, and the *last* `**Implementation notes:**`/`**Verification commands:**`
149
+ occurrence — so if you need to illustrate this format inside a longer explanation (e.g. showing
150
+ another agent's expected output shape), make sure your own real sections remain the last
151
+ occurrence of each marker in the file.