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
10 changes: 10 additions & 0 deletions cli-anything-plugin/.trae-plugin/mcp-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"mcpServers": {
"cli-anything": {
"command": "python",
"args": [
"D:\\AwesomeGithub\\CLI-Anything\\cli-anything-plugin\\mcp_server.py"
]
}
}
}
34 changes: 34 additions & 0 deletions cli-anything-plugin/.trae-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "cli-anything",
"description": "Build powerful, stateful CLI interfaces for any GUI application using the cli-anything harness methodology.",
"author": {
"name": "cli-anything contributors"
},
"commands": [
{
"name": "cli-anything",
"description": "Build a complete, stateful CLI harness for any GUI application",
"trigger": "/cli-anything"
},
{
"name": "cli-anything-refine",
"description": "Refine an existing CLI harness to improve coverage",
"trigger": "/cli-anything:refine"
},
{
"name": "cli-anything-test",
"description": "Run tests for a CLI harness",
"trigger": "/cli-anything:test"
},
{
"name": "cli-anything-validate",
"description": "Validate a CLI harness against HARNESS.md standards",
"trigger": "/cli-anything:validate"
},
{
"name": "cli-anything-list",
"description": "List all available CLI-Anything tools",
"trigger": "/cli-anything:list"
}
]
}
159 changes: 159 additions & 0 deletions cli-anything-plugin/TRAE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
# CLI-Anything Trae Integration Guide

This guide explains how to integrate CLI-Anything plugin with Trae IDE and use it to build CLI tools for applications like Shotcut.

## Table of Contents

