Skip to content

Commit 6ce64d1

Browse files
committed
fix: system prompt now shows runtime type, not hardcoded git
- Local runtime: 'You are working in a directory' (no git mention) - Worktree/SSH: 'You are in a git worktree' (git context) This aligns the system prompt with the actual runtime environment.
1 parent 8cb49e9 commit 6ce64d1

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

docs/system-prompt.mdx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,26 @@ When the user asks you to remember something:
4646

4747
/**
4848
* Build environment context XML block describing the workspace.
49+
* @param workspacePath - Workspace directory path
50+
* @param runtimeType - Runtime type: "local", "worktree", or "ssh"
4951
*/
50-
function buildEnvironmentContext(workspacePath: string): string {
52+
function buildEnvironmentContext(
53+
workspacePath: string,
54+
runtimeType: "local" | "worktree" | "ssh"
55+
): string {
56+
if (runtimeType === "local") {
57+
// Local runtime works directly in project directory - may or may not be git
58+
return `
59+
<environment>
60+
You are working in a directory at ${workspacePath}
61+
62+
- Tools run here automatically
63+
- You are meant to do your work isolated from the user and other agents
64+
</environment>
65+
`;
66+
}
67+
68+
// Worktree and SSH runtimes always operate in git repositories
5169
return `
5270
<environment>
5371
You are in a git worktree at ${workspacePath}

src/node/services/systemMessage.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,26 @@ When the user asks you to remember something:
6565

6666
/**
6767
* Build environment context XML block describing the workspace.
68+
* @param workspacePath - Workspace directory path
69+
* @param runtimeType - Runtime type: "local", "worktree", or "ssh"
6870
*/
69-
function buildEnvironmentContext(workspacePath: string): string {
71+
function buildEnvironmentContext(
72+
workspacePath: string,
73+
runtimeType: "local" | "worktree" | "ssh"
74+
): string {
75+
if (runtimeType === "local") {
76+
// Local runtime works directly in project directory - may or may not be git
77+
return `
78+
<environment>
79+
You are working in a directory at ${workspacePath}
80+
81+
- Tools run here automatically
82+
- You are meant to do your work isolated from the user and other agents
83+
</environment>
84+
`;
85+
}
86+
87+
// Worktree and SSH runtimes always operate in git repositories
7088
return `
7189
<environment>
7290
You are in a git worktree at ${workspacePath}
@@ -259,8 +277,11 @@ export async function buildSystemMessage(
259277
null;
260278
}
261279

280+
// Get runtime type from metadata (defaults to "local" for legacy workspaces without runtimeConfig)
281+
const runtimeType = metadata.runtimeConfig?.type ?? "local";
282+
262283
// Build system message
263-
let systemMessage = `${PRELUDE.trim()}\n\n${buildEnvironmentContext(workspacePath)}`;
284+
let systemMessage = `${PRELUDE.trim()}\n\n${buildEnvironmentContext(workspacePath, runtimeType)}`;
264285

265286
// Add MCP context if servers are configured
266287
if (mcpServers && Object.keys(mcpServers).length > 0) {

0 commit comments

Comments
 (0)