@staff0rd/assist 0.1068.0 → 0.1069.1

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.1068.0",
9
+ version: "0.1069.1",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -28614,25 +28614,49 @@ function commentWords(comment3) {
28614
28614
  return comment3.toLowerCase().split(/[^a-z0-9]+/).filter((word) => word.length > 0);
28615
28615
  }
28616
28616
 
28617
+ // src/commands/editHook/widenToLines.ts
28618
+ function widenToLines(content, oldString, newString) {
28619
+ const start2 = oldString === "" ? -1 : content.indexOf(oldString);
28620
+ if (start2 < 0) return { removed: oldString, added: newString };
28621
+ const end = start2 + oldString.length;
28622
+ const lineStart = content.lastIndexOf("\n", start2 - 1) + 1;
28623
+ const newline = content.indexOf("\n", end);
28624
+ const lineEnd = newline === -1 ? content.length : newline;
28625
+ const prefix2 = content.slice(lineStart, start2);
28626
+ const suffix = content.slice(end, lineEnd);
28627
+ return {
28628
+ removed: prefix2 + oldString + suffix,
28629
+ added: prefix2 + newString + suffix
28630
+ };
28631
+ }
28632
+
28617
28633
  // src/commands/editHook/partitionStrings.ts
28618
28634
  function defined(values) {
28619
28635
  return values.filter((value) => value != null);
28620
28636
  }
