@osdlc/wayfinder 0.7.4 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/CHANGELOG.md +214 -0
  2. package/CONTRIBUTING.md +6 -0
  3. package/README.md +295 -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 +30 -3
  14. package/dist/catalog.js +87 -11
  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 +151 -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 +208 -0
  24. package/dist/commands/list.js +127 -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 +271 -257
  36. package/dist/config.js +610 -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 +262 -0
  46. package/dist/core/session.js +589 -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 +432 -0
  56. package/dist/documents.js +163 -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 +112 -0
  62. package/dist/index.js +58 -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 +51 -0
  74. package/dist/serve/catalog-share.js +116 -0
  75. package/dist/serve/index.d.ts +98 -0
  76. package/dist/serve/index.js +251 -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 +180 -0
  92. package/dist/tui/app.js +1278 -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 +89 -0
  106. package/dist/vocabulary.js +153 -0
  107. package/dist/web/main.js +1965 -568
  108. package/dist/web/page.html +39 -33
  109. package/dist/web/styles.css +457 -329
  110. package/dist/xdg.d.ts +76 -4
  111. package/dist/xdg.js +77 -5
  112. package/package.json +28 -9
  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
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Agent skills as catalog rows: the Skills group. A skill is not a task. It
3
+ * has no command line; an agent runs it when a person types `/<name>`. So
4
+ * the run action copies {@link SkillRow.invoke} and nothing is spawned.
5
+ *
6
+ * Skill names, descriptions and hints come from files in the repository or
7
+ * the user's config. Filter them like any repository text before printing.
8
+ *
9
+ * Browser-safe: it imports only the matcher, so the page can use it.
10
+ */
11
+ import { matchEntry, terms as splitTerms } from '@osdlc/system-model/match';
12
+ /** Which skills a catalog lists: the `skills` setting. */
13
+ export const SKILLS_SETTING_VALUES = ['project', 'all', 'off'];
14
+ /** The text a surface shows for a skill: `/review [pr-number]`. */
15
+ export function skillLine(skill) {
16
+ return skill.argumentHint === null ? skill.invoke : `${skill.invoke} ${skill.argumentHint}`;
17
+ }
18
+ /** Whether `skill` passes the parts of `filter` a skill has. */
19
+ function keepsSkill(filter) {
20
+ // A skill does not run until stopped, and is not a runner's.
21
+ if (filter.servicesOnly === true)
22
+ return false;
23
+ if (filter.runners !== undefined)
24
+ return false;
25
+ return true;
26
+ }
27
+ /**
28
+ * The skills that pass `filter`, matched like tasks: by name, then the
29
+ * `/<name>` line, the description and the origin. With a query they are
30
+ * ranked best first; without one they keep their order.
31
+ */
32
+ export function filterSkills(skills, filter = {}) {
33
+ if (!keepsSkill(filter))
34
+ return [];
35
+ const queryTerms = splitTerms(filter.query ?? '');
36
+ if (queryTerms.length === 0)
37
+ return skills.map((skill) => ({ skill, score: 0, labelHits: null }));
38
+ const mode = filter.mode ?? 'fuzzy';
39
+ const hits = [];
40
+ for (const skill of skills) {
41
+ const entry = {
42
+ path: [skill.name],
43
+ display: skillLine(skill),
44
+ doc: skill.description ?? '',
45
+ detail: '',
46
+ tags: [skill.origin, ...skill.harnesses],
47
+ };
48
+ const m = matchEntry(entry, queryTerms, mode);
49
+ if (m !== null)
50
+ hits.push({ skill, score: m.score, labelHits: m.labelHits });
51
+ }
52
+ hits.sort((a, b) => b.score - a.score);
53
+ return hits;
54
+ }
@@ -0,0 +1,72 @@
1
+ /**
2
+ * What wayfinder could not know about a catalog, each with the one label
3
+ * every surface shows for it. The JSON documents carry the same list, so a
4
+ * script reads the words a person sees.
5
+ *
6
+ * Browser-safe: no Node built-in.
7
+ */
8
+ import type { ParametersUnknownReason, RunnerCacheState, RunnerReport, StaleReason } from '@osdlc/system-model/detect';
9
+ import { type ExecOffSource, type WithheldReason } from '../vocabulary.ts';
10
+ import type { Settings } from '../config.ts';
11
+ /**
12
+ * One thing wayfinder could not know. `label` is the wording every surface
13
+ * shows; the other fields are the facts behind it.
14
+ */
15
+ export type Unknown = {
16
+ /** A runner that was not read, because reading it means running it. */
17
+ kind: 'withheld';
18
+ runner: string;
19
+ reason: WithheldReason;
20
+ /**
21
+ * The trust scopes this runner still needs: its own id and each tool
22
+ * manager that wraps it. A grant for each (`way trust --scope <id>`)
23
+ * lets it run. Absent when trust is not what withholds it.
24
+ */
25
+ missing?: string[] | undefined;
26
+ label: string;
27
+ } | {
28
+ /** Tasks whose parameters could not be read. */
29
+ kind: 'parameters';
30
+ runner: string;
31
+ reason: ParametersUnknownReason;
32
+ /** The ids of those tasks. */
33
+ tasks: string[];
34
+ label: string;
35
+ } | {
36
+ /** A runner answered from a stored probe that is out of date. */
37
+ kind: 'stale';
38
+ runner: string;
39
+ reason?: StaleReason | undefined;
40
+ ageMs?: number | undefined;
41
+ label: string;
42
+ } | {
43
+ /** A runner whose tool is not on the PATH. */
44
+ kind: 'binary';
45
+ runner: string;
46
+ binary: string;
47
+ label: string;
48
+ };
49
+ /** What {@link unknownsOf} reads. */
50
+ export interface UnknownsInput {
51
+ reports: readonly RunnerReport[];
52
+ /** The cache verdicts, when the catalog came from the store. */
53
+ cache?: readonly RunnerCacheState[] | undefined;
54
+ /** Why withheld runners were withheld. Default `untrusted`. */
55
+ withheld?: WithheldReason | undefined;
56
+ /** For `exec-off`: what turned execution off. */
57
+ execOff?: ExecOffSource | undefined;
58
+ /** The trust scopes a runner still needs, when per-tool trust is known. */
59
+ missingScopes?: ((runner: string) => string[] | undefined) | undefined;
60
+ }
61
+ /** Every unknown in a catalog, in report order. */
62
+ export declare function unknownsOf(input: UnknownsInput): Unknown[];
63
+ /**
64
+ * What turned execution off for a gate that is not `untrusted`: a config
65
+ * file's `allowExec: false`, else the `--no-exec` flag.
66
+ */
67
+ export declare function execOffSource(settings: Pick<Settings, 'allowExec'>): ExecOffSource;
68
+ /**
69
+ * One line of text for an unknown: the runner's name and the label, and for
70
+ * parameters how many tasks. The same line on every text surface.
71
+ */
72
+ export declare function unknownLine(unknown: Unknown): string;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * What wayfinder could not know about a catalog, each with the one label
3
+ * every surface shows for it. The JSON documents carry the same list, so a
4
+ * script reads the words a person sees.
5
+ *
6
+ * Browser-safe: no Node built-in.
7
+ */
8
+ import { countTasks, missingBinaryLabel, parametersUnknownLabel, runnerLabel, staleLabel, withheldLabel, } from "../vocabulary.js";
9
+ /** Every unknown in a catalog, in report order. */
10
+ export function unknownsOf(input) {
11
+ const out = [];
12
+ const withheld = input.withheld ?? 'untrusted';
13
+ for (const report of input.reports) {
14
+ const runner = report.runner;
15
+ if (report.skippedForExec) {
16
+ const missing = withheld === 'exec-off' ? undefined : input.missingScopes?.(runner);
17
+ out.push({
18
+ kind: 'withheld',
19
+ runner,
20
+ reason: withheld,
21
+ ...(missing !== undefined ? { missing } : {}),
22
+ label: withheldLabel(withheld, missing, input.execOff),
23
+ });
24
+ }
25
+ if (report.tool !== undefined && !report.tool.found) {
26
+ const binary = report.tool.binary;
27
+ out.push({ kind: 'binary', runner, binary, label: missingBinaryLabel(binary) });
28
+ }
29
+ const byReason = new Map();
30
+ for (const task of report.tasks) {
31
+ if (task.parametersUnknown === undefined)
32
+ continue;
33
+ const ids = byReason.get(task.parametersUnknown) ?? [];
34
+ ids.push(task.id);
35
+ byReason.set(task.parametersUnknown, ids);
36
+ }
37
+ for (const [reason, tasks] of byReason) {
38
+ out.push({ kind: 'parameters', runner, reason, tasks, label: parametersUnknownLabel(reason) });
39
+ }
40
+ const state = input.cache?.find((c) => c.runner === runner);
41
+ if (state?.state === 'stale') {
42
+ out.push({
43
+ kind: 'stale',
44
+ runner,
45
+ ...(state.reason !== undefined ? { reason: state.reason } : {}),
46
+ ...(state.ageMs !== undefined ? { ageMs: state.ageMs } : {}),
47
+ label: staleLabel(state.reason, state.ageMs),
48
+ });
49
+ }
50
+ }
51
+ return out;
52
+ }
53
+ /**
54
+ * What turned execution off for a gate that is not `untrusted`: a config
55
+ * file's `allowExec: false`, else the `--no-exec` flag.
56
+ */
57
+ export function execOffSource(settings) {
58
+ const { value, source } = settings.allowExec;
59
+ return value === false && (source === 'user' || source === 'project') ? source : 'flag';
60
+ }
61
+ /**
62
+ * One line of text for an unknown: the runner's name and the label, and for
63
+ * parameters how many tasks. The same line on every text surface.
64
+ */
65
+ export function unknownLine(unknown) {
66
+ const count = unknown.kind === 'parameters' ? ` (${countTasks(unknown.tasks.length)})` : '';
67
+ return `${runnerLabel(unknown.runner)}: ${unknown.label}${count}`;
68
+ }
package/dist/devlink.d.ts CHANGED
@@ -8,6 +8,9 @@
8
8
  *
