1 unstable release
Uses new Rust 2024
| new 0.6.0-alpha | Feb 23, 2026 |
|---|
#4 in #git-push
165KB
4K
SLoC
CodeBridge CLI
A powerful local server that enables LLM-driven code automation with intelligent build detection, git operations, and script execution capabilities.
π New Features
β¨ Smart Build Detection
Automatically detects your project type and uses the appropriate build command:
- Rust (Cargo.toml) β
cargo check - Node.js (package.json) β
npm run build - Python (requirements.txt) β
python -m py_compile - Documentation (mostly .md files) β No build needed
- Unknown β No build attempted
No more "could not find Cargo.toml" errors on documentation projects!
π§ Git Repository Initialization
New GitInit action allows the LLM to initialize git repositories on-demand. No more manual setup required.
π― Script Execution (Experimental)
Execute custom scripts in multiple languages for complex automation:
- Deno: TypeScript/JavaScript with secure defaults
- Python: General-purpose scripting
- Bash: Shell automation
- Rust: Compiled scripts (coming soon)
Security Features:
- Sandboxed execution (filesystem restricted to project)
- Timeout enforcement (30s default)
- No network access by default
- Resource limits
π¦ Installation
Prerequisites
- Rust 1.70+ (for building)
- Git 2.0+ (for git operations)
- Deno 1.30+ (optional, for script execution)
- Python 3.8+ (optional, for script execution)
Build from Source
cargo build --release
Run
./target/release/codebridge-cli \
--port 3000 \
--workspace ./workspace \
--build-command auto \
--enable-script-execution \
--script-languages deno,python
π§ Configuration
CLI Options
| Flag | Default | Description |
|---|---|---|
--port |
3000 |
HTTP server port |
--workspace |
../codebridge-workspace |
Root directory for projects |
--build-command |
auto |
Build command (use auto for detection, none to disable) |
--allowed-commands |
npm,cargo,python |
Comma-separated list of allowed shell commands |
--enable-script-execution |
false |
Enable LLM script execution |
--script-languages |
deno,python |
Allowed script languages |
--script-timeout |
30 |
Script execution timeout (seconds) |
Examples
Rust-only environment:
codebridge-cli --build-command "cargo check" --allowed-commands cargo
Documentation project:
codebridge-cli --build-command none
Full automation mode (with script execution):
codebridge-cli \
--enable-script-execution \
--script-languages deno,python,bash \
--script-timeout 60
π‘ API Reference
Endpoints
POST /execute
Execute a series of actions and optionally run a build.
Request:
{
"projectId": "my-project",
"actions": [
{ "type": "writeFile", "params": { "path": "src/main.rs", "content": "fn main() {}" } },
{ "type": "gitInit" },
{ "type": "gitAdd", "params": { "files": ["src/main.rs"] } },
{ "type": "gitCommit", "params": { "message": "Initial commit" } }
]
}
Response:
{
"actionResults": [
{ "success": true, "content": null, "error": null },
{ "success": true, "content": "Git repository initialized", "error": null },
{ "success": true, "content": null, "error": null },
{ "success": true, "content": "Committed: abc123...", "error": null }
],
"buildOutput": {
"success": true,
"errors": [],
"warnings": [],
"rawOutput": "..."
},
"continueLoop": false
}
π¬ Action Types
File Operations
readFile
{ "type": "readFile", "params": { "path": "README.md" } }
writeFile
{
"type": "writeFile",
"params": {
"path": "src/lib.rs",
"content": "pub fn hello() { println!(\"Hello\"); }"
}
}
deleteFile
{ "type": "deleteFile", "params": { "path": "old-file.txt" } }
createDirectory
{ "type": "createDirectory", "params": { "path": "src/components" } }
listDirectory
{ "type": "listDirectory", "params": { "path": "src" } }
Git Operations
gitInit π
Initialize a git repository.
{ "type": "gitInit" }
gitStatus
{ "type": "gitStatus" }
gitAdd
{ "type": "gitAdd", "params": { "files": ["src/main.rs", "Cargo.toml"] } }
gitCommit
{ "type": "gitCommit", "params": { "message": "feat: Add new feature" } }
gitPush
{
"type": "gitPush",
"params": {
"remote": "origin", // optional
"branch": "main" // optional
}
}
gitDiff
{
"type": "gitDiff",
"params": {
"target": "staged" // "staged" or omit for unstaged
}
}
Script Execution π
runScript
Execute custom scripts in supported languages.
Deno Example (TypeScript):
{
"type": "runScript",
"params": {
"language": "deno",
"code": "import { walk } from 'https://deno.land/std/fs/mod.ts';\n\nfor await (const entry of walk('.', { exts: ['.rs'] })) {\n logger.log(entry.path);\n}",
"args": [],
"timeout": 30
}
}
Python Example:
{
"type": "runScript",
"params": {
"language": "python",
"code": "import os\nfor root, dirs, files in os.walk('.'):\n for f in files:\n if f.endswith('.py'):\n print(os.path.join(root, f))",
"args": [],
"timeout": 30
}
}
Bash Example:
{
"type": "runScript",
"params": {
"language": "bash",
"code": "#!/bin/bash\nfind . -name '*.log' -type f -delete\necho 'Cleaned up log files'",
"args": []
}
}
Response:
{
"success": true,
"content": "STDOUT:\n./src/main.rs\n./src/lib.rs\nSTDERR:\n",
"error": null
}
π Security
Filesystem Isolation
All file operations are restricted to the project directory. Path traversal attempts (../../../etc/passwd) are blocked.
Script Sandboxing
Scripts executed via runScript:
- Cannot access files outside the project directory
- Cannot make network requests (unless
--enable-networkflag is set) - Have a timeout (default 30 seconds)
- Run with limited privileges (no sudo/root)
Git Operations
Git push requires SSH key authentication configured on the host system.
π§ͺ Testing
Run Tests
cargo test
Manual Testing
Test 1: Smart Build Detection
# Create a docs-only project
mkdir -p workspace/docs-test
echo "# Documentation" > workspace/docs-test/README.md
# Send execute request (should skip build)
curl -X POST http://localhost:3000/execute \
-H "Content-Type: application/json" \
-d '{"projectId":"docs-test","actions":[]}'
# Expected: buildOutput should be null
Test 2: Git Initialization
curl -X POST http://localhost:3000/execute \
-H "Content-Type: application/json" \
-d '{"projectId":"new-project","actions":[{"type":"gitInit"}]}'
# Expected: success with "Git repository initialized"
Test 3: Script Execution
curl -X POST http://localhost:3000/execute \
-H "Content-Type: application/json" \
-d '{
"projectId":"test-project",
"actions":[{
"type":"runScript",
"params":{
"language":"python",
"code":"print(\"Hello from Python!\")",
"args":[]
}
}]
}'
# Expected: success with stdout containing "Hello from Python!"
π Troubleshooting
Issue: "Not a git repository" error
Solution: Use the GitInit action before other git operations.
{ "type": "gitInit" }
Issue: "could not find Cargo.toml" on docs project
Solution: Set --build-command none or use auto (default). The system should automatically detect documentation projects and skip builds.
Issue: Script execution timeout
Solutions:
- Optimize your script to run faster
- Increase timeout:
--script-timeout 60 - Break script into smaller chunks
Issue: Script cannot access files
Check:
- File paths are relative to project root
- File exists in the project directory
- No path traversal (
../) attempts
π Logging
Set log level via environment variable:
RUST_LOG=codebridge_cli=debug ./codebridge-cli
Log levels: error, warn, info, debug, trace
Log output includes:
- Request IDs for tracking
- Action execution details
- Build command detection
- Script execution logs
- Error details with context
πΊοΈ Roadmap
Phase 1 (Current)
- Smart build detection
- Git initialization action
- Script execution (Deno, Python, Bash)
Phase 2 (Next)
- Rust script support
- Docker sandboxing
- Script library with pre-approved scripts
- User approval UI for script execution
Phase 3 (Future)
- Heartbeat mechanism for multi-task coordination
- Dependency installation actions
- Network access controls
- Resource monitoring and limits
π€ Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new features
- Submit a pull request
Development Setup
git clone <repo>
cd codebridge-cli
cargo build
cargo test
π License
MIT License - see LICENSE file for details
π Acknowledgments
Built with:
π Support
For issues and questions:
- GitHub Issues: [link]
- Documentation: [link]
- Discord: [link]
Dependencies
~26β38MB
~677K SLoC