@oprt/cli 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +91 -2
- package/dist/bin.js +1653 -0
- package/dist/contract.json +1 -0
- package/dist/index.cjs +1445 -0
- package/dist/index.d.cts +211 -0
- package/dist/index.d.ts +211 -0
- package/dist/index.js +1400 -0
- package/dist/read-8a9euzJx.d.cts +246 -0
- package/dist/read-8a9euzJx.d.ts +246 -0
- package/dist/read.cjs +283 -0
- package/dist/read.d.cts +1 -0
- package/dist/read.d.ts +1 -0
- package/dist/read.js +250 -0
- package/dist/registry.json +1 -0
- package/package.json +64 -3
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { C as Command, a as Contract, R as Registry, b as RegistryEntry, A as AddOptions, I as InstallResult } from './read-8a9euzJx.cjs';
|
|
2
|
+
export { c as CliError, d as ComponentDetail, D as DetailProp, e as IndexEntry, f as InstallFile, S as SearchResult, g as applyBlock, h as blockVersion, i as componentDetail, j as componentIndex, r as removeBlock, k as renderAgentBlock, l as renderComponent, s as search } from './read-8a9euzJx.cjs';
|
|
3
|
+
|
|
4
|
+
/** The envelope every `--json` answer comes in. `type` says what `data` holds. */
|
|
5
|
+
interface Envelope {
|
|
6
|
+
apiVersion: 1;
|
|
7
|
+
type: string;
|
|
8
|
+
data: unknown;
|
|
9
|
+
}
|
|
10
|
+
interface Answer {
|
|
11
|
+
/** What a person reads. */
|
|
12
|
+
text: string;
|
|
13
|
+
/** What `--json` prints. */
|
|
14
|
+
json: Envelope;
|
|
15
|
+
exitCode: number;
|
|
16
|
+
}
|
|
17
|
+
type AgentCommand = Extract<Command, {
|
|
18
|
+
command: "component" | "search" | "init" | "doctor" | "check";
|
|
19
|
+
}>;
|
|
20
|
+
/** Runs one of the commands an agent reads the contract with, and returns both forms of the answer. */
|
|
21
|
+
declare function runAgentCommand(command: AgentCommand, context: {
|
|
22
|
+
cwd: string;
|
|
23
|
+
contract: Contract;
|
|
24
|
+
registry: Registry;
|
|
25
|
+
}): Answer;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The `typescript` module as the project has it. It is opaque in the installer's own types, so
|
|
29
|
+
* that using those types does not require TypeScript to be installed.
|
|
30
|
+
*/
|
|
31
|
+
type TypeScript = object;
|
|
32
|
+
interface Finding {
|
|
33
|
+
/** Stable, and only ever added to. Branch on this, not on the message. */
|
|
34
|
+
code: "INVALID_PROP_VALUE" | "UNKNOWN_EXPORT" | "DOT_NOTATION" | "INVALID_NESTING" | "INVALID_CHILD" | "MISSING_REQUIRED_PROP" | "UNKNOWN_PROP" | "RAW_COLOR" | "ARBITRARY_SIZE" | "ROUNDED_CORNER" | "NATIVE_CONTROL";
|
|
35
|
+
/** An error breaks the contract. A warning breaks a house rule, or may be a native attribute. */
|
|
36
|
+
severity: "error" | "warning";
|
|
37
|
+
file: string;
|
|
38
|
+
line: number;
|
|
39
|
+
column: number;
|
|
40
|
+
component?: string;
|
|
41
|
+
prop?: string;
|
|
42
|
+
message: string;
|
|
43
|
+
valid_values?: string[];
|
|
44
|
+
suggestions?: string[];
|
|
45
|
+
}
|
|
46
|
+
interface CheckReport {
|
|
47
|
+
/** How many files were read. */
|
|
48
|
+
files: number;
|
|
49
|
+
findings: Finding[];
|
|
50
|
+
summary: {
|
|
51
|
+
errors: number;
|
|
52
|
+
warnings: number;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** Check one file's source. `file` is only the name the findings carry. */
|
|
56
|
+
declare function checkSource(typescript: TypeScript, contract: Contract, file: string, text: string): Finding[];
|
|
57
|
+
/**
|
|
58
|
+
* Check every .tsx and .jsx file under the given paths. `typescript` is found in the project when
|
|
59
|
+
* it is not passed; null stands for "there is none".
|
|
60
|
+
*/
|
|
61
|
+
declare function checkPaths(paths: string[], context: {
|
|
62
|
+
cwd: string;
|
|
63
|
+
contract: Contract;
|
|
64
|
+
typescript?: TypeScript | null;
|
|
65
|
+
}): CheckReport;
|
|
66
|
+
|
|
67
|
+
interface DoctorCheck {
|
|
68
|
+
id: string;
|
|
69
|
+
status: "ok" | "warn" | "fail";
|
|
70
|
+
message: string;
|
|
71
|
+
fix?: string;
|
|
72
|
+
}
|
|
73
|
+
interface DoctorReport {
|
|
74
|
+
checks: DoctorCheck[];
|
|
75
|
+
summary: {
|
|
76
|
+
ok: number;
|
|
77
|
+
warn: number;
|
|
78
|
+
fail: number;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
declare function doctor({ cwd, contract }: {
|
|
82
|
+
cwd: string;
|
|
83
|
+
contract: Contract;
|
|
84
|
+
}): DoctorReport;
|
|
85
|
+
|
|
86
|
+
interface McpContext {
|
|
87
|
+
contract: Contract;
|
|
88
|
+
registry: Registry;
|
|
89
|
+
/** For check_code. Found beside the project or the installer when it is not passed. */
|
|
90
|
+
typescript?: TypeScript | null;
|
|
91
|
+
cwd?: string;
|
|
92
|
+
}
|
|
93
|
+
declare const TOOLS: ({
|
|
94
|
+
name: string;
|
|
95
|
+
description: string;
|
|
96
|
+
inputSchema: {
|
|
97
|
+
type: string;
|
|
98
|
+
properties: {
|
|
99
|
+
query: {
|
|
100
|
+
type: string;
|
|
101
|
+
description: string;
|
|
102
|
+
};
|
|
103
|
+
limit: {
|
|
104
|
+
type: string;
|
|
105
|
+
description: string;
|
|
106
|
+
};
|
|
107
|
+
name?: never;
|
|
108
|
+
dense?: never;
|
|
109
|
+
code?: never;
|
|
110
|
+
};
|
|
111
|
+
required: string[];
|
|
112
|
+
};
|
|
113
|
+
} | {
|
|
114
|
+
name: string;
|
|
115
|
+
description: string;
|
|
116
|
+
inputSchema: {
|
|
117
|
+
type: string;
|
|
118
|
+
properties: {
|
|
119
|
+
name: {
|
|
120
|
+
type: string;
|
|
121
|
+
description: string;
|
|
122
|
+
};
|
|
123
|
+
dense: {
|
|
124
|
+
type: string;
|
|
125
|
+
description: string;
|
|
126
|
+
};
|
|
127
|
+
query?: never;
|
|
128
|
+
limit?: never;
|
|
129
|
+
code?: never;
|
|
130
|
+
};
|
|
131
|
+
required: string[];
|
|
132
|
+
};
|
|
133
|
+
} | {
|
|
134
|
+
name: string;
|
|
135
|
+
description: string;
|
|
136
|
+
inputSchema: {
|
|
137
|
+
type: string;
|
|
138
|
+
properties: {
|
|
139
|
+
query?: never;
|
|
140
|
+
limit?: never;
|
|
141
|
+
name?: never;
|
|
142
|
+
dense?: never;
|
|
143
|
+
code?: never;
|
|
144
|
+
};
|
|
145
|
+
required?: never;
|
|
146
|
+
};
|
|
147
|
+
} | {
|
|
148
|
+
name: string;
|
|
149
|
+
description: string;
|
|
150
|
+
inputSchema: {
|
|
151
|
+
type: string;
|
|
152
|
+
properties: {
|
|
153
|
+
code: {
|
|
154
|
+
type: string;
|
|
155
|
+
description: string;
|
|
156
|
+
};
|
|
157
|
+
query?: never;
|
|
158
|
+
limit?: never;
|
|
159
|
+
name?: never;
|
|
160
|
+
dense?: never;
|
|
161
|
+
};
|
|
162
|
+
required: string[];
|
|
163
|
+
};
|
|
164
|
+
})[];
|
|
165
|
+
/**
|
|
166
|
+
* Answer one message. Returns the response to write, or null for a notification, which gets none.
|
|
167
|
+
* `raw` is a parsed message, or the line itself when it could not be parsed.
|
|
168
|
+
*/
|
|
169
|
+
declare function handleMessage(raw: unknown, context: McpContext): object | null;
|
|
170
|
+
/** Serve until the input ends: one JSON message a line in, one a line out. */
|
|
171
|
+
declare function serve(input: NodeJS.ReadableStream, output: NodeJS.WritableStream, context: McpContext): Promise<void>;
|
|
172
|
+
|
|
173
|
+
interface InitOptions {
|
|
174
|
+
agent?: string;
|
|
175
|
+
/** One file to write instead, relative to the project. */
|
|
176
|
+
path?: string;
|
|
177
|
+
/** Take the block out again. */
|
|
178
|
+
remove?: boolean;
|
|
179
|
+
dryRun?: boolean;
|
|
180
|
+
}
|
|
181
|
+
interface InitFile {
|
|
182
|
+
path: string;
|
|
183
|
+
action: "create" | "append" | "update" | "unchanged" | "remove" | "delete" | "absent";
|
|
184
|
+
}
|
|
185
|
+
interface InitResult {
|
|
186
|
+
version: string;
|
|
187
|
+
dryRun: boolean;
|
|
188
|
+
files: InitFile[];
|
|
189
|
+
}
|
|
190
|
+
declare function init(options: InitOptions, context: {
|
|
191
|
+
cwd: string;
|
|
192
|
+
contract: Contract;
|
|
193
|
+
}): InitResult;
|
|
194
|
+
|
|
195
|
+
declare const DEFAULT_OUT = "src/components/operator";
|
|
196
|
+
declare function parseArgs(args: string[]): Command;
|
|
197
|
+
|
|
198
|
+
declare function resolveEntries(names: string[], registry: Registry): RegistryEntry[];
|
|
199
|
+
|
|
200
|
+
declare const VERSION: string;
|
|
201
|
+
declare const registry: Registry;
|
|
202
|
+
/** The contract this installer carries, read from beside it the first time it is asked for. */
|
|
203
|
+
declare const contract: () => Contract;
|
|
204
|
+
|
|
205
|
+
/** Copy a fully preflighted source bundle; no package manager or network calls. */
|
|
206
|
+
declare function install(options: AddOptions, context?: {
|
|
207
|
+
cwd?: string;
|
|
208
|
+
registry?: Registry;
|
|
209
|
+
}): InstallResult;
|
|
210
|
+
|
|
211
|
+
export { AddOptions, type Answer, type CheckReport, Command, Contract, DEFAULT_OUT, type DoctorCheck, type DoctorReport, type Envelope, type Finding, type InitFile, type InitOptions, type InitResult, InstallResult, type McpContext, Registry, RegistryEntry, TOOLS, type TypeScript, VERSION, checkPaths, checkSource, contract, doctor, handleMessage, init, install, parseArgs, registry, resolveEntries, runAgentCommand, serve };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { C as Command, a as Contract, R as Registry, b as RegistryEntry, A as AddOptions, I as InstallResult } from './read-8a9euzJx.js';
|
|
2
|
+
export { c as CliError, d as ComponentDetail, D as DetailProp, e as IndexEntry, f as InstallFile, S as SearchResult, g as applyBlock, h as blockVersion, i as componentDetail, j as componentIndex, r as removeBlock, k as renderAgentBlock, l as renderComponent, s as search } from './read-8a9euzJx.js';
|
|
3
|
+
|
|
4
|
+
/** The envelope every `--json` answer comes in. `type` says what `data` holds. */
|
|
5
|
+
interface Envelope {
|
|
6
|
+
apiVersion: 1;
|
|
7
|
+
type: string;
|
|
8
|
+
data: unknown;
|
|
9
|
+
}
|
|
10
|
+
interface Answer {
|
|
11
|
+
/** What a person reads. */
|
|
12
|
+
text: string;
|
|
13
|
+
/** What `--json` prints. */
|
|
14
|
+
json: Envelope;
|
|
15
|
+
exitCode: number;
|
|
16
|
+
}
|
|
17
|
+
type AgentCommand = Extract<Command, {
|
|
18
|
+
command: "component" | "search" | "init" | "doctor" | "check";
|
|
19
|
+
}>;
|
|
20
|
+
/** Runs one of the commands an agent reads the contract with, and returns both forms of the answer. */
|
|
21
|
+
declare function runAgentCommand(command: AgentCommand, context: {
|
|
22
|
+
cwd: string;
|
|
23
|
+
contract: Contract;
|
|
24
|
+
registry: Registry;
|
|
25
|
+
}): Answer;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The `typescript` module as the project has it. It is opaque in the installer's own types, so
|
|
29
|
+
* that using those types does not require TypeScript to be installed.
|
|
30
|
+
*/
|
|
31
|
+
type TypeScript = object;
|
|
32
|
+
interface Finding {
|
|
33
|
+
/** Stable, and only ever added to. Branch on this, not on the message. */
|
|
34
|
+
code: "INVALID_PROP_VALUE" | "UNKNOWN_EXPORT" | "DOT_NOTATION" | "INVALID_NESTING" | "INVALID_CHILD" | "MISSING_REQUIRED_PROP" | "UNKNOWN_PROP" | "RAW_COLOR" | "ARBITRARY_SIZE" | "ROUNDED_CORNER" | "NATIVE_CONTROL";
|
|
35
|
+
/** An error breaks the contract. A warning breaks a house rule, or may be a native attribute. */
|
|
36
|
+
severity: "error" | "warning";
|
|
37
|
+
file: string;
|
|
38
|
+
line: number;
|
|
39
|
+
column: number;
|
|
40
|
+
component?: string;
|
|
41
|
+
prop?: string;
|
|
42
|
+
message: string;
|
|
43
|
+
valid_values?: string[];
|
|
44
|
+
suggestions?: string[];
|
|
45
|
+
}
|
|
46
|
+
interface CheckReport {
|
|
47
|
+
/** How many files were read. */
|
|
48
|
+
files: number;
|
|
49
|
+
findings: Finding[];
|
|
50
|
+
summary: {
|
|
51
|
+
errors: number;
|
|
52
|
+
warnings: number;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** Check one file's source. `file` is only the name the findings carry. */
|
|
56
|
+
declare function checkSource(typescript: TypeScript, contract: Contract, file: string, text: string): Finding[];
|
|
57
|
+
/**
|
|
58
|
+
* Check every .tsx and .jsx file under the given paths. `typescript` is found in the project when
|
|
59
|
+
* it is not passed; null stands for "there is none".
|
|
60
|
+
*/
|
|
61
|
+
declare function checkPaths(paths: string[], context: {
|
|
62
|
+
cwd: string;
|
|
63
|
+
contract: Contract;
|
|
64
|
+
typescript?: TypeScript | null;
|
|
65
|
+
}): CheckReport;
|
|
66
|
+
|
|
67
|
+
interface DoctorCheck {
|
|
68
|
+
id: string;
|
|
69
|
+
status: "ok" | "warn" | "fail";
|
|
70
|
+
message: string;
|
|
71
|
+
fix?: string;
|
|
72
|
+
}
|
|
73
|
+
interface DoctorReport {
|
|
74
|
+
checks: DoctorCheck[];
|
|
75
|
+
summary: {
|
|
76
|
+
ok: number;
|
|
77
|
+
warn: number;
|
|
78
|
+
fail: number;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
declare function doctor({ cwd, contract }: {
|
|
82
|
+
cwd: string;
|
|
83
|
+
contract: Contract;
|
|
84
|
+
}): DoctorReport;
|
|
85
|
+
|
|
86
|
+
interface McpContext {
|
|
87
|
+
contract: Contract;
|
|
88
|
+
registry: Registry;
|
|
89
|
+
/** For check_code. Found beside the project or the installer when it is not passed. */
|
|
90
|
+
typescript?: TypeScript | null;
|
|
91
|
+
cwd?: string;
|
|
92
|
+
}
|
|
93
|
+
declare const TOOLS: ({
|
|
94
|
+
name: string;
|
|
95
|
+
description: string;
|
|
96
|
+
inputSchema: {
|
|
97
|
+
type: string;
|
|
98
|
+
properties: {
|
|
99
|
+
query: {
|
|
100
|
+
type: string;
|
|
101
|
+
description: string;
|
|
102
|
+
};
|
|
103
|
+
limit: {
|
|
104
|
+
type: string;
|
|
105
|
+
description: string;
|
|
106
|
+
};
|
|
107
|
+
name?: never;
|
|
108
|
+
dense?: never;
|
|
109
|
+
code?: never;
|
|
110
|
+
};
|
|
111
|
+
required: string[];
|
|
112
|
+
};
|
|
113
|
+
} | {
|
|
114
|
+
name: string;
|
|
115
|
+
description: string;
|
|
116
|
+
inputSchema: {
|
|
117
|
+
type: string;
|
|
118
|
+
properties: {
|
|
119
|
+
name: {
|
|
120
|
+
type: string;
|
|
121
|
+
description: string;
|
|
122
|
+
};
|
|
123
|
+
dense: {
|
|
124
|
+
type: string;
|
|
125
|
+
description: string;
|
|
126
|
+
};
|
|
127
|
+
query?: never;
|
|
128
|
+
limit?: never;
|
|
129
|
+
code?: never;
|
|
130
|
+
};
|
|
131
|
+
required: string[];
|
|
132
|
+
};
|
|
133
|
+
} | {
|
|
134
|
+
name: string;
|
|
135
|
+
description: string;
|
|
136
|
+
inputSchema: {
|
|
137
|
+
type: string;
|
|
138
|
+
properties: {
|
|
139
|
+
query?: never;
|
|
140
|
+
limit?: never;
|
|
141
|
+
name?: never;
|
|
142
|
+
dense?: never;
|
|
143
|
+
code?: never;
|
|
144
|
+
};
|
|
145
|
+
required?: never;
|
|
146
|
+
};
|
|
147
|
+
} | {
|
|
148
|
+
name: string;
|
|
149
|
+
description: string;
|
|
150
|
+
inputSchema: {
|
|
151
|
+
type: string;
|
|
152
|
+
properties: {
|
|
153
|
+
code: {
|
|
154
|
+
type: string;
|
|
155
|
+
description: string;
|
|
156
|
+
};
|
|
157
|
+
query?: never;
|
|
158
|
+
limit?: never;
|
|
159
|
+
name?: never;
|
|
160
|
+
dense?: never;
|
|
161
|
+
};
|
|
162
|
+
required: string[];
|
|
163
|
+
};
|
|
164
|
+
})[];
|
|
165
|
+
/**
|
|
166
|
+
* Answer one message. Returns the response to write, or null for a notification, which gets none.
|
|
167
|
+
* `raw` is a parsed message, or the line itself when it could not be parsed.
|
|
168
|
+
*/
|
|
169
|
+
declare function handleMessage(raw: unknown, context: McpContext): object | null;
|
|
170
|
+
/** Serve until the input ends: one JSON message a line in, one a line out. */
|
|
171
|
+
declare function serve(input: NodeJS.ReadableStream, output: NodeJS.WritableStream, context: McpContext): Promise<void>;
|
|
172
|
+
|
|
173
|
+
interface InitOptions {
|
|
174
|
+
agent?: string;
|
|
175
|
+
/** One file to write instead, relative to the project. */
|
|
176
|
+
path?: string;
|
|
177
|
+
/** Take the block out again. */
|
|
178
|
+
remove?: boolean;
|
|
179
|
+
dryRun?: boolean;
|
|
180
|
+
}
|
|
181
|
+
interface InitFile {
|
|
182
|
+
path: string;
|
|
183
|
+
action: "create" | "append" | "update" | "unchanged" | "remove" | "delete" | "absent";
|
|
184
|
+
}
|
|
185
|
+
interface InitResult {
|
|
186
|
+
version: string;
|
|
187
|
+
dryRun: boolean;
|
|
188
|
+
files: InitFile[];
|
|
189
|
+
}
|
|
190
|
+
declare function init(options: InitOptions, context: {
|
|
191
|
+
cwd: string;
|
|
192
|
+
contract: Contract;
|
|
193
|
+
}): InitResult;
|
|
194
|
+
|
|
195
|
+
declare const DEFAULT_OUT = "src/components/operator";
|
|
196
|
+
declare function parseArgs(args: string[]): Command;
|
|
197
|
+
|
|
198
|
+
declare function resolveEntries(names: string[], registry: Registry): RegistryEntry[];
|
|
199
|
+
|
|
200
|
+
declare const VERSION: string;
|
|
201
|
+
declare const registry: Registry;
|
|
202
|
+
/** The contract this installer carries, read from beside it the first time it is asked for. */
|
|
203
|
+
declare const contract: () => Contract;
|
|
204
|
+
|
|
205
|
+
/** Copy a fully preflighted source bundle; no package manager or network calls. */
|
|
206
|
+
declare function install(options: AddOptions, context?: {
|
|
207
|
+
cwd?: string;
|
|
208
|
+
registry?: Registry;
|
|
209
|
+
}): InstallResult;
|
|
210
|
+
|
|
211
|
+
export { AddOptions, type Answer, type CheckReport, Command, Contract, DEFAULT_OUT, type DoctorCheck, type DoctorReport, type Envelope, type Finding, type InitFile, type InitOptions, type InitResult, InstallResult, type McpContext, Registry, RegistryEntry, TOOLS, type TypeScript, VERSION, checkPaths, checkSource, contract, doctor, handleMessage, init, install, parseArgs, registry, resolveEntries, runAgentCommand, serve };
|