@ktpartners/dgs-platform 2.6.2
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/LICENSE +38 -0
- package/README.md +851 -0
- package/agents/dgs-codebase-cross-analyzer.md +183 -0
- package/agents/dgs-codebase-mapper.md +782 -0
- package/agents/dgs-codebase-synthesizer.md +156 -0
- package/agents/dgs-debugger.md +1256 -0
- package/agents/dgs-executor.md +550 -0
- package/agents/dgs-integration-checker.md +481 -0
- package/agents/dgs-nyquist-auditor.md +178 -0
- package/agents/dgs-phase-researcher.md +563 -0
- package/agents/dgs-phase-verifier.md +450 -0
- package/agents/dgs-plan-checker.md +708 -0
- package/agents/dgs-planner.md +1324 -0
- package/agents/dgs-project-researcher.md +631 -0
- package/agents/dgs-research-synthesizer.md +249 -0
- package/agents/dgs-roadmapper.md +652 -0
- package/agents/dgs-verifier.md +607 -0
- package/bin/install.js +2073 -0
- package/commands/dgs/add-doc.md +45 -0
- package/commands/dgs/add-idea.md +38 -0
- package/commands/dgs/add-phase.md +43 -0
- package/commands/dgs/add-repo.md +54 -0
- package/commands/dgs/add-tests.md +41 -0
- package/commands/dgs/add-todo.md +47 -0
- package/commands/dgs/approve-spec.md +38 -0
- package/commands/dgs/audit-milestone.md +36 -0
- package/commands/dgs/audit-phase.md +37 -0
- package/commands/dgs/cancel-job.md +23 -0
- package/commands/dgs/capture-principle.md +143 -0
- package/commands/dgs/check-todos.md +45 -0
- package/commands/dgs/cleanup.md +18 -0
- package/commands/dgs/complete-milestone.md +136 -0
- package/commands/dgs/complete-project.md +70 -0
- package/commands/dgs/consolidate-ideas.md +50 -0
- package/commands/dgs/create-milestone-job.md +37 -0
- package/commands/dgs/debug.md +164 -0
- package/commands/dgs/develop-idea.md +53 -0
- package/commands/dgs/discuss-idea.md +41 -0
- package/commands/dgs/discuss-phase.md +83 -0
- package/commands/dgs/execute-phase.md +41 -0
- package/commands/dgs/fast.md +38 -0
- package/commands/dgs/find-related-ideas.md +43 -0
- package/commands/dgs/health.md +28 -0
- package/commands/dgs/help.md +22 -0
- package/commands/dgs/import-spec.md +36 -0
- package/commands/dgs/init-product.md +28 -0
- package/commands/dgs/insert-phase.md +32 -0
- package/commands/dgs/join-discord.md +18 -0
- package/commands/dgs/list-docs.md +40 -0
- package/commands/dgs/list-ideas.md +42 -0
- package/commands/dgs/list-jobs.md +22 -0
- package/commands/dgs/list-phase-assumptions.md +46 -0
- package/commands/dgs/list-projects.md +57 -0
- package/commands/dgs/list-specs.md +40 -0
- package/commands/dgs/map-codebase.md +92 -0
- package/commands/dgs/new-milestone.md +44 -0
- package/commands/dgs/new-project.md +42 -0
- package/commands/dgs/node-repair.md +26 -0
- package/commands/dgs/overlap-check.md +20 -0
- package/commands/dgs/pause-work.md +38 -0
- package/commands/dgs/plan-milestone-gaps.md +34 -0
- package/commands/dgs/plan-phase.md +44 -0
- package/commands/dgs/progress.md +24 -0
- package/commands/dgs/quick.md +41 -0
- package/commands/dgs/reactivate-project.md +70 -0
- package/commands/dgs/reapply-patches.md +110 -0
- package/commands/dgs/refine-spec.md +38 -0
- package/commands/dgs/reject-idea.md +43 -0
- package/commands/dgs/remove-doc.md +44 -0
- package/commands/dgs/remove-phase.md +31 -0
- package/commands/dgs/remove-repo.md +69 -0
- package/commands/dgs/research-idea.md +43 -0
- package/commands/dgs/research-phase.md +189 -0
- package/commands/dgs/restore-idea.md +45 -0
- package/commands/dgs/resume-work.md +40 -0
- package/commands/dgs/rollback-job.md +24 -0
- package/commands/dgs/run-job.md +35 -0
- package/commands/dgs/search.md +40 -0
- package/commands/dgs/set-profile.md +34 -0
- package/commands/dgs/settings.md +38 -0
- package/commands/dgs/switch-project.md +58 -0
- package/commands/dgs/undo-consolidation.md +42 -0
- package/commands/dgs/update-idea.md +44 -0
- package/commands/dgs/update.md +37 -0
- package/commands/dgs/validate-phase.md +35 -0
- package/commands/dgs/verify-work.md +39 -0
- package/commands/dgs/write-spec.md +49 -0
- package/deliver-great-systems/.planning/phases/09-backend-wiring-and-error-handling/09-01-SUMMARY.md +84 -0
- package/deliver-great-systems/.planning/phases/09-backend-wiring-and-error-handling/09-02-SUMMARY.md +86 -0
- package/deliver-great-systems/.planning/phases/10-v1-to-v2-migration-flow/10-01-SUMMARY.md +85 -0
- package/deliver-great-systems/bin/dgs-tools.cjs +1444 -0
- package/deliver-great-systems/bin/lib/auto-test.cjs +1365 -0
- package/deliver-great-systems/bin/lib/commands.cjs +570 -0
- package/deliver-great-systems/bin/lib/config.cjs +417 -0
- package/deliver-great-systems/bin/lib/conflict-agent.cjs +1063 -0
- package/deliver-great-systems/bin/lib/conflict-agent.test.cjs +554 -0
- package/deliver-great-systems/bin/lib/context.cjs +929 -0
- package/deliver-great-systems/bin/lib/context.test.cjs +693 -0
- package/deliver-great-systems/bin/lib/core.cjs +744 -0
- package/deliver-great-systems/bin/lib/core.test.cjs +822 -0
- package/deliver-great-systems/bin/lib/docs.cjs +919 -0
- package/deliver-great-systems/bin/lib/docs.test.cjs +211 -0
- package/deliver-great-systems/bin/lib/execution.cjs +705 -0
- package/deliver-great-systems/bin/lib/execution.test.cjs +1472 -0
- package/deliver-great-systems/bin/lib/frontmatter.cjs +324 -0
- package/deliver-great-systems/bin/lib/ideas.cjs +1406 -0
- package/deliver-great-systems/bin/lib/ideas.test.cjs +1417 -0
- package/deliver-great-systems/bin/lib/identity.cjs +125 -0
- package/deliver-great-systems/bin/lib/init.cjs +1114 -0
- package/deliver-great-systems/bin/lib/init.test.cjs +1271 -0
- package/deliver-great-systems/bin/lib/jobs.cjs +2015 -0
- package/deliver-great-systems/bin/lib/jobs.test.cjs +2619 -0
- package/deliver-great-systems/bin/lib/merge-conflicts.cjs +654 -0
- package/deliver-great-systems/bin/lib/merge-conflicts.test.cjs +370 -0
- package/deliver-great-systems/bin/lib/migration.cjs +352 -0
- package/deliver-great-systems/bin/lib/migration.test.cjs +582 -0
- package/deliver-great-systems/bin/lib/milestone.cjs +243 -0
- package/deliver-great-systems/bin/lib/overlap.cjs +437 -0
- package/deliver-great-systems/bin/lib/overlap.test.cjs +747 -0
- package/deliver-great-systems/bin/lib/path-audit.test.cjs +384 -0
- package/deliver-great-systems/bin/lib/paths.cjs +144 -0
- package/deliver-great-systems/bin/lib/paths.test.cjs +486 -0
- package/deliver-great-systems/bin/lib/phase.cjs +910 -0
- package/deliver-great-systems/bin/lib/projects.cjs +691 -0
- package/deliver-great-systems/bin/lib/projects.test.cjs +871 -0
- package/deliver-great-systems/bin/lib/repos.cjs +1432 -0
- package/deliver-great-systems/bin/lib/repos.test.cjs +1882 -0
- package/deliver-great-systems/bin/lib/roadmap.cjs +305 -0
- package/deliver-great-systems/bin/lib/search.cjs +570 -0
- package/deliver-great-systems/bin/lib/specs.cjs +1303 -0
- package/deliver-great-systems/bin/lib/state.cjs +893 -0
- package/deliver-great-systems/bin/lib/template.cjs +228 -0
- package/deliver-great-systems/bin/lib/test-helpers.cjs +291 -0
- package/deliver-great-systems/bin/lib/verify.cjs +796 -0
- package/deliver-great-systems/references/checkpoints.md +776 -0
- package/deliver-great-systems/references/conflict-resolution.md +66 -0
- package/deliver-great-systems/references/context-tiers.md +166 -0
- package/deliver-great-systems/references/continuation-format.md +249 -0
- package/deliver-great-systems/references/decimal-phase-calculation.md +67 -0
- package/deliver-great-systems/references/git-integration.md +250 -0
- package/deliver-great-systems/references/git-planning-commit.md +40 -0
- package/deliver-great-systems/references/model-profile-resolution.md +36 -0
- package/deliver-great-systems/references/model-profiles.md +95 -0
- package/deliver-great-systems/references/phase-argument-parsing.md +61 -0
- package/deliver-great-systems/references/planning-config.md +224 -0
- package/deliver-great-systems/references/questioning.md +162 -0
- package/deliver-great-systems/references/spec-review-loop.md +177 -0
- package/deliver-great-systems/references/tdd.md +265 -0
- package/deliver-great-systems/references/ui-brand.md +160 -0
- package/deliver-great-systems/references/verification-patterns.md +612 -0
- package/deliver-great-systems/templates/DEBUG.md +166 -0
- package/deliver-great-systems/templates/UAT.md +251 -0
- package/deliver-great-systems/templates/VALIDATION.md +95 -0
- package/deliver-great-systems/templates/claude-md.md +74 -0
- package/deliver-great-systems/templates/codebase/architecture.md +257 -0
- package/deliver-great-systems/templates/codebase/concerns.md +312 -0
- package/deliver-great-systems/templates/codebase/conventions.md +309 -0
- package/deliver-great-systems/templates/codebase/integrations.md +282 -0
- package/deliver-great-systems/templates/codebase/stack.md +188 -0
- package/deliver-great-systems/templates/codebase/structure.md +287 -0
- package/deliver-great-systems/templates/codebase/testing.md +482 -0
- package/deliver-great-systems/templates/config.json +38 -0
- package/deliver-great-systems/templates/context.md +354 -0
- package/deliver-great-systems/templates/continue-here.md +80 -0
- package/deliver-great-systems/templates/debug-subagent-prompt.md +93 -0
- package/deliver-great-systems/templates/discovery.md +148 -0
- package/deliver-great-systems/templates/milestone-archive.md +125 -0
- package/deliver-great-systems/templates/milestone.md +117 -0
- package/deliver-great-systems/templates/phase-prompt.md +615 -0
- package/deliver-great-systems/templates/planner-subagent-prompt.md +119 -0
- package/deliver-great-systems/templates/project.md +186 -0
- package/deliver-great-systems/templates/requirements.md +233 -0
- package/deliver-great-systems/templates/research-project/ARCHITECTURE.md +206 -0
- package/deliver-great-systems/templates/research-project/FEATURES.md +149 -0
- package/deliver-great-systems/templates/research-project/PITFALLS.md +202 -0
- package/deliver-great-systems/templates/research-project/STACK.md +122 -0
- package/deliver-great-systems/templates/research-project/SUMMARY.md +172 -0
- package/deliver-great-systems/templates/research.md +554 -0
- package/deliver-great-systems/templates/retrospective.md +54 -0
- package/deliver-great-systems/templates/roadmap.md +204 -0
- package/deliver-great-systems/templates/state.md +178 -0
- package/deliver-great-systems/templates/summary-complex.md +59 -0
- package/deliver-great-systems/templates/summary-minimal.md +41 -0
- package/deliver-great-systems/templates/summary-standard.md +48 -0
- package/deliver-great-systems/templates/summary.md +253 -0
- package/deliver-great-systems/templates/user-setup.md +313 -0
- package/deliver-great-systems/templates/verification-report.md +324 -0
- package/deliver-great-systems/workflows/add-doc.md +151 -0
- package/deliver-great-systems/workflows/add-idea.md +96 -0
- package/deliver-great-systems/workflows/add-phase.md +120 -0
- package/deliver-great-systems/workflows/add-tests.md +359 -0
- package/deliver-great-systems/workflows/add-todo.md +162 -0
- package/deliver-great-systems/workflows/approve-spec.md +194 -0
- package/deliver-great-systems/workflows/audit-milestone.md +364 -0
- package/deliver-great-systems/workflows/audit-phase.md +462 -0
- package/deliver-great-systems/workflows/cancel-job.md +108 -0
- package/deliver-great-systems/workflows/check-todos.md +181 -0
- package/deliver-great-systems/workflows/cleanup.md +247 -0
- package/deliver-great-systems/workflows/codereview.md +526 -0
- package/deliver-great-systems/workflows/complete-milestone.md +1298 -0
- package/deliver-great-systems/workflows/consolidate-ideas.md +365 -0
- package/deliver-great-systems/workflows/create-milestone-job.md +177 -0
- package/deliver-great-systems/workflows/develop-idea.md +544 -0
- package/deliver-great-systems/workflows/diagnose-issues.md +231 -0
- package/deliver-great-systems/workflows/discovery-phase.md +301 -0
- package/deliver-great-systems/workflows/discuss-idea.md +263 -0
- package/deliver-great-systems/workflows/discuss-phase.md +733 -0
- package/deliver-great-systems/workflows/execute-phase.md +571 -0
- package/deliver-great-systems/workflows/execute-plan.md +592 -0
- package/deliver-great-systems/workflows/find-related-ideas.md +271 -0
- package/deliver-great-systems/workflows/health.md +173 -0
- package/deliver-great-systems/workflows/help.md +997 -0
- package/deliver-great-systems/workflows/import-spec.md +381 -0
- package/deliver-great-systems/workflows/init-product.md +767 -0
- package/deliver-great-systems/workflows/insert-phase.md +138 -0
- package/deliver-great-systems/workflows/list-docs.md +119 -0
- package/deliver-great-systems/workflows/list-ideas.md +154 -0
- package/deliver-great-systems/workflows/list-jobs.md +89 -0
- package/deliver-great-systems/workflows/list-phase-assumptions.md +192 -0
- package/deliver-great-systems/workflows/list-specs.md +101 -0
- package/deliver-great-systems/workflows/map-codebase.md +621 -0
- package/deliver-great-systems/workflows/new-milestone.md +591 -0
- package/deliver-great-systems/workflows/new-project.md +1113 -0
- package/deliver-great-systems/workflows/node-repair.md +94 -0
- package/deliver-great-systems/workflows/overlap-check.md +86 -0
- package/deliver-great-systems/workflows/pause-work.md +134 -0
- package/deliver-great-systems/workflows/plan-milestone-gaps.md +306 -0
- package/deliver-great-systems/workflows/plan-phase.md +698 -0
- package/deliver-great-systems/workflows/progress.md +386 -0
- package/deliver-great-systems/workflows/quick.md +845 -0
- package/deliver-great-systems/workflows/refine-spec.md +275 -0
- package/deliver-great-systems/workflows/reject-idea.md +109 -0
- package/deliver-great-systems/workflows/remove-doc.md +117 -0
- package/deliver-great-systems/workflows/remove-phase.md +163 -0
- package/deliver-great-systems/workflows/research-idea.md +325 -0
- package/deliver-great-systems/workflows/research-phase.md +81 -0
- package/deliver-great-systems/workflows/restore-idea.md +101 -0
- package/deliver-great-systems/workflows/resume-project.md +311 -0
- package/deliver-great-systems/workflows/rollback-job.md +130 -0
- package/deliver-great-systems/workflows/run-job.md +498 -0
- package/deliver-great-systems/workflows/search.md +130 -0
- package/deliver-great-systems/workflows/set-profile.md +83 -0
- package/deliver-great-systems/workflows/settings.md +470 -0
- package/deliver-great-systems/workflows/transition.md +563 -0
- package/deliver-great-systems/workflows/undo-consolidation.md +155 -0
- package/deliver-great-systems/workflows/update-idea.md +157 -0
- package/deliver-great-systems/workflows/update.md +242 -0
- package/deliver-great-systems/workflows/validate-phase.md +177 -0
- package/deliver-great-systems/workflows/verify-phase.md +253 -0
- package/deliver-great-systems/workflows/verify-work.md +671 -0
- package/deliver-great-systems/workflows/write-spec.md +450 -0
- package/hooks/dist/dgs-check-update.js +62 -0
- package/hooks/dist/dgs-context-monitor.js +141 -0
- package/hooks/dist/dgs-statusline.js +115 -0
- package/package.json +60 -0
- package/scripts/build-hooks.js +43 -0
|
@@ -0,0 +1,570 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commands — Standalone utility commands
|
|
3
|
+
*/
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const { execSync } = require('child_process');
|
|
7
|
+
const { safeReadFile, loadConfig, isGitIgnored, execGit, normalizePhaseName, comparePhaseNum, getArchivedPhaseDirs, generateSlugInternal, getMilestoneInfo, resolveModelInternal, MODEL_PROFILES, toPosixPath, output, error, findPhaseInternal } = require('./core.cjs');
|
|
8
|
+
const { extractFrontmatter } = require('./frontmatter.cjs');
|
|
9
|
+
const { getPlanningRoot } = require('./paths.cjs');
|
|
10
|
+
|
|
11
|
+
function cmdGenerateSlug(text, raw) {
|
|
12
|
+
if (!text) {
|
|
13
|
+
error('text required for slug generation');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const slug = text
|
|
17
|
+
.toLowerCase()
|
|
18
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
19
|
+
.replace(/^-+|-+$/g, '');
|
|
20
|
+
|
|
21
|
+
const result = { slug };
|
|
22
|
+
output(result, raw, slug);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function cmdCurrentTimestamp(format, raw) {
|
|
26
|
+
const now = new Date();
|
|
27
|
+
let result;
|
|
28
|
+
|
|
29
|
+
switch (format) {
|
|
30
|
+
case 'date':
|
|
31
|
+
result = now.toISOString().split('T')[0];
|
|
32
|
+
break;
|
|
33
|
+
case 'filename':
|
|
34
|
+
result = now.toISOString().replace(/:/g, '-').replace(/\..+/, '');
|
|
35
|
+
break;
|
|
36
|
+
case 'full':
|
|
37
|
+
default:
|
|
38
|
+
result = now.toISOString();
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
output({ timestamp: result }, raw, result);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function cmdListTodos(cwd, area, raw) {
|
|
46
|
+
const pendingDir = path.join(getPlanningRoot(cwd), 'todos', 'pending');
|
|
47
|
+
|
|
48
|
+
let count = 0;
|
|
49
|
+
const todos = [];
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
const files = fs.readdirSync(pendingDir).filter(f => f.endsWith('.md'));
|
|
53
|
+
|
|
54
|
+
for (const file of files) {
|
|
55
|
+
try {
|
|
56
|
+
const content = fs.readFileSync(path.join(pendingDir, file), 'utf-8');
|
|
57
|
+
const createdMatch = content.match(/^created:\s*(.+)$/m);
|
|
58
|
+
const titleMatch = content.match(/^title:\s*(.+)$/m);
|
|
59
|
+
const areaMatch = content.match(/^area:\s*(.+)$/m);
|
|
60
|
+
|
|
61
|
+
const todoArea = areaMatch ? areaMatch[1].trim() : 'general';
|
|
62
|
+
|
|
63
|
+
// Apply area filter if specified
|
|
64
|
+
if (area && todoArea !== area) continue;
|
|
65
|
+
|
|
66
|
+
count++;
|
|
67
|
+
todos.push({
|
|
68
|
+
file,
|
|
69
|
+
created: createdMatch ? createdMatch[1].trim() : 'unknown',
|
|
70
|
+
title: titleMatch ? titleMatch[1].trim() : 'Untitled',
|
|
71
|
+
area: todoArea,
|
|
72
|
+
path: toPosixPath(path.join(path.relative(cwd, getPlanningRoot(cwd)) || '.', 'todos', 'pending', file)),
|
|
73
|
+
});
|
|
74
|
+
} catch {}
|
|
75
|
+
}
|
|
76
|
+
} catch {}
|
|
77
|
+
|
|
78
|
+
const result = { count, todos };
|
|
79
|
+
output(result, raw, count.toString());
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function cmdVerifyPathExists(cwd, targetPath, raw) {
|
|
83
|
+
if (!targetPath) {
|
|
84
|
+
error('path required for verification');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const fullPath = path.isAbsolute(targetPath) ? targetPath : path.join(cwd, targetPath);
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
const stats = fs.statSync(fullPath);
|
|
91
|
+
const type = stats.isDirectory() ? 'directory' : stats.isFile() ? 'file' : 'other';
|
|
92
|
+
const result = { exists: true, type };
|
|
93
|
+
output(result, raw, 'true');
|
|
94
|
+
} catch {
|
|
95
|
+
const result = { exists: false, type: null };
|
|
96
|
+
output(result, raw, 'false');
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function cmdHistoryDigest(cwd, raw) {
|
|
101
|
+
const phasesDir = path.join(getPlanningRoot(cwd), 'phases');
|
|
102
|
+
const digest = { phases: {}, decisions: [], tech_stack: new Set() };
|
|
103
|
+
|
|
104
|
+
// Collect all phase directories: archived + current
|
|
105
|
+
const allPhaseDirs = [];
|
|
106
|
+
|
|
107
|
+
// Add archived phases first (oldest milestones first)
|
|
108
|
+
const archived = getArchivedPhaseDirs(cwd);
|
|
109
|
+
for (const a of archived) {
|
|
110
|
+
allPhaseDirs.push({ name: a.name, fullPath: a.fullPath, milestone: a.milestone });
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Add current phases
|
|
114
|
+
if (fs.existsSync(phasesDir)) {
|
|
115
|
+
try {
|
|
116
|
+
const currentDirs = fs.readdirSync(phasesDir, { withFileTypes: true })
|
|
117
|
+
.filter(e => e.isDirectory())
|
|
118
|
+
.map(e => e.name)
|
|
119
|
+
.sort();
|
|
120
|
+
for (const dir of currentDirs) {
|
|
121
|
+
allPhaseDirs.push({ name: dir, fullPath: path.join(phasesDir, dir), milestone: null });
|
|
122
|
+
}
|
|
123
|
+
} catch {}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (allPhaseDirs.length === 0) {
|
|
127
|
+
digest.tech_stack = [];
|
|
128
|
+
output(digest, raw);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
try {
|
|
133
|
+
for (const { name: dir, fullPath: dirPath } of allPhaseDirs) {
|
|
134
|
+
const summaries = fs.readdirSync(dirPath).filter(f => f.endsWith('-SUMMARY.md') || f === 'SUMMARY.md');
|
|
135
|
+
|
|
136
|
+
for (const summary of summaries) {
|
|
137
|
+
try {
|
|
138
|
+
const content = fs.readFileSync(path.join(dirPath, summary), 'utf-8');
|
|
139
|
+
const fm = extractFrontmatter(content);
|
|
140
|
+
|
|
141
|
+
const phaseNum = fm.phase || dir.split('-')[0];
|
|
142
|
+
|
|
143
|
+
if (!digest.phases[phaseNum]) {
|
|
144
|
+
digest.phases[phaseNum] = {
|
|
145
|
+
name: fm.name || dir.split('-').slice(1).join(' ') || 'Unknown',
|
|
146
|
+
provides: new Set(),
|
|
147
|
+
affects: new Set(),
|
|
148
|
+
patterns: new Set(),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Merge provides
|
|
153
|
+
if (fm['dependency-graph'] && fm['dependency-graph'].provides) {
|
|
154
|
+
fm['dependency-graph'].provides.forEach(p => digest.phases[phaseNum].provides.add(p));
|
|
155
|
+
} else if (fm.provides) {
|
|
156
|
+
fm.provides.forEach(p => digest.phases[phaseNum].provides.add(p));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Merge affects
|
|
160
|
+
if (fm['dependency-graph'] && fm['dependency-graph'].affects) {
|
|
161
|
+
fm['dependency-graph'].affects.forEach(a => digest.phases[phaseNum].affects.add(a));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Merge patterns
|
|
165
|
+
if (fm['patterns-established']) {
|
|
166
|
+
fm['patterns-established'].forEach(p => digest.phases[phaseNum].patterns.add(p));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Merge decisions
|
|
170
|
+
if (fm['key-decisions']) {
|
|
171
|
+
fm['key-decisions'].forEach(d => {
|
|
172
|
+
digest.decisions.push({ phase: phaseNum, decision: d });
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Merge tech stack
|
|
177
|
+
if (fm['tech-stack'] && fm['tech-stack'].added) {
|
|
178
|
+
fm['tech-stack'].added.forEach(t => digest.tech_stack.add(typeof t === 'string' ? t : t.name));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
} catch (e) {
|
|
182
|
+
// Skip malformed summaries
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Convert Sets to Arrays for JSON output
|
|
188
|
+
Object.keys(digest.phases).forEach(p => {
|
|
189
|
+
digest.phases[p].provides = [...digest.phases[p].provides];
|
|
190
|
+
digest.phases[p].affects = [...digest.phases[p].affects];
|
|
191
|
+
digest.phases[p].patterns = [...digest.phases[p].patterns];
|
|
192
|
+
});
|
|
193
|
+
digest.tech_stack = [...digest.tech_stack];
|
|
194
|
+
|
|
195
|
+
output(digest, raw);
|
|
196
|
+
} catch (e) {
|
|
197
|
+
error('Failed to generate history digest: ' + e.message);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function cmdResolveModel(cwd, agentType, raw) {
|
|
202
|
+
if (!agentType) {
|
|
203
|
+
error('agent-type required');
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const config = loadConfig(cwd);
|
|
207
|
+
const profile = config.model_profile || 'balanced';
|
|
208
|
+
const model = resolveModelInternal(cwd, agentType);
|
|
209
|
+
|
|
210
|
+
const agentModels = MODEL_PROFILES[agentType];
|
|
211
|
+
const result = agentModels
|
|
212
|
+
? { model, profile }
|
|
213
|
+
: { model, profile, unknown_agent: true };
|
|
214
|
+
output(result, raw, model);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function cmdCommit(cwd, message, files, raw, amend) {
|
|
218
|
+
if (!message && !amend) {
|
|
219
|
+
error('commit message required');
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const config = loadConfig(cwd);
|
|
223
|
+
|
|
224
|
+
// Check commit_docs config
|
|
225
|
+
if (!config.commit_docs) {
|
|
226
|
+
const result = { committed: false, hash: null, reason: 'skipped_commit_docs_false' };
|
|
227
|
+
output(result, raw, 'skipped');
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
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
|
+
// Stage files
|
|
239
|
+
const filesToStage = files && files.length > 0 ? files : ['.planning/'];
|
|
240
|
+
for (const file of filesToStage) {
|
|
241
|
+
execGit(cwd, ['add', file]);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Commit
|
|
245
|
+
const commitArgs = amend ? ['commit', '--amend', '--no-edit'] : ['commit', '-m', message];
|
|
246
|
+
const commitResult = execGit(cwd, commitArgs);
|
|
247
|
+
if (commitResult.exitCode !== 0) {
|
|
248
|
+
if (commitResult.stdout.includes('nothing to commit') || commitResult.stderr.includes('nothing to commit')) {
|
|
249
|
+
const result = { committed: false, hash: null, reason: 'nothing_to_commit' };
|
|
250
|
+
output(result, raw, 'nothing');
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
const result = { committed: false, hash: null, reason: 'nothing_to_commit', error: commitResult.stderr };
|
|
254
|
+
output(result, raw, 'nothing');
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Get short hash
|
|
259
|
+
const hashResult = execGit(cwd, ['rev-parse', '--short', 'HEAD']);
|
|
260
|
+
const hash = hashResult.exitCode === 0 ? hashResult.stdout : null;
|
|
261
|
+
const result = { committed: true, hash, reason: 'committed' };
|
|
262
|
+
output(result, raw, hash || 'committed');
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function cmdSummaryExtract(cwd, summaryPath, fields, raw) {
|
|
266
|
+
if (!summaryPath) {
|
|
267
|
+
error('summary-path required for summary-extract');
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const fullPath = path.join(cwd, summaryPath);
|
|
271
|
+
|
|
272
|
+
if (!fs.existsSync(fullPath)) {
|
|
273
|
+
output({ error: 'File not found', path: summaryPath }, raw);
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
278
|
+
const fm = extractFrontmatter(content);
|
|
279
|
+
|
|
280
|
+
// Parse key-decisions into structured format
|
|
281
|
+
const parseDecisions = (decisionsList) => {
|
|
282
|
+
if (!decisionsList || !Array.isArray(decisionsList)) return [];
|
|
283
|
+
return decisionsList.map(d => {
|
|
284
|
+
const colonIdx = d.indexOf(':');
|
|
285
|
+
if (colonIdx > 0) {
|
|
286
|
+
return {
|
|
287
|
+
summary: d.substring(0, colonIdx).trim(),
|
|
288
|
+
rationale: d.substring(colonIdx + 1).trim(),
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
return { summary: d, rationale: null };
|
|
292
|
+
});
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
// Build full result
|
|
296
|
+
const fullResult = {
|
|
297
|
+
path: summaryPath,
|
|
298
|
+
one_liner: fm['one-liner'] || null,
|
|
299
|
+
key_files: fm['key-files'] || [],
|
|
300
|
+
tech_added: (fm['tech-stack'] && fm['tech-stack'].added) || [],
|
|
301
|
+
patterns: fm['patterns-established'] || [],
|
|
302
|
+
decisions: parseDecisions(fm['key-decisions']),
|
|
303
|
+
requirements_completed: fm['requirements-completed'] || [],
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
// If fields specified, filter to only those fields
|
|
307
|
+
if (fields && fields.length > 0) {
|
|
308
|
+
const filtered = { path: summaryPath };
|
|
309
|
+
for (const field of fields) {
|
|
310
|
+
if (fullResult[field] !== undefined) {
|
|
311
|
+
filtered[field] = fullResult[field];
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
output(filtered, raw);
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
output(fullResult, raw);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
async function cmdWebsearch(query, options, raw) {
|
|
322
|
+
const apiKey = process.env.BRAVE_API_KEY;
|
|
323
|
+
|
|
324
|
+
if (!apiKey) {
|
|
325
|
+
// No key = silent skip, agent falls back to built-in WebSearch
|
|
326
|
+
output({ available: false, reason: 'BRAVE_API_KEY not set' }, raw, '');
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (!query) {
|
|
331
|
+
output({ available: false, error: 'Query required' }, raw, '');
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const params = new URLSearchParams({
|
|
336
|
+
q: query,
|
|
337
|
+
count: String(options.limit || 10),
|
|
338
|
+
country: 'us',
|
|
339
|
+
search_lang: 'en',
|
|
340
|
+
text_decorations: 'false'
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
if (options.freshness) {
|
|
344
|
+
params.set('freshness', options.freshness);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
try {
|
|
348
|
+
const response = await fetch(
|
|
349
|
+
`https://api.search.brave.com/res/v1/web/search?${params}`,
|
|
350
|
+
{
|
|
351
|
+
headers: {
|
|
352
|
+
'Accept': 'application/json',
|
|
353
|
+
'X-Subscription-Token': apiKey
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
);
|
|
357
|
+
|
|
358
|
+
if (!response.ok) {
|
|
359
|
+
output({ available: false, error: `API error: ${response.status}` }, raw, '');
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
const data = await response.json();
|
|
364
|
+
|
|
365
|
+
const results = (data.web?.results || []).map(r => ({
|
|
366
|
+
title: r.title,
|
|
367
|
+
url: r.url,
|
|
368
|
+
description: r.description,
|
|
369
|
+
age: r.age || null
|
|
370
|
+
}));
|
|
371
|
+
|
|
372
|
+
output({
|
|
373
|
+
available: true,
|
|
374
|
+
query,
|
|
375
|
+
count: results.length,
|
|
376
|
+
results
|
|
377
|
+
}, raw, results.map(r => `${r.title}\n${r.url}\n${r.description}`).join('\n\n'));
|
|
378
|
+
} catch (err) {
|
|
379
|
+
output({ available: false, error: err.message }, raw, '');
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function cmdProgressRender(cwd, format, raw) {
|
|
384
|
+
const phasesDir = path.join(getPlanningRoot(cwd), 'phases');
|
|
385
|
+
const roadmapPath = path.join(getPlanningRoot(cwd), 'ROADMAP.md');
|
|
386
|
+
const milestone = getMilestoneInfo(cwd);
|
|
387
|
+
|
|
388
|
+
const phases = [];
|
|
389
|
+
let totalPlans = 0;
|
|
390
|
+
let totalSummaries = 0;
|
|
391
|
+
|
|
392
|
+
try {
|
|
393
|
+
const entries = fs.readdirSync(phasesDir, { withFileTypes: true });
|
|
394
|
+
const dirs = entries.filter(e => e.isDirectory()).map(e => e.name).sort((a, b) => comparePhaseNum(a, b));
|
|
395
|
+
|
|
396
|
+
for (const dir of dirs) {
|
|
397
|
+
const dm = dir.match(/^(\d+(?:\.\d+)*)-?(.*)/);
|
|
398
|
+
const phaseNum = dm ? dm[1] : dir;
|
|
399
|
+
const phaseName = dm && dm[2] ? dm[2].replace(/-/g, ' ') : '';
|
|
400
|
+
const phaseFiles = fs.readdirSync(path.join(phasesDir, dir));
|
|
401
|
+
const plans = phaseFiles.filter(f => f.endsWith('-PLAN.md') || f === 'PLAN.md').length;
|
|
402
|
+
const summaries = phaseFiles.filter(f => f.endsWith('-SUMMARY.md') || f === 'SUMMARY.md').length;
|
|
403
|
+
|
|
404
|
+
totalPlans += plans;
|
|
405
|
+
totalSummaries += summaries;
|
|
406
|
+
|
|
407
|
+
let status;
|
|
408
|
+
if (plans === 0) status = 'Pending';
|
|
409
|
+
else if (summaries >= plans) status = 'Complete';
|
|
410
|
+
else if (summaries > 0) status = 'In Progress';
|
|
411
|
+
else status = 'Planned';
|
|
412
|
+
|
|
413
|
+
phases.push({ number: phaseNum, name: phaseName, plans, summaries, status });
|
|
414
|
+
}
|
|
415
|
+
} catch {}
|
|
416
|
+
|
|
417
|
+
const percent = totalPlans > 0 ? Math.min(100, Math.round((totalSummaries / totalPlans) * 100)) : 0;
|
|
418
|
+
|
|
419
|
+
if (format === 'table') {
|
|
420
|
+
// Render markdown table
|
|
421
|
+
const barWidth = 10;
|
|
422
|
+
const filled = Math.round((percent / 100) * barWidth);
|
|
423
|
+
const bar = '\u2588'.repeat(filled) + '\u2591'.repeat(barWidth - filled);
|
|
424
|
+
let out = `# ${milestone.version} ${milestone.name}\n\n`;
|
|
425
|
+
out += `**Progress:** [${bar}] ${totalSummaries}/${totalPlans} plans (${percent}%)\n\n`;
|
|
426
|
+
out += `| Phase | Name | Plans | Status |\n`;
|
|
427
|
+
out += `|-------|------|-------|--------|\n`;
|
|
428
|
+
for (const p of phases) {
|
|
429
|
+
out += `| ${p.number} | ${p.name} | ${p.summaries}/${p.plans} | ${p.status} |\n`;
|
|
430
|
+
}
|
|
431
|
+
output({ rendered: out }, raw, out);
|
|
432
|
+
} else if (format === 'bar') {
|
|
433
|
+
const barWidth = 20;
|
|
434
|
+
const filled = Math.round((percent / 100) * barWidth);
|
|
435
|
+
const bar = '\u2588'.repeat(filled) + '\u2591'.repeat(barWidth - filled);
|
|
436
|
+
const text = `[${bar}] ${totalSummaries}/${totalPlans} plans (${percent}%)`;
|
|
437
|
+
output({ bar: text, percent, completed: totalSummaries, total: totalPlans }, raw, text);
|
|
438
|
+
} else {
|
|
439
|
+
// JSON format
|
|
440
|
+
output({
|
|
441
|
+
milestone_version: milestone.version,
|
|
442
|
+
milestone_name: milestone.name,
|
|
443
|
+
phases,
|
|
444
|
+
total_plans: totalPlans,
|
|
445
|
+
total_summaries: totalSummaries,
|
|
446
|
+
percent,
|
|
447
|
+
}, raw);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
function cmdTodoComplete(cwd, filename, raw) {
|
|
452
|
+
if (!filename) {
|
|
453
|
+
error('filename required for todo complete');
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
const pendingDir = path.join(getPlanningRoot(cwd), 'todos', 'pending');
|
|
457
|
+
const completedDir = path.join(getPlanningRoot(cwd), 'todos', 'completed');
|
|
458
|
+
const sourcePath = path.join(pendingDir, filename);
|
|
459
|
+
|
|
460
|
+
if (!fs.existsSync(sourcePath)) {
|
|
461
|
+
error(`Todo not found: ${filename}`);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// Ensure completed directory exists
|
|
465
|
+
fs.mkdirSync(completedDir, { recursive: true });
|
|
466
|
+
|
|
467
|
+
// Read, add completion timestamp, move
|
|
468
|
+
let content = fs.readFileSync(sourcePath, 'utf-8');
|
|
469
|
+
const today = new Date().toISOString().split('T')[0];
|
|
470
|
+
content = `completed: ${today}\n` + content;
|
|
471
|
+
|
|
472
|
+
fs.writeFileSync(path.join(completedDir, filename), content, 'utf-8');
|
|
473
|
+
fs.unlinkSync(sourcePath);
|
|
474
|
+
|
|
475
|
+
output({ completed: true, file: filename, date: today }, raw, 'completed');
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
function cmdScaffold(cwd, type, options, raw) {
|
|
479
|
+
const { phase, name } = options;
|
|
480
|
+
const padded = phase ? normalizePhaseName(phase) : '00';
|
|
481
|
+
const today = new Date().toISOString().split('T')[0];
|
|
482
|
+
|
|
483
|
+
// Find phase directory
|
|
484
|
+
const phaseInfo = phase ? findPhaseInternal(cwd, phase) : null;
|
|
485
|
+
const phaseDir = phaseInfo ? path.join(cwd, phaseInfo.directory) : null;
|
|
486
|
+
|
|
487
|
+
if (phase && !phaseDir && type !== 'phase-dir') {
|
|
488
|
+
error(`Phase ${phase} directory not found`);
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
let filePath, content;
|
|
492
|
+
|
|
493
|
+
switch (type) {
|
|
494
|
+
case 'context': {
|
|
495
|
+
filePath = path.join(phaseDir, `${padded}-CONTEXT.md`);
|
|
496
|
+
content = `---\nphase: "${padded}"\nname: "${name || phaseInfo?.phase_name || 'Unnamed'}"\ncreated: ${today}\n---\n\n# Phase ${phase}: ${name || phaseInfo?.phase_name || 'Unnamed'} — Context\n\n## Decisions\n\n_Decisions will be captured during /dgs:discuss-phase ${phase}_\n\n## Discretion Areas\n\n_Areas where the executor can use judgment_\n\n## Deferred Ideas\n\n_Ideas to consider later_\n`;
|
|
497
|
+
break;
|
|
498
|
+
}
|
|
499
|
+
case 'uat': {
|
|
500
|
+
filePath = path.join(phaseDir, `${padded}-UAT.md`);
|
|
501
|
+
content = `---\nphase: "${padded}"\nname: "${name || phaseInfo?.phase_name || 'Unnamed'}"\ncreated: ${today}\nstatus: pending\n---\n\n# Phase ${phase}: ${name || phaseInfo?.phase_name || 'Unnamed'} — User Acceptance Testing\n\n## Test Results\n\n| # | Test | Status | Notes |\n|---|------|--------|-------|\n\n## Summary\n\n_Pending UAT_\n`;
|
|
502
|
+
break;
|
|
503
|
+
}
|
|
504
|
+
case 'verification': {
|
|
505
|
+
filePath = path.join(phaseDir, `${padded}-VERIFICATION.md`);
|
|
506
|
+
content = `---\nphase: "${padded}"\nname: "${name || phaseInfo?.phase_name || 'Unnamed'}"\ncreated: ${today}\nstatus: pending\n---\n\n# Phase ${phase}: ${name || phaseInfo?.phase_name || 'Unnamed'} — Verification\n\n## Goal-Backward Verification\n\n**Phase Goal:** [From ROADMAP.md]\n\n## Checks\n\n| # | Requirement | Status | Evidence |\n|---|------------|--------|----------|\n\n## Result\n\n_Pending verification_\n`;
|
|
507
|
+
break;
|
|
508
|
+
}
|
|
509
|
+
case 'phase-dir': {
|
|
510
|
+
if (!phase || !name) {
|
|
511
|
+
error('phase and name required for phase-dir scaffold');
|
|
512
|
+
}
|
|
513
|
+
const slug = generateSlugInternal(name);
|
|
514
|
+
const dirName = `${padded}-${slug}`;
|
|
515
|
+
const phasesParent = path.join(getPlanningRoot(cwd), 'phases');
|
|
516
|
+
fs.mkdirSync(phasesParent, { recursive: true });
|
|
517
|
+
const dirPath = path.join(phasesParent, dirName);
|
|
518
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
519
|
+
const planRootRel = path.relative(cwd, getPlanningRoot(cwd)) || '.';
|
|
520
|
+
output({ created: true, directory: path.join(planRootRel, 'phases', dirName), path: dirPath }, raw, dirPath);
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
default:
|
|
524
|
+
error(`Unknown scaffold type: ${type}. Available: context, uat, verification, phase-dir`);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
if (fs.existsSync(filePath)) {
|
|
528
|
+
output({ created: false, reason: 'already_exists', path: filePath }, raw, 'exists');
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
fs.writeFileSync(filePath, content, 'utf-8');
|
|
533
|
+
const relPath = toPosixPath(path.relative(cwd, filePath));
|
|
534
|
+
output({ created: true, path: relPath }, raw, relPath);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// ─── Context Command Family ──────────────────────────────────────────────────
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Returns available context subcommands and their descriptions.
|
|
541
|
+
* Satisfies TOOL-10 requirement for context command registration in commands.cjs.
|
|
542
|
+
*
|
|
543
|
+
* @param {boolean} raw - Raw output mode
|
|
544
|
+
*/
|
|
545
|
+
function cmdContextHelp(raw) {
|
|
546
|
+
const result = {
|
|
547
|
+
command: 'context',
|
|
548
|
+
description: 'Context tier file resolution',
|
|
549
|
+
subcommands: [
|
|
550
|
+
{ name: 'load-tier', usage: 'context load-tier <name> [--phase N] [--idea N] [--spec N]', description: 'Get file list for a context tier' },
|
|
551
|
+
],
|
|
552
|
+
};
|
|
553
|
+
output(result, raw, result.subcommands.map(s => s.usage).join('\n'));
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
module.exports = {
|
|
557
|
+
cmdGenerateSlug,
|
|
558
|
+
cmdCurrentTimestamp,
|
|
559
|
+
cmdListTodos,
|
|
560
|
+
cmdVerifyPathExists,
|
|
561
|
+
cmdHistoryDigest,
|
|
562
|
+
cmdResolveModel,
|
|
563
|
+
cmdCommit,
|
|
564
|
+
cmdSummaryExtract,
|
|
565
|
+
cmdWebsearch,
|
|
566
|
+
cmdProgressRender,
|
|
567
|
+
cmdTodoComplete,
|
|
568
|
+
cmdScaffold,
|
|
569
|
+
cmdContextHelp,
|
|
570
|
+
};
|