gsd-pi 2.76.0-dev.4c866b677 → 2.76.0-dev.7218806ab
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/claude-cli-check.js +32 -3
- package/dist/mcp-server.d.ts +7 -0
- package/dist/mcp-server.js +35 -1
- package/dist/resources/extensions/claude-code-cli/readiness.js +4 -3
- package/dist/resources/extensions/claude-code-cli/stream-adapter.js +77 -17
- package/dist/resources/extensions/gsd/auto-model-selection.js +1 -1
- package/dist/resources/extensions/gsd/auto-start.js +11 -15
- package/dist/resources/extensions/gsd/auto.js +13 -17
- package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +17 -1
- package/dist/resources/extensions/gsd/bootstrap/db-tools.js +39 -9
- package/dist/resources/extensions/gsd/bootstrap/exec-tools.js +93 -0
- package/dist/resources/extensions/gsd/bootstrap/register-extension.js +2 -0
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +40 -4
- package/dist/resources/extensions/gsd/bootstrap/write-gate.js +12 -1
- package/dist/resources/extensions/gsd/commands-prefs-wizard.js +968 -23
- package/dist/resources/extensions/gsd/compaction-snapshot.js +121 -0
- package/dist/resources/extensions/gsd/error-classifier.js +10 -3
- package/dist/resources/extensions/gsd/exec-history.js +120 -0
- package/dist/resources/extensions/gsd/exec-sandbox.js +258 -0
- package/dist/resources/extensions/gsd/gsd-db.js +3 -1
- package/dist/resources/extensions/gsd/guided-flow.js +189 -0
- package/dist/resources/extensions/gsd/health-widget.js +4 -1
- package/dist/resources/extensions/gsd/key-manager.js +6 -0
- package/dist/resources/extensions/gsd/model-router.js +36 -3
- package/dist/resources/extensions/gsd/pre-execution-checks.js +35 -9
- package/dist/resources/extensions/gsd/preferences-types.js +9 -0
- package/dist/resources/extensions/gsd/preferences-validation.js +83 -0
- package/dist/resources/extensions/gsd/preferences.js +17 -17
- package/dist/resources/extensions/gsd/prompts/discuss-headless.md +8 -0
- package/dist/resources/extensions/gsd/prompts/discuss.md +29 -2
- package/dist/resources/extensions/gsd/token-counter.js +22 -5
- package/dist/resources/extensions/gsd/tools/exec-search-tool.js +59 -0
- package/dist/resources/extensions/gsd/tools/exec-tool.js +126 -0
- package/dist/resources/extensions/gsd/tools/resume-tool.js +23 -0
- package/dist/resources/extensions/gsd/workflow-mcp.js +3 -0
- package/dist/tsconfig.extensions.tsbuildinfo +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 +2 -2
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- 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-manifest.json +5 -5
- 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/package.json +1 -1
- package/packages/mcp-server/dist/remote-questions.d.ts +45 -0
- package/packages/mcp-server/dist/remote-questions.d.ts.map +1 -0
- package/packages/mcp-server/dist/remote-questions.js +732 -0
- package/packages/mcp-server/dist/remote-questions.js.map +1 -0
- package/packages/mcp-server/dist/server.d.ts.map +1 -1
- package/packages/mcp-server/dist/server.js +18 -1
- package/packages/mcp-server/dist/server.js.map +1 -1
- package/packages/mcp-server/dist/workflow-tools.d.ts.map +1 -1
- package/packages/mcp-server/dist/workflow-tools.js +64 -25
- package/packages/mcp-server/dist/workflow-tools.js.map +1 -1
- package/packages/mcp-server/package.json +2 -1
- package/packages/mcp-server/src/remote-questions.test.ts +294 -0
- package/packages/mcp-server/src/remote-questions.ts +916 -0
- package/packages/mcp-server/src/server.ts +19 -1
- package/packages/mcp-server/src/workflow-tools.test.ts +146 -1
- package/packages/mcp-server/src/workflow-tools.ts +84 -43
- package/packages/mcp-server/tsconfig.test.json +19 -0
- package/packages/mcp-server/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-ai/dist/providers/anthropic-shared.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic-shared.js +2 -0
- package/packages/pi-ai/dist/providers/anthropic-shared.js.map +1 -1
- package/packages/pi-ai/dist/providers/simple-options.d.ts +10 -0
- package/packages/pi-ai/dist/providers/simple-options.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/simple-options.js +16 -1
- package/packages/pi-ai/dist/providers/simple-options.js.map +1 -1
- package/packages/pi-ai/src/providers/anthropic-shared.ts +3 -1
- package/packages/pi-ai/src/providers/simple-options.ts +17 -1
- package/packages/pi-ai/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry-custom-caps.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/model-registry-custom-caps.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-registry-custom-caps.test.js +203 -0
- package/packages/pi-coding-agent/dist/core/model-registry-custom-caps.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-registry.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry.js +14 -0
- package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/redact-secrets.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.js +49 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.test.js +67 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/session-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/session-manager.js +9 -5
- package/packages/pi-coding-agent/dist/core/session-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/session-manager.test.js +25 -1
- package/packages/pi-coding-agent/dist/core/session-manager.test.js.map +1 -1
- 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 +13 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/pi-coding-agent/src/core/model-registry-custom-caps.test.ts +245 -0
- package/packages/pi-coding-agent/src/core/model-registry.ts +16 -0
- package/packages/pi-coding-agent/src/core/redact-secrets.test.ts +86 -0
- package/packages/pi-coding-agent/src/core/redact-secrets.ts +58 -0
- package/packages/pi-coding-agent/src/core/session-manager.test.ts +36 -1
- package/packages/pi-coding-agent/src/core/session-manager.ts +9 -5
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +13 -1
- package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
- package/src/resources/extensions/claude-code-cli/readiness.ts +4 -3
- package/src/resources/extensions/claude-code-cli/stream-adapter.ts +78 -17
- package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +149 -5
- package/src/resources/extensions/gsd/auto-model-selection.ts +1 -1
- package/src/resources/extensions/gsd/auto-post-unit.ts +0 -1
- package/src/resources/extensions/gsd/auto-start.ts +13 -16
- package/src/resources/extensions/gsd/auto.ts +12 -17
- package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +23 -1
- package/src/resources/extensions/gsd/bootstrap/db-tools.ts +40 -9
- package/src/resources/extensions/gsd/bootstrap/exec-tools.ts +109 -0
- package/src/resources/extensions/gsd/bootstrap/register-extension.ts +2 -0
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +42 -4
- package/src/resources/extensions/gsd/bootstrap/write-gate.ts +13 -1
- package/src/resources/extensions/gsd/commands-prefs-wizard.ts +898 -32
- package/src/resources/extensions/gsd/compaction-snapshot.ts +165 -0
- package/src/resources/extensions/gsd/error-classifier.ts +10 -3
- package/src/resources/extensions/gsd/exec-history.ts +153 -0
- package/src/resources/extensions/gsd/exec-sandbox.ts +326 -0
- package/src/resources/extensions/gsd/gsd-db.ts +3 -1
- package/src/resources/extensions/gsd/guided-flow.ts +221 -0
- package/src/resources/extensions/gsd/health-widget.ts +3 -1
- package/src/resources/extensions/gsd/key-manager.ts +6 -0
- package/src/resources/extensions/gsd/model-router.ts +42 -1
- package/src/resources/extensions/gsd/pre-execution-checks.ts +36 -10
- package/src/resources/extensions/gsd/preferences-types.ts +38 -0
- package/src/resources/extensions/gsd/preferences-validation.ts +79 -0
- package/src/resources/extensions/gsd/preferences.ts +17 -17
- package/src/resources/extensions/gsd/prompts/discuss-headless.md +8 -0
- package/src/resources/extensions/gsd/prompts/discuss.md +29 -2
- package/src/resources/extensions/gsd/tests/compaction-snapshot.test.ts +123 -0
- package/src/resources/extensions/gsd/tests/doctor-providers.test.ts +31 -0
- package/src/resources/extensions/gsd/tests/exec-history.test.ts +124 -0
- package/src/resources/extensions/gsd/tests/exec-sandbox.test.ts +210 -0
- package/src/resources/extensions/gsd/tests/gsd-db.test.ts +64 -0
- package/src/resources/extensions/gsd/tests/isolation-none-branch-guard.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/key-manager.test.ts +7 -0
- package/src/resources/extensions/gsd/tests/pre-exec-backtick-strip.test.ts +14 -0
- package/src/resources/extensions/gsd/tests/pre-execution-checks.test.ts +234 -0
- package/src/resources/extensions/gsd/tests/preferences.test.ts +110 -0
- package/src/resources/extensions/gsd/tests/prefs-wizard-coverage.test.ts +44 -0
- package/src/resources/extensions/gsd/tests/provider-errors.test.ts +48 -0
- package/src/resources/extensions/gsd/tests/ready-phrase-no-files-4573.test.ts +388 -0
- package/src/resources/extensions/gsd/tests/restore-tools-after-discuss.test.ts +9 -3
- package/src/resources/extensions/gsd/tests/save-gate-result-render.test.ts +95 -0
- package/src/resources/extensions/gsd/tests/session-start-footer.test.ts +32 -40
- package/src/resources/extensions/gsd/tests/token-counter.test.ts +105 -1
- package/src/resources/extensions/gsd/tests/tool-compatibility.test.ts +107 -0
- package/src/resources/extensions/gsd/tests/workflow-tool-executors.test.ts +65 -2
- package/src/resources/extensions/gsd/tests/write-gate.test.ts +64 -0
- package/src/resources/extensions/gsd/tests/zombie-gsd-state.test.ts +3 -1
- package/src/resources/extensions/gsd/token-counter.ts +22 -5
- package/src/resources/extensions/gsd/tools/exec-search-tool.ts +81 -0
- package/src/resources/extensions/gsd/tools/exec-tool.ts +183 -0
- package/src/resources/extensions/gsd/tools/resume-tool.ts +40 -0
- package/src/resources/extensions/gsd/workflow-logger.ts +2 -1
- package/src/resources/extensions/gsd/workflow-mcp.ts +3 -0
- /package/dist/web/standalone/.next/static/{jDqWYbuP_CG6Kjc-uKwkN → 5qAwYhcU5Fs2VOq_R8lOc}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{jDqWYbuP_CG6Kjc-uKwkN → 5qAwYhcU5Fs2VOq_R8lOc}/_ssgManifest.js +0 -0
|
@@ -79,6 +79,13 @@ function runPlanV2Gate(ctx, basePath, state) {
|
|
|
79
79
|
function buildDocsCommitInstruction(_message) {
|
|
80
80
|
return "Do not commit planning artifacts — .gsd/ is managed externally.";
|
|
81
81
|
}
|
|
82
|
+
// #4573: cap for how many times we nudge the LLM after a premature ready
|
|
83
|
+
// phrase before giving up and asking the user to re-run /gsd.
|
|
84
|
+
const MAX_READY_REJECTS = 2;
|
|
85
|
+
// #4573: matches the canonical ready phrase the discuss prompt asks the LLM
|
|
86
|
+
// to emit. Accepts any M-prefixed milestone ID (three digits + optional
|
|
87
|
+
// suffix) with optional trailing punctuation.
|
|
88
|
+
const READY_PHRASE_RE = /\bMilestone\s+M\d{3}[A-Z0-9-]*\s+ready\.?/i;
|
|
82
89
|
const pendingAutoStartMap = new Map();
|
|
83
90
|
/**
|
|
84
91
|
* Backward-compat bridge: returns a mutable reference to the entry matching
|
|
@@ -225,6 +232,188 @@ export function checkAutoStartAfterDiscuss() {
|
|
|
225
232
|
startAutoDetached(ctx, pi, basePath, false, { step });
|
|
226
233
|
return true;
|
|
227
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* Extract the concatenated text content from an assistant message, whether it
|
|
237
|
+
* stores content as a string or as an array of text blocks.
|
|
238
|
+
*/
|
|
239
|
+
function extractAssistantText(msg) {
|
|
240
|
+
if (!msg)
|
|
241
|
+
return "";
|
|
242
|
+
const content = msg.content;
|
|
243
|
+
if (typeof content === "string")
|
|
244
|
+
return content;
|
|
245
|
+
if (!Array.isArray(content))
|
|
246
|
+
return "";
|
|
247
|
+
const parts = [];
|
|
248
|
+
for (const block of content) {
|
|
249
|
+
if (!block || typeof block !== "object")
|
|
250
|
+
continue;
|
|
251
|
+
if (block.type === "text" && typeof block.text === "string")
|
|
252
|
+
parts.push(block.text);
|
|
253
|
+
}
|
|
254
|
+
return parts.join("\n");
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Return true if the assistant message contains any tool-use block.
|
|
258
|
+
*/
|
|
259
|
+
function hasToolUse(msg) {
|
|
260
|
+
if (!msg)
|
|
261
|
+
return false;
|
|
262
|
+
const content = msg.content;
|
|
263
|
+
if (!Array.isArray(content))
|
|
264
|
+
return false;
|
|
265
|
+
return content.some((b) => b && typeof b === "object" && (b.type === "tool_use" || b.type === "tool-use"));
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* #4573 — Detect and recover from the "ready phrase without files" failure mode.
|
|
269
|
+
*
|
|
270
|
+
* When the LLM emits "Milestone {{id}} ready." but has not written CONTEXT.md
|
|
271
|
+
* or ROADMAP.md, `checkAutoStartAfterDiscuss()` silently returns false and the
|
|
272
|
+
* next /gsd invocation loops into the "All milestones complete" warning.
|
|
273
|
+
*
|
|
274
|
+
* This function, called from `handleAgentEnd` after `checkAutoStartAfterDiscuss`
|
|
275
|
+
* returns false, pattern-matches the ready phrase on the last assistant message.
|
|
276
|
+
* If it fired AND neither CONTEXT.md nor ROADMAP.md exists, it:
|
|
277
|
+
* 1. Notifies the user that the signal was rejected.
|
|
278
|
+
* 2. Injects a system message via `pi.sendMessage(..., {triggerTurn:true})`
|
|
279
|
+
* telling the LLM the signal was premature and to emit the writes now.
|
|
280
|
+
* 3. Caps at `MAX_READY_REJECTS` per-entry; beyond that, gives up and asks
|
|
281
|
+
* the user to re-run /gsd.
|
|
282
|
+
*
|
|
283
|
+
* Returns true when a nudge (or give-up) was emitted, signaling the caller to
|
|
284
|
+
* skip `resolveAgentEnd`.
|
|
285
|
+
*/
|
|
286
|
+
export function maybeHandleReadyPhraseWithoutFiles(event) {
|
|
287
|
+
const entry = _getPendingAutoStart();
|
|
288
|
+
if (!entry)
|
|
289
|
+
return false;
|
|
290
|
+
const { ctx, pi, basePath, milestoneId } = entry;
|
|
291
|
+
// Gate: last assistant message must contain the ready phrase
|
|
292
|
+
const lastMsg = event.messages[event.messages.length - 1];
|
|
293
|
+
const text = extractAssistantText(lastMsg);
|
|
294
|
+
if (!READY_PHRASE_RE.test(text))
|
|
295
|
+
return false;
|
|
296
|
+
// Gate: artifacts must still be missing — if they exist, the happy path
|
|
297
|
+
// already fired and we have nothing to do.
|
|
298
|
+
const contextFile = resolveMilestoneFile(basePath, milestoneId, "CONTEXT");
|
|
299
|
+
const roadmapFile = resolveMilestoneFile(basePath, milestoneId, "ROADMAP");
|
|
300
|
+
if (contextFile || roadmapFile)
|
|
301
|
+
return false;
|
|
302
|
+
entry.readyRejectCount = (entry.readyRejectCount ?? 0) + 1;
|
|
303
|
+
if (entry.readyRejectCount > MAX_READY_REJECTS) {
|
|
304
|
+
// Give up: clear state and tell the user to re-run /gsd. Avoids an
|
|
305
|
+
// infinite nudge loop when the LLM never produces the writes.
|
|
306
|
+
pendingAutoStartMap.delete(basePath);
|
|
307
|
+
ctx.ui.notify(`Milestone ${milestoneId}: LLM signaled "ready" ${entry.readyRejectCount} times without writing files. ` +
|
|
308
|
+
`Stopping auto-nudge. Run /gsd to try again.`, "error");
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
ctx.ui.notify(`Milestone ${milestoneId}: "ready" signal rejected — CONTEXT.md and ROADMAP.md are missing. Asking the LLM to complete the writes.`, "warning");
|
|
312
|
+
const nudge = `You emitted "Milestone ${milestoneId} ready." but neither ` +
|
|
313
|
+
`.gsd/milestones/${milestoneId}/${milestoneId}-CONTEXT.md nor ` +
|
|
314
|
+
`.gsd/milestones/${milestoneId}/${milestoneId}-ROADMAP.md exists on disk. ` +
|
|
315
|
+
`The ready phrase is a POST-WRITE signal and has been rejected. ` +
|
|
316
|
+
`In this turn: (1) write PROJECT.md, REQUIREMENTS.md, and the milestone ` +
|
|
317
|
+
`CONTEXT.md, (2) call gsd_plan_milestone, then (3) emit the ready phrase. ` +
|
|
318
|
+
`Do not describe these steps — execute them as tool calls. ` +
|
|
319
|
+
`This is retry ${entry.readyRejectCount}/${MAX_READY_REJECTS}; further ` +
|
|
320
|
+
`premature signals will clear the session.`;
|
|
321
|
+
try {
|
|
322
|
+
pi.sendMessage({ customType: "gsd-ready-no-files", content: nudge, display: false }, { triggerTurn: true });
|
|
323
|
+
}
|
|
324
|
+
catch (e) {
|
|
325
|
+
logWarning("guided", `ready-phrase nudge sendMessage failed: ${e.message}`);
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
328
|
+
return true;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* #4573 — Detect and recover from the "announces tool, never calls it" stall.
|
|
332
|
+
*
|
|
333
|
+
* The LLM emits text like "I'll now write the CONTEXT.md file" but the turn
|
|
334
|
+
* ends with zero tool-use blocks. The harness has no post-turn tool-call
|
|
335
|
+
* validation, so the unit promise resolves and the user sees a stalled state.
|
|
336
|
+
*
|
|
337
|
+
* This function, called from `handleAgentEnd`, inspects the last assistant
|
|
338
|
+
* message. If ALL of the following are true, it injects a recovery message:
|
|
339
|
+
* - Text-only (no tool-use blocks)
|
|
340
|
+
* - Contains a commit-intent phrase ("I'll write", "I'll call", etc.)
|
|
341
|
+
* - Auto-mode is active OR a discussion autostart is pending
|
|
342
|
+
* - `emptyTurnRetryCount` is under the cap
|
|
343
|
+
*
|
|
344
|
+
* Per-handler state is held on the `PendingAutoStartEntry` when present, and
|
|
345
|
+
* on a module-level map otherwise. The counter resets on any successful
|
|
346
|
+
* tool-use turn via `resetEmptyTurnCounter`.
|
|
347
|
+
*/
|
|
348
|
+
const emptyTurnCounterByBase = new Map();
|
|
349
|
+
const MAX_EMPTY_TURN_RETRIES = 2;
|
|
350
|
+
// Phrases that indicate the LLM is about to do something but has not yet.
|
|
351
|
+
// Kept tight to avoid flagging legitimate narration like "I'll wait for your answer."
|
|
352
|
+
const COMMIT_INTENT_RE = /\b(?:I['’]ll|I will|Next,? I['’]ll|Now I['’]ll|Let me|I['’]m going to|I am going to)\s+(?:now\s+)?(?:write|create|call|invoke|update|add|make|run|execute|generate|produce|emit|compose|implement|save|apply|commit)\b/i;
|
|
353
|
+
/**
|
|
354
|
+
* Reset the empty-turn counter for a basePath after a successful tool-use turn.
|
|
355
|
+
* Called from handleAgentEnd when the last message contains tool_use blocks.
|
|
356
|
+
*/
|
|
357
|
+
export function resetEmptyTurnCounter(basePath) {
|
|
358
|
+
if (basePath)
|
|
359
|
+
emptyTurnCounterByBase.delete(basePath);
|
|
360
|
+
else
|
|
361
|
+
emptyTurnCounterByBase.clear();
|
|
362
|
+
}
|
|
363
|
+
export function maybeHandleEmptyIntentTurn(event, isAuto) {
|
|
364
|
+
// Gate: only fire when there is system-driven work in flight. Interactive
|
|
365
|
+
// /gsd discuss (user-driven) produces legitimate text-only turns.
|
|
366
|
+
if (!isAuto && pendingAutoStartMap.size === 0)
|
|
367
|
+
return false;
|
|
368
|
+
const lastMsg = event.messages[event.messages.length - 1];
|
|
369
|
+
if (!lastMsg)
|
|
370
|
+
return false;
|
|
371
|
+
if (hasToolUse(lastMsg))
|
|
372
|
+
return false;
|
|
373
|
+
const text = extractAssistantText(lastMsg).trim();
|
|
374
|
+
if (!text)
|
|
375
|
+
return false;
|
|
376
|
+
// Skip if the LLM is emitting the ready phrase — that is the ready-no-files
|
|
377
|
+
// path, handled by maybeHandleReadyPhraseWithoutFiles.
|
|
378
|
+
if (READY_PHRASE_RE.test(text))
|
|
379
|
+
return false;
|
|
380
|
+
// Skip if the LLM is clearly handing back to the user. Keep the heuristic
|
|
381
|
+
// tight: a trailing question mark on the last non-empty line is the common
|
|
382
|
+
// signal for "I asked the user a question and stopped."
|
|
383
|
+
const lines = text.split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
|
|
384
|
+
const lastLine = lines[lines.length - 1] ?? "";
|
|
385
|
+
if (lastLine.endsWith("?"))
|
|
386
|
+
return false;
|
|
387
|
+
// Must contain a commit-intent phrase — this is the stall we care about.
|
|
388
|
+
if (!COMMIT_INTENT_RE.test(text))
|
|
389
|
+
return false;
|
|
390
|
+
// Resolve the target basePath + pi for injection. Prefer the pending
|
|
391
|
+
// autostart entry (discuss flow); otherwise we cannot inject.
|
|
392
|
+
const entry = _getPendingAutoStart();
|
|
393
|
+
if (!entry)
|
|
394
|
+
return false;
|
|
395
|
+
const { ctx, pi, basePath } = entry;
|
|
396
|
+
const count = (emptyTurnCounterByBase.get(basePath) ?? 0) + 1;
|
|
397
|
+
emptyTurnCounterByBase.set(basePath, count);
|
|
398
|
+
if (count > MAX_EMPTY_TURN_RETRIES) {
|
|
399
|
+
ctx.ui.notify(`Empty-turn recovery: LLM announced intent ${count} times without calling any tool. ` +
|
|
400
|
+
`Stopping auto-nudge.`, "error");
|
|
401
|
+
return false; // let the normal flow resolve/pause the unit
|
|
402
|
+
}
|
|
403
|
+
ctx.ui.notify(`Empty-turn detected: LLM announced intent but called no tool. Prompting it to execute.`, "info");
|
|
404
|
+
const nudge = `Your last turn announced an action (e.g. "I'll write…" or "Let me call…") ` +
|
|
405
|
+
`but contained no tool call. The system records zero tool-use blocks for ` +
|
|
406
|
+
`that turn. Execute the announced action NOW as a tool call in this turn. ` +
|
|
407
|
+
`Do not describe it again. Retry ${count}/${MAX_EMPTY_TURN_RETRIES}.`;
|
|
408
|
+
try {
|
|
409
|
+
pi.sendMessage({ customType: "gsd-empty-turn-recovery", content: nudge, display: false }, { triggerTurn: true });
|
|
410
|
+
}
|
|
411
|
+
catch (e) {
|
|
412
|
+
logWarning("guided", `empty-turn nudge sendMessage failed: ${e.message}`);
|
|
413
|
+
return false;
|
|
414
|
+
}
|
|
415
|
+
return true;
|
|
416
|
+
}
|
|
228
417
|
/**
|
|
229
418
|
* Extract milestone IDs from PROJECT.md milestone sequence table.
|
|
230
419
|
* Looks for rows like "| M001 | Name | Status |" and extracts the ID column.
|
|
@@ -91,6 +91,7 @@ export function initHealthWidget(ctx) {
|
|
|
91
91
|
let data = initialData;
|
|
92
92
|
let cachedLines;
|
|
93
93
|
let refreshInFlight = false;
|
|
94
|
+
let isDisposed = false;
|
|
94
95
|
const refresh = async () => {
|
|
95
96
|
if (refreshInFlight)
|
|
96
97
|
return;
|
|
@@ -98,7 +99,8 @@ export function initHealthWidget(ctx) {
|
|
|
98
99
|
try {
|
|
99
100
|
data = loadHealthWidgetData(basePath);
|
|
100
101
|
cachedLines = undefined;
|
|
101
|
-
|
|
102
|
+
if (!isDisposed)
|
|
103
|
+
_tui.requestRender();
|
|
102
104
|
}
|
|
103
105
|
catch { /* non-fatal */ }
|
|
104
106
|
finally {
|
|
@@ -122,6 +124,7 @@ export function initHealthWidget(ctx) {
|
|
|
122
124
|
},
|
|
123
125
|
invalidate() { cachedLines = undefined; cachedWidth = undefined; },
|
|
124
126
|
dispose() {
|
|
127
|
+
isDisposed = true;
|
|
125
128
|
clearInterval(refreshTimer);
|
|
126
129
|
},
|
|
127
130
|
};
|
|
@@ -12,6 +12,12 @@ import { getErrorMessage } from "./error-utils.js";
|
|
|
12
12
|
export const PROVIDER_REGISTRY = [
|
|
13
13
|
// LLM Providers
|
|
14
14
|
{ id: "anthropic", label: "Anthropic (Claude)", category: "llm", envVar: "ANTHROPIC_API_KEY", prefixes: ["sk-ant-"], hasOAuth: true, dashboardUrl: "console.anthropic.com" },
|
|
15
|
+
// Claude Code CLI: routes through the local `claude` binary — no API key,
|
|
16
|
+
// authentication is handled by the CLI's own OAuth flow.
|
|
17
|
+
// Referenced by doctor-providers.ts, auto-model-selection.ts, and others;
|
|
18
|
+
// must be in the canonical registry so all consumers see the same catalog.
|
|
19
|
+
// See: https://github.com/gsd-build/gsd-2/issues/4541
|
|
20
|
+
{ id: "claude-code", label: "Claude Code CLI", category: "llm", hasOAuth: true },
|
|
15
21
|
{ id: "openai", label: "OpenAI", category: "llm", envVar: "OPENAI_API_KEY", prefixes: ["sk-"], dashboardUrl: "platform.openai.com/api-keys" },
|
|
16
22
|
{ id: "github-copilot", label: "GitHub Copilot", category: "llm", envVar: "GITHUB_TOKEN", hasOAuth: true },
|
|
17
23
|
{ id: "openai-codex", label: "ChatGPT Plus/Pro (Codex)", category: "llm", hasOAuth: true },
|
|
@@ -440,6 +440,20 @@ function getModelCost(modelId) {
|
|
|
440
440
|
function bareModelId(modelId) {
|
|
441
441
|
return modelId.includes("/") ? modelId.split("/").pop() : modelId;
|
|
442
442
|
}
|
|
443
|
+
// ─── Provider-specific Tool Limits ─────────────────────────────────────────
|
|
444
|
+
/**
|
|
445
|
+
* Groq enforces a hard limit of 128 tools per request.
|
|
446
|
+
* Requests exceeding this limit receive a 400 error:
|
|
447
|
+
* "maximum number of items is 128"
|
|
448
|
+
* @see https://console.groq.com/docs/tool-use
|
|
449
|
+
*/
|
|
450
|
+
export const GROQ_MAX_TOOLS = 128;
|
|
451
|
+
/**
|
|
452
|
+
* Provider IDs that map to the Groq API backend.
|
|
453
|
+
* Used to detect Groq at the GSD routing layer where only the provider string
|
|
454
|
+
* is available (the pi-ai openai-completions adapter is shared across providers).
|
|
455
|
+
*/
|
|
456
|
+
const GROQ_PROVIDER_IDS = new Set(["groq"]);
|
|
443
457
|
// ─── Tool Compatibility Filter (ADR-005 Phase 3) ───────────────────────────
|
|
444
458
|
/**
|
|
445
459
|
* Check if a tool is compatible with a provider's capabilities.
|
|
@@ -461,8 +475,14 @@ export function isToolCompatibleWithProvider(toolName, providerCaps) {
|
|
|
461
475
|
/**
|
|
462
476
|
* Filter a list of tool names to only those compatible with a provider.
|
|
463
477
|
* Used by the routing pipeline to adjust tool sets when switching providers.
|
|
478
|
+
*
|
|
479
|
+
* @param toolNames - The full list of active tool names to filter.
|
|
480
|
+
* @param providerApi - The pi-ai API string (e.g. "openai-completions").
|
|
481
|
+
* @param provider - Optional provider ID (e.g. "groq"). Used to apply
|
|
482
|
+
* provider-specific limits that can't be expressed as API-level capabilities
|
|
483
|
+
* (e.g. Groq's 128-tool hard limit on the shared openai-completions adapter).
|
|
464
484
|
*/
|
|
465
|
-
export function filterToolsForProvider(toolNames, providerApi) {
|
|
485
|
+
export function filterToolsForProvider(toolNames, providerApi, provider) {
|
|
466
486
|
const providerCaps = getProviderCapabilities(providerApi);
|
|
467
487
|
// Provider doesn't support tool calling at all
|
|
468
488
|
if (!providerCaps.toolCalling) {
|
|
@@ -478,6 +498,14 @@ export function filterToolsForProvider(toolNames, providerApi) {
|
|
|
478
498
|
filtered.push(name);
|
|
479
499
|
}
|
|
480
500
|
}
|
|
501
|
+
// Groq enforces a hard limit of 128 tools per request (#4376).
|
|
502
|
+
// Trim the compatible list to GROQ_MAX_TOOLS and move the excess to filtered.
|
|
503
|
+
if (provider && GROQ_PROVIDER_IDS.has(provider) && compatible.length > GROQ_MAX_TOOLS) {
|
|
504
|
+
const trimmed = compatible.splice(GROQ_MAX_TOOLS);
|
|
505
|
+
filtered.push(...trimmed);
|
|
506
|
+
console.warn(`[gsd] Groq tool limit: ${compatible.length + trimmed.length} tools active but Groq allows at most ${GROQ_MAX_TOOLS}. ` +
|
|
507
|
+
`Trimming to the first ${GROQ_MAX_TOOLS} tools. Removed: ${trimmed.join(", ")}`);
|
|
508
|
+
}
|
|
481
509
|
return { compatible, filtered };
|
|
482
510
|
}
|
|
483
511
|
/**
|
|
@@ -486,8 +514,13 @@ export function filterToolsForProvider(toolNames, providerApi) {
|
|
|
486
514
|
*
|
|
487
515
|
* This is a hard filter only — it removes tools that would fail at the
|
|
488
516
|
* provider level. It does NOT remove tools based on soft heuristics.
|
|
517
|
+
*
|
|
518
|
+
* @param activeToolNames - The full list of currently active tool names.
|
|
519
|
+
* @param selectedModelApi - The pi-ai API string for the selected model.
|
|
520
|
+
* @param provider - Optional provider ID (e.g. "groq") for provider-specific
|
|
521
|
+
* limits beyond what the API-level capability profile expresses.
|
|
489
522
|
*/
|
|
490
|
-
export function adjustToolSet(activeToolNames, selectedModelApi) {
|
|
491
|
-
const { compatible, filtered } = filterToolsForProvider(activeToolNames, selectedModelApi);
|
|
523
|
+
export function adjustToolSet(activeToolNames, selectedModelApi, provider) {
|
|
524
|
+
const { compatible, filtered } = filterToolsForProvider(activeToolNames, selectedModelApi, provider);
|
|
492
525
|
return { toolNames: compatible, removedTools: filtered };
|
|
493
526
|
}
|
|
@@ -68,8 +68,13 @@ export function extractPackageReferences(description) {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
// require('pkg') or import from 'pkg' in code blocks
|
|
72
|
-
|
|
71
|
+
// require('pkg') or `import ... from 'pkg'` in code blocks.
|
|
72
|
+
// The `from\s+['"]` branch MUST be preceded by an `import` keyword so that
|
|
73
|
+
// natural-language prose like `from "What's Next"` or `from 'master'` does
|
|
74
|
+
// not produce false package-existence failures. Requiring the leading import
|
|
75
|
+
// keyword anchors the match to JavaScript/TypeScript syntax.
|
|
76
|
+
// See: https://github.com/gsd-build/gsd-2/issues/4388
|
|
77
|
+
const importPattern = /(?:require\s*\(\s*['"]|import\b[\s\S]*?\bfrom\s+['"])([a-zA-Z0-9@/_-]+)['"\)]/g;
|
|
73
78
|
let importMatch;
|
|
74
79
|
while ((importMatch = importPattern.exec(description)) !== null) {
|
|
75
80
|
// Skip relative imports and node builtins
|
|
@@ -278,7 +283,12 @@ function extractPathFromAnnotation(raw) {
|
|
|
278
283
|
}
|
|
279
284
|
const annotatedMatch = trimmed.match(/^(.+?)\s+[—–-]\s+.+$/);
|
|
280
285
|
if (annotatedMatch) {
|
|
281
|
-
|
|
286
|
+
const prefix = annotatedMatch[1].trim();
|
|
287
|
+
const prefixBacktickMatch = prefix.match(/`([^`]+)`/);
|
|
288
|
+
if (prefixBacktickMatch && looksLikePathOrUrl(prefixBacktickMatch[1].trim())) {
|
|
289
|
+
return prefixBacktickMatch[1].trim();
|
|
290
|
+
}
|
|
291
|
+
return prefix.replace(/`/g, "").trim();
|
|
282
292
|
}
|
|
283
293
|
// Fallback: scan all backticked tokens and return the first one that looks
|
|
284
294
|
// like a path or URL. Handles prose-annotated bullets such as:
|
|
@@ -333,13 +343,19 @@ function containsGlobPattern(candidate) {
|
|
|
333
343
|
}
|
|
334
344
|
/**
|
|
335
345
|
* Build a set of files that will be created by tasks up to (but not including) taskIndex.
|
|
346
|
+
* Also includes outputs of completed tasks at any position — a completed task has already
|
|
347
|
+
* run and its outputs are available regardless of sequence position or disk state (#4071).
|
|
336
348
|
* All paths are normalized for consistent comparison.
|
|
337
349
|
*/
|
|
338
350
|
function getExpectedOutputsUpTo(tasks, taskIndex) {
|
|
339
351
|
const outputs = new Set();
|
|
340
|
-
for (let i = 0; i <
|
|
341
|
-
|
|
342
|
-
|
|
352
|
+
for (let i = 0; i < tasks.length; i++) {
|
|
353
|
+
const task = tasks[i];
|
|
354
|
+
// Include prior tasks (i < taskIndex) OR completed tasks at any position
|
|
355
|
+
if (i < taskIndex || task.status === "completed") {
|
|
356
|
+
for (const file of task.expected_output) {
|
|
357
|
+
outputs.add(normalizeFilePath(file));
|
|
358
|
+
}
|
|
343
359
|
}
|
|
344
360
|
}
|
|
345
361
|
return outputs;
|
|
@@ -416,8 +432,14 @@ export function checkTaskOrdering(tasks, basePath) {
|
|
|
416
432
|
const task = tasks[i];
|
|
417
433
|
for (const file of task.expected_output) {
|
|
418
434
|
const normalizedFile = normalizeFilePath(file);
|
|
419
|
-
|
|
420
|
-
|
|
435
|
+
const existing = fileCreators.get(normalizedFile);
|
|
436
|
+
if (!existing || (!existing.completed && task.status === "completed")) {
|
|
437
|
+
fileCreators.set(normalizedFile, {
|
|
438
|
+
taskId: task.id,
|
|
439
|
+
index: i,
|
|
440
|
+
originalPath: file,
|
|
441
|
+
completed: task.status === "completed",
|
|
442
|
+
});
|
|
421
443
|
}
|
|
422
444
|
}
|
|
423
445
|
}
|
|
@@ -441,7 +463,11 @@ export function checkTaskOrdering(tasks, basePath) {
|
|
|
441
463
|
const creator = fileCreators.get(normalizedFile);
|
|
442
464
|
const absolutePath = resolve(basePath, normalizedFile);
|
|
443
465
|
const existsOnDisk = existsSync(absolutePath);
|
|
444
|
-
if
|
|
466
|
+
// Skip if the creating task has already completed — its output is available
|
|
467
|
+
// regardless of disk state (e.g. file was a temp artifact cleaned up after
|
|
468
|
+
// the task ran, or a replan introduced a new earlier-sequence task that
|
|
469
|
+
// reads this pre-execution output). (#4071)
|
|
470
|
+
if (creator && creator.index > i && !existsOnDisk && !creator.completed) {
|
|
445
471
|
// Task reads file that is created later — impossible ordering
|
|
446
472
|
results.push({
|
|
447
473
|
category: "file",
|
|
@@ -5,6 +5,14 @@
|
|
|
5
5
|
* both the validation and runtime modules can import them without pulling
|
|
6
6
|
* in filesystem or loading logic.
|
|
7
7
|
*/
|
|
8
|
+
/**
|
|
9
|
+
* Resolve whether context-mode features (gsd_exec sandbox + compaction
|
|
10
|
+
* snapshot) should be active. Default is ON: missing config or missing
|
|
11
|
+
* `enabled` is treated as true. Only `enabled: false` disables.
|
|
12
|
+
*/
|
|
13
|
+
export function isContextModeEnabled(prefs) {
|
|
14
|
+
return prefs?.context_mode?.enabled !== false;
|
|
15
|
+
}
|
|
8
16
|
/** Default preference values for each workflow mode. */
|
|
9
17
|
export const MODE_DEFAULTS = {
|
|
10
18
|
solo: {
|
|
@@ -87,6 +95,7 @@ export const KNOWN_PREFERENCE_KEYS = new Set([
|
|
|
87
95
|
"flat_rate_providers",
|
|
88
96
|
"language",
|
|
89
97
|
"context_window_override",
|
|
98
|
+
"context_mode",
|
|
90
99
|
]);
|
|
91
100
|
/** Canonical list of all dispatch unit types. */
|
|
92
101
|
export const KNOWN_UNIT_TYPES = [
|
|
@@ -660,6 +660,55 @@ export function validatePreferences(preferences) {
|
|
|
660
660
|
errors.push("context_management must be an object");
|
|
661
661
|
}
|
|
662
662
|
}
|
|
663
|
+
// ─── Context Mode (gsd_exec sandbox) ────────────────────────────────────
|
|
664
|
+
if (preferences.context_mode !== undefined) {
|
|
665
|
+
if (typeof preferences.context_mode === "object" && preferences.context_mode !== null) {
|
|
666
|
+
const cmode = preferences.context_mode;
|
|
667
|
+
const validCmode = {};
|
|
668
|
+
if (cmode.enabled !== undefined) {
|
|
669
|
+
if (typeof cmode.enabled === "boolean")
|
|
670
|
+
validCmode.enabled = cmode.enabled;
|
|
671
|
+
else
|
|
672
|
+
errors.push("context_mode.enabled must be a boolean");
|
|
673
|
+
}
|
|
674
|
+
if (cmode.exec_timeout_ms !== undefined) {
|
|
675
|
+
const t = cmode.exec_timeout_ms;
|
|
676
|
+
if (typeof t === "number" && t >= 1000 && t <= 600_000)
|
|
677
|
+
validCmode.exec_timeout_ms = Math.floor(t);
|
|
678
|
+
else
|
|
679
|
+
errors.push("context_mode.exec_timeout_ms must be a number between 1000 and 600000");
|
|
680
|
+
}
|
|
681
|
+
if (cmode.exec_stdout_cap_bytes !== undefined) {
|
|
682
|
+
const b = cmode.exec_stdout_cap_bytes;
|
|
683
|
+
if (typeof b === "number" && b >= 4096 && b <= 16_777_216)
|
|
684
|
+
validCmode.exec_stdout_cap_bytes = Math.floor(b);
|
|
685
|
+
else
|
|
686
|
+
errors.push("context_mode.exec_stdout_cap_bytes must be a number between 4096 and 16777216");
|
|
687
|
+
}
|
|
688
|
+
if (cmode.exec_digest_chars !== undefined) {
|
|
689
|
+
const c = cmode.exec_digest_chars;
|
|
690
|
+
if (typeof c === "number" && c >= 0 && c <= 4000)
|
|
691
|
+
validCmode.exec_digest_chars = Math.floor(c);
|
|
692
|
+
else
|
|
693
|
+
errors.push("context_mode.exec_digest_chars must be a number between 0 and 4000");
|
|
694
|
+
}
|
|
695
|
+
if (cmode.exec_env_allowlist !== undefined) {
|
|
696
|
+
if (Array.isArray(cmode.exec_env_allowlist) &&
|
|
697
|
+
cmode.exec_env_allowlist.every((v) => typeof v === "string" && /^[A-Z_][A-Z0-9_]*$/i.test(v))) {
|
|
698
|
+
validCmode.exec_env_allowlist = cmode.exec_env_allowlist;
|
|
699
|
+
}
|
|
700
|
+
else {
|
|
701
|
+
errors.push("context_mode.exec_env_allowlist must be an array of valid env var names");
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
if (Object.keys(validCmode).length > 0) {
|
|
705
|
+
validated.context_mode = validCmode;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
else {
|
|
709
|
+
errors.push("context_mode must be an object");
|
|
710
|
+
}
|
|
711
|
+
}
|
|
663
712
|
// ─── Parallel Config ────────────────────────────────────────────────────
|
|
664
713
|
if (preferences.parallel && typeof preferences.parallel === "object") {
|
|
665
714
|
const p = preferences.parallel;
|
|
@@ -716,6 +765,40 @@ export function validatePreferences(preferences) {
|
|
|
716
765
|
validated.parallel = parallel;
|
|
717
766
|
}
|
|
718
767
|
}
|
|
768
|
+
// ─── Slice Parallel Config ───────────────────────────────────────────────
|
|
769
|
+
if (preferences.slice_parallel !== undefined) {
|
|
770
|
+
if (typeof preferences.slice_parallel === "object" && preferences.slice_parallel !== null) {
|
|
771
|
+
const sp = preferences.slice_parallel;
|
|
772
|
+
const validSp = {};
|
|
773
|
+
if (sp.enabled !== undefined) {
|
|
774
|
+
if (typeof sp.enabled === "boolean")
|
|
775
|
+
validSp.enabled = sp.enabled;
|
|
776
|
+
else
|
|
777
|
+
errors.push("slice_parallel.enabled must be a boolean");
|
|
778
|
+
}
|
|
779
|
+
if (sp.max_workers !== undefined) {
|
|
780
|
+
const maxWorkers = typeof sp.max_workers === "number" ? sp.max_workers : Number(sp.max_workers);
|
|
781
|
+
if (Number.isFinite(maxWorkers) && maxWorkers >= 1 && maxWorkers <= 8) {
|
|
782
|
+
validSp.max_workers = Math.floor(maxWorkers);
|
|
783
|
+
}
|
|
784
|
+
else {
|
|
785
|
+
errors.push("slice_parallel.max_workers must be a number between 1 and 8");
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
const knownSliceParallelKeys = new Set(["enabled", "max_workers"]);
|
|
789
|
+
for (const key of Object.keys(sp)) {
|
|
790
|
+
if (!knownSliceParallelKeys.has(key)) {
|
|
791
|
+
warnings.push(`unknown slice_parallel key "${key}" — ignored`);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
if (Object.keys(validSp).length > 0) {
|
|
795
|
+
validated.slice_parallel = validSp;
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
else {
|
|
799
|
+
errors.push("slice_parallel must be an object");
|
|
800
|
+
}
|
|
801
|
+
}
|
|
719
802
|
// ─── Reactive Execution ─────────────────────────────────────────────────
|
|
720
803
|
if (preferences.reactive_execution !== undefined) {
|
|
721
804
|
if (typeof preferences.reactive_execution === "object" && preferences.reactive_execution !== null) {
|
|
@@ -26,12 +26,12 @@ export { resolveAllSkillReferences } from "./preferences-skills.js";
|
|
|
26
26
|
// These lived in preferences-skills.ts but imported loadEffectiveGSDPreferences
|
|
27
27
|
// back from this file, creating a circular dependency. Moved here since they
|
|
28
28
|
// are trivial wrappers over loadEffectiveGSDPreferences.
|
|
29
|
-
export function resolveSkillDiscoveryMode() {
|
|
30
|
-
const prefs = loadEffectiveGSDPreferences();
|
|
29
|
+
export function resolveSkillDiscoveryMode(basePath) {
|
|
30
|
+
const prefs = loadEffectiveGSDPreferences(basePath);
|
|
31
31
|
return prefs?.preferences.skill_discovery ?? "suggest";
|
|
32
32
|
}
|
|
33
|
-
export function resolveSkillStalenessDays() {
|
|
34
|
-
const prefs = loadEffectiveGSDPreferences();
|
|
33
|
+
export function resolveSkillStalenessDays(basePath) {
|
|
34
|
+
const prefs = loadEffectiveGSDPreferences(basePath);
|
|
35
35
|
return prefs?.preferences.skill_staleness_days ?? 60;
|
|
36
36
|
}
|
|
37
37
|
// ─── Re-exports: models ─────────────────────────────────────────────────────
|
|
@@ -46,16 +46,16 @@ function globalPreferencesPath() {
|
|
|
46
46
|
function legacyGlobalPreferencesPath() {
|
|
47
47
|
return join(homedir(), ".pi", "agent", "gsd-preferences.md");
|
|
48
48
|
}
|
|
49
|
-
function projectPreferencesPath() {
|
|
50
|
-
return join(gsdRoot(
|
|
49
|
+
function projectPreferencesPath(basePath = process.cwd()) {
|
|
50
|
+
return join(gsdRoot(basePath), "PREFERENCES.md");
|
|
51
51
|
}
|
|
52
52
|
// Legacy lowercase files can still exist in older projects. Keep them as a
|
|
53
53
|
// compatibility-only fallback, but route new reads/writes through PREFERENCES.md.
|
|
54
54
|
function legacyGlobalPreferencesPathLowercase() {
|
|
55
55
|
return join(gsdHome(), "preferences.md");
|
|
56
56
|
}
|
|
57
|
-
function legacyProjectPreferencesPathLowercase() {
|
|
58
|
-
return join(gsdRoot(
|
|
57
|
+
function legacyProjectPreferencesPathLowercase(basePath = process.cwd()) {
|
|
58
|
+
return join(gsdRoot(basePath), "preferences.md");
|
|
59
59
|
}
|
|
60
60
|
export function getGlobalGSDPreferencesPath() {
|
|
61
61
|
return globalPreferencesPath();
|
|
@@ -63,8 +63,8 @@ export function getGlobalGSDPreferencesPath() {
|
|
|
63
63
|
export function getLegacyGlobalGSDPreferencesPath() {
|
|
64
64
|
return legacyGlobalPreferencesPath();
|
|
65
65
|
}
|
|
66
|
-
export function getProjectGSDPreferencesPath() {
|
|
67
|
-
return projectPreferencesPath();
|
|
66
|
+
export function getProjectGSDPreferencesPath(basePath) {
|
|
67
|
+
return projectPreferencesPath(basePath);
|
|
68
68
|
}
|
|
69
69
|
// ─── Loading ────────────────────────────────────────────────────────────────
|
|
70
70
|
export function loadGlobalGSDPreferences() {
|
|
@@ -72,13 +72,13 @@ export function loadGlobalGSDPreferences() {
|
|
|
72
72
|
?? loadPreferencesFile(legacyGlobalPreferencesPathLowercase(), "global")
|
|
73
73
|
?? loadPreferencesFile(legacyGlobalPreferencesPath(), "global");
|
|
74
74
|
}
|
|
75
|
-
export function loadProjectGSDPreferences() {
|
|
76
|
-
return loadPreferencesFile(projectPreferencesPath(), "project")
|
|
77
|
-
?? loadPreferencesFile(legacyProjectPreferencesPathLowercase(), "project");
|
|
75
|
+
export function loadProjectGSDPreferences(basePath) {
|
|
76
|
+
return loadPreferencesFile(projectPreferencesPath(basePath), "project")
|
|
77
|
+
?? loadPreferencesFile(legacyProjectPreferencesPathLowercase(basePath), "project");
|
|
78
78
|
}
|
|
79
|
-
export function loadEffectiveGSDPreferences() {
|
|
79
|
+
export function loadEffectiveGSDPreferences(basePath) {
|
|
80
80
|
const globalPreferences = loadGlobalGSDPreferences();
|
|
81
|
-
const projectPreferences = loadProjectGSDPreferences();
|
|
81
|
+
const projectPreferences = loadProjectGSDPreferences(basePath);
|
|
82
82
|
if (!globalPreferences && !projectPreferences)
|
|
83
83
|
return null;
|
|
84
84
|
let result;
|
|
@@ -489,8 +489,8 @@ export function resolvePreDispatchHooks() {
|
|
|
489
489
|
* Worktree isolation requires explicit opt-in because it depends on git
|
|
490
490
|
* branch infrastructure that must be set up before use.
|
|
491
491
|
*/
|
|
492
|
-
export function getIsolationMode() {
|
|
493
|
-
const prefs = loadEffectiveGSDPreferences()?.preferences?.git;
|
|
492
|
+
export function getIsolationMode(basePath) {
|
|
493
|
+
const prefs = loadEffectiveGSDPreferences(basePath)?.preferences?.git;
|
|
494
494
|
if (prefs?.isolation === "worktree")
|
|
495
495
|
return "worktree";
|
|
496
496
|
if (prefs?.isolation === "branch")
|
|
@@ -162,6 +162,10 @@ Preserve the specification's exact terminology, emphasis, and specific framing.
|
|
|
162
162
|
6. For each architectural or pattern decision, call `gsd_decision_save` — the tool auto-assigns IDs and regenerates `.gsd/DECISIONS.md` automatically.
|
|
163
163
|
7. {{commitInstruction}}
|
|
164
164
|
|
|
165
|
+
### Ready-phrase pre-condition (NON-BYPASSABLE)
|
|
166
|
+
|
|
167
|
+
Before emitting the ready phrase, verify in the CURRENT turn that you have written `.gsd/PROJECT.md`, `.gsd/REQUIREMENTS.md`, `{{contextPath}}`, and called `gsd_plan_milestone`. If any is missing, **STOP** — emit the missing tool calls in this same turn. The system rejects premature ready signals and retries are capped.
|
|
168
|
+
|
|
165
169
|
After writing the files, say exactly: "Milestone {{milestoneId}} ready." — nothing else. Auto-mode will start automatically.
|
|
166
170
|
|
|
167
171
|
### Multi-Milestone
|
|
@@ -234,6 +238,10 @@ For single-milestone projects, do NOT write this file.
|
|
|
234
238
|
|
|
235
239
|
7. {{multiMilestoneCommitInstruction}}
|
|
236
240
|
|
|
241
|
+
### Ready-phrase pre-condition (NON-BYPASSABLE)
|
|
242
|
+
|
|
243
|
+
Before emitting the ready phrase, verify in the CURRENT turn that you have written `.gsd/PROJECT.md`, `.gsd/REQUIREMENTS.md`, the primary `CONTEXT.md`, called `gsd_plan_milestone` for the primary milestone, and written `.gsd/DISCUSSION-MANIFEST.json` with `gates_completed === total`. If any is missing, **STOP** — emit the missing tool calls in this same turn. The system rejects premature ready signals and retries are capped.
|
|
244
|
+
|
|
237
245
|
After writing the files, say exactly: "Milestone {{milestoneId}} ready." — nothing else. Auto-mode will start automatically.
|
|
238
246
|
|
|
239
247
|
## Critical Rules
|
|
@@ -339,7 +339,20 @@ These sections are in addition to whatever other context the discussion surfaced
|
|
|
339
339
|
6. For each architectural or pattern decision made during discussion, call `gsd_decision_save` — the tool auto-assigns IDs and regenerates `.gsd/DECISIONS.md` automatically.
|
|
340
340
|
7. {{commitInstruction}}
|
|
341
341
|
|
|
342
|
-
|
|
342
|
+
### Ready-phrase pre-condition (NON-BYPASSABLE)
|
|
343
|
+
|
|
344
|
+
Before emitting the ready phrase, verify in the CURRENT turn that you have:
|
|
345
|
+
|
|
346
|
+
- [ ] Written `.gsd/PROJECT.md` (step 2)
|
|
347
|
+
- [ ] Written `.gsd/REQUIREMENTS.md` (step 3)
|
|
348
|
+
- [ ] Written `{{contextPath}}` (step 4)
|
|
349
|
+
- [ ] Called `gsd_plan_milestone` (step 5)
|
|
350
|
+
|
|
351
|
+
If ANY box is unchecked, **STOP**. Do NOT emit the ready phrase. Emit the missing tool calls in this same turn. The system detects missing artifacts and will reject premature ready signals — you will be asked again and retries are capped.
|
|
352
|
+
|
|
353
|
+
Do not announce the ready phrase as something you are "about to" do. Do not narrate "now writing the files" as a substitute for actually writing them. The ready phrase is a post-write signal, not an intent signal.
|
|
354
|
+
|
|
355
|
+
After completing steps 1–7 above, say exactly: "Milestone {{milestoneId}} ready." — nothing else. Auto-mode will start automatically.
|
|
343
356
|
|
|
344
357
|
### Multi-Milestone
|
|
345
358
|
|
|
@@ -418,6 +431,20 @@ For single-milestone projects, do NOT write this file — it is only for multi-m
|
|
|
418
431
|
|
|
419
432
|
7. {{multiMilestoneCommitInstruction}}
|
|
420
433
|
|
|
421
|
-
|
|
434
|
+
### Ready-phrase pre-condition (NON-BYPASSABLE)
|
|
435
|
+
|
|
436
|
+
Before emitting the ready phrase, verify in the CURRENT turn that you have:
|
|
437
|
+
|
|
438
|
+
- [ ] Written `.gsd/PROJECT.md` (Phase 1)
|
|
439
|
+
- [ ] Written `.gsd/REQUIREMENTS.md` (Phase 1)
|
|
440
|
+
- [ ] Written primary-milestone `CONTEXT.md` (Phase 2)
|
|
441
|
+
- [ ] Called `gsd_plan_milestone` for the primary milestone (Phase 2)
|
|
442
|
+
- [ ] Written `.gsd/DISCUSSION-MANIFEST.json` with `gates_completed === total` (Phase 3)
|
|
443
|
+
|
|
444
|
+
If ANY box is unchecked, **STOP**. Do NOT emit the ready phrase. Emit the missing tool calls in this same turn. The system detects missing artifacts and will reject premature ready signals — you will be asked again and retries are capped.
|
|
445
|
+
|
|
446
|
+
Do not announce the ready phrase as something you are "about to" do. Do not narrate "now writing the files" as a substitute for actually writing them. The ready phrase is a post-write signal, not an intent signal.
|
|
447
|
+
|
|
448
|
+
After completing all phases above, say exactly: "Milestone M001 ready." — nothing else. Auto-mode will start automatically.
|
|
422
449
|
|
|
423
450
|
{{inlinedTemplates}}
|