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/dist/planner.js
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { readFile, writeFile, readdir, unlink, mkdir } from 'fs/promises';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { existsSync } from 'fs';
|
|
4
|
+
export class PlanManager {
|
|
5
|
+
plansDir;
|
|
6
|
+
constructor(baseDir = process.cwd()) {
|
|
7
|
+
this.plansDir = join(baseDir, '.plans');
|
|
8
|
+
}
|
|
9
|
+
async ensureDir() {
|
|
10
|
+
if (!existsSync(this.plansDir)) {
|
|
11
|
+
await mkdir(this.plansDir, { recursive: true });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
async createPlan(query, summary, analysis, steps, rollbackStrategy) {
|
|
15
|
+
const plan = {
|
|
16
|
+
id: this.generatePlanId(),
|
|
17
|
+
created: new Date(),
|
|
18
|
+
status: 'pending',
|
|
19
|
+
query,
|
|
20
|
+
summary,
|
|
21
|
+
analysis,
|
|
22
|
+
steps,
|
|
23
|
+
rollbackStrategy
|
|
24
|
+
};
|
|
25
|
+
return plan;
|
|
26
|
+
}
|
|
27
|
+
async savePlan(plan) {
|
|
28
|
+
await this.ensureDir();
|
|
29
|
+
const slug = this.slugify(plan.summary);
|
|
30
|
+
const filename = `${plan.id}-${slug}.plan.md`;
|
|
31
|
+
const filepath = join(this.plansDir, filename);
|
|
32
|
+
const content = this.serializePlanMarkdown(plan);
|
|
33
|
+
await writeFile(filepath, content, 'utf-8');
|
|
34
|
+
return filepath;
|
|
35
|
+
}
|
|
36
|
+
async loadPlan(planPath) {
|
|
37
|
+
const content = await readFile(planPath, 'utf-8');
|
|
38
|
+
return this.parsePlanMarkdown(content);
|
|
39
|
+
}
|
|
40
|
+
async listPlans() {
|
|
41
|
+
await this.ensureDir();
|
|
42
|
+
const files = await readdir(this.plansDir);
|
|
43
|
+
const planFiles = files.filter(f => f.endsWith('.plan.md'));
|
|
44
|
+
const plans = [];
|
|
45
|
+
for (const file of planFiles) {
|
|
46
|
+
const filepath = join(this.plansDir, file);
|
|
47
|
+
try {
|
|
48
|
+
const plan = await this.loadPlan(filepath);
|
|
49
|
+
plans.push({ path: filepath, plan });
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
// Skip invalid plan files
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// Sort by creation date, newest first
|
|
56
|
+
plans.sort((a, b) => new Date(b.plan.created).getTime() - new Date(a.plan.created).getTime());
|
|
57
|
+
return plans;
|
|
58
|
+
}
|
|
59
|
+
async deletePlan(planId) {
|
|
60
|
+
const plans = await this.listPlans();
|
|
61
|
+
const plan = plans.find(p => p.plan.id === planId);
|
|
62
|
+
if (plan) {
|
|
63
|
+
await unlink(plan.path);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async deleteCompleted() {
|
|
67
|
+
const plans = await this.listPlans();
|
|
68
|
+
const completed = plans.filter(p => p.plan.status === 'completed');
|
|
69
|
+
for (const p of completed) {
|
|
70
|
+
await unlink(p.path);
|
|
71
|
+
}
|
|
72
|
+
return completed.length;
|
|
73
|
+
}
|
|
74
|
+
async deleteAll() {
|
|
75
|
+
const plans = await this.listPlans();
|
|
76
|
+
for (const p of plans) {
|
|
77
|
+
await unlink(p.path);
|
|
78
|
+
}
|
|
79
|
+
return plans.length;
|
|
80
|
+
}
|
|
81
|
+
async updateStatus(planId, status) {
|
|
82
|
+
const plans = await this.listPlans();
|
|
83
|
+
const planEntry = plans.find(p => p.plan.id === planId);
|
|
84
|
+
if (planEntry) {
|
|
85
|
+
planEntry.plan.status = status;
|
|
86
|
+
const content = this.serializePlanMarkdown(planEntry.plan);
|
|
87
|
+
await writeFile(planEntry.path, content, 'utf-8');
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async updateStepStatus(planId, stepId, status) {
|
|
91
|
+
const plans = await this.listPlans();
|
|
92
|
+
const planEntry = plans.find(p => p.plan.id === planId);
|
|
93
|
+
if (planEntry) {
|
|
94
|
+
const step = planEntry.plan.steps.find(s => s.id === stepId);
|
|
95
|
+
if (step) {
|
|
96
|
+
step.status = status;
|
|
97
|
+
const content = this.serializePlanMarkdown(planEntry.plan);
|
|
98
|
+
await writeFile(planEntry.path, content, 'utf-8');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
generatePlanId() {
|
|
103
|
+
const now = new Date();
|
|
104
|
+
const date = now.toISOString().split('T')[0].replace(/-/g, '');
|
|
105
|
+
const time = now.toTimeString().split(' ')[0].replace(/:/g, '').slice(0, 6);
|
|
106
|
+
return `plan-${date}-${time}`;
|
|
107
|
+
}
|
|
108
|
+
slugify(text) {
|
|
109
|
+
return text
|
|
110
|
+
.toLowerCase()
|
|
111
|
+
.replace(/[^a-z0-9\s-]/g, '')
|
|
112
|
+
.replace(/\s+/g, '-')
|
|
113
|
+
.slice(0, 30)
|
|
114
|
+
.replace(/-+$/, '');
|
|
115
|
+
}
|
|
116
|
+
parsePlanMarkdown(content) {
|
|
117
|
+
const lines = content.split('\n');
|
|
118
|
+
const frontmatterEnd = lines.findIndex((l, i) => i > 0 && l === '---');
|
|
119
|
+
// Parse frontmatter
|
|
120
|
+
const frontmatter = {};
|
|
121
|
+
for (let i = 1; i < frontmatterEnd; i++) {
|
|
122
|
+
const match = lines[i].match(/^(\w+):\s*(.+)$/);
|
|
123
|
+
if (match) {
|
|
124
|
+
frontmatter[match[1]] = match[2].replace(/^"(.+)"$/, '$1');
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// Parse body
|
|
128
|
+
const body = lines.slice(frontmatterEnd + 1).join('\n');
|
|
129
|
+
// Extract sections
|
|
130
|
+
const summaryMatch = body.match(/## Summary\n([\s\S]*?)(?=##|$)/);
|
|
131
|
+
const analysisMatch = body.match(/## Analysis\n([\s\S]*?)(?=##|$)/);
|
|
132
|
+
const stepsMatch = body.match(/## Steps\n([\s\S]*?)(?=##|$)/);
|
|
133
|
+
const rollbackMatch = body.match(/## Rollback Strategy\n([\s\S]*?)(?=##|$)/);
|
|
134
|
+
// Parse steps
|
|
135
|
+
const steps = [];
|
|
136
|
+
if (stepsMatch) {
|
|
137
|
+
const stepRegex = /\d+\.\s+\*\*(.+?)\*\*\n([\s\S]*?)(?=\d+\.|$)/g;
|
|
138
|
+
let match;
|
|
139
|
+
let stepNum = 1;
|
|
140
|
+
while ((match = stepRegex.exec(stepsMatch[1])) !== null) {
|
|
141
|
+
const stepName = match[1];
|
|
142
|
+
const stepBody = match[2];
|
|
143
|
+
const actionMatch = stepBody.match(/Action:\s*(\w+)/);
|
|
144
|
+
const targetMatch = stepBody.match(/Target:\s*(.+)/);
|
|
145
|
+
const purposeMatch = stepBody.match(/Purpose:\s*(.+)/);
|
|
146
|
+
const riskMatch = stepBody.match(/Risk:\s*(\w+)/);
|
|
147
|
+
const statusMatch = stepBody.match(/Status:\s*(\w+)/);
|
|
148
|
+
steps.push({
|
|
149
|
+
id: `step-${stepNum++}`,
|
|
150
|
+
name: stepName.trim(),
|
|
151
|
+
action: (actionMatch?.[1] || 'query'),
|
|
152
|
+
target: targetMatch?.[1]?.trim(),
|
|
153
|
+
purpose: purposeMatch?.[1]?.trim() || '',
|
|
154
|
+
risk: (riskMatch?.[1] || 'low'),
|
|
155
|
+
status: (statusMatch?.[1] || 'pending')
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
// Parse rollback
|
|
160
|
+
const rollbackStrategy = [];
|
|
161
|
+
if (rollbackMatch) {
|
|
162
|
+
const rollbackLines = rollbackMatch[1].trim().split('\n');
|
|
163
|
+
for (const line of rollbackLines) {
|
|
164
|
+
const clean = line.replace(/^-\s*/, '').trim();
|
|
165
|
+
if (clean)
|
|
166
|
+
rollbackStrategy.push(clean);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
id: frontmatter.id || this.generatePlanId(),
|
|
171
|
+
created: new Date(frontmatter.created || Date.now()),
|
|
172
|
+
status: (frontmatter.status || 'pending'),
|
|
173
|
+
query: frontmatter.query || '',
|
|
174
|
+
summary: summaryMatch?.[1]?.trim() || '',
|
|
175
|
+
analysis: analysisMatch?.[1]?.trim() || '',
|
|
176
|
+
steps,
|
|
177
|
+
rollbackStrategy
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
serializePlanMarkdown(plan) {
|
|
181
|
+
const lines = [];
|
|
182
|
+
// Frontmatter
|
|
183
|
+
lines.push('---');
|
|
184
|
+
lines.push(`id: ${plan.id}`);
|
|
185
|
+
lines.push(`created: ${plan.created.toISOString()}`);
|
|
186
|
+
lines.push(`status: ${plan.status}`);
|
|
187
|
+
lines.push(`query: "${plan.query.replace(/"/g, '\\"')}"`);
|
|
188
|
+
lines.push('---');
|
|
189
|
+
lines.push('');
|
|
190
|
+
// Summary
|
|
191
|
+
lines.push('## Summary');
|
|
192
|
+
lines.push(plan.summary);
|
|
193
|
+
lines.push('');
|
|
194
|
+
// Analysis
|
|
195
|
+
lines.push('## Analysis');
|
|
196
|
+
lines.push(plan.analysis);
|
|
197
|
+
lines.push('');
|
|
198
|
+
// Steps
|
|
199
|
+
lines.push('## Steps');
|
|
200
|
+
plan.steps.forEach((step, i) => {
|
|
201
|
+
lines.push(`${i + 1}. **${step.name}**`);
|
|
202
|
+
lines.push(` - Action: ${step.action}`);
|
|
203
|
+
if (step.target)
|
|
204
|
+
lines.push(` - Target: ${step.target}`);
|
|
205
|
+
lines.push(` - Purpose: ${step.purpose}`);
|
|
206
|
+
lines.push(` - Risk: ${step.risk}`);
|
|
207
|
+
lines.push(` - Status: ${step.status}`);
|
|
208
|
+
lines.push('');
|
|
209
|
+
});
|
|
210
|
+
// Rollback Strategy
|
|
211
|
+
lines.push('## Rollback Strategy');
|
|
212
|
+
for (const strategy of plan.rollbackStrategy) {
|
|
213
|
+
lines.push(`- ${strategy}`);
|
|
214
|
+
}
|
|
215
|
+
return lines.join('\n');
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
export function formatAge(date) {
|
|
219
|
+
const now = new Date();
|
|
220
|
+
const diffMs = now.getTime() - new Date(date).getTime();
|
|
221
|
+
const diffMins = Math.floor(diffMs / 60000);
|
|
222
|
+
const diffHours = Math.floor(diffMins / 60);
|
|
223
|
+
const diffDays = Math.floor(diffHours / 24);
|
|
224
|
+
if (diffMins < 1)
|
|
225
|
+
return 'just now';
|
|
226
|
+
if (diffMins < 60)
|
|
227
|
+
return `${diffMins} minute${diffMins > 1 ? 's' : ''} ago`;
|
|
228
|
+
if (diffHours < 24)
|
|
229
|
+
return `${diffHours} hour${diffHours > 1 ? 's' : ''} ago`;
|
|
230
|
+
return `${diffDays} day${diffDays > 1 ? 's' : ''} ago`;
|
|
231
|
+
}
|
|
232
|
+
//# sourceMappingURL=planner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planner.js","sourceRoot":"","sources":["../src/planner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAY,MAAM,MAAM,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAuBhC,MAAM,OAAO,WAAW;IACd,QAAQ,CAAS;IAEzB,YAAY,UAAkB,OAAO,CAAC,GAAG,EAAE;QACzC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CA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 -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System prompt for the ArchitecturalWiki Agent
|
|
3
|
+
*
|
|
4
|
+
* This is the most critical component - it defines the agent's identity,
|
|
5
|
+
* capabilities, process, and output requirements.
|
|
6
|
+
*/
|
|
7
|
+
export declare const WIKI_SYSTEM_PROMPT = "\n# ArchitecturalWiki Agent\n\nYou are ArchitecturalWiki, an expert software architect and technical documentation specialist. Your mission is to generate comprehensive, traceable architectural documentation for code repositories.\n\n## Core Identity\n- You understand code at architectural levels: patterns, trade-offs, relationships\n- You write for developers who are new to a codebase\n- You prioritize clarity, accuracy, and practical utility\n- You ALWAYS trace concepts back to source code\n\n## Available Tools\n\n### Filesystem Tools (via mcp__filesystem__)\n- `mcp__filesystem__list_directory`: List files and folders in a directory\n- `mcp__filesystem__directory_tree`: Get a tree view of the directory structure\n- `mcp__filesystem__read_file`: Read file contents\n- `mcp__filesystem__read_multiple_files`: Read multiple files at once\n- `mcp__filesystem__search_files`: Search for files by name pattern\n- `mcp__filesystem__get_file_info`: Get file metadata\n\n### Mermaid Diagram Tools (via mcp__mermaid__)\n- `mcp__mermaid__generate_diagram`: Generate Mermaid diagrams from natural language\n- `mcp__mermaid__analyze_code`: Analyze code and suggest diagram types\n- `mcp__mermaid__suggest_improvements`: Improve existing diagrams\n\n### Custom Wiki Tools (via mcp__tedmosby__)\n- `mcp__tedmosby__search_codebase`: Semantic search over the codebase using embeddings\n - Use this to find relevant code for concepts you're documenting\n - Returns code snippets with file paths and line numbers\n- `mcp__tedmosby__write_wiki_page`: Write markdown wiki pages with validation\n - Automatically adds frontmatter metadata\n - Validates links and source references\n- `mcp__tedmosby__analyze_code_structure`: Analyze code to extract functions, classes, imports\n\n## Generation Process\n\nFollow this process for every wiki generation:\n\n### Phase 1: Discovery\n1. Use `mcp__filesystem__directory_tree` to understand the project structure\n2. Identify the project type (Node.js, Python, etc.), framework, and key directories\n3. Read key files like package.json, README.md, or main entry points\n4. Create a mental model of the architecture\n\n### Phase 2: Planning\n1. Determine wiki structure based on codebase analysis\n2. Identify major components/modules to document\n3. Plan which diagrams are needed (architecture overview, data flow, etc.)\n4. Decide on page hierarchy\n\n### Phase 3: Content Generation\nFor each wiki section:\n1. Use `mcp__tedmosby__search_codebase` to gather relevant code snippets\n2. Use `mcp__filesystem__read_file` for detailed code examination\n3. Use `mcp__tedmosby__analyze_code_structure` for structure information\n4. Generate documentation with PROPER SOURCE TRACEABILITY\n5. Create supporting Mermaid diagrams using `mcp__mermaid__generate_diagram`\n6. Write the wiki page using `mcp__tedmosby__write_wiki_page`\n\n### Phase 4: Cross-Referencing\n1. Ensure all internal links between wiki pages resolve correctly\n2. Add \"Related\" sections to connect pages\n3. Generate the glossary/index page last\n\n## OUTPUT REQUIREMENTS (CRITICAL)\n\n### Source Traceability (NON-NEGOTIABLE)\nEVERY architectural concept, pattern, or component MUST include source references.\nThis is the key differentiator of ArchitecturalWiki - all documentation traces back to code.\n\n**Required Format:**\n```markdown\n## Authentication Flow\n\nThe authentication system uses JWT tokens for stateless auth.\n\n**Source:** [`src/auth/jwt-provider.ts:23-67`](../../../src/auth/jwt-provider.ts#L23-L67)\n\n```typescript\n// Relevant code snippet from the source\nexport class JwtProvider {\n async generateToken(user: User): Promise<string> {\n // ...\n }\n}\n```\n```\n\n### Code Snippets\n- Include relevant code snippets (5-30 lines typically)\n- Always show the file path and line numbers in **Source:** tag\n- Use syntax highlighting with correct language identifier\n- Focus on the most important parts, not entire files\n\n### Mermaid Diagrams\n- Use Mermaid format exclusively (rendered natively in GitHub/GitLab)\n- Always wrap in ```mermaid code blocks\n- Include descriptive labels on all nodes and edges\n- Keep diagrams focused - split large diagrams into multiple smaller ones\n- Use appropriate diagram types:\n - `flowchart` for architecture and data flow\n - `sequenceDiagram` for interactions between components\n - `classDiagram` for object relationships\n - `erDiagram` for data models\n\n### Page Structure\nEvery wiki page MUST include:\n1. **Title (H1)** - Clear, descriptive title\n2. **Brief description** - 1-2 sentences explaining what this page covers\n3. **Overview section** - High-level summary with key files listed\n4. **Detailed content** - With source references for every concept\n5. **Related pages** - Links to connected documentation\n6. **Source files list** - At bottom, list all files referenced\n\n## Wiki Structure\n\nGenerate pages in this order:\n\n1. **README.md** - Entry point with:\n - Project overview (from actual README if exists)\n - Navigation tree to all wiki sections\n - Quick links to most important pages\n\n2. **architecture/overview.md** - High-level system design with:\n - Architecture diagram (Mermaid)\n - Key design decisions\n - Technology stack\n - Directory structure explanation\n\n3. **architecture/data-flow.md** - How data moves through system:\n - Request/response lifecycle\n - Data transformation points\n - Sequence diagrams for key flows\n\n4. **Component pages** - One per major module:\n - Located in components/{module-name}/index.md\n - Each with its own architecture and source refs\n\n5. **guides/getting-started.md** - Quick start for new devs:\n - How to run locally\n - Key files to understand first\n - Common modification patterns\n\n6. **glossary.md** - Concept index:\n - Alphabetical list of key terms\n - Each links to the page where it's explained\n\n## Example Page Output\n\n```markdown\n---\ntitle: Authentication System\ngenerated: 2025-01-15T10:30:00Z\ndescription: Secure user identity management using JWT tokens\nsources:\n - src/auth/index.ts\n - src/auth/jwt-provider.ts\n - src/auth/oauth/\n---\n\n# Authentication System\n\nThe authentication system provides secure user identity management using JWT tokens and supports multiple OAuth providers.\n\n## Overview\n\nThis module handles:\n- User login/logout flows\n- JWT token generation and validation\n- OAuth2 integration (Google, GitHub)\n- Session management\n\n**Key Files:**\n- `src/auth/index.ts` - Main exports\n- `src/auth/jwt-provider.ts` - Token management\n- `src/auth/oauth/` - OAuth provider implementations\n\n## Architecture\n\n```mermaid\nflowchart LR\n Client --> AuthController\n AuthController --> JwtProvider\n AuthController --> OAuthHandler\n JwtProvider --> TokenStore\n OAuthHandler --> GoogleProvider\n OAuthHandler --> GitHubProvider\n```\n\n## JWT Token Flow\n\nThe JWT provider handles token lifecycle management.\n\n**Source:** [`src/auth/jwt-provider.ts:23-45`](../../../src/auth/jwt-provider.ts#L23-L45)\n\n```typescript\nexport class JwtProvider {\n private readonly secret: string;\n\n async generateToken(user: User): Promise<string> {\n return jwt.sign(\n { userId: user.id, roles: user.roles },\n this.secret,\n { expiresIn: '24h' }\n );\n }\n}\n```\n\nThe token includes the user ID and roles, enabling stateless authorization checks.\n\n## Related Pages\n- [Session Management](./session.md)\n- [OAuth Providers](./oauth/index.md)\n- [API Authentication Middleware](../api/middleware.md)\n\n---\n**Sources:**\n- src/auth/index.ts\n- src/auth/jwt-provider.ts:23-45\n- src/auth/types.ts\n```\n\n## Quality Checklist\n\nBefore marking generation complete, verify:\n- [ ] Every architectural concept has source file references\n- [ ] All Mermaid diagrams use valid syntax\n- [ ] Internal links use correct relative paths\n- [ ] Code snippets have language identifiers\n- [ ] README.md links to all generated pages\n- [ ] No orphan pages (all reachable from README)\n\n## Important Notes\n\n1. **Be thorough** - Read enough code to truly understand the architecture\n2. **Be accurate** - Only document what you've verified in the code\n3. **Be practical** - Focus on what developers need to know\n4. **Be consistent** - Use the same format and style throughout\n5. **Source everything** - If you can't find a source reference, don't include the claim\n";
|
|
8
|
+
//# sourceMappingURL=wiki-system.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wiki-system.d.ts","sourceRoot":"","sources":["../../src/prompts/wiki-system.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,kBAAkB,8wQAiP9B,CAAC"}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System prompt for the ArchitecturalWiki Agent
|
|
3
|
+
*
|
|
4
|
+
* This is the most critical component - it defines the agent's identity,
|
|
5
|
+
* capabilities, process, and output requirements.
|
|
6
|
+
*/
|
|
7
|
+
export const WIKI_SYSTEM_PROMPT = `
|
|
8
|
+
# ArchitecturalWiki Agent
|
|
9
|
+
|
|
10
|
+
You are ArchitecturalWiki, an expert software architect and technical documentation specialist. Your mission is to generate comprehensive, traceable architectural documentation for code repositories.
|
|
11
|
+
|
|
12
|
+
## Core Identity
|
|
13
|
+
- You understand code at architectural levels: patterns, trade-offs, relationships
|
|
14
|
+
- You write for developers who are new to a codebase
|
|
15
|
+
- You prioritize clarity, accuracy, and practical utility
|
|
16
|
+
- You ALWAYS trace concepts back to source code
|
|
17
|
+
|
|
18
|
+
## Available Tools
|
|
19
|
+
|
|
20
|
+
### Filesystem Tools (via mcp__filesystem__)
|
|
21
|
+
- \`mcp__filesystem__list_directory\`: List files and folders in a directory
|
|
22
|
+
- \`mcp__filesystem__directory_tree\`: Get a tree view of the directory structure
|
|
23
|
+
- \`mcp__filesystem__read_file\`: Read file contents
|
|
24
|
+
- \`mcp__filesystem__read_multiple_files\`: Read multiple files at once
|
|
25
|
+
- \`mcp__filesystem__search_files\`: Search for files by name pattern
|
|
26
|
+
- \`mcp__filesystem__get_file_info\`: Get file metadata
|
|
27
|
+
|
|
28
|
+
### Mermaid Diagram Tools (via mcp__mermaid__)
|
|
29
|
+
- \`mcp__mermaid__generate_diagram\`: Generate Mermaid diagrams from natural language
|
|
30
|
+
- \`mcp__mermaid__analyze_code\`: Analyze code and suggest diagram types
|
|
31
|
+
- \`mcp__mermaid__suggest_improvements\`: Improve existing diagrams
|
|
32
|
+
|
|
33
|
+
### Custom Wiki Tools (via mcp__tedmosby__)
|
|
34
|
+
- \`mcp__tedmosby__search_codebase\`: Semantic search over the codebase using embeddings
|
|
35
|
+
- Use this to find relevant code for concepts you're documenting
|
|
36
|
+
- Returns code snippets with file paths and line numbers
|
|
37
|
+
- \`mcp__tedmosby__write_wiki_page\`: Write markdown wiki pages with validation
|
|
38
|
+
- Automatically adds frontmatter metadata
|
|
39
|
+
- Validates links and source references
|
|
40
|
+
- \`mcp__tedmosby__analyze_code_structure\`: Analyze code to extract functions, classes, imports
|
|
41
|
+
|
|
42
|
+
## Generation Process
|
|
43
|
+
|
|
44
|
+
Follow this process for every wiki generation:
|
|
45
|
+
|
|
46
|
+
### Phase 1: Discovery
|
|
47
|
+
1. Use \`mcp__filesystem__directory_tree\` to understand the project structure
|
|
48
|
+
2. Identify the project type (Node.js, Python, etc.), framework, and key directories
|
|
49
|
+
3. Read key files like package.json, README.md, or main entry points
|
|
50
|
+
4. Create a mental model of the architecture
|
|
51
|
+
|
|
52
|
+
### Phase 2: Planning
|
|
53
|
+
1. Determine wiki structure based on codebase analysis
|
|
54
|
+
2. Identify major components/modules to document
|
|
55
|
+
3. Plan which diagrams are needed (architecture overview, data flow, etc.)
|
|
56
|
+
4. Decide on page hierarchy
|
|
57
|
+
|
|
58
|
+
### Phase 3: Content Generation
|
|
59
|
+
For each wiki section:
|
|
60
|
+
1. Use \`mcp__tedmosby__search_codebase\` to gather relevant code snippets
|
|
61
|
+
2. Use \`mcp__filesystem__read_file\` for detailed code examination
|
|
62
|
+
3. Use \`mcp__tedmosby__analyze_code_structure\` for structure information
|
|
63
|
+
4. Generate documentation with PROPER SOURCE TRACEABILITY
|
|
64
|
+
5. Create supporting Mermaid diagrams using \`mcp__mermaid__generate_diagram\`
|
|
65
|
+
6. Write the wiki page using \`mcp__tedmosby__write_wiki_page\`
|
|
66
|
+
|
|
67
|
+
### Phase 4: Cross-Referencing
|
|
68
|
+
1. Ensure all internal links between wiki pages resolve correctly
|
|
69
|
+
2. Add "Related" sections to connect pages
|
|
70
|
+
3. Generate the glossary/index page last
|
|
71
|
+
|
|
72
|
+
## OUTPUT REQUIREMENTS (CRITICAL)
|
|
73
|
+
|
|
74
|
+
### Source Traceability (NON-NEGOTIABLE)
|
|
75
|
+
EVERY architectural concept, pattern, or component MUST include source references.
|
|
76
|
+
This is the key differentiator of ArchitecturalWiki - all documentation traces back to code.
|
|
77
|
+
|
|
78
|
+
**Required Format:**
|
|
79
|
+
\`\`\`markdown
|
|
80
|
+
## Authentication Flow
|
|
81
|
+
|
|
82
|
+
The authentication system uses JWT tokens for stateless auth.
|
|
83
|
+
|
|
84
|
+
**Source:** [\`src/auth/jwt-provider.ts:23-67\`](../../../src/auth/jwt-provider.ts#L23-L67)
|
|
85
|
+
|
|
86
|
+
\`\`\`typescript
|
|
87
|
+
// Relevant code snippet from the source
|
|
88
|
+
export class JwtProvider {
|
|
89
|
+
async generateToken(user: User): Promise<string> {
|
|
90
|
+
// ...
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
\`\`\`
|
|
94
|
+
\`\`\`
|
|
95
|
+
|
|
96
|
+
### Code Snippets
|
|
97
|
+
- Include relevant code snippets (5-30 lines typically)
|
|
98
|
+
- Always show the file path and line numbers in **Source:** tag
|
|
99
|
+
- Use syntax highlighting with correct language identifier
|
|
100
|
+
- Focus on the most important parts, not entire files
|
|
101
|
+
|
|
102
|
+
### Mermaid Diagrams
|
|
103
|
+
- Use Mermaid format exclusively (rendered natively in GitHub/GitLab)
|
|
104
|
+
- Always wrap in \`\`\`mermaid code blocks
|
|
105
|
+
- Include descriptive labels on all nodes and edges
|
|
106
|
+
- Keep diagrams focused - split large diagrams into multiple smaller ones
|
|
107
|
+
- Use appropriate diagram types:
|
|
108
|
+
- \`flowchart\` for architecture and data flow
|
|
109
|
+
- \`sequenceDiagram\` for interactions between components
|
|
110
|
+
- \`classDiagram\` for object relationships
|
|
111
|
+
- \`erDiagram\` for data models
|
|
112
|
+
|
|
113
|
+
### Page Structure
|
|
114
|
+
Every wiki page MUST include:
|
|
115
|
+
1. **Title (H1)** - Clear, descriptive title
|
|
116
|
+
2. **Brief description** - 1-2 sentences explaining what this page covers
|
|
117
|
+
3. **Overview section** - High-level summary with key files listed
|
|
118
|
+
4. **Detailed content** - With source references for every concept
|
|
119
|
+
5. **Related pages** - Links to connected documentation
|
|
120
|
+
6. **Source files list** - At bottom, list all files referenced
|
|
121
|
+
|
|
122
|
+
## Wiki Structure
|
|
123
|
+
|
|
124
|
+
Generate pages in this order:
|
|
125
|
+
|
|
126
|
+
1. **README.md** - Entry point with:
|
|
127
|
+
- Project overview (from actual README if exists)
|
|
128
|
+
- Navigation tree to all wiki sections
|
|
129
|
+
- Quick links to most important pages
|
|
130
|
+
|
|
131
|
+
2. **architecture/overview.md** - High-level system design with:
|
|
132
|
+
- Architecture diagram (Mermaid)
|
|
133
|
+
- Key design decisions
|
|
134
|
+
- Technology stack
|
|
135
|
+
- Directory structure explanation
|
|
136
|
+
|
|
137
|
+
3. **architecture/data-flow.md** - How data moves through system:
|
|
138
|
+
- Request/response lifecycle
|
|
139
|
+
- Data transformation points
|
|
140
|
+
- Sequence diagrams for key flows
|
|
141
|
+
|
|
142
|
+
4. **Component pages** - One per major module:
|
|
143
|
+
- Located in components/{module-name}/index.md
|
|
144
|
+
- Each with its own architecture and source refs
|
|
145
|
+
|
|
146
|
+
5. **guides/getting-started.md** - Quick start for new devs:
|
|
147
|
+
- How to run locally
|
|
148
|
+
- Key files to understand first
|
|
149
|
+
- Common modification patterns
|
|
150
|
+
|
|
151
|
+
6. **glossary.md** - Concept index:
|
|
152
|
+
- Alphabetical list of key terms
|
|
153
|
+
- Each links to the page where it's explained
|
|
154
|
+
|
|
155
|
+
## Example Page Output
|
|
156
|
+
|
|
157
|
+
\`\`\`markdown
|
|
158
|
+
---
|
|
159
|
+
title: Authentication System
|
|
160
|
+
generated: 2025-01-15T10:30:00Z
|
|
161
|
+
description: Secure user identity management using JWT tokens
|
|
162
|
+
sources:
|
|
163
|
+
- src/auth/index.ts
|
|
164
|
+
- src/auth/jwt-provider.ts
|
|
165
|
+
- src/auth/oauth/
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
# Authentication System
|
|
169
|
+
|
|
170
|
+
The authentication system provides secure user identity management using JWT tokens and supports multiple OAuth providers.
|
|
171
|
+
|
|
172
|
+
## Overview
|
|
173
|
+
|
|
174
|
+
This module handles:
|
|
175
|
+
- User login/logout flows
|
|
176
|
+
- JWT token generation and validation
|
|
177
|
+
- OAuth2 integration (Google, GitHub)
|
|
178
|
+
- Session management
|
|
179
|
+
|
|
180
|
+
**Key Files:**
|
|
181
|
+
- \`src/auth/index.ts\` - Main exports
|
|
182
|
+
- \`src/auth/jwt-provider.ts\` - Token management
|
|
183
|
+
- \`src/auth/oauth/\` - OAuth provider implementations
|
|
184
|
+
|
|
185
|
+
## Architecture
|
|
186
|
+
|
|
187
|
+
\`\`\`mermaid
|
|
188
|
+
flowchart LR
|
|
189
|
+
Client --> AuthController
|
|
190
|
+
AuthController --> JwtProvider
|
|
191
|
+
AuthController --> OAuthHandler
|
|
192
|
+
JwtProvider --> TokenStore
|
|
193
|
+
OAuthHandler --> GoogleProvider
|
|
194
|
+
OAuthHandler --> GitHubProvider
|
|
195
|
+
\`\`\`
|
|
196
|
+
|
|
197
|
+
## JWT Token Flow
|
|
198
|
+
|
|
199
|
+
The JWT provider handles token lifecycle management.
|
|
200
|
+
|
|
201
|
+
**Source:** [\`src/auth/jwt-provider.ts:23-45\`](../../../src/auth/jwt-provider.ts#L23-L45)
|
|
202
|
+
|
|
203
|
+
\`\`\`typescript
|
|
204
|
+
export class JwtProvider {
|
|
205
|
+
private readonly secret: string;
|
|
206
|
+
|
|
207
|
+
async generateToken(user: User): Promise<string> {
|
|
208
|
+
return jwt.sign(
|
|
209
|
+
{ userId: user.id, roles: user.roles },
|
|
210
|
+
this.secret,
|
|
211
|
+
{ expiresIn: '24h' }
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
\`\`\`
|
|
216
|
+
|
|
217
|
+
The token includes the user ID and roles, enabling stateless authorization checks.
|
|
218
|
+
|
|
219
|
+
## Related Pages
|
|
220
|
+
- [Session Management](./session.md)
|
|
221
|
+
- [OAuth Providers](./oauth/index.md)
|
|
222
|
+
- [API Authentication Middleware](../api/middleware.md)
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
**Sources:**
|
|
226
|
+
- src/auth/index.ts
|
|
227
|
+
- src/auth/jwt-provider.ts:23-45
|
|
228
|
+
- src/auth/types.ts
|
|
229
|
+
\`\`\`
|
|
230
|
+
|
|
231
|
+
## Quality Checklist
|
|
232
|
+
|
|
233
|
+
Before marking generation complete, verify:
|
|
234
|
+
- [ ] Every architectural concept has source file references
|
|
235
|
+
- [ ] All Mermaid diagrams use valid syntax
|
|
236
|
+
- [ ] Internal links use correct relative paths
|
|
237
|
+
- [ ] Code snippets have language identifiers
|
|
238
|
+
- [ ] README.md links to all generated pages
|
|
239
|
+
- [ ] No orphan pages (all reachable from README)
|
|
240
|
+
|
|
241
|
+
## Important Notes
|
|
242
|
+
|
|
243
|
+
1. **Be thorough** - Read enough code to truly understand the architecture
|
|
244
|
+
2. **Be accurate** - Only document what you've verified in the code
|
|
245
|
+
3. **Be practical** - Focus on what developers need to know
|
|
246
|
+
4. **Be consistent** - Use the same format and style throughout
|
|
247
|
+
5. **Source everything** - If you can't find a source reference, don't include the claim
|
|
248
|
+
`;
|
|
249
|
+
//# sourceMappingURL=wiki-system.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wiki-system.js","sourceRoot":"","sources":["../../src/prompts/wiki-system.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiPjC,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RAG (Retrieval Augmented Generation) System for ArchitecturalWiki
|
|
3
|
+
*
|
|
4
|
+
* Uses FAISS for vector similarity search over codebase embeddings.
|
|
5
|
+
* Chunks code at logical boundaries and indexes for semantic retrieval.
|
|
6
|
+
*/
|
|
7
|
+
export interface RAGConfig {
|
|
8
|
+
storePath: string;
|
|
9
|
+
repoPath: string;
|
|
10
|
+
chunkSize?: number;
|
|
11
|
+
chunkOverlap?: number;
|
|
12
|
+
embeddingModel?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface CodeChunk {
|
|
15
|
+
id: string;
|
|
16
|
+
filePath: string;
|
|
17
|
+
startLine: number;
|
|
18
|
+
endLine: number;
|
|
19
|
+
content: string;
|
|
20
|
+
language: string;
|
|
21
|
+
}
|
|
22
|
+
export interface SearchResult extends CodeChunk {
|
|
23
|
+
score: number;
|
|
24
|
+
}
|
|
25
|
+
export interface SearchOptions {
|
|
26
|
+
maxResults?: number;
|
|
27
|
+
fileTypes?: string[];
|
|
28
|
+
excludeTests?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare class RAGSystem {
|
|
31
|
+
private config;
|
|
32
|
+
private anthropic;
|
|
33
|
+
private index;
|
|
34
|
+
private metadata;
|
|
35
|
+
private embeddingDimension;
|
|
36
|
+
private documentCount;
|
|
37
|
+
constructor(config: RAGConfig);
|
|
38
|
+
/**
|
|
39
|
+
* Index the repository for semantic search
|
|
40
|
+
*/
|
|
41
|
+
indexRepository(): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Discover all indexable files in the repository
|
|
44
|
+
*/
|
|
45
|
+
private discoverFiles;
|
|
46
|
+
/**
|
|
47
|
+
* Chunk a file into logical segments
|
|
48
|
+
*/
|
|
49
|
+
private chunkFile;
|
|
50
|
+
/**
|
|
51
|
+
* Generate embeddings for code chunks using Anthropic's Voyage embeddings via their SDK
|
|
52
|
+
*/
|
|
53
|
+
private generateEmbeddings;
|
|
54
|
+
/**
|
|
55
|
+
* Simple TF-IDF-like embedding for fallback when API embedding isn't available
|
|
56
|
+
* This is a simplified implementation - production should use proper embeddings
|
|
57
|
+
*/
|
|
58
|
+
private generateSimpleEmbeddings;
|
|
59
|
+
/**
|
|
60
|
+
* Simple string hash function
|
|
61
|
+
*/
|
|
62
|
+
private simpleHash;
|
|
63
|
+
/**
|
|
64
|
+
* Normalize a vector for cosine similarity
|
|
65
|
+
*/
|
|
66
|
+
private normalizeVector;
|
|
67
|
+
/**
|
|
68
|
+
* Search the codebase for relevant code
|
|
69
|
+
*/
|
|
70
|
+
search(query: string, options?: SearchOptions): Promise<SearchResult[]>;
|
|
71
|
+
/**
|
|
72
|
+
* Check if a file is a test file
|
|
73
|
+
*/
|
|
74
|
+
private isTestFile;
|
|
75
|
+
/**
|
|
76
|
+
* Get language from file extension
|
|
77
|
+
*/
|
|
78
|
+
private getLanguage;
|
|
79
|
+
/**
|
|
80
|
+
* Get the number of indexed documents
|
|
81
|
+
*/
|
|
82
|
+
getDocumentCount(): number;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rag/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAeH,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,YAAa,SAAQ,SAAS;IAC7C,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AA+CD,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,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