@osdlc/wayfinder 0.7.4 → 0.8.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 +214 -0
- package/CONTRIBUTING.md +6 -0
- package/README.md +295 -150
- package/SECURITY.md +19 -5
- package/dist/actions.d.ts +23 -0
- package/dist/actions.js +97 -0
- package/dist/app.d.ts +1 -13
- package/dist/app.js +1 -13
- package/dist/args.d.ts +11 -6
- package/dist/args.js +25 -7
- package/dist/cache.d.ts +2 -4
- package/dist/cache.js +5 -10
- package/dist/catalog.d.ts +30 -3
- package/dist/catalog.js +87 -11
- package/dist/clean-command.d.ts +65 -36
- package/dist/clean-command.js +372 -226
- package/dist/cli.d.ts +24 -57
- package/dist/cli.js +139 -568
- package/dist/commands/browse.d.ts +128 -0
- package/dist/commands/browse.js +151 -0
- package/dist/commands/index.d.ts +25 -0
- package/dist/commands/index.js +71 -0
- package/dist/commands/list.d.ts +208 -0
- package/dist/commands/list.js +127 -0
- package/dist/commands/query.d.ts +166 -0
- package/dist/commands/query.js +73 -0
- package/dist/commands/run.d.ts +114 -0
- package/dist/commands/run.js +139 -0
- package/dist/commands/shared.d.ts +152 -0
- package/dist/commands/shared.js +209 -0
- package/dist/config-command.d.ts +27 -43
- package/dist/config-command.js +129 -330
- package/dist/config-keys.d.ts +25 -0
- package/dist/config-keys.js +29 -0
- package/dist/config.d.ts +271 -257
- package/dist/config.js +610 -460
- package/dist/core/copy-text.d.ts +30 -0
- package/dist/core/copy-text.js +50 -0
- package/dist/core/filter.d.ts +55 -0
- package/dist/core/filter.js +59 -0
- package/dist/core/run.d.ts +22 -0
- package/dist/core/run.js +59 -0
- package/dist/core/saved-view.d.ts +59 -0
- package/dist/core/saved-view.js +119 -0
- package/dist/core/session.d.ts +262 -0
- package/dist/core/session.js +589 -0
- package/dist/core/skills.d.ts +53 -0
- package/dist/core/skills.js +54 -0
- package/dist/core/unknowns.d.ts +72 -0
- package/dist/core/unknowns.js +68 -0
- package/dist/devlink.d.ts +3 -0
- package/dist/devlink.js +5 -2
- package/dist/document-schemas.generated.d.ts +22 -0
- package/dist/document-schemas.generated.js +916 -0
- package/dist/documents.d.ts +432 -0
- package/dist/documents.js +163 -0
- package/dist/groups.d.ts +22 -26
- package/dist/groups.js +13 -29
- package/dist/guide.d.ts +26 -13
- package/dist/guide.js +119 -103
- package/dist/index.d.ts +112 -0
- package/dist/index.js +58 -0
- package/dist/keys.d.ts +51 -0
- package/dist/keys.js +273 -0
- package/dist/page.d.ts +18 -8
- package/dist/page.js +28 -17
- package/dist/providers-command.d.ts +81 -20
- package/dist/providers-command.js +33 -75
- package/dist/schema.d.ts +48 -0
- package/dist/schema.js +61 -0
- package/dist/serve/auth.d.ts +46 -0
- package/dist/serve/auth.js +82 -0
- package/dist/serve/catalog-share.d.ts +51 -0
- package/dist/serve/catalog-share.js +116 -0
- package/dist/serve/index.d.ts +98 -0
- package/dist/serve/index.js +251 -0
- package/dist/serve/routes.d.ts +60 -0
- package/dist/serve/routes.js +186 -0
- package/dist/serve/terminal-input.d.ts +50 -0
- package/dist/serve/terminal-input.js +108 -0
- package/dist/skills.d.ts +19 -0
- package/dist/skills.js +54 -0
- package/dist/terminal-text.d.ts +8 -0
- package/dist/terminal-text.js +19 -6
- package/dist/tool-info.d.ts +24 -0
- package/dist/tool-info.js +17 -0
- package/dist/trust-command.d.ts +15 -27
- package/dist/trust-command.js +110 -208
- package/dist/trust-store.d.ts +5 -10
- package/dist/trust-store.js +9 -42
- package/dist/tui/app.d.ts +180 -0
- package/dist/tui/app.js +1278 -0
- package/dist/tui/copy.d.ts +29 -0
- package/dist/tui/copy.js +39 -0
- package/dist/tui/index.d.ts +33 -0
- package/dist/tui/index.js +97 -0
- package/dist/tui/keys-input.d.ts +27 -0
- package/dist/tui/keys-input.js +87 -0
- package/dist/tui/settings.d.ts +94 -0
- package/dist/tui/settings.js +198 -0
- package/dist/tui/style.d.ts +62 -0
- package/dist/tui/style.js +77 -0
- package/dist/version.d.ts +6 -0
- package/dist/version.js +7 -0
- package/dist/vocabulary.d.ts +89 -0
- package/dist/vocabulary.js +153 -0
- package/dist/web/main.js +1965 -568
- package/dist/web/page.html +39 -33
- package/dist/web/styles.css +457 -329
- package/dist/xdg.d.ts +76 -4
- package/dist/xdg.js +77 -5
- package/package.json +28 -9
- package/schema/config.json +133 -0
- package/dist/http.d.ts +0 -22
- package/dist/http.js +0 -149
- package/dist/origin-owner.d.ts +0 -19
- package/dist/origin-owner.js +0 -85
- package/dist/serve.d.ts +0 -98
- package/dist/serve.js +0 -671
- package/dist/tui.d.ts +0 -177
- package/dist/tui.js +0 -840
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The session core: what one run of wayfinder knows about one repository,
|
|
3
|
+
* and the operations every surface shares. See `README.md` beside this file
|
|
4
|
+
* for how the CLI, the terminal UI and the web view use it.
|
|
5
|
+
*/
|
|
6
|
+
import type { Catalog, Project, RunnerCacheState, Task } from '@osdlc/system-model/detect';
|
|
7
|
+
import { type ExecGate } from '@osdlc/trust-repo';
|
|
8
|
+
import { type WayOptions } from '../catalog.ts';
|
|
9
|
+
import { type LoadedConfig, type Settings } from '../config.ts';
|
|
10
|
+
import { type ToolSummary } from '../tool-info.ts';
|
|
11
|
+
import { type LoadedTool } from '../tools.ts';
|
|
12
|
+
import { type WithheldReason } from '../vocabulary.ts';
|
|
13
|
+
import { type TaskFilter, type TaskHit } from './filter.ts';
|
|
14
|
+
import { type SkillHit, type SkillRow } from './skills.ts';
|
|
15
|
+
import { type Unknown } from './unknowns.ts';
|
|
16
|
+
/**
|
|
17
|
+
* Why a session could not start, or an operation was refused. `code` is
|
|
18
|
+
* stable, for an error document.
|
|
19
|
+
*/
|
|
20
|
+
export declare class SessionError extends Error {
|
|
21
|
+
readonly code: 'no-such-directory' | 'config' | 'tool-module' | 'not-trustable' | 'task-not-found' | 'ambiguous-task' | 'not-runnable' | 'bad-arguments' | 'task-changed';
|
|
22
|
+
/** A sentence on what to do, when there is one. */
|
|
23
|
+
readonly hint: string | undefined;
|
|
24
|
+
constructor(code: SessionError['code'], message: string, hint?: string);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The choices a command line makes for one run. Each field is absent unless
|
|
28
|
+
* its flag was given, so the config files can answer instead.
|
|
29
|
+
*/
|
|
30
|
+
export interface SessionFlags {
|
|
31
|
+
/** `--exec` or `--no-exec`. */
|
|
32
|
+
allowExec?: boolean | undefined;
|
|
33
|
+
/** `--only`: restrict to these runners. */
|
|
34
|
+
only?: string[] | undefined;
|
|
35
|
+
/** `--exclude`: skip these runners, replacing the configured `runners.disabled`. */
|
|
36
|
+
exclude?: string[] | undefined;
|
|
37
|
+
/** `--exclude-path`, replacing the configured list. */
|
|
38
|
+
excludePaths?: string[] | undefined;
|
|
39
|
+
discovery?: 'git' | 'walk' | 'auto' | undefined;
|
|
40
|
+
/** `--config` modules of extra tools, as typed. */
|
|
41
|
+
toolModules?: readonly string[] | undefined;
|
|
42
|
+
}
|
|
43
|
+
/** What {@link createSession} needs. */
|
|
44
|
+
export interface SessionOptions {
|
|
45
|
+
/** The start directory, absolute or relative to `cwd`. It must exist. */
|
|
46
|
+
dir: string;
|
|
47
|
+
/** The working directory: the base for a relative `dir` and `--config` paths. */
|
|
48
|
+
cwd: string;
|
|
49
|
+
/** The environment config, trust and cache paths are read from. */
|
|
50
|
+
env: Record<string, string | undefined>;
|
|
51
|
+
/** The home directory. Default: the OS account's. */
|
|
52
|
+
home?: string | undefined;
|
|
53
|
+
flags?: SessionFlags | undefined;
|
|
54
|
+
/** Aborts every probe this session starts. */
|
|
55
|
+
signal?: AbortSignal | undefined;
|
|
56
|
+
}
|
|
57
|
+
/** One runner's cache verdict, with the measured time of a probe made just now. */
|
|
58
|
+
export type CacheState = RunnerCacheState & {
|
|
59
|
+
/** How long this runner's probe took, when it was probed in this call. */
|
|
60
|
+
probeMs?: number | undefined;
|
|
61
|
+
};
|
|
62
|
+
/** A catalog and where each runner's rows came from. */
|
|
63
|
+
export interface CatalogSnapshot {
|
|
64
|
+
/** Grouped and in the configured runner order. */
|
|
65
|
+
catalog: Catalog;
|
|
66
|
+
/** One entry per selected runner. */
|
|
67
|
+
cache: CacheState[];
|
|
68
|
+
/** The agent skills for the Skills group, as the `skills` setting chooses. */
|
|
69
|
+
skills: SkillRow[];
|
|
70
|
+
/**
|
|
71
|
+
* `probe`: every runner was probed now. `store`: from the stored probe,
|
|
72
|
+
* with any runner missing from it probed now. `empty-store`: a stored
|
|
73
|
+
* answer was asked for, but there was none, so it was probed now.
|
|
74
|
+
* `saved`: the view the last probe or store read showed, not checked
|
|
75
|
+
* against the files (see {@link Session.savedCatalog}).
|
|
76
|
+
*/
|
|
77
|
+
origin: 'probe' | 'store' | 'empty-store' | 'saved';
|
|
78
|
+
}
|
|
79
|
+
/** The facts behind a settings screen. */
|
|
80
|
+
export interface SettingsSnapshot {
|
|
81
|
+
root: string;
|
|
82
|
+
/** Every setting and its source, from the reader `way config` uses. */
|
|
83
|
+
settings: Settings;
|
|
84
|
+
/** Whether this session runs the repository's tools. */
|
|
85
|
+
allowExec: boolean;
|
|
86
|
+
/** Why {@link allowExec} came out as it did. */
|
|
87
|
+
reason: ExecGate['reason'];
|
|
88
|
+
trusted: boolean;
|
|
89
|
+
/** Whether a trust grant would change this session's execution. */
|
|
90
|
+
trustable: boolean;
|
|
91
|
+
/** Every registered tool's description, homepage and language, in registry order. */
|
|
92
|
+
tools: ToolSummary[];
|
|
93
|
+
/**
|
|
94
|
+
* The tool ids trusted on their own, by a `--scope` grant or `trust.tools`
|
|
95
|
+
* in the user config. Empty when the repository is trusted as a whole, or
|
|
96
|
+
* trust does not decide execution.
|
|
97
|
+
*/
|
|
98
|
+
trustedTools: string[];
|
|
99
|
+
}
|
|
100
|
+
/** What {@link Session.saveSetting} wrote. */
|
|
101
|
+
export interface SavedSetting {
|
|
102
|
+
key: string;
|
|
103
|
+
/** The file it was written to. */
|
|
104
|
+
file: string;
|
|
105
|
+
layer: 'user' | 'project';
|
|
106
|
+
/** A command-line flag decides this setting for the rest of this session. */
|
|
107
|
+
pinned: boolean;
|
|
108
|
+
/** The settings as read back after the write. */
|
|
109
|
+
snapshot: SettingsSnapshot;
|
|
110
|
+
}
|
|
111
|
+
/** What a trust grant or revoke changed. */
|
|
112
|
+
export interface TrustChange {
|
|
113
|
+
/** False when the store already said so. */
|
|
114
|
+
changed: boolean;
|
|
115
|
+
/** A sentence to show, such as that project tools load on the next start. */
|
|
116
|
+
note?: string | undefined;
|
|
117
|
+
}
|
|
118
|
+
/** A task ready to run: what to spawn, where, and with which variables. */
|
|
119
|
+
export interface RunPlan {
|
|
120
|
+
task: Task;
|
|
121
|
+
/** The argv to spawn, without a shell. `argv[0]` is always the task's own. */
|
|
122
|
+
argv: string[];
|
|
123
|
+
/** Variables the task's `env` parameters set, added to the environment. */
|
|
124
|
+
env: Record<string, string>;
|
|
125
|
+
/** Absolute. */
|
|
126
|
+
cwd: string;
|
|
127
|
+
}
|
|
128
|
+
/** One run of wayfinder over one repository. */
|
|
129
|
+
export interface Session {
|
|
130
|
+
/** The project root the start directory is in. */
|
|
131
|
+
readonly root: string;
|
|
132
|
+
/** The config as last read: at start, then after {@link reloadSettings} or {@link saveSetting}. */
|
|
133
|
+
readonly config: LoadedConfig;
|
|
134
|
+
/** Warnings from the config files and the tool modules, for stderr. */
|
|
135
|
+
readonly warnings: readonly string[];
|
|
136
|
+
/** The execution decision. A trust grant updates it. */
|
|
137
|
+
readonly gate: ExecGate;
|
|
138
|
+
readonly project: Project;
|
|
139
|
+
/** The tools loaded from modules, beside the built-ins. */
|
|
140
|
+
readonly tools: readonly LoadedTool[];
|
|
141
|
+
/**
|
|
142
|
+
* The collect options. A trust grant, a saved setting and a reload change
|
|
143
|
+
* them in place, so a probe always uses the current ones.
|
|
144
|
+
*/
|
|
145
|
+
readonly options: WayOptions;
|
|
146
|
+
/** The project file names tools that were not loaded, because execution is not allowed. */
|
|
147
|
+
readonly projectToolsPending: boolean;
|
|
148
|
+
/** The collect options a flag set, which a saved setting must not undo. */
|
|
149
|
+
readonly pinnedByFlag: readonly string[];
|
|
150
|
+
/** Where probes are stored. */
|
|
151
|
+
readonly store: string;
|
|
152
|
+
readonly env: Record<string, string | undefined>;
|
|
153
|
+
readonly home: string;
|
|
154
|
+
/** `runners.order` from the config as last read. */
|
|
155
|
+
runnerOrder(): string[] | undefined;
|
|
156
|
+
/** Why withheld runners are withheld, or null when execution is allowed. */
|
|
157
|
+
withheldReason(): WithheldReason | null;
|
|
158
|
+
/**
|
|
159
|
+
* The catalog. Probed fresh by default, since a script must not get an old
|
|
160
|
+
* answer without being told. `cached` answers with {@link savedCatalog}
|
|
161
|
+
* when there is one, which checks nothing; else it reads the store, which
|
|
162
|
+
* checks each runner's files, and probes only the runners missing from it.
|
|
163
|
+
* A probe always writes the store. `signal`
|
|
164
|
+
* stops this call's probes as well as the session's own signal.
|
|
165
|
+
*/
|
|
166
|
+
catalog(opts?: {
|
|
167
|
+
cached?: boolean;
|
|
168
|
+
signal?: AbortSignal | undefined;
|
|
169
|
+
}): Promise<CatalogSnapshot>;
|
|
170
|
+
/**
|
|
171
|
+
* The catalog from the store alone, probing nothing: for a first paint
|
|
172
|
+
* before a probe. Null when the store has no answer for this project. A
|
|
173
|
+
* runner missing from the store is missing from the catalog.
|
|
174
|
+
*/
|
|
175
|
+
storedCatalog(): Promise<CatalogSnapshot | null>;
|
|
176
|
+
/**
|
|
177
|
+
* The catalog the last {@link catalog} call showed, in this process or
|
|
178
|
+
* another, read from one file without detecting or hashing anything: for
|
|
179
|
+
* a first paint in well under a second. Not checked against the files, so
|
|
180
|
+
* probe after drawing it. Null when nothing was saved under this session's
|
|
181
|
+
* trust and settings. Each `cache[].ageMs` counts from the probe.
|
|
182
|
+
*/
|
|
183
|
+
savedCatalog(): Promise<CatalogSnapshot | null>;
|
|
184
|
+
/**
|
|
185
|
+
* Before a task from a saved or stored listing runs: probe its runner
|
|
186
|
+
* alone, and return the plan for the task as that probe sees it. Throws
|
|
187
|
+
* {@link SessionError} `task-changed` when the task is gone, or its argv or
|
|
188
|
+
* cwd differ from `plan`'s; the message shows the new command line. A
|
|
189
|
+
* dry run does not need this.
|
|
190
|
+
*/
|
|
191
|
+
confirmRun(plan: RunPlan, args?: readonly string[], signal?: AbortSignal): Promise<RunPlan>;
|
|
192
|
+
/**
|
|
193
|
+
* What decides which rows a probe returns here: trust, the collect
|
|
194
|
+
* options, the skills setting and the tools. Two sessions with the same
|
|
195
|
+
* key read the same catalog.
|
|
196
|
+
*/
|
|
197
|
+
viewKey(): string;
|
|
198
|
+
/** The tasks of `catalog` that pass `filter`, best first when there is a query. */
|
|
199
|
+
search(catalog: Catalog, filter: TaskFilter): TaskHit[];
|
|
200
|
+
/** The skills that pass `filter`, matched as {@link search} matches tasks. */
|
|
201
|
+
searchSkills(skills: readonly SkillRow[], filter: TaskFilter): SkillHit[];
|
|
202
|
+
/** Everything this session could not know about `snapshot`. */
|
|
203
|
+
unknowns(snapshot: Pick<CatalogSnapshot, 'catalog' | 'cache'>): Unknown[];
|
|
204
|
+
/** Whether a trust grant would change this session's execution. */
|
|
205
|
+
trustable(): boolean;
|
|
206
|
+
/**
|
|
207
|
+
* Trust the repository and allow execution for the rest of this session.
|
|
208
|
+
* With `scope`, a tool or runner id, trust only that tool: a runner runs
|
|
209
|
+
* once it and each tool manager that wraps it are trusted (see the
|
|
210
|
+
* `missing` of a withheld unknown). Throws {@link SessionError}
|
|
211
|
+
* `not-trustable` when trust is not what withholds execution, and
|
|
212
|
+
* `bad-arguments` for a scope that cannot be a grant. Probe again
|
|
213
|
+
* afterwards.
|
|
214
|
+
*/
|
|
215
|
+
grantTrust(scope?: string): Promise<TrustChange>;
|
|
216
|
+
/**
|
|
217
|
+
* Remove the repository's trust grant, or with `scope` that tool's. A
|
|
218
|
+
* whole-repository revoke leaves this session's execution as it is until
|
|
219
|
+
* it ends; a tool revoke applies to the next probe.
|
|
220
|
+
*/
|
|
221
|
+
revokeTrust(scope?: string): Promise<TrustChange>;
|
|
222
|
+
/**
|
|
223
|
+
* The trust scopes `runner` needs that are not trusted, as of the last
|
|
224
|
+
* probe. Empty when it may run; undefined when per-tool trust does not
|
|
225
|
+
* apply (the repository is trusted, or execution is off).
|
|
226
|
+
*/
|
|
227
|
+
missingScopes(runner: string): string[] | undefined;
|
|
228
|
+
/** The settings as last read, with this session's execution and trust. */
|
|
229
|
+
settings(): SettingsSnapshot;
|
|
230
|
+
/**
|
|
231
|
+
* Read the config files again, so {@link settings} shows edits made
|
|
232
|
+
* elsewhere. The collect options and the `skills` setting follow, except
|
|
233
|
+
* where a flag decided. Throws {@link SessionError} `config`.
|
|
234
|
+
*/
|
|
235
|
+
reloadSettings(): Promise<SettingsSnapshot>;
|
|
236
|
+
/**
|
|
237
|
+
* Save one setting, as a settings screen does, then read the files back as
|
|
238
|
+
* {@link reloadSettings} does. The file comes from `settingLayer`: the
|
|
239
|
+
* user file for a user-only key, the file that sets `runners.order`, else
|
|
240
|
+
* the project file. Throws {@link SessionError} `config` for a value the
|
|
241
|
+
* key does not take or a file that cannot be written or read back; the
|
|
242
|
+
* message starts with `not saved:` or `saved to <file>, but`.
|
|
243
|
+
*/
|
|
244
|
+
saveSetting(key: string, value: unknown): Promise<SavedSetting>;
|
|
245
|
+
/**
|
|
246
|
+
* The task `id` names (an id, or a line from `list` or a `display` only
|
|
247
|
+
* one task has), with `args` bound the way its tool expects. The
|
|
248
|
+
* same rules as the terminal UI and the web view. Throws
|
|
249
|
+
* {@link SessionError}: `task-not-found`, `ambiguous-task`, `not-runnable` or
|
|
250
|
+
* `bad-arguments`.
|
|
251
|
+
*/
|
|
252
|
+
resolveRun(catalog: Catalog, id: string, args?: readonly string[]): RunPlan;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Start a session: find the root, load config, decide execution against the
|
|
256
|
+
* trust store, and load tool modules. Throws {@link SessionError} for a start
|
|
257
|
+
* directory that does not exist, a config file that cannot be used, or a tool
|
|
258
|
+
* module that cannot be loaded.
|
|
259
|
+
*/
|
|
260
|
+
export declare function createSession(opts: SessionOptions): Promise<Session>;
|
|
261
|
+
/** See {@link Session.resolveRun}. */
|
|
262
|
+
export declare function resolveRun(project: Project, root: string, catalog: Catalog, id: string, args?: readonly string[]): RunPlan;
|