gsd-pi 2.74.0-dev.ffbcc03 → 2.75.0-dev.063e5a3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/dist/resources/extensions/gsd/auto/phases.js +51 -6
  2. package/dist/resources/extensions/gsd/auto-model-selection.js +3 -3
  3. package/dist/resources/extensions/gsd/auto-worktree.js +2 -0
  4. package/dist/resources/extensions/gsd/bootstrap/provider-error-resume.js +5 -3
  5. package/dist/resources/extensions/gsd/commands/catalog.js +6 -1
  6. package/dist/resources/extensions/gsd/commands/handlers/core.js +5 -1
  7. package/dist/resources/extensions/gsd/commands-prefs-wizard.js +50 -3
  8. package/dist/resources/extensions/gsd/docs/preferences-reference.md +2 -0
  9. package/dist/resources/extensions/gsd/guided-flow.js +7 -5
  10. package/dist/resources/extensions/gsd/preferences-types.js +1 -0
  11. package/dist/resources/extensions/gsd/preferences-validation.js +10 -0
  12. package/dist/resources/extensions/gsd/preferences.js +5 -0
  13. package/dist/resources/extensions/gsd/templates/PREFERENCES.md +1 -0
  14. package/dist/tsconfig.extensions.tsbuildinfo +1 -1
  15. package/dist/web/standalone/.next/BUILD_ID +1 -1
  16. package/dist/web/standalone/.next/app-path-routes-manifest.json +6 -6
  17. package/dist/web/standalone/.next/build-manifest.json +2 -2
  18. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  19. package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
  20. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  21. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  22. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  23. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  24. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  25. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  26. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  27. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  28. package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
  29. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  30. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  31. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  32. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  33. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  34. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  35. package/dist/web/standalone/.next/server/app/index.html +1 -1
  36. package/dist/web/standalone/.next/server/app/index.rsc +1 -1
  37. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  38. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
  39. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  40. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
  41. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  42. package/dist/web/standalone/.next/server/app-paths-manifest.json +6 -6
  43. package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
  44. package/dist/web/standalone/.next/server/middleware-manifest.json +5 -5
  45. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  46. package/dist/web/standalone/.next/server/pages/500.html +1 -1
  47. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  48. package/package.json +1 -1
  49. package/packages/daemon/package.json +2 -2
  50. package/packages/mcp-server/package.json +2 -2
  51. package/packages/native/package.json +1 -1
  52. package/packages/pi-agent-core/package.json +1 -1
  53. package/packages/pi-ai/package.json +1 -1
  54. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.d.ts +2 -0
  55. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.d.ts.map +1 -0
  56. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.js +61 -0
  57. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.js.map +1 -0
  58. package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.d.ts +1 -1
  59. package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.d.ts.map +1 -1
  60. package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.js +9 -3
  61. package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.js.map +1 -1
  62. package/packages/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.d.ts +8 -5
  63. package/packages/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  64. package/packages/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.js +27 -13
  65. package/packages/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  66. package/packages/pi-coding-agent/package.json +1 -1
  67. package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.ts +92 -0
  68. package/packages/pi-coding-agent/src/modes/interactive/components/chat-frame.ts +12 -4
  69. package/packages/pi-coding-agent/src/modes/interactive/components/compaction-summary-message.ts +36 -15
  70. package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
  71. package/packages/pi-tui/dist/tui.d.ts.map +1 -1
  72. package/packages/pi-tui/dist/tui.js +9 -2
  73. package/packages/pi-tui/dist/tui.js.map +1 -1
  74. package/packages/pi-tui/package.json +1 -1
  75. package/packages/pi-tui/src/tui.ts +9 -1
  76. package/packages/pi-tui/tsconfig.tsbuildinfo +1 -1
  77. package/packages/rpc-client/package.json +1 -1
  78. package/pkg/package.json +1 -1
  79. package/src/resources/extensions/gsd/auto/phases.ts +70 -6
  80. package/src/resources/extensions/gsd/auto-model-selection.ts +3 -3
  81. package/src/resources/extensions/gsd/auto-worktree.ts +1 -0
  82. package/src/resources/extensions/gsd/bootstrap/provider-error-resume.ts +5 -3
  83. package/src/resources/extensions/gsd/commands/catalog.ts +6 -1
  84. package/src/resources/extensions/gsd/commands/handlers/core.ts +5 -1
  85. package/src/resources/extensions/gsd/commands-prefs-wizard.ts +57 -3
  86. package/src/resources/extensions/gsd/docs/preferences-reference.md +2 -0
  87. package/src/resources/extensions/gsd/guided-flow.ts +3 -1
  88. package/src/resources/extensions/gsd/preferences-types.ts +6 -0
  89. package/src/resources/extensions/gsd/preferences-validation.ts +10 -0
  90. package/src/resources/extensions/gsd/preferences.ts +6 -0
  91. package/src/resources/extensions/gsd/templates/PREFERENCES.md +1 -0
  92. package/src/resources/extensions/gsd/tests/auto-warning-noise-regression.test.ts +117 -0
  93. package/src/resources/extensions/gsd/tests/journal-integration.test.ts +3 -3
  94. package/src/resources/extensions/gsd/tests/preferences.test.ts +145 -0
  95. package/src/resources/extensions/gsd/tests/provider-errors.test.ts +57 -2
  96. /package/dist/web/standalone/.next/static/{kn6xzWKYnogsxp2b6RpDD → j7IBD35UgrL2b298GLK3V}/_buildManifest.js +0 -0
  97. /package/dist/web/standalone/.next/static/{kn6xzWKYnogsxp2b6RpDD → j7IBD35UgrL2b298GLK3V}/_ssgManifest.js +0 -0
