@emirhanturker/projectmind
v0.4.0
Published
Living Codebase Intelligence Layer for AI Agents — persistent memory, real-time coherence, and Opus-level reasoning
Maintainers
Readme
ProjectMind
Living Codebase Intelligence Layer for AI Agents.
ProjectMind scans your codebase, builds a knowledge graph, and exposes it through a CLI and an MCP server so agents can reason about architecture, debt, dependencies, embeddings, taint, and runtime traces.
Quick Start
npm install
npm run build
projectmind scan
projectmind healthCLI Commands
Core
projectmind init— Initialize ProjectMind in the current projectprojectmind scan [-r <root>]— Scan project and build/update the knowledge graphprojectmind check [<path>]— Check coherence of filesprojectmind report— Generate full coherence + debt reportprojectmind context <file>— Get relevant context for a fileprojectmind mcp— Start ProjectMind as an MCP server (stdio mode)
Intelligence
projectmind search <query>— Search code by patternprojectmind impact <file>— Analyze change impact using dependency dataprojectmind debt-prioritize— Show debt items sorted by severity and frequencyprojectmind genome— Compute and display project coherence genome
Architecture
projectmind graph— Show module dependency graph (Mermaid format)projectmind layers— Enforce architectural layer boundariesprojectmind coupling— Analyze module coupling metricsprojectmind api-surface— Track public API surface changesprojectmind dedup— Find duplicate code using redundancy detectionprojectmind churn— Analyze code churn and risk hotspots
Security & Quality
projectmind audit— Security audit: secrets, crypto patterns, OWASP checksprojectmind license— License compliance (basic check)projectmind sbom— Generate Software Bill of Materialsprojectmind flags— Audit feature flags: usage, staleness, coverage, cleanupprojectmind secrets-life— Secrets lifecycle managementprojectmind test-quality— Analyze test effectivenessprojectmind contract-test— Generate tests for architectural contracts
Refactoring & Docs
projectmind refactor— Code refactoring helpersprojectmind refactor-roi— Calculate refactoring ROIprojectmind testgen [<file>]— Generate test scaffolding for source filesprojectmind docgen— Generate documentation from codeprojectmind migrate— Migration helpers for common upgrades
Agent & Memory
projectmind session— Manage agent sessionsprojectmind memory [<scope> [<key>]]— Read or write agent memoryprojectmind skill-recommend— Recommend skill improvements for agentsprojectmind context-budget [<task>]— Optimize context window usageprojectmind onboard— Generate personalized onboarding pathprojectmind agent— Manage and inspect agent sessions and coverage
Advanced Intelligence
projectmind trace— Runtime call tracing: ingest test traces and dynamic call datatrace ingest <file>— Ingest a trace JSON filetrace convert— Convert another trace format into ProjectMind trace JSONtrace show— Show dynamic call trace datatrace clear— Clear dynamic call trace data
projectmind project— Multi-project managementproject list— List all projectsproject create <name> <rootPath>— Create a new projectproject switch <id>— Switch to a different projectproject current— Show the current projectproject delete <id>— Delete a project and all its files
projectmind data-flow— Data-flow and taint analysisdata-flow record— Record a data-flow edge between resourcesdata-flow list— List all data flows for the current projectdata-flow resource <qualifiedName>— Show all flows for a specific resourcedata-flow clear— Clear all data flows for the current project
projectmind structural-search— AST-based structural search/replacestructural-search search— Search for AST nodes matching a patternstructural-search replace— Replace AST nodes matching a pattern
projectmind embed— Embedding generation and code similarity searchembed init— Initialize the embedding providerembed generate— Generate embedding for a text or code snippetembed similar— Find similar code snippets in the codebaseembed provider— Show the current embedding provider
Diagnostics
projectmind health— Check ProjectMind system healthprojectmind debug— Debug and diagnostic commandsprojectmind doctor— Automated fixes and health remediationprojectmind heatmap— Show coverage heatmapprojectmind ownership— Show agent file ownership from session dataprojectmind pr-preview— Preview PR impactprojectmind deps-fresh— Monitor dependency freshnessprojectmind adr— Architecture Decision Records management
MCP Tools
ProjectMind can run as an MCP server (projectmind mcp). The server exposes tools organized by domain:
Core Tools
check_coherence— Check code coherence against project patternsget_context— Get relevant context for a filestore_memory— Store agent memoryget_memory— Retrieve agent memorydebt_report— Generate cognitive debt reportscale_report— Get project scale and coverage reportgenome_score— Compute project coherence genome scorescan_project— Scan project and build/update knowledge graphstart_session— Start a new agent sessionend_session— End an agent sessionget_agent_sessions— Get agent sessions
Import / Dependency Tools
trace_imports— Trace all transitive imports for a filefind_circular_deps— Find all circular dependencies in the projectresolve_import— Resolve an import path to the actual fileget_dependents— Find all files that import/depend on a given fileget_dependency_graph— Get the dependency graph for a module/directory
Path Tools
resolve_path— Resolve a file path with TypeScript/JS module resolution rulesfind_file_by_import— Find all files that match an import pattern
Architecture Tools
check_architecture— Check if a file complies with project architectural patternsanalyze_impact— Analyze the impact of changing a filesuggest_refactor— Get refactoring suggestions based on code patterns
Sync / Watch Tools
file_watch— Register interest in a file for continuous synchronizationget_file_status— Get real-time status of a filesync_context— Synchronize context between coding agent and ProjectMindunregister_file_watch— Stop watching a file for continuous synchronization
Dynamic Tracing Tools
ingest_trace— Ingest runtime call trace data into the knowledge graph
Structural Search / Replace Tools
structural_search— Find code by AST patternstructural_replace— Rewrite code by AST pattern
Project Management Tools
list_projects— List all projects in the knowledge graphcreate_project— Create a new projectswitch_project— Switch the current project context
Data-Flow / Taint Tools
record_data_flow— Record a data-flow edge between resources or functionsget_data_flows— Get all recorded data flows for the current projectget_resource_flows— Get all data flows for a specific resourceclear_data_flows— Clear all recorded data flows for the current project
Embedding Tools
init_embedding_provider— Initialize the embedding providergenerate_embedding— Generate an embedding vector for text or codeget_embedding_provider— Get the current embedding provider
Database
ProjectMind uses SQLite for persistence. The default database path is .projectmind/pm-knowledge.db.
Schema migrations are versioned and run automatically on startup:
- v1: initial schema
- v2: dynamic tracing (
callstable) - v3: multi-project graph + data-flow (
projects,resources,data_flowstables) - v4: settings table
- v5: team memories table
Migration Rollback
Migrations support down operations for rollback:
import { rollbackMigrations, rollbackLast } from './src/storage/migrations.js';
// Rollback to a specific version
rollbackMigrations(db, 3);
// Rollback the last N migrations
rollbackLast(db, 1);Architecture
src/storage— SQLite schema, migrations, knowledge graph, queriessrc/core— Coherence engine, debt tracker, scale manager, LLM providerssrc/parser— AST parsing, pattern extraction, embeddings, taint analysis, structural searchsrc/mcp— MCP server and tool registrationssrc/cli— Commander-based CLI commands and shared utilitiessrc/tracer— Runtime trace utilitiessrc/types— Shared TypeScript types and declarationssrc/utils— Configuration and shared utilities
Development
npm run build # TypeScript compile + tsc-alias
npm run lint # ESLint check
npm run lint:fix # ESLint auto-fix
npm run format # Prettier format
npm run format:check # Prettier check
npm run typecheck # TypeScript type checking
npm test # Integration tests
npm run test:vitest # Unit tests
npm run test:coverage # Unit tests with coverage report
npm run test:watch # Watch mode for unit tests
npm run start:mcp # Start MCP server
npm run ci # Full CI pipeline (lint + typecheck + test + coverage)Repository Pattern
ProjectMind uses a repository pattern for data access with full dependency injection support:
// Using default singleton database
const fileRepo = new FileRepository();
// Using custom database (for testing)
const db = new DatabaseSync(':memory:');
const manager = new DatabaseManager();
manager.init();
const fileRepo = new FileRepository(manager.getDb());Available Repositories
ProjectRepository— Project CRUD operationsFileRepository— File tracking and metadataImportRepository— Import/dependency analysisMemoryRepository— Agent sessions and memoryDataFlowRepository— Taint analysis data flowsDynamicCallRepository— Runtime call tracing
Installation Notes (Dependency Overrides & Peer Deps)
This project pins security overrides and tolerates a known tree-sitter peer conflict. Install with:
npm install --legacy-peer-depsWhy: the tree-sitter grammar packages (tree-sitter-java, etc.) still
declare peerOptional tree-sitter@^0.21.1 while this project uses
tree-sitter@^0.25.1. Plain npm install / npm audit fix therefore fails
with ERESOLVE until grammars publish updated peers.
Security overrides (see package.json > overrides) keep transitive CVEs
at zero without breaking downgrades:
| Override | Reason |
|---|---|
| adm-zip@^0.6.0 | GHSA-xcpc-8h2w-3j85 (4GB ZIP allocation) via onnxruntime-node |
| protobufjs@^8.7.2 | Critical code-injection set via onnx-proto / transformers |
| sharp@^0.35.3 | libvips CVEs via @xenova/transformers |
All three were verified compatible: onnxruntime-node and
@xenova/transformers load correctly on protobufjs 8 + sharp 0.35.
License
MIT
MCP / AI Agent Integration
See docs/MCP.md for connecting Claude Code, Cursor,
OpenCode, Windsurf or any MCP client — 28 dedicated tools plus the
run_cli bridge exposing the full CLI surface.
