drizzy-agent 0.7.3 → 0.8.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
@@ -11572,7 +11572,7 @@ var require_parse2 = __commonJS((exports, module) => {
11572
11572
  var resolveCommand = require_resolveCommand();
11573
11573
  var escape2 = require_escape();
11574
11574
  var readShebang = require_readShebang();
11575
- var isWin = process.platform === "win32";
11575
+ var isWin2 = process.platform === "win32";
11576
11576
  var isExecutableRegExp = /\.(?:com|exe)$/i;
11577
11577
  var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
11578
11578
  function detectShebang(parsed) {
@@ -11586,7 +11586,7 @@ var require_parse2 = __commonJS((exports, module) => {
11586
11586
  return parsed.file;
11587
11587
  }
11588
11588
  function parseNonShell(parsed) {
11589
- if (!isWin) {
11589
+ if (!isWin2) {
11590
11590
  return parsed;
11591
11591
  }
11592
11592
  const commandFile = detectShebang(parsed);
@@ -11627,7 +11627,7 @@ var require_parse2 = __commonJS((exports, module) => {
11627
11627
 
11628
11628
  // node_modules/cross-spawn/lib/enoent.js
11629
11629
  var require_enoent = __commonJS((exports, module) => {
11630
- var isWin = process.platform === "win32";
11630
+ var isWin2 = process.platform === "win32";
11631
11631
  function notFoundError(original, syscall) {
11632
11632
  return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
11633
11633
  code: "ENOENT",
@@ -11638,7 +11638,7 @@ var require_enoent = __commonJS((exports, module) => {
11638
11638
  });
11639
11639
  }
11640
11640
  function hookChildProcess(cp, parsed) {
11641
- if (!isWin) {
11641
+ if (!isWin2) {
11642
11642
  return;
11643
11643
  }
11644
11644
  const originalEmit = cp.emit;
@@ -11653,13 +11653,13 @@ var require_enoent = __commonJS((exports, module) => {
11653
11653
  };
11654
11654
  }
11655
11655
  function verifyENOENT(status, parsed) {
11656
- if (isWin && status === 1 && !parsed.file) {
11656
+ if (isWin2 && status === 1 && !parsed.file) {
11657
11657
  return notFoundError(parsed.original, "spawn");
11658
11658
  }
11659
11659
  return null;
11660
11660
  }
11661
11661
  function verifyENOENTSync(status, parsed) {
11662
- if (isWin && status === 1 && !parsed.file) {
11662
+ if (isWin2 && status === 1 && !parsed.file) {
11663
11663
  return notFoundError(parsed.original, "spawnSync");
11664
11664
  }
11665
11665
  return null;
@@ -16727,6 +16727,7 @@ var AGENT_MODEL_DEFAULTS = {
16727
16727
  librarian: {
16728
16728
  chain: [
16729
16729
  { providers: GEMINI_PROVIDERS, model: "gemini-3-flash" },
16730
+ { providers: OPENAI_NATIVE_PROVIDERS, model: "gpt-5.4-mini", variant: "low" },
16730
16731
  { providers: ["opencode"], model: "glm-4.7" },
16731
16732
  { providers: CLAUDE_PROVIDERS, model: "claude-sonnet-4-5" },
16732
16733
  { providers: ["opencode"], model: "minimax-m2.5-free", alwaysAvailable: true },
@@ -16743,6 +16744,7 @@ var AGENT_MODEL_DEFAULTS = {
16743
16744
  explore: {
16744
16745
  chain: [
16745
16746
  { providers: ["github-copilot"], model: "grok-code-fast-1" },
16747
+ { providers: OPENAI_NATIVE_PROVIDERS, model: "gpt-5.4-mini", variant: "low" },
16746
16748
  { providers: ["anthropic", "opencode"], model: "claude-haiku-4-5" },
16747
16749
  { providers: ["opencode"], model: "minimax-m2.5-free", alwaysAvailable: true },
16748
16750
  { providers: ["opencode"], model: "gpt-5-nano", alwaysAvailable: true }
@@ -16953,6 +16955,46 @@ function excludeFallbackEntries(chain, models) {
16953
16955
  const excludedModels = new Set(models);
16954
16956
  return chain.filter((entry) => !excludedModels.has(entry.model));
16955
16957
  }
16958
+
16959
+ // src/shared/user-message-variant.ts
16960
+ function getModelRecord(message) {
16961
+ const model = message["model"];
16962
+ if (typeof model !== "object" || model === null) {
16963
+ return;
16964
+ }
16965
+ return model;
16966
+ }
16967
+ function getOrCreateModelRecord(message) {
16968
+ const existingModel = getModelRecord(message);
16969
+ if (existingModel) {
16970
+ return existingModel;
16971
+ }
16972
+ const model = {};
16973
+ message["model"] = model;
16974
+ return model;
16975
+ }
16976
+ function getUserMessageVariant(message) {
16977
+ const model = getModelRecord(message);
16978
+ if (typeof model?.["variant"] === "string") {
16979
+ return model["variant"];
16980
+ }
16981
+ return typeof message["variant"] === "string" ? message["variant"] : undefined;
16982
+ }
16983
+ function setUserMessageVariant(message, variant) {
16984
+ const model = getOrCreateModelRecord(message);
16985
+ model["variant"] = variant;
16986
+ delete message["variant"];
16987
+ }
16988
+ function clearUserMessageVariant(message) {
16989
+ const model = getModelRecord(message);
16990
+ if (model) {
16991
+ delete model["variant"];
16992
+ }
16993
+ delete message["variant"];
16994
+ }
16995
+ function getInputVariant(input) {
16996
+ return input.model?.variant ?? input.variant;
16997
+ }
16956
16998
  // src/shared/session-cursor.ts
16957
16999
  var sessionCursors = new Map;
16958
17000
  function buildMessageKey(message, index) {
@@ -17692,7 +17734,7 @@ function convertSDKMessageToStoredMessage(msg) {
17692
17734
  return null;
17693
17735
  const providerID = info.model?.providerID ?? info.providerID;
17694
17736
  const modelID = info.model?.modelID ?? info.modelID;
17695
- const variant = info.model?.variant;
17737
+ const variant = info.model?.variant ?? info.variant;
17696
17738
  if (!info.agent && !providerID && !modelID) {
17697
17739
  return null;
17698
17740
  }
@@ -18276,11 +18318,31 @@ function parseModelSuggestion(error) {
18276
18318
  }
18277
18319
  return null;
18278
18320
  }
18321
+ function normalizePromptBody(body) {
18322
+ if (typeof body.variant !== "string") {
18323
+ return body;
18324
+ }
18325
+ const { variant, model, ...rest } = body;
18326
+ return {
18327
+ ...rest,
18328
+ model: {
18329
+ ...model ?? {},
18330
+ variant
18331
+ }
18332
+ };
18333
+ }
18334
+ function normalizePromptArgs(args) {
18335
+ return {
18336
+ ...args,
18337
+ body: normalizePromptBody(args.body)
18338
+ };
18339
+ }
18279
18340
  async function promptWithModelSuggestionRetry(client, args, options = {}) {
18341
+ const normalizedArgs = normalizePromptArgs(args);
18280
18342
  const timeoutMs = options.timeoutMs ?? PROMPT_TIMEOUT_MS;
18281
- const timeoutContext = createPromptTimeoutContext(args, timeoutMs);
18343
+ const timeoutContext = createPromptTimeoutContext(normalizedArgs, timeoutMs);
18282
18344
  const promptPromise = client.session.promptAsync({
18283
- ...args,
18345
+ ...normalizedArgs,
18284
18346
  signal: timeoutContext.signal
18285
18347
  });
18286
18348
  try {
@@ -18298,12 +18360,13 @@ async function promptWithModelSuggestionRetry(client, args, options = {}) {
18298
18360
  }
18299
18361
  }
18300
18362
  async function promptSyncWithModelSuggestionRetry(client, args, options = {}) {
18363
+ const normalizedArgs = normalizePromptArgs(args);
18301
18364
  const timeoutMs = options.timeoutMs ?? PROMPT_TIMEOUT_MS;
18302
18365
  try {
18303
- const timeoutContext = createPromptTimeoutContext(args, timeoutMs);
18366
+ const timeoutContext = createPromptTimeoutContext(normalizedArgs, timeoutMs);
18304
18367
  try {
18305
18368
  await client.session.prompt({
18306
- ...args,
18369
+ ...normalizedArgs,
18307
18370
  signal: timeoutContext.signal
18308
18371
  });
18309
18372
  if (timeoutContext.wasTimedOut()) {
@@ -18319,7 +18382,7 @@ async function promptSyncWithModelSuggestionRetry(client, args, options = {}) {
18319
18382
  }
18320
18383
  } catch (error) {
18321
18384
  const suggestion = parseModelSuggestion(error);
18322
- if (!suggestion || !args.body.model) {
18385
+ if (!suggestion || !normalizedArgs.body.model) {
18323
18386
  throw error;
18324
18387
  }
18325
18388
  log("[model-suggestion-retry] Model not found, retrying with suggestion", {
@@ -18327,12 +18390,13 @@ async function promptSyncWithModelSuggestionRetry(client, args, options = {}) {
18327
18390
  suggested: suggestion.suggestion
18328
18391
  });
18329
18392
  const retryArgs = {
18330
- ...args,
18393
+ ...normalizedArgs,
18331
18394
  body: {
18332
- ...args.body,
18395
+ ...normalizedArgs.body,
18333
18396
  model: {
18334
18397
  providerID: suggestion.providerID,
18335
- modelID: suggestion.suggestion
18398
+ modelID: suggestion.suggestion,
18399
+ ...normalizedArgs.body.model.variant ? { variant: normalizedArgs.body.model.variant } : {}
18336
18400
  }
18337
18401
  }
18338
18402
  };
@@ -35644,7 +35708,7 @@ async function processApplyPatchEditsWithCli(sessionID, edits, output, cliPath,
35644
35708
  hook_event_name: "PostToolUse",
35645
35709
  tool_input: {
35646
35710
  file_path: edit.filePath,
35647
- old_string: edit.before,
35711
+ ...edit.before !== undefined ? { old_string: edit.before } : {},
35648
35712
  new_string: edit.after
35649
35713
  }
35650
35714
  };
@@ -35662,6 +35726,871 @@ function isCliPathUsable(cliPath) {
35662
35726
  return Boolean(cliPath && existsSync27(cliPath));
35663
35727
  }
35664
35728
 
35729
+ // src/hooks/comment-checker/apply-patch-edits.ts
35730
+ import { existsSync as existsSync28, readFileSync as readFileSync18 } from "fs";
35731
+ // node_modules/diff/libesm/util/string.js
35732
+ function hasOnlyWinLineEndings(string4) {
35733
+ return string4.includes(`\r
35734
+ `) && !string4.startsWith(`
35735
+ `) && !string4.match(/[^\r]\n/);
35736
+ }
35737
+ function hasOnlyUnixLineEndings(string4) {
35738
+ return !string4.includes(`\r
35739
+ `) && string4.includes(`
35740
+ `);
35741
+ }
35742
+
35743
+ // node_modules/diff/libesm/patch/line-endings.js
35744
+ function unixToWin(patch) {
35745
+ if (Array.isArray(patch)) {
35746
+ return patch.map((p) => unixToWin(p));
35747
+ }
35748
+ return Object.assign(Object.assign({}, patch), { hunks: patch.hunks.map((hunk) => Object.assign(Object.assign({}, hunk), { lines: hunk.lines.map((line, i2) => {
35749
+ var _a2;
35750
+ return line.startsWith("\\") || line.endsWith("\r") || ((_a2 = hunk.lines[i2 + 1]) === null || _a2 === undefined ? undefined : _a2.startsWith("\\")) ? line : line + "\r";
35751
+ }) })) });
35752
+ }
35753
+ function winToUnix(patch) {
35754
+ if (Array.isArray(patch)) {
35755
+ return patch.map((p) => winToUnix(p));
35756
+ }
35757
+ return Object.assign(Object.assign({}, patch), { hunks: patch.hunks.map((hunk) => Object.assign(Object.assign({}, hunk), { lines: hunk.lines.map((line) => line.endsWith("\r") ? line.substring(0, line.length - 1) : line) })) });
35758
+ }
35759
+ function isUnix(patch) {
35760
+ if (!Array.isArray(patch)) {
35761
+ patch = [patch];
35762
+ }
35763
+ return !patch.some((index) => index.hunks.some((hunk) => hunk.lines.some((line) => !line.startsWith("\\") && line.endsWith("\r"))));
35764
+ }
35765
+ function isWin(patch) {
35766
+ if (!Array.isArray(patch)) {
35767
+ patch = [patch];
35768
+ }
35769
+ return patch.some((index) => index.hunks.some((hunk) => hunk.lines.some((line) => line.endsWith("\r")))) && patch.every((index) => index.hunks.every((hunk) => hunk.lines.every((line, i2) => {
35770
+ var _a2;
35771
+ return line.startsWith("\\") || line.endsWith("\r") || ((_a2 = hunk.lines[i2 + 1]) === null || _a2 === undefined ? undefined : _a2.startsWith("\\"));
35772
+ })));
35773
+ }
35774
+
35775
+ // node_modules/diff/libesm/patch/parse.js
35776
+ function parsePatch(uniDiff) {
35777
+ const diffstr = uniDiff.split(/\n/), list = [];
35778
+ let i2 = 0;
35779
+ function parseIndex() {
35780
+ const index = {};
35781
+ list.push(index);
35782
+ while (i2 < diffstr.length) {
35783
+ const line = diffstr[i2];
35784
+ if (/^(---|\+\+\+|@@)\s/.test(line)) {
35785
+ break;
35786
+ }
35787
+ const headerMatch = /^(?:Index:|diff(?: -r \w+)+)\s+/.exec(line);
35788
+ if (headerMatch) {
35789
+ index.index = line.substring(headerMatch[0].length).trim();
35790
+ }
35791
+ i2++;
35792
+ }
35793
+ parseFileHeader(index);
35794
+ parseFileHeader(index);
35795
+ index.hunks = [];
35796
+ while (i2 < diffstr.length) {
35797
+ const line = diffstr[i2];
35798
+ if (/^(Index:\s|diff\s|---\s|\+\+\+\s|===================================================================)/.test(line)) {
35799
+ break;
35800
+ } else if (/^@@/.test(line)) {
35801
+ index.hunks.push(parseHunk());
35802
+ } else if (line) {
35803
+ throw new Error("Unknown line " + (i2 + 1) + " " + JSON.stringify(line));
35804
+ } else {
35805
+ i2++;
35806
+ }
35807
+ }
35808
+ }
35809
+ function parseFileHeader(index) {
35810
+ const fileHeaderMatch = /^(---|\+\+\+)\s+/.exec(diffstr[i2]);
35811
+ if (fileHeaderMatch) {
35812
+ const prefix = fileHeaderMatch[1], data = diffstr[i2].substring(3).trim().split("\t", 2), header = (data[1] || "").trim();
35813
+ let fileName = data[0].replace(/\\\\/g, "\\");
35814
+ if (fileName.startsWith('"') && fileName.endsWith('"')) {
35815
+ fileName = fileName.substr(1, fileName.length - 2);
35816
+ }
35817
+ if (prefix === "---") {
35818
+ index.oldFileName = fileName;
35819
+ index.oldHeader = header;
35820
+ } else {
35821
+ index.newFileName = fileName;
35822
+ index.newHeader = header;
35823
+ }
35824
+ i2++;
35825
+ }
35826
+ }
35827
+ function parseHunk() {
35828
+ var _a2;
35829
+ const chunkHeaderIndex = i2, chunkHeaderLine = diffstr[i2++], chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
35830
+ const hunk = {
35831
+ oldStart: +chunkHeader[1],
35832
+ oldLines: typeof chunkHeader[2] === "undefined" ? 1 : +chunkHeader[2],
35833
+ newStart: +chunkHeader[3],
35834
+ newLines: typeof chunkHeader[4] === "undefined" ? 1 : +chunkHeader[4],
35835
+ lines: []
35836
+ };
35837
+ if (hunk.oldLines === 0) {
35838
+ hunk.oldStart += 1;
35839
+ }
35840
+ if (hunk.newLines === 0) {
35841
+ hunk.newStart += 1;
35842
+ }
35843
+ let addCount = 0, removeCount = 0;
35844
+ for (;i2 < diffstr.length && (removeCount < hunk.oldLines || addCount < hunk.newLines || ((_a2 = diffstr[i2]) === null || _a2 === undefined ? undefined : _a2.startsWith("\\"))); i2++) {
35845
+ const operation = diffstr[i2].length == 0 && i2 != diffstr.length - 1 ? " " : diffstr[i2][0];
35846
+ if (operation === "+" || operation === "-" || operation === " " || operation === "\\") {
35847
+ hunk.lines.push(diffstr[i2]);
35848
+ if (operation === "+") {
35849
+ addCount++;
35850
+ } else if (operation === "-") {
35851
+ removeCount++;
35852
+ } else if (operation === " ") {
35853
+ addCount++;
35854
+ removeCount++;
35855
+ }
35856
+ } else {
35857
+ throw new Error(`Hunk at line ${chunkHeaderIndex + 1} contained invalid line ${diffstr[i2]}`);
35858
+ }
35859
+ }
35860
+ if (!addCount && hunk.newLines === 1) {
35861
+ hunk.newLines = 0;
35862
+ }
35863
+ if (!removeCount && hunk.oldLines === 1) {
35864
+ hunk.oldLines = 0;
35865
+ }
35866
+ if (addCount !== hunk.newLines) {
35867
+ throw new Error("Added line count did not match for hunk at line " + (chunkHeaderIndex + 1));
35868
+ }
35869
+ if (removeCount !== hunk.oldLines) {
35870
+ throw new Error("Removed line count did not match for hunk at line " + (chunkHeaderIndex + 1));
35871
+ }
35872
+ return hunk;
35873
+ }
35874
+ while (i2 < diffstr.length) {
35875
+ parseIndex();
35876
+ }
35877
+ return list;
35878
+ }
35879
+
35880
+ // node_modules/diff/libesm/util/distance-iterator.js
35881
+ function distance_iterator_default(start, minLine, maxLine) {
35882
+ let wantForward = true, backwardExhausted = false, forwardExhausted = false, localOffset = 1;
35883
+ return function iterator() {
35884
+ if (wantForward && !forwardExhausted) {
35885
+ if (backwardExhausted) {
35886
+ localOffset++;
35887
+ } else {
35888
+ wantForward = false;
35889
+ }
35890
+ if (start + localOffset <= maxLine) {
35891
+ return start + localOffset;
35892
+ }
35893
+ forwardExhausted = true;
35894
+ }
35895
+ if (!backwardExhausted) {
35896
+ if (!forwardExhausted) {
35897
+ wantForward = true;
35898
+ }
35899
+ if (minLine <= start - localOffset) {
35900
+ return start - localOffset++;
35901
+ }
35902
+ backwardExhausted = true;
35903
+ return iterator();
35904
+ }
35905
+ return;
35906
+ };
35907
+ }
35908
+
35909
+ // node_modules/diff/libesm/patch/apply.js
35910
+ function applyPatch(source, patch, options = {}) {
35911
+ let patches;
35912
+ if (typeof patch === "string") {
35913
+ patches = parsePatch(patch);
35914
+ } else if (Array.isArray(patch)) {
35915
+ patches = patch;
35916
+ } else {
35917
+ patches = [patch];
35918
+ }
35919
+ if (patches.length > 1) {
35920
+ throw new Error("applyPatch only works with a single input.");
35921
+ }
35922
+ return applyStructuredPatch(source, patches[0], options);
35923
+ }
35924
+ function applyStructuredPatch(source, patch, options = {}) {
35925
+ if (options.autoConvertLineEndings || options.autoConvertLineEndings == null) {
35926
+ if (hasOnlyWinLineEndings(source) && isUnix(patch)) {
35927
+ patch = unixToWin(patch);
35928
+ } else if (hasOnlyUnixLineEndings(source) && isWin(patch)) {
35929
+ patch = winToUnix(patch);
35930
+ }
35931
+ }
35932
+ const lines = source.split(`
35933
+ `), hunks = patch.hunks, compareLine = options.compareLine || ((lineNumber, line, operation, patchContent) => line === patchContent), fuzzFactor = options.fuzzFactor || 0;
35934
+ let minLine = 0;
35935
+ if (fuzzFactor < 0 || !Number.isInteger(fuzzFactor)) {
35936
+ throw new Error("fuzzFactor must be a non-negative integer");
35937
+ }
35938
+ if (!hunks.length) {
35939
+ return source;
35940
+ }
35941
+ let prevLine = "", removeEOFNL = false, addEOFNL = false;
35942
+ for (let i2 = 0;i2 < hunks[hunks.length - 1].lines.length; i2++) {
35943
+ const line = hunks[hunks.length - 1].lines[i2];
35944
+ if (line[0] == "\\") {
35945
+ if (prevLine[0] == "+") {
35946
+ removeEOFNL = true;
35947
+ } else if (prevLine[0] == "-") {
35948
+ addEOFNL = true;
35949
+ }
35950
+ }
35951
+ prevLine = line;
35952
+ }
35953
+ if (removeEOFNL) {
35954
+ if (addEOFNL) {
35955
+ if (!fuzzFactor && lines[lines.length - 1] == "") {
35956
+ return false;
35957
+ }
35958
+ } else if (lines[lines.length - 1] == "") {
35959
+ lines.pop();
35960
+ } else if (!fuzzFactor) {
35961
+ return false;
35962
+ }
35963
+ } else if (addEOFNL) {
35964
+ if (lines[lines.length - 1] != "") {
35965
+ lines.push("");
35966
+ } else if (!fuzzFactor) {
35967
+ return false;
35968
+ }
35969
+ }
35970
+ function applyHunk(hunkLines, toPos, maxErrors, hunkLinesI = 0, lastContextLineMatched = true, patchedLines = [], patchedLinesLength = 0) {
35971
+ let nConsecutiveOldContextLines = 0;
35972
+ let nextContextLineMustMatch = false;
35973
+ for (;hunkLinesI < hunkLines.length; hunkLinesI++) {
35974
+ const hunkLine = hunkLines[hunkLinesI], operation = hunkLine.length > 0 ? hunkLine[0] : " ", content = hunkLine.length > 0 ? hunkLine.substr(1) : hunkLine;
35975
+ if (operation === "-") {
35976
+ if (compareLine(toPos + 1, lines[toPos], operation, content)) {
35977
+ toPos++;
35978
+ nConsecutiveOldContextLines = 0;
35979
+ } else {
35980
+ if (!maxErrors || lines[toPos] == null) {
35981
+ return null;
35982
+ }
35983
+ patchedLines[patchedLinesLength] = lines[toPos];
35984
+ return applyHunk(hunkLines, toPos + 1, maxErrors - 1, hunkLinesI, false, patchedLines, patchedLinesLength + 1);
35985
+ }
35986
+ }
35987
+ if (operation === "+") {
35988
+ if (!lastContextLineMatched) {
35989
+ return null;
35990
+ }
35991
+ patchedLines[patchedLinesLength] = content;
35992
+ patchedLinesLength++;
35993
+ nConsecutiveOldContextLines = 0;
35994
+ nextContextLineMustMatch = true;
35995
+ }
35996
+ if (operation === " ") {
35997
+ nConsecutiveOldContextLines++;
35998
+ patchedLines[patchedLinesLength] = lines[toPos];
35999
+ if (compareLine(toPos + 1, lines[toPos], operation, content)) {
36000
+ patchedLinesLength++;
36001
+ lastContextLineMatched = true;
36002
+ nextContextLineMustMatch = false;
36003
+ toPos++;
36004
+ } else {
36005
+ if (nextContextLineMustMatch || !maxErrors) {
36006
+ return null;
36007
+ }
36008
+ return lines[toPos] && (applyHunk(hunkLines, toPos + 1, maxErrors - 1, hunkLinesI + 1, false, patchedLines, patchedLinesLength + 1) || applyHunk(hunkLines, toPos + 1, maxErrors - 1, hunkLinesI, false, patchedLines, patchedLinesLength + 1)) || applyHunk(hunkLines, toPos, maxErrors - 1, hunkLinesI + 1, false, patchedLines, patchedLinesLength);
36009
+ }
36010
+ }
36011
+ }
36012
+ patchedLinesLength -= nConsecutiveOldContextLines;
36013
+ toPos -= nConsecutiveOldContextLines;
36014
+ patchedLines.length = patchedLinesLength;
36015
+ return {
36016
+ patchedLines,
36017
+ oldLineLastI: toPos - 1
36018
+ };
36019
+ }
36020
+ const resultLines = [];
36021
+ let prevHunkOffset = 0;
36022
+ for (let i2 = 0;i2 < hunks.length; i2++) {
36023
+ const hunk = hunks[i2];
36024
+ let hunkResult;
36025
+ const maxLine = lines.length - hunk.oldLines + fuzzFactor;
36026
+ let toPos;
36027
+ for (let maxErrors = 0;maxErrors <= fuzzFactor; maxErrors++) {
36028
+ toPos = hunk.oldStart + prevHunkOffset - 1;
36029
+ const iterator = distance_iterator_default(toPos, minLine, maxLine);
36030
+ for (;toPos !== undefined; toPos = iterator()) {
36031
+ hunkResult = applyHunk(hunk.lines, toPos, maxErrors);
36032
+ if (hunkResult) {
36033
+ break;
36034
+ }
36035
+ }
36036
+ if (hunkResult) {
36037
+ break;
36038
+ }
36039
+ }
36040
+ if (!hunkResult) {
36041
+ return false;
36042
+ }
36043
+ for (let i3 = minLine;i3 < toPos; i3++) {
36044
+ resultLines.push(lines[i3]);
36045
+ }
36046
+ for (let i3 = 0;i3 < hunkResult.patchedLines.length; i3++) {
36047
+ const line = hunkResult.patchedLines[i3];
36048
+ resultLines.push(line);
36049
+ }
36050
+ minLine = hunkResult.oldLineLastI + 1;
36051
+ prevHunkOffset = toPos + 1 - hunk.oldStart;
36052
+ }
36053
+ for (let i2 = minLine;i2 < lines.length; i2++) {
36054
+ resultLines.push(lines[i2]);
36055
+ }
36056
+ return resultLines.join(`
36057
+ `);
36058
+ }
36059
+
36060
+ // node_modules/diff/libesm/patch/reverse.js
36061
+ function reversePatch(structuredPatch) {
36062
+ if (Array.isArray(structuredPatch)) {
36063
+ return structuredPatch.map((patch) => reversePatch(patch)).reverse();
36064
+ }
36065
+ return Object.assign(Object.assign({}, structuredPatch), { oldFileName: structuredPatch.newFileName, oldHeader: structuredPatch.newHeader, newFileName: structuredPatch.oldFileName, newHeader: structuredPatch.oldHeader, hunks: structuredPatch.hunks.map((hunk) => {
36066
+ return {
36067
+ oldLines: hunk.newLines,
36068
+ oldStart: hunk.newStart,
36069
+ newLines: hunk.oldLines,
36070
+ newStart: hunk.oldStart,
36071
+ lines: hunk.lines.map((l) => {
36072
+ if (l.startsWith("-")) {
36073
+ return `+${l.slice(1)}`;
36074
+ }
36075
+ if (l.startsWith("+")) {
36076
+ return `-${l.slice(1)}`;
36077
+ }
36078
+ return l;
36079
+ })
36080
+ };
36081
+ }) });
36082
+ }
36083
+
36084
+ // node_modules/diff/libesm/diff/base.js
36085
+ class Diff {
36086
+ diff(oldStr, newStr, options = {}) {
36087
+ let callback;
36088
+ if (typeof options === "function") {
36089
+ callback = options;
36090
+ options = {};
36091
+ } else if ("callback" in options) {
36092
+ callback = options.callback;
36093
+ }
36094
+ const oldString = this.castInput(oldStr, options);
36095
+ const newString = this.castInput(newStr, options);
36096
+ const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
36097
+ const newTokens = this.removeEmpty(this.tokenize(newString, options));
36098
+ return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
36099
+ }
36100
+ diffWithOptionsObj(oldTokens, newTokens, options, callback) {
36101
+ var _a2;
36102
+ const done = (value) => {
36103
+ value = this.postProcess(value, options);
36104
+ if (callback) {
36105
+ setTimeout(function() {
36106
+ callback(value);
36107
+ }, 0);
36108
+ return;
36109
+ } else {
36110
+ return value;
36111
+ }
36112
+ };
36113
+ const newLen = newTokens.length, oldLen = oldTokens.length;
36114
+ let editLength = 1;
36115
+ let maxEditLength = newLen + oldLen;
36116
+ if (options.maxEditLength != null) {
36117
+ maxEditLength = Math.min(maxEditLength, options.maxEditLength);
36118
+ }
36119
+ const maxExecutionTime = (_a2 = options.timeout) !== null && _a2 !== undefined ? _a2 : Infinity;
36120
+ const abortAfterTimestamp = Date.now() + maxExecutionTime;
36121
+ const bestPath = [{ oldPos: -1, lastComponent: undefined }];
36122
+ let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
36123
+ if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
36124
+ return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
36125
+ }
36126
+ let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
36127
+ const execEditLength = () => {
36128
+ for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength);diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
36129
+ let basePath;
36130
+ const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
36131
+ if (removePath) {
36132
+ bestPath[diagonalPath - 1] = undefined;
36133
+ }
36134
+ let canAdd = false;
36135
+ if (addPath) {
36136
+ const addPathNewPos = addPath.oldPos - diagonalPath;
36137
+ canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
36138
+ }
36139
+ const canRemove = removePath && removePath.oldPos + 1 < oldLen;
36140
+ if (!canAdd && !canRemove) {
36141
+ bestPath[diagonalPath] = undefined;
36142
+ continue;
36143
+ }
36144
+ if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
36145
+ basePath = this.addToPath(addPath, true, false, 0, options);
36146
+ } else {
36147
+ basePath = this.addToPath(removePath, false, true, 1, options);
36148
+ }
36149
+ newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
36150
+ if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
36151
+ return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
36152
+ } else {
36153
+ bestPath[diagonalPath] = basePath;
36154
+ if (basePath.oldPos + 1 >= oldLen) {
36155
+ maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
36156
+ }
36157
+ if (newPos + 1 >= newLen) {
36158
+ minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
36159
+ }
36160
+ }
36161
+ }
36162
+ editLength++;
36163
+ };
36164
+ if (callback) {
36165
+ (function exec2() {
36166
+ setTimeout(function() {
36167
+ if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
36168
+ return callback(undefined);
36169
+ }
36170
+ if (!execEditLength()) {
36171
+ exec2();
36172
+ }
36173
+ }, 0);
36174
+ })();
36175
+ } else {
36176
+ while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
36177
+ const ret = execEditLength();
36178
+ if (ret) {
36179
+ return ret;
36180
+ }
36181
+ }
36182
+ }
36183
+ }
36184
+ addToPath(path5, added, removed, oldPosInc, options) {
36185
+ const last = path5.lastComponent;
36186
+ if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
36187
+ return {
36188
+ oldPos: path5.oldPos + oldPosInc,
36189
+ lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
36190
+ };
36191
+ } else {
36192
+ return {
36193
+ oldPos: path5.oldPos + oldPosInc,
36194
+ lastComponent: { count: 1, added, removed, previousComponent: last }
36195
+ };
36196
+ }
36197
+ }
36198
+ extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
36199
+ const newLen = newTokens.length, oldLen = oldTokens.length;
36200
+ let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
36201
+ while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
36202
+ newPos++;
36203
+ oldPos++;
36204
+ commonCount++;
36205
+ if (options.oneChangePerToken) {
36206
+ basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };
36207
+ }
36208
+ }
36209
+ if (commonCount && !options.oneChangePerToken) {
36210
+ basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };
36211
+ }
36212
+ basePath.oldPos = oldPos;
36213
+ return newPos;
36214
+ }
36215
+ equals(left, right, options) {
36216
+ if (options.comparator) {
36217
+ return options.comparator(left, right);
36218
+ } else {
36219
+ return left === right || !!options.ignoreCase && left.toLowerCase() === right.toLowerCase();
36220
+ }
36221
+ }
36222
+ removeEmpty(array2) {
36223
+ const ret = [];
36224
+ for (let i2 = 0;i2 < array2.length; i2++) {
36225
+ if (array2[i2]) {
36226
+ ret.push(array2[i2]);
36227
+ }
36228
+ }
36229
+ return ret;
36230
+ }
36231
+ castInput(value, options) {
36232
+ return value;
36233
+ }
36234
+ tokenize(value, options) {
36235
+ return Array.from(value);
36236
+ }
36237
+ join(chars) {
36238
+ return chars.join("");
36239
+ }
36240
+ postProcess(changeObjects, options) {
36241
+ return changeObjects;
36242
+ }
36243
+ get useLongestToken() {
36244
+ return false;
36245
+ }
36246
+ buildValues(lastComponent, newTokens, oldTokens) {
36247
+ const components = [];
36248
+ let nextComponent;
36249
+ while (lastComponent) {
36250
+ components.push(lastComponent);
36251
+ nextComponent = lastComponent.previousComponent;
36252
+ delete lastComponent.previousComponent;
36253
+ lastComponent = nextComponent;
36254
+ }
36255
+ components.reverse();
36256
+ const componentLen = components.length;
36257
+ let componentPos = 0, newPos = 0, oldPos = 0;
36258
+ for (;componentPos < componentLen; componentPos++) {
36259
+ const component = components[componentPos];
36260
+ if (!component.removed) {
36261
+ if (!component.added && this.useLongestToken) {
36262
+ let value = newTokens.slice(newPos, newPos + component.count);
36263
+ value = value.map(function(value2, i2) {
36264
+ const oldValue = oldTokens[oldPos + i2];
36265
+ return oldValue.length > value2.length ? oldValue : value2;
36266
+ });
36267
+ component.value = this.join(value);
36268
+ } else {
36269
+ component.value = this.join(newTokens.slice(newPos, newPos + component.count));
36270
+ }
36271
+ newPos += component.count;
36272
+ if (!component.added) {
36273
+ oldPos += component.count;
36274
+ }
36275
+ } else {
36276
+ component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
36277
+ oldPos += component.count;
36278
+ }
36279
+ }
36280
+ return components;
36281
+ }
36282
+ }
36283
+
36284
+ // node_modules/diff/libesm/diff/line.js
36285
+ class LineDiff extends Diff {
36286
+ constructor() {
36287
+ super(...arguments);
36288
+ this.tokenize = tokenize;
36289
+ }
36290
+ equals(left, right, options) {
36291
+ if (options.ignoreWhitespace) {
36292
+ if (!options.newlineIsToken || !left.includes(`
36293
+ `)) {
36294
+ left = left.trim();
36295
+ }
36296
+ if (!options.newlineIsToken || !right.includes(`
36297
+ `)) {
36298
+ right = right.trim();
36299
+ }
36300
+ } else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
36301
+ if (left.endsWith(`
36302
+ `)) {
36303
+ left = left.slice(0, -1);
36304
+ }
36305
+ if (right.endsWith(`
36306
+ `)) {
36307
+ right = right.slice(0, -1);
36308
+ }
36309
+ }
36310
+ return super.equals(left, right, options);
36311
+ }
36312
+ }
36313
+ var lineDiff = new LineDiff;
36314
+ function diffLines(oldStr, newStr, options) {
36315
+ return lineDiff.diff(oldStr, newStr, options);
36316
+ }
36317
+ function tokenize(value, options) {
36318
+ if (options.stripTrailingCr) {
36319
+ value = value.replace(/\r\n/g, `
36320
+ `);
36321
+ }
36322
+ const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
36323
+ if (!linesAndNewlines[linesAndNewlines.length - 1]) {
36324
+ linesAndNewlines.pop();
36325
+ }
36326
+ for (let i2 = 0;i2 < linesAndNewlines.length; i2++) {
36327
+ const line = linesAndNewlines[i2];
36328
+ if (i2 % 2 && !options.newlineIsToken) {
36329
+ retLines[retLines.length - 1] += line;
36330
+ } else {
36331
+ retLines.push(line);
36332
+ }
36333
+ }
36334
+ return retLines;
36335
+ }
36336
+
36337
+ // node_modules/diff/libesm/patch/create.js
36338
+ var INCLUDE_HEADERS = {
36339
+ includeIndex: true,
36340
+ includeUnderline: true,
36341
+ includeFileHeaders: true
36342
+ };
36343
+ function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
36344
+ let optionsObj;
36345
+ if (!options) {
36346
+ optionsObj = {};
36347
+ } else if (typeof options === "function") {
36348
+ optionsObj = { callback: options };
36349
+ } else {
36350
+ optionsObj = options;
36351
+ }
36352
+ if (typeof optionsObj.context === "undefined") {
36353
+ optionsObj.context = 4;
36354
+ }
36355
+ const context = optionsObj.context;
36356
+ if (optionsObj.newlineIsToken) {
36357
+ throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");
36358
+ }
36359
+ if (!optionsObj.callback) {
36360
+ return diffLinesResultToPatch(diffLines(oldStr, newStr, optionsObj));
36361
+ } else {
36362
+ const { callback } = optionsObj;
36363
+ diffLines(oldStr, newStr, Object.assign(Object.assign({}, optionsObj), { callback: (diff) => {
36364
+ const patch = diffLinesResultToPatch(diff);
36365
+ callback(patch);
36366
+ } }));
36367
+ }
36368
+ function diffLinesResultToPatch(diff) {
36369
+ if (!diff) {
36370
+ return;
36371
+ }
36372
+ diff.push({ value: "", lines: [] });
36373
+ function contextLines(lines) {
36374
+ return lines.map(function(entry) {
36375
+ return " " + entry;
36376
+ });
36377
+ }
36378
+ const hunks = [];
36379
+ let oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1;
36380
+ for (let i2 = 0;i2 < diff.length; i2++) {
36381
+ const current = diff[i2], lines = current.lines || splitLines(current.value);
36382
+ current.lines = lines;
36383
+ if (current.added || current.removed) {
36384
+ if (!oldRangeStart) {
36385
+ const prev = diff[i2 - 1];
36386
+ oldRangeStart = oldLine;
36387
+ newRangeStart = newLine;
36388
+ if (prev) {
36389
+ curRange = context > 0 ? contextLines(prev.lines.slice(-context)) : [];
36390
+ oldRangeStart -= curRange.length;
36391
+ newRangeStart -= curRange.length;
36392
+ }
36393
+ }
36394
+ for (const line of lines) {
36395
+ curRange.push((current.added ? "+" : "-") + line);
36396
+ }
36397
+ if (current.added) {
36398
+ newLine += lines.length;
36399
+ } else {
36400
+ oldLine += lines.length;
36401
+ }
36402
+ } else {
36403
+ if (oldRangeStart) {
36404
+ if (lines.length <= context * 2 && i2 < diff.length - 2) {
36405
+ for (const line of contextLines(lines)) {
36406
+ curRange.push(line);
36407
+ }
36408
+ } else {
36409
+ const contextSize = Math.min(lines.length, context);
36410
+ for (const line of contextLines(lines.slice(0, contextSize))) {
36411
+ curRange.push(line);
36412
+ }
36413
+ const hunk = {
36414
+ oldStart: oldRangeStart,
36415
+ oldLines: oldLine - oldRangeStart + contextSize,
36416
+ newStart: newRangeStart,
36417
+ newLines: newLine - newRangeStart + contextSize,
36418
+ lines: curRange
36419
+ };
36420
+ hunks.push(hunk);
36421
+ oldRangeStart = 0;
36422
+ newRangeStart = 0;
36423
+ curRange = [];
36424
+ }
36425
+ }
36426
+ oldLine += lines.length;
36427
+ newLine += lines.length;
36428
+ }
36429
+ }
36430
+ for (const hunk of hunks) {
36431
+ for (let i2 = 0;i2 < hunk.lines.length; i2++) {
36432
+ if (hunk.lines[i2].endsWith(`
36433
+ `)) {
36434
+ hunk.lines[i2] = hunk.lines[i2].slice(0, -1);
36435
+ } else {
36436
+ hunk.lines.splice(i2 + 1, 0, "\");
36437
+ i2++;
36438
+ }
36439
+ }
36440
+ }
36441
+ return {
36442
+ oldFileName,
36443
+ newFileName,
36444
+ oldHeader,
36445
+ newHeader,
36446
+ hunks
36447
+ };
36448
+ }
36449
+ }
36450
+ function formatPatch(patch, headerOptions) {
36451
+ if (!headerOptions) {
36452
+ headerOptions = INCLUDE_HEADERS;
36453
+ }
36454
+ if (Array.isArray(patch)) {
36455
+ if (patch.length > 1 && !headerOptions.includeFileHeaders) {
36456
+ throw new Error("Cannot omit file headers on a multi-file patch. " + "(The result would be unparseable; how would a tool trying to apply " + "the patch know which changes are to which file?)");
36457
+ }
36458
+ return patch.map((p) => formatPatch(p, headerOptions)).join(`
36459
+ `);
36460
+ }
36461
+ const ret = [];
36462
+ if (headerOptions.includeIndex && patch.oldFileName == patch.newFileName) {
36463
+ ret.push("Index: " + patch.oldFileName);
36464
+ }
36465
+ if (headerOptions.includeUnderline) {
36466
+ ret.push("===================================================================");
36467
+ }
36468
+ if (headerOptions.includeFileHeaders) {
36469
+ ret.push("--- " + patch.oldFileName + (typeof patch.oldHeader === "undefined" ? "" : "\t" + patch.oldHeader));
36470
+ ret.push("+++ " + patch.newFileName + (typeof patch.newHeader === "undefined" ? "" : "\t" + patch.newHeader));
36471
+ }
36472
+ for (let i2 = 0;i2 < patch.hunks.length; i2++) {
36473
+ const hunk = patch.hunks[i2];
36474
+ if (hunk.oldLines === 0) {
36475
+ hunk.oldStart -= 1;
36476
+ }
36477
+ if (hunk.newLines === 0) {
36478
+ hunk.newStart -= 1;
36479
+ }
36480
+ ret.push("@@ -" + hunk.oldStart + "," + hunk.oldLines + " +" + hunk.newStart + "," + hunk.newLines + " @@");
36481
+ for (const line of hunk.lines) {
36482
+ ret.push(line);
36483
+ }
36484
+ }
36485
+ return ret.join(`
36486
+ `) + `
36487
+ `;
36488
+ }
36489
+ function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
36490
+ if (typeof options === "function") {
36491
+ options = { callback: options };
36492
+ }
36493
+ if (!(options === null || options === undefined ? undefined : options.callback)) {
36494
+ const patchObj = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
36495
+ if (!patchObj) {
36496
+ return;
36497
+ }
36498
+ return formatPatch(patchObj, options === null || options === undefined ? undefined : options.headerOptions);
36499
+ } else {
36500
+ const { callback } = options;
36501
+ structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, Object.assign(Object.assign({}, options), { callback: (patchObj) => {
36502
+ if (!patchObj) {
36503
+ callback(undefined);
36504
+ } else {
36505
+ callback(formatPatch(patchObj, options.headerOptions));
36506
+ }
36507
+ } }));
36508
+ }
36509
+ }
36510
+ function splitLines(text) {
36511
+ const hasTrailingNl = text.endsWith(`
36512
+ `);
36513
+ const result = text.split(`
36514
+ `).map((line) => line + `
36515
+ `);
36516
+ if (hasTrailingNl) {
36517
+ result.pop();
36518
+ } else {
36519
+ result.push(result.pop().slice(0, -1));
36520
+ }
36521
+ return result;
36522
+ }
36523
+ // src/hooks/comment-checker/apply-patch-edits.ts
36524
+ function normalizePatchFilePath(filePath) {
36525
+ if (!filePath || filePath === "/dev/null") {
36526
+ return;
36527
+ }
36528
+ return filePath.replace(/^[ab]\//, "");
36529
+ }
36530
+ function getFilePathFromPatch(patch) {
36531
+ if (!patch) {
36532
+ return;
36533
+ }
36534
+ try {
36535
+ const parsedPatch = parsePatch(patch)[0];
36536
+ return normalizePatchFilePath(parsedPatch?.newFileName) ?? normalizePatchFilePath(parsedPatch?.oldFileName);
36537
+ } catch {
36538
+ return;
36539
+ }
36540
+ }
36541
+ function reconstructBeforeContent(after, patch) {
36542
+ if (!patch) {
36543
+ return;
36544
+ }
36545
+ try {
36546
+ const parsedPatch = parsePatch(patch)[0];
36547
+ if (!parsedPatch) {
36548
+ return;
36549
+ }
36550
+ const reversedPatch = reversePatch(parsedPatch);
36551
+ const reconstructed = applyPatch(after, reversedPatch);
36552
+ return typeof reconstructed === "string" ? reconstructed : undefined;
36553
+ } catch {
36554
+ return;
36555
+ }
36556
+ }
36557
+ function resolveCurrentFilePath(file2) {
36558
+ return file2.movePath ?? file2.filePath ?? getFilePathFromPatch(file2.patch);
36559
+ }
36560
+ function resolveApplyPatchEdits(files, debugLog3) {
36561
+ const edits = [];
36562
+ for (const file2 of files) {
36563
+ if (file2.type === "delete") {
36564
+ continue;
36565
+ }
36566
+ const filePath = resolveCurrentFilePath(file2);
36567
+ if (!filePath) {
36568
+ debugLog3("apply_patch metadata missing file path, skipping file");
36569
+ continue;
36570
+ }
36571
+ if (typeof file2.after === "string") {
36572
+ edits.push({
36573
+ filePath,
36574
+ after: file2.after,
36575
+ ...typeof file2.before === "string" ? { before: file2.before } : {}
36576
+ });
36577
+ continue;
36578
+ }
36579
+ if (!existsSync28(filePath)) {
36580
+ debugLog3("apply_patch output file missing on disk, skipping file", { filePath });
36581
+ continue;
36582
+ }
36583
+ const after = readFileSync18(filePath, "utf8");
36584
+ const before = typeof file2.before === "string" ? file2.before : reconstructBeforeContent(after, file2.patch);
36585
+ edits.push({
36586
+ filePath,
36587
+ after,
36588
+ ...typeof before === "string" ? { before } : {}
36589
+ });
36590
+ }
36591
+ return edits;
36592
+ }
36593
+
35665
36594
  // src/hooks/comment-checker/pending-calls.ts
35666
36595
  var pendingCalls = new Map;
35667
36596
  var PENDING_CALL_TTL = 60000;
@@ -35761,10 +36690,11 @@ function createCommentCheckerHooks(config2) {
35761
36690
  }
35762
36691
  const ApplyPatchMetadataSchema = zod_default.object({
35763
36692
  files: zod_default.array(zod_default.object({
35764
- filePath: zod_default.string(),
36693
+ filePath: zod_default.string().optional(),
35765
36694
  movePath: zod_default.string().optional(),
35766
- before: zod_default.string(),
35767
- after: zod_default.string(),
36695
+ before: zod_default.string().optional(),
36696
+ after: zod_default.string().optional(),
36697
+ patch: zod_default.string().optional(),
35768
36698
  type: zod_default.string().optional()
35769
36699
  }))
35770
36700
  });
@@ -35774,11 +36704,7 @@ function createCommentCheckerHooks(config2) {
35774
36704
  debugLog3("apply_patch metadata schema mismatch, skipping");
35775
36705
  return;
35776
36706
  }
35777
- const edits = parsed.data.files.filter((f) => f.type !== "delete").map((f) => ({
35778
- filePath: f.movePath ?? f.filePath,
35779
- before: f.before,
35780
- after: f.after
35781
- }));
36707
+ const edits = resolveApplyPatchEdits(parsed.data.files, debugLog3);
35782
36708
  if (edits.length === 0) {
35783
36709
  debugLog3("apply_patch had no editable files, skipping");
35784
36710
  return;
@@ -35859,11 +36785,11 @@ function createToolOutputTruncatorHook(ctx, options) {
35859
36785
  };
35860
36786
  }
35861
36787
  // src/hooks/directory-agents-injector/injector.ts
35862
- import { readFileSync as readFileSync19 } from "fs";
36788
+ import { readFileSync as readFileSync20 } from "fs";
35863
36789
  import { dirname as dirname3 } from "path";
35864
36790
 
35865
36791
  // src/hooks/directory-agents-injector/finder.ts
35866
- import { existsSync as existsSync28 } from "fs";
36792
+ import { existsSync as existsSync29 } from "fs";
35867
36793
  import { dirname as dirname2, isAbsolute as isAbsolute2, join as join31, resolve as resolve2 } from "path";
35868
36794
 
35869
36795
  // src/hooks/directory-agents-injector/constants.ts
@@ -35886,7 +36812,7 @@ function findAgentsMdUp(input) {
35886
36812
  const isRootDir = current === input.rootDir;
35887
36813
  if (!isRootDir) {
35888
36814
  const agentsPath = join31(current, AGENTS_FILENAME);
35889
- if (existsSync28(agentsPath)) {
36815
+ if (existsSync29(agentsPath)) {
35890
36816
  found.push(agentsPath);
35891
36817
  }
35892
36818
  }
@@ -35904,9 +36830,9 @@ function findAgentsMdUp(input) {
35904
36830
 
35905
36831
  // src/shared/session-injected-paths.ts
35906
36832
  import {
35907
- existsSync as existsSync29,
36833
+ existsSync as existsSync30,
35908
36834
  mkdirSync as mkdirSync7,
35909
- readFileSync as readFileSync18,
36835
+ readFileSync as readFileSync19,
35910
36836
  unlinkSync as unlinkSync3,
35911
36837
  writeFileSync as writeFileSync8
35912
36838
  } from "fs";
@@ -35915,10 +36841,10 @@ function createInjectedPathsStorage(storageDir) {
35915
36841
  const getStoragePath = (sessionID) => join32(storageDir, `${sessionID}.json`);
35916
36842
  const loadInjectedPaths = (sessionID) => {
35917
36843
  const filePath = getStoragePath(sessionID);
35918
- if (!existsSync29(filePath))
36844
+ if (!existsSync30(filePath))
35919
36845
  return new Set;
35920
36846
  try {
35921
- const content = readFileSync18(filePath, "utf-8");
36847
+ const content = readFileSync19(filePath, "utf-8");
35922
36848
  const data = JSON.parse(content);
35923
36849
  return new Set(data.injectedPaths);
35924
36850
  } catch {
@@ -35926,7 +36852,7 @@ function createInjectedPathsStorage(storageDir) {
35926
36852
  }
35927
36853
  };
35928
36854
  const saveInjectedPaths = (sessionID, paths) => {
35929
- if (!existsSync29(storageDir)) {
36855
+ if (!existsSync30(storageDir)) {
35930
36856
  mkdirSync7(storageDir, { recursive: true });
35931
36857
  }
35932
36858
  const data = {
@@ -35938,7 +36864,7 @@ function createInjectedPathsStorage(storageDir) {
35938
36864
  };
35939
36865
  const clearInjectedPaths = (sessionID) => {
35940
36866
  const filePath = getStoragePath(sessionID);
35941
- if (existsSync29(filePath)) {
36867
+ if (existsSync30(filePath)) {
35942
36868
  unlinkSync3(filePath);
35943
36869
  }
35944
36870
  };
@@ -35976,7 +36902,7 @@ async function processFilePathForAgentsInjection(input) {
35976
36902
  if (cache.has(agentsDir))
35977
36903
  continue;
35978
36904
  try {
35979
- const content = readFileSync19(agentsPath, "utf-8");
36905
+ const content = readFileSync20(agentsPath, "utf-8");
35980
36906
  const { result, truncated } = await input.truncator.truncate(input.sessionID, content);
35981
36907
  const truncationNotice = truncated ? `
35982
36908
 
@@ -36037,11 +36963,11 @@ function createDirectoryAgentsInjectorHook(ctx, modelCacheState) {
36037
36963
  };
36038
36964
  }
36039
36965
  // src/hooks/directory-readme-injector/injector.ts
36040
- import { readFileSync as readFileSync20 } from "fs";
36966
+ import { readFileSync as readFileSync21 } from "fs";
36041
36967
  import { dirname as dirname5 } from "path";
36042
36968
 
36043
36969
  // src/hooks/directory-readme-injector/finder.ts
36044
- import { existsSync as existsSync30 } from "fs";
36970
+ import { existsSync as existsSync31 } from "fs";
36045
36971
  import { dirname as dirname4, isAbsolute as isAbsolute3, join as join34, resolve as resolve3 } from "path";
36046
36972
 
36047
36973
  // src/hooks/directory-readme-injector/constants.ts
@@ -36062,7 +36988,7 @@ function findReadmeMdUp(input) {
36062
36988
  let current = input.startDir;
36063
36989
  while (true) {
36064
36990
  const readmePath = join34(current, README_FILENAME);
36065
- if (existsSync30(readmePath)) {
36991
+ if (existsSync31(readmePath)) {
36066
36992
  found.push(readmePath);
36067
36993
  }
36068
36994
  if (current === input.rootDir)
@@ -36104,7 +37030,7 @@ async function processFilePathForReadmeInjection(input) {
36104
37030
  if (cache.has(readmeDir))
36105
37031
  continue;
36106
37032
  try {
36107
- const content = readFileSync20(readmePath, "utf-8");
37033
+ const content = readFileSync21(readmePath, "utf-8");
36108
37034
  const { result, truncated } = await input.truncator.truncate(input.sessionID, content);
36109
37035
  const truncationNotice = truncated ? `
36110
37036
 
@@ -36419,14 +37345,14 @@ function incrementEmptyContentAttempt(autoCompactState, sessionID) {
36419
37345
  }
36420
37346
 
36421
37347
  // src/hooks/anthropic-context-window-limit-recovery/tool-result-storage.ts
36422
- import { existsSync as existsSync32, readdirSync as readdirSync11, readFileSync as readFileSync21, writeFileSync as writeFileSync9 } from "fs";
37348
+ import { existsSync as existsSync33, readdirSync as readdirSync11, readFileSync as readFileSync22, writeFileSync as writeFileSync9 } from "fs";
36423
37349
  import { join as join35 } from "path";
36424
37350
 
36425
37351
  // src/hooks/anthropic-context-window-limit-recovery/message-storage-directory.ts
36426
- import { existsSync as existsSync31, readdirSync as readdirSync10 } from "fs";
37352
+ import { existsSync as existsSync32, readdirSync as readdirSync10 } from "fs";
36427
37353
  function getMessageIds(sessionID) {
36428
37354
  const messageDir = getMessageDir(sessionID);
36429
- if (!messageDir || !existsSync31(messageDir))
37355
+ if (!messageDir || !existsSync32(messageDir))
36430
37356
  return [];
36431
37357
  const messageIds = [];
36432
37358
  for (const file2 of readdirSync10(messageDir)) {
@@ -36449,14 +37375,14 @@ function findToolResultsBySize(sessionID) {
36449
37375
  const results = [];
36450
37376
  for (const messageID of messageIds) {
36451
37377
  const partDir = join35(PART_STORAGE, messageID);
36452
- if (!existsSync32(partDir))
37378
+ if (!existsSync33(partDir))
36453
37379
  continue;
36454
37380
  for (const file2 of readdirSync11(partDir)) {
36455
37381
  if (!file2.endsWith(".json"))
36456
37382
  continue;
36457
37383
  try {
36458
37384
  const partPath = join35(partDir, file2);
36459
- const content = readFileSync21(partPath, "utf-8");
37385
+ const content = readFileSync22(partPath, "utf-8");
36460
37386
  const part = JSON.parse(content);
36461
37387
  if (part.type === "tool" && part.state?.output && !part.truncated) {
36462
37388
  results.push({
@@ -36483,7 +37409,7 @@ function truncateToolResult(partPath) {
36483
37409
  return { success: false };
36484
37410
  }
36485
37411
  try {
36486
- const content = readFileSync21(partPath, "utf-8");
37412
+ const content = readFileSync22(partPath, "utf-8");
36487
37413
  const part = JSON.parse(content);
36488
37414
  if (!part.state?.output) {
36489
37415
  return { success: false };
@@ -37250,7 +38176,7 @@ async function executeCompact(sessionID, msg, autoCompactState, client, director
37250
38176
  }
37251
38177
 
37252
38178
  // src/hooks/anthropic-context-window-limit-recovery/pruning-deduplication.ts
37253
- import { readdirSync as readdirSync12, readFileSync as readFileSync22 } from "fs";
38179
+ import { readdirSync as readdirSync12, readFileSync as readFileSync23 } from "fs";
37254
38180
  import { join as join36 } from "path";
37255
38181
 
37256
38182
  // src/hooks/anthropic-context-window-limit-recovery/pruning-types.ts
@@ -37287,7 +38213,7 @@ function readMessages2(sessionID) {
37287
38213
  try {
37288
38214
  const files = readdirSync12(messageDir).filter((f) => f.endsWith(".json"));
37289
38215
  for (const file2 of files) {
37290
- const content = readFileSync22(join36(messageDir, file2), "utf-8");
38216
+ const content = readFileSync23(join36(messageDir, file2), "utf-8");
37291
38217
  const data = JSON.parse(content);
37292
38218
  if (data.parts) {
37293
38219
  messages.push(data);
@@ -37392,7 +38318,7 @@ function findToolOutput(messages, callID) {
37392
38318
  }
37393
38319
 
37394
38320
  // src/hooks/anthropic-context-window-limit-recovery/pruning-tool-output-truncation.ts
37395
- import { existsSync as existsSync33, readdirSync as readdirSync13, readFileSync as readFileSync23 } from "fs";
38321
+ import { existsSync as existsSync34, readdirSync as readdirSync13, readFileSync as readFileSync24 } from "fs";
37396
38322
  import { join as join37 } from "path";
37397
38323
  init_logger();
37398
38324
  function getPartStorage() {
@@ -37422,14 +38348,14 @@ async function truncateToolOutputsByCallId(sessionID, callIds, client) {
37422
38348
  let truncatedCount = 0;
37423
38349
  for (const messageID of messageIds) {
37424
38350
  const partDir = join37(getPartStorage(), messageID);
37425
- if (!existsSync33(partDir))
38351
+ if (!existsSync34(partDir))
37426
38352
  continue;
37427
38353
  for (const file2 of readdirSync13(partDir)) {
37428
38354
  if (!file2.endsWith(".json"))
37429
38355
  continue;
37430
38356
  const partPath = join37(partDir, file2);
37431
38357
  try {
37432
- const content = readFileSync23(partPath, "utf-8");
38358
+ const content = readFileSync24(partPath, "utf-8");
37433
38359
  const part = JSON.parse(content);
37434
38360
  if (part.type !== "tool" || !part.callID)
37435
38361
  continue;
@@ -37812,7 +38738,7 @@ function createThinkModeHook() {
37812
38738
  return;
37813
38739
  }
37814
38740
  state3.requested = true;
37815
- if (typeof output.message.variant === "string") {
38741
+ if (getUserMessageVariant(output.message) !== undefined) {
37816
38742
  thinkModeState.set(sessionID, state3);
37817
38743
  return;
37818
38744
  }
@@ -37827,7 +38753,7 @@ function createThinkModeHook() {
37827
38753
  thinkModeState.set(sessionID, state3);
37828
38754
  return;
37829
38755
  }
37830
- output.message.variant = "high";
38756
+ setUserMessageVariant(output.message, "high");
37831
38757
  state3.modelSwitched = false;
37832
38758
  state3.variantSet = true;
37833
38759
  log("Think mode: variant set to high", { sessionID });
@@ -38240,9 +39166,9 @@ function createModelFallbackHook(args) {
38240
39166
  modelID: fallback.modelID
38241
39167
  };
38242
39168
  if (fallback.variant !== undefined) {
38243
- output.message["variant"] = fallback.variant;
39169
+ setUserMessageVariant(output.message, fallback.variant);
38244
39170
  } else {
38245
- delete output.message["variant"];
39171
+ clearUserMessageVariant(output.message);
38246
39172
  }
38247
39173
  if (toast) {
38248
39174
  const key = `${sessionID}:${fallback.providerID}/${fallback.modelID}:${fallback.variant ?? ""}`;
@@ -38279,7 +39205,7 @@ function createModelFallbackHook(args) {
38279
39205
  }
38280
39206
  // src/hooks/claude-code-hooks/config.ts
38281
39207
  import { join as join38 } from "path";
38282
- import { existsSync as existsSync34 } from "fs";
39208
+ import { existsSync as existsSync35 } from "fs";
38283
39209
  function normalizeHookMatcher(raw) {
38284
39210
  return {
38285
39211
  matcher: raw.matcher ?? raw.pattern ?? "*",
@@ -38309,7 +39235,7 @@ function getClaudeSettingsPaths(customPath) {
38309
39235
  join38(process.cwd(), ".claude", "settings.json"),
38310
39236
  join38(process.cwd(), ".claude", "settings.local.json")
38311
39237
  ];
38312
- if (customPath && existsSync34(customPath)) {
39238
+ if (customPath && existsSync35(customPath)) {
38313
39239
  paths.unshift(customPath);
38314
39240
  }
38315
39241
  return [...new Set(paths)];
@@ -38334,7 +39260,7 @@ async function loadClaudeHooksConfig(customSettingsPath) {
38334
39260
  const paths = getClaudeSettingsPaths(customSettingsPath);
38335
39261
  let mergedConfig = {};
38336
39262
  for (const settingsPath of paths) {
38337
- if (existsSync34(settingsPath)) {
39263
+ if (existsSync35(settingsPath)) {
38338
39264
  try {
38339
39265
  const content = await Bun.file(settingsPath).text();
38340
39266
  const settings = JSON.parse(content);
@@ -38352,14 +39278,14 @@ async function loadClaudeHooksConfig(customSettingsPath) {
38352
39278
 
38353
39279
  // src/hooks/claude-code-hooks/config-loader.ts
38354
39280
  init_logger();
38355
- import { existsSync as existsSync35 } from "fs";
39281
+ import { existsSync as existsSync36 } from "fs";
38356
39282
  import { join as join39 } from "path";
38357
39283
  var USER_CONFIG_PATH = join39(getOpenCodeConfigDir({ binary: "opencode" }), "opencode-cc-plugin.json");
38358
39284
  function getProjectConfigPath() {
38359
39285
  return join39(process.cwd(), ".opencode", "opencode-cc-plugin.json");
38360
39286
  }
38361
39287
  async function loadConfigFromPath(path5) {
38362
- if (!existsSync35(path5)) {
39288
+ if (!existsSync36(path5)) {
38363
39289
  return null;
38364
39290
  }
38365
39291
  try {
@@ -38586,7 +39512,7 @@ ${USER_PROMPT_SUBMIT_TAG_CLOSE}`);
38586
39512
 
38587
39513
  // src/hooks/claude-code-hooks/transcript.ts
38588
39514
  import { join as join40 } from "path";
38589
- import { mkdirSync as mkdirSync8, appendFileSync as appendFileSync5, existsSync as existsSync36, writeFileSync as writeFileSync10, unlinkSync as unlinkSync4 } from "fs";
39515
+ import { mkdirSync as mkdirSync8, appendFileSync as appendFileSync5, existsSync as existsSync37, writeFileSync as writeFileSync10, unlinkSync as unlinkSync4 } from "fs";
38590
39516
  import { tmpdir as tmpdir5 } from "os";
38591
39517
  import { randomUUID } from "crypto";
38592
39518
  var TRANSCRIPT_DIR = join40(getClaudeConfigDir(), "transcripts");
@@ -38594,7 +39520,7 @@ function getTranscriptPath(sessionId) {
38594
39520
  return join40(TRANSCRIPT_DIR, `${sessionId}.jsonl`);
38595
39521
  }
38596
39522
  function ensureTranscriptDir() {
38597
- if (!existsSync36(TRANSCRIPT_DIR)) {
39523
+ if (!existsSync37(TRANSCRIPT_DIR)) {
38598
39524
  mkdirSync8(TRANSCRIPT_DIR, { recursive: true });
38599
39525
  }
38600
39526
  }
@@ -39529,9 +40455,9 @@ function getRuleInjectionFilePath(output) {
39529
40455
 
39530
40456
  // src/hooks/rules-injector/storage.ts
39531
40457
  import {
39532
- existsSync as existsSync37,
40458
+ existsSync as existsSync38,
39533
40459
  mkdirSync as mkdirSync9,
39534
- readFileSync as readFileSync24,
40460
+ readFileSync as readFileSync25,
39535
40461
  writeFileSync as writeFileSync11,
39536
40462
  unlinkSync as unlinkSync5
39537
40463
  } from "fs";
@@ -39567,10 +40493,10 @@ function getStoragePath(sessionID) {
39567
40493
  }
39568
40494
  function loadInjectedRules(sessionID) {
39569
40495
  const filePath = getStoragePath(sessionID);
39570
- if (!existsSync37(filePath))
40496
+ if (!existsSync38(filePath))
39571
40497
  return { contentHashes: new Set, realPaths: new Set };
39572
40498
  try {
39573
- const content = readFileSync24(filePath, "utf-8");
40499
+ const content = readFileSync25(filePath, "utf-8");
39574
40500
  const data = JSON.parse(content);
39575
40501
  return {
39576
40502
  contentHashes: new Set(data.injectedHashes),
@@ -39581,7 +40507,7 @@ function loadInjectedRules(sessionID) {
39581
40507
  }
39582
40508
  }
39583
40509
  function saveInjectedRules(sessionID, data) {
39584
- if (!existsSync37(RULES_INJECTOR_STORAGE)) {
40510
+ if (!existsSync38(RULES_INJECTOR_STORAGE)) {
39585
40511
  mkdirSync9(RULES_INJECTOR_STORAGE, { recursive: true });
39586
40512
  }
39587
40513
  const storageData = {
@@ -39594,7 +40520,7 @@ function saveInjectedRules(sessionID, data) {
39594
40520
  }
39595
40521
  function clearInjectedRules(sessionID) {
39596
40522
  const filePath = getStoragePath(sessionID);
39597
- if (existsSync37(filePath)) {
40523
+ if (existsSync38(filePath)) {
39598
40524
  unlinkSync5(filePath);
39599
40525
  }
39600
40526
  }
@@ -39616,12 +40542,12 @@ function createSessionCacheStore() {
39616
40542
  }
39617
40543
 
39618
40544
  // src/hooks/rules-injector/injector.ts
39619
- import { readFileSync as readFileSync25, statSync as statSync4 } from "fs";
40545
+ import { readFileSync as readFileSync26, statSync as statSync4 } from "fs";
39620
40546
  import { homedir as homedir8 } from "os";
39621
40547
  import { relative as relative2, resolve as resolve4 } from "path";
39622
40548
 
39623
40549
  // src/hooks/rules-injector/project-root-finder.ts
39624
- import { existsSync as existsSync38, statSync as statSync2 } from "fs";
40550
+ import { existsSync as existsSync39, statSync as statSync2 } from "fs";
39625
40551
  import { dirname as dirname6, join as join44 } from "path";
39626
40552
  function findProjectRoot(startPath) {
39627
40553
  let current;
@@ -39634,7 +40560,7 @@ function findProjectRoot(startPath) {
39634
40560
  while (true) {
39635
40561
  for (const marker of PROJECT_MARKERS) {
39636
40562
  const markerPath = join44(current, marker);
39637
- if (existsSync38(markerPath)) {
40563
+ if (existsSync39(markerPath)) {
39638
40564
  return current;
39639
40565
  }
39640
40566
  }
@@ -39646,11 +40572,11 @@ function findProjectRoot(startPath) {
39646
40572
  }
39647
40573
  }
39648
40574
  // src/hooks/rules-injector/rule-file-finder.ts
39649
- import { existsSync as existsSync40, statSync as statSync3 } from "fs";
40575
+ import { existsSync as existsSync41, statSync as statSync3 } from "fs";
39650
40576
  import { dirname as dirname7, join as join46 } from "path";
39651
40577
 
39652
40578
  // src/hooks/rules-injector/rule-file-scanner.ts
39653
- import { existsSync as existsSync39, readdirSync as readdirSync14, realpathSync as realpathSync2 } from "fs";
40579
+ import { existsSync as existsSync40, readdirSync as readdirSync14, realpathSync as realpathSync2 } from "fs";
39654
40580
  import { join as join45 } from "path";
39655
40581
  function isGitHubInstructionsDir(dir) {
39656
40582
  return dir.includes(".github/instructions") || dir.endsWith(".github/instructions");
@@ -39662,7 +40588,7 @@ function isValidRuleFile(fileName, dir) {
39662
40588
  return RULE_EXTENSIONS.some((ext) => fileName.endsWith(ext));
39663
40589
  }
39664
40590
  function findRuleFilesRecursive(dir, results) {
39665
- if (!existsSync39(dir))
40591
+ if (!existsSync40(dir))
39666
40592
  return;
39667
40593
  try {
39668
40594
  const entries = readdirSync14(dir, { withFileTypes: true });
@@ -39721,7 +40647,7 @@ function findRuleFiles(projectRoot, homeDir, currentFile) {
39721
40647
  if (projectRoot) {
39722
40648
  for (const ruleFile of PROJECT_RULE_FILES) {
39723
40649
  const filePath = join46(projectRoot, ruleFile);
39724
- if (existsSync40(filePath)) {
40650
+ if (existsSync41(filePath)) {
39725
40651
  try {
39726
40652
  const stat = statSync3(filePath);
39727
40653
  if (stat.isFile()) {
@@ -39936,7 +40862,7 @@ function getCachedParsedRule(filePath, realPath) {
39936
40862
  if (cached2 && cached2.mtimeMs === stat.mtimeMs && cached2.size === stat.size) {
39937
40863
  return { metadata: cached2.metadata, body: cached2.body };
39938
40864
  }
39939
- const rawContent = readFileSync25(filePath, "utf-8");
40865
+ const rawContent = readFileSync26(filePath, "utf-8");
39940
40866
  const { metadata, body } = parseRuleFrontmatter(rawContent);
39941
40867
  parsedRuleCache.set(realPath, {
39942
40868
  mtimeMs: stat.mtimeMs,
@@ -39946,7 +40872,7 @@ function getCachedParsedRule(filePath, realPath) {
39946
40872
  });
39947
40873
  return { metadata, body };
39948
40874
  } catch {
39949
- const rawContent = readFileSync25(filePath, "utf-8");
40875
+ const rawContent = readFileSync26(filePath, "utf-8");
39950
40876
  return parseRuleFrontmatter(rawContent);
39951
40877
  }
39952
40878
  }
@@ -40444,7 +41370,7 @@ function spawnWithWindowsHide(command, options) {
40444
41370
  return wrapNodeProcess(proc);
40445
41371
  }
40446
41372
  // src/cli/config-manager/bun-install.ts
40447
- import { existsSync as existsSync46 } from "fs";
41373
+ import { existsSync as existsSync47 } from "fs";
40448
41374
  init_logger();
40449
41375
  var BUN_INSTALL_TIMEOUT_SECONDS = 60;
40450
41376
  var BUN_INSTALL_TIMEOUT_MS = BUN_INSTALL_TIMEOUT_SECONDS * 1000;
@@ -40472,7 +41398,7 @@ async function runBunInstallWithDetails(options) {
40472
41398
  const outputMode = options?.outputMode ?? "inherit";
40473
41399
  const cacheDir = getOpenCodeCacheDir();
40474
41400
  const packageJsonPath = `${cacheDir}/package.json`;
40475
- if (!existsSync46(packageJsonPath)) {
41401
+ if (!existsSync47(packageJsonPath)) {
40476
41402
  return {
40477
41403
  success: false,
40478
41404
  error: `Workspace not initialized: ${packageJsonPath} not found. OpenCode should create this on first run.`
@@ -40861,9 +41787,9 @@ v${latestVersion} available. Restart OpenCode to apply.` : "DrizzyAgent is activ
40861
41787
  }
40862
41788
  // src/hooks/agent-usage-reminder/storage.ts
40863
41789
  import {
40864
- existsSync as existsSync48,
41790
+ existsSync as existsSync49,
40865
41791
  mkdirSync as mkdirSync10,
40866
- readFileSync as readFileSync33,
41792
+ readFileSync as readFileSync34,
40867
41793
  writeFileSync as writeFileSync14,
40868
41794
  unlinkSync as unlinkSync8
40869
41795
  } from "fs";
@@ -40921,17 +41847,17 @@ function getStoragePath2(sessionID) {
40921
41847
  }
40922
41848
  function loadAgentUsageState(sessionID) {
40923
41849
  const filePath = getStoragePath2(sessionID);
40924
- if (!existsSync48(filePath))
41850
+ if (!existsSync49(filePath))
40925
41851
  return null;
40926
41852
  try {
40927
- const content = readFileSync33(filePath, "utf-8");
41853
+ const content = readFileSync34(filePath, "utf-8");
40928
41854
  return JSON.parse(content);
40929
41855
  } catch {
40930
41856
  return null;
40931
41857
  }
40932
41858
  }
40933
41859
  function saveAgentUsageState(state3) {
40934
- if (!existsSync48(AGENT_USAGE_REMINDER_STORAGE)) {
41860
+ if (!existsSync49(AGENT_USAGE_REMINDER_STORAGE)) {
40935
41861
  mkdirSync10(AGENT_USAGE_REMINDER_STORAGE, { recursive: true });
40936
41862
  }
40937
41863
  const filePath = getStoragePath2(state3.sessionID);
@@ -40939,7 +41865,7 @@ function saveAgentUsageState(state3) {
40939
41865
  }
40940
41866
  function clearAgentUsageState(sessionID) {
40941
41867
  const filePath = getStoragePath2(sessionID);
40942
- if (existsSync48(filePath)) {
41868
+ if (existsSync49(filePath)) {
40943
41869
  unlinkSync8(filePath);
40944
41870
  }
40945
41871
  }
@@ -42032,10 +42958,7 @@ function extractPromptText2(parts) {
42032
42958
  // src/hooks/keyword-detector/hook.ts
42033
42959
  function createKeywordDetectorHook(ctx, _collector) {
42034
42960
  function getRuntimeVariant(input, message) {
42035
- if (typeof message["variant"] === "string") {
42036
- return message["variant"];
42037
- }
42038
- return typeof input.variant === "string" ? input.variant : undefined;
42961
+ return getUserMessageVariant(message) ?? getInputVariant(input);
42039
42962
  }
42040
42963
  return {
42041
42964
  "chat.message": async (input, output) => {
@@ -42215,9 +43138,9 @@ function createNonInteractiveEnvHook(_ctx) {
42215
43138
  }
42216
43139
  // src/hooks/interactive-bash-session/storage.ts
42217
43140
  import {
42218
- existsSync as existsSync49,
43141
+ existsSync as existsSync50,
42219
43142
  mkdirSync as mkdirSync11,
42220
- readFileSync as readFileSync34,
43143
+ readFileSync as readFileSync35,
42221
43144
  writeFileSync as writeFileSync15,
42222
43145
  unlinkSync as unlinkSync9
42223
43146
  } from "fs";
@@ -42241,10 +43164,10 @@ function getStoragePath3(sessionID) {
42241
43164
  }
42242
43165
  function loadInteractiveBashSessionState(sessionID) {
42243
43166
  const filePath = getStoragePath3(sessionID);
42244
- if (!existsSync49(filePath))
43167
+ if (!existsSync50(filePath))
42245
43168
  return null;
42246
43169
  try {
42247
- const content = readFileSync34(filePath, "utf-8");
43170
+ const content = readFileSync35(filePath, "utf-8");
42248
43171
  const serialized = JSON.parse(content);
42249
43172
  return {
42250
43173
  sessionID: serialized.sessionID,
@@ -42256,7 +43179,7 @@ function loadInteractiveBashSessionState(sessionID) {
42256
43179
  }
42257
43180
  }
42258
43181
  function saveInteractiveBashSessionState(state3) {
42259
- if (!existsSync49(INTERACTIVE_BASH_SESSION_STORAGE)) {
43182
+ if (!existsSync50(INTERACTIVE_BASH_SESSION_STORAGE)) {
42260
43183
  mkdirSync11(INTERACTIVE_BASH_SESSION_STORAGE, { recursive: true });
42261
43184
  }
42262
43185
  const filePath = getStoragePath3(state3.sessionID);
@@ -42269,7 +43192,7 @@ function saveInteractiveBashSessionState(state3) {
42269
43192
  }
42270
43193
  function clearInteractiveBashSessionState(sessionID) {
42271
43194
  const filePath = getStoragePath3(sessionID);
42272
- if (existsSync49(filePath)) {
43195
+ if (existsSync50(filePath)) {
42273
43196
  unlinkSync9(filePath);
42274
43197
  }
42275
43198
  }
@@ -42666,18 +43589,18 @@ var DEFAULT_MAX_ITERATIONS = 100;
42666
43589
  var DEFAULT_COMPLETION_PROMISE = "DONE";
42667
43590
  var ULTRAWORK_VERIFICATION_PROMISE = "VERIFIED";
42668
43591
  // src/hooks/ralph-loop/storage.ts
42669
- import { existsSync as existsSync50, readFileSync as readFileSync35, writeFileSync as writeFileSync16, unlinkSync as unlinkSync10, mkdirSync as mkdirSync12 } from "fs";
43592
+ import { existsSync as existsSync51, readFileSync as readFileSync36, writeFileSync as writeFileSync16, unlinkSync as unlinkSync10, mkdirSync as mkdirSync12 } from "fs";
42670
43593
  import { dirname as dirname10, join as join56 } from "path";
42671
43594
  function getStateFilePath(directory, customPath) {
42672
43595
  return customPath ? join56(directory, customPath) : join56(directory, DEFAULT_STATE_FILE);
42673
43596
  }
42674
43597
  function readState(directory, customPath) {
42675
43598
  const filePath = getStateFilePath(directory, customPath);
42676
- if (!existsSync50(filePath)) {
43599
+ if (!existsSync51(filePath)) {
42677
43600
  return null;
42678
43601
  }
42679
43602
  try {
42680
- const content = readFileSync35(filePath, "utf-8");
43603
+ const content = readFileSync36(filePath, "utf-8");
42681
43604
  const { data, body } = parseFrontmatter(content);
42682
43605
  const active = data.active;
42683
43606
  const iteration = data.iteration;
@@ -42719,7 +43642,7 @@ function writeState(directory, state3, customPath) {
42719
43642
  const filePath = getStateFilePath(directory, customPath);
42720
43643
  try {
42721
43644
  const dir = dirname10(filePath);
42722
- if (!existsSync50(dir)) {
43645
+ if (!existsSync51(dir)) {
42723
43646
  mkdirSync12(dir, { recursive: true });
42724
43647
  }
42725
43648
  const sessionIdLine = state3.session_id ? `session_id: "${state3.session_id}"
@@ -42757,7 +43680,7 @@ ${state3.prompt}
42757
43680
  function clearState(directory, customPath) {
42758
43681
  const filePath = getStateFilePath(directory, customPath);
42759
43682
  try {
42760
- if (existsSync50(filePath)) {
43683
+ if (existsSync51(filePath)) {
42761
43684
  unlinkSync10(filePath);
42762
43685
  }
42763
43686
  return true;
@@ -43086,7 +44009,7 @@ async function handleDetectedCompletion(ctx, input) {
43086
44009
 
43087
44010
  // src/hooks/ralph-loop/completion-promise-detector.ts
43088
44011
  init_logger();
43089
- import { existsSync as existsSync51, readFileSync as readFileSync36 } from "fs";
44012
+ import { existsSync as existsSync52, readFileSync as readFileSync37 } from "fs";
43090
44013
  function escapeRegex2(str2) {
43091
44014
  return str2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
43092
44015
  }
@@ -43097,9 +44020,9 @@ function detectCompletionInTranscript(transcriptPath, promise2, startedAt) {
43097
44020
  if (!transcriptPath)
43098
44021
  return false;
43099
44022
  try {
43100
- if (!existsSync51(transcriptPath))
44023
+ if (!existsSync52(transcriptPath))
43101
44024
  return false;
43102
- const content = readFileSync36(transcriptPath, "utf-8");
44025
+ const content = readFileSync37(transcriptPath, "utf-8");
43103
44026
  const pattern = buildPromisePattern(promise2);
43104
44027
  const lines = content.split(`
43105
44028
  `).filter((line) => line.trim());
@@ -43888,7 +44811,7 @@ function findSlashCommandPartIndex(parts) {
43888
44811
  return -1;
43889
44812
  }
43890
44813
  // src/hooks/auto-slash-command/executor.ts
43891
- import { existsSync as existsSync53, readdirSync as readdirSync15, readFileSync as readFileSync39 } from "fs";
44814
+ import { existsSync as existsSync54, readdirSync as readdirSync15, readFileSync as readFileSync40 } from "fs";
43892
44815
  import { join as join61, basename as basename4, dirname as dirname13 } from "path";
43893
44816
  // src/features/builtin-commands/templates/init-deep.ts
43894
44817
  var INIT_DEEP_TEMPLATE = `# /init-deep
@@ -45601,7 +46524,7 @@ function builtinToLoadedSkill(builtin) {
45601
46524
  }
45602
46525
 
45603
46526
  // src/features/opencode-skill-loader/merger/config-skill-entry-loader.ts
45604
- import { existsSync as existsSync52, readFileSync as readFileSync37 } from "fs";
46527
+ import { existsSync as existsSync53, readFileSync as readFileSync38 } from "fs";
45605
46528
  import { dirname as dirname11, isAbsolute as isAbsolute4, resolve as resolve5 } from "path";
45606
46529
  import { homedir as homedir12 } from "os";
45607
46530
  function resolveFilePath5(from, configDir) {
@@ -45620,9 +46543,9 @@ function resolveFilePath5(from, configDir) {
45620
46543
  }
45621
46544
  function loadSkillFromFile(filePath) {
45622
46545
  try {
45623
- if (!existsSync52(filePath))
46546
+ if (!existsSync53(filePath))
45624
46547
  return null;
45625
- const content = readFileSync37(filePath, "utf-8");
46548
+ const content = readFileSync38(filePath, "utf-8");
45626
46549
  const { data, body } = parseFrontmatter(content);
45627
46550
  return { template: body, metadata: data };
45628
46551
  } catch {
@@ -47992,10 +48915,10 @@ async function getAllSkills(options) {
47992
48915
  return allSkills;
47993
48916
  }
47994
48917
  // src/features/opencode-skill-loader/loaded-skill-template-extractor.ts
47995
- import { readFileSync as readFileSync38 } from "fs";
48918
+ import { readFileSync as readFileSync39 } from "fs";
47996
48919
  function extractSkillTemplate(skill) {
47997
48920
  if (skill.path) {
47998
- const content = readFileSync38(skill.path, "utf-8");
48921
+ const content = readFileSync39(skill.path, "utf-8");
47999
48922
  const { body } = parseFrontmatter(content);
48000
48923
  return body.trim();
48001
48924
  }
@@ -48703,7 +49626,7 @@ async function discoverConfigSourceSkills(options) {
48703
49626
  }
48704
49627
  // src/hooks/auto-slash-command/executor.ts
48705
49628
  function discoverCommandsFromDir(commandsDir, scope) {
48706
- if (!existsSync53(commandsDir)) {
49629
+ if (!existsSync54(commandsDir)) {
48707
49630
  return [];
48708
49631
  }
48709
49632
  const entries = readdirSync15(commandsDir, { withFileTypes: true });
@@ -48714,7 +49637,7 @@ function discoverCommandsFromDir(commandsDir, scope) {
48714
49637
  const commandPath = join61(commandsDir, entry.name);
48715
49638
  const commandName = basename4(entry.name, ".md");
48716
49639
  try {
48717
- const content = readFileSync39(commandPath, "utf-8");
49640
+ const content = readFileSync40(commandPath, "utf-8");
48718
49641
  const { data, body } = parseFrontmatter(content);
48719
49642
  const isOpencodeSource = scope === "opencode" || scope === "opencode-project";
48720
49643
  const metadata = {
@@ -49151,18 +50074,18 @@ var NOTEPAD_DIR = "notepads";
49151
50074
  var NOTEPAD_BASE_PATH = `${BOULDER_DIR}/${NOTEPAD_DIR}`;
49152
50075
  var PLANNER_PLANS_DIR = ".drizzy/plans";
49153
50076
  // src/features/boulder-state/storage.ts
49154
- import { existsSync as existsSync54, readFileSync as readFileSync40, writeFileSync as writeFileSync17, mkdirSync as mkdirSync13, readdirSync as readdirSync16 } from "fs";
50077
+ import { existsSync as existsSync55, readFileSync as readFileSync41, writeFileSync as writeFileSync17, mkdirSync as mkdirSync13, readdirSync as readdirSync16 } from "fs";
49155
50078
  import { dirname as dirname14, join as join62, basename as basename5 } from "path";
49156
50079
  function getBoulderFilePath(directory) {
49157
50080
  return join62(directory, BOULDER_DIR, BOULDER_FILE);
49158
50081
  }
49159
50082
  function readBoulderState(directory) {
49160
50083
  const filePath = getBoulderFilePath(directory);
49161
- if (!existsSync54(filePath)) {
50084
+ if (!existsSync55(filePath)) {
49162
50085
  return null;
49163
50086
  }
49164
50087
  try {
49165
- const content = readFileSync40(filePath, "utf-8");
50088
+ const content = readFileSync41(filePath, "utf-8");
49166
50089
  const parsed = JSON.parse(content);
49167
50090
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
49168
50091
  return null;
@@ -49179,7 +50102,7 @@ function writeBoulderState(directory, state3) {
49179
50102
  const filePath = getBoulderFilePath(directory);
49180
50103
  try {
49181
50104
  const dir = dirname14(filePath);
49182
- if (!existsSync54(dir)) {
50105
+ if (!existsSync55(dir)) {
49183
50106
  mkdirSync13(dir, { recursive: true });
49184
50107
  }
49185
50108
  writeFileSync17(filePath, JSON.stringify(state3, null, 2), "utf-8");
@@ -49206,7 +50129,7 @@ function appendSessionId(directory, sessionId) {
49206
50129
  function clearBoulderState(directory) {
49207
50130
  const filePath = getBoulderFilePath(directory);
49208
50131
  try {
49209
- if (existsSync54(filePath)) {
50132
+ if (existsSync55(filePath)) {
49210
50133
  const { unlinkSync: unlinkSync11 } = __require("fs");
49211
50134
  unlinkSync11(filePath);
49212
50135
  }
@@ -49217,7 +50140,7 @@ function clearBoulderState(directory) {
49217
50140
  }
49218
50141
  function findPlannerPlans(directory) {
49219
50142
  const plansDir = join62(directory, PLANNER_PLANS_DIR);
49220
- if (!existsSync54(plansDir)) {
50143
+ if (!existsSync55(plansDir)) {
49221
50144
  return [];
49222
50145
  }
49223
50146
  try {
@@ -49232,11 +50155,11 @@ function findPlannerPlans(directory) {
49232
50155
  }
49233
50156
  }
49234
50157
  function getPlanProgress(planPath) {
49235
- if (!existsSync54(planPath)) {
50158
+ if (!existsSync55(planPath)) {
49236
50159
  return { total: 0, completed: 0, isComplete: true };
49237
50160
  }
49238
50161
  try {
49239
- const content = readFileSync40(planPath, "utf-8");
50162
+ const content = readFileSync41(planPath, "utf-8");
49240
50163
  const uncheckedMatches = content.match(/^\s*[-*]\s*\[\s*\]/gm) || [];
49241
50164
  const checkedMatches = content.match(/^\s*[-*]\s*\[[xX]\]/gm) || [];
49242
50165
  const total = uncheckedMatches.length + checkedMatches.length;
@@ -53177,7 +54100,7 @@ function createRuntimeFallbackHook(ctx, options) {
53177
54100
  };
53178
54101
  }
53179
54102
  // src/hooks/write-existing-file-guard/hook.ts
53180
- import { existsSync as existsSync56, realpathSync as realpathSync4 } from "fs";
54103
+ import { existsSync as existsSync57, realpathSync as realpathSync4 } from "fs";
53181
54104
  import { basename as basename6, dirname as dirname15, isAbsolute as isAbsolute8, join as join64, normalize, relative as relative6, resolve as resolve8 } from "path";
53182
54105
  var MAX_TRACKED_SESSIONS = 256;
53183
54106
  var MAX_TRACKED_PATHS_PER_SESSION = 1024;
@@ -53199,7 +54122,7 @@ function isPathInsideDirectory(pathToCheck, directory) {
53199
54122
  }
53200
54123
  function toCanonicalPath(absolutePath) {
53201
54124
  let canonicalPath = absolutePath;
53202
- if (existsSync56(absolutePath)) {
54125
+ if (existsSync57(absolutePath)) {
53203
54126
  try {
53204
54127
  canonicalPath = realpathSync4.native(absolutePath);
53205
54128
  } catch {
@@ -53207,7 +54130,7 @@ function toCanonicalPath(absolutePath) {
53207
54130
  }
53208
54131
  } else {
53209
54132
  const absoluteDir = dirname15(absolutePath);
53210
- const resolvedDir = existsSync56(absoluteDir) ? realpathSync4.native(absoluteDir) : absoluteDir;
54133
+ const resolvedDir = existsSync57(absoluteDir) ? realpathSync4.native(absoluteDir) : absoluteDir;
53211
54134
  canonicalPath = join64(resolvedDir, basename6(absolutePath));
53212
54135
  }
53213
54136
  return normalize(canonicalPath);
@@ -53308,7 +54231,7 @@ function createWriteExistingFileGuardHook(ctx) {
53308
54231
  return;
53309
54232
  }
53310
54233
  if (toolName === "read") {
53311
- if (!existsSync56(resolvedPath) || !input.sessionID) {
54234
+ if (!existsSync57(resolvedPath) || !input.sessionID) {
53312
54235
  return;
53313
54236
  }
53314
54237
  registerReadPermission(input.sessionID, canonicalPath);
@@ -53318,7 +54241,7 @@ function createWriteExistingFileGuardHook(ctx) {
53318
54241
  if (argsRecord && "overwrite" in argsRecord) {
53319
54242
  delete argsRecord.overwrite;
53320
54243
  }
53321
- if (!existsSync56(resolvedPath)) {
54244
+ if (!existsSync57(resolvedPath)) {
53322
54245
  return;
53323
54246
  }
53324
54247
  const isCoderPath2 = canonicalPath.includes("/.drizzy/");
@@ -54125,7 +55048,7 @@ function createAnthropicEffortHook() {
54125
55048
  const { model, message } = input;
54126
55049
  if (!model?.modelID || !model?.providerID)
54127
55050
  return;
54128
- if (message.variant !== "max")
55051
+ if (message.model?.variant !== "max")
54129
55052
  return;
54130
55053
  if (!isClaudeProvider(model.providerID, model.modelID))
54131
55054
  return;
@@ -54401,13 +55324,13 @@ var DEFAULT_MAX_SYMBOLS = 200;
54401
55324
  var DEFAULT_MAX_DIAGNOSTICS = 200;
54402
55325
  var DEFAULT_MAX_DIRECTORY_FILES = 50;
54403
55326
  // src/tools/lsp/server-config-loader.ts
54404
- import { existsSync as existsSync57, readFileSync as readFileSync42 } from "fs";
55327
+ import { existsSync as existsSync58, readFileSync as readFileSync43 } from "fs";
54405
55328
  import { join as join65 } from "path";
54406
55329
  function loadJsonFile(path12) {
54407
- if (!existsSync57(path12))
55330
+ if (!existsSync58(path12))
54408
55331
  return null;
54409
55332
  try {
54410
- return parseJsonc(readFileSync42(path12, "utf-8"));
55333
+ return parseJsonc(readFileSync43(path12, "utf-8"));
54411
55334
  } catch {
54412
55335
  return null;
54413
55336
  }
@@ -54487,7 +55410,7 @@ function getMergedServers() {
54487
55410
  }
54488
55411
 
54489
55412
  // src/tools/lsp/server-installation.ts
54490
- import { existsSync as existsSync58 } from "fs";
55413
+ import { existsSync as existsSync59 } from "fs";
54491
55414
  import { delimiter, join as join67 } from "path";
54492
55415
 
54493
55416
  // src/tools/lsp/server-path-bases.ts
@@ -54510,7 +55433,7 @@ function isServerInstalled(command) {
54510
55433
  return false;
54511
55434
  const cmd = command[0];
54512
55435
  if (cmd.includes("/") || cmd.includes("\\")) {
54513
- if (existsSync58(cmd))
55436
+ if (existsSync59(cmd))
54514
55437
  return true;
54515
55438
  }
54516
55439
  const isWindows2 = process.platform === "win32";
@@ -54531,14 +55454,14 @@ function isServerInstalled(command) {
54531
55454
  const paths = pathEnv.split(delimiter);
54532
55455
  for (const p of paths) {
54533
55456
  for (const suffix of exts) {
54534
- if (existsSync58(join67(p, cmd + suffix))) {
55457
+ if (existsSync59(join67(p, cmd + suffix))) {
54535
55458
  return true;
54536
55459
  }
54537
55460
  }
54538
55461
  }
54539
55462
  for (const base of getLspServerAdditionalPathBases(process.cwd())) {
54540
55463
  for (const suffix of exts) {
54541
- if (existsSync58(join67(base, cmd + suffix))) {
55464
+ if (existsSync59(join67(base, cmd + suffix))) {
54542
55465
  return true;
54543
55466
  }
54544
55467
  }
@@ -54596,13 +55519,13 @@ function getLanguageId(ext) {
54596
55519
  init_logger();
54597
55520
  var {spawn: bunSpawn2 } = globalThis.Bun;
54598
55521
  import { spawn as nodeSpawn2 } from "child_process";
54599
- import { existsSync as existsSync59, statSync as statSync7 } from "fs";
55522
+ import { existsSync as existsSync60, statSync as statSync7 } from "fs";
54600
55523
  function shouldUseNodeSpawn() {
54601
55524
  return process.platform === "win32";
54602
55525
  }
54603
55526
  function validateCwd(cwd) {
54604
55527
  try {
54605
- if (!existsSync59(cwd)) {
55528
+ if (!existsSync60(cwd)) {
54606
55529
  return { valid: false, error: `Working directory does not exist: ${cwd}` };
54607
55530
  }
54608
55531
  const stats = statSync7(cwd);
@@ -54734,7 +55657,7 @@ function spawnProcess(command, options) {
54734
55657
  return proc;
54735
55658
  }
54736
55659
  // src/tools/lsp/lsp-client.ts
54737
- import { readFileSync as readFileSync43 } from "fs";
55660
+ import { readFileSync as readFileSync44 } from "fs";
54738
55661
  import { extname as extname3, resolve as resolve9 } from "path";
54739
55662
  import { pathToFileURL as pathToFileURL2 } from "url";
54740
55663
 
@@ -55006,7 +55929,7 @@ class LSPClient extends LSPClientConnection {
55006
55929
  async openFile(filePath) {
55007
55930
  const absPath = resolve9(filePath);
55008
55931
  const uri = pathToFileURL2(absPath).href;
55009
- const text = readFileSync43(absPath, "utf-8");
55932
+ const text = readFileSync44(absPath, "utf-8");
55010
55933
  if (!this.openedFiles.has(absPath)) {
55011
55934
  const ext = extname3(absPath);
55012
55935
  const languageId = getLanguageId(ext);
@@ -55347,9 +56270,9 @@ var lspManager = LSPServerManager.getInstance();
55347
56270
  // src/tools/lsp/lsp-client-wrapper.ts
55348
56271
  import { extname as extname4, resolve as resolve10 } from "path";
55349
56272
  import { fileURLToPath as fileURLToPath3 } from "url";
55350
- import { existsSync as existsSync60, statSync as statSync8 } from "fs";
56273
+ import { existsSync as existsSync61, statSync as statSync8 } from "fs";
55351
56274
  function isDirectoryPath(filePath) {
55352
- if (!existsSync60(filePath)) {
56275
+ if (!existsSync61(filePath)) {
55353
56276
  return false;
55354
56277
  }
55355
56278
  return statSync8(filePath).isDirectory();
@@ -55359,14 +56282,14 @@ function uriToPath(uri) {
55359
56282
  }
55360
56283
  function findWorkspaceRoot(filePath) {
55361
56284
  let dir = resolve10(filePath);
55362
- if (!existsSync60(dir) || !isDirectoryPath(dir)) {
56285
+ if (!existsSync61(dir) || !isDirectoryPath(dir)) {
55363
56286
  dir = __require("path").dirname(dir);
55364
56287
  }
55365
56288
  const markers = [".git", "package.json", "pyproject.toml", "Cargo.toml", "go.mod", "pom.xml", "build.gradle"];
55366
56289
  let prevDir = "";
55367
56290
  while (dir !== prevDir) {
55368
56291
  for (const marker of markers) {
55369
- if (existsSync60(__require("path").join(dir, marker))) {
56292
+ if (existsSync61(__require("path").join(dir, marker))) {
55370
56293
  return dir;
55371
56294
  }
55372
56295
  }
@@ -55541,10 +56464,10 @@ function formatApplyResult(result) {
55541
56464
  `);
55542
56465
  }
55543
56466
  // src/tools/lsp/workspace-edit.ts
55544
- import { readFileSync as readFileSync44, writeFileSync as writeFileSync18 } from "fs";
56467
+ import { readFileSync as readFileSync45, writeFileSync as writeFileSync18 } from "fs";
55545
56468
  function applyTextEditsToFile(filePath, edits) {
55546
56469
  try {
55547
- let content = readFileSync44(filePath, "utf-8");
56470
+ let content = readFileSync45(filePath, "utf-8");
55548
56471
  const lines = content.split(`
55549
56472
  `);
55550
56473
  const sortedEdits = [...edits].sort((a, b) => {
@@ -55610,7 +56533,7 @@ function applyWorkspaceEdit(edit) {
55610
56533
  try {
55611
56534
  const oldPath = uriToPath(change.oldUri);
55612
56535
  const newPath = uriToPath(change.newUri);
55613
- const content = readFileSync44(oldPath, "utf-8");
56536
+ const content = readFileSync45(oldPath, "utf-8");
55614
56537
  writeFileSync18(newPath, content, "utf-8");
55615
56538
  __require("fs").unlinkSync(oldPath);
55616
56539
  result.filesModified.push(newPath);
@@ -68093,7 +69016,7 @@ var lsp_symbols = tool({
68093
69016
  import { resolve as resolve12 } from "path";
68094
69017
 
68095
69018
  // src/tools/lsp/directory-diagnostics.ts
68096
- import { existsSync as existsSync61, lstatSync as lstatSync2, readdirSync as readdirSync17 } from "fs";
69019
+ import { existsSync as existsSync62, lstatSync as lstatSync2, readdirSync as readdirSync17 } from "fs";
68097
69020
  import { extname as extname5, join as join68, resolve as resolve11 } from "path";
68098
69021
  var SKIP_DIRECTORIES = new Set(["node_modules", ".git", "dist", "build", ".next", "out"]);
68099
69022
  function collectFilesWithExtension(dir, extension, maxFiles) {
@@ -68139,7 +69062,7 @@ async function aggregateDiagnosticsForDirectory(directory, extension, severity,
68139
69062
  throw new Error(`Extension must start with a dot (e.g., ".ts", not "${extension}"). ` + `Use ".${extension}" instead.`);
68140
69063
  }
68141
69064
  const absDir = resolve11(directory);
68142
- if (!existsSync61(absDir)) {
69065
+ if (!existsSync62(absDir)) {
68143
69066
  throw new Error(`Directory does not exist: ${absDir}`);
68144
69067
  }
68145
69068
  const serverResult = findServerForExtension(extension);
@@ -68342,10 +69265,10 @@ var DEFAULT_MAX_MATCHES = 500;
68342
69265
  // src/tools/ast-grep/sg-cli-path.ts
68343
69266
  import { createRequire as createRequire4 } from "module";
68344
69267
  import { dirname as dirname16, join as join70 } from "path";
68345
- import { existsSync as existsSync63, statSync as statSync9 } from "fs";
69268
+ import { existsSync as existsSync64, statSync as statSync9 } from "fs";
68346
69269
 
68347
69270
  // src/tools/ast-grep/downloader.ts
68348
- import { existsSync as existsSync62 } from "fs";
69271
+ import { existsSync as existsSync63 } from "fs";
68349
69272
  import { join as join69 } from "path";
68350
69273
  import { homedir as homedir13 } from "os";
68351
69274
  import { createRequire as createRequire3 } from "module";
@@ -68396,7 +69319,7 @@ async function downloadAstGrep(version3 = DEFAULT_VERSION) {
68396
69319
  const cacheDir = getCacheDir3();
68397
69320
  const binaryName = getBinaryName3();
68398
69321
  const binaryPath = join69(cacheDir, binaryName);
68399
- if (existsSync62(binaryPath)) {
69322
+ if (existsSync63(binaryPath)) {
68400
69323
  return binaryPath;
68401
69324
  }
68402
69325
  const { arch, os: os6 } = platformInfo;
@@ -68459,7 +69382,7 @@ function findSgCliPathSync() {
68459
69382
  const cliPackageJsonPath = require2.resolve("@ast-grep/cli/package.json");
68460
69383
  const cliDirectory = dirname16(cliPackageJsonPath);
68461
69384
  const sgPath = join70(cliDirectory, binaryName);
68462
- if (existsSync63(sgPath) && isValidBinary(sgPath)) {
69385
+ if (existsSync64(sgPath) && isValidBinary(sgPath)) {
68463
69386
  return sgPath;
68464
69387
  }
68465
69388
  } catch {}
@@ -68471,7 +69394,7 @@ function findSgCliPathSync() {
68471
69394
  const packageDirectory = dirname16(packageJsonPath);
68472
69395
  const astGrepBinaryName = process.platform === "win32" ? "ast-grep.exe" : "ast-grep";
68473
69396
  const binaryPath = join70(packageDirectory, astGrepBinaryName);
68474
- if (existsSync63(binaryPath) && isValidBinary(binaryPath)) {
69397
+ if (existsSync64(binaryPath) && isValidBinary(binaryPath)) {
68475
69398
  return binaryPath;
68476
69399
  }
68477
69400
  } catch {}
@@ -68479,7 +69402,7 @@ function findSgCliPathSync() {
68479
69402
  if (process.platform === "darwin") {
68480
69403
  const homebrewPaths = ["/opt/homebrew/bin/sg", "/usr/local/bin/sg"];
68481
69404
  for (const path12 of homebrewPaths) {
68482
- if (existsSync63(path12) && isValidBinary(path12)) {
69405
+ if (existsSync64(path12) && isValidBinary(path12)) {
68483
69406
  return path12;
68484
69407
  }
68485
69408
  }
@@ -68503,14 +69426,14 @@ function setSgCliPath(path12) {
68503
69426
  }
68504
69427
  // src/tools/ast-grep/cli.ts
68505
69428
  var {spawn: spawn10 } = globalThis.Bun;
68506
- import { existsSync as existsSync65 } from "fs";
69429
+ import { existsSync as existsSync66 } from "fs";
68507
69430
 
68508
69431
  // src/tools/ast-grep/cli-binary-path-resolution.ts
68509
- import { existsSync as existsSync64 } from "fs";
69432
+ import { existsSync as existsSync65 } from "fs";
68510
69433
  var resolvedCliPath3 = null;
68511
69434
  var initPromise3 = null;
68512
69435
  async function getAstGrepPath() {
68513
- if (resolvedCliPath3 !== null && existsSync64(resolvedCliPath3)) {
69436
+ if (resolvedCliPath3 !== null && existsSync65(resolvedCliPath3)) {
68514
69437
  return resolvedCliPath3;
68515
69438
  }
68516
69439
  if (initPromise3) {
@@ -68518,7 +69441,7 @@ async function getAstGrepPath() {
68518
69441
  }
68519
69442
  initPromise3 = (async () => {
68520
69443
  const syncPath = findSgCliPathSync();
68521
- if (syncPath && existsSync64(syncPath)) {
69444
+ if (syncPath && existsSync65(syncPath)) {
68522
69445
  resolvedCliPath3 = syncPath;
68523
69446
  setSgCliPath(syncPath);
68524
69447
  return syncPath;
@@ -68617,7 +69540,7 @@ async function runSg(options) {
68617
69540
  const paths = options.paths && options.paths.length > 0 ? options.paths : ["."];
68618
69541
  args.push(...paths);
68619
69542
  let cliPath = getSgCliPath();
68620
- if (!cliPath || !existsSync65(cliPath)) {
69543
+ if (!cliPath || !existsSync66(cliPath)) {
68621
69544
  const downloadedPath = await getAstGrepPath();
68622
69545
  if (downloadedPath) {
68623
69546
  cliPath = downloadedPath;
@@ -68871,12 +69794,12 @@ import { resolve as resolve13 } from "path";
68871
69794
  var {spawn: spawn11 } = globalThis.Bun;
68872
69795
 
68873
69796
  // src/tools/grep/constants.ts
68874
- import { existsSync as existsSync67 } from "fs";
69797
+ import { existsSync as existsSync68 } from "fs";
68875
69798
  import { join as join72, dirname as dirname17 } from "path";
68876
69799
  import { spawnSync as spawnSync2 } from "child_process";
68877
69800
 
68878
69801
  // src/tools/grep/downloader.ts
68879
- import { existsSync as existsSync66, readdirSync as readdirSync18 } from "fs";
69802
+ import { existsSync as existsSync67, readdirSync as readdirSync18 } from "fs";
68880
69803
  import { join as join71 } from "path";
68881
69804
  function findFileRecursive(dir, filename) {
68882
69805
  try {
@@ -68940,7 +69863,7 @@ async function downloadAndInstallRipgrep() {
68940
69863
  }
68941
69864
  const installDir = getInstallDir();
68942
69865
  const rgPath = getRgPath();
68943
- if (existsSync66(rgPath)) {
69866
+ if (existsSync67(rgPath)) {
68944
69867
  return rgPath;
68945
69868
  }
68946
69869
  ensureCacheDir(installDir);
@@ -68955,7 +69878,7 @@ async function downloadAndInstallRipgrep() {
68955
69878
  await extractZip2(archivePath, installDir);
68956
69879
  }
68957
69880
  ensureExecutable(rgPath);
68958
- if (!existsSync66(rgPath)) {
69881
+ if (!existsSync67(rgPath)) {
68959
69882
  throw new Error("ripgrep binary not found after extraction");
68960
69883
  }
68961
69884
  return rgPath;
@@ -68967,7 +69890,7 @@ async function downloadAndInstallRipgrep() {
68967
69890
  }
68968
69891
  function getInstalledRipgrepPath() {
68969
69892
  const rgPath = getRgPath();
68970
- return existsSync66(rgPath) ? rgPath : null;
69893
+ return existsSync67(rgPath) ? rgPath : null;
68971
69894
  }
68972
69895
 
68973
69896
  // src/tools/grep/constants.ts
@@ -68998,7 +69921,7 @@ function getOpenCodeBundledRg() {
68998
69921
  join72(execDir, "..", "libexec", rgName)
68999
69922
  ];
69000
69923
  for (const candidate of candidates) {
69001
- if (existsSync67(candidate)) {
69924
+ if (existsSync68(candidate)) {
69002
69925
  return candidate;
69003
69926
  }
69004
69927
  }
@@ -69637,10 +70560,10 @@ Use this when a task matches an available skill's or command's description.
69637
70560
  // src/tools/skill/tools.ts
69638
70561
  import { dirname as dirname19 } from "path";
69639
70562
  // src/tools/slashcommand/command-discovery.ts
69640
- import { existsSync as existsSync68, readdirSync as readdirSync19, readFileSync as readFileSync45 } from "fs";
70563
+ import { existsSync as existsSync69, readdirSync as readdirSync19, readFileSync as readFileSync46 } from "fs";
69641
70564
  import { basename as basename7, join as join73 } from "path";
69642
70565
  function discoverCommandsFromDir2(commandsDir, scope) {
69643
- if (!existsSync68(commandsDir))
70566
+ if (!existsSync69(commandsDir))
69644
70567
  return [];
69645
70568
  const entries = readdirSync19(commandsDir, { withFileTypes: true });
69646
70569
  const commands3 = [];
@@ -69650,7 +70573,7 @@ function discoverCommandsFromDir2(commandsDir, scope) {
69650
70573
  const commandPath = join73(commandsDir, entry.name);
69651
70574
  const commandName = basename7(entry.name, ".md");
69652
70575
  try {
69653
- const content = readFileSync45(commandPath, "utf-8");
70576
+ const content = readFileSync46(commandPath, "utf-8");
69654
70577
  const { data, body } = parseFrontmatter(content);
69655
70578
  const isOpencodeSource = scope === "opencode" || scope === "opencode-project";
69656
70579
  const metadata = {
@@ -70105,7 +71028,7 @@ Has Todos: Yes (12 items, 8 completed)
70105
71028
  Has Transcript: Yes (234 entries)`;
70106
71029
 
70107
71030
  // src/tools/session-manager/storage.ts
70108
- import { existsSync as existsSync69 } from "fs";
71031
+ import { existsSync as existsSync70 } from "fs";
70109
71032
  import { readdir, readFile } from "fs/promises";
70110
71033
  import { join as join75 } from "path";
70111
71034
  var sdkClient = null;
@@ -70126,7 +71049,7 @@ async function getMainSessions(options) {
70126
71049
  return [];
70127
71050
  }
70128
71051
  }
70129
- if (!existsSync69(SESSION_STORAGE))
71052
+ if (!existsSync70(SESSION_STORAGE))
70130
71053
  return [];
70131
71054
  const sessions = [];
70132
71055
  try {
@@ -70167,7 +71090,7 @@ async function getAllSessions() {
70167
71090
  return [];
70168
71091
  }
70169
71092
  }
70170
- if (!existsSync69(MESSAGE_STORAGE))
71093
+ if (!existsSync70(MESSAGE_STORAGE))
70171
71094
  return [];
70172
71095
  const sessions = [];
70173
71096
  async function scanDirectory(dir) {
@@ -70236,7 +71159,7 @@ async function readSessionMessages(sessionID) {
70236
71159
  }
70237
71160
  }
70238
71161
  const messageDir = getMessageDir(sessionID);
70239
- if (!messageDir || !existsSync69(messageDir))
71162
+ if (!messageDir || !existsSync70(messageDir))
70240
71163
  return [];
70241
71164
  const messages = [];
70242
71165
  try {
@@ -70272,7 +71195,7 @@ async function readSessionMessages(sessionID) {
70272
71195
  }
70273
71196
  async function readParts2(messageID) {
70274
71197
  const partDir = join75(PART_STORAGE, messageID);
70275
- if (!existsSync69(partDir))
71198
+ if (!existsSync70(partDir))
70276
71199
  return [];
70277
71200
  const parts = [];
70278
71201
  try {
@@ -70307,7 +71230,7 @@ async function readSessionTodos(sessionID) {
70307
71230
  return [];
70308
71231
  }
70309
71232
  }
70310
- if (!existsSync69(TODO_DIR2))
71233
+ if (!existsSync70(TODO_DIR2))
70311
71234
  return [];
70312
71235
  try {
70313
71236
  const allFiles = await readdir(TODO_DIR2);
@@ -70334,10 +71257,10 @@ async function readSessionTodos(sessionID) {
70334
71257
  return [];
70335
71258
  }
70336
71259
  async function readSessionTranscript(sessionID) {
70337
- if (!existsSync69(TRANSCRIPT_DIR2))
71260
+ if (!existsSync70(TRANSCRIPT_DIR2))
70338
71261
  return 0;
70339
71262
  const transcriptFile = join75(TRANSCRIPT_DIR2, `${sessionID}.jsonl`);
70340
- if (!existsSync69(transcriptFile))
71263
+ if (!existsSync70(transcriptFile))
70341
71264
  return 0;
70342
71265
  try {
70343
71266
  const content = await readFile(transcriptFile, "utf-8");
@@ -72186,7 +73109,7 @@ async function resolveMultimodalLookerAgentMetadata(ctx) {
72186
73109
 
72187
73110
  // src/tools/look-at/image-converter.ts
72188
73111
  import { execFileSync as execFileSync3 } from "child_process";
72189
- import { existsSync as existsSync70, mkdtempSync, readFileSync as readFileSync46, rmSync as rmSync3, unlinkSync as unlinkSync11, writeFileSync as writeFileSync19 } from "fs";
73112
+ import { existsSync as existsSync71, mkdtempSync, readFileSync as readFileSync47, rmSync as rmSync3, unlinkSync as unlinkSync11, writeFileSync as writeFileSync19 } from "fs";
72190
73113
  import { tmpdir as tmpdir6 } from "os";
72191
73114
  import { dirname as dirname20, join as join76 } from "path";
72192
73115
  var SUPPORTED_FORMATS = new Set([
@@ -72226,7 +73149,7 @@ function needsConversion(mimeType) {
72226
73149
  return mimeType.startsWith("image/");
72227
73150
  }
72228
73151
  function convertImageToJpeg(inputPath, mimeType) {
72229
- if (!existsSync70(inputPath)) {
73152
+ if (!existsSync71(inputPath)) {
72230
73153
  throw new Error(`File not found: ${inputPath}`);
72231
73154
  }
72232
73155
  const tempDir = mkdtempSync(join76(tmpdir6(), "opencode-img-"));
@@ -72240,7 +73163,7 @@ function convertImageToJpeg(inputPath, mimeType) {
72240
73163
  encoding: "utf-8",
72241
73164
  timeout: CONVERSION_TIMEOUT_MS
72242
73165
  });
72243
- if (existsSync70(outputPath)) {
73166
+ if (existsSync71(outputPath)) {
72244
73167
  log(`[image-converter] Converted using sips: ${outputPath}`);
72245
73168
  return outputPath;
72246
73169
  }
@@ -72255,7 +73178,7 @@ function convertImageToJpeg(inputPath, mimeType) {
72255
73178
  encoding: "utf-8",
72256
73179
  timeout: CONVERSION_TIMEOUT_MS
72257
73180
  });
72258
- if (existsSync70(outputPath)) {
73181
+ if (existsSync71(outputPath)) {
72259
73182
  log(`[image-converter] Converted using ImageMagick: ${outputPath}`);
72260
73183
  return outputPath;
72261
73184
  }
@@ -72268,7 +73191,7 @@ function convertImageToJpeg(inputPath, mimeType) {
72268
73191
  ` + ` RHEL/CentOS: sudo yum install ImageMagick`);
72269
73192
  } catch (error92) {
72270
73193
  try {
72271
- if (existsSync70(outputPath)) {
73194
+ if (existsSync71(outputPath)) {
72272
73195
  unlinkSync11(outputPath);
72273
73196
  }
72274
73197
  } catch {}
@@ -72282,11 +73205,11 @@ function convertImageToJpeg(inputPath, mimeType) {
72282
73205
  function cleanupConvertedImage(filePath) {
72283
73206
  try {
72284
73207
  const tempDirectory = dirname20(filePath);
72285
- if (existsSync70(filePath)) {
73208
+ if (existsSync71(filePath)) {
72286
73209
  unlinkSync11(filePath);
72287
73210
  log(`[image-converter] Cleaned up temporary file: ${filePath}`);
72288
73211
  }
72289
- if (existsSync70(tempDirectory)) {
73212
+ if (existsSync71(tempDirectory)) {
72290
73213
  rmSync3(tempDirectory, { recursive: true, force: true });
72291
73214
  log(`[image-converter] Cleaned up temporary directory: ${tempDirectory}`);
72292
73215
  }
@@ -72306,14 +73229,14 @@ function convertBase64ImageToJpeg(base64Data, mimeType) {
72306
73229
  log(`[image-converter] Converting Base64 ${mimeType} to JPEG`);
72307
73230
  const outputPath = convertImageToJpeg(inputPath, mimeType);
72308
73231
  tempFiles.push(outputPath);
72309
- const convertedBuffer = readFileSync46(outputPath);
73232
+ const convertedBuffer = readFileSync47(outputPath);
72310
73233
  const convertedBase64 = convertedBuffer.toString("base64");
72311
73234
  log(`[image-converter] Base64 conversion successful`);
72312
73235
  return { base64: convertedBase64, tempFiles };
72313
73236
  } catch (error92) {
72314
73237
  tempFiles.forEach((file3) => {
72315
73238
  try {
72316
- if (existsSync70(file3))
73239
+ if (existsSync71(file3))
72317
73240
  unlinkSync11(file3);
72318
73241
  } catch {}
72319
73242
  });
@@ -72476,8 +73399,12 @@ Original error: ${createResult.error}`;
72476
73399
  { type: "text", text: prompt },
72477
73400
  filePart
72478
73401
  ],
72479
- ...agentModel ? { model: { providerID: agentModel.providerID, modelID: agentModel.modelID } } : {},
72480
- ...agentVariant ? { variant: agentVariant } : {}
73402
+ ...agentModel || agentVariant ? {
73403
+ model: {
73404
+ ...agentModel ? { providerID: agentModel.providerID, modelID: agentModel.modelID } : {},
73405
+ ...agentVariant ? { variant: agentVariant } : {}
73406
+ }
73407
+ } : {}
72481
73408
  }
72482
73409
  });
72483
73410
  } catch (promptError) {
@@ -73692,8 +74619,12 @@ async function executeSyncContinuation(args, ctx, executorCtx, deps = syncContin
73692
74619
  path: { id: args.session_id },
73693
74620
  body: {
73694
74621
  ...resumeAgent !== undefined ? { agent: resumeAgent } : {},
73695
- ...resumeModel !== undefined ? { model: resumeModel } : {},
73696
- ...resumeVariant !== undefined ? { variant: resumeVariant } : {},
74622
+ ...resumeModel !== undefined || resumeVariant !== undefined ? {
74623
+ model: {
74624
+ ...resumeModel ?? {},
74625
+ ...resumeVariant !== undefined ? { variant: resumeVariant } : {}
74626
+ }
74627
+ } : {},
73697
74628
  tools,
73698
74629
  parts: [{ type: "text", text: effectivePrompt }]
73699
74630
  }
@@ -74070,8 +75001,13 @@ async function sendSyncPrompt(client2, input, deps = sendSyncPromptDeps) {
74070
75001
  system: input.systemContent,
74071
75002
  tools,
74072
75003
  parts: [createInternalAgentTextPart(effectivePrompt)],
74073
- ...input.categoryModel ? { model: { providerID: input.categoryModel.providerID, modelID: input.categoryModel.modelID } } : {},
74074
- ...input.categoryModel?.variant ? { variant: input.categoryModel.variant } : {}
75004
+ ...input.categoryModel ? {
75005
+ model: {
75006
+ providerID: input.categoryModel.providerID,
75007
+ modelID: input.categoryModel.modelID,
75008
+ ...input.categoryModel.variant ? { variant: input.categoryModel.variant } : {}
75009
+ }
75010
+ } : {}
74075
75011
  }
74076
75012
  };
74077
75013
  try {
@@ -74981,7 +75917,7 @@ var TaskDeleteInputSchema = exports_external.object({
74981
75917
 
74982
75918
  // src/features/claude-tasks/storage.ts
74983
75919
  import { join as join77, dirname as dirname21, basename as basename9, isAbsolute as isAbsolute9 } from "path";
74984
- import { existsSync as existsSync71, mkdirSync as mkdirSync14, readFileSync as readFileSync47, writeFileSync as writeFileSync20, renameSync as renameSync2, unlinkSync as unlinkSync12, readdirSync as readdirSync20 } from "fs";
75920
+ import { existsSync as existsSync72, mkdirSync as mkdirSync14, readFileSync as readFileSync48, writeFileSync as writeFileSync20, renameSync as renameSync2, unlinkSync as unlinkSync12, readdirSync as readdirSync20 } from "fs";
74985
75921
  import { randomUUID as randomUUID3 } from "crypto";
74986
75922
  function getTaskDir(config4 = {}) {
74987
75923
  const tasksConfig = config4.coder?.tasks;
@@ -75009,16 +75945,16 @@ function resolveTaskListId(config4 = {}) {
75009
75945
  return sanitizePathSegment(basename9(process.cwd()));
75010
75946
  }
75011
75947
  function ensureDir(dirPath) {
75012
- if (!existsSync71(dirPath)) {
75948
+ if (!existsSync72(dirPath)) {
75013
75949
  mkdirSync14(dirPath, { recursive: true });
75014
75950
  }
75015
75951
  }
75016
75952
  function readJsonSafe(filePath, schema2) {
75017
75953
  try {
75018
- if (!existsSync71(filePath)) {
75954
+ if (!existsSync72(filePath)) {
75019
75955
  return null;
75020
75956
  }
75021
- const content = readFileSync47(filePath, "utf-8");
75957
+ const content = readFileSync48(filePath, "utf-8");
75022
75958
  const parsed = JSON.parse(content);
75023
75959
  const result = schema2.safeParse(parsed);
75024
75960
  if (!result.success) {
@@ -75038,7 +75974,7 @@ function writeJsonAtomic(filePath, data) {
75038
75974
  renameSync2(tempPath, filePath);
75039
75975
  } catch (error92) {
75040
75976
  try {
75041
- if (existsSync71(tempPath)) {
75977
+ if (existsSync72(tempPath)) {
75042
75978
  unlinkSync12(tempPath);
75043
75979
  }
75044
75980
  } catch {}
@@ -75060,7 +75996,7 @@ function acquireLock(dirPath) {
75060
75996
  };
75061
75997
  const isStale = () => {
75062
75998
  try {
75063
- const lockContent = readFileSync47(lockPath, "utf-8");
75999
+ const lockContent = readFileSync48(lockPath, "utf-8");
75064
76000
  const lockData = JSON.parse(lockContent);
75065
76001
  const lockAge = Date.now() - lockData.timestamp;
75066
76002
  return lockAge > STALE_LOCK_THRESHOLD_MS;
@@ -75098,9 +76034,9 @@ function acquireLock(dirPath) {
75098
76034
  acquired: true,
75099
76035
  release: () => {
75100
76036
  try {
75101
- if (!existsSync71(lockPath))
76037
+ if (!existsSync72(lockPath))
75102
76038
  return;
75103
- const lockContent = readFileSync47(lockPath, "utf-8");
76039
+ const lockContent = readFileSync48(lockPath, "utf-8");
75104
76040
  const lockData = JSON.parse(lockContent);
75105
76041
  if (lockData.id !== lockId)
75106
76042
  return;
@@ -75324,7 +76260,7 @@ Returns null if the task does not exist or the file is invalid.`,
75324
76260
  }
75325
76261
  // src/tools/task/task-list.ts
75326
76262
  import { join as join80 } from "path";
75327
- import { existsSync as existsSync72, readdirSync as readdirSync21 } from "fs";
76263
+ import { existsSync as existsSync73, readdirSync as readdirSync21 } from "fs";
75328
76264
  function createTaskList(config4) {
75329
76265
  return tool({
75330
76266
  description: `List all active tasks with summary information.
@@ -75335,7 +76271,7 @@ Returns summary format: id, subject, status, owner, blockedBy (not full descript
75335
76271
  args: {},
75336
76272
  execute: async () => {
75337
76273
  const taskDir = getTaskDir(config4);
75338
- if (!existsSync72(taskDir)) {
76274
+ if (!existsSync73(taskDir)) {
75339
76275
  return JSON.stringify({ tasks: [] });
75340
76276
  }
75341
76277
  const files = readdirSync21(taskDir).filter((f) => f.endsWith(".json") && f.startsWith("T-")).map((f) => f.replace(".json", ""));
@@ -76105,445 +77041,6 @@ function applyHashlineEditsWithReport(content, edits) {
76105
77041
  deduplicatedEdits: dedupeResult.deduplicatedEdits
76106
77042
  };
76107
77043
  }
76108
- // node_modules/diff/libesm/diff/base.js
76109
- class Diff {
76110
- diff(oldStr, newStr, options = {}) {
76111
- let callback;
76112
- if (typeof options === "function") {
76113
- callback = options;
76114
- options = {};
76115
- } else if ("callback" in options) {
76116
- callback = options.callback;
76117
- }
76118
- const oldString = this.castInput(oldStr, options);
76119
- const newString = this.castInput(newStr, options);
76120
- const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
76121
- const newTokens = this.removeEmpty(this.tokenize(newString, options));
76122
- return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
76123
- }
76124
- diffWithOptionsObj(oldTokens, newTokens, options, callback) {
76125
- var _a2;
76126
- const done = (value) => {
76127
- value = this.postProcess(value, options);
76128
- if (callback) {
76129
- setTimeout(function() {
76130
- callback(value);
76131
- }, 0);
76132
- return;
76133
- } else {
76134
- return value;
76135
- }
76136
- };
76137
- const newLen = newTokens.length, oldLen = oldTokens.length;
76138
- let editLength = 1;
76139
- let maxEditLength = newLen + oldLen;
76140
- if (options.maxEditLength != null) {
76141
- maxEditLength = Math.min(maxEditLength, options.maxEditLength);
76142
- }
76143
- const maxExecutionTime = (_a2 = options.timeout) !== null && _a2 !== undefined ? _a2 : Infinity;
76144
- const abortAfterTimestamp = Date.now() + maxExecutionTime;
76145
- const bestPath = [{ oldPos: -1, lastComponent: undefined }];
76146
- let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
76147
- if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
76148
- return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
76149
- }
76150
- let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
76151
- const execEditLength = () => {
76152
- for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength);diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
76153
- let basePath;
76154
- const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
76155
- if (removePath) {
76156
- bestPath[diagonalPath - 1] = undefined;
76157
- }
76158
- let canAdd = false;
76159
- if (addPath) {
76160
- const addPathNewPos = addPath.oldPos - diagonalPath;
76161
- canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
76162
- }
76163
- const canRemove = removePath && removePath.oldPos + 1 < oldLen;
76164
- if (!canAdd && !canRemove) {
76165
- bestPath[diagonalPath] = undefined;
76166
- continue;
76167
- }
76168
- if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
76169
- basePath = this.addToPath(addPath, true, false, 0, options);
76170
- } else {
76171
- basePath = this.addToPath(removePath, false, true, 1, options);
76172
- }
76173
- newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
76174
- if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
76175
- return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
76176
- } else {
76177
- bestPath[diagonalPath] = basePath;
76178
- if (basePath.oldPos + 1 >= oldLen) {
76179
- maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
76180
- }
76181
- if (newPos + 1 >= newLen) {
76182
- minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
76183
- }
76184
- }
76185
- }
76186
- editLength++;
76187
- };
76188
- if (callback) {
76189
- (function exec2() {
76190
- setTimeout(function() {
76191
- if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
76192
- return callback(undefined);
76193
- }
76194
- if (!execEditLength()) {
76195
- exec2();
76196
- }
76197
- }, 0);
76198
- })();
76199
- } else {
76200
- while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
76201
- const ret = execEditLength();
76202
- if (ret) {
76203
- return ret;
76204
- }
76205
- }
76206
- }
76207
- }
76208
- addToPath(path12, added, removed, oldPosInc, options) {
76209
- const last = path12.lastComponent;
76210
- if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
76211
- return {
76212
- oldPos: path12.oldPos + oldPosInc,
76213
- lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
76214
- };
76215
- } else {
76216
- return {
76217
- oldPos: path12.oldPos + oldPosInc,
76218
- lastComponent: { count: 1, added, removed, previousComponent: last }
76219
- };
76220
- }
76221
- }
76222
- extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
76223
- const newLen = newTokens.length, oldLen = oldTokens.length;
76224
- let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
76225
- while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
76226
- newPos++;
76227
- oldPos++;
76228
- commonCount++;
76229
- if (options.oneChangePerToken) {
76230
- basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };
76231
- }
76232
- }
76233
- if (commonCount && !options.oneChangePerToken) {
76234
- basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };
76235
- }
76236
- basePath.oldPos = oldPos;
76237
- return newPos;
76238
- }
76239
- equals(left, right, options) {
76240
- if (options.comparator) {
76241
- return options.comparator(left, right);
76242
- } else {
76243
- return left === right || !!options.ignoreCase && left.toLowerCase() === right.toLowerCase();
76244
- }
76245
- }
76246
- removeEmpty(array3) {
76247
- const ret = [];
76248
- for (let i2 = 0;i2 < array3.length; i2++) {
76249
- if (array3[i2]) {
76250
- ret.push(array3[i2]);
76251
- }
76252
- }
76253
- return ret;
76254
- }
76255
- castInput(value, options) {
76256
- return value;
76257
- }
76258
- tokenize(value, options) {
76259
- return Array.from(value);
76260
- }
76261
- join(chars) {
76262
- return chars.join("");
76263
- }
76264
- postProcess(changeObjects, options) {
76265
- return changeObjects;
76266
- }
76267
- get useLongestToken() {
76268
- return false;
76269
- }
76270
- buildValues(lastComponent, newTokens, oldTokens) {
76271
- const components = [];
76272
- let nextComponent;
76273
- while (lastComponent) {
76274
- components.push(lastComponent);
76275
- nextComponent = lastComponent.previousComponent;
76276
- delete lastComponent.previousComponent;
76277
- lastComponent = nextComponent;
76278
- }
76279
- components.reverse();
76280
- const componentLen = components.length;
76281
- let componentPos = 0, newPos = 0, oldPos = 0;
76282
- for (;componentPos < componentLen; componentPos++) {
76283
- const component = components[componentPos];
76284
- if (!component.removed) {
76285
- if (!component.added && this.useLongestToken) {
76286
- let value = newTokens.slice(newPos, newPos + component.count);
76287
- value = value.map(function(value2, i2) {
76288
- const oldValue = oldTokens[oldPos + i2];
76289
- return oldValue.length > value2.length ? oldValue : value2;
76290
- });
76291
- component.value = this.join(value);
76292
- } else {
76293
- component.value = this.join(newTokens.slice(newPos, newPos + component.count));
76294
- }
76295
- newPos += component.count;
76296
- if (!component.added) {
76297
- oldPos += component.count;
76298
- }
76299
- } else {
76300
- component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
76301
- oldPos += component.count;
76302
- }
76303
- }
76304
- return components;
76305
- }
76306
- }
76307
-
76308
- // node_modules/diff/libesm/diff/line.js
76309
- class LineDiff extends Diff {
76310
- constructor() {
76311
- super(...arguments);
76312
- this.tokenize = tokenize;
76313
- }
76314
- equals(left, right, options) {
76315
- if (options.ignoreWhitespace) {
76316
- if (!options.newlineIsToken || !left.includes(`
76317
- `)) {
76318
- left = left.trim();
76319
- }
76320
- if (!options.newlineIsToken || !right.includes(`
76321
- `)) {
76322
- right = right.trim();
76323
- }
76324
- } else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
76325
- if (left.endsWith(`
76326
- `)) {
76327
- left = left.slice(0, -1);
76328
- }
76329
- if (right.endsWith(`
76330
- `)) {
76331
- right = right.slice(0, -1);
76332
- }
76333
- }
76334
- return super.equals(left, right, options);
76335
- }
76336
- }
76337
- var lineDiff = new LineDiff;
76338
- function diffLines(oldStr, newStr, options) {
76339
- return lineDiff.diff(oldStr, newStr, options);
76340
- }
76341
- function tokenize(value, options) {
76342
- if (options.stripTrailingCr) {
76343
- value = value.replace(/\r\n/g, `
76344
- `);
76345
- }
76346
- const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
76347
- if (!linesAndNewlines[linesAndNewlines.length - 1]) {
76348
- linesAndNewlines.pop();
76349
- }
76350
- for (let i2 = 0;i2 < linesAndNewlines.length; i2++) {
76351
- const line = linesAndNewlines[i2];
76352
- if (i2 % 2 && !options.newlineIsToken) {
76353
- retLines[retLines.length - 1] += line;
76354
- } else {
76355
- retLines.push(line);
76356
- }
76357
- }
76358
- return retLines;
76359
- }
76360
-
76361
- // node_modules/diff/libesm/patch/create.js
76362
- var INCLUDE_HEADERS = {
76363
- includeIndex: true,
76364
- includeUnderline: true,
76365
- includeFileHeaders: true
76366
- };
76367
- function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
76368
- let optionsObj;
76369
- if (!options) {
76370
- optionsObj = {};
76371
- } else if (typeof options === "function") {
76372
- optionsObj = { callback: options };
76373
- } else {
76374
- optionsObj = options;
76375
- }
76376
- if (typeof optionsObj.context === "undefined") {
76377
- optionsObj.context = 4;
76378
- }
76379
- const context = optionsObj.context;
76380
- if (optionsObj.newlineIsToken) {
76381
- throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");
76382
- }
76383
- if (!optionsObj.callback) {
76384
- return diffLinesResultToPatch(diffLines(oldStr, newStr, optionsObj));
76385
- } else {
76386
- const { callback } = optionsObj;
76387
- diffLines(oldStr, newStr, Object.assign(Object.assign({}, optionsObj), { callback: (diff) => {
76388
- const patch = diffLinesResultToPatch(diff);
76389
- callback(patch);
76390
- } }));
76391
- }
76392
- function diffLinesResultToPatch(diff) {
76393
- if (!diff) {
76394
- return;
76395
- }
76396
- diff.push({ value: "", lines: [] });
76397
- function contextLines(lines) {
76398
- return lines.map(function(entry) {
76399
- return " " + entry;
76400
- });
76401
- }
76402
- const hunks = [];
76403
- let oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1;
76404
- for (let i2 = 0;i2 < diff.length; i2++) {
76405
- const current = diff[i2], lines = current.lines || splitLines(current.value);
76406
- current.lines = lines;
76407
- if (current.added || current.removed) {
76408
- if (!oldRangeStart) {
76409
- const prev = diff[i2 - 1];
76410
- oldRangeStart = oldLine;
76411
- newRangeStart = newLine;
76412
- if (prev) {
76413
- curRange = context > 0 ? contextLines(prev.lines.slice(-context)) : [];
76414
- oldRangeStart -= curRange.length;
76415
- newRangeStart -= curRange.length;
76416
- }
76417
- }
76418
- for (const line of lines) {
76419
- curRange.push((current.added ? "+" : "-") + line);
76420
- }
76421
- if (current.added) {
76422
- newLine += lines.length;
76423
- } else {
76424
- oldLine += lines.length;
76425
- }
76426
- } else {
76427
- if (oldRangeStart) {
76428
- if (lines.length <= context * 2 && i2 < diff.length - 2) {
76429
- for (const line of contextLines(lines)) {
76430
- curRange.push(line);
76431
- }
76432
- } else {
76433
- const contextSize = Math.min(lines.length, context);
76434
- for (const line of contextLines(lines.slice(0, contextSize))) {
76435
- curRange.push(line);
76436
- }
76437
- const hunk = {
76438
- oldStart: oldRangeStart,
76439
- oldLines: oldLine - oldRangeStart + contextSize,
76440
- newStart: newRangeStart,
76441
- newLines: newLine - newRangeStart + contextSize,
76442
- lines: curRange
76443
- };
76444
- hunks.push(hunk);
76445
- oldRangeStart = 0;
76446
- newRangeStart = 0;
76447
- curRange = [];
76448
- }
76449
- }
76450
- oldLine += lines.length;
76451
- newLine += lines.length;
76452
- }
76453
- }
76454
- for (const hunk of hunks) {
76455
- for (let i2 = 0;i2 < hunk.lines.length; i2++) {
76456
- if (hunk.lines[i2].endsWith(`
76457
- `)) {
76458
- hunk.lines[i2] = hunk.lines[i2].slice(0, -1);
76459
- } else {
76460
- hunk.lines.splice(i2 + 1, 0, "\");
76461
- i2++;
76462
- }
76463
- }
76464
- }
76465
- return {
76466
- oldFileName,
76467
- newFileName,
76468
- oldHeader,
76469
- newHeader,
76470
- hunks
76471
- };
76472
- }
76473
- }
76474
- function formatPatch(patch, headerOptions) {
76475
- if (!headerOptions) {
76476
- headerOptions = INCLUDE_HEADERS;
76477
- }
76478
- if (Array.isArray(patch)) {
76479
- if (patch.length > 1 && !headerOptions.includeFileHeaders) {
76480
- throw new Error("Cannot omit file headers on a multi-file patch. " + "(The result would be unparseable; how would a tool trying to apply " + "the patch know which changes are to which file?)");
76481
- }
76482
- return patch.map((p) => formatPatch(p, headerOptions)).join(`
76483
- `);
76484
- }
76485
- const ret = [];
76486
- if (headerOptions.includeIndex && patch.oldFileName == patch.newFileName) {
76487
- ret.push("Index: " + patch.oldFileName);
76488
- }
76489
- if (headerOptions.includeUnderline) {
76490
- ret.push("===================================================================");
76491
- }
76492
- if (headerOptions.includeFileHeaders) {
76493
- ret.push("--- " + patch.oldFileName + (typeof patch.oldHeader === "undefined" ? "" : "\t" + patch.oldHeader));
76494
- ret.push("+++ " + patch.newFileName + (typeof patch.newHeader === "undefined" ? "" : "\t" + patch.newHeader));
76495
- }
76496
- for (let i2 = 0;i2 < patch.hunks.length; i2++) {
76497
- const hunk = patch.hunks[i2];
76498
- if (hunk.oldLines === 0) {
76499
- hunk.oldStart -= 1;
76500
- }
76501
- if (hunk.newLines === 0) {
76502
- hunk.newStart -= 1;
76503
- }
76504
- ret.push("@@ -" + hunk.oldStart + "," + hunk.oldLines + " +" + hunk.newStart + "," + hunk.newLines + " @@");
76505
- for (const line of hunk.lines) {
76506
- ret.push(line);
76507
- }
76508
- }
76509
- return ret.join(`
76510
- `) + `
76511
- `;
76512
- }
76513
- function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
76514
- if (typeof options === "function") {
76515
- options = { callback: options };
76516
- }
76517
- if (!(options === null || options === undefined ? undefined : options.callback)) {
76518
- const patchObj = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
76519
- if (!patchObj) {
76520
- return;
76521
- }
76522
- return formatPatch(patchObj, options === null || options === undefined ? undefined : options.headerOptions);
76523
- } else {
76524
- const { callback } = options;
76525
- structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, Object.assign(Object.assign({}, options), { callback: (patchObj) => {
76526
- if (!patchObj) {
76527
- callback(undefined);
76528
- } else {
76529
- callback(formatPatch(patchObj, options.headerOptions));
76530
- }
76531
- } }));
76532
- }
76533
- }
76534
- function splitLines(text) {
76535
- const hasTrailingNl = text.endsWith(`
76536
- `);
76537
- const result = text.split(`
76538
- `).map((line) => line + `
76539
- `);
76540
- if (hasTrailingNl) {
76541
- result.pop();
76542
- } else {
76543
- result.push(result.pop().slice(0, -1));
76544
- }
76545
- return result;
76546
- }
76547
77044
  // src/tools/hashline-edit/diff-utils.ts
76548
77045
  function generateUnifiedDiff(oldContent, newContent, filePath) {
76549
77046
  return createTwoFilesPatch(filePath, filePath, oldContent, newContent, undefined, undefined, { context: 3 });
@@ -77870,7 +78367,7 @@ function unregisterManagerForCleanup(manager) {
77870
78367
  }
77871
78368
 
77872
78369
  // src/features/background-agent/compaction-aware-message-resolver.ts
77873
- import { readdirSync as readdirSync22, readFileSync as readFileSync48 } from "fs";
78370
+ import { readdirSync as readdirSync22, readFileSync as readFileSync49 } from "fs";
77874
78371
  import { join as join82 } from "path";
77875
78372
  function isCompactionAgent3(agent) {
77876
78373
  return agent?.trim().toLowerCase() === "compaction";
@@ -77890,13 +78387,14 @@ function convertSessionMessageToStoredMessage(message) {
77890
78387
  }
77891
78388
  const providerID = info.model?.providerID ?? info.providerID;
77892
78389
  const modelID = info.model?.modelID ?? info.modelID;
78390
+ const variant = info.model?.variant ?? info.variant;
77893
78391
  return {
77894
78392
  ...info.agent ? { agent: info.agent } : {},
77895
78393
  ...providerID && modelID ? {
77896
78394
  model: {
77897
78395
  providerID,
77898
78396
  modelID,
77899
- ...info.model?.variant ? { variant: info.model.variant } : {}
78397
+ ...variant ? { variant } : {}
77900
78398
  }
77901
78399
  } : {},
77902
78400
  ...info.tools ? { tools: info.tools } : {}
@@ -77950,7 +78448,7 @@ function findNearestMessageExcludingCompaction(messageDir, sessionID) {
77950
78448
  const messages = [];
77951
78449
  for (const file3 of files) {
77952
78450
  try {
77953
- const content = readFileSync48(join82(messageDir, file3), "utf-8");
78451
+ const content = readFileSync49(join82(messageDir, file3), "utf-8");
77954
78452
  messages.push(JSON.parse(content));
77955
78453
  } catch {
77956
78454
  continue;
@@ -78514,8 +79012,12 @@ class BackgroundManager {
78514
79012
  path: { id: sessionID },
78515
79013
  body: {
78516
79014
  agent: input.agent,
78517
- ...launchModel ? { model: launchModel } : {},
78518
- ...launchVariant ? { variant: launchVariant } : {},
79015
+ ...launchModel || launchVariant ? {
79016
+ model: {
79017
+ ...launchModel ?? {},
79018
+ ...launchVariant ? { variant: launchVariant } : {}
79019
+ }
79020
+ } : {},
78519
79021
  system: input.skillContent,
78520
79022
  tools: (() => {
78521
79023
  const tools = {
@@ -78722,12 +79224,16 @@ class BackgroundManager {
78722
79224
  });
78723
79225
  const resumeModel = existingTask.model ? { providerID: existingTask.model.providerID, modelID: existingTask.model.modelID } : undefined;
78724
79226
  const resumeVariant = existingTask.model?.variant;
78725
- this.client.session.promptAsync({
79227
+ promptWithModelSuggestionRetry(this.client, {
78726
79228
  path: { id: existingTask.sessionID },
78727
79229
  body: {
78728
79230
  agent: existingTask.agent,
78729
- ...resumeModel ? { model: resumeModel } : {},
78730
- ...resumeVariant ? { variant: resumeVariant } : {},
79231
+ ...resumeModel || resumeVariant ? {
79232
+ model: {
79233
+ ...resumeModel ?? {},
79234
+ ...resumeVariant ? { variant: resumeVariant } : {}
79235
+ }
79236
+ } : {},
78731
79237
  tools: (() => {
78732
79238
  const tools = {
78733
79239
  task: false,
@@ -83405,7 +83911,7 @@ class StreamableHTTPClientTransport {
83405
83911
  }
83406
83912
 
83407
83913
  // src/features/mcp-oauth/storage.ts
83408
- import { chmodSync as chmodSync2, existsSync as existsSync73, mkdirSync as mkdirSync15, readFileSync as readFileSync49, unlinkSync as unlinkSync13, writeFileSync as writeFileSync21 } from "fs";
83914
+ import { chmodSync as chmodSync2, existsSync as existsSync74, mkdirSync as mkdirSync15, readFileSync as readFileSync50, unlinkSync as unlinkSync13, writeFileSync as writeFileSync21 } from "fs";
83409
83915
  import { dirname as dirname22, join as join84 } from "path";
83410
83916
  var STORAGE_FILE_NAME = "mcp-oauth.json";
83411
83917
  function getMcpOauthStoragePath() {
@@ -83446,11 +83952,11 @@ function buildKey(serverHost, resource) {
83446
83952
  }
83447
83953
  function readStore() {
83448
83954
  const filePath = getMcpOauthStoragePath();
83449
- if (!existsSync73(filePath)) {
83955
+ if (!existsSync74(filePath)) {
83450
83956
  return null;
83451
83957
  }
83452
83958
  try {
83453
- const content = readFileSync49(filePath, "utf-8");
83959
+ const content = readFileSync50(filePath, "utf-8");
83454
83960
  return JSON.parse(content);
83455
83961
  } catch {
83456
83962
  return null;
@@ -83460,7 +83966,7 @@ function writeStore(store2) {
83460
83966
  const filePath = getMcpOauthStoragePath();
83461
83967
  try {
83462
83968
  const dir = dirname22(filePath);
83463
- if (!existsSync73(dir)) {
83969
+ if (!existsSync74(dir)) {
83464
83970
  mkdirSync15(dir, { recursive: true });
83465
83971
  }
83466
83972
  writeFileSync21(filePath, JSON.stringify(store2, null, 2), { encoding: "utf-8", mode: 384 });
@@ -91370,7 +91876,7 @@ function createGptcoderAgent2(model, availableAgents, availableToolNames, availa
91370
91876
  }
91371
91877
  createGptcoderAgent2.mode = MODE10;
91372
91878
  // src/agents/builtin-agents/resolve-file-uri.ts
91373
- import { existsSync as existsSync74, readFileSync as readFileSync50 } from "fs";
91879
+ import { existsSync as existsSync75, readFileSync as readFileSync51 } from "fs";
91374
91880
  import { homedir as homedir14 } from "os";
91375
91881
  import { isAbsolute as isAbsolute10, resolve as resolve16 } from "path";
91376
91882
  function resolvePromptAppend(promptAppend, configDir) {
@@ -91385,11 +91891,11 @@ function resolvePromptAppend(promptAppend, configDir) {
91385
91891
  } catch {
91386
91892
  return `[WARNING: Malformed file URI (invalid percent-encoding): ${promptAppend}]`;
91387
91893
  }
91388
- if (!existsSync74(filePath)) {
91894
+ if (!existsSync75(filePath)) {
91389
91895
  return `[WARNING: Could not resolve file URI: ${promptAppend}]`;
91390
91896
  }
91391
91897
  try {
91392
- return readFileSync50(filePath, "utf8");
91898
+ return readFileSync51(filePath, "utf8");
91393
91899
  } catch {
91394
91900
  return `[WARNING: Could not read file: ${promptAppend}]`;
91395
91901
  }
@@ -93210,7 +93716,7 @@ async function createBuiltinAgents(disabledAgents = [], agentOverrides = {}, dir
93210
93716
  return result;
93211
93717
  }
93212
93718
  // src/features/claude-code-agent-loader/loader.ts
93213
- import { existsSync as existsSync75, readdirSync as readdirSync23, readFileSync as readFileSync51 } from "fs";
93719
+ import { existsSync as existsSync76, readdirSync as readdirSync23, readFileSync as readFileSync52 } from "fs";
93214
93720
  import { join as join85, basename as basename10 } from "path";
93215
93721
  function parseToolsConfig2(toolsStr) {
93216
93722
  if (!toolsStr)
@@ -93225,7 +93731,7 @@ function parseToolsConfig2(toolsStr) {
93225
93731
  return result;
93226
93732
  }
93227
93733
  function loadAgentsFromDir(agentsDir, scope) {
93228
- if (!existsSync75(agentsDir)) {
93734
+ if (!existsSync76(agentsDir)) {
93229
93735
  return [];
93230
93736
  }
93231
93737
  const entries = readdirSync23(agentsDir, { withFileTypes: true });
@@ -93236,7 +93742,7 @@ function loadAgentsFromDir(agentsDir, scope) {
93236
93742
  const agentPath = join85(agentsDir, entry.name);
93237
93743
  const agentName = basename10(entry.name, ".md");
93238
93744
  try {
93239
- const content = readFileSync51(agentPath, "utf-8");
93745
+ const content = readFileSync52(agentPath, "utf-8");
93240
93746
  const { data, body } = parseFrontmatter(content);
93241
93747
  const name = data.name || agentName;
93242
93748
  const originalDescription = data.description || "";
@@ -95872,7 +96378,7 @@ function remapCommandAgentFields(commands3) {
95872
96378
  }
95873
96379
  }
95874
96380
  // src/features/claude-code-mcp-loader/loader.ts
95875
- import { existsSync as existsSync76, readFileSync as readFileSync52 } from "fs";
96381
+ import { existsSync as existsSync77, readFileSync as readFileSync53 } from "fs";
95876
96382
  import { join as join87 } from "path";
95877
96383
  import { homedir as homedir15 } from "os";
95878
96384
  init_logger();
@@ -95887,7 +96393,7 @@ function getMcpConfigPaths() {
95887
96393
  ];
95888
96394
  }
95889
96395
  async function loadMcpConfigFile(filePath) {
95890
- if (!existsSync76(filePath)) {
96396
+ if (!existsSync77(filePath)) {
95891
96397
  return null;
95892
96398
  }
95893
96399
  try {
@@ -95902,10 +96408,10 @@ function getSystemMcpServerNames() {
95902
96408
  const names = new Set;
95903
96409
  const paths = getMcpConfigPaths();
95904
96410
  for (const { path: path12 } of paths) {
95905
- if (!existsSync76(path12))
96411
+ if (!existsSync77(path12))
95906
96412
  continue;
95907
96413
  try {
95908
- const content = readFileSync52(path12, "utf-8");
96414
+ const content = readFileSync53(path12, "utf-8");
95909
96415
  const config4 = JSON.parse(content);
95910
96416
  if (!config4?.mcpServers)
95911
96417
  continue;
@@ -96585,7 +97091,7 @@ function buildChatParamsInput(raw) {
96585
97091
  const providerID = model.providerID;
96586
97092
  const modelID = model.modelID;
96587
97093
  const providerId = provider.id;
96588
- const variant = message.variant;
97094
+ const variant = getUserMessageVariant(message);
96589
97095
  if (typeof providerID !== "string")
96590
97096
  return null;
96591
97097
  if (typeof modelID !== "string")
@@ -96597,7 +97103,7 @@ function buildChatParamsInput(raw) {
96597
97103
  agent: { name: agentName },
96598
97104
  model: { providerID, modelID },
96599
97105
  provider: { id: providerId },
96600
- message: typeof variant === "string" ? { variant } : {}
97106
+ message: typeof variant === "string" ? { model: { variant } } : {}
96601
97107
  };
96602
97108
  }
96603
97109
  function isChatParamsOutput(raw) {
@@ -96726,7 +97232,7 @@ function createChatHeadersHandler(args) {
96726
97232
  // src/plugin/ultrawork-db-model-override.ts
96727
97233
  import { Database } from "bun:sqlite";
96728
97234
  import { join as join88 } from "path";
96729
- import { existsSync as existsSync77 } from "fs";
97235
+ import { existsSync as existsSync78 } from "fs";
96730
97236
  function getDbPath() {
96731
97237
  return join88(getDataDir(), "opencode", "opencode.db");
96732
97238
  }
@@ -96737,7 +97243,7 @@ function tryUpdateMessageModel(db, messageId, targetModel, variant) {
96737
97243
  if (result.changes === 0)
96738
97244
  return false;
96739
97245
  if (variant) {
96740
- db.prepare(`UPDATE message SET data = json_set(data, '$.variant', ?, '$.thinking', ?) WHERE id = ?`).run(variant, variant, messageId);
97246
+ db.prepare(`UPDATE message SET data = json_remove(json_set(data, '$.model.variant', ?, '$.thinking', ?), '$.variant') WHERE id = ?`).run(variant, variant, messageId);
96741
97247
  }
96742
97248
  return true;
96743
97249
  }
@@ -96805,7 +97311,7 @@ function retryViaMicrotask(db, messageId, targetModel, variant, attempt) {
96805
97311
  function scheduleDeferredModelOverride(messageId, targetModel, variant) {
96806
97312
  queueMicrotask(() => {
96807
97313
  const dbPath = getDbPath();
96808
- if (!existsSync77(dbPath)) {
97314
+ if (!existsSync78(dbPath)) {
96809
97315
  log("[ultrawork-db-override] DB not found, skipping deferred override");
96810
97316
  return;
96811
97317
  }
@@ -96913,7 +97419,7 @@ function resolveUltraworkOverride(pluginConfig, inputAgentName, output, sessionI
96913
97419
  function applyResolvedUltraworkOverride(args) {
96914
97420
  const { override, validatedVariant, output, inputAgentName, tui } = args;
96915
97421
  if (validatedVariant) {
96916
- output.message["variant"] = validatedVariant;
97422
+ setUserMessageVariant(output.message, validatedVariant);
96917
97423
  output.message["thinking"] = validatedVariant;
96918
97424
  }
96919
97425
  if (!override.providerID || !override.modelID)
@@ -96926,7 +97432,7 @@ function applyResolvedUltraworkOverride(args) {
96926
97432
  const messageId = output.message["id"];
96927
97433
  if (!messageId) {
96928
97434
  log("[ultrawork-model-override] No message ID found, falling back to direct mutation");
96929
- output.message.model = targetModel;
97435
+ output.message.model = validatedVariant ? { ...targetModel, variant: validatedVariant } : targetModel;
96930
97436
  return;
96931
97437
  }
96932
97438
  const fromModel = output.message.model?.modelID ?? "unknown";