svamp-cli 0.2.190 → 0.2.193
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.
- package/dist/agentCommands-BmA4np5o.mjs +379 -0
- package/dist/auth-DiC4bXUT.mjs +83 -0
- package/dist/caddy-CuTbE3NY.mjs +322 -0
- package/dist/cli.mjs +2303 -0
- package/dist/commands-B6mOqtXM.mjs +196 -0
- package/dist/commands-By97uPq7.mjs +2721 -0
- package/dist/commands-CGAgeoBz.mjs +610 -0
- package/dist/commands-CPT-Wu41.mjs +390 -0
- package/dist/commands-CRmtBdgs.mjs +544 -0
- package/dist/commands-D_Dqz5Kt.mjs +428 -0
- package/dist/commands-QzPRQeKZ.mjs +255 -0
- package/dist/fleet-CZpk6-Xg.mjs +356 -0
- package/dist/frpc-B7NXLQsh.mjs +681 -0
- package/dist/headlessCli-Dw7jUz1h.mjs +333 -0
- package/dist/httpServer-Cf54pQ77.mjs +238 -0
- package/dist/index.mjs +22 -0
- package/dist/package-CzvXt0G5.mjs +63 -0
- package/dist/pinnedClaudeCode-HydRNEt7.mjs +58 -0
- package/dist/rpc-CBVukorH.mjs +87 -0
- package/dist/rpc-MAQMw8il.mjs +151 -0
- package/dist/run-B_UWCqRV.mjs +15324 -0
- package/dist/run-iqdE_9Ef.mjs +1086 -0
- package/dist/sandboxDetect-DNTcbgWD.mjs +12 -0
- package/dist/scheduler-TfLOcnBs.mjs +96 -0
- package/dist/serveCommands-DFrOQUs1.mjs +310 -0
- package/dist/serveManager-DpIlnzKd.mjs +781 -0
- package/dist/serviceManager-hlOVxkhW.mjs +78 -0
- package/dist/sideband-C-cTD2o2.mjs +80 -0
- package/dist/store-DEZ8e-uE.mjs +148 -0
- package/dist/supervisorLock-DmfzJx7B.mjs +159 -0
- package/package.json +1 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { spawn, exec as exec$1 } from 'node:child_process';
|
|
2
|
+
import { promisify } from 'node:util';
|
|
3
|
+
|
|
4
|
+
const PINNED_CLAUDE_CODE_VERSION = "2.1.168";
|
|
5
|
+
const exec = promisify(exec$1);
|
|
6
|
+
async function readClaudeVersion() {
|
|
7
|
+
try {
|
|
8
|
+
const { stdout } = await exec("claude --version", { timeout: 1e4 });
|
|
9
|
+
const m = stdout.trim().match(/(\d+\.\d+\.\d+(?:[-.][\w]+)?)/);
|
|
10
|
+
return m ? m[1] : null;
|
|
11
|
+
} catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function runInstaller(version, log) {
|
|
16
|
+
return new Promise((resolve) => {
|
|
17
|
+
const proc = spawn("claude", ["install", version], { stdio: ["ignore", "pipe", "pipe"] });
|
|
18
|
+
let stderr = "";
|
|
19
|
+
proc.stdout?.on("data", (b) => log(`[claude install] ${b.toString().trimEnd()}`));
|
|
20
|
+
proc.stderr?.on("data", (b) => {
|
|
21
|
+
const s = b.toString();
|
|
22
|
+
stderr += s;
|
|
23
|
+
log(`[claude install] ${s.trimEnd()}`);
|
|
24
|
+
});
|
|
25
|
+
proc.on("error", (e) => {
|
|
26
|
+
stderr += String(e);
|
|
27
|
+
resolve({ ok: false, stderr });
|
|
28
|
+
});
|
|
29
|
+
proc.on("exit", (code) => resolve({ ok: code === 0, stderr }));
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
async function ensureClaudeCodeVersion(log, pinned = PINNED_CLAUDE_CODE_VERSION, opts) {
|
|
33
|
+
const autoInstall = opts?.allowAutoInstall !== false;
|
|
34
|
+
const current = await readClaudeVersion();
|
|
35
|
+
if (!current) {
|
|
36
|
+
log(`[claude-version] 'claude' not on PATH \u2014 please run the Anthropic installer once: curl -fsSL https://claude.ai/install.sh | sh`);
|
|
37
|
+
return { kind: "not-installed", want: pinned };
|
|
38
|
+
}
|
|
39
|
+
if (current === pinned) {
|
|
40
|
+
log(`[claude-version] OK \u2014 claude ${current} matches pinned ${pinned}`);
|
|
41
|
+
return { kind: "ok", version: current };
|
|
42
|
+
}
|
|
43
|
+
if (!autoInstall) {
|
|
44
|
+
log(`[claude-version] DRIFT \u2014 installed ${current} \u2260 pinned ${pinned} (auto-install disabled)`);
|
|
45
|
+
return { kind: "skipped", reason: `installed=${current} pinned=${pinned}` };
|
|
46
|
+
}
|
|
47
|
+
log(`[claude-version] DRIFT \u2014 installed ${current} \u2260 pinned ${pinned}; running 'claude install ${pinned}'`);
|
|
48
|
+
const { ok, stderr } = await runInstaller(pinned, log);
|
|
49
|
+
if (!ok) {
|
|
50
|
+
log(`[claude-version] install failed for ${pinned}: ${stderr.trim().slice(0, 400)}`);
|
|
51
|
+
return { kind: "install-failed", from: current, want: pinned, error: stderr.slice(0, 400) };
|
|
52
|
+
}
|
|
53
|
+
const after = await readClaudeVersion();
|
|
54
|
+
log(`[claude-version] installer finished; now reports ${after ?? "unknown"}`);
|
|
55
|
+
return { kind: "installed", from: current, to: after ?? pinned };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { PINNED_CLAUDE_CODE_VERSION, ensureClaudeCodeVersion };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { m as resolveProjectRoot } from './run-B_UWCqRV.mjs';
|
|
3
|
+
import { g as getWorkflow, w as workflowSteps, s as setWorkflowEnabled, r as removeWorkflow, a as saveWorkflow, b as rawWorkflow, l as listWorkflows } from './store-DEZ8e-uE.mjs';
|
|
4
|
+
import 'os';
|
|
5
|
+
import 'fs/promises';
|
|
6
|
+
import 'fs';
|
|
7
|
+
import 'path';
|
|
8
|
+
import 'url';
|
|
9
|
+
import 'child_process';
|
|
10
|
+
import 'crypto';
|
|
11
|
+
import 'node:crypto';
|
|
12
|
+
import 'node:fs';
|
|
13
|
+
import 'util';
|
|
14
|
+
import 'node:path';
|
|
15
|
+
import 'node:events';
|
|
16
|
+
import 'node:os';
|
|
17
|
+
import '@agentclientprotocol/sdk';
|
|
18
|
+
import '@modelcontextprotocol/sdk/client/index.js';
|
|
19
|
+
import '@modelcontextprotocol/sdk/client/stdio.js';
|
|
20
|
+
import '@modelcontextprotocol/sdk/types.js';
|
|
21
|
+
import 'zod';
|
|
22
|
+
import 'node:fs/promises';
|
|
23
|
+
import 'node:util';
|
|
24
|
+
import 'yaml';
|
|
25
|
+
|
|
26
|
+
function workflowRpc(cwd, params) {
|
|
27
|
+
const root = resolveProjectRoot(cwd || process.cwd());
|
|
28
|
+
const op = params.op;
|
|
29
|
+
switch (op) {
|
|
30
|
+
case "list":
|
|
31
|
+
return listWorkflows(root);
|
|
32
|
+
case "show": {
|
|
33
|
+
const wf = getWorkflow(root, String(params.name));
|
|
34
|
+
return { meta: wf, yaml: wf ? rawWorkflow(root, String(params.name)) || "" : null };
|
|
35
|
+
}
|
|
36
|
+
case "add": {
|
|
37
|
+
const on = {};
|
|
38
|
+
const crons = Array.isArray(params.cron) ? params.cron.map(String) : params.cron ? [String(params.cron)] : [];
|
|
39
|
+
if (crons.length) on.schedule = crons.map((c) => ({ cron: c }));
|
|
40
|
+
if (params.dispatch || params.workflow_dispatch) on.workflow_dispatch = true;
|
|
41
|
+
if (params.channel) on.channel = String(params.channel);
|
|
42
|
+
if (Array.isArray(params.issue) && params.issue.length) on.issue = params.issue.map(String);
|
|
43
|
+
const runs = Array.isArray(params.runs) ? params.runs.map(String).filter(Boolean) : [];
|
|
44
|
+
if (!params.name || !runs.length) throw new Error("workflow add: name and at least one run step required");
|
|
45
|
+
const wf = {
|
|
46
|
+
name: String(params.name),
|
|
47
|
+
on: Object.keys(on).length ? on : void 0,
|
|
48
|
+
jobs: { run: { steps: runs.map((r) => ({ run: r })) } },
|
|
49
|
+
session: params.session || null
|
|
50
|
+
};
|
|
51
|
+
saveWorkflow(root, wf);
|
|
52
|
+
return wf;
|
|
53
|
+
}
|
|
54
|
+
case "remove":
|
|
55
|
+
return { removed: removeWorkflow(root, String(params.name)) };
|
|
56
|
+
case "enable":
|
|
57
|
+
case "disable": {
|
|
58
|
+
const wf = setWorkflowEnabled(root, String(params.name), op === "enable");
|
|
59
|
+
if (!wf) throw new Error(`Workflow not found: ${params.name}`);
|
|
60
|
+
return wf;
|
|
61
|
+
}
|
|
62
|
+
case "run": {
|
|
63
|
+
const wf = getWorkflow(root, String(params.name));
|
|
64
|
+
if (!wf) throw new Error(`Workflow not found: ${params.name}`);
|
|
65
|
+
const steps = workflowSteps(wf);
|
|
66
|
+
const stepEnv = wf.session ? { ...process.env, SVAMP_SESSION_ID: wf.session } : process.env;
|
|
67
|
+
const out = [`\u25B6 running workflow "${wf.name}" (${steps.length} step${steps.length === 1 ? "" : "s"})`];
|
|
68
|
+
for (let i = 0; i < steps.length; i++) {
|
|
69
|
+
const step = steps[i];
|
|
70
|
+
out.push(` [${i + 1}/${steps.length}] $ ${step.run}`);
|
|
71
|
+
const r = spawnSync("sh", ["-c", step.run], { cwd: root, encoding: "utf-8", timeout: 12e4, env: stepEnv });
|
|
72
|
+
if (r.stdout) out.push(r.stdout.trimEnd());
|
|
73
|
+
if (r.stderr) out.push(r.stderr.trimEnd());
|
|
74
|
+
if (r.status !== 0) {
|
|
75
|
+
out.push(` \u2717 step ${i + 1} failed (exit ${r.status ?? "signal"}). Stopping.`);
|
|
76
|
+
return { ok: false, output: out.join("\n") };
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
out.push(`\u2713 workflow "${wf.name}" completed.`);
|
|
80
|
+
return { ok: true, output: out.join("\n") };
|
|
81
|
+
}
|
|
82
|
+
default:
|
|
83
|
+
throw new Error(`workflow rpc: unknown op "${op}"`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export { workflowRpc };
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { m as resolveProjectRoot, u as updateIssue, n as getIssue, o as addComment, p as addIssue, q as listIssues, t as searchIssues } from './run-B_UWCqRV.mjs';
|
|
2
|
+
import 'os';
|
|
3
|
+
import 'fs/promises';
|
|
4
|
+
import 'fs';
|
|
5
|
+
import 'path';
|
|
6
|
+
import 'url';
|
|
7
|
+
import 'child_process';
|
|
8
|
+
import 'crypto';
|
|
9
|
+
import 'node:crypto';
|
|
10
|
+
import 'node:fs';
|
|
11
|
+
import 'node:child_process';
|
|
12
|
+
import 'util';
|
|
13
|
+
import 'node:path';
|
|
14
|
+
import 'node:events';
|
|
15
|
+
import 'node:os';
|
|
16
|
+
import '@agentclientprotocol/sdk';
|
|
17
|
+
import '@modelcontextprotocol/sdk/client/index.js';
|
|
18
|
+
import '@modelcontextprotocol/sdk/client/stdio.js';
|
|
19
|
+
import '@modelcontextprotocol/sdk/types.js';
|
|
20
|
+
import 'zod';
|
|
21
|
+
import 'node:fs/promises';
|
|
22
|
+
import 'node:util';
|
|
23
|
+
|
|
24
|
+
function compact(i) {
|
|
25
|
+
const { body, original, ...rest } = i;
|
|
26
|
+
return rest;
|
|
27
|
+
}
|
|
28
|
+
function buildVerify(p) {
|
|
29
|
+
if (p.verifyCmd) return { type: "command", text: String(p.verifyCmd) };
|
|
30
|
+
if (p.verify) return { type: "agent", text: String(p.verify) };
|
|
31
|
+
if (p.manual) return { type: "manual" };
|
|
32
|
+
if (p.noVerify) return null;
|
|
33
|
+
return void 0;
|
|
34
|
+
}
|
|
35
|
+
function ownerScoped(items, session) {
|
|
36
|
+
if (!session) return items;
|
|
37
|
+
return items.filter((i) => i.scope === "project" || i.session === session);
|
|
38
|
+
}
|
|
39
|
+
const STATUS_MAP = {
|
|
40
|
+
ready: "ready",
|
|
41
|
+
start: "in_progress",
|
|
42
|
+
close: "archived",
|
|
43
|
+
done: "archived",
|
|
44
|
+
reopen: "ready",
|
|
45
|
+
archive: "archived",
|
|
46
|
+
backlog: "ready"
|
|
47
|
+
};
|
|
48
|
+
function issueRpc(cwd, params) {
|
|
49
|
+
const root = resolveProjectRoot(cwd || process.cwd());
|
|
50
|
+
const op = params.op;
|
|
51
|
+
switch (op) {
|
|
52
|
+
case "list": {
|
|
53
|
+
const opts = { includeArchived: params.status === "all" || params.status === "archived" || params.includeArchived };
|
|
54
|
+
if (params.status && params.status !== "all") opts.status = params.status;
|
|
55
|
+
if (params.label) opts.label = params.label;
|
|
56
|
+
if (params.scope) opts.scope = params.scope;
|
|
57
|
+
return ownerScoped(listIssues(root, opts), params.session).map(compact);
|
|
58
|
+
}
|
|
59
|
+
case "show":
|
|
60
|
+
return getIssue(root, String(params.id));
|
|
61
|
+
case "search":
|
|
62
|
+
return ownerScoped(searchIssues(root, String(params.query || "")), params.session).map(compact);
|
|
63
|
+
case "pending": {
|
|
64
|
+
const items = ownerScoped(listIssues(root), params.session).filter((i) => i.status === "ready" || i.status === "in_progress");
|
|
65
|
+
return { pending: items.map((i) => i.id), count: items.length };
|
|
66
|
+
}
|
|
67
|
+
case "add": {
|
|
68
|
+
const owner = params.session || null;
|
|
69
|
+
const scope = params.scope || (owner ? "session" : "project");
|
|
70
|
+
let title = params.title ? String(params.title) : "";
|
|
71
|
+
let body = params.body ? String(params.body) : void 0;
|
|
72
|
+
let original;
|
|
73
|
+
if (!title) {
|
|
74
|
+
const src = (body || "").trim();
|
|
75
|
+
if (!src) throw new Error("issue add: title or body required");
|
|
76
|
+
const nl = src.indexOf("\n");
|
|
77
|
+
title = (nl === -1 ? src : src.slice(0, nl)).trim().slice(0, 200);
|
|
78
|
+
original = src;
|
|
79
|
+
body = void 0;
|
|
80
|
+
}
|
|
81
|
+
return addIssue(root, {
|
|
82
|
+
title,
|
|
83
|
+
status: "ready",
|
|
84
|
+
scope,
|
|
85
|
+
labels: Array.isArray(params.labels) ? params.labels.map(String) : [],
|
|
86
|
+
verify: buildVerify(params) ?? null,
|
|
87
|
+
session: scope === "session" ? owner : null,
|
|
88
|
+
original,
|
|
89
|
+
body
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
case "comment":
|
|
93
|
+
return addComment(root, String(params.id), String(params.text || ""));
|
|
94
|
+
case "status": {
|
|
95
|
+
const status = STATUS_MAP[params.status];
|
|
96
|
+
if (!status) throw new Error(`issue status: unknown status "${params.status}"`);
|
|
97
|
+
const patch = { status };
|
|
98
|
+
if (status === "in_progress" && params.session) {
|
|
99
|
+
const cur = getIssue(root, String(params.id));
|
|
100
|
+
if (cur && cur.scope === "project" && !cur.session) patch.session = params.session;
|
|
101
|
+
}
|
|
102
|
+
const updated = updateIssue(root, String(params.id), patch);
|
|
103
|
+
if (!updated) throw new Error(`Issue not found: ${params.id}`);
|
|
104
|
+
return updated;
|
|
105
|
+
}
|
|
106
|
+
case "work": {
|
|
107
|
+
const patch = { status: "in_progress" };
|
|
108
|
+
if (params.branch) patch.branch = String(params.branch);
|
|
109
|
+
const worker = params.session || null;
|
|
110
|
+
const cur = getIssue(root, String(params.id));
|
|
111
|
+
if (worker && cur && cur.scope === "project" && !cur.session) patch.session = worker;
|
|
112
|
+
const updated = updateIssue(root, String(params.id), patch);
|
|
113
|
+
if (!updated) throw new Error(`Issue not found: ${params.id}`);
|
|
114
|
+
return updated;
|
|
115
|
+
}
|
|
116
|
+
case "edit": {
|
|
117
|
+
const patch = {};
|
|
118
|
+
if (params.title != null) patch.title = String(params.title);
|
|
119
|
+
if (Array.isArray(params.labels)) patch.labels = params.labels.map(String);
|
|
120
|
+
const v = buildVerify(params);
|
|
121
|
+
if (v !== void 0) patch.verify = v;
|
|
122
|
+
if (params.scope) patch.scope = params.scope;
|
|
123
|
+
if (params.unclaim) patch.session = null;
|
|
124
|
+
else if (params.session != null) patch.session = String(params.session);
|
|
125
|
+
if (params.body != null) patch.body = String(params.body);
|
|
126
|
+
if (params.status) patch.status = params.status;
|
|
127
|
+
if (params.disposition) patch.disposition = params.disposition === "crew" ? "crew" : "inline";
|
|
128
|
+
if (params.triaged) patch.triaged = true;
|
|
129
|
+
const updated = updateIssue(root, String(params.id), patch);
|
|
130
|
+
if (!updated) throw new Error(`Issue not found: ${params.id}`);
|
|
131
|
+
return updated;
|
|
132
|
+
}
|
|
133
|
+
case "triage": {
|
|
134
|
+
const patch = { triaged: true };
|
|
135
|
+
if (params.title != null) patch.title = String(params.title);
|
|
136
|
+
if (Array.isArray(params.labels) && params.labels.length) patch.labels = params.labels.map(String);
|
|
137
|
+
if (params.disposition) patch.disposition = params.disposition === "crew" ? "crew" : "inline";
|
|
138
|
+
const v = buildVerify(params);
|
|
139
|
+
if (v) patch.verify = v;
|
|
140
|
+
if (params.body != null) patch.body = String(params.body);
|
|
141
|
+
patch.status = "ready";
|
|
142
|
+
const updated = updateIssue(root, String(params.id), patch);
|
|
143
|
+
if (!updated) throw new Error(`Issue not found: ${params.id}`);
|
|
144
|
+
return updated;
|
|
145
|
+
}
|
|
146
|
+
default:
|
|
147
|
+
throw new Error(`issue rpc: unknown op "${op}"`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export { issueRpc };
|