forge-terminal 0.4.4 → 0.5.0

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 (151) hide show
  1. package/README.md +104 -19
  2. package/dist/chunks/{about-credits-QMC5GQU2.js → about-credits-5UQU5WHE.js} +2 -2
  3. package/dist/chunks/args-QKAIL3E4.js +3 -0
  4. package/dist/chunks/{available-GYIHVSRX.js → available-M6Z62OWE.js} +1 -1
  5. package/dist/chunks/boot-MGR26CBU.js +3 -0
  6. package/dist/chunks/catalog-VPSTQTFD.js +3 -0
  7. package/dist/chunks/check-B6NP7BEM.js +3 -0
  8. package/dist/chunks/chunk-37P6QZ5Q.js +3 -0
  9. package/dist/chunks/chunk-3GJ7GV3V.js +19 -0
  10. package/dist/chunks/{chunk-EHARO6IS.js → chunk-57M4J2BR.js} +1 -1
  11. package/dist/chunks/chunk-63XCSYHM.js +3 -0
  12. package/dist/chunks/{chunk-JFJ3ZJQL.js → chunk-63ZK5SRQ.js} +1 -1
  13. package/dist/chunks/chunk-C4UCCBCX.js +3 -0
  14. package/dist/chunks/{chunk-DERIWZAT.js → chunk-CKZBBDAW.js} +1 -1
  15. package/dist/chunks/chunk-DZOBIUV6.js +3 -0
  16. package/dist/chunks/chunk-EKTUUKDP.js +80 -0
  17. package/dist/chunks/chunk-F34DPQFQ.js +63 -0
  18. package/dist/chunks/chunk-G46QQBT3.js +3 -0
  19. package/dist/chunks/chunk-GSK2A3TN.js +3 -0
  20. package/dist/chunks/chunk-H3DIRJFE.js +3 -0
  21. package/dist/chunks/chunk-HKINXTUW.js +3 -0
  22. package/dist/chunks/chunk-HOZ6XGQQ.js +6 -0
  23. package/dist/chunks/chunk-I6754KTB.js +36 -0
  24. package/dist/chunks/{chunk-YYB3TTGT.js → chunk-JMBEZPYC.js} +1 -1
  25. package/dist/chunks/chunk-K7KKCR7V.js +6 -0
  26. package/dist/chunks/chunk-KH5DHZ2U.js +8 -0
  27. package/dist/chunks/chunk-KXKQDFHX.js +3 -0
  28. package/dist/chunks/chunk-LVYQVJOF.js +3 -0
  29. package/dist/chunks/chunk-N6RCLJE6.js +4 -0
  30. package/dist/chunks/chunk-N72E43Z3.js +3 -0
  31. package/dist/chunks/chunk-NDECMPOM.js +3 -0
  32. package/dist/chunks/chunk-NXJGO66P.js +3 -0
  33. package/dist/chunks/chunk-OK7XOZFO.js +3 -0
  34. package/dist/chunks/chunk-P4RAYEM7.js +6 -0
  35. package/dist/chunks/{chunk-EX7KZBI6.js → chunk-PE5LAYGF.js} +1 -1
  36. package/dist/chunks/chunk-PPR7B5AR.js +3 -0
  37. package/dist/chunks/chunk-Q6KQWJ4J.js +3 -0
  38. package/dist/chunks/{chunk-GJ2GZHRI.js → chunk-RMD7F3QX.js} +1 -1
  39. package/dist/chunks/chunk-SK2UZ25Y.js +3 -0
  40. package/dist/chunks/chunk-SNDFMJIX.js +3 -0
  41. package/dist/chunks/{chunk-IGF6ZFTM.js → chunk-SZRSAL64.js} +1 -1
  42. package/dist/chunks/chunk-THDAQBQ3.js +3 -0
  43. package/dist/chunks/chunk-TL5MACSF.js +3 -0
  44. package/dist/chunks/chunk-V3I6DSF4.js +3 -0
  45. package/dist/chunks/{chunk-M7A55JKD.js → chunk-W6SY5PPG.js} +2 -2
  46. package/dist/chunks/chunk-WC6SJN5Y.js +3 -0
  47. package/dist/chunks/chunk-WE6KP4FR.js +3 -0
  48. package/dist/chunks/chunk-WIPP5TWQ.js +3 -0
  49. package/dist/chunks/{chunk-I2IATJNL.js → chunk-XBOMWF34.js} +1 -1
  50. package/dist/chunks/chunk-XRI5XKEB.js +66 -0
  51. package/dist/chunks/chunk-Y7LOIHFU.js +3 -0
  52. package/dist/chunks/chunk-YINYF6C7.js +3 -0
  53. package/dist/chunks/chunk-ZRHYGR2L.js +134 -0
  54. package/dist/chunks/chunk-ZZZAPVKM.js +3 -0
  55. package/dist/chunks/clip-command-R2NKW4TI.js +3 -0
  56. package/dist/chunks/clipboard-GICOXMMN.js +3 -0
  57. package/dist/chunks/colour-APVBMEJQ.js +3 -0
  58. package/dist/chunks/command-GYCYLUHN.js +3 -0
  59. package/dist/chunks/config-command-6YUMMZF3.js +3 -0
  60. package/dist/chunks/continue-editing-QE5RRIMG.js +3 -0
  61. package/dist/chunks/decoded-UNCEUPNW.js +3 -0
  62. package/dist/chunks/entry-TSLQHDP7.js +6 -0
  63. package/dist/chunks/execute-S5WN34PS.js +3 -0
  64. package/dist/chunks/extensions-XI5R74TS.js +3 -0
  65. package/dist/chunks/{extensions-command-L2AT6OVR.js → extensions-command-25JOL47P.js} +1 -1
  66. package/dist/chunks/ffmpeg-3CJ6C37W.js +3 -0
  67. package/dist/chunks/image-QSTDWHJ4.js +3 -0
  68. package/dist/chunks/install-IDUHZTTS.js +3 -0
  69. package/dist/chunks/{install-V62EEK54.js → install-L5C2UT6M.js} +1 -1
  70. package/dist/chunks/install-size-PZUFEDGI.js +3 -0
  71. package/dist/chunks/launch-LFFWVTFE.js +17 -0
  72. package/dist/chunks/libs-EK64ACG3.js +3 -0
  73. package/dist/chunks/lock-PTQUMNYX.js +3 -0
  74. package/dist/chunks/manager-CQ6NNQY4.js +4 -0
  75. package/dist/chunks/needed-MYXIUZI4.js +3 -0
  76. package/dist/chunks/own-WNA6BFYL.js +3 -0
  77. package/dist/chunks/{paths-5XI5L4KW.js → paths-EOYKOUBC.js} +1 -1
  78. package/dist/chunks/pdfium-WFGSET5S.js +3 -0
  79. package/dist/chunks/preferences-3P4V2EDX.js +3 -0
  80. package/dist/chunks/preset-command-HMOFTZSG.js +3 -0
  81. package/dist/chunks/registry-4IOXO6DT.js +3 -0
  82. package/dist/chunks/{reveal-L6TBFOMV.js → reveal-D5FCZYOA.js} +1 -1
  83. package/dist/chunks/run-HGZVOXRW.js +5 -0
  84. package/dist/chunks/{server-7PMVIYWQ.js → server-KKF3XBQG.js} +8 -8
  85. package/dist/chunks/text-layer-LHZNDMPZ.js +3 -0
  86. package/dist/chunks/{theme-Z6X54JY4.js → theme-NAWQ77WF.js} +1 -1
  87. package/dist/chunks/transcribe-Q5NLWSSR.js +3 -0
  88. package/dist/chunks/transcribe-command-2L7F7MCG.js +3 -0
  89. package/dist/chunks/{update-command-GMBG7BK6.js → update-command-JCTCRPCS.js} +1 -1
  90. package/dist/chunks/update-note-FRMHMUMD.js +3 -0
  91. package/dist/chunks/watch-command-XCCMIQIM.js +3 -0
  92. package/dist/fonts/NotoSans-Bold.ttf.gz +0 -0
  93. package/dist/fonts/NotoSans-Regular.ttf.gz +0 -0
  94. package/dist/fonts/OFL.txt +93 -0
  95. package/dist/helpers/forge-transcribe +0 -0
  96. package/dist/helpers/forge-transcribe-whisper.mjs +525 -0
  97. package/dist/index.js +8 -8
  98. package/dist/third-party-licenses.txt +98 -0
  99. package/package.json +45 -10
  100. package/dist/chunks/args-VPUOIDWE.js +0 -3
  101. package/dist/chunks/boot-FOKV7OHT.js +0 -3
  102. package/dist/chunks/catalog-YSMT3PXT.js +0 -3
  103. package/dist/chunks/check-KAR72Y4X.js +0 -3
  104. package/dist/chunks/chunk-3UEQ2OX6.js +0 -3
  105. package/dist/chunks/chunk-5B5XXH22.js +0 -3
  106. package/dist/chunks/chunk-5IS7O673.js +0 -6
  107. package/dist/chunks/chunk-5SMYDPVX.js +0 -63
  108. package/dist/chunks/chunk-6FUVEO3A.js +0 -78
  109. package/dist/chunks/chunk-6L6C3GJU.js +0 -3
  110. package/dist/chunks/chunk-AAXBN572.js +0 -4
  111. package/dist/chunks/chunk-BZXDNDPG.js +0 -3
  112. package/dist/chunks/chunk-DOWMSJ6R.js +0 -3
  113. package/dist/chunks/chunk-EXLXSKRH.js +0 -3
  114. package/dist/chunks/chunk-FH3R2YYD.js +0 -19
  115. package/dist/chunks/chunk-I63TO22X.js +0 -3
  116. package/dist/chunks/chunk-IWFVEMDN.js +0 -3
  117. package/dist/chunks/chunk-JSMGNA55.js +0 -3
  118. package/dist/chunks/chunk-KAHWYWNT.js +0 -3
  119. package/dist/chunks/chunk-LDKF7KIZ.js +0 -6
  120. package/dist/chunks/chunk-LNB5D67B.js +0 -3
  121. package/dist/chunks/chunk-M66BUNYO.js +0 -3
  122. package/dist/chunks/chunk-NWREILRP.js +0 -66
  123. package/dist/chunks/chunk-PSEIJXGT.js +0 -3
  124. package/dist/chunks/chunk-QR6QHTC3.js +0 -3
  125. package/dist/chunks/chunk-QXTXBMTM.js +0 -3
  126. package/dist/chunks/chunk-SMBK6BTC.js +0 -3
  127. package/dist/chunks/chunk-TDW6KQH6.js +0 -3
  128. package/dist/chunks/chunk-TMQDQLY7.js +0 -21
  129. package/dist/chunks/chunk-XEQVXPPY.js +0 -3
  130. package/dist/chunks/chunk-XSOCV3F2.js +0 -3
  131. package/dist/chunks/chunk-YWKMG5WO.js +0 -3
  132. package/dist/chunks/clip-command-SGB3B4OJ.js +0 -3
  133. package/dist/chunks/clipboard-CPHPA4FH.js +0 -3
  134. package/dist/chunks/colour-QMGYV6WQ.js +0 -3
  135. package/dist/chunks/command-I5M275ZV.js +0 -3
  136. package/dist/chunks/config-command-TYNYVUMP.js +0 -3
  137. package/dist/chunks/entry-3PEVSH2X.js +0 -6
  138. package/dist/chunks/execute-WQJ37VKD.js +0 -3
  139. package/dist/chunks/extensions-ZKOWPSLD.js +0 -3
  140. package/dist/chunks/ffmpeg-PF3VLTHK.js +0 -3
  141. package/dist/chunks/image-J4FT4ACZ.js +0 -3
  142. package/dist/chunks/install-2A5BGKQU.js +0 -3
  143. package/dist/chunks/launch-L5DKAUA3.js +0 -15
  144. package/dist/chunks/lock-KN7CF4YN.js +0 -3
  145. package/dist/chunks/manager-TEZ3V4L4.js +0 -4
  146. package/dist/chunks/preferences-4VETUGMN.js +0 -3
  147. package/dist/chunks/preset-command-HORY7KZQ.js +0 -3
  148. package/dist/chunks/run-6BK4REXK.js +0 -4
  149. package/dist/chunks/transcribe-command-YUSBCQEQ.js +0 -3
  150. package/dist/chunks/update-note-RQG2RZNR.js +0 -3
  151. package/dist/chunks/watch-command-DUHMTXQL.js +0 -3
