@sayknow-cli/coding-agent 0.3.1 → 0.3.2

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 (170) hide show
  1. package/bin/skc.js +4 -0
  2. package/dist/types/cli/mcp-cli.d.ts +25 -0
  3. package/dist/types/cli/plugin-cli.d.ts +2 -0
  4. package/dist/types/cli.d.ts +6 -0
  5. package/dist/types/commands/mcp.d.ts +70 -0
  6. package/dist/types/commands/plugin.d.ts +6 -0
  7. package/dist/types/commands/session.d.ts +6 -0
  8. package/dist/types/config/keybindings.d.ts +2 -2
  9. package/dist/types/config/model-profile-activation.d.ts +8 -1
  10. package/dist/types/config/settings-schema.d.ts +1 -59
  11. package/dist/types/deep-interview/plaintext-gate-guard.d.ts +11 -0
  12. package/dist/types/extensibility/skc-plugins/compiler.d.ts +19 -0
  13. package/dist/types/extensibility/skc-plugins/constrained-hooks.d.ts +29 -0
  14. package/dist/types/extensibility/skc-plugins/index.d.ts +9 -0
  15. package/dist/types/extensibility/skc-plugins/injection.d.ts +9 -0
  16. package/dist/types/extensibility/skc-plugins/installer.d.ts +13 -0
  17. package/dist/types/extensibility/skc-plugins/mcp-policy.d.ts +26 -0
  18. package/dist/types/extensibility/skc-plugins/observability.d.ts +27 -0
  19. package/dist/types/extensibility/skc-plugins/prompt-appendix.d.ts +16 -0
  20. package/dist/types/extensibility/skc-plugins/registry.d.ts +32 -0
  21. package/dist/types/extensibility/skc-plugins/runtime-adapters.d.ts +64 -0
  22. package/dist/types/extensibility/skc-plugins/session-validation.d.ts +42 -0
  23. package/dist/types/extensibility/skc-plugins/types.d.ts +158 -2
  24. package/dist/types/extensibility/skc-plugins/validation.d.ts +8 -1
  25. package/dist/types/i18n/messages/en.d.ts +0 -1
  26. package/dist/types/main.d.ts +2 -0
  27. package/dist/types/modes/components/custom-editor.d.ts +1 -1
  28. package/dist/types/modes/components/model-selector.d.ts +8 -0
  29. package/dist/types/modes/components/settings-defs.d.ts +0 -1
  30. package/dist/types/modes/components/status-line/git-utils.d.ts +6 -0
  31. package/dist/types/modes/theme/defaults/index.d.ts +99 -0
  32. package/dist/types/modes/theme/theme.d.ts +1 -1
  33. package/dist/types/notifications/html-format.d.ts +11 -0
  34. package/dist/types/notifications/index.d.ts +149 -1
  35. package/dist/types/notifications/lifecycle-commands.d.ts +60 -0
  36. package/dist/types/notifications/lifecycle-control-runtime.d.ts +98 -0
  37. package/dist/types/notifications/lifecycle-orchestrator.d.ts +144 -0
  38. package/dist/types/notifications/operator-runtime.d.ts +52 -0
  39. package/dist/types/notifications/rate-limit-pool.d.ts +2 -0
  40. package/dist/types/notifications/recent-activity.d.ts +35 -0
  41. package/dist/types/notifications/telegram-daemon.d.ts +114 -16
  42. package/dist/types/notifications/telegram-reference.d.ts +3 -1
  43. package/dist/types/notifications/topic-registry.d.ts +12 -9
  44. package/dist/types/runtime-mcp/types.d.ts +7 -0
  45. package/dist/types/sdk.d.ts +2 -0
  46. package/dist/types/session/agent-session.d.ts +14 -4
  47. package/dist/types/session/blob-store.d.ts +25 -0
  48. package/dist/types/session/session-manager.d.ts +57 -0
  49. package/dist/types/skc-runtime/launch-tmux.d.ts +1 -0
  50. package/dist/types/skc-runtime/psmux-detect.d.ts +78 -0
  51. package/dist/types/skc-runtime/team-runtime.d.ts +2 -0
  52. package/dist/types/skc-runtime/tmux-common.d.ts +30 -2
  53. package/dist/types/skc-runtime/tmux-sessions.d.ts +18 -0
  54. package/dist/types/slash-commands/helpers/fast-status-report.d.ts +6 -0
  55. package/dist/types/system-prompt.d.ts +2 -0
  56. package/dist/types/task/executor.d.ts +9 -1
  57. package/dist/types/tools/composer-bash-policy.d.ts +14 -0
  58. package/dist/types/tools/index.d.ts +3 -1
  59. package/dist/types/utils/changelog.d.ts +1 -0
  60. package/dist/types/web/insane/url-guard.d.ts +6 -3
  61. package/dist/types/web/scrapers/types.d.ts +5 -0
  62. package/dist/types/web/scrapers/utils.d.ts +7 -1
  63. package/package.json +11 -9
  64. package/scripts/g004-tmux-smoke.ts +100 -0
  65. package/scripts/g005-daemon-smoke.ts +180 -0
  66. package/scripts/g011-daemon-path-smoke.ts +153 -0
  67. package/src/cli/fast-help.ts +29 -1
  68. package/src/cli/mcp-cli.ts +272 -0
  69. package/src/cli/plugin-cli.ts +66 -3
  70. package/src/cli.ts +30 -12
  71. package/src/commands/mcp.ts +117 -0
  72. package/src/commands/plugin.ts +4 -0
  73. package/src/commands/session.ts +18 -0
  74. package/src/config/keybindings.ts +2 -2
  75. package/src/config/model-profile-activation.ts +55 -7
  76. package/src/config/settings-schema.ts +8 -93
  77. package/src/deep-interview/plaintext-gate-guard.ts +94 -0
  78. package/src/defaults/skc/extensions/grok-cli-vendor/biome.json +1 -1
  79. package/src/defaults/skc/skills/deep-interview/SKILL.md +7 -6
  80. package/src/defaults/skc/skills/team/SKILL.md +5 -3
  81. package/src/defaults/skc/skills/ultragoal/SKILL.md +41 -13
  82. package/src/export/html/index.ts +2 -2
  83. package/src/extensibility/extensions/runner.ts +1 -0
  84. package/src/extensibility/skc-plugins/compiler.ts +351 -0
  85. package/src/extensibility/skc-plugins/constrained-hooks.ts +170 -0
  86. package/src/extensibility/skc-plugins/index.ts +9 -0
  87. package/src/extensibility/skc-plugins/injection.ts +109 -0
  88. package/src/extensibility/skc-plugins/installer.ts +434 -0
  89. package/src/extensibility/skc-plugins/loader.ts +3 -1
  90. package/src/extensibility/skc-plugins/mcp-policy.ts +239 -0
  91. package/src/extensibility/skc-plugins/observability.ts +84 -0
  92. package/src/extensibility/skc-plugins/paths.ts +1 -1
  93. package/src/extensibility/skc-plugins/prompt-appendix.ts +109 -0
  94. package/src/extensibility/skc-plugins/registry.ts +180 -0
  95. package/src/extensibility/skc-plugins/runtime-adapters.ts +234 -0
  96. package/src/extensibility/skc-plugins/schema.ts +250 -20
  97. package/src/extensibility/skc-plugins/session-validation.ts +147 -0
  98. package/src/extensibility/skc-plugins/types.ts +199 -3
  99. package/src/extensibility/skc-plugins/validation.ts +80 -0
  100. package/src/extensibility/skills.ts +15 -0
  101. package/src/hooks/skill-state.ts +57 -0
  102. package/src/i18n/messages/de.ts +0 -1
  103. package/src/i18n/messages/en.ts +0 -1
  104. package/src/i18n/messages/es.ts +0 -1
  105. package/src/i18n/messages/fr.ts +0 -1
  106. package/src/i18n/messages/ja.ts +0 -1
  107. package/src/i18n/messages/ko.ts +0 -1
  108. package/src/i18n/messages/zh.ts +0 -1
  109. package/src/internal-urls/docs-index.generated.ts +12 -8
  110. package/src/main.ts +14 -3
  111. package/src/modes/bridge/bridge-mode.ts +11 -0
  112. package/src/modes/components/assistant-message.ts +49 -1
  113. package/src/modes/components/custom-editor.ts +2 -0
  114. package/src/modes/components/footer.ts +2 -3
  115. package/src/modes/components/hook-editor.ts +1 -1
  116. package/src/modes/components/hook-selector.ts +67 -43
  117. package/src/modes/components/model-selector.ts +56 -11
  118. package/src/modes/components/settings-defs.ts +1 -2
  119. package/src/modes/components/settings-selector.ts +2 -7
  120. package/src/modes/components/status-line/git-utils.ts +25 -0
  121. package/src/modes/components/status-line.ts +10 -11
  122. package/src/modes/components/welcome.ts +2 -3
  123. package/src/modes/controllers/extension-ui-controller.ts +0 -27
  124. package/src/modes/controllers/selector-controller.ts +53 -11
  125. package/src/modes/interactive-mode.ts +4 -1
  126. package/src/modes/shared/agent-wire/scopes.ts +1 -1
  127. package/src/modes/theme/defaults/gruvbox-dark.json +99 -0
  128. package/src/modes/theme/defaults/index.ts +2 -0
  129. package/src/modes/theme/theme.ts +0 -4
  130. package/src/modes/utils/hotkeys-markdown.ts +1 -1
  131. package/src/notifications/html-format.ts +38 -0
  132. package/src/notifications/index.ts +242 -12
  133. package/src/notifications/lifecycle-commands.ts +238 -0
  134. package/src/notifications/lifecycle-control-runtime.ts +405 -0
  135. package/src/notifications/lifecycle-orchestrator.ts +358 -0
  136. package/src/notifications/operator-runtime.ts +171 -0
  137. package/src/notifications/rate-limit-pool.ts +19 -0
  138. package/src/notifications/recent-activity.ts +132 -0
  139. package/src/notifications/telegram-daemon.ts +778 -257
  140. package/src/notifications/telegram-reference.ts +25 -7
  141. package/src/notifications/topic-registry.ts +23 -9
  142. package/src/prompts/agents/executor.md +2 -2
  143. package/src/runtime-mcp/transports/stdio.ts +38 -4
  144. package/src/runtime-mcp/types.ts +7 -0
  145. package/src/sdk.ts +157 -10
  146. package/src/session/agent-session.ts +166 -74
  147. package/src/session/blob-store.ts +196 -8
  148. package/src/session/session-manager.ts +762 -12
  149. package/src/skc-runtime/launch-tmux.ts +68 -19
  150. package/src/skc-runtime/psmux-detect.ts +239 -0
  151. package/src/skc-runtime/team-runtime.ts +56 -23
  152. package/src/skc-runtime/tmux-common.ts +88 -4
  153. package/src/skc-runtime/tmux-sessions.ts +111 -9
  154. package/src/skc-runtime/ultragoal-guard.ts +25 -8
  155. package/src/skc-runtime/ultragoal-runtime.ts +75 -15
  156. package/src/slash-commands/builtin-registry.ts +23 -3
  157. package/src/slash-commands/helpers/fast-status-report.ts +13 -3
  158. package/src/slash-commands/helpers/parse.ts +2 -1
  159. package/src/system-prompt.ts +9 -0
  160. package/src/task/executor.ts +31 -7
  161. package/src/task/index.ts +2 -0
  162. package/src/tools/ask.ts +5 -1
  163. package/src/tools/bash.ts +9 -0
  164. package/src/tools/composer-bash-policy.ts +96 -0
  165. package/src/tools/fetch.ts +18 -2
  166. package/src/tools/index.ts +3 -1
  167. package/src/utils/changelog.ts +8 -0
  168. package/src/web/insane/url-guard.ts +18 -14
  169. package/src/web/scrapers/types.ts +143 -45
  170. package/src/web/scrapers/utils.ts +70 -19
