@osdlc/wayfinder 0.0.0-stage → 0.7.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 +231 -0
- package/CONTRIBUTING.md +62 -0
- package/LICENSE-APACHE +202 -0
- package/LICENSE-MIT +21 -0
- package/README.md +507 -2
- package/SECURITY.md +44 -0
- package/bin/way.js +18 -0
- package/dist/app.d.ts +24 -0
- package/dist/app.js +24 -0
- package/dist/args.d.ts +44 -0
- package/dist/args.js +93 -0
- package/dist/cache.d.ts +7 -0
- package/dist/cache.js +15 -0
- package/dist/catalog.d.ts +38 -0
- package/dist/catalog.js +61 -0
- package/dist/clean-command.d.ts +43 -0
- package/dist/clean-command.js +274 -0
- package/dist/cli.d.ts +76 -0
- package/dist/cli.js +612 -0
- package/dist/config-command.d.ts +52 -0
- package/dist/config-command.js +342 -0
- package/dist/config.d.ts +367 -0
- package/dist/config.js +700 -0
- package/dist/devlink.d.ts +14 -0
- package/dist/devlink.js +30 -0
- package/dist/groups.d.ts +34 -0
- package/dist/groups.js +38 -0
- package/dist/guide.d.ts +32 -0
- package/dist/guide.js +411 -0
- package/dist/http.d.ts +22 -0
- package/dist/http.js +149 -0
- package/dist/origin-owner.d.ts +14 -0
- package/dist/origin-owner.js +69 -0
- package/dist/page.d.ts +15 -0
- package/dist/page.js +58 -0
- package/dist/providers-command.d.ts +40 -0
- package/dist/providers-command.js +132 -0
- package/dist/serve.d.ts +97 -0
- package/dist/serve.js +678 -0
- package/dist/tools.d.ts +46 -0
- package/dist/tools.js +102 -0
- package/dist/trust-command.d.ts +33 -0
- package/dist/trust-command.js +221 -0
- package/dist/trust-store.d.ts +18 -0
- package/dist/trust-store.js +46 -0
- package/dist/tui.d.ts +178 -0
- package/dist/tui.js +846 -0
- package/dist/web/main.js +2315 -0
- package/dist/web/page.html +110 -0
- package/dist/web/styles.css +1514 -0
- package/dist/xdg.d.ts +10 -0
- package/dist/xdg.js +17 -0
- package/package.json +72 -3
package/README.md
CHANGED
|
@@ -1,3 +1,508 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @osdlc/wayfinder
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Browse and run every task in a repository from one list: package.json
|
|
4
|
+
scripts, just, make, cargo, moon, mise and the rest, plus the install, tool and
|
|
5
|
+
git-hook commands your package managers and tool managers imply.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
way # the terminal UI; Enter runs the selected task
|
|
9
|
+
way --serve # the same catalog as a live page
|
|
10
|
+
way query dev # the tasks matching a search, best match first
|
|
11
|
+
way --json # the data, for anything else
|
|
12
|
+
way providers # every tool it knows, and whether its binary is on PATH
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
It is for people who move between repositories and do not want to learn each
|
|
16
|
+
one's task runner before they can start it, and for scripts and agents that
|
|
17
|
+
need the same answer as data.
|
|
18
|
+
|
|
19
|
+
Finding and reading the tools is done by
|
|
20
|
+
[`@osdlc/system-model`](https://www.npmjs.com/package/@osdlc/system-model).
|
|
21
|
+
This package is the part you look at.
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
npm install --global @osdlc/wayfinder
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
This puts `way` on your PATH. `pnpm add --global` and `bun add --global` work
|
|
30
|
+
too. ESM only.
|
|
31
|
+
|
|
32
|
+
Node.js `^22.22.2 || ^24.15.0 || >=26.0.0`, the range of its dependency
|
|
33
|
+
`@osdlc/typed-git`. Bun can also run it.
|
|
34
|
+
|
|
35
|
+
## Running from a checkout
|
|
36
|
+
|
|
37
|
+
An installed `way` follows the source you are working on, over
|
|
38
|
+
[`@osdlc/cli-tool/devlink`](https://www.npmjs.com/package/@osdlc/cli-tool). Standing
|
|
39
|
+
inside a wayfinder checkout runs that checkout; `way dev link` makes one the
|
|
40
|
+
checkout every `way` on the machine runs; every link is remembered.
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
way dev install # once: put shims for this checkout on PATH as way and wayfinder
|
|
44
|
+
way dev link # this checkout answers everywhere, until told otherwise
|
|
45
|
+
way dev history # every checkout ever linked, most recent first, with branch and HEAD
|
|
46
|
+
way dev use #2 # back to an earlier one …
|
|
47
|
+
way dev use canonical # … or to the install itself
|
|
48
|
+
way dev status # which checkout runs now, and why
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
First hit wins: `WAY_HOME`, a checkout above the cwd (`WAY_CWD_DEV=0` turns
|
|
52
|
+
that off), the linked checkout, then the install. The shim says which entry
|
|
53
|
+
it chose on stderr; `WAY_QUIET=1` silences it. State lives in
|
|
54
|
+
`<config>/way/`: `~/Library/Application Support/way` on macOS,
|
|
55
|
+
`${XDG_CONFIG_HOME:-~/.config}/way` elsewhere. A checkout runs from source, so
|
|
56
|
+
it needs [Bun](https://bun.sh) on PATH and a `pnpm install` in the checkout.
|
|
57
|
+
|
|
58
|
+
## Why
|
|
59
|
+
|
|
60
|
+
A repository of any size runs its work through several tools at once, and each
|
|
61
|
+
answers only for itself. `just --list` shows recipes. `moon query tasks` shows
|
|
62
|
+
moon tasks. Neither helps when the question is "how do I start that app" and you
|
|
63
|
+
do not yet know which tool owns it.
|
|
64
|
+
|
|
65
|
+
`wayfinder` puts all of them in one searchable list, keyed by the call chain you would
|
|
66
|
+
actually type, and — unlike anything a browser can do — lets you press Enter.
|
|
67
|
+
|
|
68
|
+
## Groups
|
|
69
|
+
|
|
70
|
+
Rows come in four groups, in this order, on every surface:
|
|
71
|
+
|
|
72
|
+
| Group | What fills it | Example rows |
|
|
73
|
+
| --- | --- | --- |
|
|
74
|
+
| Tasks | task runners: scripts, recipes, targets | `npm run dev`, `just deploy` |
|
|
75
|
+
| Dependencies | the detected package managers | `npm ci`, `cargo fetch` |
|
|
76
|
+
| Tools | tool managers such as mise and proto | `mise install` |
|
|
77
|
+
| Git hooks | lefthook, husky, pre-commit | `lefthook install` |
|
|
78
|
+
|
|
79
|
+
The terminal UI and the page show a break between groups in the tab bar.
|
|
80
|
+
`--json` adds a `groups` array: `{id, title, runners}` for each group that has
|
|
81
|
+
rows. `runners.order` reorders runners within a group; the groups keep their
|
|
82
|
+
order.
|
|
83
|
+
|
|
84
|
+
## The terminal UI
|
|
85
|
+
|
|
86
|
+
```text
|
|
87
|
+
enter run the selected task, handing it this terminal
|
|
88
|
+
(a task with parameters asks for them first)
|
|
89
|
+
^y copy its command
|
|
90
|
+
tab next runner (all · just · node-scripts │ dependencies │ tools …)
|
|
91
|
+
^e exact search instead of fuzzy
|
|
92
|
+
^t only services — tasks that run until you stop them
|
|
93
|
+
^s trust this repository, when runners are hidden for want of it
|
|
94
|
+
^r re-probe (always a real probe, never the store)
|
|
95
|
+
, this project's configuration, read-only
|
|
96
|
+
esc quit
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
`^s` asks before it grants: the status line becomes `trust this repository?
|
|
100
|
+
y/n`, and only `y` records anything. One keystroke is not a decision when the
|
|
101
|
+
thing being decided is whether this repository's code may run.
|
|
102
|
+
|
|
103
|
+
A recipe that takes arguments collects them first. Enter on `just deploy <env>`
|
|
104
|
+
turns the key line into a command line with the command already on it and the
|
|
105
|
+
cursor after it — type `staging`, Enter runs
|
|
106
|
+
`just deploy staging`, `esc` goes back. A task that takes nothing is unchanged:
|
|
107
|
+
Enter still runs it, with nothing to dismiss.
|
|
108
|
+
|
|
109
|
+
Fuzzy by default. Terms are ANDed, so `photo dev` narrows to a photo app's dev
|
|
110
|
+
server. A leading `'` forces one term to match exactly.
|
|
111
|
+
|
|
112
|
+
The four keystrokes worth knowing: **`^t`, then the app's name, then Enter.**
|
|
113
|
+
|
|
114
|
+
What Enter will run is always on screen above the key line, so it is never a
|
|
115
|
+
surprise. Tasks are spawned from an argument vector, never through a shell, so a
|
|
116
|
+
recipe with `<placeholders>` cannot be mangled into something else on the way.
|
|
117
|
+
|
|
118
|
+
## Searching from the shell
|
|
119
|
+
|
|
120
|
+
`way query <terms>` is the terminal UI's search without the UI: the same
|
|
121
|
+
matcher, the same ranking, one command line per match.
|
|
122
|
+
|
|
123
|
+
```text
|
|
124
|
+
way query dev every task matching "dev", best match first
|
|
125
|
+
way query photo dev terms are ANDed
|
|
126
|
+
way query dev --exact every term matches as a substring, not a subsequence
|
|
127
|
+
way query --services only tasks that run until you stop them
|
|
128
|
+
way query dev --json the matching tasks, rather than their command lines
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
A leading `'` forces one term to match exactly, as it does in the UI. A search
|
|
132
|
+
that matched nothing exits **1**, so `way query dev && …` is usable from a
|
|
133
|
+
script; a bare `way query` searched for nothing, matches everything, and is
|
|
134
|
+
`way --list`. Every collection flag applies — `-C`, `--only`, `--exclude`,
|
|
135
|
+
`--cached` and the rest — and, like `--list` and `--json`, it re-probes unless
|
|
136
|
+
you ask for the store.
|
|
137
|
+
|
|
138
|
+
## The web view
|
|
139
|
+
|
|
140
|
+
`way --serve` opens a page with the same catalog: a collapsible tree by call
|
|
141
|
+
chain, sticky group headers, fuzzy and exact search, and copy buttons.
|
|
142
|
+
|
|
143
|
+
It is a server rather than a generated file on purpose. A file would be a
|
|
144
|
+
snapshot — add a task and the page is quietly wrong. Here the server re-probes
|
|
145
|
+
and the page refreshes on focus and on a slow poll, so what you are looking at
|
|
146
|
+
is what the repository currently has.
|
|
147
|
+
|
|
148
|
+
The very first request is answered from the [stored probe](#the-cache) with a
|
|
149
|
+
real probe already running behind it, so the page appears at once on a
|
|
150
|
+
repository whose slowest runner takes seconds; the rows update in place when
|
|
151
|
+
the probe lands. Refresh is always a real probe.
|
|
152
|
+
|
|
153
|
+
## Execution, and trust
|
|
154
|
+
|
|
155
|
+
Some runners can only be read by running them. `moon query tasks` evaluates the
|
|
156
|
+
repository's own toolchain configuration, and `mise tasks` can fire its
|
|
157
|
+
`[hooks]`. Pointing a task browser at a repository you did not write is
|
|
158
|
+
therefore code execution: you may choose to run nothing, and merely looking
|
|
159
|
+
already ran that repository's code.
|
|
160
|
+
|
|
161
|
+
`wayfinder` is willing in principle: its `allowExec` default is `true`, because you
|
|
162
|
+
reach for a task browser standing in your own repository and one that cannot see
|
|
163
|
+
the build graph is not much of a browser. But willingness is not the gate. Trust
|
|
164
|
+
is, asked once and remembered per repository:
|
|
165
|
+
|
|
166
|
+
```text
|
|
167
|
+
way trust trust the repository at the resolved root
|
|
168
|
+
way trust --untrust remove this repository's trust
|
|
169
|
+
way trust --show report this root's trust status
|
|
170
|
+
way trust --list every trusted path, one per line
|
|
171
|
+
way trust --json the same answer as one JSON object
|
|
172
|
+
way trust --help this list
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Every one of these answers in the machine form too. `--json` gives one object
|
|
176
|
+
per invocation — `{"root": …, "trusted": …, "changed": …, "by": …, "rule": …}`
|
|
177
|
+
for the three root-scoped modes, so a caller never has to branch on the flag
|
|
178
|
+
it just passed, and `{"trusted": [paths]}` for `--list`. `by` is
|
|
179
|
+
`"marker" | "path" | "owner" | null` — which layer decided, see "The policy"
|
|
180
|
+
below — and `rule` is the matching `trust.paths`/`trust.owners` entry, present
|
|
181
|
+
only when `by` is `"path"` or `"owner"`. A `--untrust` that found nothing still
|
|
182
|
+
prints its document and reports the miss through exit 1 and stderr, so a parser
|
|
183
|
+
is never handed an empty stdout to interpret.
|
|
184
|
+
|
|
185
|
+
`-C` applies here too. Trust, with execution allowed, also lets the project
|
|
186
|
+
file load tool modules; see
|
|
187
|
+
[Adding your own tools](#adding-your-own-tools).
|
|
188
|
+
|
|
189
|
+
### The policy
|
|
190
|
+
|
|
191
|
+
A root can also be trusted with no marker at all, through a `trust` block in
|
|
192
|
+
the USER layer of the config file (never the project layer — a repository
|
|
193
|
+
cannot grant itself trust, same as `allowExec: true`):
|
|
194
|
+
|
|
195
|
+
```jsonc
|
|
196
|
+
// ~/.config/wayfinder/config.json
|
|
197
|
+
{
|
|
198
|
+
"trust": {
|
|
199
|
+
"paths": ["/home/me/work/**"], // @osdlc/trust-repo's glob dialect
|
|
200
|
+
"owners": ["my-org"] // case-insensitive `origin` remote owners
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
`@osdlc/trust-repo`'s `policyExecGate` decides trust in order — a marker in
|
|
206
|
+
the store, then `trust.paths` (a glob over the resolved, symlink-free root),
|
|
207
|
+
then `trust.owners` (the owner in the `origin` remote's URL, read from
|
|
208
|
+
`.git/config` without running git). The precedence and the glob dialect are
|
|
209
|
+
documented in `@osdlc/trust-repo`'s README. wayfinder adds no vocabulary of its
|
|
210
|
+
own beyond expanding a leading `~` in a `trust.paths` entry against `$HOME`.
|
|
211
|
+
An owner match trusts every repository whose remote names that owner, so list
|
|
212
|
+
only owners whose repositories you would run. `way trust --show` reports which layer decided (`by`/`rule`);
|
|
213
|
+
the plain grant still writes a marker on a policy-trusted root — a standing
|
|
214
|
+
policy can change out from under a repository, and the marker is the more
|
|
215
|
+
durable of the two — and `--untrust` says when the policy still covers the
|
|
216
|
+
root after the marker is gone.
|
|
217
|
+
|
|
218
|
+
### Removing what it has stored
|
|
219
|
+
|
|
220
|
+
Three things live outside your repositories, and `clean` is how they go away.
|
|
221
|
+
Bare `clean` reports them and removes nothing — a command whose subject is
|
|
222
|
+
deleting should not delete by default.
|
|
223
|
+
|
|
224
|
+
```text
|
|
225
|
+
way clean show each store, where it is, and what it holds
|
|
226
|
+
way clean --cache stored probe results
|
|
227
|
+
way clean --trust forget which repositories you have trusted
|
|
228
|
+
way clean --config --yes your user configuration file
|
|
229
|
+
way clean --all --yes all three
|
|
230
|
+
way clean --json the same answer as one JSON object
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
`--json` answers the same thing as one object: a `stores` array of
|
|
234
|
+
`{key, flag, what, path, bytes, removed}`, all three on a bare report and only
|
|
235
|
+
the ones you named on a removal. `bytes` is null when nothing was stored, which
|
|
236
|
+
is what separates "there was nothing to remove" from "it would not delete" —
|
|
237
|
+
both are `removed: false`. The closing note about trust being asked for again
|
|
238
|
+
goes to stderr under `--json`, so stdout stays one parseable document.
|
|
239
|
+
|
|
240
|
+
`--config` and `--all` want `--yes` because the three are not equally
|
|
241
|
+
replaceable: the cache is derived and costs one slow probe, trust costs
|
|
242
|
+
re-answering a question per repository, and the configuration is the only thing
|
|
243
|
+
here you wrote by hand. Nothing inside a repository is ever touched — a
|
|
244
|
+
project's own `wayfinder.config.json` belongs to that project.
|
|
245
|
+
|
|
246
|
+
The store is a directory of marker files at `$XDG_STATE_HOME/wayfinder/trusted/`, or
|
|
247
|
+
`~/.local/state/wayfinder/trusted/` when that variable is unset. XDG **state**, not
|
|
248
|
+
config: trust is state a program maintains, not configuration a person
|
|
249
|
+
hand-edits, and a consent record that travels in a dotfiles repo onto a new
|
|
250
|
+
machine has stopped being consent. Grants made under the old waypost name, in
|
|
251
|
+
`~/.local/state/waypost/trusted/`, still count.
|
|
252
|
+
|
|
253
|
+
**A repository cannot trust itself.** `allowExec: true` in `wayfinder.config.json` is
|
|
254
|
+
ignored with a warning, because that file lives inside the repository being
|
|
255
|
+
scanned. The project layer may still lower `allowExec` to `false`. A
|
|
256
|
+
project-layer `trust` block is rejected outright, the same way — trust has no
|
|
257
|
+
"lower" state to honour from inside the repository.
|
|
258
|
+
|
|
259
|
+
`--exec` is the escape hatch and records nothing — consent for one run, which is
|
|
260
|
+
what a script or a CI job wants. `--no-exec` turns execution off however trusted
|
|
261
|
+
the repository is. Both hold on every surface, the web view included: its
|
|
262
|
+
`POST /api/trust` refuses with `409` whenever a grant would not apply, so
|
|
263
|
+
`--no-exec` cannot be lifted from the page and `--exec` cannot be persisted by
|
|
264
|
+
it. The page hides its button in those states, and the server refuses the
|
|
265
|
+
request anyway — the session token says who is asking, never that asking made
|
|
266
|
+
sense.
|
|
267
|
+
|
|
268
|
+
When runners are withheld, every surface says so and offers the grant where it
|
|
269
|
+
says it: `--list` and `--json` print one line on stderr, the terminal UI notes
|
|
270
|
+
`N hidden — repo not trusted (^s to trust)` beside the counts, and the web view
|
|
271
|
+
puts a **Trust this repository** button in each held-back runner's info panel
|
|
272
|
+
and in the runner picker.
|
|
273
|
+
|
|
274
|
+
### What decides
|
|
275
|
+
|
|
276
|
+
`configured` is `allowExec` after the layers and wayfinder's own `true` default.
|
|
277
|
+
|
|
278
|
+
| configured `allowExec` | trusted | flag | effective | why |
|
|
279
|
+
| --- | --- | --- | --- | --- |
|
|
280
|
+
| any | any | `--no-exec` | `false` | the flag is the last word, and the store is not even read |
|
|
281
|
+
| any | any | `--exec` | `true` | consent for this run, typed by a person; nothing is recorded |
|
|
282
|
+
| `false` | any | none | `false` | a file said no; trusting the repository would change nothing |
|
|
283
|
+
| `true` | no | none | `false` | willing in principle, but this repository has not been trusted |
|
|
284
|
+
| `true` | yes | none | `true` | the only combination that runs a subprocess |
|
|
285
|
+
|
|
286
|
+
A decision is keyed on the absolute, symlink-resolved repository PATH, not on a
|
|
287
|
+
hash of its contents — the same tradeoff mise makes. A repository you trusted
|
|
288
|
+
that later pulls hostile changes stays trusted, and `way trust --untrust` is the
|
|
289
|
+
only remedy. Content-hashing every runner config instead would re-prompt on
|
|
290
|
+
ordinary edits, training people to approve without reading.
|
|
291
|
+
|
|
292
|
+
## The cache
|
|
293
|
+
|
|
294
|
+
Some runners are slow to ask — moon starts its toolchain, sbt starts a JVM — and
|
|
295
|
+
a browser that waits for them looks broken. `wayfinder` keeps the last answer per
|
|
296
|
+
(root, runner) so the UI has something to paint at once.
|
|
297
|
+
|
|
298
|
+
**The two surfaces you look at always start from the store.** The terminal UI
|
|
299
|
+
and `--serve` read it, paint, then probe behind you and update in place. **The
|
|
300
|
+
two you pipe do not.** `--json` and `--list` re-probe every run, because a script
|
|
301
|
+
or an agent reading them must get what the repository has right now; those runs
|
|
302
|
+
also write the store, so the next UI start is instant. `--cached` inverts it for
|
|
303
|
+
one run.
|
|
304
|
+
|
|
305
|
+
Three states, and each surface shows them the same way:
|
|
306
|
+
|
|
307
|
+
- **Fresh** — the stored answer still holds, and nothing is said.
|
|
308
|
+
- **Stale** — the answer was used and is out of date. The terminal UI marks the
|
|
309
|
+
runner's tab with a leading `~` and notes `cached rows — re-probing just
|
|
310
|
+
(~149ms)` beside the counts, or `cached rows: just 35s old — ^r to re-probe`
|
|
311
|
+
once the refresh is over and the rows are still the stored ones; the page
|
|
312
|
+
shows `cached: just 35s old - re-probing`.
|
|
313
|
+
- **Stale and slow to probe here** — the case the cache exists for, called out
|
|
314
|
+
louder in red rather than in the same voice as a 200ms refresh:
|
|
315
|
+
`cached rows — moon (~2.4s) is slow to probe here, so this takes a moment`.
|
|
316
|
+
|
|
317
|
+
Slowness is measured in THIS repository, from a rolling window of the last five
|
|
318
|
+
probe durations reported as their median. A runner that is quick here is never
|
|
319
|
+
called slow because it is slow somewhere else, and where a repository has no
|
|
320
|
+
measurement yet the surface says so rather than inventing a number.
|
|
321
|
+
|
|
322
|
+
`^r` in the terminal UI and Refresh on the page are always real probes — the one
|
|
323
|
+
action that guarantees accuracy never answers from the store.
|
|
324
|
+
|
|
325
|
+
If a row you run turns out not to exist — a task renamed since the stored probe —
|
|
326
|
+
both surfaces say where the row came from instead of leaving you with a bare
|
|
327
|
+
spawn failure.
|
|
328
|
+
|
|
329
|
+
For the pipeable surfaces, `--cached` names the stale runners on stderr, so
|
|
330
|
+
`--list` stays pipeable and `--json` stays parseable:
|
|
331
|
+
|
|
332
|
+
```text
|
|
333
|
+
wayfinder: --cached: stale: just (35s old, refresh usually about 149ms)
|
|
334
|
+
wayfinder: --cached: not cached, probed now: github-actions
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
`--cached` against an empty store is not an error: it probes, stores the result,
|
|
338
|
+
and says so. `--json --cached` gains a `cache` array beside the catalog, one
|
|
339
|
+
entry per selected runner; over HTTP the page always receives it.
|
|
340
|
+
|
|
341
|
+
The store is at `$XDG_CACHE_HOME/wayfinder/`, or `~/.cache/wayfinder/`. XDG **cache**,
|
|
342
|
+
deliberately not the `~/.local/state/wayfinder/` [trust](#execution-and-trust) uses:
|
|
343
|
+
losing this costs one slow probe, while losing the trust store would silently
|
|
344
|
+
un-trust repositories. The cache is no part of the execution gate — a cached
|
|
345
|
+
answer is never a trust grant, clearing the cache never changes what is trusted,
|
|
346
|
+
and a runner withheld for want of trust is never stored at all. Invalidation is a
|
|
347
|
+
content hash over the files a probe depended on, never an mtime; the
|
|
348
|
+
[`@osdlc/system-model` README](https://www.npmjs.com/package/@osdlc/system-model)
|
|
349
|
+
sets out its limits.
|
|
350
|
+
|
|
351
|
+
## Configuration
|
|
352
|
+
|
|
353
|
+
The options you would otherwise retype on every invocation live in a file:
|
|
354
|
+
which runners to skip, what order to show them in, whether execution is
|
|
355
|
+
allowed, how files are discovered. Layers, lowest precedence first — built-in
|
|
356
|
+
defaults, `$XDG_CONFIG_HOME/wayfinder/config.json` (or `~/.config/wayfinder/config.json`),
|
|
357
|
+
`wayfinder.config.json` at the project root, then the flags on this command line.
|
|
358
|
+
|
|
359
|
+
The keys are `runners.disabled`, `runners.order`, `allowExec`, `discovery`,
|
|
360
|
+
`excludePaths`, `trust.paths`, `trust.owners` and `tools`. `WAYFINDER_CONFIG`
|
|
361
|
+
names a different user file and changes nothing else.
|
|
362
|
+
|
|
363
|
+
The tool was called waypost before its first release. `WAYPOST_CONFIG`,
|
|
364
|
+
`~/.config/waypost/config.json` and `waypost.config.json` are still read when
|
|
365
|
+
the new name is absent, with a warning. See the
|
|
366
|
+
[configuration guide](docs/guide/configuration.md#files-from-the-waypost-name).
|
|
367
|
+
|
|
368
|
+
```text
|
|
369
|
+
way config list [--json] every setting, and the layer it came from
|
|
370
|
+
way config get <key> one setting's effective value, as JSON
|
|
371
|
+
way config set <key> <value> [--user|--project] write a setting (default --project)
|
|
372
|
+
way config unset <key> [--user|--project] remove a setting (default --project)
|
|
373
|
+
way config path where each layer's file lives
|
|
374
|
+
way config --help this list
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
`-C` applies here too, so `way config path -C /elsewhere` reports that
|
|
378
|
+
directory's files rather than this one's. An exit code of 2 means the command
|
|
379
|
+
as typed cannot run — an unknown key, a wrong-typed value — and 1 means it was
|
|
380
|
+
well formed but failed against the state it found.
|
|
381
|
+
|
|
382
|
+
`runners.order` sets the report order everywhere — `--json`, `--list`, the
|
|
383
|
+
terminal UI's tab cycle, and the web view, where your own drag-reordering
|
|
384
|
+
(persisted in the browser) still layers on top of it.
|
|
385
|
+
|
|
386
|
+
### `allowExec` here
|
|
387
|
+
|
|
388
|
+
wayfinder's execution default is `true`, below any file. Highest precedence first:
|
|
389
|
+
|
|
390
|
+
1. `--exec` or `--no-exec` on this command line
|
|
391
|
+
2. `allowExec` in the user file, then `allowExec: false` in `wayfinder.config.json`
|
|
392
|
+
3. wayfinder's own default, `true`
|
|
393
|
+
|
|
394
|
+
A file has to say `false` for execution to be off. `way config list` and
|
|
395
|
+
`way config get allowExec` report that default, labelled `(default)`.
|
|
396
|
+
|
|
397
|
+
This settles willingness, not execution: [trust](#execution-and-trust) is the
|
|
398
|
+
gate above it, so a `true` here still collects nothing until the repository is
|
|
399
|
+
trusted.
|
|
400
|
+
|
|
401
|
+
## Options
|
|
402
|
+
|
|
403
|
+
```text
|
|
404
|
+
query <terms> the tasks matching a search, best match first
|
|
405
|
+
--exact with query: terms match as substrings, not subsequences
|
|
406
|
+
--services with query: only tasks that run until you stop them
|
|
407
|
+
--serve a page instead of the terminal UI
|
|
408
|
+
--port N fixed port for --serve
|
|
409
|
+
--no-open print the URL rather than opening a browser
|
|
410
|
+
--json | --list print the catalog and exit
|
|
411
|
+
--cached answer those two from the last stored probe
|
|
412
|
+
|
|
413
|
+
--no-exec skip runners that must run a subprocess
|
|
414
|
+
--exec allow them for this run only, without recording trust
|
|
415
|
+
--only a,b restrict to these runners
|
|
416
|
+
--exclude a,b skip these runners
|
|
417
|
+
--exclude-path P leave a path out of discovery; repeatable. A bare name
|
|
418
|
+
matches any path segment, a value with a slash matches a
|
|
419
|
+
path from the root and takes the tree beneath it
|
|
420
|
+
--discovery M git | walk | auto (default: auto)
|
|
421
|
+
-C, --dir PATH directory to inspect (default: cwd)
|
|
422
|
+
--config MODULE load extra tools from a module, this run only; repeatable
|
|
423
|
+
-h, --help the short form: the ways in, and where the rest is
|
|
424
|
+
--help --all the block above, every default and every note
|
|
425
|
+
|
|
426
|
+
config read and write the layered settings; `config --help`
|
|
427
|
+
trust allow this repository's runners to be read by running
|
|
428
|
+
them; `trust --help`
|
|
429
|
+
providers the registered tools, built-in and your own;
|
|
430
|
+
`providers --help`
|
|
431
|
+
clean remove what this tool has stored; `clean --help`
|
|
432
|
+
guide how to use and extend this tool, in Markdown
|
|
433
|
+
dev link a checkout of this tool over the installed copy
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
A subcommand is claimed before the flag parse, so the flags above are the
|
|
437
|
+
top-level command's, not theirs. `-C` is the exception: the subcommands whose
|
|
438
|
+
answer depends on which repository you are asking about take it.
|
|
439
|
+
|
|
440
|
+
| Subcommand | `-C, --dir` | Why |
|
|
441
|
+
|---|---|---|
|
|
442
|
+
| `config` | yes | reports the configuration THAT directory resolves |
|
|
443
|
+
| `trust` | yes | the grant keys on that directory's project root |
|
|
444
|
+
| `providers` | yes | a trusted project file can add tools when execution is allowed |
|
|
445
|
+
| `clean` | no | resolves every path from the environment and the home directory |
|
|
446
|
+
| `guide` | no | its argument is a topic name |
|
|
447
|
+
| `dev` | no | its state is devlink's, keyed on the tool name |
|
|
448
|
+
|
|
449
|
+
`way --help` is the short form: the ways in, the two flags most invocations
|
|
450
|
+
pass, and the names of everything below it. `way --help --all` is the complete
|
|
451
|
+
flag list — the block above — and each subcommand answers for itself with its
|
|
452
|
+
own `--help`. `way guide` is the long form, by topic. A tool that answers a
|
|
453
|
+
mistyped flag with its whole surface makes the reader hunt for the error, so a
|
|
454
|
+
usage error prints the short form too.
|
|
455
|
+
|
|
456
|
+
`way guide` prints usage-and-extension instructions for people and for agents;
|
|
457
|
+
`guide extend` is how to add a tool and `guide trust` the exec gate.
|
|
458
|
+
|
|
459
|
+
The directory is resolved upward to the project root, so running from a
|
|
460
|
+
subdirectory still inspects the whole repository.
|
|
461
|
+
|
|
462
|
+
## Adding your own tools
|
|
463
|
+
|
|
464
|
+
A tool is a `ToolDef` from `@osdlc/system-model/detect`, the same shape as the
|
|
465
|
+
built-ins. A module that exports `tools`, an array of them, can be loaded three
|
|
466
|
+
ways:
|
|
467
|
+
|
|
468
|
+
```sh
|
|
469
|
+
way --config ./acme-tools.ts --list # this run only
|
|
470
|
+
way config set --user tools '["~/acme-tools.mjs"]' # every run, from your user file
|
|
471
|
+
way config set tools '["./tools/acme.mjs"]' # this repository, once trusted with exec on
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
A module is code, so where it is named decides whether it loads. `--config`
|
|
475
|
+
and the user file always load. The project file loads only when the
|
|
476
|
+
repository is trusted and execution is allowed (`allowExec` not `false`, no
|
|
477
|
+
`--no-exec`); otherwise wayfinder prints a warning and loads nothing from it.
|
|
478
|
+
`way guide extend` prints a complete example. A tool's runner may define
|
|
479
|
+
`invoke(task, args)` to say where typed arguments go, such as after `--` for
|
|
480
|
+
`npm run`; the default appends them.
|
|
481
|
+
|
|
482
|
+
`way providers` lists every registered tool: its roles, its runner kind
|
|
483
|
+
(`parse` reads files, `exec` must run the tool and needs trust), its binary,
|
|
484
|
+
whether that binary is on PATH, and whether it is built in or custom.
|
|
485
|
+
`--json` gives the same rows as data.
|
|
486
|
+
|
|
487
|
+
## How it compares
|
|
488
|
+
|
|
489
|
+
- **Each tool's own list** (`just --list`, `npm run`, `moon query tasks`)
|
|
490
|
+
answers for one tool. wayfinder asks all of them and shows one list.
|
|
491
|
+
- **[fzf-make](https://github.com/kyu08/fzf-make)** is a fuzzy picker for
|
|
492
|
+
make, npm, pnpm, yarn, just and task targets, shipped as a Rust binary.
|
|
493
|
+
- **[runpalette](https://github.com/Adam014/runpalette)** is a Node CLI with
|
|
494
|
+
one list of package.json, justfile, Taskfile, Makefile, Cargo and Gradle
|
|
495
|
+
commands.
|
|
496
|
+
- wayfinder covers more runners (moon, mise, docker-compose, GitHub Actions and
|
|
497
|
+
others), adds the install and hook commands, has a web view and JSON output,
|
|
498
|
+
caches slow runners, and withholds runners that execute code until the
|
|
499
|
+
repository is trusted.
|
|
500
|
+
|
|
501
|
+
## Platforms
|
|
502
|
+
|
|
503
|
+
Tested on Linux and macOS. Windows is untested: running tasks and opening the
|
|
504
|
+
browser assume a POSIX environment.
|
|
505
|
+
|
|
506
|
+
## Licence
|
|
507
|
+
|
|
508
|
+
`MIT OR Apache-2.0`, at your option. See [LICENSE-MIT](./LICENSE-MIT) and [LICENSE-APACHE](./LICENSE-APACHE).
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Security policy
|
|
2
|
+
|
|
3
|
+
## Reporting a vulnerability
|
|
4
|
+
|
|
5
|
+
Please report vulnerabilities privately. Do not open a public issue.
|
|
6
|
+
|
|
7
|
+
Use GitHub private vulnerability reporting on the repository: open the
|
|
8
|
+
[Security tab](https://github.com/osdlc/osdlc/security) and choose
|
|
9
|
+
"Report a vulnerability".
|
|
10
|
+
|
|
11
|
+
Include the version, a short description, and steps to reproduce.
|
|
12
|
+
|
|
13
|
+
## Supported versions
|
|
14
|
+
|
|
15
|
+
Only the latest release gets security fixes. While the version is 0.x, that
|
|
16
|
+
is the latest minor release.
|
|
17
|
+
|
|
18
|
+
## What to expect
|
|
19
|
+
|
|
20
|
+
This is a small project. We aim to reply within a week, tell you whether we
|
|
21
|
+
accept the report, and credit you in the release notes if you want that.
|
|
22
|
+
|
|
23
|
+
## Threat model
|
|
24
|
+
|
|
25
|
+
`way` reads a repository and can run its tasks. Reports about a repository
|
|
26
|
+
making `way` run code the user did not choose to run are in scope.
|
|
27
|
+
|
|
28
|
+
- **Reading a repository can run its code.** Some runners can only be read by
|
|
29
|
+
running them (moon, mise tasks, sbt). They are withheld until the user trusts
|
|
30
|
+
the repository with `way trust` or passes `--exec` for one run. A repository
|
|
31
|
+
cannot trust itself: `allowExec` and `trust` in its own `wayfinder.config.json`
|
|
32
|
+
cannot raise the gate.
|
|
33
|
+
- **Tool modules are code.** A module named by `--config` or the user file is
|
|
34
|
+
the user's own choice. One named by the project file loads only when the
|
|
35
|
+
repository is trusted and execution is allowed.
|
|
36
|
+
- **Tasks run without a shell.** A task is spawned from an argument vector.
|
|
37
|
+
Typed arguments are bound by the task's tool and never replace its binary.
|
|
38
|
+
- **The web view listens on 127.0.0.1.** Any local process and any page the
|
|
39
|
+
browser visits can reach the port. A one-shot boot token and a session token
|
|
40
|
+
guard every route. `/api/run` takes a task id from the server's own catalog,
|
|
41
|
+
never a command. `/api/trust` refuses when a grant would not apply, so
|
|
42
|
+
`--no-exec` cannot be lifted from the page.
|
|
43
|
+
- **Trust is keyed on the resolved path.** A trusted repository that later
|
|
44
|
+
pulls hostile changes stays trusted until `way trust --untrust`.
|
package/bin/way.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The installed `way`. Before running its own code it asks devlink which
|
|
3
|
+
// checkout should answer: `WAY_HOME`, a wayfinder checkout above the cwd, or one
|
|
4
|
+
// linked by `way dev link`. Any of those other than this one runs there
|
|
5
|
+
// instead, so an installed `way` follows the source you are working on.
|
|
6
|
+
// Requires the built dist/ (`pnpm run build`).
|
|
7
|
+
import { execSelection, resolve } from '@osdlc/cli-tool/devlink'
|
|
8
|
+
|
|
9
|
+
import { main } from '../dist/cli.js'
|
|
10
|
+
import { WAYFINDER_SPEC, checkoutRoot } from '../dist/devlink.js'
|
|
11
|
+
|
|
12
|
+
const argv = process.argv.slice(2)
|
|
13
|
+
const handedOff = execSelection(
|
|
14
|
+
WAYFINDER_SPEC,
|
|
15
|
+
resolve(WAYFINDER_SPEC, { self: checkoutRoot() }),
|
|
16
|
+
argv,
|
|
17
|
+
)
|
|
18
|
+
process.exitCode = handedOff ?? (await main(argv))
|
package/dist/app.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The app's names. Every user-facing name that carries the product name
|
|
3
|
+
* derives from here. Browser-safe: the page imports it too.
|
|
4
|
+
*/
|
|
5
|
+
/** The product name: config directory, cache directory, trust store key, message prefix. */
|
|
6
|
+
export declare const APP = "wayfinder";
|
|
7
|
+
/**
|
|
8
|
+
* The name before the rename to wayfinder. Its user config, project config,
|
|
9
|
+
* trust store and config variable are still read when the new ones are
|
|
10
|
+
* absent. Nothing is written under it.
|
|
11
|
+
*/
|
|
12
|
+
export declare const LEGACY_APP = "waypost";
|
|
13
|
+
/** The installed command. */
|
|
14
|
+
export declare const BIN = "way";
|
|
15
|
+
/** Names the user config file, replacing its location only. */
|
|
16
|
+
export declare const CONFIG_ENV_VAR: string;
|
|
17
|
+
/** The old name of {@link CONFIG_ENV_VAR}, read when that one is unset. */
|
|
18
|
+
export declare const LEGACY_CONFIG_ENV_VAR: string;
|
|
19
|
+
/** The project config file, read from the project root. */
|
|
20
|
+
export declare const PROJECT_CONFIG_FILENAME = "wayfinder.config.json";
|
|
21
|
+
/** The old project config file, read when {@link PROJECT_CONFIG_FILENAME} is absent. */
|
|
22
|
+
export declare const LEGACY_PROJECT_CONFIG_FILENAME = "waypost.config.json";
|
|
23
|
+
/** The request header that carries the web view's session token. */
|
|
24
|
+
export declare const TOKEN_HEADER = "x-wayfinder-token";
|
package/dist/app.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The app's names. Every user-facing name that carries the product name
|
|
3
|
+
* derives from here. Browser-safe: the page imports it too.
|
|
4
|
+
*/
|
|
5
|
+
/** The product name: config directory, cache directory, trust store key, message prefix. */
|
|
6
|
+
export const APP = 'wayfinder';
|
|
7
|
+
/**
|
|
8
|
+
* The name before the rename to wayfinder. Its user config, project config,
|
|
9
|
+
* trust store and config variable are still read when the new ones are
|
|
10
|
+
* absent. Nothing is written under it.
|
|
11
|
+
*/
|
|
12
|
+
export const LEGACY_APP = 'waypost';
|
|
13
|
+
/** The installed command. */
|
|
14
|
+
export const BIN = 'way';
|
|
15
|
+
/** Names the user config file, replacing its location only. */
|
|
16
|
+
export const CONFIG_ENV_VAR = `${APP.toUpperCase()}_CONFIG`;
|
|
17
|
+
/** The old name of {@link CONFIG_ENV_VAR}, read when that one is unset. */
|
|
18
|
+
export const LEGACY_CONFIG_ENV_VAR = `${LEGACY_APP.toUpperCase()}_CONFIG`;
|
|
19
|
+
/** The project config file, read from the project root. */
|
|
20
|
+
export const PROJECT_CONFIG_FILENAME = `${APP}.config.json`;
|
|
21
|
+
/** The old project config file, read when {@link PROJECT_CONFIG_FILENAME} is absent. */
|
|
22
|
+
export const LEGACY_PROJECT_CONFIG_FILENAME = `${LEGACY_APP}.config.json`;
|
|
23
|
+
/** The request header that carries the web view's session token. */
|
|
24
|
+
export const TOKEN_HEADER = `x-${APP}-token`;
|
package/dist/args.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turning a typed argument tail into argv entries, shared by the terminal's
|
|
3
|
+
* entry line and the page's run bar so the two never disagree about a quote.
|
|
4
|
+
*
|
|
5
|
+
* {@link runArgv} and {@link acceptArgs} are the boundary: what a caller may
|
|
6
|
+
* contribute to a spawn, and what it may not. As pure functions they can be
|
|
7
|
+
* asserted; the route they protect cannot, because succeeding at it hands over
|
|
8
|
+
* the terminal and exits the process.
|
|
9
|
+
*/
|
|
10
|
+
import type { Project, Task } from '@osdlc/system-model/detect';
|
|
11
|
+
/**
|
|
12
|
+
* The argv a task runs with: the caller's arguments bound the way the task's
|
|
13
|
+
* tool expects (`project.runners.invoke`), so `npm run x -- --flag` gets its
|
|
14
|
+
* `--`.
|
|
15
|
+
*
|
|
16
|
+
* The binary is always `task.argv[0]`, from a catalog this process built by
|
|
17
|
+
* reading the repository, never from a request. `/api/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.
|
|
21
|
+
*/
|
|
22
|
+
export declare function runArgv(project: Project, task: Task, args?: readonly string[]): string[];
|
|
23
|
+
/**
|
|
24
|
+
* The argument list from an untrusted JSON body, or an empty one.
|
|
25
|
+
*
|
|
26
|
+
* Non-strings are DROPPED rather than coerced: `String(value)` would quietly
|
|
27
|
+
* hand a spawn `"[object Object]"` or `"null"` as a real argument, and an
|
|
28
|
+
* argument nobody typed is worse than a missing one.
|
|
29
|
+
*/
|
|
30
|
+
export declare function acceptArgs(value: unknown): string[];
|
|
31
|
+
/**
|
|
32
|
+
* Split a typed argument tail the way a shell splits words, and in no other
|
|
33
|
+
* way a shell behaves.
|
|
34
|
+
*
|
|
35
|
+
* Quotes group and a backslash escapes the next character. There is no
|
|
36
|
+
* globbing, no variable expansion, no operators, no substitution: the result
|
|
37
|
+
* goes to an `execvp`-style spawn as separate argv entries, never to a shell,
|
|
38
|
+
* so `*.log` is passed through as the four characters somebody typed. That is
|
|
39
|
+
* the same rule `argv` and `display` exist to keep.
|
|
40
|
+
*
|
|
41
|
+
* Splitting rather than `.split(/\s+/)` for exactly one reason: a quoted
|
|
42
|
+
* `"two words"` has to stay ONE argument.
|
|
43
|
+
*/
|
|
44
|
+
export declare function splitArgs(input: string): string[];
|