17d56d0e01
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).
86 lines
3.1 KiB
JavaScript
86 lines
3.1 KiB
JavaScript
/**
|
|
* @file Tests scripts/check-mcp-build.js — the freshness gate for the committed
|
|
* mcp/build artifact. Content hashing is the whole point: mtimes are meaningless
|
|
* after a clone, where every file is stamped at checkout time in arbitrary order.
|
|
* Runs against synthetic trees, never the real mcp/.
|
|
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
|
|
*/
|
|
|
|
const { describe, it, beforeEach, after } = require("node:test");
|
|
const assert = require("node:assert/strict");
|
|
const fs = require("fs");
|
|
const os = require("os");
|
|
const path = require("path");
|
|
|
|
const { sourceHash, mcpBuildStatus, writeHash } = require("../../scripts/check-mcp-build");
|
|
|
|
const ROOT = fs.mkdtempSync(path.join(os.tmpdir(), "agenthub-mcpbuild-"));
|
|
const SRC = path.join(ROOT, "mcp", "src");
|
|
const BUILD = path.join(ROOT, "mcp", "build");
|
|
|
|
function makeTree() {
|
|
fs.rmSync(path.join(ROOT, "mcp"), { recursive: true, force: true });
|
|
fs.mkdirSync(SRC, { recursive: true });
|
|
fs.mkdirSync(BUILD, { recursive: true });
|
|
fs.writeFileSync(path.join(SRC, "index.ts"), "export const a = 1;\n");
|
|
fs.writeFileSync(path.join(ROOT, "mcp", "package.json"), '{"name":"x"}\n');
|
|
fs.writeFileSync(path.join(BUILD, "index.js"), "exports.a = 1;\n");
|
|
}
|
|
|
|
after(() => fs.rmSync(ROOT, { recursive: true, force: true }));
|
|
|
|
describe("mcp build freshness", () => {
|
|
beforeEach(makeTree);
|
|
|
|
it("fails when the build has no recorded hash", () => {
|
|
const status = mcpBuildStatus(ROOT);
|
|
assert.equal(status.ok, false);
|
|
assert.match(status.reason, /no recorded source hash/);
|
|
});
|
|
|
|
it("passes right after the hash is stamped", () => {
|
|
writeHash(ROOT);
|
|
assert.equal(mcpBuildStatus(ROOT).ok, true);
|
|
});
|
|
|
|
it("fails when a source file changes after the build", () => {
|
|
writeHash(ROOT);
|
|
fs.writeFileSync(path.join(SRC, "index.ts"), "export const a = 2;\n");
|
|
const status = mcpBuildStatus(ROOT);
|
|
assert.equal(status.ok, false);
|
|
assert.match(status.reason, /stale/);
|
|
});
|
|
|
|
it("fails when a source file is added after the build", () => {
|
|
writeHash(ROOT);
|
|
fs.writeFileSync(path.join(SRC, "extra.ts"), "export const b = 1;\n");
|
|
assert.equal(mcpBuildStatus(ROOT).ok, false);
|
|
});
|
|
|
|
it("fails when the build output is missing entirely", () => {
|
|
writeHash(ROOT);
|
|
fs.rmSync(path.join(BUILD, "index.js"));
|
|
assert.match(mcpBuildStatus(ROOT).reason, /missing/);
|
|
});
|
|
|
|
it("ignores modification times — only content counts", () => {
|
|
const before = sourceHash(ROOT);
|
|
const future = Date.now() / 1000 + 10_000;
|
|
fs.utimesSync(path.join(SRC, "index.ts"), future, future);
|
|
assert.equal(sourceHash(ROOT), before);
|
|
});
|
|
|
|
it("tracks the manifest, so a dependency bump invalidates the build", () => {
|
|
writeHash(ROOT);
|
|
fs.writeFileSync(path.join(ROOT, "mcp", "package.json"), '{"name":"x","version":"2"}\n');
|
|
assert.equal(mcpBuildStatus(ROOT).ok, false);
|
|
});
|
|
});
|
|
|
|
describe("the committed mcp/build in this repo", () => {
|
|
it("matches mcp/src", () => {
|
|
const status = mcpBuildStatus(path.resolve(__dirname, "..", ".."));
|
|
assert.equal(status.ok, true, status.reason);
|
|
});
|
|
});
|