8a82895c65
Adds a root `ccam` plugin (`.claude-plugin/plugin.json`, `"source": "./"`) so
`/plugin marketplace add` + `/plugin install ccam@...` is enough on a machine
with nothing but Claude Code: no clone, no npm run setup, no manual npm start.
- scripts/plugin-bootstrap.js: SessionStart hook. Fast-path exit, Node >=22.5
gate (node:sqlite), mkdir lock with stale reclaim, deps installed into
~/.claude/agent-dashboard/runtime/ (never the plugin cache), legacy
checkout-hook cleanup (backed up), ~/.local/bin/ccam launcher, eager UI
build so client routes like /run work immediately, detached server spawn.
- scripts/plugin-open.js, scripts/plugin-doctor.js: /ccam-open, /ccam-doctor.
- server/index.js: DASHBOARD_CLIENT_DIST override (plugin cache is read-only).
- mcp/build/ is committed (plugin MCP servers start before any bootstrap could
build them) and kept honest by scripts/check-mcp-build.js (content hash,
not mtime), enforced by pre-commit when mcp/src changes.
- plugins/ccam-dashboard/.mcp.json moved under plugins/ccam/ with a working
${CLAUDE_PLUGIN_ROOT} path (the old relative path never resolved from a
marketplace-cached subdir).
- Docs: README, INSTALL, SETUP, ARCHITECTURE, CLAUDE.md, docs/PLUGINS.md,
docs/MCP.md, docs/CLI.md, docs/HOOKS.md.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
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(), "ccam-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);
|
|
});
|
|
});
|