redcon

io.github.natiixnt由 GitHub 账号 natiixnt 发布v1.15.0更新于 Oct 27, 2026

Deterministic context packing for AI coding agents; measured 83% fewer input tokens, local.

概览

AI 生成的概览

Redcon 为 AI 编程助手打包仓库上下文:在本地对文件与命令输出进行排序、压缩和 token 预算控制,并提供九个 MCP 工具。

可以做什么
  • 排序与概览仓库:按任务相关度给出前 K 个文件及分数与理由、按目录分组的仓库概览、以及适配 token 预算的仓库地图
  • 查看与搜索代码:单文件压缩视图、限定在排序文件或全仓库的正则搜索、基于 AST 的结构化搜索
  • 规划 token 预算:把选中的文件装入指定的最大 token 数
  • 运行并压缩命令:执行 shell 命令并返回按预算压缩的输出,另可做质量校验以确认关键事实未丢失
适用场景
适合助手在代码仓库中工作、希望减少探索阶段输入 token 的场景,也适合想要确定性、本地化上下文选择而非整文件倾倒或盲目 grep 的情况。同样可用于 CI 中的上下文增长检查与命令输出精简。
运行要求
作为本地进程运行,从 PyPI 安装 redcon(含 mcp 附加包),用 uvx 或 pip 启动。需要 Python 和本地仓库副本;排序会用到 git 历史。未声明任何账号、API 密钥或环境变量。
安装前请注意
redcon_run 工具会在你的机器上执行任意 shell 命令并返回其输出,应谨慎限定使用范围。init 命令会为多个编辑器写入 MCP 配置文件,并向 AGENTS.md 追加一段内容。扫描在本地读取仓库文件;说明中未提及向第三方传输数据。

安装

在 SourceWeft 中

  1. 打开 控制台中的 redcon,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

Redcon

Deterministic context budgeting for AI coding agents

Stop sending agents 200k tokens of irrelevant code. Redcon scores, compresses, and packs repo context so your agent gets what it actually needs.

[PyPI] [Tests] [Python 3.10+] [VS Code Extension] [License: FSL-1.1-MIT]

Install - Quick Start - How It Works - Docs


The Problem

AI coding agents burn tokens on irrelevant context. You either:

  • Dump the whole repo and pay for 200k input tokens per request, or
  • Let the agent grep blindly and waste tool calls figuring out where to look

Redcon solves both. It ranks files by task relevance, compresses them with language-aware strategies (full, snippet, symbol extraction, summary), and packs the result under your token budget. Deterministic, local-first, no embeddings. One MCP server covers Claude Code, Cursor, Windsurf, Cline and Zed; a plain CLI covers CI. Measured on this repository it cuts input tokens by more than 83% at the same task coverage (methodology).

Punch above your plan

On a flat subscription - Claude Pro/Max, Cursor, GitHub Copilot - the token bill isn't what stings, the usage limit is. Redcon cuts the tokens each task needs, so the same plan covers far more work before you hit the weekly wall. Same subscription, more runway.

It stretches the budget you already pay for, and reports exactly how much it saved.

Install

Option 1: VS Code Extension (easiest)

  1. Install Redcon - Context Budget from the marketplace
  2. Open the Redcon sidebar, click Install & Set Up
  3. Reload window. Done.

The extension installs the CLI via pip, registers the MCP server for Claude Code, Cursor, and Windsurf, and gives you a sidebar with budget analytics, file rankings, and compression dashboards.

Option 2: CLI + MCP Server

bash
pip install "redcon[mcp]"redcon init                      # creates redcon.toml + registers MCP

The init command auto-configures MCP for Claude Code, Cursor and Windsurf, plus VS Code, Codex CLI, Gemini CLI, Junie CLI, Cline and Zed when they are detected, so your AI agent can call redcon_rank, redcon_search, redcon_compress, and redcon_budget as native tools. It also writes a short AGENTS.md section that tells agents to prefer these tools for context selection.

Option 3: CLI only

bash
pip install redconredcon init --no-mcp

Quick Start

bash
# Rank files relevant to a taskredcon plan "add rate limiting to auth API" --repo .
# Pack context under a token budgetredcon pack "refactor payment flow" --repo . --max-tokens 30000
# Compare compression strategiesredcon benchmark "add caching" --repo .
# Audit a PR for context growthredcon pr-audit --repo . --base origin/main --head HEAD

Output goes to run.json (machine-readable) and run.md (human-readable). Use them in CI, or feed the compressed context directly into your agent.

For a full end-to-end walkthrough on a realistic service repo (plan, pack, validate, with deterministic output), see examples/service-repo.

How It Works

