Skip to content

feat: Add Terminal CLI Agent, IPC socket server, 47 subcommands, SearXNG search, and full docs - #163

Open
shahrryyar wants to merge 3 commits into
PawanOsman:mainfrom
shahrryyar:feat/cli-agent-ipc-and-docs
Open

feat: Add Terminal CLI Agent, IPC socket server, 47 subcommands, SearXNG search, and full docs#163
shahrryyar wants to merge 3 commits into
PawanOsman:mainfrom
shahrryyar:feat/cli-agent-ipc-and-docs

Conversation

@shahrryyar

@shahrryyar shahrryyar commented Aug 1, 2026

Copy link
Copy Markdown

⚠️ Work in Progress / Needs Further Development

Important

Status: This PR contains a major suite of additions and enhancements. It needs further development and ongoing updates to CHANGELOG.md as testing and refinement continue.

  • OpenRouter API Testing: Most features have been actively tested using the OpenRouter API, and everything works smoothly with no issues found during testing.
  • IPC Socket Bridge Testing: The bi-directional IPC socket bridge connecting the VS Code Extension Host to the terminal CLI has NOT been fully tested yet and requires further validation across different OS platforms.

📌 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)

  • Interactive REPL session (oc) matching terminal-first coding agent workflows (similar to Claude Code).
  • Support for single-prompt runs, custom mode (-m), model selection (--model), auto-approval (-y), and working directory flags (--cwd).
  • Built-in shell completion script generator (oc completion zsh|bash|fish).

2. 🛠️ 47 Specialized Subcommands

Automated engineering workflows implemented in src/cli/:

  • Code Quality & Refactoring: oc review, oc refactor, oc types, oc clean, oc lint-fix, oc codemod
  • Testing & Security: oc test, oc test-watch, oc flaky, oc trace, oc security, oc audit-secrets, oc license
  • Architecture & Diagrams: oc diagram, oc explain, oc knowledge, oc graph
  • DevOps & Infrastructure: oc container, oc shrink-docker, oc devcontainer, oc deploy, oc rollback, oc ci-monitor, oc benchmark-ci
  • Database & API: oc db, oc migrate, oc api, oc map-api, oc graphql, oc mock
  • Frontend & UI: oc scaffold, oc storybook, oc accessibility, oc i18n, oc translation-sync
  • Performance & Build: oc bundle, oc cache, oc bench, oc loadtest
  • Workflows & Utilities: oc 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

  • Implemented Unix socket (/tmp/opencursor-ipc.sock) and Windows Named Pipe (\\.\pipe\opencursor-ipc) IPC bridge connecting the CLI to the VS Code Extension Host.
  • Socket permissions set to 0o600 (owner-only) on Unix for security.
  • Note: Not fully tested yet; requires verification in live extension environment.

4. ⚙️ Standalone Host & Headless vscode Shim

  • Created src/vscodeShim.ts to provide safe fallbacks for vscode module namespace APIs when running outside VS Code.
  • Bundled dist/cli.js via esbuild.js with dynamic vscode module resolution.
  • Added OPEN_CURSOR_WORKSPACE_ROOT environment variable support for headless execution.

5. 🔎 SearXNG Search Engine Integration

  • SearXNG JSON API support (searxng_url in ~/.ocursor/config.json) with automatic fallback to DuckDuckGo HTML/Lite scraping.

6. 🎯 Workspace Rules & Skills Support

  • Support for workspace rules (.cursor/rules/*.md) and agent skills (.cursor/skills/*.md).

7. 📚 Complete Documentation & Changelog Update

  • Updated README.md with complete CLI references, 47 subcommand table, local AI & SearXNG setup, IPC architecture diagram, and workspace rules/skills usage.
  • Added release notes entry [0.1.1] in CHANGELOG.md.

8. 🔒 Security Fixes (Copilot Review)

All issues from the automated Copilot security review have been addressed:

  • secretAudit: Reset global regex lastIndex before test() to prevent missed matches
  • socketServer: Set IPC socket permissions to 0o600 on Unix (owner-only access)
  • tuiDiffViewer: Replaced execSync with execFileSync to prevent shell injection
  • undoSnapshotManager: Added interactive y/N confirmation before destructive git operations
  • InteractiveRepl: Fixed askUser to read actual stdin input; fixed approve to prompt user
  • loop: Restored approval gate forwarding to subagents (was bypassed with undefined)
  • watchDaemon: Added platform check for fs.watch({ recursive }) unsupported on Linux
  • README: Fixed SearXNG config path to match implementation (~/.ocursor/config.json)

Verification Summary

  • OpenRouter API: Tested most features with OpenRouter API; no issues found.
  • Build: pnpm run compile (check-types, lint, esbuild) completes cleanly with exit code 0.

…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
Copilot AI review requested due to automatic review settings August 1, 2026 15:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Comment thread src/cli/secretAudit.ts
Comment on lines +31 to +35
SECRET_PATTERNS.forEach((p) => {
if (p.regex.test(line)) {
leaks.push({ file: path.relative(cwd, full), line: idx + 1, type: p.name });
}
});
Comment on lines +399 to +403
for (let idx = 0; idx < questions.length; idx++) {
const q = questions[idx];
answers[String(idx)] = [q.question];
}
return answers;
Comment on lines +50 to +52
this.server.listen(this.socketPath, () => {
getLog().appendLine(`[IPC] OpenCursor socket server listening on ${this.socketPath}`);
});
Comment thread README.md Outdated
- **🦙 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`:
Comment thread src/agent/loop.ts
Comment on lines 301 to 305
enableTerminalSuggestions,
enableWorkspaceContext,
approve,
approve: undefined, // Subagents execute autonomously without parent UI prompts
isSubagent: true,
// Nested Task disabled; child still needs hooks for compaction etc.
Comment on lines +16 to +19
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`);
Comment thread src/cli/watchDaemon.ts Outdated

let debounceTimer: NodeJS.Timeout | undefined;

fs.watch(cwd, { recursive: true }, (eventType, filename) => {
Comment thread src/cli/tuiDiffViewer.ts Outdated
Comment on lines +1 to +10
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants