poe-code 17.0.32 → 17.0.33

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 (81) hide show
  1. package/dist/{chunk-UC3KWJDL.js → chunk-4SR3FG2F.js} +8 -8
  2. package/dist/{chunk-GK6Z56OL.js → chunk-EW55GBOF.js} +2 -2
  3. package/dist/{chunk-54JM3XZC.js → chunk-NIIYLKZ6.js} +289 -38
  4. package/dist/chunk-NIIYLKZ6.js.map +7 -0
  5. package/dist/{core-BR637SCW.js → core-2UUUWCLM.js} +2 -2
  6. package/dist/index.js +2 -2
  7. package/dist/metafile.json +1 -1
  8. package/dist/{program-3DNB5ZIC.js → program-2FF4TQ2G.js} +3 -3
  9. package/dist/safe-bash.js +2 -2
  10. package/dist/{src-R4LATOF3.js → src-LTWZPB3P.js} +3 -3
  11. package/package.json +1 -1
  12. package/packages/package-lint/dist/bundle-policy.d.ts +3 -0
  13. package/packages/package-lint/dist/bundle-policy.js +4 -1
  14. package/packages/safe-bash/dist/chunks/{chunk-RVYQDJCC.js → chunk-4CEZRUSZ.js} +2 -2
  15. package/packages/safe-bash/dist/chunks/{chunk-MCBWPJRQ.js → chunk-MX6K5URO.js} +2 -2
  16. package/packages/safe-bash/dist/chunks/{chunk-WSCXISXW.js → chunk-RGSI3B5P.js} +2 -2
  17. package/packages/safe-bash/dist/chunks/{chunk-HC4S4QZD.js → chunk-TZ53QA73.js} +2 -2
  18. package/packages/safe-bash/dist/chunks/{chunk-LUQYNLH7.js → chunk-UKO4AP3K.js} +2 -2
  19. package/packages/safe-bash/dist/chunks/{chunk-JESM4RK2.js → chunk-UMCWCITQ.js} +4 -3
  20. package/packages/safe-bash/dist/chunks/chunk-UMCWCITQ.js.map +7 -0
  21. package/packages/safe-bash/dist/chunks/{chunk-BM3BGSH7.js → chunk-YJPA2BVP.js} +63 -20
  22. package/packages/safe-bash/dist/chunks/chunk-YJPA2BVP.js.map +7 -0
  23. package/packages/safe-bash/dist/commands/archive/index.d.ts.map +1 -1
  24. package/packages/safe-bash/dist/commands/archive/index.js +27 -0
  25. package/packages/safe-bash/dist/commands/archive/index.js.map +1 -1
  26. package/packages/safe-bash/dist/commands/archive/options.d.ts +1 -1
  27. package/packages/safe-bash/dist/commands/archive/options.d.ts.map +1 -1
  28. package/packages/safe-bash/dist/commands/archive/options.js +2 -0
  29. package/packages/safe-bash/dist/commands/archive/options.js.map +1 -1
  30. package/packages/safe-bash/dist/commands/csplit/index.browser.js +1 -1
  31. package/packages/safe-bash/dist/commands/internal.d.ts +1 -1
  32. package/packages/safe-bash/dist/commands/internal.d.ts.map +1 -1
  33. package/packages/safe-bash/dist/commands/internal.js +3 -2
  34. package/packages/safe-bash/dist/commands/internal.js.map +1 -1
  35. package/packages/safe-bash/dist/commands/llm/index.browser.js +2 -2
  36. package/packages/safe-bash/dist/commands/network/index.browser.js +2 -2
  37. package/packages/safe-bash/dist/commands/node/index.browser.js +2 -2
  38. package/packages/safe-bash/dist/commands/regex-execution/ascii.d.ts +2 -0
  39. package/packages/safe-bash/dist/commands/regex-execution/ascii.d.ts.map +1 -1
  40. package/packages/safe-bash/dist/commands/regex-execution/ascii.js +4 -0
  41. package/packages/safe-bash/dist/commands/regex-execution/ascii.js.map +1 -1
  42. package/packages/safe-bash/dist/commands/regex-execution/bounded-provider.d.ts.map +1 -1
  43. package/packages/safe-bash/dist/commands/regex-execution/bounded-provider.js +51 -21
  44. package/packages/safe-bash/dist/commands/regex-execution/bounded-provider.js.map +1 -1
  45. package/packages/safe-bash/dist/commands/regex-execution/ere/matcher.d.ts +2 -2
  46. package/packages/safe-bash/dist/commands/regex-execution/ere/matcher.d.ts.map +1 -1
  47. package/packages/safe-bash/dist/commands/regex-execution/ere/matcher.js +23 -9
  48. package/packages/safe-bash/dist/commands/regex-execution/ere/matcher.js.map +1 -1
  49. package/packages/safe-bash/dist/commands/search/grep.d.ts.map +1 -1
  50. package/packages/safe-bash/dist/commands/search/grep.js +99 -4
  51. package/packages/safe-bash/dist/commands/search/grep.js.map +1 -1
  52. package/packages/safe-bash/dist/commands/search/options.d.ts +1 -0
  53. package/packages/safe-bash/dist/commands/search/options.d.ts.map +1 -1
  54. package/packages/safe-bash/dist/commands/search/options.js +4 -1
  55. package/packages/safe-bash/dist/commands/search/options.js.map +1 -1
  56. package/packages/safe-bash/dist/commands/search/rg-command.d.ts.map +1 -1
  57. package/packages/safe-bash/dist/commands/search/rg-command.js +59 -0
  58. package/packages/safe-bash/dist/commands/search/rg-command.js.map +1 -1
  59. package/packages/safe-bash/dist/commands/streams.d.ts.map +1 -1
  60. package/packages/safe-bash/dist/commands/streams.js +32 -12
  61. package/packages/safe-bash/dist/commands/streams.js.map +1 -1
  62. package/packages/safe-bash/dist/commands/text-programs/sed.d.ts.map +1 -1
  63. package/packages/safe-bash/dist/commands/text-programs/sed.js +10 -1
  64. package/packages/safe-bash/dist/commands/text-programs/sed.js.map +1 -1
  65. package/packages/safe-bash/dist/commands/xml/index.browser.js +2 -2
  66. package/packages/safe-bash/dist/commands/yq/index.browser.js +2 -2
  67. package/packages/safe-bash/dist/core.browser.js +230 -23
  68. package/packages/safe-bash/dist/core.browser.js.map +3 -3
  69. package/dist/chunk-54JM3XZC.js.map +0 -7
  70. package/packages/safe-bash/dist/chunks/chunk-BM3BGSH7.js.map +0 -7
  71. package/packages/safe-bash/dist/chunks/chunk-JESM4RK2.js.map +0 -7
  72. /package/dist/{chunk-UC3KWJDL.js.map → chunk-4SR3FG2F.js.map} +0 -0
  73. /package/dist/{chunk-GK6Z56OL.js.map → chunk-EW55GBOF.js.map} +0 -0
  74. /package/dist/{core-BR637SCW.js.map → core-2UUUWCLM.js.map} +0 -0
  75. /package/dist/{program-3DNB5ZIC.js.map → program-2FF4TQ2G.js.map} +0 -0
  76. /package/dist/{src-R4LATOF3.js.map → src-LTWZPB3P.js.map} +0 -0
  77. /package/packages/safe-bash/dist/chunks/{chunk-RVYQDJCC.js.map → chunk-4CEZRUSZ.js.map} +0 -0
  78. /package/packages/safe-bash/dist/chunks/{chunk-MCBWPJRQ.js.map → chunk-MX6K5URO.js.map} +0 -0
  79. /package/packages/safe-bash/dist/chunks/{chunk-WSCXISXW.js.map → chunk-RGSI3B5P.js.map} +0 -0
  80. /package/packages/safe-bash/dist/chunks/{chunk-HC4S4QZD.js.map → chunk-TZ53QA73.js.map} +0 -0
  81. /package/packages/safe-bash/dist/chunks/{chunk-LUQYNLH7.js.map → chunk-UKO4AP3K.js.map} +0 -0
