@politty/zod 0.1.0 → 0.1.2

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 (34) hide show
  1. package/dist/{arg-registry-B8QvBM_Q.d.ts → arg-registry-Be4GJADw.d.ts} +15 -1
  2. package/dist/augment.d.ts +1 -1
  3. package/dist/{cli-main-Cdz55PLM.js → cli-main-CAa5KwCo.js} +3 -3
  4. package/dist/cli-main-DIRMduj1.js +3 -0
  5. package/dist/cli-run-B--tZW_I.js +8 -0
  6. package/dist/cli.js +1 -1
  7. package/dist/{completion-DW5qVc3l.js → completion-Ot2qpNNw.js} +27 -24
  8. package/dist/completion.d.ts +2 -2
  9. package/dist/completion.js +2 -2
  10. package/dist/docs.d.ts +1 -1
  11. package/dist/docs.js +111 -83
  12. package/dist/{field-meta-DMy5BcRr.js → field-meta-CO38jOvl.js} +12 -10
  13. package/dist/{index-CMb2xLiJ.d.ts → index-B4NylQOW.d.ts} +1 -1
  14. package/dist/index.d.ts +20 -16
  15. package/dist/index.js +7 -7
  16. package/dist/prompt-clack.d.ts +1 -1
  17. package/dist/prompt-clack.js +1 -1
  18. package/dist/prompt-inquirer.d.ts +1 -1
  19. package/dist/prompt-inquirer.js +1 -1
  20. package/dist/prompt.d.ts +1 -1
  21. package/dist/prompt.js +1 -1
  22. package/dist/{register-DlGnMLIY.js → register-DdcsbNwM.js} +1 -1
  23. package/dist/{runner-UEbd9e-3.js → runner-Bz3arOqh.js} +135 -49
  24. package/dist/runner-Cs-Mz9JN.js +3 -0
  25. package/dist/{schema-extractor-DMSozq40.js → schema-extractor-CVNDs07l.js} +1 -1
  26. package/dist/skill.d.ts +1 -1
  27. package/dist/skill.js +8 -6
  28. package/dist/src-D4QGGgW1.js +6 -0
  29. package/dist/{src-zNS0DTqZ.js → src-DhQVU2hG.js} +7 -7
  30. package/package.json +2 -2
  31. package/dist/cli-main-B5mwyz8q.js +0 -3
  32. package/dist/cli-run-BlcK64io.js +0 -8
  33. package/dist/runner-DR5Lw7LX.js +0 -3
  34. package/dist/src-DO4W2NcZ.js +0 -6
@@ -247,6 +247,20 @@ type IsEmpty<T> = keyof T extends never ? true : false;
247
247
  * resolved by a `prompt` handler)
248
248
  */
249
249
  type ArgSource = "cli" | "env" | "default";
250
+ /**
251
+ * Identifies the CLI name a command was invoked with in the current run.
252
+ * - `name`: the literal token typed on the CLI to reach this command
253
+ * (a canonical subcommand name or one of its `aliases`).
254
+ * - `aliasFor`: set only when `name` is an alias, to the canonical
255
+ * subcommand name it resolves to; `undefined` when invoked by its
256
+ * canonical name (or run directly, with no subcommand routing involved).
257
+ */
258
+ interface RunInvocation {
259
+ /** The name or alias actually typed on the CLI to reach this command */
260
+ name: string;
261
+ /** Canonical name `name` is an alias for; undefined when not an alias */
262
+ aliasFor?: string | undefined;
263
+ }
250
264
  /**
251
265
  * Example definition for a command
252
266
  */
@@ -1022,4 +1036,4 @@ interface ArgFn<TSchemaBase extends SchemaLike = SchemaLike> {
1022
1036
  <T extends TSchemaBase, M extends ArgMeta<InferSchemaOutput<T>>>(schema: T, meta: ValidateArgMeta<M, InferSchemaOutput<T>>): T;
1023
1037
  }
1024
1038
  //#endregion
1025
- export { toKebabCase as $, LogEntry as A, RunResultSuccess as B, Command as C, GlobalCleanupContext as D, GlobalArgs as E, NonRunnableCommand as F, UnknownSubcommandHandler as G, SetupContext as H, PromptResolver as I, lazy as J, LazyCommand as K, RunCommandOptions as L, LogStream as M, Logger as N, GlobalSetupContext as O, MainOptions as P, toCamelCase as Q, RunResult as R, CollectedLogs as S, Example as T, SubCommandValue as U, RunnableCommand as V, SubCommandsRecord as W, ResolvedFieldMeta as X, ExtractedFields as Y, UnknownKeysMode as Z, DynamicCompletionResult as _, CustomCompletion as a, ArgsSchema as b, PromptType as c, ExpandCompletion as d, InferSchemaOutput as et, ResolvedExpandCandidate as f, DynamicCompletionResolver as g, DynamicCompletionContext as h, CompletionType as i, LogLevel as j, IsEmpty as k, ValidateArgMeta as l, DynamicCompletionCandidate as m, ArgMeta as n, EffectContext as o, CompletionDirectiveMask as p, isLazyCommand as q, CompletionMeta as r, PromptMeta as s, ArgFn as t, SchemaLike as tt, ExpandCandidate as u, AnyCommand as v, CommandBase as w, CleanupContext as x, ArgSource as y, RunResultFailure as z };
1039
+ export { toCamelCase as $, LogEntry as A, RunResultFailure as B, Command as C, GlobalCleanupContext as D, GlobalArgs as E, NonRunnableCommand as F, SubCommandsRecord as G, RunnableCommand as H, PromptResolver as I, isLazyCommand as J, UnknownSubcommandHandler as K, RunCommandOptions as L, LogStream as M, Logger as N, GlobalSetupContext as O, MainOptions as P, UnknownKeysMode as Q, RunInvocation as R, CollectedLogs as S, Example as T, SetupContext as U, RunResultSuccess as V, SubCommandValue as W, ExtractedFields as X, lazy as Y, ResolvedFieldMeta as Z, DynamicCompletionResult as _, CustomCompletion as a, ArgsSchema as b, PromptType as c, ExpandCompletion as d, toKebabCase as et, ResolvedExpandCandidate as f, DynamicCompletionResolver as g, DynamicCompletionContext as h, CompletionType as i, LogLevel as j, IsEmpty as k, ValidateArgMeta as l, DynamicCompletionCandidate as m, ArgMeta as n, SchemaLike as nt, EffectContext as o, CompletionDirectiveMask as p, LazyCommand as q, CompletionMeta as r, PromptMeta as s, ArgFn as t, InferSchemaOutput as tt, ExpandCandidate as u, AnyCommand as v, CommandBase as w, CleanupContext as x, ArgSource as y, RunResult as z };
package/dist/augment.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as ArgMeta } from "./arg-registry-B8QvBM_Q.js";
1
+ import { n as ArgMeta } from "./arg-registry-Be4GJADw.js";
2
2
  //#region src/augment.d.ts