9
9
  * The cwd layer stays off. Only `WAY_HOME` or `way dev link` hand off to a
10
10
  * checkout, so standing in a repository never runs that repository's code.
11
+ *
12
+ * The link state is `<config>/way/` under the `xdg` convention, moved by the
13
+ * same `WAYFINDER_ROOT` and `WAYFINDER_CONFIG_DIR` as wayfinder's other files.
11
14
  */
12
15
  import { type ToolSpec } from '@osdlc/cli-tool/devlink';
13
16
  export declare const WAYFINDER_SPEC: ToolSpec;
package/dist/devlink.js CHANGED
@@ -8,13 +8,16 @@
8
8
  *
9
9
  * The cwd layer stays off. Only `WAY_HOME` or `way dev link` hand off to a
10
10
  * checkout, so standing in a repository never runs that repository's code.
11
+ *
12
+ * The link state is `<config>/way/` under the `xdg` convention, moved by the
13
+ * same `WAYFINDER_ROOT` and `WAYFINDER_CONFIG_DIR` as wayfinder's other files.
11
14
  */
12
15
  import { existsSync } from 'node:fs';
13
16
  import { resolve } from 'node:path';
14
17
  import { fileURLToPath } from 'node:url';
15
- import { envVars } from '@osdlc/cli-tool';
16
18
  import { validateSpec } from '@osdlc/cli-tool/devlink';
