@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.
Files changed (121) hide show
  1. package/CHANGELOG.md +240 -0
  2. package/CONTRIBUTING.md +6 -0
  3. package/README.md +310 -150
  4. package/SECURITY.md +19 -5
  5. package/dist/actions.d.ts +23 -0
  6. package/dist/actions.js +97 -0
  7. package/dist/app.d.ts +1 -13
  8. package/dist/app.js +1 -13
  9. package/dist/args.d.ts +11 -6
  10. package/dist/args.js +25 -7
  11. package/dist/cache.d.ts +2 -4
  12. package/dist/cache.js +5 -10
  13. package/dist/catalog.d.ts +45 -4
  14. package/dist/catalog.js +134 -13
  15. package/dist/clean-command.d.ts +65 -36
  16. package/dist/clean-command.js +372 -226
  17. package/dist/cli.d.ts +24 -57
  18. package/dist/cli.js +139 -568
  19. package/dist/commands/browse.d.ts +128 -0
  20. package/dist/commands/browse.js +153 -0
  21. package/dist/commands/index.d.ts +25 -0
  22. package/dist/commands/index.js +71 -0
  23. package/dist/commands/list.d.ts +224 -0
  24. package/dist/commands/list.js +178 -0
  25. package/dist/commands/query.d.ts +166 -0
  26. package/dist/commands/query.js +73 -0
  27. package/dist/commands/run.d.ts +114 -0
  28. package/dist/commands/run.js +139 -0
  29. package/dist/commands/shared.d.ts +152 -0
  30. package/dist/commands/shared.js +209 -0
  31. package/dist/config-command.d.ts +27 -43
  32. package/dist/config-command.js +129 -330
  33. package/dist/config-keys.d.ts +25 -0
  34. package/dist/config-keys.js +29 -0
  35. package/dist/config.d.ts +272 -257
  36. package/dist/config.js +611 -460
  37. package/dist/core/copy-text.d.ts +30 -0
  38. package/dist/core/copy-text.js +50 -0
  39. package/dist/core/filter.d.ts +55 -0
  40. package/dist/core/filter.js +59 -0
  41. package/dist/core/run.d.ts +22 -0
  42. package/dist/core/run.js +59 -0
  43. package/dist/core/saved-view.d.ts +59 -0
  44. package/dist/core/saved-view.js +119 -0
  45. package/dist/core/session.d.ts +282 -0
  46. package/dist/core/session.js +602 -0
  47. package/dist/core/skills.d.ts +53 -0
  48. package/dist/core/skills.js +54 -0
  49. package/dist/core/unknowns.d.ts +72 -0
  50. package/dist/core/unknowns.js +68 -0
  51. package/dist/devlink.d.ts +3 -0
  52. package/dist/devlink.js +5 -2
  53. package/dist/document-schemas.generated.d.ts +22 -0
  54. package/dist/document-schemas.generated.js +916 -0
  55. package/dist/documents.d.ts +508 -0
  56. package/dist/documents.js +181 -0
  57. package/dist/groups.d.ts +22 -26
  58. package/dist/groups.js +13 -29
  59. package/dist/guide.d.ts +26 -13
  60. package/dist/guide.js +119 -103
  61. package/dist/index.d.ts +118 -0
  62. package/dist/index.js +61 -0
  63. package/dist/keys.d.ts +51 -0
  64. package/dist/keys.js +273 -0
  65. package/dist/page.d.ts +18 -8
  66. package/dist/page.js +28 -17
  67. package/dist/providers-command.d.ts +81 -20
  68. package/dist/providers-command.js +33 -75
  69. package/dist/schema.d.ts +48 -0
  70. package/dist/schema.js +61 -0
  71. package/dist/serve/auth.d.ts +46 -0
  72. package/dist/serve/auth.js +82 -0
  73. package/dist/serve/catalog-share.d.ts +63 -0
  74. package/dist/serve/catalog-share.js +155 -0
  75. package/dist/serve/index.d.ts +100 -0
  76. package/dist/serve/index.js +259 -0
  77. package/dist/serve/routes.d.ts +60 -0
  78. package/dist/serve/routes.js +186 -0
  79. package/dist/serve/terminal-input.d.ts +50 -0
  80. package/dist/serve/terminal-input.js +108 -0
  81. package/dist/skills.d.ts +19 -0
  82. package/dist/skills.js +54 -0
  83. package/dist/terminal-text.d.ts +8 -0
  84. package/dist/terminal-text.js +19 -6
  85. package/dist/tool-info.d.ts +24 -0
  86. package/dist/tool-info.js +17 -0
  87. package/dist/trust-command.d.ts +15 -27
  88. package/dist/trust-command.js +110 -208
  89. package/dist/trust-store.d.ts +5 -10
  90. package/dist/trust-store.js +9 -42
  91. package/dist/tui/app.d.ts +193 -0
  92. package/dist/tui/app.js +1400 -0
  93. package/dist/tui/copy.d.ts +29 -0
  94. package/dist/tui/copy.js +39 -0
  95. package/dist/tui/index.d.ts +33 -0
  96. package/dist/tui/index.js +97 -0
  97. package/dist/tui/keys-input.d.ts +27 -0
  98. package/dist/tui/keys-input.js +87 -0
  99. package/dist/tui/settings.d.ts +94 -0
  100. package/dist/tui/settings.js +198 -0
  101. package/dist/tui/style.d.ts +62 -0
  102. package/dist/tui/style.js +77 -0
  103. package/dist/version.d.ts +6 -0
  104. package/dist/version.js +7 -0
  105. package/dist/vocabulary.d.ts +91 -0
  106. package/dist/vocabulary.js +155 -0
  107. package/dist/web/main.js +2232 -582
  108. package/dist/web/page.html +41 -33
  109. package/dist/web/styles.css +513 -329
  110. package/dist/xdg.d.ts +76 -4
  111. package/dist/xdg.js +77 -5
  112. package/package.json +27 -8
  113. package/schema/config.json +133 -0
  114. package/dist/http.d.ts +0 -22
  115. package/dist/http.js +0 -149
  116. package/dist/origin-owner.d.ts +0 -19
  117. package/dist/origin-owner.js +0 -85
  118. package/dist/serve.d.ts +0 -98
  119. package/dist/serve.js +0 -671
  120. package/dist/tui.d.ts +0 -177
  121. package/dist/tui.js +0 -840
