@visual-z/xeno 0.2.1 → 0.4.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 (282) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +126 -34
  3. package/docs/app-server.md +84 -0
  4. package/docs/install.md +51 -13
  5. package/docs/providers.md +24 -3
  6. package/package.json +7 -5
  7. package/src/apps/app-server.ts +28 -0
  8. package/src/apps/approve.ts +3 -3
  9. package/src/apps/cli.ts +25 -10
  10. package/src/apps/commands.ts +45 -8
  11. package/src/apps/completions.ts +78 -22
  12. package/src/apps/control-transport.ts +89 -0
  13. package/src/apps/image-draft.ts +46 -0
  14. package/src/apps/model-catalog.ts +2 -1
  15. package/src/apps/project-trust.ts +2 -42
  16. package/src/apps/provider-connect.ts +346 -0
  17. package/src/apps/render.ts +22 -47
  18. package/src/apps/resources.ts +5 -2
  19. package/src/apps/shell.ts +333 -1542
  20. package/src/apps/startup-input.ts +45 -9
  21. package/src/apps/startup.ts +149 -94
  22. package/src/apps/ui/app.ts +1553 -0
  23. package/src/apps/ui/control-model.ts +26 -0
  24. package/src/apps/ui/extension-host.ts +194 -0
  25. package/src/apps/ui/image-cache.ts +78 -0
  26. package/src/apps/ui/palette.ts +88 -0
  27. package/src/apps/ui/project.ts +127 -0
  28. package/src/apps/ui/standalone.ts +146 -0
  29. package/src/apps/ui/status-model.ts +68 -0
  30. package/src/apps/ui/surface.ts +86 -0
  31. package/src/apps/ui/theme.ts +86 -0
  32. package/src/core/acceptance.ts +107 -0
  33. package/src/core/action-defaults.ts +47 -295
  34. package/src/core/benchmark.ts +2 -2
  35. package/src/core/branch-receipt.ts +24 -0
  36. package/src/core/checkpoints.ts +64 -0
  37. package/src/core/churn.ts +2 -0
  38. package/src/core/command-artifacts.ts +94 -0
  39. package/src/core/command-contract.ts +35 -0
  40. package/src/core/completion-action.ts +20 -0
  41. package/src/core/completion-review.ts +37 -21
  42. package/src/core/context-detail.ts +37 -0
  43. package/src/core/context-policy.ts +74 -1
  44. package/src/core/continuation.ts +17 -2
  45. package/src/core/control-protocol.ts +62 -0
  46. package/src/core/control-view.ts +42 -0
  47. package/src/core/derive.ts +29 -3
  48. package/src/core/draft-images.ts +56 -0
  49. package/src/core/environment.ts +145 -0
  50. package/src/core/evaluation-coverage.ts +74 -0
  51. package/src/core/event-validation.ts +81 -6
  52. package/src/core/events.ts +99 -3
  53. package/src/core/evidence-links.ts +7 -0
  54. package/src/core/evidence.ts +13 -3
  55. package/src/core/execution.ts +8 -2
  56. package/src/core/experiment.ts +133 -0
  57. package/src/core/export.ts +9 -0
  58. package/src/core/failure-recovery.ts +173 -0
  59. package/src/core/file-precondition.ts +72 -0
  60. package/src/core/handoff.ts +65 -4
  61. package/src/core/harness-diagnostics.ts +206 -0
  62. package/src/core/history-query.ts +38 -2
  63. package/src/core/history.ts +38 -1
  64. package/src/core/integration-health.ts +34 -0
  65. package/src/core/keymap.ts +8 -20
  66. package/src/core/model-picker.ts +64 -0
  67. package/src/core/native-eval.ts +25 -0
  68. package/src/core/note-guidance.ts +34 -0
  69. package/src/core/oauth-fields.ts +44 -0
  70. package/src/core/observation-view.ts +49 -8
  71. package/src/core/permissions.ts +24 -2
  72. package/src/core/process-receipt.ts +105 -0
  73. package/src/core/process-state.ts +37 -0
  74. package/src/core/program-status.ts +31 -0
  75. package/src/core/project.ts +70 -19
  76. package/src/core/prompt-policy.ts +37 -0
  77. package/src/core/query-eval-contract.ts +14 -0
  78. package/src/core/read-observation.ts +82 -0
  79. package/src/core/recovery-corpus.ts +17 -0
  80. package/src/core/recovery-evaluation.ts +60 -0
  81. package/src/core/recovery-sources.ts +74 -0
  82. package/src/core/request-progress.ts +87 -0
  83. package/src/core/request-state.ts +114 -0
  84. package/src/core/runtime-target.ts +94 -0
  85. package/src/core/search-observation.ts +97 -0
  86. package/src/core/session-tree.ts +147 -0
  87. package/src/core/settings.ts +33 -10
  88. package/src/core/skills.ts +44 -0
  89. package/src/core/sql-query.ts +211 -0
  90. package/src/core/theme.ts +36 -58
  91. package/src/core/tool-contract.ts +51 -2
  92. package/src/core/tool-discovery.ts +87 -0
  93. package/src/core/tool-failure.ts +60 -0
  94. package/src/core/tool-input.ts +6 -0
  95. package/src/core/tool-mode-protocol.ts +25 -0
  96. package/src/core/transcript.ts +19 -4
  97. package/src/core/trial-lifecycle.ts +14 -0
  98. package/src/core/tui-mode.ts +29 -0
  99. package/src/core/update-check.ts +97 -0
  100. package/src/core/version.ts +55 -0
  101. package/src/core/work-state.ts +49 -3
  102. package/src/core/working-set.ts +91 -0
  103. package/src/runtime/auth.ts +11 -4
  104. package/src/runtime/branch-jobs.ts +36 -0
  105. package/src/runtime/catalog.ts +13 -3
  106. package/src/runtime/clipboard.ts +15 -4
  107. package/src/runtime/command-artifacts.ts +64 -0
  108. package/src/runtime/control-connection.ts +104 -0
  109. package/src/runtime/environment-tools.ts +60 -0
  110. package/src/runtime/evidence-notes.ts +4 -2
  111. package/src/runtime/exec-sessions.ts +206 -61
  112. package/src/runtime/execution-control.ts +1 -0
  113. package/src/runtime/extension-ui.ts +22 -30
  114. package/src/runtime/extensions.ts +95 -16
  115. package/src/runtime/harness-comparison.ts +27 -7
  116. package/src/runtime/harness-eval.ts +462 -0
  117. package/src/runtime/history-cache.ts +57 -0
  118. package/src/runtime/history-tools.ts +62 -12
  119. package/src/runtime/integrations.ts +210 -0
  120. package/src/runtime/loop.ts +1088 -282
  121. package/src/runtime/model-discovery.ts +208 -0
  122. package/src/runtime/model.ts +9 -0
  123. package/src/runtime/native-eval-fixtures.ts +33 -0
  124. package/src/runtime/native-eval.ts +146 -0
  125. package/src/runtime/oauth.ts +80 -3
  126. package/src/runtime/pi-provider.ts +169 -12
  127. package/src/runtime/program-status.ts +38 -0
  128. package/src/runtime/provider-connect.ts +109 -0
  129. package/src/runtime/provider-presets.ts +87 -0
  130. package/src/runtime/provider-request.ts +13 -2
  131. package/src/runtime/provider.ts +23 -9
  132. package/src/runtime/query-eval-verifier.ts +28 -0
  133. package/src/runtime/recovery-coverage.ts +71 -0
  134. package/src/runtime/recovery-evidence.ts +76 -0
  135. package/src/runtime/recovery-fixtures.ts +116 -0
  136. package/src/runtime/runtime-target.ts +149 -0
  137. package/src/runtime/session-control.ts +198 -0
  138. package/src/runtime/tool-broker.ts +137 -0
  139. package/src/runtime/tool-discovery.ts +57 -0
  140. package/src/runtime/tool-mode-eval.ts +146 -0
  141. package/src/runtime/tool-queue.ts +77 -0
  142. package/src/runtime/tools.ts +628 -183
  143. package/src/runtime/trial-control.ts +45 -0
  144. package/src/runtime/update-check.ts +47 -0
  145. package/src/runtime/window-trial.ts +2 -1
  146. package/src/runtime/working-notes.ts +33 -3
  147. package/src/runtime/workspace-lifecycle.ts +97 -0
  148. package/src/store/acceptance.ts +15 -0
  149. package/src/store/checkpoint-history.ts +43 -0
  150. package/src/store/command-artifacts.ts +96 -0
  151. package/src/store/command.ts +65 -37
  152. package/src/store/file-checkpoints.ts +104 -0
  153. package/src/store/file-index.ts +13 -1
  154. package/src/store/git-checkpoints.ts +67 -0
  155. package/src/store/observations.ts +61 -20
  156. package/src/store/process-receipts.ts +34 -0
  157. package/src/store/query-source.ts +13 -8
  158. package/src/store/recovery.ts +2 -3
  159. package/src/store/replay.ts +16 -4
  160. package/src/store/runtime-target.ts +64 -0
  161. package/src/store/search.ts +171 -132
  162. package/src/store/session-archive.ts +4 -0
  163. package/src/store/source-cancellation.ts +6 -0
  164. package/src/store/update-cache.ts +36 -0
  165. package/src/store/workspace-observation.ts +113 -0
  166. package/src/tui/ansi-spans.ts +126 -0
  167. package/src/tui/style.ts +19 -16
  168. package/src/tui/ui/atomic-draft.ts +121 -0
  169. package/src/tui/ui/canvas.ts +96 -0
  170. package/src/tui/ui/colors.ts +70 -0
  171. package/src/tui/ui/composer.ts +200 -0
  172. package/src/tui/ui/control-panel.ts +23 -0
  173. package/src/tui/ui/dialog.ts +379 -0
  174. package/src/tui/ui/draft.ts +23 -0
  175. package/src/tui/ui/edge.ts +186 -0
  176. package/src/tui/ui/image-size.ts +40 -0
  177. package/src/tui/ui/ink.ts +210 -0
  178. package/src/tui/ui/items.ts +40 -0
  179. package/src/tui/ui/keys.ts +40 -0
  180. package/src/tui/ui/layout.ts +74 -0
  181. package/src/tui/ui/list-model.ts +86 -0
  182. package/src/tui/ui/list-view.ts +172 -0
  183. package/src/tui/ui/mascot.ts +67 -0
  184. package/src/tui/ui/messages.ts +518 -0
  185. package/src/tui/ui/motion.ts +28 -0
  186. package/src/tui/ui/paths.ts +10 -0
  187. package/src/tui/ui/pictures.ts +78 -0
  188. package/src/tui/ui/screen.ts +421 -0
  189. package/src/tui/ui/status.ts +279 -0
  190. package/src/tui/ui/styled.ts +85 -0
  191. package/src/tui/ui/testing.ts +5 -0
  192. package/src/tui/ui/tool-card.ts +150 -0
  193. package/src/apps/extension-ui.ts +0 -330
  194. package/src/apps/resource-browser.ts +0 -75
  195. package/src/apps/session-browser.ts +0 -113
  196. package/src/apps/session-picker.ts +0 -55
  197. package/src/tui/ansi.ts +0 -67
  198. package/src/tui/autocomplete.ts +0 -29
  199. package/src/tui/chat-viewport.ts +0 -47
  200. package/src/tui/complete.ts +0 -87
  201. package/src/tui/editor.ts +0 -940
  202. package/src/tui/host.ts +0 -264
  203. package/src/tui/input.ts +0 -75
  204. package/src/tui/keys.ts +0 -378
  205. package/src/tui/markdown.ts +0 -17
  206. package/src/tui/render.ts +0 -153
  207. package/src/tui/select.ts +0 -258
  208. package/src/tui/settings.ts +0 -44
  209. package/src/tui/statusline.ts +0 -162
  210. package/src/tui/system-theme.ts +0 -700
  211. package/src/tui/terminal.ts +0 -30
  212. package/src/tui/text.ts +0 -52
  213. package/src/tui/toolview.ts +0 -386
  214. package/src/tui/transcript.ts +0 -123
  215. package/src/tui/tree.ts +0 -471
  216. package/src/vendor/pi-tui/LICENSE.upstream +0 -21
  217. package/src/vendor/pi-tui/UPSTREAM.json +0 -50
  218. package/src/vendor/pi-tui/VENDOR.md +0 -25
  219. package/src/vendor/pi-tui/alt-screen-search.ts +0 -327
  220. package/src/vendor/pi-tui/autocomplete.ts +0 -860
  221. package/src/vendor/pi-tui/colors.ts +0 -367
  222. package/src/vendor/pi-tui/components/alt-screen-flash.ts +0 -51
  223. package/src/vendor/pi-tui/components/box.ts +0 -166
  224. package/src/vendor/pi-tui/components/cancellable-loader.ts +0 -40
  225. package/src/vendor/pi-tui/components/editor.ts +0 -2472
  226. package/src/vendor/pi-tui/components/h-stack.ts +0 -44
  227. package/src/vendor/pi-tui/components/image.ts +0 -127
  228. package/src/vendor/pi-tui/components/input.ts +0 -494
  229. package/src/vendor/pi-tui/components/loader.ts +0 -101
  230. package/src/vendor/pi-tui/components/markdown.ts +0 -1021
  231. package/src/vendor/pi-tui/components/mouse-region.ts +0 -33
  232. package/src/vendor/pi-tui/components/scroll-view.ts +0 -224
  233. package/src/vendor/pi-tui/components/select-list.ts +0 -273
  234. package/src/vendor/pi-tui/components/settings-list.ts +0 -328
  235. package/src/vendor/pi-tui/components/spacer.ts +0 -28
  236. package/src/vendor/pi-tui/components/stack.ts +0 -154
  237. package/src/vendor/pi-tui/components/text.ts +0 -107
  238. package/src/vendor/pi-tui/components/truncated-text.ts +0 -65
  239. package/src/vendor/pi-tui/components/v-stack.ts +0 -33
  240. package/src/vendor/pi-tui/editor-component.ts +0 -74
  241. package/src/vendor/pi-tui/fuzzy.ts +0 -138
  242. package/src/vendor/pi-tui/index.ts +0 -186
  243. package/src/vendor/pi-tui/keybindings.ts +0 -320
  244. package/src/vendor/pi-tui/keys.ts +0 -1401
  245. package/src/vendor/pi-tui/kill-ring.ts +0 -46
  246. package/src/vendor/pi-tui/latex.ts +0 -1506
  247. package/src/vendor/pi-tui/layout-node.ts +0 -51
  248. package/src/vendor/pi-tui/layout.ts +0 -449
  249. package/src/vendor/pi-tui/native/UPSTREAM.json +0 -23
  250. package/src/vendor/pi-tui/native/clipboard.h +0 -208
  251. package/src/vendor/pi-tui/native/darwin/README.md +0 -22
  252. package/src/vendor/pi-tui/native/darwin/build.sh +0 -69
  253. package/src/vendor/pi-tui/native/darwin/prebuilds/darwin-arm64/darwin-platform.node +0 -0
  254. package/src/vendor/pi-tui/native/darwin/prebuilds/darwin-x64/darwin-platform.node +0 -0
  255. package/src/vendor/pi-tui/native/darwin/src/darwin-platform.m +0 -132
  256. package/src/vendor/pi-tui/native/linux/README.md +0 -23
  257. package/src/vendor/pi-tui/native/linux/build.sh +0 -65
  258. package/src/vendor/pi-tui/native/linux/prebuilds/linux-arm64/linux-platform-x11.node +0 -0
  259. package/src/vendor/pi-tui/native/linux/prebuilds/linux-x64/linux-platform-x11.node +0 -0
  260. package/src/vendor/pi-tui/native/linux/src/clipboard-worker.h +0 -70
  261. package/src/vendor/pi-tui/native/linux/src/linux-platform-x11.c +0 -274
  262. package/src/vendor/pi-tui/native/napi.h +0 -91
  263. package/src/vendor/pi-tui/native/win32/README.md +0 -31
  264. package/src/vendor/pi-tui/native/win32/build.mjs +0 -232
  265. package/src/vendor/pi-tui/native/win32/prebuilds/win32-arm64/win32-platform.node +0 -0
  266. package/src/vendor/pi-tui/native/win32/prebuilds/win32-x64/win32-platform.node +0 -0
  267. package/src/vendor/pi-tui/native/win32/src/win32-platform.c +0 -241
  268. package/src/vendor/pi-tui/native-modifiers.ts +0 -13
  269. package/src/vendor/pi-tui/native-module-path.ts +0 -31
  270. package/src/vendor/pi-tui/native-platform.ts +0 -65
  271. package/src/vendor/pi-tui/oklab.ts +0 -233
  272. package/src/vendor/pi-tui/stdin-buffer.ts +0 -444
  273. package/src/vendor/pi-tui/terminal-colors.ts +0 -91
  274. package/src/vendor/pi-tui/terminal-image.ts +0 -731
  275. package/src/vendor/pi-tui/terminal.ts +0 -554
  276. package/src/vendor/pi-tui/tui-alt-screen.ts +0 -1750
  277. package/src/vendor/pi-tui/tui-main-screen.ts +0 -655
  278. package/src/vendor/pi-tui/tui.ts +0 -1493
  279. package/src/vendor/pi-tui/undo-stack.ts +0 -28
  280. package/src/vendor/pi-tui/utils.ts +0 -1385
  281. package/src/vendor/pi-tui/wheel-scroll.ts +0 -82
  282. package/src/vendor/pi-tui/word-navigation.ts +0 -117
