@cryer/star-cli 0.3.12 → 0.3.14

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 (33) hide show
  1. package/README.md +17 -5
  2. package/README.zh-CN.md +15 -5
  3. package/dist/{chunk-LSYGHLRU.js → chunk-2ISBRSBA.js} +479 -296
  4. package/dist/chunk-2ISBRSBA.js.map +1 -0
  5. package/dist/{chunk-F5RWZMQY.js → chunk-4HANB3DJ.js} +458 -221
  6. package/dist/chunk-4HANB3DJ.js.map +1 -0
  7. package/dist/chunk-4IRY44TG.js +0 -0
  8. package/dist/{chunk-Q5FJN4LN.js → chunk-54KH4JSO.js} +213 -125
  9. package/dist/chunk-54KH4JSO.js.map +1 -0
  10. package/dist/{chunk-MYHD3SZB.js → chunk-CECMCDZG.js} +43 -30
  11. package/dist/chunk-CECMCDZG.js.map +1 -0
  12. package/dist/{chunk-MVAMPVTA.js → chunk-KILMI3S5.js} +13 -5
  13. package/dist/{chunk-MVAMPVTA.js.map → chunk-KILMI3S5.js.map} +1 -1
  14. package/dist/{chunk-2GAUAYCU.js → chunk-NRLGGA7L.js} +507 -175
  15. package/dist/chunk-NRLGGA7L.js.map +1 -0
  16. package/dist/loop-M64D5YII.js +17 -0
  17. package/dist/main.js +177 -131
  18. package/dist/main.js.map +1 -1
  19. package/dist/{provider-EWMUPBLH.js → provider-3Z4B7RMF.js} +2 -2
  20. package/dist/{repl-SSCURTAH.js → repl-N2H7JDSH.js} +617 -327
  21. package/dist/repl-N2H7JDSH.js.map +1 -0
  22. package/dist/{tools-BH55BVIS.js → tools-5RKM7ZI3.js} +3 -3
  23. package/package.json +16 -25
  24. package/dist/chunk-2GAUAYCU.js.map +0 -1
  25. package/dist/chunk-F5RWZMQY.js.map +0 -1
  26. package/dist/chunk-LSYGHLRU.js.map +0 -1
  27. package/dist/chunk-MYHD3SZB.js.map +0 -1
  28. package/dist/chunk-Q5FJN4LN.js.map +0 -1
  29. package/dist/loop-BYXBNFFY.js +0 -17
  30. package/dist/repl-SSCURTAH.js.map +0 -1
  31. /package/dist/{loop-BYXBNFFY.js.map → loop-M64D5YII.js.map} +0 -0
  32. /package/dist/{provider-EWMUPBLH.js.map → provider-3Z4B7RMF.js.map} +0 -0
  33. /package/dist/{tools-BH55BVIS.js.map → tools-5RKM7ZI3.js.map} +0 -0
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <div align="center">
2
2
 
3
- <img src="assets/icon.png" alt="Star CLI" width="320" />
3
+ <img src="assets/star-cli-logo.svg" alt="Star CLI" width="480" />
4
4
 
5
5
  **An AI agent command-line interface written in TypeScript**
6
6
 
@@ -17,7 +17,7 @@ Multi-model LLM access · streaming terminal UI · tool calling · permission co
17
17
 
18
18
  </div>
19
19
 
