@dtlabs/ai-toolkit 0.6.0 → 0.7.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.
@@ -78,7 +78,7 @@ Follow all conventions EXACTLY.
78
78
  4. **Create test project/file** if it doesn't exist (following project conventions)
79
79
  5. **Write test helpers** (custom factories, builders, mocks) if needed
80
80
  6. **Implement tests** following AAA pattern
81
- 7. **Verify** by running the test command from AGENTS.md
81
+ 7. **Syntax check only (optional)** — you MAY run a build to confirm the test files compile (e.g. `dotnet build`, `npx tsc --noEmit`). **Do NOT run the test suite** (`dotnet test`, `npm test`, etc.) — the orchestrator runs the full suite once, after all agents finish. Running it here duplicates a multi-minute build per agent and contends for build artifacts.
82
82
 
83
83
  ---
84
84
 
@@ -102,13 +102,13 @@ When all assigned tasks are complete, return a **structured summary** to the orc
102
102
  Tasks completed: [list]
103
103
  Files created: [list with path only]
104
104
  Files modified: [list with path only]
105
- Test result: ✅ N/N passed / ❌ N failed — [failing test names if any]
105
+ Build check: ✅ compiles / ❌ compile error — [first error line if any] / ⏭️ not run
106
106
  Notes: [blocking issues, skipped cases, TODO items]
107
107
  ─────────────────────────────────────────────
108
108
  ```
109
109
 
110
110
  - **Never dump test code** into the summary
111
- - If tests FAILED, include only the failing test names and first error line
111
+ - Do NOT report test-run results — you do not run the suite; the orchestrator runs it once after all agents finish. Report only whether the test files compile.
112
112
 
113
113
  ---
114
114
 
@@ -119,4 +119,4 @@ Notes: [blocking issues, skipped cases, TODO items]
119
119
  - **No testing of trivial code** — getters/setters, data classes, config files
120
120
  - **Mock external dependencies** — databases, HTTP clients, file systems
121
121
  - **Use the project's preferred mocking approach** — as defined in AGENTS.md
122
- - **After implementation**: run the test command to verify all tests pass
122
+ - **Do NOT run the test suite** — the orchestrator runs the full suite once, after every agent has finished writing its files. A build for a quick syntax check is fine; running the tests here wastes minutes on a duplicate build and can lock build artifacts.
@@ -4,6 +4,7 @@ export const meta = {
4
4
  phases: [
5
5
  { title: 'Parse', detail: 'Parse Work Breakdown into structured implementation phases' },
6
6
  { title: 'Implementation', detail: 'Dispatch developer agents per US, review, commit' },
7
+ { title: 'Test', detail: 'Single test run after all phases complete' },
7
8
  { title: 'Remediation', detail: 'Fix OPEN issues from Issues Register' },
8
9
  { title: 'PR', detail: 'Push branch, create PR, update registry' },
9
10
  { title: 'Actuals', detail: 'Write Token-Estimate and Effort-Estimate actuals' },
@@ -237,6 +238,16 @@ const executePhase = async (implPhase) => {
237
238
  }
238
239
 
239
240
  phasesDone++
241
+
242
+ // Persist the cumulative token ledger to disk after every completed phase.
243
+ // budget.spent() is an in-memory counter — if the workflow is stopped (manual
244
+ // stop, crash, timeout) before the Actuals phase, all token data would be lost.
245
+ // Writing the full ledger here means the file always reflects real consumption
246
+ // up to the last completed phase, recoverable manually or by a resumed run.
247
+ await agent(
248
+ `Write the following JSON to ${featureDir}/${prefix}-token-ledger.json (overwrite the file if it exists):\n${JSON.stringify(tokenLedger, null, 2)}`,
249
+ { label: `persist-ledger:${implPhase.phase_id}`, phase: 'Implementation', model: 'haiku' }
250
+ )
240
251
  }
241
252
 
242
253
  // Execute waves: phases in the same wave run in parallel, waves are sequential
@@ -267,6 +278,28 @@ issuesPath = issuesResult?.path || ''
267
278
  issuesOpen = issuesResult?.open_count || 0
268
279
  log(`Implementation complete — ${phasesDone} phases, ${usPassed.length} US passed, ${usEscalated.length} escalated, ${issuesOpen} open issues`)
269
280
 
281
+ // ── Final test run ────────────────────────────────────────────────────────────
282
+ // Developer agents no longer run the test suite themselves (they do a syntax-check
283
+ // build at most). Running the suite once here, after all files are written, replaces
284
+ // N parallel per-agent test runs — cutting ~1h of duplicated builds and artifact
285
+ // contention down to a single centralized run with one consolidated failure report.
286
+ phase('Test')
287
+
288
+ const beforeTest = budget.spent()
289
+ await agent(
290
+ `Run the full test suite in the repository root and report the result.
291
+
292
+ 1. Read AGENTS.md in the repository root to find the exact test command for this project.
293
+ 2. Run that command (e.g. \`dotnet test --no-restore --logger "console;verbosity=normal"\`, \`npm test\`).
294
+ 3. Report the outcome: total passed/failed, and for any failures the test name and first error line.
295
+
296
+ Do NOT fix failing tests — only report them.`,
297
+ { label: 'final-test-run', phase: 'Test', model: 'haiku' }
298
+ )
299
+ const testTokens = budget.spent() - beforeTest
300
+ tokenLedger.push({ agent: 'final-test-run', model: 'haiku', phase_delta_tokens: testTokens })
301
+ log(`Test run complete — ${testTokens} tokens`)
302
+
270
303
  // ── Remediation ───────────────────────────────────────────────────────────────
