@osdlc/wayfinder 0.8.0 → 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/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @osdlc/wayfinder
2
2
 
3
+ ## 0.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f6993bf: The terminal UI and the web view draw at once, and with no saved listing they show each runner's tasks as that runner answers.
8
+
9
+ - **Terminal UI:** the frame appears before anything is read. With no saved listing, each runner's rows arrive as it answers. A runner still loading has `…` in place of its tab's count and a `… moon loading` line in the list, and the status line names them: `loading 3 of 12: just, mise, moon`. A withheld runner shows its reason as soon as it answers. A failed one gets ` !` on its tab and its reason above the rows. While rows arrive, the cursor stays on its task, so Enter runs the row on screen. Over a saved listing the status line says `refreshing…` until every runner has answered, then the rows update in place; after 3 seconds it names the runners still out. The store is no longer read before the first probe, since that costs as long as the probe's own detection.
10
+ - **Web view:** `way serve` prints its address without waiting for a probe. With no saved listing, the page's first read joins the server's probe and draws each runner as it arrives, with a loading tab and row for each runner still out, each in its final place, and the same `loading N of M` count in the status. A live region tells a screen reader when loading starts and ends. The lines stream as NDJSON over the same API, token and Host and Origin checks as every other call. Over rows already shown it says `refreshing…`.
11
+ - **Library:** `buildCatalog` takes `progress: { onRunners, onRunner }`, which hears about each runner as it answers. The `CatalogProgress` type is exported. The document it returns is unchanged.
12
+ - **CLI:** `list --progress --output jsonl` prints a `catalog-progress` line as each runner answers, before the reports. `way schema` describes it. Over HTTP the same lines stream as NDJSON. A report over about 1 MiB is named in `omitted` instead of sent.
13
+ - `list --json` and `list --output jsonl` print what they printed before.
14
+ - With a grant for one tool, the trusted and the withheld runners are now collected at the same time.
15
+
16
+ ### Patch Changes
17
+
18
+ - df47065: The config file's `$schema` URL now names the 0.9 release line. Point an existing `$schema` at
19
+ `https://unpkg.com/@osdlc/wayfinder@0.9/schema/config.json`; the 0.8 URL keeps working.
20
+ - Updated dependencies [7addea1]
21
+ - Updated dependencies [f013f38]
22
+ - Updated dependencies [f6993bf]
23
+ - Updated dependencies [f013f38]
24
+ - @osdlc/cli-tool@0.9.1
25
+ - @osdlc/command-seam@0.12.1
26
+ - @osdlc/system-model@0.6.0
27
+ - @osdlc/typed-git@0.8.2
28
+
3
29
  ## 0.8.0
4
30
 
5
31
  ### Minor Changes
package/README.md CHANGED
@@ -182,10 +182,11 @@ gets focus and on a slow poll, so it shows what the repository has now.
182
182
 
183
183
  Every action on the page is a command of `way` called over HTTP: the list
