Skip to content

chore: integrate Codebase Memory MCP workflow - #120

Merged
barisbagirlar-web merged 3 commits into
mainfrom
chore/codebase-memory-mcp
Jul 25, 2026
Merged

chore: integrate Codebase Memory MCP workflow#120
barisbagirlar-web merged 3 commits into
mainfrom
chore/codebase-memory-mcp

Conversation

@barisbagirlar-web

@barisbagirlar-web barisbagirlar-web commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Adds a graph-first Codebase Memory Cursor policy plus idempotent macOS/Linux and Windows bootstrap scripts. No production source, calculation logic, schemas, SEO, hosting, or deployment files are modified. Source and existing project rules remain SSOT; Codebase Memory is advisory only.

Summary by CodeRabbit

  • New Features

    • Added setup scripts for Windows and Unix-based systems to install and configure Codebase Memory.
    • Added automatic repository indexing and file watching support.
    • Added guidance for restarting Cursor after setup.
  • Documentation

    • Added Codebase Memory usage guidance, including source-of-truth rules, workflow expectations, and fallback behavior.

@barisbagirlar-web
barisbagirlar-web enabled auto-merge (squash) July 25, 2026 08:35
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a repository-wide Codebase Memory policy and Bash/PowerShell setup scripts that install the CLI when absent, configure automatic indexing and watching, index the repository, list projects, and provide Cursor restart instructions.

Changes

Codebase Memory integration

Layer / File(s) Summary
Codebase Memory policy
.cursor/rules/codebase-memory.mdc
Defines advisory graph usage, source inspection requirements, fallback behavior, persistence rules, and source-of-truth boundaries.
Cross-platform setup automation
scripts/setup-codebase-memory.ps1, scripts/setup-codebase-memory.sh
Resolves the repository, installs the CLI when needed, configures indexing and watching, indexes the repository, lists projects, and reports completion.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Developer
  participant SetupScript
  participant Git
  participant CodebaseMemoryCLI

  Developer->>SetupScript: Run setup script
  SetupScript->>Git: Resolve repository root
  SetupScript->>CodebaseMemoryCLI: Install if unavailable
  SetupScript->>CodebaseMemoryCLI: Configure indexing and watching
  SetupScript->>CodebaseMemoryCLI: Index repository and list projects
  SetupScript-->>Developer: Print completion and restart instructions
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the added Codebase Memory MCP policy and bootstrap workflow.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/codebase-memory-mcp

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@barisbagirlar-web
barisbagirlar-web merged commit cdd3f30 into main Jul 25, 2026
8 of 10 checks passed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.cursor/rules/codebase-memory.mdc:
- Line 3: Quote the glob pattern in the frontmatter by updating the globs
configuration from an unquoted **/* value to a quoted "**/*" value, preserving
the existing pattern while ensuring valid YAML parsing.

In `@scripts/setup-codebase-memory.ps1`:
- Around line 9-11: The bootstrap scripts execute unpinned upstream installers
without integrity verification. In scripts/setup-codebase-memory.ps1 lines 9-11
and scripts/setup-codebase-memory.sh lines 9-12, change the installer URLs from
the mutable main branch to the same immutable reviewed tag, release, or commit,
verify each downloaded installer against its reviewed digest or attestation, and
invoke PowerShell or Bash only after verification succeeds.
- Line 21: The indexing commands use the wrong argument contract. In
scripts/setup-codebase-memory.ps1 at line 21 and
scripts/setup-codebase-memory.sh at line 18, update the cli index_repository
invocation to pass a JSON payload containing the repository path, replacing the
separate --repo-path argument while preserving the existing repository-root
values.
- Around line 18-22: Update the setup command sequence in
setup-codebase-memory.ps1 to explicitly detect failures from each native
codebase-memory-mcp invocation using $LASTEXITCODE, $?, or supported PowerShell
native-error handling. Stop execution immediately on failure so subsequent
commands and the success message are not reached.
- Around line 6-18: The setup scripts must make the installer-provided
executable available before their first CLI invocation. In
scripts/setup-codebase-memory.ps1, resolve or prepend the Windows default
install path
($env:LOCALAPPDATA\Programs\codebase-memory-mcp\codebase-memory-mcp) before
codebase-memory-mcp config set; in scripts/setup-codebase-memory.sh, resolve or
prepend $HOME/.local/bin/codebase-memory-mcp before its corresponding CLI calls.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a907fd91-5f55-4a16-954c-6c0975a774b4

📥 Commits

Reviewing files that changed from the base of the PR and between 6cbf323 and 4f91ce1.

📒 Files selected for processing (3)
  • .cursor/rules/codebase-memory.mdc
  • scripts/setup-codebase-memory.ps1
  • scripts/setup-codebase-memory.sh

