@politty/zod 0.6.1 → 0.7.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 (50) hide show
  1. package/README.md +2 -2
  2. package/dist/agent.d.ts +1 -1
  3. package/dist/{arg-registry-v1Fxnqj8.d.ts → arg-registry-SvIkYiSr.d.ts} +84 -28
  4. package/dist/argv-parser-BEwhz0XV.js +1 -0
  5. package/dist/augment.d.ts +2 -4
  6. package/dist/cli-main-Dccv0RoX.js +1 -0
  7. package/dist/{cli-main-DblimvdD.js → cli-main-qfjIxAaA.js} +2 -2
  8. package/dist/cli-run-DtYY4hyA.js +1 -0
  9. package/dist/cli.js +1 -1
  10. package/dist/compile-cache.d.ts +1 -3
  11. package/dist/{completion-NbQ2jmWx.js → completion-07BWyhmL.js} +1 -1
  12. package/dist/completion-B9wrL5rH.js +1 -0
  13. package/dist/completion.d.ts +2 -22
  14. package/dist/completion.js +1 -1
  15. package/dist/{detect-agent-EHaSY1KW.d.ts → detect-agent-hU93hctO.d.ts} +0 -4
  16. package/dist/docs.d.ts +1 -21
  17. package/dist/docs.js +2 -2
  18. package/dist/dynamic-CxhC0uOL.js +1 -0
  19. package/dist/{dynamic-DvdL7L96.js → dynamic-D3fYVKon.js} +2 -2
  20. package/dist/index.d.ts +36 -48
  21. package/dist/index.js +1 -1
  22. package/dist/prompt-QPFzhQ3p.js +1 -0
  23. package/dist/prompt-clack.d.ts +2 -4
  24. package/dist/prompt-clack.js +1 -1
  25. package/dist/prompt-inquirer.d.ts +2 -4
  26. package/dist/prompt-inquirer.js +1 -1
  27. package/dist/prompt.d.ts +2 -10
  28. package/dist/prompt.js +1 -1
  29. package/dist/register-BIQ84gFS.js +1 -0
  30. package/dist/runner-Bfxogqk4.js +1 -0
  31. package/dist/runner-BxFyJbWK.js +33 -0
  32. package/dist/schema-C2QqQGOQ.js +1 -0
  33. package/dist/schema-extractor-DL8vjWso.js +1 -0
  34. package/dist/skill.d.ts +7 -24
  35. package/dist/skill.js +2 -2
  36. package/dist/{field-meta-CEtC5Mir.js → unflatten-D6YJ7e-J.js} +1 -1
  37. package/dist/{with-completion-command-CI1rxHay.js → with-completion-command-DSqob4X0.js} +2 -2
  38. package/dist/{with-completion-command-Cwt9fmEm.d.ts → with-completion-command-M2RHrGAp.d.ts} +1 -9
  39. package/package.json +2 -2
  40. package/dist/argv-parser-BzWc9lXh.js +0 -1
  41. package/dist/cli-main-CykIbGzU.js +0 -1
  42. package/dist/cli-run-Aso3lU0I.js +0 -1
  43. package/dist/completion-CmxAA8Op.js +0 -1
  44. package/dist/dynamic-BEW8hYW1.js +0 -1
  45. package/dist/prompt-Bs_O6SmK.js +0 -1
  46. package/dist/register-w1jLVF3B.js +0 -1
  47. package/dist/runner-Bg6kLaM9.js +0 -1
  48. package/dist/runner-BsHTbOwS.js +0 -33
  49. package/dist/schema-C20skX3E.js +0 -1
  50. package/dist/schema-extractor-lB6-WHOF.js +0 -1
package/dist/docs.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { $ as ResolvedFieldMeta, D as Example, K as SubCommandValue, Q as ExtractedFields, S as ArgsSchema, b as AnyCommand, ot as SchemaLike } from "./arg-registry-v1Fxnqj8.js";
1
+ import { A as Example, C as AnyCommand, T as ArgsSchema, X as SubCommandValue, ft as SchemaLike, nt as ExtractedFields, rt as ResolvedFieldMeta } from "./arg-registry-SvIkYiSr.js";
2
2
  import * as fs$1 from "node:fs";
3
- //#region ../core/src/executor/subcommand-router.d.ts
4
3
  /**
5
4
  * Resolve a lazy-loaded command (sync or async)
6
5
  *
@@ -8,14 +7,10 @@ import * as fs$1 from "node:fs";
8
7
  * @returns The resolved command
9
8
  */
10
9
  export declare function resolveLazyCommand(cmd: SubCommandValue, useMetadata?: (meta: AnyCommand) => boolean): Promise<AnyCommand>;
11
- //#endregion
12
- //#region ../core/src/docs/option-rows.d.ts
13
10
  /**
14
11
  * Column identifiers for the options markdown table, in their canonical order.
15
12
  */
16
13
  type ColumnId = "option" | "alias" | "description" | "required" | "default" | "env";
17
- //#endregion
18
- //#region ../core/src/docs/render-args.d.ts
19
14
  /**
20
15
  * Args shape type (Record of string keys to field schemas of the CLI's
21
16
  * schema library). This matches the typical structure of `commonArgs`,
@@ -53,8 +48,6 @@ type ArgsTableOptions = {
53
48
  * @returns Rendered markdown table string
54
49
  */
55
50
  export declare function renderArgsTable(args: ArgsShape, options?: ArgsTableOptions): string;
56
- //#endregion
57
- //#region ../core/src/docs/types.d.ts
58
51
  /** Heading level for markdown headings (1-6) */
59
52
  type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
60
53
  /**
@@ -545,8 +538,6 @@ export declare function indexStartMarker(scope: string): string;
545
538
  * Generate end marker for an index section
546
539
  */
547
540
  export declare function indexEndMarker(scope: string): string;
548
- //#endregion
549
- //#region ../core/src/docs/default-renderers.d.ts
550
541
  /**
551
542
  * Render usage line
552
543
  */
@@ -638,8 +629,6 @@ export declare const defaultRenderers: {
638
629
  /** List style options */
639
630
  listStyle: RenderFunction;
640
631
  };
641
- //#endregion
642
- //#region ../core/src/docs/doc-comparator.d.ts
643
632
  /**
644
633
  * Comparison result
645
634
  */
@@ -670,8 +659,6 @@ interface DeleteFileFs {
670
659
  existsSync: typeof fs$1.existsSync;
671
660
  unlinkSync: typeof fs$1.unlinkSync;
672
661
  }
673
- //#endregion
674
- //#region ../core/src/docs/doc-generator.d.ts
675
662
  /**
676
663
  * Build CommandInfo from a command
677
664
  */
