Skip to content

Commit 42babac

Browse files
committed
feat: add Rust language support and complete 3-week improvement sequence
- Add comprehensive Rust language implementation: - Rust config wizard with tool detection - Rust tool detector for rustc, cargo, rustup, frameworks - Rust command runner with 10 commands - Rust setup documentation - Complete JavaScript/TypeScript implementation: - Fix ESLint issues and add trailing commas - Add comprehensive test suite - Improve error handling and suggestions - Create LANGUAGE-ADDITION-GUIDE.md for scalable future additions - All 73 tests pass with expanded test coverage - Fix code quality infrastructure (ESLint + Prettier) This completes the 3-week improvement sequence with 6 fully supported languages: Python, Go, Elixir, PineScript, JavaScript/TypeScript, and Rust.
1 parent 31ad1eb commit 42babac

19 files changed

Lines changed: 2398 additions & 19 deletions

commands/rust-setup.md

Lines changed: 270 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
# Rust Setup Command (`/rust-setup`)
2+
3+
Interactive setup for Rust projects. Detects Rust tools, configurations, and provides recommendations.
4+
5+
## Overview
6+
7+
The Rust setup command helps you configure your Rust project by:
8+
9+
1. Detecting installed Rust tools (rustc, cargo, rustup)
10+
2. Analyzing your project structure and dependencies
11+
3. Providing tool recommendations
12+
4. Saving configuration for future use
13+
14+
## Usage
15+
16+
```bash
17+
/rust-setup
18+
```
19+
20+
## What It Does
21+
22+
### 1. Tool Detection
23+
24+
- **rustc**: Rust compiler version and installation status
25+
- **cargo**: Rust package manager and build system
26+
- **rustup**: Rust toolchain manager (if installed)
27+
- **clippy**: Rust linter (if installed)
28+
- **rustfmt**: Rust code formatter (if installed)
29+
30+
### 2. Project Analysis
31+
32+
- **Project type**: Binary, library, or workspace
33+
- **Rust edition**: 2015, 2018, or 2021
34+
- **Dependencies**: Count of regular, dev, and build dependencies
35+
- **Frameworks**: Detected web, GUI, async, or game frameworks
36+
37+
### 3. Configuration
38+
39+
Saves project configuration to `.opencode/config.json` with:
40+
41+
- Project metadata
42+
- Tool versions
43+
- Framework information
44+
- Custom settings
45+
46+
## Features
47+
48+
### Automatic Detection
49+
50+
- Detects Rust installation status
51+
- Identifies project type and structure
52+
- Finds installed frameworks and tools
53+
54+
### Smart Recommendations
55+
56+
- Suggests missing essential tools
57+
- Recommends useful development tools
58+
- Provides installation commands
59+
60+
### Error Recovery
61+
62+
- Clear error messages for missing tools
63+
- Installation instructions
64+
- Troubleshooting suggestions
65+
66+
## Examples
67+
68+
### Basic Setup
69+
70+
```bash
71+
/rust-setup
72+
```
73+
74+
Output:
75+
76+
```
77+
🦀 Rust Project Configuration Wizard
78+
79+
Rust Environment Report
80+
========================================
81+
rustc: v1.75.0
82+
cargo: v1.75.0
83+
rustup: v1.26.0
84+
Default toolchain: stable-x86_64-apple-darwin
85+
86+
Project Information:
87+
Name: my-project
88+
Version: 0.1.0
89+
Edition: 2021
90+
Type: Binary
91+
Dependencies: 5
92+
Dev Dependencies: 3
93+
Build Dependencies: 0
94+
95+
Frameworks: tokio, clap
96+
Linters: clippy
97+
Formatters: rustfmt
98+
Test Frameworks: cargo-test
99+
100+
✅ Configuration saved successfully!
101+
102+
🎉 Rust Configuration Complete!
103+
==================================================
104+
Project: my-project
105+
Type: binary
106+
Edition: 2021
107+
Frameworks: tokio, clap
108+
==================================================
109+
110+
🦀 Available Commands:
111+
/rust-setup - Setup Rust project and install tools
112+
/rust-test - Run tests
113+
/rust-build - Build project
114+
/rust-check - Check code without building
115+
/rust-clippy - Run clippy linter
116+
/rust-fmt - Format code
117+
/rust-run - Run project
118+
/rust-doc - Generate documentation
119+
120+
💡 Recommended Tools to Install:
121+
1. cargo-watch: Automatically run commands on file changes
122+
Command: cargo install cargo-watch
123+
124+
🚀 Next Steps:
125+
1. Run /rust-setup to install recommended tools
126+
2. Run /rust-check to check your code
127+
3. Run /rust-test to run tests
128+
4. Run /rust-build to build your project
129+
```
130+
131+
### Missing Tools
132+
133+
If Rust is not installed:
134+
135+
```bash
136+
/rust-setup
137+
```
138+
139+
Output:
140+
141+
```
142+
🦀 Rust Project Configuration Wizard
143+
144+
Rust Environment Report
145+
========================================
146+
rustc: Not installed
147+
cargo: Not installed
148+
149+
⚠️ Missing Essential Tools:
150+
• rustc (Rust compiler)
151+
• cargo (Rust package manager)
152+
153+
📦 Installation Instructions:
154+
To install Rust and Cargo, run:
155+
curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh
156+
157+
After installation, restart your terminal or run:
158+
source $HOME/.cargo/env
159+
```
160+
161+
## Common Issues
162+
163+
### Rust Not Installed
164+
165+
**Solution**: Install Rust using rustup:
166+
167+
```bash
168+
curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh
169+
```
170+
171+
### Outdated Rust Version
172+
173+
**Solution**: Update Rust:
174+
175+
```bash
176+
rustup update
177+
```
178+
179+
### Missing Cargo.toml
180+
181+
**Solution**: Create a new Rust project:
182+
183+
```bash
184+
cargo new my-project
185+
cd my-project
186+
/rust-setup
187+
```
188+
189+
### Permission Issues
190+
191+
**Solution**: Fix cargo directory permissions:
192+
193+
```bash
194+
sudo chown -R $(whoami) ~/.cargo
195+
```
196+
197+
## Related Commands
198+
199+
- `/rust-test` - Run Rust tests
200+
- `/rust-build` - Build Rust project
201+
- `/rust-check` - Check code without building
202+
- `/rust-clippy` - Run clippy linter
203+
- `/rust-fmt` - Format code with rustfmt
204+
- `/rust-run` - Run the project
205+
- `/rust-doc` - Generate documentation
206+
- `/rust-clean` - Clean build artifacts
207+
- `/rust-update` - Update dependencies
208+
209+
## Configuration File
210+
211+
The setup creates/updates `.opencode/config.json`:
212+
213+
```json
214+
{
215+
"rust": {
216+
"name": "my-project",
217+
"type": "binary",
218+
"edition": "2021",
219+
"frameworks": ["tokio", "clap"],
220+
"language": "rust",
221+
"tools": {
222+
"rustc": {
223+
"installed": true,
224+
"version": "1.75.0",
225+
"path": "/Users/username/.cargo/bin/rustc"
226+
},
227+
"cargo": {
228+
"installed": true,
229+
"version": "1.75.0",
230+
"path": "/Users/username/.cargo/bin/cargo"
231+
}
232+
},
233+
"project": {
234+
"hasCargoToml": true,
235+
"hasCargoLock": true,
236+
"name": "my-project",
237+
"version": "0.1.0",
238+
"dependencies": 5,
239+
"devDependencies": 3,
240+
"buildDependencies": 0
241+
},
242+
"recommendations": [
243+
{
244+
"tool": "cargo-watch",
245+
"reason": "Automatically run commands on file changes",
246+
"command": "cargo install cargo-watch"
247+
}
248+
]
249+
}
250+
}
251+
```
252+
253+
## Tips
254+
255+
1. **Run setup first**: Always run `/rust-setup` before other Rust commands
256+
2. **Keep tools updated**: Regularly update Rust and tools with `rustup update`
257+
3. **Use recommended tools**: Install suggested tools for better development experience
258+
4. **Check configuration**: Review `.opencode/config.json` for project settings
259+
5. **Re-run after changes**: Run `/rust-setup` after major project changes
260+
261+
## Support
262+
263+
For issues with Rust setup:
264+
265+
1. Check Rust installation: `rustc --version`
266+
2. Verify cargo works: `cargo --version`
267+
3. Check project has Cargo.toml
268+
4. Review error messages for specific issues
269+
270+
If problems persist, check the [Rust installation guide](https://www.rust-lang.org/tools/install).

languages/javascript/config-wizard.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class JSConfigWizard {
8585
// Package manager detection
8686
if (report.packageManager) {
8787
console.log(
88-
`📦 Package Manager: ${report.packageManager.name} v${report.packageManager.version}`
88+
`📦 Package Manager: ${report.packageManager.name} v${report.packageManager.version}`,
8989
);
9090
}
9191

@@ -99,13 +99,13 @@ class JSConfigWizard {
9999
console.log(`🔧 Build Tools: ${report.buildTools.join(', ')}`);
100100
}
101101

102-
console.log('='.repeat(40) + '\n');
102+
console.log(`${'='.repeat(40)}\n`);
103103
}
104104

105105
/**
106106
* Detect project type
107107
*/
108-
async detectProjectType(options = {}) {
108+
async detectProjectType(_options = {}) {
109109
const projectInfo = {
110110
type: 'javascript',
111111
framework: null,
@@ -202,7 +202,7 @@ class JSConfigWizard {
202202
/**
203203
* Configure project based on type
204204
*/
205-
async configureProject(projectType, options = {}) {
205+
async configureProject(projectType, _options = {}) {
206206
const config = {
207207
name: path.basename(this.projectPath),
208208
type: projectType.type,

languages/javascript/tool-detector.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Detect JavaScript/TypeScript development tools with cross-platform support
55
*/
66

7-
const { spawn } = require('child_process');
7+
// const { spawn } = require('child_process');
88
const { commandExists, runCommand } = require('../../scripts/lib/utils');
99
const PlatformDetector = require('../../scripts/lib/platform-detector');
1010

@@ -416,7 +416,7 @@ class JSToolDetector {
416416
/**
417417
* Get tool installation command
418418
*/
419-
getInstallationCommand(toolName, options = {}) {
419+
getInstallationCommand(toolName, _options = {}) {
420420
const commands = {
421421
node: {
422422
macos: 'brew install node',

0 commit comments

Comments
 (0)