/** * Type definitions for the Skill Router */ /** * Scoring weights for each signal type */ export interface SkillWeights { keywords: number; file_extensions: number; patterns: number; file_paths: number; } /** * Global configuration settings */ export interface SkillConfig { weights: SkillWeights; activation_threshold: number; pretooluse_threshold?: number; log_path?: string; } /** * Trigger conditions for a skill */ export interface SkillTriggers { keywords?: string[]; file_extensions?: string[]; patterns?: string[]; file_paths?: string[]; } /** * A single skill definition in the manifest */ export interface SkillDefinition { path: string; name: string; description?: string; triggers: SkillTriggers; } /** * An enforced approach attached to an agent: a binding directive injected at * SubagentStart, optionally backed by a skill whose invocation is verified at * SubagentStop. */ export interface ApproachEntry { name: string; directive: string; /** Optional backing skill (directory name under .claude/skills). */ skill?: string; } /** * Per-agent entry in the manifest (file ownership patterns, enforced approaches) */ export interface AgentEntry { file_patterns?: string[]; approaches?: ApproachEntry[]; } /** * Agent Insights settings (`insights` key in `.claude/grimoire.json`) */ export interface InsightsConfig { /** Archive sub-agent transcripts on SubagentStop (default true). */ archive?: boolean; /** Sessions kept per agent type (default 20; 0 disables archiving). */ retainRunsPerAgent?: number; } /** * Global Grimoire configuration (`.claude/grimoire.json`) */ export interface GrimoireConfig { enforcement?: boolean; /** Log allowed edits to non-owned files (passthrough telemetry for tuning file_patterns). Default false. */ verboseEnforcementLog?: boolean; insights?: InsightsConfig; router?: SkillManifest; } /** * Complete skill manifest structure */ export interface SkillManifest { version: string; config: SkillConfig; skills: SkillDefinition[]; /** Optional agent configurations */ agents?: Record; } /** * Input received from Claude Code hook system via stdin */ export interface HookInput { prompt: string; session_id: string; timestamp: string; } /** * Supported tool names for PreToolUse hook */ export type ToolName = 'Edit' | 'Write' | 'MultiEdit' | 'NotebookEdit' | 'Bash'; /** * Input received from PreToolUse hook via stdin */ export interface PreToolUseInput { session_id: string; hook_event_name: 'PreToolUse'; tool_name: ToolName; tool_use_id: string; tool_input: Record; /** Unique subagent invocation id — present only when the edit originates inside a subagent. */ agent_id?: string; /** Editing agent's name (e.g. `grimoire.typescript-coder`) — present inside a subagent. */ agent_type?: string; } /** * Supported hook event types */ export type HookEventName = 'UserPromptSubmit' | 'SubagentStart' | 'SubagentStop' | 'PreToolUse'; /** * Hook-specific output data */ export interface HookSpecificOutput { hookEventName: HookEventName; additionalContext: string; } /** * Output written to stdout when skills are matched */ export interface HookOutput { hookSpecificOutput: HookSpecificOutput; } /** * PreToolUse-specific output data (includes permissionDecision) */ export interface PreToolUseSpecificOutput { hookEventName: 'PreToolUse'; additionalContext: string; permissionDecision: 'allow'; } /** * Output for PreToolUse hook */ export interface PreToolUseOutput { hookSpecificOutput: PreToolUseSpecificOutput; } /** * Signals extracted from normalized prompt */ export interface ExtractedSignals { words: Set; extensions: Set; paths: string[]; } /** * Type of matched signal */ export type MatchedSignalType = 'keyword' | 'extension' | 'pattern' | 'path'; /** * A single matched signal */ export interface MatchedSignal { type: MatchedSignalType; value: string; matchQuality?: 'exact' | 'stem' | 'fuzzy'; } /** * Reference to a skill (minimal info for results) */ export interface SkillReference { path: string; name: string; } /** * Result of scoring a single skill */ export interface SkillScoreResult { skill: SkillReference; score: number; matchedSignals: MatchedSignal[]; } /** * CLI arguments parsed from process.argv */ export interface ParsedArgs { /** Run enforcement check (PreToolUse) */ enforce?: boolean; /** Emit subagent-spawned telemetry (SubagentStart) */ subagentStart?: boolean; /** Emit subagent-finished telemetry (SubagentStop) */ subagentStop?: boolean; } /** * Result of evaluateEnforce — either allow or block with matching agent names */ export interface EnforceDebugInfo { rawFilePath: string; normalizedPath: string; relativePath: string; patternsChecked: string[]; } export type EnforceResult = { action: 'allow'; debugInfo?: EnforceDebugInfo; ownerAgent?: string; } | { action: 'block'; agents: string[]; /** Owned path that triggered the block; for Bash, the offending token. */ filePath: string; /** Set when the block came from a shell command rather than an edit tool. */ via?: 'bash'; /** Truncated command text for the log — never the full string (may carry secrets). */ commandExcerpt?: string; }; /** * Input for SubagentStart/Stop hooks — telemetry logging and transcript archiving. */ export interface SubagentHookInput { session_id: string; /** Unique subagent invocation id. */ agent_id?: string; /** Subagent's name (e.g. `grimoire.typescript-coder`). */ agent_type?: string; /** SubagentStop only: `success` | `cancelled` | `error`. */ stop_reason?: string; /** Main session transcript path (`…/projects//.jsonl`). */ transcript_path?: string; /** Exact sub-agent transcript path, supplied directly by newer Claude Code. */ agent_transcript_path?: string; /** Project working directory the session runs in. */ cwd?: string; } /** * Summary of extracted signals for logging */ export interface SignalsExtractedSummary { words_count: number; extensions: string[]; paths: string[]; } /** * Matched skill info for logging */ export interface MatchedSkillLogEntry { name: string; path: string; score: number; matched_signals: MatchedSignal[]; } /** * Outcome of skill router execution */ export type LogOutcome = 'activated' | 'no_match' | 'error' | 'blocked'; /** * Log entry for an agent enforcement block (PreToolUse) */ export interface EnforceBlockLogEntry { timestamp: string; session_id: string; hook_event: 'PreToolUse'; tool_name: string; outcome: 'blocked'; enforce_block: true; file_basename: string; blocking_agents: string[]; /** Present when the block came from a shell command rather than an edit tool. */ via?: 'bash'; /** The owned path token found in the command. */ matched_token?: string; /** Truncated command text — never the full string (may carry secrets). */ command_excerpt?: string; } /** * Log entry for sub-agent lifecycle telemetry. */ export interface SubagentLogEntry { timestamp: string; hook_event: 'SubagentStart' | 'SubagentStop'; session_id: string; agent_id: string | null; agent_type: string | null; stop_reason?: string | null; archived?: boolean; /** Runtime-invoked skills observed in the transcript at SubagentStop. */ skills_activated?: string[]; /** Approach names injected into the sub-agent's context at SubagentStart. */ approaches_enforced?: string[]; /** SubagentStop adherence-check outcome (only when approaches are configured). */ approach_check?: 'passed' | 'bounced' | 'skipped'; /** Approach names violated (present only when bounced). */ approach_violations?: string[]; } /** * Complete log entry structure */ export interface LogEntry { timestamp: string; session_id: string; prompt_raw: string; prompt_normalized: string; signals_extracted: SignalsExtractedSummary; skills_evaluated: number; skills_matched: MatchedSkillLogEntry[]; threshold: number; execution_time_ms: number; outcome: LogOutcome; } /** * Log level for error entries */ export type LogLevel = 'error' | 'warning' | 'info'; /** * Error log entry structure */ export interface ErrorLogEntry { timestamp: string; level: LogLevel; message: string; error_type: string; details: Record | null; stack_trace: string | null; } //# sourceMappingURL=types.d.ts.map