@@ -1,3 +1,6 @@
1
+ import type { ResolvedTmuxBinary } from "./psmux-detect";
2
+ import { resolveSkcTmuxBinary } from "./psmux-detect";
3
+
1
4
  export const SKC_DEFAULT_TMUX_SESSION = "sayknow_cli";
2
5
  export const SKC_TMUX_SESSION_PREFIX = `${SKC_DEFAULT_TMUX_SESSION}_`;
3
6
  export const SKC_TMUX_COMMAND_ENV = "SKC_TMUX_COMMAND";
@@ -11,6 +14,7 @@ export const SKC_TMUX_PROJECT_OPTION = "@skc-project";
11
14
  export const SKC_TMUX_SESSION_ID_OPTION = "@skc-session-id";
12
15
  export const SKC_TMUX_SESSION_STATE_FILE_OPTION = "@skc-session-state-file";
13
16
  export const SKC_TMUX_VERSION_OPTION = "@skc-version";
17
+ export const SKC_PSMUX_PROFILE_FORCE_ENV = "SKC_PSMUX_PROFILE_FORCE";
14
18
 
15
19
  export interface SkcTmuxProfileCommand {
16
20
  description: string;
@@ -31,10 +35,33 @@ export function envDisabled(value: string | undefined): boolean {
31
35
  return normalized === "0" || normalized === "false" || normalized === "off" || normalized === "no";
32
36
  }
33
37
 
34
- export function resolveSkcTmuxCommand(env: NodeJS.ProcessEnv = process.env): string {
35
- return env[SKC_TMUX_COMMAND_ENV]?.trim() || env.SKC_TEAM_TMUX_COMMAND?.trim() || "tmux";
38
+ /**
39
+ * Resolve the tmux (or tmux-compatible multiplexer) command SKC should invoke.
40
+ *
41
+ * This is the shared entry point used by every SKC code path that needs to talk
42
+ * to a multiplexer: `skc --tmux` planning, `skc session ...`, `skc team ...`,
43
+ * the lifecycle controller, and the harness resident owner. Routing all of
44
+ * them through the same resolver means a single `SKC_TMUX_COMMAND` override or
45
+ * a single Windows psmux / pmux detection wins for the whole process — the
46
+ * failure mode where `skc --tmux` creates a psmux-backed session and then
47
+ * `skc session status` fails because it queries literal `tmux` is closed off.
48
+ *
49
+ * Explicit `SKC_TMUX_COMMAND` / `SKC_TEAM_TMUX_COMMAND` overrides are honored on
50
+ * every platform. On native Windows without an override the resolver walks
51
+ * `psmux`, then `pmux`, then `tmux` and uses the first binary present on PATH.
52
+ * On POSIX the resolver returns `tmux` (the historical default) and only
53
+ * falls through to the platform-aware walker if the caller opts in.
54
+ */
55
+ export function resolveSkcTmuxCommand(
56
+ env: NodeJS.ProcessEnv = process.env,
57
+ platform: NodeJS.Platform = process.platform,
58
+ ): string {
59
+ return resolveSkcTmuxBinary({ env, platform }).command;
36
60
  }
37
61
 
62
+ export type { PsmuxProbe, ResolvedTmuxBinary, ResolveSkcTmuxBinaryOptions } from "./psmux-detect";
63
+ export { clearPsmuxDetectionCache, detectPsmux, probePsmux, resolveSkcTmuxBinary } from "./psmux-detect";
64
+
38
65
  /**
39
66
  * Build the exact-session target for tmux *option* commands
40
67
  * (`show-options` / `set-option`) and `display-message -t`.
@@ -45,7 +72,17 @@ export function resolveSkcTmuxCommand(env: NodeJS.ProcessEnv = process.env): str
45
72
  * keeps the exact-session match while giving tmux the window-qualified target
46
73
  * those commands require. See sayknow-cli#580.
47
74
  */
48
- export function buildSkcTmuxExactOptionTarget(sessionName: string): string {
75
+ export function buildSkcTmuxExactOptionTarget(
76
+ sessionName: string,
77
+ opts: { env?: NodeJS.ProcessEnv; platform?: NodeJS.Platform; binary?: ResolvedTmuxBinary } = {},
78
+ ): string {
79
+ const binary = opts.binary ?? resolveSkcTmuxBinary({ env: opts.env, platform: opts.platform });
80
+ // psmux 3.3.0 rejects the tmux `=NAME` exact-session prefix for option
81
+ // commands ("no server running on session '=NAME'"); bare `NAME` and
82
+ // window-qualified `NAME:` both work. tmux 3.6a needs the
83
+ // window-qualified `=NAME:` to resolve the session for option
84
+ // commands (sayknow-cli#580).
85
+ if (binary.isPsmux) return sessionName;
49
86
  return `=${sessionName}:`;
50
87
  }
51
88
 
@@ -55,7 +92,9 @@ export function buildSkcTmuxUntaggedSessionHint(tmuxCommand: string): string {
55
92
  return (
56
93
  `the active multiplexer "${tmuxCommand}" lists this session but did not return SKC's ${SKC_TMUX_PROFILE_OPTION} ownership tag; ` +
57
94
  "SKC-managed sessions and `skc team` require a tmux provider that round-trips tmux user options. " +
58
- "Alternative multiplexers such as psmux on Windows do not persist user options yet, so the Windows-native psmux path is not fully supported; " +
95
+ "For psmux on Windows, cwd/start-directory flags such as `-c` do not isolate the server namespace; psmux uses the tmux-compatible global `-L <namespace>` flag for that. " +
96
+ "SKC_TMUX_COMMAND and SKC_TEAM_TMUX_COMMAND are binary overrides, not shell command lines, so `psmux -L name` is not a supported value. " +
97
+ "Alternative multiplexers such as psmux on Windows do not reliably persist user options yet, so the Windows-native psmux path is not fully supported; " +
59
98
  "use real tmux for SKC-managed session and team flows."
60
99
  );
61
100
  }
@@ -144,6 +183,16 @@ export function buildSkcTmuxRequiredProfileCommands(
144
183
  return commands;
145
184
  }
146
185
 
186
+ /**
187
+ * Keys whose set-option / set-window-option round-trip is unreliable on psmux
188
+ * 3.3.0. psmux does not support the tmux `set-window-option` command at all
189
+ * (it reports "unknown command: set-window-option") and silently drops several
190
+ * `set-option` keys. The list lives here so every code path that tags a tmux
191
+ * session (skc --tmux planning, skc session create, skc team bootstrap)
192
+ * applies the same filter.
193
+ */
194
+ const PSMUX_UNSUPPORTED_PROFILE_KEYS = new Set(["mouse", "set-clipboard", "mode-style"]);
195
+
147
196
  export function buildSkcTmuxProfileCommands(
148
197
  target: string,
149
198
  env: NodeJS.ProcessEnv = process.env,
@@ -155,6 +204,7 @@ export function buildSkcTmuxProfileCommands(
155
204
  sessionStateFile?: string | null;
156
205
  version?: string | null;
157
206
  } = {},
207
+ opts: { platform?: NodeJS.Platform; tmuxCommand?: string } = {},
158
208
  ): SkcTmuxProfileCommand[] {
159
209
  const commands = buildSkcTmuxRequiredProfileCommands(target, metadata);
160
210
  if (envDisabled(env[SKC_TMUX_PROFILE_ENV])) return commands;
@@ -170,6 +220,40 @@ export function buildSkcTmuxProfileCommands(
170
220
  description: "enable tmux mouse scrolling",
171
221
  args: ["set-option", "-t", target, "mouse", "on"],
172
222
  });
223
+ // psmux does not implement set-window-option and historically drops
224
+ // mouse / set-clipboard / mode-style. Filter the UX profile commands
225
+ // centrally so every code path that tags a session (skc --tmux planning,
226
+ // skc session create, skc team bootstrap) drops the same set. The
227
+ // SKC_PSMUX_PROFILE_FORCE override lets the operator opt back in when
228
+ // running on a psmux build that has caught up. The ownership-tag
229
+ // round-trip (set-option @skc-*) is never filtered, since skc session /
230
+ // skc team rely on it.
231
+ // The filter is opt-in: callers that explicitly pass `opts.tmuxCommand`
232
+ // name a psmux-class multiplexer (psmux / pmux) when they want the UX
233
+ // profile filtered. Auto-detect on Windows hosts where psmux happens
234
+ // to be on PATH would silently change the test output for every caller
235
+ // that does not pin the multiplexer, so we require the caller to opt
236
+ // in by naming the multiplexer. SKC_PSMUX_PROFILE_FORCE re-enables
237
+ // the UX profile commands when a psmux build catches up.
238
+ const tmuxName = (opts.tmuxCommand ?? "").toLowerCase();
239
+ const isPsmuxClass =
240
+ tmuxName === "psmux" ||
241
+ tmuxName === "pmux" ||
242
+ tmuxName.endsWith("/psmux") ||
243
+ tmuxName.endsWith("/pmux") ||
244
+ tmuxName.endsWith("\\psmux") ||
245
+ tmuxName.endsWith("\\pmux");
246
+ const dropUx = isPsmuxClass && !envDisabled(env[SKC_PSMUX_PROFILE_FORCE_ENV]);
247
+ if (dropUx) {
248
+ return commands.filter(command => {
249
+ const flag = command.args[0];
250
+ const key = command.args[command.args.length - 2];
251
+ return !(
252
+ PSMUX_UNSUPPORTED_PROFILE_KEYS.has(String(key)) &&
253
+ (flag === "set-option" || flag === "set-window-option")
254
+ );
255
+ });
256
+ }
173
257
  return commands;
174
258
  }
175
259
 
@@ -1,3 +1,4 @@
1
+ import { resolveSkcTmuxBinary } from "./psmux-detect";
1
2
  import {
2
3
  buildSkcTmuxExactOptionTarget,
3
4
  buildSkcTmuxProfileCommands,
@@ -128,10 +129,29 @@ function runListSessions(format: string, env: NodeJS.ProcessEnv = process.env):
128
129
  }
129
130
  throw error;
130
131
  }
131
- return output
132
+ const lines = output
132
133
  .split("\n")
133
134
  .map(line => line.trim())
134
135
  .filter(Boolean);
136
+ // psmux 3.3.0 silently ignores the tmux `-F` format flag and returns its
137
+ // default `name: N windows (created ...)` shape. Detect that case and
138
+ // synthesize a tab-separated row so downstream parseSessionLine /
139
+ // hydrateSessionFromExactOptions can recover the @skc-* ownership tags
140
+ // via follow-up show-options calls. Without this fallback skc session
141
+ // list / status return an empty list on psmux even when sessions exist.
142
+ if (lines.length > 0 && !lines[0].includes("\t")) {
143
+ const binary = resolveSkcTmuxBinary({ env });
144
+ if (binary.isPsmux) {
145
+ return lines.map(line => {
146
+ const match = line.match(/^([^:]+):\s*(\d+)\s+windows?\s+\(created\s+([^)]+)\)/);
147
+ if (!match) return line;
148
+ const [, name, windows, created] = match;
149
+ const createdEpoch = String(Math.floor(new Date(`${created} UTC`).getTime() / 1000) || 0);
150
+ return [name, windows, "0", createdEpoch, "", "", "0", "", "", "", "", "", "", ""].join("\t");
151
+ });
152
+ }
153
+ }
154
+ return lines;
135
155
  }
