@yanzc/claude-pro 0.7.4 → 0.7.6
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 +26 -2
- package/package.json +1 -1
- package/src/agent.js +211 -81
- package/src/agents.js +0 -1
- package/src/commands.js +165 -22
- package/src/config.js +27 -12
- package/src/context.js +3 -1
- package/src/host.js +8 -1
- package/src/main.js +6 -2
- package/src/print.js +2 -1
- package/src/prompt-profiles.js +115 -0
- package/src/prompts.js +1 -1
- package/src/runtime.js +16 -9
- package/src/tools/effort.js +1 -1
- package/src/tools/index.js +1 -1
- package/src/tools/task.js +6 -28
- package/src/tools/web.js +4 -4
- package/src/trace.js +477 -0
- package/src/ui/repl.js +31 -21
- package/src/ui/screen.js +32 -1
- package/src/updater.js +4 -7
- package/src/verify.js +57 -0
package/src/ui/screen.js
CHANGED
|
@@ -154,6 +154,7 @@ export class Screen {
|
|
|
154
154
|
this.wrapped = []; // fullscreen: history[i] wrapped to wrapCols - 1, made when first needed
|
|
155
155
|
this.wrapCols = 0;
|
|
156
156
|
this.lastArea = 0; // fullscreen: rows the conversation had on screen at the last draw
|
|
157
|
+
this.scrollLiveRows = null; // fullscreen: keep the live region's height fixed while the user is scrolled up
|
|
157
158
|
this.viewMap = []; // fullscreen: what each row of the conversation area shows, {line, sub} (null: blank)
|
|
158
159
|
this.barRow = null; // fullscreen: the row of the "Jump to bottom" bar, when it is shown
|
|
159
160
|
this.finding = null; // fullscreen: a search in the conversation (ctrl+f), see openFind
|
|
@@ -572,13 +573,43 @@ export class Screen {
|
|
|
572
573
|
return ' '.repeat(pad) + '\x1b[7m' + label + '\x1b[27m';
|
|
573
574
|
}
|
|
574
575
|
|
|
576
|
+
// While the user is scrolled up, keep the live region at the height it had when scrolling started. Streaming
|
|
577
|
+
// text otherwise grows and shrinks that region, moving every visible conversation row on every token. That is
|
|
578
|
+
// especially conspicuous through PowerShell/ConPTY, where the cursor moves in the terminal before the whole
|
|
579
|
+
// frame has been painted. The new output remains available behind the jump bar; returning to the bottom releases
|
|
580
|
+
// the lock and lays out the complete live region again.
|
|
581
|
+
keepScrolledLiveHeight(layout, rows) {
|
|
582
|
+
const current = layout.rows.length;
|
|
583
|
+
if (current < rows) {
|
|
584
|
+
const gap = rows - current;
|
|
585
|
+
layout.rows.unshift(...Array(gap).fill(''));
|
|
586
|
+
if (layout.cursorRow !== null) layout.cursorRow += gap;
|
|
587
|
+
return layout;
|
|
588
|
+
}
|
|
589
|
+
if (current > rows) {
|
|
590
|
+
const dropped = current - rows;
|
|
591
|
+
layout.rows.splice(0, dropped);
|
|
592
|
+
if (layout.cursorRow !== null) {
|
|
593
|
+
layout.cursorRow -= dropped;
|
|
594
|
+
if (layout.cursorRow < 0) layout.cursorRow = null;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
return layout;
|
|
598
|
+
}
|
|
599
|
+
|
|
575
600
|
// Draw the screen: the conversation above, the live region on the last rows, the cursor in the input box.
|
|
576
601
|
draw({ full = false } = {}) {
|
|
577
602
|
if (this.closed || !this.full) return;
|
|
578
603
|
if (this.scheduled) { clearTimeout(this.scheduled); this.scheduled = null; }
|
|
579
604
|
const cols = this.width;
|
|
580
605
|
const screenRows = Math.max(1, this.out.rows || this.height);
|
|
581
|
-
|
|
606
|
+
if (!this.scroll) this.scrollLiveRows = null;
|
|
607
|
+
else if (full) this.scrollLiveRows = null; // a resize changes wrapping; capture the new live layout below
|
|
608
|
+
let layout = this.layoutLive(cols);
|
|
609
|
+
if (this.scroll > 0) {
|
|
610
|
+
if (this.scrollLiveRows === null) this.scrollLiveRows = Math.max(1, layout.rows.length);
|
|
611
|
+
layout = this.keepScrolledLiveHeight(layout, this.scrollLiveRows);
|
|
612
|
+
}
|
|
582
613
|
const area = Math.max(0, screenRows - layout.rows.length);
|
|
583
614
|
this.lastArea = area;
|
|
584
615
|
if (this.finding) this.refreshFind();
|
package/src/updater.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// the
|
|
4
|
-
//
|
|
5
|
-
// then loads it with a restart (the conversation carries over); the others see the files change and restart too,
|
|
6
|
-
// each once it is idle (App.startSourceWatch). A git checkout (the development copy) is never touched. Off with
|
|
7
|
-
// CLAUDE_PRO_AUTO_UPDATE=0 or DISABLE_AUTOUPDATER=1.
|
|
1
|
+
// Manual update support for `npm i -g claude-pro`: the interactive session checks npm and installs a release only
|
|
2
|
+
// when `/update` calls App.autoUpdate({ force: true }). Installation is serialized by a lock file and the session
|
|
3
|
+
// loads the new package with a restart (the conversation carries over). A git checkout (the development copy) is
|
|
4
|
+
// never touched. The environment switches remain for callers that want to disable even manual checks.
|
|
8
5
|
|
|
9
6
|
import fs from 'node:fs';
|
|
10
7
|
import path from 'node:path';
|
package/src/verify.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Discover a conservative project verification command when the user has not configured one.
|
|
2
|
+
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
|
|
6
|
+
function exists(cwd, name) {
|
|
7
|
+
try { return fs.statSync(path.join(cwd, name)).isFile(); } catch { return false; }
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function directoryExists(cwd, name) {
|
|
11
|
+
try { return fs.statSync(path.join(cwd, name)).isDirectory(); } catch { return false; }
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function readJson(file) {
|
|
15
|
+
try { return JSON.parse(fs.readFileSync(file, 'utf8')); } catch { return null; }
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function packageRunner(cwd) {
|
|
19
|
+
if (exists(cwd, 'pnpm-lock.yaml')) return 'pnpm';
|
|
20
|
+
if (exists(cwd, 'yarn.lock')) return 'yarn';
|
|
21
|
+
return 'npm';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function meaningfulTestScript(script) {
|
|
25
|
+
if (typeof script !== 'string' || !script.trim()) return false;
|
|
26
|
+
// Skip npm init's placeholder because it intentionally exits with an error.
|
|
27
|
+
return !/(?:error:\s*)?no test specified/i.test(script);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function packageCommand(cwd) {
|
|
31
|
+
const pkg = readJson(path.join(cwd, 'package.json'));
|
|
32
|
+
const scripts = pkg?.scripts;
|
|
33
|
+
if (!scripts || typeof scripts !== 'object') return null;
|
|
34
|
+
const runner = packageRunner(cwd);
|
|
35
|
+
if (meaningfulTestScript(scripts.test)) return runner === 'npm' ? 'npm test' : `${runner} test`;
|
|
36
|
+
for (const name of ['check', 'verify', 'lint']) {
|
|
37
|
+
if (typeof scripts[name] === 'string' && scripts[name].trim()) return `${runner} run ${name}`;
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function makefileCommand(cwd) {
|
|
43
|
+
if (!exists(cwd, 'Makefile')) return null;
|
|
44
|
+
try {
|
|
45
|
+
const text = fs.readFileSync(path.join(cwd, 'Makefile'), 'utf8');
|
|
46
|
+
return /^(?:\.PHONY\s+)?test\s*(?::|;)/m.test(text) ? 'make test' : null;
|
|
47
|
+
} catch { return null; }
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function discoverVerifyCommand(cwd) {
|
|
51
|
+
const root = path.resolve(cwd || process.cwd());
|
|
52
|
+
return packageCommand(root)
|
|
53
|
+
|| (exists(root, 'pyproject.toml') && (directoryExists(root, 'tests') || directoryExists(root, 'test')) ? 'python -m pytest -q' : null)
|
|
54
|
+
|| (exists(root, 'Cargo.toml') ? 'cargo test' : null)
|
|
55
|
+
|| (exists(root, 'go.mod') ? 'go test ./...' : null)
|
|
56
|
+
|| makefileCommand(root);
|
|
57
|
+
}
|