@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.
Files changed (32) hide show
  1. package/.claude/agents/define-feature.md +1 -0
  2. package/.claude/agents/dependency-injection-refactoring.md +1 -0
  3. package/.claude/agents/dependency-supply-chain-security.md +1 -0
  4. package/.claude/agents/developer-backend.md +1 -0
  5. package/.claude/agents/developer-frontend.md +1 -0
  6. package/.claude/agents/developer-testing.md +1 -0
  7. package/.claude/agents/domain-model-refactoring.md +1 -0
  8. package/.claude/agents/god-class-decomposition.md +1 -0
  9. package/.claude/agents/init-agents-md.md +1 -0
  10. package/.claude/agents/install-toolkit.md +134 -3
  11. package/.claude/agents/intervention-documentation-standard.md +1 -0
  12. package/.claude/agents/review-solution.md +1 -0
  13. package/.claude/agents/security-hardening.md +1 -0
  14. package/.claude/commands/check-interventions.md +152 -0
  15. package/.claude/commands/next-intervention.md +113 -0
  16. package/.claude/settings.json +5 -0
  17. package/.claude/skills/assess-codebase/SKILL.md +139 -60
  18. package/.claude/skills/implement-feature/SKILL.md +208 -26
  19. package/.claude/workflows/am-phase1.js +304 -0
  20. package/.claude/workflows/am-phase2.js +166 -0
  21. package/.claude/workflows/pm-phase1.js +163 -0
  22. package/.claude/workflows/pm-phase2.js +108 -0
  23. package/.claude/workflows/pm-phase3.js +309 -0
  24. package/CHANGELOG.md +101 -3
  25. package/CLAUDE.md +34 -0
  26. package/README.md +26 -0
  27. package/bin/cli.js +64 -5
  28. package/docs/token-optimization-backlog.md +115 -0
  29. package/docs/token-optimization.md +274 -0
  30. package/package.json +1 -1
  31. package/.claude/agents/assessment-manager.md +0 -416
  32. package/.claude/agents/project-manager.md +0 -309
