wave-code 0.6.5 → 0.7.1

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 (101) hide show
  1. package/dist/cli.d.ts +1 -0
  2. package/dist/cli.d.ts.map +1 -1
  3. package/dist/cli.js +2 -2
  4. package/dist/commands/plugin/disable.d.ts.map +1 -1
  5. package/dist/commands/plugin/disable.js +3 -10
  6. package/dist/commands/plugin/enable.d.ts.map +1 -1
  7. package/dist/commands/plugin/enable.js +3 -10
  8. package/dist/commands/plugin/install.d.ts.map +1 -1
  9. package/dist/commands/plugin/install.js +4 -11
  10. package/dist/commands/plugin/list.d.ts.map +1 -1
  11. package/dist/commands/plugin/list.js +5 -39
  12. package/dist/commands/plugin/marketplace.js +9 -9
  13. package/dist/commands/plugin/uninstall.d.ts.map +1 -1
  14. package/dist/commands/plugin/uninstall.js +4 -17
  15. package/dist/commands/plugin/update.js +3 -3
  16. package/dist/components/App.d.ts +1 -0
  17. package/dist/components/App.d.ts.map +1 -1
  18. package/dist/components/App.js +4 -4
  19. package/dist/components/BackgroundTaskManager.d.ts.map +1 -1
  20. package/dist/components/BackgroundTaskManager.js +34 -18
  21. package/dist/components/ChatInterface.d.ts.map +1 -1
  22. package/dist/components/ChatInterface.js +28 -15
  23. package/dist/components/ConfirmationDetails.d.ts +1 -0
  24. package/dist/components/ConfirmationDetails.d.ts.map +1 -1
  25. package/dist/components/ConfirmationDetails.js +7 -14
  26. package/dist/components/ConfirmationSelector.d.ts +1 -0
  27. package/dist/components/ConfirmationSelector.d.ts.map +1 -1
  28. package/dist/components/ConfirmationSelector.js +164 -117
  29. package/dist/components/DiffDisplay.d.ts +1 -0
  30. package/dist/components/DiffDisplay.d.ts.map +1 -1
  31. package/dist/components/DiffDisplay.js +94 -36
  32. package/dist/components/HistorySearch.d.ts.map +1 -1
  33. package/dist/components/HistorySearch.js +26 -20
  34. package/dist/components/Markdown.d.ts.map +1 -1
  35. package/dist/components/Markdown.js +3 -1
  36. package/dist/components/McpManager.d.ts.map +1 -1
  37. package/dist/components/McpManager.js +49 -52
  38. package/dist/components/MessageBlockItem.d.ts +9 -0
  39. package/dist/components/MessageBlockItem.d.ts.map +1 -0
  40. package/dist/components/MessageBlockItem.js +11 -0
  41. package/dist/components/MessageList.d.ts +2 -4
  42. package/dist/components/MessageList.d.ts.map +1 -1
  43. package/dist/components/MessageList.js +28 -23
  44. package/dist/components/PluginDetail.d.ts.map +1 -1
  45. package/dist/components/PluginDetail.js +19 -22
  46. package/dist/components/SessionSelector.d.ts.map +1 -1
  47. package/dist/components/SessionSelector.js +8 -5
  48. package/dist/components/TaskList.d.ts.map +1 -1
  49. package/dist/components/TaskList.js +2 -5
  50. package/dist/components/ToolDisplay.d.ts.map +1 -1
  51. package/dist/components/ToolDisplay.js +1 -1
  52. package/dist/contexts/useChat.d.ts +1 -0
  53. package/dist/contexts/useChat.d.ts.map +1 -1
  54. package/dist/contexts/useChat.js +20 -3
  55. package/dist/hooks/usePluginManager.d.ts.map +1 -1
  56. package/dist/hooks/usePluginManager.js +20 -39
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/index.js +16 -0
  59. package/dist/print-cli.d.ts +1 -0
  60. package/dist/print-cli.d.ts.map +1 -1
  61. package/dist/print-cli.js +2 -1
  62. package/dist/utils/highlightUtils.d.ts +2 -0
  63. package/dist/utils/highlightUtils.d.ts.map +1 -0
  64. package/dist/utils/highlightUtils.js +69 -0
  65. package/dist/utils/toolParameterTransforms.d.ts +2 -6
  66. package/dist/utils/toolParameterTransforms.d.ts.map +1 -1
  67. package/dist/utils/toolParameterTransforms.js +10 -14
  68. package/package.json +4 -2
  69. package/src/cli.tsx +3 -0
  70. package/src/commands/plugin/disable.ts +3 -17
  71. package/src/commands/plugin/enable.ts +3 -17
  72. package/src/commands/plugin/install.ts +4 -18
  73. package/src/commands/plugin/list.ts +5 -55
  74. package/src/commands/plugin/marketplace.ts +9 -9
  75. package/src/commands/plugin/uninstall.ts +4 -26
  76. package/src/commands/plugin/update.ts +3 -3
  77. package/src/components/App.tsx +10 -2
  78. package/src/components/BackgroundTaskManager.tsx +69 -44
  79. package/src/components/ChatInterface.tsx +35 -23
  80. package/src/components/ConfirmationDetails.tsx +13 -15
  81. package/src/components/ConfirmationSelector.tsx +207 -128
  82. package/src/components/DiffDisplay.tsx +164 -75
  83. package/src/components/HistorySearch.tsx +31 -25
  84. package/src/components/Markdown.tsx +3 -1
  85. package/src/components/McpManager.tsx +51 -59
  86. package/src/components/MessageBlockItem.tsx +83 -0
  87. package/src/components/MessageList.tsx +55 -52
  88. package/src/components/PluginDetail.tsx +30 -31
  89. package/src/components/SessionSelector.tsx +8 -5
  90. package/src/components/TaskList.tsx +2 -5
  91. package/src/components/ToolDisplay.tsx +5 -1
  92. package/src/contexts/useChat.tsx +22 -2
  93. package/src/hooks/usePluginManager.ts +21 -57
  94. package/src/index.ts +17 -0
  95. package/src/print-cli.ts +3 -0
  96. package/src/utils/highlightUtils.ts +76 -0
  97. package/src/utils/toolParameterTransforms.ts +11 -20
  98. package/dist/components/MessageItem.d.ts +0 -8
  99. package/dist/components/MessageItem.d.ts.map +0 -1
  100. package/dist/components/MessageItem.js +0 -13
  101. package/src/components/MessageItem.tsx +0 -81
