zcode-app-cli 3.17.1-43 → 3.17.2-45

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.
@@ -23,7 +23,7 @@ their upstream originals byte for byte.
23
23
  revision. It is copied in its original language.
24
24
 
25
25
  The public source revision declares version 3.14.0. It is distinct from the
26
- Desktop 3.17.1 artifact pinned by this project's runtime lock. These notices
26
+ Desktop 3.17.2 artifact pinned by this project's runtime lock. These notices
27
27
  preserve upstream attribution; they are not a claim that this CLI was built
28
28
  from that exact commit. The third-party inventory covers multiple upstream
29
29
  distributions and may list components absent from our npm package.
package/README.md CHANGED
@@ -146,6 +146,14 @@ cycling (Tab also cycles effort on an empty prompt); structured session-goal sta
146
146
  animated active-turn timer with a static `ZCODE_TUI_REDUCED_MOTION=1`
147
147
  fallback; responsive context-remaining and session-token metrics.
148
148
 
149
+ **Session discovery.** Bare `/resume` opens a directory-scoped picker;
150
+ `/sessions` browses desktop and CLI sessions across directories, including forks
151
+ and workflow parents. Filter by title, directory or session ID, inspect details
152
+ with Ctrl+O, then press Enter to resume. Both pickers use the runtime's configured
153
+ session database, including `storage.sessionDbPath` and `ZCODE_SESSION_DB_PATH` overrides.
154
+ Cross-directory resumes update the displayed workspace and Git branch, file
155
+ completion and `/diff` to follow the restored session's working directory.
156
+
149
157
  **Login and permissions.** `/login` setup choices with masked API-key entry,
150
158
  redacted transcript/history and OAuth waiting state; suspended Z.AI browser
151
159
  login with terminal restoration and an optional `ZCODE_TUI_LOGIN_CMD`
package/bin/zcode.js CHANGED
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env node
2
- import { spawn } from "node:child_process";
2
+ import { execFile, spawn } from "node:child_process";
3
3
  import { appendFileSync, chmodSync, existsSync, mkdirSync, readFileSync, renameSync, statSync, unlinkSync } from "node:fs";
4
4
  import { constants, homedir, tmpdir } from "node:os";
5
5
  import { basename, dirname, join, posix, resolve, sep, win32 } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
