wave-code 0.12.0 → 0.12.2

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 (66) hide show
  1. package/README.md +9 -51
  2. package/dist/acp/agent.js +1 -1
  3. package/dist/components/App.d.ts +1 -0
  4. package/dist/components/App.d.ts.map +1 -1
  5. package/dist/components/App.js +5 -2
  6. package/dist/components/BackgroundTaskManager.d.ts.map +1 -1
  7. package/dist/components/BackgroundTaskManager.js +2 -1
  8. package/dist/components/BangDisplay.d.ts.map +1 -1
  9. package/dist/components/BangDisplay.js +2 -14
  10. package/dist/components/ChatInterface.d.ts.map +1 -1
  11. package/dist/components/ChatInterface.js +17 -27
  12. package/dist/components/ConfirmationDetails.d.ts +0 -1
  13. package/dist/components/ConfirmationDetails.d.ts.map +1 -1
  14. package/dist/components/ConfirmationDetails.js +4 -12
  15. package/dist/components/ConfirmationSelector.d.ts +0 -1
  16. package/dist/components/ConfirmationSelector.d.ts.map +1 -1
  17. package/dist/components/ConfirmationSelector.js +4 -12
  18. package/dist/components/DiffDisplay.d.ts.map +1 -1
  19. package/dist/components/DiffDisplay.js +2 -23
  20. package/dist/components/MessageList.d.ts +1 -2
  21. package/dist/components/MessageList.d.ts.map +1 -1
  22. package/dist/components/MessageList.js +12 -17
  23. package/dist/components/RewindCommand.d.ts.map +1 -1
  24. package/dist/components/RewindCommand.js +2 -4
  25. package/dist/components/StatusCommand.d.ts.map +1 -1
  26. package/dist/components/StatusCommand.js +1 -1
  27. package/dist/components/ToolDisplay.d.ts.map +1 -1
  28. package/dist/components/ToolDisplay.js +3 -6
  29. package/dist/contexts/useChat.d.ts +0 -2
  30. package/dist/contexts/useChat.d.ts.map +1 -1
  31. package/dist/contexts/useChat.js +27 -44
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +10 -0
  34. package/dist/utils/highlightUtils.d.ts.map +1 -1
  35. package/dist/utils/highlightUtils.js +0 -8
  36. package/dist/utils/logger.d.ts.map +1 -1
  37. package/dist/utils/logger.js +13 -11
  38. package/dist/utils/throttle.d.ts +15 -0
  39. package/dist/utils/throttle.d.ts.map +1 -0
  40. package/dist/utils/throttle.js +55 -0
  41. package/dist/utils/toolParameterTransforms.d.ts +5 -1
  42. package/dist/utils/toolParameterTransforms.d.ts.map +1 -1
  43. package/dist/utils/toolParameterTransforms.js +14 -0
  44. package/dist/utils/worktree.d.ts +0 -1
  45. package/dist/utils/worktree.d.ts.map +1 -1
  46. package/dist/utils/worktree.js +2 -2
  47. package/package.json +3 -3
  48. package/src/acp/agent.ts +1 -1
  49. package/src/components/App.tsx +6 -2
  50. package/src/components/BackgroundTaskManager.tsx +3 -6
  51. package/src/components/BangDisplay.tsx +4 -22
  52. package/src/components/ChatInterface.tsx +18 -33
  53. package/src/components/ConfirmationDetails.tsx +2 -15
  54. package/src/components/ConfirmationSelector.tsx +3 -15
  55. package/src/components/DiffDisplay.tsx +2 -27
  56. package/src/components/MessageList.tsx +17 -20
  57. package/src/components/RewindCommand.tsx +3 -5
  58. package/src/components/StatusCommand.tsx +7 -0
  59. package/src/components/ToolDisplay.tsx +3 -6
  60. package/src/contexts/useChat.tsx +34 -59
  61. package/src/index.ts +13 -0
  62. package/src/utils/highlightUtils.ts +0 -8
  63. package/src/utils/logger.ts +12 -14
  64. package/src/utils/throttle.ts +75 -0
  65. package/src/utils/toolParameterTransforms.ts +23 -1
  66. package/src/utils/worktree.ts +7 -3
