svamp-cli 0.2.165 → 0.2.166

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svamp-cli",
3
- "version": "0.2.165",
3
+ "version": "0.2.166",
4
4
  "description": "Svamp CLI — AI workspace daemon on Hypha Cloud",
5
5
  "author": "Amun AI AB",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -20,7 +20,7 @@
20
20
  "scripts": {
21
21
  "build": "rm -rf dist bin/skills && mkdir -p bin/skills && cp -r ../../skills/artifact bin/skills/artifact && cp -r ../../skills/loop bin/skills/loop && cp -r ../../skills/crew bin/skills/crew && tsc --noEmit && pkgroll",
22
22
  "typecheck": "tsc --noEmit",
23
- "test": "npx tsx test/test-context-window.mjs && npx tsx test/test-ratelimit-retry.mjs && npx tsx test/test-instance-config.mjs && npx tsx test/test-authorize.mjs && npx tsx test/test-normalize-allowed-user.mjs && npx tsx test/test-share-url.mjs && npx tsx test/test-update-sharing-normalization.mjs && npx tsx test/test-staged-homes-sweep.mjs && npx tsx test/test-session-helpers.mjs && npx tsx test/test-cli-routing.mjs && npx tsx test/test-security-context.mjs && npx tsx test/test-isolation-decision.mjs && npx tsx test/test-loop-activation.mjs && npx tsx test/test-message-helpers.mjs && npx tsx test/test-agent-config.mjs && npx tsx test/test-wrap-command.mjs && npx tsx test/test-credential-staging.mjs && npx tsx test/test-claude-auth.mjs && npx tsx test/test-output-formatters.mjs && npx tsx test/test-inbox-guard.mjs && npx tsx test/test-auto-topic.mjs && npx tsx test/test-project-info.mjs && npx tsx test/test-agent-types.mjs && npx tsx test/test-transport.mjs && npx tsx test/test-session-update-handlers.mjs && npx tsx test/test-session-scanner.mjs && npx tsx test/test-hypha-client.mjs && npx tsx test/test-hook-settings.mjs && npx tsx test/test-session-service-logic.mjs && npx tsx test/test-daemon-persistence.mjs && npx tsx test/test-detect-isolation.mjs && npx tsx test/test-machine-service-logic.mjs && npx tsx test/test-interactive-helpers.mjs && npx tsx test/test-codex-backend.mjs && npx tsx test/test-acp-backend.mjs && npx tsx test/test-acp-bridge.mjs && npx tsx test/test-hook-server.mjs && npx tsx test/test-session-commands.mjs && npx tsx test/test-interactive-console.mjs && npx tsx test/test-session-messages.mjs && npx tsx test/test-session-send-query.mjs && npx tsx test/test-skills.mjs && npx tsx test/test-agent-grouping.mjs && npx tsx test/test-machine-list-directory.mjs && npx tsx test/test-service-commands.mjs && npx tsx test/test-supervisor.mjs && npx tsx test/test-supervisor-lock.mjs && node test/test-supervisor-restart.mjs && npx tsx test/test-clear-detection.mjs && npx tsx test/test-session-consolidation.mjs && npx tsx test/test-inbox.mjs && npx tsx test/test-inbox-cross-machine.mjs && npx tsx test/test-checklist.mjs && npx tsx test/test-checklist-cli.mjs && npx tsx test/test-issue-store.mjs && npx tsx test/test-issue-close-gate.mjs && npx tsx test/test-workflow-store.mjs && npx tsx test/test-serve-link-subdomain.mjs && npx tsx test/test-short-id.mjs && npx tsx test/test-transcript-edit.mjs && npx tsx test/test-edit-history.mjs && npx tsx test/test-friendly-name.mjs && npx tsx test/test-session-rpc-dispatch.mjs && npx tsx test/test-sandbox-cli.mjs && npx tsx test/test-serve-manager.mjs && npx tsx test/test-serve-stability.mjs && npx tsx test/test-frpc-e2e.mjs --unit-only && npx tsx test/test-frpc-status.mjs && node test/pinnedClaudeCode.test.mjs && node test/fleet.test.mjs && npx tsx test/test-routine.mjs && npx tsx test/test-routine-rpc.mjs && npx tsx test/test-checklist-watchdog.mjs && npx tsx test/test-session-file.mjs && npx tsx test/test-channel-rpc.mjs && npx tsx test/test-wise-agent.mjs && npx tsx test/test-channel-agent.mjs && npx tsx test/test-channels-service.mjs && npx tsx test/test-channel-async-reply.mjs && npx tsx test/test-channel-binding.mjs && npx tsx test/test-channel-identity.mjs && npx tsx test/test-shared-session-identity.mjs && npx tsx test/test-wise-agent-auth.mjs && npx tsx test/test-channel-http.mjs && npx tsx test/test-wise-voice.mjs && npx tsx test/test-wise-headless.mjs && npx tsx test/test-wise-machine.mjs && npx tsx test/test-crew-merge.mjs",
23
+ "test": "npx tsx test/test-context-window.mjs && npx tsx test/test-ratelimit-retry.mjs && npx tsx test/test-instance-config.mjs && npx tsx test/test-authorize.mjs && npx tsx test/test-normalize-allowed-user.mjs && npx tsx test/test-share-url.mjs && npx tsx test/test-update-sharing-normalization.mjs && npx tsx test/test-staged-homes-sweep.mjs && npx tsx test/test-session-helpers.mjs && npx tsx test/test-cli-routing.mjs && npx tsx test/test-security-context.mjs && npx tsx test/test-isolation-decision.mjs && npx tsx test/test-loop-activation.mjs && npx tsx test/test-message-helpers.mjs && npx tsx test/test-agent-config.mjs && npx tsx test/test-wrap-command.mjs && npx tsx test/test-credential-staging.mjs && npx tsx test/test-claude-auth.mjs && npx tsx test/test-output-formatters.mjs && npx tsx test/test-inbox-guard.mjs && npx tsx test/test-auto-topic.mjs && npx tsx test/test-project-info.mjs && npx tsx test/test-agent-types.mjs && npx tsx test/test-transport.mjs && npx tsx test/test-session-update-handlers.mjs && npx tsx test/test-session-scanner.mjs && npx tsx test/test-hypha-client.mjs && npx tsx test/test-hook-settings.mjs && npx tsx test/test-session-service-logic.mjs && npx tsx test/test-daemon-persistence.mjs && npx tsx test/test-detect-isolation.mjs && npx tsx test/test-machine-service-logic.mjs && npx tsx test/test-interactive-helpers.mjs && npx tsx test/test-codex-backend.mjs && npx tsx test/test-acp-backend.mjs && npx tsx test/test-acp-bridge.mjs && npx tsx test/test-hook-server.mjs && npx tsx test/test-session-commands.mjs && npx tsx test/test-interactive-console.mjs && npx tsx test/test-session-messages.mjs && npx tsx test/test-session-send-query.mjs && npx tsx test/test-skills.mjs && npx tsx test/test-agent-grouping.mjs && npx tsx test/test-machine-list-directory.mjs && npx tsx test/test-service-commands.mjs && npx tsx test/test-supervisor.mjs && npx tsx test/test-supervisor-lock.mjs && node test/test-supervisor-restart.mjs && npx tsx test/test-clear-detection.mjs && npx tsx test/test-session-consolidation.mjs && npx tsx test/test-inbox.mjs && npx tsx test/test-inbox-cross-machine.mjs && npx tsx test/test-checklist.mjs && npx tsx test/test-checklist-cli.mjs && npx tsx test/test-issue-store.mjs && npx tsx test/test-issue-close-gate.mjs && npx tsx test/test-workflow-store.mjs && npx tsx test/test-serve-link-subdomain.mjs && npx tsx test/test-short-id.mjs && npx tsx test/test-transcript-edit.mjs && npx tsx test/test-edit-history.mjs && npx tsx test/test-friendly-name.mjs && npx tsx test/test-session-rpc-dispatch.mjs && npx tsx test/test-sandbox-cli.mjs && npx tsx test/test-serve-manager.mjs && npx tsx test/test-serve-stability.mjs && npx tsx test/test-frpc-e2e.mjs --unit-only && npx tsx test/test-frpc-status.mjs && node test/pinnedClaudeCode.test.mjs && node test/fleet.test.mjs && npx tsx test/test-routine.mjs && npx tsx test/test-routine-rpc.mjs && npx tsx test/test-checklist-watchdog.mjs && npx tsx test/test-session-file.mjs && npx tsx test/test-channel-rpc.mjs && npx tsx test/test-wise-agent.mjs && npx tsx test/test-channel-agent.mjs && npx tsx test/test-channels-service.mjs && npx tsx test/test-channel-async-reply.mjs && npx tsx test/test-channel-binding.mjs && npx tsx test/test-channel-identity.mjs && npx tsx test/test-shared-session-identity.mjs && npx tsx test/test-wise-agent-auth.mjs && npx tsx test/test-channel-http.mjs && npx tsx test/test-wise-voice.mjs && npx tsx test/test-wise-headless.mjs && npx tsx test/test-wise-machine.mjs && npx tsx test/test-crew-merge.mjs && npx tsx test/test-crew-verdict-routing.mjs",
24
24
  "test:hypha": "node --no-warnings test/test-hypha-service.mjs",
25
25
  "dev": "tsx src/cli.ts",
26
26
  "dev:daemon": "tsx src/cli.ts daemon start-sync",
@@ -1,188 +0,0 @@
1
- import { existsSync, readFileSync, unlinkSync, readdirSync, mkdirSync, writeFileSync, renameSync } from 'node:fs';
2
- import { join, dirname } from 'node:path';
3
- import { execFileSync } from 'node:child_process';
4
-
5
- const FIELD_ORDER = ["id", "title", "status", "scope", "labels", "verify", "disposition", "triaged", "branch", "session", "original", "created", "closed"];
6
- function resolveProjectRoot(start = process.cwd()) {
7
- let dir = start;
8
- for (let i = 0; i < 40; i++) {
9
- if (existsSync(join(dir, ".git")) || existsSync(join(dir, ".svamp"))) return dir;
10
- const parent = dirname(dir);
11
- if (parent === dir) break;
12
- dir = parent;
13
- }
14
- return start;
15
- }
16
- function issuesDir(projectRoot) {
17
- return join(projectRoot, ".svamp", "issues");
18
- }
19
- function archiveDir(projectRoot) {
20
- return join(issuesDir(projectRoot), "archive");
21
- }
22
- function issuePath(projectRoot, id, archived = false) {
23
- return join(archived ? archiveDir(projectRoot) : issuesDir(projectRoot), `${id}.md`);
24
- }
25
- function serializeIssue(issue) {
26
- const lines = ["---"];
27
- for (const k of FIELD_ORDER) {
28
- const v = issue[k];
29
- if (v === void 0) continue;
30
- lines.push(`${k}: ${JSON.stringify(v)}`);
31
- }
32
- lines.push("---", "");
33
- return lines.join("\n") + (issue.body ? issue.body.replace(/\s+$/, "") + "\n" : "");
34
- }
35
- function parseIssue(content) {
36
- const m = content.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
37
- if (!m) return null;
38
- const fm = {};
39
- for (const line of m[1].split("\n")) {
40
- const idx = line.indexOf(": ");
41
- if (idx === -1) continue;
42
- const key = line.slice(0, idx).trim();
43
- const raw = line.slice(idx + 2).trim();
44
- try {
45
- fm[key] = JSON.parse(raw);
46
- } catch {
47
- fm[key] = raw;
48
- }
49
- }
50
- if (!fm.id) return null;
51
- return {
52
- id: String(fm.id),
53
- title: String(fm.title ?? ""),
54
- status: fm.status ?? "backlog",
55
- scope: fm.scope ?? "session",
56
- labels: Array.isArray(fm.labels) ? fm.labels.map(String) : [],
57
- verify: fm.verify ?? null,
58
- disposition: fm.disposition === "crew" ? "crew" : "inline",
59
- triaged: fm.triaged === true,
60
- branch: fm.branch ?? null,
61
- session: fm.session ?? null,
62
- original: fm.original ?? null,
63
- created: String(fm.created ?? (/* @__PURE__ */ new Date()).toISOString()),
64
- closed: fm.closed ?? null,
65
- body: (m[2] || "").trim() || void 0
66
- };
67
- }
68
- function readDir(dir) {
69
- if (!existsSync(dir)) return [];
70
- const out = [];
71
- for (const name of readdirSync(dir)) {
72
- if (!name.endsWith(".md")) continue;
73
- try {
74
- const issue = parseIssue(readFileSync(join(dir, name), "utf-8"));
75
- if (issue) out.push(issue);
76
- } catch {
77
- }
78
- }
79
- return out;
80
- }
81
- function listIssues(projectRoot, opts = {}) {
82
- let items = readDir(issuesDir(projectRoot));
83
- if (opts.includeArchived) items = items.concat(readDir(archiveDir(projectRoot)));
84
- if (opts.status) items = items.filter((i) => i.status === opts.status);
85
- if (opts.label) items = items.filter((i) => i.labels.includes(opts.label));
86
- if (opts.scope) items = items.filter((i) => i.scope === opts.scope);
87
- return items.sort((a, b) => Number(a.id) - Number(b.id));
88
- }
89
- function getIssue(projectRoot, id) {
90
- const padded = /^\d+$/.test(id) ? id.padStart(4, "0") : id;
91
- for (const p of [issuePath(projectRoot, padded), issuePath(projectRoot, padded, true)]) {
92
- if (existsSync(p)) {
93
- try {
94
- return parseIssue(readFileSync(p, "utf-8"));
95
- } catch {
96
- return null;
97
- }
98
- }
99
- }
100
- return null;
101
- }
102
- function atomicWrite(path, content) {
103
- mkdirSync(dirname(path), { recursive: true });
104
- const tmp = `${path}.tmp-${process.pid}`;
105
- writeFileSync(tmp, content);
106
- renameSync(tmp, path);
107
- }
108
- function nextId(projectRoot) {
109
- const all = listIssues(projectRoot, { includeArchived: true });
110
- const max = all.reduce((acc, i) => Math.max(acc, Number(i.id) || 0), 0);
111
- return String(max + 1).padStart(4, "0");
112
- }
113
- function addIssue(projectRoot, fields) {
114
- const issue = {
115
- id: nextId(projectRoot),
116
- title: fields.title.trim(),
117
- status: fields.status ?? "backlog",
118
- scope: fields.scope ?? "session",
119
- labels: fields.labels ?? [],
120
- verify: fields.verify ?? null,
121
- disposition: fields.disposition ?? "inline",
122
- triaged: fields.triaged ?? false,
123
- branch: null,
124
- session: fields.session ?? null,
125
- original: fields.original ?? null,
126
- created: (/* @__PURE__ */ new Date()).toISOString(),
127
- closed: null,
128
- body: fields.body
129
- };
130
- atomicWrite(issuePath(projectRoot, issue.id), serializeIssue(issue));
131
- return issue;
132
- }
133
- function updateIssue(projectRoot, id, patch) {
134
- const cur = getIssue(projectRoot, id);
135
- if (!cur) return null;
136
- const wasArchived = cur.status === "archived";
137
- const next = { ...cur, ...patch, id: cur.id };
138
- const nowArchived = next.status === "archived";
139
- if ((next.status === "done" || nowArchived) && !next.closed) next.closed = (/* @__PURE__ */ new Date()).toISOString();
140
- if (next.status !== "done" && !nowArchived) next.closed = null;
141
- atomicWrite(issuePath(projectRoot, next.id, nowArchived), serializeIssue(next));
142
- if (wasArchived !== nowArchived) {
143
- const oldPath = issuePath(projectRoot, cur.id, wasArchived);
144
- try {
145
- if (existsSync(oldPath)) unlinkSync(oldPath);
146
- } catch {
147
- }
148
- }
149
- return next;
150
- }
151
- function addComment(projectRoot, id, text) {
152
- const cur = getIssue(projectRoot, id);
153
- if (!cur || !text.trim()) return cur;
154
- const entry = `
155
-
156
- ---
157
- **Follow-up \xB7 ${(/* @__PURE__ */ new Date()).toISOString()}**
158
-
159
- ${text.trim()}`;
160
- const body = (cur.body ? cur.body.replace(/\s+$/, "") : "") + entry;
161
- return updateIssue(projectRoot, id, { body });
162
- }
163
- function searchIssues(projectRoot, query) {
164
- const q = query.trim();
165
- if (!q) return [];
166
- try {
167
- const out = execFileSync("rg", ["-l", "-i", "--no-messages", q, issuesDir(projectRoot)], { encoding: "utf-8" });
168
- const files = out.split("\n").filter(Boolean);
169
- const issues = [];
170
- for (const f of files) {
171
- try {
172
- const i = parseIssue(readFileSync(f, "utf-8"));
173
- if (i) issues.push(i);
174
- } catch {
175
- }
176
- }
177
- return issues.sort((a, b) => Number(a.id) - Number(b.id));
178
- } catch {
179
- const ql = q.toLowerCase();
180
- return listIssues(projectRoot, { includeArchived: true }).filter((i) => i.title.toLowerCase().includes(ql) || (i.body || "").toLowerCase().includes(ql) || i.labels.some((l) => l.toLowerCase().includes(ql)));
181
- }
182
- }
183
- function summarize(issues) {
184
- const by = (s) => issues.filter((i) => i.status === s).length;
185
- return { total: issues.length, backlog: by("backlog"), ready: by("ready"), in_progress: by("in_progress"), done: by("done"), archived: by("archived") };
186
- }
187
-
188
- export { addComment as a, summarize as b, addIssue as c, getIssue as g, listIssues as l, resolveProjectRoot as r, searchIssues as s, updateIssue as u };