fix(agents): set confirmed SessionDirTemplate for Pi, Qoder, Kiro and Trae (#2019)

All four templates were confirmed against the shipped CLI, not inferred
from the agent name:

- pi-acp     -> {home}/.pi              (pi-acp@0.0.32 package source)
- qoder-acp  -> {home}/.qoder           (qodercli 1.1.7, --config-dir proof)
- kiro-acp   -> {home}/.kiro            (Kiro CLI 2.15.0, ACP session/new)
- trae-acp   -> {home}/.cache/trae-cli  (Trae CLI 0.120.48, ACP session/new)

Kiro and Trae deliberately break the "{home}/.<agent>" shape: Kiro keeps
its login token in ~/.local/share/kiro-cli/data.sqlite3 while sessions
live in ~/.kiro, and Trae keeps config in ~/.trae but session state in
the cache dir with auth in the OS keyring. Each Runtime() records the
evidence and the residual gaps.

Extends the shared ACP agent spec table with sessionDirTemplate so every
agent's session root is pinned, including the ones already set.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
João Salavisa
2026-07-28 23:17:47 +01:00
committed by GitHub
parent ca328f750f
commit 7b796b1eaa
5 changed files with 117 additions and 63 deletions
@@ -89,12 +89,14 @@ func (a *KiroACP) Runtime() *RuntimeConfig {
Protocol: agent.ProtocolACP,
UserSkillDir: ".kiro/skills",
SessionConfig: SessionConfig{
// TODO: set SessionDirTemplate once the Kiro session dir is
// confirmed (likely "{home}/.kiro"). Without it, the Docker
// runtime skips mounting the session dir, so NativeSessionResume
// has no persistence across container restarts. ACP-native
// session/load still works in standalone mode where the host
// home dir is the working filesystem.
// Verified against Kiro CLI 2.15.0 by driving `kiro-cli-chat acp`
// through session/new: each ACP session is persisted as
// ~/.kiro/sessions/cli/<sessionId>.{json,jsonl}. KIRO_HOME
// relocates the directory. Note ~/.kiro carries config + sessions
// only — the login token lives in the separate
// ~/.local/share/kiro-cli/data.sqlite3 (auth_kv table), so this
// mount persists resumable sessions but not authentication.
SessionDirTemplate: "{home}/.kiro",
NativeSessionResume: true,
CanRecover: &canRecover,
},
@@ -30,6 +30,13 @@ type acpAgentSpec struct {
installViaNpm bool // InstallScript starts with "npm install -g"
installScript string // expected InstallScript() value (empty = unchecked)
stripEnv []string // expected Runtime().StripEnv (nil = unchecked)
// sessionDirTemplate is the agent's on-disk session root. Pinned per
// agent because it is derived from what the CLI actually writes (see the
// evidence comment on each Runtime()), not from a naming convention —
// Trae and Devin both diverge from the "{home}/.<agent>" shape, and a
// wrong value silently bind-mounts the wrong directory into the
// container.
sessionDirTemplate string
}
var newACPAgentSpecs = []struct {
@@ -38,38 +45,43 @@ var newACPAgentSpecs = []struct {
}{
{func() Agent { return NewQwenACP() }, acpAgentSpec{
id: "qwen-acp", displayName: "Qwen", detectBinaries: []string{"qwen"},
expectedArgv: []string{"npx", "-y", "@qwen-code/qwen-code", "--acp"},
inferenceArgv: []string{"npx", "-y", "@qwen-code/qwen-code", "--acp"},
passthroughArgv: []string{"npx", "-y", "@qwen-code/qwen-code"},
installViaNpm: true,
expectedArgv: []string{"npx", "-y", "@qwen-code/qwen-code", "--acp"},
inferenceArgv: []string{"npx", "-y", "@qwen-code/qwen-code", "--acp"},
passthroughArgv: []string{"npx", "-y", "@qwen-code/qwen-code"},
installViaNpm: true,
sessionDirTemplate: "{home}/.qwen",
}},
{func() Agent { return NewIFlowACP() }, acpAgentSpec{
id: "iflow-acp", displayName: "iFlow (beta)", detectBinaries: []string{"iflow"},
expectedArgv: []string{"npx", "-y", "@iflow-ai/iflow-cli", "--experimental-acp"},
inferenceArgv: []string{"npx", "-y", "@iflow-ai/iflow-cli", "--experimental-acp"},
passthroughArgv: []string{"npx", "-y", "@iflow-ai/iflow-cli"},
installViaNpm: true,
expectedArgv: []string{"npx", "-y", "@iflow-ai/iflow-cli", "--experimental-acp"},
inferenceArgv: []string{"npx", "-y", "@iflow-ai/iflow-cli", "--experimental-acp"},
passthroughArgv: []string{"npx", "-y", "@iflow-ai/iflow-cli"},
installViaNpm: true,
sessionDirTemplate: "{home}/.iflow",
}},
{func() Agent { return NewDroidACP() }, acpAgentSpec{
id: "droid-acp", displayName: "Droid", detectBinaries: []string{"droid"},
expectedArgv: []string{"npx", "-y", "droid", "exec", "--output-format", "acp"},
inferenceArgv: []string{"npx", "-y", "droid", "exec", "--output-format", "acp"},
passthroughArgv: []string{"npx", "-y", "droid"},
installViaNpm: true,
expectedArgv: []string{"npx", "-y", "droid", "exec", "--output-format", "acp"},
inferenceArgv: []string{"npx", "-y", "droid", "exec", "--output-format", "acp"},
passthroughArgv: []string{"npx", "-y", "droid"},
installViaNpm: true,
sessionDirTemplate: "{home}/.factory",
}},
{func() Agent { return NewKilocodeACP() }, acpAgentSpec{
id: "kilocode-acp", displayName: "Kilocode", detectBinaries: []string{"kilo", "kilocode"},
expectedArgv: []string{"npx", "-y", "@kilocode/cli", "acp"},
inferenceArgv: []string{"npx", "-y", "@kilocode/cli", "acp"},
passthroughArgv: []string{"npx", "-y", "@kilocode/cli"},
installViaNpm: true,
expectedArgv: []string{"npx", "-y", "@kilocode/cli", "acp"},
inferenceArgv: []string{"npx", "-y", "@kilocode/cli", "acp"},
passthroughArgv: []string{"npx", "-y", "@kilocode/cli"},
installViaNpm: true,
sessionDirTemplate: "{home}/.kilocode",
}},
{func() Agent { return NewPiACP() }, acpAgentSpec{
id: "pi-acp", displayName: "Pi", detectBinaries: []string{"pi-acp", "pi"},
expectedArgv: []string{"npx", "-y", "pi-acp"},
inferenceArgv: []string{"npx", "-y", "pi-acp"},
passthroughArgv: []string{"npx", "-y", "pi-acp"},
installViaNpm: true,
expectedArgv: []string{"npx", "-y", "pi-acp"},
inferenceArgv: []string{"npx", "-y", "pi-acp"},
passthroughArgv: []string{"npx", "-y", "pi-acp"},
installViaNpm: true,
sessionDirTemplate: "{home}/.pi",
}},
{func() Agent { return NewCursorACP() }, acpAgentSpec{
id: "cursor-acp", displayName: "Cursor", detectBinaries: []string{"cursor-agent"},
@@ -87,49 +99,56 @@ bash "$tmp"
rm -f "$tmp"
export PATH="$HOME/.local/bin:$PATH"
grep -qxF 'export PATH="$HOME/.local/bin:$PATH"' "$HOME/.bashrc" 2>/dev/null || echo 'export PATH="$HOME/.local/bin:$PATH"' >> "$HOME/.bashrc"`,
sessionDirTemplate: "{home}/.cursor",
}},
{func() Agent { return NewKimiACP() }, acpAgentSpec{
id: "kimi-acp", displayName: "Kimi", detectBinaries: []string{"kimi"},
expectedArgv: []string{"kimi", "acp"},
inferenceArgv: []string{"kimi", "acp"},
passthroughArgv: []string{"kimi"},
installViaNpm: false,
expectedArgv: []string{"kimi", "acp"},
inferenceArgv: []string{"kimi", "acp"},
passthroughArgv: []string{"kimi"},
installViaNpm: false,
sessionDirTemplate: "{home}/.kimi",
}},
{func() Agent { return NewKiroACP() }, acpAgentSpec{
id: "kiro-acp", displayName: "Kiro", detectBinaries: []string{"kiro-cli-chat"},
expectedArgv: []string{"kiro-cli-chat", "acp"},
inferenceArgv: []string{"kiro-cli-chat", "acp"},
passthroughArgv: []string{"kiro-cli-chat"},
installViaNpm: false,
expectedArgv: []string{"kiro-cli-chat", "acp"},
inferenceArgv: []string{"kiro-cli-chat", "acp"},
passthroughArgv: []string{"kiro-cli-chat"},
installViaNpm: false,
sessionDirTemplate: "{home}/.kiro",
}},
{func() Agent { return NewQoderACP() }, acpAgentSpec{
id: "qoder-acp", displayName: "Qoder", detectBinaries: []string{"qodercli"},
expectedArgv: []string{"qodercli", "--acp"},
inferenceArgv: []string{"qodercli", "--acp"},
passthroughArgv: []string{"qodercli"},
installViaNpm: false,
expectedArgv: []string{"qodercli", "--acp"},
inferenceArgv: []string{"qodercli", "--acp"},
passthroughArgv: []string{"qodercli"},
installViaNpm: false,
sessionDirTemplate: "{home}/.qoder",
}},
{func() Agent { return NewTraeACP() }, acpAgentSpec{
id: "trae-acp", displayName: "Trae", detectBinaries: []string{"traecli"},
expectedArgv: []string{"traecli", "acp", "serve"},
inferenceArgv: []string{"traecli", "acp", "serve"},
passthroughArgv: []string{"traecli"},
installViaNpm: false,
expectedArgv: []string{"traecli", "acp", "serve"},
inferenceArgv: []string{"traecli", "acp", "serve"},
passthroughArgv: []string{"traecli"},
installViaNpm: false,
sessionDirTemplate: "{home}/.cache/trae-cli",
}},
{func() Agent { return NewOmpACP() }, acpAgentSpec{
id: "omp-acp", displayName: "omp", detectBinaries: []string{"omp"},
expectedArgv: []string{"omp", "acp"},
inferenceArgv: []string{"omp", "acp"},
passthroughArgv: []string{"omp"},
installViaNpm: false,
expectedArgv: []string{"omp", "acp"},
inferenceArgv: []string{"omp", "acp"},
passthroughArgv: []string{"omp"},
installViaNpm: false,
sessionDirTemplate: "{home}/.omp",
}},
{func() Agent { return NewDevinACP() }, acpAgentSpec{
id: "devin-acp", displayName: "Devin", detectBinaries: []string{"devin"},
expectedArgv: []string{"devin", "acp"},
inferenceArgv: []string{"devin", "acp"},
passthroughArgv: []string{"devin"},
installViaNpm: false,
stripEnv: []string{"ACP_BACKEND"},
expectedArgv: []string{"devin", "acp"},
inferenceArgv: []string{"devin", "acp"},
passthroughArgv: []string{"devin"},
installViaNpm: false,
stripEnv: []string{"ACP_BACKEND"},
sessionDirTemplate: "{home}/.local/share/devin",
}},
}
@@ -196,6 +215,30 @@ func TestNewACPAgents_AllCommandSurfaces(t *testing.T) {
}
}
// TestNewACPAgents_SessionDirTemplate pins the session root each agent
// declares. The lifecycle manager turns SessionDirTemplate into the
// bind-mount source under <kandev-home>/agent-sessions/<instance>/, so an
// unset value means an agent's own session state is quietly lost on every
// container restart, and a wrong value mounts a directory the CLI never
// reads.
func TestNewACPAgents_SessionDirTemplate(t *testing.T) {
for _, tc := range newACPAgentSpecs {
t.Run(tc.spec.id, func(t *testing.T) {
rt := tc.new().Runtime()
if rt == nil {
t.Fatalf("Runtime() returned nil")
}
if got := rt.SessionConfig.SessionDirTemplate; got != tc.spec.sessionDirTemplate {
t.Errorf("SessionDirTemplate = %q, want %q", got, tc.spec.sessionDirTemplate)
}
if !strings.HasPrefix(tc.spec.sessionDirTemplate, "{home}/") {
t.Errorf("SessionDirTemplate %q must be {home}-relative; SessionDirHostPath only trims that prefix",
tc.spec.sessionDirTemplate)
}
})
}
}
func TestNewACPAgents_InstallScript(t *testing.T) {
for _, tc := range newACPAgentSpecs {
t.Run(tc.spec.id, func(t *testing.T) {
+6 -4
View File
@@ -96,10 +96,12 @@ func (a *PiACP) Runtime() *RuntimeConfig {
UserSkillDir: ".pi/agent/skills",
ProjectMCPStrategy: mcpconfig.PiStrategy{},
SessionConfig: SessionConfig{
// TODO: set SessionDirTemplate once the Pi session dir is
// confirmed. Without it, the Docker runtime skips mounting the
// session dir, so NativeSessionResume has no persistence across
// container restarts.
// Verified against pi-acp@0.0.32: the adapter keeps the ACP↔pi
// session map in ~/.pi/pi-acp/session-map.json and reads pi's own
// transcripts from ~/.pi/agent/sessions (relocatable via
// PI_CODING_AGENT_DIR or a sessionDir in ~/.pi/agent/settings.json).
// Both halves of session/load live under ~/.pi.
SessionDirTemplate: "{home}/.pi",
NativeSessionResume: true,
CanRecover: &canRecover,
},
@@ -87,10 +87,11 @@ func (a *QoderACP) Runtime() *RuntimeConfig {
ResourceLimits: ResourceLimits{MemoryMB: 4096, CPUCores: 2.0, Timeout: time.Hour},
Protocol: agent.ProtocolACP,
SessionConfig: SessionConfig{
// TODO: set SessionDirTemplate once the Qoder session dir is
// confirmed. Without it, the Docker runtime skips mounting the
// session dir, so NativeSessionResume has no persistence across
// container restarts.
// Verified against qodercli 1.1.7: every user-level artifact
// (settings.json, .auth/, logs/sessions/<project>) is written
// under ~/.qoder, and the --config-dir flag relocates that single
// root wholesale — running with it leaves nothing else in $HOME.
SessionDirTemplate: "{home}/.qoder",
NativeSessionResume: true,
CanRecover: &canRecover,
},
+10 -4
View File
@@ -86,10 +86,16 @@ func (a *TraeACP) Runtime() *RuntimeConfig {
ResourceLimits: ResourceLimits{MemoryMB: 4096, CPUCores: 2.0, Timeout: time.Hour},
Protocol: agent.ProtocolACP,
SessionConfig: SessionConfig{
// TODO: set SessionDirTemplate once the Trae session dir is
// confirmed. Without it, the Docker runtime skips mounting the
// session dir, so NativeSessionResume has no persistence across
// container restarts.
// Verified against Trae CLI 0.120.48 by driving `traecli acp
// serve` through session/new + session/prompt: the ACP session ID
// appears as ~/.cache/trae-cli/sessions/<sessionId>/, which is
// where the CLI persists conversation history and metadata.
// ~/.trae holds config only (traecli.yaml, skills, agents,
// commands) and the login token lives in the OS keyring, not a
// file, so neither belongs here. The published manual still
// documents the older ~/.cache/coco/ cache root; the shipped
// binary uses ~/.cache/trae-cli, so re-check this on upgrades.
SessionDirTemplate: "{home}/.cache/trae-cli",
NativeSessionResume: true,
CanRecover: &canRecover,
},