Add OneCLI gateway plugin for Cursor#7
Open
fireharp wants to merge 5 commits into
Open
Conversation
Introduces plugins/cursor with sessionStart env injection, preToolUse Shell rewrites, sessionEnd cleanup, skills, and rules. Includes workflow and live E2E tests against OneCLI Cloud and the GitHub gateway path. Co-authored-by: Cursor <cursoragent@cursor.com>
Fixes Customize → Plugins → + Add by shipping .cursor-plugin/marketplace.json, plus INSTALL.md, project-hooks fallback, and gateway verification script. Co-authored-by: Cursor <cursoragent@cursor.com>
Documents Customize → Plugins install flow, hook verification, and dashboard Activity proof for reviewers merging Cursor support. Co-authored-by: Cursor <cursoragent@cursor.com>
Remove committed PNGs from plugins/cursor/docs/screenshots and point install docs at the PR for visual verification screenshots. Co-authored-by: Cursor <cursoragent@cursor.com>
Adds docs/hook-activation.md explaining why Codex/Cursor share a conservative command allowlist, how Claude differs via BASH_ENV, and future options toward session-only activation without preToolUse rewrites. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds first-class Cursor support to the OneCLI plugin monorepo, alongside existing Codex and Claude plugins.
Agents can call external APIs (GitHub, AWS, etc.) through the OneCLI HTTPS gateway without putting credentials, proxy URLs, or API keys in shell history, environment variables, or model context. Credentials are injected at the proxy boundary.
What's included
plugins/cursor/src/cursor/plugins/cursor/hooks/*.mjsandbin/plugins/cursor/.cursor-plugin/marketplace.jsonplugins/cursor/docs/CURSOR_SETUP.mdplugins/cursor/scripts/install-project-hooks.sh.cursor/hooks.jsonwhen plugin hooks don't registertests/test_workflows.pytests/test_cursor_live_e2e.pytests/verify_cursor_agent_gateway.pyrate_limitproof without manual proxy setupHow it works
Cursor hooks use a hybrid activation model:
sessionStart~/.onecli/env.sh, fetches OneCLI config when API key exists, returns{ env, additional_context }preToolUse(Shell)ONECLI_CURSOR_AUTOSOURCED=1; . "$HOME/.onecli/env.sh" && <original>sessionEndSkills & rules (ported from Codex):
onecli-setup,onecli-status,onecli-gateway,onecli-providers,integration-architect,onecli-cleanup, plusrules/onecli-gateway.mdc.Failure mode: No API key or unreachable gateway → command still runs without proxy; reason on stderr.
Why
preToolUse? (brief)sessionStart+BASH_ENV— every Bash auto-sources env; nopreToolUsepreToolUserewriteCursor's
preToolUselogic is identical to Codex (src/codex/pre-tool-use.mts/src/cursor/pre-tool-use.mts). The allowlist (curl,gh, networkgit/aws/terraform/package-manager subcommands, …) exists because sourcing the loader fetches OneCLI Cloud per command — we skip obviously-local commands (git status,terraform fmt, …).Today:
sessionStartreturns sessionenv, but Cursor/subagent shells don't always inherit it —preToolUseis the reliable path (verified: subagentrate_limit→11400withHTTPS_PROXYunset).Deprecation path: Once Cursor reliably applies
sessionStartenv to all shells/subagents, droppreToolUseand use session-only activation (Claude-like). Full rationale, tradeoffs, and future options (shared module, inverse blocklist, cached loader):docs/hook-activation.md.Install in Cursor
Build
Add plugin (local repo)
plugins/cursor(contains.cursor-plugin/marketplace.json)Text guide:
plugins/cursor/docs/CURSOR_SETUP.mdScreenshots (verified on Cursor 3.9.x)
Step 1 — Customize → + Add → From Local Repo
Step 2 — OneCLI Gateway in local marketplace
Step 3 — Plugin installed (✓ Added)
Step 4 — Skills, rules, and hooks loaded
Step 5 — Dashboard Activity proof
Fallback (known Cursor hook bug)
If plugin hooks don't appear in Settings → Hooks:
Verification
Automated
Gateway routing proof
GET https://api.github.com/rate_limit→resources.core.limit:HTTPS_PROXYstays unset in the shell; routing happens viapreToolUsecommand rewrite.Live subagent test (manual, recommended)
In a new Agent session after install, ask:
Verified result: subagent ran plain
curl(no manual proxy, nosource env.sh):GET /repos/onecli/onecli-plugin/pulls/7→ PR open,feat/cursor-plugin, mergeableGET /rate_limit→core.limit = 11400HTTPS_PROXY=<unset>Dashboard Activity
OneCLI project Activity tab shows proxied requests (
GET api.github.com/rate_limit,/repos/...) with HTTP 200. Requests may be labeled with the project's default agent name (e.g. "Codex") — expected, not a plugin bug.Architecture notes
updated_input), not CodexhookSpecificOutput.sessionStartadditional_contextmay be unreliable (Cursor forum); bundled rules compensate.src/cursor/, runnpm run build— same pipeline as Codex/Claude.docs/hook-activation.mdTest plan
npm run buildnpm run test— manifests, hook wiring, cursor session flow, preToolUse rewritenpm run test:live-cursor— real API key, proxied GitHubzen+rate_limit, sessionEnd cleanupcurlverification —core.limit = 11400, dashboard Activity rowsCommits
225ed26— Add OneCLI gateway plugin for Cursor (hooks, skills, rules, tests)6f01a2c— Marketplace manifest, INSTALL.md, project-hooks fallback, verify script2d7b8b5— Cursor setup guide (text)aba6dde— Remove committed screenshots; images attached to this PR only34e1aa1— Document hook activation model and preToolUse deprecation path