1. [Background](#background)
2. [Prerequisites](#prerequisites)
3. [Configure MCP Server](#configure-mcp-server)
4. [Use MCP Server](#use-mcp-server)
5. [Install and Use Shotcut CLI](#install-and-use-shotcut-cli)
6. [FAQ](#faq)

---

## Background

### What is CLI-Anything?

CLI-Anything is a framework for building CLI interfaces for GUI applications. It converts any GUI application into a CLI tool that AI Agents can use.

### What is Trae?

Trae is an AI-native IDE developed by ByteDance, supporting AI capability extension through MCP (Model Context Protocol).

### Why MCP Server?

Trae and Claude Code use different plugin systems. Claude Code uses `.claude-plugin` directory, while Trae uses MCP Server mechanism. Therefore, CLI-Anything needs to be wrapped as an MCP Server to work with Trae.

---

## Prerequisites

### 1. Install Python Dependencies

```bash
pip install mcp click prompt-toolkit lxml pytest
```

### 2. Ensure CLI-Anything Plugin Exists

CLI-Anything plugin should be located at:
```
D:\AwesomeGithub\CLI-Anything\cli-anything-plugin\
```
Comment on lines +42 to +45

This directory should contain:
- `commands/` - Command definition files
- `HARNESS.md` - Methodology documentation
- `mcp_server.py` - MCP Server implementation
- `.trae-plugin/` - Trae IDE configuration

---

## Configure MCP Server

### Step 1: Create .trae-plugin Directory

Create `.trae-plugin` directory under `cli-anything-plugin`:

```bash
mkdir cli-anything-plugin\.trae-plugin
```

### Step 2: Create mcp-config.json

Create `mcp-config.json` in `.trae-plugin` directory:

```json
{
"mcpServers": {
"cli-anything": {
"command": "python",
"args": [
"D:\\AwesomeGithub\\CLI-Anything\\cli-anything-plugin\\mcp_server.py"
]
}
}
}
```
Comment on lines +65 to +80

### Step 3: Create plugin.json

Create `plugin.json` in `.trae-plugin` directory:

```json
{
"name": "cli-anything",
"version": "1.0.0",
"description": "Build CLI harnesses for any GUI application",
"entry": "mcp_server.py"
Comment on lines +89 to +91
}
```

---

## Use MCP Server

### In Trae IDE:

1. Open Settings → Plugins
2. Find "MCP Servers" or "Custom Servers"
3. Click "Add Server"
4. Select the `mcp-config.json` file from `cli-anything-plugin\.trae-plugin\`
5. Restart Trae IDE

After configuration, you can use the `cli_anything` tool in Trae's AI chat to build CLI tools for any application.

---

## Install and Use Shotcut CLI

### Build CLI for Shotcut

In Trae IDE, use the following command:

```
Use cli_anything to build a CLI tool for Shotcut, path is D:\AwesomeGithub\shotcut
```

### Install the Built CLI

```bash
cd D:\AwesomeGithub\shotcut\agent-harness
pip install -e .
```

### Run Tests

```bash
cd D:\AwesomeGithub\shotcut\agent-harness
python -m pytest cli_anything/shotcut/tests/ -v
```

### Use Shotcut CLI

```bash
shotcut-cli --help
```

---

## FAQ

### Q: MCP Server fails to start?

A: Check Python path in `mcp-config.json` is correct. Ensure all dependencies are installed.

### Q: Tool not available in Trae?

A: Restart Trae IDE after configuring MCP Server. Check plugin settings.

### Q: How to update CLI-Anything?

A: Pull latest changes from repository and restart Trae IDE.

---

For more information, visit: https://github.com/HKUDS/CLI-Anything
147 changes: 147 additions & 0 deletions cli-anything-plugin/mcp_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
#!/usr/bin/env python3
"""
CLI-Anything MCP Server for Trae IDE
Using FastMCP framework for simpler setup
"""

from mcp.server.fastmcp import FastMCP
from pathlib import Path

PLUGIN_DIR = Path(__file__).parent
COMMANDS_DIR = PLUGIN_DIR / "commands"
HARNESS_PATH = PLUGIN_DIR / "HARNESS.md"

mcp = FastMCP("CLI-Anything")


def load_command_md(command_name: str) -> str:
"""Load command definition from markdown file"""
cmd_file = COMMANDS_DIR / f"{command_name}.md"
if cmd_file.exists():
return cmd_file.read_text(encoding="utf-8")
return ""


@mcp.tool()
def cli_anything(software_path: str) -> str:
"""Build a complete, stateful CLI harness for any GUI application"""
cmd_doc = load_command_md("cli-anything")
return f"""# CLI-Anything Build Command

## Instructions
{cmd_doc}

## Usage
To build a CLI harness, provide the software path or GitHub URL:

- Local path: `{software_path}`
- GitHub URL: `https://github.com/user/repo`

The agent will follow the HARNESS.md methodology to:
1. Analyze the codebase
2. Design CLI architecture
3. Implement the CLI
4. Create tests
5. Document everything
"""


@mcp.tool()
def cli_anything_refine(software_path: str, focus: str = "All capabilities") -> str:
"""Refine an existing CLI harness to improve coverage"""
cmd_doc = load_command_md("refine")
return f"""# CLI-Anything Refine Command

## Instructions
{cmd_doc}

## Usage
To refine an existing CLI harness:

- Base path: `{software_path}`
- Focus area: {focus}

The agent will analyze gaps and expand coverage.
"""


@mcp.tool()
def cli_anything_test(software_path: str) -> str:
"""Run tests for a CLI harness"""
cmd_doc = load_command_md("test")
return f"""# CLI-Anything Test Command

## Instructions
{cmd_doc}

## Usage
Software path: {software_path}
"""


@mcp.tool()
def cli_anything_validate(software_path: str) -> str:
"""Validate a CLI harness against HARNESS.md standards"""
cmd_doc = load_command_md("validate")
return f"""# CLI-Anything Validate Command

## Instructions
{cmd_doc}

## Usage
Software path: {software_path}
"""


@mcp.tool()
def cli_anything_list(path: str = ".", depth: int = 0, json_output: bool = False) -> str:
"""List all available CLI-Anything tools"""
import os
import json

tools = []
search_dir = Path(path)

def scan_dir(p, current_depth):
if depth > 0 and current_depth > depth:
return
Comment on lines +105 to +107
if not p.exists():
return
for item in p.iterdir():
if item.is_dir():
cli_file = item / "agent-harness" / "cli_anything"
if cli_file.exists():
tools.append({
"name": item.name,
"path": str(item),
"status": "generated"
})
Comment on lines +110 to +118
scan_dir(item, current_depth + 1)
Comment on lines +108 to +119

scan_dir(search_dir, 0)

if json_output:
return json.dumps(tools, indent=2)

return f"Found {len(tools)} CLI tools:\n\n" + "\n".join(f"- {t['name']}: {t['path']} ({t['status']})" for t in tools)


@mcp.tool()
def get_harness_doc() -> str:
"""Get the HARNESS.md documentation for cli-anything methodology"""
if HARNESS_PATH.exists():
return HARNESS_PATH.read_text(encoding="utf-8")
return "HARNESS.md not found"


@mcp.tool()
def get_command_doc(command_name: str) -> str:
"""Get documentation for a specific cli-anything command"""
content = load_command_md(command_name)
if not content:
content = load_command_md(f"cli-anything-{command_name}")
return content or f"Command {command_name} not found"
Comment on lines +138 to +143


if __name__ == "__main__":
mcp.run()
Loading