|
| 1 | +# 25. Cursor Plugin |
| 2 | + |
| 3 | +## Purpose |
| 4 | + |
| 5 | +Document the current contract and behavior of the Cursor plugin sourced from |
| 6 | +`plugins/cursor-codeclone/`. |
| 7 | + |
| 8 | +This chapter describes the plugin as a Cursor discovery and AI guidance layer |
| 9 | +over existing CodeClone MCP contracts. |
| 10 | + |
| 11 | +!!! note "Guidance layer only" |
| 12 | + The plugin contributes discovery metadata, a local MCP definition, skills, |
| 13 | + rules, hooks, and an agent definition. It does not add a second analyzer or |
| 14 | + Cursor-only finding semantics. |
| 15 | + |
| 16 | +## Position in the platform |
| 17 | + |
| 18 | +The Cursor plugin is: |
| 19 | + |
| 20 | +- sourced from `plugins/cursor-codeclone/` in this monorepo |
| 21 | +- backed by the Cursor Plugin manifest at `.cursor-plugin/plugin.json` |
| 22 | +- read-only with respect to repository state |
| 23 | +- a composition of local MCP server metadata, AI skills, rules, hooks, and an |
| 24 | + agent definition |
| 25 | +- a native Cursor setup surface, not a second extension model |
| 26 | + |
| 27 | +## Source of truth |
| 28 | + |
| 29 | +The plugin delegates analysis to the existing `codeclone-mcp` launcher and |
| 30 | +guides AI agent usage through bundled skills and rules. |
| 31 | + |
| 32 | +New canonical MCP surfaces flow through from the resolved local server version. |
| 33 | +That includes current-run metric families such as `Coverage Join` and the |
| 34 | +optional `coverage` help topic when that server supports them. |
| 35 | + |
| 36 | +It must not: |
| 37 | + |
| 38 | +- run a second analysis engine |
| 39 | +- redefine findings, health, or gates |
| 40 | +- mutate source files, baselines, cache, or report artifacts |
| 41 | +- drift away from canonical MCP semantics |
| 42 | + |
| 43 | +## Current surface |
| 44 | + |
| 45 | +The plugin currently provides: |
| 46 | + |
| 47 | +- `.cursor-plugin/plugin.json` — plugin manifest |
| 48 | +- `mcp.json` — local stdio MCP server definition |
| 49 | +- five bundled skills: |
| 50 | + - `codeclone-production-triage` — fast production-focused first pass |
| 51 | + - `codeclone-hotspots` — quick health snapshot |
| 52 | + - `codeclone-blast-radius` — standalone structural impact inspection |
| 53 | + - `codeclone-review` — full structural review session |
| 54 | + - `codeclone-change-control` — intent-first change workflow |
| 55 | +- one agent: |
| 56 | + - `structural-reviewer` — deterministic code reviewer backed by MCP tools |
| 57 | +- two rules: |
| 58 | + - `codeclone-workflow.mdc` — MCP discipline (always active) |
| 59 | + - `codeclone-python.mdc` — Python file context (glob-triggered) |
| 60 | +- two hooks: |
| 61 | + - `afterFileEdit` — post-edit re-analysis reminder |
| 62 | + - `stop` — session-end intent cleanup check |
| 63 | + |
| 64 | +## Runtime model |
| 65 | + |
| 66 | +The plugin surface is additive: |
| 67 | + |
| 68 | +- `mcp.json` contributes a local stdio MCP server definition |
| 69 | +- the skills contribute workflow guidance and starter prompts |
| 70 | +- the rules enforce MCP-first discipline and Python-aware context |
| 71 | +- the hooks provide automated reminders for re-analysis and intent hygiene |
| 72 | +- the agent provides a structured review protocol backed by MCP tools |
| 73 | +- Cursor remains free to use direct MCP configuration alongside or instead of |
| 74 | + the plugin |
| 75 | + |
| 76 | +The plugin does not rewrite user config or install CodeClone automatically. |
| 77 | + |
| 78 | +## Skill contract |
| 79 | + |
| 80 | +Each skill follows these invariants: |
| 81 | + |
| 82 | +- **MCP tools only** — no fallback to CLI or local report files |
| 83 | +- **Absolute roots** — analysis tools receive absolute repository paths |
| 84 | +- **Source of truth** — CodeClone findings are reported as-is, not reinterpreted |
| 85 | +- **Conservative first pass** — default thresholds unless the user explicitly |
| 86 | + asks for a deeper review |
| 87 | +- **Scope discipline** — change control skills enforce declare/check/verify/clear |
| 88 | + |
| 89 | +Skills are invocable via `/skill-name` in Cursor chat. Each skill's `SKILL.md` |
| 90 | +contains the full workflow, rules, and non-goals. |
| 91 | + |
| 92 | +## Hook contract |
| 93 | + |
| 94 | +Hooks follow these invariants: |
| 95 | + |
| 96 | +- **Non-blocking** — hooks return quickly (5-second timeout) and do not block |
| 97 | + agent execution |
| 98 | +- **Advisory only** — hooks return `followup_message` suggestions, not |
| 99 | + mandatory actions |
| 100 | +- **Deterministic** — hooks use simple pattern matching, not heuristic analysis |
| 101 | +- **Fail-open** — hook failures do not prevent the agent from continuing |
| 102 | + |
| 103 | +## Agent contract |
| 104 | + |
| 105 | +The structural reviewer agent: |
| 106 | + |
| 107 | +- uses CodeClone MCP tools exclusively for evidence |
| 108 | +- does not modify files or declare change intent |
| 109 | +- does not suppress or dismiss findings |
| 110 | +- does not treat report-only signals as CI failures or vulnerability claims |
| 111 | +- reports with file paths, finding IDs, and severities from CodeClone |
| 112 | + |
| 113 | +## Design rules |
| 114 | + |
| 115 | +- **Cursor-native packaging**: keep source under `plugins/cursor-codeclone/` |
| 116 | + and use `.cursor-plugin/plugin.json` as the manifest. |
| 117 | +- **Canonical MCP first**: all analysis flows through `codeclone-mcp`. |
| 118 | +- **Skill guidance, not analysis logic**: skills teach CodeClone workflows but |
| 119 | + do not create new findings. |
| 120 | +- **Rule discipline**: rules enforce MCP-first usage and prevent fallback to |
| 121 | + CLI or manual reinterpretation. |
| 122 | +- **Hook safety**: hooks are advisory, non-blocking, and fail-open. |
| 123 | +- **Agent honesty**: the structural reviewer reports deterministic evidence, not |
| 124 | + opinions. |
| 125 | +- **No hidden installation side effects**: the plugin does not patch Cursor |
| 126 | + settings or install binaries. |
| 127 | +- **Launcher honesty**: the plugin assumes `codeclone-mcp` is already |
| 128 | + installable in the current workspace or reachable on `PATH`. |
| 129 | + |
| 130 | +## Relationship to other interfaces |
| 131 | + |
| 132 | +- CLI remains the scripting and CI surface. |
| 133 | +- MCP remains the cross-client integration contract. |
| 134 | +- VS Code extension remains the native IDE view surface. |
| 135 | +- Codex plugin remains the Codex-native discovery surface. |
| 136 | +- The Cursor plugin is the native Cursor AI discovery and governance layer for |
| 137 | + CodeClone. |
| 138 | + |
| 139 | +## Non-guarantees |
| 140 | + |
| 141 | +- Cursor plugin UI presentation and skill discovery may evolve independently |
| 142 | + of the plugin manifest content. |
| 143 | +- Users who already configured `codeclone-mcp` manually may prefer the direct |
| 144 | + MCP path over the bundled plugin MCP definition. |
| 145 | +- Hook behavior may be refined as Cursor's hook API evolves. |
0 commit comments