task: "add rate limiting to auth"       |       v  [1] scan    - incremental scan of repo files (cached)       |       v  [2] rank    - score each file: keyword match, imports, file role, git history       |       v  [3] compress - per-file strategy: full / snippet / symbol extraction / summary       |       v  [4] pack    - fit top-N compressed files under token budget, drop the rest       |       v  run.json + run.md + compressed_context ready for your agent

Every step is deterministic. Same input, same output. No embeddings, no random chunking.

Benchmark: context-eval

Selection quality is measured, not claimed. context-eval/ is an open benchmark for context-selection tools: tasks come from real git commits, ground truth is the files each commit actually modified, and every tool packs the same token budget. Current results (33 tasks, 24k budget):

ToolMean coverageTokens / coverage point
redcon43.8%306.8
keyword-topk (baseline)29.8%538.9
aider-repomap (real aider)15.3%533.3
pagerank (baseline)11.4%720.0

Rerun it on any repo: python context-eval/run.py --repo /path/to/repo. Methodology, limitations, and how to add your own tool: context-eval/README.md.

MCP Integration (Pull Model)

mcp-name: io.github.natiixnt/redcon

Instead of pushing a 30k-token blob to your agent, Redcon exposes 9 MCP tools the agent calls on demand:

ToolWhat it does
redcon_rankTop-K files with scores and reasons - call this first
redcon_overviewLightweight repo map grouped by directory
redcon_repo_mapTop ranked files plus their code signatures, fitted under a token budget
redcon_compressCompressed single-file view for cheap inspection
redcon_searchRegex search scoped to ranked files or full repo
redcon_structural_searchast-grep structural search - patterns match the AST, not text
redcon_budgetPlan fitting files within a token budget
redcon_runRun a shell command, return its output compressed
redcon_quality_checkRun a command and verify the compressed output against the quality harness

Typical agent flow uses ~5k tokens for exploration instead of 30k for a blob. The agent itself decides what to read in full.

Config gets written automatically to:

  • .mcp.json (Claude Code)
  • .cursor/mcp.json (Cursor)
  • ~/.codeium/windsurf/mcp_config.json (Windsurf)

Command Output Compression

Source files are only half the bloat. The other half is command output: git diff, pytest, cargo test, grep, ls -R. Redcon's redcon_run MCP tool (and redcon run CLI) wraps the call, parses the output, and returns a budget-aware compressed view that preserves every fact the agent actually needs.

Headline reductions on representative inputs:

CompressorFixtureRaw tokensCompactUltra
git diff12 files, 240 hunks8,07897.0%99.5%
pytest30 failures + 200 passes2,55573.8%99.2%
grep/rg600 matches across 50 files7,01576.9%99.9%
find500 paths3,39881.3%99.8%
ls -R30 dirs x 15 files1,54333.5%99.0%
kubectl events200-row CrashLoopBackOff~5,00091.5%99.5%
py-spy collapsed200 stacks2,38590.0%99.0%
json-line log200 NDJSON records6,03891.1%98.0%
coverage report50-file grid73873.2%95.0%
psql EXPLAIN ANALYZE11-node Postgres plan43571.3%93.3%

Quality is enforced separately. Every compressor declares must_preserve_patterns (file paths in a diff, failing test names in pytest, branch name in git status, slowest node operator in EXPLAIN); the M8 quality harness rejects any compressor whose compact output drops a fact present in the raw input. Run it as a CI step:

bash
redcon cmd-quality   # exits non-zero if any compressor regressedredcon cmd-bench     # markdown table; --json for CI baselinesredcon run "git diff" --quality-floor compact --max-output-tokens 4000

Twenty compressors ship today: git_diff, git_status, git_log, pytest, cargo_test, npm_test (vitest+jest), go_test, grep, ls, tree, find, lint (ruff+mypy), docker, pkg_install (pip+npm+yarn), kubectl_get/kubectl_events, profiler (py-spy+perf), json_log, coverage, sql_explain (Postgres+MySQL TREE), bundle_stats (webpack + esbuild metafiles). Full per-schema benchmarks: docs/benchmarks/cmd/.

Cross-call dimension

