|
| 1 | +# Claude CLI-Inspired Features |
| 2 | + |
| 3 | +This document describes the new features added to Socket CLI inspired by modern CLI experiences like Claude CLI. |
| 4 | + |
| 5 | +## ✨ New Features |
| 6 | + |
| 7 | +### 1. Natural Language Command Interface (`socket ai`) |
| 8 | + |
| 9 | +Use natural language to describe what you want to do, and the AI will translate it to the appropriate Socket CLI command. |
| 10 | + |
| 11 | +```bash |
| 12 | +# Examples |
| 13 | +socket ai "scan this project for vulnerabilities" |
| 14 | +socket ai "fix all critical issues" |
| 15 | +socket ai "show me production vulnerabilities" |
| 16 | +socket ai "is express safe to use" |
| 17 | +socket ai "optimize my dependencies" |
| 18 | + |
| 19 | +# Execute directly with -e flag |
| 20 | +socket ai "scan for vulnerabilities" -e |
| 21 | +``` |
| 22 | + |
| 23 | +The AI understands various intents: |
| 24 | +- Scanning and security checks |
| 25 | +- Fixing vulnerabilities |
| 26 | +- Package optimization |
| 27 | +- Repository management |
| 28 | +- Configuration |
| 29 | + |
| 30 | +### 2. Interactive Fix Mode |
| 31 | + |
| 32 | +Guided vulnerability remediation with intelligent grouping and safe auto-fix options. |
| 33 | + |
| 34 | +```bash |
| 35 | +# Start interactive fix mode |
| 36 | +socket fix interactive |
| 37 | + |
| 38 | +# Auto-apply safe fixes only |
| 39 | +socket fix interactive --auto |
| 40 | + |
| 41 | +# Preview without applying |
| 42 | +socket fix interactive --dry-run |
| 43 | + |
| 44 | +# Filter by severity |
| 45 | +socket fix interactive --severity=high |
| 46 | +``` |
| 47 | + |
| 48 | +Features: |
| 49 | +- Groups vulnerabilities by severity, package, or type |
| 50 | +- Shows breaking change warnings |
| 51 | +- Identifies dependent packages |
| 52 | +- Safe auto-fix for non-breaking updates |
| 53 | +- Detailed explanations for each fix |
| 54 | + |
| 55 | +### 3. Project Context Awareness |
| 56 | + |
| 57 | +Automatically detects your project setup and provides tailored suggestions. |
| 58 | + |
| 59 | +```bash |
| 60 | +# Detects: |
| 61 | +- Package manager (npm/yarn/pnpm) |
| 62 | +- Framework (React, Vue, Angular, Next.js, etc) |
| 63 | +- Monorepo structure |
| 64 | +- Lock file presence |
| 65 | +``` |
| 66 | + |
| 67 | +Provides contextual help: |
| 68 | +- Suggests pnpm --recursive for pnpm monorepos |
| 69 | +- Recommends --prod flag for production builds |
| 70 | +- Warns about missing lock files |
| 71 | +- Framework-specific security recommendations |
| 72 | + |
| 73 | +### 4. Rich Progress Indicators |
| 74 | + |
| 75 | +Beautiful terminal UI for long-running operations. |
| 76 | + |
| 77 | +```typescript |
| 78 | +// Multi-progress bars for parallel operations |
| 79 | +const progress = new MultiProgress() |
| 80 | +progress.addTask('scan-1', 'Scanning package.json', 100) |
| 81 | +progress.addTask('scan-2', 'Analyzing dependencies', 200) |
| 82 | + |
| 83 | +// Spinners with dynamic messages |
| 84 | +const spinner = new Spinner('Analyzing project...') |
| 85 | +spinner.update('Found 150 dependencies') |
| 86 | +spinner.succeed('Analysis complete') |
| 87 | + |
| 88 | +// File progress tracking |
| 89 | +const fileProgress = new FileProgress(files, 'Scanning') |
| 90 | +``` |
| 91 | + |
| 92 | +### 5. Intelligent Offline Caching |
| 93 | + |
| 94 | +Work offline with cached data and smart TTL management. |
| 95 | + |
| 96 | +```bash |
| 97 | +# Force offline mode |
| 98 | +SOCKET_OFFLINE=1 socket scan view |
| 99 | + |
| 100 | +# Use cache with automatic refresh |
| 101 | +socket scan create # Caches results automatically |
| 102 | + |
| 103 | +# Clear cache |
| 104 | +socket cache clear |
| 105 | + |
| 106 | +# Warm cache for common operations |
| 107 | +socket cache warm |
| 108 | +``` |
| 109 | + |
| 110 | +Features: |
| 111 | +- TTL-based cache expiration |
| 112 | +- Stale-while-revalidate pattern |
| 113 | +- Namespace-based organization |
| 114 | +- Automatic fallback to cache on network errors |
| 115 | +- Cache statistics and management |
| 116 | + |
| 117 | +## 🎯 Usage Examples |
| 118 | + |
| 119 | +### Natural Language Workflow |
| 120 | + |
| 121 | +```bash |
| 122 | +# Ask what you want in plain English |
| 123 | +socket ai "check if my production dependencies are safe" |
| 124 | +# → Translates to: socket scan create . --prod |
| 125 | + |
| 126 | +# Get help understanding commands |
| 127 | +socket ai "what does scan reach do" |
| 128 | +# → Shows: socket scan reach --help |
| 129 | +``` |
| 130 | + |
| 131 | +### Interactive Security Fix |
| 132 | + |
| 133 | +```bash |
| 134 | +# Start interactive mode |
| 135 | +socket fix interactive |
| 136 | + |
| 137 | +# For each vulnerability: |
| 138 | +# [y] Apply fix |
| 139 | +# [n] Skip |
| 140 | +# [d] Show details |
| 141 | +# [a] Apply all safe fixes |
| 142 | +# [q] Quit |
| 143 | + |
| 144 | +# The tool shows: |
| 145 | +# - Severity indicators (🔴 critical, 🟠 high, 🟡 medium) |
| 146 | +# - Breaking change warnings |
| 147 | +# - Affected dependent packages |
| 148 | +# - Suggested version updates |
| 149 | +``` |
| 150 | + |
| 151 | +### Context-Aware Suggestions |
| 152 | + |
| 153 | +When you run commands, Socket CLI now: |
| 154 | +1. Detects your project type automatically |
| 155 | +2. Shows relevant suggestions |
| 156 | +3. Warns about configuration issues |
| 157 | +4. Provides framework-specific advice |
| 158 | + |
| 159 | +Example output: |
| 160 | +``` |
| 161 | +✓ Detected pnpm project using next (monorepo) |
| 162 | +
|
| 163 | +💡 Suggestions based on your project: |
| 164 | + • Use `socket pnpm --recursive` to scan all workspaces |
| 165 | + • Consider using --prod to exclude dev dependencies from production scans |
| 166 | +
|
| 167 | +📦 Detected 5 workspace(s): |
| 168 | + • packages/core |
| 169 | + • packages/ui |
| 170 | + • apps/web |
| 171 | + ... and 2 more |
| 172 | +``` |
| 173 | + |
| 174 | +## 🚀 Performance Improvements |
| 175 | + |
| 176 | +### Caching Strategy |
| 177 | + |
| 178 | +- **Hot paths cached**: Common API calls cached for 1 hour |
| 179 | +- **Offline fallback**: Use stale cache when network fails |
| 180 | +- **Smart invalidation**: Refresh on explicit user action |
| 181 | +- **Background warming**: Pre-fetch common data |
| 182 | + |
| 183 | +### Progress Tracking |
| 184 | + |
| 185 | +- **Non-blocking**: Progress updates don't slow operations |
| 186 | +- **Parallel tracking**: Monitor multiple operations simultaneously |
| 187 | +- **Smart throttling**: Update frequency adjusted to terminal capabilities |
| 188 | + |
| 189 | +## 🔧 Configuration |
| 190 | + |
| 191 | +### Environment Variables |
| 192 | + |
| 193 | +```bash |
| 194 | +# Enable offline mode |
| 195 | +export SOCKET_OFFLINE=1 |
| 196 | + |
| 197 | +# Show cache hits (verbose mode) |
| 198 | +export SOCKET_VERBOSE=1 |
| 199 | + |
| 200 | +# Debug natural language parsing |
| 201 | +export DEBUG=socket:ai |
| 202 | +``` |
| 203 | + |
| 204 | +### Cache Management |
| 205 | + |
| 206 | +```bash |
| 207 | +# View cache statistics |
| 208 | +socket cache stats |
| 209 | + |
| 210 | +# Clear specific namespace |
| 211 | +socket cache clear --namespace=scans |
| 212 | + |
| 213 | +# Clear everything |
| 214 | +socket cache clear --all |
| 215 | +``` |
| 216 | + |
| 217 | +## 🎨 Design Philosophy |
| 218 | + |
| 219 | +These features follow key principles: |
| 220 | + |
| 221 | +1. **Progressive Enhancement**: Features enhance but don't replace core functionality |
| 222 | +2. **Offline First**: Always work, even without internet |
| 223 | +3. **Context Aware**: Understand and adapt to the user's project |
| 224 | +4. **Human Friendly**: Natural language and clear visual feedback |
| 225 | +5. **Fast by Default**: Cache aggressively, compute minimally |
| 226 | + |
| 227 | +## 🔜 Future Enhancements |
| 228 | + |
| 229 | +Potential additions based on this foundation: |
| 230 | + |
| 231 | +1. **Command Chaining**: `socket scan && socket fix --auto && socket test` |
| 232 | +2. **Watch Mode**: `socket watch` - Auto-scan on file changes |
| 233 | +3. **Smart Diffing**: Show only what changed between scans |
| 234 | +4. **Team Profiles**: Shared configuration and policies |
| 235 | +5. **Integration Hooks**: Pre/post command scripts |
| 236 | + |
| 237 | +## 📝 Notes |
| 238 | + |
| 239 | +- The AI command interface uses pattern matching, not actual AI (for now) |
| 240 | +- Cache is stored in `~/.socket/_cacache` |
| 241 | +- Progress indicators automatically disable for non-TTY outputs |
| 242 | +- All features respect `--json` flag for automation |
0 commit comments