@@ -2,9 +2,9 @@ import {
2
2
  createXmlCommands,
3
3
  defaultXmlQueryLimits,
4
4
  xmlCommands
5
- } from "../../chunks/chunk-WSCXISXW.js";
5
+ } from "../../chunks/chunk-RGSI3B5P.js";
6
6
  import "../../chunks/chunk-UN4SYYTS.js";
7
- import "../../chunks/chunk-JESM4RK2.js";
7
+ import "../../chunks/chunk-UMCWCITQ.js";
8
8
  import "../../chunks/chunk-FYQULBPT.js";
9
9
  import "../../chunks/chunk-BJ6PZ4F5.js";
10
10
  import "../../chunks/chunk-RGMKSZU2.js";
@@ -2,9 +2,9 @@ import {
2
2
  createYqCommand,
3
3
  createYqCommands,
4
4
  yqCommands
5
- } from "../../chunks/chunk-MCBWPJRQ.js";
5
+ } from "../../chunks/chunk-MX6K5URO.js";
6
6
  import "../../chunks/chunk-UN4SYYTS.js";
7
- import "../../chunks/chunk-JESM4RK2.js";
7
+ import "../../chunks/chunk-UMCWCITQ.js";
8
8
  import "../../chunks/chunk-FYQULBPT.js";
