pass SYSTEM.md as --append-system-prompt instead of relying on shard to Read it

This commit is contained in:
Damocles 2026-05-01 14:24:23 +02:00
parent ce5ed98482
commit 072058a8cc

View file

@ -98,6 +98,14 @@ impl ShardSession {
pub async fn spawn(cfg: SpawnConfig<'_>) -> anyhow::Result<Self> { pub async fn spawn(cfg: SpawnConfig<'_>) -> anyhow::Result<Self> {
let identity_dir = paths::identity_dir(); let identity_dir = paths::identity_dir();
// SYSTEM.md is the harness contract. Claude Code only auto-loads
// CLAUDE.md from --add-dir, so SYSTEM.md gets passed explicitly via
// --append-system-prompt to ensure the shard always sees it.
let system_md_path = identity_dir.join("SYSTEM.md");
let system_md = tokio::fs::read_to_string(&system_md_path)
.await
.with_context(|| format!("reading {}", system_md_path.display()))?;
let mut cmd = Command::new("claude"); let mut cmd = Command::new("claude");
cmd.args([ cmd.args([
"--print", "--print",
@ -114,6 +122,8 @@ impl ShardSession {
cfg.allowed_tools, cfg.allowed_tools,
"--mcp-config", "--mcp-config",
&cfg.mcp_config_path.to_string_lossy(), &cfg.mcp_config_path.to_string_lossy(),
"--append-system-prompt",
&system_md,
]); ]);
cmd.current_dir(&identity_dir); cmd.current_dir(&identity_dir);
cmd.stdin(Stdio::piped()); cmd.stdin(Stdio::piped());