20
- Features: streaming REPL with slash commands (+ autocomplete) · OpenAI / Anthropic / OpenAI-compatible providers with an interactive `/connect` onboarding wizard · built-in fs / bash / web tools with a permission gate · git integration (`/commit` drafts Conventional Commits messages, `/diff` shows a colored working-tree diff, repo status sent as a per-turn request-scoped reminder so it never breaks the prompt cache) · prompt caching on Anthropic providers (cache breakpoints on the stable prefix and the history tail; OpenAI-style protocols cache server-side automatically) with a status-bar hit rate · token thrift: re-reading an unchanged file answers with a one-line note, and auxiliary calls (summaries, titles) can run on a cheaper `smallModel` · plan mode with read-only research and plan approval · thinking spinner with dim reasoning preview · diff preview on write/edit approval · `@file` mentions · `!cmd` shell passthrough · custom slash commands from Markdown files · conversation compaction (`/compact`) · session persistence and resume with auto-generated titles (`/resume`, `star -r`) · subagent delegation for focused subtasks · lifecycle hooks (`PreToolUse`/`PostToolUse`/`Stop` shell commands from config) · file-write snapshots with `/undo` and checkpoint rollback with `/rewind` · TODO task tracking · background shell tasks with status-bar visibility (`/tasks`) · terminal bell on long turns and background-task completion · Markdown session export (`/export`) · `/init` + `/doctor` project scaffolding and environment checks · cost estimation · update notifier · `--json` NDJSON output for scripting.
20
+ Features: streaming REPL with slash commands (+ autocomplete) · OpenAI / Anthropic / OpenAI-compatible providers with an interactive `/connect` onboarding wizard · built-in fs / bash / web tools with a permission gate · git integration (`/commit` drafts Conventional Commits messages, `/diff` shows a colored working-tree diff, repo status sent as a per-turn request-scoped reminder so it never breaks the prompt cache) · prompt caching on Anthropic providers (cache breakpoints on the stable prefix and the history tail; OpenAI-style protocols cache server-side automatically) with a status-bar hit rate · token thrift: re-reading an unchanged file answers with a one-line note, and auxiliary calls (summaries, titles) can run on a cheaper `smallModel` · plan mode with read-only research and plan approval · thinking spinner with dim reasoning preview · diff preview on write/edit approval · `@file` mentions · `!cmd` shell passthrough · custom slash commands from Markdown files · stale-context elision (old tool outputs, tool-call arguments and attached images are replaced in place with placeholders — tunable via `elision*`) · conversation compaction (`/compact`) · session persistence and resume with auto-generated titles (`/resume`, `star -r`) · subagent delegation for focused subtasks · lifecycle hooks (`PreToolUse`/`PostToolUse`/`Stop` shell commands from config) · file-write snapshots with `/undo` and checkpoint rollback with `/rewind` · TODO task tracking · background shell tasks with status-bar visibility (`/tasks`) · terminal bell on long turns and background-task completion · Markdown session export (`/export`) · `/init` + `/doctor` project scaffolding and environment checks · cost estimation · update notifier · `--json` NDJSON output for scripting.
21
21
 
22
22
  ## Requirements
23
23
 
@@ -58,6 +58,17 @@ contextMaxTokens = 100000 # context window in tokens (per-model override
58
58
  # compactThresholdTokens = 80000 # optional auto-compaction trigger in tokens; defaults to the
59
59
  # context window and is clamped to it (top-level only — there is
60
60
  # no per-model override). /compact always compacts, regardless.
61
+ # Stale-content elision: once estimated context usage reaches
62
+ # elisionThresholdFraction of the compaction threshold, bulk older than
63
+ # elisionKeepRecentMessages messages (stale tool results, old tool-call
64
+ # arguments, old attached images) is replaced in place with a placeholder —
65
+ # message count and order are unchanged, so /undo markers stay valid and
66
+ # compaction often never fires. Smaller-than-elisionMinTokens results are
67
+ # kept (cheaper than re-fetching). Set the fraction to 1 to elide only at
68
+ # the compaction point (effectively off), 0 to elide even in short sessions.
69
+ elisionThresholdFraction = 0.5
70
+ elisionKeepRecentMessages = 24
71
+ elisionMinTokens = 250
61
72
  # Max model round-trips ("steps") per turn between progress checkpoints — one
62
73
  # step is a reply plus the tool calls it asked for; retries and auto-continue
63
74
  # nudges don't count. Reaching the cap while tools still execute resets it
