reasonix 0.48.0 → 0.48.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/README.md +9 -0
  2. package/dist/cli/{acp-4ROCGYNH.js → acp-QJGGHQLA.js} +52 -135
  3. package/dist/cli/acp-QJGGHQLA.js.map +1 -0
  4. package/dist/cli/{chat-GZNB5625.js → chat-ZXF227MP.js} +23 -23
  5. package/dist/cli/{chunk-JMDE6IO3.js → chunk-3FULTFRB.js} +2 -2
  6. package/dist/cli/{chunk-7M4YYMKW.js → chunk-43ROGEX2.js} +47 -55
  7. package/dist/cli/{chunk-7M4YYMKW.js.map → chunk-43ROGEX2.js.map} +1 -1
  8. package/dist/cli/{chunk-3WGTGXO4.js → chunk-4E2BHJU4.js} +4 -4
  9. package/dist/cli/chunk-4E2BHJU4.js.map +1 -0
  10. package/dist/cli/{chunk-HR5NBKEM.js → chunk-5AW6NIHU.js} +2 -2
  11. package/dist/cli/{chunk-TE5UIIFL.js → chunk-5U5LMMFF.js} +2 -2
  12. package/dist/cli/{chunk-WZGNXR6E.js → chunk-6FRNXWDZ.js} +320 -75
  13. package/dist/cli/chunk-6FRNXWDZ.js.map +1 -0
  14. package/dist/cli/{chunk-6MZTZO7A.js → chunk-DABAOQSV.js} +1826 -1793
  15. package/dist/cli/chunk-DABAOQSV.js.map +1 -0
  16. package/dist/cli/{chunk-EMMENC4O.js → chunk-EO6RPTJG.js} +5 -5
  17. package/dist/cli/{chunk-2QSTA2QV.js → chunk-FD7SNDWW.js} +3 -3
  18. package/dist/cli/{chunk-CDVSFSAK.js → chunk-FPME5QOO.js} +19 -4
  19. package/dist/cli/chunk-FPME5QOO.js.map +1 -0
  20. package/dist/cli/{chunk-5OHHAQ4W.js → chunk-H2F4LDNH.js} +2 -2
  21. package/dist/cli/{chunk-OG5JANQ4.js → chunk-IKSYVBBZ.js} +2 -2
  22. package/dist/cli/{chunk-OPYALNTT.js → chunk-JFBGSWQB.js} +77 -38
  23. package/dist/cli/chunk-JFBGSWQB.js.map +1 -0
  24. package/dist/cli/{chunk-RUDBUHO4.js → chunk-KH5JIJJD.js} +2 -2
  25. package/dist/cli/{chunk-H4CCXMDD.js → chunk-NQZ5U37J.js} +2 -2
  26. package/dist/cli/{chunk-I4M5QJNL.js → chunk-O3AGYTG2.js} +2 -2
  27. package/dist/cli/{chunk-YW63N3ZR.js → chunk-PIC5HJRD.js} +124 -18
  28. package/dist/cli/chunk-PIC5HJRD.js.map +1 -0
  29. package/dist/cli/{chunk-NMQSUNLB.js → chunk-PJIQIYTV.js} +6 -3
  30. package/dist/cli/chunk-PJIQIYTV.js.map +1 -0
  31. package/dist/cli/{chunk-V4Y732RQ.js → chunk-R7U44O3Y.js} +2 -2
  32. package/dist/cli/{chunk-OB4BUJBL.js → chunk-RCLS63KE.js} +5 -2
  33. package/dist/cli/chunk-RCLS63KE.js.map +1 -0
  34. package/dist/cli/{chunk-FY4S7TJZ.js → chunk-SLAFMXAZ.js} +10 -2
  35. package/dist/cli/chunk-SLAFMXAZ.js.map +1 -0
  36. package/dist/cli/{chunk-DOWEOA6E.js → chunk-SWUMD2LX.js} +2 -2
  37. package/dist/cli/{chunk-S2RMQULY.js → chunk-TIJ4ZHD6.js} +7 -7
  38. package/dist/cli/{chunk-MOJYKO2A.js → chunk-WKOXKCF3.js} +3 -3
  39. package/dist/cli/{chunk-MRZG4GBF.js → chunk-XMR2VCGT.js} +3 -3
  40. package/dist/cli/{code-PMPJWXEO.js → code-OKA5YPOH.js} +26 -26
  41. package/dist/cli/{commands-QS6TG4G3.js → commands-3U6PUVSS.js} +4 -4
  42. package/dist/cli/{commit-XPRSKUBF.js → commit-HFB7SRBU.js} +3 -3
  43. package/dist/cli/{desktop-562OPWIU.js → desktop-G7UMW3CJ.js} +60 -23
  44. package/dist/cli/desktop-G7UMW3CJ.js.map +1 -0
  45. package/dist/cli/{diff-I6W4AUWJ.js → diff-PGXW4YZD.js} +8 -8
  46. package/dist/cli/{doctor-6XVZKT4U.js → doctor-WWJFLVCB.js} +8 -8
  47. package/dist/cli/index.js +33 -33
  48. package/dist/cli/{mcp-7W7ANO2Y.js → mcp-Y3VKIK3T.js} +2 -2
  49. package/dist/cli/{mcp-browse-LA4I4YIZ.js → mcp-browse-4IN2QIFR.js} +2 -2
  50. package/dist/cli/{mcp-inspect-LWXXU7BY.js → mcp-inspect-BUXFXDHB.js} +2 -2
  51. package/dist/cli/{prompt-RKZD4X6Y.js → prompt-US57R6BA.js} +5 -4
  52. package/dist/cli/{replay-2X7MVXOI.js → replay-EQJMZRB3.js} +8 -8
  53. package/dist/cli/{run-TPKXIJ27.js → run-KVEI66TR.js} +14 -14
  54. package/dist/cli/{server-NHQ3QXOZ.js → server-D6C4GHWN.js} +13 -11
  55. package/dist/cli/server-D6C4GHWN.js.map +1 -0
  56. package/dist/cli/{sessions-2A4DGSHA.js → sessions-TGVS2RQZ.js} +13 -13
  57. package/dist/cli/{setup-GOLP7J4C.js → setup-WLKX6GGG.js} +5 -5
  58. package/dist/cli/{stats-CGDAFDKI.js → stats-TCD7Q6MB.js} +6 -6
  59. package/dist/cli/{version-FIL4ZFOS.js → version-BCWWS2OU.js} +13 -13
  60. package/dist/index.d.ts +8 -2
  61. package/dist/index.js +200 -46
  62. package/dist/index.js.map +1 -1
  63. package/package.json +5 -2
  64. package/dist/cli/acp-4ROCGYNH.js.map +0 -1
  65. package/dist/cli/chunk-3WGTGXO4.js.map +0 -1
  66. package/dist/cli/chunk-6MZTZO7A.js.map +0 -1
  67. package/dist/cli/chunk-CDVSFSAK.js.map +0 -1
  68. package/dist/cli/chunk-FY4S7TJZ.js.map +0 -1
  69. package/dist/cli/chunk-NMQSUNLB.js.map +0 -1
  70. package/dist/cli/chunk-OB4BUJBL.js.map +0 -1
  71. package/dist/cli/chunk-OPYALNTT.js.map +0 -1
  72. package/dist/cli/chunk-WZGNXR6E.js.map +0 -1
  73. package/dist/cli/chunk-YW63N3ZR.js.map +0 -1
  74. package/dist/cli/desktop-562OPWIU.js.map +0 -1
  75. package/dist/cli/server-NHQ3QXOZ.js.map +0 -1
  76. /package/dist/cli/{chat-GZNB5625.js.map → chat-ZXF227MP.js.map} +0 -0
  77. /package/dist/cli/{chunk-JMDE6IO3.js.map → chunk-3FULTFRB.js.map} +0 -0
  78. /package/dist/cli/{chunk-HR5NBKEM.js.map → chunk-5AW6NIHU.js.map} +0 -0
  79. /package/dist/cli/{chunk-TE5UIIFL.js.map → chunk-5U5LMMFF.js.map} +0 -0
  80. /package/dist/cli/{chunk-EMMENC4O.js.map → chunk-EO6RPTJG.js.map} +0 -0
  81. /package/dist/cli/{chunk-2QSTA2QV.js.map → chunk-FD7SNDWW.js.map} +0 -0
  82. /package/dist/cli/{chunk-5OHHAQ4W.js.map → chunk-H2F4LDNH.js.map} +0 -0
  83. /package/dist/cli/{chunk-OG5JANQ4.js.map → chunk-IKSYVBBZ.js.map} +0 -0
  84. /package/dist/cli/{chunk-RUDBUHO4.js.map → chunk-KH5JIJJD.js.map} +0 -0
  85. /package/dist/cli/{chunk-H4CCXMDD.js.map → chunk-NQZ5U37J.js.map} +0 -0
  86. /package/dist/cli/{chunk-I4M5QJNL.js.map → chunk-O3AGYTG2.js.map} +0 -0
  87. /package/dist/cli/{chunk-V4Y732RQ.js.map → chunk-R7U44O3Y.js.map} +0 -0
  88. /package/dist/cli/{chunk-DOWEOA6E.js.map → chunk-SWUMD2LX.js.map} +0 -0
  89. /package/dist/cli/{chunk-S2RMQULY.js.map → chunk-TIJ4ZHD6.js.map} +0 -0
  90. /package/dist/cli/{chunk-MOJYKO2A.js.map → chunk-WKOXKCF3.js.map} +0 -0
  91. /package/dist/cli/{chunk-MRZG4GBF.js.map → chunk-XMR2VCGT.js.map} +0 -0
  92. /package/dist/cli/{code-PMPJWXEO.js.map → code-OKA5YPOH.js.map} +0 -0
  93. /package/dist/cli/{commands-QS6TG4G3.js.map → commands-3U6PUVSS.js.map} +0 -0
  94. /package/dist/cli/{commit-XPRSKUBF.js.map → commit-HFB7SRBU.js.map} +0 -0
  95. /package/dist/cli/{diff-I6W4AUWJ.js.map → diff-PGXW4YZD.js.map} +0 -0
  96. /package/dist/cli/{doctor-6XVZKT4U.js.map → doctor-WWJFLVCB.js.map} +0 -0
  97. /package/dist/cli/{mcp-7W7ANO2Y.js.map → mcp-Y3VKIK3T.js.map} +0 -0
  98. /package/dist/cli/{mcp-browse-LA4I4YIZ.js.map → mcp-browse-4IN2QIFR.js.map} +0 -0
  99. /package/dist/cli/{mcp-inspect-LWXXU7BY.js.map → mcp-inspect-BUXFXDHB.js.map} +0 -0
  100. /package/dist/cli/{prompt-RKZD4X6Y.js.map → prompt-US57R6BA.js.map} +0 -0
  101. /package/dist/cli/{replay-2X7MVXOI.js.map → replay-EQJMZRB3.js.map} +0 -0
  102. /package/dist/cli/{run-TPKXIJ27.js.map → run-KVEI66TR.js.map} +0 -0
  103. /package/dist/cli/{sessions-2A4DGSHA.js.map → sessions-TGVS2RQZ.js.map} +0 -0
  104. /package/dist/cli/{setup-GOLP7J4C.js.map → setup-WLKX6GGG.js.map} +0 -0
  105. /package/dist/cli/{stats-CGDAFDKI.js.map → stats-TCD7Q6MB.js.map} +0 -0
  106. /package/dist/cli/{version-FIL4ZFOS.js.map → version-BCWWS2OU.js.map} +0 -0
