robo-cortex

io.github.robotel-limited由 GitHub 帳號 robotel-limited 發布v0.4.1更新於 Oct 24, 2026

Git-aware memory store for AI coding agents; memories are anchored to git blob hashes.

已驗證STDIO僅桌面知識與記憶開發者工具

概覽

AI 產生的概覽

一個本機、感知 git 的記憶庫,讓 AI 程式助理記錄並檢索經驗,並在關聯程式碼變更時自動標記這些記憶。

可以做什麼
robo-cortex 將專案經驗、決策與證據保存在本機 SQLite 資料庫中,並透過 retrieve_context、record_memory、search_memory、attach_evidence、verify_evidence、change_status、get_memory、list_affected 等工具提供給助理。記憶可關聯到以 git blob 雜湊記錄的檔案路徑,當關聯程式碼變更時會自動標記為 needs_review,已提交的回退可使其恢復。每筆記憶都有帶強制稽核原因的狀態生命週期,證據可將 provisional 記憶提升為 active。
適用情境
當助理在 git 儲存庫中反覆重新發現相同的經驗,且你希望這些經驗跨工作階段保留、並在所描述程式碼變更時失效時使用。適合希望使用確定性本機記憶而非嵌入向量或雲端服務的團隊。
執行需求
以本機 Python 套件執行(pip install robo-cortex,MCP 使用需安裝 mcp extra),透過 stdio 啟動,例如使用 uvx。需要 git 儲存庫以支援過時偵測與路徑關聯。不需要 API 金鑰或網路存取;選用的 Gitea 證據驗證使用 ROBO_CORTEX_GITEA_URL。
安裝前請注意
它會寫入本機 SQLite 資料庫(.cortex/memory.db 與 ~/.cortex/global.db),並可安裝 git pre-commit 鉤子,阻擋觸及未複核記憶的提交,但 git commit --no-verify 可繞過。不要把 ROBO_CORTEX_GLOBAL_DB 指向網路檔案系統,SQLite 在並行寫入下可能損毀。狀態變更需要永久的 --reason。選用的 Gitea 驗證是唯一的網路呼叫。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 robo-cortex,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

robo-cortex

[PyPI version] [Python Versions] [License: MIT] [Smithery Calls] [robo-cortex MCP server] [DOI]

[robo-cortex MCP server]

Git-aware knowledge integrity for AI coding agents.

Your AI agent debugs a bug, learns the lesson, and forgets it by next week — or worse, keeps citing a "lesson" that the code has since made false. robo-cortex is a local knowledge base built for that specific failure mode: memories are anchored to git blob hashes, so when the code they're about changes, the memory is automatically flagged for review instead of being silently trusted or silently lost. In other words: drift detection and stale-memory detection for AI agent memory, done deterministically from git history — not an LLM guess, not an embedding-similarity heuristic.


Why robo-cortex, not another memory tool

Most agent-memory tools are embeddings + a vector database + a cloud dependency. robo-cortex is deliberately none of that. Four things it does that a generic key-value memory store doesn't:

  1. Git-aware staleness (drift) detection. Every memory can link to specific file paths, captured by git blob hash at record time. When the linked code changes, the memory is automatically flagged needs_review on the next retrieve/search/affected call — and a committed revert automatically heals it back. The healing requires three conditions: (a) the revert must be committed (git blob hash must match HEAD again), (b) the memory must have been flagged by the system (not manually via change_status), and (c) you must run a lazy trigger (retrieve/search/affected) after the revert to scan for changes. Few memory tools tie themselves to your actual code's history this deterministically — no embedding similarity, no LLM judgment call, just a git blob hash matching or not.
  2. Evidence, not vibes. Memories can carry attached evidence (test output, a commit, a re-runnable command) with a mechanically computed strength — not a judgment call. A provisional memory only becomes active once real evidence backs it, or a human explicitly promotes it.
  3. Zero dependencies, fully local. Pure stdlib + SQLite (FTS5 for search). No embeddings, no API keys, no network calls unless you explicitly configure Gitea evidence verification. .cortex/memory.db is just a file — inspect it with sqlite3 any time.
  4. A real lifecycle with an audit trail. Every status change (active → superseded → archived, etc.) requires a --reason, permanently recorded. Nothing disappears silently; wrong lessons are marked invalidated, not deleted.

