/** * @fileoverview Primitive Registry — catalogs all OpenCode primitives (agents, * skills, commands, tools) with metadata, versioning, dependency tracking, and * conflict detection. Used by the control plane to enforce gatekeeper decisions * before user messages reach the agent. * * Phase 61 — CP-01, CP-02, CP-03 */ import type { ValidationResult } from "../../shared/types.js"; /** * A single cataloged OpenCode primitive with full metadata. */ export interface PrimitiveEntry { /** Primitive category. */ type: "agent" | "skill" | "command" | "tool" | "rule"; /** Unique name (filename without extension). */ name: string; /** Absolute path to the primitive file on disk. */ path: string; /** Schema version extracted from frontmatter, defaults to "0". */ version: string; /** Names of other primitives this one depends on (keyed as "type:name"). */ dependencies: string[]; /** File modification timestamp. */ lastModified: Date; /** Arbitrary frontmatter metadata. */ metadata: Record; } /** * A conflict detected between primitives. */ export interface ConflictEntry { /** Conflict classification. */ type: "duplicate-name" | "circular-dependency" | "missing-dependency"; /** Affected primitive keys (format: "type:name"). */ primitives: string[]; /** Human-readable description of the conflict. */ description: string; } /** * Complete registry snapshot at a point in time. */ export interface RegistrySnapshot { /** All discovered primitives keyed as "type:name". */ primitives: Map; /** Dependency edges: primitive key → list of depended-upon primitive keys. */ dependencyGraph: Map; /** Conflicts detected at build time. */ conflicts: ConflictEntry[]; /** When this snapshot was built. */ timestamp: Date; } /** * Scans the project's `.opencode/` directory tree for all primitives * (agents, commands, skills) and returns a cataloged snapshot. * * @param projectRoot - Absolute path to the project root directory. * @returns A {@link RegistrySnapshot} with all discovered primitives, their * dependency graph, and any detected conflicts. * * @example * ```ts * const snapshot = await buildRegistry("/path/to/project") * console.log(`Found ${snapshot.primitives.size} primitives`) * ``` */ export declare function buildRegistry(projectRoot: string): Promise; /** * Builds a dependency graph from the primitives in a snapshot. * Agents reference skills via their `skills` frontmatter field. * Commands reference agents via their `agent` frontmatter field. * * @param snapshot - The registry snapshot to analyze. * @returns Map from primitive key to its list of dependency keys. */ export declare function resolveDependencyGraph(snapshot: RegistrySnapshot): Map; /** * Detects conflicts in a registry snapshot: duplicate names across types, * missing dependencies, and circular dependencies. * * @param snapshot - The registry snapshot to analyze. * @returns Array of detected conflicts. */ export declare function detectConflicts(snapshot: RegistrySnapshot): ConflictEntry[]; /** * Validates a registry snapshot for correctness. * * @param snapshot - The registry snapshot to validate. * @returns Validation result with errors (blocking) and warnings (non-blocking). */ export declare function validateRegistry(snapshot: RegistrySnapshot): ValidationResult; //# sourceMappingURL=primitive-registry.d.ts.map