spur-board 0.49.0 → 0.51.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.
- package/dist/cli.mjs +103 -17
- package/dist/{client-BSnnpBaD.mjs → client-rSOSGe04.mjs} +17 -2
- package/dist/client.mjs +2 -2
- package/dist/{config-BCrk1xe-.mjs → config-CfWbR2yC.mjs} +2 -2
- package/dist/daemon.mjs +1612 -1257
- package/dist/mcp.mjs +3 -3
- package/dist/{src-CDr8R3sf.mjs → src-B5vMuqoD.mjs} +11 -5
- package/package.json +1 -1
- package/skills/setup/SKILL.md +1 -1
- package/skills/setup/references/update.md +2 -2
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $ as configSchema, H as ERRORS, f as roleCanUseOperation, it as SLACK_BOT_SCOPES, o as SYSTEMD_SERVICE_SETTINGS, p as OPERATIONS, r as requestHashOf, tt as requiredSecretKeys } from "./src-
|
|
2
|
-
import { a as
|
|
3
|
-
import { a as memoryVerdictCache, c as loadClientConfig, d as resolveDaemonAddress, f as tokenInFolder, i as fileVerdictCache, l as loadEnrollmentConfig, n as cliPackageVersion, o as configFile, s as dataDirectory, t as checkCatalog, u as readConfiguredPort } from "./config-
|
|
1
|
+
import { $ as configSchema, H as ERRORS, I as actorIdSchema, f as roleCanUseOperation, it as SLACK_BOT_SCOPES, o as SYSTEMD_SERVICE_SETTINGS, p as OPERATIONS, q as successEnvelopeSchema, r as requestHashOf, tt as requiredSecretKeys } from "./src-B5vMuqoD.mjs";
|
|
2
|
+
import { a as requestTokenEnrollment, c as renderCliError, i as requestSkillReload, l as escapeTerminalControls, n as fetchTokenStatus, o as CliError, r as requestOperation, s as errorExitCode } from "./client-rSOSGe04.mjs";
|
|
3
|
+
import { a as memoryVerdictCache, c as loadClientConfig, d as resolveDaemonAddress, f as tokenInFolder, i as fileVerdictCache, l as loadEnrollmentConfig, n as cliPackageVersion, o as configFile, s as dataDirectory, t as checkCatalog, u as readConfiguredPort } from "./config-CfWbR2yC.mjs";
|
|
4
4
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
5
5
|
import { accessSync, chmodSync, closeSync, constants, cpSync, existsSync, ftruncateSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
|
|
6
6
|
import { homedir, hostname, userInfo } from "node:os";
|
|
@@ -369,6 +369,48 @@ function safeIds(values) {
|
|
|
369
369
|
function listing(ids) {
|
|
370
370
|
return ids.length ? `: ${ids.join(", ")}` : "";
|
|
371
371
|
}
|
|
372
|
+
function sessionCount(ids) {
|
|
373
|
+
return ids.length === 0 ? "sessions" : `${String(ids.length)} session${ids.length === 1 ? "" : "s"}`;
|
|
374
|
+
}
|
|
375
|
+
const reloadRecords = z.object({ sessions: z.array(z.object({
|
|
376
|
+
id: z.string(),
|
|
377
|
+
state: z.enum([
|
|
378
|
+
"delivered",
|
|
379
|
+
"pending",
|
|
380
|
+
"failed"
|
|
381
|
+
]),
|
|
382
|
+
queuedAt: z.string().nullable()
|
|
383
|
+
})) });
|
|
384
|
+
/**
|
|
385
|
+
* The daemon's reload record of each named session for the newest install's version. Ids travel
|
|
386
|
+
* in the body, never the URL. A record queued before that install, as after a rollback to a
|
|
387
|
+
* version installed earlier, does not count; an unreachable daemon yields no records.
|
|
388
|
+
*/
|
|
389
|
+
async function reloadStates(ids, newest, address, ports) {
|
|
390
|
+
const states = /* @__PURE__ */ new Map();
|
|
391
|
+
const sessions = [...new Set(ids.filter((id) => id.length <= 128 && actorIdSchema.safeParse(`agent:project/${id}`).success))].sort().slice(0, 200);
|
|
392
|
+
if (sessions.length === 0) return states;
|
|
393
|
+
try {
|
|
394
|
+
const response = await ports.fetcher(new URL("/v1/skills/reloads", address()), {
|
|
395
|
+
method: "POST",
|
|
396
|
+
headers: { "content-type": "application/json" },
|
|
397
|
+
body: JSON.stringify({
|
|
398
|
+
version: newest.version,
|
|
399
|
+
sessions
|
|
400
|
+
}),
|
|
401
|
+
signal: AbortSignal.timeout(5e3)
|
|
402
|
+
});
|
|
403
|
+
if (response.status !== 200) return states;
|
|
404
|
+
const envelope = successEnvelopeSchema.safeParse(await response.json());
|
|
405
|
+
const parsed = reloadRecords.safeParse(envelope.data?.value);
|
|
406
|
+
if (!parsed.success) return states;
|
|
407
|
+
for (const record of parsed.data.sessions) {
|
|
408
|
+
const queuedAt = record.queuedAt === null ? NaN : Date.parse(record.queuedAt);
|
|
409
|
+
if (record.state !== "failed" && sessions.includes(record.id) && Number.isFinite(queuedAt) && queuedAt >= newest.installedAt) states.set(record.id, record.state);
|
|
410
|
+
}
|
|
411
|
+
} catch {}
|
|
412
|
+
return states;
|
|
413
|
+
}
|
|
372
414
|
const skillLink = ".agents/skills/spur-board";
|
|
373
415
|
const codexVisibilityFix = "Add .agents/skills/spur-board to the Spur project's symlinks in its config and start a new session.";
|
|
374
416
|
const spurProjectList = z.array(z.object({
|
|
@@ -493,14 +535,18 @@ async function runDoctor(options = {}) {
|
|
|
493
535
|
checks.push(oldSessions.length > 0 ? warning("sessions.codex_skill", `Start new Spur sessions to replace Codex sessions created before the skill link${listing(safeIds([...new Set(oldSessions.map((session) => session.id))]))}; Spur links .agents/skills/spur-board only into new worktrees.`) : result("sessions.codex_skill", true, "Start new Spur sessions."));
|
|
494
536
|
const version = ports.productVersion();
|
|
495
537
|
const stamps = [".claude", ".codex"].flatMap((agent) => ["spur-board", "spur-board-setup"].map((skill) => stamp(ports, join(home, agent, "skills", skill, ".spur-board-install.json"))));
|
|
496
|
-
const
|
|
538
|
+
const newest = stamps.reduce((latest, entry) => entry !== null && (latest === null || entry.installedAt > latest.installedAt) ? entry : latest, null);
|
|
539
|
+
const latestInstall = newest?.installedAt ?? -Infinity;
|
|
497
540
|
const connected = sessions.filter((session) => session.project !== void 0 && configured.has(session.project));
|
|
498
|
-
const
|
|
499
|
-
const
|
|
500
|
-
const
|
|
501
|
-
const
|
|
502
|
-
const
|
|
503
|
-
|
|
541
|
+
const staleSessions = [...new Set(connected.filter((session) => session.startAt !== void 0 && session.startAt < latestInstall).map((session) => session.id))];
|
|
542
|
+
const undatedSessions = [...new Set(connected.filter((session) => session.startAt === void 0).map((session) => session.id))];
|
|
543
|
+
const listed = [.../* @__PURE__ */ new Set([...staleSessions, ...undatedSessions])];
|
|
544
|
+
const reloads = newest === null ? /* @__PURE__ */ new Map() : await reloadStates(listed, newest, () => resolveDaemonAddress(env, home, config.http.port), ports);
|
|
545
|
+
const unreached = staleSessions.filter((id) => reloads.get(id) === void 0);
|
|
546
|
+
const unknownStarts = undatedSessions.some((id) => reloads.get(id) === void 0);
|
|
547
|
+
const pending = listed.filter((id) => reloads.get(id) === "pending");
|
|
548
|
+
const forVersion = newest === null ? "" : ` for ${newest.version}`;
|
|
549
|
+
checks.push(unreached.length > 0 || unknownStarts || pending.length > 0 ? warning("sessions.stale", [...unreached.length > 0 || unknownStarts ? [`Stop and wake ${sessionCount(unreached)} started before the last skill install that have no delivered reload message${forVersion}${listing(safeIds(unreached))}; stopping and waking restarts the agent and keeps the conversation. A session can instead read the spur-board skill file again: ~/.claude/skills/spur-board/SKILL.md for Claude Code, ~/.codex/skills/spur-board/SKILL.md for Codex ($CODEX_HOME/skills/spur-board/SKILL.md when set); doctor keeps listing it after that.${unknownStarts ? " Do the same for connected sessions whose start time is unavailable." : ""}`] : [], ...pending.length > 0 ? [`The board's reload message${forVersion} is still queued for ${sessionCount(pending)}${listing(safeIds(pending))}; rerun board doctor in a minute.`] : []].join(" ")) : result("sessions.stale", true, "Ask older sessions to re-read the spur-board skill."));
|
|
504
550
|
const portFix = await checkHttpPort(config.http.port, {
|
|
505
551
|
bind: ports.bind,
|
|
506
552
|
run: (command, args) => Promise.resolve(ports.run(command, args))
|
|
@@ -771,6 +817,34 @@ async function uninstallService(options = {}) {
|
|
|
771
817
|
return { changed: true };
|
|
772
818
|
}
|
|
773
819
|
//#endregion
|
|
820
|
+
//#region src/skill-reload.ts
|
|
821
|
+
function reasonOf(error) {
|
|
822
|
+
return escapeTerminalControls(error instanceof CliError ? error.hint ?? ERRORS[error.code].message : error instanceof Error ? error.message : "unexpected error").replace(/\.$/, "");
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* Asks the daemon to message running sessions about a new skill version. It never throws: the
|
|
826
|
+
* install has already succeeded, and `board doctor` still lists the sessions that were not told.
|
|
827
|
+
*/
|
|
828
|
+
async function askSessionsToReload(options) {
|
|
829
|
+
const { env, home, version, stderr } = options;
|
|
830
|
+
if (env["BOARD_DAEMON_URL"] === void 0) {
|
|
831
|
+
const port = readConfiguredPort(env, home);
|
|
832
|
+
if (port === void 0 || port === 0) return;
|
|
833
|
+
}
|
|
834
|
+
try {
|
|
835
|
+
const { queued } = await requestSkillReload(version, {
|
|
836
|
+
address: resolveDaemonAddress(env, home),
|
|
837
|
+
session: void 0,
|
|
838
|
+
token: void 0,
|
|
839
|
+
connectTimeoutMs: 2e3,
|
|
840
|
+
responseTimeoutMs: 1e4
|
|
841
|
+
});
|
|
842
|
+
if (queued > 0) stderr(`Asked ${String(queued)} running session(s) to re-read the spur-board skill.\n`);
|
|
843
|
+
} catch (error) {
|
|
844
|
+
stderr(`Running sessions were not asked to re-read the spur-board skill: ${reasonOf(error)}. \`board doctor\` lists them under sessions.stale.\n`);
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
//#endregion
|
|
774
848
|
//#region src/skills.ts
|
|
775
849
|
const stampName = ".spur-board-install.json";
|
|
776
850
|
const installId = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
@@ -782,8 +856,12 @@ const skills = [{
|
|
|
782
856
|
name: "spur-board-setup"
|
|
783
857
|
}];
|
|
784
858
|
const agents = [".claude", ".codex"];
|
|
785
|
-
|
|
786
|
-
|
|
859
|
+
function bundledRoot(packageRoot) {
|
|
860
|
+
return resolve(packageRoot ?? fileURLToPath(new URL("../", import.meta.url)));
|
|
861
|
+
}
|
|
862
|
+
/** The spur-board version whose skills `installSkills` copies from `packageRoot`. */
|
|
863
|
+
async function bundledSkillVersion(packageRoot) {
|
|
864
|
+
const manifest = JSON.parse(await readFile(join(bundledRoot(packageRoot), "package.json"), "utf8"));
|
|
787
865
|
if (typeof manifest.version !== "string" || !manifest.version) throw new Error("The spur-board package has no version.");
|
|
788
866
|
return manifest.version;
|
|
789
867
|
}
|
|
@@ -1027,10 +1105,10 @@ async function installIntoHome(home, packageRoot, version, options, env) {
|
|
|
1027
1105
|
return results;
|
|
1028
1106
|
}
|
|
1029
1107
|
async function installSkills(options = {}) {
|
|
1030
|
-
const packageRoot =
|
|
1108
|
+
const packageRoot = bundledRoot(options.packageRoot);
|
|
1031
1109
|
const home = await realpath(resolve(options.home ?? homedir()));
|
|
1032
1110
|
const env = options.env ?? process.env;
|
|
1033
|
-
const version = await
|
|
1111
|
+
const version = await bundledSkillVersion(packageRoot);
|
|
1034
1112
|
await Promise.all(skills.map((skill) => requireSource(join(packageRoot, "skills", skill.source))));
|
|
1035
1113
|
return withInstallLock(home, env, () => installIntoHome(home, packageRoot, version, options, env));
|
|
1036
1114
|
}
|
|
@@ -2127,11 +2205,19 @@ function registerSetupCommands(program, options, io, env) {
|
|
|
2127
2205
|
io.stdout(`${renderDoctor(checks, json)}\n`);
|
|
2128
2206
|
if (checks.some((check) => check.blocking)) throw new CommanderError(1, "board.error", "Doctor found blocking failures.");
|
|
2129
2207
|
});
|
|
2130
|
-
commandFor(program, "skills install").description("Install bundled skills for Claude Code and Codex.").action(async () => {
|
|
2131
|
-
|
|
2208
|
+
commandFor(program, "skills install").description("Install bundled skills for Claude Code and Codex, and ask running sessions to re-read them after a version change.").action(async () => {
|
|
2209
|
+
const results = await runSetup(() => installSkills({
|
|
2132
2210
|
...options.setup,
|
|
2133
2211
|
env
|
|
2134
|
-
}))
|
|
2212
|
+
}));
|
|
2213
|
+
print(results);
|
|
2214
|
+
if (!results.some((entry) => entry.changed)) return;
|
|
2215
|
+
await askSessionsToReload({
|
|
2216
|
+
env,
|
|
2217
|
+
home: options.setup?.home ?? options.home ?? homedir(),
|
|
2218
|
+
version: await bundledSkillVersion(options.setup?.packageRoot),
|
|
2219
|
+
stderr: io.stderr
|
|
2220
|
+
});
|
|
2135
2221
|
});
|
|
2136
2222
|
commandFor(program, "service install").description("Install and start the systemd user service.").action(async () => {
|
|
2137
2223
|
print(await runSetup(() => installService(serviceOptions)));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { G as errorEnvelopeSchema, H as ERRORS, W as errorContextSchema, g as renderJsonError, q as successEnvelopeSchema } from "./src-
|
|
1
|
+
import { G as errorEnvelopeSchema, H as ERRORS, W as errorContextSchema, g as renderJsonError, q as successEnvelopeSchema } from "./src-B5vMuqoD.mjs";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { request } from "node:http";
|
|
@@ -230,5 +230,20 @@ function fetchTokenStatus(hash, config) {
|
|
|
230
230
|
decode: (response, raw) => decodeResponse(tokenStatusOutput, response, raw)
|
|
231
231
|
});
|
|
232
232
|
}
|
|
233
|
+
const skillReloadOutput = z.strictObject({
|
|
234
|
+
version: z.string(),
|
|
235
|
+
queued: z.int().min(0)
|
|
236
|
+
});
|
|
237
|
+
/** Asks the daemon to message live sessions about `version`; sends no identity header. */
|
|
238
|
+
function requestSkillReload(version, config) {
|
|
239
|
+
return send({
|
|
240
|
+
method: "POST",
|
|
241
|
+
path: "/v1/skills/reload",
|
|
242
|
+
body: { version },
|
|
243
|
+
config,
|
|
244
|
+
anonymous: true,
|
|
245
|
+
decode: (response, raw) => decodeResponse(skillReloadOutput, response, raw)
|
|
246
|
+
});
|
|
247
|
+
}
|
|
233
248
|
//#endregion
|
|
234
|
-
export {
|
|
249
|
+
export { requestTokenEnrollment as a, renderCliError as c, requestSkillReload as i, escapeTerminalControls as l, fetchTokenStatus as n, CliError as o, requestOperation as r, errorExitCode as s, fetchCatalogVersion as t };
|
package/dist/client.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { fetchCatalogVersion, fetchTokenStatus, requestOperation, requestTokenEnrollment };
|
|
1
|
+
import { a as requestTokenEnrollment, i as requestSkillReload, n as fetchTokenStatus, r as requestOperation, t as fetchCatalogVersion } from "./client-rSOSGe04.mjs";
|
|
2
|
+
export { fetchCatalogVersion, fetchTokenStatus, requestOperation, requestSkillReload, requestTokenEnrollment };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $ as configSchema, d as buildCatalogSnapshot, et as plainHttpAllowed, p as OPERATIONS } from "./src-
|
|
2
|
-
import {
|
|
1
|
+
import { $ as configSchema, d as buildCatalogSnapshot, et as plainHttpAllowed, p as OPERATIONS } from "./src-B5vMuqoD.mjs";
|
|
2
|
+
import { o as CliError, t as fetchCatalogVersion } from "./client-rSOSGe04.mjs";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import { closeSync, constants, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, realpathSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { homedir } from "node:os";
|