gsdd-cli 0.18.5 → 0.19.1

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 (101) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +610 -608
  3. package/agents/DISTILLATION.md +421 -421
  4. package/agents/README.md +62 -62
  5. package/agents/approach-explorer.md +370 -361
  6. package/agents/debugger.md +82 -82
  7. package/agents/executor.md +473 -394
  8. package/agents/integration-checker.md +318 -318
  9. package/agents/mapper.md +103 -103
  10. package/agents/planner.md +342 -313
  11. package/agents/researcher.md +84 -84
  12. package/agents/roadmapper.md +296 -296
  13. package/agents/synthesizer.md +236 -236
  14. package/agents/verifier.md +337 -337
  15. package/bin/adapters/agents.mjs +34 -34
  16. package/bin/adapters/claude.mjs +193 -191
  17. package/bin/adapters/codex.mjs +85 -85
  18. package/bin/adapters/index.mjs +20 -20
  19. package/bin/adapters/opencode.mjs +280 -278
  20. package/bin/gsdd.mjs +123 -116
  21. package/bin/lib/cli-utils.mjs +28 -28
  22. package/bin/lib/evidence-contract.mjs +325 -112
  23. package/bin/lib/file-ops.mjs +186 -144
  24. package/bin/lib/health-truth.mjs +196 -178
  25. package/bin/lib/health.mjs +246 -226
  26. package/bin/lib/init-flow.mjs +247 -231
  27. package/bin/lib/init-prompts.mjs +248 -247
  28. package/bin/lib/init-runtime.mjs +193 -190
  29. package/bin/lib/init.mjs +17 -17
  30. package/bin/lib/lifecycle-preflight.mjs +760 -326
  31. package/bin/lib/lifecycle-state.mjs +356 -267
  32. package/bin/lib/manifest.mjs +116 -114
  33. package/bin/lib/models.mjs +411 -411
  34. package/bin/lib/phase.mjs +365 -358
  35. package/bin/lib/plan-constants.mjs +35 -30
  36. package/bin/lib/provenance.mjs +109 -106
  37. package/bin/lib/rendering.mjs +119 -83
  38. package/bin/lib/runtime-freshness.mjs +214 -214
  39. package/bin/lib/session-fingerprint.mjs +91 -14
  40. package/bin/lib/templates.mjs +225 -224
  41. package/bin/lib/workspace-root.mjs +2 -1
  42. package/distilled/DESIGN.md +2461 -2323
  43. package/distilled/EVIDENCE-INDEX.md +418 -392
  44. package/distilled/README.md +196 -193
  45. package/distilled/SKILL.md +86 -85
  46. package/distilled/templates/agents.block.md +21 -21
  47. package/distilled/templates/agents.md +6 -6
  48. package/distilled/templates/approach.md +272 -232
  49. package/distilled/templates/auth-matrix.md +78 -78
  50. package/distilled/templates/brownfield-change/CHANGE.md +99 -0
  51. package/distilled/templates/brownfield-change/HANDOFF.md +38 -0
  52. package/distilled/templates/brownfield-change/VERIFICATION.md +56 -0
  53. package/distilled/templates/codebase/architecture.md +110 -110
  54. package/distilled/templates/codebase/concerns.md +95 -95
  55. package/distilled/templates/codebase/conventions.md +193 -193
  56. package/distilled/templates/codebase/stack.md +96 -96
  57. package/distilled/templates/delegates/approach-explorer.md +28 -25
  58. package/distilled/templates/delegates/mapper-arch.md +26 -26
  59. package/distilled/templates/delegates/mapper-concerns.md +27 -27
  60. package/distilled/templates/delegates/mapper-quality.md +28 -28
  61. package/distilled/templates/delegates/mapper-tech.md +25 -25
  62. package/distilled/templates/delegates/plan-checker.md +78 -68
  63. package/distilled/templates/delegates/researcher-architecture.md +30 -30
  64. package/distilled/templates/delegates/researcher-features.md +30 -30
  65. package/distilled/templates/delegates/researcher-pitfalls.md +30 -30
  66. package/distilled/templates/delegates/researcher-stack.md +30 -30
  67. package/distilled/templates/delegates/researcher-synthesizer.md +31 -31
  68. package/distilled/templates/research/architecture.md +57 -57
  69. package/distilled/templates/research/features.md +23 -23
  70. package/distilled/templates/research/pitfalls.md +46 -46
  71. package/distilled/templates/research/stack.md +45 -45
  72. package/distilled/templates/research/summary.md +67 -67
  73. package/distilled/templates/roadmap.md +74 -62
  74. package/distilled/templates/spec.md +110 -110
  75. package/distilled/workflows/audit-milestone.md +303 -271
  76. package/distilled/workflows/complete-milestone.md +349 -332
  77. package/distilled/workflows/execute.md +457 -450
  78. package/distilled/workflows/map-codebase.md +253 -253
  79. package/distilled/workflows/new-milestone.md +242 -238
  80. package/distilled/workflows/new-project.md +398 -398
  81. package/distilled/workflows/pause.md +160 -156
  82. package/distilled/workflows/plan-milestone-gaps.md +183 -183
  83. package/distilled/workflows/plan.md +454 -448
  84. package/distilled/workflows/progress.md +227 -223
  85. package/distilled/workflows/quick.md +351 -347
  86. package/distilled/workflows/resume.md +220 -212
  87. package/distilled/workflows/verify-work.md +260 -260
  88. package/distilled/workflows/verify.md +431 -429
  89. package/docs/BROWNFIELD-PROOF.md +95 -95
  90. package/docs/RUNTIME-SUPPORT.md +80 -69
  91. package/docs/USER-GUIDE.md +394 -386
  92. package/docs/VERIFICATION-DISCIPLINE.md +59 -59
  93. package/docs/claude/context-monitor.md +98 -98
  94. package/docs/proof/consumer-node-cli/README.md +37 -37
  95. package/docs/proof/consumer-node-cli/ROADMAP.md +14 -14
  96. package/docs/proof/consumer-node-cli/SPEC.md +17 -17
  97. package/docs/proof/consumer-node-cli/brief.md +9 -9
  98. package/docs/proof/consumer-node-cli/phases/01-foundation/01-01-PLAN.md +34 -34
  99. package/docs/proof/consumer-node-cli/phases/01-foundation/01-01-SUMMARY.md +10 -10
  100. package/docs/proof/consumer-node-cli/phases/01-foundation/01-VERIFICATION.md +30 -30
  101. package/package.json +62 -61
