Logo agora-code

agora-code

Cộng đồng
thebnbrkr

Persistent memory and codebase intelligence for AI coding agents, indexes symbols, tracks sessions, and exposes structured project knowledge through an MCP server so agents stop re-reading files and start building on what they already know.

Nhà phát hànhthebnbrkr
Kho mãagora-code
Ngôn ngữPython
Bản fork
11
Sao
47
Công cụ có sẵn
0
Phương thức truyền tảistdio
Danh mục
Giấy phépApache-2.0
Liên kết
  • Kết nối công cụ với quy trình làm việc AI

    agora-code cung cấp các khả năng MCP mà ứng dụng khách và tác nhân AI tương thích có thể sử dụng.

  • 0 công cụ có sẵn

    Xem các thao tác có thể gọi bên dưới, kèm tên và mô tả nếu máy chủ cung cấp.

  • Cấu hình sẵn để sao chép

    Dùng các đoạn cấu hình cài đặt mẫu để thiết lập máy chủ này trong ứng dụng khách MCP bạn muốn dùng.

  • Chỉ số quan tâm đến mã nguồn mở

    47 sao và 11 bản fork từ kho mã được liên kết.

agora-code

Persistent memory and context reduction for AI coding agents. Survives context window resets, new conversations, and agent restarts.


agora-code screenshot

Install

Prerequisites: Python 3.10+ and pip. (Fully tested on macOS.)

Step 1 — Install the package (once, globally)

Open a terminal and run:

bash
pip install git+https://github.com/thebnbrkr/agora-code.git

Verify:

bash
agora-code --version

macOS permission error? (common on macOS system Python) Use --user instead:

bash
pip install --user git+https://github.com/thebnbrkr/agora-code.git

Then add the binary to your PATH — add this line to ~/.zshrc or ~/.bashrc:

bash
export PATH="$(python3 -m site --user-base)/bin:$PATH"

Step 2 — Set up a project

Run this in a terminal outside of Claude Code — Claude Code does not need to be open. (macOS: use Terminal.app.)

Claude Code:

bash
cd your-project
agora-code install-hooks --claude-code

