Discover MCPs & agents
Loading MCPs and agents…
Loading MCPs and agents…
Automatically manage AI CLI coding tool context to prevent no-reply issues
Jump to setup instructionsFetched from the repository for this visit.
Language / 语言 / 言語: 🇨🇳 简体中文 | 🇺🇸 English | 🇯🇵 日本語
CLI Context Manager 是一个通用的 OpenClaw 技能,用于自动管理和优化 AI CLI coding 工具的会话上下文。通过智能压缩过大的会话文件,可以有效避免因上下文过大导致的无回复问题。
| 工具 | 状态 |
|---|---|
| Claude Code | ✅ 完全支持 |
| Aider | ✅ 完全支持 |
| Codex | ✅ 完全支持 |
| Gemini CLI | ✅ 完全支持 |
| OpenCode | ✅ 完全支持 |
| 自定义工具 | ✅ 支持配置 |
# 克隆仓库
git clone https://github.com/zhujingyuan7/cli-context-manager.git
# 进入目录
cd cli-context-manager
# 配置工具路径(可选)
# 编辑 CONFIG.json
# 复制到 OpenClaw skills 目录
cp -r cli-context-manager ~/.openclaw/skills/
# 或者在 Windows 上
xcopy /E /I cli-context-manager %USERPROFILE%\.openclaw\skills\cli-context-manager
编辑 CONFIG.json 文件来自定义行为:
{
"thresholds": {
"maxSizeKB": 500,
"maxLines": 300
},
"compression": {
"keepMessages": 100,
"keepSystemLines": 5,
"createBackup": true
},
"tools": {
"claude-code": {
"sessionDir": "~/.claude/sessions",
"enabled": true
},
"aider": {
"sessionDir": "~/.aider/sessions",
"enabled": true
},
"codex": {
"sessionDir": "~/.codex/sessions",
"enabled": true
},
"gemini-cli": {
"sessionDir": "~/.gemini-cli/sessions",
"enabled": true
},
"opencode": {
"sessionDir": "~/.opencode/sessions",
"enabled": true
}
}
}
| 参数 | 说明 |
|---|---|
maxSizeKB | 触发压缩的文件大小阈值(KB) |
maxLines | 触发压缩的行数阈值 |
keepMessages | 压缩后保留的消息数量 |
keepSystemLines | 压缩后保留的系统配置行数 |
createBackup | 是否在压缩前创建备份文件 |
在 HEARTBEAT.md 中添加以下内容:
## CLI Context Management
当 AI CLI 工具无回复时(replies=0):
powershell -ExecutionPolicy Bypass -File C:\path\to\cli-context-manager\scripts\auto-compress-sessions.ps1
# 进入脚本目录
cd C:\path\to\cli-context-manager
# 自动压缩所有会话
powershell -ExecutionPolicy Bypass -File scripts\auto-compress-sessions.ps1
# 进入脚本目录
cd /path/to/cli-context-manager
# 检查会话健康状态
node scripts/check-session-health.js
# 压缩指定会话
node scripts/compress-session.js ~/.cursor/sessions/session-id.jsonl
# 压缩时指定参数
node scripts/compress-session.js session.jsonl --keep-messages 50 --no-backup
检测问题
↓
查找会话文件
↓
检查大小和行数
↓
是否超过阈值? --否--> 结束
↓是
创建备份
↓
智能压缩
↓
验证结果
↓
清理备份
↓
完成
可能原因:
解决方案:
# 检查工具日志
tail -f ~/.tool/logs/current.log
# 验证会话格式
node scripts/check-session-health.js --verify
# 重启工具
killall tool-name && tool-name
可能原因:
解决方案:
# 查找会话文件
find ~ -name "*.jsonl" -type f
# 更新配置
# 编辑 CONFIG.json
解决方案:
# 清理所有备份
rm ~/.tool/sessions/*.backup
⚠️ 重要警告:
.gitignore 中添加 *.jsonl 和 *.backupCONFIG.json 中添加配置示例:
{
"tools": {
"my-tool": {
"sessionDir": "~/.my-tool/sessions",
"enabled": true,
"format": "jsonl"
}
}
}
欢迎贡献!请遵循以下步骤:
MIT License - 详见 LICENSE 文件
感谢所有贡献者和支持者!
CLI Context Manager is a universal OpenClaw skill for automatically managing and optimizing session contexts of AI CLI coding tools. By intelligently compressing oversized session files, it effectively prevents no-reply issues caused by excessive context.
| Tool | Status |
|---|---|
| Claude Code | ✅ Fully Supported |
| Aider | ✅ Fully Supported |
| Codex | ✅ Fully Supported |
| Gemini CLI | ✅ Fully Supported |
| OpenCode | ✅ Fully Supported |
| Custom Tools | ✅ Configurable |
# Clone repository
git clone https://github.com/zhujingyuan7/cli-context-manager.git
# Enter directory
cd cli-context-manager
# Configure tool paths (optional)
# Edit CONFIG.json
# Copy to OpenClaw skills directory
cp -r cli-context-manager ~/.openclaw/skills/
# Or on Windows
xcopy /E /I cli-context-manager %USERPROFILE%\.openclaw\skills\cli-context-manager
Edit the CONFIG.json file to customize behavior:
{
"thresholds": {
"maxSizeKB": 500,
"maxLines": 300
},
"compression": {
"keepMessages": 100,
"keepSystemLines": 5,
"createBackup": true
},
"tools": {
"claude-code": {
"sessionDir": "~/.claude/sessions",
"enabled": true
},
"aider": {
"sessionDir": "~/.aider/sessions",
"enabled": true
},
"codex": {
"sessionDir": "~/.codex/sessions",
"enabled": true
},
"gemini-cli": {
"sessionDir": "~/.gemini-cli/sessions",
"enabled": true
},
"opencode": {
"sessionDir": "~/.opencode/sessions",
"enabled": true
}
}
}
| Parameter | Description |
|---|---|
maxSizeKB | File size threshold for compression (KB) |
maxLines | Line count threshold for compression |
keepMessages | Number of messages to retain after compression |
keepSystemLines | Number of system config lines to retain |
createBackup | Whether to create backup file before compression |
Add the following to HEARTBEAT.md:
## CLI Context Management
When AI CLI tool has no replies (replies=0):
powershell -ExecutionPolicy Bypass -File C:\path\to\cli-context-manager\scripts\auto-compress-sessions.ps1
# Enter script directory
cd C:\path\to\cli-context-manager
# Auto compress all sessions
powershell -ExecutionPolicy Bypass -File scripts\auto-compress-sessions.ps1
# Enter script directory
cd /path/to/cli-context-manager
# Check session health
node scripts/check-session-health.js
# Compress specific session
node scripts/compress-session.js ~/.cursor/sessions/session-id.jsonl
# Compress with parameters
node scripts/compress-session.js session.jsonl --keep-messages 50 --no-backup
Detect Problem
↓
Find Session Files
↓
Check Size & Lines
↓
Exceeds threshold? --No--> Done
↓Yes
Create Backup
↓
Intelligent Compression
↓
Verify Results
↓
Clean Backup
↓
Complete
Possible Causes:
Solutions:
# Check tool logs
tail -f ~/.tool/logs/current.log
# Verify session format
node scripts/check-session-health.js --verify
# Restart tool
killall tool-name && tool-name
Possible Causes:
Solutions:
# Find session files
find ~ -name "*.jsonl" -type f
# Update configuration
# Edit CONFIG.json
Solutions:
# Clean all backups
rm ~/.tool/sessions/*.backup
⚠️ Important Warning:
*.jsonl and *.backup to .gitignoreCONFIG.jsonExample:
{
"tools": {
"new-tool": {
"sessionDir": "~/.new-tool/sessions",
"enabled": true,
"format": "jsonl"
}
}
}
Contributions are welcome! Please follow these steps:
MIT License - See LICENSE file for details
Thanks to all contributors and supporters!
CLI Context Manager は、AI CLIコーディングツールのセッションコンテキストを自動的に管理・最適化する汎用的なOpenClawスキルです。過大なセッションファイルをインテリジェントに圧縮することで、コンテキスト過多による無応答問題を効果的に防止します。
| ツール | 状態 |
|---|---|
| Claude Code | ✅ 完全にサポート |
| Aider | ✅ 完全にサポート |
| Codex | ✅ 完全にサポート |
| Gemini CLI | ✅ 完全にサポート |
| OpenCode | ✅ 完全にサポート |
| カスタムツール | ✅ 設定可能 |
# リポジトリをクローン
git clone https://github.com/zhujingyuan7/cli-context-manager.git
# ディレクトリに移動
cd cli-context-manager
# ツールのパスを設定(オプション)
# CONFIG.jsonを編集
# OpenClaw skillsディレクトリにコピー
cp -r cli-context-manager ~/.openclaw/skills/
# またはWindows上で
xcopy /E /I cli-context-manager %USERPROFILE%\.openclaw\skills\cli-context-manager
CONFIG.json ファイルを編集して動作をカスタマイズ:
{
"thresholds": {
"maxSizeKB": 500,
"maxLines": 300
},
"compression": {
"keepMessages": 100,
"keepSystemLines": 5,
"createBackup": true
},
"tools": {
"claude-code": {
"sessionDir": "~/.claude/sessions",
"enabled": true
},
"aider": {
"sessionDir": "~/.aider/sessions",
"enabled": true
},
"codex": {
"sessionDir": "~/.codex/sessions",
"enabled": true
},
"gemini-cli": {
"sessionDir": "~/.gemini-cli/sessions",
"enabled": true
},
"opencode": {
"sessionDir": "~/.opencode/sessions",
"enabled": true
}
}
}
| パラメータ | 説明 |
|---|---|
maxSizeKB | 圧縮をトリガーするファイルサイズのしきい値(KB) |
maxLines | 圧縮をトリガーする行数のしきい値 |
keepMessages | 圧縮後に保持するメッセージ数 |
keepSystemLines | 圧縮後に保持するシステム構成行数 |
createBackup | 圧縮前にバックアップファイルを作成するかどうか |
HEARTBEAT.md に以下を追加:
## CLI Context Management
AI CLIツールが応答しない場合(replies=0):
powershell -ExecutionPolicy Bypass -File C:\path\to\cli-context-manager\scripts\auto-compress-sessions.ps1
# スクリプトディレクトリに移動
cd C:\path\to\cli-context-manager
# すべてのセッションを自動圧縮
powershell -ExecutionPolicy Bypass -File scripts\auto-compress-sessions.ps1
# スクリプトディレクトリに移動
cd /path/to/cli-context-manager
# セッションの健全性をチェック
node scripts/check-session-health.js
# 特定のセッションを圧縮
node scripts/compress-session.js ~/.cursor/sessions/session-id.jsonl
# パラメータを指定して圧縮
node scripts/compress-session.js session.jsonl --keep-messages 50 --no-backup
問題を検出
↓
セッションファイルを検索
↓
サイズと行数を確認
↓
しきい値を超えている? --いいえ--> 完了
↓はい
バックアップを作成
↓
インテリジェント圧縮
↓
結果を検証
↓
バックアップをクリーンアップ
↓
完了
考えられる原因:
解決策:
# ツールログを確認
tail -f ~/.tool/logs/current.log
# セッション形式を検証
node scripts/check-session-health.js --verify
# ツールを再起動
killall tool-name && tool-name
考えられる原因:
解決策:
# セッションファイルを検索
find ~ -name "*.jsonl" -type f
# 設定を更新
# CONFIG.jsonを編集
解決策:
# すべてのバックアップをクリーンアップ
rm ~/.tool/sessions/*.backup
⚠️ 重要な警告:
.gitignore に *.jsonl と *.backup を追加CONFIG.json に設定を追加例:
{
"tools": {
"new-tool": {
"sessionDir": "~/.new-tool/sessions",
"enabled": true,
"format": "jsonl"
}
}
}
コントリビューションを歓迎します!以下の手順に従ってください:
MIT License - 詳細は LICENSE ファイルを参照
すべてのコントリビューターとサポーターに感謝します!
🇨🇳 简体中文 | 🇺🇸 English | 🇯🇵 日本語
Made with ❤️ by 小7
GitHub checked 207h ago - refresh overdue. Recently viewed repositories target hourly refresh.
Find a documented setup for your client. No sign-in, installation, or tool execution.
If this MCP is also published on mcpchannel.ai, you can subscribe from Browse and use the gateway config there instead.