@@ -0,0 +1,38 @@
---
description: Codebase Memory graph-first repository intelligence policy
globs: **/*

Copy link
Copy Markdown

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:

ruby <<'RUBY'
require "yaml"
text = File.read(".cursor/rules/codebase-memory.mdc")
frontmatter = text[/\A---\n(.*?)\n---/m, 1]
abort "missing front matter" unless frontmatter
YAML.safe_load(frontmatter)
puts "valid"
RUBY

Repository: barisbagirlar-web/SectorCalc

Length of output: 625


Quote the globs pattern.

globs: **/* is invalid YAML because plain scalars cannot begin with the * alias indicator, and Cursor may fail to load this rule. Use globs: "**/*" instead.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.cursor/rules/codebase-memory.mdc at line 3, Quote the glob pattern in the
frontmatter by updating the globs configuration from an unquoted **/* value to a
quoted "**/*" value, preserving the existing pattern while ensuring valid YAML
parsing.

Comment on lines +6 to +18
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
}
finally {
Remove-Item $installer -Force -ErrorAction SilentlyContinue
}
}

codebase-memory-mcp config set auto_index true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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/**' || true

Repository: 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}")
PY

Repository: barisbagirlar-web/SectorCalc

Length of output: 50384


🌐 Web query:

github DeusData codebase-memory-mcp install.ps1 install.sh install directory PATH bin

💡 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}")
PY

Repository: 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}")
PY

Repository: barisbagirlar-web/SectorCalc

Length of output: 2848


🌐 Web query:

raw.githubusercontent.com DeusData codebase-memory-mcp install.ps1 PowerShell -NoProfile -ExecutionPolicy Bypass Destination

💡 Result:

The file at https://raw.githubusercontent.com/DeusData/codebase-memory-mcp/main/install.ps1 is the official PowerShell installation script for the codebase-memory-mcp project, a high-performance code intelligence engine for AI coding agents [1][2][3]. The script is designed to automate the download, installation, and configuration of the codebase-memory-mcp binary on Windows systems [1][3]. When executing this script in PowerShell, users may encounter Windows script execution policy restrictions [2][4]. To address this, the project documentation provides the following guidance for bypassing these restrictions: 1. Setting the execution policy for the current process: Run the command Set-ExecutionPolicy -Scope Process Bypass before executing the script [2][4]. 2. Invoking the script with a bypass flag: Alternatively, you can run the script using the following command [2][4]: PowerShell -ExecutionPolicy Bypass -File.\install.ps1 Additionally, because files downloaded from the internet may be blocked by Windows (Mark-of-the-Web), the project recommends unblocking the script before execution using the command Unblock-File .\install.ps1 [2][4]. The official installation procedure provided by the repository is: 1. Download the script: Invoke-WebRequest -Uri https://raw.githubusercontent.com/DeusData/codebase-memory-mcp/main/install.ps1 -OutFile install.ps1 [2][4]. 2. Unblock the file: Unblock-File .\install.ps1 [2][4]. 3. Execute the script: .\install.ps1 (with the execution policy bypassed if necessary) [2][4].

Citations:


🌐 Web query:

site:github.com/DeusData/codebase-memory-mcp install.ps1 Destination $env:LOCALAPPDATA

💡 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.sh

Repository: 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 codebase-memory-mcp. Resolve the installer-provided executable path, or prepend the default install directory before those CLI invocations:

  • scripts/setup-codebase-memory.ps1: use the Windows install path (e.g., $env:LOCALAPPDATA\Programs\codebase-memory-mcp\codebase-memory-mcp) before calling it.
  • scripts/setup-codebase-memory.sh: use "$HOME/.local/bin/codebase-memory-mcp" or update the active PATH.
📍 Affects 2 files
  • scripts/setup-codebase-memory.ps1#L6-L18 (this comment)
  • scripts/setup-codebase-memory.sh#L6-L18
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/setup-codebase-memory.ps1` around lines 6 - 18, The setup scripts
must make the installer-provided executable available before their first CLI
invocation. In scripts/setup-codebase-memory.ps1, resolve or prepend the Windows
default install path
($env:LOCALAPPDATA\Programs\codebase-memory-mcp\codebase-memory-mcp) before
codebase-memory-mcp config set; in scripts/setup-codebase-memory.sh, resolve or
prepend $HOME/.local/bin/codebase-memory-mcp before its corresponding CLI calls.

Comment on lines +9 to +11
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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' . || true

Repository: barisbagirlar-web/SectorCalc

Length of output: 4333


Pin and verify the upstream installer in both bootstrap scripts.

Both scripts execute code downloaded from main (install.ps1/install.sh) before running it, so a compromised or modified upstream branch would execute arbitrary bootstrapping code. Pin the installer source to an immutable reviewed tag/release or commit, and check its digest/attestation before invoking PowerShell or Bash.

📍 Affects 2 files
  • scripts/setup-codebase-memory.ps1#L9-L11 (this comment)
  • scripts/setup-codebase-memory.sh#L9-L12
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/setup-codebase-memory.ps1` around lines 9 - 11, The bootstrap scripts
execute unpinned upstream installers without integrity verification. In
scripts/setup-codebase-memory.ps1 lines 9-11 and
scripts/setup-codebase-memory.sh lines 9-12, change the installer URLs from the
mutable main branch to the same immutable reviewed tag, release, or commit,
verify each downloaded installer against its reviewed digest or attestation, and
invoke PowerShell or Bash only after verification succeeds.

Comment on lines +18 to +22
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 $repoRoot
codebase-memory-mcp cli list_projects

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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"
fi

Repository: barisbagirlar-web/SectorCalc

Length of output: 14306


🌐 Web query:

Microsoft Learn PowerShell about ErrorHandling LASTEXITCODE native programs nonzero exit code ErrorActionPreference Stop

💡 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 $ErrorActionPreference = 'Stop' try { # If the command returns a non-zero exit code, it will now throw an exception &amp; my-native-command.exe } catch { Write-Host "Caught error: $($_.Exception.Message)" } Key Considerations: - Legacy behavior: In older versions of PowerShell (pre-7.3) or when $PSNativeCommandUseErrorActionPreference is $false, native commands will not trigger PowerShell errors, and you must check $LASTEXITCODE manually [1][4][2]. - $?: Regardless of the version, PowerShell sets the $? automatic variable to $true if the exit code is 0 and $false if it is non-zero, providing a quick way to check success without relying on error exceptions [6][7][3]. - Scope: You can scope these preference variables to a specific script block or function to avoid affecting the global session state [8].

Citations:


Check native command exit codes explicitly.

$ErrorActionPreference = 'Stop' only stops PowerShell errors by default; native codebase-memory-mcp failures remain in $LASTEXITCODE, and the script can continue through remaining commands before printing the success message. Add a $LASTEXITCODE check, check $?, or enable PowerShell 7.3+ native-error handling before these calls.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/setup-codebase-memory.ps1` around lines 18 - 22, Update the setup
command sequence in setup-codebase-memory.ps1 to explicitly detect failures from
each native codebase-memory-mcp invocation using $LASTEXITCODE, $?, or supported
PowerShell native-error handling. Stop execution immediately on failure so
subsequent commands and the success message are not reached.

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 $repoRoot

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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:

DeusData codebase-memory-mcp README index_repository repo_path CLI

💡 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 index_repository tool is the primary method for adding a codebase to the server's knowledge graph [4]. It can be invoked via the Command Line Interface (CLI) or through an integrated MCP client [4][5]. Using the CLI To index a repository via the CLI, you use the index_repository tool command, passing a JSON string that specifies the repo_path [4][5]. Basic usage example: codebase-memory-mcp cli index_repository '{"repo_path": "/path/to/your/repository"}' [4][5] Important Configuration and Troubleshooting 1. Path Requirements: You must provide the absolute path to the repository [4][6]. 2. Windows Specifics: Windows users may encounter issues with JSON quoting or path parsing. If you receive a "repo_path is required" error despite specifying the path, it is often due to shell-specific JSON escaping [6][7]. - Recommended fix: Use double quotes to escape internal quotes, for example: codebase-memory-mcp cli index_repository "{"repo_path": "C:/Users/name/projects/repo"}" [6][7] - Alternatively, ensure forward slashes are used in the path [6]. 3. Security: You can optionally set the CBM_ALLOWED_ROOT environment variable to restrict the index_repository tool to specific directories, which is useful in untrusted or multi-tenant environments [4]. For a complete list of tools, configuration options, and language support, refer to the official README at the DeusData/codebase-memory-mcp GitHub repository [1][8].

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.

cli index_repository expects a JSON string with {"repo_path": "...}, so both setup scripts should replace --repo-path "$REPO_ROOT" with that JSON-payload form instead.

📍 Affects 2 files
  • scripts/setup-codebase-memory.ps1#L21-L21 (this comment)
  • scripts/setup-codebase-memory.sh#L18-L18
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/setup-codebase-memory.ps1` at line 21, The indexing commands use the
wrong argument contract. In scripts/setup-codebase-memory.ps1 at line 21 and
scripts/setup-codebase-memory.sh at line 18, update the cli index_repository
invocation to pass a JSON payload containing the repository path, replacing the
separate --repo-path argument while preserving the existing repository-root
values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant