@staff0rd/assist 0.865.0 → 0.866.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/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.865.0",
9
+ version: "0.866.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -26028,7 +26028,7 @@ function applyCreatedIssueMetadata(createOutput, metadata2) {
26028
26028
  // src/commands/github/issue/issuePreviewMetadata.ts
26029
26029
  function issuePreviewMetadata(resolved) {
26030
26030
  if (!resolved) return [];
26031
- const { target, issueType, parent, project, labels } = resolved;
26031
+ const { target, issueType, parent, project, labels, milestone } = resolved;
26032
26032
  const items2 = [
26033
26033
  { label: "Repository", value: `${target.owner}/${target.repo}` }
26034
26034
  ];
@@ -26047,6 +26047,7 @@ function issuePreviewMetadata(resolved) {
26047
26047
  if (project?.status)
26048
26048
  items2.push({ label: "Status", value: project.status.optionName });
26049
26049
  if (labels?.length) items2.push({ label: "Labels", value: labels.join(", ") });
26050
+ if (milestone) items2.push({ label: "Milestone", value: milestone });
26050
26051
  return items2;
26051
26052
  }
26052
26053
 
@@ -26058,7 +26059,7 @@ function hasCreateIssueMetadataOptions(options2) {
26058
26059
  );
26059
26060
  }
26060
26061
  return Boolean(
26061
- options2.type || options2.parent || options2.project || options2.label?.length
26062
+ options2.type || options2.parent || options2.project || options2.label?.length || options2.milestone
26062
26063
  );
26063
26064
  }
26064
26065
 
@@ -26105,6 +26106,45 @@ function resolveIssueLabels(target, wanted) {
26105
26106
  });
26106
26107
  }
26107
26108
 
26109
+ // src/commands/github/issue/resolveIssueMilestone.ts
26110
+ var QUERY6 = `query($owner: String!, $repo: String!, $after: String) {
26111
+ repository(owner: $owner, name: $repo) {
26112
+ milestones(first: 100, after: $after, states: OPEN) {
26113
+ nodes { title }
26114
+ pageInfo { hasNextPage endCursor }
26115
+ }
26116
+ }
26117
+ }`;
26118
+ function readOpenMilestones(target) {
26119
+ const titles2 = [];
26120
+ let after;
26121
+ do {
26122
+ const page = JSON.parse(
26123
+ runGhGraphqlJson(QUERY6, { ...target, after })
26124
+ ).data?.repository?.milestones;
26125
+ if (!page) {
26126
+ throw new Error(
26127
+ `No milestones could be read for ${target.owner}/${target.repo}`
26128
+ );
26129
+ }
26130
+ for (const node of page.nodes ?? [])
26131
+ if (node?.title) titles2.push(node.title);
26132
+ after = page.pageInfo?.hasNextPage ? page.pageInfo.endCursor ?? void 0 : void 0;
26133
+ } while (after);
26134
+ return titles2;
26135
+ }
26136
+ function resolveIssueMilestone(target, wanted) {
26137
+ const titles2 = readOpenMilestones(target);
26138
+ const match = titles2.find((title) => title === wanted) ?? titles2.find((title) => title.toLowerCase() === wanted.toLowerCase());
26139
+ if (!match) {
26140
+ const available = titles2.length ? `Its open milestones are ${titles2.join(", ")}` : "It has no open milestones";
26141
+ throw new Error(
26142
+ `${target.owner}/${target.repo} has no open ${wanted} milestone. ${available}`
26143
+ );
26144
+ }
26145
+ return match;
26146
+ }
26147
+
26108
26148
  // src/commands/prs/shared.ts
26109
26149
  import { execSync as execSync37 } from "child_process";
26110
26150
 
@@ -26262,7 +26302,8 @@ function resolveCreateIssueMetadata(options2) {
26262
26302
  issueType: options2.type ? resolveIssueType(resolveOrgIssueTypes(target.owner), options2.type) : void 0,
26263
26303
  parent: options2.parent ? resolveCreateIssueParent(target, options2.parent) : void 0,
26264
26304
  project: options2.project ? resolveCreateIssueProject(target.owner, options2.project, options2.status) : void 0,
26265
- labels: labels.length ? resolveIssueLabels(target, labels) : void 0
26305
+ labels: labels.length ? resolveIssueLabels(target, labels) : void 0,
26306
+ milestone: options2.milestone ? resolveIssueMilestone(target, options2.milestone) : void 0
26266
26307
  };
