@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.
Files changed (61) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/CONTRIBUTING.md +6 -1
  3. package/README.md +31 -11
  4. package/dist/args.d.ts +7 -8
  5. package/dist/args.js +7 -8
  6. package/dist/catalog.d.ts +26 -3
  7. package/dist/catalog.js +65 -12
  8. package/dist/clean-command.d.ts +3 -1
  9. package/dist/clean-command.js +23 -11
  10. package/dist/cli.js +3 -3
  11. package/dist/commands/browse.js +4 -2
  12. package/dist/commands/index.js +1 -1
  13. package/dist/commands/list.d.ts +21 -2
  14. package/dist/commands/list.js +85 -9
  15. package/dist/commands/query.js +1 -1
  16. package/dist/commands/run.js +1 -1
  17. package/dist/commands/shared.js +2 -1
  18. package/dist/config-keys.d.ts +4 -0
  19. package/dist/config-keys.js +4 -0
  20. package/dist/config.d.ts +24 -9
  21. package/dist/config.js +64 -18
  22. package/dist/core/run.d.ts +2 -1
  23. package/dist/core/run.js +10 -2
  24. package/dist/core/saved-view.d.ts +2 -7
  25. package/dist/core/saved-view.js +5 -12
  26. package/dist/core/session.d.ts +32 -6
  27. package/dist/core/session.js +86 -36
  28. package/dist/core/writes.d.ts +13 -0
  29. package/dist/core/writes.js +22 -0
  30. package/dist/document-schemas.generated.js +6 -0
  31. package/dist/documents.d.ts +90 -1
  32. package/dist/documents.js +39 -12
  33. package/dist/guide.js +2 -2
  34. package/dist/index.d.ts +8 -2
  35. package/dist/index.js +8 -5
  36. package/dist/providers-command.d.ts +2 -2
  37. package/dist/schema.d.ts +1 -1
  38. package/dist/schema.js +1 -1
  39. package/dist/serve/auth.js +3 -16
  40. package/dist/serve/catalog-share.d.ts +13 -1
  41. package/dist/serve/catalog-share.js +42 -3
  42. package/dist/serve/index.d.ts +5 -3
  43. package/dist/serve/index.js +20 -12
  44. package/dist/serve/routes.d.ts +1 -1
  45. package/dist/serve/routes.js +1 -26
  46. package/dist/terminal-text.d.ts +4 -4
  47. package/dist/terminal-text.js +17 -12
  48. package/dist/tool-info.d.ts +2 -2
  49. package/dist/tools.js +1 -1
  50. package/dist/tui/app.d.ts +15 -2
  51. package/dist/tui/app.js +189 -43
  52. package/dist/tui/index.js +3 -3
  53. package/dist/vocabulary.d.ts +7 -1
  54. package/dist/vocabulary.js +5 -1
  55. package/dist/web/main.js +345 -59
  56. package/dist/web/page.html +2 -0
  57. package/dist/web/styles.css +56 -0
  58. package/dist/xdg.d.ts +0 -7
  59. package/dist/xdg.js +0 -14
  60. package/package.json +16 -14
  61. package/schema/config.json +14 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,105 @@
1
1
  # @osdlc/wayfinder
2
2
 
3
+ ## 0.11.1
4
+
5
+ ### Patch Changes
6
+
7
+ - a4a2021: The `$schema` URL that `way config set` writes, and the `$id` of the shipped `schema/config.json`, now follow the package version's `major.minor`, so they name `@osdlc/wayfinder@0.11` in this release line. They had stayed at `0.10`. `CONFIG_SCHEMA_URL` is now typed `string` instead of a string literal.
8
+
9
+ ## 0.11.0
10
+
11
+ ### Minor Changes
12
+
13
+ - da5e6a3: `way clean` now compares real paths, through `@osdlc/path-guard` (a new runtime dependency), when it checks a store against the home directory, against another store, and when it prunes empty directories above a removed store. A store that holds the home directory only through a symbolic link above it (a store under `~/alias/...` where `alias` links to a directory that holds the home) is no longer removed. Two stores that overlap only through a symbolic link now need `--yes`, and an old pre-release path that reaches a current store through a link is no longer listed as old.
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [da5e6a3]
18
+ - Updated dependencies [da5e6a3]
19
+ - Updated dependencies [da5e6a3]
20
+ - @osdlc/command-seam@0.14.0
21
+ - @osdlc/typed-git@0.10.0
22
+ - @osdlc/detect-harness@0.7.0
23
+ - @osdlc/cli-tool@0.10.1
24
+ - @osdlc/system-model@0.7.1
25
+ - @osdlc/trust-repo@0.5.1
26
+
27
+ ## 0.10.1
28
+
29
+ ### Patch Changes
30
+
31
+ - e5265bc: Clearer wording in the README and the terminal UI and web view guides about the skills progress line and the runner time limit.
32
+
33
+ ## 0.10.0
34
+
35
+ ### Minor Changes
36
+
37
+ - b835ae4: `way clean` no longer removes a store that holds the home directory under a directory whose name starts with `..` (such as `..x`). `way --cached --no-exec` now re-probes a runner whose stored rows were taken with exec allowed, instead of reporting it as fresh with no tasks.
38
+ Through `@osdlc/cli-tool` and `@osdlc/command-seam`, a working directory that cannot be entered now exits with the `repository` code instead of `missingTool`.
39
+ Behaviour change (stricter): a task handed the terminal (`way run`, the terminal UI, the web view's Run) whose program is a bare name now runs it only from an absolute `PATH` entry; a relative entry, which would find a file the repository ships, is skipped and the run fails as a missing binary. A path such as `./gradlew` runs as given. The web view's "handed off" message quotes the command line as the copy text does.
40
+ `~` expansion of the user config path and of tool module paths now uses `@osdlc/tiered-dirs`'s `expandTilde`; the result on each platform is unchanged.
41
+ The JSON documents' schemas take every enum that names a `@osdlc/system-model` value (group ids, cache states and stale reasons, probe costs, parameters-unknown reasons, match modes, tool roles and runner kinds) from system-model's `ALL_*` lists instead of a copy, so a value system-model adds is accepted. The values are unchanged; in the `providers` document's schema the role enum now lists `packageManager` first, in system-model's order. The terminal filter's control-character set comes from `@osdlc/ux`'s `controlPattern`; the characters it replaces are unchanged.
42
+ `way config get` of a key under a listed setting returns the nested value instead of exiting 1.
43
+ Behaviour change (through `@osdlc/cli-tool`): `way config get` and `way config unset` of an unknown key exit 2 (a usage error, with a did-you-mean) instead of 1, as `set` and `explain` already did. `way config get` of a key under a listed setting reads it from that setting's value.
44
+ - ebd5328: Loading finishes sooner and a hung tool no longer holds it up.
45
+
46
+ - New setting `runners.timeout`: how many seconds one runner may take to list its tasks, its subprocesses included. Set it in your user config (`way config set --user runners.timeout 20`), from 1 to 3600. A project file, or the web view's settings page, can only lower the limit: each runner takes the smaller of the project value and its own limit (or your user value). A project value above your user value is ignored with a warning. A runner still running then is stopped, the processes it started are killed, and it shows `timed out after 20 s` in place, in the terminal UI, the web view and `list --json`, like any failed runner. Unset or `null`, each runner has its own limit (10 s for just, 120 s for moon, 60 s for most). That limit now bounds the whole probe, not only each subprocess.
47
+ - The agent skills and the Skills tab appear while the runners load, not at the end. `list --progress` sends them on a `catalog-progress` line of their own, with `skills`, filtered like the final document. The terminal UI shows them with the first task rows, below them.
48
+ - The final status shows as soon as the last runner answers. The store is written after that, in the background, and every normal exit waits for it. A kill during the write leaves the old entry in place.
49
+ - Library: `CatalogProgress.onSkills`, called once as soon as the skills are read.
50
+ - The config file's `$schema` URL moves to `@osdlc/wayfinder@0.10`.
51
+
52
+ ### Patch Changes
53
+
54
+ - Updated dependencies [b835ae4]
55
+ - Updated dependencies [b835ae4]
56
+ - Updated dependencies [b835ae4]
57
+ - Updated dependencies [b835ae4]
58
+ - Updated dependencies [b835ae4]
59
+ - Updated dependencies [b835ae4]
60
+ - Updated dependencies [b835ae4]
61
+ - Updated dependencies [b835ae4]
62
+ - Updated dependencies [b835ae4]
63
+ - Updated dependencies [b835ae4]
64
+ - Updated dependencies [ebd5328]
65
+ - Updated dependencies [fdef74f]
66
+ - @osdlc/cli-tool@0.10.0
67
+ - @osdlc/command-seam@0.13.0
68
+ - @osdlc/config-layers@0.8.0
69
+ - @osdlc/detect-harness@0.6.0
70
+ - @osdlc/etag-write@0.3.0
71
+ - @osdlc/system-model@0.7.0
72
+ - @osdlc/tiered-dirs@0.5.0
73
+ - @osdlc/trust-repo@0.5.0
74
+ - @osdlc/typed-git@0.9.0
75
+ - @osdlc/ux@0.1.1
76
+
77
+ ## 0.9.0
78
+
79
+ ### Minor Changes
80
+
81
+ - 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.
82
+
83
+ - **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.
84
+ - **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…`.
85
+ - **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.
86
+ - **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.
87
+ - `list --json` and `list --output jsonl` print what they printed before.
88
+ - With a grant for one tool, the trusted and the withheld runners are now collected at the same time.
89
+
90
+ ### Patch Changes
91
+
92
+ - df47065: The config file's `$schema` URL now names the 0.9 release line. Point an existing `$schema` at
93
+ `https://unpkg.com/@osdlc/wayfinder@0.9/schema/config.json`; the 0.8 URL keeps working.
94
+ - Updated dependencies [7addea1]
95
+ - Updated dependencies [f013f38]
96
+ - Updated dependencies [f6993bf]
97
+ - Updated dependencies [f013f38]
98
+ - @osdlc/cli-tool@0.9.1
99
+ - @osdlc/command-seam@0.12.1
100
+ - @osdlc/system-model@0.6.0
101
+ - @osdlc/typed-git@0.8.2
102
+
3
103
  ## 0.8.0
4
104
 
5
105
  ### Minor Changes
package/CONTRIBUTING.md CHANGED
@@ -23,7 +23,8 @@ work in the package directory. The tests run on [Vitest](https://vitest.dev)
23
23
  under Node 22.22.2 or later. They build throwaway repositories in a temp
24
24
  directory, need `git` on the PATH, and need no network. The package imports its
25
25
  sibling libraries through their built `dist/`, so run `pnpm run build` at the
26
- repository root first.
26
+ repository root first, and again after a pull. The suite stops before any test
27
+ runs when a sibling's `dist/` is missing or older than its `src/`, and names it.
27
28
 
28
29
  ```sh
29
30
  pnpm install
@@ -44,6 +45,10 @@ diff.
44
45
  test` includes it. After a deliberate change to the output, regenerate them
45
46
  with `pnpm run test:e2e -u` and review the diff.
46
47
 
48
+ After a change to the config schema, run `pnpm run build`, then `pnpm run
49
+ write:config-schema`, and commit `schema/config.json` and
50
+ `docs/guide/configuration.md`.
51
+
47
52
  Other checks:
48
53
 
49
54
  ```sh
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
@@ -446,8 +447,8 @@ runners to skip, what order to show them in, whether execution is allowed, and
446
447
  how files are discovered. The layers, lowest precedence first: built-in
447
448
  defaults, the user file (`~/.config/wayfinder/config.json` by default),
448
449
  `wayfinder.config.json` at the project root, then the flags on the command
449
- line. `trust`, `open`, `theme` and `skills` count only in the user file, and a
450
- project file can lower `allowExec` but never raise it.
450
+ line. `trust`, `open`, `theme` and `skills` count only in the user file. A
451
+ project file can lower `allowExec` and `runners.timeout` but never raise them.
451
452
 
452
453
  ```text
453
454
  way config list [--json] every setting, and the layer it came from
@@ -528,6 +529,20 @@ 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. The agent skills come on a line
540
+ of their own, in `skills`, as soon as they are read, filtered like the
541
+ document. With no skills, or too many for one line, they come only with the
542
+ document. Over HTTP, `way serve` sends the
543
+ same lines as NDJSON when the request asks for `application/x-ndjson`, with
544
+ the catalog document last. `way schema` describes the line.
545
+
531
546
  ### Old flags
532
547
 
533
548
  These still work in this release and will be removed in a later one:
@@ -637,11 +652,16 @@ probe store. Nothing in the repository runs unless it is trusted and
637
652
  execution is allowed. It throws `SessionError` with a `code` for a directory
638
653
  that does not exist, a config file that cannot be used, or a tool module that
639
654
  cannot be loaded. `onWarning` gets each warning the CLI prints on stderr,
640
- such as a project file key that is ignored.
655
+ such as a project file key that is ignored. `progress` hears about each
656
+ runner as it answers: `onRunners(ids)` once, then `onRunner(report, cache)`
657
+ per runner, withheld ones included, so a caller can show the catalog before
658
+ the slowest runner is done. `onSkills(skills)` comes once, as soon as the
659
+ agent skills are read. `buildCatalog` resolves once the store and the saved
660
+ view are written.
641
661
 
642
662
  | Export | Is |
643
663
  |---|---|
644
- | `buildCatalog`, `BuildCatalogOptions`, `CatalogDocument`, `SessionFlags`, `CacheState` | the catalog for a directory, the flags it takes and each runner's cache verdict |
664
+ | `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
665
  | `filterTasks`, `keepsTask`, `sourceDepth`, `hasQuery`, `TaskFilter`, `TaskHit`, `Mode` | the search and filters every surface uses |
646
666
  | `filterSkills`, `skillLine`, `SkillRow`, `SkillHit`, `SkillsSetting`, `SKILLS_SETTING_VALUES` | the Skills group |
647
667
  | `GROUPS`, `SKILLS_GROUP`, `groupOf`, `catalogGroups`, `documentGroups`, `Group`, `GroupId`, `DocumentGroup` | the groups and their order |
package/dist/args.d.ts CHANGED
@@ -2,10 +2,10 @@
2
2
  * Turns typed trailing arguments into argv entries. The terminal's entry line
3
3
  * and the page's run bar share it, so the two always split quotes the same way.
4
4
  *
5
- * {@link runArgv} and {@link acceptArgs} decide what a caller may add to a
6
- * spawn and what it may not. As pure functions they can be tested. The route
7
- * they protect cannot, because a successful call hands over the terminal and
8
- * exits the process.
5
+ * {@link runArgv} and {@link acceptArgs} are pure helpers only the tests call.
6
+ * The web view's `/run` does not go through them: serve/routes.ts validates
7
+ * its body (a non-string argument is a 400), and session.resolveRun pins the
8
+ * binary with its own check over `runners.invocation`.
9
9
  */
10
10
  import type { Project, Task } from '@osdlc/system-model/detect';
11
11
  /**
@@ -14,10 +14,9 @@ import type { Project, Task } from '@osdlc/system-model/detect';
14
14
  * `--`.
15
15
  *
16
16
  * The binary is always `task.argv[0]`, from a catalog this process built by
17
- * reading the repository, never from a request. The web view's `/run` is reachable by any
18
- * process on the machine and any site the browser visits, so a caller that
19
- * could set element 0 could run anything. A tool whose `invoke` changes the
20
- * binary is refused.
17
+ * reading the repository, never from a request. A tool whose `invoke` changes
18
+ * the binary is refused. The live `/run` path makes the same check in
19
+ * session.resolveRun, not here.
21
20
  */
22
21
  export declare function runArgv(project: Project, task: Task, args?: readonly string[]): string[];
23
22
  /**
package/dist/args.js CHANGED
@@ -2,10 +2,10 @@
2
2
  * Turns typed trailing arguments into argv entries. The terminal's entry line
3
3
  * and the page's run bar share it, so the two always split quotes the same way.
4
4
  *
5
- * {@link runArgv} and {@link acceptArgs} decide what a caller may add to a
6
- * spawn and what it may not. As pure functions they can be tested. The route
7
- * they protect cannot, because a successful call hands over the terminal and
8
- * exits the process.
5
+ * {@link runArgv} and {@link acceptArgs} are pure helpers only the tests call.
6
+ * The web view's `/run` does not go through them: serve/routes.ts validates
7
+ * its body (a non-string argument is a 400), and session.resolveRun pins the
8
+ * binary with its own check over `runners.invocation`.
9
9
  */
10
10
  /**
11
11
  * The argv a task runs with: the caller's arguments bound the way the task's
@@ -13,10 +13,9 @@
13
13
  * `--`.
14
14
  *
15
15
  * The binary is always `task.argv[0]`, from a catalog this process built by
16
- * reading the repository, never from a request. The web view's `/run` is reachable by any
17
- * process on the machine and any site the browser visits, so a caller that
18
- * could set element 0 could run anything. A tool whose `invoke` changes the
19
- * binary is refused.
16
+ * reading the repository, never from a request. A tool whose `invoke` changes
17
+ * the binary is refused. The live `/run` path makes the same check in
18
+ * session.resolveRun, not here.
20
19
  */
21
20
  export function runArgv(project, task, args = []) {
22
21
  if (args.length === 0)
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.
@@ -19,12 +19,24 @@ export interface WayOptions {
19
19
  execWithheldHint?: string | undefined;
20
20
  discovery?: DiscoveryMode | 'auto' | undefined;
21
21
  excludePaths?: string[] | undefined;
22
+ /**
23
+ * How long one runner may take to answer, its subprocesses included, in
24
+ * ms. Unset, each runner has its own limit. A runner past it is stopped
25
+ * and reports `timed out after <n> s`.
26
+ */
27
+ probeTimeoutMs?: number | undefined;
28
+ /** The longest any runner may take, in ms: it only lowers a limit. For a project file's value. */
29
+ maxProbeTimeoutMs?: number | undefined;
22
30
  signal?: AbortSignal | undefined;
23
31
  /** Called with each probed runner's measured time. */
24
32
  onProbe?: ((probe: {
25
33
  runner: string;
26
34
  durationMs: number;
27
35
  }) => void) | undefined;
36
+ /** Called once, before any runner answers, with every runner the collection reports. */
37
+ onRunners?: ((runners: readonly string[]) => void) | undefined;
38
+ /** Called with each runner's report as it answers, withheld runners included. */
39
+ onReport?: ((report: RunnerReport) => void) | undefined;
28
40
  /**
29
41
  * Per-tool trust, for a repository that is not trusted as a whole. Used
30
42
  * only while `allowExec` is false. See {@link ToolTrust}.
@@ -52,10 +64,17 @@ export declare function projectRootFor(dir: string): Promise<string | null>;
52
64
  export declare function makeProject(extra?: readonly ToolDef[]): Project;
53
65
  /** The ids of every registered tool with a runner role. */
54
66
  export declare function runnerIds(project: Project): string[];
55
- /** Detect, collect, and store each runner's result under `store`. */
56
- export declare function collectAndCache(project: Project, root: string, options: WayOptions, store: string): Promise<Catalog>;
67
+ /**
68
+ * Detect, collect, and store each runner's result under `store`. The catalog
69
+ * comes once every runner has answered; the store is written after, in the
70
+ * background, and `flushWrites` waits for it. When a tool grant splits the
71
+ * runners in two, both collections settle before a failure is thrown.
72
+ */
73
+ export declare function collectAndStore(project: Project, root: string, options: WayOptions, store: string): Promise<Catalog>;
57
74
  /** Detect, then read what `store` holds, without running any runner. */
58
75
  export declare function readCachedCatalog(project: Project, root: string, options: WayOptions, store: string): Promise<CachedCatalog>;
76
+ /** Both results once both have settled; the first failure, if any, after both. */
77
+ export declare function settledBoth<A, B>(a: Promise<A>, b: Promise<B>): Promise<[A, B]>;
59
78
  /** True when something came out of the store, not only withheld reports. */
60
79
  export declare function fromStore(cached: CachedCatalog): boolean;
61
80
  /**
@@ -63,3 +82,7 @@ export declare function fromStore(cached: CachedCatalog): boolean;
63
82
  * git hooks) and, within a group, in the configured order.
64
83
  */
65
84
  export declare function orderedCatalog(catalog: Catalog, order: string[] | undefined): Catalog;
85
+ /** `items` by group, and within a group in the configured order. */
86
+ export declare function inDisplayOrder<T extends {
87
+ runner: string;
88
+ }>(items: readonly T[], order: string[] | undefined): T[];
package/dist/catalog.js CHANGED
@@ -7,6 +7,7 @@ import { stat } from 'node:fs/promises';
7
7
  import { builtins } from '@osdlc/system-model/builtins';
8
8
  import { createProject, } from '@osdlc/system-model/detect';
9
9
  import { orderRunners } from "./config.js";
10
+ import { trackWrite } from "./core/writes.js";
10
11
  import { groupRank } from "./groups.js";
11
12
  /**
12
13
  * The project root `dir` is in, found with the built-in tools only. Null when
@@ -36,8 +37,12 @@ function collectOptions(o) {
36
37
  exclude: o.exclude,
37
38
  allowExec: o.allowExec ?? false,
38
39
  execWithheldHint: o.execWithheldHint,
40
+ probeTimeoutMs: o.probeTimeoutMs,
41
+ maxProbeTimeoutMs: o.maxProbeTimeoutMs,
39
42
  signal: o.signal,
40
43
  onProbe: o.onProbe,
44
+ onRunners: o.onRunners,
45
+ onReport: o.onReport,
41
46
  };
42
47
  }
43
48
  /**
@@ -82,28 +87,64 @@ function grantedRunners(project, profile, o) {
82
87
  .map(([runner]) => runner);
83
88
  return granted.length > 0 ? granted : null;
84
89
  }
85
- /** The collect options for the runners a tool grant covers, and for the rest. */
90
+ /**
91
+ * The collect options for the runners a tool grant covers, and for the rest.
92
+ * The two collections report as one: `onRunners` once, with both lists, and
93
+ * no report before it.
94
+ */
86
95
  function splitOptions(o, granted) {
96
+ // Granted first, then the others, whichever answers first.
97
+ const lists = [];
98
+ const early = [];
99
+ const ready = () => lists[0] !== undefined && lists[1] !== undefined;
100
+ const onReport = (report) => {
101
+ if (ready())
102
+ o.onReport?.(report);
103
+ else
104
+ early.push(report);
105
+ };
106
+ const onRunners = (slot) => (ids) => {
107
+ lists[slot] = ids;
108
+ if (!ready())
109
+ return;
110
+ o.onRunners?.([...(lists[0] ?? []), ...(lists[1] ?? [])]);
111
+ for (const report of early.splice(0))
112
+ o.onReport?.(report);
113
+ };
87
114
  const base = collectOptions(o);
88
115
  const { execWithheldHint: _hint, exclude: _exclude, ...rest } = base;
89
116
  return {
90
- granted: { ...rest, allowExec: true, only: granted },
91
- others: { ...base, exclude: [...(o.exclude ?? []), ...granted] },
117
+ granted: { ...rest, onReport, onRunners: onRunners(0), allowExec: true, only: granted },
118
+ others: {
119
+ ...base,
120
+ onReport,
121
+ onRunners: onRunners(1),
122
+ exclude: [...(o.exclude ?? []), ...granted],
123
+ },
92
124
  };
93
125
  }
94
126
  function mergeCatalogs(granted, others) {
95
127
  return { ...others, reports: [...granted.reports, ...others.reports] };
96
128
  }
97
- /** Detect, collect, and store each runner's result under `store`. */
98
- export async function collectAndCache(project, root, options, store) {
129
+ /**
130
+ * Detect, collect, and store each runner's result under `store`. The catalog
131
+ * comes once every runner has answered; the store is written after, in the
132
+ * background, and `flushWrites` waits for it. When a tool grant splits the
133
+ * runners in two, both collections settle before a failure is thrown.
134
+ */
135
+ export async function collectAndStore(project, root, options, store) {
99
136
  const profile = await detect(project, root, options);
100
137
  const granted = grantedRunners(project, profile, options);
101
- if (granted === null) {
102
- return project.runners.collectAndCache(profile, store, collectOptions(options));
103
- }
138
+ const collect = async (opts) => {
139
+ const { catalog, stored } = await project.runners.collectAndStore(profile, store, opts);
140
+ void trackWrite(stored);
141
+ return catalog;
142
+ };
143
+ if (granted === null)
144
+ return collect(collectOptions(options));
104
145
  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);
146
+ // At the same time, so a progress count covers both from the start.
147
+ const [a, b] = await settledBoth(collect(split.granted), collect(split.others));
107
148
  return mergeCatalogs(a, b);
108
149
  }
109
150
  /** Detect, then read what `store` holds, without running any runner. */
@@ -123,6 +164,15 @@ export async function readCachedCatalog(project, root, options, store) {
123
164
  : mergeCatalogs(a.catalog, b.catalog);
124
165
  return { catalog, runners: [...a.runners, ...b.runners], allFresh: a.allFresh && b.allFresh };
125
166
  }
167
+ /** Both results once both have settled; the first failure, if any, after both. */
168
+ export async function settledBoth(a, b) {
169
+ const [ra, rb] = await Promise.allSettled([a, b]);
170
+ if (ra.status === 'rejected')
171
+ throw ra.reason;
172
+ if (rb.status === 'rejected')
173
+ throw rb.reason;
174
+ return [ra.value, rb.value];
175
+ }
126
176
  /** True when something came out of the store, not only withheld reports. */
127
177
  export function fromStore(cached) {
128
178
  return cached.catalog !== null && cached.runners.some((r) => r.ageMs !== undefined);
@@ -132,6 +182,9 @@ export function fromStore(cached) {
132
182
  * git hooks) and, within a group, in the configured order.
133
183
  */
134
184
  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 };
185
+ return { ...catalog, reports: inDisplayOrder(catalog.reports, order) };
186
+ }
187
+ /** `items` by group, and within a group in the configured order. */
188
+ export function inDisplayOrder(items, order) {
189
+ return orderRunners([...items], order).sort((a, b) => groupRank(a.runner) - groupRank(b.runner));
137
190
  }
@@ -25,7 +25,9 @@
25
25
  * link is removed, not its target), a directory store a directory, and no
26
26
  * store may be the home directory, a directory above it or a filesystem root.
27
27
  * A store whose path is, holds or sits in another flag's store is removed
28
- * only with `--yes`.
28
+ * only with `--yes`. Both checks compare real paths, so a symbolic link above
29
+ * a store cannot make it hold the home or another store unseen; the home check
30
+ * also refuses when the text alone says the store holds the home.
29
31
  * A file `WAYFINDER_CONFIG` names is removed only when its `$schema` names
30
32
  * wayfinder's config schema, which every file wayfinder writes has.
31
33
  */
@@ -25,16 +25,20 @@
25
25
  * link is removed, not its target), a directory store a directory, and no
26
26
  * store may be the home directory, a directory above it or a filesystem root.
27
27
  * A store whose path is, holds or sits in another flag's store is removed
28
- * only with `--yes`.
28
+ * only with `--yes`. Both checks compare real paths, so a symbolic link above
29
+ * a store cannot make it hold the home or another store unseen; the home check
30
+ * also refuses when the text alone says the store holds the home.
29
31
  * A file `WAYFINDER_CONFIG` names is removed only when its `$schema` names
30
32
  * wayfinder's config schema, which every file wayfinder writes has.
31
33
  */
32
34
  import { lstat, readFile, readdir, rm, rmdir, stat } from 'node:fs/promises';
33
- import { dirname, join, relative, isAbsolute, resolve } from 'node:path';
35
+ import { dirname, join, resolve } from 'node:path';
34
36
  import { z } from 'zod';
35
37
  import { UsageError, commandKit, outcome, } from '@osdlc/cli-tool/command';
36
38
  import { defaultBinDir, readShimTarget, stateDir } from '@osdlc/cli-tool/devlink';
37
39
  import { EXIT } from '@osdlc/cli-tool/exit';
40
+ import { isUnder } from '@osdlc/path-guard/lexical';
41
+ import { nodeGuard } from '@osdlc/path-guard/node';
38
42
  import { APP, BIN, CONFIG_ENV_VAR } from "./app.js";
39
43
  import { commandEnv } from "./config-command.js";
40
44
  import { configLocations } from "./config.js";
@@ -107,11 +111,24 @@ async function writtenByWayfinder(path) {
107
111
  }
108
112
  /** A `$schema` URL for any release of wayfinder's config schema. */
109
113
  const SCHEMA_MARKER = /\/@osdlc\/wayfinder@[^/]+\/schema\/config\.json$/;
114
+ /**
115
+ * True when `inner` is `outer` or inside it, once both are resolved against
116
+ * the working directory and reduced to the real path of what exists, so a
117
+ * symbolic link that leads into or out of `outer` counts where it points. A
118
+ * child named `..x` is inside: only `..` itself leaves `outer`.
119
+ */
120
+ function contains(outer, inner) {
121
+ return nodeGuard.contains(resolve(outer), resolve(inner));
122
+ }
110
123
  /** Why clean will not remove `store`, which exists, or null when it may. */
111
124
  async function refusal(store, home) {
112
125
  const path = resolve(store.path);
113
- const up = relative(path, resolve(home));
114
- if (dirname(path) === path || up === '' || (!up.startsWith('..') && !isAbsolute(up))) {
126
+ // A recursive delete fails closed: refuse when either the real paths or the
127
+ // text say the store holds the home. `contains` answers false when it cannot
128
+ // prove containment (a long link chain, say), and the text check catches
129
+ // what it then misses. `isUnder` reads POSIX paths only.
130
+ const holdsHome = contains(path, home) || (process.platform !== 'win32' && isUnder(path, resolve(home)));
131
+ if (dirname(path) === path || holdsHome) {
115
132
  return 'it is the home directory, a directory above it or a filesystem root';
116
133
  }
117
134
  const info = await lstat(path);
@@ -138,8 +155,7 @@ function humanBytes(bytes) {
138
155
  async function pruneEmptyParents(path, base) {
139
156
  let dir = dirname(path);
140
157
  for (;;) {
141
- const rel = relative(base, dir);
142
- if (rel === '' || rel.startsWith('..') || isAbsolute(rel))
158
+ if (resolve(dir) === resolve(base) || !contains(base, dir))
143
159
  return;
144
160
  const entries = await readdir(dir).catch(() => null);
145
161
  if (entries === null || entries.length > 0)
@@ -150,11 +166,7 @@ async function pruneEmptyParents(path, base) {
150
166
  }
151
167
  /** True when `a` and `b` are the same path or one is inside the other. */
152
168
  function overlaps(a, b) {
153
- const inside = (outer, inner) => {
154
- const rel = relative(resolve(outer), resolve(inner));
155
- return rel === '' || (!rel.startsWith('..') && !isAbsolute(rel));
156
- };
157
- return inside(a, b) || inside(b, a);
169
+ return contains(a, b) || contains(b, a);
158
170
  }
159
171
  /**
160
172
  * The first chosen store whose path is, holds or sits in another flag's
package/dist/cli.js CHANGED
@@ -20,7 +20,7 @@ import { APP, BIN } from "./app.js";
20
20
  import { createWayApp } from "./commands/index.js";
21
21
  import { GLOBALS } from "./commands/shared.js";
22
22
  import { WAYFINDER_SPEC, checkoutRoot } from "./devlink.js";
23
- import { flushViews } from "./core/saved-view.js";
23
+ import { flushWrites } from "./core/writes.js";
24
24
  import { safeJsonStdout, safeStderr, safeStdout } from "./terminal-text.js";
25
25
  /**
26
26
  * Exit quietly when the reader of `stream` goes away, as `way list --json |
@@ -179,8 +179,8 @@ export async function main(argv, env = process.env, home = homeDir(), io = proce
179
179
  env,
180
180
  ...(real ? { terminal: processContext().terminal } : {}),
181
181
  });
182
- // The output is out; the saved view a command wrote ends before main does.
183
- await flushViews();
182
+ // The output is out; the view and store writes a command started end before main does.
183
+ await flushWrites();
184
184
  return code;
185
185
  }
