@kaisers-io/refs 0.19.0 → 0.19.1
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/CHANGELOG.md +50 -22
- package/README.md +1 -1
- package/dist/refs.mjs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,56 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.19.1] - 2026-11-08
|
|
9
|
+
|
|
10
|
+
### Security
|
|
11
|
+
|
|
12
|
+
- **Development installs resolve from the public npm registry, and stop on an unsupported Node.**
|
|
13
|
+
The root `.npmrc` now pins `registry=https://registry.npmjs.org/`, so a user-level default
|
|
14
|
+
registry such as a company mirror no longer decides where installs in this repository resolve,
|
|
15
|
+
which trust-policy evidence and advisories they see, or which tarball URLs reach the lockfile. A
|
|
16
|
+
user-level registry for a single scope (`@scope:registry=`) still applies to that scope.
|
|
17
|
+
Its two previous settings were not read by pnpm 12, which takes only auth, registry, TLS and
|
|
18
|
+
proxy settings from `.npmrc`. They now live in `pnpm-workspace.yaml` as `saveExact` and
|
|
19
|
+
`engineStrict`, so `pnpm add` writes exact versions again and `pnpm install --frozen-lockfile`
|
|
20
|
+
fails on a Node outside `engines.node`. The published CLI is unchanged.
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- **A re-run release job can no longer move the GitHub Latest release backwards.** The job that
|
|
25
|
+
creates the GitHub release used to leave Latest to the API, which makes every new release Latest.
|
|
26
|
+
Re-running a failed one for an older version after a newer release had shipped would therefore
|
|
27
|
+
have marked the older version Latest. It now compares the tag with the current Latest release
|
|
28
|
+
and always states the decision, and release entries for different tags are created one at a
|
|
29
|
+
time.
|
|
30
|
+
|
|
31
|
+
- **Every release is now installed from npm on Linux, macOS and Windows after it is published.**
|
|
32
|
+
The release workflow used to test only a tarball it packed itself, on Linux, while the package it
|
|
33
|
+
published was assembled separately and never installed. A new job waits until the registry serves
|
|
34
|
+
the version, installs it the way a user does, and runs the same smoke test that pull requests now
|
|
35
|
+
run on all three platforms: add, list, sync, resolve and remove of a local repository, each
|
|
36
|
+
outcome checked. It runs after publication and cannot stop a release; `CONTRIBUTING.md` says what
|
|
37
|
+
to do when it fails.
|
|
38
|
+
|
|
39
|
+
### Documentation
|
|
40
|
+
|
|
41
|
+
- **`refs edit --remove`, `--decline` and `--undecline` are in the command references.**
|
|
42
|
+
`docs/commands.md` lacked all three and the skill's `COMMANDS.md` lacked `--remove`, although
|
|
43
|
+
they shipped in 0.13.1 and 0.14.0. Both now give the synopsis, the `--json` data each mode
|
|
44
|
+
returns, and its exit codes. A test now fails when a registered command or option is missing
|
|
45
|
+
from either reference.
|
|
46
|
+
|
|
47
|
+
- **The README says how to upgrade.** A new `Upgrading` section gives the commands that move the
|
|
48
|
+
CLI and the skill (or the Codex plugin) to a new release together, notes that a global skill
|
|
49
|
+
install needs `-g` again, and points at `refs doctor` and the changelog for what follows.
|
|
50
|
+
`docs/install.md` and the npm package README link to it.
|
|
51
|
+
|
|
52
|
+
- **`SECURITY.md` is the policy again, and the security model has its own page.** The reporting
|
|
53
|
+
process, supported versions and scope lists stay in `SECURITY.md`, which GitHub shows as the
|
|
54
|
+
repository's security policy. The account of the git processes refs starts, of configured hooks,
|
|
55
|
+
filters and `core.fsmonitor`, and of untrusted checkout content moved unchanged to
|
|
56
|
+
`docs/security.md`. A report now names what a useful one contains.
|
|
57
|
+
|
|
8
58
|
## [0.19.0] - 2026-11-07
|
|
9
59
|
|
|
10
60
|
### Security
|
|
@@ -1918,25 +1968,3 @@ trusted-publishing pipeline end to end.
|
|
|
1918
1968
|
URL-carrying message, and read-only enforcement of managed checkouts via
|
|
1919
1969
|
installed git hooks.
|
|
1920
1970
|
- Agent skill (`skills/refs/`) documenting the investigate/add/maintain workflows.
|
|
1921
|
-
|
|
1922
|
-
[Unreleased]: https://github.com/kaisers-io/refs/compare/v0.12.0...HEAD
|
|
1923
|
-
[0.12.0]: https://github.com/kaisers-io/refs/compare/v0.11.0...v0.12.0
|
|
1924
|
-
[0.11.0]: https://github.com/kaisers-io/refs/compare/v0.10.0...v0.11.0
|
|
1925
|
-
[0.10.0]: https://github.com/kaisers-io/refs/compare/v0.9.0...v0.10.0
|
|
1926
|
-
[0.9.0]: https://github.com/kaisers-io/refs/compare/v0.8.3...v0.9.0
|
|
1927
|
-
[0.8.3]: https://github.com/kaisers-io/refs/compare/v0.8.2...v0.8.3
|
|
1928
|
-
[0.8.2]: https://github.com/kaisers-io/refs/compare/v0.8.1...v0.8.2
|
|
1929
|
-
[0.8.1]: https://github.com/kaisers-io/refs/compare/v0.8.0...v0.8.1
|
|
1930
|
-
[0.8.0]: https://github.com/kaisers-io/refs/compare/v0.7.0...v0.8.0
|
|
1931
|
-
[0.7.0]: https://github.com/kaisers-io/refs/compare/v0.6.1...v0.7.0
|
|
1932
|
-
[0.6.1]: https://github.com/kaisers-io/refs/compare/v0.6.0...v0.6.1
|
|
1933
|
-
[0.6.0]: https://github.com/kaisers-io/refs/compare/v0.5.1...v0.6.0
|
|
1934
|
-
[0.5.1]: https://github.com/kaisers-io/refs/compare/v0.5.0...v0.5.1
|
|
1935
|
-
[0.5.0]: https://github.com/kaisers-io/refs/compare/v0.4.0...v0.5.0
|
|
1936
|
-
[0.4.0]: https://github.com/kaisers-io/refs/compare/v0.3.0...v0.4.0
|
|
1937
|
-
[0.3.0]: https://github.com/kaisers-io/refs/compare/v0.2.0...v0.3.0
|
|
1938
|
-
[0.2.0]: https://github.com/kaisers-io/refs/compare/v0.1.3...v0.2.0
|
|
1939
|
-
[0.1.3]: https://github.com/kaisers-io/refs/compare/v0.1.2...v0.1.3
|
|
1940
|
-
[0.1.2]: https://github.com/kaisers-io/refs/compare/v0.1.1...v0.1.2
|
|
1941
|
-
[0.1.1]: https://github.com/kaisers-io/refs/compare/v0.1.0...v0.1.1
|
|
1942
|
-
[0.1.0]: https://github.com/kaisers-io/refs/releases/tag/v0.1.0
|
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ The `npm:` prefix says which registry the name belongs to, so a package and a re
|
|
|
61
61
|
|
|
62
62
|
## Driving the CLI yourself
|
|
63
63
|
|
|
64
|
-
The agent runs these. Typing one yourself is quicker for some of them, and `refs sync` is the one most people reach for. `refs doctor` is the one to run after updating refs: the CLI and the skill each carry a version, and it says when they have drifted apart.
|
|
64
|
+
The agent runs these. Typing one yourself is quicker for some of them, and `refs sync` is the one most people reach for. `refs doctor` is the one to run after updating refs: the CLI and the skill each carry a version, and it says when they have drifted apart. [Upgrading](https://github.com/kaisers-io/refs#upgrading) has the commands that move both.
|
|
65
65
|
|
|
66
66
|
```bash
|
|
67
67
|
# clones and proposes; nothing is configured yet
|
package/dist/refs.mjs
CHANGED
|
@@ -436,7 +436,7 @@ let o=[],s=[],c=a+1,l=!1,u=!1,d=!1,f=a,p=``;WHILE:for(;c<e.length;){let t=String
|
|
|
436
436
|
/* c8 ignore stop */
|
|
437
437
|
if(n===!1||n===Y||!Rv(n,r))return!1}if(o===l&&s===c)return!0;if(o===l)return n;if(s===c)return o===l-1&&e[o]===``;throw Error(`wtf?`)
|
|
438
438
|
/* c8 ignore stop */
|
|
439
|
-
}braceExpand(){return Av(this.pattern,this.options)}#w(){let{pattern:e}=this;if(this.options.nobrace)return this.braceExpand();let t=57344;for(;e.includes(String.fromCharCode(t));)if(++t>63743)return this.braceExpand();let n=String.fromCharCode(t),r=!1,i=e.replace(jv,(e,t,i)=>{let a=Number(t),o=Number(i);return!Number.isSafeInteger(a)||!Number.isSafeInteger(o)||Math.abs(a-o)+1<100?e:(r=!0,`${n}${t}..${i}${n}`)});if(!r)return this.braceExpand();let a=Av(i,this.options);for(let e of a)for(let t of e.split(`/`)){let e=t.indexOf(`[`);if(e!==-1&&e<t.lastIndexOf(n))return this.braceExpand()}return this.#l=n,a}parse(e){Sv(e);let t=this.options;if(e===`**`)return Y;if(e===``)return``;let{nocase:n,nocaseMagicOnly:r,noext:i=!1,dot:a,normalize:o}=t,s=this.#l,c=s&&e.includes(s)?void 0:Pv(e,i);if(c!==void 0&&(!n||r||e.toUpperCase()===e.toLowerCase()))return this.#d(c);if(this.#c)return Yv;let l=this.#s.get(e);return l||(l=new xv(e,{nocase:n,noext:i,dot:a,normalize:o,...s&&{rangeMark:s}}),this.#s.set(e,l)),l}#T(e){return this.preserveMultipleSlashes?e.split(`/`):this.isWindows&&/^\/\/[^/]+/.test(e)?[``,...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.comment)return!1;if(this.empty)return e===``;if(e===`/`&&t)return!0;let n=this.options,r=this.#g(e);if(!r){if(!t&&!this.#r&&(this.#e||this.#t)&&Lv!==e){Lv=e;let t=this.#p(e);if(t===`no`)return!n.flipNegate&&this.negate;if(t===`yes`)return n.flipNegate?!0:!this.negate}r=this.#_(e)}let i=r.parts,a=this.#n?r.resolved??=this.#v(i):i,o=this.set,s=i[i.length-1];if(!s)for(let e=i.length-2;!s&&e>=0;e--)s=i[e];for(let e=0;e<o.length;e++){let r=o[e],c=t?void 0:this.#a[e];if(c===`base`?Rv(r[0],s):c?this.#m(a,r,c):n.matchBase&&r.length===1?this.#y([s],[s],r,t):this.#y(i,a,r,t))return n.flipNegate?!0:!this.negate}return!n.flipNegate&&this.negate}static defaults(e){return J.defaults(e).Minimatch}};J.Minimatch=Xv,J.escape=Cv,J.unescape=wv;const Zv=/[/\\]/u,Qv={kind:`ignore`},$v=e=>!ae(e)&&e.split(Zv).every(e=>e!==`.`&&e!==`..`),ey=/^!+/u,ty=/^\.?\/+/u,ny=e=>{let t=ey.exec(e)?.[0]??``;return{body:e.slice(t.length).replace(ty,``),negated:t.length%2==1}},ry=e=>ny(e).negated,iy=e=>ny(e).body,ay=/[?[\]{}()]/u,oy=e=>$v(e)&&!ry(e)&&!ay.test(e),sy=(e,t)=>J(e,t),cy=e=>e.replaceAll(/\/+/gu,`/`).replace(/\/$/u,``),ly=e=>{let t=cy(e).split(`/`),n=t.findIndex(e=>e.includes(`*`));return n===-1?Qv:{baseDir:n===0?`.`:t.slice(0,n).join(`/`),kind:`expand-children`,pattern:cy(e),suffix:t.slice(n+1).join(`/`)}},uy=e=>{let t=cy(e).split(`/`).filter(e=>e.includes(`*`));return t.length<=1&&!t.includes(`**`)},dy=e=>{let t=cy(e).split(`/`),n=t.findIndex(e=>e.includes(`*`));return n<=0?`.`:t.slice(0,n).join(`/`)},fy=e=>oy(e)?e.includes(`*`)?uy(e)?ly(e):{baseDir:dy(e),kind:`expand-recursive`,pattern:cy(e)}:{dir:e,kind:`probe-dir`,pattern:e}:Qv,py=/* @__PURE__ */ new Set([`candidate_not_inspected`,`scan_budget_exhausted`,`manifest_unreadable`,`unsupported_pattern`,`workspace_declaration_unparsed`,`workspace_dir_unreadable`,`workspace_file_unreadable`]),my=(e,t)=>t?.name?{name:t.name,path:e}:void 0,hy=e=>{let t=e.map(e=>[e.path,e]),n=[...new Map(t).values()];return n.sort((e,t)=>e.path.localeCompare(t.path)),n},gy=e=>!e.diagnostics.some(e=>py.has(e.kind)),_y=e=>!e.diagnostics.some(e=>e.kind===`no_workspace_declaration`),vy=(e,t)=>e<t?-1:+(e>t),yy=e=>`path`in e?`${e.kind} ${e.path}`:`file`in e?`${e.kind} ${e.file}`:`pattern`in e?`${e.kind} ${e.pattern}`:e.kind,by=e=>e.toSorted((e,t)=>vy(yy(e),yy(t))),xy=e=>!ae(e)&&!e.split(/[/\\]/u).includes(`..`),Sy=(e,t)=>e.kind===`missing`?{kind:`absent`}:e.kind===`outside`?{kind:`unreadable`,reason:`${t} escapes the checkout`}:{kind:`unreadable`,reason:e.code},Cy=async(e,t,n)=>{if(!xy(t))return{kind:`unreadable`,reason:`path escapes the checkout`};let r=await wy(e,t);if(`probe`in r)return r.probe;let i=await Ty(r.real);return`reason`in i?{kind:`unreadable`,reason:i.reason}:i.found===n?{kind:`match`}:{found:i.found,kind:`mismatch`}},wy=async(e,t)=>{let n=await W(e,v(e,t));if(n.kind!==`inside`)return{probe:Sy(n,`path`)};let r=await W(e,v(n.real,`package.json`));return r.kind===`inside`?{real:r.real}:{probe:Sy(r,`manifest`)}},Ty=async e=>{try{let t=JSON.parse(await s(e,`utf8`));return{found:ad(t)}}catch(e){return{reason:e.code??`manifest could not be read or interpreted`}}},Ey=(e,t)=>{let n=e.filter(e=>e.name===t).map(e=>e.path);return n.length===0?{kind:`absent`}:n.length===1?{kind:`found`,path:n[0]}:{kind:`ambiguous`,paths:n.toSorted(vy)}},Dy=`package.json`,Oy=/^\.\/[^\s%?#\\]*$/u,ky=async e=>{try{return(await p(e)).isDirectory()?`directory`:`file`}catch{return`unverifiable`}},Ay=async(e,t)=>{if(!Oy.test(t)||t.includes(`*`))return`not_checked`;let n=v(e,t.slice(2)),r=await W(e,n);return r.kind===`inside`?ky(r.real):r.kind===`missing`&&await Xu(e,n)?`absent`:`unverifiable`},jy=async(e,t,n)=>Array.isArray(t)?{alternatives:await Promise.all(t.map(t=>My(e,t,n+1))),kind:`alternatives`}:{branches:await Promise.all(Object.entries(t).map(async([t,r])=>({condition:t,value:await My(e,r,n+1)}))),kind:`conditions`},My=async(e,t,n)=>t===null?{kind:`excluded`}:n>8?{kind:`unsupported`,reason:`nested deeper than this reports on`}:typeof t==`string`?{kind:`target`,observed:await Ay(e,t),target:t}:typeof t==`object`?jy(e,t,n):{kind:`unsupported`,reason:`unexpected ${typeof t}`},Ny=[`main`,`module`,`types`,`typings`],Py=(e,t)=>{let n=Ny.filter(e=>typeof t[e]==`string`);return Promise.all(n.map(async n=>({from:n,subpath:`.`,value:await My(e,Fy(t[n]),0)})))},Fy=e=>e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`)?e:`./${e}`,Iy=async(e,t)=>{if(typeof t==`string`||Array.isArray(t))return[{from:`exports`,subpath:`.`,value:await My(e,t,0)}];if(t===void 0)return[];if(typeof t!=`object`||!t)return[{from:`exports`,subpath:`.`,value:await My(e,t,0)}];let n=Object.keys(t);return n.length>0&&!n.some(e=>e.startsWith(`.`))?[{from:`exports`,subpath:`.`,value:await My(e,t,0)}]:Promise.all(Object.entries(t).map(async([t,n])=>({from:`exports`,subpath:t,value:await My(e,n,0)})))},Ly=async(e,t)=>{let n=await W(e,v(e,Dy));if(n.kind!==`inside`)return{entries:[],manifest:Dy,reason:n.kind,status:`unverifiable`};try{let r=JSON.parse(await s(n.real,`utf8`));return r.name===t?{entries:[...await Iy(e,r.exports),...await Py(e,r)],manifest:Dy,status:`complete`}:{entries:[],manifest:Dy,reason:`manifest no longer names this package`,status:`unverifiable`}}catch(e){return{entries:[],manifest:Dy,reason:e.code??`manifest could not be read or interpreted`,status:`unverifiable`}}},Ry=Cl.partial({description:!0}),zy=P({default_branch:il,key:sl,tag_format_candidate:fl.nullable(),url:M().min(1)});zy.extend({description:M().default(``),packages:_l(Ry)});const By=zy.extend({description:M().min(1),packages:_l(Cl)}),Vy=P({effective_clone_mode:ul.optional(),head_sha:M().regex(/^[0-9a-f]{40}$/u,`head_sha must be a 40-character lowercase hex string`).optional(),last_error:M().optional(),last_fetched_at:Kc().optional(),pending_proposal_at:Kc().optional()}),Hy=P({refs:hl(e=>e.length>0&&!ml.has(e),()=>`state ref key must be non-empty and not "__proto__", "constructor", or "prototype"`,vc(M(),Vy)).default({})}),Uy=(e,t,n)=>t?.[e]??n[e],Wy=async e=>{try{return await s(e.statePath,`utf8`)}catch(e){if(L(e))return;throw e}},Gy=e=>{try{return JSON.parse(e)}catch{return}},Ky=async e=>{let t=await Wy(e);if(t===void 0)return Hy.parse({});let n=Gy(t);if(n===void 0)return Hy.parse({});let r=Hy.safeParse(n);return r.success?r.data:Hy.parse({})},qy=async(e,t)=>{let n=Hy.safeParse(t);if(!n.success)throw V(w(n.error));await fu(e.statePath,`${JSON.stringify(n.data,void 0,2)}\n`)},Jy=/^\d+\.\d+\.\d+$/u,Yy=/^0+(?=\d)/u,Xy=(e,t)=>{let n=e.replace(Yy,``),r=t.replace(Yy,``);return n.length===r.length?n===r?0:n<r?-1:1:n.length<r.length?-1:1},Zy=(e,t)=>{if(!Jy.test(e)||!Jy.test(t))return;let n=e.split(`.`),r=t.split(`.`);return n.map((e,t)=>Xy(e,r[t]??``)).find(e=>e!==0)??0},Qy=fc({version:M().regex(Jy)}),$y=P({checked_at:Kc(),latest_version:M().regex(Jy)}),eb=async e=>{try{let t=$y.safeParse(JSON.parse(await s(e.updateCachePath,`utf8`)));return t.success?t.data:void 0}catch{return}},tb=async(e,t)=>{try{await p(e.root),await fu(e.updateCachePath,`${JSON.stringify(t,void 0,2)}\n`)}catch{}},nb=(e,t)=>{let n=t-Date.parse(e.checked_at);return n>=0&&n<864e5},rb=async e=>{try{let t=await e(`https://registry.npmjs.org/@kaisers-io%2Frefs/latest`,{signal:AbortSignal.timeout(2e3)});if(t.status!==200)return;let n=Qy.safeParse(await t.json());return n.success?n.data.version:void 0}catch{return}},ib=async e=>{let t=await eb(e.home);if(t!==void 0&&nb(t,e.nowMs))return{latest:t.latest_version,refreshed:!1,stale:!1};let n=await rb(e.fetch);return n===void 0?{latest:t?.latest_version,refreshed:!1,stale:!0}:(await tb(e.home,{checked_at:new Date(e.nowMs).toISOString(),latest_version:n}),{latest:n,refreshed:!0,stale:!1})},ab=(e,t)=>{let n=Zy(e,t);return n!==void 0&&n<0},ob=(e,t)=>`refs ${t} is available (this is ${e}) — update: npm i -g @kaisers-io/refs@latest`,sb=e=>{let t=e.REFS_UPDATE_CHECK?.trim();if(t===`0`)return!1;if(t===`1`)return!0},cb=e=>{let t=e.CI?.trim().toLowerCase();return t!==void 0&&t!==``&&t!==`false`&&t!==`0`},lb={check:!0,notify:!0},ub=e=>{let t=sb(e.env);return t===void 0?(e.updates??lb).check?cb(e.env)?`ci`:`on`:`config`:t?`on`:`env`},db=e=>ub(e)===`on`,fb=e=>db(e)&&(e.updates??lb).notify,pb=async(e,t)=>{let n=await W(e,v(t,`package.json`));if(n.kind===`inside`)try{let e=JSON.parse(await s(n.real,`utf8`));return{name:ad(e),version:od(e)}}catch{return}},mb=async(e,t)=>{let n=await pb(e,v(e,t));if(n===void 0)return{diagnostic:{kind:`manifest_unreadable`,path:t}};let r=my(t,n);return r!==void 0&&n.version!==void 0?{pkg:r,version:n.version}:r===void 0?{diagnostic:{kind:`manifest_missing_name`,path:t}}:{pkg:r}},hb=e=>Object.fromEntries(e.flatMap(e=>e.pkg===void 0||e.version===void 0?[]:[[e.pkg.path,e.version]])),gb=e=>{let t=[],n=[];for(let r of e)r.diagnostic!==void 0&&t.push(r.diagnostic),r.pkg!==void 0&&n.push(r.pkg);return{diagnostics:t,packages:n,versions:hb(e)}},_b=/* @__PURE__ */ new Set([`ENOENT`,`ENOTDIR`]),vb=async(e,t)=>{let n=await W(e,v(t,`package.json`));if(n.kind===`missing`)return`none`;if(n.kind!==`inside`)return`rejected`;try{return await s(n.real,`utf8`),`manifest`}catch{return`rejected`}},yb=async e=>{try{return{entries:await c(e,{withFileTypes:!0})}}catch(e){return{code:e.code??``}}},bb=e=>Promise.all(e.entries.map(t=>vb(e.repoDir,v(e.fullPath,t.name,e.suffix)))),xb=(e,t,n)=>e.filter((e,r)=>n(t[r])).map(e=>e.name),Sb=async e=>{let{baseDir:t,dirs:n,fullPath:r,repoDir:i,suffix:a,symlinks:o}=e,s=e=>se.join(t===`.`?``:t,e,a),[c,l]=await Promise.all([bb({entries:n,fullPath:r,repoDir:i,suffix:a}),bb({entries:o,fullPath:r,repoDir:i,suffix:a})]);return{diagnostics:[...xb(n,c,e=>e===`rejected`).map(e=>({kind:`manifest_unreadable`,path:s(e)})),...xb(o,l,e=>e!==`none`).map(e=>({kind:`candidate_not_inspected`,path:s(e)}))],dirs:xb(n,c,e=>e===`manifest`).map(e=>s(e))}},Cb=async e=>{let t=await mb(e,`.`);return`pkg`in t?[t]:[]},wb=e=>{let t=e.find(e=>e.path===`.`);return t===void 0?[...e]:e.some(e=>e.path!==`.`&&e.name===t.name)?e.filter(e=>e!==t):[...e]},Tb=async e=>{let[t]=await Cb(e);return t!==void 0&&`pkg`in t?t.pkg:void 0},Eb=`package.json`,Db=e=>{let t=cy(e).split(`/`);return t.includes(`**`)?void 0:t.length},Ob=e=>cy(e).split(`/`).some(e=>e.startsWith(`.`)),kb=e=>e===`.`?0:e.split(`/`).length,Ab=e=>{let t=cy(e),n=new Xv(`${t}/${Eb}`),r=new Xv(t);return{couldHold:e=>r.match(e,!0),selects:e=>n.match(se.join(e,Eb))}},jb=e=>({...Ab(e),maxDepth:Db(e),selectsHidden:Ob(e)}),Mb=/* @__PURE__ */ new Set([`ENOENT`,`ENOTDIR`]),Nb=/* @__PURE__ */ new Set([`.git`,`node_modules`]),Pb=e=>e.some(e=>e.name.toLowerCase()===`package.json`&&!e.isDirectory()),Fb=e=>e.some(e=>e.isSymbolicLink()&&!Nb.has(e.name)),Ib=async(e,t)=>{let n=await yb(t);return`code`in n?{answer:Mb.has(n.code)}:(e.budget.entries-=n.entries.length,e.budget.entries<0||Pb(n.entries)||Fb(n.entries)?{answer:!1}:{entries:n.entries})},Lb=async(e,t,n)=>{if(e.budget.dirs<=0||n>32)return!1;--e.budget.dirs;let r=await Ib(e,t);return`answer`in r?r.answer:Rb(e,{dir:t,entries:r.entries},n)},Rb=async(e,t,n)=>{let r=t.entries.filter(e=>e.isDirectory()&&!Nb.has(e.name));for(let i of r)if(!await Lb(e,v(t.dir,i.name),n+1))return!1;return!0},zb=async(e,t)=>{let n=await W(e.repoDir,v(e.repoDir,t));n.kind!==`outside`&&n.kind!==`missing`&&(n.kind===`unreadable`?e.diagnostics.push({kind:`candidate_not_inspected`,path:t}):await Lb(e,n.real,1)||e.diagnostics.push({kind:`candidate_not_inspected`,path:t}))},Bb=()=>({dirs:2e4,entries:2e5}),Vb=/* @__PURE__ */ new Set([`.git`,`node_modules`]),Hb=(e,t)=>{e.diagnostics.push({kind:`scan_budget_exhausted`,path:t,pattern:e.pattern})},Ub=async(e,t,n)=>{if(!e.selects(t)||n.has(t))return;let r=await vb(e.repoDir,v(e.repoDir,t));r===`manifest`&&e.dirs.push(t),r===`rejected`&&e.diagnostics.push({kind:`manifest_unreadable`,path:t})},Wb=(e,t)=>!e.selectsHidden&&t.excluded.coversSubtree(t.relPath),Gb=async(e,t,n)=>!e.couldHold(n.relPath)||Vb.has(t.name)||Wb(e,n)?!1:t.isSymbolicLink()?(Wb(e,n)||await zb(e,n.relPath),!1):t.isDirectory(),Kb=async(e,t)=>{let n=await yb(v(e.repoDir,t));if(`code`in n)_b.has(n.code)||e.diagnostics.push({kind:`workspace_dir_unreadable`,path:t});else if(e.budget.entries-=n.entries.length,e.budget.entries<0)Hb(e,t);else return n.entries},qb=async(e,t,n)=>{if(e.budget.dirs<=0){Hb(e,t.relPath);return}if(--e.budget.dirs,await Ub(e,t.relPath,n),e.maxDepth!==void 0&&kb(t.relPath)>=e.maxDepth)return;let r=await Kb(e,t.relPath);r!==void 0&&await Yb(e,{depth:t.depth,entries:r,relPath:t.relPath},n)},Jb=(e,t)=>se.join(e===`.`?``:e,t),Yb=async(e,t,n)=>{for(let r of t.entries){let i=Jb(t.relPath,r.name);await Gb(e,r,{excluded:n,relPath:i})&&(t.depth+1>32?Hb(e,i):await qb(e,{depth:t.depth+1,relPath:i},n))}},Xb=async(e,t)=>{let n=await W(e,v(e,t));if(n.kind!==`inside`)return n.kind===`missing`?{diagnostics:[],dirs:[]}:{diagnostics:[{kind:`workspace_dir_unreadable`,path:t}],dirs:[]}},Zb=async(e,t,n)=>{let r=await Xb(e,t.baseDir);if(r!==void 0)return r;let i={...jb(t.pattern),budget:n.budget,diagnostics:[],dirs:[],pattern:t.pattern,repoDir:e};return await qb(i,{depth:1,relPath:t.baseDir},n.excluded),{diagnostics:i.diagnostics,dirs:i.dirs}},Qb=(e,t)=>se.join(e.baseDir===`.`?``:e.baseDir,t,e.suffix),$b=(e,t)=>sy(Qb(t,e.name),t.pattern),ex=async(e,t)=>{let n=v(e,t),r=await W(e,n);if(r.kind===`missing`)return{result:{diagnostics:[],dirs:[]}};if(r.kind!==`inside`)return{result:{diagnostics:[{kind:`workspace_dir_unreadable`,path:t}],dirs:[]}};let i=await yb(n);return`code`in i?{result:_b.has(i.code)?{diagnostics:[],dirs:[]}:{diagnostics:[{kind:`workspace_dir_unreadable`,path:t}],dirs:[]}}:{entries:i.entries}},tx=async(e,t,n)=>{let{baseDir:r}=t,i=await ex(e,r);if(`result`in i)return i.result;let a=e=>$b(e,t)&&!n.has(Qb(t,e.name)),o={entries:i.entries};return Sb({baseDir:r,dirs:o.entries.filter(e=>e.isDirectory()&&a(e)),fullPath:v(e,r),repoDir:e,suffix:t.suffix,symlinks:o.entries.filter(e=>e.isSymbolicLink()&&a(e))})},nx=async(e,t)=>{let n=await vb(e,v(e,t));return n===`manifest`?{diagnostics:[],dirs:[cy(t)]}:n===`rejected`?{diagnostics:[{kind:`manifest_unreadable`,path:t}],dirs:[]}:{diagnostics:[],dirs:[]}},rx=(e,t,n)=>{let{excluded:r}=n,i=fy(t.body);return i.kind===`expand-children`?tx(e,i,r):i.kind===`expand-recursive`?Zb(e,i,n):i.kind===`probe-dir`?r.has(cy(i.dir))?Promise.resolve({diagnostics:[],dirs:[]}):nx(e,i.dir):Promise.resolve({diagnostics:[{kind:`unsupported_pattern`,pattern:t.declared}],dirs:[]})},ix=(e,t)=>sy(iy(e),iy(t)),ax=e=>({negations:e.filter(e=>ry(e)),patterns:e.filter(e=>!ry(e))}),ox=e=>{let t=e.reduce((e,t)=>ry(t)?{negations:[...e.negations,t],patterns:e.patterns}:{negations:e.negations.filter(e=>!ix(t,e)),patterns:[...e.patterns,t]},{negations:[],patterns:[]});return{negations:t.negations,patterns:t.patterns.filter(e=>!t.negations.some(t=>ix(e,t)))}},sx=e=>e.endsWith(`/`)?e:`${e}/`,cx=(e,t)=>e.some(e=>sy(sx(t),sx(iy(e)))),lx=(e,t)=>{let n=iy(e);return n.endsWith(`/**`)&&sy(t,n.slice(0,-3))},ux=e=>({coversSubtree:t=>e.some(e=>lx(e,t)),has:t=>cx(e,t)}),dx=e=>{let t=/* @__PURE__ */ new Set,n=[];for(let r of e)r.dirs.forEach(e=>t.add(e)),n.push(...r.diagnostics);return{diagnostics:n,dirs:[...t]}},fx=async(e,t,n)=>{let{negations:r,patterns:i}=t,a=ux(r),o=dx(await Promise.all(i.map(t=>rx(e,{body:iy(t),declared:t},{budget:n,excluded:a}))));return{diagnostics:o.diagnostics,dirs:o.dirs}},px=async(e,t)=>{let n=ox(t.npm),r=ax(t.pnpm),i=Bb(),a=await Promise.all([fx(e,n,i),fx(e,r,i)]);return dx(a)},mx=async e=>{let t=await pd(e);if(t.npm.length===0&&t.pnpm.length===0)return{diagnostics:by([...t.diagnostics,{kind:`no_workspace_declaration`}]),packages:[],versions:{}};let n=await px(e,t),[r,i]=await Promise.all([Cb(e),Promise.all(n.dirs.map(t=>mb(e,t)))]),a=gb([...r,...i]);return{diagnostics:by([...t.diagnostics,...n.diagnostics,...a.diagnostics]),packages:wb(hy(a.packages)),versions:a.versions}},hx=()=>{},gx={stop:hx,update:hx},_x={frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],interval:80},vx={frames:[`-`,`\\`,`|`,`/`],interval:130},yx=`\r\x1B[K`,bx={24:`\x1B[38;2;7;210;86m`,4:`\x1B[32m`,8:`\x1B[38;5;41m`},xx=/[^ -~]/gu,Sx=(e,t)=>t.isTTY===!0&&e.TERM!==`dumb`&&!cb(e)&&e.REFS_PROGRESS?.trim()!==`0`,Cx=/* @__PURE__ */ new Set([`alacritty`,`rxvt-unicode`,`rxvt-unicode-256color`,`xterm-256color`]),wx=(e,t)=>t===`win32`?!!e.WT_SESSION||!!e.TERMINUS_SUBLIME||e.ConEmuTask===`{cmd::Cmder}`||e.TERM_PROGRAM===`Terminus-Sublime`||e.TERM_PROGRAM===`vscode`||e.TERMINAL_EMULATOR===`JetBrains-JediTerm`||Cx.has(e.TERM??``):e.TERM!==`linux`,Tx=(e,t)=>e.replaceAll(xx,`?`).slice(0,Math.max(0,t)),Ex=(e,t,n)=>{let r=(e.stream.columns??80)-3,i=bx[e.stream.getColorDepth?.(e.env)??1],a=i===void 0?t:`${i}${t}[39m`;return`${yx}${a} ${Tx(n,r)}`},Dx=e=>{if(!Sx(e.env,e.stream))return gx;let{frames:t,interval:n}=wx(e.env,e.platform)?_x:vx,r={drawn:!1,index:0,stopped:!1,text:``},i=()=>{e.stream.write(Ex(e,t[r.index%t.length]??``,r.text)),r.drawn=!0,r.index+=1},a={},o=()=>{i(),a.ticker=setInterval(i,n).unref()};return{stop:()=>{r.stopped=!0,clearTimeout(a.delay),clearInterval(a.ticker),r.drawn&&=(e.stream.write(yx),!1)},update:e=>{r.stopped||(r.text=e,a.delay??=setTimeout(o,100).unref())}}};var Ox=`0.19.0`;const kx=async()=>{let e=[];for await(let t of process.stdin)e.push(Buffer.from(t));return Buffer.concat(e).toString(`utf8`)},Ax=()=>{try{return me()}catch{return``}},jx=()=>({cliVersion:Ox,cwd:process.cwd(),env:process.env,errLine:e=>{process.stderr.write(`${e}\n`)},fetcher:(e,t)=>fetch(e,t),homedir:Ax(),nodeVersion:process.version,out:e=>{process.stdout.write(`${e}\n`)},readStdin:kx,runner:new sp({defaultTimeoutMs:Lp(process.env),env:process.env}),spinner:()=>Dx({env:process.env,platform:process.platform,stream:process.stderr})});var Mx=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},Nx=class extends Mx{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}},Px=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,t)=>{if(!this.argChoices.includes(e))throw new Nx(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,t):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Fx(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}var Ix=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(e=>Fx(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(t?` `+t:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=/* @__PURE__ */ new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
|
|
439
|
+
}braceExpand(){return Av(this.pattern,this.options)}#w(){let{pattern:e}=this;if(this.options.nobrace)return this.braceExpand();let t=57344;for(;e.includes(String.fromCharCode(t));)if(++t>63743)return this.braceExpand();let n=String.fromCharCode(t),r=!1,i=e.replace(jv,(e,t,i)=>{let a=Number(t),o=Number(i);return!Number.isSafeInteger(a)||!Number.isSafeInteger(o)||Math.abs(a-o)+1<100?e:(r=!0,`${n}${t}..${i}${n}`)});if(!r)return this.braceExpand();let a=Av(i,this.options);for(let e of a)for(let t of e.split(`/`)){let e=t.indexOf(`[`);if(e!==-1&&e<t.lastIndexOf(n))return this.braceExpand()}return this.#l=n,a}parse(e){Sv(e);let t=this.options;if(e===`**`)return Y;if(e===``)return``;let{nocase:n,nocaseMagicOnly:r,noext:i=!1,dot:a,normalize:o}=t,s=this.#l,c=s&&e.includes(s)?void 0:Pv(e,i);if(c!==void 0&&(!n||r||e.toUpperCase()===e.toLowerCase()))return this.#d(c);if(this.#c)return Yv;let l=this.#s.get(e);return l||(l=new xv(e,{nocase:n,noext:i,dot:a,normalize:o,...s&&{rangeMark:s}}),this.#s.set(e,l)),l}#T(e){return this.preserveMultipleSlashes?e.split(`/`):this.isWindows&&/^\/\/[^/]+/.test(e)?[``,...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.comment)return!1;if(this.empty)return e===``;if(e===`/`&&t)return!0;let n=this.options,r=this.#g(e);if(!r){if(!t&&!this.#r&&(this.#e||this.#t)&&Lv!==e){Lv=e;let t=this.#p(e);if(t===`no`)return!n.flipNegate&&this.negate;if(t===`yes`)return n.flipNegate?!0:!this.negate}r=this.#_(e)}let i=r.parts,a=this.#n?r.resolved??=this.#v(i):i,o=this.set,s=i[i.length-1];if(!s)for(let e=i.length-2;!s&&e>=0;e--)s=i[e];for(let e=0;e<o.length;e++){let r=o[e],c=t?void 0:this.#a[e];if(c===`base`?Rv(r[0],s):c?this.#m(a,r,c):n.matchBase&&r.length===1?this.#y([s],[s],r,t):this.#y(i,a,r,t))return n.flipNegate?!0:!this.negate}return!n.flipNegate&&this.negate}static defaults(e){return J.defaults(e).Minimatch}};J.Minimatch=Xv,J.escape=Cv,J.unescape=wv;const Zv=/[/\\]/u,Qv={kind:`ignore`},$v=e=>!ae(e)&&e.split(Zv).every(e=>e!==`.`&&e!==`..`),ey=/^!+/u,ty=/^\.?\/+/u,ny=e=>{let t=ey.exec(e)?.[0]??``;return{body:e.slice(t.length).replace(ty,``),negated:t.length%2==1}},ry=e=>ny(e).negated,iy=e=>ny(e).body,ay=/[?[\]{}()]/u,oy=e=>$v(e)&&!ry(e)&&!ay.test(e),sy=(e,t)=>J(e,t),cy=e=>e.replaceAll(/\/+/gu,`/`).replace(/\/$/u,``),ly=e=>{let t=cy(e).split(`/`),n=t.findIndex(e=>e.includes(`*`));return n===-1?Qv:{baseDir:n===0?`.`:t.slice(0,n).join(`/`),kind:`expand-children`,pattern:cy(e),suffix:t.slice(n+1).join(`/`)}},uy=e=>{let t=cy(e).split(`/`).filter(e=>e.includes(`*`));return t.length<=1&&!t.includes(`**`)},dy=e=>{let t=cy(e).split(`/`),n=t.findIndex(e=>e.includes(`*`));return n<=0?`.`:t.slice(0,n).join(`/`)},fy=e=>oy(e)?e.includes(`*`)?uy(e)?ly(e):{baseDir:dy(e),kind:`expand-recursive`,pattern:cy(e)}:{dir:e,kind:`probe-dir`,pattern:e}:Qv,py=/* @__PURE__ */ new Set([`candidate_not_inspected`,`scan_budget_exhausted`,`manifest_unreadable`,`unsupported_pattern`,`workspace_declaration_unparsed`,`workspace_dir_unreadable`,`workspace_file_unreadable`]),my=(e,t)=>t?.name?{name:t.name,path:e}:void 0,hy=e=>{let t=e.map(e=>[e.path,e]),n=[...new Map(t).values()];return n.sort((e,t)=>e.path.localeCompare(t.path)),n},gy=e=>!e.diagnostics.some(e=>py.has(e.kind)),_y=e=>!e.diagnostics.some(e=>e.kind===`no_workspace_declaration`),vy=(e,t)=>e<t?-1:+(e>t),yy=e=>`path`in e?`${e.kind} ${e.path}`:`file`in e?`${e.kind} ${e.file}`:`pattern`in e?`${e.kind} ${e.pattern}`:e.kind,by=e=>e.toSorted((e,t)=>vy(yy(e),yy(t))),xy=e=>!ae(e)&&!e.split(/[/\\]/u).includes(`..`),Sy=(e,t)=>e.kind===`missing`?{kind:`absent`}:e.kind===`outside`?{kind:`unreadable`,reason:`${t} escapes the checkout`}:{kind:`unreadable`,reason:e.code},Cy=async(e,t,n)=>{if(!xy(t))return{kind:`unreadable`,reason:`path escapes the checkout`};let r=await wy(e,t);if(`probe`in r)return r.probe;let i=await Ty(r.real);return`reason`in i?{kind:`unreadable`,reason:i.reason}:i.found===n?{kind:`match`}:{found:i.found,kind:`mismatch`}},wy=async(e,t)=>{let n=await W(e,v(e,t));if(n.kind!==`inside`)return{probe:Sy(n,`path`)};let r=await W(e,v(n.real,`package.json`));return r.kind===`inside`?{real:r.real}:{probe:Sy(r,`manifest`)}},Ty=async e=>{try{let t=JSON.parse(await s(e,`utf8`));return{found:ad(t)}}catch(e){return{reason:e.code??`manifest could not be read or interpreted`}}},Ey=(e,t)=>{let n=e.filter(e=>e.name===t).map(e=>e.path);return n.length===0?{kind:`absent`}:n.length===1?{kind:`found`,path:n[0]}:{kind:`ambiguous`,paths:n.toSorted(vy)}},Dy=`package.json`,Oy=/^\.\/[^\s%?#\\]*$/u,ky=async e=>{try{return(await p(e)).isDirectory()?`directory`:`file`}catch{return`unverifiable`}},Ay=async(e,t)=>{if(!Oy.test(t)||t.includes(`*`))return`not_checked`;let n=v(e,t.slice(2)),r=await W(e,n);return r.kind===`inside`?ky(r.real):r.kind===`missing`&&await Xu(e,n)?`absent`:`unverifiable`},jy=async(e,t,n)=>Array.isArray(t)?{alternatives:await Promise.all(t.map(t=>My(e,t,n+1))),kind:`alternatives`}:{branches:await Promise.all(Object.entries(t).map(async([t,r])=>({condition:t,value:await My(e,r,n+1)}))),kind:`conditions`},My=async(e,t,n)=>t===null?{kind:`excluded`}:n>8?{kind:`unsupported`,reason:`nested deeper than this reports on`}:typeof t==`string`?{kind:`target`,observed:await Ay(e,t),target:t}:typeof t==`object`?jy(e,t,n):{kind:`unsupported`,reason:`unexpected ${typeof t}`},Ny=[`main`,`module`,`types`,`typings`],Py=(e,t)=>{let n=Ny.filter(e=>typeof t[e]==`string`);return Promise.all(n.map(async n=>({from:n,subpath:`.`,value:await My(e,Fy(t[n]),0)})))},Fy=e=>e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`)?e:`./${e}`,Iy=async(e,t)=>{if(typeof t==`string`||Array.isArray(t))return[{from:`exports`,subpath:`.`,value:await My(e,t,0)}];if(t===void 0)return[];if(typeof t!=`object`||!t)return[{from:`exports`,subpath:`.`,value:await My(e,t,0)}];let n=Object.keys(t);return n.length>0&&!n.some(e=>e.startsWith(`.`))?[{from:`exports`,subpath:`.`,value:await My(e,t,0)}]:Promise.all(Object.entries(t).map(async([t,n])=>({from:`exports`,subpath:t,value:await My(e,n,0)})))},Ly=async(e,t)=>{let n=await W(e,v(e,Dy));if(n.kind!==`inside`)return{entries:[],manifest:Dy,reason:n.kind,status:`unverifiable`};try{let r=JSON.parse(await s(n.real,`utf8`));return r.name===t?{entries:[...await Iy(e,r.exports),...await Py(e,r)],manifest:Dy,status:`complete`}:{entries:[],manifest:Dy,reason:`manifest no longer names this package`,status:`unverifiable`}}catch(e){return{entries:[],manifest:Dy,reason:e.code??`manifest could not be read or interpreted`,status:`unverifiable`}}},Ry=Cl.partial({description:!0}),zy=P({default_branch:il,key:sl,tag_format_candidate:fl.nullable(),url:M().min(1)});zy.extend({description:M().default(``),packages:_l(Ry)});const By=zy.extend({description:M().min(1),packages:_l(Cl)}),Vy=P({effective_clone_mode:ul.optional(),head_sha:M().regex(/^[0-9a-f]{40}$/u,`head_sha must be a 40-character lowercase hex string`).optional(),last_error:M().optional(),last_fetched_at:Kc().optional(),pending_proposal_at:Kc().optional()}),Hy=P({refs:hl(e=>e.length>0&&!ml.has(e),()=>`state ref key must be non-empty and not "__proto__", "constructor", or "prototype"`,vc(M(),Vy)).default({})}),Uy=(e,t,n)=>t?.[e]??n[e],Wy=async e=>{try{return await s(e.statePath,`utf8`)}catch(e){if(L(e))return;throw e}},Gy=e=>{try{return JSON.parse(e)}catch{return}},Ky=async e=>{let t=await Wy(e);if(t===void 0)return Hy.parse({});let n=Gy(t);if(n===void 0)return Hy.parse({});let r=Hy.safeParse(n);return r.success?r.data:Hy.parse({})},qy=async(e,t)=>{let n=Hy.safeParse(t);if(!n.success)throw V(w(n.error));await fu(e.statePath,`${JSON.stringify(n.data,void 0,2)}\n`)},Jy=/^\d+\.\d+\.\d+$/u,Yy=/^0+(?=\d)/u,Xy=(e,t)=>{let n=e.replace(Yy,``),r=t.replace(Yy,``);return n.length===r.length?n===r?0:n<r?-1:1:n.length<r.length?-1:1},Zy=(e,t)=>{if(!Jy.test(e)||!Jy.test(t))return;let n=e.split(`.`),r=t.split(`.`);return n.map((e,t)=>Xy(e,r[t]??``)).find(e=>e!==0)??0},Qy=fc({version:M().regex(Jy)}),$y=P({checked_at:Kc(),latest_version:M().regex(Jy)}),eb=async e=>{try{let t=$y.safeParse(JSON.parse(await s(e.updateCachePath,`utf8`)));return t.success?t.data:void 0}catch{return}},tb=async(e,t)=>{try{await p(e.root),await fu(e.updateCachePath,`${JSON.stringify(t,void 0,2)}\n`)}catch{}},nb=(e,t)=>{let n=t-Date.parse(e.checked_at);return n>=0&&n<864e5},rb=async e=>{try{let t=await e(`https://registry.npmjs.org/@kaisers-io%2Frefs/latest`,{signal:AbortSignal.timeout(2e3)});if(t.status!==200)return;let n=Qy.safeParse(await t.json());return n.success?n.data.version:void 0}catch{return}},ib=async e=>{let t=await eb(e.home);if(t!==void 0&&nb(t,e.nowMs))return{latest:t.latest_version,refreshed:!1,stale:!1};let n=await rb(e.fetch);return n===void 0?{latest:t?.latest_version,refreshed:!1,stale:!0}:(await tb(e.home,{checked_at:new Date(e.nowMs).toISOString(),latest_version:n}),{latest:n,refreshed:!0,stale:!1})},ab=(e,t)=>{let n=Zy(e,t);return n!==void 0&&n<0},ob=(e,t)=>`refs ${t} is available (this is ${e}) — update: npm i -g @kaisers-io/refs@latest`,sb=e=>{let t=e.REFS_UPDATE_CHECK?.trim();if(t===`0`)return!1;if(t===`1`)return!0},cb=e=>{let t=e.CI?.trim().toLowerCase();return t!==void 0&&t!==``&&t!==`false`&&t!==`0`},lb={check:!0,notify:!0},ub=e=>{let t=sb(e.env);return t===void 0?(e.updates??lb).check?cb(e.env)?`ci`:`on`:`config`:t?`on`:`env`},db=e=>ub(e)===`on`,fb=e=>db(e)&&(e.updates??lb).notify,pb=async(e,t)=>{let n=await W(e,v(t,`package.json`));if(n.kind===`inside`)try{let e=JSON.parse(await s(n.real,`utf8`));return{name:ad(e),version:od(e)}}catch{return}},mb=async(e,t)=>{let n=await pb(e,v(e,t));if(n===void 0)return{diagnostic:{kind:`manifest_unreadable`,path:t}};let r=my(t,n);return r!==void 0&&n.version!==void 0?{pkg:r,version:n.version}:r===void 0?{diagnostic:{kind:`manifest_missing_name`,path:t}}:{pkg:r}},hb=e=>Object.fromEntries(e.flatMap(e=>e.pkg===void 0||e.version===void 0?[]:[[e.pkg.path,e.version]])),gb=e=>{let t=[],n=[];for(let r of e)r.diagnostic!==void 0&&t.push(r.diagnostic),r.pkg!==void 0&&n.push(r.pkg);return{diagnostics:t,packages:n,versions:hb(e)}},_b=/* @__PURE__ */ new Set([`ENOENT`,`ENOTDIR`]),vb=async(e,t)=>{let n=await W(e,v(t,`package.json`));if(n.kind===`missing`)return`none`;if(n.kind!==`inside`)return`rejected`;try{return await s(n.real,`utf8`),`manifest`}catch{return`rejected`}},yb=async e=>{try{return{entries:await c(e,{withFileTypes:!0})}}catch(e){return{code:e.code??``}}},bb=e=>Promise.all(e.entries.map(t=>vb(e.repoDir,v(e.fullPath,t.name,e.suffix)))),xb=(e,t,n)=>e.filter((e,r)=>n(t[r])).map(e=>e.name),Sb=async e=>{let{baseDir:t,dirs:n,fullPath:r,repoDir:i,suffix:a,symlinks:o}=e,s=e=>se.join(t===`.`?``:t,e,a),[c,l]=await Promise.all([bb({entries:n,fullPath:r,repoDir:i,suffix:a}),bb({entries:o,fullPath:r,repoDir:i,suffix:a})]);return{diagnostics:[...xb(n,c,e=>e===`rejected`).map(e=>({kind:`manifest_unreadable`,path:s(e)})),...xb(o,l,e=>e!==`none`).map(e=>({kind:`candidate_not_inspected`,path:s(e)}))],dirs:xb(n,c,e=>e===`manifest`).map(e=>s(e))}},Cb=async e=>{let t=await mb(e,`.`);return`pkg`in t?[t]:[]},wb=e=>{let t=e.find(e=>e.path===`.`);return t===void 0?[...e]:e.some(e=>e.path!==`.`&&e.name===t.name)?e.filter(e=>e!==t):[...e]},Tb=async e=>{let[t]=await Cb(e);return t!==void 0&&`pkg`in t?t.pkg:void 0},Eb=`package.json`,Db=e=>{let t=cy(e).split(`/`);return t.includes(`**`)?void 0:t.length},Ob=e=>cy(e).split(`/`).some(e=>e.startsWith(`.`)),kb=e=>e===`.`?0:e.split(`/`).length,Ab=e=>{let t=cy(e),n=new Xv(`${t}/${Eb}`),r=new Xv(t);return{couldHold:e=>r.match(e,!0),selects:e=>n.match(se.join(e,Eb))}},jb=e=>({...Ab(e),maxDepth:Db(e),selectsHidden:Ob(e)}),Mb=/* @__PURE__ */ new Set([`ENOENT`,`ENOTDIR`]),Nb=/* @__PURE__ */ new Set([`.git`,`node_modules`]),Pb=e=>e.some(e=>e.name.toLowerCase()===`package.json`&&!e.isDirectory()),Fb=e=>e.some(e=>e.isSymbolicLink()&&!Nb.has(e.name)),Ib=async(e,t)=>{let n=await yb(t);return`code`in n?{answer:Mb.has(n.code)}:(e.budget.entries-=n.entries.length,e.budget.entries<0||Pb(n.entries)||Fb(n.entries)?{answer:!1}:{entries:n.entries})},Lb=async(e,t,n)=>{if(e.budget.dirs<=0||n>32)return!1;--e.budget.dirs;let r=await Ib(e,t);return`answer`in r?r.answer:Rb(e,{dir:t,entries:r.entries},n)},Rb=async(e,t,n)=>{let r=t.entries.filter(e=>e.isDirectory()&&!Nb.has(e.name));for(let i of r)if(!await Lb(e,v(t.dir,i.name),n+1))return!1;return!0},zb=async(e,t)=>{let n=await W(e.repoDir,v(e.repoDir,t));n.kind!==`outside`&&n.kind!==`missing`&&(n.kind===`unreadable`?e.diagnostics.push({kind:`candidate_not_inspected`,path:t}):await Lb(e,n.real,1)||e.diagnostics.push({kind:`candidate_not_inspected`,path:t}))},Bb=()=>({dirs:2e4,entries:2e5}),Vb=/* @__PURE__ */ new Set([`.git`,`node_modules`]),Hb=(e,t)=>{e.diagnostics.push({kind:`scan_budget_exhausted`,path:t,pattern:e.pattern})},Ub=async(e,t,n)=>{if(!e.selects(t)||n.has(t))return;let r=await vb(e.repoDir,v(e.repoDir,t));r===`manifest`&&e.dirs.push(t),r===`rejected`&&e.diagnostics.push({kind:`manifest_unreadable`,path:t})},Wb=(e,t)=>!e.selectsHidden&&t.excluded.coversSubtree(t.relPath),Gb=async(e,t,n)=>!e.couldHold(n.relPath)||Vb.has(t.name)||Wb(e,n)?!1:t.isSymbolicLink()?(Wb(e,n)||await zb(e,n.relPath),!1):t.isDirectory(),Kb=async(e,t)=>{let n=await yb(v(e.repoDir,t));if(`code`in n)_b.has(n.code)||e.diagnostics.push({kind:`workspace_dir_unreadable`,path:t});else if(e.budget.entries-=n.entries.length,e.budget.entries<0)Hb(e,t);else return n.entries},qb=async(e,t,n)=>{if(e.budget.dirs<=0){Hb(e,t.relPath);return}if(--e.budget.dirs,await Ub(e,t.relPath,n),e.maxDepth!==void 0&&kb(t.relPath)>=e.maxDepth)return;let r=await Kb(e,t.relPath);r!==void 0&&await Yb(e,{depth:t.depth,entries:r,relPath:t.relPath},n)},Jb=(e,t)=>se.join(e===`.`?``:e,t),Yb=async(e,t,n)=>{for(let r of t.entries){let i=Jb(t.relPath,r.name);await Gb(e,r,{excluded:n,relPath:i})&&(t.depth+1>32?Hb(e,i):await qb(e,{depth:t.depth+1,relPath:i},n))}},Xb=async(e,t)=>{let n=await W(e,v(e,t));if(n.kind!==`inside`)return n.kind===`missing`?{diagnostics:[],dirs:[]}:{diagnostics:[{kind:`workspace_dir_unreadable`,path:t}],dirs:[]}},Zb=async(e,t,n)=>{let r=await Xb(e,t.baseDir);if(r!==void 0)return r;let i={...jb(t.pattern),budget:n.budget,diagnostics:[],dirs:[],pattern:t.pattern,repoDir:e};return await qb(i,{depth:1,relPath:t.baseDir},n.excluded),{diagnostics:i.diagnostics,dirs:i.dirs}},Qb=(e,t)=>se.join(e.baseDir===`.`?``:e.baseDir,t,e.suffix),$b=(e,t)=>sy(Qb(t,e.name),t.pattern),ex=async(e,t)=>{let n=v(e,t),r=await W(e,n);if(r.kind===`missing`)return{result:{diagnostics:[],dirs:[]}};if(r.kind!==`inside`)return{result:{diagnostics:[{kind:`workspace_dir_unreadable`,path:t}],dirs:[]}};let i=await yb(n);return`code`in i?{result:_b.has(i.code)?{diagnostics:[],dirs:[]}:{diagnostics:[{kind:`workspace_dir_unreadable`,path:t}],dirs:[]}}:{entries:i.entries}},tx=async(e,t,n)=>{let{baseDir:r}=t,i=await ex(e,r);if(`result`in i)return i.result;let a=e=>$b(e,t)&&!n.has(Qb(t,e.name)),o={entries:i.entries};return Sb({baseDir:r,dirs:o.entries.filter(e=>e.isDirectory()&&a(e)),fullPath:v(e,r),repoDir:e,suffix:t.suffix,symlinks:o.entries.filter(e=>e.isSymbolicLink()&&a(e))})},nx=async(e,t)=>{let n=await vb(e,v(e,t));return n===`manifest`?{diagnostics:[],dirs:[cy(t)]}:n===`rejected`?{diagnostics:[{kind:`manifest_unreadable`,path:t}],dirs:[]}:{diagnostics:[],dirs:[]}},rx=(e,t,n)=>{let{excluded:r}=n,i=fy(t.body);return i.kind===`expand-children`?tx(e,i,r):i.kind===`expand-recursive`?Zb(e,i,n):i.kind===`probe-dir`?r.has(cy(i.dir))?Promise.resolve({diagnostics:[],dirs:[]}):nx(e,i.dir):Promise.resolve({diagnostics:[{kind:`unsupported_pattern`,pattern:t.declared}],dirs:[]})},ix=(e,t)=>sy(iy(e),iy(t)),ax=e=>({negations:e.filter(e=>ry(e)),patterns:e.filter(e=>!ry(e))}),ox=e=>{let t=e.reduce((e,t)=>ry(t)?{negations:[...e.negations,t],patterns:e.patterns}:{negations:e.negations.filter(e=>!ix(t,e)),patterns:[...e.patterns,t]},{negations:[],patterns:[]});return{negations:t.negations,patterns:t.patterns.filter(e=>!t.negations.some(t=>ix(e,t)))}},sx=e=>e.endsWith(`/`)?e:`${e}/`,cx=(e,t)=>e.some(e=>sy(sx(t),sx(iy(e)))),lx=(e,t)=>{let n=iy(e);return n.endsWith(`/**`)&&sy(t,n.slice(0,-3))},ux=e=>({coversSubtree:t=>e.some(e=>lx(e,t)),has:t=>cx(e,t)}),dx=e=>{let t=/* @__PURE__ */ new Set,n=[];for(let r of e)r.dirs.forEach(e=>t.add(e)),n.push(...r.diagnostics);return{diagnostics:n,dirs:[...t]}},fx=async(e,t,n)=>{let{negations:r,patterns:i}=t,a=ux(r),o=dx(await Promise.all(i.map(t=>rx(e,{body:iy(t),declared:t},{budget:n,excluded:a}))));return{diagnostics:o.diagnostics,dirs:o.dirs}},px=async(e,t)=>{let n=ox(t.npm),r=ax(t.pnpm),i=Bb(),a=await Promise.all([fx(e,n,i),fx(e,r,i)]);return dx(a)},mx=async e=>{let t=await pd(e);if(t.npm.length===0&&t.pnpm.length===0)return{diagnostics:by([...t.diagnostics,{kind:`no_workspace_declaration`}]),packages:[],versions:{}};let n=await px(e,t),[r,i]=await Promise.all([Cb(e),Promise.all(n.dirs.map(t=>mb(e,t)))]),a=gb([...r,...i]);return{diagnostics:by([...t.diagnostics,...n.diagnostics,...a.diagnostics]),packages:wb(hy(a.packages)),versions:a.versions}},hx=()=>{},gx={stop:hx,update:hx},_x={frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],interval:80},vx={frames:[`-`,`\\`,`|`,`/`],interval:130},yx=`\r\x1B[K`,bx={24:`\x1B[38;2;7;210;86m`,4:`\x1B[32m`,8:`\x1B[38;5;41m`},xx=/[^ -~]/gu,Sx=(e,t)=>t.isTTY===!0&&e.TERM!==`dumb`&&!cb(e)&&e.REFS_PROGRESS?.trim()!==`0`,Cx=/* @__PURE__ */ new Set([`alacritty`,`rxvt-unicode`,`rxvt-unicode-256color`,`xterm-256color`]),wx=(e,t)=>t===`win32`?!!e.WT_SESSION||!!e.TERMINUS_SUBLIME||e.ConEmuTask===`{cmd::Cmder}`||e.TERM_PROGRAM===`Terminus-Sublime`||e.TERM_PROGRAM===`vscode`||e.TERMINAL_EMULATOR===`JetBrains-JediTerm`||Cx.has(e.TERM??``):e.TERM!==`linux`,Tx=(e,t)=>e.replaceAll(xx,`?`).slice(0,Math.max(0,t)),Ex=(e,t,n)=>{let r=(e.stream.columns??80)-3,i=bx[e.stream.getColorDepth?.(e.env)??1],a=i===void 0?t:`${i}${t}[39m`;return`${yx}${a} ${Tx(n,r)}`},Dx=e=>{if(!Sx(e.env,e.stream))return gx;let{frames:t,interval:n}=wx(e.env,e.platform)?_x:vx,r={drawn:!1,index:0,stopped:!1,text:``},i=()=>{e.stream.write(Ex(e,t[r.index%t.length]??``,r.text)),r.drawn=!0,r.index+=1},a={},o=()=>{i(),a.ticker=setInterval(i,n).unref()};return{stop:()=>{r.stopped=!0,clearTimeout(a.delay),clearInterval(a.ticker),r.drawn&&=(e.stream.write(yx),!1)},update:e=>{r.stopped||(r.text=e,a.delay??=setTimeout(o,100).unref())}}};var Ox=`0.19.1`;const kx=async()=>{let e=[];for await(let t of process.stdin)e.push(Buffer.from(t));return Buffer.concat(e).toString(`utf8`)},Ax=()=>{try{return me()}catch{return``}},jx=()=>({cliVersion:Ox,cwd:process.cwd(),env:process.env,errLine:e=>{process.stderr.write(`${e}\n`)},fetcher:(e,t)=>fetch(e,t),homedir:Ax(),nodeVersion:process.version,out:e=>{process.stdout.write(`${e}\n`)},readStdin:kx,runner:new sp({defaultTimeoutMs:Lp(process.env),env:process.env}),spinner:()=>Dx({env:process.env,platform:process.platform,stream:process.stderr})});var Mx=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},Nx=class extends Mx{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}},Px=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,t)=>{if(!this.argChoices.includes(e))throw new Nx(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,t):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Fx(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}var Ix=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(e=>Fx(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(t?` `+t:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=/* @__PURE__ */ new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
|
|
440
440
|
`)}displayWidth(e){return be(e).length}styleTitle(e){return e}styleUsage(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e===`[command]`?this.styleSubcommandText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleCommandText(e)).join(` `)}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleSubcommandText(e)).join(` `)}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){let i=` `.repeat(2);if(!n)return i+e;let a=e.padEnd(t+e.length-r.displayWidth(e)),o=(this.helpWidth??80)-t-2-2,s;return s=o<this.minWidthToWrap||r.preformatted(n)?n:r.boxWrap(n,o).replace(/\n/g,`
|
|
441
441
|
`+` `.repeat(t+2)),i+a+` `.repeat(2)+s.replace(/\n/g,`\n${i}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach(e=>{let n=e.match(r);if(n===null){i.push(``);return}let a=[n.shift()],o=this.displayWidth(a[0]);n.forEach(e=>{let n=this.displayWidth(e);if(o+n<=t){a.push(e),o+=n;return}i.push(a.join(``));let r=e.trimStart();a=[r],o=this.displayWidth(r)}),i.push(a.join(``))}),i.join(`
|
|
442
442
|
`)}},Lx=class{constructor(e,t){this.flags=e,this.description=t||``,this.required=e.includes(`<`),this.optional=e.includes(`[`),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=Bx(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith(`--no-`)),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e==`string`&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,t)=>{if(!this.argChoices.includes(e))throw new Nx(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,t):e},this}name(){return this.long?this.long.replace(/^--/,``):this.short.replace(/^-/,``)}attributeName(){return this.negate?zx(this.name().replace(/^no-/,``)):zx(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},Rx=class{constructor(e){this.positiveOptions=/* @__PURE__ */ new Map,this.negativeOptions=/* @__PURE__ */ new Map,this.dualOptions=/* @__PURE__ */ new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let r=this.negativeOptions.get(n).presetArg,i=r!==void 0&&r;return t.negate===(i===e)}};function zx(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function Bx(e){let t,n,r=/^-[^-]$/,i=/^--[^-]/,a=e.split(/[ |,]+/).concat(`guard`);if(r.test(a[0])&&(t=a.shift()),i.test(a[0])&&(n=a.shift()),!t&&r.test(a[0])&&(t=a.shift()),!t&&i.test(a[0])&&(t=n,n=a.shift()),a[0].startsWith(`-`)){let t=a[0],n=`option creation failed due to '${t}' in option flags '${e}'`;throw/^-[^-][^-]/.test(t)?Error(`${n}
|