7
  import { createHash, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
8
8
  import { access, chmod, link, mkdir, mkdtemp, open, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
9
+ import { parseArgs, promisify } from "node:util";
9
10
  import { AsyncLocalStorage } from "node:async_hooks";
10
11
  import { StringDecoder } from "node:string_decoder";
11
12
  import { createInterface } from "node:readline/promises";
12
- import { parseArgs } from "node:util";
13
13
  //#region setting.example.json
14
14
  var setting_example_default = {
15
15
  modelStream: { "idleTimeoutMs": 6e4 },
@@ -339,6 +339,7 @@ async function markSetupPending(env = process.env) {
339
339
  async function clearSetupPending(env = process.env) {
340
340
  await rm(setupPendingPath(env), { force: true }).catch(() => {});
341
341
  }
342
+ promisify(execFile);
342
343
  new AsyncLocalStorage();
343
344
  //#endregion
344
345
  //#region src/runtime-config-bridge.ts
@@ -32,6 +32,10 @@ Hook trust commands use that file's `storage.dir` too. Providers, credentials an
32
32
  the session database (including persisted project permissions) have separate path
33
33
  overrides; changing only the settings file does not isolate those stores. See
34
34
  [host integration](HOST_INTEGRATION.md#environment-and-configuration) for examples.
35
+ The `/resume` and `/sessions` pickers use the active runtime's session database,
36
+ respecting `storage.sessionDbPath` and `ZCODE_SESSION_DB_PATH` overrides.
37
+ Resuming a session from another directory also switches the TUI's workspace path,
38
+ Git branch, file completion and `/diff` to that session's working directory.
35
39
  Desktop preferences remain in `~/.zcode/v2/setting.json`; Desktop's user hooks and
36
40
  MCP configuration in `~/.zcode/cli/config.json` are not continuously synchronized
37
41
  with the CLI settings file.
@@ -205,7 +209,7 @@ Plugin controls remain under `plugins`, hook declarations under
205
209
  These paths distinguish the packaged CLI from the upstream application. The
206
210
  source references below are pinned to upstream
207
211
  [`29628c9` / `v3.14.3`](https://github.com/zai-org/ZCode/tree/29628c9acdb81b703bbd4080c207a0e7ce5e276e).
208
- This package's runtime lock selects the separate Desktop 3.17.1 / runtime 0.17.1 artifact; the
212
+ This package's runtime lock selects the separate Desktop 3.17.2 / runtime 0.17.1 artifact; the
209
213
  public source snapshot is not an assertion of that artifact's build commit.
210
214
  The configuration boundaries were rechecked on 2026-10-20 against
211
215
  [`0a1fc56` / `0.17.0`](https://github.com/zai-org/ZCode/tree/0a1fc56d279fd1001f78387bd81aec1c26767411).
@@ -28,6 +28,9 @@ CLI 通用设置默认使用用户目录中的 `~/.zcode/cli/setting.json`。
28
28
  旧 `config.json` 和 `migrations/` 标记使用所选文件所在目录,hook 信任命令也读取该文件的
29
29
  `storage.dir`。Provider、凭证和会话数据库(含持久化项目权限)有各自的路径覆盖变量,
30
30
  仅切换设置文件不会隔离这些存储,示例见[宿主集成](HOST_INTEGRATION.md#environment-and-configuration)。
31
+ `/resume` 和 `/sessions` 选择器读取当前 runtime 实际使用的会话数据库,遵循
32
+ `storage.sessionDbPath` 和 `ZCODE_SESSION_DB_PATH` 的路径覆盖。
33
+ 跨目录恢复会话时,TUI 显示的工作区路径、Git 分支、文件补全和 `/diff` 也同步切换到该会话的工作目录。
31
34
  Desktop 偏好仍位于 `~/.zcode/v2/setting.json`;桌面端保存在 `~/.zcode/cli/config.json`
32
35
  中的用户 hooks 和 MCP 配置不会与 CLI 设置文件持续同步。
33
36
 
@@ -176,7 +179,7 @@ CLI 目前没有信任管理命令,可在 Desktop 中批准相应工作区声
176
179
 
177
180
  下面区分本发行包与上游应用。源码引用固定在上游
178
181
  [`29628c9` / `v3.14.3`](https://github.com/zai-org/ZCode/tree/29628c9acdb81b703bbd4080c207a0e7ce5e276e)。
179
- 本项目 runtime lock 选择的是独立发布的 Desktop 3.17.1 / runtime 0.17.1 产物,不能据此认定该产物
182
+ 本项目 runtime lock 选择的是独立发布的 Desktop 3.17.2 / runtime 0.17.1 产物,不能据此认定该产物
180
183
  由这个公开源码提交构建。
181
184
  2026-10-20 已针对
182
185
  [`0a1fc56` / `0.17.0`](https://github.com/zai-org/ZCode/tree/0a1fc56d279fd1001f78387bd81aec1c26767411)
@@ -18,7 +18,7 @@ compatibility patches applied.
18
18
 
19
19
  The [upstream notices shipped here](../LICENSES/README.md) come from a separately
20
20
  pinned public source revision. That revision declares version 3.14.0; the current
21
- runtime lock selects Desktop 3.17.1. The notices are a conservative upstream
21
+ runtime lock selects Desktop 3.17.2. The notices are a conservative upstream
22
22
  inventory, not proof that the extracted binary was built from that exact commit
23
23
  or that every listed component is included in this npm package. Review artifact
24
24
  contents and applicable terms when updating the runtime.
@@ -44,6 +44,9 @@ patches; the patch report is in `vendor/extraction.json`.
44
44
  These are the declarations observed in the Desktop 3.16.3 packages, not a
45
45
  replacement for nested dependency or asset licenses:
46
46
 
47
+ Desktop 3.17.2 also includes `zcode-site-plugin` 0.4.2, whose package and plugin
48
+ manifests declare MIT. Its bundled `dist/THIRD_PARTY_NOTICES.txt` is retained.
49
+
47
50
  | Package directory | Manifest declaration |
48
51
  | --- | --- |
49
52
  | `browser-use-plugin` | MIT |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zcode-app-cli",
3
- "version": "3.17.1-43",
3
+ "version": "3.17.2-45",
4
4
  "description": "Unofficial terminal client for the ZCode agent runtime",
5
5
  "keywords": [
6
6
  "agent",
@@ -4,6 +4,8 @@ let node_fs_promises = require("node:fs/promises");
4
4
  let node_path = require("node:path");
5
5
  let node_crypto = require("node:crypto");
6
6
  let node_os = require("node:os");
7
+ let node_child_process = require("node:child_process");
8
+ let node_util = require("node:util");
7
9
  let node_async_hooks = require("node:async_hooks");
8
10
  let node_buffer = require("node:buffer");
9
11
  //#region src/config-paths.ts
@@ -115,8 +117,38 @@ async function readSessionResumeTarget(app) {
115
117
  const session = await store.getSession(sessionId);
116
118
  return session && session.time?.deleted === void 0 ? sessionId : void 0;
117
119
  }
120
+ function readSessionDatabasePath(app) {
121
+ return (app.sessionStore ?? app.runtime?.sessionStore)?.getDatabasePath?.();
122
+ }
123
+ /**
124
+ * Back the runtime's native `/resume` picker (which renders only when the app
125
+ * facade exposes `listSessions`). Directory-scoped to match the runtime's own
126
+ * semantics; deleted sessions are excluded by the store itself.
127
+ */
128
+ async function listSessionsForPicker(app) {
129
+ const store = app.sessionStore ?? app.runtime?.sessionStore;
130
+ if (!store?.listSessions) return [];
131
+ const directory = app.directory ?? app.runtime?.directory ?? process.cwd();
132
+ return (await store.listSessions({
133
+ directory,
134
+ limit: 50,
135
+ taskTypes: [
136
+ "interactive",
137
+ "fork",
138
+ "workflow_parent"
139
+ ]
140
+ })).map((row) => ({
141
+ id: row.id,
142
+ title: row.title ?? "",
143
+ directory: row.directory ?? directory,
144
+ updatedAt: row.time?.updated ?? row.time?.created ?? 0,
145
+ parentId: row.parentID ?? null
146
+ }));
147
+ }
118
148
  //#endregion
119
149
  //#region src/runtime-tui-bridge.ts
150
+ const execFileAsync = (0, node_util.promisify)(node_child_process.execFile);
151
+ const workspaceSnapshots = /* @__PURE__ */ new WeakMap();
120
152
  const maximumTaskMessageLength = 2e4;
121
153
  const maximumTaskSummaryLength = 200;
122
154
  function taskDetail(task) {
@@ -144,6 +176,30 @@ function taskDetail(task) {
144
176
  cancellable: kind === "local_agent" ? running : task.cancellable
145
177
  };
146
178
  }
179
+ async function readRuntimeWorkspace(runtime) {
180
+ const directory = runtime?.workingDirectory;
181
+ if (!runtime || !directory) return void 0;
182
+ const cached = workspaceSnapshots.get(runtime);
183
+ if (cached?.directory === directory) return await cached.snapshot;
184
+ const snapshot = execFileAsync("git", ["branch", "--show-current"], {
185
+ cwd: directory,
186
+ timeout: 1e3,
187
+ maxBuffer: 16 * 1024,
188
+ windowsHide: true,
189
+ env: {
190
+ ...process.env,
191
+ GIT_OPTIONAL_LOCKS: "0"
192
+ }
193
+ }).then(({ stdout }) => ({
194
+ directory,
195
+ branch: stdout.trim() || void 0
196
+ }), () => ({ directory }));
197
+ workspaceSnapshots.set(runtime, {
198
+ directory,
199
+ snapshot
200
+ });
201
+ return await snapshot;
202
+ }
147
203
  async function readTuiRuntimeProjection(app, bridge) {
148
204
  const executionState = await app.readExecutionState();
149
205
  await bridge.$zRestorePersistedBackgroundTasks?.(app);
@@ -162,6 +218,7 @@ async function readTuiRuntimeProjection(app, bridge) {
162
218
  return {
163
219
  ...projection,
164
220
  ...executionState && typeof executionState === "object" ? executionState : {},
221
+ workspace: await readRuntimeWorkspace(app.runtime),
165
222
  backgroundTasks: tasks,
166
223
  backgroundTaskDetails: details,
167
224
  restoredBackgroundTasks: Array.isArray(app.$zRestoredBackgroundTasksLog) ? app.$zRestoredBackgroundTasksLog : []
@@ -1253,10 +1310,12 @@ exports.ensureSessionForTitle = ensureSessionForTitle;
1253
1310
  exports.exchangeBigmodelOAuthCode = exchangeBigmodelOAuthCode;
1254
1311
  exports.inspectRuntimeConfiguration = inspectRuntimeConfiguration;
1255
1312
  exports.installSqliteWriteRecovery = installSqliteWriteRecovery;
1313
+ exports.listSessionsForPicker = listSessionsForPicker;
1256
1314
  exports.mergeDesktopSettings = mergeDesktopSettings;
1257
1315
  exports.migrateLegacyProviders = migrateLegacyProviders;
1258
1316
  exports.providerMigrationNeeded = providerMigrationNeeded;
1259
1317
  exports.pruneSqliteUsage = pruneSqliteUsage;
1318
+ exports.readSessionDatabasePath = readSessionDatabasePath;
1260
1319
  exports.readSessionModelState = readSessionModelState;
1261
1320
  exports.readSessionResumeTarget = readSessionResumeTarget;
1262
1321
  exports.readStartPlanSession = readStartPlanSession;
@@ -1,9 +1,9 @@
1
1
  {
2
- "appVersion": "3.17.1",
2
+ "appVersion": "3.17.2",
3
3
  "cliVersion": "0.17.1",
4
- "extractedAt": "2026-11-01T05:57:40.797Z",
5
- "sha512": "/vGkWK4TkWLGzS7tV66j7B7wlPuwWIlaZwaRKHNnzkkz1sNwr745qhPwtCDx+3nbE8iI6KcSCcfov72u1ApCmA==",
6
- "source": "https://cdn-zcode.z.ai/zcode/electron/releases/3.17.1/linux-x64/ZCode-3.17.1-linux-x64.deb",
4
+ "extractedAt": "2026-11-05T16:00:27.210Z",
5
+ "sha512": "d+0Fn/LD8C33LbxzD9jV3Er1JKg9uHii+mcSakVGd1o93WQtCNkfzrOR1DKCk6j2f26YjY5XbgWBYwCY6ROfqg==",
6
+ "source": "https://cdn-zcode.z.ai/zcode/electron/releases/3.17.2/linux-x64/ZCode-3.17.2-linux-x64.deb",
7
7
  "runtimeCapabilities": {
8
8
  "schemaVersion": 1,
9
9
  "cli": {
@@ -7,6 +7,7 @@ import { basename, dirname, extname, isAbsolute, join, posix, resolve, sep, win3
7
7
  import { randomUUID } from "node:crypto";
8
8
  import { Box, CombinedAutocompleteProvider, Container, Editor, Image, Input, Markdown, ProcessTerminal, ScrollView, SelectList, Spacer, Text, TuiAltScreen, TuiMainScreen, VStack, decodeKittyPrintable, getKeybindings, isKeyRelease, isViewportTUI, matchesKey, renderFakeCursor, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
9
9
  import { AltScreenSearchComponent } from "@earendil-works/pi-tui/dist/alt-screen-search.js";
10
+ import { DatabaseSync } from "node:sqlite";
10
11
  import { StringDecoder } from "node:string_decoder";
11
12
  import { isDeepStrictEqual } from "node:util";
12
13
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
@@ -157381,6 +157382,120 @@ function deliveredBackgroundTaskIds(messages) {
157381
157382
  return delivered;
157382
157383
  }
157383
157384
  //#endregion
157385
+ //#region packages/zcode-tui/src/session-picker.ts
157386
+ function defaultCliDbPath(home) {
157387
+ return join(home, ".zcode", "cli", "db", "db.sqlite");
157388
+ }
157389
+ function defaultTasksDbPath(home) {
157390
+ return join(home, ".zcode", "v2", "tasks-index.sqlite");
157391
+ }
157392
+ function openReadOnly(path) {
157393
+ try {
157394
+ return new DatabaseSync(path, { readOnly: true });
157395
+ } catch {
157396
+ return;
157397
+ }
157398
+ }
157399
+ function desktopTaskInfo(tasksDbPath) {
157400
+ const result = /* @__PURE__ */ new Map();
157401
+ const db = openReadOnly(tasksDbPath);
157402
+ if (!db) return result;
157403
+ try {
157404
+ const rows = db.prepare("SELECT task_id, title, pinned, archived FROM tasks WHERE deleted = 0").all();
157405
+ for (const row of rows) result.set(row.task_id, {
157406
+ title: row.title ?? "",
157407
+ pinned: row.pinned === 1,
157408
+ archived: row.archived === 1
157409
+ });
157410
+ } catch {} finally {
157411
+ db.close();
157412
+ }
157413
+ return result;
157414
+ }
157415
+ function firstLine(value) {
157416
+ return value.split("\n", 1)[0] ?? value;
157417
+ }
157418
+ /**
157419
+ * List recent resumable sessions from the shared ZCode session store.
157420
+ *
157421
+ * The desktop app and the CLI persist sessions in the same SQLite database,
157422
+ * so this surfaces desktop conversations as well as CLI ones. Desktop titles
157423
+ * and pinned/archived flags come from the desktop's task index when present.
157424
+ * All databases are opened read-only and failures degrade gracefully.
157425
+ */
157426
+ function listRecentSessions(options = {}) {
157427
+ const home = options.home ?? homedir();
157428
+ const db = openReadOnly(options.cliDbPath ?? defaultCliDbPath(home));
157429
+ if (!db) return [];
157430
+ try {
157431
+ const rows = db.prepare(`SELECT s.id, s.title, s.directory, s.time_updated,
157432
+ (SELECT COUNT(*) FROM message m WHERE m.session_id = s.id) AS message_count
157433
+ FROM session s
157434
+ WHERE s.task_type IN ('interactive', 'fork', 'workflow_parent')
157435
+ AND s.time_deleted IS NULL
157436
+ AND s.id NOT LIKE 'sess_subagent%'
157437
+ ORDER BY s.time_updated DESC
157438
+ LIMIT ?`).all(options.limit ?? 200);
157439
+ const tasks = desktopTaskInfo(options.tasksDbPath ?? defaultTasksDbPath(home));
157440
+ const summaries = [];
157441
+ for (const row of rows) {
157442
+ if (options.excludeIds?.has(row.id)) continue;
157443
+ const task = tasks.get(row.id);
157444
+ const inDesktopWorkspace = row.directory.startsWith(join(home, ".zcode", "workspace"));
157445
+ summaries.push({
157446
+ id: row.id,
157447
+ title: firstLine(task?.title || row.title || "(untitled)"),
157448
+ directory: row.directory,
157449
+ timeUpdated: row.time_updated,
157450
+ messageCount: row.message_count,
157451
+ source: task !== void 0 || inDesktopWorkspace ? "desktop" : "cli",
157452
+ pinned: task?.pinned ?? false,
157453
+ archived: task?.archived ?? false
157454
+ });
157455
+ }
157456
+ return summaries;
157457
+ } catch {
157458
+ return [];
157459
+ } finally {
157460
+ db.close();
157461
+ }
157462
+ }
157463
+ function formatSessionTimestamp(timeUpdated) {
157464
+ const date = new Date(timeUpdated);
157465
+ if (Number.isNaN(date.getTime())) return "?";
157466
+ const pad = (value) => String(value).padStart(2, "0");
157467
+ return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
157468
+ }
157469
+ function sessionDetail(session, currentDirectory) {
157470
+ const lines = [
157471
+ session.title,
157472
+ "",
157473
+ `Session: ${session.id}`,
157474
+ `Directory: ${session.directory}`,
157475
+ `Updated: ${formatSessionTimestamp(session.timeUpdated)} · ${session.messageCount} messages · ${session.source}${session.pinned ? " · pinned" : ""}${session.archived ? " · archived" : ""}`
157476
+ ];
157477
+ if (currentDirectory && session.directory !== currentDirectory) lines.push("", "This session belongs to another directory.");
157478
+ return lines.join("\n");
157479
+ }
157480
+ function sessionPreview(session, currentDirectory) {
157481
+ return new Text(sanitizeTerminalText(sessionDetail(session, currentDirectory), { preserveSgr: false }), 1, 0);
157482
+ }
157483
+ function sessionChoiceItem(session, currentDirectory) {
157484
+ return {
157485
+ value: session.id,
157486
+ label: `${session.pinned ? "★ " : ""}${session.title}`,
157487
+ description: [
157488
+ formatSessionTimestamp(session.timeUpdated),
157489
+ `${session.messageCount} msg${session.messageCount === 1 ? "" : "s"}`,
157490
+ session.source,
157491
+ session.directory
157492
+ ].join(" · "),
157493
+ keywords: [session.id],
157494
+ preview: sessionPreview(session, currentDirectory),
157495
+ payload: session
157496
+ };
157497
+ }
157498
+ //#endregion
157384
157499
  //#region packages/zcode-tui/src/background-task-output.ts
157385
157500
  const defaultMaximumBytes = 64 * 1024;
157386
157501
  function readBackgroundTaskOutput(path, maximumBytes = defaultMaximumBytes) {
@@ -157892,7 +158007,8 @@ function choose(ui, host, theme, options) {
157892
158007
  const safeItem = {
157893
158008
  ...item,
157894
158009
  label: sanitizeTerminalText(item.label, { preserveSgr: false }),
157895
- description: item.description ? sanitizeTerminalText(item.description, { preserveSgr: false }) : void 0
158010
+ description: item.description ? sanitizeTerminalText(item.description, { preserveSgr: false }) : void 0,
158011
+ keywords: item.keywords?.map((keyword) => sanitizeTerminalText(keyword, { preserveSgr: false }))
157896
158012
  };
157897
158013
  const displayLabel = numberShortcutsEnabled ? `${index + 1}. ${safeItem.label}` : safeItem.label;
157898
158014
  const value = `${safeItem.label}\u0000${index}`;
@@ -157901,7 +158017,8 @@ function choose(ui, host, theme, options) {
157901
158017
  return {
157902
158018
  value,
157903
158019
  label: displayLabel,
157904
- description: safeItem.description
158020
+ description: safeItem.description,
158021
+ keywords: safeItem.keywords
157905
158022
  };
157906
158023
  });
157907
158024
  const hasDetails = Boolean(options.content || options.showSelectedItemDetails || options.items.some((item) => item.preview));
@@ -157912,7 +158029,7 @@ function choose(ui, host, theme, options) {
157912
158029
  const maxExpandedContentLines = Math.max(2, maxContentLines, ui.terminal.rows - 8);
157913
158030
  const dialog = new ChoiceDialog(sanitizeTerminalText(options.title, { preserveSgr: false }), sanitizeTerminalText(options.prompt, { preserveSgr: false }), sanitizeTerminalText(options.help ?? (hasDetails ? numberShortcutsEnabled ? "Type to filter · number selects · Up/Down choose · Ctrl+O details · ←/→ or PgUp/PgDn scroll · Enter confirm · Esc cancel" : "Type to filter · Up/Down choose · Ctrl+O details · ←/→ or PgUp/PgDn scroll · Enter confirm · Esc cancel" : numberShortcutsEnabled ? "Type to filter · number selects · Up/Down choose · Enter confirm · Esc cancel · Ctrl+U clear" : "Type to filter · Up/Down choose · Enter confirm · Esc cancel · Ctrl+U clear"), { preserveSgr: false }), list, theme, options.content, sanitizeTerminalText(options.contentLabel ?? "Details", { preserveSgr: false }), maxContentLines, maxExpandedContentLines, options.filterMode === "substring" ? (filter) => {
157914
158031
  const query = filter.toLowerCase();
157915
- return new SelectList(searchableItems.filter((item) => item.label.toLowerCase().includes(query) || item.description?.toLowerCase().includes(query)), maxVisible, theme.select);
158032
+ return new SelectList(searchableItems.filter((item) => item.label.toLowerCase().includes(query) || item.description?.toLowerCase().includes(query) || item.keywords?.some((keyword) => keyword.toLowerCase().includes(query))), maxVisible, theme.select);
157916
158033
  } : void 0);
157917
158034
  dialog.numberShortcutCount = numberShortcutsEnabled ? options.items.length : 0;
157918
158035
  const previewFor = (item) => {
@@ -163426,8 +163543,14 @@ function normalizeRuntimeProjection(value) {
163426
163543
  const rawLastError = isRecord(projection.lastError) ? projection.lastError : void 0;
163427
163544
  const lastErrorType = rawLastError && stringField(rawLastError, "type");
163428
163545
  const lastErrorMessage = rawLastError && stringField(rawLastError, "message");
163546
+ const workspace = isRecord(projection.workspace) ? projection.workspace : void 0;
163547
+ const workspaceDirectory = workspace && asString(workspace.directory);
163429
163548
  return {
163430
163549
  sessionId: stringField(projection, "sessionId", "sessionID", "id"),
163550
+ workspace: workspaceDirectory ? {
163551
+ directory: workspaceDirectory,
163552
+ branch: stringField(workspace, "branch")
163553
+ } : void 0,
163431
163554
  status: stringField(projection, "status"),
163432
163555
  mode: stringField(projection, "mode"),
163433
163556
  planEnabled: typeof projection.planEnabled === "boolean" ? projection.planEnabled : void 0,
@@ -166026,6 +166149,10 @@ var FullscreenHeader = class {
166026
166149
  setPhase(phase) {
166027
166150
  this.phase = phase;
166028
166151
  }
166152
+ setWorkspace(workspace, branch) {
166153
+ this.workspace = clean(workspace) ?? "";
166154
+ this.branch = clean(branch);
166155
+ }
166029
166156
  getPhase() {
166030
166157
  return this.phase;
166031
166158
  }
@@ -166783,6 +166910,8 @@ var ZCodeTui = class {
166783
166910
  deliveredStreamEvents = createStreamEventRedeliveryFilter();
166784
166911
  notifications;
166785
166912
  skillCatalog;
166913
+ workspaceDirectory;
166914
+ workspaceGitBranch;
166786
166915
  done;
166787
166916
  resolveDone;
166788
166917
  stopped = false;
@@ -166896,13 +167025,14 @@ var ZCodeTui = class {
166896
167025
  this.distributionVersion = sanitizeTerminalText(process.env.ZCODE_APP_CLI_VERSION?.trim() ?? "", { preserveSgr: false }) || void 0;
166897
167026
  this.theme = createTheme(this.colorsEnabled, initialColorScheme(this.themePreference));
166898
167027
  this.transcript = new Transcript(this.theme.searchMatch);
166899
- const workspace = options.workspaceDirectory ?? process.cwd();
167028
+ this.workspaceDirectory = options.workspaceDirectory ?? process.cwd();
167029
+ this.workspaceGitBranch = options.workspaceGitBranch;
166900
167030
  const runtimeVersion = sanitizeTerminalText(options.version ?? "unknown", { preserveSgr: false });
166901
167031
  this.fullscreenHeader = new FullscreenHeader(this.theme, {
166902
- branch: options.workspaceGitBranch,
167032
+ branch: this.workspaceGitBranch,
166903
167033
  distributionVersion: this.distributionVersion,
166904
167034
  runtimeVersion,
166905
- workspace
167035
+ workspace: this.workspaceDirectory
166906
167036
  });
166907
167037
  this.sessionWelcome = new SessionWelcome(this.theme, (width) => this.fullscreenHeader.location(width), (width) => this.fullscreenHeader.identity(width), {
166908
167038
  loginRequired: options.loginRequired === true,
@@ -167002,6 +167132,7 @@ var ZCodeTui = class {
167002
167132
  return;
167003
167133
  }
167004
167134
  await this.resolveTerminalColorScheme();
167135
+ await this.refreshWorkspace();
167005
167136
  this.buildLayout();
167006
167137
  if (notificationConfigError) this.addNotice(`Unable to load notification settings: ${notificationConfigError}`, "warning");
167007
167138
  await this.restoreInitialTranscript();
@@ -167261,12 +167392,34 @@ var ZCodeTui = class {
167261
167392
  editor.isTerminalFocused = () => this.terminalFocus !== "unfocused";
167262
167393
  if (this.options.locale?.startsWith("zh")) editor.planHint = "先调研与规划,再开始修改";
167263
167394
  for (const input of [...this.editorHistory].reverse()) editor.addToHistory(input);
167264
- const commands = this.autocompleteCommands();
167265
- const workspaceDirectory = this.options.workspaceDirectory ?? process.cwd();
167266
- editor.setAutocompleteProvider(new WorkspaceAutocompleteProvider(commands, workspaceDirectory, this.options.listWorkspacePathSuggestions, this.skillCatalog, this.options.listPluginReferences ?? createRuntimePluginReferenceLister(workspaceDirectory), (this.options.slashCommands ?? []).flatMap((command) => command.aliases ?? [])));
167395
+ this.configureWorkspaceAutocomplete(editor);
167267
167396
  editor.onSubmit = (text) => void this.submit(text);
167268
167397
  return editor;
167269
167398
  }
167399
+ configureWorkspaceAutocomplete(editor) {
167400
+ const commands = this.autocompleteCommands();
167401
+ editor.setAutocompleteProvider(new WorkspaceAutocompleteProvider(commands, this.workspaceDirectory, this.options.listWorkspacePathSuggestions, this.skillCatalog, this.options.listPluginReferences ?? createRuntimePluginReferenceLister(this.workspaceDirectory), (this.options.slashCommands ?? []).flatMap((command) => command.aliases ?? [])));
167402
+ }
167403
+ applyWorkspace(workspace) {
167404
+ if (!workspace) return;
167405
+ const directoryChanged = workspace.directory !== this.workspaceDirectory;
167406
+ if (!directoryChanged && workspace.branch === this.workspaceGitBranch) return;
167407
+ this.workspaceDirectory = workspace.directory;
167408
+ this.workspaceGitBranch = workspace.branch;
167409
+ this.fullscreenHeader.setWorkspace(this.workspaceDirectory, this.workspaceGitBranch);
167410
+ if (directoryChanged) {
167411
+ this.skillCatalog = new SkillCatalog(this.options.listSkills);
167412
+ this.configureWorkspaceAutocomplete(this.editor);
167413
+ }
167414
+ this.ui.requestRender(true);
167415
+ }
167416
+ async refreshWorkspace() {
167417
+ const revision = this.executionStateRevision;
167418
+ try {
167419
+ const projection = normalizeRuntimeProjection(await this.options.readRuntimeProjection?.());
167420
+ if (revision === this.executionStateRevision) this.applyWorkspace(projection?.workspace);
167421
+ } catch {}
167422
+ }
167270
167423
  focusEditor() {
167271
167424
  this.ui.setFocus(this.editor);
167272
167425
  }
@@ -167505,6 +167658,10 @@ var ZCodeTui = class {
167505
167658
  name: "diff",
167506
167659
  description: "Browse current and per-turn file changes"
167507
167660
  },
167661
+ {
167662
+ name: "sessions",
167663
+ description: "Browse and resume past sessions (desktop and CLI)"
167664
+ },
167508
167665
  {
167509
167666
  name: "context",
167510
167667
  description: "Inspect context usage and prompt composition"
@@ -167691,7 +167848,7 @@ var ZCodeTui = class {
167691
167848
  if (!await preflightSubmission({
167692
167849
  validate: () => this.sessionModelIssue ? Promise.resolve(`${this.sessionModelIssue} Choose a model with /model before continuing.`) : missingCodingPlanKey({
167693
167850
  model: this.model,
167694
- workingDirectory: this.options.workspaceDirectory
167851
+ workingDirectory: this.workspaceDirectory
167695
167852
  }),
167696
167853
  isStopped: () => this.stopped,
167697
167854
  submission,
@@ -167797,6 +167954,10 @@ var ZCodeTui = class {
167797
167954
  await this.showDiffBrowser();
167798
167955
  return;
167799
167956
  }
167957
+ if (input === "/sessions") {
167958
+ await this.showSessionPicker();
167959
+ return;
167960
+ }
167800
167961
  if (input.startsWith("/") && this.activeSubmissions > 0) {
167801
167962
  this.addNotice("Wait for the active turn or press Ctrl+C before running a slash command.", "warning");
167802
167963
  return;
@@ -168190,6 +168351,7 @@ var ZCodeTui = class {
168190
168351
  this.emittedSessionTerminalTitle = "";
168191
168352
  emitSessionTerminalTitle(this.options.stdout ?? process.stdout, "");
168192
168353
  this.sessionMetrics = {};
168354
+ await this.refreshWorkspace();
168193
168355
  await this.restoreCustomSessionTitle();
168194
168356
  this.restoreTranscript(restoredMessages(result.restoredMessages));
168195
168357
  if (this.transcript.blockCount > 0) this.enterSessionRail(true);
@@ -170569,7 +170731,7 @@ var ZCodeTui = class {
170569
170731
  this.addNotice("Wait for the active turn or press Ctrl+C before opening diff.", "warning");
170570
170732
  return;
170571
170733
  }
170572
- const sources = diffBrowserSources(await readWorkspaceDiff(this.options.workspaceDirectory ?? process.cwd()), this.turnDiffs.snapshots());
170734
+ const sources = diffBrowserSources(await readWorkspaceDiff(this.workspaceDirectory), this.turnDiffs.snapshots());
170573
170735
  while (true) {
170574
170736
  const sourceChoice = await this.showChoice({
170575
170737
  title: "Diff",
@@ -170729,8 +170891,8 @@ var ZCodeTui = class {
170729
170891
  mode: this.mode,
170730
170892
  planEnabled: this.planEnabled,
170731
170893
  effort: this.thoughtLevel,
170732
- workspace: this.options.workspaceDirectory ?? process.cwd(),
170733
- branch: this.options.workspaceGitBranch,
170894
+ workspace: this.workspaceDirectory,
170895
+ branch: this.workspaceGitBranch,
170734
170896
  locale: this.options.locale,
170735
170897
  developerMode: this.options.developerMode,
170736
170898
  projection: this.runtimeProjection,
@@ -170790,6 +170952,40 @@ var ZCodeTui = class {
170790
170952
  return "unavailable";
170791
170953
  }
170792
170954
  }
170955
+ async showSessionPicker() {
170956
+ if (this.activeSubmissions > 0 || this.turnAbortController) {
170957
+ this.addNotice("Wait for the active turn or press Ctrl+C before switching sessions.", "warning");
170958
+ return;
170959
+ }
170960
+ const currentSessionId = this.options.getMainSessionId?.();
170961
+ const cliDbPath = await this.options.readSessionDatabasePath?.();
170962
+ if (this.options.readSessionDatabasePath && !cliDbPath) {
170963
+ this.addNotice("Session browsing is unavailable for this session store.", "muted");
170964
+ return;
170965
+ }
170966
+ const sessions = listRecentSessions({
170967
+ cliDbPath,
170968
+ excludeIds: currentSessionId ? /* @__PURE__ */ new Set([currentSessionId]) : void 0
170969
+ });
170970
+ if (sessions.length === 0) {
170971
+ this.addNotice("No past sessions found in the shared session store.", "muted");
170972
+ return;
170973
+ }
170974
+ const currentDirectory = this.workspaceDirectory;
170975
+ const selected = await this.showChoice({
170976
+ title: "Sessions",
170977
+ prompt: `${sessions.length} recent session${sessions.length === 1 ? "" : "s"} · Enter resumes in place`,
170978
+ help: "Type to filter by title, directory or id · Up/Down choose · Ctrl+O details · Enter resume · Esc cancel",
170979
+ filterMode: "substring",
170980
+ items: sessions.map((session) => sessionChoiceItem(session, currentDirectory))
170981
+ });
170982
+ if (!selected) return;
170983
+ if (selected.value === currentSessionId) {
170984
+ this.addNotice("This session is already active.", "muted");
170985
+ return;
170986
+ }
170987
+ await this.submit(`/resume ${selected.value}`);
170988
+ }
170793
170989
  async showBackgroundTasks() {
170794
170990
  while (true) {
170795
170991
  await this.refreshRuntimeState();
@@ -171363,6 +171559,7 @@ var ZCodeTui = class {
171363
171559
  }
171364
171560
  applyRuntimeProjection(projection) {
171365
171561
  if (!projection) return;
171562
+ this.applyWorkspace(projection.workspace);
171366
171563
  this.runtimeProjection = projection;
171367
171564
  if (!this.settingSwitchInFlight) this.applyExecutionState(projection);
171368
171565
  this.noticeRestoredBackgroundTasks(projection);
@@ -83730,7 +83730,7 @@ var ZCODE_CUA_HELPER_BUILD_ID;
83730
83730
  var init_cua_version = __esm({
83731
83731
  "src/broker/shared/cua-version.ts"() {
83732
83732
  "use strict";
83733
- ZCODE_CUA_HELPER_BUILD_ID = true ? "pipeline-323224-025f7f39" : "";
83733
+ ZCODE_CUA_HELPER_BUILD_ID = true ? "pipeline-326130-a2d1ba73" : "";
83734
83734
  }
83735
83735
  });
83736
83736
  var init_shared = __esm({
@@ -50,7 +50,7 @@ There is also an **interactive-surface-only** filter: a command whose name match
50
50
  5. **Empty command is dropped** — both the description and the body are empty. → Add a `description:` or at least one non-empty body line.
51
51
  6. **Unknown frontmatter key (misspelling)** — `model`/`skills`/`allowed-tools` have no effect. → Use the hyphenated keys: `allowed-tools` (not `allowed_tools`), `argument-hint`, `disable-noninteractive`.
52
52
  7. **`$ARGUMENTS`/`$1` does not substitute** — the placeholder appears literally or is empty. The body has no placeholder (arguments are appended under "User arguments:" by design), `$1` is out of range, or a form like `${ARGUMENTS}` is not recognized. → Use the exact `$ARGUMENTS`/`$1` tokens.
53
- 8. **Dynamic shell is rejected** — running the command reports an unsupported shell expansion. The body contains `` !`...` `` or a fenced `!` block. → Remove it; use static text or `$ARGUMENTS`.
53
+ 8. **Dynamic shell does not run on its own** — a `` !`...` `` or fenced `!` block is not executed when the command is invoked, and its output is not pasted in beforehand. ZCode rewrites each block into an instruction for the model to run that command with the Bash tool, so it appears as a normal tool call with the usual approval prompt (and plan mode can deny it). → Expect that tool call; if the command must not depend on shell output, use static text or `$ARGUMENTS` instead.
54
54
  9. **A plugin command is missing** — a disabled plugin contributes no command roots, or a local same-named file is shadowing it. → Enable the plugin in **Settings → Plugin Management**, and ensure no local duplicate shadows it.
55
55
  10. **Disabled by configuration** — a valid command silently disappears. The configuration disables it by the command file's absolute path (not the command name). → Set that path's `enable` to `true` or remove it.
56
56
  11. **`/` versus `:` confusion** — `/review/code` reports not found although `review/code.md` exists. Subdirectories map to `:`, so the real name is `review:code`. → Invoke `/review:code`.
@@ -62,5 +62,5 @@ There is also an **interactive-surface-only** filter: a command whose name match
62
62
  2. **Confirm the file and its root.** Ensure the `.md` sits directly under a scanned commands root for the current working directory — pitfall 1 — and that its name is valid — pitfall 2.
63
63
  3. **Check the frontmatter.** A missing/garbled key points to the flat-parser rules (pitfall 4) or an empty command (pitfall 5); a key with no effect is likely a misspelling (pitfall 6).
64
64
  4. **Resolve a duplicate.** For a given name, the winner is the first in discovery order; find and rename or remove the copy you do not want.
65
- 5. **Check the body.** Verify the argument placeholders (pitfall 7) and that there is no rejected dynamic shell (pitfall 8).
65
+ 5. **Check the body.** Verify the argument placeholders (pitfall 7) and whether a dynamic shell block is handed to the model as a tool call (pitfall 8).
66
66
  6. **Still missing with no obvious cause?** Check for a configuration disable (pitfall 10, by absolute file path), a disabled plugin (pitfall 9), or reserved-name filtering (pitfall 12).