agentrace 0.1.0 → 0.1.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.
- package/README.md +47 -0
- package/dist/index.js +1999 -70
- package/package.json +3 -2
- package/dist/commands/init.d.ts +0 -8
- package/dist/commands/init.js +0 -165
- package/dist/commands/login.d.ts +0 -1
- package/dist/commands/login.js +0 -40
- package/dist/commands/mcp-server.d.ts +0 -1
- package/dist/commands/mcp-server.js +0 -480
- package/dist/commands/off.d.ts +0 -4
- package/dist/commands/off.js +0 -46
- package/dist/commands/on.d.ts +0 -5
- package/dist/commands/on.js +0 -69
- package/dist/commands/send.d.ts +0 -12
- package/dist/commands/send.js +0 -232
- package/dist/commands/uninstall.d.ts +0 -4
- package/dist/commands/uninstall.js +0 -68
- package/dist/config/cursor.d.ts +0 -8
- package/dist/config/cursor.js +0 -57
- package/dist/config/manager.d.ts +0 -18
- package/dist/config/manager.js +0 -90
- package/dist/config/manager.test.d.ts +0 -1
- package/dist/config/manager.test.js +0 -86
- package/dist/hooks/installer.d.ts +0 -67
- package/dist/hooks/installer.js +0 -430
- package/dist/hooks/installer.test.d.ts +0 -1
- package/dist/hooks/installer.test.js +0 -166
- package/dist/index.d.ts +0 -2
- package/dist/mcp/plan-document-client.d.ts +0 -114
- package/dist/mcp/plan-document-client.js +0 -92
- package/dist/utils/browser.d.ts +0 -6
- package/dist/utils/browser.js +0 -40
- package/dist/utils/callback-server.d.ts +0 -10
- package/dist/utils/callback-server.js +0 -81
- package/dist/utils/http.d.ts +0 -28
- package/dist/utils/http.js +0 -60
- package/dist/utils/proxy.d.ts +0 -11
- package/dist/utils/proxy.js +0 -29
- package/dist/utils/proxy.test.d.ts +0 -1
- package/dist/utils/proxy.test.js +0 -116
- package/dist/utils/session-finder.d.ts +0 -10
- package/dist/utils/session-finder.js +0 -66
|
@@ -1,480 +0,0 @@
|
|
|
1
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
import { patchMake, patchToText } from "diff-match-patch-es";
|
|
5
|
-
import * as fs from "node:fs";
|
|
6
|
-
import * as path from "node:path";
|
|
7
|
-
import * as os from "node:os";
|
|
8
|
-
import { PlanDocumentClient } from "../mcp/plan-document-client.js";
|
|
9
|
-
// Read session_id and tool_use_id from file written by PreToolUse hook
|
|
10
|
-
function getSessionInfoFromFile() {
|
|
11
|
-
try {
|
|
12
|
-
const sessionFile = path.join(os.homedir(), ".agentrace", "current-session.json");
|
|
13
|
-
if (fs.existsSync(sessionFile)) {
|
|
14
|
-
const content = fs.readFileSync(sessionFile, "utf-8");
|
|
15
|
-
const data = JSON.parse(content);
|
|
16
|
-
return {
|
|
17
|
-
session_id: data.session_id,
|
|
18
|
-
tool_use_id: data.tool_use_id,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
// Ignore errors, return empty object
|
|
24
|
-
}
|
|
25
|
-
return {};
|
|
26
|
-
}
|
|
27
|
-
// Tool schemas
|
|
28
|
-
const SearchPlansSchema = z.object({
|
|
29
|
-
git_remote_url: z.string().optional().describe("Git remote URL to filter by project"),
|
|
30
|
-
status: z.string().optional().describe("Comma-separated statuses to filter (e.g., 'planning,implementation')"),
|
|
31
|
-
description: z.string().optional().describe("Partial match search on plan description"),
|
|
32
|
-
});
|
|
33
|
-
const ReadPlanSchema = z.object({
|
|
34
|
-
id: z.string().describe("Plan document ID"),
|
|
35
|
-
});
|
|
36
|
-
const CreatePlanSchema = z.object({
|
|
37
|
-
description: z.string().describe("Short description of the plan"),
|
|
38
|
-
body: z.string().describe("Plan content in Markdown format"),
|
|
39
|
-
});
|
|
40
|
-
const UpdatePlanSchema = z.object({
|
|
41
|
-
id: z.string().describe("Plan document ID"),
|
|
42
|
-
body: z.string().describe("Updated plan content in Markdown format"),
|
|
43
|
-
message: z.string().optional().describe("One-line description of what was changed"),
|
|
44
|
-
});
|
|
45
|
-
const SetPlanStatusSchema = z.object({
|
|
46
|
-
id: z.string().describe("Plan document ID"),
|
|
47
|
-
status: z.enum(["scratch", "draft", "planning", "pending", "ready", "implementation", "complete"]).describe("New status for the plan"),
|
|
48
|
-
message: z.string().optional().describe("One-line description of why the status is being changed"),
|
|
49
|
-
});
|
|
50
|
-
const GetPlanCommentsSchema = z.object({
|
|
51
|
-
plan_id: z.string().describe("Plan document ID"),
|
|
52
|
-
status: z.enum(["active", "resolved", "outdated", "all"]).optional().describe("Filter comments by status. Defaults to showing all comments."),
|
|
53
|
-
});
|
|
54
|
-
const AddPlanCommentSchema = z.object({
|
|
55
|
-
plan_id: z.string().describe("Plan document ID"),
|
|
56
|
-
target_text: z.string().describe("The text in the plan body that this comment refers to"),
|
|
57
|
-
content: z.string().describe("The comment content"),
|
|
58
|
-
});
|
|
59
|
-
const ResolvePlanCommentSchema = z.object({
|
|
60
|
-
plan_id: z.string().describe("Plan document ID"),
|
|
61
|
-
thread_id: z.string().describe("Comment thread ID to resolve"),
|
|
62
|
-
});
|
|
63
|
-
// Tool descriptions with usage guidance
|
|
64
|
-
const TOOL_DESCRIPTIONS = {
|
|
65
|
-
search_plans: `Search plan documents with filtering options.
|
|
66
|
-
|
|
67
|
-
WHEN TO USE:
|
|
68
|
-
- When you need to check existing plans for the current repository
|
|
69
|
-
- When the user asks about available plans or implementation documents
|
|
70
|
-
- Before creating a new plan to avoid duplicates
|
|
71
|
-
- When searching for plans by status (e.g., find all plans in 'scratch' status)
|
|
72
|
-
- When searching for plans by description keyword`,
|
|
73
|
-
read_plan: `Read a plan document by ID.
|
|
74
|
-
|
|
75
|
-
WHEN TO USE:
|
|
76
|
-
- When the user asks you to check or review a specific plan by ID
|
|
77
|
-
- When you need to understand an existing plan before making changes
|
|
78
|
-
- When the user references a plan ID in their request
|
|
79
|
-
|
|
80
|
-
IMPORTANT - HANDLING COMMENTS:
|
|
81
|
-
- The response includes 'active_comments_count' showing how many unresolved comments exist
|
|
82
|
-
- If the plan is in 'planning' status AND has active comments (active_comments_count > 0):
|
|
83
|
-
- You SHOULD use get_plan_comments to read the comments
|
|
84
|
-
- Consider the feedback in the comments and reflect it in your plan updates
|
|
85
|
-
- Comments represent team feedback that should be addressed before moving to ready`,
|
|
86
|
-
create_plan: `Create a new plan document to record implementation or design plans.
|
|
87
|
-
|
|
88
|
-
WHEN TO USE:
|
|
89
|
-
- ALWAYS use this when you create a design or implementation plan
|
|
90
|
-
- When entering plan mode and documenting your approach
|
|
91
|
-
- When the user asks you to save or persist a plan
|
|
92
|
-
- When planning significant features, refactoring, or architectural changes
|
|
93
|
-
|
|
94
|
-
The plan will be saved to AgenTrace server and can be reviewed by the team.
|
|
95
|
-
The project is automatically determined from the session's git repository.`,
|
|
96
|
-
update_plan: `Update an existing plan document.
|
|
97
|
-
|
|
98
|
-
WHEN TO USE:
|
|
99
|
-
- When the user asks you to modify a specific plan by ID
|
|
100
|
-
- When implementation details change and the plan needs updating
|
|
101
|
-
- When you need to add progress notes or completion status to a plan
|
|
102
|
-
|
|
103
|
-
Changes are tracked with diff patches for history.`,
|
|
104
|
-
set_plan_status: `Set the status of a plan document.
|
|
105
|
-
|
|
106
|
-
WHEN TO USE:
|
|
107
|
-
- When transitioning a plan from planning to implementation phase
|
|
108
|
-
- When marking a plan as complete after finishing the work
|
|
109
|
-
- When the user explicitly asks to change the status of a plan
|
|
110
|
-
|
|
111
|
-
Available statuses:
|
|
112
|
-
- scratch: Initial rough notes, starting point for discussion with AI
|
|
113
|
-
- draft: Plan not yet fully considered (optional intermediate status)
|
|
114
|
-
- planning: Plan is being designed/refined through discussion
|
|
115
|
-
- pending: Waiting for approval or blocked
|
|
116
|
-
- ready: Plan is finalized and ready for implementation (awaiting review/approval to start)
|
|
117
|
-
- implementation: Active development is in progress
|
|
118
|
-
- complete: The work described in the plan is finished
|
|
119
|
-
|
|
120
|
-
BASIC FLOW: scratch → planning → ready → implementation → complete
|
|
121
|
-
(draft and pending are optional auxiliary statuses)
|
|
122
|
-
|
|
123
|
-
STATUS TRANSITION GUIDELINES:
|
|
124
|
-
- scratch → planning: When you read a scratch plan (usually written by human), review its content and rewrite it into a more concrete plan, then change status to planning
|
|
125
|
-
- planning → ready: When the plan is finalized after discussion, change status to ready
|
|
126
|
-
- ready → implementation: When you start working on the plan, change status to implementation
|
|
127
|
-
- implementation → complete: When all work described in the plan is finished, change status to complete
|
|
128
|
-
|
|
129
|
-
CAUTION:
|
|
130
|
-
- When a plan is in "implementation" status, someone else might already be working on it. Check with the team before starting work on such plans.`,
|
|
131
|
-
get_plan_comments: `Get comments for a plan document.
|
|
132
|
-
|
|
133
|
-
WHEN TO USE:
|
|
134
|
-
- When you need to see feedback or discussions on a specific plan
|
|
135
|
-
- When reviewing a plan that others have commented on
|
|
136
|
-
- Before making changes to understand any concerns or suggestions
|
|
137
|
-
|
|
138
|
-
Returns comments with their status (active, resolved, or outdated).`,
|
|
139
|
-
add_plan_comment: `Add a comment to a specific location in a plan.
|
|
140
|
-
|
|
141
|
-
WHEN TO USE:
|
|
142
|
-
- When you want to provide feedback on a specific part of a plan
|
|
143
|
-
- When you have a question or suggestion about the plan content
|
|
144
|
-
- When reviewing a plan and want to leave notes for the team
|
|
145
|
-
|
|
146
|
-
The comment is anchored to specific text in the plan body.`,
|
|
147
|
-
resolve_plan_comment: `Resolve a comment thread on a plan.
|
|
148
|
-
|
|
149
|
-
WHEN TO USE:
|
|
150
|
-
- When you have addressed the feedback in a comment
|
|
151
|
-
- When the issue raised in the comment has been fixed
|
|
152
|
-
- When the comment is no longer relevant after plan updates
|
|
153
|
-
|
|
154
|
-
Resolving a comment marks it as handled, keeping it visible but indicating it's been addressed.`,
|
|
155
|
-
};
|
|
156
|
-
export async function mcpServerCommand() {
|
|
157
|
-
const server = new McpServer({
|
|
158
|
-
name: "agentrace",
|
|
159
|
-
version: "1.0.0",
|
|
160
|
-
description: `AgenTrace Plan Document Management Server.
|
|
161
|
-
|
|
162
|
-
This server provides tools to manage implementation and design plans.
|
|
163
|
-
Plans are stored on the AgenTrace server and can be reviewed by the team.
|
|
164
|
-
|
|
165
|
-
IMPORTANT GUIDELINES:
|
|
166
|
-
- When you create a design or implementation plan, ALWAYS save it using create_plan
|
|
167
|
-
- When the user asks you to check or modify a plan by ID, use the appropriate tool
|
|
168
|
-
- Plans help track what you're working on and enable team collaboration`,
|
|
169
|
-
});
|
|
170
|
-
let client = null;
|
|
171
|
-
function getClient() {
|
|
172
|
-
if (!client) {
|
|
173
|
-
// Use CLAUDE_PROJECT_DIR to find local config if available
|
|
174
|
-
const projectDir = process.env.CLAUDE_PROJECT_DIR;
|
|
175
|
-
client = new PlanDocumentClient(projectDir);
|
|
176
|
-
}
|
|
177
|
-
return client;
|
|
178
|
-
}
|
|
179
|
-
// search_plans tool
|
|
180
|
-
server.tool("search_plans", TOOL_DESCRIPTIONS.search_plans, SearchPlansSchema.shape, async (args) => {
|
|
181
|
-
try {
|
|
182
|
-
const plans = await getClient().searchPlans({
|
|
183
|
-
gitRemoteUrl: args.git_remote_url,
|
|
184
|
-
status: args.status,
|
|
185
|
-
description: args.description,
|
|
186
|
-
});
|
|
187
|
-
if (plans.length === 0) {
|
|
188
|
-
return {
|
|
189
|
-
content: [
|
|
190
|
-
{
|
|
191
|
-
type: "text",
|
|
192
|
-
text: "No plans found matching the search criteria.",
|
|
193
|
-
},
|
|
194
|
-
],
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
const planList = plans.map((plan) => ({
|
|
198
|
-
id: plan.id,
|
|
199
|
-
description: plan.description,
|
|
200
|
-
status: plan.status,
|
|
201
|
-
active_comments_count: plan.active_comments_count,
|
|
202
|
-
git_remote_url: plan.project?.canonical_git_repository || null,
|
|
203
|
-
url: plan.url || null,
|
|
204
|
-
updated_at: plan.updated_at,
|
|
205
|
-
collaborators: plan.collaborators.map((c) => c.display_name).join(", "),
|
|
206
|
-
}));
|
|
207
|
-
return {
|
|
208
|
-
content: [
|
|
209
|
-
{
|
|
210
|
-
type: "text",
|
|
211
|
-
text: JSON.stringify(planList, null, 2),
|
|
212
|
-
},
|
|
213
|
-
],
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
catch (error) {
|
|
217
|
-
return {
|
|
218
|
-
content: [
|
|
219
|
-
{
|
|
220
|
-
type: "text",
|
|
221
|
-
text: `Error: ${error instanceof Error ? error.message : String(error)}`,
|
|
222
|
-
},
|
|
223
|
-
],
|
|
224
|
-
isError: true,
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
// read_plan tool
|
|
229
|
-
server.tool("read_plan", TOOL_DESCRIPTIONS.read_plan, ReadPlanSchema.shape, async (args) => {
|
|
230
|
-
try {
|
|
231
|
-
const plan = await getClient().getPlan(args.id);
|
|
232
|
-
let text = `# ${plan.description}\n\nStatus: ${plan.status}\nActive Comments: ${plan.active_comments_count}\n\n${plan.body}`;
|
|
233
|
-
if (plan.url) {
|
|
234
|
-
text += `\n\n---\nURL: ${plan.url}`;
|
|
235
|
-
}
|
|
236
|
-
// Add reminder if there are active comments on a planning status plan
|
|
237
|
-
if (plan.status === "planning" && plan.active_comments_count > 0) {
|
|
238
|
-
text += `\n\n---\n⚠️ This plan has ${plan.active_comments_count} active comment(s). Use get_plan_comments to review them and consider the feedback.`;
|
|
239
|
-
}
|
|
240
|
-
return {
|
|
241
|
-
content: [
|
|
242
|
-
{
|
|
243
|
-
type: "text",
|
|
244
|
-
text,
|
|
245
|
-
},
|
|
246
|
-
],
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
catch (error) {
|
|
250
|
-
return {
|
|
251
|
-
content: [
|
|
252
|
-
{
|
|
253
|
-
type: "text",
|
|
254
|
-
text: `Error: ${error instanceof Error ? error.message : String(error)}`,
|
|
255
|
-
},
|
|
256
|
-
],
|
|
257
|
-
isError: true,
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
// create_plan tool
|
|
262
|
-
server.tool("create_plan", TOOL_DESCRIPTIONS.create_plan, CreatePlanSchema.shape, async (args) => {
|
|
263
|
-
try {
|
|
264
|
-
// Read session_id and tool_use_id from file written by PreToolUse hook
|
|
265
|
-
const sessionInfo = getSessionInfoFromFile();
|
|
266
|
-
const plan = await getClient().createPlan({
|
|
267
|
-
description: args.description,
|
|
268
|
-
body: args.body,
|
|
269
|
-
claude_session_id: sessionInfo.session_id,
|
|
270
|
-
tool_use_id: sessionInfo.tool_use_id,
|
|
271
|
-
});
|
|
272
|
-
let text = `Plan created successfully.\n\nID: ${plan.id}\nDescription: ${plan.description}`;
|
|
273
|
-
if (plan.url) {
|
|
274
|
-
text += `\nURL: ${plan.url}`;
|
|
275
|
-
}
|
|
276
|
-
return {
|
|
277
|
-
content: [
|
|
278
|
-
{
|
|
279
|
-
type: "text",
|
|
280
|
-
text,
|
|
281
|
-
},
|
|
282
|
-
],
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
catch (error) {
|
|
286
|
-
return {
|
|
287
|
-
content: [
|
|
288
|
-
{
|
|
289
|
-
type: "text",
|
|
290
|
-
text: `Error: ${error instanceof Error ? error.message : String(error)}`,
|
|
291
|
-
},
|
|
292
|
-
],
|
|
293
|
-
isError: true,
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
});
|
|
297
|
-
// update_plan tool
|
|
298
|
-
server.tool("update_plan", TOOL_DESCRIPTIONS.update_plan, UpdatePlanSchema.shape, async (args) => {
|
|
299
|
-
try {
|
|
300
|
-
// Read session_id and tool_use_id from file written by PreToolUse hook
|
|
301
|
-
const sessionInfo = getSessionInfoFromFile();
|
|
302
|
-
// Get current plan to compute patch
|
|
303
|
-
const currentPlan = await getClient().getPlan(args.id);
|
|
304
|
-
// Compute patch using diff-match-patch
|
|
305
|
-
const patches = patchMake(currentPlan.body, args.body);
|
|
306
|
-
const patchText = patchToText(patches);
|
|
307
|
-
const plan = await getClient().updatePlan(args.id, {
|
|
308
|
-
body: args.body,
|
|
309
|
-
patch: patchText,
|
|
310
|
-
message: args.message,
|
|
311
|
-
claude_session_id: sessionInfo.session_id,
|
|
312
|
-
tool_use_id: sessionInfo.tool_use_id,
|
|
313
|
-
});
|
|
314
|
-
let text = `Plan updated successfully.\n\nID: ${plan.id}\nDescription: ${plan.description}`;
|
|
315
|
-
if (plan.url) {
|
|
316
|
-
text += `\nURL: ${plan.url}`;
|
|
317
|
-
}
|
|
318
|
-
return {
|
|
319
|
-
content: [
|
|
320
|
-
{
|
|
321
|
-
type: "text",
|
|
322
|
-
text,
|
|
323
|
-
},
|
|
324
|
-
],
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
catch (error) {
|
|
328
|
-
return {
|
|
329
|
-
content: [
|
|
330
|
-
{
|
|
331
|
-
type: "text",
|
|
332
|
-
text: `Error: ${error instanceof Error ? error.message : String(error)}`,
|
|
333
|
-
},
|
|
334
|
-
],
|
|
335
|
-
isError: true,
|
|
336
|
-
};
|
|
337
|
-
}
|
|
338
|
-
});
|
|
339
|
-
// set_plan_status tool
|
|
340
|
-
server.tool("set_plan_status", TOOL_DESCRIPTIONS.set_plan_status, SetPlanStatusSchema.shape, async (args) => {
|
|
341
|
-
try {
|
|
342
|
-
const plan = await getClient().setStatus(args.id, args.status, args.message);
|
|
343
|
-
let text = `Plan status updated successfully.\n\nID: ${plan.id}\nDescription: ${plan.description}\nStatus: ${plan.status}`;
|
|
344
|
-
if (plan.url) {
|
|
345
|
-
text += `\nURL: ${plan.url}`;
|
|
346
|
-
}
|
|
347
|
-
return {
|
|
348
|
-
content: [
|
|
349
|
-
{
|
|
350
|
-
type: "text",
|
|
351
|
-
text,
|
|
352
|
-
},
|
|
353
|
-
],
|
|
354
|
-
};
|
|
355
|
-
}
|
|
356
|
-
catch (error) {
|
|
357
|
-
return {
|
|
358
|
-
content: [
|
|
359
|
-
{
|
|
360
|
-
type: "text",
|
|
361
|
-
text: `Error: ${error instanceof Error ? error.message : String(error)}`,
|
|
362
|
-
},
|
|
363
|
-
],
|
|
364
|
-
isError: true,
|
|
365
|
-
};
|
|
366
|
-
}
|
|
367
|
-
});
|
|
368
|
-
// get_plan_comments tool
|
|
369
|
-
server.tool("get_plan_comments", TOOL_DESCRIPTIONS.get_plan_comments, GetPlanCommentsSchema.shape, async (args) => {
|
|
370
|
-
try {
|
|
371
|
-
const threads = await getClient().getThreads(args.plan_id, args.status);
|
|
372
|
-
if (threads.length === 0) {
|
|
373
|
-
return {
|
|
374
|
-
content: [
|
|
375
|
-
{
|
|
376
|
-
type: "text",
|
|
377
|
-
text: "No comments found for this plan.",
|
|
378
|
-
},
|
|
379
|
-
],
|
|
380
|
-
};
|
|
381
|
-
}
|
|
382
|
-
const threadList = threads.map((thread) => ({
|
|
383
|
-
id: thread.id,
|
|
384
|
-
target_text: thread.target_text,
|
|
385
|
-
status: thread.status,
|
|
386
|
-
position: thread.position ? {
|
|
387
|
-
start_line: thread.position.start_line,
|
|
388
|
-
start_column: thread.position.start_column,
|
|
389
|
-
end_line: thread.position.end_line,
|
|
390
|
-
end_column: thread.position.end_column,
|
|
391
|
-
found: thread.position.found,
|
|
392
|
-
} : null,
|
|
393
|
-
messages: thread.messages.map((msg) => ({
|
|
394
|
-
id: msg.id,
|
|
395
|
-
user_name: msg.user_name,
|
|
396
|
-
content: msg.content,
|
|
397
|
-
created_at: msg.created_at,
|
|
398
|
-
})),
|
|
399
|
-
created_at: thread.created_at,
|
|
400
|
-
}));
|
|
401
|
-
return {
|
|
402
|
-
content: [
|
|
403
|
-
{
|
|
404
|
-
type: "text",
|
|
405
|
-
text: JSON.stringify(threadList, null, 2),
|
|
406
|
-
},
|
|
407
|
-
],
|
|
408
|
-
};
|
|
409
|
-
}
|
|
410
|
-
catch (error) {
|
|
411
|
-
return {
|
|
412
|
-
content: [
|
|
413
|
-
{
|
|
414
|
-
type: "text",
|
|
415
|
-
text: `Error: ${error instanceof Error ? error.message : String(error)}`,
|
|
416
|
-
},
|
|
417
|
-
],
|
|
418
|
-
isError: true,
|
|
419
|
-
};
|
|
420
|
-
}
|
|
421
|
-
});
|
|
422
|
-
// add_plan_comment tool
|
|
423
|
-
server.tool("add_plan_comment", TOOL_DESCRIPTIONS.add_plan_comment, AddPlanCommentSchema.shape, async (args) => {
|
|
424
|
-
try {
|
|
425
|
-
const thread = await getClient().createThread(args.plan_id, {
|
|
426
|
-
target_text: args.target_text,
|
|
427
|
-
context_before: "",
|
|
428
|
-
context_after: "",
|
|
429
|
-
content: args.content,
|
|
430
|
-
});
|
|
431
|
-
return {
|
|
432
|
-
content: [
|
|
433
|
-
{
|
|
434
|
-
type: "text",
|
|
435
|
-
text: `Comment added successfully.\n\nThread ID: ${thread.id}\nStatus: ${thread.status}\nTarget: "${thread.target_text}"`,
|
|
436
|
-
},
|
|
437
|
-
],
|
|
438
|
-
};
|
|
439
|
-
}
|
|
440
|
-
catch (error) {
|
|
441
|
-
return {
|
|
442
|
-
content: [
|
|
443
|
-
{
|
|
444
|
-
type: "text",
|
|
445
|
-
text: `Error: ${error instanceof Error ? error.message : String(error)}`,
|
|
446
|
-
},
|
|
447
|
-
],
|
|
448
|
-
isError: true,
|
|
449
|
-
};
|
|
450
|
-
}
|
|
451
|
-
});
|
|
452
|
-
// resolve_plan_comment tool
|
|
453
|
-
server.tool("resolve_plan_comment", TOOL_DESCRIPTIONS.resolve_plan_comment, ResolvePlanCommentSchema.shape, async (args) => {
|
|
454
|
-
try {
|
|
455
|
-
const thread = await getClient().resolveThread(args.plan_id, args.thread_id);
|
|
456
|
-
return {
|
|
457
|
-
content: [
|
|
458
|
-
{
|
|
459
|
-
type: "text",
|
|
460
|
-
text: `Comment resolved successfully.\n\nThread ID: ${thread.id}\nStatus: ${thread.status}\nTarget: "${thread.target_text}"`,
|
|
461
|
-
},
|
|
462
|
-
],
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
catch (error) {
|
|
466
|
-
return {
|
|
467
|
-
content: [
|
|
468
|
-
{
|
|
469
|
-
type: "text",
|
|
470
|
-
text: `Error: ${error instanceof Error ? error.message : String(error)}`,
|
|
471
|
-
},
|
|
472
|
-
],
|
|
473
|
-
isError: true,
|
|
474
|
-
};
|
|
475
|
-
}
|
|
476
|
-
});
|
|
477
|
-
// Start the server with stdio transport
|
|
478
|
-
const transport = new StdioServerTransport();
|
|
479
|
-
await server.connect(transport);
|
|
480
|
-
}
|
package/dist/commands/off.d.ts
DELETED
package/dist/commands/off.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { uninstallHooks, uninstallMcpServer, uninstallPreToolUseHook } from "../hooks/installer.js";
|
|
2
|
-
import { loadConfig, loadConfigWithFallback } from "../config/manager.js";
|
|
3
|
-
export async function offCommand(options = {}) {
|
|
4
|
-
const projectDir = options.local ? process.cwd() : undefined;
|
|
5
|
-
// Check if config exists (local config takes precedence if --local is specified)
|
|
6
|
-
const config = options.local ? loadConfigWithFallback(projectDir) : loadConfig();
|
|
7
|
-
if (!config) {
|
|
8
|
-
console.log("AgenTrace is not configured. Run 'npx agentrace init' first.");
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
if (options.local) {
|
|
12
|
-
console.log("[Local Mode] Disabling hooks/MCP for this project only\n");
|
|
13
|
-
}
|
|
14
|
-
const result = uninstallHooks({
|
|
15
|
-
local: options.local,
|
|
16
|
-
projectDir,
|
|
17
|
-
});
|
|
18
|
-
if (result.success) {
|
|
19
|
-
console.log(`✓ Hooks disabled. Your credentials are still saved.`);
|
|
20
|
-
console.log(` Run 'npx agentrace on${options.local ? " --local" : ""}' to re-enable.`);
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
console.error(`✗ ${result.message}`);
|
|
24
|
-
}
|
|
25
|
-
// Remove PreToolUse hook
|
|
26
|
-
const preToolUseResult = uninstallPreToolUseHook({
|
|
27
|
-
local: options.local,
|
|
28
|
-
projectDir,
|
|
29
|
-
});
|
|
30
|
-
if (preToolUseResult.success) {
|
|
31
|
-
console.log(`✓ ${preToolUseResult.message}`);
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
console.error(`✗ ${preToolUseResult.message}`);
|
|
35
|
-
}
|
|
36
|
-
const mcpResult = uninstallMcpServer({
|
|
37
|
-
local: options.local,
|
|
38
|
-
projectDir,
|
|
39
|
-
});
|
|
40
|
-
if (mcpResult.success) {
|
|
41
|
-
console.log(`✓ ${mcpResult.message}`);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
console.error(`✗ ${mcpResult.message}`);
|
|
45
|
-
}
|
|
46
|
-
}
|
package/dist/commands/on.d.ts
DELETED
package/dist/commands/on.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import * as path from "node:path";
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
import { installHooks, installMcpServer, installPreToolUseHook } from "../hooks/installer.js";
|
|
4
|
-
import { loadConfig, loadConfigWithFallback } from "../config/manager.js";
|
|
5
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
-
const __dirname = path.dirname(__filename);
|
|
7
|
-
export async function onCommand(options = {}) {
|
|
8
|
-
const projectDir = options.local ? process.cwd() : undefined;
|
|
9
|
-
// Check if config exists (local config takes precedence if --local is specified)
|
|
10
|
-
const config = options.local ? loadConfigWithFallback(projectDir) : loadConfig();
|
|
11
|
-
if (!config) {
|
|
12
|
-
console.log("AgenTrace is not configured. Run 'npx agentrace init' first.");
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
if (options.local) {
|
|
16
|
-
console.log("[Local Mode] Enabling hooks/MCP for this project only\n");
|
|
17
|
-
}
|
|
18
|
-
// Determine hook command
|
|
19
|
-
let hookCommand;
|
|
20
|
-
if (options.dev) {
|
|
21
|
-
// Use local CLI path for development
|
|
22
|
-
const cliRoot = path.resolve(__dirname, "../..");
|
|
23
|
-
const indexPath = path.join(cliRoot, "src/index.ts");
|
|
24
|
-
hookCommand = `npx tsx ${indexPath} send`;
|
|
25
|
-
}
|
|
26
|
-
const result = installHooks({
|
|
27
|
-
command: hookCommand,
|
|
28
|
-
local: options.local,
|
|
29
|
-
projectDir,
|
|
30
|
-
});
|
|
31
|
-
if (result.success) {
|
|
32
|
-
console.log(`✓ Hooks enabled. Session data will be sent to ${config.server_url}`);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
console.error(`✗ ${result.message}`);
|
|
36
|
-
}
|
|
37
|
-
// Install MCP server
|
|
38
|
-
let mcpCommand;
|
|
39
|
-
let mcpArgs;
|
|
40
|
-
if (options.dev) {
|
|
41
|
-
const cliRoot = path.resolve(__dirname, "../..");
|
|
42
|
-
const indexPath = path.join(cliRoot, "src/index.ts");
|
|
43
|
-
mcpCommand = "npx";
|
|
44
|
-
mcpArgs = ["tsx", indexPath, "mcp-server"];
|
|
45
|
-
}
|
|
46
|
-
const mcpResult = installMcpServer({
|
|
47
|
-
command: mcpCommand,
|
|
48
|
-
args: mcpArgs,
|
|
49
|
-
local: options.local,
|
|
50
|
-
projectDir,
|
|
51
|
-
});
|
|
52
|
-
if (mcpResult.success) {
|
|
53
|
-
console.log(`✓ ${mcpResult.message}`);
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
console.error(`✗ ${mcpResult.message}`);
|
|
57
|
-
}
|
|
58
|
-
// Install PreToolUse hook for session_id injection
|
|
59
|
-
const preToolUseResult = installPreToolUseHook({
|
|
60
|
-
local: options.local,
|
|
61
|
-
projectDir,
|
|
62
|
-
});
|
|
63
|
-
if (preToolUseResult.success) {
|
|
64
|
-
console.log(`✓ ${preToolUseResult.message}`);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
console.error(`✗ ${preToolUseResult.message}`);
|
|
68
|
-
}
|
|
69
|
-
}
|
package/dist/commands/send.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hook-based send command.
|
|
3
|
-
* Reads session info from stdin (provided by Claude Code hooks).
|
|
4
|
-
*/
|
|
5
|
-
export declare function sendCommand(): Promise<void>;
|
|
6
|
-
/**
|
|
7
|
-
* Manual send command.
|
|
8
|
-
* Finds session file by ID and sends to server.
|
|
9
|
-
*/
|
|
10
|
-
export declare function sendManualCommand(options: {
|
|
11
|
-
sessionId: string;
|
|
12
|
-
}): Promise<void>;
|