package/dist/config.d.ts CHANGED
@@ -4,368 +4,383 @@
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. `DEFAULT_CONFIG` — the built-in defaults.
10
- * 2. USER — `$XDG_CONFIG_HOME/wayfinder/config.json`, or `~/.config/wayfinder/config.json`
11
- * when `XDG_CONFIG_HOME` is unset or relative.
12
- * 3. PROJECT — `wayfinder.config.json` at the root `findRoot` resolves.
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
- * `allowExec` is an exception to this order. The project layer may lower it to
17
- * `false`, since a repository asking not to be run is safe to honour. It can
18
- * never raise it to `true`. `wayfinder.config.json` lives inside the repository
19
- * being scanned, so honouring `allowExec: true` from it would let a repository
20
- * authorize running its own code. So `allowExec: true` is removed from the
21
- * project layer before merging, with a warning. Only the user layer and the CLI
22
- * flags can turn execution on. To give a repository lasting permission, run
23
- * `way trust`, which records the consent outside the repository.
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. The named file is read instead of the XDG path. The project layer is
44
- * still read from the project root and still merges on top. Naming a file that
45
- * does not exist is an error, not an empty layer: an env var that points at
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. Arrays replace because each array setting
65
- * answers "which ones, in what order". A project that says `order: ["just"]`
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, and the rest of the
75
- * file still loads. A config written for a newer version must not break an
76
- * older one. A malformed file, or a value of the wrong type for a known key, is
77
- * a {@link ConfigError} naming the file and the problem. There is no silent
78
- * fallback: a setting that quietly did not apply is worse than one that refused
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
- export { CONFIG_ENV_VAR, PROJECT_CONFIG_FILENAME };
86
- /** Directory under `$XDG_CONFIG_HOME` holding the USER layer. */
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 policy `@osdlc/trust-repo`'s `policyExecGate` decides trust over, on
104
- * top of the marker store `way trust` writes to. User layer only (see the
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, here, in
65
+ * `schema/config.json` and in the configuration guide; tests check all three.
106
66
  */
107
- export interface TrustConfig {
108
- /**
109
- * Glob patterns (`@osdlc/trust-repo`'s dialect: `*`, `?`, `**`, a trailing
110
- * `/**` matching descendants only) over the repo root with symlinks resolved.
111
- * A leading `~` expands against `home`. There are no `{name}` tokens.
112
- */
113
- paths?: string[];
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
- }
67
+ export declare const CONFIG_SCHEMA_URL = "https://unpkg.com/@osdlc/wayfinder@0.9/schema/config.json";
68
+ /** The `discovery` values. */
69
+ export declare const DISCOVERY_VALUES: readonly ["git", "walk", "auto"];
70
+ /** The `open` values: what the bare `way` command opens. */
71
+ export declare const OPEN_VALUES: readonly ["tui", "web"];
72
+ /** What the bare `way` command opens. */
73
+ export type OpenSurface = (typeof OPEN_VALUES)[number];
74
+ export { THEME_VALUES, type Theme } from './config-keys.ts';
120
75
  /**
121
- * The whole configuration document, schema v1.
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.
76
+ * The configuration file, as a Zod schema. Every key is optional; the defaults
77
+ * are {@link DEFAULT_CONFIG}.
126
78
  */
127
- export type TaskConfig = {
128
- runners?: RunnersConfig;
129
- /** Default for the exec trust gate. A `--exec` / `--no-exec` flag still wins. */
130
- allowExec?: boolean;
131
- discovery?: DiscoveryMode | 'auto';
132
- /**
133
- * Paths to leave out of discovery, on top of the built-in list. A bare name
134
- * matches any path segment; a value with a slash matches a path prefix from
135
- * the root, taking the tree beneath it.
136
- *
137
- * Use it to mark a tree as data rather than project structure, such as a
138
- * fixture repo or a vendored sample. `runners.disabled` turns a runner off
139
- * everywhere in the project. This leaves the runner on and narrows where it
140
- * looks.
141
- *
142
- * It usually belongs in the project layer: which trees are fixtures is a fact
143
- * about the repository, the same for everyone working in it. The user layer
144
- * may set it too, and then the project value replaces the user value whole.
145
- */
146
- excludePaths?: string[];
147
- /** User layer only. See {@link TrustConfig} and the module docblock. */
148
- trust?: TrustConfig;
149
- /**
150
- * Modules that export extra `ToolDef`s, as paths. A relative path resolves
151
- * against the file that names it. Project entries load only when the
152
- * repository is trusted and execution is allowed.
153
- */
154
- tools?: string[];
155
- };
79
+ export declare const WayfinderConfigSchema: z.ZodObject<{
80
+ $schema: z.ZodOptional<z.ZodString>;
81
+ runners: z.ZodOptional<z.ZodObject<{
82
+ disabled: z.ZodOptional<z.ZodArray<z.ZodString>>;
83
+ order: z.ZodOptional<z.ZodArray<z.ZodString>>;
84
+ }, z.core.$strip>>;
85
+ allowExec: z.ZodOptional<z.ZodBoolean>;
86
+ discovery: z.ZodOptional<z.ZodEnum<{
87
+ git: "git";
88
+ walk: "walk";
89
+ auto: "auto";
90
+ }>>;
91
+ excludePaths: z.ZodOptional<z.ZodArray<z.ZodString>>;
92
+ trust: z.ZodOptional<z.ZodObject<{
93
+ paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
94
+ owners: z.ZodOptional<z.ZodArray<z.ZodString>>;
95
+ tools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
96
+ paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
97
+ owners: z.ZodOptional<z.ZodArray<z.ZodString>>;
98
+ }, z.core.$strip>>>;
99
+ }, z.core.$strip>>;
100
+ tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
101
+ open: z.ZodOptional<z.ZodEnum<{
102
+ tui: "tui";
103
+ web: "web";
104
+ }>>;
105
+ theme: z.ZodOptional<z.ZodEnum<{
106
+ system: "system";
107
+ light: "light";
108
+ dark: "dark";
109
+ }>>;
110
+ skills: z.ZodOptional<z.ZodEnum<{
111
+ project: "project";
112
+ all: "all";
113
+ off: "off";
114
+ }>>;
115
+ }, z.core.$strip>;
116
+ /** The configuration document. */
117
+ export type WayfinderConfig = Omit<z.infer<typeof WayfinderConfigSchema>, '$schema'>;
156
118
  /**
157
- * The built-in defaults layer.
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.
119
+ * The configuration document.
120
+ * @deprecated Use {@link WayfinderConfig}.
161
121
  */