@@ -10,6 +10,7 @@
10
10
 
11
11
  import * as fs from "fs";
12
12
  import { Chalk } from "chalk";
13
+ import { getLastLines } from "wave-agent-sdk";
13
14
  import { LOG_FILE, DATA_DIRECTORY } from "./constants.js";
14
15
 
15
16
  const chalk = new Chalk({ level: 3 });
@@ -124,21 +125,23 @@ const formatArg = (arg: unknown): string => {
124
125
  if (arg === null) return "null";
125
126
  if (arg === undefined) return "undefined";
126
127
 
128
+ let result: string;
127
129
  if (arg instanceof Error) {
128
130
  // Special handling for Error objects, display stack or message
129
- return arg.stack || arg.message || String(arg);
130
- }
131
-
132
- if (typeof arg === "object") {
131
+ result = arg.stack || arg.message || String(arg);
132
+ } else if (typeof arg === "object") {
133
133
  try {
134
- return JSON.stringify(arg, null, 2);
134
+ result = JSON.stringify(arg);
135
135
  } catch {
136
136
  // If JSON.stringify fails, fallback to String()
137
- return String(arg);
137
+ result = String(arg);
138
138
  }
139
+ } else {
140
+ result = String(arg);
139
141
  }
140
142
 
141
- return String(arg);
143
+ // Ensure no newlines in the result to keep log entries single-line
144
+ return result.replace(/[\n\r]+/g, " ");
142
145
  };
143
146
 
144
147
  /**
@@ -267,19 +270,14 @@ const truncateLogFileIfNeeded = (config: LogCleanupConfig): void => {
267
270
  // If file size exceeds limit, truncate file
268
271
  if (stats.size > config.maxFileSize) {
269
272
  const content = fs.readFileSync(logFile, "utf8");
270
- const lines = content.split("\n");
271
-
272
- // Keep the last specified number of lines
273
- const keepLines = Math.min(config.keepLines, lines.length);
274
- const truncatedContent = lines.slice(-keepLines).join("\n");
273
+ const truncatedContent = getLastLines(content, config.keepLines);
275
274
 
276
275
  // Write truncated content
277
276
  fs.writeFileSync(logFile, truncatedContent);
278
277
 
279
278
  // Record truncation operation
280
- const removedLines = lines.length - keepLines;
281
279
  logger.debug(
282
- `Log file truncated: removed ${removedLines} lines, kept last ${keepLines} lines`,
280
+ `Log file truncated: file size ${stats.size} exceeded limit ${config.maxFileSize}, kept last ${config.keepLines} lines`,
283
281
  );
284
282
  }
285
283
  } catch (error) {
@@ -0,0 +1,75 @@
1
+ export interface ThrottleOptions {
2
+ leading?: boolean;
3
+ trailing?: boolean;
4
+ }
5
+
6
+ export interface ThrottledFunction<T extends (...args: unknown[]) => void> {
7
+ (...args: Parameters<T>): void;
8
+ cancel: () => void;
9
+ flush: () => void;
10
+ }
11
+
12
+ /**
13
+ * Creates a throttled function that only invokes `func` at most once per
14
+ * every `wait` milliseconds.
15
+ */
16
+ export function throttle<T extends (...args: unknown[]) => void>(
17
+ func: T,
18
+ wait: number,
19
+ options: ThrottleOptions = { leading: true, trailing: true },
20
+ ): ThrottledFunction<T> {
21
+ let timeoutId: NodeJS.Timeout | null = null;
22
+ let lastArgs: Parameters<T> | null = null;
23
+ let lastCallTime = 0;
24
+
25
+ const invokeFunc = () => {
26
+ if (lastArgs) {
27
+ func(...lastArgs);
28
+ lastCallTime = Date.now();
29
+ lastArgs = null;
30
+ }
31
+ };
32
+
33
+ const throttled = (...args: Parameters<T>) => {
34
+ const now = Date.now();
35
+ const remaining = wait - (now - lastCallTime);
36
+
37
+ lastArgs = args;
38
+
39
+ if (remaining <= 0 || remaining > wait) {
40
+ if (timeoutId) {
41
+ clearTimeout(timeoutId);
42
+ timeoutId = null;
43
+ }
44
+ if (options.leading !== false || lastCallTime !== 0) {
45
+ invokeFunc();
46
+ } else {
47
+ lastCallTime = now;
48
+ }
49
+ } else if (!timeoutId && options.trailing !== false) {
50
+ timeoutId = setTimeout(() => {
51
+ timeoutId = null;
52
+ invokeFunc();
53
+ }, remaining);
54
+ }
55
+ };
56
+
57
+ throttled.cancel = () => {
58
+ if (timeoutId) {
59
+ clearTimeout(timeoutId);
60
+ timeoutId = null;
61
+ }
62
+ lastArgs = null;
63
+ lastCallTime = 0;
64
+ };
65
+
66
+ throttled.flush = () => {
67
+ if (timeoutId) {
68
+ clearTimeout(timeoutId);
69
+ timeoutId = null;
70
+ }
71
+ invokeFunc();
72
+ };
73
+
74
+ return throttled as ThrottledFunction<T>;
75
+ }
@@ -3,7 +3,11 @@
3
3
  * Forces type judgment based on tool name using type assertions
