repomemory 0.1.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 +227 -0
- package/dist/commands/analyze.d.ts +7 -0
- package/dist/commands/analyze.d.ts.map +1 -0
- package/dist/commands/analyze.js +360 -0
- package/dist/commands/analyze.js.map +1 -0
- package/dist/commands/init.d.ts +5 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +86 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/serve.d.ts +4 -0
- package/dist/commands/serve.d.ts.map +1 -0
- package/dist/commands/serve.js +13 -0
- package/dist/commands/serve.js.map +1 -0
- package/dist/commands/setup.d.ts +4 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +134 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/sync.d.ts +5 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +77 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +109 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/ai-provider.d.ts +18 -0
- package/dist/lib/ai-provider.d.ts.map +1 -0
- package/dist/lib/ai-provider.js +164 -0
- package/dist/lib/ai-provider.js.map +1 -0
- package/dist/lib/config.d.ts +29 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +103 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/context-store.d.ts +31 -0
- package/dist/lib/context-store.d.ts.map +1 -0
- package/dist/lib/context-store.js +150 -0
- package/dist/lib/context-store.js.map +1 -0
- package/dist/lib/git.d.ts +29 -0
- package/dist/lib/git.d.ts.map +1 -0
- package/dist/lib/git.js +139 -0
- package/dist/lib/git.js.map +1 -0
- package/dist/lib/repo-scanner.d.ts +26 -0
- package/dist/lib/repo-scanner.d.ts.map +1 -0
- package/dist/lib/repo-scanner.js +213 -0
- package/dist/lib/repo-scanner.js.map +1 -0
- package/dist/lib/search.d.ts +21 -0
- package/dist/lib/search.d.ts.map +1 -0
- package/dist/lib/search.js +147 -0
- package/dist/lib/search.js.map +1 -0
- package/dist/mcp/server.d.ts +3 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +324 -0
- package/dist/mcp/server.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { existsSync, writeFileSync } from "fs";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import { loadConfig } from "../lib/config.js";
|
|
5
|
+
import { ContextStore } from "../lib/context-store.js";
|
|
6
|
+
const DEFAULT_REPO_CONTEXT_CONFIG = {
|
|
7
|
+
provider: "anthropic",
|
|
8
|
+
model: "claude-sonnet-4-5-20250929",
|
|
9
|
+
ignorePatterns: [],
|
|
10
|
+
keyFilePatterns: [],
|
|
11
|
+
maxFilesForAnalysis: 80,
|
|
12
|
+
maxGitCommits: 100,
|
|
13
|
+
autoIndex: true,
|
|
14
|
+
contextDir: ".context",
|
|
15
|
+
};
|
|
16
|
+
export async function initCommand(options) {
|
|
17
|
+
const repoRoot = options.dir || process.cwd();
|
|
18
|
+
const config = loadConfig(repoRoot);
|
|
19
|
+
if (options.provider) {
|
|
20
|
+
config.provider = options.provider;
|
|
21
|
+
}
|
|
22
|
+
const store = new ContextStore(repoRoot, config);
|
|
23
|
+
if (store.exists()) {
|
|
24
|
+
console.log(chalk.yellow("⚠ .context/ directory already exists."));
|
|
25
|
+
console.log(chalk.dim(" Run `repomemory analyze` to regenerate content."));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
// Scaffold directories
|
|
29
|
+
store.scaffold();
|
|
30
|
+
// Write starter index
|
|
31
|
+
store.writeIndex(`# Project Context
|
|
32
|
+
|
|
33
|
+
> Auto-generated by [repomemory](https://github.com/repomemory/repomemory). Run \`repomemory analyze\` to populate.
|
|
34
|
+
|
|
35
|
+
## Quick Orient
|
|
36
|
+
*Run \`repomemory analyze\` to generate project-specific orientation.*
|
|
37
|
+
|
|
38
|
+
## Context Files
|
|
39
|
+
- \`facts/\` — Architecture, patterns, integrations
|
|
40
|
+
- \`decisions/\` — Why things are this way (prevents re-debating)
|
|
41
|
+
- \`regressions/\` — Known gotchas, things that broke before
|
|
42
|
+
- \`sessions/\` — Compressed session summaries
|
|
43
|
+
- \`changelog/\` — Recent changes by month
|
|
44
|
+
|
|
45
|
+
## For AI Agents
|
|
46
|
+
Search this directory for task-relevant context before starting work.
|
|
47
|
+
Write new learnings using the \`context_write\` MCP tool during your session.
|
|
48
|
+
`);
|
|
49
|
+
// Write config file if it doesn't exist
|
|
50
|
+
const configPath = join(repoRoot, ".repomemory.json");
|
|
51
|
+
if (!existsSync(configPath)) {
|
|
52
|
+
const configToWrite = { ...DEFAULT_REPO_CONTEXT_CONFIG };
|
|
53
|
+
if (options.provider) {
|
|
54
|
+
configToWrite.provider = options.provider;
|
|
55
|
+
}
|
|
56
|
+
writeFileSync(configPath, JSON.stringify(configToWrite, null, 2) + "\n");
|
|
57
|
+
}
|
|
58
|
+
console.log(chalk.green("✓ Initialized .context/ directory"));
|
|
59
|
+
console.log();
|
|
60
|
+
console.log(chalk.bold("Created:"));
|
|
61
|
+
console.log(` ${chalk.cyan(".context/index.md")} — Quick orientation`);
|
|
62
|
+
console.log(` ${chalk.cyan(".context/facts/")} — Architecture & patterns`);
|
|
63
|
+
console.log(` ${chalk.cyan(".context/decisions/")} — Why things are this way`);
|
|
64
|
+
console.log(` ${chalk.cyan(".context/regressions/")} — Known gotchas`);
|
|
65
|
+
console.log(` ${chalk.cyan(".context/sessions/")} — Session summaries`);
|
|
66
|
+
console.log(` ${chalk.cyan(".context/changelog/")} — Monthly changelogs`);
|
|
67
|
+
console.log(` ${chalk.cyan(".repomemory.json")} — Configuration`);
|
|
68
|
+
console.log();
|
|
69
|
+
console.log(chalk.bold("Next steps:"));
|
|
70
|
+
console.log();
|
|
71
|
+
console.log(` 1. Set your API key:`);
|
|
72
|
+
console.log(chalk.dim(` export ANTHROPIC_API_KEY=sk-ant-...`));
|
|
73
|
+
console.log(chalk.dim(` # or: export OPENAI_API_KEY=sk-...`));
|
|
74
|
+
console.log(chalk.dim(` # or: export GEMINI_API_KEY=...`));
|
|
75
|
+
console.log(chalk.dim(` # or: export GROK_API_KEY=...`));
|
|
76
|
+
console.log();
|
|
77
|
+
console.log(` 2. Analyze your repo (AI-powered):`);
|
|
78
|
+
console.log(chalk.dim(` repomemory analyze`));
|
|
79
|
+
console.log();
|
|
80
|
+
console.log(` 3. Add the MCP server to your AI tool:`);
|
|
81
|
+
console.log(chalk.dim(` repomemory setup claude # Configure Claude Code`));
|
|
82
|
+
console.log(chalk.dim(` repomemory setup cursor # Configure Cursor`));
|
|
83
|
+
console.log();
|
|
84
|
+
console.log(` 4. Commit .context/ to git — your team shares the knowledge.`);
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,MAAM,2BAA2B,GAAG;IAClC,QAAQ,EAAE,WAAW;IACrB,KAAK,EAAE,4BAA4B;IACnC,cAAc,EAAE,EAAE;IAClB,eAAe,EAAE,EAAE;IACnB,mBAAmB,EAAE,EAAE;IACvB,aAAa,EAAE,GAAG;IAClB,SAAS,EAAE,IAAI;IACf,UAAU,EAAE,UAAU;CACvB,CAAC;AAEF,MAAM,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AC;IAC/D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC,CAAC;IAC7D,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;IACpD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC,CAAC;IAClD,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;IACxD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,wDAAwD,CAAC,CAAC,CAAC;IACjF,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAC,CAAC;IAC5E,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CAAC,gEAAgE,CAAC,CAAC;AAChF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../src/commands/serve.ts"],"names":[],"mappings":"AAIA,wBAAsB,YAAY,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,iBAU3D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { loadConfig } from "../lib/config.js";
|
|
3
|
+
import { startMcpServer } from "../mcp/server.js";
|
|
4
|
+
export async function serveCommand(options) {
|
|
5
|
+
const repoRoot = options.dir || process.cwd();
|
|
6
|
+
const config = loadConfig(repoRoot);
|
|
7
|
+
// Only log to stderr so stdout is clean for MCP protocol
|
|
8
|
+
console.error(chalk.dim(`repomemory MCP server starting...`));
|
|
9
|
+
console.error(chalk.dim(` Root: ${repoRoot}`));
|
|
10
|
+
console.error(chalk.dim(` Context: ${config.contextDir}/`));
|
|
11
|
+
await startMcpServer(repoRoot, config);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=serve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../src/commands/serve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAyB;IAC1D,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAC9C,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IAEpC,yDAAyD;IACzD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC,CAAC;IAC9D,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,QAAQ,EAAE,CAAC,CAAC,CAAC;IAChD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,MAAM,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;IAE7D,MAAM,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":"AAIA,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,iBAgB1B"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
export async function setupCommand(tool, options) {
|
|
5
|
+
const repoRoot = options.dir || process.cwd();
|
|
6
|
+
switch (tool) {
|
|
7
|
+
case "claude":
|
|
8
|
+
return setupClaude(repoRoot);
|
|
9
|
+
case "cursor":
|
|
10
|
+
return setupCursor(repoRoot);
|
|
11
|
+
case "copilot":
|
|
12
|
+
return setupCopilot(repoRoot);
|
|
13
|
+
default:
|
|
14
|
+
console.log(chalk.red(`Unknown tool: ${tool}`));
|
|
15
|
+
console.log(chalk.dim("Supported: claude, cursor, copilot"));
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function setupClaude(repoRoot) {
|
|
20
|
+
// Add MCP server to .claude/settings.json or project-level settings
|
|
21
|
+
const claudeDir = join(repoRoot, ".claude");
|
|
22
|
+
mkdirSync(claudeDir, { recursive: true });
|
|
23
|
+
const settingsPath = join(claudeDir, "settings.json");
|
|
24
|
+
let settings = {};
|
|
25
|
+
if (existsSync(settingsPath)) {
|
|
26
|
+
try {
|
|
27
|
+
settings = JSON.parse(readFileSync(settingsPath, "utf-8"));
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// Start fresh
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// Add MCP server config
|
|
34
|
+
const mcpServers = (settings.mcpServers || {});
|
|
35
|
+
mcpServers["repomemory"] = {
|
|
36
|
+
command: "npx",
|
|
37
|
+
args: ["-y", "repomemory", "serve"],
|
|
38
|
+
};
|
|
39
|
+
settings.mcpServers = mcpServers;
|
|
40
|
+
writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n");
|
|
41
|
+
// Also update CLAUDE.md to point to .context/
|
|
42
|
+
const claudeMdPath = join(repoRoot, "CLAUDE.md");
|
|
43
|
+
const contextNote = `\n## Repository Context\nThis repo uses [repomemory](https://github.com/repomemory/repomemory) for persistent AI memory.\nRead \`.context/index.md\` for instant orientation. The MCP server provides \`context_search\` and \`context_write\` tools.\n`;
|
|
44
|
+
if (existsSync(claudeMdPath)) {
|
|
45
|
+
const existing = readFileSync(claudeMdPath, "utf-8");
|
|
46
|
+
if (!existing.includes("repomemory")) {
|
|
47
|
+
writeFileSync(claudeMdPath, existing + contextNote);
|
|
48
|
+
console.log(` ${chalk.green("✓")} Updated CLAUDE.md with repomemory reference`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
console.log(chalk.green("\n✓ Claude Code configured!\n"));
|
|
52
|
+
console.log(chalk.bold("Added to .claude/settings.json:"));
|
|
53
|
+
console.log(chalk.dim(JSON.stringify({ "repomemory": mcpServers["repomemory"] }, null, 2)));
|
|
54
|
+
console.log();
|
|
55
|
+
console.log(chalk.dim("The MCP server will auto-start when Claude Code opens this project."));
|
|
56
|
+
}
|
|
57
|
+
function setupCursor(repoRoot) {
|
|
58
|
+
// Create .cursor/rules/repomemory.mdc
|
|
59
|
+
const cursorDir = join(repoRoot, ".cursor", "rules");
|
|
60
|
+
mkdirSync(cursorDir, { recursive: true });
|
|
61
|
+
const ruleContent = `---
|
|
62
|
+
description: Repository context and memory system
|
|
63
|
+
globs: **/*
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
# Repository Context
|
|
67
|
+
|
|
68
|
+
This project uses repomemory for persistent AI memory.
|
|
69
|
+
|
|
70
|
+
## Quick Orientation
|
|
71
|
+
Read \`.context/index.md\` for immediate project understanding.
|
|
72
|
+
|
|
73
|
+
## Before Making Changes
|
|
74
|
+
- Search \`.context/facts/\` for architecture documentation
|
|
75
|
+
- Check \`.context/decisions/\` before proposing alternative approaches
|
|
76
|
+
- Review \`.context/regressions/\` before touching fragile code
|
|
77
|
+
|
|
78
|
+
## During Your Session
|
|
79
|
+
- Document important discoveries in \`.context/sessions/\`
|
|
80
|
+
- If you find a bug pattern, note it in \`.context/regressions/\`
|
|
81
|
+
- If you make an architectural decision, record it in \`.context/decisions/\`
|
|
82
|
+
|
|
83
|
+
## Context Files
|
|
84
|
+
\`\`\`
|
|
85
|
+
.context/
|
|
86
|
+
├── index.md — Quick orientation
|
|
87
|
+
├── facts/ — Architecture, patterns, integrations
|
|
88
|
+
├── decisions/ — Why things are this way
|
|
89
|
+
├── regressions/ — Known gotchas and past bugs
|
|
90
|
+
├── sessions/ — Session summaries
|
|
91
|
+
└── changelog/ — Monthly change logs
|
|
92
|
+
\`\`\`
|
|
93
|
+
`;
|
|
94
|
+
writeFileSync(join(cursorDir, "repomemory.mdc"), ruleContent);
|
|
95
|
+
console.log(chalk.green("\n✓ Cursor configured!\n"));
|
|
96
|
+
console.log(` ${chalk.green("✓")} Created .cursor/rules/repomemory.mdc`);
|
|
97
|
+
console.log();
|
|
98
|
+
console.log(chalk.dim("Cursor will auto-load the repomemory rule for all files."));
|
|
99
|
+
}
|
|
100
|
+
function setupCopilot(repoRoot) {
|
|
101
|
+
// Create .github/copilot-instructions.md addition
|
|
102
|
+
const githubDir = join(repoRoot, ".github");
|
|
103
|
+
mkdirSync(githubDir, { recursive: true });
|
|
104
|
+
const instructionsPath = join(githubDir, "copilot-instructions.md");
|
|
105
|
+
const content = `# Repository Context
|
|
106
|
+
|
|
107
|
+
This project uses repomemory for persistent AI memory.
|
|
108
|
+
|
|
109
|
+
## Before Starting Work
|
|
110
|
+
1. Read \`.context/index.md\` for project orientation
|
|
111
|
+
2. Check \`.context/facts/\` for relevant architecture docs
|
|
112
|
+
3. Review \`.context/decisions/\` before proposing alternatives
|
|
113
|
+
4. Check \`.context/regressions/\` for known issues
|
|
114
|
+
|
|
115
|
+
## Context Structure
|
|
116
|
+
- \`.context/facts/\` — Architecture, patterns, integrations
|
|
117
|
+
- \`.context/decisions/\` — Architectural decisions with rationale
|
|
118
|
+
- \`.context/regressions/\` — Known issues and past bugs
|
|
119
|
+
- \`.context/sessions/\` — AI session summaries
|
|
120
|
+
- \`.context/changelog/\` — Monthly change logs
|
|
121
|
+
`;
|
|
122
|
+
let existing = "";
|
|
123
|
+
if (existsSync(instructionsPath)) {
|
|
124
|
+
existing = readFileSync(instructionsPath, "utf-8");
|
|
125
|
+
if (existing.includes("repomemory")) {
|
|
126
|
+
console.log(chalk.yellow("⚠ copilot-instructions.md already references repomemory"));
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
writeFileSync(instructionsPath, existing + "\n" + content);
|
|
131
|
+
console.log(chalk.green("\n✓ GitHub Copilot configured!\n"));
|
|
132
|
+
console.log(` ${chalk.green("✓")} Updated .github/copilot-instructions.md`);
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAAY,EACZ,OAAyB;IAEzB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAE9C,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,QAAQ;YACX,OAAO,WAAW,CAAC,QAAQ,CAAC,CAAC;QAC/B,KAAK,QAAQ;YACX,OAAO,WAAW,CAAC,QAAQ,CAAC,CAAC;QAC/B,KAAK,SAAS;YACZ,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAC;QAChC;YACE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC,CAAC;YAChD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC,CAAC;YAC7D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,QAAgB;IACnC,oEAAoE;IACpE,MAAM,SAAS,GAAG,IAAI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,kDAAkD;IAClD,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC5C,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAE1C,MAAM,gBAAgB,GAAG,IAAI,CAAC,SAAS,EAAE,yBAAyB,CAAC,CAAC;IACpE,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;CAgBjB,CAAC;IAEA,IAAI,QAAQ,GAAG,EAAE,CAAC;IAClB,IAAI,UAAU,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACjC,QAAQ,GAAG,YAAY,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;QACnD,IAAI,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;YACpC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,0DAA0D,CAAC,CAAC,CAAC;YACtF,OAAO;QACT,CAAC;IACH,CAAC;IAED,aAAa,CAAC,gBAAgB,EAAE,QAAQ,GAAG,IAAI,GAAG,OAAO,CAAC,CAAC;IAE3D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC,CAAC;IAC7D,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;AAC/E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/commands/sync.ts"],"names":[],"mappings":"AAQA,wBAAsB,WAAW,CAAC,OAAO,EAAE;IACzC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,iBAkFA"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
import { loadConfig } from "../lib/config.js";
|
|
5
|
+
import { ContextStore } from "../lib/context-store.js";
|
|
6
|
+
import { SearchIndex } from "../lib/search.js";
|
|
7
|
+
import { getGitDiffSummary } from "../lib/git.js";
|
|
8
|
+
export async function syncCommand(options) {
|
|
9
|
+
const repoRoot = options.dir || process.cwd();
|
|
10
|
+
const config = loadConfig(repoRoot);
|
|
11
|
+
const store = new ContextStore(repoRoot, config);
|
|
12
|
+
if (!store.exists()) {
|
|
13
|
+
console.log(chalk.red("✗ No .context/ directory found. Run `repomemory init` first."));
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
// Determine sync period
|
|
17
|
+
const now = new Date();
|
|
18
|
+
const yearMonth = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}`;
|
|
19
|
+
// Check last sync timestamp
|
|
20
|
+
const syncFile = join(store.path, ".last-sync");
|
|
21
|
+
let lastSync = options.since || "";
|
|
22
|
+
if (!lastSync && existsSync(syncFile)) {
|
|
23
|
+
lastSync = readFileSync(syncFile, "utf-8").trim();
|
|
24
|
+
}
|
|
25
|
+
if (!lastSync) {
|
|
26
|
+
// Default to 30 days ago
|
|
27
|
+
const thirtyDaysAgo = new Date(now.getTime() - 30 * 24 * 60 * 60 * 1000);
|
|
28
|
+
lastSync = thirtyDaysAgo.toISOString().split("T")[0];
|
|
29
|
+
}
|
|
30
|
+
console.log(chalk.bold(`\n📅 Syncing git history since ${lastSync}...\n`));
|
|
31
|
+
const commits = getGitDiffSummary(repoRoot, lastSync);
|
|
32
|
+
if (!commits.trim()) {
|
|
33
|
+
console.log(chalk.dim(" No new commits since last sync."));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const commitLines = commits.split("\n").filter(Boolean);
|
|
37
|
+
console.log(` ${chalk.cyan("New commits:")} ${commitLines.length}`);
|
|
38
|
+
// Build changelog entry
|
|
39
|
+
const changelogContent = [
|
|
40
|
+
`# Changelog — ${yearMonth}`,
|
|
41
|
+
"",
|
|
42
|
+
`*Synced: ${now.toISOString().split("T")[0]}*`,
|
|
43
|
+
"",
|
|
44
|
+
"## Commits",
|
|
45
|
+
"",
|
|
46
|
+
...commitLines.map((line) => `- ${line}`),
|
|
47
|
+
"",
|
|
48
|
+
].join("\n");
|
|
49
|
+
// Write or append to monthly changelog
|
|
50
|
+
const changelogFile = `${yearMonth}.md`;
|
|
51
|
+
const existingChangelog = store.readEntry("changelog", changelogFile);
|
|
52
|
+
if (existingChangelog) {
|
|
53
|
+
// Append new commits section
|
|
54
|
+
const appendContent = [
|
|
55
|
+
"",
|
|
56
|
+
`## Synced ${now.toISOString().split("T")[0]}`,
|
|
57
|
+
"",
|
|
58
|
+
...commitLines.map((line) => `- ${line}`),
|
|
59
|
+
"",
|
|
60
|
+
].join("\n");
|
|
61
|
+
store.appendEntry("changelog", changelogFile, appendContent);
|
|
62
|
+
console.log(` ${chalk.green("✓")} Appended to changelog/${changelogFile}`);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
store.writeEntry("changelog", changelogFile, changelogContent);
|
|
66
|
+
console.log(` ${chalk.green("✓")} Created changelog/${changelogFile}`);
|
|
67
|
+
}
|
|
68
|
+
// Update last sync timestamp
|
|
69
|
+
writeFileSync(syncFile, now.toISOString().split("T")[0]);
|
|
70
|
+
// Rebuild search index
|
|
71
|
+
const searchIndex = new SearchIndex(store.path, store);
|
|
72
|
+
searchIndex.rebuild();
|
|
73
|
+
searchIndex.close();
|
|
74
|
+
console.log(` ${chalk.green("✓")} Search index updated`);
|
|
75
|
+
console.log(chalk.bold("\n✨ Sync complete!\n"));
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=sync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../src/commands/sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE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AC,uBAAuB,CAAC,CAAC;IAE1D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC;AAClD,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { initCommand } from "./commands/init.js";
|
|
4
|
+
import { analyzeCommand } from "./commands/analyze.js";
|
|
5
|
+
import { syncCommand } from "./commands/sync.js";
|
|
6
|
+
import { serveCommand } from "./commands/serve.js";
|
|
7
|
+
import { setupCommand } from "./commands/setup.js";
|
|
8
|
+
const program = new Command();
|
|
9
|
+
program
|
|
10
|
+
.name("repomemory")
|
|
11
|
+
.description("Persistent, structured memory for AI coding agents. Your repo remembers what every session learned.")
|
|
12
|
+
.version("0.1.0");
|
|
13
|
+
program
|
|
14
|
+
.command("init")
|
|
15
|
+
.description("Initialize .context/ directory in the current repo")
|
|
16
|
+
.option("-d, --dir <path>", "Repository root directory", process.cwd())
|
|
17
|
+
.option("-p, --provider <provider>", "AI provider (anthropic, openai, gemini, grok)", "anthropic")
|
|
18
|
+
.action(initCommand);
|
|
19
|
+
program
|
|
20
|
+
.command("analyze")
|
|
21
|
+
.description("Analyze the repository with AI and populate .context/ with structured knowledge")
|
|
22
|
+
.option("-d, --dir <path>", "Repository root directory", process.cwd())
|
|
23
|
+
.option("-p, --provider <provider>", "AI provider (anthropic, openai, gemini, grok)")
|
|
24
|
+
.option("-m, --model <model>", "Model to use (provider-specific)")
|
|
25
|
+
.option("-v, --verbose", "Show detailed output", false)
|
|
26
|
+
.action(analyzeCommand);
|
|
27
|
+
program
|
|
28
|
+
.command("sync")
|
|
29
|
+
.description("Sync recent git history into .context/changelog/")
|
|
30
|
+
.option("-d, --dir <path>", "Repository root directory", process.cwd())
|
|
31
|
+
.option("-s, --since <date>", "Sync commits since this date (YYYY-MM-DD)")
|
|
32
|
+
.action(syncCommand);
|
|
33
|
+
program
|
|
34
|
+
.command("serve")
|
|
35
|
+
.description("Start the MCP server for AI agent integration")
|
|
36
|
+
.option("-d, --dir <path>", "Repository root directory", process.cwd())
|
|
37
|
+
.action(serveCommand);
|
|
38
|
+
program
|
|
39
|
+
.command("setup <tool>")
|
|
40
|
+
.description("Configure AI tool integration (claude, cursor, copilot)")
|
|
41
|
+
.option("-d, --dir <path>", "Repository root directory", process.cwd())
|
|
42
|
+
.action(setupCommand);
|
|
43
|
+
program
|
|
44
|
+
.command("status")
|
|
45
|
+
.description("Show the current state of .context/")
|
|
46
|
+
.option("-d, --dir <path>", "Repository root directory", process.cwd())
|
|
47
|
+
.action(async (options) => {
|
|
48
|
+
const { default: chalk } = await import("chalk");
|
|
49
|
+
const { loadConfig } = await import("./lib/config.js");
|
|
50
|
+
const { ContextStore } = await import("./lib/context-store.js");
|
|
51
|
+
const repoRoot = options.dir || process.cwd();
|
|
52
|
+
const config = loadConfig(repoRoot);
|
|
53
|
+
const store = new ContextStore(repoRoot, config);
|
|
54
|
+
if (!store.exists()) {
|
|
55
|
+
console.log(chalk.red("✗ No .context/ directory found."));
|
|
56
|
+
console.log(chalk.dim(" Run `repomemory init` to get started."));
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
const stats = store.getStats();
|
|
60
|
+
const entries = store.listEntries();
|
|
61
|
+
console.log(chalk.bold("\n📊 repomemory status\n"));
|
|
62
|
+
console.log(` ${chalk.cyan("Total files:")} ${stats.totalFiles}`);
|
|
63
|
+
console.log(` ${chalk.cyan("Total size:")} ${(stats.totalSize / 1024).toFixed(1)}KB`);
|
|
64
|
+
console.log();
|
|
65
|
+
for (const [category, count] of Object.entries(stats.categories)) {
|
|
66
|
+
console.log(` ${chalk.bold(category + "/")} (${count} files)`);
|
|
67
|
+
const catEntries = entries.filter((e) => e.category === category);
|
|
68
|
+
for (const entry of catEntries) {
|
|
69
|
+
const sizeKb = (entry.sizeBytes / 1024).toFixed(1);
|
|
70
|
+
console.log(` ${chalk.dim("•")} ${entry.filename} — ${entry.title} (${sizeKb}KB)`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
console.log();
|
|
74
|
+
console.log(chalk.dim(` Provider: ${config.provider} | Model: ${config.model}`));
|
|
75
|
+
});
|
|
76
|
+
// Global error handler — no stack traces for users
|
|
77
|
+
process.on("uncaughtException", (err) => {
|
|
78
|
+
const msg = err.message || String(err);
|
|
79
|
+
// Known error patterns → friendly messages
|
|
80
|
+
if (msg.includes("API key")) {
|
|
81
|
+
console.error(`\n✗ ${msg}`);
|
|
82
|
+
console.error("\n Set your API key and try again:");
|
|
83
|
+
console.error(" export ANTHROPIC_API_KEY=sk-ant-...");
|
|
84
|
+
console.error(" export OPENAI_API_KEY=sk-...");
|
|
85
|
+
console.error(" export GEMINI_API_KEY=...");
|
|
86
|
+
console.error(" export GROK_API_KEY=...");
|
|
87
|
+
}
|
|
88
|
+
else if (msg.includes("ENOENT")) {
|
|
89
|
+
console.error(`\n✗ File or directory not found: ${msg.split("'")[1] || "unknown"}`);
|
|
90
|
+
}
|
|
91
|
+
else if (msg.includes("EACCES")) {
|
|
92
|
+
console.error(`\n✗ Permission denied. Try running with appropriate permissions.`);
|
|
93
|
+
}
|
|
94
|
+
else if (msg.includes("fetch failed") || msg.includes("ECONNREFUSED")) {
|
|
95
|
+
console.error(`\n✗ Network error. Check your internet connection and try again.`);
|
|
96
|
+
}
|
|
97
|
+
else if (msg.includes("401") || msg.includes("authentication")) {
|
|
98
|
+
console.error(`\n✗ Authentication failed. Check your API key is valid.`);
|
|
99
|
+
}
|
|
100
|
+
else if (msg.includes("429") || msg.includes("rate limit")) {
|
|
101
|
+
console.error(`\n✗ Rate limited. Wait a moment and try again.`);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
console.error(`\n✗ ${msg}`);
|
|
105
|
+
}
|
|
106
|
+
process.exit(1);
|
|
107
|
+
});
|
|
108
|
+
program.parse();
|
|
109
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,YAAY,CAAC;KAClB,WAAW,CACV,qGAAqG,CACtG;KACA,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,oDAAoD,CAAC;KACjE,MAAM,CAAC,kBAAkB,EAAE,2BAA2B,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;KACtE,MAAM,CACL,2BAA2B,EAC3B,+CAA+C,EAC/C,WAAW,CACZ;KACA,MAAM,CAAC,WAAW,CAAC,CAAC;AAEvB,OAAO;KACJ,OAAO,CAAC,SAAS,CAAC;KAClB,WAAW,CACV,iFAAiF,CAClF;KACA,MAAM,CAAC,kBAAkB,EAAE,2BAA2B,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;KACtE,MAAM,CACL,2BAA2B,EAC3B,+CAA+C,CAChD;KACA,MAAM,CAAC,qBAAqB,EAAE,kCAAkC,CAAC;KACjE,MAAM,CAAC,eAAe,EAAE,sBAAsB,EAAE,KAAK,CAAC;KACtD,MAAM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C;SAAM,IAAI,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAClC,OAAO,CAAC,KAAK,CAAC,kEAAkE,CAAC,CAAC;IACpF,CAAC;SAAM,IAAI,GAAG,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;QACxE,OAAO,CAAC,KAAK,CAAC,kEAAkE,CAAC,CAAC;IACpF,CAAC;SAAM,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACjE,OAAO,CAAC,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC3E,CAAC;SAAM,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QAC7D,OAAO,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;IAClE,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { RepoContextConfig } from "./config.js";
|
|
2
|
+
export interface AIMessage {
|
|
3
|
+
role: "user" | "assistant" | "system";
|
|
4
|
+
content: string;
|
|
5
|
+
}
|
|
6
|
+
export interface AIResponse {
|
|
7
|
+
content: string;
|
|
8
|
+
tokensUsed?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface AIProvider {
|
|
11
|
+
name: string;
|
|
12
|
+
generate(messages: AIMessage[], options?: {
|
|
13
|
+
maxTokens?: number;
|
|
14
|
+
temperature?: number;
|
|
15
|
+
}): Promise<AIResponse>;
|
|
16
|
+
}
|
|
17
|
+
export declare function createProvider(config: RepoContextConfig): Promise<AIProvider>;
|
|
18
|
+
//# sourceMappingURL=ai-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-provider.d.ts","sourceRoot":"","sources":["../../src/lib/ai-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,QAAQ,EAAE,SAAS,EAAE,EAAE,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAC9G;AAED,wBAAsB,cAAc,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CAenF"}
|