186
186
  // Runs when executed directly (devlink runs a checkout's `src/cli.ts` under
@@ -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)' },
@@ -18,7 +18,7 @@ import { GLOBALS, setCommandWords } from "./shared.js";
18
18
  /** The root's long description: what `way help --full` adds. */
19
19
  const DESCRIPTION = `Defaults come from ${PROJECT_CONFIG_FILENAME} in the project root and from the user file "${BIN} config path" names; a flag beats both. --exclude REPLACES the configured runners.disabled rather than adding to it.
20
20
 
21
- "${BIN} list" and "${BIN} query" probe every time, so a script reading them gets what the repository has now; --cached asks for the stored answer instead and names the stale runners on stderr. The terminal UI and "${BIN} serve" start from the store and refresh behind you.
21
+ "${BIN} list" and "${BIN} query" probe every time, so a script reading them gets what the repository has now; --cached answers from the last saved listing without checking files, or from the stored probes (naming stale runners on stderr) when nothing was saved. The terminal UI and "${BIN} serve" draw the saved listing first and refresh behind you.
22
22
 
23
23
  Reading some runners means running them, so a repository must be trusted before they are collected: "${BIN} trust" records that, once, per repository. Until then they are withheld and every surface says so. A repository cannot trust itself: allowExec in ${PROJECT_CONFIG_FILENAME} cannot raise the gate.
24
24
 
@@ -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,21 @@ 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, and the agent skills on a line of
38
+ * their own once they are read. Skills read before the runners are known
39
+ * wait for the first line. They pass `filter`, as in the document. No skills,
40
+ * or skills too large for a line, come only with the document.
41
+ */
42
+ export declare function progressLines(session: Session, emit: ProgressSink, maxLine?: number, filter?: TaskFilter): CatalogProgress;
28
43
  /**
29
44
  * Make the `list` command. `home` is the base for config, trust and cache
30
45
  * paths. `share` is the web view's held catalog (see `catalog-share.ts`).
@@ -35,6 +50,10 @@ export declare function listCommand(home: string, share?: CatalogShare): import(
35
50
  hidden: true;
36
51
  help: string;
37
52
  };
53
+ progress: {
54
+ kind: "boolean";
55
+ help: string;
56
+ };
38
57
  cached: {
39
58
  readonly kind: "boolean";
40
59
  readonly help: "answer from the last saved listing (files unchecked), else the stored probe; stderr says which";