@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
@@ -1,4 +1,6 @@
1
1
  import type { StandardSchemaV1 } from '@standard-schema/spec';
2
+ import type { Finding } from './diagnostic-text.js';
3
+ import type { InputSite } from './facts.js';
2
4
  import type { OptionValues } from './options.js';
3
5
  import type { ArgumentConfig, ArgumentValue, Host, OptionConfig, OptionValue } from './types.js';
4
6
  /**
@@ -24,6 +26,14 @@ export interface ScopedInputs {
24
26
  globals: readonly InputDeclaration[];
25
27
  locals: readonly InputDeclaration[];
26
28
  }
29
+ /**
30
+ * What the input-source stage leaves for validation's messages, by option name: the label of each
31
+ * value it filled, and the variable of each Boolean option whose value is outside the grammar.
32
+ */
33
+ interface Provenance {
34
+ labels: ReadonlyMap<string, string>;
35
+ rejected: ReadonlyMap<string, string>;
36
+ }
27
37
  /** The raw tokens one invocation collected, keyed by declaration and by option name. */
28
38
  interface SuppliedValues {
29
39
  args: ReadonlyMap<InputDeclaration, string | string[]>;
@@ -36,8 +46,14 @@ export interface Invocation {
36
46
  host: Host;
37
47
  inputs: ScopedInputs;
38
48
  passthrough: readonly string[];
39
- /** The run's cancellation signal, which stops this phase between two schema calls. */
49
+ /**
50
+ * The plugin options, which are never validated. A Boolean one whose variable is outside the
51
+ * grammar is still a problem of this phase, reported after the globals and before the locals.
52
+ */
53
+ plugins: readonly OptionInput[];
54
+ /** The run's cancellation signal, which stops this phase between two validator calls. */
40
55
  signal: AbortSignal;
56
+ sources: Provenance;
41
57
  supplied: SuppliedValues;
42
58
  }
43
59
  /**
@@ -59,6 +75,16 @@ declare class ValidatedInputs {
59
75
  read(input: InputDeclaration): unknown;
60
76
  }
61
77
  export type { ValidatedInputs };
78
+ /**
79
+ * The one check every `argument()`, `option()`, and `globalOption()` call makes before it reads its
80
+ * config, so a call in JavaScript that supplies none, or a value of another kind, reports a
81
+ * declaration fault and not a TypeError. `place` is where the call sits.
82
+ */
83
+ export declare function checkInputConfig(declared: {
84
+ readonly config: unknown;
85
+ readonly kind: InputDeclaration['kind'];
86
+ readonly name: string;
87
+ }, place: InputPlace): void;
62
88
  /**
63
89
  * Authoring's snapshot of one config. An array default is the one declared value core hands to an
64
90
  * action as its own value, so the declaration keeps a copy and the caller keeps its array. Every
@@ -66,7 +92,28 @@ export type { ValidatedInputs };
66
92
  */
67
93
  export declare function captureConfig<Config extends ArgumentConfig | OptionConfig>(config: Config): Config;
68
94
  /**
69
- * The declaration flag that sends an omitted value to its own schema. Every declaration reads it
95
+ * A declaration error names the declaration, because the author reads the declaration to fix it.
96
+ * An argument declares and reads under one name, so the two namings differ for options alone.
97
+ */
98
+ export declare function declarationSubject(input: InputDeclaration): string;
99
+ /** Where the call that declared one input sits: the call's name and the Command it is on. */
100
+ export type InputPlace = Pick<Finding, 'call' | 'path'>;
101
+ /**
102
+ * Where one input was declared: a global option at its `globalOption()` call, and every other input
103
+ * at its own `argument()` or `option()` call on the Command at `path`.
104
+ */
105
+ export declare function inputPlace(input: InputDeclaration, scope: {
106
+ readonly global: boolean;
107
+ readonly path: readonly string[];
108
+ }): InputPlace;
109
+ /**
110
+ * The site of the call that declared one input at `place`, rebuilt as `call(name, config)`. Every
111
+ * finding for an input's own call starts from it, so each marks the call the same way. `subject`
112
+ * is the sentence's name for the input.
113
+ */
114
+ export declare function declaringSite(input: InputDeclaration, place: InputPlace, subject?: string): InputSite;
115
+ /**
116
+ * The declaration flag that sends an omitted value to its own validator. Every declaration reads it
70
117
  * here, and the declaration rules below reject it wherever another rule already decides absence.
71
118
  */
72
119
  export declare function validatesOmission(input: InputDeclaration): boolean;
@@ -76,17 +123,25 @@ export declare function validatesOmission(input: InputDeclaration): boolean;
76
123
  * helper, so a rejected item reads alike wherever its diagnostic is written.
77
124
  */
78
125
  export declare function issuePath(issue: StandardSchemaV1.Issue): string | undefined;
126
+ /** One declaration and where it was declared, which its faults' findings rebuild. */
127
+ export interface SitedInput {
128
+ readonly input: InputDeclaration;
129
+ readonly site: InputSite;
130
+ }
79
131
  /**
80
- * Every declaration rule that reads the declaration alone. It is synchronous, so `inspect()` and
81
- * `run()` apply exactly the same rules, and only validating a default through its schema, which
82
- * can be asynchronous, is left to `run()`. A contributor that declares under its own name, such as
83
- * a plugin, supplies the subject its diagnostics read with; every other caller is named by the
84
- * declaration itself.
132
+ * Every declaration rule that reads the declaration alone. It is synchronous, so the call that
133
+ * declares an input applies it, and build applies it to an input a lifecycle hook declared; only
134
+ * validating a default through its validator, which can be asynchronous, is left to `run()`. A
135
+ * contributor that declares under its own name, such as a plugin, supplies the subject its
136
+ * diagnostics read with; every other caller is named by the declaration itself.
85
137
  */
86
- export declare function checkDeclarations(inputs: readonly InputDeclaration[], named?: string): void;
138
+ export declare function checkDeclarations(inputs: readonly SitedInput[], named?: string): void;
139
+ /** The call that declared one input and the Command it sits on, which a default's fault rebuilds. */
140
+ export type InputPlaces = ReadonlyMap<InputDeclaration, InputPlace>;
87
141
  /**
88
142
  * Every declared default, validated before any token is read. The host is captured by then, so a
89
- * default's schema reads the same Host its action will, under the `default` phase.
143
+ * default's validator reads the same Host its action will, under the `default` phase. `places`
144
+ * says where each declaration sits, which a rejected default's finding rebuilds.
90
145
  */
91
- export declare function prepareInputs(inputs: ScopedInputs, host: Host): Promise<DefaultValues>;
146
+ export declare function prepareInputs(inputs: ScopedInputs, host: Host, places: InputPlaces): Promise<DefaultValues>;
92
147
  export declare function validateValues(invocation: Invocation): Promise<ValidatedInputs>;