@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.
Files changed (121) hide show
  1. package/CHANGELOG.md +221 -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,180 @@
1
+ /**
2
+ * The terminal UI as an object: its state, the frame it draws and the keys it
3
+ * answers. `createTui` makes one over a {@link Session} and a {@link TuiHost};
4
+ * `runTui` in `./index.ts` gives it a real terminal. Tests give it a fake
5
+ * host, so every key and every frame can be checked without a terminal.
6
+ *
7
+ * Collection is async, which is what much of the state handling is for: keys
8
+ * arrive during a refresh, and a row can be stale.
9
+ */
10
+ import type { Catalog, RunnerCacheState, Task } from '@osdlc/system-model/detect';
11
+ import type { Mode } from '@osdlc/system-model/match';
12
+ import type { Settings } from '../config.ts';
13
+ import type { TaskHit } from '../core/filter.ts';
14
+ import type { HandOffResult } from '../core/run.ts';
15
+ import { type CacheState, type RunPlan, type Session } from '../core/session.ts';
16
+ import { type SkillHit, type SkillRow } from '../core/skills.ts';
17
+ import { type SettingsItem } from './settings.ts';
18
+ import { type Styles } from './style.ts';
19
+ /** What the terminal UI needs from the terminal it runs in. */
20
+ export interface TuiHost {
21
+ /** Write to the screen. */
22
+ write(text: string): void;
23
+ columns(): number;
24
+ rows(): number;
25
+ platform: NodeJS.Platform;
26
+ /** Put text on the clipboard; true when a program took it. */
27
+ clipboard(text: string): Promise<boolean>;
28
+ /** Give the terminal back: leave raw mode and the alternate screen. Idempotent. */
29
+ release(): void;
30
+ /** Run a task with the terminal, after {@link release}. */
31
+ handOff(plan: RunPlan): HandOffResult;
32
+ /** End the process. The real host never returns. */
33
+ exit(code: number): void;
34
+ }
35
+ /** A line of feedback on the status line. */
36
+ export interface Message {
37
+ text: string;
38
+ tone: 'note' | 'warning' | 'error';
39
+ }
40
+ /** The scopes `^o` cycles through, as the web view's Scope buttons. */
41
+ export declare const SCOPES: readonly {
42
+ label: string;
43
+ maxDepth: number | undefined;
44
+ }[];
45
+ /** The settings screen while it is open. */
46
+ export interface SettingsScreen {
47
+ settings: Settings;
48
+ /**
49
+ * The item the cursor is on. Held by item, not line, because an edit and
50
+ * the probe after it change the lines above it.
51
+ */
52
+ at: SettingsItem | null;
53
+ /** The cursor's last line, to fall back near when its item is gone. */
54
+ hint: number;
55
+ scroll: number;
56
+ /** The excluded path being typed, or null. */
57
+ adding: string | null;
58
+ }
59
+ /** The `all` tab. */
60
+ export declare const ALL = "all";
61
+ /**
62
+ * The Skills tab. Its rows are agent skills, not a runner's tasks. The `#`
63
+ * keeps it apart from any runner id.
64
+ */
65
+ export declare const SKILLS_TAB: string;
66
+ /** A row of the list: a task, or an agent skill. */
67
+ export type ListEntry = {
68
+ task: TaskHit;
69
+ skill?: undefined;
70
+ } | {
71
+ skill: SkillHit;
72
+ task?: undefined;
73
+ };
74
+ /** Everything the screen shows. */
75
+ export interface TuiState {
76
+ catalog: Catalog | null;
77
+ /** Where each runner's rows came from, one entry per selected runner. */
78
+ cache: CacheState[];
79
+ /** The agent skills from the last probe. */
80
+ skills: SkillRow[];
81
+ /** `runners.order`, applied to every catalog. */
82
+ runnerOrder: string[] | undefined;
83
+ /** True once a probe has finished, so an empty list is an answer. */
84
+ probed: boolean;
85
+ /**
86
+ * True when the rows came from a probe in this run. Until then they come
87
+ * from the saved listing or the store, and a task is probed again before
88
+ * it runs.
89
+ */
90
+ fromProbe: boolean;
91
+ /** The selected tab: `all`, a runner id or {@link SKILLS_TAB}. */
92
+ runner: string;
93
+ query: string;
94
+ mode: Mode;
95
+ servicesOnly: boolean;
96
+ declaredOnly: boolean;
97
+ /** Index into {@link SCOPES}. */
98
+ scope: number;
99
+ /** Held by task or skill id, not row index, so a refresh cannot move it to another row. */
100
+ selectedId: string | null;
101
+ scroll: number;
102
+ message: Message | null;
103
+ loading: boolean;
104
+ /**
105
+ * A trust grant waiting for `y`. Trust lets the repository's code run, so
106
+ * one key cannot grant it; `^s` is also flow control on many terminals.
107
+ */
108
+ confirmingTrust: boolean;
109
+ /** The tool the pending grant is for, or null for the whole repository. */
110
+ trustScope: string | null;
111
+ /** The task whose arguments are being typed, and the text so far. */
112
+ entering: {
113
+ task: Task;
114
+ text: string;
115
+ } | null;
116
+ view: 'list' | 'settings' | 'help';
117
+ /** The view `?` was pressed in, to go back to. */
118
+ helpFrom: 'list' | 'settings';
119
+ helpScroll: number;
120
+ settings: SettingsScreen | null;
121
+ /** The trust grant was removed in this run. */
122
+ revoked: boolean;
123
+ /** Increased on each refresh, so an older result cannot overwrite a newer one. */
124
+ generation: number;
125
+ inFlight: AbortController | null;
126
+ /** The tasks that pass the filters, in the selected tab. */
127
+ rows: TaskHit[];
128
+ /** The skills that pass the filters, listed after the tasks. */
129
+ skillRows: SkillHit[];
130
+ }
131
+ /** One terminal UI. */
132
+ export interface Tui {
133
+ readonly state: TuiState;
134
+ readonly session: Session;
135
+ /** The whole screen as one string. */
136
+ frame(width: number, height: number): string;
137
+ /** One key. */
138
+ handle(key: string): void;
139
+ /** One read from the terminal: each key, with the rows rebuilt after each. */
140
+ feed(chunk: string): void;
141
+ /** Rebuild the rows and keep the selection on a task that is still there. */
142
+ recompute(): void;
143
+ /** Index of the selected row. */
144
+ cursor(): number;
145
+ /** The list's rows: the tasks, then the skills. */
146
+ entries(): ListEntry[];
147
+ /** Write a frame to the host. */
148
+ draw(): void;
149
+ /** Show the stored probe, then probe. */
150
+ boot(): Promise<void>;
151
+ /** Probe again. */
152
+ refresh(): Promise<void>;
153
+ /** Stop any probe, give the terminal back and exit. */
154
+ quit(code: number): void;
155
+ /** Resolves when the work keys started has finished. For tests. */
156
+ idle(): Promise<void>;
157
+ }
158
+ /** What {@link createTui} takes. */
159
+ export interface CreateTuiOptions {
160
+ session: Session;
161
+ host: TuiHost;
162
+ styles: Styles;
163
+ }
164
+ /**
165
+ * `text` wrapped at word breaks to `width` columns. Each later line is
166
+ * indented to where the text after a key column starts (the first run of two
167
+ * spaces after the first word), so a key's action lines up under itself.
168
+ */
169
+ export declare function wrapHanging(text: string, width: number): string[];
170
+ /**
171
+ * What the status line says about stale rows, in three states. Fresh says
172
+ * nothing. Stale and measured slow is kept apart from ordinary stale,
173
+ * because it is the case the store exists for.
174
+ */
175
+ export declare function refreshNote(rows: readonly RunnerCacheState[], loading: boolean): {
176
+ text: string;
177
+ slow: boolean;
178
+ } | null;
179
+ /** Make a terminal UI. Nothing is drawn or probed until {@link Tui.boot}. */
180
+ export declare function createTui({ session, host, styles: s }: CreateTuiOptions): Tui;