26267
26308
  }
26268
26309
 
@@ -26340,16 +26381,17 @@ function runGhWithAttachments(args, attachments) {
26340
26381
  }
26341
26382
 
26342
26383
  // src/commands/github/issue/runGhIssueCreate.ts
26343
- function runGhIssueCreate(title, body, repo, labels, attachments = []) {
26384
+ function runGhIssueCreate(title, body, repo, metadata2, attachments = []) {
26344
26385
  const args = ["issue", "create", "--title", title, "--body", body];
26345
26386
  if (repo) args.push("--repo", repo);
26346
- for (const label2 of labels ?? []) args.push("--label", label2);
26387
+ for (const label2 of metadata2?.labels ?? []) args.push("--label", label2);
26388
+ if (metadata2?.milestone) args.push("--milestone", metadata2.milestone);
26347
26389
  args.push(...attachArgs(attachments));
26348
26390
  return runGhWithAttachments(args, attachments);
26349
26391
  }
26350
26392
 
26351
26393
  // src/commands/github/issue/createIssue.ts
26352
- var USAGE2 = "Usage: assist github issue create --title <title> --body <body> [-R <owner>/<repo>] [--type <name>] [--parent <issue>] [--project <number>] [--status <name>] [--label <name>]";
26394
+ var USAGE2 = "Usage: assist github issue create --title <title> --body <body> [-R <owner>/<repo>] [--type <name>] [--parent <issue>] [--project <number>] [--status <name>] [--label <name>] [--milestone <name>]";
26353
26395
  function preflight(options2) {
26354
26396
  try {
26355
26397
  return resolveCreateIssueMetadata(options2);
@@ -26380,7 +26422,7 @@ async function createIssue(options2) {
26380
26422
  title,
26381
26423
  appendScreenshots(body, attachments),
26382
26424
  options2.repo,
26383
- resolved?.labels,
26425
+ resolved,
26384
26426
  attachments
26385
26427
  );
26386
26428
  console.log(output.trim());
@@ -26409,13 +26451,16 @@ function registerCreateIssue(issueCommand) {
26409
26451
  "Label to apply (repeat the flag, or pass a comma-separated list)",
26410
26452
  collectLabels,
26411
26453
  []
26454
+ ).option(
26455
+ "--milestone <name>",
26456
+ "Open milestone of the target repo to put the new issue on, by title"
26412
26457
  ).addHelpText(
26413
26458
  "after",
26414
26459
  `
26415
26460
  There is no What/Why/How template: an issue reports a problem, and the target repo's own issue template is unknowable from here. Write the body as the repo's maintainers would expect.
26416
26461
  In an assist web session the title and body are previewed for approve/reject first (with inline comments); nothing is created until it is approved.
26417
26462
  The reviewer may also drop or paste screenshots or video into the pane; on approval gh attaches them (gh ${minGhAttachVersion}+) under a ## Screenshots section of the issue body automatically, and on rejection they stay attached and reappear in the preview you re-propose \u2014 so never author that section yourself.
26418
- --type, --parent, --project, --status and --label are all resolved before the preview, so an unknown name, an unreadable parent, a missing project scope or --status without --project creates nothing.
26463
+ --type, --parent, --project, --status, --label and --milestone are all resolved before the preview, so an unknown name, an unreadable parent, a missing project scope or --status without --project creates nothing.
26419
26464
  A bare --parent number is read against --repo, or the current repo; a parent in another repository is allowed.
26420
26465
  The project scope is needed for --project: gh auth refresh -h github.com -s project`
26421
26466
  ).action(createIssue);
@@ -26778,7 +26823,7 @@ function parseIssueProjectItems(raw, label2) {
26778
26823
  }
26779
26824
 
26780
26825
  // src/commands/github/issue/fetchIssueProjectItems.ts
26781
- var QUERY6 = `query($owner: String!, $repo: String!, $number: Int!) {
26826
+ var QUERY7 = `query($owner: String!, $repo: String!, $number: Int!) {
26782
26827
  repository(owner: $owner, name: $repo) {
26783
26828
  issue(number: $number) {
26784
26829
  id
@@ -26800,7 +26845,7 @@ var QUERY6 = `query($owner: String!, $repo: String!, $number: Int!) {
26800
26845
  }`;
26801
26846
  function fetchIssueProjectItems(target) {
26802
26847
  return parseIssueProjectItems(
26803
- runGhGraphqlJson(QUERY6, target),
26848
+ runGhGraphqlJson(QUERY7, target),
26804
26849
  `${target.owner}/${target.repo}#${target.number}`
26805
26850
  );
26806
26851
  }
@@ -27643,9 +27688,10 @@ function spawnInstall(worktreePath, cwd, command, where, onDone) {
27643
27688
  }
27644
27689
 
27645
27690
  // src/commands/sessions/daemon/worktree/runInstall.ts
27646
- function runInstall(worktreePath, clone, install, onSeeded) {
27691
+ function runInstall(worktreePath, clone, install, onSeeded, onInstalling = () => {
27692
+ }) {
27647
27693
  if (Array.isArray(install)) {
27648
- installPaths(worktreePath, install, onSeeded);
27694
+ installPaths(worktreePath, install, onSeeded, onInstalling);
27649
27695
  return;
27650
27696
  }
27651
27697
  const command = resolveInstallCommand(clone, install);
@@ -27653,9 +27699,10 @@ function runInstall(worktreePath, clone, install, onSeeded) {
27653
27699
  onSeeded();
27654
27700
  return;
27655
27701
  }
27702
+ onInstalling();
27656
27703
  spawnInstall(worktreePath, worktreePath, command, "", () => onSeeded());
27657
27704
  }
27658
- function installPaths(worktreePath, paths, onSeeded) {
27705
+ function installPaths(worktreePath, paths, onSeeded, onInstalling) {
27659
27706
  const next3 = (index2) => {
27660
27707
  const rel = paths[index2];
27661
27708
  if (rel === void 0) {
@@ -27671,6 +27718,7 @@ function installPaths(worktreePath, paths, onSeeded) {
27671
27718
  onSeeded();
27672
27719
  return;
27673
27720
  }
27721
+ onInstalling(rel);
27674
27722
  spawnInstall(worktreePath, dir, command, ` in ${rel}`, (outcome) => {
27675
27723
  if (outcome.ok && !outcome.stopped) {
27676
27724
  next3(index2 + 1);
@@ -27688,10 +27736,10 @@ function installPaths(worktreePath, paths, onSeeded) {
27688
27736
 
27689
27737
  // src/commands/sessions/daemon/worktree/seedWorktree.ts
27690
27738
  function seedWorktree(worktreePath, clone, onSeeded = () => {
27691
- }) {
27739
+ }, onInstalling) {
27692
27740
  const cfg = worktreeConfigFor(clone);
27693
27741
  copyConfigFiles(worktreePath, clone, cfg.copy);
27694
- runInstall(worktreePath, clone, cfg.install, onSeeded);
27742
+ runInstall(worktreePath, clone, cfg.install, onSeeded, onInstalling);
27695
27743
  }
27696
27744
  function copyConfigFiles(worktreePath, clone, copy) {
27697
27745
  for (const rel of copy) {
@@ -27788,22 +27836,27 @@ async function reportCwdToDaemon(cwd) {
27788
27836
  }
27789
27837
  }
27790
27838
 
27791
- // src/commands/review/worktreeHoldingBranch.ts
27792
- function worktreeHoldingBranch(cwd, branch2) {
27793
- const listing = gitSyncOrNull(cwd, ["worktree", "list", "--porcelain"]);
27794
- if (!listing) return null;
27795
- const here = gitSyncOrNull(cwd, ["rev-parse", "--show-toplevel"]);
27839
+ // src/commands/sessions/daemon/worktree/worktreeWithBranch.ts
27840
+ function worktreeWithBranch(listing, branch2) {
27796
27841
  let path109 = null;
27797
27842
  for (const line of listing.split("\n")) {
27798
27843
  const trimmed = line.trim();
27799
27844
  if (trimmed.startsWith("worktree "))
27800
27845
  path109 = trimmed.slice("worktree ".length).trim();
27801
- else if (trimmed === `branch refs/heads/${branch2}`)
27802
- return path109 && path109 !== here ? path109 : null;
27846
+ else if (trimmed === `branch refs/heads/${branch2}`) return path109;
27803
27847
  }
27804
27848
  return null;
27805
27849
  }
27806
27850
 
27851
+ // src/commands/review/worktreeHoldingBranch.ts
27852
+ function worktreeHoldingBranch(cwd, branch2) {
27853
+ const listing = gitSyncOrNull(cwd, ["worktree", "list", "--porcelain"]);
27854
+ if (!listing) return null;
27855
+ const here = gitSyncOrNull(cwd, ["rev-parse", "--show-toplevel"]);
27856
+ const path109 = worktreeWithBranch(listing, branch2);
27857
+ return path109 && path109 !== here ? path109 : null;
27858
+ }
27859
+
27807
27860
  // src/commands/review/checkoutPr.ts
27808
27861
  function currentBranch4() {
27809
27862
  return gitSyncOrNull(process.cwd(), ["rev-parse", "--abbrev-ref", "HEAD"]);
@@ -43862,6 +43915,7 @@ function toSessionInfo(session) {
43862
43915
  starred,
43863
43916
  design,
43864
43917
  verifying,
43918
+ seeding,
43865
43919
  pendingPrPreview,
43866
43920
  undurable,
43867
43921
  lastUserMessage,
@@ -43888,6 +43942,7 @@ function toSessionInfo(session) {
43888
43942
  starred,
43889
43943
  design,
43890
43944
  verifying,
43945
+ seeding,
43891
43946
  pendingPrPreview,
43892
43947
  undurable,
43893
43948
  lastUserMessage,
@@ -44720,7 +44775,18 @@ function bindNewWorktree(session, alloc, notify2, startHeld = () => {
44720
44775
  return;
44721
44776
  session.worktree = { path: alloc.cwd, clone: alloc.clone };
44722
44777
  if (alloc.created)
44723
- seedWorktree(alloc.cwd, alloc.clone, () => startHeld(session));
44778
+ seedWorktree(
44779
+ alloc.cwd,
44780
+ alloc.clone,
44781
+ () => {
44782
+ session.seeding = void 0;
44783
+ startHeld(session);
44784
+ },
44785
+ (path109) => {
44786
+ session.seeding = `Installing dependencies${path109 ? ` in ${path109}` : ""}\u2026`;
44787
+ notify2();
44788
+ }
44789
+ );
44724
44790
  notify2();
44725
44791
  }
44726
44792
  function bindRestoredWorktrees(sessions) {
@@ -49310,16 +49376,21 @@ function isBacklogRunArgs(args) {
49310
49376
  return rest.some((arg) => ITEM_ID.test(arg));
49311
49377
  }
49312
49378
 
49313
- // src/commands/sessions/daemon/worktree/isPrCheckoutArgs.ts
49379
+ // src/commands/sessions/daemon/worktree/prCheckoutNumber.ts
49314
49380
  var CHECKOUT_COMMANDS = /* @__PURE__ */ new Set([
49315
49381
  "review",
49316
49382
  "review-pr-comments",
49317
49383
  "fix-conflict"
49318
49384
  ]);
49319
- function isPrCheckoutArgs(args) {
49385
+ function prCheckoutNumber(args) {
49320
49386
  const [command, ...rest] = args;
49321
- if (!command || !CHECKOUT_COMMANDS.has(command)) return false;
49322
- return rest.some((arg) => /^[1-9]\d*$/.test(arg));
49387
+ if (!command || !CHECKOUT_COMMANDS.has(command)) return void 0;
49388
+ return rest.find((arg) => /^[1-9]\d*$/.test(arg));
49389
+ }
49390
+
49391
+ // src/commands/sessions/daemon/worktree/isPrCheckoutArgs.ts
49392
+ function isPrCheckoutArgs(args) {
49393
+ return prCheckoutNumber(args) !== void 0;
49323
49394
  }
49324
49395
 
49325
49396
  // src/commands/sessions/daemon/worktree/isCommittingArgs.ts
@@ -49974,15 +50045,27 @@ async function handleSearchHistory(client, data) {
49974
50045
 
49975
50046
  // src/commands/sessions/daemon/creator.ts
49976
50047
  function creator(isNew, spawn12) {
49977
- return (client, m, d) => {
49978
- if (m.links.route(client, d)) return;
49979
- const result = spawn12(m, d);
50048
+ const reply2 = (client, result) => {
49980
50049
  if (typeof result !== "string") {
49981
50050
  sendTo(client, { type: "error", message: result.error });
49982
50051
  return;
49983
50052
  }
49984
50053
  sendTo(client, { type: "created", sessionId: result, isNew });
49985
50054
  };
50055
+ return (client, m, d) => {
50056
+ if (m.links.route(client, d)) return;
50057
+ const result = spawn12(m, d);
50058
+ if (result instanceof Promise)
50059
+ result.then(
50060
+ (resolved) => reply2(client, resolved),
50061
+ (error) => {
50062
+ const reason4 = error instanceof Error ? error.message : String(error);
50063
+ daemonLog(`${d.type} failed: ${reason4}`);
50064
+ reply2(client, { error: `${d.type} failed: ${reason4}` });
50065
+ }
50066
+ );
50067
+ else reply2(client, result);
50068
+ };
49986
50069
  }
49987
50070
 
49988
50071
  // src/commands/sessions/shared/codex/codexRolloutUsage.ts
@@ -50415,6 +50498,52 @@ var sessionSettingHandlers = {
50415
50498
  )
50416
50499
  };
50417
50500
 
50501
+ // src/commands/sessions/daemon/worktree/prCheckoutHolder.ts
50502
+ import { execFile as execFile13 } from "child_process";
50503
+ import { existsSync as existsSync100 } from "fs";
50504
+ function prHeadBranch2(number, cwd) {
50505
+ return new Promise((resolve30) => {
50506
+ execFile13(
50507
+ "gh",
50508
+ ["pr", "view", number, "--json", "headRefName", "-q", ".headRefName"],
50509
+ { cwd, encoding: "utf8", windowsHide: true },
50510
+ (error, stdout) => resolve30(error ? null : stdout.trim() || null)
50511
+ );
50512
+ });
50513
+ }
50514
+ async function prCheckoutHolder(assistArgs, cwd) {
50515
+ const number = prCheckoutNumber(assistArgs);
50516
+ if (!number || !cwd || !existsSync100(cwd)) return void 0;
50517
+ const headRef = await prHeadBranch2(number, cwd);
50518
+ if (!headRef) return void 0;
50519
+ const listing = await gitOrNull(cwd, ["worktree", "list", "--porcelain"]);
50520
+ const holder = listing ? worktreeWithBranch(listing, headRef) : null;
50521
+ if (!holder || !existsSync100(holder)) return void 0;
50522
+ daemonLog(
50523
+ `pr #${number} assist ${assistArgs[0]} launched in its checkout ${holder}: head branch ${headRef} is already checked out there, so no worktree is allocated`
50524
+ );
50525
+ return holder;
50526
+ }
50527
+
50528
+ // src/commands/sessions/daemon/spawnAssistCreate.ts
50529
+ function spawnAssistCreate(m, d) {
50530
+ const assistArgs = d.assistArgs ?? [];
50531
+ const cwd = d.cwd;
50532
+ const inPlace = d.inPlace === true;
50533
+ const spawn12 = (holder) => m.spawnAssist(
50534
+ assistArgs,
50535
+ holder ?? cwd,
50536
+ {
50537
+ title: d.title,
50538
+ subtitle: d.subtitle,
50539
+ inPlace: inPlace || holder !== void 0
50540
+ },
50541
+ spawnContextFrom(d)
50542
+ );
50543
+ if (inPlace || !isPrCheckoutArgs(assistArgs)) return spawn12();
50544
+ return prCheckoutHolder(assistArgs, cwd).then(spawn12);
50545
+ }
50546
+
50418
50547
  // src/commands/sessions/daemon/spawnCreate.ts
50419
50548
  function spawnCreate(m, d) {
50420
50549
  const design = d.design === true;
@@ -50461,19 +50590,7 @@ var messageHandlers = {
50461
50590
  },
50462
50591
  create: creator(true, spawnCreate),
50463
50592
  "create-run": handleCreateRun,
50464
- "create-assist": creator(
50465
- true,
50466
- (m, d) => m.spawnAssist(
50467
- d.assistArgs ?? [],
50468
- d.cwd,
50469
- {
50470
- title: d.title,
50471
- subtitle: d.subtitle,
50472
- inPlace: d.inPlace === true
50473
- },
50474
- spawnContextFrom(d)
50475
- )
50476
- ),
50593
+ "create-assist": creator(true, spawnAssistCreate),
50477
50594
  resume: creator(
50478
50595
  false,
50479
50596
  (m, d) => m.resume(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.865.0",
3
+ "version": "0.866.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {