@loomcli/core 0.4.0 → 0.6.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 (79) hide show
  1. package/LICENSE +21 -0
  2. package/dist/application.d.ts +60 -31
  3. package/dist/application.js +356 -149
  4. package/dist/bindings.d.ts +31 -0
  5. package/dist/bindings.js +64 -0
  6. package/dist/chain.d.ts +26 -12
  7. package/dist/chain.js +59 -92
  8. package/dist/command-rules.d.ts +55 -0
  9. package/dist/command-rules.js +142 -0
  10. package/dist/command.d.ts +212 -93
  11. package/dist/command.js +1224 -454
  12. package/dist/controls.d.ts +8 -0
  13. package/dist/controls.js +23 -0
  14. package/dist/defect.d.ts +18 -0
  15. package/dist/defect.js +272 -0
  16. package/dist/developer.d.ts +24 -0
  17. package/dist/developer.js +52 -0
  18. package/dist/diagnostic-text.d.ts +81 -0
  19. package/dist/diagnostic-text.js +283 -0
  20. package/dist/diagnostic.d.ts +11 -0
  21. package/dist/diagnostic.js +70 -0
  22. package/dist/errors.d.ts +115 -26
  23. package/dist/errors.js +333 -54
  24. package/dist/exit-codes.d.ts +45 -0
  25. package/dist/exit-codes.js +46 -0
  26. package/dist/extension.d.ts +44 -9
  27. package/dist/extension.js +147 -65
  28. package/dist/facts.d.ts +71 -11
  29. package/dist/facts.js +108 -25
  30. package/dist/globals.d.ts +63 -22
  31. package/dist/globals.js +164 -39
  32. package/dist/hints.d.ts +79 -0
  33. package/dist/hints.js +247 -0
  34. package/dist/host.d.ts +13 -0
  35. package/dist/host.js +43 -1
  36. package/dist/identity.d.ts +19 -0
  37. package/dist/identity.js +72 -0
  38. package/dist/index.d.ts +15 -4
  39. package/dist/index.js +6 -0
  40. package/dist/input-rules.d.ts +64 -0
  41. package/dist/input-rules.js +145 -0
  42. package/dist/inspect.d.ts +36 -5
  43. package/dist/inspect.js +125 -27
  44. package/dist/lanes.js +1 -1
  45. package/dist/locate.d.ts +41 -0
  46. package/dist/locate.js +121 -0
  47. package/dist/options.d.ts +96 -2
  48. package/dist/options.js +259 -71
  49. package/dist/output.d.ts +11 -2
  50. package/dist/output.js +23 -3
  51. package/dist/plain.d.ts +6 -0
  52. package/dist/plain.js +12 -0
  53. package/dist/plugin-rules.d.ts +62 -0
  54. package/dist/plugin-rules.js +155 -0
  55. package/dist/plugin.d.ts +121 -55
  56. package/dist/plugin.js +496 -126
  57. package/dist/prototypes.d.ts +7 -0
  58. package/dist/prototypes.js +29 -0
  59. package/dist/rendering.d.ts +6 -1
  60. package/dist/rendering.js +23 -5
  61. package/dist/rules.d.ts +51 -0
  62. package/dist/rules.js +115 -0
  63. package/dist/sequence.js +6 -1
  64. package/dist/sources.d.ts +58 -0
  65. package/dist/sources.js +258 -0
  66. package/dist/style-wire.js +1 -1
  67. package/dist/style.js +1 -1
  68. package/dist/theme.d.ts +4 -0
  69. package/dist/theme.js +25 -5
  70. package/dist/thenable.d.ts +15 -0
  71. package/dist/thenable.js +29 -0
  72. package/dist/translators.d.ts +69 -0
  73. package/dist/translators.js +253 -0
  74. package/dist/types.d.ts +76 -21
  75. package/dist/validation.d.ts +65 -10
  76. package/dist/validation.js +314 -108
  77. package/dist/view.d.ts +49 -15
  78. package/dist/view.js +157 -79
  79. package/package.json +3 -2
package/dist/command.d.ts CHANGED
@@ -1,19 +1,30 @@
1
+ import type { Finding } from './diagnostic-text.js';
1
2
  import type { RegisteredGlobals } from './environment.js';
2
- import type { DescriptorRegistry, ExtensionRecords, ExtensionValue } from './extension.js';
3
- import type { BuiltGlobals, GlobalsState } from './globals.js';
3
+ import type { LoomError } from './errors.js';
4
+ import type { AdmittedDescriptor, DescriptorRegistry, ExtensionRecords, ExtensionStore, ExtensionSubject, ExtensionValue } from './extension.js';
5
+ import type { BuiltGlobals, GlobalsState, GlobalTable, InputRecords } from './globals.js';
6
+ import type { CommandGraph, CommandNode } from './inspect.js';
4
7
  import { compileOptions } from './options.js';
5
8
  import type { OptionValues } from './options.js';
6
- import type { BuiltPlugin, PluginBuild } from './plugin.js';
9
+ import type { BuiltPlugin } from './plugin.js';
7
10
  import type { ContextualStyle } from './style.js';
8
- import type { Action, ActionChannel, ArgumentConfig, ArgumentValue, declaredTypes, DeclaredResult, DeclaredTypes, DefaultConstraint, GlobalNameConstraint, Host, MultipleConstraint, NameConstraint, OpenResult, OptionConfig, OptionValue, Out, Request, ResultBinding, ResultViews, ResultViewsOf, RowViews, ValidateOmittedConstraint } from './types.js';
9
- import type { ArgumentInput, DefaultValues, InputDeclaration, OptionInput, ValidatedInputs } from './validation.js';
11
+ import type { Action, ActionChannel, ArgumentConfig, ArgumentValue, declaredTypes, DeclaredResult, DeclaredTypes, DefaultConstraint, GlobalNameConstraint, Host, PerValueConstraint, NameConstraint, OpenResult, OptionConfig, OptionValue, Out, Request, ResultBinding, ResultViews, ResultViewsOf, RowViews, ValidateOmittedConstraint } from './types.js';
12
+ import type { ArgumentInput, DefaultValues, InputPlaces, InputDeclaration, OptionInput, ValidatedInputs } from './validation.js';
10
13
  /** One positional slot: the declaration it fills and whether it takes the remaining tokens. */
11
14
  export interface ArgumentSlot {
12
15
  input: InputDeclaration;
13
16
  required: boolean;
14
17
  variadic: boolean;
15
18
  }
19
+ /**
20
+ * What one dispatch hands its action. `graph` and `command` are the run's inspected graph and the
21
+ * routed node inside it, the values its middleware read. Each builds on its first read, so a run
22
+ * whose action reads neither, whose chain is empty, and which asks no configuration source renders
23
+ * no graph and calls no converter.
24
+ */
16
25
  export interface DispatchInput {
26
+ command: () => CommandNode;
27
+ graph: () => CommandGraph;
17
28
  style: ContextualStyle;
18
29
  host: Host;
19
30
  /** The action's channel, whose `results` accepts whatever the routed declaration named. */
@@ -57,8 +68,8 @@ export interface BuiltCommand {
57
68
  export declare const commandValue: unique symbol;
58
69
  /**
59
70
  * The input, alias, child, and action calls a Command can publish. Its type state is a subset,
60
- * and each call removes the names it invalidates. A Command attaches children at any depth, so
61
- * `command()` belongs to every Command and to the unnamed root alike.
71
+ * and each call removes the names it invalidates. `command()` belongs to every Command and to the
72
+ * unnamed root alike, and attach bounds how deep the children it adds may nest.
62
73
  */
63
74
  export type CommandMethod = 'action' | 'alias' | 'argument' | 'command' | 'option' | 'result' | 'rows';
64
75
  /** One Command declares arguments or attaches children, so the first call removes the other. */
@@ -69,124 +80,205 @@ export type AfterCommand<State> = Exclude<State, 'argument'>;
69
80
  export type AfterResult<State> = Exclude<State, 'result' | 'rows'>;
70
81
  /** Registering the action closes input, alias, child, and further action declarations. */
71
82
  export type AfterAction = never;
72
- /** A declaration made after its authoring phase closed; build reports the first in call order. */
73
- type LateDeclaration = {
74
- alias: string;
75
- kind: 'alias';
76
- } | {
77
- name: string;
78
- kind: 'global';
79
- } | {
80
- child: object;
81
- kind: 'child';
82
- } | {
83
- kind: 'result';
84
- } | {
85
- input: InputDeclaration;
86
- kind: 'input';
87
- };
88
83
  /**
89
- * The names one `alias()` call declares. Each call keeps its own group, so a call that names none,
90
- * which the types reject and a JavaScript author can still write, reports as the call it is.
84
+ * The private handle one graph node is reached through, without its inferred declaration types:
85
+ * what attach and the Application's walk read, and the build that compiles the node.
91
86
  */
92
- type AliasDeclaration = readonly string[];
93
- /** The private handle one graph node is built through, without its inferred declaration types. */
94
- interface CommandNodeHandle {
95
- readonly name: string | null;
87
+ export interface CommandNodeHandle {
88
+ readonly declared: Declared;
89
+ readonly hasAction: boolean;
90
+ readonly name: string;
96
91
  build(context: BuildContext): BuiltCommand;
97
92
  }
98
93
  /**
99
- * One graph build's shared state. `globals` compiles once and every Command reads it. `owners`
100
- * records the name of the parent that claimed each node, so a second parent holding the same value
101
- * is building a graph with more than one path to that node, not a tree. The build is a depth-first
102
- * walk in attachment order, and a parent claims each child as the walk reaches it, so the first
103
- * owner is the parent whose attachment the walk meets first.
94
+ * One attached child, under the canonical name its parent's namespace holds it by, with the call
95
+ * that attached it, which a diagnostic about the child as a whole marks.
96
+ */
97
+ export interface AttachedChild {
98
+ readonly name: string;
99
+ readonly node: CommandNodeHandle;
100
+ readonly placement: Finding;
101
+ }
102
+ /**
103
+ * One graph build's shared state. `globals` compiles once and every Command reads it. The build is
104
+ * a depth-first walk in attachment order.
104
105
  */
105
106
  interface BuildContext {
106
107
  descriptors: DescriptorRegistry;
107
108
  extensions: ExtensionRecords;
108
109
  globals: BuiltGlobals;
109
- owners: Map<CommandNodeHandle, string | null>;
110
110
  /** The route from the root to the Command being built, which a lifecycle hook reads. */
111
111
  path: readonly string[];
112
112
  /** The installed plugins in installation order, whose hooks run over every Command. */
113
113
  plugins: readonly BuiltPlugin[];
114
114
  }
115
+ /** The handle behind a value an author built as a Command, or nothing for any other value. */
116
+ export declare function commandNode(value: unknown): CommandNodeHandle | undefined;
117
+ /** A call's arguments as its author wrote them: the trailing ones left undefined are dropped. */
118
+ export declare function callArguments(...values: readonly unknown[]): readonly unknown[];
119
+ /** A Command value as a finding prints it, which it would otherwise print as an ellipsis. */
120
+ export declare function commandCode(name: string): object;
121
+ /** The finding for one `command()` call that attached a child under the Command at `path`. */
122
+ export declare function commandPlacement(path: readonly string[], child: string): Finding;
115
123
  /**
116
- * Everything one Command declaration holds. The transitions below copy it with fields replaced, and
117
- * the Command and Application builders share them, so one declaration call has one implementation.
124
+ * The portable name rule, for every name an operator types as a command at a shell prompt: the
125
+ * application name, every Command name, and every alias. The characters are the POSIX portable
126
+ * filename set, and a name starts with neither `-`, which reads as an option, nor `.`, which a
127
+ * shell hides.
118
128
  */
129
+ export declare function isPortableName(name: unknown): name is string;
130
+ /** The one correction every portable name diagnostic ends with. */
131
+ export declare const portableNameCorrection = "Use a nonempty name of A-Z, a-z, 0-9, \".\", \"_\", and \"-\" that does not start with \"-\" or \".\".";
119
132
  /**
120
- * One call of the results lane, in the order it was made. A `result()` or `rows()` call declares
121
- * the unit, and a `views()` call reshapes the views of whichever declaration it follows.
122
- * Each record arrives unexamined, because build owns every rule the lane carries.
133
+ * One call of the results lane, in the order it was made, with the arguments a finding rebuilds it
134
+ * from. A `result()` or `rows()` call declares the unit, and a `views()` call reshapes the views of
135
+ * whichever declaration it follows.
123
136
  */
124
137
  export type ResultCall = {
138
+ arguments: readonly unknown[];
139
+ } & ({
125
140
  kind: 'value' | 'rows';
126
141
  views: unknown;
127
142
  } | {
128
143
  default: unknown;
129
144
  kind: 'views';
130
145
  views: unknown;
131
- };
146
+ });
147
+ /** The core facts a named Command declares, which its constructor checked. The root carries none. */
148
+ export interface CommandFacts {
149
+ deprecated: string | undefined;
150
+ description: string | undefined;
151
+ hidden: boolean;
152
+ }
153
+ /**
154
+ * Everything one Command declaration holds, each part checked by the call that added it. The
155
+ * transitions below copy it with fields replaced, and the Command and Application builders share
156
+ * them, so one declaration call has one implementation.
157
+ */
132
158
  export interface CommandState<Args, Options, Globals> {
133
159
  /**
134
- * The registered actions, with the declared result erased. An action is stored under the widest
160
+ * The registered action, with the declared result erased. An action is stored under the widest
135
161
  * result, so a handler typed from its own declaration stores here and the channel that carries
136
162
  * the result is built for it at dispatch.
137
163
  */
138
- actions: readonly Action<Args, Globals & Options, OpenResult>[];
139
- aliases: readonly AliasDeclaration[];
164
+ action: Action<Args, Globals & Options, OpenResult> | undefined;
165
+ aliases: readonly string[];
140
166
  bind: (values: ValidatedInputs) => {
141
167
  args: Args;
142
168
  options: Options;
143
169
  };
144
- children: readonly object[];
145
- deprecated: unknown;
146
- description: unknown;
147
- extensions: readonly unknown[];
148
- hidden: unknown;
170
+ children: readonly AttachedChild[];
171
+ /**
172
+ * Every descriptor this declaration's extension values name, by identity. The root's holds the
173
+ * whole Application's: its plugins', its global options', and every attached subtree's.
174
+ */
175
+ descriptors: ReadonlyMap<string, AdmittedDescriptor>;
176
+ /** The extension values of every layer, validated at the call that carried each one. */
177
+ extensions: ExtensionStore;
178
+ facts: CommandFacts;
149
179
  inputs: readonly InputDeclaration[];
150
- late: readonly LateDeclaration[];
151
180
  name: string | null;
152
- options: unknown;
181
+ /** The extension record each input's own call validated. */
182
+ records: InputRecords;
153
183
  results: readonly ResultCall[];
154
184
  }
185
+ /** The untyped part of a declaration, which every attach and build check reads. */
186
+ export type Declared = Pick<CommandState<unknown, unknown, unknown>, 'aliases' | 'children' | 'descriptors' | 'inputs' | 'name' | 'records' | 'results'>;
187
+ /** How the extension diagnostics of one Command's own layers name it. */
188
+ export declare function layerOf(name: string | null): ExtensionSubject;
155
189
  /**
156
- * The state every declaration starts from. The unnamed root and each named Command share it.
157
- * The declaration values arrive captured, because a later change to the options object the author
158
- * passed changes nothing the declaration holds.
190
+ * The state every declaration starts from. The unnamed root and each named Command share it. The
191
+ * declaration values arrive checked, because the constructor that read them threw for any fault.
159
192
  */
160
193
  export declare function freshState<Globals>(declaration: {
161
- deprecated: unknown;
162
- description: unknown;
163
- extensions: unknown;
164
- hidden: unknown;
194
+ descriptors: ReadonlyMap<string, AdmittedDescriptor>;
195
+ extensions: ExtensionStore;
196
+ facts: CommandFacts;
165
197
  name: string | null;
166
- options: unknown;
167
198
  }): CommandState<{}, {}, Globals>;
168
199
  /** The declared value joins `args` under its literal name, typed by its own config. */
169
- export declare function declareArgument<Args, Options, Globals, Name extends string, Config extends ArgumentConfig>(state: CommandState<Args, Options, Globals>, input: ArgumentInput<Name, Config>): CommandState<Args & Record<Name, ArgumentValue<Config>>, Options, Globals>;
170
- /** The declared value joins `options` under its literal name, typed by its own config. */
171
- export declare function declareOption<Args, Options, Globals, Name extends string, Config extends OptionConfig>(state: CommandState<Args, Options, Globals>, input: OptionInput<Name, Config>): CommandState<Args, Options & Record<Name, OptionValue<Config>>, Globals>;
172
- /** Globals close when composition starts; retain late calls for the shared build-order check. */
173
- export declare function recordGlobalOption<Args, Options, Globals>(state: CommandState<Args, Options, Globals>, name: string): CommandState<Args, Options, Globals>;
174
- /** One call's names stay one group, so the empty call the types reject still reports as one. */
175
- export declare function declareAlias<Args, Options, Globals>(state: CommandState<Args, Options, Globals>, names: AliasDeclaration): CommandState<Args, Options, Globals>;
176
- /** Extension layers remain open after inputs and the action have been fixed. */
177
- export declare function declareExtensions<Args, Options, Globals>(state: CommandState<Args, Options, Globals>, values: readonly ExtensionValue<'command'>[]): CommandState<Args, Options, Globals>;
200
+ export declare function declareArgument<Args, Options, Globals, Name extends string, Config extends ArgumentConfig>(state: CommandState<Args, Options, Globals>, declared: ArgumentInput<Name, Config>): CommandState<Args & Record<Name, ArgumentValue<Config>>, Options, Globals>;
201
+ /**
202
+ * The declared value joins `options` under its literal name, typed by its own config. The root's
203
+ * options also meet the Application's globals table, which a named Command meets when its subtree
204
+ * joins an Application.
205
+ */
206
+ export declare function declareOption<Args, Options, Globals, Name extends string, Config extends OptionConfig>(state: CommandState<Args, Options, Globals>, declared: OptionInput<Name, Config>, table?: GlobalTable): CommandState<Args, Options & Record<Name, OptionValue<Config>>, Globals>;
207
+ /**
208
+ * One call's names join the Command's aliases. A call that names none, which the types reject and
209
+ * a JavaScript author can still write, reports as the call it is.
210
+ */
211
+ export declare function declareAlias<Args, Options, Globals>(state: CommandState<Args, Options, Globals>, names: readonly string[]): CommandState<Args, Options, Globals>;
212
+ /**
213
+ * Extension layers remain open after inputs and the action have been fixed. Each layer is validated
214
+ * at its own call, against every descriptor the declaration already names.
215
+ */
216
+ export declare function declareExtensions<Args, Options, Globals>(state: CommandState<Args, Options, Globals>, values: readonly unknown[]): CommandState<Args, Options, Globals>;
178
217
  /**
179
218
  * The handler is typed against the result its own declaration carries, and the state holds one
180
- * list for every declaration, so the context each handler receives is read back at the call.
219
+ * action for every declaration, so the context the handler receives is read back at the call.
181
220
  */
182
221
  export declare function declareAction<Args, Options, Globals, Result>(state: CommandState<Args, Options, Globals>, handler: Action<Args, Globals & Options, Result>): CommandState<Args, Options, Globals>;
183
- /** The result declaration, which closes both result calls and reports lateness like the rest. */
222
+ /**
223
+ * The result declaration, which closes both result calls. Every rule its own call can judge throws
224
+ * here; the empty record and the default wait for attach, because `views()` can still add keys.
225
+ */
184
226
  export declare function declareResult<Args, Options, Globals>(state: CommandState<Args, Options, Globals>, kind: 'value' | 'rows', declaration: unknown): CommandState<Args, Options, Globals>;
185
227
  /** A `views()` call reshapes views and closes nothing, so it is never a late declaration. */
186
228
  export declare function declareResultViews<Args, Options, Globals>(state: CommandState<Args, Options, Globals>, replacements: unknown, options: unknown): CommandState<Args, Options, Globals>;
187
- /** Attaching is a declaration call too, so the receiver keeps the children it already had. */
188
- export declare function attachChild<Args, Options, Globals>(state: CommandState<Args, Options, Globals>, child: object): CommandState<Args, Options, Globals>;
189
- /** Validates one declaration against the shared globals table and compiles it for dispatch. */
229
+ /** One Command a rule judges: the name its sentence reads, and the path its findings open with. */
230
+ interface CommandPlace {
231
+ name: string | null;
232
+ path: readonly string[];
233
+ }
234
+ /** The parent one attach reads: its place, the children it holds, and the calls that close it. */
235
+ interface AttachParent extends CommandPlace {
236
+ /** The first argument the parent declares, which no child may sit beside. */
237
+ argument: InputDeclaration | undefined;
238
+ children: readonly AttachedChild[];
239
+ hasAction: boolean;
240
+ }
241
+ /**
242
+ * The one attach operation `Command.command()`, `Application.command()`, and a plugin's
243
+ * `commands` list share. A Command is an immutable value, so the child is final here: it is checked
244
+ * as a finished Command, against the parent's current children, and against the nesting cap from
245
+ * the shallowest level the parent can sit at. The placement is the call that attached it, which a
246
+ * finding about the child as a whole marks.
247
+ */
248
+ export declare function attach(parent: AttachParent, node: CommandNodeHandle, placement: Finding): AttachedChild;
249
+ /** The handle behind the value one `command()` call received; anything else is a declaration error. */
250
+ export declare function childNode(parent: string | null, child: unknown): CommandNodeHandle;
251
+ /** The first place an Application holds one Command value: its parent's name and the attach call. */
252
+ export interface ChildOwner {
253
+ name: string | null;
254
+ placement: Finding;
255
+ }
256
+ /** What an Application holds while a subtree joins it, each register a copy the caller commits. */
257
+ interface JoinScope {
258
+ descriptors: DescriptorRegistry;
259
+ /** The first place that claimed each node the Application holds. */
260
+ owners: Map<CommandNodeHandle, ChildOwner>;
261
+ table: GlobalTable;
262
+ }
263
+ /**
264
+ * Attaches one child to an Application's root and walks the subtree it brings, once. The scope's
265
+ * registers are copies: the caller commits the owners, and the returned root holds the descriptors.
266
+ */
267
+ export declare function attachToRoot<Args, Options, Globals>(state: CommandState<Args, Options, Globals>, child: {
268
+ node: CommandNodeHandle;
269
+ placement: Finding;
270
+ }, scope: JoinScope): CommandState<Args, Options, Globals>;
271
+ /**
272
+ * A declaration's own options and every attached Command's, against a globals table that has just
273
+ * grown. The table's new option reads as the other side of any collision.
274
+ */
275
+ export declare function checkDeclaredOptions(state: Declared, table: GlobalTable): void;
276
+ /**
277
+ * Compiles one declaration for dispatch against the shared globals table. Every authored rule threw
278
+ * at the call or the attach that first held its data, so what can still fail here is the root's
279
+ * finished-Command rules, the root never being attached, and whatever the lifecycle hooks
280
+ * contributed.
281
+ */
190
282
  export declare function buildCommand<Args, Options, Globals>(state: CommandState<Args, Options, Globals>, context: BuildContext): BuiltCommand;
191
283
  /** One built graph: the shared globals table, the root Command, and the facts each node carries. */
192
284
  export interface BuiltGraph {
@@ -194,20 +286,20 @@ export interface BuiltGraph {
194
286
  globals: BuiltGlobals;
195
287
  root: BuiltCommand;
196
288
  }
197
- /** The globals table and the owners record each compile once per invocation and the whole graph shares them. */
198
- export declare function buildGraph<Args, Options, Globals>(root: CommandState<Args, Options, Globals>, globals: GlobalsState<Globals>, install: PluginBuild & {
199
- plugins: readonly BuiltPlugin[];
200
- }): BuiltGraph;
289
+ /**
290
+ * The globals table compiles once per build and the whole graph shares it. The root's registry
291
+ * holds every descriptor the Application names, so a hook's `extend()` call meets all of them.
292
+ */
293
+ export declare function buildGraph<Args, Options, Globals>(root: CommandState<Args, Options, Globals>, globals: GlobalsState<Globals>, plugins: readonly BuiltPlugin[]): BuiltGraph;
201
294
  export declare class CommandBuilder<Args, Options, Globals, State extends CommandMethod = CommandMethod, Result = unknown> {
202
295
  #private;
203
296
  readonly [commandValue]: true;
204
297
  readonly [declaredTypes]: DeclaredTypes<Args, Options, Globals, Result>;
205
- constructor(state: CommandState<Args, Options, Globals>);
206
- get name(): string | null;
207
- argument<const Name extends string, const Config extends ArgumentConfig>(name: Name, config: Config & NameConstraint<Name> & NoInfer<DefaultConstraint<Config>> & NoInfer<ValidateOmittedConstraint<Config>>): Command<Args & Record<Name, ArgumentValue<Config>>, Options, Globals, AfterArgument<State>, Result>;
208
- option<const Name extends string, const Config extends OptionConfig>(name: Name, config: Config & NameConstraint<Name> & GlobalNameConstraint<Name, Globals> & NoInfer<DefaultConstraint<Config>> & NoInfer<MultipleConstraint<Config>> & NoInfer<ValidateOmittedConstraint<Config>>): Command<Args, Options & Record<Name, OptionValue<Config>>, Globals, State, Result>;
298
+ constructor(name: string, state: CommandState<Args, Options, Globals>);
299
+ argument<const Name extends string, const Config extends ArgumentConfig>(name: Name, config: Config & NameConstraint<Name> & NoInfer<DefaultConstraint<Config>> & NoInfer<PerValueConstraint<Config>> & NoInfer<ValidateOmittedConstraint<Config>>): Command<Args & Record<Name, ArgumentValue<Config>>, Options, Globals, AfterArgument<State>, Result>;
300
+ option<const Name extends string, const Config extends OptionConfig>(name: Name, config: Config & NameConstraint<Name> & GlobalNameConstraint<Name, Globals> & NoInfer<DefaultConstraint<Config>> & NoInfer<PerValueConstraint<Config>> & NoInfer<ValidateOmittedConstraint<Config>>): Command<Args, Options & Record<Name, OptionValue<Config>>, Globals, State, Result>;
209
301
  /**
210
- * Aliases are other bare tokens that route to this Command. They invalidate no call, and the
302
+ * Aliases are other portable names that route to this Command. They invalidate no call, and the
211
303
  * tuple rest parameter rejects a call that names none.
212
304
  */
213
305
  alias(...names: [string, ...string[]]): Command<Args, Options, Globals, State, Result>;
@@ -240,12 +332,6 @@ export declare class CommandBuilder<Args, Options, Globals, State extends Comman
240
332
  /** The action closes input authoring; `extend()` remains outside this state transition. */
241
333
  action(handler: Action<Args, Globals & Options, Result>): Command<Args, Options, Globals, AfterAction, Result>;
242
334
  extend(...values: readonly ExtensionValue<'command'>[]): Command<Args, Options, Globals, State, Result>;
243
- build(context: BuildContext): BuiltCommand;
244
- /**
245
- * The same runtime value in the state the calling method's return type names. Each call states
246
- * its own transition, and the declared result travels with it unless the call replaces it.
247
- */
248
- private derive;
249
335
  }
250
336
  /**
251
337
  * The authoring surface of a Command in one type state. Every call returns a new declaration value,
@@ -282,12 +368,31 @@ type CommandConstructor = new (name: string, options?: CommandOptions) => Comman
282
368
  export declare const Command: CommandConstructor;
283
369
  /** Every declaration in the graph, so defaults are validated before any token is read. */
284
370
  export declare function collectInputs(command: BuiltCommand): InputDeclaration[];
285
- /** Bare tokens, names or aliases, select children until a Command has none; a hyphen commits. */
286
- export declare function route(root: BuiltCommand, tokens: readonly string[]): {
371
+ /**
372
+ * Where every input of one graph was declared: each global option at its `globalOption()` call,
373
+ * and each Command's own inputs at their calls on the Command, under its path from the root.
374
+ */
375
+ export declare function inputPlaces(graph: BuiltGraph): InputPlaces;
376
+ /**
377
+ * Whether a token names one of the Command's children: the Command has children and the token is
378
+ * no option token. Routing and `locate` read a bare word through this rule.
379
+ */
380
+ export declare function readsAsChild(command: BuiltCommand, token: string): boolean;
381
+ /**
382
+ * Bare tokens, names or aliases, select children until a Command has none; a hyphen commits.
383
+ * `walked` receives the path after each name routes, so an unknown Command leaves its caller
384
+ * holding the partial path walked before it.
385
+ */
386
+ export declare function route(root: BuiltCommand, tokens: readonly string[], walked?: (path: readonly string[]) => void): {
287
387
  command: BuiltCommand;
288
388
  path: string[];
289
389
  tokens: string[];
290
390
  };
391
+ /**
392
+ * The slot the positional at one index fills: the slot at that index, else a variadic last slot,
393
+ * which accepts every later positional, else none. Binding and `locate` read positions through it.
394
+ */
395
+ export declare function argumentSlot(slots: readonly ArgumentSlot[], position: number): ArgumentSlot | undefined;
291
396
  /** One invocation after the pre-scan and routing, which the middleware chain runs on top of. */
292
397
  export interface RoutedInvocation {
293
398
  command: BuiltCommand;
@@ -295,24 +400,36 @@ export interface RoutedInvocation {
295
400
  scan: OptionValues;
296
401
  tokens: readonly string[];
297
402
  }
298
- /** Consumes the globals table, then routes the remaining bare tokens to a Command. */
299
- export declare function routeInvocation(graph: BuiltGraph, argv: readonly string[]): RoutedInvocation;
403
+ /**
404
+ * Consumes the globals table, then routes the remaining bare tokens to a Command. `walked`
405
+ * receives the path as routing extends it, the partial path of an unknown Command included.
406
+ */
407
+ export declare function routeInvocation(graph: BuiltGraph, argv: readonly string[], walked: (path: readonly string[]) => void): RoutedInvocation;
300
408
  /** What one invocation reaches the middleware chain with. */
301
409
  export interface DispatchInvocation {
302
410
  /** The channel the action receives, which the results lane builds from the routed node. */
303
411
  channel: (binding: ResultBinding) => ActionChannel;
304
412
  defaults: DefaultValues;
305
413
  host: Host;
414
+ /** The graph `inspect()` returns for the run, built on its first read, which a source reads. */
415
+ inspected: () => CommandGraph;
416
+ /** Offers a configuration source's foreign throw to the translators where its call settles. */
417
+ offer: (thrown: unknown) => LoomError | undefined;
306
418
  signal: AbortSignal;
419
+ /** The channel a configuration source writes through, whose results call names the source. */
420
+ sourceOut: Out<OpenResult>;
307
421
  style: ContextualStyle;
308
422
  }
309
423
  /**
310
424
  * One invocation prepared ahead of the middleware chain. `'ready'` carries the request a middleware
311
425
  * reads and the call that dispatches; `'held'` carries the fault this phase found, which core
312
426
  * raises at the dispatch boundary and never before, so a takeover swallows it. `result` is what the
313
- * routed Command declared, whose views a middleware selects among, on either shape.
427
+ * routed Command declared, whose views a middleware selects among, on either shape. `globals` holds
428
+ * the globals table's values after the input-source stage, which activation and every plugin's own
429
+ * options read on either shape.
314
430
  */
315
431
  export type Prepared = {
432
+ globals: OptionValues;
316
433
  result: DeclaredResult | undefined;
317
434
  } & ({
318
435
  dispatch: (view: string | null) => Promise<void>;
@@ -326,6 +443,8 @@ export type Prepared = {
326
443
  /**
327
444
  * Prepares one dispatch ahead of the middleware chain and holds whatever fault it found, so a
328
445
  * middleware reads the request before the action runs and a takeover never observes the fault.
446
+ * The phases run in order: local parsing, the input-source stage, and validation. A local fault
447
+ * outranks a configuration source's fault, and after either one core runs no validation.
329
448
  */
330
449
  export declare function prepareDispatch(graph: BuiltGraph, routed: RoutedInvocation, invocation: DispatchInvocation): Promise<Prepared>;
331
450
  export {};