@poe-platform/safe-bash 0.1.782 → 0.1.783

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 (116) hide show
  1. package/README.md +40 -0
  2. package/dist/office-package/zip-sync.d.ts +2 -0
  3. package/dist/office-package/zip-sync.js +111 -0
  4. package/dist/safe-bash/chunks/chunk-4FDQJUFW.js +3464 -0
  5. package/dist/safe-bash/chunks/csvkit-K55OYAQC.js +1564 -0
  6. package/dist/safe-bash/chunks/ffmpeg-BEFTQ6DZ.js +60 -0
  7. package/dist/safe-bash/chunks/gh-HQWOWLWE.js +41 -0
  8. package/dist/safe-bash/chunks/git-UFNPAOYZ.js +52 -0
  9. package/dist/safe-bash/chunks/imagemagick-53BMHH6D.js +134 -0
  10. package/dist/safe-bash/chunks/implementation-QUTAAYMT.js +105 -0
  11. package/dist/safe-bash/chunks/pdfimages-4OYI6FLG.js +73 -0
  12. package/dist/safe-bash/chunks/pdfinfo-I7U6TQPP.js +153 -0
  13. package/dist/safe-bash/chunks/pdftk-SUA6FMHI.js +79 -0
  14. package/dist/safe-bash/chunks/pdftoppm-4C5DGEWX.js +139 -0
  15. package/dist/safe-bash/chunks/pdftotext-Y4WI225Y.js +118 -0
  16. package/dist/safe-bash/chunks/qpdf-IORB4RV5.js +68 -0
  17. package/dist/safe-bash/chunks/sips-WHAMJFEU.js +77 -0
  18. package/dist/safe-bash/chunks/soffice-SYEK6WJS.js +89 -0
  19. package/dist/safe-bash/chunks/wkhtmltopdf-ZIICWJLF.js +85 -0
  20. package/dist/safe-bash/command-chunks/chunk-2LP3VMPA.js +58 -0
  21. package/dist/safe-bash/command-chunks/{chunk-CG4JSOK2.js → chunk-3HDIDEUJ.js} +1 -1
  22. package/dist/safe-bash/command-chunks/chunk-4DSJDVBM.js +2897 -0
  23. package/dist/safe-bash/command-chunks/{chunk-GBHSE6ZO.js → chunk-5GRLAARV.js} +1 -1
  24. package/dist/safe-bash/command-chunks/chunk-7OKDCM5U.js +112 -0
  25. package/dist/safe-bash/command-chunks/{chunk-FH3D75FC.js → chunk-ADCGH6A7.js} +1 -1
  26. package/dist/safe-bash/command-chunks/{chunk-MTKXVRXL.js → chunk-DREUDEQG.js} +1 -1
  27. package/dist/safe-bash/command-chunks/{chunk-ADBFNLLK.js → chunk-FXYWQ6S4.js} +16 -14
  28. package/dist/safe-bash/command-chunks/{chunk-Y2KHC6TZ.js → chunk-IDKD76KR.js} +5 -3
  29. package/dist/safe-bash/command-chunks/{chunk-K6KBYLQC.js → chunk-JUDOV5MJ.js} +1 -1
  30. package/dist/safe-bash/command-chunks/{chunk-3ZK5F23O.js → chunk-L3MLMXL4.js} +1 -1
  31. package/dist/safe-bash/command-chunks/{chunk-E5TEVROY.js → chunk-PFBJR2PY.js} +4 -4
  32. package/dist/safe-bash/command-chunks/{chunk-YGYOVXTO.js → chunk-UUR2S7AD.js} +9 -5
  33. package/dist/safe-bash/command-chunks/chunk-VIVYKW7Q.js +101 -0
  34. package/dist/safe-bash/command-chunks/{chunk-I5GLTNVH.js → chunk-X4P42NYK.js} +2 -27
  35. package/dist/safe-bash/command-chunks/{chunk-XF6TXYLD.js → chunk-Z57TV6TC.js} +4 -54
  36. package/dist/safe-bash/command-chunks/{chunk-QDPRSPHQ.js → chunk-Z64BW7CG.js} +1 -1
  37. package/dist/safe-bash/command-chunks/{chunk-X3IVPNC3.js → chunk-Z7TYZG3A.js} +5 -3
  38. package/dist/safe-bash/command-chunks/{chunk-GZXLPWT5.js → chunk-ZF3ZVGQC.js} +259 -258
  39. package/dist/safe-bash/command-chunks/{pptx-ZL6L7KP2-QVZEYFUV.js → pptx-KY2OJWZW-76LBHCHD.js} +4 -3
  40. package/dist/safe-bash/commands/csvkit/index.d.ts +1 -8
  41. package/dist/safe-bash/commands/csvkit/index.js +5 -1639
  42. package/dist/safe-bash/commands/csvkit/sync.d.ts +9 -0
  43. package/dist/safe-bash/commands/csvkit/sync.js +1639 -0
  44. package/dist/safe-bash/commands/pandoc/implementation.d.ts +8 -0
  45. package/dist/safe-bash/commands/pandoc/implementation.js +92 -0
  46. package/dist/safe-bash/commands/pandoc/index.d.ts +2 -6
  47. package/dist/safe-bash/commands/pandoc/index.js +2 -90
  48. package/dist/safe-bash/core.browser.js +808 -6271
  49. package/dist/safe-bash/core.d.ts +17 -16
  50. package/dist/safe-bash/core.js +17 -16
  51. package/dist/safe-bash/lazy-gh.d.ts +10 -0
  52. package/dist/safe-bash/lazy-gh.js +30 -0
  53. package/dist/safe-bash/lazy-optional.d.ts +499 -0
  54. package/dist/safe-bash/lazy-optional.js +609 -0
  55. package/dist/safe-bash/plugins/composition.d.ts +1 -1
  56. package/dist/safe-bash/plugins/composition.js +1 -1
  57. package/dist/safe-bash/plugins/lazy-command.d.ts +9 -0
  58. package/dist/safe-bash/plugins/lazy-command.js +57 -0
  59. package/dist/safe-bash/shell/runtime.js +24 -25
  60. package/dist/safe-bash-command-csvkit/cli/lexical.d.ts +3 -0
  61. package/dist/safe-bash-command-csvkit/cli/parser.d.ts +1 -2
  62. package/dist/safe-bash-command-csvkit/codecs/python.js +3 -2
  63. package/dist/safe-bash-command-csvkit/codecs/utf8.js +2 -1
  64. package/dist/safe-bash-command-csvkit/index.js +453 -3270
  65. package/dist/safe-bash-command-csvkit/sync-support.d.ts +7 -0
  66. package/dist/safe-bash-command-csvkit/sync-support.js +31 -0
  67. package/dist/safe-bash-command-gh/index.js +25 -17
  68. package/dist/safe-bash-command-git/index.js +6 -10
  69. package/dist/safe-bash-command-imagemagick/index.js +2 -2
  70. package/dist/safe-bash-command-pandoc/citeproc-filters.js +4 -2
  71. package/dist/safe-bash-command-pandoc/command.js +8 -6
  72. package/dist/safe-bash-command-pandoc/index.js +8 -6
  73. package/dist/safe-bash-command-pandoc/lua-filters.js +3 -2
  74. package/dist/safe-bash-command-pandoc/options.d.ts +5 -0
  75. package/dist/safe-bash-command-pandoc/options.js +93 -0
  76. package/dist/safe-bash-command-sips/index.js +2 -2
  77. package/dist/safe-bash-command-soffice/index.d.ts +1 -2
  78. package/dist/safe-bash-command-soffice/index.js +22 -18
  79. package/dist/safe-bash-command-ssconvert/commands.js +2 -2
  80. package/dist/safe-bash-command-ssconvert/core.js +2 -2
  81. package/dist/safe-bash-command-ssconvert/formats/csv.js +2 -2
  82. package/dist/safe-bash-command-ssconvert/formats/xls.js +3 -3
  83. package/dist/safe-bash-command-ssconvert/formats/xlsx.js +3 -3
  84. package/dist/safe-bash-command-timeout/index.js +3 -3
  85. package/dist/safe-bash-command-yq/index.js +5 -5
  86. package/dist/safe-bash-compression-engine/bounded-codec.js +3 -3
  87. package/dist/safe-bash-compression-engine/codec-loader.js +2 -2
  88. package/dist/safe-bash-compression-engine/files.js +7 -7
  89. package/dist/safe-bash-compression-engine/index.js +6 -6
  90. package/dist/safe-bash-compression-engine/operand.js +7 -7
  91. package/dist/safe-bash-compression-engine/stream.js +6 -6
  92. package/dist/safe-bash-compression-engine/zstd-decode.js +5 -5
  93. package/dist/safe-bash-contracts/diagnostics.js +3 -3
  94. package/dist/safe-bash-contracts/escaping.js +9 -9
  95. package/dist/safe-bash-contracts/filesystem-descriptor.js +1 -1
  96. package/dist/safe-bash-contracts/filesystem-output.js +10 -10
  97. package/dist/safe-bash-contracts/index.js +40 -40
  98. package/dist/safe-bash-io-engine/commands/search/requirements.js +4 -4
  99. package/dist/safe-bash-io-engine/commands/text-programs/shared.js +4 -4
  100. package/dist/safe-bash-io-engine/internal.d.ts +9 -0
  101. package/dist/safe-bash-io-engine/internal.js +3 -3
  102. package/dist/safe-bash-query-engine/index.js +6 -6
  103. package/dist/safe-bash-query-engine/interpreter.js +5 -5
  104. package/dist/safe-bash-query-engine/query-core.js +6 -6
  105. package/dist/safe-bash-regex-engine/execution/bounded-provider.js +3 -3
  106. package/dist/safe-bash-regex-engine/index.js +2 -2
  107. package/dist/safe-bash-regex-engine/text/regex.js +2 -2
  108. package/dist/safe-bash-xml-engine/index.js +3 -3
  109. package/package.json +4 -4
  110. package/dist/safe-bash/command-chunks/{chunk-DC52GWRK.js → chunk-BUKYQBXO.js} +13 -13
  111. package/dist/safe-bash/command-chunks/{chunk-QJ3ONEBI.js → chunk-DEH3CMGL.js} +3 -3
  112. package/dist/safe-bash/command-chunks/{chunk-Y64PA6IA.js → chunk-KHZZ4V3L.js} +3 -3
  113. package/dist/safe-bash/command-chunks/{chunk-I7PKIGII.js → chunk-QIRUOY2W.js} +3 -3
  114. package/dist/safe-bash/command-chunks/{chunk-HQG2IBZL.js → chunk-TOSM3T3A.js} +6 -6
  115. package/dist/safe-bash/command-chunks/{chunk-F4IQCXZG.js → chunk-VBZMCL23.js} +4 -4
  116. package/dist/safe-bash/command-chunks/{chunk-J2NPH7DO.js → chunk-W2T7JWT3.js} +3 -3