17
19
  import { APP, BIN } from "./app.js";
20
+ import { DIR_ENV_VARS } from "./xdg.js";
18
21
  const MARKER = 'src/cli.ts';
19
22
  export const WAYFINDER_SPEC = validateSpec({
20
23
  name: BIN,
@@ -23,7 +26,7 @@ export const WAYFINDER_SPEC = validateSpec({
23
26
  entry: MARKER,
24
27
  launcher: 'bin/way.js',
25
28
  aliases: [APP],
26
- vendorDirs: { vendor: APP, envVars: envVars(BIN.toUpperCase()) },
29
+ vendorDirs: { vendor: APP, envVars: DIR_ENV_VARS },
27
30
  });
28
31
  /**
29
32
  * The checkout this module runs from, or null for an installed package.
@@ -0,0 +1,22 @@
1
+ /** The `schemaVersion` of each document `way` prints, by `kind`. */
2
+ export declare const GENERATED_VERSIONS: {
3
+ readonly catalog: 1;
4
+ readonly query: 1;
5
+ readonly run: 1;
6
+ readonly providers: 1;
7
+ readonly "config-list": 1;
8
+ readonly "config-get": 1;
9
+ readonly "config-set": 1;
10
+ readonly "config-unset": 1;
11
+ readonly "config-path": 1;
12
+ readonly "config-explain": 1;
13
+ readonly trust: 1;
14
+ readonly guide: 1;
15
+ readonly clean: 1;
16
+ readonly help: 1;
17
+ readonly schema: 1;
18
+ readonly error: 1;
19
+ readonly version: 1;
20
+ };
21
+ /** The JSON Schema of each document src/documents.ts does not declare, by `kind`. */
22
+ export declare const GENERATED_SCHEMAS: Readonly<Record<string, Readonly<Record<string, unknown>>>>;