Skip to content

A desktop coding agent with free access to frontier models.

TypeScript

fix(swarm): .omnirush/.ignore stays out of git status

Samrat Talukdar66e501607298
diff --git a/apps/server/src/omnirush-swarm.ts b/apps/server/src/omnirush-swarm.ts
index 9f6be83b..07807624 100644
--- a/apps/server/src/omnirush-swarm.ts
+++ b/apps/server/src/omnirush-swarm.ts
@@ -63,11 +63,12 @@ export const OMNIRUSH_SWARM_FILE = `${OMNIRUSH_WORKSPACE_DIR}/swarm.md`;
export const OMNIRUSH_SWARM_ARCHIVE_DIR = `${OMNIRUSH_WORKSPACE_DIR}/swarms`;
/**
- * The `.omnirush/.gitignore` entries that keep the board, its archive and
- * that file itself out of git status and out of the collector's snapshots
- * (the board still reaches the trace through the tool calls that write it).
+ * The `.omnirush/.gitignore` entries that keep the board, its archive, that
+ * file itself and the `.ignore` file next to it out of git status and out of
+ * the collector's snapshots (the board still reaches the trace through the
+ * tool calls that write it).
*/
-export const OMNIRUSH_SWARM_GITIGNORE_LINES = ["/.gitignore", "/swarm.md", "/swarms/"] as const;
+export const OMNIRUSH_SWARM_GITIGNORE_LINES = ["/.gitignore", "/.ignore", "/swarm.md", "/swarms/"] as const;
/**
* The `.omnirush/.ignore` entries: ripgrep, which the engine's grep and glob
diff --git a/apps/server/src/opencode-plugins/omnirush-swarm.test.ts b/apps/server/src/opencode-plugins/omnirush-swarm.test.ts
index d91e1646..d8e043c3 100644
--- a/apps/server/src/opencode-plugins/omnirush-swarm.test.ts
+++ b/apps/server/src/opencode-plugins/omnirush-swarm.test.ts
@@ -129,10 +129,26 @@ describe("omnirush swarm plugin", () => {
await writeBoard(directory);
expect(await systemOf(hooks)("ses_child")).toContain("`.omnirush/swarm.md`");
expect(await readFile(join(directory, ".omnirush", ".gitignore"), "utf8")).toContain("/swarm.md\n/swarms/\n");
+ // Both of omnirush.ai's ignore files stay out of git status too.
+ expect(await readFile(join(directory, ".omnirush", ".gitignore"), "utf8")).toContain("/.gitignore\n/.ignore\n");
// ripgrep (the engine's grep and glob) honours .ignore outside git repositories too.
expect(await readFile(join(directory, ".omnirush", ".ignore"), "utf8")).toContain("/.ignore\n/swarm.md\n/swarms/\n");
});
+ test("a swarm leaves git status clean", async () => {
+ const { hooks, directory } = await setup();
+ const git = (...args: string[]) => Bun.spawnSync(["git", "-C", directory, "-c", "user.name=t", "-c", "[email protected]", "-c", "commit.gpgsign=false", ...args]);
+ git("init", "-q");
+ await writeFile(join(directory, "README.md"), "# t\n");
+ git("add", ".");
+ git("commit", "-q", "-m", "init");
+ await created(hooks, "ses_main");
+ await loadSwarmSkill(hooks, "ses_main");
+ await writeBoard(directory);
+ expect(existsSync(join(directory, ".omnirush", ".ignore"))).toBe(true);
+ expect(git("status", "--porcelain", "--untracked-files=all").stdout.toString()).toBe("");
+ });
+
test("a user's own .omnirush/.gitignore only gains the board lines", async () => {
const { hooks, directory } = await setup();
await created(hooks, "ses_main");
diff --git a/apps/server/src/opencode-plugins/omnirush-swarm.ts b/apps/server/src/opencode-plugins/omnirush-swarm.ts
index 80da5f69..eb80e6ef 100644
--- a/apps/server/src/opencode-plugins/omnirush-swarm.ts
+++ b/apps/server/src/opencode-plugins/omnirush-swarm.ts
@@ -210,6 +210,8 @@ function writesBoard(tool: string, args: unknown): boolean {
return false;
}
+const OWN_IGNORE_FILES = new Set(["/.gitignore", "/.ignore"]);
+
/** Adds the board lines to one ignore file in `.omnirush/`; a user's own file only gains the missing lines. */
async function ignoreIn(folder: string, name: string, lines: readonly string[], why: string): Promise<void> {
const file = join(folder, name);
@@ -219,8 +221,9 @@ async function ignoreIn(folder: string, name: string, lines: readonly string[],
return;
}
const present = new Set(current.split(/\r?\n/).map((line) => line.trim()));
- // A user's own file is theirs to track: only the board lines are added.
- const missing = lines.filter((line) => line !== `/${name}` && !present.has(line));
+ // A user's own file is theirs to track: only the board lines are added
+ // (never the lines for omnirush.ai's own ignore files).
+ const missing = lines.filter((line) => !OWN_IGNORE_FILES.has(line) && !present.has(line));
if (missing.length) await appendFile(file, `${current.endsWith("\n") || !current ? "" : "\n"}${missing.join("\n")}\n`, "utf8");
}