politty 0.11.6 → 0.11.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +30 -1
  2. package/dist/augment.d.ts +1 -16
  3. package/dist/augment.js +2 -0
  4. package/dist/cli-run-DGe88d0G.js +14 -0
  5. package/dist/cli.d.ts +1 -1
  6. package/dist/cli.js +13 -9
  7. package/dist/compile-cache.d.ts +1 -79
  8. package/dist/compile-cache.js +2 -2
  9. package/dist/completion.d.ts +1 -0
  10. package/dist/completion.js +3 -0
  11. package/dist/docs.d.ts +1 -0
  12. package/dist/docs.js +3 -0
  13. package/dist/index.d.ts +10 -814
  14. package/dist/index.js +17 -8
  15. package/dist/prompt-clack.d.ts +1 -0
  16. package/dist/prompt-clack.js +3 -0
  17. package/dist/prompt-inquirer.d.ts +1 -0
  18. package/dist/prompt-inquirer.js +3 -0
  19. package/dist/prompt.d.ts +1 -0
  20. package/dist/prompt.js +3 -0
  21. package/dist/skill.d.ts +1 -0
  22. package/dist/skill.js +3 -0
  23. package/package.json +18 -45
  24. package/dist/arg-registry-SrNIsq-d.d.ts +0 -981
  25. package/dist/cli-main.d.ts +0 -1
  26. package/dist/cli-main.js +0 -86
  27. package/dist/command-B4yA4LXX.js +0 -43
  28. package/dist/compile-cache-NnTkjJMV.js +0 -101
  29. package/dist/completion/index.d.ts +0 -3
  30. package/dist/completion/index.js +0 -3
  31. package/dist/completion-D9SKGJad.js +0 -5610
  32. package/dist/docs/index.d.ts +0 -771
  33. package/dist/docs/index.js +0 -3024
  34. package/dist/index-qqwo5WZT.d.ts +0 -673
  35. package/dist/log-collector-DK32-73m.js +0 -115
  36. package/dist/logger-DbDkjdfO.js +0 -134
  37. package/dist/prompt/clack/index.d.ts +0 -17
  38. package/dist/prompt/clack/index.js +0 -32
  39. package/dist/prompt/index.d.ts +0 -107
  40. package/dist/prompt/index.js +0 -3
  41. package/dist/prompt/inquirer/index.d.ts +0 -17
  42. package/dist/prompt/inquirer/index.js +0 -47
  43. package/dist/prompt-Cc8Tfmdv.js +0 -172
  44. package/dist/runner-BGs_QMJM.js +0 -3
  45. package/dist/runner-xN7248Ph.js +0 -2966
  46. package/dist/schema-extractor-wzJ1cGon.js +0 -488
  47. package/dist/skill/index.d.ts +0 -584
  48. package/dist/skill/index.js +0 -1756
  49. package/dist/src-BiCtSNrn.js +0 -193
  50. package/dist/subcommand-router-CTzHPGzF.js +0 -135