162
- export declare const DEFAULT_CONFIG: Required<TaskConfig>;
122
+ export type TaskConfig = WayfinderConfig;
123
+ /** `config.runners`. */
124
+ export type RunnersConfig = NonNullable<WayfinderConfig['runners']>;
125
+ /** `config.trust`: the policy `@osdlc/trust-repo`'s `policyExecGate` decides over. User layer only. */
126
+ export type TrustConfig = NonNullable<WayfinderConfig['trust']>;
127
+ /** The schema's JSON Schema, as shipped in `schema/config.json`. */
128
+ export declare function configJsonSchema(): Record<string, unknown>;
129
+ /**
130
+ * Every setting, in schema order: the dotted names `config list` shows and
131
+ * `config set` accepts. `trust.tools` is one setting whose value is an
132
+ * object; `config set` also takes a key under it, such as
133
+ * `trust.tools.mise.paths`.
134
+ */
135
+ export declare const CONFIG_KEYS: readonly string[];
136
+ export { CLI_ONLY_KEYS, USER_ONLY_KEYS } from './config-keys.ts';
137
+ /**
138
+ * Why the project file may not hold `value` at `key`, in a few words, or null
139
+ * when it may. `config explain` shows it beside an ignored project value.
140
+ */
141
+ export declare function projectIgnoreReason(key: string, value: unknown): string | null;
142
+ /**
143
+ * Why `value` may not be written at `key` in the project file, or null when
144
+ * it may. `config set --project` and the web view's save both ask this.
145
+ */
146
+ export declare function projectWriteRefusal(key: string, value: unknown): string | null;
147
+ /**
148
+ * A configuration file that cannot be honoured: unparseable, or holding a
149
+ * value of the wrong type.
150
+ */
151
+ export declare class ConfigError extends Error {
152
+ /**
153
+ * The file the error is about. Empty when the error concerns a value handed
154
+ * in directly, as {@link setConfigValue} does with a bad key or value.
155
+ */
156
+ readonly file: string;
157
+ constructor(message: string, file: string);
158
+ }
163
159
  export type ConfigLayer = 'default' | 'user' | 'project';
164
160
  export interface ConfigLocations {
165
161
  /** Absolute path of the user layer's file, whether or not it exists. */
166
162
  user: string;
167
- /** True when an env var supplied that path instead of XDG. */
163
+ /** True when {@link CONFIG_ENV_VAR} supplied that path. */
168
164
  userFromEnv: boolean;
169
- /** The env var that supplied it: {@link CONFIG_ENV_VAR}, or the old one. Null when none did. */
165
+ /** {@link CONFIG_ENV_VAR} when it supplied the path, else null. */
170
166
  userEnvVar: string | null;
171
- /** True when `user` is the old waypost file, found because the new one does not exist. */
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
- */
167
+ /** A relative {@link CONFIG_ENV_VAR} value, which is ignored. Null when none was. */
179
168
  userEnvIgnored: {
180
169
  variable: string;
181
170
  value: string;
182
171
  } | 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
- */
172
+ /** Absolute path of `<root>/wayfinder.config.json`, whether or not it exists. */
187
173
  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
174
  }
205
175
  /**
206
- * Every settable key, in schema order — the dotted names `config set` accepts.
176
+ * Where each layer's file lives. `env` and `home` are injectable so a test
177
+ * does not read the developer's own config. Nothing is read.
207
178
  *
208
- * Derived from {@link FIELDS}, so anything that lists the keys (the `guide`
209
- * command's config section) stays in step with the schema.
179
+ * A leading `~` in {@link CONFIG_ENV_VAR} is expanded against `home`: `.env`
180
+ * loaders, direnv and CI YAML pass a literal tilde through. A relative value
181
+ * is ignored and `userEnvIgnored` says so.
210
182
  */
211
- export declare const CONFIG_KEYS: readonly string[];
183
+ export declare function configLocations(root: string, env?: Record<string, string | undefined>, home?: string): ConfigLocations;
212
184
  /**
213
- * Resolve where each layer's file lives. `env` and `home` are injectable so a
214
- * test does not read the developer's own `~/.config`. The only other input is
215
- * whether a file exists, which picks between a new name and its old waypost
216
- * name (see the module docblock).
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.
185
+ * The warning for a Windows user config left where releases before 0.8 kept
186
+ * it (`~\.config\wayfinder\config.json`), when there is none at the new
187
+ * path. That file is not read, so its settings, `allowExec: false` among
188
+ * them, no longer apply. Null when there is nothing to say.
229
189
  */
230
- export declare function configLocations(root: string, env?: Record<string, string | undefined>, home?: string): ConfigLocations;
190
+ export declare function movedUserConfigWarning(locations: ConfigLocations, env: Record<string, string | undefined>, home: string, platform?: NodeJS.Platform): string | null;
191
+ /** The warning for a relative {@link CONFIG_ENV_VAR} that was ignored, or null. */
192
+ export declare function envIgnoredWarning(locations: ConfigLocations): string | null;
231
193
  /**
232
- * Validate a parsed JSON document against schema v1.
194
+ * Validate a parsed JSON document against {@link WayfinderConfigSchema}.
233
195
  *
234
- * Throws {@link ConfigError} on a type error. Returns the known keys plus one
235
- * warning per unknown key. Because the result holds only known keys, the write
236
- * path never goes through this shape (see {@link readRawConfigFile}).
196
+ * Throws {@link ConfigError} on a wrong value. Returns the known keys (without
197
+ * `$schema`) plus one warning per unknown key. Because the result holds only
198
+ * known keys, the write path never goes through this shape (see
199
+ * {@link readRawConfigFile}).
237
200
  */
238
201
  export declare function validateConfig(raw: unknown, file: string): {
239
- config: TaskConfig;
202
+ config: WayfinderConfig;
240
203
  warnings: string[];
241
204
  };
242
205
  /**
243
206
  * Merge `over` onto `base` per the module's rule: objects key by key, scalars
244
- * and arrays replaced whole.
245
- *
246
- * Neither argument is changed, and the result shares no object or array with
247
- * either, including branches `over` does not mention. Mutating a loaded config
248
- * must not change `DEFAULT_CONFIG`.
207
+ * and arrays replaced whole. Neither argument is changed, and the result
208
+ * shares no object or array with either, so mutating a loaded config cannot
209
+ * change {@link DEFAULT_CONFIG}.
249
210
  */
250
- export declare function mergeConfig(base: TaskConfig, over: TaskConfig): TaskConfig;
211
+ export declare function mergeConfig(base: WayfinderConfig, over: WayfinderConfig): WayfinderConfig;
251
212
  /**
252
- * The file's parsed object, unvalidated and with every key intact.
213
+ * The built-in defaults layer. Every setting is present, so
214
+ * {@link LoadedConfig.sources} has an entry for each one.
253
215
  *
254
- * `set` and `unset` edit this object, not the validated shape, because
255
- * validation drops unknown keys. Writing a validated document back would
256
- * silently delete a setting a newer version had written. `null` when the file
257
- * does not exist.
216
+ * `allowExec: true` does not mean "run this repository's code". The
217
+ * repository must also be trusted, and a configured `false` still means no
218
+ * execution.
219
+ */
220
+ export declare const DEFAULT_CONFIG: Required<WayfinderConfig>;
221
+ /**
222
+ * The file's parsed object, unvalidated and with every key intact. `set` and
223
+ * `unset` edit this object, not the validated shape, because validation drops
224
+ * unknown keys: writing a validated document back would delete a setting a
225
+ * newer version had written. `null` when the file does not exist.
258
226
  */
