@dtlabs/ai-toolkit 0.1.6 → 0.2.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.
- package/.claude/agents/define-feature.md +1 -0
- package/.claude/agents/dependency-injection-refactoring.md +1 -0
- package/.claude/agents/dependency-supply-chain-security.md +1 -0
- package/.claude/agents/developer-backend.md +1 -0
- package/.claude/agents/developer-frontend.md +1 -0
- package/.claude/agents/developer-testing.md +1 -0
- package/.claude/agents/domain-model-refactoring.md +1 -0
- package/.claude/agents/god-class-decomposition.md +1 -0
- package/.claude/agents/init-agents-md.md +1 -0
- package/.claude/agents/install-toolkit.md +134 -3
- package/.claude/agents/intervention-documentation-standard.md +1 -0
- package/.claude/agents/review-solution.md +1 -0
- package/.claude/agents/security-hardening.md +1 -0
- package/.claude/commands/check-interventions.md +152 -0
- package/.claude/commands/next-intervention.md +113 -0
- package/.claude/settings.json +5 -0
- package/.claude/skills/assess-codebase/SKILL.md +139 -60
- package/.claude/skills/implement-feature/SKILL.md +208 -26
- package/.claude/workflows/am-phase1.js +304 -0
- package/.claude/workflows/am-phase2.js +166 -0
- package/.claude/workflows/pm-phase1.js +163 -0
- package/.claude/workflows/pm-phase2.js +108 -0
- package/.claude/workflows/pm-phase3.js +309 -0
- package/CHANGELOG.md +101 -3
- package/CLAUDE.md +34 -0
- package/README.md +26 -0
- package/bin/cli.js +64 -5
- package/docs/token-optimization-backlog.md +115 -0
- package/docs/token-optimization.md +274 -0
- package/package.json +1 -1
- package/.claude/agents/assessment-manager.md +0 -416
- package/.claude/agents/project-manager.md +0 -309
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: define-feature
|
|
3
3
|
description: "Define Feature — grills the user with targeted questions to define a new feature, then writes feature.md in docs/features/FTR-XXX-slug/. Output: feature.md ready for /implement-feature"
|
|
4
|
+
model: sonnet
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
# Define Feature
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: dependency-injection-refactoring
|
|
3
3
|
description: "Dependency Injection Refactoring — guides the incremental conversion of tightly coupled or statically accessed dependencies to constructor-injected services, preserving build integrity at every step. Language-agnostic; reads AGENTS.md for framework-specific DI patterns. Input: target classes from intervention document"
|
|
4
|
+
model: sonnet
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
# Dependency Injection Refactoring
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: dependency-supply-chain-security
|
|
3
3
|
description: "Dependency Supply Chain Security — guides the implementation of dependency integrity controls: trusted package sources, deterministic restore via lock files, unused dependency audit, and SCA integration in CI/CD pipelines. Works with npm, pip, NuGet, Maven, and other package managers; reads AGENTS.md for project stack. Output: remediated configuration files + CI/CD pipeline changes"
|
|
4
|
+
model: sonnet
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
# Dependency Supply Chain Security
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: domain-model-refactoring
|
|
3
3
|
description: "Domain Model Refactoring — guides the decomposition of monolithic domain model files, introduction of type hierarchies for structurally similar types, and alignment of model names with domain ubiquitous language. Language-agnostic; reads AGENTS.md for project conventions. Input: target model directory from intervention document"
|
|
4
|
+
model: sonnet
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
# Domain Model Refactoring
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: god-class-decomposition
|
|
3
3
|
description: "God Class Decomposition — guides the safe, incremental decomposition of oversized classes and methods using responsibility cluster analysis, extract-method, extract-class, and parameter object refactoring. Language-agnostic; reads AGENTS.md for project conventions. Input: target class(es) from intervention document"
|
|
4
|
+
model: sonnet
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
# God Class Decomposition
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: init-agents-md
|
|
3
3
|
description: "Analyzes a project codebase and generates a complete AGENTS.md file with tech stack, conventions, real code patterns, build/test commands, and hard constraints. Input: (optional) path to project root — defaults to current working directory."
|
|
4
|
+
model: sonnet
|
|
4
5
|
tools: Read, Glob, Grep, Bash, Write
|
|
5
6
|
---
|
|
6
7
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: install-toolkit
|
|
3
3
|
description: "Installs the ai-toolkit into a destination project by copying agents, skills, commands, and procedures. Input: [path-to-destination] [--force] — defaults to current working directory"
|
|
4
|
+
model: sonnet
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
# Install Toolkit
|
|
@@ -43,13 +44,14 @@ The user provides:
|
|
|
43
44
|
|
|
44
45
|
## Step 2 — Plan what to copy
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
Five source directories to install:
|
|
47
48
|
|
|
48
49
|
| Source (toolkit) | Destination | Purpose |
|
|
49
50
|
|------------------|-------------|---------|
|
|
50
51
|
| `.claude/agents/` | `{dest}/.claude/agents/` | All spawnable subagents |
|
|
51
52
|
| `.claude/skills/` | `{dest}/.claude/skills/` | All user-invocable skills (except `install-toolkit/`) |
|
|
52
53
|
| `.claude/commands/` | `{dest}/.claude/commands/` | All slash commands |
|
|
54
|
+
| `.claude/workflows/` | `{dest}/.claude/workflows/` | Claude Code Workflow scripts for orchestrated pipelines |
|
|
53
55
|
| `docs/procedures/` | `{dest}/docs/procedures/` | Generic procedures (only if destination has no override) |
|
|
54
56
|
|
|
55
57
|
For each file, compare source content against destination using an MD5/hash check and determine status:
|
|
@@ -63,7 +65,6 @@ Build and display the plan before executing:
|
|
|
63
65
|
📦 Install Plan → {destination}
|
|
64
66
|
──────────────────────────────────────────────────
|
|
65
67
|
.claude/agents/
|
|
66
|
-
✅ NEW project-manager.md
|
|
67
68
|
✅ NEW generate-requirements.md
|
|
68
69
|
⚠️ MODIFIED developer-backend.md ← content differs
|
|
69
70
|
⏭ SAME review-solution.md
|
|
@@ -72,6 +73,13 @@ Build and display the plan before executing:
|
|
|
72
73
|
✅ NEW implement-feature/SKILL.md
|
|
73
74
|
⏭ SAME init-agents/SKILL.md
|
|
74
75
|
|
|
76
|
+
.claude/workflows/
|
|
77
|
+
✅ NEW pm-phase1.js
|
|
78
|
+
✅ NEW pm-phase2.js
|
|
79
|
+
✅ NEW pm-phase3.js
|
|
80
|
+
✅ NEW am-phase1.js
|
|
81
|
+
✅ NEW am-phase2.js
|
|
82
|
+
|
|
75
83
|
docs/procedures/
|
|
76
84
|
✅ NEW code-generation.md
|
|
77
85
|
⏭ SAME testing.md
|
|
@@ -106,6 +114,8 @@ cp "{source_file}" "{dest_file}"
|
|
|
106
114
|
|
|
107
115
|
**Never copy the `install-toolkit/` skill directory** — this skill is toolkit-internal and has no use in a destination project.
|
|
108
116
|
|
|
117
|
+
**Never copy `.claude/settings.json` or `.claude/settings.local.json`** — these are user-owned configuration. Copying them would clobber the destination's existing settings. The toolkit's own `settings.json` exists only to configure this repo; it is verified and advised on (Step 4b), never installed.
|
|
118
|
+
|
|
109
119
|
**For `docs/procedures/`**: copy only files that don't already exist in the destination (regardless of `--force`) — project-specific procedure overrides must never be clobbered.
|
|
110
120
|
|
|
111
121
|
---
|
|
@@ -123,6 +133,44 @@ After copying:
|
|
|
123
133
|
|
|
124
134
|
---
|
|
125
135
|
|
|
136
|
+
## Step 4b — Verify subagent spawn depth (verify & advise ONLY — never write)
|
|
137
|
+
|
|
138
|
+
The orchestrated pipelines (`/implement-feature`, `/assess-codebase`) require the
|
|
139
|
+
environment variable `CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH` to be set to `2` or higher.
|
|
140
|
+
Without it (Claude Code default is `1`), an orchestrator running as a subagent cannot
|
|
141
|
+
spawn its worker subagents, so it executes every task inline on its own model —
|
|
142
|
+
per-agent model assignment, context isolation, and per-agent token telemetry are all lost.
|
|
143
|
+
|
|
144
|
+
**This is a check, not a change. Do NOT create or edit any settings file** — merging user
|
|
145
|
+
configuration is out of scope and risks clobbering the user's existing settings.
|
|
146
|
+
|
|
147
|
+
1. Look for the variable in the destination's settings, checking in order:
|
|
148
|
+
- `{dest}/.claude/settings.local.json`
|
|
149
|
+
- `{dest}/.claude/settings.json`
|
|
150
|
+
- `~/.claude/settings.json` (user-global)
|
|
151
|
+
Read each with a tolerant JSON parse; a value of `2` or higher in `env.CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH` satisfies the requirement.
|
|
152
|
+
2. **If satisfied** → report a one-line confirmation and continue.
|
|
153
|
+
3. **If missing / below 2** → print a warning and the exact snippet the user must add themselves:
|
|
154
|
+
```
|
|
155
|
+
⚠️ CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH is not set to 2+.
|
|
156
|
+
Without it, orchestrated pipelines run every worker inline on the
|
|
157
|
+
orchestrator model (per-agent models, context isolation, and token
|
|
158
|
+
telemetry are lost).
|
|
159
|
+
|
|
160
|
+
Add this to .claude/settings.json (this project) or ~/.claude/settings.json
|
|
161
|
+
(all projects) — the installer does NOT edit it for you:
|
|
162
|
+
|
|
163
|
+
{
|
|
164
|
+
"env": {
|
|
165
|
+
"CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH": "2"
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
Then restart Claude Code so the variable is loaded.
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
126
174
|
## Step 5 — Matt Pocock Skills (version check + optional install/update)
|
|
127
175
|
|
|
128
176
|
After copying the toolkit files, check the state of Matt Pocock's skills:
|
|
@@ -167,7 +215,87 @@ After copying the toolkit files, check the state of Matt Pocock's skills:
|
|
|
167
215
|
|
|
168
216
|
---
|
|
169
217
|
|
|
170
|
-
## Step 6 —
|
|
218
|
+
## Step 6 — Compact Instructions opt-in
|
|
219
|
+
|
|
220
|
+
The toolkit includes a `# Compact instructions` section for `~/.claude/CLAUDE.md` that guides Claude's auto-compaction (what to keep, what to drop) and enables proactive topic-change suggestions.
|
|
221
|
+
|
|
222
|
+
1. **Offer the opt-in** — inform the user and ask:
|
|
223
|
+
|
|
224
|
+
> "Would you like to add a `# Compact instructions` section to your global `~/.claude/CLAUDE.md`?
|
|
225
|
+
> It guides auto-compaction to preserve decision-critical information and suggests running `/compact` when you switch topics."
|
|
226
|
+
>
|
|
227
|
+
> Options: "Yes — add it" / "No — skip"
|
|
228
|
+
|
|
229
|
+
2. If the user selects **No**: skip silently; set `compact_instructions_status = "skipped (user said No)"`.
|
|
230
|
+
|
|
231
|
+
3. If the user selects **Yes**:
|
|
232
|
+
|
|
233
|
+
a. **Resolve path**: `CLAUDE_MD="$HOME/.claude/CLAUDE.md"` (Windows bash: `$USERPROFILE/.claude/CLAUDE.md` if `$HOME` is not set).
|
|
234
|
+
|
|
235
|
+
b. **Idempotency check**: search the file for the exact heading `# Compact instructions`:
|
|
236
|
+
```bash
|
|
237
|
+
grep -q "^# Compact instructions" "$CLAUDE_MD" 2>/dev/null && echo "exists" || echo "absent"
|
|
238
|
+
```
|
|
239
|
+
- If **exists**: display skip notice and set `compact_instructions_status = "skipped (already present)"`. Do **not** modify the file.
|
|
240
|
+
- If **absent** (or file does not exist): continue to step (c).
|
|
241
|
+
|
|
242
|
+
c. **Request confirmation** — display exactly:
|
|
243
|
+
> "I am about to append a `# Compact instructions` section to your global `~/.claude/CLAUDE.md`. Confirm to proceed."
|
|
244
|
+
|
|
245
|
+
- If the user **declines**: skip silently; set `compact_instructions_status = "skipped (declined)"`.
|
|
246
|
+
- If the user **confirms**: continue to step (d).
|
|
247
|
+
|
|
248
|
+
d. **Write the section** — append verbatim to `~/.claude/CLAUDE.md` (create the file if it does not exist):
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
mkdir -p "$(dirname "$CLAUDE_MD")"
|
|
252
|
+
cat >> "$CLAUDE_MD" << 'COMPACT_SECTION'
|
|
253
|
+
|
|
254
|
+
# Compact instructions
|
|
255
|
+
|
|
256
|
+
## What to preserve
|
|
257
|
+
When compacting, always keep:
|
|
258
|
+
- Current objective and active task
|
|
259
|
+
- Confirmed decisions and user approvals
|
|
260
|
+
- User answers to questions asked during the session
|
|
261
|
+
- Paths of files created or modified
|
|
262
|
+
- Open errors and unresolved blockers
|
|
263
|
+
- Finding IDs, artifact IDs, FTR/ASSESS/INT reference numbers
|
|
264
|
+
|
|
265
|
+
## What to discard
|
|
266
|
+
When compacting, drop:
|
|
267
|
+
- Raw grep and search results
|
|
268
|
+
- Successful tool outputs (file reads, bash commands that completed without error)
|
|
269
|
+
- Repeated or superseded explanations
|
|
270
|
+
- Superseded plans and intermediate reasoning steps
|
|
271
|
+
|
|
272
|
+
## Topic-change notification
|
|
273
|
+
When the user sends a message containing any of the following phrases (case-insensitive):
|
|
274
|
+
"passiamo a", "ora facciamo", "prossimo punto", "prossimo argomento", "cambiamo argomento",
|
|
275
|
+
"nuovo argomento", "let's move on to", "next topic", "switching to", "now let's do",
|
|
276
|
+
"moving on to", "next up" —
|
|
277
|
+
|
|
278
|
+
— pause before answering and send exactly this message:
|
|
279
|
+
|
|
280
|
+
> **Context compaction suggested**
|
|
281
|
+
>
|
|
282
|
+
> You are about to switch to a new topic. Compacting the context now will keep the next session clean and focused.
|
|
283
|
+
>
|
|
284
|
+
> Reply **Approve - Compact context** to run `/compact` now, or continue to proceed without compacting.
|
|
285
|
+
|
|
286
|
+
If the user replies "Approve - Compact context", run `/compact`. Otherwise proceed normally.
|
|
287
|
+
COMPACT_SECTION
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Report success: "✅ `# Compact instructions` section added to `~/.claude/CLAUDE.md`."
|
|
291
|
+
Set `compact_instructions_status = "✅ added to ~/.claude/CLAUDE.md"`.
|
|
292
|
+
|
|
293
|
+
**Skip notice** (displayed when section already exists):
|
|
294
|
+
> "A `# Compact instructions` section already exists in `~/.claude/CLAUDE.md`. No changes were made. Review and update it manually if needed."
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## Step 7 — Report
|
|
171
299
|
|
|
172
300
|
```
|
|
173
301
|
✅ Toolkit installed at {destination}
|
|
@@ -177,6 +305,8 @@ Modified/overwritten: N
|
|
|
177
305
|
Modified/kept: N (user chose to keep existing version)
|
|
178
306
|
Unchanged (same): N (skipped silently)
|
|
179
307
|
Matt Pocock skills: ✅ installed v{X} / ⬆️ updated v{old}→v{new} / ⏭ skipped / ✅ already up to date v{X}
|
|
308
|
+
Spawn depth: ✅ CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH=2+ present / ⚠️ MISSING — see action above
|
|
309
|
+
Compact instructions: {compact_instructions_status}
|
|
180
310
|
──────────────────────────────────────────────────
|
|
181
311
|
Next steps:
|
|
182
312
|
1. Run /init-agents to generate AGENTS.md for this project
|
|
@@ -192,5 +322,6 @@ If any modified files were kept by the user (not overwritten), list them so they
|
|
|
192
322
|
|
|
193
323
|
- **Never overwrite `docs/procedures/` files** regardless of `--force` — project overrides take priority
|
|
194
324
|
- **Never copy `install-toolkit.md`** — it's a toolkit-internal utility
|
|
325
|
+
- **Never copy or edit `settings.json` / `settings.local.json`** — user-owned config; only verify and advise (Step 4b)
|
|
195
326
|
- **Create directories as needed** — destination may not have `.claude/` yet
|
|
196
327
|
- **Abort cleanly** if destination path is invalid — do not create partial installs
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: intervention-documentation-standard
|
|
3
3
|
description: "Intervention Documentation Standard — generates structured, self-contained intervention documents from assessment findings. Each document is independently actionable by an architect or developer agent. Input: assessment findings; Output: {ASSESS_PREFIX}-INT-NNN-{slug}.md per finding + Interventions-Index.md"
|
|
4
|
+
model: sonnet
|
|
4
5
|
tools: Read, Grep, Glob, Bash, Write
|
|
5
6
|
---
|
|
6
7
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: review-solution
|
|
3
3
|
description: "Senior Architect — full solution review across quality, reuse, architecture, and security dimensions. Reports findings without auto-fixing. Input: scope (files, US-XX, or git diff)"
|
|
4
|
+
model: opus
|
|
4
5
|
tools: Read, Grep, Glob, Bash
|
|
5
6
|
---
|
|
6
7
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: security-hardening
|
|
3
3
|
description: "Security Hardening — guides the implementation of targeted security fixes: input validation at system boundaries, parameterised queries, secret management, log sanitisation, and TLS/transport configuration. Language-agnostic; reads AGENTS.md for project-specific patterns. Input: security findings from assessment"
|
|
4
|
+
model: sonnet
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
# Security Hardening
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Check Interventions — full reconciliation view of all interventions from an assessment run: document presence, Approvals/Index consistency, and feature-actioning status. Usage: /check-interventions [prefix]"
|
|
3
|
+
argument-hint: "[assessment-prefix]"
|
|
4
|
+
allowed-tools: Read, Glob, Grep
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Produce a full reconciliation table for all interventions from a completed assessment run.
|
|
8
|
+
|
|
9
|
+
## Step 1 — Resolve prefix
|
|
10
|
+
|
|
11
|
+
If `$ARGUMENTS` is empty:
|
|
12
|
+
- Glob `docs/assessments/ASSESS-*/` to list available assessment folders.
|
|
13
|
+
- Output the list and say: "Please specify a prefix from the list above (e.g. `/check-interventions ASSESS-001`)."
|
|
14
|
+
- STOP.
|
|
15
|
+
|
|
16
|
+
Otherwise:
|
|
17
|
+
- If the argument is digits-only (e.g. `001`), prepend `ASSESS-` to form `ASSESS-001`.
|
|
18
|
+
- Strip any trailing slash.
|
|
19
|
+
- Use this as `{PREFIX}` for all subsequent steps.
|
|
20
|
+
|
|
21
|
+
## Step 2 — Check assessment directory
|
|
22
|
+
|
|
23
|
+
If `docs/assessments/{PREFIX}/` does not exist:
|
|
24
|
+
```
|
|
25
|
+
❌ Assessment directory not found: docs/assessments/{PREFIX}/
|
|
26
|
+
Run /assess-codebase to start a new assessment.
|
|
27
|
+
```
|
|
28
|
+
STOP.
|
|
29
|
+
|
|
30
|
+
## Step 3 — Read Approvals file
|
|
31
|
+
|
|
32
|
+
File path: `docs/assessments/{PREFIX}/{PREFIX}-Approvals.md`
|
|
33
|
+
|
|
34
|
+
If the file does not exist:
|
|
35
|
+
```
|
|
36
|
+
❌ Approvals file not found: docs/assessments/{PREFIX}/{PREFIX}-Approvals.md
|
|
37
|
+
The assessment pipeline's Findings Gate must complete before this command can run.
|
|
38
|
+
```
|
|
39
|
+
STOP.
|
|
40
|
+
|
|
41
|
+
Read the file. If it does NOT contain `## Interventions Flagged for Feature Delivery`:
|
|
42
|
+
```
|
|
43
|
+
❌ This Approvals file uses a pre-FTR-003 format (missing "Interventions Flagged for Feature Delivery" section).
|
|
44
|
+
This command requires the FTR-003 format produced by assessment-manager Phase 5.
|
|
45
|
+
```
|
|
46
|
+
STOP.
|
|
47
|
+
|
|
48
|
+
Parse the Markdown table under `## Interventions Flagged for Feature Delivery`. Extract all rows (both `Yes` and `No`). Record:
|
|
49
|
+
- `INT-NNN` identifier (normalise by stripping leading zeros for matching)
|
|
50
|
+
- `Flagged` value (`Yes`, `No`, or malformed if any other value)
|
|
51
|
+
- Full `Intervention` column value (e.g. `INT-001 — sql-injection-hardening`) to extract the slug — the slug is the part after ` — `
|
|
52
|
+
|
|
53
|
+
## Step 4 — Read Interventions Index
|
|
54
|
+
|
|
55
|
+
File path: `docs/assessments/{PREFIX}/{PREFIX}-Interventions-Index.md`
|
|
56
|
+
|
|
57
|
+
If the file does not exist:
|
|
58
|
+
- Set `index_available = false`
|
|
59
|
+
- Note: Title, Criticality, and cross-file consistency checks will be skipped or shown as `—`.
|
|
60
|
+
|
|
61
|
+
If the file exists:
|
|
62
|
+
- Set `index_available = true`
|
|
63
|
+
- Parse the Markdown table: extract columns `ID`, `Title`, `Criticality` for each row.
|
|
64
|
+
|
|
65
|
+
## Step 5 — Build unified intervention list
|
|
66
|
+
|
|
67
|
+
Collect all INT-NNN identifiers from:
|
|
68
|
+
1. The Approvals file (all rows)
|
|
69
|
+
2. The Interventions Index (all rows, if available)
|
|
70
|
+
|
|
71
|
+
Union both sets (deduplicated). This is the full list to reconcile.
|
|
72
|
+
|
|
73
|
+
For each entry, retain the **original padded identifier** from the source file (e.g., `INT-001`) as the canonical form — this is what is used in file-system glob operations. Stripping leading zeros is applied **only when comparing two identifiers from different sources** to determine whether they refer to the same intervention (e.g., `INT-001` and `INT-1` are treated as equal for deduplication only).
|
|
74
|
+
|
|
75
|
+
## Step 6 — For each intervention, collect data
|
|
76
|
+
|
|
77
|
+
For each INT-NNN in the unified list:
|
|
78
|
+
|
|
79
|
+
**a. Doc file status:**
|
|
80
|
+
- Glob `docs/assessments/{PREFIX}/{PREFIX}-{INT-NNN}-*.md`
|
|
81
|
+
- If one or more files found: `✅ present`
|
|
82
|
+
- If no files found: `❌ missing`
|
|
83
|
+
|
|
84
|
+
**b. In Approvals:**
|
|
85
|
+
- `Yes` if INT-NNN is in the Approvals table, `No` otherwise
|
|
86
|
+
|
|
87
|
+
**c. Flagged value:**
|
|
88
|
+
- From Approvals table: `Yes`, `No`, or `⚠️ malformed ({value})` if not exactly `Yes`/`No`
|
|
89
|
+
- If INT-NNN not in Approvals: `n/a`
|
|
90
|
+
|
|
91
|
+
**d. In Interventions Index:**
|
|
92
|
+
- `Yes` if INT-NNN is in the Index, `No` otherwise (or `—` if index unavailable)
|
|
93
|
+
|
|
94
|
+
**e. Title and Criticality:**
|
|
95
|
+
- From Interventions Index if available; else `—`
|
|
96
|
+
|
|
97
|
+
**f. Actioned status (only for interventions where Flagged = Yes):**
|
|
98
|
+
- Glob `internal_docs/features/FTR-*/` and `docs/features/FTR-*/`
|
|
99
|
+
- For each feature folder, apply the two-step heuristic:
|
|
100
|
+
1. **Slug match:** folder name contains the INT-NNN slug (case-insensitive substring)
|
|
101
|
+
2. **Body match (fallback):** read `feature.md`; body contains the INT-NNN identifier string (case-insensitive)
|
|
102
|
+
- If a match is found: `✅ actioned → {matched-folder}`
|
|
103
|
+
- If no match: `⏳ pending`
|
|
104
|
+
- If Flagged is not `Yes`: `n/a`
|
|
105
|
+
|
|
106
|
+
## Step 7 — Render reconciliation table
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
📊 Intervention Reconciliation — {PREFIX}
|
|
110
|
+
════════════════════════════════════════════════════════════════
|
|
111
|
+
|
|
112
|
+
| INT-NNN | Title | Criticality | Flagged | Doc file | Actioned |
|
|
113
|
+
|---------|----------------|-------------|---------|-------------|------------------|
|
|
114
|
+
| INT-001 | {title} | CRITICAL | Yes | ✅ present | ✅ actioned → FTR-010-... |
|
|
115
|
+
| INT-002 | {title} | HIGH | Yes | ✅ present | ⏳ pending |
|
|
116
|
+
| INT-003 | {title} | MEDIUM | No | ❌ missing | n/a |
|
|
117
|
+
| INT-004 | {title} | LOW | No | ✅ present | n/a |
|
|
118
|
+
|
|
119
|
+
Total: {N} interventions | {K} flagged | {A} actioned | {P} pending
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
If `index_available = false`, note above the table:
|
|
123
|
+
```
|
|
124
|
+
⚠️ Interventions Index not found — Title and Criticality columns not available.
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Step 8 — Render inconsistency list
|
|
128
|
+
|
|
129
|
+
Collect all inconsistencies:
|
|
130
|
+
|
|
131
|
+
- For each INT-NNN in Approvals that is NOT in the Interventions Index (when index available):
|
|
132
|
+
`INT-NNN: present in Approvals but not in Interventions Index`
|
|
133
|
+
- For each INT-NNN in Interventions Index that is NOT in Approvals (when index available):
|
|
134
|
+
`INT-NNN: present in Interventions Index but missing from Approvals`
|
|
135
|
+
- For each row in Approvals where `Flagged` is not exactly `Yes` or `No`:
|
|
136
|
+
`INT-NNN: malformed Flagged value '{value}' (expected 'Yes' or 'No')`
|
|
137
|
+
|
|
138
|
+
If no inconsistencies:
|
|
139
|
+
```
|
|
140
|
+
────────────────────────────────────────
|
|
141
|
+
✅ No inconsistencies found.
|
|
142
|
+
════════════════════════════════════════════════════════════════
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
If inconsistencies exist:
|
|
146
|
+
```
|
|
147
|
+
────────────────────────────────────────
|
|
148
|
+
⚠️ Inconsistencies ({N}):
|
|
149
|
+
• INT-NNN: present in Approvals but not in Interventions Index
|
|
150
|
+
• INT-NNN: malformed Flagged value 'Approved' (expected 'Yes' or 'No')
|
|
151
|
+
════════════════════════════════════════════════════════════════
|
|
152
|
+
```
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Next Intervention — finds the next un-actioned flagged intervention from an assessment run and suggests the /define-feature invocation to start on it. Usage: /next-intervention [prefix]"
|
|
3
|
+
argument-hint: "[assessment-prefix]"
|
|
4
|
+
allowed-tools: Read, Glob, Grep
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Find the next un-actioned flagged intervention from a completed assessment run.
|
|
8
|
+
|
|
9
|
+
## Step 1 — Resolve prefix
|
|
10
|
+
|
|
11
|
+
If `$ARGUMENTS` is empty:
|
|
12
|
+
- Glob `docs/assessments/ASSESS-*/` to list available assessment folders.
|
|
13
|
+
- Output the list and say: "Please specify a prefix from the list above (e.g. `/next-intervention ASSESS-001`)."
|
|
14
|
+
- STOP.
|
|
15
|
+
|
|
16
|
+
Otherwise:
|
|
17
|
+
- If the argument is digits-only (e.g. `001`), prepend `ASSESS-` to form `ASSESS-001`.
|
|
18
|
+
- Strip any trailing slash.
|
|
19
|
+
- Use this as `{PREFIX}` for all subsequent steps.
|
|
20
|
+
|
|
21
|
+
## Step 2 — Check assessment directory
|
|
22
|
+
|
|
23
|
+
If `docs/assessments/{PREFIX}/` does not exist:
|
|
24
|
+
```
|
|
25
|
+
❌ Assessment directory not found: docs/assessments/{PREFIX}/
|
|
26
|
+
Run /assess-codebase to start a new assessment.
|
|
27
|
+
```
|
|
28
|
+
STOP.
|
|
29
|
+
|
|
30
|
+
## Step 3 — Read Approvals file
|
|
31
|
+
|
|
32
|
+
File path: `docs/assessments/{PREFIX}/{PREFIX}-Approvals.md`
|
|
33
|
+
|
|
34
|
+
If the file does not exist:
|
|
35
|
+
```
|
|
36
|
+
❌ Approvals file not found: docs/assessments/{PREFIX}/{PREFIX}-Approvals.md
|
|
37
|
+
The assessment pipeline's Findings Gate must complete before this command can run.
|
|
38
|
+
```
|
|
39
|
+
STOP.
|
|
40
|
+
|
|
41
|
+
Read the file. If it does NOT contain the section heading `## Interventions Flagged for Feature Delivery`:
|
|
42
|
+
```
|
|
43
|
+
❌ This Approvals file uses a pre-FTR-003 format (missing "Interventions Flagged for Feature Delivery" section).
|
|
44
|
+
This command requires the FTR-003 format produced by assessment-manager Phase 5.
|
|
45
|
+
```
|
|
46
|
+
STOP.
|
|
47
|
+
|
|
48
|
+
## Step 4 — Extract flagged interventions
|
|
49
|
+
|
|
50
|
+
Parse the Markdown table under `## Interventions Flagged for Feature Delivery`.
|
|
51
|
+
- Extract all rows where the `Flagged` column value is exactly `Yes` (case-sensitive).
|
|
52
|
+
- Preserve document order (top-to-bottom).
|
|
53
|
+
|
|
54
|
+
If no rows are flagged:
|
|
55
|
+
```
|
|
56
|
+
ℹ️ No interventions were flagged for feature delivery in this assessment.
|
|
57
|
+
```
|
|
58
|
+
STOP.
|
|
59
|
+
|
|
60
|
+
## Step 5 — Check for matching feature folders
|
|
61
|
+
|
|
62
|
+
Glob both:
|
|
63
|
+
- `internal_docs/features/FTR-*/`
|
|
64
|
+
- `docs/features/FTR-*/`
|
|
65
|
+
|
|
66
|
+
For each flagged intervention, determine whether it is "actioned" using this two-step heuristic (attempt slug match first, then body match as fallback):
|
|
67
|
+
|
|
68
|
+
1. **Slug match:** Does any feature folder name contain the INT-NNN slug from the `Intervention` column (case-insensitive substring)?
|
|
69
|
+
- The `Intervention` column format is `INT-NNN — {slug}` (e.g. `INT-001 — sql-injection-hardening`). The slug is the part after ` — `.
|
|
70
|
+
2. **Body match (fallback):** For any folder that did NOT match by slug, read its `feature.md` and check whether the INT-NNN identifier string (e.g. `INT-001`) appears anywhere in the body (case-insensitive).
|
|
71
|
+
|
|
72
|
+
An intervention is "actioned" if either check returns true for at least one feature folder.
|
|
73
|
+
|
|
74
|
+
Normalise INT-NNN identifiers by stripping leading zeros before comparison (e.g. `INT-001` and `INT-1` are the same).
|
|
75
|
+
|
|
76
|
+
## Step 6 — Find the first un-actioned intervention
|
|
77
|
+
|
|
78
|
+
Scan the flagged interventions in document order and find the first one that is NOT actioned.
|
|
79
|
+
|
|
80
|
+
If all flagged interventions are actioned:
|
|
81
|
+
```
|
|
82
|
+
✅ All flagged interventions have been actioned. ({N} of {N} flagged)
|
|
83
|
+
|
|
84
|
+
Actioned interventions:
|
|
85
|
+
• INT-001 — {slug} → {matched-feature-folder}
|
|
86
|
+
• INT-002 — {slug} → {matched-feature-folder}
|
|
87
|
+
...
|
|
88
|
+
```
|
|
89
|
+
STOP.
|
|
90
|
+
|
|
91
|
+
## Step 7 — Output the next un-actioned intervention
|
|
92
|
+
|
|
93
|
+
Construct the document path:
|
|
94
|
+
```
|
|
95
|
+
docs/assessments/{PREFIX}/{PREFIX}-{INT-NNN}-{slug}.md
|
|
96
|
+
```
|
|
97
|
+
(Glob `docs/assessments/{PREFIX}/{PREFIX}-{INT-NNN}-*.md` to find the actual filename if the slug in the path differs from the Approvals column.)
|
|
98
|
+
|
|
99
|
+
Output:
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
🔖 Next un-actioned intervention: {INT-NNN} — {slug}
|
|
103
|
+
|
|
104
|
+
Document path: docs/assessments/{PREFIX}/{PREFIX}-{INT-NNN}-{slug}.md
|
|
105
|
+
Suggested command: /define-feature docs/assessments/{PREFIX}/{PREFIX}-{INT-NNN}-{slug}.md
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
If some interventions were already actioned, append:
|
|
109
|
+
```
|
|
110
|
+
Previously actioned ({K} of {N} flagged):
|
|
111
|
+
• INT-001 — {slug} → {matched-feature-folder}
|
|
112
|
+
...
|
|
113
|
+
```
|