@politty/zod 0.1.1 → 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.
- package/dist/{arg-registry-B8QvBM_Q.d.ts → arg-registry-Be4GJADw.d.ts} +15 -1
- package/dist/augment.d.ts +1 -1
- package/dist/{cli-main-D4kkrRfX.js → cli-main-CAa5KwCo.js} +3 -3
- package/dist/cli-main-DIRMduj1.js +3 -0
- package/dist/cli-run-B--tZW_I.js +8 -0
- package/dist/cli.js +1 -1
- package/dist/{completion-DW5qVc3l.js → completion-Ot2qpNNw.js} +27 -24
- package/dist/completion.d.ts +2 -2
- package/dist/completion.js +2 -2
- package/dist/docs.d.ts +1 -1
- package/dist/docs.js +93 -75
- package/dist/{field-meta-DMy5BcRr.js → field-meta-CO38jOvl.js} +12 -10
- package/dist/{index-CMb2xLiJ.d.ts → index-B4NylQOW.d.ts} +1 -1
- package/dist/index.d.ts +20 -16
- package/dist/index.js +7 -7
- package/dist/prompt-clack.d.ts +1 -1
- package/dist/prompt-clack.js +1 -1
- package/dist/prompt-inquirer.d.ts +1 -1
- package/dist/prompt-inquirer.js +1 -1
- package/dist/prompt.d.ts +1 -1
- package/dist/prompt.js +1 -1
- package/dist/{register-DlGnMLIY.js → register-DdcsbNwM.js} +1 -1
- package/dist/{runner-DAGvxV2P.js → runner-Bz3arOqh.js} +117 -46
- package/dist/runner-Cs-Mz9JN.js +3 -0
- package/dist/{schema-extractor-DMSozq40.js → schema-extractor-CVNDs07l.js} +1 -1
- package/dist/skill.d.ts +1 -1
- package/dist/skill.js +8 -6
- package/dist/src-D4QGGgW1.js +6 -0
- package/dist/{src-CLogLsbS.js → src-DhQVU2hG.js} +7 -7
- package/package.json +1 -1
- package/dist/cli-main-BQfutJEX.js +0 -3
- package/dist/cli-run-wxd6kPPf.js +0 -8
- package/dist/runner-MMjpKeEa.js +0 -3
- package/dist/src-bYH2XCQ4.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 {
|
|
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,6 +1,6 @@
|
|
|
1
|
-
import { a as internalField, i as internalArgs } from "./schema-extractor-
|
|
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-
|
|
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-
|
|
242
|
+
const { generateBundledCompletionWorker } = await import("./src-DhQVU2hG.js");
|
|
243
243
|
await generateBundledCompletionWorker({
|
|
244
244
|
bin: args.bin,
|
|
245
245
|
programName: args.program,
|
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-
|
|
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-
|
|
2
|
-
import { a as internalField, i as internalArgs, t as extractFields } from "./schema-extractor-
|
|
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)
|
|
189
|
-
if (
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
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)
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
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
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
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++;
|
package/dist/completion.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as Command,
|
|
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-
|
|
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
|
package/dist/completion.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./register-
|
|
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-
|
|
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,
|
|
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-
|
|
2
|
-
import "./register-
|
|
3
|
-
import { n as getExtractedFields, t as extractFields } from "./schema-extractor-
|
|
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";
|
|
@@ -327,8 +327,10 @@ function escapeTableCell$1(str) {
|
|
|
327
327
|
function renderUsage(info) {
|
|
328
328
|
const parts = [info.fullCommandPath];
|
|
329
329
|
if (info.options.length > 0) parts.push("[options]");
|
|
330
|
-
if (info.subCommands.length > 0)
|
|
331
|
-
|
|
330
|
+
if (info.subCommands.length > 0) {
|
|
331
|
+
if (info.command.run) parts.push("[command]");
|
|
332
|
+
else parts.push("<command>");
|
|
333
|
+
}
|
|
332
334
|
for (const arg of info.positionalArgs) if (arg.required) parts.push(`<${arg.name}>`);
|
|
333
335
|
else parts.push(`[${arg.name}]`);
|
|
334
336
|
return parts.join(" ");
|
|
@@ -931,7 +933,7 @@ async function executeSingleExample(example, rootCommand, commandPath) {
|
|
|
931
933
|
collector.start();
|
|
932
934
|
let success = true;
|
|
933
935
|
try {
|
|
934
|
-
const { runCommand } = await import("./runner-
|
|
936
|
+
const { runCommand } = await import("./runner-Cs-Mz9JN.js");
|
|
935
937
|
const result = await runCommand(rootCommand, argv);
|
|
936
938
|
success = result.success;
|
|
937
939
|
if (!result.success && result.error) console.error(result.error.message);
|
|
@@ -1832,16 +1834,17 @@ function buildTemplateExclusions(rawKeys, allCommands) {
|
|
|
1832
1834
|
const exclusions = createTemplateExclusions(rawKeys);
|
|
1833
1835
|
for (const key of rawKeys) {
|
|
1834
1836
|
const parsed = parsePlaceholder(`{{politty:${key}}}`, allCommands);
|
|
1835
|
-
if (parsed.kind === "command")
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
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);
|
|
1841
1846
|
}
|
|
1842
|
-
|
|
1843
|
-
}
|
|
1844
|
-
else if (parsed.kind === "global-options") exclusions.globalOptions = true;
|
|
1847
|
+
} else if (parsed.kind === "global-options") exclusions.globalOptions = true;
|
|
1845
1848
|
else if (parsed.kind === "index") exclusions.index = true;
|
|
1846
1849
|
}
|
|
1847
1850
|
return exclusions;
|
|
@@ -2177,18 +2180,20 @@ async function processGlobalOptionsMarker(existingContent, globalOptionsConfig,
|
|
|
2177
2180
|
wasUpdated
|
|
2178
2181
|
};
|
|
2179
2182
|
}
|
|
2180
|
-
if (existingSection !== generatedSection)
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
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
|
+
}
|
|
2185
2193
|
} else {
|
|
2186
2194
|
hasError = true;
|
|
2187
|
-
diffs.push(
|
|
2195
|
+
diffs.push(formatDiff(existingSection, generatedSection));
|
|
2188
2196
|
}
|
|
2189
|
-
} else {
|
|
2190
|
-
hasError = true;
|
|
2191
|
-
diffs.push(formatDiff(existingSection, generatedSection));
|
|
2192
2197
|
}
|
|
2193
2198
|
return {
|
|
2194
2199
|
content,
|
|
@@ -2232,18 +2237,20 @@ async function processStaticMarker(existingContent, markerLabel, startMarker, en
|
|
|
2232
2237
|
wasUpdated
|
|
2233
2238
|
};
|
|
2234
2239
|
}
|
|
2235
|
-
if (existingSection !== generatedSection)
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
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
|
+
}
|
|
2240
2250
|
} else {
|
|
2241
2251
|
hasError = true;
|
|
2242
|
-
diffs.push(
|
|
2252
|
+
diffs.push(formatDiff(existingSection, generatedSection));
|
|
2243
2253
|
}
|
|
2244
|
-
} else {
|
|
2245
|
-
hasError = true;
|
|
2246
|
-
diffs.push(formatDiff(existingSection, generatedSection));
|
|
2247
2254
|
}
|
|
2248
2255
|
return {
|
|
2249
2256
|
content,
|
|
@@ -2294,18 +2301,20 @@ async function processIndexMarker(existingContent, categories, command, scope, u
|
|
|
2294
2301
|
};
|
|
2295
2302
|
}
|
|
2296
2303
|
const generatedSection = await applyFormatter(await generateIndexSection(categories, command, scope, indexOptions), formatter);
|
|
2297
|
-
if (existingSection !== generatedSection)
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
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
|
+
}
|
|
2302
2314
|
} else {
|
|
2303
2315
|
hasError = true;
|
|
2304
|
-
diffs.push(
|
|
2316
|
+
diffs.push(formatDiff(existingSection, generatedSection));
|
|
2305
2317
|
}
|
|
2306
|
-
} else {
|
|
2307
|
-
hasError = true;
|
|
2308
|
-
diffs.push(formatDiff(existingSection, generatedSection));
|
|
2309
2318
|
}
|
|
2310
2319
|
return {
|
|
2311
2320
|
content,
|
|
@@ -2512,10 +2521,12 @@ async function generateDoc(config) {
|
|
|
2512
2521
|
const hasTargetCommands = targetCommands !== void 0 && targetCommands.length > 0;
|
|
2513
2522
|
const globalOptionDefinitions = collectGlobalOptionDefinitions(rootDoc);
|
|
2514
2523
|
const templateGlobalOptionFields = /* @__PURE__ */ new Map();
|
|
2515
|
-
if (config.templates)
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
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
|
+
}
|
|
2519
2530
|
}
|
|
2520
2531
|
const documentedCommandPaths = hasTargetCommands ? collectTargetDocumentedCommandPaths(targetCommands, files, allCommands, ignores) : collectDocumentedCommandPaths(files, allCommands, ignores);
|
|
2521
2532
|
const allFilesCommands = [];
|
|
@@ -2740,30 +2751,34 @@ async function generateDoc(config) {
|
|
|
2740
2751
|
if (!existingSection) continue;
|
|
2741
2752
|
if (!generatedSectionPart) {
|
|
2742
2753
|
const emptyMarker = sectionStartMarker(sectionType, targetCommand) + "\n" + sectionEndMarker(sectionType, targetCommand);
|
|
2743
|
-
if (existingSection !== emptyMarker)
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
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}"`);
|
|
2749
2777
|
} else {
|
|
2750
2778
|
hasError = true;
|
|
2751
2779
|
fileStatus = "diff";
|
|
2752
|
-
diffs.push(formatDiff(existingSection,
|
|
2780
|
+
diffs.push(formatDiff(existingSection, generatedSectionPart));
|
|
2753
2781
|
}
|
|
2754
|
-
continue;
|
|
2755
|
-
}
|
|
2756
|
-
if (existingSection !== generatedSectionPart) if (updateMode) {
|
|
2757
|
-
const updated = replaceSectionMarker(existingContent, sectionType, targetCommand, generatedSectionPart);
|
|
2758
|
-
if (updated) {
|
|
2759
|
-
existingContent = updated;
|
|
2760
|
-
writeFile(filePath, existingContent);
|
|
2761
|
-
if (fileStatus !== "created") fileStatus = "updated";
|
|
2762
|
-
} else throw new Error(`Failed to replace ${sectionType} section for command "${targetCommand}"`);
|
|
2763
|
-
} else {
|
|
2764
|
-
hasError = true;
|
|
2765
|
-
fileStatus = "diff";
|
|
2766
|
-
diffs.push(formatDiff(existingSection, generatedSectionPart));
|
|
2767
2782
|
}
|
|
2768
2783
|
}
|
|
2769
2784
|
if (doctorMode || customizable) {
|
|
@@ -2889,9 +2904,10 @@ async function generateDoc(config) {
|
|
|
2889
2904
|
const extracted = extractSectionMarker(rawSection, type, scope);
|
|
2890
2905
|
replacements.set(placeholder, extracted === null ? "" : stripPolittyMarkers(extracted));
|
|
2891
2906
|
}
|
|
2892
|
-
} else if (parsed.kind === "global-options")
|
|
2893
|
-
|
|
2894
|
-
|
|
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") {
|
|
2895
2911
|
const categories = [...deriveIndexFromFiles(files, outputPath, allCommands, ignores), ...deriveIndexFromTemplateOutputs(templateMeta, outputPath, outputPath, allCommands)];
|
|
2896
2912
|
const indexContent = await renderCommandIndex(command, categories, rootDoc?.index);
|
|
2897
2913
|
replacements.set(placeholder, indexContent);
|
|
@@ -2962,12 +2978,14 @@ async function generateDoc(config) {
|
|
|
2962
2978
|
}
|
|
2963
2979
|
if (!usingPathConfig) {
|
|
2964
2980
|
const unexpectedSectionPaths = collectSectionMarkerPaths(content);
|
|
2965
|
-
if (unexpectedSectionPaths.length > 0)
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
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
|
+
}
|
|
2971
2989
|
}
|
|
2972
2990
|
}
|
|
2973
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)
|
|
99
|
-
if (
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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,
|
|
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
|
|
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-
|
|
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`
|
|
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
|
-
* `
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
* `
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
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
|
|
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> =
|
|
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-
|
|
2
|
-
import { t as arg$1 } from "./register-
|
|
3
|
-
import { r as getUnknownKeysMode, t as extractFields } from "./schema-extractor-
|
|
4
|
-
import { n as createCompileCacheShimGenerator, t as runPolittyCli } from "./cli-main-
|
|
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-
|
|
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-
|
|
10
|
-
import "./src-
|
|
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
|
/**
|
package/dist/prompt-clack.d.ts
CHANGED
package/dist/prompt-clack.js
CHANGED
package/dist/prompt-inquirer.js
CHANGED
package/dist/prompt.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { X as
|
|
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-
|
|
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,5 +1,5 @@
|
|
|
1
|
-
import { a as getValidatorAdapter, i as toKebabCase, r as toCamelCase, t as getAllAliases } from "./field-meta-
|
|
2
|
-
import { n as getExtractedFields, o as isInternalArgsSchema, s as validateInternalArgs, t as extractFields } from "./schema-extractor-
|
|
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)
|
|
533
|
-
|
|
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)
|
|
537
|
-
|
|
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
|
/**
|
|
@@ -846,9 +850,10 @@ function generateHelp(command, options) {
|
|
|
846
850
|
const displayName = buildFullCommandName(command, context);
|
|
847
851
|
if (displayName) {
|
|
848
852
|
let header = styles.commandName(displayName);
|
|
849
|
-
if (context?.rootName && context.commandPath && context.commandPath.length > 0)
|
|
850
|
-
|
|
851
|
-
|
|
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}`)}`;
|
|
852
857
|
sections.push(header);
|
|
853
858
|
}
|
|
854
859
|
if (context?.aliasFor) sections.push(styles.dim(`Alias for ${styles.commandName(context.aliasFor)}`));
|
|
@@ -1447,24 +1452,55 @@ function checkSubCommandAliasConflicts(command, commandPath) {
|
|
|
1447
1452
|
continue;
|
|
1448
1453
|
}
|
|
1449
1454
|
const existing = nameToOwner.get(alias);
|
|
1450
|
-
if (existing)
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
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);
|
|
1463
1469
|
}
|
|
1464
1470
|
}
|
|
1465
1471
|
return errors;
|
|
1466
1472
|
}
|
|
1467
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
|
+
/**
|
|
1468
1504
|
* Validate a command and all its subcommands recursively
|
|
1469
1505
|
*
|
|
1470
1506
|
* This function collects all validation errors without throwing,
|
|
@@ -1494,7 +1530,9 @@ async function validateCommand(command, options = {}) {
|
|
|
1494
1530
|
}
|
|
1495
1531
|
errors.push(...checkSubCommandAliasConflicts(command, commandPath));
|
|
1496
1532
|
if (command.subCommands) for (const [name, subCmd] of Object.entries(command.subCommands)) {
|
|
1497
|
-
const
|
|
1533
|
+
const resolvedSubCmd = await resolveLazyCommand(subCmd);
|
|
1534
|
+
errors.push(...checkSubCommandKeyNameMismatch(name, resolvedSubCmd.name, commandPath));
|
|
1535
|
+
const subResult = await validateCommand(resolvedSubCmd, {
|
|
1498
1536
|
commandPath: [...commandPath, name],
|
|
1499
1537
|
...options.globalArgs ? { globalArgs: options.globalArgs } : {}
|
|
1500
1538
|
});
|
|
@@ -2041,37 +2079,39 @@ function parseArgs(argv, command, options = {}) {
|
|
|
2041
2079
|
const subCommandNameSet = listSubCommandNamesWithAliases(command);
|
|
2042
2080
|
const subCommandNames = [...subCommandNameSet];
|
|
2043
2081
|
const hasSubCommands = subCommandNames.length > 0;
|
|
2044
|
-
if (hasSubCommands && argv.length > 0)
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
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 {
|
|
2049
2104
|
helpRequested: false,
|
|
2050
2105
|
helpAllRequested: false,
|
|
2051
2106
|
versionRequested: false,
|
|
2052
|
-
subCommand:
|
|
2053
|
-
remainingArgs:
|
|
2107
|
+
subCommand: firstArg,
|
|
2108
|
+
remainingArgs: argv.slice(1),
|
|
2054
2109
|
rawArgs: {},
|
|
2055
2110
|
positionals: [],
|
|
2056
2111
|
rest: [],
|
|
2057
|
-
unknownFlags:
|
|
2058
|
-
unknownGlobalFlags: scanResult.suppressedTokens,
|
|
2059
|
-
rawGlobalArgs
|
|
2112
|
+
unknownFlags: []
|
|
2060
2113
|
};
|
|
2061
2114
|
}
|
|
2062
|
-
} else {
|
|
2063
|
-
const firstArg = argv[0];
|
|
2064
|
-
if (firstArg && !firstArg.startsWith("-") && subCommandNameSet.has(firstArg)) return {
|
|
2065
|
-
helpRequested: false,
|
|
2066
|
-
helpAllRequested: false,
|
|
2067
|
-
versionRequested: false,
|
|
2068
|
-
subCommand: firstArg,
|
|
2069
|
-
remainingArgs: argv.slice(1),
|
|
2070
|
-
rawArgs: {},
|
|
2071
|
-
positionals: [],
|
|
2072
|
-
rest: [],
|
|
2073
|
-
unknownFlags: []
|
|
2074
|
-
};
|
|
2075
2115
|
}
|
|
2076
2116
|
let extracted;
|
|
2077
2117
|
if (command.args) {
|
|
@@ -2415,6 +2455,35 @@ function attachArgSource(target, sourceMap) {
|
|
|
2415
2455
|
});
|
|
2416
2456
|
}
|
|
2417
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
|
+
/**
|
|
2418
2487
|
* Run a command with the given arguments (programmatic/test usage)
|
|
2419
2488
|
*
|
|
2420
2489
|
* This function parses arguments, validates them, routes to subcommands,
|
|
@@ -2874,6 +2943,7 @@ async function runCommandInternal(command, argv, options = {}) {
|
|
|
2874
2943
|
for (const name of cliProvidedGlobalFields) globalSourceMap.set(name, "cli");
|
|
2875
2944
|
for (const name of envFallbackGlobalFields) globalSourceMap.set(name, "env");
|
|
2876
2945
|
attachArgSource(validatedGlobalArgs, globalSourceMap);
|
|
2946
|
+
attachInvocation(validatedGlobalArgs, resolveInvocation(command, context));
|
|
2877
2947
|
const proxiedGlobalArgs = createDualCaseProxy(validatedGlobalArgs);
|
|
2878
2948
|
if (options._globalExtracted && !isCompletionInvocation) await runEffects(proxiedGlobalArgs, options._globalExtracted, proxiedGlobalArgs);
|
|
2879
2949
|
collector?.stop();
|
|
@@ -2936,6 +3006,7 @@ async function runCommandInternal(command, argv, options = {}) {
|
|
|
2936
3006
|
argSourceMap.set(field.name, localHasCliOrEnvValue ? localEnvFallbackFields.has(field.name) ? "env" : "cli" : "default");
|
|
2937
3007
|
}
|
|
2938
3008
|
attachArgSource(mergedPlainArgs, argSourceMap);
|
|
3009
|
+
attachInvocation(mergedPlainArgs, resolveInvocation(command, context));
|
|
2939
3010
|
const mergedArgs = createDualCaseProxy(mergedPlainArgs);
|
|
2940
3011
|
collector?.stop();
|
|
2941
3012
|
return await executeLifecycle(command, mergedArgs, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as getValidatorAdapter, n as resolveFieldMeta } from "./field-meta-
|
|
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 {
|
|
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-
|
|
2
|
-
import { a as internalField, i as internalArgs, t as extractFields } from "./schema-extractor-
|
|
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))
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
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
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { i as toKebabCase, r as toCamelCase } from "./field-meta-
|
|
2
|
-
import { t as arg } from "./register-
|
|
3
|
-
import { r as getUnknownKeysMode, t as extractFields } from "./schema-extractor-
|
|
4
|
-
import { n as createCompileCacheShimGenerator, t as runPolittyCli } from "./cli-main-
|
|
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-
|
|
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-
|
|
10
|
-
import "./src-
|
|
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
package/dist/cli-run-wxd6kPPf.js
DELETED
package/dist/runner-MMjpKeEa.js
DELETED