28637
+ function widenEdits(edits, existingContent) {
28638
+ let content = existingContent;
28639
+ const pairs = [];
28640
+ for (const { old_string, new_string } of edits) {
28641
+ if (content == null || old_string == null || new_string == null) {
28642
+ pairs.push({ removed: old_string, added: new_string });
28643
+ continue;
28644
+ }
28645
+ pairs.push(widenToLines(content, old_string, new_string));
28646
+ content = content.replace(old_string, () => new_string);
28647
+ }
28648
+ return {
28649
+ added: defined(pairs.map((p) => p.added)),
28650
+ removed: defined(pairs.map((p) => p.removed))
28651
+ };
28652
+ }
28621
28653
  function partitionStrings(input, existingContent) {
28622
28654
  const { tool_name, tool_input } = input;
28623
28655
  switch (tool_name) {
28624
28656
  case "Edit":
28625
- return {
28626
- added: defined([tool_input.new_string]),
28627
- removed: defined([tool_input.old_string])
28628
- };
28629
- case "MultiEdit": {
28630
- const edits = tool_input.edits ?? [];
28631
- return {
28632
- added: defined(edits.map((e) => e.new_string)),
28633
- removed: defined(edits.map((e) => e.old_string))
28634
- };
28635
- }
28657
+ return widenEdits([tool_input], existingContent);
28658
+ case "MultiEdit":
28659
+ return widenEdits(tool_input.edits ?? [], existingContent);
28636
28660
  case "Write":
28637
28661
  return {
28638
28662
  added: defined([tool_input.content]),
@@ -29298,7 +29322,7 @@ function readExisting(filePath) {
29298
29322
  async function editHook() {
29299
29323
  const input = tryParseInput2(await readStdin());
29300
29324
  if (!input) return;
29301
- const existing = input.tool_name === "Write" ? readExisting(input.tool_input.file_path) : void 0;
29325
+ const existing = readExisting(input.tool_input.file_path);
29302
29326
  const reason4 = decideOverrideGuard(input, existing) ?? decideCommentGuard(input, existing) ?? await decideSchemaGuard(input) ?? await decideDocsGuard(input);
29303
29327
  if (!reason4) return;
29304
29328
  console.log(
@@ -42596,10 +42620,9 @@ async function ensureCodexAvailable() {
42596
42620
  }
42597
42621
 
42598
42622
  // src/commands/review/planCodexReviewer.ts
42599
- async function planCodexReviewer(codexPath, slotAssigned) {
42623
+ async function planCodexReviewer(codexPath) {
42600
42624
  const cached2 = cachedReviewerResult("codex", codexPath);
42601
42625
  if (cached2) return { kind: "cached", cached: cached2 };
42602
- if (slotAssigned) return { kind: "run" };
42603
42626
  const status2 = await ensureCodexAvailable();
42604
42627
  if (status2 === "available") return { kind: "run" };
42605
42628
  return { kind: "skipped" };
@@ -42734,16 +42757,6 @@ async function recordReviewerRuns(fresh, target, startedAt, openDb = getDb) {
42734
42757
  }
42735
42758
  }
42736
42759
 
42737
- // src/commands/review/reviewerLabel.ts
42738
- function reviewerLabel(name, model) {
42739
- return model ? `${name} (${model})` : name;
42740
- }
42741
-
42742
- // src/commands/review/buildCodexModelArgs.ts
42743
- function buildCodexModelArgs() {
42744
- return buildLitellmCodexArgs(loadConfig().review?.codexModel);
42745
- }
42746
-
42747
42760
  // src/commands/review/runClaudeReviewer.ts
42748
42761
  import { writeFileSync as writeFileSync43 } from "fs";
42749
42762
 
@@ -42825,6 +42838,11 @@ function formatToolText(name, tool, summary) {
42825
42838
  return `${name} \u2014 ${tool}${suffix}`;
42826
42839
  }
42827
42840
 
42841
+ // src/commands/review/reviewerLabel.ts
42842
+ function reviewerLabel(name, model) {
42843
+ return model ? `${name} (${model})` : name;
42844
+ }
42845
+
42828
42846
  // src/commands/review/reportReviewerToolUse.ts
42829
42847
  function reportReviewerToolUse(name, use, spinner, model) {
42830
42848
  const label = reviewerLabel(name, model);
@@ -42837,13 +42855,13 @@ function reportReviewerToolUse(name, use, spinner, model) {
42837
42855
  }
42838
42856
 
42839
42857
  // src/commands/review/createClaudeLineHandler.ts
42840
- function createClaudeLineHandler(name, spinner, model) {
42858
+ function createClaudeLineHandler(name, spinner) {
42841
42859
  const state = { finalText: "" };
42842
42860
  const onLine = (line) => {
42843
42861
  const event = parseClaudeEvent(line);
42844
42862
  if (event.kind === "tool_uses") {
42845
42863
  for (const use of event.toolUses)
42846
- reportReviewerToolUse(name, use, spinner, model);
42864
+ reportReviewerToolUse(name, use, spinner);
42847
42865
  return;
42848
42866
  }
42849
42867
  if (event.kind === "final") {
@@ -43103,41 +43121,47 @@ function runStreamingChild(spec) {
43103
43121
 
43104
43122
  // src/commands/review/runClaudeReviewer.ts
43105
43123
  async function runClaudeReviewer(spec) {
43106
- const { spinner, override } = spec;
43124
+ const { spinner } = spec;
43107
43125
  const command = "claude";
43108
- const { state, onLine } = createClaudeLineHandler(
43109
- spec.name,
43110
- spinner,
43111
- override?.model
43112
- );
43126
+ const { state, onLine } = createClaudeLineHandler(spec.name, spinner);
43113
43127
  const result = await runStreamingChild({
43114
43128
  name: spec.name,
43115
43129
  command,
43116
- model: override?.model,
43117
43130
  args: [
43118
43131
  "-p",
43119
43132
  "--add-dir",
43120
43133
  spec.reviewDir,
43121
43134
  "--output-format",
43122
43135
  "stream-json",
43123
- "--verbose",
43124
- ...override?.args ?? []
43136
+ "--verbose"
43125
43137
  ],
43126
43138
  stdin: spec.stdin,
43127
43139
  quiet: Boolean(spinner),
43128
- ...override ? { env: override.env } : {},
43129
43140
  onLine
43130
43141
  });
43131
43142
  if (result.exitCode === 0 && state.finalText)
43132
43143
  writeFileSync43(spec.outputPath, state.finalText);
43133
- const finalised = finaliseReviewerRun(
43134
- { ...spec, command, model: override?.model },
43135
- spinner,
43136
- result
43137
- );
43144
+ const finalised = finaliseReviewerRun({ ...spec, command }, spinner, result);
43138
43145
  return state.usage ? { ...finalised, usage: state.usage } : finalised;
43139
43146
  }
43140
43147
 
43148
+ // src/commands/review/resolveClaude.ts
43149
+ function resolveClaude(args) {
43150
+ if (args.cached) return Promise.resolve(args.cached);
43151
+ return runClaudeReviewer({
43152
+ name: "claude",
43153
+ reviewDir: args.reviewDir,
43154
+ stdin: args.stdin,
43155
+ outputPath: args.claudePath,
43156
+ spinner: args.multi?.create("claude \u2014 starting")
43157
+ });
43158
+ }
43159
+
43160
+ // src/commands/review/buildCodexModelArgs.ts
43161
+ function buildCodexModelArgs() {
43162
+ return buildLitellmCodexArgs(loadConfig().review?.codexModel);
43163
+ }
43164
+
43141
43165
  // src/commands/review/runCodexReviewer.ts
43142
43166
  import { existsSync as existsSync72, unlinkSync as unlinkSync17 } from "fs";
43143
43167
 
@@ -43244,50 +43268,18 @@ async function runCodexReviewer(spec) {
43244
43268
  return state.usage ? { ...finalised, usage: state.usage } : finalised;
43245
43269
  }
43246
43270
 
43247
- // src/commands/review/runSlot.ts
43248
- function runSlot(harness, spec) {
43249
- if (harness === "claude") return runClaudeReviewer(spec);
43250
- return runCodexReviewer({
43251
- name: spec.name,
43252
- stdin: spec.stdin,
43253
- outputPath: spec.outputPath,
43254
- spinner: spec.spinner,
43255
- override: spec.override ?? buildCodexModelArgs()
43256
- });
43257
- }
43258
-
43259
- // src/commands/review/resolveClaude.ts
43260
- function resolveClaude(args) {
43261
- if (args.cached) return Promise.resolve(args.cached);
43262
- const name = args.slot?.label ?? "claude";
43263
- const override = args.slot?.override;
43264
- const spinner = args.multi?.create(
43265
- `${reviewerLabel(name, override?.model)} \u2014 starting`
43266
- );
43267
- return runSlot(args.slot?.harness ?? "claude", {
43268
- name,
43269
- reviewDir: args.reviewDir,
43270
- stdin: args.stdin,
43271
- outputPath: args.claudePath,
43272
- spinner,
43273
- override
43274
- });
43275
- }
43276
-
43277
43271
  // src/commands/review/resolveCodex.ts
43278
43272
  function resolveCodex(args) {
43279
43273
  if (args.plan.kind === "cached") return Promise.resolve(args.plan.cached);
43280
43274
  if (args.plan.kind === "skipped") {
43281
43275
  return Promise.resolve(skippedCodexResult(args.codexPath));
43282
43276
  }
43283
- const name = args.slot?.label ?? "codex";
43284
- const override = args.slot?.override ?? buildCodexModelArgs();
43277
+ const override = buildCodexModelArgs();
43285
43278
  const spinner = args.multi?.create(
43286
- `${reviewerLabel(name, override.model)} \u2014 starting`
43279
+ `${reviewerLabel("codex", override.model)} \u2014 starting`
43287
43280
  );
43288
- return runSlot(args.slot?.harness ?? "codex", {
43289
- name,
43290
- reviewDir: args.reviewDir,
43281
+ return runCodexReviewer({
43282
+ name: "codex",
43291
43283
  stdin: args.stdin,
43292
43284
  outputPath: args.codexPath,
43293
43285
  spinner,
@@ -43302,16 +43294,13 @@ async function runReviewers(reviewDir, claudePath, codexPath, stdinPrompt, optio
43302
43294
  claudePath,
43303
43295
  stdin: stdinPrompt,
43304
43296
  cached: options2.cachedClaude,
43305
- multi: options2.multi,
43306
- slot: options2.models.claude
43297
+ multi: options2.multi
43307
43298
  });
43308
43299
  const codexPromise = resolveCodex({
43309
- reviewDir,
43310
43300
  codexPath,
43311
43301
  stdin: stdinPrompt,
43312
43302
  plan: options2.codexPlan,
43313
- multi: options2.multi,
43314
- slot: options2.models.codex
43303
+ multi: options2.multi
43315
43304
  });
43316
43305
  const results = await Promise.all([claudePromise, codexPromise]);
43317
43306
  const anyFresh = options2.cachedClaude === null || options2.codexPlan.kind !== "cached";
@@ -43536,12 +43525,8 @@ async function synthesise(paths, options2) {
43536
43525
  printSummary2(paths.synthesisPath);
43537
43526
  return cached2;
43538
43527
  }
43539
- const { multi, slot } = options2;
43540
- const override = slot?.override;
43541
- const spinner = multi?.create(
43542
- `${reviewerLabel("synthesis", override?.model)} \u2014 starting`
43543
- );
43544
- const result = await runSlot(slot?.harness ?? "claude", {
43528
+ const spinner = options2.multi?.create("synthesis \u2014 starting");
43529
+ const result = await runClaudeReviewer({
43545
43530
  name: "synthesis",
43546
43531
  reviewDir: paths.reviewDir,
43547
43532
  stdin: buildSynthesisStdin(
@@ -43550,8 +43535,7 @@ async function synthesise(paths, options2) {
43550
43535
  paths.codexPath
43551
43536
  ),
43552
43537
  outputPath: paths.synthesisPath,
43553
- spinner,
43554
- override
43538
+ spinner
43555
43539
  });
43556
43540
  if (result.exitCode === 0) printSummary2(paths.synthesisPath);
43557
43541
  return result;
@@ -43563,10 +43547,7 @@ async function synthesiseAfterReviewers(input) {
43563
43547
  if (input.anyFresh && existsSync73(paths.synthesisPath)) {
43564
43548
  unlinkSync18(paths.synthesisPath);
43565
43549
  }
43566
- const synthesisResult = await synthesise(paths, {
43567
- multi: input.multi,
43568
- slot: input.slot
43569
- });
43550
+ const synthesisResult = await synthesise(paths, { multi: input.multi });
43570
43551
  if (synthesisResult.exitCode !== 0) failures.push(synthesisResult);
43571
43552
  return {
43572
43553
  ok: synthesisResult.exitCode === 0,
@@ -43576,11 +43557,9 @@ async function synthesiseAfterReviewers(input) {
43576
43557
  }
43577
43558
 
43578
43559
  // src/commands/review/skipReason.ts
43579
- function skipReason(results, failures, strict) {
43560
+ function skipReason(results, failures) {
43580
43561
  if (failures.length === results.length)
43581
43562
  return "Both reviewers failed; skipping synthesis.";
43582
- if (strict && failures.length > 0)
43583
- return "A reviewer failed; skipping synthesis.";
43584
43563
  return void 0;
43585
43564
  }
43586
43565
 
@@ -43599,13 +43578,12 @@ async function runAndSynthesise(args) {
43599
43578
  {
43600
43579
  multi,
43601
43580
  codexPlan: args.codexPlan,
43602
- cachedClaude: args.cachedClaude,
43603
- models: args.models
43581
+ cachedClaude: args.cachedClaude
43604
43582
  }
43605
43583
  );
43606
43584
  if (args.job) await recordReviewerRuns(fresh, args.job, startedAt);
43607
43585
  const failures = failed2(results);
43608
- const reason4 = skipReason(results, failures, args.strict);
43586
+ const reason4 = skipReason(results, failures);
43609
43587
  if (reason4) {
43610
43588
  console.error(reason4);
43611
43589
  return { ok: false, failures, slots: results };
@@ -43615,8 +43593,7 @@ async function runAndSynthesise(args) {
43615
43593
  results,
43616
43594
  failures,
43617
43595
  anyFresh,
43618
- multi,
43619
- slot: args.models.synthesis
43596
+ multi
43620
43597
  });
43621
43598
  }
43622
43599
 
@@ -43654,10 +43631,7 @@ function finishUi(ui, ok) {
43654
43631
  }
43655
43632
  async function runReviewPipeline(paths, options2) {
43656
43633
  const cachedClaude = cachedReviewerResult("claude", paths.claudePath);
43657
- const codexPlan = await planCodexReviewer(
43658
- paths.codexPath,
43659
- options2.models?.codex !== void 0
43660
- );
43634
+ const codexPlan = await planCodexReviewer(paths.codexPath);
43661
43635
  const ui = createUi(useSpinnerUi(options2.verbose));
43662
43636
  try {
43663
43637
  const outcome = await runAndSynthesise({
@@ -43665,8 +43639,6 @@ async function runReviewPipeline(paths, options2) {
43665
43639
  cachedClaude,
43666
43640
  codexPlan,
43667
43641
  multi: ui.multi,
43668
- models: options2.models ?? {},
43669
- strict: options2.strict ?? false,
43670
43642
  job: options2.job
43671
43643
  });
43672
43644
  finishUi(ui, outcome.ok);
@@ -44054,19 +44026,9 @@ async function postFindings(findings2) {
44054
44026
  return { posted, failed: failed3 };
44055
44027
  }
44056
44028
 
44057
- // src/commands/review/appendCiFooter.ts
44058
- function appendCiFooter(body, ciFooter) {
44059
- return ciFooter ? `${body}
44060
-
44061
- ${ciFooter}` : body;
44062
- }
44063
-
44064
44029
  // src/commands/review/buildReviewBody.ts
44065
- function buildReviewBody(markdown, unanchored, ciFooter) {
44066
- return appendCiFooter(
44067
- sanitiseReviewerNames(buildReviewSummary(markdown, unanchored)),
44068
- ciFooter
44069
- );
44030
+ function buildReviewBody(markdown, unanchored) {
44031
+ return sanitiseReviewerNames(buildReviewSummary(markdown, unanchored));
44070
44032
  }
44071
44033
 
44072
44034
  // src/commands/review/runReviewSubmission.ts
@@ -44138,16 +44100,14 @@ async function postAndMaybeSubmit(lineBound, unanchored, markdown, options2) {
44138
44100
  console.log(`Posted ${posted} comment(s)${failedSuffix}.`);
44139
44101
  const withRejected = withRejectedFindings(unanchored, failed3);
44140
44102
  const carried = carriedUnanchoredFindings(withRejected);
44141
- if (posted === 0 && carried.length === 0 && !options2.ciFooter)
44103
+ if (posted === 0 && carried.length === 0)
44142
44104
  return { posted: 0, submitted: false };
44143
44105
  const shouldSubmit = await decideSubmit(options2);
44144
44106
  if (shouldSubmit) {
44145
- const submitted = submitReview(
44146
- buildReviewBody(markdown, withRejected, options2.ciFooter),
44147
- { posted, failed: failed3.length }
44148
- );
44149
- if (!submitted && options2.ciFooter)
44150
- throw new Error("the review could not be submitted to the PR");
44107
+ const submitted = submitReview(buildReviewBody(markdown, withRejected), {
44108
+ posted,
44109
+ failed: failed3.length
44110
+ });
44151
44111
  return { posted, submitted };
44152
44112
  }
44153
44113
  console.log("Leaving the review unsubmitted.");
@@ -44347,24 +44307,6 @@ function stillOnReviewedPr(prNumber) {
44347
44307
  return false;
44348
44308
  }
44349
44309
 
44350
- // src/commands/review/submitNoFindingsReview.ts
44351
- function submitNoFindingsReview(markdown, ciFooter) {
44352
- const body = sanitiseReviewerNames(
44353
- `${buildReviewSummary(markdown)}
44354
-
44355
- No findings were raised.`
44356
- );
44357
- return submitBodyOnlyReview(appendCiFooter(body, ciFooter));
44358
- }
44359
-
44360
- // src/commands/review/postNoFindingsReview.ts
44361
- function postNoFindingsReview(markdown, ciFooter) {
44362
- if (!ciFooter) return { posted: 0, submitted: false };
44363
- if (!submitNoFindingsReview(markdown, ciFooter))
44364
- throw new Error("the review could not be submitted to the PR");
44365
- return { posted: 0, submitted: true };
44366
- }
44367
-
44368
44310
  // src/commands/review/describeWork.ts
44369
44311
  function describeWork(comments3, carried) {
44370
44312
  const parts = [];
@@ -44383,8 +44325,7 @@ async function postFindingsToPr(prInfo, synthesisPath, options2) {
44383
44325
  const markdown = readFileSync58(synthesisPath, "utf8");
44384
44326
  const { inDiff, unanchored } = selectPostableFindings(markdown, prInfo);
44385
44327
  const carried = carriedUnanchoredFindings(unanchored);
44386
- if (inDiff.length === 0 && carried.length === 0)
44387
- return postNoFindingsReview(markdown, options2.ciFooter);
44328
+ if (inDiff.length === 0 && carried.length === 0) return NOTHING_POSTED;
44388
44329
  const work = describeWork(inDiff.length, carried.length);
44389
44330
  console.log(`Found PR #${prInfo.prNumber} with ${work} to post.`);
44390
44331
  const confirmed = await confirmPost(prInfo.prNumber, work, options2);
@@ -44508,8 +44449,7 @@ async function handlePostSynthesis(synthesisPath, prInfo, options2) {
44508
44449
  prompt: options2.prompt,
44509
44450
  submit: options2.submit,
44510
44451
  addressComments: options2.addressComments,
44511
- announce: options2.announce,
44512
- ciFooter: options2.ciFooter
44452
+ announce: options2.announce
44513
44453
  });
44514
44454
  return;
44515
44455
  }
@@ -48239,10 +48179,6 @@ var rules = [
48239
48179
  matches: (path109) => path109.startsWith("claude/skills/"),
48240
48180
  reason: "claude/skills changed"
48241
48181
  },
48242
- {
48243
- matches: (path109) => path109.startsWith("src/commands/review/"),
48244
- reason: "review-ci bundle sources changed"
48245
- },
48246
48182
  {
48247
48183
  matches: (path109) => path109 === "claude/settings.json",
48248
48184
  reason: "claude/settings.json changed"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.1068.0",
3
+ "version": "0.1069.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {