@osdlc/wayfinder 0.7.1 → 0.7.2

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/dist/tui.d.ts CHANGED
@@ -1,21 +1,19 @@
1
1
  /**
2
- * The terminal UI — browse every task in a repository, and run one.
2
+ * The terminal UI: browse every task in a repository, and run one.
3
3
  *
4
- * The affordance a browser cannot have: Enter RUNS the selected task, in this
5
- * shell, with the terminal handed to it. A web view can only ever offer you
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
- * Dependency-free: raw mode, ANSI, and one frame string per keystroke. A TUI
9
- * toolkit would be a heavier dependency than the code it saves, and this has to
10
- * keep working from a checkout whose node_modules is the thing you are trying
11
- * to repair. The CLI routes its output through the `CliIo` seam so
12
- * `main()` is testable without touching a real stream, but this file writes
13
- * to `process.stdout` directly — owning the interactive terminal, raw mode,
14
- * the alternate screen, handing the terminal to a spawned task, is the whole
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 asynchronous, which is what most of the state machinery below
18
- * is for: keystrokes arrive mid-refresh, and a row can be stale.
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
- /** The project file names tools that were not loaded because the repository is untrusted or execution is off. */
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, threaded from the CLI. Injectable
41
- * for the reason every sibling in this lane is: a test that let them default
42
- * would grant trust in the developer's own `~/.local/state/wayfinder/`. Nothing but
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 — one entry per selected provider.
50
+ * Where each runner's rows came from, one entry per selected runner.
51
51
  *
52
- * The boot sequence paints from the store before anything is probed, so a row
53
- * on screen may be an hour old. This is what says which, and it is cleared to
54
- * all-fresh the moment a real probe lands.
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 came out the way it did, resolved once by the CLI. Only
69
- * `"untrusted"` earns the ^s affordance: when a config file turned execution
70
- * off, trusting the repository would change nothing, and offering it would be
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 permits this
76
- * repository's code to run, so it cannot be granted by one keystroke —
77
- * least of all ^s, which is flow control on many terminals and arrives
78
- * unintentionally. The second key is what makes it a decision.
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
- * Non-null only for a task that declares parameters: `argv` omits them, so
85
- * running one straight off Enter spawns `just deploy` with no environment
86
- * and the terminal is gone before anything can say so. Null is the ordinary
87
- * case and costs an unparameterised task nothing — Enter still runs it.
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: it reads the config
97
- * from disk, which is IO, and a screen that re-read it per keystroke would
98
- * be doing that for a view nothing can change from here.
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
- /** Bumped per refresh so a superseded result cannot overwrite a newer one. */
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: `runTui` owns a real terminal and never returns, so
110
- * the selection rule — the thing that must survive a refresh reordering and
111
- * dropping rows underneath the cursor — is only testable through this and
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 NOTHING: a line that is always there is a line nobody reads, and
119
- * there is nothing here to report.
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-and-slow is separated from ordinary stale because it is the case the
122
- * whole cache exists for. A runner this repository has MEASURED at several
123
- * seconds is why the screen would otherwise have been empty, and telling the
124
- * user "a moment" in the same voice as a 200ms refresh would waste the one
125
- * warning that matters. Slow is measured, never declared — a runner that is
126
- * quick here is not called slow because it is slow elsewhere.
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 alongside {@link state} and {@link recompute} so the three cache
138
- * states can be asserted as RENDERED lines rather than as the helper that feeds
139
- * them — the status line is the surface a user reads, and a note that is
140
- * correct but composed into the wrong line helps nobody.
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 exercised without a terminal. It is
148
- * the whole reason selection is held by task id: a refresh reorders rows and
149
- * drops some of them, and an index would silently point at a different task —
150
- * which is the same keystroke running the wrong command.
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: `runTui` owns a real terminal and
157
- * never returns, so the keys that reach disk — settings, trust — are only
158
- * reachable from a test through this.
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's already-resolved trust decision. The TUI needs it, not
163
- * just the boolean it produced, because "no exec because a file said so" and
164
- * "no exec because this repository is not trusted" call for different offers —
165
- * only the second one has an action a keystroke can take.
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;