package/src/index.ts CHANGED
@@ -43,6 +43,12 @@ export async function main() {
43
43
  string: true,
44
44
  global: false,
45
45
  })
46
+ .option("tools", {
47
+ description:
48
+ 'Specify a comma-separated list of tools to enable (e.g., \'Bash,Read,Write\'). Use "" to disable all, "default" for all.',
49
+ type: "string",
50
+ global: false,
51
+ })
46
52
  .command(
47
53
  "plugin",
48
54
  "Manage plugins and marketplaces",
@@ -217,6 +223,14 @@ export async function main() {
217
223
  .strict()
218
224
  .parseAsync();
219
225
 
226
+ const parseTools = (tools: string | undefined): string[] | undefined => {
227
+ if (tools === undefined || tools === "default") return undefined;
228
+ if (tools === "") return [];
229
+ return tools.split(",").map((t) => t.trim());
230
+ };
231
+
232
+ const tools = parseTools(argv.tools as string | undefined);
233
+
220
234
  // Handle restore session command
221
235
  if (
222
236
  argv.restore === "" ||
@@ -236,6 +250,7 @@ export async function main() {
236
250
  restoreSessionId: selectedSessionId,
237
251
  bypassPermissions: argv.dangerouslySkipPermissions,
238
252
  pluginDirs: argv.pluginDir as string[],
253
+ tools,
239
254
  });
240
255
  }
241
256
 
@@ -249,6 +264,7 @@ export async function main() {
249
264
  showStats: argv.showStats,
250
265
  bypassPermissions: argv.dangerouslySkipPermissions,
251
266
  pluginDirs: argv.pluginDir as string[],
267
+ tools,
252
268
  });
253
269
  }
254
270
 
@@ -257,6 +273,7 @@ export async function main() {
257
273
  continueLastSession: argv.continue,
258
274
  bypassPermissions: argv.dangerouslySkipPermissions,
259
275
  pluginDirs: argv.pluginDir as string[],
276
+ tools,
260
277
  });
