gsd-pi 2.70.1-dev.3591dcf → 2.70.1-dev.3a83e16
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/resources/extensions/claude-code-cli/stream-adapter.js +129 -30
- package/dist/resources/extensions/get-secrets-from-user.js +17 -1
- package/dist/resources/extensions/gsd/auto-start.js +3 -11
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +4 -0
- package/dist/resources/extensions/gsd/custom-workflow-engine.js +16 -12
- package/dist/resources/extensions/gsd/file-lock.js +60 -0
- package/dist/resources/extensions/gsd/guided-flow.js +12 -10
- package/dist/resources/extensions/gsd/init-wizard.js +3 -11
- package/dist/resources/extensions/gsd/prompts/discuss.md +31 -13
- package/dist/resources/extensions/gsd/state.js +234 -332
- package/dist/resources/extensions/gsd/tools/workflow-tool-executors.js +34 -0
- package/dist/resources/extensions/gsd/workflow-events.js +25 -13
- package/dist/resources/extensions/gsd/workflow-mcp-auto-prep.js +56 -0
- package/dist/resources/extensions/gsd/workflow-mcp.js +1 -1
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +11 -11
- package/dist/web/standalone/.next/build-manifest.json +3 -3
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/react-loadable-manifest.json +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.html +1 -1
- package/dist/web/standalone/.next/server/app/index.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app-paths-manifest.json +11 -11
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/dist/web/standalone/.next/server/pages/404.html +1 -1
- package/dist/web/standalone/.next/server/pages/500.html +1 -1
- package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
- package/dist/web/standalone/.next/static/chunks/2826.dd3dc8bbd3025fa5.js +9 -0
- package/dist/web/standalone/.next/static/chunks/{webpack-6e4d7e9a4f57bed4.js → webpack-b868033a5834586d.js} +1 -1
- package/package.json +1 -1
- package/packages/mcp-server/dist/env-writer.d.ts +39 -0
- package/packages/mcp-server/dist/env-writer.d.ts.map +1 -0
- package/packages/mcp-server/dist/env-writer.js +158 -0
- package/packages/mcp-server/dist/env-writer.js.map +1 -0
- package/packages/mcp-server/dist/server.d.ts +11 -2
- package/packages/mcp-server/dist/server.d.ts.map +1 -1
- package/packages/mcp-server/dist/server.js +102 -2
- package/packages/mcp-server/dist/server.js.map +1 -1
- package/packages/mcp-server/src/env-writer.test.ts +280 -0
- package/packages/mcp-server/src/env-writer.ts +183 -0
- package/packages/mcp-server/src/secure-env-collect.test.ts +265 -0
- package/packages/mcp-server/src/server.ts +137 -3
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js +310 -0
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.d.ts +19 -2
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.js +50 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.d.ts +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.js +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js +158 -23
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-state.d.ts +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-state.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-state.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts +6 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +58 -2
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js +1 -1
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-types.d.ts +1 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-types.js.map +1 -1
- package/packages/pi-coding-agent/src/core/chat-controller-ordering.test.ts +370 -0
- package/packages/pi-coding-agent/src/core/extensions/types.ts +2 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/dynamic-border.ts +58 -2
- package/packages/pi-coding-agent/src/modes/interactive/components/extension-input.ts +2 -0
- package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +189 -29
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode-state.ts +1 -0
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +66 -2
- package/packages/pi-coding-agent/src/modes/rpc/rpc-mode.ts +1 -1
- package/packages/pi-coding-agent/src/modes/rpc/rpc-types.ts +1 -0
- package/packages/pi-tui/dist/components/__tests__/input.test.js +9 -0
- package/packages/pi-tui/dist/components/__tests__/input.test.js.map +1 -1
- package/packages/pi-tui/dist/components/__tests__/markdown-maxlines.test.d.ts +2 -0
- package/packages/pi-tui/dist/components/__tests__/markdown-maxlines.test.d.ts.map +1 -0
- package/packages/pi-tui/dist/components/__tests__/markdown-maxlines.test.js +66 -0
- package/packages/pi-tui/dist/components/__tests__/markdown-maxlines.test.js.map +1 -0
- package/packages/pi-tui/dist/components/input.d.ts +2 -0
- package/packages/pi-tui/dist/components/input.d.ts.map +1 -1
- package/packages/pi-tui/dist/components/input.js +7 -4
- package/packages/pi-tui/dist/components/input.js.map +1 -1
- package/packages/pi-tui/dist/components/markdown.d.ts +3 -0
- package/packages/pi-tui/dist/components/markdown.d.ts.map +1 -1
- package/packages/pi-tui/dist/components/markdown.js +17 -1
- package/packages/pi-tui/dist/components/markdown.js.map +1 -1
- package/packages/pi-tui/src/components/__tests__/input.test.ts +11 -0
- package/packages/pi-tui/src/components/__tests__/markdown-maxlines.test.ts +75 -0
- package/packages/pi-tui/src/components/input.ts +7 -4
- package/packages/pi-tui/src/components/markdown.ts +22 -1
- package/src/resources/extensions/claude-code-cli/stream-adapter.ts +166 -31
- package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +145 -0
- package/src/resources/extensions/get-secrets-from-user.ts +24 -1
- package/src/resources/extensions/gsd/auto-start.ts +3 -13
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +4 -0
- package/src/resources/extensions/gsd/custom-workflow-engine.ts +19 -14
- package/src/resources/extensions/gsd/file-lock.ts +59 -0
- package/src/resources/extensions/gsd/guided-flow.ts +12 -9
- package/src/resources/extensions/gsd/init-wizard.ts +3 -13
- package/src/resources/extensions/gsd/prompts/discuss.md +31 -13
- package/src/resources/extensions/gsd/state.ts +274 -344
- package/src/resources/extensions/gsd/tests/derive-state-helpers.test.ts +436 -0
- package/src/resources/extensions/gsd/tests/discuss-incremental-persistence.test.ts +9 -0
- package/src/resources/extensions/gsd/tests/file-lock.test.ts +103 -0
- package/src/resources/extensions/gsd/tests/secure-env-collect.test.ts +45 -0
- package/src/resources/extensions/gsd/tests/workflow-mcp-auto-prep.test.ts +76 -0
- package/src/resources/extensions/gsd/tests/workflow-mcp.test.ts +155 -1
- package/src/resources/extensions/gsd/tests/workflow-tool-executors.test.ts +22 -0
- package/src/resources/extensions/gsd/tools/workflow-tool-executors.ts +60 -25
- package/src/resources/extensions/gsd/workflow-events.ts +34 -25
- package/src/resources/extensions/gsd/workflow-mcp-auto-prep.ts +76 -0
- package/src/resources/extensions/gsd/workflow-mcp.ts +1 -1
- package/dist/web/standalone/.next/static/chunks/2826.821e01b07d92e948.js +0 -9
- /package/dist/web/standalone/.next/static/{KdlODhIktLmeRKpLpHdKb → h7XsQBaK7XWBBC0Nu5f5P}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{KdlODhIktLmeRKpLpHdKb → h7XsQBaK7XWBBC0Nu5f5P}/_ssgManifest.js +0 -0
|
@@ -126,7 +126,7 @@ async function collectOneSecret(
|
|
|
126
126
|
): Promise<string | null> {
|
|
127
127
|
if (!ctx.hasUI) return null;
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
const customResult = await ctx.ui.custom((tui: any, theme: any, _kb: any, done: (r: string | null) => void) => {
|
|
130
130
|
let value = "";
|
|
131
131
|
let cachedLines: string[] | undefined;
|
|
132
132
|
|
|
@@ -223,6 +223,29 @@ async function collectOneSecret(
|
|
|
223
223
|
handleInput,
|
|
224
224
|
};
|
|
225
225
|
});
|
|
226
|
+
|
|
227
|
+
// RPC/web surfaces may not implement ctx.ui.custom(). Fall back to a
|
|
228
|
+
// standard input prompt so users can still provide the secret.
|
|
229
|
+
if (customResult !== undefined) {
|
|
230
|
+
return customResult;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (typeof ctx.ui?.input !== "function") {
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const inputTitle = `Secure value for ${keyName} (${pageIndex + 1}/${totalPages})`;
|
|
238
|
+
const inputPlaceholder = hint || "Enter secret value";
|
|
239
|
+
const inputResult = await ctx.ui.input(
|
|
240
|
+
inputTitle,
|
|
241
|
+
inputPlaceholder,
|
|
242
|
+
{ secure: true },
|
|
243
|
+
);
|
|
244
|
+
if (typeof inputResult !== "string") {
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
const trimmed = inputResult.trim();
|
|
248
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
226
249
|
}
|
|
227
250
|
|
|
228
251
|
/**
|
|
@@ -335,19 +335,9 @@ export async function bootstrapAutoSession(
|
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
const result = ensureProjectWorkflowMcpConfig(base);
|
|
342
|
-
if (result.status !== "unchanged") {
|
|
343
|
-
ctx.ui.notify(`Claude Code MCP prepared at ${result.configPath}`, "info");
|
|
344
|
-
}
|
|
345
|
-
} catch (err) {
|
|
346
|
-
ctx.ui.notify(
|
|
347
|
-
`Claude Code MCP prep failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
348
|
-
"warning",
|
|
349
|
-
);
|
|
350
|
-
}
|
|
338
|
+
{
|
|
339
|
+
const { prepareWorkflowMcpForProject } = await import("./workflow-mcp-auto-prep.js");
|
|
340
|
+
prepareWorkflowMcpForProject(ctx, base);
|
|
351
341
|
}
|
|
352
342
|
|
|
353
343
|
// Initialize GitServiceImpl
|
|
@@ -45,6 +45,8 @@ export function registerHooks(pi: ExtensionAPI): void {
|
|
|
45
45
|
resetToolCallLoopGuard();
|
|
46
46
|
resetAskUserQuestionsCache();
|
|
47
47
|
await syncServiceTierStatus(ctx);
|
|
48
|
+
const { prepareWorkflowMcpForProject } = await import("../workflow-mcp-auto-prep.js");
|
|
49
|
+
prepareWorkflowMcpForProject(ctx, process.cwd());
|
|
48
50
|
|
|
49
51
|
// Apply show_token_cost preference (#1515)
|
|
50
52
|
try {
|
|
@@ -85,6 +87,8 @@ export function registerHooks(pi: ExtensionAPI): void {
|
|
|
85
87
|
resetAskUserQuestionsCache();
|
|
86
88
|
clearDiscussionFlowState();
|
|
87
89
|
await syncServiceTierStatus(ctx);
|
|
90
|
+
const { prepareWorkflowMcpForProject } = await import("../workflow-mcp-auto-prep.js");
|
|
91
|
+
prepareWorkflowMcpForProject(ctx, process.cwd());
|
|
88
92
|
loadToolApiKeys();
|
|
89
93
|
});
|
|
90
94
|
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
import { injectContext } from "./context-injector.js";
|
|
35
35
|
import type { WorkflowDefinition, StepDefinition } from "./definition-loader.js";
|
|
36
36
|
import { parseUnitId } from "./unit-id.js";
|
|
37
|
+
import { withFileLock } from "./file-lock.js";
|
|
37
38
|
|
|
38
39
|
/** Read and parse the frozen DEFINITION.yaml from a run directory. */
|
|
39
40
|
export function readFrozenDefinition(runDir: string): WorkflowDefinition {
|
|
@@ -179,24 +180,28 @@ export class CustomWorkflowEngine implements WorkflowEngine {
|
|
|
179
180
|
state: EngineState,
|
|
180
181
|
completedStep: CompletedStep,
|
|
181
182
|
): Promise<ReconcileResult> {
|
|
182
|
-
|
|
183
|
-
// workflow edits with a stale in-memory snapshot from deriveState().
|
|
184
|
-
const graph = readGraph(this.runDir);
|
|
183
|
+
const graphPath = join(this.runDir, "GRAPH.yaml");
|
|
185
184
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
185
|
+
return await withFileLock(graphPath, () => {
|
|
186
|
+
// Re-read the graph from disk so we do not overwrite concurrent
|
|
187
|
+
// workflow edits with a stale in-memory snapshot from deriveState().
|
|
188
|
+
const graph = readGraph(this.runDir);
|
|
189
189
|
|
|
190
|
-
|
|
191
|
-
|
|
190
|
+
// Extract stepId from "<workflowName>/<stepId>"
|
|
191
|
+
const { milestone, slice, task } = parseUnitId(completedStep.unitId);
|
|
192
|
+
const stepId = task ?? slice ?? milestone;
|
|
192
193
|
|
|
193
|
-
|
|
194
|
-
(
|
|
195
|
-
);
|
|
194
|
+
const updatedGraph = markStepComplete(graph, stepId);
|
|
195
|
+
writeGraph(this.runDir, updatedGraph);
|
|
196
196
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
197
|
+
const allDone = updatedGraph.steps.every(
|
|
198
|
+
(s) => s.status === "complete" || s.status === "expanded",
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
return {
|
|
202
|
+
outcome: allDone ? "milestone-complete" : "continue",
|
|
203
|
+
};
|
|
204
|
+
});
|
|
200
205
|
}
|
|
201
206
|
|
|
202
207
|
/**
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
|
|
3
|
+
function _require(name: string) {
|
|
4
|
+
try {
|
|
5
|
+
return require(name);
|
|
6
|
+
} catch {
|
|
7
|
+
try {
|
|
8
|
+
const gsdPiRequire = require("module").createRequire(
|
|
9
|
+
require("path").join(process.cwd(), "node_modules", "gsd-pi", "index.js")
|
|
10
|
+
);
|
|
11
|
+
return gsdPiRequire(name);
|
|
12
|
+
} catch {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function withFileLockSync<T>(filePath: string, fn: () => T): T {
|
|
19
|
+
const lockfile = _require("proper-lockfile");
|
|
20
|
+
if (!lockfile) return fn();
|
|
21
|
+
|
|
22
|
+
if (!existsSync(filePath)) return fn();
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
const release = lockfile.lockSync(filePath, { retries: 5, stale: 10000 });
|
|
26
|
+
try {
|
|
27
|
+
return fn();
|
|
28
|
+
} finally {
|
|
29
|
+
release();
|
|
30
|
+
}
|
|
31
|
+
} catch (err: any) {
|
|
32
|
+
if (err.code === "ELOCKED") {
|
|
33
|
+
// Could not get lock after retries, let's fallback to un-locked instead of crashing the whole state machine
|
|
34
|
+
return fn();
|
|
35
|
+
}
|
|
36
|
+
throw err;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function withFileLock<T>(filePath: string, fn: () => Promise<T> | T): Promise<T> {
|
|
41
|
+
const lockfile = _require("proper-lockfile");
|
|
42
|
+
if (!lockfile) return await fn();
|
|
43
|
+
|
|
44
|
+
if (!existsSync(filePath)) return await fn();
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
const release = await lockfile.lock(filePath, { retries: 5, stale: 10000 });
|
|
48
|
+
try {
|
|
49
|
+
return await fn();
|
|
50
|
+
} finally {
|
|
51
|
+
await release();
|
|
52
|
+
}
|
|
53
|
+
} catch (err: any) {
|
|
54
|
+
if (err.code === "ELOCKED") {
|
|
55
|
+
return await fn();
|
|
56
|
+
}
|
|
57
|
+
throw err;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -426,8 +426,9 @@ function resolveAvailableModel<T extends { id: string; provider: string }>(
|
|
|
426
426
|
* Build the discuss-and-plan prompt for a new milestone.
|
|
427
427
|
* Used by all three "new milestone" paths (first ever, no active, all complete).
|
|
428
428
|
*/
|
|
429
|
-
function buildDiscussPrompt(nextId: string, preamble: string, _basePath: string, preparationContext?: string): string {
|
|
429
|
+
function buildDiscussPrompt(nextId: string, preamble: string, _basePath: string, pi: ExtensionAPI, ctx: ExtensionCommandContext, preparationContext?: string): string {
|
|
430
430
|
const milestoneRel = `.gsd/milestones/${nextId}`;
|
|
431
|
+
const structuredQuestionsAvailable = getStructuredQuestionsAvailability(pi, ctx);
|
|
431
432
|
const inlinedTemplates = [
|
|
432
433
|
inlineTemplate("project", "Project"),
|
|
433
434
|
inlineTemplate("requirements", "Requirements"),
|
|
@@ -439,6 +440,7 @@ function buildDiscussPrompt(nextId: string, preamble: string, _basePath: string,
|
|
|
439
440
|
milestoneId: nextId,
|
|
440
441
|
preamble,
|
|
441
442
|
preparationContext: preparationContext ?? "",
|
|
443
|
+
structuredQuestionsAvailable,
|
|
442
444
|
contextPath: `${milestoneRel}/${nextId}-CONTEXT.md`,
|
|
443
445
|
roadmapPath: `${milestoneRel}/${nextId}-ROADMAP.md`,
|
|
444
446
|
inlinedTemplates,
|
|
@@ -486,6 +488,7 @@ function buildHeadlessDiscussPrompt(nextId: string, seedContext: string, _basePa
|
|
|
486
488
|
*/
|
|
487
489
|
async function prepareAndBuildDiscussPrompt(
|
|
488
490
|
ctx: ExtensionCommandContext,
|
|
491
|
+
pi: ExtensionAPI,
|
|
489
492
|
nextId: string,
|
|
490
493
|
preamble: string,
|
|
491
494
|
basePath: string,
|
|
@@ -520,7 +523,7 @@ async function prepareAndBuildDiscussPrompt(
|
|
|
520
523
|
}
|
|
521
524
|
}
|
|
522
525
|
|
|
523
|
-
return buildDiscussPrompt(nextId, preamble, basePath, preparationContext);
|
|
526
|
+
return buildDiscussPrompt(nextId, preamble, basePath, pi, ctx, preparationContext);
|
|
524
527
|
}
|
|
525
528
|
|
|
526
529
|
/**
|
|
@@ -780,7 +783,7 @@ export async function showDiscuss(
|
|
|
780
783
|
const uniqueMilestoneIds = !!loadEffectiveGSDPreferences()?.preferences?.unique_milestone_ids;
|
|
781
784
|
const nextId = nextMilestoneIdReserved(milestoneIds, uniqueMilestoneIds);
|
|
782
785
|
pendingAutoStartMap.set(basePath, { ctx, pi, basePath, milestoneId: nextId, step: false, createdAt: Date.now() });
|
|
783
|
-
await dispatchWorkflow(pi, await prepareAndBuildDiscussPrompt(ctx, nextId, `New milestone ${nextId}.`, basePath), "gsd-run", ctx, "discuss-milestone");
|
|
786
|
+
await dispatchWorkflow(pi, await prepareAndBuildDiscussPrompt(ctx, pi, nextId, `New milestone ${nextId}.`, basePath), "gsd-run", ctx, "discuss-milestone");
|
|
784
787
|
}
|
|
785
788
|
return;
|
|
786
789
|
}
|
|
@@ -1185,7 +1188,7 @@ async function handleMilestoneActions(
|
|
|
1185
1188
|
const uniqueMilestoneIds = !!loadEffectiveGSDPreferences()?.preferences?.unique_milestone_ids;
|
|
1186
1189
|
const nextId = nextMilestoneIdReserved(milestoneIds, uniqueMilestoneIds);
|
|
1187
1190
|
pendingAutoStartMap.set(basePath, { ctx, pi, basePath, milestoneId: nextId, step: stepMode, createdAt: Date.now() });
|
|
1188
|
-
await dispatchWorkflow(pi, await prepareAndBuildDiscussPrompt(ctx, nextId,
|
|
1191
|
+
await dispatchWorkflow(pi, await prepareAndBuildDiscussPrompt(ctx, pi, nextId,
|
|
1189
1192
|
`New milestone ${nextId}.`,
|
|
1190
1193
|
basePath
|
|
1191
1194
|
), "gsd-run", ctx, "discuss-milestone");
|
|
@@ -1375,7 +1378,7 @@ export async function showSmartEntry(
|
|
|
1375
1378
|
if (isFirst) {
|
|
1376
1379
|
// First ever — skip wizard, just ask directly
|
|
1377
1380
|
pendingAutoStartMap.set(basePath, { ctx, pi, basePath, milestoneId: nextId, step: stepMode, createdAt: Date.now() });
|
|
1378
|
-
await dispatchWorkflow(pi, await prepareAndBuildDiscussPrompt(ctx, nextId,
|
|
1381
|
+
await dispatchWorkflow(pi, await prepareAndBuildDiscussPrompt(ctx, pi, nextId,
|
|
1379
1382
|
`New project, milestone ${nextId}. Do NOT read or explore .gsd/ — it's empty scaffolding.`,
|
|
1380
1383
|
basePath
|
|
1381
1384
|
), "gsd-run", ctx, "discuss-milestone");
|
|
@@ -1396,7 +1399,7 @@ export async function showSmartEntry(
|
|
|
1396
1399
|
|
|
1397
1400
|
if (choice === "new_milestone") {
|
|
1398
1401
|
pendingAutoStartMap.set(basePath, { ctx, pi, basePath, milestoneId: nextId, step: stepMode, createdAt: Date.now() });
|
|
1399
|
-
await dispatchWorkflow(pi, await prepareAndBuildDiscussPrompt(ctx, nextId,
|
|
1402
|
+
await dispatchWorkflow(pi, await prepareAndBuildDiscussPrompt(ctx, pi, nextId,
|
|
1400
1403
|
`New milestone ${nextId}.`,
|
|
1401
1404
|
basePath
|
|
1402
1405
|
), "gsd-run", ctx, "discuss-milestone");
|
|
@@ -1435,7 +1438,7 @@ export async function showSmartEntry(
|
|
|
1435
1438
|
const nextId = nextMilestoneIdReserved(milestoneIds, uniqueMilestoneIds);
|
|
1436
1439
|
|
|
1437
1440
|
pendingAutoStartMap.set(basePath, { ctx, pi, basePath, milestoneId: nextId, step: stepMode, createdAt: Date.now() });
|
|
1438
|
-
await dispatchWorkflow(pi, await prepareAndBuildDiscussPrompt(ctx, nextId,
|
|
1441
|
+
await dispatchWorkflow(pi, await prepareAndBuildDiscussPrompt(ctx, pi, nextId,
|
|
1439
1442
|
`New milestone ${nextId}.`,
|
|
1440
1443
|
basePath
|
|
1441
1444
|
), "gsd-run", ctx, "discuss-milestone");
|
|
@@ -1502,7 +1505,7 @@ export async function showSmartEntry(
|
|
|
1502
1505
|
const uniqueMilestoneIds = !!loadEffectiveGSDPreferences()?.preferences?.unique_milestone_ids;
|
|
1503
1506
|
const nextId = nextMilestoneIdReserved(milestoneIds, uniqueMilestoneIds);
|
|
1504
1507
|
pendingAutoStartMap.set(basePath, { ctx, pi, basePath, milestoneId: nextId, step: stepMode, createdAt: Date.now() });
|
|
1505
|
-
await dispatchWorkflow(pi, await prepareAndBuildDiscussPrompt(ctx, nextId,
|
|
1508
|
+
await dispatchWorkflow(pi, await prepareAndBuildDiscussPrompt(ctx, pi, nextId,
|
|
1506
1509
|
`New milestone ${nextId}.`,
|
|
1507
1510
|
basePath
|
|
1508
1511
|
), "gsd-run", ctx, "discuss-milestone");
|
|
@@ -1599,7 +1602,7 @@ export async function showSmartEntry(
|
|
|
1599
1602
|
const uniqueMilestoneIds = !!loadEffectiveGSDPreferences()?.preferences?.unique_milestone_ids;
|
|
1600
1603
|
const nextId = nextMilestoneIdReserved(milestoneIds, uniqueMilestoneIds);
|
|
1601
1604
|
pendingAutoStartMap.set(basePath, { ctx, pi, basePath, milestoneId: nextId, step: stepMode, createdAt: Date.now() });
|
|
1602
|
-
await dispatchWorkflow(pi, await prepareAndBuildDiscussPrompt(ctx, nextId,
|
|
1605
|
+
await dispatchWorkflow(pi, await prepareAndBuildDiscussPrompt(ctx, pi, nextId,
|
|
1603
1606
|
`New milestone ${nextId}.`,
|
|
1604
1607
|
basePath
|
|
1605
1608
|
), "gsd-run", ctx, "discuss-milestone");
|
|
@@ -274,19 +274,9 @@ export async function showProjectInit(
|
|
|
274
274
|
// Non-fatal — STATE.md will be regenerated on next /gsd invocation
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
const result = ensureProjectWorkflowMcpConfig(basePath);
|
|
281
|
-
if (result.status !== "unchanged") {
|
|
282
|
-
ctx.ui.notify(`Claude Code MCP prepared at ${result.configPath}`, "info");
|
|
283
|
-
}
|
|
284
|
-
} catch (err) {
|
|
285
|
-
ctx.ui.notify(
|
|
286
|
-
`Claude Code MCP prep failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
287
|
-
"warning",
|
|
288
|
-
);
|
|
289
|
-
}
|
|
277
|
+
{
|
|
278
|
+
const { prepareWorkflowMcpForProject } = await import("./workflow-mcp-auto-prep.js");
|
|
279
|
+
prepareWorkflowMcpForProject(ctx, basePath);
|
|
290
280
|
}
|
|
291
281
|
|
|
292
282
|
ctx.ui.notify("GSD initialized. Starting your first milestone...", "info");
|
|
@@ -49,6 +49,26 @@ This happens ONCE, before the first round. The goal: your first questions should
|
|
|
49
49
|
|
|
50
50
|
For subsequent rounds, continue investigating between rounds — check docs, search, or scout as needed to make each round's questions smarter. But the first-round investigation is mandatory and explicit. Distribute searches across turns rather than clustering them in one turn.
|
|
51
51
|
|
|
52
|
+
## Question Rounds
|
|
53
|
+
|
|
54
|
+
Ask **1–3 questions per round**. Keep each round tightly focused on one or two of the depth checklist dimensions — do not try to cover all six in one round.
|
|
55
|
+
|
|
56
|
+
**If `{{structuredQuestionsAvailable}}` is `true`:** use `ask_user_questions` for each round. 1–3 questions per call, each as a separate question object. Keep option labels short (3–5 words). Always include a freeform "Other / let me explain" option. When the user picks that option or writes a long freeform answer, switch to plain text follow-up for that thread before resuming structured questions. **IMPORTANT: Call `ask_user_questions` exactly once per turn. Never make multiple calls with the same or overlapping questions — wait for the user's response before asking the next round.**
|
|
57
|
+
|
|
58
|
+
**If `{{structuredQuestionsAvailable}}` is `false`:** ask questions in plain text. Keep each round to 1–3 focused questions. Wait for answers before asking the next round.
|
|
59
|
+
|
|
60
|
+
After each answer set, investigate further if any answer opens a new unknown, then ask the next round.
|
|
61
|
+
|
|
62
|
+
### Round cadence
|
|
63
|
+
|
|
64
|
+
After each round of answers, decide whether you already have enough depth to write strong output.
|
|
65
|
+
|
|
66
|
+
- **Incremental persistence:** After every 2 question rounds, silently save a `{{milestoneId}}-CONTEXT-DRAFT.md` using `gsd_summary_save` with `artifact_type: "CONTEXT-DRAFT"` and `milestone_id: "{{milestoneId}}"`. This protects confirmed work against session crashes. Do NOT mention this save to the user.
|
|
67
|
+
- If not ready, continue to the next round immediately. Do **not** ask a meta "ready to wrap up?" question after every round.
|
|
68
|
+
- **Depth-matching rule:** Simple, well-defined work needs fewer rounds — maybe 1–2. Large, ambiguous visions need more — maybe 4+. Do not pad rounds to hit a number. Stop when the Depth Enforcement checklist below is fully satisfied.
|
|
69
|
+
- Do not count the reflection step as a question round. Rounds start after reflection is confirmed.
|
|
70
|
+
- When you genuinely believe the depth checklist is satisfied, move to the Depth Verification step below. Do not ask a separate "ready to wrap up?" gate — the depth verification IS the gate.
|
|
71
|
+
|
|
52
72
|
## Questioning Philosophy
|
|
53
73
|
|
|
54
74
|
You are a thinking partner, not an interviewer.
|
|
@@ -94,29 +114,27 @@ Do NOT offer to proceed until ALL of the following are satisfied. Track these in
|
|
|
94
114
|
|
|
95
115
|
Before offering to proceed, demonstrate absorption: reference specific things the user emphasized, specific terminology they used, specific nuance they sharpened — and show how those shaped your understanding. Synthesize, don't recite. "Your emphasis on X led me to prioritize Y over Z" is good. "You said X, you said Y, you said Z" is not. The user should feel heard in the specifics, not just acknowledged in the abstract.
|
|
96
116
|
|
|
97
|
-
**Questioning depth should match scope.** Simple, well-defined work needs fewer rounds — maybe 1-2. Large, ambiguous visions need more — maybe 4+. Don't pad rounds to hit a number. Stop when the depth checklist is satisfied and you genuinely understand the work.
|
|
98
|
-
|
|
99
|
-
Do not count the reflection step as a question round. Rounds start after reflection is confirmed.
|
|
100
|
-
|
|
101
117
|
## Depth Verification
|
|
102
118
|
|
|
103
119
|
Before moving to the wrap-up gate, present a structured depth summary as a checkpoint.
|
|
104
120
|
|
|
105
121
|
**Print the summary as normal chat text first** — this is where the formatting renders properly. Structure the summary across the depth checklist dimensions using the user's own terminology and framing. Cover: what you understood them to be building, what shaped your understanding most (their emphasis, constraints, concerns), and any areas where you're least confident in your understanding.
|
|
106
122
|
|
|
107
|
-
**Then
|
|
123
|
+
**Then confirm:**
|
|
108
124
|
|
|
109
|
-
**
|
|
125
|
+
**If `{{structuredQuestionsAvailable}}` is `true`:** use `ask_user_questions` with:
|
|
126
|
+
- header: "Depth Check"
|
|
127
|
+
- question: "Did I capture the depth right?"
|
|
128
|
+
- options: "Yes, you got it (Recommended)", "Not quite — let me clarify"
|
|
129
|
+
- **The question ID must contain `depth_verification`** (e.g., `depth_verification_confirm`) — this naming convention enables downstream mechanical detection and the write-gate.
|
|
110
130
|
|
|
111
|
-
|
|
112
|
-
1. Print in chat: the full depth summary with markdown formatting (headers, bold, bullets)
|
|
113
|
-
2. Call `ask_user_questions` with: header "Depth Check", question "Did I capture the depth right?", options "Yes, you got it (Recommended)" and "Not quite — let me clarify"
|
|
131
|
+
**If `{{structuredQuestionsAvailable}}` is `false`:** ask in plain text: "Did I capture that correctly? If not, tell me what I missed." Wait for explicit confirmation before proceeding. **The same non-bypassable gate applies to the plain-text path** — if the user does not respond, gives an ambiguous answer, or does not explicitly confirm, you MUST re-ask. Never rationalize past a missing confirmation.
|
|
114
132
|
|
|
115
133
|
If they clarify, absorb the correction and re-verify.
|
|
116
134
|
|
|
117
135
|
The depth verification is the required write-gate. Do **not** add another meta "ready to proceed?" checkpoint immediately after it unless there is still material ambiguity.
|
|
118
136
|
|
|
119
|
-
**CRITICAL — Non-bypassable gate:** The system mechanically blocks CONTEXT.md writes until the user selects the "(Recommended)" option. If the user declines, cancels, or the tool fails, you MUST re-ask — never rationalize past the block ("tool not responding, I'll proceed" is forbidden). The gate exists to protect the user's work; treat a block as an instruction, not an obstacle to work around.
|
|
137
|
+
**CRITICAL — Non-bypassable gate:** The system mechanically blocks CONTEXT.md writes until the user selects the "(Recommended)" option (structured path) or explicitly confirms (plain-text path). If the user declines, cancels, does not respond, or the tool fails, you MUST re-ask — never rationalize past the block ("tool not responding, I'll proceed" is forbidden). The gate exists to protect the user's work; treat a block as an instruction, not an obstacle to work around.
|
|
120
138
|
|
|
121
139
|
## Wrap-up Gate
|
|
122
140
|
|
|
@@ -244,7 +262,7 @@ If a milestone has no dependencies, omit the frontmatter. The dependency chain f
|
|
|
244
262
|
|
|
245
263
|
#### Phase 3: Sequential readiness gate for remaining milestones
|
|
246
264
|
|
|
247
|
-
For each remaining milestone **one at a time, in sequence**, decide the most likely readiness mode from the evidence you already have, then use `ask_user_questions`
|
|
265
|
+
For each remaining milestone **one at a time, in sequence**, decide the most likely readiness mode from the evidence you already have, then present the three options below to the user. **If `{{structuredQuestionsAvailable}}` is `true`:** use `ask_user_questions`. **If `{{structuredQuestionsAvailable}}` is `false`:** present the options as a plain-text numbered list and ask the user to type their choice. **Non-bypassable:** If the user does not respond, gives an ambiguous answer, or the tool fails, you MUST re-ask — never rationalize past the block or auto-select a readiness mode. Present three options:
|
|
248
266
|
|
|
249
267
|
- **"Discuss now"** — The user wants to conduct a focused discussion for this milestone in the current session, while the context from the broader discussion is still fresh. Proceed with a focused discussion for this milestone (reflection → investigation → questioning → depth verification). When the discussion concludes, write a full `CONTEXT.md`. Then move to the gate for the next milestone.
|
|
250
268
|
- **"Write draft for later"** — This milestone has seed material from the current conversation but needs its own dedicated discussion in a future session. Write a `CONTEXT-DRAFT.md` capturing the seed material (what was discussed, key ideas, provisional scope, open questions). Mark it clearly as a draft, not a finalized context. **What happens downstream:** When auto-mode reaches this milestone, it pauses and notifies the user: "M00x has draft context — needs discussion. Run /gsd." The `/gsd` wizard shows a "Discuss from draft" option that seeds the new discussion with this draft, so nothing from the current conversation is lost. After the dedicated discussion produces a full CONTEXT.md, the draft file is automatically deleted.
|
|
@@ -256,9 +274,9 @@ Before writing each milestone's CONTEXT.md (whether primary or secondary), you M
|
|
|
256
274
|
|
|
257
275
|
1. **Read the actual code** for every file or module you reference. Confirm APIs exist, check what functions actually do, identify phantom capabilities (code that exists but isn't wired up).
|
|
258
276
|
2. **Check for stale assumptions** — the codebase changes. Verify referenced modules still work as described.
|
|
259
|
-
3. **Present findings** — use `ask_user_questions` with a question ID containing BOTH `depth_verification` AND the milestone ID (e.g., `depth_verification_M002`). Present: what you're about to write, key technical findings from investigation, risks the code review surfaced.
|
|
277
|
+
3. **Present findings** — **If `{{structuredQuestionsAvailable}}` is `true`:** use `ask_user_questions` with a question ID containing BOTH `depth_verification` AND the milestone ID (e.g., `depth_verification_M002`). Present: what you're about to write, key technical findings from investigation, risks the code review surfaced. **If `{{structuredQuestionsAvailable}}` is `false`:** present the same findings in plain text and ask for explicit confirmation before proceeding.
|
|
260
278
|
|
|
261
|
-
**The system mechanically blocks CONTEXT.md writes until the per-milestone depth verification passes
|
|
279
|
+
**The system mechanically blocks CONTEXT.md writes until the per-milestone depth verification passes** (structured path: user selects "(Recommended)" option; plain-text path: user explicitly confirms). Each milestone needs its own verification — one global verification does not unlock all milestones.
|
|
262
280
|
|
|
263
281
|
**Why sequential, not batch:** After writing the primary milestone's context and roadmap, the agent still has context window capacity. Asking one milestone at a time lets the user decide per-milestone whether to invest that remaining capacity in a focused discussion now, or defer to a future session. A batch question ("Ready/Draft/Queue for M002, M003, M004?") forces the user to decide everything upfront without knowing how much session capacity remains.
|
|
264
282
|
|