@yanzc/claude-pro 0.5.9 → 0.7.0
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 +375 -357
- package/package.json +1 -1
- package/src/agents.js +3 -1
- package/src/attach.js +132 -0
- package/src/background.js +424 -0
- package/src/commands.js +119 -80
- package/src/config.js +16 -7
- package/src/connect.js +79 -0
- package/src/history.js +94 -0
- package/src/host.js +1410 -0
- package/src/main.js +54 -10
- package/src/peers.js +290 -215
- package/src/prompts.js +74 -58
- package/src/qr.js +1 -1
- package/src/remote.js +54 -17
- package/src/runtime.js +14 -8
- package/src/session.js +29 -2
- package/src/supervisor.js +6 -3
- package/src/tools/bash.js +5 -10
- package/src/tools/files.js +6 -10
- package/src/tools/index.js +1 -1
- package/src/tools/interaction.js +8 -37
- package/src/tools/search.js +15 -10
- package/src/tools/task.js +29 -7
- package/src/ui/dialogs.js +48 -0
- package/src/ui/render.js +10 -0
- package/src/ui/repl.js +393 -79
- package/src/ui/vterm.js +62 -0
package/src/main.js
CHANGED
|
@@ -22,21 +22,34 @@ Options:
|
|
|
22
22
|
--system-prompt <text> Replace the system prompt
|
|
23
23
|
--verbose Show thinking and full tool output
|
|
24
24
|
--no-mcp Do not start MCP servers
|
|
25
|
-
--
|
|
25
|
+
--name <name> Name this session, as /rename does (other sessions reach it with &name)
|
|
26
|
+
--remote-id <id> Go online at the gateway at once with this id (the gateway's web page opens
|
|
27
|
+
sessions this way, through claude-pro host)
|
|
28
|
+
--headless A background session: no window, used from the web page (with --remote-id)
|
|
29
|
+
and from claude-pro attach; what it prints goes to stdout as a log
|
|
26
30
|
-v, --version Print version
|
|
27
31
|
-h, --help Show help
|
|
28
32
|
|
|
29
33
|
There are no permission prompts: every tool runs immediately (full access). File edits are
|
|
30
34
|
checkpointed per prompt, and /rewind in a session undoes them. The old flags
|
|
31
35
|
--dangerously-skip-permissions, --permission-mode, --allowedTools and --disallowedTools
|
|
32
|
-
are accepted and ignored (--permission-mode plan is the same as --plan)
|
|
36
|
+
are accepted and ignored (--permission-mode plan is the same as --plan), and so is
|
|
37
|
+
--remote-control (--rc): a session is online at the gateway whenever this computer is logged in to it.
|
|
33
38
|
|
|
34
39
|
Commands:
|
|
35
40
|
claude-pro config list Show effective configuration and where each value comes from
|
|
36
41
|
claude-pro config set <KEY> <VALUE> [--project|--local] Save a setting (default: ~/.claude-pro/settings.json)
|
|
37
42
|
claude-pro config unset <KEY> [--project|--local]
|
|
43
|
+
claude-pro host [start|stop|status|install|uninstall] The computer service: lets the gateway's web page
|
|
44
|
+
open sessions on this computer (claude-pro host --help)
|
|
45
|
+
claude-pro connect <code> [--url U] Join this computer to your gateway account with the web page's pairing
|
|
46
|
+
code; the computer service then starts, and starts at logon
|
|
47
|
+
claude-pro attach [name] Use a background session of this computer here, in this terminal
|
|
48
|
+
(ctrl+] detaches; it goes on in the background)
|
|
38
49
|
`;
|
|
39
50
|
|
|
51
|
+
const REMOTE_ID = /^[A-Za-z0-9_-]{8,64}$/;
|
|
52
|
+
|
|
40
53
|
function parseArgs(argv) {
|
|
41
54
|
const flags = {};
|
|
42
55
|
const positional = [];
|
|
@@ -68,7 +81,15 @@ function parseArgs(argv) {
|
|
|
68
81
|
case '--system-prompt': flags.systemPrompt = next(); break;
|
|
69
82
|
case '--verbose': flags.verbose = true; break;
|
|
70
83
|
case '--no-mcp': flags.noMcp = true; break;
|
|
71
|
-
case '--remote-control': case '--rc':
|
|
84
|
+
case '--remote-control': case '--rc': break; // online by default now
|
|
85
|
+
case '--headless': flags.headless = true; break;
|
|
86
|
+
case '--name': flags.name = next(); break;
|
|
87
|
+
case '--remote-id': {
|
|
88
|
+
const id = next();
|
|
89
|
+
if (!REMOTE_ID.test(id || '')) { process.stderr.write(`--remote-id takes 8 to 64 letters, digits, _ or -, not "${id ?? ''}"\n`); process.exit(2); }
|
|
90
|
+
flags.remoteId = id;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
72
93
|
case '-v': case '--version': flags.version = true; break;
|
|
73
94
|
case '-h': case '--help': flags.help = true; break;
|
|
74
95
|
default:
|
|
@@ -101,7 +122,7 @@ function configCommand(args, cwd) {
|
|
|
101
122
|
const what = Object.entries(remembered).map(([k, v]) => `${k} ${v}`).join(', ');
|
|
102
123
|
console.log(`chosen with /model, /effort: ${what} (kept in ${files.user}; wins over the settings above, --model/--effort win over it)`);
|
|
103
124
|
}
|
|
104
|
-
console.log(`sub-agent model: ${cfg.subagentModel.label}; small model: ${cfg.smallModel.label}`);
|
|
125
|
+
console.log(`sub-agent model: ${cfg.subagentModelChosen ? `chosen per task (not chosen: ${cfg.subagentModel.label})` : cfg.subagentModel.label}; small model: ${cfg.smallModel.label}`);
|
|
105
126
|
console.log(`auto-compact at ${cfg.autoCompactThreshold().toLocaleString()} tokens (window ${cfg.compactWindow().toLocaleString()})`);
|
|
106
127
|
}
|
|
107
128
|
return 0;
|
|
@@ -145,8 +166,11 @@ function readStdin({ optional }) {
|
|
|
145
166
|
}
|
|
146
167
|
|
|
147
168
|
export async function main(argv) {
|
|
148
|
-
|
|
169
|
+
let cwd = process.cwd();
|
|
149
170
|
if (argv[0] === 'config') return configCommand(argv.slice(1), cwd);
|
|
171
|
+
if (argv[0] === 'host') return (await import('./host.js')).hostCommand(argv.slice(1));
|
|
172
|
+
if (argv[0] === 'attach') return (await import('./attach.js')).attachCommand(argv.slice(1));
|
|
173
|
+
if (argv[0] === 'connect') return (await import('./connect.js')).connectCommand(argv.slice(1));
|
|
150
174
|
if (argv[0] === '--self-check') return (await import('./selfcheck.js')).selfCheck(); // see restart.js
|
|
151
175
|
const { flags, positional } = parseArgs(argv);
|
|
152
176
|
if (flags.version) { console.log(`${VERSION} (claude-pro)`); return 0; }
|
|
@@ -155,8 +179,9 @@ export async function main(argv) {
|
|
|
155
179
|
let prompt = positional.join(' ');
|
|
156
180
|
|
|
157
181
|
// Started by a restart of a running session: that session is picked up again, whatever the command line
|
|
158
|
-
// that started the first one said (-c, --resume, a first prompt).
|
|
159
|
-
|
|
182
|
+
// that started the first one said (-c, --resume, a first prompt). A background session (--headless) has no
|
|
183
|
+
// terminal and is interactive all the same.
|
|
184
|
+
const interactive = flags.headless || !(flags.print || !process.stdout.isTTY || !process.stdin.isTTY);
|
|
160
185
|
const restart = interactive ? takeRestartState() : null;
|
|
161
186
|
if (restart) {
|
|
162
187
|
flags.restart = restart;
|
|
@@ -164,19 +189,38 @@ export async function main(argv) {
|
|
|
164
189
|
flags.resume = false;
|
|
165
190
|
flags.resumeId = undefined;
|
|
166
191
|
prompt = '';
|
|
192
|
+
// the session's working directory, which /cd may have changed (the supervisor starts every process where the
|
|
193
|
+
// first one started)
|
|
194
|
+
if (typeof restart.cwd === 'string' && restart.cwd !== cwd) {
|
|
195
|
+
try {
|
|
196
|
+
if (fs.statSync(restart.cwd).isDirectory()) { process.chdir(restart.cwd); cwd = process.cwd(); }
|
|
197
|
+
} catch { /* gone meanwhile: where the first one started */ }
|
|
198
|
+
}
|
|
167
199
|
}
|
|
168
200
|
|
|
169
201
|
if (flags.continue || (flags.resume && flags.resumeId)) {
|
|
170
202
|
const sessions = SessionStore.list(cwd);
|
|
171
203
|
const found = flags.resumeId ? sessions.find((s) => s.id.startsWith(flags.resumeId)) : sessions[0];
|
|
172
|
-
if (!found) {
|
|
204
|
+
if (!found && flags.headless) {
|
|
205
|
+
// a background session opened again (after a crash, a reboot) that never had a conversation: a new one
|
|
206
|
+
process.stdout.write(`No conversation ${flags.resumeId || ''} here: starting a new one.\n`);
|
|
207
|
+
flags.continue = false;
|
|
208
|
+
flags.resume = false;
|
|
209
|
+
flags.resumeId = undefined;
|
|
210
|
+
} else if (!found) {
|
|
173
211
|
process.stderr.write(flags.resumeId ? `No conversation found with id ${flags.resumeId}\n` : 'No conversation found to continue\n');
|
|
174
212
|
return 1;
|
|
213
|
+
} else {
|
|
214
|
+
flags.resumeFile = found.file;
|
|
215
|
+
flags.resumeId = found.id;
|
|
175
216
|
}
|
|
176
|
-
flags.resumeFile = found.file;
|
|
177
|
-
flags.resumeId = found.id;
|
|
178
217
|
}
|
|
179
218
|
|
|
219
|
+
if (flags.headless) {
|
|
220
|
+
if (!fs.existsSync(cwd)) return 1;
|
|
221
|
+
const { runRepl } = await import('./ui/repl.js');
|
|
222
|
+
return await runRepl({ flags, cwd, initialPrompt: prompt });
|
|
223
|
+
}
|
|
180
224
|
// mintty (Git Bash's default window) connects programs through pipes, not a console.
|
|
181
225
|
if (!flags.print && !process.stdin.isTTY && process.env.TERM_PROGRAM === 'mintty') {
|
|
182
226
|
process.stderr.write('Interactive mode needs a real console. In mintty/Git Bash run `winpty claude-pro` (or `winpty node bin/claude-pro.js`), or use Windows Terminal. For scripts use `claude-pro -p`.\n');
|