@caveman-ai/cli 2.0.0 → 2.1.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 +15 -0
- package/dist/agent-skills.generated.js +27 -3
- package/dist/agents.generated.js +37 -27
- package/dist/binaries.generated.js +1 -1
- package/dist/caveman-pi-extension.mjs +120 -35
- package/dist/index.js +807 -129
- package/dist/portable-command.js +36 -15
- package/dist/provider-routing.js +11 -0
- package/package.json +3 -3
package/dist/portable-command.js
CHANGED
|
@@ -7,13 +7,47 @@ export function parseWindowsNodeShim(source) {
|
|
|
7
7
|
// Shim-relative target (npm cmd-shim, pnpm/yarn-classic @zkochan forms), or
|
|
8
8
|
// a drive-absolute target (pnpm emits one when the global bin dir and the
|
|
9
9
|
// store sit on different drives — path.relative crosses drives as absolute).
|
|
10
|
-
|
|
10
|
+
// %~dp0 already ends with a separator; managed Pi adds none before its target.
|
|
11
|
+
const match = line.match(/"%(?:dp0%|~dp0)\\?([^"\r\n]+\.(?:cjs|mjs|js))"\s+%\*/i)
|
|
11
12
|
?? line.match(/"([A-Za-z]:[\\/][^"\r\n]+\.(?:cjs|mjs|js))"\s+%\*/i);
|
|
12
13
|
if (match)
|
|
13
14
|
return match[1];
|
|
14
15
|
}
|
|
15
16
|
return null;
|
|
16
17
|
}
|
|
18
|
+
// Accept only a single shim-relative forwarding command, optionally preceded by
|
|
19
|
+
// @echo off. Never evaluate batch syntax or interpolate caller-controlled argv.
|
|
20
|
+
function parseWindowsNestedShim(source) {
|
|
21
|
+
const match = source.match(/^(?:@echo[ \t]+off[ \t]*\r?\n)?[ \t]*"%~dp0\\?([\w .@+\-\\/]+\.(?:cmd|bat))"[ \t]+%\*[ \t]*(?:\r?\n)?$/i);
|
|
22
|
+
return match?.[1] ?? null;
|
|
23
|
+
}
|
|
24
|
+
function resolveWindowsNodeShim(executable, depth = 0, seen = new Set()) {
|
|
25
|
+
if (depth > 4)
|
|
26
|
+
throw new Error("Windows command shim nesting too deep");
|
|
27
|
+
const normalized = resolve(executable);
|
|
28
|
+
if (seen.has(normalized.toLowerCase()))
|
|
29
|
+
throw new Error("Windows command shim cycle");
|
|
30
|
+
seen.add(normalized.toLowerCase());
|
|
31
|
+
const stat = statSync(normalized);
|
|
32
|
+
if (!stat.isFile() || stat.size > 256 * 1024) {
|
|
33
|
+
throw new Error(`cannot safely launch Windows command shim: ${normalized}`);
|
|
34
|
+
}
|
|
35
|
+
const source = readFileSync(normalized, "utf8");
|
|
36
|
+
// Batch forwarding must match the whole wrapper, not a later Node command.
|
|
37
|
+
const nested = parseWindowsNestedShim(source);
|
|
38
|
+
const forwardsToBatch = /"[^"\r\n]+\.(?:cmd|bat)"[ \t]+%\*/i.test(source);
|
|
39
|
+
const jsTarget = forwardsToBatch ? null : parseWindowsNodeShim(source);
|
|
40
|
+
const child = jsTarget ?? nested;
|
|
41
|
+
if (!child) {
|
|
42
|
+
throw new Error(`cannot safely launch non-Node Windows command shim: ${normalized}; install a native .exe`);
|
|
43
|
+
}
|
|
44
|
+
const target = /^[A-Za-z]:[\\/]/.test(child)
|
|
45
|
+
? child
|
|
46
|
+
: resolve(dirname(normalized), ...child.split(/[\\/]+/));
|
|
47
|
+
if (!existsSync(target) || !statSync(target).isFile())
|
|
48
|
+
throw new Error(`Windows command shim target is missing: ${target}`);
|
|
49
|
+
return jsTarget ? target : resolveWindowsNodeShim(target, depth + 1, seen);
|
|
50
|
+
}
|
|
17
51
|
function envValue(env, name) {
|
|
18
52
|
const key = Object.keys(env).find((candidate) => candidate.toLowerCase() === name.toLowerCase());
|
|
19
53
|
return key === undefined ? undefined : env[key];
|
|
@@ -56,19 +90,6 @@ export function portableInvocation(command, args, platform = process.platform, e
|
|
|
56
90
|
const executable = resolveWindowsCommand(command, env) ?? command;
|
|
57
91
|
if (!/\.(?:cmd|bat)$/i.test(executable))
|
|
58
92
|
return { command: executable, args: [...args] };
|
|
59
|
-
const
|
|
60
|
-
if (!stat.isFile() || stat.size > 256 * 1024) {
|
|
61
|
-
throw new Error(`cannot safely launch Windows command shim: ${executable}`);
|
|
62
|
-
}
|
|
63
|
-
const shimScript = parseWindowsNodeShim(readFileSync(executable, "utf8"));
|
|
64
|
-
if (!shimScript) {
|
|
65
|
-
throw new Error(`cannot safely launch non-Node Windows command shim: ${executable}; install a native .exe`);
|
|
66
|
-
}
|
|
67
|
-
const script = /^[A-Za-z]:[\\/]/.test(shimScript)
|
|
68
|
-
? shimScript
|
|
69
|
-
: resolve(dirname(executable), ...shimScript.split(/[\\/]+/));
|
|
70
|
-
if (!statSync(script).isFile()) {
|
|
71
|
-
throw new Error(`Windows command shim target is missing: ${script}`);
|
|
72
|
-
}
|
|
93
|
+
const script = resolveWindowsNodeShim(executable);
|
|
73
94
|
return { command: process.execPath, args: [script, ...args] };
|
|
74
95
|
}
|
package/dist/provider-routing.js
CHANGED
|
@@ -52,6 +52,17 @@ function compatTarget(base, path) {
|
|
|
52
52
|
overlap--;
|
|
53
53
|
return base.origin + '/' + [...left, ...right.slice(overlap)].join('/');
|
|
54
54
|
}
|
|
55
|
+
export function verifiedChatGPTSubscriptionRoute(gateway, api, provider, originalBaseUrl, published) {
|
|
56
|
+
if (api !== 'openai-codex-responses' || provider !== 'openai-codex')
|
|
57
|
+
return undefined;
|
|
58
|
+
const original = endpoint(originalBaseUrl);
|
|
59
|
+
const upstream = endpoint(published?.provider_upstreams?.['openai-codex']);
|
|
60
|
+
if (!original || !upstream || !endpoint(gateway))
|
|
61
|
+
return undefined;
|
|
62
|
+
if (append(upstream, '/codex/responses') !== append(original, '/codex/responses'))
|
|
63
|
+
return undefined;
|
|
64
|
+
return trimTrailingSlashes(gateway);
|
|
65
|
+
}
|
|
55
66
|
export function verifiedProviderRoute(gateway, api, provider, originalBaseUrl, published) {
|
|
56
67
|
const original = endpoint(originalBaseUrl);
|
|
57
68
|
if (!original || !endpoint(gateway))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caveman-ai/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Caveman CLI — wrap coding agents with recoverable local context compression and truthful metering (`caveman claude`), then drive Caveman Cloud from terminal. Compression and metering run in companion Go binaries: run `caveman setup` to see install state. Local savings stay inferred until verified.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "node scripts/gen-binaries.mjs && node scripts/gen-wedge-installer.mjs && node scripts/compile-registries.mjs && tsc && node scripts/bundle-delegate.mjs && node scripts/bundle-tui.mjs && node scripts/bundle-pi-extension.mjs && node scripts/shebang.mjs",
|
|
38
38
|
"lint": "tsc --noEmit",
|
|
39
|
-
"test": "node scripts/gen-binaries.mjs && node scripts/gen-wedge-installer.mjs && node scripts/compile-registries.mjs && tsc && node scripts/bundle-delegate.mjs && node scripts/bundle-tui.mjs && node scripts/bundle-pi-extension.mjs && node scripts/shebang.mjs && node --test --test-force-exit --test-concurrency=4 tests/*.runtime.mjs",
|
|
39
|
+
"test": "node scripts/gen-binaries.mjs && node scripts/gen-wedge-installer.mjs && node scripts/compile-registries.mjs && tsc && node scripts/bundle-delegate.mjs && node scripts/bundle-tui.mjs && node scripts/bundle-pi-extension.mjs && node scripts/shebang.mjs && node --import ./tests/fixtures/sanitize-host-env.mjs --test --test-force-exit --test-concurrency=4 tests/*.runtime.mjs",
|
|
40
40
|
"bench:native": "node scripts/benchmark-native-hooks.mjs",
|
|
41
|
-
"test:fast": "node scripts/gen-binaries.mjs && node scripts/gen-wedge-installer.mjs && node scripts/compile-registries.mjs && tsc && node scripts/bundle-delegate.mjs && node scripts/bundle-tui.mjs && node scripts/bundle-pi-extension.mjs && node --test --test-force-exit --test-concurrency=4 --test-reporter=dot tests/agent-native.runtime.mjs tests/billing.runtime.mjs tests/capability-config.runtime.mjs tests/login.runtime.mjs tests/mcp-surface.runtime.mjs tests/porcelain.runtime.mjs tests/practice-registry.runtime.mjs tests/skills.runtime.mjs tests/status.runtime.mjs tests/subscription-recovery.runtime.mjs tests/wrap-gate.runtime.mjs"
|
|
41
|
+
"test:fast": "node scripts/gen-binaries.mjs && node scripts/gen-wedge-installer.mjs && node scripts/compile-registries.mjs && tsc && node scripts/bundle-delegate.mjs && node scripts/bundle-tui.mjs && node scripts/bundle-pi-extension.mjs && node --import ./tests/fixtures/sanitize-host-env.mjs --test --test-force-exit --test-concurrency=4 --test-reporter=dot tests/agent-native.runtime.mjs tests/billing.runtime.mjs tests/capability-config.runtime.mjs tests/login.runtime.mjs tests/mcp-surface.runtime.mjs tests/porcelain.runtime.mjs tests/practice-registry.runtime.mjs tests/skills.runtime.mjs tests/status.runtime.mjs tests/subscription-recovery.runtime.mjs tests/wrap-gate.runtime.mjs"
|
|
42
42
|
}
|
|
43
43
|
}
|