@@ -1,860 +0,0 @@
1
- import { spawn } from "child_process";
2
- import { readdirSync, statSync } from "fs";
3
- import { homedir } from "os";
4
- import { basename, dirname, join } from "path";
5
- import { fuzzyFilter } from "./fuzzy.ts";
6
- import { autocompleteBoundaryRegex, autocompleteSeparatorRegex } from "./utils.ts";
7
-
8
- const PATH_DELIMITERS = new Set([" ", "\t", '"', "'", "="]);
9
- const tokenStartRegex = new RegExp(`${autocompleteBoundaryRegex.source}$`, "u");
10
- // Opening wrappers that may precede a path in prose, mapped to their closing counterpart.
11
- const PATH_WRAPPERS: Record<string, string> = { "(": ")", "[": "]", "{": "}", "<": ">", "`": "`" };
12
-
13
- function toDisplayPath(value: string): string {
14
- return value.replace(/\\/g, "/");
15
- }
16
-
17
- function escapeRegex(value: string): string {
18
- return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
19
- }
20
-
21
- function buildFdPathQuery(query: string): string {
22
- const normalized = toDisplayPath(query);
23
- if (!normalized.includes("/")) {
24
- return normalized;
25
- }
26
-
27
- const hasTrailingSeparator = normalized.endsWith("/");
28
- const trimmed = normalized.replace(/^\/+|\/+$/g, "");
29
- if (!trimmed) {
30
- return normalized;
31
- }
32
-
33
- const separatorPattern = "[\\\\/]";
34
- const segments = trimmed
35
- .split("/")
36
- .filter(Boolean)
37
- .map((segment) => escapeRegex(segment));
38
- if (segments.length === 0) {
39
- return normalized;
40
- }
41
-
42
- let pattern = segments.join(separatorPattern);
43
- if (hasTrailingSeparator) {
44
- pattern += separatorPattern;
45
- }
46
- return pattern;
47
- }
48
-
49
- function findLastDelimiter(text: string): number {
50
- let lastDelimiter = -1;
51
- let index = 0;
52
- for (const character of text) {
53
- index += character.length;
54
- if (PATH_DELIMITERS.has(character) || autocompleteSeparatorRegex.test(character)) {
55
- lastDelimiter = index - 1;
56
- }
57
- }
58
- return lastDelimiter;
59
- }
60
-
61
- // Strip opening wrappers before a path, e.g. "(~/Dev" -> "~/Dev" or "`src/ma" -> "src/ma".
62
- // Keep a wrapper if the token also contains its closer, e.g. "app/[slug]/pa" or "(group)/pa".
63
- function stripLeadingWrappers(token: string): string {
64
- let result = token;
65
- while (result.length > 0) {
66
- const closer = PATH_WRAPPERS[result[0]!];
67
- if (!closer || result.includes(closer, 1)) {
68
- break;
69
- }
70
- result = result.slice(1);
71
- }
72
- return result;
73
- }
74
-
75
- function findUnclosedQuoteStart(text: string): number | null {
76
- let inQuotes = false;
77
- let quoteStart = -1;
78
-
79
- for (let i = 0; i < text.length; i += 1) {
80
- if (text[i] === '"') {
81
- inQuotes = !inQuotes;
82
- if (inQuotes) {
83
- quoteStart = i;
84
- }
85
- }
86
- }
87
-
88
- return inQuotes ? quoteStart : null;
89
- }
90
-
91
- function isTokenStart(text: string, index: number): boolean {
92
- let start = index;
93
- while (start > 0 && PATH_WRAPPERS[text[start - 1]!]) {
94
- start -= 1;
95
- }
96
- return PATH_DELIMITERS.has(text[start - 1] ?? "") || tokenStartRegex.test(text.slice(0, start));
97
- }
98
-
99
- function extractQuotedPrefix(text: string): string | null {
100
- const quoteStart = findUnclosedQuoteStart(text);
101
- if (quoteStart === null) {
102
- return null;
103
- }
104
-
105
- if (quoteStart > 0 && text[quoteStart - 1] === "@") {
106
- if (!isTokenStart(text, quoteStart - 1)) {
107
- return null;
108
- }
109
- return text.slice(quoteStart - 1);
110
- }
111
-
112
- if (!isTokenStart(text, quoteStart)) {
113
- return null;
114
- }
115
-
116
- return text.slice(quoteStart);
117
- }
118
-
119
- function parsePathPrefix(prefix: string): { rawPrefix: string; isAtPrefix: boolean; isQuotedPrefix: boolean } {
120
- if (prefix.startsWith('@"')) {
121
- return { rawPrefix: prefix.slice(2), isAtPrefix: true, isQuotedPrefix: true };
122
- }
123
- if (prefix.startsWith('"')) {
124
- return { rawPrefix: prefix.slice(1), isAtPrefix: false, isQuotedPrefix: true };
125
- }
126
- if (prefix.startsWith("@")) {
127
- return { rawPrefix: prefix.slice(1), isAtPrefix: true, isQuotedPrefix: false };
128
- }
129
- return { rawPrefix: prefix, isAtPrefix: false, isQuotedPrefix: false };
130
- }
131
-
132
- function buildCompletionValue(
133
- path: string,
134
- options: { isDirectory: boolean; isAtPrefix: boolean; isQuotedPrefix: boolean },
135
- ): string {
136
- const needsQuotes = options.isQuotedPrefix || autocompleteSeparatorRegex.test(path);
137
- const prefix = options.isAtPrefix ? "@" : "";
138
-
139
- if (!needsQuotes) {
140
- return `${prefix}${path}`;
141
- }
142
-
143
- const openQuote = `${prefix}"`;
144
- const closeQuote = '"';
145
- return `${openQuote}${path}${closeQuote}`;
146
- }
147
-
148
- // Use fd to walk directory tree (fast, respects .gitignore)
149
- async function walkDirectoryWithFd(
150
- baseDir: string,
151
- fdPath: string,
152
- query: string,
153
- maxResults: number,
154
- signal: AbortSignal,
155
- maxDepth?: number,
156
- ): Promise<Array<{ path: string; isDirectory: boolean }>> {
157
- const args = [
158
- "--base-directory",
159
- baseDir,
160
- "--max-results",
161
- String(maxResults),
162
- "--type",
163
- "f",
164
- "--type",
165
- "d",
166
- "--follow",
167
- "--hidden",
168
- "--exclude",
169
- ".git",
170
- "--exclude",
171
- ".git/*",
172
- "--exclude",
173
- ".git/**",
174
- ];
175
-
176
- if (maxDepth !== undefined) {
177
- args.push("--max-depth", String(maxDepth));
178
- }
179
-
180
- if (toDisplayPath(query).includes("/")) {
181
- args.push("--full-path");
182
- }
183
-
184
- if (query) {
185
- args.push(buildFdPathQuery(query));
186
- }
187
-
188
- return await new Promise((resolve) => {
189
- if (signal.aborted) {
190
- resolve([]);
191
- return;
192
- }
193
-
194
- const child = spawn(fdPath, args, {
195
- stdio: ["ignore", "pipe", "pipe"],
196
- });
197
- let stdout = "";
198
- let resolved = false;
199
-
200
- const finish = (results: Array<{ path: string; isDirectory: boolean }>) => {
201
- if (resolved) return;
202
- resolved = true;
203
- signal.removeEventListener("abort", onAbort);
204
- resolve(results);
205
- };
206
-
207
- const onAbort = () => {
208
- if (child.exitCode === null) {
209
- child.kill("SIGKILL");
210
- }
211
- };
212
-
213
- signal.addEventListener("abort", onAbort, { once: true });
214
- child.stdout.setEncoding("utf-8");
215
- child.stdout.on("data", (chunk: string) => {
216
- stdout += chunk;
217
- });
218
- child.on("error", () => {
219
- finish([]);
220
- });
221
- child.on("close", (code) => {
222
- if (signal.aborted || code !== 0 || !stdout) {
223
- finish([]);
224
- return;
225
- }
226
-
227
- const lines = stdout.trim().split("\n").filter(Boolean);
228
- const results: Array<{ path: string; isDirectory: boolean }> = [];
229
-
230
- for (const line of lines) {
231
- const displayLine = toDisplayPath(line);
232
- const hasTrailingSeparator = displayLine.endsWith("/");
233
- const normalizedPath = hasTrailingSeparator ? displayLine.slice(0, -1) : displayLine;
234
- if (normalizedPath === ".git" || normalizedPath.startsWith(".git/") || normalizedPath.includes("/.git/")) {
235
- continue;
236
- }
237
-
238
- results.push({
239
- path: displayLine,
240
- isDirectory: hasTrailingSeparator,
241
- });
242
- }
243
-
244
- finish(results);
245
- });
246
- });
247
- }
248
-
249
- export interface AutocompleteItem {
250
- value: string;
251
- label: string;
252
- description?: string;
253
- }
254
-
255
- type Awaitable<T> = T | Promise<T>;
256
-
257
- export interface SlashCommand {
258
- name: string;
259
- description?: string;
260
- argumentHint?: string;
261
- // Function to get argument completions for this command
262
- // Returns null if no argument completion is available
263
- getArgumentCompletions?(argumentPrefix: string): Awaitable<AutocompleteItem[] | null>;
264
- }
265
-
266
- export interface AutocompleteSuggestions {
267
- items: AutocompleteItem[];
268
- prefix: string; // What we're matching against (e.g., "/" or "src/")
269
- }
270
-
271
- export interface AutocompleteProvider {
272
- /** Characters that should naturally trigger this provider at token boundaries. */
273
- triggerCharacters?: string[];
274
-
275
- // Get autocomplete suggestions for current text/cursor position
276
- // Returns null if no suggestions available
277
- getSuggestions(
278
- lines: string[],
279
- cursorLine: number,
280
- cursorCol: number,
281
- options: { signal: AbortSignal; force?: boolean },
282
- ): Promise<AutocompleteSuggestions | null>;
283
-
284
- // Apply the selected item
285
- // Returns the new text and cursor position
286
- applyCompletion(
287
- lines: string[],
288
- cursorLine: number,
289
- cursorCol: number,
290
- item: AutocompleteItem,
291
- prefix: string,
292
- ): {
293
- lines: string[];
294
- cursorLine: number;
295
- cursorCol: number;
296
- };
297
-
298
- // Check if file completion should trigger for explicit Tab completion
299
- shouldTriggerFileCompletion?(lines: string[], cursorLine: number, cursorCol: number): boolean;
300
- }
301
-
302
- // Combined provider that handles both slash commands and file paths
303
- export class CombinedAutocompleteProvider implements AutocompleteProvider {
304
- private commands: (SlashCommand | AutocompleteItem)[];
305
- private basePath: string;
306
- private fdPath: string | null;
307
-
308
- constructor(commands: (SlashCommand | AutocompleteItem)[] = [], basePath: string, fdPath: string | null = null) {
309
- this.commands = commands;
310
- this.basePath = basePath;
311
- this.fdPath = fdPath;
312
- }
313
-
314
- async getSuggestions(
315
- lines: string[],
316
- cursorLine: number,
317
- cursorCol: number,
318
- options: { signal: AbortSignal; force?: boolean },
319
- ): Promise<AutocompleteSuggestions | null> {
320
- const currentLine = lines[cursorLine] || "";
321
- const textBeforeCursor = currentLine.slice(0, cursorCol);
322
-
323
- const atPrefix = this.extractAtPrefix(textBeforeCursor);
324
- if (atPrefix) {
325
- const { rawPrefix, isQuotedPrefix } = parsePathPrefix(atPrefix);
326
- const suggestions = await this.getFuzzyFileSuggestions(rawPrefix, {
327
- isQuotedPrefix,
328
- signal: options.signal,
329
- });
330
- if (suggestions.length === 0) return null;
331
-
332
- return {
333
- items: suggestions,
334
- prefix: atPrefix,
335
- };
336
- }
337
-
338
- if (!options.force && textBeforeCursor.startsWith("/")) {
339
- const spaceIndex = textBeforeCursor.indexOf(" ");
340
-
341
- if (spaceIndex === -1) {
342
- const prefix = textBeforeCursor.slice(1);
343
- const commandItems = this.commands.map((cmd) => {
344
- const name = "name" in cmd ? cmd.name : cmd.value;
345
- const hint = "argumentHint" in cmd && cmd.argumentHint ? cmd.argumentHint : undefined;
346
- const desc = cmd.description ?? "";
347
- const fullDesc = hint ? (desc ? `${hint} — ${desc}` : hint) : desc;
348
- return {
349
- name,
350
- label: name,
351
- description: fullDesc || undefined,
352
- };
353
- });
354
-
355
- const bareNameMatches = fuzzyFilter(commandItems, prefix, (item) =>
356
- item.name.startsWith("skill:") ? item.name.slice("skill:".length) : item.name,
357
- );
358
- const bareNameMatchSet = new Set(bareNameMatches);
359
- const fullNameOnlyMatches = fuzzyFilter(
360
- commandItems.filter((item) => item.name.startsWith("skill:") && !bareNameMatchSet.has(item)),
361
- prefix,
362
- (item) => item.name,
363
- );
364
- const filtered = [...bareNameMatches, ...fullNameOnlyMatches].map((item) => ({
365
- value: item.name,
366
- label: item.label,
367
- ...(item.description && { description: item.description }),
368
- }));
369
-
370
- if (filtered.length === 0) return null;
371
-
372
- return {
373
- items: filtered,
374
- prefix: textBeforeCursor,
375
- };
376
- }
377
-
378
- const commandName = textBeforeCursor.slice(1, spaceIndex);
379
- const argumentText = textBeforeCursor.slice(spaceIndex + 1);
380
-
381
- const command = this.commands.find((cmd) => {
382
- const name = "name" in cmd ? cmd.name : cmd.value;
383
- return name === commandName;
384
- });
385
- if (!command || !("getArgumentCompletions" in command) || !command.getArgumentCompletions) {
386
- return null;
387
- }
388
-
389
- const argumentSuggestions = await command.getArgumentCompletions(argumentText);
390
- if (!Array.isArray(argumentSuggestions) || argumentSuggestions.length === 0) {
391
- return null;
392
- }
393
-
394
- return {
395
- items: argumentSuggestions,
396
- prefix: argumentText,
397
- };
398
- }
399
-
400
- const pathMatch = this.extractPathPrefix(textBeforeCursor, options.force ?? false);
401
- if (pathMatch === null) {
402
- return null;
403
- }
404
-
405
- const suggestions = this.getFileSuggestions(pathMatch);
406
- if (suggestions.length === 0) return null;
407
-
408
- return {
409
- items: suggestions,
410
- prefix: pathMatch,
411
- };
412
- }
413
-
414
- applyCompletion(
415
- lines: string[],
416
- cursorLine: number,
417
- cursorCol: number,
418
- item: AutocompleteItem,
419
- prefix: string,
420
- ): { lines: string[]; cursorLine: number; cursorCol: number } {
421
- const currentLine = lines[cursorLine] || "";
422
- const beforePrefix = currentLine.slice(0, cursorCol - prefix.length);
423
- const afterCursor = currentLine.slice(cursorCol);
424
- const isQuotedPrefix = prefix.startsWith('"') || prefix.startsWith('@"');
425
- const hasLeadingQuoteAfterCursor = afterCursor.startsWith('"');
426
- const hasTrailingQuoteInItem = item.value.endsWith('"');
427
- const adjustedAfterCursor =
428
- isQuotedPrefix && hasTrailingQuoteInItem && hasLeadingQuoteAfterCursor ? afterCursor.slice(1) : afterCursor;
429
-
430
- // Check if we're completing a slash command (prefix starts with "/" but NOT a file path)
431
- // Slash commands are at the start of the line and don't contain path separators after the first /
432
- const isSlashCommand = prefix.startsWith("/") && beforePrefix.trim() === "" && !prefix.slice(1).includes("/");
433
- if (isSlashCommand) {
434
- // This is a command name completion
435
- const newLine = `${beforePrefix}/${item.value} ${adjustedAfterCursor}`;
436
- const newLines = [...lines];
437
- newLines[cursorLine] = newLine;
438
-
439
- return {
440
- lines: newLines,
441
- cursorLine,
442
- cursorCol: beforePrefix.length + item.value.length + 2, // +2 for "/" and space
443
- };
444
- }
445
-
446
- // Check if we're completing a file attachment (prefix starts with "@")
447
- if (prefix.startsWith("@")) {
448
- // This is a file attachment completion
449
- // Don't add space after directories so user can continue autocompleting
450
- const isDirectory = item.label.endsWith("/");
451
- const suffix = isDirectory ? "" : " ";
452
- const newLine = `${beforePrefix + item.value}${suffix}${adjustedAfterCursor}`;
453
- const newLines = [...lines];
454
- newLines[cursorLine] = newLine;
455
-
456
- const hasTrailingQuote = item.value.endsWith('"');
457
- const cursorOffset = isDirectory && hasTrailingQuote ? item.value.length - 1 : item.value.length;
458
-
459
- return {
460
- lines: newLines,
461
- cursorLine,
462
- cursorCol: beforePrefix.length + cursorOffset + suffix.length,
463
- };
464
- }
465
-
466
- // Check if we're in a slash command context (beforePrefix contains "/command ")
467
- const textBeforeCursor = currentLine.slice(0, cursorCol);
468
- if (textBeforeCursor.includes("/") && textBeforeCursor.includes(" ")) {
469
- // This is likely a command argument completion
470
- const newLine = beforePrefix + item.value + adjustedAfterCursor;
471
- const newLines = [...lines];
472
- newLines[cursorLine] = newLine;
473
-
474
- const isDirectory = item.label.endsWith("/");
475
- const hasTrailingQuote = item.value.endsWith('"');
476
- const cursorOffset = isDirectory && hasTrailingQuote ? item.value.length - 1 : item.value.length;
477
-
478
- return {
479
- lines: newLines,
480
- cursorLine,
481
- cursorCol: beforePrefix.length + cursorOffset,
482
- };
483
- }
484
-
485
- // For file paths, complete the path
486
- const newLine = beforePrefix + item.value + adjustedAfterCursor;
487
- const newLines = [...lines];
488
- newLines[cursorLine] = newLine;
489
-
490
- const isDirectory = item.label.endsWith("/");
491
- const hasTrailingQuote = item.value.endsWith('"');
492
- const cursorOffset = isDirectory && hasTrailingQuote ? item.value.length - 1 : item.value.length;
493
-
494
- return {
495
- lines: newLines,
496
- cursorLine,
497
- cursorCol: beforePrefix.length + cursorOffset,
498
- };
499
- }
500
-
501
- // Extract @ prefix for fuzzy file suggestions
502
- private extractAtPrefix(text: string): string | null {
503
- const quotedPrefix = extractQuotedPrefix(text);
504
- if (quotedPrefix?.startsWith('@"')) {
505
- return quotedPrefix;
506
- }
507
-
508
- const lastDelimiterIndex = findLastDelimiter(text);
509
- const token = stripLeadingWrappers(lastDelimiterIndex === -1 ? text : text.slice(lastDelimiterIndex + 1));
510
-
511
- if (token.startsWith("@")) {
512
- return token;
513
- }
514
-
515
- return null;
516
- }
517
-
518
- // Extract a path-like prefix from the text before cursor
519
- private extractPathPrefix(text: string, forceExtract: boolean = false): string | null {
520
- const quotedPrefix = extractQuotedPrefix(text);
521
- if (quotedPrefix) {
522
- return quotedPrefix;
523
- }
524
-
525
- const lastDelimiterIndex = findLastDelimiter(text);
526
- const pathPrefix = stripLeadingWrappers(lastDelimiterIndex === -1 ? text : text.slice(lastDelimiterIndex + 1));
527
-
528
- // For forced extraction (Tab key), always return something
529
- if (forceExtract) {
530
- return pathPrefix;
531
- }
532
-
533
- // For natural triggers, return if it looks like a path, ends with /, starts with ~/, .
534
- // Only return empty string if the text looks like it's starting a path context
535
- if (pathPrefix.includes("/") || pathPrefix.startsWith(".") || pathPrefix.startsWith("~/")) {
536
- return pathPrefix;
537
- }
538
-
539
- // Return an empty prefix after whitespace or CJK punctuation, but not for empty text.
540
- // Empty text should not trigger file suggestions - that's for forced Tab completion
541
- if (pathPrefix === "" && text !== "" && tokenStartRegex.test(text)) {
542
- return pathPrefix;
543
- }
544
-
545
- return null;
546
- }
547
-
548
- // Expand home directory (~/) to actual home path
549
- private expandHomePath(path: string): string {
550
- if (path.startsWith("~/")) {
551
- const expandedPath = join(homedir(), path.slice(2));
552
- // Preserve trailing slash if original path had one
553
- return path.endsWith("/") && !expandedPath.endsWith("/") ? `${expandedPath}/` : expandedPath;
554
- } else if (path === "~") {
555
- return homedir();
556
- }
557
- return path;
558
- }
559
-
560
- private resolveScopedFuzzyQuery(rawQuery: string): { baseDir: string; query: string; displayBase: string } | null {
561
- const normalizedQuery = toDisplayPath(rawQuery);
562
- const slashIndex = normalizedQuery.lastIndexOf("/");
563
- if (slashIndex === -1) {
564
- return null;
565
- }
566
-
567
- const displayBase = normalizedQuery.slice(0, slashIndex + 1);
568
- const query = normalizedQuery.slice(slashIndex + 1);
569
-
570
- let baseDir: string;
571
- if (displayBase.startsWith("~/")) {
572
- baseDir = this.expandHomePath(displayBase);
573
- } else if (displayBase.startsWith("/")) {
574
- baseDir = displayBase;
575
- } else {
576
- baseDir = join(this.basePath, displayBase);
577
- }
578
-
579
- try {
580
- if (!statSync(baseDir).isDirectory()) {
581
- return null;
582
- }
583
- } catch {
584
- return null;
585
- }
586
-
587
- return { baseDir, query, displayBase };
588
- }
589
-
590
- private scopedPathForDisplay(displayBase: string, relativePath: string): string {
591
- const normalizedRelativePath = toDisplayPath(relativePath);
592
- if (displayBase === "/") {
593
- return `/${normalizedRelativePath}`;
594
- }
595
- return `${toDisplayPath(displayBase)}${normalizedRelativePath}`;
596
- }
597
-
598
- // Get file/directory suggestions for a given path prefix
599
- private getFileSuggestions(prefix: string): AutocompleteItem[] {
600
- try {
601
- let searchDir: string;
602
- let searchPrefix: string;
603
- const { rawPrefix, isAtPrefix, isQuotedPrefix } = parsePathPrefix(prefix);
604
- let expandedPrefix = rawPrefix;
605
-
606
- // Handle home directory expansion
607
- if (expandedPrefix.startsWith("~")) {
608
- expandedPrefix = this.expandHomePath(expandedPrefix);
609
- }
610
-
611
- const isRootPrefix =
612
- rawPrefix === "" ||
613
- rawPrefix === "./" ||
614
- rawPrefix === "../" ||
615
- rawPrefix === "~" ||
616
- rawPrefix === "~/" ||
617
- rawPrefix === "/" ||
618
- (isAtPrefix && rawPrefix === "");
619
-
620
- if (isRootPrefix) {
621
- // Complete from specified position
622
- if (rawPrefix.startsWith("~") || expandedPrefix.startsWith("/")) {
623
- searchDir = expandedPrefix;
624
- } else {
625
- searchDir = join(this.basePath, expandedPrefix);
626
- }
627
- searchPrefix = "";
628
- } else if (rawPrefix.endsWith("/")) {
629
- // If prefix ends with /, show contents of that directory
630
- if (rawPrefix.startsWith("~") || expandedPrefix.startsWith("/")) {
631
- searchDir = expandedPrefix;
632
- } else {
633
- searchDir = join(this.basePath, expandedPrefix);
634
- }
635
- searchPrefix = "";
636
- } else {
637
- // Split into directory and file prefix
638
- const dir = dirname(expandedPrefix);
639
- const file = basename(expandedPrefix);
640
- if (rawPrefix.startsWith("~") || expandedPrefix.startsWith("/")) {
641
- searchDir = dir;
642
- } else {
643
- searchDir = join(this.basePath, dir);
644
- }
645
- searchPrefix = file;
646
- }
647
-
648
- const entries = readdirSync(searchDir, { withFileTypes: true });
649
- const suggestions: AutocompleteItem[] = [];
650
-
651
- for (const entry of entries) {
652
- if (!entry.name.toLowerCase().startsWith(searchPrefix.toLowerCase())) {
653
- continue;
654
- }
655
-
656
- // Check if entry is a directory (or a symlink pointing to a directory)
657
- let isDirectory = entry.isDirectory();
658
- if (!isDirectory && entry.isSymbolicLink()) {
659
- try {
660
- const fullPath = join(searchDir, entry.name);
661
- isDirectory = statSync(fullPath).isDirectory();
662
- } catch {
663
- // Broken symlink or permission error - treat as file
664
- }
665
- }
666
-
667
- let relativePath: string;
668
- const name = entry.name;
669
- const displayPrefix = rawPrefix;
670
-
671
- if (displayPrefix.endsWith("/")) {
672
- // If prefix ends with /, append entry to the prefix
673
- relativePath = displayPrefix + name;
674
- } else if (displayPrefix.includes("/") || displayPrefix.includes("\\")) {
675
- // Preserve ~/ format for home directory paths
676
- if (displayPrefix.startsWith("~/")) {
677
- const homeRelativeDir = displayPrefix.slice(2); // Remove ~/
678
- const dir = dirname(homeRelativeDir);
679
- relativePath = `~/${dir === "." ? name : join(dir, name)}`;
680
- } else if (displayPrefix.startsWith("/")) {
681
- // Absolute path - construct properly
682
- const dir = dirname(displayPrefix);
683
- if (dir === "/") {
684
- relativePath = `/${name}`;
685
- } else {
686
- relativePath = `${dir}/${name}`;
687
- }
688
- } else {
689
- relativePath = join(dirname(displayPrefix), name);
690
- // path.join normalizes away ./ prefix, preserve it
691
- if (displayPrefix.startsWith("./") && !relativePath.startsWith("./")) {
692
- relativePath = `./${relativePath}`;
693
- }
694
- }
695
- } else {
696
- // For standalone entries, preserve ~/ if original prefix was ~/
697
- if (displayPrefix.startsWith("~")) {
698
- relativePath = `~/${name}`;
699
- } else {
700
- relativePath = name;
701
- }
702
- }
703
-
704
- relativePath = toDisplayPath(relativePath);
705
- const pathValue = isDirectory ? `${relativePath}/` : relativePath;
706
- const value = buildCompletionValue(pathValue, {
707
- isDirectory,
708
- isAtPrefix,
709
- isQuotedPrefix,
710
- });
711
-
712
- suggestions.push({
713
- value,
714
- label: name + (isDirectory ? "/" : ""),
715
- });
716
- }
717
-
718
- // Sort directories first, then alphabetically
719
- suggestions.sort((a, b) => {
720
- const aIsDir = a.label.endsWith("/");
721
- const bIsDir = b.label.endsWith("/");
722
- if (aIsDir && !bIsDir) return -1;
723
- if (!aIsDir && bIsDir) return 1;
724
- return a.label.localeCompare(b.label);
725
- });
726
-
727
- return suggestions;
728
- } catch (_e) {
729
- // Directory doesn't exist or not accessible
730
- return [];
731
- }
732
- }
733
-
734
- // Score an entry against the query (higher = better match)
735
- // isDirectory adds bonus to prioritize folders
736
- private scoreEntry(filePath: string, query: string, isDirectory: boolean): number {
737
- const fileName = basename(filePath);
738
- const lowerFileName = fileName.toLowerCase();
739
- const lowerQuery = query.toLowerCase();
740
-
741
- let score = 0;
742
-
743
- // Exact filename match (highest)
744
- if (lowerFileName === lowerQuery) score = 100;
745
- // Filename starts with query
746
- else if (lowerFileName.startsWith(lowerQuery)) score = 80;
747
- // Substring match in filename
748
- else if (lowerFileName.includes(lowerQuery)) score = 50;
749
- // Substring match in full path
750
- else if (filePath.toLowerCase().includes(lowerQuery)) score = 30;
751
-
752
- // Directories get a bonus to appear first
753
- if (isDirectory && score > 0) score += 10;
754
-
755
- return score;
756
- }
757
-
758
- private async getBaseDirSuggestions(
759
- baseDir: string,
760
- query: string,
761
- signal: AbortSignal,
762
- ): Promise<Array<{ path: string; isDirectory: boolean }>> {
763
- if (!this.fdPath || signal.aborted) {
764
- return [];
765
- }
766
-
767
- return await walkDirectoryWithFd(baseDir, this.fdPath, query, 100, signal, 1);
768
- }
769
-
770
- // Fuzzy file search using fd (fast, respects .gitignore)
771
- private async getFuzzyFileSuggestions(
772
- query: string,
773
- options: { isQuotedPrefix: boolean; signal: AbortSignal },
774
- ): Promise<AutocompleteItem[]> {
775
- if (!this.fdPath || options.signal.aborted) {
776
- return [];
777
- }
778
-
779
- try {
780
- const scopedQuery = this.resolveScopedFuzzyQuery(query);
781
- const fdBaseDir = scopedQuery?.baseDir ?? this.basePath;
782
- const fdQuery = scopedQuery?.query ?? query;
783
- const baseDirEntries = await this.getBaseDirSuggestions(fdBaseDir, fdQuery, options.signal);
784
- const recursiveEntries = await walkDirectoryWithFd(fdBaseDir, this.fdPath, fdQuery, 100, options.signal);
785
- const seenPaths = new Set(baseDirEntries.map((entry) => entry.path));
786
- const entries = [
787
- ...baseDirEntries,
788
- ...recursiveEntries.filter((entry) => {
789
- if (seenPaths.has(entry.path)) return false;
790
- seenPaths.add(entry.path);
791
- return true;
792
- }),
793
- ];
794
- if (options.signal.aborted) {
795
- return [];
796
- }
797
-
798
- const scoredEntries = entries
799
- .map((entry) => ({
800
- ...entry,
801
- score: fdQuery ? this.scoreEntry(entry.path, fdQuery, entry.isDirectory) : 1,
802
- }))
803
- .filter((entry) => entry.score > 0);
804
-
805
- scoredEntries.sort((a, b) => {
806
- const scoreDiff = b.score - a.score;
807
- if (scoreDiff !== 0) return scoreDiff;
808
-
809
- const aDepth = toDisplayPath(a.path).split("/").filter(Boolean).length;
810
- const bDepth = toDisplayPath(b.path).split("/").filter(Boolean).length;
811
- const depthDiff = aDepth - bDepth;
812
- if (depthDiff !== 0) return depthDiff;
813
-
814
- const lengthDiff = a.path.length - b.path.length;
815
- if (lengthDiff !== 0) return lengthDiff;
816
-
817
- return a.path.localeCompare(b.path);
818
- });
819
- const topEntries = scoredEntries.slice(0, 20);
820
-
821
- const suggestions: AutocompleteItem[] = [];
822
- for (const { path: entryPath, isDirectory } of topEntries) {
823
- const pathWithoutSlash = isDirectory ? entryPath.slice(0, -1) : entryPath;
824
- const displayPath = scopedQuery
825
- ? this.scopedPathForDisplay(scopedQuery.displayBase, pathWithoutSlash)
826
- : pathWithoutSlash;
827
- const entryName = basename(pathWithoutSlash);
828
- const completionPath = isDirectory ? `${displayPath}/` : displayPath;
829
- const value = buildCompletionValue(completionPath, {
830
- isDirectory,
831
- isAtPrefix: true,
832
- isQuotedPrefix: options.isQuotedPrefix,
833
- });
834
-
835
- suggestions.push({
836
- value,
837
- label: entryName + (isDirectory ? "/" : ""),
838
- description: displayPath,
839
- });
840
- }
841
-
842
- return suggestions;
843
- } catch {
844
- return [];
845
- }
846
- }
847
-
848
- // Check if we should trigger file completion (called on Tab key)
849
- shouldTriggerFileCompletion(lines: string[], cursorLine: number, cursorCol: number): boolean {
850
- const currentLine = lines[cursorLine] || "";
851
- const textBeforeCursor = currentLine.slice(0, cursorCol);
852
-
853
- // Don't trigger if we're typing a slash command at the start of the line
854
- if (textBeforeCursor.trim().startsWith("/") && !textBeforeCursor.trim().includes(" ")) {
855
- return false;
856
- }
857
-
858
- return true;
859
- }
860
- }