@abacus-ai/cli 2.0.0-canary.1 → 2.0.0-canary.11

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 (198) hide show
  1. package/README.md +25 -0
  2. package/dist/index.mjs +466 -438
  3. package/package.json +4 -1
  4. package/.oxlintrc.json +0 -8
  5. package/resources/abacus.ico +0 -0
  6. package/resources/entitlements.plist +0 -9
  7. package/src/__e2e__/README.md +0 -196
  8. package/src/__e2e__/agent-interactions.e2e.test.tsx +0 -61
  9. package/src/__e2e__/cli-commands.e2e.test.tsx +0 -77
  10. package/src/__e2e__/conversation-throttle.e2e.test.ts +0 -453
  11. package/src/__e2e__/conversation.e2e.test.tsx +0 -56
  12. package/src/__e2e__/diff-preview.e2e.test.tsx +0 -3399
  13. package/src/__e2e__/file-creation.e2e.test.tsx +0 -149
  14. package/src/__e2e__/helpers/test-helpers.ts +0 -449
  15. package/src/__e2e__/keyboard-navigation.e2e.test.tsx +0 -34
  16. package/src/__e2e__/llm-models.e2e.test.ts +0 -402
  17. package/src/__e2e__/mcp/mcp-callback-flow.e2e.test.tsx +0 -71
  18. package/src/__e2e__/mcp/mcp-full-app-ui.e2e.test.tsx +0 -167
  19. package/src/__e2e__/mcp/mcp-ui-rendering.e2e.test.tsx +0 -185
  20. package/src/__e2e__/repl.e2e.test.tsx +0 -78
  21. package/src/__e2e__/shell-compatibility.e2e.test.tsx +0 -76
  22. package/src/__e2e__/theme-mcp.e2e.test.tsx +0 -98
  23. package/src/__e2e__/tool-permissions.e2e.test.tsx +0 -66
  24. package/src/args.ts +0 -22
  25. package/src/components/__tests__/react-compiler.test.tsx +0 -78
  26. package/src/components/__tests__/status-indicator.test.tsx +0 -403
  27. package/src/components/composer/__tests__/bash-runner.test.tsx +0 -263
  28. package/src/components/composer/agent-mode-indicator.tsx +0 -63
  29. package/src/components/composer/bash-runner.tsx +0 -54
  30. package/src/components/composer/commands/default-commands.tsx +0 -615
  31. package/src/components/composer/commands/handler.tsx +0 -59
  32. package/src/components/composer/commands/picker.tsx +0 -273
  33. package/src/components/composer/commands/registry.ts +0 -233
  34. package/src/components/composer/commands/types.ts +0 -33
  35. package/src/components/composer/context.tsx +0 -88
  36. package/src/components/composer/file-mention-picker.tsx +0 -83
  37. package/src/components/composer/help.tsx +0 -44
  38. package/src/components/composer/index.tsx +0 -1007
  39. package/src/components/composer/mentions.ts +0 -57
  40. package/src/components/composer/message-queue.tsx +0 -70
  41. package/src/components/composer/mode-panel.tsx +0 -35
  42. package/src/components/composer/modes/__tests__/bash-handler.test.tsx +0 -755
  43. package/src/components/composer/modes/__tests__/bash-renderer.test.tsx +0 -1108
  44. package/src/components/composer/modes/bash-handler.tsx +0 -132
  45. package/src/components/composer/modes/bash-renderer.tsx +0 -175
  46. package/src/components/composer/modes/default-handlers.tsx +0 -33
  47. package/src/components/composer/modes/index.ts +0 -41
  48. package/src/components/composer/modes/types.ts +0 -21
  49. package/src/components/composer/persistent-shell.ts +0 -283
  50. package/src/components/composer/process.ts +0 -65
  51. package/src/components/composer/types.ts +0 -9
  52. package/src/components/composer/use-mention-search.ts +0 -68
  53. package/src/components/error-boundry.tsx +0 -60
  54. package/src/components/exit-message.tsx +0 -29
  55. package/src/components/expanded-view.tsx +0 -74
  56. package/src/components/file-completion.tsx +0 -127
  57. package/src/components/header.tsx +0 -47
  58. package/src/components/logo.tsx +0 -37
  59. package/src/components/segments.tsx +0 -356
  60. package/src/components/status-indicator.tsx +0 -306
  61. package/src/components/tool-group-summary.tsx +0 -263
  62. package/src/components/tool-permissions/ask-user-question-permission-ui.tsx +0 -319
  63. package/src/components/tool-permissions/diff-preview.tsx +0 -359
  64. package/src/components/tool-permissions/index.ts +0 -5
  65. package/src/components/tool-permissions/permission-options.tsx +0 -401
  66. package/src/components/tool-permissions/permission-preview-header.tsx +0 -57
  67. package/src/components/tool-permissions/tool-permission-ui.tsx +0 -420
  68. package/src/components/tools/agent/ask-user-question.tsx +0 -107
  69. package/src/components/tools/agent/enter-plan-mode.tsx +0 -55
  70. package/src/components/tools/agent/exit-plan-mode.tsx +0 -83
  71. package/src/components/tools/agent/handoff-to-main.tsx +0 -27
  72. package/src/components/tools/agent/subagent.tsx +0 -37
  73. package/src/components/tools/agent/todo-write.tsx +0 -104
  74. package/src/components/tools/browser/close-tab.tsx +0 -58
  75. package/src/components/tools/browser/computer.tsx +0 -70
  76. package/src/components/tools/browser/get-interactive-elements.tsx +0 -54
  77. package/src/components/tools/browser/get-tab-content.tsx +0 -51
  78. package/src/components/tools/browser/navigate-to.tsx +0 -59
  79. package/src/components/tools/browser/new-tab.tsx +0 -60
  80. package/src/components/tools/browser/perform-action.tsx +0 -63
  81. package/src/components/tools/browser/refresh-tab.tsx +0 -43
  82. package/src/components/tools/browser/switch-tab.tsx +0 -58
  83. package/src/components/tools/filesystem/delete-file.tsx +0 -104
  84. package/src/components/tools/filesystem/edit.tsx +0 -220
  85. package/src/components/tools/filesystem/list-dir.tsx +0 -78
  86. package/src/components/tools/filesystem/read-file.tsx +0 -180
  87. package/src/components/tools/filesystem/upload-image.tsx +0 -76
  88. package/src/components/tools/ide/ide-diagnostics.tsx +0 -62
  89. package/src/components/tools/index.ts +0 -91
  90. package/src/components/tools/mcp/mcp-tool.tsx +0 -158
  91. package/src/components/tools/search/fetch-url.tsx +0 -73
  92. package/src/components/tools/search/file-search.tsx +0 -78
  93. package/src/components/tools/search/grep.tsx +0 -90
  94. package/src/components/tools/search/semantic-search.tsx +0 -66
  95. package/src/components/tools/search/web-search.tsx +0 -71
  96. package/src/components/tools/shared/index.tsx +0 -48
  97. package/src/components/tools/shared/zod-coercion.ts +0 -35
  98. package/src/components/tools/terminal/bash-tool-output.tsx +0 -188
  99. package/src/components/tools/terminal/get-terminal-output.tsx +0 -91
  100. package/src/components/tools/terminal/run-in-terminal.tsx +0 -131
  101. package/src/components/tools/types.ts +0 -16
  102. package/src/components/tools.tsx +0 -68
  103. package/src/components/ui/__tests__/divider.test.tsx +0 -61
  104. package/src/components/ui/__tests__/gradient.test.tsx +0 -125
  105. package/src/components/ui/__tests__/input.test.tsx +0 -166
  106. package/src/components/ui/__tests__/select.test.tsx +0 -273
  107. package/src/components/ui/__tests__/shimmer.test.tsx +0 -99
  108. package/src/components/ui/blinking-indicator.tsx +0 -27
  109. package/src/components/ui/divider.tsx +0 -162
  110. package/src/components/ui/gradient.tsx +0 -56
  111. package/src/components/ui/input.tsx +0 -228
  112. package/src/components/ui/select.tsx +0 -151
  113. package/src/components/ui/shimmer.tsx +0 -76
  114. package/src/context/agent-mode.tsx +0 -95
  115. package/src/context/extension-file.tsx +0 -136
  116. package/src/context/network-activity.tsx +0 -45
  117. package/src/context/notification.tsx +0 -62
  118. package/src/context/shell-size.tsx +0 -49
  119. package/src/context/shell-title.tsx +0 -38
  120. package/src/entrypoints/print-mode.ts +0 -312
  121. package/src/entrypoints/repl.tsx +0 -389
  122. package/src/hooks/use-agent.ts +0 -15
  123. package/src/hooks/use-api-client.ts +0 -1
  124. package/src/hooks/use-available-height.ts +0 -8
  125. package/src/hooks/use-cleanup.ts +0 -29
  126. package/src/hooks/use-interrupt-manager.ts +0 -242
  127. package/src/hooks/use-models.ts +0 -22
  128. package/src/index.ts +0 -217
  129. package/src/lib/__tests__/ansi.test.ts +0 -255
  130. package/src/lib/__tests__/cli.test.ts +0 -122
  131. package/src/lib/__tests__/commands.test.ts +0 -325
  132. package/src/lib/__tests__/constants.test.ts +0 -15
  133. package/src/lib/__tests__/focusables.test.ts +0 -25
  134. package/src/lib/__tests__/fs.test.ts +0 -231
  135. package/src/lib/__tests__/markdown.test.tsx +0 -348
  136. package/src/lib/__tests__/mcpCommandHandler.test.ts +0 -173
  137. package/src/lib/__tests__/mcpManagement.test.ts +0 -38
  138. package/src/lib/__tests__/path-paste.test.ts +0 -144
  139. package/src/lib/__tests__/path.test.ts +0 -300
  140. package/src/lib/__tests__/queries.test.ts +0 -39
  141. package/src/lib/__tests__/standaloneMcpService.test.ts +0 -71
  142. package/src/lib/__tests__/text-buffer.test.ts +0 -328
  143. package/src/lib/__tests__/text-utils.test.ts +0 -32
  144. package/src/lib/__tests__/timing.test.ts +0 -78
  145. package/src/lib/__tests__/utils.test.ts +0 -238
  146. package/src/lib/__tests__/vim-buffer-actions.test.ts +0 -154
  147. package/src/lib/ansi.ts +0 -150
  148. package/src/lib/cli-push-server.ts +0 -112
  149. package/src/lib/cli.ts +0 -44
  150. package/src/lib/clipboard.ts +0 -226
  151. package/src/lib/command-utils.ts +0 -93
  152. package/src/lib/commands.ts +0 -270
  153. package/src/lib/constants.ts +0 -3
  154. package/src/lib/extension-connection.ts +0 -181
  155. package/src/lib/focusables.ts +0 -7
  156. package/src/lib/fs.ts +0 -533
  157. package/src/lib/markdown/code-block.tsx +0 -63
  158. package/src/lib/markdown/index.ts +0 -4
  159. package/src/lib/markdown/link.tsx +0 -19
  160. package/src/lib/markdown/markdown.tsx +0 -372
  161. package/src/lib/markdown/types.ts +0 -15
  162. package/src/lib/mcpCommandHandler.ts +0 -121
  163. package/src/lib/mcpManagement.ts +0 -44
  164. package/src/lib/path-paste.ts +0 -185
  165. package/src/lib/path.ts +0 -179
  166. package/src/lib/queries.ts +0 -15
  167. package/src/lib/standaloneMcpService.ts +0 -688
  168. package/src/lib/status-utils.ts +0 -237
  169. package/src/lib/test-utils.tsx +0 -72
  170. package/src/lib/text-buffer.ts +0 -2415
  171. package/src/lib/text-utils.ts +0 -272
  172. package/src/lib/timing.ts +0 -63
  173. package/src/lib/types.ts +0 -295
  174. package/src/lib/utils.ts +0 -182
  175. package/src/lib/vim-buffer-actions.ts +0 -732
  176. package/src/providers/agent.tsx +0 -1063
  177. package/src/providers/api-client.tsx +0 -43
  178. package/src/services/logger.ts +0 -85
  179. package/src/terminal/detection.ts +0 -187
  180. package/src/terminal/exit.ts +0 -279
  181. package/src/terminal/notification.ts +0 -83
  182. package/src/terminal/progress.ts +0 -201
  183. package/src/terminal/setup.ts +0 -797
  184. package/src/terminal/types.ts +0 -51
  185. package/src/theme/context.tsx +0 -57
  186. package/src/theme/index.ts +0 -4
  187. package/src/theme/themed.tsx +0 -35
  188. package/src/theme/themes.json +0 -546
  189. package/src/theme/types.ts +0 -110
  190. package/src/tools/types.ts +0 -59
  191. package/src/tools/utils/__tests__/zod-coercion.test.ts +0 -33
  192. package/src/tools/utils/tool-ui-components.tsx +0 -649
  193. package/src/tools/utils/zod-coercion.ts +0 -35
  194. package/tsconfig.json +0 -16
  195. package/tsconfig.node.json +0 -29
  196. package/tsconfig.test.json +0 -27
  197. package/tsdown.config.ts +0 -17
  198. package/vitest.config.ts +0 -76
