@agentbrain/mcp-server 1.4.19 โ 1.4.33
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 +200 -5
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -1
- package/dist/tools/create-spec.d.ts +82 -0
- package/dist/tools/create-spec.d.ts.map +1 -0
- package/dist/tools/create-spec.js +83 -0
- package/dist/tools/create-spec.js.map +1 -0
- package/dist/tools/detect-doom-loop.d.ts +30 -0
- package/dist/tools/detect-doom-loop.d.ts.map +1 -0
- package/dist/tools/detect-doom-loop.js +41 -0
- package/dist/tools/detect-doom-loop.js.map +1 -0
- package/dist/tools/load-context.d.ts +2 -0
- package/dist/tools/load-context.d.ts.map +1 -1
- package/dist/tools/load-context.js +10 -1
- package/dist/tools/load-context.js.map +1 -1
- package/dist/tools/load-spec.d.ts +30 -0
- package/dist/tools/load-spec.d.ts.map +1 -1
- package/dist/tools/load-spec.js +7 -1
- package/dist/tools/load-spec.js.map +1 -1
- package/dist/tools/save-handoff.d.ts.map +1 -1
- package/dist/tools/save-handoff.js +13 -5
- package/dist/tools/save-handoff.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,8 +8,10 @@ This MCP server lets **Claude Desktop**, **Cursor**, and **Windsurf** access Age
|
|
|
8
8
|
|
|
9
9
|
- ๐ Scan your repository structure
|
|
10
10
|
- ๐ Load comprehensive codebase context
|
|
11
|
+
- ๐ Load task specifications
|
|
11
12
|
- ๐ Read coding standards
|
|
12
13
|
- ๐พ Save session handoffs
|
|
14
|
+
- โ ๏ธ Detect doom loops automatically
|
|
13
15
|
|
|
14
16
|
**No CLI commands needed** - your agent does it all automatically!
|
|
15
17
|
|
|
@@ -87,9 +89,10 @@ Then reopen it.
|
|
|
87
89
|
|
|
88
90
|
1. Start a new conversation in Claude Desktop
|
|
89
91
|
2. Look for the **๐ icon** in the toolbar or bottom of the chat
|
|
90
|
-
3. Click it - you should see "agentbrain" with
|
|
92
|
+
3. Click it - you should see "agentbrain" with 5 tools:
|
|
91
93
|
- `scan_repo`
|
|
92
94
|
- `load_context`
|
|
95
|
+
- `load_spec`
|
|
93
96
|
- `load_standards`
|
|
94
97
|
- `save_handoff`
|
|
95
98
|
|
|
@@ -219,7 +222,7 @@ Look for MCP tools in the Windsurf interface, then ask:
|
|
|
219
222
|
|
|
220
223
|
## Available Tools
|
|
221
224
|
|
|
222
|
-
Once configured, your agent can use these
|
|
225
|
+
Once configured, your agent can use these 5 tools:
|
|
223
226
|
|
|
224
227
|
### 1. `scan_repo` - Analyze Repository Structure
|
|
225
228
|
|
|
@@ -243,6 +246,28 @@ Once configured, your agent can use these 4 tools:
|
|
|
243
246
|
- "Give me the full context of this codebase"
|
|
244
247
|
- "Load project intelligence for my app"
|
|
245
248
|
|
|
249
|
+
**Returns:**
|
|
250
|
+
```json
|
|
251
|
+
{
|
|
252
|
+
"content": "# Repository Intelligence\n\n...",
|
|
253
|
+
"fromCache": true,
|
|
254
|
+
"tokensUsed": 0,
|
|
255
|
+
"doom_warning": null // or doom loop details if detected
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
**Doom Loop Detection:** If you've been modifying the same files repeatedly, `doom_warning` will contain:
|
|
260
|
+
```json
|
|
261
|
+
{
|
|
262
|
+
"detected": true,
|
|
263
|
+
"files": [
|
|
264
|
+
"src/auth.ts (8 times ยท 80%)",
|
|
265
|
+
"src/main.ts (6 times ยท 60%)"
|
|
266
|
+
],
|
|
267
|
+
"message": "Doom loop detected. Stop coding. Investigate root cause first."
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
246
271
|
**Cost:**
|
|
247
272
|
- **First time:** ~$0.02-0.05 (generates documentation)
|
|
248
273
|
- **After that:** $0.00 (uses cache)
|
|
@@ -251,7 +276,52 @@ Once configured, your agent can use these 4 tools:
|
|
|
251
276
|
|
|
252
277
|
---
|
|
253
278
|
|
|
254
|
-
### 3. `
|
|
279
|
+
### 3. `load_spec` - Load Task Specification
|
|
280
|
+
|
|
281
|
+
**What it does:** Loads a task specification file by name, or lists all available specs if no task is specified.
|
|
282
|
+
|
|
283
|
+
**Parameters:**
|
|
284
|
+
- `repoPath` (required): Path to repository
|
|
285
|
+
- `task` (optional): Task description or slug (e.g., "add-oauth-authentication")
|
|
286
|
+
|
|
287
|
+
**Example prompts:**
|
|
288
|
+
- "Load the spec for add-oauth-authentication"
|
|
289
|
+
- "Show me available specs"
|
|
290
|
+
- "Load the task spec for user authentication"
|
|
291
|
+
|
|
292
|
+
**Returns:**
|
|
293
|
+
If task specified: The spec content
|
|
294
|
+
If no task: List of all available specs in .agentbrain/specs/
|
|
295
|
+
|
|
296
|
+
**Cost:** Free - reads from disk
|
|
297
|
+
|
|
298
|
+
**Note:** Specs must be created first using `agentbrain spec` CLI command.
|
|
299
|
+
|
|
300
|
+
**Returns:**
|
|
301
|
+
```json
|
|
302
|
+
{
|
|
303
|
+
"content": "# Task Specification: Add OAuth\n\n...",
|
|
304
|
+
"slug": "add-oauth-authentication",
|
|
305
|
+
"doom_warning": null // or doom loop details if detected
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
**Example usage:**
|
|
310
|
+
```typescript
|
|
311
|
+
// List all specs
|
|
312
|
+
load_spec({ repoPath: "/path/to/project" })
|
|
313
|
+
// Returns: "Available specs:\n\n- add-oauth-authentication\n- implement-notifications"
|
|
314
|
+
|
|
315
|
+
// Load specific spec
|
|
316
|
+
load_spec({ repoPath: "/path/to/project", task: "add-oauth-authentication" })
|
|
317
|
+
// Returns: Full spec content with problem, approach, acceptance criteria, etc.
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
**Doom Loop Detection:** Like `load_context`, this tool returns doom warnings if detected.
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
### 4. `load_standards` - Load Coding Standards
|
|
255
325
|
|
|
256
326
|
**What it does:** Loads the coding standards file for your specific agent (CLAUDE.md, .cursor/rules, or .windsurfrules).
|
|
257
327
|
|
|
@@ -266,7 +336,7 @@ Once configured, your agent can use these 4 tools:
|
|
|
266
336
|
|
|
267
337
|
---
|
|
268
338
|
|
|
269
|
-
###
|
|
339
|
+
### 5. `save_handoff` - Save Session Handoff
|
|
270
340
|
|
|
271
341
|
**What it does:** Analyzes your recent git changes and creates a handoff document for the next session.
|
|
272
342
|
|
|
@@ -280,6 +350,27 @@ Once configured, your agent can use these 4 tools:
|
|
|
280
350
|
- "Create a handoff document with goal: implemented auth"
|
|
281
351
|
- "Generate a session summary with the last 10 commits"
|
|
282
352
|
|
|
353
|
+
**Returns:**
|
|
354
|
+
```json
|
|
355
|
+
{
|
|
356
|
+
"path": ".agentbrain/handoff.md",
|
|
357
|
+
"created": true,
|
|
358
|
+
"doom_warning": null // or doom loop details if detected
|
|
359
|
+
}
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
**Doom Loop Detection:** If a doom loop is detected, a warning section is **automatically appended** to the handoff document:
|
|
363
|
+
|
|
364
|
+
```markdown
|
|
365
|
+
## โ Doom Loop Warning
|
|
366
|
+
|
|
367
|
+
The following files were modified repeatedly before this handoff. Investigate before continuing:
|
|
368
|
+
- src/auth.ts (8 times ยท 80%)
|
|
369
|
+
- src/main.ts (6 times ยท 60%)
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
This ensures the next session starts with awareness of potential issues.
|
|
373
|
+
|
|
283
374
|
**Cost:** ~$0.01
|
|
284
375
|
|
|
285
376
|
---
|
|
@@ -316,7 +407,7 @@ Agent: "Based on your current architecture, I recommend adding a
|
|
|
316
407
|
```
|
|
317
408
|
You: "Save a handoff with goal: Implemented notification system"
|
|
318
409
|
Agent: *Uses save_handoff tool*
|
|
319
|
-
Agent: "Handoff saved to agentbrain/handoff.md!
|
|
410
|
+
Agent: "Handoff saved to .agentbrain/handoff.md!
|
|
320
411
|
Summary: Added NotificationService, integrated with existing
|
|
321
412
|
user system, added tests. Next steps: Add email integration
|
|
322
413
|
and push notification support."
|
|
@@ -324,6 +415,59 @@ Agent: "Handoff saved to agentbrain/handoff.md!
|
|
|
324
415
|
|
|
325
416
|
---
|
|
326
417
|
|
|
418
|
+
## Doom Loop Detection in MCP
|
|
419
|
+
|
|
420
|
+
AgentBrain MCP tools automatically detect doom loops - situations where you're modifying the same files repeatedly, indicating you may be stuck.
|
|
421
|
+
|
|
422
|
+
### How It Works
|
|
423
|
+
|
|
424
|
+
1. **Post-commit hook** analyzes git history in the background
|
|
425
|
+
2. **Hook logs detection** to `.agentbrain/update.log` if threshold exceeded
|
|
426
|
+
3. **MCP tools check** for pending doom warnings on every call
|
|
427
|
+
4. **Warning included** in tool responses if detected
|
|
428
|
+
|
|
429
|
+
### Which Tools Return Doom Warnings
|
|
430
|
+
|
|
431
|
+
Three "decision point" tools include doom warnings:
|
|
432
|
+
|
|
433
|
+
- **`load_context`** - When loading full context at session start
|
|
434
|
+
- **`load_spec`** - When loading task specifications
|
|
435
|
+
- **`save_handoff`** - When saving session handoffs (also appends to document)
|
|
436
|
+
|
|
437
|
+
### Stateless Design
|
|
438
|
+
|
|
439
|
+
Unlike the CLI (which shows warnings once per commit), MCP tools are **stateless**:
|
|
440
|
+
|
|
441
|
+
- Warning appears in **every tool response** while the doom condition exists
|
|
442
|
+
- Never marked as "shown" - agents can see warnings multiple times
|
|
443
|
+
- This ensures warnings aren't missed in long sessions
|
|
444
|
+
|
|
445
|
+
### Example: Agent Response with Doom Warning
|
|
446
|
+
|
|
447
|
+
When your agent calls `load_context` during a doom loop:
|
|
448
|
+
|
|
449
|
+
```
|
|
450
|
+
Agent: "I've loaded the repository context. However, I notice a doom loop
|
|
451
|
+
warning - you've been modifying src/auth.ts 8 times in the last 10
|
|
452
|
+
commits (80%). This suggests we may be stuck. Should we step back
|
|
453
|
+
and investigate the root cause first?"
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
The agent can proactively suggest stopping to plan rather than continuing to code.
|
|
457
|
+
|
|
458
|
+
### Clearing Doom Warnings
|
|
459
|
+
|
|
460
|
+
Doom warnings clear automatically when:
|
|
461
|
+
- You commit changes to **different files** (breaking the pattern)
|
|
462
|
+
- Enough commits pass that repeated files drop below threshold
|
|
463
|
+
|
|
464
|
+
Or manually via CLI:
|
|
465
|
+
```bash
|
|
466
|
+
agentbrain doom --commits 20 --threshold 6 # Check with different thresholds
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
---
|
|
470
|
+
|
|
327
471
|
## Troubleshooting
|
|
328
472
|
|
|
329
473
|
### "AgentBrain not showing up in my agent"
|
|
@@ -379,6 +523,56 @@ ls /path/to/your/project
|
|
|
379
523
|
|
|
380
524
|
---
|
|
381
525
|
|
|
526
|
+
### "Doom warnings appearing too often"
|
|
527
|
+
|
|
528
|
+
**Adjust sensitivity via CLI:**
|
|
529
|
+
|
|
530
|
+
Doom detection uses these defaults:
|
|
531
|
+
- Last **10 commits** analyzed
|
|
532
|
+
- File must appear **4+ times** to trigger (40%+)
|
|
533
|
+
|
|
534
|
+
To change thresholds, edit the post-commit hook or run manually:
|
|
535
|
+
```bash
|
|
536
|
+
agentbrain doom --commits 15 --threshold 6
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
**Excluded automatically:**
|
|
540
|
+
- Lock files (package-lock.json, yarn.lock, etc.)
|
|
541
|
+
- AgentBrain files (CLAUDE.md, .cursorrules, etc.)
|
|
542
|
+
- Markdown documentation files
|
|
543
|
+
|
|
544
|
+
**False positives are rare** - if you see a doom warning, you're likely stuck on a problem.
|
|
545
|
+
|
|
546
|
+
---
|
|
547
|
+
|
|
548
|
+
### "Doom warnings not appearing when they should"
|
|
549
|
+
|
|
550
|
+
**1. Check if doom detection is enabled:**
|
|
551
|
+
```bash
|
|
552
|
+
# Verify post-commit hook exists
|
|
553
|
+
ls -la .git/hooks/post-commit
|
|
554
|
+
# or for Husky:
|
|
555
|
+
ls -la .husky/post-commit
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
**2. Check update log:**
|
|
559
|
+
```bash
|
|
560
|
+
cat .agentbrain/update.log | grep DOOM
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
**3. Manually check for doom loop:**
|
|
564
|
+
```bash
|
|
565
|
+
agentbrain doom
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
**4. Reinstall hooks if needed:**
|
|
569
|
+
```bash
|
|
570
|
+
agentbrain disable --remove-hooks
|
|
571
|
+
agentbrain setup --no-confirm
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
---
|
|
575
|
+
|
|
382
576
|
## Configuration Examples
|
|
383
577
|
|
|
384
578
|
### Minimal Configuration (Recommended)
|
|
@@ -484,6 +678,7 @@ This gives your agent full project awareness immediately.
|
|
|
484
678
|
**Q: Does this cost money?**
|
|
485
679
|
A: Depends on the tool:
|
|
486
680
|
- `scan_repo` - Free
|
|
681
|
+
- `load_spec` - Free
|
|
487
682
|
- `load_standards` - Free
|
|
488
683
|
- `load_context` (cached) - Free
|
|
489
684
|
- `load_context` (first time) - ~$0.02-0.05
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,8 @@ import { loadStandards, loadStandardsSchema } from './tools/load-standards.js';
|
|
|
8
8
|
import { loadContext, loadContextSchema } from './tools/load-context.js';
|
|
9
9
|
import { saveHandoff, saveHandoffSchema } from './tools/save-handoff.js';
|
|
10
10
|
import { loadSpecTool, loadSpecSchema } from './tools/load-spec.js';
|
|
11
|
+
import { createSpecTool, createSpecSchema } from './tools/create-spec.js';
|
|
12
|
+
import { detectDoomLoop, detectDoomLoopSchema } from './tools/detect-doom-loop.js';
|
|
11
13
|
// Create MCP server
|
|
12
14
|
const server = new Server({
|
|
13
15
|
name: 'agentbrain',
|
|
@@ -25,6 +27,8 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
25
27
|
loadStandardsSchema,
|
|
26
28
|
loadContextSchema,
|
|
27
29
|
loadSpecSchema,
|
|
30
|
+
createSpecSchema,
|
|
31
|
+
detectDoomLoopSchema,
|
|
28
32
|
saveHandoffSchema,
|
|
29
33
|
],
|
|
30
34
|
};
|
|
@@ -70,6 +74,28 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
70
74
|
],
|
|
71
75
|
};
|
|
72
76
|
}
|
|
77
|
+
case 'create_spec': {
|
|
78
|
+
const result = await createSpecTool(args);
|
|
79
|
+
return {
|
|
80
|
+
content: [
|
|
81
|
+
{
|
|
82
|
+
type: 'text',
|
|
83
|
+
text: `Spec created successfully!\n\nFile: ${result.specPath}\nSlug: ${result.slug}\nTokens used: ${result.tokensUsed}\nCost: ~$${result.cost.toFixed(4)}\n${result.injected ? 'Injected into agent files: YES' : 'Injected into agent files: NO'}\n\n---\n\n${result.content}`,
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
case 'detect_doom_loop': {
|
|
89
|
+
const result = await detectDoomLoop(args);
|
|
90
|
+
return {
|
|
91
|
+
content: [
|
|
92
|
+
{
|
|
93
|
+
type: 'text',
|
|
94
|
+
text: JSON.stringify(result, null, 2),
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
};
|
|
98
|
+
}
|
|
73
99
|
case 'save_handoff': {
|
|
74
100
|
const result = await saveHandoff(args);
|
|
75
101
|
return {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,wBAAwB;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAA;AAE3C,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE/D,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAE9E,OAAO,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AAU,cAAc,MAAM,CAAC,OAAO,EAAE;yBAC7G;qBACF;iBACF,CAAA;YACH,CAAC;YAED;gBACE,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAA;QAC5C,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAA;QACxE,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,OAAO,EAAE,EAAE,CAAC;YACtD,OAAO,EAAE,IAAI;SACd,CAAA;IACH,CAAC;AACH,CAAC,CAAC,CAAA;AAEF,eAAe;AACf,KAAK,UAAU,IAAI;IACjB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAA;IAC5C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IAE/B,oEAAoE;IACpE,OAAO,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAA;AACzD,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAA;IACpC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const createSpecSchema: {
|
|
3
|
+
readonly name: "create_spec";
|
|
4
|
+
readonly description: "Create a task specification with AI-guided structure. Generates a spec file with problem statement, scope, acceptance criteria, and implementation notes based on repository context.";
|
|
5
|
+
readonly inputSchema: {
|
|
6
|
+
readonly type: "object";
|
|
7
|
+
readonly properties: {
|
|
8
|
+
readonly repoPath: {
|
|
9
|
+
readonly type: "string";
|
|
10
|
+
readonly description: "Absolute path to the repository";
|
|
11
|
+
};
|
|
12
|
+
readonly task: {
|
|
13
|
+
readonly type: "string";
|
|
14
|
+
readonly description: "Brief task description (e.g., \"add OAuth authentication\")";
|
|
15
|
+
};
|
|
16
|
+
readonly problem: {
|
|
17
|
+
readonly type: "string";
|
|
18
|
+
readonly description: "What problem does this solve? (1-2 sentences)";
|
|
19
|
+
};
|
|
20
|
+
readonly approach: {
|
|
21
|
+
readonly type: "string";
|
|
22
|
+
readonly description: "Your implementation approach or \"not sure yet\" if unknown";
|
|
23
|
+
};
|
|
24
|
+
readonly outOfScope: {
|
|
25
|
+
readonly type: "string";
|
|
26
|
+
readonly description: "What should NOT be touched or changed";
|
|
27
|
+
};
|
|
28
|
+
readonly doneCriteria: {
|
|
29
|
+
readonly type: "string";
|
|
30
|
+
readonly description: "What does \"done\" look like? (acceptance criteria)";
|
|
31
|
+
};
|
|
32
|
+
readonly risks: {
|
|
33
|
+
readonly type: "string";
|
|
34
|
+
readonly description: "Any edge cases or risks to consider";
|
|
35
|
+
};
|
|
36
|
+
readonly inject: {
|
|
37
|
+
readonly type: "boolean";
|
|
38
|
+
readonly description: "Inject spec reference into agent files (CLAUDE.md, .cursorrules, etc.) [default: true]";
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
readonly required: readonly ["repoPath", "task", "problem", "doneCriteria"];
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
declare const inputSchema: z.ZodObject<{
|
|
45
|
+
repoPath: z.ZodString;
|
|
46
|
+
task: z.ZodString;
|
|
47
|
+
problem: z.ZodString;
|
|
48
|
+
approach: z.ZodOptional<z.ZodString>;
|
|
49
|
+
outOfScope: z.ZodOptional<z.ZodString>;
|
|
50
|
+
doneCriteria: z.ZodString;
|
|
51
|
+
risks: z.ZodOptional<z.ZodString>;
|
|
52
|
+
inject: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
53
|
+
}, "strip", z.ZodTypeAny, {
|
|
54
|
+
repoPath: string;
|
|
55
|
+
task: string;
|
|
56
|
+
problem: string;
|
|
57
|
+
doneCriteria: string;
|
|
58
|
+
inject: boolean;
|
|
59
|
+
approach?: string | undefined;
|
|
60
|
+
outOfScope?: string | undefined;
|
|
61
|
+
risks?: string | undefined;
|
|
62
|
+
}, {
|
|
63
|
+
repoPath: string;
|
|
64
|
+
task: string;
|
|
65
|
+
problem: string;
|
|
66
|
+
doneCriteria: string;
|
|
67
|
+
approach?: string | undefined;
|
|
68
|
+
outOfScope?: string | undefined;
|
|
69
|
+
risks?: string | undefined;
|
|
70
|
+
inject?: boolean | undefined;
|
|
71
|
+
}>;
|
|
72
|
+
export type CreateSpecInput = z.infer<typeof inputSchema>;
|
|
73
|
+
export declare function createSpecTool(input: CreateSpecInput): Promise<{
|
|
74
|
+
specPath: string;
|
|
75
|
+
slug: string;
|
|
76
|
+
content: string;
|
|
77
|
+
tokensUsed: number;
|
|
78
|
+
cost: number;
|
|
79
|
+
injected: boolean;
|
|
80
|
+
}>;
|
|
81
|
+
export {};
|
|
82
|
+
//# sourceMappingURL=create-spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-spec.d.ts","sourceRoot":"","sources":["../../src/tools/create-spec.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAKvB,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6CnB,CAAA;AAEV,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;EASf,CAAA;AAEF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAA;AAEzD,wBAAsB,cAAc,CAAC,KAAK,EAAE,eAAe;;;;;;;GAiC1D"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// create-spec.ts - MCP tool to create task specifications
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { createSpec as coreCreateSpec } from '@agentbrain/core';
|
|
4
|
+
import { loadAIConfig } from '@agentbrain/core';
|
|
5
|
+
import { resolve } from 'node:path';
|
|
6
|
+
export const createSpecSchema = {
|
|
7
|
+
name: 'create_spec',
|
|
8
|
+
description: 'Create a task specification with AI-guided structure. Generates a spec file with problem statement, scope, acceptance criteria, and implementation notes based on repository context.',
|
|
9
|
+
inputSchema: {
|
|
10
|
+
type: 'object',
|
|
11
|
+
properties: {
|
|
12
|
+
repoPath: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
description: 'Absolute path to the repository',
|
|
15
|
+
},
|
|
16
|
+
task: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
description: 'Brief task description (e.g., "add OAuth authentication")',
|
|
19
|
+
},
|
|
20
|
+
problem: {
|
|
21
|
+
type: 'string',
|
|
22
|
+
description: 'What problem does this solve? (1-2 sentences)',
|
|
23
|
+
},
|
|
24
|
+
approach: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
description: 'Your implementation approach or "not sure yet" if unknown',
|
|
27
|
+
},
|
|
28
|
+
outOfScope: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
description: 'What should NOT be touched or changed',
|
|
31
|
+
},
|
|
32
|
+
doneCriteria: {
|
|
33
|
+
type: 'string',
|
|
34
|
+
description: 'What does "done" look like? (acceptance criteria)',
|
|
35
|
+
},
|
|
36
|
+
risks: {
|
|
37
|
+
type: 'string',
|
|
38
|
+
description: 'Any edge cases or risks to consider',
|
|
39
|
+
},
|
|
40
|
+
inject: {
|
|
41
|
+
type: 'boolean',
|
|
42
|
+
description: 'Inject spec reference into agent files (CLAUDE.md, .cursorrules, etc.) [default: true]',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
required: ['repoPath', 'task', 'problem', 'doneCriteria'],
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
const inputSchema = z.object({
|
|
49
|
+
repoPath: z.string(),
|
|
50
|
+
task: z.string(),
|
|
51
|
+
problem: z.string(),
|
|
52
|
+
approach: z.string().optional(),
|
|
53
|
+
outOfScope: z.string().optional(),
|
|
54
|
+
doneCriteria: z.string(),
|
|
55
|
+
risks: z.string().optional(),
|
|
56
|
+
inject: z.boolean().optional().default(true),
|
|
57
|
+
});
|
|
58
|
+
export async function createSpecTool(input) {
|
|
59
|
+
// Validate input
|
|
60
|
+
const validated = inputSchema.parse(input);
|
|
61
|
+
const repoPath = resolve(validated.repoPath);
|
|
62
|
+
// Load AI config (will use env vars or stored config)
|
|
63
|
+
const aiConfig = await loadAIConfig();
|
|
64
|
+
// Build answers object for spec generation
|
|
65
|
+
const answers = {
|
|
66
|
+
problem: validated.problem,
|
|
67
|
+
approach: validated.approach || 'not sure yet',
|
|
68
|
+
outOfScope: validated.outOfScope || 'none specified',
|
|
69
|
+
doneCriteria: validated.doneCriteria,
|
|
70
|
+
risks: validated.risks || 'none specified',
|
|
71
|
+
};
|
|
72
|
+
// Use core createSpec function (handles everything: generate, save, inject)
|
|
73
|
+
const result = await coreCreateSpec(validated.task, answers, repoPath, aiConfig);
|
|
74
|
+
return {
|
|
75
|
+
specPath: result.filePath.replace(repoPath, '').slice(1), // Relative path
|
|
76
|
+
slug: result.slug,
|
|
77
|
+
content: result.content,
|
|
78
|
+
tokensUsed: result.tokensUsed,
|
|
79
|
+
cost: result.cost,
|
|
80
|
+
injected: true, // coreCreateSpec always injects
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=create-spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-spec.js","sourceRoot":"","sources":["../../src/tools/create-spec.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAE1D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;A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LoopInput {
|
|
3
|
+
repo_path: string;
|
|
4
|
+
commit_count?: number;
|
|
5
|
+
threshold?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function detectDoomLoop(input: DetectDoomLoopInput): Promise<DoomLoopResult>;
|
|
8
|
+
export declare const detectDoomLoopSchema: {
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
inputSchema: {
|
|
12
|
+
type: string;
|
|
13
|
+
properties: {
|
|
14
|
+
repo_path: {
|
|
15
|
+
type: string;
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
commit_count: {
|
|
19
|
+
type: string;
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
22
|
+
threshold: {
|
|
23
|
+
type: string;
|
|
24
|
+
description: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
required: string[];
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=detect-doom-loop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-doom-loop.d.ts","sourceRoot":"","sources":["../../src/tools/detect-doom-loop.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AActD,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,wBAAsB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,cAAc,CAAC,CAMxF;AAED,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;CAsBhC,CAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// MCP tool: detect_doom_loop - detect files modified repeatedly
|
|
2
|
+
import { analyzeDoomLoop } from '@agentbrain/core';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { resolve } from 'node:path';
|
|
5
|
+
/**
|
|
6
|
+
* Expand path: handles ~, relative paths, etc.
|
|
7
|
+
*/
|
|
8
|
+
function expandPath(path) {
|
|
9
|
+
if (path.startsWith('~/') || path === '~') {
|
|
10
|
+
return path.replace('~', homedir());
|
|
11
|
+
}
|
|
12
|
+
return resolve(path);
|
|
13
|
+
}
|
|
14
|
+
export async function detectDoomLoop(input) {
|
|
15
|
+
const { repo_path, commit_count = 10, threshold = 4 } = input;
|
|
16
|
+
const expandedPath = expandPath(repo_path);
|
|
17
|
+
return await analyzeDoomLoop(expandedPath, commit_count, threshold);
|
|
18
|
+
}
|
|
19
|
+
export const detectDoomLoopSchema = {
|
|
20
|
+
name: 'detect_doom_loop',
|
|
21
|
+
description: 'Detect doom loops by analyzing git history for files modified repeatedly in recent commits. Returns files appearing in 4+ of last 10 commits.',
|
|
22
|
+
inputSchema: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: {
|
|
25
|
+
repo_path: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
description: 'Absolute path to the repository',
|
|
28
|
+
},
|
|
29
|
+
commit_count: {
|
|
30
|
+
type: 'number',
|
|
31
|
+
description: 'Number of recent commits to analyze (default: 10)',
|
|
32
|
+
},
|
|
33
|
+
threshold: {
|
|
34
|
+
type: 'number',
|
|
35
|
+
description: 'Minimum commits for a file to be flagged (default: 4)',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
required: ['repo_path'],
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=detect-doom-loop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-doom-loop.js","sourceRoot":"","sources":["../../src/tools/detect-doom-loop.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAEhE,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAElD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC;;GAEG;AACH,SAAS,UAAU,CAAC,IAAY;IAC9B,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;QAC1C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,CAAC,CAAA;IACrC,CAAC;IACD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAA;AACtB,CAAC;AAQD,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,KAA0B;IAC7D,MAAM,EAAE,SAAS,EAAE,YAAY,GAAG,EAAE,EAAE,SAAS,GAAG,CAAC,EAAE,GAAG,KAAK,CAAA;IAE7D,MAAM,YAAY,GAAG,UAAU,CAAC,SAAS,CAAC,CAAA;IAE1C,OAAO,MAAM,eAAe,CAAC,YAAY,EAAE,YAAY,EAAE,SAAS,CAAC,CAAA;AACrE,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EACT,+IAA+I;IACjJ,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,iCAAiC;aAC/C;YACD,YAAY,EAAE;gBACZ,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,mDAAmD;aACjE;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,uDAAuD;aACrE;SACF;QACD,QAAQ,EAAE,CAAC,WAAW,CAAC;KACxB;CACF,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type DoomWarningForMCP } from '@agentbrain/core';
|
|
1
2
|
export interface LoadContextInput {
|
|
2
3
|
repo_path: string;
|
|
3
4
|
force_refresh?: boolean;
|
|
@@ -10,6 +11,7 @@ export interface LoadContextOutput {
|
|
|
10
11
|
cached_sha?: string;
|
|
11
12
|
current_sha?: string;
|
|
12
13
|
message?: string;
|
|
14
|
+
doom_warning?: DoomWarningForMCP | null;
|
|
13
15
|
}
|
|
14
16
|
export declare function loadContext(input: LoadContextInput): Promise<LoadContextOutput>;
|
|
15
17
|
export declare const loadContextSchema: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-context.d.ts","sourceRoot":"","sources":["../../src/tools/load-context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"load-context.d.ts","sourceRoot":"","sources":["../../src/tools/load-context.ts"],"names":[],"mappings":"AAMA,OAAO,EAOL,KAAK,iBAAiB,EACvB,MAAM,kBAAkB,CAAA;AAYzB,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,OAAO,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAA;CACxC;AAED,wBAAsB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAoGrF;AAED,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;CAkB7B,CAAA"}
|
|
@@ -3,7 +3,7 @@ import { readFile } from 'node:fs/promises';
|
|
|
3
3
|
import { existsSync } from 'node:fs';
|
|
4
4
|
import { join, resolve } from 'node:path';
|
|
5
5
|
import { homedir } from 'node:os';
|
|
6
|
-
import { loadAIConfig, generateContext, getCachedDoc, getGitHash, loadCache } from '@agentbrain/core';
|
|
6
|
+
import { loadAIConfig, generateContext, getCachedDoc, getGitHash, loadCache, getPendingDoomForMCP, } from '@agentbrain/core';
|
|
7
7
|
/**
|
|
8
8
|
* Expand path: handles ~, relative paths, etc.
|
|
9
9
|
*/
|
|
@@ -34,6 +34,8 @@ export async function loadContext(input) {
|
|
|
34
34
|
// Check if cached git hash matches current HEAD
|
|
35
35
|
const cache = await loadCache(expandedPath);
|
|
36
36
|
const isStale = cache && cache.gitHash !== currentGitHash;
|
|
37
|
+
// Check for doom loop warnings
|
|
38
|
+
const doomWarning = await getPendingDoomForMCP(expandedPath);
|
|
37
39
|
return {
|
|
38
40
|
content: combined,
|
|
39
41
|
fromCache: true,
|
|
@@ -44,6 +46,7 @@ export async function loadContext(input) {
|
|
|
44
46
|
current_sha: currentGitHash,
|
|
45
47
|
message: 'Context may be outdated. Run agentbrain init to refresh.',
|
|
46
48
|
}),
|
|
49
|
+
doom_warning: doomWarning,
|
|
47
50
|
};
|
|
48
51
|
}
|
|
49
52
|
// Need to generate - requires API key
|
|
@@ -57,6 +60,8 @@ export async function loadContext(input) {
|
|
|
57
60
|
// Check if cached git hash matches current HEAD
|
|
58
61
|
const cache = await loadCache(expandedPath);
|
|
59
62
|
const isStale = cache && cache.gitHash !== currentGitHash;
|
|
63
|
+
// Check for doom loop warnings
|
|
64
|
+
const doomWarning = await getPendingDoomForMCP(expandedPath);
|
|
60
65
|
return {
|
|
61
66
|
content: combined,
|
|
62
67
|
fromCache: true,
|
|
@@ -67,6 +72,7 @@ export async function loadContext(input) {
|
|
|
67
72
|
current_sha: currentGitHash,
|
|
68
73
|
message: 'Context may be outdated. Run agentbrain init to refresh.',
|
|
69
74
|
}),
|
|
75
|
+
doom_warning: doomWarning,
|
|
70
76
|
};
|
|
71
77
|
}
|
|
72
78
|
// Generate new context
|
|
@@ -78,11 +84,14 @@ export async function loadContext(input) {
|
|
|
78
84
|
const combined = result.docs
|
|
79
85
|
.map((doc) => `# ${doc.type}\n\n${doc.content}`)
|
|
80
86
|
.join('\n\n---\n\n');
|
|
87
|
+
// Check for doom loop warnings
|
|
88
|
+
const doomWarning = await getPendingDoomForMCP(expandedPath);
|
|
81
89
|
// Newly generated content is never stale
|
|
82
90
|
return {
|
|
83
91
|
content: combined,
|
|
84
92
|
fromCache: false,
|
|
85
93
|
tokensUsed: result.totalTokens,
|
|
94
|
+
doom_warning: doomWarning,
|
|
86
95
|
};
|
|
87
96
|
}
|
|
88
97
|
export const loadContextSchema = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-context.js","sourceRoot":"","sources":["../../src/tools/load-context.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,
|
|
1
|
+
{"version":3,"file":"load-context.js","sourceRoot":"","sources":["../../src/tools/load-context.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EACL,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,UAAU,EACV,SAAS,EACT,oBAAoB,GAErB,MAAM,kBAAkB,CAAA;AAEzB;;GAEG;AACH,SAAS,UAAU,CAAC,IAAY;IAC9B,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;QAC1C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,CAAC,CAAA;IACrC,CAAC;IACD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAA;AACt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AAE,KAAK,CAAC,OAAO;gBACzB,WAAW,EAAE,cAAc;gBAC3B,OAAO,EAAE,0DAA0D;aACpE,CAAC;YACF,YAAY,EAAE,WAAW;SAC1B,CAAA;IACH,CAAC;IAED,uBAAuB;IACvB,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC;QACnC,QAAQ,EAAE,YAAY;QACtB,QAAQ;QACR,QAAQ,EAAE,CAAC,aAAa;KACzB,CAAC,CAAA;IAEF,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI;SACzB,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC,OAAO,EAAE,CAAC;SAC/C,IAAI,CAAC,aAAa,CAAC,CAAA;IAEtB,+BAA+B;IAC/B,MAAM,WAAW,GAAG,MAAM,oBAAoB,CAAC,YAAY,CAAC,CAAA;IAE5D,yCAAyC;IACzC,OAAO;QACL,OAAO,EAAE,QAAQ;QACjB,SAAS,EAAE,KAAK;QAChB,UAAU,EAAE,MAAM,CAAC,WAAW;QAC9B,YAAY,EAAE,WAAW;KAC1B,CAAA;AACH,CAAC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,cAAc;IACpB,WAAW,EACT,iIAAiI;IACnI,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,iCAAiC;aAC/C;YACD,aAAa,EAAE;gBACb,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,4DAA4D;aAC1E;SACF;QACD,QAAQ,EAAE,CAAC,WAAW,CAAC;KACxB;CACF,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type DoomWarningForMCP } from '@agentbrain/core';
|
|
2
|
+
export interface LoadSpecInput {
|
|
3
|
+
repoPath: string;
|
|
4
|
+
task?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface LoadSpecOutput {
|
|
7
|
+
content: string;
|
|
8
|
+
slug?: string;
|
|
9
|
+
doom_warning?: DoomWarningForMCP | null;
|
|
10
|
+
}
|
|
11
|
+
export declare const loadSpecSchema: {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
inputSchema: {
|
|
15
|
+
type: string;
|
|
16
|
+
properties: {
|
|
17
|
+
repoPath: {
|
|
18
|
+
type: string;
|
|
19
|
+
description: string;
|
|
20
|
+
};
|
|
21
|
+
task: {
|
|
22
|
+
type: string;
|
|
23
|
+
description: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
required: string[];
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export declare function loadSpecTool(input: LoadSpecInput): Promise<LoadSpecOutput>;
|
|
30
|
+
//# sourceMappingURL=load-spec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-spec.d.ts","sourceRoot":"","sources":["../../src/tools/load-spec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"load-spec.d.ts","sourceRoot":"","sources":["../../src/tools/load-spec.ts"],"names":[],"mappings":"AAEA,OAAO,EAA6C,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEpG,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAA;CACxC;AAED,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;CAmB1B,CAAA;AAED,wBAAsB,YAAY,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CA4ChF"}
|
package/dist/tools/load-spec.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// MCP tool: load_spec - Load specification files
|
|
2
|
-
import { listSpecs, loadSpec } from '@agentbrain/core';
|
|
2
|
+
import { listSpecs, loadSpec, getPendingDoomForMCP } from '@agentbrain/core';
|
|
3
3
|
export const loadSpecSchema = {
|
|
4
4
|
name: 'load_spec',
|
|
5
5
|
description: 'Load a specification file by task name, or list all available specs if no task provided',
|
|
@@ -20,16 +20,20 @@ export const loadSpecSchema = {
|
|
|
20
20
|
};
|
|
21
21
|
export async function loadSpecTool(input) {
|
|
22
22
|
const { repoPath, task } = input;
|
|
23
|
+
// Check for doom loop warnings
|
|
24
|
+
const doomWarning = await getPendingDoomForMCP(repoPath);
|
|
23
25
|
// If no task provided, list all available specs
|
|
24
26
|
if (!task) {
|
|
25
27
|
const specs = await listSpecs(repoPath);
|
|
26
28
|
if (specs.length === 0) {
|
|
27
29
|
return {
|
|
28
30
|
content: 'No specs found. Run `agentbrain spec "<task>"` to create your first specification.',
|
|
31
|
+
doom_warning: doomWarning,
|
|
29
32
|
};
|
|
30
33
|
}
|
|
31
34
|
return {
|
|
32
35
|
content: `Available specs:\n\n${specs.map((s) => `- ${s}`).join('\n')}\n\nTo load a spec, provide the task slug as the "task" parameter.`,
|
|
36
|
+
doom_warning: doomWarning,
|
|
33
37
|
};
|
|
34
38
|
}
|
|
35
39
|
// Convert task to slug format (kebab-case)
|
|
@@ -41,11 +45,13 @@ export async function loadSpecTool(input) {
|
|
|
41
45
|
if (!content) {
|
|
42
46
|
return {
|
|
43
47
|
content: `Spec not found: ${slug}\n\nRun \`agentbrain spec "${task}"\` to create it.`,
|
|
48
|
+
doom_warning: doomWarning,
|
|
44
49
|
};
|
|
45
50
|
}
|
|
46
51
|
return {
|
|
47
52
|
content,
|
|
48
53
|
slug,
|
|
54
|
+
doom_warning: doomWarning,
|
|
49
55
|
};
|
|
50
56
|
}
|
|
51
57
|
//# sourceMappingURL=load-spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-spec.js","sourceRoot":"","sources":["../../src/tools/load-spec.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"load-spec.js","sourceRoot":"","sources":["../../src/tools/load-spec.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,oBAAoB,EAA0B,MAAM,kBAAkB,CAAA;AAapG,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,WAAW;IACjB,WAAW,EACT,yFAAyF;IAC3F,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,iCAAiC;aAC/C;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,+FAA+F;aAClG;SACF;QACD,QAAQ,EAAE,CAAC,UAAU,CAAC;KACvB;CACF,CAAA;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,KAAoB;IACrD,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,KAAK,CAAA;IAEhC,+BAA+B;IAC/B,MAAM,WAAW,GAAG,MAAM,oBAAoB,CAAC,QAAQ,CAAC,CAAA;IAExD,gDAAgD;IAChD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,CAAA;QAEvC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO;gBACL,OAAO,EACL,oFAAoF;gBACtF,YAAY,EAAE,WAAW;aAC1B,CAAA;QACH,CAAC;QAED,OAAO;YACL,OAAO,EAAE,uBAAuB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,oEAAoE;YACzI,YAAY,EAAE,WAAW;SAC1B,CAAA;IACH,CAAC;IAED,2CAA2C;IAC3C,MAAM,IAAI,GAAG,IAAI;SACd,WAAW,EAAE;SACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAA;IAE1B,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;IAE9C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;YACL,OAAO,EAAE,mBAAmB,IAAI,8BAA8B,IAAI,mBAAmB;YACrF,YAAY,EAAE,WAAW;SAC1B,CAAA;IACH,CAAC;IAED,OAAO;QACL,OAAO;QACP,IAAI;QACJ,YAAY,EAAE,WAAW;KAC1B,CAAA;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"save-handoff.d.ts","sourceRoot":"","sources":["../../src/tools/save-handoff.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,wBAAsB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"save-handoff.d.ts","sourceRoot":"","sources":["../../src/tools/save-handoff.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,wBAAsB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAyCrF;AAED,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;CAsB7B,CAAA"}
|
|
@@ -3,7 +3,7 @@ import { writeFile, mkdir } from 'node:fs/promises';
|
|
|
3
3
|
import { existsSync } from 'node:fs';
|
|
4
4
|
import { join, resolve } from 'node:path';
|
|
5
5
|
import { homedir } from 'node:os';
|
|
6
|
-
import { loadAIConfig, generateHandoff } from '@agentbrain/core';
|
|
6
|
+
import { loadAIConfig, generateHandoff, getPendingDoomForMCP } from '@agentbrain/core';
|
|
7
7
|
/**
|
|
8
8
|
* Expand path: handles ~, relative paths, etc.
|
|
9
9
|
*/
|
|
@@ -26,22 +26,30 @@ export async function saveHandoff(input) {
|
|
|
26
26
|
goal,
|
|
27
27
|
commitCount: commit_count,
|
|
28
28
|
});
|
|
29
|
+
// Check for doom loop warnings
|
|
30
|
+
const doomWarning = await getPendingDoomForMCP(expandedPath);
|
|
31
|
+
// Append doom warning section if detected
|
|
32
|
+
let finalContent = result.doc.content;
|
|
33
|
+
if (doomWarning && doomWarning.detected) {
|
|
34
|
+
const doomSection = `\n\n## โ Doom Loop Warning\n\nThe following files were modified repeatedly before this handoff. Investigate before continuing:\n${doomWarning.files.map((f) => `- ${f}`).join('\n')}\n`;
|
|
35
|
+
finalContent = result.doc.content + doomSection;
|
|
36
|
+
}
|
|
29
37
|
// Write to disk
|
|
30
38
|
const outputDir = join(expandedPath, 'agentbrain');
|
|
31
39
|
if (!existsSync(outputDir)) {
|
|
32
40
|
await mkdir(outputDir, { recursive: true });
|
|
33
41
|
}
|
|
34
42
|
const filePath = join(outputDir, 'handoff.md');
|
|
35
|
-
await writeFile(filePath,
|
|
43
|
+
await writeFile(filePath, finalContent, 'utf-8');
|
|
36
44
|
return {
|
|
37
|
-
content:
|
|
38
|
-
filePath: 'agentbrain/handoff.md',
|
|
45
|
+
content: finalContent,
|
|
46
|
+
filePath: '.agentbrain/handoff.md',
|
|
39
47
|
tokensUsed: result.tokenCount,
|
|
40
48
|
};
|
|
41
49
|
}
|
|
42
50
|
export const saveHandoffSchema = {
|
|
43
51
|
name: 'save_handoff',
|
|
44
|
-
description: 'Generate and save handoff document from git diff and recent commits. Creates agentbrain/handoff.md with session summary.',
|
|
52
|
+
description: 'Generate and save handoff document from git diff and recent commits. Creates .agentbrain/handoff.md with session summary.',
|
|
45
53
|
inputSchema: {
|
|
46
54
|
type: 'object',
|
|
47
55
|
properties: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"save-handoff.js","sourceRoot":"","sources":["../../src/tools/save-handoff.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"save-handoff.js","sourceRoot":"","sources":["../../src/tools/save-handoff.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAEtF;;GAEG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