@ktpartners/dgs-platform 2.7.5 → 2.9.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 (57) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +15 -12
  3. package/agents/dgs-executor.md +0 -52
  4. package/deliver-great-systems/bin/dgs-tools.cjs +66 -10
  5. package/deliver-great-systems/bin/lib/commands.cjs +1 -8
  6. package/deliver-great-systems/bin/lib/config.cjs +9 -90
  7. package/deliver-great-systems/bin/lib/context.cjs +2 -2
  8. package/deliver-great-systems/bin/lib/context.test.cjs +100 -100
  9. package/deliver-great-systems/bin/lib/core.cjs +17 -57
  10. package/deliver-great-systems/bin/lib/core.test.cjs +166 -170
  11. package/deliver-great-systems/bin/lib/docs.cjs +3 -3
  12. package/deliver-great-systems/bin/lib/docs.test.cjs +14 -7
  13. package/deliver-great-systems/bin/lib/execution.cjs +2 -2
  14. package/deliver-great-systems/bin/lib/execution.test.cjs +65 -67
  15. package/deliver-great-systems/bin/lib/ideas.cjs +4 -4
  16. package/deliver-great-systems/bin/lib/ideas.test.cjs +45 -44
  17. package/deliver-great-systems/bin/lib/init.cjs +9 -4
  18. package/deliver-great-systems/bin/lib/init.test.cjs +242 -175
  19. package/deliver-great-systems/bin/lib/jobs.cjs +1 -1
  20. package/deliver-great-systems/bin/lib/jobs.test.cjs +203 -202
  21. package/deliver-great-systems/bin/lib/migration.cjs +256 -281
  22. package/deliver-great-systems/bin/lib/migration.test.cjs +385 -440
  23. package/deliver-great-systems/bin/lib/milestone.cjs +1 -1
  24. package/deliver-great-systems/bin/lib/overlap.cjs +4 -4
  25. package/deliver-great-systems/bin/lib/overlap.test.cjs +45 -44
  26. package/deliver-great-systems/bin/lib/path-audit.test.cjs +16 -22
  27. package/deliver-great-systems/bin/lib/paths.cjs +60 -59
  28. package/deliver-great-systems/bin/lib/paths.test.cjs +192 -225
  29. package/deliver-great-systems/bin/lib/phase.cjs +5 -4
  30. package/deliver-great-systems/bin/lib/projects.cjs +8 -8
  31. package/deliver-great-systems/bin/lib/projects.test.cjs +75 -74
  32. package/deliver-great-systems/bin/lib/repos.cjs +94 -230
  33. package/deliver-great-systems/bin/lib/repos.test.cjs +84 -75
  34. package/deliver-great-systems/bin/lib/search.cjs +4 -4
  35. package/deliver-great-systems/bin/lib/specs.cjs +2 -2
  36. package/deliver-great-systems/bin/lib/sync.cjs +1 -1
  37. package/deliver-great-systems/bin/lib/template.cjs +3 -3
  38. package/deliver-great-systems/bin/lib/test-helpers.cjs +59 -162
  39. package/deliver-great-systems/bin/lib/verify.cjs +3 -3
  40. package/deliver-great-systems/references/planning-config.md +7 -8
  41. package/deliver-great-systems/workflows/add-tests.md +1 -1
  42. package/deliver-great-systems/workflows/approve-spec.md +1 -11
  43. package/deliver-great-systems/workflows/complete-milestone.md +2 -2
  44. package/deliver-great-systems/workflows/consolidate-ideas.md +1 -1
  45. package/deliver-great-systems/workflows/create-milestone-job.md +2 -2
  46. package/deliver-great-systems/workflows/discuss-phase.md +2 -2
  47. package/deliver-great-systems/workflows/execute-phase.md +63 -4
  48. package/deliver-great-systems/workflows/execute-plan.md +0 -51
  49. package/deliver-great-systems/workflows/find-related-ideas.md +1 -1
  50. package/deliver-great-systems/workflows/help.md +55 -84
  51. package/deliver-great-systems/workflows/init-product.md +14 -451
  52. package/deliver-great-systems/workflows/map-codebase.md +109 -0
  53. package/deliver-great-systems/workflows/new-milestone.md +16 -6
  54. package/deliver-great-systems/workflows/new-project.md +22 -681
  55. package/deliver-great-systems/workflows/quick.md +2 -2
  56. package/deliver-great-systems/workflows/run-job.md +56 -0
  57. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -8,6 +8,36 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [2.9.0] - 2026-03-25
