@optique/core 1.0.0-dev.908 → 1.0.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.
Files changed (109) hide show
  1. package/dist/annotation-state.cjs +425 -0
  2. package/dist/annotation-state.d.cts +24 -0
  3. package/dist/annotation-state.d.ts +24 -0
  4. package/dist/annotation-state.js +414 -0
  5. package/dist/annotations.cjs +2 -248
  6. package/dist/annotations.d.cts +2 -137
  7. package/dist/annotations.d.ts +2 -137
  8. package/dist/annotations.js +2 -238
  9. package/dist/completion.cjs +611 -100
  10. package/dist/completion.d.cts +1 -1
  11. package/dist/completion.d.ts +1 -1
  12. package/dist/completion.js +611 -100
  13. package/dist/constructs.cjs +3338 -827
  14. package/dist/constructs.d.cts +48 -7
  15. package/dist/constructs.d.ts +48 -7
  16. package/dist/constructs.js +3338 -827
  17. package/dist/context.cjs +0 -23
  18. package/dist/context.d.cts +119 -53
  19. package/dist/context.d.ts +119 -53
  20. package/dist/context.js +0 -22
  21. package/dist/dependency-metadata.cjs +139 -0
  22. package/dist/dependency-metadata.d.cts +112 -0
  23. package/dist/dependency-metadata.d.ts +112 -0
  24. package/dist/dependency-metadata.js +138 -0
  25. package/dist/dependency-runtime.cjs +698 -0
  26. package/dist/dependency-runtime.d.cts +149 -0
  27. package/dist/dependency-runtime.d.ts +149 -0
  28. package/dist/dependency-runtime.js +687 -0
  29. package/dist/dependency.cjs +7 -928
  30. package/dist/dependency.d.cts +2 -794
  31. package/dist/dependency.d.ts +2 -794
  32. package/dist/dependency.js +2 -899
  33. package/dist/displaywidth.cjs +44 -0
  34. package/dist/displaywidth.js +43 -0
  35. package/dist/doc.cjs +285 -23
  36. package/dist/doc.d.cts +57 -2
  37. package/dist/doc.d.ts +57 -2
  38. package/dist/doc.js +283 -25
  39. package/dist/execution-context.cjs +56 -0
  40. package/dist/execution-context.js +53 -0
  41. package/dist/extension.cjs +87 -0
  42. package/dist/extension.d.cts +97 -0
  43. package/dist/extension.d.ts +97 -0
  44. package/dist/extension.js +76 -0
  45. package/dist/facade.cjs +718 -523
  46. package/dist/facade.d.cts +87 -18
  47. package/dist/facade.d.ts +87 -18
  48. package/dist/facade.js +718 -523
  49. package/dist/index.cjs +14 -29
  50. package/dist/index.d.cts +10 -10
  51. package/dist/index.d.ts +10 -10
  52. package/dist/index.js +7 -7
  53. package/dist/input-trace.cjs +56 -0
  54. package/dist/input-trace.d.cts +77 -0
  55. package/dist/input-trace.d.ts +77 -0
  56. package/dist/input-trace.js +55 -0
  57. package/dist/internal/annotations.cjs +316 -0
  58. package/dist/internal/annotations.d.cts +140 -0
  59. package/dist/internal/annotations.d.ts +140 -0
  60. package/dist/internal/annotations.js +306 -0
  61. package/dist/internal/dependency.cjs +984 -0
  62. package/dist/internal/dependency.d.cts +539 -0
  63. package/dist/internal/dependency.d.ts +539 -0
  64. package/dist/internal/dependency.js +964 -0
  65. package/dist/{mode-dispatch.cjs → internal/mode-dispatch.cjs} +1 -3
  66. package/dist/{mode-dispatch.d.cts → internal/mode-dispatch.d.cts} +3 -7
  67. package/dist/{mode-dispatch.d.ts → internal/mode-dispatch.d.ts} +3 -7
  68. package/dist/{mode-dispatch.js → internal/mode-dispatch.js} +1 -3
  69. package/dist/internal/parser.cjs +728 -0
  70. package/dist/internal/parser.d.cts +947 -0
  71. package/dist/internal/parser.d.ts +947 -0
  72. package/dist/internal/parser.js +711 -0
  73. package/dist/message.cjs +84 -26
  74. package/dist/message.d.cts +49 -9
  75. package/dist/message.d.ts +49 -9
  76. package/dist/message.js +84 -27
  77. package/dist/modifiers.cjs +1023 -240
  78. package/dist/modifiers.d.cts +42 -1
  79. package/dist/modifiers.d.ts +42 -1
  80. package/dist/modifiers.js +1023 -240
  81. package/dist/parser.cjs +11 -463
  82. package/dist/parser.d.cts +3 -537
  83. package/dist/parser.d.ts +3 -537
  84. package/dist/parser.js +2 -433
  85. package/dist/phase2-seed.cjs +59 -0
  86. package/dist/phase2-seed.js +56 -0
  87. package/dist/primitives.cjs +557 -208
  88. package/dist/primitives.d.cts +10 -14
  89. package/dist/primitives.d.ts +10 -14
  90. package/dist/primitives.js +557 -208
  91. package/dist/program.cjs +5 -1
  92. package/dist/program.d.cts +5 -3
  93. package/dist/program.d.ts +5 -3
  94. package/dist/program.js +6 -1
  95. package/dist/suggestion.cjs +22 -8
  96. package/dist/suggestion.js +22 -8
  97. package/dist/usage-internals.cjs +3 -2
  98. package/dist/usage-internals.js +4 -2
  99. package/dist/usage.cjs +195 -40
  100. package/dist/usage.d.cts +92 -11
  101. package/dist/usage.d.ts +92 -11
  102. package/dist/usage.js +194 -41
  103. package/dist/validate.cjs +170 -0
  104. package/dist/validate.js +164 -0
  105. package/dist/valueparser.cjs +1278 -191
  106. package/dist/valueparser.d.cts +330 -20
  107. package/dist/valueparser.d.ts +330 -20
  108. package/dist/valueparser.js +1277 -192
  109. package/package.json +9 -9
