codeep 1.2.31 → 1.2.32

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.
@@ -170,8 +170,30 @@ export function startAcpServer() {
170
170
  conversationId: params.sessionId,
171
171
  abortSignal: abortController.signal,
172
172
  onChunk: sendChunk,
173
+ onThought: (text) => {
174
+ transport.notify('session/update', {
175
+ sessionId: params.sessionId,
176
+ update: {
177
+ sessionUpdate: 'agent_thought_chunk',
178
+ content: { type: 'text', text },
179
+ },
180
+ });
181
+ },
182
+ onToolCall: (toolCallId, _toolName, kind, title, status, locations) => {
183
+ transport.notify('session/update', {
184
+ sessionId: params.sessionId,
185
+ update: {
186
+ sessionUpdate: 'tool_call',
187
+ toolCallId,
188
+ title,
189
+ kind,
190
+ status,
191
+ ...(locations?.length ? { locations: locations.map(uri => ({ uri })) } : {}),
192
+ },
193
+ });
194
+ },
173
195
  onFileEdit: (uri, newText) => {
174
- // ACP structured file/edit notification — lets the editor track changed files
196
+ // ACP structured file/edit notification — lets the editor apply changes
175
197
  transport.notify('file/edit', {
176
198
  uri,
177
199
  textChanges: newText
@@ -5,6 +5,8 @@ export interface AgentSessionOptions {
5
5
  conversationId: string;
6
6
  abortSignal: AbortSignal;
7
7
  onChunk: (text: string) => void;
8
+ onThought?: (text: string) => void;
9
+ onToolCall?: (toolCallId: string, toolName: string, kind: string, title: string, status: 'pending' | 'running' | 'finished' | 'error', locations?: string[]) => void;
8
10
  onFileEdit: (uri: string, newText: string) => void;
9
11
  }
10
12
  /**
@@ -12,10 +14,5 @@ export interface AgentSessionOptions {
12
14
  * Falls back to a minimal synthetic context if scanning fails.
13
15
  */
14
16
  export declare function buildProjectContext(workspaceRoot: string): ProjectContext;
15
- /**
16
- * Run a single agent session driven by ACP parameters.
17
- *
18
- * onFileEdit is reserved for future use (v1 emits everything via onChunk).
19
- */
20
17
  export declare function runAgentSession(opts: AgentSessionOptions): Promise<void>;
21
18
  export declare function pathToUri(absolutePath: string): string;
@@ -24,28 +24,54 @@ export function buildProjectContext(workspaceRoot) {
24
24
  summary: `Workspace at ${workspaceRoot}`,
25
25
  };
26
26
  }
27
- /**
28
- * Run a single agent session driven by ACP parameters.
29
- *
30
- * onFileEdit is reserved for future use (v1 emits everything via onChunk).
31
- */
27
+ // Maps internal tool names to ACP tool_call kind values and human titles.
28
+ function toolCallMeta(toolName, params) {
29
+ const file = params.path ?? params.file ?? '';
30
+ const label = file ? ` ${file.split('/').pop()}` : '';
31
+ switch (toolName) {
32
+ case 'read_file': return { kind: 'read', title: `Reading${label}` };
33
+ case 'write_file': return { kind: 'edit', title: `Writing${label}` };
34
+ case 'edit_file': return { kind: 'edit', title: `Editing${label}` };
35
+ case 'delete_file': return { kind: 'delete', title: `Deleting${label}` };
36
+ case 'move_file': return { kind: 'move', title: `Moving${label}` };
37
+ case 'list_files': return { kind: 'read', title: `Listing files${label}` };
38
+ case 'search_files': return { kind: 'search', title: `Searching${label || ' files'}` };
39
+ case 'run_command': return { kind: 'execute', title: `Running: ${params.command ?? ''}` };
40
+ case 'web_fetch': return { kind: 'fetch', title: `Fetching ${params.url ?? ''}` };
41
+ default: return { kind: 'other', title: toolName };
42
+ }
43
+ }
32
44
  export async function runAgentSession(opts) {
33
45
  const projectContext = buildProjectContext(opts.workspaceRoot);
46
+ let toolCallCounter = 0;
34
47
  const result = await runAgent(opts.prompt, projectContext, {
35
48
  abortSignal: opts.abortSignal,
36
- onIteration: (_iteration, message) => {
37
- opts.onChunk(message + '\n');
49
+ onIteration: (_iteration, _message) => {
50
+ // Intentionally not forwarded — iteration count is internal detail
38
51
  },
39
52
  onThinking: (text) => {
40
- opts.onChunk(text);
53
+ if (opts.onThought) {
54
+ opts.onThought(text);
55
+ }
41
56
  },
42
57
  onToolCall: (toolCall) => {
43
- // Notify the caller when agent writes or edits a file so ACP can
44
- // send a structured file/edit notification to the editor.
45
58
  const name = toolCall.tool;
59
+ const params = (toolCall.parameters ?? {});
60
+ const { kind, title } = toolCallMeta(name, params);
61
+ const toolCallId = `tc_${++toolCallCounter}`;
62
+ // Resolve file locations for edit/read/delete/move tools
63
+ const locations = [];
64
+ const filePath = params.path ?? params.file ?? '';
65
+ if (filePath) {
66
+ const absPath = isAbsolute(filePath)
67
+ ? filePath
68
+ : join(opts.workspaceRoot, filePath);
69
+ locations.push(pathToFileURL(absPath).href);
70
+ }
71
+ // Emit tool_call notification (running state)
72
+ opts.onToolCall?.(toolCallId, name, kind, title, 'running', locations.length ? locations : undefined);
73
+ // For file edits, also send structured file/edit notification
46
74
  if (name === 'write_file' || name === 'edit_file') {
47
- const params = toolCall.parameters;
48
- const filePath = params.path ?? '';
49
75
  if (filePath) {
50
76
  const absPath = isAbsolute(filePath)
51
77
  ? filePath
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeep",
3
- "version": "1.2.31",
3
+ "version": "1.2.32",
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",