@oprt/cli 0.3.0 → 0.4.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/README.md +9 -8
- package/dist/babel-parser.cjs +14339 -0
- package/dist/bin.js +402 -272
- package/dist/contract.json +1 -1
- package/dist/index.cjs +389 -271
- package/dist/index.d.cts +25 -41
- package/dist/index.d.ts +25 -41
- package/dist/index.js +375 -257
- package/dist/registry.json +1 -1
- package/package.json +3 -1
package/dist/index.d.cts
CHANGED
|
@@ -8,7 +8,7 @@ declare const VERSION: string;
|
|
|
8
8
|
* structured result. It rises when a field is removed or changes meaning; adding a field does not
|
|
9
9
|
* raise it. The envelope's `apiVersion` is the same number, kept for the readers that branch on it.
|
|
10
10
|
*/
|
|
11
|
-
declare const RESULT_SCHEMA_VERSION =
|
|
11
|
+
declare const RESULT_SCHEMA_VERSION = 2;
|
|
12
12
|
interface Identity {
|
|
13
13
|
/** This program: the `@oprt/cli` package version. */
|
|
14
14
|
cli_version: string;
|
|
@@ -33,32 +33,18 @@ interface ErrorIdentity {
|
|
|
33
33
|
declare function contractDigest(contract: Contract): string;
|
|
34
34
|
declare function identityOf(contract: Contract): Identity;
|
|
35
35
|
|
|
36
|
-
/**
|
|
37
|
-
* The `typescript` module as the project has it. It is opaque in the installer's own types, so
|
|
38
|
-
* that using those types does not require TypeScript to be installed.
|
|
39
|
-
*/
|
|
40
|
-
type TypeScript = object;
|
|
41
36
|
/** Where the parser came from, for a person or an agent deciding whether to trust the answer. */
|
|
42
37
|
interface ParserInfo {
|
|
43
|
-
name: "
|
|
38
|
+
name: "@babel/parser";
|
|
44
39
|
version: string;
|
|
45
|
-
/**
|
|
46
|
-
|
|
47
|
-
* instead, because the project has none of its own. `provided`: handed in by a caller of the
|
|
48
|
-
* library.
|
|
49
|
-
*/
|
|
50
|
-
source: "project" | "installer" | "provided";
|
|
51
|
-
}
|
|
52
|
-
interface ParserResolution extends ParserInfo {
|
|
53
|
-
/** The folder of the `typescript` package that was loaded. */
|
|
54
|
-
resolved_from: string;
|
|
40
|
+
/** `bundled`: it ships inside oprt (dist/babel-parser.cjs), so there is nothing to install. */
|
|
41
|
+
source: "bundled";
|
|
55
42
|
}
|
|
56
43
|
/** Why checking cannot run, as a stable word. */
|
|
57
|
-
type ParserBlock = "
|
|
44
|
+
type ParserBlock = "parser_missing" | "parser_unusable";
|
|
58
45
|
type ParserProbe = {
|
|
59
46
|
ready: true;
|
|
60
|
-
|
|
61
|
-
resolution: ParserResolution;
|
|
47
|
+
parser: ParserInfo;
|
|
62
48
|
} | {
|
|
63
49
|
ready: false;
|
|
64
50
|
reason: ParserBlock;
|
|
@@ -70,7 +56,7 @@ type ResultType = (typeof RESULT_TYPES)[number];
|
|
|
70
56
|
/** The envelope every `--json` answer and every structured tool result comes in. */
|
|
71
57
|
interface Envelope<T = unknown> {
|
|
72
58
|
/** The result model's version (same number as `identity.schema_version`), for readers that branch on it. */
|
|
73
|
-
apiVersion:
|
|
59
|
+
apiVersion: typeof RESULT_SCHEMA_VERSION;
|
|
74
60
|
/** What `data` holds. */
|
|
75
61
|
type: ResultType;
|
|
76
62
|
identity: Identity;
|
|
@@ -78,7 +64,7 @@ interface Envelope<T = unknown> {
|
|
|
78
64
|
}
|
|
79
65
|
/** What a failure comes in. `code` is stable and only ever added to. */
|
|
80
66
|
interface ErrorEnvelope {
|
|
81
|
-
apiVersion:
|
|
67
|
+
apiVersion: typeof RESULT_SCHEMA_VERSION;
|
|
82
68
|
error: string;
|
|
83
69
|
code: string;
|
|
84
70
|
suggestions?: string[];
|
|
@@ -129,7 +115,7 @@ declare function runAgentCommand(command: AgentCommand, context: {
|
|
|
129
115
|
cwd: string;
|
|
130
116
|
contract: Contract;
|
|
131
117
|
registry: Registry;
|
|
132
|
-
/** For doctor: the
|
|
118
|
+
/** For doctor: the parser probe to report, when the caller already has it. */
|
|
133
119
|
parser?: ParserProbe;
|
|
134
120
|
}): Answer;
|
|
135
121
|
|
|
@@ -214,36 +200,36 @@ interface CheckReport {
|
|
|
214
200
|
parser: ParserInfo;
|
|
215
201
|
}
|
|
216
202
|
/**
|
|
217
|
-
* Check one file's source. `file` is only the name the findings carry
|
|
218
|
-
* is
|
|
203
|
+
* Check one file's source. `file` is only the name the findings carry (and, by its extension, the
|
|
204
|
+
* dialect: `.tsx` is read as TypeScript, anything else as JavaScript). A file that does not parse
|
|
205
|
+
* is not checked at all (`not_evaluated`, with the syntax errors as findings): what a parser
|
|
219
206
|
* recovers from broken code is a guess, and the contract is not judged on a guess.
|
|
220
207
|
*/
|
|
221
|
-
declare function checkSource(
|
|
208
|
+
declare function checkSource(contract: Contract, file: string, text: string): SourceEvaluation;
|
|
222
209
|
/**
|
|
223
210
|
* The report for a set of evaluated files. The status is `evaluated_clean` only when every file
|
|
224
211
|
* was read in full and nothing was found; everything short of that has its own name.
|
|
225
212
|
*/
|
|
226
|
-
declare function buildCheckReport(evaluations: readonly SourceEvaluation[], context
|
|
227
|
-
parser
|
|
213
|
+
declare function buildCheckReport(evaluations: readonly SourceEvaluation[], context?: {
|
|
214
|
+
parser?: ParserInfo;
|
|
228
215
|
skipped?: SkippedInput[];
|
|
229
216
|
}): CheckReport;
|
|
230
217
|
/**
|
|
231
218
|
* The exit code of `oprt check`. 0: every file that was read has no errors (and, when strict, no
|
|
232
219
|
* warnings); limits are shown and do not fail the run. 1: an error was found, a file did not
|
|
233
220
|
* parse, or no file was read at all (nothing was checked, which is not a pass). Usage mistakes
|
|
234
|
-
* and a path that is not there exit 2, and a
|
|
221
|
+
* and a path that is not there exit 2, and a parser that cannot be loaded exits 1, before any report.
|
|
235
222
|
*/
|
|
236
223
|
declare function checkExitCode(report: CheckReport, { strict }: {
|
|
237
224
|
strict: boolean;
|
|
238
225
|
}): number;
|
|
239
226
|
/**
|
|
240
|
-
* Check every .tsx and .jsx file under the given paths
|
|
241
|
-
*
|
|
227
|
+
* Check every .tsx and .jsx file under the given paths, with the parser that ships inside oprt.
|
|
228
|
+
* Fails with a code when that parser cannot be loaded, rather than answering without it.
|
|
242
229
|
*/
|
|
243
230
|
declare function checkPaths(paths: string[], context: {
|
|
244
231
|
cwd: string;
|
|
245
232
|
contract: Contract;
|
|
246
|
-
typescript?: TypeScript | null;
|
|
247
233
|
}): CheckReport;
|
|
248
234
|
/**
|
|
249
235
|
* A check as text, for a terminal or a tool result. Findings first, then the limits, then one
|
|
@@ -259,8 +245,9 @@ interface DoctorCheck {
|
|
|
259
245
|
}
|
|
260
246
|
/**
|
|
261
247
|
* Whether one thing oprt does can run here. Lookups (search, component, list) read the contract
|
|
262
|
-
* that ships inside oprt, so they always can. Checking code needs a parser, which
|
|
263
|
-
*
|
|
248
|
+
* that ships inside oprt, so they always can. Checking code needs a parser, which also ships inside
|
|
249
|
+
* oprt (Babel's): it needs nothing from the project, and is blocked only if that file is missing
|
|
250
|
+
* or fails a probe, with the reason as a word.
|
|
264
251
|
*/
|
|
265
252
|
interface DoctorOperations {
|
|
266
253
|
lookup: {
|
|
@@ -273,8 +260,8 @@ interface DoctorOperations {
|
|
|
273
260
|
message: string;
|
|
274
261
|
reason?: ParserBlock;
|
|
275
262
|
fix?: string;
|
|
276
|
-
/** The parser that checking
|
|
277
|
-
|
|
263
|
+
/** The parser that checking reads code with, when it is ready. */
|
|
264
|
+
parser?: ParserInfo;
|
|
278
265
|
};
|
|
279
266
|
}
|
|
280
267
|
interface DoctorReport {
|
|
@@ -292,7 +279,7 @@ interface DoctorReport {
|
|
|
292
279
|
declare function doctor({ cwd, contract, parser, }: {
|
|
293
280
|
cwd: string;
|
|
294
281
|
contract: Contract;
|
|
295
|
-
/** What
|
|
282
|
+
/** What probing the parser found. Probed here when it is not passed. */
|
|
296
283
|
parser?: ParserProbe;
|
|
297
284
|
}): DoctorReport;
|
|
298
285
|
|
|
@@ -317,9 +304,6 @@ interface PropertySchema {
|
|
|
317
304
|
interface McpContext {
|
|
318
305
|
contract: Contract;
|
|
319
306
|
registry: Registry;
|
|
320
|
-
/** For check_code. Found beside the project or the installer when it is not passed. */
|
|
321
|
-
typescript?: TypeScript | null;
|
|
322
|
-
cwd?: string;
|
|
323
307
|
}
|
|
324
308
|
interface ToolDefinition {
|
|
325
309
|
name: string;
|
|
@@ -377,4 +361,4 @@ declare function install(options: AddOptions, context?: {
|
|
|
377
361
|
registry?: Registry;
|
|
378
362
|
}): InstallResult;
|
|
379
363
|
|
|
380
|
-
export { AddOptions, type Answer, type CheckReport, Command, ComponentDetail, type ComponentDetailData, Contract, DEFAULT_OUT, type DoctorCheck, type DoctorReport, type Envelope, type ErrorEnvelope, type ErrorIdentity, type EvaluationStatus, type Finding, type Identity, type InitFile, type InitOptions, type InitResult, InstallResult, type Limitation, type McpContext, RESULT_SCHEMAS, RESULT_SCHEMA_VERSION, RESULT_TYPES, Registry, RegistryEntry, type ResultType, type SkippedInput, type SourceEvaluation, TOOLS,
|
|
364
|
+
export { AddOptions, type Answer, type CheckReport, Command, ComponentDetail, type ComponentDetailData, Contract, DEFAULT_OUT, type DoctorCheck, type DoctorReport, type Envelope, type ErrorEnvelope, type ErrorIdentity, type EvaluationStatus, type Finding, type Identity, type InitFile, type InitOptions, type InitResult, InstallResult, type Limitation, type McpContext, type ParserInfo, RESULT_SCHEMAS, RESULT_SCHEMA_VERSION, RESULT_TYPES, Registry, RegistryEntry, type ResultType, type SkippedInput, type SourceEvaluation, TOOLS, VERSION, buildCheckReport, checkExitCode, checkPaths, checkSource, contract, contractDigest, doctor, envelope, errorEnvelope, handleMessage, identityOf, init, install, outputSchemaFor, parseArgs, registry, renderCheckText, resolveEntries, runAgentCommand, schemaFor, serve };
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ declare const VERSION: string;
|
|
|
8
8
|
* structured result. It rises when a field is removed or changes meaning; adding a field does not
|
|
9
9
|
* raise it. The envelope's `apiVersion` is the same number, kept for the readers that branch on it.
|
|
10
10
|
*/
|
|
11
|
-
declare const RESULT_SCHEMA_VERSION =
|
|
11
|
+
declare const RESULT_SCHEMA_VERSION = 2;
|
|
12
12
|
interface Identity {
|
|
13
13
|
/** This program: the `@oprt/cli` package version. */
|
|
14
14
|
cli_version: string;
|
|
@@ -33,32 +33,18 @@ interface ErrorIdentity {
|
|
|
33
33
|
declare function contractDigest(contract: Contract): string;
|
|
34
34
|
declare function identityOf(contract: Contract): Identity;
|
|
35
35
|
|
|
36
|
-
/**
|
|
37
|
-
* The `typescript` module as the project has it. It is opaque in the installer's own types, so
|
|
38
|
-
* that using those types does not require TypeScript to be installed.
|
|
39
|
-
*/
|
|
40
|
-
type TypeScript = object;
|
|
41
36
|
/** Where the parser came from, for a person or an agent deciding whether to trust the answer. */
|
|
42
37
|
interface ParserInfo {
|
|
43
|
-
name: "
|
|
38
|
+
name: "@babel/parser";
|
|
44
39
|
version: string;
|
|
45
|
-
/**
|
|
46
|
-
|
|
47
|
-
* instead, because the project has none of its own. `provided`: handed in by a caller of the
|
|
48
|
-
* library.
|
|
49
|
-
*/
|
|
50
|
-
source: "project" | "installer" | "provided";
|
|
51
|
-
}
|
|
52
|
-
interface ParserResolution extends ParserInfo {
|
|
53
|
-
/** The folder of the `typescript` package that was loaded. */
|
|
54
|
-
resolved_from: string;
|
|
40
|
+
/** `bundled`: it ships inside oprt (dist/babel-parser.cjs), so there is nothing to install. */
|
|
41
|
+
source: "bundled";
|
|
55
42
|
}
|
|
56
43
|
/** Why checking cannot run, as a stable word. */
|
|
57
|
-
type ParserBlock = "
|
|
44
|
+
type ParserBlock = "parser_missing" | "parser_unusable";
|
|
58
45
|
type ParserProbe = {
|
|
59
46
|
ready: true;
|
|
60
|
-
|
|
61
|
-
resolution: ParserResolution;
|
|
47
|
+
parser: ParserInfo;
|
|
62
48
|
} | {
|
|
63
49
|
ready: false;
|
|
64
50
|
reason: ParserBlock;
|
|
@@ -70,7 +56,7 @@ type ResultType = (typeof RESULT_TYPES)[number];
|
|
|
70
56
|
/** The envelope every `--json` answer and every structured tool result comes in. */
|
|
71
57
|
interface Envelope<T = unknown> {
|
|
72
58
|
/** The result model's version (same number as `identity.schema_version`), for readers that branch on it. */
|
|
73
|
-
apiVersion:
|
|
59
|
+
apiVersion: typeof RESULT_SCHEMA_VERSION;
|
|
74
60
|
/** What `data` holds. */
|
|
75
61
|
type: ResultType;
|
|
76
62
|
identity: Identity;
|
|
@@ -78,7 +64,7 @@ interface Envelope<T = unknown> {
|
|
|
78
64
|
}
|
|
79
65
|
/** What a failure comes in. `code` is stable and only ever added to. */
|
|
80
66
|
interface ErrorEnvelope {
|
|
81
|
-
apiVersion:
|
|
67
|
+
apiVersion: typeof RESULT_SCHEMA_VERSION;
|
|
82
68
|
error: string;
|
|
83
69
|
code: string;
|
|
84
70
|
suggestions?: string[];
|
|
@@ -129,7 +115,7 @@ declare function runAgentCommand(command: AgentCommand, context: {
|
|
|
129
115
|
cwd: string;
|
|
130
116
|
contract: Contract;
|
|
131
117
|
registry: Registry;
|
|
132
|
-
/** For doctor: the
|
|
118
|
+
/** For doctor: the parser probe to report, when the caller already has it. */
|
|
133
119
|
parser?: ParserProbe;
|
|
134
120
|
}): Answer;
|
|
135
121
|
|
|
@@ -214,36 +200,36 @@ interface CheckReport {
|
|
|
214
200
|
parser: ParserInfo;
|
|
215
201
|
}
|
|
216
202
|
/**
|
|
217
|
-
* Check one file's source. `file` is only the name the findings carry
|
|
218
|
-
* is
|
|
203
|
+
* Check one file's source. `file` is only the name the findings carry (and, by its extension, the
|
|
204
|
+
* dialect: `.tsx` is read as TypeScript, anything else as JavaScript). A file that does not parse
|
|
205
|
+
* is not checked at all (`not_evaluated`, with the syntax errors as findings): what a parser
|
|
219
206
|
* recovers from broken code is a guess, and the contract is not judged on a guess.
|
|
220
207
|
*/
|
|
221
|
-
declare function checkSource(
|
|
208
|
+
declare function checkSource(contract: Contract, file: string, text: string): SourceEvaluation;
|
|
222
209
|
/**
|
|
223
210
|
* The report for a set of evaluated files. The status is `evaluated_clean` only when every file
|
|
224
211
|
* was read in full and nothing was found; everything short of that has its own name.
|
|
225
212
|
*/
|
|
226
|
-
declare function buildCheckReport(evaluations: readonly SourceEvaluation[], context
|
|
227
|
-
parser
|
|
213
|
+
declare function buildCheckReport(evaluations: readonly SourceEvaluation[], context?: {
|
|
214
|
+
parser?: ParserInfo;
|
|
228
215
|
skipped?: SkippedInput[];
|
|
229
216
|
}): CheckReport;
|
|
230
217
|
/**
|
|
231
218
|
* The exit code of `oprt check`. 0: every file that was read has no errors (and, when strict, no
|
|
232
219
|
* warnings); limits are shown and do not fail the run. 1: an error was found, a file did not
|
|
233
220
|
* parse, or no file was read at all (nothing was checked, which is not a pass). Usage mistakes
|
|
234
|
-
* and a path that is not there exit 2, and a
|
|
221
|
+
* and a path that is not there exit 2, and a parser that cannot be loaded exits 1, before any report.
|
|
235
222
|
*/
|
|
236
223
|
declare function checkExitCode(report: CheckReport, { strict }: {
|
|
237
224
|
strict: boolean;
|
|
238
225
|
}): number;
|
|
239
226
|
/**
|
|
240
|
-
* Check every .tsx and .jsx file under the given paths
|
|
241
|
-
*
|
|
227
|
+
* Check every .tsx and .jsx file under the given paths, with the parser that ships inside oprt.
|
|
228
|
+
* Fails with a code when that parser cannot be loaded, rather than answering without it.
|
|
242
229
|
*/
|
|
243
230
|
declare function checkPaths(paths: string[], context: {
|
|
244
231
|
cwd: string;
|
|
245
232
|
contract: Contract;
|
|
246
|
-
typescript?: TypeScript | null;
|
|
247
233
|
}): CheckReport;
|
|
248
234
|
/**
|
|
249
235
|
* A check as text, for a terminal or a tool result. Findings first, then the limits, then one
|
|
@@ -259,8 +245,9 @@ interface DoctorCheck {
|
|
|
259
245
|
}
|
|
260
246
|
/**
|
|
261
247
|
* Whether one thing oprt does can run here. Lookups (search, component, list) read the contract
|
|
262
|
-
* that ships inside oprt, so they always can. Checking code needs a parser, which
|
|
263
|
-
*
|
|
248
|
+
* that ships inside oprt, so they always can. Checking code needs a parser, which also ships inside
|
|
249
|
+
* oprt (Babel's): it needs nothing from the project, and is blocked only if that file is missing
|
|
250
|
+
* or fails a probe, with the reason as a word.
|
|
264
251
|
*/
|
|
265
252
|
interface DoctorOperations {
|
|
266
253
|
lookup: {
|
|
@@ -273,8 +260,8 @@ interface DoctorOperations {
|
|
|
273
260
|
message: string;
|
|
274
261
|
reason?: ParserBlock;
|
|
275
262
|
fix?: string;
|
|
276
|
-
/** The parser that checking
|
|
277
|
-
|
|
263
|
+
/** The parser that checking reads code with, when it is ready. */
|
|
264
|
+
parser?: ParserInfo;
|
|
278
265
|
};
|
|
279
266
|
}
|
|
280
267
|
interface DoctorReport {
|
|
@@ -292,7 +279,7 @@ interface DoctorReport {
|
|
|
292
279
|
declare function doctor({ cwd, contract, parser, }: {
|
|
293
280
|
cwd: string;
|
|
294
281
|
contract: Contract;
|
|
295
|
-
/** What
|
|
282
|
+
/** What probing the parser found. Probed here when it is not passed. */
|
|
296
283
|
parser?: ParserProbe;
|
|
297
284
|
}): DoctorReport;
|
|
298
285
|
|
|
@@ -317,9 +304,6 @@ interface PropertySchema {
|
|
|
317
304
|
interface McpContext {
|
|
318
305
|
contract: Contract;
|
|
319
306
|
registry: Registry;
|
|
320
|
-
/** For check_code. Found beside the project or the installer when it is not passed. */
|
|
321
|
-
typescript?: TypeScript | null;
|
|
322
|
-
cwd?: string;
|
|
323
307
|
}
|
|
324
308
|
interface ToolDefinition {
|
|
325
309
|
name: string;
|
|
@@ -377,4 +361,4 @@ declare function install(options: AddOptions, context?: {
|
|
|
377
361
|
registry?: Registry;
|
|
378
362
|
}): InstallResult;
|
|
379
363
|
|
|
380
|
-
export { AddOptions, type Answer, type CheckReport, Command, ComponentDetail, type ComponentDetailData, Contract, DEFAULT_OUT, type DoctorCheck, type DoctorReport, type Envelope, type ErrorEnvelope, type ErrorIdentity, type EvaluationStatus, type Finding, type Identity, type InitFile, type InitOptions, type InitResult, InstallResult, type Limitation, type McpContext, RESULT_SCHEMAS, RESULT_SCHEMA_VERSION, RESULT_TYPES, Registry, RegistryEntry, type ResultType, type SkippedInput, type SourceEvaluation, TOOLS,
|
|
364
|
+
export { AddOptions, type Answer, type CheckReport, Command, ComponentDetail, type ComponentDetailData, Contract, DEFAULT_OUT, type DoctorCheck, type DoctorReport, type Envelope, type ErrorEnvelope, type ErrorIdentity, type EvaluationStatus, type Finding, type Identity, type InitFile, type InitOptions, type InitResult, InstallResult, type Limitation, type McpContext, type ParserInfo, RESULT_SCHEMAS, RESULT_SCHEMA_VERSION, RESULT_TYPES, Registry, RegistryEntry, type ResultType, type SkippedInput, type SourceEvaluation, TOOLS, VERSION, buildCheckReport, checkExitCode, checkPaths, checkSource, contract, contractDigest, doctor, envelope, errorEnvelope, handleMessage, identityOf, init, install, outputSchemaFor, parseArgs, registry, renderCheckText, resolveEntries, runAgentCommand, schemaFor, serve };
|