/** * Brainstorm Registry Layer (Phase 3) * * Pure functions that load and query the brainstorm-eligible agent registry. * * Responsibilities: * 1. Load .pi/senai/agents.json + discovered agents from .pi/agents/*.md. * 2. Filter to the 6 brainstorm-eligible roles (BRAINSTORM_ELIGIBLE_ROLES). * 3. Match a user topic to the best specialist via keyword scoring. * 4. Render the registry as a markdown block for the stage prompt. * * This module does NOT spawn subagents — that lives in dispatcher.ts (Phase 4). * It does NOT write to the audit log — that lives in audit.ts (Phase 5). * * Pure where possible; loadBrainstormRegistry is the only I/O entry point. */ import type { MissionType, ScanType } from "../core/state.js"; import { type MissionPack } from "../core/mission-packs.js"; import { type SenaiRole } from "../core/agents-config/suggestions.js"; /** Which roles serve which scan type at the scan-plan gate. * - code: pattern/flow search + risk/dependency audit of the codebase * - doc: PRD/docs audit + architecture/big-picture read of internal docs * - community: external web research * planner stays available during DISCUSS (trade-offs) but is not a scanner. */ export declare const SCAN_TYPE_ROLES: Record; /** Stages a brainstorm mission can walk, in fixed trunk order. "decide" is the * explore-only terminal door (go / clarify / kill) that replaces the * approve → plan → implement road. */ export type BrainstormStage = "understand" | "confirm" | "scans" | "discuss" | "approve" | "plan" | "implement" | "document" | "deliver" | "decide"; export interface MissionSequence { /** Ordered stages for this mission type. */ readonly stages: readonly BrainstormStage[]; /** Scan types pre-selected at the scan-plan gate (user can still change). */ readonly defaultScans: readonly ScanType[]; /** Which UNDERSTAND follow-up question pack the skill should use. */ readonly questionPack: MissionType; /** One-line type description rendered in the sealed prompt's type list. * Lives here so the prompt has no hardcoded copy that can drift. */ readonly summary: string; /** Lifecycle pack for this type — extra brief sections, conditional * scans, hard gates, implement rules, NEVER list (core/mission-packs.ts). */ readonly pack: MissionPack; } /** One pipeline, custom sequence per mission type. The skill file and the * brainstorm/plan commands read this map — adding a type is one entry. */ export declare const MISSION_SEQUENCE: Record; /** True when this mission type walks the plan → implement road after approve. * explore does not — it ends at the decide door. */ export declare function missionUsesPlanRoad(type: MissionType): boolean; /** One brainstorm-eligible agent, ready to be dispatched. */ export interface BrainstormEligibleAgent { role: SenaiRole; /** Resolved agent name (mapped in agents.json, suggested, or default). */ agentName: string; /** Short mandate hint, used by buildRegistryBlock. */ mandate: string; /** Tool allowlist the agent receives at dispatch time (Phase 4 strips * Write/Edit). Surfaced here so the registry block + audit log agree. */ tools: readonly string[]; /** Keywords matchSpecialist uses to score topics for this role. */ matchKeywords: readonly string[]; } /** Load the brainstorm-eligible registry for a project. * * The registry contains one entry per BRAINSTORM_ELIGIBLE_ROLES role, * filtered by what the project has configured. Roles the user has not * mapped and that have no default agent are skipped (they cannot be * dispatched anyway). * * Returns an empty list when no agents.json exists AND no defaults * resolve — the parent LLM still proceeds, just with no specialist * options in the dispatch tree. */ export declare function loadBrainstormRegistry(cwd: string): BrainstormEligibleAgent[]; /** Minimum score for matchSpecialist to return a non-null result. A topic * must mention at least one keyword to qualify. */ export declare const MATCH_SCORE_THRESHOLD = 1; /** Find the best specialist for a topic. Returns null when no eligible * agent matches above the threshold. The parent LLM uses the suggestion * but remains the final decider. */ export declare function matchSpecialist(registry: BrainstormEligibleAgent[], topic: string): BrainstormEligibleAgent | null; /** Return the top-N agents sorted by score. Useful for prompts that want * a ranked list rather than a single suggestion. */ export declare function rankSpecialists(registry: BrainstormEligibleAgent[], topic: string, limit?: number): BrainstormEligibleAgent[]; /** Render the registry as a markdown block the parent LLM can read. The * block is injected into the stage prompt by commands/brainstorm.ts. * * Format: * ## Brainstorm-eligible agents * * The following agents may be dispatched during brainstorm for read-only * research. Use `subagent({ agent: , task: , * expected_output: })`. Max 3 dispatches per brainstorm. * * | Role | Agent | Mandate | Match keywords | * | scout-1 | scout | architecture recon | architecture, system, big-picture | * | ... * * Suggested match for "": → * (or: no specialist matched — answer inline.) */ export declare function buildRegistryBlock(registry: BrainstormEligibleAgent[], topic?: string): string;