Skip to content

fix(provider): deliver opencode system prompt to Cursor via the rules channel#56

Merged
justin-carper merged 8 commits into
mainfrom
cursor-agent-opencode-plu
Jul 6, 2026
Merged

fix(provider): deliver opencode system prompt to Cursor via the rules channel#56
justin-carper merged 8 commits into
mainfrom
cursor-agent-opencode-plu

Conversation

@justin-carper

Copy link
Copy Markdown
Collaborator

Summary

  • The provider flattened opencode's system prompt into the user-message transcript, which injection-hardened Cursor models rejected as a prompt-injection attempt (the agent accusing the user of gaslighting / prompt injection). opencode's system prompt is now delivered through Cursor's authoritative rules channel — written to a git-ignored .cursor/rules/opencode.mdc (alwaysApply: true) and loaded via the project settings layer — so opencode keeps control without being flagged.
  • New systemPrompt provider option: "rules" (default), "message" (legacy inline, back-comat), "omit". Rules load from disk at Agent.create, so no sidecar/RPC changes.
  • dispose removes the generated rule (best-effort). Session reuse is unaffected (fingerprint reads the prompt, not the forwarded message).

Test Plan

  • npm run typecheck — clean
  • npm test — 229 passed
  • npm run build — ESM + DTS success
  • rg -n "# System" src — only the guarded "message"-mode branch remains
  • Live: with a Cursor key, chat a cursor/* model on a project with an AGENTS.md and confirm the injection-rejection behavior no longer fires

Notes

  • Verified the Cursor SDK has no system-prompt input through @cursor/sdk@1.0.22 (latest). Cursor's documented channel for system-level instructions is .cursor/rules loaded via settingSources.
  • Tradeoffs documented in the README: a project rule also applies to your own Cursor IDE in this repo (best-effort cleanup on dispose), and enabling the project layer also loads other .cursor/ config.
  • Design plan: docs/superpowers/plans/2026-07-02-system-prompt-via-cursor-rules.md.

justin-carper added a commit that referenced this pull request Jul 6, 2026
…e writes

Address PR #56 review findings on the rules-channel system prompt:

- never force-append "project" to an explicitly configured settingSources
  (deliberate hardening opt-out); degrade to inline "message" delivery
  with a one-time warning instead
- wrap the rule write in try/catch: a failed write (read-only checkout)
  degrades to "message" mode for the turn rather than failing it
- add a generated-by sentinel to opencode.mdc frontmatter; a user-owned
  (sentinel-less) file is never overwritten or deleted
- thread one canonical cwd through the provider options and dispose so
  write and cleanup can't diverge and orphan the rule file
- make .cursor/rules/.gitignore ignore itself
- skip the rewrite when the rule content is unchanged (no sync fs write
  on the stream hot path)
…e writes

Address PR #56 review findings on the rules-channel system prompt:

- never force-append "project" to an explicitly configured settingSources
  (deliberate hardening opt-out); degrade to inline "message" delivery
  with a one-time warning instead
- wrap the rule write in try/catch: a failed write (read-only checkout)
  degrades to "message" mode for the turn rather than failing it
- add a generated-by sentinel to opencode.mdc frontmatter; a user-owned
  (sentinel-less) file is never overwritten or deleted
- thread one canonical cwd through the provider options and dispose so
  write and cleanup can't diverge and orphan the rule file
- make .cursor/rules/.gitignore ignore itself
- skip the rewrite when the rule content is unchanged (no sync fs write
  on the stream hot path)
@justin-carper justin-carper force-pushed the cursor-agent-opencode-plu branch from 4f1fbcd to 8e1ed25 Compare July 6, 2026 20:58
@justin-carper justin-carper merged commit 4cd396c into main Jul 6, 2026
6 checks passed
@justin-carper justin-carper deleted the cursor-agent-opencode-plu branch July 6, 2026 21:06
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.

1 participant