diff --git a/.claude/CLAUDE.md b/.claude/CLAUDE.md index 7c45401f..ffa467be 100644 --- a/.claude/CLAUDE.md +++ b/.claude/CLAUDE.md @@ -1,10 +1,6 @@ -# Development Guidelines -## Overview - -This document defines project-specific coding standards and development principles. -### CLI Tool Context Protocols -For all CLI tool usage, command syntax, and integration guidelines: +### Tool Context Protocols +For all tool usage, command syntax, and integration guidelines: - **Tool Strategy**: @~/.claude/workflows/tool-strategy.md - **Intelligent Context Strategy**: @~/.claude/workflows/intelligent-tools-strategy.md - **Context Search Commands**: @~/.claude/workflows/context-search-strategy.md diff --git a/.claude/workflows/tool-strategy.md b/.claude/workflows/tool-strategy.md index 50b94a48..e9ed4c0f 100644 --- a/.claude/workflows/tool-strategy.md +++ b/.claude/workflows/tool-strategy.md @@ -10,107 +10,61 @@ - Complex API research → Exa Code Context - Real-time information needs → Exa Web Search -## ⚡ CCW Tool Execution +## ⚡ CCW MCP Tools -### General Usage (JSON Parameters) +**优先使用 MCP 工具** (无需 Shell 转义,直接 JSON 参数) -```bash -ccw tool exec '{"param": "value"}' -``` - -**Examples**: -```bash -ccw tool exec get_modules_by_depth '{}' -ccw tool exec classify_folders '{"path": "./src"}' -``` - -**Available Tools**: `ccw tool list` - -### edit_file Tool +### edit_file **When to Use**: Edit tool fails 1+ times on same file -```bash -# Basic edit -ccw tool exec edit_file --path "file.py" --old "old code" --new "new code" - -# Preview without modifying (dry run) -ccw tool exec edit_file --path "file.py" --old "old" --new "new" --dry-run - -# Replace all occurrences -ccw tool exec edit_file --path "file.py" --old "old" --new "new" --replace-all - -# Line mode - insert after line -ccw tool exec edit_file --path "file.py" --mode line --operation insert_after --line 10 --text "new line" - -# Line mode - insert before line -ccw tool exec edit_file --path "file.py" --mode line --operation insert_before --line 5 --text "new line" - -# Line mode - replace line -ccw tool exec edit_file --path "file.py" --mode line --operation replace --line 3 --text "replacement" - -# Line mode - delete line -ccw tool exec edit_file --path "file.py" --mode line --operation delete --line 3 +``` +mcp__ccw-tools__edit_file(path="file.py", oldText="old", newText="new") +mcp__ccw-tools__edit_file(path="file.py", oldText="old", newText="new", dryRun=true) +mcp__ccw-tools__edit_file(path="file.py", oldText="old", newText="new", replaceAll=true) +mcp__ccw-tools__edit_file(path="file.py", mode="line", operation="insert_after", line=10, text="new line") ``` -**Parameters**: `--path`*, `--old`, `--new`, `--dry-run`, `--replace-all`, `--mode` (update|line), `--operation`, `--line`, `--text` +**Options**: `dryRun` (preview diff), `replaceAll`, `mode` (update|line), `operation`, `line`, `text` -### write_file Tool +### write_file **When to Use**: Create new files or overwrite existing content -```bash -# Basic write -ccw tool exec write_file --path "file.txt" --content "Hello" - -# With backup -ccw tool exec write_file --path "file.txt" --content "new content" --backup - -# Create directories if needed -ccw tool exec write_file --path "new/path/file.txt" --content "content" --create-directories +``` +mcp__ccw-tools__write_file(path="file.txt", content="Hello") +mcp__ccw-tools__write_file(path="file.txt", content="code with `backticks` and ${vars}", backup=true) ``` -**Parameters**: `--path`*, `--content`*, `--create-directories`, `--backup`, `--encoding` +**Options**: `backup`, `createDirectories`, `encoding` + +### codex_lens + +**When to Use**: Code indexing and semantic search + +``` +mcp__ccw-tools__codex_lens(action="init", path=".") +mcp__ccw-tools__codex_lens(action="search", query="function main", path=".") +mcp__ccw-tools__codex_lens(action="search_files", query="pattern", limit=20) +mcp__ccw-tools__codex_lens(action="symbol", file="src/main.py") +``` + +**Actions**: `init`, `search`, `search_files`, `symbol`, `status`, `update` + +### smart_search + +**When to Use**: Quick search without indexing, natural language queries + +``` +mcp__ccw-tools__smart_search(query="function main", path=".") +mcp__ccw-tools__smart_search(query="def init", mode="exact") +mcp__ccw-tools__smart_search(query="authentication logic", mode="semantic") +``` + +**Modes**: `auto` (default), `exact`, `fuzzy`, `semantic`, `graph` ### Fallback Strategy -1. **Edit fails 1+ times** → `ccw tool exec edit_file` -2. **Still fails** → `ccw tool exec write_file` +1. **Edit fails 1+ times** → `mcp__ccw-tools__edit_file` +2. **Still fails** → `mcp__ccw-tools__write_file` -## ⚡ sed Line Operations (Line Mode Alternative) - -**When to Use**: Precise line number control (insert, delete, replace specific lines) - -### Common Operations - -```bash -# Insert after line 10 -sed -i '10a\new line content' file.txt - -# Insert before line 5 -sed -i '5i\new line content' file.txt - -# Delete line 3 -sed -i '3d' file.txt - -# Delete lines 5-8 -sed -i '5,8d' file.txt - -# Replace line 3 content -sed -i '3c\replacement line' file.txt - -# Replace lines 3-5 content -sed -i '3,5c\single replacement line' file.txt -``` - -### Operation Reference - -| Operation | Command | Example | -|-----------|---------|---------| -| Insert after | `Na\text` | `sed -i '10a\new' file` | -| Insert before | `Ni\text` | `sed -i '5i\new' file` | -| Delete line | `Nd` | `sed -i '3d' file` | -| Delete range | `N,Md` | `sed -i '5,8d' file` | -| Replace line | `Nc\text` | `sed -i '3c\new' file` | - -**Note**: Use `sed -i` for in-place file modification (works in Git Bash on Windows) diff --git a/ccw/MCP_QUICKSTART.md b/ccw/MCP_QUICKSTART.md new file mode 100644 index 00000000..8a925d9d --- /dev/null +++ b/ccw/MCP_QUICKSTART.md @@ -0,0 +1,61 @@ +# MCP Server Quick Start + +This is a quick reference for using CCW as an MCP server with Claude Desktop. + +## Quick Setup + +1. Ensure CCW is installed: +```bash +npm install -g ccw +``` + +2. Add to Claude Desktop config (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS or `%APPDATA%\Claude\claude_desktop_config.json` on Windows): + +```json +{ + "mcpServers": { + "ccw-tools": { + "command": "ccw-mcp", + "args": [] + } + } +} +``` + +3. Restart Claude Desktop + +## Available Tools + +Once configured, Claude Desktop can use these CCW tools: + +- **File Operations**: `edit_file`, `write_file` +- **Code Analysis**: `codex_lens`, `smart_search`, `get_modules_by_depth`, `classify_folders` +- **Git Integration**: `detect_changed_modules` +- **Session Management**: `session_manager` +- **UI/Design**: `discover_design_files`, `ui_generate_preview`, `convert_tokens_to_css` +- **Documentation**: `generate_module_docs`, `update_module_claude` + +## Example Usage in Claude Desktop + +``` +"Use edit_file to update the version in package.json" + +"Use codex_lens to analyze the authentication flow" + +"Use get_modules_by_depth to show me the project structure" +``` + +## Full Documentation + +See [MCP_SERVER.md](./MCP_SERVER.md) for complete documentation including: +- Detailed tool descriptions +- Configuration options +- Troubleshooting guide +- Development guidelines + +## Testing + +Run MCP server tests: +```bash +npm run test:mcp +``` diff --git a/ccw/MCP_SERVER.md b/ccw/MCP_SERVER.md new file mode 100644 index 00000000..9973b3b3 --- /dev/null +++ b/ccw/MCP_SERVER.md @@ -0,0 +1,149 @@ +# CCW MCP Server + +The CCW MCP Server exposes CCW tools through the Model Context Protocol, allowing Claude Desktop and other MCP clients to access CCW functionality. + +## Installation + +1. Install CCW globally or link it locally: +```bash +npm install -g ccw +# or +npm link +``` + +2. The MCP server executable is available as `ccw-mcp`. + +## Configuration + +### Claude Desktop Configuration + +Add this to your Claude Desktop MCP settings file: + +**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json` +**Windows**: `%APPDATA%\Claude\claude_desktop_config.json` + +```json +{ + "mcpServers": { + "ccw-tools": { + "command": "ccw-mcp", + "args": [] + } + } +} +``` + +If CCW is not installed globally, use the full path: + +```json +{ + "mcpServers": { + "ccw-tools": { + "command": "node", + "args": ["/full/path/to/ccw/bin/ccw-mcp.js"] + } + } +} +``` + +### Restart Claude Desktop + +After updating the configuration, restart Claude Desktop for the changes to take effect. + +## Available Tools + +The MCP server exposes the following CCW tools: + +### File Operations +- **edit_file** - Edit files with update or line mode +- **write_file** - Create or overwrite files + +### Code Analysis +- **codex_lens** - Analyze code execution flow +- **get_modules_by_depth** - Get module hierarchy by depth +- **classify_folders** - Classify project folders +- **detect_changed_modules** - Detect modules with git changes +- **smart_search** - Intelligent code search + +### Session Management +- **session_manager** - Manage workflow sessions + +### UI/Design Tools +- **discover_design_files** - Find design-related files +- **ui_generate_preview** - Generate UI previews +- **ui_instantiate_prototypes** - Create UI prototypes +- **convert_tokens_to_css** - Convert design tokens to CSS + +### Documentation +- **generate_module_docs** - Generate module documentation +- **update_module_claude** - Update CLAUDE.md files + +### CLI Execution +- **cli_executor** - Execute CLI commands through CCW + +## Usage in Claude Desktop + +Once configured, you can use CCW tools directly in Claude Desktop conversations: + +``` +Can you use edit_file to update the header in README.md? + +Use codex_lens to analyze the authentication flow in src/auth/login.js + +Get the module structure with get_modules_by_depth +``` + +## Testing the Server + +You can test the MCP server is working by checking the logs in Claude Desktop: + +1. Open Claude Desktop +2. Check Developer Tools (Help → Developer Tools) +3. Look for `ccw-tools v6.1.4 started` message +4. Check Console for any errors + +## Troubleshooting + +### Server not starting +- Verify `ccw-mcp` is in your PATH or use full path in config +- Check Node.js version (requires >= 16.0.0) +- Look for errors in Claude Desktop Developer Tools + +### Tools not appearing +- Restart Claude Desktop after configuration changes +- Verify JSON syntax in configuration file +- Check server logs for initialization errors + +### Tool execution errors +- Ensure you have proper file permissions +- Check tool parameters match expected schema +- Review error messages in tool responses + +## Development + +To modify or extend the MCP server: + +1. Edit `ccw/src/mcp-server/index.js` for server logic +2. Add/modify tools in `ccw/src/tools/` +3. Register new tools in `ccw/src/tools/index.js` +4. Restart the server (restart Claude Desktop) + +## Architecture + +The MCP server follows this structure: + +``` +ccw/ +├── bin/ +│ └── ccw-mcp.js # Executable entry point +├── src/ +│ ├── mcp-server/ +│ │ └── index.js # MCP server implementation +│ └── tools/ +│ ├── index.js # Tool registry +│ ├── edit-file.js # Individual tool implementations +│ ├── write-file.js +│ └── ... +``` + +The server uses the `@modelcontextprotocol/sdk` to implement the MCP protocol over stdio transport. diff --git a/ccw/bin/ccw-mcp.js b/ccw/bin/ccw-mcp.js new file mode 100644 index 00000000..c004bca5 --- /dev/null +++ b/ccw/bin/ccw-mcp.js @@ -0,0 +1,7 @@ +#!/usr/bin/env node +/** + * CCW MCP Server Executable + * Entry point for running CCW tools as an MCP server + */ + +import '../src/mcp-server/index.js'; diff --git a/ccw/package-lock.json b/ccw/package-lock.json index b16d1748..ee67190e 100644 --- a/ccw/package-lock.json +++ b/ccw/package-lock.json @@ -1,14 +1,15 @@ { "name": "ccw", - "version": "1.0.0", + "version": "6.1.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ccw", - "version": "1.0.0", + "version": "6.1.4", "license": "MIT", "dependencies": { + "@modelcontextprotocol/sdk": "^1.0.4", "boxen": "^7.1.0", "chalk": "^5.3.0", "commander": "^11.0.0", @@ -20,7 +21,8 @@ "ora": "^7.0.0" }, "bin": { - "ccw": "bin/ccw.js" + "ccw": "bin/ccw.js", + "ccw-mcp": "bin/ccw-mcp.js" }, "engines": { "node": ">=16.0.0" @@ -73,6 +75,43 @@ "node": ">=12" } }, + "node_modules/@modelcontextprotocol/sdk": { + "version": "1.24.3", + "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.24.3.tgz", + "integrity": "sha512-YgSHW29fuzKKAHTGe9zjNoo+yF8KaQPzDC2W9Pv41E7/57IfY+AMGJ/aDFlgTLcVVELoggKE4syABCE75u3NCw==", + "license": "MIT", + "dependencies": { + "ajv": "^8.17.1", + "ajv-formats": "^3.0.1", + "content-type": "^1.0.5", + "cors": "^2.8.5", + "cross-spawn": "^7.0.5", + "eventsource": "^3.0.2", + "eventsource-parser": "^3.0.0", + "express": "^5.0.1", + "express-rate-limit": "^7.5.0", + "jose": "^6.1.1", + "pkce-challenge": "^5.0.0", + "raw-body": "^3.0.0", + "zod": "^3.25 || ^4.0", + "zod-to-json-schema": "^3.25.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@cfworker/json-schema": "^4.1.1", + "zod": "^3.25 || ^4.0" + }, + "peerDependenciesMeta": { + "@cfworker/json-schema": { + "optional": true + }, + "zod": { + "optional": false + } + } + }, "node_modules/@pkgjs/parseargs": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", @@ -89,6 +128,52 @@ "integrity": "sha512-iEN8J0BoMnsWBqjVbWH/c0G0Hh7O21lpR2/+PrvAVgWdzL7eexIFm4JN/Wn10PTcmNdtS6U67r499mlWMXOxNw==", "license": "MIT" }, + "node_modules/accepts": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", + "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", + "license": "MIT", + "dependencies": { + "mime-types": "^3.0.0", + "negotiator": "^1.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ajv": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", + "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ajv-formats": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz", + "integrity": "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==", + "license": "MIT", + "dependencies": { + "ajv": "^8.0.0" + }, + "peerDependencies": { + "ajv": "^8.0.0" + }, + "peerDependenciesMeta": { + "ajv": { + "optional": true + } + } + }, "node_modules/ansi-align": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-3.0.1.tgz", @@ -236,6 +321,30 @@ "readable-stream": "^3.4.0" } }, + "node_modules/body-parser": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.1.tgz", + "integrity": "sha512-nfDwkulwiZYQIGwxdy0RUmowMhKcFVcYXUU7m4QlKYim1rUtg83xm2yjZ40QjDuc291AJjjeSc9b++AWHSgSHw==", + "license": "MIT", + "dependencies": { + "bytes": "^3.1.2", + "content-type": "^1.0.5", + "debug": "^4.4.3", + "http-errors": "^2.0.0", + "iconv-lite": "^0.7.0", + "on-finished": "^2.4.1", + "qs": "^6.14.0", + "raw-body": "^3.0.1", + "type-is": "^2.0.1" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/boxen": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/boxen/-/boxen-7.1.1.tgz", @@ -318,6 +427,44 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/camelcase": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-7.0.1.tgz", @@ -432,6 +579,59 @@ "node": ">=16" } }, + "node_modules/content-disposition": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.1.tgz", + "integrity": "sha512-oIXISMynqSqm241k6kcQ5UwttDILMK4BiurCfGEREw6+X9jkkpEe5T9FZaApyLGGOnFuyMWZpdolTXMtvEJ08Q==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", + "license": "MIT", + "engines": { + "node": ">=6.6.0" + } + }, + "node_modules/cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "license": "MIT", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", @@ -446,6 +646,23 @@ "node": ">= 8" } }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, "node_modules/default-browser": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/default-browser/-/default-browser-4.0.0.tgz", @@ -504,18 +721,122 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", "license": "MIT" }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, "node_modules/emoji-regex": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", "license": "MIT" }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/eventsource": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-3.0.7.tgz", + "integrity": "sha512-CRT1WTyuQoD771GW56XEZFQ/ZoSfWid1alKGDYMmkt2yl8UXrVR4pspqWNEcqKvVIzg6PAltWjxcSSPrboA4iA==", + "license": "MIT", + "dependencies": { + "eventsource-parser": "^3.0.1" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/eventsource-parser": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-3.0.6.tgz", + "integrity": "sha512-Vo1ab+QXPzZ4tCa8SwIHJFaSzy4R6SHf7BY79rFBDf0idraZWAkYrDjDj8uWaSm3S2TK+hJ7/t1CEmZ7jXw+pg==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + } + }, "node_modules/execa": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/execa/-/execa-7.2.0.tgz", @@ -545,6 +866,86 @@ "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", "license": "ISC" }, + "node_modules/express": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz", + "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", + "license": "MIT", + "dependencies": { + "accepts": "^2.0.0", + "body-parser": "^2.2.1", + "content-disposition": "^1.0.0", + "content-type": "^1.0.5", + "cookie": "^0.7.1", + "cookie-signature": "^1.2.1", + "debug": "^4.4.0", + "depd": "^2.0.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "finalhandler": "^2.1.0", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "merge-descriptors": "^2.0.0", + "mime-types": "^3.0.0", + "on-finished": "^2.4.1", + "once": "^1.4.0", + "parseurl": "^1.3.3", + "proxy-addr": "^2.0.7", + "qs": "^6.14.0", + "range-parser": "^1.2.1", + "router": "^2.2.0", + "send": "^1.1.0", + "serve-static": "^2.2.0", + "statuses": "^2.0.1", + "type-is": "^2.0.1", + "vary": "^1.1.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/express-rate-limit": { + "version": "7.5.1", + "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-7.5.1.tgz", + "integrity": "sha512-7iN8iPMDzOMHPUYllBEsQdWVB6fPDMPqwjBaFrgr4Jgr/+okjvzAy+UHlYYL/Vs0OsOrMkwS6PJDkFlJwoxUnw==", + "license": "MIT", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/express-rate-limit" + }, + "peerDependencies": { + "express": ">= 4.11" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "license": "MIT" + }, + "node_modules/fast-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.0.tgz", + "integrity": "sha512-iPeeDKJSWf4IEOasVVrknXpaBV0IApz/gp7S2bb7Z4Lljbl2MGJRqInZiUrQwV16cpzw/D3S5j5Julj/gT52AA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "BSD-3-Clause" + }, "node_modules/figlet": { "version": "1.9.4", "resolved": "https://registry.npmjs.org/figlet/-/figlet-1.9.4.tgz", @@ -569,6 +970,27 @@ "node": ">=20" } }, + "node_modules/finalhandler": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz", + "integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "on-finished": "^2.4.1", + "parseurl": "^1.3.3", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/foreground-child": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", @@ -585,6 +1007,70 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", + "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/get-stream": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", @@ -617,6 +1103,18 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/gradient-string": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/gradient-string/-/gradient-string-2.0.2.tgz", @@ -670,6 +1168,50 @@ "node": ">=8" } }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/human-signals": { "version": "4.3.1", "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-4.3.1.tgz", @@ -980,6 +1522,15 @@ "node": ">=8" } }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, "node_modules/is-docker": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz", @@ -1034,6 +1585,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/is-promise": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", + "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", + "license": "MIT" + }, "node_modules/is-stream": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz", @@ -1106,6 +1663,21 @@ "@pkgjs/parseargs": "^0.11.0" } }, + "node_modules/jose": { + "version": "6.1.3", + "resolved": "https://registry.npmjs.org/jose/-/jose-6.1.3.tgz", + "integrity": "sha512-0TpaTfihd4QMNwrz/ob2Bp7X04yuxJkjRGi4aKmOqwhov54i6u79oCv7T+C7lo70MKH6BesI3vscD1yb/yzKXQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/panva" + } + }, + "node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "license": "MIT" + }, "node_modules/log-symbols": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-5.1.0.tgz", @@ -1128,12 +1700,67 @@ "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", "license": "ISC" }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", + "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/merge-descriptors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", + "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", "license": "MIT" }, + "node_modules/mime-db": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", + "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", + "license": "MIT", + "dependencies": { + "mime-db": "^1.54.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/mimic-fn": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", @@ -1170,6 +1797,12 @@ "node": ">=16 || 14 >=14.17" } }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, "node_modules/mute-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-1.0.0.tgz", @@ -1179,6 +1812,15 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, + "node_modules/negotiator": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", + "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/npm-run-path": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.3.0.tgz", @@ -1206,6 +1848,48 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, "node_modules/onetime": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz", @@ -1291,6 +1975,15 @@ "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", "license": "BlueOak-1.0.0" }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", @@ -1316,6 +2009,77 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/path-to-regexp": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.3.0.tgz", + "integrity": "sha512-7jdwVIRtsP8MYpdXSwOS0YdD0Du+qOoF/AEPIt88PcCFrZCzx41oxku1jD88hZBwbNUIEfpqvuhjFaMAqMTWnA==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/pkce-challenge": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/pkce-challenge/-/pkce-challenge-5.0.1.tgz", + "integrity": "sha512-wQ0b/W4Fr01qtpHlqSqspcj3EhBvimsdh0KlHhH8HRZnMsEa0ea2fTULOXOS9ccQr3om+GcGRk4e+isrZWV8qQ==", + "license": "MIT", + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/qs": { + "version": "6.14.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz", + "integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==", + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz", + "integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.7.0", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/readable-stream": { "version": "3.6.2", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", @@ -1330,6 +2094,15 @@ "node": ">= 6" } }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/restore-cursor": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-4.0.0.tgz", @@ -1376,6 +2149,22 @@ "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", "license": "ISC" }, + "node_modules/router": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz", + "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "depd": "^2.0.0", + "is-promise": "^4.0.0", + "parseurl": "^1.3.3", + "path-to-regexp": "^8.0.0" + }, + "engines": { + "node": ">= 18" + } + }, "node_modules/run-applescript": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/run-applescript/-/run-applescript-5.0.0.tgz", @@ -1530,6 +2319,49 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "license": "MIT" }, + "node_modules/send": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/send/-/send-1.2.0.tgz", + "integrity": "sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw==", + "license": "MIT", + "dependencies": { + "debug": "^4.3.5", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "mime-types": "^3.0.1", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/serve-static": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.0.tgz", + "integrity": "sha512-61g9pCh0Vnh7IutZjtLGGpTA355+OPn2TyDv/6ivP2h/AdAVX9azsoxmg2/M6nZeQZNYBEwIcsne1mJd9oQItQ==", + "license": "MIT", + "dependencies": { + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "parseurl": "^1.3.3", + "send": "^1.2.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -1551,6 +2383,78 @@ "node": ">=8" } }, + "node_modules/side-channel": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", + "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/signal-exit": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", @@ -1563,6 +2467,15 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/stdin-discarder": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/stdin-discarder/-/stdin-discarder-0.1.0.tgz", @@ -1735,6 +2648,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, "node_modules/tslib": { "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", @@ -1753,6 +2675,29 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/type-is": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz", + "integrity": "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==", + "license": "MIT", + "dependencies": { + "content-type": "^1.0.5", + "media-typer": "^1.1.0", + "mime-types": "^3.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/untildify": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/untildify/-/untildify-4.0.0.tgz", @@ -1768,6 +2713,15 @@ "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "license": "MIT" }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/wcwidth": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", @@ -1898,6 +2852,12 @@ "node": ">=8" } }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "license": "ISC" + }, "node_modules/yoctocolors-cjs": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/yoctocolors-cjs/-/yoctocolors-cjs-2.1.3.tgz", @@ -1909,6 +2869,24 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } + }, + "node_modules/zod": { + "version": "4.1.13", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.1.13.tgz", + "integrity": "sha512-AvvthqfqrAhNH9dnfmrfKzX5upOdjUVJYFqNSlkmGf64gRaTzlPwz99IHYnVs28qYAybvAlBV+H7pn0saFY4Ig==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + }, + "node_modules/zod-to-json-schema": { + "version": "3.25.0", + "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.25.0.tgz", + "integrity": "sha512-HvWtU2UG41LALjajJrML6uQejQhNJx+JBO9IflpSja4R03iNWfKXrj6W2h7ljuLyc1nKS+9yDyL/9tD1U/yBnQ==", + "license": "ISC", + "peerDependencies": { + "zod": "^3.25 || ^4" + } } } } diff --git a/ccw/package.json b/ccw/package.json index ec980424..3817e98e 100644 --- a/ccw/package.json +++ b/ccw/package.json @@ -5,11 +5,13 @@ "type": "module", "main": "src/index.js", "bin": { - "ccw": "./bin/ccw.js" + "ccw": "./bin/ccw.js", + "ccw-mcp": "./bin/ccw-mcp.js" }, "scripts": { "test": "node --test tests/*.test.js", "test:codexlens": "node --test tests/codex-lens*.test.js", + "test:mcp": "node --test tests/mcp-server.test.js", "lint": "eslint src/" }, "keywords": [ @@ -25,6 +27,7 @@ "node": ">=16.0.0" }, "dependencies": { + "@modelcontextprotocol/sdk": "^1.0.4", "boxen": "^7.1.0", "chalk": "^5.3.0", "commander": "^11.0.0", diff --git a/ccw/src/cli.js b/ccw/src/cli.js index 26e5456d..181d578f 100644 --- a/ccw/src/cli.js +++ b/ccw/src/cli.js @@ -115,6 +115,12 @@ export function run(argv) { .option('--path ', 'File path (for edit_file)') .option('--old ', 'Old text to replace (for edit_file)') .option('--new ', 'New text (for edit_file)') + .option('--action ', 'Action to perform (for codex_lens)') + .option('--query ', 'Search query (for codex_lens)') + .option('--limit ', 'Max results (for codex_lens)', '20') + .option('--file ', 'File path for symbol extraction (for codex_lens)') + .option('--files ', 'Comma-separated file paths (for codex_lens update)') + .option('--languages ', 'Comma-separated languages (for codex_lens init)') .action((subcommand, args, options) => toolCommand(subcommand, args, options)); // Session command diff --git a/ccw/src/commands/tool.js b/ccw/src/commands/tool.js index af5fcc29..10d680eb 100644 --- a/ccw/src/commands/tool.js +++ b/ccw/src/commands/tool.js @@ -70,13 +70,14 @@ async function schemaAction(options) { * Execute a tool with given parameters * @param {string} toolName - Tool name * @param {string|undefined} jsonParams - JSON string of parameters - * @param {Object} options - CLI options (--path, --old, --new for edit_file) + * @param {Object} options - CLI options */ async function execAction(toolName, jsonParams, options) { if (!toolName) { console.error(chalk.red('Tool name is required')); console.error(chalk.gray('Usage: ccw tool exec \'{"param": "value"}\'')); console.error(chalk.gray(' ccw tool exec edit_file --path file.txt --old "old" --new "new"')); + console.error(chalk.gray(' ccw tool exec codex_lens --action search --query "pattern"')); process.exit(1); } @@ -100,7 +101,7 @@ async function execAction(toolName, jsonParams, options) { process.exit(1); } } else if (toolName === 'edit_file') { - // Legacy support for edit_file with --path, --old, --new options + // Parameter mode for edit_file if (!options.path || !options.old || !options.new) { console.error(chalk.red('edit_file requires --path, --old, and --new parameters')); console.error(chalk.gray('Usage: ccw tool exec edit_file --path file.txt --old "old text" --new "new text"')); @@ -109,8 +110,23 @@ async function execAction(toolName, jsonParams, options) { params.path = options.path; params.oldText = options.old; params.newText = options.new; + } else if (toolName === 'codex_lens') { + // Parameter mode for codex_lens + if (!options.action) { + console.error(chalk.red('codex_lens requires --action parameter')); + console.error(chalk.gray('Usage: ccw tool exec codex_lens --action search --query "pattern" --path .')); + console.error(chalk.gray('Actions: init, search, search_files, symbol, status, update, bootstrap, check')); + process.exit(1); + } + params.action = options.action; + if (options.path) params.path = options.path; + if (options.query) params.query = options.query; + if (options.limit) params.limit = parseInt(options.limit, 10); + if (options.file) params.file = options.file; + if (options.files) params.files = options.files.split(',').map(f => f.trim()); + if (options.languages) params.languages = options.languages.split(',').map(l => l.trim()); } else if (jsonParams) { - // Non-JSON string provided but not for edit_file + // Non-JSON string provided but not for supported tools console.error(chalk.red('Parameters must be valid JSON')); console.error(chalk.gray(`Usage: ccw tool exec ${toolName} '{"param": "value"}'`)); process.exit(1); @@ -157,5 +173,6 @@ export async function toolCommand(subcommand, args, options) { console.log(chalk.gray(' ccw tool schema edit_file')); console.log(chalk.gray(' ccw tool exec \'{"param": "value"}\'')); console.log(chalk.gray(' ccw tool exec edit_file --path file.txt --old "old text" --new "new text"')); + console.log(chalk.gray(' ccw tool exec codex_lens --action search --query "def main" --path .')); } } diff --git a/ccw/src/core/server.js b/ccw/src/core/server.js index 8b4eff89..c5dced6a 100644 --- a/ccw/src/core/server.js +++ b/ccw/src/core/server.js @@ -350,6 +350,26 @@ export async function startServer(options = {}) { return; } + // API: Install CCW MCP server to project + if (pathname === '/api/mcp-install-ccw' && req.method === 'POST') { + handlePostRequest(req, res, async (body) => { + const { projectPath } = body; + if (!projectPath) { + return { error: 'projectPath is required', status: 400 }; + } + + // Generate CCW MCP server config + const ccwMcpConfig = { + command: "ccw-mcp", + args: [] + }; + + // Use existing addMcpServerToProject to install CCW MCP + return addMcpServerToProject(projectPath, 'ccw-mcp', ccwMcpConfig); + }); + return; + } + // API: Remove MCP server from project if (pathname === '/api/mcp-remove-server' && req.method === 'POST') { handlePostRequest(req, res, async (body) => { diff --git a/ccw/src/mcp-server/index.js b/ccw/src/mcp-server/index.js new file mode 100644 index 00000000..43b16ed0 --- /dev/null +++ b/ccw/src/mcp-server/index.js @@ -0,0 +1,160 @@ +#!/usr/bin/env node +/** + * CCW MCP Server + * Exposes CCW tools through the Model Context Protocol + */ + +import { Server } from '@modelcontextprotocol/sdk/server/index.js'; +import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; +import { + CallToolRequestSchema, + ListToolsRequestSchema, +} from '@modelcontextprotocol/sdk/types.js'; +import { getAllToolSchemas, executeTool } from '../tools/index.js'; + +const SERVER_NAME = 'ccw-tools'; +const SERVER_VERSION = '6.1.4'; + +// Default enabled tools (core set) +const DEFAULT_TOOLS = ['write_file', 'edit_file', 'codex_lens', 'smart_search']; + +/** + * Get list of enabled tools from environment or defaults + */ +function getEnabledTools() { + const envTools = process.env.CCW_ENABLED_TOOLS; + if (envTools) { + // Support "all" to enable all tools + if (envTools.toLowerCase() === 'all') { + return null; // null means all tools + } + return envTools.split(',').map(t => t.trim()).filter(Boolean); + } + return DEFAULT_TOOLS; +} + +/** + * Filter tools based on enabled list + */ +function filterTools(tools, enabledList) { + if (!enabledList) return tools; // null = all tools + return tools.filter(tool => enabledList.includes(tool.name)); +} + +/** + * Create and configure the MCP server + */ +function createServer() { + const enabledTools = getEnabledTools(); + + const server = new Server( + { + name: SERVER_NAME, + version: SERVER_VERSION, + }, + { + capabilities: { + tools: {}, + }, + } + ); + + /** + * Handler for tools/list - Returns enabled CCW tools + */ + server.setRequestHandler(ListToolsRequestSchema, async () => { + const allTools = getAllToolSchemas(); + const tools = filterTools(allTools, enabledTools); + return { tools }; + }); + + /** + * Handler for tools/call - Executes a CCW tool + */ + server.setRequestHandler(CallToolRequestSchema, async (request) => { + const { name, arguments: args } = request.params; + + // Check if tool is enabled + if (enabledTools && !enabledTools.includes(name)) { + return { + content: [{ type: 'text', text: `Tool "${name}" is not enabled` }], + isError: true, + }; + } + + try { + const result = await executeTool(name, args || {}); + + if (!result.success) { + return { + content: [{ type: 'text', text: `Error: ${result.error}` }], + isError: true, + }; + } + + return { + content: [{ type: 'text', text: formatToolResult(result.result) }], + }; + } catch (error) { + return { + content: [{ type: 'text', text: `Tool execution failed: ${error.message}` }], + isError: true, + }; + } + }); + + return server; +} + +/** + * Format tool result for display + * @param {*} result - Tool execution result + * @returns {string} - Formatted result string + */ +function formatToolResult(result) { + if (result === null || result === undefined) { + return 'Tool completed successfully (no output)'; + } + + if (typeof result === 'string') { + return result; + } + + if (typeof result === 'object') { + // Pretty print JSON with indentation + return JSON.stringify(result, null, 2); + } + + return String(result); +} + +/** + * Main server execution + */ +async function main() { + const server = createServer(); + const transport = new StdioServerTransport(); + + // Connect server to transport + await server.connect(transport); + + // Error handling + process.on('SIGINT', async () => { + await server.close(); + process.exit(0); + }); + + process.on('SIGTERM', async () => { + await server.close(); + process.exit(0); + }); + + // Log server start (to stderr to not interfere with stdio protocol) + console.error(`${SERVER_NAME} v${SERVER_VERSION} started`); +} + +// Run server +main().catch((error) => { + console.error('Server error:', error); + process.exit(1); +}); diff --git a/ccw/src/templates/dashboard-js/components/mcp-manager.js b/ccw/src/templates/dashboard-js/components/mcp-manager.js index 08776fc6..d93da030 100644 --- a/ccw/src/templates/dashboard-js/components/mcp-manager.js +++ b/ccw/src/templates/dashboard-js/components/mcp-manager.js @@ -579,20 +579,66 @@ async function createMcpServerWithConfig(name, serverConfig) { showRefreshToast(`Failed to create MCP server: ${err.message}`, 'error'); } } + // ========== CCW Tools MCP Installation ========== -async function installCcwToolsMcp() { - // Define CCW Tools MCP server configuration - // Use npx for better cross-platform compatibility (handles PATH issues) - const ccwToolsConfig = { + +// Get selected tools from checkboxes +function getSelectedCcwTools() { + const checkboxes = document.querySelectorAll('.ccw-tool-checkbox:checked'); + return Array.from(checkboxes).map(cb => cb.dataset.tool); +} + +// Select tools by category +function selectCcwTools(type) { + const checkboxes = document.querySelectorAll('.ccw-tool-checkbox'); + const coreTools = ['write_file', 'edit_file', 'codex_lens', 'smart_search']; + + checkboxes.forEach(cb => { + if (type === 'all') { + cb.checked = true; + } else if (type === 'none') { + cb.checked = false; + } else if (type === 'core') { + cb.checked = coreTools.includes(cb.dataset.tool); + } + }); +} + +// Build CCW Tools config with selected tools +function buildCcwToolsConfig(selectedTools) { + const config = { command: "npx", args: ["-y", "ccw-mcp"] }; + // Add env if not all tools or not default 4 core tools + const coreTools = ['write_file', 'edit_file', 'codex_lens', 'smart_search']; + const isDefault = selectedTools.length === 4 && + coreTools.every(t => selectedTools.includes(t)) && + selectedTools.every(t => coreTools.includes(t)); + + if (selectedTools.length === 15) { + config.env = { CCW_ENABLED_TOOLS: 'all' }; + } else if (!isDefault && selectedTools.length > 0) { + config.env = { CCW_ENABLED_TOOLS: selectedTools.join(',') }; + } + + return config; +} + +async function installCcwToolsMcp() { + const selectedTools = getSelectedCcwTools(); + + if (selectedTools.length === 0) { + showRefreshToast('Please select at least one tool', 'warning'); + return; + } + + const ccwToolsConfig = buildCcwToolsConfig(selectedTools); + try { - // Show loading toast showRefreshToast('Installing CCW Tools MCP...', 'info'); - // Use the existing copyMcpServerToProject function const response = await fetch('/api/mcp-copy-server', { method: 'POST', headers: { 'Content-Type': 'application/json' }, @@ -609,7 +655,7 @@ async function installCcwToolsMcp() { if (result.success) { await loadMcpConfig(); renderMcpManager(); - showRefreshToast('CCW Tools MCP installed successfully', 'success'); + showRefreshToast(`CCW Tools installed (${selectedTools.length} tools)`, 'success'); } else { showRefreshToast(result.error || 'Failed to install CCW Tools MCP', 'error'); } @@ -618,3 +664,42 @@ async function installCcwToolsMcp() { showRefreshToast(`Failed to install CCW Tools MCP: ${err.message}`, 'error'); } } + +async function updateCcwToolsMcp() { + const selectedTools = getSelectedCcwTools(); + + if (selectedTools.length === 0) { + showRefreshToast('Please select at least one tool', 'warning'); + return; + } + + const ccwToolsConfig = buildCcwToolsConfig(selectedTools); + + try { + showRefreshToast('Updating CCW Tools MCP...', 'info'); + + const response = await fetch('/api/mcp-copy-server', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + projectPath: projectPath, + serverName: 'ccw-tools', + serverConfig: ccwToolsConfig + }) + }); + + if (!response.ok) throw new Error('Failed to update CCW Tools MCP'); + + const result = await response.json(); + if (result.success) { + await loadMcpConfig(); + renderMcpManager(); + showRefreshToast(`CCW Tools updated (${selectedTools.length} tools)`, 'success'); + } else { + showRefreshToast(result.error || 'Failed to update CCW Tools MCP', 'error'); + } + } catch (err) { + console.error('Failed to update CCW Tools MCP:', err); + showRefreshToast(`Failed to update CCW Tools MCP: ${err.message}`, 'error'); + } +} diff --git a/ccw/src/templates/dashboard-js/views/mcp-manager.js b/ccw/src/templates/dashboard-js/views/mcp-manager.js index e2933f90..4cfd7912 100644 --- a/ccw/src/templates/dashboard-js/views/mcp-manager.js +++ b/ccw/src/templates/dashboard-js/views/mcp-manager.js @@ -1,6 +1,33 @@ // MCP Manager View // Renders the MCP server management interface +// CCW Tools available for MCP +const CCW_MCP_TOOLS = [ + // Core tools (always recommended) + { name: 'write_file', desc: 'Write/create files', core: true }, + { name: 'edit_file', desc: 'Edit/replace content', core: true }, + { name: 'codex_lens', desc: 'Code index & search', core: true }, + { name: 'smart_search', desc: 'Quick regex/NL search', core: true }, + // Optional tools + { name: 'session_manager', desc: 'Workflow sessions', core: false }, + { name: 'generate_module_docs', desc: 'Generate docs', core: false }, + { name: 'update_module_claude', desc: 'Update CLAUDE.md', core: false }, + { name: 'cli_executor', desc: 'Gemini/Qwen/Codex CLI', core: false }, +]; + +// Get currently enabled tools from installed config +function getCcwEnabledTools() { + const currentPath = projectPath.replace(/\//g, '\\'); + const projectData = mcpAllProjects[currentPath] || {}; + const ccwConfig = projectData.mcpServers?.['ccw-tools']; + if (ccwConfig?.env?.CCW_ENABLED_TOOLS) { + const val = ccwConfig.env.CCW_ENABLED_TOOLS; + if (val.toLowerCase() === 'all') return CCW_MCP_TOOLS.map(t => t.name); + return val.split(',').map(t => t.trim()); + } + return CCW_MCP_TOOLS.filter(t => t.core).map(t => t.name); +} + async function renderMcpManager() { const container = document.getElementById('mainContent'); if (!container) return; @@ -36,7 +63,7 @@ async function renderMcpManager() { .filter(([name, info]) => !currentProjectServerNames.includes(name) && !info.isGlobal); // Check if CCW Tools is already installed const isCcwToolsInstalled = currentProjectServerNames.includes("ccw-tools"); - + const enabledTools = getCcwEnabledTools(); container.innerHTML = `
@@ -54,7 +81,7 @@ async function renderMcpManager() { ${isCcwToolsInstalled ? ` - Installed + ${enabledTools.length} tools ` : ` @@ -63,36 +90,35 @@ async function renderMcpManager() { `}
-

- CCW built-in tools for file editing, code search, session management, and more -

-
- - - 15 tools available - - - - Native integration - - - - Built-in & tested - + +
+ ${CCW_MCP_TOOLS.map(tool => ` + + `).join('')} +
+
+ + +
${isCcwToolsInstalled ? ` - ` : ` `}
diff --git a/ccw/src/tools/codex-lens.js b/ccw/src/tools/codex-lens.js index 16a3fb7d..b9ed01da 100644 --- a/ccw/src/tools/codex-lens.js +++ b/ccw/src/tools/codex-lens.js @@ -383,6 +383,30 @@ async function searchCode(params) { return result; } +/** + * Search code and return only file paths + * @param {Object} params - Search parameters + * @returns {Promise} + */ +async function searchFiles(params) { + const { query, path = '.', limit = 20 } = params; + + const args = ['search', query, '--files-only', '--limit', limit.toString(), '--json']; + + const result = await executeCodexLens(args, { cwd: path }); + + if (result.success) { + try { + result.files = JSON.parse(result.output); + delete result.output; + } catch { + // Keep raw output if JSON parse fails + } + } + + return result; +} + /** * Extract symbols from a file * @param {Object} params - Parameters @@ -474,6 +498,9 @@ async function execute(params) { case 'search': return searchCode(rest); + case 'search_files': + return searchFiles(rest); + case 'symbol': return extractSymbols(rest); @@ -497,7 +524,7 @@ async function execute(params) { return checkVenvStatus(); default: - throw new Error(`Unknown action: ${action}. Valid actions: init, search, symbol, status, update, bootstrap, check`); + throw new Error(`Unknown action: ${action}. Valid actions: init, search, search_files, symbol, status, update, bootstrap, check`); } } @@ -506,38 +533,30 @@ async function execute(params) { */ export const codexLensTool = { name: 'codex_lens', - description: `Code indexing and semantic search via CodexLens Python package. + description: `Code indexing and search. -Actions: -- init: Initialize index for a directory -- search: Search code (text or semantic mode) -- symbol: Extract symbols from a file -- status: Get index status -- update: Incrementally update specific files (add/modify/remove) -- bootstrap: Force re-install CodexLens venv -- check: Check venv readiness - -Features: -- Automatic venv bootstrap at ~/.codexlens/venv -- SQLite FTS5 full-text search -- Tree-sitter symbol extraction -- Incremental updates for changed files -- Optional semantic search with embeddings`, +Usage: + codex_lens(action="init", path=".") # Index directory + codex_lens(action="search", query="func", path=".") # Search code + codex_lens(action="search_files", query="x") # Search, return paths only + codex_lens(action="symbol", file="f.py") # Extract symbols + codex_lens(action="status") # Index status + codex_lens(action="update", files=["a.js"]) # Update specific files`, parameters: { type: 'object', properties: { action: { type: 'string', - enum: ['init', 'search', 'symbol', 'status', 'update', 'bootstrap', 'check'], + enum: ['init', 'search', 'search_files', 'symbol', 'status', 'update', 'bootstrap', 'check'], description: 'Action to perform' }, path: { type: 'string', - description: 'Target path (for init, search, status, update)' + description: 'Target path (for init, search, search_files, status, update)' }, query: { type: 'string', - description: 'Search query (for search action)' + description: 'Search query (for search and search_files actions)' }, mode: { type: 'string', @@ -561,7 +580,7 @@ Features: }, limit: { type: 'number', - description: 'Maximum results (for search action)', + description: 'Maximum results (for search and search_files actions)', default: 20 }, format: { diff --git a/ccw/src/tools/edit-file.js b/ccw/src/tools/edit-file.js index 5452d2df..9cf5967b 100644 --- a/ccw/src/tools/edit-file.js +++ b/ccw/src/tools/edit-file.js @@ -391,14 +391,13 @@ async function execute(params) { */ export const editFileTool = { name: 'edit_file', - description: `Edit file with two modes: -- update: Replace oldText with newText (default). Supports multiple edits via 'edits' array. -- line: Position-driven line operations (insert_before, insert_after, replace, delete) + description: `Edit file by text replacement or line operations. -Features: -- dryRun: Preview changes without modifying file (returns diff) -- Auto line ending adaptation (CRLF/LF) -- Fuzzy matching for whitespace differences`, +Usage: + edit_file(path="f.js", oldText="old", newText="new") + edit_file(path="f.js", mode="line", operation="insert_after", line=10, text="new line") + +Options: dryRun=true (preview diff), replaceAll=true (replace all occurrences)`, parameters: { type: 'object', properties: { diff --git a/ccw/src/tools/session-manager.js b/ccw/src/tools/session-manager.js index 6c2ace43..0289b421 100644 --- a/ccw/src/tools/session-manager.js +++ b/ccw/src/tools/session-manager.js @@ -722,28 +722,15 @@ async function execute(params) { export const sessionManagerTool = { name: 'session_manager', - description: `Workflow session lifecycle management tool. - -Operations: -- init: Create new session with directory structure -- list: List sessions (active, archived, or both) -- read: Read file content by content_type -- write: Write content to file by content_type -- update: Update existing JSON file (shallow merge) -- archive: Move session from active to archives -- mkdir: Create directories within session -- delete: Delete a file within session -- stats: Get session statistics (tasks, summaries, plan) - -Content Types: -session, plan, task, summary, process, chat, brainstorm, -review-dim, review-iter, review-fix, todo, context + description: `Workflow session management. Usage: -ccw tool exec session_manager '{"operation":"list"}' -ccw tool exec session_manager '{"operation":"init","session_id":"WFS-test"}' -ccw tool exec session_manager '{"operation":"read","session_id":"WFS-test","content_type":"session"}' -ccw tool exec session_manager '{"operation":"stats","session_id":"WFS-test"}'`, + session_manager(operation="init", type="workflow", description="...") + session_manager(operation="list", location="active|archived|both") + session_manager(operation="read", sessionId="WFS-xxx", contentType="plan|task|summary") + session_manager(operation="write", sessionId="WFS-xxx", contentType="plan", content={...}) + session_manager(operation="archive", sessionId="WFS-xxx") + session_manager(operation="stats", sessionId="WFS-xxx")`, parameters: { type: 'object', diff --git a/ccw/src/tools/smart-search.js b/ccw/src/tools/smart-search.js index c89e6b17..f44fb60a 100644 --- a/ccw/src/tools/smart-search.js +++ b/ccw/src/tools/smart-search.js @@ -577,19 +577,14 @@ async function execute(params) { */ export const smartSearchTool = { name: 'smart_search', - description: `Unified search with intelligent mode selection. + description: `Intelligent code search with multiple modes. -Modes: -- auto: Classify intent and recommend optimal search mode (default) -- exact: Precise literal matching via ripgrep -- fuzzy: Approximate matching with typo tolerance -- semantic: Natural language understanding via LLM/embeddings -- graph: Dependency relationship traversal +Usage: + smart_search(query="function main", path=".") # Auto-select mode + smart_search(query="def init", mode="exact") # Exact match + smart_search(query="authentication logic", mode="semantic") # NL search -Features: -- Multi-backend search coordination -- Result fusion with RRF ranking -- Configurable result limits and context`, +Modes: auto (default), exact, fuzzy, semantic, graph`, parameters: { type: 'object', properties: { diff --git a/ccw/src/tools/write-file.js b/ccw/src/tools/write-file.js index 15775406..6b107c2f 100644 --- a/ccw/src/tools/write-file.js +++ b/ccw/src/tools/write-file.js @@ -110,14 +110,10 @@ async function execute(params) { */ export const writeFileTool = { name: 'write_file', - description: `Create a new file or overwrite an existing file with content. + description: `Write content to file. Auto-creates parent directories. -Features: -- Creates parent directories automatically (configurable) -- Optional backup before overwrite -- Supports text content with proper encoding - -Use with caution as it will overwrite existing files without warning unless backup is enabled.`, +Usage: write_file(path="file.js", content="code here") +Options: backup=true (backup before overwrite), encoding="utf8"`, parameters: { type: 'object', properties: { diff --git a/ccw/tests/mcp-server.test.js b/ccw/tests/mcp-server.test.js new file mode 100644 index 00000000..84e2a86d --- /dev/null +++ b/ccw/tests/mcp-server.test.js @@ -0,0 +1,159 @@ +/** + * Basic MCP server tests + * Tests the MCP server functionality with mock requests + */ + +import { describe, it, before, after } from 'node:test'; +import assert from 'node:assert/strict'; +import { spawn } from 'node:child_process'; +import { fileURLToPath } from 'node:url'; +import { dirname, join } from 'node:path'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +describe('MCP Server', () => { + let serverProcess; + + before(async () => { + // Start the MCP server + const serverPath = join(__dirname, '../bin/ccw-mcp.js'); + serverProcess = spawn('node', [serverPath], { + stdio: ['pipe', 'pipe', 'pipe'] + }); + + // Wait for server to start + await new Promise((resolve) => { + serverProcess.stderr.once('data', (data) => { + const message = data.toString(); + if (message.includes('started')) { + resolve(); + } + }); + }); + }); + + after(() => { + if (serverProcess) { + serverProcess.kill(); + } + }); + + it('should respond to tools/list request', async () => { + const request = { + jsonrpc: '2.0', + id: 1, + method: 'tools/list', + params: {} + }; + + // Send request + serverProcess.stdin.write(JSON.stringify(request) + '\n'); + + // Wait for response + const response = await new Promise((resolve, reject) => { + const timeout = setTimeout(() => { + reject(new Error('Request timeout')); + }, 5000); + + serverProcess.stdout.once('data', (data) => { + clearTimeout(timeout); + try { + const response = JSON.parse(data.toString()); + resolve(response); + } catch (error) { + reject(error); + } + }); + }); + + assert.equal(response.jsonrpc, '2.0'); + assert.equal(response.id, 1); + assert(response.result); + assert(Array.isArray(response.result.tools)); + assert(response.result.tools.length > 0); + + // Check that essential tools are present + const toolNames = response.result.tools.map(t => t.name); + assert(toolNames.includes('edit_file')); + assert(toolNames.includes('write_file')); + assert(toolNames.includes('codex_lens')); + }); + + it('should respond to tools/call request', async () => { + const request = { + jsonrpc: '2.0', + id: 2, + method: 'tools/call', + params: { + name: 'get_modules_by_depth', + arguments: {} + } + }; + + // Send request + serverProcess.stdin.write(JSON.stringify(request) + '\n'); + + // Wait for response + const response = await new Promise((resolve, reject) => { + const timeout = setTimeout(() => { + reject(new Error('Request timeout')); + }, 5000); + + serverProcess.stdout.once('data', (data) => { + clearTimeout(timeout); + try { + const response = JSON.parse(data.toString()); + resolve(response); + } catch (error) { + reject(error); + } + }); + }); + + assert.equal(response.jsonrpc, '2.0'); + assert.equal(response.id, 2); + assert(response.result); + assert(Array.isArray(response.result.content)); + assert(response.result.content.length > 0); + assert.equal(response.result.content[0].type, 'text'); + }); + + it('should handle invalid tool name gracefully', async () => { + const request = { + jsonrpc: '2.0', + id: 3, + method: 'tools/call', + params: { + name: 'nonexistent_tool', + arguments: {} + } + }; + + // Send request + serverProcess.stdin.write(JSON.stringify(request) + '\n'); + + // Wait for response + const response = await new Promise((resolve, reject) => { + const timeout = setTimeout(() => { + reject(new Error('Request timeout')); + }, 5000); + + serverProcess.stdout.once('data', (data) => { + clearTimeout(timeout); + try { + const response = JSON.parse(data.toString()); + resolve(response); + } catch (error) { + reject(error); + } + }); + }); + + assert.equal(response.jsonrpc, '2.0'); + assert.equal(response.id, 3); + assert(response.result); + assert.equal(response.result.isError, true); + assert(response.result.content[0].text.includes('not found')); + }); +}); diff --git a/codex-lens/src/codexlens/cli/commands.py b/codex-lens/src/codexlens/cli/commands.py index 356bdcbf..820dd39a 100644 --- a/codex-lens/src/codexlens/cli/commands.py +++ b/codex-lens/src/codexlens/cli/commands.py @@ -243,6 +243,7 @@ def init( def search( query: str = typer.Argument(..., help="FTS query to run."), limit: int = typer.Option(20, "--limit", "-n", min=1, max=500, help="Max results."), + files_only: bool = typer.Option(False, "--files-only", "-f", help="Return only file paths without content snippets."), use_global: bool = typer.Option(False, "--global", "-g", help="Use global database instead of workspace-local."), json_mode: bool = typer.Option(False, "--json", help="Output JSON response."), verbose: bool = typer.Option(False, "--verbose", "-v", help="Enable debug logging."), @@ -251,6 +252,7 @@ def search( Searches the workspace-local .codexlens/index.db by default. Use --global to search the global database at ~/.codexlens/. + Use --files-only to return only matching file paths. """ _configure_logging(verbose) @@ -258,12 +260,22 @@ def search( try: store, db_path = _get_store_for_path(Path.cwd(), use_global) store.initialize() - results = store.search_fts(query, limit=limit) - payload = {"query": query, "count": len(results), "results": results} - if json_mode: - print_json(success=True, result=payload) + + if files_only: + file_paths = store.search_files_only(query, limit=limit) + payload = {"query": query, "count": len(file_paths), "files": file_paths} + if json_mode: + print_json(success=True, result=payload) + else: + for fp in file_paths: + console.print(fp) else: - render_search_results(results) + results = store.search_fts(query, limit=limit) + payload = {"query": query, "count": len(results), "results": results} + if json_mode: + print_json(success=True, result=payload) + else: + render_search_results(results) except Exception as exc: if json_mode: print_json(success=False, error=str(exc))