@politty/loculus 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +4 -4
  2. package/dist/agent.js +1 -1
  3. package/dist/argv-parser-Chf2pXSm.js +1 -0
  4. package/dist/{cli-main-D4rJTFFd.js → cli-main-B9TTlYuI.js} +2 -2
  5. package/dist/cli-main-DyXwq8CG.js +1 -0
  6. package/dist/cli-run-DDZAhdTV.js +1 -0
  7. package/dist/cli.js +1 -1
  8. package/dist/compile-cache.js +1 -1
  9. package/dist/{completion-Cyw4RN-l.js → completion-B3F-g9jZ.js} +1 -1
  10. package/dist/completion-BKRo7EVU.js +1 -0
  11. package/dist/completion.d.ts +2 -2
  12. package/dist/completion.js +1 -1
  13. package/dist/docs.d.ts +1 -1
  14. package/dist/docs.js +13 -13
  15. package/dist/dynamic-BeM6KMs0.js +1 -0
  16. package/dist/{dynamic-Hg5BDHzz.js → dynamic-eZ7UI_q1.js} +2 -2
  17. package/dist/{import-meta-resolve-DgKm4LYW.js → import-meta-resolve-DQ_owo_7.js} +1 -1
  18. package/dist/index.d.ts +7 -2
  19. package/dist/index.js +1 -1
  20. package/dist/{prompt-fl79dWPz.js → prompt-Bsj8hqe0.js} +1 -1
  21. package/dist/prompt-clack.d.ts +1 -1
  22. package/dist/prompt-clack.js +1 -1
  23. package/dist/prompt-inquirer.d.ts +1 -1
  24. package/dist/prompt-inquirer.js +1 -1
  25. package/dist/prompt.d.ts +6 -2
  26. package/dist/prompt.js +1 -1
  27. package/dist/runner-CRY5255I.js +33 -0
  28. package/dist/runner-DBTjtw2R.js +1 -0
  29. package/dist/{schema--6eHVfwR.js → schema-CuJVxa-M.js} +1 -1
  30. package/dist/schema-extractor-BK1sJx7i.js +1 -0
  31. package/dist/skill.d.ts +1 -1
  32. package/dist/skill.js +1 -1
  33. package/dist/{subcommand-router-iqmWGZyU.js → subcommand-router-40vA6Mka.js} +1 -1
  34. package/dist/{types-Dhar1ua6.d.ts → types-DtQ-Zt3n.d.ts} +17 -7
  35. package/dist/{with-completion-command-yg7HB6Zu.js → with-completion-command-D8AbV0pu.js} +2 -2
  36. package/dist/{with-completion-command-CARvhYvv.d.ts → with-completion-command-QHQsd0Zt.d.ts} +1 -1
  37. package/package.json +5 -5
  38. package/dist/argv-parser-BRSUT6IV.js +0 -1
  39. package/dist/cli-main-CoQp6CjD.js +0 -1
  40. package/dist/cli-run-DABESHM4.js +0 -1
  41. package/dist/completion-BGidlN43.js +0 -1
  42. package/dist/dynamic-BbeRdUqR.js +0 -1
  43. package/dist/runner-D-n1xa2K.js +0 -33
  44. package/dist/runner-nPWQnqQ3.js +0 -1
  45. package/dist/schema-extractor-DFawzmtj.js +0 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @politty/loculus
2
2
 
