@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/xdg.d.ts
CHANGED
|
@@ -1,10 +1,82 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Where wayfinder keeps its files outside a repository. Every path comes from
|
|
3
|
+
* `@osdlc/tiered-dirs`, standalone tier `wayfinder`, `xdg` convention:
|
|
4
|
+
*
|
|
5
|
+
* | store | Linux and macOS | Windows |
|
|
6
|
+
* |---|---|---|
|
|
7
|
+
* | user config | `${XDG_CONFIG_HOME:-~/.config}/wayfinder/config.json` | `%APPDATA%\wayfinder\config.json` |
|
|
8
|
+
* | trust store | `${XDG_STATE_HOME:-~/.local/state}/wayfinder/trusted/` | `%LOCALAPPDATA%\state\wayfinder\trusted\` |
|
|
9
|
+
* | probe cache | `${XDG_CACHE_HOME:-~/.cache}/wayfinder/` | `%LOCALAPPDATA%\wayfinder\` |
|
|
10
|
+
*
|
|
11
|
+
* `WAYFINDER_ROOT` moves all of them under one directory, and
|
|
12
|
+
* `WAYFINDER_<HOME>_DIR` (`WAYFINDER_CONFIG_DIR`, `WAYFINDER_STATE_DIR`,
|
|
13
|
+
* `WAYFINDER_CACHE_DIR`) moves one. `WAYFINDER_CONVENTION` is not read: the
|
|
14
|
+
* convention is pinned, so the files stay where the docs say. A relative
|
|
15
|
+
* `XDG_*` value is ignored. `home` is always injected, so a test never reads
|
|
16
|
+
* or writes the real home directory.
|
|
4
17
|
*/
|
|
18
|
+
import { TieredDirs, type EnvVars } from '@osdlc/tiered-dirs';
|
|
19
|
+
/** The variables that move wayfinder's directories: `WAYFINDER_ROOT` and `WAYFINDER_<HOME>_DIR`. */
|
|
20
|
+
export declare const DIR_ENV_VARS: EnvVars;
|
|
21
|
+
/** The user config's file name inside the config directory. */
|
|
22
|
+
export declare const USER_CONFIG_FILENAME = "config.json";
|
|
23
|
+
/** wayfinder's directories. */
|
|
24
|
+
export interface AppDirs {
|
|
25
|
+
/** `<config>/wayfinder`: holds the user config file. */
|
|
26
|
+
config: string;
|
|
27
|
+
/** `<state>/wayfinder`: holds the trust store. */
|
|
28
|
+
state: string;
|
|
29
|
+
/** `<cache>/wayfinder`: the probe cache. */
|
|
30
|
+
cache: string;
|
|
31
|
+
/** `<config>/wayfinder/config.json`, before `WAYFINDER_CONFIG` is applied. */
|
|
32
|
+
userConfig: string;
|
|
33
|
+
/** `<state>/wayfinder/trusted`. */
|
|
34
|
+
trustStore: string;
|
|
35
|
+
/** The base directories the paths above are under. `way clean` prunes up to them. */
|
|
36
|
+
bases: {
|
|
37
|
+
config: string;
|
|
38
|
+
state: string;
|
|
39
|
+
cache: string;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** Inputs for {@link appDirs}. */
|
|
43
|
+
export interface AppDirsOptions {
|
|
44
|
+
/** Defaults to `process.env`. */
|
|
45
|
+
env?: Record<string, string | undefined>;
|
|
46
|
+
/** The home directory. Required, so nothing resolves a real home by accident. */
|
|
47
|
+
home: string;
|
|
48
|
+
/** Defaults to `process.platform`. */
|
|
49
|
+
platform?: string;
|
|
50
|
+
}
|
|
5
51
|
/**
|
|
6
|
-
*
|
|
52
|
+
* The `TieredDirs` wayfinder's paths come from, vendor `wayfinder`, under
|
|
53
|
+
* `convention` (default `xdg`). Throws `TieredDirsError` when an override
|
|
54
|
+
* variable holds a relative path.
|
|
55
|
+
*/
|
|
56
|
+
export declare function appTieredDirs(opts: AppDirsOptions & {
|
|
57
|
+
convention?: 'xdg' | 'native';
|
|
58
|
+
}): TieredDirs;
|
|
59
|
+
/**
|
|
60
|
+
* wayfinder's directories. Throws `TieredDirsError` when an override
|
|
61
|
+
* variable holds a relative path.
|
|
62
|
+
*/
|
|
63
|
+
export declare function appDirs(opts: AppDirsOptions): AppDirs;
|
|
64
|
+
/**
|
|
65
|
+
* The base directories releases before 0.8 used, on every platform:
|
|
66
|
+
* `$XDG_CONFIG_HOME`, `$XDG_STATE_HOME` and `$XDG_CACHE_HOME`, else
|
|
67
|
+
* `~/.config`, `~/.local/state` and `~/.cache`. The `WAYFINDER_*` variables
|
|
68
|
+
* did not exist then and are not read. Only `way clean --legacy` and the
|
|
69
|
+
* Windows move warning use these.
|
|
70
|
+
*/
|
|
71
|
+
export declare function pre08Bases(env: Record<string, string | undefined>, home: string): {
|
|
72
|
+
config: string;
|
|
73
|
+
state: string;
|
|
74
|
+
cache: string;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Expand a leading `~` against `home`, and `~\` too on Windows; anything
|
|
78
|
+
* else is returned unchanged.
|
|
7
79
|
* direnv, `.env` loaders and CI YAML pass a literal tilde through, and
|
|
8
80
|
* `<cwd>/~/x` would be a silent wrong answer.
|
|
9
81
|
*/
|
|
10
|
-
export declare function expandTilde(path: string, home: string): string;
|
|
82
|
+
export declare function expandTilde(path: string, home: string, platform?: NodeJS.Platform): string;
|
package/dist/xdg.js
CHANGED
|
@@ -1,17 +1,89 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Where wayfinder keeps its files outside a repository. Every path comes from
|
|
3
|
+
* `@osdlc/tiered-dirs`, standalone tier `wayfinder`, `xdg` convention:
|
|
4
|
+
*
|
|
5
|
+
* | store | Linux and macOS | Windows |
|
|
6
|
+
* |---|---|---|
|
|
7
|
+
* | user config | `${XDG_CONFIG_HOME:-~/.config}/wayfinder/config.json` | `%APPDATA%\wayfinder\config.json` |
|
|
8
|
+
* | trust store | `${XDG_STATE_HOME:-~/.local/state}/wayfinder/trusted/` | `%LOCALAPPDATA%\state\wayfinder\trusted\` |
|
|
9
|
+
* | probe cache | `${XDG_CACHE_HOME:-~/.cache}/wayfinder/` | `%LOCALAPPDATA%\wayfinder\` |
|
|
10
|
+
*
|
|
11
|
+
* `WAYFINDER_ROOT` moves all of them under one directory, and
|
|
12
|
+
* `WAYFINDER_<HOME>_DIR` (`WAYFINDER_CONFIG_DIR`, `WAYFINDER_STATE_DIR`,
|
|
13
|
+
* `WAYFINDER_CACHE_DIR`) moves one. `WAYFINDER_CONVENTION` is not read: the
|
|
14
|
+
* convention is pinned, so the files stay where the docs say. A relative
|
|
15
|
+
* `XDG_*` value is ignored. `home` is always injected, so a test never reads
|
|
16
|
+
* or writes the real home directory.
|
|
4
17
|
*/
|
|
5
18
|
import { join } from 'node:path';
|
|
19
|
+
import { envVars, systemBaseDirs, TieredDirs } from '@osdlc/tiered-dirs';
|
|
20
|
+
import { xdgHome } from '@osdlc/trust-repo';
|
|
21
|
+
import { APP } from "./app.js";
|
|
22
|
+
/** The variables that move wayfinder's directories: `WAYFINDER_ROOT` and `WAYFINDER_<HOME>_DIR`. */
|
|
23
|
+
export const DIR_ENV_VARS = envVars(APP.toUpperCase());
|
|
24
|
+
/** The directory under the state directory that holds the trust markers. */
|
|
25
|
+
const TRUST_DIR = 'trusted';
|
|
26
|
+
/** The user config's file name inside the config directory. */
|
|
27
|
+
export const USER_CONFIG_FILENAME = 'config.json';
|
|
6
28
|
/**
|
|
7
|
-
*
|
|
29
|
+
* The `TieredDirs` wayfinder's paths come from, vendor `wayfinder`, under
|
|
30
|
+
* `convention` (default `xdg`). Throws `TieredDirsError` when an override
|
|
31
|
+
* variable holds a relative path.
|
|
32
|
+
*/
|
|
33
|
+
export function appTieredDirs(opts) {
|
|
34
|
+
const bases = systemBaseDirs(DIR_ENV_VARS, {
|
|
35
|
+
convention: opts.convention ?? 'xdg',
|
|
36
|
+
conventionFromEnv: false,
|
|
37
|
+
env: opts.env ?? process.env,
|
|
38
|
+
home: opts.home,
|
|
39
|
+
...(opts.platform !== undefined ? { platform: opts.platform } : {}),
|
|
40
|
+
});
|
|
41
|
+
return new TieredDirs(APP, bases);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* wayfinder's directories. Throws `TieredDirsError` when an override
|
|
45
|
+
* variable holds a relative path.
|
|
46
|
+
*/
|
|
47
|
+
export function appDirs(opts) {
|
|
48
|
+
const dirs = appTieredDirs(opts);
|
|
49
|
+
const tier = dirs.standalone(APP);
|
|
50
|
+
const config = tier.config().path;
|
|
51
|
+
const state = tier.state().path;
|
|
52
|
+
const { bases } = dirs;
|
|
53
|
+
return {
|
|
54
|
+
config,
|
|
55
|
+
state,
|
|
56
|
+
cache: tier.cache().path,
|
|
57
|
+
userConfig: join(config, USER_CONFIG_FILENAME),
|
|
58
|
+
trustStore: join(state, TRUST_DIR),
|
|
59
|
+
bases: { config: bases.config, state: bases.state, cache: bases.cache },
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The base directories releases before 0.8 used, on every platform:
|
|
64
|
+
* `$XDG_CONFIG_HOME`, `$XDG_STATE_HOME` and `$XDG_CACHE_HOME`, else
|
|
65
|
+
* `~/.config`, `~/.local/state` and `~/.cache`. The `WAYFINDER_*` variables
|
|
66
|
+
* did not exist then and are not read. Only `way clean --legacy` and the
|
|
67
|
+
* Windows move warning use these.
|
|
68
|
+
*/
|
|
69
|
+
export function pre08Bases(env, home) {
|
|
70
|
+
return {
|
|
71
|
+
config: xdgHome(env, home, 'XDG_CONFIG_HOME', '.config'),
|
|
72
|
+
state: xdgHome(env, home, 'XDG_STATE_HOME', '.local', 'state'),
|
|
73
|
+
cache: xdgHome(env, home, 'XDG_CACHE_HOME', '.cache'),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Expand a leading `~` against `home`, and `~\` too on Windows; anything
|
|
78
|
+
* else is returned unchanged.
|
|
8
79
|
* direnv, `.env` loaders and CI YAML pass a literal tilde through, and
|
|
9
80
|
* `<cwd>/~/x` would be a silent wrong answer.
|
|
10
81
|
*/
|
|
11
|
-
export function expandTilde(path, home) {
|
|
82
|
+
export function expandTilde(path, home, platform = process.platform) {
|
|
12
83
|
if (path === '~')
|
|
13
84
|
return home;
|
|
14
|
-
if (path.startsWith('~/'))
|
|
85
|
+
if (path.startsWith('~/') || (platform === 'win32' && path.startsWith('~\\'))) {
|
|
15
86
|
return join(home, path.slice(2));
|
|
87
|
+
}
|
|
16
88
|
return path;
|
|
17
89
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osdlc/wayfinder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Browse and run every task in a repository from one list: a terminal UI where Enter runs the selected task, a live web view, and JSON for scripts. Tasks, installs, tool trust and git hooks come from @osdlc/system-model.",
|
|
5
5
|
"license": "MIT OR Apache-2.0",
|
|
6
6
|
"author": "sksizer",
|
|
@@ -25,12 +25,24 @@
|
|
|
25
25
|
},
|
|
26
26
|
"type": "module",
|
|
27
27
|
"sideEffects": false,
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./schema": {
|
|
34
|
+
"types": "./dist/schema.d.ts",
|
|
35
|
+
"default": "./dist/schema.js"
|
|
36
|
+
},
|
|
37
|
+
"./package.json": "./package.json"
|
|
38
|
+
},
|
|
28
39
|
"bin": {
|
|
29
40
|
"way": "./bin/way.js"
|
|
30
41
|
},
|
|
31
42
|
"files": [
|
|
32
43
|
"dist/",
|
|
33
44
|
"bin/",
|
|
45
|
+
"schema/",
|
|
34
46
|
"README.md",
|
|
35
47
|
"CHANGELOG.md",
|
|
36
48
|
"LICENSE-MIT",
|
|
@@ -42,12 +54,17 @@
|
|
|
42
54
|
"node": "^22.22.2 || ^24.15.0 || >=26.0.0"
|
|
43
55
|
},
|
|
44
56
|
"dependencies": {
|
|
45
|
-
"
|
|
46
|
-
"@osdlc/
|
|
47
|
-
"@osdlc/command-seam": "^0.
|
|
48
|
-
"@osdlc/
|
|
49
|
-
"@osdlc/
|
|
50
|
-
"@osdlc/
|
|
57
|
+
"zod": "4.4.3",
|
|
58
|
+
"@osdlc/cli-tool": "^0.9.0",
|
|
59
|
+
"@osdlc/command-seam": "^0.12.0",
|
|
60
|
+
"@osdlc/config-layers": "^0.7.3",
|
|
61
|
+
"@osdlc/detect-harness": "^0.5.0",
|
|
62
|
+
"@osdlc/etag-write": "^0.2.1",
|
|
63
|
+
"@osdlc/system-model": "^0.5.0",
|
|
64
|
+
"@osdlc/trust-repo": "^0.4.0",
|
|
65
|
+
"@osdlc/typed-git": "^0.8.1",
|
|
66
|
+
"@osdlc/tiered-dirs": "^0.4.0",
|
|
67
|
+
"@osdlc/ux": "^0.1.0"
|
|
51
68
|
},
|
|
52
69
|
"devDependencies": {
|
|
53
70
|
"@types/node": "^26.1.0",
|
|
@@ -59,12 +76,14 @@
|
|
|
59
76
|
"typescript": "~6.0.3",
|
|
60
77
|
"vitest": "^5.0.5",
|
|
61
78
|
"@osdlc/prettier-config": "^0.3.1",
|
|
62
|
-
"@osdlc/tsconfig": "^0.4.1"
|
|
79
|
+
"@osdlc/tsconfig": "^0.4.1",
|
|
80
|
+
"@osdlc/color": "^1.1.0"
|
|
63
81
|
},
|
|
64
82
|
"scripts": {
|
|
65
|
-
"build": "tsc -p tsconfig.build.json && node scripts/build-web.mjs",
|
|
83
|
+
"build": "node scripts/write-document-schemas.ts && tsc -p tsconfig.build.json && node scripts/build-web.mjs && node scripts/write-config-schema.mjs",
|
|
66
84
|
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
67
85
|
"test": "vitest run",
|
|
86
|
+
"test:e2e": "vitest run tests/e2e",
|
|
68
87
|
"smoke": "node tests/smoke.mjs",
|
|
69
88
|
"coverage": "vitest run --coverage",
|
|
70
89
|
"format": "prettier --write .",
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://unpkg.com/@osdlc/wayfinder@0.8/schema/config.json",
|
|
4
|
+
"title": "wayfinder configuration",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"$schema": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The JSON Schema this file follows. Ignored by wayfinder."
|
|
10
|
+
},
|
|
11
|
+
"runners": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"properties": {
|
|
14
|
+
"disabled": {
|
|
15
|
+
"type": "array",
|
|
16
|
+
"items": {
|
|
17
|
+
"type": "string"
|
|
18
|
+
},
|
|
19
|
+
"description": "Runner ids to skip entirely."
|
|
20
|
+
},
|
|
21
|
+
"order": {
|
|
22
|
+
"type": "array",
|
|
23
|
+
"items": {
|
|
24
|
+
"type": "string"
|
|
25
|
+
},
|
|
26
|
+
"description": "Preferred display order. Runners not named follow alphabetically."
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"description": "Which runners are read, and in what order they are shown."
|
|
30
|
+
},
|
|
31
|
+
"allowExec": {
|
|
32
|
+
"type": "boolean",
|
|
33
|
+
"description": "Whether runners that must run a subprocess may be read. Execution also needs a trusted repository. A project file may only set false."
|
|
34
|
+
},
|
|
35
|
+
"discovery": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"enum": [
|
|
38
|
+
"git",
|
|
39
|
+
"walk",
|
|
40
|
+
"auto"
|
|
41
|
+
],
|
|
42
|
+
"description": "How directories are found: git-tracked files, a directory walk, or auto."
|
|
43
|
+
},
|
|
44
|
+
"excludePaths": {
|
|
45
|
+
"type": "array",
|
|
46
|
+
"items": {
|
|
47
|
+
"type": "string"
|
|
48
|
+
},
|
|
49
|
+
"description": "Paths to leave out of discovery. A bare name matches any path segment; a value with a slash matches a path from the root and the tree beneath it."
|
|
50
|
+
},
|
|
51
|
+
"trust": {
|
|
52
|
+
"type": "object",
|
|
53
|
+
"properties": {
|
|
54
|
+
"paths": {
|
|
55
|
+
"type": "array",
|
|
56
|
+
"items": {
|
|
57
|
+
"type": "string"
|
|
58
|
+
},
|
|
59
|
+
"description": "Glob patterns over the repository root, symlinks resolved: *, ?, ** and a trailing /** for descendants only. A leading ~ is your home."
|
|
60
|
+
},
|
|
61
|
+
"owners": {
|
|
62
|
+
"type": "array",
|
|
63
|
+
"items": {
|
|
64
|
+
"type": "string"
|
|
65
|
+
},
|
|
66
|
+
"description": "Origin remote owners, as host/owner, or a bare owner for github.com/owner. Case-insensitive."
|
|
67
|
+
},
|
|
68
|
+
"tools": {
|
|
69
|
+
"type": "object",
|
|
70
|
+
"propertyNames": {
|
|
71
|
+
"type": "string",
|
|
72
|
+
"minLength": 1
|
|
73
|
+
},
|
|
74
|
+
"additionalProperties": {
|
|
75
|
+
"type": "object",
|
|
76
|
+
"properties": {
|
|
77
|
+
"paths": {
|
|
78
|
+
"type": "array",
|
|
79
|
+
"items": {
|
|
80
|
+
"type": "string"
|
|
81
|
+
},
|
|
82
|
+
"description": "Glob patterns over the repository root, symlinks resolved: *, ?, ** and a trailing /** for descendants only. A leading ~ is your home."
|
|
83
|
+
},
|
|
84
|
+
"owners": {
|
|
85
|
+
"type": "array",
|
|
86
|
+
"items": {
|
|
87
|
+
"type": "string"
|
|
88
|
+
},
|
|
89
|
+
"description": "Origin remote owners, as host/owner, or a bare owner for github.com/owner. Case-insensitive."
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"description": "Rules that trust one tool each, keyed by tool id. They are checked after the top-level rules."
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"description": "Repositories trusted without a marker. User config only: a project file cannot set it."
|
|
97
|
+
},
|
|
98
|
+
"tools": {
|
|
99
|
+
"type": "array",
|
|
100
|
+
"items": {
|
|
101
|
+
"type": "string"
|
|
102
|
+
},
|
|
103
|
+
"description": "Modules that export extra tools. A relative path resolves against the file that names it."
|
|
104
|
+
},
|
|
105
|
+
"open": {
|
|
106
|
+
"type": "string",
|
|
107
|
+
"enum": [
|
|
108
|
+
"tui",
|
|
109
|
+
"web"
|
|
110
|
+
],
|
|
111
|
+
"description": "What the bare way command opens: the terminal UI or the web view. User config only."
|
|
112
|
+
},
|
|
113
|
+
"theme": {
|
|
114
|
+
"type": "string",
|
|
115
|
+
"enum": [
|
|
116
|
+
"system",
|
|
117
|
+
"light",
|
|
118
|
+
"dark"
|
|
119
|
+
],
|
|
120
|
+
"description": "The web view theme. User config only."
|
|
121
|
+
},
|
|
122
|
+
"skills": {
|
|
123
|
+
"type": "string",
|
|
124
|
+
"enum": [
|
|
125
|
+
"project",
|
|
126
|
+
"all",
|
|
127
|
+
"off"
|
|
128
|
+
],
|
|
129
|
+
"description": "Which agent skills the Skills group lists: the repository's (project), those and your own and your plugins' (all), or none (off). User config only."
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"description": "wayfinder configuration: wayfinder.config.json or the user config file."
|
|
133
|
+
}
|
package/dist/http.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A fetch-style server on `node:http`: the handler takes a web `Request` and
|
|
3
|
-
* returns a `Response`, and the body streams out chunk by chunk. Runs under
|
|
4
|
-
* Node and Bun.
|
|
5
|
-
*/
|
|
6
|
-
/** A running server. */
|
|
7
|
-
export interface FetchServer {
|
|
8
|
-
readonly port: number;
|
|
9
|
-
/** Stop accepting, let open responses finish, then resolve. */
|
|
10
|
-
stop(): Promise<void>;
|
|
11
|
-
}
|
|
12
|
-
export type FetchHandler = (req: Request, server: FetchServer) => Response | Promise<Response>;
|
|
13
|
-
export interface ServeFetchOptions {
|
|
14
|
-
hostname: string;
|
|
15
|
-
/** 0 lets the OS pick. */
|
|
16
|
-
port: number;
|
|
17
|
-
fetch: FetchHandler;
|
|
18
|
-
}
|
|
19
|
-
/** The largest request body read; every route takes a small JSON body. */
|
|
20
|
-
export declare const MAX_BODY_BYTES: number;
|
|
21
|
-
/** Bind `hostname:port` and answer every request with `fetch`. */
|
|
22
|
-
export declare function serveFetch(options: ServeFetchOptions): Promise<FetchServer>;
|
package/dist/http.js
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A fetch-style server on `node:http`: the handler takes a web `Request` and
|
|
3
|
-
* returns a `Response`, and the body streams out chunk by chunk. Runs under
|
|
4
|
-
* Node and Bun.
|
|
5
|
-
*/
|
|
6
|
-
import { createServer } from 'node:http';
|
|
7
|
-
/** How long `stop` waits for busy connections before closing them. */
|
|
8
|
-
const STOP_GRACE_MS = 1000;
|
|
9
|
-
function toRequest(req, origin, body) {
|
|
10
|
-
const headers = new Headers();
|
|
11
|
-
for (const [name, value] of Object.entries(req.headers)) {
|
|
12
|
-
if (value === undefined)
|
|
13
|
-
continue;
|
|
14
|
-
for (const v of Array.isArray(value) ? value : [value])
|
|
15
|
-
headers.append(name, v);
|
|
16
|
-
}
|
|
17
|
-
return new Request(new URL(req.url ?? '/', origin), {
|
|
18
|
-
method: req.method ?? 'GET',
|
|
19
|
-
headers,
|
|
20
|
-
...(body !== null ? { body: new Uint8Array(body) } : {}),
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
/** The largest request body read; every route takes a small JSON body. */
|
|
24
|
-
export const MAX_BODY_BYTES = 1024 * 1024;
|
|
25
|
-
class BodyTooLarge extends Error {
|
|
26
|
-
}
|
|
27
|
-
function readBody(req) {
|
|
28
|
-
if (req.method === 'GET' || req.method === 'HEAD')
|
|
29
|
-
return Promise.resolve(null);
|
|
30
|
-
return new Promise((resolve, reject) => {
|
|
31
|
-
const chunks = [];
|
|
32
|
-
let size = 0;
|
|
33
|
-
req.on('data', (c) => {
|
|
34
|
-
size += c.length;
|
|
35
|
-
if (size > MAX_BODY_BYTES) {
|
|
36
|
-
req.removeAllListeners('data');
|
|
37
|
-
reject(new BodyTooLarge());
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
chunks.push(c);
|
|
41
|
-
});
|
|
42
|
-
req.on('end', () => resolve(Buffer.concat(chunks)));
|
|
43
|
-
req.on('error', reject);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Write `response` out. Each chunk is written, and drained when the socket is
|
|
48
|
-
* full, before the next is read. A client that disconnects cancels the body.
|
|
49
|
-
*/
|
|
50
|
-
async function writeResponse(res, response) {
|
|
51
|
-
const headers = {};
|
|
52
|
-
response.headers.forEach((value, name) => {
|
|
53
|
-
headers[name] = value;
|
|
54
|
-
});
|
|
55
|
-
res.writeHead(response.status, headers);
|
|
56
|
-
if (response.body === null) {
|
|
57
|
-
res.end();
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
const reader = response.body.getReader();
|
|
61
|
-
let closed = false;
|
|
62
|
-
let wake = () => { };
|
|
63
|
-
const onClose = () => {
|
|
64
|
-
if (res.writableFinished)
|
|
65
|
-
return;
|
|
66
|
-
closed = true;
|
|
67
|
-
wake();
|
|
68
|
-
void reader.cancel().catch(() => { });
|
|
69
|
-
};
|
|
70
|
-
res.once('close', onClose);
|
|
71
|
-
try {
|
|
72
|
-
for (;;) {
|
|
73
|
-
const { done, value } = await reader.read();
|
|
74
|
-
if (done || closed)
|
|
75
|
-
break;
|
|
76
|
-
if (!res.write(value)) {
|
|
77
|
-
await new Promise((resolve) => {
|
|
78
|
-
wake = resolve;
|
|
79
|
-
res.once('drain', resolve);
|
|
80
|
-
});
|
|
81
|
-
res.off('drain', wake);
|
|
82
|
-
if (closed)
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
finally {
|
|
88
|
-
res.off('close', onClose);
|
|
89
|
-
}
|
|
90
|
-
if (!closed)
|
|
91
|
-
res.end();
|
|
92
|
-
}
|
|
93
|
-
/** Bind `hostname:port` and answer every request with `fetch`. */
|
|
94
|
-
export function serveFetch(options) {
|
|
95
|
-
let handle;
|
|
96
|
-
let stopping = false;
|
|
97
|
-
const server = createServer((req, res) => {
|
|
98
|
-
// A response that finishes while stopping leaves an idle keep-alive
|
|
99
|
-
// connection that would hold `close` open.
|
|
100
|
-
res.on('finish', () => {
|
|
101
|
-
if (stopping)
|
|
102
|
-
setImmediate(() => server.closeIdleConnections());
|
|
103
|
-
});
|
|
104
|
-
void (async () => {
|
|
105
|
-
try {
|
|
106
|
-
const body = await readBody(req);
|
|
107
|
-
const origin = `http://${req.headers.host ?? `${options.hostname}:${handle.port}`}`;
|
|
108
|
-
await writeResponse(res, await options.fetch(toRequest(req, origin, body), handle));
|
|
109
|
-
}
|
|
110
|
-
catch (err) {
|
|
111
|
-
if (res.headersSent) {
|
|
112
|
-
// A body is part-sent under a success status: cut it off rather
|
|
113
|
-
// than append an error to it.
|
|
114
|
-
res.destroy();
|
|
115
|
-
}
|
|
116
|
-
else if (err instanceof BodyTooLarge) {
|
|
117
|
-
res.writeHead(413, { 'content-type': 'text/plain', connection: 'close' });
|
|
118
|
-
res.end('request body too large');
|
|
119
|
-
// Stop reading the rest once the answer is out.
|
|
120
|
-
res.once('finish', () => req.destroy());
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
res.writeHead(500, { 'content-type': 'text/plain' });
|
|
124
|
-
res.end(err instanceof Error ? err.message : String(err));
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
})();
|
|
128
|
-
});
|
|
129
|
-
return new Promise((resolve, reject) => {
|
|
130
|
-
server.once('error', reject);
|
|
131
|
-
server.listen(options.port, options.hostname, () => {
|
|
132
|
-
server.off('error', reject);
|
|
133
|
-
const port = server.address().port;
|
|
134
|
-
handle = {
|
|
135
|
-
port,
|
|
136
|
-
stop: () => new Promise((done) => {
|
|
137
|
-
stopping = true;
|
|
138
|
-
const force = setTimeout(() => server.closeAllConnections(), STOP_GRACE_MS);
|
|
139
|
-
server.close(() => {
|
|
140
|
-
clearTimeout(force);
|
|
141
|
-
done();
|
|
142
|
-
});
|
|
143
|
-
server.closeIdleConnections();
|
|
144
|
-
}),
|
|
145
|
-
};
|
|
146
|
-
resolve(handle);
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
}
|
package/dist/origin-owner.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The git-backed `ownerOf` handed to `@osdlc/trust-repo`, which knows no git.
|
|
3
|
-
* Without it `trust.owners` never matches.
|
|
4
|
-
*/
|
|
5
|
-
import { type CommandRunner } from '@osdlc/command-seam';
|
|
6
|
-
/**
|
|
7
|
-
* `root`'s `origin` remote host and owner as `host/owner`
|
|
8
|
-
* (`github.com/acme`), or null when there is none we can read. The host is
|
|
9
|
-
* part of the answer because the same owner name on another host is another
|
|
10
|
-
* account.
|
|
11
|
-
* Git runs in `root` with the caller's git location and config variables
|
|
12
|
-
* removed, so they cannot point it at another repository. Git still searches
|
|
13
|
-
* upward from `root`, so a directory without its own `.git` inside a
|
|
14
|
-
* repository gets that repository's owner. A remote that is neither a URL nor
|
|
15
|
-
* scp-style is a local path (`owner/repo` is one) and has no owner. A host
|
|
16
|
-
* hosted-git-info does not know (a self-hosted server) has no owner either.
|
|
17
|
-
* `git` is for tests; it defaults to the real binary.
|
|
18
|
-
*/
|
|
19
|
-
export declare function originOwner(root: string, git?: CommandRunner): string | null;
|
package/dist/origin-owner.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The git-backed `ownerOf` handed to `@osdlc/trust-repo`, which knows no git.
|
|
3
|
-
* Without it `trust.owners` never matches.
|
|
4
|
-
*/
|
|
5
|
-
import { spawnRunner } from '@osdlc/command-seam';
|
|
6
|
-
import { Git, parseGitUrl } from '@osdlc/typed-git';
|
|
7
|
-
/**
|
|
8
|
-
* `git` with `core.fsmonitor` off. The lookup runs before the repository is
|
|
9
|
-
* trusted, and `.git/config` belongs to whoever made the directory.
|
|
10
|
-
* `remote get-url` does not run fsmonitor today; the flag keeps it that way.
|
|
11
|
-
*/
|
|
12
|
-
function safeGit(git) {
|
|
13
|
-
return {
|
|
14
|
-
binary: 'git',
|
|
15
|
-
run: (argv, opts) => git.run(['-c', 'core.fsmonitor=false', ...argv], opts),
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Git variables the caller's environment must not apply to the owner lookup:
|
|
20
|
-
* they point git at another repository or add config that rewrites the
|
|
21
|
-
* remote. Git itself exports `GIT_DIR`, `GIT_INDEX_FILE`, `GIT_COMMON_DIR`
|
|
22
|
-
* and `GIT_CONFIG_PARAMETERS` (from `-c`) to hooks and aliases, so they leak
|
|
23
|
-
* into a tool by accident. `GIT_CONFIG_GLOBAL`, `GIT_CONFIG_SYSTEM` and
|
|
24
|
-
* `GIT_CONFIG_NOSYSTEM` are kept on purpose: they are deliberate user setup,
|
|
25
|
-
* like `~/.gitconfig`, whose `insteadOf` rules still apply.
|
|
26
|
-
*/
|
|
27
|
-
const GIT_LOCATION_VARS = ['GIT_DIR', 'GIT_WORK_TREE', 'GIT_INDEX_FILE', 'GIT_COMMON_DIR'];
|
|
28
|
-
const GIT_CONFIG_VAR = /^GIT_CONFIG(?:$|_COUNT$|_PARAMETERS$|_KEY_\d+$|_VALUE_\d+$)/;
|
|
29
|
-
/**
|
|
30
|
-
* Run `fn` with the git variables listed above removed from `process.env`,
|
|
31
|
-
* then put them back. The typed git client's `env` option is add-only, and an
|
|
32
|
-
* empty `GIT_DIR` is an error, so the variables are removed around one call.
|
|
33
|
-
* `fn` must be synchronous: the process environment is shared, so an await
|
|
34
|
-
* inside would let other code see the change.
|
|
35
|
-
*/
|
|
36
|
-
function withoutGitOverrides(fn) {
|
|
37
|
-
const saved = new Map();
|
|
38
|
-
for (const [name, value] of Object.entries(process.env)) {
|
|
39
|
-
if (value === undefined)
|
|
40
|
-
continue;
|
|
41
|
-
if (GIT_LOCATION_VARS.includes(name) || GIT_CONFIG_VAR.test(name))
|
|
42
|
-
saved.set(name, value);
|
|
43
|
-
}
|
|
44
|
-
for (const name of saved.keys())
|
|
45
|
-
delete process.env[name];
|
|
46
|
-
try {
|
|
47
|
-
return fn();
|
|
48
|
-
}
|
|
49
|
-
finally {
|
|
50
|
-
for (const [name, value] of saved)
|
|
51
|
-
process.env[name] = value;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
/** A remote git reads as a URL (`scheme://...`) or as scp-style (`[user@]host:path`). */
|
|
55
|
-
const URL_REMOTE = /^[a-z][a-z0-9+.-]*:\/\//i;
|
|
56
|
-
const SCP_REMOTE = /^(?:[^@/:\s]+@)?[^@/:\s]+:(?!\/\/)/;
|
|
57
|
-
/**
|
|
58
|
-
* hosted-git-info shortcuts (`github:owner/repo`). Git reads these as scp-style
|
|
59
|
-
* ssh to a host called `github`, so they have no owner here.
|
|
60
|
-
*/
|
|
61
|
-
const SHORTCUT_REMOTE = /^(?:github|gitlab|bitbucket|gist|sourcehut):/;
|
|
62
|
-
/**
|
|
63
|
-
* `root`'s `origin` remote host and owner as `host/owner`
|
|
64
|
-
* (`github.com/acme`), or null when there is none we can read. The host is
|
|
65
|
-
* part of the answer because the same owner name on another host is another
|
|
66
|
-
* account.
|
|
67
|
-
* Git runs in `root` with the caller's git location and config variables
|
|
68
|
-
* removed, so they cannot point it at another repository. Git still searches
|
|
69
|
-
* upward from `root`, so a directory without its own `.git` inside a
|
|
70
|
-
* repository gets that repository's owner. A remote that is neither a URL nor
|
|
71
|
-
* scp-style is a local path (`owner/repo` is one) and has no owner. A host
|
|
72
|
-
* hosted-git-info does not know (a self-hosted server) has no owner either.
|
|
73
|
-
* `git` is for tests; it defaults to the real binary.
|
|
74
|
-
*/
|
|
75
|
-
export function originOwner(root, git = spawnRunner('git', { absolutePathOnly: true })) {
|
|
76
|
-
const res = withoutGitOverrides(() => new Git(root, { runner: safeGit(git) }).try.remoteGetUrl('origin'));
|
|
77
|
-
if (!res.ok || res.value === null)
|
|
78
|
-
return null;
|
|
79
|
-
if (SHORTCUT_REMOTE.test(res.value))
|
|
80
|
-
return null;
|
|
81
|
-
if (!URL_REMOTE.test(res.value) && !SCP_REMOTE.test(res.value))
|
|
82
|
-
return null;
|
|
83
|
-
const info = parseGitUrl(res.value);
|
|
84
|
-
return info?.user && info.project ? `${info.domain}/${info.user}` : null;
|
|
85
|
-
}
|