feat: Add Terminal CLI Agent, IPC socket server, 47 subcommands, SearXNG search, and full docs - #163
Conversation
…XNG search, and complete documentation - Add standalone Terminal CLI Agent (oc / open-cursor) with interactive REPL and single-prompt modes - Add 47 specialized CLI subcommands for automated code reviews, scaffolding, diagrams, security audits, database ORM migrations, and docker optimization - Add IPC Socket Server bridge for bidirectional communication between CLI and VS Code extension host - Add headless VS Code shim (vscodeShim.ts) for standalone engine execution outside VS Code - Add SearXNG search engine integration in WebSearch tool with DuckDuckGo fallback - Decouple vscode module dependencies in core agent runtime and workspace context - Update README.md and CHANGELOG.md with comprehensive documentation for all new features
There was a problem hiding this comment.
🟡 Not ready to approve
There are confirmed security/operational issues (approval bypass paths, unsafe IPC socket permissions, and several CLI commands that can cause data loss or allow injection) that should be addressed before approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
This PR adds a standalone Terminal CLI (“oc” / “open-cursor”) that can either run headlessly (via a VS Code shim) or bridge into the running VS Code extension host over an IPC socket, and updates agent tooling (retry behavior, web search) plus documentation to match the new distribution.
Changes:
- Introduces a bundled Node CLI entrypoint with many subcommands, plus a TUI REPL and standalone host runner.
- Adds an IPC protocol + socket server/client bridge so the CLI can submit prompts to the extension host.
- Enhances WebSearch with SearXNG JSON API support and updates docs/changelog/build packaging for the CLI.
File summaries
| File | Description |
|---|---|
| src/vscodeShim.ts | Adds a minimal vscode namespace shim for headless CLI execution |
| src/ui/sidebarProvider.ts | Exposes a method to post a prompt into the active session (IPC hook) |
| src/logging.ts | Makes logging work both in VS Code and standalone CLI contexts |
| src/extension.ts | Starts/stops the IPC socket server alongside extension activation |
| src/context/workspaceUtils.ts | Adds headless workspace root support and removes hard vscode dependency |
| src/context/workspaceContext.ts | Removes hard vscode dependency for open files/selection extraction |
| src/cli/watchDaemon.ts | Adds continuous watch + auto-check/fix workflow |
| src/cli/voicePrompt.ts | Adds “voice” command wrapper for hands-free prompting |
| src/cli/undoSnapshotManager.ts | Adds “undo” command to revert workspace state via git |
| src/cli/typeInferrer.ts | Adds “types” command wrapper for type tightening |
| src/cli/tuiDiffViewer.ts | Adds terminal diff viewer command |
| src/cli/tui/ToolCard.ts | Adds TUI rendering for tool execution status |
| src/cli/tui/SubagentDashboard.ts | Adds TUI rendering for multi-subagent dashboard |
| src/cli/tui/StatusBar.ts | Adds TUI status bar rendering |
| src/cli/tui/InteractiveRepl.ts | Adds raw TTY REPL implementation with slash commands |
| src/cli/tui/Banner.ts | Adds REPL banner rendering |
| src/cli/tui/ApprovalPrompt.ts | Adds approval prompt rendering for TUI |
| src/cli/tui/App.ts | Adds a basic TUI session event renderer |
| src/cli/translationSync.ts | Adds “translation-sync” command wrapper |
| src/cli/testWatchDaemon.ts | Adds “test-watch” command wrapper |
| src/cli/testGenerator.ts | Adds “test” command wrapper |
| src/cli/telemetryInspector.ts | Adds local telemetry inspection command |
| src/cli/swarmOrchestrator.ts | Adds “swarm” multi-agent orchestration wrapper |
| src/cli/storybookGenerator.ts | Adds “storybook” command wrapper |
| src/cli/standaloneHost.ts | Adds standalone runner + interactive REPL entrypoints |
| src/cli/shellHooks.ts | Adds shell completion generator + “fix last command” wrapper |
| src/cli/securityScanner.ts | Adds “security” scan command wrapper |
| src/cli/secretAudit.ts | Adds local secret scanning command implementation |
| src/cli/schemaValidator.ts | Adds “validate” command wrapper |
| src/cli/scaffoldGenerator.ts | Adds “scaffold” command wrapper |
| src/cli/ruleStudio.ts | Adds commands to generate .cursor/rules and .cursor/skills artifacts |
| src/cli/rollbackPlan.ts | Adds “rollback” planning command wrapper |
| src/cli/refactorMigrator.ts | Adds “refactor” command wrapper |
| src/cli/promptCrafter.ts | Adds “craft-prompt” command wrapper |
| src/cli/prGenerator.ts | Adds “pr” command wrapper (generate PR description) |
| src/cli/pluginEcosystem.ts | Adds “plugin” discovery/listing command |
| src/cli/monorepoManager.ts | Adds “monorepo” command wrapper |
| src/cli/modelsManager.ts | Adds local model discovery via gguf + Ollama tags |
| src/cli/mockServer.ts | Adds “mock” command wrapper |
| src/cli/migrateOrm.ts | Adds “migrate” command wrapper |
| src/cli/logAnalyzer.ts | Adds “logs” command wrapper |
| src/cli/loadTestGen.ts | Adds “loadtest” command wrapper |
| src/cli/lintFixer.ts | Adds “lint-fix” command wrapper |
| src/cli/licenseChecker.ts | Adds “license” audit command wrapper |
| src/cli/knowledgeBase.ts | Adds knowledge-base build/query wrapper |
| src/cli/ipcClient.ts | Adds IPC client for connecting CLI to extension host |
| src/cli/i18nLocalizer.ts | Adds “i18n” localization command wrapper |
| src/cli/graphqlHelper.ts | Adds “graphql” command wrapper |
| src/cli/gitSuite.ts | Adds git workflow helper commands |
| src/cli/flakyTestFixer.ts | Adds flaky test detection wrapper |
| src/cli/featureFlag.ts | Adds feature-flag integration wrapper |
| src/cli/explainCode.ts | Adds “explain” command wrapper |
| src/cli/errorTracer.ts | Adds “trace” command wrapper |
| src/cli/envSync.ts | Adds “env” command wrapper |
| src/cli/docsGenerator.ts | Adds “docs” command wrapper |
| src/cli/dockerOptimizer.ts | Adds “shrink-docker” wrapper |
| src/cli/diagrammer.ts | Adds “diagram” wrapper |
| src/cli/devcontainerGenerator.ts | Adds devcontainer generator command |
| src/cli/deployAssist.ts | Adds deployment runbook wrapper |
| src/cli/dependencyAuditor.ts | Adds dependency audit wrapper |
| src/cli/deadCodePruner.ts | Adds dead-code detection wrapper |
| src/cli/dbAssistant.ts | Adds database assistant wrapper |
| src/cli/contextDump.ts | Adds context dump generator (workspace metadata) |
| src/cli/containerSynthesizer.ts | Adds containerization artifacts wrapper |
| src/cli/commitHooks.ts | Adds git hooks installer |
| src/cli/codeReview.ts | Adds “review” wrapper |
| src/cli/codemodEngine.ts | Adds “codemod” wrapper |
| src/cli/codeGraphIndex.ts | Adds lightweight symbol indexer |
| src/cli/ciMonitor.ts | Adds CI monitoring wrapper |
| src/cli/cicdGenerator.ts | Adds CI/CD workflow generator wrapper |
| src/cli/changelogGenerator.ts | Adds changelog generator wrapper |
| src/cli/cacheStrategy.ts | Adds caching strategy wrapper |
| src/cli/bundleOptimizer.ts | Adds bundle size optimization wrapper |
| src/cli/browserRunner.ts | Adds basic URL fetch + analysis wrapper |
| src/cli/bin.ts | Adds the CLI entrypoint and subcommand router |
| src/cli/benchProfiler.ts | Adds perf profiling wrapper |
| src/cli/apiTester.ts | Adds API request tester implementation |
| src/cli/apiMapper.ts | Adds API route mapping wrapper |
| src/cli/accessibilityAuditor.ts | Adds accessibility audit wrapper |
| src/bridge/socketServer.ts | Adds IPC socket server implementation |
| src/bridge/protocol.ts | Defines IPC message protocol + serializer/parser |
| src/agent/tools/web.ts | Adds SearXNG-backed WebSearch with DDG fallback |
| src/agent/tools/schemas.ts | Updates tool schema docs to reflect OpenCursor naming |
| src/agent/tools/files.ts | Removes hard vscode dependency for diagnostics in CLI mode |
| src/agent/provider.ts | Improves retry behavior (429 reset parsing, higher max attempts) |
| src/agent/prompt.ts | Updates base system prompt branding to OpenCursor |
| src/agent/loopTypes.ts | Adds onRetry/maxRetries options for retry surfacing/tuning |
| src/agent/loop.ts | Disables approval prompts for subagent runs |
| README.md | Adds CLI docs, IPC architecture, SearXNG docs, and installation steps |
| package.json | Adds bin entries for oc and open-cursor |
| esbuild.js | Adds CLI bundling + vscode shim resolve plugin |
| CHANGELOG.md | Adds 0.1.1 release notes for CLI/IPC/SearXNG features |
| .cursor/skills/django-api/SKILL.md | Adds an example skill scaffold |
| .cursor/rules/strict-typescript-typing.md | Adds an example rule scaffold |
Review details
Suppressed comments (1)
src/cli/tui/InteractiveRepl.ts:413
- When autoApprove is false, approve() still prints the approval prompt but then unconditionally returns true, effectively bypassing the approval gate for all tool calls.
- Files reviewed: 94/94 changed files
- Comments generated: 8
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
| SECRET_PATTERNS.forEach((p) => { | ||
| if (p.regex.test(line)) { | ||
| leaks.push({ file: path.relative(cwd, full), line: idx + 1, type: p.name }); | ||
| } | ||
| }); |
| for (let idx = 0; idx < questions.length; idx++) { | ||
| const q = questions[idx]; | ||
| answers[String(idx)] = [q.question]; | ||
| } | ||
| return answers; |
| this.server.listen(this.socketPath, () => { | ||
| getLog().appendLine(`[IPC] OpenCursor socket server listening on ${this.socketPath}`); | ||
| }); |
| - **🦙 llama.cpp built in** — search Hugging Face for GGUF models, pick a quantization, download, and OpenCursor spawns and manages `llama-server` for you. Full launch control: context size, GPU layers, flash attention, KV cache types, speculative decoding, vision (`--mmproj`), and more. | ||
| - **🐋 Ollama** — pull, manage, and chat with models from the Ollama library, zero config. | ||
| - **🧠 Local embeddings** — semantic codebase search powered by an on-device ONNX MiniLM model. No embedding API, no key, no code leaving your machine. | ||
| - **🔎 SearXNG Web Search** — search the web privately. Configure your self-hosted SearXNG endpoint in `~/.config/opencursor/config.json`: |
| enableTerminalSuggestions, | ||
| enableWorkspaceContext, | ||
| approve, | ||
| approve: undefined, // Subagents execute autonomously without parent UI prompts | ||
| isSubagent: true, | ||
| // Nested Task disabled; child still needs hooks for compaction etc. |
| console.log(`\x1b[33mDiscarding unstaged changes across modified files...\x1b[0m`); | ||
| execSync("git checkout -- .", { cwd }); | ||
| execSync("git clean -fd", { cwd }); | ||
| console.log(`\x1b[32m✔ Workspace successfully reverted to last committed state!\x1b[0m\n`); |
|
|
||
| let debounceTimer: NodeJS.Timeout | undefined; | ||
|
|
||
| fs.watch(cwd, { recursive: true }, (eventType, filename) => { |
| import * as fs from "fs"; | ||
| import * as path from "path"; | ||
| import { execSync } from "child_process"; | ||
|
|
||
| export async function handleDiffViewerCommand(targetFile?: string) { | ||
| const cwd = process.env.OPEN_CURSOR_WORKSPACE_ROOT || process.cwd(); | ||
| console.log(`\n\x1b[1m\x1b[36m[oc diff] Interactive Terminal Diff Viewer...\x1b[0m\n`); | ||
|
|
||
| try { | ||
| const gitDiff = execSync(`git diff ${targetFile ? `"${targetFile}"` : ""}`, { cwd, encoding: "utf8" }); |
- secretAudit: Reset global regex lastIndex before test() to prevent missed matches - socketServer: Set IPC socket permissions to 0o600 on Unix (owner-only) - tuiDiffViewer: Use execFileSync instead of execSync to prevent shell injection - undoSnapshotManager: Add interactive y/N confirmation before destructive git operations - InteractiveRepl: Fix askUser to read actual user input instead of echoing questions - InteractiveRepl: Fix approve to prompt user when autoApprove is disabled - loop: Restore approval gate forwarding to subagents - watchDaemon: Handle fs.watch recursive unsupported on Linux - README: Fix SearXNG config path to match implementation (~/.ocursor/config.json)
- InteractiveRepl: Add readLine helper, fix askUser to read actual stdin input, fix approve to prompt y/N - loop: Restore subagent approval gate forwarding (re-add isSubagent to destructuring) - watchDaemon: Handle fs.watch recursive unsupported on Linux with platform check - README: Fix SearXNG config path to ~/.ocursor/config.json matching implementation
Important
Status: This PR contains a major suite of additions and enhancements. It needs further development and ongoing updates to
CHANGELOG.mdas testing and refinement continue.📌 Related Issue
This PR is an implementation example for #161 (not terminal Native CLI) — adding a full standalone terminal-native CLI agent (
oc/open-cursor) that works independently from VS Code, along with 47 specialized subcommands, an IPC bridge to the extension host, and private SearXNG search support.🚀 Overview of Everything Added & Updated
This PR introduces the Terminal CLI Agent (
oc/open-cursor), a bi-directional IPC Socket Server bridge, 47 specialized CLI subcommands, private SearXNG web search support, a headless VS Code shim, workspace rules/skills support, and comprehensive documentation.1. 💻 Terminal CLI Agent (
oc/open-cursor)oc) matching terminal-first coding agent workflows (similar to Claude Code).-m), model selection (--model), auto-approval (-y), and working directory flags (--cwd).oc completion zsh|bash|fish).2. 🛠️ 47 Specialized Subcommands
Automated engineering workflows implemented in
src/cli/:oc review,oc refactor,oc types,oc clean,oc lint-fix,oc codemodoc test,oc test-watch,oc flaky,oc trace,oc security,oc audit-secrets,oc licenseoc diagram,oc explain,oc knowledge,oc graphoc container,oc shrink-docker,oc devcontainer,oc deploy,oc rollback,oc ci-monitor,oc benchmark-cioc db,oc migrate,oc api,oc map-api,oc graphql,oc mockoc scaffold,oc storybook,oc accessibility,oc i18n,oc translation-syncoc bundle,oc cache,oc bench,oc loadtestoc fix(auto-diagnose last error),oc git,oc pr,oc hooks,oc monorepo,oc swarm,oc voice,oc models,oc context,oc craft-prompt,oc feature-flag,oc logs,oc validate,oc telemetry,oc watch,oc undo,oc diff,oc browser,oc add-rule,oc add-skill.3. 🔌 Bi-Directional IPC Socket Bridge
/tmp/opencursor-ipc.sock) and Windows Named Pipe (\\.\pipe\opencursor-ipc) IPC bridge connecting the CLI to the VS Code Extension Host.0o600(owner-only) on Unix for security.4. ⚙️ Standalone Host & Headless
vscodeShimsrc/vscodeShim.tsto provide safe fallbacks forvscodemodule namespace APIs when running outside VS Code.dist/cli.jsviaesbuild.jswith dynamicvscodemodule resolution.OPEN_CURSOR_WORKSPACE_ROOTenvironment variable support for headless execution.5. 🔎 SearXNG Search Engine Integration
searxng_urlin~/.ocursor/config.json) with automatic fallback to DuckDuckGo HTML/Lite scraping.6. 🎯 Workspace Rules & Skills Support
.cursor/rules/*.md) and agent skills (.cursor/skills/*.md).7. 📚 Complete Documentation & Changelog Update
README.mdwith complete CLI references, 47 subcommand table, local AI & SearXNG setup, IPC architecture diagram, and workspace rules/skills usage.[0.1.1]inCHANGELOG.md.8. 🔒 Security Fixes (Copilot Review)
All issues from the automated Copilot security review have been addressed:
lastIndexbeforetest()to prevent missed matches0o600on Unix (owner-only access)execSyncwithexecFileSyncto prevent shell injectiony/Nconfirmation before destructive git operationsaskUserto read actual stdin input; fixedapproveto prompt userundefined)fs.watch({ recursive })unsupported on Linux~/.ocursor/config.json)Verification Summary
pnpm run compile(check-types,lint,esbuild) completes cleanly with exit code 0.