259
227
  export declare function readRawConfigFile(file: string): Promise<Record<string, unknown> | null>;
260
228
  /**
261
229
  * Read, parse and validate one layer. `null` when the file does not exist,
262
- * which is normal and not an error. A file that exists and is broken throws
263
- * {@link ConfigError}.
230
+ * which is normal. A file that exists and is broken throws {@link ConfigError}.
264
231
  */
265
232
  export declare function readConfigFile(file: string): Promise<{
266
- config: TaskConfig;
233
+ config: WayfinderConfig;
267
234
  warnings: string[];
268
235
  } | null>;
269
236
  /**
270
- * Write a configuration file: known keys in schema order, unknown keys after
271
- * them in the order they already had, two-space indent, trailing newline.
272
- * Parent directories are created.
273
- *
274
- * The order is fixed so that writing an unchanged document produces an
275
- * unchanged file. A config under version control should not show a diff
276
- * because a key moved.
237
+ * Write a configuration file atomically: a temporary file, then a rename, so
238
+ * a crash or two saves at once never leave a truncated file. Known keys come
239
+ * in schema order, unknown keys after them in the order they had, with a
240
+ * two-space indent and a trailing newline. A file with no `$schema` gets
241
+ * {@link CONFIG_SCHEMA_URL}. Parent directories are created.
277
242
  *
278
- * Accepts a raw record as well as a {@link TaskConfig}, so an edit can keep
279
- * unknown keys.
243
+ * Writing an unchanged document gives an unchanged file, so a config under
244
+ * version control shows no diff because a key moved. Accepts a raw record, so
245
+ * an edit can keep unknown keys.
280
246
  */
281
- export declare function writeConfigFile(file: string, config: TaskConfig | Record<string, unknown>): Promise<void>;
247
+ export declare function writeConfigFile(file: string, config: WayfinderConfig | Record<string, unknown>): Promise<void>;
282
248
  export interface LoadedConfig {
283
249
  /** Defaults, then user, then project, merged. The values a caller should use. */
284
- effective: TaskConfig;
250
+ effective: WayfinderConfig;
285
251
  /**
286
- * The layers as they were applied. `project` has already had a rejected
287
- * `allowExec: true` and any `trust` block removed, so it matches `effective`
288
- * and `sources`. Read the file itself with {@link readRawConfigFile} to see
289
- * what was written.
252
+ * The layers as they were applied. `project` has already had the keys a
253
+ * project may not set removed, so it matches `effective` and `sources`.
290
254
  */
291
255
  layers: {
292
- default: TaskConfig;
293
- user: TaskConfig | null;
294
- project: TaskConfig | null;
256
+ default: WayfinderConfig;
257
+ user: WayfinderConfig | null;
258
+ project: WayfinderConfig | null;
295
259
  };
296
- /**
297
- * Dotted key to the layer that supplied the winning value. Every leaf of
298
- * `effective` appears, so `way config list` can say where each value came
299
- * from when a setting is not what the user expected.
300
- */
260
+ /** The layers as their files say, validated but before any key was removed. */
261
+ files: {
262
+ user: WayfinderConfig | null;
263
+ project: WayfinderConfig | null;
264
+ };
265
+ /** Each key of {@link CONFIG_KEYS} to the layer that supplied its value. */
301
266
  sources: Map<string, ConfigLayer>;
302
267
  locations: ConfigLocations;
303
- /** Warnings from every layer: unknown keys, ignored project keys, old waypost names. */
268
+ /** Warnings from every layer: unknown keys, ignored project keys, an ignored env path. */
304
269
  warnings: string[];
305
270
  }
