@staff0rd/assist 0.738.0 → 0.740.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.738.0",
9
+ version: "0.740.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -7763,6 +7763,29 @@ function assertCodexResumeSupported(options2) {
7763
7763
  }
7764
7764
  }
7765
7765
 
7766
+ // src/commands/litellm/buildCodexProviderArgs.ts
7767
+ var API_KEY_ENV = "ASSIST_LITELLM_API_KEY";
7768
+ function buildCodexProviderArgs(responsesBaseUrl, apiKey, model) {
7769
+ return {
7770
+ args: [
7771
+ "-c",
7772
+ "model_providers.litellm.name=LiteLLM",
7773
+ "-c",
7774
+ `model_providers.litellm.base_url=${responsesBaseUrl}`,
7775
+ "-c",
7776
+ `model_providers.litellm.env_key=${API_KEY_ENV}`,
7777
+ "-c",
7778
+ "model_providers.litellm.wire_api=responses",
7779
+ "-c",
7780
+ "model_provider=litellm",
7781
+ "-m",
7782
+ model
7783
+ ],
7784
+ env: { [API_KEY_ENV]: apiKey },
7785
+ model
7786
+ };
7787
+ }
7788
+
7766
7789
  // src/commands/litellm/readLitellmConfig.ts
7767
7790
  function readLitellmConfig() {
7768
7791
  const litellm = loadConfig().litellm;
@@ -7777,30 +7800,12 @@ function readLitellmConfig() {
7777
7800
  }
7778
7801
 
7779
7802
  // src/commands/litellm/buildLitellmCodexArgs.ts
7780
- var API_KEY_ENV = "ASSIST_LITELLM_API_KEY";
7781
7803
  function buildLitellmCodexArgs(rawModel) {
7782
7804
  const model = rawModel?.trim();
7783
7805
  if (!model) return { args: [], env: {} };
7784
7806
  const { config } = readLitellmConfig();
7785
7807
  if (!config) return { args: [], env: {} };
7786
- return {
7787
- args: [
7788
- "-c",
7789
- "model_providers.litellm.name=LiteLLM",
7790
- "-c",
7791
- `model_providers.litellm.base_url=${config.baseUrl}/v1`,
7792
- "-c",
7793
- `model_providers.litellm.env_key=${API_KEY_ENV}`,
7794
- "-c",
7795
- "model_providers.litellm.wire_api=responses",
7796
- "-c",
7797
- "model_provider=litellm",
7798
- "-m",
7799
- model
7800
- ],
7801
- env: { [API_KEY_ENV]: config.apiKey },
7802
- model
7803
- };
7808
+ return buildCodexProviderArgs(`${config.baseUrl}/v1`, config.apiKey, model);
7804
7809
  }
7805
7810
 
7806
7811
  // src/shared/buildHarnessCodexArgs.ts
@@ -23882,6 +23887,17 @@ function resolveIssueLabels(target, wanted) {
23882
23887
 
23883
23888
  // src/commands/prs/shared.ts
23884
23889
  import { execSync as execSync37 } from "child_process";
23890
+
23891
+ // src/commands/prs/pinCurrentPr.ts
23892
+ var pinnedPr;
23893
+ function getPinnedPr() {
23894
+ return pinnedPr;
23895
+ }
23896
+ function currentPrSelector(currentBranch5) {
23897
+ return pinnedPr === void 0 ? currentBranch5() : String(pinnedPr);
23898
+ }
23899
+
23900
+ // src/commands/prs/shared.ts
23885
23901
  function isGhNotInstalled(error) {
23886
23902
  if (error instanceof Error) {
23887
23903
  const msg = error.message.toLowerCase();
@@ -23889,12 +23905,6 @@ function isGhNotInstalled(error) {
23889
23905
  }
23890
23906
  return false;
23891
23907
  }
23892
- function isNotFound(error) {
23893
- if (error instanceof Error) {
23894
- return error.message.includes("HTTP 404") || error.message.includes("Could not resolve to a PullRequest");
23895
- }
23896
- return false;
23897
- }
23898
23908
  function getRepoInfo() {
23899
23909
  const preferred = getPreferredRemoteRepo();
23900
23910
  if (preferred) return preferred;
@@ -23910,11 +23920,13 @@ function getCurrentBranch2() {
23910
23920
  }
23911
23921
  function viewCurrentPr(fields) {
23912
23922
  const { org, repo } = getRepoInfo();
23913
- const branch2 = getCurrentBranch2();
23914
23923
  return JSON.parse(
23915
- execSync37(`gh pr view ${branch2} --json ${fields} -R ${org}/${repo}`, {
23916
- encoding: "utf8"
23917
- })
23924
+ execSync37(
23925
+ `gh pr view ${currentPrSelector(getCurrentBranch2)} --json ${fields} -R ${org}/${repo}`,
23926
+ {
23927
+ encoding: "utf8"
23928
+ }
23929
+ )
23918
23930
  );
23919
23931
  }
23920
23932
  function getCurrentPrNumber() {
@@ -27792,6 +27804,14 @@ function updateCommentsCache(org, repo, prNumber, comments3) {
27792
27804
  }
27793
27805
  }
27794
27806
 
27807
+ // src/commands/prs/isNotFound.ts
27808
+ function isNotFound(error) {
27809
+ if (error instanceof Error) {
27810
+ return error.message.includes("HTTP 404") || error.message.includes("Could not resolve to a PullRequest");
27811
+ }
27812
+ return false;
27813
+ }
27814
+
27795
27815
  // src/commands/prs/listComments.ts
27796
27816
  function handleKnownErrors(error) {
27797
27817
  if (isGhNotInstalled(error)) {
@@ -33951,180 +33971,15 @@ async function runHighLevelReview(number, options2 = {}) {
33951
33971
  await openHighLevelOverlay(sessionId, subject);
33952
33972
  }
33953
33973
 
33954
- // src/commands/review/annotateDiffWithLineNumbers.ts
33955
- var FILE_HEADER = /^\+\+\+ (?:b\/)?(.+)$/;
33956
- var HUNK_HEADER = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/;
33957
- var GUTTER_WIDTH = 6;
33958
- function gutter(lineNumber) {
33959
- const label2 = lineNumber === null ? "" : String(lineNumber);
33960
- return `${label2.padStart(GUTTER_WIDTH, " ")} `;
33961
- }
33962
- function annotateDiffWithLineNumbers(diff3) {
33963
- let inFile = false;
33964
- let newLine = 0;
33965
- return diff3.split("\n").map((line) => {
33966
- if (FILE_HEADER.test(line)) {
33967
- inFile = true;
33968
- return gutter(null) + line;
33969
- }
33970
- const hunkMatch = line.match(HUNK_HEADER);
33971
- if (hunkMatch) {
33972
- newLine = Number(hunkMatch[1]);
33973
- return gutter(null) + line;
33974
- }
33975
- if (!inFile) return gutter(null) + line;
33976
- if (line.startsWith("+") || line.startsWith(" ")) {
33977
- const annotated = gutter(newLine) + line;
33978
- newLine++;
33979
- return annotated;
33980
- }
33981
- return gutter(null) + line;
33982
- }).join("\n");
33983
- }
33984
-
33985
- // src/commands/review/formatPriorComments.ts
33986
- function threadKey(c, byId) {
33987
- if (c.threadId) return c.threadId;
33988
- if (c.inReplyToId !== null && byId.has(c.inReplyToId)) {
33989
- return `root-${c.inReplyToId}`;
33990
- }
33991
- return `root-${c.id}`;
33992
- }
33993
- function groupIntoThreads(comments3) {
33994
- const byId = new Map(comments3.map((c) => [c.id, c]));
33995
- const threads = /* @__PURE__ */ new Map();
33996
- for (const c of comments3) {
33997
- const key = threadKey(c, byId);
33998
- const existing = threads.get(key);
33999
- const parent = c.inReplyToId !== null ? byId.get(c.inReplyToId) : void 0;
34000
- if (existing) {
34001
- if (parent) existing.replies.push(c);
34002
- } else if (parent) {
34003
- threads.set(key, { root: parent, replies: [c] });
34004
- } else {
34005
- threads.set(key, { root: c, replies: [] });
34006
- }
34007
- }
34008
- return [...threads.values()];
34009
- }
34010
- function headerFor(c) {
34011
- const location = c.line !== null ? `${c.file}:${c.line}` : c.file;
34012
- const tags = [c.resolved && "resolved", c.outdated && "outdated"].filter(Boolean).join(", ");
34013
- return tags ? `### ${location} [${tags}]` : `### ${location}`;
34014
- }
34015
- function formatThread(thread) {
34016
- const lines2 = [
34017
- headerFor(thread.root),
34018
- `**${thread.root.author}**: ${thread.root.body.trim()}`,
34019
- ...thread.replies.map((r) => `**${r.author}** (reply): ${r.body.trim()}`)
34020
- ];
34021
- return lines2.join("\n\n");
34022
- }
34023
- var INTRO = `The PR already has the review comments below (including resolved and outdated threads). Avoid re-raising findings that a prior comment substantively covers.`;
34024
- function formatPriorComments(comments3) {
34025
- if (comments3.length === 0) return "";
34026
- const blocks = groupIntoThreads(comments3).map(formatThread);
34027
- return `## Prior review comments
34028
-
34029
- ${INTRO}
34030
-
34031
- ${blocks.join("\n\n")}`;
34032
- }
34033
-
34034
- // src/commands/review/buildRequest.ts
34035
- function formatFiles(files) {
34036
- if (files.length === 0) return "(none)";
34037
- return files.map((file) => `- ${file}`).join("\n");
34038
- }
34039
- function buildRequest(context, priorComments = null) {
34040
- const priorSection = priorComments ? formatPriorComments(priorComments) : "";
34041
- const priorBlock = priorSection ? `
34042
- ${priorSection}
34043
- ` : "";
34044
- return `# Code review request
34045
-
34046
- - PR: #${context.prNumber}
34047
- - Branch: \`${context.branch}\` (head ref: \`${context.headRef}\`)
34048
- - Base ref: \`${context.baseRef}\`
34049
- - Base SHA: \`${context.baseSha}\`
34050
- - Head SHA: \`${context.headSha}\`
34051
-
34052
- ## Changed files
34053
-
34054
- ${formatFiles(context.changedFiles)}
34055
- ${priorBlock}
34056
- ## Diff (PR #${context.prNumber}: ${context.baseSha}..${context.headSha})
34057
-
34058
- Each added or context line is prefixed with a left gutter showing its line number in the new file. When citing a finding as \`file:line\`, use that gutter number \u2014 do **not** count lines in this document. Removed lines (\`-\`) and headers have a blank gutter and cannot be commented on.
34059
-
34060
- \`\`\`diff
34061
- ${annotateDiffWithLineNumbers(context.diff.trimEnd())}
34062
- \`\`\`
34063
- `;
34064
- }
34065
-
34066
- // src/commands/review/buildReviewPaths.ts
34067
- import { homedir as homedir23 } from "os";
34068
- import { basename as basename20, join as join79 } from "path";
34069
- function buildReviewPaths(repoRoot2, key) {
34070
- const reviewDir = join79(
34071
- homedir23(),
34072
- ".assist",
34073
- "reviews",
34074
- basename20(repoRoot2),
34075
- key
34076
- );
34077
- return {
34078
- reviewDir,
34079
- requestPath: join79(reviewDir, "request.md"),
34080
- claudePath: join79(reviewDir, "claude.md"),
34081
- codexPath: join79(reviewDir, "codex.md"),
34082
- synthesisPath: join79(reviewDir, "synthesis.md")
34083
- };
34084
- }
34085
-
34086
- // src/commands/review/fetchExistingComments.ts
34087
- import { execSync as execSync57 } from "child_process";
34088
- function fetchRawComments(org, repo, prNumber) {
34089
- const out = execSync57(
34090
- `gh api --paginate repos/${org}/${repo}/pulls/${prNumber}/comments`,
34091
- { encoding: "utf8", maxBuffer: 64 * 1024 * 1024 }
34092
- );
34093
- if (!out.trim()) return [];
34094
- return JSON.parse(out);
34095
- }
34096
- function fetchExistingComments() {
34097
- const prNumber = findCurrentPrNumber();
34098
- if (prNumber === null) return null;
34099
- const { org, repo } = getRepoInfo();
34100
- const raw = fetchRawComments(org, repo, prNumber);
34101
- if (raw.length === 0) return [];
34102
- const threadInfo = fetchThreadIds(org, repo, prNumber);
34103
- return raw.map((c) => {
34104
- const threadId = threadInfo.threadMap.get(c.id) ?? "";
34105
- return {
34106
- id: c.id,
34107
- threadId,
34108
- file: c.path,
34109
- line: c.line ?? c.original_line ?? null,
34110
- author: c.user.login,
34111
- body: c.body,
34112
- inReplyToId: c.in_reply_to_id ?? null,
34113
- resolved: threadId !== "" && threadInfo.resolvedThreadIds.has(threadId),
34114
- outdated: c.position === null
34115
- };
34116
- });
34117
- }
34118
-
34119
33974
  // src/commands/review/gatherContext.ts
34120
- import { execSync as execSync60 } from "child_process";
33975
+ import { execSync as execSync59 } from "child_process";
34121
33976
 
34122
33977
  // src/commands/review/fetchPrDiff.ts
34123
- import { execSync as execSync58 } from "child_process";
33978
+ import { execSync as execSync57 } from "child_process";
34124
33979
  function fetchPrDiff(prNumber, baseSha, headSha) {
34125
33980
  const { org, repo } = getRepoInfo();
34126
33981
  try {
34127
- return execSync58(`gh pr diff ${prNumber} -R ${org}/${repo}`, {
33982
+ return execSync57(`gh pr diff ${prNumber} -R ${org}/${repo}`, {
34128
33983
  encoding: "utf8",
34129
33984
  maxBuffer: 256 * 1024 * 1024,
34130
33985
  stdio: ["ignore", "pipe", "pipe"]
@@ -34139,35 +33994,46 @@ function isDiffTooLarge(error) {
34139
33994
  }
34140
33995
  function fetchDiffViaGit(baseSha, headSha) {
34141
33996
  try {
34142
- execSync58(`git fetch origin ${baseSha} ${headSha}`, { stdio: "ignore" });
33997
+ execSync57(`git fetch origin ${baseSha} ${headSha}`, { stdio: "ignore" });
34143
33998
  } catch {
34144
33999
  }
34145
- return execSync58(`git diff ${baseSha}...${headSha}`, {
34000
+ return execSync57(`git diff ${baseSha}...${headSha}`, {
34146
34001
  encoding: "utf8",
34147
34002
  maxBuffer: 256 * 1024 * 1024
34148
34003
  });
34149
34004
  }
34150
34005
 
34151
34006
  // src/commands/review/fetchPrDiffInfo.ts
34152
- import { execSync as execSync59 } from "child_process";
34007
+ import { execSync as execSync58 } from "child_process";
34153
34008
  function getCurrentBranch3() {
34154
- return execSync59("git rev-parse --abbrev-ref HEAD", {
34009
+ return execSync58("git rev-parse --abbrev-ref HEAD", {
34155
34010
  encoding: "utf8"
34156
34011
  }).trim();
34157
34012
  }
34013
+ var FIELDS3 = "number,baseRefName,baseRefOid,headRefName,headRefOid";
34014
+ function runGh2(command) {
34015
+ return execSync58(command, {
34016
+ encoding: "utf8",
34017
+ stdio: ["ignore", "pipe", "pipe"]
34018
+ });
34019
+ }
34020
+ function fetchRawPr(org, repo, branch2) {
34021
+ const pinned = getPinnedPr();
34022
+ if (pinned !== void 0)
34023
+ return JSON.parse(
34024
+ runGh2(`gh pr view ${pinned} --json ${FIELDS3} -R ${org}/${repo}`)
34025
+ );
34026
+ const parsed = JSON.parse(
34027
+ runGh2(
34028
+ `gh pr list --state open --head ${branch2} --json ${FIELDS3} -R ${org}/${repo}`
34029
+ )
34030
+ );
34031
+ return parsed[0];
34032
+ }
34158
34033
  function fetchPrDiffInfo() {
34159
34034
  const { org, repo } = getRepoInfo();
34160
34035
  const branch2 = getCurrentBranch3();
34161
- const fields = "number,baseRefName,baseRefOid,headRefName,headRefOid";
34162
- const raw = execSync59(
34163
- `gh pr list --state open --head ${branch2} --json ${fields} -R ${org}/${repo}`,
34164
- {
34165
- encoding: "utf8",
34166
- stdio: ["ignore", "pipe", "pipe"]
34167
- }
34168
- );
34169
- const parsed = JSON.parse(raw);
34170
- const pr = parsed[0];
34036
+ const pr = fetchRawPr(org, repo, branch2);
34171
34037
  if (!pr) {
34172
34038
  console.error(
34173
34039
  `Error: No open pull request found for branch \`${branch2}\`. Open a PR for this branch before running \`assist review\`.`
@@ -34184,7 +34050,7 @@ function fetchPrDiffInfo() {
34184
34050
  }
34185
34051
  function fetchPrChangedFiles(prNumber) {
34186
34052
  const { org, repo } = getRepoInfo();
34187
- const out = execSync59(
34053
+ const out = execSync58(
34188
34054
  `gh api repos/${org}/${repo}/pulls/${prNumber}/files --paginate --jq ".[].filename"`,
34189
34055
  {
34190
34056
  encoding: "utf8",
@@ -34196,11 +34062,11 @@ function fetchPrChangedFiles(prNumber) {
34196
34062
 
34197
34063
  // src/commands/review/gatherContext.ts
34198
34064
  function gatherContext() {
34199
- const branch2 = execSync60("git rev-parse --abbrev-ref HEAD", {
34065
+ const branch2 = execSync59("git rev-parse --abbrev-ref HEAD", {
34200
34066
  encoding: "utf8"
34201
34067
  }).trim();
34202
- const sha = execSync60("git rev-parse HEAD", { encoding: "utf8" }).trim();
34203
- const shortSha = execSync60("git rev-parse --short=7 HEAD", {
34068
+ const sha = execSync59("git rev-parse HEAD", { encoding: "utf8" }).trim();
34069
+ const shortSha = execSync59("git rev-parse --short=7 HEAD", {
34204
34070
  encoding: "utf8"
34205
34071
  }).trim();
34206
34072
  const prInfo = fetchPrDiffInfo();
@@ -34506,19 +34372,19 @@ function partitionFindings(findings) {
34506
34372
  }
34507
34373
 
34508
34374
  // src/commands/review/buildDiffLineIndex.ts
34509
- var FILE_HEADER2 = /^\+\+\+ (?:b\/)?(.+)$/;
34510
- var HUNK_HEADER2 = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/;
34375
+ var FILE_HEADER = /^\+\+\+ (?:b\/)?(.+)$/;
34376
+ var HUNK_HEADER = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/;
34511
34377
  function buildDiffLineIndex(diff3) {
34512
34378
  const index3 = /* @__PURE__ */ new Map();
34513
34379
  let currentFile = null;
34514
34380
  let newLine = 0;
34515
34381
  for (const line of diff3.split("\n")) {
34516
- const fileMatch = line.match(FILE_HEADER2);
34382
+ const fileMatch = line.match(FILE_HEADER);
34517
34383
  if (fileMatch) {
34518
34384
  currentFile = fileMatch[1] === "/dev/null" ? null : fileMatch[1];
34519
34385
  continue;
34520
34386
  }
34521
- const hunkMatch = line.match(HUNK_HEADER2);
34387
+ const hunkMatch = line.match(HUNK_HEADER);
34522
34388
  if (hunkMatch) {
34523
34389
  newLine = Number(hunkMatch[1]);
34524
34390
  continue;
@@ -34807,19 +34673,6 @@ async function handlePostSynthesis(synthesisPath, prInfo, options2) {
34807
34673
  if (options2.announce) await announcePr(prInfo.prNumber);
34808
34674
  }
34809
34675
 
34810
- // src/commands/review/prepareReviewDir.ts
34811
- import { existsSync as existsSync65, mkdirSync as mkdirSync23, unlinkSync as unlinkSync18, writeFileSync as writeFileSync40 } from "fs";
34812
- function clearReviewFiles(paths) {
34813
- for (const path106 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
34814
- if (existsSync65(path106)) unlinkSync18(path106);
34815
- }
34816
- }
34817
- function prepareReviewDir(paths, requestBody, force) {
34818
- mkdirSync23(paths.reviewDir, { recursive: true });
34819
- if (force) clearReviewFiles(paths);
34820
- writeFileSync40(paths.requestPath, requestBody);
34821
- }
34822
-
34823
34676
  // src/commands/review/cachedReviewerResult.ts
34824
34677
  import { statSync as statSync11 } from "fs";
34825
34678
  function cachedReviewerResult(name, outputPath) {
@@ -34872,8 +34725,8 @@ function renderEntry(entry, frame) {
34872
34725
  import { format } from "util";
34873
34726
 
34874
34727
  // src/commands/review/createReviewLogSink.ts
34875
- import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync24 } from "fs";
34876
- import { join as join80 } from "path";
34728
+ import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync23 } from "fs";
34729
+ import { join as join79 } from "path";
34877
34730
 
34878
34731
  // src/shared/stripAnsi.ts
34879
34732
  var ANSI = new RegExp(
@@ -34900,8 +34753,8 @@ function createReviewLogSink() {
34900
34753
  `);
34901
34754
  },
34902
34755
  attach(reviewDir) {
34903
- mkdirSync24(reviewDir, { recursive: true });
34904
- logPath2 = join80(reviewDir, LOG_FILE);
34756
+ mkdirSync23(reviewDir, { recursive: true });
34757
+ logPath2 = join79(reviewDir, LOG_FILE);
34905
34758
  const lines2 = [
34906
34759
  "",
34907
34760
  `=== ${(/* @__PURE__ */ new Date()).toISOString()} ===`,
@@ -35115,7 +34968,7 @@ function printReviewerFailures(results) {
35115
34968
  }
35116
34969
 
35117
34970
  // src/commands/review/runAndSynthesise.ts
35118
- import { existsSync as existsSync67, unlinkSync as unlinkSync20 } from "fs";
34971
+ import { existsSync as existsSync66, unlinkSync as unlinkSync19 } from "fs";
35119
34972
 
35120
34973
  // src/commands/review/buildReviewerStdin.ts
35121
34974
  var REVIEW_PROMPT = `You are acting as a reviewer for a proposed code change made by another engineer. The full review request \u2014 branch, base, changed files, and unified diff \u2014 is in the request file whose absolute path is given below.
@@ -35190,7 +35043,7 @@ The review request is at: ${requestPath}
35190
35043
  }
35191
35044
 
35192
35045
  // src/commands/review/runClaudeReviewer.ts
35193
- import { writeFileSync as writeFileSync41 } from "fs";
35046
+ import { writeFileSync as writeFileSync40 } from "fs";
35194
35047
 
35195
35048
  // src/commands/review/finaliseReviewerSpinner.ts
35196
35049
  var SUMMARY_MAX_LEN = 80;
@@ -35511,46 +35364,56 @@ function runStreamingChild(spec) {
35511
35364
  // src/commands/review/runClaudeReviewer.ts
35512
35365
  async function runClaudeReviewer(spec) {
35513
35366
  let finalText = "";
35514
- const { spinner } = spec;
35367
+ const { spinner, override } = spec;
35515
35368
  const command = "claude";
35516
35369
  const result = await runStreamingChild({
35517
35370
  name: spec.name,
35518
35371
  command,
35372
+ model: override?.model,
35519
35373
  args: [
35520
35374
  "-p",
35521
35375
  "--add-dir",
35522
35376
  spec.reviewDir,
35523
35377
  "--output-format",
35524
35378
  "stream-json",
35525
- "--verbose"
35379
+ "--verbose",
35380
+ ...override?.args ?? []
35526
35381
  ],
35527
35382
  stdin: spec.stdin,
35528
35383
  quiet: Boolean(spinner),
35384
+ ...override ? { env: override.env } : {},
35529
35385
  onLine: (line) => {
35530
35386
  const event = parseClaudeEvent(line);
35531
35387
  if (event.kind === "tool_uses") {
35532
35388
  for (const use of event.toolUses)
35533
- reportReviewerToolUse(spec.name, use, spinner);
35389
+ reportReviewerToolUse(spec.name, use, spinner, override?.model);
35534
35390
  return;
35535
35391
  }
35536
35392
  if (event.kind === "final") finalText = event.text;
35537
35393
  }
35538
35394
  });
35539
35395
  if (result.exitCode === 0 && finalText)
35540
- writeFileSync41(spec.outputPath, finalText);
35541
- return finaliseReviewerRun({ ...spec, command }, spinner, result);
35396
+ writeFileSync40(spec.outputPath, finalText);
35397
+ return finaliseReviewerRun(
35398
+ { ...spec, command, model: override?.model },
35399
+ spinner,
35400
+ result
35401
+ );
35542
35402
  }
35543
35403
 
35544
35404
  // src/commands/review/resolveClaude.ts
35545
35405
  function resolveClaude(args) {
35546
35406
  if (args.cached) return Promise.resolve(args.cached);
35547
- const spinner = args.multi?.create("claude \u2014 starting");
35407
+ const spinner = args.multi?.create(
35408
+ `${reviewerLabel("claude", args.override?.model)} \u2014 starting`
35409
+ );
35548
35410
  return runClaudeReviewer({
35549
35411
  name: "claude",
35550
35412
  reviewDir: args.reviewDir,
35551
35413
  stdin: args.stdin,
35552
35414
  outputPath: args.claudePath,
35553
- spinner
35415
+ spinner,
35416
+ override: args.override
35554
35417
  });
35555
35418
  }
35556
35419
 
@@ -35560,7 +35423,7 @@ function buildCodexModelArgs() {
35560
35423
  }
35561
35424
 
35562
35425
  // src/commands/review/runCodexReviewer.ts
35563
- import { existsSync as existsSync66, unlinkSync as unlinkSync19 } from "fs";
35426
+ import { existsSync as existsSync65, unlinkSync as unlinkSync18 } from "fs";
35564
35427
 
35565
35428
  // src/commands/review/parseCodexEvent.ts
35566
35429
  function isItemStarted(value) {
@@ -35615,8 +35478,8 @@ async function runCodexReviewer(spec) {
35615
35478
  reportReviewerToolUse(spec.name, event, spinner, override.model);
35616
35479
  }
35617
35480
  });
35618
- if (result.exitCode !== 0 && existsSync66(spec.outputPath)) {
35619
- unlinkSync19(spec.outputPath);
35481
+ if (result.exitCode !== 0 && existsSync65(spec.outputPath)) {
35482
+ unlinkSync18(spec.outputPath);
35620
35483
  }
35621
35484
  return finaliseReviewerRun(
35622
35485
  {
@@ -35636,7 +35499,7 @@ function resolveCodex(args) {
35636
35499
  if (args.plan.kind === "skipped") {
35637
35500
  return Promise.resolve(skippedCodexResult(args.codexPath));
35638
35501
  }
35639
- const override = buildCodexModelArgs();
35502
+ const override = args.override ?? buildCodexModelArgs();
35640
35503
  const spinner = args.multi?.create(
35641
35504
  `${reviewerLabel("codex", override.model)} \u2014 starting`
35642
35505
  );
@@ -35656,13 +35519,15 @@ async function runReviewers(reviewDir, claudePath, codexPath, stdinPrompt, optio
35656
35519
  claudePath,
35657
35520
  stdin: stdinPrompt,
35658
35521
  cached: options2.cachedClaude,
35659
- multi: options2.multi
35522
+ multi: options2.multi,
35523
+ override: options2.models.claude
35660
35524
  });
35661
35525
  const codexPromise = resolveCodex({
35662
35526
  codexPath,
35663
35527
  stdin: stdinPrompt,
35664
35528
  plan: options2.codexPlan,
35665
- multi: options2.multi
35529
+ multi: options2.multi,
35530
+ override: options2.models.codex
35666
35531
  });
35667
35532
  const results = await Promise.all([claudePromise, codexPromise]);
35668
35533
  const anyFresh = options2.cachedClaude === null || options2.codexPlan.kind !== "cached";
@@ -35746,9 +35611,9 @@ async function synthesise(paths, options2) {
35746
35611
  printSummary2(paths.synthesisPath);
35747
35612
  return cached;
35748
35613
  }
35749
- const { multi } = options2;
35614
+ const { multi, override } = options2;
35750
35615
  const spinner = multi?.create(
35751
- "synthesis \u2014 starting"
35616
+ `${reviewerLabel("synthesis", override?.model)} \u2014 starting`
35752
35617
  );
35753
35618
  const result = await runClaudeReviewer({
35754
35619
  name: "synthesis",
@@ -35759,12 +35624,22 @@ async function synthesise(paths, options2) {
35759
35624
  paths.codexPath
35760
35625
  ),
35761
35626
  outputPath: paths.synthesisPath,
35762
- spinner
35627
+ spinner,
35628
+ override
35763
35629
  });
35764
35630
  if (result.exitCode === 0) printSummary2(paths.synthesisPath);
35765
35631
  return result;
35766
35632
  }
35767
35633
 
35634
+ // src/commands/review/skipReason.ts
35635
+ function skipReason(results, failures, strict) {
35636
+ if (failures.length === results.length)
35637
+ return "Both reviewers failed; skipping synthesis.";
35638
+ if (strict && failures.length > 0)
35639
+ return "A reviewer failed; skipping synthesis.";
35640
+ return void 0;
35641
+ }
35642
+
35768
35643
  // src/commands/review/runAndSynthesise.ts
35769
35644
  function failed(results) {
35770
35645
  return results.filter((r) => r.exitCode !== 0);
@@ -35776,17 +35651,26 @@ async function runAndSynthesise(args) {
35776
35651
  paths.claudePath,
35777
35652
  paths.codexPath,
35778
35653
  buildReviewerStdin(paths.requestPath),
35779
- { multi, codexPlan: args.codexPlan, cachedClaude: args.cachedClaude }
35654
+ {
35655
+ multi,
35656
+ codexPlan: args.codexPlan,
35657
+ cachedClaude: args.cachedClaude,
35658
+ models: args.models
35659
+ }
35780
35660
  );
35781
35661
  const failures = failed(results);
35782
- if (results.every((r) => r.exitCode !== 0)) {
35783
- console.error("Both reviewers failed; skipping synthesis.");
35662
+ const reason4 = skipReason(results, failures, args.strict);
35663
+ if (reason4) {
35664
+ console.error(reason4);
35784
35665
  return { ok: false, failures };
35785
35666
  }
35786
- if (anyFresh && existsSync67(paths.synthesisPath)) {
35787
- unlinkSync20(paths.synthesisPath);
35667
+ if (anyFresh && existsSync66(paths.synthesisPath)) {
35668
+ unlinkSync19(paths.synthesisPath);
35788
35669
  }
35789
- const synthesisResult = await synthesise(paths, { multi });
35670
+ const synthesisResult = await synthesise(paths, {
35671
+ multi,
35672
+ override: args.models.claude
35673
+ });
35790
35674
  if (synthesisResult.exitCode !== 0) failures.push(synthesisResult);
35791
35675
  return { ok: synthesisResult.exitCode === 0, failures };
35792
35676
  }
@@ -35825,7 +35709,9 @@ async function runReviewPipeline(paths, options2) {
35825
35709
  paths,
35826
35710
  cachedClaude,
35827
35711
  codexPlan,
35828
- multi: ui.multi
35712
+ multi: ui.multi,
35713
+ models: options2.models ?? {},
35714
+ strict: options2.strict ?? false
35829
35715
  });
35830
35716
  finishUi(ui, outcome.ok);
35831
35717
  reportFailures(outcome.failures, ui.multi !== void 0);
@@ -35836,19 +35722,185 @@ async function runReviewPipeline(paths, options2) {
35836
35722
  }
35837
35723
  }
35838
35724
 
35839
- // src/commands/review/reviewPr.ts
35840
- function logPriorComments(count8) {
35841
- if (count8 === 0) return;
35842
- console.log(`Including ${count8} prior review comment(s) in request.md.`);
35725
+ // src/commands/review/annotateDiffWithLineNumbers.ts
35726
+ var FILE_HEADER2 = /^\+\+\+ (?:b\/)?(.+)$/;
35727
+ var HUNK_HEADER2 = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/;
35728
+ var GUTTER_WIDTH = 6;
35729
+ function gutter(lineNumber) {
35730
+ const label2 = lineNumber === null ? "" : String(lineNumber);
35731
+ return `${label2.padStart(GUTTER_WIDTH, " ")} `;
35843
35732
  }
35844
- function gatherChangedContext() {
35845
- const context = gatherContext();
35846
- if (context.changedFiles.length > 0) return context;
35847
- console.error(
35848
- `Error: PR #${context.prNumber} has no changed files \u2014 nothing to review.`
35733
+ function annotateDiffWithLineNumbers(diff3) {
35734
+ let inFile = false;
35735
+ let newLine = 0;
35736
+ return diff3.split("\n").map((line) => {
35737
+ if (FILE_HEADER2.test(line)) {
35738
+ inFile = true;
35739
+ return gutter(null) + line;
35740
+ }
35741
+ const hunkMatch = line.match(HUNK_HEADER2);
35742
+ if (hunkMatch) {
35743
+ newLine = Number(hunkMatch[1]);
35744
+ return gutter(null) + line;
35745
+ }
35746
+ if (!inFile) return gutter(null) + line;
35747
+ if (line.startsWith("+") || line.startsWith(" ")) {
35748
+ const annotated = gutter(newLine) + line;
35749
+ newLine++;
35750
+ return annotated;
35751
+ }
35752
+ return gutter(null) + line;
35753
+ }).join("\n");
35754
+ }
35755
+
35756
+ // src/commands/review/formatPriorComments.ts
35757
+ function threadKey(c, byId) {
35758
+ if (c.threadId) return c.threadId;
35759
+ if (c.inReplyToId !== null && byId.has(c.inReplyToId)) {
35760
+ return `root-${c.inReplyToId}`;
35761
+ }
35762
+ return `root-${c.id}`;
35763
+ }
35764
+ function groupIntoThreads(comments3) {
35765
+ const byId = new Map(comments3.map((c) => [c.id, c]));
35766
+ const threads = /* @__PURE__ */ new Map();
35767
+ for (const c of comments3) {
35768
+ const key = threadKey(c, byId);
35769
+ const existing = threads.get(key);
35770
+ const parent = c.inReplyToId !== null ? byId.get(c.inReplyToId) : void 0;
35771
+ if (existing) {
35772
+ if (parent) existing.replies.push(c);
35773
+ } else if (parent) {
35774
+ threads.set(key, { root: parent, replies: [c] });
35775
+ } else {
35776
+ threads.set(key, { root: c, replies: [] });
35777
+ }
35778
+ }
35779
+ return [...threads.values()];
35780
+ }
35781
+ function headerFor(c) {
35782
+ const location = c.line !== null ? `${c.file}:${c.line}` : c.file;
35783
+ const tags = [c.resolved && "resolved", c.outdated && "outdated"].filter(Boolean).join(", ");
35784
+ return tags ? `### ${location} [${tags}]` : `### ${location}`;
35785
+ }
35786
+ function formatThread(thread) {
35787
+ const lines2 = [
35788
+ headerFor(thread.root),
35789
+ `**${thread.root.author}**: ${thread.root.body.trim()}`,
35790
+ ...thread.replies.map((r) => `**${r.author}** (reply): ${r.body.trim()}`)
35791
+ ];
35792
+ return lines2.join("\n\n");
35793
+ }
35794
+ var INTRO = `The PR already has the review comments below (including resolved and outdated threads). Avoid re-raising findings that a prior comment substantively covers.`;
35795
+ function formatPriorComments(comments3) {
35796
+ if (comments3.length === 0) return "";
35797
+ const blocks = groupIntoThreads(comments3).map(formatThread);
35798
+ return `## Prior review comments
35799
+
35800
+ ${INTRO}
35801
+
35802
+ ${blocks.join("\n\n")}`;
35803
+ }
35804
+
35805
+ // src/commands/review/buildRequest.ts
35806
+ function formatFiles(files) {
35807
+ if (files.length === 0) return "(none)";
35808
+ return files.map((file) => `- ${file}`).join("\n");
35809
+ }
35810
+ function buildRequest(context, priorComments = null) {
35811
+ const priorSection = priorComments ? formatPriorComments(priorComments) : "";
35812
+ const priorBlock = priorSection ? `
35813
+ ${priorSection}
35814
+ ` : "";
35815
+ return `# Code review request
35816
+
35817
+ - PR: #${context.prNumber}
35818
+ - Branch: \`${context.branch}\` (head ref: \`${context.headRef}\`)
35819
+ - Base ref: \`${context.baseRef}\`
35820
+ - Base SHA: \`${context.baseSha}\`
35821
+ - Head SHA: \`${context.headSha}\`
35822
+
35823
+ ## Changed files
35824
+
35825
+ ${formatFiles(context.changedFiles)}
35826
+ ${priorBlock}
35827
+ ## Diff (PR #${context.prNumber}: ${context.baseSha}..${context.headSha})
35828
+
35829
+ Each added or context line is prefixed with a left gutter showing its line number in the new file. When citing a finding as \`file:line\`, use that gutter number \u2014 do **not** count lines in this document. Removed lines (\`-\`) and headers have a blank gutter and cannot be commented on.
35830
+
35831
+ \`\`\`diff
35832
+ ${annotateDiffWithLineNumbers(context.diff.trimEnd())}
35833
+ \`\`\`
35834
+ `;
35835
+ }
35836
+
35837
+ // src/commands/review/buildReviewPaths.ts
35838
+ import { homedir as homedir23 } from "os";
35839
+ import { basename as basename20, join as join80 } from "path";
35840
+ function buildReviewPaths(repoRoot2, key) {
35841
+ const reviewDir = join80(
35842
+ homedir23(),
35843
+ ".assist",
35844
+ "reviews",
35845
+ basename20(repoRoot2),
35846
+ key
35849
35847
  );
35850
- process.exit(1);
35848
+ return {
35849
+ reviewDir,
35850
+ requestPath: join80(reviewDir, "request.md"),
35851
+ claudePath: join80(reviewDir, "claude.md"),
35852
+ codexPath: join80(reviewDir, "codex.md"),
35853
+ synthesisPath: join80(reviewDir, "synthesis.md")
35854
+ };
35855
+ }
35856
+
35857
+ // src/commands/review/fetchExistingComments.ts
35858
+ import { execSync as execSync60 } from "child_process";
35859
+ function fetchRawComments(org, repo, prNumber) {
35860
+ const out = execSync60(
35861
+ `gh api --paginate repos/${org}/${repo}/pulls/${prNumber}/comments`,
35862
+ { encoding: "utf8", maxBuffer: 64 * 1024 * 1024 }
35863
+ );
35864
+ if (!out.trim()) return [];
35865
+ return JSON.parse(out);
35866
+ }
35867
+ function fetchExistingComments() {
35868
+ const prNumber = findCurrentPrNumber();
35869
+ if (prNumber === null) return null;
35870
+ const { org, repo } = getRepoInfo();
35871
+ const raw = fetchRawComments(org, repo, prNumber);
35872
+ if (raw.length === 0) return [];
35873
+ const threadInfo = fetchThreadIds(org, repo, prNumber);
35874
+ return raw.map((c) => {
35875
+ const threadId = threadInfo.threadMap.get(c.id) ?? "";
35876
+ return {
35877
+ id: c.id,
35878
+ threadId,
35879
+ file: c.path,
35880
+ line: c.line ?? c.original_line ?? null,
35881
+ author: c.user.login,
35882
+ body: c.body,
35883
+ inReplyToId: c.in_reply_to_id ?? null,
35884
+ resolved: threadId !== "" && threadInfo.resolvedThreadIds.has(threadId),
35885
+ outdated: c.position === null
35886
+ };
35887
+ });
35888
+ }
35889
+
35890
+ // src/commands/review/prepareReviewDir.ts
35891
+ import { existsSync as existsSync67, mkdirSync as mkdirSync24, unlinkSync as unlinkSync20, writeFileSync as writeFileSync41 } from "fs";
35892
+ function clearReviewFiles(paths) {
35893
+ for (const path106 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
35894
+ if (existsSync67(path106)) unlinkSync20(path106);
35895
+ }
35896
+ }
35897
+ function prepareReviewDir(paths, requestBody, force) {
35898
+ mkdirSync24(paths.reviewDir, { recursive: true });
35899
+ if (force) clearReviewFiles(paths);
35900
+ writeFileSync41(paths.requestPath, requestBody);
35851
35901
  }
35902
+
35903
+ // src/commands/review/setupReviewDir.ts
35852
35904
  function setupReviewDir(repoRoot2, context, force) {
35853
35905
  const paths = buildReviewPaths(
35854
35906
  repoRoot2,
@@ -35860,6 +35912,20 @@ function setupReviewDir(repoRoot2, context, force) {
35860
35912
  console.log(`Review folder: ${paths.reviewDir}`);
35861
35913
  return paths;
35862
35914
  }
35915
+ function logPriorComments(count8) {
35916
+ if (count8 === 0) return;
35917
+ console.log(`Including ${count8} prior review comment(s) in request.md.`);
35918
+ }
35919
+
35920
+ // src/commands/review/reviewPr.ts
35921
+ function gatherChangedContext() {
35922
+ const context = gatherContext();
35923
+ if (context.changedFiles.length > 0) return context;
35924
+ console.error(
35925
+ `Error: PR #${context.prNumber} has no changed files \u2014 nothing to review.`
35926
+ );
35927
+ process.exit(1);
35928
+ }
35863
35929
  function runPostSynthesis(synthesisPath, prInfo, options2) {
35864
35930
  return handlePostSynthesis(synthesisPath, prInfo, {
35865
35931
  refine: options2.refine ?? false,
@@ -35876,8 +35942,14 @@ async function reviewPr(repoRoot2, options2) {
35876
35942
  const paths = setupReviewDir(repoRoot2, context, options2.force ?? false);
35877
35943
  attachReviewLog(paths.reviewDir);
35878
35944
  const synthesisOk = await runReviewPipeline(paths, {
35879
- verbose: options2.verbose ?? false
35945
+ verbose: options2.verbose ?? false,
35946
+ models: options2.ci?.models,
35947
+ strict: options2.ci !== void 0
35880
35948
  });
35949
+ if (!synthesisOk && options2.ci) {
35950
+ console.error("Review failed; nothing was posted.");
35951
+ process.exit(1);
35952
+ }
35881
35953
  if (synthesisOk)
35882
35954
  await runPostSynthesis(paths.synthesisPath, context, options2);
35883
35955
  console.log(`Done. Review folder: ${paths.reviewDir}`);
@@ -37414,14 +37486,18 @@ function syncDesign(claudeDir, targetBase) {
37414
37486
  const skillsSource = path95.join(claudeDir, "skills");
37415
37487
  const skillsTarget = path95.join(targetBase, "skills");
37416
37488
  fs45.mkdirSync(skillsTarget, { recursive: true });
37417
- const files = fs45.readdirSync(skillsSource);
37418
- for (const file of files) {
37419
- fs45.copyFileSync(
37420
- path95.join(skillsSource, file),
37421
- path95.join(skillsTarget, file)
37422
- );
37489
+ const entries = fs45.readdirSync(skillsSource, { withFileTypes: true });
37490
+ for (const entry of entries) {
37491
+ const source = path95.join(skillsSource, entry.name);
37492
+ const target = path95.join(skillsTarget, entry.name);
37493
+ if (entry.isDirectory()) {
37494
+ fs45.rmSync(target, { recursive: true, force: true });
37495
+ fs45.cpSync(source, target, { recursive: true });
37496
+ } else {
37497
+ fs45.copyFileSync(source, target);
37498
+ }
37423
37499
  }
37424
- console.log(`Synced ${files.length} design skill(s) to ~/.claude/skills`);
37500
+ console.log(`Synced ${entries.length} skill(s) to ~/.claude/skills`);
37425
37501
  }
37426
37502
 
37427
37503
  // src/commands/sync/syncPi.ts