@yanzc/claude-pro 0.9.5 → 0.9.7

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/README.md CHANGED
@@ -71,13 +71,12 @@ claude-pro -p "用 Read 工具读取 package.json,告诉我项目版本"
71
71
 
72
72
  网关 key 只来自 `/login`:登录后保存在 `~/.claude-pro/gateway.json`,不用手动填写,也没有环境变量或 `.env` 文件可以设置它(没有浏览器的机器可以把另一台登录过的电脑的 `gateway.json` 拷过去)。
73
73
 
74
- 一般只需要 `/login`、`/model`、`/effort`、`/tui` 和 settings。六个普通设置直接写在 `settings.json` 顶层(下面也是默认值):
74
+ 一般只需要 `/login`、`/model`、`/effort` 和 settings。五个普通设置直接写在 `settings.json` 顶层(下面也是默认值):
75
75
 
76
76
  ```json
77
77
  {
78
78
  "model": "opus",
79
79
  "effort": "auto",
80
- "tui": "fullscreen",
81
80
  "promptCacheTtl": "1h",
82
81
  "subagentPromptCacheTtl": "5m",
83
82
  "cleanupPeriodDays": 30
@@ -96,22 +95,13 @@ claude-pro config list --advanced # 另外显示高级配置
96
95
  claude-pro config set CLAUDE_PRO_GATEWAY_URL https://gw.predix.icu
97
96
  ```
98
97
 
99
- 会话中 `/config` 默认只显示这六项,`/config advanced` 查看高级项;`/config set model sonnet` 等同于 CLI 的 `config set`。普通设置写顶层,高级设置写 `env`。`/config set/unset` 保留 `--project`、`--local`,分别修改项目共享设置或本地设置。`/model`、`/effort` 仍会记住选择,`/tui` 记到顶层 `tui`;`--model`、`--effort` 可覆盖本次启动。
98
+ 会话中 `/config` 默认只显示这五项,`/config advanced` 查看高级项;`/config set model sonnet` 等同于 CLI 的 `config set`。普通设置写顶层,高级设置写 `env`。`/config set/unset` 保留 `--project`、`--local`,分别修改项目共享设置或本地设置。`/model`、`/effort` 仍会记住选择;`--model`、`--effort` 可覆盖本次启动。
100
99
 
101
- 设置文件从低到高:`~/.claude-pro/settings.json`、项目 `.claude-pro/settings.json`、`.claude-pro/settings.local.json`。高级项仍兼容进程环境变量(高于设置文件),包括网关地址、远程会话、输出/thinking 预算、缓存总开关、保活、网络重试、工具路径、验证、自动记忆/话题标题和 Trace 开关;普通设置不从进程环境读取。旧 `settings.json.env` 中的 `CLAUDE_PRO_GATEWAY_MODEL`、`CLAUDE_CODE_EFFORT_LEVEL`、`CLAUDE_PRO_TUI`、`CLAUDE_CODE_PROMPT_CACHE_TTL`、`CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL` 只作为兼容别名读取,同文件顶层新字段优先;用 `config set` 或 `/config set` 设置旧别名,会改写顶层新字段并移除同文件旧别名。provider 固定为 `gateway`,已删除 `--provider` 和 `CLAUDE_PRO_PROVIDER` 配置入口。
100
+ 设置文件从低到高:`~/.claude-pro/settings.json`、项目 `.claude-pro/settings.json`、`.claude-pro/settings.local.json`。高级项仍兼容进程环境变量(高于设置文件),包括网关地址、远程会话、输出/thinking 预算、缓存总开关、保活、网络重试、工具路径、验证、自动记忆/话题标题和 Trace 开关;普通设置不从进程环境读取。旧 `settings.json.env` 中的 `CLAUDE_PRO_GATEWAY_MODEL`、`CLAUDE_CODE_EFFORT_LEVEL`、`CLAUDE_CODE_PROMPT_CACHE_TTL`、`CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL` 只作为兼容别名读取,同文件顶层新字段优先;用 `config set` 或 `/config set` 设置旧别名,会改写顶层新字段并移除同文件旧别名。provider 固定为 `gateway`,已删除 `--provider` 和 `CLAUDE_PRO_PROVIDER` 配置入口。
102
101
 
103
- ## 持久化系统提示词
102
+ ## 系统提示词
104
103
 
105
- 可以把整个系统提示词保存到用户配置中,之后关闭并重新启动仍然使用:
106
-
107
- ```text
108
- /prompt path/to/prompt.md # 读取文件,并复制到 ~/.claude-pro/prompts/
109
- /prompt "回答要简洁,先给结论" # 也可以直接保存一段文字
110
- /prompts # 选择已保存的提示词
111
- /prompts default # 切回内置默认提示词
112
- ```
113
-
114
- `/promt` 和 `/promits` 也作为常见拼写兼容。当前选择保存在 `~/.claude-pro/settings.json` 的 `prompts.active` 中,提示词内容保存在 `~/.claude-pro/prompts/`,不会依赖原始文件;`/status` 会显示当前选择。切换提示词会立即用于下一次请求,提示词缓存仍然有效时会先询问,因为下一次请求需要重新写入对话。命令行的 `--system-prompt` 和 `--system-prompt-file` 优先级更高,只覆盖本次启动。
104
+ 默认使用内置的系统提示词。只想改这一次启动时,用启动参数(和官方 Claude Code 一样):`--append-system-prompt "..."` 在默认提示词后面追加,`--system-prompt "..."` 或 `--system-prompt-file 文件` 整个替换(工具说明也会一起换掉)。长期的规则写进 CLAUDE.md 或记忆(消息以 `#` 开头)。
115
105
 
116
106
  ## 提示词缓存:自动的,尽量少花钱
117
107
 
@@ -220,7 +210,7 @@ claude-pro config set CLAUDE_PRO_GATEWAY_URL https://gw.predix.icu
220
210
  - 流式 Markdown 渲染(代码高亮、表格、中文宽度对齐),所有模型返回的思考过程始终展开显示,恢复会话时也会显示已保存的思考;`/verbose` 只切换工具输出详细度和压缩摘要,不影响思考显示
221
211
  - `Esc` 中断;忙碌时输入的消息会排队并插入当前任务