@@ -186,6 +197,7 @@ contextMaxTokens = 128000
186
197
  - `STAR_HOME` — overrides `~/.star-cli` as the data home (config, sessions, `.env`, memory, debug log).
187
198
  - `STAR_DEBUG` — any non-empty value enables stream diagnostics appended to `~/.star-cli/debug.log`, one JSON object per line.
188
199
  - `STAR_NO_NOTIFY=1` — disables the terminal bell without touching the config.
200
+ - `STAR_NO_MOTION=1` — disables spinner and terminal-title animation for reduced-motion or low-frequency terminals.
189
201
 
190
202
 
191
203
  ## CLI flags
@@ -262,7 +274,7 @@ The REPL rings the terminal bell (BEL) so you can switch windows while the agent
262
274
 
263
275
  ## Session budget
264
276
 
265
- Setting `sessionBudgetUsd` in the config caps spend per REPL session (the active model needs `promptPrice`/`completionPrice` so the cost can be computed). When a finished turn pushes the session cost past 80% of the cap, a one-time warning appears; past 100%, further prompts are blocked with an error while slash commands keep working — raise the limit in the config or start fresh with `/new`.
277
+ Setting `sessionBudgetUsd` in the config caps spend per REPL session. Usage and cost are recorded per model when each main, auxiliary or subagent request finishes, so `/model` never reprices earlier history; each model needs `promptPrice`/`completionPrice` for an exact amount, and unpriced requests are reported separately. When recorded cost passes 80% of the cap, a one-time warning appears; past 100%, further prompts are blocked while slash commands keep working — raise the limit or start fresh with `/new`.
266
278
 
267
279
  ## Plan mode
268
280
 