@@ -1,30 +1,35 @@
1
- export const PLAN_CHECK_DIMENSIONS = [
2
- 'requirement_coverage',
3
- 'task_completeness',
4
- 'dependency_correctness',
5
- 'key_link_completeness',
6
- 'scope_sanity',
7
- 'must_have_quality',
8
- 'context_compliance',
9
- 'goal_achievement',
10
- 'approach_alignment',
11
- ];
12
-
13
- export const MAX_CHECKER_CYCLES = 3;
14
-
15
- export const CHECKER_STATUSES = ['passed', 'issues_found'];
16
-
17
- export const CHECKER_JSON_SCHEMA = {
18
- status: 'passed | issues_found',
19
- summary: 'string',
20
- issues: [
21
- {
22
- dimension: 'string',
23
- severity: 'blocker | warning',
24
- description: 'string',
25
- plan: 'string',
26
- task: 'string',
27
- fix_hint: 'string',
28
- },
29
- ],
30
- };
1
+ export const PLAN_CHECK_DIMENSIONS = [
2
+ 'requirement_coverage',
3
+ 'task_completeness',
4
+ 'dependency_correctness',
5
+ 'key_link_completeness',
6
+ 'scope_sanity',
7
+ 'must_have_quality',
8
+ 'context_compliance',
9
+ 'goal_achievement',
10
+ 'scope_boundaries',
11
+ 'anti_regression_capture',
12
+ 'escalation_integrity',
13
+ 'closure_honesty',
14
+ 'high_leverage_review',
15
+ 'approach_alignment',
16
+ ];
17
+
18
+ export const MAX_CHECKER_CYCLES = 3;
19
+
20
+ export const CHECKER_STATUSES = ['passed', 'issues_found'];
21
+
22
+ export const CHECKER_JSON_SCHEMA = {
23
+ status: 'passed | issues_found',
24
+ summary: 'string',
25
+ issues: [
26
+ {
27
+ dimension: 'string',
28
+ severity: 'blocker | warning',
29
+ description: 'string',
30
+ plan: 'string',
31
+ task: 'string',
32
+ fix_hint: 'string',
33
+ },
34
+ ],
35
+ };
@@ -1,56 +1,59 @@
1
- function normalizePrState(prState) {
2
- if (!prState) return 'none';
3
- return String(prState).trim().toLowerCase();
4
- }
5
-
6
- function normalizeCount(value) {
7
- if (value === 'unknown' || value === null || value === undefined) return 'unknown';
8
- const numeric = Number(value);
9
- return Number.isFinite(numeric) ? numeric : 'unknown';
10
- }
11
-
12
- function normalizeCheckpointWorkflow(workflow) {
13
- const normalized = String(workflow || 'generic').trim().toLowerCase();
14
- return ['phase', 'quick', 'generic'].includes(normalized) ? normalized : 'generic';
15
- }
16
-
1
+ function normalizePrState(prState) {
2
+ if (!prState) return 'none';
3
+ return String(prState).trim().toLowerCase();
4
+ }
5
+
6
+ function normalizeCount(value) {
7
+ if (value === 'unknown' || value === null || value === undefined) return 'unknown';
8
+ const numeric = Number(value);
9
+ return Number.isFinite(numeric) ? numeric : 'unknown';
10
+ }
11
+
12
+ function normalizeCheckpointWorkflow(workflow) {
13
+ const normalized = String(workflow || 'generic').trim().toLowerCase();
14
+ return ['phase', 'quick', 'generic'].includes(normalized) ? normalized : 'generic';
15
+ }
16
+
17
17
  export function classifyCheckpointRouting(workflow) {
18
18
  const normalizedWorkflow = normalizeCheckpointWorkflow(workflow);
19
19
  const progressBlocks = normalizedWorkflow === 'phase' || normalizedWorkflow === 'quick';
20
-
21
- return {
22
- workflow: normalizedWorkflow,
23
- routingClass: progressBlocks ? 'blocking' : 'informational',
24
- progressBlocks,
25
- resumeOwnsCleanup: true,
26
- };
27
- }
28
-
20
+
21
+ return {
22
+ workflow: normalizedWorkflow,
23
+ routingClass: progressBlocks ? 'blocking' : 'informational',
24
+ progressBlocks,
25
+ resumeOwnsCleanup: true,
26
+ };
27
+ }
28
+
29
29
  export function parseGitStatusShort(statusText = '') {
30
- const lines = statusText
31
- .replace(/\r\n/g, '\n')
32
- .split('\n')
33
- .map((line) => line.trimEnd())
34
- .filter(Boolean);
35
-
36
- const files = [];
37
- for (const line of lines) {
38
- const match = line.match(/^(.)(.)\s+(.+)$/);
39
- if (!match) continue;
40
-
41
- const indexStatus = match[1];
42
- const worktreeStatus = match[2];
43
- if (indexStatus === '!' && worktreeStatus === '!') continue;
44
-
45
- const filePath = match[3].replace(/\\/g, '/');
46
- files.push({
47
- path: filePath,
48
- staged: indexStatus !== ' ' && indexStatus !== '?' && indexStatus !== '!',
49
- unstaged: worktreeStatus !== ' ' && worktreeStatus !== '?' && worktreeStatus !== '!',
50
- untracked: indexStatus === '?' || worktreeStatus === '?',
51
- });
52
- }
53
-
30
+ const lines = statusText
31
+ .replace(/\r\n/g, '\n')
32
+ .split('\n')
33
+ .map((line) => line.trimEnd())
34
+ .filter(Boolean);
35
+
36
+ const files = [];
37
+ for (const line of lines) {
38
+ const match = line.match(/^(.)(.)\s+(.+)$/);
39
+ if (!match) continue;
40
+
41
+ const indexStatus = match[1];
42
+ const worktreeStatus = match[2];
43
+ if (indexStatus === '!' && worktreeStatus === '!') continue;
44
+
45
+ const rawPath = match[3].replace(/\\/g, '/');
46
+ const renameMatch = rawPath.match(/^(.*?)\s+->\s+(.*?)$/);
47
+ const filePath = renameMatch ? renameMatch[2] : rawPath;
48
+ files.push({
49
+ path: filePath,
50
+ fromPath: renameMatch ? renameMatch[1] : null,
51
+ staged: indexStatus !== ' ' && indexStatus !== '?' && indexStatus !== '!',
52
+ unstaged: worktreeStatus !== ' ' && worktreeStatus !== '?' && worktreeStatus !== '!',
53
+ untracked: indexStatus === '?' || worktreeStatus === '?',
54
+ });
55
+ }
56
+
54
57
  return {
55
58
  files,
56
59
  stagedCount: files.filter((file) => file.staged).length,
@@ -206,55 +209,55 @@ export function buildProvenanceSnapshot({
206
209
  });
207
210
 
208
211
  const warnings = [];
209
-
210
- if (status.dirty) {
211
- warnings.push({
212
- id: 'dirty_worktree',
213
- severity: 'warning',
214
- summary: 'Local worktree contains staged, unstaged, or untracked changes.',
215
- });
216
- }
217
-
218
- if (commitsAheadOfMain !== 'unknown' && commitsAheadOfMain > 0) {
219
- warnings.push({
220
- id: 'ahead_of_main',
221
- severity: 'warning',
222
- summary: `${commitsAheadOfMain} commit(s) are ahead of main on the current branch.`,
223
- });
224
- }
225
-
226
- if (commitsAheadOfRemote !== 'unknown' && commitsAheadOfRemote > 0) {
227
- warnings.push({
228
- id: 'unpushed_commits',
229
- severity: 'warning',
230
- summary: `${commitsAheadOfRemote} commit(s) are ahead of the tracked remote branch.`,
231
- });
232
- }
233
-
234
- if (prState === 'none') {
235
- warnings.push({
236
- id: 'missing_pr',
237
- severity: 'warning',
238
- summary: 'No pull request is associated with the current branch.',
239
- });
240
- }
241
-
242
- if (git.staleBranch) {
243
- warnings.push({
244
- id: 'stale_branch',
245
- severity: 'warning',
246
- summary: 'The current branch is stale or spent relative to the intended integration surface.',
247
- });
248
- }
249
-
250
- if (git.mixedScope) {
251
- warnings.push({
252
- id: 'mixed_scope',
253
- severity: 'warning',
254
- summary: 'The current worktree appears to mix multiple write scopes or phases.',
255
- });
256
- }
257
-
212
+
213
+ if (status.dirty) {
214
+ warnings.push({
215
+ id: 'dirty_worktree',
216
+ severity: 'warning',
217
+ summary: 'Local worktree contains staged, unstaged, or untracked changes.',
218
+ });
219
+ }
220
+
221
+ if (commitsAheadOfMain !== 'unknown' && commitsAheadOfMain > 0) {
222
+ warnings.push({
223
+ id: 'ahead_of_main',
224
+ severity: 'warning',
225
+ summary: `${commitsAheadOfMain} commit(s) are ahead of main on the current branch.`,
226
+ });
227
+ }
228
+
229
+ if (commitsAheadOfRemote !== 'unknown' && commitsAheadOfRemote > 0) {
230
+ warnings.push({
231
+ id: 'unpushed_commits',
232
+ severity: 'warning',
233
+ summary: `${commitsAheadOfRemote} commit(s) are ahead of the tracked remote branch.`,
234
+ });
235
+ }
236
+
237
+ if (prState === 'none') {
238
+ warnings.push({
239
+ id: 'missing_pr',
240
+ severity: 'warning',
241
+ summary: 'No pull request is associated with the current branch.',
242
+ });
243
+ }
244
+
245
+ if (git.staleBranch) {
246
+ warnings.push({
247
+ id: 'stale_branch',
248
+ severity: 'warning',
249
+ summary: 'The current branch is stale or spent relative to the intended integration surface.',
250
+ });
251
+ }
252
+
253
+ if (git.mixedScope) {
254
+ warnings.push({
255
+ id: 'mixed_scope',
256
+ severity: 'warning',
257
+ summary: 'The current worktree appears to mix multiple write scopes or phases.',
258
+ });
259
+ }
260
+
258
261
  if (git.materialCheckpointMismatch) {
259
262
  warnings.push({
260
263
  id: 'checkpoint_mismatch',
@@ -299,14 +302,14 @@ export function buildProvenanceSnapshot({
299
302
  },
300
303
  git: {
301
304
  branch: git.branch || 'unknown',
302
- prState,
303
- commitsAheadOfMain,
304
- commitsAheadOfRemote,
305
- stagedCount: status.stagedCount,
306
- unstagedCount: status.unstagedCount,
307
- untrackedCount: status.untrackedCount,
308
- dirty: status.dirty,
309
- },
305
+ prState,
306
+ commitsAheadOfMain,
307
+ commitsAheadOfRemote,
308
+ stagedCount: status.stagedCount,
309
+ unstagedCount: status.unstagedCount,
310
+ untrackedCount: status.untrackedCount,
311
+ dirty: status.dirty,
312
+ },
310
313
  integrationSurface: {
311
314
  staleBranch: Boolean(git.staleBranch),
312
315
  mixedScope: Boolean(git.mixedScope),
@@ -1,7 +1,7 @@
1
- import { existsSync, readFileSync } from 'fs';
2
- import { dirname, join } from 'path';
3
- import { fileURLToPath } from 'url';
4
-
1
+ import { existsSync, readFileSync } from 'fs';
2
+ import { dirname, join } from 'path';
3
+ import { fileURLToPath } from 'url';
4
+
5
5
  const __filename = fileURLToPath(import.meta.url);
6
6
  const __dirname = dirname(__filename);
7
7
  const DISTILLED_DIR = join(__dirname, '..', '..', 'distilled');
@@ -15,28 +15,28 @@ const HELPER_LIB_FILES = Object.freeze([
15
15
  'session-fingerprint.mjs',
16
16
  'workspace-root.mjs',
17
17
  ]);
18
-
19
- function getWorkflowContent(workflowFile) {
20
- const filePath = join(DISTILLED_DIR, 'workflows', workflowFile);
21
- if (existsSync(filePath)) return readFileSync(filePath, 'utf-8');
22
- return `<!-- Workflow file not found: ${workflowFile} -->\n`;
23
- }
24
-
25
- function getDelegateContent(delegateFile) {
26
- const filePath = join(DISTILLED_DIR, 'templates', 'delegates', delegateFile);
27
- if (existsSync(filePath)) return readFileSync(filePath, 'utf-8');
28
- return `<!-- Delegate file not found: ${delegateFile} -->\n`;
29
- }
30
-
18
+
19
+ function getWorkflowContent(workflowFile) {
20
+ const filePath = join(DISTILLED_DIR, 'workflows', workflowFile);
21
+ if (existsSync(filePath)) return readFileSync(filePath, 'utf-8');
22
+ return `<!-- Workflow file not found: ${workflowFile} -->\n`;
23
+ }
24
+
25
+ function getDelegateContent(delegateFile) {
26
+ const filePath = join(DISTILLED_DIR, 'templates', 'delegates', delegateFile);
27
+ if (existsSync(filePath)) return readFileSync(filePath, 'utf-8');
28
+ return `<!-- Delegate file not found: ${delegateFile} -->\n`;
29
+ }
30
+
31
31
  function renderSkillContent(workflow) {
32
32
  const workflowContent = getWorkflowContent(workflow.workflow);
33
33
  return `---
34
34
  name: ${workflow.name}
35
35
  description: ${workflow.description}
36
- context: fork
37
- agent: ${workflow.agent}
38
- ---
39
-
36
+ context: fork
37
+ agent: ${workflow.agent}
38
+ ---
39
+
40
40
  ${workflowContent}`;
41
41
  }
42
42
 
@@ -46,34 +46,70 @@ function renderPlanningCliLauncher() {
46
46
  import { cmdFileOp } from './lib/file-ops.mjs';
47
47
  import { cmdLifecyclePreflight } from './lib/lifecycle-preflight.mjs';
48
48
  import { cmdPhaseStatus } from './lib/phase.mjs';
49
- import { bootstrapHelperWorkspace } from './lib/workspace-root.mjs';
50
-
51
- bootstrapHelperWorkspace(import.meta.url);
49
+ import { cmdSessionFingerprint } from './lib/session-fingerprint.mjs';
50
+ import { bootstrapHelperWorkspace, consumeWorkspaceRootArg, resolveWorkspaceContext } from './lib/workspace-root.mjs';
52
51
 
53
52
  const COMMANDS = {
54
53
  'file-op': cmdFileOp,
55
54
  'lifecycle-preflight': cmdLifecyclePreflight,
56
55
  'phase-status': cmdPhaseStatus,
56
+ 'session-fingerprint': cmdSessionFingerprint,
57
57
  };
58
58
 
59
59
  function printHelp() {
60
60
  console.log([
61
- 'Usage: node .planning/bin/gsdd.mjs <command> [args]',
61
+ 'Usage: node .planning/bin/gsdd.mjs [--workspace-root <path>] <command> [args]',
62
62
  '',
63
63
  'Local workflow helper commands:',
64
64
  ' file-op <copy|delete|regex-sub>',
65
65
  ' Run deterministic workspace-confined file operations',
66
+ ' Example: node .planning/bin/gsdd.mjs file-op delete .planning/.continue-here.bak --missing ok',
66
67
  ' phase-status <N> <status> Update ROADMAP.md phase status ([ ] / [-] / [x])',
68
+ ' Example: node .planning/bin/gsdd.mjs phase-status 1 done',
67
69
  ' lifecycle-preflight <surface> [phase]',
68
70
  ' Inspect lifecycle gate results for a workflow surface',
71
+ ' Example: node .planning/bin/gsdd.mjs lifecycle-preflight verify 1 --expects-mutation phase-status',
72
+ ' session-fingerprint write',
73
+ ' Rebaseline planning-state drift after reviewing changed planning files',
69
74
  '',
70
75
  'Advanced option:',
71
- ' --workspace-root <path> Override workspace root discovery when needed',
76
+ ' --workspace-root <path> Override workspace root discovery before or after the subcommand',
72
77
  ].join('\\n'));
73
78
  }
74
79
 
80
+ function applyWorkspaceRootOverride(workspaceRootArg) {
81
+ if (!workspaceRootArg) {
82
+ bootstrapHelperWorkspace(import.meta.url);
83
+ return true;
84
+ }
85
+
86
+ const context = resolveWorkspaceContext(['--workspace-root', workspaceRootArg]);
87
+ if (context.invalid) {
88
+ console.error(context.error);
89
+ process.exitCode = 1;
90
+ return false;
91
+ }
92
+
93
+ process.env.GSDD_WORKSPACE_ROOT = context.workspaceRoot;
94
+ try {
95
+ process.chdir(context.workspaceRoot);
96
+ } catch {
97
+ // best-effort: command handlers also resolve from GSDD_WORKSPACE_ROOT
98
+ }
99
+ return true;
100
+ }
101
+
75
102
  async function main() {
76
- const [command, ...args] = process.argv.slice(2);
103
+ const parsed = consumeWorkspaceRootArg(process.argv.slice(2));
104
+ if (parsed.invalid) {
105
+ console.error('Usage: --workspace-root <path>');
106
+ process.exitCode = 1;
107
+ return;
108
+ }
109
+
110
+ if (!applyWorkspaceRootOverride(parsed.workspaceRootArg)) return;
111
+
112
+ const [command, ...args] = parsed.args;
77
113
 
78
114
  if (!command || command === 'help' || command === '--help') {
79
115
  printHelp();
@@ -151,62 +187,62 @@ function buildPortableSkillEntries(workflows) {
151
187
  relativePath: `.agents/skills/${workflow.name}/SKILL.md`,
152
188
  content: renderSkillContent(workflow),
153
189
  }));
154
- }
155
-
156
- function renderOpenCodeCommandContent(workflow) {
157
- const workflowContent = getWorkflowContent(workflow.workflow);
158
- return `---
159
- description: ${workflow.description}
160
- ---
161
-
162
- ${workflowContent}`;
163
- }
164
-
165
- function renderAgentsBoundedBlock() {
166
- const blockPath = join(DISTILLED_DIR, 'templates', 'agents.block.md');
167
- if (existsSync(blockPath)) return readFileSync(blockPath, 'utf-8').trim();
168
- return '## GSDD Governance (Generated)\n\n- Framework: GSDD\n- Planning: .planning/\n- Workflows: .agents/skills/gsdd-*/SKILL.md';
169
- }
170
-
171
- function renderAgentsFileContent() {
172
- const templatePath = join(DISTILLED_DIR, 'templates', 'agents.md');
173
- if (existsSync(templatePath)) {
174
- const template = readFileSync(templatePath, 'utf-8');
175
- return template.replace('{{GSDD_BLOCK}}', renderAgentsBoundedBlock()).trimEnd() + '\n';
176
- }
177
- const block = renderAgentsBoundedBlock();
178
- return `# AGENTS.md - GSDD Governance\n\n<!-- BEGIN GSDD -->\n${block}\n<!-- END GSDD -->\n`;
179
- }
180
-
181
- function escapeRegExp(value) {
182
- return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
183
- }
184
-
185
- function upsertBoundedBlock(existing, blockContent) {
186
- const begin = '<!-- BEGIN GSDD -->';
187
- const end = '<!-- END GSDD -->';
188
- const bounded = `${begin}\n${blockContent.trimEnd()}\n${end}`;
189
-
190
- const re = new RegExp(`${escapeRegExp(begin)}[\\s\\S]*?${escapeRegExp(end)}`, 'm');
191
- if (re.test(existing)) return existing.replace(re, bounded);
192
-
193
- const lines = existing.split(/\r?\n/);
194
- const h1Idx = lines.findIndex((line) => /^#\s+/.test(line));
195
- if (h1Idx !== -1) {
196
- const insertAt = h1Idx + 1;
197
- const out = [
198
- ...lines.slice(0, insertAt),
199
- '',
200
- bounded,
201
- '',
202
- ...lines.slice(insertAt),
203
- ];
204
- return out.join('\n').replace(/\n{3,}/g, '\n\n');
205
- }
206
-
207
- return `${bounded}\n\n${existing}`.replace(/\n{3,}/g, '\n\n');
208
- }
209
-
190
+ }
191
+
192
+ function renderOpenCodeCommandContent(workflow) {
193
+ const workflowContent = getWorkflowContent(workflow.workflow);
194
+ return `---
195
+ description: ${workflow.description}
196
+ ---
197
+
198
+ ${workflowContent}`;
199
+ }
200
+
201
+ function renderAgentsBoundedBlock() {
202
+ const blockPath = join(DISTILLED_DIR, 'templates', 'agents.block.md');
203
+ if (existsSync(blockPath)) return readFileSync(blockPath, 'utf-8').trim();
204
+ return '## GSDD Governance (Generated)\n\n- Framework: GSDD\n- Planning: .planning/\n- Workflows: .agents/skills/gsdd-*/SKILL.md';
205
+ }
206
+
207
+ function renderAgentsFileContent() {
208
+ const templatePath = join(DISTILLED_DIR, 'templates', 'agents.md');
209
+ if (existsSync(templatePath)) {
210
+ const template = readFileSync(templatePath, 'utf-8');
211
+ return template.replace('{{GSDD_BLOCK}}', renderAgentsBoundedBlock()).trimEnd() + '\n';
212
+ }
213
+ const block = renderAgentsBoundedBlock();
214
+ return `# AGENTS.md - GSDD Governance\n\n<!-- BEGIN GSDD -->\n${block}\n<!-- END GSDD -->\n`;
215
+ }
216
+
217
+ function escapeRegExp(value) {
218
+ return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
219
+ }
220
+
221
+ function upsertBoundedBlock(existing, blockContent) {
222
+ const begin = '<!-- BEGIN GSDD -->';
223
+ const end = '<!-- END GSDD -->';
224
+ const bounded = `${begin}\n${blockContent.trimEnd()}\n${end}`;
225
+
226
+ const re = new RegExp(`${escapeRegExp(begin)}[\\s\\S]*?${escapeRegExp(end)}`, 'm');
227
+ if (re.test(existing)) return existing.replace(re, bounded);
228
+
229
+ const lines = existing.split(/\r?\n/);
230
+ const h1Idx = lines.findIndex((line) => /^#\s+/.test(line));
231
+ if (h1Idx !== -1) {
232
+ const insertAt = h1Idx + 1;
233
+ const out = [
234
+ ...lines.slice(0, insertAt),
235
+ '',
236
+ bounded,
237
+ '',
238
+ ...lines.slice(insertAt),
239
+ ];
240
+ return out.join('\n').replace(/\n{3,}/g, '\n\n');
241
+ }
242
+
243
+ return `${bounded}\n\n${existing}`.replace(/\n{3,}/g, '\n\n');
244
+ }
245
+
210
246
  export {
211
247
  buildPlanningCliHelperEntries,
212
248
  buildPortableSkillEntries,