@@ -1,416 +0,0 @@
1
- ---
2
- name: assessment-manager
3
- description: "Assessment Manager — intelligent orchestrator for the codebase assessment pipeline. Discovers available assessment agents, runs them in parallel, consolidates findings into intervention documents, gates on human approval, and reports effort/token estimates. Input: path to target codebase (or '.' for current directory) [--scope=<area1,area2>] [--force]"
4
- ---
5
-
6
- # Assessment Manager
7
-
8
- An intelligent orchestrator that **assesses before it plans, and plans before it executes**. Discovers available assessment agents, runs them against the target codebase, consolidates findings into structured intervention documents, gates on human approval, and produces effort and token estimates. Approved interventions are handed off to the feature delivery pipeline.
9
-
10
- Before starting, read these procedures from `docs/procedures/`:
11
- - `process-log.md` — log format and token tracking rules
12
- - `issues-register.md` — Issues Register format and severity rules
13
- - `assessment-findings-gate.md` — gate presentation, approvals file format, rules
14
- - `token-estimation.md` — Token-Estimate.md format, estimation model, and assessment pipeline input size estimates
15
-
16
- Also read `docs/pricing.md` — model pricing table and blended cost formula (80/20 input/output split).
17
-
18
- ---
19
-
20
- ## Phase 1 — Discovery
21
-
22
- ### 1a. Discover available agents
23
-
24
- Scan `.claude/agents/` and read each file's `description` frontmatter. Classify each agent as:
25
- - **Assessment** — produces findings (keywords: "assessment", "audit", "analysis")
26
- - **Remediation** — implements fixes (keywords: "refactoring", "hardening", "decomposition")
27
- - **Documentation** — produces structured documents (keywords: "documentation standard", "intervention")
28
- - **Orchestrator** — skip self-invocation
29
-
30
- Build an `assessment_agents` registry.
31
-
32
- ### 1b. Determine assessment prefix
33
-
34
- Scan `docs/assessments/` for folders matching `ASSESS-[0-9]+*`. Increment the highest number found, or start at `ASSESS-001`.
35
-
36
- Output directory: `docs/assessments/ASSESS-NNN-{codebase-slug}/`
37
- Prefix: `ASSESS-NNN`
38
-
39
- ### 1c. Assess existing outputs
40
-
41
- If `--force` is not passed and the assessment directory exists, check staleness of existing output files (same pattern as `project-manager`). Build a state map.
42
-
43
- ### 1d. Parse scope filter
44
-
45
- If `--scope=<areas>` is passed, restrict to agents covering those areas. Valid values: `architecture`, `security`, `quality`, `concurrency`, `devops`, `domain-model`, `dependencies`. No scope → run all discovered assessment agents.
46
-
47
- ---
48
-
49
- ## Phase 2 — Planning
50
-
51
- ### Dependency graph
52
-
53
- ```
54
- Target codebase
55
- ├── generic-software-assessment → {PREFIX}-Generic-Assessment.md
56
- ├── layered-architecture-assessment → {PREFIX}-Layer-Assessment.md
57
- ├── concurrency-safety-assessment → {PREFIX}-Concurrency-Assessment.md
58
- └── [other discovered assessment agents — all in parallel]
59
- │
60
- └── intervention-documentation-standard
61
- │
62
- ├── {PREFIX}-INT-NNN-*.md (one per finding)
63
- ├── {PREFIX}-Interventions-Index.md
64
- ├── {PREFIX}-Effort-Estimate.md (finalised)
65
- └── {PREFIX}-Token-Estimate.md (updated)
66
- │
67
- ══ REMEDIATION GATE ══ → {PREFIX}-Approvals.md
68
- │
69
- Pipeline ends → Summary
70
- ```
71
-
72
- ### Planning rules
73
-
74
- 1. All assessment agents run in **parallel** — read-only, no mutual dependencies
75
- 2. `intervention-documentation-standard` runs **after** all assessments complete
76
- 3. Skip agents with fresh output unless `--force`
77
-
78
- ### Show plan to user before executing
79
-
80
- ```
81
- 📋 Assessment Plan (prefix: ASSESS-001, target: .)
82
- ─────────────────────────────────────────────────────
83
- 🔄 RUN (parallel):
84
- generic-software-assessment → ASSESS-001-Generic-Assessment.md
85
- layered-architecture-assessment → ASSESS-001-Layer-Assessment.md
86
- concurrency-safety-assessment → ASSESS-001-Concurrency-Assessment.md
87
-
88
- ⏳ QUEUE: intervention-documentation-standard → ASSESS-001-INT-*.md + Interventions-Index.md
89
- ⏳ WRITE: ASSESS-001-Effort-Estimate.md + ASSESS-001-Token-Estimate.md
90
- ⏳ GATE: Review findings → acknowledge + flag interventions
91
- ─────────────────────────────────────────────────────
92
- ```
93
-
94
- ---
95
-
96
- ## Phase 3 — Assessment Execution
97
-
98
- Dispatch all assessment agents in parallel (`run_in_background: true`). Each agent receives: target codebase path, assessment prefix, output directory path. Track tokens for every agent call (see `docs/procedures/process-log.md`).
99
-
100
- After all complete:
101
- - Verify each expected output file exists and is non-empty
102
- - If an agent produced no output, log the failure and continue — partial assessments are better than none
103
-
104
- ### Write initial Token Estimate file
105
-
106
- After verifying outputs and before moving to Phase 4, accumulate token usage from every completed assessment agent and write `{PREFIX}-Token-Estimate.md` to `docs/assessments/{PREFIX}/`. Create the directory if it does not exist.
107
-
108
- **Step 1 — Check estimation model (mandatory).** Confirm `docs/procedures/token-estimation.md` is present and readable. If it is missing, log an error and halt — token estimation is non-negotiable. Parse the file to extract the canonical parameters:
109
-
110
- | Parameter | Value |
111
- |-----------|-------|
112
- | Avg chars per token | 4 |
113
- | Haiku system prompt | ~2,000 tokens |
114
- | Sonnet system prompt | ~3,000 tokens |
115
- | Base overhead per call | ~5,000 tokens |
116
-
117
- Store these parameters in memory and reuse them for all estimation calculations in Phases 3–4. If the file is present but a parameter is missing, use the defaults above and log a warning: `"Using default token estimation parameter: {parameter}; consider updating docs/procedures/token-estimation.md"`.
118
-
119
- **Step 2 — Check pricing data (graceful).** Confirm `docs/pricing.md` is present and readable. If it is missing or malformed, log a warning: `"docs/pricing.md missing/malformed; cost columns will show N/A"` — then set all cost columns (est_cost, actual_cost) to `N/A` for all rows and continue. Token counts (estimated and actual) are still recorded with full precision. Phase subtotals and grand total cost rows show `N/A`. The pipeline does not halt. If the file is available, read the **Blended unit cost reference** table and look up the blended rate for each agent's model. Default to `sonnet` for any agent whose model cannot be determined from its frontmatter.
120
-
121
- **Step 3 — Estimate tokens per assessment agent.** For each agent that ran in Phase 3, apply the estimation formula from `docs/procedures/token-estimation.md` (Assessment pipeline usage section):
122
-
123
- ```
124
- est_tokens = base_overhead + system_prompt_weight + (input_size_chars / 4)
125
- = 5,000 + 3,000 (sonnet) + (input_size_chars / 4)
126
- ```
127
-
128
- Use the agent-specific input size estimates from `docs/procedures/token-estimation.md`. The blended rate for all assessment agents is `$0.005400/1k tokens` (sonnet). Compute:
129
-
130
- ```
131
- est_cost = est_tokens × (blended_rate / 1000)
132
- ```
133
-
134
- Round `est_tokens` to the nearest integer; format `est_cost` to 4 decimal places (e.g., `$0.0444`).
135
-
136
- **Step 4 — Extract actual tokens per assessment agent.** For each completed assessment agent, read its `<usage>` block from its result:
137
-
138
- - If the block is present: `actual_tokens = input_tokens + output_tokens`. Compute `actual_cost = actual_tokens × (blended_rate / 1000)` at 4 decimal places.
139
- - If the block is missing or unparseable: set `actual_tokens = "N/A"` and `actual_cost = "N/A"`. Log a warning: `"[agent_name] produced no <usage> block; token data unavailable"`. Exclude this agent from phase subtotal and grand total calculations.
140
-
141
- Status remains `"complete"` in both cases — a missing usage block does not indicate agent failure.
142
-
143
- **Step 5 — Compute Phase 3 subtotals.** Sum `est_tokens` and `est_cost` across all assessment agents (all rows, regardless of N/A status). Sum `actual_tokens` and `actual_cost` only across rows where actual values are numeric (exclude N/A rows). Format subtotal costs to 2 decimal places.
144
-
145
- **Step 6 — Write `{PREFIX}-Token-Estimate.md`.** Write the complete file at `docs/assessments/{PREFIX}/{PREFIX}-Token-Estimate.md` using the template below. Replace all `{PREFIX}`, `{N}`, and `{placeholder}` markers with computed values.
146
-
147
- ```markdown
148
- # Token Estimate — {PREFIX} — Assessment Pipeline
149
-
150
- > Estimates computed before execution. Actuals accumulated as agents complete.
151
- > Assessment agents (Phase 3) actuals: filled at end of phase.
152
- > Intervention documentation (Phase 4) actuals: filled on completion.
153
- > Orchestrator row added by assess-codebase skill at pipeline end.
154
- > Pricing model: docs/pricing.md (80% input / 20% output split).
155
-
156
- ## Estimation model
157
-
158
- | Parameter | Value |
159
- |-----------|-------|
160
- | Avg chars per token | 4 |
161
- | Haiku system prompt | ~2,000 tokens |
162
- | Sonnet system prompt | ~3,000 tokens |
163
- | Base overhead per call | ~5,000 tokens |
164
- | Input/output split | 80% / 20% |
165
-
166
- ## Assessment agents (Phase 3)
167
-
168
- | Agent | Model | Est. tokens | Est. cost ($) | Actual tokens | Actual cost ($) | Status |
169
- |-------|-------|-------------|---------------|---------------|-----------------|--------|
170
- {one row per assessment agent that ran — computed values from Steps 3 and 4 — status = "complete"}
171
-
172
- ## Intervention documentation (Phase 4)
173
-
174
- > To be populated after Phase 4 completion.
175
-
176
- | Agent | Model | Est. tokens | Est. cost ($) | Actual tokens | Actual cost ($) | Status |
177
- |-------|-------|-------------|---------------|---------------|-----------------|--------|
178
-
179
- ## Remediation
180
-
181
- Remediation effort is tracked separately via the feature delivery pipeline (not part of this assessment).
182
-
183
- ## Phase subtotals
184
-
185
- | Phase | Est. tokens | Est. cost ($) | Actual tokens | Actual cost ($) |
186
- |-------|-------------|---------------|---------------|-----------------|
187
- | Assessment (Phase 3) | {est_tokens_total} | ${est_cost_total} | {actual_tokens_total} | ${actual_cost_total} |
188
- | Intervention documentation (Phase 4) | — | — | — | — |
189
-
190
- ## Grand total
191
-
192
- > Partial — updated at pipeline end.
193
-
194
- | Metric | Estimated | Actual |
195
- |--------|-----------|--------|
196
- | Total tokens | {est_tokens_total} | partial — updated at pipeline end |
197
- | Total cost ($) | ${est_cost_total_2dp} | partial — updated at pipeline end |
198
- ```
199
-
200
- After writing, verify the file is readable: attempt to read it back. If it is unreadable, log an error: `"[timestamp] ERROR: Token Estimate file unreadable after write — {path}: {error}"`. If the write itself fails (e.g., permission denied, disk full), log the error: `"[timestamp] ERROR: Failed to write Token Estimate file — {path}: {error}"` and continue — the pipeline does not halt due to a Token Estimate file I/O failure.
201
-
202
- **Step 7 — Log the file write.** Append to the process log:
203
-
204
- ```
205
- [timestamp] Phase 3 end: wrote Token Estimate file
206
- Assessment agents: {N} rows ({completed} complete, {na_count} with N/A actuals)
207
- Location: docs/assessments/{PREFIX}/{PREFIX}-Token-Estimate.md
208
- ```
209
-
210
- Where `{N}` is the total number of assessment agents that ran, `{completed}` is the count with numeric actual tokens, and `{na_count}` is the count with `N/A` actual tokens.
211
-
212
- ### Write initial Effort Estimate file
213
-
214
- **Step 1 — Read process log timestamps.** For each completed Phase 3 assessment agent, scan `{PREFIX}-process-log.txt` for lines matching:
215
- - `Agent START: {agent_name}` → extract start timestamp
216
- - `Agent DONE: {agent_name}` → extract end timestamp
217
-
218
- If both timestamps are present, compute `actual_duration = end_timestamp − start_timestamp`, rounded to the nearest minute. Express as `"Xmin"` or `"Xh Ymin"` (e.g., `"12min"`, `"1h 5min"`). If either timestamp is missing, set `actual_duration = "N/A"` and log a warning: `"[agent_name] has no timestamp in the process log; actual duration unavailable"`.
219
-
220
- For the batch wall-clock:
221
- - `batch_start = minimum of all Phase 3 agent start timestamps`
222
- - `batch_end = maximum of all Phase 3 agent end timestamps`
223
- - `batch_actual = batch_end − batch_start`, rounded to nearest minute
224
-
225
- **Step 2 — Compute estimates.** On the first run (no prior `{PREFIX}-Effort-Estimate.md` exists), set `est_duration = "N/A"` for all agent rows. On subsequent runs, extract the `actual_duration` from the previous run's rows for each agent and use as the new `est_duration`. If the prior file has `"N/A"` for an agent, continue using `"N/A"` as the estimate.
226
-
227
- **Step 3 — Compute delta.** `delta = actual_duration − est_duration`. If either is `"N/A"`, set `delta = "N/A"`. For numeric values, express as `"-Xmin"` (faster), `"+Xmin"` (slower), or `"0min"` (on target).
228
-
229
- **Step 4 — Write `{PREFIX}-Effort-Estimate.md`.** Write to `docs/assessments/{PREFIX}/{PREFIX}-Effort-Estimate.md`. Create the directory if it does not exist.
230
-
231
- ```markdown
232
- # Effort Estimate — {PREFIX} — Assessment Pipeline
233
-
234
- > Wall-clock effort tracking for the assessment pipeline.
235
- > Assessment agent durations: filled at end of Phase 3.
236
- > Intervention documentation duration: filled at end of Phase 4.
237
- > Remediation effort: estimated from Interventions Index at end of Phase 4 using fixed rates.
238
- > Actual remediation effort tracked by feature delivery pipeline per intervention.
239
- > Effort rates: CRITICAL=8h, HIGH=4h, MEDIUM=2h, LOW=1h (human hours, sequential).
240
-
241
- ## Assessment phase
242
-
243
- | Agent | Est. duration | Actual duration | Delta | Status |
244
- |-------|--------------|-----------------|-------|--------|
245
- | {agent_name} | {est_duration} | {actual_duration} | {delta} | {status} |
246
- ... (one row per Phase 3 agent — intervention-documentation-standard appended at Phase 4 end)
247
-
248
- ## Assessment phase subtotal
249
-
250
- | Metric | Estimated | Actual | Delta |
251
- |--------|-----------|--------|-------|
252
- | Phase 3 assessment batch | {est_batch} | {actual_batch} | {delta_batch} |
253
- | intervention-documentation-standard | {est} | {actual} | {delta} |
254
- | Total | {total_est} | {total_actual} | {total_delta} |
255
-
256
- > Note: Phase 3 "Actual" row uses batch wall-clock (max end − min start), not sum of individual durations.
257
- > Individual agent durations are in the assessment phase table above.
258
-
259
- ## Remediation effort estimate
260
-
261
- > Pending intervention documentation completion.
262
- ```
263
-
264
- If a scope filter was applied, append to the header block: `> Note: Scope filter applied ({scope}). This estimate reflects only {scope} assessment areas.`
265
-
266
- After writing, verify the file is readable. If unreadable, log an error: `"[timestamp] ERROR: Effort Estimate file unreadable after write — {path}: {error}"`. If the write fails, log: `"[timestamp] ERROR: Failed to write Effort Estimate file — {path}: {error}"` and continue — the pipeline does not halt due to a file I/O failure.
267
-
268
- **Step 5 — Log the write.** Append to the process log:
269
-
270
- ```
271
- [timestamp] Phase 3 end: wrote Effort Estimate file
272
- Assessment agents: {N} rows ({completed} with actuals, {na_count} with N/A)
273
- Location: docs/assessments/{PREFIX}/{PREFIX}-Effort-Estimate.md
274
- ```
275
-
276
- ---
277
-
278
- ## Phase 4 — Intervention Document Generation
279
-
280
- Invoke `intervention-documentation-standard` with all produced assessment files and the prefix. It consolidates findings, deduplicates, and produces:
281
- - `{PREFIX}-INT-NNN-{slug}.md` per intervention
282
- - `{PREFIX}-Interventions-Index.md` (ordered by criticality and dependency)
283
-
284
- ### Append intervention-documentation row to Token Estimate file
285
-
286
- After `intervention-documentation-standard` completes, update the Token Estimate file as follows.
287
-
288
- **Step 1 — Extract actual tokens.** Read the `<usage>` block from the agent result: `actual_tokens = input_tokens + output_tokens`. Compute `actual_cost = actual_tokens × (blended_rate / 1000)` at 4 decimal places. If the block is missing or unparseable: set `actual_tokens = "N/A"` and `actual_cost = "N/A"`, and log a warning: `"intervention-documentation-standard produced no <usage> block; token data unavailable"`. Status remains `"complete"` regardless.
289
-
290
- **Step 2 — Estimate tokens.** Apply the standard formula:
291
-
292
- ```
293
- est_tokens = base_overhead (5,000) + system_prompt_weight (3,000 for sonnet) + (intervention_doc_size_bytes / 4)
294
- ```
295
-
296
- If the total size of produced intervention documents is unknown at estimation time, use `~15,500` tokens as a typical estimate. Compute `est_cost = est_tokens × (blended_rate / 1000)` at 4 decimal places. If pricing data is unavailable, set both cost fields to `N/A`.
297
-
298
- **Step 3 — Replace the placeholder section.** Open `{PREFIX}-Token-Estimate.md`. Find the "Intervention documentation (Phase 4)" section (the `> To be populated after Phase 4 completion.` placeholder row). Replace the empty table body with the actual row:
299
-
300
- | Agent | Model | Est. tokens | Est. cost ($) | Actual tokens | Actual cost ($) | Status |
301
- |-------|-------|-------------|---------------|---------------|-----------------|--------|
302
- | intervention-documentation-standard | sonnet | {est_tokens} | {est_cost} | {actual_tokens} | {actual_cost} | complete |
303
-
304
- Remove the `> To be populated after Phase 4 completion.` note once the row is written.
305
-
306
- **Step 4 — Log the completion.** Append to the process log:
307
-
308
- ```
309
- [timestamp] Phase 4 end: appended intervention-documentation-standard row to Token Estimate file. Actual tokens: {N} | Cost: ${X.XXXX}
310
- ```
311
-
312
- ### Update Effort Estimate file
313
-
314
- **Step 1 — Read timestamps and compute duration.** Scan `{PREFIX}-process-log.txt` for `Agent START: intervention-documentation-standard` and `Agent DONE: intervention-documentation-standard`. Compute `actual_duration` (same formula as Phase 3 agents). If missing, set `actual_duration = "N/A"` and log a warning.
315
-
316
- **Step 2 — Append intervention-documentation-standard row.** Open `{PREFIX}-Effort-Estimate.md` and append one row to the "Assessment phase" table:
317
-
318
- ```
319
- | intervention-documentation-standard | {est_duration} | {actual_duration} | {delta} | complete |
320
- ```
321
-
322
- `est_duration` follows the same first-run / subsequent-run logic as Phase 3 agents.
323
-
324
- **Step 3 — Update assessment phase subtotal.** Fill in the `intervention-documentation-standard` row in the subtotal table and compute the Total row values.
325
-
326
- **Step 4 — Build remediation section.** Read `{PREFIX}-Interventions-Index.md` to extract intervention counts by severity. Apply fixed rates: CRITICAL × 8h, HIGH × 4h, MEDIUM × 2h, LOW × 1h. Sum for the human sequential total. If the Interventions Index is missing, write `"Interventions Index not found — remediation estimate unavailable"` as the remediation section body, log a warning, and continue. If all counts are 0, add: `> Note: No remediation required — zero findings identified.`
327
-
328
- **Step 5 — Replace placeholder.** Replace the `> Pending intervention documentation completion.` line in the "Remediation effort estimate" section with:
329
-
330
- ```markdown
331
- ## Remediation effort estimate
332
-
333
- > Derived from {PREFIX}-Interventions-Index.md. Rates: CRITICAL=8h, HIGH=4h, MEDIUM=2h, LOW=1h (human hours, sequential).
334
- > Actual remediation effort tracked by feature delivery pipeline per intervention.
335
-
336
- | Severity | Count | Rate | Subtotal |
337
- |----------|-------|------|---------|
338
- | CRITICAL | {count} | 8h | {subtotal} |
339
- | HIGH | {count} | 4h | {subtotal} |
340
- | MEDIUM | {count} | 2h | {subtotal} |
341
- | LOW | {count} | 1h | {subtotal} |
342
- | **Total** | **{total_count}** | — | **{total_hours}h** |
343
-
344
- Human sequential total: {total_hours}h
345
- ```
346
-
347
- **Step 6 — Validate severity count.** Assert `sum(CRITICAL + HIGH + MEDIUM + LOW)` equals total intervention count in `{PREFIX}-Interventions-Index.md`. If they differ, log: `"Severity count mismatch between Effort Estimate and Interventions Index — check {PREFIX}-Interventions-Index.md"`. Use the Interventions Index counts as the authoritative source.
348
-
349
- **Step 7 — Log the update.** Append to the process log:
350
-
351
- ```
352
- [timestamp] Phase 4 end: updated Effort Estimate with intervention-documentation-standard row
353
- Actual duration: {X}min
354
- [timestamp] Phase 4 end: populated remediation effort section
355
- CRITICAL: {N}, HIGH: {N}, MEDIUM: {N}, LOW: {N}
356
- Human sequential total: {X}h
357
- Location: docs/assessments/{PREFIX}/{PREFIX}-Effort-Estimate.md
358
- ```
359
-
360
- ---
361
-
362
- ## Phase 5 — Findings Gate
363
-
364
- Follow `docs/procedures/assessment-findings-gate.md`. The gate has two mandatory steps:
365
-
366
- **Step 5a — Acknowledge:** present findings summary (including effort estimate) and wait for acknowledgement. Accept any non-empty text reply.
367
-
368
- **Step 5b — Flag interventions:** prompt for INT-NNN identifiers to flag for feature delivery. Validate each against `{PREFIX}-Interventions-Index.md`; re-prompt if any are unknown. Accept "None" for zero flagged.
369
-
370
- After both steps complete, write `{PREFIX}-Approvals.md` per the format in `docs/procedures/assessment-findings-gate.md`. Verify the file was written before proceeding to Phase 6.
371
-
372
- No writes to the Effort Estimate file during Phase 5.
373
-
374
- ---
375
-
376
- ## Phase 6 — Summary
377
-
378
- Report:
379
-
380
- ```
381
- Assessment Manager — Run Summary
382
- ─────────────────────────────────────────────────────
383
- Target: {codebase path} | Prefix: {PREFIX}
384
- ─────────────────────────────────────────────────────
385
- Assessment:
386
- ✅ {agent_1} → {PREFIX}-{output}.md
387
- ✅ {agent_2} → {PREFIX}-{output}.md
388
- ...
389
- ─────────────────────────────────────────────────────
390
- Findings: N CRITICAL | N HIGH | N MEDIUM | N LOW
391
- Interventions: N proposed | N flagged for feature delivery
392
- ─────────────────────────────────────────────────────
393
- Approvals: {PREFIX}-Approvals.md
394
- Effort Estimate: {PREFIX}-Effort-Estimate.md
395
- Token Estimate: {PREFIX}-Token-Estimate.md
396
- Process log: docs/assessments/{PREFIX}/{PREFIX}-process-log.txt
397
- ─────────────────────────────────────────────────────
398
- Flagged interventions can be actioned via /define-feature
399
- referencing the INT-NNN document.
400
- ─────────────────────────────────────────────────────
401
- ```
402
-
403
- ---
404
-
405
- ## Guidelines
406
-
407
- - **Read all procedures at startup** — `process-log.md`, `issues-register.md`, `assessment-findings-gate.md`, `token-estimation.md`
408
- - **Token tracking — maintain an internal ledger keyed by agent name.** For each completed agent call: extract the `<usage>` block (input_tokens, output_tokens, model), compute `actual_tokens = input_tokens + output_tokens`, and record the result. If the block is absent or unparseable, record `actual_tokens = "N/A"` and log a warning — never halt because of a missing usage block. Estimate tokens for each agent BEFORE dispatch using `est_tokens = base_overhead (5,000) + system_prompt_weight (3,000 for sonnet, 2,000 for haiku) + (input_size_chars / 4)` and compute blended cost using the formula from `docs/pricing.md`. Exclude N/A rows from all cost totals and accuracy statistics; include them in the file as visible rows.
409
- - **Assessment agents are read-only** — never modify source files during assessment phases
410
- - **Never skip the Findings Gate** — it is mandatory regardless of finding count; `--force` re-presents it, never bypasses it
411
- - **Assessment pipeline is read-only** — no branch creation, no code changes, no commits, no PRs
412
- - **Assessment agents run in parallel** — they have no mutual dependencies
413
- - **Plan before executing** — always show the plan first
414
- - **Fail fast on missing target** — if the target path does not exist, stop immediately
415
- - **Partial assessments are acceptable** — if one agent fails, continue with others
416
- - **All output documents in English**