@@ -681,8 +668,6 @@ export declare function buildCommandInfo(command: AnyCommand, rootName: string,
681
668
  * Returns a map of command path -> CommandInfo
682
669
  */
683
670
  export declare function collectAllCommands(command: AnyCommand, rootName?: string): Promise<Map<string, CommandInfo>>;
684
- //#endregion
685
- //#region ../core/src/docs/example-executor.d.ts
686
671
  /**
687
672
  * Execute examples for a command and capture output
688
673
  *
@@ -693,8 +678,6 @@ export declare function collectAllCommands(command: AnyCommand, rootName?: strin
693
678
  * @returns Array of execution results with captured stdout/stderr
694
679
  */
695
680
  export declare function executeExamples(examples: Example[], config: ExampleCommandConfig, rootCommand: AnyCommand, commandPath?: string[]): Promise<ExampleExecutionResult[]>;
696
- //#endregion
697
- //#region ../core/src/docs/golden-test.d.ts
698
681
  /**
699
682
  * Generate documentation from command definition
700
683
  */
@@ -712,8 +695,6 @@ export declare function assertDocMatch(config: GenerateDocConfig): Promise<void>
712
695
  * @param fileSystem - Optional fs implementation (useful when fs is mocked)
713
696
  */
714
697
  export declare function initDocFile(config: Pick<GenerateDocConfig, "files" | "templates" | "rootDoc"> | string, fileSystem?: DeleteFileFs): void;
715
- //#endregion
716
- //#region ../core/src/docs/render-index.d.ts
717
698
  /**
718
699
  * Configuration for a command category
719
700
  */
@@ -766,5 +747,4 @@ type CommandCategory = {
766
747
  * @returns Rendered markdown string
767
748
  */
768
749
  export declare function renderCommandIndex(command: AnyCommand, categories: CommandCategory[], options?: CommandIndexOptions): Promise<string>;
769
- //#endregion
770
750
  export type { ArgsShape, ArgsTableOptions, ArgumentsRenderContext, ArgumentsRenderFunction, CommandCategory, CommandIndexOptions, CommandInfo, DefaultRendererOptions, DeleteFileFs, ExampleCommandConfig, ExampleConfig, ExampleExecutionResult, ExamplesRenderContext, ExamplesRenderFunction, ExamplesRenderOptions, FileConfig, FileMapping, FormatterFunction, GenerateDocConfig, GenerateDocResult, HeadingLevel, OptionsRenderContext, OptionsRenderFunction, PathConfig, RenderContentOptions, RenderFunction, RootCommandInfo, RootDocConfig, SectionRenderFunction, SectionType, SimpleRenderContext, SimpleRenderFunction, SubCommandInfo, SubcommandsRenderContext, SubcommandsRenderFunction, SubcommandsRenderOptions };
package/dist/docs.js CHANGED
@@ -1,4 +1,4 @@
1
- import{o as e}from"./field-meta-CEtC5Mir.js";import"./register-w1jLVF3B.js";import{c as t,n,o as r,r as i,s as a,t as o}from"./schema-extractor-lB6-WHOF.js";import{r as s}from"./subcommand-router-40vA6Mka.js";import{t as c}from"./log-collector-uhRWYT-z.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(`
1
+ import{m as e}from"./unflatten-D6YJ7e-J.js";import"./register-BIQ84gFS.js";import{c as t,n,o as r,r as i,s as a,t as o}from"./schema-extractor-DL8vjWso.js";import{r as s}from"./subcommand-router-40vA6Mka.js";import{t as c}from"./log-collector-uhRWYT-z.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
 
@@ -18,7 +18,7 @@ import{o as e}from"./field-meta-CEtC5Mir.js";import"./register-w1jLVF3B.js";impo
18
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=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-Bg6kLaM9.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-Bfxogqk4.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(`
@@ -0,0 +1 @@
1
+ export{t as createDynamicCompleteCommand}from"./dynamic-D3fYVKon.js";
@@ -1,5 +1,5 @@
1
- import{i as e,n as t}from"./field-meta-CEtC5Mir.js";import{a as n,l as r,n as i}from"./schema-extractor-lB6-WHOF.js";import{n as a}from"./command-BXsTrIgI.js";import{c as o,i as s}from"./subcommand-router-40vA6Mka.js";import{n as c,o as l,r as u,s as d,u as f}from"./argv-parser-BzWc9lXh.js";import{t as p}from"./schema-C20skX3E.js";import{execSync as m}from"node:child_process";function h(e,t,n){return{fieldName:e.name,isArrayOption:e.valueType===`array`,isGlobal:e.isGlobal===!0,resolvedDeps:_(e.valueCompletion,e.isGlobal===!0,t,n)}}function g(e,t,n){return{fieldName:e.name,isArrayOption:!1,isGlobal:!1,resolvedDeps:_(e.valueCompletion,!1,t,n)}}function _(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 v(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 y(e){return`'${e.replace(/'/g,`'\\''`)}'`}function b(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 x(e){return e.length===1?`-${e}`:`--${e}`}function S(t,n){C(t,x(n)),n.length===1?C(t,`--${n}`):n.includes(`-`)&&C(t,`--${e(n)}`)}function C(e,t){e.includes(t)||e.push(t)}function w(t,n){let r=[`--${t}`];t.length===1&&r.push(`-${t}`),t.includes(`-`)&&r.push(`--${e(t)}`);for(let e of n??[])S(r,e);return r}function T(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 E(t,n,r,i){let a=new Set(w(t,n));if(r&&(a.add(`--${r}`),r.includes(`-`)&&a.add(`--${e(r)}`)),i?.frameOptions){if(i.isGlobal===!0){for(let e of i.frameOptions)if(e.isGlobal!==!0)for(let t of A(e.cliName,e.alias))a.delete(t)}else{let e=T(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 D(e,t){return e.map(e=>{let n=t.find(t=>t.isGlobal!==!0&&t.name===e.name);return n&&E(n.cliName,n.alias,n.negation,{frameOptions:t})})}function O(e,t,n,r=`$_pos_count`){let i=D(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 k(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 O(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 A(t,n){let r=[`--${t}`];t.includes(`-`)&&r.push(`--${e(t)}`);for(let e of n??[])S(r,e);return r}function j(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 M(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?N(e.args):[]}function N(e){return n(i(e)).map(P)}function P(e){let n=t(e);return{name:e.name,cliName:e.cliName,alias:n.length>0?n:void 0,negation:e.negationDisplay,negationDescription:e.negationDescription,description:e.description,takesValue:e.type!==`boolean`,valueType:e.type,required:e.required,defaultNegationAccepted:e.type===`boolean`&&e.negation===!0,valueCompletion:M(j(e))}}function F(e){return new Set(w(e.cliName,e.alias))}function te(e,t){let n=F(t);for(let t of e)for(let e of F(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)=>{G(n,e,t,i),r.add(e.name)},o=0;for(;o<e.length;){let i=e[o];if(i===`--`||!i.startsWith(`-`))break;if(u(i)){let{isGlobal:s,flags:l,valueOption:u}=z(i,t);if(!s)break;for(let{opt:e}of l)n[e.name]=!0,r.add(e.name);if(u?.value!==void 0)a(u.opt,u.value);else if(u){let t=e[o+1];if(t===void 0)break;c(t)&&(a(u.opt,t),o++)}o++;continue}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=R(i),l=q(t,s);if(!l){if(de(t,s)){o++;continue}break}if(l.takesValue){if(B(i)){let e=i.indexOf(`=`);a(l,i.slice(e+1)),o++}else if(o+1<e.length){let t=e[o+1];if(!c(t)){o++;continue}a(l,t),o+=2}else break}else{let e=V(l,s,i);e!==void 0&&(n[l.name]=e),r.add(l.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 ie(e,t){return t.length===0?e:[...e,...t]}function ae(e,t){let n=t.length-1;if(!(n<0))return e>n?n:e}function I(e,t){return n=>{let r={...e};return l(n,e).forEach((e,n)=>{n<t.length&&(r[e.name]=t[n])}),r}}function oe(e,t,n){if(!e.args)return;let a=i(e.args),o=r(a,I(t,n));if(o!==a)return o.fields.filter(e=>e.named).map(P)}function se(e,t,n){if(!e.args)return[];let a=r(i(e.args),I(t,n));return l(a,t).map((e,t)=>({name:e.name,cliName:e.cliName,position:t,description:e.description,required:e.required,variadic:e.type===`array`,valueCompletion:M(j(e))}))}function ce(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 le(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 L(e){return e.startsWith(`-`)}function R(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 z(e,t){let n=(e,t)=>q(e,{name:t,isLong:!1}),r=t.filter(e=>e.isGlobal!==!0),i=t.filter(e=>e.isGlobal===!0),a=e=>!n(r,e)&&n(i,e)!==void 0,o=d(e.slice(1),e=>a(e)&&n(i,e).takesValue),s=o.flags.every(a),c=s?i:r,{flags:l,valueOption:u}=s?o:d(e.slice(1),e=>n(r,e)?.takesValue===!0);return{isGlobal:s,flags:l.flatMap(e=>{let t=n(c,e);return t?[{opt:t,name:e}]:[]}),valueOption:u&&{opt:n(c,u.name),value:u.value}}}function ue(e,t){let{valueOption:n}=z(e,t);return n?.value===void 0?n?.opt:void 0}function B(e){return e.includes(`=`)}function V(e,t,n){let r=fe(e,t);return B(n)?r?void 0:f(n.slice(n.indexOf(`=`)+1)):!r}function H(t,n,r){if(!r||t.valueType!==`boolean`)return!1;let i=[t.cliName,...t.alias??[]];for(let t of i){let r=`no-${t}`;if(n===r||n===e(r))return!0}return!1}function U(e,t,n){return e.defaultNegationAccepted===!0&&H(e,t,n)}function de(e,t){return e.some(e=>e.defaultNegationAccepted!==!0&&H(e,t.name,t.isLong))}function W(t,n){return t!==void 0&&t.includes(`-`)&&e(t)===n}function G(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 fe(e,t){return t.isLong?e.negation!==void 0&&(e.negation===t.name||W(e.negation,t.name))?!0:U(e,t.name,t.isLong):!1}function K(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:W(e.cliName,t)||e.alias?.some(e=>W(e,t))?!0:W(e.negation,t)}function q(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&&K(e,t.name,t.isLong));if(r)return r}return e.find(e=>K(e,t.name,t.isLong))||e.find(e=>U(e,t.name,t.isLong))}function J(e,t,n){let r=Y(e,t,n);return r.variantOptions?Y(e,t,n,{command:r.context.currentCommand,options:r.variantOptions}).context:r.context}function Y(e,t,n,r){let i=e=>e===r?.command?r.options:ee(e),a=t,o=[],s=n?N(n).map(e=>({...e,isGlobal:!0})):[],l=/* @__PURE__ */ new Set,d=!1,f=0,p={},m=[],h={},g=/* @__PURE__ */ new Set,_=0,v=/* @__PURE__ */ new Set,y=e=>{l.add(e.cliName);for(let t of e.alias??[])l.add(t);e.negation&&l.add(e.negation),d=!0},b=(e,t)=>{G(e.isGlobal===!0?h:p,e,t,v)},x=(e,t,n=``)=>{let r=e.isGlobal===!0?h:p,i=V(e,t,n);i!==void 0&&(r[e.name]=i)},S=0,C=ie(i(a),s),w=!1;for(;S<e.length-1;){let t=e[S];if(!w&&t===`--`){w=!0,S++;continue}if(!w&&u(t)){d=!0;let{flags:n,valueOption:r}=z(t,C);for(let{opt:e,name:t}of n)y(e),x(e,{name:t,isLong:!1});r&&(y(r.opt),r.value===void 0?S+1<e.length-1&&c(e[S+1])&&(b(r.opt,e[S+1]),S++):b(r.opt,r.value)),S++;continue}if(!w&&L(t)){d=!0;let n=R(t),r=q(C,n);if(r){if(y(r),r.takesValue){if(B(t)){let e=t.indexOf(`=`);b(r,t.slice(e+1))}else if(S+1<e.length-1){let t=e[S+1];c(t)&&(b(r,t),S++)}}else x(r,n,t)}S++;continue}let n=w?null:le(a,t);if(n){o.push(t);let r=i(a),c=e.slice(_,S);for(let e of ne(c,s,h))g.add(e);a=n,C=ie(i(a),s);for(let e of Object.keys(p)){let t=r.find(t=>t.name===e),n=s.find(t=>t.name===e)??(t?te(s,t):void 0);n&&(g.has(n.name)||(h[n.name]=re(p[e],n)))}l.clear(),f=0,p={},m=[],v=/* @__PURE__ */ new Set,_=S+1,S++}else m.push(t),f++,S++}let T=e[e.length-1]??``,E=e[e.length-2]??``,D=oe(a,p,m),O=se(a,p,m),k=ce(a);for(let e=0;e<O.length;e++){let t=O[e];if(t.variadic){p[t.name]=m.slice(e);break}e<m.length&&(p[t.name]=m[e])}let A,j,M;if(!w&&E&&L(E)&&!B(E)){let e=u(E)?ue(E,C):q(C,R(E));e&&e.takesValue?(A=`option-value`,j=e):T.startsWith(`-`)?A=`option-name`:(A=X(T,k,O,f),A===`positional`&&(M=f))}else if(!w&&T.startsWith(`-`)&&B(T)){let e=q(C,R(T));e&&e.takesValue?(A=`option-value`,j=e):A=`option-name`}else!w&&T.startsWith(`-`)?A=`option-name`:(A=X(T,k,O,f,w),A===`positional`&&(M=f));let P=[];if(j){if(j.valueType===`array`){let e=(j.isGlobal===!0?h:p)[j.name];P=Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}}else if(A===`positional`&&M!==void 0){let e=ae(M,O);e!==void 0&&O[e]?.variadic&&(P=m.slice(e))}let F={...h,...p};return{context:{subcommandPath:o,currentCommand:a,currentWord:T,previousWord:E,completionType:A,targetOption:j,positionalIndex:M,options:C,subcommands:k,positionals:O,usedOptions:l,hasAnyOptionBeenUsed:d,providedPositionalCount:f,parsedArgs:F,previousValues:P},variantOptions:D}}function X(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 Z={Default:0,NoSpace:1,NoFileCompletion:2,FilterPrefix:4,KeepOrder:8,FileCompletion:16,DirectoryCompletion:32,Error:64};function pe(e){if(!e.startsWith(`-`))return;let t=e.indexOf(`=`);if(!(t<=0))return e.slice(0,t+1)}async function me(e,t){switch(e.completionType){case`subcommand`:return we(e);case`option-name`:return Te(e);case`option-value`:{let n=e.targetOption,r=n?pe(e.currentWord):void 0;return Q(r?{...e,currentWord:e.currentWord.slice(r.length)}:e,t,n?.name,n?.valueCompletion,void 0,n?.valueType===`array`)}case`positional`:{let n=he(e);return n?Q(e,t,n.name,n.valueCompletion,n.description,!1):{candidates:[],directive:Z.NoFileCompletion}}}}function he(e){let t=e.positionalIndex??0,n=ae(t,e.positionals);if(n===void 0)return;let r=e.positionals[n];if(r)return n===t||r.variadic?r:void 0}function ge(e){try{return m(e,{encoding:`utf-8`,timeout:5e3}).split(`
1
+ import{f as e,u as t}from"./unflatten-D6YJ7e-J.js";import{a as n,n as r,u as i}from"./schema-extractor-DL8vjWso.js";import{n as a}from"./command-BXsTrIgI.js";import{c as o,i as s}from"./subcommand-router-40vA6Mka.js";import{n as c,o as l,r as u,s as d,u as f}from"./argv-parser-BEwhz0XV.js";import{t as p}from"./schema-C2QqQGOQ.js";import{execSync as m}from"node:child_process";function h(e,t,n){return{fieldName:e.name,isArrayOption:e.valueType===`array`,isGlobal:e.isGlobal===!0,resolvedDeps:_(e.valueCompletion,e.isGlobal===!0,t,n)}}function g(e,t,n){return{fieldName:e.name,isArrayOption:!1,isGlobal:!1,resolvedDeps:_(e.valueCompletion,!1,t,n)}}function _(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 v(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 y(e){return`'${e.replace(/'/g,`'\\''`)}'`}function b(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 x(e){return e.length===1?`-${e}`:`--${e}`}function S(t,n){C(t,x(n)),n.length===1?C(t,`--${n}`):n.includes(`-`)&&C(t,`--${e(n)}`)}function C(e,t){e.includes(t)||e.push(t)}function w(t,n){let r=[`--${t}`];t.length===1&&r.push(`-${t}`),t.includes(`-`)&&r.push(`--${e(t)}`);for(let e of n??[])S(r,e);return r}function T(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 E(t,n,r,i){let a=new Set(w(t,n));if(r&&(a.add(`--${r}`),r.includes(`-`)&&a.add(`--${e(r)}`)),i?.frameOptions){if(i.isGlobal===!0){for(let e of i.frameOptions)if(e.isGlobal!==!0)for(let t of A(e.cliName,e.alias))a.delete(t)}else{let e=T(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 D(e,t){return e.map(e=>{let n=t.find(t=>t.isGlobal!==!0&&t.name===e.name);return n&&E(n.cliName,n.alias,n.negation,{frameOptions:t})})}function O(e,t,n,r=`$_pos_count`){let i=D(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 k(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 O(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 A(t,n){let r=[`--${t}`];t.includes(`-`)&&r.push(`--${e(t)}`);for(let e of n??[])S(r,e);return r}function j(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 M(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?N(e.args):[]}function N(e){return n(r(e)).map(P)}function P(e){let n=t(e);return{name:e.name,cliName:e.cliName,alias:n.length>0?n:void 0,negation:e.negationDisplay,negationDescription:e.negationDescription,description:e.description,takesValue:e.type!==`boolean`,valueType:e.type,required:e.required,defaultNegationAccepted:e.type===`boolean`&&e.negation===!0,valueCompletion:M(j(e))}}function F(e){return new Set(w(e.cliName,e.alias))}function te(e,t){let n=F(t);for(let t of e)for(let e of F(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)=>{G(n,e,t,i),r.add(e.name)},o=0;for(;o<e.length;){let i=e[o];if(i===`--`||!i.startsWith(`-`))break;if(u(i)){let{isGlobal:s,flags:l,valueOption:u}=z(i,t);if(!s)break;for(let{opt:e}of l)n[e.name]=!0,r.add(e.name);if(u?.value!==void 0)a(u.opt,u.value);else if(u){let t=e[o+1];if(t===void 0)break;c(t)&&(a(u.opt,t),o++)}o++;continue}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=R(i),l=q(t,s);if(!l){if(de(t,s)){o++;continue}break}if(l.takesValue){if(B(i)){let e=i.indexOf(`=`);a(l,i.slice(e+1)),o++}else if(o+1<e.length){let t=e[o+1];if(!c(t)){o++;continue}a(l,t),o+=2}else break}else{let e=V(l,s,i);e!==void 0&&(n[l.name]=e),r.add(l.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 ie(e,t){return t.length===0?e:[...e,...t]}function ae(e,t){let n=t.length-1;if(!(n<0))return e>n?n:e}function I(e,t){return n=>{let r={...e};return l(n,e).forEach((e,n)=>{n<t.length&&(r[e.name]=t[n])}),r}}function oe(e,t,n){if(!e.args)return;let a=r(e.args),o=i(a,I(t,n));if(o!==a)return o.fields.filter(e=>e.named).map(P)}function se(e,t,n){if(!e.args)return[];let a=i(r(e.args),I(t,n));return l(a,t).map((e,t)=>({name:e.name,cliName:e.cliName,position:t,description:e.description,required:e.required,variadic:e.type===`array`,valueCompletion:M(j(e))}))}function ce(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 le(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 L(e){return e.startsWith(`-`)}function R(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 z(e,t){let n=(e,t)=>q(e,{name:t,isLong:!1}),r=t.filter(e=>e.isGlobal!==!0),i=t.filter(e=>e.isGlobal===!0),a=e=>!n(r,e)&&n(i,e)!==void 0,o=d(e.slice(1),e=>a(e)&&n(i,e).takesValue),s=o.flags.every(a),c=s?i:r,{flags:l,valueOption:u}=s?o:d(e.slice(1),e=>n(r,e)?.takesValue===!0);return{isGlobal:s,flags:l.flatMap(e=>{let t=n(c,e);return t?[{opt:t,name:e}]:[]}),valueOption:u&&{opt:n(c,u.name),value:u.value}}}function ue(e,t){let{valueOption:n}=z(e,t);return n?.value===void 0?n?.opt:void 0}function B(e){return e.includes(`=`)}function V(e,t,n){let r=fe(e,t);return B(n)?r?void 0:f(n.slice(n.indexOf(`=`)+1)):!r}function H(t,n,r){if(!r||t.valueType!==`boolean`)return!1;let i=[t.cliName,...t.alias??[]];for(let t of i){let r=`no-${t}`;if(n===r||n===e(r))return!0}return!1}function U(e,t,n){return e.defaultNegationAccepted===!0&&H(e,t,n)}function de(e,t){return e.some(e=>e.defaultNegationAccepted!==!0&&H(e,t.name,t.isLong))}function W(t,n){return t!==void 0&&t.includes(`-`)&&e(t)===n}function G(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 fe(e,t){return t.isLong?e.negation!==void 0&&(e.negation===t.name||W(e.negation,t.name))?!0:U(e,t.name,t.isLong):!1}function K(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:W(e.cliName,t)||e.alias?.some(e=>W(e,t))?!0:W(e.negation,t)}function q(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&&K(e,t.name,t.isLong));if(r)return r}return e.find(e=>K(e,t.name,t.isLong))||e.find(e=>U(e,t.name,t.isLong))}function J(e,t,n){let r=Y(e,t,n);return r.variantOptions?Y(e,t,n,{command:r.context.currentCommand,options:r.variantOptions}).context:r.context}function Y(e,t,n,r){let i=e=>e===r?.command?r.options:ee(e),a=t,o=[],s=n?N(n).map(e=>({...e,isGlobal:!0})):[],l=/* @__PURE__ */ new Set,d=!1,f=0,p={},m=[],h={},g=/* @__PURE__ */ new Set,_=0,v=/* @__PURE__ */ new Set,y=e=>{l.add(e.cliName);for(let t of e.alias??[])l.add(t);e.negation&&l.add(e.negation),d=!0},b=(e,t)=>{G(e.isGlobal===!0?h:p,e,t,v)},x=(e,t,n=``)=>{let r=e.isGlobal===!0?h:p,i=V(e,t,n);i!==void 0&&(r[e.name]=i)},S=0,C=ie(i(a),s),w=!1;for(;S<e.length-1;){let t=e[S];if(!w&&t===`--`){w=!0,S++;continue}if(!w&&u(t)){d=!0;let{flags:n,valueOption:r}=z(t,C);for(let{opt:e,name:t}of n)y(e),x(e,{name:t,isLong:!1});r&&(y(r.opt),r.value===void 0?S+1<e.length-1&&c(e[S+1])&&(b(r.opt,e[S+1]),S++):b(r.opt,r.value)),S++;continue}if(!w&&L(t)){d=!0;let n=R(t),r=q(C,n);if(r){if(y(r),r.takesValue){if(B(t)){let e=t.indexOf(`=`);b(r,t.slice(e+1))}else if(S+1<e.length-1){let t=e[S+1];c(t)&&(b(r,t),S++)}}else x(r,n,t)}S++;continue}let n=w?null:le(a,t);if(n){o.push(t);let r=i(a),c=e.slice(_,S);for(let e of ne(c,s,h))g.add(e);a=n,C=ie(i(a),s);for(let e of Object.keys(p)){let t=r.find(t=>t.name===e),n=s.find(t=>t.name===e)??(t?te(s,t):void 0);n&&(g.has(n.name)||(h[n.name]=re(p[e],n)))}l.clear(),f=0,p={},m=[],v=/* @__PURE__ */ new Set,_=S+1,S++}else m.push(t),f++,S++}let T=e[e.length-1]??``,E=e[e.length-2]??``,D=oe(a,p,m),O=se(a,p,m),k=ce(a);for(let e=0;e<O.length;e++){let t=O[e];if(t.variadic){p[t.name]=m.slice(e);break}e<m.length&&(p[t.name]=m[e])}let A,j,M;if(!w&&E&&L(E)&&!B(E)){let e=u(E)?ue(E,C):q(C,R(E));e&&e.takesValue?(A=`option-value`,j=e):T.startsWith(`-`)?A=`option-name`:(A=X(T,k,O,f),A===`positional`&&(M=f))}else if(!w&&T.startsWith(`-`)&&B(T)){let e=q(C,R(T));e&&e.takesValue?(A=`option-value`,j=e):A=`option-name`}else!w&&T.startsWith(`-`)?A=`option-name`:(A=X(T,k,O,f,w),A===`positional`&&(M=f));let P=[];if(j){if(j.valueType===`array`){let e=(j.isGlobal===!0?h:p)[j.name];P=Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}}else if(A===`positional`&&M!==void 0){let e=ae(M,O);e!==void 0&&O[e]?.variadic&&(P=m.slice(e))}let F={...h,...p};return{context:{subcommandPath:o,currentCommand:a,currentWord:T,previousWord:E,completionType:A,targetOption:j,positionalIndex:M,options:C,subcommands:k,positionals:O,usedOptions:l,hasAnyOptionBeenUsed:d,providedPositionalCount:f,parsedArgs:F,previousValues:P},variantOptions:D}}function X(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 Z={Default:0,NoSpace:1,NoFileCompletion:2,FilterPrefix:4,KeepOrder:8,FileCompletion:16,DirectoryCompletion:32,Error:64};function pe(e){if(!e.startsWith(`-`))return;let t=e.indexOf(`=`);if(!(t<=0))return e.slice(0,t+1)}async function me(e,t){switch(e.completionType){case`subcommand`:return we(e);case`option-name`:return Te(e);case`option-value`:{let n=e.targetOption,r=n?pe(e.currentWord):void 0;return Q(r?{...e,currentWord:e.currentWord.slice(r.length)}:e,t,n?.name,n?.valueCompletion,void 0,n?.valueType===`array`)}case`positional`:{let n=he(e);return n?Q(e,t,n.name,n.valueCompletion,n.description,!1):{candidates:[],directive:Z.NoFileCompletion}}}}function he(e){let t=e.positionalIndex??0,n=ae(t,e.positionals);if(n===void 0)return;let r=e.positionals[n];if(r)return n===t||r.variadic?r:void 0}function ge(e){try{return m(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 _e(e){return e?.type===`choices`?e.choices:void 0}function ve(e,t){let n=e.options.find(e=>e.name===t&&e.isGlobal!==!0);if(n)return _e(n.valueCompletion);let r=e.positionals.find(e=>e.name===t);return _e(r?r.valueCompletion:e.options.find(e=>e.name===t&&e.isGlobal===!0)?.valueCompletion)}function ye(e,t){let n=!t.includes(`=`),r=n?be(e):xe(e,t);return{candidates:r,hasEqSuffix:n&&r.some(e=>e.value.endsWith(`=`))}}function be(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 xe(e,t){let n=t.slice(0,t.indexOf(`=`)+1);return e.filter(e=>e.value!==n)}async function Se(e,t,n,r,i){let a=[],o=Z.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|=Z.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|=Z.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|=Z.FileCompletion)):o|=Z.FileCompletion;break;case`directory`:o|=Z.DirectoryCompletion;break;case`command`:e.shellCommand&&a.push(...ge(e.shellCommand)),o|=Z.NoFileCompletion;break;case`none`:o|=Z.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??Z.FilterPrefix|Z.NoFileCompletion}catch{o=Z.NoFileCompletion|Z.Error}break;case`expand`:o|=Z.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=ve(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=Z.NoFileCompletion|Z.Error;break}o|=Z.NoFileCompletion;break}}if(e.type===`dynamic`||e.type===`expand`||e.type===`runtime-expand`){let n=ye(e.type===`runtime-expand`&&i===!0?Ce(a,t.previousValues):a,t.currentWord);return n.hasEqSuffix&&(o|=Z.NoSpace),{candidates:n.candidates,directive:o,fileExtensions:s,fileMatchers:c}}return{candidates:a,directive:o,fileExtensions:s,fileMatchers:c}}function Ce(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 we(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=Te(e);t.push(...n.candidates)}return{candidates:t,directive:Z.FilterPrefix|Z.NoFileCompletion}}function Te(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:Z.FilterPrefix|Z.NoFileCompletion}}function Ee(e,t,n){return{currentWord:e.currentWord,shell:t.shell,parsedArgs:De(e.parsedArgs,n),previousValues:e.previousValues,subcommandPath:e.subcommandPath}}function De(e,t){if(t===void 0||!(t in e))return e;let n={...e};return delete n[t],n}async function Q(e,t,n,r,i,a){return r?Se(r,Ee(e,t,n),e,i,a):{candidates:[],directive:Z.FilterPrefix}}function Oe(e,t){switch(t.shell){case`bash`:return ke(e,t);case`zsh`:return Ae(e,t);case`fish`:return je(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 ke(e,t){let n=((e.directive&Z.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 Ae(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 je(e,t){let n=e.candidates.map(e=>e.description?`${e.value}\t${e.description}`:e.value);return $(n,e),n.join(`
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- import { r as KnownAgentId, t as AgentInfo } from "./detect-agent-EHaSY1KW.js";
2
- import { $ as ResolvedFieldMeta, A as GlobalSetupContext, B as RunInvocation, C as CleanupContext, D as Example, E as CommandBase, F as Logger, G as SetupContext, H as RunResultFailure, I as MainOptions, J as UnknownSubcommandHandler, K as SubCommandValue, L as NonRunnableCommand, M as LogEntry, N as LogLevel, O as GlobalArgs, P as LogStream, Q as ExtractedFields, R as PromptResolver, S as ArgsSchema$1, T as Command, U as RunResultSuccess, V as RunResult, W as RunnableCommand, X as isLazyCommand, Y as LazyCommand, Z as lazy, _ as DynamicCompletionResult, a as CustomCompletion, at as InferSchemaOutput, b as AnyCommand, c as PromptType, d as ExpandCompletion, et as UnknownKeysMode, f as ResolvedExpandCandidate, g as DynamicCompletionResolver, h as DynamicCompletionContext, i as CompletionType, it as loadPackage, j as IsEmpty, k as GlobalCleanupContext, l as ValidateArgMeta, m as DynamicCompletionCandidate, n as ArgMeta, nt as toKebabCase, o as EffectContext, ot as SchemaLike, p as CompletionDirectiveMask, q as SubCommandsRecord, r as CompletionMeta, rt as PackageRequirement, s as PromptMeta, t as ArgFn, tt as toCamelCase, u as ExpandCandidate, v as AgentHelp, w as CollectedLogs, x as ArgSource, y as AgentHelpContext, z as RunCommandOptions } from "./arg-registry-v1Fxnqj8.js";
3
- import { _ as CompletionResult, g as CompletionOptions, i as GenerateBundledCompletionWorkerResult, n as withCompletionCommand, r as GenerateBundledCompletionWorkerOptions, t as WithCompletionOptions, x as InternalArgsSchema } from "./with-completion-command-Cwt9fmEm.js";
1
+ import { r as KnownAgentId, t as AgentInfo } from "./detect-agent-hU93hctO.js";
2
+ import { $ as LazyCommand, A as Example, B as NonRunnableCommand, C as AnyCommand, D as CollectedLogs, E as CleanupContext, F as LogEntry, G as RunResult, H as PromptResolverContext, I as LogLevel, J as RunnableCommand, K as RunResultFailure, L as LogStream, M as GlobalCleanupContext, N as GlobalSetupContext, O as Command, P as IsEmpty, Q as UnknownSubcommandHandler, R as Logger, S as AgentHelpContext, T as ArgsSchema$1, U as RunCommandOptions, V as PromptResolver, W as RunInvocation, X as SubCommandValue, Y as SetupContext, Z as SubCommandsRecord, _ as DynamicCompletionCandidate, a as CustomCompletion, at as toCamelCase, b as DynamicCompletionResult, c as PromptChoicesContext, ct as UnflattenOptions, d as PromptType, dt as InferSchemaOutput, et as isLazyCommand, f as ValidateArgMeta, ft as SchemaLike, g as CompletionDirectiveMask, h as ResolvedExpandCandidate, i as CompletionType, it as UnknownKeysMode, j as GlobalArgs, k as CommandBase, l as PromptChoicesResolver, lt as PackageRequirement, m as ExpandCompletion, n as ArgMeta, nt as ExtractedFields, o as EffectContext, ot as toKebabCase, p as ExpandCandidate, q as RunResultSuccess, r as CompletionMeta, rt as ResolvedFieldMeta, s as PromptChoices, st as Unflatten, t as ArgFn, tt as lazy, u as PromptMeta, ut as loadPackage, v as DynamicCompletionContext, w as ArgSource, x as AgentHelp, y as DynamicCompletionResolver, z as MainOptions } from "./arg-registry-SvIkYiSr.js";
3
+ import { _ as CompletionResult, g as CompletionOptions, i as GenerateBundledCompletionWorkerResult, n as withCompletionCommand, r as GenerateBundledCompletionWorkerOptions, t as WithCompletionOptions, x as InternalArgsSchema } from "./with-completion-command-M2RHrGAp.js";
4
4
  import { z } from "zod";
5
- //#region ../core/src/core/schema-extractor.d.ts
6
5
  /**
7
6
  * Detect the unknown-keys handling mode of an args schema. Works for any
8
7
  * schema politty itself attaches to a command (including internal
@@ -16,8 +15,6 @@ export declare function getUnknownKeysMode(schema: ArgsSchema$1): UnknownKeysMod
16
15
  * @returns Extracted field information
17
16
  */
18
17
  export declare function extractFields(schema: ArgsSchema$1): ExtractedFields;
19
- //#endregion
20
- //#region ../core/src/adapter/types.d.ts
21
18
  /**
22
19
  * Validation error details
23
20
  */
@@ -43,8 +40,6 @@ type ValidationResult<T> = {
43
40
  success: false;
44
41
  errors: ValidationError[];
45
42
  };
46
- //#endregion
47
- //#region ../core/src/cli-main.d.ts
48
43
  /**
49
44
  * Run politty's own development CLI (`generate-shim`, `generate-worker`).
50
45
  *
@@ -57,8 +52,6 @@ type ValidationResult<T> = {
57
52
  * Never returns: it exits the process, like `runMain`.
58
53
  */
59
54
  export declare function runPolittyCli(ownerPackage: string): Promise<never>;
60
- //#endregion
61
- //#region ../core/src/compile-cache-shim.d.ts
62
55
  /**
63
56
  * Generator for compile-cache bin shims.
64
57
  *
@@ -157,8 +150,6 @@ interface GenerateCompileCacheShimResult {
157
150
  * clobbering the build output.
158
151
  */
159
152
  export declare function createCompileCacheShimGenerator(ownerPackage: string): (options?: GenerateCompileCacheShimOptions) => GenerateCompileCacheShimResult[];
160
- //#endregion
161
- //#region ../core/src/core/case-types.d.ts
162
153
  /**
163
154
  * TypeScript utility types for case conversion between camelCase and kebab-case.
164
155
  *
@@ -213,8 +204,6 @@ type KebabCase<S extends string> = StripLeadingHyphen<KebabCaseInner<S>>;
213
204
  * Uses a distributive conditional type so it works correctly with discriminated unions.
214
205
  */
215
206
  type WithCaseVariants<T> = T extends unknown ? T & { [K in keyof T as CamelCase<K & string>]: T[K]; } & { [K in keyof T as KebabCase<K & string>]: T[K]; } : never;
216
- //#endregion
217
- //#region ../core/src/core/case-proxy.d.ts
218
207
  /**
219
208
  * Wrap an args object with a Proxy that allows dual-case access.
220
209
  *
@@ -225,8 +214,6 @@ type WithCaseVariants<T> = T extends unknown ? T & { [K in keyof T as CamelCase<
225
214
  * - The `in` operator detects both case variants.
226
215
  */
227
216
  export declare function createDualCaseProxy<T extends Record<string, unknown>>(obj: T): WithCaseVariants<T>;
228
- //#endregion
229
- //#region ../core/src/core/command.d.ts
230
217
  /**
231
218
  * Infer args type from schema, defaults to empty object if undefined.
232
219
  * Wraps with WithCaseVariants so both camelCase and kebab-case access is typed.
@@ -247,8 +234,8 @@ type MergedArgs<TLocalArgs, TGlobalArgs> = IsEmpty<TGlobalArgs> extends true ? T
247
234
  * Add the `$source`, `$invocation` and `$agent` run-time metadata helpers.
248
235
  *
249
236
  * `$source` reports whether a given field's final value came from an
250
- * explicit CLI token, a `field.env` fallback, or neither (schema default /
251
- * `prompt` resolution). Its `name` parameter is typed as a plain `string`
237
+ * explicit CLI token, a `field.env` fallback, a `prompt` resolver answer, or
238
+ * none of these (e.g. a schema default). Its `name` parameter is typed as a plain `string`
252
239
  * (not `keyof T`) since the runtime helper deliberately accepts either
253
240
  * camelCase or kebab-case field names (matching `createDualCaseProxy`'s
254
241
  * dual-case access) and returns `"default"` for anything it doesn't
@@ -352,8 +339,6 @@ interface NonRunnableConfig<TArgsSchema extends ArgsSchema$1 | undefined, TGloba
352
339
  */
353
340
  defaultSubCommand?: DefaultSubCommandKey<TSubCommands> | undefined;
354
341
  }
355
- //#endregion
356
- //#region ../core/src/core/runner.d.ts
357
342
  /**
358
343
  * Run a command with the given arguments (programmatic/test usage)
359
344
  *
@@ -410,8 +395,6 @@ export declare function runCommand<TResult = unknown>(command: AnyCommand, argv:
410
395
  * ```
411
396
  */
412
397
  export declare function runMain(command: AnyCommand, options?: MainOptions): Promise<never>;
413
- //#endregion
414
- //#region ../core/src/output/help-generator.d.ts
415
398
  /**
416
399
  * Descriptions for built-in options
417
400
  */
@@ -661,8 +644,6 @@ interface HelpDataOptions {
661
644
  * @returns Structured help data
662
645
  */
663
646
  export declare function generateHelpData(command: AnyCommand, options?: HelpDataOptions): HelpData;
664
- //#endregion
665
- //#region ../core/src/output/logger.d.ts
666
647
  /**
667
648
  * Enable or disable color output programmatically
668
649
  */
@@ -746,8 +727,6 @@ export declare const logger: {
746
727
  */
747
728
  debug(message: string): void;
748
729
  };
749
- //#endregion
750
- //#region ../core/src/output/markdown-renderer.d.ts
751
730
  /**
752
731
  * Lightweight Markdown-to-terminal renderer.
753
732
  *
@@ -775,8 +754,6 @@ export declare function renderInline(text: string): string;
775
754
  * - Applies inline formatting within each block
776
755
  */
777
756
  export declare function renderMarkdown(markdown: string): string;
778
- //#endregion
779
- //#region ../core/src/parser/argv-parser.d.ts
780
757
  /**
781
758
  * Parsed arguments result
782
759
  */
@@ -852,14 +829,10 @@ interface ParserOptions {
852
829
  * @returns Parsed arguments
853
830
  */
854
831
  export declare function parseArgv(argv: string[], options?: ParserOptions): ParsedArgv;
855
- //#endregion
856
- //#region ../core/src/validator/args-validator.d.ts
857
832
  /**
858
833
  * Format validation errors for display
859
834
  */
860
835
  export declare function formatValidationErrors(errors: ValidationError[]): string;
861
- //#endregion
862
- //#region ../core/src/validator/validation-errors.d.ts
863
836
  /**
864
837
  * Error thrown when positional argument configuration is invalid
865
838
  */
@@ -914,18 +887,16 @@ export declare class DefaultSubCommandError extends Error {
914
887
  constructor(message: string);
915
888
  }
916
889
  /**
917
- * Error thrown when a global field and a same-named local field have
918
- * different definitions (per `extractFields()`'s type bucket, whether the
919
- * field is positional, and enum values). Only exactly-matching definitions
920
- * are allowed to share a name across global/local schemas — anything else
921
- * is rejected at validation time rather than risking a value from one
922
- * schema silently flowing into the other.
890
+ * Error thrown when a global field and a local field collide: they share a
891
+ * name, or nest into conflicting output positions (`db` against `db.host`).
892
+ * A field name can only be declared in one of the two schemas, even when the
893
+ * definitions are identical: with the name in both, a value (or prompt
894
+ * answer) for it has no single owner. Rejected at validation time rather
895
+ * than letting a value from one schema silently flow into the other.
923
896
  */
924
897
  export declare class FieldTypeConflictError extends Error {
925
898
  constructor(message: string);
926
899
  }
927
- //#endregion
928
- //#region ../core/src/validator/command-validator.d.ts
929
900
  /**
930
901
  * Error detail for command validation
931
902
  */
@@ -1043,14 +1014,14 @@ export declare function validateCaseVariantCollisions(extracted: ExtractedFields
1043
1014
  /**
1044
1015
  * Validate that no cross-schema collisions exist between two schemas
1045
1016
  * (e.g., global args and command args): neither a case-variant collision
1046
- * (same canonical name, different spelling) nor a same-named field with a
1047
- * different definition (same spelling, but the two schemas don't agree on
1048
- * what values are valid).
1017
+ * (same canonical name, different spelling) nor a same-named field (same
1018
+ * spelling, even when the two definitions are identical), nor fields that nest
1019
+ * into conflicting output positions.
1049
1020
  *
1050
1021
  * @param extractedA - Extracted fields from first schema (e.g., global args)
1051
1022
  * @param extractedB - Extracted fields from second schema (e.g., command args)
1052
1023
  * @throws {CaseVariantCollisionError} If cross-schema case-variant collisions are found
1053
- * @throws {FieldTypeConflictError} If a same-named field has a different definition on each schema
1024
+ * @throws {FieldTypeConflictError} If a field with the same name is declared on both schemas, or fields nest into conflicting output positions
1054
1025
  */
1055
1026
  export declare function validateCrossSchemaCollisions(extractedA: ExtractedFields, extractedB: ExtractedFields): void;
1056
1027
  /**
@@ -1087,8 +1058,26 @@ export declare function validateCommand(command: AnyCommand, options?: ValidateC
1087
1058
  * @returns Formatted error message
1088
1059
  */
1089
1060
  export declare function formatCommandValidationErrors(errors: CommandValidationError[]): string;
1090
- //#endregion
1091
- //#region src/index.d.ts
1061
+ /**
1062
+ * Wrap a flat object schema so that its validated output is nested by the
1063
+ * dotted (or prefixed kebab-case / camelCase) keys. Option names, `arg()`
1064
+ * metadata and validation issue paths stay flat.
1065
+ *
1066
+ * @example
1067
+ * ```ts
1068
+ * const args = unflatten(
1069
+ * z.object({
1070
+ * "config.serverPort": arg(z.coerce.number(), { alias: "p" }),
1071
+ * "config.host": z.string().default("localhost"),
1072
+ * }),
1073
+ * );
1074
+ * // --config.serverPort 8080 → { config: { serverPort: 8080, host: "localhost" } }
1075
+ * ```
1076
+ *
1077
+ * @throws TypeError when a key is both a value and a group (`db` and `db.host`)
1078
+ */
1079
+ export declare function unflatten<S extends z.ZodObject>(schema: S): z.ZodPipe<S, z.ZodTransform<Unflatten<z.output<S>>, z.output<S>>>;
1080
+ export declare function unflatten<S extends z.ZodObject, const O extends UnflattenOptions>(schema: S, options: O): z.ZodPipe<S, z.ZodTransform<Unflatten<z.output<S>, O>, z.output<S>>>;
1092
1081
  /**
1093
1082
  * Generate compile-cache bin shims that import the cache helper from
1094
1083
  * `@politty/zod/compile-cache`.
@@ -1107,5 +1096,4 @@ export type ArgsSchema = z.ZodType<Record<string, any>>;
1107
1096
  export declare const defineCommand: DefineCommandFn<ArgsSchema>;
1108
1097
  export declare const createDefineCommand: CreateDefineCommandFn<ArgsSchema>;
1109
1098
  export declare const arg: ArgFn<z.ZodType>;
1110
- //#endregion
1111
- export { type AgentHelp, type AgentHelpContext, type AgentInfo, type AnyCommand, type ArgFn, type ArgMeta, type ArgSource, type BoundDefineCommandFn, type BuiltinOptionDescriptions, type CamelCase, type CleanupContext, type CollectedLogs, type Command, type CommandBase, type CommandContext, type CommandValidationError, type CommandValidationResult, type CompletionDirectiveMask, type CompletionMeta, type CompletionOptions, type CompletionResult, type CompletionType, type CreateDefineCommandFn, type CustomCompletion, type DefineCommandFn, type DynamicCompletionCandidate, type DynamicCompletionContext, type DynamicCompletionResolver, type DynamicCompletionResult, type EffectContext, type Example, type ExpandCandidate, type ExpandCompletion, type ExtractedFields, type GenerateBundledCompletionWorkerOptions, type GenerateBundledCompletionWorkerResult, type GenerateCompileCacheShimOptions, type GenerateCompileCacheShimResult, type GlobalArgs, type GlobalCleanupContext, type GlobalSetupContext, type HelpData, type HelpDataOptions, type HelpFieldData, type HelpOptions, type HelpSubcommandData, type HelpUsageData, type HelpVariantData, type InferSchemaOutput, type KebabCase, type KnownAgentId, type LazyCommand, type LogEntry, type LogLevel, type LogStream, type Logger, type MainOptions, type MergedArgs, type NonRunnableCommand, type PackageRequirement, type ParsedArgv, type ParserOptions, type PromptMeta, type PromptResolver, type PromptType, type ResolvedExpandCandidate, type ResolvedFieldMeta, type RunCommandOptions, type RunInvocation, type RunResult, type RunResultFailure, type RunResultSuccess, type RunnableCommand, type SchemaLike, type SetupContext, type SubCommandValue, type SubCommandsRecord, type UnknownKeysMode, type UnknownSubcommandHandler, type ValidateArgMeta, type ValidationError, type ValidationResult, type WithCaseVariants, type WithCompletionOptions, isLazyCommand, lazy, loadPackage, toCamelCase, toKebabCase, withCompletionCommand };
1099
+ export { type AgentHelp, type AgentHelpContext, type AgentInfo, type AnyCommand, type ArgFn, type ArgMeta, type ArgSource, type BoundDefineCommandFn, type BuiltinOptionDescriptions, type CamelCase, type CleanupContext, type CollectedLogs, type Command, type CommandBase, type CommandContext, type CommandValidationError, type CommandValidationResult, type CompletionDirectiveMask, type CompletionMeta, type CompletionOptions, type CompletionResult, type CompletionType, type CreateDefineCommandFn, type CustomCompletion, type DefineCommandFn, type DynamicCompletionCandidate, type DynamicCompletionContext, type DynamicCompletionResolver, type DynamicCompletionResult, type EffectContext, type Example, type ExpandCandidate, type ExpandCompletion, type ExtractedFields, type GenerateBundledCompletionWorkerOptions, type GenerateBundledCompletionWorkerResult, type GenerateCompileCacheShimOptions, type GenerateCompileCacheShimResult, type GlobalArgs, type GlobalCleanupContext, type GlobalSetupContext, type HelpData, type HelpDataOptions, type HelpFieldData, type HelpOptions, type HelpSubcommandData, type HelpUsageData, type HelpVariantData, type InferSchemaOutput, type KebabCase, type KnownAgentId, type LazyCommand, type LogEntry, type LogLevel, type LogStream, type Logger, type MainOptions, type MergedArgs, type NonRunnableCommand, type PackageRequirement, type ParsedArgv, type ParserOptions, type PromptChoices, type PromptChoicesContext, type PromptChoicesResolver, type PromptMeta, type PromptResolver, type PromptResolverContext, type PromptType, type ResolvedExpandCandidate, type ResolvedFieldMeta, type RunCommandOptions, type RunInvocation, type RunResult, type RunResultFailure, type RunResultSuccess, type RunnableCommand, type SchemaLike, type SetupContext, type SubCommandValue, type SubCommandsRecord, type UnknownKeysMode, type UnknownSubcommandHandler, type ValidateArgMeta, type ValidationError, type ValidationResult, type WithCaseVariants, type WithCompletionOptions, isLazyCommand, lazy, loadPackage, toCamelCase, toKebabCase, withCompletionCommand };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as e,i as t}from"./field-meta-CEtC5Mir.js";import{t as n}from"./register-w1jLVF3B.js";import{i as r,n as i}from"./schema-extractor-lB6-WHOF.js";import{n as a,t as o}from"./cli-main-DblimvdD.js";import{n as s,t as c}from"./command-BXsTrIgI.js";import{d as l,o as u,s as d}from"./subcommand-router-40vA6Mka.js";import{C as f,D as p,E as m,O as h,S as g,T as _,_ as v,a as y,b,c as x,d as S,f as C,g as w,h as T,i as E,l as D,m as O,n as k,o as A,p as j,r as M,s as N,t as P,u as F,v as I,w as L,x as R,y as z}from"./runner-BsHTbOwS.js";import{a as B,i as V,n as H,r as U,t as W}from"./logger-CoeDrmRr.js";import{a as G}from"./argv-parser-BzWc9lXh.js";import{t as K}from"./with-completion-command-CI1rxHay.js";const q=a(`@politty/zod`),J=s,Y=c,X=n;export{w as CaseVariantCollisionError,v as DefaultSubCommandError,I as DuplicateAliasError,z as DuplicateFieldError,b as DuplicateNegationError,R as FieldTypeConflictError,g as PositionalConfigError,f as ReservedAliasError,L as ReservedFieldNameError,X as arg,a as createCompileCacheShimGenerator,Y as createDefineCommand,M as createDualCaseProxy,J as defineCommand,i as extractFields,y as formatCommandValidationErrors,E as formatValidationErrors,q as generateCompileCacheShim,_ as generateHelp,m as generateHelpData,r as getUnknownKeysMode,W as isColorEnabled,u as isLazyCommand,d as lazy,l as loadPackage,H as logger,G as parseArgv,p as renderInline,h as renderMarkdown,P as runCommand,k as runMain,o as runPolittyCli,U as setColorEnabled,V as styles,B as symbols,t as toCamelCase,e as toKebabCase,A as validateCaseVariantCollisions,N as validateCommand,x as validateCrossSchemaCollisions,D as validateDefaultSubCommand,F as validateDuplicateAliases,S as validateDuplicateFields,C as validateDuplicateNegations,j as validatePositionalConfig,O as validateReservedAliases,T as validateReservedFieldNames,K as withCompletionCommand};
1
+ import{a as e,c as t,f as n,o as r,p as i,t as a}from"./unflatten-D6YJ7e-J.js";import{t as o}from"./register-BIQ84gFS.js";import{i as s,n as c}from"./schema-extractor-DL8vjWso.js";import{n as l,t as u}from"./cli-main-qfjIxAaA.js";import{n as d,t as f}from"./command-BXsTrIgI.js";import{d as p,o as m,s as h}from"./subcommand-router-40vA6Mka.js";import{C as g,D as _,E as v,O as y,S as b,T as x,_ as S,a as C,b as w,c as T,d as E,f as D,g as O,h as k,i as A,l as j,m as M,n as ee,o as N,p as P,r as F,s as I,t as L,u as R,v as z,w as B,x as V,y as H}from"./runner-BxFyJbWK.js";import{a as U,i as W,n as G,r as K,t as q}from"./logger-CoeDrmRr.js";import{a as J}from"./argv-parser-BEwhz0XV.js";import{t as Y}from"./with-completion-command-DSqob4X0.js";import{z as X}from"zod";function Z(n,i={}){let o=e(i);a(Object.keys(n.shape),i);let s=n.transform((e,n)=>{let r=t(e,o);if(!r.issues)return r.value;for(let t of r.issues)n.issues.push({code:`custom`,input:e,message:t.message,path:t.path});return X.NEVER});return r(s,i)}const Q=l(`@politty/zod`),$=d,te=f,ne=o;export{O as CaseVariantCollisionError,S as DefaultSubCommandError,z as DuplicateAliasError,H as DuplicateFieldError,w as DuplicateNegationError,V as FieldTypeConflictError,b as PositionalConfigError,g as ReservedAliasError,B as ReservedFieldNameError,ne as arg,l as createCompileCacheShimGenerator,te as createDefineCommand,F as createDualCaseProxy,$ as defineCommand,c as extractFields,C as formatCommandValidationErrors,A as formatValidationErrors,Q as generateCompileCacheShim,x as generateHelp,v as generateHelpData,s as getUnknownKeysMode,q as isColorEnabled,m as isLazyCommand,h as lazy,p as loadPackage,G as logger,J as parseArgv,_ as renderInline,y as renderMarkdown,L as runCommand,ee as runMain,u as runPolittyCli,K as setColorEnabled,W as styles,U as symbols,n as toCamelCase,i as toKebabCase,Z as unflatten,N as validateCaseVariantCollisions,I as validateCommand,T as validateCrossSchemaCollisions,j as validateDefaultSubCommand,R as validateDuplicateAliases,E as validateDuplicateFields,D as validateDuplicateNegations,P as validatePositionalConfig,M as validateReservedAliases,k as validateReservedFieldNames,Y as withCompletionCommand};
@@ -0,0 +1 @@
1
+ import{u as e}from"./schema-extractor-DL8vjWso.js";function t(e){let t=e.prompt;if(!t||t.enabled===!1)return null;let n=t.message??e.description??e.name,a=r(e,t),o=i(e,t,a);return{field:e,type:a===`select`&&!o&&typeof t.choices!=`function`?`text`:a,message:n,...o&&{choices:o}}}function n(e){return e!==void 0&&e.length>0}function r(e,t){return t.type?t.type===`file`||t.type===`directory`?`text`:t.type:typeof t.choices==`function`||n(t.choices)?`select`:e.completion?.type===`file`||e.completion?.type===`directory`?`text`:n(e.enumValues)?`select`:e.type===`boolean`?`confirm`:`text`}function i(e,t,r){if(typeof t.choices!=`function`){if(n(t.choices))return t.choices.map(e=>typeof e==`string`?{label:e,value:e}:e);if(r===`select`&&n(e.enumValues))return e.enumValues.map(e=>({label:e,value:e}))}}function a(e,n){let r=[];for(let i of e){if(n[i.name]!==void 0||i.type===`array`)continue;let e=t(i);e&&r.push(e)}return r}function o(){return!(!process.stdin.isTTY||!process.stdout.isTTY||process.env.CI||process.env.POLITTY_NO_PROMPT)}async function s(e,t,n){if(!(n.interactive??o()))return e;let r=n.adapter,i={...e},a=n.globalArgs===e?i:n.globalArgs??{};return t.schemaType===`discriminatedUnion`&&t.discriminator&&t.variants?await c(r,i,t,a):t.schemaType===`union`||t.schemaType===`xor`||await u(r,i,t.fields,a),i}async function c(n,r,i,a){let{discriminator:o,variants:s}=i;if(!o||!s)return;if(r[o]===void 0){let e=l(i.fields,s,o),c=e?t(e):null;if(c){let e=s.map(e=>e.discriminatorValue).filter(Boolean);e.length>0&&(c.type=`select`,c.choices=e.map(e=>({label:e,value:e}))),await d(n,r,c,a)}}let c=e(i,()=>r);c!==i&&await u(n,r,c.fields.filter(e=>e.name!==o),a)}function l(e,t,n){let r=e.find(e=>e.name===n);if(r?.prompt)return r;for(let e of t){let t=e.fields.find(e=>e.name===n);if(t?.prompt)return t}}async function u(e,t,n,r){let i=a(n,t);for(let n of i)await d(e,t,n,r)}async function d(e,t,n,r){let i=n.field.prompt?.choices;if(n.type===`select`&&!n.choices&&typeof i==`function`){let e;try{e=await i({rawArgs:{...t},globalArgs:{...r}})}catch(e){throw Error(`Failed to resolve prompt choices for "${n.field.name}": ${e instanceof Error?e.message:String(e)}`,{cause:e})}if(!Array.isArray(e)||e.length===0)throw Error(`No prompt choices available for "${n.field.name}"`);n={...n,choices:e.map(e=>{if(typeof e==`string`)return{label:e,value:e};if(typeof e==`object`&&e&&typeof e.label==`string`&&typeof e.value==`string`)return e;throw Error(`Invalid prompt choice for "${n.field.name}"`)})}}let{message:a}=n,o;switch(n.type){case`text`:o=await e.text({message:a,placeholder:n.field.placeholder});break;case`password`:o=await e.password({message:a});break;case`confirm`:o=await e.confirm({message:a});break;case`select`:o=await e.select({message:a,options:n.choices??[]})}if(e.isCancelled(o))throw Error(`Prompt cancelled by user`);t[n.field.name]=o}export{t as i,o as n,a as r,s as t};
@@ -1,5 +1,4 @@
1
- import { R as PromptResolver } from "./arg-registry-v1Fxnqj8.js";
2
- //#region ../core/src/prompt/clack/index.d.ts
1
+ import { V as PromptResolver } from "./arg-registry-SvIkYiSr.js";
3
2
  /**
4
3
  * Prompt resolver backed by @clack/prompts.
5
4
  *
@@ -11,5 +10,4 @@ import { R as PromptResolver } from "./arg-registry-v1Fxnqj8.js";
11
10
  * runMain(cmd, { version: "1.0.0", prompt });
12
11
  * ```
13
12
  */
14
- export declare const prompt: PromptResolver;
15
- //#endregion
13
+ export declare const prompt: PromptResolver;
@@ -1 +1 @@
1
- import"./register-w1jLVF3B.js";import{t as e}from"./prompt-Bs_O6SmK.js";import{confirm as t,isCancel as n,password as r,select as i,text as a}from"@clack/prompts";function o(){return{text:e=>a({message:e.message,...e.placeholder!==void 0&&{placeholder:e.placeholder}}),password:e=>r(e),confirm:e=>t(e),select:e=>i(e),isCancelled:n}}const s=(t,n)=>e(t,n,{adapter:o()});export{s as prompt};
1
+ import"./register-BIQ84gFS.js";import{t as e}from"./prompt-QPFzhQ3p.js";import{confirm as t,isCancel as n,password as r,select as i,text as a}from"@clack/prompts";function o(){return{text:e=>a({message:e.message,...e.placeholder!==void 0&&{placeholder:e.placeholder}}),password:e=>r(e),confirm:e=>t(e),select:e=>i(e),isCancelled:n}}const s=(t,n,r)=>e(t,n,{adapter:o(),...r});export{s as prompt};
@@ -1,5 +1,4 @@
1
- import { R as PromptResolver } from "./arg-registry-v1Fxnqj8.js";
2
- //#region ../core/src/prompt/inquirer/index.d.ts
1
+ import { V as PromptResolver } from "./arg-registry-SvIkYiSr.js";
3
2
  /**
4
3
  * Prompt resolver backed by @inquirer/prompts.
5
4
  *
@@ -11,5 +10,4 @@ import { R as PromptResolver } from "./arg-registry-v1Fxnqj8.js";
11
10
  * runMain(cmd, { version: "1.0.0", prompt });
12
11
  * ```
13
12
  */
14
- export declare const prompt: PromptResolver;
15
- //#endregion
13
+ export declare const prompt: PromptResolver;
@@ -1 +1 @@
1
- import"./register-w1jLVF3B.js";import{t as e}from"./prompt-Bs_O6SmK.js";import{confirm as t,input as n,password as r,select as i}from"@inquirer/prompts";const a=Symbol(`inquirer-cancel`);async function o(e){try{return await e()}catch(e){if(e instanceof Error&&e.name===`ExitPromptError`)return a;throw e}}function s(){return{text:e=>o(()=>n({message:e.message})),password:e=>o(()=>r({message:e.message})),confirm:e=>o(()=>t({message:e.message})),select:e=>o(()=>i({message:e.message,choices:e.options.map(e=>({name:e.label,value:e.value}))})),isCancelled:e=>e===a}}const c=(t,n)=>e(t,n,{adapter:s()});export{c as prompt};
1
+ import"./register-BIQ84gFS.js";import{t as e}from"./prompt-QPFzhQ3p.js";import{confirm as t,input as n,password as r,select as i}from"@inquirer/prompts";const a=Symbol(`inquirer-cancel`);async function o(e){try{return await e()}catch(e){if(e instanceof Error&&e.name===`ExitPromptError`)return a;throw e}}function s(){return{text:e=>o(()=>n({message:e.message})),password:e=>o(()=>r({message:e.message})),confirm:e=>o(()=>t({message:e.message})),select:e=>o(()=>i({message:e.message,choices:e.options.map(e=>({name:e.label,value:e.value}))})),isCancelled:e=>e===a}}const c=(t,n,r)=>e(t,n,{adapter:s(),...r});export{c as prompt};
package/dist/prompt.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { $ as ResolvedFieldMeta, Q as ExtractedFields } from "./arg-registry-v1Fxnqj8.js";
2
- //#region ../core/src/prompt/types.d.ts
1
+ import { H as PromptResolverContext, nt as ExtractedFields, rt as ResolvedFieldMeta } from "./arg-registry-SvIkYiSr.js";
3
2
  /**
4
3
  * Resolved prompt configuration for a single field
5
4
  */
@@ -49,8 +48,6 @@ interface PromptAdapter {
49
48
  /** Check if a prompt result indicates user cancellation */
50
49
  isCancelled(value: unknown): boolean;
51
50
  }
52
- //#endregion
53
- //#region ../core/src/prompt/prompt-resolver.d.ts
54
51
  /**
55
52
  * Resolve prompt configuration for a field.
56
53
  *
@@ -80,19 +77,15 @@ export declare function resolvePromptConfig(field: ResolvedFieldMeta): ResolvedP
80
77
  * default apply silently.
81
78
  */
82
79
  export declare function getFieldsToPrompt(fields: ResolvedFieldMeta[], rawArgs: Record<string, unknown>): ResolvedPromptConfig[];
83
- //#endregion
84
- //#region ../core/src/prompt/tty-detector.d.ts
85
80
  /**
86
81
  * Detect whether the current environment supports interactive prompts.
87
82
  * Returns false in CI, piped input, or non-TTY environments.
88
83
  */
89
84
  export declare function isInteractive(): boolean;
90
- //#endregion
91
- //#region ../core/src/prompt/index.d.ts
92
85
  /**
93
86
  * Options for promptMissingArgs behavior
94
87
  */
95
- export interface PromptOptions {
88
+ export interface PromptOptions extends Partial<PromptResolverContext> {
96
89
  /** Prompt adapter to use for rendering prompts */
97
90
  adapter: PromptAdapter;
98
91
  /** Override interactive detection (force enable/disable prompts) */
@@ -106,5 +99,4 @@ export interface PromptOptions {
106
99
  * Returns rawArgs unchanged in non-interactive environments.
107
100
  */
108
101
  export declare function promptMissingArgs(rawArgs: Record<string, unknown>, extracted: ExtractedFields, options: PromptOptions): Promise<Record<string, unknown>>;
109
- //#endregion
110
102
  export type { PromptAdapter, ResolvedPromptConfig };
package/dist/prompt.js CHANGED
@@ -1 +1 @@
1
- import"./register-w1jLVF3B.js";export{r as getFieldsToPrompt,n as isInteractive,t as promptMissingArgs,i as resolvePromptConfig}from"./prompt-Bs_O6SmK.js";
1
+ import"./register-BIQ84gFS.js";export{r as getFieldsToPrompt,n as isInteractive,t as promptMissingArgs,i as resolvePromptConfig}from"./prompt-QPFzhQ3p.js";
@@ -0,0 +1 @@
1
+ import{d as e,h as t,s as n}from"./unflatten-D6YJ7e-J.js";const r=/* @__PURE__ */ new WeakMap;function i(e,t){return t&&r.set(e,t),e}function a(e){return r.get(e)}function o(e,t=/* @__PURE__ */ new Set){if(t.has(e))return;t.add(e);let n=a(e);if(n)return n;if(typeof e.meta==`function`){let t=e.meta();if(t&&typeof t==`object`)return t}let r=e,i=r.def??r._def;if(i?.argMeta)return i.argMeta;if(i?.meta)return i.meta;let c=s(e);if(c===`optional`||c===`nullable`||c==="default"){let e=i?.innerType;if(e)return o(e,t)}if(c===`pipe`){let e=i?.in??i?.schema;if(e)return o(e,t)}}function s(e){let t=e;return t.def?.type??t._def?.type??t.type}function c(e){let t=l(e),n=(t.def??t._def)?.catchall;if(!n)return`strip`;let r=s(n);return r===`never`?`strict`:r===`unknown`||r===`any`?`passthrough`:`strip`}function l(e){let t=s(e),n=e,r=n.def??n._def;if(t===`optional`||t===`nullable`||t==="default"){let e=r?.innerType;if(e)return l(e)}if(t===`pipe`){let e=r?.in??r?.schema;if(e)return l(e)}return e}function u(e){let t=l(e);if(d(t))return`boolean`;switch(s(t)){case`string`:case`enum`:return`string`;case`number`:case`int`:return`number`;case`boolean`:return`boolean`;case`array`:return`array`;default:return`unknown`}}function d(e){let t=e._zod.values;if(t)return t.size>0&&[...t].every(e=>typeof e==`boolean`);let n=s(e);if(n===`boolean`)return!0;if(n!==`union`)return!1;let r=(e.def??e._def)?.options??[];return r.length>0&&r.every(d)}function f(e){let t=l(e),n=s(t),r=t,i=r.def??r._def;if(n===`enum`){let e=i?.entries;if(e&&typeof e==`object`)return Object.values(e);let t=i?.values;if(Array.isArray(t))return t;let n=r.options;if(Array.isArray(n))return n}if(n===`array`){let e=i?.element;if(e)return f(e)}if(n===`union`){let e=i?.options;if(Array.isArray(e)){let t=[];for(let n of e)if(s(n)===`literal`){let e=n.def??n._def,r=e?.value,i=e?.values,a=r??i?.[0];typeof a==`string`&&t.push(a)}if(t.length===e.length&&t.length>0)return t}}}function p(e){return!e.isOptional()}function m(e){let t=s(e),n=e,r=n.def??n._def;if(t==="default"){let e=r?.defaultValue;return typeof e==`function`?e():e}if(t===`optional`||t===`nullable`){let e=r?.innerType;if(e)return m(e)}if(t===`pipe`){let e=r?.in??r?.schema;if(e)return m(e)}}function h(e){if(e.description)return e.description;let t=s(e),n=e,r=n.def??n._def;if(t===`optional`||t===`nullable`||t==="default"){let e=r?.innerType;if(e)return h(e)}if(t===`pipe`){let e=r?.in??r?.schema;if(e)return h(e)}}function g(t,n){let r=o(n);return e(t,{argMeta:r,description:h(n),required:p(n),defaultValue:m(n),type:u(n),enumValues:f(n),schema:n})}function _(e){let t=e;return(t.def??t._def)?.shape??t.shape??{}}function v(e){let t=_(e);return Object.entries(t).map(([e,t])=>g(e,t))}function y(e){let t=e,r=t.def??t._def,i=r?.discriminator??``,a=r?.options??[],o=/* @__PURE__ */ new Map,l=[];for(let e of a){n(e);let t=_(e),r=[],a=``,c=t[i];if(c){let e=s(c);if(e===`literal`){let e=c.def??c._def,t=e?.value,n=e?.values;a=String(t??n?.[0]??``)}else if(e===`enum`){let e=f(c);e&&e.length===1&&(a=e[0])}}for(let[e,n]of Object.entries(t)){let t=g(e,n);r.push(t),o.has(e)||o.set(e,t)}let u=h(e);l.push({discriminatorValue:a,fields:r,...u?{description:u}:{}})}let u=h(e);return{fields:Array.from(o.values()),schema:e,schemaType:`discriminatedUnion`,unknownKeysMode:c(e),discriminator:i,variants:l,...u?{description:u}:{}}}function b(e,t){let n=e,r=(n.def??n._def)?.options??[],i=/* @__PURE__ */ new Map,a=[];for(let e of r){let t=C(e);a.push(t);for(let e of t.fields)i.has(e.name)||i.set(e.name,e)}let o=h(e);return{fields:Array.from(i.values()),schema:e,schemaType:t,unknownKeysMode:c(e),unionOptions:a,...o?{description:o}:{}}}function x(e){let t=e,n=t.def??t._def,r=n?.left,i=n?.right,a=/* @__PURE__ */ new Map,o=e=>{if(!e)return;let t=C(e);for(let e of t.fields)a.has(e.name)||a.set(e.name,e)};o(r),o(i);let s=h(e);return{fields:Array.from(a.values()),schema:e,schemaType:`intersection`,unknownKeysMode:c(e),...s?{description:s}:{}}}const S=/* @__PURE__ */ new WeakMap;function C(e){let t=S.get(e);if(t)return t;let n=e,r,i=s(n),a=n,o=a.def??a._def;switch(i){case`object`:{let t=h(n);r={fields:v(n),schema:e,schemaType:`object`,unknownKeysMode:c(n),...t?{description:t}:{}};break}case`union`:r=o?.discriminator?y(n):b(n,`union`);break;case`xor`:r=b(n,`xor`);break;case`intersection`:r=x(n);break;case`optional`:case`nullable`:case`default`:case`pipe`:{let t=o?.innerType??o?.in??o?.schema;if(t){let i=C(t),a=h(n);r={...i,schema:e,...a?{description:a}:{}};break}let i=h(n);r={fields:[],schema:e,schemaType:`object`,unknownKeysMode:c(n),...i?{description:i}:{}};break}default:{let t=h(n);r={fields:[],schema:e,schemaType:`object`,unknownKeysMode:c(n),...t?{description:t}:{}};break}}return S.set(e,r),r}function w(e){return e.issues.map(e=>({path:e.path.map(String),message:e.message,code:e.code,received:`received`in e?e.received:void 0,expected:`expected`in e?String(e.expected):void 0}))}function T(e,t){let n=t.safeParse(e);return n.success?{success:!0,data:n.data}:{success:!1,errors:w(n.error)}}t({vendor:`zod`,extractFields:C,resolveFieldMeta:(e,t)=>g(e,t),getUnknownKeysMode:e=>c(e),validate:T});export{i as t};
@@ -0,0 +1 @@
1
+ export{t as runCommand}from"./runner-BxFyJbWK.js";