@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,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `way` and `way browse`: the terminal UI. Enter runs the selected task.
|
|
3
|
+
* `serve`: the same catalog as a live page.
|
|
4
|
+
*/
|
|
5
|
+
import type { Session } from '../core/session.ts';
|
|
6
|
+
import type { CatalogShare } from '../serve/catalog-share.ts';
|
|
7
|
+
/** The terminal UI's list keys, for help text. */
|
|
8
|
+
export declare const TUI_KEYS_HELP: string;
|
|
9
|
+
/**
|
|
10
|
+
* An abort signal that fires on SIGINT or SIGTERM, with the exit code as its
|
|
11
|
+
* reason, linked to `parent`. `dispose` removes the listeners.
|
|
12
|
+
*/
|
|
13
|
+
export declare function abortOnSignals(parent: AbortSignal): {
|
|
14
|
+
signal: AbortSignal;
|
|
15
|
+
dispose(): void;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Make the terminal UI command. With `followOpen` it is the bare `way`: it
|
|
19
|
+
* opens the web view instead when the user config says `open: "web"`, with
|
|
20
|
+
* `share` as the catalog it holds between requests.
|
|
21
|
+
*/
|
|
22
|
+
export declare function browseCommand(home: string, opts?: {
|
|
23
|
+
followOpen?: boolean;
|
|
24
|
+
share?: CatalogShare;
|
|
25
|
+
}): import("@osdlc/cli-tool/command").InteractiveCommand<Record<never, never>, {
|
|
26
|
+
readonly dir: {
|
|
27
|
+
readonly kind: "string";
|
|
28
|
+
readonly short: "C";
|
|
29
|
+
readonly valueName: "PATH";
|
|
30
|
+
readonly help: "the directory to inspect (default: cwd)";
|
|
31
|
+
};
|
|
32
|
+
readonly exec: {
|
|
33
|
+
readonly kind: "tristate";
|
|
34
|
+
readonly help: "allow runners that must run a subprocess (moon), this run only";
|
|
35
|
+
readonly offHelp: "skip them, overriding a configured allowExec: true";
|
|
36
|
+
};
|
|
37
|
+
readonly only: {
|
|
38
|
+
readonly kind: "list";
|
|
39
|
+
readonly valueName: "a,b";
|
|
40
|
+
readonly hidden: true;
|
|
41
|
+
readonly help: "restrict to these runners";
|
|
42
|
+
};
|
|
43
|
+
readonly exclude: {
|
|
44
|
+
readonly kind: "list";
|
|
45
|
+
readonly valueName: "a,b";
|
|
46
|
+
readonly hidden: true;
|
|
47
|
+
readonly help: "skip these runners, REPLACING the configured runners.disabled";
|
|
48
|
+
};
|
|
49
|
+
readonly excludePath: {
|
|
50
|
+
readonly kind: "list";
|
|
51
|
+
readonly valueName: "P";
|
|
52
|
+
readonly commaSeparated: false;
|
|
53
|
+
readonly hidden: true;
|
|
54
|
+
readonly help: "skip a path; repeatable. A bare name matches any segment, a value with a slash matches a path from the root";
|
|
55
|
+
};
|
|
56
|
+
readonly discovery: {
|
|
57
|
+
readonly kind: "enum";
|
|
58
|
+
readonly choices: readonly ["git", "walk", "auto"];
|
|
59
|
+
readonly valueName: "M";
|
|
60
|
+
readonly hidden: true;
|
|
61
|
+
readonly help: "how to find directories. Default: auto";
|
|
62
|
+
};
|
|
63
|
+
readonly config: {
|
|
64
|
+
readonly kind: "list";
|
|
65
|
+
readonly valueName: "MODULE";
|
|
66
|
+
readonly commaSeparated: false;
|
|
67
|
+
readonly help: "load extra tools from a module, this run only; repeatable";
|
|
68
|
+
};
|
|
69
|
+
}>;
|
|
70
|
+
/** What the bare `way` opens, from the user config. */
|
|
71
|
+
export declare function openSurface(session: Session): 'tui' | 'web';
|
|
72
|
+
/** Make the `serve` command: the same catalog as a live page. */
|
|
73
|
+
export declare function serveCommand(home: string, share?: CatalogShare): import("@osdlc/cli-tool/command").InteractiveCommand<{
|
|
74
|
+
port: {
|
|
75
|
+
kind: "string";
|
|
76
|
+
valueName: string;
|
|
77
|
+
help: string;
|
|
78
|
+
};
|
|
79
|
+
open: {
|
|
80
|
+
kind: "boolean";
|
|
81
|
+
negatable: true;
|
|
82
|
+
help: string;
|
|
83
|
+
};
|
|
84
|
+
}, {
|
|
85
|
+
readonly dir: {
|
|
86
|
+
readonly kind: "string";
|
|
87
|
+
readonly short: "C";
|
|
88
|
+
readonly valueName: "PATH";
|
|
89
|
+
readonly help: "the directory to inspect (default: cwd)";
|
|
90
|
+
};
|
|
91
|
+
readonly exec: {
|
|
92
|
+
readonly kind: "tristate";
|
|
93
|
+
readonly help: "allow runners that must run a subprocess (moon), this run only";
|
|
94
|
+
readonly offHelp: "skip them, overriding a configured allowExec: true";
|
|
95
|
+
};
|
|
96
|
+
readonly only: {
|
|
97
|
+
readonly kind: "list";
|
|
98
|
+
readonly valueName: "a,b";
|
|
99
|
+
readonly hidden: true;
|
|
100
|
+
readonly help: "restrict to these runners";
|
|
101
|
+
};
|
|
102
|
+
readonly exclude: {
|
|
103
|
+
readonly kind: "list";
|
|
104
|
+
readonly valueName: "a,b";
|
|
105
|
+
readonly hidden: true;
|
|
106
|
+
readonly help: "skip these runners, REPLACING the configured runners.disabled";
|
|
107
|
+
};
|
|
108
|
+
readonly excludePath: {
|
|
109
|
+
readonly kind: "list";
|
|
110
|
+
readonly valueName: "P";
|
|
111
|
+
readonly commaSeparated: false;
|
|
112
|
+
readonly hidden: true;
|
|
113
|
+
readonly help: "skip a path; repeatable. A bare name matches any segment, a value with a slash matches a path from the root";
|
|
114
|
+
};
|
|
115
|
+
readonly discovery: {
|
|
116
|
+
readonly kind: "enum";
|
|
117
|
+
readonly choices: readonly ["git", "walk", "auto"];
|
|
118
|
+
readonly valueName: "M";
|
|
119
|
+
readonly hidden: true;
|
|
120
|
+
readonly help: "how to find directories. Default: auto";
|
|
121
|
+
};
|
|
122
|
+
readonly config: {
|
|
123
|
+
readonly kind: "list";
|
|
124
|
+
readonly valueName: "MODULE";
|
|
125
|
+
readonly commaSeparated: false;
|
|
126
|
+
readonly help: "load extra tools from a module, this run only; repeatable";
|
|
127
|
+
};
|
|
128
|
+
}>;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `way` and `way browse`: the terminal UI. Enter runs the selected task.
|
|
3
|
+
* `serve`: the same catalog as a live page.
|
|
4
|
+
*/
|
|
5
|
+
import { UsageError } from '@osdlc/cli-tool/command';
|
|
6
|
+
import { keyLines } from "../keys.js";
|
|
7
|
+
import { serve } from "../serve/index.js";
|
|
8
|
+
import { runTui } from "../tui/index.js";
|
|
9
|
+
import { kit, openSession } from "./shared.js";
|
|
10
|
+
/** The terminal UI's list keys, for help text. */
|
|
11
|
+
export const TUI_KEYS_HELP = `Keys in the list (? shows every key):\n${keyLines('tui', 'list').join('\n')}`;
|
|
12
|
+
/** The exit code for each signal that stops `serve`: 128 + its number. */
|
|
13
|
+
const STOP_SIGNALS = { SIGINT: 130, SIGTERM: 143 };
|
|
14
|
+
/**
|
|
15
|
+
* An abort signal that fires on SIGINT or SIGTERM, with the exit code as its
|
|
16
|
+
* reason, linked to `parent`. `dispose` removes the listeners.
|
|
17
|
+
*/
|
|
18
|
+
export function abortOnSignals(parent) {
|
|
19
|
+
const aborter = new AbortController();
|
|
20
|
+
const handlers = Object.entries(STOP_SIGNALS).map(([name, code]) => {
|
|
21
|
+
const handler = () => aborter.abort(code);
|
|
22
|
+
process.on(name, handler);
|
|
23
|
+
return [name, handler];
|
|
24
|
+
});
|
|
25
|
+
const onParent = () => aborter.abort(parent.reason);
|
|
26
|
+
if (parent.aborted)
|
|
27
|
+
onParent();
|
|
28
|
+
else
|
|
29
|
+
parent.addEventListener('abort', onParent, { once: true });
|
|
30
|
+
return {
|
|
31
|
+
signal: aborter.signal,
|
|
32
|
+
dispose() {
|
|
33
|
+
for (const [name, handler] of handlers)
|
|
34
|
+
process.off(name, handler);
|
|
35
|
+
parent.removeEventListener('abort', onParent);
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Make the terminal UI command. With `followOpen` it is the bare `way`: it
|
|
41
|
+
* opens the web view instead when the user config says `open: "web"`, with
|
|
42
|
+
* `share` as the catalog it holds between requests.
|
|
43
|
+
*/
|
|
44
|
+
export function browseCommand(home, opts = {}) {
|
|
45
|
+
return kit.command({
|
|
46
|
+
summary: 'the terminal UI; Enter runs the selected task',
|
|
47
|
+
description: 'Type to filter. It starts from the stored probe, then refreshes. Needs a terminal; ' +
|
|
48
|
+
'"list" and "query" answer a script.' +
|
|
49
|
+
(opts.followOpen === true
|
|
50
|
+
? ' The bare command opens the web view instead when the user config sets open to "web".'
|
|
51
|
+
: '') +
|
|
52
|
+
`\n\n${TUI_KEYS_HELP}`,
|
|
53
|
+
positionals: [{ name: 'dir', help: 'the directory to inspect (beats -C)' }],
|
|
54
|
+
interactive: true,
|
|
55
|
+
async run({ globals, positionals }, ctx) {
|
|
56
|
+
const session = await openSession(globals, ctx, home, positionals[0]);
|
|
57
|
+
if (opts.followOpen === true && openSurface(session) === 'web') {
|
|
58
|
+
const stopper = abortOnSignals(ctx.signal);
|
|
59
|
+
try {
|
|
60
|
+
return await serveSession(session, globals, ctx, stopper.signal, {
|
|
61
|
+
open: true,
|
|
62
|
+
share: opts.share,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
stopper.dispose();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return runTui(session);
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/** What the bare `way` opens, from the user config. */
|
|
74
|
+
export function openSurface(session) {
|
|
75
|
+
return session.settings().settings.open.value === 'web' ? 'web' : 'tui';
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Serve `session` as a live page until `signal` aborts or a run takes the
|
|
79
|
+
* terminal. Returns the run's exit code, or the signal's.
|
|
80
|
+
*/
|
|
81
|
+
async function serveSession(session, globals, ctx, signal, opts) {
|
|
82
|
+
const exit = await serve({
|
|
83
|
+
session,
|
|
84
|
+
...(opts.share !== undefined ? { share: opts.share } : {}),
|
|
85
|
+
app: ctx.app,
|
|
86
|
+
globals: globals,
|
|
87
|
+
cwd: ctx.cwd,
|
|
88
|
+
open: opts.open,
|
|
89
|
+
signal,
|
|
90
|
+
stdout: (text) => ctx.io.stdout(text),
|
|
91
|
+
stderr: (text) => ctx.io.stderr(text),
|
|
92
|
+
// Enter in the terminal prints a new sign-in link.
|
|
93
|
+
...(ctx.terminal?.stdin === true ? { input: process.stdin } : {}),
|
|
94
|
+
...(opts.port !== undefined ? { port: opts.port } : {}),
|
|
95
|
+
});
|
|
96
|
+
if (exit !== null)
|
|
97
|
+
return exit;
|
|
98
|
+
const reason = signal.reason;
|
|
99
|
+
return typeof reason === 'number' ? reason : 0;
|
|
100
|
+
}
|
|
101
|
+
/** Make the `serve` command: the same catalog as a live page. */
|
|
102
|
+
export function serveCommand(home, share) {
|
|
103
|
+
return kit.command({
|
|
104
|
+
summary: 'the same catalog as a live page in the browser',
|
|
105
|
+
description: 'Serves 127.0.0.1 only, on an OS-assigned port unless --port gives one, and opens a ' +
|
|
106
|
+
'browser signed in to it. --no-open prints the URL instead. A reload stays signed in; for a ' +
|
|
107
|
+
'new tab or another browser, press Enter in the terminal for a new sign-in link. Every action on the page is ' +
|
|
108
|
+
'a command of this tool, called over HTTP with a token made for this run. It starts from ' +
|
|
109
|
+
'the stored probe, then refreshes. Ctrl-C stops it, and any probe it is running.',
|
|
110
|
+
positionals: [{ name: 'dir', help: 'the directory to inspect (beats -C)' }],
|
|
111
|
+
flags: {
|
|
112
|
+
port: { kind: 'string', valueName: 'N', help: 'a fixed port (default: an OS-assigned one)' },
|
|
113
|
+
open: {
|
|
114
|
+
kind: 'boolean',
|
|
115
|
+
negatable: true,
|
|
116
|
+
help: 'print the URL rather than opening a browser',
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
interactive: true,
|
|
120
|
+
async run({ flags, globals, positionals }, ctx) {
|
|
121
|
+
const port = flags.port === undefined ? undefined : parsePort(flags.port);
|
|
122
|
+
// Ctrl-C aborts the session's probes and stops the server.
|
|
123
|
+
const stopper = abortOnSignals(ctx.signal);
|
|
124
|
+
try {
|
|
125
|
+
const session = await openSession(globals, { ...ctx, signal: stopper.signal }, home, positionals[0]);
|
|
126
|
+
return await serveSession(session, globals, ctx, stopper.signal, {
|
|
127
|
+
open: flags.open,
|
|
128
|
+
share,
|
|
129
|
+
...(port !== undefined ? { port } : {}),
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
finally {
|
|
133
|
+
stopper.dispose();
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* A port number, checked as digits first. `Number('')` is 0, `Number('0x10')`
|
|
140
|
+
* is 16 and `Number('1e3')` is 1000, so a bare `Number()` would accept a port
|
|
141
|
+
* nobody typed. Port 0 means "let the OS pick", which `--port` exists to
|
|
142
|
+
* prevent.
|
|
143
|
+
*/
|
|
144
|
+
function parsePort(raw) {
|
|
145
|
+
const trimmed = raw.trim();
|
|
146
|
+
const port = /^\d+$/.test(trimmed) ? Number.parseInt(trimmed, 10) : Number.NaN;
|
|
147
|
+
if (!(port >= 1 && port <= 65535)) {
|
|
148
|
+
throw new UsageError('--port needs a port number from 1 to 65535');
|
|
149
|
+
}
|
|
150
|
+
return port;
|
|
151
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `way` command tree. See `src/core/README.md` for how a command is added.
|
|
3
|
+
*/
|
|
4
|
+
import { type App, type CommandContext } from '@osdlc/cli-tool/command';
|
|
5
|
+
import { type GuideTool } from '../guide.ts';
|
|
6
|
+
import { type CatalogShare } from '../serve/catalog-share.ts';
|
|
7
|
+
/** What {@link createWayApp} returns. */
|
|
8
|
+
export interface WayApp {
|
|
9
|
+
app: App;
|
|
10
|
+
/** Every command word at the root, hidden ones and `help` and `schema` included. */
|
|
11
|
+
words: readonly string[];
|
|
12
|
+
/** The words of the commands the complete help shows. */
|
|
13
|
+
treeWords: readonly string[];
|
|
14
|
+
/** The catalog `list` shares between the web view's requests; `serve` fills it. */
|
|
15
|
+
share: CatalogShare;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Build the command tree. `home` is the base for config, trust and cache
|
|
19
|
+
* paths, injected so a test never reads the developer's own. `guide` gives
|
|
20
|
+
* the guide its usage topic; by default the root's complete help.
|
|
21
|
+
*/
|
|
22
|
+
export declare function createWayApp(opts: {
|
|
23
|
+
home: string;
|
|
24
|
+
guide?: (ctx: CommandContext) => GuideTool;
|
|
25
|
+
}): WayApp;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `way` command tree. See `src/core/README.md` for how a command is added.
|
|
3
|
+
*/
|
|
4
|
+
import { defineApp } from '@osdlc/cli-tool/command';
|
|
5
|
+
import { BIN, PROJECT_CONFIG_FILENAME } from "../app.js";
|
|
6
|
+
import { VERSION } from "../version.js";
|
|
7
|
+
import { TUI_KEYS_HELP, browseCommand, serveCommand } from "./browse.js";
|
|
8
|
+
import { listCommand } from "./list.js";
|
|
9
|
+
import { queryCommand } from "./query.js";
|
|
10
|
+
import { runCommand } from "./run.js";
|
|
11
|
+
import { cleanCommand } from "../clean-command.js";
|
|
12
|
+
import { configCommand } from "../config-command.js";
|
|
13
|
+
import { guideCommand } from "../guide.js";
|
|
14
|
+
import { providersCommand } from "../providers-command.js";
|
|
15
|
+
import { trustCommand } from "../trust-command.js";
|
|
16
|
+
import { createCatalogShare } from "../serve/catalog-share.js";
|
|
17
|
+
import { GLOBALS, setCommandWords } from "./shared.js";
|
|
18
|
+
/** The root's long description: what `way help --full` adds. */
|
|
19
|
+
const DESCRIPTION = `Defaults come from ${PROJECT_CONFIG_FILENAME} in the project root and from the user file "${BIN} config path" names; a flag beats both. --exclude REPLACES the configured runners.disabled rather than adding to it.
|
|
20
|
+
|
|
21
|
+
"${BIN} list" and "${BIN} query" probe every time, so a script reading them gets what the repository has now; --cached asks for the stored answer instead and names the stale runners on stderr. The terminal UI and "${BIN} serve" start from the store and refresh behind you.
|
|
22
|
+
|
|
23
|
+
Reading some runners means running them, so a repository must be trusted before they are collected: "${BIN} trust" records that, once, per repository. Until then they are withheld and every surface says so. A repository cannot trust itself: allowExec in ${PROJECT_CONFIG_FILENAME} cannot raise the gate.
|
|
24
|
+
|
|
25
|
+
--config loads a module of extra tools for this run, beside the built-ins and any the config's "tools" key names; "${BIN} providers" lists them all.
|
|
26
|
+
|
|
27
|
+
The flags --serve, --list and --json with no command still work in this release, as "${BIN} serve", "${BIN} list" and "${BIN} list --json". They go away in a later release.
|
|
28
|
+
|
|
29
|
+
${TUI_KEYS_HELP}`;
|
|
30
|
+
/**
|
|
31
|
+
* Build the command tree. `home` is the base for config, trust and cache
|
|
32
|
+
* paths, injected so a test never reads the developer's own. `guide` gives
|
|
33
|
+
* the guide its usage topic; by default the root's complete help.
|
|
34
|
+
*/
|
|
35
|
+
export function createWayApp(opts) {
|
|
36
|
+
const { home } = opts;
|
|
37
|
+
const env = { globals: GLOBALS, home: () => home };
|
|
38
|
+
// The catalog the web view holds between requests; `serve` turns it on.
|
|
39
|
+
const share = createCatalogShare();
|
|
40
|
+
const browse = browseCommand(home);
|
|
41
|
+
// The bare `way` follows the `open` setting; `way browse` is always the terminal UI.
|
|
42
|
+
const bare = browseCommand(home, { followOpen: true, share });
|
|
43
|
+
const commands = {
|
|
44
|
+
browse: { ...browse, hidden: true },
|
|
45
|
+
list: listCommand(home, share),
|
|
46
|
+
query: queryCommand(home),
|
|
47
|
+
run: runCommand(home),
|
|
48
|
+
serve: serveCommand(home, share),
|
|
49
|
+
providers: providersCommand(home),
|
|
50
|
+
config: configCommand(env),
|
|
51
|
+
trust: trustCommand(env),
|
|
52
|
+
guide: guideCommand({
|
|
53
|
+
globals: GLOBALS,
|
|
54
|
+
...(opts.guide !== undefined ? { tool: opts.guide } : {}),
|
|
55
|
+
}),
|
|
56
|
+
clean: cleanCommand(env),
|
|
57
|
+
};
|
|
58
|
+
const words = [...Object.keys(commands), 'help', 'schema'];
|
|
59
|
+
setCommandWords(words);
|
|
60
|
+
const app = defineApp({
|
|
61
|
+
name: BIN,
|
|
62
|
+
version: VERSION,
|
|
63
|
+
summary: 'Browse and run every task in this repository.',
|
|
64
|
+
description: DESCRIPTION,
|
|
65
|
+
globals: GLOBALS,
|
|
66
|
+
default: bare,
|
|
67
|
+
commands,
|
|
68
|
+
});
|
|
69
|
+
const treeWords = Object.keys(commands).filter((w) => w !== 'browse');
|
|
70
|
+
return { app, words, treeWords, share };
|
|
71
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `way list`: the whole catalog. Text is one command line per task, the line
|
|
3
|
+
* Copy puts on the clipboard, then one `/<name>` line per agent skill;
|
|
4
|
+
* `--json` is the catalog document.
|
|
5
|
+
*/
|
|
6
|
+
import { type TaskFilter } from '../core/filter.ts';
|
|
7
|
+
import type { CatalogSnapshot } from '../core/session.ts';
|
|
8
|
+
import type { Unknown } from '../core/unknowns.ts';
|
|
9
|
+
import type { CatalogDocument } from '../index.ts';
|
|
10
|
+
import type { CatalogShare } from '../serve/catalog-share.ts';
|
|
11
|
+
/** The catalog document without its `schemaVersion` and `kind`. */
|
|
12
|
+
export type CatalogBody = Omit<CatalogDocument, 'schemaVersion' | 'kind'>;
|
|
13
|
+
/**
|
|
14
|
+
* The catalog document for `snapshot`: the catalog with its groups, cache
|
|
15
|
+
* verdicts, unknowns and the tools trusted on their own. With a filter, each
|
|
16
|
+
* report keeps only the tasks that pass it. The CLI and the web view send
|
|
17
|
+
* the same document.
|
|
18
|
+
*/
|
|
19
|
+
export declare function catalogDocument(snapshot: Pick<CatalogSnapshot, 'catalog' | 'cache' | 'skills' | 'origin'>, unknowns: Unknown[], filter?: TaskFilter, trustedTools?: readonly string[]): CatalogBody;
|
|
20
|
+
/**
|
|
21
|
+
* Whether the rows were probed in this call or came from the store, and when
|
|
22
|
+
* the stored ones were taken: the oldest stored runner's probe time.
|
|
23
|
+
*/
|
|
24
|
+
export declare function sourceOf(snapshot: Pick<CatalogSnapshot, 'catalog' | 'origin'>): {
|
|
25
|
+
source: 'fresh' | 'cached';
|
|
26
|
+
storedAt: string | null;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Make the `list` command. `home` is the base for config, trust and cache
|
|
30
|
+
* paths. `share` is the web view's held catalog (see `catalog-share.ts`).
|
|
31
|
+
*/
|
|
32
|
+
export declare function listCommand(home: string, share?: CatalogShare): import("@osdlc/cli-tool/command").DataCommand<{
|
|
33
|
+
join: {
|
|
34
|
+
kind: "boolean";
|
|
35
|
+
hidden: true;
|
|
36
|
+
help: string;
|
|
37
|
+
};
|
|
38
|
+
cached: {
|
|
39
|
+
readonly kind: "boolean";
|
|
40
|
+
readonly help: "answer from the last saved listing (files unchecked), else the stored probe; stderr says which";
|
|
41
|
+
};
|
|
42
|
+
services: {
|
|
43
|
+
readonly kind: "boolean";
|
|
44
|
+
readonly help: "only tasks that run until you stop them";
|
|
45
|
+
};
|
|
46
|
+
declared: {
|
|
47
|
+
readonly kind: "boolean";
|
|
48
|
+
readonly help: "only tasks a file declares, not ones inferred from a convention";
|
|
49
|
+
};
|
|
50
|
+
depth: {
|
|
51
|
+
readonly kind: "string";
|
|
52
|
+
readonly valueName: "N";
|
|
53
|
+
readonly help: "only tasks declared at most N directories below the root (the web view calls this Scope)";
|
|
54
|
+
};
|
|
55
|
+
}, {
|
|
56
|
+
readonly dir: {
|
|
57
|
+
readonly kind: "string";
|
|
58
|
+
readonly short: "C";
|
|
59
|
+
readonly valueName: "PATH";
|
|
60
|
+
readonly help: "the directory to inspect (default: cwd)";
|
|
61
|
+
};
|
|
62
|
+
readonly exec: {
|
|
63
|
+
readonly kind: "tristate";
|
|
64
|
+
readonly help: "allow runners that must run a subprocess (moon), this run only";
|
|
65
|
+
readonly offHelp: "skip them, overriding a configured allowExec: true";
|
|
66
|
+
};
|
|
67
|
+
readonly only: {
|
|
68
|
+
readonly kind: "list";
|
|
69
|
+
readonly valueName: "a,b";
|
|
70
|
+
readonly hidden: true;
|
|
71
|
+
readonly help: "restrict to these runners";
|
|
72
|
+
};
|
|
73
|
+
readonly exclude: {
|
|
74
|
+
readonly kind: "list";
|
|
75
|
+
readonly valueName: "a,b";
|
|
76
|
+
readonly hidden: true;
|
|
77
|
+
readonly help: "skip these runners, REPLACING the configured runners.disabled";
|
|
78
|
+
};
|
|
79
|
+
readonly excludePath: {
|
|
80
|
+
readonly kind: "list";
|
|
81
|
+
readonly valueName: "P";
|
|
82
|
+
readonly commaSeparated: false;
|
|
83
|
+
readonly hidden: true;
|
|
84
|
+
readonly help: "skip a path; repeatable. A bare name matches any segment, a value with a slash matches a path from the root";
|
|
85
|
+
};
|
|
86
|
+
readonly discovery: {
|
|
87
|
+
readonly kind: "enum";
|
|
88
|
+
readonly choices: readonly ["git", "walk", "auto"];
|
|
89
|
+
readonly valueName: "M";
|
|
90
|
+
readonly hidden: true;
|
|
91
|
+
readonly help: "how to find directories. Default: auto";
|
|
92
|
+
};
|
|
93
|
+
readonly config: {
|
|
94
|
+
readonly kind: "list";
|
|
95
|
+
readonly valueName: "MODULE";
|
|
96
|
+
readonly commaSeparated: false;
|
|
97
|
+
readonly help: "load extra tools from a module, this run only; repeatable";
|
|
98
|
+
};
|
|
99
|
+
}, import("zod").ZodObject<{
|
|
100
|
+
root: import("zod").ZodType<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>;
|
|
101
|
+
generatedAt: import("zod").ZodType<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>;
|
|
102
|
+
discovery: import("zod").ZodType<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>;
|
|
103
|
+
allowExec: import("zod").ZodBoolean;
|
|
104
|
+
source: import("zod").ZodEnum<{
|
|
105
|
+
fresh: "fresh";
|
|
106
|
+
cached: "cached";
|
|
107
|
+
}>;
|
|
108
|
+
storedAt: import("zod").ZodNullable<import("zod").ZodString>;
|
|
109
|
+
reports: import("zod").ZodArray<import("zod").ZodType<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>>;
|
|
110
|
+
groups: import("zod").ZodArray<import("zod").ZodObject<{
|
|
111
|
+
id: import("zod").ZodEnum<{
|
|
112
|
+
tools: "tools";
|
|
113
|
+
skills: "skills";
|
|
114
|
+
tasks: "tasks";
|
|
115
|
+
dependencies: "dependencies";
|
|
116
|
+
hooks: "hooks";
|
|
117
|
+
}>;
|
|
118
|
+
title: import("zod").ZodString;
|
|
119
|
+
runners: import("zod").ZodArray<import("zod").ZodString>;
|
|
120
|
+
}, import("zod/v4/core").$strip>>;
|
|
121
|
+
skills: import("zod").ZodArray<import("zod").ZodObject<{
|
|
122
|
+
id: import("zod").ZodString;
|
|
123
|
+
name: import("zod").ZodString;
|
|
124
|
+
description: import("zod").ZodNullable<import("zod").ZodString>;
|
|
125
|
+
argumentHint: import("zod").ZodNullable<import("zod").ZodString>;
|
|
126
|
+
path: import("zod").ZodString;
|
|
127
|
+
scope: import("zod").ZodString;
|
|
128
|
+
origin: import("zod").ZodString;
|
|
129
|
+
harnesses: import("zod").ZodArray<import("zod").ZodString>;
|
|
130
|
+
invoke: import("zod").ZodString;
|
|
131
|
+
}, import("zod/v4/core").$strip>>;
|
|
132
|
+
cache: import("zod").ZodArray<import("zod").ZodObject<{
|
|
133
|
+
runner: import("zod").ZodString;
|
|
134
|
+
state: import("zod").ZodEnum<{
|
|
135
|
+
fresh: "fresh";
|
|
136
|
+
stale: "stale";
|
|
137
|
+
miss: "miss";
|
|
138
|
+
}>;
|
|
139
|
+
reason: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
140
|
+
changed: "changed";
|
|
141
|
+
"max-age": "max-age";
|
|
142
|
+
excludes: "excludes";
|
|
143
|
+
exec: "exec";
|
|
144
|
+
version: "version";
|
|
145
|
+
tool: "tool";
|
|
146
|
+
}>>;
|
|
147
|
+
ageMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
148
|
+
estimateMs: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
149
|
+
slow: import("zod").ZodBoolean;
|
|
150
|
+
cost: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
151
|
+
slow: "slow";
|
|
152
|
+
cheap: "cheap";
|
|
153
|
+
}>>;
|
|
154
|
+
probeMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
155
|
+
}, import("zod/v4/core").$strip>>;
|
|
156
|
+
unknowns: import("zod").ZodArray<import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
|
|
157
|
+
kind: import("zod").ZodLiteral<"withheld">;
|
|
158
|
+
runner: import("zod").ZodString;
|
|
159
|
+
reason: import("zod").ZodEnum<{
|
|
160
|
+
untrusted: "untrusted";
|
|
161
|
+
"tool-untrusted": "tool-untrusted";
|
|
162
|
+
"exec-off": "exec-off";
|
|
163
|
+
}>;
|
|
164
|
+
missing: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
165
|
+
label: import("zod").ZodString;
|
|
166
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
167
|
+
kind: import("zod").ZodLiteral<"parameters">;
|
|
168
|
+
runner: import("zod").ZodString;
|
|
169
|
+
reason: import("zod").ZodEnum<{
|
|
170
|
+
"exec-withheld": "exec-withheld";
|
|
171
|
+
"tool-missing": "tool-missing";
|
|
172
|
+
"tool-failed": "tool-failed";
|
|
173
|
+
"not-read": "not-read";
|
|
174
|
+
"editor-variable": "editor-variable";
|
|
175
|
+
}>;
|
|
176
|
+
tasks: import("zod").ZodArray<import("zod").ZodString>;
|
|
177
|
+
label: import("zod").ZodString;
|
|
178
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
179
|
+
kind: import("zod").ZodLiteral<"stale">;
|
|
180
|
+
runner: import("zod").ZodString;
|
|
181
|
+
reason: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
182
|
+
changed: "changed";
|
|
183
|
+
"max-age": "max-age";
|
|
184
|
+
excludes: "excludes";
|
|
185
|
+
exec: "exec";
|
|
186
|
+
version: "version";
|
|
187
|
+
tool: "tool";
|
|
188
|
+
}>>;
|
|
189
|
+
ageMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
190
|
+
label: import("zod").ZodString;
|
|
191
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
192
|
+
kind: import("zod").ZodLiteral<"binary">;
|
|
193
|
+
runner: import("zod").ZodString;
|
|
194
|
+
binary: import("zod").ZodString;
|
|
195
|
+
label: import("zod").ZodString;
|
|
196
|
+
}, import("zod/v4/core").$strip>], "kind">>;
|
|
197
|
+
trustedTools: import("zod").ZodArray<import("zod").ZodString>;
|
|
198
|
+
filter: import("zod").ZodObject<{
|
|
199
|
+
query: import("zod").ZodOptional<import("zod").ZodString>;
|
|
200
|
+
mode: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
201
|
+
exact: "exact";
|
|
202
|
+
fuzzy: "fuzzy";
|
|
203
|
+
}>>;
|
|
204
|
+
servicesOnly: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
205
|
+
declaredOnly: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
206
|
+
maxDepth: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
207
|
+
}, import("zod/v4/core").$strip>;
|
|
208
|
+
}, import("zod/v4/core").$strip>>;
|