spur-board 0.44.0 → 0.44.2
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 +5 -4
- package/dist/daemon.mjs +293 -64
- 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
|
@@ -493,12 +493,13 @@ async function runDoctor(options = {}) {
|
|
|
493
493
|
const version = ports.productVersion();
|
|
494
494
|
const stamps = [".claude", ".codex"].flatMap((agent) => ["spur-board", "spur-board-setup"].map((skill) => stamp(ports, join(home, agent, "skills", skill, ".spur-board-install.json"))));
|
|
495
495
|
const latestInstall = Math.max(...stamps.flatMap((entry) => entry === null ? [] : [entry.installedAt]));
|
|
496
|
-
const
|
|
497
|
-
const
|
|
496
|
+
const connected = sessions.filter((session) => session.project !== void 0 && configured.has(session.project));
|
|
497
|
+
const stale = connected.filter((session) => session.startAt !== void 0 && session.startAt < latestInstall);
|
|
498
|
+
const unknownStarts = connected.some((session) => session.startAt === void 0);
|
|
498
499
|
const staleSessions = [...new Set(stale.map((session) => session.id))];
|
|
499
500
|
const staleIds = safeIds(staleSessions);
|
|
500
501
|
const staleCount = staleSessions.length === 0 ? "sessions" : `${String(staleSessions.length)} session${staleSessions.length === 1 ? "" : "s"}`;
|
|
501
|
-
checks.push(stale.length > 0 || unknownStarts ? warning("sessions.stale", `
|
|
502
|
+
checks.push(stale.length > 0 || unknownStarts ? warning("sessions.stale", `Ask ${staleCount} started before the last skill install to re-read the spur-board skill (SKILL.md and references/)${listing(staleIds)}. Claude Code reads it from ~/.claude/skills/spur-board, Codex from ~/.codex/skills/spur-board ($CODEX_HOME/skills/spur-board when set). No restart is needed; doctor keeps listing a session after it re-reads.${unknownStarts ? " Ask connected sessions whose start time is unavailable to re-read it too." : ""}`) : result("sessions.stale", true, "Ask older sessions to re-read the spur-board skill."));
|
|
502
503
|
const portFix = await checkHttpPort(config.http.port, {
|
|
503
504
|
bind: ports.bind,
|
|
504
505
|
run: (command, args) => Promise.resolve(ports.run(command, args))
|
|
@@ -1860,7 +1861,7 @@ async function update(updater, options, requested) {
|
|
|
1860
1861
|
}
|
|
1861
1862
|
updater.finish(state, "succeeded", null);
|
|
1862
1863
|
const stale = report.find((check) => check.id === "sessions.stale");
|
|
1863
|
-
const operator = [MCP_LINE, ...stale?.status === "warning" && stale.fix !== null ? [
|
|
1864
|
+
const operator = [MCP_LINE, ...stale?.status === "warning" && stale.fix !== null ? [stale.fix] : []];
|
|
1864
1865
|
return {
|
|
1865
1866
|
from,
|
|
1866
1867
|
to,
|
package/dist/daemon.mjs
CHANGED
|
@@ -16509,14 +16509,18 @@ const prFields = (number, closing = false) => `id number url title updatedAt mer
|
|
|
16509
16509
|
reviewThreads(first: 100) { nodes { isResolved } pageInfo { hasNextPage endCursor } }
|
|
16510
16510
|
reviewRequests(first: 100) { nodes { ${REVIEWER_FIELDS} } pageInfo { hasNextPage endCursor } }${closing ? `\n closingIssuesReferences(first: 100) { ${CLOSING_FIELDS} }` : ""}`;
|
|
16511
16511
|
const DISCOVERY_FIELDS = `nodes { number updatedAt author { login } state } pageInfo { hasNextPage endCursor }`;
|
|
16512
|
-
|
|
16513
|
-
|
|
16512
|
+
const INDEX_FIELDS = `number updatedAt state isDraft mergeable mergeStateStatus headRefOid statusCheckRollup { state contexts(first: 100) { totalCount nodes { ... on CheckRun { __typename name status conclusion completedAt } ... on StatusContext { __typename context state } } } } reviews(first: 100) { totalCount nodes { id state } } reviewThreads(first: 100) { totalCount nodes { isResolved } } reviewRequests(first: 100) { totalCount nodes { ${REVIEWER_FIELDS} } } comments(last: 1) { totalCount nodes { id } }`;
|
|
16513
|
+
function aliases(numbers, fields) {
|
|
16514
|
+
return numbers.map((number, i) => `pr${String(i)}: repository(owner: $owner, name: $repo) { pullRequest(number: ${String(number)}) { ${fields(number)} } }`).join("\n");
|
|
16514
16515
|
}
|
|
16515
|
-
function
|
|
16516
|
-
return `query PrBatch($owner: String!, $repo: String!) { rateLimit { remaining resetAt } repository(owner: $owner, name: $repo) { pullRequests(first: 100, states: [${bootstrap ? "OPEN" : "OPEN, MERGED"}], orderBy: {field: UPDATED_AT, direction: DESC}) { ${DISCOVERY_FIELDS} }${bootstrap ? " mergedBaseline: pullRequests(first: 1, states: [MERGED], orderBy: {field: UPDATED_AT, direction: DESC}) { nodes { updatedAt } }" : ""} }
|
|
16516
|
+
function discoveryQuery(bootstrap = false) {
|
|
16517
|
+
return `query PrBatch($owner: String!, $repo: String!) { rateLimit { remaining resetAt } repository(owner: $owner, name: $repo) { pullRequests(first: 100, states: [${bootstrap ? "OPEN" : "OPEN, MERGED"}], orderBy: {field: UPDATED_AT, direction: DESC}) { ${DISCOVERY_FIELDS} }${bootstrap ? " mergedBaseline: pullRequests(first: 1, states: [MERGED], orderBy: {field: UPDATED_AT, direction: DESC}) { nodes { updatedAt } }" : ""} } }`;
|
|
16518
|
+
}
|
|
16519
|
+
function indexQuery(numbers) {
|
|
16520
|
+
return `query PrIndex($owner: String!, $repo: String!) { rateLimit { remaining resetAt } ${aliases(numbers, () => INDEX_FIELDS)} }`;
|
|
16517
16521
|
}
|
|
16518
16522
|
function detailQuery(numbers, closing = false) {
|
|
16519
|
-
return `query PrDetails($owner: String!, $repo: String!) { rateLimit { remaining resetAt } ${aliases(numbers, closing)} }`;
|
|
16523
|
+
return `query PrDetails($owner: String!, $repo: String!) { rateLimit { remaining resetAt } ${aliases(numbers, (number) => prFields(number, closing))} }`;
|
|
16520
16524
|
}
|
|
16521
16525
|
function pageQuery(connection, bootstrap = false) {
|
|
16522
16526
|
if (connection === "comments") return `query PrPage($owner: String!, $repo: String!, $number: Int!, $before: String!) { rateLimit { remaining resetAt } repository(owner: $owner, name: $repo) { pullRequest(number: $number) { comments(last: 100, before: $before) { ${COMMENT_FIELDS} } } } }`;
|
|
@@ -16981,6 +16985,75 @@ function normalizePr(repo, value, rule, feedbackComplete) {
|
|
|
16981
16985
|
if (!parsed.success) throw new AdapterError("transient", "Malformed GitHub PR facts", { cause: parsed.error });
|
|
16982
16986
|
return parsed.data;
|
|
16983
16987
|
}
|
|
16988
|
+
const counted = (node) => z.object({
|
|
16989
|
+
totalCount: z.int().nonnegative(),
|
|
16990
|
+
nodes: z.array(node)
|
|
16991
|
+
});
|
|
16992
|
+
const indexAliasWire = z.object({ pullRequest: z.object({
|
|
16993
|
+
number: z.int().positive(),
|
|
16994
|
+
updatedAt: z.string(),
|
|
16995
|
+
state: z.string(),
|
|
16996
|
+
isDraft: z.boolean(),
|
|
16997
|
+
mergeable: z.string(),
|
|
16998
|
+
mergeStateStatus: z.string(),
|
|
16999
|
+
headRefOid: z.string(),
|
|
17000
|
+
statusCheckRollup: z.object({
|
|
17001
|
+
state: z.string(),
|
|
17002
|
+
contexts: counted(z.union([z.object({
|
|
17003
|
+
__typename: z.literal("CheckRun"),
|
|
17004
|
+
name: z.string(),
|
|
17005
|
+
status: z.string(),
|
|
17006
|
+
conclusion: z.string().nullable(),
|
|
17007
|
+
completedAt: z.string().nullable()
|
|
17008
|
+
}), z.object({
|
|
17009
|
+
__typename: z.literal("StatusContext"),
|
|
17010
|
+
context: z.string(),
|
|
17011
|
+
state: z.string()
|
|
17012
|
+
})]))
|
|
17013
|
+
}).nullable(),
|
|
17014
|
+
reviews: counted(z.object({
|
|
17015
|
+
id: z.string(),
|
|
17016
|
+
state: z.string()
|
|
17017
|
+
})),
|
|
17018
|
+
reviewThreads: counted(z.object({ isResolved: z.boolean() })),
|
|
17019
|
+
reviewRequests: counted(z.object({
|
|
17020
|
+
requestedReviewer: z.object({
|
|
17021
|
+
__typename: z.string(),
|
|
17022
|
+
login: z.string().optional(),
|
|
17023
|
+
slug: z.string().optional()
|
|
17024
|
+
}).nullable(),
|
|
17025
|
+
asCodeOwner: z.boolean()
|
|
17026
|
+
})),
|
|
17027
|
+
comments: counted(z.object({ id: z.string() }))
|
|
17028
|
+
}) });
|
|
17029
|
+
/** Reads one index alias; a shape that does not parse means the PR is read in full. */
|
|
17030
|
+
function indexEntry(alias) {
|
|
17031
|
+
const parsed = indexAliasWire.safeParse(alias);
|
|
17032
|
+
if (!parsed.success) return void 0;
|
|
17033
|
+
const pr = parsed.data.pullRequest;
|
|
17034
|
+
const whole = (conn) => conn.nodes.length >= conn.totalCount;
|
|
17035
|
+
return {
|
|
17036
|
+
fingerprint: JSON.stringify(pr),
|
|
17037
|
+
open: pr.state !== "MERGED" && pr.state !== "CLOSED",
|
|
17038
|
+
rollup: pr.statusCheckRollup?.state ?? null,
|
|
17039
|
+
green: (pr.statusCheckRollup?.contexts.nodes ?? []).every((node) => node.__typename === "StatusContext" ? node.state === "SUCCESS" : node.status === "COMPLETED" && (node.conclusion === "SUCCESS" || node.conclusion === "NEUTRAL")),
|
|
17040
|
+
complete: (pr.statusCheckRollup === null || whole(pr.statusCheckRollup.contexts)) && whole(pr.reviews) && whole(pr.reviewThreads) && whole(pr.reviewRequests)
|
|
17041
|
+
};
|
|
17042
|
+
}
|
|
17043
|
+
/**
|
|
17044
|
+
* The cached facts when the index shows the PR unchanged since its last full read and lists
|
|
17045
|
+
* every check, review, review thread and review request. An open PR is reused only with no
|
|
17046
|
+
* rollup or a `SUCCESS` one and every listed check green: a rollup that stays failed or pending
|
|
17047
|
+
* can hide a check that finished since, and a skipped check can turn required unseen.
|
|
17048
|
+
*/
|
|
17049
|
+
function reusable(cached, entry, cursorKey, now) {
|
|
17050
|
+
if (cached === void 0 || entry === void 0) return void 0;
|
|
17051
|
+
if (cached.fingerprint !== entry.fingerprint || cached.cursorKey !== cursorKey) return void 0;
|
|
17052
|
+
if (!cached.facts.feedbackComplete || !entry.complete) return void 0;
|
|
17053
|
+
if (now - cached.readAt >= (entry.open ? 9e5 : 216e5)) return void 0;
|
|
17054
|
+
if (entry.open && (entry.rollup !== null && entry.rollup !== "SUCCESS" || !entry.green)) return;
|
|
17055
|
+
return cached.facts;
|
|
17056
|
+
}
|
|
16984
17057
|
//#endregion
|
|
16985
17058
|
//#region ../adapters/src/github/index.ts
|
|
16986
17059
|
const MALFORMED$2 = "Malformed GitHub response";
|
|
@@ -17006,6 +17079,9 @@ const aliasWire = z.object({ pullRequest: prPagingWire.nullish() }).nullish();
|
|
|
17006
17079
|
const pageRootWire = z.object({ pullRequest: prPagingWire.partial() });
|
|
17007
17080
|
const commentsRootWire = z.object({ pullRequest: z.object({ comments: backPagingWire }) });
|
|
17008
17081
|
const FEEDBACK_PAGES = 3;
|
|
17082
|
+
const INDEX_CHUNK = 50;
|
|
17083
|
+
const DETAIL_CHUNK = 10;
|
|
17084
|
+
const MAX_FAILED_REQUESTS = 8;
|
|
17009
17085
|
function sourceId(project, repo) {
|
|
17010
17086
|
return `github:${project}:${repo.toLowerCase()}`;
|
|
17011
17087
|
}
|
|
@@ -17020,6 +17096,7 @@ function githubSources(config, options) {
|
|
|
17020
17096
|
const id = sourceId(project.id, repo);
|
|
17021
17097
|
const client = new GithubClient(options.token, options.now, options.fetch);
|
|
17022
17098
|
const keys = projectKeyRule(project.tracker, project.link, repo);
|
|
17099
|
+
const cache = /* @__PURE__ */ new Map();
|
|
17023
17100
|
sources.push({
|
|
17024
17101
|
repo,
|
|
17025
17102
|
reserveRemaining: config.github.reserveRemaining,
|
|
@@ -17033,7 +17110,9 @@ function githubSources(config, options) {
|
|
|
17033
17110
|
keys,
|
|
17034
17111
|
client,
|
|
17035
17112
|
now: options.now,
|
|
17036
|
-
ctx
|
|
17113
|
+
ctx,
|
|
17114
|
+
reserveRemaining: config.github.reserveRemaining,
|
|
17115
|
+
cache
|
|
17037
17116
|
}),
|
|
17038
17117
|
pollPr: (ref, ctx) => pollOnePr({
|
|
17039
17118
|
id,
|
|
@@ -17042,7 +17121,8 @@ function githubSources(config, options) {
|
|
|
17042
17121
|
client,
|
|
17043
17122
|
now: options.now,
|
|
17044
17123
|
ref,
|
|
17045
|
-
signal: ctx.signal
|
|
17124
|
+
signal: ctx.signal,
|
|
17125
|
+
cache
|
|
17046
17126
|
})
|
|
17047
17127
|
}
|
|
17048
17128
|
});
|
|
@@ -17059,8 +17139,11 @@ function checkAccessDenied(errors) {
|
|
|
17059
17139
|
function requireCheckAccess(errors) {
|
|
17060
17140
|
if (checkAccessDenied(errors)) throw new AdapterError("auth", "GitHub token lacks Checks read permission");
|
|
17061
17141
|
}
|
|
17142
|
+
function unscoped(errors, roots) {
|
|
17143
|
+
return errors.some((error) => error.path === void 0 || !roots.includes(String(error.path[0])));
|
|
17144
|
+
}
|
|
17062
17145
|
function rejectUnscoped(errors, roots) {
|
|
17063
|
-
if (errors
|
|
17146
|
+
if (unscoped(errors, roots)) throw new AdapterError("transient", "Unscoped GitHub GraphQL error");
|
|
17064
17147
|
}
|
|
17065
17148
|
function status(error) {
|
|
17066
17149
|
return error.type === "NOT_FOUND" ? "not_found" : "no_access";
|
|
@@ -17219,7 +17302,6 @@ function malformed(acc, error, ref) {
|
|
|
17219
17302
|
});
|
|
17220
17303
|
acc.parseFailedRefs += 1;
|
|
17221
17304
|
}
|
|
17222
|
-
return false;
|
|
17223
17305
|
}
|
|
17224
17306
|
async function processPr(scope, acc, number, alias, data, scopedErrors, ref) {
|
|
17225
17307
|
const errors = withoutDeniedReferences(scopedErrors);
|
|
@@ -17232,10 +17314,13 @@ async function processPr(scope, acc, number, alias, data, scopedErrors, ref) {
|
|
|
17232
17314
|
ref,
|
|
17233
17315
|
status: direct ? status(error) : "no_access"
|
|
17234
17316
|
});
|
|
17235
|
-
return
|
|
17317
|
+
return;
|
|
17236
17318
|
}
|
|
17237
17319
|
const root = content(() => parseWire(aliasWire, data[alias], MALFORMED$2, ["data", alias]));
|
|
17238
|
-
if (root instanceof AdapterError)
|
|
17320
|
+
if (root instanceof AdapterError) {
|
|
17321
|
+
malformed(acc, root, ref);
|
|
17322
|
+
return;
|
|
17323
|
+
}
|
|
17239
17324
|
const wire = root?.pullRequest;
|
|
17240
17325
|
if (wire === null || wire === void 0) {
|
|
17241
17326
|
if (ref) acc.entities.push({
|
|
@@ -17243,7 +17328,7 @@ async function processPr(scope, acc, number, alias, data, scopedErrors, ref) {
|
|
|
17243
17328
|
status: "not_found"
|
|
17244
17329
|
});
|
|
17245
17330
|
else acc.complete = false;
|
|
17246
|
-
return
|
|
17331
|
+
return;
|
|
17247
17332
|
}
|
|
17248
17333
|
const report = (next) => {
|
|
17249
17334
|
acc.budget = next;
|
|
@@ -17255,10 +17340,13 @@ async function processPr(scope, acc, number, alias, data, scopedErrors, ref) {
|
|
|
17255
17340
|
ref,
|
|
17256
17341
|
status: "no_access"
|
|
17257
17342
|
});
|
|
17258
|
-
return
|
|
17343
|
+
return;
|
|
17259
17344
|
}
|
|
17260
|
-
if (full.status === "malformed")
|
|
17261
|
-
|
|
17345
|
+
if (full.status === "malformed") {
|
|
17346
|
+
malformed(acc, full.error, ref);
|
|
17347
|
+
return;
|
|
17348
|
+
}
|
|
17349
|
+
const cursor = feedbackCursor(scope.feedbackCursors, scope.repo, number);
|
|
17262
17350
|
const feedback = await readFeedback(scope.client, full.pr.comments, scope.owner, scope.name, number, cursor, scope.signal, report);
|
|
17263
17351
|
const pr = {
|
|
17264
17352
|
...full.pr,
|
|
@@ -17268,7 +17356,10 @@ async function processPr(scope, acc, number, alias, data, scopedErrors, ref) {
|
|
|
17268
17356
|
}
|
|
17269
17357
|
};
|
|
17270
17358
|
const facts = content(() => normalizePr(ref?.repo ?? scope.repo, pr, scope.keys, feedback.complete));
|
|
17271
|
-
if (facts instanceof AdapterError)
|
|
17359
|
+
if (facts instanceof AdapterError) {
|
|
17360
|
+
malformed(acc, facts, ref);
|
|
17361
|
+
return;
|
|
17362
|
+
}
|
|
17272
17363
|
acc.items.push({
|
|
17273
17364
|
kind: "pr",
|
|
17274
17365
|
facts
|
|
@@ -17277,7 +17368,10 @@ async function processPr(scope, acc, number, alias, data, scopedErrors, ref) {
|
|
|
17277
17368
|
ref,
|
|
17278
17369
|
status: "ok"
|
|
17279
17370
|
});
|
|
17280
|
-
return
|
|
17371
|
+
return facts;
|
|
17372
|
+
}
|
|
17373
|
+
function feedbackCursor(cursors, repo, number) {
|
|
17374
|
+
return cursors?.find((entry) => entry.ref.number === number && entry.ref.repo.toLowerCase() === repo.toLowerCase());
|
|
17281
17375
|
}
|
|
17282
17376
|
function closingSelected(keys) {
|
|
17283
17377
|
return keys.type === "issues" && keys.sources.includes("closing");
|
|
@@ -17285,48 +17379,156 @@ function closingSelected(keys) {
|
|
|
17285
17379
|
function rethrowLoneParseFailure(acc) {
|
|
17286
17380
|
if (acc.parseError !== void 0 && acc.items.length === 0 && acc.entities.length === acc.parseFailedRefs) throw acc.parseError;
|
|
17287
17381
|
}
|
|
17288
|
-
|
|
17289
|
-
|
|
17382
|
+
/**
|
|
17383
|
+
* Sends one request. A transient failure (5xx, a cut-off body, a timeout) is counted and returns
|
|
17384
|
+
* undefined; an abort, `throttled`, `auth`, `config` or any other error rejects the poll.
|
|
17385
|
+
*/
|
|
17386
|
+
async function attempt(scope, query, variables = {}) {
|
|
17387
|
+
const { requests, signal } = scope;
|
|
17388
|
+
const aborted = () => signal.aborted;
|
|
17389
|
+
if (aborted()) throw new AdapterError("transient", "GitHub poll aborted");
|
|
17390
|
+
try {
|
|
17391
|
+
const response = await scope.client.query(query, {
|
|
17392
|
+
owner: scope.owner,
|
|
17393
|
+
repo: scope.name,
|
|
17394
|
+
...variables
|
|
17395
|
+
}, signal);
|
|
17396
|
+
requests.succeeded += 1;
|
|
17397
|
+
return response;
|
|
17398
|
+
} catch (error) {
|
|
17399
|
+
if (aborted() || !(error instanceof AdapterError) || error.kind !== "transient") throw error;
|
|
17400
|
+
requests.failed += 1;
|
|
17401
|
+
requests.firstError ??= error;
|
|
17402
|
+
return;
|
|
17403
|
+
}
|
|
17404
|
+
}
|
|
17405
|
+
/**
|
|
17406
|
+
* Sends one chunk of aliases. A transient failure resends the chunk as two halves, depth first,
|
|
17407
|
+
* down to one PR; once the poll has `MAX_FAILED_REQUESTS` failures nothing more is sent.
|
|
17408
|
+
*/
|
|
17409
|
+
async function sendChunk(scope, numbers, build) {
|
|
17410
|
+
if (scope.requests.failed >= MAX_FAILED_REQUESTS) return [{
|
|
17411
|
+
numbers,
|
|
17412
|
+
response: void 0
|
|
17413
|
+
}];
|
|
17414
|
+
const response = await attempt(scope, build(numbers));
|
|
17415
|
+
if (response !== void 0 || numbers.length === 1) return [{
|
|
17416
|
+
numbers,
|
|
17417
|
+
response
|
|
17418
|
+
}];
|
|
17419
|
+
const half = Math.ceil(numbers.length / 2);
|
|
17420
|
+
return [...await sendChunk(scope, numbers.slice(0, half), build), ...await sendChunk(scope, numbers.slice(half), build)];
|
|
17421
|
+
}
|
|
17422
|
+
function chunks(numbers, size) {
|
|
17423
|
+
const out = [];
|
|
17424
|
+
for (let offset = 0; offset < numbers.length; offset += size) out.push(numbers.slice(offset, offset + size));
|
|
17425
|
+
return out;
|
|
17426
|
+
}
|
|
17427
|
+
const aliasesOf = (numbers) => numbers.map((_, i) => `pr${String(i)}`);
|
|
17428
|
+
/** Lists the repository's PRs since the cursor; a transient failure leaves `ok` false. */
|
|
17429
|
+
async function readDiscovery(scope, acc, ctx, login) {
|
|
17290
17430
|
const bootstrap = ctx.cursor === void 0;
|
|
17291
|
-
const
|
|
17292
|
-
if (
|
|
17293
|
-
|
|
17294
|
-
|
|
17295
|
-
|
|
17296
|
-
|
|
17297
|
-
|
|
17298
|
-
|
|
17299
|
-
|
|
17300
|
-
|
|
17301
|
-
const acc = accumulator(true, response.budget);
|
|
17302
|
-
const roots = ["repository", ...numbers.map((_, i) => `pr${String(i)}`)];
|
|
17303
|
-
rejectUnscoped(response.errors, roots);
|
|
17304
|
-
let discoveryOk = scoped(response.errors, "repository").length === 0;
|
|
17305
|
-
const first = discoveryOk ? parseWire(discoveryRootWire, response.data.repository, MALFORMED$2, ["data", "repository"]).pullRequests : void 0;
|
|
17431
|
+
const response = await attempt(scope, discoveryQuery(bootstrap));
|
|
17432
|
+
if (response === void 0) return {
|
|
17433
|
+
ok: false,
|
|
17434
|
+
found: discover([], ctx.cursor, login),
|
|
17435
|
+
bootstrapCursor: void 0
|
|
17436
|
+
};
|
|
17437
|
+
acc.budget = response.budget;
|
|
17438
|
+
rejectUnscoped(response.errors, ["repository"]);
|
|
17439
|
+
let ok = scoped(response.errors, "repository").length === 0;
|
|
17440
|
+
const first = ok ? parseWire(discoveryRootWire, response.data.repository, MALFORMED$2, ["data", "repository"]).pullRequests : void 0;
|
|
17306
17441
|
const nodes = first === void 0 ? [] : [...first.nodes];
|
|
17307
17442
|
let cursor = first === void 0 || pastCursor(nodes, ctx.cursor) ? void 0 : nextPage(first);
|
|
17308
17443
|
const seenPages = /* @__PURE__ */ new Set();
|
|
17309
|
-
while (cursor !== void 0 &&
|
|
17444
|
+
while (cursor !== void 0 && ok) {
|
|
17310
17445
|
if (seenPages.has(cursor)) throw new AdapterError("transient", "Malformed GitHub pagination");
|
|
17311
17446
|
seenPages.add(cursor);
|
|
17312
|
-
const page = await
|
|
17313
|
-
|
|
17314
|
-
|
|
17315
|
-
|
|
17316
|
-
}
|
|
17447
|
+
const page = await attempt(scope, pageQuery("pullRequests", bootstrap), { after: cursor });
|
|
17448
|
+
if (page === void 0) {
|
|
17449
|
+
ok = false;
|
|
17450
|
+
break;
|
|
17451
|
+
}
|
|
17317
17452
|
acc.budget = page.budget;
|
|
17318
17453
|
rejectUnscoped(page.errors, ["repository"]);
|
|
17319
17454
|
if (page.errors.length > 0) {
|
|
17320
|
-
|
|
17455
|
+
ok = false;
|
|
17321
17456
|
break;
|
|
17322
17457
|
}
|
|
17323
17458
|
const connection = parseWire(discoveryRootWire, page.data.repository, MALFORMED$2, ["data", "repository"]).pullRequests;
|
|
17324
17459
|
nodes.push(...connection.nodes);
|
|
17325
17460
|
cursor = pastCursor(connection.nodes, ctx.cursor) ? void 0 : nextPage(connection);
|
|
17326
17461
|
}
|
|
17327
|
-
if (!discoveryOk) acc.complete = false;
|
|
17328
17462
|
const found = discover(nodes, ctx.cursor, login);
|
|
17329
|
-
const bootstrapCursor = bootstrap &&
|
|
17463
|
+
const bootstrapCursor = bootstrap && ok ? latestUpdatedAt(parseWire(baselineRootWire, response.data.repository, MALFORMED$2, ["data", "repository"]).mergedBaseline.nodes, found.cursor) ?? sourceCursorSchema.parse("1970-01-01T00:00:00.000Z") : void 0;
|
|
17464
|
+
return {
|
|
17465
|
+
ok,
|
|
17466
|
+
found,
|
|
17467
|
+
bootstrapCursor
|
|
17468
|
+
};
|
|
17469
|
+
}
|
|
17470
|
+
/** Reads the light index of `numbers`; a PR left out of the map is read in full. */
|
|
17471
|
+
async function readIndex(scope, acc, numbers) {
|
|
17472
|
+
const entries = /* @__PURE__ */ new Map();
|
|
17473
|
+
for (const chunk of chunks(numbers, INDEX_CHUNK)) for (const { numbers: sent, response } of await sendChunk(scope, chunk, indexQuery)) {
|
|
17474
|
+
if (response === void 0) continue;
|
|
17475
|
+
acc.budget = response.budget;
|
|
17476
|
+
if (unscoped(response.errors, aliasesOf(sent))) continue;
|
|
17477
|
+
for (const [i, number] of sent.entries()) {
|
|
17478
|
+
const alias = `pr${String(i)}`;
|
|
17479
|
+
if (scoped(response.errors, alias).length > 0) continue;
|
|
17480
|
+
const entry = indexEntry(response.data[alias]);
|
|
17481
|
+
if (entry !== void 0) entries.set(number, entry);
|
|
17482
|
+
}
|
|
17483
|
+
}
|
|
17484
|
+
return entries;
|
|
17485
|
+
}
|
|
17486
|
+
async function pollRepository({ id, repo, login, keys, client, now, ctx, reserveRemaining, cache }) {
|
|
17487
|
+
const observedAt = sourceCursorSchema.parse(new Date(now()).toISOString());
|
|
17488
|
+
const bootstrap = ctx.cursor === void 0;
|
|
17489
|
+
const [owner, name] = repo.split("/");
|
|
17490
|
+
if (!owner || !name) throw new AdapterError("config", "Invalid repository");
|
|
17491
|
+
const requested = ctx.observe.prs.filter((ref) => ref.repo.toLowerCase() === repo.toLowerCase());
|
|
17492
|
+
const byNumber = new Map(requested.map((ref) => [ref.number, ref]));
|
|
17493
|
+
const numbers = [...byNumber.keys()];
|
|
17494
|
+
const closing = closingSelected(keys);
|
|
17495
|
+
for (const number of cache.keys()) if (!byNumber.has(number)) cache.delete(number);
|
|
17496
|
+
const acc = accumulator(true);
|
|
17497
|
+
const requests = {
|
|
17498
|
+
failed: 0,
|
|
17499
|
+
succeeded: 0,
|
|
17500
|
+
firstError: void 0
|
|
17501
|
+
};
|
|
17502
|
+
const request = {
|
|
17503
|
+
client,
|
|
17504
|
+
owner,
|
|
17505
|
+
name,
|
|
17506
|
+
signal: ctx.signal,
|
|
17507
|
+
requests
|
|
17508
|
+
};
|
|
17509
|
+
const discovery = await readDiscovery(request, acc, ctx, login);
|
|
17510
|
+
if (!discovery.ok) acc.complete = false;
|
|
17511
|
+
const { found } = discovery;
|
|
17512
|
+
const entries = await readIndex(request, acc, numbers);
|
|
17513
|
+
const cursorKey = (number) => JSON.stringify(feedbackCursor(ctx.feedbackCursors, repo, number) ?? "none");
|
|
17514
|
+
const changed = [];
|
|
17515
|
+
for (const number of numbers) {
|
|
17516
|
+
const facts = reusable(cache.get(number), entries.get(number), cursorKey(number), now());
|
|
17517
|
+
const ref = byNumber.get(number);
|
|
17518
|
+
if (facts !== void 0 && ref !== void 0) {
|
|
17519
|
+
acc.items.push({
|
|
17520
|
+
kind: "pr",
|
|
17521
|
+
facts
|
|
17522
|
+
});
|
|
17523
|
+
acc.entities.push({
|
|
17524
|
+
ref,
|
|
17525
|
+
status: "ok"
|
|
17526
|
+
});
|
|
17527
|
+
continue;
|
|
17528
|
+
}
|
|
17529
|
+
cache.delete(number);
|
|
17530
|
+
changed.push(number);
|
|
17531
|
+
}
|
|
17330
17532
|
const scope = {
|
|
17331
17533
|
client,
|
|
17332
17534
|
repo,
|
|
@@ -17337,42 +17539,69 @@ async function pollRepository({ id, repo, login, keys, client, now, ctx }) {
|
|
|
17337
17539
|
...ctx.feedbackCursors === void 0 ? {} : { feedbackCursors: ctx.feedbackCursors }
|
|
17338
17540
|
};
|
|
17339
17541
|
let discoveredOk = true;
|
|
17340
|
-
|
|
17341
|
-
|
|
17342
|
-
const
|
|
17343
|
-
|
|
17344
|
-
|
|
17542
|
+
const unread = (chunk) => {
|
|
17543
|
+
acc.complete = false;
|
|
17544
|
+
for (const number of chunk) {
|
|
17545
|
+
const ref = byNumber.get(number);
|
|
17546
|
+
if (ref) acc.entities.push({
|
|
17547
|
+
ref,
|
|
17548
|
+
status: "no_access"
|
|
17549
|
+
});
|
|
17550
|
+
if (found.numbers.includes(number)) discoveredOk = false;
|
|
17551
|
+
}
|
|
17552
|
+
};
|
|
17345
17553
|
const discovered = found.numbers.filter((number) => !byNumber.has(number));
|
|
17346
|
-
for (
|
|
17347
|
-
|
|
17348
|
-
|
|
17349
|
-
|
|
17350
|
-
|
|
17351
|
-
|
|
17352
|
-
acc.budget =
|
|
17353
|
-
|
|
17354
|
-
|
|
17355
|
-
|
|
17356
|
-
|
|
17554
|
+
for (const chunk of [...chunks(changed, DETAIL_CHUNK), ...chunks(discovered, DETAIL_CHUNK)]) {
|
|
17555
|
+
if (acc.budget !== void 0 && acc.budget.remaining < reserveRemaining) {
|
|
17556
|
+
unread(chunk);
|
|
17557
|
+
continue;
|
|
17558
|
+
}
|
|
17559
|
+
const segments = await sendChunk(request, chunk, (sent) => detailQuery(sent, closing));
|
|
17560
|
+
for (const { response } of segments) if (response !== void 0) acc.budget = response.budget;
|
|
17561
|
+
for (const { numbers: sent, response } of segments) {
|
|
17562
|
+
if (response === void 0) {
|
|
17563
|
+
unread(sent);
|
|
17564
|
+
continue;
|
|
17565
|
+
}
|
|
17566
|
+
rejectUnscoped(response.errors, aliasesOf(sent));
|
|
17567
|
+
for (const [i, number] of sent.entries()) {
|
|
17568
|
+
const alias = `pr${String(i)}`;
|
|
17569
|
+
const ref = byNumber.get(number);
|
|
17570
|
+
const errors = scoped(response.errors, alias);
|
|
17571
|
+
const facts = await processPr(scope, acc, number, alias, response.data, errors, ref);
|
|
17572
|
+
if (facts === void 0) {
|
|
17573
|
+
if (found.numbers.includes(number)) discoveredOk = false;
|
|
17574
|
+
continue;
|
|
17575
|
+
}
|
|
17576
|
+
const entry = entries.get(number);
|
|
17577
|
+
if (entry !== void 0) cache.set(number, {
|
|
17578
|
+
fingerprint: entry.fingerprint,
|
|
17579
|
+
facts,
|
|
17580
|
+
cursorKey: cursorKey(number),
|
|
17581
|
+
readAt: now()
|
|
17582
|
+
});
|
|
17583
|
+
}
|
|
17357
17584
|
}
|
|
17358
17585
|
}
|
|
17359
17586
|
if (ctx.signal.aborted) throw new AdapterError("transient", "GitHub poll aborted");
|
|
17587
|
+
if (requests.firstError !== void 0 && requests.succeeded === 0) throw requests.firstError;
|
|
17360
17588
|
rethrowLoneParseFailure(acc);
|
|
17361
|
-
const nextCursor = bootstrap ? bootstrapCursor : found.cursor;
|
|
17589
|
+
const nextCursor = bootstrap ? discovery.bootstrapCursor : found.cursor;
|
|
17362
17590
|
return {
|
|
17363
17591
|
source: id,
|
|
17364
17592
|
observedAt,
|
|
17365
17593
|
complete: acc.complete,
|
|
17366
17594
|
items: acc.items,
|
|
17367
17595
|
entities: acc.entities,
|
|
17368
|
-
...
|
|
17369
|
-
budget: acc.budget
|
|
17596
|
+
...discovery.ok && discoveredOk ? nextCursor === void 0 ? {} : { cursor: nextCursor } : ctx.cursor === void 0 ? {} : { cursor: ctx.cursor },
|
|
17597
|
+
...acc.budget === void 0 ? {} : { budget: acc.budget }
|
|
17370
17598
|
};
|
|
17371
17599
|
}
|
|
17372
|
-
async function pollOnePr({ id, repo, keys, client, now, ref, signal }) {
|
|
17600
|
+
async function pollOnePr({ id, repo, keys, client, now, ref, signal, cache }) {
|
|
17373
17601
|
const observedAt = new Date(now()).toISOString();
|
|
17374
17602
|
const [owner, name] = repo.split("/");
|
|
17375
17603
|
if (!owner || !name) throw new AdapterError("config", "Invalid repository");
|
|
17604
|
+
cache.delete(ref.number);
|
|
17376
17605
|
const response = await client.query(detailQuery([ref.number], closingSelected(keys)), {
|
|
17377
17606
|
owner,
|
|
17378
17607
|
repo: name
|
|
@@ -17395,7 +17624,7 @@ async function pollOnePr({ id, repo, keys, client, now, ref, signal }) {
|
|
|
17395
17624
|
complete: false,
|
|
17396
17625
|
items: acc.items,
|
|
17397
17626
|
entities: acc.entities,
|
|
17398
|
-
budget: acc.budget
|
|
17627
|
+
...acc.budget === void 0 ? {} : { budget: acc.budget }
|
|
17399
17628
|
};
|
|
17400
17629
|
}
|
|
17401
17630
|
//#endregion
|
package/package.json
CHANGED
package/skills/setup/SKILL.md
CHANGED
|
@@ -36,7 +36,7 @@ Ask one question at a time, only when current state cannot answer it. Check befo
|
|
|
36
36
|
|
|
37
37
|
## 5. Finish
|
|
38
38
|
|
|
39
|
-
- Run `board doctor --json`. For each failed check, inspect state, apply its `fix` with any needed consent, and repeat until green. Report warnings
|
|
39
|
+
- Run `board doctor --json`. For each failed check, inspect state, apply its `fix` with any needed consent, and repeat until green. Report warnings; have sessions in `sessions.stale` re-read the `spur-board` skill (SKILL.md, references/).
|
|
40
40
|
- Wait for the feed's `spur-board is live` line after the first complete poll. If absent, inspect doctor checks and service logs and continue the fix loop. Confirm receipt without exposing a channel ID.
|
|
41
41
|
|
|
42
42
|
## Update
|
|
@@ -8,7 +8,7 @@ Use this when the installed package is older than the intended release. `board u
|
|
|
8
8
|
3. The update needs a running daemon. If the service is stopped, ask before starting it with `board service restart`.
|
|
9
9
|
4. Tell the operator the installed version and the target, then ask before updating. The service is down for the update.
|
|
10
10
|
5. Run `board update` for the latest release, or `board update <version>` for a named one. Progress lines go to stderr; the JSON result goes to stdout. A result with `changed` as `false` means the version was already installed; stop there.
|
|
11
|
-
6. On success, report `from`, `to`, `database.schemaChanged` and each `operator` line. Agent sessions that run `board mcp` must restart to load the new catalog; Spur sessions named
|
|
11
|
+
6. On success, report `from`, `to`, `database.schemaChanged` and each `operator` line. Agent sessions that run `board mcp` must restart to load the new catalog; ask the Spur sessions named in the `sessions.stale` line to re-read the `spur-board` skill (SKILL.md and references/); no restart is needed. Do not restart the service or reinstall the skills again: the update did both.
|
|
12
12
|
7. On exit 4 with `update_rolled_back`, the previous version is running again unless the hint reports a failed restart. Report the hint: it names the failed step and says whether the database was kept, restored, or not changed. At `first poll`, a source did not finish its first complete poll within five minutes. Fix the cause with the operator, then run `board update` again.
|
|
13
13
|
8. On exit 4 with `rollback_failed`, follow `Failed update or rollback` in TROUBLESHOOTING.md: fix the step the hint names, then run `board rollback --yes` again.
|
|
14
14
|
9. On any other exit 4 (`config`) or exit 2 (`usage`), nothing was changed. Report the hint and fix what it names; an older target is refused and points to `board rollback`. When another update or rollback holds the update lock, the hint gives the PID that took it: wait for it and the install it started to finish, and never remove the lock file.
|
|
@@ -22,4 +22,4 @@ Do this once; every later upgrade uses `board update`.
|
|
|
22
22
|
1. Install the newer package with the Node and user prefix of a live Spur session. Verify `board --version` there.
|
|
23
23
|
2. Note whether `board service status` reports `active` as `active`. Run the new package's `board service install`. Run `board service restart` only when the service was active before, install reported `changed` as `false`, and the daemon version changed.
|
|
24
24
|
3. Ask before writing agent skill folders, then run `board skills install`.
|
|
25
|
-
4. Run `board doctor --json` until no blocking check remains. Ask the operator to
|
|
25
|
+
4. Run `board doctor --json` until no blocking check remains. Ask the operator to have live sessions that still use the older skill re-read the `spur-board` skill.
|