import type { ToolCategory } from './harness.js'; /** Input from Claude Code PreToolUse/PostToolUse hooks (JSON on stdin) */ export interface HookInput { session_id: string; transcript_path?: string; cwd: string; permission_mode?: string; hook_event_name: string; tool_name?: string; tool_input?: Record; tool_response?: Record; tool_use_id?: string; } /** Output for PreToolUse hooks */ export interface PreToolUseOutput { hookSpecificOutput: { hookEventName: 'PreToolUse'; permissionDecision?: 'allow' | 'deny' | 'ask'; permissionDecisionReason?: string; additionalContext?: string; updatedInput?: Record; }; } /** Output for PostToolUse hooks */ export interface PostToolUseOutput { decision?: 'block'; reason?: string; hookSpecificOutput?: { hookEventName: 'PostToolUse'; additionalContext?: string; }; } /** Output for Stop hooks */ export interface StopOutput { decision?: 'block'; reason?: string; } /** A structured option within a suggestion */ export interface SuggestionOption { id: string; label: string; description?: string; /** Slash command or CLI command to run if selected */ command?: string; } /** A structured suggestion with options for the agent to present */ export interface Suggestion { id: string; title: string; context: string; options: SuggestionOption[]; /** If true, agent must present and wait for user choice */ requiresDecision: boolean; priority?: 'critical' | 'high' | 'normal'; } /** Machine-readable reason code recorded in guard metrics. */ export type GuardMetricReason = 'no-file-path' | 'no-match' | 'deduped' | 'irrelevant-command' | 'state-unavailable' | 'adhoc-session' | (string & {}); /** A guard's response — what guidance to inject */ export interface GuardResult { /** Text injected into the agent's context */ context?: string; /** For PreToolUse: permission decision */ decision?: 'allow' | 'deny' | 'ask'; /** For Stop/PostToolUse: block reason */ blockReason?: string; /** Structured suggestion — adapter formats for platform */ suggestion?: Suggestion; /** Optional machine-readable reason for metrics; never emitted to hook output */ metricReason?: GuardMetricReason; } /** Known guard names */ export type GuardName = 'explore' | 'hazard' | 'commit-nudge' | 'scope-drift' | 'shell-write' | 'compaction' | 'stop-check' | 'subagent-gate' | 'push-nudge' | 'workflow-gate' | 'review-tier' | 'version-check' | 'stale-flows' | 'next-action' | 'pr-review' | 'transcript' | 'branch-before-commit' | 'worktree-check' | 'sprint-completion' | 'worktree-merge' | 'worktree-self-remove' | 'session-briefing' | 'post-push' | 'phase-boundary' | 'claim-required' | 'review-stale' | 'worktree-reuse' | 'workflow-step-gate' | 'roadmap-edit-shipped' | 'post-hole-enforcement'; /** Guard registration entry */ export interface GuardDefinition { name: GuardName; description: string; /** Which hook event this guard fires on */ hookEvent: 'PreToolUse' | 'PostToolUse' | 'Stop' | 'PreCompact'; /** Harness-agnostic tool categories this guard matches (adapter resolves to tool names) */ toolCategories?: ToolCategory[]; /** Regex matcher for tool name (PreToolUse/PostToolUse only) — computed from toolCategories via adapter */ matcher?: string; /** Which --level installs this guard: scoring (minimal), essential (mechanical guards only), full (all) */ level: 'scoring' | 'essential' | 'full'; /** Guard enforcement type: mechanical (blocks), advisory (warns), or mixed */ guardType?: 'mechanical' | 'advisory' | 'mixed'; } /** Guidance configuration fields for .slope/config.json */ export interface GuidanceConfig { /** Disabled guard names */ disabled?: string[]; /** File paths to check for codebase index (explore guard) */ indexPaths?: string[]; /** Number of sprints to look back for hazards (default 5) */ hazardRecency?: number; /** Minutes before commit nudge fires (default 15) */ commitInterval?: number; /** Minutes before push nudge fires (default 30) */ pushInterval?: number; /** Enable scope drift detection (default true) */ scopeDrift?: boolean; /** Max turns for Explore subagents (default 10) */ subagentExploreTurns?: number; /** Max turns for Plan subagents (default 15) */ subagentPlanTurns?: number; /** Models allowed for Explore/Plan subagents (default ['haiku']) */ subagentAllowModels?: string[]; /** Unpushed commit count before push nudge fires (default 5) */ pushCommitThreshold?: number; /** Directory for compaction handoff files (default '.slope/handoffs') */ handoffsDir?: string; /** Commit message patterns allowed on main/master (branch-before-commit guard) */ allowMainCommitPatterns?: string[]; /** Branch names treated as protected (default: ['main', 'master']) */ protectedBranches?: string[]; /** Commits behind before explore guard warns (default 11) */ mapStaleWarnAt?: number; /** Commits behind before explore guard blocks Edit/Write (default 31) */ mapStaleBlockAt?: number; /** How claim-required handles implementation writes outside active sprint/claim flow (default ask) */ requireSprintForImplementationWrites?: 'ask' | 'deny' | 'off'; } /** All guard definitions */ export declare const GUARD_DEFINITIONS: GuardDefinition[]; /** A custom guard defined by a plugin (not constrained to GuardName union) */ export interface CustomGuardDefinition { name: string; description: string; hookEvent: 'PreToolUse' | 'PostToolUse' | 'Stop' | 'PreCompact'; matcher?: string; /** Harness-agnostic tool categories this guard applies to */ toolCategories?: ToolCategory[]; level: 'scoring' | 'full'; command: string; /** Guard enforcement type: mechanical (blocks), advisory (warns), or mixed */ guardType?: 'mechanical' | 'advisory' | 'mixed'; } /** Union type for functions that accept both built-in and custom guards */ export type AnyGuardDefinition = GuardDefinition | CustomGuardDefinition; /** Register a custom guard plugin. Idempotent — skips if name already registered. */ export declare function registerCustomGuard(guard: CustomGuardDefinition): void; /** Returns all guard definitions: built-in + custom */ export declare function getAllGuardDefinitions(): AnyGuardDefinition[]; /** Look up a custom guard by name */ export declare function getCustomGuard(name: string): CustomGuardDefinition | undefined; /** Clear all custom guards (for testing) */ export declare function clearCustomGuards(): void; /** Format a GuardResult as PreToolUse JSON output */ export declare function formatPreToolUseOutput(result: GuardResult): PreToolUseOutput; /** Format a GuardResult as PostToolUse JSON output */ export declare function formatPostToolUseOutput(result: GuardResult): PostToolUseOutput; /** Format a GuardResult as Stop JSON output */ export declare function formatStopOutput(result: GuardResult): StopOutput; /** * Generate Claude Code settings.json hooks configuration for installed guards. * Delegates to ClaudeCodeAdapter.generateHooksConfig(). */ export declare function generateClaudeCodeHooksConfig(guards: AnyGuardDefinition[], guardScriptPath: string): Record; }>>; //# sourceMappingURL=guard.d.ts.map