pi-gsd 2.0.1 → 2.0.3
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/dist/pi-gsd-hooks.js +1533 -0
- package/dist/pi-gsd-tools.js +53 -52
- package/package.json +3 -5
- package/.gsd/extensions/pi-gsd-hooks.ts +0 -973
- package/src/cli.ts +0 -644
- package/src/commands/base.ts +0 -67
- package/src/commands/commit.ts +0 -22
- package/src/commands/config.ts +0 -71
- package/src/commands/frontmatter.ts +0 -51
- package/src/commands/index.ts +0 -76
- package/src/commands/init.ts +0 -43
- package/src/commands/milestone.ts +0 -37
- package/src/commands/phase.ts +0 -92
- package/src/commands/progress.ts +0 -71
- package/src/commands/roadmap.ts +0 -40
- package/src/commands/scaffold.ts +0 -19
- package/src/commands/state.ts +0 -102
- package/src/commands/template.ts +0 -52
- package/src/commands/verify.ts +0 -70
- package/src/commands/workstream.ts +0 -98
- package/src/commands/wxp.ts +0 -65
- package/src/lib/commands.ts +0 -1040
- package/src/lib/config.ts +0 -385
- package/src/lib/core.ts +0 -1167
- package/src/lib/frontmatter.ts +0 -462
- package/src/lib/init.ts +0 -517
- package/src/lib/milestone.ts +0 -290
- package/src/lib/model-profiles.ts +0 -272
- package/src/lib/phase.ts +0 -1012
- package/src/lib/profile-output.ts +0 -237
- package/src/lib/profile-pipeline.ts +0 -556
- package/src/lib/roadmap.ts +0 -378
- package/src/lib/schemas.ts +0 -290
- package/src/lib/security.ts +0 -176
- package/src/lib/state.ts +0 -1175
- package/src/lib/template.ts +0 -246
- package/src/lib/uat.ts +0 -289
- package/src/lib/verify.ts +0 -879
- package/src/lib/workstream.ts +0 -524
- package/src/output.ts +0 -45
- package/src/schemas/pi-gsd-settings.schema.json +0 -80
- package/src/schemas/wxp.xsd +0 -619
- package/src/schemas/wxp.zod.ts +0 -318
- package/src/wxp/__tests__/arguments.test.ts +0 -86
- package/src/wxp/__tests__/conditions.test.ts +0 -106
- package/src/wxp/__tests__/executor.test.ts +0 -95
- package/src/wxp/__tests__/helpers.ts +0 -26
- package/src/wxp/__tests__/integration.test.ts +0 -166
- package/src/wxp/__tests__/new-features.test.ts +0 -222
- package/src/wxp/__tests__/parser.test.ts +0 -159
- package/src/wxp/__tests__/paste.test.ts +0 -66
- package/src/wxp/__tests__/schema.test.ts +0 -120
- package/src/wxp/__tests__/security.test.ts +0 -87
- package/src/wxp/__tests__/shell.test.ts +0 -85
- package/src/wxp/__tests__/string-ops.test.ts +0 -25
- package/src/wxp/__tests__/variables.test.ts +0 -65
- package/src/wxp/arguments.ts +0 -89
- package/src/wxp/conditions.ts +0 -78
- package/src/wxp/executor.ts +0 -191
- package/src/wxp/index.ts +0 -191
- package/src/wxp/parser.ts +0 -198
- package/src/wxp/paste.ts +0 -51
- package/src/wxp/security.ts +0 -102
- package/src/wxp/shell.ts +0 -81
- package/src/wxp/string-ops.ts +0 -44
- package/src/wxp/variables.ts +0 -109
package/src/lib/init.ts
DELETED
|
@@ -1,517 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* init.ts - Compound init commands for workflow bootstrapping.
|
|
3
|
-
*
|
|
4
|
-
* Each cmdInit* gathers all context needed by a workflow in one call.
|
|
5
|
-
* Ported from lib/init.cjs.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import fs from "fs";
|
|
9
|
-
import path from "path";
|
|
10
|
-
import {
|
|
11
|
-
checkAgentsInstalled,
|
|
12
|
-
comparePhaseNum,
|
|
13
|
-
findPhaseInternal,
|
|
14
|
-
generateSlugInternal,
|
|
15
|
-
getMilestoneInfo,
|
|
16
|
-
getMilestonePhaseFilter,
|
|
17
|
-
getRoadmapPhaseInternal,
|
|
18
|
-
gsdError,
|
|
19
|
-
loadConfig,
|
|
20
|
-
normalizePhaseName,
|
|
21
|
-
output,
|
|
22
|
-
planningDir,
|
|
23
|
-
planningPaths,
|
|
24
|
-
planningRoot,
|
|
25
|
-
resolveModelInternal,
|
|
26
|
-
stripShippedMilestones,
|
|
27
|
-
toPosixPath,
|
|
28
|
-
} from "./core.js";
|
|
29
|
-
|
|
30
|
-
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
31
|
-
|
|
32
|
-
function getLatestCompletedMilestone(
|
|
33
|
-
cwd: string,
|
|
34
|
-
): { version: string; name: string } | null {
|
|
35
|
-
const milestonesPath = path.join(planningRoot(cwd), "MILESTONES.md");
|
|
36
|
-
if (!fs.existsSync(milestonesPath)) return null;
|
|
37
|
-
try {
|
|
38
|
-
const content = fs.readFileSync(milestonesPath, "utf-8");
|
|
39
|
-
const match = content.match(/^##\s+(v[\d.]+)\s+(.+?)\s+\(Shipped:/m);
|
|
40
|
-
if (!match) return null;
|
|
41
|
-
return { version: match[1], name: match[2].trim() };
|
|
42
|
-
} catch {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function withProjectRoot(
|
|
48
|
-
cwd: string,
|
|
49
|
-
result: Record<string, unknown>,
|
|
50
|
-
): Record<string, unknown> {
|
|
51
|
-
result.project_root = cwd;
|
|
52
|
-
// For dist build: __dirname is dist/, gsd-tools.js is dist/gsd-tools.js
|
|
53
|
-
// Agents/ is at ../agents relative to dist/
|
|
54
|
-
result.gsd_bin = "dist/gsd-tools.js";
|
|
55
|
-
result.gsd_root = ".";
|
|
56
|
-
result.gsd_harness_dir = ".";
|
|
57
|
-
const agentStatus = checkAgentsInstalled();
|
|
58
|
-
result.agents_installed = agentStatus.agents_installed;
|
|
59
|
-
result.missing_agents = agentStatus.missing_agents;
|
|
60
|
-
return result;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// ─── Commands ─────────────────────────────────────────────────────────────────
|
|
64
|
-
|
|
65
|
-
export function cmdInitExecutePhase(
|
|
66
|
-
cwd: string,
|
|
67
|
-
phase: string | undefined,
|
|
68
|
-
raw: boolean,
|
|
69
|
-
): void {
|
|
70
|
-
if (!phase) gsdError("phase required for init execute-phase");
|
|
71
|
-
const config = loadConfig(cwd);
|
|
72
|
-
let phaseInfo = findPhaseInternal(cwd, phase!);
|
|
73
|
-
const milestone = getMilestoneInfo(cwd);
|
|
74
|
-
const roadmapPhase = getRoadmapPhaseInternal(cwd, phase!);
|
|
75
|
-
if (!phaseInfo && roadmapPhase?.found) {
|
|
76
|
-
const phaseName = roadmapPhase.phase_name;
|
|
77
|
-
phaseInfo = {
|
|
78
|
-
found: true,
|
|
79
|
-
directory: null!,
|
|
80
|
-
phase_number: roadmapPhase.phase_number,
|
|
81
|
-
phase_name: phaseName,
|
|
82
|
-
phase_slug: phaseName
|
|
83
|
-
? phaseName
|
|
84
|
-
.toLowerCase()
|
|
85
|
-
.replace(/[^a-z0-9]+/g, "-")
|
|
86
|
-
.replace(/^-+|-+$/g, "")
|
|
87
|
-
: null,
|
|
88
|
-
plans: [],
|
|
89
|
-
summaries: [],
|
|
90
|
-
incomplete_plans: [],
|
|
91
|
-
has_research: false,
|
|
92
|
-
has_context: false,
|
|
93
|
-
has_verification: false,
|
|
94
|
-
has_reviews: false,
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
const reqMatch = roadmapPhase?.section?.match(
|
|
98
|
-
/^\*\*Requirements\*\*:[^\S\n]*([^\n]*)$/m,
|
|
99
|
-
);
|
|
100
|
-
const reqExtracted = reqMatch
|
|
101
|
-
? reqMatch[1]
|
|
102
|
-
.replace(/[[\]]/g, "")
|
|
103
|
-
.split(",")
|
|
104
|
-
.map((s) => s.trim())
|
|
105
|
-
.filter(Boolean)
|
|
106
|
-
.join(", ")
|
|
107
|
-
: null;
|
|
108
|
-
const result = withProjectRoot(cwd, {
|
|
109
|
-
executor_model: resolveModelInternal(cwd, "gsd-executor"),
|
|
110
|
-
verifier_model: resolveModelInternal(cwd, "gsd-verifier"),
|
|
111
|
-
commit_docs: config.commit_docs,
|
|
112
|
-
sub_repos: config.sub_repos,
|
|
113
|
-
parallelization: config.parallelization,
|
|
114
|
-
context_window: config.context_window,
|
|
115
|
-
branching_strategy: config.branching_strategy,
|
|
116
|
-
phase_branch_template: config.phase_branch_template,
|
|
117
|
-
milestone_branch_template: config.milestone_branch_template,
|
|
118
|
-
verifier_enabled: config.verifier,
|
|
119
|
-
phase_found: !!phaseInfo,
|
|
120
|
-
phase_dir: phaseInfo?.directory ?? null,
|
|
121
|
-
phase_number: phaseInfo?.phase_number ?? null,
|
|
122
|
-
phase_name: phaseInfo?.phase_name ?? null,
|
|
123
|
-
phase_slug: phaseInfo?.phase_slug ?? null,
|
|
124
|
-
phase_req_ids: reqExtracted && reqExtracted !== "TBD" ? reqExtracted : null,
|
|
125
|
-
plans: phaseInfo?.plans ?? [],
|
|
126
|
-
summaries: phaseInfo?.summaries ?? [],
|
|
127
|
-
incomplete_plans: phaseInfo?.incomplete_plans ?? [],
|
|
128
|
-
has_research: phaseInfo?.has_research ?? false,
|
|
129
|
-
has_context: phaseInfo?.has_context ?? false,
|
|
130
|
-
has_verification: phaseInfo?.has_verification ?? false,
|
|
131
|
-
has_reviews: phaseInfo?.has_reviews ?? false,
|
|
132
|
-
roadmap_goal: roadmapPhase?.goal ?? null,
|
|
133
|
-
roadmap_section: roadmapPhase?.section ?? null,
|
|
134
|
-
milestone_version: milestone.version,
|
|
135
|
-
milestone_name: milestone.name,
|
|
136
|
-
});
|
|
137
|
-
output(result, raw);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export function cmdInitPlanPhase(
|
|
141
|
-
cwd: string,
|
|
142
|
-
phase: string | undefined,
|
|
143
|
-
raw: boolean,
|
|
144
|
-
): void {
|
|
145
|
-
if (!phase) gsdError("phase required for init plan-phase");
|
|
146
|
-
const config = loadConfig(cwd);
|
|
147
|
-
const phaseInfo = findPhaseInternal(cwd, phase!);
|
|
148
|
-
const roadmapPhase = getRoadmapPhaseInternal(cwd, phase!);
|
|
149
|
-
const milestone = getMilestoneInfo(cwd);
|
|
150
|
-
const result = withProjectRoot(cwd, {
|
|
151
|
-
planner_model: resolveModelInternal(cwd, "gsd-planner"),
|
|
152
|
-
researcher_model: resolveModelInternal(cwd, "gsd-phase-researcher"),
|
|
153
|
-
synthesizer_model: resolveModelInternal(cwd, "gsd-research-synthesizer"),
|
|
154
|
-
commit_docs: config.commit_docs,
|
|
155
|
-
research_enabled: config.research,
|
|
156
|
-
plan_checker_enabled: config.plan_checker,
|
|
157
|
-
context_window: config.context_window,
|
|
158
|
-
phase_found: !!phaseInfo,
|
|
159
|
-
phase_dir: phaseInfo?.directory ?? null,
|
|
160
|
-
phase_number: phaseInfo?.phase_number ?? null,
|
|
161
|
-
phase_name: phaseInfo?.phase_name ?? null,
|
|
162
|
-
roadmap_goal: roadmapPhase?.goal ?? null,
|
|
163
|
-
roadmap_section: roadmapPhase?.section ?? null,
|
|
164
|
-
milestone_version: milestone.version,
|
|
165
|
-
milestone_name: milestone.name,
|
|
166
|
-
});
|
|
167
|
-
output(result, raw);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export function cmdInitNewProject(cwd: string, raw: boolean): void {
|
|
171
|
-
const config = loadConfig(cwd);
|
|
172
|
-
const planningBase = planningRoot(cwd);
|
|
173
|
-
const result = withProjectRoot(cwd, {
|
|
174
|
-
planner_model: resolveModelInternal(cwd, "gsd-planner"),
|
|
175
|
-
roadmapper_model: resolveModelInternal(cwd, "gsd-roadmapper"),
|
|
176
|
-
commit_docs: config.commit_docs,
|
|
177
|
-
context_window: config.context_window,
|
|
178
|
-
planning_exists: fs.existsSync(planningBase),
|
|
179
|
-
project_exists: fs.existsSync(path.join(planningBase, "PROJECT.md")),
|
|
180
|
-
config_exists: fs.existsSync(path.join(planningBase, "config.json")),
|
|
181
|
-
roadmap_exists: fs.existsSync(path.join(planningBase, "ROADMAP.md")),
|
|
182
|
-
state_exists: fs.existsSync(path.join(planningBase, "STATE.md")),
|
|
183
|
-
});
|
|
184
|
-
output(result, raw);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
export function cmdInitNewMilestone(cwd: string, raw: boolean): void {
|
|
188
|
-
const config = loadConfig(cwd);
|
|
189
|
-
const milestone = getMilestoneInfo(cwd);
|
|
190
|
-
const lastCompleted = getLatestCompletedMilestone(cwd);
|
|
191
|
-
const result = withProjectRoot(cwd, {
|
|
192
|
-
roadmapper_model: resolveModelInternal(cwd, "gsd-roadmapper"),
|
|
193
|
-
commit_docs: config.commit_docs,
|
|
194
|
-
context_window: config.context_window,
|
|
195
|
-
current_milestone: milestone,
|
|
196
|
-
last_completed_milestone: lastCompleted,
|
|
197
|
-
roadmap_exists: fs.existsSync(planningPaths(cwd).roadmap),
|
|
198
|
-
});
|
|
199
|
-
output(result, raw);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export function cmdInitQuick(
|
|
203
|
-
cwd: string,
|
|
204
|
-
description: string | undefined,
|
|
205
|
-
raw: boolean,
|
|
206
|
-
): void {
|
|
207
|
-
const config = loadConfig(cwd);
|
|
208
|
-
const milestone = getMilestoneInfo(cwd);
|
|
209
|
-
const result = withProjectRoot(cwd, {
|
|
210
|
-
executor_model: resolveModelInternal(cwd, "gsd-executor"),
|
|
211
|
-
commit_docs: config.commit_docs,
|
|
212
|
-
context_window: config.context_window,
|
|
213
|
-
branching_strategy: config.branching_strategy,
|
|
214
|
-
quick_branch_template: config.quick_branch_template,
|
|
215
|
-
description: description || null,
|
|
216
|
-
milestone_version: milestone.version,
|
|
217
|
-
milestone_name: milestone.name,
|
|
218
|
-
state_exists: fs.existsSync(planningPaths(cwd).state),
|
|
219
|
-
});
|
|
220
|
-
output(result, raw);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
export function cmdInitResume(cwd: string, raw: boolean): void {
|
|
224
|
-
const config = loadConfig(cwd);
|
|
225
|
-
const milestone = getMilestoneInfo(cwd);
|
|
226
|
-
const stateExists = fs.existsSync(planningPaths(cwd).state);
|
|
227
|
-
let stateContent = "";
|
|
228
|
-
if (stateExists) {
|
|
229
|
-
try {
|
|
230
|
-
stateContent = fs.readFileSync(planningPaths(cwd).state, "utf-8");
|
|
231
|
-
} catch {
|
|
232
|
-
/* ok */
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
const result = withProjectRoot(cwd, {
|
|
236
|
-
executor_model: resolveModelInternal(cwd, "gsd-executor"),
|
|
237
|
-
commit_docs: config.commit_docs,
|
|
238
|
-
context_window: config.context_window,
|
|
239
|
-
state_exists: stateExists,
|
|
240
|
-
state_raw: stateContent,
|
|
241
|
-
roadmap_exists: fs.existsSync(planningPaths(cwd).roadmap),
|
|
242
|
-
config_exists: fs.existsSync(planningPaths(cwd).config),
|
|
243
|
-
milestone_version: milestone.version,
|
|
244
|
-
milestone_name: milestone.name,
|
|
245
|
-
});
|
|
246
|
-
output(result, raw);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
export function cmdInitVerifyWork(
|
|
250
|
-
cwd: string,
|
|
251
|
-
phase: string | undefined,
|
|
252
|
-
raw: boolean,
|
|
253
|
-
): void {
|
|
254
|
-
if (!phase) gsdError("phase required for init verify-work");
|
|
255
|
-
const config = loadConfig(cwd);
|
|
256
|
-
const phaseInfo = findPhaseInternal(cwd, phase!);
|
|
257
|
-
const roadmapPhase = getRoadmapPhaseInternal(cwd, phase!);
|
|
258
|
-
const result = withProjectRoot(cwd, {
|
|
259
|
-
verifier_model: resolveModelInternal(cwd, "gsd-verifier"),
|
|
260
|
-
nyquist_model: resolveModelInternal(cwd, "gsd-nyquist-auditor"),
|
|
261
|
-
commit_docs: config.commit_docs,
|
|
262
|
-
nyquist_validation: config.nyquist_validation,
|
|
263
|
-
context_window: config.context_window,
|
|
264
|
-
phase_found: !!phaseInfo,
|
|
265
|
-
phase_dir: phaseInfo?.directory ?? null,
|
|
266
|
-
phase_number: phaseInfo?.phase_number ?? null,
|
|
267
|
-
phase_name: phaseInfo?.phase_name ?? null,
|
|
268
|
-
plans: phaseInfo?.plans ?? [],
|
|
269
|
-
summaries: phaseInfo?.summaries ?? [],
|
|
270
|
-
roadmap_goal: roadmapPhase?.goal ?? null,
|
|
271
|
-
});
|
|
272
|
-
output(result, raw);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
export function cmdInitPhaseOp(
|
|
276
|
-
cwd: string,
|
|
277
|
-
phase: string | undefined,
|
|
278
|
-
raw: boolean,
|
|
279
|
-
): void {
|
|
280
|
-
const config = loadConfig(cwd);
|
|
281
|
-
const phaseInfo = phase ? findPhaseInternal(cwd, phase) : null;
|
|
282
|
-
const milestone = getMilestoneInfo(cwd);
|
|
283
|
-
const result = withProjectRoot(cwd, {
|
|
284
|
-
planner_model: resolveModelInternal(cwd, "gsd-planner"),
|
|
285
|
-
commit_docs: config.commit_docs,
|
|
286
|
-
context_window: config.context_window,
|
|
287
|
-
phase_found: !!phaseInfo,
|
|
288
|
-
phase_dir: phaseInfo?.directory ?? null,
|
|
289
|
-
phase_number: phaseInfo?.phase_number ?? null,
|
|
290
|
-
phase_name: phaseInfo?.phase_name ?? null,
|
|
291
|
-
milestone_version: milestone.version,
|
|
292
|
-
milestone_name: milestone.name,
|
|
293
|
-
});
|
|
294
|
-
output(result, raw);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
export function cmdInitTodos(
|
|
298
|
-
cwd: string,
|
|
299
|
-
area: string | undefined,
|
|
300
|
-
raw: boolean,
|
|
301
|
-
): void {
|
|
302
|
-
const config = loadConfig(cwd);
|
|
303
|
-
const pendingDir = path.join(planningDir(cwd), "todos", "pending");
|
|
304
|
-
const todos: unknown[] = [];
|
|
305
|
-
if (fs.existsSync(pendingDir)) {
|
|
306
|
-
try {
|
|
307
|
-
for (const file of fs
|
|
308
|
-
.readdirSync(pendingDir)
|
|
309
|
-
.filter((f) => f.endsWith(".md"))) {
|
|
310
|
-
try {
|
|
311
|
-
const content = fs.readFileSync(path.join(pendingDir, file), "utf-8");
|
|
312
|
-
const titleMatch = content.match(/^title:\s*(.+)$/m),
|
|
313
|
-
areaMatch = content.match(/^area:\s*(.+)$/m);
|
|
314
|
-
const todoArea = areaMatch ? areaMatch[1].trim() : "general";
|
|
315
|
-
if (area && todoArea !== area) continue;
|
|
316
|
-
todos.push({
|
|
317
|
-
file,
|
|
318
|
-
title: titleMatch ? titleMatch[1].trim() : "Untitled",
|
|
319
|
-
area: todoArea,
|
|
320
|
-
});
|
|
321
|
-
} catch {
|
|
322
|
-
/* ok */
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
} catch {
|
|
326
|
-
/* ok */
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
const result = withProjectRoot(cwd, {
|
|
330
|
-
executor_model: resolveModelInternal(cwd, "gsd-executor"),
|
|
331
|
-
commit_docs: config.commit_docs,
|
|
332
|
-
todos,
|
|
333
|
-
todo_count: todos.length,
|
|
334
|
-
area: area ?? null,
|
|
335
|
-
});
|
|
336
|
-
output(result, raw);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
export function cmdInitMilestoneOp(cwd: string, raw: boolean): void {
|
|
340
|
-
const config = loadConfig(cwd);
|
|
341
|
-
const milestone = getMilestoneInfo(cwd);
|
|
342
|
-
const lastCompleted = getLatestCompletedMilestone(cwd);
|
|
343
|
-
const result = withProjectRoot(cwd, {
|
|
344
|
-
planner_model: resolveModelInternal(cwd, "gsd-planner"),
|
|
345
|
-
commit_docs: config.commit_docs,
|
|
346
|
-
context_window: config.context_window,
|
|
347
|
-
milestone_version: milestone.version,
|
|
348
|
-
milestone_name: milestone.name,
|
|
349
|
-
last_completed_milestone: lastCompleted,
|
|
350
|
-
roadmap_exists: fs.existsSync(planningPaths(cwd).roadmap),
|
|
351
|
-
state_exists: fs.existsSync(planningPaths(cwd).state),
|
|
352
|
-
});
|
|
353
|
-
output(result, raw);
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
export function cmdInitMapCodebase(cwd: string, raw: boolean): void {
|
|
357
|
-
const config = loadConfig(cwd);
|
|
358
|
-
const result = withProjectRoot(cwd, {
|
|
359
|
-
mapper_model: resolveModelInternal(cwd, "gsd-codebase-mapper"),
|
|
360
|
-
commit_docs: config.commit_docs,
|
|
361
|
-
search_gitignored: config.search_gitignored,
|
|
362
|
-
context_window: config.context_window,
|
|
363
|
-
project_exists: fs.existsSync(path.join(planningRoot(cwd), "PROJECT.md")),
|
|
364
|
-
});
|
|
365
|
-
output(result, raw);
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
export function cmdInitProgress(cwd: string, raw: boolean): void {
|
|
369
|
-
const config = loadConfig(cwd);
|
|
370
|
-
const milestone = getMilestoneInfo(cwd);
|
|
371
|
-
const isDirInMilestone = getMilestonePhaseFilter(cwd);
|
|
372
|
-
const phasesDir = planningPaths(cwd).phases;
|
|
373
|
-
let totalPlans = 0,
|
|
374
|
-
totalSummaries = 0,
|
|
375
|
-
phaseCount = 0;
|
|
376
|
-
if (fs.existsSync(phasesDir)) {
|
|
377
|
-
try {
|
|
378
|
-
const dirs = fs
|
|
379
|
-
.readdirSync(phasesDir, { withFileTypes: true })
|
|
380
|
-
.filter((e) => e.isDirectory())
|
|
381
|
-
.map((e) => e.name)
|
|
382
|
-
.filter(isDirInMilestone);
|
|
383
|
-
phaseCount = dirs.length;
|
|
384
|
-
for (const dir of dirs) {
|
|
385
|
-
const files = fs.readdirSync(path.join(phasesDir, dir));
|
|
386
|
-
totalPlans += files.filter((f) => f.match(/-PLAN\.md$/i)).length;
|
|
387
|
-
totalSummaries += files.filter((f) => f.match(/-SUMMARY\.md$/i)).length;
|
|
388
|
-
}
|
|
389
|
-
} catch {
|
|
390
|
-
/* ok */
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
const result = withProjectRoot(cwd, {
|
|
394
|
-
commit_docs: config.commit_docs,
|
|
395
|
-
context_window: config.context_window,
|
|
396
|
-
milestone_version: milestone.version,
|
|
397
|
-
milestone_name: milestone.name,
|
|
398
|
-
phase_count: phaseCount,
|
|
399
|
-
total_plans: totalPlans,
|
|
400
|
-
total_summaries: totalSummaries,
|
|
401
|
-
percent:
|
|
402
|
-
totalPlans > 0
|
|
403
|
-
? Math.min(100, Math.round((totalSummaries / totalPlans) * 100))
|
|
404
|
-
: 0,
|
|
405
|
-
});
|
|
406
|
-
output(result, raw);
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
export function cmdInitManager(cwd: string, raw: boolean): void {
|
|
410
|
-
const config = loadConfig(cwd);
|
|
411
|
-
const milestone = getMilestoneInfo(cwd);
|
|
412
|
-
const result = withProjectRoot(cwd, {
|
|
413
|
-
planner_model: resolveModelInternal(cwd, "gsd-planner"),
|
|
414
|
-
roadmapper_model: resolveModelInternal(cwd, "gsd-roadmapper"),
|
|
415
|
-
commit_docs: config.commit_docs,
|
|
416
|
-
context_window: config.context_window,
|
|
417
|
-
milestone_version: milestone.version,
|
|
418
|
-
milestone_name: milestone.name,
|
|
419
|
-
state_exists: fs.existsSync(planningPaths(cwd).state),
|
|
420
|
-
roadmap_exists: fs.existsSync(planningPaths(cwd).roadmap),
|
|
421
|
-
});
|
|
422
|
-
output(result, raw);
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
// ─── Workspace / workstream init variants ────────────────────────────────────
|
|
426
|
-
|
|
427
|
-
export function cmdInitNewWorkspace(cwd: string, raw: boolean): void {
|
|
428
|
-
const config = loadConfig(cwd);
|
|
429
|
-
const wsRoot = path.join(planningRoot(cwd), "workstreams");
|
|
430
|
-
const result = withProjectRoot(cwd, {
|
|
431
|
-
commit_docs: config.commit_docs,
|
|
432
|
-
context_window: config.context_window,
|
|
433
|
-
workstream_mode: fs.existsSync(wsRoot),
|
|
434
|
-
workstreams: fs.existsSync(wsRoot)
|
|
435
|
-
? fs
|
|
436
|
-
.readdirSync(wsRoot, { withFileTypes: true })
|
|
437
|
-
.filter((e) => e.isDirectory())
|
|
438
|
-
.map((e) => e.name)
|
|
439
|
-
: [],
|
|
440
|
-
});
|
|
441
|
-
output(result, raw);
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
export function cmdInitListWorkspaces(cwd: string, raw: boolean): void {
|
|
445
|
-
const wsRoot = path.join(planningRoot(cwd), "workstreams");
|
|
446
|
-
if (!fs.existsSync(wsRoot)) {
|
|
447
|
-
output(
|
|
448
|
-
withProjectRoot(cwd, { mode: "flat", workstreams: [], count: 0 }),
|
|
449
|
-
raw,
|
|
450
|
-
);
|
|
451
|
-
return;
|
|
452
|
-
}
|
|
453
|
-
const workstreams = fs
|
|
454
|
-
.readdirSync(wsRoot, { withFileTypes: true })
|
|
455
|
-
.filter((e) => e.isDirectory())
|
|
456
|
-
.map((e) => e.name);
|
|
457
|
-
output(
|
|
458
|
-
withProjectRoot(cwd, {
|
|
459
|
-
mode: "workstream",
|
|
460
|
-
workstreams,
|
|
461
|
-
count: workstreams.length,
|
|
462
|
-
}),
|
|
463
|
-
raw,
|
|
464
|
-
);
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
export function cmdInitRemoveWorkspace(
|
|
468
|
-
cwd: string,
|
|
469
|
-
name: string | undefined,
|
|
470
|
-
raw: boolean,
|
|
471
|
-
): void {
|
|
472
|
-
if (!name) gsdError("workstream name required for init remove-workspace");
|
|
473
|
-
const wsDir = path.join(planningRoot(cwd), "workstreams", name!);
|
|
474
|
-
if (!fs.existsSync(wsDir)) {
|
|
475
|
-
output(
|
|
476
|
-
withProjectRoot(cwd, {
|
|
477
|
-
removed: false,
|
|
478
|
-
reason: "not_found",
|
|
479
|
-
workstream: name,
|
|
480
|
-
}),
|
|
481
|
-
raw,
|
|
482
|
-
);
|
|
483
|
-
return;
|
|
484
|
-
}
|
|
485
|
-
try {
|
|
486
|
-
fs.rmSync(wsDir, { recursive: true, force: true });
|
|
487
|
-
} catch (e) {
|
|
488
|
-
output(
|
|
489
|
-
withProjectRoot(cwd, {
|
|
490
|
-
removed: false,
|
|
491
|
-
reason: (e as Error).message,
|
|
492
|
-
workstream: name,
|
|
493
|
-
}),
|
|
494
|
-
raw,
|
|
495
|
-
);
|
|
496
|
-
return;
|
|
497
|
-
}
|
|
498
|
-
output(withProjectRoot(cwd, { removed: true, workstream: name }), raw);
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
// ─── cmdAgentSkills ───────────────────────────────────────────────────────────
|
|
502
|
-
|
|
503
|
-
export function cmdAgentSkills(
|
|
504
|
-
cwd: string,
|
|
505
|
-
agentType: string | undefined,
|
|
506
|
-
raw: boolean,
|
|
507
|
-
): void {
|
|
508
|
-
if (!agentType) gsdError("agent-type required");
|
|
509
|
-
const config = loadConfig(cwd);
|
|
510
|
-
const agentSkills =
|
|
511
|
-
(config.agent_skills as Record<string, unknown>)[agentType!] ?? {};
|
|
512
|
-
output(
|
|
513
|
-
{ agent: agentType, skills: agentSkills },
|
|
514
|
-
raw,
|
|
515
|
-
JSON.stringify(agentSkills),
|
|
516
|
-
);
|
|
517
|
-
}
|