drizzy-agent 0.7.4 → 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;
@@ -16955,6 +16955,46 @@ function excludeFallbackEntries(chain, models) {
16955
16955
  const excludedModels = new Set(models);
16956
16956
  return chain.filter((entry) => !excludedModels.has(entry.model));
16957
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
+ }
16958
16998
  // src/shared/session-cursor.ts
16959
16999
  var sessionCursors = new Map;
16960
17000
  function buildMessageKey(message, index) {
@@ -17694,7 +17734,7 @@ function convertSDKMessageToStoredMessage(msg) {
17694
17734
  return null;
17695
17735
  const providerID = info.model?.providerID ?? info.providerID;
17696
17736
  const modelID = info.model?.modelID ?? info.modelID;
17697
- const variant = info.model?.variant;
17737
+ const variant = info.model?.variant ?? info.variant;
17698
17738
  if (!info.agent && !providerID && !modelID) {
17699
17739
  return null;
17700
17740
  }
@@ -18278,11 +18318,31 @@ function parseModelSuggestion(error) {
18278
18318
  }
18279
18319
  return null;
18280
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
+ }
18281
18340
  async function promptWithModelSuggestionRetry(client, args, options = {}) {
18341
+ const normalizedArgs = normalizePromptArgs(args);
18282
18342
  const timeoutMs = options.timeoutMs ?? PROMPT_TIMEOUT_MS;
18283
- const timeoutContext = createPromptTimeoutContext(args, timeoutMs);
18343
+ const timeoutContext = createPromptTimeoutContext(normalizedArgs, timeoutMs);
18284
18344
  const promptPromise = client.session.promptAsync({
18285
- ...args,
18345
+ ...normalizedArgs,
18286
18346
  signal: timeoutContext.signal
18287
18347
  });
18288
18348
  try {
@@ -18300,12 +18360,13 @@ async function promptWithModelSuggestionRetry(client, args, options = {}) {
18300
18360
  }
18301
18361
  }
18302
18362
  async function promptSyncWithModelSuggestionRetry(client, args, options = {}) {
18363
+ const normalizedArgs = normalizePromptArgs(args);
18303
18364
  const timeoutMs = options.timeoutMs ?? PROMPT_TIMEOUT_MS;
18304
18365
  try {
18305
- const timeoutContext = createPromptTimeoutContext(args, timeoutMs);
18366
+ const timeoutContext = createPromptTimeoutContext(normalizedArgs, timeoutMs);
18306
18367
  try {
18307
18368
  await client.session.prompt({
18308
- ...args,
18369
+ ...normalizedArgs,
18309
18370
  signal: timeoutContext.signal
18310
18371
  });
18311
18372
  if (timeoutContext.wasTimedOut()) {
@@ -18321,7 +18382,7 @@ async function promptSyncWithModelSuggestionRetry(client, args, options = {}) {
18321
18382
  }
18322
18383
  } catch (error) {
18323
18384
  const suggestion = parseModelSuggestion(error);
18324
- if (!suggestion || !args.body.model) {
18385
+ if (!suggestion || !normalizedArgs.body.model) {
18325
18386
  throw error;
18326
18387
  }
18327
18388
  log("[model-suggestion-retry] Model not found, retrying with suggestion", {
@@ -18329,12 +18390,13 @@ async function promptSyncWithModelSuggestionRetry(client, args, options = {}) {
18329
18390
  suggested: suggestion.suggestion
18330
18391
  });
18331
18392
  const retryArgs = {
18332
- ...args,
18393
+ ...normalizedArgs,
18333
18394
  body: {
18334
- ...args.body,
18395
+ ...normalizedArgs.body,
18335
18396
  model: {
18336
18397
  providerID: suggestion.providerID,
18337
- modelID: suggestion.suggestion
18398
+ modelID: suggestion.suggestion,
18399
+ ...normalizedArgs.body.model.variant ? { variant: normalizedArgs.body.model.variant } : {}
18338
18400
  }
18339
18401
  }
18340
18402
  };
@@ -35646,7 +35708,7 @@ async function processApplyPatchEditsWithCli(sessionID, edits, output, cliPath,
35646
35708
  hook_event_name: "PostToolUse",
35647
35709
  tool_input: {
35648
35710
  file_path: edit.filePath,
35649
- old_string: edit.before,
35711
+ ...edit.before !== undefined ? { old_string: edit.before } : {},
35650
35712
  new_string: edit.after
35651
35713
  }
35652
35714
  };
@@ -35664,6 +35726,871 @@ function isCliPathUsable(cliPath) {
35664
35726
  return Boolean(cliPath && existsSync27(cliPath));
35665
35727
  }
35666
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
+
35667
36594
  // src/hooks/comment-checker/pending-calls.ts
35668
36595
  var pendingCalls = new Map;
35669
36596
  var PENDING_CALL_TTL = 60000;
@@ -35763,10 +36690,11 @@ function createCommentCheckerHooks(config2) {
35763
36690
  }
35764
36691
  const ApplyPatchMetadataSchema = zod_default.object({
35765
36692
  files: zod_default.array(zod_default.object({
35766
- filePath: zod_default.string(),
36693
+ filePath: zod_default.string().optional(),
35767
36694
  movePath: zod_default.string().optional(),
35768
- before: zod_default.string(),
35769
- after: zod_default.string(),
36695
+ before: zod_default.string().optional(),
36696
+ after: zod_default.string().optional(),
36697
+ patch: zod_default.string().optional(),
35770
36698
  type: zod_default.string().optional()
35771
36699
  }))
35772
36700
  });
@@ -35776,11 +36704,7 @@ function createCommentCheckerHooks(config2) {
35776
36704
  debugLog3("apply_patch metadata schema mismatch, skipping");
35777
36705
  return;
35778
36706
  }
35779
- const edits = parsed.data.files.filter((f) => f.type !== "delete").map((f) => ({
35780
- filePath: f.movePath ?? f.filePath,
35781
- before: f.before,
35782
- after: f.after
35783
- }));
36707
+ const edits = resolveApplyPatchEdits(parsed.data.files, debugLog3);
35784
36708
  if (edits.length === 0) {
35785
36709
  debugLog3("apply_patch had no editable files, skipping");
35786
36710
  return;
@@ -35861,11 +36785,11 @@ function createToolOutputTruncatorHook(ctx, options) {
35861
36785
  };
35862
36786
  }
35863
36787
  // src/hooks/directory-agents-injector/injector.ts
35864
- import { readFileSync as readFileSync19 } from "fs";
36788
+ import { readFileSync as readFileSync20 } from "fs";
35865
36789
  import { dirname as dirname3 } from "path";
35866
36790
 
35867
36791
  // src/hooks/directory-agents-injector/finder.ts
35868
- import { existsSync as existsSync28 } from "fs";
36792
+ import { existsSync as existsSync29 } from "fs";
35869
36793
  import { dirname as dirname2, isAbsolute as isAbsolute2, join as join31, resolve as resolve2 } from "path";
35870
36794
 
35871
36795
  // src/hooks/directory-agents-injector/constants.ts
@@ -35888,7 +36812,7 @@ function findAgentsMdUp(input) {
35888
36812
  const isRootDir = current === input.rootDir;
35889
36813
  if (!isRootDir) {
35890
36814
  const agentsPath = join31(current, AGENTS_FILENAME);
35891
- if (existsSync28(agentsPath)) {
36815
+ if (existsSync29(agentsPath)) {
35892
36816
  found.push(agentsPath);
35893
36817
  }
35894
36818
  }
@@ -35906,9 +36830,9 @@ function findAgentsMdUp(input) {
35906
36830
 
35907
36831
  // src/shared/session-injected-paths.ts
35908
36832
  import {
35909
- existsSync as existsSync29,
36833
+ existsSync as existsSync30,
35910
36834
  mkdirSync as mkdirSync7,
35911
- readFileSync as readFileSync18,
36835
+ readFileSync as readFileSync19,
35912
36836
  unlinkSync as unlinkSync3,
35913
36837
  writeFileSync as writeFileSync8
35914
36838
  } from "fs";
@@ -35917,10 +36841,10 @@ function createInjectedPathsStorage(storageDir) {
35917
36841
  const getStoragePath = (sessionID) => join32(storageDir, `${sessionID}.json`);
35918
36842
  const loadInjectedPaths = (sessionID) => {
35919
36843
  const filePath = getStoragePath(sessionID);
35920
- if (!existsSync29(filePath))
36844
+ if (!existsSync30(filePath))
35921
36845
  return new Set;
35922
36846
  try {
35923
- const content = readFileSync18(filePath, "utf-8");
36847
+ const content = readFileSync19(filePath, "utf-8");
35924
36848
  const data = JSON.parse(content);
35925
36849
  return new Set(data.injectedPaths);
35926
36850
  } catch {
@@ -35928,7 +36852,7 @@ function createInjectedPathsStorage(storageDir) {
35928
36852
  }
35929
36853
  };
35930
36854
  const saveInjectedPaths = (sessionID, paths) => {
35931
- if (!existsSync29(storageDir)) {
36855
+ if (!existsSync30(storageDir)) {
35932
36856
  mkdirSync7(storageDir, { recursive: true });
35933
36857
  }
35934
36858
  const data = {
@@ -35940,7 +36864,7 @@ function createInjectedPathsStorage(storageDir) {
35940
36864
  };
35941
36865
  const clearInjectedPaths = (sessionID) => {
35942
36866
  const filePath = getStoragePath(sessionID);
35943
- if (existsSync29(filePath)) {
36867
+ if (existsSync30(filePath)) {
35944
36868
  unlinkSync3(filePath);
35945
36869
  }
35946
36870
  };
@@ -35978,7 +36902,7 @@ async function processFilePathForAgentsInjection(input) {
35978
36902
  if (cache.has(agentsDir))
35979
36903
  continue;
35980
36904
  try {
35981
- const content = readFileSync19(agentsPath, "utf-8");
36905
+ const content = readFileSync20(agentsPath, "utf-8");
35982
36906
  const { result, truncated } = await input.truncator.truncate(input.sessionID, content);
35983
36907
  const truncationNotice = truncated ? `
35984
36908
 
@@ -36039,11 +36963,11 @@ function createDirectoryAgentsInjectorHook(ctx, modelCacheState) {
36039
36963
  };
36040
36964
  }
36041
36965
  // src/hooks/directory-readme-injector/injector.ts
36042
- import { readFileSync as readFileSync20 } from "fs";
36966
+ import { readFileSync as readFileSync21 } from "fs";
36043
36967
  import { dirname as dirname5 } from "path";
36044
36968
 
36045
36969
  // src/hooks/directory-readme-injector/finder.ts
36046
- import { existsSync as existsSync30 } from "fs";
36970
+ import { existsSync as existsSync31 } from "fs";
36047
36971
  import { dirname as dirname4, isAbsolute as isAbsolute3, join as join34, resolve as resolve3 } from "path";
36048
36972
 
36049
36973
  // src/hooks/directory-readme-injector/constants.ts
@@ -36064,7 +36988,7 @@ function findReadmeMdUp(input) {
36064
36988
  let current = input.startDir;
36065
36989
  while (true) {
36066
36990
  const readmePath = join34(current, README_FILENAME);
36067
- if (existsSync30(readmePath)) {
36991
+ if (existsSync31(readmePath)) {
36068
36992
  found.push(readmePath);
36069
36993
  }
36070
36994
  if (current === input.rootDir)
@@ -36106,7 +37030,7 @@ async function processFilePathForReadmeInjection(input) {
36106
37030
  if (cache.has(readmeDir))
36107
37031
  continue;
36108
37032
  try {
36109
- const content = readFileSync20(readmePath, "utf-8");
37033
+ const content = readFileSync21(readmePath, "utf-8");
36110
37034
  const { result, truncated } = await input.truncator.truncate(input.sessionID, content);
36111
37035
  const truncationNotice = truncated ? `
36112
37036
 
@@ -36421,14 +37345,14 @@ function incrementEmptyContentAttempt(autoCompactState, sessionID) {
36421
37345
  }
36422
37346
 
36423
37347
  // src/hooks/anthropic-context-window-limit-recovery/tool-result-storage.ts
36424
- 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";
36425
37349
  import { join as join35 } from "path";
36426
37350
 
36427
37351
  // src/hooks/anthropic-context-window-limit-recovery/message-storage-directory.ts
36428
- import { existsSync as existsSync31, readdirSync as readdirSync10 } from "fs";
37352
+ import { existsSync as existsSync32, readdirSync as readdirSync10 } from "fs";
36429
37353
  function getMessageIds(sessionID) {
36430
37354
  const messageDir = getMessageDir(sessionID);
36431
- if (!messageDir || !existsSync31(messageDir))
37355
+ if (!messageDir || !existsSync32(messageDir))
36432
37356
  return [];
36433
37357
  const messageIds = [];
36434
37358
  for (const file2 of readdirSync10(messageDir)) {
@@ -36451,14 +37375,14 @@ function findToolResultsBySize(sessionID) {
36451
37375
  const results = [];
36452
37376
  for (const messageID of messageIds) {
36453
37377
  const partDir = join35(PART_STORAGE, messageID);
36454
- if (!existsSync32(partDir))
37378
+ if (!existsSync33(partDir))
36455
37379
  continue;
36456
37380
  for (const file2 of readdirSync11(partDir)) {
36457
37381
  if (!file2.endsWith(".json"))
36458
37382
  continue;
36459
37383
  try {
36460
37384
  const partPath = join35(partDir, file2);
36461
- const content = readFileSync21(partPath, "utf-8");
37385
+ const content = readFileSync22(partPath, "utf-8");
36462
37386
  const part = JSON.parse(content);
36463
37387
  if (part.type === "tool" && part.state?.output && !part.truncated) {
36464
37388
  results.push({
@@ -36485,7 +37409,7 @@ function truncateToolResult(partPath) {
36485
37409
  return { success: false };
36486
37410
  }
36487
37411
  try {
36488
- const content = readFileSync21(partPath, "utf-8");
37412
+ const content = readFileSync22(partPath, "utf-8");
36489
37413
  const part = JSON.parse(content);
36490
37414
  if (!part.state?.output) {
36491
37415
  return { success: false };
@@ -37252,7 +38176,7 @@ async function executeCompact(sessionID, msg, autoCompactState, client, director
37252
38176
  }
37253
38177
 
37254
38178
  // src/hooks/anthropic-context-window-limit-recovery/pruning-deduplication.ts
37255
- import { readdirSync as readdirSync12, readFileSync as readFileSync22 } from "fs";
38179
+ import { readdirSync as readdirSync12, readFileSync as readFileSync23 } from "fs";
37256
38180
  import { join as join36 } from "path";
37257
38181
 
37258
38182
  // src/hooks/anthropic-context-window-limit-recovery/pruning-types.ts
@@ -37289,7 +38213,7 @@ function readMessages2(sessionID) {
37289
38213
  try {
37290
38214
  const files = readdirSync12(messageDir).filter((f) => f.endsWith(".json"));
37291
38215
  for (const file2 of files) {
37292
- const content = readFileSync22(join36(messageDir, file2), "utf-8");
38216
+ const content = readFileSync23(join36(messageDir, file2), "utf-8");
37293
38217
  const data = JSON.parse(content);
37294
38218
  if (data.parts) {
37295
38219
  messages.push(data);
@@ -37394,7 +38318,7 @@ function findToolOutput(messages, callID) {
37394
38318
  }
37395
38319
 
37396
38320
  // src/hooks/anthropic-context-window-limit-recovery/pruning-tool-output-truncation.ts
37397
- 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";
37398
38322
  import { join as join37 } from "path";
37399
38323
  init_logger();
37400
38324
  function getPartStorage() {
@@ -37424,14 +38348,14 @@ async function truncateToolOutputsByCallId(sessionID, callIds, client) {
37424
38348
  let truncatedCount = 0;
37425
38349
  for (const messageID of messageIds) {
37426
38350
  const partDir = join37(getPartStorage(), messageID);
37427
- if (!existsSync33(partDir))
38351
+ if (!existsSync34(partDir))
37428
38352
  continue;
37429
38353
  for (const file2 of readdirSync13(partDir)) {
37430
38354
  if (!file2.endsWith(".json"))
37431
38355
  continue;
37432
38356
  const partPath = join37(partDir, file2);
37433
38357
  try {
37434
- const content = readFileSync23(partPath, "utf-8");
38358
+ const content = readFileSync24(partPath, "utf-8");
37435
38359
  const part = JSON.parse(content);
37436
38360
  if (part.type !== "tool" || !part.callID)
37437
38361
  continue;
@@ -37814,7 +38738,7 @@ function createThinkModeHook() {
37814
38738
  return;
37815
38739
  }
37816
38740
  state3.requested = true;
37817
- if (typeof output.message.variant === "string") {
38741
+ if (getUserMessageVariant(output.message) !== undefined) {
37818
38742
  thinkModeState.set(sessionID, state3);
37819
38743
  return;
37820
38744
  }
@@ -37829,7 +38753,7 @@ function createThinkModeHook() {
37829
38753
  thinkModeState.set(sessionID, state3);
37830
38754
  return;
37831
38755
  }
37832
- output.message.variant = "high";
38756
+ setUserMessageVariant(output.message, "high");
37833
38757
  state3.modelSwitched = false;
37834
38758
  state3.variantSet = true;
37835
38759
  log("Think mode: variant set to high", { sessionID });
@@ -38242,9 +39166,9 @@ function createModelFallbackHook(args) {
38242
39166
  modelID: fallback.modelID
38243
39167
  };
38244
39168
  if (fallback.variant !== undefined) {
38245
- output.message["variant"] = fallback.variant;
39169
+ setUserMessageVariant(output.message, fallback.variant);
38246
39170
  } else {
38247
- delete output.message["variant"];
39171
+ clearUserMessageVariant(output.message);
38248
39172
  }
38249
39173
  if (toast) {
38250
39174
  const key = `${sessionID}:${fallback.providerID}/${fallback.modelID}:${fallback.variant ?? ""}`;
@@ -38281,7 +39205,7 @@ function createModelFallbackHook(args) {
38281
39205
  }
38282
39206
  // src/hooks/claude-code-hooks/config.ts
38283
39207
  import { join as join38 } from "path";
38284
- import { existsSync as existsSync34 } from "fs";
39208
+ import { existsSync as existsSync35 } from "fs";
38285
39209
  function normalizeHookMatcher(raw) {
38286
39210
  return {
38287
39211
  matcher: raw.matcher ?? raw.pattern ?? "*",
@@ -38311,7 +39235,7 @@ function getClaudeSettingsPaths(customPath) {
38311
39235
  join38(process.cwd(), ".claude", "settings.json"),
38312
39236
  join38(process.cwd(), ".claude", "settings.local.json")
38313
39237
  ];
38314
- if (customPath && existsSync34(customPath)) {
39238
+ if (customPath && existsSync35(customPath)) {
38315
39239
  paths.unshift(customPath);
38316
39240
  }
38317
39241
  return [...new Set(paths)];
@@ -38336,7 +39260,7 @@ async function loadClaudeHooksConfig(customSettingsPath) {
38336
39260
  const paths = getClaudeSettingsPaths(customSettingsPath);
38337
39261
  let mergedConfig = {};
38338
39262
  for (const settingsPath of paths) {
38339
- if (existsSync34(settingsPath)) {
39263
+ if (existsSync35(settingsPath)) {
38340
39264
  try {
38341
39265
  const content = await Bun.file(settingsPath).text();
38342
39266
  const settings = JSON.parse(content);
@@ -38354,14 +39278,14 @@ async function loadClaudeHooksConfig(customSettingsPath) {
38354
39278
 
38355
39279
  // src/hooks/claude-code-hooks/config-loader.ts
38356
39280
  init_logger();
38357
- import { existsSync as existsSync35 } from "fs";
39281
+ import { existsSync as existsSync36 } from "fs";
38358
39282
  import { join as join39 } from "path";
38359
39283
  var USER_CONFIG_PATH = join39(getOpenCodeConfigDir({ binary: "opencode" }), "opencode-cc-plugin.json");
38360
39284
  function getProjectConfigPath() {
38361
39285
  return join39(process.cwd(), ".opencode", "opencode-cc-plugin.json");
38362
39286
  }
38363
39287
  async function loadConfigFromPath(path5) {
38364
- if (!existsSync35(path5)) {
39288
+ if (!existsSync36(path5)) {
38365
39289
  return null;
38366
39290
  }
38367
39291
  try {
@@ -38588,7 +39512,7 @@ ${USER_PROMPT_SUBMIT_TAG_CLOSE}`);
38588
39512
 
38589
39513
  // src/hooks/claude-code-hooks/transcript.ts
38590
39514
  import { join as join40 } from "path";
38591
- 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";
38592
39516
  import { tmpdir as tmpdir5 } from "os";
38593
39517
  import { randomUUID } from "crypto";
38594
39518
  var TRANSCRIPT_DIR = join40(getClaudeConfigDir(), "transcripts");
@@ -38596,7 +39520,7 @@ function getTranscriptPath(sessionId) {
38596
39520
  return join40(TRANSCRIPT_DIR, `${sessionId}.jsonl`);
38597
39521
  }
38598
39522
  function ensureTranscriptDir() {
38599
- if (!existsSync36(TRANSCRIPT_DIR)) {
39523
+ if (!existsSync37(TRANSCRIPT_DIR)) {
38600
39524
  mkdirSync8(TRANSCRIPT_DIR, { recursive: true });
38601
39525
  }
38602
39526
  }
@@ -39531,9 +40455,9 @@ function getRuleInjectionFilePath(output) {
39531
40455
 
39532
40456
  // src/hooks/rules-injector/storage.ts
39533
40457
  import {
39534
- existsSync as existsSync37,
40458
+ existsSync as existsSync38,
39535
40459
  mkdirSync as mkdirSync9,
39536
- readFileSync as readFileSync24,
40460
+ readFileSync as readFileSync25,
39537
40461
  writeFileSync as writeFileSync11,
39538
40462
  unlinkSync as unlinkSync5
39539
40463
  } from "fs";
@@ -39569,10 +40493,10 @@ function getStoragePath(sessionID) {
39569
40493
  }
39570
40494
  function loadInjectedRules(sessionID) {
39571
40495
  const filePath = getStoragePath(sessionID);
39572
- if (!existsSync37(filePath))
40496
+ if (!existsSync38(filePath))
39573
40497
  return { contentHashes: new Set, realPaths: new Set };
39574
40498
  try {
39575
- const content = readFileSync24(filePath, "utf-8");
40499
+ const content = readFileSync25(filePath, "utf-8");
39576
40500
  const data = JSON.parse(content);
39577
40501
  return {
39578
40502
  contentHashes: new Set(data.injectedHashes),
@@ -39583,7 +40507,7 @@ function loadInjectedRules(sessionID) {
39583
40507
  }
39584
40508
  }
39585
40509
  function saveInjectedRules(sessionID, data) {
39586
- if (!existsSync37(RULES_INJECTOR_STORAGE)) {
40510
+ if (!existsSync38(RULES_INJECTOR_STORAGE)) {
39587
40511
  mkdirSync9(RULES_INJECTOR_STORAGE, { recursive: true });
39588
40512
  }
39589
40513
  const storageData = {
@@ -39596,7 +40520,7 @@ function saveInjectedRules(sessionID, data) {
39596
40520
  }
39597
40521
  function clearInjectedRules(sessionID) {
39598
40522
  const filePath = getStoragePath(sessionID);
39599
- if (existsSync37(filePath)) {
40523
+ if (existsSync38(filePath)) {
39600
40524
  unlinkSync5(filePath);
39601
40525
  }
39602
40526
  }
@@ -39618,12 +40542,12 @@ function createSessionCacheStore() {
39618
40542
  }
39619
40543
 
39620
40544
  // src/hooks/rules-injector/injector.ts
39621
- import { readFileSync as readFileSync25, statSync as statSync4 } from "fs";
40545
+ import { readFileSync as readFileSync26, statSync as statSync4 } from "fs";
39622
40546
  import { homedir as homedir8 } from "os";
39623
40547
  import { relative as relative2, resolve as resolve4 } from "path";
39624
40548
 
39625
40549
  // src/hooks/rules-injector/project-root-finder.ts
39626
- import { existsSync as existsSync38, statSync as statSync2 } from "fs";
40550
+ import { existsSync as existsSync39, statSync as statSync2 } from "fs";
39627
40551
  import { dirname as dirname6, join as join44 } from "path";
39628
40552
  function findProjectRoot(startPath) {
39629
40553
  let current;
@@ -39636,7 +40560,7 @@ function findProjectRoot(startPath) {
39636
40560
  while (true) {
39637
40561
  for (const marker of PROJECT_MARKERS) {
39638
40562
  const markerPath = join44(current, marker);
39639
- if (existsSync38(markerPath)) {
40563
+ if (existsSync39(markerPath)) {
39640
40564
  return current;
39641
40565
  }
39642
40566
  }
@@ -39648,11 +40572,11 @@ function findProjectRoot(startPath) {
39648
40572
  }
39649
40573
  }
39650
40574
  // src/hooks/rules-injector/rule-file-finder.ts
39651
- import { existsSync as existsSync40, statSync as statSync3 } from "fs";
40575
+ import { existsSync as existsSync41, statSync as statSync3 } from "fs";
39652
40576
  import { dirname as dirname7, join as join46 } from "path";
39653
40577
 
39654
40578
  // src/hooks/rules-injector/rule-file-scanner.ts
39655
- 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";
39656
40580
  import { join as join45 } from "path";
39657
40581
  function isGitHubInstructionsDir(dir) {
39658
40582
  return dir.includes(".github/instructions") || dir.endsWith(".github/instructions");
@@ -39664,7 +40588,7 @@ function isValidRuleFile(fileName, dir) {
39664
40588
  return RULE_EXTENSIONS.some((ext) => fileName.endsWith(ext));
39665
40589
  }
39666
40590
  function findRuleFilesRecursive(dir, results) {
39667
- if (!existsSync39(dir))
40591
+ if (!existsSync40(dir))
39668
40592
  return;
39669
40593
  try {
39670
40594
  const entries = readdirSync14(dir, { withFileTypes: true });
@@ -39723,7 +40647,7 @@ function findRuleFiles(projectRoot, homeDir, currentFile) {
39723
40647
  if (projectRoot) {
39724
40648
  for (const ruleFile of PROJECT_RULE_FILES) {
39725
40649
  const filePath = join46(projectRoot, ruleFile);
39726
- if (existsSync40(filePath)) {
40650
+ if (existsSync41(filePath)) {
39727
40651
  try {
39728
40652
  const stat = statSync3(filePath);
39729
40653
  if (stat.isFile()) {
@@ -39938,7 +40862,7 @@ function getCachedParsedRule(filePath, realPath) {
39938
40862
  if (cached2 && cached2.mtimeMs === stat.mtimeMs && cached2.size === stat.size) {
39939
40863
  return { metadata: cached2.metadata, body: cached2.body };
39940
40864
  }
39941
- const rawContent = readFileSync25(filePath, "utf-8");
40865
+ const rawContent = readFileSync26(filePath, "utf-8");
39942
40866
  const { metadata, body } = parseRuleFrontmatter(rawContent);
39943
40867
  parsedRuleCache.set(realPath, {
39944
40868
  mtimeMs: stat.mtimeMs,
@@ -39948,7 +40872,7 @@ function getCachedParsedRule(filePath, realPath) {
39948
40872
  });
39949
40873
  return { metadata, body };
39950
40874
  } catch {
39951
- const rawContent = readFileSync25(filePath, "utf-8");
40875
+ const rawContent = readFileSync26(filePath, "utf-8");
39952
40876
  return parseRuleFrontmatter(rawContent);
39953
40877
  }
39954
40878
  }
@@ -40446,7 +41370,7 @@ function spawnWithWindowsHide(command, options) {
40446
41370
  return wrapNodeProcess(proc);
40447
41371
  }
40448
41372
  // src/cli/config-manager/bun-install.ts
40449
- import { existsSync as existsSync46 } from "fs";
41373
+ import { existsSync as existsSync47 } from "fs";
40450
41374
  init_logger();
40451
41375
  var BUN_INSTALL_TIMEOUT_SECONDS = 60;
40452
41376
  var BUN_INSTALL_TIMEOUT_MS = BUN_INSTALL_TIMEOUT_SECONDS * 1000;
@@ -40474,7 +41398,7 @@ async function runBunInstallWithDetails(options) {
40474
41398
  const outputMode = options?.outputMode ?? "inherit";
40475
41399
  const cacheDir = getOpenCodeCacheDir();
40476
41400
  const packageJsonPath = `${cacheDir}/package.json`;
40477
- if (!existsSync46(packageJsonPath)) {
41401
+ if (!existsSync47(packageJsonPath)) {
40478
41402
  return {
40479
41403
  success: false,
40480
41404
  error: `Workspace not initialized: ${packageJsonPath} not found. OpenCode should create this on first run.`
@@ -40863,9 +41787,9 @@ v${latestVersion} available. Restart OpenCode to apply.` : "DrizzyAgent is activ
40863
41787
  }
40864
41788
  // src/hooks/agent-usage-reminder/storage.ts
40865
41789
  import {
40866
- existsSync as existsSync48,
41790
+ existsSync as existsSync49,
40867
41791
  mkdirSync as mkdirSync10,
40868
- readFileSync as readFileSync33,
41792
+ readFileSync as readFileSync34,
40869
41793
  writeFileSync as writeFileSync14,
40870
41794
  unlinkSync as unlinkSync8
40871
41795
  } from "fs";
@@ -40923,17 +41847,17 @@ function getStoragePath2(sessionID) {
40923
41847
  }
40924
41848
  function loadAgentUsageState(sessionID) {
40925
41849
  const filePath = getStoragePath2(sessionID);
40926
- if (!existsSync48(filePath))
41850
+ if (!existsSync49(filePath))
40927
41851
  return null;
40928
41852
  try {
40929
- const content = readFileSync33(filePath, "utf-8");
41853
+ const content = readFileSync34(filePath, "utf-8");
40930
41854
  return JSON.parse(content);
40931
41855
  } catch {
40932
41856
  return null;
40933
41857
  }
40934
41858
  }
40935
41859
  function saveAgentUsageState(state3) {
40936
- if (!existsSync48(AGENT_USAGE_REMINDER_STORAGE)) {
41860
+ if (!existsSync49(AGENT_USAGE_REMINDER_STORAGE)) {
40937
41861
  mkdirSync10(AGENT_USAGE_REMINDER_STORAGE, { recursive: true });
40938
41862
  }
40939
41863
  const filePath = getStoragePath2(state3.sessionID);
@@ -40941,7 +41865,7 @@ function saveAgentUsageState(state3) {
40941
41865
  }
40942
41866
  function clearAgentUsageState(sessionID) {
40943
41867
  const filePath = getStoragePath2(sessionID);
40944
- if (existsSync48(filePath)) {
41868
+ if (existsSync49(filePath)) {
40945
41869
  unlinkSync8(filePath);
40946
41870
  }
40947
41871
  }
@@ -42034,10 +42958,7 @@ function extractPromptText2(parts) {
42034
42958
  // src/hooks/keyword-detector/hook.ts
42035
42959
  function createKeywordDetectorHook(ctx, _collector) {
42036
42960
  function getRuntimeVariant(input, message) {
42037
- if (typeof message["variant"] === "string") {
42038
- return message["variant"];
42039
- }
42040
- return typeof input.variant === "string" ? input.variant : undefined;
42961
+ return getUserMessageVariant(message) ?? getInputVariant(input);
42041
42962
  }
42042
42963
  return {
42043
42964
  "chat.message": async (input, output) => {
@@ -42217,9 +43138,9 @@ function createNonInteractiveEnvHook(_ctx) {
42217
43138
  }
42218
43139
  // src/hooks/interactive-bash-session/storage.ts
42219
43140
  import {
42220
- existsSync as existsSync49,
43141
+ existsSync as existsSync50,
42221
43142
  mkdirSync as mkdirSync11,
42222
- readFileSync as readFileSync34,
43143
+ readFileSync as readFileSync35,
42223
43144
  writeFileSync as writeFileSync15,
42224
43145
  unlinkSync as unlinkSync9
42225
43146
  } from "fs";
@@ -42243,10 +43164,10 @@ function getStoragePath3(sessionID) {
42243
43164
  }
42244
43165
  function loadInteractiveBashSessionState(sessionID) {
42245
43166
  const filePath = getStoragePath3(sessionID);
42246
- if (!existsSync49(filePath))
43167
+ if (!existsSync50(filePath))
42247
43168
  return null;
42248
43169
  try {
42249
- const content = readFileSync34(filePath, "utf-8");
43170
+ const content = readFileSync35(filePath, "utf-8");
42250
43171
  const serialized = JSON.parse(content);
42251
43172
  return {
42252
43173
  sessionID: serialized.sessionID,
@@ -42258,7 +43179,7 @@ function loadInteractiveBashSessionState(sessionID) {
42258
43179
  }
42259
43180
  }
42260
43181
  function saveInteractiveBashSessionState(state3) {
42261
- if (!existsSync49(INTERACTIVE_BASH_SESSION_STORAGE)) {
43182
+ if (!existsSync50(INTERACTIVE_BASH_SESSION_STORAGE)) {
42262
43183
  mkdirSync11(INTERACTIVE_BASH_SESSION_STORAGE, { recursive: true });
42263
43184
  }
42264
43185
  const filePath = getStoragePath3(state3.sessionID);
@@ -42271,7 +43192,7 @@ function saveInteractiveBashSessionState(state3) {
42271
43192
  }
42272
43193
  function clearInteractiveBashSessionState(sessionID) {
42273
43194
  const filePath = getStoragePath3(sessionID);
42274
- if (existsSync49(filePath)) {
43195
+ if (existsSync50(filePath)) {
42275
43196
  unlinkSync9(filePath);
42276
43197
  }
42277
43198
  }
@@ -42668,18 +43589,18 @@ var DEFAULT_MAX_ITERATIONS = 100;
42668
43589
  var DEFAULT_COMPLETION_PROMISE = "DONE";
42669
43590
  var ULTRAWORK_VERIFICATION_PROMISE = "VERIFIED";
42670
43591
  // src/hooks/ralph-loop/storage.ts
42671
- 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";
42672
43593
  import { dirname as dirname10, join as join56 } from "path";
42673
43594
  function getStateFilePath(directory, customPath) {
42674
43595
  return customPath ? join56(directory, customPath) : join56(directory, DEFAULT_STATE_FILE);
42675
43596
  }
42676
43597
  function readState(directory, customPath) {
42677
43598
  const filePath = getStateFilePath(directory, customPath);
42678
- if (!existsSync50(filePath)) {
43599
+ if (!existsSync51(filePath)) {
42679
43600
  return null;
42680
43601
  }
42681
43602
  try {
42682
- const content = readFileSync35(filePath, "utf-8");
43603
+ const content = readFileSync36(filePath, "utf-8");
42683
43604
  const { data, body } = parseFrontmatter(content);
42684
43605
  const active = data.active;
42685
43606
  const iteration = data.iteration;
@@ -42721,7 +43642,7 @@ function writeState(directory, state3, customPath) {
42721
43642
  const filePath = getStateFilePath(directory, customPath);
42722
43643
  try {
42723
43644
  const dir = dirname10(filePath);
42724
- if (!existsSync50(dir)) {
43645
+ if (!existsSync51(dir)) {
42725
43646
  mkdirSync12(dir, { recursive: true });
42726
43647
  }
42727
43648
  const sessionIdLine = state3.session_id ? `session_id: "${state3.session_id}"
@@ -42759,7 +43680,7 @@ ${state3.prompt}
42759
43680
  function clearState(directory, customPath) {
42760
43681
  const filePath = getStateFilePath(directory, customPath);
42761
43682
  try {
42762
- if (existsSync50(filePath)) {
43683
+ if (existsSync51(filePath)) {
42763
43684
  unlinkSync10(filePath);
42764
43685
  }
42765
43686
  return true;
@@ -43088,7 +44009,7 @@ async function handleDetectedCompletion(ctx, input) {
43088
44009
 
43089
44010
  // src/hooks/ralph-loop/completion-promise-detector.ts
43090
44011
  init_logger();
43091
- import { existsSync as existsSync51, readFileSync as readFileSync36 } from "fs";
44012
+ import { existsSync as existsSync52, readFileSync as readFileSync37 } from "fs";
43092
44013
  function escapeRegex2(str2) {
43093
44014
  return str2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
43094
44015
  }
@@ -43099,9 +44020,9 @@ function detectCompletionInTranscript(transcriptPath, promise2, startedAt) {
43099
44020
  if (!transcriptPath)
43100
44021
  return false;
43101
44022
  try {
43102
- if (!existsSync51(transcriptPath))
44023
+ if (!existsSync52(transcriptPath))
43103
44024
  return false;
43104
- const content = readFileSync36(transcriptPath, "utf-8");
44025
+ const content = readFileSync37(transcriptPath, "utf-8");
43105
44026
  const pattern = buildPromisePattern(promise2);
43106
44027
  const lines = content.split(`
43107
44028
  `).filter((line) => line.trim());
@@ -43890,7 +44811,7 @@ function findSlashCommandPartIndex(parts) {
43890
44811
  return -1;
43891
44812
  }
43892
44813
  // src/hooks/auto-slash-command/executor.ts
43893
- 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";
43894
44815
  import { join as join61, basename as basename4, dirname as dirname13 } from "path";
43895
44816
  // src/features/builtin-commands/templates/init-deep.ts
43896
44817
  var INIT_DEEP_TEMPLATE = `# /init-deep
@@ -45603,7 +46524,7 @@ function builtinToLoadedSkill(builtin) {
45603
46524
  }
45604
46525
 
45605
46526
  // src/features/opencode-skill-loader/merger/config-skill-entry-loader.ts
45606
- import { existsSync as existsSync52, readFileSync as readFileSync37 } from "fs";
46527
+ import { existsSync as existsSync53, readFileSync as readFileSync38 } from "fs";
45607
46528
  import { dirname as dirname11, isAbsolute as isAbsolute4, resolve as resolve5 } from "path";
45608
46529
  import { homedir as homedir12 } from "os";
45609
46530
  function resolveFilePath5(from, configDir) {
@@ -45622,9 +46543,9 @@ function resolveFilePath5(from, configDir) {
45622
46543
  }
45623
46544
  function loadSkillFromFile(filePath) {
45624
46545
  try {
45625
- if (!existsSync52(filePath))
46546
+ if (!existsSync53(filePath))
45626
46547
  return null;
45627
- const content = readFileSync37(filePath, "utf-8");
46548
+ const content = readFileSync38(filePath, "utf-8");
45628
46549
  const { data, body } = parseFrontmatter(content);
45629
46550
  return { template: body, metadata: data };
45630
46551
  } catch {
@@ -47994,10 +48915,10 @@ async function getAllSkills(options) {
47994
48915
  return allSkills;
47995
48916
  }
47996
48917
  // src/features/opencode-skill-loader/loaded-skill-template-extractor.ts
47997
- import { readFileSync as readFileSync38 } from "fs";
48918
+ import { readFileSync as readFileSync39 } from "fs";
47998
48919
  function extractSkillTemplate(skill) {
47999
48920
  if (skill.path) {
48000
- const content = readFileSync38(skill.path, "utf-8");
48921
+ const content = readFileSync39(skill.path, "utf-8");
48001
48922
  const { body } = parseFrontmatter(content);
48002
48923
  return body.trim();
48003
48924
  }
@@ -48705,7 +49626,7 @@ async function discoverConfigSourceSkills(options) {
48705
49626
  }
48706
49627
  // src/hooks/auto-slash-command/executor.ts
48707
49628
  function discoverCommandsFromDir(commandsDir, scope) {
48708
- if (!existsSync53(commandsDir)) {
49629
+ if (!existsSync54(commandsDir)) {
48709
49630
  return [];
48710
49631
  }
48711
49632
  const entries = readdirSync15(commandsDir, { withFileTypes: true });
@@ -48716,7 +49637,7 @@ function discoverCommandsFromDir(commandsDir, scope) {
48716
49637
  const commandPath = join61(commandsDir, entry.name);
48717
49638
  const commandName = basename4(entry.name, ".md");
48718
49639
  try {
48719
- const content = readFileSync39(commandPath, "utf-8");
49640
+ const content = readFileSync40(commandPath, "utf-8");
48720
49641
  const { data, body } = parseFrontmatter(content);
48721
49642
  const isOpencodeSource = scope === "opencode" || scope === "opencode-project";
48722
49643
  const metadata = {
@@ -49153,18 +50074,18 @@ var NOTEPAD_DIR = "notepads";
49153
50074
  var NOTEPAD_BASE_PATH = `${BOULDER_DIR}/${NOTEPAD_DIR}`;
49154
50075
  var PLANNER_PLANS_DIR = ".drizzy/plans";
49155
50076
  // src/features/boulder-state/storage.ts
49156
- 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";
49157
50078
  import { dirname as dirname14, join as join62, basename as basename5 } from "path";
49158
50079
  function getBoulderFilePath(directory) {
49159
50080
  return join62(directory, BOULDER_DIR, BOULDER_FILE);
49160
50081
  }
49161
50082
  function readBoulderState(directory) {
49162
50083
  const filePath = getBoulderFilePath(directory);
49163
- if (!existsSync54(filePath)) {
50084
+ if (!existsSync55(filePath)) {
49164
50085
  return null;
49165
50086
  }
49166
50087
  try {
49167
- const content = readFileSync40(filePath, "utf-8");
50088
+ const content = readFileSync41(filePath, "utf-8");
49168
50089
  const parsed = JSON.parse(content);
49169
50090
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
49170
50091
  return null;
@@ -49181,7 +50102,7 @@ function writeBoulderState(directory, state3) {
49181
50102
  const filePath = getBoulderFilePath(directory);
49182
50103
  try {
49183
50104
  const dir = dirname14(filePath);
49184
- if (!existsSync54(dir)) {
50105
+ if (!existsSync55(dir)) {
49185
50106
  mkdirSync13(dir, { recursive: true });
49186
50107
  }
49187
50108
  writeFileSync17(filePath, JSON.stringify(state3, null, 2), "utf-8");
@@ -49208,7 +50129,7 @@ function appendSessionId(directory, sessionId) {
49208
50129
  function clearBoulderState(directory) {
49209
50130
  const filePath = getBoulderFilePath(directory);
49210
50131
  try {
49211
- if (existsSync54(filePath)) {
50132
+ if (existsSync55(filePath)) {
49212
50133
  const { unlinkSync: unlinkSync11 } = __require("fs");
49213
50134
  unlinkSync11(filePath);
49214
50135
  }
@@ -49219,7 +50140,7 @@ function clearBoulderState(directory) {
49219
50140
  }
49220
50141
  function findPlannerPlans(directory) {
49221
50142
  const plansDir = join62(directory, PLANNER_PLANS_DIR);
49222
- if (!existsSync54(plansDir)) {
50143
+ if (!existsSync55(plansDir)) {
49223
50144
  return [];
49224
50145
  }
49225
50146
  try {
@@ -49234,11 +50155,11 @@ function findPlannerPlans(directory) {
49234
50155
  }
49235
50156
  }
49236
50157
  function getPlanProgress(planPath) {
49237
- if (!existsSync54(planPath)) {
50158
+ if (!existsSync55(planPath)) {
49238
50159
  return { total: 0, completed: 0, isComplete: true };
49239
50160
  }
49240
50161
  try {
49241
- const content = readFileSync40(planPath, "utf-8");
50162
+ const content = readFileSync41(planPath, "utf-8");
49242
50163
  const uncheckedMatches = content.match(/^\s*[-*]\s*\[\s*\]/gm) || [];
49243
50164
  const checkedMatches = content.match(/^\s*[-*]\s*\[[xX]\]/gm) || [];
49244
50165
  const total = uncheckedMatches.length + checkedMatches.length;
@@ -53179,7 +54100,7 @@ function createRuntimeFallbackHook(ctx, options) {
53179
54100
  };
53180
54101
  }
53181
54102
  // src/hooks/write-existing-file-guard/hook.ts
53182
- import { existsSync as existsSync56, realpathSync as realpathSync4 } from "fs";
54103
+ import { existsSync as existsSync57, realpathSync as realpathSync4 } from "fs";
53183
54104
  import { basename as basename6, dirname as dirname15, isAbsolute as isAbsolute8, join as join64, normalize, relative as relative6, resolve as resolve8 } from "path";
53184
54105
  var MAX_TRACKED_SESSIONS = 256;
53185
54106
  var MAX_TRACKED_PATHS_PER_SESSION = 1024;
@@ -53201,7 +54122,7 @@ function isPathInsideDirectory(pathToCheck, directory) {
53201
54122
  }
53202
54123
  function toCanonicalPath(absolutePath) {
53203
54124
  let canonicalPath = absolutePath;
53204
- if (existsSync56(absolutePath)) {
54125
+ if (existsSync57(absolutePath)) {
53205
54126
  try {
53206
54127
  canonicalPath = realpathSync4.native(absolutePath);
53207
54128
  } catch {
@@ -53209,7 +54130,7 @@ function toCanonicalPath(absolutePath) {
53209
54130
  }
53210
54131
  } else {
53211
54132
  const absoluteDir = dirname15(absolutePath);
53212
- const resolvedDir = existsSync56(absoluteDir) ? realpathSync4.native(absoluteDir) : absoluteDir;
54133
+ const resolvedDir = existsSync57(absoluteDir) ? realpathSync4.native(absoluteDir) : absoluteDir;
53213
54134
  canonicalPath = join64(resolvedDir, basename6(absolutePath));
53214
54135
  }
53215
54136
  return normalize(canonicalPath);
@@ -53310,7 +54231,7 @@ function createWriteExistingFileGuardHook(ctx) {
53310
54231
  return;
53311
54232
  }
53312
54233
  if (toolName === "read") {
53313
- if (!existsSync56(resolvedPath) || !input.sessionID) {
54234
+ if (!existsSync57(resolvedPath) || !input.sessionID) {
53314
54235
  return;
53315
54236
  }
53316
54237
  registerReadPermission(input.sessionID, canonicalPath);
@@ -53320,7 +54241,7 @@ function createWriteExistingFileGuardHook(ctx) {
53320
54241
  if (argsRecord && "overwrite" in argsRecord) {
53321
54242
  delete argsRecord.overwrite;
53322
54243
  }
53323
- if (!existsSync56(resolvedPath)) {
54244
+ if (!existsSync57(resolvedPath)) {
53324
54245
  return;
53325
54246
  }
53326
54247
  const isCoderPath2 = canonicalPath.includes("/.drizzy/");
@@ -54127,7 +55048,7 @@ function createAnthropicEffortHook() {
54127
55048
  const { model, message } = input;
54128
55049
  if (!model?.modelID || !model?.providerID)
54129
55050
  return;
54130
- if (message.variant !== "max")
55051
+ if (message.model?.variant !== "max")
54131
55052
  return;
54132
55053
  if (!isClaudeProvider(model.providerID, model.modelID))
54133
55054
  return;
@@ -54403,13 +55324,13 @@ var DEFAULT_MAX_SYMBOLS = 200;
54403
55324
  var DEFAULT_MAX_DIAGNOSTICS = 200;
54404
55325
  var DEFAULT_MAX_DIRECTORY_FILES = 50;
54405
55326
  // src/tools/lsp/server-config-loader.ts
54406
- import { existsSync as existsSync57, readFileSync as readFileSync42 } from "fs";
55327
+ import { existsSync as existsSync58, readFileSync as readFileSync43 } from "fs";
54407
55328
  import { join as join65 } from "path";
54408
55329
  function loadJsonFile(path12) {
54409
- if (!existsSync57(path12))
55330
+ if (!existsSync58(path12))
54410
55331
  return null;
54411
55332
  try {
54412
- return parseJsonc(readFileSync42(path12, "utf-8"));
55333
+ return parseJsonc(readFileSync43(path12, "utf-8"));
54413
55334
  } catch {
54414
55335
  return null;
54415
55336
  }
@@ -54489,7 +55410,7 @@ function getMergedServers() {
54489
55410
  }
54490
55411
 
54491
55412
  // src/tools/lsp/server-installation.ts
54492
- import { existsSync as existsSync58 } from "fs";
55413
+ import { existsSync as existsSync59 } from "fs";
54493
55414
  import { delimiter, join as join67 } from "path";
54494
55415
 
54495
55416
  // src/tools/lsp/server-path-bases.ts
@@ -54512,7 +55433,7 @@ function isServerInstalled(command) {
54512
55433
  return false;
54513
55434
  const cmd = command[0];
54514
55435
  if (cmd.includes("/") || cmd.includes("\\")) {
54515
- if (existsSync58(cmd))
55436
+ if (existsSync59(cmd))
54516
55437
  return true;
54517
55438
  }
54518
55439
  const isWindows2 = process.platform === "win32";
@@ -54533,14 +55454,14 @@ function isServerInstalled(command) {
54533
55454
  const paths = pathEnv.split(delimiter);
54534
55455
  for (const p of paths) {
54535
55456
  for (const suffix of exts) {
54536
- if (existsSync58(join67(p, cmd + suffix))) {
55457
+ if (existsSync59(join67(p, cmd + suffix))) {
54537
55458
  return true;
54538
55459
  }
54539
55460
  }
54540
55461
  }
54541
55462
  for (const base of getLspServerAdditionalPathBases(process.cwd())) {
54542
55463
  for (const suffix of exts) {
54543
- if (existsSync58(join67(base, cmd + suffix))) {
55464
+ if (existsSync59(join67(base, cmd + suffix))) {
54544
55465
  return true;
54545
55466
  }
54546
55467
  }
@@ -54598,13 +55519,13 @@ function getLanguageId(ext) {
54598
55519
  init_logger();
54599
55520
  var {spawn: bunSpawn2 } = globalThis.Bun;
54600
55521
  import { spawn as nodeSpawn2 } from "child_process";
54601
- import { existsSync as existsSync59, statSync as statSync7 } from "fs";
55522
+ import { existsSync as existsSync60, statSync as statSync7 } from "fs";
54602
55523
  function shouldUseNodeSpawn() {
54603
55524
  return process.platform === "win32";
54604
55525
  }
54605
55526
  function validateCwd(cwd) {
54606
55527
  try {
54607
- if (!existsSync59(cwd)) {
55528
+ if (!existsSync60(cwd)) {
54608
55529
  return { valid: false, error: `Working directory does not exist: ${cwd}` };
54609
55530
  }
54610
55531
  const stats = statSync7(cwd);
@@ -54736,7 +55657,7 @@ function spawnProcess(command, options) {
54736
55657
  return proc;
54737
55658
  }
54738
55659
  // src/tools/lsp/lsp-client.ts
54739
- import { readFileSync as readFileSync43 } from "fs";
55660
+ import { readFileSync as readFileSync44 } from "fs";
54740
55661
  import { extname as extname3, resolve as resolve9 } from "path";
54741
55662
  import { pathToFileURL as pathToFileURL2 } from "url";
54742
55663
 
@@ -55008,7 +55929,7 @@ class LSPClient extends LSPClientConnection {
55008
55929
  async openFile(filePath) {
55009
55930
  const absPath = resolve9(filePath);
55010
55931
  const uri = pathToFileURL2(absPath).href;
55011
- const text = readFileSync43(absPath, "utf-8");
55932
+ const text = readFileSync44(absPath, "utf-8");
55012
55933
  if (!this.openedFiles.has(absPath)) {
55013
55934
  const ext = extname3(absPath);
55014
55935
  const languageId = getLanguageId(ext);
@@ -55349,9 +56270,9 @@ var lspManager = LSPServerManager.getInstance();
55349
56270
  // src/tools/lsp/lsp-client-wrapper.ts
55350
56271
  import { extname as extname4, resolve as resolve10 } from "path";
55351
56272
  import { fileURLToPath as fileURLToPath3 } from "url";
55352
- import { existsSync as existsSync60, statSync as statSync8 } from "fs";
56273
+ import { existsSync as existsSync61, statSync as statSync8 } from "fs";
55353
56274
  function isDirectoryPath(filePath) {
55354
- if (!existsSync60(filePath)) {
56275
+ if (!existsSync61(filePath)) {
55355
56276
  return false;
55356
56277
  }
55357
56278
  return statSync8(filePath).isDirectory();
@@ -55361,14 +56282,14 @@ function uriToPath(uri) {
55361
56282
  }
55362
56283
  function findWorkspaceRoot(filePath) {
55363
56284
  let dir = resolve10(filePath);
55364
- if (!existsSync60(dir) || !isDirectoryPath(dir)) {
56285
+ if (!existsSync61(dir) || !isDirectoryPath(dir)) {
55365
56286
  dir = __require("path").dirname(dir);
55366
56287
  }
55367
56288
  const markers = [".git", "package.json", "pyproject.toml", "Cargo.toml", "go.mod", "pom.xml", "build.gradle"];
55368
56289
  let prevDir = "";
55369
56290
  while (dir !== prevDir) {
55370
56291
  for (const marker of markers) {
55371
- if (existsSync60(__require("path").join(dir, marker))) {
56292
+ if (existsSync61(__require("path").join(dir, marker))) {
55372
56293
  return dir;
55373
56294
  }
55374
56295
  }
@@ -55543,10 +56464,10 @@ function formatApplyResult(result) {
55543
56464
  `);
55544
56465
  }
55545
56466
  // src/tools/lsp/workspace-edit.ts
55546
- import { readFileSync as readFileSync44, writeFileSync as writeFileSync18 } from "fs";
56467
+ import { readFileSync as readFileSync45, writeFileSync as writeFileSync18 } from "fs";
55547
56468
  function applyTextEditsToFile(filePath, edits) {
55548
56469
  try {
55549
- let content = readFileSync44(filePath, "utf-8");
56470
+ let content = readFileSync45(filePath, "utf-8");
55550
56471
  const lines = content.split(`
55551
56472
  `);
55552
56473
  const sortedEdits = [...edits].sort((a, b) => {
@@ -55612,7 +56533,7 @@ function applyWorkspaceEdit(edit) {
55612
56533
  try {
55613
56534
  const oldPath = uriToPath(change.oldUri);
55614
56535
  const newPath = uriToPath(change.newUri);
55615
- const content = readFileSync44(oldPath, "utf-8");
56536
+ const content = readFileSync45(oldPath, "utf-8");
55616
56537
  writeFileSync18(newPath, content, "utf-8");
55617
56538
  __require("fs").unlinkSync(oldPath);
55618
56539
  result.filesModified.push(newPath);
@@ -68095,7 +69016,7 @@ var lsp_symbols = tool({
68095
69016
  import { resolve as resolve12 } from "path";
68096
69017
 
68097
69018
  // src/tools/lsp/directory-diagnostics.ts
68098
- 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";
68099
69020
  import { extname as extname5, join as join68, resolve as resolve11 } from "path";
68100
69021
  var SKIP_DIRECTORIES = new Set(["node_modules", ".git", "dist", "build", ".next", "out"]);
68101
69022
  function collectFilesWithExtension(dir, extension, maxFiles) {
@@ -68141,7 +69062,7 @@ async function aggregateDiagnosticsForDirectory(directory, extension, severity,
68141
69062
  throw new Error(`Extension must start with a dot (e.g., ".ts", not "${extension}"). ` + `Use ".${extension}" instead.`);
68142
69063
  }
68143
69064
  const absDir = resolve11(directory);
68144
- if (!existsSync61(absDir)) {
69065
+ if (!existsSync62(absDir)) {
68145
69066
  throw new Error(`Directory does not exist: ${absDir}`);
68146
69067
  }
68147
69068
  const serverResult = findServerForExtension(extension);
@@ -68344,10 +69265,10 @@ var DEFAULT_MAX_MATCHES = 500;
68344
69265
  // src/tools/ast-grep/sg-cli-path.ts
68345
69266
  import { createRequire as createRequire4 } from "module";
68346
69267
  import { dirname as dirname16, join as join70 } from "path";
68347
- import { existsSync as existsSync63, statSync as statSync9 } from "fs";
69268
+ import { existsSync as existsSync64, statSync as statSync9 } from "fs";
68348
69269
 
68349
69270
  // src/tools/ast-grep/downloader.ts
68350
- import { existsSync as existsSync62 } from "fs";
69271
+ import { existsSync as existsSync63 } from "fs";
68351
69272
  import { join as join69 } from "path";
68352
69273
  import { homedir as homedir13 } from "os";
68353
69274
  import { createRequire as createRequire3 } from "module";
@@ -68398,7 +69319,7 @@ async function downloadAstGrep(version3 = DEFAULT_VERSION) {
68398
69319
  const cacheDir = getCacheDir3();
68399
69320
  const binaryName = getBinaryName3();
68400
69321
  const binaryPath = join69(cacheDir, binaryName);
68401
- if (existsSync62(binaryPath)) {
69322
+ if (existsSync63(binaryPath)) {
68402
69323
  return binaryPath;
68403
69324
  }
68404
69325
  const { arch, os: os6 } = platformInfo;
@@ -68461,7 +69382,7 @@ function findSgCliPathSync() {
68461
69382
  const cliPackageJsonPath = require2.resolve("@ast-grep/cli/package.json");
68462
69383
  const cliDirectory = dirname16(cliPackageJsonPath);
68463
69384
  const sgPath = join70(cliDirectory, binaryName);
68464
- if (existsSync63(sgPath) && isValidBinary(sgPath)) {
69385
+ if (existsSync64(sgPath) && isValidBinary(sgPath)) {
68465
69386
  return sgPath;
68466
69387
  }
68467
69388
  } catch {}
@@ -68473,7 +69394,7 @@ function findSgCliPathSync() {
68473
69394
  const packageDirectory = dirname16(packageJsonPath);
68474
69395
  const astGrepBinaryName = process.platform === "win32" ? "ast-grep.exe" : "ast-grep";
68475
69396
  const binaryPath = join70(packageDirectory, astGrepBinaryName);
68476
- if (existsSync63(binaryPath) && isValidBinary(binaryPath)) {
69397
+ if (existsSync64(binaryPath) && isValidBinary(binaryPath)) {
68477
69398
  return binaryPath;
68478
69399
  }
68479
69400
  } catch {}
@@ -68481,7 +69402,7 @@ function findSgCliPathSync() {
68481
69402
  if (process.platform === "darwin") {
68482
69403
  const homebrewPaths = ["/opt/homebrew/bin/sg", "/usr/local/bin/sg"];
68483
69404
  for (const path12 of homebrewPaths) {
68484
- if (existsSync63(path12) && isValidBinary(path12)) {
69405
+ if (existsSync64(path12) && isValidBinary(path12)) {
68485
69406
  return path12;
68486
69407
  }
68487
69408
  }
@@ -68505,14 +69426,14 @@ function setSgCliPath(path12) {
68505
69426
  }
68506
69427
  // src/tools/ast-grep/cli.ts
68507
69428
  var {spawn: spawn10 } = globalThis.Bun;
68508
- import { existsSync as existsSync65 } from "fs";
69429
+ import { existsSync as existsSync66 } from "fs";
68509
69430
 
68510
69431
  // src/tools/ast-grep/cli-binary-path-resolution.ts
68511
- import { existsSync as existsSync64 } from "fs";
69432
+ import { existsSync as existsSync65 } from "fs";
68512
69433
  var resolvedCliPath3 = null;
68513
69434
  var initPromise3 = null;
68514
69435
  async function getAstGrepPath() {
68515
- if (resolvedCliPath3 !== null && existsSync64(resolvedCliPath3)) {
69436
+ if (resolvedCliPath3 !== null && existsSync65(resolvedCliPath3)) {
68516
69437
  return resolvedCliPath3;
68517
69438
  }
68518
69439
  if (initPromise3) {
@@ -68520,7 +69441,7 @@ async function getAstGrepPath() {
68520
69441
  }
68521
69442
  initPromise3 = (async () => {
68522
69443
  const syncPath = findSgCliPathSync();
68523
- if (syncPath && existsSync64(syncPath)) {
69444
+ if (syncPath && existsSync65(syncPath)) {
68524
69445
  resolvedCliPath3 = syncPath;
68525
69446
  setSgCliPath(syncPath);
68526
69447
  return syncPath;
@@ -68619,7 +69540,7 @@ async function runSg(options) {
68619
69540
  const paths = options.paths && options.paths.length > 0 ? options.paths : ["."];
68620
69541
  args.push(...paths);
68621
69542
  let cliPath = getSgCliPath();
68622
- if (!cliPath || !existsSync65(cliPath)) {
69543
+ if (!cliPath || !existsSync66(cliPath)) {
68623
69544
  const downloadedPath = await getAstGrepPath();
68624
69545
  if (downloadedPath) {
68625
69546
  cliPath = downloadedPath;
@@ -68873,12 +69794,12 @@ import { resolve as resolve13 } from "path";
68873
69794
  var {spawn: spawn11 } = globalThis.Bun;
68874
69795
 
68875
69796
  // src/tools/grep/constants.ts
68876
- import { existsSync as existsSync67 } from "fs";
69797
+ import { existsSync as existsSync68 } from "fs";
68877
69798
  import { join as join72, dirname as dirname17 } from "path";
68878
69799
  import { spawnSync as spawnSync2 } from "child_process";
68879
69800
 
68880
69801
  // src/tools/grep/downloader.ts
68881
- import { existsSync as existsSync66, readdirSync as readdirSync18 } from "fs";
69802
+ import { existsSync as existsSync67, readdirSync as readdirSync18 } from "fs";
68882
69803
  import { join as join71 } from "path";
68883
69804
  function findFileRecursive(dir, filename) {
68884
69805
  try {
@@ -68942,7 +69863,7 @@ async function downloadAndInstallRipgrep() {
68942
69863
  }
68943
69864
  const installDir = getInstallDir();
68944
69865
  const rgPath = getRgPath();
68945
- if (existsSync66(rgPath)) {
69866
+ if (existsSync67(rgPath)) {
68946
69867
  return rgPath;
68947
69868
  }
68948
69869
  ensureCacheDir(installDir);
@@ -68957,7 +69878,7 @@ async function downloadAndInstallRipgrep() {
68957
69878
  await extractZip2(archivePath, installDir);
68958
69879
  }
68959
69880
  ensureExecutable(rgPath);
68960
- if (!existsSync66(rgPath)) {
69881
+ if (!existsSync67(rgPath)) {
68961
69882
  throw new Error("ripgrep binary not found after extraction");
68962
69883
  }
68963
69884
  return rgPath;
@@ -68969,7 +69890,7 @@ async function downloadAndInstallRipgrep() {
68969
69890
  }
68970
69891
  function getInstalledRipgrepPath() {
68971
69892
  const rgPath = getRgPath();
68972
- return existsSync66(rgPath) ? rgPath : null;
69893
+ return existsSync67(rgPath) ? rgPath : null;
68973
69894
  }
68974
69895
 
68975
69896
  // src/tools/grep/constants.ts
@@ -69000,7 +69921,7 @@ function getOpenCodeBundledRg() {
69000
69921
  join72(execDir, "..", "libexec", rgName)
69001
69922
  ];
69002
69923
  for (const candidate of candidates) {
69003
- if (existsSync67(candidate)) {
69924
+ if (existsSync68(candidate)) {
69004
69925
  return candidate;
69005
69926
  }
69006
69927
  }
@@ -69639,10 +70560,10 @@ Use this when a task matches an available skill's or command's description.
69639
70560
  // src/tools/skill/tools.ts
69640
70561
  import { dirname as dirname19 } from "path";
69641
70562
  // src/tools/slashcommand/command-discovery.ts
69642
- 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";
69643
70564
  import { basename as basename7, join as join73 } from "path";
69644
70565
  function discoverCommandsFromDir2(commandsDir, scope) {
69645
- if (!existsSync68(commandsDir))
70566
+ if (!existsSync69(commandsDir))
69646
70567
  return [];
69647
70568
  const entries = readdirSync19(commandsDir, { withFileTypes: true });
69648
70569
  const commands3 = [];
@@ -69652,7 +70573,7 @@ function discoverCommandsFromDir2(commandsDir, scope) {
69652
70573
  const commandPath = join73(commandsDir, entry.name);
69653
70574
  const commandName = basename7(entry.name, ".md");
69654
70575
  try {
69655
- const content = readFileSync45(commandPath, "utf-8");
70576
+ const content = readFileSync46(commandPath, "utf-8");
69656
70577
  const { data, body } = parseFrontmatter(content);
69657
70578
  const isOpencodeSource = scope === "opencode" || scope === "opencode-project";
69658
70579
  const metadata = {
@@ -70107,7 +71028,7 @@ Has Todos: Yes (12 items, 8 completed)
70107
71028
  Has Transcript: Yes (234 entries)`;
70108
71029
 
70109
71030
  // src/tools/session-manager/storage.ts
70110
- import { existsSync as existsSync69 } from "fs";
71031
+ import { existsSync as existsSync70 } from "fs";
70111
71032
  import { readdir, readFile } from "fs/promises";
70112
71033
  import { join as join75 } from "path";
70113
71034
  var sdkClient = null;
@@ -70128,7 +71049,7 @@ async function getMainSessions(options) {
70128
71049
  return [];
70129
71050
  }
70130
71051
  }
70131
- if (!existsSync69(SESSION_STORAGE))
71052
+ if (!existsSync70(SESSION_STORAGE))
70132
71053
  return [];
70133
71054
  const sessions = [];
70134
71055
  try {
@@ -70169,7 +71090,7 @@ async function getAllSessions() {
70169
71090
  return [];
70170
71091
  }
70171
71092
  }
70172
- if (!existsSync69(MESSAGE_STORAGE))
71093
+ if (!existsSync70(MESSAGE_STORAGE))
70173
71094
  return [];
70174
71095
  const sessions = [];
70175
71096
  async function scanDirectory(dir) {
@@ -70238,7 +71159,7 @@ async function readSessionMessages(sessionID) {
70238
71159
  }
70239
71160
  }
70240
71161
  const messageDir = getMessageDir(sessionID);
70241
- if (!messageDir || !existsSync69(messageDir))
71162
+ if (!messageDir || !existsSync70(messageDir))
70242
71163
  return [];
70243
71164
  const messages = [];
70244
71165
  try {
@@ -70274,7 +71195,7 @@ async function readSessionMessages(sessionID) {
70274
71195
  }
70275
71196
  async function readParts2(messageID) {
70276
71197
  const partDir = join75(PART_STORAGE, messageID);
70277
- if (!existsSync69(partDir))
71198
+ if (!existsSync70(partDir))
70278
71199
  return [];
70279
71200
  const parts = [];
70280
71201
  try {
@@ -70309,7 +71230,7 @@ async function readSessionTodos(sessionID) {
70309
71230
  return [];
70310
71231
  }
70311
71232
  }
70312
- if (!existsSync69(TODO_DIR2))
71233
+ if (!existsSync70(TODO_DIR2))
70313
71234
  return [];
70314
71235
  try {
70315
71236
  const allFiles = await readdir(TODO_DIR2);
@@ -70336,10 +71257,10 @@ async function readSessionTodos(sessionID) {
70336
71257
  return [];
70337
71258
  }
70338
71259
  async function readSessionTranscript(sessionID) {
70339
- if (!existsSync69(TRANSCRIPT_DIR2))
71260
+ if (!existsSync70(TRANSCRIPT_DIR2))
70340
71261
  return 0;
70341
71262
  const transcriptFile = join75(TRANSCRIPT_DIR2, `${sessionID}.jsonl`);
70342
- if (!existsSync69(transcriptFile))
71263
+ if (!existsSync70(transcriptFile))
70343
71264
  return 0;
70344
71265
  try {
70345
71266
  const content = await readFile(transcriptFile, "utf-8");
@@ -72188,7 +73109,7 @@ async function resolveMultimodalLookerAgentMetadata(ctx) {
72188
73109
 
72189
73110
  // src/tools/look-at/image-converter.ts
72190
73111
  import { execFileSync as execFileSync3 } from "child_process";
72191
- 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";
72192
73113
  import { tmpdir as tmpdir6 } from "os";
72193
73114
  import { dirname as dirname20, join as join76 } from "path";
72194
73115
  var SUPPORTED_FORMATS = new Set([
@@ -72228,7 +73149,7 @@ function needsConversion(mimeType) {
72228
73149
  return mimeType.startsWith("image/");
72229
73150
  }
72230
73151
  function convertImageToJpeg(inputPath, mimeType) {
72231
- if (!existsSync70(inputPath)) {
73152
+ if (!existsSync71(inputPath)) {
72232
73153
  throw new Error(`File not found: ${inputPath}`);
72233
73154
  }
72234
73155
  const tempDir = mkdtempSync(join76(tmpdir6(), "opencode-img-"));
@@ -72242,7 +73163,7 @@ function convertImageToJpeg(inputPath, mimeType) {
72242
73163
  encoding: "utf-8",
72243
73164
  timeout: CONVERSION_TIMEOUT_MS
72244
73165
  });
72245
- if (existsSync70(outputPath)) {
73166
+ if (existsSync71(outputPath)) {
72246
73167
  log(`[image-converter] Converted using sips: ${outputPath}`);
72247
73168
  return outputPath;
72248
73169
  }
@@ -72257,7 +73178,7 @@ function convertImageToJpeg(inputPath, mimeType) {
72257
73178
  encoding: "utf-8",
72258
73179
  timeout: CONVERSION_TIMEOUT_MS
72259
73180
  });
72260
- if (existsSync70(outputPath)) {
73181
+ if (existsSync71(outputPath)) {
72261
73182
  log(`[image-converter] Converted using ImageMagick: ${outputPath}`);
72262
73183
  return outputPath;
72263
73184
  }
@@ -72270,7 +73191,7 @@ function convertImageToJpeg(inputPath, mimeType) {
72270
73191
  ` + ` RHEL/CentOS: sudo yum install ImageMagick`);
72271
73192
  } catch (error92) {
72272
73193
  try {
72273
- if (existsSync70(outputPath)) {
73194
+ if (existsSync71(outputPath)) {
72274
73195
  unlinkSync11(outputPath);
72275
73196
  }
72276
73197
  } catch {}
@@ -72284,11 +73205,11 @@ function convertImageToJpeg(inputPath, mimeType) {
72284
73205
  function cleanupConvertedImage(filePath) {
72285
73206
  try {
72286
73207
  const tempDirectory = dirname20(filePath);
72287
- if (existsSync70(filePath)) {
73208
+ if (existsSync71(filePath)) {
72288
73209
  unlinkSync11(filePath);
72289
73210
  log(`[image-converter] Cleaned up temporary file: ${filePath}`);
72290
73211
  }
72291
- if (existsSync70(tempDirectory)) {
73212
+ if (existsSync71(tempDirectory)) {
72292
73213
  rmSync3(tempDirectory, { recursive: true, force: true });
72293
73214
  log(`[image-converter] Cleaned up temporary directory: ${tempDirectory}`);
72294
73215
  }
@@ -72308,14 +73229,14 @@ function convertBase64ImageToJpeg(base64Data, mimeType) {
72308
73229
  log(`[image-converter] Converting Base64 ${mimeType} to JPEG`);
72309
73230
  const outputPath = convertImageToJpeg(inputPath, mimeType);
72310
73231
  tempFiles.push(outputPath);
72311
- const convertedBuffer = readFileSync46(outputPath);
73232
+ const convertedBuffer = readFileSync47(outputPath);
72312
73233
  const convertedBase64 = convertedBuffer.toString("base64");
72313
73234
  log(`[image-converter] Base64 conversion successful`);
72314
73235
  return { base64: convertedBase64, tempFiles };
72315
73236
  } catch (error92) {
72316
73237
  tempFiles.forEach((file3) => {
72317
73238
  try {
72318
- if (existsSync70(file3))
73239
+ if (existsSync71(file3))
72319
73240
  unlinkSync11(file3);
72320
73241
  } catch {}
72321
73242
  });
@@ -72478,8 +73399,12 @@ Original error: ${createResult.error}`;
72478
73399
  { type: "text", text: prompt },
72479
73400
  filePart
72480
73401
  ],
72481
- ...agentModel ? { model: { providerID: agentModel.providerID, modelID: agentModel.modelID } } : {},
72482
- ...agentVariant ? { variant: agentVariant } : {}
73402
+ ...agentModel || agentVariant ? {
73403
+ model: {
73404
+ ...agentModel ? { providerID: agentModel.providerID, modelID: agentModel.modelID } : {},
73405
+ ...agentVariant ? { variant: agentVariant } : {}
73406
+ }
73407
+ } : {}
72483
73408
  }
72484
73409
  });
72485
73410
  } catch (promptError) {
@@ -73694,8 +74619,12 @@ async function executeSyncContinuation(args, ctx, executorCtx, deps = syncContin
73694
74619
  path: { id: args.session_id },
73695
74620
  body: {
73696
74621
  ...resumeAgent !== undefined ? { agent: resumeAgent } : {},
73697
- ...resumeModel !== undefined ? { model: resumeModel } : {},
73698
- ...resumeVariant !== undefined ? { variant: resumeVariant } : {},
74622
+ ...resumeModel !== undefined || resumeVariant !== undefined ? {
74623
+ model: {
74624
+ ...resumeModel ?? {},
74625
+ ...resumeVariant !== undefined ? { variant: resumeVariant } : {}
74626
+ }
74627
+ } : {},
73699
74628
  tools,
73700
74629
  parts: [{ type: "text", text: effectivePrompt }]
73701
74630
  }
@@ -74072,8 +75001,13 @@ async function sendSyncPrompt(client2, input, deps = sendSyncPromptDeps) {
74072
75001
  system: input.systemContent,
74073
75002
  tools,
74074
75003
  parts: [createInternalAgentTextPart(effectivePrompt)],
74075
- ...input.categoryModel ? { model: { providerID: input.categoryModel.providerID, modelID: input.categoryModel.modelID } } : {},
74076
- ...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
+ } : {}
74077
75011
  }
74078
75012
  };
74079
75013
  try {
@@ -74983,7 +75917,7 @@ var TaskDeleteInputSchema = exports_external.object({
74983
75917
 
74984
75918
  // src/features/claude-tasks/storage.ts
74985
75919
  import { join as join77, dirname as dirname21, basename as basename9, isAbsolute as isAbsolute9 } from "path";
74986
- 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";
74987
75921
  import { randomUUID as randomUUID3 } from "crypto";
74988
75922
  function getTaskDir(config4 = {}) {
74989
75923
  const tasksConfig = config4.coder?.tasks;
@@ -75011,16 +75945,16 @@ function resolveTaskListId(config4 = {}) {
75011
75945
  return sanitizePathSegment(basename9(process.cwd()));
75012
75946
  }
75013
75947
  function ensureDir(dirPath) {
75014
- if (!existsSync71(dirPath)) {
75948
+ if (!existsSync72(dirPath)) {
75015
75949
  mkdirSync14(dirPath, { recursive: true });
75016
75950
  }
75017
75951
  }
75018
75952
  function readJsonSafe(filePath, schema2) {
75019
75953
  try {
75020
- if (!existsSync71(filePath)) {
75954
+ if (!existsSync72(filePath)) {
75021
75955
  return null;
75022
75956
  }
75023
- const content = readFileSync47(filePath, "utf-8");
75957
+ const content = readFileSync48(filePath, "utf-8");
75024
75958
  const parsed = JSON.parse(content);
75025
75959
  const result = schema2.safeParse(parsed);
75026
75960
  if (!result.success) {
@@ -75040,7 +75974,7 @@ function writeJsonAtomic(filePath, data) {
75040
75974
  renameSync2(tempPath, filePath);
75041
75975
  } catch (error92) {
75042
75976
  try {
75043
- if (existsSync71(tempPath)) {
75977
+ if (existsSync72(tempPath)) {
75044
75978
  unlinkSync12(tempPath);
75045
75979
  }
75046
75980
  } catch {}
@@ -75062,7 +75996,7 @@ function acquireLock(dirPath) {
75062
75996
  };
75063
75997
  const isStale = () => {
75064
75998
  try {
75065
- const lockContent = readFileSync47(lockPath, "utf-8");
75999
+ const lockContent = readFileSync48(lockPath, "utf-8");
75066
76000
  const lockData = JSON.parse(lockContent);
75067
76001
  const lockAge = Date.now() - lockData.timestamp;
75068
76002
  return lockAge > STALE_LOCK_THRESHOLD_MS;
@@ -75100,9 +76034,9 @@ function acquireLock(dirPath) {
75100
76034
  acquired: true,
75101
76035
  release: () => {
75102
76036
  try {
75103
- if (!existsSync71(lockPath))
76037
+ if (!existsSync72(lockPath))
75104
76038
  return;
75105
- const lockContent = readFileSync47(lockPath, "utf-8");
76039
+ const lockContent = readFileSync48(lockPath, "utf-8");
75106
76040
  const lockData = JSON.parse(lockContent);
75107
76041
  if (lockData.id !== lockId)
75108
76042
  return;
@@ -75326,7 +76260,7 @@ Returns null if the task does not exist or the file is invalid.`,
75326
76260
  }
75327
76261
  // src/tools/task/task-list.ts
75328
76262
  import { join as join80 } from "path";
75329
- import { existsSync as existsSync72, readdirSync as readdirSync21 } from "fs";
76263
+ import { existsSync as existsSync73, readdirSync as readdirSync21 } from "fs";
75330
76264
  function createTaskList(config4) {
75331
76265
  return tool({
75332
76266
  description: `List all active tasks with summary information.
@@ -75337,7 +76271,7 @@ Returns summary format: id, subject, status, owner, blockedBy (not full descript
75337
76271
  args: {},
75338
76272
  execute: async () => {
75339
76273
  const taskDir = getTaskDir(config4);
75340
- if (!existsSync72(taskDir)) {
76274
+ if (!existsSync73(taskDir)) {
75341
76275
  return JSON.stringify({ tasks: [] });
75342
76276
  }
75343
76277
  const files = readdirSync21(taskDir).filter((f) => f.endsWith(".json") && f.startsWith("T-")).map((f) => f.replace(".json", ""));
@@ -76107,445 +77041,6 @@ function applyHashlineEditsWithReport(content, edits) {
76107
77041
  deduplicatedEdits: dedupeResult.deduplicatedEdits
76108
77042
  };
76109
77043
  }
76110
- // node_modules/diff/libesm/diff/base.js
76111
- class Diff {
76112
- diff(oldStr, newStr, options = {}) {
76113
- let callback;
76114
- if (typeof options === "function") {
76115
- callback = options;
76116
- options = {};
76117
- } else if ("callback" in options) {
76118
- callback = options.callback;
76119
- }
76120
- const oldString = this.castInput(oldStr, options);
76121
- const newString = this.castInput(newStr, options);
76122
- const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
76123
- const newTokens = this.removeEmpty(this.tokenize(newString, options));
76124
- return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
76125
- }
76126
- diffWithOptionsObj(oldTokens, newTokens, options, callback) {
76127
- var _a2;
76128
- const done = (value) => {
76129
- value = this.postProcess(value, options);
76130
- if (callback) {
76131
- setTimeout(function() {
76132
- callback(value);
76133
- }, 0);
76134
- return;
76135
- } else {
76136
- return value;
76137
- }
76138
- };
76139
- const newLen = newTokens.length, oldLen = oldTokens.length;
76140
- let editLength = 1;
76141
- let maxEditLength = newLen + oldLen;
76142
- if (options.maxEditLength != null) {
76143
- maxEditLength = Math.min(maxEditLength, options.maxEditLength);
76144
- }
76145
- const maxExecutionTime = (_a2 = options.timeout) !== null && _a2 !== undefined ? _a2 : Infinity;
76146
- const abortAfterTimestamp = Date.now() + maxExecutionTime;
76147
- const bestPath = [{ oldPos: -1, lastComponent: undefined }];
76148
- let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
76149
- if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
76150
- return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
76151
- }
76152
- let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
76153
- const execEditLength = () => {
76154
- for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength);diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
76155
- let basePath;
76156
- const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
76157
- if (removePath) {
76158
- bestPath[diagonalPath - 1] = undefined;
76159
- }
76160
- let canAdd = false;
76161
- if (addPath) {
76162
- const addPathNewPos = addPath.oldPos - diagonalPath;
76163
- canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
76164
- }
76165
- const canRemove = removePath && removePath.oldPos + 1 < oldLen;
76166
- if (!canAdd && !canRemove) {
76167
- bestPath[diagonalPath] = undefined;
76168
- continue;
76169
- }
76170
- if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
76171
- basePath = this.addToPath(addPath, true, false, 0, options);
76172
- } else {
76173
- basePath = this.addToPath(removePath, false, true, 1, options);
76174
- }
76175
- newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
76176
- if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
76177
- return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
76178
- } else {
76179
- bestPath[diagonalPath] = basePath;
76180
- if (basePath.oldPos + 1 >= oldLen) {
76181
- maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
76182
- }
76183
- if (newPos + 1 >= newLen) {
76184
- minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
76185
- }
76186
- }
76187
- }
76188
- editLength++;
76189
- };
76190
- if (callback) {
76191
- (function exec2() {
76192
- setTimeout(function() {
76193
- if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
76194
- return callback(undefined);
76195
- }
76196
- if (!execEditLength()) {
76197
- exec2();
76198
- }
76199
- }, 0);
76200
- })();
76201
- } else {
76202
- while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
76203
- const ret = execEditLength();
76204
- if (ret) {
76205
- return ret;
76206
- }
76207
- }
76208
- }
76209
- }
76210
- addToPath(path12, added, removed, oldPosInc, options) {
76211
- const last = path12.lastComponent;
76212
- if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
76213
- return {
76214
- oldPos: path12.oldPos + oldPosInc,
76215
- lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
76216
- };
76217
- } else {
76218
- return {
76219
- oldPos: path12.oldPos + oldPosInc,
76220
- lastComponent: { count: 1, added, removed, previousComponent: last }
76221
- };
76222
- }
76223
- }
76224
- extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
76225
- const newLen = newTokens.length, oldLen = oldTokens.length;
76226
- let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
76227
- while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
76228
- newPos++;
76229
- oldPos++;
76230
- commonCount++;
76231
- if (options.oneChangePerToken) {
76232
- basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };
76233
- }
76234
- }
76235
- if (commonCount && !options.oneChangePerToken) {
76236
- basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };
76237
- }
76238
- basePath.oldPos = oldPos;
76239
- return newPos;
76240
- }
76241
- equals(left, right, options) {
76242
- if (options.comparator) {
76243
- return options.comparator(left, right);
76244
- } else {
76245
- return left === right || !!options.ignoreCase && left.toLowerCase() === right.toLowerCase();
76246
- }
76247
- }
76248
- removeEmpty(array3) {
76249
- const ret = [];
76250
- for (let i2 = 0;i2 < array3.length; i2++) {
76251
- if (array3[i2]) {
76252
- ret.push(array3[i2]);
76253
- }
76254
- }
76255
- return ret;
76256
- }
76257
- castInput(value, options) {
76258
- return value;
76259
- }
76260
- tokenize(value, options) {
76261
- return Array.from(value);
76262
- }
76263
- join(chars) {
76264
- return chars.join("");
76265
- }
76266
- postProcess(changeObjects, options) {
76267
- return changeObjects;
76268
- }
76269
- get useLongestToken() {
76270
- return false;
76271
- }
76272
- buildValues(lastComponent, newTokens, oldTokens) {
76273
- const components = [];
76274
- let nextComponent;
76275
- while (lastComponent) {
76276
- components.push(lastComponent);
76277
- nextComponent = lastComponent.previousComponent;
76278
- delete lastComponent.previousComponent;
76279
- lastComponent = nextComponent;
76280
- }
76281
- components.reverse();
76282
- const componentLen = components.length;
76283
- let componentPos = 0, newPos = 0, oldPos = 0;
76284
- for (;componentPos < componentLen; componentPos++) {
76285
- const component = components[componentPos];
76286
- if (!component.removed) {
76287
- if (!component.added && this.useLongestToken) {
76288
- let value = newTokens.slice(newPos, newPos + component.count);
76289
- value = value.map(function(value2, i2) {
76290
- const oldValue = oldTokens[oldPos + i2];
76291
- return oldValue.length > value2.length ? oldValue : value2;
76292
- });
76293
- component.value = this.join(value);
76294
- } else {
76295
- component.value = this.join(newTokens.slice(newPos, newPos + component.count));
76296
- }
76297
- newPos += component.count;
76298
- if (!component.added) {
76299
- oldPos += component.count;
76300
- }
76301
- } else {
76302
- component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
76303
- oldPos += component.count;
76304
- }
76305
- }
76306
- return components;
76307
- }
76308
- }
76309
-
76310
- // node_modules/diff/libesm/diff/line.js
76311
- class LineDiff extends Diff {
76312
- constructor() {
76313
- super(...arguments);
76314
- this.tokenize = tokenize;
76315
- }
76316
- equals(left, right, options) {
76317
- if (options.ignoreWhitespace) {
76318
- if (!options.newlineIsToken || !left.includes(`
76319
- `)) {
76320
- left = left.trim();
76321
- }
76322
- if (!options.newlineIsToken || !right.includes(`
76323
- `)) {
76324
- right = right.trim();
76325
- }
76326
- } else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
76327
- if (left.endsWith(`
76328
- `)) {
76329
- left = left.slice(0, -1);
76330
- }
76331
- if (right.endsWith(`
76332
- `)) {
76333
- right = right.slice(0, -1);
76334
- }
76335
- }
76336
- return super.equals(left, right, options);
76337
- }
76338
- }
76339
- var lineDiff = new LineDiff;
76340
- function diffLines(oldStr, newStr, options) {
76341
- return lineDiff.diff(oldStr, newStr, options);
76342
- }
76343
- function tokenize(value, options) {
76344
- if (options.stripTrailingCr) {
76345
- value = value.replace(/\r\n/g, `
76346
- `);
76347
- }
76348
- const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
76349
- if (!linesAndNewlines[linesAndNewlines.length - 1]) {
76350
- linesAndNewlines.pop();
76351
- }
76352
- for (let i2 = 0;i2 < linesAndNewlines.length; i2++) {
76353
- const line = linesAndNewlines[i2];
76354
- if (i2 % 2 && !options.newlineIsToken) {
76355
- retLines[retLines.length - 1] += line;
76356
- } else {
76357
- retLines.push(line);
76358
- }
76359
- }
76360
- return retLines;
76361
- }
76362
-
76363
- // node_modules/diff/libesm/patch/create.js
76364
- var INCLUDE_HEADERS = {
76365
- includeIndex: true,
76366
- includeUnderline: true,
76367
- includeFileHeaders: true
76368
- };
76369
- function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
76370
- let optionsObj;
76371
- if (!options) {
76372
- optionsObj = {};
76373
- } else if (typeof options === "function") {
76374
- optionsObj = { callback: options };
76375
- } else {
76376
- optionsObj = options;
76377
- }
76378
- if (typeof optionsObj.context === "undefined") {
76379
- optionsObj.context = 4;
76380
- }
76381
- const context = optionsObj.context;
76382
- if (optionsObj.newlineIsToken) {
76383
- throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");
76384
- }
76385
- if (!optionsObj.callback) {
76386
- return diffLinesResultToPatch(diffLines(oldStr, newStr, optionsObj));
76387
- } else {
76388
- const { callback } = optionsObj;
76389
- diffLines(oldStr, newStr, Object.assign(Object.assign({}, optionsObj), { callback: (diff) => {
76390
- const patch = diffLinesResultToPatch(diff);
76391
- callback(patch);
76392
- } }));
76393
- }
76394
- function diffLinesResultToPatch(diff) {
76395
- if (!diff) {
76396
- return;
76397
- }
76398
- diff.push({ value: "", lines: [] });
76399
- function contextLines(lines) {
76400
- return lines.map(function(entry) {
76401
- return " " + entry;
76402
- });
76403
- }
76404
- const hunks = [];
76405
- let oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1;
76406
- for (let i2 = 0;i2 < diff.length; i2++) {
76407
- const current = diff[i2], lines = current.lines || splitLines(current.value);
76408
- current.lines = lines;
76409
- if (current.added || current.removed) {
76410
- if (!oldRangeStart) {
76411
- const prev = diff[i2 - 1];
76412
- oldRangeStart = oldLine;
76413
- newRangeStart = newLine;
76414
- if (prev) {
76415
- curRange = context > 0 ? contextLines(prev.lines.slice(-context)) : [];
76416
- oldRangeStart -= curRange.length;
76417
- newRangeStart -= curRange.length;
76418
- }
76419
- }
76420
- for (const line of lines) {
76421
- curRange.push((current.added ? "+" : "-") + line);
76422
- }
76423
- if (current.added) {
76424
- newLine += lines.length;
76425
- } else {
76426
- oldLine += lines.length;
76427
- }
76428
- } else {
76429
- if (oldRangeStart) {
76430
- if (lines.length <= context * 2 && i2 < diff.length - 2) {
76431
- for (const line of contextLines(lines)) {
76432
- curRange.push(line);
76433
- }
76434
- } else {
76435
- const contextSize = Math.min(lines.length, context);
76436
- for (const line of contextLines(lines.slice(0, contextSize))) {
76437
- curRange.push(line);
76438
- }
76439
- const hunk = {
76440
- oldStart: oldRangeStart,
76441
- oldLines: oldLine - oldRangeStart + contextSize,
76442
- newStart: newRangeStart,
76443
- newLines: newLine - newRangeStart + contextSize,
76444
- lines: curRange
76445
- };
76446
- hunks.push(hunk);
76447
- oldRangeStart = 0;
76448
- newRangeStart = 0;
76449
- curRange = [];
76450
- }
76451
- }
76452
- oldLine += lines.length;
76453
- newLine += lines.length;
76454
- }
76455
- }
76456
- for (const hunk of hunks) {
76457
- for (let i2 = 0;i2 < hunk.lines.length; i2++) {
76458
- if (hunk.lines[i2].endsWith(`
76459
- `)) {
76460
- hunk.lines[i2] = hunk.lines[i2].slice(0, -1);
76461
- } else {
76462
- hunk.lines.splice(i2 + 1, 0, "\");
76463
- i2++;
76464
- }
76465
- }
76466
- }
76467
- return {
76468
- oldFileName,
76469
- newFileName,
76470
- oldHeader,
76471
- newHeader,
76472
- hunks
76473
- };
76474
- }
76475
- }
76476
- function formatPatch(patch, headerOptions) {
76477
- if (!headerOptions) {
76478
- headerOptions = INCLUDE_HEADERS;
76479
- }
76480
- if (Array.isArray(patch)) {
76481
- if (patch.length > 1 && !headerOptions.includeFileHeaders) {
76482
- 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?)");
76483
- }
76484
- return patch.map((p) => formatPatch(p, headerOptions)).join(`
76485
- `);
76486
- }
76487
- const ret = [];
76488
- if (headerOptions.includeIndex && patch.oldFileName == patch.newFileName) {
76489
- ret.push("Index: " + patch.oldFileName);
76490
- }
76491
- if (headerOptions.includeUnderline) {
76492
- ret.push("===================================================================");
76493
- }
76494
- if (headerOptions.includeFileHeaders) {
76495
- ret.push("--- " + patch.oldFileName + (typeof patch.oldHeader === "undefined" ? "" : "\t" + patch.oldHeader));
76496
- ret.push("+++ " + patch.newFileName + (typeof patch.newHeader === "undefined" ? "" : "\t" + patch.newHeader));
76497
- }
76498
- for (let i2 = 0;i2 < patch.hunks.length; i2++) {
76499
- const hunk = patch.hunks[i2];
76500
- if (hunk.oldLines === 0) {
76501
- hunk.oldStart -= 1;
76502
- }
76503
- if (hunk.newLines === 0) {
76504
- hunk.newStart -= 1;
76505
- }
76506
- ret.push("@@ -" + hunk.oldStart + "," + hunk.oldLines + " +" + hunk.newStart + "," + hunk.newLines + " @@");
76507
- for (const line of hunk.lines) {
76508
- ret.push(line);
76509
- }
76510
- }
76511
- return ret.join(`
76512
- `) + `
76513
- `;
76514
- }
76515
- function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
76516
- if (typeof options === "function") {
76517
- options = { callback: options };
76518
- }
76519
- if (!(options === null || options === undefined ? undefined : options.callback)) {
76520
- const patchObj = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
76521
- if (!patchObj) {
76522
- return;
76523
- }
76524
- return formatPatch(patchObj, options === null || options === undefined ? undefined : options.headerOptions);
76525
- } else {
76526
- const { callback } = options;
76527
- structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, Object.assign(Object.assign({}, options), { callback: (patchObj) => {
76528
- if (!patchObj) {
76529
- callback(undefined);
76530
- } else {
76531
- callback(formatPatch(patchObj, options.headerOptions));
76532
- }
76533
- } }));
76534
- }
76535
- }
76536
- function splitLines(text) {
76537
- const hasTrailingNl = text.endsWith(`
76538
- `);
76539
- const result = text.split(`
76540
- `).map((line) => line + `
76541
- `);
76542
- if (hasTrailingNl) {
76543
- result.pop();
76544
- } else {
76545
- result.push(result.pop().slice(0, -1));
76546
- }
76547
- return result;
76548
- }
76549
77044
  // src/tools/hashline-edit/diff-utils.ts
76550
77045
  function generateUnifiedDiff(oldContent, newContent, filePath) {
76551
77046
  return createTwoFilesPatch(filePath, filePath, oldContent, newContent, undefined, undefined, { context: 3 });
@@ -77872,7 +78367,7 @@ function unregisterManagerForCleanup(manager) {
77872
78367
  }
77873
78368
 
77874
78369
  // src/features/background-agent/compaction-aware-message-resolver.ts
77875
- import { readdirSync as readdirSync22, readFileSync as readFileSync48 } from "fs";
78370
+ import { readdirSync as readdirSync22, readFileSync as readFileSync49 } from "fs";
77876
78371
  import { join as join82 } from "path";
77877
78372
  function isCompactionAgent3(agent) {
77878
78373
  return agent?.trim().toLowerCase() === "compaction";
@@ -77892,13 +78387,14 @@ function convertSessionMessageToStoredMessage(message) {
77892
78387
  }
77893
78388
  const providerID = info.model?.providerID ?? info.providerID;
77894
78389
  const modelID = info.model?.modelID ?? info.modelID;
78390
+ const variant = info.model?.variant ?? info.variant;
77895
78391
  return {
77896
78392
  ...info.agent ? { agent: info.agent } : {},
77897
78393
  ...providerID && modelID ? {
77898
78394
  model: {
77899
78395
  providerID,
77900
78396
  modelID,
77901
- ...info.model?.variant ? { variant: info.model.variant } : {}
78397
+ ...variant ? { variant } : {}
77902
78398
  }
77903
78399
  } : {},
77904
78400
  ...info.tools ? { tools: info.tools } : {}
@@ -77952,7 +78448,7 @@ function findNearestMessageExcludingCompaction(messageDir, sessionID) {
77952
78448
  const messages = [];
77953
78449
  for (const file3 of files) {
77954
78450
  try {
77955
- const content = readFileSync48(join82(messageDir, file3), "utf-8");
78451
+ const content = readFileSync49(join82(messageDir, file3), "utf-8");
77956
78452
  messages.push(JSON.parse(content));
77957
78453
  } catch {
77958
78454
  continue;
@@ -78516,8 +79012,12 @@ class BackgroundManager {
78516
79012
  path: { id: sessionID },
78517
79013
  body: {
78518
79014
  agent: input.agent,
78519
- ...launchModel ? { model: launchModel } : {},
78520
- ...launchVariant ? { variant: launchVariant } : {},
79015
+ ...launchModel || launchVariant ? {
79016
+ model: {
79017
+ ...launchModel ?? {},
79018
+ ...launchVariant ? { variant: launchVariant } : {}
79019
+ }
79020
+ } : {},
78521
79021
  system: input.skillContent,
78522
79022
  tools: (() => {
78523
79023
  const tools = {
@@ -78724,12 +79224,16 @@ class BackgroundManager {
78724
79224
  });
78725
79225
  const resumeModel = existingTask.model ? { providerID: existingTask.model.providerID, modelID: existingTask.model.modelID } : undefined;
78726
79226
  const resumeVariant = existingTask.model?.variant;
78727
- this.client.session.promptAsync({
79227
+ promptWithModelSuggestionRetry(this.client, {
78728
79228
  path: { id: existingTask.sessionID },
78729
79229
  body: {
78730
79230
  agent: existingTask.agent,
78731
- ...resumeModel ? { model: resumeModel } : {},
78732
- ...resumeVariant ? { variant: resumeVariant } : {},
79231
+ ...resumeModel || resumeVariant ? {
79232
+ model: {
79233
+ ...resumeModel ?? {},
79234
+ ...resumeVariant ? { variant: resumeVariant } : {}
79235
+ }
79236
+ } : {},
78733
79237
  tools: (() => {
78734
79238
  const tools = {
78735
79239
  task: false,
@@ -83407,7 +83911,7 @@ class StreamableHTTPClientTransport {
83407
83911
  }
83408
83912
 
83409
83913
  // src/features/mcp-oauth/storage.ts
83410
- 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";
83411
83915
  import { dirname as dirname22, join as join84 } from "path";
83412
83916
  var STORAGE_FILE_NAME = "mcp-oauth.json";
83413
83917
  function getMcpOauthStoragePath() {
@@ -83448,11 +83952,11 @@ function buildKey(serverHost, resource) {
83448
83952
  }
83449
83953
  function readStore() {
83450
83954
  const filePath = getMcpOauthStoragePath();
83451
- if (!existsSync73(filePath)) {
83955
+ if (!existsSync74(filePath)) {
83452
83956
  return null;
83453
83957
  }
83454
83958
  try {
83455
- const content = readFileSync49(filePath, "utf-8");
83959
+ const content = readFileSync50(filePath, "utf-8");
83456
83960
  return JSON.parse(content);
83457
83961
  } catch {
83458
83962
  return null;
@@ -83462,7 +83966,7 @@ function writeStore(store2) {
83462
83966
  const filePath = getMcpOauthStoragePath();
83463
83967
  try {
83464
83968
  const dir = dirname22(filePath);
83465
- if (!existsSync73(dir)) {
83969
+ if (!existsSync74(dir)) {
83466
83970
  mkdirSync15(dir, { recursive: true });
83467
83971
  }
83468
83972
  writeFileSync21(filePath, JSON.stringify(store2, null, 2), { encoding: "utf-8", mode: 384 });
@@ -91372,7 +91876,7 @@ function createGptcoderAgent2(model, availableAgents, availableToolNames, availa
91372
91876
  }
91373
91877
  createGptcoderAgent2.mode = MODE10;
91374
91878
  // src/agents/builtin-agents/resolve-file-uri.ts
91375
- import { existsSync as existsSync74, readFileSync as readFileSync50 } from "fs";
91879
+ import { existsSync as existsSync75, readFileSync as readFileSync51 } from "fs";
91376
91880
  import { homedir as homedir14 } from "os";
91377
91881
  import { isAbsolute as isAbsolute10, resolve as resolve16 } from "path";
91378
91882
  function resolvePromptAppend(promptAppend, configDir) {
@@ -91387,11 +91891,11 @@ function resolvePromptAppend(promptAppend, configDir) {
91387
91891
  } catch {
91388
91892
  return `[WARNING: Malformed file URI (invalid percent-encoding): ${promptAppend}]`;
91389
91893
  }
91390
- if (!existsSync74(filePath)) {
91894
+ if (!existsSync75(filePath)) {
91391
91895
  return `[WARNING: Could not resolve file URI: ${promptAppend}]`;
91392
91896
  }
91393
91897
  try {
91394
- return readFileSync50(filePath, "utf8");
91898
+ return readFileSync51(filePath, "utf8");
91395
91899
  } catch {
91396
91900
  return `[WARNING: Could not read file: ${promptAppend}]`;
91397
91901
  }
@@ -93212,7 +93716,7 @@ async function createBuiltinAgents(disabledAgents = [], agentOverrides = {}, dir
93212
93716
  return result;
93213
93717
  }
93214
93718
  // src/features/claude-code-agent-loader/loader.ts
93215
- 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";
93216
93720
  import { join as join85, basename as basename10 } from "path";
93217
93721
  function parseToolsConfig2(toolsStr) {
93218
93722
  if (!toolsStr)
@@ -93227,7 +93731,7 @@ function parseToolsConfig2(toolsStr) {
93227
93731
  return result;
93228
93732
  }
93229
93733
  function loadAgentsFromDir(agentsDir, scope) {
93230
- if (!existsSync75(agentsDir)) {
93734
+ if (!existsSync76(agentsDir)) {
93231
93735
  return [];
93232
93736
  }
93233
93737
  const entries = readdirSync23(agentsDir, { withFileTypes: true });
@@ -93238,7 +93742,7 @@ function loadAgentsFromDir(agentsDir, scope) {
93238
93742
  const agentPath = join85(agentsDir, entry.name);
93239
93743
  const agentName = basename10(entry.name, ".md");
93240
93744
  try {
93241
- const content = readFileSync51(agentPath, "utf-8");
93745
+ const content = readFileSync52(agentPath, "utf-8");
93242
93746
  const { data, body } = parseFrontmatter(content);
93243
93747
  const name = data.name || agentName;
93244
93748
  const originalDescription = data.description || "";
@@ -95874,7 +96378,7 @@ function remapCommandAgentFields(commands3) {
95874
96378
  }
95875
96379
  }
95876
96380
  // src/features/claude-code-mcp-loader/loader.ts
95877
- import { existsSync as existsSync76, readFileSync as readFileSync52 } from "fs";
96381
+ import { existsSync as existsSync77, readFileSync as readFileSync53 } from "fs";
95878
96382
  import { join as join87 } from "path";
95879
96383
  import { homedir as homedir15 } from "os";
95880
96384
  init_logger();
@@ -95889,7 +96393,7 @@ function getMcpConfigPaths() {
95889
96393
  ];
95890
96394
  }
95891
96395
  async function loadMcpConfigFile(filePath) {
95892
- if (!existsSync76(filePath)) {
96396
+ if (!existsSync77(filePath)) {
95893
96397
  return null;
95894
96398
  }
95895
96399
  try {
@@ -95904,10 +96408,10 @@ function getSystemMcpServerNames() {
95904
96408
  const names = new Set;
95905
96409
  const paths = getMcpConfigPaths();
95906
96410
  for (const { path: path12 } of paths) {
95907
- if (!existsSync76(path12))
96411
+ if (!existsSync77(path12))
95908
96412
  continue;
95909
96413
  try {
95910
- const content = readFileSync52(path12, "utf-8");
96414
+ const content = readFileSync53(path12, "utf-8");
95911
96415
  const config4 = JSON.parse(content);
95912
96416
  if (!config4?.mcpServers)
95913
96417
  continue;
@@ -96587,7 +97091,7 @@ function buildChatParamsInput(raw) {
96587
97091
  const providerID = model.providerID;
96588
97092
  const modelID = model.modelID;
96589
97093
  const providerId = provider.id;
96590
- const variant = message.variant;
97094
+ const variant = getUserMessageVariant(message);
96591
97095
  if (typeof providerID !== "string")
96592
97096
  return null;
96593
97097
  if (typeof modelID !== "string")
@@ -96599,7 +97103,7 @@ function buildChatParamsInput(raw) {
96599
97103
  agent: { name: agentName },
96600
97104
  model: { providerID, modelID },
96601
97105
  provider: { id: providerId },
96602
- message: typeof variant === "string" ? { variant } : {}
97106
+ message: typeof variant === "string" ? { model: { variant } } : {}
96603
97107
  };
96604
97108
  }
96605
97109
  function isChatParamsOutput(raw) {
@@ -96728,7 +97232,7 @@ function createChatHeadersHandler(args) {
96728
97232
  // src/plugin/ultrawork-db-model-override.ts
96729
97233
  import { Database } from "bun:sqlite";
96730
97234
  import { join as join88 } from "path";
96731
- import { existsSync as existsSync77 } from "fs";
97235
+ import { existsSync as existsSync78 } from "fs";
96732
97236
  function getDbPath() {
96733
97237
  return join88(getDataDir(), "opencode", "opencode.db");
96734
97238
  }
@@ -96739,7 +97243,7 @@ function tryUpdateMessageModel(db, messageId, targetModel, variant) {
96739
97243
  if (result.changes === 0)
96740
97244
  return false;
96741
97245
  if (variant) {
96742
- 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);
96743
97247
  }
96744
97248
  return true;
96745
97249
  }
@@ -96807,7 +97311,7 @@ function retryViaMicrotask(db, messageId, targetModel, variant, attempt) {
96807
97311
  function scheduleDeferredModelOverride(messageId, targetModel, variant) {
96808
97312
  queueMicrotask(() => {
96809
97313
  const dbPath = getDbPath();
96810
- if (!existsSync77(dbPath)) {
97314
+ if (!existsSync78(dbPath)) {
96811
97315
  log("[ultrawork-db-override] DB not found, skipping deferred override");
96812
97316
  return;
96813
97317
  }
@@ -96915,7 +97419,7 @@ function resolveUltraworkOverride(pluginConfig, inputAgentName, output, sessionI
96915
97419
  function applyResolvedUltraworkOverride(args) {
96916
97420
  const { override, validatedVariant, output, inputAgentName, tui } = args;
96917
97421
  if (validatedVariant) {
96918
- output.message["variant"] = validatedVariant;
97422
+ setUserMessageVariant(output.message, validatedVariant);
96919
97423
  output.message["thinking"] = validatedVariant;
96920
97424
  }
96921
97425
  if (!override.providerID || !override.modelID)
@@ -96928,7 +97432,7 @@ function applyResolvedUltraworkOverride(args) {
96928
97432
  const messageId = output.message["id"];
96929
97433
  if (!messageId) {
96930
97434
  log("[ultrawork-model-override] No message ID found, falling back to direct mutation");
96931
- output.message.model = targetModel;
97435
+ output.message.model = validatedVariant ? { ...targetModel, variant: validatedVariant } : targetModel;
96932
97436
  return;
96933
97437
  }
96934
97438
  const fromModel = output.message.model?.modelID ?? "unknown";