codeep 1.2.54 → 1.2.56

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.
@@ -144,6 +144,10 @@ export interface SessionUpdateToolCall {
144
144
  locations?: {
145
145
  path: string;
146
146
  }[];
147
+ content?: {
148
+ oldText?: string;
149
+ newText?: string;
150
+ };
147
151
  }
148
152
  export interface SessionUpdateToolCallUpdate {
149
153
  sessionUpdate: 'tool_call_update';
@@ -440,7 +440,7 @@ export function startAcpServer() {
440
440
  },
441
441
  });
442
442
  },
443
- onToolCall: (toolCallId, toolName, kind, title, status, locations) => {
443
+ onToolCall: (toolCallId, toolName, kind, title, status, locations, rawOutput, content) => {
444
444
  if (status === 'running') {
445
445
  // Initial tool_call notification: spec ToolCall shape
446
446
  transport.notify('session/update', {
@@ -454,17 +454,19 @@ export function startAcpServer() {
454
454
  ...(locations && locations.length > 0
455
455
  ? { locations: locations.map(path => ({ path })) }
456
456
  : {}),
457
+ ...(content ? { content } : {}),
457
458
  },
458
459
  });
459
460
  }
460
461
  else {
461
- // tool_call_update: update status to completed/failed
462
+ // tool_call_update: update status to completed/failed, with optional content
462
463
  transport.notify('session/update', {
463
464
  sessionId: params.sessionId,
464
465
  update: {
465
466
  sessionUpdate: 'tool_call_update',
466
467
  toolCallId,
467
468
  status: status === 'finished' ? 'completed' : 'failed',
469
+ ...(rawOutput !== undefined ? { rawOutput } : {}),
468
470
  },
469
471
  });
470
472
  }
@@ -6,7 +6,10 @@ export interface AgentSessionOptions {
6
6
  abortSignal: AbortSignal;
7
7
  onChunk: (text: string) => void;
8
8
  onThought?: (text: string) => void;
9
- onToolCall?: (toolCallId: string, toolName: string, kind: string, title: string, status: 'pending' | 'running' | 'finished' | 'error', locations?: string[]) => void;
9
+ onToolCall?: (toolCallId: string, toolName: string, kind: string, title: string, status: 'pending' | 'running' | 'finished' | 'error', locations?: string[], rawOutput?: string, content?: {
10
+ oldText?: string;
11
+ newText?: string;
12
+ }) => void;
10
13
  }
11
14
  /**
12
15
  * Build a ProjectContext from a workspace root directory.
@@ -44,6 +44,53 @@ function toolCallMeta(toolName, params, workspaceRoot) {
44
44
  default: return { kind: 'other', title: toolName };
45
45
  }
46
46
  }
47
+ // Builds ToolCallContent (oldText/newText) for Zed's diff view in the tool_call card.
48
+ function buildToolCallContent(toolName, params) {
49
+ switch (toolName) {
50
+ case 'write_file': {
51
+ const content = params.content ?? '';
52
+ return content ? { newText: content } : undefined;
53
+ }
54
+ case 'edit_file': {
55
+ const oldText = params.old_text ?? '';
56
+ const newText = params.new_text ?? '';
57
+ if (!oldText && !newText)
58
+ return undefined;
59
+ return { oldText: oldText || undefined, newText: newText || undefined };
60
+ }
61
+ default:
62
+ return undefined;
63
+ }
64
+ }
65
+ // Builds rawOutput content to display inside tool call cards.
66
+ // For write/edit operations, returns the code content or diff.
67
+ // For command execution, returns the command output.
68
+ function buildRawOutput(toolName, params, toolResult) {
69
+ switch (toolName) {
70
+ case 'write_file': {
71
+ const content = params.content ?? '';
72
+ return content || undefined;
73
+ }
74
+ case 'edit_file': {
75
+ const oldText = params.old_text ?? '';
76
+ const newText = params.new_text ?? '';
77
+ if (!oldText && !newText)
78
+ return undefined;
79
+ // Format as a simple before/after diff block
80
+ const oldLines = oldText.split('\n').map(l => `- ${l}`).join('\n');
81
+ const newLines = newText.split('\n').map(l => `+ ${l}`).join('\n');
82
+ return `${oldLines}\n${newLines}`;
83
+ }
84
+ case 'run_command': {
85
+ return toolResult.output || toolResult.error || undefined;
86
+ }
87
+ case 'read_file': {
88
+ return toolResult.output || undefined;
89
+ }
90
+ default:
91
+ return undefined;
92
+ }
93
+ }
47
94
  export async function runAgentSession(opts) {
48
95
  const projectContext = buildProjectContext(opts.workspaceRoot);
49
96
  let toolCallCounter = 0;
@@ -79,8 +126,9 @@ export async function runAgentSession(opts) {
79
126
  // Track this tool call so onToolResult can emit finished/error
80
127
  const mapKey = toolCall.id ?? `${name}_${toolCallCounter}`;
81
128
  toolCallIdMap.set(mapKey, { toolCallId, kind, locations: locations.length ? locations : undefined });
82
- // Emit tool_call notification (running state)
83
- opts.onToolCall?.(toolCallId, name, kind, title, 'running', locations.length ? locations : undefined);
129
+ // Emit tool_call notification (running state) with optional diff content
130
+ const toolContent = buildToolCallContent(name, params);
131
+ opts.onToolCall?.(toolCallId, name, kind, title, 'running', locations.length ? locations : undefined, undefined, toolContent);
84
132
  },
85
133
  onToolResult: (toolResult, toolCall) => {
86
134
  // Find the tracked entry: prefer exact id match, then first FIFO entry for same tool name
@@ -101,7 +149,8 @@ export async function runAgentSession(opts) {
101
149
  const tracked = toolCallIdMap.get(mapKey);
102
150
  if (tracked && opts.onToolCall) {
103
151
  const status = toolResult.success ? 'finished' : 'error';
104
- opts.onToolCall(tracked.toolCallId, toolCall.tool, tracked.kind, '', status, tracked.locations);
152
+ const rawOutput = buildRawOutput(toolCall.tool, toolCall.parameters, toolResult);
153
+ opts.onToolCall(tracked.toolCallId, toolCall.tool, tracked.kind, '', status, tracked.locations, rawOutput);
105
154
  }
106
155
  toolCallIdMap.delete(mapKey);
107
156
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeep",
3
- "version": "1.2.54",
3
+ "version": "1.2.56",
4
4
  "description": "AI-powered coding assistant built for the terminal. Multiple LLM providers, project-aware context, and a seamless development workflow.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",