Repository navigation
Expand file tree
/
Copy pathsetup.mjs
More file actions
40 lines (38 loc) · 2.1 KB
/
Copy pathsetup.mjs
File metadata and controls
40 lines (38 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env node
// ZCode access kit — one-command setup for a fresh clone (compat entry).
//
// node setup.mjs # bootstrap + one y/n question per detected harness
// node setup.mjs --only=omp,mcp # subset: omp | claude-code | codex | mcp
// node setup.mjs --rollback [tx-id] # undo the newest (or named) transaction
// node setup.mjs --list-transactions # show recorded transaction ids
//
// Since the zcode-kit CLI exists, this file is a thin shim delegating to
// cli/zcode-kit.mjs — same behavior, one implementation (no
// duplicated setup logic). Legacy flags map as: --only=<list> → --harness=<list>.
import { spawnSync } from "node:child_process";
import { join, dirname } from "node:path";
import { fileURLToPath } from "node:url";
const ROOT = dirname(fileURLToPath(import.meta.url));
const argv = process.argv.slice(2);
const mode = argv[0] ?? "install";
const kit = join(ROOT, "cli", "zcode-kit.mjs");
if (mode === "--postinstall-hint") {
console.log("ZCode Agent Kit installed. Run zcode-kit setup to choose which detected harnesses to configure.");
} else if (mode === "--rollback" || mode === "rollback") {
const res = spawnSync(process.execPath, [kit, "rollback", ...(argv[1] ? [argv[1]] : [])], { stdio: "inherit" });
process.exit(res.status ?? 1);
} else if (mode === "--list-transactions") {
const { listTransactions } = await import('./lib/transaction.mjs');
const { createCtx } = await import('./cli/context.mjs');
const ids = listTransactions(createCtx(ROOT).backupDir);
console.log(ids.length ? ids.join("\n") : "no transactions recorded");
} else {
const only = argv.find((a) => a.startsWith("--only="));
const args = ["setup"];
// Legacy `mcp` token: MCP registration follows the selected harnesses and
// is not a harness id itself.
const harnesses = only ? only.slice(7).split(",").map((s) => s.trim()).filter((s) => s && s !== "mcp") : null;
if (only && harnesses.length) args.push(`--harness=${harnesses.join(",")}`);
const res = spawnSync(process.execPath, [kit, ...args], { stdio: "inherit" });
process.exit(res.status ?? 1);
}