一键导入
adding-adapters
Guide for adding new CLI adapters to cliagents. Use when creating a new adapter for a CLI tool like Claude Code, Gemini CLI, Codex, etc.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Guide for adding new CLI adapters to cliagents. Use when creating a new adapter for a CLI tool like Claude Code, Gemini CLI, Codex, etc.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when creating, modifying, or reviewing a cliagents provider adapter for a CLI tool such as Codex, Claude Code, Gemini CLI, Qwen CLI, or OpenCode.
Use when operating as a supervised root that delegates work to child sessions through cliagents
Use when reducing prompt size for roots and child sessions without losing the information needed to execute well
Use when passing work between agents with context preservation
Use when exploring design options or solving open-ended problems
Use when reviewing code for quality, bugs, security, and maintainability
| name | adding-adapters |
| description | Guide for adding new CLI adapters to cliagents. Use when creating a new adapter for a CLI tool like Claude Code, Gemini CLI, Codex, etc. |
| allowed-tools | Read, Write, Edit, Glob, Grep |
src/adapters/my-cli.jsBaseLLMAdapter classsrc/server/index.jssrc/server/openai-compat.jsconst BaseLLMAdapter = require('../core/base-llm-adapter');
const { spawn } = require('child_process');
class MyCliAdapter extends BaseLLMAdapter {
constructor(config = {}) {
super(config);
this.name = 'my-cli';
this.timeout = config.timeout || 120000;
}
async isAvailable() {
// Check if CLI is installed
try {
const { execSync } = require('child_process');
execSync('which my-cli', { stdio: 'ignore' });
return true;
} catch {
return false;
}
}
getAvailableModels() {
return ['model-1', 'model-2'];
}
async *send(sessionId, message, options = {}) {
// Implement streaming response
const process = spawn('my-cli', ['--prompt', message]);
for await (const chunk of process.stdout) {
yield {
type: 'progress',
progressType: 'assistant',
content: chunk.toString()
};
}
yield { type: 'result', content: fullResponse };
}
async terminate(sessionId) {
// Cleanup
}
}
module.exports = MyCliAdapter;
| Method | Purpose |
|---|---|
isAvailable() | Check if CLI is installed |
getAvailableModels() | Return list of supported models |
send(sessionId, message, options) | Async generator yielding response chunks |
terminate(sessionId) | Cleanup resources |
In src/server/index.js:
const MyCliAdapter = require('../adapters/my-cli');
this.sessionManager.registerAdapter('my-cli', new MyCliAdapter(options.myCli || {}));
In src/server/openai-compat.js MODEL_MAP:
'my-model': { adapter: 'my-cli', model: 'model-1' },
Add test in tests/run-all.js:
await testAdapter('my-cli', 'My CLI');
See existing adapters:
src/adapters/claude-code.js - Full-featured with session resumesrc/adapters/gemini-cli.js - Config file managementsrc/adapters/codex-cli.js - Simple spawn pattern