@poe-platform/safe-bash 0.1.718 → 0.1.720

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 (93) hide show
  1. package/README.md +11 -2
  2. package/dist/safe-bash/chunks/{chunk-N4PN6Z63.js → chunk-6G7AGS2B.js} +41 -5
  3. package/dist/safe-bash/chunks/chunk-6G7AGS2B.js.map +7 -0
  4. package/dist/safe-bash/chunks/{chunk-RVYQDJCC.js → chunk-AOT4SUBQ.js} +2 -2
  5. package/dist/safe-bash/chunks/{chunk-MCBWPJRQ.js → chunk-FOMU56TU.js} +18 -2
  6. package/dist/safe-bash/chunks/chunk-FOMU56TU.js.map +7 -0
  7. package/dist/safe-bash/chunks/{chunk-FXCEA7NR.js → chunk-IW6BX3VX.js} +18 -2
  8. package/dist/safe-bash/chunks/chunk-IW6BX3VX.js.map +7 -0
  9. package/dist/safe-bash/chunks/{chunk-JESM4RK2.js → chunk-KLEL3WAN.js} +41 -5
  10. package/dist/safe-bash/chunks/chunk-KLEL3WAN.js.map +7 -0
  11. package/dist/safe-bash/chunks/{chunk-LUQYNLH7.js → chunk-L4HKTYVE.js} +2 -2
  12. package/dist/safe-bash/chunks/{chunk-4C5H4M64.js → chunk-M7GLXFPU.js} +2 -2
  13. package/dist/safe-bash/chunks/{chunk-B5Y7TH7K.js → chunk-NF3OGIG4.js} +2 -2
  14. package/dist/safe-bash/chunks/{chunk-G5FT6GOL.js → chunk-RNWDFNH4.js} +2 -2
  15. package/dist/safe-bash/chunks/{chunk-WSCXISXW.js → chunk-RYXT5BJJ.js} +2 -2
  16. package/dist/safe-bash/chunks/{chunk-SACGNKFN.js → chunk-UZUKVBCC.js} +2 -2
  17. package/dist/safe-bash/chunks/{chunk-HC4S4QZD.js → chunk-WSX5CLK2.js} +2 -2
  18. package/dist/safe-bash/chunks/{chunk-BM3BGSH7.js → chunk-YJPA2BVP.js} +63 -20
  19. package/dist/safe-bash/chunks/chunk-YJPA2BVP.js.map +7 -0
  20. package/dist/safe-bash/chunks/{chunk-YOUOJRAP.js → chunk-ZHWEPWDW.js} +63 -20
  21. package/dist/safe-bash/chunks/chunk-ZHWEPWDW.js.map +7 -0
  22. package/dist/safe-bash/commands/archive/index.d.ts.map +1 -1
  23. package/dist/safe-bash/commands/archive/index.js +27 -0
  24. package/dist/safe-bash/commands/archive/index.js.map +1 -1
  25. package/dist/safe-bash/commands/archive/options.d.ts +1 -1
  26. package/dist/safe-bash/commands/archive/options.d.ts.map +1 -1
  27. package/dist/safe-bash/commands/archive/options.js +2 -0
  28. package/dist/safe-bash/commands/archive/options.js.map +1 -1
  29. package/dist/safe-bash/commands/basic.d.ts.map +1 -1
  30. package/dist/safe-bash/commands/basic.js +9 -2
  31. package/dist/safe-bash/commands/basic.js.map +1 -1
  32. package/dist/safe-bash/commands/csplit/index.browser.js +1 -1
  33. package/dist/safe-bash/commands/internal.d.ts +5 -2
  34. package/dist/safe-bash/commands/internal.d.ts.map +1 -1
  35. package/dist/safe-bash/commands/internal.js +48 -4
  36. package/dist/safe-bash/commands/internal.js.map +1 -1
  37. package/dist/safe-bash/commands/llm/index.browser.js +2 -2
  38. package/dist/safe-bash/commands/network/index.browser.js +2 -2
  39. package/dist/safe-bash/commands/node/index.browser.js +2 -2
  40. package/dist/safe-bash/commands/pandoc/index.js.map +2 -2
  41. package/dist/safe-bash/commands/regex-execution/ascii.d.ts +2 -0
  42. package/dist/safe-bash/commands/regex-execution/ascii.d.ts.map +1 -1
  43. package/dist/safe-bash/commands/regex-execution/ascii.js +4 -0
  44. package/dist/safe-bash/commands/regex-execution/ascii.js.map +1 -1
  45. package/dist/safe-bash/commands/regex-execution/bounded-provider.d.ts.map +1 -1
  46. package/dist/safe-bash/commands/regex-execution/bounded-provider.js +51 -21
  47. package/dist/safe-bash/commands/regex-execution/bounded-provider.js.map +1 -1
  48. package/dist/safe-bash/commands/regex-execution/ere/matcher.d.ts +2 -2
  49. package/dist/safe-bash/commands/regex-execution/ere/matcher.d.ts.map +1 -1
  50. package/dist/safe-bash/commands/regex-execution/ere/matcher.js +23 -9
  51. package/dist/safe-bash/commands/regex-execution/ere/matcher.js.map +1 -1
  52. package/dist/safe-bash/commands/search/grep.d.ts.map +1 -1
  53. package/dist/safe-bash/commands/search/grep.js +99 -4
  54. package/dist/safe-bash/commands/search/grep.js.map +1 -1
  55. package/dist/safe-bash/commands/search/options.d.ts +1 -0
  56. package/dist/safe-bash/commands/search/options.d.ts.map +1 -1
  57. package/dist/safe-bash/commands/search/options.js +4 -1
  58. package/dist/safe-bash/commands/search/options.js.map +1 -1
  59. package/dist/safe-bash/commands/search/rg-command.d.ts.map +1 -1
  60. package/dist/safe-bash/commands/search/rg-command.js +59 -0
  61. package/dist/safe-bash/commands/search/rg-command.js.map +1 -1
  62. package/dist/safe-bash/commands/streams.d.ts.map +1 -1
  63. package/dist/safe-bash/commands/streams.js +32 -12
  64. package/dist/safe-bash/commands/streams.js.map +1 -1
  65. package/dist/safe-bash/commands/structured/jq.d.ts.map +1 -1
  66. package/dist/safe-bash/commands/structured/jq.js +8 -4
  67. package/dist/safe-bash/commands/structured/jq.js.map +1 -1
  68. package/dist/safe-bash/commands/structured/values.d.ts +1 -0
  69. package/dist/safe-bash/commands/structured/values.d.ts.map +1 -1
  70. package/dist/safe-bash/commands/structured/values.js +18 -1
  71. package/dist/safe-bash/commands/structured/values.js.map +1 -1
  72. package/dist/safe-bash/commands/text-programs/sed.d.ts.map +1 -1
  73. package/dist/safe-bash/commands/text-programs/sed.js +10 -1
  74. package/dist/safe-bash/commands/text-programs/sed.js.map +1 -1
  75. package/dist/safe-bash/commands/xml/index.browser.js +2 -2
  76. package/dist/safe-bash/commands/yq/index.browser.js +2 -2
  77. package/dist/safe-bash/core.browser.js +248 -29
  78. package/dist/safe-bash/core.browser.js.map +3 -3
  79. package/package.json +2 -2
  80. package/dist/safe-bash/chunks/chunk-BM3BGSH7.js.map +0 -7
  81. package/dist/safe-bash/chunks/chunk-FXCEA7NR.js.map +0 -7
  82. package/dist/safe-bash/chunks/chunk-JESM4RK2.js.map +0 -7
  83. package/dist/safe-bash/chunks/chunk-MCBWPJRQ.js.map +0 -7
  84. package/dist/safe-bash/chunks/chunk-N4PN6Z63.js.map +0 -7
  85. package/dist/safe-bash/chunks/chunk-YOUOJRAP.js.map +0 -7
  86. /package/dist/safe-bash/chunks/{chunk-RVYQDJCC.js.map → chunk-AOT4SUBQ.js.map} +0 -0
  87. /package/dist/safe-bash/chunks/{chunk-LUQYNLH7.js.map → chunk-L4HKTYVE.js.map} +0 -0
  88. /package/dist/safe-bash/chunks/{chunk-4C5H4M64.js.map → chunk-M7GLXFPU.js.map} +0 -0
  89. /package/dist/safe-bash/chunks/{chunk-B5Y7TH7K.js.map → chunk-NF3OGIG4.js.map} +0 -0
  90. /package/dist/safe-bash/chunks/{chunk-G5FT6GOL.js.map → chunk-RNWDFNH4.js.map} +0 -0
  91. /package/dist/safe-bash/chunks/{chunk-WSCXISXW.js.map → chunk-RYXT5BJJ.js.map} +0 -0
  92. /package/dist/safe-bash/chunks/{chunk-SACGNKFN.js.map → chunk-UZUKVBCC.js.map} +0 -0
  93. /package/dist/safe-bash/chunks/{chunk-HC4S4QZD.js.map → chunk-WSX5CLK2.js.map} +0 -0
