Files
Julius Brussee 82864c8f4c feat: ship Caveman 2.0.0 — engine, proxy, SDKs, unified CLI
Single-commit port of the Caveman 2 tree onto the original repo history
(candidate caveman-2@88878a4 applied over main@3098342). No unrelated-history
merge; original history untouched.

Preserved v1 surfaces:
- skills/caveman/SKILL.md byte-for-byte, plus plugin mirror and caveman.skill zip
- legacy CI (Node 18/20/22 installer + Python 3.11 suites) alongside engine-ci
- cli/install.js compatibility shim forwarding to bin/install.js
- .codex/config.toml ships both hooks and codex_hooks for older Codex (#617)
- README Trendshift + Skills.sh badges and local star-history asset
- v1.10.0-pinned curl installs; benchmarks/tmp-starcharts ignore rules

Fixed for public same-repo release:
- SECURITY.md vulnerability reporting points at this repository
- release-binaries.yml publishes to this repo via job-scoped GITHUB_TOKEN
  (cross-repo PAT removed); binary-release environment still gates signing
- packages/cli/PUBLISHING.md rewritten for packages/ layout and same-repo flow
- profile-contract and provider-catalog lanes skip lane-scope gates on
  initial import so the launch PR can gate on their real validation steps
- ANNOUNCEMENT.md network claim corrected: compression is local; requests
  still go to the provider you configured

Caveman 2 stays opt-in: bin-v1.0.0 binaries and @caveman-ai/cli publish
separately after this lands and soaks.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BLvb5QniwYjmcawyssQNw9
2026-08-11 16:46:10 +02:00

102 lines
4.3 KiB
JavaScript

import { test } from "node:test";
import assert from "node:assert/strict";
import { spawn } from "node:child_process";
import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
const cli = join(dirname(fileURLToPath(import.meta.url)), "..", "dist", "index.js");
function fixtureEnv() {
const home = mkdtempSync(join(tmpdir(), "cave-aider-home-"));
const binDir = mkdtempSync(join(tmpdir(), "cave-aider-bin-"));
const caveDir = join(home, ".caveman-cloud");
mkdirSync(caveDir, { recursive: true });
writeFileSync(join(caveDir, "config.json"), JSON.stringify({
firstRunAt: new Date().toISOString(),
wrap: { proxy: false, browse: false },
}));
writeFileSync(join(binDir, "aider"), `#!/usr/bin/env node
process.stdout.write(JSON.stringify({
args: process.argv.slice(2),
baseUrl: process.env.OPENAI_API_BASE || null,
}));
`, { mode: 0o755 });
const env = {
...process.env,
HOME: home,
NO_COLOR: "1",
PATH: `${binDir}:${process.env.PATH}`,
};
delete env.CAVE_GATEWAY_URL;
delete env.CAVE_API_KEY;
return env;
}
function runCli(argv, env) {
return new Promise((resolve, reject) => {
const child = spawn(process.execPath, [cli, ...argv], { env });
let stdout = "";
let stderr = "";
child.stdout.on("data", (chunk) => (stdout += chunk));
child.stderr.on("data", (chunk) => (stderr += chunk));
child.on("exit", (code) => resolve({ code, stdout, stderr }));
child.on("error", reject);
});
}
test("wrap aider selects its OpenAI-compatible provider when model is absent", async () => {
const out = await runCli(["wrap", "aider", "--yes"], fixtureEnv());
assert.equal(out.code, 0, out.stderr);
const child = JSON.parse(out.stdout);
assert.deepEqual(child.args, ["--model", "openai/gpt-5.5", "--yes"]);
assert.equal(child.baseUrl, "http://127.0.0.1:8787/w/aider/openai/v1");
assert.match(out.stderr, /aider model not set; routing with --model openai\/gpt-5\.5/);
});
test("wrap aider preserves an explicit OpenAI-compatible model", async () => {
const out = await runCli(["wrap", "aider", "--model=openai/gpt-5.4-mini", "--yes"], fixtureEnv());
assert.equal(out.code, 0, out.stderr);
assert.deepEqual(JSON.parse(out.stdout).args, ["--model=openai/gpt-5.4-mini", "--yes"]);
assert.doesNotMatch(out.stderr, /traffic may bypass Caveman/);
});
test("wrap aider treats -m as message and still inserts a routed model", async () => {
const out = await runCli(["wrap", "aider", "-m", "fix the bug"], fixtureEnv());
assert.equal(out.code, 0, out.stderr);
assert.deepEqual(JSON.parse(out.stdout).args, ["--model", "openai/gpt-5.5", "-m", "fix the bug"]);
assert.doesNotMatch(out.stderr, /traffic may bypass Caveman/);
});
test("wrap aider warns when an explicit model can bypass the routed provider", async () => {
const out = await runCli(["wrap", "aider", "--model", "anthropic/claude-sonnet-4", "--yes"], fixtureEnv());
assert.equal(out.code, 0, out.stderr);
assert.deepEqual(JSON.parse(out.stdout).args, ["--model", "anthropic/claude-sonnet-4", "--yes"]);
assert.match(out.stderr, /aider model "anthropic\/claude-sonnet-4" does not select its OpenAI-compatible provider; traffic may bypass Caveman/);
});
test("wrap aider warns from the last effective repeated model selector", async () => {
const out = await runCli([
"wrap", "aider",
"--model", "openai/gpt-5.5",
"--model=anthropic/claude-sonnet-4",
"--yes",
], fixtureEnv());
assert.equal(out.code, 0, out.stderr);
assert.deepEqual(JSON.parse(out.stdout).args, [
"--model", "openai/gpt-5.5",
"--model=anthropic/claude-sonnet-4",
"--yes",
]);
assert.match(out.stderr, /aider model "anthropic\/claude-sonnet-4" does not select its OpenAI-compatible provider; traffic may bypass Caveman/);
});
test("wrap aider warns on a malformed model selector instead of claiming a routed model", async () => {
const out = await runCli(["wrap", "aider", "--model", "--yes"], fixtureEnv());
assert.equal(out.code, 0, out.stderr);
assert.deepEqual(JSON.parse(out.stdout).args, ["--model", "--yes"]);
assert.match(out.stderr, /aider --model requires a value; Aider may reject this launch before routing/);
assert.doesNotMatch(out.stderr, /model not set; routing with/);
});