4
4
  */
5
5
 
6
- import { type Change, type EditToolParameters } from "wave-agent-sdk";
6
+ import {
7
+ type Change,
8
+ type WriteToolParameters,
9
+ type EditToolParameters,
10
+ } from "wave-agent-sdk";
7
11
  import { logger } from "./logger.js";
8
12
 
9
13
  /**
@@ -22,6 +26,20 @@ function parseToolParameters(parameters: string): unknown {
22
26
  }
23
27
  }
24
28
 
29
+ /**
30
+ * Transform Write tool parameters to changes
31
+ */
32
+ export function transformWriteParameters(
33
+ parameters: WriteToolParameters,
34
+ ): Change[] {
35
+ return [
36
+ {
37
+ oldContent: "", // No previous content for write operations
38
+ newContent: parameters.content,
39
+ },
40
+ ];
41
+ }
42
+
25
43
  /**
26
44
  * Transform Edit tool parameters to changes
27
45
  */
@@ -54,6 +72,10 @@ export function transformToolBlockToChanges(
54
72
 
55
73
  let changes: Change[] = [];
56
74
  switch (toolName) {
75
+ case "Write":
76
+ changes = transformWriteParameters(parsedParams as WriteToolParameters);
77
+ break;
78
+
57
79
  case "Edit":
58
80
  changes = transformEditParameters(parsedParams as EditToolParameters);
59
81
  break;
@@ -13,8 +13,6 @@ export interface WorktreeSession {
13
13
  isNew: boolean;
14
14
  }
15
15
 
16
- export const WORKTREE_DIR = ".wave/worktrees";
17
-
18
16
  /**
19
17
  * Create a new git worktree
20
18
  * @param name Worktree name
@@ -23,7 +21,13 @@ export const WORKTREE_DIR = ".wave/worktrees";
23
21
  */
24
22
  export function createWorktree(name: string, cwd: string): WorktreeSession {
25
23
  const repoRoot = getGitMainRepoRoot(cwd);
26
- const worktreePath = path.join(repoRoot, WORKTREE_DIR, name);
24
+ const projectName = path.basename(repoRoot);
25
+ const worktreePath = path.join(
26
+ repoRoot,
27
+ "..",
28
+ `${projectName}.worktrees`,
29
+ name,
30
+ );
27
31
  const branchName = `worktree-${name}`;
28
32
  const baseBranch = getDefaultRemoteBranch(cwd);
29
33