@osdlc/wayfinder 0.7.1 → 0.7.3
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 +33 -0
- package/README.md +210 -182
- package/SECURITY.md +39 -1
- package/bin/way.js +14 -9
- package/dist/args.d.ts +16 -16
- package/dist/args.js +19 -19
- package/dist/cache.js +3 -4
- package/dist/clean-command.d.ts +18 -18
- package/dist/clean-command.js +35 -36
- package/dist/cli.d.ts +19 -20
- package/dist/cli.js +76 -69
- package/dist/config-command.d.ts +15 -14
- package/dist/config-command.js +63 -59
- package/dist/config.d.ts +135 -130
- package/dist/config.js +156 -149
- package/dist/devlink.d.ts +6 -2
- package/dist/devlink.js +7 -2
- package/dist/guide.js +5 -4
- package/dist/origin-owner.d.ts +7 -2
- package/dist/origin-owner.js +20 -4
- package/dist/providers-command.d.ts +1 -1
- package/dist/providers-command.js +11 -23
- package/dist/serve.d.ts +43 -42
- package/dist/serve.js +251 -258
- package/dist/terminal-text.d.ts +57 -0
- package/dist/terminal-text.js +91 -0
- package/dist/tools.d.ts +4 -4
- package/dist/tools.js +4 -4
- package/dist/trust-command.d.ts +6 -7
- package/dist/trust-command.js +48 -50
- package/dist/trust-store.d.ts +1 -1
- package/dist/tui.d.ts +65 -66
- package/dist/tui.js +124 -130
- package/dist/web/main.js +371 -386
- package/dist/web/page.html +6 -5
- package/dist/web/styles.css +258 -271
- package/package.json +9 -9
package/dist/tui.d.ts
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The terminal UI
|
|
2
|
+
* The terminal UI: browse every task in a repository, and run one.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* something to paste.
|
|
4
|
+
* Unlike the page, Enter runs the selected task in this shell and hands it the
|
|
5
|
+
* terminal. The page can only give you a command to paste.
|
|
7
6
|
*
|
|
8
|
-
*
|
|
9
|
-
* toolkit would
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* to
|
|
14
|
-
* the
|
|
15
|
-
* point of it, and that job is outside the seam by design.
|
|
7
|
+
* No dependencies: raw mode, ANSI, and one frame string per keystroke. A TUI
|
|
8
|
+
* toolkit would weigh more than the code it saves, and this has to keep
|
|
9
|
+
* working from a checkout whose node_modules is what you are trying to repair.
|
|
10
|
+
* The CLI sends its output through `CliIo` so `main()` can be tested without
|
|
11
|
+
* a real stream. This file writes to `process.stdout` directly, because its
|
|
12
|
+
* job is to control the terminal: raw mode, the alternate screen, and handing
|
|
13
|
+
* the terminal to a spawned task.
|
|
16
14
|
*
|
|
17
|
-
* Collection is
|
|
18
|
-
*
|
|
15
|
+
* Collection is async, which is what most of the state handling below is for:
|
|
16
|
+
* keystrokes arrive during a refresh, and a row can be stale.
|
|
19
17
|
*/
|
|
20
18
|
import { type Catalog, type Project, type RunnerCacheState, type Task } from '@osdlc/system-model/detect';
|
|
21
19
|
import { type Mode } from '@osdlc/system-model/match';
|
|
@@ -30,28 +28,30 @@ interface State {
|
|
|
30
28
|
catalog: Catalog | null;
|
|
31
29
|
/** The registered tools, built-ins plus any loaded. */
|
|
32
30
|
project: Project;
|
|
33
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* The project file names tools that were not loaded, because the repository
|
|
33
|
+
* is untrusted or execution is off.
|
|
34
|
+
*/
|
|
34
35
|
projectToolsPending: boolean;
|
|
35
36
|
root: string;
|
|
36
37
|
options: WayOptions;
|
|
37
38
|
/** `runners.order` from config; applied to every collected catalog. */
|
|
38
39
|
runnerOrder: string[] | undefined;
|
|
39
40
|
/**
|
|
40
|
-
* The trust store's environment and home,
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* a test ever passes them.
|
|
41
|
+
* The trust store's environment and home, passed from the CLI. Injectable so
|
|
42
|
+
* a test does not grant trust in the developer's own
|
|
43
|
+
* `~/.local/state/wayfinder/`. Only tests pass them.
|
|
44
44
|
*/
|
|
45
45
|
env: Record<string, string | undefined> | undefined;
|
|
46
46
|
home: string | undefined;
|
|
47
47
|
/** Where stored probes live, resolved once from the injected env and home. */
|
|
48
48
|
store: string;
|
|
49
49
|
/**
|
|
50
|
-
* Where each runner's rows came from
|
|
50
|
+
* Where each runner's rows came from, one entry per selected runner.
|
|
51
51
|
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
52
|
+
* At start the screen shows the store before anything is probed, so a row
|
|
53
|
+
* may be an hour old. This records which rows are, and is reset to all-fresh
|
|
54
|
+
* as soon as a real probe finishes.
|
|
55
55
|
*/
|
|
56
56
|
cache: RunnerCacheState[];
|
|
57
57
|
runner: string;
|
|
@@ -65,26 +65,25 @@ interface State {
|
|
|
65
65
|
message: string;
|
|
66
66
|
loading: boolean;
|
|
67
67
|
/**
|
|
68
|
-
* Why execution
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* a wrong instruction.
|
|
68
|
+
* Why execution is on or off, decided once by the CLI. Only `"untrusted"`
|
|
69
|
+
* offers ^s. When a config file turned execution off, trusting the
|
|
70
|
+
* repository would change nothing, so offering it would mislead.
|
|
72
71
|
*/
|
|
73
72
|
gate: ExecGate | null;
|
|
74
73
|
/**
|
|
75
|
-
* True once ^s has asked and is waiting for `y`. Trust
|
|
76
|
-
* repository's code
|
|
77
|
-
*
|
|
78
|
-
*
|
|
74
|
+
* True once ^s has asked and is waiting for `y`. Trust lets this
|
|
75
|
+
* repository's code run, so one keystroke cannot grant it. This matters
|
|
76
|
+
* most for ^s, which is flow control on many terminals and can be sent by
|
|
77
|
+
* accident. The second key makes it a decision.
|
|
79
78
|
*/
|
|
80
79
|
confirmingTrust: boolean;
|
|
81
80
|
/**
|
|
82
81
|
* The task whose arguments are being typed, and what has been typed so far.
|
|
83
82
|
*
|
|
84
|
-
*
|
|
85
|
-
* running
|
|
86
|
-
* and the terminal
|
|
87
|
-
*
|
|
83
|
+
* Set only for a task that declares parameters. `argv` leaves them out, so
|
|
84
|
+
* running it straight from Enter would spawn `just deploy` with no
|
|
85
|
+
* environment, and the terminal would be handed over before anything could
|
|
86
|
+
* say so. For a task with no parameters it stays null and Enter runs it.
|
|
88
87
|
*/
|
|
89
88
|
entering: {
|
|
90
89
|
task: Task;
|
|
@@ -93,12 +92,12 @@ interface State {
|
|
|
93
92
|
/**
|
|
94
93
|
* The settings screen's rendered lines, or null when it is closed.
|
|
95
94
|
*
|
|
96
|
-
* Rendered once on open rather than on every frame
|
|
97
|
-
* from disk,
|
|
98
|
-
*
|
|
95
|
+
* Rendered once on open rather than on every frame. It reads the config
|
|
96
|
+
* from disk, and nothing on this screen can change it, so re-reading it per
|
|
97
|
+
* keystroke would be wasted work.
|
|
99
98
|
*/
|
|
100
99
|
settings: string[] | null;
|
|
101
|
-
/**
|
|
100
|
+
/** Increased on each refresh, so an older result cannot overwrite a newer one. */
|
|
102
101
|
generation: number;
|
|
103
102
|
inFlight: AbortController | null;
|
|
104
103
|
rows: Row[];
|
|
@@ -106,24 +105,24 @@ interface State {
|
|
|
106
105
|
/**
|
|
107
106
|
* The module singleton.
|
|
108
107
|
*
|
|
109
|
-
* Exported for one reason
|
|
110
|
-
* the selection rule
|
|
111
|
-
*
|
|
112
|
-
* { recompute}. Nothing outside a test writes to it.
|
|
108
|
+
* Exported for one reason. `runTui` takes over a real terminal and never
|
|
109
|
+
* returns, so the selection rule (the selection must survive a refresh that
|
|
110
|
+
* reorders or drops rows under the cursor) can only be tested through this
|
|
111
|
+
* and {@link recompute}. Nothing outside a test writes to it.
|
|
113
112
|
*/
|
|
114
113
|
export declare const state: State;
|
|
115
114
|
/**
|
|
116
115
|
* What the status line says about the rows on screen, in three states.
|
|
117
116
|
*
|
|
118
|
-
* Fresh says
|
|
119
|
-
* there is nothing
|
|
117
|
+
* Fresh says nothing. A line that is always shown is a line nobody reads,
|
|
118
|
+
* and there is nothing to report.
|
|
120
119
|
*
|
|
121
|
-
* Stale
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
120
|
+
* Stale and slow is kept apart from ordinary stale because it is the case the
|
|
121
|
+
* cache exists for. A runner measured at several seconds in this repository
|
|
122
|
+
* is why the screen would otherwise be empty. Showing it the same way as a
|
|
123
|
+
* 200ms refresh would hide the one warning that matters. Slowness is
|
|
124
|
+
* measured, never assumed: a runner that is quick here is not called slow
|
|
125
|
+
* because it is slow elsewhere.
|
|
127
126
|
*/
|
|
128
127
|
export declare function refreshNote(rows: readonly RunnerCacheState[], loading: boolean): {
|
|
129
128
|
text: string;
|
|
@@ -134,35 +133,35 @@ export declare function cursor(): number;
|
|
|
134
133
|
/**
|
|
135
134
|
* The whole screen as one string.
|
|
136
135
|
*
|
|
137
|
-
* Exported
|
|
138
|
-
*
|
|
139
|
-
* them
|
|
140
|
-
*
|
|
136
|
+
* Exported with {@link state} and {@link recompute} so tests can check the
|
|
137
|
+
* three cache states in the rendered lines, not only in the helper that
|
|
138
|
+
* builds them. The user reads the status line, and a correct note placed in
|
|
139
|
+
* the wrong line helps nobody.
|
|
141
140
|
*/
|
|
142
141
|
export declare function frame(width: number, height: number): string;
|
|
143
142
|
/**
|
|
144
143
|
* Rebuild the visible rows and re-anchor the selection onto a task that is
|
|
145
144
|
* still there.
|
|
146
145
|
*
|
|
147
|
-
* Split out of {@link draw} so it can be
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
146
|
+
* Split out of {@link draw} so it can be tested without a terminal. This is
|
|
147
|
+
* why selection is held by task id: a refresh reorders and drops rows, and an
|
|
148
|
+
* index would silently point at a different task, so the same keystroke
|
|
149
|
+
* would run the wrong command.
|
|
151
150
|
*/
|
|
152
151
|
export declare function recompute(): void;
|
|
153
152
|
/**
|
|
154
153
|
* One keystroke.
|
|
155
154
|
*
|
|
156
|
-
* Exported for the same reason `state` is
|
|
157
|
-
* never returns, so the keys that
|
|
158
|
-
*
|
|
155
|
+
* Exported for the same reason `state` is. `runTui` takes over a real
|
|
156
|
+
* terminal and never returns, so tests reach the keys that touch disk
|
|
157
|
+
* (settings, trust) only through this.
|
|
159
158
|
*/
|
|
160
159
|
export declare function handle(key: string): void;
|
|
161
160
|
/**
|
|
162
|
-
* `gate` is the CLI
|
|
163
|
-
* just
|
|
164
|
-
*
|
|
165
|
-
* only the second
|
|
161
|
+
* `gate` is the trust decision the CLI already made. The TUI needs the whole
|
|
162
|
+
* decision, not just its boolean. "No exec because a file said so" and "no
|
|
163
|
+
* exec because this repository is not trusted" need different messages, and
|
|
164
|
+
* only the second has a key that fixes it.
|
|
166
165
|
*/
|
|
167
166
|
export interface TuiOptions {
|
|
168
167
|
project: Project;
|