-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/rust cli implementation #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
e35b579
9582b43
6341a53
859f71b
5694367
05b6fc5
18d4700
9f540bc
0f06d80
53bce83
c388a13
2c523a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # Cargo aliases (simpler alternative to cargo-make) | ||
| # Usage: cargo <alias-name> | ||
| # Examples: cargo b (build), cargo r (run), cargo t (test), cargo cl (clippy) | ||
|
|
||
| [alias] | ||
| # Build aliases | ||
| b = "build" | ||
| br = "build --release" | ||
| c = "check" | ||
|
|
||
| # Run aliases | ||
| r = "run" | ||
| rr = "run --release" | ||
|
|
||
| # Test aliases | ||
| t = "test" | ||
| tt = "test -- --nocapture" | ||
|
|
||
| # Linting/formatting | ||
| cl = "clippy -- -D warnings" | ||
| f = "fmt" | ||
| fc = "fmt -- --check" | ||
|
|
||
| # Clean | ||
| clean-all = "clean" | ||
|
|
||
| # Combined tasks (use scripts/pre-commit.sh for combined workflow) | ||
| # Note: Cargo aliases don't support shell operators like && | ||
| # Run these commands separately: | ||
| # cargo fmt | ||
| # cargo clippy -- -D warnings | ||
| # cargo test |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # Logs | ||
| logs | ||
| *.log | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| dev-debug.log | ||
|
|
||
| # Dependency directories | ||
| node_modules/ | ||
|
|
||
| # Environment variables | ||
| .env | ||
|
|
||
| # Editor directories and files | ||
| .idea | ||
| .vscode | ||
| *.suo | ||
| *.ntvs* | ||
| *.njsproj | ||
| *.sln | ||
| *.sw? | ||
|
|
||
| # OS specific | ||
| .DS_Store | ||
|
|
||
|
|
||
| # Added by cargo | ||
|
|
||
| /target | ||
|
|
||
| # Local config files | ||
| .clai.toml | ||
|
|
||
| # TaskMaster (local to developer, not tracked in Git) | ||
| .taskmaster/ | ||
|
|
||
| # Cursor IDE (local to developer, not tracked in Git) | ||
| .cursor/ |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,138 @@ | ||||||||||||||||||
| # Contributing to clai | ||||||||||||||||||
|
|
||||||||||||||||||
| ## Development Setup | ||||||||||||||||||
|
|
||||||||||||||||||
| ### Prerequisites | ||||||||||||||||||
|
|
||||||||||||||||||
| - Rust 1.70+ | ||||||||||||||||||
| - OpenRouter API key (for testing AI features) | ||||||||||||||||||
|
|
||||||||||||||||||
| ```bash | ||||||||||||||||||
| git clone https://github.com/Vedaant-Rajoo/clAI.git | ||||||||||||||||||
| cd clAI | ||||||||||||||||||
| cargo build | ||||||||||||||||||
|
|
||||||||||||||||||
| # Install Git hooks (recommended) | ||||||||||||||||||
| ./scripts/install-hooks.sh | ||||||||||||||||||
| ``` | ||||||||||||||||||
|
|
||||||||||||||||||
| ### Running | ||||||||||||||||||
|
|
||||||||||||||||||
| ```bash | ||||||||||||||||||
| cargo run -- "your instruction" | ||||||||||||||||||
| ``` | ||||||||||||||||||
|
|
||||||||||||||||||
| ## Project Structure | ||||||||||||||||||
|
|
||||||||||||||||||
| ``` | ||||||||||||||||||
| src/ | ||||||||||||||||||
| ├── main.rs # Entry point | ||||||||||||||||||
| ├── lib.rs # Library exports | ||||||||||||||||||
| ├── cli/ # Argument parsing | ||||||||||||||||||
| ├── config/ # Configuration loading | ||||||||||||||||||
| ├── context/ # System/directory context gathering | ||||||||||||||||||
| ├── ai/ # AI provider abstraction | ||||||||||||||||||
| │ └── providers/ # OpenRouter, etc. | ||||||||||||||||||
| ├── safety/ # Dangerous command detection | ||||||||||||||||||
| └── error/ # Error types and exit codes | ||||||||||||||||||
| ``` | ||||||||||||||||||
|
|
||||||||||||||||||
| ## Commands | ||||||||||||||||||
|
|
||||||||||||||||||
| ```bash | ||||||||||||||||||
| cargo build # Debug build | ||||||||||||||||||
| cargo build --release # Release build | ||||||||||||||||||
| cargo test # Run tests | ||||||||||||||||||
| cargo clippy # Lint | ||||||||||||||||||
| cargo fmt # Format | ||||||||||||||||||
| cargo bench --features bench # Run benchmarks | ||||||||||||||||||
| ``` | ||||||||||||||||||
|
|
||||||||||||||||||
| ## Configuration | ||||||||||||||||||
|
|
||||||||||||||||||
| ### Environment Variables | ||||||||||||||||||
|
|
||||||||||||||||||
| | Variable | Description | | ||||||||||||||||||
| | -------------------- | ---------------------- | | ||||||||||||||||||
| | `OPENROUTER_API_KEY` | API key for OpenRouter | | ||||||||||||||||||
| | `NO_COLOR` | Disable colored output | | ||||||||||||||||||
|
|
||||||||||||||||||
| ### Config File Locations | ||||||||||||||||||
|
|
||||||||||||||||||
| 1. `./.clai.toml` (project-local, highest priority) | ||||||||||||||||||
| 2. `~/.config/clai/config.toml` (user) | ||||||||||||||||||
| 3. `/etc/clai/config.toml` (system) | ||||||||||||||||||
|
|
||||||||||||||||||
|
Comment on lines
+62
to
+65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Document XDG_CONFIG_HOME support in config file precedence. The implementation in 🔎 Proposed fixUpdate the list to include all four locations: 1. `./.clai.toml` (project-local, highest priority)
-2. `~/.config/clai/config.toml` (user)
-3. `/etc/clai/config.toml` (system)
+2. `$XDG_CONFIG_HOME/clai/config.toml` (if XDG_CONFIG_HOME is set)
+3. `~/.config/clai/config.toml` (fallback if XDG_CONFIG_HOME not set)
+4. `/etc/clai/config.toml` (system, lowest priority)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
| ### Full Config Example | ||||||||||||||||||
|
|
||||||||||||||||||
| ```toml | ||||||||||||||||||
| [provider] | ||||||||||||||||||
| default = "openrouter" | ||||||||||||||||||
| api-key = "${OPENROUTER_API_KEY}" | ||||||||||||||||||
|
|
||||||||||||||||||
| [provider.openrouter] | ||||||||||||||||||
| model = "qwen/qwen3-coder" | ||||||||||||||||||
|
|
||||||||||||||||||
| [context] | ||||||||||||||||||
| max-history = 3 | ||||||||||||||||||
| max-files = 10 | ||||||||||||||||||
|
|
||||||||||||||||||
| [safety] | ||||||||||||||||||
| confirm-dangerous = true | ||||||||||||||||||
| dangerous-patterns = [ | ||||||||||||||||||
| "rm -rf", | ||||||||||||||||||
| "sudo.*rm", | ||||||||||||||||||
| ".*> /dev/sd[a-z]", | ||||||||||||||||||
| ] | ||||||||||||||||||
|
|
||||||||||||||||||
| [ui] | ||||||||||||||||||
| interactive = true | ||||||||||||||||||
| color = "auto" | ||||||||||||||||||
| ``` | ||||||||||||||||||
|
|
||||||||||||||||||
| ## Exit Codes | ||||||||||||||||||
|
|
||||||||||||||||||
| | Code | Meaning | | ||||||||||||||||||
| | ---- | ----------------------------------------- | | ||||||||||||||||||
| | 0 | Success | | ||||||||||||||||||
| | 1 | General error | | ||||||||||||||||||
| | 2 | Usage error | | ||||||||||||||||||
| | 3 | Configuration error | | ||||||||||||||||||
| | 4 | API error | | ||||||||||||||||||
| | 5 | Safety error (dangerous command rejected) | | ||||||||||||||||||
| | 130 | Interrupted (Ctrl+C) | | ||||||||||||||||||
|
|
||||||||||||||||||
| ## Pull Request Process | ||||||||||||||||||
|
|
||||||||||||||||||
| 1. Fork and create a feature branch | ||||||||||||||||||
| 2. Install Git hooks: `./scripts/install-hooks.sh` (if not already done) | ||||||||||||||||||
| 3. Make changes | ||||||||||||||||||
| 4. The pre-commit hook will automatically run checks before each commit: | ||||||||||||||||||
| - Format code with `cargo fmt` | ||||||||||||||||||
| - Run `cargo clippy -- -D warnings` | ||||||||||||||||||
| - Run `cargo test` | ||||||||||||||||||
| 5. If you need to bypass the hook temporarily: `git commit --no-verify` | ||||||||||||||||||
| 6. Submit PR | ||||||||||||||||||
|
|
||||||||||||||||||
| ### Manual Checks | ||||||||||||||||||
|
|
||||||||||||||||||
| If you haven't installed the Git hooks, run these commands before committing: | ||||||||||||||||||
|
|
||||||||||||||||||
| ```bash | ||||||||||||||||||
| ./scripts/pre-commit.sh # Run all checks | ||||||||||||||||||
| ``` | ||||||||||||||||||
|
|
||||||||||||||||||
| Or individually: | ||||||||||||||||||
|
|
||||||||||||||||||
| ```bash | ||||||||||||||||||
| cargo fmt # Format code | ||||||||||||||||||
| cargo clippy -- -D warnings # Check lints | ||||||||||||||||||
| cargo test # Run tests | ||||||||||||||||||
| ``` | ||||||||||||||||||
|
|
||||||||||||||||||
| ## Code Style | ||||||||||||||||||
|
|
||||||||||||||||||
| - Follow `cargo fmt` formatting | ||||||||||||||||||
| - Use `cargo clippy` for lints | ||||||||||||||||||
| - Write tests for new features | ||||||||||||||||||
| - Document public APIs | ||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add language identifier to fenced code block.
The code block at line 27 lacks a language identifier, causing markdown linting failures.
🔎 Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)
27-27: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🤖 Prompt for AI Agents