Beyond per-call compression, four layers compose across an agent session:

  • Path aliases (V41): repeated paths like redcon/cmd/pipeline.py collapse to f001 on later mentions. Lazy first-use, never net-negative.
  • Content reference ledger (V43): paragraph-shaped blocks above 6 cl100k tokens get session-stable {ref:001} aliases on second-and-later occurrences. Empirically 23% of session output had block-level overlap.
  • Symbol aliases (V49): CamelCase types / multi-word snake_case identifiers (>=8 chars) collapse to c001 aliases the same way paths do. Empirically 72% of distinct symbols recur >=2 times per session.
  • Snapshot delta vs prior call (V47): when the same argv runs twice, ship only the delta. Schema-aware renderers for pytest (set-diff over failure names), git_diff (file-set with per-file +/- counts), and coverage (per-file pp moves) win meaningfully over generic line-diff. Always picks min(cost_delta, cost_abs) so non-regressive by construction.
  • Invariant cert (V93): every COMPACT/VERBOSE output stamps mp_sha=<16hex> over the sorted multiset of (pattern, capture) extracted from raw. Auditors recompute the cert against the compressed text to detect spurious additions or capture thinning - upgrades the existing must-preserve boolean to set-equality.

Empirical measurement on 5 simulated agent sessions (benchmarks/measure_sessions.py): the cross-call layers add +8.3% session-level saving on top of the per-call compressors, with +15% on heavy-overlap sessions (debugging, search-and-edit) and near-zero on distinct-content sessions. V85 adversarial GA fuzzer ratchets all 20 schemas as a hard CI gate (REDCON_V85_ENFORCE=1).

VS Code Extension

Once installed you get:

  • Sidebar chat: type a task, send, watch the pack run live
  • Dashboard: donut/pie/bar charts for budget, strategies, token impact per file
  • Status bar: current budget usage with risk indicator
  • CodeLens: compression strategy and token count shown above each file
  • File decorations: relevance score badges on files in the explorer
  • History: browse past runs, diff them, export to clipboard

Branding: red->navy gradient with triple chevron mark, glass-style UI.

Workspaces (Multi-Repo)

One task can span multiple repos. Place the workspace TOML in a folder that contains all the repos (a monorepo root or a common parent directory) - repo paths must resolve inside that folder, so a workspace file cannot reach above itself:

toml
name = "backend-services"
[scan]include_globs = ["**/*.py", "**/*.ts"]
[budget]max_tokens = 28000top_files = 24
[[repos]]label = "auth-service"path = "auth-service"
[[repos]]label = "billing-service"path = "billing-service"ignore_globs = ["tests/fixtures/**"]

Artifacts include workspace, scanned_repos, selected_repos, and repo-qualified paths like auth-service:src/auth.py.

See docs/workspace.md.

Python API

python
from redcon import RedconEngine
engine = RedconEngine()
# Rank filesplan = engine.plan(task="add user auth", repo=".", top_files=15)
# Pack contextresult = engine.pack(    task="add user auth",    repo=".",    max_tokens=30000,    top_files=25,)print(f"Used {result['budget']['estimated_input_tokens']} of {result['max_tokens']} tokens")print(f"Risk: {result['budget']['quality_risk_estimate']}")
for file in result["compressed_context"]:    print(f"{file['path']}: {file['strategy']} ({file['compressed_tokens']} tokens)")

Full reference: docs/python-api.md.

Features

  • Deterministic scoring: keyword match, import graph, file role (test/docs/prod), git history
  • Language-aware compression: Python, TypeScript, JavaScript, Go, Rust, Java, and more
  • Command output compression: 20 compressors covering git, test runners, grep/rg, listings, lint, docker, pkg-install, kubectl, profilers, JSON logs, coverage, SQL EXPLAIN, and bundle stats - 70-99% reduction at compact level
  • Incremental scanning: cached file metadata with git-aware change detection
  • Multi-repo workspaces: single task, multiple repos, shared config
  • Budget policies: enforce max tokens, quality risk levels, file counts in CI
  • Quality harness: must-preserve regex assertions per compressor, deterministic, robust to truncated/binary input
  • Streaming runner: chunked Popen reader with bounded memory and early SIGTERM/SIGKILL when output cap is hit
  • Run history: SQLite-backed artifact store for both file packs and command runs, diff/heatmap/drift analysis
  • Cost analysis: estimate token costs across GPT-4o, Claude, and other models
  • PR auditing: detect context growth in pull requests
  • Plugin system: custom scorers, compressors, token estimators, summarizers
  • Cache backends: in-memory, local file, Redis
  • Doctor command: diagnose environment, Python version, disk space, git availability

Documentation

License

Everything in this repository is licensed under the Functional Source License, FSL-1.1-MIT: use it freely for any purpose except building a competing commercial product or service. Each release automatically becomes MIT-licensed two years after it ships.

The hosted Redcon Cloud control plane (orgs, quotas, usage metering, billing, team dashboards) is separate commercial software maintained in a private repository.

Commercial licensing: [email protected]

来源:README.md,提交 fa3569a

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v1.15.0最新Sep 16, 2026

评分

已满足适用检查项的 40%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分

    请在仓库或注册中心条目中声明许可证。