12
+
13
+ ### Changed
14
+ - **new-project/new-milestone split** — `/dgs:new-project` now only handles questioning and PROJECT.md creation; all milestone-scoped work (research, requirements, roadmap, STATE.md) moves to `/dgs:new-milestone`, which now handles both first and subsequent milestones
15
+ - **Codereview gate moved to orchestrator** — code review execution moved from `dgs-executor` (which lacks Task tool) to `execute-phase` orchestrator where Task spawning is available; skips in non-interactive/job mode with log message
16
+ - **Map-codebase staleness gate** — in `--auto` mode (job runs), checks git history since last map; skips if no changes, narrows to single repo if only one changed; `--force` flag bypasses
17
+
18
+ ### Added
19
+ - **Job file commit+push on status changes** — `run-job` now commits and pushes the job file after every step status update (in-progress, completed, failed, move operations), making job progress visible on remote in real time
20
+ - **First-milestone guards in new-milestone** — handles missing MILESTONES.md/STATE.md gracefully with v1.0 default, phase-1 numbering, greenfield research framing, and STATE.md creation
21
+
22
+ ### Fixed
23
+ - **Codereview silent failure in job mode** — codereview was silently skipped in job mode because the executor agent lacked Task/Agent tools needed to spawn the 9 review subagents
24
+
25
+ ## [2.8.0] - 2026-03-25
26
+
27
+ ### Changed
28
+ - **Root layout consolidation (v18.0)** — DGS now uses a single root layout format exclusively; the `.planning/` prefix path is no longer supported
29
+ - **Path resolution simplified** — `getPlanningRoot()` reduced to a single `git rev-parse --show-toplevel` call with per-process cache, removing the detection cascade
30
+ - **V1 support removed** — V1 single-repo installs are rejected with a clear error and `V1_UNSUPPORTED.md` guidance file; all V1-to-V2 migration code removed from `migration.cjs`
31
+
32
+ ### Added
33
+ - **Automatic .planning/-to-root migration** — `migrateDotPlanningToRoot()` auto-migrates existing `.planning/` layouts on first DGS command with conflict detection, dry-run mode, rollback on failure, and non-git fallback
34
+ - **Migration CLI** — `dgs-tools migrate --layout root` for manual triggering with `--dry-run` preview
35
+
36
+ ### Fixed
37
+ - **Zero .planning references in production code** — all hardcoded `.planning` path literals removed from 20+ production modules and 11 workflow files (including 181 reference doc references)
38
+ - **Test suite root-layout-only** — all 12 test files converted to root-layout fixtures; V1 detection and dual-layout test cases removed; comprehensive migration coverage added (6 scenarios)
39
+ - **Stale test assertions** — removed `dotplanning` assertion from `init.test.cjs` and vestigial `planningRoot` write from `repos.cjs`
40
+
11
41
  ## [2.7.5] - 2026-03-22
12
42
 
13
43
  ### Added
package/README.md CHANGED
@@ -194,7 +194,7 @@ If you prefer not to use that flag, add this to your project's `.claude/settings
194
194
 
195
195
  DGS operates at the **product** level. A product contains one or more **projects**, each with its own milestones and phases. Ideas and specs live at the product level and feed into project or milestone creation.
196
196
 
197
- > **Already have code?** Run `/dgs:map-codebase` first. It spawns parallel agents per registered repo to analyze stack, architecture, structure, conventions, testing, integrations, and concerns. Per-repo maps are synthesized into unified top-level files. Then `/dgs:new-project` knows your codebasequestions focus on what you're adding, and planning automatically loads your patterns. Update a single repo after changes with `/dgs:map-codebase <repo-name>`.
197
+ > **Already have code?** Run `/dgs:map-codebase` first. It spawns parallel agents per registered repo to analyze stack, architecture, structure, conventions, testing, integrations, and concerns. Per-repo maps are synthesized into unified top-level files. Then `/dgs:new-project` captures your project identity goals, constraints, and scope. `/dgs:new-milestone` takes it from there with research, requirements, and roadmap. Update a single repo after changes with `/dgs:map-codebase <repo-name>`.
198
198
 
199
199
  ### 1. Set Up Product
200
200
 
@@ -236,18 +236,21 @@ If you have OpenAI or Gemini API keys configured, the spec goes through a **cros
236
236
 
237
237
  ```
238
238
  /dgs:new-project
239
+ /dgs:new-milestone
239
240
  ```
240
241
 
241
- One command, one flow. The system:
242
+ Two commands, one setup. First, `/dgs:new-project` asks questions until it understands your idea completely — goals, constraints, tech preferences, edge cases — then creates `PROJECT.md`.
243
+
244
+ Then `/dgs:new-milestone` takes over:
242
245
 