@@ -1 +0,0 @@
1
- export { };
package/dist/cli-main.js DELETED
@@ -1,86 +0,0 @@
1
- import { n as generateCompileCacheShim, t as formatShimPath } from "./src-BiCtSNrn.js";
2
- import { s as arg } from "./schema-extractor-wzJ1cGon.js";
3
- import { n as defineCommand } from "./command-B4yA4LXX.js";
4
- import { p as generateBundledCompletionWorker } from "./completion-D9SKGJad.js";
5
- import { n as runMain } from "./runner-xN7248Ph.js";
6
- import { z } from "zod";
7
-
8
- //#region src/cli-main.ts
9
- const generateWorkerCommand = defineCommand({
10
- name: "generate-worker",
11
- description: "Generate and verify a bundled shell completion worker",
12
- args: z.object({
13
- bin: arg(z.string(), {
14
- description: "CLI binary or built JS entry file to invoke",
15
- placeholder: "PATH"
16
- }),
17
- program: arg(z.string(), {
18
- description: "Program name embedded in worker metadata",
19
- placeholder: "NAME"
20
- }),
21
- shell: arg(z.enum([
22
- "bash",
23
- "zsh",
24
- "fish"
25
- ]), {
26
- description: "Shell worker to generate",
27
- placeholder: "SHELL"
28
- }),
29
- out: arg(z.string().optional(), {
30
- description: "Output worker path (defaults to dist/completion/<shell>-worker.<ext>)",
31
- placeholder: "PATH"
32
- }),
33
- verify: arg(z.boolean().default(false), { description: "Verify __completion-worker-path resolves to the generated worker" })
34
- }),
35
- async run(args) {
36
- await generateBundledCompletionWorker({
37
- bin: args.bin,
38
- programName: args.program,
39
- shell: args.shell,
40
- ...args.out !== void 0 && { outputPath: args.out },
41
- verify: args.verify
42
- });
43
- }
44
- });
45
- runMain(defineCommand({
46
- name: "politty",
47
- description: "politty development utilities",
48
- subCommands: {
49
- "generate-shim": defineCommand({
50
- name: "generate-shim",
51
- description: "Generate a compile-cache bin shim that loads the real CLI via dynamic import",
52
- args: z.object({
53
- entry: arg(z.array(z.string()).optional(), {
54
- 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)",
55
- placeholder: "SPECIFIER"
56
- }),
57
- out: arg(z.array(z.string()).optional(), {
58
- description: "Output path for the generated shim; repeatable, one per --entry (defaults to the bin paths in package.json)",
59
- placeholder: "PATH"
60
- }),
61
- program: arg(z.string().optional(), {
62
- description: "Program name for the cache directory, applied to all shims (defaults per shim to its bin name)",
63
- placeholder: "NAME"
64
- })
65
- }),
66
- run(args) {
67
- const cwd = process.cwd();
68
- const results = generateCompileCacheShim({
69
- ...args.entry !== void 0 && { entry: args.entry },
70
- ...args.out !== void 0 && { out: args.out },
71
- ...args.program !== void 0 && { program: args.program },
72
- cwd
73
- });
74
- for (const result of results) console.log(`Generated compile-cache shim: ${formatShimPath(result.outputPath, cwd)} (program: ${result.program}, entry: ${result.entry})`);
75
- }
76
- }),
77
- "generate-worker": generateWorkerCommand
78
- }
79
- })).catch((error) => {
80
- console.error(error instanceof Error ? error.message : String(error));
81
- process.exit(1);
82
- });
83
-
84
- //#endregion
85
- export { };
86
- //# sourceMappingURL=cli-main.js.map
@@ -1,43 +0,0 @@
1
- //#region src/core/command.ts
2
- function defineCommand(config) {
3
- return {
4
- name: config.name,
5
- description: config.description,
6
- aliases: config.aliases,
7
- args: config.args,
8
- subCommands: config.subCommands,
9
- setup: config.setup,
10
- run: config.run,
11
- cleanup: config.cleanup,
12
- notes: config.notes,
13
- examples: config.examples
14
- };
15
- }
16
- /**
17
- * Create a typed defineCommand factory with pre-bound global args type.
18
- * This is the recommended pattern for type-safe global options.
19
- *
20
- * @example
21
- * ```ts
22
- * // global-args.ts
23
- * type GlobalArgsType = { verbose: boolean; config?: string };
24
- * export const defineAppCommand = createDefineCommand<GlobalArgsType>();
25
- *
26
- * // commands/build.ts
27
- * export const buildCommand = defineAppCommand({
28
- * name: "build",
29
- * args: z.object({ output: arg(z.string().default("dist")) }),
30
- * run: (args) => {
31
- * args.verbose; // typed via GlobalArgsType
32
- * args.output; // typed via local args
33
- * },
34
- * });
35
- * ```
36
- */
37
- function createDefineCommand() {
38
- return defineCommand;
39
- }
40
-
41
- //#endregion
42
- export { defineCommand as n, createDefineCommand as t };
43
- //# sourceMappingURL=command-B4yA4LXX.js.map
@@ -1,101 +0,0 @@
1
- import * as nodeModule from "node:module";
2
- import { join } from "node:path";
3
- import { homedir } from "node:os";
4
-
5
- //#region src/compile-cache.ts
6
- /**
7
- * Node.js on-disk compile cache (V8 code cache) helpers.
8
- *
9
- * `node:module`'s `enableCompileCache` (Node.js >= 22.8.0) persists compiled
10
- * bytecode to disk so warm starts skip recompilation. Because ESM static
11
- * import graphs are compiled during the link phase — before any user code
12
- * runs — enabling the cache inside `runMain` only covers modules imported
13
- * *after* the call (e.g. `lazy()` subcommands). To cover the whole CLI,
14
- * enable it from a minimal bin shim that dynamically imports the real entry:
15
- *
16
- * ```ts
17
- * #!/usr/bin/env node
18
- * import { enableCompileCache } from "politty/compile-cache";
19
- *
20
- * enableCompileCache("my-cli");
21
- * await import("./cli.js");
22
- * ```
23
- *
24
- * This module must stay dependency-free (node builtins only) so the shim's
25
- * static graph — the part that can never be cached — stays tiny.
26
- */
27
- /**
28
- * Reduce a program name to a single safe path segment. Path separators and
29
- * a leading scope marker are collapsed (`@scope/cli` → `scope-cli`) so the
30
- * name cannot escape the cache root; names that reduce to nothing (or to
31
- * `.`/`..`) yield `undefined`. Realistic command names pass through
32
- * unchanged.
33
- */
34
- function sanitizeProgramName(programName) {
35
- const safe = programName.replace(/^@/, "").replace(/[/\\]+/g, "-").trim();
36
- if (!safe || /^[.-]+$/.test(safe)) return void 0;
37
- return safe;
38
- }
39
- /**
40
- * Compute the cache directory for a program following the same XDG
41
- * convention as the shell-completion dispatcher scripts
42
- * (`src/completion/dispatcher.ts`), so direct CLI runs and completion
43
- * workers share one warm cache:
44
- * `${XDG_CACHE_HOME:-$HOME/.cache}/<sanitized programName>/node-compile-cache`.
45
- * The program name is first reduced to a single safe path segment by
46
- * {@link sanitizeProgramName} (e.g. `@scope/cli` → `scope-cli`). The
47
- * dispatcher scripts use the raw name, but a completion program name is a
48
- * single shell word resolved on PATH and can never contain separators, so
49
- * for every name that can actually reach both sides the two paths coincide.
50
- *
51
- * Returns `undefined` when no home directory can be resolved or the program
52
- * name does not reduce to a safe path segment; callers fall back to Node's
53
- * default location (`NODE_COMPILE_CACHE` or the OS tmpdir).
54
- */
55
- function compileCacheDir(programName) {
56
- const safeName = sanitizeProgramName(programName);
57
- if (safeName === void 0) return void 0;
58
- const xdg = process.env.XDG_CACHE_HOME;
59
- if (xdg) return join(xdg, safeName, "node-compile-cache");
60
- try {
61
- const home = homedir();
62
- if (!home) return void 0;
63
- return join(home, ".cache", safeName, "node-compile-cache");
64
- } catch {
65
- return;
66
- }
67
- }
68
- /**
69
- * Enable the Node.js on-disk compile cache for this process.
70
- *
71
- * - No-ops (returns `{ enabled: false }`) on runtimes without
72
- * `module.enableCompileCache` (Node.js < 22.8.0) and never throws.
73
- * - When the `NODE_COMPILE_CACHE` environment variable is set it always
74
- * wins, keeping runs spawned by completion scripts (which set the same
75
- * variable) consistent with direct runs.
76
- * - Repeat calls are harmless: Node keeps the directory from the first
77
- * successful call.
78
- *
79
- * @param options - Program name (string shorthand) or {@link CompileCacheOptions}.
80
- */
81
- function enableCompileCache(options) {
82
- const opts = typeof options === "string" ? { programName: options } : options ?? {};
83
- try {
84
- const enable = nodeModule.enableCompileCache;
85
- if (typeof enable !== "function") return { enabled: false };
86
- let dir;
87
- if (!process.env.NODE_COMPILE_CACHE) dir = opts.cacheDir ?? (opts.programName !== void 0 ? compileCacheDir(opts.programName) : void 0);
88
- const result = dir === void 0 ? enable() : enable(dir);
89
- const status = nodeModule.constants?.compileCacheStatus;
90
- return {
91
- enabled: status !== void 0 ? result.status === status.ENABLED || result.status === status.ALREADY_ENABLED : result.status === 0 || result.status === 1,
92
- ...result.directory !== void 0 && { directory: result.directory }
93
- };
94
- } catch {
95
- return { enabled: false };
96
- }
97
- }
98
-
99
- //#endregion
100
- export { enableCompileCache as n, compileCacheDir as t };
101
- //# sourceMappingURL=compile-cache-NnTkjJMV.js.map
@@ -1,3 +0,0 @@
1
- import { f as CompletionDirectiveMask, g as DynamicCompletionResult, h as DynamicCompletionResolver, m as DynamicCompletionContext, p as DynamicCompletionCandidate } from "../arg-registry-SrNIsq-d.js";
2
- import { A as BundledWorkerOptions, C as CandidateResult, D as CompletionContext, E as generateCandidates, F as CompletionMode, I as CompletionOptions, L as CompletionResult, M as CompletableSubcommand, N as CompletionData, O as CompletionType, P as CompletionGenerator, R as ShellType, S as hasCompleteCommand, T as CompletionDirective, _ as extractCompletionData, a as detectShell, b as formatForShell, c as withCompletionCommand, d as GenerateBundledCompletionWorkerOptions, f as GenerateBundledCompletionWorkerResult, g as validateBundledWorkerFile, h as generateBundledCompletionWorker, i as createRefreshCompletionCommand, j as CompletableOption, k as parseCompletionContext, l as ValueCompletionField, m as defaultBundledWorkerOutputPath, n as createCompletionCommand, o as generateCompletion, p as bundledWorkerShellExtension, r as createCompletionWorkerPathCommand, s as getSupportedShells, t as WithCompletionOptions, u as resolveValueCompletion, v as extractPositionals, w as CompletionCandidate, x as createDynamicCompleteCommand, y as ShellFormatOptions } from "../index-qqwo5WZT.js";
3
- export { type BundledWorkerOptions, type CandidateResult, type CompletableOption, type CompletableSubcommand, type CompletionCandidate, type CompletionContext, type CompletionData, CompletionDirective, type CompletionDirectiveMask, type CompletionGenerator, type CompletionMode, type CompletionOptions, type CompletionResult, type CompletionType, type DynamicCompletionCandidate, type DynamicCompletionContext, type DynamicCompletionResolver, type DynamicCompletionResult, type GenerateBundledCompletionWorkerOptions, type GenerateBundledCompletionWorkerResult, type ShellFormatOptions, type ShellType, type ValueCompletionField, WithCompletionOptions, bundledWorkerShellExtension, createCompletionCommand, createCompletionWorkerPathCommand, createDynamicCompleteCommand, createRefreshCompletionCommand, defaultBundledWorkerOutputPath, detectShell, extractCompletionData, extractPositionals, formatForShell, generateBundledCompletionWorker, generateCandidates, generateCompletion, getSupportedShells, hasCompleteCommand, parseCompletionContext, resolveValueCompletion, validateBundledWorkerFile, withCompletionCommand };
@@ -1,3 +0,0 @@
1
- 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-D9SKGJad.js";
2
-
3
- export { CompletionDirective, bundledWorkerShellExtension, createCompletionCommand, createCompletionWorkerPathCommand, createDynamicCompleteCommand, createRefreshCompletionCommand, defaultBundledWorkerOutputPath, detectShell, extractCompletionData, extractPositionals, formatForShell, generateBundledCompletionWorker, generateCandidates, generateCompletion, getSupportedShells, hasCompleteCommand, parseCompletionContext, resolveValueCompletion, validateBundledWorkerFile, withCompletionCommand };