@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/core/session.js
CHANGED
|
@@ -9,8 +9,8 @@ import { closestMatches } from '@osdlc/config-layers/did-you-mean';
|
|
|
9
9
|
import { homeDir, parseTrustScope, policyExecGate, withheldHint, } from '@osdlc/trust-repo';
|
|
10
10
|
import { BIN, PROJECT_CONFIG_FILENAME } from "../app.js";
|
|
11
11
|
import { cacheDir } from "../cache.js";
|
|
12
|
-
import { settingLayer } from "../config-keys.js";
|
|
13
|
-
import {
|
|
12
|
+
import { DISCOVERY_VALUES, settingLayer } from "../config-keys.js";
|
|
13
|
+
import { collectAndStore, fromStore, makeProject, orderedCatalog, projectRootFor, readCachedCatalog, runnerIds, settledBoth, } from "../catalog.js";
|
|
14
14
|
import { ConfigError, collectOptionsFromConfig, readSettings, trustPolicyFromConfig, writeSetting, trustPolicyOptions, } from "../config.js";
|
|
15
15
|
import { readSkills } from "../skills.js";
|
|
16
16
|
import { toolSummary } from "../tool-info.js";
|
|
@@ -21,6 +21,7 @@ import { EDITOR_VARIABLE_LABEL } from "../vocabulary.js";
|
|
|
21
21
|
import { taskCopyText } from "./copy-text.js";
|
|
22
22
|
import { filterTasks } from "./filter.js";
|
|
23
23
|
import { readView, viewKey, writeView } from "./saved-view.js";
|
|
24
|
+
import { flushWrites } from "./writes.js";
|
|
24
25
|
import { filterSkills } from "./skills.js";
|
|
25
26
|
import { execOffSource, unknownsOf } from "./unknowns.js";
|
|
26
27
|
/**
|
|
@@ -99,31 +100,47 @@ function parseScope(scope) {
|
|
|
99
100
|
throw new SessionError('bad-arguments', err instanceof Error ? err.message : String(err));
|
|
100
101
|
}
|
|
101
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Each setting a settings screen saves that is also a collect option a flag
|
|
105
|
+
* sets. A flag pins its option: the setting no longer moves it.
|
|
106
|
+
*/
|
|
107
|
+
const COLLECT_SETTINGS = [
|
|
108
|
+
{ setting: 'runners.disabled', option: 'exclude' },
|
|
109
|
+
{ setting: 'excludePaths', option: 'excludePaths' },
|
|
110
|
+
{ setting: 'discovery', option: 'discovery' },
|
|
111
|
+
];
|
|
102
112
|
/** The collect option a flag sets, for each setting a settings screen saves. */
|
|
103
|
-
const FLAG_OF_SETTING =
|
|
104
|
-
'runners.disabled': 'exclude',
|
|
105
|
-
discovery: 'discovery',
|
|
106
|
-
excludePaths: 'excludePaths',
|
|
107
|
-
};
|
|
113
|
+
const FLAG_OF_SETTING = Object.fromEntries(COLLECT_SETTINGS.map((c) => [c.setting, c.option]));
|
|
108
114
|
/** A config error as a session error; anything else unchanged. */
|
|
109
115
|
function asSessionError(err, prefix = '') {
|
|
110
116
|
if (err instanceof ConfigError)
|
|
111
117
|
return new SessionError('config', prefix + err.message);
|
|
112
118
|
return err;
|
|
113
119
|
}
|
|
120
|
+
/** The fresh state of a runner probed just now, with its measured time when it ran. */
|
|
121
|
+
function probedState(runner, probeMs) {
|
|
122
|
+
return {
|
|
123
|
+
runner,
|
|
124
|
+
state: 'fresh',
|
|
125
|
+
ageMs: 0,
|
|
126
|
+
estimateMs: probeMs ?? null,
|
|
127
|
+
slow: false,
|
|
128
|
+
...(probeMs !== undefined ? { probeMs } : {}),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
114
131
|
/** Fresh states for a catalog probed just now, with each runner's measured time. */
|
|
115
132
|
function probedStates(catalog, times) {
|
|
116
|
-
return catalog.reports.map((r) =>
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
133
|
+
return catalog.reports.map((r) => probedState(r.runner, times.get(r.runner)));
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The selected runners the store has no rows for. That is a miss, and also a
|
|
137
|
+
* runner whose stored rows were dropped: a probe that ran the repository's
|
|
138
|
+
* tools does not answer a run that may not run them, so that entry is stale
|
|
139
|
+
* with no report.
|
|
140
|
+
*/
|
|
141
|
+
function unanswered(catalog, runners) {
|
|
142
|
+
const answered = new Set(catalog.reports.map((r) => r.runner));
|
|
143
|
+
return runners.filter((r) => !answered.has(r.runner)).map((r) => r.runner);
|
|
127
144
|
}
|
|
128
145
|
/**
|
|
129
146
|
* Start a session: find the root, load config, decide execution against the
|
|
@@ -163,7 +180,7 @@ export async function createSession(opts) {
|
|
|
163
180
|
const built = await projectFor(flags.toolModules ?? [], config, opts.cwd, home, projectAllowed);
|
|
164
181
|
const projectToolsPending = !projectAllowed && (config.layers.project?.tools?.length ?? 0) > 0;
|
|
165
182
|
// The config's own allowExec was consumed by the gate.
|
|
166
|
-
const { allowExec: _consumed, ...configOptions } = collectOptionsFromConfig(config.effective);
|
|
183
|
+
const { allowExec: _consumed, ...configOptions } = collectOptionsFromConfig(config.effective, config.layers);
|
|
167
184
|
// Config first, flags second. --exclude REPLACES runners.disabled.
|
|
168
185
|
const options = {
|
|
169
186
|
...configOptions,
|
|
@@ -177,11 +194,7 @@ export async function createSession(opts) {
|
|
|
177
194
|
...(flags.discovery !== undefined ? { discovery: flags.discovery } : {}),
|
|
178
195
|
...(opts.signal !== undefined ? { signal: opts.signal } : {}),
|
|
179
196
|
};
|
|
180
|
-
const pinnedByFlag = [
|
|
181
|
-
...(flags.exclude ? ['exclude'] : []),
|
|
182
|
-
...(flags.excludePaths ? ['excludePaths'] : []),
|
|
183
|
-
...(flags.discovery !== undefined ? ['discovery'] : []),
|
|
184
|
-
];
|
|
197
|
+
const pinnedByFlag = COLLECT_SETTINGS.filter((c) => flags[c.option] !== undefined).map((c) => c.option);
|
|
185
198
|
// Per-tool trust applies only when the repository's own trust is what
|
|
186
199
|
// withholds execution. The set is read on every probe, so a tool grant in
|
|
187
200
|
// this session applies to the next one.
|
|
@@ -207,14 +220,25 @@ export async function createSession(opts) {
|
|
|
207
220
|
};
|
|
208
221
|
}
|
|
209
222
|
const skills = () => readSkills(root, { setting: settings.skills.value, home, env, signal: opts.signal });
|
|
223
|
+
/** The skills, told to `progress` as soon as they are read. */
|
|
224
|
+
const toldSkills = async (progress) => {
|
|
225
|
+
const rows = await skills();
|
|
226
|
+
progress?.onSkills?.(rows);
|
|
227
|
+
return rows;
|
|
228
|
+
};
|
|
210
229
|
const store = cacheDir(env, home);
|
|
211
230
|
const runnerOrder = () => settings.loaded.effective.runners?.order;
|
|
212
231
|
/** Take `next` as the settings: the collect options follow, except where a flag decided. */
|
|
213
232
|
const adopt = (next) => {
|
|
214
233
|
settings = next;
|
|
215
|
-
const derived = collectOptionsFromConfig(next.loaded.effective);
|
|
234
|
+
const derived = collectOptionsFromConfig(next.loaded.effective, next.loaded.layers);
|
|
216
235
|
const target = options;
|
|
217
|
-
|
|
236
|
+
// The probe time limits have no flag, so a setting always moves them.
|
|
237
|
+
for (const key of [
|
|
238
|
+
...COLLECT_SETTINGS.map((c) => c.option),
|
|
239
|
+
'probeTimeoutMs',
|
|
240
|
+
'maxProbeTimeoutMs',
|
|
241
|
+
]) {
|
|
218
242
|
if (pinnedByFlag.includes(key))
|
|
219
243
|
continue;
|
|
220
244
|
if (derived[key] === undefined)
|
|
@@ -237,13 +261,21 @@ export async function createSession(opts) {
|
|
|
237
261
|
const signals = [options.signal, signal].filter((s) => s !== undefined);
|
|
238
262
|
return signals.length > 0 ? { ...options, signal: AbortSignal.any(signals) } : options;
|
|
239
263
|
};
|
|
240
|
-
/** Probe the runners `only` names (all when absent), timing each
|
|
241
|
-
const probe = async (only, signal) => {
|
|
264
|
+
/** Probe the runners `only` names (all when absent), timing each and telling `progress`. */
|
|
265
|
+
const probe = async (only, signal, progress) => {
|
|
242
266
|
const times = new Map();
|
|
243
|
-
const catalog = await
|
|
267
|
+
const catalog = await collectAndStore(project, root, {
|
|
244
268
|
...withSignal(signal),
|
|
245
269
|
...(only !== undefined ? { only } : {}),
|
|
246
270
|
onProbe: ({ runner, durationMs }) => times.set(runner, durationMs),
|
|
271
|
+
...(progress?.onRunners !== undefined
|
|
272
|
+
? { onRunners: (runners) => progress.onRunners?.(runners) }
|
|
273
|
+
: {}),
|
|
274
|
+
...(progress?.onRunner !== undefined
|
|
275
|
+
? {
|
|
276
|
+
onReport: (report) => progress.onRunner?.(report, probedState(report.runner, times.get(report.runner))),
|
|
277
|
+
}
|
|
278
|
+
: {}),
|
|
247
279
|
}, store);
|
|
248
280
|
return { catalog, times };
|
|
249
281
|
};
|
|
@@ -299,30 +331,35 @@ export async function createSession(opts) {
|
|
|
299
331
|
},
|
|
300
332
|
async catalog(opts = {}) {
|
|
301
333
|
if (opts.cached !== true) {
|
|
302
|
-
|
|
334
|
+
// The skills are read beside the probe, so the answer does not wait
|
|
335
|
+
// for both in turn. Both settle before a failure is thrown.
|
|
336
|
+
const [{ catalog, times }, skillRows] = await settledBoth(probe(undefined, opts.signal, opts.progress), toldSkills(opts.progress));
|
|
303
337
|
return saved({
|
|
304
338
|
catalog: orderedCatalog(catalog, runnerOrder()),
|
|
305
339
|
cache: probedStates(catalog, times),
|
|
306
|
-
skills:
|
|
340
|
+
skills: skillRows,
|
|
307
341
|
origin: 'probe',
|
|
308
342
|
});
|
|
309
343
|
}
|
|
310
344
|
const view = await session.savedCatalog();
|
|
311
345
|
if (view !== null)
|
|
312
346
|
return view;
|
|
347
|
+
// A probe in this process writes the store after it answers.
|
|
348
|
+
await flushWrites();
|
|
313
349
|
// The call's signal too: a closed tab stops hashing the store.
|
|
314
350
|
const stored = await readCachedCatalog(project, root, withSignal(opts.signal), store);
|
|
315
351
|
if (stored.catalog === null || !fromStore(stored)) {
|
|
316
|
-
const { catalog, times } = await probe(undefined, opts.signal);
|
|
352
|
+
const [{ catalog, times }, skillRows] = await settledBoth(probe(undefined, opts.signal, opts.progress), toldSkills(opts.progress));
|
|
317
353
|
return saved({
|
|
318
354
|
catalog: orderedCatalog(catalog, runnerOrder()),
|
|
319
355
|
cache: probedStates(catalog, times),
|
|
320
|
-
skills:
|
|
356
|
+
skills: skillRows,
|
|
321
357
|
origin: 'empty-store',
|
|
322
358
|
});
|
|
323
359
|
}
|
|
324
|
-
//
|
|
325
|
-
|
|
360
|
+
// Only the runners with no stored rows are probed: a miss, or a stale
|
|
361
|
+
// entry whose report the store dropped.
|
|
362
|
+
const missing = unanswered(stored.catalog, stored.runners);
|
|
326
363
|
if (missing.length === 0) {
|
|
327
364
|
return saved({
|
|
328
365
|
catalog: orderedCatalog(stored.catalog, runnerOrder()),
|
|
@@ -331,6 +368,8 @@ export async function createSession(opts) {
|
|
|
331
368
|
origin: 'store',
|
|
332
369
|
});
|
|
333
370
|
}
|
|
371
|
+
// No progress here: it would name only the missing runners, while the
|
|
372
|
+
// stored ones wait for the document.
|
|
334
373
|
const { catalog: probed, times } = await probe(missing, opts.signal);
|
|
335
374
|
const fresh = new Map(probedStates(probed, times).map((s) => [s.runner, s]));
|
|
336
375
|
return saved({
|
|
@@ -341,12 +380,23 @@ export async function createSession(opts) {
|
|
|
341
380
|
});
|
|
342
381
|
},
|
|
343
382
|
async storedCatalog() {
|
|
383
|
+
await flushWrites();
|
|
344
384
|
const stored = await readCachedCatalog(project, root, options, store);
|
|
345
385
|
if (stored.catalog === null || !fromStore(stored))
|
|
346
386
|
return null;
|
|
387
|
+
// A runner with no stored rows is missing from the catalog, so it is a miss.
|
|
388
|
+
const missing = new Set(unanswered(stored.catalog, stored.runners));
|
|
347
389
|
return {
|
|
348
390
|
catalog: orderedCatalog(stored.catalog, runnerOrder()),
|
|
349
|
-
cache: stored.runners
|
|
391
|
+
cache: stored.runners.map((r) => missing.has(r.runner)
|
|
392
|
+
? {
|
|
393
|
+
runner: r.runner,
|
|
394
|
+
state: 'miss',
|
|
395
|
+
estimateMs: r.estimateMs,
|
|
396
|
+
slow: r.slow,
|
|
397
|
+
cost: r.cost,
|
|
398
|
+
}
|
|
399
|
+
: r),
|
|
350
400
|
skills: await skills(),
|
|
351
401
|
origin: 'store',
|
|
352
402
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The writes this process starts without waiting: the saved view and the
|
|
3
|
+
* probe store. A surface answers first and writes after. `process.exit`
|
|
4
|
+
* would drop a write in flight, so every normal exit awaits {@link flushWrites}.
|
|
5
|
+
*/
|
|
6
|
+
/** Keep `write` until it settles, so {@link flushWrites} waits for it. Returns `write`. */
|
|
7
|
+
export declare function trackWrite<T>(write: Promise<T>): Promise<T>;
|
|
8
|
+
/**
|
|
9
|
+
* Settles when every write this process started has ended, those started
|
|
10
|
+
* while it waits included. Call it before `process.exit`, and before a test
|
|
11
|
+
* removes the cache directory.
|
|
12
|
+
*/
|
|
13
|
+
export declare function flushWrites(): Promise<void>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The writes this process starts without waiting: the saved view and the
|
|
3
|
+
* probe store. A surface answers first and writes after. `process.exit`
|
|
4
|
+
* would drop a write in flight, so every normal exit awaits {@link flushWrites}.
|
|
5
|
+
*/
|
|
6
|
+
const pending = new Set();
|
|
7
|
+
/** Keep `write` until it settles, so {@link flushWrites} waits for it. Returns `write`. */
|
|
8
|
+
export function trackWrite(write) {
|
|
9
|
+
const settled = write.then(() => { }, () => { });
|
|
10
|
+
pending.add(settled);
|
|
11
|
+
void settled.finally(() => pending.delete(settled));
|
|
12
|
+
return write;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Settles when every write this process started has ended, those started
|
|
16
|
+
* while it waits included. Call it before `process.exit`, and before a test
|
|
17
|
+
* removes the cache directory.
|
|
18
|
+
*/
|
|
19
|
+
export async function flushWrites() {
|
|
20
|
+
while (pending.size > 0)
|
|
21
|
+
await Promise.all(pending);
|
|
22
|
+
}
|
|
@@ -142,6 +142,9 @@ export const GENERATED_SCHEMAS = {
|
|
|
142
142
|
},
|
|
143
143
|
"file": {
|
|
144
144
|
"type": "string"
|
|
145
|
+
},
|
|
146
|
+
"dryRun": {
|
|
147
|
+
"type": "boolean"
|
|
145
148
|
}
|
|
146
149
|
},
|
|
147
150
|
"required": [
|
|
@@ -173,6 +176,9 @@ export const GENERATED_SCHEMAS = {
|
|
|
173
176
|
},
|
|
174
177
|
"file": {
|
|
175
178
|
"type": "string"
|
|
179
|
+
},
|
|
180
|
+
"dryRun": {
|
|
181
|
+
"type": "boolean"
|
|
176
182
|
}
|
|
177
183
|
},
|
|
178
184
|
"required": [
|
package/dist/documents.d.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
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
9
|
/** A `Task` from system-model. */
|
|
@@ -224,6 +225,93 @@ export declare const CatalogOutput: z.ZodObject<{
|
|
|
224
225
|
maxDepth: z.ZodOptional<z.ZodNumber>;
|
|
225
226
|
}, z.core.$strip>;
|
|
226
227
|
}, z.core.$strip>;
|
|
228
|
+
/**
|
|
229
|
+
* One line `list --progress` sends while it probes, before the catalog
|
|
230
|
+
* document: which runners have not answered, and the one that just did or
|
|
231
|
+
* the agent skills.
|
|
232
|
+
*/
|
|
233
|
+
export declare const CatalogProgressOutput: z.ZodObject<{
|
|
234
|
+
pending: z.ZodArray<z.ZodString>;
|
|
235
|
+
total: z.ZodNumber;
|
|
236
|
+
report: z.ZodOptional<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
237
|
+
omitted: z.ZodOptional<z.ZodString>;
|
|
238
|
+
cache: z.ZodOptional<z.ZodObject<{
|
|
239
|
+
runner: z.ZodString;
|
|
240
|
+
state: z.ZodEnum<{
|
|
241
|
+
fresh: "fresh";
|
|
242
|
+
stale: "stale";
|
|
243
|
+
miss: "miss";
|
|
244
|
+
}>;
|
|
245
|
+
reason: z.ZodOptional<z.ZodEnum<{
|
|
246
|
+
changed: "changed";
|
|
247
|
+
"max-age": "max-age";
|
|
248
|
+
excludes: "excludes";
|
|
249
|
+
exec: "exec";
|
|
250
|
+
version: "version";
|
|
251
|
+
tool: "tool";
|
|
252
|
+
}>>;
|
|
253
|
+
ageMs: z.ZodOptional<z.ZodNumber>;
|
|
254
|
+
estimateMs: z.ZodNullable<z.ZodNumber>;
|
|
255
|
+
slow: z.ZodBoolean;
|
|
256
|
+
cost: z.ZodOptional<z.ZodEnum<{
|
|
257
|
+
slow: "slow";
|
|
258
|
+
cheap: "cheap";
|
|
259
|
+
}>>;
|
|
260
|
+
probeMs: z.ZodOptional<z.ZodNumber>;
|
|
261
|
+
}, z.core.$strip>>;
|
|
262
|
+
unknowns: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
263
|
+
kind: z.ZodLiteral<"withheld">;
|
|
264
|
+
runner: z.ZodString;
|
|
265
|
+
reason: z.ZodEnum<{
|
|
266
|
+
untrusted: "untrusted";
|
|
267
|
+
"tool-untrusted": "tool-untrusted";
|
|
268
|
+
"exec-off": "exec-off";
|
|
269
|
+
}>;
|
|
270
|
+
missing: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
271
|
+
label: z.ZodString;
|
|
272
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
273
|
+
kind: z.ZodLiteral<"parameters">;
|
|
274
|
+
runner: z.ZodString;
|
|
275
|
+
reason: z.ZodEnum<{
|
|
276
|
+
"exec-withheld": "exec-withheld";
|
|
277
|
+
"tool-missing": "tool-missing";
|
|
278
|
+
"tool-failed": "tool-failed";
|
|
279
|
+
"not-read": "not-read";
|
|
280
|
+
"editor-variable": "editor-variable";
|
|
281
|
+
}>;
|
|
282
|
+
tasks: z.ZodArray<z.ZodString>;
|
|
283
|
+
label: z.ZodString;
|
|
284
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
285
|
+
kind: z.ZodLiteral<"stale">;
|
|
286
|
+
runner: z.ZodString;
|
|
287
|
+
reason: z.ZodOptional<z.ZodEnum<{
|
|
288
|
+
changed: "changed";
|
|
289
|
+
"max-age": "max-age";
|
|
290
|
+
excludes: "excludes";
|
|
291
|
+
exec: "exec";
|
|
292
|
+
version: "version";
|
|
293
|
+
tool: "tool";
|
|
294
|
+
}>>;
|
|
295
|
+
ageMs: z.ZodOptional<z.ZodNumber>;
|
|
296
|
+
label: z.ZodString;
|
|
297
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
298
|
+
kind: z.ZodLiteral<"binary">;
|
|
299
|
+
runner: z.ZodString;
|
|
300
|
+
binary: z.ZodString;
|
|
301
|
+
label: z.ZodString;
|
|
302
|
+
}, z.core.$strip>], "kind">>>;
|
|
303
|
+
skills: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
304
|
+
id: z.ZodString;
|
|
305
|
+
name: z.ZodString;
|
|
306
|
+
description: z.ZodNullable<z.ZodString>;
|
|
307
|
+
argumentHint: z.ZodNullable<z.ZodString>;
|
|
308
|
+
path: z.ZodString;
|
|
309
|
+
scope: z.ZodString;
|
|
310
|
+
origin: z.ZodString;
|
|
311
|
+
harnesses: z.ZodArray<z.ZodString>;
|
|
312
|
+
invoke: z.ZodString;
|
|
313
|
+
}, z.core.$strip>>>;
|
|
314
|
+
}, z.core.$strip>;
|
|
227
315
|
/** The catalog document's `schemaVersion`: the catalog's own. */
|
|
228
316
|
export declare const CATALOG_DOCUMENT_VERSION = 1;
|
|
229
317
|
/** `way query --json`: the matching tasks, best first. */
|
|
@@ -427,6 +515,7 @@ export declare const RunOutput: z.ZodObject<{
|
|
|
427
515
|
}, z.core.$strip>], "kind">>;
|
|
428
516
|
}, z.core.$strip>;
|
|
429
517
|
export type CatalogDocumentBody = z.input<typeof CatalogOutput>;
|
|
518
|
+
export type CatalogProgressBody = z.input<typeof CatalogProgressOutput>;
|
|
430
519
|
export type QueryDocumentBody = z.input<typeof QueryOutput>;
|
|
431
520
|
export type ProvidersDocumentBody = z.input<typeof ProvidersOutput>;
|
|
432
521
|
export type RunDocumentBody = z.input<typeof RunOutput>;
|
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(),
|
|
@@ -113,6 +117,29 @@ export const CatalogOutput = z.object({
|
|
|
113
117
|
.describe('The tool ids trusted on their own here. Empty when the repository is trusted as a whole.'),
|
|
114
118
|
filter: FilterZ,
|
|
115
119
|
});
|
|
120
|
+
/**
|
|
121
|
+
* One line `list --progress` sends while it probes, before the catalog
|
|
122
|
+
* document: which runners have not answered, and the one that just did or
|
|
123
|
+
* the agent skills.
|
|
124
|
+
*/
|
|
125
|
+
export const CatalogProgressOutput = z.object({
|
|
126
|
+
pending: z.array(z.string()).describe('The runners that have not answered yet, in report order.'),
|
|
127
|
+
total: z.number().int().describe('How many runners the probe reports.'),
|
|
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.'),
|
|
129
|
+
omitted: z
|
|
130
|
+
.string()
|
|
131
|
+
.optional()
|
|
132
|
+
.describe('A runner that answered with a report too large for one line. Its rows come with the catalog document.'),
|
|
133
|
+
cache: CacheStateZ.optional().describe("The answered runner's cache verdict."),
|
|
134
|
+
unknowns: z
|
|
135
|
+
.array(UnknownZ)
|
|
136
|
+
.optional()
|
|
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.'),
|
|
142
|
+
});
|
|
116
143
|
/** The catalog document's `schemaVersion`: the catalog's own. */
|
|
117
144
|
export const CATALOG_DOCUMENT_VERSION = CATALOG_SCHEMA_VERSION;
|
|
118
145
|
/** `way query --json`: the matching tasks, best first. */
|
|
@@ -134,8 +161,8 @@ export const QueryOutput = z.object({
|
|
|
134
161
|
/** One registered tool. */
|
|
135
162
|
export const ProviderZ = z.object({
|
|
136
163
|
id: z.string(),
|
|
137
|
-
roles: z.array(z.enum(
|
|
138
|
-
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."),
|
|
139
166
|
binary: z.string().nullable(),
|
|
140
167
|
onPath: z.boolean().nullable().describe('Whether binary is on the PATH; null with no binary.'),
|
|
141
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.d.ts
CHANGED
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import type { DiscoveryMode, RunnerReport } from '@osdlc/system-model/detect';
|
|
15
15
|
import type { TaskFilter } from './core/filter.ts';
|
|
16
|
-
import { type CacheState, type SessionFlags } from './core/session.ts';
|
|
16
|
+
import { type CacheState, type CatalogProgress, type SessionFlags } from './core/session.ts';
|
|
17
17
|
import type { SkillRow } from './core/skills.ts';
|
|
18
18
|
import type { Unknown } from './core/unknowns.ts';
|
|
19
19
|
import type { DocumentGroup } from './groups.ts';
|
|
20
|
-
export { SessionError, type CacheState, type SessionFlags } from './core/session.ts';
|
|
20
|
+
export { SessionError, type CacheState, type CatalogProgress, type SessionFlags, } from './core/session.ts';
|
|
21
21
|
export { filterTasks, hasQuery, keepsTask, sourceDepth } from './core/filter.ts';
|
|
22
22
|
export type { TaskFilter, TaskHit } from './core/filter.ts';
|
|
23
23
|
export { filterSkills, skillLine, SKILLS_SETTING_VALUES } from './core/skills.ts';
|
|
@@ -54,6 +54,12 @@ export interface BuildCatalogOptions {
|
|
|
54
54
|
filter?: TaskFilter | undefined;
|
|
55
55
|
/** Stops every probe. */
|
|
56
56
|
signal?: AbortSignal | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Hears about each runner the call probes as it answers: `onRunners`
|
|
59
|
+
* once, then `onRunner` per runner. An answer from the saved listing or
|
|
60
|
+
* the store probes none. The document is still the answer to use.
|
|
61
|
+
*/
|
|
62
|
+
progress?: CatalogProgress | undefined;
|
|
57
63
|
/**
|
|
58
64
|
* Called with each warning from the config files and tool modules, such
|
|
59
65
|
* as a project file key that is ignored. The CLI prints these on stderr.
|
package/dist/index.js
CHANGED
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
* change them, and the changelog says how.
|
|
13
13
|
*/
|
|
14
14
|
import { catalogDocument } from "./commands/list.js";
|
|
15
|
-
import {
|
|
16
|
-
import { createSession } from "./core/session.js";
|
|
15
|
+
import { flushWrites } from "./core/writes.js";
|
|
16
|
+
import { createSession, } from "./core/session.js";
|
|
17
17
|
import { CATALOG_DOCUMENT_VERSION } from "./documents.js";
|
|
18
|
-
export { SessionError } from "./core/session.js";
|
|
18
|
+
export { SessionError, } from "./core/session.js";
|
|
19
19
|
export { filterTasks, hasQuery, keepsTask, sourceDepth } from "./core/filter.js";
|
|
20
20
|
export { filterSkills, skillLine, SKILLS_SETTING_VALUES } from "./core/skills.js";
|
|
21
21
|
export { unknownLine, unknownsOf } from "./core/unknowns.js";
|
|
@@ -50,9 +50,12 @@ export async function buildCatalog(options) {
|
|
|
50
50
|
});
|
|
51
51
|
for (const warning of session.warnings)
|
|
52
52
|
options.onWarning?.(warning);
|
|
53
|
-
const snapshot = await session.catalog({
|
|
53
|
+
const snapshot = await session.catalog({
|
|
54
|
+
cached: options.cached === true,
|
|
55
|
+
progress: options.progress,
|
|
56
|
+
});
|
|
54
57
|
// A library caller gets a call whose writes are done.
|
|
55
|
-
await
|
|
58
|
+
await flushWrites();
|
|
56
59
|
const body = catalogDocument(snapshot, session.unknowns(snapshot), options.filter ?? {}, session.settings().trustedTools);
|
|
57
60
|
return { schemaVersion: CATALOG_DOCUMENT_VERSION, kind: 'catalog', ...body };
|
|
58
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)]));
|