gsd-pi 2.18.0 → 2.20.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/README.md +5 -1
- package/dist/cli.js +3 -3
- package/dist/onboarding.d.ts +3 -1
- package/dist/onboarding.js +77 -3
- package/dist/remote-questions-config.d.ts +1 -1
- package/dist/resources/extensions/google-search/index.ts +164 -47
- package/dist/resources/extensions/gsd/auto-dashboard.ts +14 -2
- package/dist/resources/extensions/gsd/auto-prompts.ts +148 -39
- package/dist/resources/extensions/gsd/auto-worktree.ts +93 -9
- package/dist/resources/extensions/gsd/auto.ts +690 -39
- package/dist/resources/extensions/gsd/captures.ts +384 -0
- package/dist/resources/extensions/gsd/commands.ts +654 -36
- package/dist/resources/extensions/gsd/complexity-classifier.ts +322 -0
- package/dist/resources/extensions/gsd/context-budget.ts +243 -0
- package/dist/resources/extensions/gsd/context-store.ts +195 -0
- package/dist/resources/extensions/gsd/dashboard-overlay.ts +51 -3
- package/dist/resources/extensions/gsd/db-writer.ts +341 -0
- package/dist/resources/extensions/gsd/debug-logger.ts +178 -0
- package/dist/resources/extensions/gsd/dispatch-guard.ts +0 -1
- package/dist/resources/extensions/gsd/docs/preferences-reference.md +54 -0
- package/dist/resources/extensions/gsd/doctor-proactive.ts +286 -0
- package/dist/resources/extensions/gsd/doctor.ts +283 -2
- package/dist/resources/extensions/gsd/export.ts +81 -2
- package/dist/resources/extensions/gsd/files.ts +39 -9
- package/dist/resources/extensions/gsd/git-service.ts +6 -0
- package/dist/resources/extensions/gsd/gsd-db.ts +752 -0
- package/dist/resources/extensions/gsd/guided-flow.ts +26 -1
- package/dist/resources/extensions/gsd/history.ts +0 -1
- package/dist/resources/extensions/gsd/index.ts +277 -1
- package/dist/resources/extensions/gsd/md-importer.ts +526 -0
- package/dist/resources/extensions/gsd/metrics.ts +84 -0
- package/dist/resources/extensions/gsd/model-cost-table.ts +65 -0
- package/dist/resources/extensions/gsd/model-router.ts +256 -0
- package/dist/resources/extensions/gsd/notifications.ts +0 -1
- package/dist/resources/extensions/gsd/post-unit-hooks.ts +72 -2
- package/dist/resources/extensions/gsd/preferences.ts +198 -150
- package/dist/resources/extensions/gsd/prompt-loader.ts +45 -9
- package/dist/resources/extensions/gsd/prompts/execute-task.md +3 -5
- package/dist/resources/extensions/gsd/prompts/heal-skill.md +45 -0
- package/dist/resources/extensions/gsd/prompts/plan-slice.md +5 -1
- package/dist/resources/extensions/gsd/prompts/quick-task.md +48 -0
- package/dist/resources/extensions/gsd/prompts/reassess-roadmap.md +6 -0
- package/dist/resources/extensions/gsd/prompts/replan-slice.md +8 -0
- package/dist/resources/extensions/gsd/prompts/system.md +2 -1
- package/dist/resources/extensions/gsd/prompts/triage-captures.md +62 -0
- package/dist/resources/extensions/gsd/quick.ts +156 -0
- package/dist/resources/extensions/gsd/skill-discovery.ts +5 -3
- package/dist/resources/extensions/gsd/skill-health.ts +417 -0
- package/dist/resources/extensions/gsd/skill-telemetry.ts +127 -0
- package/dist/resources/extensions/gsd/state.ts +30 -0
- package/dist/resources/extensions/gsd/templates/preferences.md +1 -0
- package/dist/resources/extensions/gsd/tests/captures.test.ts +438 -0
- package/dist/resources/extensions/gsd/tests/complexity-classifier.test.ts +181 -0
- package/dist/resources/extensions/gsd/tests/context-budget.test.ts +283 -0
- package/dist/resources/extensions/gsd/tests/context-compression.test.ts +1 -1
- package/dist/resources/extensions/gsd/tests/context-store.test.ts +462 -0
- package/dist/resources/extensions/gsd/tests/continue-here.test.ts +204 -0
- package/dist/resources/extensions/gsd/tests/dashboard-budget.test.ts +346 -0
- package/dist/resources/extensions/gsd/tests/db-writer.test.ts +602 -0
- package/dist/resources/extensions/gsd/tests/debug-logger.test.ts +185 -0
- package/dist/resources/extensions/gsd/tests/derive-state-db.test.ts +406 -0
- package/dist/resources/extensions/gsd/tests/dispatch-guard.test.ts +0 -1
- package/dist/resources/extensions/gsd/tests/dist-redirect.mjs +22 -0
- package/dist/resources/extensions/gsd/tests/doctor-proactive.test.ts +244 -0
- package/dist/resources/extensions/gsd/tests/doctor-runtime.test.ts +303 -0
- package/dist/resources/extensions/gsd/tests/feature-branch-lifecycle-integration.test.ts +434 -0
- package/dist/resources/extensions/gsd/tests/gsd-db.test.ts +353 -0
- package/dist/resources/extensions/gsd/tests/gsd-inspect.test.ts +125 -0
- package/dist/resources/extensions/gsd/tests/gsd-tools.test.ts +326 -0
- package/dist/resources/extensions/gsd/tests/integration-edge.test.ts +228 -0
- package/dist/resources/extensions/gsd/tests/integration-lifecycle.test.ts +277 -0
- package/dist/resources/extensions/gsd/tests/md-importer.test.ts +411 -0
- package/dist/resources/extensions/gsd/tests/metrics.test.ts +197 -0
- package/dist/resources/extensions/gsd/tests/milestone-transition-worktree.test.ts +144 -0
- package/dist/resources/extensions/gsd/tests/model-cost-table.test.ts +69 -0
- package/dist/resources/extensions/gsd/tests/model-isolation.test.ts +99 -0
- package/dist/resources/extensions/gsd/tests/model-router.test.ts +167 -0
- package/dist/resources/extensions/gsd/tests/parsers.test.ts +40 -0
- package/dist/resources/extensions/gsd/tests/post-unit-hooks.test.ts +41 -1
- package/dist/resources/extensions/gsd/tests/preferences-git.test.ts +0 -1
- package/dist/resources/extensions/gsd/tests/preferences-hooks.test.ts +0 -1
- package/dist/resources/extensions/gsd/tests/preferences-mode.test.ts +110 -0
- package/dist/resources/extensions/gsd/tests/preferences-models.test.ts +0 -1
- package/dist/resources/extensions/gsd/tests/prompt-budget-enforcement.test.ts +464 -0
- package/dist/resources/extensions/gsd/tests/prompt-db.test.ts +385 -0
- package/dist/resources/extensions/gsd/tests/remote-questions.test.ts +488 -1
- package/dist/resources/extensions/gsd/tests/resolve-ts-hooks.mjs +17 -29
- package/dist/resources/extensions/gsd/tests/resolve-ts.mjs +2 -8
- package/dist/resources/extensions/gsd/tests/routing-history.test.ts +215 -62
- package/dist/resources/extensions/gsd/tests/skill-lifecycle.test.ts +126 -0
- package/dist/resources/extensions/gsd/tests/stop-auto-remote.test.ts +31 -8
- package/dist/resources/extensions/gsd/tests/token-savings.test.ts +366 -0
- package/dist/resources/extensions/gsd/tests/triage-dispatch.test.ts +224 -0
- package/dist/resources/extensions/gsd/tests/triage-resolution.test.ts +215 -0
- package/dist/resources/extensions/gsd/tests/unit-runtime.test.ts +25 -1
- package/dist/resources/extensions/gsd/tests/visualizer-critical-path.test.ts +145 -0
- package/dist/resources/extensions/gsd/tests/visualizer-data.test.ts +290 -0
- package/dist/resources/extensions/gsd/tests/visualizer-overlay.test.ts +120 -0
- package/dist/resources/extensions/gsd/tests/visualizer-views.test.ts +478 -0
- package/dist/resources/extensions/gsd/tests/worktree-db-integration.test.ts +205 -0
- package/dist/resources/extensions/gsd/tests/worktree-db.test.ts +442 -0
- package/dist/resources/extensions/gsd/tests/worktree-post-create-hook.test.ts +165 -0
- package/dist/resources/extensions/gsd/triage-resolution.ts +200 -0
- package/dist/resources/extensions/gsd/triage-ui.ts +175 -0
- package/dist/resources/extensions/gsd/types.ts +29 -0
- package/dist/resources/extensions/gsd/undo.ts +0 -1
- package/dist/resources/extensions/gsd/unit-runtime.ts +5 -1
- package/dist/resources/extensions/gsd/visualizer-data.ts +505 -0
- package/dist/resources/extensions/gsd/visualizer-overlay.ts +337 -0
- package/dist/resources/extensions/gsd/visualizer-views.ts +755 -0
- package/dist/resources/extensions/gsd/worktree-command.ts +18 -0
- package/dist/resources/extensions/gsd/worktree-manager.ts +11 -4
- package/dist/resources/extensions/remote-questions/config.ts +4 -2
- package/dist/resources/extensions/remote-questions/discord-adapter.ts +35 -4
- package/dist/resources/extensions/remote-questions/format.ts +166 -14
- package/dist/resources/extensions/remote-questions/manager.ts +14 -4
- package/dist/resources/extensions/remote-questions/remote-command.ts +100 -4
- package/dist/resources/extensions/remote-questions/slack-adapter.ts +58 -2
- package/dist/resources/extensions/remote-questions/telegram-adapter.ts +161 -0
- package/dist/resources/extensions/remote-questions/types.ts +2 -1
- package/dist/resources/extensions/ttsr/ttsr-manager.ts +26 -0
- package/dist/resources/extensions/voice/index.ts +4 -3
- package/package.json +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.js +12 -1
- package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/loader.js +5 -0
- package/packages/pi-coding-agent/dist/core/extensions/loader.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/client.d.ts +6 -0
- package/packages/pi-coding-agent/dist/core/lsp/client.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/client.js +25 -0
- package/packages/pi-coding-agent/dist/core/lsp/client.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/index.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/lsp/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/index.js +106 -3
- package/packages/pi-coding-agent/dist/core/lsp/index.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/lsp.md +6 -0
- package/packages/pi-coding-agent/dist/core/lsp/types.d.ts +35 -0
- package/packages/pi-coding-agent/dist/core/lsp/types.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/types.js +6 -0
- package/packages/pi-coding-agent/dist/core/lsp/types.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/utils.d.ts +3 -1
- package/packages/pi-coding-agent/dist/core/lsp/utils.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/utils.js +45 -0
- package/packages/pi-coding-agent/dist/core/lsp/utils.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +6 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.js +43 -11
- package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/system-prompt.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/system-prompt.js +7 -1
- package/packages/pi-coding-agent/dist/core/system-prompt.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/edit.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/edit.js +5 -0
- package/packages/pi-coding-agent/dist/core/tools/edit.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/index.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/tools/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/write.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/write.js +5 -0
- package/packages/pi-coding-agent/dist/core/tools/write.js.map +1 -1
- package/packages/pi-coding-agent/src/core/agent-session.ts +13 -1
- package/packages/pi-coding-agent/src/core/extensions/loader.ts +6 -0
- package/packages/pi-coding-agent/src/core/lsp/client.ts +26 -0
- package/packages/pi-coding-agent/src/core/lsp/index.ts +157 -2
- package/packages/pi-coding-agent/src/core/lsp/lsp.md +6 -0
- package/packages/pi-coding-agent/src/core/lsp/types.ts +53 -0
- package/packages/pi-coding-agent/src/core/lsp/utils.ts +56 -0
- package/packages/pi-coding-agent/src/core/settings-manager.ts +41 -11
- package/packages/pi-coding-agent/src/core/system-prompt.ts +7 -1
- package/packages/pi-coding-agent/src/core/tools/edit.ts +3 -0
- package/packages/pi-coding-agent/src/core/tools/write.ts +3 -0
- package/src/resources/extensions/google-search/index.ts +164 -47
- package/src/resources/extensions/gsd/auto-dashboard.ts +14 -2
- package/src/resources/extensions/gsd/auto-prompts.ts +148 -39
- package/src/resources/extensions/gsd/auto-worktree.ts +93 -9
- package/src/resources/extensions/gsd/auto.ts +690 -39
- package/src/resources/extensions/gsd/captures.ts +384 -0
- package/src/resources/extensions/gsd/commands.ts +654 -36
- package/src/resources/extensions/gsd/complexity-classifier.ts +322 -0
- package/src/resources/extensions/gsd/context-budget.ts +243 -0
- package/src/resources/extensions/gsd/context-store.ts +195 -0
- package/src/resources/extensions/gsd/dashboard-overlay.ts +51 -3
- package/src/resources/extensions/gsd/db-writer.ts +341 -0
- package/src/resources/extensions/gsd/debug-logger.ts +178 -0
- package/src/resources/extensions/gsd/dispatch-guard.ts +0 -1
- package/src/resources/extensions/gsd/docs/preferences-reference.md +54 -0
- package/src/resources/extensions/gsd/doctor-proactive.ts +286 -0
- package/src/resources/extensions/gsd/doctor.ts +283 -2
- package/src/resources/extensions/gsd/export.ts +81 -2
- package/src/resources/extensions/gsd/files.ts +39 -9
- package/src/resources/extensions/gsd/git-service.ts +6 -0
- package/src/resources/extensions/gsd/gsd-db.ts +752 -0
- package/src/resources/extensions/gsd/guided-flow.ts +26 -1
- package/src/resources/extensions/gsd/history.ts +0 -1
- package/src/resources/extensions/gsd/index.ts +277 -1
- package/src/resources/extensions/gsd/md-importer.ts +526 -0
- package/src/resources/extensions/gsd/metrics.ts +84 -0
- package/src/resources/extensions/gsd/model-cost-table.ts +65 -0
- package/src/resources/extensions/gsd/model-router.ts +256 -0
- package/src/resources/extensions/gsd/notifications.ts +0 -1
- package/src/resources/extensions/gsd/post-unit-hooks.ts +72 -2
- package/src/resources/extensions/gsd/preferences.ts +198 -150
- package/src/resources/extensions/gsd/prompt-loader.ts +45 -9
- package/src/resources/extensions/gsd/prompts/execute-task.md +3 -5
- package/src/resources/extensions/gsd/prompts/heal-skill.md +45 -0
- package/src/resources/extensions/gsd/prompts/plan-slice.md +5 -1
- package/src/resources/extensions/gsd/prompts/quick-task.md +48 -0
- package/src/resources/extensions/gsd/prompts/reassess-roadmap.md +6 -0
- package/src/resources/extensions/gsd/prompts/replan-slice.md +8 -0
- package/src/resources/extensions/gsd/prompts/system.md +2 -1
- package/src/resources/extensions/gsd/prompts/triage-captures.md +62 -0
- package/src/resources/extensions/gsd/quick.ts +156 -0
- package/src/resources/extensions/gsd/skill-discovery.ts +5 -3
- package/src/resources/extensions/gsd/skill-health.ts +417 -0
- package/src/resources/extensions/gsd/skill-telemetry.ts +127 -0
- package/src/resources/extensions/gsd/state.ts +30 -0
- package/src/resources/extensions/gsd/templates/preferences.md +1 -0
- package/src/resources/extensions/gsd/tests/captures.test.ts +438 -0
- package/src/resources/extensions/gsd/tests/complexity-classifier.test.ts +181 -0
- package/src/resources/extensions/gsd/tests/context-budget.test.ts +283 -0
- package/src/resources/extensions/gsd/tests/context-compression.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/context-store.test.ts +462 -0
- package/src/resources/extensions/gsd/tests/continue-here.test.ts +204 -0
- package/src/resources/extensions/gsd/tests/dashboard-budget.test.ts +346 -0
- package/src/resources/extensions/gsd/tests/db-writer.test.ts +602 -0
- package/src/resources/extensions/gsd/tests/debug-logger.test.ts +185 -0
- package/src/resources/extensions/gsd/tests/derive-state-db.test.ts +406 -0
- package/src/resources/extensions/gsd/tests/dispatch-guard.test.ts +0 -1
- package/src/resources/extensions/gsd/tests/dist-redirect.mjs +22 -0
- package/src/resources/extensions/gsd/tests/doctor-proactive.test.ts +244 -0
- package/src/resources/extensions/gsd/tests/doctor-runtime.test.ts +303 -0
- package/src/resources/extensions/gsd/tests/feature-branch-lifecycle-integration.test.ts +434 -0
- package/src/resources/extensions/gsd/tests/gsd-db.test.ts +353 -0
- package/src/resources/extensions/gsd/tests/gsd-inspect.test.ts +125 -0
- package/src/resources/extensions/gsd/tests/gsd-tools.test.ts +326 -0
- package/src/resources/extensions/gsd/tests/integration-edge.test.ts +228 -0
- package/src/resources/extensions/gsd/tests/integration-lifecycle.test.ts +277 -0
- package/src/resources/extensions/gsd/tests/md-importer.test.ts +411 -0
- package/src/resources/extensions/gsd/tests/metrics.test.ts +197 -0
- package/src/resources/extensions/gsd/tests/milestone-transition-worktree.test.ts +144 -0
- package/src/resources/extensions/gsd/tests/model-cost-table.test.ts +69 -0
- package/src/resources/extensions/gsd/tests/model-isolation.test.ts +99 -0
- package/src/resources/extensions/gsd/tests/model-router.test.ts +167 -0
- package/src/resources/extensions/gsd/tests/parsers.test.ts +40 -0
- package/src/resources/extensions/gsd/tests/post-unit-hooks.test.ts +41 -1
- package/src/resources/extensions/gsd/tests/preferences-git.test.ts +0 -1
- package/src/resources/extensions/gsd/tests/preferences-hooks.test.ts +0 -1
- package/src/resources/extensions/gsd/tests/preferences-mode.test.ts +110 -0
- package/src/resources/extensions/gsd/tests/preferences-models.test.ts +0 -1
- package/src/resources/extensions/gsd/tests/prompt-budget-enforcement.test.ts +464 -0
- package/src/resources/extensions/gsd/tests/prompt-db.test.ts +385 -0
- package/src/resources/extensions/gsd/tests/remote-questions.test.ts +488 -1
- package/src/resources/extensions/gsd/tests/resolve-ts-hooks.mjs +17 -29
- package/src/resources/extensions/gsd/tests/resolve-ts.mjs +2 -8
- package/src/resources/extensions/gsd/tests/routing-history.test.ts +215 -62
- package/src/resources/extensions/gsd/tests/skill-lifecycle.test.ts +126 -0
- package/src/resources/extensions/gsd/tests/stop-auto-remote.test.ts +31 -8
- package/src/resources/extensions/gsd/tests/token-savings.test.ts +366 -0
- package/src/resources/extensions/gsd/tests/triage-dispatch.test.ts +224 -0
- package/src/resources/extensions/gsd/tests/triage-resolution.test.ts +215 -0
- package/src/resources/extensions/gsd/tests/unit-runtime.test.ts +25 -1
- package/src/resources/extensions/gsd/tests/visualizer-critical-path.test.ts +145 -0
- package/src/resources/extensions/gsd/tests/visualizer-data.test.ts +290 -0
- package/src/resources/extensions/gsd/tests/visualizer-overlay.test.ts +120 -0
- package/src/resources/extensions/gsd/tests/visualizer-views.test.ts +478 -0
- package/src/resources/extensions/gsd/tests/worktree-db-integration.test.ts +205 -0
- package/src/resources/extensions/gsd/tests/worktree-db.test.ts +442 -0
- package/src/resources/extensions/gsd/tests/worktree-post-create-hook.test.ts +165 -0
- package/src/resources/extensions/gsd/triage-resolution.ts +200 -0
- package/src/resources/extensions/gsd/triage-ui.ts +175 -0
- package/src/resources/extensions/gsd/types.ts +29 -0
- package/src/resources/extensions/gsd/undo.ts +0 -1
- package/src/resources/extensions/gsd/unit-runtime.ts +5 -1
- package/src/resources/extensions/gsd/visualizer-data.ts +505 -0
- package/src/resources/extensions/gsd/visualizer-overlay.ts +337 -0
- package/src/resources/extensions/gsd/visualizer-views.ts +755 -0
- package/src/resources/extensions/gsd/worktree-command.ts +18 -0
- package/src/resources/extensions/gsd/worktree-manager.ts +11 -4
- package/src/resources/extensions/remote-questions/config.ts +4 -2
- package/src/resources/extensions/remote-questions/discord-adapter.ts +35 -4
- package/src/resources/extensions/remote-questions/format.ts +166 -14
- package/src/resources/extensions/remote-questions/manager.ts +14 -4
- package/src/resources/extensions/remote-questions/remote-command.ts +100 -4
- package/src/resources/extensions/remote-questions/slack-adapter.ts +58 -2
- package/src/resources/extensions/remote-questions/telegram-adapter.ts +161 -0
- package/src/resources/extensions/remote-questions/types.ts +2 -1
- package/src/resources/extensions/ttsr/ttsr-manager.ts +26 -0
- package/src/resources/extensions/voice/index.ts +4 -3
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
// Integration Lifecycle Test
|
|
2
|
+
//
|
|
3
|
+
// Proves full M001 subsystem composition end-to-end:
|
|
4
|
+
// realistic markdown on disk → migrateFromMarkdown → scoped DB queries →
|
|
5
|
+
// formatted prompt output → token savings validation → re-import after changes →
|
|
6
|
+
// structured tool write-back → DB consistency verification.
|
|
7
|
+
//
|
|
8
|
+
// Crosses ≥4 module boundaries: gsd-db, md-importer, context-store, db-writer.
|
|
9
|
+
// Uses file-backed DB (not :memory:) for WAL fidelity.
|
|
10
|
+
|
|
11
|
+
import { mkdtempSync, mkdirSync, rmSync, writeFileSync, readFileSync, appendFileSync } from 'node:fs';
|
|
12
|
+
import { join } from 'node:path';
|
|
13
|
+
import { tmpdir } from 'node:os';
|
|
14
|
+
|
|
15
|
+
import { openDatabase, closeDatabase, isDbAvailable, _getAdapter } from '../gsd-db.ts';
|
|
16
|
+
import { migrateFromMarkdown, parseDecisionsTable } from '../md-importer.ts';
|
|
17
|
+
import {
|
|
18
|
+
queryDecisions,
|
|
19
|
+
queryRequirements,
|
|
20
|
+
formatDecisionsForPrompt,
|
|
21
|
+
formatRequirementsForPrompt,
|
|
22
|
+
} from '../context-store.ts';
|
|
23
|
+
import { saveDecisionToDb, generateDecisionsMd } from '../db-writer.ts';
|
|
24
|
+
import { createTestContext } from './test-helpers.ts';
|
|
25
|
+
|
|
26
|
+
const { assertEq, assertTrue, assertMatch, report } = createTestContext();
|
|
27
|
+
|
|
28
|
+
// ─── Fixture Generators (duplicated from token-savings.test.ts — file-scoped) ──
|
|
29
|
+
|
|
30
|
+
function generateDecisionsMarkdown(count: number, milestones: string[]): string {
|
|
31
|
+
const lines: string[] = [
|
|
32
|
+
'# Decisions Register',
|
|
33
|
+
'',
|
|
34
|
+
'<!-- Append-only. Never edit or remove existing rows. -->',
|
|
35
|
+
'',
|
|
36
|
+
'| # | When | Scope | Decision | Choice | Rationale | Revisable? |',
|
|
37
|
+
'|---|------|-------|----------|--------|-----------|------------|',
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
for (let i = 1; i <= count; i++) {
|
|
41
|
+
const id = `D${String(i).padStart(3, '0')}`;
|
|
42
|
+
const milestone = milestones[(i - 1) % milestones.length];
|
|
43
|
+
const sliceNum = ((i - 1) % 5) + 1;
|
|
44
|
+
const when = `${milestone}/S${String(sliceNum).padStart(2, '0')}`;
|
|
45
|
+
const scope = ['architecture', 'testing', 'observability', 'security', 'performance'][(i - 1) % 5];
|
|
46
|
+
const decision = `${scope} decision ${i}: implement ${scope}-level ${['caching', 'validation', 'retry logic', 'circuit breaker', 'rate limiting'][(i - 1) % 5]} for the ${['API layer', 'data pipeline', 'auth subsystem', 'notification service', 'background workers'][(i - 1) % 5]}`;
|
|
47
|
+
const choice = `Use ${['SQLite', 'Redis', 'in-memory cache', 'exponential backoff', 'token bucket'][(i - 1) % 5]} with ${['WAL mode', 'cluster mode', 'LRU eviction', 'jitter', 'sliding window'][(i - 1) % 5]}`;
|
|
48
|
+
const rationale = `${['Built-in Node.js support eliminates external dependency', 'Sub-millisecond latency meets P99 requirement', 'Memory-efficient with bounded growth prevents OOM', 'Prevents thundering herd during recovery', 'Protects downstream services from burst traffic'][(i - 1) % 5]}. Aligns with ${scope} principles for ${milestone}.`;
|
|
49
|
+
const revisable = i % 3 === 0 ? 'no' : 'yes';
|
|
50
|
+
|
|
51
|
+
lines.push(`| ${id} | ${when} | ${scope} | ${decision} | ${choice} | ${rationale} | ${revisable} |`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return lines.join('\n');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function milestone_shorthand(index: number): string {
|
|
58
|
+
return ['alpha', 'beta', 'GA'][index] ?? 'alpha';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function generateRequirementsMarkdown(count: number, sliceAssignments: { milestone: string; slice: string }[]): string {
|
|
62
|
+
const lines: string[] = [
|
|
63
|
+
'# Requirements',
|
|
64
|
+
'',
|
|
65
|
+
'## Active',
|
|
66
|
+
'',
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
for (let i = 1; i <= count; i++) {
|
|
70
|
+
const id = `R${String(i).padStart(3, '0')}`;
|
|
71
|
+
const assignment = sliceAssignments[(i - 1) % sliceAssignments.length];
|
|
72
|
+
const reqClass = ['functional', 'non-functional', 'constraint', 'functional', 'non-functional'][(i - 1) % 5];
|
|
73
|
+
const description = `${['Response latency', 'Data consistency', 'Error recovery', 'Access control', 'Audit logging', 'Cache invalidation', 'Schema migration'][(i - 1) % 7]} requirement for ${assignment.milestone}/${assignment.slice}`;
|
|
74
|
+
const why = `Critical for ${['user experience', 'data integrity', 'system reliability', 'security compliance', 'regulatory requirements', 'operational visibility', 'deployment safety'][(i - 1) % 7]}. Without this, the system would ${['degrade under load', 'lose data during failures', 'fail to recover from crashes', 'expose unauthorized data', 'violate compliance mandates', 'have stale data issues', 'break during schema changes'][(i - 1) % 7]}.`;
|
|
75
|
+
const source = `Architecture review ${milestone_shorthand((i - 1) % 3)}, stakeholder feedback round ${((i - 1) % 4) + 1}`;
|
|
76
|
+
const primaryOwner = assignment.slice;
|
|
77
|
+
const supportingSlices = sliceAssignments
|
|
78
|
+
.filter(a => a.slice !== assignment.slice && a.milestone === assignment.milestone)
|
|
79
|
+
.map(a => a.slice)
|
|
80
|
+
.slice(0, 2)
|
|
81
|
+
.join(', ');
|
|
82
|
+
const validation = `${['Automated test suite covers all edge cases', 'Load test confirms P99 < 200ms under 1000 RPS', 'Chaos test proves recovery within 30s', 'Penetration test shows no unauthorized access paths', 'Audit log review confirms complete event capture', 'Integration test validates cache consistency', 'Migration test verifies zero-downtime upgrade'][(i - 1) % 7]}.`;
|
|
83
|
+
const notes = `Tracked in JIRA-${100 + i}. See ADR-${((i - 1) % 5) + 1} for background.`;
|
|
84
|
+
|
|
85
|
+
lines.push(`### ${id} — ${description}`);
|
|
86
|
+
lines.push('');
|
|
87
|
+
lines.push(`- Class: ${reqClass}`);
|
|
88
|
+
lines.push(`- Status: active`);
|
|
89
|
+
lines.push(`- Why it matters: ${why}`);
|
|
90
|
+
lines.push(`- Source: ${source}`);
|
|
91
|
+
lines.push(`- Primary owning slice: ${primaryOwner}`);
|
|
92
|
+
if (supportingSlices) {
|
|
93
|
+
lines.push(`- Supporting slices: ${supportingSlices}`);
|
|
94
|
+
}
|
|
95
|
+
lines.push(`- Validation: ${validation}`);
|
|
96
|
+
lines.push(`- Notes: ${notes}`);
|
|
97
|
+
lines.push('');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return lines.join('\n');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// ─── Fixture Constants ─────────────────────────────────────────────────────
|
|
104
|
+
|
|
105
|
+
const MILESTONES = ['M001', 'M002'];
|
|
106
|
+
const SLICE_ASSIGNMENTS = [
|
|
107
|
+
{ milestone: 'M001', slice: 'S01' },
|
|
108
|
+
{ milestone: 'M001', slice: 'S02' },
|
|
109
|
+
{ milestone: 'M001', slice: 'S03' },
|
|
110
|
+
{ milestone: 'M002', slice: 'S04' },
|
|
111
|
+
{ milestone: 'M002', slice: 'S05' },
|
|
112
|
+
];
|
|
113
|
+
const DECISIONS_COUNT = 14;
|
|
114
|
+
const REQUIREMENTS_COUNT = 12;
|
|
115
|
+
|
|
116
|
+
const ROADMAP_CONTENT = `# M001: Test Milestone\n\n**Vision:** Integration test milestone.\n\n## Slices\n\n- [ ] **S01: First Slice** \`risk:low\` \`depends:[]\`\n > After this: Done.\n`;
|
|
117
|
+
|
|
118
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
119
|
+
// Full Lifecycle Integration Test
|
|
120
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
121
|
+
|
|
122
|
+
async function main(): Promise<void> {
|
|
123
|
+
|
|
124
|
+
console.log('\n=== integration-lifecycle: full pipeline ===');
|
|
125
|
+
{
|
|
126
|
+
// ── Step 1: Set up temp dir with realistic .gsd/ structure ──────────
|
|
127
|
+
const base = mkdtempSync(join(tmpdir(), 'gsd-int-lifecycle-'));
|
|
128
|
+
const gsdDir = join(base, '.gsd');
|
|
129
|
+
mkdirSync(gsdDir, { recursive: true });
|
|
130
|
+
mkdirSync(join(gsdDir, 'milestones', 'M001'), { recursive: true });
|
|
131
|
+
mkdirSync(join(gsdDir, 'milestones', 'M002'), { recursive: true });
|
|
132
|
+
|
|
133
|
+
const decisionsMarkdown = generateDecisionsMarkdown(DECISIONS_COUNT, MILESTONES);
|
|
134
|
+
const requirementsMarkdown = generateRequirementsMarkdown(REQUIREMENTS_COUNT, SLICE_ASSIGNMENTS);
|
|
135
|
+
|
|
136
|
+
writeFileSync(join(gsdDir, 'DECISIONS.md'), decisionsMarkdown);
|
|
137
|
+
writeFileSync(join(gsdDir, 'REQUIREMENTS.md'), requirementsMarkdown);
|
|
138
|
+
writeFileSync(join(gsdDir, 'milestones', 'M001', 'M001-ROADMAP.md'), ROADMAP_CONTENT);
|
|
139
|
+
|
|
140
|
+
const dbPath = join(gsdDir, 'test-lifecycle.db');
|
|
141
|
+
|
|
142
|
+
try {
|
|
143
|
+
// ── Step 2: Open file-backed DB + migrateFromMarkdown ──────────────
|
|
144
|
+
openDatabase(dbPath);
|
|
145
|
+
assertTrue(isDbAvailable(), 'lifecycle: DB is available after open');
|
|
146
|
+
|
|
147
|
+
const result = migrateFromMarkdown(base);
|
|
148
|
+
|
|
149
|
+
assertTrue(result.decisions === DECISIONS_COUNT, `lifecycle: imported ${result.decisions} decisions, expected ${DECISIONS_COUNT}`);
|
|
150
|
+
assertTrue(result.requirements === REQUIREMENTS_COUNT, `lifecycle: imported ${result.requirements} requirements, expected ${REQUIREMENTS_COUNT}`);
|
|
151
|
+
assertTrue(result.artifacts >= 1, `lifecycle: imported at least 1 artifact (got ${result.artifacts})`);
|
|
152
|
+
|
|
153
|
+
// Verify file-backed DB uses WAL
|
|
154
|
+
const adapter = _getAdapter()!;
|
|
155
|
+
const mode = adapter.prepare('PRAGMA journal_mode').get();
|
|
156
|
+
assertEq(mode?.['journal_mode'], 'wal', 'lifecycle: file-backed DB uses WAL mode');
|
|
157
|
+
|
|
158
|
+
// ── Step 3: Scoped queries — decisions by milestone ────────────────
|
|
159
|
+
const allDecisions = queryDecisions();
|
|
160
|
+
const m001Decisions = queryDecisions({ milestoneId: 'M001' });
|
|
161
|
+
const m002Decisions = queryDecisions({ milestoneId: 'M002' });
|
|
162
|
+
|
|
163
|
+
assertTrue(allDecisions.length === DECISIONS_COUNT, `lifecycle: all decisions count = ${DECISIONS_COUNT} (got ${allDecisions.length})`);
|
|
164
|
+
assertTrue(m001Decisions.length > 0, 'lifecycle: M001 decisions non-empty');
|
|
165
|
+
assertTrue(m002Decisions.length > 0, 'lifecycle: M002 decisions non-empty');
|
|
166
|
+
assertTrue(m001Decisions.length < allDecisions.length, 'lifecycle: M001 filtered count < total count');
|
|
167
|
+
assertTrue(m002Decisions.length < allDecisions.length, 'lifecycle: M002 filtered count < total count');
|
|
168
|
+
assertEq(m001Decisions.length + m002Decisions.length, allDecisions.length, 'lifecycle: M001 + M002 = total decisions');
|
|
169
|
+
|
|
170
|
+
// Verify scoping correctness
|
|
171
|
+
for (const d of m001Decisions) {
|
|
172
|
+
assertTrue(d.when_context.includes('M001'), `lifecycle: M001 decision ${d.id} has M001 in when_context`);
|
|
173
|
+
}
|
|
174
|
+
for (const d of m002Decisions) {
|
|
175
|
+
assertTrue(d.when_context.includes('M002'), `lifecycle: M002 decision ${d.id} has M002 in when_context`);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// ── Step 4: Scoped queries — requirements by slice ─────────────────
|
|
179
|
+
const allRequirements = queryRequirements();
|
|
180
|
+
const s01Requirements = queryRequirements({ sliceId: 'S01' });
|
|
181
|
+
const s04Requirements = queryRequirements({ sliceId: 'S04' });
|
|
182
|
+
|
|
183
|
+
assertTrue(allRequirements.length === REQUIREMENTS_COUNT, `lifecycle: all requirements count = ${REQUIREMENTS_COUNT} (got ${allRequirements.length})`);
|
|
184
|
+
assertTrue(s01Requirements.length > 0, 'lifecycle: S01 requirements non-empty');
|
|
185
|
+
assertTrue(s04Requirements.length > 0, 'lifecycle: S04 requirements non-empty');
|
|
186
|
+
assertTrue(s01Requirements.length < allRequirements.length, 'lifecycle: S01 filtered count < total count');
|
|
187
|
+
|
|
188
|
+
// ── Step 5: Format + token savings validation ──────────────────────
|
|
189
|
+
const formattedDecisions = formatDecisionsForPrompt(m001Decisions);
|
|
190
|
+
const formattedRequirements = formatRequirementsForPrompt(s01Requirements);
|
|
191
|
+
|
|
192
|
+
assertTrue(formattedDecisions.length > 0, 'lifecycle: formatted M001 decisions non-empty');
|
|
193
|
+
assertTrue(formattedRequirements.length > 0, 'lifecycle: formatted S01 requirements non-empty');
|
|
194
|
+
assertMatch(formattedDecisions, /\| D/, 'lifecycle: formatted decisions contains decision rows');
|
|
195
|
+
assertMatch(formattedRequirements, /### R\d+/, 'lifecycle: formatted requirements has headings');
|
|
196
|
+
|
|
197
|
+
// Token savings: scoped output vs full file content
|
|
198
|
+
const fullDecisionsContent = readFileSync(join(gsdDir, 'DECISIONS.md'), 'utf-8');
|
|
199
|
+
const fullRequirementsContent = readFileSync(join(gsdDir, 'REQUIREMENTS.md'), 'utf-8');
|
|
200
|
+
const dbScopedTotal = formattedDecisions.length + formattedRequirements.length;
|
|
201
|
+
const fullTotal = fullDecisionsContent.length + fullRequirementsContent.length;
|
|
202
|
+
const savingsPercent = ((fullTotal - dbScopedTotal) / fullTotal) * 100;
|
|
203
|
+
|
|
204
|
+
console.log(` Token savings: ${savingsPercent.toFixed(1)}% (scoped: ${dbScopedTotal}, full: ${fullTotal})`);
|
|
205
|
+
|
|
206
|
+
assertTrue(dbScopedTotal > 0, 'lifecycle: scoped content non-empty');
|
|
207
|
+
assertTrue(dbScopedTotal < fullTotal, 'lifecycle: scoped content smaller than full content');
|
|
208
|
+
assertTrue(savingsPercent >= 30, `lifecycle: savings ≥30% (actual: ${savingsPercent.toFixed(1)}%)`);
|
|
209
|
+
|
|
210
|
+
// ── Step 6: Simulate content change → re-import ────────────────────
|
|
211
|
+
const newDecisionRow = `| D${DECISIONS_COUNT + 1} | M001/S01 | testing | new decision added after initial import | choice X | rationale Y | yes |`;
|
|
212
|
+
appendFileSync(join(gsdDir, 'DECISIONS.md'), '\n' + newDecisionRow + '\n');
|
|
213
|
+
|
|
214
|
+
const result2 = migrateFromMarkdown(base);
|
|
215
|
+
assertTrue(result2.decisions === DECISIONS_COUNT + 1, `lifecycle: re-import got ${result2.decisions} decisions, expected ${DECISIONS_COUNT + 1}`);
|
|
216
|
+
|
|
217
|
+
const afterReimport = queryDecisions();
|
|
218
|
+
assertTrue(afterReimport.length === DECISIONS_COUNT + 1, `lifecycle: DB has ${DECISIONS_COUNT + 1} decisions after re-import (got ${afterReimport.length})`);
|
|
219
|
+
|
|
220
|
+
// Verify the new decision is queryable
|
|
221
|
+
const newM001 = queryDecisions({ milestoneId: 'M001' });
|
|
222
|
+
const foundNew = newM001.some(d => d.id === `D${DECISIONS_COUNT + 1}`);
|
|
223
|
+
assertTrue(foundNew, `lifecycle: newly imported D${DECISIONS_COUNT + 1} found in M001 scope`);
|
|
224
|
+
|
|
225
|
+
// ── Step 7: saveDecisionToDb write-back + round-trip ───────────────
|
|
226
|
+
const saved = await saveDecisionToDb(
|
|
227
|
+
{
|
|
228
|
+
scope: 'M001/S01',
|
|
229
|
+
decision: 'integration test write-back decision',
|
|
230
|
+
choice: 'option Z',
|
|
231
|
+
rationale: 'proves round-trip fidelity',
|
|
232
|
+
when_context: 'M001/S01',
|
|
233
|
+
},
|
|
234
|
+
base,
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
assertTrue(typeof saved.id === 'string', 'lifecycle: saveDecisionToDb returned an id');
|
|
238
|
+
assertMatch(saved.id, /^D\d+$/, 'lifecycle: saved ID matches D### pattern');
|
|
239
|
+
|
|
240
|
+
// Query back from DB
|
|
241
|
+
const allAfterSave = queryDecisions();
|
|
242
|
+
const savedDecision = allAfterSave.find(d => d.id === saved.id);
|
|
243
|
+
assertTrue(savedDecision !== null && savedDecision !== undefined, `lifecycle: saved decision ${saved.id} found in DB`);
|
|
244
|
+
assertEq(savedDecision?.decision, 'integration test write-back decision', 'lifecycle: saved decision text matches');
|
|
245
|
+
assertEq(savedDecision?.choice, 'option Z', 'lifecycle: saved choice matches');
|
|
246
|
+
|
|
247
|
+
// Verify DECISIONS.md was regenerated with the new decision
|
|
248
|
+
const regeneratedMd = readFileSync(join(gsdDir, 'DECISIONS.md'), 'utf-8');
|
|
249
|
+
assertTrue(regeneratedMd.includes(saved.id), `lifecycle: regenerated DECISIONS.md contains ${saved.id}`);
|
|
250
|
+
assertTrue(regeneratedMd.includes('integration test write-back decision'), 'lifecycle: regenerated md contains write-back text');
|
|
251
|
+
|
|
252
|
+
// Round-trip: parse regenerated markdown back → verify field fidelity
|
|
253
|
+
const reparsed = parseDecisionsTable(regeneratedMd);
|
|
254
|
+
const reparsedSaved = reparsed.find(d => d.id === saved.id);
|
|
255
|
+
assertTrue(reparsedSaved !== undefined, `lifecycle: reparsed markdown contains ${saved.id}`);
|
|
256
|
+
assertEq(reparsedSaved?.choice, 'option Z', 'lifecycle: round-trip choice preserved');
|
|
257
|
+
assertEq(reparsedSaved?.rationale, 'proves round-trip fidelity', 'lifecycle: round-trip rationale preserved');
|
|
258
|
+
|
|
259
|
+
// ── Step 8: DB consistency — total count sanity ─────────────────────
|
|
260
|
+
const finalCount = queryDecisions().length;
|
|
261
|
+
// Original 14 + 1 re-import + 1 saveDecisionToDb = 16
|
|
262
|
+
assertTrue(finalCount === DECISIONS_COUNT + 2, `lifecycle: final DB count = ${DECISIONS_COUNT + 2} (got ${finalCount})`);
|
|
263
|
+
|
|
264
|
+
closeDatabase();
|
|
265
|
+
} finally {
|
|
266
|
+
closeDatabase();
|
|
267
|
+
rmSync(base, { recursive: true, force: true });
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
report();
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
main().catch((error) => {
|
|
275
|
+
console.error(error);
|
|
276
|
+
process.exit(1);
|
|
277
|
+
});
|