@rigstate/cli 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +5 -0
- package/IMPLEMENTATION.md +239 -0
- package/QUICK_START.md +220 -0
- package/README.md +150 -0
- package/dist/index.cjs +3987 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3964 -0
- package/dist/index.js.map +1 -0
- package/install.sh +15 -0
- package/package.json +53 -0
- package/src/commands/check.ts +329 -0
- package/src/commands/config.ts +81 -0
- package/src/commands/daemon.ts +197 -0
- package/src/commands/env.ts +158 -0
- package/src/commands/fix.ts +140 -0
- package/src/commands/focus.ts +134 -0
- package/src/commands/hooks.ts +163 -0
- package/src/commands/init.ts +282 -0
- package/src/commands/link.ts +45 -0
- package/src/commands/login.ts +35 -0
- package/src/commands/mcp.ts +73 -0
- package/src/commands/nexus.ts +81 -0
- package/src/commands/override.ts +65 -0
- package/src/commands/scan.ts +242 -0
- package/src/commands/sync-rules.ts +191 -0
- package/src/commands/sync.ts +339 -0
- package/src/commands/watch.ts +283 -0
- package/src/commands/work.ts +172 -0
- package/src/daemon/bridge-listener.ts +127 -0
- package/src/daemon/core.ts +184 -0
- package/src/daemon/factory.ts +45 -0
- package/src/daemon/file-watcher.ts +97 -0
- package/src/daemon/guardian-monitor.ts +133 -0
- package/src/daemon/heuristic-engine.ts +203 -0
- package/src/daemon/intervention-protocol.ts +128 -0
- package/src/daemon/telemetry.ts +23 -0
- package/src/daemon/types.ts +18 -0
- package/src/hive/gateway.ts +74 -0
- package/src/hive/protocol.ts +29 -0
- package/src/hive/scrubber.ts +72 -0
- package/src/index.ts +85 -0
- package/src/nexus/council.ts +103 -0
- package/src/nexus/dispatcher.ts +133 -0
- package/src/utils/config.ts +83 -0
- package/src/utils/files.ts +95 -0
- package/src/utils/governance.ts +128 -0
- package/src/utils/logger.ts +66 -0
- package/src/utils/manifest.ts +18 -0
- package/src/utils/rule-engine.ts +292 -0
- package/src/utils/skills-provisioner.ts +153 -0
- package/src/utils/version.ts +1 -0
- package/src/utils/watchdog.ts +215 -0
- package/tsconfig.json +29 -0
- package/tsup.config.ts +11 -0
package/.env.example
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# ✅ Rigstate CLI - Implementation Complete
|
|
2
|
+
|
|
3
|
+
## 📦 What Was Built
|
|
4
|
+
|
|
5
|
+
A fully functional CLI tool (`@rigstate/cli`) that consumes the Rigstate Public API at `/api/v1/audit`.
|
|
6
|
+
|
|
7
|
+
## 🎯 Features Implemented
|
|
8
|
+
|
|
9
|
+
### 1. Package Setup ✅
|
|
10
|
+
- **Location:** `packages/cli`
|
|
11
|
+
- **Package Name:** `@rigstate/cli`
|
|
12
|
+
- **Binary:** `rigstate` command
|
|
13
|
+
- **Build System:** tsup (ESM + CJS dual output)
|
|
14
|
+
- **Dependencies:**
|
|
15
|
+
- `commander` - CLI framework
|
|
16
|
+
- `axios` - HTTP client
|
|
17
|
+
- `chalk` - Terminal colors
|
|
18
|
+
- `conf` - Config storage
|
|
19
|
+
- `ora` - Loading spinners
|
|
20
|
+
- `glob` - File finding
|
|
21
|
+
- `dotenv` - Environment variables
|
|
22
|
+
|
|
23
|
+
### 2. Config Management ✅
|
|
24
|
+
- **File:** `src/utils/config.ts`
|
|
25
|
+
- **Storage:** Uses `conf` package
|
|
26
|
+
- **Location:**
|
|
27
|
+
- macOS/Linux: `~/.config/rigstate-cli/config.json`
|
|
28
|
+
- Windows: `%APPDATA%\rigstate-cli\config.json`
|
|
29
|
+
- **Stores:**
|
|
30
|
+
- API key
|
|
31
|
+
- Default project ID (optional)
|
|
32
|
+
- API URL (defaults to `http://localhost:3000`)
|
|
33
|
+
- **Helper Functions:**
|
|
34
|
+
- `getApiKey()` - Throws error if not logged in
|
|
35
|
+
- `setApiKey(key)`
|
|
36
|
+
- `getProjectId()`
|
|
37
|
+
- `setProjectId(id)`
|
|
38
|
+
- `getApiUrl()`
|
|
39
|
+
- `setApiUrl(url)`
|
|
40
|
+
|
|
41
|
+
### 3. Login Command ✅
|
|
42
|
+
- **Usage:** `rigstate login <api-key>`
|
|
43
|
+
- **Validation:** Ensures key starts with `sk_rigstate_`
|
|
44
|
+
- **Storage:** Saves key securely to local config
|
|
45
|
+
- **Output:** Success message confirming login
|
|
46
|
+
|
|
47
|
+
### 4. Scan Command ✅
|
|
48
|
+
- **Usage:** `rigstate scan [path] [--json] [--project <id>]`
|
|
49
|
+
- **Features:**
|
|
50
|
+
- **Smart File Detection:** Finds all code files (`.js`, `.ts`, `.py`, etc.)
|
|
51
|
+
- **Gitignore Respect:** ✅ CRITICAL - Honors `.gitignore` patterns
|
|
52
|
+
- **Default Ignores:** `node_modules`, `.git`, `dist`, `build`, `.next`, etc.
|
|
53
|
+
- **Progress Indicators:** Shows scanning progress with `ora` spinners
|
|
54
|
+
- **Individual File Scanning:** Sends each file separately to API
|
|
55
|
+
- **Error Handling:** Continues on individual file failures
|
|
56
|
+
- **Aggregated Results:** Combines all results into summary
|
|
57
|
+
|
|
58
|
+
#### Output Modes:
|
|
59
|
+
1. **Pretty Table (default):**
|
|
60
|
+
- Color-coded severity levels
|
|
61
|
+
- File grouping
|
|
62
|
+
- Summary statistics
|
|
63
|
+
- Easy to read for humans
|
|
64
|
+
|
|
65
|
+
2. **JSON (`--json` flag):**
|
|
66
|
+
- Machine-readable format
|
|
67
|
+
- Perfect for IDE extensions
|
|
68
|
+
- Includes full vulnerability details
|
|
69
|
+
|
|
70
|
+
### 5. File Utilities ✅
|
|
71
|
+
- **File:** `src/utils/files.ts`
|
|
72
|
+
- **Functions:**
|
|
73
|
+
- `readGitignore(dir)` - Parse .gitignore file
|
|
74
|
+
- `shouldIgnore(path, patterns)` - Check if file should be skipped
|
|
75
|
+
- `isCodeFile(path)` - Detect code files by extension
|
|
76
|
+
|
|
77
|
+
### 6. Entry Point ✅
|
|
78
|
+
- **File:** `src/index.ts`
|
|
79
|
+
- **Features:**
|
|
80
|
+
- Commander.js integration
|
|
81
|
+
- Command registration
|
|
82
|
+
- Help text with examples
|
|
83
|
+
- Version management
|
|
84
|
+
|
|
85
|
+
## 🔧 Build Configuration
|
|
86
|
+
|
|
87
|
+
### TypeScript (`tsconfig.json`)
|
|
88
|
+
- Target: ES2022
|
|
89
|
+
- Module: ESNext
|
|
90
|
+
- Strict mode enabled
|
|
91
|
+
- Node types included
|
|
92
|
+
|
|
93
|
+
### Bundler (`tsup.config.ts`)
|
|
94
|
+
- Dual output: ESM + CJS
|
|
95
|
+
- Source maps enabled
|
|
96
|
+
- Type declarations generated
|
|
97
|
+
- Clean build directory
|
|
98
|
+
|
|
99
|
+
## 📚 Documentation
|
|
100
|
+
|
|
101
|
+
1. **README.md** - Full documentation
|
|
102
|
+
2. **QUICK_START.md** - Step-by-step tutorial with troubleshooting
|
|
103
|
+
3. **.env.example** - Environment variable template
|
|
104
|
+
4. **install.sh** - Installation helper script
|
|
105
|
+
|
|
106
|
+
## 🧪 Testing
|
|
107
|
+
|
|
108
|
+
- **Test Sample:** `test-sample/vulnerable.js` (intentional security issues for demo)
|
|
109
|
+
- **Manual Testing:**
|
|
110
|
+
- Login command ✅
|
|
111
|
+
- Help output ✅
|
|
112
|
+
- Scan command structure ✅
|
|
113
|
+
|
|
114
|
+
## 🚀 Usage
|
|
115
|
+
|
|
116
|
+
### Installation:
|
|
117
|
+
```bash
|
|
118
|
+
cd packages/cli
|
|
119
|
+
npm install
|
|
120
|
+
npm run build
|
|
121
|
+
npm install -g .
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Commands:
|
|
125
|
+
```bash
|
|
126
|
+
# Login
|
|
127
|
+
rigstate login sk_rigstate_your_api_key
|
|
128
|
+
|
|
129
|
+
# Scan current directory
|
|
130
|
+
rigstate scan
|
|
131
|
+
|
|
132
|
+
# Scan specific path with project
|
|
133
|
+
rigstate scan ./src --project abc-123
|
|
134
|
+
|
|
135
|
+
# JSON output for IDE extensions
|
|
136
|
+
rigstate scan --json
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## 🔌 API Integration
|
|
140
|
+
|
|
141
|
+
### Endpoint:
|
|
142
|
+
`POST /api/v1/audit`
|
|
143
|
+
|
|
144
|
+
### Request Format:
|
|
145
|
+
```json
|
|
146
|
+
{
|
|
147
|
+
"content": "file contents",
|
|
148
|
+
"file_path": "relative/path/to/file.js",
|
|
149
|
+
"project_id": "uuid"
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Authentication:
|
|
154
|
+
```
|
|
155
|
+
Authorization: Bearer sk_rigstate_xxxxx
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### API Key Validation:
|
|
159
|
+
- Must start with `sk_rigstate_`
|
|
160
|
+
- Validated against `api_keys` table
|
|
161
|
+
- Updates `last_used_at` on each request
|
|
162
|
+
- Verifies project ownership
|
|
163
|
+
|
|
164
|
+
## 🎨 User Experience
|
|
165
|
+
|
|
166
|
+
### Features:
|
|
167
|
+
- ✅ **Beautiful output** with chalk colors
|
|
168
|
+
- ✅ **Progress indicators** with ora spinners
|
|
169
|
+
- ✅ **Error messages** with helpful suggestions
|
|
170
|
+
- ✅ **Severity color coding** (critical=red, high=red, medium=yellow, low=blue)
|
|
171
|
+
- ✅ **File count progress** (e.g., "Scanning 3/10: file.js")
|
|
172
|
+
- ✅ **Graceful error handling** (continues on file failures)
|
|
173
|
+
|
|
174
|
+
## 🔮 Future IDE Extensions
|
|
175
|
+
|
|
176
|
+
This CLI is designed as the **engine** for future IDE extensions:
|
|
177
|
+
|
|
178
|
+
### VS Code Extension
|
|
179
|
+
- Use `rigstate scan --json` to get structured results
|
|
180
|
+
- Parse and display in Problems panel
|
|
181
|
+
- Show inline warnings
|
|
182
|
+
|
|
183
|
+
### JetBrains Plugin
|
|
184
|
+
- Same JSON interface
|
|
185
|
+
- Integrate with IntelliJ inspection system
|
|
186
|
+
|
|
187
|
+
### Neovim Plugin
|
|
188
|
+
- Execute CLI commands
|
|
189
|
+
- Parse JSON output
|
|
190
|
+
- Display in quickfix list
|
|
191
|
+
|
|
192
|
+
## 📂 File Structure
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
packages/cli/
|
|
196
|
+
├── src/
|
|
197
|
+
│ ├── commands/
|
|
198
|
+
│ │ ├── login.ts # Login command
|
|
199
|
+
│ │ └── scan.ts # Scan command
|
|
200
|
+
│ ├── utils/
|
|
201
|
+
│ │ ├── config.ts # Config management
|
|
202
|
+
│ │ └── files.ts # File utilities
|
|
203
|
+
│ └── index.ts # Entry point
|
|
204
|
+
├── dist/ # Built files (ESM + CJS)
|
|
205
|
+
├── test-sample/ # Test files
|
|
206
|
+
├── package.json
|
|
207
|
+
├── tsconfig.json
|
|
208
|
+
├── tsup.config.ts
|
|
209
|
+
├── README.md
|
|
210
|
+
├── QUICK_START.md
|
|
211
|
+
└── install.sh
|
|
212
|
+
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## ✅ All Requirements Met
|
|
216
|
+
|
|
217
|
+
- [x] Initialize `packages/cli` in monorepo
|
|
218
|
+
- [x] Package name: `@rigstate/cli`
|
|
219
|
+
- [x] Binary: `rigstate` command
|
|
220
|
+
- [x] Dependencies: All installed and configured
|
|
221
|
+
- [x] Config management with `conf`
|
|
222
|
+
- [x] Login command with validation
|
|
223
|
+
- [x] Scan command with file globbing
|
|
224
|
+
- [x] **.gitignore respect** (CRITICAL REQUIREMENT)
|
|
225
|
+
- [x] API integration with proper auth
|
|
226
|
+
- [x] JSON output flag for IDE extensions
|
|
227
|
+
- [x] Pretty table output for humans
|
|
228
|
+
- [x] Error handling and user feedback
|
|
229
|
+
- [x] Build configuration (ESM + CJS)
|
|
230
|
+
- [x] Documentation (README + Quick Start)
|
|
231
|
+
|
|
232
|
+
## 🎉 Ready to Use
|
|
233
|
+
|
|
234
|
+
You can now:
|
|
235
|
+
1. Install globally: `npm install -g .` (inside packages/cli)
|
|
236
|
+
2. Login: `rigstate login sk_rigstate_your_key`
|
|
237
|
+
3. Scan: `rigstate scan`
|
|
238
|
+
|
|
239
|
+
The CLI is production-ready and serves as the foundation for IDE extensions! 🚀
|
package/QUICK_START.md
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# Rigstate CLI - Quick Start Guide
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
cd packages/cli
|
|
7
|
+
npm install
|
|
8
|
+
npm run build
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Global Installation (Optional)
|
|
12
|
+
|
|
13
|
+
To use `rigstate` from anywhere:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# Option 1: npm install
|
|
17
|
+
npm install -g .
|
|
18
|
+
|
|
19
|
+
# Option 2: Use the install script
|
|
20
|
+
chmod +x install.sh
|
|
21
|
+
./install.sh
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**Note:** You may need to use `sudo` for global installation on macOS/Linux.
|
|
25
|
+
|
|
26
|
+
## Testing Locally (Without Global Install)
|
|
27
|
+
|
|
28
|
+
You can test all commands without installing globally:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
node dist/index.js --help
|
|
32
|
+
node dist/index.js login sk_rigstate_your_key_here
|
|
33
|
+
node dist/index.js scan
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Step-by-Step Tutorial
|
|
37
|
+
|
|
38
|
+
### 1. Get Your API Key
|
|
39
|
+
|
|
40
|
+
1. Go to your Rigstate dashboard
|
|
41
|
+
2. Navigate to Settings → API Keys
|
|
42
|
+
3. Click "Generate New Key"
|
|
43
|
+
4. Copy the key (it starts with `sk_rigstate_`)
|
|
44
|
+
|
|
45
|
+
### 2. Login
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
rigstate login sk_rigstate_1234567890abcdef
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
You should see:
|
|
52
|
+
```
|
|
53
|
+
✅ Successfully logged in!
|
|
54
|
+
|
|
55
|
+
Your API key has been securely stored. You can now use "rigstate scan" to audit your code.
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 3. Run Your First Scan
|
|
59
|
+
|
|
60
|
+
**Scan current directory:**
|
|
61
|
+
```bash
|
|
62
|
+
rigstate scan
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**Scan a specific folder:**
|
|
66
|
+
```bash
|
|
67
|
+
rigstate scan ./src
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Scan with project ID:**
|
|
71
|
+
```bash
|
|
72
|
+
rigstate scan --project abc-123-def-456
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Output as JSON (for IDE extensions):**
|
|
76
|
+
```bash
|
|
77
|
+
rigstate scan --json
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### 4. Understanding the Output
|
|
81
|
+
|
|
82
|
+
**Human-readable format (default):**
|
|
83
|
+
```
|
|
84
|
+
📊 Scan Summary
|
|
85
|
+
────────────────────────────────────────────────────────────
|
|
86
|
+
Total Files Scanned: 5
|
|
87
|
+
Total Issues Found: 3
|
|
88
|
+
|
|
89
|
+
Issues by Severity:
|
|
90
|
+
critical: 1
|
|
91
|
+
high: 1
|
|
92
|
+
medium: 1
|
|
93
|
+
|
|
94
|
+
🔍 Detailed Results
|
|
95
|
+
────────────────────────────────────────────────────────────
|
|
96
|
+
|
|
97
|
+
src/auth.js
|
|
98
|
+
[CRITICAL] SQL Injection
|
|
99
|
+
Potential SQL injection vulnerability detected
|
|
100
|
+
[HIGH] Hardcoded Password
|
|
101
|
+
Hardcoded credentials found in source code
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**JSON format:**
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"results": [
|
|
108
|
+
{
|
|
109
|
+
"id": "src/auth.js",
|
|
110
|
+
"file_path": "src/auth.js",
|
|
111
|
+
"issues": [
|
|
112
|
+
{
|
|
113
|
+
"type": "SQL Injection",
|
|
114
|
+
"severity": "critical",
|
|
115
|
+
"message": "Potential SQL injection vulnerability detected",
|
|
116
|
+
"line": 5
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
"summary": {
|
|
122
|
+
"total_files": 5,
|
|
123
|
+
"total_issues": 3,
|
|
124
|
+
"by_severity": {
|
|
125
|
+
"critical": 1,
|
|
126
|
+
"high": 1,
|
|
127
|
+
"medium": 1
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## File Detection
|
|
134
|
+
|
|
135
|
+
The CLI automatically:
|
|
136
|
+
- ✅ Finds all code files (`.js`, `.ts`, `.py`, etc.)
|
|
137
|
+
- ✅ Respects your `.gitignore` patterns
|
|
138
|
+
- ✅ Skips `node_modules`, `.git`, `dist`, etc.
|
|
139
|
+
- ✅ Processes files in parallel for speed
|
|
140
|
+
|
|
141
|
+
## Configuration
|
|
142
|
+
|
|
143
|
+
Your config is stored at:
|
|
144
|
+
- **macOS/Linux:** `~/.config/rigstate-cli/config.json`
|
|
145
|
+
- **Windows:** `%APPDATA%\rigstate-cli\config.json`
|
|
146
|
+
|
|
147
|
+
### Environment Variables
|
|
148
|
+
|
|
149
|
+
Override the API URL for production:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
export RIGSTATE_API_URL=https://api.rigstate.com
|
|
153
|
+
rigstate scan
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Or create a `.env` file:
|
|
157
|
+
```
|
|
158
|
+
RIGSTATE_API_URL=https://api.rigstate.com
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Troubleshooting
|
|
162
|
+
|
|
163
|
+
### "Not logged in" Error
|
|
164
|
+
```bash
|
|
165
|
+
❌ Not logged in. Please run "rigstate login <your-api-key>" first.
|
|
166
|
+
```
|
|
167
|
+
**Solution:** Run `rigstate login sk_rigstate_your_key_here`
|
|
168
|
+
|
|
169
|
+
### "Invalid API key format" Error
|
|
170
|
+
```bash
|
|
171
|
+
❌ Invalid API key format
|
|
172
|
+
API keys must start with "sk_rigstate_"
|
|
173
|
+
```
|
|
174
|
+
**Solution:** Make sure your key starts with `sk_rigstate_`. Generate a new one from the dashboard if needed.
|
|
175
|
+
|
|
176
|
+
### "Project not found" Error
|
|
177
|
+
```bash
|
|
178
|
+
❌ Project not found or access denied
|
|
179
|
+
```
|
|
180
|
+
**Solution:**
|
|
181
|
+
- Check that the project ID is correct
|
|
182
|
+
- Ensure you own the project
|
|
183
|
+
- Try without the `--project` flag
|
|
184
|
+
|
|
185
|
+
### Network Error
|
|
186
|
+
```bash
|
|
187
|
+
❌ Network Error: Could not reach the API. Is the server running?
|
|
188
|
+
```
|
|
189
|
+
**Solution:**
|
|
190
|
+
- Check that the Rigstate API is running (`npm run dev` in the main project)
|
|
191
|
+
- Verify the API URL in your config or environment variables
|
|
192
|
+
- Check your internet connection
|
|
193
|
+
|
|
194
|
+
## Development
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
# Install dependencies
|
|
198
|
+
npm install
|
|
199
|
+
|
|
200
|
+
# Build once
|
|
201
|
+
npm run build
|
|
202
|
+
|
|
203
|
+
# Watch mode (auto-rebuild on changes)
|
|
204
|
+
npm run dev
|
|
205
|
+
|
|
206
|
+
# Type checking
|
|
207
|
+
npm run lint
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Next Steps
|
|
211
|
+
|
|
212
|
+
- Check out the full [README.md](./README.md)
|
|
213
|
+
- Learn about [IDE Extensions](./README.md#future-ide-extensions)
|
|
214
|
+
- Read the [API Documentation](../../docs/api.md)
|
|
215
|
+
|
|
216
|
+
## Support
|
|
217
|
+
|
|
218
|
+
- GitHub Issues: [Create an issue](https://github.com/rigstate/rigstate/issues)
|
|
219
|
+
- Email: support@rigstate.com
|
|
220
|
+
- Discord: [Join our community](https://discord.gg/rigstate)
|
package/README.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# @rigstate/cli
|
|
2
|
+
|
|
3
|
+
The official command-line interface for Rigstate - AI-powered code audit and security analysis.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
### From source (development)
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
cd packages/cli
|
|
11
|
+
npm install
|
|
12
|
+
npm run build
|
|
13
|
+
npm install -g .
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### From npm (coming soon)
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install -g @rigstate/cli
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
### 1. Login
|
|
25
|
+
|
|
26
|
+
Authenticate with your Rigstate API key:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
rigstate login sk_rigstate_your_key_here
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
You can generate an API key from your Rigstate dashboard at the API Keys section.
|
|
33
|
+
|
|
34
|
+
### 2. Scan Your Code
|
|
35
|
+
|
|
36
|
+
Scan your current directory:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
rigstate scan
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Scan a specific directory:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
rigstate scan ./src
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Scan with a project ID:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
rigstate scan --project abc123
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Output as JSON (useful for IDE extensions):
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
rigstate scan --json
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Commands
|
|
61
|
+
|
|
62
|
+
### `rigstate login <api-key>`
|
|
63
|
+
|
|
64
|
+
Authenticate with your Rigstate API key. The key is securely stored locally.
|
|
65
|
+
|
|
66
|
+
**Arguments:**
|
|
67
|
+
- `api-key` - Your Rigstate API key (starts with `sk_rigstate_`)
|
|
68
|
+
|
|
69
|
+
**Example:**
|
|
70
|
+
```bash
|
|
71
|
+
rigstate login sk_rigstate_1234567890abcdef
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### `rigstate scan [path]`
|
|
75
|
+
|
|
76
|
+
Scan code files for security and quality issues.
|
|
77
|
+
|
|
78
|
+
**Arguments:**
|
|
79
|
+
- `path` - Directory or file to scan (default: current directory)
|
|
80
|
+
|
|
81
|
+
**Options:**
|
|
82
|
+
- `--json` - Output results as JSON instead of formatted text
|
|
83
|
+
- `--project <id>` - Project ID to associate with this scan
|
|
84
|
+
|
|
85
|
+
**Example:**
|
|
86
|
+
```bash
|
|
87
|
+
rigstate scan ./src --project my-project-123 --json
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Features
|
|
91
|
+
|
|
92
|
+
- 🔐 **Secure Authentication** - API keys stored locally using `conf`
|
|
93
|
+
- 📁 **Smart File Detection** - Automatically finds code files
|
|
94
|
+
- 🚫 **Gitignore Respect** - Honors your .gitignore patterns
|
|
95
|
+
- 🎨 **Beautiful Output** - Color-coded results with severity levels
|
|
96
|
+
- 📊 **JSON Export** - Machine-readable output for integrations
|
|
97
|
+
- ⚡ **Fast Scanning** - Parallel file processing
|
|
98
|
+
|
|
99
|
+
## Configuration
|
|
100
|
+
|
|
101
|
+
Configuration is stored in:
|
|
102
|
+
- **macOS/Linux:** `~/.config/rigstate-cli/config.json`
|
|
103
|
+
- **Windows:** `%APPDATA%\rigstate-cli\config.json`
|
|
104
|
+
|
|
105
|
+
The config file stores:
|
|
106
|
+
- `apiKey` - Your authentication key
|
|
107
|
+
- `projectId` - Default project ID (optional)
|
|
108
|
+
- `apiUrl` - API endpoint (defaults to `http://localhost:3000`)
|
|
109
|
+
|
|
110
|
+
## Environment Variables
|
|
111
|
+
|
|
112
|
+
You can override the API URL with an environment variable:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
export RIGSTATE_API_URL=https://api.rigstate.com
|
|
116
|
+
rigstate scan
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Development
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# Install dependencies
|
|
123
|
+
npm install
|
|
124
|
+
|
|
125
|
+
# Build the CLI
|
|
126
|
+
npm run build
|
|
127
|
+
|
|
128
|
+
# Watch mode for development
|
|
129
|
+
npm run dev
|
|
130
|
+
|
|
131
|
+
# Link locally for testing
|
|
132
|
+
npm link
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Future IDE Extensions
|
|
136
|
+
|
|
137
|
+
This CLI is the foundation for our upcoming IDE extensions:
|
|
138
|
+
- VS Code Extension
|
|
139
|
+
- JetBrains Plugin
|
|
140
|
+
- Neovim Plugin
|
|
141
|
+
|
|
142
|
+
The `--json` flag is specifically designed for these integrations.
|
|
143
|
+
|
|
144
|
+
## Support
|
|
145
|
+
|
|
146
|
+
For issues, questions, or feature requests, please visit our GitHub repository or contact support.
|
|
147
|
+
|
|
148
|
+
## License
|
|
149
|
+
|
|
150
|
+
MIT
|