@ktpartners/dgs-platform 3.0.4 → 3.3.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 (115) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/README.md +8 -1
  3. package/agents/dgs-executor.md +124 -3
  4. package/agents/dgs-idea-researcher.md +447 -0
  5. package/agents/dgs-plan-checker.md +32 -0
  6. package/agents/dgs-planner.md +41 -8
  7. package/bin/install.js +44 -0
  8. package/commands/dgs/audit-milestone.md +2 -1
  9. package/commands/dgs/diff-report.md +124 -0
  10. package/commands/dgs/new-project.md +8 -21
  11. package/commands/dgs/package-scan.md +43 -0
  12. package/commands/dgs/research-idea.md +1 -0
  13. package/commands/dgs/switch-project.md +13 -0
  14. package/deliver-great-systems/bin/dgs-tools.cjs +120 -5
  15. package/deliver-great-systems/bin/lib/audit-tolerance.cjs +77 -0
  16. package/deliver-great-systems/bin/lib/audit-tolerance.test.cjs +101 -0
  17. package/deliver-great-systems/bin/lib/commands.cjs +311 -16
  18. package/deliver-great-systems/bin/lib/commands.test.cjs +115 -0
  19. package/deliver-great-systems/bin/lib/commit-verify.test.cjs +236 -0
  20. package/deliver-great-systems/bin/lib/config.cjs +41 -0
  21. package/deliver-great-systems/bin/lib/config.test.cjs +309 -0
  22. package/deliver-great-systems/bin/lib/core.cjs +7 -3
  23. package/deliver-great-systems/bin/lib/core.test.cjs +79 -1
  24. package/deliver-great-systems/bin/lib/fast-routing.cjs +199 -0
  25. package/deliver-great-systems/bin/lib/fast-routing.test.cjs +108 -0
  26. package/deliver-great-systems/bin/lib/final-commit-precondition.test.cjs +87 -0
  27. package/deliver-great-systems/bin/lib/fixtures/package-scan/bundler-audit-gemfile.json +21 -0
  28. package/deliver-great-systems/bin/lib/fixtures/package-scan/gate-parity-expected.md +186 -0
  29. package/deliver-great-systems/bin/lib/fixtures/package-scan/gate-parity-runresult.json +235 -0
  30. package/deliver-great-systems/bin/lib/fixtures/package-scan/govulncheck-import.json +3 -0
  31. package/deliver-great-systems/bin/lib/fixtures/package-scan/npm-audit-v10.json +37 -0
  32. package/deliver-great-systems/bin/lib/fixtures/package-scan/osv-clean.json +3 -0
  33. package/deliver-great-systems/bin/lib/fixtures/package-scan/osv-vulns.json +77 -0
  34. package/deliver-great-systems/bin/lib/fixtures/package-scan/pip-audit-requirements.json +28 -0
  35. package/deliver-great-systems/bin/lib/fixtures/package-scan/snyk-lodash.json +30 -0
  36. package/deliver-great-systems/bin/lib/fixtures/package-scan/snyk-workspaces.json +55 -0
  37. package/deliver-great-systems/bin/lib/frontmatter.cjs +1 -1
  38. package/deliver-great-systems/bin/lib/governance.cjs +211 -0
  39. package/deliver-great-systems/bin/lib/governance.test.cjs +339 -0
  40. package/deliver-great-systems/bin/lib/health-untracked-phase.test.cjs +269 -0
  41. package/deliver-great-systems/bin/lib/init.cjs +56 -27
  42. package/deliver-great-systems/bin/lib/init.test.cjs +212 -5
  43. package/deliver-great-systems/bin/lib/jobs.cjs +7 -4
  44. package/deliver-great-systems/bin/lib/milestone.cjs +101 -3
  45. package/deliver-great-systems/bin/lib/milestone.test.cjs +203 -0
  46. package/deliver-great-systems/bin/lib/package-adapters.cjs +530 -0
  47. package/deliver-great-systems/bin/lib/package-adapters.test.cjs +618 -0
  48. package/deliver-great-systems/bin/lib/package-ecosystems.cjs +350 -0
  49. package/deliver-great-systems/bin/lib/package-ecosystems.test.cjs +348 -0
  50. package/deliver-great-systems/bin/lib/package-runner.cjs +199 -0
  51. package/deliver-great-systems/bin/lib/package-runner.test.cjs +198 -0
  52. package/deliver-great-systems/bin/lib/package-scan-provenance.cjs +56 -0
  53. package/deliver-great-systems/bin/lib/package-scan-provenance.test.cjs +103 -0
  54. package/deliver-great-systems/bin/lib/package-scan-report.cjs +1140 -0
  55. package/deliver-great-systems/bin/lib/package-scan-report.test.cjs +1963 -0
  56. package/deliver-great-systems/bin/lib/package-scan-skill.cjs +96 -0
  57. package/deliver-great-systems/bin/lib/package-scan-skill.test.cjs +136 -0
  58. package/deliver-great-systems/bin/lib/package-scan.cjs +919 -0
  59. package/deliver-great-systems/bin/lib/package-scan.test.cjs +2147 -0
  60. package/deliver-great-systems/bin/lib/phase.cjs +18 -1
  61. package/deliver-great-systems/bin/lib/plan-number-validity.test.cjs +48 -0
  62. package/deliver-great-systems/bin/lib/projects.cjs +38 -3
  63. package/deliver-great-systems/bin/lib/projects.test.cjs +112 -2
  64. package/deliver-great-systems/bin/lib/quick.cjs +178 -23
  65. package/deliver-great-systems/bin/lib/quick.test.cjs +138 -4
  66. package/deliver-great-systems/bin/lib/repos.cjs +12 -12
  67. package/deliver-great-systems/bin/lib/review.cjs +1821 -0
  68. package/deliver-great-systems/bin/lib/state.cjs +7 -3
  69. package/deliver-great-systems/bin/lib/summary-frontmatter.cjs +54 -0
  70. package/deliver-great-systems/bin/lib/summary-frontmatter.test.cjs +78 -0
  71. package/deliver-great-systems/bin/lib/sweep-scope.test.cjs +263 -0
  72. package/deliver-great-systems/bin/lib/verify.cjs +118 -6
  73. package/deliver-great-systems/bin/lib/verify.test.cjs +82 -0
  74. package/deliver-great-systems/bin/lib/wave-0-template-rename.test.cjs +40 -0
  75. package/deliver-great-systems/bin/lib/worktrees.cjs +27 -1
  76. package/deliver-great-systems/bin/lib/worktrees.test.cjs +76 -0
  77. package/deliver-great-systems/references/agent-step-reliability.md +60 -0
  78. package/deliver-great-systems/references/conflict-resolution.md +4 -0
  79. package/deliver-great-systems/references/context-tiers.md +4 -0
  80. package/deliver-great-systems/references/package-scan-config.md +151 -0
  81. package/deliver-great-systems/references/questioning.md +0 -30
  82. package/deliver-great-systems/references/spec-review-loop.md +1 -2
  83. package/deliver-great-systems/references/workflow-conventions.md +29 -0
  84. package/deliver-great-systems/skills/dgs-tests/package-scan.md +44 -0
  85. package/deliver-great-systems/templates/REVIEW.md +35 -0
  86. package/deliver-great-systems/templates/VALIDATION.md +1 -1
  87. package/deliver-great-systems/templates/claude-md.md +11 -0
  88. package/deliver-great-systems/templates/package-scan-report.md +108 -0
  89. package/deliver-great-systems/templates/project.md +6 -170
  90. package/deliver-great-systems/templates/summary.md +3 -1
  91. package/deliver-great-systems/workflows/add-phase.md +5 -0
  92. package/deliver-great-systems/workflows/audit-milestone.md +66 -10
  93. package/deliver-great-systems/workflows/cancel-job.md +1 -1
  94. package/deliver-great-systems/workflows/codereview.md +103 -9
  95. package/deliver-great-systems/workflows/complete-milestone.md +26 -7
  96. package/deliver-great-systems/workflows/complete-quick.md +40 -2
  97. package/deliver-great-systems/workflows/discuss-phase.md +3 -2
  98. package/deliver-great-systems/workflows/execute-phase.md +89 -2
  99. package/deliver-great-systems/workflows/execute-plan.md +10 -1
  100. package/deliver-great-systems/workflows/help.md +51 -18
  101. package/deliver-great-systems/workflows/import-spec.md +65 -7
  102. package/deliver-great-systems/workflows/init-product.md +46 -152
  103. package/deliver-great-systems/workflows/new-milestone.md +115 -14
  104. package/deliver-great-systems/workflows/new-project.md +60 -331
  105. package/deliver-great-systems/workflows/package-scan.md +59 -0
  106. package/deliver-great-systems/workflows/plan-phase.md +79 -1
  107. package/deliver-great-systems/workflows/quick-complete.md +40 -2
  108. package/deliver-great-systems/workflows/quick.md +183 -10
  109. package/deliver-great-systems/workflows/research-idea.md +80 -142
  110. package/deliver-great-systems/workflows/run-job.md +21 -35
  111. package/deliver-great-systems/workflows/settings.md +13 -77
  112. package/deliver-great-systems/workflows/write-spec.md +9 -11
  113. package/hooks/dist/dgs-enforce-discipline.js +196 -0
  114. package/package.json +1 -1
  115. package/scripts/build-hooks.js +1 -0