@@ -0,0 +1,609 @@
1
+ import { createGhCommands, ghMetadata } from "./lazy-gh.js";
2
+ import { validatePandocOptions } from "../safe-bash-command-pandoc/options.js";
3
+ import { createLazyCommandLoader, createLazyCommands, lazyCommandPlugin } from "./plugins/lazy-command.js";
4
+ import { CommandRegistry } from "./contracts/command.js";
5
+ const loadffmpeg = createLazyCommandLoader(() => import("./commands/ffmpeg/index.js"));
6
+ const ffmpegMetadata = [
7
+ {
8
+ name: "ffmpeg",
9
+ description: "Multimedia converter, merger, and stream processor powered by pluggable ASTs"
10
+ },
11
+ {
12
+ name: "ffprobe",
13
+ description: "Multimedia stream analyzer powered by pluggable ASTs"
14
+ }
15
+ ];
16
+ export const createFfmpegCommand = (...args) => {
17
+ const metadata = ffmpegMetadata.find((item) => item.name === "ffmpeg");
18
+ if (!metadata)
19
+ throw new TypeError("Unknown ffmpeg command");
20
+ return createLazyCommands([metadata], async () => {
21
+ const module = await loadffmpeg();
22
+ return () => [module.createFfmpegCommand(...args)];
23
+ })[0];
24
+ };
25
+ export const createFfprobeCommand = (...args) => {
26
+ const metadata = ffmpegMetadata.find((item) => item.name === "ffprobe");
27
+ if (!metadata)
28
+ throw new TypeError("Unknown ffmpeg command");
29
+ return createLazyCommands([metadata], async () => {
30
+ const module = await loadffmpeg();
31
+ return () => [module.createFfprobeCommand(...args)];
32
+ })[0];
33
+ };
34
+ export const createFfmpegCommands = (...args) => {
35
+ const definitions = createLazyCommands(ffmpegMetadata, async () => {
36
+ const module = await loadffmpeg();
37
+ return () => module.createFfmpegCommands(...args);
38
+ });
39
+ return Object.freeze(Object.assign([definitions[0], definitions[1]], {
40
+ ffmpeg: definitions[0],
41
+ ffprobe: definitions[1]
42
+ }));
43
+ };
44
+ export const ffmpegCommands = (options = {}) => lazyCommandPlugin("ffmpeg-commands", createFfmpegCommands(options), options.replace ?? false);
45
+ const loadgit = createLazyCommandLoader(() => import("./commands/git/index.js"));
46
+ const gitMetadata = [
47
+ {
48
+ name: "git",
49
+ description: "Git repositories in the virtual filesystem"
50
+ }
51
+ ];
52
+ export const gitCommands = (options = {}) => lazyCommandPlugin("git-commands", createGitCommands(options), options.replace ?? false);
53
+ export const createGitCommands = (...args) => {
54
+ const definitions = createLazyCommands(gitMetadata, async () => {
55
+ const module = await loadgit();
56
+ return () => module.createGitCommands(...args);
57
+ });
58
+ return definitions;
59
+ };
60
+ export const createGitCommand = (...args) => {
61
+ const metadata = gitMetadata.find((item) => item.name === "git");
62
+ if (!metadata)
63
+ throw new TypeError("Unknown git command");
64
+ return createLazyCommands([metadata], async () => {
65
+ const module = await loadgit();
66
+ return () => [module.createGitCommand(...args)];
67
+ })[0];
68
+ };
69
+ const loadsoffice = createLazyCommandLoader(() => import("./commands/soffice/index.js"));
70
+ const sofficeMetadata = [
71
+ {
72
+ name: "soffice",
73
+ description: "Headless document/spreadsheet/presentation to PDF and CSV converter via @poe-code/pdf-ast"
74
+ },
75
+ {
76
+ name: "libreoffice",
77
+ description: "Headless LibreOffice document/spreadsheet/presentation to PDF converter via @poe-code/pdf-ast"
78
+ }
79
+ ];
80
+ export const createSofficeCommand = (...args) => {
81
+ const metadata = sofficeMetadata.find((item) => item.name === "soffice");
82
+ if (!metadata)
83
+ throw new TypeError("Unknown soffice command");
84
+ return createLazyCommands([metadata], async () => {
85
+ const module = await loadsoffice();
86
+ return () => [module.createSofficeCommand(...args)];
87
+ })[0];
88
+ };
89
+ export const sofficeCommands = (options = {}) => lazyCommandPlugin("soffice", createSofficeCommands(options), options.replace ?? false);
90
+ export const createSofficeCommands = (...args) => {
91
+ const definitions = createLazyCommands(sofficeMetadata, async () => {
92
+ const module = await loadsoffice();
93
+ return () => module.createSofficeCommands(...args);
94
+ });
95
+ return definitions;
96
+ };
97
+ const loadpandoc = createLazyCommandLoader(() => import("./commands/pandoc/implementation.js"));
98
+ const pandocMetadata = [
99
+ {
100
+ name: "pandoc",
101
+ description: "Convert documents with the original bounded TypeScript SDK"
102
+ }
103
+ ];
104
+ export const pandocCommands = (options = {}) => {
105
+ let hasCommand;
106
+ const command = createPandocCommand(options, (name) => hasCommand?.(name) ?? false);
107
+ return {
108
+ name: "pandoc",
109
+ setup(host) {
110
+ hasCommand = (name) => host.commands.has(name);
111
+ host.commands.register(command, { replace: options.replace ?? false });
112
+ }
113
+ };
114
+ };
115
+ export const createPandocCommands = (...args) => {
116
+ validatePandocOptions(args[0] === undefined ? {} : args[0]);
117
+ const definitions = createLazyCommands(pandocMetadata, async () => {
118
+ const module = await loadpandoc();
119
+ return () => module.createPandocCommands(...args);
120
+ });
121
+ return definitions;
122
+ };
123
+ export const createPandocCommand = (...args) => {
124
+ validatePandocOptions(args[0] === undefined ? {} : args[0]);
125
+ const metadata = pandocMetadata.find((item) => item.name === "pandoc");
126
+ if (!metadata)
127
+ throw new TypeError("Unknown pandoc command");
128
+ return createLazyCommands([metadata], async () => {
129
+ const module = await loadpandoc();
130
+ return () => [module.createPandocCommand(...args)];
131
+ })[0];
132
+ };
133
+ const loadssconvert = createLazyCommandLoader(() => import("../safe-bash-command-ssconvert/index.js"));
134
+ const loadSelectedSsconvert = createLazyCommandLoader(() => import("../safe-bash-command-ssconvert/commands.js"));
135
+ const ssconvertMetadata = [
136
+ {
137
+ name: "ssconvert",
138
+ description: "Explicitly bound TypeScript spreadsheet conversion engine"
139
+ }
140
+ ];
141
+ export const createSsconvertCommand = (...args) => {
142
+ const metadata = ssconvertMetadata.find((item) => item.name === "ssconvert");
143
+ if (!metadata)
144
+ throw new TypeError("Unknown ssconvert command");
145
+ return createLazyCommands([metadata], async () => {
146
+ const module = await (args[0]?.formats === undefined
147
+ ? loadssconvert()
148
+ : loadSelectedSsconvert());
149
+ return () => [module.createSsconvertCommand(...args)];
150
+ })[0];
151
+ };
152
+ export const ssconvertCommands = (options = {}) => lazyCommandPlugin("ssconvert-commands", createSsconvertCommands(options), options.replace ?? false);
153
+ export const createSsconvertCommands = (...args) => {
154
+ const definitions = createLazyCommands(ssconvertMetadata, async () => {
155
+ const module = await (args[0]?.formats === undefined
156
+ ? loadssconvert()
157
+ : loadSelectedSsconvert());
158
+ return () => module.createSsconvertCommands(...args);
159
+ });
160
+ return definitions;
161
+ };
162
+ const loadpdfinfo = createLazyCommandLoader(() => import("./commands/pdfinfo/index.js"));
163
+ const pdfinfoMetadata = [
164
+ {
165
+ name: "pdfinfo",
166
+ description: "Extract PDF metadata, page boxes, encryption, and structure via @poe-code/pdf-ast"
167
+ },
168
+ {
169
+ name: "pdfunite",
170
+ description: "Merge multiple PDF documents into a single PDF via @poe-code/pdf-ast"
171
+ },
172
+ {
173
+ name: "pdfseparate",
174
+ description: "Split PDF pages into individual PDF files via @poe-code/pdf-ast"
175
+ },
176
+ {
177
+ name: "pdffonts",
178
+ description: "List fonts used in a PDF document via @poe-code/pdf-ast"
179
+ },
180
+ {
181
+ name: "pdfdetach",
182
+ description: "List and extract embedded file attachments from PDF documents via @poe-code/pdf-ast"
183
+ }
184
+ ];
185
+ export const createPdfinfoCommand = (...args) => {
186
+ const metadata = pdfinfoMetadata.find((item) => item.name === "pdfinfo");
187
+ if (!metadata)
188
+ throw new TypeError("Unknown pdfinfo command");
189
+ return createLazyCommands([metadata], async () => {
190
+ const module = await loadpdfinfo();
191
+ return () => [module.createPdfinfoCommand(...args)];
192
+ })[0];
193
+ };
194
+ export const pdfinfoCommands = (options = {}) => lazyCommandPlugin("pdfinfo", createPdfinfoCommands(options), options.replace ?? false);
195
+ export const createPdfinfoCommands = (...args) => {
196
+ const definitions = createLazyCommands(pdfinfoMetadata, async () => {
197
+ const module = await loadpdfinfo();
198
+ return () => module.createPdfinfoCommands(...args);
199
+ });
200
+ return definitions;
201
+ };
202
+ const loadpdftotext = createLazyCommandLoader(() => import("./commands/pdftotext/index.js"));
203
+ const pdftotextMetadata = [
204
+ {
205
+ name: "pdftotext",
206
+ description: "Extract PDF text, layout, XHTML bounding boxes, and TSV via @poe-code/pdf-ast"
207
+ },
208
+ {
209
+ name: "pdftohtml",
210
+ description: "Convert PDF pages into HTML or XML layout documents via @poe-code/pdf-ast"
211
+ }
212
+ ];
213
+ export const createPdftotextCommand = (...args) => {
214
+ const metadata = pdftotextMetadata.find((item) => item.name === "pdftotext");
215
+ if (!metadata)
216
+ throw new TypeError("Unknown pdftotext command");
217
+ return createLazyCommands([metadata], async () => {
218
+ const module = await loadpdftotext();
219
+ return () => [module.createPdftotextCommand(...args)];
220
+ })[0];
221
+ };
222
+ export const pdftotextCommands = (options = {}) => lazyCommandPlugin("pdftotext", createPdftotextCommands(options), options.replace ?? false);
223
+ export const createPdftotextCommands = (...args) => {
224
+ const definitions = createLazyCommands(pdftotextMetadata, async () => {
225
+ const module = await loadpdftotext();
226
+ return () => module.createPdftotextCommands(...args);
227
+ });
228
+ return definitions;
229
+ };
230
+ const loadpdfimages = createLazyCommandLoader(() => import("./commands/pdfimages/index.js"));
231
+ const pdfimagesMetadata = [
232
+ {
233
+ name: "pdfimages",
234
+ description: "List and extract embedded images from PDF pages via @poe-code/pdf-ast"
235
+ }
236
+ ];
237
+ export const createPdfimagesCommand = (...args) => {
238
+ const metadata = pdfimagesMetadata.find((item) => item.name === "pdfimages");
239
+ if (!metadata)
240
+ throw new TypeError("Unknown pdfimages command");
241
+ return createLazyCommands([metadata], async () => {
242
+ const module = await loadpdfimages();
243
+ return () => [module.createPdfimagesCommand(...args)];
244
+ })[0];
245
+ };
246
+ export const pdfimagesCommands = (options = {}) => lazyCommandPlugin("pdfimages", createPdfimagesCommands(options), options.replace ?? false);
247
+ export const createPdfimagesCommands = (...args) => {
248
+ const definitions = createLazyCommands(pdfimagesMetadata, async () => {
249
+ const module = await loadpdfimages();
250
+ return () => module.createPdfimagesCommands(...args);
251
+ });
252
+ return definitions;
253
+ };
254
+ const loadpdftoppm = createLazyCommandLoader(() => import("./commands/pdftoppm/index.js"));
255
+ const pdftoppmMetadata = [
256
+ {
257
+ name: "pdftoppm",
258
+ description: "Render PDF pages to PNG, PPM, PGM, PBM, or SVG via @poe-code/pdf-ast"
259
+ },
260
+ {
261
+ name: "pdftocairo",
262
+ description: "Render PDF pages to PNG, JPEG, TIFF, PDF, PS, EPS, or SVG via @poe-code/pdf-ast"
263
+ }
264
+ ];
265
+ export const createPdftoppmCommand = (...args) => {
266
+ const metadata = pdftoppmMetadata.find((item) => item.name === "pdftoppm");
267
+ if (!metadata)
268
+ throw new TypeError("Unknown pdftoppm command");
269
+ return createLazyCommands([metadata], async () => {
270
+ const module = await loadpdftoppm();
271
+ return () => [module.createPdftoppmCommand(...args)];
272
+ })[0];
273
+ };
274
+ export const pdftoppmCommands = (options = {}) => lazyCommandPlugin("pdftoppm", createPdftoppmCommands(options), options.replace ?? false);
275
+ export const createPdftoppmCommands = (...args) => {
276
+ const definitions = createLazyCommands(pdftoppmMetadata, async () => {
277
+ const module = await loadpdftoppm();
278
+ return () => module.createPdftoppmCommands(...args);
279
+ });
280
+ return definitions;
281
+ };
282
+ const loadpdftk = createLazyCommandLoader(() => import("./commands/pdftk/index.js"));
283
+ const pdftkMetadata = [
284
+ {
285
+ name: "pdftk",
286
+ description: "Manipulate PDF documents, fill/flatten AcroForms, and assemble pages via @poe-code/pdf-ast"
287
+ }
288
+ ];
289
+ export const createPdftkCommand = (...args) => {
290
+ const metadata = pdftkMetadata.find((item) => item.name === "pdftk");
291
+ if (!metadata)
292
+ throw new TypeError("Unknown pdftk command");
293
+ return createLazyCommands([metadata], async () => {
294
+ const module = await loadpdftk();
295
+ return () => [module.createPdftkCommand(...args)];
296
+ })[0];
297
+ };
298
+ export const pdftkCommands = (options = {}) => lazyCommandPlugin("pdftk", createPdftkCommands(options), options.replace ?? false);
299
+ export const createPdftkCommands = (...args) => {
300
+ const definitions = createLazyCommands(pdftkMetadata, async () => {
301
+ const module = await loadpdftk();
302
+ return () => module.createPdftkCommands(...args);
303
+ });
304
+ return definitions;
305
+ };
306
+ const loadqpdf = createLazyCommandLoader(() => import("./commands/qpdf/index.js"));
307
+ const qpdfMetadata = [
308
+ {
309
+ name: "qpdf",
310
+ description: "Structural PDF inspection, encryption, page selection, and transformation via @poe-code/pdf-ast"
311
+ }
312
+ ];
313
+ export const createQpdfCommand = (...args) => {
314
+ const metadata = qpdfMetadata.find((item) => item.name === "qpdf");
315
+ if (!metadata)
316
+ throw new TypeError("Unknown qpdf command");
317
+ return createLazyCommands([metadata], async () => {
318
+ const module = await loadqpdf();
319
+ return () => [module.createQpdfCommand(...args)];
320
+ })[0];
321
+ };
322
+ export const qpdfCommands = (options = {}) => lazyCommandPlugin("qpdf", createQpdfCommands(options), options.replace ?? false);
323
+ export const createQpdfCommands = (...args) => {
324
+ const definitions = createLazyCommands(qpdfMetadata, async () => {
325
+ const module = await loadqpdf();
326
+ return () => module.createQpdfCommands(...args);
327
+ });
328
+ return definitions;
329
+ };
330
+ const loadsips = createLazyCommandLoader(() => import("./commands/sips/index.js"));
331
+ const sipsMetadata = [
332
+ {
333
+ name: "sips",
334
+ description: "Scriptable image processing system powered by @poe-code/image-ast"
335
+ }
336
+ ];
337
+ export const createSipsCommand = (...args) => {
338
+ const metadata = sipsMetadata.find((item) => item.name === "sips");
339
+ if (!metadata)
340
+ throw new TypeError("Unknown sips command");
341
+ return createLazyCommands([metadata], async () => {
342
+ const module = await loadsips();
343
+ return () => [module.createSipsCommand(...args)];
344
+ })[0];
345
+ };
346
+ export const sipsCommands = (options = {}) => lazyCommandPlugin("sips", createSipsCommands(options), options.replace ?? false);
347
+ export const createSipsCommands = (...args) => {
348
+ const definitions = createLazyCommands(sipsMetadata, async () => {
349
+ const module = await loadsips();
350
+ return () => module.createSipsCommands(...args);
351
+ });
352
+ return definitions;
353
+ };
354
+ const loadimagemagick = createLazyCommandLoader(() => import("./commands/imagemagick/index.js"));
355
+ const imagemagickMetadata = [
356
+ {
357
+ name: "magick",
358
+ description: "ImageMagick v7 image processor powered by @poe-code/image-ast"
359
+ },
360
+ {
361
+ name: "convert",
362
+ description: "ImageMagick convert pipeline powered by @poe-code/image-ast"
363
+ },
364
+ {
365
+ name: "mogrify",
366
+ description: "ImageMagick in-place batch image processor powered by @poe-code/image-ast"
367
+ },
368
+ {
369
+ name: "composite",
370
+ description: "ImageMagick overlay composition tool powered by @poe-code/image-ast"
371
+ },
372
+ {
373
+ name: "montage",
374
+ description: "ImageMagick contact-sheet grid generator powered by @poe-code/image-ast"
375
+ },
376
+ {
377
+ name: "identify",
378
+ description: "ImageMagick image metadata inspector powered by @poe-code/image-ast"
379
+ },
380
+ {
381
+ name: "compare",
382
+ description: "ImageMagick image comparison and diff generator powered by @poe-code/image-ast"
383
+ }
384
+ ];
385
+ export const createMagickCommand = (...args) => {
386
+ const metadata = imagemagickMetadata.find((item) => item.name === "magick");
387
+ if (!metadata)
388
+ throw new TypeError("Unknown imagemagick command");
389
+ return createLazyCommands([metadata], async () => {
390
+ const module = await loadimagemagick();
391
+ return () => [module.createMagickCommand(...args)];
392
+ })[0];
393
+ };
394
+ export const imagemagickCommands = (options = {}) => lazyCommandPlugin("imagemagick", createImagemagickCommands(options), options.replace ?? false);
395
+ export const createImagemagickCommands = (...args) => {
396
+ const definitions = createLazyCommands(imagemagickMetadata, async () => {
397
+ const module = await loadimagemagick();
398
+ return () => module.createImagemagickCommands(...args);
399
+ });
400
+ return definitions;
401
+ };
402
+ export const createImagemagickCommand = (...args) => {
403
+ const metadata = imagemagickMetadata.find((item) => item.name === "magick");
404
+ if (!metadata)
405
+ throw new TypeError("Unknown imagemagick command");
406
+ return createLazyCommands([metadata], async () => {
407
+ const module = await loadimagemagick();
408
+ return () => [module.createImagemagickCommand(...args)];
409
+ })[0];
410
+ };
411
+ const loadwkhtmltopdf = createLazyCommandLoader(() => import("./commands/wkhtmltopdf/index.js"));
412
+ const wkhtmltopdfMetadata = [
413
+ {
414
+ name: "wkhtmltopdf",
415
+ description: "Bounded static HTML-to-PDF adapter with a built-in PDF AST renderer"
416
+ }
417
+ ];
418
+ export const createWkhtmltopdfCommand = (...args) => {
419
+ const metadata = wkhtmltopdfMetadata.find((item) => item.name === "wkhtmltopdf");
420
+ if (!metadata)
421
+ throw new TypeError("Unknown wkhtmltopdf command");
422
+ return createLazyCommands([metadata], async () => {
423
+ const module = await loadwkhtmltopdf();
424
+ return () => [module.createWkhtmltopdfCommand(...args)];
425
+ })[0];
426
+ };
427
+ export const wkhtmltopdfCommands = (options = {}) => lazyCommandPlugin("wkhtmltopdf", createWkhtmltopdfCommands(options), options.replace ?? false);
428
+ export const createWkhtmltopdfCommands = (...args) => {
429
+ const definitions = createLazyCommands(wkhtmltopdfMetadata, async () => {
430
+ const module = await loadwkhtmltopdf();
431
+ return () => module.createWkhtmltopdfCommands(...args);
432
+ });
433
+ return definitions;
434
+ };
435
+ const loadcsvkit = createLazyCommandLoader(() => import("./commands/csvkit/index.js"));
436
+ const csvkitMetadata = [
437
+ {
438
+ name: "csvclean",
439
+ description: "csvkit 2.2.0 csvclean; compatibility gaps return status 78"
440
+ },
441
+ {
442
+ name: "csvcut",
443
+ description: "csvkit 2.2.0 csvcut; compatibility gaps return status 78",
444
+ fallback: true
445
+ },
446
+ {
447
+ name: "csvformat",
448
+ description: "csvkit 2.2.0 csvformat; compatibility gaps return status 78"
449
+ },
450
+ {
451
+ name: "csvgrep",
452
+ description: "csvkit 2.2.0 csvgrep; compatibility gaps return status 78",
453
+ fallback: true
454
+ },
455
+ {
456
+ name: "csvjoin",
457
+ description: "csvkit 2.2.0 csvjoin; compatibility gaps return status 78"
458
+ },
459
+ {
460
+ name: "csvjson",
461
+ description: "csvkit 2.2.0 csvjson; compatibility gaps return status 78"
462
+ },
463
+ {
464
+ name: "csvlook",
465
+ description: "csvkit 2.2.0 csvlook; compatibility gaps return status 78"
466
+ },
467
+ {
468
+ name: "csvpy",
469
+ description: "csvkit 2.2.0 csvpy; compatibility gaps return status 78"
470
+ },
471
+ {
472
+ name: "csvsort",
473
+ description: "csvkit 2.2.0 csvsort; compatibility gaps return status 78"
474
+ },
475
+ {
476
+ name: "csvsql",
477
+ description: "csvkit 2.2.0 csvsql; compatibility gaps return status 78"
478
+ },
479
+ {
480
+ name: "csvstack",
481
+ description: "csvkit 2.2.0 csvstack; compatibility gaps return status 78"
482
+ },
483
+ {
484
+ name: "csvstat",
485
+ description: "csvkit 2.2.0 csvstat; compatibility gaps return status 78"
486
+ },
487
+ {
488
+ name: "in2csv",
489
+ description: "csvkit 2.2.0 in2csv; compatibility gaps return status 78"
490
+ },
491
+ {
492
+ name: "sql2csv",
493
+ description: "csvkit 2.2.0 sql2csv; compatibility gaps return status 78"
494
+ }
495
+ ];
496
+ export const csvkitCommands = (options = {}) => lazyCommandPlugin("csvkit-commands", createCsvkitCommands(options), options.replace ?? false);
497
+ export const createCsvkitCommands = (...args) => {
498
+ const definitions = createLazyCommands(csvkitMetadata, async () => {
499
+ const module = await loadcsvkit();
500
+ return () => module.createCsvkitCommands(...args);
501
+ });
502
+ return definitions;
503
+ };
504
+ export const createCsvkitCommand = (...args) => {
505
+ const metadata = csvkitMetadata.find((item) => item.name === (args[0]?.name ?? "csvclean"));
506
+ if (!metadata)
507
+ throw new TypeError("Unknown csvkit command");
508
+ return createLazyCommands([metadata], async () => {
509
+ const module = await loadcsvkit();
510
+ return () => [module.createCsvkitCommand(...args)];
511
+ })[0];
512
+ };
513
+ export { createGhCommand, createGhCommands, ghCommands } from "./lazy-gh.js";
514
+ /** Extension contract for trusted, statically bundled command code. */
515
+ export { createLazyCommandLoader, createLazyCommands, lazyCommandPlugin } from "./plugins/lazy-command.js";
516
+ const optionalFamilies = {
517
+ ffmpeg: {
518
+ metadata: ffmpegMetadata,
519
+ create: (options) => createFfmpegCommands(options.ffmpeg)
520
+ },
521
+ git: {
522
+ metadata: gitMetadata,
523
+ create: (options) => createGitCommands(options.git)
524
+ },
525
+ soffice: {
526
+ metadata: sofficeMetadata,
527
+ create: (options) => createSofficeCommands(options.soffice)
528
+ },
529
+ pandoc: {
530
+ metadata: pandocMetadata,
531
+ create: (options) => createPandocCommands(options.pandoc)
532
+ },
533
+ ssconvert: {
534
+ metadata: ssconvertMetadata,
535
+ create: (options) => createSsconvertCommands(options.ssconvert)
536
+ },
537
+ pdfinfo: {
538
+ metadata: pdfinfoMetadata,
539
+ create: (options) => createPdfinfoCommands(options.pdfinfo)
540
+ },
541
+ pdftotext: {
542
+ metadata: pdftotextMetadata,
543
+ create: (options) => createPdftotextCommands(options.pdftotext)
544
+ },
545
+ pdfimages: {
546
+ metadata: pdfimagesMetadata,
547
+ create: (options) => createPdfimagesCommands(options.pdfimages)
548
+ },
549
+ pdftoppm: {
550
+ metadata: pdftoppmMetadata,
551
+ create: (options) => createPdftoppmCommands(options.pdftoppm)
552
+ },
553
+ pdftk: {
554
+ metadata: pdftkMetadata,
555
+ create: (options) => createPdftkCommands(options.pdftk)
556
+ },
557
+ qpdf: {
558
+ metadata: qpdfMetadata,
559
+ create: (options) => createQpdfCommands(options.qpdf)
560
+ },
561
+ sips: {
562
+ metadata: sipsMetadata,
563
+ create: (options) => createSipsCommands(options.sips)
564
+ },
565
+ imagemagick: {
566
+ metadata: imagemagickMetadata,
567
+ create: (options) => createImagemagickCommands(options.imagemagick)
568
+ },
569
+ wkhtmltopdf: {
570
+ metadata: wkhtmltopdfMetadata,
571
+ create: (options) => createWkhtmltopdfCommands(options.wkhtmltopdf)
572
+ },
573
+ csvkit: {
574
+ metadata: csvkitMetadata,
575
+ create: (options) => createCsvkitCommands(options.csvkit)
576
+ },
577
+ gh: {
578
+ metadata: ghMetadata,
579
+ create: (options) => createGhCommands(options.gh)
580
+ }
581
+ };
582
+ export const optionalCommandCatalog = Object.freeze(Object.entries(optionalFamilies).flatMap(([family, entry]) => entry.metadata.map((metadata) => Object.freeze({ family: family, ...metadata }))));
583
+ export function createOptionalCommands(options = {}) {
584
+ const names = new Set(options.commands ?? []);
585
+ for (const name of names)
586
+ if (!optionalCommandCatalog.some((metadata) => metadata.name === name)) {
587
+ throw new TypeError(`Unknown optional command: ${name}`);
588
+ }
589
+ const families = new Set(options.families ?? []);
590
+ for (const family of families)
591
+ if (!Object.hasOwn(optionalFamilies, family)) {
592
+ throw new TypeError(`Unknown optional command family: ${family}`);
593
+ }
594
+ const definitions = [];
595
+ for (const [family, entry] of Object.entries(optionalFamilies)) {
596
+ const fullFamily = options.profile === "full" || families.has(family);
597
+ if (!fullFamily && !entry.metadata.some((metadata) => names.has(metadata.name)))
598
+ continue;
599
+ definitions.push(...entry
600
+ .create(options.configuration ?? {})
601
+ .filter((command) => fullFamily || names.has(command.name))
602
+ .map((command) => options.profile === "full" ? Object.freeze({ ...command, fallback: true }) : command));
603
+ }
604
+ return new CommandRegistry(definitions).list();
605
+ }
606
+ export function optionalCommands(options = {}) {
607
+ return lazyCommandPlugin("optional-commands", createOptionalCommands(options), options.replace ?? false);
608
+ }
609
+ //# sourceMappingURL=lazy-optional.js.map
@@ -1,4 +1,4 @@
1
- import { type GhCommandOptions } from "../commands/gh/index.js";
1
+ import { type GhCommandOptions } from "../lazy-gh.js";
2
2
  import { type CommandDefinition, type CommandHandler } from "../contracts/index.js";
3
3
  import { type ExecutionCommandsOptions, type StandardCommandsOptions } from "../commands/standard.js";
4
4
  import { type TextProgramOptions } from "../commands/text-programs/index.js";
@@ -1,4 +1,4 @@
1
- import { createGhCommands } from "../commands/gh/index.js";
1
+ import { createGhCommands } from "../lazy-gh.js";
2
2
  import { CommandRegistry } from "../contracts/index.js";
3
3
  import { PublicDiagnostic } from "../diagnostics.js";
4
4
  import { createStandardCommandsWithGrep } from "../commands/standard.js";
@@ -0,0 +1,9 @@
1
+ import type { CommandDefinition, VirtualShellPlugin } from "../contracts/index.js";
2
+ /** A static, trusted loader. Share code, never invocation context or authority. */
3
+ export declare function createLazyCommandLoader<T>(load: () => Promise<T>): () => Promise<T>;
4
+ export type LazyCommandMetadata = Omit<CommandDefinition, "execute" | "runtimeIdentity">;
5
+ export type LazyCommandFactory = () => readonly CommandDefinition[];
6
+ /** Factories run per invocation; only the loader's immutable code is shared. */
7
+ export declare function createLazyCommands(metadata: readonly LazyCommandMetadata[], load: () => Promise<LazyCommandFactory>): readonly CommandDefinition[];
8
+ export declare function lazyCommandPlugin(name: string, commands: readonly CommandDefinition[], replace?: boolean): VirtualShellPlugin;
9
+ //# sourceMappingURL=lazy-command.d.ts.map
@@ -0,0 +1,57 @@
1
+ import { commandRuntimeIdentity } from "../contracts/command.js";
2
+ /** A static, trusted loader. Share code, never invocation context or authority. */
3
+ export function createLazyCommandLoader(load) {
4
+ let pending;
5
+ return () => (pending ??= Promise.resolve()
6
+ .then(load)
7
+ .catch((error) => {
8
+ pending = undefined;
9
+ throw error;
10
+ }));
11
+ }
12
+ async function waitForCode(pending, signal) {
13
+ signal.throwIfAborted();
14
+ let abort;
15
+ const cancelled = new Promise((_resolve, reject) => {
16
+ abort = () => reject(signal.reason);
17
+ signal.addEventListener("abort", abort, { once: true });
18
+ });
19
+ try {
20
+ return await Promise.race([pending, cancelled]);
21
+ }
22
+ finally {
23
+ signal.removeEventListener("abort", abort);
24
+ }
25
+ }
26
+ /** Factories run per invocation; only the loader's immutable code is shared. */
27
+ export function createLazyCommands(metadata, load) {
28
+ return Object.freeze(metadata.map((item) => Object.freeze({
29
+ ...item,
30
+ runtimeIdentity: commandRuntimeIdentity,
31
+ async execute(context) {
32
+ context.signal.throwIfAborted();
33
+ const factory = await waitForCode(load(), context.signal);
34
+ context.signal.throwIfAborted();
35
+ const definition = factory().find((command) => command.name === item.name);
36
+ if (!definition)
37
+ throw new Error(`Lazy command loader did not provide ${item.name}`);
38
+ return definition.execute(context);
39
+ }
40
+ })));
41
+ }
42
+ export function lazyCommandPlugin(name, commands, replace = false) {
43
+ return {
44
+ name,
45
+ setup(host) {
46
+ if (!replace)
47
+ for (const command of commands) {
48
+ const existing = host.commands.get(command.name);
49
+ if (existing && !(command.fallback && !existing.fallback))
50
+ throw new Error(`Command already registered: ${command.name}`);
51
+ }
52
+ for (const command of commands)
53
+ host.commands.register(command, { replace });
54
+ }
55
+ };
56
+ }
57
+ //# sourceMappingURL=lazy-command.js.map