@staff0rd/assist 0.812.1 → 0.814.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/claude/skills/review-ci/scripts/review.mjs +1 -1
- package/dist/commands/sessions/web/bundle.js +470 -434
- package/dist/index.js +178 -78
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.814.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -3290,6 +3290,7 @@ function toPreviewDecision(msg) {
|
|
|
3290
3290
|
announceAfter: msg.announceAfter === true,
|
|
3291
3291
|
draft: typeof msg.draft === "boolean" ? msg.draft : void 0,
|
|
3292
3292
|
autoMerge: msg.autoMerge === true,
|
|
3293
|
+
autostart: msg.autostart === true,
|
|
3293
3294
|
selection: toSelection(msg.selection),
|
|
3294
3295
|
checklist: toChecklist(msg.checklist)
|
|
3295
3296
|
};
|
|
@@ -7133,27 +7134,101 @@ function renderProposedItem(item) {
|
|
|
7133
7134
|
async function reviewProposal(item, sessionId, confirmed) {
|
|
7134
7135
|
const body = renderProposedItem(item);
|
|
7135
7136
|
if (sessionId) {
|
|
7136
|
-
await awaitPreviewApproval("Backlog item preview", {
|
|
7137
|
+
const decision = await awaitPreviewApproval("Backlog item preview", {
|
|
7137
7138
|
sessionId,
|
|
7138
7139
|
requestId: randomUUID4(),
|
|
7139
7140
|
title: item.name,
|
|
7140
7141
|
body,
|
|
7141
7142
|
prNumber: null,
|
|
7142
7143
|
kind: "backlog-item",
|
|
7143
|
-
itemType: item.type
|
|
7144
|
+
itemType: item.type,
|
|
7145
|
+
canStart: true
|
|
7144
7146
|
});
|
|
7145
|
-
return true;
|
|
7147
|
+
return { autostart: decision.autostart === true };
|
|
7146
7148
|
}
|
|
7147
|
-
if (isClaudeCode() && confirmed) return
|
|
7149
|
+
if (isClaudeCode() && confirmed) return { autostart: false };
|
|
7148
7150
|
console.log(chalk53.bold(item.name));
|
|
7149
7151
|
console.log(renderMarkdownTerminal(body));
|
|
7150
|
-
if (!isClaudeCode()) return
|
|
7152
|
+
if (!isClaudeCode()) return { autostart: false };
|
|
7151
7153
|
console.log(
|
|
7152
7154
|
chalk53.yellow(
|
|
7153
7155
|
"Draft only \u2014 nothing was written to the backlog. Show this draft in the chat, apply any changes the user asks for, then re-run 'assist backlog propose --json <file|->' with --confirmed to create the item."
|
|
7154
7156
|
)
|
|
7155
7157
|
);
|
|
7156
|
-
return
|
|
7158
|
+
return null;
|
|
7159
|
+
}
|
|
7160
|
+
|
|
7161
|
+
// src/commands/review/startChainedSession.ts
|
|
7162
|
+
async function startChainedSession(label2, start2) {
|
|
7163
|
+
if (process.env.ASSIST_SESSION !== "1") return;
|
|
7164
|
+
try {
|
|
7165
|
+
await start2();
|
|
7166
|
+
console.log(`Started ${label2}.`);
|
|
7167
|
+
} catch (error) {
|
|
7168
|
+
console.error(
|
|
7169
|
+
`Warning: could not start ${label2}: ${error instanceof Error ? error.message : String(error)}`
|
|
7170
|
+
);
|
|
7171
|
+
}
|
|
7172
|
+
}
|
|
7173
|
+
|
|
7174
|
+
// src/commands/sessions/shared/requestSession.ts
|
|
7175
|
+
function parseIncoming(line, type) {
|
|
7176
|
+
try {
|
|
7177
|
+
const msg = JSON.parse(line);
|
|
7178
|
+
if (msg.type === "error" && (msg.message ?? "").includes(type))
|
|
7179
|
+
return { kind: "error", message: msg.message ?? `${type} failed` };
|
|
7180
|
+
if (msg.type !== "created" || !msg.sessionId) return null;
|
|
7181
|
+
return { kind: "created", sessionId: msg.sessionId };
|
|
7182
|
+
} catch {
|
|
7183
|
+
return null;
|
|
7184
|
+
}
|
|
7185
|
+
}
|
|
7186
|
+
function requestSession(message3) {
|
|
7187
|
+
return new Promise((resolve30, reject) => {
|
|
7188
|
+
connectToDaemon().then((socket) => {
|
|
7189
|
+
let settled = false;
|
|
7190
|
+
const finish2 = (error, sessionId) => {
|
|
7191
|
+
if (settled) return;
|
|
7192
|
+
settled = true;
|
|
7193
|
+
socket.destroy();
|
|
7194
|
+
if (error) reject(error);
|
|
7195
|
+
else resolve30(sessionId);
|
|
7196
|
+
};
|
|
7197
|
+
readSocketLines(socket, (line) => {
|
|
7198
|
+
const incoming = parseIncoming(line, message3.type);
|
|
7199
|
+
if (!incoming) return;
|
|
7200
|
+
if (incoming.kind === "error") finish2(new Error(incoming.message));
|
|
7201
|
+
else finish2(void 0, incoming.sessionId);
|
|
7202
|
+
});
|
|
7203
|
+
socket.on("error", (error) => finish2(error));
|
|
7204
|
+
socket.on(
|
|
7205
|
+
"close",
|
|
7206
|
+
() => finish2(new Error("daemon closed before the session was created"))
|
|
7207
|
+
);
|
|
7208
|
+
socket.write(`${JSON.stringify(message3)}
|
|
7209
|
+
`);
|
|
7210
|
+
}, reject);
|
|
7211
|
+
});
|
|
7212
|
+
}
|
|
7213
|
+
|
|
7214
|
+
// src/commands/sessions/shared/requestAssistSession.ts
|
|
7215
|
+
function requestAssistSession(assistArgs, cwd, options2) {
|
|
7216
|
+
return requestSession({
|
|
7217
|
+
type: "create-assist",
|
|
7218
|
+
assistArgs,
|
|
7219
|
+
cwd,
|
|
7220
|
+
inPlace: options2?.inPlace === true,
|
|
7221
|
+
launchedFrom: options2?.launchedFrom ?? process.env.ASSIST_SESSION_ID
|
|
7222
|
+
});
|
|
7223
|
+
}
|
|
7224
|
+
|
|
7225
|
+
// src/commands/backlog/propose/startProposedRun.ts
|
|
7226
|
+
function startProposedRun(id) {
|
|
7227
|
+
const itemId2 = formatItemId(id);
|
|
7228
|
+
return startChainedSession(
|
|
7229
|
+
`a backlog run session for ${itemId2}`,
|
|
7230
|
+
() => requestAssistSession(["backlog", "run", itemId2], process.cwd())
|
|
7231
|
+
);
|
|
7157
7232
|
}
|
|
7158
7233
|
|
|
7159
7234
|
// src/commands/backlog/propose.ts
|
|
@@ -7170,10 +7245,15 @@ async function propose(options2) {
|
|
|
7170
7245
|
return;
|
|
7171
7246
|
}
|
|
7172
7247
|
const item = await readProposedItem(options2.json);
|
|
7173
|
-
|
|
7174
|
-
|
|
7248
|
+
const approval = await reviewProposal(
|
|
7249
|
+
item,
|
|
7250
|
+
sessionId,
|
|
7251
|
+
options2.confirmed === true
|
|
7252
|
+
);
|
|
7253
|
+
if (!approval) return;
|
|
7175
7254
|
const id = await createItemWithDefaults(item);
|
|
7176
7255
|
console.log(chalk54.green(`Added item ${formatItemId(id)}: ${item.name}`));
|
|
7256
|
+
if (approval.autostart) await startProposedRun(id);
|
|
7177
7257
|
}
|
|
7178
7258
|
|
|
7179
7259
|
// src/commands/backlog/propose/proposeHelpText.ts
|
|
@@ -15747,6 +15827,87 @@ async function prStatus(req, res) {
|
|
|
15747
15827
|
respondJson(res, 200, { pr });
|
|
15748
15828
|
}
|
|
15749
15829
|
|
|
15830
|
+
// src/commands/sessions/web/releases/toReleaseCompareCommit.ts
|
|
15831
|
+
function toReleaseCompareCommit({
|
|
15832
|
+
sha,
|
|
15833
|
+
commit: commit2
|
|
15834
|
+
}) {
|
|
15835
|
+
return {
|
|
15836
|
+
sha,
|
|
15837
|
+
subject: commit2?.message?.split("\n")[0] ?? null,
|
|
15838
|
+
author: commit2?.author?.name ?? null,
|
|
15839
|
+
date: commit2?.committer?.date ?? null
|
|
15840
|
+
};
|
|
15841
|
+
}
|
|
15842
|
+
|
|
15843
|
+
// src/commands/sessions/web/releases/newestCommits.ts
|
|
15844
|
+
var PAGE_SIZE = 50;
|
|
15845
|
+
function comparePage(cwd, repo, range, page) {
|
|
15846
|
+
return ghJson(cwd, [
|
|
15847
|
+
"api",
|
|
15848
|
+
`repos/${repo}/compare/${range}?per_page=${PAGE_SIZE}&page=${page}`,
|
|
15849
|
+
"--jq",
|
|
15850
|
+
"{total_commits, commits: [.commits[] | {sha, commit}]}"
|
|
15851
|
+
]);
|
|
15852
|
+
}
|
|
15853
|
+
async function newestCommits(cwd, repo, range) {
|
|
15854
|
+
const first = await comparePage(cwd, repo, range, 1);
|
|
15855
|
+
const total = first.total_commits;
|
|
15856
|
+
if (total <= PAGE_SIZE)
|
|
15857
|
+
return { total, commits: first.commits.map(toReleaseCompareCommit) };
|
|
15858
|
+
const last = Math.ceil(total / PAGE_SIZE);
|
|
15859
|
+
const tail = await Promise.all(
|
|
15860
|
+
[last - 1, last].map(
|
|
15861
|
+
(page) => page === 1 ? first : comparePage(cwd, repo, range, page)
|
|
15862
|
+
)
|
|
15863
|
+
);
|
|
15864
|
+
const commits2 = tail.flatMap((page) => page.commits).slice(-PAGE_SIZE);
|
|
15865
|
+
return { total, commits: commits2.map(toReleaseCompareCommit) };
|
|
15866
|
+
}
|
|
15867
|
+
|
|
15868
|
+
// src/commands/sessions/web/releases/compareCommits.ts
|
|
15869
|
+
async function compareCommits(cwd, repo, base, head) {
|
|
15870
|
+
if (!base) {
|
|
15871
|
+
const commit2 = await ghJson(cwd, [
|
|
15872
|
+
"api",
|
|
15873
|
+
`repos/${repo}/commits/${head}`,
|
|
15874
|
+
"--jq",
|
|
15875
|
+
"{sha, commit}"
|
|
15876
|
+
]);
|
|
15877
|
+
return { total: 1, commits: [toReleaseCompareCommit(commit2)] };
|
|
15878
|
+
}
|
|
15879
|
+
const { total, commits: commits2 } = await newestCommits(
|
|
15880
|
+
cwd,
|
|
15881
|
+
repo,
|
|
15882
|
+
`${base}...${head}`
|
|
15883
|
+
);
|
|
15884
|
+
return { total, commits: commits2.reverse() };
|
|
15885
|
+
}
|
|
15886
|
+
|
|
15887
|
+
// src/commands/sessions/web/releases/releasesCompare.ts
|
|
15888
|
+
async function releasesCompare(req, res) {
|
|
15889
|
+
const cwd = getCwdParam(req, res);
|
|
15890
|
+
if (!cwd) return;
|
|
15891
|
+
const params = new URL(req.url ?? "/", "http://localhost").searchParams;
|
|
15892
|
+
const repo = params.get("repo");
|
|
15893
|
+
const head = params.get("head");
|
|
15894
|
+
if (!repo || !head) {
|
|
15895
|
+
respondJson(res, 400, { error: "Missing repo or head" });
|
|
15896
|
+
return;
|
|
15897
|
+
}
|
|
15898
|
+
try {
|
|
15899
|
+
respondJson(
|
|
15900
|
+
res,
|
|
15901
|
+
200,
|
|
15902
|
+
await compareCommits(cwd, repo, params.get("base"), head)
|
|
15903
|
+
);
|
|
15904
|
+
} catch (error) {
|
|
15905
|
+
respondJson(res, 502, {
|
|
15906
|
+
error: error instanceof Error ? error.message : "gh compare failed"
|
|
15907
|
+
});
|
|
15908
|
+
}
|
|
15909
|
+
}
|
|
15910
|
+
|
|
15750
15911
|
// src/commands/sessions/web/releases/releasesConfigured.ts
|
|
15751
15912
|
function releasesConfigured(req, res) {
|
|
15752
15913
|
const cwd = getCwdParam(req, res);
|
|
@@ -17922,6 +18083,7 @@ var routes2 = {
|
|
|
17922
18083
|
"GET /api/news/nav": newsNavConfig,
|
|
17923
18084
|
"GET /api/releases/state": releasesState,
|
|
17924
18085
|
"GET /api/releases/configured": releasesConfigured,
|
|
18086
|
+
"GET /api/releases/compare": releasesCompare,
|
|
17925
18087
|
"GET /api/usage/history": listUsageHistory,
|
|
17926
18088
|
"GET /api/usage/items": listUsageItems,
|
|
17927
18089
|
"GET /api/backups/list": getBackups,
|
|
@@ -28936,10 +29098,10 @@ function printPr(pr) {
|
|
|
28936
29098
|
}
|
|
28937
29099
|
|
|
28938
29100
|
// src/commands/prs/prs/displayPaginated.ts
|
|
28939
|
-
var
|
|
29101
|
+
var PAGE_SIZE2 = 10;
|
|
28940
29102
|
function getPageSlice(pullRequests, page) {
|
|
28941
|
-
const start2 = page *
|
|
28942
|
-
return pullRequests.slice(start2, start2 +
|
|
29103
|
+
const start2 = page * PAGE_SIZE2;
|
|
29104
|
+
return pullRequests.slice(start2, start2 + PAGE_SIZE2);
|
|
28943
29105
|
}
|
|
28944
29106
|
function pageHeader(page, totalPages, total) {
|
|
28945
29107
|
return `
|
|
@@ -28983,7 +29145,7 @@ async function promptNavigation(currentPage, totalPages) {
|
|
|
28983
29145
|
return parseAction(action);
|
|
28984
29146
|
}
|
|
28985
29147
|
function computeTotalPages(count8) {
|
|
28986
|
-
return Math.ceil(count8 /
|
|
29148
|
+
return Math.ceil(count8 / PAGE_SIZE2);
|
|
28987
29149
|
}
|
|
28988
29150
|
async function navigateAndDisplay(pullRequests, totalPages, currentPage) {
|
|
28989
29151
|
const delta = await promptNavigation(currentPage, totalPages);
|
|
@@ -30189,46 +30351,6 @@ async function placePr(prNumber, title, body, options2, attachments = []) {
|
|
|
30189
30351
|
// src/commands/prs/previewAndPlace.ts
|
|
30190
30352
|
import { randomUUID as randomUUID17 } from "crypto";
|
|
30191
30353
|
|
|
30192
|
-
// src/commands/sessions/shared/requestSession.ts
|
|
30193
|
-
function parseIncoming(line, type) {
|
|
30194
|
-
try {
|
|
30195
|
-
const msg = JSON.parse(line);
|
|
30196
|
-
if (msg.type === "error" && (msg.message ?? "").includes(type))
|
|
30197
|
-
return { kind: "error", message: msg.message ?? `${type} failed` };
|
|
30198
|
-
if (msg.type !== "created" || !msg.sessionId) return null;
|
|
30199
|
-
return { kind: "created", sessionId: msg.sessionId };
|
|
30200
|
-
} catch {
|
|
30201
|
-
return null;
|
|
30202
|
-
}
|
|
30203
|
-
}
|
|
30204
|
-
function requestSession(message3) {
|
|
30205
|
-
return new Promise((resolve30, reject) => {
|
|
30206
|
-
connectToDaemon().then((socket) => {
|
|
30207
|
-
let settled = false;
|
|
30208
|
-
const finish2 = (error, sessionId) => {
|
|
30209
|
-
if (settled) return;
|
|
30210
|
-
settled = true;
|
|
30211
|
-
socket.destroy();
|
|
30212
|
-
if (error) reject(error);
|
|
30213
|
-
else resolve30(sessionId);
|
|
30214
|
-
};
|
|
30215
|
-
readSocketLines(socket, (line) => {
|
|
30216
|
-
const incoming = parseIncoming(line, message3.type);
|
|
30217
|
-
if (!incoming) return;
|
|
30218
|
-
if (incoming.kind === "error") finish2(new Error(incoming.message));
|
|
30219
|
-
else finish2(void 0, incoming.sessionId);
|
|
30220
|
-
});
|
|
30221
|
-
socket.on("error", (error) => finish2(error));
|
|
30222
|
-
socket.on(
|
|
30223
|
-
"close",
|
|
30224
|
-
() => finish2(new Error("daemon closed before the session was created"))
|
|
30225
|
-
);
|
|
30226
|
-
socket.write(`${JSON.stringify(message3)}
|
|
30227
|
-
`);
|
|
30228
|
-
}, reject);
|
|
30229
|
-
});
|
|
30230
|
-
}
|
|
30231
|
-
|
|
30232
30354
|
// src/commands/sessions/shared/requestClaudeSession.ts
|
|
30233
30355
|
function requestClaudeSession(prompt, cwd, options2) {
|
|
30234
30356
|
return requestSession({
|
|
@@ -30240,19 +30362,6 @@ function requestClaudeSession(prompt, cwd, options2) {
|
|
|
30240
30362
|
});
|
|
30241
30363
|
}
|
|
30242
30364
|
|
|
30243
|
-
// src/commands/review/startChainedSession.ts
|
|
30244
|
-
async function startChainedSession(label2, start2) {
|
|
30245
|
-
if (process.env.ASSIST_SESSION !== "1") return;
|
|
30246
|
-
try {
|
|
30247
|
-
await start2();
|
|
30248
|
-
console.log(`Started ${label2}.`);
|
|
30249
|
-
} catch (error) {
|
|
30250
|
-
console.error(
|
|
30251
|
-
`Warning: could not start ${label2}: ${error instanceof Error ? error.message : String(error)}`
|
|
30252
|
-
);
|
|
30253
|
-
}
|
|
30254
|
-
}
|
|
30255
|
-
|
|
30256
30365
|
// src/commands/review/announcePr.ts
|
|
30257
30366
|
function announcePr(prNumber) {
|
|
30258
30367
|
return startChainedSession(
|
|
@@ -30265,17 +30374,6 @@ function announcePr(prNumber) {
|
|
|
30265
30374
|
);
|
|
30266
30375
|
}
|
|
30267
30376
|
|
|
30268
|
-
// src/commands/sessions/shared/requestAssistSession.ts
|
|
30269
|
-
function requestAssistSession(assistArgs, cwd, options2) {
|
|
30270
|
-
return requestSession({
|
|
30271
|
-
type: "create-assist",
|
|
30272
|
-
assistArgs,
|
|
30273
|
-
cwd,
|
|
30274
|
-
inPlace: options2?.inPlace === true,
|
|
30275
|
-
launchedFrom: options2?.launchedFrom ?? process.env.ASSIST_SESSION_ID
|
|
30276
|
-
});
|
|
30277
|
-
}
|
|
30278
|
-
|
|
30279
30377
|
// src/commands/prs/chainReviewAndPost.ts
|
|
30280
30378
|
function chainReviewAndPost(prNumber, announce) {
|
|
30281
30379
|
const args = [
|
|
@@ -44444,7 +44542,7 @@ function decidePrPreview(sessions, waiters, notify2, d) {
|
|
|
44444
44542
|
const screenshotCount = Array.isArray(d.screenshots) ? d.screenshots.length : 0;
|
|
44445
44543
|
const checklistCount = Array.isArray(d.checklist) ? d.checklist.length : 0;
|
|
44446
44544
|
daemonLog(
|
|
44447
|
-
`pr-decision received: id=${id} requestId=${requestId} decision=${d.decision} comments=${commentCount} screenshots=${screenshotCount} checklist=${checklistCount} reviewAfter=${d.reviewAfter === true} announceAfter=${d.announceAfter === true} draft=${d.draft} autoMerge=${d.autoMerge === true}`
|
|
44545
|
+
`pr-decision received: id=${id} requestId=${requestId} decision=${d.decision} comments=${commentCount} screenshots=${screenshotCount} checklist=${checklistCount} reviewAfter=${d.reviewAfter === true} announceAfter=${d.announceAfter === true} draft=${d.draft} autoMerge=${d.autoMerge === true} autostart=${d.autostart === true}`
|
|
44448
44546
|
);
|
|
44449
44547
|
const waiter = waiters.get(id);
|
|
44450
44548
|
if (waiter)
|
|
@@ -44460,6 +44558,7 @@ function decidePrPreview(sessions, waiters, notify2, d) {
|
|
|
44460
44558
|
announceAfter: d.announceAfter,
|
|
44461
44559
|
draft: d.draft,
|
|
44462
44560
|
autoMerge: d.autoMerge,
|
|
44561
|
+
autostart: d.autostart,
|
|
44463
44562
|
checklist: d.checklist
|
|
44464
44563
|
});
|
|
44465
44564
|
waiters.delete(id);
|
|
@@ -44487,6 +44586,7 @@ function buildPrPreview(d, kind, prNumber) {
|
|
|
44487
44586
|
prNumber,
|
|
44488
44587
|
kind,
|
|
44489
44588
|
itemType: kind === "backlog-item" ? d.itemType === "bug" ? "bug" : "story" : void 0,
|
|
44589
|
+
canStart: kind === "backlog-item" && d.canStart === true ? true : void 0,
|
|
44490
44590
|
draft: kind === "pr" && prNumber === null ? draft : void 0,
|
|
44491
44591
|
metadata: parsePreviewMetadata(d.metadata),
|
|
44492
44592
|
screenshots: kind === "pr" ? toAttachments(d.screenshots) : void 0
|