wave-code 1.0.10 → 1.1.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 (242) hide show
  1. package/bin/wave-code.js +8 -2
  2. package/dist/bundle/wave.mjs +3207 -0
  3. package/package.json +24 -25
  4. package/src/commands/update.ts +2 -7
  5. package/src/components/App.tsx +3 -7
  6. package/src/components/BtwDisplay.tsx +10 -1
  7. package/src/components/ChatInterface.tsx +21 -52
  8. package/src/components/ConfirmationDetails.tsx +144 -37
  9. package/src/components/DiffDisplay.tsx +335 -301
  10. package/src/components/InputBox.tsx +3 -1
  11. package/src/components/LoadingIndicator.tsx +16 -2
  12. package/src/components/MessageBlockItem.tsx +2 -4
  13. package/src/components/MessageList.tsx +75 -14
  14. package/src/components/ReasoningDisplay.tsx +2 -4
  15. package/src/components/SessionSelector.tsx +82 -11
  16. package/src/components/StatusCommand.tsx +2 -9
  17. package/src/components/ToolDisplay.tsx +2 -4
  18. package/src/contexts/useChat.tsx +156 -335
  19. package/src/daemon/commands.ts +57 -27
  20. package/src/daemon/jsonRpcClient.ts +1 -1
  21. package/src/daemon/socketClient.ts +2 -2
  22. package/src/hooks/useInputManager.ts +1 -1
  23. package/src/index.ts +57 -10
  24. package/src/managers/inputReducer.ts +186 -104
  25. package/src/print-cli.ts +21 -17
  26. package/src/reducers/selectorReducer.ts +10 -0
  27. package/src/session-selector-cli.tsx +269 -28
  28. package/src/stdio/agentBridge.ts +22 -21
  29. package/src/stdio/daemonServer.ts +3 -1
  30. package/src/utils/clipboard.ts +21 -0
  31. package/src/utils/highlightUtils.ts +46 -1
  32. package/src/utils/readPackageJson.ts +29 -0
  33. package/src/utils/streamingText.ts +11 -0
  34. package/src/utils/worktree.ts +191 -43
  35. package/dist/cli.d.ts +0 -6
  36. package/dist/cli.js +0 -53
  37. package/dist/commands/plugin/disable.d.ts +0 -5
  38. package/dist/commands/plugin/disable.js +0 -15
  39. package/dist/commands/plugin/enable.d.ts +0 -5
  40. package/dist/commands/plugin/enable.js +0 -15
  41. package/dist/commands/plugin/install.d.ts +0 -5
  42. package/dist/commands/plugin/install.js +0 -21
  43. package/dist/commands/plugin/list.d.ts +0 -1
  44. package/dist/commands/plugin/list.js +0 -31
  45. package/dist/commands/plugin/marketplace.d.ts +0 -10
  46. package/dist/commands/plugin/marketplace.js +0 -90
  47. package/dist/commands/plugin/uninstall.d.ts +0 -3
  48. package/dist/commands/plugin/uninstall.js +0 -16
  49. package/dist/commands/plugin/update.d.ts +0 -3
  50. package/dist/commands/plugin/update.js +0 -15
  51. package/dist/commands/update.d.ts +0 -1
  52. package/dist/commands/update.js +0 -97
  53. package/dist/components/AgentsManager.d.ts +0 -7
  54. package/dist/components/AgentsManager.js +0 -109
  55. package/dist/components/App.d.ts +0 -9
  56. package/dist/components/App.js +0 -76
  57. package/dist/components/BackgroundTaskManager.d.ts +0 -5
  58. package/dist/components/BackgroundTaskManager.js +0 -99
  59. package/dist/components/BangDisplay.d.ts +0 -8
  60. package/dist/components/BangDisplay.js +0 -17
  61. package/dist/components/BtwDisplay.d.ts +0 -7
  62. package/dist/components/BtwDisplay.js +0 -19
  63. package/dist/components/ChatInterface.d.ts +0 -2
  64. package/dist/components/ChatInterface.js +0 -61
  65. package/dist/components/CommandSelector.d.ts +0 -10
  66. package/dist/components/CommandSelector.js +0 -66
  67. package/dist/components/CompactDisplay.d.ts +0 -8
  68. package/dist/components/CompactDisplay.js +0 -13
  69. package/dist/components/ConfirmationDetails.d.ts +0 -9
  70. package/dist/components/ConfirmationDetails.js +0 -45
  71. package/dist/components/ConfirmationSelector.d.ts +0 -13
  72. package/dist/components/ConfirmationSelector.js +0 -127
  73. package/dist/components/DiffDisplay.d.ts +0 -8
  74. package/dist/components/DiffDisplay.js +0 -201
  75. package/dist/components/DiscoverView.d.ts +0 -2
  76. package/dist/components/DiscoverView.js +0 -37
  77. package/dist/components/FileSelector.d.ts +0 -11
  78. package/dist/components/FileSelector.js +0 -50
  79. package/dist/components/HelpView.d.ts +0 -7
  80. package/dist/components/HelpView.js +0 -74
  81. package/dist/components/HistorySearch.d.ts +0 -8
  82. package/dist/components/HistorySearch.js +0 -66
  83. package/dist/components/InputBox.d.ts +0 -24
  84. package/dist/components/InputBox.js +0 -149
  85. package/dist/components/InstalledView.d.ts +0 -2
  86. package/dist/components/InstalledView.js +0 -45
  87. package/dist/components/LoadingIndicator.d.ts +0 -10
  88. package/dist/components/LoadingIndicator.js +0 -6
  89. package/dist/components/LoginCommand.d.ts +0 -5
  90. package/dist/components/LoginCommand.js +0 -153
  91. package/dist/components/Markdown.d.ts +0 -5
  92. package/dist/components/Markdown.js +0 -127
  93. package/dist/components/MarketplaceAddForm.d.ts +0 -2
  94. package/dist/components/MarketplaceAddForm.js +0 -55
  95. package/dist/components/MarketplaceDetail.d.ts +0 -2
  96. package/dist/components/MarketplaceDetail.js +0 -74
  97. package/dist/components/MarketplaceList.d.ts +0 -8
  98. package/dist/components/MarketplaceList.js +0 -17
  99. package/dist/components/MarketplaceView.d.ts +0 -2
  100. package/dist/components/MarketplaceView.js +0 -41
  101. package/dist/components/McpManager.d.ts +0 -9
  102. package/dist/components/McpManager.js +0 -88
  103. package/dist/components/MessageBlockItem.d.ts +0 -8
  104. package/dist/components/MessageBlockItem.js +0 -15
  105. package/dist/components/MessageList.d.ts +0 -10
  106. package/dist/components/MessageList.js +0 -80
  107. package/dist/components/ModelSelector.d.ts +0 -8
  108. package/dist/components/ModelSelector.js +0 -45
  109. package/dist/components/Notifications.d.ts +0 -7
  110. package/dist/components/Notifications.js +0 -9
  111. package/dist/components/PlanDisplay.d.ts +0 -7
  112. package/dist/components/PlanDisplay.js +0 -6
  113. package/dist/components/PluginDetail.d.ts +0 -2
  114. package/dist/components/PluginDetail.js +0 -87
  115. package/dist/components/PluginList.d.ts +0 -13
  116. package/dist/components/PluginList.js +0 -15
  117. package/dist/components/PluginManagerShell.d.ts +0 -6
  118. package/dist/components/PluginManagerShell.js +0 -92
  119. package/dist/components/PluginManagerTypes.d.ts +0 -35
  120. package/dist/components/PluginManagerTypes.js +0 -1
  121. package/dist/components/QueuedMessageList.d.ts +0 -2
  122. package/dist/components/QueuedMessageList.js +0 -18
  123. package/dist/components/ReasoningDisplay.d.ts +0 -8
  124. package/dist/components/ReasoningDisplay.js +0 -13
  125. package/dist/components/RewindCommand.d.ts +0 -12
  126. package/dist/components/RewindCommand.js +0 -78
  127. package/dist/components/SessionSelector.d.ts +0 -12
  128. package/dist/components/SessionSelector.js +0 -47
  129. package/dist/components/StatusCommand.d.ts +0 -5
  130. package/dist/components/StatusCommand.js +0 -28
  131. package/dist/components/StatusLine.d.ts +0 -6
  132. package/dist/components/StatusLine.js +0 -9
  133. package/dist/components/TaskList.d.ts +0 -5
  134. package/dist/components/TaskList.js +0 -197
  135. package/dist/components/TaskNotificationMessage.d.ts +0 -5
  136. package/dist/components/TaskNotificationMessage.js +0 -12
  137. package/dist/components/ToolDisplay.d.ts +0 -9
  138. package/dist/components/ToolDisplay.js +0 -55
  139. package/dist/components/WorkflowManager.d.ts +0 -5
  140. package/dist/components/WorkflowManager.js +0 -102
  141. package/dist/components/WorktreeExitPrompt.d.ts +0 -12
  142. package/dist/components/WorktreeExitPrompt.js +0 -35
  143. package/dist/constants/commands.d.ts +0 -2
  144. package/dist/constants/commands.js +0 -92
  145. package/dist/contexts/PluginManagerContext.d.ts +0 -3
  146. package/dist/contexts/PluginManagerContext.js +0 -9
  147. package/dist/contexts/useAppConfig.d.ts +0 -10
  148. package/dist/contexts/useAppConfig.js +0 -13
  149. package/dist/contexts/useChat.d.ts +0 -101
  150. package/dist/contexts/useChat.js +0 -993
  151. package/dist/contracts/status.d.ts +0 -7
  152. package/dist/contracts/status.js +0 -1
  153. package/dist/daemon/commands.d.ts +0 -49
  154. package/dist/daemon/commands.js +0 -341
  155. package/dist/daemon/jsonRpcClient.d.ts +0 -38
  156. package/dist/daemon/jsonRpcClient.js +0 -129
  157. package/dist/daemon/socketClient.d.ts +0 -13
  158. package/dist/daemon/socketClient.js +0 -26
  159. package/dist/daemon-cli.d.ts +0 -10
  160. package/dist/daemon-cli.js +0 -15
  161. package/dist/hooks/useInputManager.d.ts +0 -75
  162. package/dist/hooks/useInputManager.js +0 -583
  163. package/dist/hooks/usePluginManager.d.ts +0 -4
  164. package/dist/hooks/usePluginManager.js +0 -265
  165. package/dist/hooks/useTasks.d.ts +0 -1
  166. package/dist/hooks/useTasks.js +0 -5
  167. package/dist/index.d.ts +0 -4
  168. package/dist/index.js +0 -447
  169. package/dist/managers/inputHandlers.d.ts +0 -30
  170. package/dist/managers/inputHandlers.js +0 -625
  171. package/dist/managers/inputReducer.d.ts +0 -271
  172. package/dist/managers/inputReducer.js +0 -1121
  173. package/dist/plugin-manager-cli.d.ts +0 -5
  174. package/dist/plugin-manager-cli.js +0 -12
  175. package/dist/print-cli.d.ts +0 -10
  176. package/dist/print-cli.js +0 -209
  177. package/dist/reducers/agentsManagerReducer.d.ts +0 -26
  178. package/dist/reducers/agentsManagerReducer.js +0 -54
  179. package/dist/reducers/backgroundTaskManagerReducer.d.ts +0 -62
  180. package/dist/reducers/backgroundTaskManagerReducer.js +0 -106
  181. package/dist/reducers/confirmationReducer.d.ts +0 -37
  182. package/dist/reducers/confirmationReducer.js +0 -193
  183. package/dist/reducers/helpSelectorReducer.d.ts +0 -25
  184. package/dist/reducers/helpSelectorReducer.js +0 -52
  185. package/dist/reducers/marketplaceAddFormReducer.d.ts +0 -24
  186. package/dist/reducers/marketplaceAddFormReducer.js +0 -58
  187. package/dist/reducers/mcpManagerReducer.d.ts +0 -37
  188. package/dist/reducers/mcpManagerReducer.js +0 -74
  189. package/dist/reducers/pluginDetailReducer.d.ts +0 -32
  190. package/dist/reducers/pluginDetailReducer.js +0 -70
  191. package/dist/reducers/questionReducer.d.ts +0 -82
  192. package/dist/reducers/questionReducer.js +0 -375
  193. package/dist/reducers/rewindSelectorReducer.d.ts +0 -21
  194. package/dist/reducers/rewindSelectorReducer.js +0 -37
  195. package/dist/reducers/selectorReducer.d.ts +0 -23
  196. package/dist/reducers/selectorReducer.js +0 -42
  197. package/dist/reducers/workflowManagerReducer.d.ts +0 -40
  198. package/dist/reducers/workflowManagerReducer.js +0 -100
  199. package/dist/session-selector-cli.d.ts +0 -3
  200. package/dist/session-selector-cli.js +0 -25
  201. package/dist/stdio/agentBridge.d.ts +0 -139
  202. package/dist/stdio/agentBridge.js +0 -999
  203. package/dist/stdio/daemonServer.d.ts +0 -67
  204. package/dist/stdio/daemonServer.js +0 -191
  205. package/dist/stdio/index.d.ts +0 -5
  206. package/dist/stdio/index.js +0 -5
  207. package/dist/stdio/jsonRpcConnection.d.ts +0 -39
  208. package/dist/stdio/jsonRpcConnection.js +0 -135
  209. package/dist/stdio/protocol.d.ts +0 -41
  210. package/dist/stdio/protocol.js +0 -26
  211. package/dist/stdio/stdioServer.d.ts +0 -36
  212. package/dist/stdio/stdioServer.js +0 -51
  213. package/dist/stdio-cli.d.ts +0 -8
  214. package/dist/stdio-cli.js +0 -15
  215. package/dist/types.d.ts +0 -20
  216. package/dist/types.js +0 -1
  217. package/dist/utils/bracketedPaste.d.ts +0 -39
  218. package/dist/utils/bracketedPaste.js +0 -122
  219. package/dist/utils/clipboard.d.ts +0 -21
  220. package/dist/utils/clipboard.js +0 -347
  221. package/dist/utils/constants.d.ts +0 -16
  222. package/dist/utils/constants.js +0 -18
  223. package/dist/utils/highlightUtils.d.ts +0 -1
  224. package/dist/utils/highlightUtils.js +0 -93
  225. package/dist/utils/inputUtils.d.ts +0 -17
  226. package/dist/utils/inputUtils.js +0 -67
  227. package/dist/utils/logger.d.ts +0 -71
  228. package/dist/utils/logger.js +0 -259
  229. package/dist/utils/markdownTable.d.ts +0 -34
  230. package/dist/utils/markdownTable.js +0 -302
  231. package/dist/utils/rewindCheckpoints.d.ts +0 -8
  232. package/dist/utils/rewindCheckpoints.js +0 -17
  233. package/dist/utils/throttle.d.ts +0 -14
  234. package/dist/utils/throttle.js +0 -55
  235. package/dist/utils/toolParameterTransforms.d.ts +0 -18
  236. package/dist/utils/toolParameterTransforms.js +0 -73
  237. package/dist/utils/usageSummary.d.ts +0 -28
  238. package/dist/utils/usageSummary.js +0 -121
  239. package/dist/utils/version.d.ts +0 -1
  240. package/dist/utils/version.js +0 -4
  241. package/dist/utils/worktree.d.ts +0 -35
  242. package/dist/utils/worktree.js +0 -219
@@ -1,39 +0,0 @@
1
- /**
2
- * Bracketed paste (DECSET 2004) detector.
3
- *
4
- * When bracketed paste is enabled, terminals wrap pasted text in
5
- * `\x1b[200~` (start) and `\x1b[201~` (end) markers, which lets the input
6
- * pipeline distinguish "text was pasted" from "user typed keys" — most
7
- * importantly, a pasted trailing `\r` must NOT be treated as an Enter key.
8
- *
9
- * ink delivers each stdin chunk through useInput after stripping ONE leading
10
- * ESC from the parsed sequence (see use-input.js), so markers may arrive in
11
- * either the raw form (`\x1b[200~`) or the stripped form (`[200~`), and may
12
- * be split across chunks. The detector normalizes both forms and buffers
13
- * partial markers until they complete (deferral is safe: a deferred partial
14
- * is flushed unchanged if the next chunk does not complete a marker).
15
- */
16
- export type PasteProcessResult = {
17
- kind: "input";
18
- input: string;
19
- } | {
20
- kind: "paste";
21
- text: string;
22
- leadingInput?: string;
23
- } | {
24
- kind: "consume";
25
- };
26
- export interface BracketedPasteDetector {
27
- /**
28
- * Feed one input chunk (as delivered by ink's useInput callback).
29
- * - `input`: regular keystrokes, pass through to normal handling.
30
- * - `paste`: completed bracketed paste; insert `text` without submitting.
31
- * `leadingInput` (rare) is content that preceded the start marker in the
32
- * same chunk and should be handled as regular input first.
33
- * - `consume`: content of an in-flight paste (or an empty paste); do
34
- * nothing with this chunk.
35
- */
36
- process(chunk: string): PasteProcessResult;
37
- reset(): void;
38
- }
39
- export declare function createBracketedPasteDetector(): BracketedPasteDetector;
@@ -1,122 +0,0 @@
1
- const ESC = "\u001b";
2
- const START_STRIPPED = "[200~";
3
- const START_RAW = `${ESC}[200~`;
4
- const END_STRIPPED = "[201~";
5
- const END_RAW = `${ESC}[201~`;
6
- const START_FORMS = [START_RAW, START_STRIPPED];
7
- const END_FORMS = [END_RAW, END_STRIPPED];
8
- /**
9
- * Suffixes that may be the beginning of a marker split across chunks.
10
- * Longest-first so the longest matching suffix is deferred (e.g. `[200`
11
- * rather than `[20` for `...x[200`). Deferral is flush-equivalent: if the
12
- * next chunk does not complete a marker, the deferred suffix is delivered
13
- * as regular input unchanged.
14
- */
15
- const PARTIAL_SUFFIXES = [
16
- `${ESC}[201`,
17
- `${ESC}[200`,
18
- `${ESC}[20`,
19
- `${ESC}[2`,
20
- "[201",
21
- "[200",
22
- "[20",
23
- "[2",
24
- ].sort((a, b) => b.length - a.length);
25
- export function createBracketedPasteDetector() {
26
- let inPaste = false;
27
- let buffer = ""; // paste content collected since the start marker
28
- let pending = ""; // deferred partial marker suffix from a previous chunk
29
- const findFirst = (text, forms) => {
30
- let best = null;
31
- for (const form of forms) {
32
- const index = text.indexOf(form);
33
- if (index !== -1 && (best === null || index < best.index)) {
34
- best = { index, length: form.length };
35
- }
36
- }
37
- return best;
38
- };
39
- const endsWithPartial = (text) => {
40
- for (const prefix of PARTIAL_SUFFIXES) {
41
- if (text.endsWith(prefix)) {
42
- return prefix;
43
- }
44
- }
45
- return null;
46
- };
47
- const process = (chunk) => {
48
- let remaining = pending + chunk;
49
- pending = "";
50
- let leadingInput = "";
51
- let pasteText = null;
52
- while (remaining.length > 0) {
53
- if (!inPaste) {
54
- const start = findFirst(remaining, START_FORMS);
55
- if (start) {
56
- leadingInput += remaining.slice(0, start.index);
57
- remaining = remaining.slice(start.index + start.length);
58
- inPaste = true;
59
- continue;
60
- }
61
- // Orphan end marker (start was missed, e.g. consumed by another
62
- // input handler): treat the preceding text as paste so a trailing
63
- // `\r` cannot trigger the coalesced-Enter submit heuristic.
64
- const end = findFirst(remaining, END_FORMS);
65
- if (end) {
66
- pasteText =
67
- (pasteText ?? "") + leadingInput + remaining.slice(0, end.index);
68
- leadingInput = "";
69
- remaining = remaining.slice(end.index + end.length);
70
- continue;
71
- }
72
- const partial = endsWithPartial(remaining);
73
- if (partial) {
74
- pending = remaining.slice(remaining.length - partial.length);
75
- remaining = remaining.slice(0, remaining.length - partial.length);
76
- }
77
- if (remaining.length > 0) {
78
- leadingInput += remaining;
79
- remaining = "";
80
- }
81
- break;
82
- }
83
- const end = findFirst(remaining, END_FORMS);
84
- if (end) {
85
- pasteText = (pasteText ?? "") + buffer + remaining.slice(0, end.index);
86
- buffer = "";
87
- inPaste = false;
88
- remaining = remaining.slice(end.index + end.length);
89
- continue;
90
- }
91
- const partial = endsWithPartial(remaining);
92
- if (partial) {
93
- pending = remaining.slice(remaining.length - partial.length);
94
- remaining = remaining.slice(0, remaining.length - partial.length);
95
- }
96
- buffer += remaining;
97
- remaining = "";
98
- break;
99
- }
100
- if (inPaste) {
101
- // Paste still in flight: hold the content, deliver nothing yet.
102
- return { kind: "consume" };
103
- }
104
- if (pasteText !== null) {
105
- const result = {
106
- kind: "paste",
107
- text: pasteText,
108
- };
109
- if (leadingInput !== "") {
110
- result.leadingInput = leadingInput;
111
- }
112
- return result;
113
- }
114
- return { kind: "input", input: leadingInput };
115
- };
116
- const reset = () => {
117
- inPaste = false;
118
- buffer = "";
119
- pending = "";
120
- };
121
- return { process, reset };
122
- }
@@ -1,21 +0,0 @@
1
- export interface ClipboardImageResult {
2
- success: boolean;
3
- imagePath?: string;
4
- error?: string;
5
- mimeType?: string;
6
- }
7
- /**
8
- * Read image from clipboard
9
- * @returns Promise<ClipboardImageResult> Result containing image path or error information
10
- */
11
- export declare function readClipboardImage(): Promise<ClipboardImageResult>;
12
- /**
13
- * Clean up temporary image file
14
- * @param imagePath Path to the image file to clean up
15
- */
16
- export declare function cleanupTempImage(imagePath: string): void;
17
- /**
18
- * Check if clipboard contains image (quick check, does not save file)
19
- * @returns Promise<boolean> Whether it contains image
20
- */
21
- export declare function hasClipboardImage(): Promise<boolean>;
@@ -1,347 +0,0 @@
1
- import { unlinkSync, existsSync } from "fs";
2
- import { join } from "path";
3
- import { tmpdir } from "os";
4
- /**
5
- * Read image from clipboard
6
- * @returns Promise<ClipboardImageResult> Result containing image path or error information
7
- */
8
- export async function readClipboardImage() {
9
- try {
10
- const platform = process.platform;
11
- if (platform === "darwin") {
12
- return await readClipboardImageMac();
13
- }
14
- else if (platform === "win32") {
15
- return await readClipboardImageWindows();
16
- }
17
- else if (platform === "linux") {
18
- return await readClipboardImageLinux();
19
- }
20
- else {
21
- return {
22
- success: false,
23
- error: `Clipboard image reading is not supported on platform: ${platform}`,
24
- };
25
- }
26
- }
27
- catch (error) {
28
- return {
29
- success: false,
30
- error: `Failed to read clipboard image: ${error instanceof Error ? error.message : String(error)}`,
31
- };
32
- }
33
- }
34
- /**
35
- * Read clipboard image on macOS
36
- */
37
- async function readClipboardImageMac() {
38
- const { exec } = await import("child_process");
39
- const { promisify } = await import("util");
40
- const execAsync = promisify(exec);
41
- try {
42
- // Try to read image data directly to check if image exists
43
- const testScript = `
44
- tell application "System Events"
45
- try
46
- set imageData to the clipboard as «class PNGf»
47
- return true
48
- on error
49
- return false
50
- end try
51
- end tell
52
- `;
53
- let hasImage = false;
54
- try {
55
- const { stdout: testResult } = await execAsync(`osascript -e '${testScript}'`);
56
- hasImage = testResult.trim() === "true";
57
- }
58
- catch {
59
- hasImage = false;
60
- }
61
- if (!hasImage) {
62
- return {
63
- success: false,
64
- error: "No image found in clipboard",
65
- };
66
- }
67
- // Generate temporary file path
68
- const tempFilePath = join(tmpdir(), `clipboard-image-${Date.now()}.png`);
69
- // Use osascript to save clipboard image as file
70
- const saveScript = `
71
- tell application "System Events"
72
- try
73
- set imageData to the clipboard as «class PNGf»
74
- set fileRef to open for access POSIX file "${tempFilePath}" with write permission
75
- write imageData to fileRef
76
- close access fileRef
77
- return true
78
- on error errMsg
79
- try
80
- close access fileRef
81
- end try
82
- error errMsg
83
- end try
84
- end tell
85
- `;
86
- await execAsync(`osascript -e '${saveScript}'`);
87
- // Verify if file was created successfully
88
- if (!existsSync(tempFilePath)) {
89
- return {
90
- success: false,
91
- error: "Failed to save clipboard image to temporary file",
92
- };
93
- }
94
- return {
95
- success: true,
96
- imagePath: tempFilePath,
97
- mimeType: "image/png",
98
- };
99
- }
100
- catch (error) {
101
- return {
102
- success: false,
103
- error: `Failed to read clipboard image on macOS: ${error instanceof Error ? error.message : String(error)}`,
104
- };
105
- }
106
- }
107
- /**
108
- * Read clipboard image on Windows
109
- */
110
- async function readClipboardImageWindows() {
111
- try {
112
- const { exec } = await import("child_process");
113
- const { promisify } = await import("util");
114
- const execAsync = promisify(exec);
115
- // Use PowerShell to check if clipboard contains image
116
- const checkScript = `
117
- Add-Type -AssemblyName System.Windows.Forms
118
- if ([System.Windows.Forms.Clipboard]::ContainsImage()) {
119
- Write-Output "true"
120
- } else {
121
- Write-Output "false"
122
- }
123
- `;
124
- try {
125
- const { stdout } = await execAsync(`powershell -Command "${checkScript}"`);
126
- const hasImage = stdout.trim() === "true";
127
- if (!hasImage) {
128
- return {
129
- success: false,
130
- error: "No image found in clipboard",
131
- };
132
- }
133
- // Generate temporary file path
134
- const tempFilePath = join(tmpdir(), `clipboard-image-${Date.now()}.png`);
135
- // Use PowerShell to save clipboard image
136
- const saveScript = `
137
- Add-Type -AssemblyName System.Windows.Forms
138
- Add-Type -AssemblyName System.Drawing
139
- $image = [System.Windows.Forms.Clipboard]::GetImage()
140
- if ($image -ne $null) {
141
- $image.Save("${tempFilePath.replace(/\\/g, "\\\\")}", [System.Drawing.Imaging.ImageFormat]::Png)
142
- Write-Output "true"
143
- } else {
144
- Write-Output "false"
145
- }
146
- `;
147
- const { stdout: saveResult } = await execAsync(`powershell -Command "${saveScript}"`);
148
- if (saveResult.trim() !== "true" || !existsSync(tempFilePath)) {
149
- return {
150
- success: false,
151
- error: "Failed to save clipboard image to temporary file",
152
- };
153
- }
154
- return {
155
- success: true,
156
- imagePath: tempFilePath,
157
- mimeType: "image/png",
158
- };
159
- }
160
- catch (err) {
161
- return {
162
- success: false,
163
- error: `Failed to access clipboard on Windows: ${err instanceof Error ? err.message : String(err)}`,
164
- };
165
- }
166
- }
167
- catch (err) {
168
- return {
169
- success: false,
170
- error: `Failed to read clipboard image on Windows: ${err instanceof Error ? err.message : String(err)}`,
171
- };
172
- }
173
- }
174
- /**
175
- * Read clipboard image on Linux
176
- */
177
- async function readClipboardImageLinux() {
178
- try {
179
- // Linux can use tools like xclip or wl-clipboard
180
- const { exec } = await import("child_process");
181
- const { promisify } = await import("util");
182
- const execAsync = promisify(exec);
183
- // Check if xclip is available
184
- try {
185
- await execAsync("which xclip");
186
- }
187
- catch {
188
- return {
189
- success: false,
190
- error: "xclip is required for clipboard image operations on Linux. Please install it: sudo apt-get install xclip",
191
- };
192
- }
193
- // Check if clipboard contains image
194
- try {
195
- await execAsync("xclip -selection clipboard -t image/png -o > /dev/null 2>&1");
196
- }
197
- catch {
198
- return {
199
- success: false,
200
- error: "No image found in clipboard",
201
- };
202
- }
203
- // Generate temporary file path
204
- const tempFilePath = join(tmpdir(), `clipboard-image-${Date.now()}.png`);
205
- // Use xclip to save clipboard image
206
- try {
207
- await execAsync(`xclip -selection clipboard -t image/png -o > "${tempFilePath}"`);
208
- if (!existsSync(tempFilePath)) {
209
- return {
210
- success: false,
211
- error: "Failed to save clipboard image to temporary file",
212
- };
213
- }
214
- return {
215
- success: true,
216
- imagePath: tempFilePath,
217
- mimeType: "image/png",
218
- };
219
- }
220
- catch (err) {
221
- return {
222
- success: false,
223
- error: `Failed to save clipboard image: ${err instanceof Error ? err.message : String(err)}`,
224
- };
225
- }
226
- }
227
- catch (err) {
228
- return {
229
- success: false,
230
- error: `Failed to read clipboard image on Linux: ${err instanceof Error ? err.message : String(err)}`,
231
- };
232
- }
233
- }
234
- /**
235
- * Clean up temporary image file
236
- * @param imagePath Path to the image file to clean up
237
- */
238
- export function cleanupTempImage(imagePath) {
239
- try {
240
- if (existsSync(imagePath)) {
241
- unlinkSync(imagePath);
242
- }
243
- }
244
- catch (error) {
245
- console.warn(`Failed to cleanup temporary image file: ${imagePath}`, error);
246
- }
247
- }
248
- /**
249
- * Check if clipboard contains image (quick check, does not save file)
250
- * @returns Promise<boolean> Whether it contains image
251
- */
252
- export async function hasClipboardImage() {
253
- try {
254
- const platform = process.platform;
255
- if (platform === "darwin") {
256
- return await hasClipboardImageMac();
257
- }
258
- else if (platform === "win32") {
259
- return await hasClipboardImageWindows();
260
- }
261
- else if (platform === "linux") {
262
- return await hasClipboardImageLinux();
263
- }
264
- else {
265
- return false;
266
- }
267
- }
268
- catch {
269
- return false;
270
- }
271
- }
272
- /**
273
- * Check if clipboard contains image on macOS
274
- */
275
- async function hasClipboardImageMac() {
276
- try {
277
- const { exec } = await import("child_process");
278
- const { promisify } = await import("util");
279
- const execAsync = promisify(exec);
280
- const checkScript = `
281
- tell application "System Events"
282
- try
283
- set imageData to the clipboard as «class PNGf»
284
- return true
285
- on error
286
- return false
287
- end try
288
- end tell
289
- `;
290
- const { stdout } = await execAsync(`osascript -e '${checkScript}'`);
291
- return stdout.trim() === "true";
292
- }
293
- catch {
294
- return false;
295
- }
296
- }
297
- /**
298
- * Check if clipboard contains image on Windows
299
- */
300
- async function hasClipboardImageWindows() {
301
- try {
302
- const { exec } = await import("child_process");
303
- const { promisify } = await import("util");
304
- const execAsync = promisify(exec);
305
- const checkScript = `
306
- Add-Type -AssemblyName System.Windows.Forms
307
- if ([System.Windows.Forms.Clipboard]::ContainsImage()) {
308
- Write-Output "true"
309
- } else {
310
- Write-Output "false"
311
- }
312
- `;
313
- const { stdout } = await execAsync(`powershell -Command "${checkScript}"`);
314
- return stdout.trim() === "true";
315
- }
316
- catch {
317
- return false;
318
- }
319
- }
320
- /**
321
- * Check if clipboard contains image on Linux
322
- */
323
- async function hasClipboardImageLinux() {
324
- try {
325
- const { exec } = await import("child_process");
326
- const { promisify } = await import("util");
327
- const execAsync = promisify(exec);
328
- // Check if xclip is available
329
- try {
330
- await execAsync("which xclip");
331
- }
332
- catch {
333
- return false;
334
- }
335
- // Check if clipboard contains image
336
- try {
337
- await execAsync("xclip -selection clipboard -t image/png -o > /dev/null 2>&1");
338
- return true;
339
- }
340
- catch {
341
- return false;
342
- }
343
- }
344
- catch {
345
- return false;
346
- }
347
- }
@@ -1,16 +0,0 @@
1
- /**
2
- * Application constants definition
3
- */
4
- /**
5
- * Application data storage directory
6
- * Used to store debug logs, command history and other data
7
- */
8
- export declare const DATA_DIRECTORY: string;
9
- /**
10
- * Application log file path
11
- */
12
- export declare const LOG_FILE: string;
13
- /**
14
- * Pagination related constants
15
- */
16
- export declare const MESSAGES_PER_PAGE = 15;
@@ -1,18 +0,0 @@
1
- /**
2
- * Application constants definition
3
- */
4
- import path from "path";
5
- import os from "os";
6
- /**
7
- * Application data storage directory
8
- * Used to store debug logs, command history and other data
9
- */
10
- export const DATA_DIRECTORY = path.join(os.homedir(), ".wave");
11
- /**
12
- * Application log file path
13
- */
14
- export const LOG_FILE = path.join(DATA_DIRECTORY, "app.log");
15
- /**
16
- * Pagination related constants
17
- */
18
- export const MESSAGES_PER_PAGE = 15; // Number of messages displayed per page
@@ -1 +0,0 @@
1
- export declare function highlightToAnsi(code: string, language?: string): string;
@@ -1,93 +0,0 @@
1
- import hljs from "highlight.js";
2
- import { parse, HTMLElement, TextNode } from "node-html-parser";
3
- import chalk from "chalk";
4
- const theme = {
5
- "hljs-keyword": chalk.blue,
6
- "hljs-built_in": chalk.cyan,
7
- "hljs-type": chalk.cyan,
8
- "hljs-literal": chalk.magenta,
9
- "hljs-number": chalk.magenta,
10
- "hljs-operator": chalk.white,
11
- "hljs-punctuation": chalk.white,
12
- "hljs-property": chalk.yellow,
13
- "hljs-attr": chalk.yellow,
14
- "hljs-variable": chalk.white,
15
- "hljs-template-variable": chalk.white,
16
- "hljs-string": chalk.green,
17
- "hljs-char": chalk.green,
18
- "hljs-comment": chalk.gray,
19
- "hljs-doctag": chalk.gray,
20
- "hljs-function": chalk.yellow,
21
- "hljs-title": chalk.yellow,
22
- "hljs-params": chalk.white,
23
- "hljs-tag": chalk.blue,
24
- "hljs-name": chalk.blue,
25
- "hljs-selector-tag": chalk.blue,
26
- "hljs-selector-id": chalk.blue,
27
- "hljs-selector-class": chalk.blue,
28
- "hljs-selector-attr": chalk.blue,
29
- "hljs-selector-pseudo": chalk.blue,
30
- "hljs-subst": chalk.white,
31
- "hljs-section": chalk.blue.bold,
32
- "hljs-bullet": chalk.magenta,
33
- "hljs-emphasis": chalk.italic,
34
- "hljs-strong": chalk.bold,
35
- "hljs-addition": chalk.green,
36
- "hljs-deletion": chalk.red,
37
- "hljs-link": chalk.blue.underline,
38
- };
39
- function nodeToAnsi(node) {
40
- if (node instanceof TextNode) {
41
- return node.text;
42
- }
43
- if (node instanceof HTMLElement) {
44
- const content = node.childNodes.map(nodeToAnsi).join("");
45
- const classes = node.getAttribute("class")?.split(/\s+/) || [];
46
- for (const className of classes) {
47
- if (theme[className]) {
48
- return theme[className](content);
49
- }
50
- }
51
- return content;
52
- }
53
- return "";
54
- }
55
- export function highlightToAnsi(code, language) {
56
- if (!code) {
57
- return "";
58
- }
59
- try {
60
- const highlighted = language
61
- ? hljs.highlight(code, { language }).value
62
- : hljs.highlightAuto(code, [
63
- "javascript",
64
- "typescript",
65
- "bash",
66
- "json",
67
- "markdown",
68
- "python",
69
- "yaml",
70
- "html",
71
- "css",
72
- "sql",
73
- "xml",
74
- "rust",
75
- "go",
76
- "java",
77
- "cpp",
78
- "c",
79
- "csharp",
80
- "php",
81
- "ruby",
82
- "swift",
83
- "kotlin",
84
- "toml",
85
- "ini",
86
- ]).value;
87
- const root = parse(highlighted);
88
- return root.childNodes.map(nodeToAnsi).join("");
89
- }
90
- catch {
91
- return code;
92
- }
93
- }
@@ -1,17 +0,0 @@
1
- export declare const expandLongTextPlaceholders: (text: string, longTextMap: Record<string, string>) => string;
2
- export declare const getAtSelectorPosition: (text: string, cursorPosition: number) => number;
3
- export declare const getSlashSelectorPosition: (text: string, cursorPosition: number) => number;
4
- export declare const getWordEnd: (text: string, startPos: number) => number;
5
- export declare const SELECTOR_TRIGGERS: readonly [{
6
- readonly char: "@";
7
- readonly type: "ACTIVATE_FILE_SELECTOR";
8
- readonly shouldActivate: (char: string, pos: number, text: string) => boolean;
9
- }, {
10
- readonly char: "/";
11
- readonly type: "ACTIVATE_COMMAND_SELECTOR";
12
- readonly shouldActivate: (char: string, pos: number, text: string, showFileSelector: boolean) => boolean;
13
- }];
14
- export declare const getProjectedState: (inputText: string, cursorPosition: number, char: string) => {
15
- newInputText: string;
16
- newCursorPosition: number;
17
- };