9
9
  import "../../chunks/chunk-LCORBKFF.js";
10
10
  import "../../chunks/chunk-BJ6PZ4F5.js";
@@ -24,7 +24,7 @@ import {
24
24
  createXmlCommands,
25
25
  defaultXmlQueryLimits,
26
26
  xmlCommands
27
- } from "./chunks/chunk-WSCXISXW.js";
27
+ } from "./chunks/chunk-RGSI3B5P.js";
28
28
  import {
29
29
  Interpreter,
30
30
  createYqCommand,
@@ -35,7 +35,7 @@ import {
35
35
  rawValues,
36
36
  stringify,
37
37
  yqCommands
38
- } from "./chunks/chunk-MCBWPJRQ.js";
38
+ } from "./chunks/chunk-MX6K5URO.js";
39
39
  import {
40
40
  Budget,
41
41
  JqError,
@@ -61,7 +61,7 @@ import {
61
61
  curlCommands,
62
62
  defaultNetworkLimits,
63
63
  networkCommands
64
- } from "./chunks/chunk-RVYQDJCC.js";
64
+ } from "./chunks/chunk-4CEZRUSZ.js";
65
65
  import {
66
66
  SafeJsCommandLimitError,
67
67
  createSafeJsNodeCommand,
@@ -72,7 +72,7 @@ import {
72
72
  safeJsNodeCommands,
73
73
  stringValue,
74
74
  withSignal
75
- } from "./chunks/chunk-LUQYNLH7.js";
75
+ } from "./chunks/chunk-UKO4AP3K.js";
76
76
  import {
77
77
  AvailableRecords,
78
78
  EreLedger,
@@ -92,7 +92,7 @@ import {
92
92
  exprMatchCeilings,
93
93
  matchEre,
94
94
  withRegexSession
95
- } from "./chunks/chunk-BM3BGSH7.js";
95
+ } from "./chunks/chunk-YJPA2BVP.js";
96
96
  import {
97
97
  openFileOutput,
98
98
  writeFileOutput
@@ -149,7 +149,7 @@ import {
149
149
  import {
150
150
  createLlmCommands,
151
151
  llmCommands
152
- } from "./chunks/chunk-HC4S4QZD.js";
152
+ } from "./chunks/chunk-TZ53QA73.js";
153
153
  import {
154
154
  RecordBuffer,
155
155
  UsageError,
@@ -181,7 +181,7 @@ import {
181
181
  textOutputRequirements,
182
182
  value,
183
183
  writeDiagnostic
184
- } from "./chunks/chunk-JESM4RK2.js";
184
+ } from "./chunks/chunk-UMCWCITQ.js";
185
185
  import {
186
186
  PublicDiagnostic,
187
187
  publicDiagnosticMessage
@@ -3890,7 +3890,7 @@ async function* combinedInput(context2, names, state) {
3890
3890
  }
3891
3891
  }
3892
3892
  }
