⚡ CompText V5:Claude代理团队的原生协议
将上下文污染减少94%
   
CompText V5 是用于的本地协议 克劳德代理团队它充当高速压缩层,允许代理以94%的令牌开销交换上下文。
CompText将详细上下文压缩为紧凑的命令结构(C;P:FIB)与原始文本摄入相比,令牌使用量减少了94%。
______________________________________________________________________
📊 性能指标(v5.0)
对大型命令集的本地解析进行了测试。
| 度量 | 原始文本/详细 | CompText协议 | 影响 |
|---|---|---|---|
| 代币开销 | ~100个令牌/cmd | ~5个令牌/cmd | 📉 节省94% |
| 解析速度 | 线性文本扫描 | O(1)直接访问 | ⚡ 瞬间 |
| 稳定性 | 变量(取决于LLM) | 确定性的 | ✅ 零损失 |
💸 效率可视化
*CompText协议通过单字符命令映射实现了94%的令牌减少。*
______________________________________________________________________
🚀 快速开始
安装
pip install comptext-codex基本用法
# Parse a compressed command
comptext parse "C;P:FIB"
# Output:
# Command: CODE, Language: PYTHON, Task: FIB
# Interactive mode
comptext interactive
# Get full command reference
comptext referencePython API
from comptext_codex.parser_v5 import CompTextParserV5
parser = CompTextParserV5()
result = parser.parse("C;P:FIB")
print(result[0].command) # CODE
print(result[0].language) # PYTHON
print(result[0].task) # FIB______________________________________________________________________
🎯 主要特点
单字符命令语法
Natural: "Write a Python function to calculate Fibonacci sequence"
CompText: "C;P:FIB"
Savings: 83.3% token reduction命令词汇:
C=代码|F=修复|M=修改|T=测试D=文件|E=解释|O=优化|A=分析
语言代码:
PpythonJ=JavaScript|T=TypeScriptR=生锈|G=开始|S=SQL|H=HTML
批量操作
在一次压缩调用中处理多个命令:
B:[C;P:FIB]|[T;P:FIB]|[D:FIB]执行:生成→ Test → 文档(全部为斐波那契)
MCP集成
# Start MCP server
comptext-mcp
# Use with any MCP-compatible client
# Server provides 8 tool endpoints for compression/parsing______________________________________________________________________
📚 文档
______________________________________________________________________
💰 现实世界影响
成本节约计算器
场景:生产AI代理(每月10万API调用)
Without CompText: 100K × 10 tokens × $0.003/1K = $3,000/month
With CompText: 100K × 1 token × $0.003/1K = $300/month
Monthly Savings: $2,700
Annual Savings: $32,400代币减少示例:
| 任务 | 自然语言 | CompText V5.0 | 精简 |
|---|---|---|---|
| 简单代码 | 6个令牌 | 1个令牌 | 83.3% |
| 测试生成 | 13个令牌 | 1个令牌 | 92.3% |
| 批量操作 | 12个令牌 | 1个令牌 | 91.7% |
| 复杂工作流 | 15个令牌 | 1个令牌 | 93.3% |
| 平均 | 67个代币 | 4个代币 | 94.0% |
______________________________________________________________________
🏗️ 建筑
运作原理
CompText使用 确定性映射 而不是冗长的文本:
Agent → "C;P:FIB" → Parser → {command: CODE, language: PYTHON, task: FIB}优点:
- 即时解析 (减压不需要LLM)
- 零幻觉 (确定性查找)
- 向后兼容 (V4.0命令仍受支持)
组件
- 解析器v5.py -核心压缩发动机
- cli_v5.py -交互式终端界面
- mcpserver_v5.py -MCP协议集成
______________________________________________________________________
🧪 测试与质量
# Run test suite
pytest tests/
# Results: 10/10 tests passing (100% coverage)测试覆盖范围:
- ✅ 基本命令解析
- ✅ 批量操作
- ✅ 编码/解码往返
- ✅ 边缘情况和错误处理
- ✅ 现实世界场景
______________________________________________________________________
🔧 CLI参考
# Parse commands
comptext parse "C;P:FIB"
# Encode to V5.0 format
comptext encode --command CODE --language PYTHON --task FIB
# Benchmark token reduction
comptext benchmark "Write Python Fibonacci"
# Interactive shell
comptext interactive
# Get command reference
comptext reference
# Show examples
comptext examples______________________________________________________________________
🌟 OpenClaw集成
CompText包括一个即用型 OpenClaw技能 对于自动代理优化:
cd integrations/openclaw
npm install
npm publish --access public特征:
- 自动提示压缩
- 代理API调用成本降低94%
- MCP兼容集成
看 OpenClaw自述文件 了解详情。
______________________________________________________________________
🤝 贡献
我们欢迎捐款!CompText是 麻省理工学院许可 完全开源。
# Clone repository
git clone https://github.com/ProfRandom92/comptext-codex.git
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Submit PR______________________________________________________________________
📄 许可证
MIT许可证 -请参阅 许可证 文件
免费供商业和个人使用。没有限制。
______________________________________________________________________
🔗 链接
- PyPI包: https://pypi.org/project/comptext-codex/
- 文档: https://profrandom92.github.io/comptext-docs
- 主页: https://comptext-txsu.vercel.app
- 问题: https://github.com/ProfRandom92/comptext-codex/issues
______________________________________________________________________
⭐ 星迹
如果CompText为您节省了API成本,请在回购中加星!

______________________________________________________________________
🏆 学分
内置于❤️ 通过 ProfRandom92 和 克劳德·十四行诗4.5
特别感谢:
- CompText社区
- OpenClaw贡献者
- MCP协议团队
______________________________________________________________________
立即安装并开始节省LLM API成本:
pip install comptext-codex