@politty/zod 0.0.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{arg-registry-YaWTVu_x.d.ts → arg-registry-B8QvBM_Q.d.ts} +1 -1
- package/dist/augment.d.ts +1 -1
- package/dist/cli-main-BQfutJEX.js +3 -0
- package/dist/{src-KzC0g5CS.js → cli-main-D4kkrRfX.js} +144 -21
- package/dist/cli-run-wxd6kPPf.js +8 -0
- package/dist/cli.js +2 -2
- package/dist/{compile-cache-Ct41pWGL.js → compile-cache-BC65o7MH.js} +4 -1
- package/dist/compile-cache.d.ts +4 -1
- package/dist/compile-cache.js +1 -1
- package/dist/{completion-gtWX3mwP.js → completion-DW5qVc3l.js} +10 -5
- package/dist/completion.d.ts +2 -2
- package/dist/completion.js +2 -2
- package/dist/docs.d.ts +1 -1
- package/dist/docs.js +23 -12
- package/dist/{index-CvhsecfS.d.ts → index-CMb2xLiJ.d.ts} +1 -1
- package/dist/index.d.ts +68 -17
- package/dist/index.js +15 -5
- package/dist/{prompt-CEIZ-7H1.js → prompt-BjIZThsH.js} +4 -6
- package/dist/prompt-clack.d.ts +1 -1
- package/dist/prompt-clack.js +2 -2
- package/dist/prompt-inquirer.d.ts +1 -1
- package/dist/prompt-inquirer.js +2 -2
- package/dist/prompt.d.ts +1 -1
- package/dist/prompt.js +2 -2
- package/dist/{register-Bk0K83W2.js → register-DlGnMLIY.js} +2 -1
- package/dist/{runner-D72I7wvK.js → runner-DAGvxV2P.js} +70 -46
- package/dist/runner-MMjpKeEa.js +3 -0
- package/dist/skill.d.ts +1 -1
- package/dist/skill.js +6 -3
- package/dist/src-CLogLsbS.js +12 -0
- package/dist/src-bYH2XCQ4.js +6 -0
- package/package.json +2 -2
- package/dist/cli-main-Dn88vIyn.js +0 -84
- package/dist/cli-run-eibUcgys.js +0 -7
- package/dist/runner-FvUwOHyE.js +0 -3
package/README.md
CHANGED
|
@@ -475,7 +475,7 @@ politty integrates Node.js's on-disk compile cache (V8 code cache, Node >= 22.8.
|
|
|
475
475
|
}
|
|
476
476
|
```
|
|
477
477
|
|
|
478
|
-
`generate-shim` writes an executable shim that enables the cache and loads `--entry` (a specifier relative to the shim) with a dynamic import. The
|
|
478
|
+
`generate-shim` writes an executable shim that enables the cache and loads `--entry` (a specifier relative to the shim) with a dynamic import. The output path and program name come from `package.json` (the `bin` path and the `bin` name), and the shim imports the cache helper from the politty package whose `politty` bin you ran — the one you installed, so it resolves from your package. Packages with multiple bins pass `--entry` once per bin, and `--entry` itself can be omitted when the entry sits next to the shim under a conventional name (`./cli.js`, `./index.js`, ...). See [Faster Startup (Compile Cache)](./docs/recipes.md#faster-startup-compile-cache) for the flags, the opt-out (`compileCache: false`), and the hand-written shim variant.
|
|
479
479
|
|
|
480
480
|
## Skill Management
|
|
481
481
|
|
|
@@ -438,7 +438,7 @@ interface MainOptions {
|
|
|
438
438
|
*
|
|
439
439
|
* The `NODE_COMPILE_CACHE` environment variable always takes precedence.
|
|
440
440
|
* Note: the entry module's static import graph is compiled before `runMain`
|
|
441
|
-
* runs and cannot be cached here — see `
|
|
441
|
+
* runs and cannot be cached here — see the `compile-cache` subpath for the
|
|
442
442
|
* bin-shim pattern that covers it.
|
|
443
443
|
*/
|
|
444
444
|
compileCache?: boolean | string;
|
package/dist/augment.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import "./
|
|
3
|
-
import "./
|
|
1
|
+
import { a as internalField, i as internalArgs } from "./schema-extractor-DMSozq40.js";
|
|
2
|
+
import { n as defineCommand } from "./command-k-4yAz4J.js";
|
|
3
|
+
import { n as runMain } from "./runner-DAGvxV2P.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";
|
|
@@ -10,10 +10,14 @@ import { fileURLToPath } from "node:url";
|
|
|
10
10
|
* Generator for compile-cache bin shims.
|
|
11
11
|
*
|
|
12
12
|
* Emits the minimal entry file described in docs/recipes.md ("Faster
|
|
13
|
-
* Startup"): a shim that enables the Node.js on-disk compile cache
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
13
|
+
* Startup"): a shim that enables the Node.js on-disk compile cache and then
|
|
14
|
+
* loads the real CLI with a dynamic import. Meant to be wired into a
|
|
15
|
+
* `postbuild` or `prepack` script via `politty generate-shim` so the shim
|
|
16
|
+
* never has to live in source.
|
|
17
|
+
*
|
|
18
|
+
* Each politty package binds its own generator with
|
|
19
|
+
* {@link createCompileCacheShimGenerator}, so the shim imports the cache
|
|
20
|
+
* helper from the package that generated it.
|
|
17
21
|
*/
|
|
18
22
|
/**
|
|
19
23
|
* Marker identifying files this generator wrote (overwrite guard). Must be
|
|
@@ -87,7 +91,7 @@ function defaultEntry(outputPath) {
|
|
|
87
91
|
if (existsSync(join(dir, candidate))) return candidate;
|
|
88
92
|
}
|
|
89
93
|
}
|
|
90
|
-
function shimContent(program, entry) {
|
|
94
|
+
function shimContent(program, entry, compileCacheSpecifier) {
|
|
91
95
|
return [
|
|
92
96
|
"#!/usr/bin/env node",
|
|
93
97
|
"",
|
|
@@ -96,11 +100,12 @@ function shimContent(program, entry) {
|
|
|
96
100
|
"// CLI module graph is compiled, so warm starts skip recompilation",
|
|
97
101
|
"// (Node >= 22.8.0; silent no-op otherwise).",
|
|
98
102
|
"try {",
|
|
99
|
-
|
|
103
|
+
` const { enableCompileCache } = await import(${JSON.stringify(compileCacheSpecifier)});`,
|
|
100
104
|
` enableCompileCache(${JSON.stringify(program)});`,
|
|
101
105
|
"} catch {",
|
|
102
|
-
|
|
103
|
-
" // start without the compile cache rather than failing
|
|
106
|
+
` // ${compileCacheSpecifier} is not resolvable from here (e.g. a fully`,
|
|
107
|
+
" // bundled CLI) — start without the compile cache rather than failing",
|
|
108
|
+
" // the CLI.",
|
|
104
109
|
"}",
|
|
105
110
|
`await import(${JSON.stringify(entry)});`,
|
|
106
111
|
""
|
|
@@ -111,13 +116,24 @@ function toArray(value) {
|
|
|
111
116
|
return Array.isArray(value) ? value : [value];
|
|
112
117
|
}
|
|
113
118
|
/**
|
|
114
|
-
*
|
|
119
|
+
* Build the shim generator for one politty package.
|
|
120
|
+
*
|
|
121
|
+
* `ownerPackage` is the npm name of the package the generator is exported
|
|
122
|
+
* from (`@politty/zod`, `@politty/valibot`, `politty`), and the shim imports
|
|
123
|
+
* `enableCompileCache` from its `compile-cache` subpath. Taking the name from
|
|
124
|
+
* the owner rather than guessing it is what makes the specifier reliable:
|
|
125
|
+
* reaching this generator at all — through that package's bin or through an
|
|
126
|
+
* import of it — means the package is installed in the host, so the specifier
|
|
127
|
+
* resolves from the shim that lands there. The alternative, reading the host's
|
|
128
|
+
* `package.json`, could only guess which of the three politty packages was
|
|
129
|
+
* meant.
|
|
115
130
|
*
|
|
116
|
-
*
|
|
117
|
-
* nearest `package.json`, each
|
|
118
|
-
* to it — so a bare
|
|
119
|
-
*
|
|
120
|
-
* `
|
|
131
|
+
* The returned function generates executable shims. With no explicit paths,
|
|
132
|
+
* one is generated per `bin` entry of the nearest `package.json`, each
|
|
133
|
+
* importing a conventional built module next to it — so a bare
|
|
134
|
+
* `politty generate-shim` in a `postbuild` script is usually enough. Explicit
|
|
135
|
+
* `entry` values are paired in order with the `bin` entries (or with explicit
|
|
136
|
+
* `out` values of the same count).
|
|
121
137
|
*
|
|
122
138
|
* The generated files are ESM (they use top-level `await import`), so `.js`
|
|
123
139
|
* output requires `"type": "module"` in the package; use a `.mjs` extension
|
|
@@ -125,7 +141,10 @@ function toArray(value) {
|
|
|
125
141
|
* a `bin` path still pointing at the real CLI entry fails loudly instead of
|
|
126
142
|
* clobbering the build output.
|
|
127
143
|
*/
|
|
128
|
-
function
|
|
144
|
+
function createCompileCacheShimGenerator(ownerPackage) {
|
|
145
|
+
return (options = {}) => generateShims(`${ownerPackage}/compile-cache`, options);
|
|
146
|
+
}
|
|
147
|
+
function generateShims(defaultCompileCacheSpecifier, options) {
|
|
129
148
|
const cwd = options.cwd ?? process.cwd();
|
|
130
149
|
const found = readNearestPackageJson(cwd);
|
|
131
150
|
const pkg = found?.pkg;
|
|
@@ -145,6 +164,8 @@ function generateCompileCacheShim(options = {}) {
|
|
|
145
164
|
const binNameByPath = /* @__PURE__ */ new Map();
|
|
146
165
|
if (found) for (const [name, path] of bins) binNameByPath.set(resolve(found.dir, path), name);
|
|
147
166
|
const warnings = [];
|
|
167
|
+
const compileCacheSpecifier = options.compileCacheSpecifier ?? defaultCompileCacheSpecifier;
|
|
168
|
+
if (/[\r\n\u2028\u2029]/.test(compileCacheSpecifier)) throw new Error(`Invalid compile-cache specifier ${JSON.stringify(compileCacheSpecifier)}: a module specifier cannot contain a line terminator.`);
|
|
148
169
|
const plans = outputPaths.map((outputPath, index) => {
|
|
149
170
|
const matchedBinName = binNameByPath.get(outputPath);
|
|
150
171
|
const program = options.program ?? matchedBinName ?? defaultProgramName(pkg);
|
|
@@ -168,13 +189,14 @@ function generateCompileCacheShim(options = {}) {
|
|
|
168
189
|
return {
|
|
169
190
|
outputPath,
|
|
170
191
|
program,
|
|
171
|
-
entry
|
|
192
|
+
entry,
|
|
193
|
+
compileCacheSpecifier
|
|
172
194
|
};
|
|
173
195
|
});
|
|
174
196
|
for (const warning of warnings) console.warn(warning);
|
|
175
197
|
for (const { outputPath, program, entry } of plans) {
|
|
176
198
|
mkdirSync(dirname(outputPath), { recursive: true });
|
|
177
|
-
writeFileSync(outputPath, shimContent(program, entry));
|
|
199
|
+
writeFileSync(outputPath, shimContent(program, entry, compileCacheSpecifier));
|
|
178
200
|
chmodSync(outputPath, 493);
|
|
179
201
|
}
|
|
180
202
|
return plans;
|
|
@@ -188,4 +210,105 @@ function formatShimPath(outputPath, cwd) {
|
|
|
188
210
|
}
|
|
189
211
|
|
|
190
212
|
//#endregion
|
|
191
|
-
|
|
213
|
+
//#region ../core/src/cli-main.ts
|
|
214
|
+
const generateWorkerArgsSchema = internalArgs({
|
|
215
|
+
bin: internalField.string({
|
|
216
|
+
description: "CLI binary or built JS entry file to invoke",
|
|
217
|
+
placeholder: "PATH"
|
|
218
|
+
}),
|
|
219
|
+
program: internalField.string({
|
|
220
|
+
description: "Program name embedded in worker metadata",
|
|
221
|
+
placeholder: "NAME"
|
|
222
|
+
}),
|
|
223
|
+
shell: internalField.enum([
|
|
224
|
+
"bash",
|
|
225
|
+
"zsh",
|
|
226
|
+
"fish"
|
|
227
|
+
], {
|
|
228
|
+
description: "Shell worker to generate",
|
|
229
|
+
placeholder: "SHELL"
|
|
230
|
+
}),
|
|
231
|
+
out: internalField.optionalString({
|
|
232
|
+
description: "Output worker path (defaults to dist/completion/<shell>-worker.<ext>)",
|
|
233
|
+
placeholder: "PATH"
|
|
234
|
+
}),
|
|
235
|
+
verify: internalField.boolean({ description: "Verify __completion-worker-path resolves to the generated worker" })
|
|
236
|
+
});
|
|
237
|
+
const generateWorkerCommand = defineCommand({
|
|
238
|
+
name: "generate-worker",
|
|
239
|
+
description: "Generate and verify a bundled shell completion worker",
|
|
240
|
+
args: generateWorkerArgsSchema,
|
|
241
|
+
async run(args) {
|
|
242
|
+
const { generateBundledCompletionWorker } = await import("./src-CLogLsbS.js");
|
|
243
|
+
await generateBundledCompletionWorker({
|
|
244
|
+
bin: args.bin,
|
|
245
|
+
programName: args.program,
|
|
246
|
+
shell: args.shell,
|
|
247
|
+
...args.out !== void 0 && { outputPath: args.out },
|
|
248
|
+
verify: args.verify
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
const generateShimArgsSchema = internalArgs({
|
|
253
|
+
entry: internalField.optionalStringArray({
|
|
254
|
+
description: "Module specifier the shim imports, relative to the shim file; repeatable, one per bin/--out (defaults to ./cli.js, ./cli.mjs, ./index.js, or ./index.mjs next to each shim)",
|
|
255
|
+
placeholder: "SPECIFIER"
|
|
256
|
+
}),
|
|
257
|
+
out: internalField.optionalStringArray({
|
|
258
|
+
description: "Output path for the generated shim; repeatable, one per --entry (defaults to the bin paths in package.json)",
|
|
259
|
+
placeholder: "PATH"
|
|
260
|
+
}),
|
|
261
|
+
program: internalField.optionalString({
|
|
262
|
+
description: "Program name for the cache directory, applied to all shims (defaults per shim to its bin name)",
|
|
263
|
+
placeholder: "NAME"
|
|
264
|
+
}),
|
|
265
|
+
compileCacheSpecifier: internalField.optionalString({
|
|
266
|
+
description: "Module specifier the shim imports enableCompileCache from (defaults to the compile-cache subpath of the politty package running this command)",
|
|
267
|
+
placeholder: "SPECIFIER"
|
|
268
|
+
})
|
|
269
|
+
});
|
|
270
|
+
/**
|
|
271
|
+
* Run politty's own development CLI (`generate-shim`, `generate-worker`).
|
|
272
|
+
*
|
|
273
|
+
* `ownerPackage` is the npm name of the politty package providing the `politty`
|
|
274
|
+
* bin that invoked this — `@politty/zod`, `@politty/valibot`, or `politty`. It
|
|
275
|
+
* is threaded through to {@link createCompileCacheShimGenerator} so a generated
|
|
276
|
+
* shim imports the cache helper from the package the user actually installed,
|
|
277
|
+
* which is the one guaranteed to resolve from their own package.
|
|
278
|
+
*
|
|
279
|
+
* Never returns: it exits the process, like `runMain`.
|
|
280
|
+
*/
|
|
281
|
+
function runPolittyCli(ownerPackage) {
|
|
282
|
+
const generateCompileCacheShim = createCompileCacheShimGenerator(ownerPackage);
|
|
283
|
+
const generateShimCommand = defineCommand({
|
|
284
|
+
name: "generate-shim",
|
|
285
|
+
description: "Generate a compile-cache bin shim that loads the real CLI via dynamic import",
|
|
286
|
+
args: generateShimArgsSchema,
|
|
287
|
+
run(args) {
|
|
288
|
+
const cwd = process.cwd();
|
|
289
|
+
const results = generateCompileCacheShim({
|
|
290
|
+
...args.entry !== void 0 && { entry: args.entry },
|
|
291
|
+
...args.out !== void 0 && { out: args.out },
|
|
292
|
+
...args.program !== void 0 && { program: args.program },
|
|
293
|
+
...args.compileCacheSpecifier !== void 0 && { compileCacheSpecifier: args.compileCacheSpecifier },
|
|
294
|
+
cwd
|
|
295
|
+
});
|
|
296
|
+
for (const result of results) console.log(`Generated compile-cache shim: ${formatShimPath(result.outputPath, cwd)} (program: ${result.program}, entry: ${result.entry}, compile-cache: ${result.compileCacheSpecifier})`);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
const cli = defineCommand({
|
|
300
|
+
name: "politty",
|
|
301
|
+
description: "politty development utilities",
|
|
302
|
+
subCommands: {
|
|
303
|
+
"generate-shim": generateShimCommand,
|
|
304
|
+
"generate-worker": generateWorkerCommand
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
return runMain(cli).catch((error) => {
|
|
308
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
309
|
+
process.exit(1);
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
//#endregion
|
|
314
|
+
export { createCompileCacheShimGenerator as n, runPolittyCli as t };
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { n as enableCompileCache } from "./compile-cache-
|
|
2
|
+
import { n as enableCompileCache } from "./compile-cache-BC65o7MH.js";
|
|
3
3
|
|
|
4
4
|
//#region src/cli.ts
|
|
5
5
|
/**
|
|
@@ -10,7 +10,7 @@ import { n as enableCompileCache } from "./compile-cache-Ct41pWGL.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-wxd6kPPf.js");
|
|
14
14
|
|
|
15
15
|
//#endregion
|
|
16
16
|
export { };
|
|
@@ -15,7 +15,10 @@ import { homedir } from "node:os";
|
|
|
15
15
|
*
|
|
16
16
|
* ```ts
|
|
17
17
|
* #!/usr/bin/env node
|
|
18
|
-
*
|
|
18
|
+
* // Import from the `compile-cache` subpath of the politty package your CLI
|
|
19
|
+
* // depends on — `politty generate-shim` writes that specifier for you,
|
|
20
|
+
* // naming whichever package's bin generated the shim.
|
|
21
|
+
* import { enableCompileCache } from "<your-politty-package>/compile-cache";
|
|
19
22
|
*
|
|
20
23
|
* enableCompileCache("my-cli");
|
|
21
24
|
* await import("./cli.js");
|
package/dist/compile-cache.d.ts
CHANGED
|
@@ -11,7 +11,10 @@
|
|
|
11
11
|
*
|
|
12
12
|
* ```ts
|
|
13
13
|
* #!/usr/bin/env node
|
|
14
|
-
*
|
|
14
|
+
* // Import from the `compile-cache` subpath of the politty package your CLI
|
|
15
|
+
* // depends on — `politty generate-shim` writes that specifier for you,
|
|
16
|
+
* // naming whichever package's bin generated the shim.
|
|
17
|
+
* import { enableCompileCache } from "<your-politty-package>/compile-cache";
|
|
15
18
|
*
|
|
16
19
|
* enableCompileCache("my-cli");
|
|
17
20
|
* await import("./cli.js");
|
package/dist/compile-cache.js
CHANGED
|
@@ -4,8 +4,8 @@ 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";
|
|
6
6
|
import { dirname, extname, isAbsolute, join, relative, resolve } from "node:path";
|
|
7
|
-
import { execFile, execSync, spawn } from "node:child_process";
|
|
8
7
|
import { promisify } from "node:util";
|
|
8
|
+
import { execFile, execSync, spawn } from "node:child_process";
|
|
9
9
|
|
|
10
10
|
//#region ../core/src/completion/shell-shared.ts
|
|
11
11
|
/**
|
|
@@ -2757,7 +2757,7 @@ async function runTargetBin(bin, args, opts) {
|
|
|
2757
2757
|
...opts.env
|
|
2758
2758
|
},
|
|
2759
2759
|
encoding: "utf8",
|
|
2760
|
-
maxBuffer:
|
|
2760
|
+
maxBuffer: 10485760
|
|
2761
2761
|
});
|
|
2762
2762
|
return {
|
|
2763
2763
|
stdout,
|
|
@@ -3882,7 +3882,8 @@ function createDynamicCompleteCommand(rootCommand, _programName, globalArgsSchem
|
|
|
3882
3882
|
const context = parseCompletionContext(args.args, rootCommand, globalArgsSchema);
|
|
3883
3883
|
const inlinePrefix = context.completionType === "option-value" && context.targetOption ? detectInlineOptionPrefix(context.currentWord) : void 0;
|
|
3884
3884
|
const effectiveWord = inlinePrefix ? context.currentWord.slice(inlinePrefix.length) : context.currentWord;
|
|
3885
|
-
const
|
|
3885
|
+
const result = await generateCandidates(context, { shell: args.shell });
|
|
3886
|
+
const output = formatForShell(result, {
|
|
3886
3887
|
shell: args.shell,
|
|
3887
3888
|
currentWord: effectiveWord,
|
|
3888
3889
|
inlinePrefix
|
|
@@ -4587,8 +4588,12 @@ function defaultCacheDir(programName) {
|
|
|
4587
4588
|
* `$XDG_CONFIG_HOME` / `$HOME`.
|
|
4588
4589
|
*/
|
|
4589
4590
|
function installPath(programName, shell, cacheDir) {
|
|
4590
|
-
if (shell === "fish")
|
|
4591
|
-
|
|
4591
|
+
if (shell === "fish") {
|
|
4592
|
+
const cfg = process.env.XDG_CONFIG_HOME ?? `${process.env.HOME ?? ""}/.config`;
|
|
4593
|
+
return join(cfg, "fish", "completions", `${programName}.fish`);
|
|
4594
|
+
}
|
|
4595
|
+
const dir = cacheDir ?? defaultCacheDir(programName);
|
|
4596
|
+
return join(dir, `completion.${shell}`);
|
|
4592
4597
|
}
|
|
4593
4598
|
/** Atomic write: tmp file in the same dir, then rename. */
|
|
4594
4599
|
function writeAtomic(path, content) {
|
package/dist/completion.d.ts
CHANGED
|
@@ -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-
|
|
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, 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";
|
|
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-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";
|
|
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-
|
|
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";
|
|
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,8 +1,8 @@
|
|
|
1
1
|
import { a as getValidatorAdapter } from "./field-meta-DMy5BcRr.js";
|
|
2
|
-
import "./register-
|
|
2
|
+
import "./register-DlGnMLIY.js";
|
|
3
3
|
import { n as getExtractedFields, t as extractFields } from "./schema-extractor-DMSozq40.js";
|
|
4
|
-
import { r as resolveLazyCommand } from "./subcommand-router-Cskpofdk.js";
|
|
5
4
|
import { t as createLogCollector } from "./log-collector-CoUkLVJB.js";
|
|
5
|
+
import { r as resolveLazyCommand } from "./subcommand-router-Cskpofdk.js";
|
|
6
6
|
import * as fs from "node:fs";
|
|
7
7
|
import * as path$1 from "node:path";
|
|
8
8
|
import path from "node:path";
|
|
@@ -67,10 +67,19 @@ function toOptionRows(options) {
|
|
|
67
67
|
return options.map(toOptionRow);
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
|
-
*
|
|
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, "\\|")
|
|
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, "\\|")
|
|
322
|
+
return inlineMarkdownBreaks(str.replace(/\|/g, "\\|"));
|
|
313
323
|
}
|
|
314
324
|
/**
|
|
315
325
|
* Render usage line
|
|
@@ -346,7 +356,7 @@ function renderArgumentsList(info) {
|
|
|
346
356
|
const lines = [];
|
|
347
357
|
for (const arg of info.positionalArgs) {
|
|
348
358
|
const required = arg.required ? "(required)" : "(optional)";
|
|
349
|
-
const desc = arg.description ? ` - ${arg.description}` : "";
|
|
359
|
+
const desc = arg.description ? ` - ${inlineMarkdownBreaks(arg.description)}` : "";
|
|
350
360
|
lines.push(`- \`${arg.name}\`${desc} ${required}`);
|
|
351
361
|
}
|
|
352
362
|
return lines.join("\n");
|
|
@@ -503,7 +513,7 @@ function renderArgumentsListFromArray(args) {
|
|
|
503
513
|
const lines = [];
|
|
504
514
|
for (const arg of args) {
|
|
505
515
|
const required = arg.required ? "(required)" : "(optional)";
|
|
506
|
-
const desc = arg.description ? ` - ${arg.description}` : "";
|
|
516
|
+
const desc = arg.description ? ` - ${inlineMarkdownBreaks(arg.description)}` : "";
|
|
507
517
|
lines.push(`- \`${arg.name}\`${desc} ${required}`);
|
|
508
518
|
}
|
|
509
519
|
return lines.join("\n");
|
|
@@ -921,7 +931,7 @@ async function executeSingleExample(example, rootCommand, commandPath) {
|
|
|
921
931
|
collector.start();
|
|
922
932
|
let success = true;
|
|
923
933
|
try {
|
|
924
|
-
const { runCommand } = await import("./runner-
|
|
934
|
+
const { runCommand } = await import("./runner-MMjpKeEa.js");
|
|
925
935
|
const result = await runCommand(rootCommand, argv);
|
|
926
936
|
success = result.success;
|
|
927
937
|
if (!result.success && result.error) console.error(result.error.message);
|
|
@@ -2882,7 +2892,8 @@ async function generateDoc(config) {
|
|
|
2882
2892
|
} else if (parsed.kind === "global-options") if (normalizedTemplateGlobalOptions) replacements.set(placeholder, buildGlobalOptionsContent(normalizedTemplateGlobalOptions));
|
|
2883
2893
|
else replacements.set(placeholder, "");
|
|
2884
2894
|
else if (parsed.kind === "index") {
|
|
2885
|
-
const
|
|
2895
|
+
const categories = [...deriveIndexFromFiles(files, outputPath, allCommands, ignores), ...deriveIndexFromTemplateOutputs(templateMeta, outputPath, outputPath, allCommands)];
|
|
2896
|
+
const indexContent = await renderCommandIndex(command, categories, rootDoc?.index);
|
|
2886
2897
|
replacements.set(placeholder, indexContent);
|
|
2887
2898
|
}
|
|
2888
2899
|
}
|
|
@@ -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-
|
|
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";
|
|
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-
|
|
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 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";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region ../core/src/core/schema-extractor.d.ts
|
|
5
5
|
/**
|
|
@@ -43,18 +43,38 @@ type ValidationResult<T> = {
|
|
|
43
43
|
errors: ValidationError[];
|
|
44
44
|
};
|
|
45
45
|
//#endregion
|
|
46
|
+
//#region ../core/src/cli-main.d.ts
|
|
47
|
+
/**
|
|
48
|
+
* Run politty's own development CLI (`generate-shim`, `generate-worker`).
|
|
49
|
+
*
|
|
50
|
+
* `ownerPackage` is the npm name of the politty package providing the `politty`
|
|
51
|
+
* bin that invoked this — `@politty/zod`, `@politty/valibot`, or `politty`. It
|
|
52
|
+
* is threaded through to {@link createCompileCacheShimGenerator} so a generated
|
|
53
|
+
* shim imports the cache helper from the package the user actually installed,
|
|
54
|
+
* which is the one guaranteed to resolve from their own package.
|
|
55
|
+
*
|
|
56
|
+
* Never returns: it exits the process, like `runMain`.
|
|
57
|
+
*/
|
|
58
|
+
declare function runPolittyCli(ownerPackage: string): Promise<never>;
|
|
59
|
+
//#endregion
|
|
46
60
|
//#region ../core/src/compile-cache-shim.d.ts
|
|
47
61
|
/**
|
|
48
62
|
* Generator for compile-cache bin shims.
|
|
49
63
|
*
|
|
50
64
|
* Emits the minimal entry file described in docs/recipes.md ("Faster
|
|
51
|
-
* Startup"): a shim that enables the Node.js on-disk compile cache
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
65
|
+
* Startup"): a shim that enables the Node.js on-disk compile cache and then
|
|
66
|
+
* loads the real CLI with a dynamic import. Meant to be wired into a
|
|
67
|
+
* `postbuild` or `prepack` script via `politty generate-shim` so the shim
|
|
68
|
+
* never has to live in source.
|
|
69
|
+
*
|
|
70
|
+
* Each politty package binds its own generator with
|
|
71
|
+
* {@link createCompileCacheShimGenerator}, so the shim imports the cache
|
|
72
|
+
* helper from the package that generated it.
|
|
55
73
|
*/
|
|
56
74
|
/**
|
|
57
|
-
* Options for
|
|
75
|
+
* Options for the generator returned by
|
|
76
|
+
* {@link createCompileCacheShimGenerator} — exported as
|
|
77
|
+
* `generateCompileCacheShim` from each politty package.
|
|
58
78
|
*/
|
|
59
79
|
interface GenerateCompileCacheShimOptions {
|
|
60
80
|
/**
|
|
@@ -86,9 +106,18 @@ interface GenerateCompileCacheShimOptions {
|
|
|
86
106
|
* `package.json` (default: `process.cwd()`).
|
|
87
107
|
*/
|
|
88
108
|
cwd?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Module specifier the shim imports `enableCompileCache` from. Defaults to
|
|
111
|
+
* the `compile-cache` subpath of the politty package this generator belongs
|
|
112
|
+
* to (see {@link createCompileCacheShimGenerator}). Set this when politty is
|
|
113
|
+
* reached some other way — a re-export from your own package, an import
|
|
114
|
+
* map, and so on.
|
|
115
|
+
*/
|
|
116
|
+
compileCacheSpecifier?: string;
|
|
89
117
|
}
|
|
90
118
|
/**
|
|
91
|
-
* One generated shim from
|
|
119
|
+
* One generated shim from the generator returned by
|
|
120
|
+
* {@link createCompileCacheShimGenerator}.
|
|
92
121
|
*/
|
|
93
122
|
interface GenerateCompileCacheShimResult {
|
|
94
123
|
/** Absolute path of the generated shim. */
|
|
@@ -97,15 +126,28 @@ interface GenerateCompileCacheShimResult {
|
|
|
97
126
|
program: string;
|
|
98
127
|
/** Entry specifier baked into the shim. */
|
|
99
128
|
entry: string;
|
|
129
|
+
/** Specifier the shim imports `enableCompileCache` from. */
|
|
130
|
+
compileCacheSpecifier: string;
|
|
100
131
|
}
|
|
101
132
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
133
|
+
* Build the shim generator for one politty package.
|
|
134
|
+
*
|
|
135
|
+
* `ownerPackage` is the npm name of the package the generator is exported
|
|
136
|
+
* from (`@politty/zod`, `@politty/valibot`, `politty`), and the shim imports
|
|
137
|
+
* `enableCompileCache` from its `compile-cache` subpath. Taking the name from
|
|
138
|
+
* the owner rather than guessing it is what makes the specifier reliable:
|
|
139
|
+
* reaching this generator at all — through that package's bin or through an
|
|
140
|
+
* import of it — means the package is installed in the host, so the specifier
|
|
141
|
+
* resolves from the shim that lands there. The alternative, reading the host's
|
|
142
|
+
* `package.json`, could only guess which of the three politty packages was
|
|
143
|
+
* meant.
|
|
144
|
+
*
|
|
145
|
+
* The returned function generates executable shims. With no explicit paths,
|
|
146
|
+
* one is generated per `bin` entry of the nearest `package.json`, each
|
|
147
|
+
* importing a conventional built module next to it — so a bare
|
|
148
|
+
* `politty generate-shim` in a `postbuild` script is usually enough. Explicit
|
|
149
|
+
* `entry` values are paired in order with the `bin` entries (or with explicit
|
|
150
|
+
* `out` values of the same count).
|
|
109
151
|
*
|
|
110
152
|
* The generated files are ESM (they use top-level `await import`), so `.js`
|
|
111
153
|
* output requires `"type": "module"` in the package; use a `.mjs` extension
|
|
@@ -113,7 +155,7 @@ interface GenerateCompileCacheShimResult {
|
|
|
113
155
|
* a `bin` path still pointing at the real CLI entry fails loudly instead of
|
|
114
156
|
* clobbering the build output.
|
|
115
157
|
*/
|
|
116
|
-
declare function
|
|
158
|
+
declare function createCompileCacheShimGenerator(ownerPackage: string): (options?: GenerateCompileCacheShimOptions) => GenerateCompileCacheShimResult[];
|
|
117
159
|
//#endregion
|
|
118
160
|
//#region ../core/src/core/case-types.d.ts
|
|
119
161
|
/**
|
|
@@ -786,6 +828,15 @@ declare function validateCommand(command: AnyCommand, options?: ValidateCommandO
|
|
|
786
828
|
declare function formatCommandValidationErrors(errors: CommandValidationError[]): string;
|
|
787
829
|
//#endregion
|
|
788
830
|
//#region src/index.d.ts
|
|
831
|
+
/**
|
|
832
|
+
* Generate compile-cache bin shims that import the cache helper from
|
|
833
|
+
* `@politty/zod/compile-cache`.
|
|
834
|
+
*
|
|
835
|
+
* The specifier is this package's own name rather than something derived from
|
|
836
|
+
* the caller's `package.json`: reaching this function means `@politty/zod` is
|
|
837
|
+
* installed, so the shim it writes into your package can resolve it.
|
|
838
|
+
*/
|
|
839
|
+
declare const generateCompileCacheShim: (options?: GenerateCompileCacheShimOptions) => GenerateCompileCacheShimResult[];
|
|
789
840
|
/**
|
|
790
841
|
* Supported schema types for args in this package: zod schemas whose
|
|
791
842
|
* output is an object. Narrows `@politty/core`'s Standard-Schema-based
|
|
@@ -796,4 +847,4 @@ declare const defineCommand: DefineCommandFn<ArgsSchema>;
|
|
|
796
847
|
declare const createDefineCommand: CreateDefineCommandFn<ArgsSchema>;
|
|
797
848
|
declare const arg: ArgFn<z.ZodType>;
|
|
798
849
|
//#endregion
|
|
799
|
-
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, createDefineCommand, createDualCaseProxy, defineCommand, extractFields, formatCommandValidationErrors, formatValidationErrors, generateBundledCompletionWorker, generateCompileCacheShim, generateCompletion, generateHelp, getUnknownKeysMode, isColorEnabled, isLazyCommand, lazy, logger, parseArgv, renderInline, renderMarkdown, runCommand, runMain, setColorEnabled, styles, symbols, toCamelCase, toKebabCase, validateCaseVariantCollisions, validateCommand, validateCrossSchemaCollisions, validateDuplicateAliases, validateDuplicateFields, validateDuplicateNegations, validatePositionalConfig, validateReservedAliases, validateReservedFieldNames, withCompletionCommand };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
import { i as toKebabCase, r as toCamelCase } from "./field-meta-DMy5BcRr.js";
|
|
2
|
-
import { t as arg$1 } from "./register-
|
|
3
|
-
import { n as generateCompileCacheShim } from "./src-KzC0g5CS.js";
|
|
2
|
+
import { t as arg$1 } from "./register-DlGnMLIY.js";
|
|
4
3
|
import { r as getUnknownKeysMode, t as extractFields } from "./schema-extractor-DMSozq40.js";
|
|
4
|
+
import { n as createCompileCacheShimGenerator, t as runPolittyCli } from "./cli-main-D4kkrRfX.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-DAGvxV2P.js";
|
|
6
7
|
import { o as isLazyCommand, s as lazy } from "./subcommand-router-Cskpofdk.js";
|
|
7
|
-
import { a as generateCompletion, p as generateBundledCompletionWorker, s as withCompletionCommand } from "./completion-gtWX3mwP.js";
|
|
8
|
-
import { C as generateHelp, E as createDualCaseProxy, S as ReservedFieldNameError, T as renderMarkdown, _ as DuplicateFieldError, a as formatCommandValidationErrors, b as PositionalConfigError, c as validateCrossSchemaCollisions, d as validateDuplicateNegations, f as validatePositionalConfig, g as DuplicateAliasError, h as CaseVariantCollisionError, i as parseArgv, l as validateDuplicateAliases, m as validateReservedFieldNames, n as runMain, o as validateCaseVariantCollisions, p as validateReservedAliases, r as formatValidationErrors, s as validateCommand, t as runCommand, u as validateDuplicateFields, v as DuplicateNegationError, w as renderInline, x as ReservedAliasError, y as FieldTypeConflictError } from "./runner-D72I7wvK.js";
|
|
9
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-bYH2XCQ4.js";
|
|
10
11
|
|
|
11
12
|
//#region src/index.ts
|
|
13
|
+
/**
|
|
14
|
+
* Generate compile-cache bin shims that import the cache helper from
|
|
15
|
+
* `@politty/zod/compile-cache`.
|
|
16
|
+
*
|
|
17
|
+
* The specifier is this package's own name rather than something derived from
|
|
18
|
+
* the caller's `package.json`: reaching this function means `@politty/zod` is
|
|
19
|
+
* installed, so the shim it writes into your package can resolve it.
|
|
20
|
+
*/
|
|
21
|
+
const generateCompileCacheShim = createCompileCacheShimGenerator("@politty/zod");
|
|
12
22
|
const defineCommand = defineCommand$1;
|
|
13
23
|
const createDefineCommand = createDefineCommand$1;
|
|
14
24
|
const arg = arg$1;
|
|
15
25
|
|
|
16
26
|
//#endregion
|
|
17
|
-
export { CaseVariantCollisionError, DuplicateAliasError, DuplicateFieldError, DuplicateNegationError, FieldTypeConflictError, PositionalConfigError, ReservedAliasError, ReservedFieldNameError, arg, createDefineCommand, createDualCaseProxy, defineCommand, extractFields, formatCommandValidationErrors, formatValidationErrors, generateBundledCompletionWorker, generateCompileCacheShim, generateCompletion, generateHelp, getUnknownKeysMode, isColorEnabled, isLazyCommand, lazy, logger, parseArgv, renderInline, renderMarkdown, runCommand, runMain, setColorEnabled, styles, symbols, toCamelCase, toKebabCase, validateCaseVariantCollisions, validateCommand, validateCrossSchemaCollisions, validateDuplicateAliases, validateDuplicateFields, validateDuplicateNegations, validatePositionalConfig, validateReservedAliases, validateReservedFieldNames, withCompletionCommand };
|
|
27
|
+
export { CaseVariantCollisionError, DuplicateAliasError, DuplicateFieldError, DuplicateNegationError, FieldTypeConflictError, PositionalConfigError, ReservedAliasError, ReservedFieldNameError, 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 };
|
|
@@ -156,12 +156,10 @@ async function promptAndCollect(adapter, result, config) {
|
|
|
156
156
|
case "confirm":
|
|
157
157
|
value = await adapter.confirm({ message });
|
|
158
158
|
break;
|
|
159
|
-
case "select":
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
});
|
|
164
|
-
break;
|
|
159
|
+
case "select": value = await adapter.select({
|
|
160
|
+
message,
|
|
161
|
+
options: config.choices ?? []
|
|
162
|
+
});
|
|
165
163
|
}
|
|
166
164
|
if (adapter.isCancelled(value)) throw new Error("Prompt cancelled by user");
|
|
167
165
|
result[config.field.name] = value;
|
package/dist/prompt-clack.d.ts
CHANGED
package/dist/prompt-clack.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./register-
|
|
2
|
-
import { t as promptMissingArgs } from "./prompt-
|
|
1
|
+
import "./register-DlGnMLIY.js";
|
|
2
|
+
import { t as promptMissingArgs } from "./prompt-BjIZThsH.js";
|
|
3
3
|
import { confirm, isCancel, password, select, text } from "@clack/prompts";
|
|
4
4
|
|
|
5
5
|
//#region ../core/src/prompt/clack/index.ts
|
package/dist/prompt-inquirer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./register-
|
|
2
|
-
import { t as promptMissingArgs } from "./prompt-
|
|
1
|
+
import "./register-DlGnMLIY.js";
|
|
2
|
+
import { t as promptMissingArgs } from "./prompt-BjIZThsH.js";
|
|
3
3
|
import { confirm, input, password, select } from "@inquirer/prompts";
|
|
4
4
|
|
|
5
5
|
//#region ../core/src/prompt/inquirer/index.ts
|
package/dist/prompt.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { X as ResolvedFieldMeta, Y as ExtractedFields } from "./arg-registry-
|
|
1
|
+
import { X as ResolvedFieldMeta, Y as ExtractedFields } from "./arg-registry-B8QvBM_Q.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-
|
|
2
|
-
import { i as resolvePromptConfig, n as isInteractive, r as getFieldsToPrompt, t as promptMissingArgs } from "./prompt-
|
|
1
|
+
import "./register-DlGnMLIY.js";
|
|
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 };
|
|
@@ -187,8 +187,9 @@ function extractDescription(schema) {
|
|
|
187
187
|
* `resolveFieldMeta` (adapter/field-meta.ts).
|
|
188
188
|
*/
|
|
189
189
|
function resolveZodFieldMeta(name, schema) {
|
|
190
|
+
const argMeta = getArgMeta(schema) ?? getArgMeta(unwrapSchema(schema));
|
|
190
191
|
return resolveFieldMeta(name, {
|
|
191
|
-
argMeta
|
|
192
|
+
argMeta,
|
|
192
193
|
description: extractDescription(schema),
|
|
193
194
|
required: isRequired(schema),
|
|
194
195
|
defaultValue: extractDefaultValue(schema),
|
|
@@ -1,47 +1,11 @@
|
|
|
1
1
|
import { a as getValidatorAdapter, i as toKebabCase, r as toCamelCase, t as getAllAliases } from "./field-meta-DMy5BcRr.js";
|
|
2
2
|
import { n as getExtractedFields, o as isInternalArgsSchema, s as validateInternalArgs, t as extractFields } from "./schema-extractor-DMSozq40.js";
|
|
3
|
-
import {
|
|
4
|
-
import { n as enableCompileCache } from "./compile-cache-Ct41pWGL.js";
|
|
3
|
+
import { n as enableCompileCache } from "./compile-cache-BC65o7MH.js";
|
|
5
4
|
import { n as emptyLogs, r as mergeLogs, t as createLogCollector } from "./log-collector-CoUkLVJB.js";
|
|
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";
|
|
6
6
|
import { a as symbols, i as styles } from "./logger-i_bb-Jhc.js";
|
|
7
7
|
import { stripVTControlCharacters } from "node:util";
|
|
8
8
|
|
|
9
|
-
//#region ../core/src/core/case-proxy.ts
|
|
10
|
-
/**
|
|
11
|
-
* Wrap an args object with a Proxy that allows dual-case access.
|
|
12
|
-
*
|
|
13
|
-
* Given `{ "my-option": "value" }`, both `obj["my-option"]` and `obj.myOption`
|
|
14
|
-
* will return `"value"`.
|
|
15
|
-
*
|
|
16
|
-
* - `Object.keys()`, `JSON.stringify()`, and spread return only the original keys.
|
|
17
|
-
* - The `in` operator detects both case variants.
|
|
18
|
-
*/
|
|
19
|
-
function createDualCaseProxy(obj) {
|
|
20
|
-
return new Proxy(obj, {
|
|
21
|
-
get(target, prop, receiver) {
|
|
22
|
-
if (typeof prop === "string") {
|
|
23
|
-
if (prop in target) return Reflect.get(target, prop, receiver);
|
|
24
|
-
const camel = toCamelCase(prop);
|
|
25
|
-
if (camel !== prop && camel in target) return Reflect.get(target, camel, receiver);
|
|
26
|
-
const kebab = toKebabCase(prop);
|
|
27
|
-
if (kebab !== prop && kebab in target) return Reflect.get(target, kebab, receiver);
|
|
28
|
-
}
|
|
29
|
-
return Reflect.get(target, prop, receiver);
|
|
30
|
-
},
|
|
31
|
-
has(target, prop) {
|
|
32
|
-
if (typeof prop === "string") {
|
|
33
|
-
if (prop in target) return true;
|
|
34
|
-
const camel = toCamelCase(prop);
|
|
35
|
-
if (camel !== prop && camel in target) return true;
|
|
36
|
-
const kebab = toKebabCase(prop);
|
|
37
|
-
if (kebab !== prop && kebab in target) return true;
|
|
38
|
-
}
|
|
39
|
-
return Reflect.has(target, prop);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
//#endregion
|
|
45
9
|
//#region ../core/src/executor/command-runner.ts
|
|
46
10
|
/**
|
|
47
11
|
* Execute a command lifecycle: setup → run → cleanup
|
|
@@ -121,7 +85,9 @@ async function executeLifecycle(command, args, _options = {}) {
|
|
|
121
85
|
}
|
|
122
86
|
}
|
|
123
87
|
collector?.stop();
|
|
124
|
-
const
|
|
88
|
+
const existingLogs = _options.existingLogs ?? emptyLogs();
|
|
89
|
+
const collectedLogs = collector?.getLogs() ?? emptyLogs();
|
|
90
|
+
const logs = mergeLogs(existingLogs, collectedLogs);
|
|
125
91
|
if (error) return {
|
|
126
92
|
success: false,
|
|
127
93
|
error,
|
|
@@ -771,16 +737,31 @@ function padEndVisual(str, width) {
|
|
|
771
737
|
return str + " ".repeat(padding);
|
|
772
738
|
}
|
|
773
739
|
/**
|
|
740
|
+
* Re-indent the continuation lines of a multi-line description so they align
|
|
741
|
+
* under the description column. A `\n` in a description is treated as a hard
|
|
742
|
+
* line break; every line after the first is padded to `column` spaces.
|
|
743
|
+
*/
|
|
744
|
+
function indentDescription(description, column) {
|
|
745
|
+
if (!description.includes("\n")) return description;
|
|
746
|
+
const pad = " ".repeat(column);
|
|
747
|
+
return description.split("\n").join(`\n${pad}`);
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
774
750
|
* Format a single option line
|
|
775
751
|
* If flags exceed the column width, description is moved to the next line
|
|
752
|
+
*
|
|
753
|
+
* Descriptions may contain `\n` line breaks; continuation lines are indented to
|
|
754
|
+
* stay aligned under the description column.
|
|
776
755
|
*/
|
|
777
756
|
function formatOption(flags, description, indent = 0, extraDescPadding = 0) {
|
|
778
757
|
const flagWidth = 32;
|
|
779
758
|
const indentStr = " ".repeat(indent);
|
|
780
759
|
const visualFlagLength = stripAnsi(flags).length;
|
|
781
760
|
const effectiveFlagWidth = flagWidth - indent * 2 + extraDescPadding;
|
|
782
|
-
|
|
783
|
-
|
|
761
|
+
const descColumn = effectiveFlagWidth + 2 + indent * 2;
|
|
762
|
+
const desc = indentDescription(description, descColumn);
|
|
763
|
+
if (visualFlagLength >= effectiveFlagWidth) return `${indentStr} ${flags}\n${" ".repeat(descColumn)}${desc}`;
|
|
764
|
+
return `${indentStr} ${padEndVisual(flags, effectiveFlagWidth)}${desc}`;
|
|
784
765
|
}
|
|
785
766
|
/**
|
|
786
767
|
* Format a single option field as a help line
|
|
@@ -915,7 +896,7 @@ function renderExamplesForHelp(examples, context) {
|
|
|
915
896
|
const cmdPath = context?.commandPath?.join(" ") ?? "";
|
|
916
897
|
const fullPrefix = cmdPath ? `${cmdPrefix}${cmdPath} ` : cmdPrefix;
|
|
917
898
|
for (const example of examples) {
|
|
918
|
-
lines.push(` ${styles.dim(example.desc)}`);
|
|
899
|
+
lines.push(` ${styles.dim(example.desc).split("\n").join("\n ")}`);
|
|
919
900
|
lines.push(` ${styles.dim("$")} ${fullPrefix}${example.cmd}`);
|
|
920
901
|
if (example.output) for (const line of example.output.split("\n")) lines.push(` ${line}`);
|
|
921
902
|
lines.push("");
|
|
@@ -1237,7 +1218,10 @@ function checkReservedFieldNames(extracted, commandPath) {
|
|
|
1237
1218
|
*/
|
|
1238
1219
|
function validateDuplicateFields(extracted) {
|
|
1239
1220
|
const errors = checkDuplicateFields(extracted, []);
|
|
1240
|
-
if (errors.length > 0)
|
|
1221
|
+
if (errors.length > 0) {
|
|
1222
|
+
const field = errors[0]?.field ?? "unknown";
|
|
1223
|
+
throw new DuplicateFieldError(`Duplicate field name "${field}" detected. Each field must have a unique name.`);
|
|
1224
|
+
}
|
|
1241
1225
|
}
|
|
1242
1226
|
/**
|
|
1243
1227
|
* Validate that no duplicate aliases exist
|
|
@@ -2196,7 +2180,9 @@ function parseArgs(argv, command, options = {}) {
|
|
|
2196
2180
|
*/
|
|
2197
2181
|
function parseGlobalArgs(tokens, globalExtracted) {
|
|
2198
2182
|
if (tokens.length === 0) return {};
|
|
2199
|
-
|
|
2183
|
+
const parserOptions = buildParserOptions(globalExtracted);
|
|
2184
|
+
const parsed = parseArgv(tokens, parserOptions);
|
|
2185
|
+
return mergeWithPositionals(parsed, globalExtracted);
|
|
2200
2186
|
}
|
|
2201
2187
|
/**
|
|
2202
2188
|
* Separate global flags from command-local args in argv.
|
|
@@ -2347,6 +2333,42 @@ function formatRuntimeError(error, debug) {
|
|
|
2347
2333
|
return `${styles.error("Error:")} ${error.message}`;
|
|
2348
2334
|
}
|
|
2349
2335
|
|
|
2336
|
+
//#endregion
|
|
2337
|
+
//#region ../core/src/core/case-proxy.ts
|
|
2338
|
+
/**
|
|
2339
|
+
* Wrap an args object with a Proxy that allows dual-case access.
|
|
2340
|
+
*
|
|
2341
|
+
* Given `{ "my-option": "value" }`, both `obj["my-option"]` and `obj.myOption`
|
|
2342
|
+
* will return `"value"`.
|
|
2343
|
+
*
|
|
2344
|
+
* - `Object.keys()`, `JSON.stringify()`, and spread return only the original keys.
|
|
2345
|
+
* - The `in` operator detects both case variants.
|
|
2346
|
+
*/
|
|
2347
|
+
function createDualCaseProxy(obj) {
|
|
2348
|
+
return new Proxy(obj, {
|
|
2349
|
+
get(target, prop, receiver) {
|
|
2350
|
+
if (typeof prop === "string") {
|
|
2351
|
+
if (prop in target) return Reflect.get(target, prop, receiver);
|
|
2352
|
+
const camel = toCamelCase(prop);
|
|
2353
|
+
if (camel !== prop && camel in target) return Reflect.get(target, camel, receiver);
|
|
2354
|
+
const kebab = toKebabCase(prop);
|
|
2355
|
+
if (kebab !== prop && kebab in target) return Reflect.get(target, kebab, receiver);
|
|
2356
|
+
}
|
|
2357
|
+
return Reflect.get(target, prop, receiver);
|
|
2358
|
+
},
|
|
2359
|
+
has(target, prop) {
|
|
2360
|
+
if (typeof prop === "string") {
|
|
2361
|
+
if (prop in target) return true;
|
|
2362
|
+
const camel = toCamelCase(prop);
|
|
2363
|
+
if (camel !== prop && camel in target) return true;
|
|
2364
|
+
const kebab = toKebabCase(prop);
|
|
2365
|
+
if (kebab !== prop && kebab in target) return true;
|
|
2366
|
+
}
|
|
2367
|
+
return Reflect.has(target, prop);
|
|
2368
|
+
}
|
|
2369
|
+
});
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2350
2372
|
//#endregion
|
|
2351
2373
|
//#region ../core/src/core/effect-runner.ts
|
|
2352
2374
|
/**
|
|
@@ -2620,7 +2642,9 @@ async function runCommandInternal(command, argv, options = {}) {
|
|
|
2620
2642
|
const collector = options.captureLogs ?? false ? createLogCollector() : null;
|
|
2621
2643
|
collector?.start();
|
|
2622
2644
|
const getCurrentLogs = () => {
|
|
2623
|
-
|
|
2645
|
+
const existingLogs = options._existingLogs ?? emptyLogs();
|
|
2646
|
+
const collectedLogs = collector?.getLogs() ?? emptyLogs();
|
|
2647
|
+
return mergeLogs(existingLogs, collectedLogs);
|
|
2624
2648
|
};
|
|
2625
2649
|
try {
|
|
2626
2650
|
const parseResult = parseArgs(argv, command, {
|
|
@@ -2953,4 +2977,4 @@ function extractAndValidateGlobal(options) {
|
|
|
2953
2977
|
}
|
|
2954
2978
|
|
|
2955
2979
|
//#endregion
|
|
2956
|
-
export {
|
|
2980
|
+
export { ReservedFieldNameError as C, renderMarkdown as E, ReservedAliasError as S, renderInline as T, DuplicateAliasError as _, parseArgv as a, FieldTypeConflictError as b, validateCommand as c, validateDuplicateFields as d, validateDuplicateNegations as f, CaseVariantCollisionError as g, validateReservedFieldNames as h, formatValidationErrors as i, validateCrossSchemaCollisions as l, validateReservedAliases as m, runMain as n, formatCommandValidationErrors as o, validatePositionalConfig as p, createDualCaseProxy as r, validateCaseVariantCollisions as s, runCommand as t, validateDuplicateAliases as u, DuplicateFieldError as v, generateHelp as w, PositionalConfigError as x, DuplicateNegationError as y };
|
package/dist/skill.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Z as UnknownKeysMode, b as ArgsSchema, v as AnyCommand } from "./arg-registry-
|
|
1
|
+
import { Z as UnknownKeysMode, b as ArgsSchema, v as AnyCommand } from "./arg-registry-B8QvBM_Q.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
//#region ../core/src/skill/types.d.ts
|
|
4
4
|
/**
|
package/dist/skill.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./register-
|
|
1
|
+
import "./register-DlGnMLIY.js";
|
|
2
2
|
import { a as internalField, i as internalArgs, t as extractFields } from "./schema-extractor-DMSozq40.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";
|
|
@@ -712,8 +712,9 @@ function populateAgentDirs(cwd, name, canonicalDir, expectedStamp, mode) {
|
|
|
712
712
|
const resolvedTargetParent = realpathSync(targetParent);
|
|
713
713
|
const targetDir = join(resolvedTargetParent, name);
|
|
714
714
|
clearInstallSlot(targetDir, expectedStamp, { restrictSymlinkTo: canonicalDir });
|
|
715
|
+
const resolvedCanonicalParent = realpathSync(resolve(canonicalDir, ".."));
|
|
715
716
|
symlinkOrCopy({
|
|
716
|
-
linkTarget: join(relative(resolvedTargetParent,
|
|
717
|
+
linkTarget: join(relative(resolvedTargetParent, resolvedCanonicalParent), name),
|
|
717
718
|
linkPath: targetDir,
|
|
718
719
|
copyFrom: canonicalDir,
|
|
719
720
|
mode
|
|
@@ -1394,7 +1395,9 @@ function danglingRoutesToSource(canonical, sourceDir) {
|
|
|
1394
1395
|
return false;
|
|
1395
1396
|
}
|
|
1396
1397
|
const absoluteTarget = isAbsolute(raw) ? raw : resolve(dirname(canonical), raw);
|
|
1397
|
-
const
|
|
1398
|
+
const resolvedSource = resolveDeepestExisting(resolve(sourceDir));
|
|
1399
|
+
const resolvedTarget = resolveDeepestExisting(absoluteTarget);
|
|
1400
|
+
const rel = relative(resolvedSource, resolvedTarget);
|
|
1398
1401
|
if (isAbsolute(rel)) return false;
|
|
1399
1402
|
if (rel === ".." || rel.startsWith(`..${sep}`)) return false;
|
|
1400
1403
|
return true;
|
|
@@ -0,0 +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-D4kkrRfX.js";
|
|
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-DAGvxV2P.js";
|
|
7
|
+
import { o as isLazyCommand, s as lazy } from "./subcommand-router-Cskpofdk.js";
|
|
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-bYH2XCQ4.js";
|
|
11
|
+
|
|
12
|
+
export { generateBundledCompletionWorker };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@politty/zod",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
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.
|
|
74
|
+
"yaml": "^2.9.0"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@types/node": "25.9.5",
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { n as generateCompileCacheShim, t as formatShimPath } from "./src-KzC0g5CS.js";
|
|
2
|
-
import { a as internalField, i as internalArgs } from "./schema-extractor-DMSozq40.js";
|
|
3
|
-
import { n as defineCommand } from "./command-k-4yAz4J.js";
|
|
4
|
-
import { p as generateBundledCompletionWorker } from "./completion-gtWX3mwP.js";
|
|
5
|
-
import { n as runMain } from "./runner-D72I7wvK.js";
|
|
6
|
-
|
|
7
|
-
//#region ../core/src/cli-main.ts
|
|
8
|
-
const generateWorkerCommand = defineCommand({
|
|
9
|
-
name: "generate-worker",
|
|
10
|
-
description: "Generate and verify a bundled shell completion worker",
|
|
11
|
-
args: internalArgs({
|
|
12
|
-
bin: internalField.string({
|
|
13
|
-
description: "CLI binary or built JS entry file to invoke",
|
|
14
|
-
placeholder: "PATH"
|
|
15
|
-
}),
|
|
16
|
-
program: internalField.string({
|
|
17
|
-
description: "Program name embedded in worker metadata",
|
|
18
|
-
placeholder: "NAME"
|
|
19
|
-
}),
|
|
20
|
-
shell: internalField.enum([
|
|
21
|
-
"bash",
|
|
22
|
-
"zsh",
|
|
23
|
-
"fish"
|
|
24
|
-
], {
|
|
25
|
-
description: "Shell worker to generate",
|
|
26
|
-
placeholder: "SHELL"
|
|
27
|
-
}),
|
|
28
|
-
out: internalField.optionalString({
|
|
29
|
-
description: "Output worker path (defaults to dist/completion/<shell>-worker.<ext>)",
|
|
30
|
-
placeholder: "PATH"
|
|
31
|
-
}),
|
|
32
|
-
verify: internalField.boolean({ description: "Verify __completion-worker-path resolves to the generated worker" })
|
|
33
|
-
}),
|
|
34
|
-
async run(args) {
|
|
35
|
-
await generateBundledCompletionWorker({
|
|
36
|
-
bin: args.bin,
|
|
37
|
-
programName: args.program,
|
|
38
|
-
shell: args.shell,
|
|
39
|
-
...args.out !== void 0 && { outputPath: args.out },
|
|
40
|
-
verify: args.verify
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
runMain(defineCommand({
|
|
45
|
-
name: "politty",
|
|
46
|
-
description: "politty development utilities",
|
|
47
|
-
subCommands: {
|
|
48
|
-
"generate-shim": defineCommand({
|
|
49
|
-
name: "generate-shim",
|
|
50
|
-
description: "Generate a compile-cache bin shim that loads the real CLI via dynamic import",
|
|
51
|
-
args: internalArgs({
|
|
52
|
-
entry: internalField.optionalStringArray({
|
|
53
|
-
description: "Module specifier the shim imports, relative to the shim file; repeatable, one per bin/--out (defaults to ./cli.js, ./cli.mjs, ./index.js, or ./index.mjs next to each shim)",
|
|
54
|
-
placeholder: "SPECIFIER"
|
|
55
|
-
}),
|
|
56
|
-
out: internalField.optionalStringArray({
|
|
57
|
-
description: "Output path for the generated shim; repeatable, one per --entry (defaults to the bin paths in package.json)",
|
|
58
|
-
placeholder: "PATH"
|
|
59
|
-
}),
|
|
60
|
-
program: internalField.optionalString({
|
|
61
|
-
description: "Program name for the cache directory, applied to all shims (defaults per shim to its bin name)",
|
|
62
|
-
placeholder: "NAME"
|
|
63
|
-
})
|
|
64
|
-
}),
|
|
65
|
-
run(args) {
|
|
66
|
-
const cwd = process.cwd();
|
|
67
|
-
const results = generateCompileCacheShim({
|
|
68
|
-
...args.entry !== void 0 && { entry: args.entry },
|
|
69
|
-
...args.out !== void 0 && { out: args.out },
|
|
70
|
-
...args.program !== void 0 && { program: args.program },
|
|
71
|
-
cwd
|
|
72
|
-
});
|
|
73
|
-
for (const result of results) console.log(`Generated compile-cache shim: ${formatShimPath(result.outputPath, cwd)} (program: ${result.program}, entry: ${result.entry})`);
|
|
74
|
-
}
|
|
75
|
-
}),
|
|
76
|
-
"generate-worker": generateWorkerCommand
|
|
77
|
-
}
|
|
78
|
-
})).catch((error) => {
|
|
79
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
80
|
-
process.exit(1);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
//#endregion
|
|
84
|
-
export { };
|
package/dist/cli-run-eibUcgys.js
DELETED
package/dist/runner-FvUwOHyE.js
DELETED