@osdlc/wayfinder 0.9.0 → 0.11.1
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/CHANGELOG.md +74 -0
- package/CONTRIBUTING.md +6 -1
- package/README.md +9 -4
- package/dist/args.d.ts +7 -8
- package/dist/args.js +7 -8
- package/dist/catalog.d.ts +13 -4
- package/dist/catalog.js +16 -8
- package/dist/clean-command.d.ts +3 -1
- package/dist/clean-command.js +23 -11
- package/dist/cli.js +3 -3
- package/dist/commands/index.js +1 -1
- package/dist/commands/list.d.ts +5 -2
- package/dist/commands/list.js +28 -3
- package/dist/commands/query.js +1 -1
- package/dist/commands/run.js +1 -1
- package/dist/commands/shared.js +2 -1
- package/dist/config-keys.d.ts +4 -0
- package/dist/config-keys.js +4 -0
- package/dist/config.d.ts +24 -10
- package/dist/config.js +64 -19
- package/dist/core/run.d.ts +2 -1
- package/dist/core/run.js +10 -2
- package/dist/core/saved-view.d.ts +2 -7
- package/dist/core/saved-view.js +5 -12
- package/dist/core/session.d.ts +7 -1
- package/dist/core/session.js +59 -22
- package/dist/core/writes.d.ts +13 -0
- package/dist/core/writes.js +22 -0
- package/dist/document-schemas.generated.js +6 -0
- package/dist/documents.d.ts +15 -2
- package/dist/documents.js +23 -14
- package/dist/guide.js +2 -2
- package/dist/index.js +2 -2
- package/dist/providers-command.d.ts +2 -2
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +1 -1
- package/dist/serve/auth.js +3 -16
- package/dist/serve/routes.d.ts +1 -1
- package/dist/serve/routes.js +1 -26
- package/dist/terminal-text.d.ts +4 -4
- package/dist/terminal-text.js +17 -12
- package/dist/tool-info.d.ts +2 -2
- package/dist/tools.js +1 -1
- package/dist/tui/app.js +24 -0
- package/dist/tui/index.js +3 -3
- package/dist/vocabulary.d.ts +5 -1
- package/dist/vocabulary.js +3 -1
- package/dist/web/main.js +67 -34
- package/dist/xdg.d.ts +0 -7
- package/dist/xdg.js +0 -14
- package/package.json +15 -13
- package/schema/config.json +14 -1
package/dist/documents.js
CHANGED
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
* The JSON documents wayfinder prints, as Zod schemas. Each command declares
|
|
3
3
|
* one as its output; `schema.ts` turns them into the JSON Schemas the
|
|
4
4
|
* `./schema` entry exports. The task and report shapes come from
|
|
5
|
-
* `@osdlc/system-model/schema`, so
|
|
5
|
+
* `@osdlc/system-model/schema`, and so do the values of every enum that names
|
|
6
|
+
* a system-model value, so they cannot drift from the library.
|
|
6
7
|
*/
|
|
7
8
|
import { z } from 'zod';
|
|
8
|
-
import {
|
|
9
|
+
import { ALL_GROUP_IDS } from '@osdlc/system-model/groups';
|
|
10
|
+
import { ALL_MATCH_MODES } from '@osdlc/system-model/match';
|
|
11
|
+
import { ALL_CACHE_STATES, ALL_PARAMETERS_UNKNOWN_REASONS, ALL_PROBE_COSTS, ALL_PROVIDER_KINDS, ALL_ROLE_NAMES, ALL_STALE_REASONS, CATALOG_SCHEMA_VERSION, catalogSchema, runnerReportSchema, taskSchema, } from '@osdlc/system-model/schema';
|
|
12
|
+
import { ALL_WITHHELD_REASONS } from "./vocabulary.js";
|
|
9
13
|
/** A schema embedded in another one: without its own `$schema`. */
|
|
10
14
|
function embedded(schema) {
|
|
11
15
|
const { $schema: _, ...rest } = schema;
|
|
@@ -20,7 +24,7 @@ export const RunnerReportZ = embedded(runnerReportSchema);
|
|
|
20
24
|
export const CatalogZ = embedded(catalogSchema);
|
|
21
25
|
/** One row group and the runners in it. */
|
|
22
26
|
export const GroupZ = z.object({
|
|
23
|
-
id: z.enum([
|
|
27
|
+
id: z.enum([...ALL_GROUP_IDS, 'skills']),
|
|
24
28
|
title: z.string(),
|
|
25
29
|
runners: z.array(z.string()).describe('The runners whose reports fill it. Empty for skills.'),
|
|
26
30
|
});
|
|
@@ -39,12 +43,12 @@ export const SkillZ = z.object({
|
|
|
39
43
|
/** One runner's cache verdict. */
|
|
40
44
|
export const CacheStateZ = z.object({
|
|
41
45
|
runner: z.string(),
|
|
42
|
-
state: z.enum(
|
|
43
|
-
reason: z.enum(
|
|
46
|
+
state: z.enum(ALL_CACHE_STATES),
|
|
47
|
+
reason: z.enum(ALL_STALE_REASONS).optional(),
|
|
44
48
|
ageMs: z.number().optional().describe('Age of the stored probe. 0 when probed just now.'),
|
|
45
49
|
estimateMs: z.number().nullable().describe('Expected refresh time. Null when never measured.'),
|
|
46
50
|
slow: z.boolean(),
|
|
47
|
-
cost: z.enum(
|
|
51
|
+
cost: z.enum(ALL_PROBE_COSTS).optional(),
|
|
48
52
|
probeMs: z.number().optional().describe('How long the probe took, when it ran in this call.'),
|
|
49
53
|
});
|
|
50
54
|
/** One thing wayfinder could not know, with the label every surface shows. */
|
|
@@ -52,7 +56,7 @@ export const UnknownZ = z.discriminatedUnion('kind', [
|
|
|
52
56
|
z.object({
|
|
53
57
|
kind: z.literal('withheld'),
|
|
54
58
|
runner: z.string(),
|
|
55
|
-
reason: z.enum(
|
|
59
|
+
reason: z.enum(ALL_WITHHELD_REASONS),
|
|
56
60
|
missing: z
|
|
57
61
|
.array(z.string())
|
|
58
62
|
.optional()
|
|
@@ -62,14 +66,14 @@ export const UnknownZ = z.discriminatedUnion('kind', [
|
|
|
62
66
|
z.object({
|
|
63
67
|
kind: z.literal('parameters'),
|
|
64
68
|
runner: z.string(),
|
|
65
|
-
reason: z.enum(
|
|
69
|
+
reason: z.enum(ALL_PARAMETERS_UNKNOWN_REASONS),
|
|
66
70
|
tasks: z.array(z.string()),
|
|
67
71
|
label: z.string(),
|
|
68
72
|
}),
|
|
69
73
|
z.object({
|
|
70
74
|
kind: z.literal('stale'),
|
|
71
75
|
runner: z.string(),
|
|
72
|
-
reason: z.enum(
|
|
76
|
+
reason: z.enum(ALL_STALE_REASONS).optional(),
|
|
73
77
|
ageMs: z.number().optional(),
|
|
74
78
|
label: z.string(),
|
|
75
79
|
}),
|
|
@@ -83,7 +87,7 @@ export const UnknownZ = z.discriminatedUnion('kind', [
|
|
|
83
87
|
/** The filter a listing applied. Absent fields were not given. */
|
|
84
88
|
export const FilterZ = z.object({
|
|
85
89
|
query: z.string().optional(),
|
|
86
|
-
mode: z.enum(
|
|
90
|
+
mode: z.enum(ALL_MATCH_MODES).optional(),
|
|
87
91
|
servicesOnly: z.boolean().optional(),
|
|
88
92
|
declaredOnly: z.boolean().optional(),
|
|
89
93
|
maxDepth: z.number().int().optional(),
|
|
@@ -115,12 +119,13 @@ export const CatalogOutput = z.object({
|
|
|
115
119
|
});
|
|
116
120
|
/**
|
|
117
121
|
* One line `list --progress` sends while it probes, before the catalog
|
|
118
|
-
* document: which runners have not answered, and the one that just did
|
|
122
|
+
* document: which runners have not answered, and the one that just did or
|
|
123
|
+
* the agent skills.
|
|
119
124
|
*/
|
|
120
125
|
export const CatalogProgressOutput = z.object({
|
|
121
126
|
pending: z.array(z.string()).describe('The runners that have not answered yet, in report order.'),
|
|
122
127
|
total: z.number().int().describe('How many runners the probe reports.'),
|
|
123
|
-
report: RunnerReportZ.optional().describe('The runner that answered. Absent on the first line, which only names the runners, and when omitted is set.'),
|
|
128
|
+
report: RunnerReportZ.optional().describe('The runner that answered. Absent on the first line, which only names the runners, on the skills line, and when omitted is set.'),
|
|
124
129
|
omitted: z
|
|
125
130
|
.string()
|
|
126
131
|
.optional()
|
|
@@ -130,6 +135,10 @@ export const CatalogProgressOutput = z.object({
|
|
|
130
135
|
.array(UnknownZ)
|
|
131
136
|
.optional()
|
|
132
137
|
.describe('What could not be read about the answered runner.'),
|
|
138
|
+
skills: z
|
|
139
|
+
.array(SkillZ)
|
|
140
|
+
.optional()
|
|
141
|
+
.describe('The agent skills, on a line of their own once they are read, filtered like the document. No line when there are none or they are too large for one; they come with the catalog document.'),
|
|
133
142
|
});
|
|
134
143
|
/** The catalog document's `schemaVersion`: the catalog's own. */
|
|
135
144
|
export const CATALOG_DOCUMENT_VERSION = CATALOG_SCHEMA_VERSION;
|
|
@@ -152,8 +161,8 @@ export const QueryOutput = z.object({
|
|
|
152
161
|
/** One registered tool. */
|
|
153
162
|
export const ProviderZ = z.object({
|
|
154
163
|
id: z.string(),
|
|
155
|
-
roles: z.array(z.enum(
|
|
156
|
-
kind: z.enum(
|
|
164
|
+
roles: z.array(z.enum(ALL_ROLE_NAMES)),
|
|
165
|
+
kind: z.enum(ALL_PROVIDER_KINDS).nullable().describe("The runner role's kind; null with none."),
|
|
157
166
|
binary: z.string().nullable(),
|
|
158
167
|
onPath: z.boolean().nullable().describe('Whether binary is on the PATH; null with no binary.'),
|
|
159
168
|
source: z.enum(['built-in', 'custom']),
|
package/dist/guide.js
CHANGED
|
@@ -279,8 +279,8 @@ stored answers and a \`binary\` not on the PATH.
|
|
|
279
279
|
|
|
280
280
|
A cached \`generatedAt\` is the OLDEST contributing probe time.
|
|
281
281
|
|
|
282
|
-
|
|
283
|
-
the
|
|
282
|
+
A trust grant would help when \`unknowns\` holds a \`withheld\` entry with
|
|
283
|
+
reason \`untrusted\` or \`tool-untrusted\` (the web page works this out itself).
|
|
284
284
|
|
|
285
285
|
Trimmed example:
|
|
286
286
|
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* change them, and the changelog says how.
|
|
13
13
|
*/
|
|
14
14
|
import { catalogDocument } from "./commands/list.js";
|
|
15
|
-
import {
|
|
15
|
+
import { flushWrites } from "./core/writes.js";
|
|
16
16
|
import { createSession, } from "./core/session.js";
|
|
17
17
|
import { CATALOG_DOCUMENT_VERSION } from "./documents.js";
|
|
18
18
|
export { SessionError, } from "./core/session.js";
|
|
@@ -55,7 +55,7 @@ export async function buildCatalog(options) {
|
|
|
55
55
|
progress: options.progress,
|
|
56
56
|
});
|
|
57
57
|
// A library caller gets a call whose writes are done.
|
|
58
|
-
await
|
|
58
|
+
await flushWrites();
|
|
59
59
|
const body = catalogDocument(snapshot, session.unknowns(snapshot), options.filter ?? {}, session.settings().trustedTools);
|
|
60
60
|
return { schemaVersion: CATALOG_DOCUMENT_VERSION, kind: 'catalog', ...body };
|
|
61
61
|
}
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
* with its roles, its runner kind, its binary and whether that binary is on
|
|
4
4
|
* an absolute PATH entry. Reads files only; runs nothing.
|
|
5
5
|
*/
|
|
6
|
-
import type { RoleName, ToolDef } from '@osdlc/system-model/detect';
|
|
6
|
+
import type { ProviderKind, RoleName, ToolDef } from '@osdlc/system-model/detect';
|
|
7
7
|
import type { LoadedTool } from './tools.ts';
|
|
8
8
|
/** One row of the listing, as `--json` prints it in `providers`. */
|
|
9
9
|
export interface ProviderRow {
|
|
10
10
|
id: string;
|
|
11
11
|
roles: RoleName[];
|
|
12
12
|
/** The runner role's kind; null for a tool with no runner. */
|
|
13
|
-
kind:
|
|
13
|
+
kind: ProviderKind | null;
|
|
14
14
|
binary: string | null;
|
|
15
15
|
/** Whether `binary` is on the PATH; null when the tool names none. */
|
|
16
16
|
onPath: boolean | null;
|
package/dist/schema.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ export declare const providersDocumentSchema: JsonSchema;
|
|
|
42
42
|
export declare const runDocumentSchema: JsonSchema;
|
|
43
43
|
/** `way trust --json`: what a grant, a removal, `--show` or `--list` found. */
|
|
44
44
|
export declare const trustDocumentSchema: JsonSchema;
|
|
45
|
-
/** `way clean --json`: what was removed,
|
|
45
|
+
/** `way clean --json`: with a store flag what was removed (`mode: "remove"`), with none a report of every store (`mode: "report"`). */
|
|
46
46
|
export declare const cleanDocumentSchema: JsonSchema;
|
|
47
47
|
/** Every document schema, by `kind`. */
|
|
48
48
|
export declare const DOCUMENT_SCHEMAS: Readonly<Record<DocumentKind, JsonSchema>>;
|
package/dist/schema.js
CHANGED
|
@@ -55,7 +55,7 @@ export const providersDocumentSchema = jsonSchema('providers');
|
|
|
55
55
|
export const runDocumentSchema = jsonSchema('run');
|
|
56
56
|
/** `way trust --json`: what a grant, a removal, `--show` or `--list` found. */
|
|
57
57
|
export const trustDocumentSchema = jsonSchema('trust');
|
|
58
|
-
/** `way clean --json`: what was removed,
|
|
58
|
+
/** `way clean --json`: with a store flag what was removed (`mode: "remove"`), with none a report of every store (`mode: "report"`). */
|
|
59
59
|
export const cleanDocumentSchema = jsonSchema('clean');
|
|
60
60
|
/** Every document schema, by `kind`. */
|
|
61
61
|
export const DOCUMENT_SCHEMAS = Object.fromEntries(DOCUMENT_KINDS.map((kind) => [kind, jsonSchema(kind)]));
|
package/dist/serve/auth.js
CHANGED
|
@@ -21,29 +21,16 @@
|
|
|
21
21
|
* A JSON body from another origin needs a CORS preflight, which the server
|
|
22
22
|
* never answers, so a website cannot redeem the boot token either.
|
|
23
23
|
*/
|
|
24
|
+
import { newToken, tokenEquals } from '@osdlc/cli-tool/http';
|
|
24
25
|
/** How long the boot token stays usable once the URL is shown. */
|
|
25
26
|
const BOOT_TTL_MS = 60_000;
|
|
26
|
-
/** 128 bits, hex, from a secure source. */
|
|
27
|
-
function secret() {
|
|
28
|
-
const bytes = globalThis.crypto.getRandomValues(new Uint8Array(16));
|
|
29
|
-
return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
|
|
30
|
-
}
|
|
31
|
-
/** Compared without an early exit, so a near miss takes as long as a far one. */
|
|
32
|
-
function tokenEquals(a, b) {
|
|
33
|
-
if (a.length !== b.length)
|
|
34
|
-
return false;
|
|
35
|
-
let diff = 0;
|
|
36
|
-
for (let i = 0; i < a.length; i++)
|
|
37
|
-
diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
|
|
38
|
-
return diff === 0;
|
|
39
|
-
}
|
|
40
27
|
/**
|
|
41
28
|
* Make a boot token. `now` is injectable for tests. `onReplay` is called when
|
|
42
29
|
* the right boot token arrives after it was redeemed: a second tab, or
|
|
43
30
|
* another program that read the link.
|
|
44
31
|
*/
|
|
45
32
|
export function createSignIn(now = Date.now, onReplay) {
|
|
46
|
-
let bootToken =
|
|
33
|
+
let bootToken = newToken();
|
|
47
34
|
let live = true;
|
|
48
35
|
let redeemed = false;
|
|
49
36
|
let expiresAt = Number.POSITIVE_INFINITY;
|
|
@@ -72,7 +59,7 @@ export function createSignIn(now = Date.now, onReplay) {
|
|
|
72
59
|
return true;
|
|
73
60
|
},
|
|
74
61
|
renew() {
|
|
75
|
-
bootToken =
|
|
62
|
+
bootToken = newToken();
|
|
76
63
|
live = true;
|
|
77
64
|
redeemed = false;
|
|
78
65
|
expiresAt = now() + BOOT_TTL_MS;
|
package/dist/serve/routes.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*
|
|
17
17
|
* Every route passes the adapter's Host and Origin checks first.
|
|
18
18
|
*/
|
|
19
|
-
import type
|
|
19
|
+
import { type HttpApi } from '@osdlc/cli-tool/http';
|
|
20
20
|
import type { SignIn } from './auth.ts';
|
|
21
21
|
/**
|
|
22
22
|
* The page's content security policy. Only the page's own script runs, and
|
package/dist/serve/routes.js
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* Every route passes the adapter's Host and Origin checks first.
|
|
18
18
|
*/
|
|
19
19
|
import { randomBytes } from 'node:crypto';
|
|
20
|
+
import { readBody } from '@osdlc/cli-tool/http';
|
|
20
21
|
const HEADERS = {
|
|
21
22
|
'cache-control': 'no-store',
|
|
22
23
|
'x-content-type-options': 'nosniff',
|
|
@@ -49,32 +50,6 @@ function text(body, status, extra = {}) {
|
|
|
49
50
|
headers: { ...HEADERS, 'content-type': 'text/plain; charset=utf-8', ...extra },
|
|
50
51
|
});
|
|
51
52
|
}
|
|
52
|
-
/**
|
|
53
|
-
* At most `max` bytes of `request`'s body, or null when it is larger. Read as
|
|
54
|
-
* a stream and given up past `max`: `/session` needs no token, so a chunked
|
|
55
|
-
* body of any size must not be buffered first.
|
|
56
|
-
*/
|
|
57
|
-
async function readBody(request, max) {
|
|
58
|
-
if (Number(request.headers.get('content-length') ?? '0') > max)
|
|
59
|
-
return null;
|
|
60
|
-
if (request.body === null)
|
|
61
|
-
return '';
|
|
62
|
-
const reader = request.body.getReader();
|
|
63
|
-
const chunks = [];
|
|
64
|
-
let size = 0;
|
|
65
|
-
for (;;) {
|
|
66
|
-
const { done, value } = await reader.read();
|
|
67
|
-
if (done)
|
|
68
|
-
break;
|
|
69
|
-
size += value.byteLength;
|
|
70
|
-
if (size > max) {
|
|
71
|
-
void reader.cancel().catch(() => { });
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
chunks.push(value);
|
|
75
|
-
}
|
|
76
|
-
return new TextDecoder().decode(Buffer.concat(chunks));
|
|
77
|
-
}
|
|
78
53
|
/** The JSON body of `request`, or a Response refusing it. */
|
|
79
54
|
async function readJson(request) {
|
|
80
55
|
if (!/^application\/json\b/i.test(request.headers.get('content-type') ?? '')) {
|
package/dist/terminal-text.d.ts
CHANGED
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
* a match offset into it still points at the same character.
|
|
16
16
|
*
|
|
17
17
|
* This is wayfinder's one filter for repository text. `stripControls` from
|
|
18
|
-
* `@osdlc/ux`
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
18
|
+
* `@osdlc/ux` removes the controls, and whole escape sequences with them.
|
|
19
|
+
* That changes the length, so the terminal UI's match highlights would point
|
|
20
|
+
* at the wrong characters, and a person would not see that the name held
|
|
21
|
+
* anything. The set of control characters is ux's own, from `controlPattern`.
|
|
22
22
|
*/
|
|
23
23
|
import { type CliIo } from '@osdlc/cli-tool';
|
|
24
24
|
/**
|
package/dist/terminal-text.js
CHANGED
|
@@ -15,24 +15,21 @@
|
|
|
15
15
|
* a match offset into it still points at the same character.
|
|
16
16
|
*
|
|
17
17
|
* This is wayfinder's one filter for repository text. `stripControls` from
|
|
18
|
-
* `@osdlc/ux`
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
18
|
+
* `@osdlc/ux` removes the controls, and whole escape sequences with them.
|
|
19
|
+
* That changes the length, so the terminal UI's match highlights would point
|
|
20
|
+
* at the wrong characters, and a person would not see that the name held
|
|
21
|
+
* anything. The set of control characters is ux's own, from `controlPattern`.
|
|
22
22
|
*/
|
|
23
23
|
import { EXIT } from '@osdlc/cli-tool';
|
|
24
|
+
import { controlPattern } from '@osdlc/ux';
|
|
24
25
|
import { BIN } from "./app.js";
|
|
25
26
|
/**
|
|
26
27
|
* C0 (tab and newline included), DEL, C1, and the bidi controls: the marks
|
|
27
28
|
* U+061C, U+200E and U+200F, and U+202A-202E and U+2066-2069.
|
|
28
29
|
*/
|
|
29
|
-
const CONTROL =
|
|
30
|
+
const CONTROL = controlPattern();
|
|
30
31
|
/** The same, but tab and newline are kept. */
|
|
31
|
-
const CONTROL_KEEP_LINES =
|
|
32
|
-
/** C0 without tab and newline. */
|
|
33
|
-
const C0_KEEP_LINES = /[\u0000-\u0008\u000b-\u001f]/g;
|
|
34
|
-
/** What `JSON.stringify` leaves raw of the above: it escapes C0 itself. */
|
|
35
|
-
const JSON_RAW = /[\u007f-\u009f\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/g;
|
|
32
|
+
const CONTROL_KEEP_LINES = controlPattern({ newline: true, tab: true });
|
|
36
33
|
const REPLACEMENT = '�';
|
|
37
34
|
/**
|
|
38
35
|
* `text` with every C0 control character (ESC included), DEL, C1 control
|
|
@@ -55,8 +52,16 @@ export function jsonText(value, indent) {
|
|
|
55
52
|
const json = JSON.stringify(value, null, indent);
|
|
56
53
|
return escapeJsonRaw(json ?? '');
|
|
57
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* `json` with DEL, C1 and the bidi controls written as `\u` escapes, and any
|
|
57
|
+
* other C0 than tab and newline replaced by U+FFFD. `JSON.stringify` escapes
|
|
58
|
+
* C0 itself, so on its output only the escapes apply.
|
|
59
|
+
*/
|
|
58
60
|
function escapeJsonRaw(json) {
|
|
59
|
-
return json.replace(
|
|
61
|
+
return json.replace(CONTROL_KEEP_LINES, (c) => {
|
|
62
|
+
const code = c.charCodeAt(0);
|
|
63
|
+
return code < 0x20 ? REPLACEMENT : `\\u${code.toString(16).padStart(4, '0')}`;
|
|
64
|
+
});
|
|
60
65
|
}
|
|
61
66
|
/**
|
|
62
67
|
* `io` with stdout made terminal-safe, tab and newline kept. For a command
|
|
@@ -76,7 +81,7 @@ export function safeStdout(io) {
|
|
|
76
81
|
export function safeJsonStdout(io) {
|
|
77
82
|
return {
|
|
78
83
|
...io,
|
|
79
|
-
stdout: (text) => io.stdout(escapeJsonRaw(text
|
|
84
|
+
stdout: (text) => io.stdout(escapeJsonRaw(text)),
|
|
80
85
|
};
|
|
81
86
|
}
|
|
82
87
|
/**
|
package/dist/tool-info.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* What a settings screen and `way providers` say about a tool: what it is,
|
|
3
3
|
* its homepage and its language, from `@osdlc/system-model`'s `ToolDef`.
|
|
4
4
|
*/
|
|
5
|
-
import type { ToolDef } from '@osdlc/system-model/detect';
|
|
5
|
+
import type { ProviderKind, ToolDef } from '@osdlc/system-model/detect';
|
|
6
6
|
/** One tool's description, homepage and language. */
|
|
7
7
|
export interface ToolSummary {
|
|
8
8
|
id: string;
|
|
@@ -18,7 +18,7 @@ export interface ToolSummary {
|
|
|
18
18
|
/** The language a person reads: `JavaScript`, or `any language` (see `languageLabel`). */
|
|
19
19
|
language: string;
|
|
20
20
|
/** The runner role's kind: `exec` needs trust to be read. Null with no runner role. */
|
|
21
|
-
runnerKind:
|
|
21
|
+
runnerKind: ProviderKind | null;
|
|
22
22
|
}
|
|
23
23
|
/** The summary of `tool`. A custom tool's `homepage` and `description` are repository text. */
|
|
24
24
|
export declare function toolSummary(tool: ToolDef): ToolSummary;
|
package/dist/tools.js
CHANGED
|
@@ -21,8 +21,8 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
21
21
|
import { dirname, resolve } from 'node:path';
|
|
22
22
|
import { pathToFileURL } from 'node:url';
|
|
23
23
|
import { BUILTIN_TOOL_IDS } from '@osdlc/system-model/builtins';
|
|
24
|
+
import { expandTilde } from '@osdlc/tiered-dirs';
|
|
24
25
|
import { BIN } from "./app.js";
|
|
25
|
-
import { expandTilde } from "./xdg.js";
|
|
26
26
|
/** A tool module that could not be loaded or does not export tools. */
|
|
27
27
|
export class ToolModuleError extends Error {
|
|
28
28
|
constructor(message) {
|
package/dist/tui/app.js
CHANGED
|
@@ -833,6 +833,21 @@ export function createTui({ session, host, styles: s }) {
|
|
|
833
833
|
if (current() && state.loading)
|
|
834
834
|
draw();
|
|
835
835
|
}, WAITING_AFTER_MS);
|
|
836
|
+
// Skills wait for the first task row, so later rows go above them and the
|
|
837
|
+
// cursor stays put. The Skills tab has no task rows and shows them at once.
|
|
838
|
+
let held = null;
|
|
839
|
+
const showSkills = () => {
|
|
840
|
+
if (held === null)
|
|
841
|
+
return false;
|
|
842
|
+
if (state.runner !== SKILLS_TAB) {
|
|
843
|
+
recompute();
|
|
844
|
+
if (state.rows.length === 0)
|
|
845
|
+
return false;
|
|
846
|
+
}
|
|
847
|
+
state.skills = held;
|
|
848
|
+
held = null;
|
|
849
|
+
return true;
|
|
850
|
+
};
|
|
836
851
|
const progress = {
|
|
837
852
|
onRunners(runners) {
|
|
838
853
|
if (!current())
|
|
@@ -853,8 +868,17 @@ export function createTui({ session, host, styles: s }) {
|
|
|
853
868
|
}
|
|
854
869
|
state.partial = inDisplayOrder([...state.partial.filter((r) => r.runner !== report.runner), report], state.runnerOrder);
|
|
855
870
|
state.cache = [...state.cache.filter((c) => c.runner !== report.runner), cache];
|
|
871
|
+
showSkills();
|
|
856
872
|
draw();
|
|
857
873
|
},
|
|
874
|
+
onSkills(skills) {
|
|
875
|
+
// Over rows already on screen, the skills come with the whole answer.
|
|
876
|
+
if (!current() || state.partial === null)
|
|
877
|
+
return;
|
|
878
|
+
held = [...skills];
|
|
879
|
+
if (showSkills())
|
|
880
|
+
draw();
|
|
881
|
+
},
|
|
858
882
|
};
|
|
859
883
|
draw();
|
|
860
884
|
try {
|
package/dist/tui/index.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
import { constants } from 'node:os';
|
|
15
15
|
import { BIN } from "../app.js";
|
|
16
16
|
import { handOff } from "../core/run.js";
|
|
17
|
-
import {
|
|
17
|
+
import { flushWrites } from "../core/writes.js";
|
|
18
18
|
import { createTui } from "./app.js";
|
|
19
19
|
import { writeClipboard } from "./copy.js";
|
|
20
20
|
import { stylesFor } from "./style.js";
|
|
@@ -76,8 +76,8 @@ export async function runTui(session) {
|
|
|
76
76
|
process.stdout.write(SHOW + ALT_OFF);
|
|
77
77
|
},
|
|
78
78
|
handOff,
|
|
79
|
-
// A view write still in flight would be dropped by process.exit.
|
|
80
|
-
exit: (code) => void
|
|
79
|
+
// A view or store write still in flight would be dropped by process.exit.
|
|
80
|
+
exit: (code) => void flushWrites().finally(() => process.exit(code)),
|
|
81
81
|
};
|
|
82
82
|
const tui = createTui({
|
|
83
83
|
session,
|
package/dist/vocabulary.d.ts
CHANGED
|
@@ -39,7 +39,11 @@ export declare const WITHHELD = "withheld";
|
|
|
39
39
|
* runs has no trust grant while others in the repository have one, or
|
|
40
40
|
* execution is off by a flag or a config file.
|
|
41
41
|
*/
|
|
42
|
-
export type WithheldReason =
|
|
42
|
+
export type WithheldReason = (typeof ALL_WITHHELD_REASONS)[number];
|
|
43
|
+
/** Every {@link WithheldReason}, for the JSON documents' schema. */
|
|
44
|
+
export declare const ALL_WITHHELD_REASONS: readonly ["untrusted", "tool-untrusted", "exec-off"];
|
|
45
|
+
/** `a`, `a and b`, `a, b and c`. */
|
|
46
|
+
export declare function listWords(words: readonly string[]): string;
|
|
43
47
|
/**
|
|
44
48
|
* What turned execution off: the `--no-exec` flag, or `allowExec: false` in
|
|
45
49
|
* the user or the project config.
|
package/dist/vocabulary.js
CHANGED
|
@@ -40,13 +40,15 @@ export function displayPath(path, runner) {
|
|
|
40
40
|
}
|
|
41
41
|
/** The word for a runner that was not read because reading it means running it. */
|
|
42
42
|
export const WITHHELD = 'withheld';
|
|
43
|
+
/** Every {@link WithheldReason}, for the JSON documents' schema. */
|
|
44
|
+
export const ALL_WITHHELD_REASONS = ['untrusted', 'tool-untrusted', 'exec-off'];
|
|
43
45
|
const WITHHELD_REASONS = {
|
|
44
46
|
untrusted: 'this repository is not trusted',
|
|
45
47
|
'tool-untrusted': 'a tool it runs is not trusted',
|
|
46
48
|
'exec-off': 'execution is off',
|
|
47
49
|
};
|
|
48
50
|
/** `a`, `a and b`, `a, b and c`. */
|
|
49
|
-
function listWords(words) {
|
|
51
|
+
export function listWords(words) {
|
|
50
52
|
if (words.length <= 1)
|
|
51
53
|
return words.join('');
|
|
52
54
|
return `${words.slice(0, -1).join(', ')} and ${words.at(-1)}`;
|