@@ -14,6 +14,8 @@ import { debugLog } from "../debug-logger.js";
14
14
  import { PROJECT_FILES } from "../detection.js";
15
15
  import { MergeConflictError } from "../git-service.js";
16
16
  import { setCurrentPhase, clearCurrentPhase } from "../../shared/gsd-phase-state.js";
17
+ import { pauseAutoForProviderError } from "../provider-error-pause.js";
18
+ import { resumeAutoAfterProviderDelay } from "../bootstrap/provider-error-resume.js";
17
19
  import { join, basename, dirname, parse as parsePath } from "node:path";
18
20
  import { existsSync, cpSync, readdirSync } from "node:fs";
19
21
  import { logWarning, logError, _resetLogs, drainLogs, drainAndSummarize, formatForNotification, hasAnyIssues, } from "../workflow-logger.js";
@@ -32,6 +34,12 @@ import { resetEvidence } from "../safety/evidence-collector.js";
32
34
  import { createCheckpoint, cleanupCheckpoint, rollbackToCheckpoint } from "../safety/git-checkpoint.js";
33
35
  import { resolveSafetyHarnessConfig } from "../safety/safety-harness.js";
34
36
  import { getWorkflowTransportSupportError, getRequiredWorkflowToolsForAutoUnit, } from "../workflow-mcp.js";
37
+ // ─── Session timeout auto-resume state ────────────────────────────────────────
38
+ let consecutiveSessionTimeouts = 0;
39
+ const MAX_SESSION_TIMEOUT_AUTO_RESUMES = 3;
40
+ export function resetSessionTimeoutState() {
41
+ consecutiveSessionTimeouts = 0;
42
+ }
35
43
  // ─── generateMilestoneReport ──────────────────────────────────────────────────