222
212
  - `!` Bash 模式、`#` 写入记忆(CLAUDE.md)、`\`+回车 或 `ctrl+j` 换行、粘贴大段文本折叠为 `[Pasted text #1 +42 lines]`
223
- - **全屏模式(默认)**:程序画在终端的备用屏幕上(像 vim),输入框固定在窗口最底下,不随输出或终端滚动条移动;对话在程序里滚动:鼠标滚轮(每格 3 行)、`PgUp`/`PgDn`(半屏)、`Ctrl+Home`(对话开头)、`Ctrl+End`(回到最新)。往上翻时新输出不会把画面拉回底部,底部浮着 `Jump to bottom (ctrl+End) ↓ · N new lines`,**点它**或按 `Ctrl+End` 回到底部;发消息时自动回到底部。**选中文字直接用鼠标拖**(不用按 Shift),松开只保留反色选择,不会自动复制;双击选一个词,三击选一整行;拖到对话区上下边缘会跟着滚动。选中的部分反色显示,点一下别处、按 `Esc` 或任意键就消失;有选中时只有 `Ctrl+C` 会复制。**输入框里**单击把光标移到那里,拖动、双击、三击选中正在写的文字,`Ctrl+C` 复制(不会打断任务,也不清空输入框);选中后打字不会替换选中的文字。**引用追问**(像 ChatGPT 的“向 ChatGPT 提问”):选中对话里的内容后按 `Ctrl+Q`(终端占用了 `Ctrl+Q` 时用 `Alt+Q`),选中的内容就以 `[Quote #1 +12 lines]` 插进输入框,光标停在下一行,直接写追问。发给模型的是选中的原文,加上它所在的那条工具调用、回复或消息的首行(`<quote source="⏺ Read(src/api.js)">…</quote>`),模型就知道问的是哪一段、哪个文件;对话里只显示引用的前三行。可以连续引用好几段,退格一次删掉整个引用。`Ctrl+V` 粘贴剪贴板文字(剪贴板里只有图片时作为图片附加),`Alt+V` 优先附加剪贴板图片;右键不执行复制或粘贴。仍可按住 Shift 拖动用终端自己的选中。退出后终端回到启动前的样子(对话不留在终端滚动记录里)。`/tui default` 切回经典模式(对话写进终端自己的滚动记录,输入框在窗口底部、靠空行顶到底),`/tui fullscreen` 切回全屏,选择会记到 `settings.json` 顶层的 `tui`
213
+ - **全屏界面**:程序画在终端的备用屏幕上(像 vim),输入框固定在窗口最底下,不随输出或终端滚动条移动;对话在程序里滚动:鼠标滚轮(每格 3 行)、`PgUp`/`PgDn`(半屏)、`Ctrl+Home`(对话开头)、`Ctrl+End`(回到最新)。往上翻时新输出不会把画面拉回底部,底部浮着 `Jump to bottom (ctrl+End) ↓ · N new lines`,**点它**或按 `Ctrl+End` 回到底部;发消息时自动回到底部。**选中文字直接用鼠标拖**(不用按 Shift),松开只保留反色选择,不会自动复制;双击选一个词,三击选一整行;拖到对话区上下边缘会跟着滚动。选中的部分反色显示,点一下别处、按 `Esc` 或任意键就消失;有选中时只有 `Ctrl+C` 会复制。**输入框里**单击把光标移到那里,拖动、双击、三击选中正在写的文字,`Ctrl+C` 复制(不会打断任务,也不清空输入框);选中后打字不会替换选中的文字。**引用追问**(像 ChatGPT 的“向 ChatGPT 提问”):选中对话里的内容后按 `Ctrl+Q`(终端占用了 `Ctrl+Q` 时用 `Alt+Q`),选中的内容就以 `[Quote #1 +12 lines]` 插进输入框,光标停在下一行,直接写追问。发给模型的是选中的原文,加上它所在的那条工具调用、回复或消息的首行(`<quote source="⏺ Read(src/api.js)">…</quote>`),模型就知道问的是哪一段、哪个文件;对话里只显示引用的前三行。可以连续引用好几段,退格一次删掉整个引用。`Ctrl+V` 粘贴剪贴板文字(剪贴板里只有图片时作为图片附加),`Alt+V` 优先附加剪贴板图片;右键不执行复制或粘贴。仍可按住 Shift 拖动用终端自己的选中。退出后终端回到启动前的样子(对话不留在终端滚动记录里)
224
214
  - `ctrl+c` 或连按两次 `Esc` 清掉的草稿不会丢:在空输入框按 `↑` 找回(连同粘贴的文本和图片),中间发过别的消息也可以
225
215
  - `@` 同时补全文件和本机/远程会话:文件引用走 `Read` 工具,等于模型自己读了这个文件。最多带前 2000 行(被截断时会明确告诉模型,并把该文件记为"只读了一部分",之后 `Write` 不会去覆盖没给它看过的行);图片作为图片附加;二进制文件和超过 512KB 的文本会被跳过并提示原因;`@目录` 列出目录内容;行首 `@会话 任务` 把任务发给另一会话
226
216
  - 上下文用满上游输入上限时自动压缩(留出写摘要要用的余量:窗口的 5%,最多 4 万 token,这样摘要请求能读缓存而不是因超长被拒),不再读取 `CLAUDE_CODE_AUTO_COMPACT_WINDOW`;子 agent 定义的 `autoCompactWindow` 仍有效,也可手动 `/compact`
@@ -228,7 +218,7 @@ claude-pro config set CLAUDE_PRO_GATEWAY_URL https://gw.predix.icu
228
218
 
229
219
  **`/cd <目录>`**:换工作目录,对话接着进行。目录可以是绝对路径、`~`、相对当前目录的路径;不存在或不是目录时报错(不会创建)。会话在新目录里重启一次(约一秒),新目录的项目设置、CLAUDE.md、记忆、git 状态、`@` 文件/会话补全、输入历史都换成新目录的;对话、模型、effort、待办、网页上的远程会话(同一个链接)不变。会话记录跟着搬到新目录下,在新目录里 `/resume` 能找到。用 `/rename` 或 `--name` 起过的名字保留,默认按目录取的名字换成新目录名。任务进行中不能切换。
230
220
 
231
- **斜杠命令**:`/help` `/tui` `/cd` `/rename` `/peers` `/clear` `/compact` `/config` `/model` `/effort` `/status` `/cost` `/trace` `/context` `/init` `/review` `/memory` `/verify` `/tasks` `/rewind` `/skills` `/resume` `/todos` `/agents` `/mcp` `/bashes` `/verbose` `/export` `/doctor` `/exit`,以及 `.claude/commands/*.md`、`.claude-pro/commands/*.md`、`~/.claude-pro/commands/*.md` 中的自定义命令(支持 `$ARGUMENTS`、`$1`、`` !`cmd` ``)。
221
+ **斜杠命令**:`/help` `/cd` `/rename` `/peers` `/clear` `/compact` `/config` `/model` `/effort` `/status` `/cost` `/trace` `/context` `/init` `/review` `/memory` `/verify` `/tasks` `/rewind` `/skills` `/resume` `/todos` `/agents` `/mcp` `/bashes` `/verbose` `/export` `/doctor` `/exit`,以及 `.claude/commands/*.md`、`.claude-pro/commands/*.md`、`~/.claude-pro/commands/*.md` 中的自定义命令(支持 `$ARGUMENTS`、`$1`、`` !`cmd` ``)。
232
222
 
233
223
  **记忆**:自动读取 `~/.claude-pro/CLAUDE.md`、项目各级目录的 `CLAUDE.md` / `.claude/CLAUDE.md` / `CLAUDE.local.md`;某一级目录没有 `CLAUDE.md` 时读它的 `AGENTS.md` 代替(两者都有时通常是同一份说明,不重复发送)。
234
224
 
@@ -262,18 +252,13 @@ claude-pro config set CLAUDE_PRO_GATEWAY_URL https://gw.predix.icu
262
252
  } }
