@yanzc/claude-pro 0.6.0 → 0.7.1
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 +372 -370
- package/package.json +1 -1
- package/src/agent.js +18 -13
- package/src/attach.js +132 -0
- package/src/background.js +424 -0
- package/src/commands.js +80 -59
- package/src/connect.js +79 -0
- package/src/history.js +94 -0
- package/src/host.js +445 -66
- package/src/main.js +38 -10
- package/src/peers.js +290 -215
- package/src/print.js +0 -1
- package/src/prompts.js +2 -7
- package/src/remote.js +50 -15
- package/src/runtime.js +2 -6
- package/src/session.js +24 -0
- package/src/supervisor.js +6 -3
- package/src/tools/bash.js +2 -2
- package/src/tools/index.js +2 -3
- package/src/tools/interaction.js +2 -30
- package/src/tools/task.js +1 -1
- package/src/ui/ansi.js +0 -1
- package/src/ui/dialogs.js +48 -0
- package/src/ui/render.js +10 -4
- package/src/ui/repl.js +318 -77
- package/src/ui/vterm.js +62 -0
- package/src/modes.js +0 -154
- package/src/qr.js +0 -206
package/src/main.js
CHANGED
|
@@ -15,7 +15,6 @@ Options:
|
|
|
15
15
|
--provider <backend> api (default) | claude-code (direct HTTP with existing local login)
|
|
16
16
|
--model <model> Model for this session (name or alias: opus, sonnet, haiku)
|
|
17
17
|
--effort <level> Reasoning effort: none|minimal|low|medium|high|xhigh|max
|
|
18
|
-
--plan Start in read-only plan mode (research first, then ExitPlanMode)
|
|
19
18
|
--output-format <format> text | json | stream-json (with --print)
|
|
20
19
|
--verify <command> After the agent edits files, run this (e.g. "npm test") and send failures back to fix
|
|
21
20
|
--append-system-prompt <text> Append text to the system prompt
|
|
@@ -25,13 +24,15 @@ Options:
|
|
|
25
24
|
--name <name> Name this session, as /rename does (other sessions reach it with &name)
|
|
26
25
|
--remote-id <id> Go online at the gateway at once with this id (the gateway's web page opens
|
|
27
26
|
sessions this way, through claude-pro host)
|
|
27
|
+
--headless A background session: no window, used from the web page (with --remote-id)
|
|
28
|
+
and from claude-pro attach; what it prints goes to stdout as a log
|
|
28
29
|
-v, --version Print version
|
|
29
30
|
-h, --help Show help
|
|
30
31
|
|
|
31
32
|
There are no permission prompts: every tool runs immediately (full access). File edits are
|
|
32
33
|
checkpointed per prompt, and /rewind in a session undoes them. The old flags
|
|
33
34
|
--dangerously-skip-permissions, --permission-mode, --allowedTools and --disallowedTools
|
|
34
|
-
are accepted and ignored
|
|
35
|
+
are accepted and ignored, and so are --plan (there is no plan mode: ask for a plan in the message) and
|
|
35
36
|
--remote-control (--rc): a session is online at the gateway whenever this computer is logged in to it.
|
|
36
37
|
|
|
37
38
|
Commands:
|
|
@@ -40,6 +41,10 @@ Commands:
|
|
|
40
41
|
claude-pro config unset <KEY> [--project|--local]
|
|
41
42
|
claude-pro host [start|stop|status|install|uninstall] The computer service: lets the gateway's web page
|
|
42
43
|
open sessions on this computer (claude-pro host --help)
|
|
44
|
+
claude-pro connect <code> [--url U] Join this computer to your gateway account with the web page's pairing
|
|
45
|
+
code; the computer service then starts, and starts at logon
|
|
46
|
+
claude-pro attach [name] Use a background session of this computer here, in this terminal
|
|
47
|
+
(ctrl+] detaches; it goes on in the background)
|
|
43
48
|
`;
|
|
44
49
|
|
|
45
50
|
const REMOTE_ID = /^[A-Za-z0-9_-]{8,64}$/;
|
|
@@ -65,8 +70,8 @@ function parseArgs(argv) {
|
|
|
65
70
|
case '--model': flags.model = next(); break;
|
|
66
71
|
case '--provider': flags.provider = next(); break;
|
|
67
72
|
case '--effort': flags.effort = next(); break;
|
|
68
|
-
case '--plan':
|
|
69
|
-
case '--permission-mode':
|
|
73
|
+
case '--plan': break; // no plan mode any more: asking for a plan in the message does it
|
|
74
|
+
case '--permission-mode': next(); break;
|
|
70
75
|
case '--dangerously-skip-permissions': break; // nothing to skip: there are no prompts
|
|
71
76
|
case '--allowedTools': case '--allowed-tools': case '--disallowedTools': case '--disallowed-tools': skipRules(); break;
|
|
72
77
|
case '--output-format': flags.outputFormat = next(); break;
|
|
@@ -76,6 +81,7 @@ function parseArgs(argv) {
|
|
|
76
81
|
case '--verbose': flags.verbose = true; break;
|
|
77
82
|
case '--no-mcp': flags.noMcp = true; break;
|
|
78
83
|
case '--remote-control': case '--rc': break; // online by default now
|
|
84
|
+
case '--headless': flags.headless = true; break;
|
|
79
85
|
case '--name': flags.name = next(); break;
|
|
80
86
|
case '--remote-id': {
|
|
81
87
|
const id = next();
|
|
@@ -159,9 +165,11 @@ function readStdin({ optional }) {
|
|
|
159
165
|
}
|
|
160
166
|
|
|
161
167
|
export async function main(argv) {
|
|
162
|
-
|
|
168
|
+
let cwd = process.cwd();
|
|
163
169
|
if (argv[0] === 'config') return configCommand(argv.slice(1), cwd);
|
|
164
170
|
if (argv[0] === 'host') return (await import('./host.js')).hostCommand(argv.slice(1));
|
|
171
|
+
if (argv[0] === 'attach') return (await import('./attach.js')).attachCommand(argv.slice(1));
|
|
172
|
+
if (argv[0] === 'connect') return (await import('./connect.js')).connectCommand(argv.slice(1));
|
|
165
173
|
if (argv[0] === '--self-check') return (await import('./selfcheck.js')).selfCheck(); // see restart.js
|
|
166
174
|
const { flags, positional } = parseArgs(argv);
|
|
167
175
|
if (flags.version) { console.log(`${VERSION} (claude-pro)`); return 0; }
|
|
@@ -170,8 +178,9 @@ export async function main(argv) {
|
|
|
170
178
|
let prompt = positional.join(' ');
|
|
171
179
|
|
|
172
180
|
// Started by a restart of a running session: that session is picked up again, whatever the command line
|
|
173
|
-
// that started the first one said (-c, --resume, a first prompt).
|
|
174
|
-
|
|
181
|
+
// that started the first one said (-c, --resume, a first prompt). A background session (--headless) has no
|
|
182
|
+
// terminal and is interactive all the same.
|
|
183
|
+
const interactive = flags.headless || !(flags.print || !process.stdout.isTTY || !process.stdin.isTTY);
|
|
175
184
|
const restart = interactive ? takeRestartState() : null;
|
|
176
185
|
if (restart) {
|
|
177
186
|
flags.restart = restart;
|
|
@@ -179,19 +188,38 @@ export async function main(argv) {
|
|
|
179
188
|
flags.resume = false;
|
|
180
189
|
flags.resumeId = undefined;
|
|
181
190
|
prompt = '';
|
|
191
|
+
// the session's working directory, which /cd may have changed (the supervisor starts every process where the
|
|
192
|
+
// first one started)
|
|
193
|
+
if (typeof restart.cwd === 'string' && restart.cwd !== cwd) {
|
|
194
|
+
try {
|
|
195
|
+
if (fs.statSync(restart.cwd).isDirectory()) { process.chdir(restart.cwd); cwd = process.cwd(); }
|
|
196
|
+
} catch { /* gone meanwhile: where the first one started */ }
|
|
197
|
+
}
|
|
182
198
|
}
|
|
183
199
|
|
|
184
200
|
if (flags.continue || (flags.resume && flags.resumeId)) {
|
|
185
201
|
const sessions = SessionStore.list(cwd);
|
|
186
202
|
const found = flags.resumeId ? sessions.find((s) => s.id.startsWith(flags.resumeId)) : sessions[0];
|
|
187
|
-
if (!found) {
|
|
203
|
+
if (!found && flags.headless) {
|
|
204
|
+
// a background session opened again (after a crash, a reboot) that never had a conversation: a new one
|
|
205
|
+
process.stdout.write(`No conversation ${flags.resumeId || ''} here: starting a new one.\n`);
|
|
206
|
+
flags.continue = false;
|
|
207
|
+
flags.resume = false;
|
|
208
|
+
flags.resumeId = undefined;
|
|
209
|
+
} else if (!found) {
|
|
188
210
|
process.stderr.write(flags.resumeId ? `No conversation found with id ${flags.resumeId}\n` : 'No conversation found to continue\n');
|
|
189
211
|
return 1;
|
|
212
|
+
} else {
|
|
213
|
+
flags.resumeFile = found.file;
|
|
214
|
+
flags.resumeId = found.id;
|
|
190
215
|
}
|
|
191
|
-
flags.resumeFile = found.file;
|
|
192
|
-
flags.resumeId = found.id;
|
|
193
216
|
}
|
|
194
217
|
|
|
218
|
+
if (flags.headless) {
|
|
219
|
+
if (!fs.existsSync(cwd)) return 1;
|
|
220
|
+
const { runRepl } = await import('./ui/repl.js');
|
|
221
|
+
return await runRepl({ flags, cwd, initialPrompt: prompt });
|
|
222
|
+
}
|
|
195
223
|
// mintty (Git Bash's default window) connects programs through pipes, not a console.
|
|
196
224
|
if (!flags.print && !process.stdin.isTTY && process.env.TERM_PROGRAM === 'mintty') {
|
|
197
225
|
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');
|