@@ -140,6 +140,24 @@ MUST present 3 options:
140
140
 
141
141
  If user selects "Proceed anyway": note incomplete requirements in MILESTONES.md under `### Known Gaps` with REQ-IDs and descriptions.
142
142
 
143
+ **REVIEW.md existence check:**
144
+
145
+ ```bash
146
+ REVIEW_PATH="${project_root}/../milestones/${milestone_version}-REVIEW.md"
147
+ if [ ! -f "$REVIEW_PATH" ]; then
148
+ # Also check archive directory
149
+ REVIEW_PATH="${archive_dir}/${milestone_version}-REVIEW.md"
150
+ fi
151
+ ```
152
+
153
+ If REVIEW.md does not exist at either path:
154
+
155
+ ```
156
+ Warning: REVIEW.md not found — run `dgs-tools jobs generate-review` before sharing with reviewers
157
+ ```
158
+
159
+ This is a warning only — REVIEW.md absence does NOT block milestone completion. The report is supplementary context for four-eyes reviewers and can be generated after completion if needed.
160
+
143
161
  <config-check>
144
162
 
145
163
  ```bash
@@ -603,7 +621,7 @@ Update `${roadmap_path}` — group completed milestone phases:
603
621
  **Delegate archival to dgs-tools:**
604
622
 
605
623
  ```bash
