forge-terminal 0.5.7 → 0.5.8
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.
- package/README.md +11 -6
- package/dist/chunks/{about-credits-4DHA4HMT.js → about-credits-PQSIWSE2.js} +1 -1
- package/dist/chunks/{args-5CQKOHYO.js → args-J5JEHQLE.js} +1 -1
- package/dist/chunks/{boot-XX2TLD3Q.js → boot-ETZUHG3U.js} +1 -1
- package/dist/chunks/{chunk-JMIKUWLY.js → chunk-2M5PPZIS.js} +2 -2
- package/dist/chunks/{chunk-P6JX5ZQT.js → chunk-4OSMYHKQ.js} +1 -1
- package/dist/chunks/{chunk-MPSLPE4C.js → chunk-6TTONCYR.js} +1 -1
- package/dist/chunks/{chunk-L57UZTYE.js → chunk-BP6CVOQR.js} +2 -2
- package/dist/chunks/{chunk-SUB2JM7G.js → chunk-DD5Z6NSH.js} +1 -1
- package/dist/chunks/{chunk-6HQKTDGG.js → chunk-DHW72U6X.js} +1 -1
- package/dist/chunks/{chunk-VDQMK2B2.js → chunk-FEFNS6YZ.js} +1 -1
- package/dist/chunks/{chunk-4YK4XWYS.js → chunk-H3KW7HTC.js} +1 -1
- package/dist/chunks/{chunk-RM3XA72H.js → chunk-J7Z7ULLN.js} +1 -1
- package/dist/chunks/{chunk-AET63NOB.js → chunk-JI7YY44M.js} +1 -1
- package/dist/chunks/{chunk-U3D3EU33.js → chunk-KTCHWHQB.js} +1 -1
- package/dist/chunks/chunk-NAE3AJ3M.js +3 -0
- package/dist/chunks/{chunk-X6PZIFFX.js → chunk-NUW4YOJ6.js} +1 -1
- package/dist/chunks/{chunk-RRVD63NF.js → chunk-RQWWUCGQ.js} +1 -1
- package/dist/chunks/{chunk-6FXF6ALB.js → chunk-RT6EXB2P.js} +1 -1
- package/dist/chunks/{chunk-GYERZAZU.js → chunk-T4CLHCLJ.js} +2 -2
- package/dist/chunks/{chunk-7MC3LDNP.js → chunk-TJ5YBJEO.js} +1 -1
- package/dist/chunks/{chunk-UGYBXR4V.js → chunk-VBDRWNEG.js} +1 -1
- package/dist/chunks/{chunk-WMK3IKW6.js → chunk-XGG3NYQN.js} +1 -1
- package/dist/chunks/{chunk-NRMLO5TP.js → chunk-YISJTRB6.js} +1 -1
- package/dist/chunks/chunk-YPAFAG4W.js +6 -0
- package/dist/chunks/{chunk-PUGNBNSV.js → chunk-Z6IQV737.js} +1 -1
- package/dist/chunks/{clip-command-3CMQ6A5D.js → clip-command-QIMH2U7N.js} +1 -1
- package/dist/chunks/{colour-VBHJAKAX.js → colour-3MFAFJNN.js} +1 -1
- package/dist/chunks/{entry-SOHEQPXT.js → entry-HGEJC7CZ.js} +1 -1
- package/dist/chunks/{execute-KTLXJTU2.js → execute-MRVDAKZO.js} +1 -1
- package/dist/chunks/{extensions-YF2KGD66.js → extensions-ONARRS5Q.js} +1 -1
- package/dist/chunks/{extensions-command-VT4M2JQW.js → extensions-command-65QEMN2L.js} +1 -1
- package/dist/chunks/{ffmpeg-Q2WJH2OP.js → ffmpeg-RTFJS67A.js} +1 -1
- package/dist/chunks/{launch-SOQTCV2D.js → launch-T7YOO7BQ.js} +5 -5
- package/dist/chunks/{manager-HBAXHJL4.js → manager-5EJGANFW.js} +1 -1
- package/dist/chunks/{needed-GMZEKBH4.js → needed-6GCBKP3S.js} +1 -1
- package/dist/chunks/{own-IICGHC4K.js → own-KMIT2CXF.js} +1 -1
- package/dist/chunks/{preset-command-4OVFEH7Y.js → preset-command-3ILRQZSJ.js} +1 -1
- package/dist/chunks/{registry-TO6HJQJ4.js → registry-K245FDI2.js} +1 -1
- package/dist/chunks/{server-6275TY3O.js → server-M5YGJHOL.js} +22 -19
- package/dist/chunks/{theme-ISNQEBTS.js → theme-XKWZV7OX.js} +1 -1
- package/dist/chunks/{transcribe-QC2E7ETQ.js → transcribe-SQC6QTV5.js} +1 -1
- package/dist/chunks/transcribe-command-PAHSXMWG.js +3 -0
- package/dist/chunks/{update-note-T4LVCD25.js → update-note-NRPILOCL.js} +1 -1
- package/dist/chunks/{watch-command-EYEZKROF.js → watch-command-QOMMDISG.js} +1 -1
- package/dist/index.js +6 -6
- package/package.json +5 -5
- package/skills/forge/SKILL.md +67 -4
- package/dist/chunks/chunk-GBA5DFEO.js +0 -6
- package/dist/chunks/transcribe-command-GAKYFBWQ.js +0 -3
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v}from"./chunk-
|
|
3
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v}from"./chunk-4OSMYHKQ.js";import"./chunk-TMUK2DD3.js";export{t as BAR,c as DARK,d as LIGHT,g as MODE_KEYS,j as MODE_MARKERS,f as MODE_ORDER,e as NEUTRAL,b as SYMBOLS,a as VERSION,v as applyColourPreference,u as colourEnabled,s as colourProp,n as dotGradient,o as menuPalette,k as modeColours,i as modeForKey,l as modeGradient,p as modePalette,m as modeWash,q as paintsCanvas,r as paletteFor,h as tabStep};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{
|
|
3
|
+
import{f as a,g as b,h as c,i as d,j as e,k as f,l as g,m as h,n as i,o as j,p as k,q as l,r as m,s as n}from"./chunk-2M5PPZIS.js";import"./chunk-MF3KKEFB.js";import"./chunk-I25E2XDH.js";import"./chunk-HZDYZ5RD.js";import"./chunk-6TTONCYR.js";import"./chunk-KH5DHZ2U.js";import"./chunk-HON4OV7M.js";import"./chunk-ZBMJTIYR.js";import"./chunk-J7FLFHQJ.js";import"./chunk-VLVNA4T3.js";import"./chunk-H3DIRJFE.js";import"./chunk-KXKQDFHX.js";import"./chunk-TMUK2DD3.js";export{h as appleDoes,e as chooseHearing,c as helperPaths,d as helpers,b as notesNeed,i as probeSound,l as readRefusal,m as renderPages,n as renderTranscript,k as runRead,j as runTranscribe,a as transcribeNeeds,f as transcribeStatus,g as whisperUseful};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a as _,c as tt}from"./chunk-NAE3AJ3M.js";import{a as S,b as Y,c as Z,d as x}from"./chunk-YPAFAG4W.js";import{c as X}from"./chunk-RT6EXB2P.js";import"./chunk-XGG3NYQN.js";import{a as M,b as B,c as H,d as K,f as q,g as z,k,o as G,p as J,q as Q,r as V,s as W}from"./chunk-2M5PPZIS.js";import"./chunk-VBDRWNEG.js";import"./chunk-MF3KKEFB.js";import"./chunk-I25E2XDH.js";import"./chunk-KTCHWHQB.js";import"./chunk-HZDYZ5RD.js";import"./chunk-O7DK3GJT.js";import"./chunk-RQWWUCGQ.js";import"./chunk-EEQSUBBL.js";import"./chunk-6TTONCYR.js";import"./chunk-FAUL5L2W.js";import{a as j,d as D}from"./chunk-KH5DHZ2U.js";import"./chunk-HON4OV7M.js";import"./chunk-TLHUFIXD.js";import"./chunk-4MJEEEFA.js";import{a as T,r as P}from"./chunk-V6GWPR2A.js";import"./chunk-WBW6G4N6.js";import{G as A,a as I,b as U,oa as L,qa as O,ra as y,ta as R,ua as C,va as N,y as g}from"./chunk-ZBMJTIYR.js";import"./chunk-J7FLFHQJ.js";import{c as v}from"./chunk-VLVNA4T3.js";import"./chunk-H3DIRJFE.js";import"./chunk-KXKQDFHX.js";import"./chunk-TMUK2DD3.js";import{existsSync as $}from"node:fs";import{stat as it}from"node:fs/promises";import{basename as l,dirname as rt,extname as w,join as et,resolve as p}from"node:path";function at(t){if(t.format)return t.format;let e=t.output;if(e===void 0||T(e))return"md";let r=w(e).toLowerCase();return j.find(n=>n.ext===r)?.id??"md"}function h(t,e,r,n){let i=`${t}${D(n)}`;return r===void 0?et(e,i):T(r)?et(p(r),i):p(r)}var nt=t=>t.split(/\s+/).filter(Boolean).length,st=t=>t.segments.reduce((e,r)=>e+nt(r.text),0);async function ct(t){let{probe:e}=await import("./registry-K245FDI2.js"),r=await e(t).catch(()=>{throw L(t)});return _(r)}async function dt(t,e,r,n){if(e.to!==void 0)throw A("--to is for video and sound: a picture or PDF gives its text as it is.",`Try: forge transcribe ${l(t.path)}`);if(!(await k())?.read)throw await Q();let o=h(l(t.path,w(t.path)),rt(t.path),e.output,n);if($(o)&&!e.force)throw g(o);let c=await J(t.path,{language:e.language,signal:r.signal,onEvent:r.onProgress}),a=M(c);if(!B(a))throw R(t.path);await P(o,await V(a,n,l(t.path),{signal:r.signal,lang:e.language})),r.document?.({path:o,markdown:H(a)});let s=t.what==="pdf"?`${t.pages} ${t.pages===1?"page":"pages"}`:w(t.path).slice(1).toUpperCase()||"picture";return r.out(`\u2713 ${v(o)} ${s} \u2192 ${nt(K(a)).toLocaleString("en-US")} words`),r.finished?.({made:[{from:[t.path],to:[o]}],failed:[]}),0}async function xt(t,e){try{let r=S(t.input);if(r?.kind==="playlist")throw O("This is a playlist.",void 0,{hint:"Pass one video's link.",shellHint:"Paste one video's link."});let n,i,o,c,a=at(t);if(r===void 0){if(n=p(t.input),!(await it(n).catch(()=>{}))?.isFile())throw U(n);let d=await X(n);if(d!=="video"&&d!=="audio"){let u=await ct(n);if(u)return await dt(u,t,e,a)}}let s=await k(t.language?{locale:t.language}:{});if(s===void 0||!s.speech)throw y(q(process.platform,s?.missing));let E=t.notes&&s.notes==="available";if(t.notes&&!E){if(!t.transcript)throw y(z(process.platform,s.notes));s.notes==="off"&&e.err("\u26A0 Apple Intelligence is off, so this is the transcript only.")}if(r===void 0){if(n=p(t.input),i={title:l(n,w(n)),from:l(n)},o=h(i.title,rt(n),t.output,a),$(o)&&!t.force)throw g(o)}else{let m=new AbortController;e.signal?.addEventListener("abort",()=>m.abort(e.signal?.reason),{once:!0});let d;c=await tt(r.url,{signal:m.signal,onEvent:u=>{u.kind==="facts"&&(d=h(x(u.facts.title),process.cwd(),t.output,a),$(d)&&!t.force&&m.abort(g(d)))}}),n=c.path,i={title:c.facts.title,from:r.url},o=d??h(x(c.facts.title),process.cwd(),t.output,a)}let f;try{f=await G(n,{notes:E,detail:t.detail,locale:t.language,signal:e.signal,onEvent:e.onProgress})}finally{await c?.dispose()}let F=Z(f,i,{transcript:t.transcript});await P(o,await W(F,a,{signal:e.signal,lang:f.locale})),e.document?.({path:o,markdown:F});let b=f.notes?.parts.length,ot=b===void 0?"":` \xB7 ${b} ${b===1?"part":"parts"}`;return e.out(`\u2713 ${v(o)} ${Y(f.seconds)} \u2192 ${st(f).toLocaleString("en-US")} words${ot}`),e.finished?.({made:[{from:[r===void 0?n:i.title],to:[o]}],failed:[]}),0}catch(r){let n=I(r)?r:C(r);for(let o of N(n,{debug:t.debug}))e.err(o);let i=S(t.input)===void 0?p(t.input):"";return e.finished?.({made:[],failed:[{path:i,message:n.message}]}),1}}export{xt as runTranscribeCommand};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{b as m,c as w,d as h,i as l,j as p,k as b}from"./chunk-SZRSAL64.js";import{c as $,d as g}from"./chunk-
|
|
3
|
+
import{b as m,c as w,d as h,i as l,j as p,k as b}from"./chunk-SZRSAL64.js";import{c as $,d as g}from"./chunk-4OSMYHKQ.js";import{e as u}from"./chunk-N6RCLJE6.js";import"./chunk-WE6KP4FR.js";import"./chunk-KH5DHZ2U.js";import"./chunk-HON4OV7M.js";import"./chunk-H3DIRJFE.js";import"./chunk-TMUK2DD3.js";import{spawn as x}from"node:child_process";var P=60;function v(t,n){let e=Number.parseInt(t.slice(1),16);return`\x1B[${n};2;${e>>16&255};${e>>8&255};${e&255}m`}function C(t,n,e){let i=[" \u2191 ",`Forge ${t} is available`,` \xB7 your version ${n}`],r=[" In terminal: ","forge update"];if(e===void 0)return[i.join(""),r.join("")];let s=v(e.newTagBg,48),o=f=>v(f,38),c="\x1B[1m",a="\x1B[0m",d=f=>" ".repeat(Math.max(0,P-f.join("").length));return[`${s}${o(e.newTag)}${c}${i[0]}${o(e.fg)}${i[1]}${a}${s}${o(e.dim)}${i[2]}${d(i)}${a}`,`${s}${o(e.dim)}${r[0]}${o(e.fg)}${c}${r[1]}${a}${s}${d(r)}${a}`]}async function I(t,n){let e=n.now??Date.now(),{prefs:i}=await u();if(!h(i,n.env??process.env))return[];let r=await l();b(r,e)&&n.refresh();let s=r?.latest;if(r===void 0||s===void 0||!w(s,t))return[];let o=r.notifiedAt;if(o!==void 0&&o<=e&&e-o<=m)return[];await p({...r,notifiedAt:e}).catch(()=>{});let c=n.colour?i.theme==="light"?g:$:void 0;return C(s,t,c)}function N(t,n=process.platform,e=x){if(t!==void 0)try{e(process.execPath,[...process.execArgv,t,"__update-check"],{detached:!0,stdio:"ignore",...n==="win32"?{windowsHide:!0}:{}}).unref()}catch{}}export{I as afterCommand,C as noteLines,N as spawnRefresh};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{c as R,d as k}from"./chunk-
|
|
3
|
+
import{c as R,d as k}from"./chunk-DD5Z6NSH.js";import{a as W,d as N}from"./chunk-RT6EXB2P.js";import"./chunk-FEFNS6YZ.js";import"./chunk-Q6KQWJ4J.js";import"./chunk-NUW4YOJ6.js";import"./chunk-VBDRWNEG.js";import"./chunk-DHW72U6X.js";import"./chunk-KTCHWHQB.js";import{d as w,e as h}from"./chunk-YJ6XLDRA.js";import"./chunk-63XCSYHM.js";import{a as S}from"./chunk-4OSMYHKQ.js";import"./chunk-O7DK3GJT.js";import"./chunk-RQWWUCGQ.js";import"./chunk-EEQSUBBL.js";import"./chunk-6TTONCYR.js";import"./chunk-FAUL5L2W.js";import"./chunk-N6RCLJE6.js";import"./chunk-WE6KP4FR.js";import"./chunk-KH5DHZ2U.js";import"./chunk-HON4OV7M.js";import"./chunk-TLHUFIXD.js";import"./chunk-4MJEEEFA.js";import"./chunk-V6GWPR2A.js";import"./chunk-WBW6G4N6.js";import{G as L,a as M,b as I,va as E}from"./chunk-ZBMJTIYR.js";import{a as A}from"./chunk-J7FLFHQJ.js";import{c as a}from"./chunk-VLVNA4T3.js";import{a as F}from"./chunk-H3DIRJFE.js";import"./chunk-KXKQDFHX.js";import"./chunk-TMUK2DD3.js";import{readdir as T,stat as B}from"node:fs/promises";import{join as C,resolve as y}from"node:path";function K(r,t,s,n){return[`\u2713 ${r} converted${n?` to ${n}`:""}`,...t?[`${t} failed`]:[],...s?[`${s} left alone`]:[]].join(" \xB7 ")}var P=r=>{let[t,...s]=r.job.outputs,n=`${a(t??"")}${s.length?` + ${s.length} more`:""}`;return`\u2713 ${a(r.job.sources[0].path)} \u2192 ${n} ${A(r.outputBytes)}`},O=(r,t)=>`\u2715 ${a(r)} ${t.title.toLowerCase()}`,D=r=>`\u2013 ${a(r.path)} ${r.reason}`;async function v(r,t){let s=y(r.folder),n=(e,o)=>t.out(JSON.stringify({forge:S,event:e,...o}));try{let e=await B(s).catch(()=>{});if(!e)throw I(s);if(!e.isDirectory())throw L(`${a(s)} is not a folder.`,`forge watch watches a folder. Try: forge watch ${a(y(s,".."))} --to ${r.target}`)}catch(e){if(!M(e))throw e;if(t.json)n("error",{ok:!1,failures:[h({error:e})]});else for(let o of E(e,{debug:r.debug}))t.out(o);return 2}let m={target:r.target,...r.quality===void 0?{}:{quality:r.quality},dpi:r.dpi??150},$={images:m,pdfs:m,documents:m},c=r.output===void 0?void 0:y(r.output),q=F[r.target].label,p=0,i=[],u=[],b=new Set,g;if(r.newOnly)g=(await T(s,{withFileTypes:!0})).filter(o=>o.isFile()&&!W(o.name)).map(o=>C(s,o.name));else{let e=await N(s);g=e.paths;let o=await R(e,$,{destination:c});b=o.claimed;let f=[...e.failures,...o.outcome.refusals,...o.outcome.failures],j=e.kinds.flatMap(l=>l.why?[{count:l.count,why:l.why}]:[]),J=o.left.length+j.reduce((l,d)=>l+d.count,0);if(p+=o.outcome.results.length,i.push(...f),u.push(...o.left),t.json)n("converted-existing",{ok:f.length===0,results:o.outcome.results.map(w),failures:f.map(h),leftAlone:o.left});else if(e.paths.length>0){t.out(K(o.outcome.results.length,f.length,J,q));for(let l of f)t.out(O(l.path,l.error))}for(let l of j)for(let d=0;d<l.count;d++)u.push({path:"",reason:l.why})}t.json?n("watching",{folder:s,...c?{output:c}:{}}):t.out(`Watching ${a(s)} \xB7 any new files you add will be converted \xB7 ctrl-c to stop`);let x=k({dir:s,answers:$,known:g,claimed:b,destination:c,...t.settleMs===void 0?{}:{settleMs:t.settleMs},...t.pollMs===void 0?{}:{pollMs:t.pollMs},onEvent:e=>{e.type==="converted"?(p++,t.json?n("converted",{result:w(e.result)}):t.out(P(e.result))):e.type==="failed"?(i.push({path:e.path,error:e.error}),t.json?n("failed",{failure:h({path:e.path,error:e.error})}):t.out(O(e.path,e.error))):e.type==="left"&&(u.push({path:e.path,reason:e.reason}),t.json?n("left-alone",{path:e.path,reason:e.reason}):t.out(D({path:e.path,reason:e.reason})))}});return await new Promise(e=>{t.signal.aborted?e():t.signal.addEventListener("abort",()=>e(),{once:!0})}),await x.stop(),t.json?n("stopped",{converted:p,failed:i.length,leftAlone:u.length}):t.out(K(p,i.length,u.length)),i.length>0?1:0}export{v as runWatch};
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
3
3
|
const require = __forgeCreateRequire(import.meta.url);
|
|
4
|
-
import{e as x,f as S}from"./chunks/chunk-
|
|
4
|
+
import{e as x,f as S}from"./chunks/chunk-YISJTRB6.js";import{b as g,d as C}from"./chunks/chunk-IBPGC4N2.js";import"./chunks/chunk-DHW72U6X.js";import"./chunks/chunk-KTCHWHQB.js";import"./chunks/chunk-HZDYZ5RD.js";import"./chunks/chunk-N32JL4UI.js";import{g as b}from"./chunks/chunk-YJ6XLDRA.js";import"./chunks/chunk-63XCSYHM.js";import{a as p}from"./chunks/chunk-4OSMYHKQ.js";import{b as E}from"./chunks/chunk-O7DK3GJT.js";import"./chunks/chunk-RQWWUCGQ.js";import"./chunks/chunk-EEQSUBBL.js";import"./chunks/chunk-6TTONCYR.js";import"./chunks/chunk-FAUL5L2W.js";import"./chunks/chunk-HTA25PO2.js";import"./chunks/chunk-N6RCLJE6.js";import"./chunks/chunk-WE6KP4FR.js";import"./chunks/chunk-KH5DHZ2U.js";import"./chunks/chunk-HON4OV7M.js";import"./chunks/chunk-TLHUFIXD.js";import"./chunks/chunk-4MJEEEFA.js";import"./chunks/chunk-V6GWPR2A.js";import"./chunks/chunk-WBW6G4N6.js";import{G as $,a as w,ua as k,va as m}from"./chunks/chunk-ZBMJTIYR.js";import"./chunks/chunk-J7FLFHQJ.js";import"./chunks/chunk-VLVNA4T3.js";import"./chunks/chunk-H3DIRJFE.js";import"./chunks/chunk-KXKQDFHX.js";import"./chunks/chunk-TMUK2DD3.js";import*as j from"node:module";function v(e){return w(e)?e:k(e)}function T(e,n){return m(v(e),{debug:n})}function F(e,n){process.once("beforeExit",()=>{e()||(n(new Error("Forge stopped before it finished: it was waiting for input that never came.")),process.exitCode=1)})}E();j.enableCompileCache?.();function M({completed:e,total:n}){e===0?process.stderr.write(`Converting ${n} files
|
|
5
5
|
`):process.stderr.write(` ${e}/${n}
|
|
6
|
-
`)}async function D(){let e=process.argv.slice(2),n=e.includes("--debug"),d=x(e);try{if(e[0]==="__update-check"){let{checkNow:r}=await import("./chunks/check-B6NP7BEM.js");await r();return}if(e[0]==="menu"){let{openedForClick:r,parseMenuArgs:t}=await import("./chunks/command-GAGAD65W.js"),s=t(e.slice(1));if(s.kind==="open"){let{applyColourPreference:h}=await import("./chunks/theme-
|
|
6
|
+
`)}async function D(){let e=process.argv.slice(2),n=e.includes("--debug"),d=x(e);try{if(e[0]==="__update-check"){let{checkNow:r}=await import("./chunks/check-B6NP7BEM.js");await r();return}if(e[0]==="menu"){let{openedForClick:r,parseMenuArgs:t}=await import("./chunks/command-GAGAD65W.js"),s=t(e.slice(1));if(s.kind==="open"){let{applyColourPreference:h}=await import("./chunks/theme-XKWZV7OX.js");h();let{bootShell:I}=await import("./chunks/boot-ETZUHG3U.js");await I(void 0,{opened:await r(s.action,s.paths)});return}let{runMenuCommand:c}=await import("./chunks/entry-HGEJC7CZ.js");process.exitCode=await c(s,p);return}if(e[0]==="mcp"){let{runMcpServer:r}=await import("./chunks/server-M5YGJHOL.js");await r(e.slice(1));return}let o=S(e);if(o.kind==="shell"){if(d)throw $("No files given.","Name a file, for example: forge photo.jpg --to webp --json");if(!process.stdout.isTTY||!process.stdin.isTTY){process.stderr.write(`Forge needs a file and a target format.
|
|
7
7
|
Try: forge photo.jpg --to webp
|
|
8
|
-
`),process.exitCode=2;return}let{applyColourPreference:r}=await import("./chunks/theme-
|
|
9
|
-
`),json:d,signal:t.signal});return}if(o.kind==="uninstall"){let{runUninstall:r}=await import("./chunks/entry-
|
|
10
|
-
`));return}let{execute:l}=await import("./chunks/execute-
|
|
8
|
+
`),process.exitCode=2;return}let{applyColourPreference:r}=await import("./chunks/theme-XKWZV7OX.js");r();let{bootShell:t}=await import("./chunks/boot-ETZUHG3U.js");await t(void 0,{menuNote:async()=>(await import("./chunks/entry-HGEJC7CZ.js")).menuAtStart(p)});return}if(o.kind==="watch"){let{runWatch:r}=await import("./chunks/watch-command-QOMMDISG.js"),t=new AbortController;process.once("SIGINT",()=>t.abort()),process.exitCode=await r(o,{out:s=>process.stdout.write(`${s}
|
|
9
|
+
`),json:d,signal:t.signal});return}if(o.kind==="uninstall"){let{runUninstall:r}=await import("./chunks/entry-HGEJC7CZ.js");process.exitCode=await r(p,t=>process.stdout.write(`${t}
|
|
10
|
+
`));return}let{execute:l}=await import("./chunks/execute-MRVDAKZO.js"),i,y=0,A=(r,t)=>{let s=Date.now();if(r<t&&s-y<100)return;y=s;let c=h=>(h/1e6).toFixed(1);process.stderr.write(`\r downloading ${c(r)} / ${c(t)} MB${r>=t?`
|
|
11
11
|
`:""}`)},u=!!process.stderr.isTTY&&!d,f=new AbortController;o.kind==="extension-op"&&process.once("SIGINT",()=>f.abort());let B=Date.now(),a=await l(o,{json:d,...u?{onInstalling:r=>{i=g(process.stderr,`installing Forge ${r}`)}}:{},signal:f.signal,...u?{onDownload:A}:{},colour:!!process.stdout.isTTY&&!d&&C(),onProgress:u?r=>{r.completed>0&&i?.stop(),M(r)}:void 0,...u?{onSearch:r=>{i??=g(process.stderr,"finding the smallest that fits"),i.update(r)},onEncode:r=>{i??=g(process.stderr,"encoding"),i.update(r)}}:{}});if(i?.stop(),a.stdout.length>0&&process.stdout.write(`${a.stdout.join(`
|
|
12
12
|
`)}
|
|
13
13
|
`),a.stderr.length>0&&process.stderr.write(`${a.stderr.join(`
|
|
14
14
|
`)}
|
|
15
|
-
`),process.exitCode=f.signal.aborted?130:a.exitCode,u&&a.notice&&!f.signal.aborted){let{postFinishNotice:r}=await import("./chunks/notify-NQNNOBFC.js");await r(a.notice,Date.now()-B)}if(u&&process.stdout.isTTY&&o.kind!=="update")try{let{afterCommand:r,spawnRefresh:t}=await import("./chunks/update-note-
|
|
15
|
+
`),process.exitCode=f.signal.aborted?130:a.exitCode,u&&a.notice&&!f.signal.aborted){let{postFinishNotice:r}=await import("./chunks/notify-NQNNOBFC.js");await r(a.notice,Date.now()-B)}if(u&&process.stdout.isTTY&&o.kind!=="update")try{let{afterCommand:r,spawnRefresh:t}=await import("./chunks/update-note-NRPILOCL.js"),{runningScript:s}=await import("./chunks/install-MFYGS5TG.js"),c=await r(p,{refresh:()=>t(s(process.argv[1])),colour:C()});c.length>0&&process.stderr.write(`
|
|
16
16
|
${c.join(`
|
|
17
17
|
`)}
|
|
18
18
|
`)}catch{}}catch(o){if(w(o)){d?process.stdout.write(`${JSON.stringify(b(p,o))}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "forge-terminal",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.8",
|
|
4
4
|
"description": "A terminal-native file converter for macOS, Windows and Linux",
|
|
5
5
|
"whatsNew": [
|
|
6
6
|
{
|
|
7
|
-
"title": "Agents
|
|
8
|
-
"text": "
|
|
7
|
+
"title": "Agents hear recordings",
|
|
8
|
+
"text": "AI agents using Forge can now get the notes and transcript of a video, sound file or YouTube link, made on your computer."
|
|
9
9
|
},
|
|
10
10
|
{
|
|
11
|
-
"title": "
|
|
12
|
-
"text": "Agents can
|
|
11
|
+
"title": "Agents read pictures",
|
|
12
|
+
"text": "Agents can also get the text in a picture, screenshot, scan or PDF, with headings, lists and tables kept."
|
|
13
13
|
}
|
|
14
14
|
],
|
|
15
15
|
"keywords": [
|
package/skills/forge/SKILL.md
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: forge
|
|
3
|
-
description: Convert, compress and edit local files
|
|
3
|
+
description: Convert, compress and edit local files with the Forge CLI (`forge`) — images (HEIC, camera RAW, JPEG, PNG, WebP, AVIF, GIF, TIFF), PDFs, Word documents, video and sound — and hear or read what an agent cannot. Use when the user wants a file in another format, smaller or under a size limit, or cropped to a shape; a PDF merged, split, trimmed or rotated; what a recording, meeting or YouTube video says; the text in a picture, scan or PDF; or a colour palette, tonal scale or named colours as a card to paste into Figma — and `forge` is installed (`npm i -g forge-terminal`).
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Forge
|
|
7
7
|
|
|
8
|
-
Forge converts files on this
|
|
8
|
+
Forge converts files on this computer. Nothing is uploaded.
|
|
9
|
+
|
|
10
|
+
## When to reach for it
|
|
11
|
+
|
|
12
|
+
- **A file must fit a limit** (an upload under 5 MB, an email, a form):
|
|
13
|
+
`--max-size 5mb`. A set width: `--width 1200`.
|
|
14
|
+
- **A format you cannot open** (HEIC, camera RAW, Word): convert it to PNG,
|
|
15
|
+
JPEG or PDF and read that.
|
|
16
|
+
- **What a recording, meeting or YouTube video says:** `forge transcribe`,
|
|
17
|
+
then read the Markdown file it writes.
|
|
18
|
+
- **The text in a picture, screenshot, scan or PDF:** `forge transcribe` on
|
|
19
|
+
it reads the text instead.
|
|
20
|
+
- **Colours for Figma:** `forge card`, `forge scale` or `forge palette` with
|
|
21
|
+
`--svg`, piped to `pbcopy`. The user presses ⌘V in Figma.
|
|
9
22
|
|
|
10
23
|
## Always
|
|
11
24
|
|
|
@@ -55,6 +68,10 @@ forge --formats --json
|
|
|
55
68
|
forge palette photo.jpg --json # an image's main colours
|
|
56
69
|
forge palette photo.jpg --inside F96363 --json # one colour's shades
|
|
57
70
|
forge scale 6579FD --json # 50–950, the colour at 500
|
|
71
|
+
forge card palette.csv --json # named colours, as read
|
|
72
|
+
forge card palette.csv --svg | pbcopy # a card to paste into Figma
|
|
73
|
+
forge transcribe talk.mp4 # notes and transcript -> talk.md
|
|
74
|
+
forge transcribe scan.pdf # a picture's or PDF's text -> scan.md
|
|
58
75
|
```
|
|
59
76
|
|
|
60
77
|
For a colour, pass the hex without `#`, or quote it: an unquoted `#` starts
|
|
@@ -76,6 +93,47 @@ Outputs go beside the source unless `-o` names a folder (or, for one file, a
|
|
|
76
93
|
filename). Page operations always write beside the source, take no `-o`, and
|
|
77
94
|
never edit the original.
|
|
78
95
|
|
|
96
|
+
## Transcribe and read text
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
forge transcribe meeting.m4a # summary, notes and transcript -> meeting.md
|
|
100
|
+
forge transcribe talk.mp4 --to transcript # no notes; --to notes: no transcript
|
|
101
|
+
forge transcribe 'https://youtu.be/…' # a YouTube link, into this folder
|
|
102
|
+
forge transcribe talk.mp4 --detail brief --format pdf -o ~/Notes/
|
|
103
|
+
forge transcribe whiteboard.jpg # the text in a picture -> whiteboard.md
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
It takes one file or link at a time and has **no `--json`**: on success it
|
|
107
|
+
prints one line, `✓ <file> 1:15 → 812 words · 4 parts`, and exits 0. Read
|
|
108
|
+
the file it names. A video or sound file gives notes and a transcript; a
|
|
109
|
+
picture, screenshot or PDF gives its text, with headings, lists and tables
|
|
110
|
+
kept (`--to` is refused for those). What it is is read from the content, not
|
|
111
|
+
the name. `--language fr-FR` when the speech or text is not in the
|
|
112
|
+
computer's own language. Notes need Apple Intelligence on a Mac; elsewhere
|
|
113
|
+
`--to all` gives the transcript alone. A long recording takes minutes.
|
|
114
|
+
Without `--force` an existing file is refused (`output-exists`).
|
|
115
|
+
|
|
116
|
+
Failure codes: `transcribe-unavailable` (the hint names what to install or
|
|
117
|
+
turn on), `read-unavailable` (reading text needs macOS 26, or the read-text
|
|
118
|
+
extension on Windows and Linux), `no-text` (nothing to read),
|
|
119
|
+
`link-unavailable` (a playlist, or a video yt-dlp could not fetch),
|
|
120
|
+
`extension-missing` (a link needs yt-dlp: the hint is the install command;
|
|
121
|
+
ask the user first, it downloads), `output-exists`.
|
|
122
|
+
|
|
123
|
+
## Colour cards for Figma
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
forge card palette.csv --svg | pbcopy # design tokens, CSV, CSS variables or "bg #F8F1E6" lines
|
|
127
|
+
pbpaste | forge card - --svg --title 'Brand' | pbcopy # colours you wrote, from stdin
|
|
128
|
+
forge scale 6579FD --svg | pbcopy # a 50–950 scale
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Pasted into Figma, the card is one layer per colour, named as written, with
|
|
132
|
+
its exact fill. `forge card` reads the file by content. If any line is not a
|
|
133
|
+
colour it draws nothing, names every bad line and exits 1. Write your colours
|
|
134
|
+
one a line as `name colour` and pipe them in with `-`. If `pbcopy` fails (a
|
|
135
|
+
sandbox may block the clipboard), give the user the command to run instead.
|
|
136
|
+
|
|
79
137
|
## Resize and trim edges
|
|
80
138
|
|
|
81
139
|
Built in, images only, format kept unless `--to` is given:
|
|
@@ -167,8 +225,13 @@ exit 1 and a hint; a wrong password has its own hint.
|
|
|
167
225
|
## MCP
|
|
168
226
|
|
|
169
227
|
If a `forge` MCP server is connected (tools `forge_probe`, `forge_formats`,
|
|
170
|
-
`forge_convert`, `forge_compress`, `forge_pdf`, `forge_palette`,
|
|
171
|
-
`forge_scale`), prefer it.
|
|
228
|
+
`forge_convert`, `forge_compress`, `forge_pdf`, `forge_clip`, `forge_palette`,
|
|
229
|
+
`forge_scale`, `forge_card`, `forge_transcribe`, `forge_read_text`), prefer it.
|
|
230
|
+
`forge_transcribe` and `forge_read_text` write the file and also return its
|
|
231
|
+
text as Markdown, so there is nothing more to read. `forge_card`,
|
|
232
|
+
`forge_scale` and `forge_palette` take `copy: true`, which puts the card on
|
|
233
|
+
the user's clipboard from Forge itself, with no shell needed; `svg: true`
|
|
234
|
+
returns it. It takes absolute
|
|
172
235
|
paths and returns the same JSON as `structuredContent`. It never overwrites
|
|
173
236
|
unless you pass `overwrite: true`, and an encrypted PDF takes a `password`
|
|
174
237
|
argument. `forge_convert` also takes `sharpen: true`, `boost: 2 | 3 | 4` and `removeBackground: true`
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{l as P}from"./chunk-WMK3IKW6.js";import{c as k,e as I,f as $}from"./chunk-I25E2XDH.js";import{K as S,oa as E,qa as m,x}from"./chunk-ZBMJTIYR.js";var D=new Set(["youtube.com","www.youtube.com","m.youtube.com","music.youtube.com"]),M=/^[A-Za-z0-9_-]{11}$/,w=t=>t&&M.test(t)?{kind:"video",id:t,url:`https://www.youtube.com/watch?v=${t}`}:void 0;function Z(t){let r=t.trim();if(r==="")return;let e;try{e=new URL(/^[a-z]+:\/\//i.test(r)?r:`https://${r}`)}catch{return}let n=e.hostname.toLowerCase();if(n==="youtu.be")return w(e.pathname.slice(1).split("/")[0]);if(!D.has(n))return;let[s,o]=e.pathname.split("/").filter(Boolean);if(s==="watch")return w(e.searchParams.get("v"));if(s==="shorts"||s==="live")return w(o);if(s==="playlist"&&e.searchParams.get("list"))return{kind:"playlist"}}var R="Summary and notes by Apple Intelligence. They may contain mistakes.";function N(t){let r=Math.floor(t),e=o=>String(o).padStart(2,"0"),n=Math.floor(r/3600),s=Math.floor(r/60)%60;return n>0?`${n}:${e(s)}:${e(r%60)}`:`${s}:${e(r%60)}`}var L=t=>t.split(/\s+/).filter(Boolean).length,V=60,j=140,Y=1,W=10;function H(t){let r=[],e;for(let n of t){if(e){let s=n.start-e.end;if(!(s>W||s>Y&&e.words>=V||e.words>=j)){e.text+=` ${n.text}`,e.end=n.end,e.words+=L(n.text);continue}r.push({start:e.start,text:e.text})}e={start:n.start,end:n.end,text:n.text,words:L(n.text)}}return e&&r.push({start:e.start,text:e.text}),r}var T=t=>H(t).flatMap(r=>[`**${N(r.start)}** ${r.text}`,""]),B=t=>/^https?:\/\/\S+$/.test(t)?`<${t}>`:t;function Q(t,r,{transcript:e=!0}={}){let n=[`# ${r.title}`,"",B(r.from),""],s=t.notes;if(!s)return[...n,...T(t.segments)].join(`
|
|
4
|
-
`);let o=s.parts,p=a=>{let d=o[a];return d?`### ${d.refused?`Part ${a+1}`:d.heading} \xB7 ${N(d.start)}`:""};n.push(s.summary,"","## Notes",""),o.forEach((a,d)=>{n.push(p(d),""),a.points.length>0&&n.push(...a.points.map(l=>`- ${l}`),"")});let c=[`_${R}_`,""];return e?(n.push("## Transcript",""),o.forEach((a,d)=>{let l=o[d+1]?.start??Number.POSITIVE_INFINITY,b=t.segments.filter(h=>h.start>=a.start&&h.start<l);n.push(p(d),"",...T(b))}),[...n,...c].join(`
|
|
5
|
-
`)):[...n,...c].join(`
|
|
6
|
-
`)}function tt(t){let r=[...t].map(e=>(e.codePointAt(0)??0)<32?" ":e).join("").replace(/[/\\:*?"<>|]/g,"-").replace(/\s+/g," ").trim().slice(0,120).replace(/^\.+/,"");return r===""?"transcript":r}function nt(t){if(t.kind!=="media"){if(t.kind==="image"){let{path:r,format:e,bytes:n,width:s,height:o}=t;return{what:"image",path:r,format:e,bytes:n,width:s,height:o}}if(t.format!=="pdf")throw E(t.path);if(t.encrypted)throw x(t.path);return{what:"pdf",path:t.path,bytes:t.bytes,pages:t.pages}}}import{spawn as _}from"node:child_process";import{mkdtemp as C,rm as K}from"node:fs/promises";import{tmpdir as U}from"node:os";import{join as A}from"node:path";import{createInterface as G}from"node:readline";var z=[[/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."]],g=class extends Error{};function J(t=process.platform,r=process.arch){let e=I("yt-dlp");return e!==void 0&&$(e,t,r)!==void 0?S("yt-dlp"):m(`YouTube links on ${k(t)} need yt-dlp on your PATH.`,void 0,{hint:"Install yt-dlp (https://github.com/yt-dlp/yt-dlp) and put it on your PATH.",shellHint:"Install yt-dlp and put it on your PATH."})}async function ft(t,r={}){let e=await P();if(e===void 0)throw J();let n=await C(A(U(),"forge-yt-"));r.onDir?.(n);let s=()=>K(n,{recursive:!0,force:!0});try{let o;try{o=await F(e.entry,t,n,r)}catch(p){if(!(p instanceof g))throw p;if(e.own)throw m(`yt-dlp could not fetch this video: ${p.message}`,p);await X(e.entry,r.signal);try{o=await F(e.entry,t,n,r)}catch(c){throw c instanceof g?m(`yt-dlp could not fetch this video: ${c.message}`,c):c}}return{...o,dispose:s}}catch(o){throw await s(),o}}function F(t,r,e,n){let{signal:s}=n;if(s?.aborted)return Promise.reject(s.reason??new Error("aborted"));let o=["--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",A(e,"sound.%(ext)s"),r];return new Promise((p,c)=>{let a=_(t,o,{stdio:["ignore","pipe","pipe"]}),d,l,b="",h=!1,y=i=>{h||(h=!0,s?.removeEventListener("abort",v),i())},v=()=>{a.kill("SIGKILL"),y(()=>c(s?.reason??new Error("aborted")))};s?.addEventListener("abort",v,{once:!0}),G({input:a.stdout}).on("line",i=>{if(i.startsWith("forge-facts ")){let u=JSON.parse(i.slice(12));if(u.is_live===!0){a.kill("SIGKILL"),y(()=>c(m("Live streams cannot be transcribed.")));return}d={title:String(u.title??""),uploader:String(u.uploader??""),seconds:Number(u.duration??0)},n.onEvent?.({kind:"facts",facts:d})}else if(i.startsWith("forge-bytes ")){let[u,f]=i.slice(12).split(" ").map(Number);Number.isFinite(u)&&Number.isFinite(f)&&(f??0)>0&&n.onEvent?.({kind:"bytes",done:u,total:f})}else i.startsWith("forge-file ")&&(l=i.slice(11))}),a.stderr.on("data",i=>{b+=i.toString()}),a.on("error",i=>y(()=>c(new g(i.message)))),a.on("close",i=>y(()=>{if(i===0&&d!==void 0&&l!==void 0)return p({path:l,facts:d});let u=b.match(/ERROR: (?:\[[^\]]*\] )?(?:[\w-]+: )?(.*)/)?.[1]?.trim()??"",f=z.find(([O])=>O.test(u));c(f?m(f[1]):new g(u||`yt-dlp exited ${i}`))}))})}function X(t,r){return new Promise((e,n)=>{let s=_(t,["--update"],{stdio:"ignore"}),o=()=>s.kill("SIGKILL");r?.addEventListener("abort",o,{once:!0}),s.on("error",()=>e()),s.on("close",()=>{r?.removeEventListener("abort",o),r?.aborted?n(r.reason??new Error("aborted")):e()})})}export{Z as a,N as b,Q as c,tt as d,nt as e,J as f,ft as g};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as x,b as W,c as X,d as $,e as Y,g as Z}from"./chunk-GBA5DFEO.js";import{c as V}from"./chunk-6FXF6ALB.js";import"./chunk-WMK3IKW6.js";import{a as D,b as B,c as H,e as K,f as M,j as S,n as q,o as z,p as G,q as J,r as Q}from"./chunk-JMIKUWLY.js";import"./chunk-UGYBXR4V.js";import"./chunk-MF3KKEFB.js";import"./chunk-I25E2XDH.js";import"./chunk-U3D3EU33.js";import"./chunk-HZDYZ5RD.js";import"./chunk-O7DK3GJT.js";import"./chunk-RRVD63NF.js";import"./chunk-EEQSUBBL.js";import"./chunk-MPSLPE4C.js";import"./chunk-FAUL5L2W.js";import{a as N,d as j}from"./chunk-KH5DHZ2U.js";import"./chunk-HON4OV7M.js";import"./chunk-TLHUFIXD.js";import"./chunk-4MJEEEFA.js";import{a as T,r as P}from"./chunk-V6GWPR2A.js";import"./chunk-WBW6G4N6.js";import{G as U,a as F,b as I,oa as A,qa as L,ra as y,ta as O,ua as R,va as C,y as g}from"./chunk-ZBMJTIYR.js";import"./chunk-J7FLFHQJ.js";import{c as v}from"./chunk-VLVNA4T3.js";import"./chunk-H3DIRJFE.js";import"./chunk-KXKQDFHX.js";import"./chunk-TMUK2DD3.js";import{existsSync as E}from"node:fs";import{stat as ot}from"node:fs/promises";import{basename as l,dirname as tt,extname as w,join as _,resolve as p}from"node:path";function it(t){if(t.format)return t.format;let e=t.output;if(e===void 0||T(e))return"md";let r=w(e).toLowerCase();return N.find(n=>n.ext===r)?.id??"md"}function h(t,e,r,n){let i=`${t}${j(n)}`;return r===void 0?_(e,i):T(r)?_(p(r),i):p(r)}var et=t=>t.split(/\s+/).filter(Boolean).length,at=t=>t.segments.reduce((e,r)=>e+et(r.text),0);async function st(t){let{probe:e}=await import("./registry-TO6HJQJ4.js"),r=await e(t).catch(()=>{throw A(t)});return Y(r)}async function ct(t,e,r,n){if(e.to!==void 0)throw U("--to is for video and sound: a picture or PDF gives its text as it is.",`Try: forge transcribe ${l(t.path)}`);if(!(await S())?.read)throw await G();let o=h(l(t.path,w(t.path)),tt(t.path),e.output,n);if(E(o)&&!e.force)throw g(o);let c=await z(t.path,{language:e.language,signal:r.signal,onEvent:r.onProgress}),a=D(c);if(!B(a))throw O(t.path);await P(o,await J(a,n,l(t.path),{signal:r.signal,lang:e.language}));let s=t.what==="pdf"?`${t.pages} ${t.pages===1?"page":"pages"}`:w(t.path).slice(1).toUpperCase()||"picture";return r.out(`\u2713 ${v(o)} ${s} \u2192 ${et(H(a)).toLocaleString("en-US")} words`),r.finished?.({made:[{from:[t.path],to:[o]}],failed:[]}),0}async function $t(t,e){try{let r=x(t.input);if(r?.kind==="playlist")throw L("This is a playlist.",void 0,{hint:"Pass one video's link.",shellHint:"Paste one video's link."});let n,i,o,c,a=it(t);if(r===void 0){if(n=p(t.input),!(await ot(n).catch(()=>{}))?.isFile())throw I(n);let d=await V(n);if(d!=="video"&&d!=="audio"){let u=await st(n);if(u)return await ct(u,t,e,a)}}let s=await S(t.language?{locale:t.language}:{});if(s===void 0||!s.speech)throw y(K(process.platform,s?.missing));let k=t.notes&&s.notes==="available";if(t.notes&&!k){if(!t.transcript)throw y(M(process.platform,s.notes));s.notes==="off"&&e.err("\u26A0 Apple Intelligence is off, so this is the transcript only.")}if(r===void 0){if(n=p(t.input),i={title:l(n,w(n)),from:l(n)},o=h(i.title,tt(n),t.output,a),E(o)&&!t.force)throw g(o)}else{let m=new AbortController;e.signal?.addEventListener("abort",()=>m.abort(e.signal?.reason),{once:!0});let d;c=await Z(r.url,{signal:m.signal,onEvent:u=>{u.kind==="facts"&&(d=h($(u.facts.title),process.cwd(),t.output,a),E(d)&&!t.force&&m.abort(g(d)))}}),n=c.path,i={title:c.facts.title,from:r.url},o=d??h($(c.facts.title),process.cwd(),t.output,a)}let f;try{f=await q(n,{notes:k,detail:t.detail,locale:t.language,signal:e.signal,onEvent:e.onProgress})}finally{await c?.dispose()}let rt=X(f,i,{transcript:t.transcript});await P(o,await Q(rt,a,{signal:e.signal,lang:f.locale}));let b=f.notes?.parts.length,nt=b===void 0?"":` \xB7 ${b} ${b===1?"part":"parts"}`;return e.out(`\u2713 ${v(o)} ${W(f.seconds)} \u2192 ${at(f).toLocaleString("en-US")} words${nt}`),e.finished?.({made:[{from:[r===void 0?n:i.title],to:[o]}],failed:[]}),0}catch(r){let n=F(r)?r:R(r);for(let o of C(n,{debug:t.debug}))e.err(o);let i=x(t.input)===void 0?p(t.input):"";return e.finished?.({made:[],failed:[{path:i,message:n.message}]}),1}}export{$t as runTranscribeCommand};
|