@hailer/mcp 0.1.17 → 0.2.1
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/dist/app.js +24 -20
- package/dist/core.d.ts +33 -9
- package/dist/core.js +279 -147
- package/dist/mcp/UserContextCache.js +18 -0
- package/dist/mcp/hailer-clients.d.ts +9 -1
- package/dist/mcp/hailer-clients.js +13 -3
- package/dist/mcp/signal-handler.js +1 -1
- package/dist/mcp/tool-registry.d.ts +3 -1
- package/dist/mcp/tool-registry.js +4 -1
- package/dist/mcp/tools/activity.js +43 -34
- package/dist/mcp/tools/bot-config/constants.d.ts +23 -0
- package/dist/mcp/tools/bot-config/constants.js +94 -0
- package/dist/mcp/tools/{bot-config.d.ts → bot-config/core.d.ts} +6 -6
- package/dist/mcp/tools/{bot-config.js → bot-config/core.js} +15 -15
- package/dist/mcp/tools/bot-config/index.d.ts +10 -0
- package/dist/mcp/tools/bot-config/index.js +59 -0
- package/dist/mcp/tools/bot-config/tools.d.ts +7 -0
- package/dist/mcp/tools/bot-config/tools.js +15 -0
- package/dist/mcp/tools/bot-config/types.d.ts +50 -0
- package/dist/mcp/tools/bot-config/types.js +6 -0
- package/dist/mcp/tools/bug-fixer-tools.d.ts +21 -0
- package/dist/mcp/tools/{giuseppe-tools.js → bug-fixer-tools.js} +61 -61
- package/dist/mcp/tools/user.js +10 -29
- package/dist/mcp/tools/workflow.js +36 -2
- package/dist/mcp/utils/data-transformers.d.ts +0 -8
- package/dist/mcp/utils/data-transformers.js +0 -28
- package/dist/mcp/utils/index.d.ts +4 -1
- package/dist/mcp/utils/index.js +17 -3
- package/dist/mcp/utils/pagination.d.ts +40 -0
- package/dist/mcp/utils/pagination.js +55 -0
- package/dist/mcp/utils/response-builder.d.ts +53 -0
- package/dist/mcp/utils/response-builder.js +110 -0
- package/dist/mcp/utils/tool-helpers.d.ts +0 -8
- package/dist/mcp/utils/tool-helpers.js +0 -24
- package/dist/mcp/utils/types.d.ts +1 -33
- package/dist/mcp-server.d.ts +2 -2
- package/dist/mcp-server.js +161 -139
- package/package.json +1 -1
- package/REFACTOR_STATUS.md +0 -127
- package/dist/agents/bot-manager.d.ts +0 -48
- package/dist/agents/bot-manager.js +0 -254
- package/dist/agents/factory.d.ts +0 -150
- package/dist/agents/factory.js +0 -650
- package/dist/agents/giuseppe/ai.d.ts +0 -83
- package/dist/agents/giuseppe/ai.js +0 -466
- package/dist/agents/giuseppe/bot.d.ts +0 -110
- package/dist/agents/giuseppe/bot.js +0 -780
- package/dist/agents/giuseppe/config.d.ts +0 -25
- package/dist/agents/giuseppe/config.js +0 -227
- package/dist/agents/giuseppe/files.d.ts +0 -52
- package/dist/agents/giuseppe/files.js +0 -338
- package/dist/agents/giuseppe/git.d.ts +0 -48
- package/dist/agents/giuseppe/git.js +0 -298
- package/dist/agents/giuseppe/index.d.ts +0 -97
- package/dist/agents/giuseppe/index.js +0 -258
- package/dist/agents/giuseppe/lsp.d.ts +0 -113
- package/dist/agents/giuseppe/lsp.js +0 -485
- package/dist/agents/giuseppe/monitor.d.ts +0 -118
- package/dist/agents/giuseppe/monitor.js +0 -621
- package/dist/agents/giuseppe/prompt.d.ts +0 -5
- package/dist/agents/giuseppe/prompt.js +0 -94
- package/dist/agents/giuseppe/registries/pending-classification.d.ts +0 -28
- package/dist/agents/giuseppe/registries/pending-classification.js +0 -50
- package/dist/agents/giuseppe/registries/pending-fix.d.ts +0 -30
- package/dist/agents/giuseppe/registries/pending-fix.js +0 -42
- package/dist/agents/giuseppe/registries/pending.d.ts +0 -27
- package/dist/agents/giuseppe/registries/pending.js +0 -49
- package/dist/agents/giuseppe/specialist.d.ts +0 -47
- package/dist/agents/giuseppe/specialist.js +0 -237
- package/dist/agents/giuseppe/types.d.ts +0 -123
- package/dist/agents/giuseppe/types.js +0 -9
- package/dist/agents/hailer-expert/index.d.ts +0 -8
- package/dist/agents/hailer-expert/index.js +0 -14
- package/dist/agents/hal/daemon.d.ts +0 -142
- package/dist/agents/hal/daemon.js +0 -1103
- package/dist/agents/hal/definitions.d.ts +0 -55
- package/dist/agents/hal/definitions.js +0 -263
- package/dist/agents/hal/index.d.ts +0 -3
- package/dist/agents/hal/index.js +0 -8
- package/dist/agents/index.d.ts +0 -18
- package/dist/agents/index.js +0 -48
- package/dist/agents/shared/base.d.ts +0 -216
- package/dist/agents/shared/base.js +0 -846
- package/dist/agents/shared/services/agent-registry.d.ts +0 -107
- package/dist/agents/shared/services/agent-registry.js +0 -629
- package/dist/agents/shared/services/conversation-manager.d.ts +0 -50
- package/dist/agents/shared/services/conversation-manager.js +0 -136
- package/dist/agents/shared/services/mcp-client.d.ts +0 -56
- package/dist/agents/shared/services/mcp-client.js +0 -124
- package/dist/agents/shared/services/message-classifier.d.ts +0 -37
- package/dist/agents/shared/services/message-classifier.js +0 -187
- package/dist/agents/shared/services/message-formatter.d.ts +0 -89
- package/dist/agents/shared/services/message-formatter.js +0 -371
- package/dist/agents/shared/services/session-logger.d.ts +0 -106
- package/dist/agents/shared/services/session-logger.js +0 -446
- package/dist/agents/shared/services/tool-executor.d.ts +0 -41
- package/dist/agents/shared/services/tool-executor.js +0 -169
- package/dist/agents/shared/services/workspace-schema-cache.d.ts +0 -125
- package/dist/agents/shared/services/workspace-schema-cache.js +0 -578
- package/dist/agents/shared/specialist.d.ts +0 -91
- package/dist/agents/shared/specialist.js +0 -399
- package/dist/agents/shared/tool-schema-loader.d.ts +0 -62
- package/dist/agents/shared/tool-schema-loader.js +0 -232
- package/dist/agents/shared/types.d.ts +0 -327
- package/dist/agents/shared/types.js +0 -121
- package/dist/client/agents/base.d.ts +0 -207
- package/dist/client/agents/base.js +0 -744
- package/dist/client/agents/definitions.d.ts +0 -53
- package/dist/client/agents/definitions.js +0 -263
- package/dist/client/agents/orchestrator.d.ts +0 -141
- package/dist/client/agents/orchestrator.js +0 -1062
- package/dist/client/agents/specialist.d.ts +0 -86
- package/dist/client/agents/specialist.js +0 -340
- package/dist/client/bot-entrypoint.d.ts +0 -7
- package/dist/client/bot-entrypoint.js +0 -103
- package/dist/client/bot-manager.d.ts +0 -44
- package/dist/client/bot-manager.js +0 -173
- package/dist/client/bot-runner.d.ts +0 -35
- package/dist/client/bot-runner.js +0 -188
- package/dist/client/chat-agent-daemon.d.ts +0 -464
- package/dist/client/chat-agent-daemon.js +0 -1774
- package/dist/client/daemon-factory.d.ts +0 -106
- package/dist/client/daemon-factory.js +0 -301
- package/dist/client/factory.d.ts +0 -111
- package/dist/client/factory.js +0 -314
- package/dist/client/index.d.ts +0 -17
- package/dist/client/index.js +0 -38
- package/dist/client/multi-bot-manager.d.ts +0 -42
- package/dist/client/multi-bot-manager.js +0 -161
- package/dist/client/orchestrator-daemon.d.ts +0 -87
- package/dist/client/orchestrator-daemon.js +0 -444
- package/dist/client/server.d.ts +0 -8
- package/dist/client/server.js +0 -251
- package/dist/client/services/agent-registry.d.ts +0 -108
- package/dist/client/services/agent-registry.js +0 -630
- package/dist/client/services/conversation-manager.d.ts +0 -50
- package/dist/client/services/conversation-manager.js +0 -136
- package/dist/client/services/mcp-client.d.ts +0 -48
- package/dist/client/services/mcp-client.js +0 -105
- package/dist/client/services/message-classifier.d.ts +0 -37
- package/dist/client/services/message-classifier.js +0 -187
- package/dist/client/services/message-formatter.d.ts +0 -84
- package/dist/client/services/message-formatter.js +0 -353
- package/dist/client/services/session-logger.d.ts +0 -106
- package/dist/client/services/session-logger.js +0 -446
- package/dist/client/services/tool-executor.d.ts +0 -41
- package/dist/client/services/tool-executor.js +0 -169
- package/dist/client/services/workspace-schema-cache.d.ts +0 -149
- package/dist/client/services/workspace-schema-cache.js +0 -732
- package/dist/client/specialist-daemon.d.ts +0 -77
- package/dist/client/specialist-daemon.js +0 -197
- package/dist/client/specialists.d.ts +0 -53
- package/dist/client/specialists.js +0 -178
- package/dist/client/tool-schema-loader.d.ts +0 -62
- package/dist/client/tool-schema-loader.js +0 -232
- package/dist/client/types.d.ts +0 -327
- package/dist/client/types.js +0 -121
- package/dist/commands/seed-config.d.ts +0 -9
- package/dist/commands/seed-config.js +0 -372
- package/dist/lib/context-manager.d.ts +0 -111
- package/dist/lib/context-manager.js +0 -431
- package/dist/lib/prompt-length-manager.d.ts +0 -81
- package/dist/lib/prompt-length-manager.js +0 -457
- package/dist/mcp/tools/giuseppe-tools.d.ts +0 -21
- package/dist/modules/bug-reports/bug-config.d.ts +0 -25
- package/dist/modules/bug-reports/bug-config.js +0 -187
- package/dist/modules/bug-reports/bug-monitor.d.ts +0 -108
- package/dist/modules/bug-reports/bug-monitor.js +0 -510
- package/dist/modules/bug-reports/giuseppe-agent.d.ts +0 -58
- package/dist/modules/bug-reports/giuseppe-agent.js +0 -467
- package/dist/modules/bug-reports/giuseppe-ai.d.ts +0 -83
- package/dist/modules/bug-reports/giuseppe-ai.js +0 -466
- package/dist/modules/bug-reports/giuseppe-bot.d.ts +0 -110
- package/dist/modules/bug-reports/giuseppe-bot.js +0 -804
- package/dist/modules/bug-reports/giuseppe-daemon.d.ts +0 -80
- package/dist/modules/bug-reports/giuseppe-daemon.js +0 -617
- package/dist/modules/bug-reports/giuseppe-files.d.ts +0 -64
- package/dist/modules/bug-reports/giuseppe-files.js +0 -375
- package/dist/modules/bug-reports/giuseppe-git.d.ts +0 -48
- package/dist/modules/bug-reports/giuseppe-git.js +0 -298
- package/dist/modules/bug-reports/giuseppe-lsp.d.ts +0 -113
- package/dist/modules/bug-reports/giuseppe-lsp.js +0 -485
- package/dist/modules/bug-reports/giuseppe-prompt.d.ts +0 -5
- package/dist/modules/bug-reports/giuseppe-prompt.js +0 -94
- package/dist/modules/bug-reports/index.d.ts +0 -77
- package/dist/modules/bug-reports/index.js +0 -215
- package/dist/modules/bug-reports/pending-classification-registry.d.ts +0 -28
- package/dist/modules/bug-reports/pending-classification-registry.js +0 -50
- package/dist/modules/bug-reports/pending-fix-registry.d.ts +0 -30
- package/dist/modules/bug-reports/pending-fix-registry.js +0 -42
- package/dist/modules/bug-reports/pending-registry.d.ts +0 -27
- package/dist/modules/bug-reports/pending-registry.js +0 -49
- package/dist/modules/bug-reports/types.d.ts +0 -123
- package/dist/modules/bug-reports/types.js +0 -9
- package/dist/routes/agents.d.ts +0 -44
- package/dist/routes/agents.js +0 -311
- package/dist/services/agent-credential-store.d.ts +0 -73
- package/dist/services/agent-credential-store.js +0 -212
- package/dist/services/bug-monitor.d.ts +0 -23
- package/dist/services/bug-monitor.js +0 -275
|
@@ -1,467 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Giuseppe Agent - Full Conversational Bug Fixer
|
|
4
|
-
*
|
|
5
|
-
* A natural language agent that handles bug fixing through conversation.
|
|
6
|
-
* No keywords, no intent detection - just natural dialogue with tools.
|
|
7
|
-
*/
|
|
8
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
-
}
|
|
14
|
-
Object.defineProperty(o, k2, desc);
|
|
15
|
-
}) : (function(o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
o[k2] = m[k];
|
|
18
|
-
}));
|
|
19
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
-
}) : function(o, v) {
|
|
22
|
-
o["default"] = v;
|
|
23
|
-
});
|
|
24
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
-
var ownKeys = function(o) {
|
|
26
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
-
var ar = [];
|
|
28
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
-
return ar;
|
|
30
|
-
};
|
|
31
|
-
return ownKeys(o);
|
|
32
|
-
};
|
|
33
|
-
return function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
})();
|
|
41
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
42
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
43
|
-
};
|
|
44
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.GiuseppeAgent = void 0;
|
|
46
|
-
const sdk_1 = __importDefault(require("@anthropic-ai/sdk"));
|
|
47
|
-
const child_process_1 = require("child_process");
|
|
48
|
-
const logger_1 = require("../../lib/logger");
|
|
49
|
-
const giuseppe_files_1 = require("./giuseppe-files");
|
|
50
|
-
const giuseppe_git_1 = require("./giuseppe-git");
|
|
51
|
-
const giuseppe_lsp_1 = require("./giuseppe-lsp");
|
|
52
|
-
const logger = (0, logger_1.createLogger)({ component: 'giuseppe-agent' });
|
|
53
|
-
class GiuseppeAgent {
|
|
54
|
-
userContext;
|
|
55
|
-
monitor;
|
|
56
|
-
appsBasePath;
|
|
57
|
-
anthropic;
|
|
58
|
-
conversations = new Map();
|
|
59
|
-
bugContexts = new Map();
|
|
60
|
-
// Sub-modules
|
|
61
|
-
files;
|
|
62
|
-
git;
|
|
63
|
-
lsp;
|
|
64
|
-
constructor(userContext, monitor, appsBasePath, apiKey) {
|
|
65
|
-
this.userContext = userContext;
|
|
66
|
-
this.monitor = monitor;
|
|
67
|
-
this.appsBasePath = appsBasePath;
|
|
68
|
-
this.anthropic = new sdk_1.default({ apiKey: apiKey || process.env.ANTHROPIC_API_KEY });
|
|
69
|
-
this.files = new giuseppe_files_1.GiuseppeFiles(appsBasePath);
|
|
70
|
-
this.git = new giuseppe_git_1.GiuseppeGit();
|
|
71
|
-
this.lsp = new giuseppe_lsp_1.GiuseppeLsp();
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Handle a new bug - start the conversation
|
|
75
|
-
*/
|
|
76
|
-
async handleNewBug(bug) {
|
|
77
|
-
if (!bug.discussionId) {
|
|
78
|
-
logger.warn('Bug has no discussion, cannot start conversation', { bugId: bug.id });
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
// Store bug context
|
|
82
|
-
this.bugContexts.set(bug.discussionId, { bug });
|
|
83
|
-
// Find the app
|
|
84
|
-
const app = await this.files.findAppFromBugTitle(bug.name);
|
|
85
|
-
if (app) {
|
|
86
|
-
this.bugContexts.get(bug.discussionId).app = app;
|
|
87
|
-
}
|
|
88
|
-
// Start fresh conversation
|
|
89
|
-
this.conversations.set(bug.discussionId, []);
|
|
90
|
-
// Send initial message with bug context
|
|
91
|
-
const initialPrompt = this.buildInitialPrompt(bug, app);
|
|
92
|
-
const response = await this.chat(bug.discussionId, initialPrompt, true);
|
|
93
|
-
// Post response to discussion
|
|
94
|
-
await this.postMessage(bug.discussionId, response);
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Handle any message in the bug discussion
|
|
98
|
-
*/
|
|
99
|
-
async handleMessage(discussionId, message, senderName) {
|
|
100
|
-
const context = this.bugContexts.get(discussionId);
|
|
101
|
-
if (!context) {
|
|
102
|
-
logger.debug('No bug context for discussion, ignoring', { discussionId });
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
// Add user message to conversation
|
|
106
|
-
const userMessage = `${senderName}: ${message}`;
|
|
107
|
-
const response = await this.chat(discussionId, userMessage, false);
|
|
108
|
-
// Post response
|
|
109
|
-
await this.postMessage(discussionId, response);
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Chat with the LLM - handles tool calls automatically
|
|
113
|
-
*/
|
|
114
|
-
async chat(discussionId, userMessage, isSystemContext) {
|
|
115
|
-
const conversation = this.conversations.get(discussionId) || [];
|
|
116
|
-
// Add user message
|
|
117
|
-
conversation.push({ role: 'user', content: userMessage });
|
|
118
|
-
// Keep conversation manageable
|
|
119
|
-
if (conversation.length > 30) {
|
|
120
|
-
conversation.splice(0, conversation.length - 20);
|
|
121
|
-
}
|
|
122
|
-
try {
|
|
123
|
-
const response = await this.anthropic.messages.create({
|
|
124
|
-
model: 'claude-sonnet-4-20250514',
|
|
125
|
-
max_tokens: 4096,
|
|
126
|
-
system: this.getSystemPrompt(),
|
|
127
|
-
messages: conversation,
|
|
128
|
-
tools: this.getTools(),
|
|
129
|
-
});
|
|
130
|
-
// Handle tool calls
|
|
131
|
-
let finalResponse = response;
|
|
132
|
-
while (finalResponse.stop_reason === 'tool_use') {
|
|
133
|
-
const toolResults = await this.executeToolCalls(finalResponse.content, discussionId);
|
|
134
|
-
// Add assistant response and tool results
|
|
135
|
-
conversation.push({ role: 'assistant', content: finalResponse.content });
|
|
136
|
-
conversation.push({ role: 'user', content: toolResults });
|
|
137
|
-
// Continue conversation
|
|
138
|
-
finalResponse = await this.anthropic.messages.create({
|
|
139
|
-
model: 'claude-sonnet-4-20250514',
|
|
140
|
-
max_tokens: 4096,
|
|
141
|
-
system: this.getSystemPrompt(),
|
|
142
|
-
messages: conversation,
|
|
143
|
-
tools: this.getTools(),
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
// Extract text response
|
|
147
|
-
const textContent = finalResponse.content
|
|
148
|
-
.filter((block) => block.type === 'text')
|
|
149
|
-
.map(block => block.text)
|
|
150
|
-
.join('\n');
|
|
151
|
-
// Save final response
|
|
152
|
-
conversation.push({ role: 'assistant', content: finalResponse.content });
|
|
153
|
-
this.conversations.set(discussionId, conversation);
|
|
154
|
-
return textContent || "I'm not sure how to respond to that.";
|
|
155
|
-
}
|
|
156
|
-
catch (error) {
|
|
157
|
-
logger.error('Chat failed', { error, discussionId });
|
|
158
|
-
return "Sorry, I encountered an error. Please try again.";
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Execute tool calls and return results
|
|
163
|
-
*/
|
|
164
|
-
async executeToolCalls(content, discussionId) {
|
|
165
|
-
const toolUses = content.filter((block) => block.type === 'tool_use');
|
|
166
|
-
const results = [];
|
|
167
|
-
const context = this.bugContexts.get(discussionId);
|
|
168
|
-
for (const tool of toolUses) {
|
|
169
|
-
try {
|
|
170
|
-
const result = await this.executeTool(tool.name, tool.input, context);
|
|
171
|
-
results.push({
|
|
172
|
-
type: 'tool_result',
|
|
173
|
-
tool_use_id: tool.id,
|
|
174
|
-
content: JSON.stringify(result),
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
catch (error) {
|
|
178
|
-
results.push({
|
|
179
|
-
type: 'tool_result',
|
|
180
|
-
tool_use_id: tool.id,
|
|
181
|
-
content: JSON.stringify({ error: error.message }),
|
|
182
|
-
is_error: true,
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return results;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Execute a single tool
|
|
190
|
-
*/
|
|
191
|
-
async executeTool(name, input, context) {
|
|
192
|
-
const projectPath = context?.app?.projectPath || input.projectPath;
|
|
193
|
-
switch (name) {
|
|
194
|
-
case 'check_git_status': {
|
|
195
|
-
try {
|
|
196
|
-
const status = (0, child_process_1.execSync)('git status --short', { cwd: projectPath, encoding: 'utf-8' });
|
|
197
|
-
const branch = (0, child_process_1.execSync)('git branch --show-current', { cwd: projectPath, encoding: 'utf-8' }).trim();
|
|
198
|
-
const behindAhead = (0, child_process_1.execSync)('git rev-list --left-right --count HEAD...@{upstream} 2>/dev/null || echo "0 0"', { cwd: projectPath, encoding: 'utf-8' }).trim().split(/\s+/);
|
|
199
|
-
return {
|
|
200
|
-
branch,
|
|
201
|
-
status: status || 'clean',
|
|
202
|
-
behind: parseInt(behindAhead[1]) || 0,
|
|
203
|
-
ahead: parseInt(behindAhead[0]) || 0
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
catch (e) {
|
|
207
|
-
return { error: e.message };
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
case 'git_pull': {
|
|
211
|
-
try {
|
|
212
|
-
const output = (0, child_process_1.execSync)('git pull', { cwd: projectPath, encoding: 'utf-8' });
|
|
213
|
-
return { success: true, output };
|
|
214
|
-
}
|
|
215
|
-
catch (e) {
|
|
216
|
-
return { success: false, error: e.stderr || e.message };
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
case 'git_commit': {
|
|
220
|
-
try {
|
|
221
|
-
(0, child_process_1.execSync)('git add -A', { cwd: projectPath });
|
|
222
|
-
const msg = input.message || 'fix: bug fix by Giuseppe';
|
|
223
|
-
(0, child_process_1.execSync)(`git commit -m "${msg.replace(/"/g, '\\"')}"`, { cwd: projectPath });
|
|
224
|
-
const hash = (0, child_process_1.execSync)('git rev-parse --short HEAD', { cwd: projectPath, encoding: 'utf-8' }).trim();
|
|
225
|
-
return { success: true, hash };
|
|
226
|
-
}
|
|
227
|
-
catch (e) {
|
|
228
|
-
return { success: false, error: e.stderr || e.stdout || e.message };
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
case 'git_push': {
|
|
232
|
-
const pushed = await this.git.push(projectPath);
|
|
233
|
-
return { success: pushed };
|
|
234
|
-
}
|
|
235
|
-
case 'git_revert': {
|
|
236
|
-
try {
|
|
237
|
-
(0, child_process_1.execSync)('git checkout -- .', { cwd: projectPath });
|
|
238
|
-
return { success: true };
|
|
239
|
-
}
|
|
240
|
-
catch (e) {
|
|
241
|
-
return { success: false, error: e.message };
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
case 'list_files': {
|
|
245
|
-
const files = await this.files.scanSourceFiles(projectPath);
|
|
246
|
-
return { files: files.slice(0, 50), total: files.length };
|
|
247
|
-
}
|
|
248
|
-
case 'read_file': {
|
|
249
|
-
const content = await this.files.readFile(projectPath, input.path);
|
|
250
|
-
return content ? { content } : { error: 'File not found' };
|
|
251
|
-
}
|
|
252
|
-
case 'write_file': {
|
|
253
|
-
const success = await this.files.writeFile(projectPath, input.path, input.content);
|
|
254
|
-
return { success };
|
|
255
|
-
}
|
|
256
|
-
case 'run_build': {
|
|
257
|
-
const result = await this.lsp.validateFix(projectPath);
|
|
258
|
-
return result;
|
|
259
|
-
}
|
|
260
|
-
case 'analyze_code': {
|
|
261
|
-
const analysis = await this.lsp.analyzeProject(projectPath);
|
|
262
|
-
return {
|
|
263
|
-
issues: analysis.issues.slice(0, 10),
|
|
264
|
-
unusedProps: analysis.unusedProps.slice(0, 10),
|
|
265
|
-
summary: analysis.summary
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
case 'publish_app': {
|
|
269
|
-
try {
|
|
270
|
-
const appScaffold = await Promise.resolve().then(() => __importStar(require('../../mcp/tools/app-scaffold')));
|
|
271
|
-
const tool = appScaffold.publishHailerAppTool;
|
|
272
|
-
const result = await tool.execute({ projectDirectory: projectPath }, this.userContext);
|
|
273
|
-
const text = result.content?.[0]?.text || '';
|
|
274
|
-
return {
|
|
275
|
-
success: !text.includes('❌'),
|
|
276
|
-
message: text.substring(0, 500)
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
catch (e) {
|
|
280
|
-
return { success: false, error: e.message };
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
case 'move_bug_phase': {
|
|
284
|
-
const phase = input.phase;
|
|
285
|
-
const bugId = context?.bug.id || input.bugId;
|
|
286
|
-
const moved = await this.monitor.moveBugToPhase(bugId, phase);
|
|
287
|
-
return { success: moved, phase };
|
|
288
|
-
}
|
|
289
|
-
default:
|
|
290
|
-
return { error: `Unknown tool: ${name}` };
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Post message to discussion
|
|
295
|
-
*/
|
|
296
|
-
async postMessage(discussionId, message) {
|
|
297
|
-
try {
|
|
298
|
-
await this.userContext.hailer.sendDiscussionMessage(discussionId, message);
|
|
299
|
-
}
|
|
300
|
-
catch (error) {
|
|
301
|
-
logger.error('Failed to post message', { discussionId, error });
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Build initial prompt with bug context
|
|
306
|
-
*/
|
|
307
|
-
buildInitialPrompt(bug, app) {
|
|
308
|
-
return `A new bug report has been filed. Here are the details:
|
|
309
|
-
|
|
310
|
-
**Bug Report**
|
|
311
|
-
- Title: ${bug.name}
|
|
312
|
-
- Description: ${bug.description || 'No description provided'}
|
|
313
|
-
${bug.stepsToReproduce ? `- Steps to reproduce: ${bug.stepsToReproduce}` : ''}
|
|
314
|
-
${bug.expectedBehavior ? `- Expected: ${bug.expectedBehavior}` : ''}
|
|
315
|
-
${bug.actualBehavior ? `- Actual: ${bug.actualBehavior}` : ''}
|
|
316
|
-
|
|
317
|
-
**App Info**
|
|
318
|
-
${app ? `- Found app: ${app.name} at ${app.projectPath}` : '- Could not find matching app project'}
|
|
319
|
-
|
|
320
|
-
Please introduce yourself, analyze this bug report, and let the user know what you think. Ask any clarifying questions if needed.`;
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* System prompt for natural conversation
|
|
324
|
-
*/
|
|
325
|
-
getSystemPrompt() {
|
|
326
|
-
return `You are Giuseppe, a friendly AI assistant specialized in fixing bugs in React/TypeScript applications.
|
|
327
|
-
|
|
328
|
-
**Your personality:**
|
|
329
|
-
- Friendly and conversational
|
|
330
|
-
- Technical but explains things clearly
|
|
331
|
-
- Proactive - you take initiative but ask before destructive actions
|
|
332
|
-
- Honest about limitations and errors
|
|
333
|
-
|
|
334
|
-
**Your workflow:**
|
|
335
|
-
1. When a bug is reported, analyze it and share your understanding
|
|
336
|
-
2. Ask clarifying questions if the bug is unclear
|
|
337
|
-
3. Check git status before making changes
|
|
338
|
-
4. If git is behind, pull first
|
|
339
|
-
5. Read relevant files to understand the code
|
|
340
|
-
6. Make fixes by writing to files
|
|
341
|
-
7. Run the build to verify the fix works
|
|
342
|
-
8. Commit the changes
|
|
343
|
-
9. Ask the user if they want to publish to production
|
|
344
|
-
10. Only publish when the user confirms
|
|
345
|
-
|
|
346
|
-
**Important rules:**
|
|
347
|
-
- ALWAYS ask before publishing to production
|
|
348
|
-
- If the build fails, explain the error and try to fix it
|
|
349
|
-
- If git has issues, explain and resolve them
|
|
350
|
-
- Keep the user informed of what you're doing
|
|
351
|
-
- Be conversational - this is a chat, not a report
|
|
352
|
-
|
|
353
|
-
**Tools available:**
|
|
354
|
-
- check_git_status: See branch, changes, sync status
|
|
355
|
-
- git_pull: Pull latest from remote
|
|
356
|
-
- git_commit: Stage and commit changes
|
|
357
|
-
- git_push: Push to remote
|
|
358
|
-
- git_revert: Discard uncommitted changes
|
|
359
|
-
- list_files: See source files in the project
|
|
360
|
-
- read_file: Read a file's contents
|
|
361
|
-
- write_file: Write/update a file
|
|
362
|
-
- run_build: Check if code compiles
|
|
363
|
-
- analyze_code: LSP analysis for issues
|
|
364
|
-
- publish_app: Deploy to Hailer (ASK FIRST!)
|
|
365
|
-
- move_bug_phase: Update bug status (inProgress, fixed, closed, declined)
|
|
366
|
-
|
|
367
|
-
Start by understanding the bug, then work through fixing it naturally.`;
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* Tool definitions
|
|
371
|
-
*/
|
|
372
|
-
getTools() {
|
|
373
|
-
return [
|
|
374
|
-
{
|
|
375
|
-
name: 'check_git_status',
|
|
376
|
-
description: 'Check git status - branch, changes, sync with remote',
|
|
377
|
-
input_schema: { type: 'object', properties: {}, required: [] }
|
|
378
|
-
},
|
|
379
|
-
{
|
|
380
|
-
name: 'git_pull',
|
|
381
|
-
description: 'Pull latest changes from remote',
|
|
382
|
-
input_schema: { type: 'object', properties: {}, required: [] }
|
|
383
|
-
},
|
|
384
|
-
{
|
|
385
|
-
name: 'git_commit',
|
|
386
|
-
description: 'Stage all changes and commit',
|
|
387
|
-
input_schema: {
|
|
388
|
-
type: 'object',
|
|
389
|
-
properties: {
|
|
390
|
-
message: { type: 'string', description: 'Commit message' }
|
|
391
|
-
},
|
|
392
|
-
required: ['message']
|
|
393
|
-
}
|
|
394
|
-
},
|
|
395
|
-
{
|
|
396
|
-
name: 'git_push',
|
|
397
|
-
description: 'Push commits to remote',
|
|
398
|
-
input_schema: { type: 'object', properties: {}, required: [] }
|
|
399
|
-
},
|
|
400
|
-
{
|
|
401
|
-
name: 'git_revert',
|
|
402
|
-
description: 'Discard all uncommitted changes',
|
|
403
|
-
input_schema: { type: 'object', properties: {}, required: [] }
|
|
404
|
-
},
|
|
405
|
-
{
|
|
406
|
-
name: 'list_files',
|
|
407
|
-
description: 'List source files in the project',
|
|
408
|
-
input_schema: { type: 'object', properties: {}, required: [] }
|
|
409
|
-
},
|
|
410
|
-
{
|
|
411
|
-
name: 'read_file',
|
|
412
|
-
description: 'Read a source file',
|
|
413
|
-
input_schema: {
|
|
414
|
-
type: 'object',
|
|
415
|
-
properties: {
|
|
416
|
-
path: { type: 'string', description: 'Relative path to file' }
|
|
417
|
-
},
|
|
418
|
-
required: ['path']
|
|
419
|
-
}
|
|
420
|
-
},
|
|
421
|
-
{
|
|
422
|
-
name: 'write_file',
|
|
423
|
-
description: 'Write content to a file',
|
|
424
|
-
input_schema: {
|
|
425
|
-
type: 'object',
|
|
426
|
-
properties: {
|
|
427
|
-
path: { type: 'string', description: 'Relative path to file' },
|
|
428
|
-
content: { type: 'string', description: 'New file content' }
|
|
429
|
-
},
|
|
430
|
-
required: ['path', 'content']
|
|
431
|
-
}
|
|
432
|
-
},
|
|
433
|
-
{
|
|
434
|
-
name: 'run_build',
|
|
435
|
-
description: 'Run TypeScript build to check for errors',
|
|
436
|
-
input_schema: { type: 'object', properties: {}, required: [] }
|
|
437
|
-
},
|
|
438
|
-
{
|
|
439
|
-
name: 'analyze_code',
|
|
440
|
-
description: 'Run LSP analysis to find issues',
|
|
441
|
-
input_schema: { type: 'object', properties: {}, required: [] }
|
|
442
|
-
},
|
|
443
|
-
{
|
|
444
|
-
name: 'publish_app',
|
|
445
|
-
description: 'Publish app to Hailer production - ALWAYS ASK USER FIRST',
|
|
446
|
-
input_schema: { type: 'object', properties: {}, required: [] }
|
|
447
|
-
},
|
|
448
|
-
{
|
|
449
|
-
name: 'move_bug_phase',
|
|
450
|
-
description: 'Move bug to a different phase',
|
|
451
|
-
input_schema: {
|
|
452
|
-
type: 'object',
|
|
453
|
-
properties: {
|
|
454
|
-
phase: {
|
|
455
|
-
type: 'string',
|
|
456
|
-
enum: ['inProgress', 'fixed', 'closed', 'declined'],
|
|
457
|
-
description: 'Target phase'
|
|
458
|
-
}
|
|
459
|
-
},
|
|
460
|
-
required: ['phase']
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
];
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
exports.GiuseppeAgent = GiuseppeAgent;
|
|
467
|
-
//# sourceMappingURL=giuseppe-agent.js.map
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Giuseppe AI Module - Claude API interactions for bug analysis and fix generation
|
|
3
|
-
*/
|
|
4
|
-
import type { BugReport, AppRegistryEntry } from './types';
|
|
5
|
-
/** Fix plan from Claude analysis */
|
|
6
|
-
export interface FixPlan {
|
|
7
|
-
analysis: string;
|
|
8
|
-
debugTrace?: string;
|
|
9
|
-
failurePoint?: string;
|
|
10
|
-
rootCause: string;
|
|
11
|
-
fix: {
|
|
12
|
-
files: Array<{
|
|
13
|
-
path: string;
|
|
14
|
-
action: 'edit' | 'create' | 'delete';
|
|
15
|
-
search?: string;
|
|
16
|
-
replace?: string;
|
|
17
|
-
content?: string;
|
|
18
|
-
}>;
|
|
19
|
-
};
|
|
20
|
-
explanation: string;
|
|
21
|
-
testSuggestions?: string[];
|
|
22
|
-
}
|
|
23
|
-
export type BugClassification = 'bug' | 'feature_request' | 'unclear';
|
|
24
|
-
export interface ClassificationResult {
|
|
25
|
-
classification: BugClassification;
|
|
26
|
-
reason: string;
|
|
27
|
-
}
|
|
28
|
-
export interface FileContent {
|
|
29
|
-
path: string;
|
|
30
|
-
content: string;
|
|
31
|
-
}
|
|
32
|
-
export declare class GiuseppeAI {
|
|
33
|
-
private anthropic?;
|
|
34
|
-
constructor(apiKey?: string);
|
|
35
|
-
get isAvailable(): boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Classify a report as bug or feature request
|
|
38
|
-
*/
|
|
39
|
-
classifyReport(bug: BugReport): Promise<ClassificationResult>;
|
|
40
|
-
/**
|
|
41
|
-
* Detect user intent from a message (replaces magic word detection)
|
|
42
|
-
* Returns the intent and confidence level
|
|
43
|
-
*/
|
|
44
|
-
detectIntent(message: string, context: 'classification' | 'approval'): Promise<{
|
|
45
|
-
intent: string;
|
|
46
|
-
confidence: 'high' | 'medium' | 'low';
|
|
47
|
-
explanation: string;
|
|
48
|
-
}>;
|
|
49
|
-
/**
|
|
50
|
-
* Extract keywords from bug description for LSP filtering
|
|
51
|
-
*/
|
|
52
|
-
private extractKeywords;
|
|
53
|
-
/**
|
|
54
|
-
* Analyze bug and generate fix plan using Claude (two-phase approach)
|
|
55
|
-
* Phase 1: Send file list -> Claude picks relevant files
|
|
56
|
-
* Phase 2: Send those files -> Claude generates fix
|
|
57
|
-
*/
|
|
58
|
-
analyzeAndPlanFix(bug: BugReport, app: AppRegistryEntry, allFiles: string[], readFiles: (paths: string[]) => Promise<FileContent[]>, runLspAnalysis?: (files: string[], keywords: string[]) => Promise<{
|
|
59
|
-
unusedProps: {
|
|
60
|
-
name: string;
|
|
61
|
-
line: number;
|
|
62
|
-
file: string;
|
|
63
|
-
}[];
|
|
64
|
-
issues: {
|
|
65
|
-
file: string;
|
|
66
|
-
line: number;
|
|
67
|
-
message: string;
|
|
68
|
-
}[];
|
|
69
|
-
}>): Promise<FixPlan | null>;
|
|
70
|
-
/**
|
|
71
|
-
* Retry fix based on apply error (search string not found) - re-reads file and generates new fix
|
|
72
|
-
*/
|
|
73
|
-
retryFixFromApplyError(bug: BugReport, previousFix: FixPlan, applyError: string, currentFiles: FileContent[], attempt: number): Promise<FixPlan | null>;
|
|
74
|
-
/**
|
|
75
|
-
* Retry fix based on build error - sends error to Claude to generate corrected fix
|
|
76
|
-
*/
|
|
77
|
-
retryFixFromError(bug: BugReport, previousFix: FixPlan, buildError: string, currentFiles: FileContent[], attempt: number): Promise<FixPlan | null>;
|
|
78
|
-
/**
|
|
79
|
-
* Generate a new fix based on user feedback
|
|
80
|
-
*/
|
|
81
|
-
retryFixWithFeedback(bug: BugReport, previousFix: FixPlan, feedback: string, allSourceFiles: string[], currentFiles: FileContent[]): Promise<FixPlan | null>;
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=giuseppe-ai.d.ts.map
|