606
- ARCHIVE=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" milestone complete "v[X.Y]" --name "[Milestone Name]")
624
+ ARCHIVE=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" milestone complete "v[X.Y]" --name "[Milestone Name]" --archive-phases)
607
625
  ```
608
626
 
609
627
  The CLI handles:
@@ -613,20 +631,21 @@ The CLI handles:
613
631
  - Moving audit file to milestones if it exists
614
632
  - Creating/appending MILESTONES.md entry with accomplishments from SUMMARY.md files
615
633
  - Updating STATE.md (status, last activity)
634
+ - Moving milestone phase directories to `milestones/v[X.Y]-phases/` (planning root)
635
+ - Moving completed quick task directories to `milestones/v[X.Y]-quick/` (those with SUMMARY.md)
616
636
 
617
637
  Extract from result: `version`, `date`, `phases`, `plans`, `tasks`, `accomplishments`, `archived`.
618
638
 
619
639
  Verify: `✅ Milestone archived to milestones/`
620
640
 
621
- **Phase archival (mandatory):** After milestone archival completes, archive phase directories. Phase directories are fully committed to git history, so they are always recoverable.
641
+ Verify `archived.phases` is `true` in the result. If false, error: "Phase archival failed check ${phases_dir} and milestones/ directory."
622
642
 
623
- ```bash
624
- mkdir -p milestones/v[X.Y]-phases
625
- # For each phase directory in ${phases_dir}/:
626
- mv ${phases_dir}/{phase-dir} milestones/v[X.Y]-phases/
627
- ```
628
643
  Verify: `✅ Phase directories archived to milestones/v[X.Y]-phases/`
629
644
 
645
+ Verify `archived.quick` is `true` in the result if completed quick tasks existed. If false but quick dirs were expected, warn: "Quick archival returned false -- check projects/{project}/quick/ directory."
646
+
647
+ Verify: `completed quick directories archived to milestones/v[X.Y]-quick/`
648
+
630
649
  After archival, the AI still handles:
631
650
  - Reorganizing ROADMAP.md with milestone grouping (requires judgment)
632
651
  - Full PROJECT.md evolution review (requires understanding)
@@ -8,7 +8,44 @@ This workflow is only valid for product-level quicks. If the user is working in
8
8
 
9
9
  <process>
10
10
 
11
- **Step 1: Validate and execute complete-quick**
11
+ **Step 1: Generate inline review summary**
12
+
13
+ Before rebase-and-merge, generate a review report while the quick branch still exists with original commits.
14
+
15
+ ```bash
16
+ REVIEW_RESULT=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" quick generate-review --raw 2>&1)
17
+ REVIEW_EXIT=$?
18
+ ```
19
+
20
+ **If generation succeeds** (`REVIEW_EXIT` is 0):
21
+
22
+ Parse JSON output for the summary:
23
+ ```bash
24
+ REVIEW_PATH=$(echo "$REVIEW_RESULT" | jq -r '.relativePath // empty')
25
+ REVIEW_COMMITS=$(echo "$REVIEW_RESULT" | jq -r '.stats.commits // 0')
26
+ REVIEW_FILES=$(echo "$REVIEW_RESULT" | jq -r '.stats.filesChanged // 0')
27
+ REVIEW_RISKS=$(echo "$REVIEW_RESULT" | jq -r '.stats.riskFlags // 0')
28
+ ```
29
+
30
+ Display the stats banner:
31
+ ```
32
+ Review: ${REVIEW_PATH} (${REVIEW_COMMITS} commits, ${REVIEW_FILES} files${REVIEW_RISKS > 0 ? ", ${REVIEW_RISKS} risk flags" : ""})
33
+ ```
34
+
35
+ **If fast-forward detected** (output contains `"fastForward": true`):
36
+
37
+ Display: `No code changes detected -- review not generated.`
38
+
39
+ **If generation fails** (`REVIEW_EXIT` is non-zero):
40
+
41
+ Log warning and continue -- do NOT block task completion:
42
+ ```
43
+ Warning: Review generation failed. Continuing with completion.
44
+ ```
45
+
46
+ Review generation failure is non-fatal. The quick task will still complete normally.
47
+
48
+ **Step 2: Validate and execute complete-quick**
12
49
 
13
50
  Call the complete-quick CLI command which validates the active quick and executes the full flow:
14
51
 
@@ -43,7 +80,7 @@ After resolving conflicts manually, re-run:
43
80
  ```
44
81
  End workflow.
45
82
 
46
- **Step 2: Display success**
83
+ **Step 3: Display success**
47
84
 
48
85
  Parse JSON result from RESULT.
49
86
 
@@ -59,6 +96,7 @@ Worktree cleaned up. Pushed to origin.
59
96
  </process>
60
97
 
61
98
  <success_criteria>
99
+ - [ ] Review summary generated before rebase-and-merge (or warning logged on failure)
62
100
  - [ ] Active product-level quick validated
63
101
  - [ ] Rebase-before-merge flow executed via rebaseAndMerge()
64
102
  - [ ] Worktree and branch cleaned up
@@ -183,7 +183,8 @@ Read prior phase context to avoid re-asking decided questions and maintain consi
183
183
  **Step 1: Project-level files**
184
184
 
185
185
  Project-level files (PROJECT.md, REQUIREMENTS.md, STATE.md, ROADMAP.md, REPOS.md, and codebase docs) are already loaded via the planning-tier `load-tier` call in the initialize step. Extract from those:
186
- - **PROJECT.md** — Vision, principles, non-negotiables, user preferences
186
+ - **docs/product/PRODUCT-SUMMARY.md** — Vision, principles, non-negotiables (product-level)
187
+ - **PROJECT.md** — Project identity (thin skeleton: name + one-liner)
187
188
  - **REQUIREMENTS.md** — Acceptance criteria, constraints, must-haves vs nice-to-haves
188
189
  - **STATE.md** — Current progress, any flags or session notes
189
190
 
