@runa-cmd/core 0.1.0 → 0.2.0-beta.0
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/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +69 -58
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +5 -3
- package/dist/lifecycle.js.map +1 -1
- package/dist/parse/adapters/zod-v4.d.ts +3 -0
- package/dist/parse/adapters/zod-v4.d.ts.map +1 -0
- package/dist/parse/adapters/zod-v4.js +103 -0
- package/dist/parse/adapters/zod-v4.js.map +1 -0
- package/dist/parse/parseargs-bridge.d.ts +10 -0
- package/dist/parse/parseargs-bridge.d.ts.map +1 -1
- package/dist/parse/parseargs-bridge.js +10 -0
- package/dist/parse/parseargs-bridge.js.map +1 -1
- package/dist/parse/resolve.d.ts +13 -0
- package/dist/parse/resolve.d.ts.map +1 -1
- package/dist/parse/resolve.js +26 -28
- package/dist/parse/resolve.js.map +1 -1
- package/dist/parse/schema-adapter.d.ts +40 -0
- package/dist/parse/schema-adapter.d.ts.map +1 -0
- package/dist/parse/schema-adapter.js +4 -0
- package/dist/parse/schema-adapter.js.map +1 -0
- package/dist/parse/schema-walker.d.ts +3 -3
- package/dist/parse/schema-walker.d.ts.map +1 -1
- package/dist/parse/schema-walker.js +12 -104
- package/dist/parse/schema-walker.js.map +1 -1
- package/dist/parse/strict.d.ts +21 -0
- package/dist/parse/strict.d.ts.map +1 -0
- package/dist/parse/strict.js +42 -0
- package/dist/parse/strict.js.map +1 -0
- package/dist/parse/variadic.d.ts +2 -1
- package/dist/parse/variadic.d.ts.map +1 -1
- package/dist/parse/variadic.js +4 -24
- package/dist/parse/variadic.js.map +1 -1
- package/dist/plugin.d.ts +31 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +138 -0
- package/dist/plugin.js.map +1 -1
- package/dist/suggest.d.ts +17 -0
- package/dist/suggest.d.ts.map +1 -0
- package/dist/suggest.js +55 -0
- package/dist/suggest.js.map +1 -0
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/parse/resolve.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,QAAQ,EAAgB,CAAC,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAgC3C,+DAA+D;AAE/D,SAAS,cAAc,CACtB,WAAqB,EACrB,WAAoC;IAEpC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACtC,MAAM,MAAM,GAA4B,EAAE,CAAC;IAE3C,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,2CAA2C;QAC3C,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,eAAe,CAAC;gBACzB;oBACC,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,oCAAoC,WAAW,CAAC,CAAC,CAAC,GAAG;oBAC9D,IAAI,EAAE,EAAE;iBACR;aACD,CAAC,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAED,gCAAgC;IAChC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACtC,IAAI,CAAC,OAAO;QAAE,OAAO,MAAM,CAAC;IAC5B,MAAM,UAAU,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM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
|
|
3
|
+
*
|
|
4
|
+
* Introspection-only abstraction over schema-library internals (design D1).
|
|
5
|
+
* The adapter answers structural questions (kind, optionality, default,
|
|
6
|
+
* enum values, description) — it does NOT validate; `resolve.ts` keeps
|
|
7
|
+
* calling Zod's `.parse()` directly.
|
|
8
|
+
*
|
|
9
|
+
* The `SchemaAdapter`/`SchemaDescription` types are public (exported from
|
|
10
|
+
* the package barrel) to enable external experimentation, but adapter
|
|
11
|
+
* SELECTION stays internal: no `schemaAdapter` config option ships until
|
|
12
|
+
* a second implementation exists (design D2).
|
|
13
|
+
*/
|
|
14
|
+
import type { ZodType } from 'zod';
|
|
15
|
+
import type { ParamType } from '../types.js';
|
|
16
|
+
export interface SchemaAdapter {
|
|
17
|
+
/** Adapter identity for diagnostics, e.g. 'zod-v4' */
|
|
18
|
+
readonly name: string;
|
|
19
|
+
/** Whether this adapter can introspect the given schema object */
|
|
20
|
+
supports(schema: unknown): boolean;
|
|
21
|
+
/** Full structural description: unwraps optional/default/nullable internally */
|
|
22
|
+
describe(schema: ZodType): SchemaDescription;
|
|
23
|
+
}
|
|
24
|
+
export interface SchemaDescription {
|
|
25
|
+
/** Base type kind after unwrapping (int maps to 'number'; unknown falls back to 'string') */
|
|
26
|
+
kind: ParamType;
|
|
27
|
+
/** Optional from the user's perspective: explicitly optional OR carrying a default */
|
|
28
|
+
isOptional: boolean;
|
|
29
|
+
/** Whether a `default` wrapper is present */
|
|
30
|
+
hasDefault: boolean;
|
|
31
|
+
/** The default value; undefined when hasDefault is false */
|
|
32
|
+
defaultValue: unknown;
|
|
33
|
+
/** Enum member values, present only when kind is 'enum' */
|
|
34
|
+
enumValues?: string[];
|
|
35
|
+
/** Schema description, preferring the outermost layer that has one */
|
|
36
|
+
description?: string;
|
|
37
|
+
}
|
|
38
|
+
/** The adapter used by schema-walker/variadic. Internal — not exported from the barrel. */
|
|
39
|
+
export declare const defaultAdapter: SchemaAdapter;
|
|
40
|
+
//# sourceMappingURL=schema-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-adapter.d.ts","sourceRoot":"","sources":["../../src/parse/schema-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C,MAAM,WAAW,aAAa;IAC7B,sDAAsD;IACtD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,kEAAkE;IAClE,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC;IACnC,gFAAgF;IAChF,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,iBAAiB,CAAC;CAC7C;AAED,MAAM,WAAW,iBAAiB;IACjC,6FAA6F;IAC7F,IAAI,EAAE,SAAS,CAAC;IAChB,sFAAsF;IACtF,UAAU,EAAE,OAAO,CAAC;IACpB,6CAA6C;IAC7C,UAAU,EAAE,OAAO,CAAC;IACpB,4DAA4D;IAC5D,YAAY,EAAE,OAAO,CAAC;IACtB,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,sEAAsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,2FAA2F;AAC3F,eAAO,MAAM,cAAc,EAAE,aAA4B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-adapter.js","sourceRoot":"","sources":["../../src/parse/schema-adapter.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AA0BpD,2FAA2F;AAC3F,MAAM,CAAC,MAAM,cAAc,GAAkB,YAAY,CAAC"}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* @runa-cmd/core — Zod Schema Walker
|
|
3
3
|
*
|
|
4
4
|
* Walks Zod schemas to extract parameter metadata (type, default, required,
|
|
5
|
-
* description, enum values, variadic).
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* description, enum values, variadic). Introspection is delegated to the
|
|
6
|
+
* SchemaAdapter seam (see `schema-adapter.ts`); this module only maps
|
|
7
|
+
* `SchemaDescription` onto the `ParamMetadata` shape.
|
|
8
8
|
*/
|
|
9
9
|
import type { ZodType } from 'zod';
|
|
10
10
|
import type { ParamMetadata } from '../types.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-walker.d.ts","sourceRoot":"","sources":["../../src/parse/schema-walker.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,KAAK,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"schema-walker.d.ts","sourceRoot":"","sources":["../../src/parse/schema-walker.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAmBjD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa,EAAE,CAE5E;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,aAAa,CAE7E"}
|
|
@@ -1,121 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
function
|
|
3
|
-
const
|
|
4
|
-
if (!s._zod?.def) {
|
|
5
|
-
throw new Error('Cannot introspect Zod schema: ._zod.def is missing. Ensure you are using Zod v4.');
|
|
6
|
-
}
|
|
7
|
-
return s._zod.def;
|
|
8
|
-
}
|
|
9
|
-
function getDescription(schema) {
|
|
10
|
-
const s = schema;
|
|
11
|
-
return s.description;
|
|
12
|
-
}
|
|
13
|
-
function unwrapSchema(schema) {
|
|
14
|
-
let isOptional = false;
|
|
15
|
-
let defaultValue;
|
|
16
|
-
let hasDefault = false;
|
|
17
|
-
let description = getDescription(schema);
|
|
18
|
-
let current = schema;
|
|
19
|
-
// Iteratively unwrap layers
|
|
20
|
-
const maxDepth = 10; // safety limit
|
|
21
|
-
for (let i = 0; i < maxDepth; i++) {
|
|
22
|
-
const def = getZodDef(current);
|
|
23
|
-
if (def.type === 'optional') {
|
|
24
|
-
isOptional = true;
|
|
25
|
-
current = def.innerType;
|
|
26
|
-
if (!description)
|
|
27
|
-
description = getDescription(current);
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
if (def.type === 'default') {
|
|
31
|
-
isOptional = true; // defaults make the field optional from the user's perspective
|
|
32
|
-
hasDefault = true;
|
|
33
|
-
defaultValue = def.defaultValue;
|
|
34
|
-
current = def.innerType;
|
|
35
|
-
if (!description)
|
|
36
|
-
description = getDescription(current);
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
if (def.type === 'nullable') {
|
|
40
|
-
current = def.innerType;
|
|
41
|
-
if (!description)
|
|
42
|
-
description = getDescription(current);
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
// Base type reached
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
// If we found a default via the wrapper, keep it.
|
|
49
|
-
// If not, defaultValue stays undefined.
|
|
1
|
+
import { defaultAdapter } from './schema-adapter.js';
|
|
2
|
+
function toParamMetadata(name, schema) {
|
|
3
|
+
const desc = defaultAdapter.describe(schema);
|
|
50
4
|
return {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
isOptional,
|
|
54
|
-
defaultValue:
|
|
55
|
-
|
|
5
|
+
name,
|
|
6
|
+
zodType: desc.kind,
|
|
7
|
+
isOptional: desc.isOptional,
|
|
8
|
+
defaultValue: desc.defaultValue,
|
|
9
|
+
isArray: desc.kind === 'array',
|
|
10
|
+
enumValues: desc.enumValues,
|
|
11
|
+
description: desc.description,
|
|
56
12
|
};
|
|
57
13
|
}
|
|
58
|
-
// ─── Detect base type ───────────────────────────────────────
|
|
59
|
-
function detectParamType(def) {
|
|
60
|
-
switch (def.type) {
|
|
61
|
-
case 'string':
|
|
62
|
-
return { zodType: 'string' };
|
|
63
|
-
case 'number':
|
|
64
|
-
case 'int':
|
|
65
|
-
return { zodType: 'number' };
|
|
66
|
-
case 'boolean':
|
|
67
|
-
return { zodType: 'boolean' };
|
|
68
|
-
case 'enum': {
|
|
69
|
-
// Zod v4 uses `entries` (object { staging: 'staging', prod: 'prod' })
|
|
70
|
-
// not `values` (array). Extract the values from the entries object.
|
|
71
|
-
const entries = def.entries;
|
|
72
|
-
const values = entries ? Object.values(entries) : undefined;
|
|
73
|
-
return { zodType: 'enum', enumValues: values };
|
|
74
|
-
}
|
|
75
|
-
case 'array':
|
|
76
|
-
return { zodType: 'array' };
|
|
77
|
-
default:
|
|
78
|
-
// Fallback: treat unknown types as string
|
|
79
|
-
return { zodType: 'string' };
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
14
|
// ─── Public API ─────────────────────────────────────────────
|
|
83
15
|
/**
|
|
84
16
|
* Walk a record of Zod schemas and extract parameter metadata for each key.
|
|
85
17
|
* Keys are returned in insertion order (Object.entries preserves it).
|
|
86
18
|
*/
|
|
87
19
|
export function walkSchema(schemas) {
|
|
88
|
-
|
|
89
|
-
for (const [name, schema] of Object.entries(schemas)) {
|
|
90
|
-
const { baseDef, isOptional, defaultValue, description } = unwrapSchema(schema);
|
|
91
|
-
const { zodType, enumValues } = detectParamType(baseDef);
|
|
92
|
-
result.push({
|
|
93
|
-
name,
|
|
94
|
-
zodType,
|
|
95
|
-
isOptional,
|
|
96
|
-
defaultValue,
|
|
97
|
-
isArray: zodType === 'array',
|
|
98
|
-
enumValues,
|
|
99
|
-
description,
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
return result;
|
|
20
|
+
return Object.entries(schemas).map(([name, schema]) => toParamMetadata(name, schema));
|
|
103
21
|
}
|
|
104
22
|
/**
|
|
105
23
|
* Walk a single Zod schema and extract its metadata.
|
|
106
24
|
* Used by other modules that need to inspect individual schemas.
|
|
107
25
|
*/
|
|
108
26
|
export function walkSingleSchema(name, schema) {
|
|
109
|
-
|
|
110
|
-
const { zodType, enumValues } = detectParamType(baseDef);
|
|
111
|
-
return {
|
|
112
|
-
name,
|
|
113
|
-
zodType,
|
|
114
|
-
isOptional,
|
|
115
|
-
defaultValue,
|
|
116
|
-
isArray: zodType === 'array',
|
|
117
|
-
enumValues,
|
|
118
|
-
description,
|
|
119
|
-
};
|
|
27
|
+
return toParamMetadata(name, schema);
|
|
120
28
|
}
|
|
121
29
|
//# sourceMappingURL=schema-walker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-walker.js","sourceRoot":"","sources":["../../src/parse/schema-walker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema-walker.js","sourceRoot":"","sources":["../../src/parse/schema-walker.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,SAAS,eAAe,CAAC,IAAY,EAAE,MAAe;IACrD,MAAM,IAAI,GAAG,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAE7C,OAAO;QACN,IAAI;QACJ,OAAO,EAAE,IAAI,CAAC,IAAI;QAClB,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,YAAY,EAAE,IAAI,CAAC,YAAY;QAC/B,OAAO,EAAE,IAAI,CAAC,IAAI,KAAK,OAAO;QAC9B,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,WAAW,EAAE,IAAI,CAAC,WAAW;KAC7B,CAAC;AACH,CAAC;AAED,+DAA+D;AAE/D;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,OAAgC;IAC1D,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;AACvF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,MAAe;IAC7D,OAAO,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface AssertKnownOptionsInput {
|
|
2
|
+
/** Object.keys() of the util.parseArgs result `.values` */
|
|
3
|
+
producedKeys: string[];
|
|
4
|
+
/**
|
|
5
|
+
* Keys parseArgs may legitimately produce: canonical names + long aliases
|
|
6
|
+
* (+ defensive `no-*` negations) from parseargs-bridge, plus global option
|
|
7
|
+
* names, long aliases, and short-alias characters added by the caller.
|
|
8
|
+
*/
|
|
9
|
+
knownKeys: Set<string>;
|
|
10
|
+
/** Canonical names of boolean options — accepts `no-{name}` keys defensively */
|
|
11
|
+
booleanKeys: Set<string>;
|
|
12
|
+
/** Candidate names for did-you-mean: command + global canonical names and long aliases */
|
|
13
|
+
suggestionCandidates: string[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Throw a ValidationError (exit 2) on the first parseArgs-produced key that
|
|
17
|
+
* is not registered, with a did-you-mean suggestion when a candidate is
|
|
18
|
+
* within Levenshtein distance ≤ 3.
|
|
19
|
+
*/
|
|
20
|
+
export declare function assertKnownOptions(input: AssertKnownOptionsInput): void;
|
|
21
|
+
//# sourceMappingURL=strict.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strict.d.ts","sourceRoot":"","sources":["../../src/parse/strict.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,uBAAuB;IACvC,2DAA2D;IAC3D,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB;;;;OAIG;IACH,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACvB,gFAAgF;IAChF,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB,0FAA0F;IAC1F,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAC/B;AAWD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,GAAG,IAAI,CAoBvE"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @runa-cmd/core — Strict unknown-option checking
|
|
3
|
+
*
|
|
4
|
+
* Post-parse validation: util.parseArgs runs with `strict: false` (required
|
|
5
|
+
* for the alias/negation handling and the two-pass global/command parse), so
|
|
6
|
+
* unknown flags surface here as unexpected keys in the parse result. This is
|
|
7
|
+
* the SINGLE place the check lives — disabling it is one call-site guard
|
|
8
|
+
* (`CLIConfig.strictOptions: false`).
|
|
9
|
+
*/
|
|
10
|
+
import { ValidationError } from '../errors.js';
|
|
11
|
+
import { findSuggestion } from '../suggest.js';
|
|
12
|
+
// ─── Helpers ────────────────────────────────────────────────
|
|
13
|
+
/** Render a parseArgs value key as the flag the user typed: `-x` or `--xyz`. */
|
|
14
|
+
function renderFlag(key) {
|
|
15
|
+
return key.length === 1 ? `-${key}` : `--${key}`;
|
|
16
|
+
}
|
|
17
|
+
// ─── Public API ─────────────────────────────────────────────
|
|
18
|
+
/**
|
|
19
|
+
* Throw a ValidationError (exit 2) on the first parseArgs-produced key that
|
|
20
|
+
* is not registered, with a did-you-mean suggestion when a candidate is
|
|
21
|
+
* within Levenshtein distance ≤ 3.
|
|
22
|
+
*/
|
|
23
|
+
export function assertKnownOptions(input) {
|
|
24
|
+
const { producedKeys, knownKeys, booleanKeys, suggestionCandidates } = input;
|
|
25
|
+
for (const key of producedKeys) {
|
|
26
|
+
if (knownKeys.has(key))
|
|
27
|
+
continue;
|
|
28
|
+
// Defensive allowance: on Node 24, parseArgs folds `--no-x` into
|
|
29
|
+
// `x: false` even for unregistered keys (see parseargs-negation.test.ts),
|
|
30
|
+
// so `no-*` keys never appear today — this guards a future Node line
|
|
31
|
+
// surfacing the negation token un-folded.
|
|
32
|
+
if (key.startsWith('no-') && booleanKeys.has(key.slice(3)))
|
|
33
|
+
continue;
|
|
34
|
+
const flag = renderFlag(key);
|
|
35
|
+
const suggestion = findSuggestion(key, suggestionCandidates);
|
|
36
|
+
const message = suggestion
|
|
37
|
+
? `Unknown option: ${flag}. Did you mean '${renderFlag(suggestion)}'?`
|
|
38
|
+
: `Unknown option: ${flag}`;
|
|
39
|
+
throw new ValidationError([{ code: 'custom', message, path: [] }]);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=strict.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strict.js","sourceRoot":"","sources":["../../src/parse/strict.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAmB/C,+DAA+D;AAE/D,gFAAgF;AAChF,SAAS,UAAU,CAAC,GAAW;IAC9B,OAAO,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;AAClD,CAAC;AAED,+DAA+D;AAE/D;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAA8B;IAChE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,oBAAoB,EAAE,GAAG,KAAK,CAAC;IAE7E,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;QAChC,IAAI,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,SAAS;QAEjC,iEAAiE;QACjE,0EAA0E;QAC1E,qEAAqE;QACrE,0CAA0C;QAC1C,IAAI,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAAE,SAAS;QAErE,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;QAC7B,MAAM,UAAU,GAAG,cAAc,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC;QAC7D,MAAM,OAAO,GAAG,UAAU;YACzB,CAAC,CAAC,mBAAmB,IAAI,mBAAmB,UAAU,CAAC,UAAU,CAAC,IAAI;YACtE,CAAC,CAAC,mBAAmB,IAAI,EAAE,CAAC;QAE7B,MAAM,IAAI,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IACpE,CAAC;AACF,CAAC"}
|
package/dist/parse/variadic.d.ts
CHANGED
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
import type { ZodType } from 'zod';
|
|
9
9
|
/**
|
|
10
10
|
* Check if a Zod schema is a z.array() type.
|
|
11
|
-
*
|
|
11
|
+
* Wrapper unwrapping (optional/default/nullable) is handled by the
|
|
12
|
+
* SchemaAdapter seam — this is a thin delegate over `describe()`.
|
|
12
13
|
*/
|
|
13
14
|
export declare function isVariadic(schema: ZodType): boolean;
|
|
14
15
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variadic.d.ts","sourceRoot":"","sources":["../../src/parse/variadic.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"variadic.d.ts","sourceRoot":"","sources":["../../src/parse/variadic.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAMnC;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAEnD;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAsCxE"}
|
package/dist/parse/variadic.js
CHANGED
|
@@ -1,33 +1,13 @@
|
|
|
1
1
|
import { RunaError } from '../errors.js';
|
|
2
|
-
|
|
3
|
-
const s = schema;
|
|
4
|
-
return s._zod?.def?.type ?? 'unknown';
|
|
5
|
-
}
|
|
2
|
+
import { defaultAdapter } from './schema-adapter.js';
|
|
6
3
|
// ─── Public API ─────────────────────────────────────────────
|
|
7
4
|
/**
|
|
8
5
|
* Check if a Zod schema is a z.array() type.
|
|
9
|
-
*
|
|
6
|
+
* Wrapper unwrapping (optional/default/nullable) is handled by the
|
|
7
|
+
* SchemaAdapter seam — this is a thin delegate over `describe()`.
|
|
10
8
|
*/
|
|
11
9
|
export function isVariadic(schema) {
|
|
12
|
-
|
|
13
|
-
const maxDepth = 10;
|
|
14
|
-
for (let i = 0; i < maxDepth; i++) {
|
|
15
|
-
const defType = getDefType(current);
|
|
16
|
-
if (defType === 'array') {
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
// Unwrap wrappers
|
|
20
|
-
if (defType === 'optional' || defType === 'default' || defType === 'nullable') {
|
|
21
|
-
const s = current;
|
|
22
|
-
const inner = s._zod?.def?.innerType;
|
|
23
|
-
if (inner) {
|
|
24
|
-
current = inner;
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
return false;
|
|
10
|
+
return defaultAdapter.describe(schema).kind === 'array';
|
|
31
11
|
}
|
|
32
12
|
/**
|
|
33
13
|
* Validate variadic arg constraints:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variadic.js","sourceRoot":"","sources":["../../src/parse/variadic.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"variadic.js","sourceRoot":"","sources":["../../src/parse/variadic.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC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J,CAAC;IAED,kDAAkD;IAClD,MAAM,UAAU,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;IACnC,IAAI,UAAU,IAAI,UAAU,CAAC,KAAK,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxD,MAAM,IAAI,SAAS,CAClB,iBAAiB,UAAU,CAAC,IAAI,0CAA0C;YACzE,qBAAqB,UAAU,CAAC,KAAK,OAAO,IAAI,CAAC,MAAM,GAAG,EAC3D,EAAE,IAAI,EAAE,2BAA2B,EAAE,QAAQ,EAAE,CAAC,EAAE,CAClD,CAAC;IACH,CAAC;IAED,wCAAwC;AACzC,CAAC"}
|
package/dist/plugin.d.ts
CHANGED
|
@@ -34,6 +34,14 @@ export interface PluginHostRefs {
|
|
|
34
34
|
middleware: Middleware[];
|
|
35
35
|
hookRegister: (name: HookName, handler: HookHandler) => void;
|
|
36
36
|
getSchema: () => CLISchema;
|
|
37
|
+
/**
|
|
38
|
+
* Registrant(s) per global option name, for collision attribution
|
|
39
|
+
* (design Decision 9). Statically-declared `config.globalOptions` are
|
|
40
|
+
* seeded with STATIC_GLOBAL_OPTION_SOURCE; `addGlobalOption` appends the
|
|
41
|
+
* registering plugin's name. More than one registrant = a collision that
|
|
42
|
+
* `validateOptionCollisions()` reports.
|
|
43
|
+
*/
|
|
44
|
+
globalOptionSources?: Map<string, string[]>;
|
|
37
45
|
}
|
|
38
46
|
/**
|
|
39
47
|
* Create a PluginAPI for a specific plugin, enforcing capability checks.
|
|
@@ -43,6 +51,29 @@ export declare function createPluginAPI(pluginName: string, capabilities: Plugin
|
|
|
43
51
|
* Call setup(api) for each plugin in topological order.
|
|
44
52
|
*/
|
|
45
53
|
export declare function runPluginSetup(plugins: PluginConfig[], refs: PluginHostRefs): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Sentinel registrant for global options declared statically in
|
|
56
|
+
* `config.globalOptions` (as opposed to plugin-registered ones).
|
|
57
|
+
*/
|
|
58
|
+
export declare const STATIC_GLOBAL_OPTION_SOURCE = "<cli-config>";
|
|
59
|
+
/**
|
|
60
|
+
* Single validation pass over the full option surface (design Decision 9).
|
|
61
|
+
* Called once per `cli.run()`, immediately after plugin setup — the earliest
|
|
62
|
+
* point where plugin-registered globals AND plugin-added commands both exist.
|
|
63
|
+
*
|
|
64
|
+
* Detects, in deterministic order:
|
|
65
|
+
* 1. Global-vs-global same-name registrations (two plugins, or config + plugin)
|
|
66
|
+
* 2. Global-vs-global alias overlaps (name or alias claimed by two globals)
|
|
67
|
+
* 3. Global-vs-command collisions (names + aliases, full nested command tree)
|
|
68
|
+
*
|
|
69
|
+
* Throws `RunaError` code `OPTION_COLLISION`, exit 1 (CLI-author defect, not a
|
|
70
|
+
* usage error) on the FIRST collision found. This function is the ONLY place
|
|
71
|
+
* the check lives — the proposal's rollback path (downgrade throw to
|
|
72
|
+
* `console.warn`) is a one-line change here.
|
|
73
|
+
*/
|
|
74
|
+
export declare function validateOptionCollisions(commands: CommandTree, globalOptions: Record<string, ZodType>, globalMeta: {
|
|
75
|
+
options: Record<string, OptionMeta>;
|
|
76
|
+
}, sources?: Map<string, string[]>): void;
|
|
46
77
|
/**
|
|
47
78
|
* Call cleanup() for each plugin in REVERSE topological order.
|
|
48
79
|
* Each cleanup is wrapped in try/catch — failures don't prevent others from running.
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEnC,OAAO,KAAK,EACX,SAAS,EAET,WAAW,EACX,WAAW,EACX,QAAQ,EACR,UAAU,EACV,UAAU,EACV,SAAS,EACT,kBAAkB,EAClB,YAAY,EACZ,MAAM,YAAY,CAAC;AAIpB;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAc/D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BAAsB,gBAAgB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAiBhF"}
|
package/dist/plugin.js
CHANGED
|
@@ -140,6 +140,18 @@ export function createPluginAPI(pluginName, capabilities, refs) {
|
|
|
140
140
|
if (meta) {
|
|
141
141
|
refs.globalMeta.options[name] = meta;
|
|
142
142
|
}
|
|
143
|
+
// Record the registrant for collision attribution (Decision 9).
|
|
144
|
+
// A duplicate registration is NOT rejected here — the single
|
|
145
|
+
// validation pass after setup reports it (order-independent).
|
|
146
|
+
if (refs.globalOptionSources) {
|
|
147
|
+
const registrants = refs.globalOptionSources.get(name);
|
|
148
|
+
if (registrants) {
|
|
149
|
+
registrants.push(pluginName);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
refs.globalOptionSources.set(name, [pluginName]);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
143
155
|
},
|
|
144
156
|
addMiddleware(middleware) {
|
|
145
157
|
if (!caps.addMiddleware) {
|
|
@@ -169,6 +181,132 @@ export async function runPluginSetup(plugins, refs) {
|
|
|
169
181
|
await plugin.setup(api);
|
|
170
182
|
}
|
|
171
183
|
}
|
|
184
|
+
// ─── Option collision detection (Decision 9) ────────────────
|
|
185
|
+
/**
|
|
186
|
+
* Sentinel registrant for global options declared statically in
|
|
187
|
+
* `config.globalOptions` (as opposed to plugin-registered ones).
|
|
188
|
+
*/
|
|
189
|
+
export const STATIC_GLOBAL_OPTION_SOURCE = '<cli-config>';
|
|
190
|
+
/** Human label for a registrant in collision messages. */
|
|
191
|
+
function sourceLabel(registrant) {
|
|
192
|
+
return registrant === undefined || registrant === STATIC_GLOBAL_OPTION_SOURCE
|
|
193
|
+
? 'declared in config.globalOptions'
|
|
194
|
+
: `from plugin '${registrant}'`;
|
|
195
|
+
}
|
|
196
|
+
/** Render a token for messages: long names as `--name`, short chars as `-c`. */
|
|
197
|
+
function renderLong(name) {
|
|
198
|
+
return `--${name}`;
|
|
199
|
+
}
|
|
200
|
+
function renderShort(char) {
|
|
201
|
+
return `-${char}`;
|
|
202
|
+
}
|
|
203
|
+
/** Split OptionMeta aliases into long names (without `--`) and short chars (without `-`). */
|
|
204
|
+
function splitAliases(meta) {
|
|
205
|
+
const longs = [];
|
|
206
|
+
const shorts = [];
|
|
207
|
+
for (const alias of meta?.alias ?? []) {
|
|
208
|
+
if (alias.startsWith('--')) {
|
|
209
|
+
longs.push(alias.slice(2));
|
|
210
|
+
}
|
|
211
|
+
else if (alias.startsWith('-') && alias.length === 2) {
|
|
212
|
+
shorts.push(alias.slice(1));
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return { longs, shorts };
|
|
216
|
+
}
|
|
217
|
+
function isCommandNode(value) {
|
|
218
|
+
return '_type' in value && value._type === 'runa:command';
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Single validation pass over the full option surface (design Decision 9).
|
|
222
|
+
* Called once per `cli.run()`, immediately after plugin setup — the earliest
|
|
223
|
+
* point where plugin-registered globals AND plugin-added commands both exist.
|
|
224
|
+
*
|
|
225
|
+
* Detects, in deterministic order:
|
|
226
|
+
* 1. Global-vs-global same-name registrations (two plugins, or config + plugin)
|
|
227
|
+
* 2. Global-vs-global alias overlaps (name or alias claimed by two globals)
|
|
228
|
+
* 3. Global-vs-command collisions (names + aliases, full nested command tree)
|
|
229
|
+
*
|
|
230
|
+
* Throws `RunaError` code `OPTION_COLLISION`, exit 1 (CLI-author defect, not a
|
|
231
|
+
* usage error) on the FIRST collision found. This function is the ONLY place
|
|
232
|
+
* the check lives — the proposal's rollback path (downgrade throw to
|
|
233
|
+
* `console.warn`) is a one-line change here.
|
|
234
|
+
*/
|
|
235
|
+
export function validateOptionCollisions(commands, globalOptions, globalMeta, sources) {
|
|
236
|
+
// 1. Same global name registered more than once (config counts as a registrant).
|
|
237
|
+
if (sources) {
|
|
238
|
+
for (const [name, registrants] of sources) {
|
|
239
|
+
if (registrants.length > 1) {
|
|
240
|
+
const labels = registrants
|
|
241
|
+
.map((r) => (r === STATIC_GLOBAL_OPTION_SOURCE ? 'the CLI config' : `plugin '${r}'`))
|
|
242
|
+
.join(' and ');
|
|
243
|
+
throw new RunaError(`Global option '${renderLong(name)}' is registered by both ${labels}.`, { code: 'OPTION_COLLISION', exitCode: 1 });
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
// 2. Build the global token surface; overlapping claims between two
|
|
248
|
+
// different globals throw here. Long names and short chars are
|
|
249
|
+
// separate namespaces (`--h` and `-h` are different tokens).
|
|
250
|
+
const globalLong = new Map();
|
|
251
|
+
const globalShort = new Map();
|
|
252
|
+
const claim = (map, key, owner) => {
|
|
253
|
+
const existing = map.get(key);
|
|
254
|
+
if (existing && existing.canonical !== owner.canonical) {
|
|
255
|
+
throw new RunaError(`Global option '${renderLong(owner.canonical)}' (${sourceLabel(sources?.get(owner.canonical)?.[0])}) ` +
|
|
256
|
+
`collides with global option '${renderLong(existing.canonical)}' (${sourceLabel(sources?.get(existing.canonical)?.[0])}): ` +
|
|
257
|
+
`both use '${owner.token}'.`, { code: 'OPTION_COLLISION', exitCode: 1 });
|
|
258
|
+
}
|
|
259
|
+
map.set(key, owner);
|
|
260
|
+
};
|
|
261
|
+
for (const name of Object.keys(globalOptions)) {
|
|
262
|
+
claim(globalLong, name, { canonical: name, token: renderLong(name) });
|
|
263
|
+
const { longs, shorts } = splitAliases(globalMeta.options[name]);
|
|
264
|
+
for (const long of longs) {
|
|
265
|
+
claim(globalLong, long, { canonical: name, token: renderLong(long) });
|
|
266
|
+
}
|
|
267
|
+
for (const short of shorts) {
|
|
268
|
+
claim(globalShort, short, { canonical: name, token: renderShort(short) });
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (globalLong.size === 0 && globalShort.size === 0)
|
|
272
|
+
return;
|
|
273
|
+
// 3. Walk the FULL command tree (including plugin-added commands and
|
|
274
|
+
// nested subcommands) comparing option names + aliases.
|
|
275
|
+
const walk = (tree, path) => {
|
|
276
|
+
for (const [key, entry] of Object.entries(tree)) {
|
|
277
|
+
if (!isCommandNode(entry)) {
|
|
278
|
+
walk(entry, [...path, key]);
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
const commandPath = [...path, key].join(' ');
|
|
282
|
+
const optionMeta = entry.meta.options;
|
|
283
|
+
for (const optName of Object.keys(entry.options ?? {})) {
|
|
284
|
+
const { longs, shorts } = splitAliases(optionMeta?.[optName]);
|
|
285
|
+
const collide = (owner) => {
|
|
286
|
+
const viaAlias = owner.token === renderLong(owner.canonical) && owner.token === renderLong(optName)
|
|
287
|
+
? ''
|
|
288
|
+
: ` Both use '${owner.token}'.`;
|
|
289
|
+
throw new RunaError(`Global option '${renderLong(owner.canonical)}' (${sourceLabel(sources?.get(owner.canonical)?.[0])}) ` +
|
|
290
|
+
`collides with option '${renderLong(optName)}' of command '${commandPath}'.${viaAlias}`, { code: 'OPTION_COLLISION', exitCode: 1 });
|
|
291
|
+
};
|
|
292
|
+
for (const long of [optName, ...longs]) {
|
|
293
|
+
const owner = globalLong.get(long);
|
|
294
|
+
if (owner) {
|
|
295
|
+
// Re-render the token from the command's side when the
|
|
296
|
+
// collision came through the command's long alias.
|
|
297
|
+
collide(long === owner.canonical ? owner : { ...owner, token: renderLong(long) });
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
for (const short of shorts) {
|
|
301
|
+
const owner = globalShort.get(short);
|
|
302
|
+
if (owner)
|
|
303
|
+
collide(owner);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
walk(commands, []);
|
|
309
|
+
}
|
|
172
310
|
// ─── Cleanup orchestration ──────────────────────────────────
|
|
173
311
|
/**
|
|
174
312
|
* Call cleanup() for each plugin in REVERSE topological order.
|