@poe-platform/safe-bash 0.1.801 → 0.1.803

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 (198) hide show
  1. package/README.md +4 -2
  2. package/dist/image-ast/index.browser.js +16 -5
  3. package/dist/image-ast/index.js +16 -5
  4. package/dist/safe-bash/chunks/chunk-2LSAMQER.js +84 -0
  5. package/dist/safe-bash/chunks/chunk-3HQU4OJO.js +13 -0
  6. package/dist/safe-bash/chunks/chunk-4BSJLKNM.js +14 -0
  7. package/dist/safe-bash/chunks/chunk-4D4N7IU2.js +47 -0
  8. package/dist/safe-bash/chunks/chunk-55YJASTN.js +14 -0
  9. package/dist/safe-bash/chunks/{chunk-NZQXYWA3.js → chunk-5OHX7C2V.js} +0 -1
  10. package/dist/safe-bash/chunks/chunk-7ZBU7KYV.js +14 -0
  11. package/dist/safe-bash/chunks/{chunk-7VNF5BFF.js → chunk-B7PIL77G.js} +101 -415
  12. package/dist/safe-bash/chunks/chunk-DQP3VHSB.js +15 -0
  13. package/dist/safe-bash/chunks/{chunk-VQDD3G76.js → chunk-EEEWOYEG.js} +18 -18
  14. package/dist/safe-bash/chunks/chunk-FZE4HW6G.js +11 -0
  15. package/dist/safe-bash/chunks/{chunk-45PK3NWI.js → chunk-GDYNCWRV.js} +1 -1
  16. package/dist/safe-bash/chunks/chunk-GEG3BWGE.js +14 -0
  17. package/dist/safe-bash/chunks/chunk-HBCN24ZA.js +50 -0
  18. package/dist/safe-bash/chunks/chunk-HZ7BWKQ3.js +13 -0
  19. package/dist/safe-bash/chunks/{chunk-ICFDYV64.js → chunk-HZAMGT5I.js} +2 -2
  20. package/dist/safe-bash/chunks/{chunk-FNDNHAGE.js → chunk-JMMEIDPF.js} +2 -2
  21. package/dist/safe-bash/chunks/{chunk-IVRQ4BXL.js → chunk-PH63PLPZ.js} +7 -7
  22. package/dist/safe-bash/chunks/{chunk-SZH7EJLD.js → chunk-PNBBUWSM.js} +5529 -6547
  23. package/dist/safe-bash/chunks/chunk-QGUV42T5.js +44 -0
  24. package/dist/safe-bash/chunks/chunk-R3NAKOED.js +51 -0
  25. package/dist/safe-bash/chunks/chunk-RRR7AQ24.js +38 -0
  26. package/dist/safe-bash/chunks/{chunk-PQRAK7HU.js → chunk-RYFQ3LZG.js} +281 -476
  27. package/dist/safe-bash/chunks/chunk-VBTDHOWC.js +55 -0
  28. package/dist/safe-bash/chunks/{chunk-NR3EM4LS.js → chunk-VKNVHEX3.js} +1 -6
  29. package/dist/safe-bash/chunks/chunk-XAQMU6OY.js +14 -0
  30. package/dist/safe-bash/chunks/chunk-ZVD5IS4V.js +49 -0
  31. package/dist/safe-bash/command-chunks/{chunk-ORYGZYKW.js → chunk-4FEVBOL5.js} +1 -1
  32. package/dist/safe-bash/command-chunks/{chunk-VXSLJH7G.js → chunk-6JSIFWYT.js} +26 -6
  33. package/dist/safe-bash/command-chunks/chunk-A7MU7762.js +200 -0
  34. package/dist/safe-bash/command-chunks/{chunk-KJIMDLBB.js → chunk-BXCXRYVU.js} +1 -1
  35. package/dist/safe-bash/command-chunks/{chunk-F4TEEZTL.js → chunk-CQHP3I66.js} +1 -1
  36. package/dist/safe-bash/command-chunks/{chunk-PEF7K3UQ.js → chunk-EARHPPPJ.js} +1 -1
  37. package/dist/safe-bash/command-chunks/{chunk-QKFSRZGQ.js → chunk-GFC2NTDG.js} +2 -2
  38. package/dist/safe-bash/command-chunks/chunk-GIRNFXP3.js +466 -0
  39. package/dist/safe-bash/command-chunks/{chunk-EFANWIHL.js → chunk-GY3BWK7K.js} +1 -0
  40. package/dist/safe-bash/command-chunks/{chunk-FPVUD6TH.js → chunk-HDCNKOIX.js} +9 -7
  41. package/dist/safe-bash/command-chunks/{chunk-MQFIPHIQ.js → chunk-ILX2NOLF.js} +18 -15
  42. package/dist/safe-bash/command-chunks/{chunk-5E4WAO4O.js → chunk-JD5QNRNO.js} +3 -3
  43. package/dist/safe-bash/command-chunks/{chunk-I237SNW5.js → chunk-LFJJQQND.js} +1 -1
  44. package/dist/safe-bash/command-chunks/{chunk-W5DNF4JH.js → chunk-LOICUCHG.js} +1 -1
  45. package/dist/safe-bash/command-chunks/{chunk-7U7EXOXX.js → chunk-NASVPT6F.js} +2 -1
  46. package/dist/safe-bash/command-chunks/{chunk-WBNZ4PRE.js → chunk-NGG2XL56.js} +7 -4
  47. package/dist/safe-bash/command-chunks/{chunk-GLOZX57Y.js → chunk-NKIELG7Y.js} +45 -115
  48. package/dist/safe-bash/command-chunks/{chunk-WPYIOKE3.js → chunk-PICVQ6B5.js} +2 -2
  49. package/dist/safe-bash/command-chunks/{chunk-YOFC45RK.js → chunk-QVOS4YXL.js} +1 -1
  50. package/dist/safe-bash/command-chunks/{chunk-VGG2DL5Q.js → chunk-TRR4MYWF.js} +4 -0
  51. package/dist/safe-bash/command-chunks/{chunk-2JRBIDAD.js → chunk-V4K2JDYU.js} +2 -2
  52. package/dist/safe-bash/command-chunks/{chunk-CZ7EN3JG.js → chunk-VT6MJBEI.js} +1 -1
  53. package/dist/safe-bash/command-chunks/{chunk-PCEFOYA3.js → chunk-WWIBP2ET.js} +41 -114
  54. package/dist/safe-bash/command-chunks/{chunk-F6OYH562.js → chunk-X54L3DBL.js} +4 -9
  55. package/dist/safe-bash/command-chunks/{chunk-TNOA7FCQ.js → chunk-YVNGTIJO.js} +1 -1
  56. package/dist/safe-bash/command-chunks/chunk-ZDN7MJE6.js +168 -0
  57. package/dist/safe-bash/commands/apply-patch/index.browser.js +14 -0
  58. package/dist/safe-bash/commands/archive/index.browser.js +36 -0
  59. package/dist/safe-bash/commands/bytes/compression/index.js +54 -51
  60. package/dist/safe-bash/commands/chmod/index.browser.js +14 -0
  61. package/dist/safe-bash/commands/chmod/index.d.ts +2 -0
  62. package/dist/safe-bash/commands/chmod/index.js +2 -0
  63. package/dist/safe-bash/commands/column/index.browser.js +12 -0
  64. package/dist/safe-bash/commands/du/index.browser.js +14 -0
  65. package/dist/safe-bash/commands/expr/index.browser.js +12 -0
  66. package/dist/safe-bash/commands/file/index.browser.js +14 -0
  67. package/dist/safe-bash/commands/filesystem.js +9 -2
  68. package/dist/safe-bash/commands/grep-aliases/index.browser.js +14 -0
  69. package/dist/safe-bash/commands/html-to-markdown/index.browser.js +16 -0
  70. package/dist/safe-bash/commands/metadata/chmod.d.ts +1 -7
  71. package/dist/safe-bash/commands/metadata/chmod.js +1 -204
  72. package/dist/safe-bash/commands/metadata/index.browser.js +17 -0
  73. package/dist/safe-bash/commands/metadata/internal.d.ts +1 -30
  74. package/dist/safe-bash/commands/metadata/internal.js +1 -76
  75. package/dist/safe-bash/commands/metadata/mktemp.d.ts +1 -3
  76. package/dist/safe-bash/commands/metadata/mktemp.js +1 -202
  77. package/dist/safe-bash/commands/metadata/stat.d.ts +1 -7
  78. package/dist/safe-bash/commands/metadata/stat.js +1 -530
  79. package/dist/safe-bash/commands/mktemp/index.browser.js +13 -0
  80. package/dist/safe-bash/commands/mktemp/index.d.ts +2 -0
  81. package/dist/safe-bash/commands/mktemp/index.js +2 -0
  82. package/dist/safe-bash/commands/network/index.browser.js +1 -1
  83. package/dist/safe-bash/commands/node/index.browser.js +4 -4
  84. package/dist/safe-bash/commands/portable-random.d.ts +1 -1
  85. package/dist/safe-bash/commands/portable-random.js +1 -12
  86. package/dist/safe-bash/commands/python/index.browser.js +8 -8
  87. package/dist/safe-bash/commands/regex-execution/public.browser.js +5 -3
  88. package/dist/safe-bash/commands/split/index.browser.js +14 -0
  89. package/dist/safe-bash/commands/stat/index.browser.js +13 -0
  90. package/dist/safe-bash/commands/stat/index.d.ts +2 -0
  91. package/dist/safe-bash/commands/stat/index.js +2 -0
  92. package/dist/safe-bash/commands/stream-format/index.browser.js +11 -0
  93. package/dist/safe-bash/commands/stream-inspection/index.browser.js +11 -0
  94. package/dist/safe-bash/commands/streams.js +5 -5
  95. package/dist/safe-bash/commands/table-text/index.browser.js +11 -0
  96. package/dist/safe-bash/commands/text.js +48 -143
  97. package/dist/safe-bash/commands/time-env/index.browser.js +15 -0
  98. package/dist/safe-bash/commands/tree/index.browser.js +14 -0
  99. package/dist/safe-bash/full-core.browser.js +256 -247
  100. package/dist/safe-bash/opt-in/commands/yq/native-work.js +1 -0
  101. package/dist/safe-bash/optional-host.browser.js +12 -12
  102. package/dist/safe-bash/plugins/index.browser.js +25 -11
  103. package/dist/safe-bash/registry-entry.browser.js +28 -14
  104. package/dist/safe-bash/search.browser.js +48 -0
  105. package/dist/safe-bash/shell/runtime.d.ts +3 -9
  106. package/dist/safe-bash/shell/runtime.js +63 -311
  107. package/dist/safe-bash/shell/shell.js +0 -23
  108. package/dist/safe-bash/shell/types.d.ts +2 -0
  109. package/dist/safe-bash/shell/worker-limits.js +1 -0
  110. package/dist/safe-bash/shell-entry.browser.js +19 -10
  111. package/dist/safe-bash/worker/host.js +1 -1
  112. package/dist/safe-bash-command-bc/index.js +12 -5
  113. package/dist/safe-bash-command-bzip2/index.js +4 -3
  114. package/dist/safe-bash-command-chmod/LICENSE +21 -0
  115. package/dist/safe-bash-command-chmod/command.d.ts +7 -0
  116. package/dist/safe-bash-command-chmod/command.js +11 -0
  117. package/dist/safe-bash-command-chmod/index.d.ts +6 -0
  118. package/dist/safe-bash-command-chmod/index.js +27 -0
  119. package/dist/safe-bash-command-exiftool/index.js +5 -5
  120. package/dist/safe-bash-command-find/find.js +1 -1
  121. package/dist/safe-bash-command-find/index.js +1 -1
  122. package/dist/safe-bash-command-fmt/index.js +9 -2
  123. package/dist/safe-bash-command-gzip/index.js +45 -42
  124. package/dist/safe-bash-command-imagemagick/index.js +3 -1
  125. package/dist/safe-bash-command-jq/index.js +1 -1
  126. package/dist/safe-bash-command-jq/jq.js +1 -1
  127. package/dist/safe-bash-command-less/index.js +12 -3
  128. package/dist/safe-bash-command-mktemp/LICENSE +21 -0
  129. package/dist/safe-bash-command-mktemp/command.d.ts +3 -0
  130. package/dist/safe-bash-command-mktemp/command.js +9 -0
  131. package/dist/safe-bash-command-mktemp/index.d.ts +6 -0
  132. package/dist/safe-bash-command-mktemp/index.js +25 -0
  133. package/dist/safe-bash-command-nl/index.js +1 -1
  134. package/dist/safe-bash-command-nl/nl.js +1 -1
  135. package/dist/safe-bash-command-od/index.js +6 -2
  136. package/dist/safe-bash-command-op/index.js +25 -6
  137. package/dist/safe-bash-command-rg/index.js +1 -1
  138. package/dist/safe-bash-command-rg/rg-command.d.ts +0 -1
  139. package/dist/safe-bash-command-rg/rg-command.js +3 -5
  140. package/dist/safe-bash-command-sed/index.js +1 -1
  141. package/dist/safe-bash-command-sed/sed.js +1 -1
  142. package/dist/safe-bash-command-sips/index.js +13 -5
  143. package/dist/safe-bash-command-sponge/index.js +10 -3
  144. package/dist/safe-bash-command-stat/LICENSE +21 -0
  145. package/dist/safe-bash-command-stat/command.d.ts +7 -0
  146. package/dist/safe-bash-command-stat/command.js +9 -0
  147. package/dist/safe-bash-command-stat/index.d.ts +6 -0
  148. package/dist/safe-bash-command-stat/index.js +25 -0
  149. package/dist/safe-bash-command-unexpand/index.js +1 -1
  150. package/dist/safe-bash-command-unexpand/unexpand.js +1 -1
  151. package/dist/safe-bash-command-unrtf/index.js +11 -1
  152. package/dist/safe-bash-command-xxd/index.js +6 -2
  153. package/dist/safe-bash-command-xz/command.d.ts +1 -1
  154. package/dist/safe-bash-command-xz/index.js +3 -2
  155. package/dist/safe-bash-command-yq/index.js +1 -0
  156. package/dist/safe-bash-command-yq/native-work.js +1 -0
  157. package/dist/safe-bash-command-yq/query.js +3 -0
  158. package/dist/safe-bash-compression-engine/bounded-codec.js +3 -3
  159. package/dist/safe-bash-compression-engine/codec-loader.js +2 -2
  160. package/dist/safe-bash-compression-engine/files.js +6 -6
  161. package/dist/safe-bash-compression-engine/index.js +5 -5
  162. package/dist/safe-bash-compression-engine/operand.js +6 -6
  163. package/dist/safe-bash-compression-engine/options.js +1 -1
  164. package/dist/safe-bash-compression-engine/stream.js +5 -5
  165. package/dist/safe-bash-compression-engine/zstd-decode.js +4 -4
  166. package/dist/safe-bash-contracts/escaping.js +2 -2
  167. package/dist/safe-bash-contracts/filesystem-output.js +2 -2
  168. package/dist/safe-bash-contracts/index.js +2 -2
  169. package/dist/safe-bash-contracts/io.d.ts +2 -0
  170. package/dist/safe-bash-contracts/io.js +1 -1
  171. package/dist/safe-bash-contracts/output.js +2 -2
  172. package/dist/safe-bash-io-engine/commands/search/requirements.js +1 -1
  173. package/dist/safe-bash-io-engine/commands/text-programs/shared.js +1 -1
  174. package/dist/safe-bash-mcp/index.browser.js +11 -1
  175. package/dist/safe-bash-mcp/index.js +38 -17
  176. package/dist/safe-bash-metadata-engine/LICENSE +21 -0
  177. package/dist/safe-bash-metadata-engine/index.d.ts +30 -0
  178. package/dist/safe-bash-metadata-engine/index.js +82 -0
  179. package/dist/safe-bash-metadata-engine/random.d.ts +1 -0
  180. package/dist/safe-bash-metadata-engine/random.js +21 -0
  181. package/dist/safe-bash-regex-engine/index.js +4 -4
  182. package/dist/safe-bash-regex-engine/text/budget.d.ts +0 -1
  183. package/dist/safe-bash-regex-engine/text/budget.js +1 -1
  184. package/dist/safe-bash-regex-engine/text/regex.js +4 -4
  185. package/dist/safe-bash-regex-engine/text/replacement-buffer.js +2 -2
  186. package/dist/safe-bash-regex-engine/text/rust-syntax.js +2 -2
  187. package/dist/safe-bash-search-engine/ergonomic-regex.js +2 -2
  188. package/dist/safe-bash-search-engine/glob.js +2 -2
  189. package/dist/safe-bash-search-engine/grep.js +2 -2
  190. package/dist/safe-bash-search-engine/matcher.js +2 -2
  191. package/dist/safe-bash-search-engine/options.d.ts +2 -0
  192. package/dist/safe-bash-search-engine/options.js +1 -1
  193. package/dist/safe-bash-search-engine/output.js +1 -1
  194. package/dist/safe-bash-search-engine/shared.js +2 -2
  195. package/dist/safe-bash-search-engine/walk.js +3 -3
  196. package/dist/safe-playwright-cloudflare/browser-snapshot-json.js +2 -2
  197. package/dist/safe-playwright-cloudflare/browser-snapshot-references.js +1 -1
  198. package/package.json +91 -10