263
253
  ```
264
254
 
265
- ## 浏览器:指定要操作的标签页
255
+ ## 浏览器
266
256
 
267
257
  `Browser` 工具操作你自己的 Edge/Chrome(带着你的登录状态),也可以用 claude-pro 自己的浏览器(`browser: "own"`)。先在 Edge 的 `edge://inspect/#remote-debugging`(Chrome 是 `chrome://inspect/#remote-debugging`)里打开允许远程调试。浏览器对每个新连接都会弹窗问“是否允许远程调试”(没有“始终允许”),所以连接由一个后台小进程(`src/browser/broker.js`)替所有 claude-pro 会话保持:每个浏览器实例只需点一次“允许”,claude-pro 重启、新开会话都沿用这个连接,不再弹窗。最后一个用它的会话退出 10 分钟后,后台进程才断开连接并退出;之后再用浏览器会重新问一次。
268
258
 
269
- **用 `/tabs` 指定标签页**:列出浏览器里所有标签页和它们的 ID,用方向键选一个,回车。同时开着几个允许远程调试的浏览器实例时(例如一个用独立数据目录启动的 Edge 应用窗口,它和平常的 Edge 是两个实例,标签页互不相通),先让你选浏览器:`Microsoft Edge`、`Microsoft Edge · ASR-Web\desktop-profile`……;`/tabs edge` 只列 Edge 的实例,`/tabs asr` 按数据目录里的字筛选。标签页列表最后一项“Another browser or profile…”可以换到别的实例。选中标签页后:
270
-
271
- - 这个标签页成为 Browser 工具当前操作的标签页,并在浏览器里切到前台;
272
- - 输入框里插入 `[Browser tab t3f9a in Microsoft Edge: "(1) 收件箱 | …"]`,接着写要它做什么就行,模型不用再列出标签页查找、匹配。
273
-
274
- 标签页 ID 是 `t` 加浏览器内部 ID 的前几位,只要标签页没关就不变:重新连接或 claude-pro 重启后,同一个 ID 还是同一个标签页,所以也可以直接在消息里写“用 t3f9a”。标签页关了,ID 就失效并报错,不会落到别的标签页上。
259
+ **指定标签页**:在消息里写网址或标题里的字(例如“操作 YouTube 那个标签页”),模型在当前连着的浏览器里按标题和网址找到它。标签页 ID 是 `t` 加浏览器内部 ID 的前几位,只要标签页没关就不变:重新连接或 claude-pro 重启后,同一个 ID 还是同一个标签页,所以也可以直接在消息里写“用 t3f9a”。标签页关了,ID 就失效并报错,不会落到别的标签页上。
275
260
 
276
- 选过的浏览器实例会记住:claude-pro 重启后,模型下一次用浏览器时自动连回这个实例,对话里的标签页 ID 仍然有效。没选过时,自动选第一个开了远程调试的浏览器(按 Edge、Chrome、Brave、Chromium 的常用数据目录,再到用独立数据目录运行的实例);要固定默认,`/config set CLAUDE_PRO_BROWSER edge`。查找浏览器实例要读取正在运行的浏览器进程(Windows 上约 1–3 秒),已经连着浏览器时直接 `/tabs` 不用再找。
261
+ 用过的浏览器实例会记住:claude-pro 重启后,模型下一次用浏览器时自动连回这个实例,对话里的标签页 ID 仍然有效。没用过时,自动选第一个开了远程调试的浏览器(按 Edge、Chrome、Brave、Chromium 的常用数据目录,再到用独立数据目录运行的实例);要固定默认,`/config set CLAUDE_PRO_BROWSER edge`。
277
262
 
278
263
  ## 非交互模式
279
264
 
@@ -292,14 +277,14 @@ claude-pro -p "只调研,给出重构方案,不要改文件" # 只出方
292
277
  | `Enter` | 发送 |
293
278
  | `\` + `Enter` / `ctrl+j` / `alt+enter` | 换行 |
294
279
  | `Esc` | 中断当前任务;连按两次:有文字时清空输入,输入框为空时打开回退菜单(同 `/rewind`) |
295
- | `ctrl+c` | 全屏有选中文字时复制;否则中断 / 清空输入 / 连按两次退出 |
296
- | `ctrl+q` / `alt+q` | 全屏有选中文字时把它引用进输入框,在下一行写追问;模型会收到原文和它所在的工具调用或回复 |
280
+ | `ctrl+c` | 有选中文字时复制;否则中断 / 清空输入 / 连按两次退出 |
281
+ | `ctrl+q` / `alt+q` | 有选中文字时把它引用进输入框,在下一行写追问;模型会收到原文和它所在的工具调用或回复 |
297
282
  | `ctrl+v` | 粘贴剪贴板文字(只有图片时附加图片) |
298
283
  | `alt+v` | 附加剪贴板图片(没有图片时粘贴文字) |
299
284
  | `ctrl+t` | 显示/隐藏 todo 列表 |
300
285
  | `ctrl+l` | 清屏重绘 |
301
- | `PgUp` / `PgDn`、滚轮、`Ctrl+Home` / `Ctrl+End` | 全屏模式下滚动对话 / 到开头 / 回到最新 |
302
- | `ctrl+f` | 全屏模式下在对话里查找(像 VS Code):输入框的位置换成查找框,边输入边高亮所有匹配(不分大小写,当前这个橙色、其余黄色),右上角显示"第几个/共几个"(`No results` 表示没有)。先跳到视图底部往上最近的一个;`Enter` 或 `↑` 跳到更早的一个,`Shift+Enter` 或 `↓` 跳到更新的一个,到头后绕回;`PgUp`/`PgDn`、滚轮照常滚动;`Esc` 关闭,画面停在当前位置(`Ctrl+End` 回到底部)。再按 `ctrl+f` 会带上上次的关键字(已选中,直接输入就替换);先用鼠标选中文字再按,会搜选中的文字。查找时有新输出,匹配会跟着更新。经典模式(`/tui default`)的对话在终端自己的滚动缓冲里,请用终端自带的查找 |
286
+ | `PgUp` / `PgDn`、滚轮、`Ctrl+Home` / `Ctrl+End` | 滚动对话 / 到开头 / 回到最新 |
287
+ | `ctrl+f` | 在对话里查找(像 VS Code):输入框的位置换成查找框,边输入边高亮所有匹配(不分大小写,当前这个橙色、其余黄色),右上角显示"第几个/共几个"(`No results` 表示没有)。先跳到视图底部往上最近的一个;`Enter` 或 `↑` 跳到更早的一个,`Shift+Enter` 或 `↓` 跳到更新的一个,到头后绕回;`PgUp`/`PgDn`、滚轮照常滚动;`Esc` 关闭,画面停在当前位置(`Ctrl+End` 回到底部)。再按 `ctrl+f` 会带上上次的关键字(已选中,直接输入就替换);先用鼠标选中文字再按,会搜选中的文字。查找时有新输出,匹配会跟着更新。 |
303
288
  | `↑` / `↓` | 在多行输入(包括自动折行的长文字)里上下移动光标;光标在第一行时 `↑` 先移到开头、再按才翻到上一条历史消息,`↓` 在最后一行同理 |
304
289
  | `Tab` | 补全命令 / 文件 |
305
290
 
@@ -338,7 +323,7 @@ src/commands.js 斜杠命令
338
323
 
339
324
  WebSearch 依赖网关:没有网关时只能抓取 DuckDuckGo/Bing 网页,而它们常把程序当爬虫拦下(DuckDuckGo 返回 202,Bing 只按查询的第一个词搜),结果可能离题。GitHub 相关的查询,系统提示词让模型优先用 Bash 跑 `gh`(需要已安装并登录)。检查点只覆盖文件工具的修改,不覆盖 Bash 命令造成的改动。
340
325
 
341
- 提示:全屏模式里的鼠标选择不会自动写入剪贴板;使用 `Ctrl+C` 复制、`Ctrl+V` 粘贴,`Ctrl+Q` 引用到输入框里追问。按住 Shift 的终端原生选择行为由终端自身决定。
326
+ 提示:鼠标选择不会自动写入剪贴板;使用 `Ctrl+C` 复制、`Ctrl+V` 粘贴,`Ctrl+Q` 引用到输入框里追问。按住 Shift 的终端原生选择行为由终端自身决定。
342
327
 
343
328
  ## 历史
344
329
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yanzc/claude-pro",
3
- "version": "0.9.5",
3
+ "version": "0.9.7",
4
4
  "description": "claude-pro: a command line coding agent for the codex-gateway. Full access with no permission prompts; file edits are checkpointed and can be rewound.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -154,8 +154,8 @@ const howToTurnOn = (b) => `${b.label} does not allow remote debugging now. The