@@ -362,7 +374,7 @@ The `subagent` tool (`exec` level, so it is hidden in plan mode and denied in re
362
374
 
363
375
  Permission modes: `ask` (reads allowed, writes/exec ask) · `auto` (everything allowed except the hard-denied rules above) · `readonly` (read-only) · `yolo` (allow everything, never ask — **all safety checks disabled**, use at your own risk) · `plan` (read-only research with a plan-approval flow, see above — session-only). Switch at runtime with `/permission` (persisted to the config file), per session with `/plan` or `Shift+Tab`, or at startup with `--permission-mode`. On top of the modes, the `[permissions]` config block holds persistent `allow` and `deny` rule lists (same `bash(npm test *)` syntax); deny rules are evaluated right after the hard safety rules and beat both `auto` mode and allow-rules, while `yolo` bypasses everything.
364
376
 
365
- Every successful `write_file` / `edit_file` first snapshots the file's previous content (in-memory, last 50 writes per session); `/undo` reverts the last turn's snapshots — restoring old content, or deleting files the turn created — but only after showing a preview of the retraction and per-file revert diffs and getting a `y`/`n` confirmation.
377
+ Every successful `write_file` / `edit_file` first snapshots the file's previous content (in-memory, last 50 writes per session). A write is refused when existing content is too large or unreadable and therefore cannot be restored safely. `/undo` reverts the last turn's snapshots — restoring old content, or deleting files the turn created — but only after showing a preview and getting confirmation. Whole-tree Git snapshots also honor custom `permissions.sensitive` rules and disable Git attribute/filter/encoding conversion so restores preserve bytes.
366
378
 
367
379
  ## Checkpoints and /rewind
368
380
 
@@ -372,7 +384,7 @@ Checkpoints are persisted under `~/.star-cli/sessions/<id>/checkpoints/` (an `in
372
384
 
373
385
  ## Sessions
374
386
 
375
- Sessions persist under `~/.star-cli/sessions/<id>/` (messages as JSONL + `meta.json`). `/resume` with no argument opens an interactive picker of this directory's sessions (most recently active first, message counts, relative times, a preview of the first message, and a `current` marker on the live session; `/resume --all` covers every directory with each session's cwd shown), while `/resume <id>` and `star -r <id>` jump straight to one — both accept the short id shown in the list. `/fork` branches the live session: every message is copied into a new session titled `Fork of …` which becomes the active one, so you can explore a different direction while the original stays intact (checkpoints and rewind history are not carried over). `/search <query>` full-text-searches every stored session — message text plus tool-call arguments and results — and lists matching sessions with a snippet, ready for `/resume <id>`. `star -c` (`--continue`) jumps straight back into the most recently active session for the current directory, in the REPL and in print mode alike; when the directory has no sessions it says so and starts a fresh one. `-r` and `-c` are mutually exclusive, and a bare `star -r` prints the session list instead of erroring. Sessions are created lazily — opening the REPL and exiting without chatting leaves nothing on disk, and print mode (`-p`) doesn't create a session unless resuming with `-r` or `-c`. Token usage is accumulated in `meta.json`, so `/cost` reflects resumed history too. `/usage` is the global counterpart of `/cost` (which stays session-scoped): it aggregates every session's `meta.json` across all directories into a dashboard — grand totals, a per-day bar chart of the last 14 days with usage, and a per-model breakdown with a $ estimate for models that have pricing configured (models without pricing are listed but excluded from the total). Per-day numbers come from a `usageByDay` bucket map recorded from now on; usage recorded before that field existed only has grand totals and shows up as a single "earlier usage" line. `/new` abandons the in-memory conversation and attaches a fresh lazy session store (the old session stays on disk); deletion is a separate explicit action — `/clear-sessions` removes the sessions recorded for the current directory, `/clear-sessions --all` wipes every session directory (including ones with an unreadable `meta.json`), and both keep the live session; `star --clear-sessions [all]` does the same non-interactively and exits.
387
+ Sessions persist under `~/.star-cli/sessions/<id>/` (messages as JSONL + `meta.json`). `/resume` with no argument opens an interactive picker of this directory's sessions (most recently active first, message counts, relative times, a preview of the first message, and a `current` marker on the live session; `/resume --all` covers every directory with each session's cwd shown), while `/resume <id>` and `star -r <id>` jump straight to one — both accept the short id shown in the list. `/fork` branches the live session: every message is copied into a new session titled `Fork of …` which becomes the active one, so you can explore a different direction while the original stays intact (checkpoints and rewind history are not carried over). `/search <query>` full-text-searches every stored session — message text plus tool-call arguments and results — and lists matching sessions with a snippet, ready for `/resume <id>`. `star -c` (`--continue`) jumps straight back into the most recently active session for the current directory, in the REPL and in print mode alike; when the directory has no sessions it says so and starts a fresh one. `-r` and `-c` are mutually exclusive, and a bare `star -r` prints the session list instead of erroring. Session content is still created lazily — opening the REPL and exiting without chatting leaves no `meta.json` or `messages.jsonl`, and print mode (`-p`) doesn't create a session unless resuming with `-r` or `-c`. A writable session holds an exclusive lifecycle lock until close; another process cannot resume or delete the active session, and stale locks from crashed processes are reclaimed automatically. Token usage and actual cost are accumulated per model in `meta.json`, so `/cost` reflects resumed and mixed-model history accurately. `/usage` is the global counterpart of `/cost` (which stays session-scoped): it aggregates every session's `meta.json` across all directories into a dashboard — grand totals, a per-day bar chart of the last 14 days with usage, and a per-model breakdown with a $ estimate for models that have pricing configured (models without pricing are listed but excluded from the total). Per-day numbers come from a `usageByDay` bucket map recorded from now on; usage recorded before that field existed only has grand totals and shows up as a single "earlier usage" line. `/new` abandons the in-memory conversation and attaches a fresh lazy session store (the old session stays on disk); deletion is a separate explicit action — `/clear-sessions` removes the sessions recorded for the current directory, `/clear-sessions --all` wipes every session directory (including ones with an unreadable `meta.json`), and both keep the live session; `star --clear-sessions [all]` does the same non-interactively and exits.
376
388
 
377
389
  After the first turn of a session (the first user message gets its first assistant reply), a lightweight background LLM request — same model, capped at 20 output tokens — summarizes the first user message into a short title (≤50 chars, matching the message's language) and stores it in `meta.json`, where the `/resume` list picks it up. Title generation is fire-and-forget: it never blocks the REPL or print-mode output, it runs only when the session has no title yet (resumed sessions keep their existing title; untitled older sessions get one after their next turn), and if the request fails the title simply stays empty — untitled sessions show as `(无标题)` in the list. An unfinished request is abandoned when the process exits. It applies wherever a session is attached, including print mode when resuming with `-r`/`-c`.
378
390
 
package/README.zh-CN.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <div align="center">
2
2
 
3
- <img src="assets/icon.png" alt="Star CLI" width="320" />
3
+ <img src="assets/star-cli-logo.svg" alt="Star CLI" width="480" />
4
4
 
5
5
  **用 TypeScript 编写的 AI 代理命令行界面**
6
6
 
@@ -17,7 +17,7 @@
17
17
 
18
18
  </div>
19
19
 
20
- 功能特性:带斜杠命令(+ 自动补全)的流式 REPL · OpenAI / Anthropic / OpenAI 兼容服务商,配交互式 `/connect` 接入向导 · 内置 fs / bash / web 工具,带权限门禁 · git 集成(`/commit` 起草 Conventional Commits 提交信息,`/diff` 显示彩色工作区 diff,仓库状态以每回合请求级 reminder 发送,不会破坏提示词缓存)· Anthropic 服务商的提示词缓存(在稳定前缀与历史尾部打缓存断点;OpenAI 系协议由服务端自动缓存),状态栏显示命中率 · token 节俭:重复读取未变化的文件只回一行说明,压缩摘要、标题等辅助调用可配置更便宜的 `smallModel` · 计划模式:只读调研 + 计划批准 · 带暗色推理预览的思考动画 · 写入/编辑批准时的 diff 预览 · `@file` 引用 · `!cmd` shell 直通 · 用 Markdown 文件自定义斜杠命令 · 对话压缩(`/compact`)· 会话持久化与恢复,自动生成标题(`/resume`、`star -r`)· 子代理委派,处理专注的子任务 · 生命周期钩子(来自配置的 `PreToolUse`/`PostToolUse`/`Stop` shell 命令)· 文件写入快照 `/undo` 与检查点回滚 `/rewind` · TODO 任务跟踪 · 状态栏可见的后台 shell 任务(`/tasks`)· 长回合与后台任务完成时的终端响铃 · Markdown 会话导出(`/export`)· `/init` + `/doctor` 项目脚手架与环境检查 · 成本估算 · 更新提醒 · 便于脚本化的 `--json` NDJSON 输出。
20
+ 功能特性:带斜杠命令(+ 自动补全)的流式 REPL · OpenAI / Anthropic / OpenAI 兼容服务商,配交互式 `/connect` 接入向导 · 内置 fs / bash / web 工具,带权限门禁 · git 集成(`/commit` 起草 Conventional Commits 提交信息,`/diff` 显示彩色工作区 diff,仓库状态以每回合请求级 reminder 发送,不会破坏提示词缓存)· Anthropic 服务商的提示词缓存(在稳定前缀与历史尾部打缓存断点;OpenAI 系协议由服务端自动缓存),状态栏显示命中率 · token 节俭:重复读取未变化的文件只回一行说明,压缩摘要、标题等辅助调用可配置更便宜的 `smallModel` · 计划模式:只读调研 + 计划批准 · 带暗色推理预览的思考动画 · 写入/编辑批准时的 diff 预览 · `@file` 引用 · `!cmd` shell 直通 · 用 Markdown 文件自定义斜杠命令 · 陈旧上下文省略(旧的工具输出、工具调用参数和附加图片会被原地替换为占位符——可用 `elision*` 键调节)· 对话压缩(`/compact`)· 会话持久化与恢复,自动生成标题(`/resume`、`star -r`)· 子代理委派,处理专注的子任务 · 生命周期钩子(来自配置的 `PreToolUse`/`PostToolUse`/`Stop` shell 命令)· 文件写入快照 `/undo` 与检查点回滚 `/rewind` · TODO 任务跟踪 · 状态栏可见的后台 shell 任务(`/tasks`)· 长回合与后台任务完成时的终端响铃 · Markdown 会话导出(`/export`)· `/init` + `/doctor` 项目脚手架与环境检查 · 成本估算 · 更新提醒 · 便于脚本化的 `--json` NDJSON 输出。
21
21
 
22
22
  ## 环境要求
23
23
 
@@ -58,6 +58,15 @@ contextMaxTokens = 100000 # 上下文窗口(token 数,下方可按
58
58
  # compactThresholdTokens = 80000 # 可选的自动压缩触发阈值(token 数);默认为上下文窗口本身,
59
59
  # 且会被钳制到窗口以内(仅顶层键——没有按模型覆盖)。
60
60
  # /compact 无视此阈值,总是执行压缩。
61
+ # 陈旧内容省略(elision):当估算的上下文用量达到压缩阈值的
62
+ # elisionThresholdFraction 倍时,早于最近 elisionKeepRecentMessages 条消息的大块内容
63
+ #(陈旧的工具结果、旧的工具调用参数、早先附加的图片)会被原地替换为占位符——
64
+ # 消息数量和顺序不变,因此 /undo 标记仍然有效,且往往因此不再需要整轮压缩。
65
+ # 小于 elisionMinTokens 的结果会保留(重新获取反而更贵)。
66
+ # fraction 设为 1 表示只在压缩点才省略(基本等于关闭),设为 0 表示短会话也省略。
67
+ elisionThresholdFraction = 0.5
68
+ elisionKeepRecentMessages = 24
69
+ elisionMinTokens = 250
61
70
  # 每回合在进度检查点之间允许的最大模型往返("step")数——一个 step 是
62
71
  # 一次回复加上它请求的所有工具调用;重试和 auto-continue nudge 不占 step。
63
72
  # 到达上限时若工具仍在执行,会发提示并重置额度而不是终止回合;0 表示完全不限。
@@ -181,6 +190,7 @@ contextMaxTokens = 128000
181
190
  - `STAR_HOME` —— 把数据目录从 `~/.star-cli` 改为其他位置(配置、会话、`.env`、记忆、调试日志)。
182
191
  - `STAR_DEBUG` —— 任意非空值即启用流诊断日志,追加写入 `~/.star-cli/debug.log`,每行一个 JSON 对象。
183
192
  - `STAR_NO_NOTIFY=1` —— 不改配置即可禁用终端响铃。
193
+ - `STAR_NO_MOTION=1` —— 禁用 spinner 和终端标题动画,适合减少动态效果或低频远程终端。
184
194
 
185
195
 
186
196
  ## CLI 参数
@@ -257,7 +267,7 @@ REPL 会响终端铃(BEL),这样代理工作时你可以切到别的窗口
257
267
 
258
268
  ## 会话预算
259
269
 
260
- 在配置中设置 `sessionBudgetUsd` 可为每个 REPL 会话设置花费上限(活动模型需要配置 `promptPrice`/`completionPrice` 才能计算成本)。已完成的回合使会话成本超过上限的 80% 时,会出现一次性警告;超过 100% 时,后续提示会被阻止并报错,斜杠命令仍可用——在配置中提高限额,或用 `/new` 重新开始。
270
+ 在配置中设置 `sessionBudgetUsd` 可为每个 REPL 会话设置花费上限。主请求、辅助请求和子代理完成时都会按实际所用模型分别记录 token 与成本,因此 `/model` 不会按新价格重算历史;每个模型需要配置 `promptPrice`/`completionPrice` 才能精确计价,未定价请求会单独标明。已记录成本超过上限的 80% 时会出现一次性警告;超过 100% 时后续提示会被阻止,斜杠命令仍可用——在配置中提高限额,或用 `/new` 重新开始。
261
271
 
262
272
  ## 计划模式
263
273
 
@@ -357,7 +367,7 @@ star -p "what's wrong in this UI?" --image screenshot.png --image mockup.jpg
357
367
 
358
368
  权限模式:`ask`(读放行,写/执行询问)· `auto`(除上述硬性拒绝规则外全部放行)· `readonly`(只读)· `yolo`(放行一切,从不询问——**所有安全检查关闭**,风险自负)· `plan`(只读调研加计划审批流程,见上文——仅会话内)。运行时用 `/permission` 切换(持久化到配置文件),会话内用 `/plan` 或 `Shift+Tab`,启动时用 `--permission-mode`。在模式之上,`[permissions]` 配置块持有持久的 `allow` 和 `deny` 规则列表(同样的 `bash(npm test *)` 语法);deny 规则在硬性安全规则之后评估,胜过 `auto` 模式和 allow 规则,而 `yolo` 绕过一切。
359
369
 
360
- 每次成功的 `write_file` / `edit_file` 会先快照文件的旧内容(内存中,每会话保留最近 50 次写入);`/undo` 还原上一回合的快照——恢复旧内容,或删除该回合创建的文件——但只在展示撤回预览与逐文件还原 diff 并获得 `y`/`n` 确认之后。
370
+ 每次成功的 `write_file` / `edit_file` 会先快照文件的旧内容(内存中,每会话保留最近 50 次写入)。如果旧内容过大或不可读、无法安全恢复,写入会被拒绝。`/undo` 还原上一回合的快照——恢复旧内容,或删除该回合创建的文件——但只在展示预览并获得确认之后。整树 Git 快照同样遵循自定义 `permissions.sensitive` 规则,并禁用 Git 属性、过滤器和编码转换,以确保按原始字节恢复。
361
371
 
362
372
  ## 检查点与 /rewind
363
373
 
@@ -367,7 +377,7 @@ star -p "what's wrong in this UI?" --image screenshot.png --image mockup.jpg
367
377
 
368
378
  ## 会话
369
379
 
370
- 会话持久化在 `~/.star-cli/sessions/<id>/` 下(消息为 JSONL + `meta.json`)。无参数的 `/resume` 打开当前目录会话的交互式选择器(最近活跃优先、消息数、相对时间、首条消息预览、当前会话带 `current` 标记;`/resume --all` 涵盖所有目录并显示各会话的 cwd),`/resume <id>` 和 `star -r <id>` 直接跳转到指定会话——两者都接受列表中显示的短 id。`/fork` 分叉当前会话:所有消息复制到一个标题为 `Fork of …` 的新会话并使之成为活动会话,因此你可以探索不同方向而原会话保持完好(检查点与回滚历史不随带)。`/search <query>` 对所有已存会话做全文搜索——消息文本加工具调用参数与结果——并列出带摘要片段的匹配会话,可直接 `/resume <id>`。`star -c`(`--continue`)直接回到当前目录最近活跃的会话,REPL 与 print 模式一致;目录没有会话时它会说明并开始新会话。`-r` 与 `-c` 互斥,裸 `star -r` 打印会话列表而不报错。会话是懒创建的——打开 REPL 不聊天就退出不会在磁盘留下任何东西,print 模式(`-p`)除非用 `-r` 或 `-c` 恢复,否则不创建会话。token 用量累积在 `meta.json` 中,因此 `/cost` 也反映恢复的历史。`/usage` 是 `/cost` 的全局对应物(`/cost` 保持会话作用域):它聚合所有目录下每个会话的 `meta.json` 成一张面板——总计、最近 14 天有用量日期的按日柱状图,以及按模型细分并为配置了定价的模型给出美元估算(未配置定价的模型会列出但不计入总额)。按日数字来自此后记录的 `usageByDay` 桶映射;该字段出现之前记录的用量只有总计,显示为单独一行“earlier usage”(更早用量)。`/new` 丢弃内存中的对话并挂载一个全新的懒会话存储(旧会话保留在磁盘上);删除是单独的显式操作——`/clear-sessions` 删除当前目录记录的会话,`/clear-sessions --all` 清空所有会话目录(包括 `meta.json` 不可读的),两者都保留当前活动会话;`star --clear-sessions [all]` 以非交互方式做同样的事并退出。
380
+ 会话持久化在 `~/.star-cli/sessions/<id>/` 下(消息为 JSONL + `meta.json`)。无参数的 `/resume` 打开当前目录会话的交互式选择器(最近活跃优先、消息数、相对时间、首条消息预览、当前会话带 `current` 标记;`/resume --all` 涵盖所有目录并显示各会话的 cwd),`/resume <id>` 和 `star -r <id>` 直接跳转到指定会话——两者都接受列表中显示的短 id。`/fork` 分叉当前会话:所有消息复制到一个标题为 `Fork of …` 的新会话并使之成为活动会话,因此你可以探索不同方向而原会话保持完好(检查点与回滚历史不随带)。`/search <query>` 对所有已存会话做全文搜索——消息文本加工具调用参数与结果——并列出带摘要片段的匹配会话,可直接 `/resume <id>`。`star -c`(`--continue`)直接回到当前目录最近活跃的会话,REPL 与 print 模式一致;目录没有会话时它会说明并开始新会话。`-r` 与 `-c` 互斥,裸 `star -r` 打印会话列表而不报错。会话内容仍是懒创建的——打开 REPL 不聊天就退出不会留下 `meta.json` 或 `messages.jsonl`,print 模式(`-p`)除非用 `-r` 或 `-c` 恢复,否则不创建会话。可写会话在关闭前持有独占生命周期锁,其他进程不能恢复或删除活动会话;崩溃遗留的锁会自动回收。token 用量和实际成本按模型累积到 `meta.json`,因此 `/cost` 能准确覆盖恢复历史和混合模型会话。`/usage` 是 `/cost` 的全局对应物(`/cost` 保持会话作用域):它聚合所有目录下每个会话的 `meta.json` 成一张面板——总计、最近 14 天有用量日期的按日柱状图,以及按模型细分并为配置了定价的模型给出美元估算(未配置定价的模型会列出但不计入总额)。按日数字来自此后记录的 `usageByDay` 桶映射;该字段出现之前记录的用量只有总计,显示为单独一行“earlier usage”(更早用量)。`/new` 丢弃内存中的对话并挂载一个全新的懒会话存储(旧会话保留在磁盘上);删除是单独的显式操作——`/clear-sessions` 删除当前目录记录的会话,`/clear-sessions --all` 清空所有会话目录(包括 `meta.json` 不可读的),两者都保留当前活动会话;`star --clear-sessions [all]` 以非交互方式做同样的事并退出。
371
381
 
372
382
  会话首个回合完成后(第一条用户消息得到第一条助手回复),一个轻量后台 LLM 请求——同一模型,上限 20 个输出 token——把第一条用户消息总结为短标题(≤50 字符,与消息语言一致)并存入 `meta.json`,`/resume` 列表从中读取。标题生成是即发即忘的:它从不阻塞 REPL 或 print 模式输出,只在会话尚无标题时运行(恢复的会话保留已有标题;无标题的旧会话在下一回合后获得标题),请求失败时标题保持为空——无标题会话在列表中显示为 `(无标题)`。进程退出时未完成的请求被放弃。只要挂载着会话它就适用,包括用 `-r`/`-c` 恢复的 print 模式。
373
383