@finityno/claude-code-acp 0.18.0 → 0.19.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-mcp-tools.d.ts","sourceRoot":"","sources":["../src/task-mcp-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAkB,eAAe,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"task-mcp-tools.d.ts","sourceRoot":"","sources":["../src/task-mcp-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAkB,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAKxE,MAAM,WAAW,mBAAmB;IAClC,mCAAmC;IACnC,OAAO,EAAE,eAAe,CAAC;IACzB,oDAAoD;IACpD,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAC;CACnB;AAkFD;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,mBAAmB,GAC3B,IAAI,CA6SN"}
|
package/dist/task-mcp-tools.js
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { TaskManager } from "./task-manager.js";
|
|
3
|
+
import { homedir } from "os";
|
|
4
|
+
import { join } from "path";
|
|
5
|
+
import { readFile } from "fs/promises";
|
|
6
|
+
/**
|
|
7
|
+
* Get Claude Code's project path for a given working directory
|
|
8
|
+
* Converts /Users/foo/project -> -Users-foo-project
|
|
9
|
+
*/
|
|
10
|
+
function getClaudeProjectPath(workingDir) {
|
|
11
|
+
// Replace path separators with dashes and remove leading slash
|
|
12
|
+
return workingDir.replace(/\//g, "-");
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Read sessions from Claude Code's sessions-index.json
|
|
16
|
+
*/
|
|
17
|
+
async function readClaudeSessions(workingDir) {
|
|
18
|
+
const claudeDir = join(homedir(), ".claude", "projects");
|
|
19
|
+
const sessions = [];
|
|
20
|
+
try {
|
|
21
|
+
// If working dir is specified, only read that project's sessions
|
|
22
|
+
if (workingDir) {
|
|
23
|
+
const projectPath = getClaudeProjectPath(workingDir);
|
|
24
|
+
const indexPath = join(claudeDir, projectPath, "sessions-index.json");
|
|
25
|
+
try {
|
|
26
|
+
const content = await readFile(indexPath, "utf8");
|
|
27
|
+
const index = JSON.parse(content);
|
|
28
|
+
sessions.push(...index.entries);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
// Project might not exist
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// Read all projects' sessions
|
|
36
|
+
const { readdir } = await import("fs/promises");
|
|
37
|
+
const projects = await readdir(claudeDir);
|
|
38
|
+
for (const project of projects) {
|
|
39
|
+
const indexPath = join(claudeDir, project, "sessions-index.json");
|
|
40
|
+
try {
|
|
41
|
+
const content = await readFile(indexPath, "utf8");
|
|
42
|
+
const index = JSON.parse(content);
|
|
43
|
+
sessions.push(...index.entries);
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
// Skip projects without sessions-index.json
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// Sort by modified date, newest first
|
|
51
|
+
sessions.sort((a, b) => new Date(b.modified).getTime() - new Date(a.modified).getTime());
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
// Claude directory might not exist
|
|
55
|
+
}
|
|
56
|
+
return sessions;
|
|
57
|
+
}
|
|
3
58
|
/**
|
|
4
59
|
* Register MCP tools for task management
|
|
5
60
|
*/
|
|
@@ -173,25 +228,43 @@ Can filter by status, session, or background execution.`,
|
|
|
173
228
|
await tracker.cancelSubagent(input.taskId);
|
|
174
229
|
return { content: [{ type: "text", text: `Task ${input.taskId} cancelled` }] };
|
|
175
230
|
});
|
|
176
|
-
// List resumable tasks
|
|
231
|
+
// List resumable tasks - reads from Claude Code's sessions-index.json
|
|
177
232
|
server.registerTool("ListResumableTasks", {
|
|
178
233
|
title: "List Resumable Tasks",
|
|
179
|
-
description:
|
|
234
|
+
description: `List previous Claude Code sessions that can be resumed via Task tool's resume parameter.
|
|
235
|
+
Reads from Claude Code's sessions storage (~/.claude/projects/) to find resumable sessions.
|
|
236
|
+
Also shows in-memory tracked subagents that haven't been persisted yet.`,
|
|
180
237
|
inputSchema: {
|
|
181
|
-
limit: z.number().optional().default(10).describe("Maximum number of
|
|
238
|
+
limit: z.number().optional().default(10).describe("Maximum number of sessions to return"),
|
|
239
|
+
projectPath: z.string().optional().describe("Filter to sessions from a specific project path"),
|
|
182
240
|
},
|
|
183
241
|
annotations: {
|
|
184
242
|
title: "List resumable tasks",
|
|
185
243
|
readOnlyHint: true,
|
|
186
244
|
},
|
|
187
245
|
}, async (input) => {
|
|
188
|
-
|
|
246
|
+
// Get sessions from Claude Code's storage
|
|
247
|
+
const claudeSessions = await readClaudeSessions(input.projectPath);
|
|
248
|
+
const limited = claudeSessions.slice(0, input.limit);
|
|
249
|
+
// Also get in-memory tracked subagents (for current session)
|
|
250
|
+
const inMemoryTasks = tracker.getResumableTasks();
|
|
189
251
|
return {
|
|
190
252
|
content: [{
|
|
191
253
|
type: "text",
|
|
192
254
|
text: JSON.stringify({
|
|
193
|
-
count:
|
|
194
|
-
tasks:
|
|
255
|
+
count: limited.length,
|
|
256
|
+
tasks: limited.map((s) => ({
|
|
257
|
+
sessionId: s.sessionId,
|
|
258
|
+
summary: s.summary,
|
|
259
|
+
firstPrompt: s.firstPrompt.substring(0, 100) + (s.firstPrompt.length > 100 ? "..." : ""),
|
|
260
|
+
messageCount: s.messageCount,
|
|
261
|
+
created: s.created,
|
|
262
|
+
modified: s.modified,
|
|
263
|
+
gitBranch: s.gitBranch,
|
|
264
|
+
projectPath: s.projectPath,
|
|
265
|
+
})),
|
|
266
|
+
// Also include in-memory subagents not yet persisted
|
|
267
|
+
inMemorySubagents: inMemoryTasks.length > 0 ? inMemoryTasks.map((t) => ({
|
|
195
268
|
id: t.id,
|
|
196
269
|
agentId: t.agentId,
|
|
197
270
|
type: t.subagentType,
|
|
@@ -199,8 +272,7 @@ Can filter by status, session, or background execution.`,
|
|
|
199
272
|
status: t.status,
|
|
200
273
|
completedAt: t.completedAt ? new Date(t.completedAt).toISOString() : undefined,
|
|
201
274
|
summary: t.summary,
|
|
202
|
-
|
|
203
|
-
})),
|
|
275
|
+
})) : undefined,
|
|
204
276
|
}, null, 2),
|
|
205
277
|
}],
|
|
206
278
|
};
|
package/package.json
CHANGED