261
278
  } catch (error) {
262
279
  console.error("Failed to start WAVE Code:", error);
package/src/print-cli.ts CHANGED
@@ -8,6 +8,7 @@ export interface PrintCliOptions {
8
8
  showStats?: boolean;
9
9
  bypassPermissions?: boolean;
10
10
  pluginDirs?: string[];
11
+ tools?: string[];
11
12
  }
12
13
 
13
14
  function displayTimingInfo(startTime: Date, showStats: boolean): void {
@@ -33,6 +34,7 @@ export async function startPrintCli(options: PrintCliOptions): Promise<void> {
33
34
  showStats = false,
34
35
  bypassPermissions,
35
36
  pluginDirs,
37
+ tools,
36
38
  } = options;
37
39
 
38
40
  if (
@@ -136,6 +138,7 @@ export async function startPrintCli(options: PrintCliOptions): Promise<void> {
136
138
  continueLastSession,
137
139
  permissionMode: bypassPermissions ? "bypassPermissions" : undefined,
138
140
  plugins: pluginDirs?.map((path) => ({ type: "local", path })),
141
+ tools,
139
142
  // 保持流式模式以获得更好的命令行用户体验
140
143
  });
141
144
 
@@ -0,0 +1,76 @@
1
+ import hljs from 'highlight.js';
2
+ import { parse, Node, HTMLElement, TextNode } from 'node-html-parser';
3
+ import chalk from 'chalk';
4
+
5
+ const theme: Record<string, (text: string) => string> = {
6
+ 'hljs-keyword': chalk.blue,
7
+ 'hljs-built_in': chalk.cyan,
8
+ 'hljs-type': chalk.cyan,
9
+ 'hljs-literal': chalk.magenta,
10
+ 'hljs-number': chalk.magenta,
11
+ 'hljs-operator': chalk.white,
12
+ 'hljs-punctuation': chalk.white,
13
+ 'hljs-property': chalk.yellow,
14
+ 'hljs-attr': chalk.yellow,
15
+ 'hljs-variable': chalk.white,
16
+ 'hljs-template-variable': chalk.white,
17
+ 'hljs-string': chalk.green,
18
+ 'hljs-char': chalk.green,
19
+ 'hljs-comment': chalk.gray,
20
+ 'hljs-doctag': chalk.gray,
21
+ 'hljs-function': chalk.yellow,
22
+ 'hljs-title': chalk.yellow,
23
+ 'hljs-params': chalk.white,
24
+ 'hljs-tag': chalk.blue,
25
+ 'hljs-name': chalk.blue,
26
+ 'hljs-selector-tag': chalk.blue,
27
+ 'hljs-selector-id': chalk.blue,
28
+ 'hljs-selector-class': chalk.blue,
29
+ 'hljs-selector-attr': chalk.blue,
30
+ 'hljs-selector-pseudo': chalk.blue,
31
+ 'hljs-subst': chalk.white,
32
+ 'hljs-section': chalk.blue.bold,
33
+ 'hljs-bullet': chalk.magenta,
34
+ 'hljs-emphasis': chalk.italic,
35
+ 'hljs-strong': chalk.bold,
36
+ 'hljs-addition': chalk.green,
37
+ 'hljs-deletion': chalk.red,
38
+ 'hljs-link': chalk.blue.underline,
39
+ };
40
+
41
+ function nodeToAnsi(node: Node): string {
42
+ if (node instanceof TextNode) {
43
+ return node.text;
44
+ }
45
+
46
+ if (node instanceof HTMLElement) {
47
+ const content = node.childNodes.map(nodeToAnsi).join('');
48
+ const classes = node.getAttribute('class')?.split(/\s+/) || [];
49
+
50
+ for (const className of classes) {
51
+ if (theme[className]) {
52
+ return theme[className](content);
53
+ }
54
+ }
55
+
56
+ return content;
57
+ }
58
+
59
+ return '';
60
+ }
61
+
62
+ export function highlightToAnsi(code: string, language?: string): string {
63
+ if (!code) {
64
+ return '';
65
+ }
66
+ try {
67
+ const highlighted = language
68
+ ? hljs.highlight(code, { language }).value
69
+ : hljs.highlightAuto(code).value;
70
+
71
+ const root = parse(highlighted);
72
+ return root.childNodes.map(nodeToAnsi).join('');
73
+ } catch {
74
+ return code;
75
+ }
76
+ }
@@ -7,7 +7,6 @@ import {
7
7
  type Change,
8
8
  type WriteToolParameters,
9
9
  type EditToolParameters,
10
- type MultiEditToolParameters,
11
10
  } from "wave-agent-sdk";
12
11
  import { logger } from "./logger.js";
13
12
 
@@ -55,18 +54,6 @@ export function transformEditParameters(
55
54
  ];
56
55
  }
57
56
 
58
- /**
59
- * Transform MultiEdit tool parameters to changes
60
- */
61
- export function transformMultiEditParameters(
62
- parameters: MultiEditToolParameters,
63
- ): Change[] {
64
- return parameters.edits.map((edit) => ({
65
- oldContent: edit.old_string,
66
- newContent: edit.new_string,
67
- }));
68
- }
69
-
70
57
  /**
71
58
  * Transform tool block parameters into standardized Change[] array for diff display
72
59
  * Forces type judgment based on tool name using type assertions
@@ -74,6 +61,7 @@ export function transformMultiEditParameters(
74
61
  export function transformToolBlockToChanges(
75
62
  toolName: string,
76
63
  parameters: string,
64
+ startLineNumber?: number,
77
65
  ): Change[] {
78
66
  try {
79
67
  if (!toolName) {
@@ -82,21 +70,24 @@ export function transformToolBlockToChanges(
82
70
 
83
71
  const parsedParams = parseToolParameters(parameters);
84
72
 
73
+ let changes: Change[] = [];
85
74
  switch (toolName) {
86
75
  case "Write":
87
- return transformWriteParameters(parsedParams as WriteToolParameters);
76
+ changes = transformWriteParameters(parsedParams as WriteToolParameters);
77
+ break;
88
78
 
89
79
  case "Edit":
90
- return transformEditParameters(parsedParams as EditToolParameters);
91
-
92
- case "MultiEdit":
93
- return transformMultiEditParameters(
94
- parsedParams as MultiEditToolParameters,
95
- );
80
+ changes = transformEditParameters(parsedParams as EditToolParameters);
81
+ break;
96
82
 
97
83
  default:
98
84
  return [];
99
85
  }
86
+
87
+ if (changes.length > 0 && startLineNumber !== undefined) {
88
+ changes[0].startLineNumber = startLineNumber;
89
+ }
90
+ return changes;
100
91
  } catch (error) {
101
92
  logger.warn("Failed to transform tool block to changes:", error);
102
93
  return [];
@@ -1,8 +0,0 @@
1
- import type { Message } from "wave-agent-sdk";
2
- export interface MessageItemProps {
3
- message: Message;
4
- isExpanded: boolean;
5
- shouldShowHeader: boolean;
6
- }
7
- export declare const MessageItem: ({ message, isExpanded }: MessageItemProps) => import("react/jsx-runtime").JSX.Element | null;
8
- //# sourceMappingURL=MessageItem.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MessageItem.d.ts","sourceRoot":"","sources":["../../src/components/MessageItem.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAQ9C,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED,eAAO,MAAM,WAAW,GAAI,yBAAyB,gBAAgB,mDAgEpE,CAAC"}
@@ -1,13 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Box, Text } from "ink";
3
- import { MessageSource } from "wave-agent-sdk";
4
- import { CommandOutputDisplay } from "./CommandOutputDisplay.js";
5
- import { ToolDisplay } from "./ToolDisplay.js";
6
- import { CompressDisplay } from "./CompressDisplay.js";
7
- import { ReasoningDisplay } from "./ReasoningDisplay.js";
8
- import { Markdown } from "./Markdown.js";
9
- export const MessageItem = ({ message, isExpanded }) => {
10
- if (message.blocks.length === 0)
11
- return null;
12
- return (_jsx(Box, { flexDirection: "column", gap: 1, marginTop: 1, children: _jsx(Box, { flexDirection: "column", gap: 1, children: message.blocks.map((block, blockIndex) => (_jsxs(Box, { children: [block.type === "text" && block.content.trim() && (_jsxs(Box, { children: [block.customCommandContent && (_jsx(Text, { color: "cyan", bold: true, children: "$ " })), block.source === MessageSource.HOOK && (_jsx(Text, { color: "magenta", bold: true, children: "~ " })), message.role === "user" ? (_jsx(Text, { backgroundColor: "gray", color: "white", children: block.content })) : (_jsx(Markdown, { children: block.content }))] })), block.type === "error" && (_jsx(Box, { children: _jsxs(Text, { color: "red", children: ["Error: ", block.content] }) })), block.type === "command_output" && (_jsx(CommandOutputDisplay, { block: block, isExpanded: isExpanded })), block.type === "tool" && (_jsx(ToolDisplay, { block: block, isExpanded: isExpanded })), block.type === "image" && (_jsxs(Box, { children: [_jsx(Text, { color: "magenta", bold: true, children: "# Image" }), block.imageUrls && block.imageUrls.length > 0 && (_jsxs(Text, { color: "gray", dimColor: true, children: [" ", "(", block.imageUrls.length, ")"] }))] })), block.type === "compress" && (_jsx(CompressDisplay, { block: block, isExpanded: isExpanded })), block.type === "reasoning" && _jsx(ReasoningDisplay, { block: block })] }, blockIndex))) }) }));
13
- };
@@ -1,81 +0,0 @@
1
- import React from "react";
2
- import { Box, Text } from "ink";
3
- import type { Message } from "wave-agent-sdk";
4
- import { MessageSource } from "wave-agent-sdk";
5
- import { CommandOutputDisplay } from "./CommandOutputDisplay.js";
6
- import { ToolDisplay } from "./ToolDisplay.js";
7
- import { CompressDisplay } from "./CompressDisplay.js";
8
- import { ReasoningDisplay } from "./ReasoningDisplay.js";
9
- import { Markdown } from "./Markdown.js";
10
-
11
- export interface MessageItemProps {
12
- message: Message;
13
- isExpanded: boolean;
14
- shouldShowHeader: boolean;
15
- }
16
-
17
- export const MessageItem = ({ message, isExpanded }: MessageItemProps) => {
18
- if (message.blocks.length === 0) return null;
19
-
20
- return (
21
- <Box flexDirection="column" gap={1} marginTop={1}>
22
- <Box flexDirection="column" gap={1}>
23
- {message.blocks.map((block, blockIndex) => (
24
- <Box key={blockIndex}>
25
- {block.type === "text" && block.content.trim() && (
26
- <Box>
27
- {block.customCommandContent && (
28
- <Text color="cyan" bold>$ </Text>
29
- )}
30
- {block.source === MessageSource.HOOK && (
31
- <Text color="magenta" bold>~ </Text>
32
- )}
33
- {message.role === "user" ? (
34
- <Text backgroundColor="gray" color="white">
35
- {block.content}
36
- </Text>
37
- ) : (
38
- <Markdown>{block.content}</Markdown>
39
- )}
40
- </Box>
41
- )}
42
-
43
- {block.type === "error" && (
44
- <Box>
45
- <Text color="red">Error: {block.content}</Text>
46
- </Box>
47
- )}
48
-
49
- {block.type === "command_output" && (
50
- <CommandOutputDisplay block={block} isExpanded={isExpanded} />
51
- )}
52
-
53
- {block.type === "tool" && (
54
- <ToolDisplay block={block} isExpanded={isExpanded} />
55
- )}
56
-
57
- {block.type === "image" && (
58
- <Box>
59
- <Text color="magenta" bold>
60
- # Image
61
- </Text>
62
- {block.imageUrls && block.imageUrls.length > 0 && (
63
- <Text color="gray" dimColor>
64
- {" "}
65
- ({block.imageUrls.length})
66
- </Text>
67
- )}
68
- </Box>
69
- )}
70
-
71
- {block.type === "compress" && (
72
- <CompressDisplay block={block} isExpanded={isExpanded} />
73
- )}
74
-
75
- {block.type === "reasoning" && <ReasoningDisplay block={block} />}
76
- </Box>
77
- ))}
78
- </Box>
79
- </Box>
80
- );
81
- };