politty 0.11.5 → 0.11.7
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 +30 -1
- package/bin/cli.mjs +3 -0
- package/dist/augment.d.ts +1 -16
- package/dist/augment.js +2 -0
- package/dist/cli-run-DGe88d0G.js +14 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +13 -9
- package/dist/compile-cache.d.ts +1 -79
- package/dist/compile-cache.js +2 -2
- package/dist/completion.d.ts +1 -0
- package/dist/completion.js +3 -0
- package/dist/docs.d.ts +1 -0
- package/dist/docs.js +3 -0
- package/dist/index.d.ts +10 -814
- package/dist/index.js +17 -8
- package/dist/prompt-clack.d.ts +1 -0
- package/dist/prompt-clack.js +3 -0
- package/dist/prompt-inquirer.d.ts +1 -0
- package/dist/prompt-inquirer.js +3 -0
- package/dist/prompt.d.ts +1 -0
- package/dist/prompt.js +3 -0
- package/dist/skill.d.ts +1 -0
- package/dist/skill.js +3 -0
- package/package.json +20 -46
- package/dist/arg-registry-SrNIsq-d.d.ts +0 -981
- package/dist/cli-main.d.ts +0 -1
- package/dist/cli-main.js +0 -86
- package/dist/command-B4yA4LXX.js +0 -43
- package/dist/compile-cache-NnTkjJMV.js +0 -101
- package/dist/completion/index.d.ts +0 -3
- package/dist/completion/index.js +0 -3
- package/dist/completion-D9SKGJad.js +0 -5610
- package/dist/docs/index.d.ts +0 -771
- package/dist/docs/index.js +0 -3024
- package/dist/index-qqwo5WZT.d.ts +0 -673
- package/dist/log-collector-DK32-73m.js +0 -115
- package/dist/logger-DbDkjdfO.js +0 -134
- package/dist/prompt/clack/index.d.ts +0 -17
- package/dist/prompt/clack/index.js +0 -32
- package/dist/prompt/index.d.ts +0 -107
- package/dist/prompt/index.js +0 -3
- package/dist/prompt/inquirer/index.d.ts +0 -17
- package/dist/prompt/inquirer/index.js +0 -47
- package/dist/prompt-Cc8Tfmdv.js +0 -172
- package/dist/runner-BGs_QMJM.js +0 -3
- package/dist/runner-xN7248Ph.js +0 -2966
- package/dist/schema-extractor-wzJ1cGon.js +0 -488
- package/dist/skill/index.d.ts +0 -584
- package/dist/skill/index.js +0 -1756
- package/dist/src-BiCtSNrn.js +0 -193
- package/dist/subcommand-router-CTzHPGzF.js +0 -135
package/README.md
CHANGED
|
@@ -33,6 +33,35 @@ pnpm add politty zod
|
|
|
33
33
|
yarn add politty zod
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
+
### Using valibot instead of zod
|
|
37
|
+
|
|
38
|
+
politty is also available as [`@politty/valibot`](https://www.npmjs.com/package/@politty/valibot), built on [valibot](https://valibot.dev/) schemas — same API (`defineCommand`, `arg`, `runMain`, and all subpath modules), and its published build never loads zod:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install @politty/valibot valibot
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import * as v from "valibot";
|
|
46
|
+
import { defineCommand, runMain, arg } from "@politty/valibot";
|
|
47
|
+
|
|
48
|
+
const command = defineCommand({
|
|
49
|
+
name: "greet",
|
|
50
|
+
args: v.object({
|
|
51
|
+
name: arg(v.string(), { description: "Name to greet", positional: true }),
|
|
52
|
+
loud: arg(v.optional(v.boolean(), false), { alias: "l" }),
|
|
53
|
+
}),
|
|
54
|
+
run: (args) => {
|
|
55
|
+
const greeting = `Hello, ${args.name}!`;
|
|
56
|
+
console.log(args.loud ? greeting.toUpperCase() : greeting);
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
runMain(command);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Field descriptions can also come from valibot's own metadata actions. They are actions, not schemas, so they belong inside `v.pipe(...)`: `v.pipe(v.string(), v.description("..."))` or `v.pipe(v.string(), v.metadata({ description: "..." }))`. The one zod-only feature without a valibot counterpart is the `politty/augment` module (zod `GlobalMeta` interface augmentation) — use `arg()` or `v.metadata()` instead. The `politty` package itself remains the zod flavor (an alias of `@politty/zod`).
|
|
64
|
+
|
|
36
65
|
## Quick Start
|
|
37
66
|
|
|
38
67
|
```typescript
|
|
@@ -446,7 +475,7 @@ politty integrates Node.js's on-disk compile cache (V8 code cache, Node >= 22.8.
|
|
|
446
475
|
}
|
|
447
476
|
```
|
|
448
477
|
|
|
449
|
-
`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.
|
|
450
479
|
|
|
451
480
|
## Skill Management
|
|
452
481
|
|
package/bin/cli.mjs
ADDED
package/dist/augment.d.ts
CHANGED
|
@@ -1,16 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
//#region src/augment.d.ts
|
|
3
|
-
declare module "zod" {
|
|
4
|
-
interface ZodTypeDef {
|
|
5
|
-
argMeta?: ArgMeta;
|
|
6
|
-
}
|
|
7
|
-
interface GlobalMeta {
|
|
8
|
-
description?: string;
|
|
9
|
-
positional?: boolean;
|
|
10
|
-
placeholder?: string;
|
|
11
|
-
alias?: string | string[] | readonly string[];
|
|
12
|
-
hiddenAlias?: string | string[] | readonly string[];
|
|
13
|
-
overrideBuiltinAlias?: boolean;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=augment.d.ts.map
|
|
1
|
+
import "@politty/zod/augment";
|
package/dist/augment.js
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { runPolittyCli } from "@politty/zod";
|
|
2
|
+
|
|
3
|
+
//#region src/cli-run.ts
|
|
4
|
+
/**
|
|
5
|
+
* The real CLI graph behind this package's bin shim.
|
|
6
|
+
*
|
|
7
|
+
* Importing `@politty/zod` registers the zod adapter as a side effect of that
|
|
8
|
+
* package's entry, so the adapter is installed before the politty CLI can
|
|
9
|
+
* dynamically load user command modules carrying zod schemas.
|
|
10
|
+
*/
|
|
11
|
+
await runPolittyCli("politty");
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { };
|
package/dist/cli.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {}
|
package/dist/cli.js
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { enableCompileCache } from "@politty/zod/compile-cache";
|
|
3
3
|
|
|
4
4
|
//#region src/cli.ts
|
|
5
5
|
/**
|
|
6
|
-
* Bin shim
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
6
|
+
* Bin shim for the `politty` bin of this compatibility alias.
|
|
7
|
+
*
|
|
8
|
+
* Cannot simply re-run `@politty/zod`'s CLI: the CLI bakes the name of the
|
|
9
|
+
* package running it into the shims `generate-shim` writes, and for a CLI
|
|
10
|
+
* depending on `politty` alone that name has to be `politty` — under a strict
|
|
11
|
+
* node_modules layout (pnpm) its own package cannot resolve `@politty/zod`.
|
|
12
|
+
*
|
|
13
|
+
* Mirrors `@politty/zod`'s entry otherwise: enable the on-disk V8 compile
|
|
14
|
+
* cache before the real CLI graph is compiled, then load that graph through a
|
|
15
|
+
* dynamic import so it is what the cache covers.
|
|
11
16
|
*/
|
|
12
17
|
enableCompileCache("politty");
|
|
13
|
-
await import("./cli-
|
|
18
|
+
await import("./cli-run-DGe88d0G.js");
|
|
14
19
|
|
|
15
20
|
//#endregion
|
|
16
|
-
export { };
|
|
17
|
-
//# sourceMappingURL=cli.js.map
|
|
21
|
+
export { };
|
package/dist/compile-cache.d.ts
CHANGED
|
@@ -1,79 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Node.js on-disk compile cache (V8 code cache) helpers.
|
|
4
|
-
*
|
|
5
|
-
* `node:module`'s `enableCompileCache` (Node.js >= 22.8.0) persists compiled
|
|
6
|
-
* bytecode to disk so warm starts skip recompilation. Because ESM static
|
|
7
|
-
* import graphs are compiled during the link phase — before any user code
|
|
8
|
-
* runs — enabling the cache inside `runMain` only covers modules imported
|
|
9
|
-
* *after* the call (e.g. `lazy()` subcommands). To cover the whole CLI,
|
|
10
|
-
* enable it from a minimal bin shim that dynamically imports the real entry:
|
|
11
|
-
*
|
|
12
|
-
* ```ts
|
|
13
|
-
* #!/usr/bin/env node
|
|
14
|
-
* import { enableCompileCache } from "politty/compile-cache";
|
|
15
|
-
*
|
|
16
|
-
* enableCompileCache("my-cli");
|
|
17
|
-
* await import("./cli.js");
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* This module must stay dependency-free (node builtins only) so the shim's
|
|
21
|
-
* static graph — the part that can never be cached — stays tiny.
|
|
22
|
-
*/
|
|
23
|
-
/**
|
|
24
|
-
* Options for {@link enableCompileCache}.
|
|
25
|
-
*/
|
|
26
|
-
interface CompileCacheOptions {
|
|
27
|
-
/**
|
|
28
|
-
* Program name used to derive the default cache directory
|
|
29
|
-
* (`${XDG_CACHE_HOME:-$HOME/.cache}/<sanitized programName>/node-compile-cache`
|
|
30
|
-
* — see {@link compileCacheDir} for how the name is sanitized).
|
|
31
|
-
* Ignored when `cacheDir` is set.
|
|
32
|
-
*/
|
|
33
|
-
programName?: string;
|
|
34
|
-
/** Explicit cache directory (takes precedence over `programName`). */
|
|
35
|
-
cacheDir?: string;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Result of {@link enableCompileCache}.
|
|
39
|
-
*/
|
|
40
|
-
interface CompileCacheResult {
|
|
41
|
-
/** Whether the compile cache is active for this process. */
|
|
42
|
-
enabled: boolean;
|
|
43
|
-
/** Directory the cache is (or was already) persisted to, when known. */
|
|
44
|
-
directory?: string;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Compute the cache directory for a program following the same XDG
|
|
48
|
-
* convention as the shell-completion dispatcher scripts
|
|
49
|
-
* (`src/completion/dispatcher.ts`), so direct CLI runs and completion
|
|
50
|
-
* workers share one warm cache:
|
|
51
|
-
* `${XDG_CACHE_HOME:-$HOME/.cache}/<sanitized programName>/node-compile-cache`.
|
|
52
|
-
* The program name is first reduced to a single safe path segment by
|
|
53
|
-
* {@link sanitizeProgramName} (e.g. `@scope/cli` → `scope-cli`). The
|
|
54
|
-
* dispatcher scripts use the raw name, but a completion program name is a
|
|
55
|
-
* single shell word resolved on PATH and can never contain separators, so
|
|
56
|
-
* for every name that can actually reach both sides the two paths coincide.
|
|
57
|
-
*
|
|
58
|
-
* Returns `undefined` when no home directory can be resolved or the program
|
|
59
|
-
* name does not reduce to a safe path segment; callers fall back to Node's
|
|
60
|
-
* default location (`NODE_COMPILE_CACHE` or the OS tmpdir).
|
|
61
|
-
*/
|
|
62
|
-
declare function compileCacheDir(programName: string): string | undefined;
|
|
63
|
-
/**
|
|
64
|
-
* Enable the Node.js on-disk compile cache for this process.
|
|
65
|
-
*
|
|
66
|
-
* - No-ops (returns `{ enabled: false }`) on runtimes without
|
|
67
|
-
* `module.enableCompileCache` (Node.js < 22.8.0) and never throws.
|
|
68
|
-
* - When the `NODE_COMPILE_CACHE` environment variable is set it always
|
|
69
|
-
* wins, keeping runs spawned by completion scripts (which set the same
|
|
70
|
-
* variable) consistent with direct runs.
|
|
71
|
-
* - Repeat calls are harmless: Node keeps the directory from the first
|
|
72
|
-
* successful call.
|
|
73
|
-
*
|
|
74
|
-
* @param options - Program name (string shorthand) or {@link CompileCacheOptions}.
|
|
75
|
-
*/
|
|
76
|
-
declare function enableCompileCache(options?: string | CompileCacheOptions): CompileCacheResult;
|
|
77
|
-
//#endregion
|
|
78
|
-
export { CompileCacheOptions, CompileCacheResult, compileCacheDir, enableCompileCache };
|
|
79
|
-
//# sourceMappingURL=compile-cache.d.ts.map
|
|
1
|
+
export * from "@politty/zod/compile-cache";
|
package/dist/compile-cache.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
export * from "@politty/zod/compile-cache"
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@politty/zod/completion";
|
package/dist/docs.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@politty/zod/docs";
|
package/dist/docs.js
ADDED