Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix(cos): clean up BTW.md after agent completion, add to .gitignore

Adam Eivy823e376fa8ef
diff --git a/.gitignore b/.gitignore
index 0f57c0cc72..20dc04f414 100644
--- a/.gitignore
+++ b/.gitignore
@@ -41,6 +41,9 @@ Thumbs.db
.claude/worktrees/
.claude/settings.local.json
+# BTW messages (ephemeral agent context, cleaned up after ingestion)
+BTW.md
+
# Browser service node_modules (code is committed)
browser/node_modules/
diff --git a/server/services/subAgentSpawner.js b/server/services/subAgentSpawner.js
index 52465cbc33..b45f9b6239 100644
--- a/server/services/subAgentSpawner.js
+++ b/server/services/subAgentSpawner.js
@@ -63,6 +63,16 @@ function extractTaskTypeKey(task) {
return 'unknown';
}
+/**
+ * Remove BTW.md from agent workspace after completion.
+ * Prevents ephemeral context files from being committed to git.
+ */
+async function cleanupBtwFile(workspacePath) {
+ if (!workspacePath) return;
+ const btwPath = join(workspacePath, 'BTW.md');
+ await rm(btwPath).catch(() => {});
+}
+
const SKILLS_DIR = join(ROOT_DIR, 'data/prompts/skills');
/**
@@ -1942,6 +1952,9 @@ async function handleAgentCompletion(agentId, exitCode, success, duration) {
}
}
+ // Clean up ephemeral BTW.md before worktree removal
+ await cleanupBtwFile(agentState?.metadata?.workspacePath);
+
// Clean up worktree if agent was using one (skip merge when JIRA branch — PR handles merge)
if (!jiraBranch) {
const taskOpenPR = isTruthyMeta(agent.task?.metadata?.openPR);
@@ -2249,6 +2262,9 @@ async function spawnDirectly(agentId, task, prompt, workspacePath, model, provid
// Process memory extraction and app cooldown
await processAgentCompletion(agentId, task, success, outputBuffer);
+ // Clean up ephemeral BTW.md before worktree removal
+ await cleanupBtwFile(workspacePath);
+
// Clean up worktree if agent was using one
await cleanupAgentWorktree(agentId, success, {
openPR: isTruthyMeta(task.metadata?.openPR),