@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/config.d.ts
CHANGED
|
@@ -4,368 +4,382 @@
|
|
|
4
4
|
* project structure, whether execution is allowed, extra tools) are set once,
|
|
5
5
|
* per user and per project. Flags are for one-off changes.
|
|
6
6
|
*
|
|
7
|
+
* {@link WayfinderConfigSchema} is the one description of the file. Validation,
|
|
8
|
+
* the settable keys, the key order of a written file and `schema/config.json`
|
|
9
|
+
* all come from it.
|
|
10
|
+
*
|
|
7
11
|
* ## Layers, lowest precedence first
|
|
8
12
|
*
|
|
9
|
-
* 1.
|
|
10
|
-
* 2. USER
|
|
11
|
-
*
|
|
12
|
-
* 3. PROJECT
|
|
13
|
+
* 1. {@link DEFAULT_CONFIG}: the built-in defaults.
|
|
14
|
+
* 2. USER: `<config>/wayfinder/config.json` (see `xdg.ts`), or the file
|
|
15
|
+
* `WAYFINDER_CONFIG` names.
|
|
16
|
+
* 3. PROJECT: `wayfinder.config.json` at the project root.
|
|
13
17
|
* 4. CLI flags, applied by the caller. {@link collectOptionsFromConfig}
|
|
14
18
|
* returns the options a caller spreads its own flags on top of.
|
|
15
19
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* `
|
|
20
|
+
* The project file lives inside the repository being scanned, so it may not
|
|
21
|
+
* set what would let a repository authorize itself, or what is a person's own
|
|
22
|
+
* choice. Each of these is dropped from the project layer before the merge,
|
|
23
|
+
* with a warning, and `config set --project` refuses to write it:
|
|
24
|
+
*
|
|
25
|
+
* - `allowExec: true`. A project may lower `allowExec` to `false`, never
|
|
26
|
+
* raise it. Run `way trust` to give a repository lasting permission.
|
|
27
|
+
* - `trust`, whole. A repository must not pre-authorize itself, or any group
|
|
28
|
+
* of repositories that includes it.
|
|
29
|
+
* - `open`, `theme` and `skills`, which say how a person likes to work.
|
|
24
30
|
*
|
|
25
31
|
* `tools` is gated too, because a tool module is code. User-layer entries
|
|
26
32
|
* always load; project-layer entries load only when the repository is trusted
|
|
27
33
|
* and execution is allowed (see `tools.ts`).
|
|
28
34
|
*
|
|
29
|
-
* `trust` is a stricter exception. It has no lower setting a project could
|
|
30
|
-
* choose, so the whole project-layer `trust` block is dropped, with a warning
|
|
31
|
-
* when it is not empty. A repository must not be able to pre-authorize itself,
|
|
32
|
-
* or any group of repositories that includes it. Only the user layer's `trust`
|
|
33
|
-
* reaches `@osdlc/trust-repo`'s `policyExecGate`, which combines it with the
|
|
34
|
-
* marker store that `way trust` writes to. See that package's README for the
|
|
35
|
-
* glob dialect, and `origin-owner.ts` for the origin-remote lookup that
|
|
36
|
-
* `trust.owners` uses.
|
|
37
|
-
*
|
|
38
|
-
* XDG paths are used on every platform, macOS included, as `gh` does. A
|
|
39
|
-
* developer with a dotfiles repository expects this file beside their other
|
|
40
|
-
* tool config.
|
|
41
|
-
*
|
|
42
35
|
* `WAYFINDER_CONFIG=/path/to/file` changes only where the user layer is read
|
|
43
|
-
* from.
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* nothing is a typo. A relative value is ignored with a warning, and the XDG
|
|
47
|
-
* path is read instead.
|
|
48
|
-
*
|
|
49
|
-
* ## The old waypost names
|
|
50
|
-
*
|
|
51
|
-
* The tool was called waypost before its first release. Each old name is still
|
|
52
|
-
* read when its new one is absent, so an existing setup keeps working:
|
|
53
|
-
* `WAYPOST_CONFIG` when `WAYFINDER_CONFIG` is unset, `<config>/waypost/config.json`
|
|
54
|
-
* when `<config>/wayfinder/config.json` does not exist, and `waypost.config.json`
|
|
55
|
-
* when `wayfinder.config.json` does not exist. A file found this way is also the
|
|
56
|
-
* one `config set` edits, so a setting never lands in a file that is not read.
|
|
57
|
-
* Each fallback adds a warning that names the new location. When both the old
|
|
58
|
-
* and the new file exist, the new one is read and a warning says the old one
|
|
59
|
-
* is ignored.
|
|
36
|
+
* from. Naming a file that does not exist is an error, not an empty layer. A
|
|
37
|
+
* relative value is ignored with a warning, since from the project root it
|
|
38
|
+
* would name a file in the repository.
|
|
60
39
|
*
|
|
61
40
|
* ## Merge rule
|
|
62
41
|
*
|
|
63
42
|
* Objects merge key by key. Everything else, scalars and arrays alike,
|
|
64
|
-
* replaces the lower value whole.
|
|
65
|
-
*
|
|
66
|
-
* means that list, not that list appended to the user's.
|
|
67
|
-
*
|
|
68
|
-
* user { runners: { disabled: ["cargo"], order: ["moon"] } }
|
|
69
|
-
* project { runners: { order: ["just"] } }
|
|
70
|
-
* result { runners: { disabled: ["cargo"], order: ["just"] } }
|
|
43
|
+
* replaces the lower value whole. A project that says `order: ["just"]` means
|
|
44
|
+
* that list, not that list appended to the user's.
|
|
71
45
|
*
|
|
72
46
|
* ## Unknown keys and broken files
|
|
73
47
|
*
|
|
74
|
-
* An unknown key is a warning naming the file and the key,
|
|
75
|
-
* file still loads
|
|
76
|
-
* older one. A malformed file, or a value of the
|
|
77
|
-
* a {@link ConfigError} naming the file and the
|
|
78
|
-
*
|
|
79
|
-
* to load.
|
|
48
|
+
* An unknown key is a warning naming the file and the key, with the closest
|
|
49
|
+
* known key, and the rest of the file still loads: a file written for a newer
|
|
50
|
+
* version must not break an older one. A malformed file, or a value of the
|
|
51
|
+
* wrong type for a known key, is a {@link ConfigError} naming the file and the
|
|
52
|
+
* problem. `$schema` is accepted and ignored.
|
|
80
53
|
*/
|
|
54
|
+
import { z } from 'zod';
|
|
81
55
|
import { type PolicyDecisionOptions, type TrustPolicy } from '@osdlc/trust-repo';
|
|
82
|
-
import type { DiscoveryMode } from '@osdlc/system-model/detect';
|
|
83
56
|
import { CONFIG_ENV_VAR, PROJECT_CONFIG_FILENAME } from './app.ts';
|
|
57
|
+
import { type Theme } from './config-keys.ts';
|
|
58
|
+
import { USER_CONFIG_FILENAME } from './xdg.ts';
|
|
84
59
|
import type { WayOptions } from './catalog.ts';
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
export declare const USER_CONFIG_DIR = "wayfinder";
|
|
88
|
-
/** The `tool` key of the trust store (`$XDG_STATE_HOME/<tool>/trusted/`). */
|
|
89
|
-
export declare const TRUST_STORE_TOOL = "wayfinder";
|
|
90
|
-
/** The old {@link USER_CONFIG_DIR}, read when the new user file does not exist. */
|
|
91
|
-
export declare const LEGACY_USER_CONFIG_DIR = "waypost";
|
|
92
|
-
/** The old {@link TRUST_STORE_TOOL}. Its grants are still honoured; see `trust-store.ts`. */
|
|
93
|
-
export declare const LEGACY_TRUST_STORE_TOOL = "waypost";
|
|
94
|
-
/** The USER layer's filename inside {@link USER_CONFIG_DIR}. */
|
|
95
|
-
export declare const USER_CONFIG_FILENAME = "config.json";
|
|
96
|
-
export interface RunnersConfig {
|
|
97
|
-
/** Built-in runner ids to skip entirely. Becomes `CollectOptions.exclude`. */
|
|
98
|
-
disabled?: string[];
|
|
99
|
-
/** Preferred display order. Runners not named here follow alphabetically. */
|
|
100
|
-
order?: string[];
|
|
101
|
-
}
|
|
60
|
+
import { type SkillsSetting } from './core/skills.ts';
|
|
61
|
+
export { CONFIG_ENV_VAR, PROJECT_CONFIG_FILENAME, USER_CONFIG_FILENAME };
|
|
102
62
|
/**
|
|
103
|
-
* The
|
|
104
|
-
*
|
|
105
|
-
* module docblock). A project-layer block is dropped before the merge.
|
|
63
|
+
* The URL a written file's `$schema` names: the schema this release line ships
|
|
64
|
+
* in `schema/config.json`. Raise it with each minor release.
|
|
106
65
|
*/
|
|
107
|
-
export
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
* Origin remote owners that trust a root without a marker: `host/owner`, or
|
|
116
|
-
* a bare `owner` for `github.com/owner`. Case-insensitive.
|
|
117
|
-
*/
|
|
118
|
-
owners?: string[];
|
|
119
|
-
}
|
|
66
|
+
export declare const CONFIG_SCHEMA_URL = "https://unpkg.com/@osdlc/wayfinder@0.8/schema/config.json";
|
|
67
|
+
/** The `discovery` values. */
|
|
68
|
+
export declare const DISCOVERY_VALUES: readonly ["git", "walk", "auto"];
|
|
69
|
+
/** The `open` values: what the bare `way` command opens. */
|
|
70
|
+
export declare const OPEN_VALUES: readonly ["tui", "web"];
|
|
71
|
+
/** What the bare `way` command opens. */
|
|
72
|
+
export type OpenSurface = (typeof OPEN_VALUES)[number];
|
|
73
|
+
export { THEME_VALUES, type Theme } from './config-keys.ts';
|
|
120
74
|
/**
|
|
121
|
-
* The
|
|
122
|
-
*
|
|
123
|
-
* A type alias rather than an interface, so it has an implicit index
|
|
124
|
-
* signature. That lets {@link setConfigValue} and the related functions take
|
|
125
|
-
* both this and the raw record read from a file.
|
|
75
|
+
* The configuration file, as a Zod schema. Every key is optional; the defaults
|
|
76
|
+
* are {@link DEFAULT_CONFIG}.
|
|
126
77
|
*/
|
|
127
|
-
export
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
78
|
+
export declare const WayfinderConfigSchema: z.ZodObject<{
|
|
79
|
+
$schema: z.ZodOptional<z.ZodString>;
|
|
80
|
+
runners: z.ZodOptional<z.ZodObject<{
|
|
81
|
+
disabled: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
82
|
+
order: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
83
|
+
}, z.core.$strip>>;
|
|
84
|
+
allowExec: z.ZodOptional<z.ZodBoolean>;
|
|
85
|
+
discovery: z.ZodOptional<z.ZodEnum<{
|
|
86
|
+
git: "git";
|
|
87
|
+
walk: "walk";
|
|
88
|
+
auto: "auto";
|
|
89
|
+
}>>;
|
|
90
|
+
excludePaths: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
91
|
+
trust: z.ZodOptional<z.ZodObject<{
|
|
92
|
+
paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
93
|
+
owners: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
94
|
+
tools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
95
|
+
paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
96
|
+
owners: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
97
|
+
}, z.core.$strip>>>;
|
|
98
|
+
}, z.core.$strip>>;
|
|
99
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
100
|
+
open: z.ZodOptional<z.ZodEnum<{
|
|
101
|
+
tui: "tui";
|
|
102
|
+
web: "web";
|
|
103
|
+
}>>;
|
|
104
|
+
theme: z.ZodOptional<z.ZodEnum<{
|
|
105
|
+
system: "system";
|
|
106
|
+
light: "light";
|
|
107
|
+
dark: "dark";
|
|
108
|
+
}>>;
|
|
109
|
+
skills: z.ZodOptional<z.ZodEnum<{
|
|
110
|
+
project: "project";
|
|
111
|
+
all: "all";
|
|
112
|
+
off: "off";
|
|
113
|
+
}>>;
|
|
114
|
+
}, z.core.$strip>;
|
|
115
|
+
/** The configuration document. */
|
|
116
|
+
export type WayfinderConfig = Omit<z.infer<typeof WayfinderConfigSchema>, '$schema'>;
|
|
156
117
|
/**
|
|
157
|
-
* The
|
|
158
|
-
*
|
|
159
|
-
* Every leaf is present, so {@link LoadedConfig.sources} has an entry for
|
|
160
|
-
* every key. A key set in no file is attributed to this layer.
|
|
118
|
+
* The configuration document.
|
|
119
|
+
* @deprecated Use {@link WayfinderConfig}.
|
|
161
120
|
*/
|
|
162
|
-
export
|
|
121
|
+
export type TaskConfig = WayfinderConfig;
|
|
122
|
+
/** `config.runners`. */
|
|
123
|
+
export type RunnersConfig = NonNullable<WayfinderConfig['runners']>;
|
|
124
|
+
/** `config.trust`: the policy `@osdlc/trust-repo`'s `policyExecGate` decides over. User layer only. */
|
|
125
|
+
export type TrustConfig = NonNullable<WayfinderConfig['trust']>;
|
|
126
|
+
/** The schema's JSON Schema, as shipped in `schema/config.json`. */
|
|
127
|
+
export declare function configJsonSchema(): Record<string, unknown>;
|
|
128
|
+
/**
|
|
129
|
+
* Every setting, in schema order: the dotted names `config list` shows and
|
|
130
|
+
* `config set` accepts. `trust.tools` is one setting whose value is an
|
|
131
|
+
* object; `config set` also takes a key under it, such as
|
|
132
|
+
* `trust.tools.mise.paths`.
|
|
133
|
+
*/
|
|
134
|
+
export declare const CONFIG_KEYS: readonly string[];
|
|
135
|
+
export { CLI_ONLY_KEYS, USER_ONLY_KEYS } from './config-keys.ts';
|
|
136
|
+
/**
|
|
137
|
+
* Why the project file may not hold `value` at `key`, in a few words, or null
|
|
138
|
+
* when it may. `config explain` shows it beside an ignored project value.
|
|
139
|
+
*/
|
|
140
|
+
export declare function projectIgnoreReason(key: string, value: unknown): string | null;
|
|
141
|
+
/**
|
|
142
|
+
* Why `value` may not be written at `key` in the project file, or null when
|
|
143
|
+
* it may. `config set --project` and the web view's save both ask this.
|
|
144
|
+
*/
|
|
145
|
+
export declare function projectWriteRefusal(key: string, value: unknown): string | null;
|
|
146
|
+
/**
|
|
147
|
+
* A configuration file that cannot be honoured: unparseable, or holding a
|
|
148
|
+
* value of the wrong type.
|
|
149
|
+
*/
|
|
150
|
+
export declare class ConfigError extends Error {
|
|
151
|
+
/**
|
|
152
|
+
* The file the error is about. Empty when the error concerns a value handed
|
|
153
|
+
* in directly, as {@link setConfigValue} does with a bad key or value.
|
|
154
|
+
*/
|
|
155
|
+
readonly file: string;
|
|
156
|
+
constructor(message: string, file: string);
|
|
157
|
+
}
|
|
163
158
|
export type ConfigLayer = 'default' | 'user' | 'project';
|
|
164
159
|
export interface ConfigLocations {
|
|
165
160
|
/** Absolute path of the user layer's file, whether or not it exists. */
|
|
166
161
|
user: string;
|
|
167
|
-
/** True when
|
|
162
|
+
/** True when {@link CONFIG_ENV_VAR} supplied that path. */
|
|
168
163
|
userFromEnv: boolean;
|
|
169
|
-
/**
|
|
164
|
+
/** {@link CONFIG_ENV_VAR} when it supplied the path, else null. */
|
|
170
165
|
userEnvVar: string | null;
|
|
171
|
-
/**
|
|
172
|
-
userLegacy: boolean;
|
|
173
|
-
/** The old waypost user file, when it exists beside the new one and is ignored. */
|
|
174
|
-
userIgnored: string | null;
|
|
175
|
-
/**
|
|
176
|
-
* A relative {@link CONFIG_ENV_VAR} (or old-name) value, which is ignored:
|
|
177
|
-
* the variable and its value. Null when none was ignored.
|
|
178
|
-
*/
|
|
166
|
+
/** A relative {@link CONFIG_ENV_VAR} value, which is ignored. Null when none was. */
|
|
179
167
|
userEnvIgnored: {
|
|
180
168
|
variable: string;
|
|
181
169
|
value: string;
|
|
182
170
|
} | null;
|
|
183
|
-
/**
|
|
184
|
-
* Absolute path of `<root>/wayfinder.config.json`, whether or not it exists,
|
|
185
|
-
* or of `<root>/waypost.config.json` when only that one exists.
|
|
186
|
-
*/
|
|
171
|
+
/** Absolute path of `<root>/wayfinder.config.json`, whether or not it exists. */
|
|
187
172
|
project: string;
|
|
188
|
-
/** True when `project` is the old waypost file. */
|
|
189
|
-
projectLegacy: boolean;
|
|
190
|
-
/** `<root>/waypost.config.json`, when it exists beside the new file and is ignored. */
|
|
191
|
-
projectIgnored: string | null;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* A configuration file that cannot be honoured — unparseable, or holding a
|
|
195
|
-
* value of the wrong type.
|
|
196
|
-
*/
|
|
197
|
-
export declare class ConfigError extends Error {
|
|
198
|
-
/**
|
|
199
|
-
* The file the error is about. Empty when the error concerns a value handed
|
|
200
|
-
* in directly, as {@link setConfigValue} does with a bad key or value.
|
|
201
|
-
*/
|
|
202
|
-
readonly file: string;
|
|
203
|
-
constructor(message: string, file: string);
|
|
204
173
|
}
|
|
205
174
|
/**
|
|
206
|
-
*
|
|
175
|
+
* Where each layer's file lives. `env` and `home` are injectable so a test
|
|
176
|
+
* does not read the developer's own config. Nothing is read.
|
|
207
177
|
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
178
|
+
* A leading `~` in {@link CONFIG_ENV_VAR} is expanded against `home`: `.env`
|
|
179
|
+
* loaders, direnv and CI YAML pass a literal tilde through. A relative value
|
|
180
|
+
* is ignored and `userEnvIgnored` says so.
|
|
210
181
|
*/
|
|
211
|
-
export declare
|
|
182
|
+
export declare function configLocations(root: string, env?: Record<string, string | undefined>, home?: string): ConfigLocations;
|
|
212
183
|
/**
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
* Rules for a path taken from the environment:
|
|
219
|
-
*
|
|
220
|
-
* A leading `~` is expanded against `home`. A shell expands it before exec, but
|
|
221
|
-
* `.env` loaders, direnv and CI YAML pass the literal tilde through. Without
|
|
222
|
-
* this, `~/config.json` would silently become `<somewhere>/~/config.json`.
|
|
223
|
-
*
|
|
224
|
-
* A relative `XDG_CONFIG_HOME` is ignored, as the XDG spec says. A relative
|
|
225
|
-
* `WAYFINDER_CONFIG` is ignored too, and `userEnvIgnored` says so. Resolved
|
|
226
|
-
* against the root, or against the cwd, which is usually the root, it would
|
|
227
|
-
* name a file inside the repository being scanned, and the user layer can
|
|
228
|
-
* turn execution on and load tools.
|
|
184
|
+
* The warning for a Windows user config left where releases before 0.8 kept
|
|
185
|
+
* it (`~\.config\wayfinder\config.json`), when there is none at the new
|
|
186
|
+
* path. That file is not read, so its settings, `allowExec: false` among
|
|
187
|
+
* them, no longer apply. Null when there is nothing to say.
|
|
229
188
|
*/
|
|
230
|
-
export declare function
|
|
189
|
+
export declare function movedUserConfigWarning(locations: ConfigLocations, env: Record<string, string | undefined>, home: string, platform?: NodeJS.Platform): string | null;
|
|
190
|
+
/** The warning for a relative {@link CONFIG_ENV_VAR} that was ignored, or null. */
|
|
191
|
+
export declare function envIgnoredWarning(locations: ConfigLocations): string | null;
|
|
231
192
|
/**
|
|
232
|
-
* Validate a parsed JSON document against
|
|
193
|
+
* Validate a parsed JSON document against {@link WayfinderConfigSchema}.
|
|
233
194
|
*
|
|
234
|
-
* Throws {@link ConfigError} on a
|
|
235
|
-
* warning per unknown key. Because the result holds only
|
|
236
|
-
* path never goes through this shape (see
|
|
195
|
+
* Throws {@link ConfigError} on a wrong value. Returns the known keys (without
|
|
196
|
+
* `$schema`) plus one warning per unknown key. Because the result holds only
|
|
197
|
+
* known keys, the write path never goes through this shape (see
|
|
198
|
+
* {@link readRawConfigFile}).
|
|
237
199
|
*/
|
|
238
200
|
export declare function validateConfig(raw: unknown, file: string): {
|
|
239
|
-
config:
|
|
201
|
+
config: WayfinderConfig;
|
|
240
202
|
warnings: string[];
|
|
241
203
|
};
|
|
242
204
|
/**
|
|
243
205
|
* Merge `over` onto `base` per the module's rule: objects key by key, scalars
|
|
244
|
-
* and arrays replaced whole.
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
* either, including branches `over` does not mention. Mutating a loaded config
|
|
248
|
-
* must not change `DEFAULT_CONFIG`.
|
|
206
|
+
* and arrays replaced whole. Neither argument is changed, and the result
|
|
207
|
+
* shares no object or array with either, so mutating a loaded config cannot
|
|
208
|
+
* change {@link DEFAULT_CONFIG}.
|
|
249
209
|
*/
|
|
250
|
-
export declare function mergeConfig(base:
|
|
210
|
+
export declare function mergeConfig(base: WayfinderConfig, over: WayfinderConfig): WayfinderConfig;
|
|
251
211
|
/**
|
|
252
|
-
* The
|
|
212
|
+
* The built-in defaults layer. Every setting is present, so
|
|
213
|
+
* {@link LoadedConfig.sources} has an entry for each one.
|
|
253
214
|
*
|
|
254
|
-
* `
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
|
|
215
|
+
* `allowExec: true` does not mean "run this repository's code". The
|
|
216
|
+
* repository must also be trusted, and a configured `false` still means no
|
|
217
|
+
* execution.
|
|
218
|
+
*/
|
|
219
|
+
export declare const DEFAULT_CONFIG: Required<WayfinderConfig>;
|
|
220
|
+
/**
|
|
221
|
+
* The file's parsed object, unvalidated and with every key intact. `set` and
|
|
222
|
+
* `unset` edit this object, not the validated shape, because validation drops
|
|
223
|
+
* unknown keys: writing a validated document back would delete a setting a
|
|
224
|
+
* newer version had written. `null` when the file does not exist.
|
|
258
225
|
*/
|
|
259
226
|
export declare function readRawConfigFile(file: string): Promise<Record<string, unknown> | null>;
|
|
260
227
|
/**
|
|
261
228
|
* Read, parse and validate one layer. `null` when the file does not exist,
|
|
262
|
-
* which is normal
|
|
263
|
-
* {@link ConfigError}.
|
|
229
|
+
* which is normal. A file that exists and is broken throws {@link ConfigError}.
|
|
264
230
|
*/
|
|
265
231
|
export declare function readConfigFile(file: string): Promise<{
|
|
266
|
-
config:
|
|
232
|
+
config: WayfinderConfig;
|
|
267
233
|
warnings: string[];
|
|
268
234
|
} | null>;
|
|
269
235
|
/**
|
|
270
|
-
* Write a configuration file:
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
* unchanged file. A config under version control should not show a diff
|
|
276
|
-
* because a key moved.
|
|
236
|
+
* Write a configuration file atomically: a temporary file, then a rename, so
|
|
237
|
+
* a crash or two saves at once never leave a truncated file. Known keys come
|
|
238
|
+
* in schema order, unknown keys after them in the order they had, with a
|
|
239
|
+
* two-space indent and a trailing newline. A file with no `$schema` gets
|
|
240
|
+
* {@link CONFIG_SCHEMA_URL}. Parent directories are created.
|
|
277
241
|
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
242
|
+
* Writing an unchanged document gives an unchanged file, so a config under
|
|
243
|
+
* version control shows no diff because a key moved. Accepts a raw record, so
|
|
244
|
+
* an edit can keep unknown keys.
|
|
280
245
|
*/
|
|
281
|
-
export declare function writeConfigFile(file: string, config:
|
|
246
|
+
export declare function writeConfigFile(file: string, config: WayfinderConfig | Record<string, unknown>): Promise<void>;
|
|
282
247
|
export interface LoadedConfig {
|
|
283
248
|
/** Defaults, then user, then project, merged. The values a caller should use. */
|
|
284
|
-
effective:
|
|
249
|
+
effective: WayfinderConfig;
|
|
285
250
|
/**
|
|
286
|
-
* The layers as they were applied. `project` has already had a
|
|
287
|
-
*
|
|
288
|
-
* and `sources`. Read the file itself with {@link readRawConfigFile} to see
|
|
289
|
-
* what was written.
|
|
251
|
+
* The layers as they were applied. `project` has already had the keys a
|
|
252
|
+
* project may not set removed, so it matches `effective` and `sources`.
|
|
290
253
|
*/
|
|
291
254
|
layers: {
|
|
292
|
-
default:
|
|
293
|
-
user:
|
|
294
|
-
project:
|
|
255
|
+
default: WayfinderConfig;
|
|
256
|
+
user: WayfinderConfig | null;
|
|
257
|
+
project: WayfinderConfig | null;
|
|
295
258
|
};
|
|
296
|
-
/**
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
259
|
+
/** The layers as their files say, validated but before any key was removed. */
|
|
260
|
+
files: {
|
|
261
|
+
user: WayfinderConfig | null;
|
|
262
|
+
project: WayfinderConfig | null;
|
|
263
|
+
};
|
|
264
|
+
/** Each key of {@link CONFIG_KEYS} to the layer that supplied its value. */
|
|
301
265
|
sources: Map<string, ConfigLayer>;
|
|
302
266
|
locations: ConfigLocations;
|
|
303
|
-
/** Warnings from every layer: unknown keys, ignored project keys,
|
|
267
|
+
/** Warnings from every layer: unknown keys, ignored project keys, an ignored env path. */
|
|
304
268
|
warnings: string[];
|
|
305
269
|
}
|
|
306
270
|
/**
|
|
307
|
-
* Load every layer and merge them. `env` and `home` are injectable for the
|
|
308
|
-
* reason {@link configLocations} takes them.
|
|
271
|
+
* Load every layer and merge them. `env` and `home` are injectable for the
|
|
272
|
+
* same reason {@link configLocations} takes them.
|
|
309
273
|
*/
|
|
310
274
|
export declare function loadConfig(root: string, env?: Record<string, string | undefined>, home?: string): Promise<LoadedConfig>;
|
|
311
|
-
/**
|
|
312
|
-
export
|
|
313
|
-
/**
|
|
275
|
+
/** One setting's effective value and where it came from. */
|
|
276
|
+
export interface SettingValue<T = unknown> {
|
|
277
|
+
/** The dotted key: `runners.order`. */
|
|
278
|
+
key: string;
|
|
279
|
+
value: T;
|
|
280
|
+
/** The layer that set it, or `default`. */
|
|
281
|
+
source: ConfigLayer;
|
|
282
|
+
/** The file that set it. Null for the default. */
|
|
283
|
+
file: string | null;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* The settings every surface shows, read once. The terminal UI, the web view
|
|
287
|
+
* and `way config list` all take their values from {@link readSettings}, so
|
|
288
|
+
* they show the same answer.
|
|
289
|
+
*/
|
|
290
|
+
export interface Settings {
|
|
291
|
+
/** The full load, for a caller that needs the layers. */
|
|
292
|
+
loaded: LoadedConfig;
|
|
293
|
+
/** Every key of {@link CONFIG_KEYS}, in order. */
|
|
294
|
+
settings: SettingValue[];
|
|
295
|
+
/** The configured `allowExec`. Execution also needs a trusted repository. */
|
|
296
|
+
allowExec: SettingValue<boolean>;
|
|
297
|
+
/** What the bare `way` command opens. */
|
|
298
|
+
open: SettingValue<OpenSurface>;
|
|
299
|
+
/** The web view's theme. */
|
|
300
|
+
theme: SettingValue<Theme>;
|
|
301
|
+
/** The runner display order. */
|
|
302
|
+
runnerOrder: SettingValue<string[]>;
|
|
303
|
+
/** Which agent skills the Skills group lists. */
|
|
304
|
+
skills: SettingValue<SkillsSetting>;
|
|
305
|
+
warnings: string[];
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Read every layer for `root` and return each setting's effective value and
|
|
309
|
+
* source. Throws {@link ConfigError} for a broken file.
|
|
310
|
+
*/
|
|
311
|
+
export declare function readSettings(root: string, env?: Record<string, string | undefined>, home?: string): Promise<Settings>;
|
|
312
|
+
/** A file layer a setting can be written to. */
|
|
313
|
+
export type WritableLayer = 'user' | 'project';
|
|
314
|
+
/** Where {@link writeSetting} and {@link removeSetting} write. */
|
|
315
|
+
export interface WriteTarget {
|
|
316
|
+
layer: WritableLayer;
|
|
317
|
+
/** The project root. Used for the project layer. */
|
|
318
|
+
root: string;
|
|
319
|
+
env?: Record<string, string | undefined>;
|
|
320
|
+
home?: string;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Write `value` at `key` in one layer's file, atomically, keeping every other
|
|
324
|
+
* key. Throws {@link ConfigError} with an empty `file` for an unknown key, a
|
|
325
|
+
* wrong value, or a key the project file may not hold (see
|
|
326
|
+
* {@link projectWriteRefusal}); throws one naming the file when the file is
|
|
327
|
+
* broken. Returns the file and the value as written, and warnings for unknown
|
|
328
|
+
* keys inside the value.
|
|
329
|
+
*/
|
|
330
|
+
export declare function writeSetting(target: WriteTarget, key: string, value: unknown): Promise<{
|
|
331
|
+
file: string;
|
|
332
|
+
value: unknown;
|
|
333
|
+
warnings: string[];
|
|
334
|
+
}>;
|
|
335
|
+
/** Remove `key` from one layer's file. `removed: false` when it was not set there. */
|
|
336
|
+
export declare function removeSetting(target: WriteTarget, key: string): Promise<{
|
|
337
|
+
file: string;
|
|
338
|
+
removed: boolean;
|
|
339
|
+
}>;
|
|
340
|
+
/** Read a dotted path: `"runners.order"`, `"allowExec"`. `undefined` when absent. */
|
|
314
341
|
export declare function getConfigValue(config: object, key: string): unknown;
|
|
315
342
|
/**
|
|
316
343
|
* Set a dotted path, returning a new document. The input is not changed.
|
|
317
344
|
* Missing intermediate objects are created, so `set` works on an empty file.
|
|
318
345
|
*
|
|
319
346
|
* Throws {@link ConfigError} for an unknown key, a value of the wrong type, or
|
|
320
|
-
* an existing intermediate value that is not an object
|
|
321
|
-
*
|
|
322
|
-
* its unknown keys untouched.
|
|
347
|
+
* an existing intermediate value that is not an object. Given a raw record, it
|
|
348
|
+
* returns a raw record with its unknown keys untouched.
|
|
323
349
|
*/
|
|
324
350
|
export declare function setConfigValue<T extends object>(config: T, key: string, value: unknown): T;
|
|
325
351
|
/**
|
|
326
|
-
* Remove a dotted path, returning a new document. A container left empty by
|
|
327
|
-
* removal is removed too
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
* Unlike `set`, any key may be unset, including one this version does not
|
|
331
|
-
* know, so a stale setting can be removed.
|
|
352
|
+
* Remove a dotted path, returning a new document. A container left empty by
|
|
353
|
+
* the removal is removed too. Any key may be unset, including one this
|
|
354
|
+
* version does not know, so a stale setting can be removed.
|
|
332
355
|
*/
|
|
333
356
|
export declare function unsetConfigValue<T extends object>(config: T, key: string): T;
|
|
334
357
|
/**
|
|
335
|
-
* Parse a value typed on a command line
|
|
336
|
-
* `
|
|
337
|
-
* JSON is kept as a string, so `moon` need not be typed as `"moon"`.
|
|
358
|
+
* Parse a value typed on a command line: JSON first, so `true` and
|
|
359
|
+
* `["a","b"]` keep their types, else the bare string.
|
|
338
360
|
*/
|
|
339
361
|
export declare function parseConfigValue(raw: string): unknown;
|
|
362
|
+
/** The key a typed key names, or undefined when it names no setting. */
|
|
363
|
+
export declare function resolveConfigKey(key: string): string | undefined;
|
|
340
364
|
/**
|
|
341
365
|
* The {@link WayOptions} fields this configuration controls. Only keys the
|
|
342
366
|
* config sets are present, so a caller spreads its own flags after it.
|
|
343
367
|
*/
|
|
344
|
-
export declare function collectOptionsFromConfig(config:
|
|
345
|
-
/** `config.trust`, defaulted to the empty policy `@osdlc/trust-repo` expects. */
|
|
346
|
-
export declare function trustPolicyFromConfig(config: TaskConfig): TrustPolicy;
|
|
368
|
+
export declare function collectOptionsFromConfig(config: WayfinderConfig): Pick<WayOptions, 'exclude' | 'allowExec' | 'discovery' | 'excludePaths'>;
|
|
347
369
|
/**
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
* character) with `resolveTrustRoot`.
|
|
351
|
-
*
|
|
352
|
-
* This is the `expandPath` that `policyExecGate` and `policyDecision` take.
|
|
353
|
-
* Without it, a pattern written as a person typed it (`/tmp/…`, which on macOS
|
|
354
|
-
* is really `/private/tmp/…`) would never match the resolved root that
|
|
355
|
-
* `policyDecision` compares it with.
|
|
370
|
+
* `config.trust` as the policy `@osdlc/trust-repo` expects: the top-level
|
|
371
|
+
* rules, and `trust.tools` as its per-scope rules.
|
|
356
372
|
*/
|
|
357
|
-
export declare function
|
|
373
|
+
export declare function trustPolicyFromConfig(config: WayfinderConfig): TrustPolicy;
|
|
358
374
|
/**
|
|
359
|
-
* The options every `@osdlc/trust-repo` gate call takes:
|
|
360
|
-
* against `home`, and the
|
|
361
|
-
* Built in one place, so a call site cannot leave out `ownerOf
|
|
362
|
-
* stop honouring `trust.owners`.
|
|
375
|
+
* The options every `@osdlc/trust-repo` gate call takes: `expandTrustPath`
|
|
376
|
+
* against `home`, and the git-backed `originOwner` lookup that `trust.owners`
|
|
377
|
+
* needs. Built in one place, so a call site cannot leave out `ownerOf`.
|
|
363
378
|
*/
|
|
364
379
|
export declare function trustPolicyOptions(home: string): PolicyDecisionOptions;
|
|
365
380
|
/**
|
|
366
381
|
* Sort runner-keyed items for display: the ids named in `order` first, in that
|
|
367
|
-
* order, then everything else alphabetically.
|
|
368
|
-
* registry order, so adding a tool does not reorder the list.
|
|
382
|
+
* order, then everything else alphabetically.
|
|
369
383
|
*/
|
|
370
384
|
export declare function orderRunners<T extends {
|
|
371
385
|
runner: string;
|