Files
nntrivi2001 17d56d0e01 refactor!: rebrand CCAM to AgentHub
Clean break, no compatibility alias. Renames the product name, the CLI
binary (`ccam` -> `agenthub`), the env var prefix (`CCAM_` ->
`AGENTHUB_`), the Prometheus metric namespace (`ccam_*` ->
`agenthub_*`), the tmux session prefix (`ccam-lane-<id>` ->
`agenthub-lane-<id>`), the per-repo runtime profile directory
(`.ccam/profile` -> `.agenthub/profile`), the lanes state root
(`~/.claude/ccam-lanes` -> `~/.claude/agenthub-lanes`), the bundled
plugins (`plugins/ccam*` -> `plugins/agenthub*`) and their slash
commands (`/ccam-doctor` -> `/agenthub-doctor`, `/ccam:*` ->
`/agenthub:*`).

Because there is no alias, an existing install has to be updated by
hand: rename its `.ccam/profile` directory and any `CCAM_*` variables,
and reinstall the plugin under its new name.

Two other name families are deliberately left alone here, since they are
not just strings: the `Claude-Code-Monitor` repository/marketplace name,
and the `agent-dashboard` npm package plus its `~/.claude/agent-dashboard`
runtime directory, which holds the live database and needs a migration
rather than a rename.

Verified: server 1406/1406, client 459/459, `grep -i ccam` clean across
tracked files, `openapi.yaml` regenerated (95 paths, unchanged count).
2026-09-07 12:09:15 +07:00

66 lines
2.2 KiB
JavaScript

/**
* @file Tests for server/lib/gh.js's execFile wrapper against real fake `gh`
* scripts on PATH — the same fixture style server/__tests__/lane-lifecycle.test.js
* uses for a fake `claude` binary, since this codebase's server tests use real
* subprocesses instead of mocking child_process.
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
*/
const { describe, it, after } = require("node:test");
const assert = require("node:assert/strict");
const fs = require("node:fs");
const os = require("node:os");
const path = require("node:path");
const ROOT = fs.mkdtempSync(path.join(os.tmpdir(), "agenthub-gh-"));
const { gh } = require("../lib/gh");
/** Puts a fake `gh` script on PATH for the duration of one test. */
function stubGh(scriptBody) {
const bin = path.join(ROOT, `bin-${Date.now()}-${Math.random().toString(36).slice(2)}`);
fs.mkdirSync(bin, { recursive: true });
const bin_gh = path.join(bin, "gh");
fs.writeFileSync(bin_gh, `#!/usr/bin/env bash\n${scriptBody}\n`);
fs.chmodSync(bin_gh, 0o755);
const originalPath = process.env.PATH;
process.env.PATH = `${bin}${path.delimiter}${originalPath}`;
return () => {
process.env.PATH = originalPath;
};
}
after(() => fs.rmSync(ROOT, { recursive: true, force: true }));
describe("gh()", () => {
it("returns stdout on success", async () => {
const restore = stubGh('echo "$@" >&2\necho \'{"ok":true}\'');
try {
const result = await gh(ROOT, ["run", "list"]);
assert.match(result.stdout, /"ok":true/);
} finally {
restore();
}
});
it("throws with .gh details on a non-zero exit", async () => {
const restore = stubGh('echo "boom" >&2\nexit 7');
try {
await assert.rejects(
() => gh(ROOT, ["run", "list"]),
(err) => err.gh.code === 7 && /boom/.test(err.gh.stderr)
);
} finally {
restore();
}
});
it("throws ENOGH when gh is not on PATH", async () => {
const originalPath = process.env.PATH;
process.env.PATH = ROOT; // a directory with no gh binary in it
try {
await assert.rejects(() => gh(ROOT, ["run", "list"]), { code: "ENOGH" });
} finally {
process.env.PATH = originalPath;
}
});
});