306
271
  /**
307
- * Load every layer and merge them. `env` and `home` are injectable for the same
308
- * reason {@link configLocations} takes them.
272
+ * Load every layer and merge them. `env` and `home` are injectable for the
273
+ * same reason {@link configLocations} takes them.
309
274
  */
310
275
  export declare function loadConfig(root: string, env?: Record<string, string | undefined>, home?: string): Promise<LoadedConfig>;
311
- /** The warning for a relative `WAYFINDER_CONFIG` that was ignored, or null. */
312
- export declare function envIgnoredWarning(locations: ConfigLocations): string | null;
313
- /** Read a dotted path — `"runners.order"`, `"allowExec"`. `undefined` when absent. */
276
+ /** One setting's effective value and where it came from. */
277
+ export interface SettingValue<T = unknown> {
278
+ /** The dotted key: `runners.order`. */
279
+ key: string;
280
+ value: T;
281
+ /** The layer that set it, or `default`. */
282
+ source: ConfigLayer;
283
+ /** The file that set it. Null for the default. */
284
+ file: string | null;
285
+ }
286
+ /**
287
+ * The settings every surface shows, read once. The terminal UI, the web view
288
+ * and `way config list` all take their values from {@link readSettings}, so
289
+ * they show the same answer.
290
+ */
291
+ export interface Settings {
292
+ /** The full load, for a caller that needs the layers. */
293
+ loaded: LoadedConfig;
294
+ /** Every key of {@link CONFIG_KEYS}, in order. */
295
+ settings: SettingValue[];
296
+ /** The configured `allowExec`. Execution also needs a trusted repository. */
297
+ allowExec: SettingValue<boolean>;
298
+ /** What the bare `way` command opens. */
299
+ open: SettingValue<OpenSurface>;
300
+ /** The web view's theme. */
301
+ theme: SettingValue<Theme>;
302
+ /** The runner display order. */
303
+ runnerOrder: SettingValue<string[]>;
304
+ /** Which agent skills the Skills group lists. */
305
+ skills: SettingValue<SkillsSetting>;
306
+ warnings: string[];
307
+ }
308
+ /**
309
+ * Read every layer for `root` and return each setting's effective value and
310
+ * source. Throws {@link ConfigError} for a broken file.
311
+ */
312
+ export declare function readSettings(root: string, env?: Record<string, string | undefined>, home?: string): Promise<Settings>;
313
+ /** A file layer a setting can be written to. */
314
+ export type WritableLayer = 'user' | 'project';
315
+ /** Where {@link writeSetting} and {@link removeSetting} write. */
316
+ export interface WriteTarget {
317
+ layer: WritableLayer;
318
+ /** The project root. Used for the project layer. */
319
+ root: string;
320
+ env?: Record<string, string | undefined>;
321
+ home?: string;
322
+ }
323
+ /**
324
+ * Write `value` at `key` in one layer's file, atomically, keeping every other
325
+ * key. Throws {@link ConfigError} with an empty `file` for an unknown key, a
326
+ * wrong value, or a key the project file may not hold (see
327
+ * {@link projectWriteRefusal}); throws one naming the file when the file is
328
+ * broken. Returns the file and the value as written, and warnings for unknown
329
+ * keys inside the value.
330
+ */
331
+ export declare function writeSetting(target: WriteTarget, key: string, value: unknown): Promise<{
332
+ file: string;
333
+ value: unknown;
334
+ warnings: string[];
335
+ }>;
336
+ /** Remove `key` from one layer's file. `removed: false` when it was not set there. */
337
+ export declare function removeSetting(target: WriteTarget, key: string): Promise<{
338
+ file: string;
339
+ removed: boolean;
340
+ }>;
341
+ /** Read a dotted path: `"runners.order"`, `"allowExec"`. `undefined` when absent. */
314
342
  export declare function getConfigValue(config: object, key: string): unknown;
