agentleFS
pi22by7pi22by7/In-Memoria/.github/copilot-instructions.md

In-Memoria

Copilot instructions174 starsChanged 13 months agoMITView on GitHub

This repository includes In Memoria, an intelligent MCP (Model Context Protocol) server that provides codebase intelligence through semantic analysis, pattern recognition, and smart navigation. ALWAYS provide absolute paths to In-Memoria tools. NEVER rely on default values. In MCP server context, process.cwd() is unpredictable and may point to the wrong directory (like /home/user instead of your project). Always specify the path explicitly to avoid analyzing the wrong codebase or creating databases in unexpected locations. Every tool that accepts a path parameter…

The file

Show its rules and text

We split this copilot-instructions.md into the rules it gives an agent

17 rules. About 0 are common, 14 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈14

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Ensure it's an absolute path (starts with / on Unix, C:\ on Windows)

    line 29
  2. Distinctive:

    Verify the path exists before calling tools

    line 31
  3. Very specific:

    Every tool that accepts a path parameter should receive:

    line 35
  4. Distinctive:

    Use for: Understanding files or directories

    line 81
  5. Distinctive:

    Use for: Finding code by meaning, text, or patterns

    line 98
  6. Distinctive:

    Use for: Cold-start elimination, understanding project structure

    line 115
  7. Distinctive:

    Use for: Getting suggestions before writing code

    line 125
  8. Distinctive:

    Use for: Maintaining consistency with existing code

    line 136
  9. Distinctive:

    Use for: Understanding what the codebase knows

    line 147
  10. Distinctive:

    Use for: Initial learning or re-learning after major changes

    line 157
  11. Distinctive:

    Use for: Automatic learning with setup verification

    line 167
  12. Distinctive:

    Use for: Learning project conventions and preferences

    line 180
  13. Distinctive:

    Use for: Teaching In Memoria about the codebase

    line 190
  14. Distinctive:

    Use these for debugging and system health:

    line 222
  15. Very specific:

    Feature Mapping: Use includeFeatureMap: true in get_project_blueprint to get instant feature-to-file routing

    line 317
  16. Distinctive:

    Always check learning status: before starting work

    line 352
  17. Distinctive:

    Contribute insights: when you discover architectural decisions

    line 356

≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
copilot-instructions.md

GitHub Copilot Instructions for In Memoria

This repository includes In Memoria, an intelligent MCP (Model Context Protocol) server that provides codebase intelligence through semantic analysis, pattern recognition, and smart navigation.

⚠️ CRITICAL: Path Parameter Usage

ALWAYS provide absolute paths to In-Memoria tools. NEVER rely on default values.

Why This Matters

In MCP server context, process.cwd() is unpredictable and may point to the wrong directory (like /home/user instead of your project). Always specify the path explicitly to avoid analyzing the wrong codebase or creating databases in unexpected locations.

// ❌ WRONG - May use incorrect directory
await use_mcp_tool('in-memoria', 'get_project_blueprint', {
  includeFeatureMap: true
});

// ✅ CORRECT - Always specify path explicitly
await use_mcp_tool('in-memoria', 'get_project_blueprint', {
  path: '/absolute/path/to/project',  // Use workspace root
  includeFeatureMap: true
});

Getting the Project Path

  • In VS Code: Use ${workspaceFolder} or workspace root API
  • Ensure it's an absolute path (starts with / on Unix, C:\ on Windows)
  • Be consistent across all tool calls in a session
  • Verify the path exists before calling tools

Path Convention for All Tools

Every tool that accepts a path parameter should receive:

  • Absolute paths to the project root directory
  • Same path throughout the entire session
  • No relative paths like . or ./src (resolve them first)

Core Capabilities

In Memoria learns from codebases and provides:

  • Instant project context - Tech stack, entry points, key directories, architecture overview
  • Semantic search - Find code by meaning, not just keywords
  • Pattern recognition - Discover coding patterns and best practices
  • Smart file routing - Navigate to relevant files from vague requests
  • Coding approach predictions - Get implementation suggestions based on learned patterns

How to Use In Memoria MCP Tools

🚀 Quick Start Pattern

ALWAYS start new sessions with:

// IMPORTANT: Get the absolute project path first
const projectPath = '/absolute/path/to/project'; // or ${workspaceFolder}

// 1. Get instant project blueprint
const blueprint = await use_mcp_tool('in-memoria', 'get_project_blueprint', {
  path: projectPath,  // Always provide path!
  includeFeatureMap: true
});

// Check if learning is needed
if (blueprint.learningStatus.recommendation === 'learning_recommended') {
  // 2. Auto-learn from codebase if needed
  await use_mcp_tool('in-memoria', 'auto_learn_if_needed', {
    path: projectPath,  // Same path throughout session
    includeProgress: true
  });
}