@@ -5,14 +5,14 @@ import {
5
5
  // packages/safe-bash-command-rg/src/rg-command.ts
6
6
  init_buffer();
7
7
  import { utf8ByteLength, bytesFrom } from "../../safe-bash-byte-engine/index.js";
8
- import { tryGetMemoryDirectoryEntryNamesSync, tryReadMemoryFileViewSync } from "@poe-platform/safe-fs/core";
9
- import { assertCommandRequirements, collectBytes } from "../../safe-bash-contracts/index.js";
8
+ import { tryReadMemoryFileViewSync } from "@poe-platform/safe-fs/core";
9
+ import { assertCommandRequirements, collectBytes, createCommandArguments, getCommandArguments } from "../../safe-bash-contracts/index.js";
10
10
  import { hasYieldCheckpoint } from "../../safe-bash-contracts/yield.js";
11
11
  import { chargeRuntimeFileSystemOperation, getRuntimeBackingFileSystem } from "../../safe-bash-contracts/runtime-control.js";
12
12
  import { Matcher } from "../../safe-bash-search-engine/matcher.js";
13
13
  import { parse, ParsedArguments, SearchError } from "../../safe-bash-search-engine/options.js";
14
14
  import { data, elapsed, Printer, stats } from "../../safe-bash-search-engine/output.js";
15
- import { diagnostic, Limits, lineBatches, sharedOutBufGeneration, trySyncLineBatches, OutputClosed, pathFor } from "../../safe-bash-search-engine/shared.js";
15
+ import { diagnostic, Limits, lineBatches, trySyncLineBatches, OutputClosed, pathFor } from "../../safe-bash-search-engine/shared.js";
16
16
  import { Walker } from "../../safe-bash-search-engine/walk.js";
17
17
  import { RegexExecutionError, withRegexSession } from "../../safe-bash-regex-engine/execution/portable.js";
18
18
  import { inProcessRegexProviders } from "../../safe-bash-regex-engine/execution/protocol.js";
@@ -20,69 +20,10 @@ import { assertPathRequirements, requiredFileInput, searchRequirements } from ".
20
20
  import { RESOLVED_EXIT_ONE, RESOLVED_EXIT_ZERO } from "../../safe-bash-io-engine/internal.js";
21
21
  var EMPTY_RG_LINES = Object.freeze([]);
22
22
  var EMPTY_PATTERNS = Object.freeze([]);
23
- var EMPTY_SEARCH_OPTIONS = Object.freeze({});
24
23
  var DEFAULT_CWD_PATHS = Object.freeze(["."]);
25
24
  var DEFAULT_STDIN_PATHS = Object.freeze(["-"]);
26
25
  var defaultLimitsTick = Limits.prototype.tick;
27
26
  var sharedReadState = { bytesRead: 0, bytesSearched: 0, binaryOffset: null, skipped: false };
28
- var srcRefSlotMap = /* @__PURE__ */ new WeakMap();
29
- var srcRefCountMap = /* @__PURE__ */ new WeakMap();
30
- var srcRefCacheLiteral = new Uint8Array(0);
31
- var defaultDateNowRg = Date.now;
32
- var lastRgTreePattern = "";
33
- var lastRgTreePath = "";
34
- var lastRgTreeCwd = "";
35
- var lastRgTreeOutLen = -1;
36
- var lastRgTreeFound = false;
37
- var lastRgTreeGen = -1;
38
- var lastRgTreeDirNames = new Array(8).fill("");
39
- var lastRgTreeFileNames = new Array(64).fill("");
40
- function preverifyMemoryRgTree(fastMem) {
41
- const m = fastMem;
42
- if (m && m.root?.entries?.size === 1 && m.root.entries._keys?.[0] === "src" && lastRgTreeOutLen >= 0 && lastRgTreePath === "/src") {
43
- if (tryVerifyAndPopulate64Tree(fastMem, "/src", true)) {
44
- m._rgTreeVerifiedTick = m.mutationTick ?? 0;
45
- m._rgTreeVerifiedGen = lastRgTreeGen;
46
- }
47
- }
48
- }
49
- function tryVerifyAndPopulate64Tree(fastMem, rootPath, verifyOnly) {
50
- if (verifyOnly && rootPath === "/src" && fastMem._rgTreeVerifiedTick !== void 0 && fastMem._rgTreeVerifiedTick === (fastMem.mutationTick ?? -1) && fastMem._rgTreeVerifiedGen === lastRgTreeGen) {
51
- return true;
52
- }
53
- const rootEntries = tryGetMemoryDirectoryEntryNamesSync(fastMem, rootPath);
54
- if (!rootEntries || rootEntries._next !== 8 || rootEntries.size !== 8) return false;
55
- const rKeys = rootEntries._keys;
56
- const rVals = rootEntries._vals;
57
- for (let d = 0; d < 8; d++) {
58
- const dName = rKeys[d];
59
- if (verifyOnly) {
60
- if (dName !== lastRgTreeDirNames[d]) return false;
61
- } else {
62
- lastRgTreeDirNames[d] = dName;
63
- }
64
- const dObj = rVals[d];
65
- if (!dObj || dObj.type !== "directory" || dObj.mode === void 0 || (dObj.mode >> 6 & 4) !== 4) return false;
66
- const sub = dObj.entries;
67
- if (!sub || sub._next !== 8 || sub.size !== 8) return false;
68
- const sKeys = sub._keys;
69
- const sVals = sub._vals;
70
- const base = d << 3;
71
- for (let f = 0; f < 8; f++) {
72
- const slot = base | f;
73
- const fName = sKeys[f];
74
- if (verifyOnly) {
75
- if (fName !== lastRgTreeFileNames[slot]) return false;
76
- } else {
77
- lastRgTreeFileNames[slot] = fName;
78
- }
79
- const fObj = sVals[f];
80
- if (!fObj || fObj.type !== "file" || fObj.mode === void 0 || (fObj.mode >> 6 & 4) !== 4 || fObj.revision !== 0) return false;
81
- if (fObj.sourceRef === void 0 || srcRefSlotMap.get(fObj.sourceRef) !== slot) return false;
82
- }
83
- }
84
- return true;
85
- }
86
27
  var BATCH_SIZE_1 = () => 1;
87
28
  var BATCH_SIZE_128 = () => 128;
88
29
  var RETURN_TRUE = () => true;
@@ -114,6 +55,7 @@ function trySearchFileSync(context, args, limits, matcher, printer, target, file
114
55
  const maxBytes = limits.hasFiniteMaxFileBytes ? limits.maxFileBytes : void 0;
115
56
  const view = target.memoryView ?? tryReadMemoryFileViewSync(backing, target.canonicalPath, maxBytes, context.signal);
116
57
  if (view === void 0) return void 0;
58
+ context.inputBudget?.check(view.byteLength);
117
59
  if (!args.hasInfiniteMaxCount && args.maxCount === 0) {
118
60
  totals.searches++;
119
61
  return false;
@@ -122,7 +64,7 @@ function trySearchFileSync(context, args, limits, matcher, printer, target, file
122
64
  const needAll = args.replacement !== void 0 || args.onlyMatching || args.mode === "matches" || args.stats === true;
123
65
  const hasExtYield = hasYieldCheckpoint(context.signal);
124
66
  const lit = matcher.literalAsciiBytes;
125
- if (lit !== void 0 && !args.invert && args.replacement === void 0 && !args.onlyMatching && args.mode !== "matches" && !args.nullData && !args.crlf && binary === "skip" && args.hasInfiniteMaxCount !== false && !hasExtYield && (view.length <= limits.maxLineBytesSmi || view.length <= limits.maxLineBytes) && (target.sourceRef !== void 0 && srcRefSlotMap.get(target.sourceRef) === (totals.searches & 63) || view.indexOf(0) === -1)) {
67
+ if (lit !== void 0 && !args.invert && args.replacement === void 0 && !args.onlyMatching && args.mode !== "matches" && !args.nullData && !args.crlf && binary === "skip" && args.hasInfiniteMaxCount !== false && !hasExtYield && (view.length <= limits.maxLineBytesSmi || view.length <= limits.maxLineBytes) && view.indexOf(0) === -1) {
126
68
  const firstByte = lit[0];
127
69
  const litLen = lit.length;
128
70
  let matchedLines2 = 0;
@@ -130,43 +72,27 @@ function trySearchFileSync(context, args, limits, matcher, printer, target, file
130
72
  let bytesSearched2 = 0;
131
73
  if (!args.stats && !limits.hasExtYield && (args.mode === "count" || args.mode === "with" || args.mode === "without" || args.quiet) && lit.indexOf(10) === -1) {
132
74
  bytesSearched2 = view.length;
133
- const slot = totals.searches & 63;
134
- const srcRef = target.sourceRef;
135
- if (srcRefCacheLiteral.length !== litLen || !srcRefCacheLiteral.every((byte, index) => byte === lit[index])) {
136
- srcRefCacheLiteral = new Uint8Array(lit);
137
- srcRefSlotMap = /* @__PURE__ */ new WeakMap();
138
- srcRefCountMap = /* @__PURE__ */ new WeakMap();
139
- }
140
- if (srcRef !== void 0 && srcRefSlotMap.get(srcRef) === slot && args.mode === "count") {
141
- matchedLines2 = srcRefCountMap.get(srcRef);
142
- matchesCount2 = matchedLines2;
143
- } else {
144
- const searchEnd = view.length - litLen;
145
- let pos = 0;
146
- while (pos <= searchEnd) {
147
- const index = view.indexOf(firstByte, pos);
148
- if (index < 0 || index > searchEnd) break;
149
- let equal = true;
150
- for (let offset = 1; offset < litLen; offset++) {
151
- if (view[index + offset] !== lit[offset]) {
152
- equal = false;
153
- break;
154
- }
155
- }
156
- if (equal) {
157
- matchedLines2++;
158
- matchesCount2++;
159
- if (args.quiet || args.mode === "with" || args.mode === "without") break;
160
- const nl = view.indexOf(10, index + litLen);
161
- if (nl < 0) break;
162
- pos = nl + 1;
163
- } else {
164
- pos = index + 1;
75
+ const searchEnd = view.length - litLen;
76
+ let pos = 0;
77
+ while (pos <= searchEnd) {
78
+ const index = view.indexOf(firstByte, pos);
79
+ if (index < 0 || index > searchEnd) break;
80
+ let equal = true;
81
+ for (let offset = 1; offset < litLen; offset++) {
82
+ if (view[index + offset] !== lit[offset]) {
83
+ equal = false;
84
+ break;
165
85
  }
166
86
  }
167
- if (srcRef !== void 0 && args.mode === "count") {
168
- srcRefSlotMap.set(srcRef, slot);
169
- srcRefCountMap.set(srcRef, matchedLines2);
87
+ if (equal) {
88
+ matchedLines2++;
89
+ matchesCount2++;
90
+ if (args.quiet || args.mode === "with" || args.mode === "without") break;
91
+ const nl = view.indexOf(10, index + litLen);
92
+ if (nl < 0) break;
93
+ pos = nl + 1;
94
+ } else {
95
+ pos = index + 1;
170
96
  }
171
97
  }
172
98
  } else {
@@ -684,14 +610,6 @@ function tryExecuteRgFastSync(context, executor, options) {
684
610
  const limits = runner.limits;
685
611
  limits.resetForRun(context, options);
686
612
  limits.speculative = true;
687
- const cArgs = context.args;
688
- if (cArgs.length === 3 && cArgs[0] === "-c" && cArgs[1] === lastRgTreePattern && cArgs[2] === lastRgTreePath && context.cwd === lastRgTreeCwd && sharedOutBufGeneration === lastRgTreeGen && lastRgTreeOutLen >= 0 && Date.now === defaultDateNowRg && options.regexExecutor === void 0 && tryVerifyAndPopulate64Tree(fastMem, lastRgTreePath, true)) {
689
- committing = true;
690
- if (lastRgTreeOutLen === 0 || limits.flushCachedSharedSync(lastRgTreeOutLen)) {
691
- return lastRgTreeFound ? RESOLVED_EXIT_ZERO : RESOLVED_EXIT_ONE;
692
- }
693
- committing = false;
694
- }
695
613
  const args = parse(context.args, runner.args);
696
614
  if (args.help || args.version || args.patternFiles.length !== 0 || args.mode === "json" || !args.quiet && args.mode === "lines" || args.before > 0 || args.after > 0 || args.stats || args.globs.length !== 0 || args.types.length !== 0 || args.ignoreFiles && args.ignorePaths.length !== 0) {
697
615
  return void 0;
@@ -731,14 +649,6 @@ function tryExecuteRgFastSync(context, executor, options) {
731
649
  }
732
650
  return void 0;
733
651
  }
734
- if (cArgs.length === 3 && cArgs[0] === "-c" && totals.searches === 64 && limits.outPos >= 0 && Date.now === defaultDateNowRg && cArgs[2].charCodeAt(0) === 47 && tryVerifyAndPopulate64Tree(fastMem, cArgs[2], false)) {
735
- lastRgTreePattern = cArgs[1];
736
- lastRgTreePath = cArgs[2];
737
- lastRgTreeCwd = context.cwd;
738
- lastRgTreeOutLen = limits.outPos;
739
- lastRgTreeFound = runner.found;
740
- lastRgTreeGen = sharedOutBufGeneration;
741
- }
742
652
  committing = true;
743
653
  const flushRes = limits.flushSyncOrAsync();
744
654
  if (flushRes === void 0) return runner.found ? RESOLVED_EXIT_ZERO : RESOLVED_EXIT_ONE;
@@ -1114,12 +1024,33 @@ ${totals.bytes_searched} bytes searched
1114
1024
  })();
1115
1025
  });
1116
1026
  }
1027
+ async function executeRgWithConfig(context, executor, options, path) {
1028
+ try {
1029
+ if (parse(context.args).noConfig) return await executeRgSlow(context, executor, options);
1030
+ const maximum = options.maxFileBytes ?? Infinity;
1031
+ const bytes = await collectBytes(requiredFileInput(context, searchRequirements, "file", pathFor(context, path), maximum), { maxBytes: maximum, signal: context.signal });
1032
+ const configArgs = new TextDecoder("utf-8", { fatal: true }).decode(bytes).split("\n").map((line) => line.trim()).filter((line) => line.length > 0 && !line.startsWith("#"));
1033
+ const original = getCommandArguments(context);
1034
+ const argumentsWithConfig = original.slice(0, 0).concat(createCommandArguments(configArgs), original);
1035
+ const configured = Object.create(context, {
1036
+ args: { value: argumentsWithConfig.args },
1037
+ argumentValues: { value: argumentsWithConfig }
1038
+ });
1039
+ return await executeRgSlow(configured, executor, options);
1040
+ } catch (error) {
1041
+ context.signal.throwIfAborted();
1042
+ await diagnostic(context, error);
1043
+ return { exitCode: 2 };
1044
+ }
1045
+ }
1117
1046
  function createRgCommand(executor, options = {}) {
1118
1047
  return {
1119
1048
  name: "rg",
1120
1049
  filesystemRequirements: searchRequirements,
1121
1050
  description: "Search virtual files or stdin with recursive filtering and structured results",
1122
1051
  execute(context) {
1052
+ const config = context.env.RIPGREP_CONFIG_PATH;
1053
+ if (config) return executeRgWithConfig(context, executor, options, config);
1123
1054
  const fastSync = tryExecuteRgFastSync(context, executor, options);
1124
1055
  if (fastSync !== void 0) return fastSync;
1125
1056
  return executeRgSlow(context, executor, options);
@@ -1128,7 +1059,6 @@ function createRgCommand(executor, options = {}) {
1128
1059
  }
1129
1060
 
1130
1061
  export {
1131
- preverifyMemoryRgTree,
1132
1062
  clearRgFastRunnerPool,
1133
1063
  createRgCommand
1134
1064
  };
@@ -2,10 +2,10 @@ import {
2
2
  chunkBytes,
3
3
  stagingLimit,
4
4
  transform
5
- } from "./chunk-2JRBIDAD.js";
5
+ } from "./chunk-V4K2JDYU.js";
6
6
  import {
7
7
  formats
8
- } from "./chunk-5E4WAO4O.js";
8
+ } from "./chunk-JD5QNRNO.js";
9
9
  import {
10
10
  codeOf,
11
11
  pathOf
@@ -5,7 +5,7 @@ import {
5
5
  outputFailure,
6
6
  removeManagedAbortWaiter,
7
7
  writeBytes
8
- } from "./chunk-VXSLJH7G.js";
8
+ } from "./chunk-6JSIFWYT.js";
9
9
  import {
10
10
  init_buffer
11
11
  } from "./chunk-HX3SHTCE.js";
@@ -28,6 +28,7 @@ var ParsedArguments = class _ParsedArguments {
28
28
  patterns = [];
29
29
  paths = [];
30
30
  reset() {
31
+ this.noConfig = false;
31
32
  this.help = void 0;
32
33
  this.version = void 0;
33
34
  this.patternFiles = EMPTY_STRINGS;
@@ -86,6 +87,7 @@ var ParsedArguments = class _ParsedArguments {
86
87
  }
87
88
  static {
88
89
  Object.assign(_ParsedArguments.prototype, {
90
+ noConfig: false,
89
91
  patternFiles: EMPTY_STRINGS,
90
92
  explicitPatterns: false,
91
93
  mode: "lines",
@@ -434,7 +436,9 @@ function parse(args, target) {
434
436
  result.requireGit = false;
435
437
  break;
436
438
  case "no-ignore-global":
439
+ break;
437
440
  case "no-config":
441
+ result.noConfig = true;
438
442
  break;
439
443
  case "a":
440
444
  case "text":
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  zstdDecode
3
- } from "./chunk-F4TEEZTL.js";
3
+ } from "./chunk-CQHP3I66.js";
4
4
  import {
5
5
  gunzipMembers
6
6
  } from "./chunk-Z6UEDK5T.js";
7
7
  import {
8
8
  boundedCodec
9
- } from "./chunk-W5DNF4JH.js";
9
+ } from "./chunk-LOICUCHG.js";
10
10
  import {
11
11
  CodecReader,
12
12
  codec
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ProgramError
3
- } from "./chunk-F6OYH562.js";
3
+ } from "./chunk-X54L3DBL.js";
4
4
  import {
5
5
  init_buffer
6
6
  } from "./chunk-HX3SHTCE.js";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  ReplacementBuffer
3
- } from "./chunk-CZ7EN3JG.js";
3
+ } from "./chunk-VT6MJBEI.js";
4
4
  import {
5
5
  parseRustPattern
6
- } from "./chunk-TNOA7FCQ.js";
6
+ } from "./chunk-YVNGTIJO.js";
7
7
  import {
8
8
  ProgramError
9
- } from "./chunk-F6OYH562.js";
9
+ } from "./chunk-X54L3DBL.js";
10
10
  import {
11
11
  init_buffer
12
12
  } from "./chunk-HX3SHTCE.js";
@@ -973,74 +973,44 @@ var Pattern = class {
973
973
  let matchEnd = -1;
974
974
  let groupStart = -1;
975
975
  let groupEnd = -1;
976
- if (anchoredStart2) {
977
- if (textStart + prefix.length <= textEnd && text.startsWith(prefix, textStart)) {
978
- const pos = textStart + prefix.length;
979
- let cursor = pos;
980
- let count = 0;
981
- while (cursor < textEnd) {
982
- const code = text.codePointAt(cursor);
983
- if (code < 128 ? ascii[code] === 0 : !accepts(String.fromCodePoint(code))) break;
984
- cursor += code > 65535 ? 2 : 1;
985
- count++;
986
- }
987
- if (count >= minimum && (!anchoredEnd2 || cursor === textEnd)) {
988
- found2 = textStart;
989
- matchEnd = cursor;
990
- groupStart = pos;
991
- groupEnd = cursor;
992
- }
993
- }
994
- } else if (prefix.length === 0) {
995
- let searchFrom = from;
996
- const maxStart = textEnd - minimum;
997
- while (searchFrom <= maxStart) {
998
- const c0 = text.codePointAt(searchFrom);
999
- if (c0 < 128 ? ascii[c0] === 0 : !accepts(String.fromCodePoint(c0))) {
1000
- searchFrom += c0 > 65535 ? 2 : 1;
1001
- continue;
1002
- }
1003
- const idx = searchFrom;
1004
- let cursor = idx + (c0 > 65535 ? 2 : 1);
1005
- let count = 1;
1006
- while (cursor < textEnd) {
1007
- const code = text.codePointAt(cursor);
976
+ let searchFrom = from;
977
+ let runStart = -1;
978
+ let runEnd = -1;
979
+ let count = 0;
980
+ while (searchFrom <= textEnd - prefix.length) {
981
+ budget.step();
982
+ const idx = anchoredStart2 ? textStart + prefix.length <= textEnd && text.startsWith(prefix, textStart) ? textStart : -1 : text.indexOf(prefix, searchFrom);
983
+ if (idx < 0 || idx > textEnd - prefix.length) break;
984
+ budget.step(idx - searchFrom);
985
+ const pos = idx + prefix.length;
986
+ if (pos > runEnd) {
987
+ runStart = pos;
988
+ runEnd = pos;
989
+ count = 0;
990
+ while (runEnd < textEnd) {
991
+ budget.step();
992
+ const code = text.codePointAt(runEnd);
1008
993
  if (code < 128 ? ascii[code] === 0 : !accepts(String.fromCodePoint(code))) break;
1009
- cursor += code > 65535 ? 2 : 1;
994
+ runEnd += code > 65535 ? 2 : 1;
1010
995
  count++;
1011
996
  }
1012
- if (count >= minimum && (!anchoredEnd2 || cursor === textEnd)) {
1013
- found2 = idx;
1014
- matchEnd = cursor;
1015
- groupStart = idx;
1016
- groupEnd = cursor;
1017
- break;
997
+ } else {
998
+ while (runStart < pos) {
999
+ budget.step();
1000
+ runStart += text.codePointAt(runStart) > 65535 ? 2 : 1;
1001
+ count--;
1018
1002
  }
1019
- searchFrom = cursor + ((text.codePointAt(cursor) ?? 0) > 65535 ? 2 : 1);
1020
1003
  }
1021
- } else {
1022
- let searchFrom = from;
1023
- while (searchFrom <= textEnd - prefix.length) {
1024
- const idx = text.indexOf(prefix, searchFrom);
1025
- if (idx < 0 || idx > textEnd - prefix.length) break;
1026
- const pos = idx + prefix.length;
1027
- let cursor = pos;
1028
- let count = 0;
1029
- while (cursor < textEnd) {
1030
- const code = text.codePointAt(cursor);
1031
- if (code < 128 ? ascii[code] === 0 : !accepts(String.fromCodePoint(code))) break;
1032
- cursor += code > 65535 ? 2 : 1;
1033
- count++;
1034
- }
1035
- if (count >= minimum && (!anchoredEnd2 || cursor === textEnd)) {
1036
- found2 = idx;
1037
- matchEnd = cursor;
1038
- groupStart = pos;
1039
- groupEnd = cursor;
1040
- break;
1041
- }
1042
- searchFrom = idx + 1;
1004
+ if (count >= minimum && (!anchoredEnd2 || runEnd === textEnd)) {
1005
+ found2 = idx;
1006
+ matchEnd = runEnd;
1007
+ groupStart = pos;
1008
+ groupEnd = runEnd;
1009
+ break;
1043
1010
  }
1011
+ if (anchoredStart2) break;
1012
+ const next = prefix.length === 0 ? runEnd : idx;
1013
+ searchFrom = next + ((text.codePointAt(next) ?? 0) > 65535 ? 2 : 1);
1044
1014
  }
1045
1015
  const positionsTried2 = anchoredStart2 ? 1 : found2 >= 0 ? found2 - from + 1 : textEnd - from + 1;
1046
1016
  const len2 = found2 >= 0 ? matchEnd - found2 : 0;
@@ -1168,58 +1138,15 @@ var Pattern = class {
1168
1138
  return found !== void 0;
1169
1139
  }
1170
1140
  execSimpleRepeat(text, budget, from) {
1171
- const { prefix, anchoredStart, anchoredEnd, captured, minimum, accepts, ascii } = this.simpleRepeatMatch;
1172
- if (from > text.length || anchoredStart && from > 0) return void 0;
1173
- let found = -1;
1174
- let matchEnd = -1;
1175
- let groupStart = -1;
1176
- let groupEnd = -1;
1177
- if (anchoredStart) {
1178
- if (text.startsWith(prefix)) {
1179
- const pos = prefix.length;
1180
- let cursor = pos;
1181
- let count = 0;
1182
- while (cursor < text.length) {
1183
- const code = text.codePointAt(cursor);
1184
- if (code < 128 ? ascii[code] === 0 : !accepts(String.fromCodePoint(code))) break;
1185
- cursor += code > 65535 ? 2 : 1;
1186
- count++;
1187
- }
1188
- if (count >= minimum && (!anchoredEnd || cursor === text.length)) {
1189
- found = 0;
1190
- matchEnd = cursor;
1191
- groupStart = pos;
1192
- groupEnd = cursor;
1193
- }
1194
- }
1195
- } else {
1196
- let searchFrom = from;
1197
- while (searchFrom <= text.length - prefix.length) {
1198
- const idx = text.indexOf(prefix, searchFrom);
1199
- if (idx < 0) break;
1200
- const pos = idx + prefix.length;
1201
- let cursor = pos;
1202
- let count = 0;
1203
- while (cursor < text.length) {
1204
- const code = text.codePointAt(cursor);
1205
- if (code < 128 ? ascii[code] === 0 : !accepts(String.fromCodePoint(code))) break;
1206
- cursor += code > 65535 ? 2 : 1;
1207
- count++;
1208
- }
1209
- if (count >= minimum && (!anchoredEnd || cursor === text.length)) {
1210
- found = idx;
1211
- matchEnd = cursor;
1212
- groupStart = pos;
1213
- groupEnd = cursor;
1214
- break;
1215
- }
1216
- searchFrom = idx + ((text.codePointAt(idx) ?? 0) > 65535 ? 2 : 1);
1217
- }
1218
- }
1141
+ const matched = this.findSyncFastInto(text, budget, from, FAST_MATCH_OFFSETS);
1142
+ const found = matched ? FAST_MATCH_OFFSETS[0] : -1;
1143
+ const matchEnd = matched ? FAST_MATCH_OFFSETS[1] : -1;
1144
+ const groupStart = matched ? FAST_MATCH_OFFSETS[2] : -1;
1145
+ const groupEnd = matched ? FAST_MATCH_OFFSETS[3] : -1;
1146
+ const { anchoredStart, captured } = this.simpleRepeatMatch;
1219
1147
  const positionsTried = anchoredStart ? 1 : found >= 0 ? found - from + 1 : text.length - from + 1;
1220
1148
  const len = found >= 0 ? matchEnd - found : 0;
1221
1149
  const stepCount = positionsTried * 2 + (found >= 0 ? this.code.length * 2 + len : 0);
1222
- budget.step(stepCount);
1223
1150
  if (stepCount >= 64) {
1224
1151
  const midCheck = budget.checkpointSync ? budget.checkpointSync() : budget.checkpoint();
1225
1152
  if (midCheck) {
@@ -37,8 +37,7 @@ var Budget = class _Budget {
37
37
  this.remainingNum = this.unlimited ? 0 : rem;
38
38
  this.remainingSmi = !this.unlimited && rem <= 1073741823 ? rem | 0 : 1073741823;
39
39
  this.signal = context.signal;
40
- this.hasExtYield = hasYieldCheckpoint(context.signal);
41
- this.yieldTimes[0] = performance.now !== defaultPerfNow || this.hasExtYield ? monotonicNow() : -1;
40
+ this.yieldTimes[0] = monotonicNow();
42
41
  this.maxBufferBytes = options.maxBufferBytes ?? Infinity;
43
42
  if (context.signal.aborted) context.signal.throwIfAborted();
44
43
  if (!validatedTextProgramOptions.has(options)) {
@@ -60,7 +59,6 @@ var Budget = class _Budget {
60
59
  unlimited;
61
60
  signal;
62
61
  checkpoints = 0;
63
- hasExtYield = false;
64
62
  yieldTimes = new Float64Array(1);
65
63
  static acquire(context, options) {
66
64
  if (!pooledBudgetA) {
@@ -102,8 +100,7 @@ var Budget = class _Budget {
102
100
  this.remainingSmi = !this.unlimited && rem <= 1073741823 ? rem | 0 : 1073741823;
103
101
  this.signal = context.signal;
104
102
  this.checkpoints = 0;
105
- this.hasExtYield = hasYieldCheckpoint(context.signal);
106
- this.yieldTimes[0] = performance.now !== defaultPerfNow || this.hasExtYield ? monotonicNow() : -1;
103
+ this.yieldTimes[0] = monotonicNow();
107
104
  const nextMaxBuf = options.maxBufferBytes ?? Infinity;
108
105
  if (this.maxBufferBytes !== nextMaxBuf) this.maxBufferBytes = nextMaxBuf;
109
106
  }
@@ -135,11 +132,9 @@ var Budget = class _Budget {
135
132
  if ((count & 255) === 0) {
136
133
  return this.yieldCheckpointAsync();
137
134
  }
138
- if (performance.now !== defaultPerfNow || this.hasExtYield || (count & 63) === 0) {
135
+ if (performance.now !== defaultPerfNow || hasYieldCheckpoint(this.signal) || (count & 63) === 0) {
139
136
  const now = monotonicNow();
140
- if (this.yieldTimes[0] < 0) {
141
- this.yieldTimes[0] = now;
142
- } else if (now - this.yieldTimes[0] >= 25) {
137
+ if (now - this.yieldTimes[0] >= 25) {
143
138
  return this.yieldCheckpointAsync();
144
139
  }
145
140
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ProgramError
3
- } from "./chunk-F6OYH562.js";
3
+ } from "./chunk-X54L3DBL.js";
4
4
  import {
5
5
  init_buffer
6
6
  } from "./chunk-HX3SHTCE.js";