Documentation
¶
Overview ¶
Package cursor is the brainjar Platform adapter for the Cursor IDE (cursor.com). Imported for side effects from internal/cli to register itself in the parent platform registry.
Runtime verified against Cursor 3.1 / cursor.com/docs (Apr 2026). Sync writes a dedicated .cursor/rules/brainjar.mdc file that brainjar owns end-to-end (YAML frontmatter + shared markers + composed prompt). Hooks use Cursor's camelCase schema introduced in Cursor 1.7 (Oct 2025). MCP registration uses the Claude-Desktop- style schema Cursor adopted for its .cursor/mcp.json.
Index ¶
- type Platform
- func (c *Platform) Capabilities() platform.Capabilities
- func (c *Platform) Catalog() platform.ModelCatalog
- func (c *Platform) EmitSkills(_ context.Context, _ string, _ []platform.SkillEmit) (platform.SkillEmitResult, error)
- func (c *Platform) HooksStatus(_ context.Context, scope platform.HookScope, projectRoot string) (platform.HookStatus, error)
- func (c *Platform) InstallHooks(_ context.Context, scope platform.HookScope, projectRoot string) error
- func (c *Platform) InstallMCP(_ context.Context, scope platform.HookScope, projectRoot, home string) error
- func (c *Platform) MCPStatus(_ context.Context, scope platform.HookScope, projectRoot, home string) (platform.MCPStatus, error)
- func (c *Platform) MapModelPrefs(prefs *models.ModelPrefs) map[string]any
- func (c *Platform) ModelArgs(*models.ModelPrefs) []string
- func (c *Platform) Name() string
- func (c *Platform) RemoveHooks(_ context.Context, scope platform.HookScope, projectRoot string) error
- func (c *Platform) RemoveMCP(_ context.Context, scope platform.HookScope, projectRoot string) error
- func (c *Platform) SkillsStatus(_ context.Context, _ string) (platform.SkillsStatus, error)
- func (c *Platform) Spawn(_ context.Context, _ string, _ []string) (*exec.Cmd, error)
- func (c *Platform) Sync(_ context.Context, prompt string, projectRoot string) error
- func (c *Platform) SyncRemove(_ context.Context, projectRoot string) error
- func (c *Platform) SyncUser(_ context.Context, _ string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Platform ¶
type Platform struct{}
Platform adapts brainjar to the Cursor IDE.
func (*Platform) Capabilities ¶
func (c *Platform) Capabilities() platform.Capabilities
Capabilities implements Platform. Cursor supports sync, hooks, and MCP. User Rules are UI-only (no documented filesystem path) so Sync at user scope is unsupported even though hooks and MCP work at user scope. Local scope is Claude-only. Spawn is unsupported because Cursor's CLI has no per-invocation system-prompt injection surface; it consumes its rules from the filesystem only.
func (*Platform) Catalog ¶ added in v0.6.0
func (c *Platform) Catalog() platform.ModelCatalog
Catalog satisfies platform.Platform.
func (*Platform) EmitSkills ¶ added in v0.6.0
func (c *Platform) EmitSkills(_ context.Context, _ string, _ []platform.SkillEmit) (platform.SkillEmitResult, error)
EmitSkills returns ErrUnsupportedByPlatform. Cursor maps skills onto its rules-as-skills surface (`.cursor/rules/<slug>.mdc`) but the semantic — context-match vs description-match — is different enough that shipping a half-truth here is worse than shipping nothing. Deferred to the Company Brain milestone.
func (*Platform) HooksStatus ¶
func (c *Platform) HooksStatus(_ context.Context, scope platform.HookScope, projectRoot string) (platform.HookStatus, error)
HooksStatus reports whether brainjar's entry is present and whether the installed command matches what InstallHooks would write now.
func (*Platform) InstallHooks ¶
func (c *Platform) InstallHooks(_ context.Context, scope platform.HookScope, projectRoot string) error
InstallHooks registers brainjar's beforeSubmitPrompt hook in <scope>/.cursor/hooks.json. Top-level version is stamped so Cursor accepts the file; existing entries at any event are preserved.
func (*Platform) InstallMCP ¶
func (c *Platform) InstallMCP(_ context.Context, scope platform.HookScope, projectRoot, home string) error
InstallMCP registers brainjar as an MCP server in <scope>/.cursor/mcp.json. Schema matches Claude Desktop's. Project and user scopes are both supported; local is Claude-only. Short-circuits when the stored entry already matches what we'd write — saves an unnecessary rewrite and mtime bump on every re-install.
func (*Platform) MCPStatus ¶
func (c *Platform) MCPStatus(_ context.Context, scope platform.HookScope, projectRoot, home string) (platform.MCPStatus, error)
MCPStatus reports registration and drift against the active home.
func (*Platform) MapModelPrefs ¶
func (c *Platform) MapModelPrefs(prefs *models.ModelPrefs) map[string]any
MapModelPrefs delegates to the catalog-backed canonical helper. Cursor's catalog is empty by design — values pass through verbatim because Cursor's model selection is UI-bound and brainjar can't enforce it from the filesystem.
func (*Platform) ModelArgs ¶ added in v0.6.0
func (c *Platform) ModelArgs(*models.ModelPrefs) []string
ModelArgs returns nil — Cursor's model selection is UI-bound, no CLI flag to inject. The brain's model field is informational on Cursor and never reaches a process argv.
func (*Platform) RemoveHooks ¶
func (c *Platform) RemoveHooks(_ context.Context, scope platform.HookScope, projectRoot string) error
RemoveHooks strips brainjar's entry from hooks.json. When the file becomes an empty `{version: 1}` shell, it's deleted entirely.
func (*Platform) SkillsStatus ¶ added in v0.6.0
SkillsStatus returns ErrUnsupportedByPlatform for the same reason EmitSkills does.
func (*Platform) Spawn ¶
Spawn implements Platform. Cursor has no documented mechanism to inject a per-invocation system prompt via the CLI, so this returns ErrUnsupportedByPlatform. The CLI catches the sentinel and exits 2 with the hint below.
func (*Platform) Sync ¶
Sync writes the composed prompt into <projectRoot>/.cursor/rules/brainjar.mdc. Unlike Claude/Codex, brainjar owns the entire file: YAML frontmatter governs how Cursor applies the rule (alwaysApply=true), and the managed markers sit inside the rule body for grepability. A re-sync with the same prompt is a byte-compare no-op.
func (*Platform) SyncRemove ¶ added in v0.7.0
SyncRemove deletes brainjar's rule file. Cursor's adapter owns the whole file, so removal is a delete rather than a managed-section strip. Missing file is a no-op.