fix: preserve agent memory files when installing RA-H rules
- Add RA-H graph memory as a marked section instead of replacing files - Make install-rules idempotent for AGENTS.md and CLAUDE.md - Document the demo-safe memory file setup command Generated with Claude Code
This commit is contained in:
@@ -217,6 +217,8 @@ If you need a frozen version for debugging, pin it explicitly and restart the cl
|
|||||||
Suggested snippet:
|
Suggested snippet:
|
||||||
|
|
||||||
```md
|
```md
|
||||||
|
## RA-H Graph Memory
|
||||||
|
|
||||||
You are helping build a thoughtful graph of atomic units of context.
|
You are helping build a thoughtful graph of atomic units of context.
|
||||||
|
|
||||||
- Use `queryNodes` for direct lookup of a specific existing node.
|
- Use `queryNodes` for direct lookup of a specific existing node.
|
||||||
@@ -226,6 +228,12 @@ You are helping build a thoughtful graph of atomic units of context.
|
|||||||
- Preserve the user's wording in `source` for user-authored ideas unless they explicitly want a rewrite.
|
- Preserve the user's wording in `source` for user-authored ideas unless they explicitly want a rewrite.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Or install that guidance into the repo memory file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx -y ra-h-mcp-server@latest install-rules --client codex --target . --yes
|
||||||
|
```
|
||||||
|
|
||||||
Available tools:
|
Available tools:
|
||||||
|
|
||||||
| Tool | What it does |
|
| Tool | What it does |
|
||||||
|
|||||||
@@ -88,9 +88,17 @@ Once connected, the agent should:
|
|||||||
If you use external agents through this MCP server, you may add one short instruction line to your agent memory file (`AGENTS.md`, `CLAUDE.md`, etc.) as optional reinforcement:
|
If you use external agents through this MCP server, you may add one short instruction line to your agent memory file (`AGENTS.md`, `CLAUDE.md`, etc.) as optional reinforcement:
|
||||||
|
|
||||||
```md
|
```md
|
||||||
|
## RA-H Graph Memory
|
||||||
|
|
||||||
Retrieve relevant RA-H context before substantive work, search before creating, and keep durable writeback prompts brief and confirmation-gated.
|
Retrieve relevant RA-H context before substantive work, search before creating, and keep durable writeback prompts brief and confirmation-gated.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Install or refresh that guidance without replacing the rest of the memory file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx -y ra-h-mcp-server@latest install-rules --client codex --target . --yes
|
||||||
|
```
|
||||||
|
|
||||||
RA-H should still work well without this line. The MCP tools, server instructions, skills, and docs are meant to carry the core behavior on their own.
|
RA-H should still work well without this line. The MCP tools, server instructions, skills, and docs are meant to carry the core behavior on their own.
|
||||||
|
|
||||||
Do not create contradictory instruction files. Prefer one short reinforcement line over a pile of overlapping guidance.
|
Do not create contradictory instruction files. Prefer one short reinforcement line over a pile of overlapping guidance.
|
||||||
|
|||||||
@@ -344,7 +344,9 @@ function validateClient(client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function rulesSnippet() {
|
function rulesSnippet() {
|
||||||
return `You are helping build a thoughtful graph of atomic units of context.
|
return `## RA-H Graph Memory
|
||||||
|
|
||||||
|
You are helping build a thoughtful graph of atomic units of context.
|
||||||
|
|
||||||
- Before substantive work that touches the user's projects, ideas, people, decisions, or prior context, retrieve relevant graph context from RA-H.
|
- Before substantive work that touches the user's projects, ideas, people, decisions, or prior context, retrieve relevant graph context from RA-H.
|
||||||
- Use queryNodes for direct lookup of a specific existing node.
|
- Use queryNodes for direct lookup of a specific existing node.
|
||||||
@@ -356,6 +358,19 @@ function rulesSnippet() {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function mergeRulesFile(existing, content) {
|
||||||
|
const start = '<!-- RA-H_GRAPH_MEMORY_START -->';
|
||||||
|
const end = '<!-- RA-H_GRAPH_MEMORY_END -->';
|
||||||
|
const block = `${start}\n${content.trimEnd()}\n${end}`;
|
||||||
|
const pattern = new RegExp(`${start}[\\s\\S]*?${end}`);
|
||||||
|
|
||||||
|
if (pattern.test(existing)) {
|
||||||
|
return `${existing.replace(pattern, block).trimEnd()}\n`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${existing.trimEnd()}${existing.trim() ? '\n\n' : ''}${block}\n`;
|
||||||
|
}
|
||||||
|
|
||||||
function rulesTarget(client, target) {
|
function rulesTarget(client, target) {
|
||||||
const base = expandPath(target || process.cwd());
|
const base = expandPath(target || process.cwd());
|
||||||
if (client === 'cursor') return path.join(base, '.cursor', 'rules', 'ra-h.mdc');
|
if (client === 'cursor') return path.join(base, '.cursor', 'rules', 'ra-h.mdc');
|
||||||
@@ -415,8 +430,9 @@ function commandInstallRules(args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fs.mkdirSync(path.dirname(targetPath), { recursive: true });
|
fs.mkdirSync(path.dirname(targetPath), { recursive: true });
|
||||||
fs.writeFileSync(targetPath, content);
|
const existing = fs.existsSync(targetPath) ? fs.readFileSync(targetPath, 'utf8') : '';
|
||||||
log(`Wrote rules to ${targetPath}`);
|
fs.writeFileSync(targetPath, mergeRulesFile(existing, content));
|
||||||
|
log(`Updated rules in ${targetPath}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function commandSetup(args) {
|
function commandSetup(args) {
|
||||||
|
|||||||
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "ra-h-mcp-server",
|
"name": "ra-h-mcp-server",
|
||||||
"version": "3.2.1",
|
"version": "3.2.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "ra-h-mcp-server",
|
"name": "ra-h-mcp-server",
|
||||||
"version": "3.2.1",
|
"version": "3.2.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@modelcontextprotocol/sdk": "^1.0.0",
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ra-h-mcp-server",
|
"name": "ra-h-mcp-server",
|
||||||
"version": "3.2.1",
|
"version": "3.2.2",
|
||||||
"description": "Connect Claude Code/Desktop to your RA-H knowledge base. Direct SQLite access to an existing RA-H database.",
|
"description": "Connect Claude Code/Desktop to your RA-H knowledge base. Direct SQLite access to an existing RA-H database.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
@@ -133,6 +133,8 @@ Recommended guidance:
|
|||||||
Suggested memory-file snippet:
|
Suggested memory-file snippet:
|
||||||
|
|
||||||
```md
|
```md
|
||||||
|
## RA-H Graph Memory
|
||||||
|
|
||||||
You are helping build a thoughtful graph of atomic units of context.
|
You are helping build a thoughtful graph of atomic units of context.
|
||||||
|
|
||||||
- Use `queryNodes` for direct lookup of a specific existing node.
|
- Use `queryNodes` for direct lookup of a specific existing node.
|
||||||
@@ -141,3 +143,9 @@ You are helping build a thoughtful graph of atomic units of context.
|
|||||||
- `description` should state plainly what the thing is first, then why it belongs and current status.
|
- `description` should state plainly what the thing is first, then why it belongs and current status.
|
||||||
- Preserve the user's wording in `source` for user-authored ideas unless they explicitly want a rewrite.
|
- Preserve the user's wording in `source` for user-authored ideas unless they explicitly want a rewrite.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The installer can add or refresh this section without replacing the rest of the memory file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx -y ra-h-mcp-server@latest install-rules --client codex --target . --yes
|
||||||
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user