3
- Politty with [loculus](https://github.com/toiroakr/loculus) flat string-input schemas. Requires Node 24 or newer. Uses the same core command execution, help, docs, completion, prompt, skills and agent functionality as `@politty/zod`.
3
+ Politty with [loculus](https://github.com/toiroakr/loculus) flat string-input schemas. Requires Node.js 22.18.0 or newer. Uses the same core command execution, help, docs, completion, prompt, skills and agent functionality as `@politty/zod`.
4
4
 
5
5
  ```ts
6
6
  import * as l from "loculus";
@@ -43,7 +43,7 @@ Arrays require array inputs by default in Loculus 0.2. Politty collects repeated
43
43
 
44
44
  ## Build-time optimization
45
45
 
46
- Loculus 0.2.4 or newer in the 0.2 line can be used with `@loculus/rolldown` 0.2.2 or newer in the 0.2 line to specialize supported static schemas during the CLI build. The generated validators preserve the metadata used by help, docs, completion and prompts. Dynamic or unsupported definitions retain ordinary validation.
46
+ Loculus 0.2.5 or newer in the 0.2 line can be used with `@loculus/rolldown` 0.2.3 or newer in the 0.2 line to specialize supported static schemas during the CLI build. The generated validators preserve the metadata used by help, docs, completion and prompts. Dynamic or unsupported definitions retain ordinary validation.
47
47
 
48
48
  ```ts
49
49
  import { defineConfig } from "tsdown";
@@ -55,11 +55,11 @@ export default defineConfig({
55
55
  });
56
56
  ```
57
57
 
58
- The plugin requires Node.js 24 or newer at build time and Rolldown `>=1.2.13 <2`. It is optional and belongs in the CLI project's devDependencies.
58
+ The plugin requires Node.js 22.18.0 or newer at build time and Rolldown `>=1.2.13 <2`. It is optional and belongs in the CLI project's devDependencies.
59
59
 
60
60
  ## Development
61
61
 
62
- The adapter uses the published `loculus` 0.2.4 package for development and requires `loculus ^0.2.4` at runtime. No local archive or adjacent loculus checkout is needed.
62
+ The adapter uses the published `loculus` 0.2.5 package for development and requires `loculus ^0.2.5` at runtime. No local archive or adjacent loculus checkout is needed.
63
63
 
64
64
  This repository's first-package release procedure in CLAUDE.md applies to `@politty/loculus`.
65
65
 
package/dist/agent.js CHANGED
@@ -1 +1 @@
1
- import{t as e}from"./detect-agent-D7KSeWMh.js";export{e as detectAgent};
1
+ export{t as detectAgent}from"./detect-agent-D7KSeWMh.js";
@@ -0,0 +1 @@
1
+ import{i as e,o as t}from"./registry-BEz5iex_.js";const n=/* @__PURE__ */ new Set([`1`,`t`,`T`,`TRUE`,`true`,`True`]),r=/* @__PURE__ */ new Set([`0`,`f`,`F`,`FALSE`,`false`,`False`]);function i(e){return n.has(e)?!0:!r.has(e)&&e}function a(e,t){return t===`boolean`?i(e):e}function o(e){let t=e.indexOf(`=`);return t>=0?e.slice(2,t):e.slice(2)}function s(e,t){let n=o(e);if(!e.includes(`=`)){let e=t.negationMap.get(n);if(e&&t.booleanFlags.has(e))return{resolvedName:e,withoutDashes:n,isNegated:!0,isCustomNegation:!0,isSuppressedNegation:!1}}let r=e.includes(`=`);if(!r&&n.startsWith(`no-`)){let e=n.slice(3);if(e===e.toLowerCase()){let r=t.aliasMap.get(e)??e;if(t.booleanFlags.has(r)){let e=t.aliasMap.get(n)??n;if(!t.definedNames.has(e))return t.defaultNegationDisabledFields.has(r)?{resolvedName:r,withoutDashes:n,isNegated:!1,isCustomNegation:!1,isSuppressedNegation:!0}:{resolvedName:r,withoutDashes:n,isNegated:!0,isCustomNegation:!1,isSuppressedNegation:!1}}}}if(!r&&n.length>2&&n.startsWith(`no`)&&/[A-Z]/.test(n[2])){let e=n[2].toLowerCase()+n.slice(3),r=t.aliasMap.get(e)??e;if(t.booleanFlags.has(r)){let e=t.aliasMap.get(n)??n;if(!t.definedNames.has(e))return t.defaultNegationDisabledFields.has(r)?{resolvedName:r,withoutDashes:n,isNegated:!1,isCustomNegation:!1,isSuppressedNegation:!0}:{resolvedName:r,withoutDashes:n,isNegated:!0,isCustomNegation:!1,isSuppressedNegation:!1}}}return{resolvedName:t.aliasMap.get(n)??n,withoutDashes:n,isNegated:!1,isCustomNegation:!1,isSuppressedNegation:!1}}const c=/^-\.?\d/;function l(e){return c.test(e)}function u(e,t={}){let{aliasMap:n=/* @__PURE__ */ new Map,booleanFlags:r=/* @__PURE__ */ new Set,arrayFlags:a=/* @__PURE__ */ new Set,definedNames:o=/* @__PURE__ */ new Set,negationMap:c=/* @__PURE__ */ new Map,defaultNegationDisabledFields:u,unknownFlagsTakeNoValue:d=!1}=t,f=u??new Set(r),p=e=>r.has(e)||d&&!o.has(e),m={aliasMap:n,booleanFlags:r,definedNames:o,negationMap:c,defaultNegationDisabledFields:f},h={options:{},positionals:[],rest:[]},g=0,_=!1,v=(e,t)=>{let r=n.get(e)??e;if(a.has(r)){let e=h.options[r];Array.isArray(e)?e.push(t):e===void 0?h.options[r]=[t]:h.options[r]=[e,t]}else h.options[r]=t};for(;g<e.length;){let t=e[g];if(_)h.rest.push(t),g++;else if(t===`--`)_=!0,g++;else if(t.startsWith(`--`)){let a=t.slice(2),o=s(t,m);if(o.isSuppressedNegation){v(o.withoutDashes,!0),g++;continue}if(o.isNegated){v(o.resolvedName,!1),g++;continue}let c=a.indexOf(`=`);if(c!==-1){let e=a.slice(0,c),t=a.slice(c+1),o=n.get(e)??e;v(e,r.has(o)?i(t):t),g++}else{let t=a;if(p(n.get(t)??t))v(t,!0),g++;else{let n=e[g+1];n!==void 0&&(!n.startsWith(`-`)||l(n))?(v(t,n),g+=2):(v(t,!0),g++)}}}else if(t.startsWith(`-`)&&t.length>1&&!t.startsWith(`--`)){let a=t.slice(1),o=a.indexOf(`=`);if(o!==-1){let e=a.slice(0,o),t=a.slice(o+1),s=n.get(e)??e;v(e,r.has(s)?i(t):t),g++}else if(a.length===1){let t=a;if(p(n.get(t)??t))v(t,!0),g++;else{let n=e[g+1];n!==void 0&&(!n.startsWith(`-`)||l(n))?(v(t,n),g+=2):(v(t,!0),g++)}}else{for(let e of a)v(e,!0);g++}}else h.positionals.push(t),g++}return h}function d(n){let r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Set,o=/* @__PURE__ */ new Set,s=/* @__PURE__ */ new Map,c=/* @__PURE__ */ new Set;for(let e of n.fields)o.add(e.name);for(let l of n.fields){if(!l.named)continue;l.cliName!==l.name&&r.set(l.cliName,l.name);for(let n of e(l))if(r.set(n,l.name),n.length>1&&n.includes(`-`)){let e=t(n);e!==n&&!o.has(e)&&!r.has(e)&&r.set(e,l.name)}let n=t(l.name);if(n!==l.name&&!o.has(n)&&!r.has(n)&&r.set(n,l.name),l.type===`boolean`&&i.add(l.name),l.type===`array`&&a.add(l.name),l.type===`boolean`&&l.negation!==!0&&(c.add(l.name),typeof l.negation==`string`&&(s.set(l.negation,l.name),l.negation.includes(`-`)))){let e=t(l.negation);e!==l.negation&&s.set(e,l.name)}}return{aliasMap:r,booleanFlags:i,arrayFlags:a,definedNames:o,negationMap:s,defaultNegationDisabledFields:c}}function f(e,t){return e.fields.filter(e=>e.positional&&!(e.named&&Object.hasOwn(t,e.name)))}function p(e,t){let n={...e.options},r=t.fields.filter(e=>e.positional),i=e.rest.length>0?[...e.positionals,...e.rest]:e.positionals;for(let e of r)e.named||delete n[e.name];let a=0;for(let r of f(t,e.options)){if(a>=i.length)break;if(r.type===`array`){n[r.name]=i.slice(a);break}n[r.name]=i[a],a++}return n}export{o as a,a as c,f as i,p as n,s as o,u as r,i as s,d as t};
@@ -1,2 +1,2 @@
1
- import{d as e,u as t}from"./schema-extractor-DFawzmtj.js";import{n}from"./command-BXsTrIgI.js";import{n as r}from"./runner-D-n1xa2K.js";import{chmodSync as i,existsSync as a,mkdirSync as o,readFileSync as s,writeFileSync as c}from"node:fs";import{basename as l,dirname as u,extname as d,isAbsolute as f,join as p,relative as m,resolve as h}from"node:path";import{fileURLToPath as g}from"node:url";const _=`Generated by politty: compile-cache bin shim`,v=[`./cli.js`,`./cli.mjs`,`./index.js`,`./index.mjs`];function y(e){let t=h(e);for(;;){let e=p(t,`package.json`);if(a(e))return{pkg:JSON.parse(s(e,`utf8`)),dir:t};let n=u(t);if(n===t)return;t=n}}function b(e){if(!e)return[];if(typeof e.bin==`string`&&e.bin){let t=x(e);return t?[[t,e.bin]]:[]}return typeof e.bin==`object`&&e.bin!==null?Object.entries(e.bin).filter(e=>typeof e[1]==`string`&&e[1]!==``):[]}function x(e){if(e){if(typeof e.bin==`object`&&e.bin!==null){let[t]=Object.keys(e.bin);if(t)return t}if(typeof e.name==`string`&&e.name){let t=e.name;return t.startsWith(`@`)?t.split(`/`)[1]??t:t}}}function S(e){let t=u(e),n=l(e);for(let e of v)if(l(e)!==n&&a(p(t,e)))return e}function C(e,t,n){return[`#!/usr/bin/env node`,``,`// ${_}.`,`// Enables the Node.js on-disk compile cache (V8 code cache) before the`,`// CLI module graph is compiled, so warm starts skip recompilation`,`// (Node >= 22.8.0; silent no-op otherwise).`,`try {`,` const { enableCompileCache } = await import(${JSON.stringify(n)});`,` enableCompileCache(${JSON.stringify(e)});`,`} catch {`,` // ${n} is not resolvable from here (e.g. a fully`,` // bundled CLI) — start without the compile cache rather than failing`,` // the CLI.`,`}`,`await import(${JSON.stringify(t)});`,``].join(`
2
- `)}function w(e){return e===void 0?[]:Array.isArray(e)?e:[e]}function T(e){return(t={})=>E(`${e}/compile-cache`,t)}function E(e,t){let n=t.cwd??process.cwd(),r=y(n),l=r?.pkg,p=w(t.entry),m=w(t.out),T=b(l),E;if(m.length>0){if(p.length>0&&p.length!==m.length)throw Error(`--entry count (${p.length}) does not match --out count (${m.length}); pass one --out per --entry or omit --out entirely.`);E=m.map(e=>f(e)?e:h(n,e))}else{if(T.length===0||r===void 0)throw Error(`Cannot derive the output path: no bin entry in package.json. Pass --out explicitly.`);if(p.length>0&&p.length!==T.length)throw Error(`--entry count (${p.length}) does not match the package's bin entries (${T.length}); pass one --entry per bin (in declaration order) or matching --out paths.`);E=T.map(([,e])=>h(r.dir,e))}if(new Set(E).size!==E.length)throw Error(`Duplicate output paths; each shim needs a distinct output file. Check the --out values (or the bin paths in package.json when --out is omitted).`);let O=/* @__PURE__ */ new Map;if(r)for(let[e,t]of T)O.set(h(r.dir,t),e);let k=[],A=t.compileCacheSpecifier??e;if(/[\r\n\u2028\u2029]/.test(A))throw Error(`Invalid compile-cache specifier ${JSON.stringify(A)}: a module specifier cannot contain a line terminator.`);let j=E.map((e,r)=>{let i=O.get(e),o=t.program??i??x(l);if(!o)throw Error(`Cannot derive a program name: no bin or name in package.json. Pass --program explicitly.`);if(t.program===void 0&&i===void 0&&m.length>0&&k.push(`Warning: ${D(e,n)} does not match any bin path in package.json, so its cache directory uses the program name ${JSON.stringify(o)}. Pass --program to override.`),e.endsWith(`.cjs`))throw Error(`The generated shim is an ES module and cannot be written to a .cjs file. Use a .mjs (or .js in a "type": "module" package) output path.`);if(d(e)===``)throw Error(`The generated shim is an ES module and cannot be written to an extensionless file (it would not load on every supported Node.js version). Use a .mjs (or .js in a "type": "module" package) output path.`);if(e.endsWith(`.js`)&&l?.type!==`module`)throw Error(l===void 0?`The generated shim is an ES module, and no package.json was found to confirm .js files are treated as ESM. Write it to a .mjs file instead (e.g. --out dist/bin.mjs).`:`The generated shim is an ES module, but the package is not "type": "module". Write it to a .mjs file instead (e.g. --out dist/bin.mjs).`);let c=p[r]??S(e);if(c===void 0)throw Error(`Cannot derive an entry: none of ${v.join(`, `)} exist next to ${e}. Pass --entry explicitly.`);if(!c.startsWith(`./`)&&!c.startsWith(`../`)&&!c.startsWith(`file:`))throw Error(`Invalid entry ${c}: pass a specifier relative to the shim file ("./..." or "../...") or a file: URL.`);let f;if(c.startsWith(`file:`))try{f=g(c)}catch{f=void 0}else f=h(u(e),c);if(f===e)throw Error(`The shim at ${e} would import itself (entry ${c}). Point bin at a separate shim path (e.g. dist/bin.js) or pass a different --entry.`);if(a(e)&&!s(e,`utf8`).includes(_))throw Error(`Refusing to overwrite ${e}: it exists and was not generated by politty. If bin currently points at your real CLI entry, point it at a separate shim path (e.g. dist/bin.js) or pass --out explicitly.`);return{outputPath:e,program:o,entry:c,compileCacheSpecifier:A}});for(let e of k)console.warn(e);for(let{outputPath:e,program:t,entry:n}of j)o(u(e),{recursive:!0}),c(e,C(t,n,A)),i(e,493);return j}function D(e,t){let n=m(t,e);return n&&!n.startsWith(`..`)?n:e}const O=t({bin:e.string({description:`CLI binary or built JS entry file to invoke`,placeholder:`PATH`}),program:e.string({description:`Program name embedded in worker metadata`,placeholder:`NAME`}),shell:e.enum([`bash`,`zsh`,`fish`],{description:`Shell worker to generate`,placeholder:`SHELL`}),out:e.optionalString({description:`Output worker path (defaults to dist/completion/<shell>-worker.<ext>)`,placeholder:`PATH`}),verify:e.boolean({description:`Verify __completion-worker-path resolves to the generated worker`})}),k=n({name:`generate-worker`,description:`Generate and verify a bundled shell completion worker`,args:O,async run(e){let{generateBundledCompletionWorker:t}=await import(`./completion-BGidlN43.js`);await t({bin:e.bin,programName:e.program,shell:e.shell,...e.out!==void 0&&{outputPath:e.out},verify:e.verify})}}),A=t({entry:e.optionalStringArray({description:`Module specifier the shim imports, relative to the shim file; repeatable, one per bin/--out (defaults to ./cli.js, ./cli.mjs, ./index.js, or ./index.mjs next to each shim)`,placeholder:`SPECIFIER`}),out:e.optionalStringArray({description:`Output path for the generated shim; repeatable, one per --entry (defaults to the bin paths in package.json)`,placeholder:`PATH`}),program:e.optionalString({description:`Program name for the cache directory, applied to all shims (defaults per shim to its bin name)`,placeholder:`NAME`}),compileCacheSpecifier:e.optionalString({description:`Module specifier the shim imports enableCompileCache from (defaults to the compile-cache subpath of the politty package running this command)`,placeholder:`SPECIFIER`})});function j(e){let t=T(e),i=n({name:`generate-shim`,description:`Generate a compile-cache bin shim that loads the real CLI via dynamic import`,args:A,run(e){let n=process.cwd(),r=t({...e.entry!==void 0&&{entry:e.entry},...e.out!==void 0&&{out:e.out},...e.program!==void 0&&{program:e.program},...e.compileCacheSpecifier!==void 0&&{compileCacheSpecifier:e.compileCacheSpecifier},cwd:n});for(let e of r)console.log(`Generated compile-cache shim: ${D(e.outputPath,n)} (program: ${e.program}, entry: ${e.entry}, compile-cache: ${e.compileCacheSpecifier})`)}}),a=n({name:`politty`,description:`politty development utilities`,subCommands:{"generate-shim":i,"generate-worker":k}});return r(a).catch(e=>{console.error(e instanceof Error?e.message:String(e)),process.exit(1)})}export{T as n,j as t};
1
+ import{d as e,u as t}from"./schema-extractor-BK1sJx7i.js";import{n}from"./command-BXsTrIgI.js";import{n as r}from"./runner-CRY5255I.js";import{chmodSync as i,existsSync as a,mkdirSync as o,readFileSync as s,writeFileSync as c}from"node:fs";import{basename as l,dirname as u,extname as d,isAbsolute as f,join as p,relative as m,resolve as h}from"node:path";import{fileURLToPath as g}from"node:url";const _=`Generated by politty: compile-cache bin shim`,v=[`./cli.js`,`./cli.mjs`,`./index.js`,`./index.mjs`];function y(e){let t=h(e);for(;;){let e=p(t,`package.json`);if(a(e))return{pkg:JSON.parse(s(e,`utf8`)),dir:t};let n=u(t);if(n===t)return;t=n}}function b(e){if(!e)return[];if(typeof e.bin==`string`&&e.bin){let t=x(e);return t?[[t,e.bin]]:[]}return typeof e.bin==`object`&&e.bin!==null?Object.entries(e.bin).filter(e=>typeof e[1]==`string`&&e[1]!==``):[]}function x(e){if(e){if(typeof e.bin==`object`&&e.bin!==null){let[t]=Object.keys(e.bin);if(t)return t}if(typeof e.name==`string`&&e.name){let t=e.name;return t.startsWith(`@`)?t.split(`/`)[1]??t:t}}}function S(e){let t=u(e),n=l(e);for(let e of v)if(l(e)!==n&&a(p(t,e)))return e}function C(e,t,n){return[`#!/usr/bin/env node`,``,`// ${_}.`,`// Enables the Node.js on-disk compile cache (V8 code cache) before the`,`// CLI module graph is compiled, so warm starts skip recompilation`,`// (Node >= 22.8.0; silent no-op otherwise).`,`try {`,` const { enableCompileCache } = await import(${JSON.stringify(n)});`,` enableCompileCache(${JSON.stringify(e)});`,`} catch {`,` // ${n} is not resolvable from here (e.g. a fully`,` // bundled CLI) — start without the compile cache rather than failing`,` // the CLI.`,`}`,`await import(${JSON.stringify(t)});`,``].join(`
2
+ `)}function w(e){return e===void 0?[]:Array.isArray(e)?e:[e]}function T(e){return(t={})=>E(`${e}/compile-cache`,t)}function E(e,t){let n=t.cwd??process.cwd(),r=y(n),l=r?.pkg,p=w(t.entry),m=w(t.out),T=b(l),E;if(m.length>0){if(p.length>0&&p.length!==m.length)throw Error(`--entry count (${p.length}) does not match --out count (${m.length}); pass one --out per --entry or omit --out entirely.`);E=m.map(e=>f(e)?e:h(n,e))}else{if(T.length===0||r===void 0)throw Error(`Cannot derive the output path: no bin entry in package.json. Pass --out explicitly.`);if(p.length>0&&p.length!==T.length)throw Error(`--entry count (${p.length}) does not match the package's bin entries (${T.length}); pass one --entry per bin (in declaration order) or matching --out paths.`);E=T.map(([,e])=>h(r.dir,e))}if(new Set(E).size!==E.length)throw Error(`Duplicate output paths; each shim needs a distinct output file. Check the --out values (or the bin paths in package.json when --out is omitted).`);let O=/* @__PURE__ */ new Map;if(r)for(let[e,t]of T)O.set(h(r.dir,t),e);let k=[],A=t.compileCacheSpecifier??e;if(/[\r\n\u2028\u2029]/.test(A))throw Error(`Invalid compile-cache specifier ${JSON.stringify(A)}: a module specifier cannot contain a line terminator.`);let j=E.map((e,r)=>{let i=O.get(e),o=t.program??i??x(l);if(!o)throw Error(`Cannot derive a program name: no bin or name in package.json. Pass --program explicitly.`);if(t.program===void 0&&i===void 0&&m.length>0&&k.push(`Warning: ${D(e,n)} does not match any bin path in package.json, so its cache directory uses the program name ${JSON.stringify(o)}. Pass --program to override.`),e.endsWith(`.cjs`))throw Error(`The generated shim is an ES module and cannot be written to a .cjs file. Use a .mjs (or .js in a "type": "module" package) output path.`);if(d(e)===``)throw Error(`The generated shim is an ES module and cannot be written to an extensionless file (it would not load on every supported Node.js version). Use a .mjs (or .js in a "type": "module" package) output path.`);if(e.endsWith(`.js`)&&l?.type!==`module`)throw Error(l===void 0?`The generated shim is an ES module, and no package.json was found to confirm .js files are treated as ESM. Write it to a .mjs file instead (e.g. --out dist/bin.mjs).`:`The generated shim is an ES module, but the package is not "type": "module". Write it to a .mjs file instead (e.g. --out dist/bin.mjs).`);let c=p[r]??S(e);if(c===void 0)throw Error(`Cannot derive an entry: none of ${v.join(`, `)} exist next to ${e}. Pass --entry explicitly.`);if(!c.startsWith(`./`)&&!c.startsWith(`../`)&&!c.startsWith(`file:`))throw Error(`Invalid entry ${c}: pass a specifier relative to the shim file ("./..." or "../...") or a file: URL.`);let f;if(c.startsWith(`file:`))try{f=g(c)}catch{f=void 0}else f=h(u(e),c);if(f===e)throw Error(`The shim at ${e} would import itself (entry ${c}). Point bin at a separate shim path (e.g. dist/bin.js) or pass a different --entry.`);if(a(e)&&!s(e,`utf8`).includes(_))throw Error(`Refusing to overwrite ${e}: it exists and was not generated by politty. If bin currently points at your real CLI entry, point it at a separate shim path (e.g. dist/bin.js) or pass --out explicitly.`);return{outputPath:e,program:o,entry:c,compileCacheSpecifier:A}});for(let e of k)console.warn(e);for(let{outputPath:e,program:t,entry:n}of j)o(u(e),{recursive:!0}),c(e,C(t,n,A)),i(e,493);return j}function D(e,t){let n=m(t,e);return n&&!n.startsWith(`..`)?n:e}const O=t({bin:e.string({description:`CLI binary or built JS entry file to invoke`,placeholder:`PATH`}),program:e.string({description:`Program name embedded in worker metadata`,placeholder:`NAME`}),shell:e.enum([`bash`,`zsh`,`fish`],{description:`Shell worker to generate`,placeholder:`SHELL`}),out:e.optionalString({description:`Output worker path (defaults to dist/completion/<shell>-worker.<ext>)`,placeholder:`PATH`}),verify:e.boolean({description:`Verify __completion-worker-path resolves to the generated worker`})}),k=n({name:`generate-worker`,description:`Generate and verify a bundled shell completion worker`,args:O,async run(e){let{generateBundledCompletionWorker:t}=await import(`./completion-BKRo7EVU.js`);await t({bin:e.bin,programName:e.program,shell:e.shell,...e.out!==void 0&&{outputPath:e.out},verify:e.verify})}}),A=t({entry:e.optionalStringArray({description:`Module specifier the shim imports, relative to the shim file; repeatable, one per bin/--out (defaults to ./cli.js, ./cli.mjs, ./index.js, or ./index.mjs next to each shim)`,placeholder:`SPECIFIER`}),out:e.optionalStringArray({description:`Output path for the generated shim; repeatable, one per --entry (defaults to the bin paths in package.json)`,placeholder:`PATH`}),program:e.optionalString({description:`Program name for the cache directory, applied to all shims (defaults per shim to its bin name)`,placeholder:`NAME`}),compileCacheSpecifier:e.optionalString({description:`Module specifier the shim imports enableCompileCache from (defaults to the compile-cache subpath of the politty package running this command)`,placeholder:`SPECIFIER`})});function j(e){let t=T(e),i=n({name:`generate-shim`,description:`Generate a compile-cache bin shim that loads the real CLI via dynamic import`,args:A,run(e){let n=process.cwd(),r=t({...e.entry!==void 0&&{entry:e.entry},...e.out!==void 0&&{out:e.out},...e.program!==void 0&&{program:e.program},...e.compileCacheSpecifier!==void 0&&{compileCacheSpecifier:e.compileCacheSpecifier},cwd:n});for(let e of r)console.log(`Generated compile-cache shim: ${D(e.outputPath,n)} (program: ${e.program}, entry: ${e.entry}, compile-cache: ${e.compileCacheSpecifier})`)}}),a=n({name:`politty`,description:`politty development utilities`,subCommands:{"generate-shim":i,"generate-worker":k}});return r(a).catch(e=>{console.error(e instanceof Error?e.message:String(e)),process.exit(1)})}export{T as n,j as t};
@@ -0,0 +1 @@
1
+ export{t as runPolittyCli}from"./cli-main-B9TTlYuI.js";
@@ -0,0 +1 @@
1
+ import"./register-Ceh-HlVN.js";const{runPolittyCli:e}=await import(`./cli-main-DyXwq8CG.js`);await e(`@politty/loculus`);export{};
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{n as e}from"./compile-cache-6u9hgeWu.js";e(`politty`),await import(`./cli-run-DABESHM4.js`);export{};
2
+ import{n as e}from"./compile-cache-6u9hgeWu.js";e(`politty`),await import(`./cli-run-DDZAhdTV.js`);export{};
@@ -1 +1 @@
1
- import{n as e,t}from"./compile-cache-6u9hgeWu.js";export{t as compileCacheDir,e as enableCompileCache};
1
+ export{t as compileCacheDir,n as enableCompileCache}from"./compile-cache-6u9hgeWu.js";
@@ -1,4 +1,4 @@
1
- import{a as e,c as t,n}from"./schema-extractor-DFawzmtj.js";import{n as r}from"./command-BXsTrIgI.js";import{c as i}from"./subcommand-router-iqmWGZyU.js";import{a,i as o,n as s,o as c,r as l,s as u}from"./with-completion-command-yg7HB6Zu.js";import{_ as d,c as f,d as p,f as m,g as h,h as g,i as _,l as v,m as y,p as b,s as ee,t as te,u as ne,v as x,y as S}from"./dynamic-Hg5BDHzz.js";import{existsSync as C,mkdirSync as re,readFileSync as w,realpathSync as T,renameSync as ie,rmSync as ae,statSync as E,writeFileSync as oe}from"node:fs";import{dirname as D,extname as se,isAbsolute as O,join as k,relative as ce,resolve as le}from"node:path";import{promisify as ue}from"node:util";import{execFile as de}from"node:child_process";function fe(e,t,n=[],r=!1){if(t.length===0)return;let i=pe(e,n);for(let e of t)e.set(me(e,i,r))}function pe(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Set;for(let t of[...e.options,...e.positionals])r.add(t.name);let i=(e,t)=>{for(let i of e){if(n.has(i.name)||t&&r.has(i.name))continue;let e=i.valueCompletion;e?.type===`choices`&&e.choices&&e.choices.length>0&&n.set(i.name,e.choices)}};return i([...e.options,...e.positionals],!1),i(t,!0),n}function me(e,t,n=!1){let{spec:r}=e,i=r.dependsOn;if(i.length===0)throw Error(`Field "${e.describe}": completion.custom.expand.dependsOn must list at least one sibling arg.`);let a=[];for(let n of i){if(n===e.name)throw Error(`Field "${e.describe}": completion.custom.expand.dependsOn cannot reference the field itself ("${n}").`);let r=t.get(n);if(!r)throw Error(`Field "${e.describe}": completion.custom.expand.dependsOn references "${n}", which is not a sibling arg with a static \`choices\`/enum schema on the same command. Chaining expand specs is not supported.`);a.push([...r])}if(n)return{type:`expand`,dependsOn:i,table:[]};let o=[];for(let t of ge(a)){let n={};i.forEach((e,r)=>{n[e]=t[r]});let a;try{a=r.enumerate(n)}catch(t){let r=t instanceof Error?t.message:String(t);throw Error(`Field "${e.describe}": completion.custom.expand.enumerate threw for deps=${JSON.stringify(n)}: ${r}`)}let s=he(a);s.length!==0&&o.push({key:t,candidates:s})}return{type:`expand`,dependsOn:i,table:o}}function he(e){let t=[],n=/* @__PURE__ */ new Set;for(let r of e){let e=typeof r==`string`?r:r.value;if(n.has(e))continue;n.add(e);let i={value:e};typeof r!=`string`&&r.description!==void 0&&(i.description=r.description),t.push(i)}return t}function*ge(e){if(e.length===0){yield[];return}let t=Array.from({length:e.length}).fill(0);for(;;){yield t.map((t,n)=>e[n][t]);let n=e.length-1;for(;n>=0&&(t[n]++,!(t[n]<e[n].length));)t[n]=0,n--;if(n<0)return}}function _e(e,t,n,r){let i=ee(e);if(i?.type===`pending-expand`){t.push({name:e.name,describe:n,set:r,spec:i.spec});return}i!==void 0&&r(i)}function A(e){return e.replace(/[^a-zA-Z0-9_]/g,`_`)}function j(e){let t=e.toUpperCase();return/^[A-Z_]/.test(t)?`${t}_BIN`:`_${t}_BIN`}function M(e,t,n){return`__${e}_expand_${t}__${A(n)}`}function ve(e,t){return[`__${e}_invoke_complete() {`,` local _shell="$1"; shift`,` "\${${j(e)}:-${t}}" __complete --shell "$_shell" -- "$@" 2>/dev/null`,`}`]}function N(e){return e.filter(e=>!e.name.startsWith(`__`))}function P(e){let t=[];for(let n of N(e))if(t.push({name:n.name,description:n.description}),n.aliases)for(let e of n.aliases)t.push({name:e,description:n.description});return t}function ye(e,t){let n=e.type===`boolean`&&e.negation===!0,r={name:e.name,cliName:e.cliName,alias:e.alias,negation:e.negationDisplay,negationDescription:e.negationDescription,description:e.description,takesValue:e.type!==`boolean`,valueType:e.type,required:e.required,defaultNegationAccepted:n};return _e(e,t,`--${e.cliName}`,e=>{r.valueCompletion=e}),r}function be(e){return e.args?t(n(e.args)):[]}function xe(e,t){return e.filter(e=>e.named).map(e=>ye(e,t))}function Se(e,t){return e.filter(e=>e.positional).map((e,n)=>{let r={name:e.name,cliName:e.cliName,position:n,description:e.description,required:e.required,variadic:e.type===`array`};return _e(e,t,`<${e.cliName}>`,e=>{r.valueCompletion=e}),r})}function Ce(r,a,o=[],s=!1){let c=[];if(a.subCommands)for(let[e,t]of Object.entries(a.subCommands)){let n=i(t);n?c.push(Ce(e,n,o,s)):c.push({name:e,description:`(lazy loaded)`,subcommands:[],options:[],positionals:[]})}let l=[],u=a.args?n(a.args):void 0,d={name:r,description:a.description,aliases:a.aliases,subcommands:c,options:xe(u?e(u):[],l),positionals:Se(u?t(u):[],l)};return fe(d,l,o,s),d}function F(e,t,n){return e?`${e}${n}${t}`:t}function we(e,t){let n=[t.name,...t.aliases??[]];return e.flatMap(e=>n.map(t=>F(e,t,`:`)))}function Te(e){let t=[],n=(e,r)=>{let i=new Set(e.options.filter(e=>e.isGlobal!==!0).map(e=>e.name));e.positionals.some(e=>i.has(e.name))&&t.push({pathStrs:r,positionals:e.positionals,options:e.options});for(let t of N(e.subcommands))n(t,we(r,t))};return n(e,[``]),t}function I(e,t){let n=[],r=N(e.subcommands).length>0;for(let i of e.options){if(!i.takesValue)continue;let a=r&&i.isGlobal===!0?v(i.cliName,i.alias):R(i,e.options);a.length!==0&&n.push({parentPath:t,tokens:a})}for(let r of N(e.subcommands))for(let e of[r.name,...r.aliases??[]])n.push(...I(r,F(t,e,`:`)));return n}function Ee(e,t){return I(e,t).map(e=>` ${e.tokens.map(t=>`${e.parentPath}:${t}`).join(`|`)}) return 0 ;;`)}function L(e,t=``,n=``){let r=[];for(let i of N(e.subcommands)){let e=F(n,A(i.name),`_`);for(let n of[i.name,...i.aliases??[]]){let a=F(t,n,`:`);r.push(...L(i,a,e)),r.push({pathStr:a,funcSuffix:e,lookupPattern:`${t}:${n}`})}}return r}function De(e){return e.map(e=>` ${e.lookupPattern}) return 0 ;;`)}function Oe(e,t){return e.map(e=>` ${e.pathStr}) __${t}_complete_${e.funcSuffix} ;;`)}function ke(e,t){let n=e.isGlobal?`_global_arg_values`:`_arg_values`;return t===`bash`?`${n}_${A(e.fieldName)}="$3"`:`${n}[${e.fieldName}]="$3"`}function Ae(e,t){let n=[];for(let r of e){if(r.isPositional||!r.optionTokens||r.optionTokens.length===0)continue;let e=r.pathStrs.flatMap(e=>r.optionTokens.map(t=>`${e}:${t}`)).join(`|`);n.push(` ${e}) ${ke(r,t)} ;;`)}return n}function je(e,t){let n=[];for(let r of e){if(!r.isPositional)continue;let e=r.pathStrs.map(e=>`${e}:${r.position}`).join(`|`);n.push(` ${e}) ${ke(r,t)} ;;`)}return n}function Me(e,t){let n=[];for(let r of e){if(r.optionTokens.length===0)continue;let e=r.pathStrs.flatMap(e=>r.optionTokens.map(t=>`${e}:${t}`)).join(`|`),i=A(r.fieldName),a=r.isGlobal?`_global_used_field_keys`:`_used_field_keys`,o=t===`bash`?`${a}_${i}`:`${a}[${i}]`,s=t===`bash`?`_global_arr_seen_${i}`:`_global_arr_seen[${i}]`,c=`${o}=" $_k "`,l=`${o}+=" $_k "`,u=`${s}=1`;n.push(` ${e})`),n.push(` if [[ "$3" == *=* ]]; then`),n.push(' local _k="${3%%=*}"'),r.isGlobal?(n.push(` if [[ -n "$_k" ]]; then`),n.push(` if [[ -z "\${${s}:-}" ]]; then`),n.push(` ${c}`),n.push(` ${u}`),n.push(` else`),n.push(` ${l}`),n.push(` fi`),n.push(` fi`)):n.push(` [[ -n "$_k" ]] && ${l}`),n.push(` fi`),n.push(` ;;`)}return n}function R(e,t){let n=v(e.cliName,e.alias);if(e.isGlobal===!0){let e=/* @__PURE__ */ new Set;for(let n of t)if(n.isGlobal!==!0)for(let t of p(n.cliName,n.alias))e.add(t);return n.filter(t=>!e.has(t))}let r=ne(t);return r.size===0?n:n.filter(t=>!t.startsWith(`-`)||t.startsWith(`--`)||!r.has(t)?!0:e.alias?.includes(t.slice(1))===!0)}function z(e){let t=[];return Ne(e,[],[``],[],`root`,t),t}function Ne(e,t,n,r,i,a){let o=n[0];for(let s of e.options){let c=s.valueCompletion;if(c?.type===`expand`){let l=s.valueType===`array`;a.push({path:t,pathStr:o,pathStrs:n,intermediatePathStrs:r,funcSuffix:i,fieldName:s.name,isGlobal:s.isGlobal===!0,isPositional:!1,isArrayOption:l,optionTokens:l?R(s,e.options):[],vc:c})}}for(let s of e.positionals){let e=s.valueCompletion;e?.type===`expand`&&a.push({path:t,pathStr:o,pathStrs:n,intermediatePathStrs:r,funcSuffix:i,fieldName:s.name,isGlobal:!1,isPositional:!0,isArrayOption:!1,optionTokens:[],vc:e})}for(let o of N(e.subcommands))Ne(o,[...t,o.name],we(n,o),[...r,...n],i===`root`?A(o.name):`${i}_${A(o.name)}`,a)}function B(e,t,n=[]){let r=Pe(e),i=/* @__PURE__ */ new Map,a=(e,t,n)=>{let r=i.get(e);r||(r={ref:t,pathStrs:[],seen:/* @__PURE__ */ new Set},i.set(e,r));for(let e of n)r.seen.has(e)||(r.seen.add(e),r.pathStrs.push(e))},o=(e,t,n)=>{let i=/* @__PURE__ */ new Map,a=(e,t)=>{if(t.length===0)return;let n=t.join(` `),r=i.get(n);r||(r={tokens:t,paths:[]},i.set(n,r)),r.paths.push(e)};for(let n of t){let t=r.get(n);if(!t)continue;let i=/* @__PURE__ */ new Set;for(let e of t.options)if(e.isGlobal!==!0)for(let t of p(e.cliName,e.alias))i.add(t);a(n,e.filter(e=>!i.has(e)))}for(let t of n)a(t,e);return i},s=(e,t,n)=>{let r=v(t.cliName,t.alias),i=o(r,n.pathStrs,n.intermediatePathStrs);for(let[t,n]of i)a(`g::${e}::${t}`,{fieldName:e,isGlobal:!0,isPositional:!1,optionTokens:n.tokens},n.paths)};for(let e of t){let t=r.get(e.pathStr);if(t)for(let r of e.vc.dependsOn){if(e.isGlobal){let t=n.find(e=>e.name===r);if(!t)continue;s(r,t,e);continue}let i=t.positionals.findIndex(e=>e.name===r);i>=0&&a(`lp::${e.pathStr}::${r}`,{fieldName:r,isGlobal:!1,isPositional:!0,position:i},e.pathStrs);let o=t.options.find(e=>e.name===r);if(o){if(o.isGlobal===!0){s(r,o,e);continue}a(`lo::${e.pathStr}::${r}`,{fieldName:r,isGlobal:!1,isPositional:!1,optionTokens:R(o,t.options)},e.pathStrs)}}}let c=[];for(let e of i.values())e.pathStrs.length!==0&&c.push({...e.ref,pathStr:e.pathStrs[0],pathStrs:e.pathStrs});return c}function Pe(e){let t=/* @__PURE__ */ new Map,n=(e,r)=>{for(let n of r)t.set(n,e);for(let t of N(e.subcommands))n(t,we(r,t))};return n(e,[``]),t}function V(e){for(let t of e.options)if(t.valueCompletion?.type===`dynamic`)return!0;for(let t of e.positionals)if(t.valueCompletion?.type===`dynamic`)return!0;for(let t of e.subcommands)if(V(t))return!0;return!1}function Fe(e,t){let n=new Set(e.options.map(e=>e.name)),r=t.filter(e=>!n.has(e.name));e.options=[...e.options,...r];for(let n of e.subcommands)Fe(n,t)}function H(e,t,r,i=!1){let a=[];if(r){let e=[];a=xe(n(r).fields,e).map(e=>(e.isGlobal=!0,e)),fe({name:t,subcommands:[],options:a,positionals:[]},e,[],i)}let o=Ce(t,e,a,i);return r?Fe(o,a):a=o.options,{command:o,programName:t,globalOptions:a}}function U(e){try{return Math.floor(E(e).mtimeMs/1e3).toString()}catch{return`0`}}function Ie(e){return e.replace(/\r?\n/g,` `)}function Le(e){if(!e||/[/\\\0]/.test(e))return null;let t=process.env.PATH??``;for(let n of t.split(`:`)){if(!n)continue;let t=k(n,e);try{if(E(t).isFile())return t}catch{}}return null}function W(e,t){return t||process.env[j(A(e))]||(Le(e)??process.argv[1]??``)}function G(e){let t=W(e.programName,e.binPath),n=[`# politty-completion-version: 1`,`# politty-bin-sig: ${U(t)}`,`# politty-bin-path: ${Ie(t)}`,`# program: ${e.programName}`];return e.programVersion&&n.push(`# program-version: ${e.programVersion}`),n.push(`# shell: ${e.shell}`),n}function Re(e){let{programName:t,binPath:n}=e,r=A(t),i=j(r),a=W(t,n),o=U(a),s=x(a),c=`__${r}_self_refresh`;return[`${c}() {`,` local _self _bin _sig`," _self=${BASH_SOURCE[0]:-}",` [[ -n "$_self" && -f "$_self" ]] || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qF "# politty-completion-version:" || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# program: ${t}" || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# shell: bash" || return 1`,` _bin="\${${i}:-$(type -P ${t} 2>/dev/null)}"`,` [[ -n "$_bin" ]] || return 1`,` _sig=${S(`$_bin`,{shell:`posix`})} || return 1`,` [[ "$_sig" != "${o}" || "$_bin" != ${s} ]] || return 1`,` "$_bin" __refresh-completion bash "$_self" --static 2>/dev/null || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# politty-bin-sig: $_sig" || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# politty-bin-path: $_bin" || return 1`,` source "$_self" 2>/dev/null || return 1`,` return 0`,`}`,`if ${c}; then`,` unset -f ${c}`,` return 0 2>/dev/null || true`,`else`,` unset -f ${c}`,`fi`,``]}function ze(e){let{programName:t,binPath:n}=e,r=A(t),i=j(r),a=`_${t}`,o=W(t,n),s=U(o),c=x(o),l=`__${r}_self_refresh`;return[`${l}() {`,` emulate -L zsh`,` setopt local_options no_aliases`,` local _self _bin _sig`,' _self="${(%):-%x}"',` [[ -n "$_self" && -f "$_self" ]] || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qF "# politty-completion-version:" || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# program: ${t}" || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# shell: zsh" || return 1`,` _bin="\${${i}:-$(whence -p ${t} 2>/dev/null)}"`,` [[ -n "$_bin" ]] || return 1`,` _sig=${S(`$_bin`,{shell:`posix`})} || return 1`,` [[ "$_sig" != "${s}" || "$_bin" != ${c} ]] || return 1`,` "$_bin" __refresh-completion zsh "$_self" --static 2>/dev/null || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# politty-bin-sig: $_sig" || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# politty-bin-path: $_bin" || return 1`,` source "$_self" 2>/dev/null || return 1`,` ${a} "$@"`,` return 0`,`}`,`if ${l} "$@"; then`,` unfunction ${l} 2>/dev/null`,` return 0 2>/dev/null || true`,`else`,` unfunction ${l} 2>/dev/null`,`fi`,``]}function Be(e){return e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/\$/g,`\\$`).replace(/`/g,"\\`")}function Ve(e){let t=``,n=new TextEncoder().encode(e);for(let e of n)t+=e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122?String.fromCharCode(e):`_${e.toString(16).toUpperCase().padStart(2,`0`)}`;return t}function He(e,t,n,r){if(!e)return[];switch(e.type){case`expand`:{if(!r)throw Error(`bashValueLines: expand variant requires a location`);let e=M(n,r.funcSuffix,r.fieldName),i=[`local _enc_key='' _enc_v`];r.resolvedDeps.forEach((e,t)=>{let r=A(e.name),a=e.isGlobal?`_global_arg_values_${r}`:`_arg_values_${r}`;i.push(`_enc_v="\${${a}:-}"`),i.push(t===0?`_enc_key="$(__${n}_enc "$_enc_v")"`:`_enc_key+="_$(__${n}_enc "$_enc_v")"`)});let a=t?'"${_inline_prefix}${_c}"':`"$_c"`,o=r.isGlobal?`\${_global_used_field_keys_${A(r.fieldName)}:-}`:`\${_used_field_keys_${A(r.fieldName)}:-}`,s=r.isArrayOption?[` if [[ -n "$_ck" && " ${o} " == *" $_ck "* ]]; then continue; fi`]:[];return[`compopt +o default 2>/dev/null`,...i,`local _varname=${e}__\${_enc_key}`,'local _raw="${!_varname:-}"',`if [[ -n "$_raw" ]]; then`,` local -a _vals=()`,` local _line`,` while IFS= read -r _line; do _vals+=("$_line"); done <<< "$_raw"`,` local _c _ck _seen_keys=" " _had_key=0`,' for _c in "${_vals[@]}"; do',` [[ -z "$_c" ]] && continue`,` if [[ "$_c" == *=* ]]; then`,' _ck="${_c%%=*}"',...s,` if [[ "$_cur" != *=* ]]; then`,` [[ "$_seen_keys" == *" $_ck "* ]] && continue`,` _seen_keys+="$_ck "`,' _c="${_ck}="',` _had_key=1`,` elif [[ "$_c" != *=?* ]]; then`,` continue`,` fi`,` fi`,` [[ "$_c" == "$_cur"* ]] && COMPREPLY+=(${a})`,` done`,` if (( _had_key )); then compopt -o nospace 2>/dev/null; fi`,`fi`,'if (( ${#COMPREPLY[@]} == 0 )); then COMPREPLY=( "" ); fi']}case`dynamic`:return[`local _dyn_out`,`_dyn_out=$(__${n}_invoke_complete bash "\${_words[@]}")`,`__${n}_apply_dynamic_output "$_dyn_out"`];case`choices`:{let n=[`local -a _choices=(${e.choices.map(e=>`"${Be(e)}"`).join(` `)})`,`COMPREPLY=()`,'local _c; for _c in "${_choices[@]}"; do [[ "$_c" == "$_cur"* ]] && COMPREPLY+=("${_inline_prefix}${_c}"); done'];return t&&n.push(`compopt -o nospace`),n.push(`compopt +o default 2>/dev/null`),n}case`file`:return e.matcher?.length?Ue(e.matcher.map(e=>`[[ "\${_f##*/}" == ${e} ]]`).join(` || `)):e.extensions?.length?Ue(e.extensions.map(e=>`[[ "$_f" == *".${e}" ]]`).join(` || `)):[`COMPREPLY=($(compgen -P "$_inline_prefix" -f -- "$_cur"))`,`compopt -o filenames`];case`directory`:return[`COMPREPLY=($(compgen -P "$_inline_prefix" -d -- "$_cur"))`,`compopt -o filenames`];case`command`:return[`COMPREPLY=($(compgen -P "$_inline_prefix" -W "$(${e.shellCommand})" -- "$_cur"))`];case`none`:return[`compopt +o default 2>/dev/null`];case`runtime-expand`:return[]}}function K(e){return`unset $(compgen -v ${e} 2>/dev/null) 2>/dev/null`}function Ue(e){return[`local -a _all_entries=($(compgen -f -- "$_cur"))`,'for _f in "${_all_entries[@]}"; do',` if [[ -d "$_f" ]]; then`,' COMPREPLY+=("${_inline_prefix}$_f")',` elif ${e}; then`,' COMPREPLY+=("${_inline_prefix}$_f")',` fi`,`done`,`compopt -o filenames`,`compopt +o default 2>/dev/null`]}function We(e,t,n,r,i){let a=[];for(let o of e){if(!o.takesValue||!o.valueCompletion)continue;let s=He(o.valueCompletion,n,r,{funcSuffix:i,...b(o,e,t)});if(s.length===0)continue;let c=R(o,e);if(c.length!==0){a.push(` ${c.join(`|`)})`);for(let e of s)a.push(` ${e}`);a.push(` return ;;`)}}return a}function q(e,t,n,r=[]){if(e.length===0)return[];let i=g(e,r,t),a=[...i??[]];a.push(` case "${i?`$_slot`:`$_pos_count`}" in`);for(let o of e){o.variadic&&!i?a.push(` ${o.position}|*)`):a.push(` ${o.position})`);for(let i of He(o.valueCompletion,!1,t,{funcSuffix:n,...y(o,r,e)}))a.push(` ${i}`);a.push(` ;;`)}return a.push(` esac`),a}function Ge(e,t,n,r,i){let a=[`COMPREPLY=($(compgen -W "${e}" -- "$_cur"))`,`compopt +o default 2>/dev/null`];return t.length===0?a:[`local -a _sub_names=(${e})`,`local _sub_name _sub_match=0`,'for _sub_name in "${_sub_names[@]}"; do',` [[ "$_sub_name" == "$_cur"* ]] && _sub_match=1 && break`,`done`,`if (( _sub_match )); then`,...a.map(e=>` ${e}`),`else`,...q(t,n,r,i),`fi`]}function Ke(e,t,n,r){if(!e.some(e=>e.takesValue&&e.valueCompletion))return[];let i=[],a=We(e,t,!1,n,r);a.length>0&&(i.push(` if [[ -z "$_inline_prefix" ]]; then`),i.push(` case "$_prev" in`),i.push(...a),i.push(` esac`),i.push(` fi`));let o=We(e,t,!0,n,r);return o.length>0&&(i.push(` if [[ -n "$_inline_prefix" ]]; then`),i.push(' case "${_inline_prefix%=}" in'),i.push(...o),i.push(` esac`),i.push(` fi`)),i}function qe(e,t){let n=[];for(let r of e){if(r.valueType===`array`){n.push(` _avail+=(--${r.cliName})`);continue}let i=d(r.cliName,r.alias,r.negation,{isGlobal:r.isGlobal===!0,frameOptions:e}),a=`__${t}_not_used ${i.join(` `)}`,o=r.negation?[r.cliName,r.negation]:[r.cliName];for(let e of o)i.includes(`"--${e}"`)&&n.push(` ${a} && _avail+=(--${e})`)}return n.push(` if (( ! _any_opt_used )); then`),n.push(` _avail+=(--help --help-all --help-json)`),n.push(` fi`),n}function Je(e,t,n){let r=[...n,e.name],i=r.map(A).join(`_`),a=`__${t}_complete_${i}`,o=N(e.subcommands),s=[];for(let e of o)s.push(...Je(e,t,r));s.push(`${a}() {`),s.push(...Ke(e.options,e.positionals,t,i));let c=r.join(`:`);if(s.push(` if [[ -z "$_inline_prefix" ]] && __${t}_opt_takes_value "${c}" "$_prev"; then return; fi`),s.push(` if [[ -n "$_inline_prefix" ]] && __${t}_opt_takes_value "${c}" "\${_inline_prefix%=}"; then return; fi`),e.positionals.length>0?(s.push(` if (( _after_dd )); then`),s.push(...q(e.positionals,t,i,e.options).map(e=>` ${e}`)),s.push(` return`),s.push(` fi`)):s.push(` if (( _after_dd )); then return; fi`),s.push(` if [[ "$_cur" == -* ]]; then`),s.push(` local -a _avail=()`),s.push(...qe(e.options,t)),s.push(' COMPREPLY=($(compgen -W "${_avail[*]}" -- "$_cur"))'),s.push(` compopt +o default 2>/dev/null`),s.push(` return`),s.push(` fi`),o.length>0){let n=P(e.subcommands).map(e=>e.name).join(` `);s.push(...Ge(n,e.positionals,t,i,e.options).map(e=>` ${e}`))}else e.positionals.length>0&&s.push(...q(e.positionals,t,i,e.options));return s.push(`}`),s.push(``),s}function Ye(e,t){let{programName:n}=t,r=H(e,n,t.globalArgsSchema),i=A(n),a=t.staticWorker?`${i}_${A(t.staticWorker.functionSuffix)}`:i,o=t.staticWorker!==void 0,s=r.command,c=N(s.subcommands),l=z(s),u=B(s,l,r.globalOptions),d=[];d.push(...G({programName:n,shell:`bash`,binPath:t.binPath,programVersion:t.programVersion})),d.push(`# politty-completion-mode: ${o?`worker`:`static`}`),o&&d.push(`# politty-completion-worker: true`),d.push(`# Generated by politty`),d.push(``),o||d.push(...Re({programName:n,binPath:t.binPath}));let p=l.length>0,m=l.filter(e=>e.isArrayOption),g=m.length>0;p&&(d.push(`__${a}_enc() {`),d.push(` local LC_ALL=C`),d.push(` local _s=$1 _r='' _c _i`),d.push(" for (( _i=0; _i<${#_s}; _i++ )); do"),d.push(" _c=${_s:_i:1}"),d.push(` case "$_c" in`),d.push(` [a-zA-Z0-9]) _r+="$_c" ;;`),d.push(` *) printf -v _r '%s_%02X' "$_r" "'$_c" ;;`),d.push(` esac`),d.push(` done`),d.push(` printf '%s' "$_r"`),d.push(`}`),d.push(``));for(let e of l){let t=M(a,e.funcSuffix,e.fieldName);for(let n of e.vc.table){let e=n.key.map(Ve).join(`_`),r=n.candidates.map(e=>e.value).join(`
1
+ import{a as e,c as t,n}from"./schema-extractor-BK1sJx7i.js";import{n as r}from"./command-BXsTrIgI.js";import{c as i}from"./subcommand-router-40vA6Mka.js";import{a,i as o,n as s,o as c,r as l,s as u}from"./with-completion-command-D8AbV0pu.js";import{_ as d,c as f,d as p,f as m,g as h,h as g,i as _,l as v,m as y,p as b,s as ee,t as te,u as ne,v as x,y as S}from"./dynamic-eZ7UI_q1.js";import{existsSync as C,mkdirSync as re,readFileSync as w,realpathSync as T,renameSync as ie,rmSync as ae,statSync as E,writeFileSync as oe}from"node:fs";import{dirname as D,extname as se,isAbsolute as O,join as k,relative as ce,resolve as le}from"node:path";import{promisify as ue}from"node:util";import{execFile as de}from"node:child_process";function fe(e,t,n=[],r=!1){if(t.length===0)return;let i=pe(e,n);for(let e of t)e.set(me(e,i,r))}function pe(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Set;for(let t of[...e.options,...e.positionals])r.add(t.name);let i=(e,t)=>{for(let i of e){if(n.has(i.name)||t&&r.has(i.name))continue;let e=i.valueCompletion;e?.type===`choices`&&e.choices&&e.choices.length>0&&n.set(i.name,e.choices)}};return i([...e.options,...e.positionals],!1),i(t,!0),n}function me(e,t,n=!1){let{spec:r}=e,i=r.dependsOn;if(i.length===0)throw Error(`Field "${e.describe}": completion.custom.expand.dependsOn must list at least one sibling arg.`);let a=[];for(let n of i){if(n===e.name)throw Error(`Field "${e.describe}": completion.custom.expand.dependsOn cannot reference the field itself ("${n}").`);let r=t.get(n);if(!r)throw Error(`Field "${e.describe}": completion.custom.expand.dependsOn references "${n}", which is not a sibling arg with a static \`choices\`/enum schema on the same command. Chaining expand specs is not supported.`);a.push([...r])}if(n)return{type:`expand`,dependsOn:i,table:[]};let o=[];for(let t of ge(a)){let n={};i.forEach((e,r)=>{n[e]=t[r]});let a;try{a=r.enumerate(n)}catch(t){let r=t instanceof Error?t.message:String(t);throw Error(`Field "${e.describe}": completion.custom.expand.enumerate threw for deps=${JSON.stringify(n)}: ${r}`)}let s=he(a);s.length!==0&&o.push({key:t,candidates:s})}return{type:`expand`,dependsOn:i,table:o}}function he(e){let t=[],n=/* @__PURE__ */ new Set;for(let r of e){let e=typeof r==`string`?r:r.value;if(n.has(e))continue;n.add(e);let i={value:e};typeof r!=`string`&&r.description!==void 0&&(i.description=r.description),t.push(i)}return t}function*ge(e){if(e.length===0){yield[];return}let t=Array.from({length:e.length}).fill(0);for(;;){yield t.map((t,n)=>e[n][t]);let n=e.length-1;for(;n>=0&&(t[n]++,!(t[n]<e[n].length));)t[n]=0,n--;if(n<0)return}}function _e(e,t,n,r){let i=ee(e);i?.type===`pending-expand`?t.push({name:e.name,describe:n,set:r,spec:i.spec}):i!==void 0&&r(i)}function A(e){return e.replace(/[^a-zA-Z0-9_]/g,`_`)}function j(e){let t=e.toUpperCase();return/^[A-Z_]/.test(t)?`${t}_BIN`:`_${t}_BIN`}function M(e,t,n){return`__${e}_expand_${t}__${A(n)}`}function ve(e,t){return[`__${e}_invoke_complete() {`,` local _shell="$1"; shift`,` "\${${j(e)}:-${t}}" __complete --shell "$_shell" -- "$@" 2>/dev/null`,`}`]}function N(e){return e.filter(e=>!e.name.startsWith(`__`))}function P(e){let t=[];for(let n of N(e))if(t.push({name:n.name,description:n.description}),n.aliases)for(let e of n.aliases)t.push({name:e,description:n.description});return t}function ye(e,t){let n=e.type===`boolean`&&e.negation===!0,r={name:e.name,cliName:e.cliName,alias:e.alias,negation:e.negationDisplay,negationDescription:e.negationDescription,description:e.description,takesValue:e.type!==`boolean`,valueType:e.type,required:e.required,defaultNegationAccepted:n};return _e(e,t,`--${e.cliName}`,e=>{r.valueCompletion=e}),r}function be(e){return e.args?t(n(e.args)):[]}function xe(e,t){return e.filter(e=>e.named).map(e=>ye(e,t))}function Se(e,t){return e.filter(e=>e.positional).map((e,n)=>{let r={name:e.name,cliName:e.cliName,position:n,description:e.description,required:e.required,variadic:e.type===`array`};return _e(e,t,`<${e.cliName}>`,e=>{r.valueCompletion=e}),r})}function Ce(r,a,o=[],s=!1){let c=[];if(a.subCommands)for(let[e,t]of Object.entries(a.subCommands)){let n=i(t);n?c.push(Ce(e,n,o,s)):c.push({name:e,description:`(lazy loaded)`,subcommands:[],options:[],positionals:[]})}let l=[],u=a.args?n(a.args):void 0,d={name:r,description:a.description,aliases:a.aliases,subcommands:c,options:xe(u?e(u):[],l),positionals:Se(u?t(u):[],l)};return fe(d,l,o,s),d}function F(e,t,n){return e?`${e}${n}${t}`:t}function we(e,t){let n=[t.name,...t.aliases??[]];return e.flatMap(e=>n.map(t=>F(e,t,`:`)))}function Te(e){let t=[],n=(e,r)=>{let i=new Set(e.options.filter(e=>e.isGlobal!==!0).map(e=>e.name));e.positionals.some(e=>i.has(e.name))&&t.push({pathStrs:r,positionals:e.positionals,options:e.options});for(let t of N(e.subcommands))n(t,we(r,t))};return n(e,[``]),t}function I(e,t){let n=[],r=N(e.subcommands).length>0;for(let i of e.options){if(!i.takesValue)continue;let a=r&&i.isGlobal===!0?v(i.cliName,i.alias):R(i,e.options);a.length!==0&&n.push({parentPath:t,tokens:a})}for(let r of N(e.subcommands))for(let e of[r.name,...r.aliases??[]])n.push(...I(r,F(t,e,`:`)));return n}function Ee(e,t){return I(e,t).map(e=>` ${e.tokens.map(t=>`${e.parentPath}:${t}`).join(`|`)}) return 0 ;;`)}function L(e,t=``,n=``){let r=[];for(let i of N(e.subcommands)){let e=F(n,A(i.name),`_`);for(let n of[i.name,...i.aliases??[]]){let a=F(t,n,`:`);r.push(...L(i,a,e)),r.push({pathStr:a,funcSuffix:e,lookupPattern:`${t}:${n}`})}}return r}function De(e){return e.map(e=>` ${e.lookupPattern}) return 0 ;;`)}function Oe(e,t){return e.map(e=>` ${e.pathStr}) __${t}_complete_${e.funcSuffix} ;;`)}function ke(e,t){let n=e.isGlobal?`_global_arg_values`:`_arg_values`;return t===`bash`?`${n}_${A(e.fieldName)}="$3"`:`${n}[${e.fieldName}]="$3"`}function Ae(e,t){let n=[];for(let r of e){if(r.isPositional||!r.optionTokens||r.optionTokens.length===0)continue;let e=r.pathStrs.flatMap(e=>r.optionTokens.map(t=>`${e}:${t}`)).join(`|`);n.push(` ${e}) ${ke(r,t)} ;;`)}return n}function je(e,t){let n=[];for(let r of e){if(!r.isPositional)continue;let e=r.pathStrs.map(e=>`${e}:${r.position}`).join(`|`);n.push(` ${e}) ${ke(r,t)} ;;`)}return n}function Me(e,t){let n=[];for(let r of e){if(r.optionTokens.length===0)continue;let e=r.pathStrs.flatMap(e=>r.optionTokens.map(t=>`${e}:${t}`)).join(`|`),i=A(r.fieldName),a=r.isGlobal?`_global_used_field_keys`:`_used_field_keys`,o=t===`bash`?`${a}_${i}`:`${a}[${i}]`,s=t===`bash`?`_global_arr_seen_${i}`:`_global_arr_seen[${i}]`,c=`${o}=" $_k "`,l=`${o}+=" $_k "`,u=`${s}=1`;n.push(` ${e})`),n.push(` if [[ "$3" == *=* ]]; then`),n.push(' local _k="${3%%=*}"'),r.isGlobal?(n.push(` if [[ -n "$_k" ]]; then`),n.push(` if [[ -z "\${${s}:-}" ]]; then`),n.push(` ${c}`),n.push(` ${u}`),n.push(` else`),n.push(` ${l}`),n.push(` fi`),n.push(` fi`)):n.push(` [[ -n "$_k" ]] && ${l}`),n.push(` fi`),n.push(` ;;`)}return n}function R(e,t){let n=v(e.cliName,e.alias);if(e.isGlobal===!0){let e=/* @__PURE__ */ new Set;for(let n of t)if(n.isGlobal!==!0)for(let t of p(n.cliName,n.alias))e.add(t);return n.filter(t=>!e.has(t))}let r=ne(t);return r.size===0?n:n.filter(t=>!t.startsWith(`-`)||t.startsWith(`--`)||!r.has(t)?!0:e.alias?.includes(t.slice(1))===!0)}function z(e){let t=[];return Ne(e,[],[``],[],`root`,t),t}function Ne(e,t,n,r,i,a){let o=n[0];for(let s of e.options){let c=s.valueCompletion;if(c?.type===`expand`){let l=s.valueType===`array`;a.push({path:t,pathStr:o,pathStrs:n,intermediatePathStrs:r,funcSuffix:i,fieldName:s.name,isGlobal:s.isGlobal===!0,isPositional:!1,isArrayOption:l,optionTokens:l?R(s,e.options):[],vc:c})}}for(let s of e.positionals){let e=s.valueCompletion;e?.type===`expand`&&a.push({path:t,pathStr:o,pathStrs:n,intermediatePathStrs:r,funcSuffix:i,fieldName:s.name,isGlobal:!1,isPositional:!0,isArrayOption:!1,optionTokens:[],vc:e})}for(let o of N(e.subcommands))Ne(o,[...t,o.name],we(n,o),[...r,...n],i===`root`?A(o.name):`${i}_${A(o.name)}`,a)}function B(e,t,n=[]){let r=Pe(e),i=/* @__PURE__ */ new Map,a=(e,t,n)=>{let r=i.get(e);r||(r={ref:t,pathStrs:[],seen:/* @__PURE__ */ new Set},i.set(e,r));for(let e of n)r.seen.has(e)||(r.seen.add(e),r.pathStrs.push(e))},o=(e,t,n)=>{let i=/* @__PURE__ */ new Map,a=(e,t)=>{if(t.length===0)return;let n=t.join(` `),r=i.get(n);r||(r={tokens:t,paths:[]},i.set(n,r)),r.paths.push(e)};for(let n of t){let t=r.get(n);if(!t)continue;let i=/* @__PURE__ */ new Set;for(let e of t.options)if(e.isGlobal!==!0)for(let t of p(e.cliName,e.alias))i.add(t);a(n,e.filter(e=>!i.has(e)))}for(let t of n)a(t,e);return i},s=(e,t,n)=>{let r=v(t.cliName,t.alias),i=o(r,n.pathStrs,n.intermediatePathStrs);for(let[t,n]of i)a(`g::${e}::${t}`,{fieldName:e,isGlobal:!0,isPositional:!1,optionTokens:n.tokens},n.paths)};for(let e of t){let t=r.get(e.pathStr);if(t)for(let r of e.vc.dependsOn){if(e.isGlobal){let t=n.find(e=>e.name===r);if(!t)continue;s(r,t,e);continue}let i=t.positionals.findIndex(e=>e.name===r);i>=0&&a(`lp::${e.pathStr}::${r}`,{fieldName:r,isGlobal:!1,isPositional:!0,position:i},e.pathStrs);let o=t.options.find(e=>e.name===r);o&&(o.isGlobal===!0?s(r,o,e):a(`lo::${e.pathStr}::${r}`,{fieldName:r,isGlobal:!1,isPositional:!1,optionTokens:R(o,t.options)},e.pathStrs))}}let c=[];for(let e of i.values())e.pathStrs.length!==0&&c.push({...e.ref,pathStr:e.pathStrs[0],pathStrs:e.pathStrs});return c}function Pe(e){let t=/* @__PURE__ */ new Map,n=(e,r)=>{for(let n of r)t.set(n,e);for(let t of N(e.subcommands))n(t,we(r,t))};return n(e,[``]),t}function V(e){for(let t of e.options)if(t.valueCompletion?.type===`dynamic`)return!0;for(let t of e.positionals)if(t.valueCompletion?.type===`dynamic`)return!0;for(let t of e.subcommands)if(V(t))return!0;return!1}function Fe(e,t){let n=new Set(e.options.map(e=>e.name)),r=t.filter(e=>!n.has(e.name));e.options=[...e.options,...r];for(let n of e.subcommands)Fe(n,t)}function H(e,t,r,i=!1){let a=[];if(r){let e=[];a=xe(n(r).fields,e).map(e=>(e.isGlobal=!0,e)),fe({name:t,subcommands:[],options:a,positionals:[]},e,[],i)}let o=Ce(t,e,a,i);return r?Fe(o,a):a=o.options,{command:o,programName:t,globalOptions:a}}function U(e){try{return Math.floor(E(e).mtimeMs/1e3).toString()}catch{return`0`}}function Ie(e){return e.replace(/\r?\n/g,` `)}function Le(e){if(!e||/[/\\\0]/.test(e))return null;let t=process.env.PATH??``;for(let n of t.split(`:`)){if(!n)continue;let t=k(n,e);try{if(E(t).isFile())return t}catch{}}return null}function W(e,t){return t||process.env[j(A(e))]||(Le(e)??process.argv[1]??``)}function G(e){let t=W(e.programName,e.binPath),n=[`# politty-completion-version: 1`,`# politty-bin-sig: ${U(t)}`,`# politty-bin-path: ${Ie(t)}`,`# program: ${e.programName}`];return e.programVersion&&n.push(`# program-version: ${e.programVersion}`),n.push(`# shell: ${e.shell}`),n}function Re(e){let{programName:t,binPath:n}=e,r=A(t),i=j(r),a=W(t,n),o=U(a),s=x(a),c=`__${r}_self_refresh`;return[`${c}() {`,` local _self _bin _sig`," _self=${BASH_SOURCE[0]:-}",` [[ -n "$_self" && -f "$_self" ]] || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qF "# politty-completion-version:" || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# program: ${t}" || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# shell: bash" || return 1`,` _bin="\${${i}:-$(type -P ${t} 2>/dev/null)}"`,` [[ -n "$_bin" ]] || return 1`,` _sig=${S(`$_bin`,{shell:`posix`})} || return 1`,` [[ "$_sig" != "${o}" || "$_bin" != ${s} ]] || return 1`,` "$_bin" __refresh-completion bash "$_self" --static 2>/dev/null || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# politty-bin-sig: $_sig" || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# politty-bin-path: $_bin" || return 1`,` source "$_self" 2>/dev/null || return 1`,` return 0`,`}`,`if ${c}; then`,` unset -f ${c}`,` return 0 2>/dev/null || true`,`else`,` unset -f ${c}`,`fi`,``]}function ze(e){let{programName:t,binPath:n}=e,r=A(t),i=j(r),a=`_${t}`,o=W(t,n),s=U(o),c=x(o),l=`__${r}_self_refresh`;return[`${l}() {`,` emulate -L zsh`,` setopt local_options no_aliases`,` local _self _bin _sig`,' _self="${(%):-%x}"',` [[ -n "$_self" && -f "$_self" ]] || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qF "# politty-completion-version:" || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# program: ${t}" || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# shell: zsh" || return 1`,` _bin="\${${i}:-$(whence -p ${t} 2>/dev/null)}"`,` [[ -n "$_bin" ]] || return 1`,` _sig=${S(`$_bin`,{shell:`posix`})} || return 1`,` [[ "$_sig" != "${s}" || "$_bin" != ${c} ]] || return 1`,` "$_bin" __refresh-completion zsh "$_self" --static 2>/dev/null || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# politty-bin-sig: $_sig" || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# politty-bin-path: $_bin" || return 1`,` source "$_self" 2>/dev/null || return 1`,` ${a} "$@"`,` return 0`,`}`,`if ${l} "$@"; then`,` unfunction ${l} 2>/dev/null`,` return 0 2>/dev/null || true`,`else`,` unfunction ${l} 2>/dev/null`,`fi`,``]}function Be(e){return e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/\$/g,`\\$`).replace(/`/g,"\\`")}function Ve(e){let t=``,n=new TextEncoder().encode(e);for(let e of n)t+=e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122?String.fromCharCode(e):`_${e.toString(16).toUpperCase().padStart(2,`0`)}`;return t}function He(e,t,n,r){if(!e)return[];switch(e.type){case`expand`:{if(!r)throw Error(`bashValueLines: expand variant requires a location`);let e=M(n,r.funcSuffix,r.fieldName),i=[`local _enc_key='' _enc_v`];r.resolvedDeps.forEach((e,t)=>{let r=A(e.name),a=e.isGlobal?`_global_arg_values_${r}`:`_arg_values_${r}`;i.push(`_enc_v="\${${a}:-}"`),i.push(t===0?`_enc_key="$(__${n}_enc "$_enc_v")"`:`_enc_key+="_$(__${n}_enc "$_enc_v")"`)});let a=t?'"${_inline_prefix}${_c}"':`"$_c"`,o=r.isGlobal?`\${_global_used_field_keys_${A(r.fieldName)}:-}`:`\${_used_field_keys_${A(r.fieldName)}:-}`,s=r.isArrayOption?[` if [[ -n "$_ck" && " ${o} " == *" $_ck "* ]]; then continue; fi`]:[];return[`compopt +o default 2>/dev/null`,...i,`local _varname=${e}__\${_enc_key}`,'local _raw="${!_varname:-}"',`if [[ -n "$_raw" ]]; then`,` local -a _vals=()`,` local _line`,` while IFS= read -r _line; do _vals+=("$_line"); done <<< "$_raw"`,` local _c _ck _seen_keys=" " _had_key=0`,' for _c in "${_vals[@]}"; do',` [[ -z "$_c" ]] && continue`,` if [[ "$_c" == *=* ]]; then`,' _ck="${_c%%=*}"',...s,` if [[ "$_cur" != *=* ]]; then`,` [[ "$_seen_keys" == *" $_ck "* ]] && continue`,` _seen_keys+="$_ck "`,' _c="${_ck}="',` _had_key=1`,` elif [[ "$_c" != *=?* ]]; then`,` continue`,` fi`,` fi`,` [[ "$_c" == "$_cur"* ]] && COMPREPLY+=(${a})`,` done`,` if (( _had_key )); then compopt -o nospace 2>/dev/null; fi`,`fi`,'if (( ${#COMPREPLY[@]} == 0 )); then COMPREPLY=( "" ); fi']}case`dynamic`:return[`local _dyn_out`,`_dyn_out=$(__${n}_invoke_complete bash "\${_words[@]}")`,`__${n}_apply_dynamic_output "$_dyn_out"`];case`choices`:{let n=[`local -a _choices=(${e.choices.map(e=>`"${Be(e)}"`).join(` `)})`,`COMPREPLY=()`,'local _c; for _c in "${_choices[@]}"; do [[ "$_c" == "$_cur"* ]] && COMPREPLY+=("${_inline_prefix}${_c}"); done'];return t&&n.push(`compopt -o nospace`),n.push(`compopt +o default 2>/dev/null`),n}case`file`:return e.matcher?.length?Ue(e.matcher.map(e=>`[[ "\${_f##*/}" == ${e} ]]`).join(` || `)):e.extensions?.length?Ue(e.extensions.map(e=>`[[ "$_f" == *".${e}" ]]`).join(` || `)):[`COMPREPLY=($(compgen -P "$_inline_prefix" -f -- "$_cur"))`,`compopt -o filenames`];case`directory`:return[`COMPREPLY=($(compgen -P "$_inline_prefix" -d -- "$_cur"))`,`compopt -o filenames`];case`command`:return[`COMPREPLY=($(compgen -P "$_inline_prefix" -W "$(${e.shellCommand})" -- "$_cur"))`];case`none`:return[`compopt +o default 2>/dev/null`];case`runtime-expand`:return[]}}function K(e){return`unset $(compgen -v ${e} 2>/dev/null) 2>/dev/null`}function Ue(e){return[`local -a _all_entries=($(compgen -f -- "$_cur"))`,'for _f in "${_all_entries[@]}"; do',` if [[ -d "$_f" ]]; then`,' COMPREPLY+=("${_inline_prefix}$_f")',` elif ${e}; then`,' COMPREPLY+=("${_inline_prefix}$_f")',` fi`,`done`,`compopt -o filenames`,`compopt +o default 2>/dev/null`]}function We(e,t,n,r,i){let a=[];for(let o of e){if(!o.takesValue||!o.valueCompletion)continue;let s=He(o.valueCompletion,n,r,{funcSuffix:i,...b(o,e,t)});if(s.length===0)continue;let c=R(o,e);if(c.length!==0){a.push(` ${c.join(`|`)})`);for(let e of s)a.push(` ${e}`);a.push(` return ;;`)}}return a}function q(e,t,n,r=[]){if(e.length===0)return[];let i=g(e,r,t),a=[...i??[]];a.push(` case "${i?`$_slot`:`$_pos_count`}" in`);for(let o of e){o.variadic&&!i?a.push(` ${o.position}|*)`):a.push(` ${o.position})`);for(let i of He(o.valueCompletion,!1,t,{funcSuffix:n,...y(o,r,e)}))a.push(` ${i}`);a.push(` ;;`)}return a.push(` esac`),a}function Ge(e,t,n,r,i){let a=[`COMPREPLY=($(compgen -W "${e}" -- "$_cur"))`,`compopt +o default 2>/dev/null`];return t.length===0?a:[`local -a _sub_names=(${e})`,`local _sub_name _sub_match=0`,'for _sub_name in "${_sub_names[@]}"; do',` [[ "$_sub_name" == "$_cur"* ]] && _sub_match=1 && break`,`done`,`if (( _sub_match )); then`,...a.map(e=>` ${e}`),`else`,...q(t,n,r,i),`fi`]}function Ke(e,t,n,r){if(!e.some(e=>e.takesValue&&e.valueCompletion))return[];let i=[],a=We(e,t,!1,n,r);a.length>0&&(i.push(` if [[ -z "$_inline_prefix" ]]; then`),i.push(` case "$_prev" in`),i.push(...a),i.push(` esac`),i.push(` fi`));let o=We(e,t,!0,n,r);return o.length>0&&(i.push(` if [[ -n "$_inline_prefix" ]]; then`),i.push(' case "${_inline_prefix%=}" in'),i.push(...o),i.push(` esac`),i.push(` fi`)),i}function qe(e,t){let n=[];for(let r of e){if(r.valueType===`array`){n.push(` _avail+=(--${r.cliName})`);continue}let i=d(r.cliName,r.alias,r.negation,{isGlobal:r.isGlobal===!0,frameOptions:e}),a=`__${t}_not_used ${i.join(` `)}`,o=r.negation?[r.cliName,r.negation]:[r.cliName];for(let e of o)i.includes(`"--${e}"`)&&n.push(` ${a} && _avail+=(--${e})`)}return n.push(` if (( ! _any_opt_used )); then`),n.push(` _avail+=(--help --help-all --help-json)`),n.push(` fi`),n}function Je(e,t,n){let r=[...n,e.name],i=r.map(A).join(`_`),a=`__${t}_complete_${i}`,o=N(e.subcommands),s=[];for(let e of o)s.push(...Je(e,t,r));s.push(`${a}() {`),s.push(...Ke(e.options,e.positionals,t,i));let c=r.join(`:`);if(s.push(` if [[ -z "$_inline_prefix" ]] && __${t}_opt_takes_value "${c}" "$_prev"; then return; fi`),s.push(` if [[ -n "$_inline_prefix" ]] && __${t}_opt_takes_value "${c}" "\${_inline_prefix%=}"; then return; fi`),e.positionals.length>0?(s.push(` if (( _after_dd )); then`),s.push(...q(e.positionals,t,i,e.options).map(e=>` ${e}`)),s.push(` return`),s.push(` fi`)):s.push(` if (( _after_dd )); then return; fi`),s.push(` if [[ "$_cur" == -* ]]; then`),s.push(` local -a _avail=()`),s.push(...qe(e.options,t)),s.push(' COMPREPLY=($(compgen -W "${_avail[*]}" -- "$_cur"))'),s.push(` compopt +o default 2>/dev/null`),s.push(` return`),s.push(` fi`),o.length>0){let n=P(e.subcommands).map(e=>e.name).join(` `);s.push(...Ge(n,e.positionals,t,i,e.options).map(e=>` ${e}`))}else e.positionals.length>0&&s.push(...q(e.positionals,t,i,e.options));return s.push(`}`),s.push(``),s}function Ye(e,t){let{programName:n}=t,r=H(e,n,t.globalArgsSchema),i=A(n),a=t.staticWorker?`${i}_${A(t.staticWorker.functionSuffix)}`:i,o=t.staticWorker!==void 0,s=r.command,c=N(s.subcommands),l=z(s),u=B(s,l,r.globalOptions),d=[];d.push(...G({programName:n,shell:`bash`,binPath:t.binPath,programVersion:t.programVersion})),d.push(`# politty-completion-mode: ${o?`worker`:`static`}`),o&&d.push(`# politty-completion-worker: true`),d.push(`# Generated by politty`),d.push(``),o||d.push(...Re({programName:n,binPath:t.binPath}));let p=l.length>0,m=l.filter(e=>e.isArrayOption),g=m.length>0;p&&(d.push(`__${a}_enc() {`),d.push(` local LC_ALL=C`),d.push(` local _s=$1 _r='' _c _i`),d.push(" for (( _i=0; _i<${#_s}; _i++ )); do"),d.push(" _c=${_s:_i:1}"),d.push(` case "$_c" in`),d.push(` [a-zA-Z0-9]) _r+="$_c" ;;`),d.push(` *) printf -v _r '%s_%02X' "$_r" "'$_c" ;;`),d.push(` esac`),d.push(` done`),d.push(` printf '%s' "$_r"`),d.push(`}`),d.push(``));for(let e of l){let t=M(a,e.funcSuffix,e.fieldName);for(let n of e.vc.table){let e=n.key.map(Ve).join(`_`),r=n.candidates.map(e=>e.value).join(`
2
2
  `);d.push(`${t}__${e}=${f(r)}`)}d.push(``)}V(s)&&(d.push(...ve(a,n)),d.push(``),d.push(`__${a}_apply_dynamic_output() {`),d.push(` local _raw="$1"`),d.push(` COMPREPLY=()`),d.push(` local _directive=0`),d.push(` local -a _lines=()`),d.push(` local _line`),d.push(` while IFS= read -r _line; do _lines+=("$_line"); done <<< "$_raw"`),d.push(" local _last=$((${#_lines[@]} - 1))"),d.push(' if (( _last >= 0 )) && [[ "${_lines[$_last]}" =~ ^:[0-9]+$ ]]; then'),d.push(' _directive="${_lines[$_last]#:}"'),d.push(` unset '_lines[_last]'`),d.push(` fi`),d.push(' for _line in "${_lines[@]}"; do'),d.push(` [[ -z "$_line" ]] && continue`),d.push(` COMPREPLY+=("$_line")`),d.push(` done`),d.push(' local _ip="${_inline_prefix:-}"'),d.push(` if (( _directive & ${_.DirectoryCompletion} )); then`),d.push(` compopt +o default 2>/dev/null`),d.push(` compopt -o filenames 2>/dev/null`),d.push(` local _d`),d.push(' while IFS= read -r _d; do COMPREPLY+=("${_ip}${_d}"); done < <(compgen -d -- "$_cur")'),d.push(' if (( ${#COMPREPLY[@]} == 0 )); then COMPREPLY=( "" ); fi'),d.push(` elif (( _directive & ${_.FileCompletion} )); then`),d.push(' if (( ${#COMPREPLY[@]} > 0 )) || [[ -n "$_ip" ]]; then'),d.push(` compopt -o filenames 2>/dev/null`),d.push(` local _f`),d.push(' while IFS= read -r _f; do COMPREPLY+=("${_ip}${_f}"); done < <(compgen -f -- "$_cur")'),d.push(` else`),d.push(` compopt -o default 2>/dev/null`),d.push(` fi`),d.push(` else`),d.push(` if (( _directive & ${_.NoFileCompletion} )); then`),d.push(` compopt +o default 2>/dev/null`),d.push(' if (( ${#COMPREPLY[@]} == 0 )); then COMPREPLY=( "" ); fi'),d.push(` fi`),d.push(` fi`),d.push(` if (( _directive & ${_.NoSpace} )); then`),d.push(` compopt -o nospace 2>/dev/null`),d.push(` fi`),d.push(`}`),d.push(``)),d.push(`__${a}_not_used() {`),d.push(' for _u in "${_used_opts[@]}"; do'),d.push(` for _chk in "$@"; do`),d.push(` [[ "$_u" == "$_chk" ]] && return 1`),d.push(` done`),d.push(` done`),d.push(` return 0`),d.push(`}`),d.push(``),d.push(`__${a}_opt_takes_value() {`),d.push(` case "$1:$2" in`),d.push(...Ee(s,``)),d.push(` esac`),d.push(` return 1`),d.push(`}`),d.push(``),p&&(d.push(`__${a}_track_opt() {`),d.push(` case "$1:$2" in`),d.push(...Ae(u,`bash`)),d.push(` esac`),d.push(`}`),d.push(``),d.push(`__${a}_track_pos() {`),d.push(` case "$1:$2" in`),d.push(...je(u,`bash`)),d.push(` esac`),d.push(`}`),d.push(``),d.push(...h(a,Te(s)))),g&&(d.push(`__${a}_track_array_expand() {`),d.push(` case "$1:$2" in`),d.push(...Me(m,`bash`)),d.push(` esac`),d.push(`}`),d.push(``));let v=L(s);v.length>0&&(d.push(`__${a}_is_subcmd() {`),d.push(` case "$1:$2" in`),d.push(...De(v)),d.push(` esac`),d.push(` return 1`),d.push(`}`),d.push(``));for(let e of c)d.push(...Je(e,a,[]));if(d.push(`__${a}_complete_root() {`),d.push(...Ke(s.options,s.positionals,a,`root`)),d.push(` if [[ -z "$_inline_prefix" ]] && __${a}_opt_takes_value "" "$_prev"; then return; fi`),d.push(` if [[ -n "$_inline_prefix" ]] && __${a}_opt_takes_value "" "\${_inline_prefix%=}"; then return; fi`),s.positionals.length>0?(d.push(` if (( _after_dd )); then`),d.push(...q(s.positionals,a,`root`,s.options).map(e=>` ${e}`)),d.push(` return`),d.push(` fi`)):d.push(` if (( _after_dd )); then return; fi`),d.push(` if [[ "$_cur" == -* ]]; then`),d.push(` local -a _avail=()`),d.push(...qe(s.options,a)),d.push(' COMPREPLY=($(compgen -W "${_avail[*]}" -- "$_cur"))'),d.push(` compopt +o default 2>/dev/null`),c.length>0){d.push(` else`);let e=P(s.subcommands).map(e=>e.name).join(` `);d.push(...Ge(e,s.positionals,a,`root`,s.options).map(e=>` ${e}`))}else s.positionals.length>0&&(d.push(` else`),d.push(...q(s.positionals,a,`root`,s.options).map(e=>` ${e}`)));d.push(` fi`),d.push(`}`),d.push(``);let y=Oe(v,a).join(`
3
3
  `);d.push(`_${a}_completions() {`),d.push(` COMPREPLY=()`),d.push(``),d.push(` # Rejoin words split by '=' in COMP_WORDBREAKS`),d.push(` local -a _words=()`),d.push(` local _i=1`),d.push(` while (( _i <= COMP_CWORD )); do`),d.push(' if [[ "${COMP_WORDS[_i]}" == "=" && ${#_words[@]} -gt 0 ]]; then'),d.push(' _words[${#_words[@]}-1]+="=${COMP_WORDS[_i+1]:-}"'),d.push(` (( _i += 2 ))`),d.push(` else`),d.push(' _words+=("${COMP_WORDS[_i]}")'),d.push(` (( _i++ ))`),d.push(` fi`),d.push(` done`),d.push(``),d.push(` local _cur=""`),d.push(' (( ${#_words[@]} > 0 )) && _cur="${_words[${#_words[@]}-1]}"'),d.push(` local _inline_prefix=""`),d.push(``),d.push(` local _prev=""`),d.push(' (( ${#_words[@]} > 1 )) && _prev="${_words[${#_words[@]}-2]}"'),d.push(``),d.push(` local _subcmd="" _after_dd=0 _pos_count=0 _skip_next=0`),d.push(` local -a _used_opts=()`),p&&d.push(` local -a _pos_words=()`),d.push(` local _any_opt_used=0`),p&&(d.push(` ${K(`_arg_values_`)}`),d.push(` ${K(`_global_arg_values_`)}`)),g&&(d.push(` ${K(`_used_field_keys_`)}`),d.push(` ${K(`_global_used_field_keys_`)}`),d.push(` ${K(`_global_arr_seen_`)}`)),d.push(``),d.push(` local _j=0`),d.push(" while (( _j < ${#_words[@]} - 1 )); do"),d.push(' local _w="${_words[_j]}"'),d.push(` if (( _skip_next )); then _skip_next=0; (( _j++ )); continue; fi`),d.push(` if [[ "$_w" == "--" ]]; then _after_dd=1; (( _j++ )); continue; fi`);let b=p?`_pos_words+=("$_w"); `:``;d.push(` if (( _after_dd )); then ${b}(( _pos_count++ )); (( _j++ )); continue; fi`),d.push(` if [[ "$_w" == -*=* ]]; then`),d.push(' _used_opts+=("${_w%%=*}")'),d.push(` _any_opt_used=1`),p&&(d.push(` __${a}_track_opt "$_subcmd" "\${_w%%=*}" "\${_w#*=}"`),g&&d.push(` __${a}_track_array_expand "$_subcmd" "\${_w%%=*}" "\${_w#*=}"`)),d.push(` (( _j++ )); continue`),d.push(` fi`),d.push(` if [[ "$_w" == -* ]]; then`),d.push(` _used_opts+=("$_w")`),d.push(` _any_opt_used=1`),d.push(` if __${a}_opt_takes_value "$_subcmd" "$_w"; then`),d.push(' local _next="${_words[_j+1]:-}"'),d.push(` if [[ -n "$_next" && "$_next" != -* ]]; then _skip_next=1; fi`),p&&(d.push(` if (( _skip_next )); then`),d.push(` __${a}_track_opt "$_subcmd" "$_w" "$_next"`),g&&(d.push(" if (( _j + 2 < ${#_words[@]} )); then"),d.push(` __${a}_track_array_expand "$_subcmd" "$_w" "$_next"`),d.push(` fi`)),d.push(` fi`)),d.push(` fi`),d.push(` (( _j++ )); continue`),d.push(` fi`);let ee=g?`; ${K(`_arg_values_`)}; ${K(`_used_field_keys_`)}; ${K(`_global_arr_seen_`)}`:p?`; ${K(`_arg_values_`)}`:``,te=p?`_pos_words+=("$_w"); `:``;return v.length>0?d.push(` if __${a}_is_subcmd "$_subcmd" "$_w"; then _subcmd="\${_subcmd:+\${_subcmd}:}$_w"; _used_opts=(); _pos_count=0${p?`; _pos_words=()`:``}${ee}; else ${te}(( _pos_count++ )); fi`):(p&&d.push(` _pos_words+=("$_w")`),d.push(` (( _pos_count++ ))`)),d.push(` (( _j++ ))`),d.push(` done`),p&&d.push(` __${a}_track_positionals`),d.push(``),d.push(` if (( ! _after_dd )) && [[ "$_cur" == -*=* ]]; then`),d.push(' _inline_prefix="${_cur%%=*}="'),d.push(' _cur="${_cur#*=}"'),d.push(` fi`),d.push(``),d.push(` case "$_subcmd" in`),d.push(y),d.push(` *) __${a}_complete_root ;;`),d.push(` esac`),d.push(`}`),d.push(``),o||d.push(`complete -o default -F _${a}_completions ${n}`),d.push(``),{script:d.join(`
4
4
  `),shell:`bash`,installInstructions:`# To enable auto-refreshing bash completions, add this to your ~/.bashrc:
@@ -0,0 +1 @@
1
+ import"./with-completion-command-D8AbV0pu.js";import"./dynamic-eZ7UI_q1.js";export{t as createCompletionCommand,n as createCompletionWorkerPathCommand,r as createRefreshCompletionCommand,c as generateBundledCompletionWorker}from"./completion-B3F-g9jZ.js";
@@ -1,5 +1,5 @@
1
- import { $ as DynamicCompletionCandidate, I as ResolvedFieldMeta, Q as CompletionDirectiveMask, X as ExpandCompletion, a as ArgsSchema, c as Command, et as DynamicCompletionContext, nt as DynamicCompletionResult, r as AnyCommand, tt as DynamicCompletionResolver } from "./types-Dhar1ua6.js";
2
- import { _ as CompletionResult, a as bundledWorkerShellExtension, b as InferInternalArgs, c as validateBundledWorkerFile, d as CompletablePositional, f as CompletableSubcommand, g as CompletionOptions, h as CompletionMode, i as GenerateBundledCompletionWorkerResult, l as BundledWorkerOptions, m as CompletionGenerator, n as withCompletionCommand, o as defaultBundledWorkerOutputPath, p as CompletionData, r as GenerateBundledCompletionWorkerOptions, s as generateBundledCompletionWorker, t as WithCompletionOptions, u as CompletableOption, v as ShellType, x as InternalArgsSchema, y as ValueCompletion } from "./with-completion-command-CARvhYvv.js";
1
+ import { $ as DynamicCompletionCandidate, I as ResolvedFieldMeta, Q as CompletionDirectiveMask, X as ExpandCompletion, a as ArgsSchema, c as Command, et as DynamicCompletionContext, nt as DynamicCompletionResult, r as AnyCommand, tt as DynamicCompletionResolver } from "./types-DtQ-Zt3n.js";
2
+ import { _ as CompletionResult, a as bundledWorkerShellExtension, b as InferInternalArgs, c as validateBundledWorkerFile, d as CompletablePositional, f as CompletableSubcommand, g as CompletionOptions, h as CompletionMode, i as GenerateBundledCompletionWorkerResult, l as BundledWorkerOptions, m as CompletionGenerator, n as withCompletionCommand, o as defaultBundledWorkerOutputPath, p as CompletionData, r as GenerateBundledCompletionWorkerOptions, s as generateBundledCompletionWorker, t as WithCompletionOptions, u as CompletableOption, v as ShellType, x as InternalArgsSchema, y as ValueCompletion } from "./with-completion-command-QHQsd0Zt.js";
3
3
  //#region ../core/src/completion/schemas.d.ts
4
4
  /**
5
5
  * Schema for the completion command arguments
@@ -1 +1 @@
1
- import{s as e,t}from"./with-completion-command-yg7HB6Zu.js";import"./register-Ceh-HlVN.js";import{a as n,i as r,n as i,o as a,r as o,s,t as c}from"./dynamic-Hg5BDHzz.js";import{a as l,c as u,d,i as f,l as p,n as m,o as h,r as g,s as _,t as v,u as y}from"./completion-Cyw4RN-l.js";export{r as CompletionDirective,h as bundledWorkerShellExtension,v as createCompletionCommand,m as createCompletionWorkerPathCommand,c as createDynamicCompleteCommand,g as createRefreshCompletionCommand,_ as defaultBundledWorkerOutputPath,e as detectShell,y as extractCompletionData,d as extractPositionals,o as formatForShell,u as generateBundledCompletionWorker,n as generateCandidates,f as generateCompletion,l as getSupportedShells,i as hasCompleteCommand,a as parseCompletionContext,s as resolveValueCompletion,p as validateBundledWorkerFile,t as withCompletionCommand};
1
+ import{s as e,t}from"./with-completion-command-D8AbV0pu.js";import"./register-Ceh-HlVN.js";import{a as n,i as r,n as i,o as a,r as o,s,t as c}from"./dynamic-eZ7UI_q1.js";import{a as l,c as u,d,i as f,l as p,n as m,o as h,r as g,s as _,t as v,u as y}from"./completion-B3F-g9jZ.js";export{r as CompletionDirective,h as bundledWorkerShellExtension,v as createCompletionCommand,m as createCompletionWorkerPathCommand,c as createDynamicCompleteCommand,g as createRefreshCompletionCommand,_ as defaultBundledWorkerOutputPath,e as detectShell,y as extractCompletionData,d as extractPositionals,o as formatForShell,u as generateBundledCompletionWorker,n as generateCandidates,f as generateCompletion,l as getSupportedShells,i as hasCompleteCommand,a as parseCompletionContext,s as resolveValueCompletion,p as validateBundledWorkerFile,t as withCompletionCommand};
package/dist/docs.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { F as ExtractedFields, I as ResolvedFieldMeta, a as ArgsSchema, k as SubCommandValue, ot as SchemaLike, r as AnyCommand, u as Example } from "./types-Dhar1ua6.js";
1
+ import { F as ExtractedFields, I as ResolvedFieldMeta, a as ArgsSchema, k as SubCommandValue, ot as SchemaLike, r as AnyCommand, u as Example } from "./types-DtQ-Zt3n.js";
2
2
  import * as fs$1 from "node:fs";
3
3
  //#region ../core/src/executor/subcommand-router.d.ts
4
4
  /**
package/dist/docs.js CHANGED
@@ -1,8 +1,8 @@
1
- import{t as e}from"./registry-BEz5iex_.js";import{c as t,n,o as r,r as i,s as a,t as o}from"./schema-extractor-DFawzmtj.js";import{r as s}from"./subcommand-router-iqmWGZyU.js";import{t as c}from"./log-collector-uhRWYT-z.js";import"./register-Ceh-HlVN.js";import*as l from"node:fs";import*as u from"node:path";import d from"node:path";import{isDeepStrictEqual as f}from"node:util";const p=[`option`,`alias`,`description`,`required`,`default`];function m(e){return`(↔ \`--${e.cliName}\`)`}function h(e){return e.placeholder??e.cliName.toUpperCase().replace(/-/g,`_`)}function g(e){return e.type===`boolean`?`--${e.cliName}`:`--${e.cliName} <${h(e)}>`}function _(e){let t=g(e),n=[];if(e.alias)for(let t of e.alias)n.push(t.length===1?`-${t}`:`--${t}`);let r=e.type===`boolean`&&!!e.negationDisplay,i=r&&!e.negationDescription?`--${e.negationDisplay}`:void 0,a=r&&e.negationDescription?{flag:`--${e.negationDisplay}`,description:e.negationDescription,relationMarker:m(e),required:e.required}:void 0;return{longFlag:t,aliases:n,inlineNegation:i,description:e.description,required:e.required,hasDefault:e.defaultValue!==void 0,defaultValue:e.defaultValue,env:e.env,negationRow:a}}function v(e){return e.map(_)}function y(e){return e.replace(/\r?\n/g,`<br>`)}function b(e){return y(e.replace(/\|/g,`\\|`))}function x(e){return`\`${e}\``}function S(e){return e.hasDefault?`\`${JSON.stringify(e.defaultValue)}\``:`-`}function C(e){return e?Array.isArray(e)?e.map(e=>`\`${e}\``).join(`, `):`\`${e}\``:`-`}function w(e){return e?` [env: ${(Array.isArray(e)?e:[e]).join(`, `)}]`:``}const T={option:{header:`Option`,separator:`--------`},alias:{header:`Alias`,separator:`-------`},description:{header:`Description`,separator:`-------------`},required:{header:`Required`,separator:`----------`},default:{header:`Default`,separator:`---------`},env:{header:`Env`,separator:`-----`}};function E(e,t){switch(t){case`option`:{let t=x(e.longFlag);return e.inlineNegation?`${t} / ${x(e.inlineNegation)}`:t}case`alias`:return e.aliases.length>0?e.aliases.map(x).join(`, `):`-`;case`description`:return b(e.description??``);case`required`:return e.required?`Yes`:`No`;case`default`:return S(e);case`env`:return C(e.env)}}function D(e,t){switch(t){case`option`:return x(e.flag);case`description`:return`${b(e.description)} ${e.relationMarker}`;case`required`:return e.required?`Yes`:`No`;case`alias`:case`default`:case`env`:return`-`}}function O(e,t){if(e.length===0)return``;let n=t??(e.some(e=>e.env)?[...p,`env`]:p),r=[];r.push(`| ${n.map(e=>T[e].header).join(` | `)} |`),r.push(`|${n.map(e=>T[e].separator).join(`|`)}|`);for(let t of e)r.push(`| ${n.map(e=>E(t,e)).join(` | `)} |`),t.negationRow&&r.push(`| ${n.map(e=>D(t.negationRow,e)).join(` | `)} |`);return r.join(`
1
+ import{t as e}from"./registry-BEz5iex_.js";import{c as t,n,o as r,r as i,s as a,t as o}from"./schema-extractor-BK1sJx7i.js";import{r as s}from"./subcommand-router-40vA6Mka.js";import{t as c}from"./log-collector-uhRWYT-z.js";import"./register-Ceh-HlVN.js";import*as l from"node:fs";import u,*as d from"node:path";import{isDeepStrictEqual as f}from"node:util";const p=[`option`,`alias`,`description`,`required`,`default`];function m(e){return`(↔ \`--${e.cliName}\`)`}function h(e){return e.placeholder??e.cliName.toUpperCase().replace(/-/g,`_`)}function g(e){return e.type===`boolean`?`--${e.cliName}`:`--${e.cliName} <${h(e)}>`}function _(e){let t=g(e),n=[];if(e.alias)for(let t of e.alias)n.push(t.length===1?`-${t}`:`--${t}`);let r=e.type===`boolean`&&!!e.negationDisplay,i=r&&!e.negationDescription?`--${e.negationDisplay}`:void 0,a=r&&e.negationDescription?{flag:`--${e.negationDisplay}`,description:e.negationDescription,relationMarker:m(e),required:e.required}:void 0;return{longFlag:t,aliases:n,inlineNegation:i,description:e.description,required:e.required,hasDefault:e.defaultValue!==void 0,defaultValue:e.defaultValue,env:e.env,negationRow:a}}function v(e){return e.map(_)}function y(e){return e.replace(/\r?\n/g,`<br>`)}function b(e){return y(e.replace(/\|/g,`\\|`))}function x(e){return`\`${e}\``}function S(e){return e.hasDefault?`\`${JSON.stringify(e.defaultValue)}\``:`-`}function C(e){return e?Array.isArray(e)?e.map(e=>`\`${e}\``).join(`, `):`\`${e}\``:`-`}function w(e){return e?` [env: ${(Array.isArray(e)?e:[e]).join(`, `)}]`:``}const T={option:{header:`Option`,separator:`--------`},alias:{header:`Alias`,separator:`-------`},description:{header:`Description`,separator:`-------------`},required:{header:`Required`,separator:`----------`},default:{header:`Default`,separator:`---------`},env:{header:`Env`,separator:`-----`}};function E(e,t){switch(t){case`option`:{let t=x(e.longFlag);return e.inlineNegation?`${t} / ${x(e.inlineNegation)}`:t}case`alias`:return e.aliases.length>0?e.aliases.map(x).join(`, `):`-`;case`description`:return b(e.description??``);case`required`:return e.required?`Yes`:`No`;case`default`:return S(e);case`env`:return C(e.env)}}function D(e,t){switch(t){case`option`:return x(e.flag);case`description`:return`${b(e.description)} ${e.relationMarker}`;case`required`:return e.required?`Yes`:`No`;case`alias`:case`default`:case`env`:return`-`}}function O(e,t){if(e.length===0)return``;let n=t??(e.some(e=>e.env)?[...p,`env`]:p),r=[];r.push(`| ${n.map(e=>T[e].header).join(` | `)} |`),r.push(`|${n.map(e=>T[e].separator).join(`|`)}|`);for(let t of e)r.push(`| ${n.map(e=>E(t,e)).join(` | `)} |`),t.negationRow&&r.push(`| ${n.map(e=>D(t.negationRow,e)).join(` | `)} |`);return r.join(`
2
2
  `)}function k(e){if(e.length===0)return``;let t=[];for(let n of e){let e=n.aliases.filter(e=>!e.startsWith(`--`)),r=n.aliases.filter(e=>e.startsWith(`--`)),i=[...e,n.longFlag,...r].map(x).join(`, `);n.inlineNegation&&(i+=` / ${x(n.inlineNegation)}`);let a=n.description?` - ${y(n.description)}`:``,o=n.required?` (required)`:``,s=n.hasDefault?` (default: ${JSON.stringify(n.defaultValue)})`:``,c=w(n.env);t.push(`- ${i}${a}${o}${s}${c}`),n.negationRow&&t.push(`- ${x(n.negationRow.flag)} - ${y(n.negationRow.description)} ${n.negationRow.relationMarker}`)}return t.join(`
3
3
  `)}const A=`POLITTY_DOCS_UPDATE`,j=`POLITTY_DOCS_DOCTOR`,M=[`heading`,`description`,`usage`,`arguments`,`options`,`global-options-link`,`subcommands`,`examples`,`notes`],N=`politty:command`;function P(e,t){return`<!-- ${N}:${t}:${e}:start -->`}function F(e,t){return`<!-- ${N}:${t}:${e}:end -->`}const I=`politty:global-options`;function L(){return`<!-- ${I}:start -->`}function ee(){return`<!-- ${I}:end -->`}const R=`politty:root-header`;function te(){return`<!-- ${R}:start -->`}function ne(){return`<!-- ${R}:end -->`}const z=`politty:root-footer`;function re(){return`<!-- ${z}:start -->`}function ie(){return`<!-- ${z}:end -->`}const B=`politty:index`;function V(e){return`<!-- ${B}:${e}:start -->`}function ae(e){return`<!-- ${B}:${e}:end -->`}function oe(e){return y(e.replace(/\|/g,`\\|`))}function se(e){let t=[e.fullCommandPath];e.options.length>0&&t.push(`[options]`),e.subCommands.length>0&&(e.command.run||e.command.defaultSubCommand?t.push(`[command]`):t.push(`<command>`));for(let n of e.positionalArgs)n.required?t.push(`<${n.name}>`):t.push(`[${n.name}]`);return t.join(` `)}function ce(e){return de(e,Se)}function le(e){return e.named?`\`${e.name}\`, \`${g(e)}\``:`\`${e.name}\``}function ue(e){return de(e,Ce)}function de(e,t,n=e.positionalArgs){let r=fe(e.extracted),i=r.length>0?o(r):void 0,a=new Set(n.map(e=>e.name)),s=[],c=n.filter(e=>i===void 0||i.has(e.name));c.length>0&&s.push(t(c));for(let e of r){let n=e.fields.filter(e=>e.positional&&!i?.has(e.name)&&a.has(e.name));n.length>0&&s.push(`${e.label}\n\n${t(n)}`)}return s.join(`
4
4
 
5
- `)}function fe(e){if(e?.schemaType===`discriminatedUnion`&&e.discriminator){let t=e.discriminator;return(e.variants??[]).map(e=>({label:pe(t,e),fields:e.fields}))}return(e?.schemaType===`union`||e?.schemaType===`xor`)&&e.unionOptions?e.unionOptions.map((e,t)=>({label:me(e,t),fields:e.fields})):[]}function pe(e,t){let n=t.description?` ${t.description}`:``;return`**When \`${e}\` = \`${t.discriminatorValue}\`:**${n}`}function me(e,t){return`**${e.description??`Variant ${t+1}`}:**`}function he(e){return O(v(e.options))}function ge(e){return k(v(e.options))}function _e(e){return e.join(`-`).toLowerCase()}function ve(e,t){let n=e.replace(/\\/g,`/`),r=t.replace(/\\/g,`/`);return d.posix.relative(d.posix.dirname(n),r)}function ye(e,t=!0){return we(e.subCommands,e,t)}function H(e){return O(v(e))}function be(e,t=`table`){let n=e.unionOptions??[];if(n.length===0)return``;let r=[],i=o(n),a=e.fields.filter(e=>i.has(e.name)&&!e.positional);a.length>0&&r.push(t===`table`?H(a):U(a)),r.push(`> One of the following option groups is required:`);for(let e=0;e<n.length;e++){let a=n[e];if(!a)continue;let o=a.fields.filter(e=>!i.has(e.name)&&!e.positional),s=me(a,e);if(o.length===0){r.push(`${s}\n\n_no options_`);continue}let c=t===`table`?H(o):U(o);r.push(`${s}\n\n${c}`)}return r.join(`
5
+ `)}function fe(e){if(e?.schemaType===`discriminatedUnion`&&e.discriminator){let t=e.discriminator;return(e.variants??[]).map(e=>({label:pe(t,e),fields:e.fields}))}return(e?.schemaType===`union`||e?.schemaType===`xor`)&&e.unionOptions?e.unionOptions.map((e,t)=>({label:me(e,t),fields:e.fields})):[]}function pe(e,t){let n=t.description?` ${t.description}`:``;return`**When \`${e}\` = \`${t.discriminatorValue}\`:**${n}`}function me(e,t){return`**${e.description??`Variant ${t+1}`}:**`}function he(e){return O(v(e.options))}function ge(e){return k(v(e.options))}function _e(e){return e.join(`-`).toLowerCase()}function ve(e,t){let n=e.replace(/\\/g,`/`),r=t.replace(/\\/g,`/`);return u.posix.relative(u.posix.dirname(n),r)}function ye(e,t=!0){return we(e.subCommands,e,t)}function H(e){return O(v(e))}function be(e,t=`table`){let n=e.unionOptions??[];if(n.length===0)return``;let r=[],i=o(n),a=e.fields.filter(e=>i.has(e.name)&&!e.positional);a.length>0&&r.push(t===`table`?H(a):U(a)),r.push(`> One of the following option groups is required:`);for(let e=0;e<n.length;e++){let a=n[e];if(!a)continue;let o=a.fields.filter(e=>!i.has(e.name)&&!e.positional),s=me(a,e);if(o.length===0){r.push(`${s}\n\n_no options_`);continue}let c=t===`table`?H(o):U(o);r.push(`${s}\n\n${c}`)}return r.join(`
6
6
 
7
7
  `)}function xe(e,t=`table`){let n=e.discriminator,i=e.variants??[];if(!n||i.length===0)return``;let a=[],s=o(i,n),c=r(e,n),l=i.map(e=>e.discriminatorValue).join(`\\|`),u=[];c&&u.push({...c,placeholder:l});for(let t of s){let n=e.fields.find(e=>e.name===t);n&&!n.positional&&u.push(n)}u.length>0&&a.push(t===`table`?H(u):U(u));for(let e of i){let r=e.fields.filter(e=>e.name!==n&&!s.has(e.name)&&!e.positional);if(r.length===0)continue;let i=pe(n,e),o=t===`table`?H(r):U(r);a.push(`${i}\n\n${o}`)}return a.join(`
8
8
 
@@ -15,10 +15,10 @@ import{t as e}from"./registry-BEz5iex_.js";import{c as t,n,o as r,r as i,s as a,
15
15
  `),heading:``,info:e},r=o?o(n):n.content;r&&a.push(m(`description`,h,r))}}{let t={content:`**Usage**\n\n\`\`\`\n${se(e)}\n\`\`\``,heading:`**Usage**`,info:e},n=s?s(t):t.content;n&&a.push(m(`usage`,h,n))}if(e.positionalArgs.length>0){let t=(t,r)=>{let i=r?.style??n,a=r?.withHeading??!0,o=i===`table`?Se:Ce,s=fe(e.extracted).length>0?de(e,o,t):o(t);return a?`**Arguments**\n\n${s}`:s},r={args:e.positionalArgs,render:t,heading:`**Arguments**`,info:e},i=c?c(r):t(r.args);i&&a.push(m(`arguments`,h,i))}if(e.options.length>0){let t=(t,r)=>{let i=r?.style??n,a=r?.withHeading??!0,o=e.extracted,s;return s=o&&(o.schemaType===`union`||o.schemaType===`xor`)&&o.unionOptions?be(o,i):o&&o.schemaType===`discriminatedUnion`&&o.discriminator?xe(o,i):i===`table`?H(t):U(t),a?`**Options**\n\n${s}`:s},r={options:e.options,render:t,heading:`**Options**`,info:e},i=l?l(r):t(r.options);i&&a.push(m(`options`,h,i))}{let t=De(e);t&&a.push(m(`global-options-link`,h,t))}if(e.subCommands.length>0){let t=r&&i,n=(n,r)=>{let i=r?.generateAnchors??t,a=r?.withHeading??!0,o=we(n,e,i);return a?`**Commands**\n\n${o}`:o},o={subcommands:e.subCommands,render:n,heading:`**Commands**`,info:e},s=u?u(o):n(o.subcommands);s&&a.push(m(`subcommands`,h,s))}if(e.examples&&e.examples.length>0){let t=(t,n,r)=>{let i=r?.withHeading??!0,a=Te(t,n,{commandPrefix:e.fullCommandPath,...r});return i?`**Examples**\n\n${a}`:a},n={examples:e.examples,results:e.exampleResults,render:t,heading:`**Examples**`,info:e},r=p?p(n):t(n.examples,n.results);r&&a.push(m(`examples`,h,r))}if(e.notes){let t={content:`**Notes**\n\n${e.notes}`,heading:`**Notes**`,info:e},n=d?d(t):t.content;n&&a.push(m(`notes`,h,n))}{let t={content:``,heading:``,info:e},n=f?f(t):t.content;n&&a.push(n)}return a.join(`
16
16
 
17
17
  `)+`
18
- `}}const Oe={command:e=>W(e),tableStyle:W({optionStyle:`table`}),listStyle:W({optionStyle:`list`})};function ke(e,t){let n=u.resolve(t);if(!l.existsSync(n))return{match:!1,fileExists:!1};let r=l.readFileSync(n,`utf-8`);return e===r?{match:!0,fileExists:!0}:{match:!1,diff:G(r,e),fileExists:!0}}function G(e,t){let n=e.split(`
18
+ `}}const Oe={command:e=>W(e),tableStyle:W({optionStyle:`table`}),listStyle:W({optionStyle:`list`})};function ke(e,t){let n=d.resolve(t);if(!l.existsSync(n))return{match:!1,fileExists:!1};let r=l.readFileSync(n,`utf-8`);return e===r?{match:!0,fileExists:!0}:{match:!1,diff:G(r,e),fileExists:!0}}function G(e,t){let n=e.split(`
19
19
  `),r=t.split(`
20
20
  `),i=[];i.push(`--- existing`),i.push(`+++ generated`),i.push(``);let a=Math.max(n.length,r.length),o=!1,s=0,c=[],l=()=>{c.length>0&&(i.push(`@@ -${s+1},${c.length} @@`),i.push(...c),c.length=0),o=!1};for(let e=0;e<a;e++){let t=n[e],i=r[e];if(t===i){if(o){c.push(` ${t??``}`);let e=c.findIndex((e,t)=>(e.startsWith(`-`)||e.startsWith(`+`))&&c.slice(t+1).every(e=>e.startsWith(` `)));e!==-1&&c.length-e>3&&l()}}else{if(!o){o=!0,s=e;let t=Math.max(0,e-3);for(let r=t;r<e;r++)c.push(` ${n[r]??``}`)}t!==void 0&&(i===void 0||t!==i)&&c.push(`-${t}`),i!==void 0&&(t===void 0||t!==i)&&c.push(`+${i}`)}}return l(),i.join(`
21
- `)}function K(e,t){let n=u.resolve(e),r=u.dirname(n);l.existsSync(r)||l.mkdirSync(r,{recursive:!0}),l.writeFileSync(n,t,`utf-8`)}function Ae(e){let t=u.resolve(e);return l.existsSync(t)?l.readFileSync(t,`utf-8`):null}function je(e,t=l){let n=u.resolve(e);t.existsSync(n)&&t.unlinkSync(n)}async function Me(e,t,n=[]){return Ne(e,t,n,!1)}async function Ne(e,n,r,o){let c=i(e),l=c?t(c):[],u=c?a(c):[],d=[];if(e.subCommands)for(let[t,n]of Object.entries(e.subCommands)){let i=await s(n,t=>o||!!e.requiredPackages?.length||!!t.requiredPackages?.length),a=[...r,t];d.push({name:t,description:i.description,aliases:i.aliases,fullPath:a})}return{name:e.name??``,description:e.description,aliases:e.aliases,fullCommandPath:r.length>0?`${n} ${r.join(` `)}`:n,commandPath:r.join(` `),depth:r.length+1,positionalArgs:l,options:u,subCommands:d,extracted:c,command:e,notes:e.notes,examples:e.examples}}async function Pe(e,t){let n=t??e.name??`command`,r=/* @__PURE__ */ new Map;async function i(e,t,a){a||=!!e.requiredPackages?.length;let o=await Ne(e,n,t,a),c=t.join(` `);if(r.set(c,o),e.subCommands)for(let[n,r]of Object.entries(e.subCommands))await i(await s(r,e=>a||!!e.requiredPackages?.length),[...t,n],a)}return await i(e,[],!1),r}async function Fe(e,t,n,r=[]){let i=[];t.mock&&await t.mock();try{for(let t of e){let e=await Ie(t,n,r);i.push(e)}}finally{t.cleanup&&await t.cleanup()}return i}async function Ie(e,t,n){let r=Le(e.cmd),i=[...n,...r],a=c({passthrough:!1});a.start();let o=!0;try{let{runCommand:e}=await import(`./runner-nPWQnqQ3.js`),n=await e(t,i);o=n.success,!n.success&&n.error&&console.error(n.error.message)}catch(e){o=!1,console.error(e instanceof Error?e.message:String(e))}finally{a.stop()}let s=a.getLogs(),l=s.entries.filter(e=>e.stream===`stdout`).map(e=>e.message).join(`
21
+ `)}function K(e,t){let n=d.resolve(e),r=d.dirname(n);l.existsSync(r)||l.mkdirSync(r,{recursive:!0}),l.writeFileSync(n,t,`utf-8`)}function Ae(e){let t=d.resolve(e);return l.existsSync(t)?l.readFileSync(t,`utf-8`):null}function je(e,t=l){let n=d.resolve(e);t.existsSync(n)&&t.unlinkSync(n)}async function Me(e,t,n=[]){return Ne(e,t,n,!1)}async function Ne(e,n,r,o){let c=i(e),l=c?t(c):[],u=c?a(c):[],d=[];if(e.subCommands)for(let[t,n]of Object.entries(e.subCommands)){let i=await s(n,t=>o||!!e.requiredPackages?.length||!!t.requiredPackages?.length),a=[...r,t];d.push({name:t,description:i.description,aliases:i.aliases,fullPath:a})}return{name:e.name??``,description:e.description,aliases:e.aliases,fullCommandPath:r.length>0?`${n} ${r.join(` `)}`:n,commandPath:r.join(` `),depth:r.length+1,positionalArgs:l,options:u,subCommands:d,extracted:c,command:e,notes:e.notes,examples:e.examples}}async function Pe(e,t){let n=t??e.name??`command`,r=/* @__PURE__ */ new Map;async function i(e,t,a){a||=!!e.requiredPackages?.length;let o=await Ne(e,n,t,a),c=t.join(` `);if(r.set(c,o),e.subCommands)for(let[n,r]of Object.entries(e.subCommands))await i(await s(r,e=>a||!!e.requiredPackages?.length),[...t,n],a)}return await i(e,[],!1),r}async function Fe(e,t,n,r=[]){let i=[];t.mock&&await t.mock();try{for(let t of e){let e=await Ie(t,n,r);i.push(e)}}finally{t.cleanup&&await t.cleanup()}return i}async function Ie(e,t,n){let r=Le(e.cmd),i=[...n,...r],a=c({passthrough:!1});a.start();let o=!0;try{let{runCommand:e}=await import(`./runner-DBTjtw2R.js`),n=await e(t,i);o=n.success,!n.success&&n.error&&console.error(n.error.message)}catch(e){o=!1,console.error(e instanceof Error?e.message:String(e))}finally{a.stop()}let s=a.getLogs(),l=s.entries.filter(e=>e.stream===`stdout`).map(e=>e.message).join(`
22
22
  `),u=s.entries.filter(e=>e.stream===`stderr`).map(e=>e.message).join(`
23
23
  `);return{cmd:e.cmd,desc:e.desc,expectedOutput:e.output,stdout:l,stderr:u,success:o}}function Le(e){let t=[],n=``,r=!1,i=``;for(let a=0;a<e.length;a++){let o=e[a];(o===`"`||o===`'`)&&!r?(r=!0,i=o):o===i&&r?(r=!1,i=``):o===` `&&!r?n&&=(t.push(n),``):n+=o}return n&&t.push(n),t}function Re(t){let n=e();return Object.entries(t).map(([e,t])=>n.resolveFieldMeta(e,t))}function ze(e,t){let n=Re(e).filter(e=>!e.positional);return n.length===0?``:O(v(n),t?.columns)}function Be(e){return e.replace(/\|/g,`\\|`).replace(/\n/g,` `)}function Ve(e){return e.replace(/\s+/g,`-`).toLowerCase()}function He(e){return e.subCommands.length===0}function Ue(e,t){return e===t?!0:t===``?e!==``:e.startsWith(t+` `)}function We(e,t,n){let r=[];for(let i of e){let e=t.get(i);if(e){if(He(e))r.push(i);else for(let[e,a]of t)(i===``?e.length>0:e.startsWith(i+` `)||e===i)&&(He(a)||!n)&&r.push(e)}}return r}function Ge(e,t,n,r){let i=`#`.repeat(n),a=[];a.push(`${i} [${e.title}](${e.docPath})`),a.push(``),a.push(e.description),a.push(``);let o=e.noExpand?e.commands:We(e.commands,t,r),s=o,c=/* @__PURE__ */ new Set;if(e.allowedCommands){let t=new Set(e.allowedCommands);s=o.filter(e=>t.has(e));for(let n of e.commands)t.has(n)&&!s.some(e=>Ue(e,n))&&(s.push(n),c.add(n))}a.push(`| Command | Description |`),a.push(`|---------|-------------|`);for(let n of s){let i=t.get(n);if(!i||!e.noExpand&&r&&!c.has(n)&&!He(i))continue;let o=n||i.name,s=Ve(o),l=Be(i.description??``);a.push(`| [${o}](${e.docPath}#${s}) | ${l} |`)}return a.join(`
24
24
  `)}async function Ke(e,t,n){let r=n?.headingLevel??3,i=n?.leafOnly??!0,a=await Pe(e),o=[];for(let e of t){let t=Ge(e,a,r,i);o.push(t)}return o.join(`
@@ -26,7 +26,7 @@ import{t as e}from"./registry-BEz5iex_.js";import{c as t,n,o as r,r as i,s as a,
26
26
  `)}async function q(e,t){if(!t)return e;let n=await t(e);return!e.endsWith(`
27
27
  `)&&n.endsWith(`
28
28
  `)?n.slice(0,-1):n}function qe(e){let t=process.env[e];return t===`true`||t===`1`}function Je(e){let t=e.split(/\r?\n/);if(t[0]!==`---`)return null;let n=[];for(let e=1;e<t.length;e++){let r=t[e];if(r===`---`||r===`...`)return n.join(`
29
- `);n.push(r??``)}return null}function Ye(e){let t=Et(e),n=e.split(/\r?\n/);if(n[0]!==`---`)return e;let r=-1;for(let e=1;e<n.length;e++){let t=n[e];if(t===`---`||t===`...`){r=e;break}}if(r===-1)return e;let i=n.slice(1,r),a=[];for(let e=0;e<i.length;e++){let t=i[e]??``;if(!/^politty\s*:\s*(.*)$/.test(t)){a.push(t);continue}for(;e+1<i.length;){let t=i[e+1]??``;if(t.trim()!==``&&!t.startsWith(` `)&&!t.startsWith(` `))break;e++}}let o=n.slice(r+1);return a.some(e=>e.trim()!==``)?[`---`,...a,n[r]??`---`,...o].join(t):o.join(t).replace(RegExp(`^${t}`),``)}function Xe(e){let t=e.trim();return t.length>=2&&(t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`))?t.slice(1,-1):t}function Ze(e){let t=Xe(e);if(t===``)return null;let n=t.match(/^\{\{politty:([^{}]*)\}\}$/);return n?t=n[1]??``:t.startsWith(`politty:`)&&(t=t.slice(8)),t===``?null:t}function Qe(e){return e.slice(2,-2).slice(8)}function $e(e){let t=e.trim();return!t.startsWith(`[`)||!t.endsWith(`]`)?[t]:t.slice(1,-1).split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function et(e,t){let n=Ze(t);n!==null&&e.add(n)}function tt(e){let t=/* @__PURE__ */ new Set,n=Je(e);if(n===null)return t;let r=!1,i=!1,a=0;for(let e of n.split(/\r?\n/)){let n=e.trim();if(n===``||n.startsWith(`#`))continue;let o=e.match(/^politty\s*:\s*(.*)$/);if(o){r=(o[1]?.trim()??``)===``,i=!1;continue}if(!e.startsWith(` `)&&!e.startsWith(` `)){r=!1,i=!1;continue}if(!r)continue;let s=e.match(/^(\s+)(?:exclude|excludes)\s*:\s*(.*)$/);if(s){let e=s[2]?.trim()??``;if(e===``)i=!0,a=s[1]?.length??0;else{i=!1;for(let n of $e(e))et(t,n)}continue}if(!i)continue;let c=e.match(/^(\s*)-\s*(.+)$/);if(!c||(c[1]?.length??0)<=a){i=!1;continue}et(t,c[2]??``)}return t}function nt(e){let t=Je(e);if(t===null)return{};let n=!1,r=!1,i=0,a={};for(let e of t.split(/\r?\n/)){let t=e.trim();if(t===``||t.startsWith(`#`))continue;let o=e.match(/^politty\s*:\s*(.*)$/);if(o){n=(o[1]?.trim()??``)===``,r=!1;continue}if(!e.startsWith(` `)&&!e.startsWith(` `)){n=!1,r=!1;continue}if(!n)continue;let s=e.match(/^(\s+)index\s*:\s*(.*)$/);if(s){r=(s[2]?.trim()??``)===``,i=s[1]?.length??0;continue}if(!r)continue;if((e.match(/^(\s*)/)?.[1]?.length??0)<=i){r=!1;continue}let c=e.match(/^\s+(title|description)\s*:\s*(.+)$/);if(!c)continue;let l=c[1],u=Xe(c[2]??``);l===`title`?a.title=u:l===`description`&&(a.description=u)}return a}function rt(e){return{rawKeys:e,commandScopes:/* @__PURE__ */ new Set,commandSections:/* @__PURE__ */ new Map,globalOptions:!1,index:!1}}function it(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})}function at(e){if(Array.isArray(e))return{commands:e};if(!(`commands`in e)||!Array.isArray(e.commands))throw Error(`Invalid file config: object form must include a "commands" array. Use [] to skip generation intentionally.`);return e}function J(e,t){return t===``||e===t||e.startsWith(t+` `)}function Y(e){return e.includes(`*`)}function ot(e,t){let n=e===``?[]:e.split(` `),r=t===``?[]:t.split(` `);if(n.length!==r.length)return!1;for(let e=0;e<r.length;e++){let t=r[e],i=n[e];if(t!==`*`&&t!==i)return!1}return!0}function st(e,t){let n=[];for(let r of t.keys())ot(r,e)&&n.push(r);return n}function ct(e,t){if(Y(t)){if(ot(e,t))return!0;let n=e===``?[]:e.split(` `),r=t===``?[]:t.split(` `);return n.length>r.length&&ot(n.slice(0,r.length).join(` `),t)}return J(e,t)}function lt(e,t){let n=/* @__PURE__ */ new Set,r=e.flatMap(e=>Y(e)?st(e,t):[e]);for(let e of r)for(let r of t.keys())J(r,e)&&n.add(r);return Array.from(n)}function ut(e,t){return e.filter(e=>!t.some(t=>ct(e,t)))}function dt(e,t){let n=[];for(let r of e)Y(r)?n.push(...st(r,t)):t.has(r)&&n.push(r);return n}function X(e,t,n){let r=at(e),i=r.commands;return{fileConfig:r,specifiedCommands:i,commandPaths:ut(r.noExpand?i.filter(e=>t.has(e)):lt(i,t),n),topLevelCommands:ut(dt(i,t),n)}}function ft(e,t,n){let r=[];for(let i of e){let e=Y(i)?st(i,n):[i];for(let n of e)for(let e of t)Y(e)?ot(n,e)&&r.push(`"${n}" is both in files and ignored by "${e}"`):(n===e||J(n,e))&&r.push(`"${n}" is both in files and ignored by "${e}"`)}if(r.length>0)throw Error(`Conflict between files and ignores:\n - ${r.join(`
29
+ `);n.push(r??``)}return null}function Ye(e){let t=Et(e),n=e.split(/\r?\n/);if(n[0]!==`---`)return e;let r=-1;for(let e=1;e<n.length;e++){let t=n[e];if(t===`---`||t===`...`){r=e;break}}if(r===-1)return e;let i=n.slice(1,r),a=[];for(let e=0;e<i.length;e++){let t=i[e]??``;if(!/^politty\s*:\s*(.*)$/.test(t))a.push(t);else for(;e+1<i.length;){let t=i[e+1]??``;if(t.trim()!==``&&!t.startsWith(` `)&&!t.startsWith(` `))break;e++}}let o=n.slice(r+1);return a.some(e=>e.trim()!==``)?[`---`,...a,n[r]??`---`,...o].join(t):o.join(t).replace(RegExp(`^${t}`),``)}function Xe(e){let t=e.trim();return t.length>=2&&(t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`))?t.slice(1,-1):t}function Ze(e){let t=Xe(e);if(t===``)return null;let n=t.match(/^\{\{politty:([^{}]*)\}\}$/);return n?t=n[1]??``:t.startsWith(`politty:`)&&(t=t.slice(8)),t===``?null:t}function Qe(e){return e.slice(2,-2).slice(8)}function $e(e){let t=e.trim();return!t.startsWith(`[`)||!t.endsWith(`]`)?[t]:t.slice(1,-1).split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function et(e,t){let n=Ze(t);n!==null&&e.add(n)}function tt(e){let t=/* @__PURE__ */ new Set,n=Je(e);if(n===null)return t;let r=!1,i=!1,a=0;for(let e of n.split(/\r?\n/)){let n=e.trim();if(n===``||n.startsWith(`#`))continue;let o=e.match(/^politty\s*:\s*(.*)$/);if(o){r=(o[1]?.trim()??``)===``,i=!1;continue}if(!e.startsWith(` `)&&!e.startsWith(` `)){r=!1,i=!1;continue}if(!r)continue;let s=e.match(/^(\s+)(?:exclude|excludes)\s*:\s*(.*)$/);if(s){let e=s[2]?.trim()??``;if(e===``)i=!0,a=s[1]?.length??0;else{i=!1;for(let n of $e(e))et(t,n)}continue}if(!i)continue;let c=e.match(/^(\s*)-\s*(.+)$/);!c||(c[1]?.length??0)<=a?i=!1:et(t,c[2]??``)}return t}function nt(e){let t=Je(e);if(t===null)return{};let n=!1,r=!1,i=0,a={};for(let e of t.split(/\r?\n/)){let t=e.trim();if(t===``||t.startsWith(`#`))continue;let o=e.match(/^politty\s*:\s*(.*)$/);if(o){n=(o[1]?.trim()??``)===``,r=!1;continue}if(!e.startsWith(` `)&&!e.startsWith(` `)){n=!1,r=!1;continue}if(!n)continue;let s=e.match(/^(\s+)index\s*:\s*(.*)$/);if(s){r=(s[2]?.trim()??``)===``,i=s[1]?.length??0;continue}if(!r)continue;if((e.match(/^(\s*)/)?.[1]?.length??0)<=i){r=!1;continue}let c=e.match(/^\s+(title|description)\s*:\s*(.+)$/);if(!c)continue;let l=c[1],u=Xe(c[2]??``);l===`title`?a.title=u:l===`description`&&(a.description=u)}return a}function rt(e){return{rawKeys:e,commandScopes:/* @__PURE__ */ new Set,commandSections:/* @__PURE__ */ new Map,globalOptions:!1,index:!1}}function it(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})}function at(e){if(Array.isArray(e))return{commands:e};if(!(`commands`in e)||!Array.isArray(e.commands))throw Error(`Invalid file config: object form must include a "commands" array. Use [] to skip generation intentionally.`);return e}function J(e,t){return t===``||e===t||e.startsWith(t+` `)}function Y(e){return e.includes(`*`)}function ot(e,t){let n=e===``?[]:e.split(` `),r=t===``?[]:t.split(` `);if(n.length!==r.length)return!1;for(let e=0;e<r.length;e++){let t=r[e],i=n[e];if(t!==`*`&&t!==i)return!1}return!0}function st(e,t){let n=[];for(let r of t.keys())ot(r,e)&&n.push(r);return n}function ct(e,t){if(Y(t)){if(ot(e,t))return!0;let n=e===``?[]:e.split(` `),r=t===``?[]:t.split(` `);return n.length>r.length&&ot(n.slice(0,r.length).join(` `),t)}return J(e,t)}function lt(e,t){let n=/* @__PURE__ */ new Set,r=e.flatMap(e=>Y(e)?st(e,t):[e]);for(let e of r)for(let r of t.keys())J(r,e)&&n.add(r);return Array.from(n)}function ut(e,t){return e.filter(e=>!t.some(t=>ct(e,t)))}function dt(e,t){let n=[];for(let r of e)Y(r)?n.push(...st(r,t)):t.has(r)&&n.push(r);return n}function X(e,t,n){let r=at(e),i=r.commands;return{fileConfig:r,specifiedCommands:i,commandPaths:ut(r.noExpand?i.filter(e=>t.has(e)):lt(i,t),n),topLevelCommands:ut(dt(i,t),n)}}function ft(e,t,n){let r=[];for(let i of e){let e=Y(i)?st(i,n):[i];for(let n of e)for(let e of t)Y(e)?ot(n,e)&&r.push(`"${n}" is both in files and ignored by "${e}"`):(n===e||J(n,e))&&r.push(`"${n}" is both in files and ignored by "${e}"`)}if(r.length>0)throw Error(`Conflict between files and ignores:\n - ${r.join(`
30
30
  - `)}`)}function pt(e,t){let n=[];for(let r of e)Y(r)?st(r,t).length===0&&n.push(`"${r}"`):t.has(r)||n.push(`"${r}"`);if(n.length>0)throw Error(`Ignored command paths do not exist: ${n.join(`, `)}`)}function mt(e,t){let n=new Set(e),r=t.filter(e=>n.has(e));for(let t of e)(t===``?0:t.split(` `).length)===1&&!r.includes(t)&&r.push(t);let i=[],a=/* @__PURE__ */ new Set;function o(t){if(a.has(t)||!n.has(t))return;a.add(t),i.push(t);let r=e.filter(e=>e===t||a.has(e)?!1:t===``?e.split(` `).length===1:e.startsWith(t+` `)&&e.split(` `).length===t.split(` `).length+1).sort((e,t)=>e.localeCompare(t));for(let e of r)o(e)}for(let e of r)o(e);for(let t of e)a.has(t)||i.push(t);return i}function ht(e){if(!e.title&&!e.description)return null;let t=[];if(e.title){let n=`#`.repeat(e.headingLevel??1);t.push(`${n} ${e.title}`)}return e.description&&(t.push(``),t.push(e.description)),t.push(``),t.join(`
31
31
  `)}function gt(e){if(!/^#{1,6} /.test(e))return null;let t=e.indexOf(`
32
32
  `);if(t===-1)return e;let n=t+1;for(e[n]===`
@@ -61,17 +61,17 @@ import{t as e}from"./registry-BEz5iex_.js";import{c as t,n,o as r,r as i,s as a,
61
61
  `),e}function wt(e){let t=Tt(e.split(`
62
62
  `).filter(e=>!/^<!-- politty:.*-->$/.test(e.trim())).join(`
63
63
  `));return t=t.replace(/^\n+/,``).replace(/\n+$/,``),t}function Tt(e){let t=e.split(`
64
- `),n=[],r=!1,i=0;for(let e of t){let t=e.trim();if(t.startsWith("```")||t.startsWith(`~~~`)){r=!r,i=0,n.push(e);continue}if(!r&&e.trim()===``){if(i++,i>=2)continue}else r||(i=0);n.push(e)}return n.join(`
64
+ `),n=[],r=!1,i=0;for(let e of t){let t=e.trim();if(t.startsWith("```")||t.startsWith(`~~~`))r=!r,i=0,n.push(e);else{if(!r&&e.trim()===``){if(i++,i>=2)continue}else r||(i=0);n.push(e)}}return n.join(`
65
65
  `)}function Et(e){return e.includes(`\r
66
66
  `)?`\r
67
67
  `:`
68
68
  `}function Dt(e){return(e.match(/\n/g)??[]).length}function Ot(e){return M.some(t=>t===e)}function kt(e){switch(Math.min(6,Math.max(1,Math.trunc(e)))){case 1:return 1;case 2:return 2;case 3:return 3;case 4:return 4;case 5:return 5;default:return 6}}function At(e,t){if(e.length===0)return t===void 0||t.has(``)?``:null;let n=e.join(`:`);if(t?.has(n))return n;let r=e.join(` `);return t?.has(r)||t===void 0?r:null}function jt(e){return e.join(` `)}function Mt(e,t){let n=e.slice(2,-2).split(`:`),r=n[1];if(r===`command`){let r=n.slice(2);if(r.length===1&&r[0]===``)return{kind:`invalid`,reason:`Trailing colon in "${e}"; use {{politty:command}} for the root command.`};let i=At(r,t);if(i!==null)return{kind:`command`,scope:i,type:void 0};if(r.length>=2){let e=r[r.length-1],n=r.slice(0,-1),i=At(n,t);if(e!==void 0&&Ot(e))return{kind:`command`,scope:i??jt(n),type:e};if(e!==void 0&&i!==null)return{kind:`invalid`,reason:`Unknown section type "${e}" for command scope "${Z(i)}". Valid section types: ${M.join(`, `)}`}}return{kind:`command`,scope:jt(r),type:void 0}}return r===`global-options`?n.length===2?{kind:`global-options`}:{kind:`invalid`,reason:`Malformed placeholder "${e}". Expected {{politty:global-options}}.`}:r===`index`?n.length===2?{kind:`index`}:{kind:`invalid`,reason:`Malformed placeholder "${e}". Expected {{politty:index}}.`}:{kind:`invalid`,reason:`Unknown politty directive "${r??``}" in "${e}". Valid directives: command, global-options, index`}}function Nt(e,t){let n=rt(e);for(let r of e){let e=Mt(`{{politty:${r}}}`,t);if(e.kind===`command`){if(e.type===void 0)n.commandScopes.add(e.scope);else{let t=n.commandSections.get(e.scope);t||(t=/* @__PURE__ */ new Set,n.commandSections.set(e.scope,t)),t.add(e.type)}}else e.kind===`global-options`?n.globalOptions=!0:e.kind===`index`&&(n.index=!0)}return n}function Pt(e,t){for(let n of t)if(J(e,n))return!0;return!1}function Ft(e,t,n){return Pt(e,n.commandScopes)?!0:n.commandSections.get(e)?.has(t)??!1}function It(e,t,n,r){return mt(ut(lt([e],t),n).filter(e=>!Pt(e,r.commandScopes)),[e])}function Lt(e,t,n){return n.rawKeys.has(Qe(e))?!0:t.kind===`command`?Pt(t.scope,n.commandScopes)?!0:t.type!==void 0&&(n.commandSections.get(t.scope)?.has(t.type)??!1):t.kind===`global-options`?n.globalOptions:t.kind===`index`&&n.index}function Rt(e,t){if(!e.startsWith(`command:`))return!1;let n=e.slice(8).split(`:`);for(let e of t.commandScopes){if(e===``)return!0;let t=e.split(` `);if(n.slice(0,t.length).join(` `)===e)return!0;let r=e.split(`:`);if(n.slice(0,r.length).join(`:`)===e)return!0}return!1}const zt=/\{\{politty:[^{}]*\}\}/g;function Bt(e,t){let n=/* @__PURE__ */ new Set;for(let r of e.matchAll(zt)){let i=r.index,a=i+r[0].length;if(e[i-1]===`{`||e[a]===`}`){let n=e.slice(Math.max(0,i-1),Math.min(e.length,a+1)).split(`
69
69
  `)[0];throw Error(`Malformed politty placeholder in template "${t}": "${n}". Expected {{politty:...}}.`)}n.add(i)}let r=0;for(;;){let i=e.indexOf(`{{politty:`,r);if(i===-1)return;if(!n.has(i)){let n=e.slice(i,i+80).split(`
70
- `)[0];throw Error(`Malformed politty placeholder in template "${t}": "${n}". Expected {{politty:...}}.`)}r=i+10}}function Vt(e,t){let n=e.lastIndexOf(`:`);if(n===-1)return null;let r=e.slice(0,n),i=e.slice(n+1);return i===``||!t.has(r)?null:`Unknown section type "${i}" for command scope "${Z(r)}". Valid section types: ${M.join(`, `)}`}function Ht(e,t,n){let r=e.indexOf(t);if(r===-1)return null;let i=e.indexOf(n,r);return i===-1?null:e.slice(r,i+n.length)}function Ut(e,t,n,r){let i=e.indexOf(t);if(i===-1)return null;let a=e.indexOf(n,i);return a===-1?null:e.slice(0,i)+r+e.slice(a+n.length)}function Wt(e){if(typeof e!=`object`||!e)return!1;let t=e[`~standard`];if(typeof t!=`object`||!t)return!1;let{vendor:n,validate:r}=t;return typeof n==`string`&&typeof r==`function`}function Gt(e){return typeof e!=`object`||!e||!(`args`in e)?!1:!Wt(e.args)}function Kt(t){let n=e();return Object.entries(t).map(([e,t])=>n.resolveFieldMeta(e,t)).filter(e=>!e.positional)}function qt(e,t){let{schema:n,...r}=e,{schema:i,...a}=t;return f(r,a)}function Jt(e){if(e)return Gt(e)?e:{args:e}}function Yt(e){if(!e)return;let t=n(e).fields.filter(e=>!e.positional);if(t.length!==0)return Object.fromEntries(t.map(e=>[e.name,e.schema]))}function Xt(e){let t=/* @__PURE__ */ new Map;if(!e?.globalOptions)return t;let n=Jt(e.globalOptions);if(!n)return t;for(let e of Kt(n.args))t.set(e.name,e);return t}function Zt(e,t,n,r){let i=[];for(let[a,o]of Object.entries(e)){let{commandPaths:e,topLevelCommands:s}=X(o,n,r);if(e.length===0)continue;let c=`./`+u.relative(u.dirname(t),a).replace(/\\/g,`/`),l=e[0],d=l===void 0?void 0:n.get(l),f=Array.isArray(o)?void 0:o;i.push({title:f?.title??d?.name??u.basename(a,u.extname(a)),description:f?.description??d?.description??``,commands:s,allowedCommands:e,docPath:c})}return i}function Qt(e,t,n,r){let i=$(t),a=[];for(let[t,o]of e.entries()){if($(t)===i)continue;let e=o.headingScopes;if(e.length===0)continue;let s=`./`+u.relative(u.dirname(n),t).replace(/\\/g,`/`),c=e[0],l=c===void 0?void 0:r.get(c);a.push({title:o.indexTitle??l?.name??u.basename(t,u.extname(t)),description:o.indexDescription??l?.description??``,commands:e,docPath:s,noExpand:!0})}return a}function $t(e,t,n){let r=/* @__PURE__ */ new Set;for(let i of Object.values(e)){let{commandPaths:e}=X(i,t,n);for(let t of e)r.add(t)}return r}function en(e,t,n,r){let i=/* @__PURE__ */ new Set;for(let a of Object.keys(t)){let o=pn(e,a,t,n,r);for(let e of o)i.add(e)}return i}function tn(e,t){return t.some(t=>J(e,t))}function nn(e,t){return e.referencedScopes.some(e=>tn(e,t))}function rn(e,t){return e.emitsIndex||e.emitsGlobalOptions||nn(e,t)}function an(e,t,n){if(n.size===0)return;let r=[];for(let i of e){let e=t.get(i);if(e)for(let t of e.options){let e=n.get(t.name);e&&(qt(e,t)||r.push(`Command "${Z(i)}" option "--${t.cliName}" does not match globalOptions definition for "${t.name}".`))}}if(r.length>0)throw Error(`Invalid globalOptions configuration:\n - ${r.join(`
70
+ `)[0];throw Error(`Malformed politty placeholder in template "${t}": "${n}". Expected {{politty:...}}.`)}r=i+10}}function Vt(e,t){let n=e.lastIndexOf(`:`);if(n===-1)return null;let r=e.slice(0,n),i=e.slice(n+1);return i===``||!t.has(r)?null:`Unknown section type "${i}" for command scope "${Z(r)}". Valid section types: ${M.join(`, `)}`}function Ht(e,t,n){let r=e.indexOf(t);if(r===-1)return null;let i=e.indexOf(n,r);return i===-1?null:e.slice(r,i+n.length)}function Ut(e,t,n,r){let i=e.indexOf(t);if(i===-1)return null;let a=e.indexOf(n,i);return a===-1?null:e.slice(0,i)+r+e.slice(a+n.length)}function Wt(e){if(typeof e!=`object`||!e)return!1;let t=e[`~standard`];if(typeof t!=`object`||!t)return!1;let{vendor:n,validate:r}=t;return typeof n==`string`&&typeof r==`function`}function Gt(e){return typeof e!=`object`||!e||!(`args`in e)?!1:!Wt(e.args)}function Kt(t){let n=e();return Object.entries(t).map(([e,t])=>n.resolveFieldMeta(e,t)).filter(e=>!e.positional)}function qt(e,t){let{schema:n,...r}=e,{schema:i,...a}=t;return f(r,a)}function Jt(e){if(e)return Gt(e)?e:{args:e}}function Yt(e){if(!e)return;let t=n(e).fields.filter(e=>!e.positional);if(t.length!==0)return Object.fromEntries(t.map(e=>[e.name,e.schema]))}function Xt(e){let t=/* @__PURE__ */ new Map;if(!e?.globalOptions)return t;let n=Jt(e.globalOptions);if(!n)return t;for(let e of Kt(n.args))t.set(e.name,e);return t}function Zt(e,t,n,r){let i=[];for(let[a,o]of Object.entries(e)){let{commandPaths:e,topLevelCommands:s}=X(o,n,r);if(e.length===0)continue;let c=`./`+d.relative(d.dirname(t),a).replace(/\\/g,`/`),l=e[0],u=l===void 0?void 0:n.get(l),f=Array.isArray(o)?void 0:o;i.push({title:f?.title??u?.name??d.basename(a,d.extname(a)),description:f?.description??u?.description??``,commands:s,allowedCommands:e,docPath:c})}return i}function Qt(e,t,n,r){let i=$(t),a=[];for(let[t,o]of e.entries()){if($(t)===i)continue;let e=o.headingScopes;if(e.length===0)continue;let s=`./`+d.relative(d.dirname(n),t).replace(/\\/g,`/`),c=e[0],l=c===void 0?void 0:r.get(c);a.push({title:o.indexTitle??l?.name??d.basename(t,d.extname(t)),description:o.indexDescription??l?.description??``,commands:e,docPath:s,noExpand:!0})}return a}function $t(e,t,n){let r=/* @__PURE__ */ new Set;for(let i of Object.values(e)){let{commandPaths:e}=X(i,t,n);for(let t of e)r.add(t)}return r}function en(e,t,n,r){let i=/* @__PURE__ */ new Set;for(let a of Object.keys(t)){let o=pn(e,a,t,n,r);for(let e of o)i.add(e)}return i}function tn(e,t){return t.some(t=>J(e,t))}function nn(e,t){return e.referencedScopes.some(e=>tn(e,t))}function rn(e,t){return e.emitsIndex||e.emitsGlobalOptions||nn(e,t)}function an(e,t,n){if(n.size===0)return;let r=[];for(let i of e){let e=t.get(i);if(e)for(let t of e.options){let e=n.get(t.name);e&&(qt(e,t)||r.push(`Command "${Z(i)}" option "--${t.cliName}" does not match globalOptions definition for "${t.name}".`))}}if(r.length>0)throw Error(`Invalid globalOptions configuration:\n - ${r.join(`
71
71
  - `)}`)}function on(e){return[`<a id="global-options"></a>`,ze(e.args,e.options)].join(`
72
72
  `)}function sn(e){return[L(),on(e),ee()].join(`
73
73
  `)}async function cn(e,t,n,r){let i=V(n),a=ae(n);return[i,await Ke(t,e,r),a].join(`
74
- `)}function $(e){return u.resolve(e)}async function ln(e,t,n,r,i){let a=e,o=[],s=!1,c=!1,l=L(),u=ee(),d=await q(sn(t),r),f=Ht(a,l,u);if(!f)return n&&i?(a=a.trimEnd()+`
74
+ `)}function $(e){return d.resolve(e)}async function ln(e,t,n,r,i){let a=e,o=[],s=!1,c=!1,l=L(),u=ee(),d=await q(sn(t),r),f=Ht(a,l,u);if(!f)return n&&i?(a=a.trimEnd()+`
75
75
 
76
76
  `+d+`
77
77
  `,c=!0,{content:a,diffs:o,hasError:s,wasUpdated:c}):(s=!0,o.push(`Global options marker not found in file. Expected markers:\n${l}\n...\n${u}`),{content:a,diffs:o,hasError:s,wasUpdated:c});if(f!==d){if(n){let e=Ut(a,l,u,d);e?(a=e,c=!0):(s=!0,o.push(`Failed to replace global options section`))}else s=!0,o.push(G(f,d))}return{content:a,diffs:o,hasError:s,wasUpdated:c}}async function un(e,t,n,r,i,a,o,s){let c=e,l=[],u=!1,d=!1,f=[n,await q(i,o),r].join(`
@@ -80,14 +80,14 @@ import{t as e}from"./registry-BEz5iex_.js";import{c as t,n,o as r,r as i,s as a,
80
80
  `+f+`
81
81
  `,d=!0,{content:c,diffs:l,hasError:u,wasUpdated:d}):(u=!0,l.push(`${t} marker not found in file. Expected markers:\n${n}\n...\n${r}`),{content:c,diffs:l,hasError:u,wasUpdated:d});if(p!==f){if(a){let e=Ut(c,n,r,f);e?(c=e,d=!0):(u=!0,l.push(`Failed to replace ${t} section`))}else u=!0,l.push(G(p,f))}return{content:c,diffs:l,hasError:u,wasUpdated:d}}async function dn(e,t,n,r,i,a,o){let s=e,c=[],l=!1,u=!1,d=V(r),f=ae(r),p=s.includes(d),m=s.includes(f);if(!p&&!m)return{content:s,diffs:c,hasError:l,wasUpdated:u};if(!p||!m)return l=!0,c.push(`Index marker section is malformed: both start and end markers are required.`),{content:s,diffs:c,hasError:l,wasUpdated:u};let h=Ht(s,d,f);if(!h)return l=!0,c.push(`Index marker section is malformed: start marker must appear before end marker.`),{content:s,diffs:c,hasError:l,wasUpdated:u};let g=await q(await cn(t,n,r,o),a);if(h!==g){if(i){let e=Ut(s,d,f,g);e?(s=e,u=!0):(l=!0,c.push(`Failed to replace index section`))}else l=!0,c.push(G(h,g))}return{content:s,diffs:c,hasError:l,wasUpdated:u}}function fn(e,t,n,r){for(let[i,a]of Object.entries(t)){let{commandPaths:t}=X(a,n,r);if(t.includes(e))return i}return null}function pn(e,t,n,r,i){let a=n[t];if(!a)return[];let{specifiedCommands:o,commandPaths:s}=X(a,r,i),c=/* @__PURE__ */ new Set;for(let t of e)if(s.includes(t)){c.add(t);for(let e of s)J(e,t)&&!o.includes(e)&&c.add(e)}return Array.from(c)}function mn(e,t,n,r,i,a,o,s=[],c,l){let u=t.get(e);if(!u||l&&Pt(u.commandPath,l.commandScopes))return null;let d={...u,filePath:r,fileMap:i,rootDocPath:a};(s.length>0||l&&l.commandScopes.size>0)&&(d.subCommands=u.subCommands.filter(e=>{let t=e.fullPath.join(` `);return!s.some(e=>ct(t,e))&&!(l&&Pt(t,l.commandScopes))})),o!==void 0&&(d.hasGlobalOptions=o),c&&c.size>0&&(d.options=u.options.filter(e=>!c.has(e.name)),u.extracted&&(d.extracted=gn(u.extracted,c)));let f=n(d);if(l){for(let[e,t]of l.commandSections)if(e===u.commandPath){for(let n of t){let t=Q(f,n,e);t!==null&&(f=f.replace(t,``))}f=Tt(f)}}return f}function hn(e,t,n,r,i,a,o,s,c,l){let u=It(e,t,r,l),d=[];for(let e of u){let u=mn(e,t,n,i,a,o,s,r,c,l);u!==null&&d.push(u)}return d.length===0?null:d.join(`
82
82
  `)}function gn(e,t){let n={...e,fields:e.fields.filter(e=>!t.has(e.name))};return e.unionOptions&&(n.unionOptions=e.unionOptions.map(e=>gn(e,t))),e.variants&&(n.variants=e.variants.map(e=>({...e,fields:e.fields.filter(e=>!t.has(e.name))}))),n}function _n(e,t,n,r,i,a,o,s,c,l=[]){let u=[],d=o?ht(o):null;d&&u.push(d);let f=mt(e,a??[]);for(let e of f){let a=mn(e,t,n,r,i,s,c,l);a&&u.push(a)}return`${u.join(`
83
- `)}\n`}function vn(e,t,n){let r={};for(let[i,a]of Object.entries(e)){let{commandPaths:e}=X(a,t,n);for(let t of e)it(r,t,i)}return r}async function yn(e,t,n){for(let[r,i]of Object.entries(t)){let t=e.get(r);if(!t?.examples?.length)continue;let a=i===!0?{}:i,o=r?r.split(` `):[];t.exampleResults=await Fe(t.examples,a,n,o)}}function bn(e,t){if(typeof e==`string`)return{files:{[e]:Array.from(t.keys())},rootDocPath:e};let{root:n,commands:r={}}=e,i={},a=/* @__PURE__ */ new Set,o=Object.entries(r).sort(([e],[t])=>t.split(` `).length-e.split(` `).length);for(let[e,n]of o){i[n]||(i[n]={commands:[],noExpand:!0});let r=i[n];for(let n of t.keys())(n===e||n.startsWith(e+` `))&&!a.has(n)&&(r.commands.push(n),a.add(n))}return i[n]={commands:Array.from(t.keys()).filter(e=>!a.has(e)),noExpand:!0},{files:i,rootDocPath:n}}async function xn(e){let{command:t,ignores:r=[],format:i={},formatter:a,examples:o,targetCommands:s,globalArgs:c,customizable:l=!1}=e,d=await Pe(t),f,p=!1,m;if(e.path!==void 0){if(e.files!==void 0)throw Error(`Cannot specify both "path" and "files". Use one or the other.`);let t=bn(e.path,d);f=t.files,m=t.rootDocPath,p=!0}else if(e.files!==void 0)f=e.files;else if(e.templates!==void 0)f={};else throw Error(`Either "path", "files", or "templates" must be specified.`);let h=e.rootDoc;if(!h&&p&&(c||e.rootInfo)&&(h={path:m}),c&&h&&!h.globalOptions){let e=n(c).fields.filter(e=>!e.positional);if(e.length>0){let t=Object.fromEntries(e.map(e=>[e.name,e.schema]));h={...h,globalOptions:t}}}let g=qe(A),_=qe(j),v=!1;if(h&&!p){let e=$(h.path);if(Object.keys(f).some(t=>$(t)===e))throw Error(`rootDoc.path "${h.path}" must not also appear as a key in files.`)}o&&await yn(d,o,t);let y=s!==void 0&&s.length>0,b=Xt(h),x=/* @__PURE__ */ new Map;if(e.templates){if(b.size>0)for(let[e,t]of b)x.set(e,t);else{let e=Yt(c);if(e)for(let t of Kt(e))x.set(t.name,t)}}let S=y?en(s,f,d,r):$t(f,d,r),C=[];for(let e of Object.values(f)){let t=at(e);C.push(...t.commands)}pt(r,d),ft(C,r,d);let w=vn(f,d,r),T=/* @__PURE__ */ new Map,E=/* @__PURE__ */ new Map;if(e.templates)for(let[t,n]of Object.entries(e.templates)){let e=Ae(n);T.set(t,e),e!==null&&E.set(t,Nt(tt(e),d))}let D=Object.entries(e.templates??{}),O=/* @__PURE__ */ new Map,k=/* @__PURE__ */ new Map;if(D.length>0){let e=h?$(h.path):null,t=new Set(Object.keys(f).map($)),n=/* @__PURE__ */ new Set,i=new Set(D.map(([e])=>$(e)));for(let[r,a]of D){let o=$(r),s=$(a);if(t.has(o))throw Error(`Template output path "${r}" conflicts with an existing files key.`);if(e&&o===e)throw Error(`Template output path "${r}" conflicts with rootDoc.path "${h.path}".`);if(n.has(o))throw Error(`Duplicate template output path: "${r}".`);if(n.add(o),s===o)throw Error(`Template output path "${r}" must not be the same as its source template path.`);if(t.has(s))throw Error(`Template source path "${a}" conflicts with a files output key.`);if(e&&s===e)throw Error(`Template source path "${a}" conflicts with rootDoc.path "${h.path}".`);if(i.has(s))throw Error(`Template source path "${a}" conflicts with a template output path.`)}let a=Array.from(d.keys()).join(`, `);for(let[e,t]of D){let n=T.get(e)??null,i=[];if(n===null){O.set(e,{referencedScopes:[],headingScopes:[],commandTreeRoots:[],emitsGlobalOptions:!1,emitsIndex:!1}),k.set(e,i);continue}try{Bt(n,t)}catch(e){i.push(e instanceof Error?e.message:String(e))}let o=Array.from(new Set(n.match(zt)??[])),s=/* @__PURE__ */ new Set,l=/* @__PURE__ */ new Set,u=/* @__PURE__ */ new Set,f=!1,p=!1,m=E.get(e)??rt(/* @__PURE__ */ new Set),g=nt(n);for(let e of o){let n=Qe(e);if(m.rawKeys.has(n)||Rt(n,m))continue;let o=Mt(e,d);if(!Lt(e,o,m)){if(o.kind===`invalid`){i.push(`${o.reason} (in template "${t}")`);continue}if(o.kind===`command`){let{scope:e,type:n}=o;if(!d.has(e)){let n=Vt(e,d);if(n){i.push(`${n} (in template "${t}")`);continue}i.push(`Unknown command scope "${e}" in template "${t}". Available: ${a}`);continue}if(r.some(t=>ct(e,t))){i.push(`Command scope "${e}" in template "${t}" conflicts with ignores configuration.`);continue}if(n===void 0){let t=It(e,d,r,m);Ft(e,`heading`,m)||u.add(e);for(let e of t)s.add(e),Ft(e,`heading`,m)||l.add(e)}else s.add(e),n===`heading`&&!Ft(e,`heading`,m)&&(l.add(e),u.add(e))}else o.kind===`global-options`?f=!0:o.kind===`index`&&(p=!0)}}f&&(h?.globalOptions||Yt(c)!==void 0||i.push(`Template "${t}" uses {{politty:global-options}} but no global options are configured (neither rootDoc.globalOptions nor globalArgs with non-positional options).`)),O.set(e,{referencedScopes:Array.from(s),headingScopes:Array.from(l),commandTreeRoots:Array.from(u),emitsGlobalOptions:f,emitsIndex:p,...g.title===void 0?{}:{indexTitle:g.title},...g.description===void 0?{}:{indexDescription:g.description}}),k.set(e,i)}for(let e of O.values())if(!y||rn(e,s))for(let t of e.referencedScopes)S.add(t)}if(y)for(let e of s){let t=fn(e,f,d,r),n=Array.from(O.values()).some(t=>nn(t,[e]));if(!t&&!n)throw Error(`Target command "${e}" not found in any file or template configuration`)}let M=y&&e.templates?new Map(Array.from(O.entries()).filter(([,e])=>rn(e,s))):O;for(let[e,t]of k.entries())if(t.length>0&&M.has(e))throw Error(t.join(`
84
- `));let N=Array.from(O.entries()).filter(([,e])=>e.emitsGlobalOptions).map(([e])=>e),I=N.length===1?N[0]:void 0;if(an(S,d,b),b.size===0&&x.size>0){let e=/* @__PURE__ */ new Set;for(let t of M.values())if(t.emitsGlobalOptions||I!==void 0)for(let n of t.referencedScopes)e.add(n);an(e,d,x)}if(b.size>0)for(let e of d.values())e.options=e.options.filter(e=>!b.has(e.name)),e.extracted&&=gn(e.extracted,new Set(b.keys()));let L={};for(let[e,t]of Object.entries(w))it(L,e,t);let ee=e=>e===``?0:e.split(` `).length,R=/* @__PURE__ */ new Map;for(let[e,t]of O.entries())for(let n of t.headingScopes){if(Object.prototype.hasOwnProperty.call(w,n))continue;let r=-1;for(let e of t.commandTreeRoots)J(n,e)&&(r=Math.max(r,ee(e)));if(r<0)continue;let i=R.get(n);(!i||r>i.rootLen)&&R.set(n,{outputPath:e,rootLen:r})}for(let[e,{outputPath:t}]of R)it(L,e,t);let z=[],B=!1;for(let[e,t]of Object.entries(f)){let{fileConfig:n,specifiedCommands:o,commandPaths:c}=X(t,d,r);if(o.length===0||c.length===0)continue;let u=y?pn(s,e,f,d,r):[];if(y&&u.length===0)continue;let m=`match`,x=[],S=Math.min(...c.map(e=>d.get(e)?.depth??1)),C=Math.max(1,(i?.headingLevel??1)-(S-1)),w=p&&h&&$(e)===$(h.path),T=p||l,E=W({...i,headingLevel:C,markerless:!T}),D=n.render??E;if(w||y&&T){let t=Ae(e),i=mt(c,o),s=y?u:c;for(let o of s){let s=mn(o,d,D,e,L,h?.path,b.size>0,r);if(!s)throw Error(`Target command "${o}" not found in commands`);let c=await q(s,a);if(!t){if(g){let r=o===``&&n?ht(n):null,i=r?`${r}\n${c}`:c;K(e,i),t=i,m=`created`}else B=!0,m=`diff`,x.push(`File does not exist. Target command "${o}" section cannot be validated.`);continue}let u=bt(t,o);if(u.length===0){g?(t=St(t,o,c,i),K(e,t),m!==`created`&&(m=`updated`)):(B=!0,m=`diff`,x.push(`Existing file does not contain section markers for command "${o}"`));continue}for(let n of u){let r=Q(t,n,o),i=Q(c,n,o);if(r){if(!i){let i=P(n,o)+`
83
+ `)}\n`}function vn(e,t,n){let r={};for(let[i,a]of Object.entries(e)){let{commandPaths:e}=X(a,t,n);for(let t of e)it(r,t,i)}return r}async function yn(e,t,n){for(let[r,i]of Object.entries(t)){let t=e.get(r);if(!t?.examples?.length)continue;let a=i===!0?{}:i,o=r?r.split(` `):[];t.exampleResults=await Fe(t.examples,a,n,o)}}function bn(e,t){if(typeof e==`string`)return{files:{[e]:Array.from(t.keys())},rootDocPath:e};let{root:n,commands:r={}}=e,i={},a=/* @__PURE__ */ new Set,o=Object.entries(r).sort(([e],[t])=>t.split(` `).length-e.split(` `).length);for(let[e,n]of o){i[n]||(i[n]={commands:[],noExpand:!0});let r=i[n];for(let n of t.keys())(n===e||n.startsWith(e+` `))&&!a.has(n)&&(r.commands.push(n),a.add(n))}return i[n]={commands:Array.from(t.keys()).filter(e=>!a.has(e)),noExpand:!0},{files:i,rootDocPath:n}}async function xn(e){let{command:t,ignores:r=[],format:i={},formatter:a,examples:o,targetCommands:s,globalArgs:c,customizable:l=!1}=e,u=await Pe(t),f,p=!1,m;if(e.path!==void 0){if(e.files!==void 0)throw Error(`Cannot specify both "path" and "files". Use one or the other.`);let t=bn(e.path,u);f=t.files,m=t.rootDocPath,p=!0}else if(e.files!==void 0)f=e.files;else if(e.templates!==void 0)f={};else throw Error(`Either "path", "files", or "templates" must be specified.`);let h=e.rootDoc;if(!h&&p&&(c||e.rootInfo)&&(h={path:m}),c&&h&&!h.globalOptions){let e=n(c).fields.filter(e=>!e.positional);if(e.length>0){let t=Object.fromEntries(e.map(e=>[e.name,e.schema]));h={...h,globalOptions:t}}}let g=qe(A),_=qe(j),v=!1;if(h&&!p){let e=$(h.path);if(Object.keys(f).some(t=>$(t)===e))throw Error(`rootDoc.path "${h.path}" must not also appear as a key in files.`)}o&&await yn(u,o,t);let y=s!==void 0&&s.length>0,b=Xt(h),x=/* @__PURE__ */ new Map;if(e.templates){if(b.size>0)for(let[e,t]of b)x.set(e,t);else{let e=Yt(c);if(e)for(let t of Kt(e))x.set(t.name,t)}}let S=y?en(s,f,u,r):$t(f,u,r),C=[];for(let e of Object.values(f)){let t=at(e);C.push(...t.commands)}pt(r,u),ft(C,r,u);let w=vn(f,u,r),T=/* @__PURE__ */ new Map,E=/* @__PURE__ */ new Map;if(e.templates)for(let[t,n]of Object.entries(e.templates)){let e=Ae(n);T.set(t,e),e!==null&&E.set(t,Nt(tt(e),u))}let D=Object.entries(e.templates??{}),O=/* @__PURE__ */ new Map,k=/* @__PURE__ */ new Map;if(D.length>0){let e=h?$(h.path):null,t=new Set(Object.keys(f).map($)),n=/* @__PURE__ */ new Set,i=new Set(D.map(([e])=>$(e)));for(let[r,a]of D){let o=$(r),s=$(a);if(t.has(o))throw Error(`Template output path "${r}" conflicts with an existing files key.`);if(e&&o===e)throw Error(`Template output path "${r}" conflicts with rootDoc.path "${h.path}".`);if(n.has(o))throw Error(`Duplicate template output path: "${r}".`);if(n.add(o),s===o)throw Error(`Template output path "${r}" must not be the same as its source template path.`);if(t.has(s))throw Error(`Template source path "${a}" conflicts with a files output key.`);if(e&&s===e)throw Error(`Template source path "${a}" conflicts with rootDoc.path "${h.path}".`);if(i.has(s))throw Error(`Template source path "${a}" conflicts with a template output path.`)}let a=Array.from(u.keys()).join(`, `);for(let[e,t]of D){let n=T.get(e)??null,i=[];if(n===null){O.set(e,{referencedScopes:[],headingScopes:[],commandTreeRoots:[],emitsGlobalOptions:!1,emitsIndex:!1}),k.set(e,i);continue}try{Bt(n,t)}catch(e){i.push(e instanceof Error?e.message:String(e))}let o=Array.from(new Set(n.match(zt)??[])),s=/* @__PURE__ */ new Set,l=/* @__PURE__ */ new Set,d=/* @__PURE__ */ new Set,f=!1,p=!1,m=E.get(e)??rt(/* @__PURE__ */ new Set),g=nt(n);for(let e of o){let n=Qe(e);if(m.rawKeys.has(n)||Rt(n,m))continue;let o=Mt(e,u);if(!Lt(e,o,m)){if(o.kind===`invalid`)i.push(`${o.reason} (in template "${t}")`);else if(o.kind===`command`){let{scope:e,type:n}=o;if(!u.has(e)){let n=Vt(e,u);if(n){i.push(`${n} (in template "${t}")`);continue}i.push(`Unknown command scope "${e}" in template "${t}". Available: ${a}`);continue}if(r.some(t=>ct(e,t))){i.push(`Command scope "${e}" in template "${t}" conflicts with ignores configuration.`);continue}if(n===void 0){let t=It(e,u,r,m);Ft(e,`heading`,m)||d.add(e);for(let e of t)s.add(e),Ft(e,`heading`,m)||l.add(e)}else s.add(e),n===`heading`&&!Ft(e,`heading`,m)&&(l.add(e),d.add(e))}else o.kind===`global-options`?f=!0:o.kind===`index`&&(p=!0)}}f&&(h?.globalOptions||Yt(c)!==void 0||i.push(`Template "${t}" uses {{politty:global-options}} but no global options are configured (neither rootDoc.globalOptions nor globalArgs with non-positional options).`)),O.set(e,{referencedScopes:Array.from(s),headingScopes:Array.from(l),commandTreeRoots:Array.from(d),emitsGlobalOptions:f,emitsIndex:p,...g.title===void 0?{}:{indexTitle:g.title},...g.description===void 0?{}:{indexDescription:g.description}}),k.set(e,i)}for(let e of O.values())if(!y||rn(e,s))for(let t of e.referencedScopes)S.add(t)}if(y)for(let e of s){let t=fn(e,f,u,r),n=Array.from(O.values()).some(t=>nn(t,[e]));if(!t&&!n)throw Error(`Target command "${e}" not found in any file or template configuration`)}let M=y&&e.templates?new Map(Array.from(O.entries()).filter(([,e])=>rn(e,s))):O;for(let[e,t]of k.entries())if(t.length>0&&M.has(e))throw Error(t.join(`
84
+ `));let N=Array.from(O.entries()).filter(([,e])=>e.emitsGlobalOptions).map(([e])=>e),I=N.length===1?N[0]:void 0;if(an(S,u,b),b.size===0&&x.size>0){let e=/* @__PURE__ */ new Set;for(let t of M.values())if(t.emitsGlobalOptions||I!==void 0)for(let n of t.referencedScopes)e.add(n);an(e,u,x)}if(b.size>0)for(let e of u.values())e.options=e.options.filter(e=>!b.has(e.name)),e.extracted&&=gn(e.extracted,new Set(b.keys()));let L={};for(let[e,t]of Object.entries(w))it(L,e,t);let ee=e=>e===``?0:e.split(` `).length,R=/* @__PURE__ */ new Map;for(let[e,t]of O.entries())for(let n of t.headingScopes){if(Object.prototype.hasOwnProperty.call(w,n))continue;let r=-1;for(let e of t.commandTreeRoots)J(n,e)&&(r=Math.max(r,ee(e)));if(r<0)continue;let i=R.get(n);(!i||r>i.rootLen)&&R.set(n,{outputPath:e,rootLen:r})}for(let[e,{outputPath:t}]of R)it(L,e,t);let z=[],B=!1;for(let[e,t]of Object.entries(f)){let{fileConfig:n,specifiedCommands:o,commandPaths:c}=X(t,u,r);if(o.length===0||c.length===0)continue;let d=y?pn(s,e,f,u,r):[];if(y&&d.length===0)continue;let m=`match`,x=[],S=Math.min(...c.map(e=>u.get(e)?.depth??1)),C=Math.max(1,(i?.headingLevel??1)-(S-1)),w=p&&h&&$(e)===$(h.path),T=p||l,E=W({...i,headingLevel:C,markerless:!T}),D=n.render??E;if(w||y&&T){let t=Ae(e),i=mt(c,o),s=y?d:c;for(let o of s){let s=mn(o,u,D,e,L,h?.path,b.size>0,r);if(!s)throw Error(`Target command "${o}" not found in commands`);let c=await q(s,a);if(!t){if(g){let r=o===``&&n?ht(n):null,i=r?`${r}\n${c}`:c;K(e,i),t=i,m=`created`}else B=!0,m=`diff`,x.push(`File does not exist. Target command "${o}" section cannot be validated.`);continue}let d=bt(t,o);if(d.length===0)g?(t=St(t,o,c,i),K(e,t),m!==`created`&&(m=`updated`)):(B=!0,m=`diff`,x.push(`Existing file does not contain section markers for command "${o}"`));else{for(let n of d){let r=Q(t,n,o),i=Q(c,n,o);if(r){if(!i){let i=P(n,o)+`
85
85
  `+F(n,o);if(r!==i){if(g){let r=vt(t,n,o,i);if(!r)throw Error(`Failed to replace stale ${n} section for command "${o}"`);t=r.replace(/\n{3,}/g,`
86
86
 
87
- `),K(e,t),m!==`created`&&(m=`updated`)}else B=!0,m=`diff`,x.push(G(r,i))}continue}if(r!==i){if(g){let r=vt(t,n,o,i);if(r)t=r,K(e,t),m!==`created`&&(m=`updated`);else throw Error(`Failed to replace ${n} section for command "${o}"`)}else B=!0,m=`diff`,x.push(G(r,i))}}}if(_||l){let n=bt(c,o),r=new Set(u);for(let i of n){if(r.has(i))continue;let n=Q(c,i,o);n&&(_&&g?(t=yt(t,i,o,n),K(e,t),m!==`created`&&(m=`updated`)):_?(B=!0,v=!0,m=`diff`,x.push(`[doctor] Missing section marker "${i}" for command "${Z(o)}". Run with ${j}=true ${A}=true to insert.\n${n}`)):console.warn(`[politty] Missing "${i}" section for command "${Z(o)}" in ${e}. Run with ${j}=true ${A}=true to insert it, or leave it removed to opt that section out.`))}}}if(t){let n=xt(t),r=new Set(c);if(g){let i=!1;for(let e of n)r.has(e)||(t=Ct(t,e),i=!0);i&&(K(e,t),m!==`created`&&(m=`updated`))}else for(let e of n)r.has(e)||(B=!0,m=`diff`,x.push(`Found orphaned section markers for deleted command "${Z(e)}"`))}}else{let t=await q(_n(c,d,D,e,L,o,n,h?.path,b.size>0,r),a),i=ke(t,e);i.match||(g?(K(e,t),m=i.fileExists?`updated`:`created`):(B=!0,m=`diff`,i.diff&&x.push(i.diff)))}x.length>0&&(m=`diff`),z.push({path:e,status:m,diff:x.length>0?x.join(`
87
+ `),K(e,t),m!==`created`&&(m=`updated`)}else B=!0,m=`diff`,x.push(G(r,i))}}else if(r!==i){if(g){let r=vt(t,n,o,i);if(r)t=r,K(e,t),m!==`created`&&(m=`updated`);else throw Error(`Failed to replace ${n} section for command "${o}"`)}else B=!0,m=`diff`,x.push(G(r,i))}}}if(_||l){let n=bt(c,o),r=new Set(d);for(let i of n){if(r.has(i))continue;let n=Q(c,i,o);n&&(_&&g?(t=yt(t,i,o,n),K(e,t),m!==`created`&&(m=`updated`)):_?(B=!0,v=!0,m=`diff`,x.push(`[doctor] Missing section marker "${i}" for command "${Z(o)}". Run with ${j}=true ${A}=true to insert.\n${n}`)):console.warn(`[politty] Missing "${i}" section for command "${Z(o)}" in ${e}. Run with ${j}=true ${A}=true to insert it, or leave it removed to opt that section out.`))}}}}if(t){let n=xt(t),r=new Set(c);if(g){let i=!1;for(let e of n)r.has(e)||(t=Ct(t,e),i=!0);i&&(K(e,t),m!==`created`&&(m=`updated`))}else for(let e of n)r.has(e)||(B=!0,m=`diff`,x.push(`Found orphaned section markers for deleted command "${Z(e)}"`))}}else{let t=await q(_n(c,u,D,e,L,o,n,h?.path,b.size>0,r),a),i=ke(t,e);i.match||(g?(K(e,t),m=i.fileExists?`updated`:`created`):(B=!0,m=`diff`,i.diff&&x.push(i.diff)))}x.length>0&&(m=`diff`),z.push({path:e,status:m,diff:x.length>0?x.join(`
88
88
 
89
- `):void 0})}let V;if(h?.globalOptions)V=Jt(h.globalOptions);else{let e=Yt(c);e&&(V={args:e})}for(let[e,n]of D){if(!M.has(e))continue;let o=T.get(e)??null;if(o===null){B=!0,z.push({path:e,status:`diff`,diff:`Template file not found: ${n}`});continue}let s=O.get(e),c=Et(o),l=Ye(o),u=(s?.headingScopes??[]).map(e=>d.get(e)?.depth??1),p=u.length>0?Math.min(...u):1,m=kt((i?.headingLevel??1)-(p-1)),_=W({...i,headingLevel:m}),v=s?.emitsGlobalOptions??!1,y=(h!==void 0&&b.size>0||v||I!==void 0)&&x.size>0?new Set(x.keys()):void 0,S=y!==void 0,C=v?e:h?.path??I,w=Array.from(new Set(l.match(zt)??[])),D=/* @__PURE__ */ new Map,k=E.get(e)??rt(/* @__PURE__ */ new Set);for(let i of w){let a=Qe(i);if(k.rawKeys.has(a)||Rt(a,k)){D.set(i,``);continue}let o=Mt(i,d);if(Lt(i,o,k)){D.set(i,``);continue}if(o.kind===`invalid`)throw Error(`Internal error: unresolved placeholder "${i}" in template "${n}": ${o.reason}`);if(o.kind===`command`){let{scope:t,type:n}=o;if(n===void 0){let n=hn(t,d,_,r,e,L,C,S,y,k);if(n===null){D.set(i,``);continue}D.set(i,wt(n))}else{let a=mn(t,d,_,e,L,C,S,r,y,k);if(a===null){D.set(i,``);continue}let o=Q(a,n,t);D.set(i,o===null?``:wt(o))}}else if(o.kind===`global-options`)V?D.set(i,on(V)):D.set(i,``);else if(o.kind===`index`){let n=await Ke(t,[...Zt(f,e,d,r),...Qt(O,e,e,d)],h?.index);D.set(i,n)}}let A=l.replace(/((?:\r?\n)*)([ \t]*)(\{\{politty:[^{}]*\}\})([ \t]*)((?:\r?\n)*)/g,(e,t,r,i,a,o,s,c)=>{let l=D.get(i);if(l===void 0)throw Error(`Internal error: unresolved placeholder "${i}" in template "${n}".`);let u=t!==``||s===0||c[s-1]===`
90
- `,d=o!==``||s+e.length===c.length;if(l===``&&u&&d){if(t===``||o===``)return``;let e=Dt(t),n=Dt(o),r=Math.max(e,n),i=Et(e>=n?t:o);return r>=2?i+i:r===1?i:``}return`${t}${r}${l}${a}${o}`});A=`${A.trimEnd()}${c}`,A=await q(A,a);let j=ke(A,e),N=`match`,P;j.match||(g?(K(e,A),N=j.fileExists?`updated`:`created`):(B=!0,N=`diff`,j.diff&&(P=j.diff))),z.push({path:e,status:N,diff:P})}if(h){let n=h.path,i=`match`,o=[],s=Ae(n);if(s===null)B=!0,i=`diff`,o.push(`File does not exist. Cannot validate rootDoc markers.`);else{let c=s,l=!1,m=e.rootInfo,_={title:m?.title??t.name};h.headingLevel!==void 0&&(_.headingLevel=h.headingLevel);let v=m?.description??t.description;v!==void 0&&(_.description=v);let y=_t(c,_,g);if(c=y.content,y.diff&&o.push(y.diff),y.hasError&&(B=!0),y.wasUpdated&&(l=!0),m?.header){let e=await un(c,`Root header`,te(),ne(),m.header,g,a,p);c=e.content,o.push(...e.diffs),e.hasError&&(B=!0),e.wasUpdated&&(l=!0)}if(!p){let e=xt(c);if(e.length>0){if(g){for(let t of e)c=Ct(c,t);l=!0}else B=!0,o.push(`Found unexpected section markers in rootDoc: ${e.map(e=>`"${Z(e)}"`).join(`, `)}.`)}}let b=Jt(h.globalOptions);if(b){let e=await ln(c,b,g,a,p);c=e.content,o.push(...e.diffs),e.hasError&&(B=!0),e.wasUpdated&&(l=!0)}let x=Zt(f,n,d,r),S=u.relative(process.cwd(),n).replace(/\\/g,`/`),C=await dn(c,x,t,S,g,a,h.index);if(c=C.content,o.push(...C.diffs),C.hasError&&(B=!0),C.wasUpdated&&(l=!0),m?.footer){let e=await un(c,`Root footer`,re(),ie(),m.footer,g,a,p);c=e.content,o.push(...e.diffs),e.hasError&&(B=!0),e.wasUpdated&&(l=!0)}g&&l&&(K(n,c),i===`match`&&(i=`updated`))}o.length>0&&(i=`diff`),z.push({path:n,status:i,diff:o.length>0?o.join(`
89
+ `):void 0})}let V;if(h?.globalOptions)V=Jt(h.globalOptions);else{let e=Yt(c);e&&(V={args:e})}for(let[e,n]of D){if(!M.has(e))continue;let o=T.get(e)??null;if(o===null){B=!0,z.push({path:e,status:`diff`,diff:`Template file not found: ${n}`});continue}let s=O.get(e),c=Et(o),l=Ye(o),d=(s?.headingScopes??[]).map(e=>u.get(e)?.depth??1),p=d.length>0?Math.min(...d):1,m=kt((i?.headingLevel??1)-(p-1)),_=W({...i,headingLevel:m}),v=s?.emitsGlobalOptions??!1,y=(h!==void 0&&b.size>0||v||I!==void 0)&&x.size>0?new Set(x.keys()):void 0,S=y!==void 0,C=v?e:h?.path??I,w=Array.from(new Set(l.match(zt)??[])),D=/* @__PURE__ */ new Map,k=E.get(e)??rt(/* @__PURE__ */ new Set);for(let i of w){let a=Qe(i);if(k.rawKeys.has(a)||Rt(a,k)){D.set(i,``);continue}let o=Mt(i,u);if(Lt(i,o,k))D.set(i,``);else{if(o.kind===`invalid`)throw Error(`Internal error: unresolved placeholder "${i}" in template "${n}": ${o.reason}`);if(o.kind===`command`){let{scope:t,type:n}=o;if(n===void 0){let n=hn(t,u,_,r,e,L,C,S,y,k);if(n===null){D.set(i,``);continue}D.set(i,wt(n))}else{let a=mn(t,u,_,e,L,C,S,r,y,k);if(a===null){D.set(i,``);continue}let o=Q(a,n,t);D.set(i,o===null?``:wt(o))}}else if(o.kind===`global-options`)V?D.set(i,on(V)):D.set(i,``);else if(o.kind===`index`){let n=await Ke(t,[...Zt(f,e,u,r),...Qt(O,e,e,u)],h?.index);D.set(i,n)}}}let A=l.replace(/((?:\r?\n)*)([ \t]*)(\{\{politty:[^{}]*\}\})([ \t]*)((?:\r?\n)*)/g,(e,t,r,i,a,o,s,c)=>{let l=D.get(i);if(l===void 0)throw Error(`Internal error: unresolved placeholder "${i}" in template "${n}".`);let u=t!==``||s===0||c[s-1]===`
90
+ `,d=o!==``||s+e.length===c.length;if(l===``&&u&&d){if(t===``||o===``)return``;let e=Dt(t),n=Dt(o),r=Math.max(e,n),i=Et(e>=n?t:o);return r>=2?i+i:r===1?i:``}return`${t}${r}${l}${a}${o}`});A=`${A.trimEnd()}${c}`,A=await q(A,a);let j=ke(A,e),N=`match`,P;j.match||(g?(K(e,A),N=j.fileExists?`updated`:`created`):(B=!0,N=`diff`,j.diff&&(P=j.diff))),z.push({path:e,status:N,diff:P})}if(h){let n=h.path,i=`match`,o=[],s=Ae(n);if(s===null)B=!0,i=`diff`,o.push(`File does not exist. Cannot validate rootDoc markers.`);else{let c=s,l=!1,m=e.rootInfo,_={title:m?.title??t.name};h.headingLevel!==void 0&&(_.headingLevel=h.headingLevel);let v=m?.description??t.description;v!==void 0&&(_.description=v);let y=_t(c,_,g);if(c=y.content,y.diff&&o.push(y.diff),y.hasError&&(B=!0),y.wasUpdated&&(l=!0),m?.header){let e=await un(c,`Root header`,te(),ne(),m.header,g,a,p);c=e.content,o.push(...e.diffs),e.hasError&&(B=!0),e.wasUpdated&&(l=!0)}if(!p){let e=xt(c);if(e.length>0){if(g){for(let t of e)c=Ct(c,t);l=!0}else B=!0,o.push(`Found unexpected section markers in rootDoc: ${e.map(e=>`"${Z(e)}"`).join(`, `)}.`)}}let b=Jt(h.globalOptions);if(b){let e=await ln(c,b,g,a,p);c=e.content,o.push(...e.diffs),e.hasError&&(B=!0),e.wasUpdated&&(l=!0)}let x=Zt(f,n,u,r),S=d.relative(process.cwd(),n).replace(/\\/g,`/`),C=await dn(c,x,t,S,g,a,h.index);if(c=C.content,o.push(...C.diffs),C.hasError&&(B=!0),C.wasUpdated&&(l=!0),m?.footer){let e=await un(c,`Root footer`,re(),ie(),m.footer,g,a,p);c=e.content,o.push(...e.diffs),e.hasError&&(B=!0),e.wasUpdated&&(l=!0)}g&&l&&(K(n,c),i===`match`&&(i=`updated`))}o.length>0&&(i=`diff`),z.push({path:n,status:i,diff:o.length>0?o.join(`
91
91
 
92
92
  `):void 0})}return{success:!B,files:z,error:B?`Documentation is out of date. ${v?`Run with ${j}=true ${A}=true to fix missing markers.`:`Run with ${A}=true to update.`}`:void 0}}async function Sn(e){let t=await xn(e);if(!t.success){let e=t.files.filter(e=>e.status===`diff`).map(e=>{let t=`File: ${e.path}\n`;return e.diff&&(t+=e.diff),t}).join(`
93
93
 
@@ -0,0 +1 @@
1
+ export{t as createDynamicCompleteCommand}from"./dynamic-eZ7UI_q1.js";
@@ -1,5 +1,5 @@
1
- import{i as e,o as t}from"./registry-BEz5iex_.js";import{a as n,l as r,n as i}from"./schema-extractor-DFawzmtj.js";import{n as a}from"./command-BXsTrIgI.js";import{c as o,i as s}from"./subcommand-router-iqmWGZyU.js";import{i as c,s as l}from"./argv-parser-BRSUT6IV.js";import{t as u}from"./schema--6eHVfwR.js";import{execSync as d}from"node:child_process";function f(e,t,n){return{fieldName:e.name,isArrayOption:e.valueType===`array`,isGlobal:e.isGlobal===!0,resolvedDeps:m(e.valueCompletion,e.isGlobal===!0,t,n)}}function p(e,t,n){return{fieldName:e.name,isArrayOption:!1,isGlobal:!1,resolvedDeps:m(e.valueCompletion,!1,t,n)}}function m(e,t,n,r=[]){if(e?.type!==`expand`)return[];let i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Set;for(let e of n)e.isGlobal===!0?i.add(e.name):a.add(e.name);for(let e of r)a.add(e.name);return e.dependsOn.map(e=>({name:e,isGlobal:t||i.has(e)&&!a.has(e)}))}function h(e){let t=`$'`;for(let n of e){let e=n.codePointAt(0);t+=n===`\\`?`\\\\`:n===`'`?`\\'`:n===`
2
- `?`\\n`:n===`\r`?`\\r`:n===` `?`\\t`:e<32||e===127?`\\x${e.toString(16).padStart(2,`0`)}`:n}return t+=`'`,t}function g(e){return`'${e.replace(/'/g,`'\\''`)}'`}function _(e,t){let n=t.withSize?`%Y:%s`:`%Y`,r=t.withSize?`%m:%z`:`%m`,i=`stat -L -c '${n}' "${e}" 2>/dev/null`,a=`stat -L -f '${r}' "${e}" 2>/dev/null`;return t.shell===`fish`?`(${i}; or ${a})`:`$(${i} || ${a})`}function v(e){return e.length===1?`-${e}`:`--${e}`}function y(e,n){b(e,v(n)),n.length===1?b(e,`--${n}`):n.includes(`-`)&&b(e,`--${t(n)}`)}function b(e,t){e.includes(t)||e.push(t)}function x(e,n){let r=[`--${e}`];e.length===1&&r.push(`-${e}`),e.includes(`-`)&&r.push(`--${t(e)}`);for(let e of n??[])y(r,e);return r}function S(e){let t=/* @__PURE__ */ new Set;for(let n of e)if(n.isGlobal===!0){n.cliName.length===1&&t.add(`-${n.cliName}`);for(let e of n.alias??[])e.length===1&&t.add(`-${e}`)}return t}function C(e,n,r,i){let a=new Set(x(e,n));if(r&&(a.add(`--${r}`),r.includes(`-`)&&a.add(`--${t(r)}`)),i?.frameOptions){if(i.isGlobal===!0){for(let e of i.frameOptions)if(e.isGlobal!==!0)for(let t of D(e.cliName,e.alias))a.delete(t)}else{let e=S(i.frameOptions);if(e.size>0){let t=new Set((n??[]).filter(e=>e.length===1).map(e=>`-${e}`));for(let n of e)t.has(n)||a.delete(n)}}}return[...a].map(e=>`"${e}"`)}function w(e,t){return e.map(e=>{let n=t.find(t=>t.isGlobal!==!0&&t.name===e.name);return n&&C(n.cliName,n.alias,n.negation,{frameOptions:t})})}function T(e,t,n,r=`$_pos_count`){let i=w(e,t);if(i.every(e=>e===void 0))return;let a=[` local _slot=-1 _left=${r}`];return e.forEach((e,t)=>{let r=i[t],o=r?` && __${n}_not_used ${r.join(` `)}`:``,s=e.variadic?`_slot=${e.position}`:`if (( _left == 0 )); then _slot=${e.position}; else (( _left-- )); fi`;a.push(` if (( _slot < 0 ))${o}; then ${s}; fi`)}),a}function E(e,t){let n=[`__${e}_track_positionals() {`,` local _k=0 _w`,' for _w in "${_pos_words[@]}"; do',` local _slot=$_k`,` case "$_subcmd" in`];for(let r of t){n.push(` ${r.pathStrs.map(e=>`"${e}"`).join(`|`)})`);for(let t of T(r.positionals,r.options,e,`$_k`)??[])n.push(` ${t}`);n.push(` ;;`)}return n.push(` esac`,` __${e}_track_pos "$_subcmd" "$_slot" "$_w"`,` (( _k++ ))`,` done`,`}`,``),n}function D(e,n){let r=[`--${e}`];e.includes(`-`)&&r.push(`--${t(e)}`);for(let e of n??[])y(r,e);return r}function O(e){let t=e.completion;if(t?.custom){let n=t.custom,r=[];if(n.expand&&r.push(`expand`),n.resolve&&r.push(`resolve`),n.choices&&n.choices.length>0&&r.push(`choices`),n.shellCommand&&r.push(`shellCommand`),r.length>1)throw Error(`Field "${e.name??`<unknown>`}": completion.custom may only specify one of choices, shellCommand, resolve, expand (got ${r.join(`, `)}).`);if(n.expand)return{type:`pending-expand`,spec:n.expand};if(n.resolve)return{type:`dynamic`,resolve:n.resolve};if(n.choices&&n.choices.length>0)return{type:`choices`,choices:n.choices};if(n.shellCommand)return{type:`command`,shellCommand:n.shellCommand}}if(t?.type){if(t.type===`file`)return t.matcher?{type:`file`,matcher:t.matcher}:t.extensions?{type:`file`,extensions:t.extensions}:{type:`file`};if(t.type===`directory`)return{type:`directory`};if(t.type===`none`)return{type:`none`}}if(e.enumValues&&e.enumValues.length>0)return{type:`choices`,choices:e.enumValues}}function k(e){if(e)return e.type===`pending-expand`?{type:`runtime-expand`,dependsOn:e.spec.dependsOn,enumerate:e.spec.enumerate}:e}function ee(e){return e.args?A(e.args):[]}function A(e){return n(i(e)).map(j)}function j(t){let n=e(t);return{name:t.name,cliName:t.cliName,alias:n.length>0?n:void 0,negation:t.negationDisplay,negationDescription:t.negationDescription,description:t.description,takesValue:t.type!==`boolean`,valueType:t.type,required:t.required,defaultNegationAccepted:t.type===`boolean`&&t.negation===!0,valueCompletion:k(O(t))}}function M(e){return new Set(x(e.cliName,e.alias))}function te(e,t){let n=M(t);for(let t of e)for(let e of M(t))if(n.has(e))return t}function ne(e,t,n){let r=/* @__PURE__ */ new Set;if(t.length===0)return r;let i=/* @__PURE__ */ new Set,a=(e,t)=>{U(n,e,t,i),r.add(e.name)},o=0;for(;o<e.length;){let i=e[o];if(i===`--`||!i.startsWith(`-`))break;if(!i.startsWith(`--`)&&i.length>2){let e=i.indexOf(`=`);if((e>=0?i.slice(1,e):i.slice(1)).length>1)break}let s=L(i),c=G(t,s);if(!c){if(ce(t,s)){o++;continue}break}if(c.takesValue){if(R(i)){let e=i.indexOf(`=`);a(c,i.slice(e+1)),o++}else if(o+1<e.length){let t=e[o+1];if(t.startsWith(`-`)){o++;continue}a(c,t),o+=2}else break}else{let e=z(c,s,i);e!==void 0&&(n[c.name]=e),r.add(c.name),o++}}return r}function re(e,t){return t.valueType===`array`?Array.isArray(e)?e:[e]:Array.isArray(e)?e.at(-1):e}function N(e,t){return t.length===0?e:[...e,...t]}function P(e,t){let n=t.length-1;if(!(n<0))return e>n?n:e}function F(e,t){return n=>{let r={...e};return c(n,e).forEach((e,n)=>{n<t.length&&(r[e.name]=t[n])}),r}}function ie(e,t,n){if(!e.args)return;let a=i(e.args),o=r(a,F(t,n));if(o!==a)return o.fields.filter(e=>e.named).map(j)}function ae(e,t,n){if(!e.args)return[];let a=r(i(e.args),F(t,n));return c(a,t).map((e,t)=>({name:e.name,cliName:e.cliName,position:t,description:e.description,required:e.required,variadic:e.type===`array`,valueCompletion:k(O(e))}))}function oe(e){if(!e.subCommands)return[];let t=[];for(let[n,r]of Object.entries(e.subCommands)){if(n.startsWith(`__`))continue;t.push(n);let e=o(r);e?.aliases&&t.push(...e.aliases)}return t}function se(e,t){if(!e.subCommands)return null;let n=Object.hasOwn(e.subCommands,t)?e.subCommands[t]:void 0;if(n)return o(n);let r=s(e,t);return r?o(e.subCommands[r]):null}function I(e){return e.startsWith(`-`)}function L(e){if(e.startsWith(`--`)){let t=e.slice(2),n=t.indexOf(`=`);return{name:n>=0?t.slice(0,n):t,isLong:!0}}return e.startsWith(`-`)?{name:e.slice(1,2),isLong:!1}:{name:e,isLong:!0}}function R(e){return e.includes(`=`)}function z(e,t,n){let r=le(e,t);return R(n)?r?void 0:l(n.slice(n.indexOf(`=`)+1)):!r}function B(e,n,r){if(!r||e.valueType!==`boolean`)return!1;let i=[e.cliName,...e.alias??[]];for(let e of i){let r=`no-${e}`;if(n===r||n===t(r))return!0}return!1}function V(e,t,n){return e.defaultNegationAccepted===!0&&B(e,t,n)}function ce(e,t){return e.some(e=>e.defaultNegationAccepted!==!0&&B(e,t.name,t.isLong))}function H(e,n){return e!==void 0&&e.includes(`-`)&&t(e)===n}function U(e,t,n,r){if(t.valueType!==`array`){e[t.name]=n;return}if(r.has(t.name)){let r=e[t.name];e[t.name]=Array.isArray(r)?[...r,n]:[n]}else e[t.name]=[n],r.add(t.name)}function le(e,t){return t.isLong?e.negation!==void 0&&(e.negation===t.name||H(e.negation,t.name))?!0:V(e,t.name,t.isLong):!1}function W(e,t,n){if(e.cliName===t&&(n||e.cliName.length===1))return!0;if(e.alias){for(let r of e.alias)if(r===t&&(n||r.length===1))return!0}return n&&e.negation===t?!0:!n||t.length<=1?!1:H(e.cliName,t)||e.alias?.some(e=>H(e,t))?!0:H(e.negation,t)}function G(e,t){if(!t.isLong){let n=e.find(e=>e.isGlobal!==!0&&e.alias?.includes(t.name)===!0);if(n)return n;let r=e.find(e=>e.isGlobal===!0&&W(e,t.name,t.isLong));if(r)return r}return e.find(e=>W(e,t.name,t.isLong))||e.find(e=>V(e,t.name,t.isLong))}function K(e,t,n){let r=q(e,t,n);return r.variantOptions?q(e,t,n,{command:r.context.currentCommand,options:r.variantOptions}).context:r.context}function q(e,t,n,r){let i=e=>e===r?.command?r.options:ee(e),a=t,o=[],s=n?A(n).map(e=>({...e,isGlobal:!0})):[],c=/* @__PURE__ */ new Set,l=!1,u=0,d={},f=[],p={},m=/* @__PURE__ */ new Set,h=0,g=/* @__PURE__ */ new Set,_=e=>{c.add(e.cliName);for(let t of e.alias??[])c.add(t);e.negation&&c.add(e.negation),l=!0},v=(e,t)=>{U(e.isGlobal===!0?p:d,e,t,g)},y=(e,t,n=``)=>{let r=e.isGlobal===!0?p:d,i=z(e,t,n);i!==void 0&&(r[e.name]=i)},b=0,x=N(i(a),s),S=!1;for(;b<e.length-1;){let t=e[b];if(!S&&t===`--`){S=!0,b++;continue}if(!S&&t.startsWith(`-`)&&!t.startsWith(`--`)&&t.length>2&&!t.includes(`=`)){l=!0;let e=Array.from(t.slice(1)),n=x.filter(e=>e.isGlobal!==!0);for(let t of e){let e=G(n,{name:t,isLong:!1});e&&!e.takesValue&&(_(e),y(e,{name:t,isLong:!1}))}b++;continue}if(!S&&I(t)){l=!0;let n=L(t),r=G(x,n);if(r){if(_(r),r.takesValue){if(R(t)){let e=t.indexOf(`=`);v(r,t.slice(e+1))}else if(b+1<e.length-1){let t=e[b+1];I(t)||(v(r,t),b++)}}else y(r,n,t)}b++;continue}let n=S?null:se(a,t);if(n){o.push(t);let r=i(a),l=e.slice(h,b);for(let e of ne(l,s,p))m.add(e);a=n,x=N(i(a),s);for(let e of Object.keys(d)){let t=r.find(t=>t.name===e),n=s.find(t=>t.name===e)??(t?te(s,t):void 0);n&&(m.has(n.name)||(p[n.name]=re(d[e],n)))}c.clear(),u=0,d={},f=[],g=/* @__PURE__ */ new Set,h=b+1,b++;continue}f.push(t),u++,b++}let C=e[e.length-1]??``,w=e[e.length-2]??``,T=ie(a,d,f),E=ae(a,d,f),D=oe(a);for(let e=0;e<E.length;e++){let t=E[e];if(t.variadic){d[t.name]=f.slice(e);break}e<f.length&&(d[t.name]=f[e])}let O,k,j;if(!S&&w&&I(w)&&!R(w)){let e=G(x,L(w));e&&e.takesValue?(O=`option-value`,k=e):C.startsWith(`-`)?O=`option-name`:(O=J(C,D,E,u),O===`positional`&&(j=u))}else if(!S&&C.startsWith(`-`)&&R(C)){let e=G(x,L(C));e&&e.takesValue?(O=`option-value`,k=e):O=`option-name`}else!S&&C.startsWith(`-`)?O=`option-name`:(O=J(C,D,E,u,S),O===`positional`&&(j=u));let M=[];if(k){if(k.valueType===`array`){let e=(k.isGlobal===!0?p:d)[k.name];M=Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}}else if(O===`positional`&&j!==void 0){let e=P(j,E);e!==void 0&&E[e]?.variadic&&(M=f.slice(e))}let F={...p,...d};return{context:{subcommandPath:o,currentCommand:a,currentWord:C,previousWord:w,completionType:O,targetOption:k,positionalIndex:j,options:x,subcommands:D,positionals:E,usedOptions:c,hasAnyOptionBeenUsed:l,providedPositionalCount:u,parsedArgs:F,previousValues:M},variantOptions:T}}function J(e,t,n,r,i){return i?`positional`:t.length>0&&(t.filter(t=>t.startsWith(e)).length>0||e===``)?`subcommand`:r<n.length||n.length>0&&n[n.length-1].variadic?`positional`:`subcommand`}const Y={Default:0,NoSpace:1,NoFileCompletion:2,FilterPrefix:4,KeepOrder:8,FileCompletion:16,DirectoryCompletion:32,Error:64};function X(e){if(!e.startsWith(`-`))return;let t=e.indexOf(`=`);if(!(t<=0))return e.slice(0,t+1)}async function ue(e,t){switch(e.completionType){case`subcommand`:return ye(e);case`option-name`:return be(e);case`option-value`:{let n=e.targetOption,r=n?X(e.currentWord):void 0;return Ce(r?{...e,currentWord:e.currentWord.slice(r.length)}:e,t,n?.name,n?.valueCompletion,void 0,n?.valueType===`array`)}case`positional`:{let n=de(e);return n?Ce(e,t,n.name,n.valueCompletion,n.description,!1):{candidates:[],directive:Y.NoFileCompletion}}}}function de(e){let t=e.positionalIndex??0,n=P(t,e.positionals);if(n===void 0)return;let r=e.positionals[n];if(r)return n===t||r.variadic?r:void 0}function fe(e){try{return d(e,{encoding:`utf-8`,timeout:5e3}).split(`
1
+ import{i as e,o as t}from"./registry-BEz5iex_.js";import{a as n,l as r,n as i}from"./schema-extractor-BK1sJx7i.js";import{n as a}from"./command-BXsTrIgI.js";import{c as o,i as s}from"./subcommand-router-40vA6Mka.js";import{i as c,s as l}from"./argv-parser-Chf2pXSm.js";import{t as u}from"./schema-CuJVxa-M.js";import{execSync as d}from"node:child_process";function f(e,t,n){return{fieldName:e.name,isArrayOption:e.valueType===`array`,isGlobal:e.isGlobal===!0,resolvedDeps:m(e.valueCompletion,e.isGlobal===!0,t,n)}}function p(e,t,n){return{fieldName:e.name,isArrayOption:!1,isGlobal:!1,resolvedDeps:m(e.valueCompletion,!1,t,n)}}function m(e,t,n,r=[]){if(e?.type!==`expand`)return[];let i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Set;for(let e of n)e.isGlobal===!0?i.add(e.name):a.add(e.name);for(let e of r)a.add(e.name);return e.dependsOn.map(e=>({name:e,isGlobal:t||i.has(e)&&!a.has(e)}))}function h(e){let t=`$'`;for(let n of e){let e=n.codePointAt(0);t+=n===`\\`?`\\\\`:n===`'`?`\\'`:n===`
2
+ `?`\\n`:n===`\r`?`\\r`:n===` `?`\\t`:e<32||e===127?`\\x${e.toString(16).padStart(2,`0`)}`:n}return t+=`'`,t}function g(e){return`'${e.replace(/'/g,`'\\''`)}'`}function _(e,t){let n=t.withSize?`%Y:%s`:`%Y`,r=t.withSize?`%m:%z`:`%m`,i=`stat -L -c '${n}' "${e}" 2>/dev/null`,a=`stat -L -f '${r}' "${e}" 2>/dev/null`;return t.shell===`fish`?`(${i}; or ${a})`:`$(${i} || ${a})`}function v(e){return e.length===1?`-${e}`:`--${e}`}function y(e,n){b(e,v(n)),n.length===1?b(e,`--${n}`):n.includes(`-`)&&b(e,`--${t(n)}`)}function b(e,t){e.includes(t)||e.push(t)}function x(e,n){let r=[`--${e}`];e.length===1&&r.push(`-${e}`),e.includes(`-`)&&r.push(`--${t(e)}`);for(let e of n??[])y(r,e);return r}function S(e){let t=/* @__PURE__ */ new Set;for(let n of e)if(n.isGlobal===!0){n.cliName.length===1&&t.add(`-${n.cliName}`);for(let e of n.alias??[])e.length===1&&t.add(`-${e}`)}return t}function C(e,n,r,i){let a=new Set(x(e,n));if(r&&(a.add(`--${r}`),r.includes(`-`)&&a.add(`--${t(r)}`)),i?.frameOptions){if(i.isGlobal===!0){for(let e of i.frameOptions)if(e.isGlobal!==!0)for(let t of D(e.cliName,e.alias))a.delete(t)}else{let e=S(i.frameOptions);if(e.size>0){let t=new Set((n??[]).filter(e=>e.length===1).map(e=>`-${e}`));for(let n of e)t.has(n)||a.delete(n)}}}return[...a].map(e=>`"${e}"`)}function w(e,t){return e.map(e=>{let n=t.find(t=>t.isGlobal!==!0&&t.name===e.name);return n&&C(n.cliName,n.alias,n.negation,{frameOptions:t})})}function T(e,t,n,r=`$_pos_count`){let i=w(e,t);if(i.every(e=>e===void 0))return;let a=[` local _slot=-1 _left=${r}`];return e.forEach((e,t)=>{let r=i[t],o=r?` && __${n}_not_used ${r.join(` `)}`:``,s=e.variadic?`_slot=${e.position}`:`if (( _left == 0 )); then _slot=${e.position}; else (( _left-- )); fi`;a.push(` if (( _slot < 0 ))${o}; then ${s}; fi`)}),a}function E(e,t){let n=[`__${e}_track_positionals() {`,` local _k=0 _w`,' for _w in "${_pos_words[@]}"; do',` local _slot=$_k`,` case "$_subcmd" in`];for(let r of t){n.push(` ${r.pathStrs.map(e=>`"${e}"`).join(`|`)})`);for(let t of T(r.positionals,r.options,e,`$_k`)??[])n.push(` ${t}`);n.push(` ;;`)}return n.push(` esac`,` __${e}_track_pos "$_subcmd" "$_slot" "$_w"`,` (( _k++ ))`,` done`,`}`,``),n}function D(e,n){let r=[`--${e}`];e.includes(`-`)&&r.push(`--${t(e)}`);for(let e of n??[])y(r,e);return r}function O(e){let t=e.completion;if(t?.custom){let n=t.custom,r=[];if(n.expand&&r.push(`expand`),n.resolve&&r.push(`resolve`),n.choices&&n.choices.length>0&&r.push(`choices`),n.shellCommand&&r.push(`shellCommand`),r.length>1)throw Error(`Field "${e.name??`<unknown>`}": completion.custom may only specify one of choices, shellCommand, resolve, expand (got ${r.join(`, `)}).`);if(n.expand)return{type:`pending-expand`,spec:n.expand};if(n.resolve)return{type:`dynamic`,resolve:n.resolve};if(n.choices&&n.choices.length>0)return{type:`choices`,choices:n.choices};if(n.shellCommand)return{type:`command`,shellCommand:n.shellCommand}}if(t?.type){if(t.type===`file`)return t.matcher?{type:`file`,matcher:t.matcher}:t.extensions?{type:`file`,extensions:t.extensions}:{type:`file`};if(t.type===`directory`)return{type:`directory`};if(t.type===`none`)return{type:`none`}}if(e.enumValues&&e.enumValues.length>0)return{type:`choices`,choices:e.enumValues}}function k(e){if(e)return e.type===`pending-expand`?{type:`runtime-expand`,dependsOn:e.spec.dependsOn,enumerate:e.spec.enumerate}:e}function ee(e){return e.args?A(e.args):[]}function A(e){return n(i(e)).map(j)}function j(t){let n=e(t);return{name:t.name,cliName:t.cliName,alias:n.length>0?n:void 0,negation:t.negationDisplay,negationDescription:t.negationDescription,description:t.description,takesValue:t.type!==`boolean`,valueType:t.type,required:t.required,defaultNegationAccepted:t.type===`boolean`&&t.negation===!0,valueCompletion:k(O(t))}}function M(e){return new Set(x(e.cliName,e.alias))}function te(e,t){let n=M(t);for(let t of e)for(let e of M(t))if(n.has(e))return t}function ne(e,t,n){let r=/* @__PURE__ */ new Set;if(t.length===0)return r;let i=/* @__PURE__ */ new Set,a=(e,t)=>{U(n,e,t,i),r.add(e.name)},o=0;for(;o<e.length;){let i=e[o];if(i===`--`||!i.startsWith(`-`))break;if(!i.startsWith(`--`)&&i.length>2){let e=i.indexOf(`=`);if((e>=0?i.slice(1,e):i.slice(1)).length>1)break}let s=L(i),c=G(t,s);if(!c){if(ce(t,s)){o++;continue}break}if(c.takesValue){if(R(i)){let e=i.indexOf(`=`);a(c,i.slice(e+1)),o++}else if(o+1<e.length){let t=e[o+1];if(t.startsWith(`-`)){o++;continue}a(c,t),o+=2}else break}else{let e=z(c,s,i);e!==void 0&&(n[c.name]=e),r.add(c.name),o++}}return r}function re(e,t){return t.valueType===`array`?Array.isArray(e)?e:[e]:Array.isArray(e)?e.at(-1):e}function N(e,t){return t.length===0?e:[...e,...t]}function P(e,t){let n=t.length-1;if(!(n<0))return e>n?n:e}function F(e,t){return n=>{let r={...e};return c(n,e).forEach((e,n)=>{n<t.length&&(r[e.name]=t[n])}),r}}function ie(e,t,n){if(!e.args)return;let a=i(e.args),o=r(a,F(t,n));if(o!==a)return o.fields.filter(e=>e.named).map(j)}function ae(e,t,n){if(!e.args)return[];let a=r(i(e.args),F(t,n));return c(a,t).map((e,t)=>({name:e.name,cliName:e.cliName,position:t,description:e.description,required:e.required,variadic:e.type===`array`,valueCompletion:k(O(e))}))}function oe(e){if(!e.subCommands)return[];let t=[];for(let[n,r]of Object.entries(e.subCommands)){if(n.startsWith(`__`))continue;t.push(n);let e=o(r);e?.aliases&&t.push(...e.aliases)}return t}function se(e,t){if(!e.subCommands)return null;let n=Object.hasOwn(e.subCommands,t)?e.subCommands[t]:void 0;if(n)return o(n);let r=s(e,t);return r?o(e.subCommands[r]):null}function I(e){return e.startsWith(`-`)}function L(e){if(e.startsWith(`--`)){let t=e.slice(2),n=t.indexOf(`=`);return{name:n>=0?t.slice(0,n):t,isLong:!0}}return e.startsWith(`-`)?{name:e.slice(1,2),isLong:!1}:{name:e,isLong:!0}}function R(e){return e.includes(`=`)}function z(e,t,n){let r=le(e,t);return R(n)?r?void 0:l(n.slice(n.indexOf(`=`)+1)):!r}function B(e,n,r){if(!r||e.valueType!==`boolean`)return!1;let i=[e.cliName,...e.alias??[]];for(let e of i){let r=`no-${e}`;if(n===r||n===t(r))return!0}return!1}function V(e,t,n){return e.defaultNegationAccepted===!0&&B(e,t,n)}function ce(e,t){return e.some(e=>e.defaultNegationAccepted!==!0&&B(e,t.name,t.isLong))}function H(e,n){return e!==void 0&&e.includes(`-`)&&t(e)===n}function U(e,t,n,r){if(t.valueType!==`array`)e[t.name]=n;else if(r.has(t.name)){let r=e[t.name];e[t.name]=Array.isArray(r)?[...r,n]:[n]}else e[t.name]=[n],r.add(t.name)}function le(e,t){return t.isLong?e.negation!==void 0&&(e.negation===t.name||H(e.negation,t.name))?!0:V(e,t.name,t.isLong):!1}function W(e,t,n){if(e.cliName===t&&(n||e.cliName.length===1))return!0;if(e.alias){for(let r of e.alias)if(r===t&&(n||r.length===1))return!0}return n&&e.negation===t?!0:!n||t.length<=1?!1:H(e.cliName,t)||e.alias?.some(e=>H(e,t))?!0:H(e.negation,t)}function G(e,t){if(!t.isLong){let n=e.find(e=>e.isGlobal!==!0&&e.alias?.includes(t.name)===!0);if(n)return n;let r=e.find(e=>e.isGlobal===!0&&W(e,t.name,t.isLong));if(r)return r}return e.find(e=>W(e,t.name,t.isLong))||e.find(e=>V(e,t.name,t.isLong))}function K(e,t,n){let r=q(e,t,n);return r.variantOptions?q(e,t,n,{command:r.context.currentCommand,options:r.variantOptions}).context:r.context}function q(e,t,n,r){let i=e=>e===r?.command?r.options:ee(e),a=t,o=[],s=n?A(n).map(e=>({...e,isGlobal:!0})):[],c=/* @__PURE__ */ new Set,l=!1,u=0,d={},f=[],p={},m=/* @__PURE__ */ new Set,h=0,g=/* @__PURE__ */ new Set,_=e=>{c.add(e.cliName);for(let t of e.alias??[])c.add(t);e.negation&&c.add(e.negation),l=!0},v=(e,t)=>{U(e.isGlobal===!0?p:d,e,t,g)},y=(e,t,n=``)=>{let r=e.isGlobal===!0?p:d,i=z(e,t,n);i!==void 0&&(r[e.name]=i)},b=0,x=N(i(a),s),S=!1;for(;b<e.length-1;){let t=e[b];if(!S&&t===`--`){S=!0,b++;continue}if(!S&&t.startsWith(`-`)&&!t.startsWith(`--`)&&t.length>2&&!t.includes(`=`)){l=!0;let e=Array.from(t.slice(1)),n=x.filter(e=>e.isGlobal!==!0);for(let t of e){let e=G(n,{name:t,isLong:!1});e&&!e.takesValue&&(_(e),y(e,{name:t,isLong:!1}))}b++;continue}if(!S&&I(t)){l=!0;let n=L(t),r=G(x,n);if(r){if(_(r),r.takesValue){if(R(t)){let e=t.indexOf(`=`);v(r,t.slice(e+1))}else if(b+1<e.length-1){let t=e[b+1];I(t)||(v(r,t),b++)}}else y(r,n,t)}b++;continue}let n=S?null:se(a,t);if(n){o.push(t);let r=i(a),l=e.slice(h,b);for(let e of ne(l,s,p))m.add(e);a=n,x=N(i(a),s);for(let e of Object.keys(d)){let t=r.find(t=>t.name===e),n=s.find(t=>t.name===e)??(t?te(s,t):void 0);n&&(m.has(n.name)||(p[n.name]=re(d[e],n)))}c.clear(),u=0,d={},f=[],g=/* @__PURE__ */ new Set,h=b+1,b++}else f.push(t),u++,b++}let C=e[e.length-1]??``,w=e[e.length-2]??``,T=ie(a,d,f),E=ae(a,d,f),D=oe(a);for(let e=0;e<E.length;e++){let t=E[e];if(t.variadic){d[t.name]=f.slice(e);break}e<f.length&&(d[t.name]=f[e])}let O,k,j;if(!S&&w&&I(w)&&!R(w)){let e=G(x,L(w));e&&e.takesValue?(O=`option-value`,k=e):C.startsWith(`-`)?O=`option-name`:(O=J(C,D,E,u),O===`positional`&&(j=u))}else if(!S&&C.startsWith(`-`)&&R(C)){let e=G(x,L(C));e&&e.takesValue?(O=`option-value`,k=e):O=`option-name`}else!S&&C.startsWith(`-`)?O=`option-name`:(O=J(C,D,E,u,S),O===`positional`&&(j=u));let M=[];if(k){if(k.valueType===`array`){let e=(k.isGlobal===!0?p:d)[k.name];M=Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}}else if(O===`positional`&&j!==void 0){let e=P(j,E);e!==void 0&&E[e]?.variadic&&(M=f.slice(e))}let F={...p,...d};return{context:{subcommandPath:o,currentCommand:a,currentWord:C,previousWord:w,completionType:O,targetOption:k,positionalIndex:j,options:x,subcommands:D,positionals:E,usedOptions:c,hasAnyOptionBeenUsed:l,providedPositionalCount:u,parsedArgs:F,previousValues:M},variantOptions:T}}function J(e,t,n,r,i){return i?`positional`:t.length>0&&(t.filter(t=>t.startsWith(e)).length>0||e===``)?`subcommand`:r<n.length||n.length>0&&n[n.length-1].variadic?`positional`:`subcommand`}const Y={Default:0,NoSpace:1,NoFileCompletion:2,FilterPrefix:4,KeepOrder:8,FileCompletion:16,DirectoryCompletion:32,Error:64};function X(e){if(!e.startsWith(`-`))return;let t=e.indexOf(`=`);if(!(t<=0))return e.slice(0,t+1)}async function ue(e,t){switch(e.completionType){case`subcommand`:return ye(e);case`option-name`:return be(e);case`option-value`:{let n=e.targetOption,r=n?X(e.currentWord):void 0;return Ce(r?{...e,currentWord:e.currentWord.slice(r.length)}:e,t,n?.name,n?.valueCompletion,void 0,n?.valueType===`array`)}case`positional`:{let n=de(e);return n?Ce(e,t,n.name,n.valueCompletion,n.description,!1):{candidates:[],directive:Y.NoFileCompletion}}}}function de(e){let t=e.positionalIndex??0,n=P(t,e.positionals);if(n===void 0)return;let r=e.positionals[n];if(r)return n===t||r.variadic?r:void 0}function fe(e){try{return d(e,{encoding:`utf-8`,timeout:5e3}).split(`
3
3
  `).map(e=>e.trim()).filter(e=>e.length>0).map(e=>({value:e,type:`value`}))}catch{return[]}}function Z(e){return e?.type===`choices`?e.choices:void 0}function pe(e,t){let n=e.options.find(e=>e.name===t&&e.isGlobal!==!0);if(n)return Z(n.valueCompletion);let r=e.positionals.find(e=>e.name===t);return Z(r?r.valueCompletion:e.options.find(e=>e.name===t&&e.isGlobal===!0)?.valueCompletion)}function me(e,t){let n=!t.includes(`=`),r=n?he(e):ge(e,t);return{candidates:r,hasEqSuffix:n&&r.some(e=>e.value.endsWith(`=`))}}function he(e){let t=/* @__PURE__ */ new Set,n=[];for(let r of e){let e=r.value.indexOf(`=`);if(e<=0){n.push(r);continue}let i=r.value.slice(0,e+1);t.has(i)||(t.add(i),n.push({...r,value:i}))}return n}function ge(e,t){let n=t.slice(0,t.indexOf(`=`)+1);return e.filter(e=>e.value!==n)}async function _e(e,t,n,r,i){let a=[],o=Y.FilterPrefix,s,c;switch(e.type){case`choices`:if(e.choices)for(let t of e.choices)a.push({value:t,description:r,type:`value`});o|=Y.NoFileCompletion;break;case`file`:e.matcher&&e.matcher.length>0?(c=e.matcher.filter(e=>e.trim().length>0),c.length===0&&(c=void 0,o|=Y.FileCompletion)):e.extensions&&e.extensions.length>0?(s=Array.from(new Set(e.extensions.map(e=>e.trim().replace(/^\./,``)).filter(e=>e.length>0))),s.length===0&&(s=void 0,o|=Y.FileCompletion)):o|=Y.FileCompletion;break;case`directory`:o|=Y.DirectoryCompletion;break;case`command`:e.shellCommand&&a.push(...fe(e.shellCommand)),o|=Y.NoFileCompletion;break;case`none`:o|=Y.NoFileCompletion;break;case`dynamic`:try{let n=await e.resolve(t);for(let e of n.candidates){let t=typeof e==`string`?{value:e}:e;a.push({...t,type:`value`})}o=n.directive??Y.FilterPrefix|Y.NoFileCompletion}catch{o=Y.NoFileCompletion|Y.Error}break;case`expand`:o|=Y.NoFileCompletion;break;case`runtime-expand`:{let r={},i=!1;for(let a of e.dependsOn){let e=t.parsedArgs[a],o=Array.isArray(e)?e[e.length-1]:e,s=pe(n,a);if(typeof o!=`string`||s===void 0||!s.includes(o)){i=!0;break}r[a]=o}if(!i)try{let t=/* @__PURE__ */ new Set;for(let n of e.enumerate(r)){let e=typeof n==`string`?{value:n}:n;t.has(e.value)||(t.add(e.value),a.push({...e,type:`value`}))}}catch{o=Y.NoFileCompletion|Y.Error;break}o|=Y.NoFileCompletion;break}}if(e.type===`dynamic`||e.type===`expand`||e.type===`runtime-expand`){let n=me(e.type===`runtime-expand`&&i===!0?ve(a,t.previousValues):a,t.currentWord);return n.hasEqSuffix&&(o|=Y.NoSpace),{candidates:n.candidates,directive:o,fileExtensions:s,fileMatchers:c}}return{candidates:a,directive:o,fileExtensions:s,fileMatchers:c}}function ve(e,t){let n=/* @__PURE__ */ new Set;for(let e of t){let t=e.indexOf(`=`);t>0&&n.add(e.slice(0,t))}return n.size===0?[...e]:e.filter(e=>{let t=e.value.indexOf(`=`);return t<=0||!n.has(e.value.slice(0,t))})}function ye(e){let t=[];for(let n of e.subcommands){let r=e.currentCommand.subCommands,i=r?.[n],a=i?void 0:s(e.currentCommand,n),c=i??(a?r?.[a]:void 0),l=c?o(c)?.description:void 0;t.push({value:n,description:l,type:`subcommand`})}if(t.length===0||e.currentWord.startsWith(`-`)){let n=be(e);t.push(...n.candidates)}return{candidates:t,directive:Y.FilterPrefix|Y.NoFileCompletion}}function be(e){let t=[],n=e.options.filter(t=>t.valueType===`array`||!(e.usedOptions.has(t.cliName)||t.alias&&t.alias.some(t=>e.usedOptions.has(t))||t.negation&&e.usedOptions.has(t.negation)));for(let e of n)t.push({value:`--${e.cliName}`,description:e.description,type:`option`}),e.negation&&t.push({value:`--${e.negation}`,description:e.negationDescription??e.description,type:`option`});return e.hasAnyOptionBeenUsed||t.push({value:`--help`,description:`Show help information`,type:`option`},{value:`--help-all`,description:`Show help with all subcommand options`,type:`option`},{value:`--help-json`,description:`Show help as JSON`,type:`option`}),{candidates:t,directive:Y.FilterPrefix|Y.NoFileCompletion}}function xe(e,t,n){return{currentWord:e.currentWord,shell:t.shell,parsedArgs:Se(e.parsedArgs,n),previousValues:e.previousValues,subcommandPath:e.subcommandPath}}function Se(e,t){if(t===void 0||!(t in e))return e;let n={...e};return delete n[t],n}async function Ce(e,t,n,r,i,a){return r?_e(r,xe(e,t,n),e,i,a):{candidates:[],directive:Y.FilterPrefix}}function Q(e,t){switch(t.shell){case`bash`:return we(e,t);case`zsh`:return Te(e,t);case`fish`:return Ee(e,t)}}function $(e,t){let n=`:${t.directive}`;t.fileExtensions&&t.fileExtensions.length>0&&(n+=`\t@ext:${t.fileExtensions.join(`,`)}`),t.fileMatchers&&t.fileMatchers.length>0&&(n+=`\t@matcher:${t.fileMatchers.join(`,`)}`),e.push(n)}function we(e,t){let n=((e.directive&Y.FilterPrefix)!==0&&t.currentWord?e.candidates.filter(e=>e.value.startsWith(t.currentWord)):e.candidates).map(e=>t.inlinePrefix?`${t.inlinePrefix}${e.value}`:e.value);return $(n,e),n.join(`
4
4
  `)}function Te(e,t){let n=e.candidates.map(e=>{let t=e.value.replace(/:/g,`\\:`);return e.description?`${t}:${e.description.replace(/:/g,`\\:`)}`:t});return $(n,e),n.join(`
5
5
  `)}function Ee(e,t){let n=e.candidates.map(e=>e.description?`${e.value}\t${e.description}`:e.value);return $(n,e),n.join(`