184
184
  is `way list`, a trust grant is `way trust`, a saved setting is `way config
185
- set`. The page first asks for the [stored probe](#the-cache), then for a
186
- real one. So the page appears at once, even when the slowest runner takes
187
- seconds. The rows update in place when the probe finishes. Refresh always
188
- runs a real probe.
185
+ set`. The page first asks for the [last saved listing](#the-cache), then for
186
+ a real probe. So the page appears at once, even when the slowest runner takes
187
+ seconds. The rows update in place when the probe finishes. With nothing
188
+ saved, each runner's rows appear as that runner answers. Refresh always runs
189
+ a real probe.
189
190
 
190
191
  ## Execution, and trust
191
192
 
@@ -366,9 +367,9 @@ The terminal UI and `serve` always start from what was last shown. Every
366
367
  `list`, `query` and refresh saves the catalog it showed in one file, and a
367
368
  start draws that file before it reads anything else, so the rows appear in
368
369
  well under a second even on a large repository. The file is used only under
369
- the same trust and settings that produced it. Without it they read the store,
370
- which needs no probe but detects the project and hashes each runner's files.
371
- Then they probe in the background and update in place. `list` and `query`
370
+ the same trust and settings that produced it. Then they probe in the
371
+ background and update in place. Without it they probe and show each runner
372
+ as it answers, with the runners still loading named. `list` and `query`
372
373
  re-probe on every run, because a script or an agent reading them needs what
373
374
  the repository has right now. `--cached` makes `list`, `query` and `run`
374
375
  answer at once from the same saved listing the UIs draw. It does not check
@@ -528,6 +529,17 @@ The `catalog` and `query` documents carry `cache`, `filter` and `unknowns`.
528
529
  prints: a runner withheld for trust, tasks whose parameters are unknown and
529
530
  why, a stale stored answer, a tool missing from `PATH`.
530
531
 
532
+ ### Progress lines
533
+
534
+ `way list --progress --output jsonl` prints a `catalog-progress` line as each
535
+ runner answers, then the reports. The first line names every runner in
536
+ `pending`, in display order. Each later line carries the runner that answered
537
+ in `report`, with its `cache` verdict and `unknowns`, and the runners still
538
+ out in `pending`. A report too large for one line (about 1 MiB) is named in
539
+ `omitted` instead and comes with the reports. Over HTTP, `way serve` sends the
540
+ same lines as NDJSON when the request asks for `application/x-ndjson`, with
541
+ the catalog document last. `way schema` describes the line.
542
+
531
543
  ### Old flags
532
544
 
533
545
  These still work in this release and will be removed in a later one:
@@ -637,11 +649,14 @@ probe store. Nothing in the repository runs unless it is trusted and
637
649
  execution is allowed. It throws `SessionError` with a `code` for a directory
638
650
  that does not exist, a config file that cannot be used, or a tool module that
639
651
  cannot be loaded. `onWarning` gets each warning the CLI prints on stderr,
640
- such as a project file key that is ignored.
652
+ such as a project file key that is ignored. `progress` hears about each
653
+ runner as it answers: `onRunners(ids)` once, then `onRunner(report, cache)`
654
+ per runner, withheld ones included, so a caller can show the catalog before
655
+ the slowest runner is done.
641
656
 
642
657
  | Export | Is |
643
658
  |---|---|
644
- | `buildCatalog`, `BuildCatalogOptions`, `CatalogDocument`, `SessionFlags`, `CacheState` | the catalog for a directory, the flags it takes and each runner's cache verdict |
659
+ | `buildCatalog`, `BuildCatalogOptions`, `CatalogDocument`, `SessionFlags`, `CacheState`, `CatalogProgress` | the catalog for a directory, the flags it takes, each runner's cache verdict and each runner as it answers |
645
660
  | `filterTasks`, `keepsTask`, `sourceDepth`, `hasQuery`, `TaskFilter`, `TaskHit`, `Mode` | the search and filters every surface uses |
646
661
  | `filterSkills`, `skillLine`, `SkillRow`, `SkillHit`, `SkillsSetting`, `SKILLS_SETTING_VALUES` | the Skills group |
647
662
  | `GROUPS`, `SKILLS_GROUP`, `groupOf`, `catalogGroups`, `documentGroups`, `Group`, `GroupId`, `DocumentGroup` | the groups and their order |
package/dist/catalog.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * repository, then collect (or read the cache) with the options wayfinder
4
4
  * resolved from flags, config and trust.
5
5
  */
6
- import { type CachedCatalog, type Catalog, type DiscoveryMode, type Project, type ToolDef } from '@osdlc/system-model/detect';
6
+ import { type CachedCatalog, type Catalog, type DiscoveryMode, type Project, type RunnerReport, type ToolDef } from '@osdlc/system-model/detect';
7
7
  /**
8
8
  * Everything one collection needs: detection settings and runner selection
9
9
  * together, because both come from the same flags and config keys.
@@ -25,6 +25,10 @@ export interface WayOptions {
25
25
  runner: string;
26
26
  durationMs: number;
27
27
  }) => void) | undefined;
28
+ /** Called once, before any runner answers, with every runner the collection reports. */
29
+ onRunners?: ((runners: readonly string[]) => void) | undefined;
30
+ /** Called with each runner's report as it answers, withheld runners included. */
31
+ onReport?: ((report: RunnerReport) => void) | undefined;
28
32
  /**
29
33
  * Per-tool trust, for a repository that is not trusted as a whole. Used
30
34
  * only while `allowExec` is false. See {@link ToolTrust}.
@@ -52,10 +56,16 @@ export declare function projectRootFor(dir: string): Promise<string | null>;
52
56
  export declare function makeProject(extra?: readonly ToolDef[]): Project;
53
57
  /** The ids of every registered tool with a runner role. */
54
58
  export declare function runnerIds(project: Project): string[];
55
- /** Detect, collect, and store each runner's result under `store`. */
59
+ /**
60
+ * Detect, collect, and store each runner's result under `store`. When a tool
61
+ * grant splits the runners in two, both collections settle before a failure
62
+ * is thrown.
63
+ */
56
64
  export declare function collectAndCache(project: Project, root: string, options: WayOptions, store: string): Promise<Catalog>;
57
65
  /** Detect, then read what `store` holds, without running any runner. */
58
66
  export declare function readCachedCatalog(project: Project, root: string, options: WayOptions, store: string): Promise<CachedCatalog>;
67
+ /** Both results once both have settled; the first failure, if any, after both. */
68
+ export declare function settledBoth<A, B>(a: Promise<A>, b: Promise<B>): Promise<[A, B]>;
59
69
  /** True when something came out of the store, not only withheld reports. */
60
70
  export declare function fromStore(cached: CachedCatalog): boolean;
61
71
  /**
@@ -63,3 +73,7 @@ export declare function fromStore(cached: CachedCatalog): boolean;
63
73
  * git hooks) and, within a group, in the configured order.
64
74
  */
65
75
  export declare function orderedCatalog(catalog: Catalog, order: string[] | undefined): Catalog;
76
+ /** `items` by group, and within a group in the configured order. */
77
+ export declare function inDisplayOrder<T extends {
78
+ runner: string;
79
+ }>(items: readonly T[], order: string[] | undefined): T[];
package/dist/catalog.js CHANGED
@@ -38,6 +38,8 @@ function collectOptions(o) {
38
38
  execWithheldHint: o.execWithheldHint,
39
39
  signal: o.signal,
40
40
  onProbe: o.onProbe,
41
+ onRunners: o.onRunners,
42
+ onReport: o.onReport,
41
43
  };
42
44
  }
43
45
  /**
@@ -82,19 +84,50 @@ function grantedRunners(project, profile, o) {
82
84
  .map(([runner]) => runner);
83
85
  return granted.length > 0 ? granted : null;
84
86
  }
85
- /** The collect options for the runners a tool grant covers, and for the rest. */
87
+ /**
88
+ * The collect options for the runners a tool grant covers, and for the rest.
89
+ * The two collections report as one: `onRunners` once, with both lists, and
90
+ * no report before it.
91
+ */
86
92
  function splitOptions(o, granted) {
93
+ // Granted first, then the others, whichever answers first.
94
+ const lists = [];
95
+ const early = [];
96
+ const ready = () => lists[0] !== undefined && lists[1] !== undefined;
97
+ const onReport = (report) => {
98
+ if (ready())
99
+ o.onReport?.(report);
100
+ else
101
+ early.push(report);
102
+ };
103
+ const onRunners = (slot) => (ids) => {
104
+ lists[slot] = ids;
105
+ if (!ready())
106
+ return;
107
+ o.onRunners?.([...(lists[0] ?? []), ...(lists[1] ?? [])]);
108
+ for (const report of early.splice(0))
109
+ o.onReport?.(report);
110
+ };
87
111
  const base = collectOptions(o);
88
112
  const { execWithheldHint: _hint, exclude: _exclude, ...rest } = base;
89
113
  return {
90
- granted: { ...rest, allowExec: true, only: granted },
91
- others: { ...base, exclude: [...(o.exclude ?? []), ...granted] },
114
+ granted: { ...rest, onReport, onRunners: onRunners(0), allowExec: true, only: granted },
115
+ others: {
116
+ ...base,
117
+ onReport,
118
+ onRunners: onRunners(1),
119
+ exclude: [...(o.exclude ?? []), ...granted],
120
+ },
92
121
  };
93
122
  }
94
123
  function mergeCatalogs(granted, others) {
95
124
  return { ...others, reports: [...granted.reports, ...others.reports] };
96
125
  }
97
- /** Detect, collect, and store each runner's result under `store`. */
126
+ /**
127
+ * Detect, collect, and store each runner's result under `store`. When a tool
128
+ * grant splits the runners in two, both collections settle before a failure
129
+ * is thrown.
130
+ */
98
131
  export async function collectAndCache(project, root, options, store) {
99
132
  const profile = await detect(project, root, options);
100
133
  const granted = grantedRunners(project, profile, options);
@@ -102,8 +135,8 @@ export async function collectAndCache(project, root, options, store) {
102
135
  return project.runners.collectAndCache(profile, store, collectOptions(options));
103
136
  }
104
137
  const split = splitOptions(options, granted);
105
- const a = await project.runners.collectAndCache(profile, store, split.granted);
106
- const b = await project.runners.collectAndCache(profile, store, split.others);
138
+ // At the same time, so a progress count covers both from the start.
139
+ const [a, b] = await settledBoth(project.runners.collectAndCache(profile, store, split.granted), project.runners.collectAndCache(profile, store, split.others));
107
140
  return mergeCatalogs(a, b);
108
141
  }
109
142
  /** Detect, then read what `store` holds, without running any runner. */
@@ -123,6 +156,15 @@ export async function readCachedCatalog(project, root, options, store) {
123
156
  : mergeCatalogs(a.catalog, b.catalog);
124
157
  return { catalog, runners: [...a.runners, ...b.runners], allFresh: a.allFresh && b.allFresh };
125
158
  }
159
+ /** Both results once both have settled; the first failure, if any, after both. */
160
+ export async function settledBoth(a, b) {
161
+ const [ra, rb] = await Promise.allSettled([a, b]);
162
+ if (ra.status === 'rejected')
163
+ throw ra.reason;
164
+ if (rb.status === 'rejected')
165
+ throw rb.reason;
166
+ return [ra.value, rb.value];
167
+ }
126
168
  /** True when something came out of the store, not only withheld reports. */
127
169
  export function fromStore(cached) {
128
170
  return cached.catalog !== null && cached.runners.some((r) => r.ageMs !== undefined);
@@ -132,6 +174,9 @@ export function fromStore(cached) {
132
174
  * git hooks) and, within a group, in the configured order.
133
175
  */
134
176
  export function orderedCatalog(catalog, order) {
135
- const reports = orderRunners(catalog.reports, order).sort((a, b) => groupRank(a.runner) - groupRank(b.runner));
136
- return { ...catalog, reports };
177
+ return { ...catalog, reports: inDisplayOrder(catalog.reports, order) };
178
+ }
179
+ /** `items` by group, and within a group in the configured order. */
180
+ export function inDisplayOrder(items, order) {
181
+ return orderRunners([...items], order).sort((a, b) => groupRank(a.runner) - groupRank(b.runner));
137
182
  }
@@ -44,7 +44,8 @@ export function abortOnSignals(parent) {
44
44
  export function browseCommand(home, opts = {}) {
45
45
  return kit.command({
46
46
  summary: 'the terminal UI; Enter runs the selected task',
47
- description: 'Type to filter. It starts from the stored probe, then refreshes. Needs a terminal; ' +
47
+ description: 'Type to filter. It starts from the last saved listing, then refreshes; with none, each ' +
48
+ 'runner shows as it answers. Needs a terminal; ' +
48
49
  '"list" and "query" answer a script.' +
49
50
  (opts.followOpen === true
50
51
  ? ' The bare command opens the web view instead when the user config sets open to "web".'
@@ -106,7 +107,8 @@ export function serveCommand(home, share) {
106
107
  'browser signed in to it. --no-open prints the URL instead. A reload stays signed in; for a ' +
107
108
  'new tab or another browser, press Enter in the terminal for a new sign-in link. Every action on the page is ' +
108
109
  'a command of this tool, called over HTTP with a token made for this run. It starts from ' +
109
- 'the stored probe, then refreshes. Ctrl-C stops it, and any probe it is running.',
110
+ 'the last saved listing, then refreshes; with none, the page shows each runner as it ' +
111
+ 'answers. Ctrl-C stops it, and any probe it is running.',
110
112
  positionals: [{ name: 'dir', help: 'the directory to inspect (beats -C)' }],
111
113
  flags: {
112
114
  port: { kind: 'string', valueName: 'N', help: 'a fixed port (default: an OS-assigned one)' },
@@ -4,10 +4,10 @@
4
4
  * `--json` is the catalog document.
5
5
  */
6
6
  import { type TaskFilter } from '../core/filter.ts';
7
- import type { CatalogSnapshot } from '../core/session.ts';
7
+ import type { CatalogProgress, CatalogSnapshot, Session } from '../core/session.ts';
8
8
  import type { Unknown } from '../core/unknowns.ts';
9
9
  import type { CatalogDocument } from '../index.ts';
10
- import type { CatalogShare } from '../serve/catalog-share.ts';
10
+ import type { CatalogShare, ProgressSink } from '../serve/catalog-share.ts';
11
11
  /** The catalog document without its `schemaVersion` and `kind`. */
12
12
  export type CatalogBody = Omit<CatalogDocument, 'schemaVersion' | 'kind'>;
13
13
  /**
@@ -25,6 +25,18 @@ export declare function sourceOf(snapshot: Pick<CatalogSnapshot, 'catalog' | 'or
25
25
  source: 'fresh' | 'cached';
26
26
  storedAt: string | null;
27
27
  };
28
+ /**
29
+ * The largest progress line, in UTF-16 code units of its JSON. A runner
30
+ * whose line would be larger is sent without its report, as `omitted`; its
31
+ * rows come with the catalog document.
32
+ */
33
+ export declare const MAX_PROGRESS_LINE: number;
34
+ /**
35
+ * A {@link CatalogProgress} that sends `session`'s probe as progress lines:
36
+ * the runners first, in the order the catalog will list them, then each
37
+ * runner as it answers, with its unknowns.
38
+ */
39
+ export declare function progressLines(session: Session, emit: ProgressSink, maxLine?: number): CatalogProgress;
28
40
  /**
29
41
  * Make the `list` command. `home` is the base for config, trust and cache
30
42
  * paths. `share` is the web view's held catalog (see `catalog-share.ts`).
@@ -35,6 +47,10 @@ export declare function listCommand(home: string, share?: CatalogShare): import(
35
47
  hidden: true;
36
48
  help: string;
37
49
  };
50
+ progress: {
51
+ kind: "boolean";
52
+ help: string;
53
+ };
38
54
  cached: {
39
55
  readonly kind: "boolean";
40
56
  readonly help: "answer from the last saved listing (files unchecked), else the stored probe; stderr says which";
@@ -3,10 +3,11 @@
3
3
  * Copy puts on the clipboard, then one `/<name>` line per agent skill;
4
4
  * `--json` is the catalog document.
5
5
  */
6
+ import { inDisplayOrder } from "../catalog.js";
6
7
  import { documentGroups } from "../groups.js";
7
8
  import { filterTasks } from "../core/filter.js";
8
9
  import { filterSkills, skillLine } from "../core/skills.js";
9
- import { CATALOG_DOCUMENT_VERSION, CatalogOutput } from "../documents.js";
10
+ import { CATALOG_DOCUMENT_VERSION, CatalogOutput, CatalogProgressOutput, } from "../documents.js";
10
11
  import { taskLine } from "../core/copy-text.js";
11
12
  import { terminalSafe } from "../terminal-text.js";
12
13
  import { FILTER_FLAGS, filterFrom, kit, noteUnknowns, openSession } from "./shared.js";
@@ -52,6 +53,36 @@ export function sourceOf(snapshot) {
52
53
  ? { source: 'cached', storedAt: snapshot.catalog.generatedAt }
53
54
  : { source: 'fresh', storedAt: null };
54
55
  }
56
+ /**
57
+ * The largest progress line, in UTF-16 code units of its JSON. A runner
58
+ * whose line would be larger is sent without its report, as `omitted`; its
59
+ * rows come with the catalog document.
60
+ */
61
+ export const MAX_PROGRESS_LINE = 1024 * 1024;
62
+ /**
63
+ * A {@link CatalogProgress} that sends `session`'s probe as progress lines:
64
+ * the runners first, in the order the catalog will list them, then each
65
+ * runner as it answers, with its unknowns.
66
+ */
67
+ export function progressLines(session, emit, maxLine = MAX_PROGRESS_LINE) {
68
+ let pending = [];
69
+ let total = 0;
70
+ return {
71
+ onRunners(runners) {
72
+ pending = inDisplayOrder(runners.map((runner) => ({ runner })), session.runnerOrder()).map((r) => r.runner);
73
+ total = runners.length;
74
+ emit({ pending: [...pending], total });
75
+ },
76
+ onRunner(report, cache) {
77
+ pending = pending.filter((r) => r !== report.runner);
78
+ const unknowns = session.unknowns({ catalog: { reports: [report] }, cache: [cache] });
79
+ const line = { pending: [...pending], total, report, cache, unknowns };
80
+ emit(JSON.stringify(line).length <= maxLine
81
+ ? line
82
+ : { pending: [...pending], total, omitted: report.runner });
83
+ },
84
+ };
85
+ }
55
86
  /** Every task in the document, in catalog order. */
56
87
  function documentTasks(doc) {
57
88
  return doc.reports.flatMap((r) => r.tasks);
@@ -65,7 +96,8 @@ export function listCommand(home, share) {
65
96
  summary: 'the whole catalog: one pasteable command line per task, or the catalog document with --json',
66
97
  description: 'Each task line is the command Copy gives, quoted and with a cd when the task runs from ' +
67
98
  'its own directory, so it pastes into a shell; "run" takes that line or the task id, which ' +
68
- '--json shows. --output jsonl prints one runner report per line; "query" with no terms ' +
99
+ '--json shows. --output jsonl prints one runner report per line; with --progress it first ' +
100
+ 'prints a catalog-progress line as each runner answers. "query" with no terms ' +
69
101
  'prints one task per line. ' +
70
102
  'Probes every runner, so a script gets what the repository has now. --cached answers at ' +
71
103
  'once with the last listing saved under the same trust and settings, and does not check ' +
@@ -86,10 +118,16 @@ export function listCommand(home, share) {
86
118
  hidden: true,
87
119
  help: 'in the web view, answer with a probe already running for the same catalog',
88
120
  },
121
+ progress: {
122
+ kind: 'boolean',
123
+ help: 'send a catalog-progress line as each runner answers, before the document: with ' +
124
+ '--output jsonl, or as NDJSON over HTTP',
125
+ },
89
126
  },
90
127
  output: CatalogOutput,
91
128
  kind: 'catalog',
92
129
  schemaVersion: CATALOG_DOCUMENT_VERSION,
130
+ events: { schema: CatalogProgressOutput, kind: 'catalog-progress' },
93
131
  items: { field: 'reports', kind: 'report' },
94
132
  readOnly: true,
95
133
  examples: ['list', 'list --json', 'list --services', '-C ../repo list --cached --json'],
@@ -99,22 +137,35 @@ export function listCommand(home, share) {
99
137
  // A shared probe outlives the request that started it, so the session
100
138
  // runs on the share's signal; this request's own is passed to the share.
101
139
  const session = await openSession(globals, sharing ? { ...ctx, signal: share.signal } : ctx, home, positionals[0]);
102
- const read = async (cached, signal) => {
103
- const snapshot = await session.catalog({ cached, signal });
140
+ // Progress lines only when asked for, so --output jsonl is unchanged.
141
+ const own = flags.progress ? (line) => ctx.emit(line) : undefined;
142
+ const read = async (cached, signal, emit) => {
143
+ const snapshot = await session.catalog({
144
+ cached,
145
+ signal,
146
+ ...(emit !== undefined ? { progress: progressLines(session, emit) } : {}),
147
+ });
104
148
  const unknowns = session.unknowns(snapshot);
105
149
  noteUnknowns(ctx, session, snapshot, unknowns);
106
150
  return catalogDocument(snapshot, unknowns, filter, session.settings().trustedTools);
107
151
  };
108
152
  if (sharing) {
109
153
  const key = session.viewKey();
110
- if (flags.cached)
111
- return share.cached(key) ?? read(true, ctx.signal);
112
- return share.fresh(key, (signal) => read(false, signal), {
113
- join: flags.join,
154
+ const shared = (join) => share.fresh(key, (signal, emit) => read(false, signal, emit), {
155
+ join,
114
156
  signal: ctx.signal,
157
+ onEvent: own,
115
158
  });
159
+ if (flags.cached) {
160
+ // With nothing held yet, the probe serve started is the answer.
161
+ const held = share.cached(key);
162
+ if (held !== null)
163
+ return held;
164
+ return share.probing(key) ? shared(true) : read(true, ctx.signal, own);
165
+ }
166
+ return shared(flags.join);
116
167
  }
117
- return read(flags.cached);
168
+ return read(flags.cached, undefined, own);
118
169
  },
119
170
  text(doc) {
120
171
  const lines = [
package/dist/config.d.ts CHANGED
@@ -61,9 +61,10 @@ import { type SkillsSetting } from './core/skills.ts';
61
61
  export { CONFIG_ENV_VAR, PROJECT_CONFIG_FILENAME, USER_CONFIG_FILENAME };
62
62
  /**
63
63
  * The URL a written file's `$schema` names: the schema this release line ships
64
- * in `schema/config.json`. Raise it with each minor release.
64
+ * in `schema/config.json`. Raise it with each minor release, here, in
65
+ * `schema/config.json` and in the configuration guide; tests check all three.
65
66
  */
66
- export declare const CONFIG_SCHEMA_URL = "https://unpkg.com/@osdlc/wayfinder@0.8/schema/config.json";
67
+ export declare const CONFIG_SCHEMA_URL = "https://unpkg.com/@osdlc/wayfinder@0.9/schema/config.json";
67
68
  /** The `discovery` values. */
68
69
  export declare const DISCOVERY_VALUES: readonly ["git", "walk", "auto"];
69
70
  /** The `open` values: what the bare `way` command opens. */
package/dist/config.js CHANGED
@@ -66,9 +66,10 @@ import { SKILLS_SETTING_VALUES } from "./core/skills.js";
66
66
  export { CONFIG_ENV_VAR, PROJECT_CONFIG_FILENAME, USER_CONFIG_FILENAME };
67
67
  /**
68
68
  * The URL a written file's `$schema` names: the schema this release line ships
69
- * in `schema/config.json`. Raise it with each minor release.
69
+ * in `schema/config.json`. Raise it with each minor release, here, in
70
+ * `schema/config.json` and in the configuration guide; tests check all three.
70
71
  */
71
- export const CONFIG_SCHEMA_URL = 'https://unpkg.com/@osdlc/wayfinder@0.8/schema/config.json';
72
+ export const CONFIG_SCHEMA_URL = 'https://unpkg.com/@osdlc/wayfinder@0.9/schema/config.json';
72
73
  const strings = (description) => z.array(z.string()).describe(description);
73
74
  /** One set of trust rules: globs over the resolved root, and origin owners. */
74
75
  const TrustRulesSchema = z.object({
@@ -3,7 +3,7 @@
3
3
  * and the operations every surface shares. See `README.md` beside this file
4
4
  * for how the CLI, the terminal UI and the web view use it.
5
5
  */
6
- import type { Catalog, Project, RunnerCacheState, Task } from '@osdlc/system-model/detect';
6
+ import type { Catalog, Project, RunnerCacheState, RunnerReport, Task } from '@osdlc/system-model/detect';
7
7
  import { type ExecGate } from '@osdlc/trust-repo';
8
8
  import { type WayOptions } from '../catalog.ts';
9
9
  import { type LoadedConfig, type Settings } from '../config.ts';
@@ -59,6 +59,20 @@ export type CacheState = RunnerCacheState & {
59
59
  /** How long this runner's probe took, when it was probed in this call. */
60
60
  probeMs?: number | undefined;
61
61
  };
62
+ /**
63
+ * What a probe reports while it runs, so a surface can draw each runner as
64
+ * it answers. See {@link Session.catalog}.
65
+ */
66
+ export interface CatalogProgress {
67
+ /** Once, before any runner answers: every runner this call probes. */
68
+ onRunners?(runners: readonly string[]): void;
69
+ /**
70
+ * Once per runner, as it answers, a withheld runner included: its report
71
+ * and its cache state. The snapshot `catalog` resolves with is still the
72
+ * answer to show; it can add a diagnostic this report lacks.
73
+ */
74
+ onRunner?(report: RunnerReport, cache: CacheState): void;
75
+ }
62
76
  /** A catalog and where each runner's rows came from. */
63
77
  export interface CatalogSnapshot {
64
78
  /** Grouped and in the configured runner order. */
@@ -162,10 +176,13 @@ export interface Session {
162
176
  * checks each runner's files, and probes only the runners missing from it.
163
177
  * A probe always writes the store. `signal`
164
178
  * stops this call's probes as well as the session's own signal.
179
+ * `progress` hears about each runner this call probes as it answers; an
180
+ * answer from the saved view or the store probes none.
165
181
  */
166
182
  catalog(opts?: {
167
183
  cached?: boolean;
168
184
  signal?: AbortSignal | undefined;
185
+ progress?: CatalogProgress | undefined;
169
186
  }): Promise<CatalogSnapshot>;
170
187
  /**
171
188
  * The catalog from the store alone, probing nothing: for a first paint
@@ -196,11 +213,14 @@ export interface Session {
196
213
  */
197
214
  viewKey(): string;
198
215
  /** The tasks of `catalog` that pass `filter`, best first when there is a query. */
199
- search(catalog: Catalog, filter: TaskFilter): TaskHit[];
216
+ search(catalog: Pick<Catalog, 'reports'>, filter: TaskFilter): TaskHit[];
200
217
  /** The skills that pass `filter`, matched as {@link search} matches tasks. */
201
218
  searchSkills(skills: readonly SkillRow[], filter: TaskFilter): SkillHit[];
202
219
  /** Everything this session could not know about `snapshot`. */
203
- unknowns(snapshot: Pick<CatalogSnapshot, 'catalog' | 'cache'>): Unknown[];
220
+ unknowns(snapshot: {
221
+ catalog: Pick<Catalog, 'reports'>;
222
+ cache: readonly CacheState[];
223
+ }): Unknown[];
204
224
  /** Whether a trust grant would change this session's execution. */
205
225
  trustable(): boolean;
206
226
  /**
@@ -249,7 +269,7 @@ export interface Session {
249
269
  * {@link SessionError}: `task-not-found`, `ambiguous-task`, `not-runnable` or
250
270
  * `bad-arguments`.
251
271
  */
252
- resolveRun(catalog: Catalog, id: string, args?: readonly string[]): RunPlan;
272
+ resolveRun(catalog: Pick<Catalog, 'reports'>, id: string, args?: readonly string[]): RunPlan;
253
273
  }
254
274
  /**
255
275
  * Start a session: find the root, load config, decide execution against the
@@ -259,4 +279,4 @@ export interface Session {
259
279
  */
260
280
  export declare function createSession(opts: SessionOptions): Promise<Session>;
261
281
  /** See {@link Session.resolveRun}. */
262
- export declare function resolveRun(project: Project, root: string, catalog: Catalog, id: string, args?: readonly string[]): RunPlan;
282
+ export declare function resolveRun(project: Project, root: string, catalog: Pick<Catalog, 'reports'>, id: string, args?: readonly string[]): RunPlan;
@@ -10,7 +10,7 @@ import { homeDir, parseTrustScope, policyExecGate, withheldHint, } from '@osdlc/
10
10
  import { BIN, PROJECT_CONFIG_FILENAME } from "../app.js";
11
11
  import { cacheDir } from "../cache.js";
12
12
  import { settingLayer } from "../config-keys.js";
13
- import { collectAndCache, fromStore, makeProject, orderedCatalog, projectRootFor, readCachedCatalog, runnerIds, } from "../catalog.js";
13
+ import { collectAndCache, 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";
@@ -111,19 +111,20 @@ function asSessionError(err, prefix = '') {
111
111
  return new SessionError('config', prefix + err.message);
112
112
  return err;
113
113
  }
114
+ /** The fresh state of a runner probed just now, with its measured time when it ran. */
115
+ function probedState(runner, probeMs) {
116
+ return {
117
+ runner,
118
+ state: 'fresh',
119
+ ageMs: 0,
120
+ estimateMs: probeMs ?? null,
121
+ slow: false,
122
+ ...(probeMs !== undefined ? { probeMs } : {}),
123
+ };
124
+ }
114
125
  /** Fresh states for a catalog probed just now, with each runner's measured time. */
115
126
  function probedStates(catalog, times) {
116
- return catalog.reports.map((r) => {
117
- const probeMs = times.get(r.runner);
118
- return {
119
- runner: r.runner,
120
- state: 'fresh',
121
- ageMs: 0,
122
- estimateMs: probeMs ?? null,
123
- slow: false,
124
- ...(probeMs !== undefined ? { probeMs } : {}),
125
- };
126
- });
127
+ return catalog.reports.map((r) => probedState(r.runner, times.get(r.runner)));
127
128
  }
128
129
  /**
129
130
  * Start a session: find the root, load config, decide execution against the
@@ -237,13 +238,21 @@ export async function createSession(opts) {
237
238
  const signals = [options.signal, signal].filter((s) => s !== undefined);
238
239
  return signals.length > 0 ? { ...options, signal: AbortSignal.any(signals) } : options;
239
240
  };
240
- /** Probe the runners `only` names (all when absent), timing each. */
241
- const probe = async (only, signal) => {
241
+ /** Probe the runners `only` names (all when absent), timing each and telling `progress`. */
242
+ const probe = async (only, signal, progress) => {
242
243
  const times = new Map();
243
244
  const catalog = await collectAndCache(project, root, {
244
245
  ...withSignal(signal),
245
246
  ...(only !== undefined ? { only } : {}),
246
247
  onProbe: ({ runner, durationMs }) => times.set(runner, durationMs),
248
+ ...(progress?.onRunners !== undefined
249
+ ? { onRunners: (runners) => progress.onRunners?.(runners) }
250
+ : {}),
251
+ ...(progress?.onRunner !== undefined
252
+ ? {
253
+ onReport: (report) => progress.onRunner?.(report, probedState(report.runner, times.get(report.runner))),
254
+ }
255
+ : {}),
247
256
  }, store);
248
257
  return { catalog, times };
249
258
  };
@@ -299,11 +308,13 @@ export async function createSession(opts) {
299
308
  },
300
309
  async catalog(opts = {}) {
301
310
  if (opts.cached !== true) {
302
- const { catalog, times } = await probe(undefined, opts.signal);
311
+ // The skills are read beside the probe, so the answer does not wait
312
+ // for both in turn. Both settle before a failure is thrown.
313
+ const [{ catalog, times }, skillRows] = await settledBoth(probe(undefined, opts.signal, opts.progress), skills());
303
314
  return saved({
304
315
  catalog: orderedCatalog(catalog, runnerOrder()),
305
316
  cache: probedStates(catalog, times),
306
- skills: await skills(),
317
+ skills: skillRows,
307
318
  origin: 'probe',
308
319
  });
309
320
  }
@@ -313,7 +324,7 @@ export async function createSession(opts) {
313
324
  // The call's signal too: a closed tab stops hashing the store.
314
325
  const stored = await readCachedCatalog(project, root, withSignal(opts.signal), store);
315
326
  if (stored.catalog === null || !fromStore(stored)) {
316
- const { catalog, times } = await probe(undefined, opts.signal);
327
+ const { catalog, times } = await probe(undefined, opts.signal, opts.progress);
317
328
  return saved({
318
329
  catalog: orderedCatalog(catalog, runnerOrder()),
319
330
  cache: probedStates(catalog, times),
@@ -331,6 +342,8 @@ export async function createSession(opts) {
331
342
  origin: 'store',
332
343
  });
333
344
  }
345
+ // No progress here: it would name only the missing runners, while the
346
+ // stored ones wait for the document.
334
347
  const { catalog: probed, times } = await probe(missing, opts.signal);
335
348
  const fresh = new Map(probedStates(probed, times).map((s) => [s.runner, s]));
336
349
  return saved({