politty 0.9.0 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -0
- package/dist/arg-registry-BeLLAW5-.js +25 -0
- package/dist/cli.js +4 -3
- package/dist/command-B4yA4LXX.js +43 -0
- package/dist/completion/index.js +1 -1
- package/dist/{completion-DHnVx9Zk.js → completion-DwTFOtQk.js} +5 -44
- package/dist/docs/index.js +4 -3
- package/dist/index.js +6 -3
- package/dist/logger-DbDkjdfO.js +134 -0
- package/dist/{runner-APRZYXUS.js → runner-BmWR9TLM.js} +9 -136
- package/dist/{schema-extractor-Dqe7_kyQ.js → schema-extractor-CVHWm23M.js} +3 -24
- package/dist/skill/index.d.ts +432 -0
- package/dist/skill/index.js +1563 -0
- package/package.json +9 -2
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-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { n as runMain } from "./runner-BmWR9TLM.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
|
package/dist/completion/index.js
CHANGED
|
@@ -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-
|
|
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 {
|
|
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 {
|
|
5638
|
-
//# sourceMappingURL=completion-
|
|
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
|
package/dist/docs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as resolveLazyCommand, r as getExtractedFields, t as extractFields } from "../schema-extractor-
|
|
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";
|
|
@@ -131,7 +131,8 @@ function formatDefaultValue$1(value) {
|
|
|
131
131
|
function renderUsage(info) {
|
|
132
132
|
const parts = [info.fullCommandPath];
|
|
133
133
|
if (info.options.length > 0) parts.push("[options]");
|
|
134
|
-
if (info.subCommands.length > 0) parts.push("[command]");
|
|
134
|
+
if (info.subCommands.length > 0) if (info.command.run) parts.push("[command]");
|
|
135
|
+
else parts.push("<command>");
|
|
135
136
|
for (const arg of info.positionalArgs) if (arg.required) parts.push(`<${arg.name}>`);
|
|
136
137
|
else parts.push(`[${arg.name}]`);
|
|
137
138
|
return parts.join(" ");
|
|
@@ -874,7 +875,7 @@ async function executeSingleExample(example, rootCommand, commandPath) {
|
|
|
874
875
|
collector.start();
|
|
875
876
|
let success = true;
|
|
876
877
|
try {
|
|
877
|
-
const { runCommand } = await import("../runner-
|
|
878
|
+
const { runCommand } = await import("../runner-BmWR9TLM.js").then((n) => n.r);
|
|
878
879
|
const result = await runCommand(rootCommand, argv);
|
|
879
880
|
success = result.success;
|
|
880
881
|
if (!result.success && result.error) console.error(result.error.message);
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { C as renderMarkdown,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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-BmWR9TLM.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,6 +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-
|
|
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 {
|
|
3
|
+
import { a as symbols, i as styles } from "./logger-DbDkjdfO.js";
|
|
4
|
+
import { stripVTControlCharacters } from "node:util";
|
|
4
5
|
|
|
5
6
|
//#region \0rolldown/runtime.js
|
|
6
7
|
var __defProp = Object.defineProperty;
|
|
@@ -149,136 +150,6 @@ async function executeLifecycle(command, args, _options = {}) {
|
|
|
149
150
|
};
|
|
150
151
|
}
|
|
151
152
|
|
|
152
|
-
//#endregion
|
|
153
|
-
//#region src/output/logger.ts
|
|
154
|
-
/**
|
|
155
|
-
* Check if color output should be disabled
|
|
156
|
-
*/
|
|
157
|
-
function shouldDisableColor() {
|
|
158
|
-
if (process.env.NO_COLOR !== void 0) return true;
|
|
159
|
-
if (process.env.FORCE_COLOR === "0") return true;
|
|
160
|
-
if (process.env.FORCE_COLOR) return false;
|
|
161
|
-
if (process.env.CI) return true;
|
|
162
|
-
if (!process.stdout.isTTY) return true;
|
|
163
|
-
return false;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Global flag to control color output
|
|
167
|
-
*/
|
|
168
|
-
let colorDisabled = shouldDisableColor();
|
|
169
|
-
/**
|
|
170
|
-
* Enable or disable color output programmatically
|
|
171
|
-
*/
|
|
172
|
-
function setColorEnabled(enabled) {
|
|
173
|
-
colorDisabled = !enabled;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Check if color output is currently enabled
|
|
177
|
-
*/
|
|
178
|
-
function isColorEnabled() {
|
|
179
|
-
return !colorDisabled;
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Create a style function that applies the given styles
|
|
183
|
-
*/
|
|
184
|
-
function createStyleFn(...styleArgs) {
|
|
185
|
-
return (text) => {
|
|
186
|
-
if (colorDisabled) return text;
|
|
187
|
-
let result = text;
|
|
188
|
-
for (const style of styleArgs) result = styleText(style, result);
|
|
189
|
-
return result;
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Semantic style functions for inline text styling
|
|
194
|
-
*/
|
|
195
|
-
const styles = {
|
|
196
|
-
success: createStyleFn("green"),
|
|
197
|
-
error: createStyleFn("red"),
|
|
198
|
-
warning: createStyleFn("yellow"),
|
|
199
|
-
info: createStyleFn("cyan"),
|
|
200
|
-
bold: createStyleFn("bold"),
|
|
201
|
-
dim: createStyleFn("dim"),
|
|
202
|
-
italic: createStyleFn("italic"),
|
|
203
|
-
underline: createStyleFn("underline"),
|
|
204
|
-
red: createStyleFn("red"),
|
|
205
|
-
green: createStyleFn("green"),
|
|
206
|
-
yellow: createStyleFn("yellow"),
|
|
207
|
-
blue: createStyleFn("blue"),
|
|
208
|
-
magenta: createStyleFn("magenta"),
|
|
209
|
-
cyan: createStyleFn("cyan"),
|
|
210
|
-
white: createStyleFn("white"),
|
|
211
|
-
gray: createStyleFn("gray"),
|
|
212
|
-
command: createStyleFn("bold"),
|
|
213
|
-
commandName: createStyleFn("bold", "underline", "cyan"),
|
|
214
|
-
option: createStyleFn("cyan"),
|
|
215
|
-
optionName: createStyleFn("bold"),
|
|
216
|
-
placeholder: createStyleFn("dim"),
|
|
217
|
-
defaultValue: createStyleFn("dim"),
|
|
218
|
-
required: createStyleFn("yellow"),
|
|
219
|
-
description: (text) => text,
|
|
220
|
-
sectionHeader: createStyleFn("bold", "underline"),
|
|
221
|
-
version: createStyleFn("dim")
|
|
222
|
-
};
|
|
223
|
-
/**
|
|
224
|
-
* Standardized symbols for CLI output
|
|
225
|
-
*/
|
|
226
|
-
const symbols = {
|
|
227
|
-
success: styles.green("✓"),
|
|
228
|
-
error: styles.red("✖"),
|
|
229
|
-
warning: styles.yellow("⚠"),
|
|
230
|
-
info: styles.cyan("ℹ"),
|
|
231
|
-
bullet: styles.gray("•"),
|
|
232
|
-
arrow: styles.gray("→")
|
|
233
|
-
};
|
|
234
|
-
/**
|
|
235
|
-
* Logger for CLI output
|
|
236
|
-
*/
|
|
237
|
-
const logger = {
|
|
238
|
-
/**
|
|
239
|
-
* Log informational message
|
|
240
|
-
*/
|
|
241
|
-
info(message) {
|
|
242
|
-
console.log(message);
|
|
243
|
-
},
|
|
244
|
-
/**
|
|
245
|
-
* Log success message
|
|
246
|
-
*/
|
|
247
|
-
success(message) {
|
|
248
|
-
console.log(`${symbols.success} ${styles.success(message)}`);
|
|
249
|
-
},
|
|
250
|
-
/**
|
|
251
|
-
* Log warning message
|
|
252
|
-
*/
|
|
253
|
-
warn(message) {
|
|
254
|
-
console.warn(`${symbols.warning} ${styles.warning(message)}`);
|
|
255
|
-
},
|
|
256
|
-
/**
|
|
257
|
-
* Log error message
|
|
258
|
-
*/
|
|
259
|
-
error(message) {
|
|
260
|
-
console.error(`${symbols.error} ${styles.error(message)}`);
|
|
261
|
-
},
|
|
262
|
-
/**
|
|
263
|
-
* Log raw message without prefix
|
|
264
|
-
*/
|
|
265
|
-
log(message) {
|
|
266
|
-
console.log(message);
|
|
267
|
-
},
|
|
268
|
-
/**
|
|
269
|
-
* Log empty line
|
|
270
|
-
*/
|
|
271
|
-
newline() {
|
|
272
|
-
console.log("");
|
|
273
|
-
},
|
|
274
|
-
/**
|
|
275
|
-
* Log debug message with dim color
|
|
276
|
-
*/
|
|
277
|
-
debug(message) {
|
|
278
|
-
console.log(styles.dim(message));
|
|
279
|
-
}
|
|
280
|
-
};
|
|
281
|
-
|
|
282
153
|
//#endregion
|
|
283
154
|
//#region src/output/string-width.ts
|
|
284
155
|
/**
|
|
@@ -705,10 +576,12 @@ function renderUsageLine(command, context) {
|
|
|
705
576
|
if (extracted) {
|
|
706
577
|
const positionals = extracted.fields.filter((a) => a.positional);
|
|
707
578
|
if (extracted.fields.filter((a) => !a.positional).length > 0) parts.push(styles.placeholder("[options]"));
|
|
708
|
-
if (command.subCommands && getVisibleSubcommandEntries(command.subCommands).length > 0) parts.push(styles.placeholder("[command]"));
|
|
579
|
+
if (command.subCommands && getVisibleSubcommandEntries(command.subCommands).length > 0) if (command.run) parts.push(styles.placeholder("[command]"));
|
|
580
|
+
else parts.push(styles.option("<command>"));
|
|
709
581
|
for (const arg of positionals) if (arg.required) parts.push(styles.option(`<${arg.name}>`));
|
|
710
582
|
else parts.push(styles.placeholder(`[${arg.name}]`));
|
|
711
|
-
} else if (command.subCommands && getVisibleSubcommandEntries(command.subCommands).length > 0) parts.push(styles.placeholder("[command]"));
|
|
583
|
+
} else if (command.subCommands && getVisibleSubcommandEntries(command.subCommands).length > 0) if (command.run) parts.push(styles.placeholder("[command]"));
|
|
584
|
+
else parts.push(styles.option("<command>"));
|
|
712
585
|
return parts.join(" ");
|
|
713
586
|
}
|
|
714
587
|
/**
|
|
@@ -2775,5 +2648,5 @@ function extractAndValidateGlobal(options) {
|
|
|
2775
2648
|
}
|
|
2776
2649
|
|
|
2777
2650
|
//#endregion
|
|
2778
|
-
export { renderMarkdown as C,
|
|
2779
|
-
//# sourceMappingURL=runner-
|
|
2651
|
+
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 };
|
|
2652
|
+
//# sourceMappingURL=runner-BmWR9TLM.js.map
|
|
@@ -1,26 +1,5 @@
|
|
|
1
|
-
import {
|
|
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,
|
|
621
|
-
//# sourceMappingURL=schema-extractor-
|
|
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
|