3893
- async function prefix(context2, source2, count2, bytes3, skip) {
3893
+ async function prefix(context2, source2, count2, bytes3, skip, delimiter) {
3894
3894
  let remaining = count2;
3895
3895
  if (!remaining && !skip) return;
3896
3896
  for await (const chunk of source2) {
@@ -3901,7 +3901,7 @@ async function prefix(context2, source2, count2, bytes3, skip) {
3901
3901
  offset = Math.min(chunk.length, remaining);
3902
3902
  remaining -= offset;
3903
3903
  } else {
3904
- for (; offset < chunk.length && remaining; offset++) if (chunk[offset] === 10) remaining--;
3904
+ for (; offset < chunk.length && remaining; offset++) if (chunk[offset] === delimiter) remaining--;
3905
3905
  }
3906
3906
  }
3907
3907
  if (skip) {
@@ -3912,12 +3912,12 @@ async function prefix(context2, source2, count2, bytes3, skip) {
3912
3912
  }
3913
3913
  }
3914
3914
  }
3915
- async function suffix(context2, source2, count2, bytes3, omit) {
3915
+ async function suffix(context2, source2, count2, bytes3, omit, delimiter) {
3916
3916
  let pending = [];
3917
3917
  let start = 0;
3918
3918
  let size = 0;
3919
3919
  const records5 = bytes3 ? source2 : (async function* () {
3920
- for await (const line of lines(source2)) yield line.terminated ? concatenate([line.bytes, Uint8Array.of(10)]) : line.bytes;
3920
+ for await (const line of lines(source2, delimiter)) yield line.terminated ? concatenate([line.bytes, Uint8Array.of(delimiter)]) : line.bytes;
3921
3921
  })();
3922
3922
  for await (const chunk of records5) {
3923
3923
  context2.signal.throwIfAborted();
@@ -3992,9 +3992,10 @@ function headTail(name2, maxTailFollowHandles = 64) {
3992
3992
  return define(name2, async (context2) => {
3993
3993
  const args = context2.args[0] && /^-[0-9]+$/u.test(context2.args[0]) ? ["-n", context2.args[0].slice(1), ...context2.args.slice(1)] : context2.args;
3994
3994
  const follow = name2 === "tail" ? parseTailFollow(args) : void 0;
3995
- const parsed = options(follow?.args ?? args, "n:c:qv", { lines: "n", bytes: "c", quiet: "q", silent: "q", verbose: "v" });
3995
+ const parsed = options(follow?.args ?? args, "n:c:qvz", { lines: "n", bytes: "c", quiet: "q", silent: "q", verbose: "v", "zero-terminated": "z" });
3996
3996
  if (parsed.flags.has("n") && parsed.flags.has("c")) throw new UsageError("cannot combine line and byte counts");
3997
3997
  const bytes3 = parsed.flags.has("c");
3998
+ const delimiter = parsed.flags.has("z") ? 0 : 10;
3998
3999
  const amount = value(parsed, bytes3 ? "c" : "n") ?? "10";
3999
4000
  const positive = amount.startsWith("+");
4000
4001
  const negative = amount.startsWith("-");
@@ -4008,7 +4009,7 @@ function headTail(name2, maxTailFollowHandles = 64) {
4008
4009
  bytes: bytes3,
4009
4010
  positive,
4010
4011
  headers: parsed.flags.has("v") || names.length > 1 && !parsed.flags.has("q")
4011
- }, maxTailFollowHandles, (target, source2) => positive ? prefix(target, source2, Math.max(0, count2 - 1), bytes3, true) : suffix(target, source2, count2, bytes3, false));
4012
+ }, maxTailFollowHandles, (target, source2) => positive ? prefix(target, source2, Math.max(0, count2 - 1), bytes3, true, delimiter) : suffix(target, source2, count2, bytes3, false, delimiter));
4012
4013
  await assertInputRequirements(context2, names);
4013
4014
  assertCommandRequirements(context2, inspectedInputRequirements, [names.some((name3) => name3 !== "-") ? "file" : "stdin"]);
4014
4015
  let exitCode = 0;
@@ -4026,9 +4027,9 @@ function headTail(name2, maxTailFollowHandles = 64) {
4026
4027
  `);
4027
4028
  headerWritten = true;
4028
4029
  }
4029
- if (name2 === "head" && !negative) await prefix(context2, input(context2, file), count2, bytes3, false);
4030
- else if (name2 === "tail" && positive) await prefix(context2, input(context2, file), Math.max(0, count2 - 1), bytes3, true);
4031
- else await suffix(context2, input(context2, file), count2, bytes3, name2 === "head");
4030
+ if (name2 === "head" && !negative) await prefix(context2, input(context2, file), count2, bytes3, false, delimiter);
4031
+ else if (name2 === "tail" && positive) await prefix(context2, input(context2, file), Math.max(0, count2 - 1), bytes3, true, delimiter);
4032
+ else await suffix(context2, input(context2, file), count2, bytes3, name2 === "head", delimiter);
4032
4033
  } catch (error) {
4033
4034
  await diagnostic(context2, error);
4034
4035
  exitCode = 1;
@@ -4097,7 +4098,26 @@ function streamCommands(maxTeeTargets = 64, maxTailFollowHandles = 64) {
4097
4098
  }
4098
4099
  return [
4099
4100
  define("cat", async (context2) => {
4100
- const parsed = options(context2.args, "nbsvETAute", { number: "n", "number-nonblank": "b", "squeeze-blank": "s", "show-ends": "E", "show-tabs": "T", "show-nonprinting": "v", "show-all": "A" });
4101
+ const parsed = options(context2.args, "nbsvETAute", { help: false, number: "n", "number-nonblank": "b", "squeeze-blank": "s", "show-ends": "E", "show-tabs": "T", "show-nonprinting": "v", "show-all": "A" });
4102
+ if (parsed.flags.has("help")) {
4103
+ await output(context2, `Usage: cat [OPTION]... [FILE]...
4104
+ Concatenate FILEs to standard output. With no FILE, or FILE -, read standard input.
4105
+
4106
+ -n, --number Number all output lines
4107
+ -b, --number-nonblank Number nonempty output lines (overrides -n)
4108
+ -s, --squeeze-blank Suppress repeated empty output lines
4109
+ -E, --show-ends Display $ at each line end
4110
+ -T, --show-tabs Display TAB characters as ^I
4111
+ -v, --show-nonprinting Display nonprinting characters
4112
+ -A, --show-all Equivalent to -vET
4113
+ -e Equivalent to -vE
4114
+ -t Equivalent to -vT
4115
+ -u Accepted for compatibility; ignored
4116
+ --help Display this help and exit
4117
+ -- End options; remaining arguments are filenames
4118
+ `);
4119
+ return { exitCode: 0 };
4120
+ }
4101
4121
  await assertInputRequirements(context2, parsed.operands);
4102
4122
  if (parsed.flags.has("A")) for (const flag of ["v", "E", "T"]) parsed.flags.add(flag);
4103
4123
  if (parsed.flags.has("e")) {
@@ -14534,7 +14554,7 @@ async function execute(program, context2, files, quiet, budget, separator, outpu
14534
14554
  const character = pattern[offset];
14535
14555
  const lineEnd = character === "\n" && separator === "\n";
14536
14556
  const token = character === void 0 || lineEnd ? "$" : escapes2[character] ?? (character.charCodeAt(0) < 32 || character.charCodeAt(0) >= 127 ? `\\${character.charCodeAt(0).toString(8).padStart(3, "0")}` : character);
14537
- if (line.length + token.length >= 60) {
14557
+ if (character !== void 0 && !lineEnd && line.length + token.length >= 70) {
14538
14558
  await emit2(line + "\\" + separator);
14539
14559
  line = "";
14540
14560
  }
@@ -14695,6 +14715,14 @@ function sedCommand(options2 = {}) {
14695
14715
  separator = "\0";
14696
14716
  continue;
14697
14717
  }
14718
+ if (argument2 === "--quiet") {
14719
+ quiet = true;
14720
+ continue;
14721
+ }
14722
+ if (argument2 === "--regexp-extended") {
14723
+ extended = true;
14724
+ continue;
14725
+ }
14698
14726
  if (argument2.startsWith("--")) throw new ProgramError(`unsupported option '${argument2}'`);
14699
14727
  for (let position = 1; position < argument2.length; position++) {
14700
14728
  const flag = argument2[position];
@@ -17031,6 +17059,9 @@ function parse6(args) {
17031
17059
  return output3;
17032
17060
  };
17033
17061
  switch (flag) {
17062
+ case "help":
17063
+ result.help = true;
17064
+ break;
17034
17065
  case "e":
17035
17066
  case "regexp":
17036
17067
  result.explicitPatterns = true;
@@ -17276,7 +17307,7 @@ function parse6(args) {
17276
17307
  }
17277
17308
  }
17278
17309
  if (result.before > 1e5 || result.after > 1e5) throw new SearchError("context limit exceeded");
17279
- if (result.mode !== "files" && !result.explicitPatterns) {
17310
+ if (!result.help && result.mode !== "files" && !result.explicitPatterns) {
17280
17311
  const pattern = operands.shift();
17281
17312
  if (pattern === void 0) throw new SearchError("a search pattern is required");
17282
17313
  result.patterns.push(pattern);
@@ -17878,6 +17909,65 @@ function createRgCommand(executor, options2 = {}) {
17878
17909
  try {
17879
17910
  const limits = new Limits(context2, options2);
17880
17911
  args = parse6(context2.args);
17912
+ if (args.help) {
17913
+ await limits.output(import_buffer.Buffer.from(`Usage: rg [OPTIONS] PATTERN [PATH ...]
17914
+ Search files for PATTERN. PATH - reads standard input.
17915
+ Default input depends on shell configuration.
17916
+
17917
+ -e, --regexp=PATTERN Add a pattern (repeatable)
17918
+ -f, --file=FILE Read patterns from FILE
17919
+ -F, --fixed-strings Use fixed strings
17920
+ -i, --ignore-case Ignore case distinctions
17921
+ -s, --case-sensitive Match case sensitively
17922
+ -S, --smart-case Infer case sensitivity from the pattern
17923
+ -v, --invert-match Select nonmatching lines
17924
+ -w, --word-regexp Match whole words
17925
+ -x, --line-regexp Match whole lines
17926
+ -n, --line-number Print line numbers
17927
+ -N, --no-line-number Suppress line numbers
17928
+ -H, --with-filename Print filenames
17929
+ -I, --no-filename Suppress filenames
17930
+ -o, --only-matching Print matching parts
17931
+ -l, --files-with-matches Print filenames with matches
17932
+ --files-without-match Print filenames without matches
17933
+ --files List files without searching
17934
+ -c, --count Print matching line counts
17935
+ --count-matches Print match counts
17936
+ --json Emit JSON events
17937
+ -q, --quiet Suppress normal output
17938
+ -g, --glob=GLOB Include or exclude paths (repeatable)
17939
+ --iglob=GLOB Case-insensitive glob
17940
+ -t, --type=TYPE Include a file type
17941
+ -T, --type-not=TYPE Exclude a file type
17942
+ -., --hidden Search hidden files
17943
+ -L, --follow Follow symbolic links
17944
+ --no-ignore Disable ignore-file filtering
17945
+ -u, --unrestricted Relax ignore, hidden and binary filtering (repeatable)
17946
+ -a, --text Search binary files as text
17947
+ -A, --after-context=NUM Print NUM lines after matches
17948
+ -B, --before-context=NUM Print NUM lines before matches
17949
+ -C, --context=NUM Print NUM lines before and after matches
17950
+ -m, --max-count=NUM Limit matching lines per file
17951
+ --max-depth=NUM Limit directory traversal depth (maximum 128)
17952
+ --column Print columns
17953
+ -b, --byte-offset Print byte offsets
17954
+ -0, --null NUL-terminate filenames
17955
+ --null-data Use NUL-delimited records
17956
+ --crlf Handle CRLF line endings
17957
+ --heading Group output by filename
17958
+ --sort=path Sort paths
17959
+ --color=never Disable color
17960
+ --help Display this help and exit
17961
+ -- End options
17962
+
17963
+ Exit status: 0 when a match is found, 1 when none is found, 2 on error.
17964
+ Regular expression support depends on the configured regex executor.
17965
+ The default supports UTF-8 literals and bounded ASCII regular expressions.
17966
+ Regex operators: . ^ $ [...] (...) | * + ? {n,m}; -F treats patterns literally.
17967
+ Word/case flags and extended regex syntax require a configured executor.
17968
+ `));
17969
+ return { exitCode: 0 };
17970
+ }
17881
17971
  if (args.mode !== "files" && args.patternFiles.includes("-") && args.paths.includes("-")) {
17882
17972
  throw new SearchError("cannot search stdin while also reading patterns from stdin");
17883
17973
  }
@@ -17936,7 +18026,51 @@ var maxPatternCount = 1024;
17936
18026
  function createGrepCommands(executor) {
17937
18027
  return [{ name: "grep", filesystemRequirements: grepRequirements, execute: (context2) => withRegexSession(context2, executor, async (session) => {
17938
18028
  try {
17939
- const parsed = options(context2.args, "EFivnclLqhHowxae:f:m:sz", { "extended-regexp": "E", "fixed-strings": "F", "ignore-case": "i", "invert-match": "v", "line-number": "n", count: "c", "files-with-matches": "l", "files-without-match": "L", quiet: "q", silent: "q", "no-filename": "h", "with-filename": "H", "only-matching": "o", "word-regexp": "w", "line-regexp": "x", regexp: "e", file: "f", "max-count": "m", "no-messages": "s", text: "a", "null-data": "z" });
18029
+ const contextLengths = /* @__PURE__ */ new Map();
18030
+ const parsed = options(context2.args, "EFivnclLqhHowxae:f:m:szA:B:C:", { help: false, "extended-regexp": "E", "fixed-strings": "F", "ignore-case": "i", "invert-match": "v", "line-number": "n", count: "c", "files-with-matches": "l", "files-without-match": "L", quiet: "q", silent: "q", "no-filename": "h", "with-filename": "H", "only-matching": "o", "word-regexp": "w", "line-regexp": "x", regexp: "e", file: "f", "max-count": "m", "no-messages": "s", text: "a", "null-data": "z", "after-context": "A", "before-context": "B", context: "C" }, false, void 0, (key, index, offset) => {
18031
+ if (!["A", "B", "C"].includes(key)) return;
18032
+ const text3 = context2.args[index].slice(offset);
18033
+ try {
18034
+ contextLengths.set(key, integer(text3));
18035
+ } catch {
18036
+ throw new UsageError(`${text3}: invalid context length argument`);
18037
+ }
18038
+ });
18039
+ if (parsed.flags.has("help")) {
18040
+ await output(context2, `Usage: grep [OPTION]... PATTERN [FILE]...
18041
+ Print lines matching PATTERN. With no FILE, or FILE -, read standard input.
18042
+
18043
+ -E, --extended-regexp Use extended regular expressions
18044
+ -F, --fixed-strings Use fixed strings
18045
+ -e, --regexp=PATTERN Add a pattern (repeatable)
18046
+ -f, --file=FILE Read patterns from FILE
18047
+ -i, --ignore-case Ignore case distinctions
18048
+ -v, --invert-match Select nonmatching lines
18049
+ -w, --word-regexp Match whole words
18050
+ -x, --line-regexp Match whole lines
18051
+ -n, --line-number Print line numbers
18052
+ -H, --with-filename Print filenames
18053
+ -h, --no-filename Suppress filenames
18054
+ -o, --only-matching Print only matching parts
18055
+ -c, --count Print matching line counts
18056
+ -l, --files-with-matches Print filenames with matches
18057
+ -L, --files-without-match Print filenames without matches
18058
+ -q, --quiet, --silent Suppress normal output
18059
+ -m, --max-count=NUM Stop after NUM selected lines per file
18060
+ -A, --after-context=NUM Print NUM lines after selected lines
18061
+ -B, --before-context=NUM Print NUM lines before selected lines
18062
+ -C, --context=NUM Print NUM lines before and after selected lines
18063
+ -s, --no-messages Suppress file error messages
18064
+ -a, --text Process input as text
18065
+ -z, --null-data Use NUL-delimited records
18066
+ --help Display this help and exit
18067
+ -- End options
18068
+
18069
+ Exit status: 0 when a line is selected, 1 when none is selected, 2 on error.
18070
+ Regular expression support depends on the configured regex executor.
18071
+ `);
18072
+ return { exitCode: 0 };
18073
+ }
17940
18074
  let positionalPattern;
17941
18075
  if (!parsed.flags.has("e") && !parsed.flags.has("f")) {
17942
18076
  if (!parsed.operands.length) throw new UsageError("missing pattern");
@@ -17998,13 +18132,30 @@ function createGrepCommands(executor) {
17998
18132
  const batchSize = Number.isFinite(maxCount) || parsed.flags.has("q") || parsed.flags.has("l") || parsed.flags.has("L") ? 1 : 128;
17999
18133
  const delimiter = parsed.flags.has("z") ? "\0" : "\n";
18000
18134
  const extractMatches = parsed.flags.has("o") && !["c", "q", "l", "L", "v"].some((flag) => parsed.flags.has(flag));
18135
+ const displayLines = !["c", "q", "l", "L"].some((flag) => parsed.flags.has(flag));
18136
+ const withContext = contextLengths.size > 0 && displayLines && !(parsed.flags.has("o") && parsed.flags.has("v"));
18137
+ const before = withContext ? contextLengths.get("B") ?? contextLengths.get("C") ?? 0 : 0;
18138
+ const after = withContext ? contextLengths.get("A") ?? contextLengths.get("C") ?? 0 : 0;
18139
+ let emittedGroup = false;
18001
18140
  let anySelected = false;
18002
18141
  let failed = false;
18003
18142
  for (const name2 of names) {
18004
18143
  let count2 = 0;
18005
18144
  let number6 = 0;
18145
+ let lastCovered = 0;
18146
+ let remainingAfter = 0;
18147
+ let pendingBytes = 0;
18148
+ const pending = /* @__PURE__ */ new Map();
18006
18149
  const named2 = name2 === "-" ? "(standard input)" : name2;
18007
- const prefix3 = (lineNumber = false) => `${!parsed.flags.has("h") && (parsed.flags.has("H") || names.length > 1) ? `${named2}:` : ""}${lineNumber && parsed.flags.has("n") ? `${number6}:` : ""}`;
18150
+ const prefix3 = (lineNumber = false, position = number6, separator = ":") => `${!parsed.flags.has("h") && (parsed.flags.has("H") || names.length > 1) ? `${named2}${separator}` : ""}${lineNumber && parsed.flags.has("n") ? `${position}${separator}` : ""}`;
18151
+ const emitContext = async (line, position) => {
18152
+ if (!parsed.flags.has("o")) {
18153
+ await output(context2, prefix3(true, position, "-"));
18154
+ await output(context2, line.bytes);
18155
+ await output(context2, delimiter);
18156
+ }
18157
+ lastCovered = position;
18158
+ };
18008
18159
  try {
18009
18160
  const available2 = new AvailableRecords(parsed.flags.has("z") ? 0 : 10, bufferLimit);
18010
18161
  const source2 = name2 === "-" ? input(context2) : requiredFileInput(context2, grepRequirements, "file", name2, bufferLimit);
@@ -18015,12 +18166,40 @@ function createGrepCommands(executor) {
18015
18166
  context2.signal.throwIfAborted();
18016
18167
  number6++;
18017
18168
  const found = results[index];
18018
- if (found.length > 0 === parsed.flags.has("v")) continue;
18169
+ const selected = count2 < maxCount && found.length > 0 !== parsed.flags.has("v");
18170
+ if (!selected) {
18171
+ if (remainingAfter > 0) {
18172
+ await emitContext(line, number6);
18173
+ remainingAfter--;
18174
+ if (count2 >= maxCount && remainingAfter === 0) break records;
18175
+ } else if (before > 0) {
18176
+ if (pending.size >= before) {
18177
+ const oldest = pending.keys().next().value;
18178
+ pendingBytes -= pending.get(oldest).bytes.length + 1;
18179
+ pending.delete(oldest);
18180
+ }
18181
+ const size = line.bytes.length + 1;
18182
+ if (size > bufferLimit - pendingBytes) throw new UsageError(`context byte limit exceeded (${bufferLimit} bytes)`);
18183
+ pending.set(number6, { bytes: Uint8Array.from(line.bytes), terminated: line.terminated });
18184
+ pendingBytes += size;
18185
+ }
18186
+ continue;
18187
+ }
18019
18188
  count2++;
18020
18189
  if (!parsed.flags.has("L")) anySelected = true;
18021
18190
  if (parsed.flags.has("q")) return { exitCode: 0 };
18022
18191
  if (parsed.flags.has("l") || parsed.flags.has("L")) break records;
18023
18192
  if (!parsed.flags.has("c")) {
18193
+ if (withContext) {
18194
+ const first = pending.keys().next().value ?? number6;
18195
+ if (emittedGroup && (lastCovered === 0 || first > lastCovered + 1)) await output(context2, "--\n");
18196
+ for (const [position, previous] of pending) await emitContext(previous, position);
18197
+ pending.clear();
18198
+ pendingBytes = 0;
18199
+ remainingAfter = after;
18200
+ lastCovered = number6;
18201
+ emittedGroup = true;
18202
+ }
18024
18203
  if (parsed.flags.has("o")) {
18025
18204
  if (!parsed.flags.has("v")) {
18026
18205
  let end = -1;
@@ -18038,7 +18217,7 @@ function createGrepCommands(executor) {
18038
18217
  await output(context2, delimiter);
18039
18218
  }
18040
18219
  }
18041
- if (count2 >= maxCount) break records;
18220
+ if (count2 >= maxCount && remainingAfter === 0) break records;
18042
18221
  }
18043
18222
  }
18044
18223
  if (parsed.flags.has("l") && count2 > 0 || parsed.flags.has("L") && count2 === 0) {
@@ -27792,6 +27971,7 @@ async function parseOptions2(context2, limits) {
27792
27971
  if (values2.has(flag) && value2 === void 0) value2 = context2.args[++index];
27793
27972
  if (values2.has(flag) && value2 === void 0) fail(`missing argument for --${name2}`);
27794
27973
  if (!values2.has(flag) && value2 !== void 0) fail(`option --${name2} does not take an argument`);
27974
+ if (flag === "help") return "help";
27795
27975
  await apply(flag, value2);
27796
27976
  } else if (!end && (argument2.startsWith("-") && argument2 !== "-" || index === 0 && /^[ctxzvfCT]+$/u.test(argument2))) {
27797
27977
  const old = !argument2.startsWith("-");
@@ -33562,6 +33742,33 @@ function createTarCommand(options2 = {}) {
33562
33742
  const context2 = { ...original, signal };
33563
33743
  try {
33564
33744
  const parsed = await parseOptions2(context2, limits);
33745
+ if (parsed === "help") {
33746
+ await writeBytes(context2.stdout, import_buffer.Buffer.from(`Usage: tar [OPTION]... [FILE]...
33747
+ Create, list or extract USTAR/PAX archives in the virtual filesystem.
33748
+
33749
+ -c, --create Create an archive
33750
+ -t, --list List archive members
33751
+ -x, --extract, --get Extract archive members
33752
+ -f, --file=ARCHIVE Use ARCHIVE (default - for standard input/output)
33753
+ -z, --gzip Use gzip compression
33754
+ -v, --verbose List processed members
33755
+ -C, --directory=DIR Change directory for subsequent operands
33756
+ -T, --files-from=FILE Read filenames from FILE (- for standard input)
33757
+ --null Read NUL-delimited filenames; implies verbatim names
33758
+ --no-null Read newline-delimited filenames
33759
+ --verbatim-files-from Treat file-list entries as literal filenames
33760
+ --no-verbatim-files-from Enable supported file-list directory options
33761
+ --exclude=PATTERN Exclude paths (place before source operands)
33762
+ --strip-components=NUM Remove leading components when reading archives
33763
+ --format=FORMAT Create pax (default), posix or ustar archives
33764
+ --help Display this help and exit
33765
+ -- End options; remaining arguments are filenames
33766
+
33767
+ Exactly one of -c, -t or -x is required for archive operations.
33768
+ Examples: tar cf archive.tar file; tar tf archive.tar; tar xf archive.tar -C directory
33769
+ `), signal);
33770
+ return { exitCode: 0 };
33771
+ }
33565
33772
  const budget = new Budget14(context2, limits);
33566
33773
  if (parsed.mode === "c") {
33567
33774
  const prepared = await manifest(context2, parsed, budget);