@dialecte/cli 0.8.3 → 0.9.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 +5 -5
- package/dist/cli.js +10004 -7211
- package/dist/lookups.d.ts +356 -1
- package/dist/lookups.js +2579 -210
- package/dist/schemas/config-yml.schema.json +3 -0
- package/package.json +5 -2
package/dist/lookups.d.ts
CHANGED
|
@@ -103,10 +103,360 @@ declare function runApi(params: {
|
|
|
103
103
|
*/
|
|
104
104
|
declare function packagesText(indexes: readonly ApiJson[]): string;
|
|
105
105
|
|
|
106
|
+
/** The host seam's constants, the same for every host. */
|
|
107
|
+
/** The names of the known host vendors: what the config key `host` is checked against (`config/` imports this, never a vendor). */
|
|
108
|
+
declare const HOST_VENDOR_NAMES: readonly ["github"];
|
|
109
|
+
/** The adapter methods a live probe may call: reads only (a probe never writes). */
|
|
110
|
+
declare const HOST_READ_METHODS: readonly ["readPullRequest", "readChecks", "readQueued", "probeStacks"];
|
|
111
|
+
|
|
112
|
+
/** A pull request on the host, as a landing reads it. */
|
|
113
|
+
type PullRequest = {
|
|
114
|
+
number: number;
|
|
115
|
+
url: string;
|
|
116
|
+
title: string;
|
|
117
|
+
/** Its description as the host holds it (the squash commit's body). */
|
|
118
|
+
body: string;
|
|
119
|
+
state: 'open' | 'merged' | 'closed';
|
|
120
|
+
draft: boolean;
|
|
121
|
+
/** True while the host merges it once its checks pass: auto-merge on, or in the merge queue. */
|
|
122
|
+
queued: boolean;
|
|
123
|
+
/** The commit its head branch pointed at (the last push). */
|
|
124
|
+
head: string;
|
|
125
|
+
/** The branch it merges into; undefined when the host did not say. */
|
|
126
|
+
base?: string;
|
|
127
|
+
/** The page of its changed files, which `lot review` prints; absent when the host gives none (its `url` is then printed). */
|
|
128
|
+
filesUrl?: string;
|
|
129
|
+
};
|
|
130
|
+
/** Whether the host links pull requests into stacks here, and why not when it does not. */
|
|
131
|
+
type StackSupport = {
|
|
132
|
+
stacks: true;
|
|
133
|
+
} | {
|
|
134
|
+
stacks: false;
|
|
135
|
+
why: string;
|
|
136
|
+
};
|
|
137
|
+
/** How the checks on a pull request's head stand: all passed, one failed, one still running, or none at all. */
|
|
138
|
+
type ChecksState = 'green' | 'failing' | 'pending' | 'none';
|
|
139
|
+
/** The checks on a pull request's head: their state and the names of the failing and the pending ones. */
|
|
140
|
+
type PullRequestChecks = {
|
|
141
|
+
/** The commit the checks ran on (the pull request's head). */
|
|
142
|
+
head: string;
|
|
143
|
+
state: ChecksState;
|
|
144
|
+
failing: string[];
|
|
145
|
+
pending: string[];
|
|
146
|
+
};
|
|
147
|
+
/** A line comment of a pull request's review: on a file, at a line when it has one; a reply names what it answers. */
|
|
148
|
+
type ReviewComment = {
|
|
149
|
+
id: number;
|
|
150
|
+
path: string;
|
|
151
|
+
line?: number;
|
|
152
|
+
body: string;
|
|
153
|
+
/** The comment this one answers in its thread; absent for a thread's first comment. */
|
|
154
|
+
replyTo?: number;
|
|
155
|
+
};
|
|
156
|
+
/** A host operation's refusal: git's or the host tool's first line. */
|
|
157
|
+
type HostRefusal = {
|
|
158
|
+
refusal: string;
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Where lots land: the one seam to the repository's host (each vendor is one adapter). Every call runs in the
|
|
162
|
+
* repository at `root`; none prompts.
|
|
163
|
+
*/
|
|
164
|
+
type HostAdapter = {
|
|
165
|
+
/** The pull request `ref` names (a number, or a branch: its newest); undefined when there is none. */
|
|
166
|
+
readPullRequest(params: {
|
|
167
|
+
root: string;
|
|
168
|
+
ref: string;
|
|
169
|
+
}): PullRequest | undefined | HostRefusal;
|
|
170
|
+
/** A new pull request of `branch` into `base`. */
|
|
171
|
+
openPullRequest(params: {
|
|
172
|
+
root: string;
|
|
173
|
+
branch: string;
|
|
174
|
+
base: string;
|
|
175
|
+
title: string;
|
|
176
|
+
body: string;
|
|
177
|
+
draft: boolean;
|
|
178
|
+
}): PullRequest | HostRefusal;
|
|
179
|
+
/** The pull request's title and body replaced by `title` and `body`. */
|
|
180
|
+
editPullRequest(params: {
|
|
181
|
+
root: string;
|
|
182
|
+
number: number;
|
|
183
|
+
title: string;
|
|
184
|
+
body: string;
|
|
185
|
+
}): HostRefusal | undefined;
|
|
186
|
+
/** The pull request closed: taken out of the merge queue, never merged. */
|
|
187
|
+
closePullRequest(params: {
|
|
188
|
+
root: string;
|
|
189
|
+
number: number;
|
|
190
|
+
}): HostRefusal | undefined;
|
|
191
|
+
/** The pull request queued: merged by the host once its checks pass (a draft made ready first). */
|
|
192
|
+
queuePullRequest(params: {
|
|
193
|
+
root: string;
|
|
194
|
+
number: number;
|
|
195
|
+
draft: boolean;
|
|
196
|
+
}): HostRefusal | undefined;
|
|
197
|
+
/**
|
|
198
|
+
* The pull request taken back out of the queue: auto-merge turned off when `queued`, made a draft when not `draft`
|
|
199
|
+
* (an approval is for one head); nothing asked when it is a draft not queued.
|
|
200
|
+
*/
|
|
201
|
+
draftPullRequest(params: {
|
|
202
|
+
root: string;
|
|
203
|
+
number: number;
|
|
204
|
+
queued: boolean;
|
|
205
|
+
draft: boolean;
|
|
206
|
+
}): HostRefusal | undefined;
|
|
207
|
+
/**
|
|
208
|
+
* Whether the host merges the pull request once its checks pass: auto-merge on, or in the merge queue (which a
|
|
209
|
+
* pull request read cannot say).
|
|
210
|
+
*/
|
|
211
|
+
readQueued(params: {
|
|
212
|
+
root: string;
|
|
213
|
+
number: number;
|
|
214
|
+
}): {
|
|
215
|
+
queued: boolean;
|
|
216
|
+
} | HostRefusal;
|
|
217
|
+
/** The checks on the pull request's head. */
|
|
218
|
+
readChecks(params: {
|
|
219
|
+
root: string;
|
|
220
|
+
number: number;
|
|
221
|
+
}): PullRequestChecks | HostRefusal;
|
|
222
|
+
/** The line comments of the pull request's reviews, oldest first. */
|
|
223
|
+
readReviewComments(params: {
|
|
224
|
+
root: string;
|
|
225
|
+
number: number;
|
|
226
|
+
}): ReviewComment[] | HostRefusal;
|
|
227
|
+
/** The pull request's changed files opened in the browser (`url` is the pull request's page). */
|
|
228
|
+
openFiles(params: {
|
|
229
|
+
root: string;
|
|
230
|
+
url: string;
|
|
231
|
+
}): HostRefusal | undefined;
|
|
232
|
+
/** Whether the host links pull requests into stacks here (33CI CI4); no network asked. */
|
|
233
|
+
probeStacks(params: {
|
|
234
|
+
root: string;
|
|
235
|
+
}): StackSupport;
|
|
236
|
+
/** The pull request at `child` (its url) linked on top of the one at `parent` as a stack. */
|
|
237
|
+
linkStack(params: {
|
|
238
|
+
root: string;
|
|
239
|
+
parent: string;
|
|
240
|
+
child: string;
|
|
241
|
+
}): HostRefusal | undefined;
|
|
242
|
+
/**
|
|
243
|
+
* The stack queued up to and including `number`, all or nothing (never auto-merge: refused for a stack); a draft made
|
|
244
|
+
* ready first.
|
|
245
|
+
*/
|
|
246
|
+
queueStack(params: {
|
|
247
|
+
root: string;
|
|
248
|
+
number: number;
|
|
249
|
+
draft: boolean;
|
|
250
|
+
}): HostRefusal | undefined;
|
|
251
|
+
/** The pull request's base branch changed to `base`. */
|
|
252
|
+
retargetPullRequest(params: {
|
|
253
|
+
root: string;
|
|
254
|
+
number: number;
|
|
255
|
+
base: string;
|
|
256
|
+
}): HostRefusal | undefined;
|
|
257
|
+
};
|
|
258
|
+
/** The adapter as a probe sees it: only the methods the probes use, all reads, so a probe cannot write. */
|
|
259
|
+
type HostReadAdapter = Pick<HostAdapter, (typeof HOST_READ_METHODS)[number]>;
|
|
260
|
+
/** Whether a host call only reads (short timeout, probed live) or writes (long timeout, never live). */
|
|
261
|
+
type HostCallKind = 'read' | 'write';
|
|
262
|
+
/** One call of a host's tool, declared once: the table the argv and the contract check both read. */
|
|
263
|
+
type HostCallSpec = {
|
|
264
|
+
/** The command path: `['pr', 'view']`, `['api']`, `['stack', 'merge']`. */
|
|
265
|
+
words: readonly string[];
|
|
266
|
+
/** Every flag a call site may pass; never the implied ones (`--json`, `-f`, `--jq`), which come from the spec. */
|
|
267
|
+
flags: readonly string[];
|
|
268
|
+
kind: HostCallKind;
|
|
269
|
+
/** The fields the tool is asked for, passed by the runner itself. */
|
|
270
|
+
fields?: readonly string[];
|
|
271
|
+
/** The GraphQL query, passed by the runner itself (the entry's endpoint is then `graphql`). */
|
|
272
|
+
graphql?: string;
|
|
273
|
+
/** The output filter, passed by the runner itself, so a probe sends the adapter's exact argv. */
|
|
274
|
+
filter?: string;
|
|
275
|
+
/** The REST path template; each `{x}` given in `values` is filled, the rest is left to the tool. */
|
|
276
|
+
endpoint?: string;
|
|
277
|
+
};
|
|
278
|
+
/** A host's calls by name. */
|
|
279
|
+
type HostCallTable = Record<string, HostCallSpec>;
|
|
280
|
+
/** The names of the table's read calls. */
|
|
281
|
+
type ReadCallOf<Calls extends HostCallTable> = {
|
|
282
|
+
[K in keyof Calls]: Calls[K]['kind'] extends 'read' ? K : never;
|
|
283
|
+
}[keyof Calls];
|
|
284
|
+
/** The name of a known host vendor. */
|
|
285
|
+
type HostVendorName = (typeof HOST_VENDOR_NAMES)[number];
|
|
286
|
+
/** A host vendor's runtime record: how a repository is recognised as its, and the adapter that serves it. */
|
|
287
|
+
type HostVendor<Calls extends HostCallTable, Subject extends keyof Calls> = {
|
|
288
|
+
name: HostVendorName;
|
|
289
|
+
/** The cli the vendor's adapter runs (`gh`). */
|
|
290
|
+
tool: string;
|
|
291
|
+
/** The hosts of an origin that mean this vendor (lower-case). */
|
|
292
|
+
remoteHosts: readonly string[];
|
|
293
|
+
/** The calls the adapter makes, by name. */
|
|
294
|
+
calls: Calls;
|
|
295
|
+
/** The versions of the tool the record was taken from, by part (the keys `describe.versionOf` takes). */
|
|
296
|
+
recordedVersions: Readonly<Record<string, string>>;
|
|
297
|
+
/** The read that finds the pull request the other probes read, and its probe. */
|
|
298
|
+
subject: {
|
|
299
|
+
call: Calls[Subject]['kind'] extends 'write' ? never : Subject;
|
|
300
|
+
find: HostSubjectProbe<Calls>;
|
|
301
|
+
};
|
|
302
|
+
/** One live probe per other read call; a read without one does not compile. */
|
|
303
|
+
probes: Record<Exclude<ReadCallOf<Calls>, Subject>, HostProbe<Calls>>;
|
|
304
|
+
createAdapter(): HostAdapter;
|
|
305
|
+
};
|
|
306
|
+
/** What a vendor's live probes are run with: its tool's runner and the reads of what the tool describes of itself. */
|
|
307
|
+
type HostVendorSeams = {
|
|
308
|
+
/** The runner of the vendor's tool, for the probe-only reads. */
|
|
309
|
+
run: HostToolRun;
|
|
310
|
+
describe: HostDescribe;
|
|
311
|
+
};
|
|
312
|
+
/**
|
|
313
|
+
* A tool run with its call table erased (any call name), written out rather than as `HostToolRun<HostCallTable>`: a
|
|
314
|
+
* vendor's run, typed by its own table, is compared with it structurally.
|
|
315
|
+
*/
|
|
316
|
+
type HostErasedToolRun = {
|
|
317
|
+
bivarianceHack(params: HostToolCall<string>): {
|
|
318
|
+
output: string;
|
|
319
|
+
} | HostRefusal;
|
|
320
|
+
}['bivarianceHack'];
|
|
321
|
+
/** The probes of a vendor whose call table is erased: the same shapes, run by any call name. */
|
|
322
|
+
type HostErasedProbes = {
|
|
323
|
+
find(params: {
|
|
324
|
+
root: string;
|
|
325
|
+
host: HostReadAdapter;
|
|
326
|
+
run: HostErasedToolRun;
|
|
327
|
+
subject: string;
|
|
328
|
+
}): ReturnType<HostSubjectProbe>;
|
|
329
|
+
probe(params: {
|
|
330
|
+
root: string;
|
|
331
|
+
host: HostReadAdapter;
|
|
332
|
+
run: HostErasedToolRun;
|
|
333
|
+
subject: string;
|
|
334
|
+
pullRequest?: number;
|
|
335
|
+
}): HostLine;
|
|
336
|
+
};
|
|
337
|
+
/** A vendor with its call table erased, and what its probes run with: the element of the one list of vendors. */
|
|
338
|
+
type HostVendorRecord = Omit<HostVendor<HostCallTable, string>, 'subject' | 'probes'> & {
|
|
339
|
+
subject: {
|
|
340
|
+
call: string;
|
|
341
|
+
find: HostErasedProbes['find'];
|
|
342
|
+
};
|
|
343
|
+
probes: Readonly<Record<string, HostErasedProbes['probe']>>;
|
|
344
|
+
} & HostVendorSeams;
|
|
345
|
+
/** A flag's short and long forms, as a tool's help prints them together (`-q, --jq`). */
|
|
346
|
+
type HostFlagAlias = {
|
|
347
|
+
short: string;
|
|
348
|
+
long: string;
|
|
349
|
+
};
|
|
350
|
+
/** One field of a GraphQL type: the name of its type, unwrapped, and the names of its arguments. */
|
|
351
|
+
type HostGraphqlField = {
|
|
352
|
+
type: string;
|
|
353
|
+
args: readonly string[];
|
|
354
|
+
};
|
|
355
|
+
/** One answer of the tool's description: the bytes it printed, kept as they are, and what was read out of them. */
|
|
356
|
+
type HostAnswer<Parsed> = {
|
|
357
|
+
raw: string;
|
|
358
|
+
} & Parsed;
|
|
359
|
+
/** A part of the tool that is not installed (an extension): the name it installs under, and the tool's own line. */
|
|
360
|
+
type HostAbsentPart = HostRefusal & {
|
|
361
|
+
absent: string;
|
|
362
|
+
};
|
|
363
|
+
/** The closed reads of what a tool describes of itself; each runs in the repository at `root`. */
|
|
364
|
+
type HostDescribe = {
|
|
365
|
+
/** The command's help: its flags, short and long, and the alias pairs. */
|
|
366
|
+
helpOf(params: {
|
|
367
|
+
root: string;
|
|
368
|
+
words: readonly string[];
|
|
369
|
+
}): HostAnswer<{
|
|
370
|
+
flags: string[];
|
|
371
|
+
aliases: HostFlagAlias[];
|
|
372
|
+
}> | HostRefusal;
|
|
373
|
+
/** The fields the command lists (absent for a tool that lists none). */
|
|
374
|
+
fieldsOf?(params: {
|
|
375
|
+
root: string;
|
|
376
|
+
words: readonly string[];
|
|
377
|
+
}): HostAnswer<{
|
|
378
|
+
fields: string[];
|
|
379
|
+
}> | HostRefusal;
|
|
380
|
+
/** One GraphQL type: its fields. */
|
|
381
|
+
typeOf(params: {
|
|
382
|
+
root: string;
|
|
383
|
+
name: string;
|
|
384
|
+
}): HostAnswer<{
|
|
385
|
+
fields: Record<string, HostGraphqlField>;
|
|
386
|
+
}> | HostRefusal;
|
|
387
|
+
/**
|
|
388
|
+
* The version of one of the tool's parts (`selector`: a key of the record's versions; a part other than the tool
|
|
389
|
+
* itself is the first word of its commands); absent when that part is not installed.
|
|
390
|
+
*/
|
|
391
|
+
versionOf(params: {
|
|
392
|
+
root: string;
|
|
393
|
+
selector: string;
|
|
394
|
+
}): HostAnswer<{
|
|
395
|
+
version: string;
|
|
396
|
+
}> | HostAbsentPart | HostRefusal;
|
|
397
|
+
};
|
|
398
|
+
/**
|
|
399
|
+
* One line of the host check: what was probed, what was found, and the command that fixes it (only on a warning or an
|
|
400
|
+
* error). `doctor` re-exports it as `DoctorLine`.
|
|
401
|
+
*/
|
|
402
|
+
type HostLine = {
|
|
403
|
+
status: 'ok' | 'warning' | 'error';
|
|
404
|
+
subject: string;
|
|
405
|
+
detail: string;
|
|
406
|
+
fix?: string;
|
|
407
|
+
};
|
|
408
|
+
/** One call of a vendor's tool for a probe-only read: `call` names an entry of its table. */
|
|
409
|
+
type HostToolCall<Call extends string> = {
|
|
410
|
+
root: string;
|
|
411
|
+
call: Call;
|
|
412
|
+
positional?: readonly string[];
|
|
413
|
+
options?: Readonly<Record<string, string | true | readonly string[] | undefined>>;
|
|
414
|
+
values?: Readonly<Record<string, string>>;
|
|
415
|
+
input?: string;
|
|
416
|
+
};
|
|
417
|
+
/** The seam a vendor's tool is called through for a probe-only read: one read call of its table, by name. */
|
|
418
|
+
type HostToolRun<Calls extends HostCallTable = HostCallTable> = {
|
|
419
|
+
/** The read calls of the vendor's table (any name when the table is erased). */
|
|
420
|
+
bivarianceHack(params: HostToolCall<HostCallTable extends Calls ? string : Extract<ReadCallOf<Calls>, string>>): {
|
|
421
|
+
output: string;
|
|
422
|
+
} | HostRefusal;
|
|
423
|
+
}['bivarianceHack'];
|
|
424
|
+
/**
|
|
425
|
+
* One live probe of a read call: its line, whose subject is `subject` (the probe's key in the vendor's table);
|
|
426
|
+
* `pullRequest` is the one the vendor's subject probe found, when it did.
|
|
427
|
+
*/
|
|
428
|
+
type HostProbe<Calls extends HostCallTable = HostCallTable> = (params: {
|
|
429
|
+
root: string;
|
|
430
|
+
host: HostReadAdapter;
|
|
431
|
+
run: HostToolRun<Calls>;
|
|
432
|
+
subject: string;
|
|
433
|
+
pullRequest?: number;
|
|
434
|
+
}) => HostLine;
|
|
435
|
+
/**
|
|
436
|
+
* The probe of the read that finds the pull request the other probes read: its line (its subject `subject`, the
|
|
437
|
+
* read's name), and the pull request found.
|
|
438
|
+
*/
|
|
439
|
+
type HostSubjectProbe<Calls extends HostCallTable = HostCallTable> = (params: {
|
|
440
|
+
root: string;
|
|
441
|
+
host: HostReadAdapter;
|
|
442
|
+
run: HostToolRun<Calls>;
|
|
443
|
+
subject: string;
|
|
444
|
+
}) => {
|
|
445
|
+
line: HostLine;
|
|
446
|
+
pullRequest?: number;
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* One line of `dialecte doctor`: what was checked, what was found, and the one command that fixes it. `error`: the
|
|
451
|
+
* package.json holds a value no command accepts (a profile that is none).
|
|
452
|
+
*/
|
|
453
|
+
type DoctorLine = HostLine;
|
|
454
|
+
|
|
106
455
|
/**
|
|
107
456
|
* What `dialecte doctor` prints for `argv` run in `cwd`: each check of the installed `@dialecte/*` packages, their
|
|
108
457
|
* skills, the local checkouts (`dialecteRoot`) and the cli, ✅, ⚠️ or ❌ with the command that fixes it, exit 1 when a
|
|
109
|
-
* check is not ok; with `--brief`, one line per problem, nothing when in sync, always exit 0
|
|
458
|
+
* check is not ok; with `--brief`, one line per problem, nothing when in sync, always exit 0; with `--host`, only the
|
|
459
|
+
* host lines, exit 1 on an error only.
|
|
110
460
|
*
|
|
111
461
|
* @intent check a Dialecte install without the command line, tell whether the installed packages and their skills are in sync
|
|
112
462
|
*/
|
|
@@ -116,6 +466,11 @@ declare function runDoctor(params: {
|
|
|
116
466
|
dialecteRoot: string | undefined;
|
|
117
467
|
/** The cli's version, or how to read it: `--brief` reads it inside its guard, so a failure never shows. */
|
|
118
468
|
cliVersion: string | (() => string);
|
|
469
|
+
/** The host check of `--host` (the vendor of the folder, or the one `--vendor` names); default: the real one. */
|
|
470
|
+
hostLines?: (params: {
|
|
471
|
+
root: string;
|
|
472
|
+
vendor: HostVendorRecord;
|
|
473
|
+
}) => DoctorLine[];
|
|
119
474
|
}): LookupCommandOutput;
|
|
120
475
|
|
|
121
476
|
/** One public method of the q / tx / doc / project surface, with what its JSDoc says about it. */
|