@yanzc/claude-pro 0.7.4 → 0.7.5
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 +15 -13
- package/src/ui/screen.js +32 -1
- package/src/verify.js +57 -0
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
|
+
}
|