Measured impact (benchmark, honestly stated)

A 30-session benchmark (3 real historical bugs from this repo, re-introduced and solved 10× each by a small model — Claude Haiku 4.5 — with and without a robo-cortex memory pack) measured, at identical fix quality (30/30 correct, zero disqualifications): ~12% fewer fresh tokens and ~15% lower API-equivalent cost (medians of paired per-task deltas), scaling up to −26% tokens / −39% cost on the task whose fix was hardest to locate unaided. Recording a lesson was itself metered: a memory pays for itself after ~1–6 sessions that reuse it (median ≈ 5). We make no wall-clock claim — time differences were noise-dominated. Full methodology, per-run raw evidence (usage logs, diffs, prompts), and the reusable harness are in the repo: docs/benchmark-results.md, benchmark-results-20260718/, scripts/benchmark/. Known limits, stated plainly: one subject model (small — an earlier n=3 pilot on a larger model measured a smaller 2.7% effect, see EVALUATION.md §9), one well-documented codebase (likely compresses the effect), 3 task types. We'd rather publish a modest number we measured than a dramatic one we didn't.


Quick Start

Prerequisite: robo-cortex requires a git repository (staleness detection needs git history to compare against):

bash
git init && git add -A && git commit -m "initial commit"

Installation

bash
pip install robo-cortex

If pip install refuses with error: externally-managed-environment (common on recent Debian/Ubuntu), use a virtual environment or pipx:

bash
python3 -m venv .venv && source .venv/bin/activate && pip install robo-cortex# or: pipx install robo-cortex

If you plan to use robo-cortex with an MCP-capable agent (Claude Desktop/Code, etc.), install the MCP extra instead:

bash
pip install 'robo-cortex[mcp]'

Usage

bash
cd /path/to/your/projectroco init
# Record a project-specific lesson (scope=repo: no extra fields needed)roco record --type lesson --scope repo \  --statement "Copy-to-clipboard fails on HTTP; use a textarea+execCommand fallback." \  --confidence high
# Retrieve it laterroco retrieve --task "copy to clipboard http"
matched=1 returned=1 needs_review=0 contradicted=0[1] score=0.650 repo   lesson       Copy-to-clipboard fails on HTTP; use a textarea+execCommand fallback.

--path links a memory to a file, but only accepts a path that already exists at HEAD (no memory is ever born pointing at a dead link). For code you just wrote but haven't committed yet: record the memory without --path now, commit, then attach the path afterward:

bash
roco record --type decision --scope repo --statement "..." --confidence high# id=7, no linked path yet
git add new_module.py && git commit -m "add new_module.py"roco record 7 --add-path new_module.py

Reusable lessons (not specific to this project) use scope=global and require --assumptions — the conditions under which the lesson applies, so it doesn't get suggested everywhere by accident:

bash
roco record --type lesson --scope global \  --statement "Safari 14 breaks CSS grid+gap. Use flexbox+margin instead." \  --confidence high \  --assumptions "css grid gap safari"

Global-scope commands (record --scope global, show, search, status, link, evidence, list) work from anywhere, including outside any git repository — the global store (~/.cortex/global.db) isn't tied to a project. retrieve is the one exception: it's local-repo-aware by design, so it still requires an initialized repo.

Enable enforcement (recommended)

bash
roco hooks install

Installs a git pre-commit hook: if the commit touches code linked to a memory that's active/provisional/needs_review, the commit is blocked with the memory's id and a review prompt, until you've reviewed it or bypassed explicitly. Example, for a memory linked to src/scanner.py when that file is part of the commit:

robo-cortex: this commit touches code linked to memories that need review:  [1] path_changed:src/scanner.py@working_tree  scanner batches at 50 items deliberately
Review with: roco show <id>Then either re-verify (roco status <id> activate --reason "...") or supersede it, and commit again.To bypass this check: git commit --no-verify

The bypass is real and documented — git commit --no-verify skips it, same as any git hook. This is "enforcement by default, bypass explicit," not "impossible to skip." See roco hooks --help for uninstall/status. For a CI-level check on pull requests instead of (or in addition to) local commits, see docs/ci-example.yml.

There's also an optional post-commit hook, purely informational (it never blocks — the commit it reports on already happened by the time it runs):

bash
roco hooks install --post-commit