@@ -2,7 +2,7 @@
2
2
  import { createRequire as __cr } from 'node:module'; if (typeof globalThis.require === 'undefined') { globalThis.require = __cr(import.meta.url); }
3
3
  import {
4
4
  computeReplayStats
5
- } from "./chunk-MRZG4GBF.js";
5
+ } from "./chunk-XMR2VCGT.js";
6
6
 
7
7
  // src/transcript/diff.ts
8
8
  function findNextDivergence(pairs, fromIdx) {
@@ -305,4 +305,4 @@ export {
305
305
  renderSummaryTable,
306
306
  renderMarkdown
307
307
  };
308
- //# sourceMappingURL=chunk-5OHHAQ4W.js.map
308
+ //# sourceMappingURL=chunk-H2F4LDNH.js.map
@@ -2,7 +2,7 @@
2
2
  import { createRequire as __cr } from 'node:module'; if (typeof globalThis.require === 'undefined') { globalThis.require = __cr(import.meta.url); }
3
3
  import {
4
4
  loadPricingOverride
5
- } from "./chunk-CDVSFSAK.js";
5
+ } from "./chunk-FPME5QOO.js";
6
6
 
7
7
  // src/telemetry/stats.ts
8
8
  var DEEPSEEK_PRICING = {
@@ -160,4 +160,4 @@ export {
160
160
  claudeEquivalentCost,
161
161
  SessionStats
162
162
  };
163
- //# sourceMappingURL=chunk-OG5JANQ4.js.map
163
+ //# sourceMappingURL=chunk-IKSYVBBZ.js.map
@@ -3,7 +3,7 @@ import { createRequire as __cr } from 'node:module'; if (typeof globalThis.requi
3
3
  import {
4
4
  MemoryStore,
5
5
  sanitizeMemoryName
6
- } from "./chunk-2QSTA2QV.js";
6
+ } from "./chunk-FD7SNDWW.js";
7
7
  import {
8
8
  countTokens,
9
9
  countTokensBounded,
@@ -12,23 +12,23 @@ import {
12
12
  } from "./chunk-6OWJV3YW.js";
13
13
  import {
14
14
  Usage
15
- } from "./chunk-TE5UIIFL.js";
15
+ } from "./chunk-5U5LMMFF.js";
16
16
  import {
17
17
  applyEdit,
18
18
  applyMultiEdit,
19
19
  pauseGate
20
- } from "./chunk-WZGNXR6E.js";
20
+ } from "./chunk-6FRNXWDZ.js";
21
21
  import {
22
22
  NEGATIVE_CLAIM_RULE,
23
23
  PROJECT_MEMORY_FILES,
24
24
  PROJECT_MEMORY_MAX_CHARS,
25
25
  TUI_FORMATTING_RULES,
26
26
  memoryEnabled
27
- } from "./chunk-FY4S7TJZ.js";
27
+ } from "./chunk-SLAFMXAZ.js";
28
28
  import {
29
29
  formatHookOutcomeMessage,
30
30
  runHooks
31
- } from "./chunk-NMQSUNLB.js";
31
+ } from "./chunk-PJIQIYTV.js";
32
32
  import {
33
33
  ignoredByLayers,
34
34
  loadGitignoreAt,
@@ -46,10 +46,10 @@ import {
46
46
  DEEPSEEK_CONTEXT_TOKENS,
47
47
  DEFAULT_CONTEXT_TOKENS,
48
48
  SessionStats
49
- } from "./chunk-OG5JANQ4.js";
49
+ } from "./chunk-IKSYVBBZ.js";
50
50
  import {
51
51
  t
52
- } from "./chunk-YW63N3ZR.js";
52
+ } from "./chunk-PIC5HJRD.js";
53
53
  import {
54
54
  DEFAULT_INDEX_EXCLUDES,
55
55
  addProjectPathAllowed,
@@ -62,7 +62,7 @@ import {
62
62
  require_picomatch,
63
63
  webSearchEndpoint,
64
64
  webSearchEngine
65
- } from "./chunk-CDVSFSAK.js";
65
+ } from "./chunk-FPME5QOO.js";
66
66
  import {
67
67
  __commonJS,
68
68
  __esm,
@@ -2599,10 +2599,10 @@ var require_helpers = __commonJS({
2599
2599
  return !arr.includes(node, i + 1);
2600
2600
  });
2601
2601
  nodes.sort(function(a, b) {
2602
- var relative6 = compareDocumentPosition(a, b);
2603
- if (relative6 & DocumentPosition.PRECEDING) {
2602
+ var relative7 = compareDocumentPosition(a, b);
2603
+ if (relative7 & DocumentPosition.PRECEDING) {
2604
2604
  return -1;
2605
- } else if (relative6 & DocumentPosition.FOLLOWING) {
2605
+ } else if (relative7 & DocumentPosition.FOLLOWING) {
2606
2606
  return 1;
2607
2607
  }
2608
2608
  return 0;
@@ -6757,14 +6757,16 @@ function buildSyntheticAssistantMessage(content, fallbackModel) {
6757
6757
  }
6758
6758
 
6759
6759
  // src/context-manager.ts
6760
- var HISTORY_FOLD_THRESHOLD = 0.5;
6760
+ var HISTORY_FOLD_THRESHOLD = 0.75;
6761
6761
  var HISTORY_FOLD_TAIL_FRACTION = 0.2;
6762
- var HISTORY_FOLD_AGGRESSIVE_THRESHOLD = 0.7;
6762
+ var HISTORY_FOLD_AGGRESSIVE_THRESHOLD = 0.78;
6763
6763
  var HISTORY_FOLD_AGGRESSIVE_TAIL_FRACTION = 0.1;
6764
6764
  var HISTORY_FOLD_MIN_SAVINGS_FRACTION = 0.3;
6765
6765
  var FORCE_SUMMARY_THRESHOLD = 0.8;
6766
6766
  var PREFLIGHT_EMERGENCY_THRESHOLD = 0.95;
6767
6767
  var PREFLIGHT_MECHANICAL_TARGET_FRACTION = 0.7;
6768
+ var MAX_BODY_BYTES = 7e5;
6769
+ var MAX_BODY_BYTES_TARGET = 5e5;
6768
6770
  var HISTORY_FOLD_SUMMARY_TIMEOUT_MS = 15e3;
6769
6771
  var HISTORY_FOLD_MARKER = "[CONVERSATION HISTORY SUMMARY \u2014 earlier turns folded for context efficiency]\n\n";
6770
6772
  var SKILL_PIN_MEMO_HEADER = "[Active skill memos \u2014 preserved verbatim across the fold:]";
@@ -6831,14 +6833,25 @@ var ContextManager = class {
6831
6833
  }
6832
6834
  return { kind: "none", ...base };
6833
6835
  }
6834
- /** Local-side preflight before sending a request — catches oversized payloads early. */
6836
+ /** Local-side preflight before sending a request — catches oversized payloads early.
6837
+ * Two independent signals trip mechanical truncate: token estimate above the context-window
6838
+ * fraction, OR JSON body bytes above the gateway limit (see `MAX_BODY_BYTES`). */
6835
6839
  decidePreflight(messages, toolSpecs, model) {
6836
6840
  const ctxMax = DEEPSEEK_CONTEXT_TOKENS[model] ?? DEFAULT_CONTEXT_TOKENS;
6837
6841
  const estimate = estimateRequestTokens(messages, toolSpecs ?? null, true);
6842
+ const estimateBytes = Buffer.byteLength(JSON.stringify(messages), "utf8");
6843
+ const tokensOver = estimate / ctxMax > PREFLIGHT_EMERGENCY_THRESHOLD;
6844
+ const bytesOver = estimateBytes > MAX_BODY_BYTES;
6845
+ let trigger = "none";
6846
+ if (tokensOver && bytesOver) trigger = "both";
6847
+ else if (tokensOver) trigger = "tokens";
6848
+ else if (bytesOver) trigger = "bytes";
6838
6849
  return {
6839
- needsAction: estimate / ctxMax > PREFLIGHT_EMERGENCY_THRESHOLD,
6850
+ needsAction: tokensOver || bytesOver,
6840
6851
  estimateTokens: estimate,
6841
- ctxMax
6852
+ estimateBytes,
6853
+ ctxMax,
6854
+ trigger
6842
6855
  };
6843
6856
  }
6844
6857
  /** Replace older turns with one summary message; keep tail within keepRecentTokens budget. */
@@ -6891,10 +6904,13 @@ ${pinnedBodies.join("\n\n")}` : "";
6891
6904
  summaryChars: summary.content.length
6892
6905
  };
6893
6906
  }
6894
- /** Pure local emergency compaction for preflight: drop oldest log entries and keep a valid tail. */
6907
+ /** Pure local emergency compaction for preflight: drop oldest log entries and keep a valid tail.
6908
+ * Bounded by tokens AND bytes — bytes matter because DeepSeek's gateway 400s on bodies past
6909
+ * `MAX_BODY_BYTES` even when the token budget is far from exhausted. */
6895
6910
  mechanicalTruncate(model, opts) {
6896
6911
  const ctxMax = DEEPSEEK_CONTEXT_TOKENS[model] ?? DEFAULT_CONTEXT_TOKENS;
6897
6912
  const targetTokens = opts?.targetTokens ?? Math.floor(ctxMax * PREFLIGHT_MECHANICAL_TARGET_FRACTION);
6913
+ const targetBytes = opts?.targetBytes ?? MAX_BODY_BYTES_TARGET;
6898
6914
  const all = this.deps.log.toMessages();
6899
6915
  const noop = {
6900
6916
  folded: false,
@@ -6904,6 +6920,7 @@ ${pinnedBodies.join("\n\n")}` : "";
6904
6920
  };
6905
6921
  if (all.length === 0) return noop;
6906
6922
  const tokenCounts = all.map((m) => estimateConversationTokens([m], true));
6923
+ const byteCounts = all.map((m) => Buffer.byteLength(JSON.stringify(m), "utf8"));
6907
6924
  let latestUserBoundary = -1;
6908
6925
  for (let i = all.length - 1; i >= 0; i--) {
6909
6926
  if (all[i].role === "user") {
@@ -6912,12 +6929,15 @@ ${pinnedBodies.join("\n\n")}` : "";
6912
6929
  }
6913
6930
  }
6914
6931
  let cumTokens = 0;
6932
+ let cumBytes = 0;
6915
6933
  let boundary = all.length;
6916
6934
  let foundSafeBoundary = false;
6917
6935
  for (let i = all.length - 1; i >= 0; i--) {
6918
- const next = cumTokens + tokenCounts[i];
6919
- if (next > targetTokens) break;
6920
- cumTokens = next;
6936
+ const nextTokens = cumTokens + tokenCounts[i];
6937
+ const nextBytes = cumBytes + byteCounts[i];
6938
+ if (nextTokens > targetTokens || nextBytes > targetBytes) break;
6939
+ cumTokens = nextTokens;
6940
+ cumBytes = nextBytes;
6921
6941
  if (all[i].role === "user") {
6922
6942
  boundary = i;
6923
6943
  foundSafeBoundary = true;
@@ -8152,7 +8172,7 @@ ${reason}`
8152
8172
  {
8153
8173
  const decision2 = this.context.decidePreflight(messages, this.prefix.toolSpecs, this.model);
8154
8174
  if (decision2.needsAction) {
8155
- const { estimateTokens: estimate, ctxMax } = decision2;
8175
+ const { estimateTokens: estimate, estimateBytes, ctxMax } = decision2;
8156
8176
  yield {
8157
8177
  turn: this._turn,
8158
8178
  role: "status",
@@ -8174,6 +8194,7 @@ ${reason}`
8174
8194
  estimate: after.estimateTokens.toLocaleString(),
8175
8195
  ctxMax: after.ctxMax.toLocaleString(),
8176
8196
  pct: Math.round(after.estimateTokens / after.ctxMax * 100),
8197
+ bodyKB: Math.round(after.estimateBytes / 1024).toLocaleString(),
8177
8198
  beforeMessages: result.beforeMessages,
8178
8199
  afterMessages: result.afterMessages
8179
8200
  }
@@ -8186,7 +8207,8 @@ ${reason}`
8186
8207
  content: t("loop.preflightNoFold", {
8187
8208
  estimate: estimate.toLocaleString(),
8188
8209
  ctxMax: ctxMax.toLocaleString(),
8189
- pct: Math.round(estimate / ctxMax * 100)
8210
+ pct: Math.round(estimate / ctxMax * 100),
8211
+ bodyKB: Math.round(estimateBytes / 1024).toLocaleString()
8190
8212
  })
8191
8213
  };
8192
8214
  }
@@ -9444,6 +9466,7 @@ async function searchSearxng(query, opts = {}) {
9444
9466
  async function searchMetaso(query, opts = {}) {
9445
9467
  const topK = Math.max(1, Math.min(100, opts.topK ?? DEFAULT_TOPK));
9446
9468
  const apiKey = loadMetasoApiKey();
9469
+ if (!apiKey) throw new Error(t("webErrors.metasoMissingKey"));
9447
9470
  let resp;
9448
9471
  try {
9449
9472
  resp = await fetch(`${METASO_ENDPOINT}/search`, {
@@ -10596,8 +10619,8 @@ async function searchContent(ctx, startAbs, args) {
10596
10619
  for (let i = realStart; i <= winEnd; i++) {
10597
10620
  const line = lines[i];
10598
10621
  const display = line.length > 200 ? `${line.slice(0, 200)}\u2026` : line;
10599
- const sep2 = hitSet.has(i) ? ":" : "-";
10600
- if (!pushLine(`${rel}:${i + 1}${sep2} ${display}`)) return;
10622
+ const sep = hitSet.has(i) ? ":" : "-";
10623
+ if (!pushLine(`${rel}:${i + 1}${sep} ${display}`)) return;
10601
10624
  }
10602
10625
  prevWindowEnd = winEnd;
10603
10626
  }
@@ -12008,7 +12031,7 @@ import {
12008
12031
  writeFileSync,
12009
12032
  writeSync
12010
12033
  } from "fs";
12011
- import { dirname as dirname3, resolve as resolve4 } from "path";
12034
+ import { dirname as dirname3, isAbsolute as isAbsolute3, relative as relative6, resolve as resolve4 } from "path";
12012
12035
  var BLOCK_RE = /^(\S[^\n]*)\n<{7} SEARCH\n([\s\S]*?)\n?={7}\n([\s\S]*?)\n?>{7} REPLACE/gm;
12013
12036
  function parseEditBlocks(text) {
12014
12037
  const out = [];
@@ -12025,10 +12048,30 @@ function parseEditBlocks(text) {
12025
12048
  }
12026
12049
  return out;
12027
12050
  }
12051
+ function resolveEditPath(rootDir, rawPath) {
12052
+ const absRoot = resolve4(rootDir);
12053
+ if (/^[A-Za-z]:[\\/]/.test(rawPath) || looksLikeAbsoluteSystemPath2(rawPath)) {
12054
+ return resolve4(rawPath);
12055
+ }
12056
+ let rooted = rawPath;
12057
+ while (rooted.startsWith("/") || rooted.startsWith("\\")) {
12058
+ rooted = rooted.slice(1);
12059
+ }
12060
+ return resolve4(absRoot, rooted || ".");
12061
+ }
12062
+ function looksLikeAbsoluteSystemPath2(rawPath) {
12063
+ return /^\/(?:home|Users|etc|var|opt|tmp|usr|mnt|Library|Volumes|proc|sys|dev|run|srv|media|Applications|System|root|boot|private)(?:[/\\]|$)/.test(
12064
+ rawPath
12065
+ );
12066
+ }
12067
+ function pathIsUnder2(child, parent) {
12068
+ const rel = relative6(parent, child);
12069
+ return rel === "" || !rel.startsWith("..") && !isAbsolute3(rel);
12070
+ }
12028
12071
  function applyEditBlock(block, rootDir) {
12029
12072
  const absRoot = resolve4(rootDir);
12030
- const absTarget = resolve4(absRoot, block.path);
12031
- if (absTarget !== absRoot && !absTarget.startsWith(`${absRoot}${sep()}`)) {
12073
+ const absTarget = resolveEditPath(rootDir, block.path);
12074
+ if (!pathIsUnder2(absTarget, absRoot)) {
12032
12075
  return {
12033
12076
  path: block.path,
12034
12077
  status: "path-escape",
@@ -12122,7 +12165,7 @@ function applyEditBlocks(blocks, rootDir) {
12122
12165
  return blocks.map((b) => applyEditBlock(b, rootDir));
12123
12166
  }
12124
12167
  function toWholeFileEditBlock(path, content, rootDir) {
12125
- const abs = resolve4(rootDir, path);
12168
+ const abs = resolveEditPath(rootDir, path);
12126
12169
  let search = "";
12127
12170
  if (existsSync3(abs)) {
12128
12171
  try {
@@ -12134,13 +12177,12 @@ function toWholeFileEditBlock(path, content, rootDir) {
12134
12177
  return { path, search, replace: content, offset: 0 };
12135
12178
  }
12136
12179
  function snapshotBeforeEdits(blocks, rootDir) {
12137
- const absRoot = resolve4(rootDir);
12138
12180
  const seen = /* @__PURE__ */ new Set();
12139
12181
  const snapshots = [];
12140
12182
  for (const b of blocks) {
12141
- if (seen.has(b.path)) continue;
12142
- seen.add(b.path);
12143
- const abs = resolve4(absRoot, b.path);
12183
+ const abs = resolveEditPath(rootDir, b.path);
12184
+ if (seen.has(abs)) continue;
12185
+ seen.add(abs);
12144
12186
  if (!existsSync3(abs)) {
12145
12187
  snapshots.push({ path: b.path, prevContent: null });
12146
12188
  continue;
@@ -12156,8 +12198,8 @@ function snapshotBeforeEdits(blocks, rootDir) {
12156
12198
  function restoreSnapshots(snapshots, rootDir) {
12157
12199
  const absRoot = resolve4(rootDir);
12158
12200
  return snapshots.map((snap) => {
12159
- const abs = resolve4(absRoot, snap.path);
12160
- if (abs !== absRoot && !abs.startsWith(`${absRoot}${sep()}`)) {
12201
+ const abs = resolveEditPath(rootDir, snap.path);
12202
+ if (!pathIsUnder2(abs, absRoot)) {
12161
12203
  return {
12162
12204
  path: snap.path,
12163
12205
  status: "path-escape",
@@ -12184,9 +12226,6 @@ function restoreSnapshots(snapshots, rootDir) {
12184
12226
  }
12185
12227
  });
12186
12228
  }
12187
- function sep() {
12188
- return process.platform === "win32" ? "\\" : "/";
12189
- }
12190
12229
  function lineEndingOf(text) {
12191
12230
  return text.includes("\r\n") ? "\r\n" : "\n";
12192
12231
  }
@@ -12228,4 +12267,4 @@ export {
12228
12267
  he/he.js:
12229
12268
  (*! https://mths.be/he v1.2.0 by @mathias | MIT license *)
12230
12269
  */
12231
- //# sourceMappingURL=chunk-OPYALNTT.js.map
12270
+ //# sourceMappingURL=chunk-JFBGSWQB.js.map