politty 0.8.0 → 0.9.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.
Files changed (71) hide show
  1. package/README.md +57 -0
  2. package/dist/arg-registry-BeLLAW5-.js +25 -0
  3. package/dist/cli.js +4 -3
  4. package/dist/command-B4yA4LXX.js +43 -0
  5. package/dist/completion/index.js +1 -1
  6. package/dist/{completion-DHnVx9Zk.js → completion-DwTFOtQk.js} +5 -44
  7. package/dist/docs/index.js +2 -2
  8. package/dist/index.js +6 -3
  9. package/dist/logger-DbDkjdfO.js +134 -0
  10. package/dist/{runner-D43SkHt5.js → runner-B-FZMN89.js} +63 -121
  11. package/dist/{schema-extractor-Dqe7_kyQ.js → schema-extractor-CVHWm23M.js} +3 -24
  12. package/dist/skill/index.d.ts +432 -0
  13. package/dist/skill/index.js +1563 -0
  14. package/package.json +25 -63
  15. package/dist/arg-registry-DDJpsUea.d.cts +0 -942
  16. package/dist/arg-registry-DDJpsUea.d.cts.map +0 -1
  17. package/dist/arg-registry-DDJpsUea.d.ts.map +0 -1
  18. package/dist/augment.cjs +0 -0
  19. package/dist/augment.d.cts +0 -17
  20. package/dist/augment.d.cts.map +0 -1
  21. package/dist/augment.d.ts.map +0 -1
  22. package/dist/cli.cjs +0 -54
  23. package/dist/cli.cjs.map +0 -1
  24. package/dist/cli.d.cts +0 -1
  25. package/dist/cli.js.map +0 -1
  26. package/dist/completion/index.cjs +0 -23
  27. package/dist/completion/index.d.cts +0 -3
  28. package/dist/completion-CLHO3Xaz.cjs +0 -5769
  29. package/dist/completion-CLHO3Xaz.cjs.map +0 -1
  30. package/dist/completion-DHnVx9Zk.js.map +0 -1
  31. package/dist/docs/index.cjs +0 -3127
  32. package/dist/docs/index.cjs.map +0 -1
  33. package/dist/docs/index.d.cts +0 -752
  34. package/dist/docs/index.d.cts.map +0 -1
  35. package/dist/docs/index.d.ts.map +0 -1
  36. package/dist/docs/index.js.map +0 -1
  37. package/dist/index-DKGn3lIl.d.ts.map +0 -1
  38. package/dist/index-WyViqW59.d.cts +0 -663
  39. package/dist/index-WyViqW59.d.cts.map +0 -1
  40. package/dist/index.cjs +0 -45
  41. package/dist/index.d.cts +0 -685
  42. package/dist/index.d.cts.map +0 -1
  43. package/dist/index.d.ts.map +0 -1
  44. package/dist/log-collector-DK32-73m.js.map +0 -1
  45. package/dist/log-collector-DUqC427m.cjs +0 -185
  46. package/dist/log-collector-DUqC427m.cjs.map +0 -1
  47. package/dist/prompt/clack/index.cjs +0 -33
  48. package/dist/prompt/clack/index.cjs.map +0 -1
  49. package/dist/prompt/clack/index.d.cts +0 -18
  50. package/dist/prompt/clack/index.d.cts.map +0 -1
  51. package/dist/prompt/clack/index.d.ts.map +0 -1
  52. package/dist/prompt/clack/index.js.map +0 -1
  53. package/dist/prompt/index.cjs +0 -7
  54. package/dist/prompt/index.d.cts +0 -108
  55. package/dist/prompt/index.d.cts.map +0 -1
  56. package/dist/prompt/index.d.ts.map +0 -1
  57. package/dist/prompt/inquirer/index.cjs +0 -48
  58. package/dist/prompt/inquirer/index.cjs.map +0 -1
  59. package/dist/prompt/inquirer/index.d.cts +0 -18
  60. package/dist/prompt/inquirer/index.d.cts.map +0 -1
  61. package/dist/prompt/inquirer/index.d.ts.map +0 -1
  62. package/dist/prompt/inquirer/index.js.map +0 -1
  63. package/dist/prompt-Bs9e-Em3.cjs +0 -196
  64. package/dist/prompt-Bs9e-Em3.cjs.map +0 -1
  65. package/dist/prompt-Cc8Tfmdv.js.map +0 -1
  66. package/dist/runner-D43SkHt5.js.map +0 -1
  67. package/dist/runner-DvFvokV6.cjs +0 -2865
  68. package/dist/runner-DvFvokV6.cjs.map +0 -1
  69. package/dist/schema-extractor-BxSRwLrx.cjs +0 -710
  70. package/dist/schema-extractor-BxSRwLrx.cjs.map +0 -1
  71. package/dist/schema-extractor-Dqe7_kyQ.js.map +0 -1