3
3
  declare module "zod" {
4
4
  interface ZodTypeDef {
@@ -1,6 +1,6 @@
1
- import { a as internalField, i as internalArgs } from "./schema-extractor-DMSozq40.js";
1
+ import { a as internalField, i as internalArgs } from "./schema-extractor-CVNDs07l.js";
2
2
  import { n as defineCommand } from "./command-k-4yAz4J.js";
3
- import { n as runMain } from "./runner-UEbd9e-3.js";
3
+ import { n as runMain } from "./runner-Bz3arOqh.js";
4
4
  import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
5
5
  import { basename, dirname, extname, isAbsolute, join, relative, resolve } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
@@ -239,7 +239,7 @@ const generateWorkerCommand = defineCommand({
239
239
  description: "Generate and verify a bundled shell completion worker",
240
240
  args: generateWorkerArgsSchema,
241
241
  async run(args) {
242
- const { generateBundledCompletionWorker } = await import("./src-zNS0DTqZ.js");
242
+ const { generateBundledCompletionWorker } = await import("./src-DhQVU2hG.js");
243
243
  await generateBundledCompletionWorker({
244
244
  bin: args.bin,
245
245
  programName: args.program,
@@ -0,0 +1,3 @@
1
+ import { t as runPolittyCli } from "./cli-main-CAa5KwCo.js";
2
+
3
+ export { runPolittyCli };
@@ -0,0 +1,8 @@
1
+ import "./register-DdcsbNwM.js";
2
+
3
+ //#region src/cli-run.ts
4
+ const { runPolittyCli } = await import("./cli-main-DIRMduj1.js");
5
+ await runPolittyCli("@politty/zod");
6
+
7
+ //#endregion
8
+ export { };
package/dist/cli.js CHANGED
@@ -10,7 +10,7 @@ import { n as enableCompileCache } from "./compile-cache-BC65o7MH.js";
10
10
  * before any code runs, so they could never hit a cache enabled here.
11
11
  */
12
12
  enableCompileCache("politty");
13
- await import("./cli-run-BlcK64io.js");
13
+ await import("./cli-run-B--tZW_I.js");
14
14
 
15
15
  //#endregion
16
16
  export { };
@@ -1,5 +1,5 @@
1
- import { r as toCamelCase, t as getAllAliases } from "./field-meta-DMy5BcRr.js";
2
- import { a as internalField, i as internalArgs, t as extractFields } from "./schema-extractor-DMSozq40.js";
1
+ import { r as toCamelCase, t as getAllAliases } from "./field-meta-CO38jOvl.js";
2
+ import { a as internalField, i as internalArgs, t as extractFields } from "./schema-extractor-CVNDs07l.js";
3
3
  import { n as defineCommand } from "./command-k-4yAz4J.js";
4
4
  import { c as resolveSubCommandMeta, i as resolveSubCommandAlias } from "./subcommand-router-Cskpofdk.js";
5
5
  import { existsSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
@@ -185,15 +185,17 @@ function quotedAvailabilityTokens(cliName, aliases, negation, options) {
185
185
  tokens.add(`--${negation}`);
186
186
  if (negation.includes("-")) tokens.add(`--${toCamelCase(negation)}`);
187
187
  }
188
- if (options?.frameOptions) if (options.isGlobal === true) for (const o of options.frameOptions) {
189
- if (o.isGlobal === true) continue;
190
- for (const t of localShadowingTokens(o.cliName, o.alias)) tokens.delete(t);
191
- }
192
- else {
193
- const globalShort = globalShortTokens(options.frameOptions);
194
- if (globalShort.size > 0) {
195
- const localExplicitShort = new Set((aliases ?? []).filter((a) => a.length === 1).map((a) => `-${a}`));
196
- for (const g of globalShort) if (!localExplicitShort.has(g)) tokens.delete(g);
188
+ if (options?.frameOptions) {
189
+ if (options.isGlobal === true) for (const o of options.frameOptions) {
190
+ if (o.isGlobal === true) continue;
191
+ for (const t of localShadowingTokens(o.cliName, o.alias)) tokens.delete(t);
192
+ }
193
+ else {
194
+ const globalShort = globalShortTokens(options.frameOptions);
195
+ if (globalShort.size > 0) {
196
+ const localExplicitShort = new Set((aliases ?? []).filter((a) => a.length === 1).map((a) => `-${a}`));
197
+ for (const g of globalShort) if (!localExplicitShort.has(g)) tokens.delete(g);
198
+ }
197
199
  }
198
200
  }
199
201
  return [...tokens].map((t) => `"${t}"`);
@@ -383,20 +385,21 @@ function parsePreSubGlobals(tokens, globalOptions, globalParsedArgs) {
383
385
  }
384
386
  break;
385
387
  }
386
- if (opt.takesValue) if (hasInlineValue(word)) {
387
- const eqIdx = word.indexOf("=");
388
- writeGlobal(opt, word.slice(eqIdx + 1));
389
- i++;
390
- } else if (i + 1 < tokens.length) {
391
- const next = tokens[i + 1];
392
- if (next.startsWith("-")) {
388
+ if (opt.takesValue) {
389
+ if (hasInlineValue(word)) {
390
+ const eqIdx = word.indexOf("=");
391
+ writeGlobal(opt, word.slice(eqIdx + 1));
393
392
  i++;
394
- continue;
395
- }
396
- writeGlobal(opt, next);
397
- i += 2;
398
- } else break;
399
- else {
393
+ } else if (i + 1 < tokens.length) {
394
+ const next = tokens[i + 1];
395
+ if (next.startsWith("-")) {
396
+ i++;
397
+ continue;
398
+ }
399
+ writeGlobal(opt, next);
400
+ i += 2;
401
+ } else break;
402
+ } else {
400
403
  globalParsedArgs[opt.name] = !isNegationOf(opt, parsed);
401
404
  captured.add(opt.name);
402
405
  i++;
@@ -1,5 +1,5 @@
1
- import { C as Command, X as ResolvedFieldMeta, _ as DynamicCompletionResult, b as ArgsSchema, d as ExpandCompletion, g as DynamicCompletionResolver, h as DynamicCompletionContext, m as DynamicCompletionCandidate, p as CompletionDirectiveMask, v as AnyCommand } from "./arg-registry-B8QvBM_Q.js";
2
- import { C as CompletionResult, D as InternalArgsSchema, E as InferInternalArgs, S as CompletionOptions, T as ValueCompletion, _ as CompletablePositional, a as detectShell, b as CompletionGenerator, c as withCompletionCommand, d as bundledWorkerShellExtension, f as defaultBundledWorkerOutputPath, g as CompletableOption, h as BundledWorkerOptions, i as createRefreshCompletionCommand, l as GenerateBundledCompletionWorkerOptions, m as validateBundledWorkerFile, n as createCompletionCommand, o as generateCompletion, p as generateBundledCompletionWorker, r as createCompletionWorkerPathCommand, s as getSupportedShells, t as WithCompletionOptions, u as GenerateBundledCompletionWorkerResult, v as CompletableSubcommand, w as ShellType, x as CompletionMode, y as CompletionData } from "./index-CMb2xLiJ.js";
1
+ import { C as Command, Z as ResolvedFieldMeta, _ as DynamicCompletionResult, b as ArgsSchema, d as ExpandCompletion, g as DynamicCompletionResolver, h as DynamicCompletionContext, m as DynamicCompletionCandidate, p as CompletionDirectiveMask, v as AnyCommand } from "./arg-registry-Be4GJADw.js";
2
+ import { C as CompletionResult, D as InternalArgsSchema, E as InferInternalArgs, S as CompletionOptions, T as ValueCompletion, _ as CompletablePositional, a as detectShell, b as CompletionGenerator, c as withCompletionCommand, d as bundledWorkerShellExtension, f as defaultBundledWorkerOutputPath, g as CompletableOption, h as BundledWorkerOptions, i as createRefreshCompletionCommand, l as GenerateBundledCompletionWorkerOptions, m as validateBundledWorkerFile, n as createCompletionCommand, o as generateCompletion, p as generateBundledCompletionWorker, r as createCompletionWorkerPathCommand, s as getSupportedShells, t as WithCompletionOptions, u as GenerateBundledCompletionWorkerResult, v as CompletableSubcommand, w as ShellType, x as CompletionMode, y as CompletionData } from "./index-B4NylQOW.js";
3
3
  //#region ../core/src/completion/dynamic/context-parser.d.ts
4
4
  /**
5
5
  * Completion type indicates what kind of completion is expected
@@ -1,4 +1,4 @@
1
- import "./register-DlGnMLIY.js";
2
- import { _ as CompletionDirective, a as generateCompletion, b as resolveValueCompletion, c as createDynamicCompleteCommand, d as bundledWorkerShellExtension, f as defaultBundledWorkerOutputPath, g as extractPositionals, h as extractCompletionData, i as detectShell, l as hasCompleteCommand, m as validateBundledWorkerFile, n as createCompletionWorkerPathCommand, o as getSupportedShells, p as generateBundledCompletionWorker, r as createRefreshCompletionCommand, s as withCompletionCommand, t as createCompletionCommand, u as formatForShell, v as generateCandidates, y as parseCompletionContext } from "./completion-DW5qVc3l.js";
1
+ import "./register-DdcsbNwM.js";
2
+ import { _ as CompletionDirective, a as generateCompletion, b as resolveValueCompletion, c as createDynamicCompleteCommand, d as bundledWorkerShellExtension, f as defaultBundledWorkerOutputPath, g as extractPositionals, h as extractCompletionData, i as detectShell, l as hasCompleteCommand, m as validateBundledWorkerFile, n as createCompletionWorkerPathCommand, o as getSupportedShells, p as generateBundledCompletionWorker, r as createRefreshCompletionCommand, s as withCompletionCommand, t as createCompletionCommand, u as formatForShell, v as generateCandidates, y as parseCompletionContext } from "./completion-Ot2qpNNw.js";
3
3
 
4
4
  export { CompletionDirective, bundledWorkerShellExtension, createCompletionCommand, createCompletionWorkerPathCommand, createDynamicCompleteCommand, createRefreshCompletionCommand, defaultBundledWorkerOutputPath, detectShell, extractCompletionData, extractPositionals, formatForShell, generateBundledCompletionWorker, generateCandidates, generateCompletion, getSupportedShells, hasCompleteCommand, parseCompletionContext, resolveValueCompletion, validateBundledWorkerFile, withCompletionCommand };
package/dist/docs.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { T as Example, U as SubCommandValue, X as ResolvedFieldMeta, Y as ExtractedFields, b as ArgsSchema, tt as SchemaLike, v as AnyCommand } from "./arg-registry-B8QvBM_Q.js";
1
+ import { T as Example, W as SubCommandValue, X as ExtractedFields, Z as ResolvedFieldMeta, b as ArgsSchema, nt as SchemaLike, v as AnyCommand } from "./arg-registry-Be4GJADw.js";
2
2
  import * as fs from "node:fs";
3
3
  //#region ../core/src/executor/subcommand-router.d.ts
4
4
  /**
package/dist/docs.js CHANGED
@@ -1,6 +1,6 @@
1
- import { a as getValidatorAdapter } from "./field-meta-DMy5BcRr.js";
2
- import "./register-DlGnMLIY.js";
3
- import { n as getExtractedFields, t as extractFields } from "./schema-extractor-DMSozq40.js";
1
+ import { a as getValidatorAdapter } from "./field-meta-CO38jOvl.js";
2
+ import "./register-DdcsbNwM.js";
3
+ import { n as getExtractedFields, t as extractFields } from "./schema-extractor-CVNDs07l.js";
4
4
  import { t as createLogCollector } from "./log-collector-CoUkLVJB.js";
5
5
  import { r as resolveLazyCommand } from "./subcommand-router-Cskpofdk.js";
6
6
  import * as fs from "node:fs";
@@ -67,10 +67,19 @@ function toOptionRows(options) {
67
67
  return options.map(toOptionRow);
68
68
  }
69
69
  /**
70
- * Escape markdown special characters in table cells.
70
+ * Convert hard line breaks in a description into `<br>` so they render as line
71
+ * breaks inside a single markdown table cell or list item, instead of breaking
72
+ * the surrounding table row / list structure.
73
+ */
74
+ function inlineMarkdownBreaks(str) {
75
+ return str.replace(/\r?\n/g, "<br>");
76
+ }
77
+ /**
78
+ * Escape markdown special characters in table cells. Embedded line breaks are
79
+ * converted to `<br>` so multi-line descriptions stay within a single cell.
71
80
  */
72
81
  function escapeTableCell$2(str) {
73
- return str.replace(/\|/g, "\\|").replace(/\n/g, " ");
82
+ return inlineMarkdownBreaks(str.replace(/\|/g, "\\|"));
74
83
  }
75
84
  function backtick(value) {
76
85
  return `\`${value}\``;
@@ -195,12 +204,12 @@ function emitMarkdownList(rows) {
195
204
  ...longAliases
196
205
  ].map(backtick).join(", ");
197
206
  if (row.inlineNegation) flags += ` / ${backtick(row.inlineNegation)}`;
198
- const desc = row.description ? ` - ${row.description}` : "";
207
+ const desc = row.description ? ` - ${inlineMarkdownBreaks(row.description)}` : "";
199
208
  const required = row.required ? " (required)" : "";
200
209
  const defaultVal = row.hasDefault ? ` (default: ${JSON.stringify(row.defaultValue)})` : "";
201
210
  const envInfo = formatEnvInfo(row.env);
202
211
  lines.push(`- ${flags}${desc}${required}${defaultVal}${envInfo}`);
203
- if (row.negationRow) lines.push(`- ${backtick(row.negationRow.flag)} - ${row.negationRow.description} ${row.negationRow.relationMarker}`);
212
+ if (row.negationRow) lines.push(`- ${backtick(row.negationRow.flag)} - ${inlineMarkdownBreaks(row.negationRow.description)} ${row.negationRow.relationMarker}`);
204
213
  }
205
214
  return lines.join("\n");
206
215
  }
@@ -306,10 +315,11 @@ function indexEndMarker(scope) {
306
315
  //#endregion
307
316
  //#region ../core/src/docs/default-renderers.ts
308
317
  /**
309
- * Escape markdown special characters in table cells
318
+ * Escape markdown special characters in table cells. Embedded line breaks are
319
+ * converted to `<br>` so multi-line descriptions stay within a single cell.
310
320
  */
311
321
  function escapeTableCell$1(str) {
312
- return str.replace(/\|/g, "\\|").replace(/\n/g, " ");
322
+ return inlineMarkdownBreaks(str.replace(/\|/g, "\\|"));
313
323
  }
314
324
  /**
315
325
  * Render usage line
@@ -317,8 +327,10 @@ function escapeTableCell$1(str) {
317
327
  function renderUsage(info) {
318
328
  const parts = [info.fullCommandPath];
319
329
  if (info.options.length > 0) parts.push("[options]");
320
- if (info.subCommands.length > 0) if (info.command.run) parts.push("[command]");
321
- else parts.push("<command>");
330
+ if (info.subCommands.length > 0) {
331
+ if (info.command.run) parts.push("[command]");
332
+ else parts.push("<command>");
333
+ }
322
334
  for (const arg of info.positionalArgs) if (arg.required) parts.push(`<${arg.name}>`);
323
335
  else parts.push(`[${arg.name}]`);
324
336
  return parts.join(" ");
@@ -346,7 +358,7 @@ function renderArgumentsList(info) {
346
358
  const lines = [];
347
359
  for (const arg of info.positionalArgs) {
348
360
  const required = arg.required ? "(required)" : "(optional)";
349
- const desc = arg.description ? ` - ${arg.description}` : "";
361
+ const desc = arg.description ? ` - ${inlineMarkdownBreaks(arg.description)}` : "";
350
362
  lines.push(`- \`${arg.name}\`${desc} ${required}`);
351
363
  }
352
364
  return lines.join("\n");
@@ -503,7 +515,7 @@ function renderArgumentsListFromArray(args) {
503
515
  const lines = [];
504
516
  for (const arg of args) {
505
517
  const required = arg.required ? "(required)" : "(optional)";
506
- const desc = arg.description ? ` - ${arg.description}` : "";
518
+ const desc = arg.description ? ` - ${inlineMarkdownBreaks(arg.description)}` : "";
507
519
  lines.push(`- \`${arg.name}\`${desc} ${required}`);
508
520
  }
509
521
  return lines.join("\n");
@@ -921,7 +933,7 @@ async function executeSingleExample(example, rootCommand, commandPath) {
921
933
  collector.start();
922
934
  let success = true;
923
935
  try {
924
- const { runCommand } = await import("./runner-DR5Lw7LX.js");
936
+ const { runCommand } = await import("./runner-Cs-Mz9JN.js");
925
937
  const result = await runCommand(rootCommand, argv);
926
938
  success = result.success;
927
939
  if (!result.success && result.error) console.error(result.error.message);
@@ -1822,16 +1834,17 @@ function buildTemplateExclusions(rawKeys, allCommands) {
1822
1834
  const exclusions = createTemplateExclusions(rawKeys);
1823
1835
  for (const key of rawKeys) {
1824
1836
  const parsed = parsePlaceholder(`{{politty:${key}}}`, allCommands);
1825
- if (parsed.kind === "command") if (parsed.type === void 0) exclusions.commandScopes.add(parsed.scope);
1826
- else {
1827
- let sections = exclusions.commandSections.get(parsed.scope);
1828
- if (!sections) {
1829
- sections = /* @__PURE__ */ new Set();
1830
- exclusions.commandSections.set(parsed.scope, sections);
1837
+ if (parsed.kind === "command") {
1838
+ if (parsed.type === void 0) exclusions.commandScopes.add(parsed.scope);
1839
+ else {
1840
+ let sections = exclusions.commandSections.get(parsed.scope);
1841
+ if (!sections) {
1842
+ sections = /* @__PURE__ */ new Set();
1843
+ exclusions.commandSections.set(parsed.scope, sections);
1844
+ }
1845
+ sections.add(parsed.type);
1831
1846
  }
1832
- sections.add(parsed.type);
1833
- }
1834
- else if (parsed.kind === "global-options") exclusions.globalOptions = true;
1847
+ } else if (parsed.kind === "global-options") exclusions.globalOptions = true;
1835
1848
  else if (parsed.kind === "index") exclusions.index = true;
1836
1849
  }
1837
1850
  return exclusions;
@@ -2167,18 +2180,20 @@ async function processGlobalOptionsMarker(existingContent, globalOptionsConfig,
2167
2180
  wasUpdated
2168
2181
  };
2169
2182
  }
2170
- if (existingSection !== generatedSection) if (updateMode) {
2171
- const updated = replaceMarkerSection(content, startMarker, endMarker, generatedSection);
2172
- if (updated) {
2173
- content = updated;
2174
- wasUpdated = true;
2183
+ if (existingSection !== generatedSection) {
2184
+ if (updateMode) {
2185
+ const updated = replaceMarkerSection(content, startMarker, endMarker, generatedSection);
2186
+ if (updated) {
2187
+ content = updated;
2188
+ wasUpdated = true;
2189
+ } else {
2190
+ hasError = true;
2191
+ diffs.push("Failed to replace global options section");
2192
+ }
2175
2193
  } else {
2176
2194
  hasError = true;
2177
- diffs.push("Failed to replace global options section");
2195
+ diffs.push(formatDiff(existingSection, generatedSection));
2178
2196
  }
2179
- } else {
2180
- hasError = true;
2181
- diffs.push(formatDiff(existingSection, generatedSection));
2182
2197
  }
2183
2198
  return {
2184
2199
  content,
@@ -2222,18 +2237,20 @@ async function processStaticMarker(existingContent, markerLabel, startMarker, en
2222
2237
  wasUpdated
2223
2238
  };
2224
2239
  }
2225
- if (existingSection !== generatedSection) if (updateMode) {
2226
- const updated = replaceMarkerSection(content, startMarker, endMarker, generatedSection);
2227
- if (updated) {
2228
- content = updated;
2229
- wasUpdated = true;
2240
+ if (existingSection !== generatedSection) {
2241
+ if (updateMode) {
2242
+ const updated = replaceMarkerSection(content, startMarker, endMarker, generatedSection);
2243
+ if (updated) {
2244
+ content = updated;
2245
+ wasUpdated = true;
2246
+ } else {
2247
+ hasError = true;
2248
+ diffs.push(`Failed to replace ${markerLabel} section`);
2249
+ }
2230
2250
  } else {
2231
2251
  hasError = true;
2232
- diffs.push(`Failed to replace ${markerLabel} section`);
2252
+ diffs.push(formatDiff(existingSection, generatedSection));
2233
2253
  }
2234
- } else {
2235
- hasError = true;
2236
- diffs.push(formatDiff(existingSection, generatedSection));
2237
2254
  }
2238
2255
  return {
2239
2256
  content,
@@ -2284,18 +2301,20 @@ async function processIndexMarker(existingContent, categories, command, scope, u
2284
2301
  };
2285
2302
  }
2286
2303
  const generatedSection = await applyFormatter(await generateIndexSection(categories, command, scope, indexOptions), formatter);
2287
- if (existingSection !== generatedSection) if (updateMode) {
2288
- const updated = replaceMarkerSection(content, startMarker, endMarker, generatedSection);
2289
- if (updated) {
2290
- content = updated;
2291
- wasUpdated = true;
2304
+ if (existingSection !== generatedSection) {
2305
+ if (updateMode) {
2306
+ const updated = replaceMarkerSection(content, startMarker, endMarker, generatedSection);
2307
+ if (updated) {
2308
+ content = updated;
2309
+ wasUpdated = true;
2310
+ } else {
2311
+ hasError = true;
2312
+ diffs.push("Failed to replace index section");
2313
+ }
2292
2314
  } else {
2293
2315
  hasError = true;
2294
- diffs.push("Failed to replace index section");
2316
+ diffs.push(formatDiff(existingSection, generatedSection));
2295
2317
  }
2296
- } else {
2297
- hasError = true;
2298
- diffs.push(formatDiff(existingSection, generatedSection));
2299
2318
  }
2300
2319
  return {
2301
2320
  content,
@@ -2502,10 +2521,12 @@ async function generateDoc(config) {
2502
2521
  const hasTargetCommands = targetCommands !== void 0 && targetCommands.length > 0;
2503
2522
  const globalOptionDefinitions = collectGlobalOptionDefinitions(rootDoc);
2504
2523
  const templateGlobalOptionFields = /* @__PURE__ */ new Map();
2505
- if (config.templates) if (globalOptionDefinitions.size > 0) for (const [name, field] of globalOptionDefinitions) templateGlobalOptionFields.set(name, field);
2506
- else {
2507
- const shape = deriveGlobalArgsShape(globalArgs);
2508
- if (shape) for (const field of collectRenderableGlobalOptionFields(shape)) templateGlobalOptionFields.set(field.name, field);
2524
+ if (config.templates) {
2525
+ if (globalOptionDefinitions.size > 0) for (const [name, field] of globalOptionDefinitions) templateGlobalOptionFields.set(name, field);
2526
+ else {
2527
+ const shape = deriveGlobalArgsShape(globalArgs);
2528
+ if (shape) for (const field of collectRenderableGlobalOptionFields(shape)) templateGlobalOptionFields.set(field.name, field);
2529
+ }
2509
2530
  }
2510
2531
  const documentedCommandPaths = hasTargetCommands ? collectTargetDocumentedCommandPaths(targetCommands, files, allCommands, ignores) : collectDocumentedCommandPaths(files, allCommands, ignores);
2511
2532
  const allFilesCommands = [];
@@ -2730,30 +2751,34 @@ async function generateDoc(config) {
2730
2751
  if (!existingSection) continue;
2731
2752
  if (!generatedSectionPart) {
2732
2753
  const emptyMarker = sectionStartMarker(sectionType, targetCommand) + "\n" + sectionEndMarker(sectionType, targetCommand);
2733
- if (existingSection !== emptyMarker) if (updateMode) {
2734
- const updated = replaceSectionMarker(existingContent, sectionType, targetCommand, emptyMarker);
2735
- if (!updated) throw new Error(`Failed to replace stale ${sectionType} section for command "${targetCommand}"`);
2736
- existingContent = updated.replace(/\n{3,}/g, "\n\n");
2737
- writeFile(filePath, existingContent);
2738
- if (fileStatus !== "created") fileStatus = "updated";
2754
+ if (existingSection !== emptyMarker) {
2755
+ if (updateMode) {
2756
+ const updated = replaceSectionMarker(existingContent, sectionType, targetCommand, emptyMarker);
2757
+ if (!updated) throw new Error(`Failed to replace stale ${sectionType} section for command "${targetCommand}"`);
2758
+ existingContent = updated.replace(/\n{3,}/g, "\n\n");
2759
+ writeFile(filePath, existingContent);
2760
+ if (fileStatus !== "created") fileStatus = "updated";
2761
+ } else {
2762
+ hasError = true;
2763
+ fileStatus = "diff";
2764
+ diffs.push(formatDiff(existingSection, emptyMarker));
2765
+ }
2766
+ }
2767
+ continue;
2768
+ }
2769
+ if (existingSection !== generatedSectionPart) {
2770
+ if (updateMode) {
2771
+ const updated = replaceSectionMarker(existingContent, sectionType, targetCommand, generatedSectionPart);
2772
+ if (updated) {
2773
+ existingContent = updated;
2774
+ writeFile(filePath, existingContent);
2775
+ if (fileStatus !== "created") fileStatus = "updated";
2776
+ } else throw new Error(`Failed to replace ${sectionType} section for command "${targetCommand}"`);
2739
2777
  } else {
2740
2778
  hasError = true;
2741
2779
  fileStatus = "diff";
2742
- diffs.push(formatDiff(existingSection, emptyMarker));
2780
+ diffs.push(formatDiff(existingSection, generatedSectionPart));
2743
2781
  }
2744
- continue;
2745
- }
2746
- if (existingSection !== generatedSectionPart) if (updateMode) {
2747
- const updated = replaceSectionMarker(existingContent, sectionType, targetCommand, generatedSectionPart);
2748
- if (updated) {
2749
- existingContent = updated;
2750
- writeFile(filePath, existingContent);
2751
- if (fileStatus !== "created") fileStatus = "updated";
2752
- } else throw new Error(`Failed to replace ${sectionType} section for command "${targetCommand}"`);
2753
- } else {
2754
- hasError = true;
2755
- fileStatus = "diff";
2756
- diffs.push(formatDiff(existingSection, generatedSectionPart));
2757
2782
  }
2758
2783
  }
2759
2784
  if (doctorMode || customizable) {
@@ -2879,9 +2904,10 @@ async function generateDoc(config) {
2879
2904
  const extracted = extractSectionMarker(rawSection, type, scope);
2880
2905
  replacements.set(placeholder, extracted === null ? "" : stripPolittyMarkers(extracted));
2881
2906
  }
2882
- } else if (parsed.kind === "global-options") if (normalizedTemplateGlobalOptions) replacements.set(placeholder, buildGlobalOptionsContent(normalizedTemplateGlobalOptions));
2883
- else replacements.set(placeholder, "");
2884
- else if (parsed.kind === "index") {
2907
+ } else if (parsed.kind === "global-options") {
2908
+ if (normalizedTemplateGlobalOptions) replacements.set(placeholder, buildGlobalOptionsContent(normalizedTemplateGlobalOptions));
2909
+ else replacements.set(placeholder, "");
2910
+ } else if (parsed.kind === "index") {
2885
2911
  const categories = [...deriveIndexFromFiles(files, outputPath, allCommands, ignores), ...deriveIndexFromTemplateOutputs(templateMeta, outputPath, outputPath, allCommands)];
2886
2912
  const indexContent = await renderCommandIndex(command, categories, rootDoc?.index);
2887
2913
  replacements.set(placeholder, indexContent);
@@ -2952,12 +2978,14 @@ async function generateDoc(config) {
2952
2978
  }
2953
2979
  if (!usingPathConfig) {
2954
2980
  const unexpectedSectionPaths = collectSectionMarkerPaths(content);
2955
- if (unexpectedSectionPaths.length > 0) if (updateMode) {
2956
- for (const commandPath of unexpectedSectionPaths) content = removeCommandSections(content, commandPath);
2957
- markerUpdated = true;
2958
- } else {
2959
- hasError = true;
2960
- rootDocDiffs.push(`Found unexpected section markers in rootDoc: ${unexpectedSectionPaths.map((commandPath) => `"${formatCommandPath(commandPath)}"`).join(", ")}.`);
2981
+ if (unexpectedSectionPaths.length > 0) {
2982
+ if (updateMode) {
2983
+ for (const commandPath of unexpectedSectionPaths) content = removeCommandSections(content, commandPath);
2984
+ markerUpdated = true;
2985
+ } else {
2986
+ hasError = true;
2987
+ rootDocDiffs.push(`Found unexpected section markers in rootDoc: ${unexpectedSectionPaths.map((commandPath) => `"${formatCommandPath(commandPath)}"`).join(", ")}.`);
2988
+ }
2961
2989
  }
2962
2990
  }
2963
2991
  const normalizedGlobalOptions = normalizeGlobalOptions(rootDoc.globalOptions);
@@ -95,16 +95,18 @@ function resolveFieldMeta(name, intro) {
95
95
  const fieldType = intro.type;
96
96
  const rawNegation = argMeta?.negation;
97
97
  let negation;
98
- if (rawNegation !== void 0 && rawNegation !== null) if (typeof rawNegation === "boolean") {
99
- if (fieldType !== "boolean") throw new Error(`Invalid negation for field "${name}": negation can only be used on boolean fields.`);
100
- negation = rawNegation;
101
- } else {
102
- if (typeof rawNegation !== "string") throw new Error(`Invalid negation for field "${name}": expected string or boolean, received ${typeof rawNegation}.`);
103
- const candidate = rawNegation.trim().replace(/^-+/, "");
104
- if (candidate.length === 0 || !aliasPattern.test(candidate)) throw new Error(`Invalid negation "${rawNegation}" for field "${name}": negation names must match ${aliasPattern}.`);
105
- if (RESERVED_NEGATION_NAMES.has(candidate)) throw new Error(`Invalid negation "${rawNegation}" for field "${name}": negation cannot use reserved built-in flag names (${[...RESERVED_NEGATION_NAMES].map((n) => `--${n}`).join(", ")}).`);
106
- if (fieldType !== "boolean") throw new Error(`Invalid negation for field "${name}": negation can only be used on boolean fields.`);
107
- negation = candidate;
98
+ if (rawNegation !== void 0 && rawNegation !== null) {
99
+ if (typeof rawNegation === "boolean") {
100
+ if (fieldType !== "boolean") throw new Error(`Invalid negation for field "${name}": negation can only be used on boolean fields.`);
101
+ negation = rawNegation;
102
+ } else {
103
+ if (typeof rawNegation !== "string") throw new Error(`Invalid negation for field "${name}": expected string or boolean, received ${typeof rawNegation}.`);
104
+ const candidate = rawNegation.trim().replace(/^-+/, "");
105
+ if (candidate.length === 0 || !aliasPattern.test(candidate)) throw new Error(`Invalid negation "${rawNegation}" for field "${name}": negation names must match ${aliasPattern}.`);
106
+ if (RESERVED_NEGATION_NAMES.has(candidate)) throw new Error(`Invalid negation "${rawNegation}" for field "${name}": negation cannot use reserved built-in flag names (${[...RESERVED_NEGATION_NAMES].map((n) => `--${n}`).join(", ")}).`);
107
+ if (fieldType !== "boolean") throw new Error(`Invalid negation for field "${name}": negation can only be used on boolean fields.`);
108
+ negation = candidate;
109
+ }
108
110
  }
109
111
  const rawNegationDescription = argMeta?.negationDescription;
110
112
  let negationDescription;
@@ -1,4 +1,4 @@
1
- import { C as Command, Z as UnknownKeysMode, b as ArgsSchema, f as ResolvedExpandCandidate, g as DynamicCompletionResolver, n as ArgMeta, v as AnyCommand } from "./arg-registry-B8QvBM_Q.js";
1
+ import { C as Command, Q as UnknownKeysMode, b as ArgsSchema, f as ResolvedExpandCandidate, g as DynamicCompletionResolver, n as ArgMeta, v as AnyCommand } from "./arg-registry-Be4GJADw.js";
2
2
  //#region ../core/src/adapter/internal-args.d.ts
3
3
  /** Runtime brand distinguishing internal descriptors from library schemas. */
4
4
  declare const INTERNAL_ARGS_BRAND = "__polittyInternalArgs";
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { $ as toKebabCase, A as LogEntry, B as RunResultSuccess, C as Command, D as GlobalCleanupContext, E as GlobalArgs, F as NonRunnableCommand, G as UnknownSubcommandHandler, H as SetupContext, I as PromptResolver, J as lazy, K as LazyCommand, L as RunCommandOptions, M as LogStream, N as Logger, O as GlobalSetupContext, P as MainOptions, Q as toCamelCase, R as RunResult, S as CollectedLogs, T as Example, U as SubCommandValue, V as RunnableCommand, W as SubCommandsRecord, X as ResolvedFieldMeta, Y as ExtractedFields, Z as UnknownKeysMode, _ as DynamicCompletionResult, a as CustomCompletion, b as ArgsSchema$1, c as PromptType, d as ExpandCompletion, et as InferSchemaOutput, f as ResolvedExpandCandidate, g as DynamicCompletionResolver, h as DynamicCompletionContext, i as CompletionType, j as LogLevel, k as IsEmpty, l as ValidateArgMeta, m as DynamicCompletionCandidate, n as ArgMeta, o as EffectContext, p as CompletionDirectiveMask, q as isLazyCommand, r as CompletionMeta, s as PromptMeta, t as ArgFn, tt as SchemaLike, u as ExpandCandidate, v as AnyCommand, w as CommandBase, x as CleanupContext, y as ArgSource, z as RunResultFailure } from "./arg-registry-B8QvBM_Q.js";
2
- import { C as CompletionResult, D as InternalArgsSchema, S as CompletionOptions, c as withCompletionCommand, l as GenerateBundledCompletionWorkerOptions, o as generateCompletion, p as generateBundledCompletionWorker, t as WithCompletionOptions, u as GenerateBundledCompletionWorkerResult } from "./index-CMb2xLiJ.js";
1
+ import { $ as toCamelCase, A as LogEntry, B as RunResultFailure, C as Command, D as GlobalCleanupContext, E as GlobalArgs, F as NonRunnableCommand, G as SubCommandsRecord, H as RunnableCommand, I as PromptResolver, J as isLazyCommand, K as UnknownSubcommandHandler, L as RunCommandOptions, M as LogStream, N as Logger, O as GlobalSetupContext, P as MainOptions, Q as UnknownKeysMode, R as RunInvocation, S as CollectedLogs, T as Example, U as SetupContext, V as RunResultSuccess, W as SubCommandValue, X as ExtractedFields, Y as lazy, Z as ResolvedFieldMeta, _ as DynamicCompletionResult, a as CustomCompletion, b as ArgsSchema$1, c as PromptType, d as ExpandCompletion, et as toKebabCase, f as ResolvedExpandCandidate, g as DynamicCompletionResolver, h as DynamicCompletionContext, i as CompletionType, j as LogLevel, k as IsEmpty, l as ValidateArgMeta, m as DynamicCompletionCandidate, n as ArgMeta, nt as SchemaLike, o as EffectContext, p as CompletionDirectiveMask, q as LazyCommand, r as CompletionMeta, s as PromptMeta, t as ArgFn, tt as InferSchemaOutput, u as ExpandCandidate, v as AnyCommand, w as CommandBase, x as CleanupContext, y as ArgSource, z as RunResult } from "./arg-registry-Be4GJADw.js";
2
+ import { C as CompletionResult, D as InternalArgsSchema, S as CompletionOptions, c as withCompletionCommand, l as GenerateBundledCompletionWorkerOptions, o as generateCompletion, p as generateBundledCompletionWorker, t as WithCompletionOptions, u as GenerateBundledCompletionWorkerResult } from "./index-B4NylQOW.js";
3
3
  import { z } from "zod";
4
4
  //#region ../core/src/core/schema-extractor.d.ts
5
5
  /**
@@ -243,25 +243,29 @@ type InferArgs<TArgsSchema> = TArgsSchema extends InternalArgsSchema<infer TInte
243
243
  */
244
244
  type MergedArgs<TLocalArgs, TGlobalArgs> = IsEmpty<TGlobalArgs> extends true ? TLocalArgs : TLocalArgs & WithCaseVariants<TGlobalArgs>;
245
245
  /**
246
- * Add the `$source` helper, which reports whether a given field's final
247
- * value came from an explicit CLI token, a `field.env` fallback, or
248
- * neither (schema default / `prompt` resolution).
246
+ * Add the `$source` and `$invocation` run-time metadata helpers.
249
247
  *
250
- * `name` is typed as a plain `string` (not `keyof T`) since the runtime
251
- * helper deliberately accepts either camelCase or kebab-case field names
252
- * (matching `createDualCaseProxy`'s dual-case access) and returns
253
- * `"default"` for anything it doesn't recognize. A `keyof T`-based type
254
- * would also be unsound for discriminated-union `args` schemas, where
255
- * narrowing `args` to one branch doesn't retroactively narrow `$source`'s
256
- * already-fixed parameter type.
248
+ * `$source` reports whether a given field's final value came from an
249
+ * explicit CLI token, a `field.env` fallback, or neither (schema default /
250
+ * `prompt` resolution). Its `name` parameter is typed as a plain `string`
251
+ * (not `keyof T`) since the runtime helper deliberately accepts either
252
+ * camelCase or kebab-case field names (matching `createDualCaseProxy`'s
253
+ * dual-case access) and returns `"default"` for anything it doesn't
254
+ * recognize. A `keyof T`-based type would also be unsound for
255
+ * discriminated-union `args` schemas, where narrowing `args` to one branch
256
+ * doesn't retroactively narrow `$source`'s already-fixed parameter type.
257
+ *
258
+ * `$invocation` reports the CLI name (canonical or alias) this command was
259
+ * invoked with.
257
260
  */
258
- type WithArgSource<T> = T & {
261
+ type WithRunMeta<T> = T & {
259
262
  $source?: (name: string) => ArgSource;
263
+ $invocation?: RunInvocation;
260
264
  };
261
265
  /**
262
266
  * Resolve merged args from schema and global args type
263
267
  */
264
- type ResolvedArgs<TArgsSchema, TGlobalArgs> = WithArgSource<MergedArgs<InferArgs<TArgsSchema>, TGlobalArgs>>;
268
+ type ResolvedArgs<TArgsSchema, TGlobalArgs> = WithRunMeta<MergedArgs<InferArgs<TArgsSchema>, TGlobalArgs>>;
265
269
  /**
266
270
  * Config for defining a command
267
271
  * @template TArgsSchema - The args schema type (from the CLI's schema library)
@@ -684,7 +688,7 @@ interface CommandValidationError {
684
688
  /** Path to the command (e.g., ["cli", "build", "watch"]) */
685
689
  commandPath: string[];
686
690
  /** Error type */
687
- type: "duplicate_field" | "duplicate_alias" | "invalid_alias" | "positional_config" | "reserved_alias" | "reserved_field_name" | "case_variant_collision" | "duplicate_negation" | "field_type_conflict";
691
+ type: "duplicate_field" | "duplicate_alias" | "invalid_alias" | "positional_config" | "reserved_alias" | "reserved_field_name" | "case_variant_collision" | "duplicate_negation" | "field_type_conflict" | "subcommand_key_name_mismatch";
688
692
  /** Error message */
689
693
  message: string;
690
694
  /** Related field name (if applicable) */
@@ -847,4 +851,4 @@ declare const defineCommand: DefineCommandFn<ArgsSchema>;
847
851
  declare const createDefineCommand: CreateDefineCommandFn<ArgsSchema>;
848
852
  declare const arg: ArgFn<z.ZodType>;
849
853
  //#endregion
850
- export { type AnyCommand, type ArgFn, type ArgMeta, type ArgSource, ArgsSchema, type BoundDefineCommandFn, type BuiltinOptionDescriptions, type CamelCase, CaseVariantCollisionError, 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, DuplicateAliasError, DuplicateFieldError, DuplicateNegationError, type DynamicCompletionCandidate, type DynamicCompletionContext, type DynamicCompletionResolver, type DynamicCompletionResult, type EffectContext, type Example, type ExpandCandidate, type ExpandCompletion, type ExtractedFields, FieldTypeConflictError, type GenerateBundledCompletionWorkerOptions, type GenerateBundledCompletionWorkerResult, type GenerateCompileCacheShimOptions, type GenerateCompileCacheShimResult, type GlobalArgs, type GlobalCleanupContext, type GlobalSetupContext, type HelpOptions, type InferSchemaOutput, type KebabCase, type LazyCommand, type LogEntry, type LogLevel, type LogStream, type Logger, type MainOptions, type MergedArgs, type NonRunnableCommand, type ParsedArgv, type ParserOptions, PositionalConfigError, type PromptMeta, type PromptResolver, type PromptType, ReservedAliasError, ReservedFieldNameError, type ResolvedExpandCandidate, type ResolvedFieldMeta, type RunCommandOptions, 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, arg, createCompileCacheShimGenerator, createDefineCommand, createDualCaseProxy, defineCommand, extractFields, formatCommandValidationErrors, formatValidationErrors, generateBundledCompletionWorker, generateCompileCacheShim, generateCompletion, generateHelp, getUnknownKeysMode, isColorEnabled, isLazyCommand, lazy, logger, parseArgv, renderInline, renderMarkdown, runCommand, runMain, runPolittyCli, setColorEnabled, styles, symbols, toCamelCase, toKebabCase, validateCaseVariantCollisions, validateCommand, validateCrossSchemaCollisions, validateDuplicateAliases, validateDuplicateFields, validateDuplicateNegations, validatePositionalConfig, validateReservedAliases, validateReservedFieldNames, withCompletionCommand };
854
+ export { type AnyCommand, type ArgFn, type ArgMeta, type ArgSource, ArgsSchema, type BoundDefineCommandFn, type BuiltinOptionDescriptions, type CamelCase, CaseVariantCollisionError, 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, DuplicateAliasError, DuplicateFieldError, DuplicateNegationError, type DynamicCompletionCandidate, type DynamicCompletionContext, type DynamicCompletionResolver, type DynamicCompletionResult, type EffectContext, type Example, type ExpandCandidate, type ExpandCompletion, type ExtractedFields, FieldTypeConflictError, type GenerateBundledCompletionWorkerOptions, type GenerateBundledCompletionWorkerResult, type GenerateCompileCacheShimOptions, type GenerateCompileCacheShimResult, type GlobalArgs, type GlobalCleanupContext, type GlobalSetupContext, type HelpOptions, type InferSchemaOutput, type KebabCase, type LazyCommand, type LogEntry, type LogLevel, type LogStream, type Logger, type MainOptions, type MergedArgs, type NonRunnableCommand, type ParsedArgv, type ParserOptions, PositionalConfigError, type PromptMeta, type PromptResolver, type PromptType, ReservedAliasError, ReservedFieldNameError, 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, arg, createCompileCacheShimGenerator, createDefineCommand, createDualCaseProxy, defineCommand, extractFields, formatCommandValidationErrors, formatValidationErrors, generateBundledCompletionWorker, generateCompileCacheShim, generateCompletion, generateHelp, getUnknownKeysMode, isColorEnabled, isLazyCommand, lazy, logger, parseArgv, renderInline, renderMarkdown, runCommand, runMain, runPolittyCli, setColorEnabled, styles, symbols, toCamelCase, toKebabCase, validateCaseVariantCollisions, validateCommand, validateCrossSchemaCollisions, validateDuplicateAliases, validateDuplicateFields, validateDuplicateNegations, validatePositionalConfig, validateReservedAliases, validateReservedFieldNames, withCompletionCommand };
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
- import { i as toKebabCase, r as toCamelCase } from "./field-meta-DMy5BcRr.js";
2
- import { t as arg$1 } from "./register-DlGnMLIY.js";
3
- import { r as getUnknownKeysMode, t as extractFields } from "./schema-extractor-DMSozq40.js";
4
- import { n as createCompileCacheShimGenerator, t as runPolittyCli } from "./cli-main-Cdz55PLM.js";
1
+ import { i as toKebabCase, r as toCamelCase } from "./field-meta-CO38jOvl.js";
2
+ import { t as arg$1 } from "./register-DdcsbNwM.js";
3
+ import { r as getUnknownKeysMode, t as extractFields } from "./schema-extractor-CVNDs07l.js";
4
+ import { n as createCompileCacheShimGenerator, t as runPolittyCli } from "./cli-main-CAa5KwCo.js";
5
5
  import { n as defineCommand$1, t as createDefineCommand$1 } from "./command-k-4yAz4J.js";
6
- import { C as ReservedFieldNameError, E as renderMarkdown, S as ReservedAliasError, T as renderInline, _ as DuplicateAliasError, a as parseArgv, b as FieldTypeConflictError, c as validateCommand, d as validateDuplicateFields, f as validateDuplicateNegations, g as CaseVariantCollisionError, h as validateReservedFieldNames, i as formatValidationErrors, l as validateCrossSchemaCollisions, m as validateReservedAliases, n as runMain, o as formatCommandValidationErrors, p as validatePositionalConfig, r as createDualCaseProxy, s as validateCaseVariantCollisions, t as runCommand, u as validateDuplicateAliases, v as DuplicateFieldError, w as generateHelp, x as PositionalConfigError, y as DuplicateNegationError } from "./runner-UEbd9e-3.js";
6
+ import { C as ReservedFieldNameError, E as renderMarkdown, S as ReservedAliasError, T as renderInline, _ as DuplicateAliasError, a as parseArgv, b as FieldTypeConflictError, c as validateCommand, d as validateDuplicateFields, f as validateDuplicateNegations, g as CaseVariantCollisionError, h as validateReservedFieldNames, i as formatValidationErrors, l as validateCrossSchemaCollisions, m as validateReservedAliases, n as runMain, o as formatCommandValidationErrors, p as validatePositionalConfig, r as createDualCaseProxy, s as validateCaseVariantCollisions, t as runCommand, u as validateDuplicateAliases, v as DuplicateFieldError, w as generateHelp, x as PositionalConfigError, y as DuplicateNegationError } from "./runner-Bz3arOqh.js";
7
7
  import { o as isLazyCommand, s as lazy } from "./subcommand-router-Cskpofdk.js";
8
8
  import { a as symbols, i as styles, n as logger, r as setColorEnabled, t as isColorEnabled } from "./logger-i_bb-Jhc.js";
9
- import { a as generateCompletion, p as generateBundledCompletionWorker, s as withCompletionCommand } from "./completion-DW5qVc3l.js";
10
- import "./src-DO4W2NcZ.js";
9
+ import { a as generateCompletion, p as generateBundledCompletionWorker, s as withCompletionCommand } from "./completion-Ot2qpNNw.js";
10
+ import "./src-D4QGGgW1.js";
11
11
 
12
12
  //#region src/index.ts
13
13
  /**
@@ -1,4 +1,4 @@
1
- import { I as PromptResolver } from "./arg-registry-B8QvBM_Q.js";
1
+ import { I as PromptResolver } from "./arg-registry-Be4GJADw.js";
2
2
  //#region ../core/src/prompt/clack/index.d.ts
3
3
  /**
4
4
  * Prompt resolver backed by @clack/prompts.
@@ -1,4 +1,4 @@
1
- import "./register-DlGnMLIY.js";
1
+ import "./register-DdcsbNwM.js";
2
2
  import { t as promptMissingArgs } from "./prompt-BjIZThsH.js";
3
3
  import { confirm, isCancel, password, select, text } from "@clack/prompts";
4
4
 
@@ -1,4 +1,4 @@
1
- import { I as PromptResolver } from "./arg-registry-B8QvBM_Q.js";
1
+ import { I as PromptResolver } from "./arg-registry-Be4GJADw.js";
2
2
  //#region ../core/src/prompt/inquirer/index.d.ts
3
3
  /**
4
4
  * Prompt resolver backed by @inquirer/prompts.
@@ -1,4 +1,4 @@
1
- import "./register-DlGnMLIY.js";
1
+ import "./register-DdcsbNwM.js";
2
2
  import { t as promptMissingArgs } from "./prompt-BjIZThsH.js";
3
3
  import { confirm, input, password, select } from "@inquirer/prompts";
4
4
 
package/dist/prompt.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { X as ResolvedFieldMeta, Y as ExtractedFields } from "./arg-registry-B8QvBM_Q.js";
1
+ import { X as ExtractedFields, Z as ResolvedFieldMeta } from "./arg-registry-Be4GJADw.js";
2
2
  //#region ../core/src/prompt/types.d.ts
3
3
  /**
4
4
  * Resolved prompt configuration for a single field
package/dist/prompt.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./register-DlGnMLIY.js";
1
+ import "./register-DdcsbNwM.js";
2
2
  import { i as resolvePromptConfig, n as isInteractive, r as getFieldsToPrompt, t as promptMissingArgs } from "./prompt-BjIZThsH.js";
3
3
 
4
4
  export { getFieldsToPrompt, isInteractive, promptMissingArgs, resolvePromptConfig };
@@ -1,4 +1,4 @@
1
- import { n as resolveFieldMeta, o as registerValidatorAdapter } from "./field-meta-DMy5BcRr.js";
1
+ import { n as resolveFieldMeta, o as registerValidatorAdapter } from "./field-meta-CO38jOvl.js";
2
2
 
3
3
  //#region ../core/src/core/arg-registry.ts
4
4
  /**
@@ -1,5 +1,5 @@
1
- import { a as getValidatorAdapter, i as toKebabCase, r as toCamelCase, t as getAllAliases } from "./field-meta-DMy5BcRr.js";
2
- import { n as getExtractedFields, o as isInternalArgsSchema, s as validateInternalArgs, t as extractFields } from "./schema-extractor-DMSozq40.js";
1
+ import { a as getValidatorAdapter, i as toKebabCase, r as toCamelCase, t as getAllAliases } from "./field-meta-CO38jOvl.js";
2
+ import { n as getExtractedFields, o as isInternalArgsSchema, s as validateInternalArgs, t as extractFields } from "./schema-extractor-CVNDs07l.js";
3
3
  import { n as enableCompileCache } from "./compile-cache-BC65o7MH.js";
4
4
  import { n as emptyLogs, r as mergeLogs, t as createLogCollector } from "./log-collector-CoUkLVJB.js";
5
5
  import { a as resolveSubcommandWithAlias, c as resolveSubCommandMeta, n as listSubCommands, o as isLazyCommand, r as resolveLazyCommand, t as listSubCommandNamesWithAliases } from "./subcommand-router-Cskpofdk.js";
@@ -529,12 +529,16 @@ function renderUsageLine(command, context) {
529
529
  if (extracted) {
530
530
  const positionals = extracted.fields.filter((a) => a.positional);
531
531
  if (extracted.fields.filter((a) => !a.positional).length > 0) parts.push(styles.placeholder("[options]"));
532
- if (command.subCommands && getVisibleSubcommandEntries(command.subCommands).length > 0) if (command.run) parts.push(styles.placeholder("[command]"));
533
- else parts.push(styles.option("<command>"));
532
+ if (command.subCommands && getVisibleSubcommandEntries(command.subCommands).length > 0) {
533
+ if (command.run) parts.push(styles.placeholder("[command]"));
534
+ else parts.push(styles.option("<command>"));
535
+ }
534
536
  for (const arg of positionals) if (arg.required) parts.push(styles.option(`<${arg.name}>`));
535
537
  else parts.push(styles.placeholder(`[${arg.name}]`));
536
- } else if (command.subCommands && getVisibleSubcommandEntries(command.subCommands).length > 0) if (command.run) parts.push(styles.placeholder("[command]"));
537
- else parts.push(styles.option("<command>"));
538
+ } else if (command.subCommands && getVisibleSubcommandEntries(command.subCommands).length > 0) {
539
+ if (command.run) parts.push(styles.placeholder("[command]"));
540
+ else parts.push(styles.option("<command>"));
541
+ }
538
542
  return parts.join(" ");
539
543
  }
540
544
  /**
@@ -737,16 +741,31 @@ function padEndVisual(str, width) {
737
741
  return str + " ".repeat(padding);
738
742
  }
739
743
  /**
744
+ * Re-indent the continuation lines of a multi-line description so they align
745
+ * under the description column. A `\n` in a description is treated as a hard
746
+ * line break; every line after the first is padded to `column` spaces.
747
+ */
748
+ function indentDescription(description, column) {
749
+ if (!description.includes("\n")) return description;
750
+ const pad = " ".repeat(column);
751
+ return description.split("\n").join(`\n${pad}`);
752
+ }
753
+ /**
740
754
  * Format a single option line
741
755
  * If flags exceed the column width, description is moved to the next line
756
+ *
757
+ * Descriptions may contain `\n` line breaks; continuation lines are indented to
758
+ * stay aligned under the description column.
742
759
  */
743
760
  function formatOption(flags, description, indent = 0, extraDescPadding = 0) {
744
761
  const flagWidth = 32;
745
762
  const indentStr = " ".repeat(indent);
746
763
  const visualFlagLength = stripAnsi(flags).length;
747
764
  const effectiveFlagWidth = flagWidth - indent * 2 + extraDescPadding;
748
- if (visualFlagLength >= effectiveFlagWidth) return `${indentStr} ${flags}\n${" ".repeat(effectiveFlagWidth + 2 + indent * 2)}${description}`;
749
- return `${indentStr} ${padEndVisual(flags, effectiveFlagWidth)}${description}`;
765
+ const descColumn = effectiveFlagWidth + 2 + indent * 2;
766
+ const desc = indentDescription(description, descColumn);
767
+ if (visualFlagLength >= effectiveFlagWidth) return `${indentStr} ${flags}\n${" ".repeat(descColumn)}${desc}`;
768
+ return `${indentStr} ${padEndVisual(flags, effectiveFlagWidth)}${desc}`;
750
769
  }
751
770
  /**
752
771
  * Format a single option field as a help line
@@ -831,9 +850,10 @@ function generateHelp(command, options) {
831
850
  const displayName = buildFullCommandName(command, context);
832
851
  if (displayName) {
833
852
  let header = styles.commandName(displayName);
834
- if (context?.rootName && context.commandPath && context.commandPath.length > 0) if (context.rootVersion) header += ` ${styles.version(`(${context.rootName} v${context.rootVersion})`)}`;
835
- else header += ` ${styles.version(`(${context.rootName})`)}`;
836
- else if (context?.rootVersion) header += ` ${styles.version(`v${context.rootVersion}`)}`;
853
+ if (context?.rootName && context.commandPath && context.commandPath.length > 0) {
854
+ if (context.rootVersion) header += ` ${styles.version(`(${context.rootName} v${context.rootVersion})`)}`;
855
+ else header += ` ${styles.version(`(${context.rootName})`)}`;
856
+ } else if (context?.rootVersion) header += ` ${styles.version(`v${context.rootVersion}`)}`;
837
857
  sections.push(header);
838
858
  }
839
859
  if (context?.aliasFor) sections.push(styles.dim(`Alias for ${styles.commandName(context.aliasFor)}`));
@@ -881,7 +901,7 @@ function renderExamplesForHelp(examples, context) {
881
901
  const cmdPath = context?.commandPath?.join(" ") ?? "";
882
902
  const fullPrefix = cmdPath ? `${cmdPrefix}${cmdPath} ` : cmdPrefix;
883
903
  for (const example of examples) {
884
- lines.push(` ${styles.dim(example.desc)}`);
904
+ lines.push(` ${styles.dim(example.desc).split("\n").join("\n ")}`);
885
905
  lines.push(` ${styles.dim("$")} ${fullPrefix}${example.cmd}`);
886
906
  if (example.output) for (const line of example.output.split("\n")) lines.push(` ${line}`);
887
907
  lines.push("");
@@ -1432,24 +1452,55 @@ function checkSubCommandAliasConflicts(command, commandPath) {
1432
1452
  continue;
1433
1453
  }
1434
1454
  const existing = nameToOwner.get(alias);
1435
- if (existing) if (existing === name) errors.push({
1436
- commandPath: subCommandPath,
1437
- type: "duplicate_alias",
1438
- message: `Alias "${alias}" is duplicated within the alias list.`,
1439
- field: name
1440
- });
1441
- else errors.push({
1442
- commandPath: subCommandPath,
1443
- type: "duplicate_alias",
1444
- message: `Alias "${alias}" conflicts with existing subcommand or alias "${existing}".`,
1445
- field: name
1446
- });
1447
- else nameToOwner.set(alias, name);
1455
+ if (existing) {
1456
+ if (existing === name) errors.push({
1457
+ commandPath: subCommandPath,
1458
+ type: "duplicate_alias",
1459
+ message: `Alias "${alias}" is duplicated within the alias list.`,
1460
+ field: name
1461
+ });
1462
+ else errors.push({
1463
+ commandPath: subCommandPath,
1464
+ type: "duplicate_alias",
1465
+ message: `Alias "${alias}" conflicts with existing subcommand or alias "${existing}".`,
1466
+ field: name
1467
+ });
1468
+ } else nameToOwner.set(alias, name);
1448
1469
  }
1449
1470
  }
1450
1471
  return errors;
1451
1472
  }
1452
1473
  /**
1474
+ * Check that a subcommand's own `.name` matches the key it is registered
1475
+ * under in its parent's `subCommands` record.
1476
+ *
1477
+ * Routing (`resolveSubcommand`/`resolveSubcommandWithAlias`), `commandPath`,
1478
+ * the "Alias for X" help line, shell completion, and `run()`'s
1479
+ * `args.$invocation` all key off the registration key — none of them read a
1480
+ * subcommand's own `.name` once it is nested. If the two disagree, a direct
1481
+ * key match is indistinguishable from an alias match by name alone, so
1482
+ * `$invocation`/`aliasFor` would report the key as if it were the canonical
1483
+ * name even though the command's own `.name` says otherwise.
1484
+ *
1485
+ * Takes the already-resolved subcommand's name rather than resolving it
1486
+ * itself: `validateCommand`'s recursive loop already awaits
1487
+ * `resolveLazyCommand` for every subcommand (including pure async
1488
+ * subcommand functions) to validate its nested schema, so by the time this
1489
+ * runs the full `.name` is available at no extra cost -- unlike
1490
+ * `checkSubCommandAliasConflicts`, which must stay synchronous because CLI
1491
+ * argv routing resolves aliases before deciding whether to load a subcommand
1492
+ * at all.
1493
+ */
1494
+ function checkSubCommandKeyNameMismatch(name, resolvedName, commandPath) {
1495
+ if (name === resolvedName) return [];
1496
+ return [{
1497
+ commandPath: [...commandPath, name],
1498
+ type: "subcommand_key_name_mismatch",
1499
+ message: `Subcommand registered as "${name}" but its own name is "${resolvedName}".`,
1500
+ field: name
1501
+ }];
1502
+ }
1503
+ /**
1453
1504
  * Validate a command and all its subcommands recursively
1454
1505
  *
1455
1506
  * This function collects all validation errors without throwing,
@@ -1479,7 +1530,9 @@ async function validateCommand(command, options = {}) {
1479
1530
  }
1480
1531
  errors.push(...checkSubCommandAliasConflicts(command, commandPath));
1481
1532
  if (command.subCommands) for (const [name, subCmd] of Object.entries(command.subCommands)) {
1482
- const subResult = await validateCommand(await resolveLazyCommand(subCmd), {
1533
+ const resolvedSubCmd = await resolveLazyCommand(subCmd);
1534
+ errors.push(...checkSubCommandKeyNameMismatch(name, resolvedSubCmd.name, commandPath));
1535
+ const subResult = await validateCommand(resolvedSubCmd, {
1483
1536
  commandPath: [...commandPath, name],
1484
1537
  ...options.globalArgs ? { globalArgs: options.globalArgs } : {}
1485
1538
  });
@@ -2026,37 +2079,39 @@ function parseArgs(argv, command, options = {}) {
2026
2079
  const subCommandNameSet = listSubCommandNamesWithAliases(command);
2027
2080
  const subCommandNames = [...subCommandNameSet];
2028
2081
  const hasSubCommands = subCommandNames.length > 0;
2029
- if (hasSubCommands && argv.length > 0) if (options.globalExtracted) {
2030
- const scanResult = scanForSubcommand(argv, subCommandNames, options.globalExtracted);
2031
- if (scanResult.subCommandIndex >= 0) {
2032
- const rawGlobalArgs = parseGlobalArgs(scanResult.globalTokensBefore, options.globalExtracted);
2033
- return {
2082
+ if (hasSubCommands && argv.length > 0) {
2083
+ if (options.globalExtracted) {
2084
+ const scanResult = scanForSubcommand(argv, subCommandNames, options.globalExtracted);
2085
+ if (scanResult.subCommandIndex >= 0) {
2086
+ const rawGlobalArgs = parseGlobalArgs(scanResult.globalTokensBefore, options.globalExtracted);
2087
+ return {
2088
+ helpRequested: false,
2089
+ helpAllRequested: false,
2090
+ versionRequested: false,
2091
+ subCommand: argv[scanResult.subCommandIndex],
2092
+ remainingArgs: scanResult.tokensAfterSubcommand,
2093
+ rawArgs: {},
2094
+ positionals: [],
2095
+ rest: [],
2096
+ unknownFlags: scanResult.suppressedTokens,
2097
+ unknownGlobalFlags: scanResult.suppressedTokens,
2098
+ rawGlobalArgs
2099
+ };
2100
+ }
2101
+ } else {
2102
+ const firstArg = argv[0];
2103
+ if (firstArg && !firstArg.startsWith("-") && subCommandNameSet.has(firstArg)) return {
2034
2104
  helpRequested: false,
2035
2105
  helpAllRequested: false,
2036
2106
  versionRequested: false,
2037
- subCommand: argv[scanResult.subCommandIndex],
2038
- remainingArgs: scanResult.tokensAfterSubcommand,
2107
+ subCommand: firstArg,
2108
+ remainingArgs: argv.slice(1),
2039
2109
  rawArgs: {},
2040
2110
  positionals: [],
2041
2111
  rest: [],
2042
- unknownFlags: scanResult.suppressedTokens,
2043
- unknownGlobalFlags: scanResult.suppressedTokens,
2044
- rawGlobalArgs
2112
+ unknownFlags: []
2045
2113
  };
2046
2114
  }
2047
- } else {
2048
- const firstArg = argv[0];
2049
- if (firstArg && !firstArg.startsWith("-") && subCommandNameSet.has(firstArg)) return {
2050
- helpRequested: false,
2051
- helpAllRequested: false,
2052
- versionRequested: false,
2053
- subCommand: firstArg,
2054
- remainingArgs: argv.slice(1),
2055
- rawArgs: {},
2056
- positionals: [],
2057
- rest: [],
2058
- unknownFlags: []
2059
- };
2060
2115
  }
2061
2116
  let extracted;
2062
2117
  if (command.args) {
@@ -2400,6 +2455,35 @@ function attachArgSource(target, sourceMap) {
2400
2455
  });
2401
2456
  }
2402
2457
  /**
2458
+ * Attach a non-enumerable `$invocation` helper to the final args object,
2459
+ * mirroring `attachArgSource`'s visibility (invisible to `Object.keys`/
2460
+ * `JSON.stringify`/spread, reachable via property access through
2461
+ * `createDualCaseProxy`).
2462
+ */
2463
+ function attachInvocation(target, invocation) {
2464
+ Object.defineProperty(target, "$invocation", {
2465
+ value: invocation,
2466
+ enumerable: false
2467
+ });
2468
+ }
2469
+ /**
2470
+ * Resolve the `RunInvocation` metadata for the command about to run: the
2471
+ * literal CLI token that reached it (canonical name or alias), and the
2472
+ * canonical name if that token was an alias.
2473
+ *
2474
+ * `context.commandPath`'s last entry is the raw token a parent recorded
2475
+ * when descending into this command (see the subcommand-descent branch
2476
+ * below); it falls back to `command.name` for the root command or a
2477
+ * directly-invoked command (no subcommand routing took place).
2478
+ */
2479
+ function resolveInvocation(command, context) {
2480
+ const name = context.commandPath?.at(-1) ?? command.name;
2481
+ return context.aliasFor ? {
2482
+ name,
2483
+ aliasFor: context.aliasFor
2484
+ } : { name };
2485
+ }
2486
+ /**
2403
2487
  * Run a command with the given arguments (programmatic/test usage)
2404
2488
  *
2405
2489
  * This function parses arguments, validates them, routes to subcommands,
@@ -2859,6 +2943,7 @@ async function runCommandInternal(command, argv, options = {}) {
2859
2943
  for (const name of cliProvidedGlobalFields) globalSourceMap.set(name, "cli");
2860
2944
  for (const name of envFallbackGlobalFields) globalSourceMap.set(name, "env");
2861
2945
  attachArgSource(validatedGlobalArgs, globalSourceMap);
2946
+ attachInvocation(validatedGlobalArgs, resolveInvocation(command, context));
2862
2947
  const proxiedGlobalArgs = createDualCaseProxy(validatedGlobalArgs);
2863
2948
  if (options._globalExtracted && !isCompletionInvocation) await runEffects(proxiedGlobalArgs, options._globalExtracted, proxiedGlobalArgs);
2864
2949
  collector?.stop();
@@ -2921,6 +3006,7 @@ async function runCommandInternal(command, argv, options = {}) {
2921
3006
  argSourceMap.set(field.name, localHasCliOrEnvValue ? localEnvFallbackFields.has(field.name) ? "env" : "cli" : "default");
2922
3007
  }
2923
3008
  attachArgSource(mergedPlainArgs, argSourceMap);
3009
+ attachInvocation(mergedPlainArgs, resolveInvocation(command, context));
2924
3010
  const mergedArgs = createDualCaseProxy(mergedPlainArgs);
2925
3011
  collector?.stop();
2926
3012
  return await executeLifecycle(command, mergedArgs, {
@@ -0,0 +1,3 @@
1
+ import { n as runMain, t as runCommand } from "./runner-Bz3arOqh.js";
2
+
3
+ export { runCommand };
@@ -1,4 +1,4 @@
1
- import { a as getValidatorAdapter, n as resolveFieldMeta } from "./field-meta-DMy5BcRr.js";
1
+ import { a as getValidatorAdapter, n as resolveFieldMeta } from "./field-meta-CO38jOvl.js";
2
2
 
3
3
  //#region ../core/src/adapter/internal-args.ts
4
4
  /** Runtime brand distinguishing internal descriptors from library schemas. */
package/dist/skill.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Z as UnknownKeysMode, b as ArgsSchema, v as AnyCommand } from "./arg-registry-B8QvBM_Q.js";
1
+ import { Q as UnknownKeysMode, b as ArgsSchema, v as AnyCommand } from "./arg-registry-Be4GJADw.js";
2
2
  import { z } from "zod";
3
3
  //#region ../core/src/skill/types.d.ts
4
4
  /**
package/dist/skill.js CHANGED
@@ -1,5 +1,5 @@
1
- import "./register-DlGnMLIY.js";
2
- import { a as internalField, i as internalArgs, t as extractFields } from "./schema-extractor-DMSozq40.js";
1
+ import "./register-DdcsbNwM.js";
2
+ import { a as internalField, i as internalArgs, t as extractFields } from "./schema-extractor-CVNDs07l.js";
3
3
  import { n as defineCommand } from "./command-k-4yAz4J.js";
4
4
  import { a as symbols, n as logger } from "./logger-i_bb-Jhc.js";
5
5
  import { copyFileSync, existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, symlinkSync, unlinkSync } from "node:fs";
@@ -1178,10 +1178,12 @@ function createSkillRemoveCommand(resolved) {
1178
1178
  const stamp = resolved.stamp;
1179
1179
  if (args.name) {
1180
1180
  if (sourceSkills.some((s) => s.frontmatter.name === args.name)) findOrThrow(sourceSkills, args.name);
1181
- if (!removeOwnedSkill(args.name, stamp, resolved.cwd, resolved.sourceDir)) if (slotPresent(args.name, resolved.cwd)) logger.info(`${args.name} is installed without a ${OWNERSHIP_METADATA_KEY} stamp this CLI recognises; refusing to remove. Remove .agents/skills/${args.name} manually if intended.`);
1182
- else {
1183
- const installed = new Set(findOwnedInstalledSkills(stamp, resolved.cwd, resolved.sourceDir));
1184
- logger.info(`${args.name} is not installed; nothing to remove.\n` + formatSkillUniverse({ installed }));
1181
+ if (!removeOwnedSkill(args.name, stamp, resolved.cwd, resolved.sourceDir)) {
1182
+ if (slotPresent(args.name, resolved.cwd)) logger.info(`${args.name} is installed without a ${OWNERSHIP_METADATA_KEY} stamp this CLI recognises; refusing to remove. Remove .agents/skills/${args.name} manually if intended.`);
1183
+ else {
1184
+ const installed = new Set(findOwnedInstalledSkills(stamp, resolved.cwd, resolved.sourceDir));
1185
+ logger.info(`${args.name} is not installed; nothing to remove.\n` + formatSkillUniverse({ installed }));
1186
+ }
1185
1187
  }
1186
1188
  return;
1187
1189
  }
@@ -0,0 +1,6 @@
1
+ import "./cli-main-CAa5KwCo.js";
2
+ import "./runner-Bz3arOqh.js";
3
+ import "./logger-i_bb-Jhc.js";
4
+ import "./completion-Ot2qpNNw.js";
5
+
6
+ export { };
@@ -1,12 +1,12 @@
1
- import { i as toKebabCase, r as toCamelCase } from "./field-meta-DMy5BcRr.js";
2
- import { t as arg } from "./register-DlGnMLIY.js";
3
- import { r as getUnknownKeysMode, t as extractFields } from "./schema-extractor-DMSozq40.js";
4
- import { n as createCompileCacheShimGenerator, t as runPolittyCli } from "./cli-main-Cdz55PLM.js";
1
+ import { i as toKebabCase, r as toCamelCase } from "./field-meta-CO38jOvl.js";
2
+ import { t as arg } from "./register-DdcsbNwM.js";
3
+ import { r as getUnknownKeysMode, t as extractFields } from "./schema-extractor-CVNDs07l.js";
4
+ import { n as createCompileCacheShimGenerator, t as runPolittyCli } from "./cli-main-CAa5KwCo.js";
5
5
  import { n as defineCommand, t as createDefineCommand } from "./command-k-4yAz4J.js";
6
- import { C as ReservedFieldNameError, E as renderMarkdown, S as ReservedAliasError, T as renderInline, _ as DuplicateAliasError, a as parseArgv, b as FieldTypeConflictError, c as validateCommand, d as validateDuplicateFields, f as validateDuplicateNegations, g as CaseVariantCollisionError, h as validateReservedFieldNames, i as formatValidationErrors, l as validateCrossSchemaCollisions, m as validateReservedAliases, n as runMain, o as formatCommandValidationErrors, p as validatePositionalConfig, r as createDualCaseProxy, s as validateCaseVariantCollisions, t as runCommand, u as validateDuplicateAliases, v as DuplicateFieldError, w as generateHelp, x as PositionalConfigError, y as DuplicateNegationError } from "./runner-UEbd9e-3.js";
6
+ import { C as ReservedFieldNameError, E as renderMarkdown, S as ReservedAliasError, T as renderInline, _ as DuplicateAliasError, a as parseArgv, b as FieldTypeConflictError, c as validateCommand, d as validateDuplicateFields, f as validateDuplicateNegations, g as CaseVariantCollisionError, h as validateReservedFieldNames, i as formatValidationErrors, l as validateCrossSchemaCollisions, m as validateReservedAliases, n as runMain, o as formatCommandValidationErrors, p as validatePositionalConfig, r as createDualCaseProxy, s as validateCaseVariantCollisions, t as runCommand, u as validateDuplicateAliases, v as DuplicateFieldError, w as generateHelp, x as PositionalConfigError, y as DuplicateNegationError } from "./runner-Bz3arOqh.js";
7
7
  import { o as isLazyCommand, s as lazy } from "./subcommand-router-Cskpofdk.js";
8
8
  import { a as symbols, i as styles, n as logger, r as setColorEnabled, t as isColorEnabled } from "./logger-i_bb-Jhc.js";
9
- import { a as generateCompletion, p as generateBundledCompletionWorker, s as withCompletionCommand } from "./completion-DW5qVc3l.js";
10
- import "./src-DO4W2NcZ.js";
9
+ import { a as generateCompletion, p as generateBundledCompletionWorker, s as withCompletionCommand } from "./completion-Ot2qpNNw.js";
10
+ import "./src-D4QGGgW1.js";
11
11
 
12
12
  export { generateBundledCompletionWorker };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@politty/zod",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "A lightweight CLI framework inspired by citty with zod v4 registry integration for type-safe metadata management",
5
5
  "keywords": [
6
6
  "argument-parser",
@@ -71,7 +71,7 @@
71
71
  }
72
72
  },
73
73
  "dependencies": {
74
- "yaml": "^2.8.3"
74
+ "yaml": "^2.9.0"
75
75
  },
76
76
  "devDependencies": {
77
77
  "@types/node": "25.9.5",
@@ -1,3 +0,0 @@
1
- import { t as runPolittyCli } from "./cli-main-Cdz55PLM.js";
2
-
3
- export { runPolittyCli };
@@ -1,8 +0,0 @@
1
- import "./register-DlGnMLIY.js";
2
-
3
- //#region src/cli-run.ts
4
- const { runPolittyCli } = await import("./cli-main-B5mwyz8q.js");
5
- await runPolittyCli("@politty/zod");
6
-
7
- //#endregion
8
- export { };
@@ -1,3 +0,0 @@
1
- import { n as runMain, t as runCommand } from "./runner-UEbd9e-3.js";
2
-
3
- export { runCommand };
@@ -1,6 +0,0 @@
1
- import "./cli-main-Cdz55PLM.js";
2
- import "./runner-UEbd9e-3.js";
3
- import "./logger-i_bb-Jhc.js";
4
- import "./completion-DW5qVc3l.js";
5
-
6
- export { };