It runs roco affected --diff-range HEAD~1..HEAD after each commit and reports anything at risk, so a flag shows up immediately instead of waiting for the next retrieve/search/affected call. --post-commit also works with uninstall/status, independently of the pre-commit hook.


Shorthand: roco

Both robo-cortex and roco are identical commands (same binary, two script entry points). Use whichever fits your fingers:

bash
roco retrieve --task "..."          # Shorter aliasrobo-cortex retrieve --task "..."   # Full name, backwards compatible

Name collision note: PyPI already has an unrelated package named roco ("Runtime Config Generator"). If that package is also installed in the same environment, whichever was installed last wins the roco command — use the full robo-cortex name to be unambiguous, or check roco --version to confirm which one you're actually running.

Shell completion

bash
roco completion bash >> ~/.bashrc

Completes subcommand names and each subcommand's own flags (not flag values, and not nested sub-subcommands like hooks install). It's a static script generated from the installed version — re-run the command after upgrading to pick up new commands or flags.


Three ways to use it

ScenarioBest methodWhy
One-off CLI commands (shell, scripts, manual testing)CLI: roco retrieve --task "..."Simplest, no dependencies, immediate
Python agent or script running your own codePython SDK: from robo_cortex import retrieve, recordIn-process (no subprocess), real exceptions, not string-parsed errors
LLM agent (Claude Code, or any MCP client) with tool-callingMCP server: add to your MCP configAgent decides when to call; tool descriptions ship with the package

All three call the same underlying robo_cortex.core functions — pick based on what the calling code already uses.

MCP configuration

json
{  "mcpServers": {    "robo-cortex": {      "command": "roco",      "args": ["mcp", "--repo", "/path/to/project"]    }  }}

Available tools: retrieve_context, record_memory, search_memory, attach_evidence, verify_evidence, change_status, get_memory, list_affected. Full contract in MCP_TOOLS.md.

Python SDK

python
from robo_cortex import retrieve, record
memories = retrieve("feature description", repo_path="/srv/project")if memories["data"]:    print(f"Found solution: {memories['data'][0]['statement']}")
record(    type="lesson",    statement="What you learned",    confidence="high",    repo_path="/srv/project",)

Full API, including the RoboCortex class for multiple calls against the same repo, in PYTHON_SDK.md.


Memory Lifecycle: Status Transitions

Every memory has a status that reflects its confidence and applicability. New memories start provisional; manual review or evidence changes their status:

StatusMeaningCan transition to
provisionalNew memory, not yet validatedactive, needs_review, abandoned
activeConfident, applicable to future workneeds_review, superseded, invalidated, archived, abandoned
needs_reviewSuspect or context-dependent; needs human judgmentactive, superseded, invalidated
supersededReplaced by a better solution (must link to replacement ID)archived
invalidatedProven false or no longer applicablearchived
abandonedLesson that went nowhere; dead-end explorationarchived
archivedTerminal state (read-only)—

Automatic Transitions

  • provisional → active: happens automatically when you attach evidence to a memory (roco evidence add) — the first supporting data promotes the memory to trusted.

Manual Transitions

Use roco status <id> <verb> --reason "..." to change status manually:

bash
# Promote a provisional memory (no evidence yet)roco status 5 activate --reason "Tested and validated on three projects"
# Mark a memory as superseded by a better lessonroco status 7 supersede --supersedes 12 --reason "Version 2 of this pattern handles edge cases better"
# Mark as proven falseroco status 9 invalidate --reason "Benchmark shows this optimization actually makes things slower"
# Archive old/resolved itemsroco status 3 archive --reason "No longer applicable after database migration"

--reason is mandatory and permanent — it becomes part of the memory's audit history and cannot be edited.


Deciding Scope (Global vs Repo)

Use scope=repo for project-specific learnings:

  • This codebase's chosen patterns (we use FastAPI + SQLAlchemy)
  • Project-specific decisions (batch size tuned for our infrastructure)
  • Test: "Does this reference our code, infra, or team decision?"

Use scope=global for reusable lessons:

  • Browser/library bugs (Safari CSS, Node.js async patterns)
  • Language/framework patterns
  • Best practices (SQL injection prevention)

scope=global requires assumptions — the preconditions under which the lesson applies:

