@scp-dev/cli 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/dist/{chunk-2LIJXXTL.js → chunk-BSX24XMZ.js} +89 -20
  2. package/dist/{chunk-VQU5CPE4.js → chunk-C5PYVRJE.js} +2 -2
  3. package/dist/{chunk-IEFXYBX7.js → chunk-C7ZUACP7.js} +1 -1
  4. package/dist/{chunk-HHVNSHGB.js → chunk-CVW3INZO.js} +5 -5
  5. package/dist/{chunk-VW7DYSGM.js → chunk-DEK3TE6T.js} +3 -3
  6. package/dist/{chunk-B2G3XTW7.js → chunk-GG33NSBW.js} +5 -1
  7. package/dist/claude-NCPNZLIX.js +290 -0
  8. package/dist/cli.js +1 -1
  9. package/dist/{codex-4WPBAFAT.js → codex-4GTXURTS.js} +33 -26
  10. package/dist/{hooks-ISZTCOLZ.js → hooks-SWVIDONV.js} +2 -2
  11. package/dist/{install-SDLWXW32.js → install-YE7LCGPC.js} +3 -3
  12. package/dist/{join-FITJVZCA.js → join-64BU6SEY.js} +6 -2
  13. package/dist/{login-AUMLI4FS.js → login-4IF26HH5.js} +2 -2
  14. package/dist/{main-STUKDZ5L.js → main-RA3MP25N.js} +72 -28
  15. package/dist/{mcp-J2CL6A4R.js → mcp-RERRUUIX.js} +31 -20
  16. package/dist/{mesh-UG6VO7ZO.js → mesh-XTMBRJLR.js} +1 -1
  17. package/dist/{opencode-WFP57BZD.js → opencode-CPNR2G3W.js} +4 -4
  18. package/dist/{peek-YTCWVPF7.js → peek-GEYQ7SHV.js} +1 -1
  19. package/dist/{pi-QEZVFDNR.js → pi-XHZAUDP4.js} +1 -1
  20. package/dist/{relay-QWJM372C.js → relay-E4JFR33E.js} +1 -1
  21. package/dist/{remote-P4GFUIAP.js → remote-3R4GRDGI.js} +2 -2
  22. package/dist/{setup-R5SNWVVF.js → setup-O45SE5L7.js} +4 -4
  23. package/dist/{spawn-WJYOTAKI.js → spawn-CJSHYE7E.js} +5 -5
  24. package/dist/{up-UWV5BQUH.js → up-O2CMDGXP.js} +5 -5
  25. package/package.json +6 -6
  26. package/dist/claude-L2I5ZM2B.js +0 -130
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scp-dev/cli",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "The swarm command line tool.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://scp.dev",
@@ -24,15 +24,15 @@
24
24
  "typecheck": "tsc -p ."
25
25
  },
26
26
  "dependencies": {
27
- "@scp-dev/core": "0.2.0",
28
- "@scp-dev/broker": "0.3.0",
29
- "@scp-dev/hub": "0.6.0",
30
- "@scp-dev/mcp": "0.1.9",
27
+ "@scp-dev/core": "0.3.1",
28
+ "@scp-dev/broker": "0.4.1",
29
+ "@scp-dev/hub": "0.6.2",
30
+ "@scp-dev/mcp": "0.2.1",
31
31
  "smol-toml": "^1.9.1"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@openai/codex": "0.159.0",
35
- "@scp-dev/mesh": "0.0.6",
35
+ "@scp-dev/mesh": "0.0.8",
36
36
  "opencode-ai": "1.18.34",
37
37
  "tsup": "^8.5.1"
38
38
  },
@@ -1,130 +0,0 @@
1
- import {
2
- entryArgv,
3
- mcpFile,
4
- mountedEntry,
5
- whichOnPath
6
- } from "./chunk-VW7DYSGM.js";
7
- import "./chunk-VQU5CPE4.js";
8
- import "./chunk-B2G3XTW7.js";
9
- import "./chunk-YYSLYVNZ.js";
10
- import {
11
- CHANNELS_ENV,
12
- RelayUsage,
13
- deriveHandle,
14
- joinMode
15
- } from "./chunk-2LIJXXTL.js";
16
- import "./chunk-MNTIEWKF.js";
17
-
18
- // src/claude.ts
19
- import { spawn } from "child_process";
20
- import { existsSync, readFileSync } from "fs";
21
- import { join } from "path";
22
- import { CLI_NAME, validHandle } from "@scp-dev/core";
23
- var CHANNEL_FLAGS = ["--dangerously-load-development-channels", "server:scp"];
24
- function claudeArgv(argv) {
25
- let name;
26
- let i = 0;
27
- for (; ; ) {
28
- const arg = argv[i];
29
- if (arg === "--name" || arg === "--as") {
30
- if (argv[i + 1] === void 0) throw new RelayUsage(`${CLI_NAME} claude ${arg} takes a handle`);
31
- name = argv[i + 1];
32
- i += 2;
33
- } else if (arg?.startsWith("--name=") || arg?.startsWith("--as=")) {
34
- name = arg.slice(arg.indexOf("=") + 1);
35
- i++;
36
- } else break;
37
- }
38
- if (argv[i] === "--") i++;
39
- name = name?.replace(/^me\//, "");
40
- if (name !== void 0 && !validHandle(name)) throw new RelayUsage(`--name ${JSON.stringify(name)} is not a valid agent handle`);
41
- return { ...name !== void 0 ? { name } : {}, args: argv.slice(i) };
42
- }
43
- function claudeLaunchArgs(args, added) {
44
- const end = args.indexOf("--");
45
- const at = end < 0 ? args.length : end;
46
- const channels = args.some((arg, i) => i < at && (arg === "server:scp" || arg === `${CHANNEL_FLAGS[0]}=server:scp`)) ? [] : CHANNEL_FLAGS;
47
- return [...args.slice(0, at), ...channels, ...added, ...args.slice(at)];
48
- }
49
- var STRICT_HINT = `${CLI_NAME} claude: --strict-mcp-config without --mcp-config drops the scp mount, so messages cannot wake this session`;
50
- function externalMcp(args) {
51
- return args.some((arg) => arg === "--mcp-config" || arg.startsWith("--mcp-config="));
52
- }
53
- function namePrompt(name, args, env, cwd) {
54
- if (name !== void 0 || joinMode(env) === "manual" || args.some((arg) => /^--(append-)?system-prompt/.test(arg))) return [];
55
- const handle = env.SCP_NAME || deriveHandle("claude-code", cwd);
56
- return [
57
- "--append-system-prompt",
58
- `You are on the SCP network as ${handle}. Pick a short descriptive name for yourself with \`${CLI_NAME} name <name>\` when you know what you're working on.`
59
- ];
60
- }
61
- function mountHint(env, cwd = process.cwd()) {
62
- const file = mcpFile("claude", env);
63
- const entries = [];
64
- try {
65
- const user = mountedEntry("claude", file);
66
- if (user) entries.push(user);
67
- const config = existsSync(file) ? JSON.parse(readFileSync(file, "utf8")) : {};
68
- const local = config.projects?.[cwd]?.mcpServers?.scp;
69
- if (local && typeof local === "object") entries.push(local);
70
- } catch {
71
- return `${CLI_NAME} claude: ${file} is unreadable, so the scp mount is unchecked; fix it or run ${CLI_NAME} setup --write`;
72
- }
73
- const project = join(cwd, ".mcp.json");
74
- try {
75
- const entry = existsSync(project) ? mountedEntry("claude", project) : void 0;
76
- if (entry) entries.push(entry);
77
- } catch {
78
- }
79
- if (!entries.length) return `${CLI_NAME} claude: Claude Code has no scp MCP mount, so messages cannot wake this session; run ${CLI_NAME} setup --write`;
80
- if (!entries.some((entry) => entryArgv("claude", entry).includes("--channels")))
81
- return `${CLI_NAME} claude: the scp mount lacks --channels, so messages cannot wake this session; run ${CLI_NAME} setup --write`;
82
- return void 0;
83
- }
84
- async function claudeCommand(argv, env = process.env, err = (line) => void process.stderr.write(`${line}
85
- `), cwd = process.cwd()) {
86
- if (argv[0] === "--help" || argv[0] === "-h") {
87
- process.stdout.write(
88
- `${CLI_NAME} claude [--name N | --as N] [--] [claude args...] start Claude Code with the scp channel loaded, so peer messages wake it
89
- `
90
- );
91
- return 0;
92
- }
93
- const { name, args } = claudeArgv(argv);
94
- const bin = whichOnPath("claude", env);
95
- if (!bin) throw new RelayUsage("claude is not on PATH");
96
- const external = externalMcp(args);
97
- const hint = external ? void 0 : args.includes("--strict-mcp-config") ? STRICT_HINT : mountHint(env, cwd);
98
- if (hint) throw new RelayUsage(hint);
99
- if (external) err(`${CLI_NAME} claude: using your --mcp-config; it needs the scp server with --channels for messages to wake this session`);
100
- const child = spawn(bin, claudeLaunchArgs(args, namePrompt(name, args, env, cwd)), {
101
- cwd,
102
- stdio: "inherit",
103
- env: { ...env, ...name !== void 0 ? { SCP_NAME: name } : {}, [CHANNELS_ENV]: String(process.pid) }
104
- });
105
- const forward = (signal) => () => void child.kill(signal);
106
- const handlers = ["SIGTERM", "SIGHUP"].map((signal) => [signal, forward(signal)]);
107
- const ignore = () => {
108
- };
109
- process.on("SIGINT", ignore);
110
- for (const [signal, handler] of handlers) process.on(signal, handler);
111
- try {
112
- return await new Promise((resolve, reject) => {
113
- child.once("error", reject);
114
- child.once("exit", (code, signal) => resolve(code ?? (signal ? 128 + (signalNumber(signal) ?? 1) : 1)));
115
- });
116
- } finally {
117
- process.off("SIGINT", ignore);
118
- for (const [signal, handler] of handlers) process.off(signal, handler);
119
- }
120
- }
121
- var SIGNALS = { SIGHUP: 1, SIGINT: 2, SIGKILL: 9, SIGTERM: 15 };
122
- var signalNumber = (signal) => SIGNALS[signal];
123
- export {
124
- CHANNEL_FLAGS,
125
- claudeArgv,
126
- claudeCommand,
127
- claudeLaunchArgs,
128
- mountHint,
129
- namePrompt
130
- };