a8b50f5109
---ci---
project: ci
phase: 6
milestone: v0.9
status: complete
artifacts:
tags: [v0.9.0]
decisions:
- id: D-047
decision: v0.9 theme = Distribution & Expansion
rationale: npm publish + OpenAI/Anthropic backends + agent flesh + parallel execution
confidence: 0.92
- id: D-049
decision: Feature milestone — patch tags v0.8.1-v0.8.6 then v0.9.0
rationale: OpenAI backend, agent flesh, npm publish all feat
confidence: 0.95
- id: D-059
decision: Rename OllamaBaseBackend to LLMBaseBackend + thin OllamaBaseBackend subclass
rationale: 15 of 17 methods backend-agnostic
confidence: 0.92
- id: D-060
decision: OpenAI/Anthropic backends use native fetch() not SDK packages
rationale: No dependency bloat; fetch native in Node 18+
confidence: 0.85
- id: D-066
decision: Concurrency limiter internal (no p-limit dependency)
rationale: 15 lines; avoids dependency for trivial feature
confidence: 0.90
- id: D-067
decision: Promise.allSettled for review agents at orchestrator lines 373-400
rationale: Current sequential loop replaced with parallel execution
confidence: 0.88
requirements:
covered: [PUBLISH-01, PUBLISH-02, PUBLISH-03, PUBLISH-04, OPENAI-01, OPENAI-02, OPENAI-03, OPENAI-04, OPENAI-05, FLESH-01, FLESH-02, FLESH-03, FLESH-04, FLESH-05, ANTHROPIC-01, ANTHROPIC-02, FLESH-06, FLESH-07, NPM-01, NPM-02, PARALLEL-01, PARALLEL-02, PARALLEL-03, INTEG-01, INTEG-02, INTEG-03, INTEG-04, INTEG-05]
---/ci---
6 phases, 28 tasks, 4077 net lines added, 57 test suites, 527 tests, zero stub agents
74 lines
2.5 KiB
TypeScript
74 lines
2.5 KiB
TypeScript
import * as fs from "node:fs";
|
|
import * as path from "node:path";
|
|
import * as os from "node:os";
|
|
import { PhaseResearcherAgent } from "../agents/phase-researcher.js";
|
|
|
|
describe("PhaseResearcherAgent", () => {
|
|
let tempDir: string;
|
|
|
|
beforeEach(() => {
|
|
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "ciagent-phase-researcher-test-"));
|
|
fs.mkdirSync(path.join(tempDir, ".git"), { recursive: true });
|
|
});
|
|
|
|
afterEach(() => {
|
|
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
});
|
|
|
|
it("extracts decisions from commit log content", () => {
|
|
const agent = new PhaseResearcherAgent();
|
|
const result = agent.extractDecisions(
|
|
`some commit\n---ci---\nphase: 1\ndecisions:\n - D-101: Use SQLite for storage confidence: 0.9\n - D-102: Retry on failure confidence: 0.3\n---/ci---\n`
|
|
);
|
|
|
|
expect(result.length).toBe(2);
|
|
expect(result[0].id).toBe("D-101");
|
|
expect(result[0].confidence).toBe(0.9);
|
|
expect(result[1].id).toBe("D-102");
|
|
expect(result[1].confidence).toBe(0.3);
|
|
});
|
|
|
|
it("extracts lessons from commit log content", () => {
|
|
const agent = new PhaseResearcherAgent();
|
|
const result = agent.extractLessons(
|
|
`some commit\n---ci---\nphase: 1\nlessons:\n - testing: Flaky tests are a problem\n - build: CI timeouts\n---/ci---\n`
|
|
);
|
|
|
|
expect(result.length).toBe(2);
|
|
expect(result[0]).toContain("testing");
|
|
});
|
|
|
|
it("identifies risks from low-confidence decisions and repeated lessons", () => {
|
|
const agent = new PhaseResearcherAgent();
|
|
const decisions = [
|
|
{ id: "D-1", decision: "Risky choice", confidence: 0.4 },
|
|
{ id: "D-2", decision: "Safe choice", confidence: 0.9 },
|
|
];
|
|
const lessons = [
|
|
"testing: Flaky tests",
|
|
"testing: More flaky tests",
|
|
"build: CI timeouts",
|
|
];
|
|
|
|
const risks = agent.identifyRisks(decisions, lessons);
|
|
|
|
const highRisk = risks.filter((r) => r.severity === "high");
|
|
expect(highRisk.length).toBeGreaterThan(0);
|
|
expect(highRisk.some((r) => r.description.includes("D-1"))).toBe(true);
|
|
});
|
|
|
|
it("handles empty git log gracefully", () => {
|
|
const agent = new PhaseResearcherAgent();
|
|
const result = agent.mechanicalPhaseResearch(tempDir, 1);
|
|
|
|
expect(result.phase).toBe(1);
|
|
expect(result.decisions).toEqual([]);
|
|
expect(result.lessons).toEqual([]);
|
|
expect(result.risks).toEqual([]);
|
|
});
|
|
|
|
it("agent name is phase-researcher", () => {
|
|
const agent = new PhaseResearcherAgent();
|
|
expect(agent.name).toBe("phase-researcher");
|
|
});
|
|
}); |