@@ -0,0 +1,149 @@
1
+ import { DependencyRegistryLike } from "./registry-types.cjs";
2
+ import { ValueParserResult } from "./valueparser.cjs";
3
+ import { ParserDependencyMetadata } from "./dependency-metadata.cjs";
4
+
5
+ //#region src/dependency-runtime.d.ts
6
+
7
+ /**
8
+ * The origin of a dependency source value.
9
+ *
10
+ * @internal
11
+ * @since 1.0.0
12
+ */
13
+ type DependencyValueOrigin = "cli" | "default" | "config" | "env" | "prompt" | "derived-precomplete";
14
+ /**
15
+ * A request to resolve one or more dependency values.
16
+ *
17
+ * @internal
18
+ * @since 1.0.0
19
+ */
20
+ interface DependencyRequest {
21
+ /** The dependency source IDs to resolve. */
22
+ readonly dependencyIds: readonly symbol[];
23
+ /** Optional default values (one per ID) for missing sources. */
24
+ readonly defaultValues?: readonly unknown[];
25
+ }
26
+ /**
27
+ * The result of a dependency resolution request.
28
+ *
29
+ * @internal
30
+ * @since 1.0.0
31
+ */
32
+ interface DependencyResolution {
33
+ /**
34
+ * - `"resolved"`: all dependency values are available.
35
+ * - `"partial"`: some are available, some are missing.
36
+ * - `"missing"`: none are available.
37
+ */
38
+ readonly kind: "resolved" | "partial" | "missing";
39
+ /** The resolved values (one per requested ID, `undefined` for missing). */
40
+ readonly values: readonly unknown[];
41
+ /** For each position, whether the value came from a default. */
42
+ readonly usedDefaults: readonly boolean[];
43
+ }
44
+ /**
45
+ * A failure that occurred while evaluating a missing-source default.
46
+ * Returned by `fillMissingSourceDefaults()` so the caller can propagate
47
+ * the error instead of silently treating the source as absent.
48
+ *
49
+ * @internal
50
+ * @since 1.0.0
51
+ */
52
+
53
+ /**
54
+ * A key for caching replayed parse results.
55
+ *
56
+ * @internal
57
+ * @since 1.0.0
58
+ */
59
+ interface ReplayKey {
60
+ /** Path from root to the parser node. */
61
+ readonly path: readonly PropertyKey[];
62
+ /** The raw input string that was parsed. */
63
+ readonly rawInput: string;
64
+ /** A stable fingerprint of the dependency values used. */
65
+ readonly dependencyFingerprint: string;
66
+ /**
67
+ * A per-parser identity string that disambiguates different derived
68
+ * parsers sharing the same path (e.g., alternative branches).
69
+ * @since 1.0.0
70
+ */
71
+ readonly parserFingerprint: string;
72
+ }
73
+ /**
74
+ * A runtime node representing a child parser's position, metadata, and state.
75
+ * Used as input to the shared runtime helpers.
76
+ *
77
+ * @internal
78
+ * @since 1.0.0
79
+ */
80
+ interface RuntimeNode {
81
+ /** Path from root to this parser node. */
82
+ readonly path: readonly PropertyKey[];
83
+ /** The parser (only the metadata field is inspected). */
84
+ readonly parser: {
85
+ readonly dependencyMetadata?: ParserDependencyMetadata;
86
+ };
87
+ /** The parser's current state. */
88
+ readonly state: unknown;
89
+ /**
90
+ * Whether the parser consumed explicit input during parsing.
91
+ * When `true`, the parser's state reflects user-provided input (which
92
+ * may have failed validation). Missing-source defaults must not override
93
+ * explicit parse failures.
94
+ * @since 1.0.0
95
+ */
96
+ readonly matched?: boolean;
97
+ /**
98
+ * Snapshotted default dependency values for derived parsers.
99
+ * Constructs should populate this at node creation time (once) to
100
+ * avoid re-evaluating dynamic `getDefaultDependencyValues()` thunks
101
+ * at replay time.
102
+ * @since 1.0.0
103
+ */
104
+ readonly defaultDependencyValues?: readonly unknown[];
105
+ }
106
+ /**
107
+ * Dependency runtime context for centralized dependency resolution.
108
+ *
109
+ * @internal
110
+ * @since 1.0.0
111
+ */
112
+ interface DependencyRuntimeContext {
113
+ /** The underlying registry (for bridge interop). */
114
+ readonly registry: DependencyRegistryLike;
115
+ /** Register a source value with its origin. */
116
+ registerSource(sourceId: symbol, value: unknown, origin: DependencyValueOrigin): void;
117
+ /** Check if a source has been registered. */
118
+ hasSource(sourceId: symbol): boolean;
119
+ /** Get a registered source value. */
120
+ getSource(sourceId: symbol): unknown;
121
+ /** Resolve dependency values for a request. */
122
+ resolveDependencies(request: DependencyRequest): DependencyResolution;
123
+ /** Get a cached replay result. */
124
+ getReplayResult(key: ReplayKey): ValueParserResult<unknown> | undefined;
125
+ /** Cache a replay result. */
126
+ setReplayResult(key: ReplayKey, result: ValueParserResult<unknown>): void;
127
+ /**
128
+ * Mark a source as explicitly failed (user provided input that did
129
+ * not pass validation). Derived parsers should not fall back to
130
+ * defaults for failed sources.
131
+ */
132
+ markSourceFailed(sourceId: symbol): void;
133
+ /**
134
+ * Check if a source was explicitly attempted but failed validation.
135
+ */
136
+ isSourceFailed(sourceId: symbol): boolean;
137
+ /** Resolve dependencies for suggestions (same semantics as resolve). */
138
+ getSuggestionDependencies(request: DependencyRequest): DependencyResolution;
139
+ }
140
+ /**
141
+ * Creates a new {@link DependencyRuntimeContext}.
142
+ *
143
+ * @param registry Optional existing registry to wrap for bridge interop.
144
+ * @returns A new runtime context.
145
+ * @internal
146
+ * @since 1.0.0
147
+ */
148
+ //#endregion
149
+ export { DependencyRuntimeContext, RuntimeNode };
@@ -0,0 +1,149 @@
1
+ import { DependencyRegistryLike } from "./registry-types.js";
2
+ import { ValueParserResult } from "./valueparser.js";
3
+ import { ParserDependencyMetadata } from "./dependency-metadata.js";
4
+
5
+ //#region src/dependency-runtime.d.ts
6
+
7
+ /**
8
+ * The origin of a dependency source value.
9
+ *
10
+ * @internal
11
+ * @since 1.0.0
12
+ */
13
+ type DependencyValueOrigin = "cli" | "default" | "config" | "env" | "prompt" | "derived-precomplete";
14
+ /**
15
+ * A request to resolve one or more dependency values.
16
+ *
17
+ * @internal
18
+ * @since 1.0.0
19
+ */
20
+ interface DependencyRequest {
21
+ /** The dependency source IDs to resolve. */
22
+ readonly dependencyIds: readonly symbol[];
23
+ /** Optional default values (one per ID) for missing sources. */
24
+ readonly defaultValues?: readonly unknown[];
25
+ }
26
+ /**
27
+ * The result of a dependency resolution request.
28
+ *
29
+ * @internal
30
+ * @since 1.0.0
31
+ */
32
+ interface DependencyResolution {
33
+ /**
34
+ * - `"resolved"`: all dependency values are available.
35
+ * - `"partial"`: some are available, some are missing.
36
+ * - `"missing"`: none are available.
37
+ */
38
+ readonly kind: "resolved" | "partial" | "missing";
39
+ /** The resolved values (one per requested ID, `undefined` for missing). */
40
+ readonly values: readonly unknown[];
41
+ /** For each position, whether the value came from a default. */
42
+ readonly usedDefaults: readonly boolean[];
43
+ }
44
+ /**
45
+ * A failure that occurred while evaluating a missing-source default.
46
+ * Returned by `fillMissingSourceDefaults()` so the caller can propagate
47
+ * the error instead of silently treating the source as absent.
48
+ *
49
+ * @internal
50
+ * @since 1.0.0
51
+ */
52
+
53
+ /**
54
+ * A key for caching replayed parse results.
55
+ *
56
+ * @internal
57
+ * @since 1.0.0
58
+ */
59
+ interface ReplayKey {
60
+ /** Path from root to the parser node. */
61
+ readonly path: readonly PropertyKey[];
62
+ /** The raw input string that was parsed. */
63
+ readonly rawInput: string;
64
+ /** A stable fingerprint of the dependency values used. */
65
+ readonly dependencyFingerprint: string;
66
+ /**
67
+ * A per-parser identity string that disambiguates different derived
68
+ * parsers sharing the same path (e.g., alternative branches).
69
+ * @since 1.0.0
70
+ */
71
+ readonly parserFingerprint: string;
72
+ }
73
+ /**
74
+ * A runtime node representing a child parser's position, metadata, and state.
75
+ * Used as input to the shared runtime helpers.
76
+ *
77
+ * @internal
78
+ * @since 1.0.0
79
+ */
80
+ interface RuntimeNode {
81
+ /** Path from root to this parser node. */
82
+ readonly path: readonly PropertyKey[];
83
+ /** The parser (only the metadata field is inspected). */
84
+ readonly parser: {
85
+ readonly dependencyMetadata?: ParserDependencyMetadata;
86
+ };
87
+ /** The parser's current state. */
88
+ readonly state: unknown;
89
+ /**
90
+ * Whether the parser consumed explicit input during parsing.
91
+ * When `true`, the parser's state reflects user-provided input (which
92
+ * may have failed validation). Missing-source defaults must not override
93
+ * explicit parse failures.
94
+ * @since 1.0.0
95
+ */
96
+ readonly matched?: boolean;
97
+ /**
98
+ * Snapshotted default dependency values for derived parsers.
99
+ * Constructs should populate this at node creation time (once) to
100
+ * avoid re-evaluating dynamic `getDefaultDependencyValues()` thunks
101
+ * at replay time.
102
+ * @since 1.0.0
103
+ */
104
+ readonly defaultDependencyValues?: readonly unknown[];
105
+ }
106
+ /**
107
+ * Dependency runtime context for centralized dependency resolution.
108
+ *
109
+ * @internal
110
+ * @since 1.0.0
111
+ */
112
+ interface DependencyRuntimeContext {
113
+ /** The underlying registry (for bridge interop). */
114
+ readonly registry: DependencyRegistryLike;
115
+ /** Register a source value with its origin. */
116
+ registerSource(sourceId: symbol, value: unknown, origin: DependencyValueOrigin): void;
117
+ /** Check if a source has been registered. */
118
+ hasSource(sourceId: symbol): boolean;
119
+ /** Get a registered source value. */
120
+ getSource(sourceId: symbol): unknown;
121
+ /** Resolve dependency values for a request. */
122
+ resolveDependencies(request: DependencyRequest): DependencyResolution;
123
+ /** Get a cached replay result. */
124
+ getReplayResult(key: ReplayKey): ValueParserResult<unknown> | undefined;
125
+ /** Cache a replay result. */
126
+ setReplayResult(key: ReplayKey, result: ValueParserResult<unknown>): void;
127
+ /**
128
+ * Mark a source as explicitly failed (user provided input that did
129
+ * not pass validation). Derived parsers should not fall back to
130
+ * defaults for failed sources.
131
+ */
132
+ markSourceFailed(sourceId: symbol): void;
133
+ /**
134
+ * Check if a source was explicitly attempted but failed validation.
135
+ */
136
+ isSourceFailed(sourceId: symbol): boolean;
137
+ /** Resolve dependencies for suggestions (same semantics as resolve). */
138
+ getSuggestionDependencies(request: DependencyRequest): DependencyResolution;
139
+ }
140
+ /**
141
+ * Creates a new {@link DependencyRuntimeContext}.
142
+ *
143
+ * @param registry Optional existing registry to wrap for bridge interop.
144
+ * @returns A new runtime context.
145
+ * @internal
146
+ * @since 1.0.0
147
+ */
148
+ //#endregion
149
+ export { DependencyRuntimeContext, RuntimeNode };