@phuetz/code-buddy 0.1.19 → 0.1.22
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 +23 -2
- package/dist/analytics/dashboard.js +1 -1
- package/dist/analytics/dashboard.js.map +1 -1
- package/dist/commands/delegate.js +2 -2
- package/dist/commands/delegate.js.map +1 -1
- package/dist/commands/features.d.ts +1 -1
- package/dist/commands/features.js +1 -1
- package/dist/commands/handlers/core-handlers.js +1 -1
- package/dist/commands/handlers/core-handlers.js.map +1 -1
- package/dist/commands/handlers/missing-handlers.js +15 -14
- package/dist/commands/handlers/missing-handlers.js.map +1 -1
- package/dist/commands/handlers/worktree-handlers.d.ts +1 -1
- package/dist/commands/handlers/worktree-handlers.js +2 -2
- package/dist/commands/slash/builtin-commands.js +1 -1
- package/dist/commands/slash/builtin-commands.js.map +1 -1
- package/dist/config/constants.d.ts +2 -2
- package/dist/config/constants.js +2 -2
- package/dist/config/constants.js.map +1 -1
- package/dist/config/toml-config.js +1 -1
- package/dist/config/toml-config.js.map +1 -1
- package/dist/context/context-files.js +1 -1
- package/dist/features/index.d.ts +1 -1
- package/dist/features/index.js +2 -2
- package/dist/features/index.js.map +1 -1
- package/dist/hooks/hook-system.js +1 -1
- package/dist/hooks/hook-system.js.map +1 -1
- package/dist/hooks/use-input-handler.js +44 -0
- package/dist/hooks/use-input-handler.js.map +1 -1
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -1
- package/dist/integrations/github-actions.js +1 -1
- package/dist/integrations/github-actions.js.map +1 -1
- package/dist/lsp/server.js +3 -3
- package/dist/lsp/server.js.map +1 -1
- package/dist/mcp/mcp-agent-tools.d.ts +20 -0
- package/dist/mcp/mcp-agent-tools.js +142 -0
- package/dist/mcp/mcp-agent-tools.js.map +1 -0
- package/dist/mcp/mcp-memory-tools.d.ts +12 -0
- package/dist/mcp/mcp-memory-tools.js +79 -0
- package/dist/mcp/mcp-memory-tools.js.map +1 -0
- package/dist/mcp/mcp-prompts.d.ts +15 -0
- package/dist/mcp/mcp-prompts.js +170 -0
- package/dist/mcp/mcp-prompts.js.map +1 -0
- package/dist/mcp/mcp-resources.d.ts +14 -0
- package/dist/mcp/mcp-resources.js +183 -0
- package/dist/mcp/mcp-resources.js.map +1 -0
- package/dist/mcp/mcp-server.d.ts +30 -1
- package/dist/mcp/mcp-server.js +181 -1
- package/dist/mcp/mcp-server.js.map +1 -1
- package/dist/mcp/mcp-session-tools.d.ts +15 -0
- package/dist/mcp/mcp-session-tools.js +116 -0
- package/dist/mcp/mcp-session-tools.js.map +1 -0
- package/dist/observability/dashboard.d.ts +1 -1
- package/dist/observability/dashboard.js +2 -2
- package/dist/observability/dashboard.js.map +1 -1
- package/dist/offline/offline-mode.d.ts +1 -1
- package/dist/offline/offline-mode.js +1 -1
- package/dist/plugins/marketplace.d.ts +1 -1
- package/dist/plugins/marketplace.js +1 -1
- package/dist/prompts/index.d.ts +1 -1
- package/dist/prompts/index.js +1 -1
- package/dist/providers/local-llm-provider.d.ts +1 -1
- package/dist/providers/local-llm-provider.js +1 -1
- package/dist/scripting/codebuddy-bindings.js +1 -1
- package/dist/scripting/codebuddy-bindings.js.map +1 -1
- package/dist/security/index.d.ts +1 -1
- package/dist/security/index.js +1 -1
- package/dist/templates/export/html.template.js +2 -2
- package/dist/templates/export/markdown.template.js +1 -1
- package/dist/templates/export/markdown.template.js.map +1 -1
- package/dist/themes/default-themes.d.ts +1 -1
- package/dist/themes/default-themes.js +1 -1
- package/dist/themes/index.d.ts +1 -1
- package/dist/themes/index.js +1 -1
- package/dist/themes/theme-manager.d.ts +1 -1
- package/dist/themes/theme-manager.js +1 -1
- package/dist/themes/theme.d.ts +1 -1
- package/dist/themes/theme.js +1 -1
- package/dist/types/errors.d.ts +1 -1
- package/dist/types/errors.js +1 -1
- package/dist/ui/app.js +1 -1
- package/dist/ui/app.js.map +1 -1
- package/dist/ui/components/HelpSystem.d.ts +1 -1
- package/dist/ui/components/HelpSystem.js +1 -1
- package/dist/ui/context/theme-context.d.ts +1 -1
- package/dist/ui/context/theme-context.js +1 -1
- package/dist/ui/dashboard/dashboard.js +1 -1
- package/dist/ui/dashboard/dashboard.js.map +1 -1
- package/dist/undo/checkpoint-manager.d.ts +1 -1
- package/dist/undo/checkpoint-manager.js +1 -1
- package/dist/utils/codebuddy-home.d.ts +1 -1
- package/dist/utils/codebuddy-home.js +1 -1
- package/dist/utils/conversation-export.js +3 -3
- package/dist/utils/conversation-export.js.map +1 -1
- package/dist/utils/custom-commands.js +1 -1
- package/dist/utils/debug-logger.d.ts +1 -1
- package/dist/utils/debug-logger.js +1 -1
- package/dist/utils/errors.d.ts +2 -2
- package/dist/utils/errors.js +2 -2
- package/dist/utils/export-manager.js +3 -3
- package/dist/utils/export-manager.js.map +1 -1
- package/dist/utils/headless-output.js +1 -1
- package/dist/utils/headless-output.js.map +1 -1
- package/dist/utils/logger.d.ts +1 -1
- package/dist/utils/logger.js +15 -2
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/shell-completions.js +6 -6
- package/dist/utils/terminal-notifications.js +1 -1
- package/dist/utils/terminal-notifications.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Memory Tools - Expose Code Buddy's memory system
|
|
3
|
+
*
|
|
4
|
+
* Tools:
|
|
5
|
+
* - memory_search: Search semantic memory
|
|
6
|
+
* - memory_save: Save a memory entry
|
|
7
|
+
*/
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
/**
|
|
10
|
+
* Register memory tools with the MCP server.
|
|
11
|
+
*/
|
|
12
|
+
export function registerMemoryTools(server) {
|
|
13
|
+
// memory_search - Search semantic memory
|
|
14
|
+
server.tool('memory_search', 'Search Code Buddy\'s semantic memory for relevant stored knowledge, patterns, and context.', {
|
|
15
|
+
query: z.string().describe('The search query to find relevant memories'),
|
|
16
|
+
max_results: z.number().optional().describe('Maximum results to return (default: 5)'),
|
|
17
|
+
}, async (args) => {
|
|
18
|
+
try {
|
|
19
|
+
const { searchAndRetrieve } = await import('../memory/semantic-memory-search.js');
|
|
20
|
+
const results = await searchAndRetrieve(args.query, {
|
|
21
|
+
maxResults: args.max_results ?? 5,
|
|
22
|
+
});
|
|
23
|
+
if (results.length === 0) {
|
|
24
|
+
return {
|
|
25
|
+
content: [{ type: 'text', text: 'No matching memories found.' }],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const formatted = results.map((r, i) => {
|
|
29
|
+
const { result, content } = r;
|
|
30
|
+
return [
|
|
31
|
+
`## Result ${i + 1} (score: ${result.score.toFixed(2)})`,
|
|
32
|
+
`**Source:** ${result.entry.metadata?.source || 'unknown'}`,
|
|
33
|
+
`**Snippet:** ${result.snippet}`,
|
|
34
|
+
content ? `**Content:**\n${content}` : '',
|
|
35
|
+
].filter(Boolean).join('\n');
|
|
36
|
+
}).join('\n\n---\n\n');
|
|
37
|
+
return {
|
|
38
|
+
content: [{ type: 'text', text: formatted }],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
43
|
+
return {
|
|
44
|
+
content: [{ type: 'text', text: `Memory search error: ${message}` }],
|
|
45
|
+
isError: true,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
// memory_save - Save a memory entry
|
|
50
|
+
server.tool('memory_save', 'Save a piece of knowledge to Code Buddy\'s persistent memory for future reference.', {
|
|
51
|
+
key: z.string().describe('A short key/name for the memory entry'),
|
|
52
|
+
value: z.string().describe('The content to remember'),
|
|
53
|
+
category: z.enum(['project', 'preferences', 'decisions', 'patterns', 'context', 'custom']).optional()
|
|
54
|
+
.describe('Memory category (default: context)'),
|
|
55
|
+
scope: z.enum(['project', 'user']).optional()
|
|
56
|
+
.describe('Memory scope: project-specific or user-global (default: project)'),
|
|
57
|
+
}, async (args) => {
|
|
58
|
+
try {
|
|
59
|
+
const { getMemoryManager } = await import('../memory/persistent-memory.js');
|
|
60
|
+
const manager = getMemoryManager();
|
|
61
|
+
await manager.initialize();
|
|
62
|
+
await manager.remember(args.key, args.value, {
|
|
63
|
+
category: args.category,
|
|
64
|
+
scope: args.scope,
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
content: [{ type: 'text', text: `Memory saved: "${args.key}" (${args.scope || 'project'} / ${args.category || 'context'})` }],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
72
|
+
return {
|
|
73
|
+
content: [{ type: 'text', text: `Memory save error: ${message}` }],
|
|
74
|
+
isError: true,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=mcp-memory-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-memory-tools.js","sourceRoot":"","sources":["../../src/mcp/mcp-memory-tools.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAiB;IACnD,yCAAyC;IACzC,MAAM,CAAC,IAAI,CACT,eAAe,EACf,4FAA4F,EAC5F;QACE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4CAA4C,CAAC;QACxE,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,wCAAwC,CAAC;KACtF,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;QACb,IAAI,CAAC;YACH,MAAM,EAAE,iBAAiB,EAAE,GAAG,MAAM,MAAM,CAAC,qCAAqC,CAAC,CAAC;YAClF,MAAM,OAAO,GAAG,MAAM,iBAAiB,CAAC,IAAI,CAAC,KAAK,EAAE;gBAClD,UAAU,EAAE,IAAI,CA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AAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,sBAAsB,OAAO,EAAE,EAAE,CAAC;gBAC3E,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Prompts - Workflow templates for common development tasks
|
|
3
|
+
*
|
|
4
|
+
* Prompts:
|
|
5
|
+
* - code_review: Review code changes
|
|
6
|
+
* - explain_code: Explain file/function
|
|
7
|
+
* - generate_tests: Generate tests
|
|
8
|
+
* - refactor: Refactor with strategy
|
|
9
|
+
* - fix_bugs: Find and fix bugs
|
|
10
|
+
*/
|
|
11
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
12
|
+
/**
|
|
13
|
+
* Register workflow prompt templates with the MCP server.
|
|
14
|
+
*/
|
|
15
|
+
export declare function registerPrompts(server: McpServer): void;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Prompts - Workflow templates for common development tasks
|
|
3
|
+
*
|
|
4
|
+
* Prompts:
|
|
5
|
+
* - code_review: Review code changes
|
|
6
|
+
* - explain_code: Explain file/function
|
|
7
|
+
* - generate_tests: Generate tests
|
|
8
|
+
* - refactor: Refactor with strategy
|
|
9
|
+
* - fix_bugs: Find and fix bugs
|
|
10
|
+
*/
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
/**
|
|
13
|
+
* Register workflow prompt templates with the MCP server.
|
|
14
|
+
*/
|
|
15
|
+
export function registerPrompts(server) {
|
|
16
|
+
// code_review - Review code changes
|
|
17
|
+
server.prompt('code_review', 'Review code changes for bugs, security issues, and best practices', {
|
|
18
|
+
path: z.string().optional().describe('File or directory path to review (defaults to staged changes)'),
|
|
19
|
+
}, (args) => {
|
|
20
|
+
const target = args.path
|
|
21
|
+
? `the file at \`${args.path}\``
|
|
22
|
+
: 'the current staged git changes (run `git diff --staged`)';
|
|
23
|
+
return {
|
|
24
|
+
messages: [{
|
|
25
|
+
role: 'user',
|
|
26
|
+
content: {
|
|
27
|
+
type: 'text',
|
|
28
|
+
text: [
|
|
29
|
+
`Please review ${target}. Focus on:`,
|
|
30
|
+
'',
|
|
31
|
+
'1. **Bugs & Logic Errors** - Incorrect behavior, edge cases, off-by-one errors',
|
|
32
|
+
'2. **Security Issues** - Injection vulnerabilities, secrets exposure, unsafe operations',
|
|
33
|
+
'3. **Performance** - Unnecessary computations, memory leaks, N+1 queries',
|
|
34
|
+
'4. **Code Quality** - Readability, naming, DRY violations, missing error handling',
|
|
35
|
+
'5. **TypeScript** - Type safety, proper use of generics, avoiding `any`',
|
|
36
|
+
'',
|
|
37
|
+
'For each issue found, provide:',
|
|
38
|
+
'- File and line number',
|
|
39
|
+
'- Severity (critical/warning/suggestion)',
|
|
40
|
+
'- Description of the issue',
|
|
41
|
+
'- Suggested fix with code snippet',
|
|
42
|
+
].join('\n'),
|
|
43
|
+
},
|
|
44
|
+
}],
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
// explain_code - Explain file/function
|
|
48
|
+
server.prompt('explain_code', 'Explain how a file or function works in detail', {
|
|
49
|
+
path: z.string().describe('Path to the file to explain'),
|
|
50
|
+
function_name: z.string().optional().describe('Specific function to explain (explains whole file if omitted)'),
|
|
51
|
+
}, (args) => {
|
|
52
|
+
const target = args.function_name
|
|
53
|
+
? `the function \`${args.function_name}\` in \`${args.path}\``
|
|
54
|
+
: `the file \`${args.path}\``;
|
|
55
|
+
return {
|
|
56
|
+
messages: [{
|
|
57
|
+
role: 'user',
|
|
58
|
+
content: {
|
|
59
|
+
type: 'text',
|
|
60
|
+
text: [
|
|
61
|
+
`Please explain ${target}. Include:`,
|
|
62
|
+
'',
|
|
63
|
+
'1. **Purpose** - What it does and why it exists',
|
|
64
|
+
'2. **How It Works** - Step-by-step walkthrough of the logic',
|
|
65
|
+
'3. **Dependencies** - What it imports/uses and why',
|
|
66
|
+
'4. **Data Flow** - Input → processing → output',
|
|
67
|
+
'5. **Key Patterns** - Design patterns, idioms, or conventions used',
|
|
68
|
+
'6. **Edge Cases** - Important boundary conditions handled',
|
|
69
|
+
'',
|
|
70
|
+
'Use code snippets from the file to illustrate key points.',
|
|
71
|
+
].join('\n'),
|
|
72
|
+
},
|
|
73
|
+
}],
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
// generate_tests - Generate tests
|
|
77
|
+
server.prompt('generate_tests', 'Generate comprehensive tests for a file or module', {
|
|
78
|
+
path: z.string().describe('Path to the file to generate tests for'),
|
|
79
|
+
framework: z.string().optional().describe('Test framework to use (default: jest)'),
|
|
80
|
+
}, (args) => {
|
|
81
|
+
const framework = args.framework || 'jest';
|
|
82
|
+
return {
|
|
83
|
+
messages: [{
|
|
84
|
+
role: 'user',
|
|
85
|
+
content: {
|
|
86
|
+
type: 'text',
|
|
87
|
+
text: [
|
|
88
|
+
`Generate comprehensive tests for \`${args.path}\` using ${framework}. Include:`,
|
|
89
|
+
'',
|
|
90
|
+
'1. **Unit tests** for each exported function/method',
|
|
91
|
+
'2. **Happy path** tests with typical inputs',
|
|
92
|
+
'3. **Error cases** - invalid inputs, edge cases, boundary conditions',
|
|
93
|
+
'4. **Mock setup** for external dependencies (API calls, file system, etc.)',
|
|
94
|
+
'5. **Integration tests** if the module interacts with other components',
|
|
95
|
+
'',
|
|
96
|
+
'Follow these conventions:',
|
|
97
|
+
'- Use descriptive test names: `it(\'should return error when file not found\')`',
|
|
98
|
+
'- Group related tests with `describe` blocks',
|
|
99
|
+
'- Use `beforeEach`/`afterEach` for setup/cleanup',
|
|
100
|
+
`- Place the test file in the \`tests/\` directory`,
|
|
101
|
+
'- Match the existing test patterns in the project',
|
|
102
|
+
].join('\n'),
|
|
103
|
+
},
|
|
104
|
+
}],
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
// refactor - Refactor with strategy
|
|
108
|
+
server.prompt('refactor', 'Refactor code using a specific strategy', {
|
|
109
|
+
path: z.string().describe('Path to the file to refactor'),
|
|
110
|
+
strategy: z.string().describe('Refactoring strategy (e.g., extract-function, simplify, split-module, dry, rename)'),
|
|
111
|
+
}, (args) => {
|
|
112
|
+
return {
|
|
113
|
+
messages: [{
|
|
114
|
+
role: 'user',
|
|
115
|
+
content: {
|
|
116
|
+
type: 'text',
|
|
117
|
+
text: [
|
|
118
|
+
`Refactor \`${args.path}\` using the **${args.strategy}** strategy.`,
|
|
119
|
+
'',
|
|
120
|
+
'Guidelines:',
|
|
121
|
+
'1. **Read the file first** to understand current structure',
|
|
122
|
+
'2. **Explain what you plan to change** and why before making edits',
|
|
123
|
+
'3. **Preserve behavior** - refactoring should not change functionality',
|
|
124
|
+
'4. **Keep changes minimal** - only refactor what the strategy calls for',
|
|
125
|
+
'5. **Update imports** if moving or renaming things',
|
|
126
|
+
'6. **Run existing tests** after refactoring to verify nothing broke',
|
|
127
|
+
'',
|
|
128
|
+
'Common strategies:',
|
|
129
|
+
'- `extract-function`: Pull complex logic into named functions',
|
|
130
|
+
'- `simplify`: Reduce complexity, flatten nesting, simplify conditionals',
|
|
131
|
+
'- `split-module`: Break large file into focused modules',
|
|
132
|
+
'- `dry`: Eliminate duplication',
|
|
133
|
+
'- `rename`: Improve naming for clarity',
|
|
134
|
+
].join('\n'),
|
|
135
|
+
},
|
|
136
|
+
}],
|
|
137
|
+
};
|
|
138
|
+
});
|
|
139
|
+
// fix_bugs - Find and fix bugs
|
|
140
|
+
server.prompt('fix_bugs', 'Find and fix bugs in a file', {
|
|
141
|
+
path: z.string().describe('Path to the file to fix'),
|
|
142
|
+
description: z.string().optional().describe('Description of the bug or symptoms'),
|
|
143
|
+
}, (args) => {
|
|
144
|
+
const bugDesc = args.description
|
|
145
|
+
? `\n\n**Reported issue:** ${args.description}`
|
|
146
|
+
: '';
|
|
147
|
+
return {
|
|
148
|
+
messages: [{
|
|
149
|
+
role: 'user',
|
|
150
|
+
content: {
|
|
151
|
+
type: 'text',
|
|
152
|
+
text: [
|
|
153
|
+
`Find and fix bugs in \`${args.path}\`.${bugDesc}`,
|
|
154
|
+
'',
|
|
155
|
+
'Steps:',
|
|
156
|
+
'1. **Read the file** and understand its purpose',
|
|
157
|
+
'2. **Identify bugs** - logic errors, type issues, edge cases, race conditions',
|
|
158
|
+
'3. **For each bug found:**',
|
|
159
|
+
' - Explain what\'s wrong and how it manifests',
|
|
160
|
+
' - Show the fix with a code edit',
|
|
161
|
+
' - Explain why the fix works',
|
|
162
|
+
'4. **Run tests** to verify the fixes',
|
|
163
|
+
'5. **Check for related issues** that might have the same root cause',
|
|
164
|
+
].join('\n'),
|
|
165
|
+
},
|
|
166
|
+
}],
|
|
167
|
+
};
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=mcp-prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-prompts.js","sourceRoot":"","sources":["../../src/mcp/mcp-prompts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,MAAiB;IAC/C,oCAAoC;IACpC,MAAM,CAAC,MAAM,CACX,aAAa,EACb,mEAAmE,EACnE;QACE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,+DAA+D,CAAC;KACtG,EACD,CAAC,IAAI,EAAE,EAAE;QACP,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI;YACtB,CAAC,CAAC,iBAAiB,IAAI,CAAC,IAAI,IAAI;YAChC,CAAC,CAAC,0DAA0D,CAAC;QAE/D,OAAO;YACL,QAAQ,EAAE,CAAC;oBACT,I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
|
+
* Resources (codebuddy:// URI scheme):
|
|
5
|
+
* - codebuddy://project/context - Project context files + git status
|
|
6
|
+
* - codebuddy://project/instructions - CODEBUDDY.md / CLAUDE.md custom instructions
|
|
7
|
+
* - codebuddy://sessions/latest - Latest session data as JSON
|
|
8
|
+
* - codebuddy://memory/all - All stored memories formatted as markdown
|
|
9
|
+
*/
|
|
10
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
11
|
+
/**
|
|
12
|
+
* Register read-only resources with the MCP server.
|
|
13
|
+
*/
|
|
14
|
+
export declare function registerResources(server: McpServer): void;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Resources - Read-only project context exposed via URI scheme
|
|
3
|
+
*
|
|
4
|
+
* Resources (codebuddy:// URI scheme):
|
|
5
|
+
* - codebuddy://project/context - Project context files + git status
|
|
6
|
+
* - codebuddy://project/instructions - CODEBUDDY.md / CLAUDE.md custom instructions
|
|
7
|
+
* - codebuddy://sessions/latest - Latest session data as JSON
|
|
8
|
+
* - codebuddy://memory/all - All stored memories formatted as markdown
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Register read-only resources with the MCP server.
|
|
12
|
+
*/
|
|
13
|
+
export function registerResources(server) {
|
|
14
|
+
// codebuddy://project/context
|
|
15
|
+
server.resource('project_context', 'codebuddy://project/context', {
|
|
16
|
+
description: 'Project context files (CODEBUDDY.md, .codebuddy/config, etc.) and git status',
|
|
17
|
+
mimeType: 'text/markdown',
|
|
18
|
+
}, async () => {
|
|
19
|
+
try {
|
|
20
|
+
const { loadContext, formatContextForPrompt } = await import('../context/context-files.js');
|
|
21
|
+
const context = await loadContext(process.cwd());
|
|
22
|
+
let text = formatContextForPrompt(context);
|
|
23
|
+
// Append git status
|
|
24
|
+
try {
|
|
25
|
+
const { execSync } = await import('child_process');
|
|
26
|
+
const gitStatus = execSync('git status --short 2>/dev/null', { encoding: 'utf-8', timeout: 5000 });
|
|
27
|
+
if (gitStatus.trim()) {
|
|
28
|
+
text += `\n\n## Git Status\n\`\`\`\n${gitStatus.trim()}\n\`\`\``;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// Not a git repo or git not available
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
contents: [{
|
|
36
|
+
uri: 'codebuddy://project/context',
|
|
37
|
+
mimeType: 'text/markdown',
|
|
38
|
+
text,
|
|
39
|
+
}],
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
44
|
+
return {
|
|
45
|
+
contents: [{
|
|
46
|
+
uri: 'codebuddy://project/context',
|
|
47
|
+
mimeType: 'text/plain',
|
|
48
|
+
text: `Error loading project context: ${message}`,
|
|
49
|
+
}],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
// codebuddy://project/instructions
|
|
54
|
+
server.resource('project_instructions', 'codebuddy://project/instructions', {
|
|
55
|
+
description: 'Custom project instructions from CODEBUDDY.md, CLAUDE.md, or .codebuddy/instructions',
|
|
56
|
+
mimeType: 'text/markdown',
|
|
57
|
+
}, async () => {
|
|
58
|
+
try {
|
|
59
|
+
const fs = await import('fs');
|
|
60
|
+
const path = await import('path');
|
|
61
|
+
const cwd = process.cwd();
|
|
62
|
+
const instructionFiles = [
|
|
63
|
+
'CODEBUDDY.md',
|
|
64
|
+
'CLAUDE.md',
|
|
65
|
+
'.codebuddy/instructions.md',
|
|
66
|
+
'.github/copilot-instructions.md',
|
|
67
|
+
];
|
|
68
|
+
const parts = [];
|
|
69
|
+
for (const file of instructionFiles) {
|
|
70
|
+
const fullPath = path.join(cwd, file);
|
|
71
|
+
try {
|
|
72
|
+
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
73
|
+
parts.push(`## ${file}\n\n${content}`);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
// File doesn't exist, skip
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const text = parts.length > 0
|
|
80
|
+
? parts.join('\n\n---\n\n')
|
|
81
|
+
: 'No custom instruction files found in this project.';
|
|
82
|
+
return {
|
|
83
|
+
contents: [{
|
|
84
|
+
uri: 'codebuddy://project/instructions',
|
|
85
|
+
mimeType: 'text/markdown',
|
|
86
|
+
text,
|
|
87
|
+
}],
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
92
|
+
return {
|
|
93
|
+
contents: [{
|
|
94
|
+
uri: 'codebuddy://project/instructions',
|
|
95
|
+
mimeType: 'text/plain',
|
|
96
|
+
text: `Error loading instructions: ${message}`,
|
|
97
|
+
}],
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
// codebuddy://sessions/latest
|
|
102
|
+
server.resource('sessions_latest', 'codebuddy://sessions/latest', {
|
|
103
|
+
description: 'Latest Code Buddy session data including messages and metadata',
|
|
104
|
+
mimeType: 'application/json',
|
|
105
|
+
}, async () => {
|
|
106
|
+
try {
|
|
107
|
+
const { getSessionStore } = await import('../persistence/session-store.js');
|
|
108
|
+
const store = getSessionStore();
|
|
109
|
+
const sessions = await store.getRecentSessions(1);
|
|
110
|
+
if (sessions.length === 0) {
|
|
111
|
+
return {
|
|
112
|
+
contents: [{
|
|
113
|
+
uri: 'codebuddy://sessions/latest',
|
|
114
|
+
mimeType: 'application/json',
|
|
115
|
+
text: JSON.stringify({ message: 'No sessions found' }),
|
|
116
|
+
}],
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
const session = sessions[0];
|
|
120
|
+
const data = {
|
|
121
|
+
id: session.id,
|
|
122
|
+
name: session.name,
|
|
123
|
+
model: session.model,
|
|
124
|
+
workingDirectory: session.workingDirectory,
|
|
125
|
+
messageCount: session.messages?.length ?? 0,
|
|
126
|
+
createdAt: session.createdAt,
|
|
127
|
+
lastAccessedAt: session.lastAccessedAt,
|
|
128
|
+
recentMessages: (session.messages || []).slice(-10).map(m => ({
|
|
129
|
+
type: m.type,
|
|
130
|
+
content: m.content.length > 500 ? m.content.slice(0, 500) + '...' : m.content,
|
|
131
|
+
timestamp: m.timestamp,
|
|
132
|
+
})),
|
|
133
|
+
};
|
|
134
|
+
return {
|
|
135
|
+
contents: [{
|
|
136
|
+
uri: 'codebuddy://sessions/latest',
|
|
137
|
+
mimeType: 'application/json',
|
|
138
|
+
text: JSON.stringify(data, null, 2),
|
|
139
|
+
}],
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
144
|
+
return {
|
|
145
|
+
contents: [{
|
|
146
|
+
uri: 'codebuddy://sessions/latest',
|
|
147
|
+
mimeType: 'application/json',
|
|
148
|
+
text: JSON.stringify({ error: message }),
|
|
149
|
+
}],
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
// codebuddy://memory/all
|
|
154
|
+
server.resource('memory_all', 'codebuddy://memory/all', {
|
|
155
|
+
description: 'All stored Code Buddy memories formatted as markdown',
|
|
156
|
+
mimeType: 'text/markdown',
|
|
157
|
+
}, async () => {
|
|
158
|
+
try {
|
|
159
|
+
const { getMemoryManager } = await import('../memory/persistent-memory.js');
|
|
160
|
+
const manager = getMemoryManager();
|
|
161
|
+
await manager.initialize();
|
|
162
|
+
const text = manager.formatMemories() || 'No memories stored.';
|
|
163
|
+
return {
|
|
164
|
+
contents: [{
|
|
165
|
+
uri: 'codebuddy://memory/all',
|
|
166
|
+
mimeType: 'text/markdown',
|
|
167
|
+
text,
|
|
168
|
+
}],
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
173
|
+
return {
|
|
174
|
+
contents: [{
|
|
175
|
+
uri: 'codebuddy://memory/all',
|
|
176
|
+
mimeType: 'text/plain',
|
|
177
|
+
text: `Error loading memories: ${message}`,
|
|
178
|
+
}],
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=mcp-resources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-resources.js","sourceRoot":"","sources":["../../src/mcp/mcp-resources.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAiB;IACjD,8BAA8B;IAC9B,MAAM,CAAC,QAAQ,CACb,iBAAiB,EACjB,6BAA6B,EAC7B;QACE,WAAW,EAAE,8EAA8E;QAC3F,QAAQ,EAAE,eAAe;KAC1B,EACD,KAAK,IAAI,EAAE;QACT,IAAI,CAAC;YACH,MAAM,EAAE,WAAW,EAAE,sBAAsB,EAAE,GAAG,MAAM,MAAM,CAAC,6BAA6B,CAAC,CAAC;YAC5F,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;YACjD,IAAI,IAAI,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC;YAE3C,oBAAoB;YACpB,IAAI,CAAC;gBACH,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC;gBACnD,MAAM,SAAS,GAAG,QAAQ,CAAC,gCAAgC,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;gBACnG,IAAI,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC;oBACrB,IAAI,IAAI,8BAA8B,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC;gBACnE,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,sCAAsC;YACxC,CAAC;YAED,OAAO;gBACL,QAAQ,EAAE,CAAC;wBACT,GAAG,EAAE,6BAA6B;wBAClC,QAAQ,EAAE,eAAe;wBACz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|
5
5
|
* (VS Code, Cursor, Claude Desktop, etc.) over stdio transport.
|
|
6
6
|
*
|
|
7
|
-
* Exposed tools:
|
|
7
|
+
* Exposed tools (15 total):
|
|
8
8
|
* - read_file: Read file contents
|
|
9
9
|
* - write_file: Write/create a file
|
|
10
10
|
* - edit_file: String replacement editing
|
|
@@ -12,6 +12,23 @@
|
|
|
12
12
|
* - search_files: Search file contents (ripgrep-based)
|
|
13
13
|
* - list_files: List directory contents
|
|
14
14
|
* - git: Git operations (status, diff, log, add, commit, etc.)
|
|
15
|
+
* - agent_chat: AI-powered chat with tool execution
|
|
16
|
+
* - agent_task: Autonomous task execution
|
|
17
|
+
* - agent_plan: Create execution plan
|
|
18
|
+
* - memory_search: Search semantic memory
|
|
19
|
+
* - memory_save: Save persistent memory
|
|
20
|
+
* - session_list: List recent sessions
|
|
21
|
+
* - session_resume: Resume previous session
|
|
22
|
+
* - web_search: Web search via configured providers
|
|
23
|
+
*
|
|
24
|
+
* Resources (4):
|
|
25
|
+
* - codebuddy://project/context
|
|
26
|
+
* - codebuddy://project/instructions
|
|
27
|
+
* - codebuddy://sessions/latest
|
|
28
|
+
* - codebuddy://memory/all
|
|
29
|
+
*
|
|
30
|
+
* Prompts (5):
|
|
31
|
+
* - code_review, explain_code, generate_tests, refactor, fix_bugs
|
|
15
32
|
*/
|
|
16
33
|
/**
|
|
17
34
|
* Tool definition metadata for listing purposes.
|
|
@@ -37,7 +54,19 @@ export declare class CodeBuddyMCPServer {
|
|
|
37
54
|
private searchTool;
|
|
38
55
|
private gitTool;
|
|
39
56
|
private bashTool;
|
|
57
|
+
private agent;
|
|
58
|
+
private agentInitPromise;
|
|
40
59
|
constructor();
|
|
60
|
+
/**
|
|
61
|
+
* Lazily initialize the CodeBuddyAgent on first use.
|
|
62
|
+
*/
|
|
63
|
+
private ensureAgent;
|
|
64
|
+
/**
|
|
65
|
+
* Register agent intelligence tools, resources, and prompts.
|
|
66
|
+
* Registration modules are lightweight (just Zod schemas + handler stubs).
|
|
67
|
+
* Heavy dependencies (agent, memory, sessions) are lazy-loaded inside handlers.
|
|
68
|
+
*/
|
|
69
|
+
private registerAgentLayer;
|
|
41
70
|
/**
|
|
42
71
|
* Get the list of tools exposed by this MCP server.
|
|
43
72
|
*/
|