154
154
  //
155
155
  // A browser started with a profile directory of its own (--user-data-dir: an app that opens its window in Edge, a
156
156
  // second profile kept apart) is another instance, with its own tabs and its own DevToolsActivePort in that
157
- // directory, which the usual places do not have: /tabs edge listed the user's main Edge and not the one their
158
- // mail was open in. The running browsers' command lines say where each one keeps its profile.
157
+ // directory, which the usual places do not have: looking in those only missed the Edge the user's mail was open
158
+ // in. The running browsers' command lines say where each one keeps its profile.
159
159
 
160
160
  const samePath = (a, b) => {
161
161
  const x = path.resolve(String(a));
@@ -229,7 +229,7 @@ function shortDir(dir) {
229
229
  return dir;
230
230
  }
231
231
 
232
- // An instance found at `dir`, for /tabs and the Browser tool: {name, label, dir, url, port, isDefault, own?}.
232
+ // An instance found at `dir`, for the Browser tool: {name, label, dir, url, port, isDefault, own?}.
233
233
  function instance(kind, dir, url) {
234
234
  if (kind === 'own' || samePath(dir, OWN.dir)) return { ...OWN, dir: OWN.dir, url, port: portOf(url), own: true };
235
235
  const base = knownBrowsers().find((b) => b.name === kind) || { name: kind || 'chrome', label: 'Chromium browser', inspect: 'chrome://inspect/#remote-debugging' };
@@ -258,7 +258,7 @@ export async function browserInstances() {
258
258
  return found.filter(Boolean);
259
259
  }
260
260
 
261
- // The instance the session used last (picked with /tabs, or the one before a restart), when it is still there and
261
+ // The instance the session used last (the one before a restart, too), when it is still there and
262
262
  // the call asks for no browser in particular or for one of its kind (`w`, the call's own browser field: the user's
263
263
  // pick wins over the configured default): its tab ids are the ones the conversation knows.
264
264
  async function preferredTarget(preferred, w) {
@@ -287,7 +287,7 @@ export async function resolveBrowser(spec, env, signal, preferred = null) {
287
287
  // not in its usual profile: one running on a profile directory of its own
288
288
  const others = (await browserInstances()).filter((i) => i.name === w);
289
289
  if (others.length === 1) return others[0];
290
- if (others.length > 1) throw new BrowserError(`${known.label} allows remote debugging in ${others.length} profile directories: ${others.map((i) => i.dir).join('; ')}. Pass the one meant as browser (the user can pick one with /tabs)`);
290
+ if (others.length > 1) throw new BrowserError(`${known.label} allows remote debugging in ${others.length} profile directories: ${others.map((i) => i.dir).join('; ')}. Pass the one meant as browser (ask the user which one)`);
291
291
  throw new BrowserError(howToTurnOn(known));
292
292
  }
293
293
  if (/[\\/]/.test(wanted) && fs.existsSync(wanted) && fs.statSync(wanted).isDirectory()) {
@@ -406,7 +406,7 @@ class BrowserSession {
406
406
  return next;
407
407
  }
408
408
 
409
- // `spec`: what the call asked for (see resolveBrowser), or an instance from browserInstances (/tabs). The user's
409
+ // `spec`: what the call asked for (see resolveBrowser), or an instance from browserInstances. The user's
410
410
  // browsers are reached through the broker (broker.js), whose connection outlives this process: the user allows
411
411
  // it once, not again at every restart and in every session. Another browser asked for is found and connected to
412
412
  // before the one there is let go: a request for one that is not there (chrome, when only Edge allows it) cost
@@ -465,8 +465,8 @@ class BrowserSession {
465
465
  // A tab's id is "t" and the start of its own id in the browser (its targetId, which it keeps while it is open),
466
466
  // 4 hex digits or as many more as it takes to tell it from the other open tabs. Numbers given in the order of a
467
467
  // connection (t1, t2...) started again at every reconnect and restart of claude-pro, so that an id in the
468
- // conversation (one the user picked with /tabs, say) could then be another tab, the one the agent would click in
469
- // or close. These ids mean the same tab in every connection and every session (see tab).
468
+ // conversation could then be another tab, the one the agent would click in or close. These ids mean the same tab
469
+ // in every connection and every session (see tab).
470
470
  relabel() {
471
471
  const hexTabs = [...this.tabs.values()].filter((t) => t.hex);
472
472
  for (const tab of hexTabs) {
@@ -857,7 +857,9 @@ class BrowserSession {
857
857
  }
858
858
 
859
859
  async evaluate(tab, script, ref) {
860
- const isFn = /^\s*(async\s+)?(function\b|\([^)]*\)\s*=>|[\w$]+\s*=>)/.test(script);
860
+ // a function is called; one that calls itself already ((() => {…})()) is an expression, not called again
861
+ const iife = /^\s*\(/.test(script) && /\)\s*\(\s*\)\s*;?\s*$/.test(script);
862
+ const isFn = !iife && /^\s*(async\s+)?(function\b|\([^)]*\)\s*=>|[\w$]+\s*=>)/.test(script);
861
863
  let r;
862
864
  if (ref) {
863
865
  const objectId = await this.objectId(tab, refId(ref), ref);
package/src/commands.js CHANGED
@@ -16,11 +16,9 @@ import { estimateTokens } from './agent.js';
16
16
  import { quickQuery, cacheRefusals, defaultEffort, effortToSend, CLAUDE_EFFORTS } from './api.js';
17
17
  import { hasRipgrep } from './utils/shell.js';
18
18
  import { displayPath, normalizeDir, resolvePath } from './utils/paths.js';
19
- import { activePromptName, listPromptProfiles, loadActivePrompt, promptDirectory, promptNameForText, savePrompt, setActivePrompt } from './prompt-profiles.js';
20
19
  import { cleanName, machineName } from './peers.js';
21
20
  import { rewind, promptAt } from './checkpoints.js';
22
21
  import { canRestart, runSelfCheck } from './restart.js';
23
- import { browserSession, browserInstances, sameBrowser, safeUrl } from './browser/session.js';
24
22
 
25
23
  const EFFORTS = ['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
26
24
  const isGpt = (modelId) => /^gpt-/i.test(modelId);
@@ -119,91 +117,6 @@ export function buildCommands(app) {
119
117
  return choice === 'yes';
120
118
  };
121
119
 
122
- const unquotePromptArgument = (args) => {
123
- const value = String(args ?? '').trim();
124
- return /^(["'])[\s\S]*\1$/.test(value) ? value.slice(1, -1).trim() : value;
125
- };
126
-
127
- // `/prompt` accepts either an existing file or literal text. Files are copied into the user's prompt directory so
128
- // changing or deleting the source later does not change the prompt used by future sessions.
129
- const readPromptArgument = (args) => {
130
- const value = unquotePromptArgument(args);
131
- if (!value) throw new Error('Usage: /prompt <file|text>');
132
- const file = resolvePath(value, app.cwd);
133
- let stat = null;
134
- try { stat = fs.statSync(file); } catch (e) { if (e.code !== 'ENOENT') throw e; }
135
- if (stat) {
136
- if (!stat.isFile()) throw new Error(`Prompt source is not a file: ${file}`);
137
- const text = fs.readFileSync(file, 'utf8');
138
- if (!text.trim()) throw new Error(`Prompt source is empty: ${file}`);
139
- return { name: path.basename(file), text, source: file };
140
- }
141
- return { name: promptNameForText(value), text: value, source: null };
142
- };
143
-
144
- const promptChanged = (name, text = undefined) => {
145
- const currentName = activePromptName();
146
- if (currentName !== name) return true;
147
- if (text === undefined) return false;
148
- return loadActivePrompt()?.text !== text;
149
- };
150
-
151
- const activatePrompt = async (name, { text, saved = null } = {}) => {
152
- const changed = promptChanged(name, text);
153
- if (!changed) {
154
- out(`System prompt is already ${name ? c.bold(name) : c.bold('the built-in default')}.`);
155
- return false;
156
- }
157
- if (!(await confirmCacheLoss('Changing the system prompt'))) {
158
- out(c.dim('The system prompt was not changed.'));
159
- return false;
160
- }
161
- const stored = saved ? savePrompt(saved.name, saved.text, { activate: true }) : null;
162
- if (!saved) setActivePrompt(name);
163
- // A prompt choice is persistent, but also takes effect for the next request in this session. The cache check
164
- // above is the same safeguard used by /model and /effort when changing request-level cache inputs.
165
- app.runtime.invalidateSystemPrompt();
166
- const label = name ? c.bold(name) : c.bold('the built-in default');
167
- const location = stored ? ` · copied to ${displayPath(stored.file, app.cwd)}` : '';
168
- out(`System prompt set to ${label}${location} · kept for later sessions${promptDirectory() ? c.dim(` (${promptDirectory()})`) : ''}`);
169
- return true;
170
- };
171
-
172
- const choosePrompt = async (args = '') => {
173
- const wanted = unquotePromptArgument(args);
174
- const profiles = listPromptProfiles();
175
- const current = activePromptName();
176
- if (wanted) {
177
- if (/^(default|none|off)$/i.test(wanted)) return activatePrompt(null);
178
- const found = profiles.find((p) => p.name === wanted) || profiles.find((p) => p.name.toLowerCase() === wanted.toLowerCase());
179
- if (!found) {
180
- out(c.red(`No saved prompt named "${wanted}". Use /prompts to choose one, or /prompt <file|text> to save it.`));
181
- return false;
182
- }
183
- return activatePrompt(found.name);
184
- }
185
- if (!profiles.length) {
186
- out(c.dim(`No saved prompts. Use /prompt <file|text> to create one (saved in ${promptDirectory()}).`));
187
- return false;
188
- }
189
- const options = [
190
- { label: `Built-in default${current ? '' : c.dim(' (active)')}`, value: '__default__', description: 'Use claude-pro\'s normal system prompt' },
191
- ...profiles.map((p) => ({
192
- label: `${p.name}${p.name === current ? c.dim(' (active)') : ''}`,
193
- value: p.name,
194
- description: p.preview || `${p.size} bytes`,
195
- })),
196
- ];
197
- const selected = await app.showDialog(new SelectDialog({
198
- title: 'Select system prompt',
199
- question: `Saved prompts in ${promptDirectory()}`,
200
- options,
201
- selected: Math.max(0, current ? options.findIndex((o) => o.value === current) : 0),
202
- }));
203
- if (selected === null || selected === undefined) return false;
204
- return activatePrompt(selected === '__default__' ? null : selected);
205
- };
206
-
207
120
  add({
208
121
  name: 'help',
209
122
  description: 'Show help and available commands',
@@ -360,27 +273,6 @@ export function buildCommands(app) {
360
273
  },
361
274
  });
362
275
 
363
- add({
364
- name: 'prompt',
365
- aliases: ['promt'],
366
- argHint: '<file|text>',
367
- argRequired: true,
368
- description: 'Save and use a system prompt from a file or literal text (kept for later sessions)',
369
- async run(args) {
370
- if (!unquotePromptArgument(args)) return choosePrompt('');
371
- const source = readPromptArgument(args);
372
- return activatePrompt(source.name, { text: source.text, saved: source });
373
- },
374
- });
375
-
376
- add({
377
- name: 'prompts',
378
- aliases: ['promits', 'promts'],
379
- argHint: '[name|default]',
380
- description: 'Choose a saved system prompt, or return to the built-in default',
381
- run(args) { return choosePrompt(args); },
382
- });
383
-
384
276
  add({
385
277
  name: 'model',
386
278
  argHint: '[model]',
@@ -536,7 +428,6 @@ export function buildCommands(app) {
536
428
  run() {
537
429
  const cfg = app.runtime.config;
538
430
  const mem = memoryFiles(app.cwd);
539
- const savedPrompt = loadActivePrompt();
540
431
  const mcp = app.runtime.mcp.status();
541
432
  const row = (k, v) => `${c.dim(padEnd(k, 18))} ${v}`;
542
433
  log([
@@ -549,9 +440,7 @@ export function buildCommands(app) {
549
440
  row('Auth', gatewayLogin(cfg.gatewayUrl) ? `gateway key of ${gatewayLogin(cfg.gatewayUrl).account?.email || 'this machine'} ${c.dim('(/cost shows the balance)')}` : c.red('not logged in (/login)')),
550
441
  row('Model', `${cfg.model.label} ${c.dim(`(sent as "${cfg.model.id}", ${formatTokens(cfg.model.contextWindow)} context)`)}`),
551
442
  row('Effort', cfg.effort || 'auto'),
552
- row('System prompt', app.flags.systemPrompt !== undefined
553
- ? 'command line override'
554
- : savedPrompt?.text != null ? `${savedPrompt.name} (saved)` : savedPrompt?.error ? `${savedPrompt.name} (missing; using built-in)` : 'built-in default'),
443
+ row('System prompt', app.flags.systemPrompt !== undefined ? 'command line override' : 'built-in default'),
555
444
  row('Max output', formatTokens(cfg.maxOutputTokens)),
556
445
  row('Prompt cache', cfg.promptCachingDisabled() ? 'off (DISABLE_PROMPT_CACHING)' : `on · TTL ${cfg.cacheTtl('main')} for the conversation, ${cfg.cacheTtl('other')} for sub-agents and compaction${cacheRefusals(cfg, cfg.model.id).length ? c.yellow(` · the endpoint refused: ${cacheRefusals(cfg, cfg.model.id).join(', ')}`) : ''}${app.runtime.systemPromptStale ? c.dim(' · memory/config changes reach the system prompt at /clear or /compact') : ''}`),
557
446
  row('Auto-compact', `at ${formatTokens(cfg.compactWindow())} tokens (the window, less room for the summary)`),
@@ -760,128 +649,6 @@ export function buildCommands(app) {
760
649
  },
761
650
  });
762
651
 
763
- // The tab the Browser tool is to work in, picked by the user instead of looked for by the model: the tabs of the
764
- // browser with their ids, from the same connection the tool uses (so the ids are the tool's), and the one picked is
765
- // selected there and named in the message being written. Its id stays that tab's after a reconnect or a restart
766
- // (BrowserSession.relabel), so the agent goes straight to it. Several browser instances may allow remote debugging
767
- // (Edge also on a profile directory of its own, as an app's window has): the user picks one first, and the
768
- // session goes back to it after a restart (BrowserSession.preferred).
769
- add({
770
- name: 'tabs',
771
- aliases: ['tab'],
772
- argHint: '[edge|chrome|brave|chromium|own|words of a profile directory]',
773
- description: 'Pick a tab of your browser for the Browser tool: it is selected, and its id goes into your message',
774
- async run(args) {
775
- // the agent's own browser calls go to the selected tab: not changed under it while it works
776
- if (app.isTurnRunning()) { out(c.dim('The agent is working and may be using the browser: /tabs once the turn is done (or Esc).')); return; }
777
- if (app.runtime.tasks.running().length) { out(c.dim('Background agents are running and may be using the browser: /tabs once they are done (/tasks).')); return; }
778
- const s = browserSession;
779
- // Esc cancels while it waits: the browser may ask the user to allow the connection first
780
- const busy = async (status, fn) => {
781
- app.busy = true;
782
- app.status = status;
783
- app.turnStart = Date.now();
784
- app.controller = new AbortController();
785
- try { return await s.run(app.controller.signal, fn); } finally {
786
- app.busy = false;
787
- app.status = null;
788
- app.controller = null;
789
- app.screen.schedule();
790
- }
791
- };
792
- const failed = (e, what) => out(e?.name === 'AbortError' ? c.dim('Cancelled.') : c.red(`${what}: ${e.message}`));
793
- // The instance to connect to: the one matching `ask` (a kind, or words of its profile directory), or the user's
794
- // pick when several are there. null: none, or the user closed the list.
795
- const chooseBrowser = async (ask) => {
796
- let all;
797
- try { all = await busy('Looking for browsers', () => browserInstances()); } catch (e) { failed(e, 'Cannot list the browsers'); return null; }
798
- const q = ask.toLowerCase();
799
- const list = q ? all.filter((i) => i.name === q || `${i.label} ${i.dir}`.toLowerCase().includes(q)) : all;
800
- if (!list.length) {
801
- out(c.red(`${q ? `No browser matching "${ask}" allows` : 'No browser allows'} remote debugging now. Turn it on in yours at edge://inspect/#remote-debugging (Chrome: chrome://inspect/#remote-debugging) and allow it for this browser instance.`));
802
- return null;
803
- }
804
- if (list.length === 1) return list[0];
805
- const connected = list.find((i) => s.connected && sameBrowser(i, s.browser));
806
- const key = await app.showDialog(new SelectDialog({
807
- title: 'Which browser?',
808
- question: 'These allow remote debugging now; each asks once per connection to allow it.',
809
- options: list.map((i) => ({ value: i.dir || i.url, label: `${i.label}${i === connected ? c.dim(' (connected)') : ''}`, description: `${i.dir}${i.port ? ` · port ${i.port}` : ''}` })),
810
- selected: Math.max(0, list.indexOf(connected)),
811
- }));
812
- return key ? list.find((i) => (i.dir || i.url) === key) : null;
813
- };
814
- try {
815
- const ask = args.trim();
816
- let target = null;
817
- if (ask || !s.connected) {
818
- target = await chooseBrowser(ask);
819
- if (!target) return;
820
- }
821
- for (;;) {
822
- if (target) {
823
- const connecting = target;
824
- target = null;
825
- try {
826
- await busy('Connecting to the browser', () => s.connect(connecting, app.runtime.config.env, (b) => {
827
- app.status = `Allow the connection in ${b.label} ("Allow remote debugging?" → Allow) · Esc cancels`;
828
- app.screen.schedule();
829
- }));
830
- } catch (e) { failed(e, 'Cannot use the browser'); return; }
831
- }
832
- const browser = s.browser;
833
- const tabs = [...s.tabs.values()];
834
- if (!browser) { out(c.dim('The connection to the browser was lost.')); return; }
835
- const title = (t, n) => truncate(String(t.title || '(no title)').replace(/\s+/g, ' '), n);
836
- const chosen = await app.showDialog(new SelectDialog({
837
- title: `Tabs in ${browser.label}`,
838
- question: 'The Browser tool works in the tab you pick, and its id goes into your message.',
839
- options: [
840
- ...tabs.map((t) => ({ value: t.targetId, label: `${padEnd(t.id, 8)} ${title(t, 70)}${t === s.current ? c.dim(' (selected)') : ''}`, description: safeUrl(t.url || '') })),
841
- { value: '__browser__', label: c.dim('Another browser or profile…') },
842
- ],
843
- selected: Math.max(0, tabs.indexOf(s.current)),
844
- }));
845
- if (!chosen) return;
846
- if (chosen === '__browser__') {
847
- target = await chooseBrowser('');
848
- if (!target) return;
849
- continue;
850
- }
851
- const tab = s.tabs.get(chosen);
852
- if (!tab) { out(c.red('That tab was closed meanwhile.')); return; }
853
- try { await busy('Selecting the tab', () => s.select(tab)); } catch (e) { failed(e, `Could not select ${tab.id}`); return; }
854
- app.editor.insert(`[Browser tab ${tab.id} in ${browser.label}: ${JSON.stringify(title(tab, 60))}] `);
855
- out(c.dim(`${tab.id} is the Browser tool's tab now, and its id is in your message.`));
856
- return;
857
- }
858
- } finally {
859
- app.sendWhatWaited(); // what was typed while it connected
860
- }
861
- },
862
- });
863
-
864
- add({
865
- name: 'tui',
866
- argHint: '[fullscreen | default]',
867
- description: 'The renderer: fullscreen (the input box fixed at the bottom, the conversation scrolled with the wheel or PgUp/PgDn) or default (it scrolls in the terminal)',
868
- run(args) {
869
- const want = args.trim().toLowerCase();
870
- if (!want) {
871
- out(`The ${c.bold(app.screen.full ? 'fullscreen' : 'default')} renderer is active. /tui fullscreen or /tui default switches (and is remembered).`);
872
- return;
873
- }
874
- if (want !== 'fullscreen' && want !== 'default') { out(c.red('Use /tui fullscreen or /tui default.')); return; }
875
- const file = settingsFiles(app.cwd).user;
876
- writeConfigSetting(file, 'tui', want);
877
- reloadConfig();
878
- app.screen.setFull(want === 'fullscreen');
879
- out(want === 'fullscreen'
880
- ? `Fullscreen: the input box stays at the bottom; scroll with the wheel, PgUp/PgDn, ctrl+Home/End; drag to select, then use ctrl+c to copy; ctrl+f to find in the conversation. (Saved in ${file})`
881
- : `Default renderer: the conversation scrolls in the terminal. (Saved in ${file})`);
882
- },
883
- });
884
-
885
652
  add({
886
653
  name: 'rename',
887
654
  argHint: '<name>',
package/src/config.js CHANGED
@@ -30,7 +30,6 @@ export const VERSION = JSON.parse(fs.readFileSync(path.join(INSTALL_DIR, 'packag
30
30
  export const BASIC_SETTINGS = {
31
31
  model: { default: 'opus', legacy: 'CLAUDE_PRO_GATEWAY_MODEL', description: 'Default model; /model and --model override it' },
32
32
  effort: { default: 'auto', legacy: 'CLAUDE_CODE_EFFORT_LEVEL', description: 'Reasoning effort; /effort and --effort override it' },
33
- tui: { default: 'fullscreen', legacy: 'CLAUDE_PRO_TUI', description: 'fullscreen or default; /tui switches and remembers it' },
34
33
  promptCacheTtl: { default: '1h', legacy: 'CLAUDE_CODE_PROMPT_CACHE_TTL', description: 'Conversation prompt cache: 5m or 1h' },
35
34
  subagentPromptCacheTtl: { default: '5m', legacy: 'CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL', description: 'Sub-agent, compaction and side-query prompt cache: 5m or 1h' },
36
35
  // `userOnly`: read from ~/.claude-pro/settings.json only. It deletes the data of every project, so a project's
@@ -77,7 +76,6 @@ function basicValue(key, value) {
77
76
  }
78
77
  const normalized = text.toLowerCase();
79
78
  if (key === 'effort' && ['auto', 'default', 'none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max', 'ultra'].includes(normalized)) return normalized;
80
- if (key === 'tui' && ['fullscreen', 'default'].includes(normalized)) return normalized;
81
79
  if ((key === 'promptCacheTtl' || key === 'subagentPromptCacheTtl') && normalizeTtl(normalized)) return normalized;
82
80
  throw new Error(`Invalid ${key}: ${text}. ${BASIC_SETTINGS[key].description}.`);
83
81
  }
package/src/runtime.js CHANGED
@@ -17,7 +17,6 @@ import { autoMemoryDir, sweepOldData, projectDir } from './session.js';
17
17
  import { loadAutoMemoryIndex, takeEnvSnapshot, takeEnvSnapshotAsync, localDate } from './context.js';
18
18
  import { canRestart } from './restart.js';
19
19
  import { RuntimeTrace } from './trace.js';
20
- import { loadActivePrompt } from './prompt-profiles.js';
21
20
 
22
21
  export async function createRuntime({ cwd, flags = {}, io, sessionId = '' }) {
23
22
  const config = loadConfig({ cwd, flags });
@@ -85,12 +84,9 @@ export async function createRuntime({ cwd, flags = {}, io, sessionId = '' }) {
85
84
  runtime.systemPrompt = () => {
86
85
  if (!promptCache) {
87
86
  const autoMemory = config.autoMemoryEnabled ? { dir: memoryDir, index: loadAutoMemoryIndex(memoryDir) } : null;
88
- const savedPrompt = flags.systemPrompt === undefined ? loadActivePrompt() : null;
89
87
  promptCache = flags.systemPrompt !== undefined
90
88
  ? flags.systemPrompt
91
- : savedPrompt?.text != null
92
- ? savedPrompt.text
93
- : mainSystemPrompt({ cwd, model: config.model, shellName: shell.name, extra: flags.appendSystemPrompt || '', autoMemory, mcpInstructions: mcp.promptInstructions(), selfRestart: selfEdit, installedCopy: !SOURCE_CHECKOUT, snapshot: snapshotFor(cwd) });
89
+ : mainSystemPrompt({ cwd, model: config.model, shellName: shell.name, extra: flags.appendSystemPrompt || '', autoMemory, mcpInstructions: mcp.promptInstructions(), selfRestart: selfEdit, installedCopy: !SOURCE_CHECKOUT, snapshot: snapshotFor(cwd) });
94
90
  promptStale = false;
95
91
  }
96
92
  return promptCache;
package/src/ui/repl.js CHANGED
@@ -1057,8 +1057,8 @@ export class App {
1057
1057
  changedDirectory: Boolean(request.cwd),
1058
1058
  // where the agent's shell is (a `cd` in Bash moves it): the next process goes on there, not at the project's root
1059
1059
  agentCwd: request.cwd ? null : this.agent.cwd,
1060
- // the browser instance in use (one picked with /tabs may be any of several): the next process connects to it
1061
- // again, where the tab ids in the conversation are still its tabs'
1060
+ // the browser instance in use (it may be any of several): the next process connects to it again, where the
1061
+ // tab ids in the conversation are still its tabs'
1062
1062
  browser: browserSession.preferred || null,
1063
1063
  sessionId: this.store.id,
1064
1064
  sessionFile: moved?.file || this.store.file,
@@ -1316,10 +1316,10 @@ export class App {
1316
1316
 
1317
1317
  // ---------------------------------------------------------------- input
1318
1318
 
1319
- // Fullscreen unless settings.tui selects the classic renderer; a driven test defaults to classic.
1319
+ // Always fullscreen on a terminal (there is no other mode to choose). Output that is no terminal (isTTY false: a
1320
+ // test's fake terminal that asks for it) is written as it comes, with the input box after it.
1320
1321
  fullscreenWanted() {
1321
- const mode = this.driven && this.config.settings.tui == null ? 'default' : this.config.setting('tui');
1322
- return mode === 'fullscreen' && this.stdout.isTTY !== false;
1322
+ return this.stdout.isTTY !== false;
1323
1323
  }
1324
1324
 
1325
1325
  // Fullscreen: the wheel scrolls the conversation (3 rows a notch); a drag,
@@ -1350,7 +1350,7 @@ export class App {
1350
1350
  // "[Quote #1 +12 lines]"; the model gets the text and the line of the conversation it is under (see
1351
1351
  // Editor.insertQuote), so that it knows which part, and which file or command, the question is about.
1352
1352
  quoteSelection() {
1353
- if (!this.screen.full) { this.flash('Quoting works in fullscreen (/tui fullscreen): select text with the mouse, then ctrl+q', 'warn'); return; }
1353
+ if (!this.screen.full) { this.flash('Quoting needs the fullscreen view: select text with the mouse, then ctrl+q', 'warn'); return; }
1354
1354
  const quote = this.screen.selectionQuote();
1355
1355
  if (!quote?.text.trim()) { this.flash('Select part of the conversation first (drag over it, or double/triple-click), then ctrl+q', 'warn'); return; }
1356
1356
  if (this.dialogs.length) { this.flash('Answer the open question first, then quote', 'warn'); return; }
@@ -1700,7 +1700,7 @@ export class App {
1700
1700
  // renderer the conversation is in the terminal's own scrollback.
1701
1701
 
1702
1702
  openFind(seed = '') {
1703
- if (!this.screen.full) { this.flash('ctrl+f finds in the conversation in fullscreen (/tui); here use the terminal\'s own find', 'warn'); return; }
1703
+ if (!this.screen.full) { this.flash('ctrl+f needs the fullscreen view; here use the terminal\'s own find', 'warn'); return; }
1704
1704
  if (this.finder && !seed.trim()) { this.finder.selected = Boolean(this.finder.text); this.screen.schedule(); return; } // open: select what is typed
1705
1705
  const text = (seed.split('\n').find((l) => l.trim()) || '').trim() || this.lastFind || '';
1706
1706
  if (!this.finder) this.screen.openFind();
@@ -1,109 +0,0 @@
1
- // Persistent system-prompt profiles saved in the user's claude-pro configuration.
2
-
3
- import fs from 'node:fs';
4
- import path from 'node:path';
5
- import { CONFIG_DIR, updateSettingsFile } from './config.js';
6
-
7
- export const PROMPTS_DIR = path.join(CONFIG_DIR, 'prompts');
8
- const SETTINGS_FILE = path.join(CONFIG_DIR, 'settings.json');
9
-
10
- const isPromptName = (name) => {
11
- const value = String(name ?? '').trim();
12
- return Boolean(value) && value !== '.' && value !== '..' && !/[\\/\0]/.test(value);
13
- };
14
-
15
- function readSettings() {
16
- try {
17
- return JSON.parse(fs.readFileSync(SETTINGS_FILE, 'utf8').replace(/^\uFEFF/, ''));
18
- } catch {
19
- return null;
20
- }
21
- }
22
-
23
- function profileFile(name) {
24
- if (!isPromptName(name)) throw new Error(`Invalid prompt name: ${name}`);
25
- return path.join(PROMPTS_DIR, name);
26
- }
27
-
28
- export function activePromptName() {
29
- const prompts = readSettings()?.prompts;
30
- const name = prompts && typeof prompts === 'object' && !Array.isArray(prompts) ? prompts.active : null;
31
- return isPromptName(name) ? String(name).trim() : null;
32
- }
33
-
34
- // Returns null for the built-in prompt, or a descriptor with an error when the selected file disappeared.
35
- export function loadActivePrompt() {
36
- const name = activePromptName();
37
- if (!name) return null;
38
- const file = profileFile(name);
39
- try {
40
- return { name, file, text: fs.readFileSync(file, 'utf8') };
41
- } catch (error) {
42
- return { name, file, text: null, error };
43
- }
44
- }
45
-
46
- export function listPromptProfiles() {
47
- let entries;
48
- try { entries = fs.readdirSync(PROMPTS_DIR, { withFileTypes: true }); } catch { return []; }
49
- return entries
50
- .filter((entry) => entry.isFile() && isPromptName(entry.name))
51
- .map((entry) => {
52
- const file = path.join(PROMPTS_DIR, entry.name);
53
- let size = 0;
54
- let preview = '';
55
- try {
56
- size = fs.statSync(file).size;
57
- preview = fs.readFileSync(file, 'utf8').replace(/\s+/g, ' ').trim().slice(0, 140);
58
- } catch { /* a file can disappear between readdir and stat/read */ }
59
- return { name: entry.name, file, size, preview };
60
- })
61
- .sort((a, b) => a.name.localeCompare(b.name));
62
- }
63
-
64
- export function setActivePrompt(name) {
65
- const active = name == null || String(name).trim() === '' ? null : String(name).trim();
66
- if (active !== null) {
67
- const file = profileFile(active);
68
- if (!fs.statSync(file).isFile()) throw new Error(`Prompt profile is not a file: ${active}`);
69
- }
70
- updateSettingsFile(SETTINGS_FILE, (json) => {
71
- const current = json.prompts && typeof json.prompts === 'object' && !Array.isArray(json.prompts) ? { ...json.prompts } : {};
72
- if (active) current.active = active;
73
- else delete current.active;
74
- if (Object.keys(current).length) json.prompts = current;
75
- else delete json.prompts;
76
- });
77
- return active;
78
- }
79
-
80
- export function promptNameForText(text) {
81
- const firstLine = String(text).split(/\r?\n/, 1)[0].trim();
82
- let slug = firstLine
83
- .normalize('NFKC')
84
- .replace(/[^\p{L}\p{N}._-]+/gu, '-')
85
- .replace(/^-+|-+$/g, '')
86
- .slice(0, 48)
87
- .replace(/^-+|-+$/g, '');
88
- if (!slug || slug === '.' || slug === '..') slug = `prompt-${Date.now()}`;
89
- let name = `${slug}.txt`;
90
- let n = 2;
91
- while (fs.existsSync(profileFile(name))) name = `${slug}-${n++}.txt`;
92
- return name;
93
- }
94
-
95
- export function savePrompt(name, text, { activate = true } = {}) {
96
- const profile = String(name ?? '').trim();
97
- const content = String(text ?? '');
98
- if (!isPromptName(profile)) throw new Error('A prompt profile needs a file name.');
99
- if (!content.trim()) throw new Error('The system prompt cannot be empty.');
100
- const file = profileFile(profile);
101
- fs.mkdirSync(PROMPTS_DIR, { recursive: true });
102
- fs.writeFileSync(file, content);
103
- if (activate) setActivePrompt(profile);
104
- return { name: profile, file, text: content };
105
- }
106
-
107
- export function promptDirectory() {
108
- return PROMPTS_DIR;
109
- }