@neurynae/toolcairn-mcp 0.1.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.
- package/bin/toolpilot-mcp.js +5 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware/event-logger.d.ts +19 -0
- package/dist/middleware/event-logger.d.ts.map +1 -0
- package/dist/middleware/event-logger.js +138 -0
- package/dist/middleware/event-logger.js.map +1 -0
- package/dist/schemas.d.ts +2 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +3 -0
- package/dist/schemas.js.map +1 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +116 -0
- package/dist/server.js.map +1 -0
- package/dist/server.prod.d.ts +14 -0
- package/dist/server.prod.d.ts.map +1 -0
- package/dist/server.prod.js +127 -0
- package/dist/server.prod.js.map +1 -0
- package/dist/templates/agent-instructions.d.ts +22 -0
- package/dist/templates/agent-instructions.d.ts.map +1 -0
- package/dist/templates/agent-instructions.js +155 -0
- package/dist/templates/agent-instructions.js.map +1 -0
- package/dist/tools/check-compatibility.d.ts +100 -0
- package/dist/tools/check-compatibility.d.ts.map +1 -0
- package/dist/tools/check-compatibility.js +103 -0
- package/dist/tools/check-compatibility.js.map +1 -0
- package/dist/tools/check-issue.d.ts +126 -0
- package/dist/tools/check-issue.d.ts.map +1 -0
- package/dist/tools/check-issue.js +248 -0
- package/dist/tools/check-issue.js.map +1 -0
- package/dist/tools/classify-prompt.d.ts +101 -0
- package/dist/tools/classify-prompt.d.ts.map +1 -0
- package/dist/tools/classify-prompt.js +64 -0
- package/dist/tools/classify-prompt.js.map +1 -0
- package/dist/tools/compare-tools.d.ts +102 -0
- package/dist/tools/compare-tools.d.ts.map +1 -0
- package/dist/tools/compare-tools.js +178 -0
- package/dist/tools/compare-tools.js.map +1 -0
- package/dist/tools/format-results.d.ts +44 -0
- package/dist/tools/format-results.d.ts.map +1 -0
- package/dist/tools/format-results.js +114 -0
- package/dist/tools/format-results.js.map +1 -0
- package/dist/tools/generate-tracker.d.ts +7 -0
- package/dist/tools/generate-tracker.d.ts.map +1 -0
- package/dist/tools/generate-tracker.js +408 -0
- package/dist/tools/generate-tracker.js.map +1 -0
- package/dist/tools/get-stack.d.ts +105 -0
- package/dist/tools/get-stack.d.ts.map +1 -0
- package/dist/tools/get-stack.js +156 -0
- package/dist/tools/get-stack.js.map +1 -0
- package/dist/tools/init-project-config.d.ts +107 -0
- package/dist/tools/init-project-config.d.ts.map +1 -0
- package/dist/tools/init-project-config.js +52 -0
- package/dist/tools/init-project-config.js.map +1 -0
- package/dist/tools/read-project-config.d.ts +99 -0
- package/dist/tools/read-project-config.d.ts.map +1 -0
- package/dist/tools/read-project-config.js +78 -0
- package/dist/tools/read-project-config.js.map +1 -0
- package/dist/tools/refine-requirement.d.ts +105 -0
- package/dist/tools/refine-requirement.d.ts.map +1 -0
- package/dist/tools/refine-requirement.js +77 -0
- package/dist/tools/refine-requirement.js.map +1 -0
- package/dist/tools/report-outcome.d.ts +104 -0
- package/dist/tools/report-outcome.d.ts.map +1 -0
- package/dist/tools/report-outcome.js +108 -0
- package/dist/tools/report-outcome.js.map +1 -0
- package/dist/tools/search-tools-respond.d.ts +103 -0
- package/dist/tools/search-tools-respond.d.ts.map +1 -0
- package/dist/tools/search-tools-respond.js +91 -0
- package/dist/tools/search-tools-respond.js.map +1 -0
- package/dist/tools/search-tools.d.ts +104 -0
- package/dist/tools/search-tools.d.ts.map +1 -0
- package/dist/tools/search-tools.js +77 -0
- package/dist/tools/search-tools.js.map +1 -0
- package/dist/tools/suggest-graph-update.d.ts +117 -0
- package/dist/tools/suggest-graph-update.d.ts.map +1 -0
- package/dist/tools/suggest-graph-update.js +177 -0
- package/dist/tools/suggest-graph-update.js.map +1 -0
- package/dist/tools/toolpilot-init.d.ts +103 -0
- package/dist/tools/toolpilot-init.d.ts.map +1 -0
- package/dist/tools/toolpilot-init.js +115 -0
- package/dist/tools/toolpilot-init.js.map +1 -0
- package/dist/tools/update-project-config.d.ts +104 -0
- package/dist/tools/update-project-config.d.ts.map +1 -0
- package/dist/tools/update-project-config.js +117 -0
- package/dist/tools/update-project-config.js.map +1 -0
- package/dist/tools/verify-suggestion.d.ts +113 -0
- package/dist/tools/verify-suggestion.d.ts.map +1 -0
- package/dist/tools/verify-suggestion.js +223 -0
- package/dist/tools/verify-suggestion.js.map +1 -0
- package/dist/transport.d.ts +5 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +13 -0
- package/dist/transport.js.map +1 -0
- package/dist/utils.d.ts +4 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +12 -0
- package/dist/utils.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* check_issue — Checks GitHub directly for known issues matching an error.
|
|
3
|
+
*
|
|
4
|
+
* IMPORTANT: This is a last-resort tool. The agent should:
|
|
5
|
+
* 1. Try to fix the error itself (2 retries)
|
|
6
|
+
* 2. Consult the tool's documentation (2 more retries)
|
|
7
|
+
* 3. ONLY THEN call check_issue (pass retry_count≥4, docs_consulted=true)
|
|
8
|
+
*
|
|
9
|
+
* This prevents spamming the GitHub API for errors that are config issues,
|
|
10
|
+
* environment problems, or things the docs would explain.
|
|
11
|
+
*
|
|
12
|
+
* Flow:
|
|
13
|
+
* 1. Gate: enforce retry + docs requirements
|
|
14
|
+
* 2. Look up tool's github_url in Memgraph
|
|
15
|
+
* 3. Search GitHub Issues API directly (no local DB — live data)
|
|
16
|
+
* 4. Also search for PRs that may fix the issue
|
|
17
|
+
* 5. Return one of four statuses:
|
|
18
|
+
* - not_found: no matching issue on GitHub → agent handles it
|
|
19
|
+
* - fix_in_progress: open issue + open PR exists → track PR
|
|
20
|
+
* - known_issue_no_fix: open issue, no PR → gist + ask user intent
|
|
21
|
+
* - fixed_in_version: closed issue → which version fixed it
|
|
22
|
+
* 6. In real-issue cases (3/4): add 👍 reaction to the issue via GitHub API
|
|
23
|
+
*/
|
|
24
|
+
import { config } from '@toolpilot/config';
|
|
25
|
+
import { MemgraphToolRepository } from '@toolpilot/graph';
|
|
26
|
+
import pino from 'pino';
|
|
27
|
+
import { errResult, okResult } from '../utils.js';
|
|
28
|
+
const logger = pino({ name: '@toolpilot/mcp-server:check-issue' });
|
|
29
|
+
const repo = new MemgraphToolRepository();
|
|
30
|
+
const DOCS_RETRY_THRESHOLD = 4; // total retries before check_issue is appropriate
|
|
31
|
+
function githubHeaders() {
|
|
32
|
+
const headers = {
|
|
33
|
+
Accept: 'application/vnd.github+json',
|
|
34
|
+
'X-GitHub-Api-Version': '2022-11-28',
|
|
35
|
+
};
|
|
36
|
+
if (config.GITHUB_TOKEN) {
|
|
37
|
+
headers.Authorization = `Bearer ${config.GITHUB_TOKEN}`;
|
|
38
|
+
}
|
|
39
|
+
return headers;
|
|
40
|
+
}
|
|
41
|
+
async function searchGitHubIssues(owner, repoName, query, type) {
|
|
42
|
+
const q = encodeURIComponent(`${query} repo:${owner}/${repoName} type:${type}`);
|
|
43
|
+
const url = `https://api.github.com/search/issues?q=${q}&sort=relevance&per_page=5`;
|
|
44
|
+
const res = await fetch(url, { headers: githubHeaders() });
|
|
45
|
+
if (!res.ok) {
|
|
46
|
+
if (res.status === 422 || res.status === 403)
|
|
47
|
+
return []; // rate limit or bad query
|
|
48
|
+
throw new Error(`GitHub Search API error: ${res.status}`);
|
|
49
|
+
}
|
|
50
|
+
const data = (await res.json());
|
|
51
|
+
return data.items ?? [];
|
|
52
|
+
}
|
|
53
|
+
async function addReaction(owner, repoName, issueNumber) {
|
|
54
|
+
if (!config.GITHUB_TOKEN)
|
|
55
|
+
return false; // reactions require auth
|
|
56
|
+
try {
|
|
57
|
+
const res = await fetch(`https://api.github.com/repos/${owner}/${repoName}/issues/${issueNumber}/reactions`, {
|
|
58
|
+
method: 'POST',
|
|
59
|
+
headers: { ...githubHeaders(), 'Content-Type': 'application/json' },
|
|
60
|
+
body: JSON.stringify({ content: '+1' }),
|
|
61
|
+
});
|
|
62
|
+
return res.ok || res.status === 200;
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Extract a concise gist from an issue (title + key labels + first 500 chars of body).
|
|
70
|
+
*/
|
|
71
|
+
function buildIssueGist(issue) {
|
|
72
|
+
const labels = issue.labels.map((l) => l.name).join(', ');
|
|
73
|
+
const bodySnippet = (issue.body ?? '').slice(0, 500).replace(/\r?\n/g, ' ');
|
|
74
|
+
return [
|
|
75
|
+
`Title: ${issue.title}`,
|
|
76
|
+
labels ? `Labels: ${labels}` : null,
|
|
77
|
+
bodySnippet
|
|
78
|
+
? `Description: ${bodySnippet}${issue.body && issue.body.length > 500 ? '...' : ''}`
|
|
79
|
+
: null,
|
|
80
|
+
`State: ${issue.state}`,
|
|
81
|
+
`Comments: ${issue.comments}`,
|
|
82
|
+
]
|
|
83
|
+
.filter(Boolean)
|
|
84
|
+
.join('\n');
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Parse owner/repo from a GitHub URL.
|
|
88
|
+
*/
|
|
89
|
+
function parseGitHubRepo(githubUrl) {
|
|
90
|
+
const match = githubUrl.match(/github\.com\/([^/]+)\/([^/]+)/i);
|
|
91
|
+
if (!match)
|
|
92
|
+
return null;
|
|
93
|
+
return { owner: match[1], repo: (match[2] ?? '').replace(/\.git$/, '') };
|
|
94
|
+
}
|
|
95
|
+
// ─── Handler ──────────────────────────────────────────────────────────────────
|
|
96
|
+
export async function handleCheckIssue(args) {
|
|
97
|
+
try {
|
|
98
|
+
const retryCount = args.retry_count ?? 0;
|
|
99
|
+
const docsConsulted = args.docs_consulted ?? false;
|
|
100
|
+
logger.info({ tool_name: args.tool_name, issue_title: args.issue_title, retryCount, docsConsulted }, 'check_issue called');
|
|
101
|
+
// ── Gate: enforce "docs first, then issues" protocol ─────────────────────
|
|
102
|
+
if (retryCount < DOCS_RETRY_THRESHOLD || !docsConsulted) {
|
|
103
|
+
const nextStep = !docsConsulted
|
|
104
|
+
? "Consult the documentation link in the tool's prompt_hint before calling check_issue. Read the changelog and README carefully — most errors are config or version issues."
|
|
105
|
+
: `Retry at least ${DOCS_RETRY_THRESHOLD} times total before checking GitHub issues. You have tried ${retryCount} time(s).`;
|
|
106
|
+
return okResult({
|
|
107
|
+
status: 'too_early',
|
|
108
|
+
message: 'check_issue is a last resort. Exhaust documentation and retries first.',
|
|
109
|
+
retry_count: retryCount,
|
|
110
|
+
docs_consulted: docsConsulted,
|
|
111
|
+
next_step: nextStep,
|
|
112
|
+
agent_instructions: [
|
|
113
|
+
'1. Try to fix the error yourself (up to 2 retries).',
|
|
114
|
+
"2. Read the tool's documentation — use the docs_url/readme_url from search_tools results.",
|
|
115
|
+
'3. Apply documentation guidance and retry (up to 2 more retries).',
|
|
116
|
+
'4. Only call check_issue after 4+ total retries AND docs_consulted=true.',
|
|
117
|
+
].join(' '),
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
// ── Look up tool in Memgraph to get github_url ────────────────────────────
|
|
121
|
+
const toolResult = await repo.findByName(args.tool_name);
|
|
122
|
+
if (!toolResult.ok) {
|
|
123
|
+
return errResult('db_error', toolResult.error.message);
|
|
124
|
+
}
|
|
125
|
+
if (!toolResult.data) {
|
|
126
|
+
return errResult('tool_not_found', `Tool '${args.tool_name}' is not in the ToolPilot index. Try search_tools to find the correct tool name.`);
|
|
127
|
+
}
|
|
128
|
+
const tool = toolResult.data;
|
|
129
|
+
const parsed = parseGitHubRepo(tool.github_url);
|
|
130
|
+
if (!parsed) {
|
|
131
|
+
return errResult('parse_error', `Cannot parse GitHub repo from: ${tool.github_url}`);
|
|
132
|
+
}
|
|
133
|
+
const { owner, repo: repoName } = parsed;
|
|
134
|
+
// ── Search GitHub Issues + PRs directly ──────────────────────────────────
|
|
135
|
+
logger.info({ owner, repo: repoName, query: args.issue_title }, 'Searching GitHub issues');
|
|
136
|
+
const [issues, prs] = await Promise.all([
|
|
137
|
+
searchGitHubIssues(owner, repoName, args.issue_title, 'issue'),
|
|
138
|
+
searchGitHubIssues(owner, repoName, args.issue_title, 'pr'),
|
|
139
|
+
]);
|
|
140
|
+
// ── CASE 1: Nothing found ─────────────────────────────────────────────────
|
|
141
|
+
if (issues.length === 0 && prs.length === 0) {
|
|
142
|
+
return okResult({
|
|
143
|
+
status: 'not_found',
|
|
144
|
+
tool: args.tool_name,
|
|
145
|
+
message: `No matching issue found on GitHub for '${args.tool_name}'. The problem may be specific to your environment or configuration.`,
|
|
146
|
+
github_issues_url: `${tool.github_url}/issues`,
|
|
147
|
+
agent_instructions: [
|
|
148
|
+
'No known GitHub issue matches this error.',
|
|
149
|
+
'Investigate: (1) environment/config differences, (2) version mismatch, (3) incorrect usage pattern.',
|
|
150
|
+
'Re-read the documentation section relevant to this error.',
|
|
151
|
+
'Consider searching GitHub manually with different keywords.',
|
|
152
|
+
].join(' '),
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
// Find the most relevant open issue
|
|
156
|
+
const openIssues = issues.filter((i) => i.state === 'open');
|
|
157
|
+
const closedIssues = issues.filter((i) => i.state === 'closed');
|
|
158
|
+
const topIssue = openIssues[0] ?? closedIssues[0];
|
|
159
|
+
// Find related open PRs (not merged yet)
|
|
160
|
+
const openPrs = prs.filter((pr) => pr.state === 'open');
|
|
161
|
+
const mergedPrs = prs.filter((pr) => pr.pull_request?.merged_at != null);
|
|
162
|
+
const topPr = openPrs[0] ?? mergedPrs[0];
|
|
163
|
+
// ── CASE 4: Fixed in a closed issue + merged PR ───────────────────────────
|
|
164
|
+
if (!topIssue || topIssue.state === 'closed') {
|
|
165
|
+
const fixInfo = mergedPrs[0]
|
|
166
|
+
? `PR #${mergedPrs[0].number} was merged: ${mergedPrs[0].html_url}`
|
|
167
|
+
: `Issue was closed: ${topIssue?.html_url ?? `${tool.github_url}/issues`}`;
|
|
168
|
+
return okResult({
|
|
169
|
+
status: 'fixed_in_version',
|
|
170
|
+
tool: args.tool_name,
|
|
171
|
+
issue: topIssue
|
|
172
|
+
? {
|
|
173
|
+
number: topIssue.number,
|
|
174
|
+
title: topIssue.title,
|
|
175
|
+
github_url: topIssue.html_url,
|
|
176
|
+
closed_at: topIssue.closed_at,
|
|
177
|
+
}
|
|
178
|
+
: null,
|
|
179
|
+
fix_info: fixInfo,
|
|
180
|
+
message: `This issue appears to have been fixed. ${fixInfo}`,
|
|
181
|
+
agent_instructions: 'Update the tool to the latest version to get this fix. Check the PR/release notes for the specific version.',
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
// ── Add 👍 reaction to the issue (signal that others have hit this too) ───
|
|
185
|
+
const reactionAdded = await addReaction(owner, repoName, topIssue.number);
|
|
186
|
+
logger.info({ issue: topIssue.number, reactionAdded }, 'Attempted to add 👍 reaction to issue');
|
|
187
|
+
// ── CASE 2: Open issue + open PR exists ───────────────────────────────────
|
|
188
|
+
if (topPr && topPr.state === 'open') {
|
|
189
|
+
return okResult({
|
|
190
|
+
status: 'fix_in_progress',
|
|
191
|
+
tool: args.tool_name,
|
|
192
|
+
issue: {
|
|
193
|
+
number: topIssue.number,
|
|
194
|
+
title: topIssue.title,
|
|
195
|
+
github_url: topIssue.html_url,
|
|
196
|
+
gist: buildIssueGist(topIssue),
|
|
197
|
+
},
|
|
198
|
+
pr: {
|
|
199
|
+
number: topPr.number,
|
|
200
|
+
title: topPr.title,
|
|
201
|
+
github_url: topPr.html_url,
|
|
202
|
+
state: 'open',
|
|
203
|
+
},
|
|
204
|
+
reaction_added: reactionAdded,
|
|
205
|
+
message: `Known issue — a fix is in progress (PR #${topPr.number}). Your 👍 reaction was ${reactionAdded ? 'added' : 'not added (no GitHub token)'} to signal impact.`,
|
|
206
|
+
agent_instructions: 'A fix is in progress. Consider: (1) checking if a pre-release/nightly build has the fix, (2) applying a temporary workaround, (3) tracking the PR for a stable release.',
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
// ── CASE 3: Open issue, no PR ─────────────────────────────────────────────
|
|
210
|
+
return okResult({
|
|
211
|
+
status: 'known_issue_no_fix',
|
|
212
|
+
tool: args.tool_name,
|
|
213
|
+
issue: {
|
|
214
|
+
number: topIssue.number,
|
|
215
|
+
title: topIssue.title,
|
|
216
|
+
github_url: topIssue.html_url,
|
|
217
|
+
state: topIssue.state,
|
|
218
|
+
comments: topIssue.comments,
|
|
219
|
+
created_at: topIssue.created_at,
|
|
220
|
+
gist: buildIssueGist(topIssue),
|
|
221
|
+
},
|
|
222
|
+
reaction_added: reactionAdded,
|
|
223
|
+
other_matching_issues: openIssues.slice(1, 3).map((i) => ({
|
|
224
|
+
number: i.number,
|
|
225
|
+
title: i.title,
|
|
226
|
+
github_url: i.html_url,
|
|
227
|
+
})),
|
|
228
|
+
message: `Known open issue (#${topIssue.number}): "${topIssue.title}". Your 👍 reaction was ${reactionAdded ? 'added' : 'not added'} to signal impact.`,
|
|
229
|
+
user_action_required: {
|
|
230
|
+
question: 'What would you like to do? Options: (a) Create a new issue report if your case has additional detail, (b) Handle it later, (c) Ignore.',
|
|
231
|
+
if_create_issue: "Ask the agent to generate an issue template — you can copy and paste it to GitHub manually. The agent will follow the repo's issue template format.",
|
|
232
|
+
github_new_issue_url: `${tool.github_url}/issues/new`,
|
|
233
|
+
},
|
|
234
|
+
agent_instructions: [
|
|
235
|
+
`Issue #${topIssue.number} is open with no fix yet.`,
|
|
236
|
+
'Ask the user whether they want to: (a) create a new issue, (b) handle it later, (c) ignore.',
|
|
237
|
+
"If user wants to create an issue: generate a detailed issue template using the repo's issue format, present it for the user to copy-paste manually.",
|
|
238
|
+
'Do NOT auto-submit any GitHub issue — always require explicit user action.',
|
|
239
|
+
'In the meantime, explore workarounds: different config, version pinning, or alternative approaches.',
|
|
240
|
+
].join(' '),
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
catch (e) {
|
|
244
|
+
logger.error({ err: e, tool_name: args.tool_name }, 'check_issue failed');
|
|
245
|
+
return errResult('internal_error', e instanceof Error ? e.message : String(e));
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
//# sourceMappingURL=check-issue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-issue.js","sourceRoot":"","sources":["../../src/tools/check-issue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,IAAI,EAAE,mCAAmC,EAAE,CAAC,CAAC;AACnE,MAAM,IAAI,GAAG,IAAI,sBAAsB,EAAE,CAAC;AAE1C,MAAM,oBAAoB,GAAG,CAAC,CAAC,CAAC,kDAAkD;AAwBlF,SAAS,aAAa;IACpB,MAAM,OAAO,GAA2B;QACtC,MAAM,EAAE,6BAA6B;QACrC,sBAAsB,EAAE,YAAY;KACrC,CAAC;IACF,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;QACxB,OAAO,CAAC,aAAa,GAAG,UAAU,MAAM,CAAC,YAAY,EAAE,CAAC;IAC1D,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,KAAK,UAAU,kBAAkB,CAC/B,KAAa,EACb,QAAgB,EAChB,KAAa,EACb,IAAoB;IAEpB,MAAM,CAAC,GAAG,kBAAkB,CAAC,GAAG,KAAK,SAAS,KAAK,IAAI,QAAQ,SAAS,IAAI,EAAE,CAAC,CAAC;IAChF,MAAM,GAAG,GAAG,0CAA0C,CAAC,4BAA4B,CAAC;IAEpF,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,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'tool_discovery' | 'stack_building' | 'tool_configuration' | 'tool_comparison' | 'debugging' | 'general_coding';
|
|
2
|
+
export declare function handleClassifyPrompt(args: {
|
|
3
|
+
prompt: string;
|
|
4
|
+
project_tools?: string[];
|
|
5
|
+
}): Promise<{
|
|
6
|
+
[x: string]: unknown;
|
|
7
|
+
content: ({
|
|
8
|
+
type: "text";
|
|
9
|
+
text: string;
|
|
10
|
+
annotations?: {
|
|
11
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
12
|
+
priority?: number | undefined;
|
|
13
|
+
lastModified?: string | undefined;
|
|
14
|
+
} | undefined;
|
|
15
|
+
_meta?: {
|
|
16
|
+
[x: string]: unknown;
|
|
17
|
+
} | undefined;
|
|
18
|
+
} | {
|
|
19
|
+
type: "image";
|
|
20
|
+
data: string;
|
|
21
|
+
mimeType: string;
|
|
22
|
+
annotations?: {
|
|
23
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
24
|
+
priority?: number | undefined;
|
|
25
|
+
lastModified?: string | undefined;
|
|
26
|
+
} | undefined;
|
|
27
|
+
_meta?: {
|
|
28
|
+
[x: string]: unknown;
|
|
29
|
+
} | undefined;
|
|
30
|
+
} | {
|
|
31
|
+
type: "audio";
|
|
32
|
+
data: string;
|
|
33
|
+
mimeType: string;
|
|
34
|
+
annotations?: {
|
|
35
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
36
|
+
priority?: number | undefined;
|
|
37
|
+
lastModified?: string | undefined;
|
|
38
|
+
} | undefined;
|
|
39
|
+
_meta?: {
|
|
40
|
+
[x: string]: unknown;
|
|
41
|
+
} | undefined;
|
|
42
|
+
} | {
|
|
43
|
+
uri: string;
|
|
44
|
+
name: string;
|
|
45
|
+
type: "resource_link";
|
|
46
|
+
description?: string | undefined;
|
|
47
|
+
mimeType?: string | undefined;
|
|
48
|
+
annotations?: {
|
|
49
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
50
|
+
priority?: number | undefined;
|
|
51
|
+
lastModified?: string | undefined;
|
|
52
|
+
} | undefined;
|
|
53
|
+
_meta?: {
|
|
54
|
+
[x: string]: unknown;
|
|
55
|
+
} | undefined;
|
|
56
|
+
icons?: {
|
|
57
|
+
src: string;
|
|
58
|
+
mimeType?: string | undefined;
|
|
59
|
+
sizes?: string[] | undefined;
|
|
60
|
+
theme?: "light" | "dark" | undefined;
|
|
61
|
+
}[] | undefined;
|
|
62
|
+
title?: string | undefined;
|
|
63
|
+
} | {
|
|
64
|
+
type: "resource";
|
|
65
|
+
resource: {
|
|
66
|
+
uri: string;
|
|
67
|
+
text: string;
|
|
68
|
+
mimeType?: string | undefined;
|
|
69
|
+
_meta?: {
|
|
70
|
+
[x: string]: unknown;
|
|
71
|
+
} | undefined;
|
|
72
|
+
} | {
|
|
73
|
+
uri: string;
|
|
74
|
+
blob: string;
|
|
75
|
+
mimeType?: string | undefined;
|
|
76
|
+
_meta?: {
|
|
77
|
+
[x: string]: unknown;
|
|
78
|
+
} | undefined;
|
|
79
|
+
};
|
|
80
|
+
annotations?: {
|
|
81
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
82
|
+
priority?: number | undefined;
|
|
83
|
+
lastModified?: string | undefined;
|
|
84
|
+
} | undefined;
|
|
85
|
+
_meta?: {
|
|
86
|
+
[x: string]: unknown;
|
|
87
|
+
} | undefined;
|
|
88
|
+
})[];
|
|
89
|
+
_meta?: {
|
|
90
|
+
[x: string]: unknown;
|
|
91
|
+
progressToken?: string | number | undefined;
|
|
92
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
93
|
+
taskId: string;
|
|
94
|
+
} | undefined;
|
|
95
|
+
} | undefined;
|
|
96
|
+
structuredContent?: {
|
|
97
|
+
[x: string]: unknown;
|
|
98
|
+
} | undefined;
|
|
99
|
+
isError?: boolean | undefined;
|
|
100
|
+
}>;
|
|
101
|
+
//# sourceMappingURL=classify-prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classify-prompt.d.ts","sourceRoot":"","sources":["../../src/tools/classify-prompt.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,oBAAoB,GAC5B,gBAAgB,GAChB,gBAAgB,GAChB,oBAAoB,GACpB,iBAAiB,GACjB,WAAW,GACX,gBAAgB,CAAC;AASrB,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DA"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import pino from 'pino';
|
|
2
|
+
import { errResult, okResult } from '../utils.js';
|
|
3
|
+
const logger = pino({ name: '@toolpilot/mcp-server:classify-prompt' });
|
|
4
|
+
// Categories where ToolPilot search is useful
|
|
5
|
+
const TOOL_REQUIRED_CLASSIFICATIONS = [
|
|
6
|
+
'tool_discovery',
|
|
7
|
+
'stack_building',
|
|
8
|
+
'tool_comparison',
|
|
9
|
+
];
|
|
10
|
+
export async function handleClassifyPrompt(args) {
|
|
11
|
+
try {
|
|
12
|
+
logger.info({ promptLen: args.prompt.length }, 'classify_prompt called');
|
|
13
|
+
const projectToolsContext = args.project_tools && args.project_tools.length > 0
|
|
14
|
+
? `\n\nThe project already uses: ${args.project_tools.join(', ')}. Consider whether the prompt relates to tools already confirmed in the project.`
|
|
15
|
+
: '';
|
|
16
|
+
// Build a structured prompt the agent uses to classify
|
|
17
|
+
const classification_prompt = `Classify the following developer prompt into exactly ONE of these categories:
|
|
18
|
+
|
|
19
|
+
Categories:
|
|
20
|
+
- tool_discovery: The developer needs to find, select, or identify a tool, library, framework, or service
|
|
21
|
+
- stack_building: The developer needs to compose multiple tools together to build a complete system
|
|
22
|
+
- tool_comparison: The developer wants to compare two or more specific tools
|
|
23
|
+
- tool_configuration: The developer already has a tool chosen and needs help configuring or using it
|
|
24
|
+
- debugging: The developer is encountering an error, bug, or unexpected behavior
|
|
25
|
+
- general_coding: Architecture, business logic, algorithms — no new tool selection is needed
|
|
26
|
+
|
|
27
|
+
Rules:
|
|
28
|
+
1. If the prompt involves building something "from scratch" or asks for tech stack recommendations, classify as stack_building
|
|
29
|
+
2. If the prompt mentions a specific tool and asks "should I use X or Y", classify as tool_comparison
|
|
30
|
+
3. If the prompt is about implementing features WITHOUT mentioning specific tools, classify as tool_discovery
|
|
31
|
+
4. If the prompt mentions an error message, traceback, or "not working", classify as debugging
|
|
32
|
+
5. Respond with ONLY the category name, nothing else
|
|
33
|
+
|
|
34
|
+
Prompt to classify:
|
|
35
|
+
"""
|
|
36
|
+
${args.prompt}
|
|
37
|
+
"""${projectToolsContext}
|
|
38
|
+
|
|
39
|
+
Your response (one category name only):`;
|
|
40
|
+
const needs_tool_search_prompt = `Based on this classification, determine if ToolPilot tool search should be invoked.
|
|
41
|
+
Respond with 1 if the classification is one of: tool_discovery, stack_building, tool_comparison
|
|
42
|
+
Respond with 0 if the classification is: tool_configuration, debugging, general_coding
|
|
43
|
+
Respond with ONLY 0 or 1.`;
|
|
44
|
+
return okResult({
|
|
45
|
+
classification_prompt,
|
|
46
|
+
needs_tool_search_prompt,
|
|
47
|
+
valid_classifications: [
|
|
48
|
+
'tool_discovery',
|
|
49
|
+
'stack_building',
|
|
50
|
+
'tool_comparison',
|
|
51
|
+
'tool_configuration',
|
|
52
|
+
'debugging',
|
|
53
|
+
'general_coding',
|
|
54
|
+
],
|
|
55
|
+
tool_required_if: TOOL_REQUIRED_CLASSIFICATIONS,
|
|
56
|
+
instructions: 'Step 1: Send classification_prompt to the LLM and get a classification. Step 2: If classification is in tool_required_if, call refine_requirement with the classification. Otherwise, proceed without ToolPilot search.',
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
logger.error({ err: e }, 'classify_prompt failed');
|
|
61
|
+
return errResult('classify_error', e instanceof Error ? e.message : String(e));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=classify-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classify-prompt.js","sourceRoot":"","sources":["../../src/tools/classify-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,IAAI,EAAE,uCAAuC,EAAE,CAAC,CAAC;AAWvE,8CAA8C;AAC9C,MAAM,6BAA6B,GAA2B;IAC5D,gBAAgB;IAChB,gBAAgB;IAChB,iBAAiB;CAClB,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,IAG1C;IACC,IAAI,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,wBAAwB,CAAC,CAAC;QAEzE,MAAM,mBAAmB,GACvB,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC;YACjD,CAAC,CAAC,iCAAiC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,kFAAkF;YAClJ,CAAC,CAAC,EAAE,CAAC;QAET,uDAAuD;QACvD,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;EAmBhC,IAAI,CAAC,MAAM;KACR,mBAAmB;;wCAEgB,CAAC;QAErC,MAAM,wBAAwB,GAAG;;;0BAGX,CAAC;QAEvB,OAAO,QAAQ,CAAC;YACd,qBAAqB;YACrB,wBAAwB;YACxB,qBAAqB,EAAE;gBACrB,gBAAgB;gBAChB,gBAAgB;gBAChB,iBAAiB;gBACjB,oBAAoB;gBACpB,WAAW;gBACX,gBAAgB;aACS;YAC3B,gBAAgB,EAAE,6BAA6B;YAC/C,YAAY,EACV,yNAAyN;SAC5N,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,wBAAwB,CAAC,CAAC;QACnD,OAAO,SAAS,CAAC,gBAAgB,EAAE,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACjF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export declare function handleCompareTools(args: {
|
|
2
|
+
tool_a: string;
|
|
3
|
+
tool_b: string;
|
|
4
|
+
use_case?: string;
|
|
5
|
+
project_config?: string;
|
|
6
|
+
}): Promise<{
|
|
7
|
+
[x: string]: unknown;
|
|
8
|
+
content: ({
|
|
9
|
+
type: "text";
|
|
10
|
+
text: string;
|
|
11
|
+
annotations?: {
|
|
12
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
13
|
+
priority?: number | undefined;
|
|
14
|
+
lastModified?: string | undefined;
|
|
15
|
+
} | undefined;
|
|
16
|
+
_meta?: {
|
|
17
|
+
[x: string]: unknown;
|
|
18
|
+
} | undefined;
|
|
19
|
+
} | {
|
|
20
|
+
type: "image";
|
|
21
|
+
data: string;
|
|
22
|
+
mimeType: string;
|
|
23
|
+
annotations?: {
|
|
24
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
25
|
+
priority?: number | undefined;
|
|
26
|
+
lastModified?: string | undefined;
|
|
27
|
+
} | undefined;
|
|
28
|
+
_meta?: {
|
|
29
|
+
[x: string]: unknown;
|
|
30
|
+
} | undefined;
|
|
31
|
+
} | {
|
|
32
|
+
type: "audio";
|
|
33
|
+
data: string;
|
|
34
|
+
mimeType: string;
|
|
35
|
+
annotations?: {
|
|
36
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
37
|
+
priority?: number | undefined;
|
|
38
|
+
lastModified?: string | undefined;
|
|
39
|
+
} | undefined;
|
|
40
|
+
_meta?: {
|
|
41
|
+
[x: string]: unknown;
|
|
42
|
+
} | undefined;
|
|
43
|
+
} | {
|
|
44
|
+
uri: string;
|
|
45
|
+
name: string;
|
|
46
|
+
type: "resource_link";
|
|
47
|
+
description?: string | undefined;
|
|
48
|
+
mimeType?: string | undefined;
|
|
49
|
+
annotations?: {
|
|
50
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
51
|
+
priority?: number | undefined;
|
|
52
|
+
lastModified?: string | undefined;
|
|
53
|
+
} | undefined;
|
|
54
|
+
_meta?: {
|
|
55
|
+
[x: string]: unknown;
|
|
56
|
+
} | undefined;
|
|
57
|
+
icons?: {
|
|
58
|
+
src: string;
|
|
59
|
+
mimeType?: string | undefined;
|
|
60
|
+
sizes?: string[] | undefined;
|
|
61
|
+
theme?: "light" | "dark" | undefined;
|
|
62
|
+
}[] | undefined;
|
|
63
|
+
title?: string | undefined;
|
|
64
|
+
} | {
|
|
65
|
+
type: "resource";
|
|
66
|
+
resource: {
|
|
67
|
+
uri: string;
|
|
68
|
+
text: string;
|
|
69
|
+
mimeType?: string | undefined;
|
|
70
|
+
_meta?: {
|
|
71
|
+
[x: string]: unknown;
|
|
72
|
+
} | undefined;
|
|
73
|
+
} | {
|
|
74
|
+
uri: string;
|
|
75
|
+
blob: string;
|
|
76
|
+
mimeType?: string | undefined;
|
|
77
|
+
_meta?: {
|
|
78
|
+
[x: string]: unknown;
|
|
79
|
+
} | undefined;
|
|
80
|
+
};
|
|
81
|
+
annotations?: {
|
|
82
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
83
|
+
priority?: number | undefined;
|
|
84
|
+
lastModified?: string | undefined;
|
|
85
|
+
} | undefined;
|
|
86
|
+
_meta?: {
|
|
87
|
+
[x: string]: unknown;
|
|
88
|
+
} | undefined;
|
|
89
|
+
})[];
|
|
90
|
+
_meta?: {
|
|
91
|
+
[x: string]: unknown;
|
|
92
|
+
progressToken?: string | number | undefined;
|
|
93
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
94
|
+
taskId: string;
|
|
95
|
+
} | undefined;
|
|
96
|
+
} | undefined;
|
|
97
|
+
structuredContent?: {
|
|
98
|
+
[x: string]: unknown;
|
|
99
|
+
} | undefined;
|
|
100
|
+
isError?: boolean | undefined;
|
|
101
|
+
}>;
|
|
102
|
+
//# sourceMappingURL=compare-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compare-tools.d.ts","sourceRoot":"","sources":["../../src/tools/compare-tools.ts"],"names":[],"mappings":"AAgEA,wBAAsB,kBAAkB,CAAC,IAAI,EAAE;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4JA"}
|