243
- 1. **Questions** — Asks until it understands your idea completely (goals, constraints, tech preferences, edge cases)
244
- 2. **Research** — Spawns parallel agents to investigate the domain (optional but recommended)
245
- 3. **Requirements** — Extracts what's v1, v2, and out of scope
246
- 4. **Roadmap** — Creates phases mapped to requirements
246
+ 1. **Research** — Spawns parallel agents to investigate the domain (optional but recommended)
247
+ 2. **Requirements** — Extracts what's v1, v2, and out of scope
248
+ 3. **Roadmap** — Creates phases mapped to requirements
247
249
 
248
250
  You approve the roadmap. Now you're ready to build.
249
251
 
250
- **Creates:** `PROJECT.md`, `REQUIREMENTS.md`, `ROADMAP.md`, `STATE.md`, `.planning/research/`
252
+ **`new-project` creates:** `PROJECT.md`
253
+ **`new-milestone` creates:** `REQUIREMENTS.md`, `ROADMAP.md`, `STATE.md`, `research/`
251
254
 
252
255
  ---
253
256
 
@@ -393,7 +396,7 @@ When all phases are done, `/dgs:complete-milestone` archives the milestone and t
393
396
 
394
397
  **Automated alternative:** Instead of running each phase command manually, use `/dgs:create-milestone-job` to generate a build job and `/dgs:run-job` to execute the entire milestone pipeline automatically with subagent isolation per step. See the [User Guide](docs/USER-GUIDE.md#milestone-jobs) for details.
395
398
 
396
- Then `/dgs:new-milestone` starts the next version same flow as `new-project` but for your existing codebase. You describe what you want to build next, the system researches the domain, you scope requirements, and it creates a fresh roadmap. Each milestone is a clean cycle: define → build → ship.
399
+ Then `/dgs:new-milestone` starts the next cycle. This is the same command used after `new-project` it handles research, requirements, and roadmap for each version. You describe what you want to build next, it researches the domain, you scope requirements, and it creates a fresh roadmap. Each milestone is a clean cycle: define → build → ship.
397
400
 
398
401
  ---
399
402
 
@@ -460,7 +463,7 @@ DGS handles it for you:
460
463
  | `REQUIREMENTS.md` | Scoped v1/v2 requirements with phase traceability |
461
464
  | `ROADMAP.md` | Where you're going, what's done |
462
465
  | `STATE.md` | Decisions, blockers, position — memory across sessions |
463
- | `docs/product/` | Product-level documents (architecture, summary) — loaded as context by write-spec, plan-phase, new-project, new-milestone |
466
+ | `docs/product/` | Product-level documents (architecture, summary) — loaded as context by write-spec, plan-phase, new-milestone |
464
467
  | `codebase/` | Per-repo maps + unified synthesis from `/dgs:map-codebase` |
465
468
  | `research/` | Ecosystem knowledge (stack, features, architecture, pitfalls) |
466
469
  | `PLAN.md` | Atomic task with XML structure, verification steps |
@@ -554,7 +557,7 @@ See the [User Guide](docs/USER-GUIDE.md#context-tiers) for the complete command-
554
557
 
555
558
  | Command | What it does |
556
559
  |---------|--------------|
557
- | `/dgs:new-project [--auto]` | Full initialization: questionsresearch → requirements → roadmap |
560
+ | `/dgs:new-project [--auto]` | Project identity: questioningPROJECT.md |
558
561
  | `/dgs:discuss-phase [N] [--auto]` | Capture implementation decisions before planning |
559
562
  | `/dgs:plan-phase [N] [--auto]` | Research + plan + verify for a phase |
560
563
  | `/dgs:execute-phase <N>` | Execute all plans in parallel waves, verify when complete |
@@ -562,7 +565,7 @@ See the [User Guide](docs/USER-GUIDE.md#context-tiers) for the complete command-
562
565
  | `/dgs:audit-phase <phase> [--rerun-failed]` | Automated phase verification: test execution + structural inspection |
563
566
  | `/dgs:audit-milestone` | Verify milestone achieved its definition of done |
564
567
  | `/dgs:complete-milestone` | Archive milestone, tag release |
565
- | `/dgs:new-milestone [name]` | Start next version: questions → research → requirements → roadmap |
568
+ | `/dgs:new-milestone [name]` | Start milestone: research → requirements → roadmap (first or subsequent) |
566
569
 
567
570
  ### Navigation
568
571
 
@@ -665,7 +668,7 @@ See the [User Guide](docs/USER-GUIDE.md#context-tiers) for the complete command-
665
668
 
666
669
  ## Configuration
667
670
 
668
- DGS stores product-level settings in `.planning/config.json`. This file is shared across all projects in the product. Configure during `/dgs:init-product` or `/dgs:new-project`, and update later with `/dgs:settings`. For the full config schema, workflow toggles, git branching options, and per-agent model breakdown, see the [User Guide](docs/USER-GUIDE.md#configuration-reference).
671
+ DGS stores product-level settings in `.planning/config.json`. This file is shared across all projects in the product. Configure during `/dgs:init-product`, and update later with `/dgs:settings`. For the full config schema, workflow toggles, git branching options, and per-agent model breakdown, see the [User Guide](docs/USER-GUIDE.md#configuration-reference).
669
672
 
670
673
  ### Core Settings
671
674
 
@@ -516,57 +516,6 @@ node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" commit "docs({phase
516
516
 
517
517
  Separate from per-task commits — captures execution results only.
518
518
  </final_commit>
519
-
520
- <codereview_gate>
521
- Check if code review is enabled:
522
-
523
- ```bash
524
- CODEREVIEW=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" config-get workflow.codereview 2>/dev/null || echo "false")
525
- ```
526
-
527
- If `CODEREVIEW` is `true`:
528
-
529
- Display:
530
- ```
531
- ------------------------------------------------------------
532
- DGS > SPAWNING CODE REVIEW
533
- ------------------------------------------------------------
534
-
535
- Reviewing {phase}-{plan} changes across 3 passes...
536
- ```
537
-
538
- Compute diff reference for the plan's task commits:
539
-
540
- ```bash
541
- 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)
542
- ```
543
-
544
- If FIRST_TASK_COMMIT is empty (no task commits found), skip codereview with message: "No task commits found for {phase}-{plan}, skipping code review."
545
-
546
- Otherwise, invoke the codereview workflow:
547
-
548
- ```
549
- @~/.claude/deliver-great-systems/workflows/codereview.md
550
- ```
551
-
552
- With inputs:
553
- - PHASE: ${PHASE}
554
- - PLAN: ${PLAN}
555
- - PLAN_PATH: ${phase_dir}/{phase}-{plan}-PLAN.md
556
- - PHASE_DIR: ${phase_dir}
557
- - DIFF_REF: ${FIRST_TASK_COMMIT}^..HEAD
558
-
559
- After codereview completes:
560
- - If auto-fixes were committed, the fix commit hash is noted in the codereview output
561
- - The SUMMARY.md already has codereview findings appended and CODEREVIEW.md has been created with the full report (both done by codereview workflow)
562
- - If the codereview workflow committed auto-fixes, amend the metadata commit to include the updated SUMMARY.md and CODEREVIEW.md:
563
- ```bash
564
- node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" commit "" --files ${phase_dir}/{phase}-{plan}-SUMMARY.md ${phase_dir}/{phase}-{plan}-CODEREVIEW.md --amend
565
- ```
566
-
567
- If `CODEREVIEW` is `false` or absent: skip silently (no output).
568
- </codereview_gate>
569
-
570
519
  <completion_format>
571
520
  ```markdown
572
521
  ## PLAN COMPLETE
@@ -596,6 +545,5 @@ Plan execution complete when:
596
545
  - [ ] STATE.md updated (position, decisions, issues, session)
597
546
  - [ ] ROADMAP.md updated with plan progress (via `roadmap update-plan-progress`)
598
547
  - [ ] Final metadata commit made (includes SUMMARY.md, STATE.md, ROADMAP.md)
599
- - [ ] Codereview gate checked (if enabled: codereview invoked, if auto-fixes committed: metadata commit amended)
600
548
  - [ ] Completion format returned to orchestrator
601
549
  </success_criteria>
@@ -22,7 +22,7 @@
22
22
  * current-timestamp [format] Get timestamp (full|date|filename)
23
23
  * list-todos [area] Count and enumerate pending todos
24
24
  * verify-path-exists <path> Check file/directory existence
25
- * config-ensure-section Initialize .planning/config.json
25
+ * config-ensure-section Initialize config.json
26
26
  * review-config Load review config with defaults
27
27
  * check-config-gitignore Check if config.json needs .gitignore
28
28
  * history-digest Aggregate all SUMMARY.md data
@@ -55,7 +55,7 @@
55
55
  *
56
56
  * Validation:
57
57
  * validate consistency Check phase numbering, disk/roadmap sync
58
- * validate health [--repair] Check .planning/ integrity, optionally repair
58
+ * validate health [--repair] Check planning file integrity, optionally repair
59
59
  *
60
60
  * Progress:
61
61
  * progress [json|table|bar] Render progress in various formats
@@ -70,6 +70,11 @@
70
70
  * scaffold phase-dir --phase <N> Create phase directory
71
71
  * --name <name>
72
72
  *
73
+ * Migration:
74
+ * migrate --layout root Migrate .planning/ to root layout
75
+ * [--dry-run] Show what would change without modifying
76
+ * [--raw] JSON output for scripting
77
+ *
73
78
  * Context:
74
79
  * context load-tier <name> Get file list for a context tier
75
80
  * [--phase N] [--idea N] [--spec N] Scope-specific enrichment
@@ -167,7 +172,6 @@
167
172
  * repos scan-tags <phase-dir> Scan plan files for <repos> tags
168
173
  * repos auto-populate <plan-file> Auto-populate <repos> tags from <files> paths
169
174
  * repos validate-consistency <plan> Validate <repos>/<files> consistency
170
- * repos migrate <slug> Migrate v1 install to v2 structure
171
175
  *
172
176
  * Sync:
173
177
  * sync pull [--dry-run] [--force] Pull from all repos (ff-only)
@@ -279,6 +283,7 @@ const mergeConflicts = require('./lib/merge-conflicts.cjs');
279
283
  const conflictAgent = require('./lib/conflict-agent.cjs');
280
284
  const { requireGitIdentity, formatAuthorString, cmdIdentityResolve } = require('./lib/identity.cjs');
281
285
  const { pullAll, pushAll, getCadence, checkStaleState, shouldShowFirstRunHint, markFirstRunHintShown, isWithinSuppressionWindow, recordPromptYes } = require('./lib/sync.cjs');
286
+ const { migrateDotPlanningToRoot, rejectV1Install } = require('./lib/migration.cjs');
282
287
 
283
288
  // ─── Identity Gate ────────────────────────────────────────────────────────────
284
289
 
@@ -564,8 +569,32 @@ async function main() {
564
569
  const command = args[0];
565
570
  const cwd = process.cwd();
566
571
 
572
+ // V1 rejection: single call site — library callers skip this guard
573
+ rejectV1Install(cwd);
574
+
575
+ // .planning/ to root layout migration: auto-trigger before command dispatch
576
+ // Silent migration with compact banner — original command continues after
577
+ // Skip auto-trigger when user explicitly invokes 'migrate' (they control the options)
578
+ if (command !== 'migrate') try {
579
+ const migrationResult = migrateDotPlanningToRoot(cwd);
580
+ if (migrationResult.migrated) {
581
+ const parts = [`DGS migrated .planning/ to root layout. ${migrationResult.filesMoved} file(s) moved.`];
582
+ if (migrationResult.identicalResolved > 0) {
583
+ parts.push(`${migrationResult.identicalResolved} identical file(s) resolved (kept root copy).`);
584
+ }
585
+ if (migrationResult.commitHash) {
586
+ parts.push(`See commit ${migrationResult.commitHash}.`);
587
+ }
588
+ process.stderr.write(parts.join(' ') + '\n');
589
+ }
590
+ } catch {
591
+ // Migration errors are already handled by error() inside migrateDotPlanningToRoot.
592
+ // This catch handles unexpected errors — let command continue if migration
593
+ // fails for unexpected reasons (defensive, should not normally trigger).
594
+ }
595
+
567
596
  if (!command) {
568
- error('Usage: dgs-tools <command> [args] [--raw]\nCommands: state, resolve-model, find-phase, commit, verify-summary, verify, frontmatter, template, generate-slug, current-timestamp, list-todos, verify-path-exists, config-ensure-section, repos, projects, overlap, merge-conflicts, conflict-agent, init');
597
+ error('Usage: dgs-tools <command> [args] [--raw]\nCommands: state, resolve-model, find-phase, commit, verify-summary, verify, frontmatter, template, generate-slug, current-timestamp, list-todos, verify-path-exists, config-ensure-section, repos, projects, overlap, merge-conflicts, conflict-agent, init, migrate');
569
598
  }
570
599
 
571
600
  switch (command) {
@@ -927,13 +956,8 @@ async function main() {
927
956
  } else if (subcommand === 'validate-consistency') {
928
957
  const planFile = args[2];
929
958
  repos.cmdReposValidateConsistency(cwd, planFile, raw);
930
- } else if (subcommand === 'migrate') {
931
- const migrationMod = require('./lib/migration.cjs');
932
- const slug = args[2];
933
- if (!slug) error('Usage: repos migrate <slug>');
934
- migrationMod.cmdMigrateV1ToV2(cwd, slug, raw);
935
959
  } else {
936
- error('Unknown repos subcommand. Available: list, add, remove, validate, resolve, init-product, detect-layout, scan-tags, auto-populate, validate-consistency, migrate');
960
+ error('Unknown repos subcommand. Available: list, add, remove, validate, resolve, init-product, detect-layout, scan-tags, auto-populate, validate-consistency');
937
961
  }
938
962
  break;
939
963
  }
@@ -1723,6 +1747,38 @@ async function main() {
1723
1747
  break;
1724
1748
  }
1725
1749
 
1750
+ case 'migrate': {
1751
+ const layoutIdx = args.indexOf('--layout');
1752
+ const layout = layoutIdx !== -1 ? args[layoutIdx + 1] : null;
1753
+ if (layout !== 'root') {
1754
+ error('Usage: dgs-tools migrate --layout root [--dry-run] [--raw]');
1755
+ }
1756
+ const dryRun = args.includes('--dry-run');
1757
+ const result = migrateDotPlanningToRoot(cwd, { dryRun });
1758
+ if (raw) {
1759
+ const { output: out } = require('./lib/core.cjs');
1760
+ out(result, raw);
1761
+ } else if (result.dryRun) {
1762
+ if (result.actions.length === 0) {
1763
+ process.stderr.write('Nothing to migrate. Already in root layout.\n');
1764
+ } else {
1765
+ process.stderr.write('Dry run — the following changes would be made:\n');
1766
+ for (const action of result.actions) {
1767
+ const label = action.type === 'identical' ? '(identical, delete .planning copy)' : '';
1768
+ process.stderr.write(` ${action.from} -> ${action.to} ${label}\n`);
1769
+ }
1770
+ process.stderr.write(`\n${result.filesMoved} file(s) to move, ${result.identicalResolved} identical conflict(s) to resolve.\n`);
1771
+ }
1772
+ } else if (result.migrated) {
1773
+ process.stderr.write(`Migration complete. ${result.filesMoved} file(s) moved.`);
1774
+ if (result.commitHash) process.stderr.write(` Commit: ${result.commitHash}`);
1775
+ process.stderr.write('\n');
1776
+ } else {
1777
+ process.stderr.write('Nothing to migrate. Already in root layout.\n');
1778
+ }
1779
+ break;
1780
+ }
1781
+
1726
1782
  default:
1727
1783
  error(`Unknown command: ${command}`);
1728
1784
  }
@@ -228,15 +228,8 @@ function cmdCommit(cwd, message, files, raw, amend, push) {
228
228
  return;
229
229
  }
230
230
 
231
- // Check if .planning is gitignored
232
- if (isGitIgnored(cwd, '.planning')) {
233
- const result = { committed: false, hash: null, reason: 'skipped_gitignored' };
234
- output(result, raw, 'skipped');
235
- return;
236
- }
237
-
238
231
  // Stage files
239
- const filesToStage = files && files.length > 0 ? files : ['.planning/'];
232
+ const filesToStage = files && files.length > 0 ? files : ['.'];
240
233
  for (const file of filesToStage) {
241
234
  execGit(cwd, ['add', file]);
242
235
  }
@@ -9,7 +9,7 @@
9
9
  * writeConfigField routes writes to the correct file based on isLocalKey().
10
10
  * loadConfig (in core.cjs) merges both files with local overriding shared.
11
11
  *
12
- * Zero hardcoded .planning/config.json paths -- all resolved via getPlanningRoot.
12
+ * Zero hardcoded config.json paths -- all resolved via getPlanningRoot.
13
13
  */
14
14
 
15
15
  const fs = require('fs');
@@ -33,7 +33,7 @@ const VALID_CONFIG_KEYS = new Set([
33
33
  'search_gitignored', 'brave_search',
34
34
  'workflow.research', 'workflow.plan_check', 'workflow.verifier',
35
35
  'workflow.nyquist_validation', 'workflow.ui_phase', 'workflow.ui_safety_gate',
36
- 'workflow._auto_chain_active', 'workflow.discipline',
36
+ 'workflow._auto_chain_active', 'workflow.discipline', 'workflow.codereview',
37
37
  'git.base_branch', 'git.branching_strategy', 'git.phase_branch_template', 'git.milestone_branch_template',
38
38
  'git.sync', 'git.sync_push', 'git.sync_pull',
39
39
  'planning.commit_docs', 'planning.search_gitignored',
@@ -63,21 +63,13 @@ function getLocalConfigPath(cwd) {
63
63
  * @deprecated Use getSharedConfigPath or getLocalConfigPath instead.
64
64
  * Resolve the config file path for the given cwd and mode.
65
65
  * Now returns config.json (shared) for both read and write modes.
66
- * Falls back to legacy dgs.config.json for read mode.
67
66
  *
68
67
  * @param {string} cwd - Working directory
69
68
  * @param {'read'|'write'} mode - 'read' or 'write'
70
69
  * @returns {string} Absolute path to the config file
71
70
  */
72
71
  function getConfigPath(cwd, mode) {
73
- const root = getPlanningRoot(cwd);
74
- const sharedPath = path.join(root, 'config.json');
75
- if (mode === 'write') return sharedPath;
76
- // Read mode: prefer config.json, fall back to legacy dgs.config.json
77
- if (fs.existsSync(sharedPath)) return sharedPath;
78
- const legacyPath = path.join(root, 'dgs.config.json');
79
- if (fs.existsSync(legacyPath)) return legacyPath;
80
- return sharedPath; // default when neither exists
72
+ return getSharedConfigPath(cwd);
81
73
  }
82
74
 
83
75
  /**
@@ -120,56 +112,6 @@ function _writeJson(filePath, data) {
120
112
  fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf-8');
121
113
  }
122
114
 
123
- /**
124
- * Perform a one-time migration of legacy dgs.config.json to the two-file layout.
125
- * Separates local keys from shared keys and writes to the appropriate files.
126
- *
127
- * @param {string} cwd - Working directory
128
- * @returns {boolean} True if migration was performed
129
- */
130
- function _migrateLegacyConfig(cwd) {
131
- const root = getPlanningRoot(cwd);
132
- const legacyPath = path.join(root, 'dgs.config.json');
133
- const sharedPath = path.join(root, 'config.json');
134
- const localPath = path.join(root, 'config.local.json');
135
-
136
- if (!fs.existsSync(legacyPath)) return false;
137
- if (fs.existsSync(sharedPath) || fs.existsSync(localPath)) return false;
138
-
139
- try {
140
- const legacy = JSON.parse(fs.readFileSync(legacyPath, 'utf-8'));
141
- const shared = {};
142
- const local = {};
143
-
144
- for (const [key, value] of Object.entries(legacy)) {
145
- if (LOCAL_KEYS.has(key)) {
146
- local[key] = value;
147
- } else if (key === 'git' && typeof value === 'object') {
148
- // Split git section: sync_hint_shown is local, rest is shared
149
- const gitShared = {};
150
- for (const [gk, gv] of Object.entries(value)) {
151
- if (gk === 'sync_hint_shown') {
152
- local.sync_hint_shown = gv;
153
- } else {
154
- gitShared[gk] = gv;
155
- }
156
- }
157
- if (Object.keys(gitShared).length > 0) {
158
- shared.git = gitShared;
159
- }
160
- } else {
161
- shared[key] = value;
162
- }
163
- }
164
-
165
- if (Object.keys(shared).length > 0) _writeJson(sharedPath, shared);
166
- if (Object.keys(local).length > 0) _writeJson(localPath, local);
167
- return true;
168
- } catch {
169
- return false;
170
- }
171
- }
172
-
173
115
  function cmdConfigEnsureSection(cwd, raw) {
174
116
  const sharedPath = getSharedConfigPath(cwd);
175
117
  const parentDir = path.dirname(sharedPath);
@@ -183,23 +125,13 @@ function cmdConfigEnsureSection(cwd, raw) {
183
125
  error('Failed to create config directory: ' + err.message);
184
126
  }
185
127
 
186
- // Check if config already exists (shared config.json or legacy dgs.config.json)
128
+ // Check if config already exists
187
129
  if (fs.existsSync(sharedPath)) {
188
130
  const result = { created: false, reason: 'already_exists' };
189
131
  output(result, raw, 'exists');
190
132
  return;
191
133
  }
192
134
 
193
- // Check for legacy dgs.config.json and migrate if found
194
- const root = getPlanningRoot(cwd);
195
- const legacyPath = path.join(root, 'dgs.config.json');
196
- if (fs.existsSync(legacyPath)) {
197
- _migrateLegacyConfig(cwd);
198
- const result = { created: false, reason: 'already_exists' };
199
- output(result, raw, 'exists');
200
- return;
201
- }
202
-
203
135
  // Detect Brave Search API key availability
204
136
  const homedir = require('os').homedir();
205
137
  const braveKeyFile = path.join(homedir, '.dgs', 'brave_api_key');
@@ -342,15 +274,10 @@ function cmdConfigGet(cwd, keyPath, raw) {
342
274
  const shared = _readJsonSafe(getSharedConfigPath(cwd));
343
275
  const local = _readJsonSafe(getLocalConfigPath(cwd));
344
276
 
345
- // Fall back to legacy dgs.config.json if neither new file has data
346
277
  let config;
347
278
  if (Object.keys(shared).length === 0 && Object.keys(local).length === 0) {
348
- const root = getPlanningRoot(cwd);
349
- const legacyPath = path.join(root, 'dgs.config.json');
350
- config = _readJsonSafe(legacyPath);
351
- if (Object.keys(config).length === 0) {
352
- error('No config file found at ' + getSharedConfigPath(cwd));
353
- }
279
+ config = {};
280
+ error('No config file found at ' + getSharedConfigPath(cwd));
354
281
  } else {
355
282
  config = { ...shared, ...local };
356
283
  }
@@ -386,12 +313,8 @@ function cmdConfigGet(cwd, keyPath, raw) {
386
313
  * @returns {object} Updated merged config object
387
314
  */
388
315
  function writeConfigField(cwd, keyPath, value) {
389
- // Attempt migration if needed
390
316
  const sharedPath = getSharedConfigPath(cwd);
391
317
  const localPath = getLocalConfigPath(cwd);
392
- if (!fs.existsSync(sharedPath) && !fs.existsSync(localPath)) {
393
- _migrateLegacyConfig(cwd);
394
- }
395
318
 
396
319
  // git.sync is a virtual shorthand -- sets both sync_push and sync_pull in shared config
397
320
  if (keyPath === 'git.sync') {
@@ -533,9 +456,7 @@ function checkConfigGitignore(cwd) {
533
456
  const content = fs.readFileSync(gitignorePath, 'utf-8');
534
457
  const lines = content.split('\n').map((l) => l.trim());
535
458
  gitignoreCoversReviewKeys = lines.some(
536
- (line) =>
537
- line === 'review-keys.json' ||
538
- line === '.planning/review-keys.json'
459
+ (line) => line === 'review-keys.json'
539
460
  );
540
461
  }
541
462
  } catch {
@@ -569,8 +490,8 @@ function ensureConfigGitignored(cwd) {
569
490
 
570
491
  // Check if already present
571
492
  const lines = content.split('\n').map((l) => l.trim());
572
- const hasLocalConfig = lines.some((line) => line === 'config.local.json' || line === '.planning/config.local.json');
573
- const hasReviewKeys = lines.some((line) => line === 'review-keys.json' || line === '.planning/review-keys.json');
493
+ const hasLocalConfig = lines.some((line) => line === 'config.local.json');
494
+ const hasReviewKeys = lines.some((line) => line === 'review-keys.json');
574
495
 
575
496
  if (hasLocalConfig && hasReviewKeys) {
576
497
  return { added: false, reason: 'already_present' };
@@ -581,12 +502,10 @@ function ensureConfigGitignored(cwd) {
581
502
  if (!hasLocalConfig) {
582
503
  entry += '\n# DGS local config (per-machine state)\n';
583
504
  entry += 'config.local.json\n';
584
- entry += '.planning/config.local.json\n';
585
505
  }
586
506
  if (!hasReviewKeys) {
587
507
  entry += '\n# DGS review keys (contains API keys)\n';
588
508
  entry += 'review-keys.json\n';
589
- entry += '.planning/review-keys.json\n';
590
509
  }
591
510
  fs.writeFileSync(gitignorePath, content + entry, 'utf-8');
592
511
  return { added: true };
@@ -531,7 +531,7 @@ function getMilestoneSummaries(cwd, planningRoot, currentPhaseNum) {
531
531
  const { getProjectRoot } = require('./core.cjs');
532
532
  projectRoot = getProjectRoot(cwd);
533
533
  } catch {
534
- projectRoot = path.relative(cwd, planningRoot) || '.planning';
534
+ projectRoot = path.relative(cwd, planningRoot) || '.';
535
535
  }
536
536
 
537
537
  const phasesDir = path.join(cwd, projectRoot, 'phases');
@@ -818,7 +818,7 @@ function loadTierInternal(tierName, planningRoot, options) {
818
818
  let relPath;
819
819
  if (entry._fromScope) {
820
820
  relPath = entry.path;
821
- } else if (entry.path.startsWith(planRootRel) || entry.path.startsWith('.planning')) {
821
+ } else if (entry.path.startsWith(planRootRel)) {
822
822
  // Already relative to cwd
823
823
  relPath = entry.path;
824
824
  } else {