@@ -204,7 +205,7 @@ Structure the extracted information:
204
205
  ```
205
206
  <prior_decisions>
206
207
  ## Project-Level
207
- - [Key principle or constraint from PROJECT.md]
208
+ - [Key principle or constraint from docs/product/PRODUCT-SUMMARY.md]
208
209
  - [Requirement that affects this phase from REQUIREMENTS.md]
209
210
 
210
211
  ## From Prior Phases
@@ -290,7 +290,34 @@ Execute each wave in sequence. Within a wave: parallel if `PARALLELIZATION=true`
290
290
  - Bad: "Executing terrain generation plan"
291
291
  - Good: "Procedural terrain generator using Perlin noise — creates height maps, biome zones, and collision meshes. Required before vehicle physics can interact with ground."
292
292
 
293
- 2. **Spawn executor agents:**
293
+ 2. **Execute plans for this wave:**
294
+
295
+ **If `NON_INTERACTIVE` is true (job mode — inline execution):**
296
+
297
+ The Task tool is not available in nested Task contexts (run-job spawns execute-phase, which would otherwise spawn dgs-executor — Claude Code structural limitation). Run plans inline within the current orchestrator context instead.
298
+
299
+ For each plan in the wave, **in document order** (plans within a wave still execute in the order they appear in the wave's plan list — even if `parallelization` is true, inline mode runs them sequentially because there is no parallel-Task harness):
300
+
301
+ a. Read `~/.claude/deliver-great-systems/workflows/execute-plan.md` and follow its steps inline for this plan, supplying:
302
+ - The plan path: `{phase_dir}/{plan_id}-PLAN.md`
303
+ - The state path: ${state_path} (resolved by init)
304
+ - The phase context file (if present): `{phase_dir}/{padded_phase}-CONTEXT.md`
305
+ - Project conventions: `./CLAUDE.md` (if exists) and `.claude/skills/` or `.agents/skills/` (if either exists)
306
+ - Tier files from $TIER_FILES (computed in initialize step)
307
+ - Author: ${author}
308
+ - Worktree context: when $WORKTREE_REPOS is non-empty, treat the worktree directories as the repo cwds for all task commits and file operations (do NOT use the main checkout paths).
309
+
310
+ b. Treat segmented plans (Pattern B in execute-plan.md `parse_segments`) as Pattern C / main-context for inline mode — i.e. execute every task in the orchestrator's current context. Do NOT spawn nested Tasks. Checkpoint tasks (`type="checkpoint:*"`) are auto-resolved per the `checkpoint_handling` step's `NON_INTERACTIVE`-true rules (human-verify → auto-approve, decision → first option, human-action → FAIL the step).
311
+
312
+ c. Preserve all execute-plan semantics: atomic per-task commits via `dgs-tools.cjs commit`, deviation handling per `<deviation_rules>` (Rules 1–3 auto, Rule 4 logged as deviation since no user is available — record under "Deferred Issues" in SUMMARY.md), authentication gates (in job mode, treat any auth gate as a hard failure — log and halt the wave), and run all of: `record_start_time`, `parse_segments`, `load_prompt`, `preflight_check`, `execute`, `record_completion_time`, `generate_user_setup`, `create_summary`, `update_current_position`, `extract_decisions_and_issues`, `update_session_continuity`, `issues_review_gate`, `finalize_plan`, `update_codebase_map`.
313
+
314
+ d. **Skip the `offer_next` step from execute-plan.md.** Wave/phase advancement is the responsibility of this `execute_waves` step in execute-phase.md, not the inline plan loop.
315
+
316
+ e. After each plan completes, run the same spot-checks defined in step 4 below (SUMMARY.md exists, git commits present, no `## Self-Check: FAILED` marker). If a plan fails the spot-check, log `[INLINE-EXEC] Plan {plan_id} failed spot-check -- halting wave` and halt the wave (do NOT continue to subsequent plans in the same wave).
317
+
318
+ f. After all plans in the wave complete successfully, fall through to step 4 (Report completion).
319
+
320
+ **If `NON_INTERACTIVE` is false (interactive mode — Task spawning):**
294
321
 
295
322
  Pass paths only — executors read files themselves with their fresh 200k context.
296
323
  This keeps orchestrator context lean (~10-15%).
@@ -387,6 +414,27 @@ Execute each wave in sequence. Within a wave: parallel if `PARALLELIZATION=true`
387
414
 
388
415
  If `CODEREVIEW` is not `true`: skip silently, proceed to next step.
389
416
 
417
+ **Derive code repo path:**
418
+
419
+ The gate's git log and the spawned codereview subagent must run against the **code repo** (where task commits live), not the planning repo. Derive `CODE_REPO_PATH` from `$WORKTREE_REPOS` (populated in `handle_worktree`, step 3):
420
+
421
+ ```bash
422
+ CODE_REPO_PATH=$(WORKTREE_REPOS="$WORKTREE_REPOS" node -e "
423
+ const repos = JSON.parse(process.env.WORKTREE_REPOS || '{}');
424
+ const names = Object.keys(repos);
425
+ if (names.length === 0) { process.stdout.write(''); }
426
+ else { process.stdout.write(repos[names[0]]); }
427
+ ")
428
+ ```
429
+
430
+ If `CODE_REPO_PATH` is empty (no milestone worktree registered — e.g. phase executed without a worktree), skip the codereview gate entirely for this wave with the message:
431
+ ```
432
+ No code repo registered for this phase — skipping code review for wave.
433
+ ```
434
+ and proceed to the next step.
435
+
436
+ **Multi-repo note:** when `WORKTREE_REPOS` has more than one entry, this uses the first entry. Multi-repo codereview is a known limitation (TODO: loop over entries once a real multi-repo project exists).
437
+
390
438
  The codereview workflow is non-interactive by design — it auto-fixes low-risk issues and logs CRITICAL/HIGH findings as deviations to SUMMARY.md rather than prompting. It runs in both interactive and job modes.
391
439
 
392
440
  For each plan that completed successfully in this wave:
@@ -402,7 +450,7 @@ Execute each wave in sequence. Within a wave: parallel if `PARALLELIZATION=true`
402
450
 
403
451
  Compute diff reference for the plan's task commits:
404
452
  ```bash
405
- FIRST_TASK_COMMIT=$(git log --oneline --grep="feat(${PHASE}-${PLAN}):" --grep="fix(${PHASE}-${PLAN}):" --grep="test(${PHASE}-${PLAN}):" --grep="refactor(${PHASE}-${PLAN}):" --reverse | head -1 | cut -d' ' -f1)
453
+ FIRST_TASK_COMMIT=$(git -C "${CODE_REPO_PATH}" log --oneline --grep="feat(${PHASE}-${PLAN}):" --grep="fix(${PHASE}-${PLAN}):" --grep="test(${PHASE}-${PLAN}):" --grep="refactor(${PHASE}-${PLAN}):" --reverse | head -1 | cut -d' ' -f1)
406
454
  ```
407
455
 
408
456
  If FIRST_TASK_COMMIT is empty (no task commits found), skip codereview for this plan with message: "No task commits found for {phase}-{plan}, skipping code review."
