@floegence/floe-webapp-core 0.35.7 → 0.35.8

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.
@@ -0,0 +1,7 @@
1
+ import type { TerminalEditorState } from './types';
2
+ export declare function createTerminalEditorState(value?: string): TerminalEditorState;
3
+ export declare function insertTerminalText(state: TerminalEditorState, text: string): TerminalEditorState;
4
+ export declare function deleteTerminalTextBackward(state: TerminalEditorState): TerminalEditorState;
5
+ export declare function moveTerminalCursor(state: TerminalEditorState, direction: 'left' | 'right'): TerminalEditorState;
6
+ export declare function navigateTerminalHistory(state: TerminalEditorState, history: readonly string[], direction: 'up' | 'down'): TerminalEditorState;
7
+ export declare function clampTerminalCursor(cursor: number, valueLength: number): number;
@@ -0,0 +1,84 @@
1
+ function h(r = "") {
2
+ return {
3
+ value: r,
4
+ cursor: r.length,
5
+ historyIndex: null,
6
+ draft: ""
7
+ };
8
+ }
9
+ function d(r, n) {
10
+ if (!n) return r;
11
+ const u = o(r.cursor, r.value.length);
12
+ return {
13
+ value: r.value.slice(0, u) + n + r.value.slice(u),
14
+ cursor: u + n.length,
15
+ historyIndex: null,
16
+ draft: ""
17
+ };
18
+ }
19
+ function f(r) {
20
+ const n = o(r.cursor, r.value.length);
21
+ return n === 0 ? r : {
22
+ value: r.value.slice(0, n - 1) + r.value.slice(n),
23
+ cursor: n - 1,
24
+ historyIndex: null,
25
+ draft: ""
26
+ };
27
+ }
28
+ function a(r, n) {
29
+ const u = o(r.cursor, r.value.length), e = n === "left" ? Math.max(0, u - 1) : Math.min(r.value.length, u + 1);
30
+ return e === u ? r : {
31
+ ...r,
32
+ cursor: e
33
+ };
34
+ }
35
+ function x(r, n, u) {
36
+ if (!n.length) return r;
37
+ if (u === "up") {
38
+ if (r.historyIndex === null) {
39
+ const t = n[n.length - 1] ?? "";
40
+ return {
41
+ value: t,
42
+ cursor: t.length,
43
+ historyIndex: n.length - 1,
44
+ draft: r.value
45
+ };
46
+ }
47
+ const l = Math.max(0, r.historyIndex - 1);
48
+ if (l === r.historyIndex) return r;
49
+ const i = n[l] ?? "";
50
+ return {
51
+ ...r,
52
+ value: i,
53
+ cursor: i.length,
54
+ historyIndex: l
55
+ };
56
+ }
57
+ if (r.historyIndex === null) return r;
58
+ const e = r.historyIndex + 1;
59
+ if (e >= n.length)
60
+ return {
61
+ value: r.draft,
62
+ cursor: r.draft.length,
63
+ historyIndex: null,
64
+ draft: ""
65
+ };
66
+ const c = n[e] ?? "";
67
+ return {
68
+ ...r,
69
+ value: c,
70
+ cursor: c.length,
71
+ historyIndex: e
72
+ };
73
+ }
74
+ function o(r, n) {
75
+ return Math.max(0, Math.min(n, r));
76
+ }
77
+ export {
78
+ o as clampTerminalCursor,
79
+ h as createTerminalEditorState,
80
+ f as deleteTerminalTextBackward,
81
+ d as insertTerminalText,
82
+ a as moveTerminalCursor,
83
+ x as navigateTerminalHistory
84
+ };
@@ -0,0 +1,2 @@
1
+ import type { TerminalRuntimeAdapter } from './types';
2
+ export declare const runTerminalMockCommand: TerminalRuntimeAdapter;
@@ -0,0 +1,287 @@
1
+ import { normalizeTerminalWorkspaceProfile as T } from "./workspaceProfile.js";
2
+ const y = {
3
+ "README.md": `# Floe Webapp
4
+ Terminal-first demo workspace with a mobile keyboard.`,
5
+ "package.json": `{
6
+ "name": "floe-webapp",
7
+ "scripts": {
8
+ "dev": "node scripts/dev.mjs",
9
+ "build": "pnpm -r build"
10
+ }
11
+ }`,
12
+ "pnpm-lock.yaml": `lockfileVersion: "9.0"
13
+ packages:
14
+ packages/core:
15
+ version: 0.35.7
16
+ packages/protocol:
17
+ version: 0.35.7`,
18
+ "tsconfig.json": `{
19
+ "compilerOptions": {
20
+ "target": "ES2022",
21
+ "module": "ESNext"
22
+ }
23
+ }`,
24
+ ".env.local": `VITE_FLOE_CONTROLPLANE_BASE_URL=https://controlplane.example.com
25
+ VITE_FLOE_ENDPOINT_ID=demo-endpoint`,
26
+ "scripts/dev.mjs": `import { spawn } from 'node:child_process';
27
+
28
+ spawn('pnpm', ['--filter', '@floegence/floe-webapp-demo', 'dev'], { stdio: 'inherit' });`
29
+ }, B = (s, r) => {
30
+ const n = T(r?.profile), u = r?.resolveNow ?? (() => (/* @__PURE__ */ new Date()).toString()), e = s.trim();
31
+ if (!e)
32
+ return {
33
+ clear: !1,
34
+ lines: []
35
+ };
36
+ if (e === "help")
37
+ return t(
38
+ [
39
+ "Available commands:",
40
+ 'pwd, ls, ls -la, cat <file>, less <file>, head -n <count> <file>, tail -n <count> <file>, wc -l|-w|-c <file>, mkdir -p <dir>, touch <file>, chmod <mode> <target>, clear, date, echo <text>, echo "$PATH", echo "$SHELL"',
41
+ "git status, git diff, git log --oneline -10, git add ., git checkout -b <branch>, git commit -m <message>",
42
+ `pnpm ${n.scripts.join(", pnpm ")}`,
43
+ "find . -name <pattern>, grep -R <pattern> src/, grep -n <pattern> <file>, grep -i <pattern> <file>, sort <file>, cut <options> <file>, uname -a, vim <file>, sed -n <range> <file>, awk <program> <file>",
44
+ "curl -I|-L <url>, tar -czf|-xzf|-tf <archive>, ssh <host>, scp <src> <dest>"
45
+ ].join(`
46
+ `)
47
+ );
48
+ if (e === "pwd")
49
+ return t(n.cwd);
50
+ if (e === "ls" || e === "ls -la") {
51
+ const i = [...n.directories, ...n.files];
52
+ return t(
53
+ e === "ls" ? i.join(" ") : [
54
+ ...n.directories.map((o) => `drwxr-xr-x ${o}`),
55
+ ...n.files.map((o) => `-rw-r--r-- ${o}`)
56
+ ].join(`
57
+ `)
58
+ );
59
+ }
60
+ if (e.startsWith("ls ")) {
61
+ const i = e.slice(3).trim().replace(/\/$/, "");
62
+ if (n.directories.includes(i))
63
+ return t(i === "packages" ? "boot core init protocol" : i === "apps" ? "demo" : i === "src" ? "app.ts widgets terminal components" : `${i}/`);
64
+ }
65
+ if (e === "clear")
66
+ return {
67
+ clear: !0,
68
+ lines: []
69
+ };
70
+ if (e === "date")
71
+ return t(u());
72
+ if (e === 'echo "$PATH"')
73
+ return t("/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin");
74
+ if (e === 'echo "$SHELL"')
75
+ return t("/bin/zsh");
76
+ if (e.startsWith("echo "))
77
+ return t(e.slice(5));
78
+ if (e === "uname -a")
79
+ return t("Darwin floe-webapp.local 24.4.0 Darwin Kernel Version 24.4.0 arm64");
80
+ if (e === "uname -sr")
81
+ return t("Darwin 24.4.0");
82
+ if (e === "uname -m")
83
+ return t("arm64");
84
+ if (e === "git status")
85
+ return t(`On branch main
86
+ nothing to commit, working tree clean`);
87
+ if (e === "git diff")
88
+ return t(`diff --git a/packages/core/src/terminal/suggestionEngine.ts b/packages/core/src/terminal/suggestionEngine.ts
89
+ index 1234567..89abcde 100644`);
90
+ if (e === "git log --oneline -10" || e === "git log --oneline")
91
+ return t(`307a37e merge mobile keyboard
92
+ c942cb5 add terminal-first mobile keyboard
93
+ 37fa316 release 0.35.7`);
94
+ if (e === "git add .")
95
+ return t("staged tracked changes");
96
+ const f = e.match(/^git checkout -b\s+(.+)$/);
97
+ if (f)
98
+ return t(`Switched to a new branch '${f[1]}'`);
99
+ const m = e.match(/^git commit -m\s+"(.+)"$/);
100
+ if (m)
101
+ return t(`[main abc1234] ${m[1]}
102
+ 3 files changed, 42 insertions(+), 8 deletions(-)`);
103
+ const d = e.match(/^cat\s+(.+)$/);
104
+ if (d) {
105
+ const i = p(n.files, d[1] ?? "");
106
+ if (i)
107
+ return t(i);
108
+ }
109
+ const j = e.match(/^vim\s+(.+)$/);
110
+ if (j) {
111
+ const i = l(j[1] ?? ""), o = p(n.files, i);
112
+ if (o)
113
+ return t(S(i, o));
114
+ }
115
+ const $ = e.match(/^pnpm\s+([a-z0-9:-]+)$/i);
116
+ if ($ && n.scripts.includes($[1] ?? ""))
117
+ return t(`> pnpm ${$[1]}
118
+ completed mock run for script '${$[1]}'`);
119
+ if (e.match(/^find \. -name\s+(.+)$/))
120
+ return t(["./README.md", "./packages/core/src/terminal/suggestionEngine.ts"].join(`
121
+ `));
122
+ if (e.match(/^grep -R\s+(.+)\s+src\/?$/))
123
+ return t("src/terminal/suggestionEngine.ts:getTerminalSuggestions");
124
+ const b = e.match(/^grep\s+(-n|-i)\s+(.+?)\s+(.+)$/);
125
+ if (b) {
126
+ const i = b[1] ?? "", o = C(b[2] ?? ""), c = l(b[3] ?? ""), a = p(n.files, c);
127
+ if (a)
128
+ return t(W(a, c, o, i));
129
+ }
130
+ const v = e.match(/^less\s+(.+)$/);
131
+ if (v) {
132
+ const i = l(v[1] ?? ""), o = p(n.files, i);
133
+ if (o)
134
+ return t(`${o}
135
+ (END)`);
136
+ }
137
+ const L = e.match(/^mkdir\s+-p\s+(.+)$/);
138
+ if (L)
139
+ return t(`created directory ${l(L[1] ?? "")}`);
140
+ const N = e.match(/^touch\s+(.+)$/);
141
+ if (N)
142
+ return t(`updated timestamp for ${l(N[1] ?? "")}`);
143
+ const M = e.match(/^chmod\s+(.+?)\s+(.+)$/);
144
+ if (M)
145
+ return t(
146
+ `mode ${M[1] ?? ""} applied to ${l(M[2] ?? "")}`
147
+ );
148
+ const h = e.match(/^head(?:\s+-n\s+(\d+))?(?:\s+-c\s+(\d+))?\s+(.+)$/);
149
+ if (h) {
150
+ const i = Number(h[1] ?? 10), o = h[2] ? Number(h[2]) : null, c = l(h[3] ?? ""), a = p(n.files, c);
151
+ if (a)
152
+ return t(
153
+ o === null ? z(a, i) : a.slice(0, Math.max(0, o))
154
+ );
155
+ }
156
+ const g = e.match(/^tail(?:\s+-n\s+(\d+))?(?:\s+-c\s+(\d+))?\s+(.+)$/);
157
+ if (g) {
158
+ const i = Number(g[1] ?? 10), o = g[2] ? Number(g[2]) : null, c = l(g[3] ?? ""), a = p(n.files, c);
159
+ if (a)
160
+ return t(
161
+ o === null ? D(a, i) : a.slice(Math.max(0, a.length - Math.max(0, o)))
162
+ );
163
+ }
164
+ const w = e.match(/^wc\s+(-[lwc])\s+(.+)$/);
165
+ if (w) {
166
+ const i = w[1] ?? "", o = l(w[2] ?? ""), c = p(n.files, o);
167
+ if (c)
168
+ return t(A(c, o, i));
169
+ }
170
+ const x = e.match(/^sort(?:\s+(-u|-r))?\s+(.+)$/);
171
+ if (x) {
172
+ const i = x[1] ?? "", o = l(x[2] ?? ""), c = p(n.files, o);
173
+ if (c)
174
+ return t(F(c, i));
175
+ }
176
+ const E = e.match(/^cut\s+(.+)\s+(.+)$/);
177
+ if (E) {
178
+ const i = E[1] ?? "", o = l(E[2] ?? ""), c = p(n.files, o);
179
+ if (c)
180
+ return t(_(c, i));
181
+ }
182
+ const k = e.match(/^sed -n '(\d+),(\d+)p'\s+(.+)$/);
183
+ if (k) {
184
+ const i = Number(k[1] ?? 1), o = Number(k[2] ?? i), c = l(k[3] ?? ""), a = p(n.files, c);
185
+ if (a)
186
+ return t(R(a, i, o));
187
+ }
188
+ return e === "sed -E 's/floe/Floe/g' README.md" ? t(`# Floe Webapp
189
+ Terminal-first demo workspace with a mobile keyboard.`) : e === "awk '{print $1}' package.json" ? t(["{", '"name":', '"scripts":', '"dev":', '"build":', "}", "}"].join(`
190
+ `)) : e === "awk 'NR<=20 {print}' README.md" ? t(`# Floe Webapp
191
+ Terminal-first demo workspace with a mobile keyboard.`) : e === `awk '/scripts/ {print NR ":" $0}' package.json` ? t('3: "scripts": {') : e === "curl -I https://example.com" ? t(
192
+ [
193
+ "HTTP/2 200",
194
+ "content-type: text/html; charset=utf-8",
195
+ "cache-control: max-age=300"
196
+ ].join(`
197
+ `)
198
+ ) : e === "curl -L https://example.com" ? t(`<!doctype html>
199
+ <html>
200
+ <body>Example Domain</body>
201
+ </html>`) : e === 'curl -H "Authorization: Bearer " https://api.example.com' ? t('{"error":"missing bearer token"}') : e === "tar -czf floe-webapp.tgz packages/" ? t("created archive floe-webapp.tgz from packages/") : e === "tar -xzf floe-webapp.tgz" ? t("extracted archive floe-webapp.tgz") : e === "tar -tf floe-webapp.tgz" ? t(["packages/", "packages/core/", "packages/protocol/"].join(`
202
+ `)) : e === "ssh user@example.com" ? t(`Connected to user@example.com
203
+ Last login: Tue Mar 17 22:00:00 2026`) : e === "ssh -p 22 user@example.com" ? t("Connected to user@example.com on port 22") : e === "scp README.md user@example.com:/tmp/" ? t("README.md 100% 58B 1.2KB/s 00:00") : e === "scp -r scripts/ user@example.com:/tmp/scripts/" ? t("scripts/ 100% copied recursively") : {
204
+ clear: !1,
205
+ lines: [
206
+ {
207
+ type: "error",
208
+ content: `Command not found: ${e}`
209
+ }
210
+ ]
211
+ };
212
+ };
213
+ function t(s) {
214
+ return {
215
+ clear: !1,
216
+ lines: [
217
+ {
218
+ type: "output",
219
+ content: s
220
+ }
221
+ ]
222
+ };
223
+ }
224
+ function p(s, r) {
225
+ const n = l(r);
226
+ return !n || !s.includes(n) ? null : y[n] ?? `// Mock contents for ${n}
227
+ // Generated by the shared terminal runtime.`;
228
+ }
229
+ function l(s) {
230
+ return s.trim().replace(/\/$/, "");
231
+ }
232
+ function C(s) {
233
+ const r = s.trim();
234
+ return r.startsWith('"') && r.endsWith('"') || r.startsWith("'") && r.endsWith("'") ? r.slice(1, -1) : r;
235
+ }
236
+ function z(s, r) {
237
+ return s.split(`
238
+ `).slice(0, Math.max(0, r)).join(`
239
+ `);
240
+ }
241
+ function D(s, r) {
242
+ return s.split(`
243
+ `).slice(-Math.max(0, r)).join(`
244
+ `);
245
+ }
246
+ function R(s, r, n) {
247
+ return s.split(`
248
+ `).slice(Math.max(0, r - 1), Math.max(r - 1, n)).join(`
249
+ `);
250
+ }
251
+ function S(s, r) {
252
+ return `"${s}" ${r.split(`
253
+ `).length}L, ${r.length}B
254
+ ~
255
+ Mock vim session opened for ${s}`;
256
+ }
257
+ function A(s, r, n) {
258
+ return n === "-l" ? `${s.split(`
259
+ `).length} ${r}` : n === "-w" ? `${s.trim().split(/\s+/).filter(Boolean).length} ${r}` : `${s.length} ${r}`;
260
+ }
261
+ function W(s, r, n, u) {
262
+ if (!n)
263
+ return `${r}: pattern is empty`;
264
+ const e = u === "-i" ? n.toLowerCase() : n;
265
+ return s.split(`
266
+ `).map((m, d) => ({ line: m, index: d })).filter(
267
+ ({ line: m }) => (u === "-i" ? m.toLowerCase() : m).includes(e)
268
+ ).map(({ line: m, index: d }) => u === "-n" ? `${d + 1}:${m}` : m).join(`
269
+ `) || `${r}: no matches`;
270
+ }
271
+ function F(s, r) {
272
+ const u = [...s.split(`
273
+ `)].sort((e, f) => e.localeCompare(f));
274
+ return r === "-u" ? [...new Set(u)].join(`
275
+ `) : r === "-r" ? u.reverse().join(`
276
+ `) : u.join(`
277
+ `);
278
+ }
279
+ function _(s, r) {
280
+ const n = r.match(/-d\s+"([^"]+)"/), u = r.match(/-f\s+(\d+)/), e = n?.[1] ?? " ", f = Math.max(1, Number(u?.[1] ?? 1)) - 1;
281
+ return s.split(`
282
+ `).map((m) => m.split(e)[f] ?? "").join(`
283
+ `);
284
+ }
285
+ export {
286
+ B as runTerminalMockCommand
287
+ };
@@ -0,0 +1,37 @@
1
+ import { type TerminalSuggestionEngineOptions } from './suggestionEngine';
2
+ import type { TerminalEditorState, TerminalSuggestion, TerminalWorkspaceProfile } from './types';
3
+ export interface TerminalSessionState {
4
+ editor: TerminalEditorState;
5
+ history: string[];
6
+ }
7
+ export interface TerminalPromptPreview {
8
+ before: string;
9
+ cursor: string;
10
+ after: string;
11
+ }
12
+ export type TerminalSessionEffect = {
13
+ type: 'none';
14
+ } | {
15
+ type: 'submit';
16
+ command: string;
17
+ } | {
18
+ type: 'interrupt';
19
+ command: string | null;
20
+ } | {
21
+ type: 'clear-screen';
22
+ };
23
+ export interface TerminalSessionTransition {
24
+ state: TerminalSessionState;
25
+ effect: TerminalSessionEffect;
26
+ }
27
+ export interface TerminalSessionSuggestionOptions extends TerminalSuggestionEngineOptions {
28
+ profile?: Partial<TerminalWorkspaceProfile>;
29
+ maxItems?: number;
30
+ }
31
+ export declare function createTerminalSessionState(value?: string): TerminalSessionState;
32
+ export declare function setTerminalSessionInputValue(state: TerminalSessionState, value: string): TerminalSessionState;
33
+ export declare function getTerminalPromptPreview(editor: TerminalEditorState): TerminalPromptPreview;
34
+ export declare function getTerminalSessionSuggestions(state: TerminalSessionState, options?: TerminalSessionSuggestionOptions): TerminalSuggestion[];
35
+ export declare function applyTerminalSessionSuggestion(state: TerminalSessionState, suggestion: TerminalSuggestion): TerminalSessionState;
36
+ export declare function submitTerminalSession(state: TerminalSessionState): TerminalSessionTransition;
37
+ export declare function dispatchTerminalSessionKey(state: TerminalSessionState, key: string, options?: Omit<TerminalSessionSuggestionOptions, 'maxItems'>): TerminalSessionTransition;
@@ -0,0 +1,143 @@
1
+ import { createTerminalEditorState as o, deleteTerminalTextBackward as l, navigateTerminalHistory as t, moveTerminalCursor as u, insertTerminalText as m } from "./editorModel.js";
2
+ import { applyTerminalSuggestion as c, autocompleteTerminalInput as d, getTerminalSuggestions as s } from "./suggestionEngine.js";
3
+ function h(r = "") {
4
+ return {
5
+ editor: o(r),
6
+ history: []
7
+ };
8
+ }
9
+ function g(r, e) {
10
+ return {
11
+ ...r,
12
+ editor: o(e)
13
+ };
14
+ }
15
+ function v(r) {
16
+ const e = r.value, i = Math.max(0, Math.min(r.cursor, e.length));
17
+ return {
18
+ before: e.slice(0, i),
19
+ cursor: i < e.length ? e[i] ?? " " : " ",
20
+ after: i < e.length ? e.slice(i + 1) : ""
21
+ };
22
+ }
23
+ function S(r, e) {
24
+ return s(
25
+ {
26
+ value: r.editor.value,
27
+ cursor: r.editor.cursor,
28
+ history: r.history,
29
+ profile: e?.profile,
30
+ maxItems: e?.maxItems
31
+ },
32
+ {
33
+ providers: e?.providers
34
+ }
35
+ );
36
+ }
37
+ function x(r, e) {
38
+ return {
39
+ ...r,
40
+ editor: c(r.editor, e)
41
+ };
42
+ }
43
+ function p(r) {
44
+ const e = r.editor.value;
45
+ return e.trim() ? {
46
+ state: {
47
+ editor: o(),
48
+ history: [...r.history, e]
49
+ },
50
+ effect: {
51
+ type: "submit",
52
+ command: e
53
+ }
54
+ } : {
55
+ state: r,
56
+ effect: { type: "none" }
57
+ };
58
+ }
59
+ function y(r, e, i) {
60
+ if (!e)
61
+ return {
62
+ state: r,
63
+ effect: { type: "none" }
64
+ };
65
+ if (e === "\r")
66
+ return p(r);
67
+ if (e === "")
68
+ return n(r, l(r.editor));
69
+ if (e === " ")
70
+ return n(
71
+ r,
72
+ d(
73
+ r.editor,
74
+ {
75
+ history: r.history,
76
+ profile: i?.profile
77
+ },
78
+ {
79
+ providers: i?.providers
80
+ }
81
+ )
82
+ );
83
+ if (e === "\x1B[A")
84
+ return n(
85
+ r,
86
+ t(r.editor, r.history, "up")
87
+ );
88
+ if (e === "\x1B[B")
89
+ return n(
90
+ r,
91
+ t(r.editor, r.history, "down")
92
+ );
93
+ if (e === "\x1B[D")
94
+ return n(r, u(r.editor, "left"));
95
+ if (e === "\x1B[C")
96
+ return n(r, u(r.editor, "right"));
97
+ if (e === "") {
98
+ const f = r.editor.value || null;
99
+ return {
100
+ state: {
101
+ ...r,
102
+ editor: o()
103
+ },
104
+ effect: {
105
+ type: "interrupt",
106
+ command: f
107
+ }
108
+ };
109
+ }
110
+ return e === "\f" ? {
111
+ state: {
112
+ ...r,
113
+ editor: o()
114
+ },
115
+ effect: {
116
+ type: "clear-screen"
117
+ }
118
+ } : e.startsWith("\x1B") ? {
119
+ state: r,
120
+ effect: { type: "none" }
121
+ } : n(r, m(r.editor, e));
122
+ }
123
+ function n(r, e) {
124
+ return e === r.editor ? {
125
+ state: r,
126
+ effect: { type: "none" }
127
+ } : {
128
+ state: {
129
+ ...r,
130
+ editor: e
131
+ },
132
+ effect: { type: "none" }
133
+ };
134
+ }
135
+ export {
136
+ x as applyTerminalSessionSuggestion,
137
+ h as createTerminalSessionState,
138
+ y as dispatchTerminalSessionKey,
139
+ v as getTerminalPromptPreview,
140
+ S as getTerminalSessionSuggestions,
141
+ g as setTerminalSessionInputValue,
142
+ p as submitTerminalSession
143
+ };
@@ -0,0 +1,64 @@
1
+ import type { TerminalEditorState, TerminalSuggestion, TerminalSuggestionKind, TerminalSuggestionRequest, TerminalWorkspaceProfile } from './types';
2
+ export interface TerminalToken {
3
+ text: string;
4
+ from: number;
5
+ to: number;
6
+ }
7
+ export interface ParsedTerminalSuggestionContext {
8
+ value: string;
9
+ cursor: number;
10
+ tokens: TerminalToken[];
11
+ command: string | null;
12
+ activeTokenIndex: number;
13
+ activeTokenPrefix: string;
14
+ activeTokenText: string;
15
+ activeReplaceFrom: number;
16
+ activeReplaceTo: number;
17
+ atTokenBoundary: boolean;
18
+ }
19
+ export interface TerminalSuggestionProviderInput {
20
+ request: TerminalSuggestionRequest;
21
+ profile: TerminalWorkspaceProfile;
22
+ context: ParsedTerminalSuggestionContext;
23
+ }
24
+ export type TerminalSuggestionProvider = (input: TerminalSuggestionProviderInput) => readonly TerminalSuggestion[];
25
+ export interface TerminalSuggestionEngineOptions {
26
+ providers?: readonly TerminalSuggestionProvider[];
27
+ }
28
+ export interface TerminalFullLineSuggestionSpec {
29
+ id: string;
30
+ kind: TerminalSuggestionKind;
31
+ label: string;
32
+ detail?: string;
33
+ score: number;
34
+ insertText?: string;
35
+ replaceTo?: number;
36
+ nextCursorOffset?: number;
37
+ }
38
+ export interface TerminalTokenSuggestionSpec {
39
+ id: string;
40
+ kind: TerminalSuggestionKind;
41
+ label: string;
42
+ insertText: string;
43
+ detail?: string;
44
+ score: number;
45
+ replaceFrom?: number;
46
+ replaceTo?: number;
47
+ nextCursorOffset?: number;
48
+ }
49
+ export declare const terminalHistorySuggestionProvider: TerminalSuggestionProvider;
50
+ export declare const terminalRootSuggestionProvider: TerminalSuggestionProvider;
51
+ export declare const terminalCommandTokenSuggestionProvider: TerminalSuggestionProvider;
52
+ export declare const terminalPathSuggestionProvider: TerminalSuggestionProvider;
53
+ export declare const terminalSnippetSuggestionProvider: TerminalSuggestionProvider;
54
+ export declare const DEFAULT_TERMINAL_SUGGESTION_PROVIDERS: readonly TerminalSuggestionProvider[];
55
+ export declare function getTerminalSuggestions(request: TerminalSuggestionRequest, options?: TerminalSuggestionEngineOptions): TerminalSuggestion[];
56
+ export declare function autocompleteTerminalInput(state: TerminalEditorState, requestOptions?: Omit<TerminalSuggestionRequest, 'value' | 'cursor'>, options?: TerminalSuggestionEngineOptions): TerminalEditorState;
57
+ export declare function applyTerminalSuggestion(state: TerminalEditorState, suggestion: TerminalSuggestion): TerminalEditorState;
58
+ export declare function createTerminalFullLineSuggestion(context: ParsedTerminalSuggestionContext, input: TerminalFullLineSuggestionSpec): TerminalSuggestion;
59
+ export declare function createTerminalTokenSuggestion(context: ParsedTerminalSuggestionContext, input: TerminalTokenSuggestionSpec): TerminalSuggestion;
60
+ export declare function matchesTerminalSuggestionPrefix(context: ParsedTerminalSuggestionContext, input: {
61
+ label: string;
62
+ matchText?: string;
63
+ }): boolean;
64
+ export declare function parseTerminalSuggestionContext(value: string, cursor?: number): ParsedTerminalSuggestionContext;