36
44
  /**
37
45
  * Resolve the base path for milestone reports.
@@ -1105,19 +1113,54 @@ export async function runUnitPhase(ic, iterData, loopState, sidecarItem) {
1105
1113
  debugLog("autoLoop", { phase: "exit", reason: "provider-pause", isTransient: unitResult.errorContext.isTransient });
1106
1114
  return { action: "break", reason: "provider-pause" };
1107
1115
  }
1108
- // Session creation timeout (not a structural error): pause auto-mode
1109
- // and let the provider-error-resume timer handle recovery (#3767). This
1110
- // matches the provider-pause pathbreak out cleanly, don't hard-stop.
1116
+ // Timeout category covers two distinct scenarios:
1117
+ // 1. Session creation timeout (120s) transient, auto-resume with backoff
1118
+ // 2. Unit hard timeout (30min+)stuck agent, pause for manual review
1111
1119
  // Structural errors (TypeError, is not a function) are NOT transient
1112
1120
  // and must hard-stop to avoid infinite retry loops.
1113
1121
  if (unitResult.errorContext?.isTransient &&
1114
1122
  unitResult.errorContext?.category === "timeout") {
1115
- ctx.ui.notify(`Session creation timed out for ${unitType} ${unitId}. Pausing auto-mode (recoverable).`, "warning");
1116
- debugLog("autoLoop", { phase: "session-timeout-pause", unitType, unitId });
1123
+ const isSessionCreationTimeout = unitResult.errorContext.message?.includes("Session creation timed out");
1124
+ if (isSessionCreationTimeout) {
1125
+ consecutiveSessionTimeouts += 1;
1126
+ const baseRetryAfterMs = 30_000;
1127
+ const retryAfterMs = baseRetryAfterMs * 2 ** Math.max(0, consecutiveSessionTimeouts - 1);
1128
+ const allowAutoResume = consecutiveSessionTimeouts <= MAX_SESSION_TIMEOUT_AUTO_RESUMES;
1129
+ if (!allowAutoResume) {
1130
+ ctx.ui.notify(`Session creation timed out ${consecutiveSessionTimeouts} consecutive times for ${unitType} ${unitId}. Pausing for manual review.`, "warning");
1131
+ }
1132
+ debugLog("autoLoop", {
1133
+ phase: "session-timeout-pause",
1134
+ unitType, unitId,
1135
+ consecutiveSessionTimeouts,
1136
+ retryAfterMs,
1137
+ allowAutoResume,
1138
+ });
1139
+ const errorDetail = ` for ${unitType} ${unitId}`;
1140
+ await pauseAutoForProviderError(ctx.ui, errorDetail, () => deps.pauseAuto(ctx, pi), {
1141
+ isRateLimit: false,
1142
+ isTransient: allowAutoResume,
1143
+ retryAfterMs,
1144
+ resume: allowAutoResume
1145
+ ? () => {
1146
+ void resumeAutoAfterProviderDelay(pi, ctx).catch((err) => {
1147
+ const message = err instanceof Error ? err.message : String(err);
1148
+ ctx.ui.notify(`Session timeout recovery failed: ${message}`, "error");
1149
+ });
1150
+ }
1151
+ : undefined,
1152
+ });
1153
+ await deps.autoCommitUnit?.(s.basePath, unitType, unitId, ctx);
1154
+ await emitCancelledUnitEnd(ic, unitType, unitId, unitStartSeq, unitResult.errorContext);
1155
+ return { action: "break", reason: "session-timeout" };
1156
+ }
1157
+ // Unit hard timeout (30min+): pause without auto-resume — stuck agent
1158
+ ctx.ui.notify(`Unit timed out for ${unitType} ${unitId} (supervision may have failed). Pausing auto-mode.`, "warning");
1159
+ debugLog("autoLoop", { phase: "unit-hard-timeout-pause", unitType, unitId });
1117
1160
  await deps.pauseAuto(ctx, pi);
1118
1161
  await deps.autoCommitUnit?.(s.basePath, unitType, unitId, ctx);
1119
1162
  await emitCancelledUnitEnd(ic, unitType, unitId, unitStartSeq, unitResult.errorContext);
1120
- return { action: "break", reason: "session-timeout" };
1163
+ return { action: "break", reason: "unit-hard-timeout" };
1121
1164
  }
1122
1165
  // All other cancelled states (structural errors, non-transient failures): hard stop
1123
1166
  if (s.currentUnit) {
@@ -1136,6 +1179,8 @@ export async function runUnitPhase(ic, iterData, loopState, sidecarItem) {
1136
1179
  // Guard: stopAuto() may have nulled s.currentUnit via s.reset() while
1137
1180
  // this coroutine was suspended at `await runUnit(...)` (#2939).
1138
1181
  if (s.currentUnit) {
1182
+ // Reset session timeout counter — any successful unit clears the slate
1183
+ consecutiveSessionTimeouts = 0;
1139
1184
  await deps.closeoutUnit(ctx, s.basePath, unitType, unitId, s.currentUnit.startedAt, deps.buildSnapshotOpts(unitType, unitId));
1140
1185
  }
1141
1186
  // ── Zero tool-call guard (#1833, #2653) ──────────────────────────
@@ -405,10 +405,10 @@ export function isFlatRateProvider(provider, opts) {
405
405
  */
