@osdlc/wayfinder 0.9.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/CONTRIBUTING.md +6 -1
  3. package/README.md +9 -4
  4. package/dist/args.d.ts +7 -8
  5. package/dist/args.js +7 -8
  6. package/dist/catalog.d.ts +13 -4
  7. package/dist/catalog.js +16 -8
  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/index.js +1 -1
  12. package/dist/commands/list.d.ts +5 -2
  13. package/dist/commands/list.js +28 -3
  14. package/dist/commands/query.js +1 -1
  15. package/dist/commands/run.js +1 -1
  16. package/dist/commands/shared.js +2 -1
  17. package/dist/config-keys.d.ts +4 -0
  18. package/dist/config-keys.js +4 -0
  19. package/dist/config.d.ts +24 -10
  20. package/dist/config.js +64 -19
  21. package/dist/core/run.d.ts +2 -1
  22. package/dist/core/run.js +10 -2
  23. package/dist/core/saved-view.d.ts +2 -7
  24. package/dist/core/saved-view.js +5 -12
  25. package/dist/core/session.d.ts +7 -1
  26. package/dist/core/session.js +59 -22
  27. package/dist/core/writes.d.ts +13 -0
  28. package/dist/core/writes.js +22 -0
  29. package/dist/document-schemas.generated.js +6 -0
  30. package/dist/documents.d.ts +15 -2
  31. package/dist/documents.js +23 -14
  32. package/dist/guide.js +2 -2
  33. package/dist/index.js +2 -2
  34. package/dist/providers-command.d.ts +2 -2
  35. package/dist/schema.d.ts +1 -1
  36. package/dist/schema.js +1 -1
  37. package/dist/serve/auth.js +3 -16
  38. package/dist/serve/routes.d.ts +1 -1
  39. package/dist/serve/routes.js +1 -26
  40. package/dist/terminal-text.d.ts +4 -4
  41. package/dist/terminal-text.js +17 -12
  42. package/dist/tool-info.d.ts +2 -2
  43. package/dist/tools.js +1 -1
  44. package/dist/tui/app.js +24 -0
  45. package/dist/tui/index.js +3 -3
  46. package/dist/vocabulary.d.ts +5 -1
  47. package/dist/vocabulary.js +3 -1
  48. package/dist/web/main.js +67 -34
  49. package/dist/xdg.d.ts +0 -7
  50. package/dist/xdg.js +0 -14
  51. package/package.json +15 -13
  52. package/schema/config.json +14 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,79 @@
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
+
3
77
  ## 0.9.0
4
78
 
5
79
  ### 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
@@ -447,8 +447,8 @@ runners to skip, what order to show them in, whether execution is allowed, and
447
447
  how files are discovered. The layers, lowest precedence first: built-in
448
448
  defaults, the user file (`~/.config/wayfinder/config.json` by default),
449
449
  `wayfinder.config.json` at the project root, then the flags on the command
450
- line. `trust`, `open`, `theme` and `skills` count only in the user file, and a
451
- 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.
452
452
 
