@dtlabs/ai-toolkit 0.4.0 → 0.6.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.
|
@@ -6,7 +6,75 @@ model: sonnet
|
|
|
6
6
|
|
|
7
7
|
# Define Feature
|
|
8
8
|
|
|
9
|
-
Helps the user define a new feature by asking
|
|
9
|
+
Helps the user define a new feature by first **reading everything the repository already knows**, then asking only the questions whose answers are genuinely missing — and finally synthesizing the result into a `feature.md` file ready for the `/implement-feature` pipeline.
|
|
10
|
+
|
|
11
|
+
**Core principle: never ask what the repo can already answer.** Every question you ask must be one you could not resolve by reading `AGENTS.md`, an existing backlog/ticket, the existing feature docs, or the code itself. Redundant questions are a defect.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Input
|
|
16
|
+
|
|
17
|
+
The user MAY provide a **source reference** as an argument — treat it as authoritative input, not as a starting point to re-derive from scratch:
|
|
18
|
+
|
|
19
|
+
- A path to a backlog entry or section (e.g. `docs/token-optimization-backlog.md → OPT-09`)
|
|
20
|
+
- A path to a ticket, spec, or design note
|
|
21
|
+
- A free-text description of the feature
|
|
22
|
+
- Nothing at all (fully interactive definition)
|
|
23
|
+
|
|
24
|
+
If a source reference is given, your job is to **ingest it, pre-fill the feature draft, and grill only on the real gaps** — not to ask the user to restate what the source already says.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Phase 0 — Context Ingestion (MANDATORY — before any question)
|
|
29
|
+
|
|
30
|
+
Do NOT ask the user anything until you have read the available context. Silently gather, then build a pre-filled draft.
|
|
31
|
+
|
|
32
|
+
### 0a. Read project conventions
|
|
33
|
+
|
|
34
|
+
- Read `AGENTS.md` from the project root if it exists (tech stack, directory structure, patterns, constraints). This answers most stack/structure/permission questions without asking.
|
|
35
|
+
- If `AGENTS.md` is absent, note it — you will infer conventions from the code and may confirm the stack in one consolidated question.
|
|
36
|
+
|
|
37
|
+
### 0b. Ingest the source reference (if provided)
|
|
38
|
+
|
|
39
|
+
- Read the referenced file/section fully. Extract every field it already provides: objective, scope, out-of-scope, affected files, acceptance criteria, dependencies, effort/risk.
|
|
40
|
+
- Follow obvious pointers (e.g. a backlog entry that says "deriva da `docs/token-optimization.md`" → read that too).
|
|
41
|
+
|
|
42
|
+
### 0c. Study existing features and code
|
|
43
|
+
|
|
44
|
+
- List `docs/features/` and `internal_docs/features/` (whichever exists) to learn the house style of prior `feature.md` files and to detect overlap/dependencies with existing work.
|
|
45
|
+
- Read the code the feature will touch (files named in the source, or found via Grep/Glob) enough to understand the current behavior being changed.
|
|
46
|
+
|
|
47
|
+
### 0d. Classify the feature type — this drives which questions are asked
|
|
48
|
+
|
|
49
|
+
Decide the primary type from the evidence gathered:
|
|
50
|
+
|
|
51
|
+
| Type | Signals | Rounds that DON'T apply |
|
|
52
|
+
|------|---------|-------------------------|
|
|
53
|
+
| **business/UI** | end-user pages, forms, actors, CRUD on domain entities | (all rounds apply) |
|
|
54
|
+
| **internal/technical** | refactor, tooling, script, workflow, agent, build/infra, optimization | Actors, Core-flow-as-page, Data model, Roles/permissions |
|
|
55
|
+
| **library/API** | public functions/endpoints, no UI, consumed by other code | Core-flow-as-page, Roles/permissions (unless auth is the point) |
|
|
56
|
+
|
|
57
|
+
Record the type. In Phase 2 you will **skip inapplicable rounds entirely** and mark their template sections `N/A — <type> feature`.
|
|
58
|
+
|
|
59
|
+
### 0e. Build and present the pre-filled draft
|
|
60
|
+
|
|
61
|
+
Assemble a draft of the feature fields from 0a–0c and show it to the user **before grilling**:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
📋 Pre-filled from: <source reference or "no source — interactive">
|
|
65
|
+
Feature type: <business/UI | internal/technical | library/API>
|
|
66
|
+
──────────────────────────────────────────────────
|
|
67
|
+
Objective : <from source, or "❓ unknown">
|
|
68
|
+
Scope : <from source, or "❓ unknown">
|
|
69
|
+
Out of scope : <from source, or "❓ unknown">
|
|
70
|
+
Files affected : <from source/code, or "❓ unknown">
|
|
71
|
+
Acceptance : <from source, or "❓ unknown">
|
|
72
|
+
Dependencies : <from source, or "❓ unknown">
|
|
73
|
+
──────────────────────────────────────────────────
|
|
74
|
+
Gaps I still need to resolve: <list only the ❓ items + genuine ambiguities>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Ask the user to **confirm or correct the draft**. Then grill ONLY on the `❓` gaps and ambiguities — skip every field already answered by the source.
|
|
10
78
|
|
|
11
79
|
---
|
|
12
80
|
|
|
@@ -30,11 +98,16 @@ Example: "Supplier Onboarding" → `FTR-003-supplier-onboarding`
|
|
|
30
98
|
|
|
31
99
|
---
|
|
32
100
|
|
|
33
|
-
## Phase 2 — Grilling
|
|
101
|
+
## Phase 2 — Grilling (only the gaps)
|
|
102
|
+
|
|
103
|
+
**Objective**: resolve the `❓` gaps and ambiguities identified in Phase 0 — nothing already answered.
|
|
34
104
|
|
|
35
|
-
**
|
|
105
|
+
**Hard rules before asking any question:**
|
|
106
|
+
1. **Never ask what Phase 0 already answered.** If the source, `AGENTS.md`, existing features, or the code already provides a field, do NOT ask about it — at most ask a single confirmation if genuinely ambiguous.
|
|
107
|
+
2. **Skip rounds that don't apply to the feature type** (from Phase 0d). For an internal/technical feature, skip Actors, page-based Core Flow, Data model, and Roles/permissions entirely and mark those template sections `N/A — technical feature`.
|
|
108
|
+
3. **One dimension at a time** — use `AskUserQuestion` per round; adapt follow-ups to prior answers.
|
|
36
109
|
|
|
37
|
-
|
|
110
|
+
Below are the possible rounds. Run a round **only if** it applies to the feature type AND it contains at least one unresolved gap. If a round has no open gap, skip it silently.
|
|
38
111
|
|
|
39
112
|
### Round 1 — The problem
|
|
40
113
|
|
|
@@ -49,15 +122,21 @@ Follow-up if vague:
|
|
|
49
122
|
|
|
50
123
|
### Round 2 — The core flow
|
|
51
124
|
|
|
52
|
-
|
|
125
|
+
**Applies to:** all types — but phrase it to the type.
|
|
126
|
+
- business/UI: *"Walk me through the main scenario step by step — from the moment the user opens the page to the moment they're done."*
|
|
127
|
+
- internal/technical or library/API: *"Walk me through the main execution path — what triggers it, what it does step by step, and what the end state is."* (There is no page; do not ask page questions.)
|
|
53
128
|
|
|
54
|
-
Goal: extract the happy path in concrete
|
|
129
|
+
Goal: extract the happy path in concrete steps.
|
|
55
130
|
|
|
56
|
-
Follow-up:
|
|
131
|
+
Follow-up (business/UI):
|
|
57
132
|
- "What does the user see first?"
|
|
58
133
|
- "What data do they need to input or select?"
|
|
59
134
|
- "What happens after they submit/save?"
|
|
60
|
-
|
|
135
|
+
|
|
136
|
+
Follow-up (technical/API):
|
|
137
|
+
- "What is the entry point (function, script, command, event)?"
|
|
138
|
+
- "What are the inputs and where do they come from?"
|
|
139
|
+
- "What is the observable output or side effect when it completes?"
|
|
61
140
|
|
|
62
141
|
### Round 3 — Boundaries
|
|
63
142
|
|
|
@@ -81,6 +160,8 @@ Follow-up:
|
|
|
81
160
|
|
|
82
161
|
### Round 5 — Data and entities
|
|
83
162
|
|
|
163
|
+
**Applies to:** business/UI and library/API features that manage domain data. **Skip for internal/technical/refactor/tooling features that create no domain entities** — mark the Data Model section `N/A — technical feature`.
|
|
164
|
+
|
|
84
165
|
> "What data does this feature create, read, update, or delete?"
|
|
85
166
|
|
|
86
167
|
Follow-up:
|
|
@@ -90,6 +171,8 @@ Follow-up:
|
|
|
90
171
|
|
|
91
172
|
### Round 6 — Roles and permissions
|
|
92
173
|
|
|
174
|
+
**Applies to:** business/UI features (and API features where authorization is in scope). **Skip for internal/technical features with no end-user roles** — mark the Roles and Permissions section `N/A — technical feature`.
|
|
175
|
+
|
|
93
176
|
> "Who can do what? Are there different permission levels within this feature?"
|
|
94
177
|
|
|
95
178
|
Follow-up:
|
|
@@ -226,9 +309,10 @@ For each entity: name, key fields (name, type, constraints), relationships.
|
|
|
226
309
|
### Writing rules
|
|
227
310
|
|
|
228
311
|
- Write in **English** (regardless of the language used during grilling)
|
|
229
|
-
- Derive content **
|
|
312
|
+
- Derive content from **the source reference (Phase 0) plus the user's answers** — do not invent requirements
|
|
313
|
+
- For sections that don't apply to the feature type, write `N/A — <type> feature` instead of leaving them blank or inventing content (e.g. Actors / Data Model / Roles for an internal/technical feature)
|
|
230
314
|
- Mark open questions explicitly rather than guessing
|
|
231
|
-
- Acceptance criteria must be **testable** (Given/When/Then)
|
|
315
|
+
- Acceptance criteria must be **testable** (Given/When/Then) — for technical features, express them as observable/verifiable checks (e.g. "grep returns nothing", "build passes", "output file exists")
|
|
232
316
|
- Be concrete and specific — avoid vague statements like "the system should be fast"
|
|
233
317
|
|
|
234
318
|
---
|
|
@@ -258,9 +342,12 @@ Next step: run /implement-feature docs/features/{PREFIX}-{slug}/feature.md
|
|
|
258
342
|
|
|
259
343
|
## Guidelines
|
|
260
344
|
|
|
261
|
-
- **
|
|
262
|
-
- **
|
|
263
|
-
- **
|
|
264
|
-
- **
|
|
265
|
-
- **
|
|
266
|
-
- **
|
|
345
|
+
- **Read before you ask** — Phase 0 is mandatory; never ask what `AGENTS.md`, the source reference, existing feature docs, or the code already answers. A redundant question is a defect.
|
|
346
|
+
- **Match questions to the feature type** — skip Actors / Data model / Roles / page-flow rounds for internal/technical features; do not force business-feature questions onto a refactor or tooling task.
|
|
347
|
+
- **Confirm the draft, then grill the gaps** — present the pre-filled draft first; only unresolved `❓` items and genuine ambiguities become questions.
|
|
348
|
+
- **Grill relentlessly on real gaps** — vague answers to open questions get follow-ups, not acceptance.
|
|
349
|
+
- **One dimension at a time** — do not overwhelm the user with all questions at once.
|
|
350
|
+
- **Challenge contradictions** — if answers conflict with each other or with the source, surface it before writing.
|
|
351
|
+
- **Do not invent** — if something is unclear and the user can't answer, record it as an open question.
|
|
352
|
+
- **Create the folder** if it doesn't exist — do not ask the user to do it manually.
|
|
353
|
+
- **Always write in English** — feature.md is input to English-language downstream agents.
|
|
@@ -121,9 +121,11 @@ For each document with gaps, invoke the corresponding agent with a **targeted re
|
|
|
121
121
|
|
|
122
122
|
---
|
|
123
123
|
|
|
124
|
-
## Phase 6 — Write Validation Report
|
|
124
|
+
## Phase 6 — Write Validation Report (MANDATORY — your final action)
|
|
125
125
|
|
|
126
|
-
**
|
|
126
|
+
**This is not optional and not the same as the Phase 4 gap report.** The coverage report you produced in Phase 4 is on-screen text; it is NOT the deliverable. Your job is not complete until the file `{PREFIX}-Validation-Report.md` exists **on disk**. You MUST call the `Write` tool to create it — even when validation is clean and zero gaps were found. Returning a summary without having called `Write` is a failure.
|
|
127
|
+
|
|
128
|
+
Execute this phase **last, always**, regardless of outcome. Downstream agents read this file as a hard precondition; if it is missing, the entire pipeline aborts.
|
|
127
129
|
|
|
128
130
|
Write `{PREFIX}-Validation-Report.md` in the same directory:
|
|
129
131
|
|
|
@@ -166,6 +168,7 @@ Do NOT guess how to fill ambiguous gaps. Ask first, then revise only with a clea
|
|
|
166
168
|
|
|
167
169
|
## Guidelines
|
|
168
170
|
|
|
171
|
+
- **Always call `Write` for the Validation Report before finishing** (Phase 6) — the on-screen gap report is not the deliverable; the file on disk is. This is your last action, clean or not.
|
|
169
172
|
- **Do not regenerate documents from scratch** — targeted revisions only
|
|
170
173
|
- **Be specific about gaps** — point to the exact section, claim, and what is missing
|
|
171
174
|
- **Stop after 3 revision cycles** — if coverage is still incomplete, report remaining gaps and exit
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "Define Feature —
|
|
2
|
+
description: "Define Feature — reads existing repo context, then grills only on the real gaps and writes feature.md in docs/features/FTR-XXX-slug/. Usage: /define-feature [source reference]"
|
|
3
3
|
disable-model-invocation: true
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
Spawn the `define-feature` agent
|
|
6
|
+
Spawn the `define-feature` agent, passing through whatever the user provided as a source reference (a backlog entry, ticket path, spec path, or free-text description). If the user gave nothing, pass an empty source.
|
|
7
7
|
|
|
8
8
|
```
|
|
9
9
|
subagent_type: define-feature
|
|
10
|
-
prompt:
|
|
10
|
+
prompt: |
|
|
11
|
+
Start the feature definition session.
|
|
12
|
+
Source reference (may be empty): {{user arguments verbatim}}
|
|
11
13
|
```
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
The agent runs Phase 0 (context ingestion) first — it reads AGENTS.md, the source reference, existing feature docs, and the relevant code, then pre-fills a draft and grills ONLY on the genuine gaps. Do not add instructions telling it to skip discovery.
|
|
@@ -103,6 +103,7 @@ if (discoveryResult.needs_tech_spec) {
|
|
|
103
103
|
phase('Validation')
|
|
104
104
|
|
|
105
105
|
let validationSummary = 'skipped'
|
|
106
|
+
let lastValText = ''
|
|
106
107
|
const MAX_CYCLES = 3
|
|
107
108
|
|
|
108
109
|
for (let cycle = 1; cycle <= MAX_CYCLES; cycle++) {
|
|
@@ -115,6 +116,7 @@ for (let cycle = 1; cycle <= MAX_CYCLES; cycle++) {
|
|
|
115
116
|
// valResult is the agent's text output — check for gap indicators
|
|
116
117
|
// Use only 'MISSING:' as the gap signal: 'gaps found' also matches 'ZERO GAPS FOUND'
|
|
117
118
|
const resultText = typeof valResult === 'string' ? valResult : JSON.stringify(valResult)
|
|
119
|
+
lastValText = resultText
|
|
118
120
|
const hasGaps = resultText.includes('MISSING:')
|
|
119
121
|
|
|
120
122
|
if (!hasGaps) {
|
|
@@ -139,6 +141,56 @@ for (let cycle = 1; cycle <= MAX_CYCLES; cycle++) {
|
|
|
139
141
|
}
|
|
140
142
|
}
|
|
141
143
|
|
|
144
|
+
// ── Guarantee the Validation Report exists on disk ───────────────────────────
|
|
145
|
+
// The validate-feature-docs agent (haiku) is instructed to write the report in its
|
|
146
|
+
// Phase 6, but this is LLM-dependent and unreliable when validation is clean. Downstream
|
|
147
|
+
// pm-phase2 (generate-work-breakdown) treats the report as a hard precondition, so its
|
|
148
|
+
// absence aborts the whole pipeline. This step deterministically ensures the file exists.
|
|
149
|
+
if (validationSummary !== 'skipped') {
|
|
150
|
+
const validationReportPath = `${feature_dir}/${prefix}-Validation-Report.md`
|
|
151
|
+
await agent(
|
|
152
|
+
`Ensure the Validation Report file exists on disk for this feature delivery run.
|
|
153
|
+
|
|
154
|
+
File path: ${validationReportPath}
|
|
155
|
+
|
|
156
|
+
Steps:
|
|
157
|
+
1. Check whether the file already exists (use Read or Glob).
|
|
158
|
+
2. If it ALREADY EXISTS: do nothing, return "exists".
|
|
159
|
+
3. If it DOES NOT EXIST: write it now using the Write tool, based on the validation outcome below.
|
|
160
|
+
Get the current date via Bash: run \`date -u +"%Y-%m-%d"\`.
|
|
161
|
+
|
|
162
|
+
Validation outcome summary: ${validationSummary}
|
|
163
|
+
|
|
164
|
+
Validation agent output (source of truth for gaps found/resolved):
|
|
165
|
+
──────────────────────────────────────────────────
|
|
166
|
+
${lastValText.slice(0, 4000)}
|
|
167
|
+
──────────────────────────────────────────────────
|
|
168
|
+
|
|
169
|
+
File format to write (fill from the outcome above; if the run was clean, mark both documents Clean with 0 gaps):
|
|
170
|
+
|
|
171
|
+
# Validation Report — ${prefix}
|
|
172
|
+
|
|
173
|
+
## Summary
|
|
174
|
+
| Document | Gaps found | Gaps resolved | Status |
|
|
175
|
+
|----------|-----------|--------------|--------|
|
|
176
|
+
| ${prefix}-Requirements.md | N | N | Clean / Gaps remain |
|
|
177
|
+
| ${prefix}-Tech-Spec.md | N | N | Clean / Gaps remain |
|
|
178
|
+
|
|
179
|
+
## Gaps found and resolved
|
|
180
|
+
(derive from the validation output above; write "(none)" if clean)
|
|
181
|
+
|
|
182
|
+
## Remaining gaps (if any)
|
|
183
|
+
(list any unresolved gaps, or "(none)")
|
|
184
|
+
|
|
185
|
+
## Validation date
|
|
186
|
+
{date from Bash}
|
|
187
|
+
|
|
188
|
+
Return "written" if you created the file, or "exists" if it was already present.`,
|
|
189
|
+
{ label: 'ensure-validation-report', phase: 'Validation' }
|
|
190
|
+
)
|
|
191
|
+
log(`Validation report ensured at ${validationReportPath}`)
|
|
192
|
+
}
|
|
193
|
+
|
|
142
194
|
// ── Write process-log (phase 1 snapshot) ─────────────────────────────────────
|
|
143
195
|
const reqEntry = tokenLedger.find(e => e.agent === 'generate-requirements')
|
|
144
196
|
const specEntry = tokenLedger.find(e => e.agent === 'generate-tech-spec')
|
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
## 0.1.4 (2026-07-21)
|
|
2
|
+
## [0.6.0](https://github.com/dtlab-tech/ai-toolkit/compare/v0.5.0...v0.6.0) (2026-07-29)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* **define-feature:** context ingestion + adaptive grilling; add AGENTS.md ([581b783](https://github.com/dtlab-tech/ai-toolkit/commit/581b783a18626796ae764ce69f658556b83ab490))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* **pipeline:** persist Validation Report + smarter define-feature + AGENTS.md ([a5bae6a](https://github.com/dtlab-tech/ai-toolkit/commit/a5bae6aab65ca78aa5daa08a4a731b7c16051754))
|
|
13
|
+
* **pm-phase1:** guarantee Validation Report is persisted to disk ([53e10c0](https://github.com/dtlab-tech/ai-toolkit/commit/53e10c0e8f20021da9408d6b9e0c077142a449ae))
|
|
14
|
+
|
|
15
|
+
## [0.5.0](https://github.com/dtlab-tech/ai-toolkit/compare/v0.4.0...v0.5.0) (2026-07-29)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* **pm-phase3:** Option C review architecture + estimate format improvements ([b385b3e](https://github.com/dtlab-tech/ai-toolkit/commit/b385b3e35ef9121b8d9008223c77c88291c4173a))
|
|
21
|
+
|
|
2
22
|
## [0.4.0](https://github.com/dtlab-tech/ai-toolkit/compare/v0.3.1...v0.4.0) (2026-07-29)
|
|
3
23
|
|
|
4
24
|
|
package/README.md
CHANGED
|
@@ -104,7 +104,7 @@ npm run test:coverage # run all tests and generate a coverage report
|
|
|
104
104
|
The test suite covers:
|
|
105
105
|
|
|
106
106
|
- **`tests/cli/`** — unit tests for pure functions in `bin/cli.js`
|
|
107
|
-
(`fileHash`, `walkDir`, `expandMappings`, `categorize`, `readInstalledVersion
|
|
107
|
+
(`fileHash`, `walkDir`, `expandMappings`, `categorize`, `readInstalledVersion`)
|
|
108
108
|
- **`tests/frontmatter/`** — structural validation of all `.claude/agents/*.md`
|
|
109
109
|
and `.claude/skills/**/SKILL.md` frontmatter fields
|
|
110
110
|
|