406
406
  export function buildFlatRateContext(provider, ctx, prefs) {
407
407
  let authMode;
408
- const getAuthMode = ctx?.modelRegistry?.getProviderAuthMode;
409
- if (typeof getAuthMode === "function") {
408
+ const registry = ctx?.modelRegistry;
409
+ if (registry && typeof registry.getProviderAuthMode === "function") {
410
410
  try {
411
- const mode = getAuthMode(provider);
411
+ const mode = registry.getProviderAuthMode(provider);
412
412
  if (mode === "apiKey" || mode === "oauth" || mode === "externalCli" || mode === "none") {
413
413
  authMode = mode;
414
414
  }
@@ -54,6 +54,8 @@ function isSamePath(a, b) {
54
54
  return realpathSync(a) === realpathSync(b);
55
55
  }
56
56
  catch (e) {
57
+ if (e.code === "ENOENT")
58
+ return false;
57
59
  logWarning("worktree", `isSamePath failed: ${e.message}`);
58
60
  return false;
59
61
  }
@@ -1,5 +1,6 @@
1
1
  import { getAutoDashboardData, startAuto } from "../auto.js";
2
2
  import { resetTransientRetryState } from "./agent-end-recovery.js";
3
+ import { resetSessionTimeoutState } from "../auto/phases.js";
3
4
  const defaultDeps = {
4
5
  getSnapshot: () => getAutoDashboardData(),
5
6
  startAuto,
@@ -14,10 +15,11 @@ export async function resumeAutoAfterProviderDelay(pi, ctx, deps = defaultDeps)
14
15
  ctx.ui.notify("Provider error recovery delay elapsed, but no paused auto-mode base path was available. Leaving auto-mode paused.", "warning");
15
16
  return "missing-base";
16
17
  }
17
- // Reset the transient retry counter before restarting — without this,
18
- // consecutiveTransientCount accumulates across pause/resume cycles and
19
- // permanently locks out auto-resume after MAX_TRANSIENT_AUTO_RESUMES errors.
18
+ // Reset retry counters before restarting — without this, counters
19
+ // accumulate across pause/resume cycles and permanently lock out
20
+ // auto-resume after their respective MAX thresholds.
20
21
  resetTransientRetryState();
22
+ resetSessionTimeoutState();
21
23
  await deps.startAuto(ctx, pi, snapshot.basePath, false, { step: snapshot.stepMode });
22
24
  return "resumed";
23
25
  }
@@ -4,7 +4,7 @@ import { join } from "node:path";
4
4
  import { loadRegistry } from "../workflow-templates.js";
5
5
  import { resolveProjectRoot } from "../worktree.js";
6
6
  const gsdHome = process.env.GSD_HOME || join(homedir(), ".gsd");
7
- export const GSD_COMMAND_DESCRIPTION = "GSD — Get Shit Done: /gsd help|start|templates|next|auto|stop|pause|status|widget|visualize|queue|quick|discuss|capture|triage|dispatch|history|undo|undo-task|reset-slice|rate|skip|export|cleanup|model|mode|prefs|config|keys|hooks|run-hook|skill-health|doctor|logs|forensics|changelog|migrate|remote|steer|knowledge|new-milestone|parallel|cmux|park|unpark|init|setup|inspect|extensions|update|fast|mcp|rethink|codebase|notifications|ship|do|session-report|backlog|pr-branch|add-tests";
7
+ export const GSD_COMMAND_DESCRIPTION = "GSD — Get Shit Done: /gsd help|start|templates|next|auto|stop|pause|status|widget|visualize|queue|quick|discuss|capture|triage|dispatch|history|undo|undo-task|reset-slice|rate|skip|export|cleanup|model|mode|prefs|config|keys|hooks|run-hook|skill-health|doctor|logs|forensics|changelog|migrate|remote|steer|knowledge|new-milestone|parallel|cmux|park|unpark|init|setup|inspect|extensions|update|fast|mcp|rethink|codebase|notifications|ship|do|session-report|backlog|pr-branch|add-tests|language";
8
8
  export const TOP_LEVEL_SUBCOMMANDS = [
9
9
  { cmd: "help", desc: "Categorized command reference with descriptions" },
10
10
  { cmd: "next", desc: "Explicit step mode (same as /gsd)" },
@@ -68,6 +68,7 @@ export const TOP_LEVEL_SUBCOMMANDS = [
68
68
  { cmd: "backlog", desc: "Manage backlog items (add, promote, remove, list)" },
69
69
  { cmd: "pr-branch", desc: "Create clean PR branch filtering .gsd/ commits" },
70
70
  { cmd: "add-tests", desc: "Generate tests for completed slices" },
71
+ { cmd: "language", desc: "Set or clear the global response language (e.g. /gsd language Chinese)" },
71
72
  ];
72
73
  const NESTED_COMPLETIONS = {
73
74
  auto: [
@@ -256,6 +257,10 @@ const NESTED_COMPLETIONS = {
256
257
  { cmd: "--dry-run", desc: "Preview what would be filtered" },
257
258
  { cmd: "--name", desc: "Custom branch name" },
258
259
  ],
260
+ language: [
261
+ { cmd: "off", desc: "Clear the language preference (revert to default)" },
262
+ { cmd: "clear", desc: "Alias for off — clear the language preference" },
263
+ ],
259
264
  };
260
265
  function filterOptions(partial, options, prefix = "") {
261
266
  const normalizedPrefix = prefix ? `${prefix} ` : "";
@@ -1,6 +1,6 @@
1
1
  import { computeProgressScore, formatProgressLine } from "../../progress-score.js";
2
2
  import { getGlobalGSDPreferencesPath, getProjectGSDPreferencesPath } from "../../preferences.js";
3
- import { ensurePreferencesFile, handlePrefs, handlePrefsMode, handlePrefsWizard } from "../../commands-prefs-wizard.js";
3
+ import { ensurePreferencesFile, handlePrefs, handlePrefsMode, handlePrefsWizard, handleLanguage } from "../../commands-prefs-wizard.js";
4
4
  import { runEnvironmentChecks } from "../../doctor-environment.js";
5
5
  import { deriveState } from "../../state.js";
6
6
  import { handleCmux } from "../../commands-cmux.js";
@@ -339,6 +339,10 @@ export async function handleCoreCommand(trimmed, ctx, pi) {
339
339
  await handlePrefs(trimmed.replace(/^prefs\s*/, "").trim(), ctx);
340
340
  return true;
341
341
  }
342
+ if (trimmed === "language" || trimmed.startsWith("language ")) {
343
+ await handleLanguage(trimmed.replace(/^language\s*/, "").trim(), ctx);
344
+ return true;
345
+ }
342
346
  if (trimmed === "cmux" || trimmed.startsWith("cmux ")) {
343
347
  await handleCmux(trimmed.replace(/^cmux\s*/, "").trim(), ctx);
344
348
  return true;
@@ -642,8 +642,8 @@ export async function handlePrefsWizard(ctx, scope) {
642
642
  export function yamlSafeString(val) {
643
643
  if (typeof val !== "string")
644
644
  return String(val);
645
- if (/[:#{\[\]'"`,|>&*!?@%]/.test(val) || val.trim() !== val || val === "") {
646
- return `"${val.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
645
+ if (/[:#{\[\]'"`,|>&*!?@%\r\n]/.test(val) || val.trim() !== val || val === "") {
646
+ return `"${val.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\r/g, "\\r").replace(/\n/g, "\\n")}"`;
647
647
  }
648
648
  return val;
649
649
  }
@@ -708,7 +708,7 @@ export function serializePreferencesToFrontmatter(prefs) {
708
708
  "dynamic_routing", "uok", "token_profile", "phases", "parallel",
709
709
  "auto_visualize", "auto_report",
710
710
  "verification_commands", "verification_auto_fix", "verification_max_retries",
711
- "search_provider", "context_selection",
711
+ "search_provider", "context_selection", "language",
712
712
  ];
713
713
  const seen = new Set();
714
714
  for (const key of orderedKeys) {
@@ -739,3 +739,50 @@ export async function ensurePreferencesFile(path, ctx, scope) {
739
739
  ctx.ui.notify(`Using existing ${scope} GSD skill preferences at ${path}`, "info");
740
740
  }
741
741
  }
742
+ /**
743
+ * Handle `/gsd language [code]` — set or clear the global language preference.
744
+ * Without an argument, shows the current setting.
745
+ * Project-level override can be set by editing `.gsd/preferences.md` directly
746
+ * (project language overrides global when both are set).
747
+ */
748
+ export async function handleLanguage(args, ctx) {
749
+ const path = getGlobalGSDPreferencesPath();
750
+ const lang = args.trim();
751
+ // Show current setting when called without argument
752
+ if (!lang) {
753
+ const loaded = loadGlobalGSDPreferences();
754
+ const current = loaded?.preferences.language;
755
+ if (current) {
756
+ ctx.ui.notify(`Current language preference: ${current}\nUse /gsd language <name> to change, or /gsd language off to clear.`, "info");
757
+ }
758
+ else {
759
+ ctx.ui.notify("No language preference set. Use /gsd language <name> to set one (e.g. /gsd language Chinese).", "info");
760
+ }
761
+ return;
762
+ }
763
+ // Ensure preferences file exists with the canonical template
764
+ await ensurePreferencesFile(path, ctx, "global");
765
+ // Read via the same validated path as other handlers
766
+ const existing = loadGlobalGSDPreferences();
767
+ const prefs = existing?.preferences ? { ...existing.preferences } : { version: 1 };
768
+ if (lang === "off" || lang === "none" || lang === "clear") {
769
+ delete prefs.language;
770
+ ctx.ui.notify("Language preference cleared. GSD will use the default language.", "info");
771
+ }
772
+ else {
773
+ // Validate before writing — reject values that would fail on next load
774
+ if (lang.length > 50 || /[\r\n]/.test(lang)) {
775
+ ctx.ui.notify("Language value must be 50 characters or fewer with no newlines (e.g. /gsd language Chinese).", "warning");
776
+ return;
777
+ }
778
+ prefs.language = lang;
779
+ ctx.ui.notify(`Language preference set to: ${lang}\nGSD will now respond in ${lang} across all sessions.`, "info");
780
+ }
781
+ const rawContent = existsSync(path) ? readFileSync(path, "utf-8") : `---\nversion: 1\n---\n`;
782
+ const frontmatter = serializePreferencesToFrontmatter(prefs);
783
+ const body = extractBodyAfterFrontmatter(rawContent)
784
+ ?? "\n# GSD Skill Preferences\n\nSee `~/.gsd/agent/extensions/gsd/docs/preferences-reference.md` for full field documentation and examples.\n";
785
+ await saveFile(path, `---\n${frontmatter}---${body}`);
786
+ await ctx.waitForIdle();
787
+ await ctx.reload();
788
+ }
@@ -102,6 +102,8 @@ Setting `prefer_skills: []` does **not** disable skill discovery — it just mea
102
102
 
103
103
  - `custom_instructions`: extra durable instructions related to skill use. For operational project knowledge (recurring rules, gotchas, patterns), use `.gsd/KNOWLEDGE.md` instead — it's injected into every agent prompt automatically and agents can append to it during execution.
104
104
 
105
+ - `language`: preferred response language for all GSD interactions. Accepts any language name or code — `"Chinese"`, `"zh"`, `"German"`, `"de"`, `"日本語"`, etc. When set, GSD injects "Always respond in \<language\>" into every agent's system prompt, including after `/clear`. Quickest way to set it: `/gsd language <name>`. To clear: `/gsd language off`.
106
+
105
107
  - `models`: per-stage model selection (applies to both auto-mode and guided-flow dispatches). Keys: `research`, `planning`, `discuss`, `execution`, `execution_simple`, `completion`, `validation`, `subagent`. Values can be:
106
108
  - Simple string: `"claude-sonnet-4-6"` — single model, no fallbacks
107
109
  - Provider-qualified string: `"bedrock/claude-sonnet-4-6"` — targets a specific provider when the same model ID exists across multiple providers
@@ -212,11 +212,13 @@ export function checkAutoStartAfterDiscuss() {
212
212
  logWarning("guided", `CONTEXT-DRAFT.md unlink failed: ${e.message}`);
213
213
  }
214
214
  // Cleanup: remove discussion manifest after auto-start (only needed during discussion)
215
- try {
216
- unlinkSync(manifestPath);
217
- }
218
- catch (e) {
219
- logWarning("guided", `manifest unlink failed: ${e.message}`);
215
+ if (existsSync(manifestPath)) {
216
+ try {
217
+ unlinkSync(manifestPath);
218
+ }
219
+ catch (e) {
220
+ logWarning("guided", `manifest unlink failed: ${e.message}`);
221
+ }
220
222
  }
221
223
  pendingAutoStartMap.delete(basePath);
222
224
  ctx.ui.notify(`Milestone ${milestoneId} ready.`, "success");
@@ -85,6 +85,7 @@ export const KNOWN_PREFERENCE_KEYS = new Set([
85
85
  "discuss_web_research",
86
86
  "discuss_depth",
87
87
  "flat_rate_providers",
88
+ "language",
88
89
  ]);
89
90
  /** Canonical list of all dispatch unit types. */
90
91
  export const KNOWN_UNIT_TYPES = [
@@ -1144,5 +1144,15 @@ export function validatePreferences(preferences) {
1144
1144
  errors.push(`discuss_depth must be one of: quick, standard, thorough`);
1145
1145
  }
1146
1146
  }
1147
+ // ─── Language ────────────────────────────────────────────────────────
1148
+ if (preferences.language !== undefined) {
1149
+ const trimmed = typeof preferences.language === "string" ? preferences.language.trim() : undefined;
1150
+ if (trimmed && trimmed.length <= 50 && !/[\r\n]/.test(trimmed)) {
1151
+ validated.language = trimmed;
1152
+ }
1153
+ else {
1154
+ errors.push(`language must be a non-empty string up to 50 characters with no newlines (e.g. "Chinese", "de", "日本語")`);
1155
+ }
1156
+ }
1147
1157
  return { preferences: validated, errors, warnings };
1148
1158
  }
@@ -360,6 +360,7 @@ function mergePreferences(base, override) {
360
360
  slice_parallel: (base.slice_parallel || override.slice_parallel)
361
361
  ? { ...(base.slice_parallel ?? {}), ...(override.slice_parallel ?? {}) }
362
362
  : undefined,
363
+ language: override.language ?? base.language,
363
364
  };
364
365
  }
365
366
  function mergeStringLists(base, override) {
@@ -454,6 +455,10 @@ export function renderPreferencesForSystemPrompt(preferences, resolutions) {
454
455
  lines.push(` - ${instruction}`);
455
456
  }
456
457
  }
458
+ if (preferences.language) {
459
+ const safeLang = preferences.language.replace(/[\r\n]/g, " ").slice(0, 50);
460
+ lines.push(`- Language: Always respond in ${safeLang}.`);
461
+ }
457
462
  return lines.join("\n");
458
463
  }
459
464
  // ─── Hook Resolution ──────────────────────────────────────────────────────────
@@ -89,6 +89,7 @@ remote_questions:
89
89
  uat_dispatch:
90
90
  post_unit_hooks: []
91
91
  pre_dispatch_hooks: []
92
+ # language:
92
93
  # experimental:
93
94
  # rtk: false
94
95
  ---