453
453
  ```text
454
454
  way config list [--json] every setting, and the layer it came from
@@ -536,7 +536,10 @@ runner answers, then the reports. The first line names every runner in
536
536
  `pending`, in display order. Each later line carries the runner that answered
537
537
  in `report`, with its `cache` verdict and `unknowns`, and the runners still
538
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
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
540
543
  same lines as NDJSON when the request asks for `application/x-ndjson`, with
541
544
  the catalog document last. `way schema` describes the line.
542
545
 
@@ -652,7 +655,9 @@ cannot be loaded. `onWarning` gets each warning the CLI prints on stderr,
652
655
  such as a project file key that is ignored. `progress` hears about each
653
656
  runner as it answers: `onRunners(ids)` once, then `onRunner(report, cache)`
654
657
  per runner, withheld ones included, so a caller can show the catalog before
655
- the slowest runner is done.
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.
656
661
 
657
662
  | Export | Is |
658
663
  |---|---|
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
@@ -19,6 +19,14 @@ 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: {
@@ -57,11 +65,12 @@ export declare function makeProject(extra?: readonly ToolDef[]): Project;
57
65
  /** The ids of every registered tool with a runner role. */
58
66
  export declare function runnerIds(project: Project): string[];
59
67
  /**
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.
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.
63
72
  */
64
- export declare function collectAndCache(project: Project, root: string, options: WayOptions, store: string): Promise<Catalog>;
73
+ export declare function collectAndStore(project: Project, root: string, options: WayOptions, store: string): Promise<Catalog>;
65
74
  /** Detect, then read what `store` holds, without running any runner. */
66
75
  export declare function readCachedCatalog(project: Project, root: string, options: WayOptions, store: string): Promise<CachedCatalog>;
67
76
  /** Both results once both have settled; the first failure, if any, after both. */
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,6 +37,8 @@ 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,
41
44
  onRunners: o.onRunners,
@@ -124,19 +127,24 @@ function mergeCatalogs(granted, others) {
124
127
  return { ...others, reports: [...granted.reports, ...others.reports] };
125
128
  }
126
129
  /**
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
+ * 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.
130
134
  */
131
- export async function collectAndCache(project, root, options, store) {
135
+ export async function collectAndStore(project, root, options, store) {
132
136
  const profile = await detect(project, root, options);
133
137
  const granted = grantedRunners(project, profile, options);
134
- if (granted === null) {
135
- return project.runners.collectAndCache(profile, store, collectOptions(options));
136
- }
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));
137
145
  const split = splitOptions(options, granted);
138
146
  // 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));
147
+ const [a, b] = await settledBoth(collect(split.granted), collect(split.others));
140
148
  return mergeCatalogs(a, b);
141
149
  }
142
150
  /** Detect, then read what `store` holds, without running any runner. */
@@ -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
@@ -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
 
@@ -34,9 +34,12 @@ export declare const MAX_PROGRESS_LINE: number;
34
34
  /**
35
35
  * A {@link CatalogProgress} that sends `session`'s probe as progress lines:
36
36
  * the runners first, in the order the catalog will list them, then each
37
- * runner as it answers, with its unknowns.
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.
38
41
  */
39
- export declare function progressLines(session: Session, emit: ProgressSink, maxLine?: number): CatalogProgress;
42
+ export declare function progressLines(session: Session, emit: ProgressSink, maxLine?: number, filter?: TaskFilter): CatalogProgress;
40
43
  /**
41
44
  * Make the `list` command. `home` is the base for config, trust and cache
42
45
  * paths. `share` is the web view's held catalog (see `catalog-share.ts`).
@@ -62,16 +62,39 @@ export const MAX_PROGRESS_LINE = 1024 * 1024;
62
62
  /**
63
63
  * A {@link CatalogProgress} that sends `session`'s probe as progress lines:
64
64
  * the runners first, in the order the catalog will list them, then each
65
- * runner as it answers, with its unknowns.
65
+ * runner as it answers, with its unknowns, and the agent skills on a line of
66
+ * their own once they are read. Skills read before the runners are known
67
+ * wait for the first line. They pass `filter`, as in the document. No skills,
68
+ * or skills too large for a line, come only with the document.
66
69
  */
67
- export function progressLines(session, emit, maxLine = MAX_PROGRESS_LINE) {
70
+ export function progressLines(session, emit, maxLine = MAX_PROGRESS_LINE, filter = {}) {
68
71
  let pending = [];
69
72
  let total = 0;
73
+ let named = false;
74
+ let early = null;
75
+ const sendSkills = (skills) => {
76
+ const line = { pending: [...pending], total, skills };
77
+ if (JSON.stringify(line).length <= maxLine)
78
+ emit(line);
79
+ };
70
80
  return {
71
81
  onRunners(runners) {
72
82
  pending = inDisplayOrder(runners.map((runner) => ({ runner })), session.runnerOrder()).map((r) => r.runner);
73
83
  total = runners.length;
84
+ named = true;
74
85
  emit({ pending: [...pending], total });
86
+ if (early !== null)
87
+ sendSkills(early);
88
+ early = null;
89
+ },
90
+ onSkills(all) {
91
+ const skills = filterSkills(all, filter).map((h) => h.skill);
92
+ if (skills.length === 0)
93
+ return;
94
+ if (named)
95
+ sendSkills(skills);
96
+ else
97
+ early = skills;
75
98
  },
76
99
  onRunner(report, cache) {
77
100
  pending = pending.filter((r) => r !== report.runner);
@@ -143,7 +166,9 @@ export function listCommand(home, share) {
143
166
  const snapshot = await session.catalog({
144
167
  cached,
145
168
  signal,
146
- ...(emit !== undefined ? { progress: progressLines(session, emit) } : {}),
169
+ ...(emit !== undefined
170
+ ? { progress: progressLines(session, emit, MAX_PROGRESS_LINE, filter) }
171
+ : {}),
147
172
  });
148
173
  const unknowns = session.unknowns(snapshot);
149
174
  noteUnknowns(ctx, session, snapshot, unknowns);
@@ -30,7 +30,7 @@ export function queryCommand(home) {
30
30
  items: { field: 'tasks', kind: 'task' },
31
31
  exits: { 1: 'the terms matched nothing' },
32
32
  readOnly: true,
33
- examples: ['query build', "query 'dev web --json", 'query test --services'],
33
+ examples: ['query build', 'query "\'dev" web --json', 'query test --services'],
34
34
  async run({ flags, globals, positionals }, ctx) {
35
35
  const filter = {
36
36
  ...filterFrom(flags),
@@ -58,7 +58,7 @@ export function runCommand(home) {
58
58
  kind: 'run',
59
59
  examples: [
60
60
  'run just:justfile:build',
61
- 'run npm:package.json:test -- --watch',
61
+ 'run node-scripts:package.json:test -- --watch',
62
62
  'run x --dry-run --json',
63
63
  ],
64
64
  // Running a task is the command line's; an adapter may only ask what would run.
@@ -6,6 +6,7 @@ import { commandKit, CommandError, UsageError } from '@osdlc/cli-tool/command';
6
6
  import { closestMatches } from '@osdlc/config-layers/did-you-mean';
7
7
  import { humanAge } from '@osdlc/system-model/duration';
8
8
  import { BIN } from "../app.js";
9
+ import { DISCOVERY_VALUES } from "../config-keys.js";
9
10
  import { SessionError, createSession } from "../core/session.js";
10
11
  import { unknownLine } from "../core/unknowns.js";
11
12
  import { NOT_CACHED, refreshCostLabel, runnerLabel, staleLabel } from "../vocabulary.js";
@@ -41,7 +42,7 @@ export const GLOBALS = {
41
42
  },
42
43
  discovery: {
43
44
  kind: 'enum',
44
- choices: ['git', 'walk', 'auto'],
45
+ choices: DISCOVERY_VALUES,
45
46
  valueName: 'M',
46
47
  hidden: true,
47
48
  help: 'how to find directories. Default: auto',
@@ -6,6 +6,10 @@
6
6
  export declare const THEME_VALUES: readonly ["system", "light", "dark"];
7
7
  /** The web view's theme. */
8
8
  export type Theme = (typeof THEME_VALUES)[number];
9
+ /** The `discovery` values. */
10
+ export declare const DISCOVERY_VALUES: readonly ["git", "walk", "auto"];
11
+ /** The `open` values: what the bare `way` command opens. */
12
+ export declare const OPEN_VALUES: readonly ["tui", "web"];
9
13
  /**
10
14
  * The keys `config set` and `config unset` change from the command line only.
11
15
  * cli-tool's adapters, such as the HTTP one the web view's server runs,
@@ -4,6 +4,10 @@
4
4
  */
5
5
  /** The `theme` values for the web view. `system` follows the browser. */
6
6
  export const THEME_VALUES = ['system', 'light', 'dark'];
7
+ /** The `discovery` values. */
8
+ export const DISCOVERY_VALUES = ['git', 'walk', 'auto'];
9
+ /** The `open` values: what the bare `way` command opens. */
10
+ export const OPEN_VALUES = ['tui', 'web'];
7
11
  /**
8
12
  * The keys `config set` and `config unset` change from the command line only.
9
13
  * cli-tool's adapters, such as the HTTP one the web view's server runs,
package/dist/config.d.ts CHANGED
@@ -28,6 +28,10 @@
28
28
  * of repositories that includes it.
29
29
  * - `open`, `theme` and `skills`, which say how a person likes to work.
30
30
  *
31
+ * `runners.timeout` from a project can only lower a limit: it caps each
32
+ * runner's own limit, or the user's value. A project value above the user's,
33
+ * or a project `null` that would undo it, is dropped with a warning.
34
+ *
31
35
  * `tools` is gated too, because a tool module is code. User-layer entries
32
36
  * always load; project-layer entries load only when the repository is trusted
33
37
  * and execution is allowed (see `tools.ts`).
@@ -54,24 +58,25 @@
54
58
  import { z } from 'zod';
55
59
  import { type PolicyDecisionOptions, type TrustPolicy } from '@osdlc/trust-repo';
56
60
  import { CONFIG_ENV_VAR, PROJECT_CONFIG_FILENAME } from './app.ts';
57
- import { type Theme } from './config-keys.ts';
61
+ import { OPEN_VALUES, type Theme } from './config-keys.ts';
58
62
  import { USER_CONFIG_FILENAME } from './xdg.ts';
59
63
  import type { WayOptions } from './catalog.ts';
60
64
  import { type SkillsSetting } from './core/skills.ts';
61
65
  export { CONFIG_ENV_VAR, PROJECT_CONFIG_FILENAME, USER_CONFIG_FILENAME };
62
66
  /**
63
67
  * 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, here, in
65
- * `schema/config.json` and in the configuration guide; tests check all three.
68
+ * in `schema/config.json`. It follows package.json's version, and
69
+ * `scripts/write-config-schema.mjs` writes it into `schema/config.json` and
70
+ * the configuration guide.
66
71
  */
67
- export declare const CONFIG_SCHEMA_URL = "https://unpkg.com/@osdlc/wayfinder@0.9/schema/config.json";
68
- /** The `discovery` values. */
69
- export declare const DISCOVERY_VALUES: readonly ["git", "walk", "auto"];
70
- /** The `open` values: what the bare `way` command opens. */
71
- export declare const OPEN_VALUES: readonly ["tui", "web"];
72
+ export declare const CONFIG_SCHEMA_URL: string;
73
+ /** The smallest `runners.timeout`, in seconds. */
74
+ export declare const MIN_RUNNER_TIMEOUT_S = 1;
75
+ /** The largest `runners.timeout`, in seconds: one hour. */
76
+ export declare const MAX_RUNNER_TIMEOUT_S = 3600;
72
77
  /** What the bare `way` command opens. */
73
78
  export type OpenSurface = (typeof OPEN_VALUES)[number];
74
- export { THEME_VALUES, type Theme } from './config-keys.ts';
79
+ export { DISCOVERY_VALUES, OPEN_VALUES, THEME_VALUES, type Theme } from './config-keys.ts';
75
80
  /**
76
81
  * The configuration file, as a Zod schema. Every key is optional; the defaults
77
82
  * are {@link DEFAULT_CONFIG}.
@@ -81,6 +86,7 @@ export declare const WayfinderConfigSchema: z.ZodObject<{
81
86
  runners: z.ZodOptional<z.ZodObject<{
82
87
  disabled: z.ZodOptional<z.ZodArray<z.ZodString>>;
83
88
  order: z.ZodOptional<z.ZodArray<z.ZodString>>;
89
+ timeout: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
84
90
  }, z.core.$strip>>;
85
91
  allowExec: z.ZodOptional<z.ZodBoolean>;
86
92
  discovery: z.ZodOptional<z.ZodEnum<{
@@ -362,11 +368,19 @@ export declare function unsetConfigValue<T extends object>(config: T, key: strin
362
368
  export declare function parseConfigValue(raw: string): unknown;
363
369
  /** The key a typed key names, or undefined when it names no setting. */
364
370
  export declare function resolveConfigKey(key: string): string | undefined;
371
+ type ConfigOptions = Pick<WayOptions, 'exclude' | 'allowExec' | 'discovery' | 'excludePaths' | 'probeTimeoutMs' | 'maxProbeTimeoutMs'>;
365
372
  /**
366
373
  * The {@link WayOptions} fields this configuration controls. Only keys the
367
374
  * config sets are present, so a caller spreads its own flags after it.
375
+ *
376
+ * With `layers`, `runners.timeout` comes from them: the user's value replaces
377
+ * each runner's limit, and the project's caps it. Without, `config`'s value
378
+ * replaces each runner's limit.
368
379
  */
369
- export declare function collectOptionsFromConfig(config: WayfinderConfig): Pick<WayOptions, 'exclude' | 'allowExec' | 'discovery' | 'excludePaths'>;
380
+ export declare function collectOptionsFromConfig(config: WayfinderConfig, layers?: {
381
+ user: WayfinderConfig | null;
382
+ project: WayfinderConfig | null;
383
+ }): ConfigOptions;
370
384
  /**
371
385
  * `config.trust` as the policy `@osdlc/trust-repo` expects: the top-level
372
386
  * rules, and `trust.tools` as its per-scope rules.