@@ -1,185 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import path from "node:path";
3
-
4
- import { stripFileProtocol } from "./clipboard.js";
5
- import { expandHome, abbreviatePath } from "./path.js";
6
-
7
- export const IMAGE_EXTENSIONS = [".png", ".jpg", ".jpeg", ".webp", ".heic", ".heif", ".gif"];
8
-
9
- export function isImagePath(p: string): boolean {
10
- return IMAGE_EXTENSIONS.includes(path.extname(p).toLowerCase());
11
- }
12
-
13
- /**
14
- * Escapes a path for use in an @mention.
15
- * Paths containing spaces are wrapped in single quotes (shell-safe).
16
- */
17
- export function escapePathForMention(p: string): string {
18
- if (p.includes(" ")) return `'${p.replace(/'/g, "'\\''")}'`;
19
- return p;
20
- }
21
-
22
- /**
23
- * Abbreviates an absolute path for display, picking the shorter of
24
- * CWD-relative (./src/foo.ts) or home-relative (~/work/bar.ts).
25
- */
26
- export function prettifyMentionPath(absolutePath: string): string {
27
- return abbreviatePath(absolutePath);
28
- }
29
-
30
- // ── State-machine path splitter ───────────────────────────────────────────
31
-
32
- type SplitMode = "NORMAL" | "SINGLE" | "DOUBLE";
33
-
34
- function looksLikePathStart(text: string): boolean {
35
- const unquoted = text.startsWith("'") || text.startsWith('"') ? text.slice(1) : text;
36
- return (
37
- unquoted.startsWith("/") ||
38
- unquoted.startsWith("~") ||
39
- unquoted.startsWith("./") ||
40
- unquoted.startsWith("../") ||
41
- /^file:\/\//i.test(unquoted) ||
42
- /^[A-Za-z]:[/\\]/.test(unquoted) ||
43
- unquoted.startsWith("\\\\") || // Windows UNC
44
- text.startsWith("& '") // PowerShell & 'path'
45
- );
46
- }
47
-
48
- /**
49
- * Generator that splits a drag-and-drop input string into resolved absolute paths.
50
- *
51
- * Handles all major terminal/OS path encodings:
52
- * - Bare POSIX: /path/to/file.txt
53
- * - Backslash-escaped: /path/to/my\ file.txt
54
- * - Single-quoted: '/path/to/my file.txt'
55
- * - Double-quoted (Windows): "C:\path\to\file.txt"
56
- * - file:// URI: file:///path/to/my%20file.txt
57
- * - Windows bare C:: c:\path\to\file.txt
58
- * - Windows UNC: \\Mac\Home\file.txt
59
- * - PowerShell & '...': & 'c:\New Text Document.txt'
60
- */
61
- export function* splitDragAndDropPaths(text: string): Generator<string> {
62
- const trimmed = text.trim();
63
-
64
- if (!looksLikePathStart(trimmed)) return;
65
-
66
- // Strip PowerShell & prefix (e.g. & 'path')
67
- const input = trimmed.replace(/^& /, "");
68
-
69
- function resolveSeg(raw: string): string {
70
- let s = raw.trim();
71
- // Decode file:// URI
72
- if (/^file:\/\//i.test(s)) {
73
- s = stripFileProtocol(s);
74
- }
75
- // Unescape backslash-escaped spaces
76
- s = s.replace(/\\ /g, " ");
77
- // Expand ~ to home
78
- s = expandHome(s);
79
- return path.resolve(s);
80
- }
81
-
82
- let mode: SplitMode = "NORMAL";
83
- let current = "";
84
-
85
- let i = 0;
86
- while (i < input.length) {
87
- const ch = input[i];
88
-
89
- if (mode === "SINGLE") {
90
- // Check for '\'' (escaped single quote within single-quoted string)
91
- if (ch === "'" && input.slice(i, i + 4) === "'\\''") {
92
- current += "'";
93
- i += 4;
94
- continue;
95
- }
96
- if (ch === "'") {
97
- // End of single-quoted segment
98
- const resolved = resolveSeg(current);
99
- if (resolved) yield resolved;
100
- current = "";
101
- mode = "NORMAL";
102
- i++;
103
- continue;
104
- }
105
- current += ch;
106
- i++;
107
- continue;
108
- }
109
-
110
- if (mode === "DOUBLE") {
111
- if (ch === '"') {
112
- const resolved = resolveSeg(current);
113
- if (resolved) yield resolved;
114
- current = "";
115
- mode = "NORMAL";
116
- i++;
117
- continue;
118
- }
119
- current += ch;
120
- i++;
121
- continue;
122
- }
123
-
124
- // NORMAL mode
125
- if (ch === "'") {
126
- mode = "SINGLE";
127
- i++;
128
- continue;
129
- }
130
- if (ch === '"') {
131
- mode = "DOUBLE";
132
- i++;
133
- continue;
134
- }
135
- // Backslash-escaped space
136
- if (ch === "\\" && i + 1 < input.length && input[i + 1] === " ") {
137
- current += "\\ ";
138
- i += 2;
139
- continue;
140
- }
141
- // Unescaped separator between paths
142
- if (ch === " " || ch === "\n" || ch === "\t") {
143
- if (current.trim()) {
144
- const resolved = resolveSeg(current);
145
- if (resolved) yield resolved;
146
- current = "";
147
- }
148
- i++;
149
- continue;
150
- }
151
- current += ch;
152
- i++;
153
- }
154
-
155
- // Flush remaining segment
156
- if (current.trim()) {
157
- const resolved = resolveSeg(current);
158
- if (resolved) yield resolved;
159
- }
160
- }
161
-
162
- /**
163
- * Validates pasted text as file paths and formats them as @mention strings.
164
- *
165
- * All-or-nothing: returns null if any segment doesn't exist on disk,
166
- * or if no path segments are found.
167
- *
168
- * @returns "@path1 @path2 " (trailing space) or null
169
- */
170
- export function parsePastedPaths(text: string): string | null {
171
- const segments: string[] = [];
172
-
173
- for (const resolved of splitDragAndDropPaths(text)) {
174
- if (!existsSync(resolved)) {
175
- return null; // all-or-nothing: bail if any path is missing
176
- }
177
- const pretty = prettifyMentionPath(resolved);
178
- const escaped = escapePathForMention(pretty);
179
- segments.push(`@${escaped}`);
180
- }
181
-
182
- if (segments.length === 0) return null;
183
-
184
- return segments.join(" ") + " ";
185
- }
package/src/lib/path.ts DELETED
@@ -1,179 +0,0 @@
1
- import { realpathSync } from "node:fs";
2
- import os from "node:os";
3
- import path from "node:path";
4
-
5
- /**
6
- * Special characters that need to be escaped in file paths for shell compatibility.
7
- * Includes: spaces, parentheses, brackets, braces, semicolons, ampersands, pipes,
8
- * asterisks, question marks, dollar signs, backticks, quotes, hash, and other shell metacharacters.
9
- */
10
- export const SHELL_SPECIAL_CHARS = /[ \t()[\]{};|*?$`'"#&<>!~]/;
11
-
12
- /**
13
- * Unescapes special characters in a file path.
14
- * Removes backslash escaping from shell metacharacters.
15
- */
16
- export function unescapePath(filePath: string): string {
17
- return filePath.replace(
18
- new RegExp(`\\\\([${SHELL_SPECIAL_CHARS.source.slice(1, -1)}])`, "g"),
19
- "$1",
20
- );
21
- }
22
-
23
- const home = os.homedir();
24
-
25
- export function expandHome(filePath: string): string {
26
- if (filePath === "~") {
27
- return home;
28
- }
29
- if (filePath.startsWith("~/")) {
30
- return path.join(home, filePath.slice(2));
31
- }
32
- return filePath;
33
- }
34
-
35
- /**
36
- * Abbreviates the home directory in a file path
37
- * @param filePath - The file path to abbreviate.
38
- * @param cwd - The current working directory (defaults to process.cwd())
39
- *
40
- * @example
41
- * ```ts
42
- * abbreviateHome('/home/user/documents/file.txt') // ~/documents/file.txt
43
- * abbreviateHome('./documents/file.txt', '/home/user') // ~/documents/file.txt
44
- * ```
45
- */
46
- export function abbreviateHome(filePath: string, cwd: string = process.cwd()): string {
47
- const resolved = path.resolve(cwd, filePath);
48
- if (resolved === home || resolved.startsWith(`${home}${path.sep}`)) {
49
- const suffix = resolved.slice(home.length);
50
- const posix = suffix.split(path.sep).join("/");
51
- return `~${posix}`;
52
- }
53
- return resolved;
54
- }
55
-
56
- export function abbreviateCwd(filePath: string): string {
57
- const resolved = path.resolve(filePath);
58
- const rel = path.relative(process.cwd(), resolved);
59
- if (!rel) {
60
- return ".";
61
- }
62
- const posixRel = rel.split(path.sep).join("/");
63
- if (posixRel.startsWith(".")) {
64
- return posixRel;
65
- }
66
- return `./${posixRel}`;
67
- }
68
-
69
- export function abbreviatePath(filePath: string): string {
70
- const resolved = path.resolve(filePath);
71
- const cwd = process.cwd();
72
- const rel = path.relative(cwd, resolved);
73
-
74
- if (!rel) {
75
- return ".";
76
- }
77
-
78
- if (!rel.startsWith("..")) {
79
- const posixRel = rel.split(path.sep).join("/");
80
- return posixRel.startsWith(".") ? posixRel : `./${posixRel}`;
81
- }
82
-
83
- if (resolved === home || resolved.startsWith(`${home}${path.sep}`)) {
84
- const suffix = resolved.slice(home.length);
85
- const posix = suffix.split(path.sep).join("/");
86
- return `~${posix}`;
87
- }
88
-
89
- return resolved;
90
- }
91
-
92
- export function resolvePath(filePath: string): string {
93
- return path.resolve(expandHome(filePath));
94
- }
95
-
96
- /**
97
- * Attempts to convert an absolute path to a relative path within a workspace,
98
- * handling symlinks correctly. This is useful for SSH environments where workspace
99
- * directories may be symlinked (e.g., /home/user/code -> /shared/home/user/code).
100
- *
101
- * @param absolutePath - The absolute path to convert
102
- * @param workspacePath - The workspace base path
103
- * @returns An object with:
104
- * - success: true if conversion succeeded
105
- * - relativePath: the relative path (only if success is true)
106
- * - reason: explanation if conversion failed
107
- *
108
- * @example
109
- * ```ts
110
- * // Direct path match
111
- * convertAbsoluteToRelativePath('/home/user/code/file.py', '/home/user/code')
112
- * // => { success: true, relativePath: 'file.py' }
113
- *
114
- * // With symlinks: /home/user/code -> /shared/home/user/code
115
- * convertAbsoluteToRelativePath('/home/user/code/file.py', '/shared/home/user/code')
116
- * // => { success: true, relativePath: 'file.py' }
117
- *
118
- * // Outside workspace
119
- * convertAbsoluteToRelativePath('/other/path/file.py', '/home/user/code')
120
- * // => { success: false, reason: 'outside_workspace' }
121
- * ```
122
- */
123
- export function convertAbsoluteToRelativePath(
124
- absolutePath: string,
125
- workspacePath: string,
126
- ): { success: true; relativePath: string } | { success: false; reason: string } {
127
- const normalizedTarget = path.resolve(absolutePath);
128
- const normalizedWorkspace = path.resolve(workspacePath);
129
-
130
- // Step 1: Try direct conversion (without symlink resolution)
131
- let relativeToWorkspace = path.relative(normalizedWorkspace, normalizedTarget);
132
- const canConvertDirect =
133
- relativeToWorkspace &&
134
- !relativeToWorkspace.startsWith("..") &&
135
- !path.isAbsolute(relativeToWorkspace);
136
-
137
- if (canConvertDirect) {
138
- return { success: true, relativePath: relativeToWorkspace };
139
- }
140
-
141
- // Step 2: Try with symlink resolution
142
- // This handles cases like /home/user/code vs /shared/home/user/code
143
- let realTarget = normalizedTarget;
144
- let realWorkspace = normalizedWorkspace;
145
-
146
- try {
147
- realTarget = realpathSync(normalizedTarget);
148
- } catch {
149
- // If realpath fails (file doesn't exist yet), try resolving parent directory
150
- try {
151
- const parentDir = path.resolve(normalizedTarget, "..");
152
- const fileName = normalizedTarget.split(path.sep).pop() || "";
153
- const realParent = realpathSync(parentDir);
154
- realTarget = path.resolve(realParent, fileName);
155
- } catch {
156
- // If that also fails, use normalized path
157
- }
158
- }
159
-
160
- try {
161
- realWorkspace = realpathSync(normalizedWorkspace);
162
- } catch {
163
- // If realpath fails, use normalized path
164
- }
165
-
166
- // Try relative path calculation with resolved symlinks
167
- relativeToWorkspace = path.relative(realWorkspace, realTarget);
168
- const canConvertWithSymlinks =
169
- relativeToWorkspace &&
170
- !relativeToWorkspace.startsWith("..") &&
171
- !path.isAbsolute(relativeToWorkspace);
172
-
173
- if (canConvertWithSymlinks) {
174
- return { success: true, relativePath: relativeToWorkspace };
175
- }
176
-
177
- // Could not convert - path is outside workspace
178
- return { success: false, reason: "outside_workspace" };
179
- }
@@ -1,15 +0,0 @@
1
- export enum QueryKey {
2
- Models = "models",
3
- CreateConversation = "create-conversation",
4
- GetConversation = "get-conversation",
5
-
6
- Grep = "grep",
7
- FileSearch = "file-search",
8
- ListDir = "list-dir",
9
- ReadFile = "read-file",
10
- DeleteFile = "delete-file",
11
- EditFile = "edit-file",
12
- RunTerminal = "run-terminal",
13
- GetTerminalOutput = "get-terminal-output",
14
- MCPTool = "mcp-tool",
15
- }