svamp-cli 0.2.164 → 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/bin/skills/loop/bin/stop-gate.mjs +1 -1
- package/dist/{agentCommands-BQUIj0L3.mjs → agentCommands-0rtN3zaT.mjs} +5 -5
- package/dist/{auth-Nb44v13A.mjs → auth-tsCGoeiF.mjs} +1 -1
- package/dist/cli.mjs +61 -61
- package/dist/{commands-BCr6iO_n.mjs → commands-BLLkJy6f.mjs} +2 -2
- package/dist/{commands-Cc-98Ot6.mjs → commands-BQTA2fC4.mjs} +5 -5
- package/dist/{commands-fyFKlqCv.mjs → commands-BaC0EoLm.mjs} +1 -1
- package/dist/{commands-C8uqsoRM.mjs → commands-D51uPoPK.mjs} +40 -2
- package/dist/{commands-D2Zpi3G8.mjs → commands-DbEd_EMK.mjs} +1 -1
- package/dist/{commands-DVA2p60j.mjs → commands-Df6MbSt-.mjs} +34 -3
- package/dist/{commands-PsObXuzm.mjs → commands-DumGHsHS.mjs} +2 -2
- package/dist/{commands-mAHn_FPb.mjs → commands-l8v1VLPp.mjs} +19 -1
- package/dist/{fleet-BgpaxJ3S.mjs → fleet-Dwk-C37I.mjs} +1 -1
- package/dist/{frpc-BbpARLqP.mjs → frpc-B6KtYbVe.mjs} +1 -1
- package/dist/{headlessCli-BQKqriom.mjs → headlessCli-B7MIr4r2.mjs} +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{package-Dwhojj-r.mjs → package-Cu7Ik_Mk.mjs} +2 -2
- package/dist/{run-Dfj1qf30.mjs → run-D2AdmLLH.mjs} +1 -1
- package/dist/{run-KCqpMQJZ.mjs → run-DEfioSLJ.mjs} +209 -36
- package/dist/{serveCommands-DMfzU2xe.mjs → serveCommands-C_DNG6Z1.mjs} +5 -5
- package/dist/{serveManager-fwaBwmlm.mjs → serveManager-BH7mQRkn.mjs} +2 -2
- package/dist/{sideband-XblR5fr5.mjs → sideband-BuMjm0m2.mjs} +1 -1
- package/package.json +2 -2
- package/dist/store-BQxdRyuI.mjs +0 -188
|
@@ -54,7 +54,7 @@ async function handleServeCommand() {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
async function serveAdd(args, machineId) {
|
|
57
|
-
const { connectAndGetMachine } = await import('./commands-
|
|
57
|
+
const { connectAndGetMachine } = await import('./commands-DbEd_EMK.mjs');
|
|
58
58
|
const pos = positionalArgs(args);
|
|
59
59
|
const name = pos[0];
|
|
60
60
|
if (!name) {
|
|
@@ -93,7 +93,7 @@ async function serveAdd(args, machineId) {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
async function serveApply(args, machineId) {
|
|
96
|
-
const { connectAndGetMachine } = await import('./commands-
|
|
96
|
+
const { connectAndGetMachine } = await import('./commands-DbEd_EMK.mjs');
|
|
97
97
|
const fs = await import('fs');
|
|
98
98
|
const yaml = await import('yaml');
|
|
99
99
|
const file = positionalArgs(args)[0];
|
|
@@ -182,7 +182,7 @@ async function serveApply(args, machineId) {
|
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
async function serveRemove(args, machineId) {
|
|
185
|
-
const { connectAndGetMachine } = await import('./commands-
|
|
185
|
+
const { connectAndGetMachine } = await import('./commands-DbEd_EMK.mjs');
|
|
186
186
|
const pos = positionalArgs(args);
|
|
187
187
|
const name = pos[0];
|
|
188
188
|
if (!name) {
|
|
@@ -202,7 +202,7 @@ async function serveRemove(args, machineId) {
|
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
async function serveList(args, machineId) {
|
|
205
|
-
const { connectAndGetMachine } = await import('./commands-
|
|
205
|
+
const { connectAndGetMachine } = await import('./commands-DbEd_EMK.mjs');
|
|
206
206
|
const all = hasFlag(args, "--all", "-a");
|
|
207
207
|
const json = hasFlag(args, "--json");
|
|
208
208
|
const sessionId = getFlag(args, "--session");
|
|
@@ -235,7 +235,7 @@ async function serveList(args, machineId) {
|
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
async function serveInfo(machineId) {
|
|
238
|
-
const { connectAndGetMachine } = await import('./commands-
|
|
238
|
+
const { connectAndGetMachine } = await import('./commands-DbEd_EMK.mjs');
|
|
239
239
|
const { machine, server } = await connectAndGetMachine(machineId);
|
|
240
240
|
try {
|
|
241
241
|
const info = await machine.serveInfo();
|
|
@@ -4,7 +4,7 @@ import * as fs from 'fs';
|
|
|
4
4
|
import * as http from 'http';
|
|
5
5
|
import * as net from 'net';
|
|
6
6
|
import * as path from 'path';
|
|
7
|
-
import { k as getHyphaServerUrl, S as ServeAuth, l as hasCookieToken } from './run-
|
|
7
|
+
import { k as getHyphaServerUrl, S as ServeAuth, l as hasCookieToken } from './run-DEfioSLJ.mjs';
|
|
8
8
|
import 'os';
|
|
9
9
|
import 'fs/promises';
|
|
10
10
|
import 'url';
|
|
@@ -733,7 +733,7 @@ class ServeManager {
|
|
|
733
733
|
const mount = this.mounts.get(mountName);
|
|
734
734
|
const subdomainOverride = mount?.access === "link" && mount.linkToken ? /* @__PURE__ */ new Map([[this.port, buildLinkSubdomain(subdomainSafe, mount.linkToken)]]) : void 0;
|
|
735
735
|
try {
|
|
736
|
-
const { FrpcTunnel } = await import('./frpc-
|
|
736
|
+
const { FrpcTunnel } = await import('./frpc-B6KtYbVe.mjs');
|
|
737
737
|
let tunnel;
|
|
738
738
|
tunnel = new FrpcTunnel({
|
|
739
739
|
name: tunnelName,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as READ_ONLY_TOOLS,
|
|
1
|
+
import { R as READ_ONLY_TOOLS, H as loadMachineContext, I as buildMachineInstructions, J as machineToolsForRole, K as buildMachineTools } from './run-DEfioSLJ.mjs';
|
|
2
2
|
import 'node:child_process';
|
|
3
3
|
import 'os';
|
|
4
4
|
import 'fs/promises';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svamp-cli",
|
|
3
|
-
"version": "0.2.
|
|
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-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",
|
package/dist/store-BQxdRyuI.mjs
DELETED
|
@@ -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 };
|