Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 43 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# agent-commander

A JavaScript library to control agents enclosed in CLI commands like Anthropic Claude Code CLI, OpenAI Codex, OpenCode, Qwen Code, and @link-assistant/agent.
A JavaScript library to control agents enclosed in CLI commands like Anthropic Claude Code CLI, OpenAI Codex, OpenCode, Qwen Code, Gemini CLI, and @link-assistant/agent.

Built on the success of [hive-mind](https://github.com/link-assistant/hive-mind), `agent-commander` provides a flexible JavaScript interface and CLI tools for managing agent processes with various isolation levels.

Expand All @@ -12,6 +12,7 @@ Built on the success of [hive-mind](https://github.com/link-assistant/hive-mind)
- `codex` - OpenAI Codex CLI
- `opencode` - OpenCode CLI
- `qwen` - Qwen Code CLI (Alibaba's AI coding agent)
- `gemini` - Gemini CLI (Google's AI coding agent)
- `agent` - @link-assistant/agent (unrestricted OpenCode fork)
- **Multiple Isolation Modes**:
- No isolation (direct execution)
Expand Down Expand Up @@ -58,7 +59,8 @@ bun add agent-commander
| `codex` | OpenAI Codex CLI | ✅ | ❌ | `gpt5`, `o3`, `gpt4o` |
| `opencode` | OpenCode CLI | ✅ | ❌ | `grok`, `gemini`, `sonnet` |
| `qwen` | Qwen Code CLI | ✅ (stream-json) | ✅ (stream-json) | `qwen3-coder`, `coder`, `gpt-4o` |
| `agent` | @link-assistant/agent | ✅ | ❌ | `grok`, `sonnet`, `haiku` |
| `gemini` | Gemini CLI | ✅ (stream-json) | ❌ | `flash`, `pro`, `lite` |
| `agent` | @link-assistant/agent | ✅ | ✅ | `grok`, `sonnet`, `haiku` |

### Claude-specific Features

Expand All @@ -83,6 +85,28 @@ The [Qwen Code CLI](https://github.com/QwenLM/qwen-code) supports additional fea
- **Partial messages**: Use `--include-partial-messages` with stream-json for real-time UI updates
- **Model flexibility**: Supports Qwen3-Coder models plus OpenAI-compatible models via API

### Gemini-specific Features

The [Gemini CLI](https://github.com/google-gemini/gemini-cli) supports additional features:

- **Stream JSON format**: Uses `--output-format stream-json` for real-time NDJSON streaming
- **Auto-approval mode**: Use `--yolo` flag for automatic action approval (enabled by default)
- **Sandbox mode**: Use `--sandbox` flag for secure tool execution in isolated environment
- **Checkpointing**: Use `--checkpointing` to save project snapshots before file modifications
- **Debug output**: Use `-d` flag for detailed debug output
- **Model selection**: Use `-m` flag to select model (e.g., `gemini-2.5-flash`, `gemini-2.5-pro`)
- **Interactive mode**: Use `-i` flag with prompt to start interactive session

### Agent-specific Features

The [@link-assistant/agent](https://github.com/link-assistant/agent) supports additional features:

- **JSON Input/Output**: Accepts JSON via stdin, outputs JSON event streams (OpenCode-compatible)
- **Unrestricted access**: No sandbox, no permissions system - full autonomous execution
- **13 built-in tools**: Including websearch, codesearch, batch - all enabled by default
- **MCP support**: Model Context Protocol for extending functionality with MCP servers
- **OpenCode compatibility**: 100% compatible with OpenCode's JSON event streaming format

## CLI Usage

### start-agent
Expand All @@ -95,7 +119,7 @@ start-agent --tool claude --working-directory "/tmp/dir" --prompt "Solve the iss

#### Options

- `--tool <name>` - CLI tool to use (e.g., 'claude', 'codex', 'opencode', 'qwen', 'agent') [required]
- `--tool <name>` - CLI tool to use (e.g., 'claude', 'codex', 'opencode', 'qwen', 'gemini', 'agent') [required]
- `--working-directory <path>` - Working directory for the agent [required]
- `--prompt <text>` - Prompt for the agent
- `--system-prompt <text>` - System prompt for the agent
Expand Down Expand Up @@ -136,6 +160,11 @@ start-agent --tool agent --working-directory "/tmp/dir" --prompt "Analyze code"
start-agent --tool qwen --working-directory "/tmp/dir" --prompt "Review this code" --model qwen3-coder
```

**Using Gemini**
```bash
start-agent --tool gemini --working-directory "/tmp/dir" --prompt "Explain this code" --model flash
```

**With model fallback (Claude)**
```bash
start-agent --tool claude --working-directory "/tmp/dir" \
Expand Down Expand Up @@ -259,6 +288,14 @@ const qwenAgent = agent({
prompt: 'Review this code',
model: 'qwen3-coder',
});

// Using Gemini CLI
const geminiAgent = agent({
tool: 'gemini',
workingDirectory: '/tmp/project',
prompt: 'Explain this code',
model: 'flash',
});
```

### Streaming JSON Messages
Expand Down Expand Up @@ -373,7 +410,7 @@ await myAgent.start({ dryRun: true });
import { getTool, listTools, isToolSupported } from 'agent-commander';

// List all available tools
console.log(listTools()); // ['claude', 'codex', 'opencode', 'agent', 'qwen']
console.log(listTools()); // ['claude', 'codex', 'opencode', 'agent', 'gemini', 'qwen']

// Check if a tool is supported
console.log(isToolSupported({ toolName: 'claude' })); // true
Expand All @@ -394,7 +431,7 @@ console.log(fullId); // 'claude-opus-4-5-20251101'
Creates an agent controller.

**Parameters:**
- `options.tool` (string, required) - CLI tool to use ('claude', 'codex', 'opencode', 'qwen', 'agent')
- `options.tool` (string, required) - CLI tool to use ('claude', 'codex', 'opencode', 'qwen', 'gemini', 'agent')
- `options.workingDirectory` (string, required) - Working directory
- `options.prompt` (string, optional) - Prompt for the agent
- `options.systemPrompt` (string, optional) - System prompt
Expand Down Expand Up @@ -562,6 +599,7 @@ agent-commander/
│ │ ├── codex.mjs # Codex CLI config
│ │ ├── opencode.mjs # OpenCode CLI config
│ │ ├── qwen.mjs # Qwen Code CLI config
│ │ ├── gemini.mjs # Gemini CLI config
│ │ └── agent.mjs # @link-assistant/agent config
│ ├── streaming/ # JSON streaming utilities
│ │ ├── index.mjs # Stream exports
Expand Down
121 changes: 121 additions & 0 deletions docs/case-studies/issue-15/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Case Study: JSON Output/Input Documentation Accuracy

**Issue:** [#15 - Double check for JSON Output and JSON Input for all our tools](https://github.com/link-assistant/agent-commander/issues/15)

This document captures the investigation and resolution of documentation discrepancies in the agent-commander README.md regarding JSON input/output support for supported CLI tools.

## Overview

The issue identified two documentation problems:
1. **Missing Gemini CLI** - Not listed in the Supported Tools table despite being fully implemented
2. **Incorrect Agent CLI JSON Input status** - Marked as ❌ but actually supports JSON input

## Investigation Methodology

### Data Collection

1. **Repository Analysis**: Examined the codebase for actual tool configurations
2. **External Verification**: Checked upstream repositories (@link-assistant/agent, google-gemini/gemini-cli)
3. **Code Review**: Analyzed `js/src/tools/*.mjs` configuration files
4. **Documentation Review**: Cross-referenced README.md claims with actual capabilities

### Evidence Sources

| Source | Location | Key Finding |
|--------|----------|-------------|
| agent.mjs | js/src/tools/agent.mjs:246 | `supportsJsonInput: true` |
| gemini.mjs | js/src/tools/gemini.mjs | Full Gemini CLI implementation |
| tools/index.mjs | js/src/tools/index.mjs:21 | Exports `geminiTool` |
| @link-assistant/agent | GitHub README | "JSON Input/Output: Accepts JSON via stdin" |
| google-gemini/gemini-cli | GitHub README | Supports `--output-format stream-json` |

## Root Cause Analysis

### Problem 1: Missing Gemini in README

**Root Cause**: The Gemini CLI tool was added to the codebase in a previous update (gemini.mjs created, index.mjs updated), but the README.md Supported Tools table was not updated to include this new tool.

**Evidence**:
- `js/src/tools/gemini.mjs` exists with full implementation (318 lines)
- `js/src/tools/index.mjs` imports and exports `geminiTool`
- README.md table only lists: claude, codex, opencode, qwen, agent

### Problem 2: Incorrect Agent JSON Input Status

**Root Cause**: Documentation lag - the Agent CLI's JSON input capability was either overlooked during initial documentation or the capability was added after documentation was written.

**Evidence**:
- `js/src/tools/agent.mjs:246` explicitly states `supportsJsonInput: true`
- @link-assistant/agent README states: "JSON Input/Output: Accepts JSON via stdin, outputs JSON event streams (OpenCode-compatible)"
- The code comments in agent.mjs line 71 confirm: "Agent uses stdin for prompt input (NDJSON streaming supported)"

## Timeline of Events

1. **Initial Release**: agent-commander released with support for claude, codex, opencode, agent, qwen
2. **Agent JSON Support**: Agent CLI implemented full JSON input/output (based on OpenCode compatibility)
3. **Gemini Addition**: Gemini CLI tool added to codebase (gemini.mjs created)
4. **Documentation Gap**: README.md not updated to reflect Gemini addition or Agent JSON input capability
5. **Issue #15**: Documentation inconsistency discovered and reported

## Solution Implementation

### Changes Made to README.md

1. **Added Gemini to Supported Tools Table**:
```markdown
| `gemini` | Gemini CLI | ✅ (stream-json) | ❌ | `flash`, `pro`, `lite` |
```

2. **Fixed Agent JSON Input Status**:
```markdown
| `agent` | @link-assistant/agent | ✅ | ✅ | `grok`, `sonnet`, `haiku` |
```

3. **Added Gemini-specific Features Section**:
- Stream JSON format documentation
- Yolo mode (auto-approval) documentation
- Sandbox mode documentation
- Checkpointing support documentation
- Model configuration documentation

4. **Updated Feature List**:
- Added `gemini` to the Multiple CLI Agents list
- Updated description to include Gemini CLI

### Verification

| Tool | JSON Output | JSON Input | Verified Source |
|------|-------------|------------|-----------------|
| claude | ✅ (stream-json) | ✅ (stream-json) | Code + README |
| codex | ✅ | ❌ | Code analysis |
| opencode | ✅ | ❌ | Code analysis |
| qwen | ✅ (stream-json) | ✅ (stream-json) | Code + README |
| agent | ✅ | ✅ | Code + upstream README |
| gemini | ✅ (stream-json) | ❌ | Code + upstream README |

## Lessons Learned

1. **Documentation-Code Sync**: When adding new tools or capabilities, update documentation in the same commit/PR
2. **Verification Process**: Cross-reference code configurations with upstream tool documentation
3. **Case Studies**: Documenting the investigation helps prevent similar issues and provides institutional knowledge

## Files Modified

| File | Changes |
|------|---------|
| README.md | Added Gemini to table, fixed Agent JSON Input, added Gemini features section |
| docs/case-studies/issue-15/README.md | This case study document |
| docs/case-studies/issue-15/evidence-timeline.md | Investigation evidence and timeline |

## References

- [google-gemini/gemini-cli](https://github.com/google-gemini/gemini-cli) - Official Gemini CLI repository
- [@link-assistant/agent](https://github.com/link-assistant/agent) - Agent CLI repository
- [Gemini CLI Headless Mode](https://geminicli.com/docs/cli/headless/) - JSON output documentation
- [Issue #15](https://github.com/link-assistant/agent-commander/issues/15) - Original issue report

## Conclusion

The documentation discrepancies were caused by documentation lag rather than technical issues. The actual code implementations were correct - only the README.md needed updating to accurately reflect the supported tools and their capabilities.

Key insight: Maintaining accurate documentation requires systematic verification against both the codebase and upstream tool capabilities. Creating case studies for such investigations helps prevent similar issues and provides a reference for future contributors.
Loading
Loading