ted-mosby 1.0.0
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/LICENSE +21 -0
- package/README.md +238 -0
- package/dist/agent.d.ts +37 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +247 -0
- package/dist/agent.js.map +1 -0
- package/dist/claude-config.d.ts +58 -0
- package/dist/claude-config.d.ts.map +1 -0
- package/dist/claude-config.js +169 -0
- package/dist/claude-config.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +1379 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +42 -0
- package/dist/config.js.map +1 -0
- package/dist/mcp-config.d.ts +45 -0
- package/dist/mcp-config.d.ts.map +1 -0
- package/dist/mcp-config.js +111 -0
- package/dist/mcp-config.js.map +1 -0
- package/dist/permissions.d.ts +32 -0
- package/dist/permissions.d.ts.map +1 -0
- package/dist/permissions.js +165 -0
- package/dist/permissions.js.map +1 -0
- package/dist/planner.d.ts +42 -0
- package/dist/planner.d.ts.map +1 -0
- package/dist/planner.js +232 -0
- package/dist/planner.js.map +1 -0
- package/dist/prompts/wiki-system.d.ts +8 -0
- package/dist/prompts/wiki-system.d.ts.map +1 -0
- package/dist/prompts/wiki-system.js +249 -0
- package/dist/prompts/wiki-system.js.map +1 -0
- package/dist/rag/index.d.ts +84 -0
- package/dist/rag/index.d.ts.map +1 -0
- package/dist/rag/index.js +446 -0
- package/dist/rag/index.js.map +1 -0
- package/dist/tools/command-runner.d.ts +21 -0
- package/dist/tools/command-runner.d.ts.map +1 -0
- package/dist/tools/command-runner.js +67 -0
- package/dist/tools/command-runner.js.map +1 -0
- package/dist/tools/file-operations.d.ts +22 -0
- package/dist/tools/file-operations.d.ts.map +1 -0
- package/dist/tools/file-operations.js +119 -0
- package/dist/tools/file-operations.js.map +1 -0
- package/dist/tools/web-tools.d.ts +17 -0
- package/dist/tools/web-tools.d.ts.map +1 -0
- package/dist/tools/web-tools.js +122 -0
- package/dist/tools/web-tools.js.map +1 -0
- package/dist/wiki-agent.d.ts +81 -0
- package/dist/wiki-agent.d.ts.map +1 -0
- package/dist/wiki-agent.js +552 -0
- package/dist/wiki-agent.js.map +1 -0
- package/dist/workflows.d.ts +53 -0
- package/dist/workflows.d.ts.map +1 -0
- package/dist/workflows.js +169 -0
- package/dist/workflows.js.map +1 -0
- package/package.json +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Dakota Kim
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
# Ted Mosby
|
|
2
|
+
|
|
3
|
+
> "Kids, I'm going to tell you an incredible story... the story of your codebase architecture."
|
|
4
|
+
|
|
5
|
+
An AI-powered CLI tool that generates comprehensive architectural documentation wikis for code repositories with source code traceability.
|
|
6
|
+
|
|
7
|
+
**Built with [buildanagentworkshop.com](https://buildanagentworkshop.com)**
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## What is Ted Mosby?
|
|
12
|
+
|
|
13
|
+
Ted Mosby is an AI agent that reads your codebase and automatically generates professional architectural documentation. Unlike generic documentation tools, every concept in the generated wiki links directly to the source code (`file:line` references), making it easy to navigate from documentation to implementation.
|
|
14
|
+
|
|
15
|
+
### Generated Documentation Includes:
|
|
16
|
+
|
|
17
|
+
- **Architecture Overview** - High-level system design with Mermaid diagrams
|
|
18
|
+
- **Module Documentation** - Per-component breakdowns with source traceability
|
|
19
|
+
- **Data Flow Documentation** - How data moves through your system
|
|
20
|
+
- **Getting Started Guides** - Onboarding documentation for new developers
|
|
21
|
+
- **Glossary** - Key concepts and terminology
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install -g ted-mosby
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Prerequisites
|
|
32
|
+
|
|
33
|
+
- **Node.js** >= 18.0.0
|
|
34
|
+
- **Anthropic API key** - Get one at [console.anthropic.com](https://console.anthropic.com)
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Quick Start
|
|
39
|
+
|
|
40
|
+
### 1. Set your API key
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
export ANTHROPIC_API_KEY=your-api-key-here
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Or create a `.env` file in your project:
|
|
47
|
+
```bash
|
|
48
|
+
echo "ANTHROPIC_API_KEY=your-api-key-here" > .env
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 2. Generate documentation
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# For a local project
|
|
55
|
+
ted-mosby generate -r ./my-project
|
|
56
|
+
|
|
57
|
+
# For a GitHub repository
|
|
58
|
+
ted-mosby generate -r https://github.com/user/repo
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 3. View the results
|
|
62
|
+
|
|
63
|
+
Open the generated `wiki/README.md` to explore your architectural documentation.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Usage
|
|
68
|
+
|
|
69
|
+
### Basic Commands
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Generate wiki for current directory
|
|
73
|
+
ted-mosby generate -r .
|
|
74
|
+
|
|
75
|
+
# Generate wiki for a specific directory
|
|
76
|
+
ted-mosby generate -r /path/to/project
|
|
77
|
+
|
|
78
|
+
# Generate wiki from a GitHub URL
|
|
79
|
+
ted-mosby generate -r https://github.com/user/repo
|
|
80
|
+
|
|
81
|
+
# Specify output directory
|
|
82
|
+
ted-mosby generate -r ./my-project -o ./docs/architecture
|
|
83
|
+
|
|
84
|
+
# Focus on a specific subdirectory
|
|
85
|
+
ted-mosby generate -r ./my-project -p src/core
|
|
86
|
+
|
|
87
|
+
# Verbose output (see what the agent is doing)
|
|
88
|
+
ted-mosby generate -r ./my-project -v
|
|
89
|
+
|
|
90
|
+
# Estimate time/cost before running (dry run)
|
|
91
|
+
ted-mosby generate -r ./my-project -e
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### All Options
|
|
95
|
+
|
|
96
|
+
| Option | Description | Default |
|
|
97
|
+
|--------|-------------|---------|
|
|
98
|
+
| `-r, --repo <path/url>` | Repository path or GitHub URL (required) | - |
|
|
99
|
+
| `-o, --output <dir>` | Output directory for wiki | `./wiki` |
|
|
100
|
+
| `-c, --config <file>` | Path to wiki.json config file | - |
|
|
101
|
+
| `-t, --token <token>` | GitHub token for private repos | - |
|
|
102
|
+
| `-m, --model <model>` | Claude model to use | `claude-sonnet-4-20250514` |
|
|
103
|
+
| `-p, --path <path>` | Focus on specific directory | - |
|
|
104
|
+
| `-f, --force` | Force regeneration (ignore cache) | - |
|
|
105
|
+
| `-v, --verbose` | Show detailed progress | - |
|
|
106
|
+
| `-e, --estimate` | Estimate time/cost (dry run) | - |
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## What to Expect
|
|
111
|
+
|
|
112
|
+
When you run Ted Mosby:
|
|
113
|
+
|
|
114
|
+
1. **Repository Analysis** - The agent scans your codebase structure
|
|
115
|
+
2. **Semantic Indexing** - Creates embeddings for intelligent code search
|
|
116
|
+
3. **Architecture Discovery** - Identifies patterns, components, and relationships
|
|
117
|
+
4. **Documentation Generation** - Writes markdown pages with diagrams
|
|
118
|
+
5. **Source Linking** - Every concept links to specific file:line references
|
|
119
|
+
|
|
120
|
+
### Typical Runtime
|
|
121
|
+
|
|
122
|
+
| Codebase Size | Approximate Time |
|
|
123
|
+
|---------------|------------------|
|
|
124
|
+
| Small (<50 files) | 1-2 minutes |
|
|
125
|
+
| Medium (50-200 files) | 2-5 minutes |
|
|
126
|
+
| Large (200+ files) | 5-10 minutes |
|
|
127
|
+
|
|
128
|
+
Use `--estimate` to get a cost/time estimate before running.
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Example Output
|
|
133
|
+
|
|
134
|
+
The generated wiki structure:
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
wiki/
|
|
138
|
+
├── README.md # Navigation entry point
|
|
139
|
+
├── architecture/
|
|
140
|
+
│ ├── overview.md # System architecture + diagrams
|
|
141
|
+
│ └── data-flow.md # Data flow documentation
|
|
142
|
+
├── components/
|
|
143
|
+
│ └── {module}/
|
|
144
|
+
│ └── index.md # Per-module documentation
|
|
145
|
+
├── guides/
|
|
146
|
+
│ └── getting-started.md # Quick start guide
|
|
147
|
+
└── glossary.md # Concept index
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Source Traceability Example
|
|
151
|
+
|
|
152
|
+
Every architectural concept includes clickable source references:
|
|
153
|
+
|
|
154
|
+
```markdown
|
|
155
|
+
## Authentication Flow
|
|
156
|
+
|
|
157
|
+
The authentication system uses JWT tokens for stateless auth.
|
|
158
|
+
|
|
159
|
+
**Source:** [`src/auth/jwt-provider.ts:23-67`](../../../src/auth/jwt-provider.ts#L23-L67)
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
export class JwtProvider {
|
|
163
|
+
async generateToken(user: User): Promise<string> {
|
|
164
|
+
// Token generation logic...
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Configuration (Optional)
|
|
173
|
+
|
|
174
|
+
Create a `wiki.json` file in your project root to customize generation:
|
|
175
|
+
|
|
176
|
+
```json
|
|
177
|
+
{
|
|
178
|
+
"repo_notes": [
|
|
179
|
+
{ "content": "Focus on the src/core directory for main logic" }
|
|
180
|
+
],
|
|
181
|
+
"pages": [
|
|
182
|
+
{ "title": "Architecture Overview", "purpose": "High-level design", "parent": null },
|
|
183
|
+
{ "title": "Authentication", "parent": "Architecture Overview" }
|
|
184
|
+
],
|
|
185
|
+
"exclude_patterns": ["**/*.test.ts", "**/__mocks__/**"],
|
|
186
|
+
"output": {
|
|
187
|
+
"format": "markdown",
|
|
188
|
+
"diagrams": true
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## How It Works
|
|
196
|
+
|
|
197
|
+
Ted Mosby is built with:
|
|
198
|
+
|
|
199
|
+
- **[Claude Agent SDK](https://github.com/anthropics/claude-agent-sdk)** - Orchestrates the AI agent workflow
|
|
200
|
+
- **RAG (Retrieval Augmented Generation)** - Semantic code search using embeddings
|
|
201
|
+
- **[Model Context Protocol (MCP)](https://modelcontextprotocol.io)** - Tool integration for file operations
|
|
202
|
+
- **Mermaid** - Architecture diagram generation
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Development
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
# Clone the repo
|
|
210
|
+
git clone https://github.com/your-username/ted-mosby.git
|
|
211
|
+
cd ted-mosby
|
|
212
|
+
|
|
213
|
+
# Install dependencies
|
|
214
|
+
npm install
|
|
215
|
+
|
|
216
|
+
# Build
|
|
217
|
+
npm run build
|
|
218
|
+
|
|
219
|
+
# Run locally
|
|
220
|
+
npm start -- generate -r ./my-project
|
|
221
|
+
|
|
222
|
+
# Watch mode for development
|
|
223
|
+
npm run dev
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## Built With
|
|
229
|
+
|
|
230
|
+
This project was created using the [Claude Agent SDK](https://github.com/anthropics/claude-agent-sdk) at the **Build an Agent Workshop**.
|
|
231
|
+
|
|
232
|
+
**Learn to build your own AI agents at [buildanagentworkshop.com](https://buildanagentworkshop.com)**
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## License
|
|
237
|
+
|
|
238
|
+
MIT
|
package/dist/agent.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { PermissionManager, type PermissionPolicy } from './permissions.js';
|
|
2
|
+
import { type ClaudeConfig } from './claude-config.js';
|
|
3
|
+
export interface DevelopmentAgentAgentConfig {
|
|
4
|
+
verbose?: boolean;
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
permissionManager?: PermissionManager;
|
|
7
|
+
permissions?: PermissionPolicy;
|
|
8
|
+
auditPath?: string;
|
|
9
|
+
workingDir?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class DevelopmentAgentAgent {
|
|
12
|
+
private config;
|
|
13
|
+
private permissionManager;
|
|
14
|
+
private fileOps;
|
|
15
|
+
private commandRunner;
|
|
16
|
+
private customServer;
|
|
17
|
+
private mcpConfigManager;
|
|
18
|
+
private claudeConfig;
|
|
19
|
+
private sessionId?;
|
|
20
|
+
constructor(config?: DevelopmentAgentAgentConfig);
|
|
21
|
+
/**
|
|
22
|
+
* Get loaded Claude Code configuration
|
|
23
|
+
*/
|
|
24
|
+
getClaudeConfig(): ClaudeConfig;
|
|
25
|
+
private loadExternalMcpServers;
|
|
26
|
+
query(userQuery: string, history?: Array<{
|
|
27
|
+
role: string;
|
|
28
|
+
content: string;
|
|
29
|
+
}>): AsyncGenerator<import("@anthropic-ai/claude-agent-sdk").SDKMessage, void, unknown>;
|
|
30
|
+
private createToolServer;
|
|
31
|
+
private buildSystemPrompt;
|
|
32
|
+
readFile(filePath: string): Promise<string>;
|
|
33
|
+
writeFile(filePath: string, content: string): Promise<void>;
|
|
34
|
+
findFiles(pattern: string): Promise<string[]>;
|
|
35
|
+
runCommand(command: string): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE5E,OAAO,EAA2C,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEhG,MAAM,WAAW,2BAA2B;IAC1C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,qBAAqB;IAChC,OAAO,CAAC,MAAM,CAA8B;IAC5C,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,YAAY,CAAwC;IAC5D,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,SAAS,CAAC,CAAS;gBAEf,MAAM,GAAE,2BAAgC;IAyBpD;;OAEG;IACH,eAAe,IAAI,YAAY;YAIjB,sBAAsB;IA4C7B,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,KAAK,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAC,CAAM;IAuDpF,OAAO,CAAC,gBAAgB;IAyFxB,OAAO,CAAC,iBAAiB;IAuDnB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI3C,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3D,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAK7C,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAIjD"}
|
package/dist/agent.js
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { query, tool, createSdkMcpServer } from '@anthropic-ai/claude-agent-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { FileOperations } from './tools/file-operations.js';
|
|
4
|
+
import { CommandRunner } from './tools/command-runner.js';
|
|
5
|
+
import { PermissionManager } from './permissions.js';
|
|
6
|
+
import { MCPConfigManager } from './mcp-config.js';
|
|
7
|
+
import { loadClaudeConfig, formatSkillsForPrompt } from './claude-config.js';
|
|
8
|
+
export class DevelopmentAgentAgent {
|
|
9
|
+
config;
|
|
10
|
+
permissionManager;
|
|
11
|
+
fileOps;
|
|
12
|
+
commandRunner;
|
|
13
|
+
customServer;
|
|
14
|
+
mcpConfigManager;
|
|
15
|
+
claudeConfig;
|
|
16
|
+
sessionId;
|
|
17
|
+
constructor(config = {}) {
|
|
18
|
+
this.config = config;
|
|
19
|
+
if (config.apiKey) {
|
|
20
|
+
process.env.ANTHROPIC_API_KEY = config.apiKey;
|
|
21
|
+
}
|
|
22
|
+
if (!process.env.ANTHROPIC_API_KEY) {
|
|
23
|
+
throw new Error('Anthropic API key is required. Set it via config.apiKey or ANTHROPIC_API_KEY environment variable.');
|
|
24
|
+
}
|
|
25
|
+
this.permissionManager = config.permissionManager || new PermissionManager({ policy: config.permissions, auditPath: config.auditPath });
|
|
26
|
+
this.fileOps = new FileOperations(this.permissionManager);
|
|
27
|
+
this.commandRunner = new CommandRunner(this.permissionManager);
|
|
28
|
+
// Create SDK MCP server with custom tools
|
|
29
|
+
this.customServer = this.createToolServer();
|
|
30
|
+
// Initialize MCP config manager
|
|
31
|
+
this.mcpConfigManager = new MCPConfigManager();
|
|
32
|
+
// Load Claude Code configuration (CLAUDE.md, skills, commands)
|
|
33
|
+
this.claudeConfig = loadClaudeConfig(config.workingDir || process.cwd());
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get loaded Claude Code configuration
|
|
37
|
+
*/
|
|
38
|
+
getClaudeConfig() {
|
|
39
|
+
return this.claudeConfig;
|
|
40
|
+
}
|
|
41
|
+
async loadExternalMcpServers() {
|
|
42
|
+
await this.mcpConfigManager.load();
|
|
43
|
+
const servers = {};
|
|
44
|
+
for (const [name, config] of Object.entries(this.mcpConfigManager.getEnabledServers())) {
|
|
45
|
+
const resolved = this.mcpConfigManager.resolveEnvVariables(config);
|
|
46
|
+
switch (resolved.type) {
|
|
47
|
+
case 'stdio':
|
|
48
|
+
servers[name] = {
|
|
49
|
+
command: resolved.command,
|
|
50
|
+
args: resolved.args || [],
|
|
51
|
+
env: resolved.env || {}
|
|
52
|
+
};
|
|
53
|
+
break;
|
|
54
|
+
case 'sse':
|
|
55
|
+
servers[name] = {
|
|
56
|
+
type: 'sse',
|
|
57
|
+
url: resolved.url,
|
|
58
|
+
headers: resolved.headers || {}
|
|
59
|
+
};
|
|
60
|
+
break;
|
|
61
|
+
case 'http':
|
|
62
|
+
servers[name] = {
|
|
63
|
+
type: 'http',
|
|
64
|
+
url: resolved.url,
|
|
65
|
+
headers: resolved.headers || {}
|
|
66
|
+
};
|
|
67
|
+
break;
|
|
68
|
+
case 'sdk':
|
|
69
|
+
try {
|
|
70
|
+
// For SDK servers, pass the module directly
|
|
71
|
+
const mod = await import(resolved.serverModule);
|
|
72
|
+
servers[name] = mod.default || mod;
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
console.warn(`Warning: Could not load SDK MCP server '${name}': ${err}`);
|
|
76
|
+
}
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return servers;
|
|
81
|
+
}
|
|
82
|
+
async *query(userQuery, history = []) {
|
|
83
|
+
const systemPrompt = this.buildSystemPrompt();
|
|
84
|
+
// Load external MCP servers from .mcp.json
|
|
85
|
+
const externalMcpServers = await this.loadExternalMcpServers();
|
|
86
|
+
const options = {
|
|
87
|
+
model: 'claude-sonnet-4-20250514',
|
|
88
|
+
cwd: process.cwd(),
|
|
89
|
+
systemPrompt,
|
|
90
|
+
mcpServers: {
|
|
91
|
+
// Pass SDK server directly
|
|
92
|
+
'custom-tools': this.customServer,
|
|
93
|
+
...externalMcpServers
|
|
94
|
+
},
|
|
95
|
+
// Enable built-in web search and fetch tools from Claude Agent SDK
|
|
96
|
+
allowedTools: ['WebSearch', 'WebFetch'],
|
|
97
|
+
permissionMode: 'default',
|
|
98
|
+
includePartialMessages: true,
|
|
99
|
+
canUseTool: async (toolName, input) => {
|
|
100
|
+
// Permission check happens in tool execution
|
|
101
|
+
return { behavior: 'allow', updatedInput: input };
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
// Resume previous session if we have one
|
|
105
|
+
if (this.sessionId) {
|
|
106
|
+
options.resume = this.sessionId;
|
|
107
|
+
}
|
|
108
|
+
// If history provided and no active session, prepend conversation context to prompt
|
|
109
|
+
let effectivePrompt = userQuery;
|
|
110
|
+
if (history.length > 0 && !this.sessionId) {
|
|
111
|
+
const contextLines = history.map(h => `${h.role === 'user' ? 'User' : 'Assistant'}: ${h.content}`).join('\n\n');
|
|
112
|
+
effectivePrompt = `Previous conversation:\n${contextLines}\n\nUser: ${userQuery}`;
|
|
113
|
+
}
|
|
114
|
+
const queryResult = query({
|
|
115
|
+
prompt: effectivePrompt,
|
|
116
|
+
options
|
|
117
|
+
});
|
|
118
|
+
// Stream messages and capture session ID
|
|
119
|
+
for await (const message of queryResult) {
|
|
120
|
+
// Capture session ID from system init message for future queries
|
|
121
|
+
if (message.type === 'system' && message.subtype === 'init') {
|
|
122
|
+
this.sessionId = message.session_id;
|
|
123
|
+
}
|
|
124
|
+
yield message;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
createToolServer() {
|
|
128
|
+
const tools = [];
|
|
129
|
+
// File operation tools
|
|
130
|
+
tools.push(tool('read_file', 'Read the contents of a file', {
|
|
131
|
+
filePath: z.string().describe('Path to the file to read')
|
|
132
|
+
}, async (args) => {
|
|
133
|
+
const content = await this.fileOps.readFile(args.filePath);
|
|
134
|
+
return {
|
|
135
|
+
content: [{
|
|
136
|
+
type: 'text',
|
|
137
|
+
text: content
|
|
138
|
+
}]
|
|
139
|
+
};
|
|
140
|
+
}));
|
|
141
|
+
tools.push(tool('write_file', 'Write content to a file (creates or overwrites)', {
|
|
142
|
+
filePath: z.string().describe('Path to the file to write'),
|
|
143
|
+
content: z.string().describe('Content to write to the file')
|
|
144
|
+
}, async (args) => {
|
|
145
|
+
await this.fileOps.writeFile(args.filePath, args.content);
|
|
146
|
+
return {
|
|
147
|
+
content: [{
|
|
148
|
+
type: 'text',
|
|
149
|
+
text: `Successfully wrote to ${args.filePath}`
|
|
150
|
+
}]
|
|
151
|
+
};
|
|
152
|
+
}));
|
|
153
|
+
tools.push(tool('find_files', 'Find files matching a glob pattern', {
|
|
154
|
+
pattern: z.string().describe('Glob pattern to match files (e.g., "**/*.ts")')
|
|
155
|
+
}, async (args) => {
|
|
156
|
+
const files = await this.fileOps.findFiles(args.pattern);
|
|
157
|
+
return {
|
|
158
|
+
content: [{
|
|
159
|
+
type: 'text',
|
|
160
|
+
text: files.join('\n')
|
|
161
|
+
}]
|
|
162
|
+
};
|
|
163
|
+
}));
|
|
164
|
+
// Command execution tools
|
|
165
|
+
tools.push(tool('run_command', 'Execute a shell command', {
|
|
166
|
+
command: z.string().describe('Command to execute')
|
|
167
|
+
}, async (args) => {
|
|
168
|
+
const result = await this.commandRunner.execute(args.command);
|
|
169
|
+
return {
|
|
170
|
+
content: [{
|
|
171
|
+
type: 'text',
|
|
172
|
+
text: this.commandRunner.formatResult(result)
|
|
173
|
+
}]
|
|
174
|
+
};
|
|
175
|
+
}));
|
|
176
|
+
return createSdkMcpServer({
|
|
177
|
+
name: 'custom-tools',
|
|
178
|
+
version: '1.0.0',
|
|
179
|
+
tools
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
buildSystemPrompt() {
|
|
183
|
+
// Build memory section from CLAUDE.md if available
|
|
184
|
+
const memorySection = this.claudeConfig.memory
|
|
185
|
+
? `## Project Context (from CLAUDE.md):
|
|
186
|
+
${this.claudeConfig.memory}
|
|
187
|
+
|
|
188
|
+
`
|
|
189
|
+
: '';
|
|
190
|
+
// Build skills section if any skills are loaded
|
|
191
|
+
const skillsSection = this.claudeConfig.skills.length > 0
|
|
192
|
+
? `## Available Skills:
|
|
193
|
+
${formatSkillsForPrompt(this.claudeConfig.skills)}
|
|
194
|
+
|
|
195
|
+
When the user asks you to use a skill (e.g., "run the api-design skill" or "use code-review"), apply the skill's instructions to the current context. Skills provide specialized expertise and workflows.
|
|
196
|
+
|
|
197
|
+
`
|
|
198
|
+
: '';
|
|
199
|
+
// Build subagents section if any are loaded
|
|
200
|
+
const subagentsSection = this.claudeConfig.subagents.length > 0
|
|
201
|
+
? '## Available Subagents:\n' + this.claudeConfig.subagents.map(a => '- **' + a.name + '**: ' + a.description).join('\n') + '\n\nYou can delegate specialized tasks to these subagents when appropriate.\n\n'
|
|
202
|
+
: '';
|
|
203
|
+
// Build commands info if any are loaded
|
|
204
|
+
const commandsSection = this.claudeConfig.commands.length > 0
|
|
205
|
+
? '## Slash Commands:\nThe user can invoke these commands with /command-name:\n' + this.claudeConfig.commands.map(c => '- **/' + c.name + '**: ' + (c.description || 'No description')).join('\n') + '\n\n'
|
|
206
|
+
: '';
|
|
207
|
+
return `You are Development Agent, a specialized AI assistant for development.
|
|
208
|
+
|
|
209
|
+
${memorySection}A comprehensive development assistant that can read, write, and modify code files, execute build commands, manage git repositories, and help with debugging and optimization.
|
|
210
|
+
|
|
211
|
+
## Your Capabilities:
|
|
212
|
+
- **Read File**: Read contents of any file in the project
|
|
213
|
+
- **Find Files**: Search for files using glob patterns
|
|
214
|
+
- **Search in Files**: Search for text content across files
|
|
215
|
+
- **Write File**: Create new files with specified content
|
|
216
|
+
- **Edit File**: Modify existing files with find-and-replace
|
|
217
|
+
- **Git Operations**: Git commands for version control
|
|
218
|
+
- **Run Command**: Execute shell commands and scripts
|
|
219
|
+
- **Web Search**: Search the web for information
|
|
220
|
+
- **Web Fetch**: Fetch and analyze web page content
|
|
221
|
+
- **Database Query**: Query SQL databases
|
|
222
|
+
- **API Client**: Make HTTP requests to external APIs
|
|
223
|
+
|
|
224
|
+
${skillsSection}${subagentsSection}${commandsSection}## Instructions:
|
|
225
|
+
- Provide helpful, accurate, and actionable assistance
|
|
226
|
+
- Use your available tools when appropriate
|
|
227
|
+
- Be thorough and explain your reasoning
|
|
228
|
+
|
|
229
|
+
Always be helpful, accurate, and focused on development tasks.`;
|
|
230
|
+
}
|
|
231
|
+
// File operation helpers
|
|
232
|
+
async readFile(filePath) {
|
|
233
|
+
return this.fileOps.readFile(filePath);
|
|
234
|
+
}
|
|
235
|
+
async writeFile(filePath, content) {
|
|
236
|
+
return this.fileOps.writeFile(filePath, content);
|
|
237
|
+
}
|
|
238
|
+
async findFiles(pattern) {
|
|
239
|
+
return this.fileOps.findFiles(pattern);
|
|
240
|
+
}
|
|
241
|
+
// Command execution helpers
|
|
242
|
+
async runCommand(command) {
|
|
243
|
+
const result = await this.commandRunner.execute(command);
|
|
244
|
+
console.log(this.commandRunner.formatResult(result));
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,kBAAkB,EAAc,MAAM,gCAAgC,CAAC;AAC7F,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAyB,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAqB,MAAM,oBAAoB,CAAC;AAWhG,MAAM,OAAO,qBAAqB;IACxB,MAAM,CAA8B;IACpC,iBAAiB,CAAoB;IACrC,OAAO,CAAiB;IACxB,aAAa,CAAgB;IAC7B,YAAY,CAAwC;IACpD,gBAAgB,CAAmB;IACnC,YAAY,CAAe;IAC3B,SAAS,CAAU;IAE3B,YAAY,SAAsC,EAAE;QAClD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC;QAChD,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB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AAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,4BAA4B;IAC5B,KAAK,CAAC,UAAU,CAAC,OAAe;QAC9B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACzD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;IACvD,CAAC;CACF"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Config Loader
|
|
3
|
+
*
|
|
4
|
+
* Loads Claude Code configuration files at runtime:
|
|
5
|
+
* - CLAUDE.md (project memory/context)
|
|
6
|
+
* - .claude/skills/*.md (model-invoked skills)
|
|
7
|
+
* - .claude/commands/*.md (slash commands)
|
|
8
|
+
* - .claude/agents/*.md (subagents)
|
|
9
|
+
*/
|
|
10
|
+
export interface SkillDefinition {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
tools: string[];
|
|
14
|
+
instructions: string;
|
|
15
|
+
filePath: string;
|
|
16
|
+
}
|
|
17
|
+
export interface CommandDefinition {
|
|
18
|
+
name: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
template: string;
|
|
21
|
+
filePath: string;
|
|
22
|
+
}
|
|
23
|
+
export interface SubagentDefinition {
|
|
24
|
+
name: string;
|
|
25
|
+
description: string;
|
|
26
|
+
tools: string[];
|
|
27
|
+
model: string;
|
|
28
|
+
permissionMode?: string;
|
|
29
|
+
systemPrompt: string;
|
|
30
|
+
filePath: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ClaudeConfig {
|
|
33
|
+
memory: string | null;
|
|
34
|
+
skills: SkillDefinition[];
|
|
35
|
+
commands: CommandDefinition[];
|
|
36
|
+
subagents: SubagentDefinition[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Load all Claude Code configuration from the working directory
|
|
40
|
+
*/
|
|
41
|
+
export declare function loadClaudeConfig(workingDir?: string): ClaudeConfig;
|
|
42
|
+
/**
|
|
43
|
+
* Format skills as a system prompt section
|
|
44
|
+
*/
|
|
45
|
+
export declare function formatSkillsForPrompt(skills: SkillDefinition[]): string;
|
|
46
|
+
/**
|
|
47
|
+
* Format commands for display/autocomplete
|
|
48
|
+
*/
|
|
49
|
+
export declare function formatCommandsForDisplay(commands: CommandDefinition[]): string[];
|
|
50
|
+
/**
|
|
51
|
+
* Get a specific command by name
|
|
52
|
+
*/
|
|
53
|
+
export declare function getCommand(commands: CommandDefinition[], name: string): CommandDefinition | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Expand a command template with arguments
|
|
56
|
+
*/
|
|
57
|
+
export declare function expandCommand(command: CommandDefinition, args: string): string;
|
|
58
|
+
//# sourceMappingURL=claude-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-config.d.ts","sourceRoot":"","sources":["../src/claude-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;C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