This eliminates cold-start exploration and gives you instant context.

📊 The 10 Core Tools (Use These Frequently)

1. analyze_codebase - Comprehensive Analysis

Use for: Understanding files or directories

const projectPath = '/absolute/path/to/project';

// Analyze a specific file
await use_mcp_tool('in-memoria', 'analyze_codebase', {
  path: `${projectPath}/src/components/Header.tsx`
});

// Analyze entire directory
await use_mcp_tool('in-memoria', 'analyze_codebase', {
  path: `${projectPath}/src`
});

Returns: Languages, frameworks, complexity, top concepts, top patterns (token-efficient)

2. search_codebase - Smart Search

Use for: Finding code by meaning, text, or patterns

// Semantic search (finds by meaning)
await use_mcp_tool('in-memoria', 'search_codebase', {
  query: 'authentication logic',
  type: 'semantic',
  limit: 10
});

// Text search (fast keyword matching)
await use_mcp_tool('in-memoria', 'search_codebase', {
  query: 'fetchUserData',
  type: 'text'
});

3. get_project_blueprint - Instant Context

Use for: Cold-start elimination, understanding project structure

await use_mcp_tool('in-memoria', 'get_project_blueprint', {
  path: '/absolute/path/to/project',  // ALWAYS provide path
  includeFeatureMap: true
});

Returns: Tech stack, entry points, key directories, feature-to-file mapping, learning status

4. predict_coding_approach - Implementation Guidance

Use for: Getting suggestions before writing code

await use_mcp_tool('in-memoria', 'predict_coding_approach', {
  problemDescription: 'Add user profile editing feature',
  context: { currentFile: 'src/pages/profile.tsx' },
  includeFileRouting: true
});

Returns: Recommended approach, patterns, complexity estimate, target files

5. get_pattern_recommendations - Pattern Suggestions

Use for: Maintaining consistency with existing code

await use_mcp_tool('in-memoria', 'get_pattern_recommendations', {
  problemDescription: 'Create new API endpoint for user search',
  currentFile: 'src/api/routes/users.ts',
  includeRelatedFiles: true
});

Returns: Patterns to follow, examples, confidence scores, related files

6. get_semantic_insights - Explore Concepts

Use for: Understanding what the codebase knows

await use_mcp_tool('in-memoria', 'get_semantic_insights', {
  query: 'authentication',
  limit: 10
});

Returns: Related concepts, usage contexts, relationships

7. learn_codebase_intelligence - Deep Learning

Use for: Initial learning or re-learning after major changes

await use_mcp_tool('in-memoria', 'learn_codebase_intelligence', {
  path: '.',
  force: false  // Set true to force re-learning
});

Returns: Concepts learned, patterns discovered, blueprint data

8. auto_learn_if_needed - Smart Automation

Use for: Automatic learning with setup verification

await use_mcp_tool('in-memoria', 'auto_learn_if_needed', {
  path: '.',
  force: false,
  includeProgress: true,
  skipLearning: false,      // Set true for quick setup without learning
  includeSetupSteps: true   // Get detailed setup verification
});

Returns: Action taken, status, intelligence metrics

9. get_developer_profile - Understand Coding Style

Use for: Learning project conventions and preferences

await use_mcp_tool('in-memoria', 'get_developer_profile', {
  includeRecentActivity: true,
  includeWorkContext: true
});

Returns: Naming conventions, structural patterns, testing approach, expertise areas

10. contribute_insights - Record Learnings

Use for: Teaching In Memoria about the codebase

⚠️ IMPORTANT: The content field is REQUIRED and must contain the actual insight data.

// ✅ CORRECT - content field with insight details
await use_mcp_tool('in-memoria', 'contribute_insights', {
  type: 'best_practice',
  content: {  // REQUIRED FIELD
    practice: 'Use React Query for all API calls',
    reasoning: 'Provides better caching and error handling',
    affectedFiles: ['src/hooks/', 'src/api/']
  },
  confidence: 0.95,
  sourceAgent: 'github-copilot',
  sessionUpdate: {  // OPTIONAL
    feature: 'API integration',
    files: ['src/api/users.ts']
  }
});

// ❌ WRONG - missing content field
await use_mcp_tool('in-memoria', 'contribute_insights', {
  type: 'best_practice',
  confidence: 0.9,
  sourceAgent: 'github-copilot'
  // ERROR: content is required!
});

🔍 Monitoring Tools (Debug/System)

Use these for debugging and system health:

  • get_system_status - Database status, learning state
  • get_intelligence_metrics - Concept/pattern counts, quality scores
  • get_performance_status - Vector DB health, query performance
  • health_check - Verify setup and configuration (checks paths, database, API keys)