@@ -419,7 +467,10 @@ Execute each wave in sequence. Within a wave: parallel if `PARALLELIZATION=true`
419
467
  - PLAN: ${PLAN}
420
468
  - PLAN_PATH: ${phase_dir}/{phase}-{plan}-PLAN.md
421
469
  - PHASE_DIR: ${phase_dir}
470
+ - CODE_REPO_PATH: ${CODE_REPO_PATH}
422
471
  - DIFF_REF: ${FIRST_TASK_COMMIT}^..HEAD
472
+ - PROJECT_ROOT: ${project_root}
473
+ - PLANNING_ROOT: $(pwd)
423
474
  ",
424
475
  model="{executor_model}"
425
476
  )
@@ -579,6 +630,42 @@ node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" commit "docs(phase-
579
630
  <step name="verify_phase_goal">
580
631
  Verify phase achieved its GOAL, not just completed tasks.
581
632
 
633
+ **If `NON_INTERACTIVE` is true (job mode — inline verification):**
634
+
635
+ The Task tool is not available in nested Task contexts (run-job → execute-phase → would otherwise spawn dgs-verifier). Perform verification inline within the current orchestrator context.
636
+
637
+ Inline verification procedure:
638
+
639
+ a. **Load phase context:**
640
+ - Phase goal: read from `${roadmap_path}` for phase `${PHASE_NUMBER}`.
641
+ - Phase requirement IDs: `${phase_req_ids}` (from init JSON).
642
+ - Phase directory: `${phase_dir}`.
643
+
644
+ b. **Read all plan SUMMARY.md files** in `${phase_dir}` matching `*-SUMMARY.md`. Cross-reference each SUMMARY's `requirements_completed` frontmatter against `${phase_req_ids}`. Every requirement ID listed in the phase MUST be accounted for in at least one SUMMARY.
645
+
646
+ c. **Read each PLAN.md** in `${phase_dir}` matching `*-PLAN.md` and extract the `must_haves` frontmatter (truths, artifacts, key_links).
647
+
648
+ d. **Check must_haves against the actual codebase:**
649
+ - For each artifact: confirm the file exists on disk (use $WORKTREE_REPOS to resolve repo paths when present; otherwise resolve via REPOS.md). If `min_lines` is specified, verify line count.
650
+ - For each key_link: grep the `from` file for the `pattern`. If pattern is missing, the link is unverified.
651
+ - For each truth: best-effort verification via grep / file existence; truths that require human UAT are marked `human_needed`.
652
+
653
+ e. **Cross-reference REQUIREMENTS.md:** every ID in `${phase_req_ids}` MUST appear in REQUIREMENTS.md with a status reflecting completion. Flag any ID missing from REQUIREMENTS.md as a gap.
654
+
655
+ f. **Determine status:**
656
+ - `passed` — all artifacts present, all key_links found, all truths automatically verified, all requirement IDs accounted for.
657
+ - `human_needed` — automated checks pass but ≥1 truth requires human UAT.
658
+ - `gaps_found` — ≥1 artifact missing, key_link unverified, requirement ID unaccounted for, or truth fails automated verification.
659
+
660
+ g. **Write `${phase_dir}/${PHASE_NUMBER}-VERIFICATION.md`** with frontmatter including `status:` (one of `passed` / `human_needed` / `gaps_found`), `phase:`, `verified_by: ${author}`, `verified_at: <ISO-8601 timestamp>`, and a `mode: inline` marker (so audits can distinguish inline from Task-based verification). Body sections: must-haves checklist (per plan), requirement-ID cross-check table, gaps list (if any), human_verification list (if status is `human_needed`).
661
+
662
+ h. Commit the VERIFICATION.md file:
663
+ ```bash
664
+ node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" commit "docs(phase-${PHASE_NUMBER}): inline verification" --files ${phase_dir}/${PHASE_NUMBER}-VERIFICATION.md
665
+ ```
666
+
667
+ **If `NON_INTERACTIVE` is false (interactive mode — Task spawning):**
668
+
582
669
  ```
583
670
  Task(
584
671
  prompt="Verify phase {phase_number} goal achievement.
@@ -318,6 +318,15 @@ TASK_COMMIT=$(git rev-parse --short HEAD)
318
318
  TASK_COMMITS+=("Task ${TASK_NUM}: ${TASK_COMMIT}")
319
319
  ```
320
320
 
321
+ **6. Post-commit dirty sweep:** After recording the task commit hash, run `git status --porcelain` in every gitCwd the task touched. Resolve gitCwds via the task's `<repos>` tag + REPOS.md (one `resolveRepoRelativePath(cwd, repoName, '.', repos).repoAbsPath` per distinct repo); if the task has no `<repos>` tag, the single gitCwd is the planning root (or the `repo-cwd` override when set). The `dirty_after` field in the commit JSON result from `dgs-tools.cjs commit` already surfaces the list for the repo the commit ran in.
322
+
323
+ Classify each dirty path:
324
+
325
+ - **SWEEP** (`*.tfvars`/`*.tf` fmt reflows, pure whitespace verified by `git diff -w -- <path>` being empty, type-only narrowings in `*.ts`/`*.tsx` confined to type-position tokens on existing declaration lines — type annotations, `as`-casts, generic params; NOT statement-structure keywords like `const`/`await`/`import`): stage and commit as `chore({phase}-{plan}-reflow): verify-step side effects` with one bullet per file. Log under "Post-verify reflows" in SUMMARY.md.
326
+ - **FAIL** (added/removed statements, new imports, new function bodies, or any logic change in files NOT listed in the plan's `files_modified` frontmatter): halt. Record under "Deferred Issues" with a `git diff` excerpt. Treat as a blocking issue and auto-fix per the existing fix-attempt-limit policy (3 attempts then document and continue).
327
+
328
+ Default to SWEEP — false negatives lose work.
329
+
321
330
  </task_commit>
322
331
 
323
332
  <step name="checkpoint_protocol">
@@ -392,7 +401,7 @@ If user_setup exists: create `{phase}-USER-SETUP.md` using template `~/.claude/d
392
401
  <step name="create_summary">
393
402
  Create `{phase}-{plan}-SUMMARY.md` at `${phase_dir}/`. Use `~/.claude/deliver-great-systems/templates/summary.md`.
394
403
 
395
- **Frontmatter:** phase, plan, subsystem, tags | requires/provides/affects | tech-stack.added/patterns | key-files.created/modified | key-decisions | requirements-completed (**MUST** copy `requirements` array from PLAN.md frontmatter verbatim) | duration ($DURATION), completed ($PLAN_END_TIME date).
404
+ **Frontmatter:** phase, plan, subsystem, tags | requires/provides/affects | tech-stack.added/patterns | key-files.created/modified | key-decisions | requirements_completed (**MUST** copy `requirements` array from PLAN.md frontmatter verbatim — pre-commit precondition `dgs-tools final-commit-precondition` aborts the executor on mismatch per REL-08) | duration ($DURATION), completed ($PLAN_END_TIME date).
396
405
 
397
406
  Include `executed_by: ${author}` (from init JSON) in frontmatter — records who triggered this execution.
398
407
 
@@ -12,14 +12,14 @@ Display the complete DGS command reference. Output ONLY the reference content. D
12
12
  ## Quick Start
13
13
 
14
14
  **Single-project (v1):**
15
- 1. `/dgs:new-project` - Create project (questioning + PROJECT.md)
15
+ 1. `/dgs:new-project [<name>]` - Create project (thin skeleton)
16
16
  2. `/dgs:new-milestone` - First milestone (research, requirements, roadmap)
17
17
  3. `/dgs:plan-phase 1` - Create detailed plan for first phase
18
18
  4. `/dgs:execute-phase 1` - Execute the phase
19
19
 
20
20
  **Multi-project / multi-repo (v2):**
21
21
  1. `/dgs:init-product` - Set up product folder and register repos
22
- 2. `/dgs:new-project` - Create a project (questioning + PROJECT.md)
22
+ 2. `/dgs:new-project [<name>]` - Create a project (thin skeleton)
23
23
  3. `/dgs:new-milestone` - First milestone (research, requirements, roadmap)
24
24
  4. `/dgs:plan-phase 1` - Plan first phase (repos tracked per task)
25
25
  5. `/dgs:execute-phase 1` - Execute (commits per-repo automatically)
@@ -73,22 +73,20 @@ Usage: `/dgs:init-product`
73
73
 
74
74
  ### Project Initialization
75
75
 
76
- **`/dgs:new-project`**
77
- Initialize new project through deep questioning. *(Tier 2: planning)*
76
+ **`/dgs:new-project [<name>]`**
77
+ Initialize a new project as a thin skeleton. *(Tier 2: planning)*
78
78
 
79
- One command takes you from idea to project identity:
80
- - Deep questioning to understand what you're building
81
- - Optional brownfield mapping for existing codebases
82
- - PROJECT.md creation with vision, requirements hypotheses, and key decisions
79
+ - Creates `projects/<slug>/PROJECT.md` with title + one-line placeholder
80
+ - Optional brownfield codebase mapping offer for existing code
81
+ - No deep questioning, no `--auto` flag
83
82
 
84
- Creates project artifacts:
85
- - `PROJECT.md` vision and requirements
83
+ Projects are holders. Vision and principles live in `docs/product/PRODUCT-SUMMARY.md`
84
+ (loaded via Tier 1). Specs live at the milestone level.
86
85
 
87
- **v2 additions:** Prompts for project name (used as folder slug), prompts for which repos this project touches (from REPOS.md). Artifacts are created under `projects/<project-slug>/`.
86
+ **Next:** `/dgs:write-spec` to capture what you're building, then
87
+ `/dgs:new-milestone --auto <spec-id>` to start the first milestone.
88
88
 
89
- After completion, run `/dgs:new-milestone` to start your first milestone.
90
-
91
- Usage: `/dgs:new-project`
89
+ Usage: `/dgs:new-project [<name>]`
92
90
 
93
91
  **`/dgs:map-codebase [<repo-name>]`**
94
92
  Map registered repos with parallel agents to produce structured codebase documentation. *(Tier 2: planning)*
@@ -406,7 +404,7 @@ Usage: `/dgs:check-todos api`
406
404
 
407
405
  ### Ideas & Specs
408
406
 
409
- `capture ideas → develop idea → write spec → new-project --auto → new-milestone --auto`
407
+ `capture ideas → develop idea → write spec → new-project → new-milestone --auto`
410
408
 
411
409
  #### Ideas
412
410
 
@@ -658,6 +656,41 @@ Create phases to close gaps identified by audit. *(Tier 2: planning)*
658
656
  Usage: `/dgs:plan-milestone-gaps`
659
657
  Usage: `/dgs:plan-milestone-gaps --auto` (non-interactive gap closure)
660
658
 
659
+ **`/dgs:diff-report [version|--quick slug] [--detailed]`**
660
+ Generate a diff report (REVIEW.md) on demand. *(Tier 4: verification)*
661
+
662
+ - Auto-detects context: active quick task or current milestone
663
+ - Explicit target: version for milestones, `--quick slug` for quick tasks
664
+ - `--detailed` flag invokes LLM-powered per-file analysis
665
+ - Delegates to existing CLI commands (`jobs generate-review` / `quick generate-review`)
666
+
667
+ Usage: `/dgs:diff-report`, `/dgs:diff-report v21.0`, `/dgs:diff-report --quick my-task --detailed`
668
+
669
+ ### Testing & Dependency Scanning
670
+
671
+ **`/dgs:package-scan [flags]`**
672
+ Scan every registered repo + product root for dependency vulnerabilities and licence issues. *(Tier 0: none — no STATE.md/ROADMAP.md auto-inject)*
673
+
674
+ - **Tool cascade:** Snyk → OSV-Scanner → ecosystem-native (`npm audit`, `pip-audit`, `govulncheck`, `bundler-audit`)
675
+ - **Ecosystems:** Node.js, Python, Go, Ruby, Java (Maven; Gradle treated as single-module, PKG-41 deferred)
676
+ - **Monorepo-aware:** npm/pnpm/Yarn workspaces, Maven multi-module, Go workspaces
677
+ - **Report placement:** active phase dir → active milestone dir → timestamped project-root file
678
+ - **Findings in canonical shape** (forward-compatible with `/dgs:plan-test-gaps`)
679
+
680
+ **Flags:**
681
+ - `--threshold critical|high|medium|low` — filter by severity
682
+ - `--repo <name>` — scan a single registered repo
683
+ - `--json` — emit machine-readable JSON alongside the markdown report
684
+ - `--include-dev-deps` / `--no-include-dev-deps` — toggle devDependencies scanning
685
+
686
+ **Config keys:** `testing.packages.tool`, `testing.packages.severity_threshold`, `testing.packages.include_dev_dependencies`, `testing.packages.timeout_seconds` (all in `config.json`). `testing.packages.snyk_token` goes to `config.local.json` only.
687
+
688
+ **Reference doc:** `~/.claude/deliver-great-systems/references/package-scan-config.md` — tool installation steps, Snyk-auth priority, report placement cascade.
689
+
690
+ Usage: `/dgs:package-scan`
691
+ Usage: `/dgs:package-scan --threshold high --repo api`
692
+ Usage: `/dgs:package-scan --json` (pipe to jq, feed CI, etc.)
693
+
661
694
  ### Milestone Jobs
662
695
 
663
696
  | Command | What it does | When to use |
@@ -866,7 +899,7 @@ Example config:
866
899
  **Starting a new project (v1):**
867
900
 
868
901
  ```
869
- /dgs:new-project # Questioning -> PROJECT.md
902
+ /dgs:new-project # Thin skeleton PROJECT.md
870
903
  /clear
871
904
  /dgs:new-milestone # Research -> requirements -> roadmap
872
905
  /clear
@@ -879,7 +912,7 @@ Example config:
879
912
 
880
913
  ```
881
914
  /dgs:init-product # One-time: register repos, create product structure
882
- /dgs:new-project # Questioning -> PROJECT.md
915
+ /dgs:new-project # Thin skeleton PROJECT.md
883
916
  /clear
884
917
  /dgs:new-milestone # Research -> requirements -> roadmap
885
918
  /clear
@@ -944,7 +977,7 @@ Example config:
944
977
  # /dgs:research-idea # Investigate feasibility
945
978
  /dgs:write-spec # Turn ideas into structured spec
946
979
  /clear
947
- /dgs:new-project --auto @spec.md # Create project from spec
980
+ /dgs:new-project <name> # Create project holder
948
981
  /clear
949
982
  /dgs:new-milestone --auto <spec-id> # First milestone from spec
950
983
  ```
@@ -201,6 +201,60 @@ This is the core AI conversion step. Restructure `SOURCE_CONTENT` into a 9-secti
201
201
  Store the full converted PRD as `CONVERTED_PRD`.
202
202
  </step>
203
203
 
204
+ <step name="run_cross_llm_review">
205
+ Run cross-LLM review on the converted PRD before presenting to the user. This matches the review pattern from write-spec.
206
+
207
+ Load the review loop reference for detailed API call mechanics:
208
+ @~/.claude/deliver-great-systems/references/spec-review-loop.md
209
+
210
+ **1. Load review config:**
211
+
212
+ ```bash
213
+ node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs review-config
214
+ ```
215
+
216
+ Parse JSON result. If `has_any_key = false`: warn "No review API keys configured. Edit review-keys.json in your planning root to add OpenAI or Gemini keys. Skipping review." and proceed directly to `present_and_review`.
217
+
218
+ **2. Initialize tracking:**
219
+
220
+ - `round = 0`
221
+ - `total_tokens = { openai: { prompt: 0, completion: 0 }, gemini: { prompt: 0, completion: 0 } }`
222
+ - `rejected_items_history = []`
223
+ - `REVIEW_HISTORY = ""`
224
+
225
+ **3. Loop** (while round < max_rounds):
226
+
227
+ a. Increment round.
228
+ b. Send `CONVERTED_PRD` to available reviewers in parallel using the API call patterns from the reference doc. Issue both curl commands via parallel Bash tool calls.
229
+ c. Handle failures per reference doc error handling rules (retry once, then mark failed).
230
+ d. Parse feedback items from each reviewer's response. Each item: section, severity, feedback text, reviewer name.
231
+ e. **Auto-reject Non-Goal contradictions:** read the `## Non-Goals` section of `CONVERTED_PRD`, reject any feedback that suggests adding something explicitly listed as a Non-Goal. Disposition: `rejected-non-goal`.
232
+ f. **Check convergence:** compare rejected items against `rejected_items_history`. If an item (or substantially similar item) was rejected in the previous round too, move the concern to `## Open Questions` tagged as "From review: [concern]". Disposition: `moved-to-open-questions`.
233
+ g. **Apply accepted feedback:** Claude reads each remaining item and decides whether to apply it by modifying `CONVERTED_PRD`. Disposition: `accepted` (with change description) or `no-action` (with reason).
234
+ h. Build round history entry with all dispositions in the review history table format.
235
+ i. Append round history to `REVIEW_HISTORY` string.
236
+ j. Update token totals from response usage metadata.
237
+ k. **Check exit conditions:**
238
+ - No changes applied (all items rejected, no-action, or moved-to-open-questions) -> EXIT
239
+ - Green-only (all reviewers responded "LGTM" or no actionable feedback) -> EXIT
240
+ - Max rounds reached -> EXIT
241
+ If none met: continue to next round.
242
+
243
+ **4. Display token/cost summary:**
244
+
245
+ ```
246
+ Review complete (N rounds).
247
+ Tokens: OpenAI [X prompt + Y completion] | Gemini [X prompt + Y completion]
248
+ Estimated cost: ~$X.XX
249
+ ```
250
+
251
+ **5. Append review history to CONVERTED_PRD:**
252
+
253
+ If `REVIEW_HISTORY` is non-empty, append it to `CONVERTED_PRD` as a `## Review History` section at the end. This ensures the review history is included when the spec is saved.
254
+
255
+ **Note:** Unlike write-spec, there is no spec file on disk yet. The review operates entirely on the in-memory `CONVERTED_PRD` string. The review history is appended to the content and persisted when the user chooses "save" in the next step.
256
+ </step>
257
+
204
258
  <step name="present_and_review">
205
259
  Present the converted PRD for user review and handle the review loop.
206
260
 
@@ -217,7 +271,7 @@ Present the converted PRD for user review and handle the review loop.
217
271
  {CONVERTED_PRD}
218
272
 
219
273
  ---
220
- Original: will be saved to ${project_root}/{attachment_path}
274
+ Original: will be saved to {attachment_path} (relative to planning root)
221
275
  {If IDEA_IDS is non-empty: "Linking to: " followed by comma-separated IDEA_DISPLAY entries, e.g., "Linking to: IDEA-1 (Phase 0 Foundation Infrastructure), IDEA-3 (Other Idea)"}
222
276
 
223
277
  **Review options:**
@@ -233,7 +287,7 @@ Original: will be saved to ${project_root}/{attachment_path}
233
287
 
234
288
  **If "save":**
235
289
  1. Generate the slug from `SPEC_TITLE` (lowercase, replace non-alphanumeric with hyphens, trim leading/trailing hyphens).
236
- 2. Check if `${project_root}/specs/spec-{slug}.md` already exists. If it does, use AskUserQuestion to prompt: `A spec with slug '{slug}' already exists. Enter a new title:` -- then regenerate the slug from the new title and re-check. Loop until no conflict.
290
+ 2. Check if `specs/spec-{slug}.md` (relative to planning root) already exists. If it does, use AskUserQuestion to prompt: `A spec with slug '{slug}' already exists. Enter a new title:` -- then regenerate the slug from the new title and re-check. Loop until no conflict.
237
291
  3. Compute the slugified source filename: take `SOURCE_FILENAME`, lowercase it, replace non-alphanumeric chars (except dots) with hyphens, trim leading/trailing hyphens, preserve file extension. This matches `docs.slugifyFilename()` behaviour.
238
292
  4. Compute the attachment path: `specs/spec-{slug}/docs/{slugified-source-filename}` (relative to the planning root).
239
293
  5. Call specs create (with --source-ideas when ideas are linked):
@@ -264,7 +318,7 @@ Original: will be saved to ${project_root}/{attachment_path}
264
318
 
265
319
  **Execute the commit:**
266
320
  ```bash
267
- node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs commit "specs: import {id} - {title} (from {original-filename})" --push --files ${project_root}/specs/spec-{slug}.md ${project_root}/{attachment_path} ${project_root}/specs/spec-{slug}/docs/INDEX.md ${project_root}/specs/spec-{slug}/docs/.names.json
321
+ node ~/.claude/deliver-great-systems/bin/dgs-tools.cjs commit "specs: import {id} - {title} (from {original-filename})" --push --files specs/spec-{slug}.md {attachment_path} specs/spec-{slug}/docs/INDEX.md specs/spec-{slug}/docs/.names.json
268
322
  ```
269
323
  The `dgs-tools.cjs commit` helper with `--files` stages only the specified files and commits them. This ensures other unstaged/uncommitted changes in the working tree are not included. The `.names.json` file is included because `docs add` creates it as internal metadata for INDEX rebuilds.
270
324
 
@@ -283,8 +337,8 @@ Original: will be saved to ${project_root}/{attachment_path}
283
337
  ID: {id}
284
338
  Title: {SPEC_TITLE}
285
339
  Status: draft
286
- File: ${project_root}/{filename path from specs create result}
287
- Source: ${project_root}/{attachment_path}
340
+ File: {filename path from specs create result} (relative to planning root)
341
+ Source: {attachment_path} (relative to planning root)
288
342
  Committed: specs: import {id} - {title} (from {original-filename})
289
343
  {If IDEA_IDS is non-empty: "Linked ideas: IDEA-1, IDEA-3 (unchanged state)"}
290
344
 
@@ -298,8 +352,8 @@ Original: will be saved to ${project_root}/{attachment_path}
298
352
  ID: {id}
299
353
  Title: {SPEC_TITLE}
300
354
  Status: draft
301
- File: ${project_root}/{filename path from specs create result}
302
- Source: ${project_root}/{attachment_path}
355
+ File: {filename path from specs create result} (relative to planning root)
356
+ Source: {attachment_path} (relative to planning root)
303
357
  {If IDEA_IDS is non-empty: "Linked ideas: IDEA-1, IDEA-3 (unchanged state)"}
304
358
 
305
359
  Next steps:
@@ -360,6 +414,10 @@ Stop execution.
360
414
  - [ ] Requirements use explicit language signal mapping (must/critical -> P0, should/important -> P1, could/nice-to-have -> P2) with P1 default
361
415
  - [ ] Requirements preserve original identifiers if numbered in source
362
416
  - [ ] Implementation Notes reference real files and patterns when codebase context available
417
+ - [ ] Cross-LLM review runs after conversion (when review keys configured)
418
+ - [ ] Review feedback applied to CONVERTED_PRD in-memory before user presentation
419
+ - [ ] Review history appended to spec content and persisted on save
420
+ - [ ] Missing review keys skip review with warning (non-blocking)
363
421
  - [ ] Spec title is auto-generated from source content
364
422
  - [ ] Full converted PRD is displayed for review with attachment path shown
365
423
  - [ ] Linked ideas displayed in review when --ideas provided