Skip to content

Commit af2f198

Browse files
committed
feat(provider): systemPrompt option (default rules) + dispose cleanup
1 parent 2dc6f66 commit af2f198

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

‎src/plugin/index.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
translateMcpServers,
1111
} from "./mcp-config.js";
1212
import { buildCursorTools } from "./cursor-tools.js";
13+
import { removeSystemRule } from "../provider/system-rule.js";
1314

1415
function apiKeyFromAuth(auth: Auth | undefined): string | undefined {
1516
return auth?.type === "api" ? auth.key : undefined;
@@ -210,6 +211,12 @@ export const CursorPlugin: Plugin = async (input) => {
210211
defaultCwd: () => input?.directory ?? process.cwd(),
211212
}),
212213
},
214+
215+
dispose: async () => {
216+
// Best-effort: drop the generated system-prompt rule so it doesn't
217+
// linger in the user's workspace / Cursor IDE after the session ends.
218+
if (directory) removeSystemRule(directory);
219+
},
213220
};
214221
};
215222

‎src/provider/index.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
type CursorModelConfig,
1717
} from "./language-model.js";
1818
import type { ToolDisplay } from "./stream-map.js";
19+
import type { SystemPromptMode } from "./message-map.js";
1920

2021
export interface CursorProviderOptions {
2122
/**
@@ -65,6 +66,17 @@ export interface CursorProviderOptions {
6566
* hosts (works everywhere).
6667
*/
6768
toolDisplay?: ToolDisplay;
69+
/**
70+
* How opencode's system prompt reaches the Cursor agent:
71+
* - "rules" (default): written to `<cwd>/.cursor/rules/opencode.mdc`
72+
* (git-ignored, alwaysApply) and loaded via the `project` settings layer —
73+
* Cursor's authoritative channel, so it is not rejected as prompt injection.
74+
* Note: a project rule also applies to your own Cursor IDE in this repo, and
75+
* enabling the project layer also loads other `.cursor/` config.
76+
* - "message": legacy inline `# System` block (may be flagged as injection).
77+
* - "omit": not forwarded at all.
78+
*/
79+
systemPrompt?: SystemPromptMode;
6880
}
6981

7082
/**
@@ -94,6 +106,7 @@ export function createCursor(options: CursorProviderOptions = {}): ProviderV3 {
94106
...(options.agents ? { agents: options.agents } : {}),
95107
session: options.session ?? "auto",
96108
toolDisplay: options.toolDisplay ?? "blocks",
109+
systemPrompt: options.systemPrompt ?? "rules",
97110
};
98111

99112
const notImplemented = (kind: string, modelId: string): never => {

0 commit comments

Comments
 (0)