Example: Run health check

// Diagnose setup issues
const health = await use_mcp_tool('in-memoria', 'health_check', {
  path: '/absolute/path/to/project'
});

// Check status: 'healthy', 'warning', or 'error'
console.log(health.status);       // Overall status
console.log(health.summary);      // Human-readable summary
console.log(health.checks);       // Detailed check results

🎯 Usage Patterns

Pattern 1: Starting a New Feature

// 1. Get project context
const blueprint = await use_mcp_tool('in-memoria', 'get_project_blueprint', { path: '.' });

// 2. Find similar features
const similar = await use_mcp_tool('in-memoria', 'search_codebase', {
  query: 'user profile features',
  type: 'semantic'
});

// 3. Get implementation approach
const approach = await use_mcp_tool('in-memoria', 'predict_coding_approach', {
  problemDescription: 'Add profile photo upload',
  includeFileRouting: true
});

// 4. Get pattern recommendations
const patterns = await use_mcp_tool('in-memoria', 'get_pattern_recommendations', {
  problemDescription: 'Profile photo upload with validation',
  currentFile: approach.fileRouting.suggestedStartPoint
});

// Now you have: context, similar code, approach, patterns, target files

Pattern 2: Understanding Unfamiliar Code

// 1. Analyze the file/directory
const analysis = await use_mcp_tool('in-memoria', 'analyze_codebase', {
  path: './src/auth'
});

// 2. Get semantic insights about key concepts
const insights = await use_mcp_tool('in-memoria', 'get_semantic_insights', {
  query: 'authentication flow'
});

// 3. Search for usage examples
const examples = await use_mcp_tool('in-memoria', 'search_codebase', {
  query: 'auth.login',
  type: 'text'
});

Pattern 3: Debugging/Code Review

// 1. Get developer profile to understand conventions
const profile = await use_mcp_tool('in-memoria', 'get_developer_profile', {});

// 2. Check if current code follows patterns
const patterns = await use_mcp_tool('in-memoria', 'get_pattern_recommendations', {
  problemDescription: 'Review error handling in API routes',
  currentFile: 'src/api/routes/users.ts'
});

// 3. Find similar implementations for comparison
const similar = await use_mcp_tool('in-memoria', 'search_codebase', {
  query: 'error handling middleware',
  type: 'pattern'
});

🚫 What NOT to Do

❌ Don't guess file paths - Use get_project_blueprint to discover structure ❌ Don't skip learning checks - Always call auto_learn_if_needed at session start ❌ Don't use text search for concepts - Use semantic search for meaning-based queries ❌ Don't ignore pattern recommendations - They reflect actual codebase conventions ❌ Don't re-learn unnecessarily - Check blueprint.learningStatus before forcing re-learning

💡 Pro Tips

  1. Token Efficiency: analyze_codebase automatically limits concepts/patterns to top 10-15 to avoid overwhelming responses
  2. Feature Mapping: Use includeFeatureMap: true in get_project_blueprint to get instant feature-to-file routing
  3. Smart Routing: Set includeFileRouting: true in predict_coding_approach to get target files automatically
  4. Related Files: Set includeRelatedFiles: true in get_pattern_recommendations to discover similar implementations
  5. Work Context: Set includeWorkContext: true in get_developer_profile to see session history and recent decisions

🔄 Typical Session Flow

// Session Start
1. get_project_blueprint({ path: '.' })
   → Get instant context + check learning status

2. auto_learn_if_needed({ path: '.' })
   → Learn if needed (only runs if data is stale/missing)

// During Development
3. predict_coding_approach({ problemDescription: '...', includeFileRouting: true })
   → Get implementation approach + target files

4. get_pattern_recommendations({ problemDescription: '...', includeRelatedFiles: true })
   → Get patterns + similar files

5. search_codebase({ query: '...', type: 'semantic' })
   → Find relevant code

6. analyze_codebase({ path: './specific/file.ts' })
   → Understand specific files

// Session End (Optional)
7. contribute_insights({ type: '...', content: {...} })
   → Record learnings for future sessions

🎨 Best Practices

  • Always check learning status before starting work
  • Use semantic search for concept-based queries
  • Leverage feature maps for instant navigation
  • Follow pattern recommendations to maintain consistency
  • Contribute insights when you discover architectural decisions
  • Use token-efficient responses - tools automatically limit output for LLM efficiency

📚 Additional Resources

  • Full API documentation: See tool schemas in src/mcp-server/tools/
  • Implementation roadmap: IMPLEMENTATION_ROADMAP.md
  • Architecture overview: README.md

Remember: In Memoria learns from the codebase and provides intelligent, context-aware suggestions. Trust the pattern recommendations and semantic insights - they reflect actual code in the project.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.