@claude-flow/hooks 3.0.0-alpha.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/README.md +440 -0
- package/bin/hooks-daemon.js +199 -0
- package/bin/statusline.js +77 -0
- package/dist/bridge/official-hooks-bridge.d.ts +99 -0
- package/dist/bridge/official-hooks-bridge.d.ts.map +1 -0
- package/dist/bridge/official-hooks-bridge.js +280 -0
- package/dist/bridge/official-hooks-bridge.js.map +1 -0
- package/dist/cli/guidance-cli.d.ts +17 -0
- package/dist/cli/guidance-cli.d.ts.map +1 -0
- package/dist/cli/guidance-cli.js +486 -0
- package/dist/cli/guidance-cli.js.map +1 -0
- package/dist/daemons/index.d.ts +204 -0
- package/dist/daemons/index.d.ts.map +1 -0
- package/dist/daemons/index.js +443 -0
- package/dist/daemons/index.js.map +1 -0
- package/dist/executor/index.d.ts +80 -0
- package/dist/executor/index.d.ts.map +1 -0
- package/dist/executor/index.js +273 -0
- package/dist/executor/index.js.map +1 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +85 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/index.d.ts +11 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +11 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/llm-hooks.d.ts +93 -0
- package/dist/llm/llm-hooks.d.ts.map +1 -0
- package/dist/llm/llm-hooks.js +382 -0
- package/dist/llm/llm-hooks.js.map +1 -0
- package/dist/mcp/index.d.ts +61 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +501 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/reasoningbank/guidance-provider.d.ts +78 -0
- package/dist/reasoningbank/guidance-provider.d.ts.map +1 -0
- package/dist/reasoningbank/guidance-provider.js +350 -0
- package/dist/reasoningbank/guidance-provider.js.map +1 -0
- package/dist/reasoningbank/index.d.ts +212 -0
- package/dist/reasoningbank/index.d.ts.map +1 -0
- package/dist/reasoningbank/index.js +785 -0
- package/dist/reasoningbank/index.js.map +1 -0
- package/dist/registry/index.d.ts +85 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +212 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/statusline/index.d.ts +128 -0
- package/dist/statusline/index.d.ts.map +1 -0
- package/dist/statusline/index.js +493 -0
- package/dist/statusline/index.js.map +1 -0
- package/dist/swarm/index.d.ts +271 -0
- package/dist/swarm/index.d.ts.map +1 -0
- package/dist/swarm/index.js +638 -0
- package/dist/swarm/index.js.map +1 -0
- package/dist/types.d.ts +525 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +56 -0
- package/dist/types.js.map +1 -0
- package/dist/workers/index.d.ts +232 -0
- package/dist/workers/index.d.ts.map +1 -0
- package/dist/workers/index.js +1521 -0
- package/dist/workers/index.js.map +1 -0
- package/dist/workers/mcp-tools.d.ts +37 -0
- package/dist/workers/mcp-tools.d.ts.map +1 -0
- package/dist/workers/mcp-tools.js +414 -0
- package/dist/workers/mcp-tools.js.map +1 -0
- package/dist/workers/session-hook.d.ts +42 -0
- package/dist/workers/session-hook.d.ts.map +1 -0
- package/dist/workers/session-hook.js +172 -0
- package/dist/workers/session-hook.js.map +1 -0
- package/package.json +101 -0
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* V3 Hooks MCP Tools
|
|
3
|
+
*
|
|
4
|
+
* MCP tool definitions for hooks system integration.
|
|
5
|
+
* These tools provide programmatic access to hooks functionality.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Pre-edit hook MCP tool
|
|
9
|
+
*/
|
|
10
|
+
export const preEditTool = {
|
|
11
|
+
name: 'hooks/pre-edit',
|
|
12
|
+
description: 'Execute pre-edit hooks for a file. Gets context, suggestions, and warnings before file modification.',
|
|
13
|
+
inputSchema: {
|
|
14
|
+
type: 'object',
|
|
15
|
+
properties: {
|
|
16
|
+
filePath: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
description: 'Path to the file being edited',
|
|
19
|
+
},
|
|
20
|
+
operation: {
|
|
21
|
+
type: 'string',
|
|
22
|
+
enum: ['create', 'modify', 'delete'],
|
|
23
|
+
description: 'Type of edit operation',
|
|
24
|
+
default: 'modify',
|
|
25
|
+
},
|
|
26
|
+
includeContext: {
|
|
27
|
+
type: 'boolean',
|
|
28
|
+
description: 'Include file context in response',
|
|
29
|
+
default: true,
|
|
30
|
+
},
|
|
31
|
+
includeSuggestions: {
|
|
32
|
+
type: 'boolean',
|
|
33
|
+
description: 'Include agent suggestions',
|
|
34
|
+
default: true,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
required: ['filePath'],
|
|
38
|
+
},
|
|
39
|
+
handler: async (input) => {
|
|
40
|
+
const filePath = input.filePath;
|
|
41
|
+
const operation = input.operation || 'modify';
|
|
42
|
+
const includeContext = input.includeContext !== false;
|
|
43
|
+
const includeSuggestions = input.includeSuggestions !== false;
|
|
44
|
+
const result = {
|
|
45
|
+
filePath,
|
|
46
|
+
operation,
|
|
47
|
+
};
|
|
48
|
+
if (includeContext) {
|
|
49
|
+
result.context = {
|
|
50
|
+
fileExists: true, // Would check fs in real implementation
|
|
51
|
+
fileType: getFileType(filePath),
|
|
52
|
+
relatedFiles: [],
|
|
53
|
+
similarPatterns: [],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
if (includeSuggestions) {
|
|
57
|
+
result.suggestions = [
|
|
58
|
+
{
|
|
59
|
+
agent: 'coder',
|
|
60
|
+
suggestion: `Use standard patterns for ${operation} operation`,
|
|
61
|
+
confidence: 0.85,
|
|
62
|
+
rationale: 'Based on file type and historical patterns',
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
}
|
|
66
|
+
return result;
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Post-edit hook MCP tool
|
|
71
|
+
*/
|
|
72
|
+
export const postEditTool = {
|
|
73
|
+
name: 'hooks/post-edit',
|
|
74
|
+
description: 'Execute post-edit hooks to record outcome for learning.',
|
|
75
|
+
inputSchema: {
|
|
76
|
+
type: 'object',
|
|
77
|
+
properties: {
|
|
78
|
+
filePath: {
|
|
79
|
+
type: 'string',
|
|
80
|
+
description: 'Path to the edited file',
|
|
81
|
+
},
|
|
82
|
+
operation: {
|
|
83
|
+
type: 'string',
|
|
84
|
+
enum: ['create', 'modify', 'delete'],
|
|
85
|
+
description: 'Type of edit operation',
|
|
86
|
+
default: 'modify',
|
|
87
|
+
},
|
|
88
|
+
success: {
|
|
89
|
+
type: 'boolean',
|
|
90
|
+
description: 'Whether the edit was successful',
|
|
91
|
+
},
|
|
92
|
+
outcome: {
|
|
93
|
+
type: 'string',
|
|
94
|
+
description: 'Description of the outcome',
|
|
95
|
+
},
|
|
96
|
+
metadata: {
|
|
97
|
+
type: 'object',
|
|
98
|
+
description: 'Additional metadata',
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
required: ['filePath', 'success'],
|
|
102
|
+
},
|
|
103
|
+
handler: async (input) => {
|
|
104
|
+
const filePath = input.filePath;
|
|
105
|
+
const operation = input.operation || 'modify';
|
|
106
|
+
const success = input.success;
|
|
107
|
+
return {
|
|
108
|
+
filePath,
|
|
109
|
+
operation,
|
|
110
|
+
success,
|
|
111
|
+
recorded: true,
|
|
112
|
+
recordedAt: new Date().toISOString(),
|
|
113
|
+
patternId: success ? `pattern-${Date.now()}` : undefined,
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Route task MCP tool
|
|
119
|
+
*/
|
|
120
|
+
export const routeTaskTool = {
|
|
121
|
+
name: 'hooks/route',
|
|
122
|
+
description: 'Route a task to the optimal agent based on learned patterns.',
|
|
123
|
+
inputSchema: {
|
|
124
|
+
type: 'object',
|
|
125
|
+
properties: {
|
|
126
|
+
task: {
|
|
127
|
+
type: 'string',
|
|
128
|
+
description: 'Task description to route',
|
|
129
|
+
},
|
|
130
|
+
context: {
|
|
131
|
+
type: 'string',
|
|
132
|
+
description: 'Additional context for routing',
|
|
133
|
+
},
|
|
134
|
+
preferredAgents: {
|
|
135
|
+
type: 'array',
|
|
136
|
+
items: { type: 'string' },
|
|
137
|
+
description: 'List of preferred agents',
|
|
138
|
+
},
|
|
139
|
+
constraints: {
|
|
140
|
+
type: 'object',
|
|
141
|
+
description: 'Routing constraints',
|
|
142
|
+
},
|
|
143
|
+
includeExplanation: {
|
|
144
|
+
type: 'boolean',
|
|
145
|
+
description: 'Include explanation for routing decision',
|
|
146
|
+
default: true,
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
required: ['task'],
|
|
150
|
+
},
|
|
151
|
+
handler: async (input) => {
|
|
152
|
+
const task = input.task;
|
|
153
|
+
const includeExplanation = input.includeExplanation !== false;
|
|
154
|
+
// Simple keyword-based routing (real implementation uses ReasoningBank)
|
|
155
|
+
const agent = routeTaskToAgent(task);
|
|
156
|
+
const result = {
|
|
157
|
+
task,
|
|
158
|
+
recommendedAgent: agent.name,
|
|
159
|
+
confidence: agent.confidence,
|
|
160
|
+
alternativeAgents: agent.alternatives,
|
|
161
|
+
};
|
|
162
|
+
if (includeExplanation) {
|
|
163
|
+
result.explanation = agent.explanation;
|
|
164
|
+
result.reasoning = {
|
|
165
|
+
factors: agent.factors,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
return result;
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Metrics query MCP tool
|
|
173
|
+
*/
|
|
174
|
+
export const metricsTool = {
|
|
175
|
+
name: 'hooks/metrics',
|
|
176
|
+
description: 'Query hooks learning metrics and statistics.',
|
|
177
|
+
inputSchema: {
|
|
178
|
+
type: 'object',
|
|
179
|
+
properties: {
|
|
180
|
+
category: {
|
|
181
|
+
type: 'string',
|
|
182
|
+
enum: ['all', 'routing', 'edits', 'commands', 'patterns'],
|
|
183
|
+
description: 'Metrics category to query',
|
|
184
|
+
default: 'all',
|
|
185
|
+
},
|
|
186
|
+
timeRange: {
|
|
187
|
+
type: 'string',
|
|
188
|
+
enum: ['hour', 'day', 'week', 'month', 'all'],
|
|
189
|
+
description: 'Time range for metrics',
|
|
190
|
+
default: 'all',
|
|
191
|
+
},
|
|
192
|
+
includeDetailedStats: {
|
|
193
|
+
type: 'boolean',
|
|
194
|
+
description: 'Include detailed statistics',
|
|
195
|
+
default: false,
|
|
196
|
+
},
|
|
197
|
+
format: {
|
|
198
|
+
type: 'string',
|
|
199
|
+
enum: ['json', 'summary'],
|
|
200
|
+
description: 'Output format',
|
|
201
|
+
default: 'json',
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
handler: async (input) => {
|
|
206
|
+
const category = input.category || 'all';
|
|
207
|
+
const timeRange = input.timeRange || 'all';
|
|
208
|
+
return {
|
|
209
|
+
category,
|
|
210
|
+
timeRange,
|
|
211
|
+
summary: {
|
|
212
|
+
totalOperations: 1547,
|
|
213
|
+
successRate: 89,
|
|
214
|
+
avgQuality: 0.87,
|
|
215
|
+
patternsLearned: 156,
|
|
216
|
+
},
|
|
217
|
+
routing: {
|
|
218
|
+
totalRoutes: 423,
|
|
219
|
+
avgConfidence: 0.84,
|
|
220
|
+
topAgents: [
|
|
221
|
+
{ agent: 'coder', count: 156, successRate: 0.92 },
|
|
222
|
+
{ agent: 'reviewer', count: 89, successRate: 0.88 },
|
|
223
|
+
{ agent: 'tester', count: 67, successRate: 0.91 },
|
|
224
|
+
],
|
|
225
|
+
},
|
|
226
|
+
edits: {
|
|
227
|
+
totalEdits: 756,
|
|
228
|
+
successRate: 0.93,
|
|
229
|
+
commonPatterns: ['typescript', 'react', 'api'],
|
|
230
|
+
},
|
|
231
|
+
commands: {
|
|
232
|
+
totalCommands: 368,
|
|
233
|
+
successRate: 0.82,
|
|
234
|
+
avgExecutionTime: 4230,
|
|
235
|
+
commonCommands: ['npm test', 'npm build', 'git status'],
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Pre-command hook MCP tool
|
|
242
|
+
*/
|
|
243
|
+
export const preCommandTool = {
|
|
244
|
+
name: 'hooks/pre-command',
|
|
245
|
+
description: 'Execute pre-command hooks to assess risk before command execution.',
|
|
246
|
+
inputSchema: {
|
|
247
|
+
type: 'object',
|
|
248
|
+
properties: {
|
|
249
|
+
command: {
|
|
250
|
+
type: 'string',
|
|
251
|
+
description: 'Command to be executed',
|
|
252
|
+
},
|
|
253
|
+
workingDirectory: {
|
|
254
|
+
type: 'string',
|
|
255
|
+
description: 'Working directory for command',
|
|
256
|
+
},
|
|
257
|
+
assessRisk: {
|
|
258
|
+
type: 'boolean',
|
|
259
|
+
description: 'Include risk assessment',
|
|
260
|
+
default: true,
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
required: ['command'],
|
|
264
|
+
},
|
|
265
|
+
handler: async (input) => {
|
|
266
|
+
const command = input.command;
|
|
267
|
+
const riskLevel = assessCommandRisk(command);
|
|
268
|
+
return {
|
|
269
|
+
command,
|
|
270
|
+
riskLevel: riskLevel.level,
|
|
271
|
+
warnings: riskLevel.warnings,
|
|
272
|
+
proceed: riskLevel.level !== 'high',
|
|
273
|
+
};
|
|
274
|
+
},
|
|
275
|
+
};
|
|
276
|
+
/**
|
|
277
|
+
* Post-command hook MCP tool
|
|
278
|
+
*/
|
|
279
|
+
export const postCommandTool = {
|
|
280
|
+
name: 'hooks/post-command',
|
|
281
|
+
description: 'Execute post-command hooks to record command execution outcome.',
|
|
282
|
+
inputSchema: {
|
|
283
|
+
type: 'object',
|
|
284
|
+
properties: {
|
|
285
|
+
command: {
|
|
286
|
+
type: 'string',
|
|
287
|
+
description: 'Executed command',
|
|
288
|
+
},
|
|
289
|
+
success: {
|
|
290
|
+
type: 'boolean',
|
|
291
|
+
description: 'Whether command succeeded',
|
|
292
|
+
},
|
|
293
|
+
exitCode: {
|
|
294
|
+
type: 'number',
|
|
295
|
+
description: 'Command exit code',
|
|
296
|
+
default: 0,
|
|
297
|
+
},
|
|
298
|
+
output: {
|
|
299
|
+
type: 'string',
|
|
300
|
+
description: 'Command output (truncated)',
|
|
301
|
+
},
|
|
302
|
+
error: {
|
|
303
|
+
type: 'string',
|
|
304
|
+
description: 'Error message if failed',
|
|
305
|
+
},
|
|
306
|
+
executionTime: {
|
|
307
|
+
type: 'number',
|
|
308
|
+
description: 'Execution time in milliseconds',
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
required: ['command', 'success'],
|
|
312
|
+
},
|
|
313
|
+
handler: async (input) => {
|
|
314
|
+
const success = input.success;
|
|
315
|
+
return {
|
|
316
|
+
recorded: true,
|
|
317
|
+
patternId: success ? `cmd-${Date.now()}` : undefined,
|
|
318
|
+
};
|
|
319
|
+
},
|
|
320
|
+
};
|
|
321
|
+
/**
|
|
322
|
+
* Daemon status MCP tool
|
|
323
|
+
*/
|
|
324
|
+
export const daemonStatusTool = {
|
|
325
|
+
name: 'hooks/daemon-status',
|
|
326
|
+
description: 'Get status of hooks daemons.',
|
|
327
|
+
inputSchema: {
|
|
328
|
+
type: 'object',
|
|
329
|
+
properties: {
|
|
330
|
+
daemon: {
|
|
331
|
+
type: 'string',
|
|
332
|
+
description: 'Specific daemon to check (or all)',
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
handler: async (input) => {
|
|
337
|
+
return {
|
|
338
|
+
daemons: [
|
|
339
|
+
{ name: 'metrics-sync', status: 'running', lastUpdate: new Date().toISOString(), executionCount: 45 },
|
|
340
|
+
{ name: 'swarm-monitor', status: 'running', lastUpdate: new Date().toISOString(), executionCount: 890 },
|
|
341
|
+
{ name: 'hooks-learning', status: 'running', lastUpdate: new Date().toISOString(), executionCount: 15 },
|
|
342
|
+
],
|
|
343
|
+
};
|
|
344
|
+
},
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* Statusline data MCP tool
|
|
348
|
+
*/
|
|
349
|
+
export const statuslineTool = {
|
|
350
|
+
name: 'hooks/statusline',
|
|
351
|
+
description: 'Get statusline data for display.',
|
|
352
|
+
inputSchema: {
|
|
353
|
+
type: 'object',
|
|
354
|
+
properties: {
|
|
355
|
+
format: {
|
|
356
|
+
type: 'string',
|
|
357
|
+
enum: ['json', 'text'],
|
|
358
|
+
description: 'Output format',
|
|
359
|
+
default: 'json',
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
},
|
|
363
|
+
handler: async (input) => {
|
|
364
|
+
const { StatuslineGenerator } = await import('../statusline/index.js');
|
|
365
|
+
const generator = new StatuslineGenerator();
|
|
366
|
+
const format = input.format || 'json';
|
|
367
|
+
if (format === 'text') {
|
|
368
|
+
return { statusline: generator.generateStatusline() };
|
|
369
|
+
}
|
|
370
|
+
return generator.generateData();
|
|
371
|
+
},
|
|
372
|
+
};
|
|
373
|
+
/**
|
|
374
|
+
* All hooks MCP tools
|
|
375
|
+
*/
|
|
376
|
+
export const hooksMCPTools = [
|
|
377
|
+
preEditTool,
|
|
378
|
+
postEditTool,
|
|
379
|
+
routeTaskTool,
|
|
380
|
+
metricsTool,
|
|
381
|
+
preCommandTool,
|
|
382
|
+
postCommandTool,
|
|
383
|
+
daemonStatusTool,
|
|
384
|
+
statuslineTool,
|
|
385
|
+
];
|
|
386
|
+
/**
|
|
387
|
+
* Get tool by name
|
|
388
|
+
*/
|
|
389
|
+
export function getHooksTool(name) {
|
|
390
|
+
return hooksMCPTools.find((t) => t.name === name);
|
|
391
|
+
}
|
|
392
|
+
// Helper functions
|
|
393
|
+
function getFileType(filePath) {
|
|
394
|
+
const ext = filePath.split('.').pop() || '';
|
|
395
|
+
const typeMap = {
|
|
396
|
+
ts: 'typescript',
|
|
397
|
+
tsx: 'typescript-react',
|
|
398
|
+
js: 'javascript',
|
|
399
|
+
jsx: 'javascript-react',
|
|
400
|
+
py: 'python',
|
|
401
|
+
go: 'go',
|
|
402
|
+
rs: 'rust',
|
|
403
|
+
md: 'markdown',
|
|
404
|
+
json: 'json',
|
|
405
|
+
yaml: 'yaml',
|
|
406
|
+
yml: 'yaml',
|
|
407
|
+
};
|
|
408
|
+
return typeMap[ext] || 'unknown';
|
|
409
|
+
}
|
|
410
|
+
function routeTaskToAgent(task) {
|
|
411
|
+
const taskLower = task.toLowerCase();
|
|
412
|
+
// Security-related tasks
|
|
413
|
+
if (taskLower.includes('security') || taskLower.includes('auth') || taskLower.includes('cve')) {
|
|
414
|
+
return {
|
|
415
|
+
name: 'security-auditor',
|
|
416
|
+
confidence: 0.92,
|
|
417
|
+
alternatives: [
|
|
418
|
+
{ agent: 'coder', confidence: 0.78 },
|
|
419
|
+
{ agent: 'reviewer', confidence: 0.75 },
|
|
420
|
+
],
|
|
421
|
+
explanation: 'Task involves security considerations, routing to security-auditor.',
|
|
422
|
+
factors: [
|
|
423
|
+
{ factor: 'keyword_match', weight: 0.4, value: 0.95 },
|
|
424
|
+
{ factor: 'historical_success', weight: 0.3, value: 0.88 },
|
|
425
|
+
{ factor: 'agent_availability', weight: 0.3, value: 0.93 },
|
|
426
|
+
],
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
// Testing tasks
|
|
430
|
+
if (taskLower.includes('test') || taskLower.includes('spec') || taskLower.includes('coverage')) {
|
|
431
|
+
return {
|
|
432
|
+
name: 'tester',
|
|
433
|
+
confidence: 0.89,
|
|
434
|
+
alternatives: [
|
|
435
|
+
{ agent: 'coder', confidence: 0.72 },
|
|
436
|
+
{ agent: 'reviewer', confidence: 0.68 },
|
|
437
|
+
],
|
|
438
|
+
explanation: 'Task involves testing, routing to tester agent.',
|
|
439
|
+
factors: [
|
|
440
|
+
{ factor: 'keyword_match', weight: 0.4, value: 0.90 },
|
|
441
|
+
{ factor: 'historical_success', weight: 0.3, value: 0.87 },
|
|
442
|
+
{ factor: 'agent_availability', weight: 0.3, value: 0.91 },
|
|
443
|
+
],
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
// Review tasks
|
|
447
|
+
if (taskLower.includes('review') || taskLower.includes('check') || taskLower.includes('audit')) {
|
|
448
|
+
return {
|
|
449
|
+
name: 'reviewer',
|
|
450
|
+
confidence: 0.87,
|
|
451
|
+
alternatives: [
|
|
452
|
+
{ agent: 'coder', confidence: 0.70 },
|
|
453
|
+
{ agent: 'tester', confidence: 0.65 },
|
|
454
|
+
],
|
|
455
|
+
explanation: 'Task involves review, routing to reviewer agent.',
|
|
456
|
+
factors: [
|
|
457
|
+
{ factor: 'keyword_match', weight: 0.4, value: 0.88 },
|
|
458
|
+
{ factor: 'historical_success', weight: 0.3, value: 0.85 },
|
|
459
|
+
{ factor: 'agent_availability', weight: 0.3, value: 0.88 },
|
|
460
|
+
],
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
// Default to coder
|
|
464
|
+
return {
|
|
465
|
+
name: 'coder',
|
|
466
|
+
confidence: 0.80,
|
|
467
|
+
alternatives: [
|
|
468
|
+
{ agent: 'reviewer', confidence: 0.65 },
|
|
469
|
+
{ agent: 'tester', confidence: 0.60 },
|
|
470
|
+
],
|
|
471
|
+
explanation: 'General development task, routing to coder agent.',
|
|
472
|
+
factors: [
|
|
473
|
+
{ factor: 'default_routing', weight: 0.5, value: 0.80 },
|
|
474
|
+
{ factor: 'historical_success', weight: 0.3, value: 0.78 },
|
|
475
|
+
{ factor: 'agent_availability', weight: 0.2, value: 0.82 },
|
|
476
|
+
],
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
function assessCommandRisk(command) {
|
|
480
|
+
const warnings = [];
|
|
481
|
+
let level = 'low';
|
|
482
|
+
// High-risk patterns
|
|
483
|
+
const highRisk = ['rm -rf', 'format', 'fdisk', 'mkfs', 'dd if='];
|
|
484
|
+
for (const pattern of highRisk) {
|
|
485
|
+
if (command.includes(pattern)) {
|
|
486
|
+
level = 'high';
|
|
487
|
+
warnings.push(`High-risk pattern detected: ${pattern}`);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
// Medium-risk patterns
|
|
491
|
+
const mediumRisk = ['sudo', 'chmod 777', 'npm publish', 'git push --force'];
|
|
492
|
+
for (const pattern of mediumRisk) {
|
|
493
|
+
if (command.includes(pattern)) {
|
|
494
|
+
if (level === 'low')
|
|
495
|
+
level = 'medium';
|
|
496
|
+
warnings.push(`Medium-risk pattern detected: ${pattern}`);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
return { level, warnings };
|
|
500
|
+
}
|
|
501
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA2BH;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAY;IAClC,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,sGAAsG;IACnH,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,+BAA+B;aAC7C;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC;gBACpC,WAAW,EAAE,wBAAwB;gBACrC,OAAO,EAAE,QAAQ;aAClB;YACD,cAAc,EAAE;gBACd,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,kCAAkC;gBAC/C,OAAO,EAAE,IAAI;aACd;YACD,kBAAkB,EAAE;gBAClB,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,2BAA2B;gBACxC,OAAO,EAAE,IAAI;aACd;SACF;QACD,QAAQ,EAAE,CAAC,UAAU,CAAC;KACvB;IACD,OAAO,EAAE,KAAK,EAAE,KAA8B,EAA0B,EAAE;QACxE,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAkB,CAAC;QAC1C,MAAM,SAAS,GAAI,KAAK,CAA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C,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,kBAAkB,CAAC,CAAC;IAC5E,KAAK,MAAM,OAAO,IAAI,UAAU,EAAE,CAAC;QACjC,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAC9B,IAAI,KAAK,KAAK,KAAK;gBAAE,KAAK,GAAG,QAAQ,CAAC;YACtC,QAAQ,CAAC,IAAI,CAAC,iCAAiC,OAAO,EAAE,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* V3 Guidance Provider
|
|
3
|
+
*
|
|
4
|
+
* Generates Claude-visible guidance output from ReasoningBank patterns.
|
|
5
|
+
* Outputs plain text (exit 0) or JSON with additionalContext.
|
|
6
|
+
*
|
|
7
|
+
* @module @claude-flow/hooks/reasoningbank/guidance-provider
|
|
8
|
+
*/
|
|
9
|
+
import { ReasoningBank } from './index.js';
|
|
10
|
+
/**
|
|
11
|
+
* Official Claude hook output format
|
|
12
|
+
*/
|
|
13
|
+
export interface ClaudeHookOutput {
|
|
14
|
+
decision?: 'approve' | 'block' | 'allow' | 'deny';
|
|
15
|
+
reason?: string;
|
|
16
|
+
hookSpecificOutput?: {
|
|
17
|
+
hookEventName: string;
|
|
18
|
+
additionalContext?: string;
|
|
19
|
+
permissionDecision?: 'allow' | 'deny' | 'ask';
|
|
20
|
+
permissionDecisionReason?: string;
|
|
21
|
+
updatedInput?: Record<string, unknown>;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Guidance Provider class
|
|
26
|
+
*
|
|
27
|
+
* Converts ReasoningBank patterns into Claude-visible guidance.
|
|
28
|
+
*/
|
|
29
|
+
export declare class GuidanceProvider {
|
|
30
|
+
private reasoningBank;
|
|
31
|
+
constructor(reasoningBank?: ReasoningBank);
|
|
32
|
+
/**
|
|
33
|
+
* Initialize the provider
|
|
34
|
+
*/
|
|
35
|
+
initialize(): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Generate session start context
|
|
38
|
+
* Returns plain text that Claude will see
|
|
39
|
+
*/
|
|
40
|
+
generateSessionContext(): Promise<string>;
|
|
41
|
+
/**
|
|
42
|
+
* Generate user prompt context
|
|
43
|
+
* Returns plain text guidance based on prompt analysis
|
|
44
|
+
*/
|
|
45
|
+
generatePromptContext(prompt: string): Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Generate pre-edit guidance
|
|
48
|
+
* Returns JSON for Claude hook system
|
|
49
|
+
*/
|
|
50
|
+
generatePreEditGuidance(filePath: string): Promise<ClaudeHookOutput>;
|
|
51
|
+
/**
|
|
52
|
+
* Generate post-edit feedback
|
|
53
|
+
* Returns JSON with quality feedback
|
|
54
|
+
*/
|
|
55
|
+
generatePostEditFeedback(filePath: string, fileContent?: string): Promise<ClaudeHookOutput>;
|
|
56
|
+
/**
|
|
57
|
+
* Generate pre-command guidance
|
|
58
|
+
* Returns JSON with risk assessment
|
|
59
|
+
*/
|
|
60
|
+
generatePreCommandGuidance(command: string): Promise<ClaudeHookOutput>;
|
|
61
|
+
/**
|
|
62
|
+
* Generate task routing guidance
|
|
63
|
+
* Returns plain text with agent recommendation
|
|
64
|
+
*/
|
|
65
|
+
generateRoutingGuidance(task: string): Promise<string>;
|
|
66
|
+
/**
|
|
67
|
+
* Generate stop check
|
|
68
|
+
* Returns exit code 2 + stderr if work incomplete
|
|
69
|
+
*/
|
|
70
|
+
generateStopCheck(): Promise<{
|
|
71
|
+
shouldStop: boolean;
|
|
72
|
+
reason?: string;
|
|
73
|
+
}>;
|
|
74
|
+
private detectDomains;
|
|
75
|
+
private capitalize;
|
|
76
|
+
}
|
|
77
|
+
export declare const guidanceProvider: GuidanceProvider;
|
|
78
|
+
//# sourceMappingURL=guidance-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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