feat(backends): multi-backend intelligence layer — LLM + Agent backends, persona-loading agents, honest CLI commands

Add IntelligenceBackend abstraction with two categories:
- LLMBackend (OllamaLocal, OllamaCloud): CI runs tool loop, provides tools, constructs prompts
- AgentBackend (Opencode): agent runs own tool loop, CI serializes request

Refactor all 18 agents from hardcoded stubs to persona loaders that delegate
to the active backend or fail honestly when no backend is available.

Refactor OrchestratorAgent.executeStage() from monolithic switch to agent
delegation via STAGE_AGENT_MAP for intelligent stages (research, plan, execute,
verify), with mechanical stages (specify, clarify, complete) staying inline.

Wire CLI commands with --backend flag and auto-detection (opencode →
ollama-local → ollama-cloud). Harden rollback/ship with real git operations.
No command returns fake success.
This commit is contained in:
CI
2026-05-29 15:58:34 +00:00
parent ddf04792c7
commit 940b85bfae
33 changed files with 1828 additions and 100 deletions
+14 -5
View File
@@ -3,17 +3,26 @@ import { BaseAgent, AgentContext, AgentResult } from "./base.js";
export class PlannerAgent extends BaseAgent {
readonly name = "planner";
readonly description = "Creates phase plans with tasks. Never sets autonomous:false — decomposes into verifiable subtasks.";
readonly workflow = "plan";
async execute(context: AgentContext): Promise<AgentResult> {
this.log("Creating phase plan...");
const start = Date.now();
this.log("Creating phase plan...");
if (context.backend) {
const result = await this.executeViaBackend(
context,
`Create a phase plan for stage ${context.stage}, phase ${context.phase}. Specification: ${context.specification}`
);
return { ...result, duration_ms: Date.now() - start };
}
return {
success: true,
output: "Plan created with verifiable subtasks",
artifacts_created: ["PLAN.md"],
decisions: 1,
success: false,
output: "Planning requires an intelligence backend. Configure one with: ci init --backend",
artifacts_created: [],
decisions: 0,
escalations: 0,
duration_ms: Date.now() - start,
error: "No intelligence backend available",
};
}
}