werkmeister 0.87.2 → 0.87.3
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/dist/budget-BLK2WAB7.js +4 -0
- package/dist/cache-HYS5M4AY.js +4 -0
- package/dist/chunk-22YIK2BP.js +40 -0
- package/dist/chunk-2IE5JCIK.js +4 -0
- package/dist/chunk-47HAXWC4.js +4 -0
- package/dist/chunk-7D4A3HVZ.js +5 -0
- package/dist/chunk-7I5GWJOR.js +45 -0
- package/dist/chunk-7YUHPLUW.js +5 -0
- package/dist/chunk-A5QL5RDB.js +4 -0
- package/dist/chunk-AEDQ3BHS.js +24 -0
- package/dist/chunk-ANDUBI2O.js +23 -0
- package/dist/chunk-ATYTAZNX.js +4 -0
- package/dist/chunk-AXXV337U.js +18 -0
- package/dist/chunk-C4J3VWL3.js +26 -0
- package/dist/chunk-CBTQBN4M.js +110 -0
- package/dist/chunk-CVIURF6M.js +180 -0
- package/dist/chunk-CVK35MQA.js +4 -0
- package/dist/chunk-CVMWX5W5.js +146 -0
- package/dist/chunk-DL73WFKY.js +4 -0
- package/dist/chunk-DMZPGI56.js +13 -0
- package/dist/chunk-DNDCV7NJ.js +6 -0
- package/dist/chunk-EHWLRQV7.js +410 -0
- package/dist/chunk-EOBOW6TP.js +48 -0
- package/dist/chunk-FUA5NLXY.js +57 -0
- package/dist/chunk-GMROWN6L.js +10 -0
- package/dist/chunk-GMYAKGU2.js +4 -0
- package/dist/chunk-GUFHPPBN.js +4 -0
- package/dist/chunk-H3J3PJGY.js +7 -0
- package/dist/chunk-HKKHKLTS.js +11 -0
- package/dist/chunk-I3QYJM3C.js +4 -0
- package/dist/chunk-I7X6WZIM.js +4 -0
- package/dist/chunk-IFSWSRJW.js +5 -0
- package/dist/chunk-JPAIPFJZ.js +6 -0
- package/dist/chunk-JYCKRH6K.js +68 -0
- package/dist/chunk-K6GRVJQO.js +4 -0
- package/dist/chunk-N72DCINT.js +82 -0
- package/dist/chunk-NX6LSFJH.js +4 -0
- package/dist/chunk-OC7PYYEG.js +145 -0
- package/dist/chunk-OSW5G2B6.js +82 -0
- package/dist/chunk-OTPRXRNK.js +23 -0
- package/dist/chunk-P3NAQKV7.js +6 -0
- package/dist/chunk-PLREOZEU.js +4 -0
- package/dist/chunk-Q2CVZANF.js +42 -0
- package/dist/chunk-QAQMYRCU.js +4 -0
- package/dist/chunk-QEYZ7HOT.js +36 -0
- package/dist/chunk-QO5K65QU.js +5 -0
- package/dist/chunk-QVMMQ5JU.js +41 -0
- package/dist/chunk-RJQTC65O.js +33 -0
- package/dist/chunk-RO5NEK3B.js +4 -0
- package/dist/chunk-RS7NMSUP.js +4 -0
- package/dist/chunk-S62C4SVE.js +4 -0
- package/dist/chunk-SNY4QE2J.js +137 -0
- package/dist/chunk-SUWACJLK.js +5 -0
- package/dist/chunk-TCABDYVJ.js +4 -0
- package/dist/chunk-U4733O5I.js +13 -0
- package/dist/chunk-U4RIK7SI.js +15 -0
- package/dist/chunk-USRMIMWS.js +11 -0
- package/dist/chunk-UTVZKLGU.js +89 -0
- package/dist/chunk-UU5QPEC3.js +9 -0
- package/dist/chunk-VNP6M5VF.js +294 -0
- package/dist/chunk-WITTY5DQ.js +4 -0
- package/dist/chunk-X7GPCYQ7.js +4 -0
- package/dist/chunk-XGIW27EP.js +4 -0
- package/dist/chunk-XMARLDYZ.js +11 -0
- package/dist/chunk-XS5OH4RT.js +9 -0
- package/dist/chunk-YSPELKLM.js +8 -0
- package/dist/chunk-ZQOM25KE.js +31 -0
- package/dist/chunk-ZUSETSI2.js +4 -0
- package/dist/chunk-ZYR6KZ3U.js +4 -0
- package/dist/clean-XPY5QAR2.js +8 -0
- package/dist/close_out-3G6LG5CE.js +8 -0
- package/dist/code-LB6A5M22.js +4 -0
- package/dist/config-NTIS2QLB.js +4 -0
- package/dist/connect-MNBVLTKZ.js +11 -0
- package/dist/daemon-3A47MBS2.js +4 -0
- package/dist/dashboard.js +20 -1898
- package/dist/detect-QMRHHFXH.js +13 -0
- package/dist/down-WKZSBYCI.js +17 -0
- package/dist/fixture-OLAE2KUV.js +14 -0
- package/dist/form-cli.js +3 -1507
- package/dist/hooks-ULLFLRUW.js +4 -0
- package/dist/hooks_gen-GKZVUPMO.js +4 -0
- package/dist/infra-A3C7FDNR.js +4 -0
- package/dist/init_workspace-TU76APJQ.js +4 -0
- package/dist/intercept-SOU6VA2K.js +7 -0
- package/dist/issue-XC7UEFIP.js +5 -0
- package/dist/lib/agent_state.js +1 -6
- package/dist/lib/gate.js +1 -2
- package/dist/lib/pr_guard.js +1 -1
- package/dist/list_workspaces-4FBP4CIS.js +7 -0
- package/dist/logs-GFJHTAOE.js +6 -0
- package/dist/main.js +42 -1852
- package/dist/mcp-proxy.js +12 -229
- package/dist/mcp.js +30 -1930
- package/dist/migrate-PB3PLOPH.js +8 -0
- package/dist/notes-BT4GAPYP.js +4 -0
- package/dist/open-ZM2OEFSN.js +6 -0
- package/dist/optimize-2IZXOEM6.js +11 -0
- package/dist/pause-UPYUR576.js +4 -0
- package/dist/pr-UT66UXR7.js +5 -0
- package/dist/proxy_reload-PXGCYXTX.js +6 -0
- package/dist/registry-BYQSBFX2.js +4 -0
- package/dist/remove-E3D5UE6C.js +7 -0
- package/dist/remove_workspace-HH5DY2PQ.js +8 -0
- package/dist/restart-WACF24Q5.js +8 -0
- package/dist/resume-WUHWDN5P.js +8 -0
- package/dist/safari-LADKSYXB.js +8 -0
- package/dist/sandbox-KCOIOWUC.js +4 -0
- package/dist/services-HGBYH2BF.js +6 -0
- package/dist/setup-IHMHWCWE.js +5 -0
- package/dist/skills-AGQ43EYJ.js +4 -0
- package/dist/slots-FUNR4X2E.js +4 -0
- package/dist/standards-R42OMGAN.js +4 -0
- package/dist/start_args-5VUTUZJK.js +4 -0
- package/dist/starting_prompt-VSXMHUES.js +4 -0
- package/dist/stats-SBCCNRRR.js +4 -0
- package/dist/status-YRBJF4LX.js +13 -0
- package/dist/stop-UOWK5NZB.js +9 -0
- package/dist/telepresence-KGO67FZ6.js +4 -0
- package/dist/test-IGAOSBIZ.js +6 -0
- package/dist/tokens-2IJEBSSK.js +6 -0
- package/dist/up-LO6N5V5M.js +11 -0
- package/dist/v4-IBDIQBRV.js +4 -0
- package/dist/wait_load-LVY5WRZP.js +4 -0
- package/dist/werkmeister-workspaces.vsix +0 -0
- package/dist/workspace-LDQAAZM6.js +4 -0
- package/package.json +3 -3
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __sandboxCreateRequire } from "node:module";
|
|
2
|
+
const require = __sandboxCreateRequire(import.meta.url);
|
|
3
|
+
import{c as u,h as a,i as g,s as p}from"./chunk-DNDCV7NJ.js";import"./chunk-U4RIK7SI.js";import"./chunk-GUFHPPBN.js";import"./chunk-H3J3PJGY.js";import"./chunk-USRMIMWS.js";import"./chunk-2IE5JCIK.js";import"./chunk-A5QL5RDB.js";import"./chunk-47HAXWC4.js";import"./chunk-QO5K65QU.js";import"./chunk-C4J3VWL3.js";import"./chunk-WITTY5DQ.js";import"./chunk-OC7PYYEG.js";import"./chunk-RO5NEK3B.js";import{a as s,f as m}from"./chunk-K6GRVJQO.js";m();import f from"node:os";var $=2**30,d=s((n,e)=>Number.isFinite(n)?`${Number(n.toFixed(1))}${e}`:"no limit","limit");async function k(n){let e=await a(),r=g(f.cpus().length),l=u(),i=await p();if(n.json){let t=s(o=>Number.isFinite(o)?o:null,"n");console.log(JSON.stringify({budget:{memory:t(e.memory),cpus:t(e.cpus),preempt:e.preempt},host_load:r,leases:l,waiting:i}));return}console.log(`Budget: ${d(e.memory/$," GiB")} memory, ${d(e.cpus," CPUs")}, host load ${r||"unchecked"}, preemption ${e.preempt?"on":"off"}`);let c=Object.entries(l).sort(([,t],[,o])=>t.slot-o.slot);console.log(c.length?"Slots:":"Slots: none held");for(let[t,o]of c)console.log(` ${o.slot} ${t}${o.workspace?` ${o.workspace}`:""}`);console.log(i.length?"Waiting:":"Waiting: none");for(let[t,o]of i.entries())console.log(` ${t+1}. ${o}`)}s(k,"run");export{k as run};
|
|
4
|
+
//# sourceMappingURL=budget-BLK2WAB7.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __sandboxCreateRequire } from "node:module";
|
|
2
|
+
const require = __sandboxCreateRequire(import.meta.url);
|
|
3
|
+
import"./chunk-QAQMYRCU.js";import{c as s}from"./chunk-ZUSETSI2.js";import"./chunk-S62C4SVE.js";import"./chunk-U4RIK7SI.js";import"./chunk-H3J3PJGY.js";import"./chunk-WITTY5DQ.js";import{h as e,l as c}from"./chunk-OC7PYYEG.js";import"./chunk-RO5NEK3B.js";import{a as r,f as i}from"./chunk-K6GRVJQO.js";i();async function u(o){o.action!=="prune"&&(c(`Unknown action \`${String(o.action)}\` \u2014 the only action is \`prune\`.`),process.exit(2));let t=await s({name:typeof o.name=="string"?o.name:void 0,reset:!!o.reset,force:!!o.force,dryRun:!!o.dry_run});t.length||console.log("No caches in the registry.");for(let n of t){let a=n.ok?`${e.GREEN}\u2713${e.RESET}`:`${e.RED}\u2717${e.RESET}`;console.log(`${a} ${n.name} (${n.action}): ${n.detail}`)}t.some(n=>!n.ok)&&process.exit(1)}r(u,"run");export{u as run};
|
|
4
|
+
//# sourceMappingURL=cache-HYS5M4AY.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createRequire as __sandboxCreateRequire } from "node:module";
|
|
2
|
+
const require = __sandboxCreateRequire(import.meta.url);
|
|
3
|
+
import{b as a}from"./chunk-RO5NEK3B.js";import{a as s,f as i}from"./chunk-K6GRVJQO.js";i();import*as e from"node:fs";import*as o from"node:path";var n=`#!/bin/sh
|
|
4
|
+
# Generated by \`werkmeister workspace init\` (SW-124); rerun it to regenerate.
|
|
5
|
+
# Runs <cmd...> with HOME set to a fresh temporary directory, removed on exit,
|
|
6
|
+
# so no test or CLI exercise reads or writes the real ~/.werkmeister.
|
|
7
|
+
# --no-wait first does what WERKMEISTER_NO_WAIT=1 does, without an env assignment (SW-367),
|
|
8
|
+
# and exports it, so a with-temp-home nested under it skips its wait too (SW-425).
|
|
9
|
+
[ "\${1:-}" != --no-wait ] || { export WERKMEISTER_NO_WAIT=1; shift; }
|
|
10
|
+
no_wait=\${WERKMEISTER_NO_WAIT:-}
|
|
11
|
+
[ "$#" -gt 0 ] || { echo "usage: with-temp-home [--no-wait] <cmd> [args...]" >&2; exit 2; }
|
|
12
|
+
# Wait like the pr gate while host load is over budget.host_load (SW-224), before HOME
|
|
13
|
+
# changes so the real config's budget applies; no werkmeister on PATH, no wait.
|
|
14
|
+
# In the background with a trap, so killing the wrapper ends the wait too (SW-456).
|
|
15
|
+
[ -n "$no_wait" ] || ! command -v werkmeister >/dev/null 2>&1 || {
|
|
16
|
+
# Trap before the fork: $! is empty until the job exists, so no signal can land between them.
|
|
17
|
+
trap 'kill $! 2>/dev/null; exit 130' HUP INT TERM
|
|
18
|
+
werkmeister internal wait-load >&2 &
|
|
19
|
+
wait $!
|
|
20
|
+
# 75: the wait is spent and load is still over, so running would pile on (SW-540); any other failure runs.
|
|
21
|
+
} || { s=$?; [ "$s" -ne 75 ] || exit 75; }
|
|
22
|
+
tmp=$(mktemp -d) || exit 1
|
|
23
|
+
trap 'rm -rf "$tmp"' EXIT
|
|
24
|
+
trap 'exit 130' HUP INT TERM
|
|
25
|
+
# Corepack keeps pnpm under HOME; without this a fresh HOME re-downloads it every run.
|
|
26
|
+
export COREPACK_HOME="\${COREPACK_HOME:-$HOME/.cache/node/corepack}"
|
|
27
|
+
# OrbStack and Docker Desktop keep the compose plugin and context here (SW-285).
|
|
28
|
+
export DOCKER_CONFIG="\${DOCKER_CONFIG:-$HOME/.docker}"
|
|
29
|
+
# A temp HOME isolates files, not the daemon: unreachable unless the caller sets it (SW-264).
|
|
30
|
+
export WERKMEISTER_HOST="\${WERKMEISTER_HOST:-http://127.0.0.1:1}"
|
|
31
|
+
# An agent's shell inherits its Claude Code session's variables; CI has none (SW-332). CLAUDE_BIN stays.
|
|
32
|
+
unset CLAUDECODE
|
|
33
|
+
for v in $(env | sed -n '/^CLAUDE_CODE_[A-Za-z0-9_]*=/s/=.*//p'); do unset "$v"; done
|
|
34
|
+
HOME=$tmp "$@"
|
|
35
|
+
status=$?
|
|
36
|
+
# A failure under load reads as load (SW-209).
|
|
37
|
+
[ "$status" -eq 0 ] || echo "with-temp-home: exit $status; host load $(uptime | sed 's/.*load averages*: //; s/,//g') on $(getconf _NPROCESSORS_ONLN) cores" >&2
|
|
38
|
+
exit "$status"
|
|
39
|
+
`;function p(r){return o.join(a(r),"bin","with-temp-home")}s(p,"tempHomeWrapper");function m(r){let t=p(r);return e.mkdirSync(o.dirname(t),{recursive:!0}),e.writeFileSync(t,n),e.chmodSync(t,493),t}s(m,"writeTempHomeWrapper");export{n as a,p as b,m as c};
|
|
40
|
+
//# sourceMappingURL=chunk-22YIK2BP.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __sandboxCreateRequire } from "node:module";
|
|
2
|
+
const require = __sandboxCreateRequire(import.meta.url);
|
|
3
|
+
import{f as t}from"./chunk-K6GRVJQO.js";t();var p="mcp__ccd_turn__wrap_up",o="Don't turn on Auto-fix in the Claude desktop app (`ccd_pr`).";export{p as a,o as b};
|
|
4
|
+
//# sourceMappingURL=chunk-2IE5JCIK.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __sandboxCreateRequire } from "node:module";
|
|
2
|
+
const require = __sandboxCreateRequire(import.meta.url);
|
|
3
|
+
import{b as T}from"./chunk-QO5K65QU.js";import{n as x}from"./chunk-C4J3VWL3.js";import{b as d}from"./chunk-WITTY5DQ.js";import{l as w,s as u}from"./chunk-OC7PYYEG.js";import{b as h}from"./chunk-RO5NEK3B.js";import{a as n,f as p}from"./chunk-K6GRVJQO.js";p();import*as s from"node:fs";import*as S from"node:os";import*as a from"node:path";var E=3002;function A(){let e=u("MCP_PORT")||x().overrides?.mcp_port,t=Number(e);return Number.isInteger(t)&&t>0?t:E}n(A,"daemonPort");function f(){return(u("HOST")||`http://127.0.0.1:${A()}`).replace(/\/+$/,"")}n(f,"daemonUrl");function b(e){try{return s.readFileSync(e,"utf8").trim()||null}catch{return null}}n(b,"readToken");function _(e){return u("MCP_TOKEN")||(e?b(T(e)):null)||b(a.join(h(S.homedir()),"mcp-token"))}n(_,"daemonToken");var m=class extends d{static{n(this,"DaemonUnavailable")}constructor(t){super(`werkmeister daemon not reachable at ${f()} (${t}). Run \`werkmeister machine setup\` (macOS) or \`werkmeister infra connect\`.`,"DAEMON_DOWN")}};function $(e){let t=e===void 0?_():e;return t?{Authorization:`Bearer ${t}`}:{}}n($,"headers");async function k(e,t){try{return await fetch(e,t)}catch(r){let o=r;throw new m(o.cause?.code??o.name)}}n(k,"send");var y="x-werkmeister-build",M="x-werkmeister-launcher",I="x-werkmeister-client-ui";function B(e){if(!e)return null;try{let t=s.statSync(e).mtime.toISOString().replace(/\.\d+Z$/,"Z");for(let r=a.dirname(e);;r=a.dirname(r)){let o=a.join(r,"package.json");if(s.existsSync(o))return`${JSON.parse(s.readFileSync(o,"utf8")).version} @ ${t}`;if(a.dirname(r)===r)return null}}catch{return null}}n(B,"buildOf");var O=null,g=!1;function U(e){O=e}n(U,"expectDaemonBuild");function N(e,t){let r=t.headers.get(y);g||!e||!r||r===e||(g=!0,w(`The werkmeister daemon runs an older build (loaded ${r}, on disk ${e}); it restarts by itself once idle, or run \`werkmeister daemon restart\`.`))}n(N,"checkBuild");async function v(){try{let e=await k(`${f()}/api/status`,{headers:$(void 0),signal:AbortSignal.timeout(5e3)});return e.ok?await e.json():null}catch{return null}}n(v,"daemonStatus");async function F(e,t={},r={}){let o=AbortSignal.timeout(r.timeoutMs??12e4),l=O?.()??null,i=await k(`${f()}/api/tool`,{method:"POST",headers:{"Content-Type":"application/json",...$(r.token),...l?{[y]:l}:{}},body:JSON.stringify({name:e,arguments:t}),signal:r.signal?AbortSignal.any([r.signal,o]):o});N(l,i);let c=await i.json().catch(()=>({}));if(!i.ok)throw c.error?.replace(/^MCP error -?\d+: /,"")===`Tool ${e} not found`?new d(`The werkmeister daemon is older than this CLI: it has no \`${e}\` tool. Run \`werkmeister daemon restart\`.`,"DAEMON_STALE"):new d(c.error??`daemon answered HTTP ${i.status} to ${e}`,c.code??`HTTP_${i.status}`);return{data:c.structuredContent,text:c.text??""}}n(F,"callTool");export{E as a,A as b,f as c,_ as d,m as e,y as f,M as g,I as h,B as i,U as j,v as k,F as l};
|
|
4
|
+
//# sourceMappingURL=chunk-47HAXWC4.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createRequire as __sandboxCreateRequire } from "node:module";
|
|
2
|
+
const require = __sandboxCreateRequire(import.meta.url);
|
|
3
|
+
import{a as $,b as g}from"./chunk-RO5NEK3B.js";import{a,f as v}from"./chunk-K6GRVJQO.js";v();import*as l from"node:fs";import*as i from"node:path";var A="Precedence: these standards' rules win over conflicting task framing \u2014 if a rule and the task clash, follow the rule and say so (invariant: apply it and write a `decision` note; rule: surface the conflict in one line, then apply). This gate fires once; your retry will proceed.",j="Standards gate: invoke `w9r-implement` before coding \u2014 it loads the universal base (ponytail + comments + engineering) and the workspace notes. Then retry this edit.";function D(t){let e="",n=0,r=t.length;for(;n<r;){let o=t[n];if(n+=1,o==="*")e+=".*";else if(o==="?")e+=".";else if(o==="["){let s=n;for(s<r&&t[s]==="!"&&(s+=1),s<r&&t[s]==="]"&&(s+=1);s<r&&t[s]!=="]";)s+=1;if(s>=r)e+="\\[";else{let c=t.slice(n,s).replace(/\\/g,"\\\\");n=s+1,c.startsWith("!")?c="^"+c.slice(1):c.startsWith("^")&&(c="\\"+c),e+=`[${c}]`}}else e+=o.replace(/[.+^${}()|[\]\\]/g,"\\$&")}return`^(?:${e})$`}a(D,"_translate");function F(t,e){return new RegExp(D(e),"s").test(t)}a(F,"fnmatch");function O(t,e){let n=T(t);for(let r of e){let o=T(r),s=i.relative(o,n);if(!(s===""||s===".."||s.startsWith(".."+i.sep)||i.isAbsolute(s)))return i.join(o,s.split(i.sep)[0])}return null}a(O,"workspaceUnder");function T(t){try{return l.realpathSync(t)}catch{return i.resolve(t)}}a(T,"_realpath");function R(t,e){if(e){let r=O(t,e);return r!==null&&E(g(r))?r:null}let n=i.resolve(t);for(;;){if(E(g(n)))return n;let r=i.dirname(n);if(r===n)return null;n=r}}a(R,"findWorkspaceRoot");function E(t){try{return l.statSync(t).isDirectory()}catch{return!1}}a(E,"_isDir");function P(t){try{return l.statSync(t).isFile()}catch{return!1}}a(P,"_isFile");function p(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}a(p,"_isDict");function W(t){let e=i.join(g(t),"standards.json");if(!P(e))return null;let n;try{n=JSON.parse(l.readFileSync(e,"utf8"))}catch{return null}return p(n)?n:null}a(W,"loadManifest");function k(t,e){return i.join(g(t),".gate",`${e}.json`)}a(k,"_statePath");function C(t,e){let n=k(t,e);if(!P(n))return{};let r;try{r=JSON.parse(l.readFileSync(n,"utf8"))}catch{return null}return p(r)?r:null}a(C,"_loadState");function J(t,e,n){try{let r=k(t,e);return l.mkdirSync(i.dirname(r),{recursive:!0}),l.writeFileSync(r,JSON.stringify(n)),!0}catch{return!1}}a(J,"_saveState");function q(t,e){if(!(!e||e.includes("/")||e.includes("..")))try{l.unlinkSync(k(t,e))}catch{}}a(q,"resetSessionState");function N(t){return[...t].sort()}a(N,"_sorted");function G(t){let e=/^---\r?\n([\s\S]*?)\r?\n---/.exec(t);if(!e)return;let n=/^status:\s*["']?([^\s"'#]+)/m.exec(e[1]);return n?n[1].toLowerCase():null}a(G,"_noteStatus");function H(t,e){let n=String(e.note??"");if(!/^[a-z]+$/.test(n))return!0;let r=e.status?String(e.status).toLowerCase():null,o=i.join(g(t),"notes"),s;try{s=l.readdirSync(o)}catch(u){return u.code!=="ENOENT"}let c=new RegExp(`^\\d{3}-${n}-.+\\.md$`);for(let u of s){if(!c.test(u))continue;let f;try{f=l.readFileSync(i.join(o,u),"utf8")}catch{return!0}let d=G(f);if(d===void 0)return!0;if(!(d==="superseded"||d==="graduated")&&(r===null||d===r))return!0}return!1}a(H,"_phaseGateSatisfied");function U(t){let e=String(t.note);if(t.status){let n=String(t.status);return`Phase gate: no \`${e}\` note in \`.werkmeister/notes/\` has \`status: ${n}\`, so source edits wait for an approved design. Invoke \`w9r-research\`, present the design to the user, and when they approve write \`NNN-${e}-<slug>.md\` with \`status: ${n}\` recording what was approved. Then retry this edit. Edits under \`.werkmeister/\` are not gated.`}return`Phase gate: no \`${e}\` note in \`.werkmeister/notes/\` names the root cause yet. Invoke \`w9r-research\`, reproduce the problem, and write \`NNN-${e}-<slug>.md\` stating the root cause. Then retry this edit. Edits under \`.werkmeister/\` are not gated.`}a(U,"_phaseGateText");function L(t,e,n){if(!e||e.includes("/")||e.includes(".."))return null;let r=R(t);if(r===null)return null;let o=W(r);if(o===null)return null;let s=C(r,e);if(s===null)return null;let c=n?i.relative(r,n):"",u=o.phase_gate;if(p(u)&&c&&c!==".."&&!c.startsWith(".."+i.sep)&&!i.isAbsolute(c)&&!c.startsWith($+i.sep)&&!H(r,u))return U(u);let f=new Set(Array.isArray(s.delivered)?s.delivered:[]),d=!s.phase_entry_delivered,h=null,S=p(o.domains)?o.domains:{};for(let m of N(Object.keys(S))){let y=S[m];if(f.has(m)||!p(y))continue;if((Array.isArray(y.applies_to)?y.applies_to:[]).some(b=>F(c,String(b)))){h=m;break}}if(!d&&h===null)return null;let w=[];if(d&&w.push(j),h!==null){let m=S[h],y=String(p(m)&&m.summary||"").trim(),_=`Standards gate: you are editing a path governed by the \`${h}\` standard, which has not been loaded this session. Invoke the \`w9r-${h}-standard\` skill, then retry this edit.`;y&&(_+=` Summary: ${y}.`),w.push(_)}w.push(A);let x={phase_entry_delivered:!0,delivered:N(h?new Set([...f,h]):f)};return J(r,e,x)?w.join(`
|
|
4
|
+
`):null}a(L,"decide");var M=/^\*\*\* (?:Add File|Update File|Delete File|Move to): (.+)$/gm;function X(t){return[...new Set([...t.matchAll(M)].map(e=>e[1].trim()))]}a(X,"patchPaths");function B(){let t;try{let f=process.stdin.isTTY?"":l.readFileSync(0,"utf8"),d=f.trim()?JSON.parse(f):{};t=p(d)?d:{}}catch{t={}}let e=String(t.session_id||""),n=t.tool_input,r=p(n)?n:{},o=String(t.cwd||process.cwd()),s=t.tool_name==="apply_patch"?r.command:void 0,c=typeof s=="string"?X(s).map(f=>i.resolve(o,f)):[String(r.file_path||"")],u=null;try{for(let f of c)if(u=L(o,e,f),u)break}catch{u=null}u&&console.log(JSON.stringify({hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:u}}))}a(B,"main");export{O as a,R as b,W as c,q as d,B as e};
|
|
5
|
+
//# sourceMappingURL=chunk-7D4A3HVZ.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createRequire as __sandboxCreateRequire } from "node:module";
|
|
2
|
+
const require = __sandboxCreateRequire(import.meta.url);
|
|
3
|
+
import{n as C,r as M}from"./chunk-C4J3VWL3.js";import{a as j,h as B,j as b,m as x,n as S}from"./chunk-OC7PYYEG.js";import{b as I}from"./chunk-RO5NEK3B.js";import{a as i,e as L,f as F}from"./chunk-K6GRVJQO.js";F();var _=L(j(),1);import{spawn as W}from"node:child_process";import*as k from"node:crypto";import*as p from"node:fs";import*as v from"node:net";import*as R from"node:os";import*as P from"node:path";function N(){return`.${M().local_domain.replace(/^\.+/,"")}`}i(N,"cookieDomain");var y={chrome:{label:"Google Chrome",engine:"chromium",macPath:"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"},chromium:{label:"Chromium",engine:"chromium",macPath:"/Applications/Chromium.app/Contents/MacOS/Chromium"},brave:{label:"Brave Browser",engine:"chromium",macPath:"/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"},edge:{label:"Microsoft Edge",engine:"chromium",macPath:"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"},firefox:{label:"Firefox",engine:"gecko",macPath:"/Applications/Firefox.app/Contents/MacOS/firefox"},safari:{label:"Safari",engine:"webkit",macPath:"/Applications/Safari.app/Contents/MacOS/Safari"},duckduckgo:{label:"DuckDuckGo",engine:"webkit",macPath:"/Applications/DuckDuckGo.app/Contents/MacOS/DuckDuckGo"}},A="chrome",oe={key:"browser",label:"Browser for `werkmeister feature open`",help:"Chromium browsers (chrome, chromium, brave, edge) work via CDP; safari works via Apple's bundled safaridriver. Firefox/DuckDuckGo are listed for visibility but aren't wired up yet.",acceptEmpty:!1,pattern:`(${Object.keys(y).join("|")})`,placeholder:A,choicesFn:i(()=>Object.keys(y),"choicesFn")};function H(){if(process.env.CHROME_BIN)return process.env.CHROME_BIN;let s=C().overrides??{};if(s.browser_path)return s.browser_path;let t=s.browser||A,e=y[t];if(!e)return x(`Unknown overrides.browser '${t}' -- choices: ${Object.keys(y).join(", ")}`),null;if(e.engine!=="chromium"){let o=e.engine==="webkit"?"WebKit":"Gecko",r=Object.keys(y).filter(n=>y[n].engine==="chromium");return x(`${e.label} uses ${o}, not Chromium -- \`werkmeister feature open\` only speaks the Chrome DevTools Protocol, which just Chromium-based browsers support. Run \`werkmeister machine setup\` and pick one of: ${r.join(", ")}.`),null}return e.macPath}i(H,"resolveBrowserBinary");function $(s){return new Promise(t=>setTimeout(t,s))}i($,"sleep");var O=class s{static{i(this,"WS")}host;port;sock;fatalError=null;rxbuf=Buffer.alloc(0);nextId=0;pending=[];handler=null;set onMessage(t){if(this.handler=t,t)for(;this.pending.length;)t(this.pending.shift())}constructor(t,e,o){this.sock=t,this.host=e,this.port=o}static connect(t){let e=new URL(t),o=e.hostname,r=e.port?parseInt(e.port,10):80,n=e.pathname||"/";return e.search&&(n+=e.search),new Promise((a,l)=>{let c=v.createConnection({host:o,port:r}),u=new s(c,o,r),d=!1,f=Buffer.alloc(0);c.setTimeout(1e4,()=>c.destroy(new Error("websocket handshake timed out"))),c.on("error",h=>{d?u.fatalError||(u.fatalError=h):l(h)}),c.on("close",()=>{d?u.fatalError||(u.fatalError=new Error("websocket closed by peer")):l(new Error("websocket handshake failed (closed)"))});let m=i(h=>{f=Buffer.concat([f,h]);let w=f.indexOf(`\r
|
|
4
|
+
\r
|
|
5
|
+
`);if(w===-1)return;if(!f.subarray(0,f.indexOf(`\r
|
|
6
|
+
`)).toString("latin1").includes(" 101 ")){c.destroy(),l(new Error(`websocket handshake failed: ${f.subarray(0,80).toString("latin1")}`));return}u.rxbuf=f.subarray(w+4),c.setTimeout(0),c.off("data",m),c.on("data",g=>{u.rxbuf=Buffer.concat([u.rxbuf,g]),u.pump()}),d=!0,a(u),u.pump()},"onHandshakeData");c.on("data",m),c.on("connect",()=>{let h=k.randomBytes(16).toString("base64"),w=`GET ${n} HTTP/1.1\r
|
|
7
|
+
Host: ${o}:${r}\r
|
|
8
|
+
Upgrade: websocket\r
|
|
9
|
+
Connection: Upgrade\r
|
|
10
|
+
Sec-WebSocket-Key: ${h}\r
|
|
11
|
+
Sec-WebSocket-Version: 13\r
|
|
12
|
+
\r
|
|
13
|
+
`;c.write(w)})})}sendFrame(t,e=1){let o=k.randomBytes(4),r=t.length,n;r<126?n=Buffer.from([128|e,128|r]):r<65536?(n=Buffer.alloc(4),n[0]=128|e,n[1]=254,n.writeUInt16BE(r,2)):(n=Buffer.alloc(10),n[0]=128|e,n[1]=255,n.writeBigUInt64BE(BigInt(r),2));let a=Buffer.alloc(r);for(let l=0;l<r;l++)a[l]=t[l]^o[l%4];this.sock.write(Buffer.concat([n,o,a]))}tryParseFrame(){if(this.rxbuf.length<2)return null;let t=this.rxbuf[0],e=this.rxbuf[1],o=t&15,r=e&127,n=2;if(r===126){if(this.rxbuf.length<4)return null;r=this.rxbuf.readUInt16BE(2),n=4}else if(r===127){if(this.rxbuf.length<10)return null;r=Number(this.rxbuf.readBigUInt64BE(2)),n=10}if(this.rxbuf.length<n+r)return null;let a=this.rxbuf.subarray(n,n+r);return this.rxbuf=this.rxbuf.subarray(n+r),{opcode:o,payload:a}}pump(){for(;;){let t;try{t=this.tryParseFrame()}catch(r){this.fatalError=r instanceof Error?r:new Error(String(r));return}if(!t)return;let{opcode:e,payload:o}=t;if(e===8){this.fatalError=new Error("websocket closed"),this.sock.destroy();return}if(e===9){this.sendFrame(o,10);continue}if(e!==10)try{let r=JSON.parse(o.toString("utf8"));this.handler?this.handler(r):this.pending.push(r)}catch(r){this.fatalError=r instanceof Error?r:new Error(String(r));return}}}send(t,e=null,o=null){this.nextId+=1;let r={id:this.nextId,method:t,params:e??{}};return o&&(r.sessionId=o),this.sendFrame(Buffer.from(JSON.stringify(r))),this.nextId}close(){try{this.sendFrame(Buffer.alloc(0),8)}catch{}try{this.sock.destroy()}catch{}}};function G(s){return BigInt("0x"+k.createHash("sha1").update(s).digest("hex"))}i(G,"sha1Int");function z(s){let t=G(s),e=Number(t%360n),o=.65,r=.42,n=(1-Math.abs(2*r-1))*o,a=n*(1-Math.abs(e/60%2-1)),l=r-n/2,c=[[n,a,0],[a,n,0],[0,n,a],[0,a,n],[a,0,n],[n,0,a]],[u,d,f]=c[Math.floor(e/60)],m=i(h=>Math.trunc((h+l)*255).toString(16).padStart(2,"0"),"hex");return`#${m(u)}${m(d)}${m(f)}`}i(z,"featureColor");function J(s,t){let e=JSON.stringify(s),o=JSON.stringify(t);return`
|
|
14
|
+
(function(){
|
|
15
|
+
var FEATURE=${e}, COLOR=${o}, TAG="["+FEATURE+"] ";
|
|
16
|
+
function pinTitle(){
|
|
17
|
+
var t=document.title;
|
|
18
|
+
while(t.indexOf(TAG)===0){ t=t.slice(TAG.length); } // collapse any doubling
|
|
19
|
+
if(!t) return; // wait for a real page title
|
|
20
|
+
var want=TAG+t;
|
|
21
|
+
if(document.title!==want){ document.title=want; }
|
|
22
|
+
}
|
|
23
|
+
function paintBadge(){
|
|
24
|
+
var root=document.documentElement; if(!root) return;
|
|
25
|
+
var id="__sandbox_feature_badge__";
|
|
26
|
+
if(document.getElementById(id)) return;
|
|
27
|
+
var b=document.createElement("div");
|
|
28
|
+
b.id=id; b.textContent="\\u25CF "+FEATURE;
|
|
29
|
+
b.style.cssText="position:fixed;z-index:2147483647;bottom:12px;right:12px;"
|
|
30
|
+
+"background:"+COLOR+";color:#fff;font:600 12px/1.4 -apple-system,system-ui,sans-serif;"
|
|
31
|
+
+"padding:6px 10px;border-radius:6px;box-shadow:0 2px 8px rgba(0,0,0,.35);"
|
|
32
|
+
+"pointer-events:none;letter-spacing:.02em;user-select:none;";
|
|
33
|
+
root.appendChild(b);
|
|
34
|
+
}
|
|
35
|
+
function tick(){ try{pinTitle();paintBadge();}catch(e){} }
|
|
36
|
+
document.addEventListener("DOMContentLoaded",tick);
|
|
37
|
+
tick();
|
|
38
|
+
setInterval(tick,1000); // self-heal across SPA route changes
|
|
39
|
+
})();
|
|
40
|
+
`}i(J,"badgeScript");function K(){return new Promise((s,t)=>{let e=v.createServer();e.once("error",t),e.listen(0,"127.0.0.1",()=>{let o=e.address().port;e.close(()=>s(o))})})}i(K,"findFreePort");async function q(s,t=15){let e=Date.now()+t*1e3,o=null;for(;Date.now()<e;)try{return(await(await fetch(`http://127.0.0.1:${s}/json/version`,{signal:AbortSignal.timeout(2e3)})).json()).webSocketDebuggerUrl}catch(r){o=r,await $(250)}throw new Error(`Chrome debug endpoint never came up on :${s} (${o})`)}i(q,"waitForBrowserWs");var T=class{static{i(this,"FeatureSession")}ws;feature;url;script;procExited;shouldStop;configured=new Set;cookieSet=!1;navigated=!1;constructor(t,e,o,r,n,a){this.ws=t,this.feature=e,this.url=r,this.script=J(e,o),this.procExited=n,this.shouldStop=a}configureTarget(t){this.cookieSet||(this.ws.send("Network.enable",null,t),this.ws.send("Network.setCookie",{name:"X-Feature",value:this.feature,domain:N(),path:"/",secure:!0,sameSite:"Lax"},t),this.cookieSet=!0),this.ws.send("Page.enable",null,t),this.ws.send("Page.addScriptToEvaluateOnNewDocument",{source:this.script},t),this.ws.send("Runtime.evaluate",{expression:this.script},t),this.navigated||(this.ws.send("Page.navigate",{url:this.url},t),this.navigated=!0)}onEvent(t){if(t?.method!=="Target.attachedToTarget")return;let e=t.params,o=e.sessionId;if(e.targetInfo?.type==="page"&&!this.configured.has(o)){this.configured.add(o);try{this.configureTarget(o)}catch(r){x(`could not configure tab: ${r instanceof Error?r.message:r}`)}}}async start(t=15e3){this.ws.send("Target.setAutoAttach",{autoAttach:!0,waitForDebuggerOnStart:!1,flatten:!0}),this.ws.onMessage=o=>this.onEvent(o);let e=Date.now()+t;for(;!this.navigated;){if(this.ws.fatalError)throw this.ws.fatalError;if(this.procExited()||Date.now()>e)return!1;await $(50)}return!0}async poll(){for(;!this.procExited()&&!this.shouldStop();){if(this.ws.fatalError)throw this.ws.fatalError;await $(1e3)}}};function X(){if(process.env.CHROME_BIN)return!1;let s=C().overrides??{};return s.browser_path?!1:(s.browser||A)==="safari"}i(X,"wantsSafari");async function ne(s,t,e={}){if(X()){let{launchSafariWindow:o}=await import("./safari-LADKSYXB.js");return o(s,t,e)}return V(s,t,e)}i(ne,"launchFeatureWindow");async function V(s,t,e={}){let o=e.size??"1440,900",r=e.position??null,n=H();if(!n)return null;if(!p.existsSync(n))return x(`Browser not found at ${n} (set CHROME_BIN, or overrides.browser_path in config.yaml, to override -- or run \`werkmeister machine setup\` to pick an installed browser)`),null;let a=z(s),l=await K(),c=p.mkdtempSync(P.join(R.tmpdir(),`chrome-${s}-`));if(!r){let g=Number(G(s)%8n)*40;r=`${60+g},${60+g}`}let u=[`--user-data-dir=${c}`,`--remote-debugging-port=${l}`,"--no-first-run","--no-default-browser-check","--new-window",`--window-size=${o}`,`--window-position=${r}`,"about:blank"],d=W(n,u,{stdio:"ignore",detached:!0});d.unref();let f=!1;d.on("exit",()=>{f=!0});let m=null;async function h(){m?.close();try{d.kill()}catch{}if(!f&&!await new Promise(D=>{let U=setTimeout(()=>D(!1),5e3);d.once("exit",()=>{clearTimeout(U),D(!0)})}))try{d.kill("SIGKILL")}catch{}p.rmSync(c,{recursive:!0,force:!0})}i(h,"cleanup");let w,E=!1;try{if(m=await O.connect(await q(l)),w=new T(m,s,a,t,()=>f,()=>E),!await w.start())return x("The browser window never came up \u2014 nothing was tagged."),await h(),null}catch(g){throw await h(),g}return S(`
|
|
41
|
+
`),b(`Feature : ${s}`),b(`Cookie : X-Feature=${s} (domain ${N()})`),b(`Badge : ${a}`),b(`URL : ${t}`),b(`Profile : ${c} (throwaway)`),S(`
|
|
42
|
+
Window is tagged ${B.BOLD}[${s}]${B.RESET} in the title bar + corner badge.
|
|
43
|
+
`),{stop:i(()=>{E=!0},"stop"),async supervise(){try{return await w.poll(),E?(S(`
|
|
44
|
+
`),b("Closing feature window\u2026"),130):0}finally{await h()}}}}i(V,"launchChromiumWindow");function se(s){for(let t of["workspace.yml","workspace.yaml"]){let e=P.join(I(s),t);if(!(p.existsSync(e)&&p.statSync(e).isFile()))continue;let o;try{o=(0,_.parse)(p.readFileSync(e,"utf8"))}catch{return{}}return o&&typeof o=="object"&&!Array.isArray(o)?o:{}}return{}}i(se,"readWorkspaceYaml");export{N as a,y as b,A as c,oe as d,$ as e,z as f,J as g,K as h,ne as i,se as j};
|
|
45
|
+
//# sourceMappingURL=chunk-7I5GWJOR.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createRequire as __sandboxCreateRequire } from "node:module";
|
|
2
|
+
const require = __sandboxCreateRequire(import.meta.url);
|
|
3
|
+
import{l as k,m as x}from"./chunk-H3J3PJGY.js";import{a as w}from"./chunk-OC7PYYEG.js";import{a as s,e as h,f as i}from"./chunk-K6GRVJQO.js";i();var j=h(w(),1);import*as c from"node:fs";import*as f from"node:path";function D(e){let t=e.split("/");return t.some((r,o)=>r==="node_modules"||o<t.length-1&&r.startsWith("."))}s(D,"pruned");function A(e,t=""){let r=[];for(let o of c.readdirSync(f.join(e,t),{withFileTypes:!0})){let a=t?`${t}/${o.name}`:o.name;if(o.isDirectory()){if(o.name==="node_modules"||o.name.startsWith("."))continue;r.push(...A(e,a))}else o.isFile()&&r.push(a)}return r}s(A,"walk");function z(e,t){let[r,o]=t(["git","-C",e,"ls-files","--cached","--others","--exclude-standard"]);return(r===0?o.split(`
|
|
4
|
+
`).map(n=>n.trim()).filter(Boolean):A(e)).filter(n=>!D(n)&&c.existsSync(f.join(e,n))).sort()}s(z,"listRepoFiles");function y(e,t){return c.readFileSync(f.join(e.root,t),"utf8")}s(y,"readText");function S(e,t){if(!e.files.includes(t))return null;let r=JSON.parse(y(e,t));return r&&typeof r=="object"&&!Array.isArray(r)?r:null}s(S,"readJson");function J(e){return(0,j.parseAllDocuments)(e).map(t=>{if(t.errors.length)throw new Error(t.errors[0].message);return t.toJS()})}s(J,"yamlDocs");function O(e){try{let t=x(e,{capture:!0,timeout:120});return[t.status,t.status===0?t.stdout||"":(t.stderr||t.stdout||"").trim()]}catch(t){if(t instanceof k&&t.code==="ENOENT")return[127,`${e[0]}: command not found`];if(t instanceof k&&t.code==="ETIMEDOUT")return[124,`${e.join(" ")}: timed out`];throw t}}s(O,"stdoutRunner");i();var b=h(w(),1);import*as m from"node:path";i();function g(e,t){return{value:e,source:t,confidence:"stated"}}s(g,"stated");function I(e,t){return{value:e,source:t,confidence:"guessed"}}s(I,"guessed");var T={npm:"npm install",pnpm:"corepack enable && pnpm install",yarn:"corepack enable && yarn install"},W={npm:["package-lock.json","npm ci"],pnpm:["pnpm-lock.yaml","corepack enable && pnpm install --frozen-lockfile"]};function K(e){return[e("pnpm-lock.yaml")&&"pnpm install --frozen-lockfile",e("package-lock.json")&&"npm ci",e("yarn.lock")&&(e(".yarnrc.yml")?"yarn install --immutable":"yarn install --frozen-lockfile"),e("uv.lock")&&"uv sync --frozen"].filter(t=>!!t)}s(K,"frozenInstalls");function F(e,t){let r=s(n=>new RegExp("^"+n.replace(/^\.\//,"").replace(/\/+$/,"").replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"\0").replace(/\*/g,"[^/]+").replace(/\0/g,".+")+"$"),"toRe"),o=e.filter(n=>!n.startsWith("!")).map(r),a=e.filter(n=>n.startsWith("!")).map(n=>r(n.slice(1)));return t.filter(n=>n.endsWith("/package.json")).map(n=>m.posix.dirname(n)).filter(n=>o.some(l=>l.test(n))&&!a.some(l=>l.test(n))).sort()}s(F,"expandWorkspaceGlobs");function M(e,t=null,r=null){let o=s(p=>e.files.includes(p),"has"),a=o("pnpm-lock.yaml")||o("pnpm-workspace.yaml")?"pnpm":o("yarn.lock")?"yarn":"npm",n=S(e,"package.json");if(!n)return{pm:a,packageDirs:[],setupName:null,setupFields:{}};let l=[],u="package.json";if(o("pnpm-workspace.yaml")){let p=(0,b.parse)(y(e,"pnpm-workspace.yaml"))?.packages;l=Array.isArray(p)?p.map(String):[],u="pnpm-workspace.yaml"}else{let p=n.workspaces;l=Array.isArray(p)?p.map(String):Array.isArray(p?.packages)?p.packages.map(String):[],l.length&&(u="package.json \u2192 workspaces")}let d=W[a],E=d&&o(d[0])?d[1]:T[a];return{pm:a,packageDirs:F(l,e.files),setupName:t??`${m.basename(e.root)}-install`,setupFields:{command:g(E,`${u} (${a})`),node_modules_volume:g(r??`${m.basename(e.root)}-node-modules`,u)}}}s(M,"detectWorkspace");export{z as a,y as b,S as c,J as d,O as e,g as f,I as g,K as h,M as i};
|
|
5
|
+
//# sourceMappingURL=chunk-7YUHPLUW.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __sandboxCreateRequire } from "node:module";
|
|
2
|
+
const require = __sandboxCreateRequire(import.meta.url);
|
|
3
|
+
import{a as p,b as a}from"./chunk-RO5NEK3B.js";import{a as o,f as c}from"./chunk-K6GRVJQO.js";c();import*as i from"node:fs";import*as s from"node:path";function u(t){let e=s.resolve(t);for(;;){if(i.existsSync(s.join(a(e),"workspace.yml")))return e;let r=s.dirname(e);if(r===e)return null;e=r}}o(u,"findRecordRoot");function d(t){try{let e=i.readdirSync(s.join(t,"stages")).filter(n=>/^\d+_/.test(n)).sort(),r=e.find(n=>/^\d+_propose$/.test(n))??e.find(n=>/^\d+_ship$/.test(n))??e.at(-1);return r?`stages/${r}/output/`:"the last stage's output/"}catch{return`${s.basename(a(t))}/notes/`}}o(d,"prFileDirName");var f=/(?<!<)<<(?!<)-?\s*(['"]?)(\w+)\1([^\n]*)(?:\n(?:[\s\S]*?\n)?\t*\2(?=\n|$)|[\s\S]*$)/g,m=/'[^']*(?:'|$)|"(?:[^"\\]|\\[\s\S])*(?:"|$)/g,h=/(?:^|[;&|({\n`])\s*(?:(?:\w+=\S*|command|exec|env|then|do|else)\s+)*gh\s+pr\s+create\b/,R=/create_pull_request$/;function y(t){return h.test(t.replace(f,"$3").replace(m,"_"))}o(y,"opensPr");function S(t){return["_shared/pr-rules.md",`${p}/pr-rules.md`].find(e=>i.existsSync(s.join(t,e)))??"docs/workspace-lifecycle.md in the werkmeister repo"}o(S,"prRulesPath");function _(t){let e=u(String(t.cwd||process.cwd()));if(!e)return null;let r=String(t.tool_name||""),n=String(t.tool_input?.command||"");if(!(r==="Bash"&&y(n)||R.test(r)))return null;let l=S(e);return`Inside workspace \`${s.basename(e)}\`, PRs open only through \`werkmeister pr open\`: it runs the pre-PR gate and records the URL. Write the PR file in \`${d(e)}\`, have the person set \`status: approved\`, then run \`werkmeister pr open\`. Rules: \`${l}\`.`}o(_,"decide");function w(){let t=null;try{let e=process.stdin.isTTY?"":i.readFileSync(0,"utf8"),r=e.trim()?JSON.parse(e):{};typeof r=="object"&&r!==null&&!Array.isArray(r)&&(t=_(r))}catch{t=null}t&&console.log(JSON.stringify({hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:t}}))}o(w,"main");export{u as a,S as b,w as c};
|
|
4
|
+
//# sourceMappingURL=chunk-A5QL5RDB.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createRequire as __sandboxCreateRequire } from "node:module";
|
|
2
|
+
const require = __sandboxCreateRequire(import.meta.url);
|
|
3
|
+
import{b as st}from"./chunk-HKKHKLTS.js";import{f as _e,g as $e,h as H,i as be}from"./chunk-EOBOW6TP.js";import{a as ve,b as S,c as se,d as K,f as y,g as w,i as ye}from"./chunk-7YUHPLUW.js";import{r as ke}from"./chunk-C4J3VWL3.js";import{A as he,X as ge,a as F,w as ue}from"./chunk-OC7PYYEG.js";import{a as p,e as M,f as $}from"./chunk-K6GRVJQO.js";$();var ie=M(F(),1);import*as z from"node:fs";import*as oe from"node:path";var re=class extends Error{static{p(this,"AllocationError")}};function Ct(e=he()){try{let t=(0,ie.parse)(z.readFileSync(e,"utf8"))?.feature_slots?.ports_per_slot;return Number.isInteger(t)&&t>0?t:20}catch{return 20}}p(Ct,"portsPerSlot");function ne(e,t){for(let r of["services","infrastructure"])for(let a of Object.values(e?.[r]??{})){if(!a||typeof a!="object")continue;let i=a;Number.isInteger(i.port_offset)&&t.offsets.add(i.port_offset),Number.isInteger(i.k8s_forward_port)&&t.forwards.add(i.k8s_forward_port)}}p(ne,"collect");function xe(e,t,r,a){let i={offsets:new Set,forwards:new Set};for(let n of H(e))oe.resolve(n.path)!==oe.resolve(t)&&ne(n.doc,i);return z.existsSync(r)&&ne((0,ie.parse)(z.readFileSync(r,"utf8"))??null,i),ne(a,i),i}p(xe,"takenPorts");function we(e,t,r){let a=new Set(t),i=new Map;for(let n of[...e].sort()){let s=0;for(;a.has(s);)s++;if(s>=r)throw new re(`port_offset exhausted: ${r} offsets (ports.yaml ports_per_slot) are all used \u2014 raise ports_per_slot or free one`);a.add(s),i.set(n,s)}return i}p(we,"allocateOffsets");function Se(e,t,r=9050){let a=new Set(t),i=new Map;for(let n of[...e].sort()){let s=r;for(;a.has(s);)s++;a.add(s),i.set(n,s)}return i}p(Se,"allocateForwards");var nt=p(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeRe");function je(e,t,r){let a={...e},i=[];for(let n of t){let s=a[n];if(s===void 0)continue;let o=s;for(let c of r)o=o.replace(new RegExp(`(?<![\\w.-])${nt(c.host??c.name)}:${c.port}\\b`,"g"),`k8s-${c.name}:${c.forward}`);o!==s&&(a[n]=o,i.push(n))}return{env:a,rewritten:i}}p(je,"rewriteEnv");$();var Ie=M(F(),1);$();$();import*as U from"node:path";var ae={redis:{health:"redis",port:6379},postgres:{health:"postgres",port:5432},postgis:{health:"postgres",port:5432},mysql:{health:"",port:3306},mariadb:{health:"",port:3306},mongo:{health:"",port:27017},rabbitmq:{health:"",port:5672}};function Ae(e){return(e.split("@")[0].split("/").pop()??e).split(":")[0]}p(Ae,"imageRepoName");var Oe=p((e,t)=>e.name.localeCompare(t.name),"byName");function Ee(e){let t=e.image?Ae(e.image):"";return Object.hasOwn(ae,t)?t:null}p(Ee,"datastoreOf");function Ne(e,t){let r=e.filter(f=>f.kind==="package"||f.kind==="dockerfile"),a=e.filter(f=>f.kind==="k8s"||f.kind==="compose"),i=[...new Set(r.map(f=>f.dir))].sort(),n=p(f=>f==="."?t:U.posix.basename(f),"base"),s=p(f=>{let h=U.posix.dirname(f);return h==="."?t:U.posix.basename(h)},"parent"),o=new Map;for(let f of i)o.set(n(f),(o.get(n(f))??0)+1);let c=i.map(f=>({dir:f,name:(o.get(n(f))??0)>1?`${s(f)}-${n(f)}`:n(f),findings:r.filter(h=>h.dir===f)})),u=[(f,h)=>f.kind==="k8s"&&f.dir!==null&&h.dir!=="."&&(f.dir===h.dir||f.dir.startsWith(`${h.dir}/`)),(f,h)=>f.kind==="compose"&&f.dir!==null&&f.dir===h.dir,(f,h)=>f.name===h.name,(f,h)=>!!f.image&&Ae(f.image)===h.name],m=[];for(let f of a){let h=Ee(f)?[u[2]]:u,b;for(let N of h)if(b=c.find(j=>N(f,j)),b)break;b?b.findings.push(f):m.push(f)}let d=[],g=new Map,k=[];for(let f of m){let h=Ee(f);if(h){let b=g.get(f.name)??{name:f.name,datastore:h,findings:[]};b.findings.push(f),g.set(f.name,b)}else{k.push(f);let b=f.kind==="k8s"?"Deployment":"compose service";d.push({item:f.file,reason:`found ${b} ${f.name} \u2014 no source dir in this repo, skipped`})}}return{services:c.filter(f=>{let h=f.findings.some(b=>b.kind!=="package"||b.runnable);return h||d.push({item:f.dir,reason:"library package (no Dockerfile, deploy config or dev/start script), skipped"}),h}).sort(Oe),infrastructure:[...g.values()].sort(Oe),unmatched:k,skipped:d}}p(Ne,"correlate");var ot={type:["package"],archetype:["package"],test:["package"],internal_port:["k8s","compose","dockerfile"],health_endpoint:["k8s","compose"],setup_service:["package"],image:["dockerfile","package"],command:["package","compose","dockerfile"],memory_limit:["k8s"],memory_reservation:["k8s"],node_modules_volume:["package"],secrets:["k8s"],k8s_deployment:["k8s"],k8s_namespace:["k8s"],k8s_port:["k8s"],k8s_port_name:["k8s"],k8s_pod_prefix:["k8s"],feature_router:["k8s"],depends_on:["compose"]},ce=p((e,t)=>JSON.stringify(e)===JSON.stringify(t),"same");function rt(e){return Object.fromEntries(Object.entries(e).sort(([t],[r])=>t.localeCompare(r)))}p(rt,"sortKeys");function Pe(e,t){return Object.assign({},...e.filter(r=>r.kind===t&&r.fields.environment).map(r=>r.fields.environment.value))}p(Pe,"envOf");function V(e){let t={path:y(e.dir,"source directory")},r=[];for(let[o,c]of Object.entries(ot)){let u=c.flatMap(g=>e.findings.filter(k=>k.kind===g&&k.fields[o]!==void 0).map(k=>k.fields[o]));if(!u.length)continue;let m=u[0];if(t[o]=m,m.confidence!=="stated")continue;let d=u.slice(1).filter(g=>g.confidence==="stated"&&!ce(g.value,m.value)).filter((g,k,v)=>v.findIndex(f=>ce(f.value,g.value))===k);d.length&&r.push({service:e.name,key:o,chosen:m,also:d})}t.internal_port??=w(3e3,"no port in any source \u2014 default 3000"),t.health_endpoint??=w("","no readiness probe or healthcheck \u2014 TCP-only"),t.type??=w("api","no package.json \u2014 assumed a service"),t.image??=w("alpine:3","no usable FROM and no package.json \u2014 set the dev image"),!t.feature_router&&t.type.value==="web"&&(t.feature_router=w({},"type: web \u2014 routed through Caddy"));let a=Pe(e.findings,"k8s"),i=Pe(e.findings,"compose"),n={...a,...i};if(Object.keys(n).length){let o=[Object.keys(i).length?"compose environment":"",Object.keys(a).length?"k8s env":""];t.environment=y(rt(n),o.filter(Boolean).join(" + "))}let s=Object.keys(a).filter(o=>!(o in i)).sort();return{name:e.name,dir:e.dir,fields:t,conflicts:r,k8sEnvKeys:s,findings:e.findings}}p(V,"resolveService");function Me(e,t=[]){let r=ae[e.datastore],a=e.findings.filter(o=>o.kind==="k8s"),i=a[0];for(let o of a.slice(1))for(let c of["internal_port","k8s_namespace"]){let u=i.fields[c],m=o.fields[c];u&&m&&!ce(u.value,m.value)&&t.push({item:o.file,reason:`infrastructure ${e.name}: ${c} ${m.value} disagrees with ${u.value} (${u.source}), kept ${u.value}`})}let n=i?.fields.internal_port??e.findings.find(o=>o.fields.internal_port)?.fields.internal_port,s="no k8s manifest for this datastore";return{name:e.name,fields:{internal_port:n??y(r.port,`${e.datastore} default port`),k8s_namespace:i?.fields.k8s_namespace??w("default",s),k8s_pod_prefix:i?.fields.k8s_pod_prefix??w(e.name,s),health_endpoint:y(r.health,r.health?`${e.datastore} wire probe`:"no wire probe for this datastore \u2014 TCP-only")}}}p(Me,"resolveInfra");var Xt={type:"object",required:["answers"],additionalProperties:!1,properties:{answers:{type:"array",items:{type:"object",required:["item","value","reason","files_read"],additionalProperties:!1,properties:{item:{type:"string"},value:{},reason:{type:"string"},files_read:{type:"array",items:{type:"string"}}}}}}};function it(e){let t=e.existing?(0,Ie.parse)(e.existing)??{}:{},r=p((n,s)=>t?.services?.[n]?.[s]!==void 0,"inFile"),a=e.services.map(n=>n.name),i=[];for(let n of e.services){let s=n.fields,o=p((m,d)=>{r(n.name,m)||i.push({id:`${n.name}.${m}`,service:n.name,...d})},"ask");s.command?.confidence==="guessed"&&o("command",{kind:"command",prompt:`What command starts ${n.name} for local development? It runs with the repo root mounted at /app as the working directory.`,facts:{dir:n.dir,guess:s.command.value,why:s.command.source}}),s.health_endpoint?.confidence==="guessed"&&o("health_endpoint",{kind:"health_endpoint",prompt:`Which HTTP path answers 200 when ${n.name} is healthy? Answer "" if it has none.`,facts:{dir:n.dir,port:s.internal_port?.value}});let c=e.envExample[n.name]??[];c.length&&(o("environment",{kind:"environment",prompt:`Which environment variables does ${n.name} need for local development, with development values? Leave secrets out.`,facts:{dir:n.dir,env_example_keys:c,current:s.environment?.value??{}}}),s.secrets||o("secrets",{kind:"secrets",prompt:`Which of these keys must be set for ${n.name} to start at all? A declared secret that is missing stops \`werkmeister feature up\`.`,facts:{dir:n.dir},choices:c}));let u=a.filter(m=>m!==n.name);u.length&&!s.depends_on&&o("depends_on",{kind:"depends_on",prompt:`Which of these services must be running before ${n.name} starts (it calls them at startup)? Answer [] for none.`,facts:{dir:n.dir},choices:u});for(let m of n.conflicts)o(m.key,{kind:"conflict",prompt:`Sources disagree on ${n.name}.${m.key}. Which value is right for local development?`,facts:{sources:[m.chosen,...m.also].map(d=>({value:d.value,source:d.source}))},choices:[m.chosen.value,...m.also.map(d=>d.value)]})}for(let n of[...new Set(e.unmatched.map(s=>s.name))]){let s=e.unmatched.filter(c=>c.name===n),o=s.map(c=>c.file).join(", ");i.push({id:`unmatched.${n}`,kind:"unmatched",service:null,prompt:`${o} define${s.length>1?"":"s"} ${n}, but no source directory matched it. Which service is it? Answer null if its code lives in another repo.`,facts:{files:s.map(c=>c.file),image:s.find(c=>c.image)?.image??null},choices:[...a,null]})}return i}p(it,"collectQuestions");var at=p(e=>!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.values(e).every(t=>typeof t=="string"),"isStringMap"),De=p((e,t)=>Array.isArray(e)&&e.every(r=>typeof r=="string"&&t.includes(r)),"subsetOf"),ct=p((e,t)=>JSON.stringify(e)===JSON.stringify(t),"same");function ft(e,t,r,a){if(r===null)return null;let i=typeof r=="string"?e.services.find(o=>o.name===r):void 0,n=e.unmatched.filter(o=>`unmatched.${o.name}`===t);if(!i||!n.length)return"expected one of this repo's services, or null";let s=V({name:i.name,dir:i.dir,findings:[...i.findings,...n]});for(let[o,c]of Object.entries(s.fields))o in i.fields||(i.fields[o]={...c,confidence:"inferred",source:`${c.source}; matched by Claude: ${a}`});return i.findings.push(...n),e.unmatched=e.unmatched.filter(o=>!n.includes(o)),e.skipped=e.skipped.filter(o=>!n.some(c=>o.item===c.file&&o.reason.includes(` ${c.name} \u2014 `))),null}p(ft,"applyUnmatched");function Qt(e,t){let r=structuredClone(e),a=new Map(it(e).map(o=>[o.id,o])),i=[],n=[],s=new Set;for(let o of t){let c=a.get(o.item);if(!c){n.push({item:o.item,reason:"not one of the questions asked"});continue}if(s.has(o.item)){n.push({item:o.item,reason:"answered twice; kept the first"});continue}s.add(o.item);let u=o.reason?.trim()||"no reason given",m=p(k=>({value:k,source:u,confidence:"inferred"}),"inferred"),d=c.service?r.services.find(k=>k.name===c.service):void 0,g=null;if(c.kind==="unmatched")g=ft(r,c.id,o.value,u);else if(!d)g=`no service named ${c.service} in this plan`;else switch(c.kind){case"command":typeof o.value=="string"&&o.value.trim()?d.fields.command=m(o.value.trim()):g="expected a non-empty command string";break;case"health_endpoint":typeof o.value=="string"&&(o.value===""||o.value.startsWith("/"))?d.fields.health_endpoint=m(o.value):g='expected "" or a path starting with /';break;case"environment":{if(!at(o.value)){g="expected an object of string values";break}let k=d.fields.environment?.value??{},v=Object.fromEntries(Object.entries({...o.value,...k}).sort(([h],[b])=>h.localeCompare(b))),f=d.fields.environment?.source;d.fields.environment=m(v),f&&(d.fields.environment.source=`${f}; Claude added keys: ${u}`);break}case"secrets":De(o.value,c.choices??[])?o.value.length&&(d.fields.secrets=m([...o.value].sort())):g="expected a list of keys from .env.example";break;case"depends_on":De(o.value,c.choices??[])?o.value.length&&(d.fields.depends_on=m([...o.value].sort())):g="expected a list of this repo's other services";break;case"conflict":{let k=(c.choices??[]).find(f=>ct(f,o.value));if(k===void 0){g="not one of the conflicting values";break}let v=c.id.slice(d.name.length+1);d.fields[v]=m(k),d.conflicts=d.conflicts.filter(f=>f.key!==v);break}}g?n.push({item:o.item,reason:g}):i.push(o.item)}return{plan:r,accepted:i,rejected:n}}p(Qt,"applyAnswers");function es(e){return["You are helping generate a werkmeister service-registry fragment for the repository in your working directory.","A deterministic scan already filled every field it could read from package manifests, Dockerfiles, compose files and Kubernetes manifests.","The questions below are the fields it had to guess. Answer each one from the repository's own files, using Read, Glob and Grep.","","Rules:","- Answer only the questions listed, using each question's `id` as `item`.","- When a question has `choices`, `value` must be one of them; for list questions, a subset of them.","- Leave a question out if the repository doesn't settle it. A missing answer keeps the scan's guess; a wrong answer is worse than none.","- Never put credentials, tokens or keys in environment values. Those belong in `secrets`.",'- `reason` is one short sentence naming the evidence, e.g. "apps/api/src/main.ts registers GET /healthz". It is written into the file as a comment.',"- `files_read` lists the files that support the answer.","","Questions (JSON):",JSON.stringify(e,null,2)].join(`
|
|
4
|
+
`)}p(es,"assistPrompt");$();var Je=M(F(),1);import*as X from"node:fs";import*as T from"node:path";$();var Te=M(F(),1);import*as Z from"node:path";var fe=/(^|\/)(docker-)?compose(\.[\w-]+)?\.ya?ml$/;function Fe(e){if(typeof e=="number")return Number.isInteger(e)&&e>0?e:void 0;if(typeof e=="string"){let t=(e.split(":").pop()??"").split("/")[0].split("-")[0],r=Number(t);return Number.isInteger(r)&&r>0?r:void 0}if(e&&typeof e=="object"){let t=e.target;return typeof t=="number"&&Number.isInteger(t)?t:void 0}}p(Fe,"containerPort");function pt(e){return Array.isArray(e)?Object.fromEntries(e.map(String).filter(t=>t.includes("=")).map(t=>[t.slice(0,t.indexOf("=")),t.slice(t.indexOf("=")+1)])):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).filter(([,t])=>t!=null).map(([t,r])=>[t,String(r)])):{}}p(pt,"envMap");function mt(e){let t=e?.test,r=Array.isArray(t)?t.join(" "):String(t??"");return/https?:\/\/[^/\s"']+(\/[^\s"']*)/.exec(r)?.[1]}p(mt,"healthPath");function Re(e){let t=[];for(let r of e.files.filter(a=>fe.test(a))){let a;try{a=(0,Te.parse)(S(e,r),{merge:!0})}catch(i){e.skipped.push({item:r,reason:`unparsable YAML: ${i instanceof Error?i.message:String(i)}`});continue}for(let[i,n]of Object.entries(a?.services??{})){if(!n||typeof n!="object")continue;let s=n,o=p(f=>`${r} \u2192 services.${i}.${f}`,"src"),c=typeof s.build=="string"?s.build:s.build?.context,u=c===void 0?null:Z.posix.normalize(Z.posix.join(Z.posix.dirname(r),String(c))).replace(/\/$/,"")||".",m={},d=pt(s.environment);Object.keys(d).length&&(m.environment=y(d,o("environment")));let g=Array.isArray(s.depends_on)?s.depends_on.map(String):s.depends_on&&typeof s.depends_on=="object"?Object.keys(s.depends_on):[];g.length&&(m.depends_on=y([...g].sort(),o("depends_on"))),s.command!==void 0&&(m.command=y(Array.isArray(s.command)?s.command.join(" "):String(s.command),o("command")));let k=Fe(s.ports?.[0])??Fe(s.expose?.[0]);k&&(m.internal_port=y(k,o(s.ports?"ports":"expose")));let v=mt(s.healthcheck);v&&(m.health_endpoint=y(v,o("healthcheck"))),t.push({kind:"compose",name:i,dir:u,file:r,...s.image?{image:String(s.image)}:{},fields:m})}}return t}p(Re,"detectCompose");$();import*as R from"node:path";var lt=/^(?!.*\.(md|dockerignore)$)(Dockerfile(\..+)?|.+\.Dockerfile)$/,dt=/(^|\.)dev(\.|$)/i;function ut(e){let t=[];for(let r of e.replace(/\\\r?\n/g," ").split(/\r?\n/)){let a=r.trim();if(!a||a.startsWith("#"))continue;let i=/^(\w+)\s+(.*)$/.exec(a);i&&t.push([i[1].toUpperCase(),i[2].trim()])}return t}p(ut,"dockerInstructions");function ht(e){if(e.startsWith("["))try{let t=JSON.parse(e);if(Array.isArray(t))return t.map(String).join(" ")}catch{}return e}p(ht,"commandText");function qe(e){let t=p(a=>dt.test(R.posix.basename(a)),"isDev");return e.files.filter(a=>lt.test(R.posix.basename(a))).sort((a,i)=>Number(t(i))-Number(t(a))||a.localeCompare(i)).map(a=>{let i=R.posix.dirname(a),n=ut(S(e,a)),s={},c=n.find(([k])=>k==="FROM")?.[1].split(/\s+/).find(k=>!k.startsWith("--"));c&&!c.includes("$")&&(s.image=y(c,`${a} \u2192 FROM`));let u=n.find(([k])=>k==="EXPOSE"),m=Number(/(\d+)/.exec(u?.[1]??"")?.[1]);Number.isInteger(m)&&m>0&&(s.internal_port=y(m,`${a} \u2192 EXPOSE`));let d=p(k=>[...n].reverse().find(([v])=>v===k),"last"),g=d("CMD")??d("ENTRYPOINT");if(g){let k=ht(g[1]);s.command=w(i==="."?k:`cd ${i} && exec ${k}`,`${a} \u2192 ${g[0]} is the production entrypoint`)}return{kind:"dockerfile",name:i==="."?R.basename(e.root):R.posix.basename(i),dir:i,file:a,fields:s}})}p(qe,"detectDockerfiles");$();var Ke=M(F(),1);import*as P from"node:path";$();import*as G from"node:path";var gt=new Set(["Deployment","StatefulSet"]);function Ce(e){let t=/^(\d+)([KMG])?i?$/.exec(String(e??""));return t?`${t[1]}${t[2]??""}`:void 0}p(Ce,"memory");function kt(e){let t=e?.spec?.rules??[];return[e?.spec?.defaultBackend?.service?.name,...t.flatMap(r=>(r?.http?.paths??[]).map(a=>a?.backend?.service?.name))].filter(r=>typeof r=="string")}p(kt,"ingressBackends");function J(e){let t=e.flatMap(n=>n.docs.flatMap(s=>s?.kind==="List"&&Array.isArray(s.items)?s.items:[s]).filter(s=>s&&typeof s=="object"&&typeof s.kind=="string").map(s=>({doc:s,source:n}))),r=t.filter(n=>n.doc.kind==="Service").map(n=>n.doc),a=new Set(t.filter(n=>n.doc.kind==="Ingress").flatMap(n=>kt(n.doc))),i=[];for(let{doc:n,source:s}of t.filter(o=>gt.has(o.doc.kind))){let o=n.metadata?.name,c=n.spec?.template?.spec?.containers?.[0];if(typeof o!="string"||!c)continue;let u=p(x=>`${s.file} \u2192 ${x}`,"src"),m={k8s_namespace:n.metadata?.namespace?y(n.metadata.namespace,u("metadata.namespace")):y("default",`${s.file} \u2192 no metadata.namespace (Kubernetes default)`),k8s_pod_prefix:y(o,u(`${n.kind} ${o}`))};n.kind==="Deployment"&&(m.k8s_deployment=y(o,u(`Deployment ${o}`)));let d=c.ports?.[0]?.containerPort;Number.isInteger(d)&&(m.internal_port=y(d,u("containerPort")));let g=c.readinessProbe?.httpGet?.path?["readinessProbe",c.readinessProbe.httpGet.path]:c.livenessProbe?.httpGet?.path?["livenessProbe",c.livenessProbe.httpGet.path]:null;g&&(m.health_endpoint=y(String(g[1]),u(`${g[0]}.httpGet.path`)));let k=Ce(c.resources?.limits?.memory),v=Ce(c.resources?.requests?.memory);k&&(m.memory_limit=y(k,u("resources.limits.memory"))),v&&(m.memory_reservation=y(v,u("resources.requests.memory")));let f={},h=[];for(let x of Array.isArray(c.env)?c.env:[])typeof x?.name=="string"&&(x.valueFrom?.secretKeyRef?h.push(x.name):x.value!==void 0&&x.value!==null&&(f[x.name]=String(x.value)));Object.keys(f).length&&(m.environment=y(f,u("env"))),h.length&&(m.secrets=y([...h].sort(),u("env[].valueFrom.secretKeyRef")));let b=n.spec?.template?.metadata?.labels??{},N=r.find(x=>{let Y=x.spec?.selector??{};return Object.keys(Y).length>0&&Object.entries(Y).every(([Q,ee])=>b[Q]===ee)}),j=N?.metadata?.name,I=N?.spec?.ports?.[0];Number.isInteger(I?.port)&&(m.k8s_port=y(I.port,u(`Service ${j} port`))),typeof I?.name=="string"&&(m.k8s_port_name=y(I.name,u(`Service ${j} port name`))),j&&a.has(j)&&(m.feature_router=y({},u(`Ingress \u2192 Service ${j}`))),i.push({kind:"k8s",name:o,dir:s.dir,file:s.file,...typeof c.image=="string"?{image:c.image}:{},fields:m})}return i}p(J,"findingsFromManifests");function pe(e){return e.filter(t=>G.posix.basename(t)==="Chart.yaml").map(t=>G.posix.dirname(t))}p(pe,"chartDirs");var me=/(^|\/)kustomization\.ya?ml$/,vt=[/(^|\/)values[^/]*\.ya?ml$/,/\.values\.ya?ml$/,/^pnpm-workspace\.yaml$/,fe],yt=/^\s*kind:\s*(Deployment|StatefulSet|Service|Ingress|List)\b/m;function We(e){let t=[...pe(e.files),...e.files.filter(i=>me.test(i)).map(i=>G.posix.dirname(i))],r=p(i=>t.some(n=>n==="."||i.startsWith(`${n}/`)),"ownedElsewhere"),a=[];for(let i of e.files){if(!/\.ya?ml$/.test(i)||r(i)||vt.some(s=>s.test(i)))continue;let n=S(e,i);if(yt.test(n))try{a.push({file:i,dir:G.posix.dirname(i),docs:K(n)})}catch(s){e.skipped.push({item:i,reason:`unparsable YAML: ${s instanceof Error?s.message:String(s)}`})}}return J(a)}p(We,"detectK8s");function _t(e,t){try{let r=(0,Ke.parse)(S(e,`${t}/Chart.yaml`))?.name;return typeof r=="string"&&r?r:P.posix.basename(t)}catch{return P.posix.basename(t)}}p(_t,"chartName");function Le(e){let t=pe(e.files),r=[];for(let a of t){let i=P.posix.dirname(a),n=t.filter(c=>P.posix.dirname(c)===i),s=e.files.filter(c=>P.posix.dirname(c)===i&&/[^/]\.values\.ya?ml$/.test(c));if(s.length&&n.length>1){if(a===n[0])for(let c of s)e.skipped.push({item:c,reason:`several charts in ${i}/ \u2014 can't tell which one ${c} is for`});continue}let o=s.length?s.map(c=>({release:P.posix.basename(c).replace(/\.values\.ya?ml$/,""),values:c})):[{release:_t(e,a),values:null}];for(let{release:c,values:u}of o){let m=["helm","template",c,P.join(e.root,a)];u&&m.push("-f",P.join(e.root,u));let[d,g]=e.runner(m);if(d===127)return e.skipped.push({item:"helm charts",reason:"helm is not installed \u2014 charts skipped"}),r;let k=u??a;if(d!==0){e.skipped.push({item:k,reason:`helm template failed: ${g.split(`
|
|
5
|
+
`)[0]}`});continue}try{r.push(...J([{file:`${k} (helm template)`,dir:null,docs:K(g)}]))}catch(v){e.skipped.push({item:k,reason:`unparsable helm output: ${v instanceof Error?v.message:String(v)}`})}}}return r}p(Le,"detectHelm");$();var Ye=M(F(),1);import*as q from"node:path";function $t(e,t){let r=new Set;for(let a of t){let i;try{i=(0,Ye.parse)(S(e,a))}catch{continue}let n=q.posix.dirname(a);for(let s of[i?.resources,i?.bases,i?.components].flatMap(o=>Array.isArray(o)?o:[]))typeof s=="string"&&r.add(q.posix.normalize(q.posix.join(n,s)).replace(/\/$/,""))}return r}p($t,"referencedDirs");function ze(e){let t=[],r=e.files.filter(i=>me.test(i)),a=$t(e,r);for(let i of r){let n=q.posix.dirname(i);if(a.has(n))continue;let[s,o]=e.runner(["kubectl","kustomize",q.join(e.root,n)]);if(s===127)return e.skipped.push({item:"kustomize overlays",reason:"kubectl is not installed \u2014 overlays skipped"}),t;if(s!==0){e.skipped.push({item:i,reason:`kubectl kustomize failed: ${o.split(`
|
|
6
|
+
`)[0]}`});continue}try{t.push(...J([{file:`${i} (kubectl kustomize)`,dir:null,docs:K(o)}]))}catch(c){e.skipped.push({item:i,reason:`unparsable kustomize output: ${c instanceof Error?c.message:String(c)}`})}}return t}p(ze,"detectKustomize");$();import*as B from"node:path";var bt=["next","vite","react","expo"],xt=["express","fastify","@nestjs/core","koa"],wt=["sharp","better-sqlite3","esbuild","@swc/core"];function St(e,t,r,a){let i=a.map(s=>s==="test"?s:`run ${s}`),n=p(s=>i.map(s).join(" && "),"chain");return t==="."?n(s=>`${e.pm} ${s}`):r!==void 0?e.pm==="pnpm"?n(s=>`pnpm --filter ${r} ${s}`):e.pm==="yarn"?n(s=>`yarn workspace ${r} ${s}`):n(s=>`npm ${s} -w ${r}`):e.pm==="pnpm"?n(s=>`pnpm --filter ./${t} ${s}`):e.pm==="yarn"?`cd ${t} && ${n(s=>`yarn ${s}`)}`:n(s=>`npm ${s} -w ${t}`)}p(St,"testCommand");function jt(e,t,r,a){for(let i of[r.engines?.node,a?.engines?.node]){let n=/(\d+)/.exec(String(i??""));if(n)return n[1]}for(let i of[B.posix.join(t,".nvmrc"),".nvmrc"]){if(!e.files.includes(i))continue;let n=/(\d+)/.exec(S(e,i));if(n)return n[1]}return"22"}p(jt,"nodeMajor");function Ge(e,t){let r=se(e,"package.json"),a=t.packageDirs.length?t.packageDirs:r?["."]:[],i=[];for(let n of a){let s=n==="."?"package.json":`${n}/package.json`,o=se(e,s);if(!o)continue;let c=o.scripts??{},u={...o.dependencies,...o.devDependencies},m={},d=c.dev?"dev":c.start?"start":null;if(d){let h=`exec ${t.pm} run ${d}`;m.command=y(n==="."?h:`cd ${n} && ${h}`,`${s} \u2192 scripts.${d}`)}if(c.test){let h=c.typecheck?["typecheck","test"]:["test"];m.test=y(St(t,n,o.name,h),`${s} \u2192 ${h.map(b=>`scripts.${b}`).join(", ")}`)}let g=bt.find(h=>h in u),k=xt.find(h=>h in u),v=g?["web","node-web",`${s} \u2192 dependency ${g}`]:k?["api","node-service",`${s} \u2192 dependency ${k}`]:o.bin?["cli","node-tool",`${s} \u2192 bin`]:null;if(v)m.type=y(v[0],v[2]),m.archetype=y(v[1],v[2]);else{let h=`no web, api or bin marker in ${s} \u2014 assumed a service`;m.type=w("api",h),m.archetype=w("node-service",h)}let f=wt.find(h=>h in u);m.image=w(`node:${jt(e,n,o,r)}${f?"":"-alpine"}`,`no Dockerfile \u2014 Node major from engines/.nvmrc${f?`; glibc image because of ${f}`:""}`),t.setupName&&(m.setup_service=y(t.setupName,"shared workspace install"),m.node_modules_volume=y(t.setupFields.node_modules_volume.value,"shared workspace install")),i.push({kind:"package",name:n==="."?B.basename(e.root):B.posix.basename(n),dir:n,file:s,runnable:!!d,fields:m})}return i}p(Ge,"detectPackages");var Ot=[".env.example",".env.sample",".env.template"];function C(e,t,r,a){try{return a()}catch(i){return e.push({item:t,reason:`${t} failed: ${i instanceof Error?i.message:String(i)}`}),r}}p(C,"safely");function Et(e,t){let r=new Set,a=Ot.flatMap(i=>[T.posix.join(t,i),i]);for(let i of new Set(a))if(e.files.includes(i))for(let n of S(e,i).split(/\r?\n/)){let s=/^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(n);s&&r.add(s[1])}return[...r].sort()}p(Et,"envExampleKeys");function Hs(e,t){let r=T.resolve(e),a=T.basename(r),i=T.join(r,_e),n=X.existsSync(i)?X.readFileSync(i,"utf8"):null,s=n?(0,Je.parse)(n)??null:null,o={root:r,files:ve(r,t.runner),runner:t.runner,skipped:[]},c=Object.values(s?.services??{}).map(l=>l?.setup_service).find(l=>typeof l=="string")??null,u=Object.values(s?.services??{}).map(l=>l?.node_modules_volume).find(l=>typeof l=="string")??null,m={pm:"npm",packageDirs:[],setupName:null,setupFields:{}},d=C(o.skipped,"workspace detection",m,()=>ye(o,c,u)),g=[...C(o.skipped,"package.json detection",[],()=>Ge(o,d)),...C(o.skipped,"Dockerfile detection",[],()=>qe(o)),...C(o.skipped,"k8s manifest detection",[],()=>We(o)),...C(o.skipped,"Helm detection",[],()=>Le(o)),...C(o.skipped,"kustomize detection",[],()=>ze(o)),...C(o.skipped,"compose detection",[],()=>Re(o))],k=Ne(g,a),v=k.services.map(V),f=k.infrastructure.map(l=>Me(l,k.skipped)),h=p((l,_,O)=>Object.entries(s?.[l]??{}).find(([,A])=>A?.[_]===O)?.[0],"adopt"),b=new Map;for(let l of v){let _=h("services","path",l.dir);if(_&&_!==l.name){b.set(l.name,_),l.name=_;for(let O of l.conflicts)O.service=_}}let N=new Map(f.map(l=>[l.name,l.name]));for(let l of f){let _=h("infrastructure","k8s_pod_prefix",l.fields.k8s_pod_prefix.value);_&&_!==l.name&&(b.set(l.name,_),N.set(_,l.name),l.name=_)}let j=p((l,_)=>l.name.localeCompare(_.name),"byName");v.sort(j),f.sort(j);let I=new Set(v.map(l=>l.name)),x=p((l,_,O)=>s?.[l]?.[_]?.[O]!==void 0,"inFile"),Y=xe(t.reposRoot,i,t.localPath,s),Q=we(v.filter(l=>!x("services",l.name,"port_offset")).map(l=>l.name),Y.offsets,t.portsPerSlot);for(let l of v){let _=Q.get(l.name);_!==void 0&&(l.fields.port_offset=y(_,"lowest free offset across registered repos"))}let ee=Se(f.filter(l=>!x("infrastructure",l.name,"k8s_forward_port")).map(l=>l.name),Y.forwards);for(let l of f){let _=ee.get(l.name);_!==void 0&&(l.fields.k8s_forward_port=y(_,"lowest free forward port from 9050"))}let et=f.map(l=>({name:l.name,host:N.get(l.name),port:Number(s?.infrastructure?.[l.name]?.internal_port??l.fields.internal_port.value),forward:Number(s?.infrastructure?.[l.name]?.k8s_forward_port??l.fields.k8s_forward_port?.value)}));for(let l of v){let _=l.fields.environment;if(!_)continue;let{env:O,rewritten:A}=je(_.value,l.k8sEnvKeys,et);A.length&&(l.fields.environment=w(O,`${_.source}; ${A.join(", ")} rewritten from the in-cluster address to the werkmeister tunnel`))}for(let l of v){let _=l.fields.depends_on;if(!_)continue;let O=[...new Set(_.value.map(A=>b.get(A)??A))].filter(A=>I.has(A)&&A!==l.name).sort();O.length?l.fields.depends_on={..._,value:O}:delete l.fields.depends_on}let te=v.filter(l=>l.fields.setup_service),tt=d.setupName&&te.length?{name:d.setupName,fields:{image:{...te[0].fields.image,source:`same image as ${te[0].name}`},...d.setupFields}}:null,de={};for(let l of v){let _=new Set([...Object.keys(l.fields.environment?.value??{}),...l.fields.secrets?.value??[]]),O=Et(o,l.dir).filter(A=>!_.has(A));O.length&&(de[l.name]=O)}return{repo:a,root:r,fragmentPath:i,existing:n,services:v,infrastructure:f,setup:tt,envExample:de,unmatched:k.unmatched,skipped:[...o.skipped,...k.skipped]}}p(Hs,"planFragment");function Us(e){let t=p(r=>Object.fromEntries(Object.entries(r).map(([a,i])=>[a,{value:i.value,source:i.source,confidence:i.confidence}])),"fields");return{repo:e.repo,fragment:e.fragmentPath,existed:e.existing!==null,services:e.services.map(r=>({name:r.name,dir:r.dir,fields:t(r.fields),conflicts:r.conflicts.map(a=>({key:a.key,chosen:a.chosen,also:a.also}))})),infrastructure:e.infrastructure.map(r=>({name:r.name,fields:t(r.fields)})),setup:e.setup?{name:e.setup.name,fields:t(e.setup.fields)}:null,envExample:e.envExample,skipped:e.skipped}}p(Us,"planSummary");$();var D=M(F(),1);var At=["# Werkmeister service-registry fragment for this repo.","#","# `werkmeister registry sync` (run by `werkmeister machine setup`) merges every","# <repo>/.werkmeister/services.yaml under paths.repos_root into","# ~/.werkmeister/services.yaml. Only `services:`, `setup_services:` and","# `infrastructure:` may appear here; `repo:` is the checkout's directory name","# and `repos:` is derived. Generated by `werkmeister machine detect`; re-running it only","# adds what is missing, so edit freely.","",""].join(`
|
|
7
|
+
`),Nt=["path","type","archetype","test","internal_port","port_offset","health_endpoint","setup_service","image","command","memory_limit","memory_reservation","node_modules_volume","environment","secrets","k8s_deployment","k8s_namespace","k8s_port","k8s_port_name","k8s_pod_prefix","feature_router","depends_on"],Pt=["k8s_forward_port","internal_port","k8s_namespace","k8s_pod_prefix","health_endpoint"],Mt=["image","command","node_modules_volume"];function Dt(e){let t=[];e.note&&t.push(e.note),e.fv.confidence==="guessed"&&t.push(`guessed: ${e.fv.source}`),e.fv.confidence==="inferred"&&t.push(`inferred by Claude: ${e.fv.source}`);for(let r of e.also)t.push(`also: ${JSON.stringify(r.value)} (${r.source})`);return t.length?` # ${t.join("; ").replace(/\n/g," ")}`:""}p(Dt,"commentFor");function Ze(e,t){let r=(0,D.stringify)({[e.key]:e.fv.value},{lineWidth:0}).trimEnd().split(`
|
|
8
|
+
`);return r[0]+=Dt(e),r.map(a=>t+a).join(`
|
|
9
|
+
`)+`
|
|
10
|
+
`}p(Ze,"keyBlock");function Be(e,t,r){return`${r}${e}:
|
|
11
|
+
`+t.map(a=>Ze(a,`${r} `)).join("")}p(Be,"entryBlock");function He(e,t){let r=e.indexOf(`
|
|
12
|
+
`,Math.max(0,t-1));return r===-1?e.length:r+1}p(He,"endOfLine");function Ue(e){let t=e.items[e.items.length-1],r=t.value??t.key;return r.range?r.range[1]:0}p(Ue,"lastItemEnd");function Ve(e,t){let r=t.items[0].key.range?.[0]??0;return" ".repeat(r-(e.lastIndexOf(`
|
|
13
|
+
`,r-1)+1))}p(Ve,"indentOf");function It(e){let t=p((n,s,o=()=>({}))=>s.filter(c=>n[c]).map(c=>({key:c,fv:n[c],also:[],...o(c)})),"pick"),r=e.services.map(n=>[n.name,t(n.fields,Nt,s=>({also:n.conflicts.find(o=>o.key===s)?.also??[],note:s==="path"&&e.envExample[n.name]?`.env.example also lists: ${e.envExample[n.name].join(", ")} \u2014 declare required ones under secrets:`:void 0}))]),a=e.infrastructure.map(n=>[n.name,t(n.fields,Pt)]),i=e.setup?[[e.setup.name,t(e.setup.fields,Mt)]]:[];return[["services",r],["infrastructure",a],["setup_services",i]]}p(It,"sections");function Qs(e){let t=e.existing??"",r=(0,D.parseDocument)(t),a=(0,D.isMap)(r.contents)?r.contents:null,i=[],n=[],s=[],o=[],c=0;for(let[m,d]of It(e)){if(!d.length)continue;let g=a?.get(m,!0);if(!(0,D.isMap)(g)||g.flow||!g.items.length){if(g!==void 0){let v=d.map(([f])=>f).filter(f=>!((0,D.isMap)(g)&&g.has(f)));v.length&&o.push(`${m}: is empty, null or flow-styled in the existing file, so ${v.join(", ")} were not added \u2014 add them by hand`);continue}n.push(`${m}:
|
|
14
|
+
`+d.map(([v,f])=>Be(v,f," ")).join(""));for(let[v,f]of d)s.push(...f.map(h=>`${m}.${v}.${h.key}`));continue}let k=[];for(let[v,f]of d){let h=g.get(v,!0);if(h===void 0){k.push(Be(v,f,Ve(t,g))),s.push(...f.map(x=>`${m}.${v}.${x.key}`));continue}if(!(0,D.isMap)(h)||h.flow||!h.items.length)continue;let b=f.filter(x=>!h.has(x.key));if(!b.length)continue;let N=b.find(x=>x.key==="feature_router"),j=h.get("k8s_forward_port");N&&typeof j=="number"&&(N.fv={...N.fv,value:{remote_upstream:`k8s-${v}:${j}`}});let I=Ve(t,h);i.push({at:He(t,Ue(h)),seq:c++,text:b.map(x=>Ze(x,I)).join("")}),s.push(...b.map(x=>`${m}.${v}.${x.key}`))}k.length&&i.push({at:He(t,Ue(g)),seq:c++,text:k.join("")})}if(t&&!t.endsWith(`
|
|
15
|
+
`)){let m=i.filter(d=>d.at===t.length).sort((d,g)=>d.seq-g.seq)[0];m&&(m.text=`
|
|
16
|
+
`+m.text)}let u=t;for(let m of i.sort((d,g)=>g.at-d.at||g.seq-d.seq))u=u.slice(0,m.at)+m.text+u.slice(m.at);return n.length&&(u=(u===""?At:u.endsWith(`
|
|
17
|
+
|
|
18
|
+
`)?u:u.endsWith(`
|
|
19
|
+
`)?`${u}
|
|
20
|
+
`:`${u}
|
|
21
|
+
|
|
22
|
+
`)+n.join(`
|
|
23
|
+
`)),{path:e.fragmentPath,yaml:u,added:s,changed:u!==t,skipped:o}}p(Qs,"renderFragment");$();var le=M(st(),1),Qe=M(F(),1);import*as L from"node:fs";import*as Xe from"node:os";import*as W from"node:path";var Ft=le.default.default??le.default;function Tt(){return W.join(ge(),"infra","schemas","services-fragment.schema.json")}p(Tt,"defaultSchemaPath");function an(e,t,r,a=Tt()){let i;try{i=(0,Qe.parse)(e.yaml)??{}}catch(o){return[`generated YAML does not parse: ${o instanceof Error?o.message:String(o)}`]}let n=new Ft({allErrors:!0,strict:!1}).compile(JSON.parse(L.readFileSync(a,"utf8"))),s=n(i)?[]:(n.errors??[]).map(o=>`${o.instancePath||"/"} ${o.message??"is invalid"}`);try{let o=H(r).filter(c=>W.resolve(c.path)!==W.resolve(t.fragmentPath));be([...o,{repo:t.repo,path:t.fragmentPath,doc:i}],{defaults:{},local:{},paths:{home:Xe.homedir(),repos_root:r,workspaces_root:r,werkmeister_home:ue(),local_domain:ke().local_domain}})}catch(o){if(!(o instanceof $e))throw o;s.push(o.message)}return s}p(an,"validateFragment");function cn(e){L.mkdirSync(W.dirname(e.path),{recursive:!0}),L.writeFileSync(e.path,e.yaml)}p(cn,"writeFragment");$();export{re as a,Ct as b,Xt as c,it as d,Qt as e,es as f,Hs as g,Us as h,Qs as i,an as j,cn as k};
|
|
24
|
+
//# sourceMappingURL=chunk-AEDQ3BHS.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createRequire as __sandboxCreateRequire } from "node:module";
|
|
2
|
+
const require = __sandboxCreateRequire(import.meta.url);
|
|
3
|
+
import{a as wt}from"./chunk-XS5OH4RT.js";import{a as lx}from"./chunk-X7GPCYQ7.js";import{P as fx}from"./chunk-RJQTC65O.js";import{j as h0,l as p0}from"./chunk-OC7PYYEG.js";import{a as s,b as Q0,c as G,e as v0,f as c}from"./chunk-K6GRVJQO.js";var _x=G((en,Sx)=>{"use strict";c();Sx.exports=Ot;function Ut(x){let e={defaultWidth:0,output:process.stdout,tty:Q0("tty")};return x?(Object.keys(e).forEach(function(t){x[t]||(x[t]=e[t])}),x):e}s(Ut,"normalizeOpts");function Ot(x){let e=Ut(x);if(e.output.getWindowSize)return e.output.getWindowSize()[0]||e.defaultWidth;if(e.tty.getWindowSize)return e.tty.getWindowSize()[1]||e.defaultWidth;if(e.output.columns)return e.output.columns;if(process.env.CLI_WIDTH){let t=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(t)&&t!==0)return t}return e.defaultWidth}s(Ot,"cliWidth")});var $x=G((Tn,jx)=>{c();var Qt=Q0("stream"),ne=class extends Qt{static{s(this,"MuteStream")}#t=null;constructor(e={}){super(e),this.writable=this.readable=!0,this.muted=!1,this.on("pipe",this._onpipe),this.replace=e.replace,this._prompt=e.prompt||null,this._hadControl=!1}#x(e,t){return this._dest?this._dest[e]:this._src?this._src[e]:t}#e(e,...t){typeof this._dest?.[e]=="function"&&this._dest[e](...t),typeof this._src?.[e]=="function"&&this._src[e](...t)}get isTTY(){return this.#t!==null?this.#t:this.#x("isTTY",!1)}set isTTY(e){this.#t=e}get rows(){return this.#x("rows")}get columns(){return this.#x("columns")}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(e){this._src=e}pipe(e,t){return this._dest=e,super.pipe(e,t)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(e){if(this.muted){if(!this.replace)return!0;if(e.match(/^\u001b/))return e.indexOf(this._prompt)===0&&(e=e.slice(this._prompt.length),e=e.replace(/./g,this.replace),e=this._prompt+e),this._hadControl=!0,this.emit("data",e);this._prompt&&this._hadControl&&e.indexOf(this._prompt)===0&&(this._hadControl=!1,this.emit("data",this._prompt),e=e.slice(this._prompt.length)),e=e.toString().replace(/./g,this.replace)}this.emit("data",e)}end(e){this.muted&&(e&&this.replace?e=e.toString().replace(/./g,this.replace):e=null),e&&this.emit("data",e),this.emit("end")}destroy(...e){return this.#e("destroy",...e)}destroySoon(...e){return this.#e("destroySoon",...e)}close(...e){return this.#e("close",...e)}};jx.exports=ne});var zx=G((ye,we)=>{"use strict";c();Object.defineProperty(ye,"__esModule",{value:!0});var N0;ye.default=()=>{if(typeof we=="object"&&typeof we.exports=="object")return N0=N0||Q0("fs"),N0;throw new Error("File system is not available")}});var d0=G(Se=>{"use strict";c();Object.defineProperty(Se,"__esModule",{value:!0});Se.default=(x,e,t)=>({confidence:t,name:e.name(x),lang:e.language?e.language():void 0})});var Jx=G(I0=>{"use strict";c();var f2=I0&&I0.__importDefault||function(x){return x&&x.__esModule?x:{default:x}};Object.defineProperty(I0,"__esModule",{value:!0});var Yx=f2(d0()),_e=class{static{s(this,"Ascii")}name(){return"ASCII"}match(e){let t=e.rawInput;for(let r=0;r<e.rawLen;r++){let n=t[r];if(n<32||n>126)return(0,Yx.default)(e,this,0)}return(0,Yx.default)(e,this,100)}};I0.default=_e});var Qx=G(L0=>{"use strict";c();var l2=L0&&L0.__importDefault||function(x){return x&&x.__esModule?x:{default:x}};Object.defineProperty(L0,"__esModule",{value:!0});var d2=l2(d0()),Ee=class{static{s(this,"Utf8")}name(){return"UTF-8"}match(e){let t=!1,r=0,n=0,i=0,a,o=e.rawInput;e.rawLen>=3&&(o[0]&255)==239&&(o[1]&255)==187&&(o[2]&255)==191&&(t=!0);for(let f=0;f<e.rawLen;f++){let l=o[f];if(l&128){if((l&224)==192)i=1;else if((l&240)==224)i=2;else if((l&248)==240)i=3;else{if(n++,n>5)break;i=0}for(;f++,!(f>=e.rawLen);){if((o[f]&192)!=128){n++;break}if(--i==0){r++;break}}}}if(a=0,t&&n==0)a=100;else if(t&&r>n*10)a=80;else if(r>3&&n==0)a=100;else if(r>0&&n==0)a=80;else if(r==0&&n==0)a=10;else if(r>n*10)a=25;else return null;return(0,d2.default)(e,this,a)}};L0.default=Ee});var Zx=G(H=>{"use strict";c();var u2=H&&H.__importDefault||function(x){return x&&x.__esModule?x:{default:x}};Object.defineProperty(H,"__esModule",{value:!0});H.UTF_32LE=H.UTF_32BE=H.UTF_16LE=H.UTF_16BE=void 0;var Re=u2(d0()),De=class{static{s(this,"UTF_16BE")}name(){return"UTF-16BE"}match(e){let t=e.rawInput;return t.length>=2&&(t[0]&255)==254&&(t[1]&255)==255?(0,Re.default)(e,this,100):null}};H.UTF_16BE=De;var Be=class{static{s(this,"UTF_16LE")}name(){return"UTF-16LE"}match(e){let t=e.rawInput;return t.length>=2&&(t[0]&255)==255&&(t[1]&255)==254?t.length>=4&&t[2]==0&&t[3]==0?null:(0,Re.default)(e,this,100):null}};H.UTF_16LE=Be;var K0=class{static{s(this,"UTF_32")}name(){return"UTF-32"}getChar(e,t){return-1}match(e){let t=0,r=0,n=!1,i=0,a=e.rawLen/4*4,o=e.rawInput;if(a==0)return null;this.getChar(o,0)==65279&&(n=!0);for(let f=0;f<a;f+=4){let l=this.getChar(o,f);l<0||l>=1114111||l>=55296&&l<=57343?r+=1:t+=1}return n&&r==0?i=100:n&&t>r*10?i=80:t>3&&r==0?i=100:t>0&&r==0?i=80:t>r*10&&(i=25),i==0?null:(0,Re.default)(e,this,i)}},Ie=class extends K0{static{s(this,"UTF_32BE")}name(){return"UTF-32BE"}getChar(e,t){return(e[t+0]&255)<<24|(e[t+1]&255)<<16|(e[t+2]&255)<<8|e[t+3]&255}};H.UTF_32BE=Ie;var Le=class extends K0{static{s(this,"UTF_32LE")}name(){return"UTF-32LE"}getChar(e,t){return(e[t+3]&255)<<24|(e[t+2]&255)<<16|(e[t+1]&255)<<8|e[t+0]&255}};H.UTF_32LE=Le});var et=G($=>{"use strict";c();var h2=$&&$.__importDefault||function(x){return x&&x.__esModule?x:{default:x}};Object.defineProperty($,"__esModule",{value:!0});$.gb_18030=$.euc_kr=$.euc_jp=$.big5=$.sjis=void 0;var p2=h2(d0());function b2(x,e){let t=s((r,n,i,a)=>{if(a<i)return-1;let o=Math.floor(i+a>>>1);return n>r[o]?t(r,n,o+1,a):n<r[o]?t(r,n,i,o-1):o},"find");return t(x,e,0,x.length-1)}s(b2,"binarySearch");var Te=class{static{s(this,"IteratedChar")}constructor(){this.charValue=0,this.index=0,this.nextIndex=0,this.error=!1,this.done=!1}reset(){this.charValue=0,this.index=-1,this.nextIndex=0,this.error=!1,this.done=!1}nextByte(e){return this.nextIndex>=e.rawLen?(this.done=!0,-1):e.rawInput[this.nextIndex++]&255}},u0=class{static{s(this,"mbcs")}constructor(){this.commonChars=[]}name(){return"mbcs"}match(e){let t=0,r=0,n=0,i=0,a=0,o=new Te;e:{for(o.reset();this.nextChar(o,e);){if(i++,o.error)n++;else{let f=o.charValue&4294967295;f>255&&(t++,this.commonChars!=null&&b2(this.commonChars,f)>=0&&r++)}if(n>=2&&n*5>=t)break e}if(t<=10&&n==0){t==0&&i<10?a=0:a=10;break e}if(t<20*n){a=0;break e}if(this.commonChars==null)a=30+t-20*n,a>100&&(a=100);else{let l=90/Math.log(t/4);a=Math.floor(Math.log(r+1)*l+10),a=Math.min(a,100)}}return a==0?null:(0,p2.default)(e,this,a)}nextChar(e,t){return!0}},Fe=class extends u0{static{s(this,"sjis")}constructor(){super(...arguments),this.commonChars=[33088,33089,33090,33093,33115,33129,33130,33141,33142,33440,33442,33444,33449,33450,33451,33453,33455,33457,33459,33461,33463,33469,33470,33473,33476,33477,33478,33480,33481,33484,33485,33500,33504,33511,33512,33513,33514,33520,33521,33601,33603,33614,33615,33624,33630,33634,33639,33653,33654,33673,33674,33675,33677,33683,36502,37882,38314]}name(){return"Shift_JIS"}language(){return"ja"}nextChar(e,t){e.index=e.nextIndex,e.error=!1;let r=e.charValue=e.nextByte(t);if(r<0)return!1;if(r<=127||r>160&&r<=223)return!0;let n=e.nextByte(t);return n<0?!1:(e.charValue=r<<8|n,n>=64&&n<=127||n>=128&&n<=255||(e.error=!0),!0)}};$.sjis=Fe;var ve=class extends u0{static{s(this,"big5")}constructor(){super(...arguments),this.commonChars=[41280,41281,41282,41283,41287,41289,41333,41334,42048,42054,42055,42056,42065,42068,42071,42084,42090,42092,42103,42147,42148,42151,42177,42190,42193,42207,42216,42237,42304,42312,42328,42345,42445,42471,42583,42593,42594,42600,42608,42664,42675,42681,42707,42715,42726,42738,42816,42833,42841,42970,43171,43173,43181,43217,43219,43236,43260,43456,43474,43507,43627,43706,43710,43724,43772,44103,44111,44208,44242,44377,44745,45024,45290,45423,45747,45764,45935,46156,46158,46412,46501,46525,46544,46552,46705,47085,47207,47428,47832,47940,48033,48593,49860,50105,50240,50271]}name(){return"Big5"}language(){return"zh"}nextChar(e,t){e.index=e.nextIndex,e.error=!1;let r=e.charValue=e.nextByte(t);if(r<0)return!1;if(r<=127||r==255)return!0;let n=e.nextByte(t);return n<0?!1:(e.charValue=e.charValue<<8|n,(n<64||n==127||n==255)&&(e.error=!0),!0)}};$.big5=ve;function Xx(x,e){x.index=x.nextIndex,x.error=!1;let t=0,r=0,n=0;e:{if(t=x.charValue=x.nextByte(e),t<0){x.done=!0;break e}if(t<=141)break e;if(r=x.nextByte(e),x.charValue=x.charValue<<8|r,t>=161&&t<=254){r<161&&(x.error=!0);break e}if(t==142){r<161&&(x.error=!0);break e}t==143&&(n=x.nextByte(e),x.charValue=x.charValue<<8|n,n<161&&(x.error=!0))}return x.done==!1}s(Xx,"eucNextChar");var Ce=class extends u0{static{s(this,"euc_jp")}constructor(){super(...arguments),this.commonChars=[41377,41378,41379,41382,41404,41418,41419,41430,41431,42146,42148,42150,42152,42154,42155,42156,42157,42159,42161,42163,42165,42167,42169,42171,42173,42175,42176,42177,42179,42180,42182,42183,42184,42185,42186,42187,42190,42191,42192,42206,42207,42209,42210,42212,42216,42217,42218,42219,42220,42223,42226,42227,42402,42403,42404,42406,42407,42410,42413,42415,42416,42419,42421,42423,42424,42425,42431,42435,42438,42439,42440,42441,42443,42448,42453,42454,42455,42462,42464,42465,42469,42473,42474,42475,42476,42477,42483,47273,47572,47854,48072,48880,49079,50410,50940,51133,51896,51955,52188,52689],this.nextChar=Xx}name(){return"EUC-JP"}language(){return"ja"}};$.euc_jp=Ce;var Pe=class extends u0{static{s(this,"euc_kr")}constructor(){super(...arguments),this.commonChars=[45217,45235,45253,45261,45268,45286,45293,45304,45306,45308,45496,45497,45511,45527,45538,45994,46011,46274,46287,46297,46315,46501,46517,46527,46535,46569,46835,47023,47042,47054,47270,47278,47286,47288,47291,47337,47531,47534,47564,47566,47613,47800,47822,47824,47857,48103,48115,48125,48301,48314,48338,48374,48570,48576,48579,48581,48838,48840,48863,48878,48888,48890,49057,49065,49088,49124,49131,49132,49144,49319,49327,49336,49338,49339,49341,49351,49356,49358,49359,49366,49370,49381,49403,49404,49572,49574,49590,49622,49631,49654,49656,50337,50637,50862,51151,51153,51154,51160,51173,51373],this.nextChar=Xx}name(){return"EUC-KR"}language(){return"ko"}};$.euc_kr=Pe;var ke=class extends u0{static{s(this,"gb_18030")}constructor(){super(...arguments),this.commonChars=[41377,41378,41379,41380,41392,41393,41457,41459,41889,41900,41914,45480,45496,45502,45755,46025,46070,46323,46525,46532,46563,46767,46804,46816,47010,47016,47037,47062,47069,47284,47327,47350,47531,47561,47576,47610,47613,47821,48039,48086,48097,48122,48316,48347,48382,48588,48845,48861,49076,49094,49097,49332,49389,49611,49883,50119,50396,50410,50636,50935,51192,51371,51403,51413,51431,51663,51706,51889,51893,51911,51920,51926,51957,51965,52460,52728,52906,52932,52946,52965,53173,53186,53206,53442,53445,53456,53460,53671,53930,53938,53941,53947,53972,54211,54224,54269,54466,54490,54754,54992]}name(){return"GB18030"}language(){return"zh"}nextChar(e,t){e.index=e.nextIndex,e.error=!1;let r=0,n=0,i=0,a=0;e:{if(r=e.charValue=e.nextByte(t),r<0){e.done=!0;break e}if(r<=128)break e;if(n=e.nextByte(t),e.charValue=e.charValue<<8|n,r>=129&&r<=254){if(n>=64&&n<=126||n>=80&&n<=254)break e;if(n>=48&&n<=57&&(i=e.nextByte(t),i>=129&&i<=254&&(a=e.nextByte(t),a>=48&&a<=57))){e.charValue=e.charValue<<16|i<<8|a;break e}e.error=!0;break e}}return e.done==!1}};$.gb_18030=ke});var tt=G(L=>{"use strict";c();var m2=L&&L.__importDefault||function(x){return x&&x.__esModule?x:{default:x}};Object.defineProperty(L,"__esModule",{value:!0});L.KOI8_R=L.windows_874=L.windows_1258=L.windows_1257=L.windows_1256=L.windows_1251=L.ISO_8859_9=L.ISO_8859_8=L.ISO_8859_7=L.ISO_8859_6=L.ISO_8859_5=L.ISO_8859_2=L.ISO_8859_1=void 0;var xt=m2(d0()),g2=16777215,W0=class{static{s(this,"NGramParser")}constructor(e,t){this.byteIndex=0,this.ngram=0,this.ngramCount=0,this.hitCount=0,this.spaceChar=32,this.ngramList=e,this.byteMap=t}search(e,t){let r=0;return e[r+32]<=t&&(r+=32),e[r+16]<=t&&(r+=16),e[r+8]<=t&&(r+=8),e[r+4]<=t&&(r+=4),e[r+2]<=t&&(r+=2),e[r+1]<=t&&(r+=1),e[r]>t&&(r-=1),r<0||e[r]!=t?-1:r}lookup(e){this.ngramCount+=1,this.search(this.ngramList,e)>=0&&(this.hitCount+=1)}addByte(e){this.ngram=(this.ngram<<8)+(e&255)&g2,this.lookup(this.ngram)}nextByte(e){return this.byteIndex>=e.inputLen?-1:e.inputBytes[this.byteIndex++]&255}parse(e,t){let r,n=!1;for(this.spaceChar=t;(r=this.nextByte(e))>=0;){let a=this.byteMap[r];a!=0&&(a==this.spaceChar&&n||this.addByte(a),n=a==this.spaceChar)}this.addByte(this.spaceChar);let i=this.hitCount/this.ngramCount;return i>.33?98:Math.floor(i*300)}},C=class{static{s(this,"NGramsPlusLang")}constructor(e,t){this.fLang=e,this.fNGrams=t}},w2=s(x=>Array.isArray(x)&&isFinite(x[0]),"isFlatNgrams"),M=class{static{s(this,"sbcs")}constructor(){this.spaceChar=32,this.nGramLang=void 0}ngrams(){return[]}byteMap(){return[]}name(e){return"sbcs"}language(){return this.nGramLang}match(e){this.nGramLang=void 0;let t=this.ngrams();if(w2(t)){let i=new W0(t,this.byteMap()).parse(e,this.spaceChar);return i<=0?null:(0,xt.default)(e,this,i)}let r=-1;for(let n=t.length-1;n>=0;n--){let i=t[n],o=new W0(i.fNGrams,this.byteMap()).parse(e,this.spaceChar);o>r&&(r=o,this.nGramLang=i.fLang)}return r<=0?null:(0,xt.default)(e,this,r)}},Ue=class extends M{static{s(this,"ISO_8859_1")}byteMap(){return[32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,0,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,32,32,32,32,32,32,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,170,32,32,32,32,32,32,32,32,32,32,181,32,32,32,32,186,32,32,32,32,32,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,32,248,249,250,251,252,253,254,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,32,248,249,250,251,252,253,254,255]}ngrams(){return[new C("da",[2122086,2122100,2122853,2123118,2123122,2123375,2123873,2124064,2125157,2125671,2126053,2126697,2126708,2126953,2127465,6383136,6385184,6385252,6386208,6386720,6579488,6579566,6579570,6579572,6627443,6644768,6644837,6647328,6647396,6648352,6648421,6648608,6648864,6713202,6776096,6776174,6776178,6907749,6908960,6909543,7038240,7039845,7103858,7104871,7105637,7169380,7234661,7234848,7235360,7235429,7300896,7302432,7303712,7398688,7479396,7479397,7479411,7496992,7566437,7610483,7628064,7628146,7629164,7759218]),new C("de",[2122094,2122101,2122341,2122849,2122853,2122857,2123113,2123621,2123873,2124142,2125161,2126691,2126693,2127214,2127461,2127471,2127717,2128501,6448498,6514720,6514789,6514804,6578547,6579566,6579570,6580581,6627428,6627443,6646126,6646132,6647328,6648352,6648608,6776174,6841710,6845472,6906728,6907168,6909472,6909541,6911008,7104867,7105637,7217249,7217252,7217267,7234592,7234661,7234848,7235360,7235429,7238757,7479396,7496805,7497065,7562088,7566437,7610468,7628064,7628142,7628146,7695972,7695975,7759218]),new C("en",[2122016,2122094,2122341,2122607,2123375,2123873,2123877,2124142,2125153,2125670,2125938,2126437,2126689,2126708,2126952,2126959,2127720,6383972,6384672,6385184,6385252,6386464,6386720,6386789,6386793,6561889,6561908,6627425,6627443,6627444,6644768,6647412,6648352,6648608,6713202,6840692,6841632,6841714,6906912,6909472,6909543,6909806,6910752,7217249,7217268,7234592,7235360,7238688,7300640,7302688,7303712,7496992,7500576,7544929,7544948,7561577,7566368,7610484,7628146,7628897,7628901,7629167,7630624,7631648]),new C("es",[2122016,2122593,2122607,2122853,2123116,2123118,2123123,2124142,2124897,2124911,2125921,2125935,2125938,2126197,2126437,2126693,2127214,2128160,6365283,6365284,6365285,6365292,6365296,6382441,6382703,6384672,6386208,6386464,6515187,6516590,6579488,6579564,6582048,6627428,6627429,6627436,6646816,6647328,6647412,6648608,6648692,6907246,6943598,7102752,7106419,7217253,7238757,7282788,7282789,7302688,7303712,7303968,7364978,7435621,7495968,7497075,7544932,7544933,7544944,7562528,7628064,7630624,7693600,15953440]),new C("fr",[2122101,2122607,2122849,2122853,2122869,2123118,2123124,2124897,2124901,2125921,2125935,2125938,2126197,2126693,2126703,2127214,2154528,6385268,6386793,6513952,6516590,6579488,6579571,6583584,6627425,6627427,6627428,6627429,6627436,6627440,6627443,6647328,6647412,6648352,6648608,6648864,6649202,6909806,6910752,6911008,7102752,7103776,7103859,7169390,7217252,7234848,7238432,7238688,7302688,7302772,7304562,7435621,7479404,7496992,7544929,7544932,7544933,7544940,7544944,7610468,7628064,7629167,7693600,7696928]),new C("it",[2122092,2122600,2122607,2122853,2122857,2123040,2124140,2124142,2124897,2125925,2125938,2127214,6365283,6365284,6365296,6365299,6386799,6514789,6516590,6579564,6580512,6627425,6627427,6627428,6627433,6627436,6627440,6627443,6646816,6646892,6647412,6648352,6841632,6889569,6889571,6889572,6889587,6906144,6908960,6909472,6909806,7102752,7103776,7104800,7105633,7234848,7235872,7237408,7238757,7282785,7282788,7282793,7282803,7302688,7302757,7366002,7495968,7496992,7563552,7627040,7628064,7629088,7630624,8022383]),new C("nl",[2122092,2122341,2122849,2122853,2122857,2123109,2123118,2123621,2123877,2124142,2125153,2125157,2125680,2126949,2127457,2127461,2127471,2127717,2128489,6381934,6381938,6385184,6385252,6386208,6386720,6514804,6579488,6579566,6579570,6627426,6627446,6645102,6645106,6647328,6648352,6648435,6648864,6776174,6841716,6907168,6909472,6909543,6910752,7217250,7217252,7217253,7217256,7217263,7217270,7234661,7235360,7302756,7303026,7303200,7303712,7562088,7566437,7610468,7628064,7628142,7628146,7758190,7759218,7761775]),new C("no",[2122100,2122102,2122853,2123118,2123122,2123375,2123873,2124064,2125157,2125671,2126053,2126693,2126699,2126703,2126708,2126953,2127465,2155808,6385252,6386208,6386720,6579488,6579566,6579572,6627443,6644768,6647328,6647397,6648352,6648421,6648864,6648948,6713202,6776174,6908779,6908960,6909543,7038240,7039845,7103776,7105637,7169380,7169390,7217267,7234848,7235360,7235429,7237221,7300896,7302432,7303712,7398688,7479411,7496992,7565165,7566437,7610483,7628064,7628142,7628146,7629164,7631904,7631973,7759218]),new C("pt",[2122016,2122607,2122849,2122853,2122863,2123040,2123123,2125153,2125423,2125600,2125921,2125935,2125938,2126197,2126437,2126693,2127213,6365281,6365283,6365284,6365296,6382693,6382703,6384672,6386208,6386273,6386464,6516589,6516590,6578464,6579488,6582048,6582131,6627425,6627428,6647072,6647412,6648608,6648692,6906144,6906721,7169390,7238757,7238767,7282785,7282787,7282788,7282789,7282800,7303968,7364978,7435621,7495968,7497075,7544929,7544932,7544933,7544944,7566433,7628064,7630624,7693600,14905120,15197039]),new C("sv",[2122100,2122102,2122853,2123118,2123510,2123873,2124064,2124142,2124655,2125157,2125667,2126053,2126699,2126703,2126708,2126953,2127457,2127465,2155634,6382693,6385184,6385252,6386208,6386804,6514720,6579488,6579566,6579570,6579572,6644768,6647328,6648352,6648864,6747762,6776174,6909036,6909543,7037216,7105568,7169380,7217267,7233824,7234661,7235360,7235429,7235950,7299944,7302432,7302688,7398688,7479393,7479411,7495968,7564129,7565165,7610483,7627040,7628064,7628146,7629164,7631904,7758194,14971424,16151072])]}name(e){return e&&e.c1Bytes?"windows-1252":"ISO-8859-1"}};L.ISO_8859_1=Ue;var Oe=class extends M{static{s(this,"ISO_8859_2")}byteMap(){return[32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,0,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,32,32,32,32,32,32,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,177,32,179,32,181,182,32,32,185,186,187,188,32,190,191,32,177,32,179,32,181,182,183,32,185,186,187,188,32,190,191,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,32,248,249,250,251,252,253,254,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,32,248,249,250,251,252,253,254,32]}ngrams(){return[new C("cs",[2122016,2122361,2122863,2124389,2125409,2125413,2125600,2125668,2125935,2125938,2126072,2126447,2126693,2126703,2126708,2126959,2127392,2127481,2128481,6365296,6513952,6514720,6627440,6627443,6627446,6647072,6647533,6844192,6844260,6910836,6972704,7042149,7103776,7104800,7233824,7268640,7269408,7269664,7282800,7300206,7301737,7304052,7304480,7304801,7368548,7368554,7369327,7403621,7562528,7565173,7566433,7566441,7566446,7628146,7630573,7630624,7676016,12477728,14773997,15296623,15540336,15540339,15559968,16278884]),new C("hu",[2122016,2122106,2122341,2123111,2123116,2123365,2123873,2123887,2124147,2124645,2124649,2124790,2124901,2125153,2125157,2125161,2125413,2126714,2126949,2156915,6365281,6365291,6365293,6365299,6384416,6385184,6388256,6447470,6448494,6645625,6646560,6646816,6646885,6647072,6647328,6648421,6648864,6648933,6648948,6781216,6844263,6909556,6910752,7020641,7075450,7169383,7170414,7217249,7233899,7234923,7234925,7238688,7300985,7544929,7567973,7567988,7568097,7596391,7610465,7631904,7659891,8021362,14773792,15299360]),new C("pl",[2122618,2122863,2124064,2124389,2124655,2125153,2125161,2125409,2125417,2125668,2125935,2125938,2126697,2127648,2127721,2127737,2128416,2128481,6365296,6365303,6385257,6514720,6519397,6519417,6582048,6584937,6627440,6627443,6627447,6627450,6645615,6646304,6647072,6647401,6778656,6906144,6907168,6907242,7037216,7039264,7039333,7170405,7233824,7235937,7235941,7282800,7305057,7305065,7368556,7369313,7369327,7369338,7502437,7502457,7563754,7564137,7566433,7825765,7955304,7957792,8021280,8022373,8026400,15955744]),new C("ro",[2122016,2122083,2122593,2122597,2122607,2122613,2122853,2122857,2124897,2125153,2125925,2125938,2126693,2126819,2127214,2144873,2158190,6365283,6365284,6386277,6386720,6386789,6386976,6513010,6516590,6518048,6546208,6579488,6627425,6627427,6627428,6627440,6627443,6644e3,6646048,6646885,6647412,6648692,6889569,6889571,6889572,6889584,6907168,6908192,6909472,7102752,7103776,7106418,7107945,7234848,7238770,7303712,7365998,7496992,7497057,7501088,7594784,7628064,7631477,7660320,7694624,7695392,12216608,15625760])]}name(e){return e&&e.c1Bytes?"windows-1250":"ISO-8859-2"}};L.ISO_8859_2=Oe;var Me=class extends M{static{s(this,"ISO_8859_5")}byteMap(){return[32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,0,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,32,32,32,32,32,32,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,241,242,243,244,245,246,247,248,249,250,251,252,32,254,255,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,32,241,242,243,244,245,246,247,248,249,250,251,252,32,254,255]}ngrams(){return[2150944,2151134,2151646,2152400,2152480,2153168,2153182,2153936,2153941,2154193,2154462,2154464,2154704,2154974,2154978,2155230,2156514,2158050,13688280,13689580,13884960,14015468,14015960,14016994,14017056,14164191,14210336,14211104,14216992,14407133,14407712,14413021,14536736,14538016,14538965,14538991,14540320,14540498,14557394,14557407,14557409,14602784,14602960,14603230,14604576,14605292,14605344,14606818,14671579,14672085,14672088,14672094,14733522,14734804,14803664,14803666,14803672,14806816,14865883,14868e3,14868192,14871584,15196894,15459616]}name(){return"ISO-8859-5"}language(){return"ru"}};L.ISO_8859_5=Me;var Ae=class extends M{static{s(this,"ISO_8859_6")}byteMap(){return[32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,0,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,32,32,32,32,32,32,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,32,32,32,32,32,224,225,226,227,228,229,230,231,232,233,234,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32]}ngrams(){return[2148324,2148326,2148551,2152932,2154986,2155748,2156006,2156743,13050055,13091104,13093408,13095200,13100064,13100227,13100231,13100232,13100234,13100236,13100237,13100239,13100243,13100249,13100258,13100261,13100264,13100266,13100320,13100576,13100746,13115591,13181127,13181153,13181156,13181157,13181160,13246663,13574343,13617440,13705415,13748512,13836487,14229703,14279913,14805536,14950599,14993696,15001888,15002144,15016135,15058720,15059232,15066656,15081671,15147207,15189792,15255524,15263264,15278279,15343815,15343845,15343848,15386912,15388960,15394336]}name(){return"ISO-8859-6"}language(){return"ar"}};L.ISO_8859_6=Ae;var je=class extends M{static{s(this,"ISO_8859_7")}byteMap(){return[32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,0,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,32,32,32,32,32,32,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,161,162,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,220,32,221,222,223,32,252,32,253,254,192,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,32,243,244,245,246,247,248,249,250,251,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,32]}ngrams(){return[2154989,2154992,2155497,2155753,2156016,2156320,2157281,2157797,2158049,2158368,2158817,2158831,2158833,2159604,2159605,2159847,2159855,14672160,14754017,14754036,14805280,14806304,14807292,14807584,14936545,15067424,15069728,15147252,15199520,15200800,15278324,15327520,15330014,15331872,15393257,15393268,15525152,15540449,15540453,15540464,15589664,15725088,15725856,15790069,15790575,15793184,15868129,15868133,15868138,15868144,15868148,15983904,15984416,15987951,16048416,16048617,16050157,16050162,16050666,16052e3,16052213,16054765,16379168,16706848]}name(e){return e&&e.c1Bytes?"windows-1253":"ISO-8859-7"}language(){return"el"}};L.ISO_8859_7=je;var $e=class extends M{static{s(this,"ISO_8859_8")}byteMap(){return[32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,0,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,32,32,32,32,32,32,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,181,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,32,32,32,32,32]}ngrams(){return[new C("he",[2154725,2154727,2154729,2154746,2154985,2154990,2155744,2155749,2155753,2155758,2155762,2155769,2155770,2157792,2157796,2158304,2159340,2161132,14744096,14950624,14950625,14950628,14950636,14950638,14950649,15001056,15065120,15068448,15068960,15071264,15071776,15278308,15328288,15328762,15329773,15330592,15331104,15333408,15333920,15474912,15474916,15523872,15524896,15540448,15540449,15540452,15540460,15540462,15540473,15655968,15671524,15787040,15788320,15788525,15920160,16261348,16312813,16378912,16392416,16392417,16392420,16392428,16392430,16392441]),new C("he",[2154725,2154732,2155753,2155756,2155758,2155760,2157040,2157810,2157817,2158053,2158057,2158565,2158569,2160869,2160873,2161376,2161381,2161385,14688484,14688492,14688493,14688506,14738464,14738916,14740512,14741024,14754020,14754029,14754042,14950628,14950633,14950636,14950637,14950639,14950648,14950650,15002656,15065120,15066144,15196192,15327264,15327520,15328288,15474916,15474925,15474938,15528480,15530272,15591913,15591920,15591928,15605988,15605997,15606010,15655200,15655968,15918112,16326884,16326893,16326906,16376864,16441376,16442400,16442857])]}name(e){return e&&e.c1Bytes?"windows-1255":"ISO-8859-8"}language(){return"he"}};L.ISO_8859_8=$e;var Ne=class extends M{static{s(this,"ISO_8859_9")}byteMap(){return[32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,0,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,32,32,32,32,32,32,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,170,32,32,32,32,32,32,32,32,32,32,181,32,32,32,32,186,32,32,32,32,32,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,32,248,249,250,251,252,105,254,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,32,248,249,250,251,252,253,254,255]}ngrams(){return[2122337,2122345,2122357,2122849,2122853,2123621,2123873,2124140,2124641,2124655,2125153,2125676,2126689,2126945,2127461,2128225,6365282,6384416,6384737,6384993,6385184,6385405,6386208,6386273,6386429,6386685,6388065,6449522,6578464,6579488,6580512,6627426,6627435,6644841,6647328,6648352,6648425,6648681,6909029,6909472,6909545,6910496,7102830,7102834,7103776,7103858,7217249,7217250,7217259,7234657,7234661,7234848,7235872,7235950,7273760,7498094,7535982,7759136,7954720,7958386,16608800,16608868,16609021,16642301]}name(e){return e&&e.c1Bytes?"windows-1254":"ISO-8859-9"}language(){return"tr"}};L.ISO_8859_9=Ne;var Ke=class extends M{static{s(this,"windows_1251")}byteMap(){return[32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,0,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,32,32,32,32,32,32,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,32,32,32,32,32,144,131,32,131,32,32,32,32,32,32,154,32,156,157,158,159,144,32,32,32,32,32,32,32,32,32,154,32,156,157,158,159,32,162,162,188,32,180,32,32,184,32,186,32,32,32,32,191,32,32,179,179,180,181,32,32,184,32,186,32,188,190,190,191,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255]}ngrams(){return[2155040,2155246,2155758,2156512,2156576,2157280,2157294,2158048,2158053,2158305,2158574,2158576,2158816,2159086,2159090,2159342,2160626,2162162,14740968,14742268,14937632,15068156,15068648,15069682,15069728,15212783,15263008,15263776,15269664,15459821,15460384,15465709,15589408,15590688,15591653,15591679,15592992,15593186,15605986,15605999,15606001,15655456,15655648,15655918,15657248,15657980,15658016,15659506,15724267,15724773,15724776,15724782,15786210,15787492,15856352,15856354,15856360,15859488,15918571,15920672,15920880,15924256,16249582,16512288]}name(){return"windows-1251"}language(){return"ru"}};L.windows_1251=Ke;var We=class extends M{static{s(this,"windows_1256")}byteMap(){return[32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,0,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,32,32,32,32,32,32,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,32,32,32,32,32,32,129,32,131,32,32,32,32,136,32,138,32,156,141,142,143,144,32,32,32,32,32,32,32,152,32,154,32,156,32,32,159,32,32,32,32,32,32,32,32,32,32,170,32,32,32,32,32,32,32,32,32,32,181,32,32,32,32,32,32,32,32,32,32,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,32,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,32,32,32,32,244,32,32,32,32,249,32,251,252,32,32,255]}ngrams(){return[2148321,2148324,2148551,2153185,2153965,2154977,2155492,2156231,13050055,13091104,13093408,13095200,13099296,13099459,13099463,13099464,13099466,13099468,13099469,13099471,13099475,13099482,13099486,13099491,13099494,13099501,13099808,13100064,13100234,13115591,13181127,13181149,13181153,13181155,13181158,13246663,13574343,13617440,13705415,13748512,13836487,14295239,14344684,14544160,14753991,14797088,14806048,14806304,14885063,14927648,14928160,14935072,14950599,15016135,15058720,15124449,15131680,15474887,15540423,15540451,15540454,15583520,15585568,15590432]}name(){return"windows-1256"}language(){return"ar"}};L.windows_1256=We;var qe=class extends M{static{s(this,"windows_1257")}match(e){return e.inputBytes.some(t=>t>=128)?super.match(e):null}byteMap(){let e=new Array(256).fill(32);e[39]=0;for(let t=65;t<=90;t++)e[t]=t+32;for(let t=97;t<=122;t++)e[t]=t;e[142]=142,e[168]=e[184]=184,e[170]=e[186]=186,e[175]=e[191]=191,e[181]=181;for(let t=192;t<=214;t++)e[t]=t+32;for(let t=216;t<=222;t++)e[t]=t+32;e[223]=223;for(let t=224;t<=246;t++)e[t]=t;for(let t=248;t<=254;t++)e[t]=t;return e}ngrams(){return[new C("et",[2122090,2122098,2123109,2124135,2124385,2124641,2124645,2124649,2124655,2124661,2124897,2125417,2125678,2126441,2126693,2126949,6365281,6365290,6365291,6365292,6382112,6382624,6384499,6386549,6386785,6387297,6561908,6578464,6583667,6627435,6627443,6645100,6645107,6646816,6646885,6646900,6648608,6648692,6889579,6906912,6910570,6910752,6971680,7037299,7038309,7039346,7040879,7041893,7041908,7104875,7107616,7544929,7544939,7562528,7562604,7566437,7566441,7566708,7627115,7627124,7629088,7697184,7697253,7697505]),new C("lv",[2122098,2122601,2122849,2124146,2124154,2124897,2125282,2125921,2125938,2126433,2126689,2126699,2126949,2127214,2127457,6365289,6365301,6365302,6382185,6383904,6384499,6384751,6385778,6386293,6386464,6386806,6449509,6452512,6515052,6515060,6578464,6578546,6583584,6584864,6644850,6646123,6646643,6647393,6648608,6680693,6889577,6907236,6907376,6908642,6909046,7041908,7102836,7106404,7233824,7300193,7496043,7501166,7544947,7544949,7544950,7566453,7566574,7632160,7632489,7676022,7695904,7697184,7758188,14840608]),new C("lt",[2122089,2122341,2124146,2124641,2124905,2125167,2126433,2126689,2126699,2126709,2126945,2126949,2126965,2127457,2127465,6365300,6365424,6383904,6383988,6384112,6384738,6384993,6385268,6386274,6386292,6386976,6387050,6418553,6447392,6448489,6448494,6647401,6648949,6889569,6889577,6889579,6889581,6906217,6907246,6907252,6909543,6910496,6910752,6942827,6971757,6972704,7037289,7037292,7103073,7104869,7170419,7171947,7269152,7301733,7302009,7303968,7496176,7544937,7544939,7544950,7564129,7629088,7632246,7957356])]}name(){return"windows-1257"}};L.windows_1257=qe;var Ve=class extends M{static{s(this,"windows_1258")}match(e){return e.inputBytes.some(t=>t>=128)?super.match(e):null}byteMap(){let e=new Array(256).fill(32);e[39]=0;for(let t=65;t<=90;t++)e[t]=t+32;for(let t=97;t<=122;t++)e[t]=t;e[131]=131,e[136]=136,e[140]=e[156]=156,e[159]=255,e[170]=170,e[181]=181,e[186]=186;for(let t=192;t<=203;t++)e[t]=t+32;e[204]=204;for(let t=205;t<=209;t++)e[t]=t+32;e[210]=210;for(let t=211;t<=214;t++)e[t]=t+32;for(let t=216;t<=221;t++)e[t]=t+32;e[222]=222,e[223]=223;for(let t=224;t<=246;t++)e[t]=t;for(let t=248;t<=253;t++)e[t]=t;return e[255]=255,e}ngrams(){return[2122600,2122721,2123625,2123887,2125415,2125928,2126952,2126953,2126962,2127465,2127584,6419060,6496355,6496374,6514720,6514925,6545763,6758504,6758510,6758516,6758518,6812782,6815198,6815221,6824052,6844402,6876526,6889582,6889588,6941394,6941420,6941426,7217251,7217262,7217268,7235360,7235572,7235581,7235616,7302759,7336547,7610483,7629053,7629290,7631471,7676020,7760362,7790624,13396256,13397607,14557288,14771048,15395950,15397492,15494759,15496224,15560296,15885088,15886624,15887904,15889440,16018976,16108649,16643532]}name(){return"windows-1258"}language(){return"vi"}};L.windows_1258=Ve;var Ge=class extends M{static{s(this,"windows_874")}byteMap(){let e=new Array(256).fill(32);e[39]=0;for(let t=65;t<=90;t++)e[t]=t+32;for(let t=97;t<=122;t++)e[t]=t;for(let t=161;t<=218;t++)e[t]=t;for(let t=223;t<=251;t++)e[t]=t;return e}ngrams(){return[2138578,2138856,2146514,2148291,2154949,10604985,10605251,10669479,10671554,10799058,11064263,11195847,11200960,11200995,11910083,12042976,12042979,12047848,12132544,12165586,12173522,12305360,12314553,12636873,12828960,12829619,12829633,12832936,12832994,12837026,13091779,13095353,13095617,13096117,13226679,13226724,13293544,13477063,13674707,13689538,13744416,13805473,13812171,13812452,13812512,13812704,13814226,13821111,13879249,13940155,14009017,14010324,14149837,14721749,14728167,14796240,14860964,14920425,14924193,14989250,15258279,15262634,15319250,15328185]}name(){return"windows-874"}language(){return"th"}};L.windows_874=Ge;var He=class extends M{static{s(this,"KOI8_R")}byteMap(){return[32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,0,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,32,32,32,32,32,32,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,163,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,163,32,32,32,32,32,32,32,32,32,32,32,32,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223]}ngrams(){return[2147535,2148640,2149313,2149327,2150081,2150085,2150338,2150607,2150610,2151105,2151375,2151380,2151631,2152224,2152399,2153153,2153684,2154196,12701385,12702936,12963032,12963529,12964820,12964896,13094688,13181136,13223200,13224224,13226272,13419982,13420832,13424846,13549856,13550880,13552069,13552081,13553440,13553623,13574352,13574355,13574359,13617103,13617696,13618392,13618464,13620180,13621024,13621185,13684684,13685445,13685449,13685455,13812183,13813188,13881632,13882561,13882569,13882583,13944268,13946656,13946834,13948960,14272544,14603471]}name(){return"KOI8-R"}language(){return"ru"}};L.KOI8_R=He});var rt=G(X=>{"use strict";c();var y2=X&&X.__importDefault||function(x){return x&&x.__esModule?x:{default:x}};Object.defineProperty(X,"__esModule",{value:!0});X.ISO_2022_CN=X.ISO_2022_KR=X.ISO_2022_JP=void 0;var S2=y2(d0()),R0=class{static{s(this,"ISO_2022")}constructor(){this.escapeSequences=[]}name(){return"ISO_2022"}match(e){let t,r,n,i=0,a=0,o=0,f,l=e.inputBytes,p=e.inputLen;e:for(t=0;t<p;t++){if(l[t]==27){x:for(n=0;n<this.escapeSequences.length;n++){let d=this.escapeSequences[n];if(p-t<d.length)continue x;for(r=1;r<d.length;r++)if(d[r]!=l[t+r])continue x;i++,t+=d.length-1;continue e}a++}(l[t]==14||l[t]==15)&&o++}return i==0?null:(f=(100*i-100*a)/(i+a),i+o<5&&(f-=(5-(i+o))*10),f<=0?null:(0,S2.default)(e,this,f))}},ze=class extends R0{static{s(this,"ISO_2022_JP")}constructor(){super(...arguments),this.escapeSequences=[[27,36,40,67],[27,36,40,68],[27,36,64],[27,36,65],[27,36,66],[27,38,64],[27,40,66],[27,40,72],[27,40,73],[27,40,74],[27,46,65],[27,46,70]]}name(){return"ISO-2022-JP"}language(){return"ja"}};X.ISO_2022_JP=ze;var Ye=class extends R0{static{s(this,"ISO_2022_KR")}constructor(){super(...arguments),this.escapeSequences=[[27,36,41,67]]}name(){return"ISO-2022-KR"}language(){return"kr"}};X.ISO_2022_KR=Ye;var Je=class extends R0{static{s(this,"ISO_2022_CN")}constructor(){super(...arguments),this.escapeSequences=[[27,36,41,65],[27,36,41,71],[27,36,42,72],[27,36,41,69],[27,36,43,73],[27,36,43,74],[27,36,43,75],[27,36,43,76],[27,36,43,77],[27,78],[27,79]]}name(){return"ISO-2022-CN"}language(){return"zh"}};X.ISO_2022_CN=Je});var nt=G(q0=>{"use strict";c();Object.defineProperty(q0,"__esModule",{value:!0});q0.isByteArray=void 0;var _2=s(x=>x==null||typeof x!="object"?!1:isFinite(x.length)&&x.length>=0,"isByteArray");q0.isByteArray=_2});var it=G(R=>{"use strict";c();var E2=R&&R.__createBinding||(Object.create?function(x,e,t,r){r===void 0&&(r=t);var n=Object.getOwnPropertyDescriptor(e,t);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:s(function(){return e[t]},"get")}),Object.defineProperty(x,r,n)}:function(x,e,t,r){r===void 0&&(r=t),x[r]=e[t]}),D2=R&&R.__setModuleDefault||(Object.create?function(x,e){Object.defineProperty(x,"default",{enumerable:!0,value:e})}:function(x,e){x.default=e}),G0=R&&R.__importStar||function(){var x=s(function(e){return x=Object.getOwnPropertyNames||function(t){var r=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[r.length]=n);return r},x(e)},"ownKeys");return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=x(e),n=0;n<r.length;n++)r[n]!=="default"&&E2(t,e,r[n]);return D2(t,e),t}}(),Ze=R&&R.__importDefault||function(x){return x&&x.__esModule?x:{default:x}};Object.defineProperty(R,"__esModule",{value:!0});R.detectFileSync=R.detectFile=R.analyse=R.detect=void 0;var st=Ze(zx()),B2=Ze(Jx()),I2=Ze(Qx()),V0=G0(Zx()),T0=G0(et()),V=G0(tt()),Qe=G0(rt()),L2=nt(),R2=[new I2.default,new V0.UTF_16BE,new V0.UTF_16LE,new V0.UTF_32BE,new V0.UTF_32LE,new T0.sjis,new T0.big5,new T0.euc_jp,new T0.euc_kr,new T0.gb_18030,new Qe.ISO_2022_JP,new Qe.ISO_2022_KR,new Qe.ISO_2022_CN,new V.ISO_8859_1,new V.ISO_8859_2,new V.ISO_8859_5,new V.ISO_8859_6,new V.ISO_8859_7,new V.ISO_8859_8,new V.ISO_8859_9,new V.windows_1251,new V.windows_1256,new V.windows_1257,new V.windows_1258,new V.windows_874,new V.KOI8_R,new B2.default],T2=s(x=>{let e=(0,R.analyse)(x);return e.length>0?e[0].name:null},"detect");R.detect=T2;var F2=s(x=>{if(!(0,L2.isByteArray)(x))throw new Error("Input must be a byte array, e.g. Buffer or Uint8Array");let e=[];for(let i=0;i<256;i++)e[i]=0;for(let i=x.length-1;i>=0;i--)e[x[i]&255]++;let t=!1;for(let i=128;i<=159;i+=1)if(e[i]!==0){t=!0;break}let r={byteStats:e,c1Bytes:t,rawInput:x,rawLen:x.length,inputBytes:x,inputLen:x.length};return R2.map(i=>i.match(r)).filter(i=>!!i).sort((i,a)=>a.confidence-i.confidence)},"analyse");R.analyse=F2;var v2=s((x,e={})=>new Promise((t,r)=>{let n,i=(0,st.default)(),a=s((f,l)=>{n&&i.closeSync(n),f?r(f):l?t((0,R.detect)(l)):r(new Error("No error and no buffer received"))},"handler"),o=e?.sampleSize||0;if(o>0){n=i.openSync(x,"r");let f=Buffer.allocUnsafe(o);i.read(n,f,0,o,e.offset,(l,p)=>{l?a(l,null):(p<o&&(f=f.subarray(0,p)),a(null,f))});return}i.readFile(x,a)}),"detectFile");R.detectFile=v2;var C2=s((x,e={})=>{let t=(0,st.default)();if(e&&e.sampleSize){let r=t.openSync(x,"r"),n=Buffer.allocUnsafe(e.sampleSize),i=t.readSync(r,n,0,e.sampleSize,e.offset);return i<e.sampleSize&&(n=n.subarray(0,i)),t.closeSync(r),(0,R.detect)(n)}return(0,R.detect)(t.readFileSync(x))},"detectFileSync");R.detectFileSync=C2;R.default={analyse:R.analyse,detect:R.detect,detectFileSync:R.detectFileSync,detectFile:R.detectFile}});c();import*as ut from"node:readline/promises";c();c();c();c();var yt=["emacs","vim"],St=new Set(yt);function _t(x){return St.has(x)}s(_t,"isKeybinding");function dx(){let x=process.env.INQUIRER_KEYBINDINGS;return x?Array.from(new Set(x.toLowerCase().split(/[\s,]+/).filter(_t))):[]}s(dx,"getDefaultKeybindings");var x0=s((x,e=[])=>x.name==="up"||e.includes("vim")&&x.name==="k"||e.includes("emacs")&&x.ctrl&&x.name==="p","isUpKey"),s0=s((x,e=[])=>x.name==="down"||e.includes("vim")&&x.name==="j"||e.includes("emacs")&&x.ctrl&&x.name==="n","isDownKey"),Z0=s(x=>x.name==="space","isSpaceKey"),w0=s(x=>x.name==="backspace","isBackspaceKey"),y0=s(x=>x.name==="tab","isTabKey"),S0=s(x=>"1234567890".includes(x.name),"isNumberKey"),N=s(x=>x.name==="enter"||x.name==="return","isEnterKey");c();var C0=class extends Error{static{s(this,"AbortPromptError")}name="AbortPromptError";message="Prompt was aborted";constructor(e){super(),this.cause=e?.cause}},P0=class extends Error{static{s(this,"CancelPromptError")}name="CancelPromptError";message="Prompt was canceled"},_0=class extends Error{static{s(this,"ExitPromptError")}name="ExitPromptError"},k0=class extends Error{static{s(this,"HookError")}name="HookError"},r0=class extends Error{static{s(this,"ValidationError")}name="ValidationError"};c();c();import{AsyncResource as It}from"node:async_hooks";c();import{AsyncLocalStorage as Et,AsyncResource as Dt}from"node:async_hooks";var ux=new Et;function Bt(x){return{rl:x,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}s(Bt,"createStore");function hx(x,e){let t=Bt(x);return ux.run(t,()=>{function r(n){t.handleChange=()=>{t.index=0,n()},t.handleChange()}return s(r,"cycle"),e(r)})}s(hx,"withHooks");function i0(){let x=ux.getStore();if(!x)throw new k0("[Inquirer] Hook functions can only be called from within a prompt");return x}s(i0,"getStore");function X0(){return i0().rl}s(X0,"readline");function ee(x){let e=s((...t)=>{let r=i0(),n=!1,i=r.handleChange;r.handleChange=()=>{n=!0};let a=x(...t);return n&&i(),r.handleChange=i,a},"wrapped");return Dt.bind(e)}s(ee,"withUpdates");function b0(x){let e=i0(),{index:t}=e,r={get(){return e.hooks[t]},set(i){e.hooks[t]=i},initialized:t in e.hooks},n=x(r);return e.index++,n}s(b0,"withPointer");function px(){i0().handleChange()}s(px,"handleChange");var a0={queue(x){let e=i0(),{index:t}=e;e.hooksEffect.push(()=>{e.hooksCleanup[t]?.();let r=x(X0());if(r!=null&&typeof r!="function")throw new r0("useEffect return value must be a cleanup function or nothing.");e.hooksCleanup[t]=r})},run(){let x=i0();ee(()=>{x.hooksEffect.forEach(e=>{e()}),x.hooksEffect.length=0})()},clearAll(){let x=i0();x.hooksCleanup.forEach(e=>{e?.()}),x.hooksEffect.length=0,x.hooksCleanup.length=0}};function Lt(x){return typeof x=="function"}s(Lt,"isFactory");function I(x){return b0(e=>{let t=It.bind(s(function(i){e.get()!==i&&(e.set(i),px())},"setState"));if(e.initialized)return[e.get(),t];let r=Lt(x)?x():x;return e.set(r),[r,t]})}s(I,"useState");c();function Y(x,e){b0(t=>{let r=t.get();(!Array.isArray(r)||e.some((i,a)=>!Object.is(i,r[a])))&&a0.queue(x),t.set(e)})}s(Y,"useEffect");c();c();import{styleText as Z}from"node:util";c();import J from"node:process";function Rt(){return J.platform.startsWith("win")?!!J.env.CI||!!J.env.WT_SESSION||!!J.env.TERMINUS_SUBLIME||J.env.ConEmuTask==="{cmd::Cmder}"||J.env.TERM_PROGRAM==="Terminus-Sublime"||J.env.TERM_PROGRAM==="vscode"||J.env.TERM==="xterm-256color"||J.env.TERM==="alacritty"||J.env.TERMINAL_EMULATOR==="JetBrains-JediTerm":J.env.TERM!=="linux"}s(Rt,"isUnicodeSupported");var bx={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"\u2588",squareDarkShade:"\u2593",squareMediumShade:"\u2592",squareLightShade:"\u2591",squareTop:"\u2580",squareBottom:"\u2584",squareLeft:"\u258C",squareRight:"\u2590",squareCenter:"\u25A0",bullet:"\u25CF",dot:"\u2024",ellipsis:"\u2026",pointerSmall:"\u203A",triangleUp:"\u25B2",triangleUpSmall:"\u25B4",triangleDown:"\u25BC",triangleDownSmall:"\u25BE",triangleLeftSmall:"\u25C2",triangleRightSmall:"\u25B8",home:"\u2302",heart:"\u2665",musicNote:"\u266A",musicNoteBeamed:"\u266B",arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",arrowLeftRight:"\u2194",arrowUpDown:"\u2195",almostEqual:"\u2248",notEqual:"\u2260",lessOrEqual:"\u2264",greaterOrEqual:"\u2265",identical:"\u2261",infinity:"\u221E",subscriptZero:"\u2080",subscriptOne:"\u2081",subscriptTwo:"\u2082",subscriptThree:"\u2083",subscriptFour:"\u2084",subscriptFive:"\u2085",subscriptSix:"\u2086",subscriptSeven:"\u2087",subscriptEight:"\u2088",subscriptNine:"\u2089",oneHalf:"\xBD",oneThird:"\u2153",oneQuarter:"\xBC",oneFifth:"\u2155",oneSixth:"\u2159",oneEighth:"\u215B",twoThirds:"\u2154",twoFifths:"\u2156",threeQuarters:"\xBE",threeFifths:"\u2157",threeEighths:"\u215C",fourFifths:"\u2158",fiveSixths:"\u215A",fiveEighths:"\u215D",sevenEighths:"\u215E",line:"\u2500",lineBold:"\u2501",lineDouble:"\u2550",lineDashed0:"\u2504",lineDashed1:"\u2505",lineDashed2:"\u2508",lineDashed3:"\u2509",lineDashed4:"\u254C",lineDashed5:"\u254D",lineDashed6:"\u2574",lineDashed7:"\u2576",lineDashed8:"\u2578",lineDashed9:"\u257A",lineDashed10:"\u257C",lineDashed11:"\u257E",lineDashed12:"\u2212",lineDashed13:"\u2013",lineDashed14:"\u2010",lineDashed15:"\u2043",lineVertical:"\u2502",lineVerticalBold:"\u2503",lineVerticalDouble:"\u2551",lineVerticalDashed0:"\u2506",lineVerticalDashed1:"\u2507",lineVerticalDashed2:"\u250A",lineVerticalDashed3:"\u250B",lineVerticalDashed4:"\u254E",lineVerticalDashed5:"\u254F",lineVerticalDashed6:"\u2575",lineVerticalDashed7:"\u2577",lineVerticalDashed8:"\u2579",lineVerticalDashed9:"\u257B",lineVerticalDashed10:"\u257D",lineVerticalDashed11:"\u257F",lineDownLeft:"\u2510",lineDownLeftArc:"\u256E",lineDownBoldLeftBold:"\u2513",lineDownBoldLeft:"\u2512",lineDownLeftBold:"\u2511",lineDownDoubleLeftDouble:"\u2557",lineDownDoubleLeft:"\u2556",lineDownLeftDouble:"\u2555",lineDownRight:"\u250C",lineDownRightArc:"\u256D",lineDownBoldRightBold:"\u250F",lineDownBoldRight:"\u250E",lineDownRightBold:"\u250D",lineDownDoubleRightDouble:"\u2554",lineDownDoubleRight:"\u2553",lineDownRightDouble:"\u2552",lineUpLeft:"\u2518",lineUpLeftArc:"\u256F",lineUpBoldLeftBold:"\u251B",lineUpBoldLeft:"\u251A",lineUpLeftBold:"\u2519",lineUpDoubleLeftDouble:"\u255D",lineUpDoubleLeft:"\u255C",lineUpLeftDouble:"\u255B",lineUpRight:"\u2514",lineUpRightArc:"\u2570",lineUpBoldRightBold:"\u2517",lineUpBoldRight:"\u2516",lineUpRightBold:"\u2515",lineUpDoubleRightDouble:"\u255A",lineUpDoubleRight:"\u2559",lineUpRightDouble:"\u2558",lineUpDownLeft:"\u2524",lineUpBoldDownBoldLeftBold:"\u252B",lineUpBoldDownBoldLeft:"\u2528",lineUpDownLeftBold:"\u2525",lineUpBoldDownLeftBold:"\u2529",lineUpDownBoldLeftBold:"\u252A",lineUpDownBoldLeft:"\u2527",lineUpBoldDownLeft:"\u2526",lineUpDoubleDownDoubleLeftDouble:"\u2563",lineUpDoubleDownDoubleLeft:"\u2562",lineUpDownLeftDouble:"\u2561",lineUpDownRight:"\u251C",lineUpBoldDownBoldRightBold:"\u2523",lineUpBoldDownBoldRight:"\u2520",lineUpDownRightBold:"\u251D",lineUpBoldDownRightBold:"\u2521",lineUpDownBoldRightBold:"\u2522",lineUpDownBoldRight:"\u251F",lineUpBoldDownRight:"\u251E",lineUpDoubleDownDoubleRightDouble:"\u2560",lineUpDoubleDownDoubleRight:"\u255F",lineUpDownRightDouble:"\u255E",lineDownLeftRight:"\u252C",lineDownBoldLeftBoldRightBold:"\u2533",lineDownLeftBoldRightBold:"\u252F",lineDownBoldLeftRight:"\u2530",lineDownBoldLeftBoldRight:"\u2531",lineDownBoldLeftRightBold:"\u2532",lineDownLeftRightBold:"\u252E",lineDownLeftBoldRight:"\u252D",lineDownDoubleLeftDoubleRightDouble:"\u2566",lineDownDoubleLeftRight:"\u2565",lineDownLeftDoubleRightDouble:"\u2564",lineUpLeftRight:"\u2534",lineUpBoldLeftBoldRightBold:"\u253B",lineUpLeftBoldRightBold:"\u2537",lineUpBoldLeftRight:"\u2538",lineUpBoldLeftBoldRight:"\u2539",lineUpBoldLeftRightBold:"\u253A",lineUpLeftRightBold:"\u2536",lineUpLeftBoldRight:"\u2535",lineUpDoubleLeftDoubleRightDouble:"\u2569",lineUpDoubleLeftRight:"\u2568",lineUpLeftDoubleRightDouble:"\u2567",lineUpDownLeftRight:"\u253C",lineUpBoldDownBoldLeftBoldRightBold:"\u254B",lineUpDownBoldLeftBoldRightBold:"\u2548",lineUpBoldDownLeftBoldRightBold:"\u2547",lineUpBoldDownBoldLeftRightBold:"\u254A",lineUpBoldDownBoldLeftBoldRight:"\u2549",lineUpBoldDownLeftRight:"\u2540",lineUpDownBoldLeftRight:"\u2541",lineUpDownLeftBoldRight:"\u253D",lineUpDownLeftRightBold:"\u253E",lineUpBoldDownBoldLeftRight:"\u2542",lineUpDownLeftBoldRightBold:"\u253F",lineUpBoldDownLeftBoldRight:"\u2543",lineUpBoldDownLeftRightBold:"\u2544",lineUpDownBoldLeftBoldRight:"\u2545",lineUpDownBoldLeftRightBold:"\u2546",lineUpDoubleDownDoubleLeftDoubleRightDouble:"\u256C",lineUpDoubleDownDoubleLeftRight:"\u256B",lineUpDownLeftDoubleRightDouble:"\u256A",lineCross:"\u2573",lineBackslash:"\u2572",lineSlash:"\u2571"},mx={tick:"\u2714",info:"\u2139",warning:"\u26A0",cross:"\u2718",squareSmall:"\u25FB",squareSmallFilled:"\u25FC",circle:"\u25EF",circleFilled:"\u25C9",circleDotted:"\u25CC",circleDouble:"\u25CE",circleCircle:"\u24DE",circleCross:"\u24E7",circlePipe:"\u24BE",radioOn:"\u25C9",radioOff:"\u25EF",checkboxOn:"\u2612",checkboxOff:"\u2610",checkboxCircleOn:"\u24E7",checkboxCircleOff:"\u24BE",pointer:"\u276F",triangleUpOutline:"\u25B3",triangleLeft:"\u25C0",triangleRight:"\u25B6",lozenge:"\u25C6",lozengeOutline:"\u25C7",hamburger:"\u2630",smiley:"\u32E1",mustache:"\u0DF4",star:"\u2605",play:"\u25B6",nodejs:"\u2B22",oneSeventh:"\u2150",oneNinth:"\u2151",oneTenth:"\u2152"},Tt={tick:"\u221A",info:"i",warning:"\u203C",cross:"\xD7",squareSmall:"\u25A1",squareSmallFilled:"\u25A0",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(\u25CB)",circleCross:"(\xD7)",circlePipe:"(\u2502)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[\xD7]",checkboxOff:"[ ]",checkboxCircleOn:"(\xD7)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"\u2206",triangleLeft:"\u25C4",triangleRight:"\u25BA",lozenge:"\u2666",lozengeOutline:"\u25CA",hamburger:"\u2261",smiley:"\u263A",mustache:"\u250C\u2500\u2510",star:"\u2736",play:"\u25BA",nodejs:"\u2666",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},Ft={...bx,...mx},vt={...bx,...Tt},Ct=Rt(),Pt=Ct?Ft:vt,Q=Pt,yr=Object.entries(mx);var kt={prefix:{idle:Z("blue","?"),done:Z("green",Q.tick)},spinner:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"].map(x=>Z("yellow",x))},keybindings:[],style:{answer:s(x=>Z("cyan",x),"answer"),message:s(x=>Z("bold",x),"message"),error:s(x=>Z("red",`> ${x}`),"error"),defaultAnswer:s(x=>Z("dim",`(${x})`),"defaultAnswer"),help:s(x=>Z("dim",x),"help"),highlight:s(x=>Z("cyan",x),"highlight"),key:s(x=>Z("cyan",Z("bold",`<${x}>`)),"key")}};function gx(){return{...kt,keybindings:dx()}}s(gx,"getDefaultTheme");function wx(x){if(typeof x!="object"||x===null)return!1;let e=x;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(x)===e}s(wx,"isPlainObject");function yx(...x){let e={};for(let t of x)for(let[r,n]of Object.entries(t)){let i=e[r];e[r]=wx(i)&&wx(n)?yx(i,n):n}return e}s(yx,"deepMerge");function O(...x){let e=[gx(),...x.filter(t=>t!=null)];return yx(...e)}s(O,"makeTheme");function K({status:x="idle",theme:e}){let[t,r]=I(!1),[n,i]=I(0),{prefix:a,spinner:o}=O(e);return Y(()=>{if(x==="loading"){let l,p=-1,d=setTimeout(()=>{r(!0),l=setInterval(()=>{p=p+1,i(p%o.frames.length)},o.interval)},300);return()=>{clearTimeout(d),clearInterval(l)}}else r(!1)},[x]),t?o.frames[n]:typeof a=="string"?a:a[x==="loading"?"idle":x]??a.idle}s(K,"usePrefix");c();function o0(x,e){return b0(t=>{let r=t.get();if(!r||r.dependencies.length!==e.length||r.dependencies.some((n,i)=>n!==e[i])){let n=x();return t.set({value:n,dependencies:e}),n}return r.value})}s(o0,"useMemo");c();function c0(x){return I({current:x})[0]}s(c0,"useRef");c();function W(x){let e=c0(x);e.current=x,Y(t=>{let r=!1,n=ee((i,a)=>{r||e.current(a,t)});return t.input.on("keypress",n),()=>{r=!0,t.input.removeListener("keypress",n)}},[])}s(W,"useKeypress");c();c();var Ax=v0(_x(),1);c();c();c();c();var Ex=(()=>{let x=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return e=>{let t=0;for(x.lastIndex=0;x.test(e);)t+=1;return e.length-t}})(),Dx=s(x=>x===12288||x>=65281&&x<=65376||x>=65504&&x<=65510,"isFullWidth"),Bx=s(x=>x===8987||x===9001||x>=12272&&x<=12287||x>=12289&&x<=12350||x>=12441&&x<=12543||x>=12549&&x<=12591||x>=12593&&x<=12686||x>=12688&&x<=12771||x>=12783&&x<=12830||x>=12832&&x<=12871||x>=12880&&x<=19903||x>=65040&&x<=65049||x>=65072&&x<=65106||x>=65108&&x<=65126||x>=65128&&x<=65131||x>=127488&&x<=127490||x>=127504&&x<=127547||x>=127552&&x<=127560||x>=131072&&x<=196605||x>=196608&&x<=262141,"isWideNotCJKTNotEmoji");var Mt=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,At=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Ix=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,jt=/\t{1,1000}/y,Lx=new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*","yu"),$t=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Nt=new RegExp("\\p{M}+","gu"),Kt={limit:1/0,ellipsis:""},Rx=s((x,e={},t={})=>{let r=e.limit??1/0,n=e.ellipsis??"",i=e?.ellipsisWidth??(n?Rx(n,Kt,t).width:0),a=0,o=t.controlWidth??0,f=t.tabWidth??8,l=t.emojiWidth??2,p=2,d=t.regularWidth??1,u=t.wideWidth??p,S=[[$t,d],[Mt,a],[At,o],[jt,f],[Lx,l],[Ix,u]],w=0,m=0,g=x.length,_=0,b=!1,B=g,T=Math.max(0,r-i),k=0,P=0,U=0,A=0;e:for(;;){if(P>k||m>=g&&m>w){let h=x.slice(k,P)||x.slice(w,m);_=0;for(let E of h.replaceAll(Nt,"")){let D=E.codePointAt(0)||0;if(Dx(D)?A=p:Bx(D)?A=u:A=d,U+A>T&&(B=Math.min(B,Math.max(k,w)+_)),U+A>r){b=!0;break e}_+=E.length,U+=A}k=P=0}if(m>=g)break e;for(let h=0,E=S.length;h<E;h++){let[D,F]=S[h];if(D.lastIndex=m,D.test(x)){if(_=D===Ix?Ex(x.slice(m,D.lastIndex)):D===Lx?1:D.lastIndex-m,A=_*F,U+A>T&&(B=Math.min(B,m+Math.floor((T-U)/F))),U+A>r){b=!0;break e}U+=A,k=w,P=m,m=w=D.lastIndex;continue e}}m+=1}return{width:b?T:U,index:b?B:g,truncated:b,ellipsed:b&&r>=i}},"getStringTruncatedWidth"),Tx=Rx;var Wt={limit:1/0,ellipsis:"",ellipsisWidth:0},qt=s((x,e={})=>Tx(x,Wt,e).width,"fastStringWidth"),t0=qt;var U0="\x1B",kx="\x9B",Vt=39,te="\x07",Ux="[",Gt="]",Ox="m",re=`${Gt}8;;`,Fx=new RegExp(`(?:\\${Ux}(?<code>\\d+)m|\\${re}(?<uri>.*)${te})`,"y"),vx=s(x=>{if(x>=30&&x<=37||x>=90&&x<=97)return 39;if(x>=40&&x<=47||x>=100&&x<=107)return 49;if(x===1||x===2)return 22;if(x===3)return 23;if(x===4)return 24;if(x===7)return 27;if(x===8)return 28;if(x===9)return 29;if(x===0)return 0},"getClosingCode"),Cx=s(x=>`${U0}${Ux}${x}${Ox}`,"wrapAnsiCode"),Px=s(x=>`${U0}${re}${x}${te}`,"wrapAnsiHyperlink"),xe=s((x,e,t)=>{let r=e[Symbol.iterator](),n=!1,i=!1,a=x.at(-1),o=a===void 0?0:t0(a),f=r.next(),l=r.next(),p=0;for(;!f.done;){let d=f.value,u=t0(d);o+u<=t?x[x.length-1]+=d:(x.push(d),o=0),(d===U0||d===kx)&&(n=!0,i=e.startsWith(re,p+1)),n?i?d===te&&(n=!1,i=!1):d===Ox&&(n=!1):(o+=u,o===t&&!l.done&&(x.push(""),o=0)),f=l,l=r.next(),p+=d.length}a=x.at(-1),!o&&a!==void 0&&a.length&&x.length>1&&(x[x.length-2]+=x.pop())},"wrapWord"),Ht=s(x=>{let e=x.split(" "),t=e.length;for(;t&&!t0(e[t-1]);)t--;return t===e.length?x:e.slice(0,t).join(" ")+e.slice(t).join("")},"stringVisibleTrimSpacesRight"),zt=s((x,e,t={})=>{if(t.trim!==!1&&x.trim()==="")return"";let r="",n,i,a=x.split(" "),o=[""],f=0;for(let d=0;d<a.length;d++){let u=a[d];if(t.trim!==!1){let w=o.at(-1)??"",m=w.trimStart();w.length!==m.length&&(o[o.length-1]=m,f=t0(m))}d!==0&&(f>=e&&(t.wordWrap===!1||t.trim===!1)&&(o.push(""),f=0),(f||t.trim===!1)&&(o[o.length-1]+=" ",f++));let S=t0(u);if(t.hard&&S>e){let w=e-f,m=1+Math.floor((S-w-1)/e);Math.floor((S-1)/e)<m&&o.push(""),xe(o,u,e),f=t0(o.at(-1)??"");continue}if(f+S>e&&f&&S){if(t.wordWrap===!1&&f<e){xe(o,u,e),f=t0(o.at(-1)??"");continue}o.push(""),f=0}if(f+S>e&&t.wordWrap===!1){xe(o,u,e),f=t0(o.at(-1)??"");continue}o[o.length-1]+=u,f+=S}t.trim!==!1&&(o=o.map(d=>Ht(d)));let l=o.join(`
|
|
4
|
+
`),p=!1;for(let d=0;d<l.length;d++){let u=l[d];if(r+=u,p)p=!1;else if(p=u>="\uD800"&&u<="\uDBFF",p)continue;if(u===U0||u===kx){Fx.lastIndex=d+1;let w=Fx.exec(l)?.groups;if(w?.code!==void 0){let m=Number.parseFloat(w.code);n=m===Vt?void 0:m}else w?.uri!==void 0&&(i=w.uri.length===0?void 0:w.uri)}if(l[d+1]===`
|
|
5
|
+
`){i&&(r+=Px(""));let S=n?vx(n):void 0;n&&S&&(r+=Cx(S))}else u===`
|
|
6
|
+
`&&(n&&vx(n)&&(r+=Cx(n)),i&&(r+=Px(i)))}return r},"exec"),Yt=/\r?\n/;function Mx(x,e,t){return String(x).normalize().split(Yt).map(r=>zt(r,e,t)).join(`
|
|
7
|
+
`)}s(Mx,"wrapAnsi");function E0(x,e){return x.split(`
|
|
8
|
+
`).flatMap(t=>Mx(t,e,{trim:!1,wordWrap:!1}).split(`
|
|
9
|
+
`).map(r=>r.trimEnd())).join(`
|
|
10
|
+
`)}s(E0,"breakLines");function O0(){return(0,Ax.default)({defaultWidth:80,output:X0().output})}s(O0,"readlineWidth");function Jt({active:x,renderedItems:e,pageSize:t,loop:r}){let n=c0({lastPointer:x,lastActive:void 0}),{lastPointer:i,lastActive:a}=n.current,o=Math.floor(t/2),f=e.reduce((d,u)=>d+u.length,0),l=e.slice(0,x).reduce((d,u)=>d+u.length,0),p=l;if(f>t)if(r)p=i,a!=null&&a<x&&x-a<t&&(p=Math.min(o,Math.abs(x-a)===1?Math.min(i+(e[a]?.length??0),Math.max(l,i)):i+x-a));else{let d=e.slice(x).reduce((u,S)=>u+S.length,0);p=d<t-o?t-d:Math.min(l,o)}return n.current.lastPointer=p,n.current.lastActive=x,p}s(Jt,"usePointerPosition");function D0({items:x,active:e,renderItem:t,pageSize:r,loop:n=!0}){let i=O0(),a=s(_=>(_%x.length+x.length)%x.length,"bound"),o=x.map((_,b)=>_==null?[]:E0(t({item:_,index:b,isActive:b===e}),i).split(`
|
|
11
|
+
`)),f=o.reduce((_,b)=>_+b.length,0),l=s(_=>o[_]??[],"renderItemAtIndex"),p=Jt({active:e,renderedItems:o,pageSize:r,loop:n}),d=l(e).slice(0,r),u=p+d.length<=r?p:r-d.length,S=Array.from({length:r});S.splice(u,d.length,...d);let w=new Set([e]),m=u+d.length,g=a(e+1);for(;m<r&&!w.has(g)&&(n&&f>r?g!==e:g>e);){let b=l(g).slice(0,r-m);S.splice(m,b.length,...b),w.add(g),m+=b.length,g=a(g+1)}for(m=u-1,g=a(e-1);m>=0&&!w.has(g)&&(n&&f>r?g!==e:g<e);){let _=l(g),b=_.slice(Math.max(0,_.length-m-1));S.splice(m-b.length+1,b.length,...b),w.add(g),m-=b.length,g=a(g-1)}return S.filter(_=>typeof _=="string").join(`
|
|
12
|
+
`)}s(D0,"usePagination");c();var Gx=v0($x(),1);import*as Vx from"node:readline";import{AsyncResource as t2}from"node:async_hooks";c();c();var f0=[];f0.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&f0.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&f0.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var M0=s(x=>!!x&&typeof x=="object"&&typeof x.removeListener=="function"&&typeof x.emit=="function"&&typeof x.reallyExit=="function"&&typeof x.listeners=="function"&&typeof x.kill=="function"&&typeof x.pid=="number"&&typeof x.on=="function","processOk"),se=Symbol.for("signal-exit emitter"),ie=globalThis,Zt=Object.defineProperty.bind(Object),ae=class{static{s(this,"Emitter")}emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(ie[se])return ie[se];Zt(ie,se,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){let r=this.listeners[e],n=r.indexOf(t);n!==-1&&(n===0&&r.length===1?r.length=0:r.splice(n,1))}emit(e,t,r){if(this.emitted[e])return!1;this.emitted[e]=!0;let n=!1;for(let i of this.listeners[e])n=i(t,r)===!0||n;return e==="exit"&&(n=this.emit("afterExit",t,r)||n),n}},A0=class{static{s(this,"SignalExitBase")}},Xt=s(x=>({onExit(e,t){return x.onExit(e,t)},load(){return x.load()},unload(){return x.unload()}}),"signalExitWrap"),oe=class extends A0{static{s(this,"SignalExitFallback")}onExit(){return()=>{}}load(){}unload(){}},ce=class extends A0{static{s(this,"SignalExit")}#t=fe.platform==="win32"?"SIGINT":"SIGHUP";#x=new ae;#e;#s;#i;#n={};#r=!1;constructor(e){super(),this.#e=e,this.#n={};for(let t of f0)this.#n[t]=()=>{let r=this.#e.listeners(t),{count:n}=this.#x,i=e;if(typeof i.__signal_exit_emitter__=="object"&&typeof i.__signal_exit_emitter__.count=="number"&&(n+=i.__signal_exit_emitter__.count),r.length===n){this.unload();let a=this.#x.emit("exit",null,t),o=t==="SIGHUP"?this.#t:t;a||e.kill(e.pid,o)}};this.#i=e.reallyExit,this.#s=e.emit}onExit(e,t){if(!M0(this.#e))return()=>{};this.#r===!1&&this.load();let r=t?.alwaysLast?"afterExit":"exit";return this.#x.on(r,e),()=>{this.#x.removeListener(r,e),this.#x.listeners.exit.length===0&&this.#x.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#r){this.#r=!0,this.#x.count+=1;for(let e of f0)try{let t=this.#n[e];t&&this.#e.on(e,t)}catch{}this.#e.emit=(e,...t)=>this.#o(e,...t),this.#e.reallyExit=e=>this.#a(e)}}unload(){this.#r&&(this.#r=!1,f0.forEach(e=>{let t=this.#n[e];if(!t)throw new Error("Listener not defined for signal: "+e);try{this.#e.removeListener(e,t)}catch{}}),this.#e.emit=this.#s,this.#e.reallyExit=this.#i,this.#x.count-=1)}#a(e){return M0(this.#e)?(this.#e.exitCode=e||0,this.#x.emit("exit",this.#e.exitCode,null),this.#i.call(this.#e,this.#e.exitCode)):0}#o(e,...t){let r=this.#s;if(e==="exit"&&M0(this.#e)){typeof t[0]=="number"&&(this.#e.exitCode=t[0]);let n=r.call(this.#e,e,...t);return this.#x.emit("exit",this.#e.exitCode,null),n}else return r.call(this.#e,e,...t)}},fe=globalThis.process,{onExit:Nx,load:Un,unload:On}=Xt(M0(fe)?new ce(fe):new oe);c();import{stripVTControlCharacters as e2}from"node:util";c();var n0="\x1B[",le=n0+"G",m0=n0+"?25l",Wx=n0+"?25h",de=s((x=1)=>x>0?`${n0}${x}A`:"","cursorUp"),ue=s((x=1)=>x>0?`${n0}${x}B`:"","cursorDown"),he=s((x,e)=>typeof e=="number"&&!Number.isNaN(e)?`${n0}${e+1};${x+1}H`:`${n0}${x+1}G`,"cursorTo"),Kx=n0+"2K",pe=s(x=>x>0?(Kx+de(1)).repeat(x-1)+Kx+le:"","eraseLines");var qx=s(x=>x.split(`
|
|
13
|
+
`).length,"height"),x2=s(x=>x.split(`
|
|
14
|
+
`).pop()??"","lastLine"),B0=class{static{s(this,"ScreenManager")}height=0;extraLinesUnderPrompt=0;cursorPos;rl;constructor(e){this.rl=e,this.cursorPos=e.getCursorPos()}write(e){this.rl.output.unmute(),this.rl.output.write(e),this.rl.output.mute()}render(e,t=""){let r=x2(e),n=e2(r),i=n;this.rl.line.length>0&&(i=i.slice(0,-this.rl.line.length)),this.rl.setPrompt(i),this.cursorPos=this.rl.getCursorPos();let a=O0();e=E0(e,a),t=E0(t,a),n.length%a===0&&(e+=`
|
|
15
|
+
`);let o=e+(t?`
|
|
16
|
+
`+t:""),l=Math.floor(n.length/a)-this.cursorPos.rows+(t?qx(t):0);l>0&&(o+=de(l)),o+=he(this.cursorPos.cols),this.write(ue(this.extraLinesUnderPrompt)+pe(this.height)+o),this.extraLinesUnderPrompt=l,this.height=qx(o)}checkCursorPos(){let e=this.rl.getCursorPos();e.cols!==this.cursorPos.cols&&(this.write(he(e.cols)),this.cursorPos=e)}done({clearContent:e}){this.rl.setPrompt("");let t=ue(this.extraLinesUnderPrompt);t+=e?pe(this.height):`
|
|
17
|
+
`,t+=le,t+=Wx,this.write(t),this.rl.close()}};c();var j0=class extends Promise{static{s(this,"PromisePolyfill")}static withResolver(){let e,t;return{promise:new Promise((n,i)=>{e=n,t=i}),resolve:e,reject:t}}};import r2 from"node:path";var n2=globalThis.setImmediate;function s2(){let x=Error.prepareStackTrace,e=[];try{Error.prepareStackTrace=(t,r)=>{let n=r.slice(1);return e=n,n},new Error().stack}catch{return e}return Error.prepareStackTrace=x,e}s(s2,"getCallSites");function q(x){let e=s2();return s((r,n={})=>{let{input:i=process.stdin,signal:a}=n,o=new Set,f=new Gx.default;f.pipe(n.output??process.stdout);let l=Vx.createInterface({terminal:!0,input:i,output:f});f.mute();let p=new B0(l),{promise:d,resolve:u,reject:S}=j0.withResolver(),w=s(()=>S(new P0),"cancel");if(a){let g=s(()=>S(new C0({cause:a.reason})),"abort");if(a.aborted)return g(),Object.assign(d,{cancel:w});a.addEventListener("abort",g),o.add(()=>a.removeEventListener("abort",g))}o.add(Nx((g,_)=>{S(new _0(`User force closed the prompt with ${g} ${_}`))}));let m=s(()=>S(new _0("User force closed the prompt with SIGINT")),"sigint");return l.on("SIGINT",m),o.add(()=>l.removeListener("SIGINT",m)),hx(l,g=>{let _=t2.bind(()=>a0.clearAll());l.on("close",_),o.add(()=>l.removeListener("close",_));let b=s(()=>{let B=s(()=>p.checkCursorPos(),"checkCursorPos");l.input.on("keypress",B),o.add(()=>l.input.removeListener("keypress",B));let T=null;g(()=>{let k=!1;try{let P=x(r,h=>{k?u(h):T={value:h}});if(P===void 0){let h=e[1]?.getFileName();throw h&&!h.startsWith("file://")&&(h=r2.resolve(h)),new Error(`Prompt functions must return a string.
|
|
18
|
+
at ${h}`)}let[U,A]=typeof P=="string"?[P]:P;p.render(U,A),a0.run()}catch(P){S(P)}if(k=!0,T!==null){let{value:P}=T;T=null,u(P)}})},"startCycle");return"readableFlowing"in i?n2(b):b(),Object.assign(d.then(B=>(a0.clearAll(),B),B=>{throw a0.clearAll(),B}).finally(()=>{o.forEach(B=>B()),p.done({clearContent:!!n.clearPromptOnDone}),f.end()}).then(()=>d),{cancel:w})})},"prompt")}s(q,"createPrompt");c();import{styleText as i2}from"node:util";var v=class{static{s(this,"Separator")}separator=i2("dim",Array.from({length:15}).join(Q.line));type="separator";constructor(e){e&&(this.separator=e)}static isSeparator(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="separator")}};import{styleText as l0}from"node:util";var a2={icon:{checked:l0("green",Q.circleFilled),unchecked:Q.circle,cursor:Q.pointer,disabledChecked:l0("green",Q.circleDouble),disabledUnchecked:"-"},style:{disabled:s(x=>l0("dim",x),"disabled"),renderSelectedChoices:s(x=>x.map(e=>e.short).join(", "),"renderSelectedChoices"),description:s(x=>l0("cyan",x),"description"),keysHelpTip:s(x=>x.map(([e,t])=>`${l0("bold",e)} ${l0("dim",t)}`).join(l0("dim"," \u2022 ")),"keysHelpTip")},i18n:{disabledError:"This option is disabled and cannot be toggled."}};function $0(x){return!v.isSeparator(x)&&!x.disabled}s($0,"isSelectable");function be(x){return!v.isSeparator(x)}s(be,"isNavigable");function Hx(x){return!v.isSeparator(x)&&x.checked}s(Hx,"isChecked");function me(x){return $0(x)?{...x,checked:!x.checked}:x}s(me,"toggle");function o2(x){return function(e){return $0(e)?{...e,checked:x}:e}}s(o2,"check");function c2(x){return x.map(e=>{if(v.isSeparator(e))return e;if(typeof e!="object"||e===null||!("value"in e)){let n=String(e);return{value:e,name:n,short:n,checkedName:n,disabled:!1,checked:!1}}let t=e.name??String(e.value),r={value:e.value,name:t,short:e.short??t,checkedName:e.checkedName??t,disabled:e.disabled??!1,checked:e.checked??!1};return e.description&&(r.description=e.description),r})}s(c2,"normalizeChoices");var ge=q((x,e)=>{let{pageSize:t=7,loop:r=!0,required:n,validate:i=s(()=>!0,"validate")}=x,a={all:"a",invert:"i",...x.shortcuts},o=O(a2,x.theme),{keybindings:f}=o,[l,p]=I("idle"),d=K({status:l,theme:o}),[u,S]=I(c2(x.choices)),w=o0(()=>{let h=u.findIndex(be),E=u.findLastIndex(be);if(h===-1)throw new r0("[checkbox prompt] No selectable choices. All choices are disabled.");return{first:h,last:E}},[u]),[m,g]=I(w.first),[_,b]=I();W(async h=>{if(N(h)){let E=u.filter(Hx),D=await i([...E]);n&&!E.length?b("At least one choice must be selected"):D===!0?(p("done"),e(E.map(F=>F.value))):b(D||"You must select a valid value")}else if(x0(h,f)||s0(h,f)){if(_&&b(void 0),r||x0(h,f)&&m!==w.first||s0(h,f)&&m!==w.last){let E=x0(h,f)?-1:1,D=m;do D=(D+E+u.length)%u.length;while(!be(u[D]));g(D)}}else if(Z0(h)){let E=u[m];E&&!v.isSeparator(E)&&(E.disabled?b(o.i18n.disabledError):(b(void 0),S(u.map((D,F)=>F===m?me(D):D))))}else if(h.name===a.all){let E=u.some(D=>$0(D)&&!D.checked);S(u.map(o2(E)))}else if(h.name===a.invert)S(u.map(me));else if(S0(h)){let E=Number(h.name)-1,D=-1,F=u.findIndex(e0=>v.isSeparator(e0)?!1:(D++,D===E)),j=u[F];j&&$0(j)&&(g(F),S(u.map((e0,z)=>z===F?me(e0):e0)))}});let B=o.style.message(x.message,l),T,k=D0({items:u,active:m,renderItem({item:h,isActive:E}){if(v.isSeparator(h))return` ${h.separator}`;let D=E?o.icon.cursor:" ";if(h.disabled){let z=typeof h.disabled=="string"?h.disabled:"(disabled)",J0=h.checked?o.icon.disabledChecked:o.icon.disabledUnchecked;return o.style.disabled(`${D}${J0} ${h.name} ${z}`)}E&&(T=h.description);let F=h.checked?o.icon.checked:o.icon.unchecked,j=h.checked?h.checkedName:h.name;return(E?o.style.highlight:z=>z)(`${D}${F} ${j}`)},pageSize:t,loop:r});if(l==="done"){let h=u.filter(Hx),E=o.style.answer(o.style.renderSelectedChoices(h,u));return[d,B,E].filter(Boolean).join(" ")}let P=[["\u2191\u2193","navigate"],["space","select"]];a.all&&P.push([a.all,"all"]),a.invert&&P.push([a.invert,"invert"]),P.push(["\u23CE","submit"]);let U=o.style.keysHelpTip(P);return`${[[d,B].filter(Boolean).join(" "),k," ",T?o.style.description(T):"",_?o.style.error(_):"",U].filter(Boolean).join(`
|
|
19
|
+
`).trimEnd()}${m0}`});c();c();var ct=v0(it(),1),ex=v0(wt(),1);import{spawn as P2,spawnSync as k2}from"node:child_process";import{mkdtempSync as U2,readFileSync as O2,rmSync as M2,writeFileSync as A2}from"node:fs";import Xe from"node:path";import j2 from"node:os";import{randomUUID as $2}from"node:crypto";c();var H0=class extends Error{static{s(this,"CreateFileError")}name="CreateFileError";originalError;constructor(e){super(`Failed to create temporary file.${e instanceof Error?` ${e.message}`:""}`,{cause:e}),this.originalError=e}},g0=class extends Error{static{s(this,"LaunchEditorError")}name="LaunchEditorError";originalError;constructor(e){super(`Failed to launch editor.${e instanceof Error?` ${e.message}`:""}`,{cause:e}),this.originalError=e}},z0=class extends Error{static{s(this,"ReadFileError")}name="ReadFileError";originalError;constructor(e){super(`Failed to read temporary file.${e instanceof Error?` ${e.message}`:""}`,{cause:e}),this.originalError=e}},Y0=class extends Error{static{s(this,"RemoveFileError")}name="RemoveFileError";originalError;constructor(e){super(`Failed to remove temporary file.${e instanceof Error?` ${e.message}`:""}`,{cause:e}),this.originalError=e}};c();function at(x){let e,t;if(x.startsWith('"')){let r=x.indexOf('"',1);r===-1?(e=x.slice(1),t=""):(e=x.substring(1,r),t=x.substring(r+1).trim())}else{let r=x.indexOf(" ");r===-1?(e=x,t=""):(e=x.substring(0,r),t=x.substring(r+1).trim())}return{bin:e,args:t?t.split(/\s+/):[]}}s(at,"parseEditorCommand");var ft=s((x,e,t)=>{let r=typeof e=="function"?e:void 0,n=typeof e=="function"?t:e;return new xx(x,n).runAsync(r)},"editAsync");function ot(x){return x?x.replace(/[^a-zA-Z0-9_.-]/g,"_"):""}s(ot,"sanitizeAffix");var xx=class{static{s(this,"ExternalEditor")}editor;lastExitStatus=0;text="";tempFile="";tempDir="";fileOptions={};constructor(e="",t={}){this.text=e,this.fileOptions=t,this.editor=at(process.env.VISUAL??process.env.EDITOR??(process.platform.startsWith("win")?"notepad":"vim"))}run(){this.createTempFile();try{try{let e=k2(this.editor.bin,this.editorArgs(),{shell:!1,stdio:"inherit"});if(e.error)throw e.error;this.lastExitStatus=e.status??0}catch(e){throw new g0(e)}return this.readTemporaryFile(),this.text}finally{this.cleanup()}}runAsync(e){this.createTempFile();let t=new Promise((r,n)=>{try{let i=P2(this.editor.bin,this.editorArgs(),{shell:!1,stdio:"inherit"});i.once("error",a=>{n(new g0(a))}),i.once("exit",a=>{this.lastExitStatus=a??0,r()})}catch(i){n(new g0(i))}}).then(()=>(this.readTemporaryFile(),this.text)).finally(()=>{this.cleanup()});return e&&t.then(r=>e(void 0,r),r=>e(r instanceof Error?r:new Error(String(r)),void 0)),t}cleanup(){if(this.tempDir)try{M2(this.tempDir,{force:!0,recursive:!0}),this.tempFile="",this.tempDir=""}catch(e){throw new Y0(e)}}createTempFile(){try{let e=Xe.resolve(this.fileOptions.dir??j2.tmpdir());this.tempDir=U2(Xe.join(e,"inquirer-editor-"));let t=$2(),r=ot(this.fileOptions.prefix),n=ot(this.fileOptions.postfix),i=`${r}${t}${n}`;this.tempFile=Xe.join(this.tempDir,i);let a={encoding:"utf8",flag:"wx"};Object.prototype.hasOwnProperty.call(this.fileOptions,"mode")&&(a.mode=this.fileOptions.mode),A2(this.tempFile,this.text,a)}catch(e){throw new H0(e)}}editorArgs(){return[...this.editor.args,this.tempFile]}readTemporaryFile(){try{let e=O2(this.tempFile);if(e.length===0)this.text="";else{let t=(0,ct.detect)(e)??"utf8";ex.default.encodingExists(t)||(t="utf8"),this.text=ex.default.decode(e,t)}}catch(e){throw new z0(e)}}};var N2={validationFailureMode:"keep",style:{loadingMessage:s(()=>"Validating...","loadingMessage"),waitingMessage:s(x=>`Press ${x} to launch your preferred editor.`,"waitingMessage")}},tx=q((x,e)=>{let{waitForUserInput:t=!0,file:{postfix:r=x.postfix??".txt",...n}={},validate:i=s(()=>!0,"validate")}=x,a=O(N2,x.theme),[o,f]=I("idle"),[l="",p]=I(x.default),[d,u]=I(),S=K({status:o,theme:a});async function w(b){b.pause();try{let B=await ft(l,{postfix:r,...n});b.resume(),f("loading");let T=await i(B);T===!0?(u(void 0),f("done"),e(B)):(a.validationFailureMode==="clear"?p(x.default):p(B),u(T||"You must provide a valid value"),f("idle"))}catch(B){b.resume(),u(String(B))}}s(w,"startEditor"),Y(b=>{t||w(b)},[]),W((b,B)=>{o==="idle"&&N(b)&&w(B)});let m=a.style.message(x.message,o),g="";if(o==="loading")g=a.style.help(a.style.loadingMessage());else if(o==="idle"){let b=a.style.key("enter");g=a.style.help(a.style.waitingMessage(b))}let _="";return d&&(_=a.style.error(d)),[[S,m,g].filter(Boolean).join(" "),_]});c();function lt(x,e){let t=e!==!1;return/^(y|yes)/i.test(x)?t=!0:/^(n|no)/i.test(x)&&(t=!1),t}s(lt,"getBooleanValue");function dt(x){return x?"Yes":"No"}s(dt,"boolToString");var rx=q((x,e)=>{let{transformer:t=dt}=x,[r,n]=I("idle"),[i,a]=I(""),o=O(x.theme),f=K({status:r,theme:o});W((u,S)=>{if(r==="idle")if(N(u)){let w=lt(i,x.default);a(t(w)),n("done"),e(w)}else if(y0(u)){let w=dt(!lt(i,x.default));S.clearLine(0),S.write(w),a(w)}else a(S.line)});let l=i,p="";r==="done"?l=o.style.answer(i):p=` ${o.style.defaultAnswer(x.default===!1?"y/N":"Y/n")}`;let d=o.style.message(x.message,r);return`${f} ${d}${p} ${l}`});c();var K2={validationFailureMode:"keep"},nx=q((x,e)=>{let{prefill:t="tab"}=x,r=O(K2,x.theme),[n,i]=I("idle"),[a,o]=I(String(x.default??"")),[f,l]=I(),[p,d]=I(""),u=K({status:n,theme:r});async function S(b){let{required:B,pattern:T,patternError:k="Invalid input"}=x;return B&&!b?"You must provide a value":T&&!T.test(b)?k:typeof x.validate=="function"?await x.validate(b)||"You must provide a valid value":!0}s(S,"validate"),W(async(b,B)=>{if(n==="idle")if(N(b)){let T=p||a;i("loading");let k=await S(T);k===!0?(d(T),i("done"),e(T)):(r.validationFailureMode==="clear"?d(""):B.write(p),l(k),i("idle"))}else w0(b)&&!p?o(""):y0(b)&&!p?(o(""),B.clearLine(0),B.write(a),d(a)):(d(B.line),l(void 0))}),Y(b=>{t==="editable"&&a&&(b.write(a),d(a))},[]);let w=r.style.message(x.message,n),m=p;typeof x.transformer=="function"?m=x.transformer(p,{isFinal:n==="done"}):n==="done"&&(m=r.style.answer(p));let g;a&&n!=="done"&&!p&&(g=r.style.defaultAnswer(a));let _="";return f&&(_=r.style.error(f)),[[u,w,g,m].filter(b=>b!==void 0).join(" "),_]});c();var W2={style:{maskedText:"[input is masked]"}},sx=q((x,e)=>{let{validate:t=s(()=>!0,"validate")}=x,r=O(W2,x.theme),[n,i]=I("idle"),[a,o]=I(),[f,l]=I(""),p=K({status:n,theme:r});W(async(m,g)=>{if(n==="idle")if(N(m)){let _=f;i("loading");let b=await t(_);b===!0?(l(_),i("done"),e(_)):(g.write(f),o(b||"You must provide a valid value"),i("idle"))}else l(g.line),o(void 0)});let d=r.style.message(x.message,n),u="",S;x.mask?u=(typeof x.mask=="string"?x.mask:"*").repeat(f.length):n!=="done"&&(S=`${r.style.help(r.style.maskedText)}${m0}`),n==="done"&&(u=r.style.answer(u));let w="";return a&&(w=r.style.error(a)),[[p,d,x.mask?u:S].join(" "),w]});c();import{styleText as F0}from"node:util";var q2={icon:{cursor:Q.pointer},style:{disabled:s(x=>F0("dim",x),"disabled"),description:s(x=>F0("cyan",x),"description"),keysHelpTip:s(x=>x.map(([e,t])=>`${F0("bold",e)} ${F0("dim",t)}`).join(F0("dim"," \u2022 ")),"keysHelpTip")},i18n:{disabledError:"This option is disabled and cannot be selected."},indexMode:"hidden"};function ix(x){return!v.isSeparator(x)&&!x.disabled}s(ix,"isSelectable");function ax(x){return!v.isSeparator(x)}s(ax,"isNavigable");function V2(x){return x.map(e=>{if(v.isSeparator(e))return e;if(typeof e!="object"||e===null||!("value"in e)){let n=String(e);return{value:e,name:n,short:n,disabled:!1}}let t=e.name??String(e.value),r={value:e.value,name:t,short:e.short??t,disabled:e.disabled??!1};return e.description&&(r.description=e.description),r})}s(V2,"normalizeChoices");var ox=q((x,e)=>{let{loop:t=!0,pageSize:r=7}=x,n=O(q2,x.theme),{keybindings:i}=n,[a,o]=I("idle"),f=K({status:a,theme:n}),l=c0(),p=!i.includes("vim"),d=o0(()=>V2(x.choices),[x.choices]),u=o0(()=>{let h=d.findIndex(ax),E=d.findLastIndex(ax);if(h===-1)throw new r0("[select prompt] No selectable choices. All choices are disabled.");return{first:h,last:E}},[d]),S=o0(()=>"default"in x?d.findIndex(h=>ix(h)&&h.value===x.default):-1,[x.default,d]),[w,m]=I(S===-1?u.first:S),g=d[w];if(g==null||v.isSeparator(g))throw new Error("Active index does not point to a choice");let[_,b]=I();W((h,E)=>{if(clearTimeout(l.current),_&&b(void 0),N(h))g.disabled?b(n.i18n.disabledError):(o("done"),e(g.value));else if(x0(h,i)||s0(h,i)){if(E.clearLine(0),t||x0(h,i)&&w!==u.first||s0(h,i)&&w!==u.last){let D=x0(h,i)?-1:1,F=w;do F=(F+D+d.length)%d.length;while(!ax(d[F]));m(F)}}else if(S0(h)&&!Number.isNaN(Number(E.line))){let D=Number(E.line)-1,F=-1,j=d.findIndex(z=>v.isSeparator(z)?!1:(F++,F===D)),e0=d[j];e0!=null&&ix(e0)&&m(j),l.current=setTimeout(()=>{E.clearLine(0)},700)}else if(w0(h))E.clearLine(0);else if(p){let D=E.line.toLowerCase(),F=d.findIndex(j=>v.isSeparator(j)||!ix(j)?!1:j.name.toLowerCase().startsWith(D));F!==-1&&m(F),l.current=setTimeout(()=>{E.clearLine(0)},700)}}),Y(()=>()=>{clearTimeout(l.current)},[]);let B=n.style.message(x.message,a),T=n.style.keysHelpTip([["\u2191\u2193","navigate"],["\u23CE","select"]]),k=0,P=D0({items:d,active:w,renderItem({item:h,isActive:E,index:D}){if(v.isSeparator(h))return k++,` ${h.separator}`;let F=E?n.icon.cursor:" ",j=n.indexMode==="number"?`${D+1-k}. `:"";if(h.disabled){let z=typeof h.disabled=="string"?h.disabled:"(disabled)",J0=E?n.icon.cursor:"-";return n.style.disabled(`${J0} ${j}${h.name} ${z}`)}return(E?n.style.highlight:z=>z)(`${F} ${j}${h.name}`)},pageSize:r,loop:t});if(a==="done")return[f,B,n.style.answer(g.short)].filter(Boolean).join(" ");let{description:U}=g;return`${[[f,B].filter(Boolean).join(" "),P," ",U?n.style.description(U):"",_?n.style.error(_):"",T].filter(Boolean).join(`
|
|
20
|
+
`).trimEnd()}${m0}`});function ht(x){console.log(),x&&p0(x),process.exit(130)}s(ht,"abort");function cx(x){if(x?.name!=="ExitPromptError")throw x;ht()}s(cx,"abortIfCancelled");async function pt(x,e){let t=e?` [${e}]`:"",r=ut.createInterface({input:process.stdin,output:process.stdout});try{return await new Promise((n,i)=>{r.on("SIGINT",()=>i(new Error("interrupted"))),r.on("close",()=>i(new Error("eof"))),r.question(` ${x}${t}: `).then(n,i)})}catch(n){ht(n.message==="eof"?"No answer: stdin is not a terminal and had no input left -- nothing changed.":void 0)}finally{r.close()}}s(pt,"readLine");async function G2(x,e="",{secret:t=!1,multiline:r=!1}={}){if(!process.stdin.isTTY)return(await pt(x,e)).trim()||e;try{return t?(await sx({message:x,mask:!0})).trim()||e:r&&(process.env.VISUAL||process.env.EDITOR)?(await tx({message:x,default:e,postfix:".md"})).trim()||e:(await nx({message:x,default:e||void 0})).trim()||e}catch(n){cx(n)}}s(G2,"prompt");async function bt(x,e,t=!0){if(!t)return e;if(!process.stdin.isTTY)return/^y/i.test((await pt(`${x} [y/n]`,e?"y":"n")).trim());try{return await rx({message:x,default:e})}catch(r){cx(r)}}s(bt,"confirm");function H2(x,e){let t=new Set,r=[];for(let n of x.split(","))n=n.trim(),n&&!t.has(n)&&(t.add(n),r.push(n));if(e?.length){let n=r.filter(i=>!e.includes(i));n.length&&p0(`Unknown values will be skipped downstream: ${n.join(", ")}`)}return r.join(",")}s(H2,"normalizeMulti");var z2=Symbol("other");function mt(x){let{schema:e,uiSchema:t={},formData:r={}}=x,n=new Set(e.required??[]);return(t["ui:order"]??Object.keys(e.properties??{})).map(a=>{let o=e.properties[a],f=t[a]??{},l=f["ui:options"]??{},p=r[a];return{key:a,label:o.title??a,multi:o.type==="array",multiline:f["ui:widget"]==="textarea",boolean:o.type==="boolean",pattern:o.pattern??null,choices:o.items?.enum??o.enum??null,groups:l.groups??null,required:n.has(a),refinable:!!l.refinable,refineInstruction:l.refineInstruction??null,default:Array.isArray(p)?p.join(","):String(p??"")}})}s(mt,"fieldsOf");function Y2(x,e){if(!e)return x;let t=new Map(x.map(i=>[i.value,i])),r=[],n=s((i,a)=>{a.length&&r.push(new v(`\u2500\u2500 ${i} \u2500\u2500`),...a)},"section");for(let[i,a]of Object.entries(e)){let o=a.flatMap(f=>t.get(f)??[]);for(let f of o)t.delete(f.value);n(i,o)}return n("other",[...t.values()]),r}s(Y2,"withGroupHeadings");async function J2(x,e,t){if(!process.stdin.isTTY)return null;let r=new Set(e.split(",").map(n=>n.trim()).filter(Boolean));try{if(x.multi)return(await ge({message:x.label,choices:Y2(t.map(a=>({value:a,checked:r.has(a)})),x.groups)})).join(",");let n=await ox({message:x.label,choices:[...t.map(i=>({name:i,value:i})),{name:"Other (type it)",value:z2}],default:t.includes(e)?e:void 0});return typeof n=="string"?n:null}catch(n){cx(n)}}s(J2,"pickFromChoices");async function Q2(x,e,t=x.choices??null){for(;;){let r=t?.length?await J2(x,e,t):null;if(r??=await G2(x.label,e,{multiline:x.multiline}),x.multi&&r&&(r=H2(r,t)),r&&x.pattern&&!new RegExp(`^(?:${x.pattern})`).test(r)){p0(`'${r}' doesn't match the expected format ${x.pattern} \u2014 try again.`);continue}return r}}s(Q2,"promptOne");async function Z2(x,e,t,r=bt){if(!await r("Refine with Claude?",!1))return e;h0(" Refining via the claude CLI \u2014 this takes a few seconds\u2026");let n;try{let{refinePrompt:i}=await import("./sandbox-KCOIOWUC.js");n=(await i(e,x.refineInstruction??"",t)).trim()}catch(i){return p0(`Refine failed (${i.message}) \u2014 keeping what you typed.`),e}return n?(h0(`
|
|
21
|
+
${n}
|
|
22
|
+
`),await r("Keep this version?",!0)?n:e):(p0("Claude returned no text \u2014 keeping what you typed."),e)}s(Z2,"offerRefine");async function gt(x,e){if(x.boolean){e[x.key]=String(await bt(x.label,x.default==="true"));return}x.choices?.length&&!process.stdin.isTTY&&h0(" Choices: "+x.choices.join(", "));let t=await Q2(x,x.default??"");x.refinable&&t&&(t=await Z2(x,t,e)),(t||x.required)&&(e[x.key]=t)}s(gt,"askField");async function oi(x,e,{intro:t=null,afterField:r}={}){t&&h0(t);let n={};for(let i of mt(x))i.key in e||await gt(n[i.key]?{...i,default:n[i.key]}:i,e),r&&i.key in e&&Object.assign(n,await r(i.key,e));return e}s(oi,"runFormWizard");async function ci(x,e,t,{intro:r=null}={}){r&&h0(r);for(let n of x){if(n.key in e)continue;let i={...fx(n,"",e,{defaults:!1}),default:t(n)};for(let a of mt(lx({prompts:[i]})))await gt(a,e)}return e}s(ci,"runWizard");export{G2 as a,bt as b,mt as c,gt as d,oi as e,ci as f};
|
|
23
|
+
//# sourceMappingURL=chunk-ANDUBI2O.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __sandboxCreateRequire } from "node:module";
|
|
2
|
+
const require = __sandboxCreateRequire(import.meta.url);
|
|
3
|
+
import{r as l}from"./chunk-C4J3VWL3.js";import{M as f,l as i}from"./chunk-OC7PYYEG.js";import{a as n,f as u}from"./chunk-K6GRVJQO.js";u();import{promises as p}from"node:dns";function h(e,o){return`${e}.${o.replace(/^\.+/,"")}`}n(h,"hostFor");function v(e,o){let a=e??f(),s=o??l(),m={};for(let[t,r]of Object.entries(a)){let c=r&&typeof r=="object"?r.feature_router:null;if(!c)continue;let d=c.remote_upstream??void 0;m[t]={hostname:c.hostname??h(t,s.local_domain),k8s:c.k8s??void 0,remoteHostname:c.remote_hostname??(d?h(t,s.remote_domain):void 0),remoteUpstream:d}}return m}n(v,"loadFeatureRouters");function $(e,o){let a=new Set;for(let s of Object.values(v(e,o)))s.hostname&&a.add(s.hostname),s.remoteHostname&&a.add(s.remoteHostname);return[...a].sort()}n($,"ingressHostnames");function _(e){let o;try{o=$()}catch{return null}return o.length?`https://${o[0]}${e.startsWith("/")?e:`/${e}`}`:null}n(_,"featureUrl");var g=n(e=>p.lookup(e,{all:!0}),"platformLookup");async function b(e,o=g){let s=(await Promise.all(e.map(async t=>{try{return{host:t,addresses:(await o(t)).map(r=>r.address)}}catch{return{host:t,addresses:[]}}}))).filter(({addresses:t})=>!t.includes("127.0.0.1"));if(!s.length)return[];let m=s.map(({host:t})=>t);i(`${m.length} routed hostname(s) do not resolve to 127.0.0.1 on this machine:`);for(let{host:t,addresses:r}of s)i(` ${t}: ${r.length?`resolves to ${r.join(", ")}`:"no address"}`);return i(`Add them: echo "127.0.0.1 ${m.join(" ")}" | sudo tee -a /etc/hosts`),i('or run `werkmeister machine setup` (docs/configuration.md: "New hostnames need /etc/hosts entries")'),m}n(b,"warnUnresolvedHosts");export{v as a,$ as b,_ as c,b as d};
|
|
4
|
+
//# sourceMappingURL=chunk-ATYTAZNX.js.map
|