Files
oh-my-pi/packages/coding-agent/test/status-line-model.test.ts
T
can1357 37ecd3e73a feat(advisor): added advisor agent for passive code review with severity-tagged advice
- Created AdvisorRuntime and AdviseTool to drive a read-only advisor agent that delivers severity-tagged advice (nit, concern, blocker) with interruption policy and transcript delta rendering.
- Added /advisor slash command with on/off/status/dump subcommands to control advisor lifecycle and inspect advisor metrics (model, messages, tokens, cost).
- Added advisor.enabled and advisor.subagents settings to enable passive advisor review on main agent and spawned task/eval subagents.
- Implemented advisor message rendering with severity-color badges (blocker=error, concern=warning, nit=muted) in chat log and status line indicator (++ badge).
- Extended yield-queue and session-history-format to support advisor batching and optional thinking block inclusion.
2026-06-15 16:32:13 +02:00

59 lines
1.8 KiB
TypeScript

import { beforeAll, describe, expect, it } from "bun:test";
import type { SegmentContext } from "@oh-my-pi/pi-coding-agent/modes/components/status-line/segments";
import { renderSegment } from "@oh-my-pi/pi-coding-agent/modes/components/status-line/segments";
import { initTheme, theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme";
beforeAll(async () => {
await initTheme();
});
function createModelContext(advisorActive: boolean): SegmentContext {
return {
session: {
state: { model: { id: "test-model", name: "Test Model" } },
isFastModeActive: () => false,
isAutoThinking: false,
autoResolvedThinkingLevel: () => undefined,
isAdvisorActive: () => advisorActive,
} as unknown as SegmentContext["session"],
width: 120,
options: {},
planMode: null,
loopMode: null,
goalMode: null,
collab: null,
usageStats: {
input: 0,
output: 0,
cacheRead: 0,
cacheWrite: 0,
premiumRequests: 0,
cost: 0,
tokensPerSecond: null,
},
contextPercent: 0,
contextWindow: 0,
autoCompactEnabled: false,
subagentCount: 0,
sessionStartTime: Date.now(),
git: { branch: null, status: null, pr: null },
usage: null,
};
}
describe("status line model segment advisor badge", () => {
it("appends a success-colored ++ badge when the advisor is active", () => {
const rendered = renderSegment("model", createModelContext(true));
expect(rendered.content).toContain("Test Model");
// The badge carries the success color, kept distinct from the statusLineModel
// name color (which several themes alias to `accent`).
expect(rendered.content).toContain(theme.fg("success", "++"));
});
it("omits the badge when the advisor is inactive", () => {
const rendered = renderSegment("model", createModelContext(false));
expect(rendered.content).toContain("Test Model");
expect(rendered.content).not.toContain("++");
});
});