315
343
  /**
316
344
  * Set a dotted path, returning a new document. The input is not changed.
317
345
  * Missing intermediate objects are created, so `set` works on an empty file.
318
346
  *
319
347
  * Throws {@link ConfigError} for an unknown key, a value of the wrong type, or
320
- * an existing intermediate value that is not an object, rather than writing a
321
- * file that will fail to load. Given a raw record, it returns a raw record with
322
- * its unknown keys untouched.
348
+ * an existing intermediate value that is not an object. Given a raw record, it
349
+ * returns a raw record with its unknown keys untouched.
323
350
  */
324
351
  export declare function setConfigValue<T extends object>(config: T, key: string, value: unknown): T;
325
352
  /**
326
- * Remove a dotted path, returning a new document. A container left empty by the
327
- * removal is removed too, so unsetting the last `runners.*` key does not leave
328
- * `"runners": {}` behind.
329
- *
330
- * Unlike `set`, any key may be unset, including one this version does not
331
- * know, so a stale setting can be removed.
353
+ * Remove a dotted path, returning a new document. A container left empty by
354
+ * the removal is removed too. Any key may be unset, including one this
355
+ * version does not know, so a stale setting can be removed.
332
356
  */
333
357
  export declare function unsetConfigValue<T extends object>(config: T, key: string): T;
334
358
  /**
335
- * Parse a value typed on a command line. It is parsed as JSON first, so
336
- * `true`, `3` and `["a","b"]` keep their types. A bare word that is not valid
337
- * JSON is kept as a string, so `moon` need not be typed as `"moon"`.
359
+ * Parse a value typed on a command line: JSON first, so `true` and
360
+ * `["a","b"]` keep their types, else the bare string.
338
361
  */
339
362
  export declare function parseConfigValue(raw: string): unknown;
363
+ /** The key a typed key names, or undefined when it names no setting. */
364
+ export declare function resolveConfigKey(key: string): string | undefined;
340
365
  /**
341
366
  * The {@link WayOptions} fields this configuration controls. Only keys the
342
367
  * config sets are present, so a caller spreads its own flags after it.
343
368
  */
344
- export declare function collectOptionsFromConfig(config: TaskConfig): Pick<WayOptions, 'exclude' | 'allowExec' | 'discovery' | 'excludePaths'>;
345
- /** `config.trust`, defaulted to the empty policy `@osdlc/trust-repo` expects. */
346
- export declare function trustPolicyFromConfig(config: TaskConfig): TrustPolicy;
369
+ export declare function collectOptionsFromConfig(config: WayfinderConfig): Pick<WayOptions, 'exclude' | 'allowExec' | 'discovery' | 'excludePaths'>;
347
370
  /**
348
- * Expand a `trust.paths` entry's leading `~` against `home`, then resolve
349
- * symlinks in the pattern's static prefix (the part before the first glob
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.
371
+ * `config.trust` as the policy `@osdlc/trust-repo` expects: the top-level
372
+ * rules, and `trust.tools` as its per-scope rules.
356
373
  */
357
- export declare function expandTrustPath(raw: string, home: string): Promise<string>;
374
+ export declare function trustPolicyFromConfig(config: WayfinderConfig): TrustPolicy;
358
375
  /**
359
- * The options every `@osdlc/trust-repo` gate call takes: {@link expandTrustPath}
360
- * against `home`, and the {@link originOwner} lookup that `trust.owners` needs.
361
- * Built in one place, so a call site cannot leave out `ownerOf` and silently
362
- * stop honouring `trust.owners`.
376
+ * The options every `@osdlc/trust-repo` gate call takes: `expandTrustPath`
377
+ * against `home`, and the git-backed `originOwner` lookup that `trust.owners`
378
+ * needs. Built in one place, so a call site cannot leave out `ownerOf`.
363
379
  */
364
380
  export declare function trustPolicyOptions(home: string): PolicyDecisionOptions;
365
381
  /**
366
382
  * Sort runner-keyed items for display: the ids named in `order` first, in that
367
- * order, then everything else alphabetically. Alphabetical rather than
368
- * registry order, so adding a tool does not reorder the list.
383
+ * order, then everything else alphabetically.
369
384
  */
370
385
  export declare function orderRunners<T extends {
371
386
  runner: string;