-
Notifications
You must be signed in to change notification settings - Fork 0
chore: integrate Codebase Memory MCP workflow #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| --- | ||
| description: Codebase Memory graph-first repository intelligence policy | ||
| globs: **/* | ||
| alwaysApply: true | ||
| --- | ||
| # Codebase Memory MCP Policy | ||
|
|
||
| Codebase Memory is an advisory repository-intelligence layer. Source code, schemas, tests, DECISIONS.md, AGENTS.md, and existing project rules remain authoritative. | ||
|
|
||
| ## Mandatory workflow | ||
|
|
||
| For architecture discovery, dependency tracing, blast-radius analysis, or any change that can affect multiple files: | ||
|
|
||
| 1. Use Codebase Memory first when the MCP server is available. | ||
| 2. Establish current architecture with `get_architecture` when the session lacks fresh repository context. | ||
| 3. Locate symbols and relationships with `search_graph` and `trace_path` instead of broad repeated file reads. | ||
| 4. Before editing, determine the affected surface and read the actual source files that will be changed. | ||
| 5. Never treat graph output as authorization to violate `.cursorrules`, `DECISIONS.md`, `AGENTS.md`, sealed boundaries, or user scope. | ||
| 6. After editing, run `detect_changes` to inspect blast radius when Codebase Memory is available. | ||
| 7. Run the repository's existing verification gates from `AGENTS.md` and `.cursorrules`. Graph analysis never replaces schema validation, tests, checks, builds, or language validation. | ||
|
|
||
| ## Failure behavior | ||
|
|
||
| - If the graph is missing, stale, degraded, or lacks coverage for a relevant path, fall back to direct source search/read and continue safely. | ||
| - Dynamic behavior not represented in the graph must be verified from source and tests. | ||
| - A clean graph result means only that no relationship was recorded; it is not proof that no dependency exists. | ||
| - Never modify code solely from graph summaries without reading the target implementation. | ||
|
|
||
| ## Persistence | ||
|
|
||
| - `auto_index=true` is recommended. | ||
| - `auto_watch=true` is recommended. | ||
| - Do not commit `.codebase-memory/graph.db.zst` or any generated graph artifact unless the user explicitly requests a team-shared graph snapshot. | ||
|
|
||
| ## Invariant | ||
|
|
||
| SOURCE + PROJECT RULES + TESTS = SSOT. | ||
| CODEBASE MEMORY = DERIVED NAVIGATION AND IMPACT INTELLIGENCE ONLY. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| $ErrorActionPreference = 'Stop' | ||
|
|
||
| $repoRoot = (git rev-parse --show-toplevel).Trim() | ||
| if (-not $repoRoot) { throw 'Unable to resolve repository root.' } | ||
|
|
||
| if (-not (Get-Command codebase-memory-mcp -ErrorAction SilentlyContinue)) { | ||
| $installer = Join-Path $env:TEMP ("cbm-install-{0}.ps1" -f [guid]::NewGuid().ToString('N')) | ||
| try { | ||
| Invoke-WebRequest -Uri 'https://raw.githubusercontent.com/DeusData/codebase-memory-mcp/main/install.ps1' -OutFile $installer | ||
| Unblock-File $installer -ErrorAction SilentlyContinue | ||
| & powershell -NoProfile -ExecutionPolicy Bypass -File $installer | ||
|
Comment on lines
+9
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
printf 'Repository files matching setup scripts:\n'
fd -a 'setup-codebase-memory\.(ps1|sh)$' . || true
printf '\nscripts/setup-codebase-memory.ps1:\n'
if [ -f scripts/setup-codebase-memory.ps1 ]; then
cat -n scripts/setup-codebase-memory.ps1
fi
printf '\nscripts/setup-codebase-memory.sh:\n'
if [ -f scripts/setup-codebase-memory.sh ]; then
cat -n scripts/setup-codebase-memory.sh
fi
printf '\nAny related README/security/codebase-memory docs:\n'
rg -n --hidden --glob '!*.lock' --glob '!node_modules/**' --glob '!dist/**' --glob '!build/**' \
'codebase-memory|install\.ps1|install\.sh|setup-codebase-memory|raw\.githubusercontent\.com/DeusData' . || trueRepository: barisbagirlar-web/SectorCalc Length of output: 4333 Pin and verify the upstream installer in both bootstrap scripts. Both scripts execute code downloaded from 📍 Affects 2 files
🤖 Prompt for AI Agents |
||
| } | ||
| finally { | ||
| Remove-Item $installer -Force -ErrorAction SilentlyContinue | ||
| } | ||
| } | ||
|
|
||
| codebase-memory-mcp config set auto_index true | ||
|
Comment on lines
+6
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== repository files =="
git ls-files | rg 'scripts/setup-codebase-memory\.(ps1|sh)$|scripts/|README|AGENTS|CODEBASE|DECISIONS' || true
echo
echo "== setup script snippets =="
for f in scripts/setup-codebase-memory.ps1 scripts/setup-codebase-memory.sh; do
if [ -f "$f" ]; then
echo "--- $f ---"
nl -ba "$f" | sed -n '1,120p'
fi
done
echo
echo "== references to codebase-memory-mcp =="
rg -n "codebase-memory-mcp|INSTALLER|PATH|\\\$env:PATH|export PATH|\\.local/bin|mcp" . --glob '!node_modules/**' --glob '!dist/**' --glob '!build/**' || trueRepository: barisbagirlar-web/SectorCalc Length of output: 851 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== setup script snippets =="
for f in scripts/setup-codebase-memory.ps1 scripts/setup-codebase-memory.sh; do
if [ -f "$f" ]; then
echo "--- $f ---"
awk '{printf "%6d %s\n", NR, $0}' "$f" | sed -n '1,120p'
else
echo "missing $f"
fi
done
echo
echo "== references to codebase-memory-mcp and path/install vars =="
grep -RInEi "codebase-memory-mcp|INSTALLER|PATH|\\\$env:PATH|export PATH|\\.local/bin|mcp" . --exclude-dir=node_modules --exclude-dir=dist --exclude-dir=build || true
echo
echo "== inspect install scripts from upstream (read-only) =="
python3 - <<'PY'
import urllib.request
urls = [
("https://raw.githubusercontent.com/DeusData/codebase-memory-mcp/main/install.ps1", "scripts/setup-codebase-memory.ps1"),
("https://raw.githubusercontent.com/DeusData/codebase-memory-mcp/main/install.sh", "scripts/setup-codebase-memory.sh"),
]
for url, context in urls:
print(f"--- upstream {context} depends on {url} ---")
try:
with urllib.request.urlopen(url, timeout=20) as r:
text = r.read().decode("utf-8", "replace")
for i, line in enumerate(text.splitlines(), 1):
if any(s in line.lower() for s in ["bin", "programfiles", "appdata", "local", "path", "cp", "copy", "chmod", "codebase-memory-mcp"]):
print(f"{i}: {line}")
except Exception as e:
print(f"ERROR: {e}")
PYRepository: barisbagirlar-web/SectorCalc Length of output: 50384 🌐 Web query:
💡 Result: DeusData codebase-memory-mcp is a high-performance, single-binary Model Context Protocol (MCP) server that indexes codebases into a persistent knowledge graph [1][2]. Installation is handled via platform-specific scripts provided in the GitHub repository [1][3]. Installation Scripts and Directories: - macOS and Linux: Uses install.sh, which defaults to installing the binary in $HOME/.local/bin [4][5]. You can specify a custom installation directory using the --dir flag (e.g., curl -fsSL... | bash -s -- --dir /custom/path) [4][5]. - Windows: Uses install.ps1, which typically installs to $env:LOCALAPPDATA\Programs\codebase-memory-mcp [6]. PATH Configuration: After installation, the installer checks if the target directory is in your system PATH [4][6][5]. If it is not, the installer will typically warn you and provide the command to add it to your shell configuration (e.g., ~/.bashrc, ~/.zshrc, or the Windows User PATH environment variable) [4][6][5][7]. Usage: Once installed, you can configure your AI coding agents by running the following command in your terminal [8]: codebase-memory-mcp install For further configuration or to install the UI variant (with graph visualization), refer to the official repository documentation [2][4]. Citations:
🏁 Script executed: #!/bin/bash
set -euo pipefail
python3 - <<'PY'
import urllib.request
urls = [
"https://raw.githubusercontent.com/DeusData/codebase-memory-mcp/main/install.ps1",
"https://raw.githubusercontent.com/DeusData/codebase-memory-mcp/main/install.sh",
]
for url in urls:
print(f"--- {url} ---")
with urllib.request.urlopen(url, timeout=20) as r:
text = r.read().decode("utf-8", "replace").splitlines()
for i, line in enumerate(text, 1):
if any(s in line for for s in [
"localappdata", "program files", ".local", "local/bin", "PATH", "path", "Copy",
"cp", "chmod", "exec", "codebase-memory-mcp", "Destination", "targetDir",
"Programs", "bin", "warn", "message"
]):
print(f"{i:03d}: {line}")
PYRepository: barisbagirlar-web/SectorCalc Length of output: 285 🏁 Script executed: #!/bin/bash
set -euo pipefail
python3 - <<'PY'
import urllib.request
urls = [
"https://raw.githubusercontent.com/DeusData/codebase-memory-mcp/main/install.ps1",
"https://raw.githubusercontent.com/DeusData/codebase-memory-mcp/main/install.sh",
]
for url in urls:
print(f"--- {url} ---")
with urllib.request.urlopen(url, timeout=20) as r:
text = r.read().decode("utf-8", "replace").splitlines()
for i, line in enumerate(text, 1):
if any(s in line for s in [
"localappdata", "program files", ".local", "local/bin", "PATH", "path", "Copy",
"cp", "chmod", "exec", "codebase-memory-mcp", "Destination", "targetDir",
"Programs", "bin", "warn", "message"
]):
print(f"{i:03d}: {line}")
PYRepository: barisbagirlar-web/SectorCalc Length of output: 2848 🌐 Web query:
💡 Result: The file at Citations:
🌐 Web query:
💡 Result: The command install.ps1 Destination $env:LOCALAPPDATA is not a standard or built-in PowerShell command. It appears to be a pattern associated with specific custom installers, most notably the codebase-memory-mcp project [1][2][3]. In the context of that project, the install.ps1 script is used to install binaries to a user-local directory [1]. While the script typically defaults to $env:LOCALAPPDATA\Programs\codebase-memory-mcp [1], some installers allow users to specify a custom installation directory using command-line arguments [2][3]. If you are trying to use a script and need to specify a destination, check if the script supports a parameter like -Destination or a similar flag [3]. You can typically inspect a PowerShell script to see which parameters it accepts by opening it in a text editor or by running the following command in PowerShell: Get-Help.\install.ps1 -Detailed If you are writing your own script and want to install to a folder within $env:LOCALAPPDATA, you can use the following approach in your PowerShell script: $InstallDir = Join-Path $env:LOCALAPPDATA "YourAppFolder" if (!(Test-Path $InstallDir)) { New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null } # Proceed with copying your files to $InstallDir Always be cautious when running scripts downloaded from the internet [2][3]. It is recommended to inspect the code first (e.g., using notepad install.ps1) and unblock the file using Unblock-File.\install.ps1 if necessary [2][3]. Citations:
🏁 Script executed: #!/bin/bash
set -euo pipefail
curl --fail --silent --show-error --location -o /tmp/cbm-install.ps1 'https://raw.githubusercontent.com/DeusData/codebase-memory-mcp/main/install.ps1'
echo "--- install.ps1 PATH / install-dir lines ---"
grep -InEi '\.(path|prepend|environmentvariable|LOCALAPPDATA|Programs|Destination|InstallDir|PATH|path)' /tmp/cbm-install.ps1 | sed -n '1,120p' || true
wc -l /tmp/cbm-install.ps1
curl --fail --silent --show-error --location -o /tmp/cbm-install.sh 'https://raw.githubusercontent.com/DeusData/codebase-memory-mcp/main/install.sh'
echo "--- install.sh PATH / install-dir lines ---"
grep -InEi '\.(path|prepend|export|export PATH|\.local/bin|DIRECTORY|DIR|local|bin|chmod|codebase-memory-mcp)' /tmp/cbm-install.sh | sed -n '1,160p' || true
wc -l /tmp/cbm-install.sh
echo "--- full install.ps1 size-safe line numbers relevant ---"
awk '/Dest|LOCALAPPDATA|Programs|PATH|path|Copy|Unblock|Write|Message/ { printf "%d: %s\n", NR, $0 }' /tmp/cbm-install.ps1
echo "--- full install.sh size-safe line numbers relevant ---"
awk '/Dest|local|bin|export PATH|PATH|cp|chmod|codebase-memory-mcp|Write|Message|InstallDir/ { printf "%d: %s\n", NR, $0 }' /tmp/cbm-install.shRepository: barisbagirlar-web/SectorCalc Length of output: 5008 Make the installed executable available before the first CLI call. The installers only print a PATH warning/instruction; the setup scripts then immediately call
📍 Affects 2 files
🤖 Prompt for AI Agents |
||
| codebase-memory-mcp config set auto_watch true | ||
| codebase-memory-mcp config set auto_index_limit 50000 | ||
| codebase-memory-mcp cli --progress index_repository --repo-path $repoRoot | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "Repo files matching setup-codebase-memory:"
fd -a 'setup-codebase-memory\.(ps1|sh)$' . || true
echo
echo "Contents of setup scripts:"
for f in $(fd 'setup-codebase-memory\.(ps1|sh)$' .); do
echo "--- $f ---"
nl -ba "$f" | sed -n '1,80p'
done
echo
echo "Search for codebase-memory-mcp usage and repo_path arguments:"
rg -n "codebase-memory-mcp|repo_path|--repo-path|index_repository|convertto-json|JSON|read_text_file" -S .Repository: barisbagirlar-web/SectorCalc Length of output: 427 🌐 Web query:
💡 Result: codebase-memory-mcp is a high-performance, open-source Model Context Protocol (MCP) server that indexes codebases into a persistent knowledge graph to assist AI coding agents [1][2]. It is designed as a structural analysis backend that provides fast, token-efficient querying of code elements like functions, classes, and call chains, rather than functioning as an LLM itself [2][3]. The Citations:
🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "Setup script contents:"
for f in scripts/setup-codebase-memory.ps1 scripts/setup-codebase-memory.sh; do
echo "--- $f ---"
awk '{printf "%5d\t%s\n", NR, $0}' "$f" | sed -n '1,120p'
done
echo
echo "Repository references to codebase-memory-mcp CLI usage:"
rg -n "codebase-memory-mcp|index_repository|repo_path|--repo-path|ConvertTo-Json|repo-path" -S .Repository: barisbagirlar-web/SectorCalc Length of output: 3995 Use the documented JSON argument contract for indexing.
📍 Affects 2 files
🤖 Prompt for AI Agents |
||
| codebase-memory-mcp cli list_projects | ||
|
Comment on lines
+18
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
printf 'Files matching setup-codebase-memory.ps1:\n'
fd -a 'setup-codebase-memory\.ps1$' . || true
printf '\nTarget file contents with line numbers:\n'
if [ -f scripts/setup-codebase-memory.ps1 ]; then
cat -n scripts/setup-codebase-memory.ps1
fi
printf '\nSearch for LASTEXITCODE handling or wrappers:\n'
rg -n "LASTEXITCODE|Check-Executable|ExecutableExists|codebase-memory-mcp|Set-StrictMode|trap|throws|Exception" scripts setup-codebase-memory.ps1 . --glob '!**/.git/**' --glob '!**/node_modules/**' || true
printf '\nPowerShell availability and native error behavior probe (if pwsh available):\n'
if command -v pwsh >/dev/null 2>&1; then
pwsh -NoProfile -Command '
$ErrorActionPreference = "Stop"
$ErrorActionPreference | Out-String
try {
echo "foo" ; exit 7
"after native nonzero"
} catch {
"catch executed"
}
"LASTEXITCODE=$LASTEXITCODE"
'
else
echo "pwsh not available"
fiRepository: barisbagirlar-web/SectorCalc Length of output: 14306 🌐 Web query:
💡 Result: In PowerShell, native programs do not participate in the standard PowerShell error system by default; they report failure via a non-zero exit code, which is stored in the automatic variable $LASTEXITCODE [1][2]. Traditionally, developers had to manually check this variable after every command execution [3][4]. However, starting in PowerShell 7.3 (and stabilized in 7.4), you can leverage the $PSNativeCommandUseErrorActionPreference feature to integrate native program failures into PowerShell's standard error handling [1][2]. How to use ErrorActionPreference Stop with native commands: 1. Enable the preference variable: Set $PSNativeCommandUseErrorActionPreference = $true [1][5]. 2. Configure error handling: Set $ErrorActionPreference = 'Stop' [1][5]. 3. Wrap in try/catch: When these two variables are set, a non-zero exit code from a native command will emit a NativeCommandExitException [1][2]. Because $ErrorActionPreference is set to 'Stop', this non-terminating error is promoted to a script-terminating error, allowing it to be caught by a try/catch block [1][5][2]. Example: $PSNativeCommandUseErrorActionPreference = $true Citations:
Check native command exit codes explicitly.
🤖 Prompt for AI Agents |
||
|
|
||
| Write-Output 'Codebase Memory is installed and this repository is indexed.' | ||
| Write-Output 'Restart Cursor so the MCP server and managed agent configuration are loaded.' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| REPO_ROOT="$(git rev-parse --show-toplevel)" | ||
|
|
||
| if ! command -v codebase-memory-mcp >/dev/null 2>&1; then | ||
| INSTALLER="$(mktemp)" | ||
| trap 'rm -f "$INSTALLER"' EXIT | ||
| curl --fail --silent --show-error --location --proto '=https' --tlsv1.2 \ | ||
| https://raw.githubusercontent.com/DeusData/codebase-memory-mcp/main/install.sh \ | ||
| --output "$INSTALLER" | ||
| bash "$INSTALLER" | ||
| fi | ||
|
|
||
| codebase-memory-mcp config set auto_index true | ||
| codebase-memory-mcp config set auto_watch true | ||
| codebase-memory-mcp config set auto_index_limit 50000 | ||
| codebase-memory-mcp cli --progress index_repository --repo-path "$REPO_ROOT" | ||
| codebase-memory-mcp cli list_projects | ||
|
|
||
| printf '%s\n' \ | ||
| 'Codebase Memory is installed and this repository is indexed.' \ | ||
| 'Restart Cursor so the MCP server and managed agent configuration are loaded.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: barisbagirlar-web/SectorCalc
Length of output: 625
Quote the
globspattern.globs: **/*is invalid YAML because plain scalars cannot begin with the*alias indicator, and Cursor may fail to load this rule. Useglobs: "**/*"instead.🤖 Prompt for AI Agents