@yanzc/claude-pro 0.9.6 → 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 +12 -22
- package/package.json +1 -1
- package/src/commands.js +1 -132
- package/src/config.js +0 -2
- package/src/runtime.js +1 -5
- package/src/ui/repl.js +5 -5
- package/src/prompt-profiles.js +0 -109
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
|
|
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`
|
|
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`、`
|
|
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
|
-
-
|
|
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` `/
|
|
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
|
|
|
@@ -287,14 +277,14 @@ claude-pro -p "只调研,给出重构方案,不要改文件" # 只出方
|
|
|
287
277
|
| `Enter` | 发送 |
|
|
288
278
|
| `\` + `Enter` / `ctrl+j` / `alt+enter` | 换行 |
|
|
289
279
|
| `Esc` | 中断当前任务;连按两次:有文字时清空输入,输入框为空时打开回退菜单(同 `/rewind`) |
|
|
290
|
-
| `ctrl+c` |
|
|
291
|
-
| `ctrl+q` / `alt+q` |
|
|
280
|
+
| `ctrl+c` | 有选中文字时复制;否则中断 / 清空输入 / 连按两次退出 |
|
|
281
|
+
| `ctrl+q` / `alt+q` | 有选中文字时把它引用进输入框,在下一行写追问;模型会收到原文和它所在的工具调用或回复 |
|
|
292
282
|
| `ctrl+v` | 粘贴剪贴板文字(只有图片时附加图片) |
|
|
293
283
|
| `alt+v` | 附加剪贴板图片(没有图片时粘贴文字) |
|
|
294
284
|
| `ctrl+t` | 显示/隐藏 todo 列表 |
|
|
295
285
|
| `ctrl+l` | 清屏重绘 |
|
|
296
|
-
| `PgUp` / `PgDn`、滚轮、`Ctrl+Home` / `Ctrl+End` |
|
|
297
|
-
| `ctrl+f` |
|
|
286
|
+
| `PgUp` / `PgDn`、滚轮、`Ctrl+Home` / `Ctrl+End` | 滚动对话 / 到开头 / 回到最新 |
|
|
287
|
+
| `ctrl+f` | 在对话里查找(像 VS Code):输入框的位置换成查找框,边输入边高亮所有匹配(不分大小写,当前这个橙色、其余黄色),右上角显示"第几个/共几个"(`No results` 表示没有)。先跳到视图底部往上最近的一个;`Enter` 或 `↑` 跳到更早的一个,`Shift+Enter` 或 `↓` 跳到更新的一个,到头后绕回;`PgUp`/`PgDn`、滚轮照常滚动;`Esc` 关闭,画面停在当前位置(`Ctrl+End` 回到底部)。再按 `ctrl+f` 会带上上次的关键字(已选中,直接输入就替换);先用鼠标选中文字再按,会搜选中的文字。查找时有新输出,匹配会跟着更新。 |
|
|
298
288
|
| `↑` / `↓` | 在多行输入(包括自动折行的长文字)里上下移动光标;光标在第一行时 `↑` 先移到开头、再按才翻到上一条历史消息,`↓` 在最后一行同理 |
|
|
299
289
|
| `Tab` | 补全命令 / 文件 |
|
|
300
290
|
|
|
@@ -333,7 +323,7 @@ src/commands.js 斜杠命令
|
|
|
333
323
|
|
|
334
324
|
WebSearch 依赖网关:没有网关时只能抓取 DuckDuckGo/Bing 网页,而它们常把程序当爬虫拦下(DuckDuckGo 返回 202,Bing 只按查询的第一个词搜),结果可能离题。GitHub 相关的查询,系统提示词让模型优先用 Bash 跑 `gh`(需要已安装并登录)。检查点只覆盖文件工具的修改,不覆盖 Bash 命令造成的改动。
|
|
335
325
|
|
|
336
|
-
|
|
326
|
+
提示:鼠标选择不会自动写入剪贴板;使用 `Ctrl+C` 复制、`Ctrl+V` 粘贴,`Ctrl+Q` 引用到输入框里追问。按住 Shift 的终端原生选择行为由终端自身决定。
|
|
337
327
|
|
|
338
328
|
## 历史
|
|
339
329
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yanzc/claude-pro",
|
|
3
|
-
"version": "0.9.
|
|
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": {
|
package/src/commands.js
CHANGED
|
@@ -16,7 +16,6 @@ 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';
|
|
@@ -118,91 +117,6 @@ export function buildCommands(app) {
|
|
|
118
117
|
return choice === 'yes';
|
|
119
118
|
};
|
|
120
119
|
|
|
121
|
-
const unquotePromptArgument = (args) => {
|
|
122
|
-
const value = String(args ?? '').trim();
|
|
123
|
-
return /^(["'])[\s\S]*\1$/.test(value) ? value.slice(1, -1).trim() : value;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
// `/prompt` accepts either an existing file or literal text. Files are copied into the user's prompt directory so
|
|
127
|
-
// changing or deleting the source later does not change the prompt used by future sessions.
|
|
128
|
-
const readPromptArgument = (args) => {
|
|
129
|
-
const value = unquotePromptArgument(args);
|
|
130
|
-
if (!value) throw new Error('Usage: /prompt <file|text>');
|
|
131
|
-
const file = resolvePath(value, app.cwd);
|
|
132
|
-
let stat = null;
|
|
133
|
-
try { stat = fs.statSync(file); } catch (e) { if (e.code !== 'ENOENT') throw e; }
|
|
134
|
-
if (stat) {
|
|
135
|
-
if (!stat.isFile()) throw new Error(`Prompt source is not a file: ${file}`);
|
|
136
|
-
const text = fs.readFileSync(file, 'utf8');
|
|
137
|
-
if (!text.trim()) throw new Error(`Prompt source is empty: ${file}`);
|
|
138
|
-
return { name: path.basename(file), text, source: file };
|
|
139
|
-
}
|
|
140
|
-
return { name: promptNameForText(value), text: value, source: null };
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
const promptChanged = (name, text = undefined) => {
|
|
144
|
-
const currentName = activePromptName();
|
|
145
|
-
if (currentName !== name) return true;
|
|
146
|
-
if (text === undefined) return false;
|
|
147
|
-
return loadActivePrompt()?.text !== text;
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
const activatePrompt = async (name, { text, saved = null } = {}) => {
|
|
151
|
-
const changed = promptChanged(name, text);
|
|
152
|
-
if (!changed) {
|
|
153
|
-
out(`System prompt is already ${name ? c.bold(name) : c.bold('the built-in default')}.`);
|
|
154
|
-
return false;
|
|
155
|
-
}
|
|
156
|
-
if (!(await confirmCacheLoss('Changing the system prompt'))) {
|
|
157
|
-
out(c.dim('The system prompt was not changed.'));
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
const stored = saved ? savePrompt(saved.name, saved.text, { activate: true }) : null;
|
|
161
|
-
if (!saved) setActivePrompt(name);
|
|
162
|
-
// A prompt choice is persistent, but also takes effect for the next request in this session. The cache check
|
|
163
|
-
// above is the same safeguard used by /model and /effort when changing request-level cache inputs.
|
|
164
|
-
app.runtime.invalidateSystemPrompt();
|
|
165
|
-
const label = name ? c.bold(name) : c.bold('the built-in default');
|
|
166
|
-
const location = stored ? ` · copied to ${displayPath(stored.file, app.cwd)}` : '';
|
|
167
|
-
out(`System prompt set to ${label}${location} · kept for later sessions${promptDirectory() ? c.dim(` (${promptDirectory()})`) : ''}`);
|
|
168
|
-
return true;
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
const choosePrompt = async (args = '') => {
|
|
172
|
-
const wanted = unquotePromptArgument(args);
|
|
173
|
-
const profiles = listPromptProfiles();
|
|
174
|
-
const current = activePromptName();
|
|
175
|
-
if (wanted) {
|
|
176
|
-
if (/^(default|none|off)$/i.test(wanted)) return activatePrompt(null);
|
|
177
|
-
const found = profiles.find((p) => p.name === wanted) || profiles.find((p) => p.name.toLowerCase() === wanted.toLowerCase());
|
|
178
|
-
if (!found) {
|
|
179
|
-
out(c.red(`No saved prompt named "${wanted}". Use /prompts to choose one, or /prompt <file|text> to save it.`));
|
|
180
|
-
return false;
|
|
181
|
-
}
|
|
182
|
-
return activatePrompt(found.name);
|
|
183
|
-
}
|
|
184
|
-
if (!profiles.length) {
|
|
185
|
-
out(c.dim(`No saved prompts. Use /prompt <file|text> to create one (saved in ${promptDirectory()}).`));
|
|
186
|
-
return false;
|
|
187
|
-
}
|
|
188
|
-
const options = [
|
|
189
|
-
{ label: `Built-in default${current ? '' : c.dim(' (active)')}`, value: '__default__', description: 'Use claude-pro\'s normal system prompt' },
|
|
190
|
-
...profiles.map((p) => ({
|
|
191
|
-
label: `${p.name}${p.name === current ? c.dim(' (active)') : ''}`,
|
|
192
|
-
value: p.name,
|
|
193
|
-
description: p.preview || `${p.size} bytes`,
|
|
194
|
-
})),
|
|
195
|
-
];
|
|
196
|
-
const selected = await app.showDialog(new SelectDialog({
|
|
197
|
-
title: 'Select system prompt',
|
|
198
|
-
question: `Saved prompts in ${promptDirectory()}`,
|
|
199
|
-
options,
|
|
200
|
-
selected: Math.max(0, current ? options.findIndex((o) => o.value === current) : 0),
|
|
201
|
-
}));
|
|
202
|
-
if (selected === null || selected === undefined) return false;
|
|
203
|
-
return activatePrompt(selected === '__default__' ? null : selected);
|
|
204
|
-
};
|
|
205
|
-
|
|
206
120
|
add({
|
|
207
121
|
name: 'help',
|
|
208
122
|
description: 'Show help and available commands',
|
|
@@ -359,27 +273,6 @@ export function buildCommands(app) {
|
|
|
359
273
|
},
|
|
360
274
|
});
|
|
361
275
|
|
|
362
|
-
add({
|
|
363
|
-
name: 'prompt',
|
|
364
|
-
aliases: ['promt'],
|
|
365
|
-
argHint: '<file|text>',
|
|
366
|
-
argRequired: true,
|
|
367
|
-
description: 'Save and use a system prompt from a file or literal text (kept for later sessions)',
|
|
368
|
-
async run(args) {
|
|
369
|
-
if (!unquotePromptArgument(args)) return choosePrompt('');
|
|
370
|
-
const source = readPromptArgument(args);
|
|
371
|
-
return activatePrompt(source.name, { text: source.text, saved: source });
|
|
372
|
-
},
|
|
373
|
-
});
|
|
374
|
-
|
|
375
|
-
add({
|
|
376
|
-
name: 'prompts',
|
|
377
|
-
aliases: ['promits', 'promts'],
|
|
378
|
-
argHint: '[name|default]',
|
|
379
|
-
description: 'Choose a saved system prompt, or return to the built-in default',
|
|
380
|
-
run(args) { return choosePrompt(args); },
|
|
381
|
-
});
|
|
382
|
-
|
|
383
276
|
add({
|
|
384
277
|
name: 'model',
|
|
385
278
|
argHint: '[model]',
|
|
@@ -535,7 +428,6 @@ export function buildCommands(app) {
|
|
|
535
428
|
run() {
|
|
536
429
|
const cfg = app.runtime.config;
|
|
537
430
|
const mem = memoryFiles(app.cwd);
|
|
538
|
-
const savedPrompt = loadActivePrompt();
|
|
539
431
|
const mcp = app.runtime.mcp.status();
|
|
540
432
|
const row = (k, v) => `${c.dim(padEnd(k, 18))} ${v}`;
|
|
541
433
|
log([
|
|
@@ -548,9 +440,7 @@ export function buildCommands(app) {
|
|
|
548
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)')),
|
|
549
441
|
row('Model', `${cfg.model.label} ${c.dim(`(sent as "${cfg.model.id}", ${formatTokens(cfg.model.contextWindow)} context)`)}`),
|
|
550
442
|
row('Effort', cfg.effort || 'auto'),
|
|
551
|
-
row('System prompt', app.flags.systemPrompt !== undefined
|
|
552
|
-
? 'command line override'
|
|
553
|
-
: 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'),
|
|
554
444
|
row('Max output', formatTokens(cfg.maxOutputTokens)),
|
|
555
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') : ''}`),
|
|
556
446
|
row('Auto-compact', `at ${formatTokens(cfg.compactWindow())} tokens (the window, less room for the summary)`),
|
|
@@ -759,27 +649,6 @@ export function buildCommands(app) {
|
|
|
759
649
|
},
|
|
760
650
|
});
|
|
761
651
|
|
|
762
|
-
add({
|
|
763
|
-
name: 'tui',
|
|
764
|
-
argHint: '[fullscreen | default]',
|
|
765
|
-
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)',
|
|
766
|
-
run(args) {
|
|
767
|
-
const want = args.trim().toLowerCase();
|
|
768
|
-
if (!want) {
|
|
769
|
-
out(`The ${c.bold(app.screen.full ? 'fullscreen' : 'default')} renderer is active. /tui fullscreen or /tui default switches (and is remembered).`);
|
|
770
|
-
return;
|
|
771
|
-
}
|
|
772
|
-
if (want !== 'fullscreen' && want !== 'default') { out(c.red('Use /tui fullscreen or /tui default.')); return; }
|
|
773
|
-
const file = settingsFiles(app.cwd).user;
|
|
774
|
-
writeConfigSetting(file, 'tui', want);
|
|
775
|
-
reloadConfig();
|
|
776
|
-
app.screen.setFull(want === 'fullscreen');
|
|
777
|
-
out(want === 'fullscreen'
|
|
778
|
-
? `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})`
|
|
779
|
-
: `Default renderer: the conversation scrolls in the terminal. (Saved in ${file})`);
|
|
780
|
-
},
|
|
781
|
-
});
|
|
782
|
-
|
|
783
652
|
add({
|
|
784
653
|
name: 'rename',
|
|
785
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
|
-
:
|
|
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
|
@@ -1316,10 +1316,10 @@ export class App {
|
|
|
1316
1316
|
|
|
1317
1317
|
// ---------------------------------------------------------------- input
|
|
1318
1318
|
|
|
1319
|
-
//
|
|
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
|
-
|
|
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
|
|
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
|
|
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();
|
package/src/prompt-profiles.js
DELETED
|
@@ -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
|
-
}
|