@ktpartners/dgs-platform 2.7.4 → 2.8.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/CHANGELOG.md +25 -0
- package/agents/dgs-executor.md +0 -52
- package/deliver-great-systems/bin/dgs-tools.cjs +66 -10
- package/deliver-great-systems/bin/lib/commands.cjs +1 -8
- package/deliver-great-systems/bin/lib/config.cjs +9 -90
- package/deliver-great-systems/bin/lib/context.cjs +2 -2
- package/deliver-great-systems/bin/lib/context.test.cjs +100 -100
- package/deliver-great-systems/bin/lib/core.cjs +17 -57
- package/deliver-great-systems/bin/lib/core.test.cjs +166 -170
- package/deliver-great-systems/bin/lib/docs.cjs +3 -3
- package/deliver-great-systems/bin/lib/docs.test.cjs +14 -7
- package/deliver-great-systems/bin/lib/execution.cjs +2 -2
- package/deliver-great-systems/bin/lib/execution.test.cjs +65 -67
- package/deliver-great-systems/bin/lib/ideas.cjs +4 -4
- package/deliver-great-systems/bin/lib/ideas.test.cjs +45 -44
- package/deliver-great-systems/bin/lib/init.cjs +9 -4
- package/deliver-great-systems/bin/lib/init.test.cjs +242 -175
- package/deliver-great-systems/bin/lib/jobs.cjs +1 -1
- package/deliver-great-systems/bin/lib/jobs.test.cjs +203 -202
- package/deliver-great-systems/bin/lib/migration.cjs +256 -281
- package/deliver-great-systems/bin/lib/migration.test.cjs +385 -440
- package/deliver-great-systems/bin/lib/milestone.cjs +1 -1
- package/deliver-great-systems/bin/lib/overlap.cjs +4 -4
- package/deliver-great-systems/bin/lib/overlap.test.cjs +45 -44
- package/deliver-great-systems/bin/lib/path-audit.test.cjs +16 -22
- package/deliver-great-systems/bin/lib/paths.cjs +60 -59
- package/deliver-great-systems/bin/lib/paths.test.cjs +192 -225
- package/deliver-great-systems/bin/lib/phase.cjs +5 -4
- package/deliver-great-systems/bin/lib/projects.cjs +8 -8
- package/deliver-great-systems/bin/lib/projects.test.cjs +75 -74
- package/deliver-great-systems/bin/lib/repos.cjs +94 -230
- package/deliver-great-systems/bin/lib/repos.test.cjs +84 -75
- package/deliver-great-systems/bin/lib/search.cjs +4 -4
- package/deliver-great-systems/bin/lib/specs.cjs +2 -2
- package/deliver-great-systems/bin/lib/sync.cjs +1 -1
- package/deliver-great-systems/bin/lib/template.cjs +3 -3
- package/deliver-great-systems/bin/lib/test-helpers.cjs +59 -162
- package/deliver-great-systems/bin/lib/verify.cjs +3 -3
- package/deliver-great-systems/references/planning-config.md +7 -8
- package/deliver-great-systems/workflows/add-tests.md +1 -1
- package/deliver-great-systems/workflows/approve-spec.md +1 -11
- package/deliver-great-systems/workflows/complete-milestone.md +2 -2
- package/deliver-great-systems/workflows/consolidate-ideas.md +1 -1
- package/deliver-great-systems/workflows/create-milestone-job.md +2 -2
- package/deliver-great-systems/workflows/discuss-phase.md +2 -2
- package/deliver-great-systems/workflows/execute-phase.md +63 -4
- package/deliver-great-systems/workflows/execute-plan.md +0 -51
- package/deliver-great-systems/workflows/find-related-ideas.md +1 -1
- package/deliver-great-systems/workflows/help.md +25 -58
- package/deliver-great-systems/workflows/init-product.md +14 -451
- package/deliver-great-systems/workflows/map-codebase.md +109 -0
- package/deliver-great-systems/workflows/new-project.md +0 -1
- package/deliver-great-systems/workflows/quick.md +6 -7
- package/deliver-great-systems/workflows/run-job.md +56 -0
- package/deliver-great-systems/workflows/settings.md +30 -0
- package/package.json +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,31 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [2.8.0] - 2026-03-25
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
- **Root layout consolidation (v18.0)** — DGS now uses a single root layout format exclusively; the `.planning/` prefix path is no longer supported
|
|
15
|
+
- **Path resolution simplified** — `getPlanningRoot()` reduced to a single `git rev-parse --show-toplevel` call with per-process cache, removing the detection cascade
|
|
16
|
+
- **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`
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
- **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
|
|
20
|
+
- **Migration CLI** — `dgs-tools migrate --layout root` for manual triggering with `--dry-run` preview
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
- **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)
|
|
24
|
+
- **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)
|
|
25
|
+
- **Stale test assertions** — removed `dotplanning` assertion from `init.test.cjs` and vestigial `planningRoot` write from `repos.cjs`
|
|
26
|
+
|
|
27
|
+
## [2.7.5] - 2026-03-22
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
- **Settings workflow commit/push** — `/dgs:settings` now commits and pushes `config.json` after writing changes, closing the gap where config updates were saved locally but never committed
|
|
31
|
+
|
|
32
|
+
### Fixed
|
|
33
|
+
- **Fast path sync parity** — fast mode now uses `dgs-tools commit --push` instead of raw `git commit`, ensuring automatic push works when `sync_push` is configured
|
|
34
|
+
- **Package metadata** — added `repository` field to package.json for npm registry linking
|
|
35
|
+
|
|
11
36
|
## [2.7.4] - 2026-03-22
|
|
12
37
|
|
|
13
38
|
### Fixed
|
package/agents/dgs-executor.md
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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 : ['.
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
349
|
-
|
|
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'
|
|
573
|
-
const hasReviewKeys = lines.some((line) => line === '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) || '.
|
|
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)
|
|
821
|
+
} else if (entry.path.startsWith(planRootRel)) {
|
|
822
822
|
// Already relative to cwd
|
|
823
823
|
relPath = entry.path;
|
|
824
824
|
} else {
|