gsd-pi 2.46.0-dev.f45e6dc → 2.46.1-dev.79664f2
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/README.md +1 -0
- package/dist/resources/extensions/claude-code-cli/index.js +25 -0
- package/dist/resources/extensions/claude-code-cli/models.js +40 -0
- package/dist/resources/extensions/claude-code-cli/package.json +11 -0
- package/dist/resources/extensions/claude-code-cli/partial-builder.js +223 -0
- package/dist/resources/extensions/claude-code-cli/readiness.js +26 -0
- package/dist/resources/extensions/claude-code-cli/sdk-types.js +8 -0
- package/dist/resources/extensions/claude-code-cli/stream-adapter.js +293 -0
- package/dist/resources/extensions/gsd/prompts/complete-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/guided-plan-milestone.md +2 -2
- package/dist/resources/extensions/gsd/prompts/plan-milestone.md +2 -2
- package/dist/resources/extensions/gsd/prompts/plan-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/research-milestone.md +2 -2
- package/dist/resources/extensions/gsd/prompts/run-uat.md +2 -2
- package/dist/resources/extensions/gsd/workflow-events.js +1 -1
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +14 -14
- package/dist/web/standalone/.next/build-manifest.json +2 -2
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/server/app/_global-error.html +2 -2
- 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 +14 -14
- package/dist/web/standalone/.next/server/pages/404.html +1 -1
- package/dist/web/standalone/.next/server/pages/500.html +2 -2
- package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
- package/package.json +2 -1
- package/packages/pi-coding-agent/package.json +1 -1
- package/pkg/package.json +1 -1
- package/src/resources/extensions/claude-code-cli/index.ts +28 -0
- package/src/resources/extensions/claude-code-cli/models.ts +42 -0
- package/src/resources/extensions/claude-code-cli/package.json +11 -0
- package/src/resources/extensions/claude-code-cli/partial-builder.ts +258 -0
- package/src/resources/extensions/claude-code-cli/readiness.ts +30 -0
- package/src/resources/extensions/claude-code-cli/sdk-types.ts +149 -0
- package/src/resources/extensions/claude-code-cli/stream-adapter.ts +355 -0
- package/src/resources/extensions/gsd/prompts/complete-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/guided-plan-milestone.md +2 -2
- package/src/resources/extensions/gsd/prompts/plan-milestone.md +2 -2
- package/src/resources/extensions/gsd/prompts/plan-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/research-milestone.md +2 -2
- package/src/resources/extensions/gsd/prompts/run-uat.md +2 -2
- package/src/resources/extensions/gsd/tests/plan-slice-prompt.test.ts +40 -0
- package/src/resources/extensions/gsd/tests/run-uat.test.ts +25 -0
- package/src/resources/extensions/gsd/workflow-events.ts +1 -1
- /package/dist/web/standalone/.next/static/{9CuEqE-DGAlva1uIjyfjF → vP6aj-TThZymVNx5Pi2AN}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{9CuEqE-DGAlva1uIjyfjF → vP6aj-TThZymVNx5Pi2AN}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stream adapter: bridges the Claude Agent SDK into GSD's streamSimple contract.
|
|
3
|
+
*
|
|
4
|
+
* The SDK runs the full agentic loop (multi-turn, tool execution, compaction)
|
|
5
|
+
* in one call. This adapter translates the SDK's streaming output into
|
|
6
|
+
* AssistantMessageEvents for TUI rendering, then strips tool-call blocks from
|
|
7
|
+
* the final AssistantMessage so GSD's agent loop doesn't try to dispatch them.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type {
|
|
11
|
+
AssistantMessage,
|
|
12
|
+
AssistantMessageEvent,
|
|
13
|
+
AssistantMessageEventStream,
|
|
14
|
+
Context,
|
|
15
|
+
Model,
|
|
16
|
+
SimpleStreamOptions,
|
|
17
|
+
} from "@gsd/pi-ai";
|
|
18
|
+
import { EventStream } from "@gsd/pi-ai";
|
|
19
|
+
import { execSync } from "node:child_process";
|
|
20
|
+
import { PartialMessageBuilder, ZERO_USAGE, mapUsage } from "./partial-builder.js";
|
|
21
|
+
import type {
|
|
22
|
+
SDKAssistantMessage,
|
|
23
|
+
SDKMessage,
|
|
24
|
+
SDKPartialAssistantMessage,
|
|
25
|
+
SDKResultMessage,
|
|
26
|
+
SDKSystemMessage,
|
|
27
|
+
SDKStatusMessage,
|
|
28
|
+
SDKUserMessage,
|
|
29
|
+
} from "./sdk-types.js";
|
|
30
|
+
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
// Stream factory
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Construct an AssistantMessageEventStream using EventStream directly.
|
|
37
|
+
* (The class itself is only re-exported as a type from the @gsd/pi-ai barrel.)
|
|
38
|
+
*/
|
|
39
|
+
function createAssistantStream(): AssistantMessageEventStream {
|
|
40
|
+
return new EventStream<AssistantMessageEvent, AssistantMessage>(
|
|
41
|
+
(event) => event.type === "done" || event.type === "error",
|
|
42
|
+
(event) => {
|
|
43
|
+
if (event.type === "done") return event.message;
|
|
44
|
+
if (event.type === "error") return event.error;
|
|
45
|
+
throw new Error("Unexpected event type for final result");
|
|
46
|
+
},
|
|
47
|
+
) as AssistantMessageEventStream;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
// Claude binary resolution
|
|
52
|
+
// ---------------------------------------------------------------------------
|
|
53
|
+
|
|
54
|
+
let cachedClaudePath: string | null = null;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Resolve the path to the system-installed `claude` binary.
|
|
58
|
+
* The SDK defaults to a bundled cli.js which doesn't exist when
|
|
59
|
+
* installed as a library — we need to point it at the real CLI.
|
|
60
|
+
*/
|
|
61
|
+
function getClaudePath(): string {
|
|
62
|
+
if (cachedClaudePath) return cachedClaudePath;
|
|
63
|
+
try {
|
|
64
|
+
cachedClaudePath = execSync("which claude", { timeout: 5_000, stdio: "pipe" })
|
|
65
|
+
.toString()
|
|
66
|
+
.trim();
|
|
67
|
+
} catch {
|
|
68
|
+
cachedClaudePath = "claude"; // fall back to PATH resolution
|
|
69
|
+
}
|
|
70
|
+
return cachedClaudePath;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// ---------------------------------------------------------------------------
|
|
74
|
+
// Prompt extraction
|
|
75
|
+
// ---------------------------------------------------------------------------
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Extract the last user prompt text from GSD's context messages.
|
|
79
|
+
* The SDK manages its own conversation history — we only send
|
|
80
|
+
* the latest user message as the prompt.
|
|
81
|
+
*/
|
|
82
|
+
function extractLastUserPrompt(context: Context): string {
|
|
83
|
+
for (let i = context.messages.length - 1; i >= 0; i--) {
|
|
84
|
+
const msg = context.messages[i];
|
|
85
|
+
if (msg.role === "user") {
|
|
86
|
+
if (typeof msg.content === "string") return msg.content;
|
|
87
|
+
if (Array.isArray(msg.content)) {
|
|
88
|
+
const textParts = msg.content
|
|
89
|
+
.filter((part: any) => part.type === "text")
|
|
90
|
+
.map((part: any) => part.text);
|
|
91
|
+
if (textParts.length > 0) return textParts.join("\n");
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return "";
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// ---------------------------------------------------------------------------
|
|
99
|
+
// Error helper
|
|
100
|
+
// ---------------------------------------------------------------------------
|
|
101
|
+
|
|
102
|
+
function makeErrorMessage(model: string, errorMsg: string): AssistantMessage {
|
|
103
|
+
return {
|
|
104
|
+
role: "assistant",
|
|
105
|
+
content: [{ type: "text", text: `Claude Code error: ${errorMsg}` }],
|
|
106
|
+
api: "anthropic-messages",
|
|
107
|
+
provider: "claude-code",
|
|
108
|
+
model,
|
|
109
|
+
usage: { ...ZERO_USAGE },
|
|
110
|
+
stopReason: "error",
|
|
111
|
+
errorMessage: errorMsg,
|
|
112
|
+
timestamp: Date.now(),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// ---------------------------------------------------------------------------
|
|
117
|
+
// streamSimple implementation
|
|
118
|
+
// ---------------------------------------------------------------------------
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* GSD streamSimple function that delegates to the Claude Agent SDK.
|
|
122
|
+
*
|
|
123
|
+
* Emits AssistantMessageEvent deltas for real-time TUI rendering
|
|
124
|
+
* (thinking, text, tool calls). The final AssistantMessage has tool-call
|
|
125
|
+
* blocks stripped so the agent loop ends the turn without local dispatch.
|
|
126
|
+
*/
|
|
127
|
+
export function streamViaClaudeCode(
|
|
128
|
+
model: Model<any>,
|
|
129
|
+
context: Context,
|
|
130
|
+
options?: SimpleStreamOptions,
|
|
131
|
+
): AssistantMessageEventStream {
|
|
132
|
+
const stream = createAssistantStream();
|
|
133
|
+
|
|
134
|
+
void pumpSdkMessages(model, context, options, stream);
|
|
135
|
+
|
|
136
|
+
return stream;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async function pumpSdkMessages(
|
|
140
|
+
model: Model<any>,
|
|
141
|
+
context: Context,
|
|
142
|
+
options: SimpleStreamOptions | undefined,
|
|
143
|
+
stream: AssistantMessageEventStream,
|
|
144
|
+
): Promise<void> {
|
|
145
|
+
const modelId = model.id;
|
|
146
|
+
let builder: PartialMessageBuilder | null = null;
|
|
147
|
+
/** Track the last text content seen across all assistant turns for the final message. */
|
|
148
|
+
let lastTextContent = "";
|
|
149
|
+
let lastThinkingContent = "";
|
|
150
|
+
|
|
151
|
+
try {
|
|
152
|
+
// Dynamic import — the SDK is an optional dependency.
|
|
153
|
+
const sdkModule = "@anthropic-ai/claude-agent-sdk";
|
|
154
|
+
const sdk = (await import(/* webpackIgnore: true */ sdkModule)) as {
|
|
155
|
+
query: (args: {
|
|
156
|
+
prompt: string | AsyncIterable<unknown>;
|
|
157
|
+
options?: Record<string, unknown>;
|
|
158
|
+
}) => AsyncIterable<SDKMessage>;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
// Bridge GSD's AbortSignal to SDK's AbortController
|
|
162
|
+
const controller = new AbortController();
|
|
163
|
+
if (options?.signal) {
|
|
164
|
+
options.signal.addEventListener("abort", () => controller.abort(), { once: true });
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const prompt = extractLastUserPrompt(context);
|
|
168
|
+
|
|
169
|
+
const queryResult = sdk.query({
|
|
170
|
+
prompt,
|
|
171
|
+
options: {
|
|
172
|
+
pathToClaudeCodeExecutable: getClaudePath(),
|
|
173
|
+
model: modelId,
|
|
174
|
+
includePartialMessages: true,
|
|
175
|
+
persistSession: false,
|
|
176
|
+
abortController: controller,
|
|
177
|
+
cwd: process.cwd(),
|
|
178
|
+
permissionMode: "bypassPermissions",
|
|
179
|
+
allowDangerouslySkipPermissions: true,
|
|
180
|
+
settingSources: ["project"],
|
|
181
|
+
systemPrompt: { type: "preset", preset: "claude_code" },
|
|
182
|
+
betas: modelId.includes("sonnet") ? ["context-1m-2025-08-07"] : [],
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
// Emit start with an empty partial
|
|
187
|
+
const initialPartial: AssistantMessage = {
|
|
188
|
+
role: "assistant",
|
|
189
|
+
content: [],
|
|
190
|
+
api: "anthropic-messages",
|
|
191
|
+
provider: "claude-code",
|
|
192
|
+
model: modelId,
|
|
193
|
+
usage: { ...ZERO_USAGE },
|
|
194
|
+
stopReason: "stop",
|
|
195
|
+
timestamp: Date.now(),
|
|
196
|
+
};
|
|
197
|
+
stream.push({ type: "start", partial: initialPartial });
|
|
198
|
+
|
|
199
|
+
for await (const msg of queryResult as AsyncIterable<SDKMessage>) {
|
|
200
|
+
if (options?.signal?.aborted) break;
|
|
201
|
+
|
|
202
|
+
switch (msg.type) {
|
|
203
|
+
// -- Init --
|
|
204
|
+
case "system": {
|
|
205
|
+
// Nothing to emit — the stream is already started.
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// -- Streaming partial messages --
|
|
210
|
+
case "stream_event": {
|
|
211
|
+
const partial = msg as SDKPartialAssistantMessage;
|
|
212
|
+
if (partial.parent_tool_use_id !== null) break; // skip subagent
|
|
213
|
+
|
|
214
|
+
const event = partial.event;
|
|
215
|
+
|
|
216
|
+
// New assistant turn starts with message_start
|
|
217
|
+
if (event.type === "message_start") {
|
|
218
|
+
builder = new PartialMessageBuilder(
|
|
219
|
+
(event as any).message?.model ?? modelId,
|
|
220
|
+
);
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (!builder) break;
|
|
225
|
+
|
|
226
|
+
const assistantEvent = builder.handleEvent(event);
|
|
227
|
+
if (assistantEvent) {
|
|
228
|
+
stream.push(assistantEvent);
|
|
229
|
+
}
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// -- Complete assistant message (non-streaming fallback) --
|
|
234
|
+
case "assistant": {
|
|
235
|
+
const sdkAssistant = msg as SDKAssistantMessage;
|
|
236
|
+
if (sdkAssistant.parent_tool_use_id !== null) break;
|
|
237
|
+
|
|
238
|
+
// Capture text content from complete messages
|
|
239
|
+
for (const block of sdkAssistant.message.content) {
|
|
240
|
+
if (block.type === "text") {
|
|
241
|
+
lastTextContent = block.text;
|
|
242
|
+
} else if (block.type === "thinking") {
|
|
243
|
+
lastThinkingContent = block.thinking;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// -- User message (synthetic tool result — signals turn boundary) --
|
|
250
|
+
case "user": {
|
|
251
|
+
const userMsg = msg as SDKUserMessage;
|
|
252
|
+
if (userMsg.parent_tool_use_id !== null) break;
|
|
253
|
+
|
|
254
|
+
// Capture accumulated text from the builder before resetting
|
|
255
|
+
if (builder) {
|
|
256
|
+
for (const block of builder.message.content) {
|
|
257
|
+
if (block.type === "text" && block.text) {
|
|
258
|
+
lastTextContent = block.text;
|
|
259
|
+
} else if (block.type === "thinking" && block.thinking) {
|
|
260
|
+
lastThinkingContent = block.thinking;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
builder = null;
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// -- Result (terminal) --
|
|
269
|
+
case "result": {
|
|
270
|
+
const result = msg as SDKResultMessage;
|
|
271
|
+
|
|
272
|
+
// Build final message with text/thinking only (strip tool calls)
|
|
273
|
+
const finalContent: AssistantMessage["content"] = [];
|
|
274
|
+
|
|
275
|
+
// Use builder's accumulated content if available, falling back to captured text
|
|
276
|
+
if (builder) {
|
|
277
|
+
for (const block of builder.message.content) {
|
|
278
|
+
if (block.type === "text" && block.text) {
|
|
279
|
+
lastTextContent = block.text;
|
|
280
|
+
} else if (block.type === "thinking" && block.thinking) {
|
|
281
|
+
lastThinkingContent = block.thinking;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (lastThinkingContent) {
|
|
287
|
+
finalContent.push({ type: "thinking", thinking: lastThinkingContent });
|
|
288
|
+
}
|
|
289
|
+
if (lastTextContent) {
|
|
290
|
+
finalContent.push({ type: "text", text: lastTextContent });
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// Fallback: use the SDK's result text if we have no content
|
|
294
|
+
if (finalContent.length === 0 && result.subtype === "success" && result.result) {
|
|
295
|
+
finalContent.push({ type: "text", text: result.result });
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const finalMessage: AssistantMessage = {
|
|
299
|
+
role: "assistant",
|
|
300
|
+
content: finalContent,
|
|
301
|
+
api: "anthropic-messages",
|
|
302
|
+
provider: "claude-code",
|
|
303
|
+
model: modelId,
|
|
304
|
+
usage: mapUsage(result.usage, result.total_cost_usd),
|
|
305
|
+
stopReason: result.is_error ? "error" : "stop",
|
|
306
|
+
timestamp: Date.now(),
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
if (result.is_error) {
|
|
310
|
+
const errText =
|
|
311
|
+
"errors" in result
|
|
312
|
+
? (result as any).errors?.join("; ")
|
|
313
|
+
: result.subtype;
|
|
314
|
+
finalMessage.errorMessage = errText;
|
|
315
|
+
stream.push({ type: "error", reason: "error", error: finalMessage });
|
|
316
|
+
} else {
|
|
317
|
+
stream.push({ type: "done", reason: "stop", message: finalMessage });
|
|
318
|
+
}
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
default:
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// Generator exhausted without a result message (unexpected)
|
|
328
|
+
const fallbackContent: AssistantMessage["content"] = [];
|
|
329
|
+
if (lastTextContent) {
|
|
330
|
+
fallbackContent.push({ type: "text", text: lastTextContent });
|
|
331
|
+
}
|
|
332
|
+
if (fallbackContent.length === 0) {
|
|
333
|
+
fallbackContent.push({ type: "text", text: "(Claude Code session ended without a response)" });
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
const fallback: AssistantMessage = {
|
|
337
|
+
role: "assistant",
|
|
338
|
+
content: fallbackContent,
|
|
339
|
+
api: "anthropic-messages",
|
|
340
|
+
provider: "claude-code",
|
|
341
|
+
model: modelId,
|
|
342
|
+
usage: { ...ZERO_USAGE },
|
|
343
|
+
stopReason: "stop",
|
|
344
|
+
timestamp: Date.now(),
|
|
345
|
+
};
|
|
346
|
+
stream.push({ type: "done", reason: "stop", message: fallback });
|
|
347
|
+
} catch (err) {
|
|
348
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
349
|
+
stream.push({
|
|
350
|
+
type: "error",
|
|
351
|
+
reason: "error",
|
|
352
|
+
error: makeErrorMessage(modelId, errorMsg),
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
}
|
|
@@ -32,6 +32,6 @@ Then:
|
|
|
32
32
|
11. Do not run git commands — the system commits your changes and handles any merge after this unit succeeds.
|
|
33
33
|
12. Update `.gsd/PROJECT.md` if it exists — refresh current state if needed.
|
|
34
34
|
|
|
35
|
-
**You MUST
|
|
35
|
+
**You MUST call `gsd_complete_slice` with the slice summary and UAT content before finishing. The tool persists to both DB and disk and renders `{{sliceSummaryPath}}` and `{{sliceUatPath}}` automatically.**
|
|
36
36
|
|
|
37
37
|
When done, say: "Slice {{sliceId}} complete."
|
|
@@ -10,10 +10,10 @@ Plan milestone {{milestoneId}} ("{{milestoneTitle}}"). Read `.gsd/DECISIONS.md`
|
|
|
10
10
|
## Planning Doctrine
|
|
11
11
|
|
|
12
12
|
- **Risk-first means proof-first.** The earliest slices should prove the hardest thing works by shipping the real feature through the uncertain path. If auth is the risk, the first slice ships a real login page with real session handling that a user can actually use — not a CLI command that returns "authenticated: true". Proof is the shipped feature working. There is no separate "proof" artifact. Do not plan spikes, proof-of-concept slices, or validation-only slices — the proof is the real feature, built through the risky path.
|
|
13
|
-
- **Every slice is vertical, demoable, and shippable.** Every slice ships real, user-facing functionality. "Demoable" means
|
|
13
|
+
- **Every slice is vertical, demoable, and shippable.** Every slice ships real, user-facing functionality. "Demoable" means the intended user can exercise the capability through its real interface — for a web app that's the UI, for a CLI tool that's the terminal, for an API that's a consuming client or curl. The test is: can someone *use* it, not just *assert* it passes. A slice that only proves something but doesn't ship real working code is not a slice — restructure it.
|
|
14
14
|
- **Brownfield bias.** When planning against an existing codebase, ground slices in existing modules, conventions, and seams. Prefer extending real patterns over inventing new ones.
|
|
15
15
|
- **Each slice should establish something downstream slices can depend on.** Think about what stable surface this slice creates for later work — an API, a data shape, a proven integration path.
|
|
16
|
-
- **Avoid foundation-only slices.** If a slice doesn't produce something demoable end-to-end, it's probably a layer, not a vertical slice. Restructure it.
|
|
16
|
+
- **Avoid foundation-only slices.** If a slice doesn't produce something demoable end-to-end, it's probably a layer, not a vertical slice. Restructure it. Exception: if the infrastructure *is* the product surface (a new protocol, extension API, or provider interface), the slice is vertical by definition — the downstream consumer is the demo.
|
|
17
17
|
- **Verification-first.** When planning slices, know what "done" looks like before detailing implementation. Each slice's demo line should describe concrete, verifiable evidence — not vague "it works" claims.
|
|
18
18
|
- **Plan for integrated reality, not just local proof.** Distinguish contract proof from live integration proof. If the milestone involves multiple runtime boundaries, one slice must explicitly prove the assembled system through the real entrypoint or runtime path.
|
|
19
19
|
- **Truthful demo lines only.** If a slice is proven by fixtures or tests only, say so. Do not phrase harness-level proof as if the user can already perform the live end-to-end behavior unless that has actually been exercised.
|
|
@@ -64,10 +64,10 @@ Then:
|
|
|
64
64
|
Apply these when decomposing and ordering slices:
|
|
65
65
|
|
|
66
66
|
- **Risk-first means proof-first.** The earliest slices should prove the hardest thing works by shipping the real feature through the uncertain path. If auth is the risk, the first slice ships a real login page with real session handling that a user can actually use — not a CLI command that returns "authenticated: true". Proof is the shipped feature working. There is no separate "proof" artifact. Do not plan spikes, proof-of-concept slices, or validation-only slices — the proof is the real feature, built through the risky path.
|
|
67
|
-
- **Every slice is vertical, demoable, and shippable.** Every slice ships real, user-facing functionality. "Demoable" means
|
|
67
|
+
- **Every slice is vertical, demoable, and shippable.** Every slice ships real, user-facing functionality. "Demoable" means the intended user can exercise the capability through its real interface — for a web app that's the UI, for a CLI tool that's the terminal, for an API that's a consuming client or curl. The test is: can someone *use* it, not just *assert* it passes. A slice that only proves something but doesn't ship real working code is not a slice — restructure it.
|
|
68
68
|
- **Brownfield bias.** When planning against an existing codebase, ground slices in existing modules, conventions, and seams. Prefer extending real patterns over inventing new ones.
|
|
69
69
|
- **Each slice should establish something downstream slices can depend on.** Think about what stable surface this slice creates for later work — an API, a data shape, a proven integration path.
|
|
70
|
-
- **Avoid foundation-only slices.** If a slice doesn't produce something demoable end-to-end, it's probably a layer, not a vertical slice. Restructure it.
|
|
70
|
+
- **Avoid foundation-only slices.** If a slice doesn't produce something demoable end-to-end, it's probably a layer, not a vertical slice. Restructure it. Exception: if the infrastructure *is* the product surface (a new protocol, extension API, or provider interface), the slice is vertical by definition — the downstream consumer is the demo.
|
|
71
71
|
- **Verification-first.** When planning slices, know what "done" looks like before detailing implementation. Each slice's demo line should describe concrete, verifiable evidence — not vague "it works" claims.
|
|
72
72
|
- **Plan for integrated reality, not just local proof.** Distinguish contract proof from live integration proof. If the milestone involves multiple runtime boundaries, one slice must explicitly prove the assembled system through the real entrypoint or runtime path.
|
|
73
73
|
- **Truthful demo lines only.** If a slice is proven by fixtures or tests only, say so. Do not phrase harness-level proof as if the user can already perform the live end-to-end behavior unless that has actually been exercised.
|
|
@@ -77,6 +77,6 @@ Then:
|
|
|
77
77
|
|
|
78
78
|
The slice directory and tasks/ subdirectory already exist. Do NOT mkdir. All work stays in your working directory: `{{workingDirectory}}`.
|
|
79
79
|
|
|
80
|
-
**You MUST
|
|
80
|
+
**You MUST call `gsd_plan_slice` to persist the planning state before finishing.**
|
|
81
81
|
|
|
82
82
|
When done, say: "Slice {{sliceId}} planned."
|
|
@@ -28,7 +28,7 @@ Then research the codebase and relevant technologies. Narrate key findings and s
|
|
|
28
28
|
5. **Web search budget:** You have a limited budget of web searches (max ~15 per session). Use them strategically — prefer `resolve_library` / `get_library_docs` for library documentation. Do NOT repeat the same or similar queries. If a search didn't find what you need, rephrase once or move on. Target 3-5 total web searches for a typical research unit.
|
|
29
29
|
6. Use the **Research** output template from the inlined context above — include only sections that have real content
|
|
30
30
|
7. If `.gsd/REQUIREMENTS.md` exists, research against it. Identify which Active requirements are table stakes, likely omissions, overbuilt risks, or domain-standard behaviors the user may or may not want.
|
|
31
|
-
8.
|
|
31
|
+
8. Call `gsd_summary_save` with `milestone_id: {{milestoneId}}`, `artifact_type: "RESEARCH"`, and the full research markdown as `content` — the tool computes the file path and persists to both DB and disk.
|
|
32
32
|
|
|
33
33
|
## Strategic Questions to Answer
|
|
34
34
|
|
|
@@ -42,6 +42,6 @@ Then research the codebase and relevant technologies. Narrate key findings and s
|
|
|
42
42
|
|
|
43
43
|
**Research is advisory, not auto-binding.** Surface candidate requirements clearly instead of silently expanding scope.
|
|
44
44
|
|
|
45
|
-
**You MUST
|
|
45
|
+
**You MUST call `gsd_summary_save` with the research content before finishing.**
|
|
46
46
|
|
|
47
47
|
When done, say: "Milestone {{milestoneId}} researched."
|
|
@@ -55,7 +55,7 @@ After running all checks, compute the **overall verdict**:
|
|
|
55
55
|
- `FAIL` — one or more checks failed
|
|
56
56
|
- `PARTIAL` — some checks passed, but one or more checks were skipped, inconclusive, or still require human judgment
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
Call `gsd_summary_save` with `milestone_id: {{milestoneId}}`, `slice_id: {{sliceId}}`, `artifact_type: "ASSESSMENT"`, and the full UAT result markdown as `content` — the tool computes the file path and persists to both DB and disk. The content should follow this format:
|
|
59
59
|
|
|
60
60
|
```markdown
|
|
61
61
|
---
|
|
@@ -84,6 +84,6 @@ date: <ISO 8601 timestamp>
|
|
|
84
84
|
|
|
85
85
|
---
|
|
86
86
|
|
|
87
|
-
**You MUST
|
|
87
|
+
**You MUST call `gsd_summary_save` with the UAT result content before finishing.**
|
|
88
88
|
|
|
89
89
|
When done, say: "UAT {{sliceId}} complete."
|
|
@@ -61,6 +61,18 @@ test("plan-slice prompt: DB-backed tool names survive template substitution", ()
|
|
|
61
61
|
assert.ok(result.includes("canonical write path"), "canonical write path language should survive substitution");
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
+
test("plan-slice prompt: footer references gsd_plan_slice tool, not direct write", () => {
|
|
65
|
+
const result = loadPrompt("plan-slice", { ...BASE_VARS, commitInstruction: "Do not commit." });
|
|
66
|
+
assert.ok(
|
|
67
|
+
result.includes("MUST call `gsd_plan_slice`"),
|
|
68
|
+
"footer should instruct calling gsd_plan_slice tool",
|
|
69
|
+
);
|
|
70
|
+
assert.ok(
|
|
71
|
+
!result.includes("MUST write the file"),
|
|
72
|
+
"footer should not instruct direct file write",
|
|
73
|
+
);
|
|
74
|
+
});
|
|
75
|
+
|
|
64
76
|
test("domain-work prompts use skillActivation placeholder", () => {
|
|
65
77
|
const prompts = [
|
|
66
78
|
"research-milestone",
|
|
@@ -174,6 +186,34 @@ test("research-milestone prompt substitutes skillActivation", () => {
|
|
|
174
186
|
assert.ok(!result.includes("{{skillActivation}}"));
|
|
175
187
|
});
|
|
176
188
|
|
|
189
|
+
test("research-milestone prompt references gsd_summary_save, not direct write", () => {
|
|
190
|
+
const result = loadPrompt("research-milestone", {
|
|
191
|
+
workingDirectory: "/tmp/test-project",
|
|
192
|
+
milestoneId: "M001",
|
|
193
|
+
milestoneTitle: "Test Milestone",
|
|
194
|
+
milestonePath: ".gsd/milestones/M001",
|
|
195
|
+
contextPath: ".gsd/milestones/M001/M001-CONTEXT.md",
|
|
196
|
+
outputPath: "/tmp/test-project/.gsd/milestones/M001/M001-RESEARCH.md",
|
|
197
|
+
inlinedContext: "Context",
|
|
198
|
+
skillDiscoveryMode: "manual",
|
|
199
|
+
skillDiscoveryInstructions: " Discover skills manually.",
|
|
200
|
+
skillActivation: "Load research skills first.",
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
assert.ok(
|
|
204
|
+
result.includes("gsd_summary_save"),
|
|
205
|
+
"research-milestone should reference gsd_summary_save tool",
|
|
206
|
+
);
|
|
207
|
+
assert.ok(
|
|
208
|
+
result.includes('artifact_type: "RESEARCH"'),
|
|
209
|
+
"research-milestone should specify RESEARCH artifact type",
|
|
210
|
+
);
|
|
211
|
+
assert.ok(
|
|
212
|
+
!result.includes("MUST write the file"),
|
|
213
|
+
"research-milestone should not instruct direct file write",
|
|
214
|
+
);
|
|
215
|
+
});
|
|
216
|
+
|
|
177
217
|
test("research-slice prompt substitutes skillActivation", () => {
|
|
178
218
|
const result = loadPrompt("research-slice", {
|
|
179
219
|
workingDirectory: "/tmp/test-project",
|
|
@@ -228,6 +228,31 @@ test('(k) run-uat prompt template', () => {
|
|
|
228
228
|
);
|
|
229
229
|
});
|
|
230
230
|
|
|
231
|
+
test('(k2) run-uat prompt references gsd_summary_save, not direct write', () => {
|
|
232
|
+
const promptResult = loadPromptFromWorktree('run-uat', {
|
|
233
|
+
workingDirectory: '/tmp/test-project',
|
|
234
|
+
milestoneId: 'M001',
|
|
235
|
+
sliceId: 'S01',
|
|
236
|
+
uatPath: '.gsd/milestones/M001/slices/S01/S01-UAT.md',
|
|
237
|
+
uatResultPath: '.gsd/milestones/M001/slices/S01/S01-UAT-RESULT.md',
|
|
238
|
+
uatType: 'artifact-driven',
|
|
239
|
+
inlinedContext: '<!-- no context -->',
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
assert.ok(
|
|
243
|
+
promptResult.includes('gsd_summary_save'),
|
|
244
|
+
'run-uat prompt should reference gsd_summary_save tool',
|
|
245
|
+
);
|
|
246
|
+
assert.ok(
|
|
247
|
+
promptResult.includes('artifact_type: "ASSESSMENT"'),
|
|
248
|
+
'run-uat prompt should specify ASSESSMENT artifact type',
|
|
249
|
+
);
|
|
250
|
+
assert.ok(
|
|
251
|
+
!promptResult.includes('MUST write'),
|
|
252
|
+
'run-uat prompt should not instruct direct file write in footer',
|
|
253
|
+
);
|
|
254
|
+
});
|
|
255
|
+
|
|
231
256
|
test('(l) dispatch preconditions via resolveSliceFile', () => {
|
|
232
257
|
const base = createFixtureBase();
|
|
233
258
|
const uatContent = makeUatContent('artifact-driven');
|
|
@@ -40,7 +40,7 @@ export function appendEvent(
|
|
|
40
40
|
event: Omit<WorkflowEvent, "hash" | "session_id"> & { actor_name?: string; trigger_reason?: string },
|
|
41
41
|
): void {
|
|
42
42
|
const hash = createHash("sha256")
|
|
43
|
-
.update(JSON.stringify({ cmd: event.cmd, params: event.params
|
|
43
|
+
.update(JSON.stringify({ cmd: event.cmd, params: event.params }))
|
|
44
44
|
.digest("hex")
|
|
45
45
|
.slice(0, 16);
|
|
46
46
|
|
|
File without changes
|
|
File without changes
|