aiterm-mcp 0.70.66 → 0.70.68

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/CHANGELOG.md CHANGED
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.70.68] - 2026-11-15
11
+
12
+ - `agent_configure` now changes the model or the effort (low to max) of a Claude seat whose turn is running, without ending the turn (b8, Kiro's request, Owner's order). Typing `/model` into a busy Claude seat only queues it as a user message (2.1.325), so the picker is opened with Alt+P (tmux/psmux key `M-p`, ESC and p in one write; a lone ESC would stop the turn) and the usual row match, `s` (this session only, never Enter), "Yes, switch" and refusal logic (`configureRefusal`, `aiterm/configure_error`) follow. The same turn's next request runs on the new model. Differences from an idle seat: no Esc is sent except to close the picker or the switch question while one is on screen, the result line is read without the `❯ /model` line above it, and no composer is waited for. Idle seats still use `/model`. `fast`, `opusplan`, `ultracode`, an effort outside low-max and a running Claude goal keep the refusal "入力待ちではありません" (nothing typed). A seat already in a running turn needs no relaunch; the change is on the seat's own session only (model-configuration.md).
13
+
14
+ ## [0.70.67] - 2026-11-15
15
+
16
+ - A Claude seat can no longer enter plan mode without having written what it will plan (b4, Kiro's request, Owner's order). EnterPlanMode takes no arguments, so a seat that called it blind fell into plan mode's ask-the-user flow and an unattended seat stalled there. Every Claude seat's own settings now carry a `PreToolUse` hook for `EnterPlanMode` only. It waits up to 1.5 s (polling every 50 ms) for the call to appear in the seat's transcript, then counts the assistant text written right before it in the same message. 80 characters or more: the call goes through. Less: the call is turned back once per prompt with an instruction to write the detailed spec in the AI's own words and call again; the second call of the same prompt is never turned back (a small `.claude-plan-spec` state file in the seat's agents folder records the turn-back and is cleaned with the seat). An unreadable transcript, a missing `prompt_id`, an unwritable state file, an unreadable input and a process outside an Aiterm seat all let the call through. A seat already running keeps its old settings until it is resumed or relaunched; an Aiterm below 0.70.67 behaves as before (harness-contracts.md "EnterPlanModeの前に仕様を書かせる").
17
+
10
18
  ## [0.70.66] - 2026-11-15
11
19
 
12
20
  - A Claude seat on plan mode no longer waits for a person at the ExitPlanMode dialog "Ready to code?" (a141, Kiro's request). Every Claude seat's own settings now carry a `PermissionRequest` hook for `ExitPlanMode` only. The hook answers as option 1 ("Yes, and switch to BYPASS PERMISSIONS"): it allows the call with the call's own input and sets the session mode to `bypassPermissions`, which the seat already ran in. Claude Code 2.1.325 ignores an allow without the input for this tool, so the input is part of the answer. Any other tool, any other dialog (AskUserQuestion included), an unreadable input and a process outside an Aiterm seat get no decision and keep their screen. A seat already running keeps its old settings until it is resumed or relaunched; an Aiterm below 0.70.66 behaves as before (harness-contracts.md "ExitPlanModeの承認").
@@ -3514,7 +3522,9 @@ prototype (preserved under `prototype/python/` as the porting source and referen
3514
3522
  `ubuntu-latest` for Node 18/20/22, publishing to npm on `v*` tags with
3515
3523
  provenance.
3516
3524
 
3517
- [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.66...HEAD
3525
+ [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.68...HEAD
3526
+ [0.70.68]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.67...v0.70.68
3527
+ [0.70.67]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.66...v0.70.67
3518
3528
  [0.70.66]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.65...v0.70.66
3519
3529
  [0.70.65]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.64...v0.70.65
3520
3530
  [0.70.64]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.63...v0.70.64
package/README.ja.md CHANGED
@@ -215,7 +215,7 @@ runtime-error store は canonical dotagents config の `collection.enabled: true
215
215
  場合だけ収集し、既定OFF、network送信は行いません。tag起点CIのnpm provenance(OIDC Trusted
216
216
  Publishing)で公開し、GitHub Release が Official MCP Registry を再登録します。
217
217
 
218
- **状態:** 開発継続中 · 現行公開版 **v0.70.66** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
218
+ **状態:** 開発継続中 · 現行公開版 **v0.70.68** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
219
219
 
220
220
  ### 更新と巻き戻し
221
221
 
package/README.md CHANGED
@@ -227,7 +227,7 @@ collection is off by default and performs no network I/O. It ships via
227
227
  tag-triggered CI with npm provenance (OIDC Trusted Publishing); the GitHub
228
228
  Release re-registers the Official MCP Registry entry.
229
229
 
230
- **Status:** actively maintained · current public release **v0.70.66** · runs on Linux · WSL2 · macOS · native Windows (tmux on POSIX, the tmux-CLI-compatible [psmux](https://github.com/psmux/psmux) on native Windows — no WSL required) · MIT · see the [CHANGELOG](CHANGELOG.md).
230
+ **Status:** actively maintained · current public release **v0.70.68** · runs on Linux · WSL2 · macOS · native Windows (tmux on POSIX, the tmux-CLI-compatible [psmux](https://github.com/psmux/psmux) on native Windows — no WSL required) · MIT · see the [CHANGELOG](CHANGELOG.md).
231
231
 
232
232
  ### Update and rollback
233
233
 
@@ -0,0 +1,139 @@
1
+ #!/usr/bin/env node
2
+ // Claude PreToolUse hook for EnterPlanMode only (harness-contracts.md "EnterPlanModeの前に仕様を書かせる").
3
+ // EnterPlanMode takes no arguments, so a seat that calls it without having written what it will plan falls into plan mode's
4
+ // "ask the user" flow and an unattended seat stalls there. This turns the first such call back, once per prompt, telling the
5
+ // AI to write the spec in its own words. Anything unexpected prints nothing and exits 0 (allow).
6
+ import * as fs from "node:fs";
7
+ import * as path from "node:path";
8
+ import { currentUid, runtimeStateBase } from "./state-root.js";
9
+ const MAX_STDIN_BYTES = 8 * 1024 * 1024;
10
+ const TAIL_BYTES = 512 * 1024;
11
+ const POLL_MS = 50;
12
+ const WAIT_MS = 1500;
13
+ // shortcut: a length floor, because the spec is the AI's own words and a tool cannot judge it; raise it if seats pass one-line stubs.
14
+ const SPEC_MIN_CHARS = 80;
15
+ const AITERM_ENV = ["AITERM_AGENT_KIND", "AITERM_SESSION_ID", "AITERM_AGENT_SESSION_ID", "AITERM_AGENT_LAUNCH_ID"];
16
+ const GUIDANCE = "プランモードに入る前に、プランを練りたい内容の詳細な仕様を、あなた自身の言葉で書いてください。"
17
+ + "何を作る・直す・調べるのか、範囲、守る条件、終わりの形を書いたうえで、もう一度 EnterPlanMode を呼んでください。";
18
+ async function readStdin() {
19
+ const chunks = [];
20
+ let total = 0;
21
+ for await (const chunk of process.stdin) {
22
+ const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk));
23
+ total += bytes.length;
24
+ if (total > MAX_STDIN_BYTES)
25
+ return "";
26
+ chunks.push(bytes);
27
+ }
28
+ return Buffer.concat(chunks).toString("utf8");
29
+ }
30
+ /** The transcript's tail as text (a cut first line is dropped), or null when it cannot be read. */
31
+ function readTail(file) {
32
+ try {
33
+ const fd = fs.openSync(file, "r");
34
+ try {
35
+ const size = fs.fstatSync(fd).size;
36
+ const start = Math.max(0, size - TAIL_BYTES);
37
+ const buffer = Buffer.alloc(size - start);
38
+ fs.readSync(fd, buffer, 0, buffer.length, start);
39
+ const text = buffer.toString("utf8");
40
+ return start > 0 ? text.slice(text.indexOf("\n") + 1) : text;
41
+ }
42
+ finally {
43
+ fs.closeSync(fd);
44
+ }
45
+ }
46
+ catch {
47
+ return null;
48
+ }
49
+ }
50
+ function blocksOf(row) {
51
+ return Array.isArray(row.message?.content) ? row.message.content : [];
52
+ }
53
+ /**
54
+ * Characters of assistant text written right before the tool_use `toolUseId` in the same assistant message
55
+ * (Claude Code writes one transcript line per content block, all with the same message.id); null while the tool_use is not there yet.
56
+ */
57
+ export function specChars(transcript, toolUseId) {
58
+ const rows = [];
59
+ for (const line of transcript.split("\n")) {
60
+ try {
61
+ rows.push(JSON.parse(line));
62
+ }
63
+ catch { /* a half-written or foreign line */ }
64
+ }
65
+ const at = rows.findIndex(row => blocksOf(row).some(block => block?.type === "tool_use" && block.id === toolUseId));
66
+ if (at < 0)
67
+ return null;
68
+ const own = blocksOf(rows[at]);
69
+ const blocks = own.slice(0, own.findIndex(block => block?.type === "tool_use" && block.id === toolUseId));
70
+ const messageId = rows[at].message?.id;
71
+ if (typeof messageId === "string") {
72
+ for (let j = at - 1; j >= 0; j -= 1) {
73
+ if (!rows[j].message)
74
+ continue; // bookkeeping rows (ai-title, attachment...) can sit between the blocks of one message
75
+ if (rows[j].message.id !== messageId)
76
+ break;
77
+ blocks.push(...blocksOf(rows[j]));
78
+ }
79
+ }
80
+ const texts = blocks.filter(block => block?.type === "text" && typeof block.text === "string");
81
+ return texts.reduce((sum, block) => sum + block.text.trim().length, 0);
82
+ }
83
+ function stateFile(env) {
84
+ const seat = env.AITERM_SESSION_ID;
85
+ const launch = env.AITERM_AGENT_LAUNCH_ID;
86
+ if (!seat || !launch)
87
+ return null;
88
+ return path.join(runtimeStateBase(), `aiterm-mcp-${currentUid()}`, "agents", `${seat}.${launch}.claude-plan-spec`);
89
+ }
90
+ const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
91
+ export async function planSpecDecision(payload, env = process.env, timing = { waitMs: WAIT_MS, pollMs: POLL_MS }) {
92
+ const input = payload;
93
+ if (!input || typeof input !== "object" || input.hook_event_name !== "PreToolUse" || input.tool_name !== "EnterPlanMode"
94
+ || !AITERM_ENV.some(name => env[name]))
95
+ return null;
96
+ const file = stateFile(env);
97
+ if (!file || typeof input.session_id !== "string" || typeof input.prompt_id !== "string" || typeof input.tool_use_id !== "string"
98
+ || typeof input.transcript_path !== "string" || !path.isAbsolute(input.transcript_path))
99
+ return null;
100
+ const key = `${input.session_id}\n${input.prompt_id}`;
101
+ try {
102
+ if (fs.readFileSync(file, "utf8") === key)
103
+ return null;
104
+ }
105
+ catch { /* nothing recorded yet */ }
106
+ let chars = null;
107
+ for (let waited = 0;; waited += timing.pollMs) {
108
+ const tail = readTail(input.transcript_path);
109
+ if (tail === null)
110
+ return null;
111
+ chars = specChars(tail, input.tool_use_id);
112
+ if (chars !== null || waited >= timing.waitMs)
113
+ break;
114
+ await sleep(timing.pollMs);
115
+ }
116
+ if (chars !== null && chars >= SPEC_MIN_CHARS)
117
+ return null;
118
+ // Record the turn-back first: if it cannot be recorded the second call could not be let through, so allow instead.
119
+ try {
120
+ fs.writeFileSync(file, key, { mode: 0o600 });
121
+ }
122
+ catch {
123
+ return null;
124
+ }
125
+ return { hookSpecificOutput: { hookEventName: "PreToolUse", permissionDecision: "deny", permissionDecisionReason: GUIDANCE } };
126
+ }
127
+ async function main() {
128
+ let payload = null;
129
+ try {
130
+ payload = JSON.parse(await readStdin());
131
+ }
132
+ catch { /* not JSON: no decision */ }
133
+ const decision = await planSpecDecision(payload);
134
+ if (decision)
135
+ process.stdout.write(JSON.stringify(decision) + "\n");
136
+ }
137
+ // Run only as the hook entry; importing it (tests) has no effect.
138
+ if (process.argv[1] && /claude-plan-spec-hook\.js$/.test(process.argv[1]))
139
+ await main();
package/dist/core.js CHANGED
@@ -504,6 +504,7 @@ function cleanupAgentState(name) {
504
504
  /\.antigravity-result-\d+-\d+\.json$/.test(f) ||
505
505
  f.endsWith(".claude-operation.json") ||
506
506
  f.endsWith(".claude-approval.json") ||
507
+ f.endsWith(".claude-plan-spec") ||
507
508
  f.endsWith(".claude-dispatch") ||
508
509
  f.endsWith(".interim.json") ||
509
510
  f.endsWith(".steers.jsonl") ||
@@ -6722,6 +6723,16 @@ function claudeSeatCatalogEnv(name, meta) {
6722
6723
  env[key] = value;
6723
6724
  return env;
6724
6725
  }
6726
+ /** Whether a Claude goal is running on the seat (inside the send lock). Unreadable counts as no goal: the picker path is harmless either way. */
6727
+ async function claudeGoalActive(name, meta) {
6728
+ try {
6729
+ const result = await agentGoalInContext({ session_id: name, launch_id: meta.launch_id, action: "inspect" }, "automatic", undefined, true);
6730
+ return result.availability === "available" && result.goal?.status === "active";
6731
+ }
6732
+ catch {
6733
+ return false;
6734
+ }
6735
+ }
6725
6736
  /** 返りの null は、席の画面が番の最中を示していて、何も打っていない時。 */
6726
6737
  async function configureAgentInLock(name, model, effort, fast, beforeChange) {
6727
6738
  // 席の控えは、行列の順番が来てから読む(前の送信が書いた分を、古い控えで上書きしない)。
@@ -6730,10 +6741,17 @@ async function configureAgentInLock(name, model, effort, fast, beforeChange) {
6730
6741
  let seatEnv;
6731
6742
  const claudeSeatEnv = () => seatEnv === undefined ? (seatEnv = claudeSeatCatalogEnv(name, meta)) : seatEnv;
6732
6743
  // Codexは回答を流している間、動作中の行を出さない(ADR 0101)。送信と同じく記録の番の開始を見て、動いている席へ命令を打たない。
6744
+ // A running Claude turn is changed in place only for model/effort(low-max), with no goal running (model-configuration.md, b8).
6745
+ let inTurn = false;
6733
6746
  if (isAgentTuiBusy(meta.kind, captureScreen(name, AGENT_TUI_READY_LINES))
6734
- || (meta.kind === "codex" && codexRunningTurn(meta) !== null && observeSession(name).harness_alive === true))
6735
- return null;
6736
- const { ready, codexRateLimitModelSwitch } = await waitAgentTuiReadyAfterCodexRateLimitRecovery(name, meta, AGENT_TUI_READY_TIMEOUT_MS);
6747
+ || (meta.kind === "codex" && codexRunningTurn(meta) !== null && observeSession(name).harness_alive === true)) {
6748
+ inTurn = meta.kind === "claude" && fast === null && (model !== null || effort !== null) && model?.toLowerCase() !== "opusplan"
6749
+ && (effort === null || CLAUDE_EFFORTS.has(effort)) && !(await claudeGoalActive(name, meta));
6750
+ if (!inTurn)
6751
+ return null;
6752
+ }
6753
+ const { ready, codexRateLimitModelSwitch } = inTurn ? { ready: { ready: true, lastScreen: "" }, codexRateLimitModelSwitch: false }
6754
+ : await waitAgentTuiReadyAfterCodexRateLimitRecovery(name, meta, AGENT_TUI_READY_TIMEOUT_MS);
6737
6755
  if (!ready.ready) {
6738
6756
  if (codexRateLimitModelSwitch) {
6739
6757
  throw new AitermError(`CODEX_RATE_LIMIT_MODEL_SWITCH_RECOVERY_FAILED: ${codexPaneObservation(ready.lastScreen).reason}。設定変更は送信していません。`, 2);
@@ -6834,7 +6852,7 @@ async function configureAgentInLock(name, model, effort, fast, beforeChange) {
6834
6852
  if (model?.toLowerCase() === "opusplan")
6835
6853
  await switchClaudeOpusPlan(name, meta, beforeChange);
6836
6854
  if (model || level)
6837
- await configureClaudeForSessionOnly(name, meta, model, level, beforeChange, { ...agentModelUi(name), ready: () => waitAgentTuiReady(name, meta, AGENT_TUI_READY_TIMEOUT_MS) }, claudeSeatEnv() ?? process.env);
6855
+ await configureClaudeForSessionOnly(name, meta, model, level, beforeChange, { ...agentModelUi(name), ready: () => waitAgentTuiReady(name, meta, AGENT_TUI_READY_TIMEOUT_MS) }, claudeSeatEnv() ?? process.env, inTurn);
6838
6856
  if (effort && !level) {
6839
6857
  beforeChange();
6840
6858
  await sendAgentPromptText(name, `/effort ${effort}`);
@@ -1,12 +1,15 @@
1
1
  import { AitermError } from "../errors.js";
2
2
  import { sleep } from "../agent-shared.js";
3
3
  import { resolveAgentBin } from "../agent-resolver.js";
4
- import { claudeModelPicker, claudeModelPickerRow, claudePickerRowByName, claudeModelDisplayName, claudeModelSwitchConfirm, claudeModelSwitchResult, claudePaneObservation, claudeModelChoices } from "./claude.js";
4
+ import { claudeModelPicker, claudeModelPickerRow, claudePickerRowByName, claudeModelDisplayName, claudeModelSwitchConfirm, claudeModelSwitchResult, claudeModelSwitchResults, claudePaneObservation, claudeModelChoices } from "./claude.js";
5
5
  const CLAUDE_MODEL_PICKER_TIMEOUT_MS = 8_000;
6
6
  const CLAUDE_MODEL_PICKER_KEY_TIMEOUT_MS = 1_500;
7
7
  const CLAUDE_MODEL_SWITCH_TIMEOUT_MS = 15_000;
8
8
  const CLAUDE_EFFORT_ORDER = ["low", "medium", "high", "xhigh", "max"];
9
- export async function configureClaudeForSessionOnly(name, meta, model, effort, beforeChange, ui, catalogEnv = process.env) {
9
+ export async function configureClaudeForSessionOnly(name, meta, model, effort, beforeChange, ui, catalogEnv = process.env, // the seat's own root and login (model-configuration.md)
10
+ // The seat's turn is running: `/model` would only queue as a user message, so the picker opens with Alt+P, and no Esc or
11
+ // ready wait is used outside the picker (an Esc in a running turn stops it; the turn goes on after the switch).
12
+ inTurn = false) {
10
13
  let selectionIssued = false;
11
14
  const screen = () => ui.screen();
12
15
  const until = async (read, timeoutMs) => {
@@ -47,12 +50,16 @@ export async function configureClaudeForSessionOnly(name, meta, model, effort, b
47
50
  }
48
51
  return null;
49
52
  };
50
- await ui.command("/model");
53
+ const resultsBefore = inTurn ? claudeModelSwitchResults(screen()) : [];
54
+ if (inTurn)
55
+ ui.key("M-p");
56
+ else
57
+ await ui.command("/model");
51
58
  let now = await until(picker, CLAUDE_MODEL_PICKER_TIMEOUT_MS);
52
59
  if (!now) {
53
60
  // 読めない形の画面が開いたままだと、席が次の文を受け取れない。入力待ちでも動作中でもない時だけ、Escを1度打って閉じる。
54
61
  let state = claudePaneObservation(screen());
55
- if (state.state === "unknown") {
62
+ if (!inTurn && state.state === "unknown") {
56
63
  ui.key("Escape");
57
64
  await sleep(500);
58
65
  state = claudePaneObservation(screen());
@@ -174,7 +181,12 @@ export async function configureClaudeForSessionOnly(name, meta, model, effort, b
174
181
  }
175
182
  if (confirm || claudeModelPicker(text))
176
183
  return null;
177
- return claudeModelSwitchResult(text);
184
+ if (!inTurn)
185
+ return claudeModelSwitchResult(text);
186
+ // In a running turn the result has no `❯ /model` line above it: take the newest result line that was not on screen before.
187
+ const seen = (rows, line) => rows.filter(row => row.line === line).length;
188
+ const rows = claudeModelSwitchResults(text);
189
+ return rows.filter(row => seen(rows, row.line) > seen(resultsBefore, row.line)).at(-1) ?? null;
178
190
  }, CLAUDE_MODEL_SWITCH_TIMEOUT_MS);
179
191
  if (!result)
180
192
  return refuse("CLAUDE_MODEL_SWITCH_UNCONFIRMED", "Claude Codeの切り替えの知らせを確認できません");
@@ -186,6 +198,8 @@ export async function configureClaudeForSessionOnly(name, meta, model, effort, b
186
198
  throw new AitermError(`CLAUDE_MODEL_SWITCH_REFUSED vendor=claude session=${name}\n` +
187
199
  `Claude Codeがmodelを切り替えませんでした(${result.line})。modelとreasoning_effortは変えていません。`, 2);
188
200
  }
201
+ if (inTurn)
202
+ return; // the turn keeps running on the new model; there is no composer to wait for
189
203
  const ready = await ui.ready();
190
204
  if (!ready.ready)
191
205
  throw new AitermError("Claudeのmodel変更完了を確認できません", 2);
@@ -79,6 +79,9 @@ export function agentClaudeDispatchReceiptPath(name, launchId, operationId) {
79
79
  function claudePlanApproveScriptPath() {
80
80
  return path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "claude-plan-approve-hook.js");
81
81
  }
82
+ function claudePlanSpecScriptPath() {
83
+ return path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "claude-plan-spec-hook.js");
84
+ }
82
85
  function claudeHookScriptPath() {
83
86
  // この module は dist/harnesses/ に置かれるが、stop hook 実体は dist/ 直下に build される。
84
87
  return path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "claude-stop-hook.js");
@@ -105,6 +108,10 @@ export function createClaudeCorrelationSettings(name, launchId, model, effort) {
105
108
  if (!fs.existsSync(planScript)) {
106
109
  throw new AitermError(`Claude plan approve hook が見つかりません。npm run build を実行してください: ${planScript}`, 2);
107
110
  }
111
+ const specScript = claudePlanSpecScriptPath();
112
+ if (!fs.existsSync(specScript)) {
113
+ throw new AitermError(`Claude plan spec hook が見つかりません。npm run build を実行してください: ${specScript}`, 2);
114
+ }
108
115
  const settings = agentManagedClaudeSettingsPath(name, launchId);
109
116
  writeJson0600(settings, {
110
117
  ...(model ? { model } : {}),
@@ -128,6 +135,10 @@ export function createClaudeCorrelationSettings(name, launchId, model, effort) {
128
135
  PermissionRequest: [
129
136
  { matcher: "ExitPlanMode", hooks: [{ type: "command", command: nodeHookCommand(planScript), timeout: 10 }] },
130
137
  ],
138
+ // EnterPlanMode without a written spec drops an unattended seat into plan mode's ask-the-user flow; turn it back once (harness-contracts.md).
139
+ PreToolUse: [
140
+ { matcher: "EnterPlanMode", hooks: [{ type: "command", command: nodeHookCommand(specScript), timeout: 10 }] },
141
+ ],
131
142
  },
132
143
  });
133
144
  return settings;
@@ -624,14 +635,7 @@ export function claudeModelSwitchConfirm(screen) {
624
635
  return null;
625
636
  return body.some((line) => /^\s*❯\s*1\.\s*Yes, switch\b/u.test(line)) ? "yes_selected" : "other_selected";
626
637
  }
627
- export function claudeModelSwitchResult(screen) {
628
- const lines = screen.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, "").split(/\r?\n/u);
629
- const command = lastLineIndex(lines, /^\s*❯\s*\/model(?:\s+\S+)?\s*$/u);
630
- if (command < 0)
631
- return null;
632
- const start = lines.findIndex((line, i) => i > command && /^\s*⎿\s+\S/u.test(line));
633
- if (start < 0)
634
- return null;
638
+ function switchResultAt(lines, start) {
635
639
  const parts = [lines[start].replace(/^\s*⎿\s+/u, "").trim()];
636
640
  for (const line of lines.slice(start + 1)) {
637
641
  if (!/^\s{3,}\S/u.test(line) || /^\s*⎿/u.test(line))
@@ -649,6 +653,22 @@ export function claudeModelSwitchResult(screen) {
649
653
  return { scope: "saved_as_default", line };
650
654
  return /\bfor this session only\b/u.test(line) ? { scope: "session_only", line } : null;
651
655
  }
656
+ export function claudeModelSwitchResult(screen) {
657
+ const lines = screen.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, "").split(/\r?\n/u);
658
+ const command = lastLineIndex(lines, /^\s*❯\s*\/model(?:\s+\S+)?\s*$/u);
659
+ if (command < 0)
660
+ return null;
661
+ const start = lines.findIndex((line, i) => i > command && /^\s*⎿\s+\S/u.test(line));
662
+ return start < 0 ? null : switchResultAt(lines, start);
663
+ }
664
+ /**
665
+ * Every switch result line on the screen, oldest first. A switch made with Alt+P in a running turn prints its result with no
666
+ * `❯ /model` line above it (2.1.325), so the caller compares against the lines present before the picker was opened.
667
+ */
668
+ export function claudeModelSwitchResults(screen) {
669
+ const lines = screen.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, "").split(/\r?\n/u);
670
+ return lines.flatMap((text, i) => /^\s*⎿\s+\S/u.test(text) ? [switchResultAt(lines, i)] : []).filter(row => row !== null);
671
+ }
652
672
  // Claude Code 2.1.282 は選択肢へ「1.」などの番号を付ける。番号の有無のどちらも受ける。
653
673
  export function claudeLoginMethodMenu(screen) {
654
674
  const tail = screen.split("\n").slice(-32).join("\n");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiterm-mcp",
3
- "version": "0.70.66",
3
+ "version": "0.70.68",
4
4
  "mcpName": "io.github.kitepon/aiterm-mcp",
5
5
  "description": "Persistent terminal MCP with one harness-based launcher for Claude Code, Codex CLI, Grok CLI, Cursor Agent CLI, and Antigravity CLI, plus durable PTYs for SSH, containers, and REPLs.",
6
6
  "keywords": [