This creates:

  • .claude/settings.json — registers all hooks with Claude Code
  • .claude/hooks/*.sh — the hook scripts that fire automatically
  • ~/.claude/skills/agora-code/SKILL.md — enables /agora-code globally (created once, works in all repos)
  • .mcp.json — registers the memory MCP server

Already have .claude/settings.json? Use --force:

bash
agora-code install-hooks --claude-code --force

Cursor:

Copy the .cursor/ directory from this repo into your project root:

bash
cp -r /path/to/agora-code/.cursor your-project/.cursor

Or clone the repo and copy:

bash
git clone https://github.com/thebnbrkr/agora-code.git /tmp/agora-code
cp -r /tmp/agora-code/.cursor your-project/.cursor

Gemini CLI:

Same approach — copy .gemini/ into your project root:

bash
cp -r /tmp/agora-code/.gemini your-project/.gemini

Restart your editor after setup.


Step 3 — Start using it (Claude Code)

Open Claude Code in your project. At the start of every session, type:

/agora-code

This loads the skill — it tells Claude when to summarize files, when to inject context, and when to save progress. Without it, Claude doesn't know these rules exist.

Your previous session context is injected automatically on session start. To see what was loaded:

bash
agora-code inject

What happens automatically

When you...agora-code automatically...
Start a sessionInjects last checkpoint + relevant learnings from recent commits
Submit a promptRecalls relevant past findings, sets session goal
Read a file > 50 linesSummarizes it via AST — saves 75–95% of tokens
Edit a fileTracks the diff, re-indexes symbols
Run git commitStores learnings derived from the commit
Context window compressesCheckpoints before, re-injects after
End a sessionParses transcript → structured checkpoint in DB

Cursor / Claude Desktop / other MCP editors

For editors without hook support, add to your MCP config:

json
{
  "mcpServers": {
    "agora-memory": {
      "command": "agora-code",
      "args": ["memory-server"]
    }
  }
}

Use which agora-code for the full path if your editor can't find it. Restart your editor.


Optional: better recall with embeddings

(This feature is actively being worked on — behaviour may change.)

By default recall uses FTS5 keyword search — works with no setup. For semantic (fuzzy) search:

bash
export OPENAI_API_KEY=sk-...          # OpenAI text-embedding-3-small
export GEMINI_API_KEY=...             # Gemini gemini-embedding-001
pip install "git+https://github.com/thebnbrkr/agora-code[local]"  # offline, no API key

Two problems it solves

1. Token budget — large files eat your context fast

When an AI reads a 1000-line file it burns ~8000 tokens just for that read. agora-code intercepts every file read and serves a structured AST summary instead of raw source — typically 75–95% fewer tokens while keeping all the signal.

Summarization pipeline:

File typeMethodWhat you get
Pythonstdlib ASTClasses, functions, signatures, docstrings, line numbers
JS, TS, Go, Rust, Java, Ruby, C#, Swift, Kotlin, PHP + 160 moretree-sitter (real AST)Same — exact line numbers, parameter types
JSON / YAMLStructure parserTop-level keys + shape overview
Markdown / textHeading extractorHeadings + opening paragraph
Anything elseRegex fallbackFunction/class names, rough structure

Token counting uses tiktoken (BPE cl100k_base) — the same tokenizer Claude and GPT-4 class models use.

Example: summarizer.py (885 lines) → 8,436 tokens raw → 542 tokens summarized (93.6% reduction).

Summaries are cached in SQLite. Re-reads of the same file on the same branch are served from cache instantly.


2. Memory loss between sessions

AI assistants forget everything when a conversation ends. agora-code persists what you did, why you did it, what files changed, and what non-obvious things you found — then injects the relevant parts automatically at the start of every future session.


How it all works

Storage — three layers

┌─────────────────────────────────────────────────────────┐
│  Layer 1: .agora-code/session.json  (project-local)      │
│  Active session — goal, hypothesis, next steps, files.   │
│  Auto-saved on every checkpoint. Gitignored.             │
└─────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────┐
│  Layer 2: ~/.agora-code/memory.db  (global SQLite)       │
│  Long-term memory — archived sessions, learnings,        │
│  file change history, symbol index.                      │
│  Scoped per project via git remote URL.                  │
└─────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────┐
│  Layer 3: Search                                         │
│  FTS5/BM25 keyword search — always on, zero config.      │
│  Optional: semantic vector search via sqlite-vec.        │
└─────────────────────────────────────────────────────────┘

What's in the database

TableWhat's stored
sessionsSession records — goal, branch, commit SHA, status
learningsPermanent findings — bugs, decisions, API quirks
commit_learningsJunction: commit SHA → learning IDs
file_changesPer-file git diff summaries with commit SHA
file_snapshotsAST summaries per (project, file, branch)
symbol_notesPer-symbol: name, type, line numbers, signature, code block
api_callsHTTP interaction log (for serve / chat commands)

Claude Code hooks

HookEventWhat it does
pre-read.shPreToolUse(Read)AST-summarizes file → if > threshold, blocks read and serves summary
on-read.shPostToolUse(Read)Indexes symbols + stores file snapshot
on-grep.shPostToolUse(Grep)Indexes files matched by grep
on-edit.shPostToolUse(Write/Edit)Tracks diff + re-indexes symbols
on-bash.shPostToolUse(Bash)Detects git commit → tags files → runs learn-from-commit
on-prompt.shUserPromptSubmitRecalls relevant learnings, auto-sets session goal
on-stop.shStopParses transcript → extracts goal/decisions/next steps → checkpoint
on-subagent.shSubagentStartInjects session context into subagents
(inline)PreCompactCheckpoints before context window compresses
(inline)PostCompactRe-injects context after compaction

Cursor hooks

Cursor's hook system works differently — the pre-read hook can't block a read, so instead it redirects the read to a temp file containing the AST summary.

HookEventWhat it does
session-start.shsessionStartInjects session context as additional_context JSON
pre-read.shpreToolUse(Read)Rewrites the read to point to a temp file with the AST summary
post-tool.shpostToolUseTracks tool usage
after-file-edit.shafterFileEditTracks diff + re-indexes symbols
after-shell.shafterShellExecutionSummarizes large shell output
pre-compact.shpreCompactCheckpoints before compaction
session-end.shsessionEndCheckpoints on session end

Gemini CLI hooks

HookEventWhat it does
(inline)SessionStartInjects session context
before-agent.shBeforeAgentInjects fresh context before every agent turn (not just start)
pre-read.shBeforeTool(read_file)Summarizes large files
post-tool.shAfterTool(write/edit)Tracks file changes
(inline)PreCompressCheckpoints before compaction
(inline)SessionEndCheckpoints on exit

Session lifecycle

Session start   → inject: last checkpoint, top learnings from recent
                  commits on this branch, uncommitted file notes,
                  git state, symbol index for dirty files

Each prompt     → on-prompt recalls relevant findings, auto-sets goal

Each file read  → pre-read summarizes → on-read indexes symbols

Each file edit  → on-edit tracks diff + re-indexes symbols

git commit      → on-bash tags files + derives learnings from commit

Session end     → on-stop parses transcript → checkpoint in DB

When done       → agora-code complete --summary "..." archives to long-term

CLI Reference

Session

agora-code inject

Load previous session context. Runs automatically at session start — run manually to see what's loaded.

bash
agora-code inject
agora-code inject --level detail    # more verbose
agora-code inject --raw             # raw session JSON
agora-code inject --quiet           # silent if no session

agora-code checkpoint

Save current session state.

bash
agora-code checkpoint --goal "Refactor auth module"
agora-code checkpoint --next "Write edge case test" --blocker "Waiting on review"
OptionDescription
--goalWhat you're trying to accomplish
--hypothesisCurrent working theory
--actionWhat you're doing right now
--contextFree-text notes
--nextNext step (repeatable)
--blockerBlocker (repeatable)

agora-code complete

Archive session to long-term memory.

bash
agora-code complete --summary "Refactored auth, added retry logic"
agora-code complete --summary "Partial progress" --outcome partial
OptionDescription
--summaryWhat you accomplished
--outcomesuccess / partial / abandoned

agora-code restore

List or restore a past session.

bash
agora-code restore                              # list sessions
agora-code restore 2026-03-08-debug-auth        # restore specific

agora-code status

Show current session and DB statistics.

bash
agora-code status       # global
agora-code status -p    # scoped to current repo

Memory & learnings

agora-code learn

Store a permanent finding for future sessions.

bash
agora-code learn "POST /users rejects + in emails" --tags email,validation
agora-code learn "Rate limit is 100 req/min" --confidence confirmed
OptionDescription
--endpointe.g. POST /users
--evidenceSupporting evidence
--confidenceconfirmed / likely / hypothesis
--tagsComma-separated

agora-code recall

Search past learnings. Semantic if embeddings configured, keyword (BM25) otherwise.

bash
agora-code recall "email validation"
agora-code recall "rate limit" --limit 10
agora-code recall                         # most recent

agora-code remove

Delete a learning by ID (scoped to current repo).

bash
agora-code remove abc12345

agora-code memory

Show DB path, counts, recent sessions and learnings.

bash
agora-code memory
agora-code memory 20
agora-code memory --verbose

Files & symbols

agora-code summarize

Summarize a file via AST. Files under the threshold pass through unmodified.

bash
agora-code summarize agora_code/session.py
agora-code summarize large_file.py --threshold 50
agora-code summarize file.py --json-output      # JSON (used by hooks)

agora-code track-diff

Capture a git diff and store a compact summary. Called automatically by hooks.

bash
agora-code track-diff agora_code/auth.py
agora-code track-diff --all                 # all uncommitted files
agora-code track-diff auth.py --committed   # diff against HEAD~1

agora-code file-history

Show tracked change history for a file.

bash
agora-code file-history agora_code/auth.py --limit 5

agora-code index

Re-index a file into the DB. Called automatically on edit.

bash
agora-code index agora_code/auth.py

Listing commands

bash
agora-code list-sessions        # archived session records
agora-code list-learnings       # permanent findings
agora-code list-snapshots       # AST summaries per file
agora-code list-symbols         # indexed functions and classes
agora-code list-file-changes    # per-file diff history
agora-code list-api-calls       # HTTP calls from serve/chat

All accept -n / --limit. list-symbols also accepts --file <path>.


API tools

agora-code scan

Discover all API routes in a codebase or from a live URL.

bash
agora-code scan ./my-fastapi-app
agora-code scan https://api.example.com
agora-code scan ./my-app --output routes.json

agora-code serve

Start an MCP server for your API.

bash
agora-code serve ./my-api --url http://localhost:8000
json
{
  "mcpServers": {
    "my-api": {
      "command": "agora-code",
      "args": ["serve", "./my-api", "--url", "http://localhost:8000"]
    }
  }
}

agora-code chat

Interactive natural-language chat against your API.

bash
agora-code chat ./my-api --url http://localhost:8000

agora-code memory-server

Start the MCP memory server for any MCP-compatible editor.

bash
agora-code memory-server

MCP Tools Reference

ToolWhen to use
get_session_contextSession start — loads checkpoint, learnings, git state
save_checkpointAfter completing a meaningful step
store_learningNon-obvious finding: bug, gotcha, decision
recall_learningsBefore starting something — check if solved before
get_file_symbolsIndexed functions/classes for a file with line numbers
search_symbolsSearch across all indexed symbols
recall_file_historyWhat changed in a file across past sessions
complete_sessionArchive session to long-term memory
list_sessionsFind past sessions
get_memory_statsDB usage stats

Environment Variables

VariablePurposeDefault
OPENAI_API_KEYOpenAI embeddings + LLM scan—
GEMINI_API_KEYGemini embeddings + LLM scan—
ANTHROPIC_API_KEYClaude for LLM scan + workflow detection—
EMBEDDING_PROVIDERauto / openai / gemini / localauto
AGORA_CODE_DBOverride DB path~/.agora-code/memory.db
AGORA_AUTH_TOKENDefault bearer token for API calls—

Project scoping

All sessions and learnings are scoped to a project via git remote URL:

bash
git remote get-url origin   # → used as project_id

Falls back to directory name if no git remote is set.


Troubleshooting

Testing the pre-read hook (Claude Code)

bash
echo '{"file_path": "/path/to/large-file.py"}' | bash .claude/hooks/pre-read.sh
echo "exit code: $?"
  • Summary + exit code: 2 → hook working correctly
  • No output + exit code: 0 → file is under threshold (pass through)
bash
cat /tmp/agora-pre-read-error.log   # if something went wrong

agora-code not found in hooks

macOS:

bash
pip install --user git+https://github.com/thebnbrkr/agora-code.git
export PATH="$(python3 -m site --user-base)/bin:$PATH"
# add the export to ~/.zshrc or ~/.bashrc

virtualenv / pyenv:

bash
which agora-code
# replace `agora-code` with the full path in the hook scripts

Embeddings not working

Expected without an API key — keyword search still works. To enable semantic search:

bash
export OPENAI_API_KEY=sk-...
# or: export GEMINI_API_KEY=...
# or: pip install "agora-code[local]"

Roadmap

See ROADMAP.md for the full roadmap with rationale.

  • install-hooks --cursor — automate Cursor hook setup (currently manual copy)
  • install-hooks --gemini — automate Gemini CLI hook setup
  • Gemini BeforeToolSelection — filter available tools to reduce tool-choice noise
  • Gemini AfterAgent — response validation, auto-retry on ignored context
  • Gemini BeforeModel — modify LLM request before sending

Contributing

This project is actively developed — issues and PRs are welcome. Things may still break and APIs may change as the project matures.

If you run into something, open an issue. If you want to add hook support for a new editor, the pattern is in .claude/hooks/ and .cursor/hooks/ — the structure is consistent.

Cài đặt

TypingMind
Yêu cầu:

Node.js 18+

{
  "mcpServers": {
    "thebnbrkr-agora-code": {
      "command": "uvx",
      "args": [
        "agora-code"
      ]
    }
  }
}

Dùng MCP agora-code với nhiều mô hình AI

TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên sau khi kết nối agora-code, bạn có thể dùng với nhiều mô hình AI khác nhau trong TypingMind thay vì phải thiết lập riêng cho từng mô hình. MCP này chạy cục bộ thông qua trình kết nối MCP của TypingMind trên thiết bị của bạn.

Hướng dẫn thiết lập để dùng trình kết nối cục bộ

Dùng cách này khi máy chủ MCP cần truy cập các tệp, ứng dụng hoặc tài nguyên riêng tư trên máy tính của bạn.

1

Mở cài đặt MCP

Trong TypingMind, vào Cài đặt, Cài đặt nâng cao, rồi đến Giao thức ngữ cảnh mô hình và chọn Cài trình kết nối.

  1. Mở TypingMind trong trình duyệt của bạn.
  2. Nhấp vào biểu tượng Cài đặt.
  3. Vào Cài đặt nâng cao.
  4. Mở mục Giao thức ngữ cảnh mô hình.
  5. Nhấp vào Cài trình kết nối rồi chọn Thiết bị này.
Màn hình thiết lập trình kết nối MCP của TypingMind với tùy chọn Thiết bị này được chọn
2

Chạy lệnh trình kết nối

Chọn Thiết bị này, sao chép lệnh từ TypingMind và chạy trong Terminal. Giữ tiến trình chạy trong khi bạn dùng MCP.

  1. Sao chép lệnh thiết lập hiển thị trong TypingMind.
  2. Mở Terminal trên macOS hoặc Windows Terminal trên Windows.
  3. Dán và chạy lệnh.
  4. Xác nhận cài đặt gói nếu Terminal hỏi bạn có muốn tiếp tục không.
  5. Giữ tiến trình trong cửa sổ Terminal chạy trong khi dùng các công cụ MCP.
3

Thêm agora-code làm máy chủ

Khi trạng thái trình kết nối là Sẵn sàng, nhấp vào Sửa máy chủ và dán cấu hình máy chủ MCP.

  1. Đợi đến khi trạng thái trình kết nối hiển thị Sẵn sàng.
  2. Nhấp vào Sửa máy chủ.
  3. Dán cấu hình máy chủ MCP của agora-code.
  4. Lưu danh sách máy chủ.
  5. Làm mới nếu bạn muốn xác nhận trình kết nối vẫn sẵn sàng.
Cài đặt MCP của TypingMind hiển thị máy chủ đang hoạt động và nút Sửa máy chủ
{
  "mcpServers": {
    "thebnbrkr-agora-code": {
      "command": "npx",
      "args": [
        "-y",
        "agora-code"
      ]
    }
  }
}
4

Dùng kết nối với nhiều mô hình

Lưu danh sách máy chủ, mở Plugin, bật các công cụ MCP của agora-code, sau đó chọn bất kỳ mô hình AI nào được hỗ trợ trong TypingMind và dùng các công cụ trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.

  1. Mở trang Plugin trong TypingMind.
  2. Bật các công cụ MCP của agora-code.
  3. Bắt đầu cuộc trò chuyện và chọn mô hình AI bạn muốn dùng.
  4. Dùng các công cụ MCP trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.
  5. Chuyển sang mô hình AI khác bất cứ khi nào cần mà không phải kết nối lại MCP.
Cuộc trò chuyện TypingMind dùng các công cụ MCP đã bật với một mô hình AI được chọn
Bạn có thể dùng agora-code giúp tôi làm việc này không?
agora-code
Được. Tôi đã đọc.
Đây là kết quả tôi tìm được bằng agora-code.

Câu hỏi thường gặp

Máy chủ MCP agora-code dùng để làm gì?

agora-code là máy chủ MCP cho phép các ứng dụng AI tương thích kết nối với công cụ và ngữ cảnh bên ngoài. Trong TypingMind, bạn chỉ cần thêm máy chủ MCP này một lần để các công cụ của nó có sẵn trong không gian làm việc AI của bạn.

Bạn có thể dùng MCP agora-code với nhiều mô hình AI trong TypingMind không?

Có. TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên bạn có thể dùng agora-code với nhiều mô hình AI như Claude, ChatGPT, Gemini hoặc các mô hình khác đã cấu hình trong TypingMind mà không cần thiết lập máy chủ MCP riêng cho từng mô hình.

Vì sao nên dùng MCP agora-code với TypingMind?

TypingMind là một trong những giao diện trò chuyện với LLM tốt nhất vì tập hợp nhiều mô hình AI, prompt, plugin, tác nhân AI, khóa API và công cụ MCP vào một không gian làm việc. Khi kết nối agora-code, bạn có thể dùng các công cụ MCP của dịch vụ này với những mô hình ưa thích, đồng thời giữ quy trình trò chuyện gọn gàng trong TypingMind.

Làm cách nào để kết nối MCP agora-code với TypingMind?

agora-code hoạt động thông qua trình kết nối MCP cục bộ của TypingMind. Đây là lựa chọn phù hợp nhất khi máy chủ MCP cần truy cập tệp cục bộ, ứng dụng máy tính, công cụ dòng lệnh hoặc tài nguyên riêng trên máy tính của bạn.

MCP agora-code cung cấp những công cụ nào trong TypingMind?

agora-code cung cấp các chức năng MCP mà bạn có thể bật từ trang Plugin của TypingMind để dùng trong trò chuyện hoặc gán cho tác nhân AI.

Bạn có cần chia sẻ khóa API với TypingMind để dùng MCP agora-code không?

Không. TypingMind ưu tiên xử lý cục bộ và cho phép bạn kiểm soát nhà cung cấp mô hình, khóa API, prompt và cấu hình MCP. Nếu agora-code yêu cầu xác thực, hãy thêm các header, cài đặt OAuth hoặc cấu hình cục bộ cần thiết cho máy chủ MCP đó khi tạo kết nối.

Máy chủ MCP liên quan

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