package/package.json CHANGED
@@ -1,19 +1,47 @@
1
1
  {
2
2
  "name": "forge-terminal",
3
- "version": "0.4.4",
4
- "description": "A terminal-native file converter for macOS and Windows",
3
+ "version": "0.5.0",
4
+ "description": "A terminal-native file converter for macOS, Windows and Linux",
5
5
  "whatsNew": [
6
6
  {
7
- "title": "Keys light up",
8
- "text": "Press a key and its hint on screen turns orange for a moment. Tab stays lit while the supported formats are showing."
7
+ "title": "Windows and Linux",
8
+ "text": "Transcribe, read text, camera RAW, Boost and remove background now work on Windows and Linux too, as extensions."
9
9
  },
10
10
  {
11
- "title": "A calmer formats list",
12
- "text": "The supported formats list has lost its title and rule, so it has more room to breathe."
11
+ "title": "Read text",
12
+ "text": "Transcribe reads the words in pictures and PDFs, including Chinese, Japanese, Korean, Russian, Arabic, Hindi and Thai."
13
13
  },
14
14
  {
15
- "title": "Copy all commands",
16
- "text": "On /cli, press c to copy the whole command reference in one go."
15
+ "title": "Transcript formats",
16
+ "text": "Save a transcript as Markdown, Word, PDF or plain text."
17
+ },
18
+ {
19
+ "title": "Many files at once",
20
+ "text": "Convert, compress and edit take several files or a whole folder. esc stops a batch."
21
+ },
22
+ {
23
+ "title": "Run a preset",
24
+ "text": "Run a saved preset from home with p, or from Finder’s Quick Actions. Choose which ones show in /right-click."
25
+ },
26
+ {
27
+ "title": "Camera RAW",
28
+ "text": "Photos straight from a camera open like any other picture."
29
+ },
30
+ {
31
+ "title": "More in edit",
32
+ "text": "Rotate pictures and video, change a video’s speed, take the sound out of a video, and clean up noisy audio."
33
+ },
34
+ {
35
+ "title": "One way off Done",
36
+ "text": "Every Done ends in the same row of buttons: Home, show in Finder, or keep editing."
37
+ },
38
+ {
39
+ "title": "Simpler colour mode",
40
+ "text": "Palette is a tab now, More holds the rest, and a gradient can have any number of colours."
41
+ },
42
+ {
43
+ "title": "Your own tools",
44
+ "text": "Forge uses the yt-dlp and ffmpeg you already have, and /extensions shows the space each one takes."
17
45
  }
18
46
  ],
19
47
  "keywords": [
@@ -29,7 +57,8 @@
29
57
  "terminal",
30
58
  "tui",
31
59
  "macos",
32
- "windows"
60
+ "windows",
61
+ "linux"
33
62
  ],
34
63
  "homepage": "https://github.com/AtharvaN16/forge-terminal#readme",
35
64
  "repository": {
@@ -53,7 +82,8 @@
53
82
  },
54
83
  "os": [
55
84
  "darwin",
56
- "win32"
85
+ "win32",
86
+ "linux"
57
87
  ],
58
88
  "license": "MIT",
59
89
  "scripts": {
@@ -87,8 +117,10 @@
87
117
  "ink": "^7.1.1",
88
118
  "ink-testing-library": "^4.0.0",
89
119
  "libheif-js": "^1.23.5",
120
+ "libraw-wasm": "^1.6.0",
90
121
  "mammoth": "^1.13.0",
91
122
  "onnxruntime-node": "1.23.2",
123
+ "onnxruntime-node-rmbg": "npm:onnxruntime-node@1.25.1",
92
124
  "pdf-lib": "^1.17.1",
93
125
  "react": "^19.3.0",
94
126
  "string-width": "^8.3.0",
@@ -103,6 +135,9 @@
103
135
  "overrides": {
104
136
  "onnxruntime-node": {
105
137
  "adm-zip": "$adm-zip"
138
+ },
139
+ "onnxruntime-node-rmbg": {
140
+ "adm-zip": "$adm-zip"
106
141
  }
107
142
  }
108
143
  }
@@ -1,3 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{a,b,c,d}from"./chunk-5SMYDPVX.js";import"./chunk-U5TEGDGH.js";import"./chunk-QVACE4IE.js";import"./chunk-HZDYZ5RD.js";import"./chunk-QR6QHTC3.js";import"./chunk-6L6C3GJU.js";import"./chunk-EEQSUBBL.js";import"./chunk-YYB3TTGT.js";import"./chunk-KAHWYWNT.js";import"./chunk-SMBK6BTC.js";import"./chunk-EXLXSKRH.js";import"./chunk-3UEQ2OX6.js";import"./chunk-J7FLFHQJ.js";import"./chunk-LDKF7KIZ.js";import"./chunk-I2IATJNL.js";import"./chunk-AAXBN572.js";import"./chunk-HON4OV7M.js";import"./chunk-M66BUNYO.js";import"./chunk-TMUK2DD3.js";export{b as COMMANDS_HELP,a as EXIT_CODES_HELP,d as parseArgs,c as wantsJson};
@@ -1,3 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{r as l}from"./chunk-I2IATJNL.js";import{f as a}from"./chunk-AAXBN572.js";import"./chunk-HON4OV7M.js";import"./chunk-M66BUNYO.js";import"./chunk-TMUK2DD3.js";var c={loadPreferences:a,loadShell:()=>import("./launch-L5DKAUA3.js")};async function f(e=c,n={}){let t=e.loadShell();t.catch(()=>{});let{prefs:o,warning:r}=await e.loadPreferences(),s=l(o.theme),{launchShell:i}=await t;await i({prefs:o,palette:s,...r===void 0?{}:{warning:r},...n})}export{f as bootShell};
@@ -1,3 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{a,b,c,d,e}from"./chunk-5B5XXH22.js";import"./chunk-TMUK2DD3.js";export{a as CATALOG,c as assetFor,b as catalogEntry,e as offeredHere,d as offeredOn};
@@ -1,3 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk-IGF6ZFTM.js";import"./chunk-AAXBN572.js";import"./chunk-HON4OV7M.js";import"./chunk-M66BUNYO.js";import"./chunk-TMUK2DD3.js";export{b as CHECK_EVERY_MS,e as MAX_NOTES,g as NOTE_TEXT,f as NOTE_TITLE,a as REGISTRY_URL,o as availableUpdate,h as cachePath,m as checkNow,l as fetchLatest,c as isNewer,k as isStale,i as readCache,d as updateChecksEnabled,n as whatsNewFor,j as writeCache};
@@ -1,3 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{a as s}from"./chunk-J7FLFHQJ.js";import{a}from"./chunk-M66BUNYO.js";import{homedir as m}from"node:os";import{posix as p,win32 as g}from"node:path";var f=/[\u0000-\u001f\u007f-\u009f‪-‮⁦-⁩]/g;function d(e){return e.replace(f,"?")}function c(e,t,n){let i=n.relative(t,e);if(i==="")return"";if(!(i===".."||i.startsWith(`..${n.sep}`)||n.isAbsolute(i)))return i}function C(e,t={}){return d(w(e,t))}function w(e,t){let n=(t.platform??process.platform)==="win32"?g:p;if(t.cwd!==void 0){let l=c(e,t.cwd,n);if(l!==void 0)return l===""?".":l}let i=c(e,t.home??m(),n);return i!==void 0?i===""?"~":`~${n.sep}${i}`:e}function r(e,t=process.platform){return d((t==="win32"?g:p).basename(e))}import{dirname as b}from"node:path";var o=class extends Error{code;title;detail;short;hint;shellHint;constructor(t){super(`${t.title}: ${t.detail}`,t.cause===void 0?void 0:{cause:t.cause}),this.name="ForgeError",this.code=t.code,this.title=t.title,this.detail=t.detail,this.short=t.short,this.hint=t.hint,this.shellHint=t.shellHint}};function $(e){return e instanceof o}function N(e){return new o({code:"file-not-found",title:"File not found",detail:`${r(e)} could not be found.`,short:`${r(e)} could not be found.`,hint:"Check the filename and try again."})}function U(e){return new o({code:"not-a-file",title:"Not a file",detail:`${r(e)} is not a file.`,short:`${r(e)} is not a file.`,hint:"Point Forge at an image, or at a directory of images."})}function D(e){return new o({code:"permission-denied",title:"Permission denied",detail:`${r(e)} could not be read.`,short:`${r(e)} could not be read.`,hint:"Check the file permissions and try again."})}function O(e){return new o({code:"not-a-directory",title:"Invalid path",detail:`${r(e)} could not be found: part of its path is not a directory.`,short:`part of ${r(e)}'s path is not a folder.`,hint:"Check the path and try again."})}function z(e){return new o({code:"symlink-loop",title:"Too many symbolic links",detail:`${r(e)} could not be resolved: its path contains a symbolic-link loop.`,short:`${r(e)}'s path loops back on itself.`,hint:"Check for a circular symlink somewhere in the path."})}function A(e){return new o({code:"path-too-long",title:"Path too long",detail:`${r(e)}'s path is too long for the filesystem to resolve.`,short:`${r(e)}'s path is too long.`,hint:"Use a shorter path and try again."})}function j(e,t){return new o({code:"unreadable-path",title:"Could not read path",detail:`${r(e)} could not be checked.`,short:`${r(e)} could not be checked.`,hint:"Check the path and try again.",cause:t})}function M(e,t){return new o({code:"unsupported-source",title:"Unsupported file type",detail:`${r(e)} is ${t}, which Forge cannot read.`,short:`${r(e)} is ${t}, which Forge cannot read.`,hint:"Forge 0.1 handles images only."})}function J(e,t){return new o({code:"unsupported-source",title:"Not an image",detail:`${r(e)} is ${t}, not an image.`,hint:"A palette is taken from a photo, a screenshot or artwork."})}function R(e){return new o({code:"unsupported-source",title:"Nothing to take colours from",detail:`${r(e)} has no visible pixels.`})}function W(e,t=process.platform){return t==="win32"?new o({code:"heic-decoder-unavailable",title:"Cannot read HEIC here",detail:`${r(e,t)} is a HEIC photo, which needs Forge's free HEIC extension on Windows.`,short:"HEIC needs the heic extension.",hint:"Install it with: forge extensions add heic",shellHint:"Open /extensions to install it."}):new o({code:"heic-decoder-unavailable",title:"Cannot read HEIC here",detail:`${r(e)} is a HEIC photo, which Forge decodes with the macOS sips tool.`,short:"HEIC needs sips, which could not be run.",hint:"sips could not be run. It ships with macOS at /usr/bin/sips."})}function q(e,t){let n=r(e.path);if(t!==void 0&&t!==e.format){let i=a[t].label;return a[t].lossy?new o({code:"unsupported-compress",title:"Cannot fit that to a size",detail:`Forge cannot search ${n} \u2192 ${i} toward a size yet.`,hint:"Convert it first, then compress the result with --max-size.",shellHint:"Convert it first, then /compress the result to a size."}):new o({code:"unsupported-compress",title:"Cannot fit that to a size",detail:`${i} is lossless \u2014 there is no quality to trade away, so ${n} cannot be made to fit as ${i}.`,hint:"Drop --max-size, or choose a lossy target. forge --formats lists them.",shellHint:"Choose a lossy target to aim for a size."})}if(e.kind==="document"&&e.format==="pdf"){let i=e.images?.skipped??0;return new o({code:"unsupported-compress",title:"Nothing to compress",detail:i>0?`${n}'s images are a kind Forge cannot re-encode, so there is nothing to make smaller.`:`${n} has no images \u2014 it is text and layout, which compression cannot shrink.`,hint:"Try a page operation such as --extract to keep fewer pages, or --to <format> to turn its pages into images.",shellHint:"Try /pdf to keep fewer pages, or /convert to turn its pages into images."})}return e.kind==="document"?new o({code:"unsupported-compress",title:"Nothing to compress",detail:`${n} is ${a[e.format].label}, which has no images Forge can re-encode.`,hint:`Use --to pdf to change it to PDF instead: forge ${n} --to pdf`,shellHint:"Use /convert to change it to PDF instead."}):new o({code:"unsupported-compress",title:"Nothing to compress",detail:`${n} is ${a[e.format].label}, which is lossless \u2014 there is no quality to trade away.`,hint:"Use --to to change it to a smaller format instead. forge --formats lists them.",shellHint:"Use /convert to change it to a smaller format instead."})}function L(e){let t=r(e.path);return new o({code:"unsupported-pdf",title:"/pdf needs a PDF",detail:`${t} is ${a[e.format].label}, not a PDF.`,hint:"Converting it instead."})}function V(e,t,n){return new o({code:"unsupported-operation",title:`Cannot ${e} these files`,detail:`Not available for these files: ${t}.`,hint:n??"Page operations work on PDFs: --merge takes two or more, the others take one.",shellHint:n??"Use /pdf with a PDF staged \u2014 two or more for merge."})}function _(e,t,n){let i=e.kind==="media"?`The smallest ${r(e.path)} can get is ${s(n)}, which is still over ${s(t)}.`:`${r(e.path)} is ${s(n)} even at the lowest quality, which is still over ${s(t)}.`;return new o({code:"target-unreachable",title:"Cannot get that small",detail:i,hint:"Try a larger --max-size, or --to a smaller format.",shellHint:"Try a larger target, or /convert to a smaller format."})}function B(e,t,n){return new o({code:"unsupported-target",title:`Can't convert ${r(e.path)} to ${t}`,detail:`${r(e.path)} is a ${a[e.format].label} ${e.kind==="image"?"image":"document"}.`,hint:`Available: ${n.join(", ")}`})}function X(e,t){return new o({code:"corrupt-source",title:"Damaged file",detail:`${r(e)} could not be read. It may be damaged, or not a format Forge recognises.`,short:`${r(e)} could not be read.`,hint:"The file may be incomplete or corrupted.",cause:t})}function Y(e,t,n){return new o({code:"corrupt-source",title:`Damaged ${a[t].label}`,detail:`${r(e)} is a ${a[t].label} file, but its content could not be read.`,short:`${r(e)} could not be read.`,hint:"The file may be incomplete or corrupted.",cause:n})}function G(e,t={}){let n=r(e);return new o({code:"encrypted-source",title:"This PDF is password-protected",detail:`${n} is password-protected.`,short:`${n} is password-protected.`,hint:t.attempted?"That password didn't open it. Check it and try again.":`Convert it to images instead: forge ${n} --to jpeg --password-stdin`})}var u=e=>e==="convert"||e==="boost"||e==="remove-background";function K(e,t="convert"){return new o({code:"output-exists",title:"File already exists",detail:`${r(e)} is already there.`,hint:u(t)?"Pass --force to replace it, or choose a different --output.":"Pass --force to replace it, or move the existing file out of the way.",shellHint:"Run it again and Forge will ask before replacing it."})}function Q(e,t){return new o({code:"output-collision",title:"Two files want the same output",detail:`${r(e[0])} and ${r(e[1])} would both become ${r(t)}.`,hint:"Convert them separately, or use --output to send them to different folders.",shellHint:"Convert them one at a time."})}function Z(e,t){return new o({code:"output-collision",title:"One output, written twice",detail:`${r(e)} would write ${r(t)} twice, and only the second would survive.`,hint:"Every output has to be its own file. Check the selection for a repeated page."})}function ee(e,t="convert"){return new o({code:"output-is-input",title:"Output would replace the original",detail:`${r(e)} is both the input and the output.`,hint:u(t)?"Choose a different --output, or pass --force to overwrite in place.":"Move or rename that file first, or pass --force to overwrite it in place.",shellHint:u(t)?"Choose a different folder to save it in.":"Move or rename that file first."})}function x(e,t){return new o({code:"permission-denied",title:"Permission denied",detail:`${r(b(e))} is not a folder you can write to.`,hint:"Choose a different --output, or check the folder permissions.",shellHint:"Choose a different folder, or check its permissions.",cause:t})}var y=new Set(["EACCES","EPERM","EROFS"]);function te(e,t){if($(t))return t;let n=t?.code;return n!==void 0&&y.has(n)?x(e,t):t}function oe(e,t){return new o({code:"output-invalid",title:"Cannot write there",detail:`${e} could not be written to.`,hint:"Check that the path is valid and that you have permission to write to it.",cause:t})}function ne(e){return new o({code:"empty-directory",title:"No images found",detail:`${r(e)} contains no images Forge can convert.`,hint:"Try --recursive to look inside subfolders.",shellHint:"Only files directly inside a folder are read \u2014 drop the files themselves, or the folder that holds them."})}function re(e,t){return new o({code:"invalid-arguments",title:"Invalid arguments",detail:e,hint:t})}function ie(e,t,n){return new o({code:"invalid-page-range",title:"Page range not understood",detail:t,hint:`This document has ${n} pages. Use numbers and spans, like "3-7, 12, 20-".`})}function se(e){return new o({code:"empty-selection",title:"Nothing to write",detail:e,hint:"Select at least one page to keep."})}function ae(e){return new o({code:"invalid-dpi",title:"Invalid resolution",detail:`${String(e)} is not a resolution Forge can use.`,hint:"Give a number between 36 and 600. The default is 150."})}function le(e){return new o({code:"extension-missing",title:"Extension not installed",detail:`${e} is an optional extension and is not installed.`,hint:`Install it with: forge extensions add ${e}`,shellHint:"Open /extensions to install it."})}function de(e,t,n,i){return new o({code:"extension-outdated",title:"Extension out of date",detail:`${e} ${n} cannot ${t}; that needs ${i} or later.`,hint:`Update it with: forge extensions add ${e}`,shellHint:"Open /extensions to update it."})}function ue(e,t){return new o({code:"extension-corrupt",title:"Extension failed verification",detail:`${e}: ${t}`,hint:`Nothing was installed. Try again with: forge extensions add ${e}`,shellHint:"Nothing was installed. Try again from /extensions."})}function ce(e,t,n=process.platform){let i=n==="win32"?"PC":"Mac";return new o({code:"extension-unsupported",title:"Extension not available here",detail:`${e} cannot be installed on this ${i}: ${t}`,hint:"See what is available with: forge extensions",shellHint:"See what is available in /extensions."})}function pe(e,t=process.platform){let n=t==="win32"?"Windows":t==="darwin"?"macOS":"this system";return new o({code:"extension-unsupported",title:"Extension not available here",detail:`${e} is not available on ${n}.`,hint:"See what is available with: forge extensions",shellHint:"See what is available in /extensions."})}function ge(e){return new o({code:"update-unavailable",title:"Cannot update this Forge",detail:`This copy of Forge was not installed with npm i -g, so ${e} cannot be installed over it.`,hint:"npm i -g forge-terminal"})}function he(e,t=process.platform){return t==="win32"?new o({code:"update-denied",title:"Forge is in use",detail:`npm could not replace Forge's files to update it to ${e}. Windows keeps them locked while Forge runs: close every Forge window, then run the command below. If Node is installed for every user, run it in a terminal opened as administrator.`,short:"Windows locks Forge while it runs: close it, then run this",hint:`npm i -g forge-terminal@${e}`}):new o({code:"update-denied",title:"npm needs permission",detail:`npm needs permission to update Forge to ${e}.`,short:"npm needs permission to update Forge",hint:`sudo npm i -g forge-terminal@${e}`})}function fe(e,t){return new o({code:"update-failed",title:"Update failed",detail:`npm could not install Forge ${e}: ${t}`,short:"npm could not install the update",hint:`npm i -g forge-terminal@${e}`})}function me(){return new o({code:"update-unreachable",title:"Could not check for updates",detail:"The npm registry could not be reached.",short:"could not reach npm",hint:"Check your connection (and HTTPS_PROXY if you use a proxy), then run: forge update",shellHint:"Check your connection, then try again."})}function we(e,t){return new o({code:"extension-download-failed",title:"Download failed",detail:`${e}: ${t}`,hint:`Check your connection (and HTTPS_PROXY if you use a proxy), then run: forge extensions add ${e}`,shellHint:"Check your connection, then try again from /extensions."})}function be(e,t){return new o({code:"extension-download-failed",title:"Not enough disk space",detail:`${e}: ${t}`,hint:`Free some disk space, then run: forge extensions add ${e}`,shellHint:"Free some disk space, then try again from /extensions."})}function $e(e,t,n){let i=t?t.what?`${t.what} (forge, pid ${t.pid})`:`another forge (pid ${t.pid}) is using it`:"another forge is using it";return new o({code:"extension-in-use",title:"Extension in use",detail:`${e} is in use: ${i}.`,hint:n==="remove"?`Wait for that job to finish, then run: forge extensions remove ${e}`:"Wait for that job to finish, then try again.",shellHint:n==="remove"?"It can be removed when that job finishes.":"Try again when that job finishes."})}function xe(e){return new o({code:"no-subject",title:"No subject found",detail:`${r(e)} has no clear subject to cut out.`,hint:"Try a photo where the subject stands apart from the background."})}function ye(e,t,n){return n===1?new o({code:"boost-too-large",title:"Too large to sharpen",detail:`${r(e)} is too large to sharpen.`,hint:"Sharpen works on images up to 16,384 px a side and 100 megapixels."}):new o({code:"boost-too-large",title:"Too large to boost",detail:t>=2?`${r(e)} is too large to boost that far; ${t}x is the most it can take.`:`${r(e)} is already too large to boost.`,hint:t>=2?`Try --boost ${t}.`:"Boost works on images up to 100 megapixels.",shellHint:t>=2?`Choose ${t}x instead.`:void 0})}function Fe(e,t){return new o({code:"resize-too-large",title:"Too large to resize to",detail:`${r(e)} would be ${t.width} \xD7 ${t.height}.`,hint:"Resize works up to 16,384 px a side and 100 megapixels."})}function Ee(e){return new o({code:"no-clipboard-image",title:"No image",detail:e==="text"?"The clipboard holds text, not a picture.":"The clipboard is empty.",hint:"Copy a picture, or take a screenshot with \u2303\u21E7\u23184, then run forge clip again."})}function ve(){return new o({code:"clipboard-unavailable",title:"No clipboard",detail:"Forge reads the clipboard on a Mac, and not over SSH."})}function ke(){return new o({code:"nothing-to-undo",title:"Nothing to undo",detail:"No copied image has been changed yet."})}function Ce(e,t,n,i=!1){let l=r(e);if(i)return new o({code:"cannot-compress-more",title:"Cannot compress more",detail:`${l} is no smaller even at the lowest quality, so nothing was written.`,short:"nothing written"});let h=n>t?`would grow from ${s(t)} to ${s(n)}`:`would stay at ${s(t)}`;return new o({code:"cannot-compress-more",title:"Cannot compress more",detail:`${l} ${h}, so nothing was written.`,short:"nothing written",hint:"Try a lower --quality.",shellHint:"Try a lower quality."})}function Te(e,t,n){return new o({code:"cannot-compress-more",title:"Already small enough",detail:`${r(e)} is ${s(t)}, already under ${s(n)}, so nothing was written.`,short:"already under that size"})}function Se(e){return new o({code:"nothing-to-trim",title:"Nothing to trim",detail:`${r(e)} has no empty edges.`,short:"no empty edges"})}function He(e){return new o({code:"animated-trim",title:"Can't trim an animation",detail:`${r(e)} is animated; trimming works on still images.`})}function Pe(e,t){return new o({code:"nothing-to-crop",title:"Nothing to crop",detail:`${r(e)} is already ${t}.`,short:`already ${t}`})}function Ie(e){return new o({code:"animated-crop",title:"Can't crop an animation",detail:`${r(e)} is animated; cropping works on still images.`})}function Ne(e,t=process.platform,n=!1){let i=t==="win32"?"winget install ffmpeg":"brew install ffmpeg",l=n?`forge extensions add video (or ${i})`:i;return new o({code:"ffmpeg-missing",title:"Video and audio need ffmpeg",detail:`${r(e)} is a video or audio file, and ffmpeg is not on this computer.`,short:"ffmpeg is not on this computer",hint:`Install it with ${l}, then run Forge again.`})}function Ue(e,t){return new o({code:"conversion-failed",title:"Conversion failed",detail:`${r(e)} could not be converted.`,hint:"Run again with --debug for the underlying error.",shellHint:"Run the same conversion with forge --debug from the command line to see why.",cause:t})}function De(e){return new o({code:"no-sound",title:"Nothing to transcribe",detail:`${r(e)} has no sound.`})}function Oe(e){return new o({code:"unsupported-source",title:"Cannot transcribe this file",detail:`${r(e)} cannot be read by Apple's speech recogniser.`,hint:"MP4, MOV, M4A, MP3, WAV and AIFF files can be transcribed."})}function ze(e){return new o({code:"language-unsupported",title:"Language not supported",detail:`Apple's speech recogniser does not support ${e}.`,hint:"Pass another with --language, for example --language en-US."})}function Ae(e,t,n={}){return new o({code:"link-unavailable",title:"Cannot transcribe this link",detail:e,...n,...t===void 0?{}:{cause:t}})}function je(e){return new o({code:"transcribe-unavailable",title:"Transcribe is not available",detail:e})}function Me(e){return new o({code:"unexpected",title:"Something went wrong",detail:e instanceof Error?e.message:String(e),hint:"This was not expected. Try again \u2014 if it keeps happening, it may be worth reporting.",cause:e})}function Je(e,t={}){let n=[`\u2715 ${e.title}`,"",` ${e.detail}`];return e.hint&&n.push("",` ${e.hint}`),t.debug&&e.cause instanceof Error&&n.push("",` ${e.cause.stack??e.cause.message}`),n}export{d as a,C as b,r as c,$ as d,N as e,U as f,D as g,O as h,z as i,A as j,j as k,M as l,J as m,R as n,W as o,q as p,L as q,V as r,_ as s,B as t,X as u,Y as v,G as w,K as x,Q as y,Z as z,ee as A,x as B,te as C,oe as D,ne as E,re as F,ie as G,se as H,ae as I,le as J,de as K,ue as L,ce as M,pe as N,ge as O,he as P,fe as Q,me as R,we as S,be as T,$e as U,xe as V,ye as W,Fe as X,Ee as Y,ve as Z,ke as _,Ce as $,Te as aa,Se as ba,He as ca,Pe as da,Ie as ea,Ne as fa,Ue as ga,De as ha,Oe as ia,ze as ja,Ae as ka,je as la,Me as ma,Je as na};
@@ -1,3 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- var s="https://github.com/AtharvaN16/forge-terminal/releases/download",r=[{id:"boost",title:"Boost resolution",summary:"Sharpen, or boost resolution 2x or 4x, with a local AI model",minMacos:14,assets:{"darwin-arm64":{version:"1.0.0",url:`${s}/ext-boost-v1.0.0/forge-ext-boost-1.0.0-arm64.tar.gz`,bytes:14866325,sha256:"7af24c92f95b1cd34618adde4a90926c91a8db4347d640be4921f1dc706a9a2e"},"win32-x64":{version:"1.1.0",url:`${s}/ext-boost-v1.1.0/forge-ext-boost-1.1.0-win32-x64.tar.gz`,bytes:22993151,sha256:"abac81a9efe616f33b3bce98db2c0ff0b5597b43a7e3d5ea98968761a2b7a0ce"},"win32-arm64":{version:"1.1.0",url:`${s}/ext-boost-v1.1.0/forge-ext-boost-1.1.0-win32-arm64.tar.gz`,bytes:22936985,sha256:"7d39d93cae52f298423db0b185b0ae3a3bac65464abeb23561d9bcb2ebb3f026"}},licence:"Real-ESRGAN general-x4v3 (BSD-3-Clause), ONNX Runtime (MIT)"},{id:"remove-background",title:"Remove background",summary:"Cut the subject out of a photo, on this Mac",minMacos:14,assets:{"darwin-universal":{version:"1.0.0",url:`${s}/ext-remove-background-v1.0.0/forge-ext-remove-background-1.0.0-universal.tar.gz`,bytes:32489,sha256:"9f6e055c0ce25f7504e10c7871e506a813bc75d6536396a675a8c075c4eb4686"}},licence:"Uses Apple Vision on-device; helper is MIT"},{id:"heic",title:"HEIC photos",summary:"Open iPhone photos (HEIC) on Windows",assets:{"win32-universal":{version:"1.0.0",url:`${s}/ext-heic-v1.0.0/forge-ext-heic-1.0.0-win32-universal.tar.gz`,bytes:532364,sha256:"6c5f86c1a896d84264fb19371117e6ca6ec9b8726afec03f8c30aa5125a3ad97"}},licence:"libheif and libde265 (LGPL-3.0), via libheif-js"},{id:"video",title:"Video and audio",summary:"Convert, compress and trim video and audio (ffmpeg)",minMacos:13,assets:{},licence:"FFmpeg (GPL-2.0-or-later) with x264 (GPL-2.0), LAME (LGPL-2.0), Opus and libvpx (BSD), zimg (WTFPL)"},{id:"yt-dlp",title:"YouTube links",summary:"Transcribe YouTube videos: yt-dlp fetches their sound",minMacos:26,assets:{"darwin-universal":{version:"2026.08.19",url:"https://github.com/yt-dlp/yt-dlp/releases/download/2026.08.19/yt-dlp_macos",bytes:37146048,sha256:"0f192b7ec147ab6288885d6351d9ab67367640029b4377576ef46dd79cf7b202",binary:"yt-dlp"}},licence:"yt-dlp (Unlicense); its bundled Python and libraries under their own licences"}];function n(t){return r.find(e=>e.id===t)}function d(t,e=process.platform,a=process.arch){let o=t.assets;return o[`${e}-${a}`]??o[`${e}-universal`]}function i(t,e=process.platform){return Object.keys(t.assets).some(a=>a.startsWith(`${e}-`))}function c(t,e=process.platform){let a=n(t);return a!==void 0&&i(a,e)}export{r as a,n as b,d as c,i as d,c as e};
@@ -1,6 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{c as I}from"./chunk-EX7KZBI6.js";import{b as A}from"./chunk-HZDYZ5RD.js";import{J as T,ga as v,ha as N,ia as P,ja as $,ka as w,la as x}from"./chunk-3UEQ2OX6.js";var W=new Set(["youtube.com","www.youtube.com","m.youtube.com","music.youtube.com"]),B=/^[A-Za-z0-9_-]{11}$/,S=e=>e&&B.test(e)?{kind:"video",id:e,url:`https://www.youtube.com/watch?v=${e}`}:void 0;function de(e){let t=e.trim();if(t==="")return;let n;try{n=new URL(/^[a-z]+:\/\//i.test(t)?t:`https://${t}`)}catch{return}let r=n.hostname.toLowerCase();if(r==="youtu.be")return S(n.pathname.slice(1).split("/")[0]);if(!W.has(r))return;let[o,i]=n.pathname.split("/").filter(Boolean);if(o==="watch")return S(n.searchParams.get("v"));if(o==="shorts"||o==="live")return S(i);if(o==="playlist"&&n.searchParams.get("list"))return{kind:"playlist"}}import{spawn as O}from"node:child_process";import{mkdtemp as C,rm as G}from"node:fs/promises";import{tmpdir as K}from"node:os";import{join as R}from"node:path";import{createInterface as Y}from"node:readline";var H=[[/private video/i,"This video is private."],[/confirm your age/i,"This video is age-restricted."],[/members-only|join this channel/i,"This video is for channel members only."],[/live event will begin|premieres in/i,"This video has not started yet."],[/unavailable|has been removed|does not exist/i,"This video is unavailable."]],h=class extends Error{};async function he(e,t={}){let n=await I("yt-dlp");if(n===void 0)throw T("yt-dlp");let r=await C(R(K(),"forge-yt-"));t.onDir?.(r);let o=()=>G(r,{recursive:!0,force:!0});try{let i;try{i=await _(n.entry,e,r,t)}catch(u){if(!(u instanceof h))throw u;await z(n.entry,t.signal);try{i=await _(n.entry,e,r,t)}catch(a){throw a instanceof h?w(`yt-dlp could not fetch this video: ${a.message}`,a):a}}return{...i,dispose:o}}catch(i){throw await o(),i}}function _(e,t,n,r){let{signal:o}=r;if(o?.aborted)return Promise.reject(o.reason??new Error("aborted"));let i=["--js-runtimes",`node:${process.execPath}`,"--no-playlist","--no-warnings","--newline","--progress","-f","bestaudio[ext=m4a]/bestaudio","--print","before_dl:forge-facts %(.{title,uploader,duration,is_live})j","--progress-template","download:forge-bytes %(progress.downloaded_bytes)s %(progress.total_bytes,progress.total_bytes_estimate)s","--print","after_move:forge-file %(filepath)s","--no-simulate","-o",R(n,"sound.%(ext)s"),t];return new Promise((u,a)=>{let s=O(e,i,{stdio:["ignore","pipe","pipe"]}),d,l,g="",f=!1,p=c=>{f||(f=!0,o?.removeEventListener("abort",k),c())},k=()=>{s.kill("SIGKILL"),p(()=>a(o?.reason??new Error("aborted")))};o?.addEventListener("abort",k,{once:!0}),Y({input:s.stdout}).on("line",c=>{if(c.startsWith("forge-facts ")){let m=JSON.parse(c.slice(12));if(m.is_live===!0){s.kill("SIGKILL"),p(()=>a(w("Live streams cannot be transcribed.")));return}d={title:String(m.title??""),uploader:String(m.uploader??""),seconds:Number(m.duration??0)},r.onEvent?.({kind:"facts",facts:d})}else if(c.startsWith("forge-bytes ")){let[m,b]=c.slice(12).split(" ").map(Number);Number.isFinite(m)&&Number.isFinite(b)&&(b??0)>0&&r.onEvent?.({kind:"bytes",done:m,total:b})}else c.startsWith("forge-file ")&&(l=c.slice(11))}),s.stderr.on("data",c=>{g+=c.toString()}),s.on("error",c=>p(()=>a(new h(c.message)))),s.on("close",c=>p(()=>{if(c===0&&d!==void 0&&l!==void 0)return u({path:l,facts:d});let m=g.match(/ERROR: (?:\[[^\]]*\] )?(?:[\w-]+: )?(.*)/)?.[1]?.trim()??"",b=H.find(([j])=>j.test(m));a(b?w(b[1]):new h(m||`yt-dlp exited ${c}`))}))})}function z(e,t){return new Promise((n,r)=>{let o=O(e,["--update"],{stdio:"ignore"}),i=()=>o.kill("SIGKILL");t?.addEventListener("abort",i,{once:!0}),o.on("error",()=>n()),o.on("close",()=>{t?.removeEventListener("abort",i),t?.aborted?r(t.reason??new Error("aborted")):n()})})}var J="Summary and notes by Apple Intelligence. They may contain mistakes.";function M(e){let t=Math.floor(e),n=i=>String(i).padStart(2,"0"),r=Math.floor(t/3600),o=Math.floor(t/60)%60;return r>0?`${r}:${n(o)}:${n(t%60)}`:`${o}:${n(t%60)}`}var F=e=>e.split(/\s+/).filter(Boolean).length,X=60,Z=140,q=1,Q=10;function ee(e){let t=[],n;for(let r of e){if(n){let o=r.start-n.end;if(!(o>Q||o>q&&n.words>=X||n.words>=Z)){n.text+=` ${r.text}`,n.end=r.end,n.words+=F(r.text);continue}t.push({start:n.start,text:n.text})}n={start:r.start,end:r.end,text:r.text,words:F(r.text)}}return n&&t.push({start:n.start,text:n.text}),t}var D=e=>ee(e).flatMap(t=>[`**${M(t.start)}** ${t.text}`,""]),te=e=>/^https?:\/\/\S+$/.test(e)?`<${e}>`:e;function we(e,t,{transcript:n=!0}={}){let r=[`# ${t.title}`,"",te(t.from),""],o=e.notes;if(!o)return[...r,...D(e.segments)].join(`
4
- `);let i=o.parts,u=s=>{let d=i[s];return d?`### ${d.refused?`Part ${s+1}`:d.heading} \xB7 ${M(d.start)}`:""};r.push(o.summary,"","## Notes",""),i.forEach((s,d)=>{r.push(u(d),""),s.points.length>0&&r.push(...s.points.map(l=>`- ${l}`),"")});let a=[`_${J}_`,""];return n?(r.push("## Transcript",""),i.forEach((s,d)=>{let l=i[d+1]?.start??Number.POSITIVE_INFINITY,g=e.segments.filter(f=>f.start>=s.start&&f.start<l);r.push(u(d),"",...D(g))}),[...r,...a].join(`
5
- `)):[...r,...a].join(`
6
- `)}function ye(e){let t=[...e].map(n=>(n.codePointAt(0)??0)<32?" ":n).join("").replace(/[/\\:*?"<>|]/g,"-").replace(/\s+/g," ").trim().slice(0,120).replace(/^\.+/,"");return t===""?"transcript":t}import{spawn as ne}from"node:child_process";import{existsSync as U}from"node:fs";import{dirname as re,join as E}from"node:path";import{createInterface as oe}from"node:readline";import{fileURLToPath as ie}from"node:url";var y="forge-transcribe";function V(){let e=process.env.FORGE_TRANSCRIBE_HELPER;if(e!==void 0)return U(e)?e:void 0;if(process.platform!=="darwin")return;let t=re(ie(import.meta.url));return[E(t,"helpers",y),E(t,"..","helpers",y),E(t,"..","..","dist","helpers",y)].find(n=>U(n))}function L(e,t,n={}){let r=V();if(r===void 0)return Promise.reject(x("Transcribe needs macOS 26 or later on Apple silicon."));let{signal:o}=n;return o?.aborted?Promise.reject(o.reason??new Error("aborted")):new Promise((i,u)=>{let a=ne(r,e,{stdio:["ignore","pipe","ignore"]}),s,d=!1,l=f=>{d||(d=!0,o?.removeEventListener("abort",g),f())},g=()=>{a.kill("SIGKILL"),l(()=>u(o?.reason??new Error("aborted")))};o?.addEventListener("abort",g,{once:!0}),oe({input:a.stdout}).on("line",f=>{let p;try{p=JSON.parse(f)}catch{return}"ok"in p?s=p:n.onLine?.(p)}),a.on("error",f=>l(()=>u(v(t,f)))),a.on("close",()=>l(()=>{if(s===void 0)return u(v(t,new Error(`${y} gave no result`)));if(s.ok===!0)return i(s);u(se(String(s.code??""),String(s.message??""),t,e))}))})}function se(e,t,n,r){if(e==="no-sound")return N(n);if(e==="unreadable")return P(n);if(e==="locale"){let o=r.indexOf("--locale");return $(o>=0?r[o+1]??"this language":"this Mac's language")}return e==="unsupported"?x(t):v(n,new Error(`${e}: ${t}`))}async function $e(e={}){if(V()===void 0)return;let t=["status",...e.locale?["--locale",e.locale]:[]],n=await L(t,"");return{speech:n.speech===!0,locale:typeof n.locale=="string"?n.locale:null,notes:n.notes==="available"||n.notes==="off"?n.notes:"unsupported"}}async function Ie(e){let t=await L(["probe",e],e);return{seconds:Number(t.seconds)}}async function Ae(e,t){let n=["run",e,...t.locale?["--locale",t.locale]:[],...t.notes?["--notes"]:[],...t.notes&&t.detail&&t.detail!==A?["--detail",t.detail]:[]],r=await L(n,e,{signal:t.signal,onLine:o=>{let i=ae(o);i&&t.onEvent?.(i)}});return{locale:String(r.locale),seconds:Number(r.seconds),segments:r.segments,...r.notes?{notes:r.notes}:{}}}function ae(e){if(e.event==="model")return{kind:"model",fraction:Number(e.fraction)};if(e.event==="heard")return{kind:"heard",seconds:Number(e.seconds),of:Number(e.of)};if(e.event==="notes")return{kind:"notes",part:Number(e.part),of:Number(e.of)}}export{de as a,he as b,M as c,we as d,ye as e,$e as f,Ie as g,Ae as h};
@@ -1,63 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{a as B}from"./chunk-U5TEGDGH.js";import{a as K,b as Y}from"./chunk-HZDYZ5RD.js";import{h as W}from"./chunk-QR6QHTC3.js";import{b as J}from"./chunk-EEQSUBBL.js";import{a as D}from"./chunk-YYB3TTGT.js";import{l as L,n as U}from"./chunk-KAHWYWNT.js";import{F as d,I as H}from"./chunk-3UEQ2OX6.js";import{d as R}from"./chunk-J7FLFHQJ.js";import{a as X}from"./chunk-I2IATJNL.js";import{b as z}from"./chunk-M66BUNYO.js";var x=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},v=class extends x{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var E=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new v(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,n):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function V(s){let e=s.name()+(s.variadic===!0?"...":"");return s.required?"<"+e+">":"["+e+"]"}import{EventEmitter as ae}from"node:events";import G from"node:child_process";import C from"node:path";import F from"node:fs";import m from"node:process";import{stripVTControlCharacters as ue}from"node:util";import{stripVTControlCharacters as re}from"node:util";var T=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(i=>!i._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((i,r)=>i.name().localeCompare(r.name())),t}compareOptions(e,t){let n=i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,"");return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(i=>!i.hidden),n=e._getHelpOption();if(n&&!n.hidden){let i=n.short&&e._findOption(n.short),r=n.long&&e._findOption(n.long);!i&&!r?t.push(n):n.long&&!r?t.push(e.createOption(n.long,n.description)):n.short&&!i&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let i=n.options.filter(r=>!r.hidden);t.push(...i)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(n=>V(n)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(i)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(i)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let n="";for(let i=e.parent;i;i=i.parent)n=i.name()+" "+n;return n+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,""]}groupItems(e,t,n){let i=new Map;return e.forEach(r=>{let o=n(r);i.has(o)||i.set(o,[])}),t.forEach(r=>{let o=n(r);i.has(o)||i.set(o,[]),i.get(o).push(r)}),i}formatHelp(e,t){let n=t.padWidth(e,t),i=t.helpWidth??80;function r(c,p){return t.formatItem(c,n,p,t)}let o=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],u=t.commandDescription(e);u.length>0&&(o=o.concat([t.boxWrap(t.styleCommandDescription(u),i),""]));let l=t.visibleArguments(e).map(c=>r(t.styleArgumentTerm(t.argumentTerm(c)),t.styleArgumentDescription(t.argumentDescription(c))));if(o=o.concat(this.formatItemList("Arguments:",l,t)),this.groupItems(e.options,t.visibleOptions(e),c=>c.helpGroupHeading??"Options:").forEach((c,p)=>{let O=c.map(_=>r(t.styleOptionTerm(t.optionTerm(_)),t.styleOptionDescription(t.optionDescription(_))));o=o.concat(this.formatItemList(p,O,t))}),t.showGlobalOptions){let c=t.visibleGlobalOptions(e).map(p=>r(t.styleOptionTerm(t.optionTerm(p)),t.styleOptionDescription(t.optionDescription(p))));o=o.concat(this.formatItemList("Global Options:",c,t))}return this.groupItems(e.commands,t.visibleCommands(e),c=>c.helpGroup()||"Commands:").forEach((c,p)=>{let O=c.map(_=>r(t.styleSubcommandTerm(t.subcommandTerm(_)),t.styleSubcommandDescription(t.subcommandDescription(_))));o=o.concat(this.formatItemList(p,O,t))}),o.join(`
4
- `)}displayWidth(e){return re(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t==="[command]"?this.styleSubcommandText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleCommandText(t)).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,i){let o=" ".repeat(2);if(!n)return o+e;let u=e.padEnd(t+e.length-i.displayWidth(e)),l=2,a=(this.helpWidth??80)-t-l-2,c;return a<this.minWidthToWrap||i.preformatted(n)?c=n:c=i.boxWrap(n,a).replace(/\n/g,`
5
- `+" ".repeat(t+l)),o+u+" ".repeat(l)+c.replace(/\n/g,`
6
- ${o}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),i=/[\s]*[^\s]+/g,r=[];return n.forEach(o=>{let u=o.match(i);if(u===null){r.push("");return}let l=[u.shift()],h=this.displayWidth(l[0]);u.forEach(a=>{let c=this.displayWidth(a);if(h+c<=t){l.push(a),h+=c;return}r.push(l.join(""));let p=a.trimStart();l=[p],h=this.displayWidth(p)}),r.push(l.join(""))}),r.join(`
7
- `)}};var A=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=oe(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new v(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,n):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?Q(this.name().replace(/^no-/,"")):Q(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},N=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,n)=>{this.positiveOptions.has(n)&&this.dualOptions.add(n)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let i=this.negativeOptions.get(n).presetArg,r=i!==void 0?i:!1;return t.negate===(r===e)}};function Q(s){return s.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function oe(s){let e,t,n=/^-[^-]$/,i=/^--[^-]/,r=s.split(/[ |,]+/).concat("guard");if(n.test(r[0])&&(e=r.shift()),i.test(r[0])&&(t=r.shift()),!e&&n.test(r[0])&&(e=r.shift()),!e&&i.test(r[0])&&(e=t,t=r.shift()),r[0].startsWith("-")){let o=r[0],u=`option creation failed due to '${o}' in option flags '${s}'`;throw/^-[^-][^-]/.test(o)?new Error(`${u}
8
- - a short flag is a single dash and a single character
9
- - either use a single dash and a single character (for a short flag)
10
- - or use a double dash for a long option (and can have two, like '--ws, --workspace')`):n.test(o)?new Error(`${u}
11
- - too many short flags`):i.test(o)?new Error(`${u}
12
- - too many long flags`):new Error(`${u}
13
- - unrecognised flag format`)}if(e===void 0&&t===void 0)throw new Error(`option creation failed due to no flags found in '${s}'.`);return{shortFlag:e,longFlag:t}}function se(s,e){if(Math.abs(s.length-e.length)>3)return Math.max(s.length,e.length);let t=[];for(let n=0;n<=s.length;n++)t[n]=[n];for(let n=0;n<=e.length;n++)t[0][n]=n;for(let n=1;n<=e.length;n++)for(let i=1;i<=s.length;i++){let r;s[i-1]===e[n-1]?r=0:r=1,t[i][n]=Math.min(t[i-1][n]+1,t[i][n-1]+1,t[i-1][n-1]+r),i>1&&n>1&&s[i-1]===e[n-2]&&s[i-2]===e[n-1]&&(t[i][n]=Math.min(t[i][n],t[i-2][n-2]+1))}return t[s.length][e.length]}function q(s,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=s.startsWith("--");t&&(s=s.slice(2),e=e.map(o=>o.slice(2)));let n=[],i=3,r=.4;return e.forEach(o=>{if(o.length<=1)return;let u=se(s,o),l=Math.max(s.length,o.length);(l-u)/l>r&&(u<i?(i=u,n=[o]):u===i&&n.push(o))}),n.sort((o,u)=>o.localeCompare(u)),t&&(n=n.map(o=>`--${o}`)),n.length>1?`
14
- (Did you mean one of ${n.join(", ")}?)`:n.length===1?`
15
- (Did you mean ${n[0]}?)`:""}var $=class s extends ae{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:t=>m.stdout.write(t),writeErr:t=>m.stderr.write(t),outputError:(t,n)=>n(t),getOutHelpWidth:()=>m.stdout.isTTY?m.stdout.columns:void 0,getErrHelpWidth:()=>m.stderr.isTTY?m.stderr.columns:void 0,getOutHasColors:()=>ee()??(m.stdout.isTTY&&m.stdout.hasColors?.()),getErrHasColors:()=>ee()??(m.stderr.isTTY&&m.stderr.hasColors?.()),stripColor:t=>ue(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,n){let i=t,r=n;typeof i=="object"&&i!==null&&(r=i,i=null),r=r||{};let[,o,u]=e.match(/([^ ]+) *(.*)/),l=this.createCommand(o);return i&&(l.description(i),l._executableHandler=!0),r.isDefault&&(this._defaultCommandName=l._name),l._hidden=!!(r.noHelp||r.hidden),l._executableFile=r.executableFile||null,u&&l.arguments(u),this._registerCommand(l),l.parent=this,l.copyInheritedSettings(this),i?this:l}createCommand(e){return new s(e)}createHelp(){return Object.assign(new T,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...e},this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
16
- - specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new E(e,t)}argument(e,t,n,i){let r=this.createArgument(e,t);return typeof n=="function"?r.default(i).argParser(n):r.default(n),this.addArgument(r),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t?.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,e&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let n=e??"help [command]",[,i,r]=n.match(/([^ ]+) *(.*)/),o=t??"display help for command",u=this.createCommand(i);return u.helpOption(!1),r&&u.arguments(r),o&&u.description(o),this._addImplicitHelpCommand=!0,this._helpCommand=u,(e||t)&&this._initCommandGroup(u),this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(e),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let n=["preSubcommand","preAction","postAction"];if(!n.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
17
- Expecting one of '${n.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,n){this._exitCallback&&this._exitCallback(new x(e,t,n)),m.exit(e)}action(e){let t=n=>{let i=this.registeredArguments.length,r=n.slice(0,i);return this._storeOptionsAsProperties?r[i]=this:r[i]=this.opts(),r.push(this),e.apply(this,r)};return this._actionHandler=t,this}createOption(e,t){return new A(e,t)}_callParseArg(e,t,n,i){try{return e.parseArg(t,n)}catch(r){if(r.code==="commander.invalidArgument"){let o=`${i} ${r.message}`;this.error(o,{exitCode:r.exitCode,code:r.code})}throw r}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let n=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${n}'
18
- - already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=i=>[i.name()].concat(i.aliases()),n=t(e).find(i=>this._findCommand(i));if(n){let i=t(this._findCommand(n)).join("|"),r=t(e).join("|");throw new Error(`cannot add command '${r}' as already have command '${i}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),n=e.attributeName();e.defaultValue!==void 0&&this.setOptionValueWithSource(n,e.defaultValue,"default");let i=(r,o,u)=>{r==null&&e.presetArg!==void 0&&(r=e.presetArg);let l=this.getOptionValue(n);r!==null&&e.parseArg?r=this._callParseArg(e,r,l,o):r!==null&&e.variadic&&(r=e._collectValue(r,l)),r==null&&(e.negate?r=!1:e.isBoolean()||e.optional?r=!0:r=""),this.setOptionValueWithSource(n,r,u)};return this.on("option:"+t,r=>{let o=`error: option '${e.flags}' argument '${r}' is invalid.`;i(r,o,"cli")}),e.envVar&&this.on("optionEnv:"+t,r=>{let o=`error: option '${e.flags}' value '${r}' from env '${e.envVar}' is invalid.`;i(r,o,"env")}),this}_optionEx(e,t,n,i,r){if(typeof t=="object"&&t instanceof A)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let o=this.createOption(t,n);if(o.makeOptionMandatory(!!e.mandatory),typeof i=="function")o.default(r).argParser(i);else if(i instanceof RegExp){let u=i;i=(l,h)=>{let a=u.exec(l);return a?a[0]:h},o.default(r).argParser(i)}else o.default(i);return this.addOption(o)}option(e,t,n,i){return this._optionEx({},e,t,n,i)}requiredOption(e,t,n,i){return this._optionEx({mandatory:!0},e,t,n,i)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,n){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=n,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(n=>{n.getOptionValueSource(e)!==void 0&&(t=n.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){m.versions?.electron&&(t.from="electron");let i=m.execArgv??[];(i.includes("-e")||i.includes("--eval")||i.includes("-p")||i.includes("--print"))&&(t.from="eval")}e===void 0&&(e=m.argv),this.rawArgs=e.slice();let n;switch(t.from){case void 0:case"node":this._scriptPath=e[1],n=e.slice(2);break;case"electron":m.defaultApp?(this._scriptPath=e[1],n=e.slice(2)):n=e.slice(1);break;case"user":n=e.slice(0);break;case"eval":n=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",n}parse(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return this._parseCommand([],n),this}async parseAsync(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return await this._parseCommand([],n),this}_prepareForParse(){this._savedState===null?(this.options.filter(e=>e.negate&&e.defaultValue===void 0&&this.getOptionValue(e.attributeName())===void 0).forEach(e=>{let t=e.long.replace(/^--no-/,"--");this._findOption(t)||this.setOptionValueWithSource(e.attributeName(),!0,"default")}),this.saveStateBeforeParse()):this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
19
- - either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(e,t,n){if(F.existsSync(e))return;let i=t?`searched for local subcommand relative to directory '${t}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",r=`'${e}' does not exist
20
- - if '${n}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
21
- - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
22
- - ${i}`;throw new Error(r)}_executeSubCommand(e,t){t=t.slice();let n=[".js",".ts",".tsx",".mjs",".cjs"];function i(a,c){let p=C.resolve(a,c);if(F.existsSync(p))return p;if(n.includes(C.extname(c)))return;let O=n.find(_=>F.existsSync(`${p}${_}`));if(O)return`${p}${O}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=e._executableFile||`${this._name}-${e._name}`,o=this._executableDir||"";if(this._scriptPath){let a;try{a=F.realpathSync(this._scriptPath)}catch{a=this._scriptPath}o=C.resolve(C.dirname(a),o)}if(o){let a=i(o,r);if(!a&&!e._executableFile&&this._scriptPath){let c=C.basename(this._scriptPath,C.extname(this._scriptPath));c!==this._name&&(a=i(o,`${c}-${e._name}`))}r=a||r}let u=n.includes(C.extname(r)),l;m.platform!=="win32"?u?(t.unshift(r),t=Z(m.execArgv).concat(t),l=G.spawn(m.argv[0],t,{stdio:"inherit"})):l=G.spawn(r,t,{stdio:"inherit"}):(this._checkForMissingExecutable(r,o,e._name),t.unshift(r),t=Z(m.execArgv).concat(t),l=G.spawn(m.execPath,t,{stdio:"inherit"})),l.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(c=>{m.on(c,()=>{l.killed===!1&&l.exitCode===null&&l.kill(c)})});let h=this._exitCallback;l.on("close",a=>{a=a??1,h?h(new x(a,"commander.executeSubCommandAsync","(close)")):m.exit(a)}),l.on("error",a=>{if(a.code==="ENOENT")this._checkForMissingExecutable(r,o,e._name);else if(a.code==="EACCES")throw new Error(`'${r}' not executable`);if(!h)m.exit(1);else{let c=new x(1,"commander.executeSubCommandAsync","(error)");c.nestedError=a,h(c)}}),this.runningCommand=l}_dispatchSubcommand(e,t,n){let i=this._findCommand(e);i||this.help({error:!0}),i._prepareForParse();let r;return r=this._chainOrCallSubCommandHook(r,i,"preSubcommand"),r=this._chainOrCall(r,()=>{if(i._executableHandler)this._executeSubCommand(i,t.concat(n));else return i._parseCommand(t,n)}),r}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(n,i,r)=>{let o=i;if(i!==null&&n.parseArg){let u=`error: command-argument value '${i}' is invalid for argument '${n.name()}'.`;o=this._callParseArg(n,i,r,u)}return o};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,i)=>{let r=n.defaultValue;n.variadic?i<this.args.length?(r=this.args.slice(i),n.parseArg&&(r=r.reduce((o,u)=>e(n,u,o),n.defaultValue))):r===void 0&&(r=[]):i<this.args.length&&(r=this.args[i],n.parseArg&&(r=e(n,r,n.defaultValue))),t[i]=r}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,i=[];return this._getCommandAndAncestors().reverse().filter(r=>r._lifeCycleHooks[t]!==void 0).forEach(r=>{r._lifeCycleHooks[t].forEach(o=>{i.push({hookedCommand:r,callback:o})})}),t==="postAction"&&i.reverse(),i.forEach(r=>{n=this._chainOrCall(n,()=>r.callback(r.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let i=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(r=>{i=this._chainOrCall(i,()=>r(this,t))}),i}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let i=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},r=`command:${this.name()}`;if(this._actionHandler){i(),this._processArguments();let o;return o=this._chainOrCallHooks(o,"preAction"),o=this._chainOrCall(o,()=>this._actionHandler(this.processedArgs)),this.parent&&(o=this._chainOrCall(o,()=>{this.parent.emit(r,e,t)})),o=this._chainOrCallHooks(o,"postAction"),o}if(this.parent?.listenerCount(r))i(),this._processArguments(),this.parent.emit(r,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(i(),this._processArguments())}else this.commands.length?(i(),this.help({error:!0})):(i(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(n=>{let i=n.attributeName();return this.getOptionValue(i)===void 0?!1:this.getOptionValueSource(i)!=="default"});e.filter(n=>n.conflictsWith.length>0).forEach(n=>{let i=e.find(r=>n.conflictsWith.includes(r.attributeName()));i&&this._conflictingOption(n,i)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],i=t;function r(a){return a.length>1&&a[0]==="-"}let o=a=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(a)?!this._getCommandAndAncestors().some(c=>c.options.map(p=>p.short).some(p=>/^-\d$/.test(p))):!1,u=null,l=null,h=0;for(;h<e.length||l;){let a=l??e[h++];if(l=null,a==="--"){i===n&&i.push(a),i.push(...e.slice(h));break}if(u&&(!r(a)||o(a))){this.emit(`option:${u.name()}`,a);continue}if(u=null,r(a)){let c=this._findOption(a);if(c){if(c.required){let p=e[h++];p===void 0&&this.optionMissingArgument(c),this.emit(`option:${c.name()}`,p)}else if(c.optional){let p=null;h<e.length&&(!r(e[h])||o(e[h]))&&(p=e[h++]),this.emit(`option:${c.name()}`,p)}else this.emit(`option:${c.name()}`);u=c.variadic?c:null;continue}}if(a.length>2&&a[0]==="-"&&a[1]!=="-"){let c=this._findOption(`-${a[1]}`);if(c){c.required||c.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${c.name()}`,a.slice(2)):(this.emit(`option:${c.name()}`),l=`-${a.slice(2)}`);continue}}if(/^--[^=]+=/.test(a)){let c=a.indexOf("="),p=this._findOption(a.slice(0,c));if(p&&(p.required||p.optional)){this.emit(`option:${p.name()}`,a.slice(c+1));continue}}if(i===t&&r(a)&&!(this.commands.length===0&&o(a))&&(i=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(a)){t.push(a),n.push(...e.slice(h));break}else if(this._getHelpCommand()&&a===this._getHelpCommand().name()){t.push(a,...e.slice(h));break}else if(this._defaultCommandName){n.push(a,...e.slice(h));break}}if(this._passThroughOptions){i.push(a,...e.slice(h));break}i.push(a)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let i=this.options[n].attributeName();e[i]=i===this._versionOptionName?this._version:this[i]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
23
- `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
24
- `):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
25
- `),this.outputHelp({error:!0}));let n=t||{},i=n.exitCode||1,r=n.code||"commander.error";this._exit(i,r,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in m.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,m.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new N(this.options),t=n=>this.getOptionValue(n)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(n));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(n=>{Object.keys(n.implied).filter(i=>!t(i)).forEach(i=>{this.setOptionValueWithSource(i,n.implied[i],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let n=o=>{let u=o.attributeName(),l=this.getOptionValue(u),h=this.options.find(c=>c.negate&&u===c.attributeName()),a=this.options.find(c=>!c.negate&&u===c.attributeName());return h&&(h.presetArg===void 0&&l===!1||h.presetArg!==void 0&&l===h.presetArg)?h:a||o},i=o=>{let u=n(o),l=u.attributeName();return this.getOptionValueSource(l)==="env"?`environment variable '${u.envVar}'`:`option '${u.flags}'`},r=`error: ${i(e)} cannot be used with ${i(t)}`;this.error(r,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let i=[],r=this;do{let o=r.createHelp().visibleOptions(r).filter(u=>u.long).map(u=>u.long);i=i.concat(o),r=r.parent}while(r&&!r._enablePositionalOptions);t=q(e,i)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?"":"s",i=e.length,r=this.parent?` for '${this.name()}'`:"",o=e.join(", "),u=`error: too many arguments${r}. Expected ${t} argument${n} but got ${i}: ${o}.`;this.error(u,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let i=[];this.createHelp().visibleCommands(this).forEach(r=>{i.push(r.name()),r.alias()&&i.push(r.alias())}),t=q(e,i)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:"commander.unknownCommand"})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",n=n||"output the version number";let i=this.createOption(t,n);return this._versionOptionName=i.attributeName(),this._registerOption(i),this.on("option:"+i.name(),()=>{this._outputConfiguration.writeOut(`${e}
26
- `),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let n=this.parent?._findCommand(e);if(n){let i=[n.name()].concat(n.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${i}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(n=>V(n));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=C.basename(e,C.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let i=t.formatHelp(this,t);return n.hasColors?i:this._outputConfiguration.stripColor(i)}_getOutputContext(e){e=e||{};let t=!!e.error,n,i,r;return t?(n=u=>this._outputConfiguration.writeErr(u),i=this._outputConfiguration.getErrHasColors(),r=this._outputConfiguration.getErrHelpWidth()):(n=u=>this._outputConfiguration.writeOut(u),i=this._outputConfiguration.getOutHasColors(),r=this._outputConfiguration.getOutHelpWidth()),{error:t,write:u=>(i||(u=this._outputConfiguration.stripColor(u)),n(u)),hasColors:i,helpWidth:r}}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let n=this._getOutputContext(e),i={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(o=>o.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let r=this.helpInformation({error:n.error});if(t&&(r=t(r),typeof r!="string"&&!Buffer.isBuffer(r)))throw new Error("outputHelp callback must return a string or a Buffer");n.write(r),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",i),this._getCommandAndAncestors().forEach(o=>o.emit("afterAllHelp",i))}helpOption(e,t){return typeof e=="boolean"?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??"-h, --help",t??"display help for command"),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(m.exitCode??0);t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let n=["beforeAll","before","after","afterAll"];if(!n.includes(e))throw new Error(`Unexpected value for position to addHelpText.
27
- Expecting one of '${n.join("', '")}'`);let i=`${e}Help`;return this.on(i,r=>{let o;typeof t=="function"?o=t({error:r.error,command:r.command}):o=t,o&&r.write(`${o}
28
- `)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(i=>t.is(i))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Z(s){return s.map(e=>{if(!e.startsWith("--inspect"))return e;let t,n="127.0.0.1",i="9229",r;return(r=e.match(/^(--inspect(-brk)?)$/))!==null?t=r[1]:(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=r[1],/^\d+$/.test(r[3])?i=r[3]:n=r[3]):(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=r[1],n=r[3],i=r[4]),t&&i!=="0"?`${t}=${n}:${parseInt(i)+1}`:e})}function ee(){if(m.env.NO_COLOR||m.env.FORCE_COLOR==="0"||m.env.FORCE_COLOR==="false")return!1;if(m.env.FORCE_COLOR||m.env.CLICOLOR_FORCE!==void 0)return!0}var Xe=new $;function le(s){let[,e,t,...n]=s;if(e===void 0||e==="list")return{kind:"config",action:"list"};if(e==="path")return{kind:"config",action:"path"};if(e==="set"){if(t===void 0||!D.includes(t))throw d(`Unknown config setting ${t??"(none)"}.`,`Try one of: ${D.join(", ")}.`);let i=n.join(" ");if(i.length===0)throw d(`forge config set ${t} needs a value.`);return{kind:"config",action:"set",key:t,value:i}}throw d(`Unknown config action ${e}.`,"Try: forge config list, forge config set <setting> <value>, or forge config path.")}var he={jpg:"jpeg",tif:"tiff",heif:"heic"};function I(s){let e=s.toLowerCase().replace(/^\./,""),t=z(he[e]??e);if(!t)throw d(`${s} is not a format Forge knows.`,"Run forge --formats to see what is available.");return t.id}function P(s,e,t,n,i){let r=Number(String(e).replace(/k$/i,""));if(!Number.isFinite(r)||r<t||r>n)throw d(`${s} takes ${t} to ${n}, not ${e}.`,`For example ${s} ${i}.`);return r}function ce(s){let e={};if(s.cut!==void 0){let t=J(String(s.cut));if(!t)throw d(`--cut takes a start and an end, the end after the start, not ${s.cut}.`,"For example --cut 0:03.2-0:41, or --cut 0:10- to keep from 0:10 to the end.");e.cut=t.end===void 0?{start:t.start}:{start:t.start,end:t.end}}return s.mute&&(e.mute=!0),s.speed!==void 0&&(e.speed=P("--speed",s.speed,.25,4,"2")),s.fps!==void 0&&(e.fps=P("--fps",s.fps,1,120,"30")),s.bitrate!==void 0&&(e.bitrate=Math.round(P("--bitrate",s.bitrate,32,320,"128k"))),s.loudness!==void 0&&(e.loudness=P("--loudness",s.loudness,-70,-5,"-16")),Object.keys(e).length?e:void 0}function S(s){let e=Number(s);if(!Number.isInteger(e)||e<1||e>100)throw d(`Quality must be a whole number between 1 and 100, not ${s}.`);return e}function te(s,e){let t=/^\d+$/.test(String(e))?Number(e):Number.NaN;if(!Number.isInteger(t)||t<1)throw d(`${s} takes a whole number of pixels, at least 1, not ${e}.`);return t}function de(s){let e=String(s),t=/^\d+(\.\d+)?%?$/.test(e)?Number.parseFloat(e):Number.NaN;if(!(t>=1&&t<=W))throw d(`--resize takes a percent from 1 to ${W}, not ${s}.`,"Try --resize 50% to halve, or --width 1200 for an exact width.");return t}function j(s){let e=Number(s);if(!Number.isInteger(e)||e<1)throw d(`Concurrency must be a positive whole number, not ${s}.`);return e}var pe=`
29
- Exit codes:
30
- 0 every input succeeded
31
- 1 the command was understood, and at least one input failed or was refused
32
- 2 the command itself was invalid: an unknown flag, a missing argument, contradictory flags`,fe=`
33
- Other commands:
34
- forge probe <files...> what each file is and what Forge can do with it
35
- forge palette <image> an image's main colours (--json, --svg, --inside <hex>)
36
- forge scale <colour> 50\u2013950 from one colour, with it at 500 (--json, --svg)
37
- forge clip compress the copied image and put it back (--to, --quality,
38
- --max-size, --save [folder], --undo)
39
- forge transcribe <file | link>
40
- a video or audio file, or a YouTube link, into Markdown
41
- (--to all | notes | transcript, --detail brief | standard | detailed,
42
- --language <id>, -o <path>, --force)
43
- forge watch <folder> --to <format>
44
- convert the folder, then every file added to it, until ctrl-c
45
- (--quality, --dpi, -o <folder>, --new-only, --json)
46
- forge config [list | path | set <setting> <value>]
47
- forge extensions [add | remove <id>] optional extras, such as boost and remove-background
48
- forge update install a newer Forge, if there is one
49
- forge uninstall take Forge out of the right-click menu, then remove it
50
- forge mcp run as a local MCP server over stdio, for AI agents`;function M(s){let e=R(String(s));if(e===void 0)throw d(`${s} is not a size.`,"Try a number with a unit, for example 500kb, 2mb or 1.5mb.");return e}function me(s){let e=s.slice(1).filter(n=>n!=="--json"),t=e.find(n=>n.startsWith("-"));if(t!==void 0)throw d(`forge probe takes files, not ${t}.`,"Try: forge probe photo.jpg --json");if(e.length===0)throw d("No files given.","Name a file, for example: forge probe scan.pdf --json");return{kind:"probe",inputs:e}}function ge(s){let e={kind:"clip",undo:!1,debug:!1},t=s.slice(1),n=(i,r)=>{let o=t[r+1];if(o===void 0||o.startsWith("-"))throw d(`${i} needs a value.`);return o};for(let i=0;i<t.length;i++){let r=t[i];if(r!=="--json")if(r==="--debug")e.debug=!0;else if(r==="--undo")e.undo=!0;else if(r==="--to"||r==="-t")e.target=I(n(r,i++));else if(r==="--quality"||r==="-q")e.quality=S(n(r,i++));else if(r==="--max-size")e.maxBytes=M(n(r,i++));else if(r==="--save"){let o=t[i+1];e.save=o===void 0||o.startsWith("-")?!0:t[++i]}else throw r.startsWith("-")?d(`forge clip does not take ${r}.`,"Try: forge --help"):d(`forge clip takes no files: it reads the clipboard, not ${r}.`,`To compress a file, try: forge ${r} --quality 80`)}if(e.undo&&Object.keys(e).some(i=>!["kind","undo","debug"].includes(i)))throw d("--undo takes no other flag.","Try: forge clip --undo");if(e.quality!==void 0&&e.maxBytes!==void 0)throw d("Use either --quality or --max-size, not both.","They are two ways of asking for the same thing, and Forge will not guess which wins.");return e}function be(s){let e=s.slice(1),t=[],n={kind:"transcribe",input:"",notes:!0,transcript:!0,detail:Y,force:!1,debug:!1},i=(l,h)=>{let a=e[h+1];if(a===void 0||a.startsWith("-"))throw d(`${l} needs a value.`);return a},r="Try: forge transcribe talk.mp4";for(let l=0;l<e.length;l++){let h=e[l];if(h==="--debug")n.debug=!0;else if(h==="--force"||h==="-f")n.force=!0;else if(h==="--language"||h==="-l")n.language=i(h,l++);else if(h==="--output"||h==="-o")n.output=i(h,l++);else if(h==="--detail"){let a=i(h,l++).toLowerCase();if(!K.includes(a))throw d(`forge transcribe writes notes in brief, standard or detailed, not ${a}.`,"Try: forge transcribe talk.mp4 --detail brief");n.detail=a}else if(h==="--to"||h==="-t"){let a=i(h,l++).toLowerCase();if(a!=="all"&&a!=="notes"&&a!=="transcript")throw d(`forge transcribe makes all, notes or a transcript, not ${a}.`,"Try: forge transcribe talk.mp4 --to transcript");n.notes=a!=="transcript",n.transcript=a!=="notes"}else{if(h.startsWith("-"))throw d(`forge transcribe does not take ${h}.`,r);t.push(h)}}let[o,...u]=t;if(o===void 0)throw d("forge transcribe needs a file or a link.",r);if(u.length>0)throw d("forge transcribe takes one file or link at a time.",r);return{...n,input:o}}function _e(s){let e=s.slice(1),t=[],n,i={kind:"watch",newOnly:!1,debug:!1},r={},o=(h,a)=>{let c=e[a+1];if(c===void 0||c.startsWith("-"))throw d(`${h} needs a value.`);return c};for(let h=0;h<e.length;h++){let a=e[h];if(a!=="--json")if(a==="--debug")i.debug=!0;else if(a==="--new-only")i.newOnly=!0;else if(a==="--to"||a==="-t")n=I(o(a,h++));else if(a==="--quality"||a==="-q")r.quality=S(o(a,h++));else if(a==="--output"||a==="-o")r.output=o(a,h++);else if(a==="--dpi"){let c=o(a,h++),p=Number(c);if(!Number.isInteger(p)||p<36||p>600)throw H(c);r.dpi=p}else{if(a.startsWith("-"))throw d(`forge watch does not take ${a}.`,"Try: forge watch ./images --to webp");t.push(a)}}let[u,...l]=t;if(u===void 0)throw d("forge watch needs a folder.","Try: forge watch ./images --to webp");if(l.length>0)throw d("forge watch watches one folder at a time.",`Try: forge watch ${u} --to webp`);if(n===void 0)throw d("forge watch needs a format to convert to.",`Try: forge watch ${u} --to webp`);return{kind:"watch",folder:u,target:n,...r.quality===void 0?{}:{quality:r.quality},...r.dpi===void 0?{}:{dpi:r.dpi},...r.output===void 0?{}:{output:r.output},newOnly:i.newOnly,debug:i.debug}}function we(s){let e=s.slice(1).filter(o=>o!=="--json"),t=e.find(o=>o.startsWith("-"));if(t!==void 0)throw d(`forge extensions does not take ${t}.`,"Try: forge extensions, forge extensions add <id>, or forge extensions remove <id>.");let[n,i,...r]=e;if(n===void 0)return{kind:"extensions",action:"list"};if(n!=="add"&&n!=="remove")throw d(`Unknown extensions action ${n}.`,"Try: forge extensions, forge extensions add <id>, or forge extensions remove <id>.");if(i===void 0||r.length>0)throw d(`forge extensions ${n} takes exactly one extension.`,`Try: forge extensions ${n} boost`);return{kind:"extensions",action:n,id:i}}function ne(s){if(s===void 0)throw d("No colour given.","Try: forge scale 6579FD \u2014 or quote it, '#6579FD', because an unquoted # starts a comment in the shell.");let e=B(s)?.rgb;if(!e)throw d(`${s} is not a colour.`,"Try a hex code (6579FD), rgb(), hsl(), oklch() or a colour name, quoted: 'rgb(101 121 253)'.");return e}var ye={palette:`Usage: forge palette <image> [--json] [--svg] [--inside <hex>]
51
-
52
- An image's main colours, most of the image first.
53
- --json one JSON document: palette.colours[] with hex, rgb, oklch, share
54
- --svg a card of swatches; pipe to pbcopy and paste into Figma
55
- --inside <hex> the shades of the palette colour nearest <hex>
56
- `,scale:`Usage: forge scale <colour> [--json] [--svg]
57
-
58
- 50\u2013950 built in OKLCH, with <colour> at 500. Pass the hex without #, or quote it.
59
- --json one JSON document: scale.steps[] with hex, oklch, white, black
60
- --svg a card of swatches; pipe to pbcopy and paste into Figma
61
- `};function Oe(s){let[e,...t]=s;if(t.includes("--help")||t.includes("-h"))throw process.stdout.write(ye[e==="scale"?"scale":"palette"]),new x(0,"commander.helpDisplayed","(outputHelp)");let n=t.filter(l=>l!=="--json"&&l!=="--svg"),i=t.includes("--svg"),r=n.indexOf("--inside"),o=r===-1?void 0:n[r+1];r!==-1&&n.splice(r,2);let u=n.find(l=>l.startsWith("-"));if(u!==void 0)throw d(`forge ${e} does not take ${u}.`,`Try: forge ${e} --help`);if(e==="scale"){if(r!==-1)throw d("--inside is for forge palette.","Try: forge palette photo.jpg --inside F26E69");if(n.length>1)throw d("forge scale takes one colour.","Try: forge scale 6579FD");return{kind:"scale",colour:ne(n[0]),svg:i}}if(n.length!==1)throw d(n.length===0?"No image given.":"forge palette takes one image.","Try: forge palette photo.jpg");return{kind:"palette",input:n[0],svg:i,...r===-1?{}:{inside:ne(o)}}}function ct(s){let e=s.indexOf("--");return(e===-1?s:s.slice(0,e)).includes("--json")}function xe(s){let e=s.indexOf("--"),t=e===-1?s:s.slice(0,e),n=e===-1?[]:s.slice(e),i=[],r;for(let o=0;o<t.length;o++){let u=t[o],l=u.startsWith("--boost=")?u.slice(8):void 0;if(u!=="--boost"&&l===void 0){i.push(u);continue}let h=l;if(h===void 0&&/^\d+$/.test(t[o+1]??"")&&(h=t[++o]),h!==void 0&&h!=="2"&&h!=="3"&&h!=="4")throw d(`--boost takes 2, 3 or 4, not ${h}.`,"Try --boost, --boost 2, --boost 3 or --boost 4.");r=h==="4"?4:h==="3"?3:2}return{rest:[...i,...n],...r===void 0?{}:{scale:r}}}function dt(s){let e=s;if(e[0]==="clip"||e[0]==="watch"||e[0]==="transcribe"||e[0]==="config"||e[0]==="probe"||e[0]==="extensions"||e[0]==="palette"||e[0]==="scale"||e[0]==="update"||e[0]==="uninstall")return Ce(e);let t=xe(e);return ke(t.rest,t.scale)}function Ce(s){if(s[0]==="update"){let e=s.slice(1).filter(t=>t!=="--json");if(e.length>0)throw d(`forge update takes nothing else, got: ${e.join(" ")}.`,"Try: forge update");return{kind:"update"}}if(s[0]==="uninstall"){let e=s.slice(1);if(e.length>0)throw d(`forge uninstall takes nothing else, got: ${e.join(" ")}.`,"Try: forge uninstall");return{kind:"uninstall"}}return s[0]==="clip"?ge(s):s[0]==="watch"?_e(s):s[0]==="transcribe"?be(s):s[0]==="config"?le(s.filter(e=>e!=="--json")):s[0]==="probe"?me(s):s[0]==="palette"||s[0]==="scale"?Oe(s):we(s)}function ke(s,e){let t=new $().name("forge").description("Convert \u2014 transform your files from the terminal").argument("[inputs...]","files, folders or globs").option("-t, --to <format>","target format").option("-o, --output <path>","output file or directory").option("-q, --quality <n>","quality for lossy formats, 1-100").option("--background <colour>","fill colour when flattening transparency","#ffffff").option("--keep-metadata","preserve EXIF and GPS data",!1).option("--recursive","descend into subfolders",!1).option("--force","allow overwriting existing files",!1).option("--max-size <size>","compress until the file fits, e.g. 500kb").option("--concurrency <n>","how many files to convert at once").option("--debug","show underlying errors",!1).option("--formats","list supported formats",!1).option("--merge","combine several PDFs into one").option("--split <mode>","every-page | every=N | at=N,N").option("--extract <pages>","keep only these pages, e.g. 3-7,12").option("--delete <pages>","drop these pages").option("--rotate <degrees>","90, 180 or 270").option("--separate","with --extract, write one file per page").option("--sharpen","sharpen at the same size; needs the boost extension").option("--boost [2|3|4]","sharpen and enlarge 2x (default), 3x or 4x; needs the boost extension").option("--trim","cut transparent or solid-colour edges; keeps the format").option("--crop <W:H>","cut to a shape, e.g. 1:1, 4:5, 16:9; keeps the subject").option("--resize <percent>","resize to a percent of the size, 1-200, e.g. 50%").option("--width <px>","resize to this width; the height follows").option("--height <px>","resize to this height; the width follows").option("--remove-bg","cut out the subject; needs the remove-background extension").option("--cut <start-end>","video or audio: keep from start to end, e.g. 0:03.2-0:41").option("--mute","video: take the sound out").option("--speed <x>","video or audio: play faster or slower, 0.25-4").option("--fps <n>","video: frames per second").option("--bitrate <kbps>","audio: bitrate, e.g. 128k").option("--loudness <LUFS>","audio: even out loudness to this level, e.g. -16").option("--preset <name>","run a preset saved from Done, e.g. --preset blog").option("--pages <ranges>","with --to, which pages to render, e.g. 3-7,12").option("--dpi <n>","rasterisation resolution, 36-600","150").option("--password-stdin","read an encrypted PDF's password from stdin").option("--json","print one JSON document on stdout instead of text").helpOption("-h, --help","show this help").version(X,"-V, --version","show the version").addHelpText("after",`${fe}
62
- ${pe}`).configureOutput({outputError:()=>{}}).exitOverride().allowExcessArguments(!1);try{t.parse(s,{from:"user"})}catch(f){if(f instanceof x&&f.code!=="commander.helpDisplayed"&&f.code!=="commander.version"){let[g="",...b]=f.message.replace(/^error: /,"").split(`
63
- `),w=b.join(" ").trim().replace(/^\((.*)\)\.?$/,"$1");throw d(`${g.charAt(0).toUpperCase()}${g.slice(1).replace(/\.$/,"")}.`,w||"Run forge --help to see what Forge accepts.")}throw f}let n=t.opts(),i=t.args;if(n.formats)return{kind:"formats"};let r=ce(n);if(r!==void 0&&n.trim)throw d("--trim cuts the empty edges of an image.","To keep part of a video or audio file, use --cut, for example --cut 0:03-0:41.");if(n.preset!==void 0){let f=[["to","--to"],["quality","--quality"],["maxSize","--max-size"],["merge","--merge"],["split","--split"],["extract","--extract"],["delete","--delete"],["rotate","--rotate"],["sharpen","--sharpen"],["trim","--trim"],["crop","--crop"],["resize","--resize"],["width","--width"],["height","--height"],["removeBg","--remove-bg"],["pages","--pages"]].filter(([g])=>n[g]!==void 0&&n[g]!==!1).map(([,g])=>g);if(e!==void 0&&f.push("--boost"),f.length>0)throw d(`--preset already says what to do \u2014 leave out ${f.join(" and ")}.`,"Run the preset alone, or change it from Done with \u2192 continue editing.");return{kind:"preset",inputs:i,name:String(n.preset),...n.output===void 0?{}:{output:String(n.output)},force:n.force===!0,recursive:n.recursive===!0,debug:n.debug===!0}}if(n.pages!==void 0&&n.to===void 0)throw d("--pages needs --to: it chooses which pages to render.");let o=["merge","split","extract","delete","rotate"].filter(f=>n[f]!==void 0);if(o.length>1)throw d(`Use one operation at a time \u2014 got ${o.map(f=>`--${f}`).join(" and ")}.`);let u=[...n.sharpen?["--sharpen"]:[],...e!==void 0?["--boost"]:[],...n.removeBg?["--remove-bg"]:[]],l=[...n.resize!==void 0?["--resize"]:[],...n.width!==void 0?["--width"]:[],...n.height!==void 0?["--height"]:[]],h=r!==void 0&&!n.to&&n.quality===void 0&&n.maxSize===void 0;if(n.trim||n.crop!==void 0||l.length>0||h){if(l.length>1)throw d(`Use one of --resize, --width and --height \u2014 got ${l.join(" and ")}.`);let f=n.crop!==void 0?"--crop":l[0]??(n.trim?"--trim":"--cut"),g=[...n.crop!==void 0&&n.trim?["--trim"]:[],...u,...n.maxSize!==void 0?["--max-size"]:[],...n.pages!==void 0?["--pages"]:[],...o.map(ie=>`--${ie}`)][0];if(g!==void 0)throw d(`${f} cannot be combined with ${g}.`,g!=="--max-size"?"Run them one after the other.":f==="--crop"?"Crop first, then compress the result: forge photo-cropped-1x1.jpg --max-size 500kb":"Resize first, then compress the result: forge photo-1200x900.jpg --max-size 500kb");let b=n.crop!==void 0?{aspect:L(String(n.crop))}:void 0,w=n.resize!==void 0?{percent:de(n.resize)}:n.width!==void 0?{width:te("--width",n.width)}:n.height!==void 0?{height:te("--height",n.height)}:void 0;if(i.length===0)throw d("No files given.","Name an image, for example: forge photo.jpg --resize 50%");let k={background:String(n.background),keepMetadata:!!n.keepMetadata};n.quality!==void 0&&(k.quality=S(String(n.quality)));let y={kind:"edit",inputs:i,trim:!!n.trim,options:k,force:!!n.force,recursive:!!n.recursive,debug:!!n.debug};return b!==void 0&&(y.crop=b),w!==void 0&&(y.resize=w),r!==void 0&&(y.media=r),n.to&&(y.target=I(String(n.to))),n.output!==void 0&&(y.output=String(n.output)),n.concurrency!==void 0&&(y.concurrency=j(String(n.concurrency))),y}let a=n.sharpen?1:e,c=a!==void 0?"boost":n.removeBg?"remove-background":null;if(c!==null){if(u.length>1)throw d(`Use one operation at a time \u2014 got ${u.join(" and ")}.`);let f=u[0];if(o.length>0)throw d(`${f} cannot be combined with --${o[0]}.`);if(n.maxSize!==void 0||n.pages!==void 0)throw d(`${f} cannot be combined with ${n.maxSize!==void 0?"--max-size":"--pages"}.`);if(i.length===0)throw d("No files given.",`Name an image, for example: forge photo.jpg ${f}`);let g=n.to?I(String(n.to)):"png";if(c==="remove-background"){let k=U(g);if(k)throw k}let b={background:String(n.background),keepMetadata:!!n.keepMetadata};n.quality!==void 0&&(b.quality=S(String(n.quality)));let w={kind:"extension-op",op:c,inputs:i,target:g,options:b,force:!!n.force,recursive:!!n.recursive,debug:!!n.debug};return a!==void 0&&(w.scale=a),n.output!==void 0&&(w.output=String(n.output)),n.concurrency!==void 0&&(w.concurrency=j(String(n.concurrency))),w}if(o.length===1){let f=o[0];if(i.length===0)throw d("No files given.",`Name a PDF, for example: forge doc.pdf --${f}`);if(n.separate&&f!=="extract")throw d(`--separate only applies to --extract, not --${f}.`);if(n.output!==void 0)throw d(`--output does not apply to --${f}.`,"Page operations name their own outputs, beside the source. Rename the result afterwards.");let g={kind:"pageop",action:f,inputs:i,force:!!n.force,debug:!!n.debug};if(f==="rotate"){let b=Number(n.rotate);if(!Number.isInteger(b)||b%90!==0||b===0||b>=360)throw d(`--rotate takes a multiple of 90 below 360, not "${n.rotate}".`);g.rotate=b}if((f==="extract"||f==="delete")&&(g.pages=String(n[f]),f==="extract"&&n.separate&&(g.separate=!0)),f==="split"){let b=String(n.split),w=b.match(/^every=(\d+)$/),k=b.match(/^at=([\d,\s]+)$/);if(b==="every-page")g.split={mode:"every-page"};else if(w?.[1]!==void 0){let y=Number(w[1]);if(!Number.isInteger(y)||y<1)throw d(`--split every=N takes a whole number of pages, at least 1, not "${w[1]}".`);g.split={mode:"every-n",n:y}}else if(k?.[1])g.split={mode:"points",after:k[1].split(",").map(y=>Number(y.trim()))};else throw d(`--split takes every-page, every=N or at=N,N \u2014 not "${b}".`)}return g}if(i.length===0&&!n.to&&n.quality===void 0&&n.maxSize===void 0)return{kind:"shell"};if(n.quality!==void 0&&n.maxSize!==void 0)throw d("Use either --quality or --max-size, not both.","They are two ways of asking for the same thing, and Forge will not guess which wins.");if(!n.to&&(n.quality!==void 0||n.maxSize!==void 0)){if(i.length===0)throw d("No files given.","Name a file, for example: forge photo.jpg --max-size 500kb");let f={background:String(n.background),keepMetadata:!!n.keepMetadata};r!==void 0&&(f.media=r);let g={kind:"compress",inputs:i,options:f,force:!!n.force,recursive:!!n.recursive,debug:!!n.debug};if(n.quality!==void 0&&(g.quality=S(String(n.quality))),n.maxSize!==void 0&&(g.maxBytes=M(n.maxSize)),n.output!==void 0&&(g.output=String(n.output)),t.getOptionValueSource("dpi")==="cli"){let b=Number(n.dpi);if(!Number.isInteger(b)||b<36||b>600)throw H(n.dpi);g.dpi=b}return n.concurrency!==void 0&&(g.concurrency=j(String(n.concurrency))),g}if(!n.to)throw d("No target format given.","Add --to <format>, for example: forge photo.jpg --to webp");if(i.length===0)throw d("No files given.","Name a file, a folder or a glob, for example: forge photo.jpg --to webp");let p={background:String(n.background),keepMetadata:!!n.keepMetadata};n.quality!==void 0&&(p.quality=S(String(n.quality))),r!==void 0&&(p.media=r);let O=Number(n.dpi);if(!Number.isInteger(O)||O<36||O>600)throw H(n.dpi);let _={kind:"convert",inputs:i,target:I(String(n.to)),options:p,force:!!n.force,recursive:!!n.recursive,debug:!!n.debug,dpi:O,passwordStdin:!!n.passwordStdin};return n.output!==void 0&&(_.output=String(n.output)),n.pages!==void 0&&(_.pages=String(n.pages)),n.maxSize!==void 0&&(_.maxBytes=M(n.maxSize)),n.concurrency!==void 0&&(_.concurrency=j(String(n.concurrency))),_}export{pe as a,fe as b,ct as c,dt as d};
@@ -1,78 +0,0 @@
1
- import { createRequire as __forgeCreateRequire } from 'node:module';
2
- const require = __forgeCreateRequire(import.meta.url);
3
- import{execFile as de}from"node:child_process";import{chmodSync as ye,mkdirSync as Y,readFileSync as he,rmSync as w,writeFileSync as we}from"node:fs";import{dirname as Se,join as u}from"node:path";var ne={convert:"#55c7d9",compress:"#79c98b",edit:"#b39ae8",pdf:"#ff6b4a"},re="#55c7d9",oe="#a68ce0",ie=4/5,se=(e,t,n,o)=>`<path fill="${o}" d="M${e} ${t}h${4*n}v${n}h${-3*n}v${n}h${2*n}v${n}h${-2*n}v${2*n}h${-n}z"/>`;function ae(e,t){let n=t<=20,o=n?3:4,r=n?6:4.6,i=n?51:51.5,a=Array.from({length:o},(p,m)=>i-(o-1-m)*r).map(p=>`<line x1="${p}" y1="66" x2="${p+66*ie}" y2="0"/>`).join(""),c=e==="forge"?"url(#w)":ne[e];return`<svg width="${t}" height="${t}" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg"><defs><linearGradient id="w" gradientUnits="userSpaceOnUse" x1="34" y1="0" x2="62" y2="0"><stop offset="0" stop-color="${re}"/><stop offset="1" stop-color="${oe}"/></linearGradient><clipPath id="c"><rect width="64" height="64" rx="14"/></clipPath><clipPath id="i"><rect x="1.5" y="1.5" width="61" height="61" rx="12.5"/></clipPath></defs><g clip-path="url(#c)"><rect width="64" height="64" fill="#1e1e1e"/><g clip-path="url(#i)" stroke="${c}" stroke-width="${n?3.6:2.4}">${a}</g>${se(16,12,8,"#e7e7e7")}</g><rect x=".75" y=".75" width="62.5" height="62.5" rx="13.5" fill="none" stroke="#3a3a3a" stroke-width="1.5"/></svg>`}async function d(e,t){let{default:n}=await import("sharp");return n(Buffer.from(ae(e,t))).png().toBuffer()}function O(e){let t=Buffer.alloc(6);t.writeUInt16LE(0,0),t.writeUInt16LE(1,2),t.writeUInt16LE(e.length,4);let n=6+16*e.length,o=e.map(({size:r,png:i})=>{let s=Buffer.alloc(16);return s[0]=r>=256?0:r,s[1]=r>=256?0:r,s.writeUInt16LE(1,4),s.writeUInt16LE(32,6),s.writeUInt32LE(i.length,8),s.writeUInt32LE(n,12),n+=i.length,s});return Buffer.concat([t,...o,...e.map(r=>r.png)])}function y(e){let t=[{action:"open",label:"Open Forge",kinds:["image","folder"],window:!0,paint:"forge"},{action:"convert",label:"Convert in Forge",kinds:["image","folder"],window:!0,paint:"convert"},{action:"compress",label:"Compress in Forge",kinds:["image","folder"],window:!0,paint:"compress"},{action:"sharpen",label:"Sharpen in Forge",kinds:["image"],window:!1,paint:"edit"},{action:"open-pdf",label:"Open in Forge",kinds:["pdf"],window:!0,paint:"pdf"}];return e.sharpen?t:t.filter(n=>n.action!=="sharpen")}var k=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");function S(e,t){if(typeof e=="string")return`${t}<string>${k(e)}</string>`;if(typeof e=="number")return`${t}<integer>${e}</integer>`;if(typeof e=="boolean")return`${t}<${e}/>`;if(Array.isArray(e))return`${t}<array>
4
- ${e.map(o=>S(o,`${t} `)).join(`
5
- `)}
6
- ${t}</array>`;let n=Object.entries(e).map(([o,r])=>`${t} <key>${k(o)}</key>
7
- ${S(r,`${t} `)}`);return n.length===0?`${t}<dict/>`:`${t}<dict>
8
- ${n.join(`
9
- `)}
10
- ${t}</dict>`}var B=e=>`<?xml version="1.0" encoding="UTF-8"?>
11
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
12
- <plist version="1.0">
13
- ${S(e,"")}
14
- </plist>
15
- `,ce={image:"public.image",folder:"public.folder",pdf:"com.adobe.pdf"};function le(e){return e.length===1&&e[0]==="image"?"com.apple.Automator.fileSystemObject.image":e.length===1&&e[0]==="pdf"?"com.apple.Automator.fileSystemObject.PDF":e.length===1&&e[0]==="folder"?"com.apple.Automator.fileSystemObject.folder":"com.apple.Automator.fileSystemObject"}var l=e=>`'${e.replace(/'/g,"'\\''")}'`,$="forge",R=e=>`com.forge-terminal.menu.${e.action}`,U="runWorkflowAsService",v=e=>`${R(e)} - ${e.label} - ${U}`,ue=`ObjC.import('Foundation')
16
- function run(argv) {
17
- const domain = argv[0]
18
- const defaults = $.NSUserDefaults.standardUserDefaults
19
- const or = (v) => (v.isNil() ? $.NSDictionary.dictionary : v)
20
- const all = $.NSMutableDictionary.dictionaryWithDictionary(or(defaults.persistentDomainForName(domain)))
21
- const status = $.NSMutableDictionary.dictionaryWithDictionary(or(all.objectForKey('NSServicesStatus')))
22
- const on = { presentation_modes: { ContextMenu: true, FinderPreview: true, ServicesMenu: true, TouchBar: true } }
23
- for (const arg of argv.slice(1)) {
24
- const key = arg.slice(1)
25
- if (arg[0] === '+') status.setObjectForKey($(on), key)
26
- else status.removeObjectForKey(key)
27
- }
28
- all.setObjectForKey(status, 'NSServicesStatus')
29
- defaults.setPersistentDomainForName(all, domain)
30
- }`;function g(e){return[e.osascript??"/usr/bin/osascript",["-l","JavaScript","-e",ue,e.domain??"pbs",...e.on.map(t=>`+${t}`),...e.off.map(t=>`-${t}`)]]}function T(e,t){let n=B({CFBundleDevelopmentRegion:"English",CFBundleIdentifier:R(e),CFBundleInfoDictionaryVersion:"6.0",CFBundleName:e.label,CFBundlePackageType:"BNDL",CFBundleShortVersionString:"1.0",CFBundleVersion:"1",NSServices:[{NSIconName:$,NSMenuItem:{default:e.label},NSMessage:U,NSRequiredContext:{NSApplicationIdentifier:"com.apple.finder"},NSSendFileTypes:e.kinds.map(i=>ce[i])}]}),o=`${l(t)} ${e.action} "$@"`,r=B({AMApplicationBuild:"521",AMApplicationVersion:"2.10",AMDocumentVersion:"2",actions:[{action:{AMAccepts:{Container:"List",Optional:!0,Types:["com.apple.cocoa.path"]},AMActionVersion:"2.0.3",AMApplication:["Automator"],AMParameterProperties:{COMMAND_STRING:{},CheckedForUserDefaultShell:{},inputMethod:{},shell:{},source:{}},AMProvides:{Container:"List",Types:["com.apple.cocoa.string"]},ActionBundlePath:"/System/Library/Automator/Run Shell Script.action",ActionName:"Run Shell Script",ActionParameters:{COMMAND_STRING:o,CheckedForUserDefaultShell:!0,inputMethod:1,shell:"/bin/zsh",source:""},BundleIdentifier:"com.apple.RunShellScript",CFBundleVersion:"2.0.3",CanShowSelectedItemsWhenRun:!1,CanShowWhenRun:!0,Category:["AMCategoryUtilities"],"Class Name":"RunShellScriptAction",InputUUID:"7A1F3C2E-0F4B-4E8A-9C61-5B2D8E4F1A01",OutputUUID:"7A1F3C2E-0F4B-4E8A-9C61-5B2D8E4F1A02",UUID:"7A1F3C2E-0F4B-4E8A-9C61-5B2D8E4F1A03",UnlocalizedApplications:["Automator"]},isViewVisible:!0}],connectors:{},workflowMetaData:{serviceApplicationBundleID:"com.apple.finder",serviceApplicationPath:"/System/Library/CoreServices/Finder.app",serviceInputTypeIdentifier:le(e.kinds),serviceOutputTypeIdentifier:"com.apple.Automator.nothing",serviceProcessesInput:!1,workflowTypeIdentifier:"com.apple.Automator.servicesMenu"}});return{name:`${e.label}.workflow`,files:{"Contents/Info.plist":n,"Contents/document.wflow":r,"Contents/Resources/document.wflow":r}}}import{execFile as pe}from"node:child_process";var x="ForgeTerminal.Forge",L=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),M=e=>e.replace(/['‘’‚‛]/g,"$&$&"),j=M;function I(e,t){return["[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null","[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] > $null","$x = New-Object Windows.Data.Xml.Dom.XmlDocument",`$x.LoadXml('<toast><visual><binding template="ToastText02"><text id="1">${j(L(e))}</text><text id="2">${j(L(t))}</text></binding></visual></toast>')`,`[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier('${x}').Show([Windows.UI.Notifications.ToastNotification]::new($x))`].join("; ")}function me(e,t,n=process.platform){return n==="win32"?["powershell.exe",["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-Command",I(e,t)]]:["/usr/bin/osascript",["-e","on run argv","-e","display notification (item 2 of argv) with title (item 1 of argv)","-e","end run",e,t]]}function Ae(e,t,n=process.platform){let[o,r]=me(e,t,n);return new Promise(i=>{pe(o,r,{timeout:1e4,windowsHide:!0},()=>i())})}var _="Forge was uninstalled",H="Its menu items are removed.",fe="Forge could not start",ge="Run forge in a terminal once to set its menu up again.";function K(e){let{osascript:t,pbs:n}=e.tools??{osascript:"/usr/bin/osascript",pbs:"/System/Library/CoreServices/pbs"},o=[e.node,...e.execArgv,e.forge].map(l).join(" "),[r,i]=g({on:[],off:e.services,osascript:t}),s=[r,...i].map(l).join(" "),a=(c,p)=>`${l(t)} -e 'display notification "${p}" with title "${c}"'`;return`#!/bin/sh
31
- # Forge's right-click menu. Rewritten by Forge whenever it sets the menu up.
32
- if [ ! -f ${l(e.forge)} ]; then
33
- # Forge is gone: take its menu with it, and say so once.
34
- ${e.bundles.map(c=>` rm -rf ${l(c)}`).join(`
35
- `)}
36
- rm -rf ${l(e.menuDir)}
37
- ${s}
38
- ${l(n)} -update
39
- ${a(_,H)}
40
- exit 0
41
- fi
42
- if [ ! -x ${l(e.node)} ]; then
43
- ${a(fe,ge)}
44
- exit 1
45
- fi
46
- ${e.xdgConfigHome===void 0?"":`export XDG_CONFIG_HOME=${l(e.xdgConfigHome)}
47
- `}exec ${o} menu run "$@"
48
- `}function V(e){let t=e.xdgConfigHome===void 0?{}:{XDG_CONFIG_HOME:e.xdgConfigHome};return`// Forge's right-click menu. Rewritten by Forge whenever it sets the menu up.
49
- import { execFileSync, spawn } from 'node:child_process'
50
- import { existsSync, rmSync } from 'node:fs'
51
-
52
- const FORGE = ${JSON.stringify(e.forge)}
53
- const ARGS = ${JSON.stringify(e.execArgv)}
54
- const MENU = ${JSON.stringify(e.menuDir)}
55
- const KEYS = ${JSON.stringify(e.keys)}
56
- const ENV = ${JSON.stringify(t)}
57
-
58
- if (existsSync(FORGE)) {
59
- const child = spawn(process.execPath, [...ARGS, FORGE, 'menu', 'run', ...process.argv.slice(2)], {
60
- stdio: 'inherit',
61
- windowsHide: true,
62
- env: { ...process.env, ...ENV },
63
- })
64
- child.on('exit', (code) => process.exit(code ?? 0))
65
- } else {
66
- // Forge is gone: say so while its app ID still exists, then take the menu with it.
67
- try {
68
- execFileSync('powershell.exe', ['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-Command', ${JSON.stringify(I(_,H))}], { windowsHide: true })
69
- } catch {}
70
- for (const key of KEYS) {
71
- try {
72
- execFileSync('reg.exe', ['delete', key, '/f'], { windowsHide: true, stdio: 'ignore' })
73
- } catch {}
74
- }
75
- rmSync(MENU, { recursive: true, force: true })
76
- }
77
- `}var h="HKCU\\Software\\Classes",G=`${h}\\SystemFileAssociations\\image\\shell\\Forge`,W=`${h}\\Directory\\shell\\Forge`,N=`${h}\\SystemFileAssociations\\.pdf\\shell\\ForgeOpen`,J=`${h}\\AppUserModelId\\${x}`,D=()=>[G,W,N,J],F=e=>`${e.paint}.ico`;function X(e){let t=i=>`conhost.exe --headless "${e.node}" "${e.menuDir}\\run.mjs" ${i} "%1"`,n=i=>`${e.menuDir}\\${F(i)}`,o=(i,s)=>{let a=e.items.filter(c=>c.kinds.includes(s));return a.length===0?[]:[{key:i,values:{MUIVerb:"Forge",Icon:n({paint:"forge"}),SubCommands:""}},...a.flatMap((c,p)=>{let m=`${i}\\shell\\${p+1}${c.action}`;return[{key:m,values:{MUIVerb:c.label,Icon:n(c)}},{key:`${m}\\command`,values:{"":t(c.action)}}]})]},r=e.items.find(i=>i.kinds.includes("pdf"));return[...o(G,"image"),...o(W,"folder"),...r?[{key:N,values:{MUIVerb:r.label,Icon:n(r)}},{key:`${N}\\command`,values:{"":t(r.action)}}]:[],{key:J,values:{DisplayName:"Forge",IconUri:`${e.menuDir}\\forge.png`}}]}var b=e=>`'${M(e)}'`,A=e=>b(`Registry::${e.replace(/^HKCU\\/,"HKEY_CURRENT_USER\\")}`);function C(e){return["$ErrorActionPreference = 'Stop'",...D().map(n=>`Remove-Item -Path ${A(n)} -Recurse -Force -ErrorAction SilentlyContinue`),...e.flatMap(({key:n,values:o})=>[`New-Item -Path ${A(n)} -Force | Out-Null`,...Object.entries(o).map(([r,i])=>`Set-ItemProperty -LiteralPath ${A(n)} -Name ${b(r===""?"(default)":r)} -Value ${b(i)}`)])].join(`
78
- `)}var je=(e,t)=>e.version===t.version&&e.forge===t.forge&&e.node===t.node&&e.execArgv.join("\0")===t.execArgv.join("\0")&&e.xdgConfigHome===t.xdgConfigHome,Q="/System/Library/CoreServices/pbs",q=e=>u(e.menuDir,"state.json"),Z=e=>u(e.home,"Library","Services"),E=e=>y({sharpen:!0}).map(t=>u(Z(e),`${t.label}.workflow`)),P=()=>y({sharpen:!0}).map(v);function $e(e){try{return JSON.parse(he(q(e),"utf8"))}catch{return}}var _e=e=>$e(e)!==void 0,f=(e,t)=>{Y(Se(e),{recursive:!0}),we(e,t)};async function He(e){if(e.platform!=="darwin"&&e.platform!=="win32")return;let t=y({sharpen:e.sharpen});if(Y(e.menuDir,{recursive:!0}),e.platform==="darwin"){let o=u(e.menuDir,"run");f(o,K({...e,bundles:E(e),services:P()})),ye(o,493);for(let a of E(e))w(a,{recursive:!0,force:!0});let r=new Map,{default:i}=await import("sharp");for(let a of t){r.has(a.paint)||r.set(a.paint,await i(await d(a.paint,64)).tiff().toBuffer());let{name:c,files:p}=T(a,o),m=u(Z(e),c);for(let[ee,te]of Object.entries(p))f(u(m,ee),te);f(u(m,"Contents","Resources",`${$}.tiff`),r.get(a.paint))}let s=t.map(v);await e.run(...g({on:s,off:P().filter(a=>!s.includes(a))})),await e.run(Q,["-update"])}else{f(u(e.menuDir,"run.mjs"),V({...e,keys:D()}));let o=["forge","convert","compress","edit","pdf"];for(let r of o){let i=await Promise.all([16,24,32,48,256].map(async s=>({size:s,png:await d(r,s)})));f(u(e.menuDir,F({paint:r})),O(i))}f(u(e.menuDir,"forge.png"),await d("forge",256)),await e.run("powershell.exe",z(C(X({...e,items:t}))))}let n={version:e.version,forge:e.forge,node:e.node,execArgv:e.execArgv,...e.xdgConfigHome===void 0?{}:{xdgConfigHome:e.xdgConfigHome}};f(q(e),JSON.stringify(n))}async function Ke(e){if(e.platform==="darwin"){for(let t of E(e))w(t,{recursive:!0,force:!0});w(e.menuDir,{recursive:!0,force:!0}),await e.run(...g({on:[],off:P()})),await e.run(Q,["-update"])}else e.platform==="win32"&&(w(e.menuDir,{recursive:!0,force:!0}),await e.run("powershell.exe",z(C([]))))}var z=e=>["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-Command",e],Ve=(e,t)=>new Promise((n,o)=>{de(e,t,{timeout:6e4,windowsHide:!0},r=>r?o(r):n())});export{l as a,Ae as b,je as c,$e as d,_e as e,He as f,Ke as g,Ve as h};