271
304
  phase('Remediation')
272
305
 
@@ -381,6 +414,30 @@ log(`PR done: ${prResult.pr_url} — ${prTokens} tokens`)
381
414
  // ── Actuals ───────────────────────────────────────────────────────────────────
382
415
  phase('Actuals')
383
416
 
417
+ // Fallback: merge in any ledger entries that were persisted to disk but are missing
418
+ // from the in-memory ledger (e.g. this is a resumed run and earlier phases ran in a
419
+ // previous, interrupted invocation). The in-memory ledger has priority for entries
420
+ // present in both — it reflects the most recent measurements.
421
+ const persistedLedgerRaw = await agent(
422
+ `Read ${featureDir}/${prefix}-token-ledger.json and return its contents as a raw JSON string, nothing else. If the file does not exist, return exactly "[]".`,
423
+ { label: 'read-ledger', phase: 'Actuals', model: 'haiku' }
424
+ )
425
+ try {
426
+ const persisted = JSON.parse(typeof persistedLedgerRaw === 'string' ? persistedLedgerRaw.trim() : '[]')
427
+ if (Array.isArray(persisted)) {
428
+ const seen = new Set(tokenLedger.map(e => e.agent))
429
+ for (const entry of persisted) {
430
+ if (entry && entry.agent && !seen.has(entry.agent)) {
431
+ tokenLedger.push(entry)
432
+ seen.add(entry.agent)
433
+ log(`Recovered ledger entry from disk: ${entry.agent} (${entry.phase_delta_tokens} tokens)`)
434
+ }
435
+ }
436
+ }
437
+ } catch (e) {
438
+ log(`Could not parse persisted token ledger — using in-memory ledger only`)
439
+ }
440
+
384
441
  const totalPhase3Tokens = tokenLedger.reduce((s, e) => s + (e.phase_delta_tokens || 0), 0)
385
442
 
386
443
  const ACTUALS_SCHEMA = {
package/CHANGELOG.md CHANGED
@@ -1,4 +1,13 @@
1
1
  ## 0.1.4 (2026-07-21)
2
+ ## [0.7.0](https://github.com/dtlab-tech/ai-toolkit/compare/v0.6.0...v0.7.0) (2026-07-29)
3
+
4
+
5
+ ### Features
6
+
7
+ * **pipeline:** centralized test run + persistent token ledger + validation report fix + smarter define-feature ([c9fad6e](https://github.com/dtlab-tech/ai-toolkit/commit/c9fad6e4e5dfe25823df1d6534b4e597baa97001))
8
+ * **pm-phase3:** add centralized test run phase to streamline testing process ([972fac5](https://github.com/dtlab-tech/ai-toolkit/commit/972fac55d0754743859a7d75379a41acd49a890d))
9
+ * **pm-phase3:** persist token ledger to disk after every phase ([b6ad681](https://github.com/dtlab-tech/ai-toolkit/commit/b6ad6814770fae31cda60f25298dab9b2739eeaa))
10
+
2
11
  ## [0.6.0](https://github.com/dtlab-tech/ai-toolkit/compare/v0.5.0...v0.6.0) (2026-07-29)
3
12
 
4
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dtlabs/ai-toolkit",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "AI Toolkit — reusable agents and procedures for developers to build AI-powered applications.",
5
5
  "files": [
6
6
  "docs/",