feat: auto-launch reflection via shared background task helper (#924)
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
22
src/tests/cli/reflection-auto-launch-wiring.test.ts
Normal file
22
src/tests/cli/reflection-auto-launch-wiring.test.ts
Normal 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({");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user