feat: auto-launch reflection via shared background task helper (#924)

This commit is contained in:
Charles Packer
2026-02-11 20:45:14 -08:00
committed by GitHub
parent 7f83035a09
commit 9630da190a
10 changed files with 750 additions and 275 deletions

View File

@@ -8,6 +8,7 @@ import {
buildMemoryReminder,
getReflectionSettings,
reflectionSettingsToLegacyMode,
shouldFireStepCountTrigger,
} from "../../cli/helpers/memoryReminder";
import { settingsManager } from "../../settings-manager";
@@ -144,4 +145,28 @@ describe("memoryReminder", () => {
const reminder = await buildCompactionMemoryReminder("agent-1");
expect(reminder).toBe(MEMORY_REFLECTION_REMINDER);
});
test("evaluates step-count trigger based on effective settings", () => {
expect(
shouldFireStepCountTrigger(10, {
trigger: "step-count",
behavior: "auto-launch",
stepCount: 5,
}),
).toBe(true);
expect(
shouldFireStepCountTrigger(10, {
trigger: "step-count",
behavior: "reminder",
stepCount: 6,
}),
).toBe(false);
expect(
shouldFireStepCountTrigger(10, {
trigger: "off",
behavior: "reminder",
stepCount: 5,
}),
).toBe(false);
});
});

View File

@@ -0,0 +1,22 @@
import { describe, expect, test } from "bun:test";
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
describe("reflection auto-launch wiring", () => {
test("handles step-count and compaction-event auto-launch modes", () => {
const appPath = fileURLToPath(
new URL("../../cli/App.tsx", import.meta.url),
);
const source = readFileSync(appPath, "utf-8");
expect(source).toContain("const maybeLaunchReflectionSubagent = async");
expect(source).toContain(
'await maybeLaunchReflectionSubagent("step-count")',
);
expect(source).toContain(
'await maybeLaunchReflectionSubagent("compaction-event")',
);
expect(source).toContain("hasActiveReflectionSubagent()");
expect(source).toContain("spawnBackgroundSubagentTask({");
});
});