@osdlc/wayfinder 0.7.3 → 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 +221 -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
package/dist/groups.js
CHANGED
|
@@ -1,38 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The row groups every surface shows: tasks from runners, then the actions
|
|
3
3
|
* system-model synthesizes from package managers, tool managers and hook
|
|
4
|
-
* managers
|
|
5
|
-
*
|
|
4
|
+
* managers, then agent skills. The report groups are
|
|
5
|
+
* `@osdlc/system-model/groups`; this module adds the order wayfinder sorts
|
|
6
|
+
* reports by and the Skills group, whose rows are `CatalogSnapshot.skills`
|
|
7
|
+
* rather than a report. Browser-safe: the page imports it.
|
|
6
8
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* browser-safe; a test checks they agree.
|
|
11
|
-
*/
|
|
12
|
-
export const GROUPS = [
|
|
13
|
-
{ id: 'tasks', title: 'Tasks' },
|
|
14
|
-
{ id: 'dependencies', title: 'Dependencies', runner: 'package-manager' },
|
|
15
|
-
{ id: 'tools', title: 'Tools', runner: 'tool-manager' },
|
|
16
|
-
{ id: 'hooks', title: 'Git hooks', runner: 'hook-manager' },
|
|
17
|
-
];
|
|
18
|
-
/** The group a runner's report belongs to. */
|
|
19
|
-
export function groupOf(runner) {
|
|
20
|
-
return GROUPS.find((g) => g.runner === runner) ?? GROUPS[0];
|
|
21
|
-
}
|
|
9
|
+
import { GROUPS, catalogGroups, groupOf } from '@osdlc/system-model/groups';
|
|
10
|
+
export { GROUPS, catalogGroups, groupOf } from '@osdlc/system-model/groups';
|
|
11
|
+
export { runnerLabel } from "./vocabulary.js";
|
|
22
12
|
/** Position of a runner's group in {@link GROUPS}. */
|
|
23
13
|
export function groupRank(runner) {
|
|
24
14
|
return GROUPS.indexOf(groupOf(runner));
|
|
25
15
|
}
|
|
26
|
-
/**
|
|
27
|
-
export
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
export function catalogGroups(reports) {
|
|
33
|
-
return GROUPS.map((g) => ({
|
|
34
|
-
id: g.id,
|
|
35
|
-
title: g.title,
|
|
36
|
-
runners: reports.filter((r) => groupOf(r.runner) === g).map((r) => r.runner),
|
|
37
|
-
})).filter((g) => g.runners.length > 0);
|
|
16
|
+
/** The Skills group. Its rows are skills, not a runner's tasks, so it names no runner. */
|
|
17
|
+
export const SKILLS_GROUP = { id: 'skills', title: 'Skills' };
|
|
18
|
+
/** The groups with rows, in display order: the report groups, then Skills when there are skills. */
|
|
19
|
+
export function documentGroups(reports, skillCount) {
|
|
20
|
+
const groups = catalogGroups(reports);
|
|
21
|
+
return skillCount > 0 ? [...groups, { ...SKILLS_GROUP, runners: [] }] : groups;
|
|
38
22
|
}
|
package/dist/guide.d.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* `way guide`: cli-tool's shared `guide` command over wayfinder's topics,
|
|
3
|
+
* Markdown for a person or a model who has the binary and not the README.
|
|
4
|
+
* `--help` lists the flags; this says what `--json` hands you, why a runner is
|
|
5
|
+
* missing, and how to add a tool.
|
|
5
6
|
*
|
|
6
7
|
* Sections are data, so `tests/guide.test.ts` can check each one against the
|
|
7
8
|
* code it describes. No roster is retyped: the built-in tools come from
|
|
8
9
|
* `builtins` and the settable keys from `CONFIG_KEYS`.
|
|
9
10
|
*/
|
|
10
|
-
import {
|
|
11
|
+
import type { CommandContext, DataCommand } from '@osdlc/cli-tool/command';
|
|
12
|
+
import type { FlagSpec } from '@osdlc/cli-tool/define-cli';
|
|
11
13
|
/** One section of the guide. The document is these, in this order. */
|
|
12
|
-
export type
|
|
13
|
-
export declare const GUIDE_TOPICS: readonly
|
|
14
|
+
export type GuideTopicId = 'usage' | 'config' | 'json' | 'trust' | 'extend';
|
|
15
|
+
export declare const GUIDE_TOPICS: readonly GuideTopicId[];
|
|
14
16
|
/**
|
|
15
|
-
* What the guide takes from the CLI. `usage` is the same string
|
|
16
|
-
* prints, so the guide's flag list and the help cannot drift.
|
|
17
|
+
* What the guide takes from the CLI. `usage` is the same string the complete
|
|
18
|
+
* help prints, so the guide's flag list and the help cannot drift.
|
|
17
19
|
*/
|
|
18
20
|
export interface GuideTool {
|
|
19
21
|
usage: string;
|
|
@@ -24,9 +26,20 @@ export interface GuideTool {
|
|
|
24
26
|
* the typechecker compiles, and `tests/guide.test.ts` checks the two match.
|
|
25
27
|
*/
|
|
26
28
|
export declare const EXTEND_EXAMPLE = "import type { ToolDef } from '@osdlc/system-model/detect'\n\nexport const tools: ToolDef[] = [\n {\n id: 'acme',\n binary: 'acme',\n markers: [{ files: '/acme.json', tier: 'files' }],\n roles: {\n runner: {\n kind: 'parse',\n chain: [{ label: 'task', hint: 'the acme task to run' }],\n async collect(ctx) {\n const config = (await ctx.readJson('acme.json')) as { tasks?: string[] } | null\n const tasks = (config?.tasks ?? []).map((name) => ({\n id: `acme:${name}`,\n runner: 'acme',\n path: ['acme', name],\n argv: ['acme', 'run', name],\n cwd: '.',\n display: `acme run ${name}`,\n parameters: [],\n source: 'acme.json',\n origin: 'declared' as const,\n tags: [],\n persistent: { value: false, declared: false },\n executes: 'local' as const,\n }))\n return { status: 'ok', tasks, diagnostics: [] }\n },\n },\n },\n },\n]\n";
|
|
27
|
-
/** One section
|
|
28
|
-
export declare function guideSection(topic:
|
|
29
|
-
/**
|
|
29
|
+
/** One section with its heading, as `guide <topic>` prints it. */
|
|
30
|
+
export declare function guideSection(topic: GuideTopicId, tool: GuideTool): string;
|
|
31
|
+
/** The guide's title. */
|
|
32
|
+
export declare const GUIDE_TITLE = "wayfinder guide";
|
|
33
|
+
/** The paragraph under the title. */
|
|
34
|
+
export declare const GUIDE_INTRO: string;
|
|
35
|
+
/** Every section, in {@link GUIDE_TOPICS} order, under the title, as `guide` prints it. */
|
|
30
36
|
export declare function guideDocument(tool: GuideTool): string;
|
|
31
|
-
/**
|
|
32
|
-
|
|
37
|
+
/**
|
|
38
|
+
* The `guide` command. Mount it as `guide: guideCommand({ globals })`. The
|
|
39
|
+
* usage topic shows `tool(ctx).usage`; by default that is the app's complete
|
|
40
|
+
* root help.
|
|
41
|
+
*/
|
|
42
|
+
export declare function guideCommand<G extends FlagSpec = Record<never, never>>(options?: {
|
|
43
|
+
globals?: G;
|
|
44
|
+
tool?: (ctx: CommandContext) => GuideTool;
|
|
45
|
+
}): DataCommand;
|
package/dist/guide.js
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* `way guide`: cli-tool's shared `guide` command over wayfinder's topics,
|
|
3
|
+
* Markdown for a person or a model who has the binary and not the README.
|
|
4
|
+
* `--help` lists the flags; this says what `--json` hands you, why a runner is
|
|
5
|
+
* missing, and how to add a tool.
|
|
5
6
|
*
|
|
6
7
|
* Sections are data, so `tests/guide.test.ts` can check each one against the
|
|
7
8
|
* code it describes. No roster is retyped: the built-in tools come from
|
|
8
9
|
* `builtins` and the settable keys from `CONFIG_KEYS`.
|
|
9
10
|
*/
|
|
10
|
-
import {
|
|
11
|
+
import { guideCommand as sharedGuideCommand } from '@osdlc/cli-tool/guide';
|
|
11
12
|
import { builtins } from '@osdlc/system-model/builtins';
|
|
12
|
-
import { APP, BIN, CONFIG_ENV_VAR,
|
|
13
|
-
import { CONFIG_KEYS } from "./config.js";
|
|
13
|
+
import { APP, BIN, CONFIG_ENV_VAR, PROJECT_CONFIG_FILENAME } from "./app.js";
|
|
14
|
+
import { CONFIG_KEYS, OPEN_VALUES, THEME_VALUES } from "./config.js";
|
|
14
15
|
import { GROUPS } from "./groups.js";
|
|
15
16
|
export const GUIDE_TOPICS = ['usage', 'config', 'json', 'trust', 'extend'];
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
/** One line per topic, for `guide topics`. */
|
|
18
|
+
const SUMMARIES = {
|
|
19
|
+
usage: 'the surfaces, the flags and the row groups',
|
|
20
|
+
config: 'the layered settings files and every key',
|
|
21
|
+
json: 'what --json prints, field by field',
|
|
22
|
+
trust: 'why some runners need trust, and how it is decided',
|
|
23
|
+
extend: 'adding your own tools',
|
|
24
|
+
};
|
|
19
25
|
const code = '```';
|
|
20
26
|
/** The built-in runner ids, as an inline list. */
|
|
21
27
|
function runnerRoster() {
|
|
@@ -74,6 +80,8 @@ export const tools: ToolDef[] = [
|
|
|
74
80
|
]
|
|
75
81
|
`;
|
|
76
82
|
const JSON_EXAMPLE = `{
|
|
83
|
+
"schemaVersion": 1,
|
|
84
|
+
"kind": "catalog",
|
|
77
85
|
"root": "/home/you/repo",
|
|
78
86
|
"generatedAt": "2026-01-01T00:00:00.000Z",
|
|
79
87
|
"discovery": "git",
|
|
@@ -105,13 +113,14 @@ const JSON_EXAMPLE = `{
|
|
|
105
113
|
"skippedForExec": false
|
|
106
114
|
}
|
|
107
115
|
],
|
|
108
|
-
"groups": [{ "id": "tasks", "title": "Tasks", "runners": ["just"] }]
|
|
116
|
+
"groups": [{ "id": "tasks", "title": "Tasks", "runners": ["just"] }],
|
|
117
|
+
"cache": [{ "runner": "just", "state": "fresh", "ageMs": 0, "probeMs": 12, "estimateMs": 12, "slow": false }],
|
|
118
|
+
"unknowns": [],
|
|
119
|
+
"filter": {}
|
|
109
120
|
}`;
|
|
110
|
-
function
|
|
121
|
+
function usageBody(tool) {
|
|
111
122
|
const extra = tool.extraUsage === undefined ? '' : `\n${tool.extraUsage.trim()}\n`;
|
|
112
|
-
return
|
|
113
|
-
|
|
114
|
-
\`${BIN}\` lists every task this repository can run, and runs one.
|
|
123
|
+
return `\`${BIN}\` lists every task this repository can run, and runs one.
|
|
115
124
|
|
|
116
125
|
Point it at a directory; the directory is resolved upward to the project root,
|
|
117
126
|
so running from a subdirectory still inspects the whole repository.
|
|
@@ -136,10 +145,8 @@ claimed before the flag parse, so their own arguments are not read as this
|
|
|
136
145
|
tool's flags.
|
|
137
146
|
`;
|
|
138
147
|
}
|
|
139
|
-
function
|
|
140
|
-
return
|
|
141
|
-
|
|
142
|
-
Layers, lowest precedence first:
|
|
148
|
+
function configBody() {
|
|
149
|
+
return `Layers, lowest precedence first:
|
|
143
150
|
|
|
144
151
|
1. The built-in defaults, with \`allowExec: true\`: willing in principle,
|
|
145
152
|
still gated on trust.
|
|
@@ -150,19 +157,26 @@ Layers, lowest precedence first:
|
|
|
150
157
|
Files. The project file is \`${PROJECT_CONFIG_FILENAME}\` at the project root, the
|
|
151
158
|
root this tool resolved, not the working directory. The user file is
|
|
152
159
|
\`$XDG_CONFIG_HOME/${APP}/config.json\`, or \`~/.config/${APP}/config.json\` when
|
|
153
|
-
that variable is unset or relative
|
|
160
|
+
that variable is unset or relative; on Windows it is under \`%APPDATA%\`.
|
|
161
|
+
\`WAYFINDER_ROOT\` moves every file ${APP} keeps outside your repositories under
|
|
162
|
+
one directory.
|
|
154
163
|
|
|
155
164
|
\`${CONFIG_ENV_VAR}\` replaces the USER file's location and nothing else. It does
|
|
156
165
|
not move the project file and it does not add a layer. A path in it may start
|
|
157
166
|
with a tilde, which is expanded. A relative path is ignored with a warning,
|
|
158
167
|
because from the project root it would name a file in the repository.
|
|
159
168
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
\`${LEGACY_PROJECT_CONFIG_FILENAME}\` are still read when the new name is absent,
|
|
163
|
-
with a warning naming the new location.
|
|
169
|
+
Settable keys: ${configKeyList()}. A key under \`trust.tools\` names one tool:
|
|
170
|
+
\`trust.tools.<tool>.paths\`.
|
|
164
171
|
|
|
165
|
-
|
|
172
|
+
\`open\` is what a bare \`${BIN}\` opens: ${OPEN_VALUES.map((v) => `"${v}"`).join(' or ')}.
|
|
173
|
+
\`theme\` is the web view's theme: ${THEME_VALUES.map((v) => `"${v}"`).join(', ')}.
|
|
174
|
+
Both are personal, so only the user file may set them.
|
|
175
|
+
|
|
176
|
+
A file may start with \`"$schema"\`, naming the JSON Schema an editor checks it
|
|
177
|
+
against; every file ${BIN} writes has one. An unknown key is a warning that
|
|
178
|
+
names the closest known key, and the rest of the file still loads. A value of
|
|
179
|
+
the wrong type is an error.
|
|
166
180
|
|
|
167
181
|
Merging. Objects merge key by key. An ARRAY answers "which ones" wholesale, so
|
|
168
182
|
a later layer replaces it rather than appending to it: \`--exclude\` REPLACES
|
|
@@ -177,26 +191,33 @@ takes the tree beneath it. Not glob syntax.
|
|
|
177
191
|
\`tools\` names modules that export more tools (see extend). A relative path
|
|
178
192
|
resolves against the file that names it.
|
|
179
193
|
|
|
194
|
+
\`${BIN} config explain <key>\` shows each layer's value for a key, which one won,
|
|
195
|
+
and why a project value was ignored.
|
|
196
|
+
|
|
180
197
|
Exit codes. 2 means the command cannot be run as typed: an unknown
|
|
181
198
|
subcommand, a wrong argument count, an unknown setting, a value of the wrong
|
|
182
|
-
type. 1 means a well-formed command
|
|
183
|
-
will not parse, a key that is not set
|
|
199
|
+
type, a key the project file may not hold. 1 means a well-formed command
|
|
200
|
+
failed against the state: a file that will not parse, a key that is not set
|
|
201
|
+
where you asked to unset it.
|
|
184
202
|
|
|
185
203
|
The project file cannot grant execution. It may LOWER \`allowExec\` to false,
|
|
186
204
|
never raise it, because it lives inside the repository being scanned. A
|
|
187
|
-
project file's \`allowExec: true
|
|
188
|
-
|
|
189
|
-
|
|
205
|
+
project file's \`allowExec: true\`, its trust block, \`open\`, \`theme\` and
|
|
206
|
+
\`skills\` are dropped with a warning, and \`config set\` refuses to write them
|
|
207
|
+
there. Its \`tools\` load only when the repository is trusted and execution is
|
|
208
|
+
allowed, since a tool module is code. The web view cannot set \`allowExec\`,
|
|
209
|
+
\`tools\` or the trust keys.
|
|
190
210
|
|
|
191
211
|
The effective gate: \`--no-exec\` forbids execution whatever is configured;
|
|
192
212
|
\`--exec\` allows it for that one run; with neither flag, execution needs a
|
|
193
213
|
configured \`allowExec\` of true and a trusted repository.
|
|
194
214
|
`;
|
|
195
215
|
}
|
|
196
|
-
function
|
|
197
|
-
return
|
|
198
|
-
|
|
199
|
-
|
|
216
|
+
function jsonBody() {
|
|
217
|
+
return `Every command answers \`--json\` with one JSON document whose first fields are
|
|
218
|
+
\`schemaVersion\` and \`kind\`. \`${BIN} schema\` prints each one's JSON Schema, and
|
|
219
|
+
\`@osdlc/wayfinder/schema\` exports them. \`${BIN} list --json\` prints the
|
|
220
|
+
catalog document (\`kind\` "catalog"). Field by field:
|
|
200
221
|
|
|
201
222
|
\`Catalog\`
|
|
202
223
|
- \`root\`: absolute path the collection ran against. Every \`cwd\` and
|
|
@@ -241,17 +262,24 @@ ${groupList()}
|
|
|
241
262
|
- \`skippedForExec\`: true when the runner was withheld because it needed to
|
|
242
263
|
shell out.
|
|
243
264
|
|
|
244
|
-
\`cache\`:
|
|
265
|
+
\`cache\`: one entry per runner:
|
|
245
266
|
- \`state\`: "fresh", "stale" (used, and out of date) or "miss" (nothing was
|
|
246
|
-
stored
|
|
247
|
-
- \`reason\`:
|
|
248
|
-
- \`ageMs\`: how old the stored answer is
|
|
249
|
-
- \`
|
|
267
|
+
stored).
|
|
268
|
+
- \`reason\`: why a stale row is stale, such as "changed".
|
|
269
|
+
- \`ageMs\`: how old the stored answer is; 0 when probed just now.
|
|
270
|
+
- \`probeMs\`: how long the probe took, when it ran in this call.
|
|
271
|
+
- \`estimateMs\`: the expected re-probe cost, or null when never measured.
|
|
250
272
|
- \`slow\`: true when those measurements say this runner is slow here.
|
|
251
273
|
|
|
274
|
+
\`unknowns\`: what could not be read, each with the \`label\` the terminal
|
|
275
|
+
shows: \`withheld\` runners, tasks whose \`parameters\` are unknown, \`stale\`
|
|
276
|
+
stored answers and a \`binary\` not on the PATH.
|
|
277
|
+
|
|
278
|
+
\`filter\`: the filters \`--services\`, \`--declared\` and \`--depth\` applied.
|
|
279
|
+
|
|
252
280
|
A cached \`generatedAt\` is the OLDEST contributing probe time.
|
|
253
281
|
|
|
254
|
-
Over HTTP, \`${BIN}
|
|
282
|
+
Over HTTP, \`${BIN} serve\` adds \`trustable\`, the server's own reading of
|
|
255
283
|
the gate it resolved.
|
|
256
284
|
|
|
257
285
|
Trimmed example:
|
|
@@ -261,10 +289,8 @@ ${JSON_EXAMPLE}
|
|
|
261
289
|
${code}
|
|
262
290
|
`;
|
|
263
291
|
}
|
|
264
|
-
function
|
|
265
|
-
return
|
|
266
|
-
|
|
267
|
-
Reading some runners means RUNNING them. Asking moon for its task graph
|
|
292
|
+
function trustBody() {
|
|
293
|
+
return `Reading some runners means RUNNING them. Asking moon for its task graph
|
|
268
294
|
evaluates the repository's toolchain configuration, and asking mise for its
|
|
269
295
|
tasks can fire that repository's hooks. Pointing a tool at a repository you
|
|
270
296
|
did not write is code execution before you have run anything from the list.
|
|
@@ -274,8 +300,7 @@ Built-ins that must shell out: ${execRoster()}.
|
|
|
274
300
|
The store is \`$XDG_STATE_HOME/${APP}/trusted/\`, or
|
|
275
301
|
\`~/.local/state/${APP}/trusted/\` when that variable is unset: state, not
|
|
276
302
|
config, so consent does not travel in a dotfiles repository. One marker file
|
|
277
|
-
per trusted root
|
|
278
|
-
store still count.
|
|
303
|
+
per trusted root, and one per tool granted alone.
|
|
279
304
|
|
|
280
305
|
It is PATH-KEYED: the key is the absolute, symlink-resolved root, not a hash
|
|
281
306
|
of the contents. A repository you trusted that later pulls hostile changes
|
|
@@ -296,21 +321,25 @@ ${code}
|
|
|
296
321
|
|
|
297
322
|
The exec flag grants execution for ONE run and records nothing.
|
|
298
323
|
|
|
299
|
-
The command: \`${BIN} trust\` grants, \`--untrust\` revokes, \`--
|
|
300
|
-
this root, \`--
|
|
324
|
+
The command: \`${BIN} trust\` grants, \`--untrust\` revokes, \`--untrust-all\`
|
|
325
|
+
revokes every grant of this root, \`--show\` reports this root, \`--list\`
|
|
326
|
+
prints every grant. \`--scope <tool>\` grants, revokes or shows one tool's
|
|
327
|
+
trust instead of the whole repository's. \`-C PATH\` reaches all of them.
|
|
328
|
+
Granting works from the command line only: the web view cannot grant
|
|
329
|
+
trust.
|
|
301
330
|
|
|
302
331
|
A root can also be trusted with no marker, by a trust block in the USER
|
|
303
332
|
config: \`trust.paths\` (a glob over the resolved root) and \`trust.owners\`
|
|
304
333
|
(the \`origin\` remote's \`host/owner\`; a bare owner means github.com), decided in
|
|
305
|
-
that order after the marker.
|
|
334
|
+
that order after the marker. \`trust.tools.<tool>\` holds the same two lists for
|
|
335
|
+
one tool. A run needs every tool it runs trusted: a mise task needs mise as
|
|
336
|
+
well as its own runner.
|
|
306
337
|
\`--show\` and \`--json\` name which layer decided (\`by\`:
|
|
307
338
|
\`marker\`/\`path\`/\`owner\`, plus the matching \`rule\` for a policy hit).
|
|
308
339
|
`;
|
|
309
340
|
}
|
|
310
|
-
function
|
|
311
|
-
return
|
|
312
|
-
|
|
313
|
-
A tool is a \`ToolDef\` from \`@osdlc/system-model/detect\`, the same shape as
|
|
341
|
+
function extendBody() {
|
|
342
|
+
return `A tool is a \`ToolDef\` from \`@osdlc/system-model/detect\`, the same shape as
|
|
314
343
|
the built-ins: an id, the binary, the files that show it is in use, and the
|
|
315
344
|
roles it plays. A tool with a \`runner\` role adds tasks.
|
|
316
345
|
|
|
@@ -347,66 +376,53 @@ strips types. A tool whose id matches a built-in is an error.
|
|
|
347
376
|
\`${BIN} providers\` lists every registered tool and where it came from.
|
|
348
377
|
`;
|
|
349
378
|
}
|
|
350
|
-
/** One section
|
|
351
|
-
|
|
379
|
+
/** One section's Markdown body, without its heading. */
|
|
380
|
+
function guideBody(topic, tool) {
|
|
352
381
|
switch (topic) {
|
|
353
382
|
case 'usage':
|
|
354
|
-
return
|
|
383
|
+
return usageBody(tool);
|
|
355
384
|
case 'config':
|
|
356
|
-
return
|
|
385
|
+
return configBody();
|
|
357
386
|
case 'json':
|
|
358
|
-
return
|
|
387
|
+
return jsonBody();
|
|
359
388
|
case 'trust':
|
|
360
|
-
return
|
|
389
|
+
return trustBody();
|
|
361
390
|
case 'extend':
|
|
362
|
-
return
|
|
391
|
+
return extendBody();
|
|
363
392
|
}
|
|
364
393
|
}
|
|
365
|
-
/**
|
|
394
|
+
/** One section with its heading, as `guide <topic>` prints it. */
|
|
395
|
+
export function guideSection(topic, tool) {
|
|
396
|
+
return `## ${topic}\n\n${guideBody(topic, tool).trim()}\n`;
|
|
397
|
+
}
|
|
398
|
+
/** The guide's title. */
|
|
399
|
+
export const GUIDE_TITLE = `${APP} guide`;
|
|
400
|
+
/** The paragraph under the title. */
|
|
401
|
+
export const GUIDE_INTRO = `Instructions for using and extending this tool without the README. Topics: ${GUIDE_TOPICS.join(', ')}. Print one with \`${BIN} guide <topic>\`.`;
|
|
402
|
+
/** Every section, in {@link GUIDE_TOPICS} order, under the title, as `guide` prints it. */
|
|
366
403
|
export function guideDocument(tool) {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
Instructions for using and extending this tool without the README. Topics:
|
|
370
|
-
${GUIDE_TOPICS.join(', ')}. Print one with \`${BIN} guide <topic>\`.
|
|
371
|
-
`;
|
|
372
|
-
return [header, ...GUIDE_TOPICS.map((t) => guideSection(t, tool))].join('\n');
|
|
404
|
+
return (`# ${GUIDE_TITLE}\n\n${GUIDE_INTRO}\n\n` +
|
|
405
|
+
GUIDE_TOPICS.map((t) => guideSection(t, tool)).join('\n'));
|
|
373
406
|
}
|
|
374
|
-
/** `
|
|
375
|
-
function
|
|
376
|
-
return
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
<topic> one section: ${GUIDE_TOPICS.join(', ')}
|
|
383
|
-
-h, --help this text
|
|
384
|
-
`;
|
|
407
|
+
/** The topics for cli-tool's `guide` command. `tool` gives the usage text for a run. */
|
|
408
|
+
function guideTopics(tool) {
|
|
409
|
+
return GUIDE_TOPICS.map((id) => ({
|
|
410
|
+
id,
|
|
411
|
+
title: id,
|
|
412
|
+
summary: SUMMARIES[id],
|
|
413
|
+
body: (ctx) => guideBody(id, tool(ctx)),
|
|
414
|
+
}));
|
|
385
415
|
}
|
|
386
|
-
/**
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
const [
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
io.stderr(`${APP}: guide: ${what} — topics are: ${GUIDE_TOPICS.join(', ')} (or "topics")\n`);
|
|
399
|
-
return EXIT.usage;
|
|
400
|
-
};
|
|
401
|
-
if (rest.length > 0)
|
|
402
|
-
return bad('expected at most one topic');
|
|
403
|
-
if (first === 'topics') {
|
|
404
|
-
io.stdout(`${GUIDE_TOPICS.join('\n')}\n`);
|
|
405
|
-
return EXIT.ok;
|
|
406
|
-
}
|
|
407
|
-
if (isGuideTopic(first)) {
|
|
408
|
-
io.stdout(guideSection(first, tool));
|
|
409
|
-
return EXIT.ok;
|
|
410
|
-
}
|
|
411
|
-
return bad(`unknown topic "${first}"`);
|
|
416
|
+
/**
|
|
417
|
+
* The `guide` command. Mount it as `guide: guideCommand({ globals })`. The
|
|
418
|
+
* usage topic shows `tool(ctx).usage`; by default that is the app's complete
|
|
419
|
+
* root help.
|
|
420
|
+
*/
|
|
421
|
+
export function guideCommand(options = {}) {
|
|
422
|
+
const tool = options.tool ?? ((ctx) => ({ usage: ctx.app.helpText([], { full: true }) }));
|
|
423
|
+
return sharedGuideCommand(guideTopics(tool), {
|
|
424
|
+
title: GUIDE_TITLE,
|
|
425
|
+
intro: GUIDE_INTRO,
|
|
426
|
+
...(options.globals !== undefined ? { globals: options.globals } : {}),
|
|
427
|
+
});
|
|
412
428
|
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@osdlc/wayfinder`: build the catalog `way` shows, from code. The answer is
|
|
3
|
+
* the document `way list --json` prints: the runner reports with their
|
|
4
|
+
* tasks, the groups, the agent skills, the cache verdicts and what could not
|
|
5
|
+
* be read.
|
|
6
|
+
*
|
|
7
|
+
* Detection is `@osdlc/system-model`'s. This entry adds what wayfinder layers
|
|
8
|
+
* on top: configuration, trust, the probe store, groups and skills. It runs
|
|
9
|
+
* on Node; it is not for a browser.
|
|
10
|
+
*
|
|
11
|
+
* The exported names follow semver from 1.0. Before 1.0 a minor release may
|
|
12
|
+
* change them, and the changelog says how.
|
|
13
|
+
*/
|
|
14
|
+
import type { DiscoveryMode, RunnerReport } from '@osdlc/system-model/detect';
|
|
15
|
+
import type { TaskFilter } from './core/filter.ts';
|
|
16
|
+
import { type CacheState, type SessionFlags } from './core/session.ts';
|
|
17
|
+
import type { SkillRow } from './core/skills.ts';
|
|
18
|
+
import type { Unknown } from './core/unknowns.ts';
|
|
19
|
+
import type { DocumentGroup } from './groups.ts';
|
|
20
|
+
export { SessionError, type CacheState, type SessionFlags } from './core/session.ts';
|
|
21
|
+
export { filterTasks, hasQuery, keepsTask, sourceDepth } from './core/filter.ts';
|
|
22
|
+
export type { TaskFilter, TaskHit } from './core/filter.ts';
|
|
23
|
+
export { filterSkills, skillLine, SKILLS_SETTING_VALUES } from './core/skills.ts';
|
|
24
|
+
export type { SkillHit, SkillRow, SkillsSetting } from './core/skills.ts';
|
|
25
|
+
export { unknownLine, unknownsOf, type Unknown, type UnknownsInput } from './core/unknowns.ts';
|
|
26
|
+
export { GROUPS, SKILLS_GROUP, catalogGroups, documentGroups, groupOf, type DocumentGroup, type Group, type GroupId, } from './groups.ts';
|
|
27
|
+
export { jsonText, terminalSafe } from './terminal-text.ts';
|
|
28
|
+
export { toolSummary, type ToolSummary } from './tool-info.ts';
|
|
29
|
+
export { ANY_LANGUAGE, languageLabel, runnerLabel, withheldLabel } from './vocabulary.ts';
|
|
30
|
+
export type { WithheldReason } from './vocabulary.ts';
|
|
31
|
+
export type { Catalog, DiscoveryMode, Param, ParametersUnknownReason, RunnerCacheState, RunnerReport, StaleReason, Task, ToolDef, } from '@osdlc/system-model/detect';
|
|
32
|
+
export type { Mode } from '@osdlc/system-model/match';
|
|
33
|
+
/** What {@link buildCatalog} reads, and the choices the CLI makes with flags. */
|
|
34
|
+
export interface BuildCatalogOptions {
|
|
35
|
+
/** The directory to read: absolute, or relative to `cwd`. It must exist. */
|
|
36
|
+
dir: string;
|
|
37
|
+
/** The base for a relative `dir` and tool module paths. Default `process.cwd()`. */
|
|
38
|
+
cwd?: string | undefined;
|
|
39
|
+
/** Where config, trust and the probe store are found. Default `process.env`. */
|
|
40
|
+
env?: Record<string, string | undefined> | undefined;
|
|
41
|
+
/** The home directory. Default: the OS account's. */
|
|
42
|
+
home?: string | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* What the CLI's flags choose: `allowExec` is `--exec` or `--no-exec`,
|
|
45
|
+
* `toolModules` is `--config`. Absent fields come from the config files.
|
|
46
|
+
*/
|
|
47
|
+
flags?: SessionFlags | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Answer as `--cached` does: from the last saved listing, which checks no
|
|
50
|
+
* files, else from the stored probe, probing only the runners missing from it.
|
|
51
|
+
*/
|
|
52
|
+
cached?: boolean | undefined;
|
|
53
|
+
/** Keep only some tasks and skills, as `--services`, `--declared` and `--depth`. */
|
|
54
|
+
filter?: TaskFilter | undefined;
|
|
55
|
+
/** Stops every probe. */
|
|
56
|
+
signal?: AbortSignal | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Called with each warning from the config files and tool modules, such
|
|
59
|
+
* as a project file key that is ignored. The CLI prints these on stderr.
|
|
60
|
+
*/
|
|
61
|
+
onWarning?: ((message: string) => void) | undefined;
|
|
62
|
+
}
|
|
63
|
+
/** The catalog document: what `way list --json` prints. */
|
|
64
|
+
export interface CatalogDocument {
|
|
65
|
+
schemaVersion: number;
|
|
66
|
+
kind: 'catalog';
|
|
67
|
+
/** Absolute. Every `cwd` and `source` is relative to it. */
|
|
68
|
+
root: string;
|
|
69
|
+
generatedAt: string;
|
|
70
|
+
discovery: DiscoveryMode;
|
|
71
|
+
/** Whether every runner was allowed to run subprocesses. */
|
|
72
|
+
allowExec: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* `fresh`: every runner was probed in this call. `cached` (under `cached:
|
|
75
|
+
* true`): the rows came from the last saved listing, which checks no
|
|
76
|
+
* files, or else from the stored probes, where `cache` says which runners
|
|
77
|
+
* were stale or probed now.
|
|
78
|
+
*/
|
|
79
|
+
source: 'fresh' | 'cached';
|
|
80
|
+
/** With `source: "cached"`, when the oldest stored rows were probed (ISO 8601). Null when fresh. */
|
|
81
|
+
storedAt: string | null;
|
|
82
|
+
/** Grouped, and in the configured runner order. */
|
|
83
|
+
reports: RunnerReport[];
|
|
84
|
+
/** The groups with rows, in display order. */
|
|
85
|
+
groups: DocumentGroup[];
|
|
86
|
+
/** The agent skills, as the `skills` setting chooses. */
|
|
87
|
+
skills: SkillRow[];
|
|
88
|
+
cache: CacheState[];
|
|
89
|
+
/** What could not be read, each with the label every surface shows. */
|
|
90
|
+
unknowns: Unknown[];
|
|
91
|
+
/**
|
|
92
|
+
* The tool ids trusted on their own here. Empty when the repository is
|
|
93
|
+
* trusted as a whole, or trust does not decide execution.
|
|
94
|
+
*/
|
|
95
|
+
trustedTools: string[];
|
|
96
|
+
/** The filter applied. Absent fields were not given. */
|
|
97
|
+
filter: Pick<TaskFilter, 'servicesOnly' | 'declaredOnly' | 'maxDepth'>;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The catalog for `dir`, as `way list --json` builds it: the same config,
|
|
101
|
+
* trust gate and probe store. Nothing in the repository runs unless the
|
|
102
|
+
* repository (or the tool) is trusted and execution is allowed. A probe
|
|
103
|
+
* writes the store, as `way list` does.
|
|
104
|
+
*
|
|
105
|
+
* Throws {@link SessionError}: `no-such-directory`, `config` for a config
|
|
106
|
+
* file that cannot be used, `tool-module` for a tool module that cannot be
|
|
107
|
+
* loaded.
|
|
108
|
+
*
|
|
109
|
+
* Task names, skill text and other strings come from the repository. Pass
|
|
110
|
+
* them through {@link terminalSafe} before printing them to a terminal.
|
|
111
|
+
*/
|
|
112
|
+
export declare function buildCatalog(options: BuildCatalogOptions): Promise<CatalogDocument>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@osdlc/wayfinder`: build the catalog `way` shows, from code. The answer is
|
|
3
|
+
* the document `way list --json` prints: the runner reports with their
|
|
4
|
+
* tasks, the groups, the agent skills, the cache verdicts and what could not
|
|
5
|
+
* be read.
|
|
6
|
+
*
|
|
7
|
+
* Detection is `@osdlc/system-model`'s. This entry adds what wayfinder layers
|
|
8
|
+
* on top: configuration, trust, the probe store, groups and skills. It runs
|
|
9
|
+
* on Node; it is not for a browser.
|
|
10
|
+
*
|
|
11
|
+
* The exported names follow semver from 1.0. Before 1.0 a minor release may
|
|
12
|
+
* change them, and the changelog says how.
|
|
13
|
+
*/
|
|
14
|
+
import { catalogDocument } from "./commands/list.js";
|
|
15
|
+
import { flushViews } from "./core/saved-view.js";
|
|
16
|
+
import { createSession } from "./core/session.js";
|
|
17
|
+
import { CATALOG_DOCUMENT_VERSION } from "./documents.js";
|
|
18
|
+
export { SessionError } from "./core/session.js";
|
|
19
|
+
export { filterTasks, hasQuery, keepsTask, sourceDepth } from "./core/filter.js";
|
|
20
|
+
export { filterSkills, skillLine, SKILLS_SETTING_VALUES } from "./core/skills.js";
|
|
21
|
+
export { unknownLine, unknownsOf } from "./core/unknowns.js";
|
|
22
|
+
export { GROUPS, SKILLS_GROUP, catalogGroups, documentGroups, groupOf, } from "./groups.js";
|
|
23
|
+
export { jsonText, terminalSafe } from "./terminal-text.js";
|
|
24
|
+
export { toolSummary } from "./tool-info.js";
|
|
25
|
+
export { ANY_LANGUAGE, languageLabel, runnerLabel, withheldLabel } from "./vocabulary.js";
|
|
26
|
+
// Fails to compile when CatalogDocument and the document schema name different fields.
|
|
27
|
+
const catalogFieldsMatch = true;
|
|
28
|
+
void catalogFieldsMatch;
|
|
29
|
+
/**
|
|
30
|
+
* The catalog for `dir`, as `way list --json` builds it: the same config,
|
|
31
|
+
* trust gate and probe store. Nothing in the repository runs unless the
|
|
32
|
+
* repository (or the tool) is trusted and execution is allowed. A probe
|
|
33
|
+
* writes the store, as `way list` does.
|
|
34
|
+
*
|
|
35
|
+
* Throws {@link SessionError}: `no-such-directory`, `config` for a config
|
|
36
|
+
* file that cannot be used, `tool-module` for a tool module that cannot be
|
|
37
|
+
* loaded.
|
|
38
|
+
*
|
|
39
|
+
* Task names, skill text and other strings come from the repository. Pass
|
|
40
|
+
* them through {@link terminalSafe} before printing them to a terminal.
|
|
41
|
+
*/
|
|
42
|
+
export async function buildCatalog(options) {
|
|
43
|
+
const session = await createSession({
|
|
44
|
+
dir: options.dir,
|
|
45
|
+
cwd: options.cwd ?? process.cwd(),
|
|
46
|
+
env: options.env ?? process.env,
|
|
47
|
+
home: options.home,
|
|
48
|
+
flags: options.flags,
|
|
49
|
+
signal: options.signal,
|
|
50
|
+
});
|
|
51
|
+
for (const warning of session.warnings)
|
|
52
|
+
options.onWarning?.(warning);
|
|
53
|
+
const snapshot = await session.catalog({ cached: options.cached === true });
|
|
54
|
+
// A library caller gets a call whose writes are done.
|
|
55
|
+
await flushViews();
|
|
56
|
+
const body = catalogDocument(snapshot, session.unknowns(snapshot), options.filter ?? {}, session.settings().trustedTools);
|
|
57
|
+
return { schemaVersion: CATALOG_DOCUMENT_VERSION, kind: 'catalog', ...body };
|
|
58
|
+
}
|