@@ -24,7 +24,7 @@ import {
24
24
  createXmlCommands,
25
25
  defaultXmlQueryLimits,
26
26
  xmlCommands
27
- } from "./chunks/chunk-G5FT6GOL.js";
27
+ } from "./chunks/chunk-RNWDFNH4.js";
28
28
  import {
29
29
  Interpreter,
30
30
  createYqCommand,
@@ -33,9 +33,10 @@ import {
33
33
  parse,
34
34
  parseJson,
35
35
  rawValues,
36
+ sortObjectKeys,
36
37
  stringify,
37
38
  yqCommands
38
- } from "./chunks/chunk-FXCEA7NR.js";
39
+ } from "./chunks/chunk-IW6BX3VX.js";
39
40
  import {
40
41
  Budget,
41
42
  JqError,
@@ -61,7 +62,7 @@ import {
61
62
  curlCommands,
62
63
  defaultNetworkLimits,
63
64
  networkCommands
64
- } from "./chunks/chunk-B5Y7TH7K.js";
65
+ } from "./chunks/chunk-NF3OGIG4.js";
65
66
  import {
66
67
  SafeJsCommandLimitError,
67
68
  createSafeJsNodeCommand,
@@ -72,7 +73,7 @@ import {
72
73
  safeJsNodeCommands,
73
74
  stringValue,
74
75
  withSignal
75
- } from "./chunks/chunk-4C5H4M64.js";
76
+ } from "./chunks/chunk-M7GLXFPU.js";
76
77
  import {
77
78
  AvailableRecords,
78
79
  EreLedger,
@@ -92,7 +93,7 @@ import {
92
93
  exprMatchCeilings,
93
94
  matchEre,
94
95
  withRegexSession
95
- } from "./chunks/chunk-YOUOJRAP.js";
96
+ } from "./chunks/chunk-ZHWEPWDW.js";
96
97
  import {
97
98
  openFileOutput,
98
99
  writeFileOutput
@@ -152,7 +153,7 @@ import {
152
153
  import {
153
154
  createLlmCommands,
154
155
  llmCommands
155
- } from "./chunks/chunk-SACGNKFN.js";
156
+ } from "./chunks/chunk-UZUKVBCC.js";
156
157
  import {
157
158
  RecordBuffer,
158
159
  UsageError,
@@ -182,7 +183,7 @@ import {
182
183
  textOutputRequirements,
183
184
  value,
184
185
  writeDiagnostic
185
- } from "./chunks/chunk-N4PN6Z63.js";
186
+ } from "./chunks/chunk-6G7AGS2B.js";
186
187
  import {
187
188
  PublicDiagnostic,
188
189
  publicDiagnosticMessage
@@ -699,6 +700,11 @@ async function formatPrintf(context2) {
699
700
  let argument2 = 1;
700
701
  let exitCode = 0;
701
702
  let stopped = false;
703
+ const locale = context2.env.LC_ALL || context2.env.LC_CTYPE || context2.env.LANG || "C.UTF-8";
704
+ const unicodeErrors = [];
705
+ const unicode = { utf8: locale !== "C" && locale !== "POSIX", missingDigit: (escape) => {
706
+ unicodeErrors.push(escape);
707
+ } };
702
708
  do {
703
709
  const before = argument2;
704
710
  for (let offset = 0; offset < formatLength && !stopped; ) {
@@ -706,7 +712,9 @@ async function formatPrintf(context2) {
706
712
  const end = rawFormat ? rawFormat.indexOf(37, offset) : format3.indexOf("%", offset);
707
713
  const limit = end < 0 ? formatLength : end;
708
714
  const literal = rawFormat ? rawFormat.subarray(offset, limit) : format3.slice(offset, limit);
709
- const escaped3 = escapeBytes(literal);
715
+ const escaped3 = escapeBytes(literal, false, false, unicode);
716
+ for (const escape of unicodeErrors.splice(0)) await writeDiagnostic(context2.stderr, `printf: missing unicode digit for \\${escape}
717
+ `, context2.signal);
710
718
  await output(context2, escaped3.bytes);
711
719
  stopped = escaped3.stop;
712
720
  offset += literal.length;
@@ -735,7 +743,9 @@ async function formatPrintf(context2) {
735
743
  if (specifier === "b" || specifier === "s") {
736
744
  const suppliedValue = arguments_.values[suppliedIndex] ?? "";
737
745
  const raw = specifier === "b" && typeof suppliedValue === "string" ? suppliedValue : arguments_.bytes(suppliedIndex) ?? new Uint8Array();
738
- const escaped3 = specifier === "b" ? escapeBytes(raw, true, true) : { bytes: raw, stop: false };
746
+ const escaped3 = specifier === "b" ? escapeBytes(raw, true, true, unicode) : { bytes: raw, stop: false };
747
+ for (const escape of unicodeErrors.splice(0)) await writeDiagnostic(context2.stderr, `printf: missing unicode digit for \\${escape}
748
+ `, context2.signal);
739
749
  const bytes3 = escaped3.bytes.subarray(0, precision);
740
750
  const padding = " ".repeat(Math.max(0, width - bytes3.length));
741
751
  if (!flags3.includes("-")) await output(context2, padding);
@@ -4194,7 +4204,7 @@ async function* combinedInput(context2, names, state) {
4194
4204
  }
4195
4205
  }
4196
4206
  }
4197
- async function prefix(context2, source2, count2, bytes3, skip) {
4207
+ async function prefix(context2, source2, count2, bytes3, skip, delimiter) {
4198
4208
  let remaining = count2;
4199
4209
  if (!remaining && !skip) return;
4200
4210
  for await (const chunk of source2) {
@@ -4205,7 +4215,7 @@ async function prefix(context2, source2, count2, bytes3, skip) {
4205
4215
  offset = Math.min(chunk.length, remaining);
4206
4216
  remaining -= offset;
4207
4217
  } else {
4208
- for (; offset < chunk.length && remaining; offset++) if (chunk[offset] === 10) remaining--;
4218
+ for (; offset < chunk.length && remaining; offset++) if (chunk[offset] === delimiter) remaining--;
4209
4219
  }
4210
4220
  }
4211
4221
  if (skip) {
@@ -4216,12 +4226,12 @@ async function prefix(context2, source2, count2, bytes3, skip) {
4216
4226
  }
4217
4227
  }
4218
4228
  }
4219
- async function suffix(context2, source2, count2, bytes3, omit) {
4229
+ async function suffix(context2, source2, count2, bytes3, omit, delimiter) {
4220
4230
  let pending = [];
4221
4231
  let start = 0;
4222
4232
  let size = 0;
4223
4233
  const records5 = bytes3 ? source2 : (async function* () {
4224
- for await (const line of lines(source2)) yield line.terminated ? concatenate([line.bytes, Uint8Array.of(10)]) : line.bytes;
4234
+ for await (const line of lines(source2, delimiter)) yield line.terminated ? concatenate([line.bytes, Uint8Array.of(delimiter)]) : line.bytes;
4225
4235
  })();
4226
4236
  for await (const chunk of records5) {
4227
4237
  context2.signal.throwIfAborted();
@@ -4296,9 +4306,10 @@ function headTail(name2, maxTailFollowHandles = 64) {
4296
4306
  return define(name2, async (context2) => {
4297
4307
  const args = context2.args[0] && /^-[0-9]+$/u.test(context2.args[0]) ? ["-n", context2.args[0].slice(1), ...context2.args.slice(1)] : context2.args;
4298
4308
  const follow = name2 === "tail" ? parseTailFollow(args) : void 0;
4299
- const parsed = options(follow?.args ?? args, "n:c:qv", { lines: "n", bytes: "c", quiet: "q", silent: "q", verbose: "v" });
4309
+ const parsed = options(follow?.args ?? args, "n:c:qvz", { lines: "n", bytes: "c", quiet: "q", silent: "q", verbose: "v", "zero-terminated": "z" });
4300
4310
  if (parsed.flags.has("n") && parsed.flags.has("c")) throw new UsageError("cannot combine line and byte counts");
4301
4311
  const bytes3 = parsed.flags.has("c");
4312
+ const delimiter = parsed.flags.has("z") ? 0 : 10;
4302
4313
  const amount = value(parsed, bytes3 ? "c" : "n") ?? "10";
4303
4314
  const positive = amount.startsWith("+");
4304
4315
  const negative = amount.startsWith("-");
@@ -4312,7 +4323,7 @@ function headTail(name2, maxTailFollowHandles = 64) {
4312
4323
  bytes: bytes3,
4313
4324
  positive,
4314
4325
  headers: parsed.flags.has("v") || names.length > 1 && !parsed.flags.has("q")
4315
- }, maxTailFollowHandles, (target, source2) => positive ? prefix(target, source2, Math.max(0, count2 - 1), bytes3, true) : suffix(target, source2, count2, bytes3, false));
4326
+ }, maxTailFollowHandles, (target, source2) => positive ? prefix(target, source2, Math.max(0, count2 - 1), bytes3, true, delimiter) : suffix(target, source2, count2, bytes3, false, delimiter));
4316
4327
  await assertInputRequirements(context2, names);
4317
4328
  (0, command_requirements_exports.assertCommandRequirements)(context2, inspectedInputRequirements, [names.some((name3) => name3 !== "-") ? "file" : "stdin"]);
4318
4329
  let exitCode = 0;
@@ -4330,9 +4341,9 @@ function headTail(name2, maxTailFollowHandles = 64) {
4330
4341
  `);
4331
4342
  headerWritten = true;
4332
4343
  }
4333
- if (name2 === "head" && !negative) await prefix(context2, input(context2, file), count2, bytes3, false);
4334
- else if (name2 === "tail" && positive) await prefix(context2, input(context2, file), Math.max(0, count2 - 1), bytes3, true);
4335
- else await suffix(context2, input(context2, file), count2, bytes3, name2 === "head");
4344
+ if (name2 === "head" && !negative) await prefix(context2, input(context2, file), count2, bytes3, false, delimiter);
4345
+ else if (name2 === "tail" && positive) await prefix(context2, input(context2, file), Math.max(0, count2 - 1), bytes3, true, delimiter);
4346
+ else await suffix(context2, input(context2, file), count2, bytes3, name2 === "head", delimiter);
4336
4347
  } catch (error) {
4337
4348
  await diagnostic(context2, error);
4338
4349
  exitCode = 1;
@@ -4401,7 +4412,26 @@ function streamCommands(maxTeeTargets = 64, maxTailFollowHandles = 64) {
4401
4412
  }
4402
4413
  return [
4403
4414
  define("cat", async (context2) => {
4404
- 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" });
4415
+ 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" });
4416
+ if (parsed.flags.has("help")) {
4417
+ await output(context2, `Usage: cat [OPTION]... [FILE]...
4418
+ Concatenate FILEs to standard output. With no FILE, or FILE -, read standard input.
4419
+
4420
+ -n, --number Number all output lines
4421
+ -b, --number-nonblank Number nonempty output lines (overrides -n)
4422
+ -s, --squeeze-blank Suppress repeated empty output lines
4423
+ -E, --show-ends Display $ at each line end
4424
+ -T, --show-tabs Display TAB characters as ^I
4425
+ -v, --show-nonprinting Display nonprinting characters
4426
+ -A, --show-all Equivalent to -vET
4427
+ -e Equivalent to -vE
4428
+ -t Equivalent to -vT
4429
+ -u Accepted for compatibility; ignored
4430
+ --help Display this help and exit
4431
+ -- End options; remaining arguments are filenames
4432
+ `);
4433
+ return { exitCode: 0 };
4434
+ }
4405
4435
  await assertInputRequirements(context2, parsed.operands);
4406
4436
  if (parsed.flags.has("A")) for (const flag of ["v", "E", "T"]) parsed.flags.add(flag);
4407
4437
  if (parsed.flags.has("e")) {
@@ -12556,7 +12586,7 @@ async function execute(program, context2, files, quiet, budget, separator, outpu
12556
12586
  const character = pattern[offset];
12557
12587
  const lineEnd = character === "\n" && separator === "\n";
12558
12588
  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);
12559
- if (line.length + token.length >= 60) {
12589
+ if (character !== void 0 && !lineEnd && line.length + token.length >= 70) {
12560
12590
  await emit2(line + "\\" + separator);
12561
12591
  line = "";
12562
12592
  }
@@ -12717,6 +12747,14 @@ function sedCommand(options2 = {}) {
12717
12747
  separator = "\0";
12718
12748
  continue;
12719
12749
  }
12750
+ if (argument2 === "--quiet") {
12751
+ quiet = true;
12752
+ continue;
12753
+ }
12754
+ if (argument2 === "--regexp-extended") {
12755
+ extended = true;
12756
+ continue;
12757
+ }
12720
12758
  if (argument2.startsWith("--")) throw new ProgramError(`unsupported option '${argument2}'`);
12721
12759
  for (let position = 1; position < argument2.length; position++) {
12722
12760
  const flag = argument2[position];
@@ -14485,7 +14523,7 @@ function argumentsFor(args, budget) {
14485
14523
  argumentBytes += import_buffer.Buffer.byteLength(argument2);
14486
14524
  if (argumentBytes > budget.limits.maxInputBytes) throw new JqLimitError("maxInputBytes");
14487
14525
  }
14488
- const options2 = { raw: false, rawInput: false, joinOutput: false, compact: false, slurp: false, nullInput: false, exitStatus: false, source: void 0, programFile: void 0, files: [], variables: /* @__PURE__ */ new Map() };
14526
+ const options2 = { raw: false, rawInput: false, joinOutput: false, compact: false, sortKeys: false, slurp: false, nullInput: false, exitStatus: false, source: void 0, programFile: void 0, files: [], variables: /* @__PURE__ */ new Map() };
14489
14527
  const named2 = object();
14490
14528
  let ended = false;
14491
14529
  let variableBytes = 0;
@@ -14526,10 +14564,10 @@ function argumentsFor(args, budget) {
14526
14564
  options2.programFile = operand();
14527
14565
  continue;
14528
14566
  }
14529
- const long = { "--raw-output": "r", "--raw-input": "R", "--join-output": "j", "--compact-output": "c", "--slurp": "s", "--null-input": "n", "--exit-status": "e" };
14567
+ const long = { "--raw-output": "r", "--raw-input": "R", "--join-output": "j", "--compact-output": "c", "--sort-keys": "S", "--slurp": "s", "--null-input": "n", "--exit-status": "e" };
14530
14568
  if (!ended && argument2.startsWith("-") && argument2 !== "-") {
14531
14569
  const flags3 = Object.hasOwn(long, argument2) ? long[argument2] : argument2.startsWith("--") ? "" : argument2.slice(1);
14532
- if (!flags3 || !/^[rRjcsne]+$/u.test(flags3)) throw new JqError(`unsupported option ${argument2}`, 2);
14570
+ if (!flags3 || [...flags3].some((flag) => !"rRjcSsne".includes(flag))) throw new JqError(`unsupported option ${argument2}`, 2);
14533
14571
  for (const flag of flags3) {
14534
14572
  if (flag === "r") options2.raw = true;
14535
14573
  else if (flag === "R") options2.rawInput = true;
@@ -14537,6 +14575,7 @@ function argumentsFor(args, budget) {
14537
14575
  options2.joinOutput = true;
14538
14576
  options2.raw = true;
14539
14577
  } else if (flag === "c") options2.compact = true;
14578
+ else if (flag === "S") options2.sortKeys = true;
14540
14579
  else if (flag === "s") options2.slurp = true;
14541
14580
  else if (flag === "n") options2.nullInput = true;
14542
14581
  else options2.exitStatus = true;
@@ -14662,7 +14701,8 @@ async function execute2(context2, limits) {
14662
14701
  if (++budget.results > limits.maxResults) throw new JqLimitError("maxResults");
14663
14702
  const remaining = limits.maxOutputBytes - budget.outputBytes;
14664
14703
  const suffix2 = options2.joinOutput ? "" : "\n";
14665
- const text3 = options2.raw && typeof result === "string" ? result : await stringify(result, budget, !options2.compact, Math.max(0, remaining - suffix2.length), "maxOutputBytes");
14704
+ const output2 = options2.sortKeys ? await sortObjectKeys(result, budget) : result;
14705
+ const text3 = options2.raw && typeof output2 === "string" ? output2 : await stringify(output2, budget, !options2.compact, Math.max(0, remaining - suffix2.length), "maxOutputBytes");
14666
14706
  const bytes3 = import_buffer.Buffer.from(`${text3}${suffix2}`);
14667
14707
  if (bytes3.byteLength > remaining) throw new JqLimitError("maxOutputBytes");
14668
14708
  budget.outputBytes += bytes3.byteLength;
@@ -15053,6 +15093,9 @@ function parse6(args) {
15053
15093
  return output2;
15054
15094
  };
15055
15095
  switch (flag) {
15096
+ case "help":
15097
+ result.help = true;
15098
+ break;
15056
15099
  case "e":
15057
15100
  case "regexp":
15058
15101
  result.explicitPatterns = true;
@@ -15298,7 +15341,7 @@ function parse6(args) {
15298
15341
  }
15299
15342
  }
15300
15343
  if (result.before > 1e5 || result.after > 1e5) throw new SearchError("context limit exceeded");
15301
- if (result.mode !== "files" && !result.explicitPatterns) {
15344
+ if (!result.help && result.mode !== "files" && !result.explicitPatterns) {
15302
15345
  const pattern = operands.shift();
15303
15346
  if (pattern === void 0) throw new SearchError("a search pattern is required");
15304
15347
  result.patterns.push(pattern);
@@ -15900,6 +15943,65 @@ function createRgCommand(executor, options2 = {}) {
15900
15943
  try {
15901
15944
  const limits = new Limits(context2, options2);
15902
15945
  args = parse6(context2.args);
15946
+ if (args.help) {
15947
+ await limits.output(import_buffer.Buffer.from(`Usage: rg [OPTIONS] PATTERN [PATH ...]
15948
+ Search files for PATTERN. PATH - reads standard input.
15949
+ Default input depends on shell configuration.
15950
+
15951
+ -e, --regexp=PATTERN Add a pattern (repeatable)
15952
+ -f, --file=FILE Read patterns from FILE
15953
+ -F, --fixed-strings Use fixed strings
15954
+ -i, --ignore-case Ignore case distinctions
15955
+ -s, --case-sensitive Match case sensitively
15956
+ -S, --smart-case Infer case sensitivity from the pattern
15957
+ -v, --invert-match Select nonmatching lines
15958
+ -w, --word-regexp Match whole words
15959
+ -x, --line-regexp Match whole lines
15960
+ -n, --line-number Print line numbers
15961
+ -N, --no-line-number Suppress line numbers
15962
+ -H, --with-filename Print filenames
15963
+ -I, --no-filename Suppress filenames
15964
+ -o, --only-matching Print matching parts
15965
+ -l, --files-with-matches Print filenames with matches
15966
+ --files-without-match Print filenames without matches
15967
+ --files List files without searching
15968
+ -c, --count Print matching line counts
15969
+ --count-matches Print match counts
15970
+ --json Emit JSON events
15971
+ -q, --quiet Suppress normal output
15972
+ -g, --glob=GLOB Include or exclude paths (repeatable)
15973
+ --iglob=GLOB Case-insensitive glob
15974
+ -t, --type=TYPE Include a file type
15975
+ -T, --type-not=TYPE Exclude a file type
15976
+ -., --hidden Search hidden files
15977
+ -L, --follow Follow symbolic links
15978
+ --no-ignore Disable ignore-file filtering
15979
+ -u, --unrestricted Relax ignore, hidden and binary filtering (repeatable)
15980
+ -a, --text Search binary files as text
15981
+ -A, --after-context=NUM Print NUM lines after matches
15982
+ -B, --before-context=NUM Print NUM lines before matches
15983
+ -C, --context=NUM Print NUM lines before and after matches
15984
+ -m, --max-count=NUM Limit matching lines per file
15985
+ --max-depth=NUM Limit directory traversal depth (maximum 128)
15986
+ --column Print columns
15987
+ -b, --byte-offset Print byte offsets
15988
+ -0, --null NUL-terminate filenames
15989
+ --null-data Use NUL-delimited records
15990
+ --crlf Handle CRLF line endings
15991
+ --heading Group output by filename
15992
+ --sort=path Sort paths
15993
+ --color=never Disable color
15994
+ --help Display this help and exit
15995
+ -- End options
15996
+
15997
+ Exit status: 0 when a match is found, 1 when none is found, 2 on error.
15998
+ Regular expression support depends on the configured regex executor.
15999
+ The default supports UTF-8 literals and bounded ASCII regular expressions.
16000
+ Regex operators: . ^ $ [...] (...) | * + ? {n,m}; -F treats patterns literally.
16001
+ Word/case flags and extended regex syntax require a configured executor.
16002
+ `));
16003
+ return { exitCode: 0 };
16004
+ }
15903
16005
  if (args.mode !== "files" && args.patternFiles.includes("-") && args.paths.includes("-")) {
15904
16006
  throw new SearchError("cannot search stdin while also reading patterns from stdin");
15905
16007
  }
@@ -15958,7 +16060,51 @@ var maxPatternCount = 1024;
15958
16060
  function createGrepCommands(executor) {
15959
16061
  return [{ name: "grep", filesystemRequirements: grepRequirements, execute: (context2) => withRegexSession(context2, executor, async (session) => {
15960
16062
  try {
15961
- 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" });
16063
+ const contextLengths = /* @__PURE__ */ new Map();
16064
+ 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) => {
16065
+ if (!["A", "B", "C"].includes(key)) return;
16066
+ const text3 = context2.args[index].slice(offset);
16067
+ try {
16068
+ contextLengths.set(key, integer(text3));
16069
+ } catch {
16070
+ throw new UsageError(`${text3}: invalid context length argument`);
16071
+ }
16072
+ });
16073
+ if (parsed.flags.has("help")) {
16074
+ await output(context2, `Usage: grep [OPTION]... PATTERN [FILE]...
16075
+ Print lines matching PATTERN. With no FILE, or FILE -, read standard input.
16076
+
16077
+ -E, --extended-regexp Use extended regular expressions
16078
+ -F, --fixed-strings Use fixed strings
16079
+ -e, --regexp=PATTERN Add a pattern (repeatable)
16080
+ -f, --file=FILE Read patterns from FILE
16081
+ -i, --ignore-case Ignore case distinctions
16082
+ -v, --invert-match Select nonmatching lines
16083
+ -w, --word-regexp Match whole words
16084
+ -x, --line-regexp Match whole lines
16085
+ -n, --line-number Print line numbers
16086
+ -H, --with-filename Print filenames
16087
+ -h, --no-filename Suppress filenames
16088
+ -o, --only-matching Print only matching parts
16089
+ -c, --count Print matching line counts
16090
+ -l, --files-with-matches Print filenames with matches
16091
+ -L, --files-without-match Print filenames without matches
16092
+ -q, --quiet, --silent Suppress normal output
16093
+ -m, --max-count=NUM Stop after NUM selected lines per file
16094
+ -A, --after-context=NUM Print NUM lines after selected lines
16095
+ -B, --before-context=NUM Print NUM lines before selected lines
16096
+ -C, --context=NUM Print NUM lines before and after selected lines
16097
+ -s, --no-messages Suppress file error messages
16098
+ -a, --text Process input as text
16099
+ -z, --null-data Use NUL-delimited records
16100
+ --help Display this help and exit
16101
+ -- End options
16102
+
16103
+ Exit status: 0 when a line is selected, 1 when none is selected, 2 on error.
16104
+ Regular expression support depends on the configured regex executor.
16105
+ `);
16106
+ return { exitCode: 0 };
16107
+ }
15962
16108
  let positionalPattern;
15963
16109
  if (!parsed.flags.has("e") && !parsed.flags.has("f")) {
15964
16110
  if (!parsed.operands.length) throw new UsageError("missing pattern");
@@ -16020,13 +16166,30 @@ function createGrepCommands(executor) {
16020
16166
  const batchSize = Number.isFinite(maxCount) || parsed.flags.has("q") || parsed.flags.has("l") || parsed.flags.has("L") ? 1 : 128;
16021
16167
  const delimiter = parsed.flags.has("z") ? "\0" : "\n";
16022
16168
  const extractMatches = parsed.flags.has("o") && !["c", "q", "l", "L", "v"].some((flag) => parsed.flags.has(flag));
16169
+ const displayLines = !["c", "q", "l", "L"].some((flag) => parsed.flags.has(flag));
16170
+ const withContext = contextLengths.size > 0 && displayLines && !(parsed.flags.has("o") && parsed.flags.has("v"));
16171
+ const before = withContext ? contextLengths.get("B") ?? contextLengths.get("C") ?? 0 : 0;
16172
+ const after = withContext ? contextLengths.get("A") ?? contextLengths.get("C") ?? 0 : 0;
16173
+ let emittedGroup = false;
16023
16174
  let anySelected = false;
16024
16175
  let failed = false;
16025
16176
  for (const name2 of names) {
16026
16177
  let count2 = 0;
16027
16178
  let number6 = 0;
16179
+ let lastCovered = 0;
16180
+ let remainingAfter = 0;
16181
+ let pendingBytes = 0;
16182
+ const pending = /* @__PURE__ */ new Map();
16028
16183
  const named2 = name2 === "-" ? "(standard input)" : name2;
16029
- const prefix3 = (lineNumber = false) => `${!parsed.flags.has("h") && (parsed.flags.has("H") || names.length > 1) ? `${named2}:` : ""}${lineNumber && parsed.flags.has("n") ? `${number6}:` : ""}`;
16184
+ 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}` : ""}`;
16185
+ const emitContext = async (line, position) => {
16186
+ if (!parsed.flags.has("o")) {
16187
+ await output(context2, prefix3(true, position, "-"));
16188
+ await output(context2, line.bytes);
16189
+ await output(context2, delimiter);
16190
+ }
16191
+ lastCovered = position;
16192
+ };
16030
16193
  try {
16031
16194
  const available2 = new AvailableRecords(parsed.flags.has("z") ? 0 : 10, bufferLimit);
16032
16195
  const source2 = name2 === "-" ? input(context2) : requiredFileInput(context2, grepRequirements, "file", name2, bufferLimit);
@@ -16037,12 +16200,40 @@ function createGrepCommands(executor) {
16037
16200
  context2.signal.throwIfAborted();
16038
16201
  number6++;
16039
16202
  const found = results[index];
16040
- if (found.length > 0 === parsed.flags.has("v")) continue;
16203
+ const selected = count2 < maxCount && found.length > 0 !== parsed.flags.has("v");
16204
+ if (!selected) {
16205
+ if (remainingAfter > 0) {
16206
+ await emitContext(line, number6);
16207
+ remainingAfter--;
16208
+ if (count2 >= maxCount && remainingAfter === 0) break records;
16209
+ } else if (before > 0) {
16210
+ if (pending.size >= before) {
16211
+ const oldest = pending.keys().next().value;
16212
+ pendingBytes -= pending.get(oldest).bytes.length + 1;
16213
+ pending.delete(oldest);
16214
+ }
16215
+ const size = line.bytes.length + 1;
16216
+ if (size > bufferLimit - pendingBytes) throw new UsageError(`context byte limit exceeded (${bufferLimit} bytes)`);
16217
+ pending.set(number6, { bytes: Uint8Array.from(line.bytes), terminated: line.terminated });
16218
+ pendingBytes += size;
16219
+ }
16220
+ continue;
16221
+ }
16041
16222
  count2++;
16042
16223
  if (!parsed.flags.has("L")) anySelected = true;
16043
16224
  if (parsed.flags.has("q")) return { exitCode: 0 };
16044
16225
  if (parsed.flags.has("l") || parsed.flags.has("L")) break records;
16045
16226
  if (!parsed.flags.has("c")) {
16227
+ if (withContext) {
16228
+ const first = pending.keys().next().value ?? number6;
16229
+ if (emittedGroup && (lastCovered === 0 || first > lastCovered + 1)) await output(context2, "--\n");
16230
+ for (const [position, previous] of pending) await emitContext(previous, position);
16231
+ pending.clear();
16232
+ pendingBytes = 0;
16233
+ remainingAfter = after;
16234
+ lastCovered = number6;
16235
+ emittedGroup = true;
16236
+ }
16046
16237
  if (parsed.flags.has("o")) {
16047
16238
  if (!parsed.flags.has("v")) {
16048
16239
  let end = -1;
@@ -16060,7 +16251,7 @@ function createGrepCommands(executor) {
16060
16251
  await output(context2, delimiter);
16061
16252
  }
16062
16253
  }
16063
- if (count2 >= maxCount) break records;
16254
+ if (count2 >= maxCount && remainingAfter === 0) break records;
16064
16255
  }
16065
16256
  }
16066
16257
  if (parsed.flags.has("l") && count2 > 0 || parsed.flags.has("L") && count2 === 0) {
@@ -25820,6 +26011,7 @@ async function parseOptions2(context2, limits) {
25820
26011
  if (values.has(flag) && value2 === void 0) value2 = context2.args[++index];
25821
26012
  if (values.has(flag) && value2 === void 0) fail(`missing argument for --${name2}`);
25822
26013
  if (!values.has(flag) && value2 !== void 0) fail(`option --${name2} does not take an argument`);
26014
+ if (flag === "help") return "help";
25823
26015
  await apply(flag, value2);
25824
26016
  } else if (!end && (argument2.startsWith("-") && argument2 !== "-" || index === 0 && /^[ctxzvfCT]+$/u.test(argument2))) {
25825
26017
  const old = !argument2.startsWith("-");
@@ -31590,6 +31782,33 @@ function createTarCommand(options2 = {}) {
31590
31782
  const context2 = { ...original, signal };
31591
31783
  try {
31592
31784
  const parsed = await parseOptions2(context2, limits);
31785
+ if (parsed === "help") {
31786
+ await (0, contracts_exports.writeBytes)(context2.stdout, import_buffer.Buffer.from(`Usage: tar [OPTION]... [FILE]...
31787
+ Create, list or extract USTAR/PAX archives in the virtual filesystem.
31788
+
31789
+ -c, --create Create an archive
31790
+ -t, --list List archive members
31791
+ -x, --extract, --get Extract archive members
31792
+ -f, --file=ARCHIVE Use ARCHIVE (default - for standard input/output)
31793
+ -z, --gzip Use gzip compression
31794
+ -v, --verbose List processed members
31795
+ -C, --directory=DIR Change directory for subsequent operands
31796
+ -T, --files-from=FILE Read filenames from FILE (- for standard input)
31797
+ --null Read NUL-delimited filenames; implies verbatim names
31798
+ --no-null Read newline-delimited filenames
31799
+ --verbatim-files-from Treat file-list entries as literal filenames
31800
+ --no-verbatim-files-from Enable supported file-list directory options
31801
+ --exclude=PATTERN Exclude paths (place before source operands)
31802
+ --strip-components=NUM Remove leading components when reading archives
31803
+ --format=FORMAT Create pax (default), posix or ustar archives
31804
+ --help Display this help and exit
31805
+ -- End options; remaining arguments are filenames
31806
+
31807
+ Exactly one of -c, -t or -x is required for archive operations.
31808
+ Examples: tar cf archive.tar file; tar tf archive.tar; tar xf archive.tar -C directory
31809
+ `), signal);
31810
+ return { exitCode: 0 };
31811
+ }
31593
31812
  const budget = new Budget14(context2, limits);
31594
31813
  if (parsed.mode === "c") {
31595
31814
  const prepared = await manifest(context2, parsed, budget);