@hailer/mcp 0.0.6 → 0.1.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/.claude/agents/ada.md +127 -0
- package/.claude/agents/agent-builder.md +151 -0
- package/.claude/agents/alejandro.md +66 -0
- package/.claude/agents/bjorn.md +305 -0
- package/.claude/agents/dmitri.md +61 -0
- package/.claude/agents/giuseppe.md +66 -0
- package/.claude/agents/gunther.md +355 -0
- package/.claude/agents/helga.md +68 -0
- package/.claude/agents/ingrid.md +108 -0
- package/.claude/agents/kenji.md +58 -0
- package/.claude/agents/svetlana.md +394 -0
- package/.claude/agents/viktor.md +63 -0
- package/.claude/agents/yevgeni.md +60 -0
- package/.claude/hooks/agent-failure-detector.cjs +286 -0
- package/.claude/hooks/app-edit-guard.cjs +462 -0
- package/.claude/hooks/interactive-mode.cjs +59 -0
- package/.claude/hooks/mcp-server-guard.cjs +92 -0
- package/.claude/hooks/post-scaffold-hook.cjs +31 -0
- package/.claude/hooks/sdk-delete-guard.cjs +2 -0
- package/.claude/hooks/src-edit-guard.cjs +208 -0
- package/.claude/settings.json +47 -2
- package/.claude/skills/insight-join-patterns/SKILL.md +209 -0
- package/.env.example +13 -1
- package/CLAUDE.md +135 -0
- package/dist/app.js +4 -3
- package/dist/cli.js +0 -0
- package/dist/client/adaptive-documentation-bot.d.ts +0 -2
- package/dist/client/adaptive-documentation-bot.js +5 -16
- package/dist/client/message-processor.js +5 -0
- package/dist/client/providers/anthropic-provider.js +21 -7
- package/dist/mcp/UserContextCache.d.ts +14 -0
- package/dist/mcp/UserContextCache.js +49 -24
- package/dist/mcp/auth.d.ts +7 -0
- package/dist/mcp/auth.js +13 -5
- package/dist/mcp/hailer-clients.d.ts +5 -2
- package/dist/mcp/signal-handler.d.ts +28 -2
- package/dist/mcp/signal-handler.js +4 -2
- package/dist/mcp/tool-registry.d.ts +55 -2
- package/dist/mcp/tool-registry.js +197 -2
- package/dist/mcp/tools/app-core.d.ts +15 -0
- package/dist/mcp/tools/app-core.js +609 -0
- package/dist/mcp/tools/app-marketplace.d.ts +21 -0
- package/dist/mcp/tools/app-marketplace.js +1284 -0
- package/dist/mcp/tools/app-member.d.ts +11 -0
- package/dist/mcp/tools/app-member.js +258 -0
- package/dist/mcp/tools/app-scaffold.d.ts +11 -0
- package/dist/mcp/tools/app-scaffold.js +743 -0
- package/dist/mcp/tools/app.d.ts +13 -22
- package/dist/mcp/tools/app.js +17 -2466
- package/dist/mcp/tools/file.js +6 -6
- package/dist/mcp/tools/insight.d.ts +1 -0
- package/dist/mcp/tools/insight.js +203 -64
- package/dist/mcp/tools/user.js +3 -9
- package/dist/mcp/tools/workflow.js +49 -38
- package/dist/mcp/utils/hailer-api-client.js +4 -13
- package/dist/mcp/utils/tool-helpers.d.ts +102 -0
- package/dist/mcp/utils/tool-helpers.js +179 -0
- package/dist/mcp/utils/types.d.ts +6 -0
- package/dist/mcp/workspace-cache.d.ts +5 -5
- package/dist/mcp/workspace-cache.js +4 -3
- package/package.json +1 -1
- package/.claude/hooks/PreToolUse.sh +0 -52
- package/.claude/hooks/prompt-skill-loader.cjs +0 -553
- package/.claude/hooks/skill-loader.cjs +0 -142
- package/.claude/settings.local.json +0 -49
- package/.claude/skills/MCP-add-app-member-skill/SKILL.md +0 -977
- package/.claude/skills/MCP-build-data-app-skill/SKILL.md +0 -372
- package/.claude/skills/MCP-create-app-skill/SKILL.md +0 -1101
- package/.claude/skills/MCP-create-insight-skill/SKILL.md +0 -1317
- package/.claude/skills/MCP-get-insight-data-skill/SKILL.md +0 -1053
- package/.claude/skills/MCP-insight-api/SKILL.md +0 -185
- package/.claude/skills/MCP-insight-api/references/insight-endpoints.md +0 -514
- package/.claude/skills/MCP-install-workflow-skill/SKILL.md +0 -1056
- package/.claude/skills/MCP-list-apps-skill/SKILL.md +0 -1010
- package/.claude/skills/MCP-list-workflows-minimal-skill/SKILL.md +0 -992
- package/.claude/skills/MCP-local-first-skill/SKILL.md +0 -570
- package/.claude/skills/MCP-populate-workflow-data-skill/SKILL.md +0 -395
- package/.claude/skills/MCP-preview-insight-skill/SKILL.md +0 -1290
- package/.claude/skills/MCP-publish-hailer-app-skill/SKILL.md +0 -453
- package/.claude/skills/MCP-publish-template-skill/SKILL.md +0 -278
- package/.claude/skills/MCP-remove-app-member-skill/SKILL.md +0 -671
- package/.claude/skills/MCP-remove-app-skill/SKILL.md +0 -985
- package/.claude/skills/MCP-remove-insight-skill/SKILL.md +0 -1011
- package/.claude/skills/MCP-remove-workflow-skill/SKILL.md +0 -920
- package/.claude/skills/MCP-scaffold-hailer-app-skill/SKILL.md +0 -1314
- package/.claude/skills/MCP-update-app-skill/SKILL.md +0 -970
- package/.claude/skills/MCP-update-workflow-field-skill/SKILL.md +0 -1098
- package/.claude/skills/SDK-create-function-field-skill/SKILL.md +0 -313
- package/.claude/skills/SDK-generate-skill/SKILL.md +0 -223
- package/.claude/skills/SDK-init-skill/SKILL.md +0 -177
- package/.claude/skills/SDK-workspace-setup-skill/SKILL.md +0 -605
- package/.claude/skills/SDK-ws-config-skill/SKILL.md +0 -435
- package/.claude/skills/activity-api/SKILL.md +0 -96
- package/.claude/skills/activity-api/references/activity-endpoints.md +0 -845
- package/.claude/skills/agent-building/SKILL.md +0 -243
- package/.claude/skills/agent-building/references/architecture-patterns.md +0 -446
- package/.claude/skills/agent-building/references/code-examples.md +0 -587
- package/.claude/skills/agent-building/references/implementation-guide.md +0 -619
- package/.claude/skills/app-api/SKILL.md +0 -219
- package/.claude/skills/app-api/references/app-endpoints.md +0 -759
- package/.claude/skills/building-hailer-apps-skill/SKILL.md +0 -813
- package/.claude/skills/hailer-api/SKILL.md +0 -283
- package/.claude/skills/hailer-api/references/activities.md +0 -620
- package/.claude/skills/hailer-api/references/authentication.md +0 -216
- package/.claude/skills/hailer-api/references/datasets.md +0 -437
- package/.claude/skills/hailer-api/references/files.md +0 -301
- package/.claude/skills/hailer-api/references/insights.md +0 -469
- package/.claude/skills/hailer-api/references/workflows.md +0 -720
- package/.claude/skills/hailer-api/references/workspaces-users.md +0 -445
- package/.claude/skills/hailer-app-builder/SKILL.md +0 -340
- package/.claude/skills/mcp-tools/SKILL.md +0 -419
- package/.claude/skills/mcp-tools/references/api-endpoints.md +0 -499
- package/.claude/skills/mcp-tools/references/data-structures.md +0 -554
- package/.claude/skills/mcp-tools/references/implementation-patterns.md +0 -717
- package/.claude/skills/skill-testing/README.md +0 -137
- package/.claude/skills/skill-testing/SKILL.md +0 -348
- package/.claude/skills/skill-testing/references/test-patterns.md +0 -705
- package/.claude/skills/skill-testing/references/testing-guide.md +0 -603
- package/.claude/skills/skill-testing/references/validation-checklist.md +0 -537
- package/.claude/skills/spawn-app-builder/SKILL.md +0 -366
- package/.claude/skills/tool-builder/SKILL.md +0 -328
- package/tsconfig.json +0 -23
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Agent Failure Detector Hook
|
|
4
|
+
*
|
|
5
|
+
* PostToolUse hook for Task tool - detects agent failures, categorizes them,
|
|
6
|
+
* and suggests appropriate fixes (skill creation vs agent update).
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
const os = require('os');
|
|
12
|
+
|
|
13
|
+
const TRACKER_FILE = path.join(os.tmpdir(), '.claude-agent-failures.json');
|
|
14
|
+
const FAILURE_THRESHOLD = 2;
|
|
15
|
+
|
|
16
|
+
let input = '';
|
|
17
|
+
process.stdin.setEncoding('utf8');
|
|
18
|
+
process.stdin.on('data', chunk => input += chunk);
|
|
19
|
+
process.stdin.on('end', () => {
|
|
20
|
+
try {
|
|
21
|
+
const data = JSON.parse(input);
|
|
22
|
+
processHook(data);
|
|
23
|
+
} catch {
|
|
24
|
+
process.exit(0);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
function loadTracker() {
|
|
29
|
+
try {
|
|
30
|
+
if (fs.existsSync(TRACKER_FILE)) {
|
|
31
|
+
return JSON.parse(fs.readFileSync(TRACKER_FILE, 'utf8'));
|
|
32
|
+
}
|
|
33
|
+
} catch {}
|
|
34
|
+
return { failures: {}, prompted: {}, errorTypes: {} };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function saveTracker(tracker) {
|
|
38
|
+
fs.writeFileSync(TRACKER_FILE, JSON.stringify(tracker, null, 2));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Error categorization - determines fix type
|
|
42
|
+
const ERROR_CATEGORIES = {
|
|
43
|
+
// API/Schema errors -> Create skill (reusable knowledge)
|
|
44
|
+
skill: {
|
|
45
|
+
patterns: [
|
|
46
|
+
'validation error',
|
|
47
|
+
'invalid field',
|
|
48
|
+
'schema',
|
|
49
|
+
'required parameter',
|
|
50
|
+
'type mismatch',
|
|
51
|
+
'format error',
|
|
52
|
+
'join syntax',
|
|
53
|
+
'sql error',
|
|
54
|
+
'query error',
|
|
55
|
+
'activitylink',
|
|
56
|
+
'workflow.*not found',
|
|
57
|
+
'phase.*not found',
|
|
58
|
+
'field.*not found'
|
|
59
|
+
],
|
|
60
|
+
suggestion: 'Create a skill documenting the correct pattern',
|
|
61
|
+
action: 'create_skill'
|
|
62
|
+
},
|
|
63
|
+
// Agent behavior errors -> Update agent
|
|
64
|
+
agent: {
|
|
65
|
+
patterns: [
|
|
66
|
+
'wrong approach',
|
|
67
|
+
'misunderstood',
|
|
68
|
+
'incorrect assumption',
|
|
69
|
+
'should have',
|
|
70
|
+
'forgot to',
|
|
71
|
+
'didn\'t check',
|
|
72
|
+
'missing context',
|
|
73
|
+
'needs to first',
|
|
74
|
+
'order of operations'
|
|
75
|
+
],
|
|
76
|
+
suggestion: 'Update agent definition with better instructions',
|
|
77
|
+
action: 'update_agent'
|
|
78
|
+
},
|
|
79
|
+
// Permission/Auth errors -> Neither (user issue)
|
|
80
|
+
user_issue: {
|
|
81
|
+
patterns: [
|
|
82
|
+
'permission denied',
|
|
83
|
+
'unauthorized',
|
|
84
|
+
'access denied',
|
|
85
|
+
'not allowed',
|
|
86
|
+
'admin required'
|
|
87
|
+
],
|
|
88
|
+
suggestion: 'User permission issue - not an agent problem',
|
|
89
|
+
action: 'ignore'
|
|
90
|
+
},
|
|
91
|
+
// Connection/Transient errors -> Neither (retry)
|
|
92
|
+
transient: {
|
|
93
|
+
patterns: [
|
|
94
|
+
'timeout',
|
|
95
|
+
'connection',
|
|
96
|
+
'network',
|
|
97
|
+
'unavailable',
|
|
98
|
+
'try again',
|
|
99
|
+
'rate limit'
|
|
100
|
+
],
|
|
101
|
+
suggestion: 'Transient error - retry may work',
|
|
102
|
+
action: 'ignore'
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
function categorizeError(responseText) {
|
|
107
|
+
const lower = responseText.toLowerCase();
|
|
108
|
+
|
|
109
|
+
for (const [category, config] of Object.entries(ERROR_CATEGORIES)) {
|
|
110
|
+
for (const pattern of config.patterns) {
|
|
111
|
+
const regex = new RegExp(pattern, 'i');
|
|
112
|
+
if (regex.test(lower)) {
|
|
113
|
+
return {
|
|
114
|
+
category,
|
|
115
|
+
...config,
|
|
116
|
+
matchedPattern: pattern
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Default: likely needs skill (documentation)
|
|
123
|
+
return {
|
|
124
|
+
category: 'unknown',
|
|
125
|
+
suggestion: 'Analyze error to determine fix type',
|
|
126
|
+
action: 'analyze'
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function detectFailure(responseText) {
|
|
131
|
+
const lower = responseText.toLowerCase();
|
|
132
|
+
const failurePatterns = [
|
|
133
|
+
'"status":"error"',
|
|
134
|
+
'"status": "error"',
|
|
135
|
+
'failed to',
|
|
136
|
+
'error:',
|
|
137
|
+
'could not',
|
|
138
|
+
'unable to',
|
|
139
|
+
'invalid',
|
|
140
|
+
'not found',
|
|
141
|
+
'exception'
|
|
142
|
+
];
|
|
143
|
+
|
|
144
|
+
for (const pattern of failurePatterns) {
|
|
145
|
+
if (lower.includes(pattern)) {
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function extractErrorMessage(responseText) {
|
|
153
|
+
// Try to extract meaningful error message
|
|
154
|
+
const patterns = [
|
|
155
|
+
/"error":\s*"([^"]+)"/i,
|
|
156
|
+
/"message":\s*"([^"]+)"/i,
|
|
157
|
+
/Error:\s*([^\n]+)/i,
|
|
158
|
+
/failed to ([^\n.]+)/i
|
|
159
|
+
];
|
|
160
|
+
|
|
161
|
+
for (const pattern of patterns) {
|
|
162
|
+
const match = responseText.match(pattern);
|
|
163
|
+
if (match) {
|
|
164
|
+
return match[1].substring(0, 100); // Limit length
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return 'Unknown error';
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function processHook(data) {
|
|
172
|
+
const { tool_name, tool_input, tool_response } = data;
|
|
173
|
+
|
|
174
|
+
if (tool_name !== 'Task') {
|
|
175
|
+
process.exit(0);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const agentName = tool_input?.subagent_type;
|
|
179
|
+
if (!agentName || agentName === 'ada') {
|
|
180
|
+
process.exit(0);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const responseText = typeof tool_response === 'string'
|
|
184
|
+
? tool_response
|
|
185
|
+
: JSON.stringify(tool_response || '');
|
|
186
|
+
|
|
187
|
+
if (!detectFailure(responseText)) {
|
|
188
|
+
process.exit(0);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Categorize the error
|
|
192
|
+
const errorInfo = categorizeError(responseText);
|
|
193
|
+
const errorMessage = extractErrorMessage(responseText);
|
|
194
|
+
|
|
195
|
+
// Skip if it's a user issue or transient
|
|
196
|
+
if (errorInfo.action === 'ignore') {
|
|
197
|
+
process.exit(0);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Track the failure with category
|
|
201
|
+
const tracker = loadTracker();
|
|
202
|
+
const key = `${agentName}:${errorInfo.category}`;
|
|
203
|
+
tracker.failures[key] = (tracker.failures[key] || 0) + 1;
|
|
204
|
+
tracker.errorTypes[key] = errorInfo;
|
|
205
|
+
saveTracker(tracker);
|
|
206
|
+
|
|
207
|
+
const failureCount = tracker.failures[key];
|
|
208
|
+
|
|
209
|
+
if (failureCount >= FAILURE_THRESHOLD && !tracker.prompted[key]) {
|
|
210
|
+
tracker.prompted[key] = true;
|
|
211
|
+
saveTracker(tracker);
|
|
212
|
+
|
|
213
|
+
// Build suggestion based on category
|
|
214
|
+
let fixOptions;
|
|
215
|
+
let recommendation;
|
|
216
|
+
|
|
217
|
+
if (errorInfo.action === 'create_skill') {
|
|
218
|
+
recommendation = `📚 RECOMMENDED: Create a skill to document this pattern`;
|
|
219
|
+
fixOptions = [
|
|
220
|
+
{ label: 'Create skill', description: `Ada creates docs/skills/ entry for ${errorInfo.matchedPattern || 'this pattern'}` },
|
|
221
|
+
{ label: 'Update agent instead', description: `Add knowledge directly to ${agentName}'s definition` },
|
|
222
|
+
{ label: 'Ignore', description: 'Continue without changes' }
|
|
223
|
+
];
|
|
224
|
+
} else if (errorInfo.action === 'update_agent') {
|
|
225
|
+
recommendation = `🤖 RECOMMENDED: Update ${agentName}'s agent definition`;
|
|
226
|
+
fixOptions = [
|
|
227
|
+
{ label: 'Update agent', description: `Ada adds better instructions to ${agentName}.md` },
|
|
228
|
+
{ label: 'Create skill instead', description: 'Document as reusable skill for all agents' },
|
|
229
|
+
{ label: 'Ignore', description: 'Continue without changes' }
|
|
230
|
+
];
|
|
231
|
+
} else {
|
|
232
|
+
recommendation = `🔍 ANALYZE: Let Ada determine the best fix`;
|
|
233
|
+
fixOptions = [
|
|
234
|
+
{ label: 'Let Ada analyze', description: 'Ada will determine if skill or agent update is better' },
|
|
235
|
+
{ label: 'Ignore', description: 'Continue without changes' }
|
|
236
|
+
];
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const output = `
|
|
240
|
+
${'='.repeat(60)}
|
|
241
|
+
🔧 AGENT IMPROVEMENT SUGGESTION
|
|
242
|
+
${'='.repeat(60)}
|
|
243
|
+
|
|
244
|
+
Agent "${agentName}" has failed ${failureCount} times with similar errors.
|
|
245
|
+
|
|
246
|
+
**Error type:** ${errorInfo.category}
|
|
247
|
+
**Error:** ${errorMessage}
|
|
248
|
+
**Pattern:** ${errorInfo.matchedPattern || 'general failure'}
|
|
249
|
+
|
|
250
|
+
${recommendation}
|
|
251
|
+
|
|
252
|
+
USE THIS AskUserQuestion CALL:
|
|
253
|
+
|
|
254
|
+
\`\`\`json
|
|
255
|
+
{
|
|
256
|
+
"questions": [{
|
|
257
|
+
"question": "${agentName} failed ${failureCount}x (${errorInfo.category}). How should Ada fix this?",
|
|
258
|
+
"header": "Fix type",
|
|
259
|
+
"options": ${JSON.stringify(fixOptions)},
|
|
260
|
+
"multiSelect": false
|
|
261
|
+
}]
|
|
262
|
+
}
|
|
263
|
+
\`\`\`
|
|
264
|
+
|
|
265
|
+
After user responds, invoke Ada with context:
|
|
266
|
+
\`\`\`
|
|
267
|
+
Task(subagent_type="ada", prompt=\`{
|
|
268
|
+
"task": "${errorInfo.action === 'create_skill' ? 'create_skill' : 'update_agent'}",
|
|
269
|
+
"context": {
|
|
270
|
+
"agent": "${agentName}",
|
|
271
|
+
"error_type": "${errorInfo.category}",
|
|
272
|
+
"error_message": "${errorMessage.replace(/"/g, '\\"')}",
|
|
273
|
+
"failure_count": ${failureCount}
|
|
274
|
+
},
|
|
275
|
+
"output": ["action_taken", "file_path"]
|
|
276
|
+
}\`)
|
|
277
|
+
\`\`\`
|
|
278
|
+
|
|
279
|
+
${'='.repeat(60)}
|
|
280
|
+
`;
|
|
281
|
+
|
|
282
|
+
console.error(output);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
process.exit(0);
|
|
286
|
+
}
|