package/README.md CHANGED
@@ -15,6 +15,7 @@ From simple scripts to complex CLI tools with subcommands, validation, and auto-
15
15
  - **Auto Help Generation**: Automatically generate help text from definitions
16
16
  - **Interactive Prompts**: Prompt for missing arguments with pluggable adapters (clack, inquirer)
17
17
  - **Discriminated Union**: Support for mutually exclusive argument sets
18
+ - **Skill Management**: Manage agent skills (SKILL.md) with file-based install/uninstall
18
19
 
19
20
  ## Requirements
20
21
 
@@ -422,6 +423,61 @@ const command = defineCommand({
422
423
  });
423
424
  ```
424
425
 
426
+ ## Skill Management
427
+
428
+ politty manages SKILL.md-based agent skills distributed via npm packages.
429
+
430
+ ### Quick Setup
431
+
432
+ Use `withSkillCommand` to add skill management to your CLI:
433
+
434
+ ```typescript
435
+ import { dirname, resolve } from "node:path";
436
+ import { fileURLToPath } from "node:url";
437
+ import { defineCommand, runMain } from "politty";
438
+ import { withSkillCommand } from "politty/skill";
439
+
440
+ // Resolves to ../skills from both src/ and dist/
441
+ const sourceDir = resolve(dirname(fileURLToPath(import.meta.url)), "../skills");
442
+
443
+ const cli = withSkillCommand(
444
+ defineCommand({
445
+ name: "my-agent",
446
+ subCommands: {
447
+ /* ... */
448
+ },
449
+ }),
450
+ { sourceDir, package: "@my-agent/skills" },
451
+ );
452
+
453
+ runMain(cli);
454
+ ```
455
+
456
+ `package` identifies who owns these skills. It is combined with the command name as `"{package}:{cliName}"` and must match the `metadata["politty-cli"]` stamp pre-declared in each source SKILL.md — `skills add`/`sync` refuse mismatches, and `remove`/`sync` refuse to delete skills belonging to another tool. The default install mode is `"symlink"` (`.agents/skills/<name>` -> source, `.claude/skills/<name>` -> canonical), so source updates propagate live; on filesystems without symlink support (e.g. Windows without Developer Mode) install throws with guidance to retry with `mode: "copy"`, which recursively copies instead (source updates then require re-running `sync`). See [Skill Management](./docs/skill-management.md) for details.
457
+
458
+ Skills are SKILL.md files with YAML frontmatter (spec-compliant: https://agentskills.io/specification). The `metadata["politty-cli"]` stamp is authored by the skill package:
459
+
460
+ ```markdown
461
+ ---
462
+ name: commit
463
+ description: Git commit message generation
464
+ license: MIT
465
+ metadata:
466
+ politty-cli: "@my-agent/skills:my-agent"
467
+ ---
468
+
469
+ # Instructions for the agent...
470
+ ```
471
+
472
+ Then users can manage skills:
473
+
474
+ ```bash
475
+ my-agent skills sync # Remove and reinstall all skills
476
+ my-agent skills add commit # Install a specific skill
477
+ my-agent skills remove commit # Remove a specific skill
478
+ my-agent skills list # List available skills
479
+ ```
480
+
425
481
  ## Documentation
426
482
 
427
483
  For detailed documentation, see the `docs/` directory:
@@ -431,6 +487,7 @@ For detailed documentation, see the `docs/` directory:
431
487
  - [Advanced Features](./docs/advanced-features.md) - Subcommands, Discriminated Union
432
488
  - [Interactive Prompts](./docs/interactive-prompts.md) - Prompt for missing arguments interactively
433
489
  - [Recipes](./docs/recipes.md) - Testing, configuration, error handling
490
+ - [Skill Management](./docs/skill-management.md) - Agent skill management (SKILL.md-based)
434
491
  - [API Reference](./docs/api-reference.md) - Detailed API reference
435
492
  - [Doc Generation](./docs/doc-generation.md) - Automatic documentation generation
436
493
 
@@ -0,0 +1,25 @@
1
+ import { z } from "zod";
2
+
3
+ //#region src/core/arg-registry.ts
4
+ /**
5
+ * Custom registry for politty argument metadata
6
+ * This avoids polluting Zod's GlobalMeta
7
+ */
8
+ const argRegistry = z.registry();
9
+ function arg(schema, meta) {
10
+ if (meta) argRegistry.add(schema, meta);
11
+ return schema;
12
+ }
13
+ /**
14
+ * Get metadata for a schema from the registry
15
+ *
16
+ * @param schema - The Zod schema
17
+ * @returns The metadata if registered, undefined otherwise
18
+ */
19
+ function getArgMeta(schema) {
20
+ return argRegistry.get(schema);
21
+ }
22
+
23
+ //#endregion
24
+ export { getArgMeta as n, arg as t };
25
+ //# sourceMappingURL=arg-registry-BeLLAW5-.js.map
package/dist/cli.js CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { n as runMain } from "./runner-D43SkHt5.js";
3
- import { h as arg } from "./schema-extractor-Dqe7_kyQ.js";
4
- import { S as defineCommand, p as generateBundledCompletionWorker } from "./completion-DHnVx9Zk.js";
2
+ import { n as runMain } from "./runner-B-FZMN89.js";
3
+ import { t as arg } from "./arg-registry-BeLLAW5-.js";
4
+ import { n as defineCommand } from "./command-B4yA4LXX.js";
5
+ import { p as generateBundledCompletionWorker } from "./completion-DwTFOtQk.js";
5
6
  import "./index.js";
6
7
  import { z } from "zod";
7
8
 
@@ -0,0 +1,43 @@
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,3 +1,3 @@
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-DHnVx9Zk.js";
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-DwTFOtQk.js";
2
2
 
3
3
  export { CompletionDirective, bundledWorkerShellExtension, createCompletionCommand, createCompletionWorkerPathCommand, createDynamicCompleteCommand, createRefreshCompletionCommand, defaultBundledWorkerOutputPath, detectShell, extractCompletionData, extractPositionals, formatForShell, generateBundledCompletionWorker, generateCandidates, generateCompletion, getSupportedShells, hasCompleteCommand, parseCompletionContext, resolveValueCompletion, validateBundledWorkerFile, withCompletionCommand };
@@ -1,51 +1,12 @@
1
- import { a as toCamelCase, h as arg, m as resolveSubCommandMeta, n as getAllAliases, t as extractFields, u as resolveSubCommandAlias } from "./schema-extractor-Dqe7_kyQ.js";
1
+ import { t as arg } from "./arg-registry-BeLLAW5-.js";
2
+ import { n as defineCommand } from "./command-B4yA4LXX.js";
3
+ import { a as toCamelCase, m as resolveSubCommandMeta, n as getAllAliases, t as extractFields, u as resolveSubCommandAlias } from "./schema-extractor-CVHWm23M.js";
2
4
  import { z } from "zod";
3
5
  import { execFile, execSync, spawn } from "node:child_process";
4
6
  import { existsSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
5
7
  import { dirname, extname, isAbsolute, join, relative, resolve } from "node:path";
6
8
  import { promisify } from "node:util";
7
9
 
8
- //#region src/core/command.ts
9
- function defineCommand(config) {
10
- return {
11
- name: config.name,
12
- description: config.description,
13
- aliases: config.aliases,
14
- args: config.args,
15
- subCommands: config.subCommands,
16
- setup: config.setup,
17
- run: config.run,
18
- cleanup: config.cleanup,
19
- notes: config.notes,
20
- examples: config.examples
21
- };
22
- }
23
- /**
24
- * Create a typed defineCommand factory with pre-bound global args type.
25
- * This is the recommended pattern for type-safe global options.
26
- *
27
- * @example
28
- * ```ts
29
- * // global-args.ts
30
- * type GlobalArgsType = { verbose: boolean; config?: string };
31
- * export const defineAppCommand = createDefineCommand<GlobalArgsType>();
32
- *
33
- * // commands/build.ts
34
- * export const buildCommand = defineAppCommand({
35
- * name: "build",
36
- * args: z.object({ output: arg(z.string().default("dist")) }),
37
- * run: (args) => {
38
- * args.verbose; // typed via GlobalArgsType
39
- * args.output; // typed via local args
40
- * },
41
- * });
42
- * ```
43
- */
44
- function createDefineCommand() {
45
- return defineCommand;
46
- }
47
-
48
- //#endregion
49
10
  //#region src/completion/shell-shared.ts
50
11
  /**
51
12
  * Helpers shared across the bash/zsh/fish completion generators.
@@ -5634,5 +5595,5 @@ function maybeSpawnRefresh(argv, ctx) {
5634
5595
  }
5635
5596
 
5636
5597
  //#endregion
5637
- export { defineCommand as S, CompletionDirective as _, generateCompletion as a, resolveValueCompletion as b, createDynamicCompleteCommand as c, bundledWorkerShellExtension as d, defaultBundledWorkerOutputPath as f, extractPositionals as g, extractCompletionData as h, detectShell as i, hasCompleteCommand as l, validateBundledWorkerFile as m, createCompletionWorkerPathCommand as n, getSupportedShells as o, generateBundledCompletionWorker as p, createRefreshCompletionCommand as r, withCompletionCommand as s, createCompletionCommand as t, formatForShell as u, generateCandidates as v, createDefineCommand as x, parseCompletionContext as y };
5638
- //# sourceMappingURL=completion-DHnVx9Zk.js.map
5598
+ export { CompletionDirective as _, generateCompletion as a, resolveValueCompletion as b, createDynamicCompleteCommand as c, bundledWorkerShellExtension as d, defaultBundledWorkerOutputPath as f, extractPositionals as g, extractCompletionData as h, detectShell as i, hasCompleteCommand as l, validateBundledWorkerFile as m, createCompletionWorkerPathCommand as n, getSupportedShells as o, generateBundledCompletionWorker as p, createRefreshCompletionCommand as r, withCompletionCommand as s, createCompletionCommand as t, formatForShell as u, generateCandidates as v, parseCompletionContext as y };
5599
+ //# sourceMappingURL=completion-DwTFOtQk.js.map
@@ -1,4 +1,4 @@
1
- import { l as resolveLazyCommand, r as getExtractedFields, t as extractFields } from "../schema-extractor-Dqe7_kyQ.js";
1
+ import { l as resolveLazyCommand, r as getExtractedFields, t as extractFields } from "../schema-extractor-CVHWm23M.js";
2
2
  import { t as createLogCollector } from "../log-collector-DK32-73m.js";
3
3
  import { z } from "zod";
4
4
  import * as fs from "node:fs";
@@ -874,7 +874,7 @@ async function executeSingleExample(example, rootCommand, commandPath) {
874
874
  collector.start();
875
875
  let success = true;
876
876
  try {
877
- const { runCommand } = await import("../runner-D43SkHt5.js").then((n) => n.r);
877
+ const { runCommand } = await import("../runner-B-FZMN89.js").then((n) => n.r);
878
878
  const result = await runCommand(rootCommand, argv);
879
879
  success = result.success;
880
880
  if (!result.success && result.error) console.error(result.error.message);
package/dist/index.js CHANGED
@@ -1,5 +1,8 @@
1
- import { C as renderMarkdown, D as styles, E as setColorEnabled, O as symbols, S as renderInline, T as logger, _ as DuplicateFieldError, a as parseArgv, b as ReservedAliasError, c as validateCommand, d as validateDuplicateFields, f as validateDuplicateNegations, g as DuplicateAliasError, h as CaseVariantCollisionError, i as formatValidationErrors, k as createDualCaseProxy, l as validateCrossSchemaCollisions, m as validateReservedAliases, n as runMain, o as formatCommandValidationErrors, p as validatePositionalConfig, s as validateCaseVariantCollisions, t as runCommand, u as validateDuplicateAliases, v as DuplicateNegationError, w as isColorEnabled, x as generateHelp, y as PositionalConfigError } from "./runner-D43SkHt5.js";
2
- import { a as toCamelCase, f as isLazyCommand, h as arg, i as getUnknownKeysMode, o as toKebabCase, p as lazy, t as extractFields } from "./schema-extractor-Dqe7_kyQ.js";
3
- import { S as defineCommand, a as generateCompletion, p as generateBundledCompletionWorker, s as withCompletionCommand, x as createDefineCommand } from "./completion-DHnVx9Zk.js";
1
+ import { C as renderMarkdown, S as renderInline, _ as DuplicateFieldError, a as parseArgv, b as ReservedAliasError, c as validateCommand, d as validateDuplicateFields, f as validateDuplicateNegations, g as DuplicateAliasError, h as CaseVariantCollisionError, i as formatValidationErrors, l as validateCrossSchemaCollisions, m as validateReservedAliases, n as runMain, o as formatCommandValidationErrors, p as validatePositionalConfig, s as validateCaseVariantCollisions, t as runCommand, u as validateDuplicateAliases, v as DuplicateNegationError, w as createDualCaseProxy, x as generateHelp, y as PositionalConfigError } from "./runner-B-FZMN89.js";
2
+ import { t as arg } from "./arg-registry-BeLLAW5-.js";
3
+ import { n as defineCommand, t as createDefineCommand } from "./command-B4yA4LXX.js";
4
+ import { a as toCamelCase, f as isLazyCommand, i as getUnknownKeysMode, o as toKebabCase, p as lazy, t as extractFields } from "./schema-extractor-CVHWm23M.js";
5
+ import { a as generateCompletion, p as generateBundledCompletionWorker, s as withCompletionCommand } from "./completion-DwTFOtQk.js";
6
+ import { a as symbols, i as styles, n as logger, r as setColorEnabled, t as isColorEnabled } from "./logger-DbDkjdfO.js";
4
7
 
5
8
  export { CaseVariantCollisionError, DuplicateAliasError, DuplicateFieldError, DuplicateNegationError, PositionalConfigError, ReservedAliasError, arg, createDefineCommand, createDualCaseProxy, defineCommand, extractFields, formatCommandValidationErrors, formatValidationErrors, generateBundledCompletionWorker, 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, withCompletionCommand };
@@ -0,0 +1,134 @@
1
+ import { styleText } from "node:util";
2
+
3
+ //#region src/output/logger.ts
4
+ /**
5
+ * Check if color output should be disabled
6
+ */
7
+ function shouldDisableColor() {
8
+ if (process.env.NO_COLOR !== void 0) return true;
9
+ if (process.env.FORCE_COLOR === "0") return true;
10
+ if (process.env.FORCE_COLOR) return false;
11
+ if (process.env.CI) return true;
12
+ if (!process.stdout.isTTY) return true;
13
+ return false;
14
+ }
15
+ /**
16
+ * Global flag to control color output
17
+ */
18
+ let colorDisabled = shouldDisableColor();
19
+ /**
20
+ * Enable or disable color output programmatically
21
+ */
22
+ function setColorEnabled(enabled) {
23
+ colorDisabled = !enabled;
24
+ }
25
+ /**
26
+ * Check if color output is currently enabled
27
+ */
28
+ function isColorEnabled() {
29
+ return !colorDisabled;
30
+ }
31
+ /**
32
+ * Create a style function that applies the given styles
33
+ */
34
+ function createStyleFn(...styleArgs) {
35
+ return (text) => {
36
+ if (colorDisabled) return text;
37
+ let result = text;
38
+ for (const style of styleArgs) result = styleText(style, result);
39
+ return result;
40
+ };
41
+ }
42
+ /**
43
+ * Semantic style functions for inline text styling
44
+ */
45
+ const styles = {
46
+ success: createStyleFn("green"),
47
+ error: createStyleFn("red"),
48
+ warning: createStyleFn("yellow"),
49
+ info: createStyleFn("cyan"),
50
+ bold: createStyleFn("bold"),
51
+ dim: createStyleFn("dim"),
52
+ italic: createStyleFn("italic"),
53
+ underline: createStyleFn("underline"),
54
+ red: createStyleFn("red"),
55
+ green: createStyleFn("green"),
56
+ yellow: createStyleFn("yellow"),
57
+ blue: createStyleFn("blue"),
58
+ magenta: createStyleFn("magenta"),
59
+ cyan: createStyleFn("cyan"),
60
+ white: createStyleFn("white"),
61
+ gray: createStyleFn("gray"),
62
+ command: createStyleFn("bold"),
63
+ commandName: createStyleFn("bold", "underline", "cyan"),
64
+ option: createStyleFn("cyan"),
65
+ optionName: createStyleFn("bold"),
66
+ placeholder: createStyleFn("dim"),
67
+ defaultValue: createStyleFn("dim"),
68
+ required: createStyleFn("yellow"),
69
+ description: (text) => text,
70
+ sectionHeader: createStyleFn("bold", "underline"),
71
+ version: createStyleFn("dim")
72
+ };
73
+ /**
74
+ * Standardized symbols for CLI output
75
+ */
76
+ const symbols = {
77
+ success: styles.green("✓"),
78
+ error: styles.red("✖"),
79
+ warning: styles.yellow("⚠"),
80
+ info: styles.cyan("ℹ"),
81
+ bullet: styles.gray("•"),
82
+ arrow: styles.gray("→")
83
+ };
84
+ /**
85
+ * Logger for CLI output
86
+ */
87
+ const logger = {
88
+ /**
89
+ * Log informational message
90
+ */
91
+ info(message) {
92
+ console.log(message);
93
+ },
94
+ /**
95
+ * Log success message
96
+ */
97
+ success(message) {
98
+ console.log(`${symbols.success} ${styles.success(message)}`);
99
+ },
100
+ /**
101
+ * Log warning message
102
+ */
103
+ warn(message) {
104
+ console.warn(`${symbols.warning} ${styles.warning(message)}`);
105
+ },
106
+ /**
107
+ * Log error message
108
+ */
109
+ error(message) {
110
+ console.error(`${symbols.error} ${styles.error(message)}`);
111
+ },
112
+ /**
113
+ * Log raw message without prefix
114
+ */
115
+ log(message) {
116
+ console.log(message);
117
+ },
118
+ /**
119
+ * Log empty line
120
+ */
121
+ newline() {
122
+ console.log("");
123
+ },
124
+ /**
125
+ * Log debug message with dim color
126
+ */
127
+ debug(message) {
128
+ console.log(styles.dim(message));
129
+ }
130
+ };
131
+
132
+ //#endregion
133
+ export { symbols as a, styles as i, logger as n, setColorEnabled as r, isColorEnabled as t };
134
+ //# sourceMappingURL=logger-DbDkjdfO.js.map
@@ -1,7 +1,7 @@
1
- import { a as toCamelCase, c as listSubCommands, d as resolveSubcommandWithAlias, f as isLazyCommand, l as resolveLazyCommand, m as resolveSubCommandMeta, n as getAllAliases, o as toKebabCase, r as getExtractedFields, s as listSubCommandNamesWithAliases, t as extractFields } from "./schema-extractor-Dqe7_kyQ.js";
1
+ import { a as toCamelCase, c as listSubCommands, d as resolveSubcommandWithAlias, f as isLazyCommand, l as resolveLazyCommand, m as resolveSubCommandMeta, n as getAllAliases, o as toKebabCase, r as getExtractedFields, s as listSubCommandNamesWithAliases, t as extractFields } from "./schema-extractor-CVHWm23M.js";
2
2
  import { n as emptyLogs, r as mergeLogs, t as createLogCollector } from "./log-collector-DK32-73m.js";
3
- import { styleText } from "node:util";
4
- import stringWidth from "string-width";
3
+ import { a as symbols, i as styles } from "./logger-DbDkjdfO.js";
4
+ import { stripVTControlCharacters } from "node:util";
5
5
 
6
6
  //#region \0rolldown/runtime.js
7
7
  var __defProp = Object.defineProperty;
@@ -151,134 +151,76 @@ async function executeLifecycle(command, args, _options = {}) {
151
151
  }
152
152
 
153
153
  //#endregion
154
- //#region src/output/logger.ts
154
+ //#region src/output/string-width.ts
155
155
  /**
156
- * Check if color output should be disabled
157
- */
158
- function shouldDisableColor() {
159
- if (process.env.NO_COLOR !== void 0) return true;
160
- if (process.env.FORCE_COLOR === "0") return true;
161
- if (process.env.FORCE_COLOR) return false;
162
- if (process.env.CI) return true;
163
- if (!process.stdout.isTTY) return true;
164
- return false;
165
- }
166
- /**
167
- * Global flag to control color output
156
+ * Lightweight replacement for the `string-width` package.
157
+ *
158
+ * Computes the visual (terminal) width of a string by:
159
+ * 1. Stripping ANSI escape codes (via Node's `stripVTControlCharacters`)
160
+ * 2. Skipping zero-width characters (combining marks, control chars, etc.)
161
+ * 3. Counting East Asian wide / fullwidth characters and most emoji as 2
162
+ * 4. Counting everything else as 1
163
+ *
164
+ * This covers the cases the markdown renderer cares about (CJK text, emoji,
165
+ * and already-styled ANSI strings) without pulling in an external dependency.
168
166
  */
169
- let colorDisabled = shouldDisableColor();
170
167
  /**
171
- * Enable or disable color output programmatically
168
+ * Whether a code point has no visual width (combining marks, zero-width
169
+ * spaces/joiners, variation selectors, control characters).
172
170
  */
173
- function setColorEnabled(enabled) {
174
- colorDisabled = !enabled;
171
+ function isZeroWidth(cp) {
172
+ return cp <= 31 || cp >= 127 && cp <= 159 || cp >= 768 && cp <= 879 || cp >= 6832 && cp <= 6911 || cp >= 7616 && cp <= 7679 || cp >= 8400 && cp <= 8447 || cp >= 65056 && cp <= 65071 || cp === 8203 || cp >= 8204 && cp <= 8207 || cp === 65279 || cp >= 65024 && cp <= 65039 || cp >= 917760 && cp <= 917999;
175
173
  }
176
174
  /**
177
- * Check if color output is currently enabled
175
+ * Whether a code point is rendered at double (full) width in a terminal.
176
+ * Based on Unicode East Asian Width (Wide/Fullwidth) plus common emoji ranges.
178
177
  */
179
- function isColorEnabled() {
180
- return !colorDisabled;
178
+ function isFullWidth(cp) {
179
+ return cp >= 4352 && cp <= 4447 || cp >= 11904 && cp <= 12350 || cp >= 12353 && cp <= 13311 || cp >= 13312 && cp <= 19903 || cp >= 19968 && cp <= 40959 || cp >= 40960 && cp <= 42191 || cp >= 43360 && cp <= 43391 || cp >= 44032 && cp <= 55203 || cp >= 63744 && cp <= 64255 || cp >= 65040 && cp <= 65049 || cp >= 65072 && cp <= 65135 || cp >= 65280 && cp <= 65376 || cp >= 65504 && cp <= 65510 || cp >= 110592 && cp <= 110959 || cp >= 127488 && cp <= 127569 || cp >= 131072 && cp <= 262141 || cp >= 9728 && cp <= 10175 || cp >= 126976 && cp <= 129791;
181
180
  }
182
181
  /**
183
- * Create a style function that applies the given styles
184
- */
185
- function createStyleFn(...styleArgs) {
186
- return (text) => {
187
- if (colorDisabled) return text;
188
- let result = text;
189
- for (const style of styleArgs) result = styleText(style, result);
190
- return result;
191
- };
182
+ * Visual width of a single grapheme cluster (a user-perceived character).
183
+ *
184
+ * Iterating by code point would over-count multi-code-point clusters such as
185
+ * ZWJ emoji sequences (👨‍👩‍👧), regional-indicator flags (🇯🇵), and emoji with
186
+ * skin-tone modifiers (👍🏽). These render as a single glyph, so the whole
187
+ * cluster contributes width 0/1/2 once.
188
+ */
189
+ function graphemeWidth(grapheme) {
190
+ let hasVisible = false;
191
+ let hasWide = false;
192
+ let hasEmojiVariation = false;
193
+ for (const char of grapheme) {
194
+ const cp = char.codePointAt(0);
195
+ if (cp === 65039) {
196
+ hasEmojiVariation = true;
197
+ continue;
198
+ }
199
+ if (isZeroWidth(cp)) continue;
200
+ hasVisible = true;
201
+ if (isFullWidth(cp)) hasWide = true;
202
+ }
203
+ if (!hasVisible) return 0;
204
+ return hasWide || hasEmojiVariation ? 2 : 1;
192
205
  }
206
+ const segmenter = (() => {
207
+ try {
208
+ return new Intl.Segmenter("en", { granularity: "grapheme" });
209
+ } catch {
210
+ return;
211
+ }
212
+ })();
193
213
  /**
194
- * Semantic style functions for inline text styling
195
- */
196
- const styles = {
197
- success: createStyleFn("green"),
198
- error: createStyleFn("red"),
199
- warning: createStyleFn("yellow"),
200
- info: createStyleFn("cyan"),
201
- bold: createStyleFn("bold"),
202
- dim: createStyleFn("dim"),
203
- italic: createStyleFn("italic"),
204
- underline: createStyleFn("underline"),
205
- red: createStyleFn("red"),
206
- green: createStyleFn("green"),
207
- yellow: createStyleFn("yellow"),
208
- blue: createStyleFn("blue"),
209
- magenta: createStyleFn("magenta"),
210
- cyan: createStyleFn("cyan"),
211
- white: createStyleFn("white"),
212
- gray: createStyleFn("gray"),
213
- command: createStyleFn("bold"),
214
- commandName: createStyleFn("bold", "underline", "cyan"),
215
- option: createStyleFn("cyan"),
216
- optionName: createStyleFn("bold"),
217
- placeholder: createStyleFn("dim"),
218
- defaultValue: createStyleFn("dim"),
219
- required: createStyleFn("yellow"),
220
- description: (text) => text,
221
- sectionHeader: createStyleFn("bold", "underline"),
222
- version: createStyleFn("dim")
223
- };
224
- /**
225
- * Standardized symbols for CLI output
226
- */
227
- const symbols = {
228
- success: styles.green("✓"),
229
- error: styles.red("✖"),
230
- warning: styles.yellow("⚠"),
231
- info: styles.cyan("ℹ"),
232
- bullet: styles.gray("•"),
233
- arrow: styles.gray("→")
234
- };
235
- /**
236
- * Logger for CLI output
214
+ * Compute the visual width of a string as rendered in a terminal.
237
215
  */
238
- const logger = {
239
- /**
240
- * Log informational message
241
- */
242
- info(message) {
243
- console.log(message);
244
- },
245
- /**
246
- * Log success message
247
- */
248
- success(message) {
249
- console.log(`${symbols.success} ${styles.success(message)}`);
250
- },
251
- /**
252
- * Log warning message
253
- */
254
- warn(message) {
255
- console.warn(`${symbols.warning} ${styles.warning(message)}`);
256
- },
257
- /**
258
- * Log error message
259
- */
260
- error(message) {
261
- console.error(`${symbols.error} ${styles.error(message)}`);
262
- },
263
- /**
264
- * Log raw message without prefix
265
- */
266
- log(message) {
267
- console.log(message);
268
- },
269
- /**
270
- * Log empty line
271
- */
272
- newline() {
273
- console.log("");
274
- },
275
- /**
276
- * Log debug message with dim color
277
- */
278
- debug(message) {
279
- console.log(styles.dim(message));
280
- }
281
- };
216
+ function stringWidth(input) {
217
+ if (input.length === 0) return 0;
218
+ const str = input.includes("\x1B") || input.includes("›") ? stripVTControlCharacters(input) : input;
219
+ let width = 0;
220
+ if (segmenter) for (const { segment } of segmenter.segment(str)) width += graphemeWidth(segment);
221
+ else for (const char of str) width += graphemeWidth(char);
222
+ return width;
223
+ }
282
224
 
283
225
  //#endregion
284
226
  //#region src/output/markdown-renderer.ts
@@ -2704,5 +2646,5 @@ function extractAndValidateGlobal(options) {
2704
2646
  }
2705
2647
 
2706
2648
  //#endregion
2707
- export { renderMarkdown as C, styles as D, setColorEnabled as E, symbols as O, renderInline as S, logger as T, DuplicateFieldError as _, parseArgv as a, ReservedAliasError as b, validateCommand as c, validateDuplicateFields as d, validateDuplicateNegations as f, DuplicateAliasError as g, CaseVariantCollisionError as h, formatValidationErrors as i, createDualCaseProxy as k, validateCrossSchemaCollisions as l, validateReservedAliases as m, runMain as n, formatCommandValidationErrors as o, validatePositionalConfig as p, runner_exports as r, validateCaseVariantCollisions as s, runCommand as t, validateDuplicateAliases as u, DuplicateNegationError as v, isColorEnabled as w, generateHelp as x, PositionalConfigError as y };
2708
- //# sourceMappingURL=runner-D43SkHt5.js.map
2649
+ export { renderMarkdown as C, renderInline as S, DuplicateFieldError as _, parseArgv as a, ReservedAliasError as b, validateCommand as c, validateDuplicateFields as d, validateDuplicateNegations as f, DuplicateAliasError as g, CaseVariantCollisionError as h, formatValidationErrors as i, validateCrossSchemaCollisions as l, validateReservedAliases as m, runMain as n, formatCommandValidationErrors as o, validatePositionalConfig as p, runner_exports as r, validateCaseVariantCollisions as s, runCommand as t, validateDuplicateAliases as u, DuplicateNegationError as v, createDualCaseProxy as w, generateHelp as x, PositionalConfigError as y };
2650
+ //# sourceMappingURL=runner-B-FZMN89.js.map
@@ -1,26 +1,5 @@
1
- import { z } from "zod";
1
+ import { n as getArgMeta$1 } from "./arg-registry-BeLLAW5-.js";
2
2
 
3
- //#region src/core/arg-registry.ts
4
- /**
5
- * Custom registry for politty argument metadata
6
- * This avoids polluting Zod's GlobalMeta
7
- */
8
- const argRegistry = z.registry();
9
- function arg(schema, meta) {
10
- if (meta) argRegistry.add(schema, meta);
11
- return schema;
12
- }
13
- /**
14
- * Get metadata for a schema from the registry
15
- *
16
- * @param schema - The Zod schema
17
- * @returns The metadata if registered, undefined otherwise
18
- */
19
- function getArgMeta$1(schema) {
20
- return argRegistry.get(schema);
21
- }
22
-
23
- //#endregion
24
3
  //#region src/lazy.ts
25
4
  /**
26
5
  * Marker property for LazyCommand identification
@@ -617,5 +596,5 @@ function getExtractedFields(command) {
617
596
  }
618
597
 
619
598
  //#endregion
620
- export { toCamelCase as a, listSubCommands as c, resolveSubcommandWithAlias as d, isLazyCommand as f, arg as h, getUnknownKeysMode as i, resolveLazyCommand as l, resolveSubCommandMeta as m, getAllAliases as n, toKebabCase as o, lazy as p, getExtractedFields as r, listSubCommandNamesWithAliases as s, extractFields as t, resolveSubCommandAlias as u };
621
- //# sourceMappingURL=schema-extractor-Dqe7_kyQ.js.map
599
+ export { toCamelCase as a, listSubCommands as c, resolveSubcommandWithAlias as d, isLazyCommand as f, getUnknownKeysMode as i, resolveLazyCommand as l, resolveSubCommandMeta as m, getAllAliases as n, toKebabCase as o, lazy as p, getExtractedFields as r, listSubCommandNamesWithAliases as s, extractFields as t, resolveSubCommandAlias as u };
600
+ //# sourceMappingURL=schema-extractor-CVHWm23M.js.map