@staff0rd/assist 0.730.2 → 0.732.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/README.md +3 -3
- package/claude/advice/show-links.md +6 -0
- package/dist/commands/sessions/web/bundle.js +285 -285
- package/dist/index.js +191 -63
- 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.732.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -579,6 +579,7 @@ var adviceFragmentTitles = {
|
|
|
579
579
|
markdown: "Writing markdown",
|
|
580
580
|
refactor: "Renaming and extracting TypeScript",
|
|
581
581
|
"settings-json": "Editing claude/settings.json",
|
|
582
|
+
"show-links": "Showing long links, paths and snippets",
|
|
582
583
|
verify: "Verifying a change"
|
|
583
584
|
};
|
|
584
585
|
var adviceFragmentNames = [
|
|
@@ -594,6 +595,7 @@ var adviceFragmentNames = [
|
|
|
594
595
|
"markdown",
|
|
595
596
|
"refactor",
|
|
596
597
|
"settings-json",
|
|
598
|
+
"show-links",
|
|
597
599
|
"verify"
|
|
598
600
|
];
|
|
599
601
|
|
|
@@ -12572,8 +12574,8 @@ var nextConfigHelp = [
|
|
|
12572
12574
|
},
|
|
12573
12575
|
{
|
|
12574
12576
|
key: "next.repos",
|
|
12575
|
-
setter: "assist config set next.repos
|
|
12576
|
-
note: "
|
|
12577
|
+
setter: "assist config set next.repos my-org,other/web -g --repo",
|
|
12578
|
+
note: "GitHub repos the web /next view reads peer PRs and issues assigned to you from: owner/name for one repo, or a bare owner (org or user) for all its unarchived repos (default: the selected repo)"
|
|
12577
12579
|
}
|
|
12578
12580
|
];
|
|
12579
12581
|
|
|
@@ -13711,24 +13713,38 @@ function ghJson(cwd, args) {
|
|
|
13711
13713
|
return result;
|
|
13712
13714
|
}
|
|
13713
13715
|
|
|
13716
|
+
// src/commands/sessions/web/next/isOwnerEntry.ts
|
|
13717
|
+
function isOwnerEntry(entry) {
|
|
13718
|
+
return !entry.includes("/");
|
|
13719
|
+
}
|
|
13720
|
+
|
|
13714
13721
|
// src/commands/sessions/web/next/fetchAssignedIssues.ts
|
|
13715
|
-
|
|
13722
|
+
var FIELDS = "number,title,url,createdAt,author,labels";
|
|
13723
|
+
function listArgs(entry) {
|
|
13724
|
+
if (isOwnerEntry(entry))
|
|
13725
|
+
return [
|
|
13726
|
+
"search",
|
|
13727
|
+
"issues",
|
|
13728
|
+
"--owner",
|
|
13729
|
+
entry,
|
|
13730
|
+
"--archived=false",
|
|
13731
|
+
"--json",
|
|
13732
|
+
`${FIELDS},repository`
|
|
13733
|
+
];
|
|
13734
|
+
return ["issue", "list", "--repo", entry, "--json", FIELDS];
|
|
13735
|
+
}
|
|
13736
|
+
async function fetchAssignedIssues(cwd, entry) {
|
|
13716
13737
|
const issues = await ghJson(cwd, [
|
|
13717
|
-
|
|
13718
|
-
"list",
|
|
13719
|
-
"--repo",
|
|
13720
|
-
repo,
|
|
13738
|
+
...listArgs(entry),
|
|
13721
13739
|
"--assignee",
|
|
13722
13740
|
"@me",
|
|
13723
13741
|
"--state",
|
|
13724
13742
|
"open",
|
|
13725
13743
|
"--limit",
|
|
13726
|
-
"100"
|
|
13727
|
-
"--json",
|
|
13728
|
-
"number,title,url,createdAt,author,labels"
|
|
13744
|
+
"100"
|
|
13729
13745
|
]);
|
|
13730
13746
|
return issues.map((issue) => ({
|
|
13731
|
-
repo,
|
|
13747
|
+
repo: issue.repository?.nameWithOwner ?? entry,
|
|
13732
13748
|
number: issue.number,
|
|
13733
13749
|
title: issue.title,
|
|
13734
13750
|
url: issue.url,
|
|
@@ -13740,13 +13756,8 @@ async function fetchAssignedIssues(cwd, repo) {
|
|
|
13740
13756
|
}));
|
|
13741
13757
|
}
|
|
13742
13758
|
|
|
13743
|
-
// src/commands/sessions/web/next/
|
|
13744
|
-
var
|
|
13745
|
-
viewer { login }
|
|
13746
|
-
repository(owner: $owner, name: $name) {
|
|
13747
|
-
pullRequests(states: OPEN, first: 100, orderBy: { field: CREATED_AT, direction: ASC }) {
|
|
13748
|
-
nodes {
|
|
13749
|
-
number
|
|
13759
|
+
// src/commands/sessions/web/next/peerPrFields.ts
|
|
13760
|
+
var peerPrFields = `number
|
|
13750
13761
|
title
|
|
13751
13762
|
url
|
|
13752
13763
|
createdAt
|
|
@@ -13768,9 +13779,16 @@ var peerPrsQuery = `query($owner: String!, $name: String!) {
|
|
|
13768
13779
|
requestedReviewer { ... on User { login } }
|
|
13769
13780
|
}
|
|
13770
13781
|
}
|
|
13771
|
-
}
|
|
13772
|
-
|
|
13773
|
-
|
|
13782
|
+
}`;
|
|
13783
|
+
|
|
13784
|
+
// src/commands/sessions/web/next/ownerPeerPrsQuery.ts
|
|
13785
|
+
var ownerPeerPrsQuery = `query($requested: String!, $authored: String!, $hasPeers: Boolean!) {
|
|
13786
|
+
viewer { login }
|
|
13787
|
+
requested: search(query: $requested, type: ISSUE, first: 100) {
|
|
13788
|
+
nodes { ... on PullRequest { repository { nameWithOwner } ${peerPrFields} } }
|
|
13789
|
+
}
|
|
13790
|
+
authored: search(query: $authored, type: ISSUE, first: 100) @include(if: $hasPeers) {
|
|
13791
|
+
nodes { ... on PullRequest { repository { nameWithOwner } ${peerPrFields} } }
|
|
13774
13792
|
}
|
|
13775
13793
|
}`;
|
|
13776
13794
|
|
|
@@ -13836,8 +13854,56 @@ function selectPeerPrs(nodes, viewer, peers) {
|
|
|
13836
13854
|
return selected.sort((a, b) => a.requestedAt.localeCompare(b.requestedAt));
|
|
13837
13855
|
}
|
|
13838
13856
|
|
|
13857
|
+
// src/commands/sessions/web/next/fetchOwnerPeerPrs.ts
|
|
13858
|
+
function uniqueNodes(...results) {
|
|
13859
|
+
const byUrl = /* @__PURE__ */ new Map();
|
|
13860
|
+
for (const node of results.flatMap((result) => result?.nodes ?? []))
|
|
13861
|
+
if (node?.url) byUrl.set(node.url, node);
|
|
13862
|
+
return [...byUrl.values()];
|
|
13863
|
+
}
|
|
13864
|
+
async function fetchOwnerPeerPrs(cwd, owner, peers) {
|
|
13865
|
+
const base = `user:${owner} is:pr is:open archived:false`;
|
|
13866
|
+
const authors = peers.map((peer) => `author:${peer}`).join(" ");
|
|
13867
|
+
const response = await ghJson(cwd, [
|
|
13868
|
+
"api",
|
|
13869
|
+
"graphql",
|
|
13870
|
+
"-f",
|
|
13871
|
+
`query=${ownerPeerPrsQuery}`,
|
|
13872
|
+
"-f",
|
|
13873
|
+
`requested=${base} review-requested:@me`,
|
|
13874
|
+
"-f",
|
|
13875
|
+
`authored=${base} ${authors}`,
|
|
13876
|
+
"-F",
|
|
13877
|
+
`hasPeers=${peers.length > 0}`
|
|
13878
|
+
]);
|
|
13879
|
+
const viewer = response.data?.viewer?.login;
|
|
13880
|
+
if (!viewer || !response.data?.requested)
|
|
13881
|
+
throw new Error("Owner not searchable");
|
|
13882
|
+
const nodes = uniqueNodes(response.data.requested, response.data.authored);
|
|
13883
|
+
const repoOf2 = new Map(
|
|
13884
|
+
nodes.map((node) => [node.url, node.repository?.nameWithOwner ?? owner])
|
|
13885
|
+
);
|
|
13886
|
+
return selectPeerPrs(nodes, viewer, peers).map((pr) => ({
|
|
13887
|
+
...pr,
|
|
13888
|
+
repo: repoOf2.get(pr.url) ?? owner
|
|
13889
|
+
}));
|
|
13890
|
+
}
|
|
13891
|
+
|
|
13892
|
+
// src/commands/sessions/web/next/peerPrsQuery.ts
|
|
13893
|
+
var peerPrsQuery = `query($owner: String!, $name: String!) {
|
|
13894
|
+
viewer { login }
|
|
13895
|
+
repository(owner: $owner, name: $name) {
|
|
13896
|
+
pullRequests(states: OPEN, first: 100, orderBy: { field: CREATED_AT, direction: ASC }) {
|
|
13897
|
+
nodes {
|
|
13898
|
+
${peerPrFields}
|
|
13899
|
+
}
|
|
13900
|
+
}
|
|
13901
|
+
}
|
|
13902
|
+
}`;
|
|
13903
|
+
|
|
13839
13904
|
// src/commands/sessions/web/next/fetchPeerPrs.ts
|
|
13840
13905
|
async function fetchPeerPrs(cwd, repo, peers) {
|
|
13906
|
+
if (isOwnerEntry(repo)) return fetchOwnerPeerPrs(cwd, repo, peers);
|
|
13841
13907
|
const [owner, name] = repo.split("/");
|
|
13842
13908
|
const response = await ghJson(cwd, [
|
|
13843
13909
|
"api",
|
|
@@ -13892,14 +13958,15 @@ async function sectionAcross(repos2, load3, compare) {
|
|
|
13892
13958
|
error: "No GitHub repo to read: set next.repos or select a repo with a GitHub origin."
|
|
13893
13959
|
};
|
|
13894
13960
|
const results = await Promise.allSettled(repos2.map((repo) => load3(repo)));
|
|
13895
|
-
const items2 =
|
|
13961
|
+
const items2 = /* @__PURE__ */ new Map();
|
|
13896
13962
|
const errors = [];
|
|
13897
13963
|
results.forEach((result, index3) => {
|
|
13898
|
-
if (result.status === "fulfilled")
|
|
13964
|
+
if (result.status === "fulfilled")
|
|
13965
|
+
for (const item of result.value) items2.set(item.url, item);
|
|
13899
13966
|
else errors.push(`${repos2[index3]}: ${errorMessage(result.reason)}`);
|
|
13900
13967
|
});
|
|
13901
13968
|
return {
|
|
13902
|
-
items: items2.sort(compare),
|
|
13969
|
+
items: [...items2.values()].sort(compare),
|
|
13903
13970
|
error: errors.length > 0 ? errors.join("\n") : null
|
|
13904
13971
|
};
|
|
13905
13972
|
}
|
|
@@ -28515,10 +28582,10 @@ function describeFetchError(error) {
|
|
|
28515
28582
|
|
|
28516
28583
|
// src/commands/prs/status/fetchRepoPullRequests.ts
|
|
28517
28584
|
import { execSync as execSync47 } from "child_process";
|
|
28518
|
-
var
|
|
28585
|
+
var FIELDS2 = "number,title,url,author,isDraft,createdAt,updatedAt,reviewDecision,latestReviews,statusCheckRollup,mergeable";
|
|
28519
28586
|
function fetchRepoPullRequests(org, repo) {
|
|
28520
28587
|
const output = execSync47(
|
|
28521
|
-
`gh pr list --state open --json ${
|
|
28588
|
+
`gh pr list --state open --json ${FIELDS2} --limit 100 -R ${org}/${repo}`,
|
|
28522
28589
|
{ encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }
|
|
28523
28590
|
);
|
|
28524
28591
|
const parsed = JSON.parse(output);
|
|
@@ -36246,32 +36313,60 @@ import { randomUUID as randomUUID19 } from "crypto";
|
|
|
36246
36313
|
async function sendShowPreview(request) {
|
|
36247
36314
|
const socket = await connectToDaemon();
|
|
36248
36315
|
await new Promise((resolve26, reject) => {
|
|
36249
|
-
|
|
36250
|
-
|
|
36316
|
+
const finish2 = (error) => {
|
|
36317
|
+
socket.destroy();
|
|
36318
|
+
if (error) reject(error);
|
|
36319
|
+
else resolve26();
|
|
36320
|
+
};
|
|
36321
|
+
readSocketLines(socket, (line) => {
|
|
36322
|
+
const reply2 = parseReply(line);
|
|
36323
|
+
if (reply2?.type === "error") finish2(new Error(reply2.message));
|
|
36324
|
+
if (reply2?.requestId !== request.requestId) return;
|
|
36325
|
+
if (reply2.type === "show-ack") finish2();
|
|
36326
|
+
if (reply2.type === "show-refused") finish2(new Error(reply2.message));
|
|
36327
|
+
});
|
|
36328
|
+
socket.on("error", (error) => finish2(error));
|
|
36329
|
+
socket.on(
|
|
36330
|
+
"close",
|
|
36331
|
+
() => finish2(new Error("daemon closed before acknowledging the show"))
|
|
36332
|
+
);
|
|
36333
|
+
socket.write(
|
|
36251
36334
|
`${JSON.stringify({ type: "pr-preview", kind: "show", prNumber: null, ...request })}
|
|
36252
|
-
|
|
36253
|
-
() => {
|
|
36254
|
-
socket.destroy();
|
|
36255
|
-
resolve26();
|
|
36256
|
-
}
|
|
36335
|
+
`
|
|
36257
36336
|
);
|
|
36258
36337
|
});
|
|
36259
36338
|
}
|
|
36339
|
+
function parseReply(line) {
|
|
36340
|
+
try {
|
|
36341
|
+
return JSON.parse(line);
|
|
36342
|
+
} catch {
|
|
36343
|
+
return null;
|
|
36344
|
+
}
|
|
36345
|
+
}
|
|
36260
36346
|
|
|
36261
36347
|
// src/commands/show.ts
|
|
36262
36348
|
async function show2(options2) {
|
|
36263
36349
|
const body = await readBodyArgument(options2.body);
|
|
36350
|
+
if (body.trim().length === 0) {
|
|
36351
|
+
console.error("Error: --body is empty; there is nothing to show.");
|
|
36352
|
+
process.exit(1);
|
|
36353
|
+
}
|
|
36264
36354
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
36265
36355
|
if (process.env.ASSIST_SESSION !== "1" || !sessionId) {
|
|
36266
36356
|
console.log(body);
|
|
36267
36357
|
return;
|
|
36268
36358
|
}
|
|
36269
|
-
|
|
36270
|
-
|
|
36271
|
-
|
|
36272
|
-
|
|
36273
|
-
|
|
36274
|
-
|
|
36359
|
+
try {
|
|
36360
|
+
await sendShowPreview({
|
|
36361
|
+
sessionId,
|
|
36362
|
+
requestId: randomUUID19(),
|
|
36363
|
+
title: options2.title ?? "Show",
|
|
36364
|
+
body
|
|
36365
|
+
});
|
|
36366
|
+
} catch (error) {
|
|
36367
|
+
console.error(`Error: ${error.message}`);
|
|
36368
|
+
process.exit(1);
|
|
36369
|
+
}
|
|
36275
36370
|
console.log("Opened in the assist web UI preview pane.");
|
|
36276
36371
|
}
|
|
36277
36372
|
|
|
@@ -41433,6 +41528,31 @@ function decidePrPreview(sessions, waiters, notify2, d) {
|
|
|
41433
41528
|
notify2();
|
|
41434
41529
|
}
|
|
41435
41530
|
|
|
41531
|
+
// src/commands/sessions/daemon/parsePreviewMetadata.ts
|
|
41532
|
+
function parsePreviewMetadata(value) {
|
|
41533
|
+
if (!Array.isArray(value)) return void 0;
|
|
41534
|
+
const items2 = value.flatMap((entry) => {
|
|
41535
|
+
const { label: label2, value: text18 } = entry ?? {};
|
|
41536
|
+
return typeof label2 === "string" && typeof text18 === "string" ? [{ label: label2, value: text18 }] : [];
|
|
41537
|
+
});
|
|
41538
|
+
return items2.length > 0 ? items2 : void 0;
|
|
41539
|
+
}
|
|
41540
|
+
|
|
41541
|
+
// src/commands/sessions/daemon/buildPrPreview.ts
|
|
41542
|
+
function buildPrPreview(d, kind, prNumber) {
|
|
41543
|
+
const draft = d.draft === true;
|
|
41544
|
+
return {
|
|
41545
|
+
requestId: d.requestId,
|
|
41546
|
+
title: d.title,
|
|
41547
|
+
body: d.body,
|
|
41548
|
+
prNumber,
|
|
41549
|
+
kind,
|
|
41550
|
+
itemType: kind === "backlog-item" ? d.itemType === "bug" ? "bug" : "story" : void 0,
|
|
41551
|
+
draft: kind === "pr" && prNumber === null ? draft : void 0,
|
|
41552
|
+
metadata: parsePreviewMetadata(d.metadata)
|
|
41553
|
+
};
|
|
41554
|
+
}
|
|
41555
|
+
|
|
41436
41556
|
// src/commands/sessions/daemon/isPreviewKind.ts
|
|
41437
41557
|
var PREVIEW_KINDS = [
|
|
41438
41558
|
"pr",
|
|
@@ -41451,16 +41571,6 @@ function isPreviewKind(value) {
|
|
|
41451
41571
|
return PREVIEW_KINDS.includes(value);
|
|
41452
41572
|
}
|
|
41453
41573
|
|
|
41454
|
-
// src/commands/sessions/daemon/parsePreviewMetadata.ts
|
|
41455
|
-
function parsePreviewMetadata(value) {
|
|
41456
|
-
if (!Array.isArray(value)) return void 0;
|
|
41457
|
-
const items2 = value.flatMap((entry) => {
|
|
41458
|
-
const { label: label2, value: text18 } = entry ?? {};
|
|
41459
|
-
return typeof label2 === "string" && typeof text18 === "string" ? [{ label: label2, value: text18 }] : [];
|
|
41460
|
-
});
|
|
41461
|
-
return items2.length > 0 ? items2 : void 0;
|
|
41462
|
-
}
|
|
41463
|
-
|
|
41464
41574
|
// src/commands/sessions/daemon/previewTargetLabel.ts
|
|
41465
41575
|
function previewTargetLabel(kind, itemType, prNumber, draft) {
|
|
41466
41576
|
if (kind === "backlog-comment") return "backlog comment";
|
|
@@ -41477,6 +41587,27 @@ function previewTargetLabel(kind, itemType, prNumber, draft) {
|
|
|
41477
41587
|
return draft ? "create draft" : "create";
|
|
41478
41588
|
}
|
|
41479
41589
|
|
|
41590
|
+
// src/commands/sessions/daemon/refuseShowOverApproval.ts
|
|
41591
|
+
function refuseShowOverApproval(session, client, d) {
|
|
41592
|
+
const pending = session.pendingPrPreview;
|
|
41593
|
+
if (!pending || pending.kind === "show") return false;
|
|
41594
|
+
const target = previewTargetLabel(
|
|
41595
|
+
pending.kind ?? "pr",
|
|
41596
|
+
pending.itemType ?? "story",
|
|
41597
|
+
pending.prNumber,
|
|
41598
|
+
pending.draft === true
|
|
41599
|
+
);
|
|
41600
|
+
daemonLog(
|
|
41601
|
+
`pr-preview show refused: id=${session.id} requestId=${d.requestId} pending=${target}`
|
|
41602
|
+
);
|
|
41603
|
+
sendTo(client, {
|
|
41604
|
+
type: "show-refused",
|
|
41605
|
+
requestId: d.requestId,
|
|
41606
|
+
message: `A ${target} preview is awaiting approval in this session's preview pane; approve or reject it before showing anything else.`
|
|
41607
|
+
});
|
|
41608
|
+
return true;
|
|
41609
|
+
}
|
|
41610
|
+
|
|
41480
41611
|
// src/commands/sessions/daemon/setPrPreview.ts
|
|
41481
41612
|
function setPrPreview(sessions, waiters, notify2, client, d) {
|
|
41482
41613
|
const id = d.sessionId;
|
|
@@ -41491,20 +41622,17 @@ function setPrPreview(sessions, waiters, notify2, client, d) {
|
|
|
41491
41622
|
}
|
|
41492
41623
|
const prNumber = typeof d.prNumber === "number" ? d.prNumber : null;
|
|
41493
41624
|
const kind = isPreviewKind(d.kind) ? d.kind : "pr";
|
|
41494
|
-
|
|
41495
|
-
|
|
41496
|
-
|
|
41497
|
-
requestId: d.requestId
|
|
41498
|
-
|
|
41499
|
-
|
|
41500
|
-
prNumber,
|
|
41625
|
+
if (kind === "show" && refuseShowOverApproval(session, client, d)) return;
|
|
41626
|
+
session.pendingPrPreview = buildPrPreview(d, kind, prNumber);
|
|
41627
|
+
if (kind === "show")
|
|
41628
|
+
sendTo(client, { type: "show-ack", requestId: d.requestId });
|
|
41629
|
+
else waiters.set(id, client);
|
|
41630
|
+
const target = previewTargetLabel(
|
|
41501
41631
|
kind,
|
|
41502
|
-
itemType
|
|
41503
|
-
|
|
41504
|
-
|
|
41505
|
-
|
|
41506
|
-
if (kind !== "show") waiters.set(id, client);
|
|
41507
|
-
const target = previewTargetLabel(kind, itemType, prNumber, draft);
|
|
41632
|
+
d.itemType === "bug" ? "bug" : "story",
|
|
41633
|
+
prNumber,
|
|
41634
|
+
d.draft === true
|
|
41635
|
+
);
|
|
41508
41636
|
daemonLog(
|
|
41509
41637
|
`pr-preview set: id=${id} requestId=${d.requestId} kind=${kind} target=${target}`
|
|
41510
41638
|
);
|