@osdlc/wayfinder 0.8.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 +100 -0
- package/CONTRIBUTING.md +6 -1
- package/README.md +31 -11
- package/dist/args.d.ts +7 -8
- package/dist/args.js +7 -8
- package/dist/catalog.d.ts +26 -3
- package/dist/catalog.js +65 -12
- package/dist/clean-command.d.ts +3 -1
- package/dist/clean-command.js +23 -11
- package/dist/cli.js +3 -3
- package/dist/commands/browse.js +4 -2
- package/dist/commands/index.js +1 -1
- package/dist/commands/list.d.ts +21 -2
- package/dist/commands/list.js +85 -9
- 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 -9
- package/dist/config.js +64 -18
- 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 +32 -6
- package/dist/core/session.js +86 -36
- 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 +90 -1
- package/dist/documents.js +39 -12
- package/dist/guide.js +2 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +8 -5
- 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/catalog-share.d.ts +13 -1
- package/dist/serve/catalog-share.js +42 -3
- package/dist/serve/index.d.ts +5 -3
- package/dist/serve/index.js +20 -12
- 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.d.ts +15 -2
- package/dist/tui/app.js +189 -43
- package/dist/tui/index.js +3 -3
- package/dist/vocabulary.d.ts +7 -1
- package/dist/vocabulary.js +5 -1
- package/dist/web/main.js +345 -59
- package/dist/web/page.html +2 -0
- package/dist/web/styles.css +56 -0
- package/dist/xdg.d.ts +0 -7
- package/dist/xdg.js +0 -14
- package/package.json +16 -14
- package/schema/config.json +14 -1
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;
|
|
@@ -20,8 +20,15 @@
|
|
|
20
20
|
* An entry is used only by a request whose session has the same view key
|
|
21
21
|
* (trust and settings), so a trust grant or a saved setting is never answered
|
|
22
22
|
* with rows from before it. Only unfiltered listings are shared.
|
|
23
|
+
*
|
|
24
|
+
* A shared probe's progress lines (one per runner as it answers) go to every
|
|
25
|
+
* waiter that asks for them. One that joins late gets the lines sent so far
|
|
26
|
+
* first, so each waiter sees every runner.
|
|
23
27
|
*/
|
|
24
28
|
import type { CatalogBody } from '../commands/list.ts';
|
|
29
|
+
import type { CatalogProgressBody } from '../documents.ts';
|
|
30
|
+
/** Sends one progress line of a shared probe. */
|
|
31
|
+
export type ProgressSink = (line: CatalogProgressBody) => void;
|
|
25
32
|
/** See the module comment. One per command tree; `serve` turns it on. */
|
|
26
33
|
export interface CatalogShare {
|
|
27
34
|
/** True once `serve` has started, until it stops. The command line never shares. */
|
|
@@ -35,15 +42,20 @@ export interface CatalogShare {
|
|
|
35
42
|
remember(key: string, body: CatalogBody): void;
|
|
36
43
|
/** The newest catalog for `key`, marked as cached, or null. */
|
|
37
44
|
cached(key: string): CatalogBody | null;
|
|
45
|
+
/** True while a probe for `key` runs. */
|
|
46
|
+
probing(key: string): boolean;
|
|
38
47
|
/**
|
|
39
48
|
* A fresh catalog for `key`. With `join`, the probe already running for it
|
|
40
49
|
* when there is one; otherwise `probe` starts now. `probe` gets the
|
|
41
50
|
* share's signal, not the caller's. `signal` is the caller's own: when it
|
|
42
51
|
* aborts, this call rejects and the probe goes on for the other waiters.
|
|
52
|
+
* `probe` sends its progress lines through its second argument; `onEvent`
|
|
53
|
+
* gets them, the ones sent before this call first.
|
|
43
54
|
*/
|
|
44
|
-
fresh(key: string, probe: (signal: AbortSignal) => Promise<CatalogBody>, opts: {
|
|
55
|
+
fresh(key: string, probe: (signal: AbortSignal, emit: ProgressSink) => Promise<CatalogBody>, opts: {
|
|
45
56
|
join: boolean;
|
|
46
57
|
signal?: AbortSignal | undefined;
|
|
58
|
+
onEvent?: ProgressSink | undefined;
|
|
47
59
|
}): Promise<CatalogBody>;
|
|
48
60
|
/** How many callers wait on the running probe for `key`. For tests. */
|
|
49
61
|
waiting(key: string): number;
|
|
@@ -20,7 +20,24 @@
|
|
|
20
20
|
* An entry is used only by a request whose session has the same view key
|
|
21
21
|
* (trust and settings), so a trust grant or a saved setting is never answered
|
|
22
22
|
* with rows from before it. Only unfiltered listings are shared.
|
|
23
|
+
*
|
|
24
|
+
* A shared probe's progress lines (one per runner as it answers) go to every
|
|
25
|
+
* waiter that asks for them. One that joins late gets the lines sent so far
|
|
26
|
+
* first, so each waiter sees every runner.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Give `line` to one waiter's listener. False when it throws: that waiter
|
|
30
|
+
* gets no more lines, and the probe and the other waiters go on.
|
|
23
31
|
*/
|
|
32
|
+
function tell(listener, line) {
|
|
33
|
+
try {
|
|
34
|
+
listener(line);
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
24
41
|
export function createCatalogShare() {
|
|
25
42
|
let active = false;
|
|
26
43
|
const stopper = new AbortController();
|
|
@@ -31,13 +48,26 @@ export function createCatalogShare() {
|
|
|
31
48
|
const controller = new AbortController();
|
|
32
49
|
const onStop = () => controller.abort(stopper.signal.reason);
|
|
33
50
|
stopper.signal.addEventListener('abort', onStop, { once: true });
|
|
51
|
+
const events = [];
|
|
52
|
+
const listeners = new Set();
|
|
53
|
+
const emit = (line) => {
|
|
54
|
+
if (run.settled)
|
|
55
|
+
return;
|
|
56
|
+
events.push(line);
|
|
57
|
+
for (const listener of listeners) {
|
|
58
|
+
if (!tell(listener, line))
|
|
59
|
+
listeners.delete(listener);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
34
62
|
const run = {
|
|
35
63
|
key,
|
|
36
64
|
seq: ++seq,
|
|
37
65
|
controller,
|
|
38
|
-
promise: Promise.resolve().then(() => probe(controller.signal)),
|
|
66
|
+
promise: Promise.resolve().then(() => probe(controller.signal, emit)),
|
|
39
67
|
waiters: 0,
|
|
40
68
|
settled: false,
|
|
69
|
+
events,
|
|
70
|
+
listeners,
|
|
41
71
|
};
|
|
42
72
|
running = run;
|
|
43
73
|
const done = () => {
|
|
@@ -54,7 +84,7 @@ export function createCatalogShare() {
|
|
|
54
84
|
}, done);
|
|
55
85
|
return run;
|
|
56
86
|
};
|
|
57
|
-
const wait = (run, signal) => new Promise((resolve, reject) => {
|
|
87
|
+
const wait = (run, signal, onEvent) => new Promise((resolve, reject) => {
|
|
58
88
|
let left = false;
|
|
59
89
|
run.waiters++;
|
|
60
90
|
const leave = () => {
|
|
@@ -62,6 +92,8 @@ export function createCatalogShare() {
|
|
|
62
92
|
return;
|
|
63
93
|
left = true;
|
|
64
94
|
run.waiters--;
|
|
95
|
+
if (onEvent !== undefined)
|
|
96
|
+
run.listeners.delete(onEvent);
|
|
65
97
|
signal?.removeEventListener('abort', onAbort);
|
|
66
98
|
if (run.waiters === 0 && !run.settled)
|
|
67
99
|
run.controller.abort(new Error('nobody is waiting'));
|
|
@@ -73,6 +105,10 @@ export function createCatalogShare() {
|
|
|
73
105
|
if (signal?.aborted === true)
|
|
74
106
|
return onAbort();
|
|
75
107
|
signal?.addEventListener('abort', onAbort, { once: true });
|
|
108
|
+
// After `leave` is set up, so a listener that throws cannot leak this waiter.
|
|
109
|
+
if (onEvent !== undefined && run.events.every((line) => tell(onEvent, line))) {
|
|
110
|
+
run.listeners.add(onEvent);
|
|
111
|
+
}
|
|
76
112
|
run.promise.then((body) => {
|
|
77
113
|
leave();
|
|
78
114
|
resolve(body);
|
|
@@ -104,10 +140,13 @@ export function createCatalogShare() {
|
|
|
104
140
|
? body
|
|
105
141
|
: { ...body, source: 'cached', storedAt: body.generatedAt };
|
|
106
142
|
},
|
|
143
|
+
probing(key) {
|
|
144
|
+
return running !== null && running.key === key && !running.settled;
|
|
145
|
+
},
|
|
107
146
|
fresh(key, probe, opts) {
|
|
108
147
|
const joinable = running !== null && running.key === key && !running.settled;
|
|
109
148
|
const run = opts.join && joinable ? running : start(key, probe);
|
|
110
|
-
return wait(run, opts.signal);
|
|
149
|
+
return wait(run, opts.signal, opts.onEvent);
|
|
111
150
|
},
|
|
112
151
|
waiting(key) {
|
|
113
152
|
return running !== null && running.key === key ? running.waiters : 0;
|
package/dist/serve/index.d.ts
CHANGED
|
@@ -81,11 +81,13 @@ export interface WebServer {
|
|
|
81
81
|
export declare function startServer(options: ServeOptions): Promise<WebServer>;
|
|
82
82
|
/**
|
|
83
83
|
* The first lines `serve` prints: the address, the root, what was collected
|
|
84
|
-
* and what came from the store.
|
|
84
|
+
* and what came from the store. With nothing saved (`first` null), `root`
|
|
85
|
+
* and that the page shows each runner as it answers. Repository text in them
|
|
86
|
+
* is terminal-safe.
|
|
85
87
|
*/
|
|
86
|
-
export declare function startupSummary(address: string, first: Omit<CatalogSnapshot, 'origin'> & {
|
|
88
|
+
export declare function startupSummary(address: string, first: (Omit<CatalogSnapshot, 'origin'> & {
|
|
87
89
|
origin?: CatalogSnapshot['origin'];
|
|
88
|
-
}): string;
|
|
90
|
+
}) | null, root?: string): string;
|
|
89
91
|
/** The program that opens a URL in the default browser on `platform`, before the URL. */
|
|
90
92
|
export declare function browserOpener(platform: NodeJS.Platform): {
|
|
91
93
|
binary: string;
|
package/dist/serve/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import { commandString, spawnRunnerAsync } from '@osdlc/command-seam';
|
|
|
13
13
|
import { humanAge } from '@osdlc/system-model/duration';
|
|
14
14
|
import { APP, BIN } from "../app.js";
|
|
15
15
|
import { handOff as defaultHandOff } from "../core/run.js";
|
|
16
|
-
import { catalogDocument } from "../commands/list.js";
|
|
16
|
+
import { catalogDocument, progressLines } from "../commands/list.js";
|
|
17
17
|
import { buildPage } from "../page.js";
|
|
18
18
|
import { terminalSafe } from "../terminal-text.js";
|
|
19
19
|
import { WITHHELD, runnerLabel, staleLabel } from "../vocabulary.js";
|
|
@@ -144,9 +144,16 @@ export async function startServer(options) {
|
|
|
144
144
|
}
|
|
145
145
|
/**
|
|
146
146
|
* The first lines `serve` prints: the address, the root, what was collected
|
|
147
|
-
* and what came from the store.
|
|
147
|
+
* and what came from the store. With nothing saved (`first` null), `root`
|
|
148
|
+
* and that the page shows each runner as it answers. Repository text in them
|
|
149
|
+
* is terminal-safe.
|
|
148
150
|
*/
|
|
149
|
-
export function startupSummary(address, first) {
|
|
151
|
+
export function startupSummary(address, first, root = first?.catalog.root ?? '') {
|
|
152
|
+
if (first === null) {
|
|
153
|
+
return (`${APP} ${address}\n` +
|
|
154
|
+
` root ${terminalSafe(root)}\n` +
|
|
155
|
+
` collected nothing yet; the page shows each runner as it answers\n`);
|
|
156
|
+
}
|
|
150
157
|
// A withheld runner reports `absent`. It is named withheld here, because
|
|
151
158
|
// absent means the repository does not have it.
|
|
152
159
|
const counts = first.catalog.reports
|
|
@@ -190,27 +197,28 @@ export async function serve(options) {
|
|
|
190
197
|
const web = await startServer(options);
|
|
191
198
|
const address = web.server.url;
|
|
192
199
|
const bootUrl = () => `${address}/?boot=${web.signIn.bootToken}`;
|
|
193
|
-
// The saved view when there is one,
|
|
194
|
-
//
|
|
200
|
+
// The saved view when there is one, so the address shows at once. A probe
|
|
201
|
+
// starts now; the page's first reads join it, and without a saved view
|
|
202
|
+
// the page shows each runner as it answers. Without a share (tests), the
|
|
203
|
+
// store, then a probe.
|
|
195
204
|
const session = options.session;
|
|
196
|
-
const first = (await session.savedCatalog()) ?? (await session.catalog({ cached: true }));
|
|
197
205
|
const share = options.share;
|
|
206
|
+
const saved = await session.savedCatalog();
|
|
207
|
+
const first = saved ?? (share === undefined ? await session.catalog({ cached: true }) : null);
|
|
198
208
|
if (share !== undefined) {
|
|
199
209
|
const key = session.viewKey();
|
|
200
210
|
const documentOf = (snapshot) => catalogDocument(snapshot, session.unknowns(snapshot), {}, session.settings().trustedTools);
|
|
201
|
-
|
|
211
|
+
if (first !== null)
|
|
212
|
+
share.remember(key, documentOf(first));
|
|
202
213
|
share.activate();
|
|
203
214
|
// It waits on the share's own signal, so it runs to the end unless the
|
|
204
215
|
// server stops, as on a hand-off.
|
|
205
216
|
void share
|
|
206
|
-
.fresh(key, async (signal) => documentOf(await session.catalog({ signal })), {
|
|
207
|
-
join: true,
|
|
208
|
-
signal: share.signal,
|
|
209
|
-
})
|
|
217
|
+
.fresh(key, async (signal, emit) => documentOf(await session.catalog({ signal, progress: progressLines(session, emit) })), { join: true, signal: share.signal })
|
|
210
218
|
.catch(() => { });
|
|
211
219
|
}
|
|
212
220
|
web.signIn.arm();
|
|
213
|
-
options.stdout(startupSummary(address, first));
|
|
221
|
+
options.stdout(startupSummary(address, first, session.root));
|
|
214
222
|
options.stdout(` live the page refreshes on focus and every 15s; Refresh re-reads\n`);
|
|
215
223
|
options.stdout(` stop Ctrl-C\n`);
|
|
216
224
|
/** Open the current link, or print it when there is no browser to open. */
|
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.d.ts
CHANGED
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
* host, so every key and every frame can be checked without a terminal.
|
|
6
6
|
*
|
|
7
7
|
* Collection is async, which is what much of the state handling is for: keys
|
|
8
|
-
* arrive during a refresh, and a row can be stale.
|
|
8
|
+
* arrive during a refresh, and a row can be stale. With nothing on screen,
|
|
9
|
+
* each runner's rows are drawn as that runner answers. Over rows already on
|
|
10
|
+
* screen, a refresh replaces them all at once when it ends.
|
|
9
11
|
*/
|
|
10
|
-
import type { Catalog, RunnerCacheState, Task } from '@osdlc/system-model/detect';
|
|
12
|
+
import type { Catalog, RunnerCacheState, RunnerReport, Task } from '@osdlc/system-model/detect';
|
|
11
13
|
import type { Mode } from '@osdlc/system-model/match';
|
|
12
14
|
import type { Settings } from '../config.ts';
|
|
13
15
|
import type { TaskHit } from '../core/filter.ts';
|
|
@@ -74,6 +76,17 @@ export type ListEntry = {
|
|
|
74
76
|
/** Everything the screen shows. */
|
|
75
77
|
export interface TuiState {
|
|
76
78
|
catalog: Catalog | null;
|
|
79
|
+
/**
|
|
80
|
+
* The reports the first probe has sent so far, while there is no catalog
|
|
81
|
+
* to show. Null once there is one, and before a probe starts.
|
|
82
|
+
*/
|
|
83
|
+
partial: RunnerReport[] | null;
|
|
84
|
+
/** The runners the running probe has not heard from yet. */
|
|
85
|
+
pending: string[];
|
|
86
|
+
/** How many runners the running probe reports; -1 until it names them. */
|
|
87
|
+
expected: number;
|
|
88
|
+
/** When the running probe started, in ms, so a long refresh can name what it waits on. */
|
|
89
|
+
loadStarted: number;
|
|
77
90
|
/** Where each runner's rows came from, one entry per selected runner. */
|
|
78
91
|
cache: CacheState[];
|
|
79
92
|
/** The agent skills from the last probe. */
|