136
156
 
137
157
  function listSessionLines(env: NodeJS.ProcessEnv = process.env): string[] {
@@ -221,7 +241,13 @@ export function statusSkcTmuxSession(sessionName: string, env: NodeJS.ProcessEnv
221
241
  export function createSkcTmuxSession(env: NodeJS.ProcessEnv = process.env): SkcTmuxSessionStatus {
222
242
  const tmuxCommand = resolveSkcTmuxCommand(env);
223
243
  const sessionName = buildSkcTmuxSessionName(env);
224
- const command = "exec env SKC_TMUX_LAUNCHED=1 skc";
244
+ // Build a shell-bootstrap command appropriate for the host shell. Psmux on
245
+ // Windows runs the new-session command through PowerShell, so we use the
246
+ // $env:VAR = ... assignment form there. POSIX keeps the historical exec
247
+ // env form so the launched skc inherits SKC_TMUX_LAUNCHED without leaking
248
+ // into the parent tmux server.
249
+ const platform = process.platform;
250
+ const command = platform === "win32" ? "$env:SKC_TMUX_LAUNCHED = '1'; skc" : "exec env SKC_TMUX_LAUNCHED=1 skc";
225
251
  const created = Bun.spawnSync([tmuxCommand, "new-session", "-d", "-s", sessionName, command], {
226
252
  stdout: "pipe",
227
253
  stderr: "pipe",
@@ -229,7 +255,14 @@ export function createSkcTmuxSession(env: NodeJS.ProcessEnv = process.env): SkcT
229
255
  });
230
256
  if (created.exitCode !== 0) throw new Error(created.stderr.toString().trim() || "skc_tmux_session_create_failed");
231
257
  try {
232
- for (const profileCommand of buildSkcTmuxProfileCommands(sessionName, env)) {
258
+ // psmux 3.3.0 rejects the tmux `=NAME` exact-session prefix for option
259
+ // commands, so the target is the bare session name on psmux and the
260
+ // window-qualified `=NAME:` on tmux. The ownership-tag round-trip
261
+ // (set-option @skc-*) is preserved on both; only the UX profile commands
262
+ // (mouse / set-clipboard / mode-style / set-window-option) get filtered
263
+ // by buildSkcTmuxProfileCommands when the active binary is psmux.
264
+ const target = buildSkcTmuxExactOptionTarget(sessionName, { env });
265
+ for (const profileCommand of buildSkcTmuxProfileCommands(target, env, {}, { tmuxCommand })) {
233
266
  runTmux(profileCommand.args, env);
234
267
  }
235
268
  } catch (error) {
@@ -240,18 +273,43 @@ export function createSkcTmuxSession(env: NodeJS.ProcessEnv = process.env): SkcT
240
273
  }
241
274
 
242
275
  function readProfileForExactTarget(sessionName: string, env: NodeJS.ProcessEnv): string {
243
- return runTmux(
244
- ["show-options", "-qv", "-t", buildSkcTmuxExactOptionTarget(sessionName), SKC_TMUX_PROFILE_OPTION],
276
+ const raw = runTmux(
277
+ ["show-options", "-qv", "-t", buildSkcTmuxExactOptionTarget(sessionName, { env }), SKC_TMUX_PROFILE_OPTION],
245
278
  env,
246
279
  ).trim();
280
+ // tmux returns just the value; psmux returns `key value`. Strip the
281
+ // leading key on psmux so the SKC_TMUX_PROFILE_VALUE equality check
282
+ // against "1" works the same on both.
283
+ if (raw && resolveSkcTmuxBinary({ env }).isPsmux) {
284
+ const tokens = raw.split(/\s+/).filter(Boolean);
285
+ return tokens[tokens.length - 1] ?? raw;
286
+ }
287
+ return raw;
247
288
  }
248
289
 
249
290
  function readExactOptionForGc(sessionName: string, option: string, env: NodeJS.ProcessEnv): string | undefined {
250
291
  try {
251
- return (
252
- runTmux(["show-options", "-qv", "-t", buildSkcTmuxExactOptionTarget(sessionName), option], env).trim() ||
253
- undefined
254
- );
292
+ const raw = runTmux(
293
+ ["show-options", "-qv", "-t", buildSkcTmuxExactOptionTarget(sessionName, { env }), option],
294
+ env,
295
+ ).trim();
296
+ if (!raw) return undefined;
297
+ // tmux returns just the option value (e.g. `1` for @skc-profile).
298
+ // psmux 3.3.0 returns `key value` (or `key "value with space"` for
299
+ // @skc-branch etc.). On psmux, parse the last token and strip any
300
+ // surrounding double quotes so both shapes resolve to the same value.
301
+ if (resolveSkcTmuxBinary({ env }).isPsmux) {
302
+ // Prefer the last whitespace-separated token. If the value is
303
+ // quoted, find the matching close-quote and slice.
304
+ const lastQuote = raw.lastIndexOf('"');
305
+ if (lastQuote > 0 && raw[lastQuote - 1] !== "\\") {
306
+ const firstQuote = raw.lastIndexOf('"', lastQuote - 1);
307
+ if (firstQuote > 0) return raw.slice(firstQuote + 1, lastQuote);
308
+ }
309
+ const tokens = raw.split(/\s+/).filter(Boolean);
310
+ return tokens[tokens.length - 1];
311
+ }
312
+ return raw;
255
313
  } catch {
256
314
  return undefined;
257
315
  }
@@ -306,6 +364,50 @@ export function removeSkcTmuxSession(sessionName: string, env: NodeJS.ProcessEnv
306
364
  return session;
307
365
  }
308
366
 
367
+ /**
368
+ * Force-close a SKC-managed tmux session, even if a live pane is attached.
369
+ *
370
+ * This is the lifecycle-control counterpart to {@link removeSkcTmuxSession}: it
371
+ * intentionally does NOT refuse live/attached panes (hard-kill is the contract),
372
+ * but it keeps every safety check so it can only ever kill a genuinely
373
+ * SKC-managed session:
374
+ * - re-reads the exact tmux profile immediately before kill (never a non-SKC
375
+ * session, even one that collides by name);
376
+ * - when `expectedSessionId` is given, requires the `@skc-session-id` tag match;
377
+ * - when `expectedStateFile` is given, requires the `@skc-session-state-file`
378
+ * tag match.
379
+ *
380
+ * Returns the prior status (for audit). Throws a tagged error otherwise:
381
+ * `skc_tmux_session_not_found`, `skc_tmux_session_not_managed`,
382
+ * `skc_tmux_session_id_mismatch`, or `skc_tmux_session_state_file_mismatch`.
383
+ */
384
+ export function forceCloseSkcTmuxSession(
385
+ sessionName: string,
386
+ env: NodeJS.ProcessEnv = process.env,
387
+ expectedSessionId?: string,
388
+ expectedStateFile?: string,
389
+ ): SkcTmuxSessionStatus {
390
+ const session = statusSkcTmuxSession(sessionName, env);
391
+ if (readProfileForExactTarget(session.name, env) !== SKC_TMUX_PROFILE_VALUE) {
392
+ throw new Error(`skc_tmux_session_not_managed:${sessionName}`);
393
+ }
394
+ if (expectedSessionId !== undefined) {
395
+ const actual = readExactOptionForGc(session.name, SKC_TMUX_SESSION_ID_OPTION, env);
396
+ if (actual !== expectedSessionId) {
397
+ throw new Error(`skc_tmux_session_id_mismatch:${sessionName}`);
398
+ }
399
+ }
400
+ if (expectedStateFile !== undefined) {
401
+ const actual = readExactOptionForGc(session.name, SKC_TMUX_SESSION_STATE_FILE_OPTION, env);
402
+ if (actual !== expectedStateFile) {
403
+ throw new Error(`skc_tmux_session_state_file_mismatch:${sessionName}`);
404
+ }
405
+ }
406
+ // Intentionally NOT refusing live/attached panes — force-close is hard-kill.
407
+ runTmux(["kill-session", "-t", `=${session.name}`], env);
408
+ return session;
409
+ }
410
+
309
411
  export function attachSkcTmuxSession(sessionName: string, env: NodeJS.ProcessEnv = process.env): never {
310
412
  const session = statusSkcTmuxSession(sessionName, env);
311
413
  const tmuxCommand = resolveSkcTmuxCommand(env);
@@ -65,15 +65,17 @@ function isKnownUltragoalObjective(currentObjective: string): boolean {
65
65
  );
66
66
  }
67
67
 
68
- async function ultragoalReadPaths(cwd: string): Promise<UltragoalPaths> {
68
+ async function ultragoalReadPaths(cwd: string): Promise<{ paths: UltragoalPaths; sessionId: string | null }> {
69
69
  const envSessionId = process.env.SKC_SESSION_ID?.trim();
70
- if (envSessionId) return getUltragoalPaths(cwd, envSessionId);
70
+ if (envSessionId) return { paths: getUltragoalPaths(cwd, envSessionId), sessionId: envSessionId };
71
71
  try {
72
72
  const session = await resolveSkcSessionForRead(cwd, { envSessionId: process.env.SKC_SESSION_ID });
73
- return getUltragoalPaths(cwd, session.skcSessionId);
73
+ return { paths: getUltragoalPaths(cwd, session.skcSessionId), sessionId: session.skcSessionId };
74
74
  } catch (error) {
75
75
  if (error instanceof SessionResolutionError && error.code === "no_session") {
76
- return getUltragoalPaths(cwd, null);
76
+ // No session could be resolved (no env, no auto-detectable active session).
77
+ // Surface the null session id so callers can decide; ask-guard treats it as inactive.
78
+ return { paths: getUltragoalPaths(cwd, null), sessionId: null };
77
79
  }
78
80
  throw error;
79
81
  }
@@ -82,7 +84,7 @@ async function ultragoalReadPaths(cwd: string): Promise<UltragoalPaths> {
82
84
  async function hasDurableUltragoalState(cwd: string): Promise<boolean> {
83
85
  let paths: UltragoalPaths;
84
86
  try {
85
- paths = await ultragoalReadPaths(cwd);
87
+ ({ paths } = await ultragoalReadPaths(cwd));
86
88
  } catch (error) {
87
89
  if (error instanceof SessionResolutionError) return true;
88
90
  throw error;
@@ -368,14 +370,26 @@ export async function readUltragoalVerificationState(input: {
368
370
 
369
371
  export async function isUltragoalAskBlocked(cwd: string): Promise<UltragoalAskBlockDiagnostic> {
370
372
  let paths: UltragoalPaths;
373
+ let sessionId: string | null;
371
374
  try {
372
- paths = await ultragoalReadPaths(cwd);
375
+ ({ paths, sessionId } = await ultragoalReadPaths(cwd));
373
376
  } catch (error) {
374
377
  return activeAskDiagnostic({
375
378
  reason: `Unable to resolve durable Ultragoal state: ${error instanceof Error ? error.message : String(error)}`,
376
379
  source: "durable_state_unreadable",
377
380
  });
378
381
  }
382
+ // Ultragoal state is session-scoped. When no session can be resolved (no env,
383
+ // no auto-detectable active session) there is no active run to protect, so the
384
+ // ask guard must fall open rather than block on legacy/global durable state.
385
+ if (sessionId === null) {
386
+ return inactiveAskDiagnostic({
387
+ reason: "No active SKC session resolved; ultragoal is inactive.",
388
+ source: "absent",
389
+ goalsPath: paths.goalsPath,
390
+ ledgerPath: paths.ledgerPath,
391
+ });
392
+ }
379
393
  try {
380
394
  await fs.stat(paths.dir);
381
395
  } catch (error) {
@@ -398,8 +412,8 @@ export async function isUltragoalAskBlocked(cwd: string): Promise<UltragoalAskBl
398
412
  let plan: UltragoalPlan | null;
399
413
  let ledger: UltragoalLedgerEvent[];
400
414
  try {
401
- plan = await readUltragoalPlan(cwd);
402
- ledger = await readUltragoalLedger(cwd);
415
+ plan = await readUltragoalPlan(cwd, sessionId);
416
+ ledger = await readUltragoalLedger(cwd, sessionId);
403
417
  } catch (error) {
404
418
  return activeAskDiagnostic({
405
419
  reason: `Unable to read durable Ultragoal state: ${error instanceof Error ? error.message : String(error)}`,
@@ -409,6 +423,9 @@ export async function isUltragoalAskBlocked(cwd: string): Promise<UltragoalAskBl
409
423
  });
410
424
  }
411
425
  if (!plan) {
426
+ // goals.json absent or empty while the state dir exists is an inconsistent
427
+ // durable state, not a clean "no run". Fail closed so the pause guard (which
428
+ // relies on this `durable_state_unreadable` signal) keeps blocking give-ups.
412
429
  return activeAskDiagnostic({
413
430
  reason: "Durable .skc/ultragoal state exists but goals.json is missing or empty.",
414
431
  source: "durable_state_unreadable",
@@ -1,11 +1,12 @@
1
1
  import * as crypto from "node:crypto";
2
2
  import * as path from "node:path";
3
3
  import { inflateSync } from "node:zlib";
4
-
4
+ import { normalizeGoal } from "../goals/state";
5
+ import { buildSessionContext, loadEntriesFromFile, type SessionEntry } from "../session/session-manager";
5
6
  import type { WorkflowHudSummary } from "../skill-state/active-state";
6
7
  import { buildUltragoalHudSummary as buildWorkflowUltragoalHudSummary } from "../skill-state/workflow-hud";
7
8
  import { renderCliWriteReceipt } from "./cli-write-receipt";
8
- import { DEFAULT_ULTRAGOAL_OBJECTIVE } from "./goal-mode-request";
9
+ import { DEFAULT_ULTRAGOAL_OBJECTIVE, SKC_SESSION_FILE_ENV } from "./goal-mode-request";
9
10
  import { sessionUltragoalDir, skcRoot } from "./session-layout";
10
11
  import { resolveSkcSessionForRead, resolveSkcSessionForWrite, writeSessionActivityMarker } from "./session-resolution";
11
12
  import { renderUltragoalStatusMarkdown } from "./state-renderer";
@@ -831,6 +832,14 @@ function normalizedEvidenceKind(row: JsonObject): string {
831
832
  function evidenceKindMatches(kind: string, words: string[]): boolean {
832
833
  return words.some(word => kind.includes(word));
833
834
  }
835
+ function formatActualArtifactKinds(artifactIds: string[], kinds: string[]): string {
836
+ if (artifactIds.length === 0) return "none";
837
+ return artifactIds.map((id, index) => `${id}=${kinds[index] ?? "<missing-kind>"}`).join(", ");
838
+ }
839
+
840
+ function formatExpectedKindWords(words: string[]): string {
841
+ return words.map(word => `"${word}"`).join(", ");
842
+ }
834
843
 
835
844
  type SurfaceFamily = "web" | "cli" | "native" | "api-package" | "algorithm-math" | "unknown";
836
845
 
@@ -899,9 +908,18 @@ function categorizeComputerChangePath(value: string): UltragoalChangeCategory {
899
908
  }
900
909
 
901
910
  function isComputerControlSurfaceCategory(category: UltragoalChangeCategory): boolean {
902
- return (
903
- category === "code" || category === "generated-binding" || category === "tool" || category === "settings-registry"
904
- );
911
+ // The computer-use red-team suite is conditional, not universal (see the
912
+ // ultragoal SKILL): require it only when the change actually touches
913
+ // computer-control source — the computer tool (`tool`), its settings/registry
914
+ // wiring (`settings-registry`), or computer Rust (`code`). A bare regeneration
915
+ // of the SHARED native binding (`generated-binding`: packages/natives/native/
916
+ // index.{d.ts,js}) is NOT by itself a computer-use change: that file is
917
+ // generated from Rust, so any real computer-use behavior change must also
918
+ // touch one of the categories above and will still trigger the suite. Treating
919
+ // the regenerated aggregate binding as a computer surface forced the suite on
920
+ // unrelated features (e.g. notifications), which the SKILL explicitly warns
921
+ // against, so it is excluded here.
922
+ return category === "code" || category === "tool" || category === "settings-registry";
905
923
  }
906
924
 
907
925
  function isComputerControlSurfaceChangePath(row: UltragoalChangeSetPath): boolean {
@@ -967,7 +985,7 @@ function validateSurfaceArtifactCompatibility(
967
985
  const hasVisual = kinds.some(kind => evidenceKindMatches(kind, ["screenshot", "image", "visual"]));
968
986
  if (!hasBrowser || !hasVisual) {
969
987
  throw new Error(
970
- `qualityGate ${fieldName} for GUI/web surfaces must reference browser automation plus screenshot or image-verdict artifacts`,
988
+ `qualityGate ${fieldName} for GUI/web surfaces must reference browser automation plus screenshot or image-verdict artifacts; surface "${surface}" expected one artifact kind containing one of ${formatExpectedKindWords(["browser", "playwright", "pandawright", "automation"])} and one containing one of ${formatExpectedKindWords(["screenshot", "image", "visual"])}; actual artifact kinds: ${formatActualArtifactKinds(artifactIds, kinds)}`,
971
989
  );
972
990
  }
973
991
  return;
@@ -994,7 +1012,7 @@ function validateSurfaceArtifactCompatibility(
994
1012
  const expected = surfaceFamilies[family];
995
1013
  if (!kinds.some(kind => evidenceKindMatches(kind, expected.evidence))) {
996
1014
  throw new Error(
997
- `qualityGate ${fieldName} for ${expected.label} surfaces must reference compatible artifact kinds`,
1015
+ `qualityGate ${fieldName} for ${expected.label} surfaces must reference compatible artifact kinds; surface "${surface}" expected at least one artifact kind containing one of ${formatExpectedKindWords(expected.evidence)}; actual artifact kinds: ${formatActualArtifactKinds(artifactIds, kinds)}`,
998
1016
  );
999
1017
  }
1000
1018
  }
@@ -1490,6 +1508,20 @@ function isAllowedCliReplayCommand(command: readonly string[]): boolean {
1490
1508
  if (executable === "skc") return args.length === 1 && ["read", "status"].includes(args[0] ?? "");
1491
1509
  return false;
1492
1510
  }
1511
+ function summarizeBlockedCliReplayCommand(command: readonly string[]): string {
1512
+ const executable = command[0] ? basenameCommand(command[0]) : "<missing>";
1513
+ const argCount = Math.max(0, command.length - 1);
1514
+ return `${JSON.stringify(executable)} with ${argCount} arg${argCount === 1 ? "" : "s"}`;
1515
+ }
1516
+
1517
+ function cliReplayAllowlistDescription(): string {
1518
+ return [
1519
+ '`bun --version`, `node --version`, or deterministic `bun/node -e "console.log(...)"`',
1520
+ "`npm|pnpm|yarn --version` or `npm|pnpm|yarn list`",
1521
+ "read-only `git status|rev-parse|merge-base|diff|show|log` with safe args",
1522
+ "`skc read` or `skc status`",
1523
+ ].join("; ");
1524
+ }
1493
1525
 
1494
1526
  function resolveCliReplayCommand(command: string[]): string[] {
1495
1527
  if (basenameCommand(command[0]!) === "bun") return [process.execPath, ...command.slice(1)];
@@ -1578,8 +1610,11 @@ function parseCliReplayRecord(
1578
1610
  if (!command) throw new Error(`qualityGate ${fieldName}.command must be a non-empty string array`);
1579
1611
  if (record.replaySafe !== true)
1580
1612
  throw new Error(`qualityGate ${fieldName}.replaySafe must be true before CLI replay executes`);
1581
- if (!isAllowedCliReplayCommand(command))
1582
- throw new Error(`qualityGate ${fieldName}.command is not in the conservative CLI replay allowlist`);
1613
+ if (!isAllowedCliReplayCommand(command)) {
1614
+ throw new Error(
1615
+ `qualityGate ${fieldName}.command is not in the conservative CLI replay allowlist; command ${summarizeBlockedCliReplayCommand(command)} is blocked. Allowed replay commands: ${cliReplayAllowlistDescription()}. For other commands, provide audited replayExempt metadata with reasonCode, reason, approvedBy, and fallbackArtifactRefs that point to a structurally valid fallback artifact.`,
1616
+ );
1617
+ }
1583
1618
  if (record.normalization !== undefined && record.normalization !== "default") {
1584
1619
  throw new Error(`qualityGate ${fieldName}.normalization must be default when provided`);
1585
1620
  }
@@ -2231,6 +2266,28 @@ function snapshotUpdatedAtMilliseconds(value: unknown): number | null {
2231
2266
  const parsed = Date.parse(trimmed);
2232
2267
  return Number.isFinite(parsed) ? parsed : null;
2233
2268
  }
2269
+
2270
+ function singleSessionLeafId(entries: readonly SessionEntry[]): string | undefined {
2271
+ if (entries.length === 0) return undefined;
2272
+ const parentIds = new Set(
2273
+ entries.map(entry => entry.parentId).filter((parentId): parentId is string => typeof parentId === "string"),
2274
+ );
2275
+ const leafIds = entries.map(entry => entry.id).filter(id => !parentIds.has(id));
2276
+ return leafIds.length === 1 ? leafIds[0] : undefined;
2277
+ }
2278
+
2279
+ async function readCurrentSessionSkcGoalSnapshot(): Promise<unknown | undefined> {
2280
+ const sessionFile = process.env[SKC_SESSION_FILE_ENV]?.trim();
2281
+ if (!sessionFile) return undefined;
2282
+ const fileEntries = await loadEntriesFromFile(sessionFile);
2283
+ const entries = fileEntries.filter((entry): entry is SessionEntry => entry.type !== "session");
2284
+ const leafId = singleSessionLeafId(entries);
2285
+ if (!leafId) return undefined;
2286
+ const context = buildSessionContext(entries, leafId);
2287
+ if (context.mode !== "goal" && context.mode !== "goal_paused") return undefined;
2288
+ const goal = normalizeGoal(context.modeData?.goal);
2289
+ return goal ? { goal } : undefined;
2290
+ }
2234
2291
  async function readSkcGoalSnapshot(input: {
2235
2292
  cwd: string;
2236
2293
  value: string | undefined;
@@ -2240,13 +2297,15 @@ async function readSkcGoalSnapshot(input: {
2240
2297
  errorPrefix: string;
2241
2298
  allowCompletedLegacyBlocker?: boolean;
2242
2299
  }): Promise<unknown> {
2243
- if (!input.value?.trim()) {
2300
+ const snapshot = input.value?.trim()
2301
+ ? await readStructuredValue(input.cwd, input.value)
2302
+ : await readCurrentSessionSkcGoalSnapshot();
2303
+ if (snapshot === undefined) {
2244
2304
  if (!input.required) return undefined;
2245
2305
  throw new Error(
2246
- `${input.errorPrefix} require --skc-goal-json from a fresh active goal({"op":"get"}) snapshot; this is the SKC goal-mode receipt, not the .skc/ultragoal/goals.json goal record`,
2306
+ `${input.errorPrefix} require an active SKC goal-mode snapshot from the current session or --skc-goal-json; this is the SKC goal-mode receipt, not the .skc/ultragoal/goals.json goal record`,
2247
2307
  );
2248
2308
  }
2249
- const snapshot = await readStructuredValue(input.cwd, input.value);
2250
2309
  const snapshotObject = qualityGateObject(snapshot);
2251
2310
  const detailsObject = qualityGateObject(snapshotObject?.details);
2252
2311
  const goalObject = qualityGateObject(snapshotObject?.goal) ?? qualityGateObject(detailsObject?.goal);
@@ -3331,18 +3390,19 @@ function renderUltragoalHelp(args: readonly string[]): string | null {
3331
3390
  " --status=<value> pending|active|complete|failed|blocked|review_blocked|superseded",
3332
3391
  " --evidence=<value> Completion or checkpoint evidence text",
3333
3392
  " --quality-gate-json=<value> JSON string or path for complete checkpoints",
3334
- ' --skc-goal-json=<value> JSON string or path containing the current goal({"op":"get"}) snapshot',
3393
+ " --skc-goal-json=<value> Optional JSON/path override for current goal snapshot; omitted complete checkpoints read current session goal state",
3335
3394
  " --json Output a machine-readable receipt",
3336
3395
  "",
3337
3396
  "COMPLETE CHECKPOINT RECEIPTS",
3338
3397
  " --quality-gate-json must be an object with architectReview, executorQa, and iteration.",
3339
3398
  " executorQa.contractCoverage[] rows require an obligation field; description is not a substitute.",
3340
- ' --skc-goal-json must contain the active SKC goal-mode snapshot from goal({"op":"get"}), not the .skc/ultragoal/goals.json goal record.',
3399
+ " Complete checkpoints use the current session's active SKC goal-mode snapshot when --skc-goal-json is omitted.",
3400
+ " Explicit --skc-goal-json values must contain an active SKC goal-mode snapshot, not the .skc/ultragoal/goals.json goal record.",
3341
3401
  " goal.updatedAt may be epoch milliseconds or an ISO timestamp and must be fresh.",
3342
3402
  "",
3343
3403
  "EXAMPLES",
3344
3404
  ' $ skc ultragoal checkpoint --goal-id G001 --status blocked --evidence "waiting on review"',
3345
- ' $ skc ultragoal checkpoint --goal-id G001 --status complete --evidence "tests passed" --skc-goal-json ./goal.json --quality-gate-json ./quality-gate.json --json',
3405
+ ' $ skc ultragoal checkpoint --goal-id G001 --status complete --evidence "tests passed" --quality-gate-json ./quality-gate.json --json',
3346
3406
  "",
3347
3407
  ].join("\n");
3348
3408
  }
@@ -6,6 +6,7 @@ import { getOAuthProviders } from "@sayknow-cli/ai/utils/oauth";
6
6
  import { Spacer, Text } from "@sayknow-cli/tui";
7
7
  import { setProjectDir } from "@sayknow-cli/utils";
8
8
  import { jobElapsedMs } from "../async";
9
+ import { materializeActiveModelProfileAssignment } from "../config/model-profile-activation";
9
10
  import {
10
11
  SKC_MODEL_ASSIGNMENT_TARGET_IDS,
11
12
  SKC_MODEL_ASSIGNMENT_TARGETS,
@@ -299,6 +300,12 @@ const BUILTIN_SLASH_COMMAND_REGISTRY: ReadonlyArray<SlashCommandSpec> = [
299
300
  selector: selection.selector,
300
301
  thinkingLevel: selection.thinkingLevel,
301
302
  });
303
+ materializeActiveModelProfileAssignment({
304
+ session: runtime.session,
305
+ settings: runtime.settings,
306
+ role: parsedArgs.targetId,
307
+ selector: persistedSelector,
308
+ });
302
309
  if (selection.thinkingLevel) {
303
310
  runtime.session.setThinkingLevel(selection.thinkingLevel);
304
311
  }
@@ -317,10 +324,23 @@ const BUILTIN_SLASH_COMMAND_REGISTRY: ReadonlyArray<SlashCommandSpec> = [
317
324
  selection.thinkingLevel ??
318
325
  extractExplicitThinkingSelector(overrides[parsedArgs.targetId], runtime.settings);
319
326
  const roleSelector = formatModelSelectorValue(selection.selector, thinkingLevel);
320
- runtime.settings.set("task.agentModelOverrides", {
321
- ...overrides,
322
- [parsedArgs.targetId]: roleSelector,
327
+ const materializedProfile = materializeActiveModelProfileAssignment({
328
+ session: runtime.session,
329
+ settings: runtime.settings,
330
+ role: parsedArgs.targetId,
331
+ selector: roleSelector,
323
332
  });
333
+ if (!materializedProfile) {
334
+ const target = SKC_MODEL_ASSIGNMENT_TARGETS[parsedArgs.targetId];
335
+ if (target.settingsPath === "modelRoles") {
336
+ runtime.settings.setModelRole(parsedArgs.targetId, roleSelector);
337
+ } else {
338
+ runtime.settings.set("task.agentModelOverrides", {
339
+ ...overrides,
340
+ [parsedArgs.targetId]: roleSelector,
341
+ });
342
+ }
343
+ }
324
344
  runtime.settings.getStorage()?.recordModelUsage(`${selection.model.provider}/${selection.model.id}`);
325
345
  await runtime.output(`${parsedArgs.targetId} agent model set to ${roleSelector}.`);
326
346
  }
@@ -56,6 +56,12 @@ export interface FastStatusSessionLike {
56
56
  readonly model?: Model;
57
57
  /** Fast predicate against the main session tier (current model + `modelRoles`). */
58
58
  isFastForProvider(provider?: string): boolean;
59
+ /**
60
+ * Current-model EFFECTIVE fast state (intent minus any provider auto-disable).
61
+ * Used for the current-model row so it matches what the next request does.
62
+ * Optional so lightweight fakes can omit it; falls back to `isFastForProvider`.
63
+ */
64
+ isFastModeActive?(): boolean;
59
65
  /** Fast predicate against the effective subagent tier (`task.agentModelOverrides` roles). */
60
66
  isFastForSubagentProvider(provider?: string): boolean;
61
67
  resolveRoleModelWithThinking(role: string): { model?: Model };
@@ -95,9 +101,13 @@ export interface BuildFastStatusReportArgs {
95
101
  */
96
102
  export function buildFastStatusReport(args: BuildFastStatusReportArgs): string {
97
103
  const { session, roleTargets, iconFast, formatInactive } = args;
98
- const rows: FastStatusRow[] = [
99
- { label: "현재 모델", model: session.model, fast: session.isFastForProvider(session.model?.provider) },
100
- ];
104
+ // Current-model row uses the EFFECTIVE predicate (intent minus any provider
105
+ // auto-disable) so it matches the next request; `modelRoles` rows below stay
106
+ // on pure intent. Fall back to intent when a fake omits `isFastModeActive`.
107
+ const currentFast = session.isFastModeActive
108
+ ? session.isFastModeActive()
109
+ : session.isFastForProvider(session.model?.provider);
110
+ const rows: FastStatusRow[] = [{ label: "현재 모델", model: session.model, fast: currentFast }];
101
111
  for (const target of roleTargets) {
102
112
  const resolved = session.resolveRoleModelWithThinking(target.id);
103
113
  if (resolved.model) {
@@ -1,3 +1,4 @@
1
+ import { parseCommandArgs } from "../../utils/command-args";
1
2
  import type { ParsedSlashCommand, SlashCommandResult, SlashCommandRuntime } from "../types";
2
3
 
3
4
  export interface ParsedSubcommand {
@@ -65,7 +66,7 @@ export function errorMessage(error: unknown): string {
65
66
  * "name required" diagnostics with their own messaging.
66
67
  */
67
68
  export function parseNamedScopeArgs(rest: string, invalidScopeMessage: string): NamedScopeArgs {
68
- const tokens = rest.split(/\s+/).filter(Boolean);
69
+ const tokens = parseCommandArgs(rest);
69
70
  let name: string | undefined;
70
71
  let scope: ConfigScope = "project";
71
72
  let i = 0;