fix: resolve ${PWD} in system prompt from session cwd, not process env
expandSystemPrompt fell through to os.Getenv("PWD") which always
returned the process startup directory. Map "PWD" explicitly to the
cwd parameter so the system prompt reflects the session's working
directory.
This commit is contained in:
parent
e0bd5cefe8
commit
197c3664c6
|
|
@ -137,6 +137,8 @@ func expandSystemPrompt(content, cwd string) string {
|
|||
}
|
||||
mapper := func(key string) string {
|
||||
switch key {
|
||||
case "PWD":
|
||||
return cwd
|
||||
case "PRIME_DATE":
|
||||
return time.Now().Format("2006-01-02")
|
||||
case "PRIME_PLATFORM":
|
||||
|
|
|
|||
|
|
@ -544,6 +544,14 @@ func TestExpandSystemPrompt_IsGitFalse(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestExpandSystemPrompt_PWDUsesCWD(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
got := expandSystemPrompt("${PWD}", dir)
|
||||
if got != dir {
|
||||
t.Errorf("got %q; want %q", got, dir)
|
||||
}
|
||||
}
|
||||
|
||||
// --- BuildAgentEnv: missing system prompt ---
|
||||
|
||||
func TestBuildAgentEnv_MissingSystemPrompt(t *testing.T) {
|
||||
|
|
|
|||
Reference in New Issue