json
{  "type": "lesson",  "scope": "global",  "statement": "Copy-to-clipboard fails on HTTP. Use textarea + execCommand() fallback.",  "assumptions": "Web app with clipboard feature, needs to work on HTTP",  "confidence": "high"}

Sharing knowledge across projects

bash
roco export --scope global --output kb.jsonl# In another project:roco import kb.jsonl

Import is idempotent (re-importing the same file skips duplicates by id+scope) and validated exactly like record — a scope=global line missing assumptions, or an invalid type/confidence, is skipped with a warning, not silently inserted or a raw database error.

Two projects that learned independently can converge with roco merge:

bash
roco merge kb_a.jsonl kb_b.jsonl --output kb_merged.jsonl# Both projects then: roco import kb_merged.jsonl

De-duplicates by ID+scope; conflicts resolved by confidence (higher wins), tie-broken by timestamp. See EXPORT_IMPORT.md for the full workflow, including team-KB and backup use cases.

Do not point ROBO_CORTEX_GLOBAL_DB at a network filesystem (NFS/SMB) for "shared team memory." SQLite is not safe for concurrent writers over a network mount and can corrupt the database. Share via export/import through git instead — it's versioned and auditable, which a live-shared file isn't.


FAQ

Q: Do I need a git repository? A: Yes. Staleness detection, path linking, and affected all compare against git history. Without git, you can still use export/import/merge to move knowledge between machines, but the git-aware features won't work.

Q: What if I (or my agent) forget to check memory? A: roco hooks install blocks a commit that touches code linked to an unreviewed memory — but the bypass (git commit --no-verify) is real and always available, same as any git hook. This is enforcement-by-default with an explicit escape hatch, not an unconditional guarantee.

Q: Stale notes are dangerous. A: Memories auto-flag needs_review when their linked code changes. You review before trusting, or mark as superseded. Nothing silently misleads.

Q: Sharing memory across teams? A: Two approaches:

  • Snapshot sharing (versioned, audited): export from one project, commit the JSONL to git, team members import.
  • Live shared database: set ROBO_CORTEX_GLOBAL_DB=/path/to/shared/global.db on a local path all roco invocations can reach — not a network mount (see warning above).

Q: Offline? A: Yes. Everything is local SQLite. Zero network calls unless you explicitly configure Gitea evidence verification (ROBO_CORTEX_GITEA_URL).

Q: Wrong lesson? A: Mark as invalidated with a reason. Preserved in history, never suggested going forward.

Q: Read-only database? A: retrieve/search/affected degrade gracefully on a read-only .cortex/memory.db (read-only checkouts, some CI setups). Reads return their result, writes (staleness refresh, usage tracking) are skipped, and meta includes a warning. The memory core still works, just without incidental writes that don't affect correctness.

Q: How do I opt out of the global store? A: Set ROBO_CORTEX_NO_GLOBAL=1. CLI and MCP both skip opening ~/.cortex/global.db entirely — retrieve/search scopes strictly to the current repo, with no cross-project knowledge channel. Useful if you want strict per-project isolation.

Q: What's the expected scale? A: robo-cortex is designed and tested for thousands of memories per store (repo-scoped and global combined). Performance degrades gracefully beyond that — scoring stays O(n) per candidate, and FTS candidate set is capped at 200 for each store. If you have significantly more memories than that, consider splitting into multiple projects or archiving old memories. See ARCHITECTURE.md for details.


Architecture

Codebase    ↓git pre-commit hook (roco hooks install) -- blocks commits touching unreviewed memories    ↓robo-cortex Memory (SQLite + FTS5)    ↓.cortex/memory.db (repo)  +  ~/.cortex/global.db (shared)    ↓retrieve_context() → ranked memories with evidence, gated by staleness + assumptions

No embeddings. No cloud. Just SQLite, git awareness, and an explicit enforcement layer you can inspect (.git/hooks/pre-commit is plain shell, readable in five seconds).


Learn More


Made By

Free to use. Made available by Robotel Limited UK (https://robotel.top).

The architecture was designed with Anthropic's Claude (Fable) on July 2026 as an AI development agent, applying the expertise of Robotel Limited’s developers, who bring over three years of hands-on experience building and operating AI coding agents in production.

MIT License. Open source. No telemetry. No vendor lock-in.

來源:README.md,提交 5d1f2ba

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.4.1最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分