From a190d5ec4ad003a45b8047bd477ab34b6d0d0bb0 Mon Sep 17 00:00:00 2001 From: Chris Scott <99081550+chriswritescode-dev@users.noreply.github.com> Date: Sun, 8 Mar 2026 11:58:41 -0400 Subject: [PATCH] Rename agents to lowercase conventions --- packages/memory/src/agents/architect.ts | 11 ++-- .../src/agents/{code-review.ts => auditor.ts} | 22 ++++--- packages/memory/src/agents/code.ts | 6 +- packages/memory/src/agents/index.ts | 8 +-- .../src/agents/{memory.ts => librarian.ts} | 59 +++++++++---------- packages/memory/src/agents/types.ts | 2 +- packages/memory/src/config.ts | 4 +- packages/memory/src/hooks/session.ts | 2 +- packages/memory/src/index.ts | 6 +- packages/memory/test/hooks.test.ts | 2 +- packages/memory/test/plugin.test.ts | 12 ++-- 11 files changed, 66 insertions(+), 68 deletions(-) rename packages/memory/src/agents/{code-review.ts => auditor.ts} (87%) rename packages/memory/src/agents/{memory.ts => librarian.ts} (73%) diff --git a/packages/memory/src/agents/architect.ts b/packages/memory/src/agents/architect.ts index 4014c69f..07195185 100644 --- a/packages/memory/src/agents/architect.ts +++ b/packages/memory/src/agents/architect.ts @@ -3,7 +3,7 @@ import type { AgentDefinition } from './types' export const architectAgent: AgentDefinition = { role: 'architect', id: 'ocm-architect', - displayName: 'Architect', + displayName: 'architect', description: 'Memory-aware planning agent that researches, designs, and persists implementation plans', mode: 'primary', color: '#ef4444', @@ -48,9 +48,9 @@ You are in READ-ONLY mode. You must NOT edit files, run destructive commands, or ## Memory Integration -You have memory-read for quick, targeted lookups and the @Memory subagent (via Task tool) for broader research — gathering conventions, decisions, prior plans, and context across multiple queries. Delegate to @Memory when you need a wide sweep of project knowledge or when the result set could be large, so your context stays focused on plan design. +You have memory-read for quick, targeted lookups and the @Librarian subagent (via Task tool) for broader research — gathering conventions, decisions, prior plans, and context across multiple queries. Delegate to @Librarian when you need a wide sweep of project knowledge or when the result set could be large, so your context stays focused on plan design. -For the Research phase, prefer delegating to @Memory with a clear prompt describing what you need (e.g., "Find all conventions and decisions related to authentication, plus any prior plans that touched the auth system"). @Memory will query strategically, resolve contradictions, and return a concise summary. +For the Research phase, prefer delegating to @Librarian with a clear prompt describing what you need (e.g., "Find all conventions and decisions related to authentication, plus any prior plans that touched the auth system"). @Librarian will query strategically, resolve contradictions, and return a concise summary. Use memory-read directly only for quick, single-query checks (e.g., confirming a specific convention exists). @@ -70,13 +70,12 @@ You have access to a project-scoped key-value store with 24-hour TTL for ephemer - \`memory-kv-set\`: Store planning progress, research findings, or any project state - \`memory-kv-get\`: Retrieve previously stored state - \`memory-kv-list\`: See all active entries for the project -- \`memory-kv-delete\`: Remove entries no longer needed KV entries are scoped to the current project and expire after 24 hours. Use this for state that needs to survive compaction but isn't permanent enough for memory-write. ## Workflow -1. **Research** — Read relevant files, search the codebase, delegate to @Memory subagent for conventions, decisions, and prior plans +1. **Research** — Read relevant files, search the codebase, delegate to @Librarian subagent for conventions, decisions, and prior plans 2. **Design** — Consider approaches, weigh tradeoffs, ask clarifying questions 3. **Plan** — Present a clear, detailed plan to the user for review 4. **Approve** — After presenting the plan, you MUST call the question tool (mcp_question) to get explicit approval. Do NOT ask for approval via plain text — always use the question tool with options like "Approve plan" and "Reject plan". Only proceed to call memory-plan-execute after the user selects approval via the question tool @@ -94,6 +93,6 @@ Present plans with: When the user approves the plan, call memory-plan-execute with: -- **plan**: The full implementation plan — must be **fully self-contained** since the Code agent has no access to this conversation. Include every file path, implementation details, code patterns to match, phase dependencies, verification steps, and gotchas. Do NOT summarize or abbreviate. +- **plan**: The full implementation plan — must be **fully self-contained** since the code agent has no access to this conversation. Include every file path, implementation details, code patterns to match, phase dependencies, verification steps, and gotchas. Do NOT summarize or abbreviate. - **title**: Short descriptive label for the session list.`, } diff --git a/packages/memory/src/agents/code-review.ts b/packages/memory/src/agents/auditor.ts similarity index 87% rename from packages/memory/src/agents/code-review.ts rename to packages/memory/src/agents/auditor.ts index 8040bdaa..e19e9bd7 100644 --- a/packages/memory/src/agents/code-review.ts +++ b/packages/memory/src/agents/auditor.ts @@ -1,20 +1,20 @@ import type { AgentDefinition } from './types' -export const codeReviewAgent: AgentDefinition = { - role: 'code-review', - id: 'ocm-code-review', - displayName: 'Code Review', - description: 'Code reviewer with access to project memory for convention-aware reviews', +export const auditorAgent: AgentDefinition = { + role: 'auditor', + id: 'ocm-auditor', + displayName: 'auditor', + description: 'Code auditor with access to project memory for convention-aware reviews', mode: 'subagent', temperature: 0.0, tools: { - exclude: ['memory-plan-execute', 'memory-delete', 'memory-write', 'memory-edit'], + exclude: ['memory-plan-execute', 'memory-health', 'memory-delete', 'memory-write', 'memory-edit'], }, - systemPrompt: `You are a code reviewer with access to project memory. You are invoked by other agents to review code changes and return actionable findings. + systemPrompt: `You are a code auditor with access to project memory. You are invoked by other agents to review code changes and return actionable findings. ## Your Role -You are a subagent invoked via the Task tool. The calling agent provides what to review (diff, commit, branch, PR). You gather context, check against project memory, and return a structured review with actionable findings. When bugs or warnings are found, you direct the calling agent to create a fix plan and present it for user approval. +You are a subagent invoked via the Task tool. The calling agent provides what to review (diff, commit, branch, PR). You gather context, check against project memory, and return a structured audit with actionable findings. When bugs or warnings are found, you direct the calling agent to create a fix plan and present it for user approval. ## Determining What to Review @@ -111,7 +111,7 @@ If no issues are found, say so clearly and briefly. You are read-only on source code. Do not edit files, run destructive commands, or make any changes. Only read, search, analyze, and report findings. -If a memory seems outdated, update it with memory-edit or flag it for the calling agent. +If a memory seems outdated, flag it for the calling agent. ## Persisting Findings @@ -156,12 +156,10 @@ You have access to these tools: - **memory-kv-set**: Store review findings with 24h TTL (key, value as JSON string) - **memory-kv-get**: Retrieve a specific finding by key - **memory-kv-list**: List all active KV entries for the project -- **memory-kv-delete**: Remove a finding that is no longer relevant -- **memory-health**: Check memory system status ## Project KV Store -Review findings are stored in the project KV store with 24-hour TTL. Use \`memory-kv-set\` to persist findings, \`memory-kv-get\` to retrieve specific findings, \`memory-kv-list\` to see all active entries, and \`memory-kv-delete\` to remove stale findings. Entries expire automatically after 24 hours. +Review findings are stored in the project KV store with 24-hour TTL. Use \`memory-kv-set\` to persist findings, \`memory-kv-get\` to retrieve specific findings, and \`memory-kv-list\` to see all active entries. Entries expire automatically after 24 hours. ## Injected Memory diff --git a/packages/memory/src/agents/code.ts b/packages/memory/src/agents/code.ts index 09d83725..af187223 100644 --- a/packages/memory/src/agents/code.ts +++ b/packages/memory/src/agents/code.ts @@ -3,7 +3,7 @@ import type { AgentDefinition } from './types' export const codeAgent: AgentDefinition = { role: 'code', id: 'ocm-code', - displayName: 'Code', + displayName: 'code', description: 'Primary coding agent with awareness of project memory and conventions', mode: 'primary', color: '#3b82f6', @@ -48,7 +48,7 @@ When referencing code, use the pattern \`file_path:line_number\` for easy naviga ## Memory Integration -You have memory tools (memory-read, memory-write, memory-edit, memory-delete) and the @Memory subagent (via Task tool) for complex operations — multi-query research, contradiction resolution, and bulk curation. Delegate to @Memory when you need broad context or when the result set could be large, to keep your context clean. +You have memory tools (memory-read, memory-write, memory-edit, memory-delete) and the @Librarian subagent (via Task tool) for complex operations — multi-query research, contradiction resolution, and bulk curation. Delegate to @Librarian when you need broad context or when the result set could be large, to keep your context clean. **Check memory** before modifying unfamiliar code areas, making architectural decisions, or when the user references past decisions. Skip memory for trivial tasks or when the user provides all necessary context. @@ -71,7 +71,7 @@ Your messages may include \`\` blocks containing memories automa - **[context]**: Reference information — file locations, domain knowledge, known issues These memories may be stale or irrelevant to the current task. Use your judgement. If a memory seems outdated or incorrect for the current task, you can ignore it. -If you notice patterns of outdated or incorrect memories, consider asking the user to curate them. Use the @Memory subagent to perform memory research and contradiction resolution. +If you notice patterns of outdated or incorrect memories, consider asking the user to curate them. Use the @Librarian subagent to perform memory research and contradiction resolution. ## Project KV Store diff --git a/packages/memory/src/agents/index.ts b/packages/memory/src/agents/index.ts index c19f98bc..365cb408 100644 --- a/packages/memory/src/agents/index.ts +++ b/packages/memory/src/agents/index.ts @@ -1,14 +1,14 @@ import type { AgentRole, AgentDefinition } from './types' import { codeAgent } from './code' -import { memoryAgent } from './memory' +import { librarianAgent } from './librarian' import { architectAgent } from './architect' -import { codeReviewAgent } from './code-review' +import { auditorAgent } from './auditor' export const agents: Record = { code: codeAgent, - memory: memoryAgent, + librarian: librarianAgent, architect: architectAgent, - 'code-review': codeReviewAgent, + auditor: auditorAgent, } export { type AgentRole, type AgentDefinition, type AgentConfig } from './types' diff --git a/packages/memory/src/agents/memory.ts b/packages/memory/src/agents/librarian.ts similarity index 73% rename from packages/memory/src/agents/memory.ts rename to packages/memory/src/agents/librarian.ts index 4b3bcc68..eac08fef 100644 --- a/packages/memory/src/agents/memory.ts +++ b/packages/memory/src/agents/librarian.ts @@ -1,15 +1,16 @@ import type { AgentDefinition } from './types' -export const memoryAgent: AgentDefinition = { - role: 'memory', - id: 'ocm-memory', - displayName: 'Memory', +export const librarianAgent: AgentDefinition = { + role: 'librarian', + id: 'ocm-librarian', + displayName: 'librarian', description: 'Expert agent for managing project memory - storing and retrieving conventions, decisions, context, and session progress', mode: 'subagent', + temperature: 0.0, tools: { - exclude: ['memory-plan-execute'], + exclude: ['memory-plan-execute', 'memory-health', 'memory-kv-set', 'memory-kv-get', 'memory-kv-list'], }, - systemPrompt: `You are the project's institutional memory. Your purpose is to capture, organize, and retrieve knowledge that persists across sessions. + systemPrompt: `You are the project's librarian — the keeper of institutional memory. Your purpose is to capture, organize, and retrieve knowledge that persists across sessions. ## Your Role @@ -22,40 +23,39 @@ Every memory belongs to exactly one scope. Choose carefully: ### Convention (how we do things) Use for: -- Coding style preferences (e.g., "Use named imports only", "Prefer const over let") -- Naming conventions (e.g., "Component files use PascalCase", "Hooks start with 'use'") -- File organization rules (e.g., "Tests live alongside source in __tests__ folder") -- Testing patterns (e.g., "Use describe/it blocks", "Mock external APIs") -- Import/export conventions (e.g., "Barrel files re-export from index.ts") -- Workflow preferences (e.g., "PRs require review", "Commit messages follow conventional commits") -- Error handling approaches (e.g., "Use Result types for fallible operations") -- Code formatting rules (e.g., "4 spaces indent", "Trailing commas") +- Coding style preferences +- Naming conventions +- File organization rules +- Testing patterns +- Import/export conventions +- Workflow preferences +- Error handling approaches +- Code formatting rules Be prescriptive with conventions—they are rules to follow. ### Decision (why we chose this) Use for: -- Architectural choices and the reasoning behind them (e.g., "We chose SQLite over PostgreSQL for simplicity") -- Technology selections (e.g., "Using Bun as the runtime for faster tests") -- Trade-offs considered and why others were rejected (e.g., "Chose Zustand over Redux for simpler boilerplate") -- Design pattern choices (e.g., "Repository pattern for data access") -- Project structure decisions (e.g., "Monorepo with workspace packages") -- API design decisions (e.g., "REST over GraphQL for this use case") +- Architectural choices and the reasoning behind them +- Technology selections +- Trade-offs considered and why others were rejected +- Design pattern choices +- Project structure decisions +- API design decisions Include the reasoning—not just "we use X" but "we use X because Y". This helps future maintainers understand the context. ### Context (everything else) Use for: -- Project structure knowledge (e.g., "The frontend lives in /packages/client") -- Key file locations (e.g., "Entry point is src/index.ts") -- Domain-specific terminology (e.g., "User refers to authenticated entity, Guest to unauthenticated") -- Integration points and API contracts (e.g., "Payment service expects amount in cents") -- Known issues and workarounds (e.g., "Hot reload breaks with circular imports—restart required") -- Code review findings (prefixed with \`[review-finding]\`, stored by the Code Review agent) -- Technical debt notes (e.g., "Auth needs migration to JWT") -- Domain knowledge (e.g., "Prices stored as integers to avoid floating point issues") +- Project structure knowledge +- Key file locations +- Domain-specific terminology +- Integration points and API contracts +- Known issues and workarounds +- Technical debt notes +- Domain knowledge Context is reference material—helpful but not binding like conventions. @@ -104,7 +104,6 @@ When creating memories: - Bad: "We use Bun" 4. **Reference files when applicable**: - - "The API client lives in src/lib/api.ts and follows the Repository pattern" - This helps agents locate relevant code 5. **Check for duplicates first**: @@ -172,7 +171,7 @@ You are invoked when: - An agent makes an architectural decision that should be recorded - An agent encounters something worth preserving for future sessions - Review feedback involves project-specific standards -- The Architect agent needs broad memory research before designing a plan (multi-query sweep of conventions, decisions, and prior plans) +- The architect agent needs broad memory research before designing a plan (multi-query sweep of conventions, decisions, and prior plans) You are NOT needed for: - Trivial changes (formatting, simple renames) diff --git a/packages/memory/src/agents/types.ts b/packages/memory/src/agents/types.ts index 212f3c26..b9399385 100644 --- a/packages/memory/src/agents/types.ts +++ b/packages/memory/src/agents/types.ts @@ -1,4 +1,4 @@ -export type AgentRole = 'code' | 'memory' | 'architect' | 'code-review' +export type AgentRole = 'code' | 'librarian' | 'architect' | 'auditor' export interface AgentDefinition { role: AgentRole diff --git a/packages/memory/src/config.ts b/packages/memory/src/config.ts index 1d3cb476..628756b9 100644 --- a/packages/memory/src/config.ts +++ b/packages/memory/src/config.ts @@ -13,7 +13,7 @@ const ENHANCED_BUILTIN_AGENTS: Record } const PLUGIN_COMMANDS: Record = { review: { description: 'Run a code review on current changes', - agent: 'Code Review', + agent: 'auditor', subtask: true, template: 'Review the current code changes. $ARGUMENTS', }, @@ -50,7 +50,7 @@ export function createConfigHandler(agents: Record) } config.agent = mergedAgents - config.default_agent = 'Code' + config.default_agent = 'code' const userCommands = config.command as Record | undefined const mergedCommands: Record = { ...PLUGIN_COMMANDS } diff --git a/packages/memory/src/hooks/session.ts b/packages/memory/src/hooks/session.ts index 81cf76ba..362721a4 100644 --- a/packages/memory/src/hooks/session.ts +++ b/packages/memory/src/hooks/session.ts @@ -111,7 +111,7 @@ export function createSessionHooks( parts: [ { type: 'subtask', - agent: 'Memory', + agent: 'librarian', description: 'Memory extraction after compaction', prompt: buildSubtaskPrompt(compactionSummary), }, diff --git a/packages/memory/src/index.ts b/packages/memory/src/index.ts index 7fe45fc7..a90d605b 100644 --- a/packages/memory/src/index.ts +++ b/packages/memory/src/index.ts @@ -536,7 +536,7 @@ export function createMemoryPlugin(config: PluginConfig): Plugin { path: { id: newSessionId }, body: { parts: [{ type: 'text' as const, text: args.plan }], - agent: 'Code', + agent: 'code', ...(executionModel && { model: executionModel }), }, }) @@ -696,7 +696,9 @@ export function createMemoryPlugin(config: PluginConfig): Plugin { text: ` Plan mode is active. You MUST NOT make any file edits, run any non-readonly tools (including changing configs or making commits), or otherwise make any changes to the system. This supersedes any other instructions you have received. -You may ONLY: observe, analyze, plan, and use memory tools (memory-read, memory-write, memory-edit, memory-delete, memory-health, memory-plan-execute, memory-kv-set, memory-kv-get, memory-kv-delete, memory-kv-list). +You may ONLY: observe, analyze, plan, and use memory tools (memory-read, memory-write, memory-edit, memory-delete, memory-kv-set, memory-kv-get, memory-kv-list), and mcp_question. + +You MUST get explicit approval via mcp_question before calling memory-plan-execute. Never execute a plan without approval. `, synthetic: true, }) diff --git a/packages/memory/test/hooks.test.ts b/packages/memory/test/hooks.test.ts index 3b83f500..876a461f 100644 --- a/packages/memory/test/hooks.test.ts +++ b/packages/memory/test/hooks.test.ts @@ -195,7 +195,7 @@ describe('SessionHooks', () => { const subtask = call.body.parts[0] expect(subtask.type).toBe('subtask') - expect(subtask.agent).toBe('Memory') + expect(subtask.agent).toBe('librarian') expect(subtask.description).toBe('Memory extraction after compaction') expect(subtask.prompt).toContain('Compaction summary content') expect(subtask.prompt).toContain('active work in progress') diff --git a/packages/memory/test/plugin.test.ts b/packages/memory/test/plugin.test.ts index ecc17574..0688a937 100644 --- a/packages/memory/test/plugin.test.ts +++ b/packages/memory/test/plugin.test.ts @@ -457,11 +457,11 @@ describe('messages.transform hook', () => { } }) - test('injects system-reminder for Architect agent messages', async () => { + test('injects system-reminder for architect agent messages', async () => { const output = { messages: [ { info: { role: 'assistant' }, parts: [{ type: 'text', text: 'hello' }] }, - { info: { role: 'user', agent: 'Architect' }, parts: [{ type: 'text', text: 'plan this' }] }, + { info: { role: 'user', agent: 'architect' }, parts: [{ type: 'text', text: 'plan this' }] }, ], } @@ -478,10 +478,10 @@ describe('messages.transform hook', () => { expect(text).toContain('MUST NOT make any file edits') }) - test('does NOT inject for non-Architect agents', async () => { + test('does NOT inject for non-architect agents', async () => { const output = { messages: [ - { info: { role: 'user', agent: 'Code' }, parts: [{ type: 'text', text: 'do something' }] }, + { info: { role: 'user', agent: 'code' }, parts: [{ type: 'text', text: 'do something' }] }, ], } @@ -505,9 +505,9 @@ describe('messages.transform hook', () => { test('targets the LAST user message in the array', async () => { const output = { messages: [ - { info: { role: 'user', agent: 'Code' }, parts: [{ type: 'text', text: 'first' }] }, + { info: { role: 'user', agent: 'code' }, parts: [{ type: 'text', text: 'first' }] }, { info: { role: 'assistant' }, parts: [{ type: 'text', text: 'response' }] }, - { info: { role: 'user', agent: 'Architect' }, parts: [{ type: 'text', text: 'second' }] }, + { info: { role: 'user', agent: 'architect' }, parts: [{ type: 'text', text: 'second' }] }, ], }