@osdlc/wayfinder 0.7.4 → 0.9.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 +240 -0
- package/CONTRIBUTING.md +6 -0
- package/README.md +310 -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 +45 -4
- package/dist/catalog.js +134 -13
- 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 +153 -0
- package/dist/commands/index.d.ts +25 -0
- package/dist/commands/index.js +71 -0
- package/dist/commands/list.d.ts +224 -0
- package/dist/commands/list.js +178 -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 +272 -257
- package/dist/config.js +611 -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 +282 -0
- package/dist/core/session.js +602 -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 +508 -0
- package/dist/documents.js +181 -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 +118 -0
- package/dist/index.js +61 -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 +63 -0
- package/dist/serve/catalog-share.js +155 -0
- package/dist/serve/index.d.ts +100 -0
- package/dist/serve/index.js +259 -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 +193 -0
- package/dist/tui/app.js +1400 -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 +91 -0
- package/dist/vocabulary.js +155 -0
- package/dist/web/main.js +2232 -582
- package/dist/web/page.html +41 -33
- package/dist/web/styles.css +513 -329
- package/dist/xdg.d.ts +76 -4
- package/dist/xdg.js +77 -5
- package/package.json +27 -8
- 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,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What every `way` command shares: the global flags, the command kit typed
|
|
3
|
+
* with them, and the step that turns the parsed flags into a session.
|
|
4
|
+
*/
|
|
5
|
+
import { type CommandContext } from '@osdlc/cli-tool/command';
|
|
6
|
+
import type { FlagValues } from '@osdlc/cli-tool/define-cli';
|
|
7
|
+
import type { TaskFilter } from '../core/filter.ts';
|
|
8
|
+
import { type CatalogSnapshot, type Session } from '../core/session.ts';
|
|
9
|
+
import { type Unknown } from '../core/unknowns.ts';
|
|
10
|
+
/**
|
|
11
|
+
* The flags every command takes, before or after the command word. They
|
|
12
|
+
* choose the repository and what is collected from it.
|
|
13
|
+
*/
|
|
14
|
+
export declare const GLOBALS: {
|
|
15
|
+
readonly dir: {
|
|
16
|
+
readonly kind: "string";
|
|
17
|
+
readonly short: "C";
|
|
18
|
+
readonly valueName: "PATH";
|
|
19
|
+
readonly help: "the directory to inspect (default: cwd)";
|
|
20
|
+
};
|
|
21
|
+
readonly exec: {
|
|
22
|
+
readonly kind: "tristate";
|
|
23
|
+
readonly help: "allow runners that must run a subprocess (moon), this run only";
|
|
24
|
+
readonly offHelp: "skip them, overriding a configured allowExec: true";
|
|
25
|
+
};
|
|
26
|
+
readonly only: {
|
|
27
|
+
readonly kind: "list";
|
|
28
|
+
readonly valueName: "a,b";
|
|
29
|
+
readonly hidden: true;
|
|
30
|
+
readonly help: "restrict to these runners";
|
|
31
|
+
};
|
|
32
|
+
readonly exclude: {
|
|
33
|
+
readonly kind: "list";
|
|
34
|
+
readonly valueName: "a,b";
|
|
35
|
+
readonly hidden: true;
|
|
36
|
+
readonly help: "skip these runners, REPLACING the configured runners.disabled";
|
|
37
|
+
};
|
|
38
|
+
readonly excludePath: {
|
|
39
|
+
readonly kind: "list";
|
|
40
|
+
readonly valueName: "P";
|
|
41
|
+
readonly commaSeparated: false;
|
|
42
|
+
readonly hidden: true;
|
|
43
|
+
readonly help: "skip a path; repeatable. A bare name matches any segment, a value with a slash matches a path from the root";
|
|
44
|
+
};
|
|
45
|
+
readonly discovery: {
|
|
46
|
+
readonly kind: "enum";
|
|
47
|
+
readonly choices: readonly ["git", "walk", "auto"];
|
|
48
|
+
readonly valueName: "M";
|
|
49
|
+
readonly hidden: true;
|
|
50
|
+
readonly help: "how to find directories. Default: auto";
|
|
51
|
+
};
|
|
52
|
+
readonly config: {
|
|
53
|
+
readonly kind: "list";
|
|
54
|
+
readonly valueName: "MODULE";
|
|
55
|
+
readonly commaSeparated: false;
|
|
56
|
+
readonly help: "load extra tools from a module, this run only; repeatable";
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
export declare const kit: import("@osdlc/cli-tool/command").CommandKit<{
|
|
60
|
+
readonly dir: {
|
|
61
|
+
readonly kind: "string";
|
|
62
|
+
readonly short: "C";
|
|
63
|
+
readonly valueName: "PATH";
|
|
64
|
+
readonly help: "the directory to inspect (default: cwd)";
|
|
65
|
+
};
|
|
66
|
+
readonly exec: {
|
|
67
|
+
readonly kind: "tristate";
|
|
68
|
+
readonly help: "allow runners that must run a subprocess (moon), this run only";
|
|
69
|
+
readonly offHelp: "skip them, overriding a configured allowExec: true";
|
|
70
|
+
};
|
|
71
|
+
readonly only: {
|
|
72
|
+
readonly kind: "list";
|
|
73
|
+
readonly valueName: "a,b";
|
|
74
|
+
readonly hidden: true;
|
|
75
|
+
readonly help: "restrict to these runners";
|
|
76
|
+
};
|
|
77
|
+
readonly exclude: {
|
|
78
|
+
readonly kind: "list";
|
|
79
|
+
readonly valueName: "a,b";
|
|
80
|
+
readonly hidden: true;
|
|
81
|
+
readonly help: "skip these runners, REPLACING the configured runners.disabled";
|
|
82
|
+
};
|
|
83
|
+
readonly excludePath: {
|
|
84
|
+
readonly kind: "list";
|
|
85
|
+
readonly valueName: "P";
|
|
86
|
+
readonly commaSeparated: false;
|
|
87
|
+
readonly hidden: true;
|
|
88
|
+
readonly help: "skip a path; repeatable. A bare name matches any segment, a value with a slash matches a path from the root";
|
|
89
|
+
};
|
|
90
|
+
readonly discovery: {
|
|
91
|
+
readonly kind: "enum";
|
|
92
|
+
readonly choices: readonly ["git", "walk", "auto"];
|
|
93
|
+
readonly valueName: "M";
|
|
94
|
+
readonly hidden: true;
|
|
95
|
+
readonly help: "how to find directories. Default: auto";
|
|
96
|
+
};
|
|
97
|
+
readonly config: {
|
|
98
|
+
readonly kind: "list";
|
|
99
|
+
readonly valueName: "MODULE";
|
|
100
|
+
readonly commaSeparated: false;
|
|
101
|
+
readonly help: "load extra tools from a module, this run only; repeatable";
|
|
102
|
+
};
|
|
103
|
+
}>;
|
|
104
|
+
/** The parsed global flags, as a command receives them. */
|
|
105
|
+
export type Globals = FlagValues<typeof GLOBALS>;
|
|
106
|
+
/** The filter flags `list` and `query` share, beside `--services`. */
|
|
107
|
+
export declare const FILTER_FLAGS: {
|
|
108
|
+
readonly cached: {
|
|
109
|
+
readonly kind: "boolean";
|
|
110
|
+
readonly help: "answer from the last saved listing (files unchecked), else the stored probe; stderr says which";
|
|
111
|
+
};
|
|
112
|
+
readonly services: {
|
|
113
|
+
readonly kind: "boolean";
|
|
114
|
+
readonly help: "only tasks that run until you stop them";
|
|
115
|
+
};
|
|
116
|
+
readonly declared: {
|
|
117
|
+
readonly kind: "boolean";
|
|
118
|
+
readonly help: "only tasks a file declares, not ones inferred from a convention";
|
|
119
|
+
};
|
|
120
|
+
readonly depth: {
|
|
121
|
+
readonly kind: "string";
|
|
122
|
+
readonly valueName: "N";
|
|
123
|
+
readonly help: "only tasks declared at most N directories below the root (the web view calls this Scope)";
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
/** The filter the shared filter flags ask for. */
|
|
127
|
+
export declare function filterFrom(flags: {
|
|
128
|
+
services: boolean;
|
|
129
|
+
declared: boolean;
|
|
130
|
+
depth?: string | undefined;
|
|
131
|
+
}): TaskFilter;
|
|
132
|
+
/** Set by the app once the tree is built. */
|
|
133
|
+
export declare function setCommandWords(words: readonly string[]): void;
|
|
134
|
+
/**
|
|
135
|
+
* Start the session the global flags describe. A positional directory beats
|
|
136
|
+
* `-C`. A {@link SessionError} becomes a {@link CommandError} with the same
|
|
137
|
+
* code, and the session's warnings go to stderr.
|
|
138
|
+
*/
|
|
139
|
+
export declare function openSession(globals: Globals, ctx: CommandContext, home: string, positionalDir?: string): Promise<Session>;
|
|
140
|
+
/**
|
|
141
|
+
* How to read the withheld runners, when a trust grant would: `way trust`, or
|
|
142
|
+
* `way trust --scope <tool>` for each tool still missing. Null when trust
|
|
143
|
+
* would not help, as under `--no-exec`.
|
|
144
|
+
*/
|
|
145
|
+
export declare function withheldTrustHint(withheld: readonly Unknown[]): string | null;
|
|
146
|
+
/**
|
|
147
|
+
* Write the warnings a listing leaves on stderr: a line for each withheld
|
|
148
|
+
* runner and why, with how to trust it when trust would help; the `--cached`
|
|
149
|
+
* note; and a line for each other unknown. stdout stays the listing, so it
|
|
150
|
+
* can be piped.
|
|
151
|
+
*/
|
|
152
|
+
export declare function noteUnknowns(ctx: CommandContext, session: Session, snapshot: CatalogSnapshot, unknowns: readonly Unknown[]): void;
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What every `way` command shares: the global flags, the command kit typed
|
|
3
|
+
* with them, and the step that turns the parsed flags into a session.
|
|
4
|
+
*/
|
|
5
|
+
import { commandKit, CommandError, UsageError } from '@osdlc/cli-tool/command';
|
|
6
|
+
import { closestMatches } from '@osdlc/config-layers/did-you-mean';
|
|
7
|
+
import { humanAge } from '@osdlc/system-model/duration';
|
|
8
|
+
import { BIN } from "../app.js";
|
|
9
|
+
import { SessionError, createSession } from "../core/session.js";
|
|
10
|
+
import { unknownLine } from "../core/unknowns.js";
|
|
11
|
+
import { NOT_CACHED, refreshCostLabel, runnerLabel, staleLabel } from "../vocabulary.js";
|
|
12
|
+
/**
|
|
13
|
+
* The flags every command takes, before or after the command word. They
|
|
14
|
+
* choose the repository and what is collected from it.
|
|
15
|
+
*/
|
|
16
|
+
export const GLOBALS = {
|
|
17
|
+
dir: {
|
|
18
|
+
kind: 'string',
|
|
19
|
+
short: 'C',
|
|
20
|
+
valueName: 'PATH',
|
|
21
|
+
help: 'the directory to inspect (default: cwd)',
|
|
22
|
+
},
|
|
23
|
+
exec: {
|
|
24
|
+
kind: 'tristate',
|
|
25
|
+
help: 'allow runners that must run a subprocess (moon), this run only',
|
|
26
|
+
offHelp: 'skip them, overriding a configured allowExec: true',
|
|
27
|
+
},
|
|
28
|
+
only: { kind: 'list', valueName: 'a,b', hidden: true, help: 'restrict to these runners' },
|
|
29
|
+
exclude: {
|
|
30
|
+
kind: 'list',
|
|
31
|
+
valueName: 'a,b',
|
|
32
|
+
hidden: true,
|
|
33
|
+
help: 'skip these runners, REPLACING the configured runners.disabled',
|
|
34
|
+
},
|
|
35
|
+
excludePath: {
|
|
36
|
+
kind: 'list',
|
|
37
|
+
valueName: 'P',
|
|
38
|
+
commaSeparated: false,
|
|
39
|
+
hidden: true,
|
|
40
|
+
help: 'skip a path; repeatable. A bare name matches any segment, a value with a slash matches a path from the root',
|
|
41
|
+
},
|
|
42
|
+
discovery: {
|
|
43
|
+
kind: 'enum',
|
|
44
|
+
choices: ['git', 'walk', 'auto'],
|
|
45
|
+
valueName: 'M',
|
|
46
|
+
hidden: true,
|
|
47
|
+
help: 'how to find directories. Default: auto',
|
|
48
|
+
},
|
|
49
|
+
config: {
|
|
50
|
+
kind: 'list',
|
|
51
|
+
valueName: 'MODULE',
|
|
52
|
+
commaSeparated: false,
|
|
53
|
+
help: 'load extra tools from a module, this run only; repeatable',
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
export const kit = commandKit({ globals: GLOBALS });
|
|
57
|
+
/** The filter flags `list` and `query` share, beside `--services`. */
|
|
58
|
+
export const FILTER_FLAGS = {
|
|
59
|
+
cached: {
|
|
60
|
+
kind: 'boolean',
|
|
61
|
+
help: 'answer from the last saved listing (files unchecked), else the stored probe; stderr says which',
|
|
62
|
+
},
|
|
63
|
+
services: { kind: 'boolean', help: 'only tasks that run until you stop them' },
|
|
64
|
+
declared: {
|
|
65
|
+
kind: 'boolean',
|
|
66
|
+
help: 'only tasks a file declares, not ones inferred from a convention',
|
|
67
|
+
},
|
|
68
|
+
depth: {
|
|
69
|
+
kind: 'string',
|
|
70
|
+
valueName: 'N',
|
|
71
|
+
help: 'only tasks declared at most N directories below the root (the web view calls this Scope)',
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
/** The filter the shared filter flags ask for. */
|
|
75
|
+
export function filterFrom(flags) {
|
|
76
|
+
const filter = {};
|
|
77
|
+
if (flags.services)
|
|
78
|
+
filter.servicesOnly = true;
|
|
79
|
+
if (flags.declared)
|
|
80
|
+
filter.declaredOnly = true;
|
|
81
|
+
if (flags.depth !== undefined) {
|
|
82
|
+
if (!/^\d+$/.test(flags.depth.trim())) {
|
|
83
|
+
throw new CommandError('--depth needs a whole number', { exit: 2, code: 'usage' });
|
|
84
|
+
}
|
|
85
|
+
filter.maxDepth = Number.parseInt(flags.depth.trim(), 10);
|
|
86
|
+
}
|
|
87
|
+
return filter;
|
|
88
|
+
}
|
|
89
|
+
/** The command words, for a "did you mean" when a directory does not exist. */
|
|
90
|
+
let commandWords = [];
|
|
91
|
+
/** Set by the app once the tree is built. */
|
|
92
|
+
export function setCommandWords(words) {
|
|
93
|
+
commandWords = words;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Start the session the global flags describe. A positional directory beats
|
|
97
|
+
* `-C`. A {@link SessionError} becomes a {@link CommandError} with the same
|
|
98
|
+
* code, and the session's warnings go to stderr.
|
|
99
|
+
*/
|
|
100
|
+
export async function openSession(globals, ctx, home, positionalDir) {
|
|
101
|
+
// Over HTTP every command keeps the directory `way serve` started with, so
|
|
102
|
+
// a caller holding the token cannot read another directory's catalog.
|
|
103
|
+
if (positionalDir !== undefined && ctx.surface === 'http') {
|
|
104
|
+
throw new UsageError('the directory is fixed when the web view starts; restart it to read another one');
|
|
105
|
+
}
|
|
106
|
+
const dir = positionalDir ?? globals.dir ?? ctx.cwd;
|
|
107
|
+
let session;
|
|
108
|
+
try {
|
|
109
|
+
session = await createSession({
|
|
110
|
+
dir,
|
|
111
|
+
cwd: ctx.cwd,
|
|
112
|
+
env: ctx.env,
|
|
113
|
+
home,
|
|
114
|
+
signal: ctx.signal,
|
|
115
|
+
flags: {
|
|
116
|
+
allowExec: globals.exec,
|
|
117
|
+
...(globals.only !== undefined ? { only: globals.only.filter(Boolean) } : {}),
|
|
118
|
+
...(globals.exclude !== undefined ? { exclude: globals.exclude.filter(Boolean) } : {}),
|
|
119
|
+
...(globals.excludePath !== undefined ? { excludePaths: globals.excludePath } : {}),
|
|
120
|
+
...(globals.discovery !== undefined ? { discovery: globals.discovery } : {}),
|
|
121
|
+
toolModules: globals.config ?? [],
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
if (err instanceof SessionError) {
|
|
127
|
+
let hint = err.hint;
|
|
128
|
+
if (err.code === 'no-such-directory' && positionalDir !== undefined) {
|
|
129
|
+
const close = closestMatches(positionalDir, commandWords);
|
|
130
|
+
if (close.length > 0)
|
|
131
|
+
hint = `did you mean "${BIN} ${close[0]}"?`;
|
|
132
|
+
}
|
|
133
|
+
throw new CommandError(err.message, {
|
|
134
|
+
code: err.code,
|
|
135
|
+
...(hint !== undefined ? { hint } : {}),
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
throw err;
|
|
139
|
+
}
|
|
140
|
+
for (const warning of session.warnings)
|
|
141
|
+
ctx.warn(warning);
|
|
142
|
+
return session;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The `--cached` note, or null when there is nothing to say: which runners
|
|
146
|
+
* were stale and which had nothing stored and were probed now.
|
|
147
|
+
*/
|
|
148
|
+
function cacheNote(snapshot) {
|
|
149
|
+
if (snapshot.origin === 'saved') {
|
|
150
|
+
const ages = snapshot.cache.flatMap((c) => (c.ageMs !== undefined ? [c.ageMs] : []));
|
|
151
|
+
const age = ages.length > 0 ? `, ${humanAge(Math.max(...ages))}` : '';
|
|
152
|
+
return `--cached: the last listing${age}; files changed since storedAt are not checked`;
|
|
153
|
+
}
|
|
154
|
+
if (snapshot.origin === 'empty-store') {
|
|
155
|
+
return '--cached: nothing cached for this repository yet; probed it now and stored the result';
|
|
156
|
+
}
|
|
157
|
+
if (snapshot.origin !== 'store')
|
|
158
|
+
return null;
|
|
159
|
+
const stale = snapshot.cache.filter((r) => r.state === 'stale');
|
|
160
|
+
const probed = snapshot.cache.filter((r) => r.probeMs !== undefined);
|
|
161
|
+
if (stale.length === 0 && probed.length === 0)
|
|
162
|
+
return null;
|
|
163
|
+
const parts = [];
|
|
164
|
+
if (stale.length > 0) {
|
|
165
|
+
const each = stale.map((r) => `${runnerLabel(r.runner)} (${staleLabel(r.reason, r.ageMs)}; ${refreshCostLabel(r.estimateMs)})`);
|
|
166
|
+
parts.push(each.join(', '));
|
|
167
|
+
}
|
|
168
|
+
if (probed.length > 0) {
|
|
169
|
+
parts.push(`${NOT_CACHED}, probed now: ${probed.map((r) => runnerLabel(r.runner)).join(', ')}`);
|
|
170
|
+
}
|
|
171
|
+
return `--cached: ${parts.join('; ')}`;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* How to read the withheld runners, when a trust grant would: `way trust`, or
|
|
175
|
+
* `way trust --scope <tool>` for each tool still missing. Null when trust
|
|
176
|
+
* would not help, as under `--no-exec`.
|
|
177
|
+
*/
|
|
178
|
+
export function withheldTrustHint(withheld) {
|
|
179
|
+
const held = withheld.filter((u) => u.kind === 'withheld');
|
|
180
|
+
if (held.some((u) => u.reason === 'untrusted')) {
|
|
181
|
+
return `run "${BIN} trust" to trust this repository, or pass --exec for this run only`;
|
|
182
|
+
}
|
|
183
|
+
const missing = [...new Set(held.flatMap((u) => u.missing ?? []))];
|
|
184
|
+
if (missing.length === 0)
|
|
185
|
+
return null;
|
|
186
|
+
const each = missing.map((tool) => `"${BIN} trust --scope ${tool}"`).join(', ');
|
|
187
|
+
return `run ${each} to trust ${missing.length === 1 ? 'it' : 'each'}, or pass --exec for this run only`;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Write the warnings a listing leaves on stderr: a line for each withheld
|
|
191
|
+
* runner and why, with how to trust it when trust would help; the `--cached`
|
|
192
|
+
* note; and a line for each other unknown. stdout stays the listing, so it
|
|
193
|
+
* can be piped.
|
|
194
|
+
*/
|
|
195
|
+
export function noteUnknowns(ctx, session, snapshot, unknowns) {
|
|
196
|
+
const withheld = unknowns.filter((u) => u.kind === 'withheld');
|
|
197
|
+
for (const unknown of withheld)
|
|
198
|
+
ctx.warn(unknownLine(unknown));
|
|
199
|
+
const hint = withheldTrustHint(withheld);
|
|
200
|
+
if (hint !== null)
|
|
201
|
+
ctx.io.stderr(` ${hint}\n`);
|
|
202
|
+
const cache = cacheNote(snapshot);
|
|
203
|
+
if (cache !== null)
|
|
204
|
+
ctx.note(cache);
|
|
205
|
+
for (const unknown of unknowns) {
|
|
206
|
+
if (unknown.kind === 'parameters' || unknown.kind === 'binary')
|
|
207
|
+
ctx.warn(unknownLine(unknown));
|
|
208
|
+
}
|
|
209
|
+
}
|
package/dist/config-command.d.ts
CHANGED
|
@@ -1,53 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* `CliIo` plus the environment this command needs injected.
|
|
2
|
+
* `way config`: cli-tool's shared `config` group over wayfinder's files.
|
|
3
|
+
* {@link configStore} is the {@link ConfigStore} it runs on; this module also
|
|
4
|
+
* holds what every wayfinder command needs from its context (the home
|
|
5
|
+
* directory and the project root).
|
|
6
|
+
*
|
|
7
|
+
* `trust`, `allowExec` and `tools` are written from the command line only
|
|
8
|
+
* ({@link CLI_ONLY_KEYS}): the web view's server refuses them.
|
|
10
9
|
*/
|
|
11
|
-
|
|
10
|
+
import { type CommandContext, type Group } from '@osdlc/cli-tool/command';
|
|
11
|
+
import type { FlagSpec } from '@osdlc/cli-tool/define-cli';
|
|
12
|
+
/** What a wayfinder command takes from its caller, beside the command context. */
|
|
13
|
+
export interface CommandEnvOptions {
|
|
12
14
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
+
* The home directory. Default: `HOME` from the context's environment when
|
|
16
|
+
* it is absolute, else the OS account's home.
|
|
15
17
|
*/
|
|
16
|
-
|
|
17
|
-
/** Defaults to `homeDir()` from `@osdlc/trust-repo`. The base for the non-XDG user path. */
|
|
18
|
-
home?: string;
|
|
18
|
+
home?: (ctx: CommandContext) => string;
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* The project root for a run. Default: `-C` (`ctx.globals.dir`) or the
|
|
21
|
+
* working directory, resolved upward to the project root.
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
root?: (ctx: CommandContext) => Promise<string>;
|
|
24
24
|
}
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
* without this it would be accepted and ignored. All four spellings are
|
|
30
|
-
* accepted: `-C X`, `-CX`, `--dir X`, `--dir=X`.
|
|
31
|
-
*/
|
|
32
|
-
export declare function takeConfigDir(argv: string[]): {
|
|
33
|
-
dir?: string;
|
|
34
|
-
rest: string[];
|
|
35
|
-
} | {
|
|
36
|
-
error: string;
|
|
25
|
+
/** {@link homeOf} and {@link projectRootOf}, or the caller's own. */
|
|
26
|
+
export declare function commandEnv(opts?: CommandEnvOptions): {
|
|
27
|
+
home: (ctx: CommandContext) => string;
|
|
28
|
+
root: (ctx: CommandContext) => Promise<string>;
|
|
37
29
|
};
|
|
38
30
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* Exit codes: 0 means success. 2 means the command cannot run as typed: an
|
|
43
|
-
* unknown subcommand or option, a wrong number of arguments, conflicting
|
|
44
|
-
* flags, an unknown setting name, or a value of the wrong type. Each is
|
|
45
|
-
* decided from the arguments and the schema alone, with no file involved, so
|
|
46
|
-
* running it again gives the same answer. 1 means a valid command that
|
|
47
|
-
* failed: a file that will not parse, a key that is not set where you asked
|
|
48
|
-
* to unset it, or a `get` that found nothing.
|
|
49
|
-
*
|
|
50
|
-
* A script can act on the difference: 2 means fix the command, 1 means look
|
|
51
|
-
* at the state.
|
|
31
|
+
* The `config` group: `list` (the default), `get`, `set`, `unset`, `path` and
|
|
32
|
+
* `explain`. Mount it as `config: configCommand({ globals })`, with the app's
|
|
33
|
+
* global flags; `-C` must be declared as `dir`.
|
|
52
34
|
*/
|
|
53
|
-
export declare function
|
|
35
|
+
export declare function configCommand<G extends FlagSpec = Record<never, never>>(options?: CommandEnvOptions & {
|
|
36
|
+
globals?: G;
|
|
37
|
+
}): Group;
|