/** * Shared utilities for hook handlers. * * @module core/hooks/handlers/utils */ import type { HookContext, HookInput } from './types.js'; /** Single JSONL hook log per project; rotated once when it exceeds this size. */ export declare const HOOK_LOG_FILE = "hooks.jsonl"; export declare const HOOK_LOG_MAX_BYTES: number; export type HookLogLevel = 'warn' | 'error' | 'block'; /** * Walk up from `startDir` to find the nearest directory containing `.specweave/config.json`. * Returns the project root path, or null if not found. */ export declare function findProjectRoot(startDir?: string): string | null; /** Build a HookContext from a project root path. */ export declare function createContext(projectRoot: string): HookContext; /** Parse a raw stdin string as JSON. Returns empty object on failure. */ export declare function parseStdinJson(raw: string): HookInput; /** Normalize a path for matching: backslashes → forward slashes. */ export declare function normalizePath(p: string): string; export declare function getToolName(input: HookInput): string; export declare function getToolInput(input: HookInput): Record; /** The normalized `tool_input.file_path` ('' when absent). */ export declare function getFilePath(input: HookInput): string; /** True when the (normalized) path is inside a `.specweave/increments/` tree. */ export declare function isIncrementFile(filePath: string): boolean; /** `0874-crawl-coverage` from any increment path; 'unknown' otherwise. */ export declare function extractIncrementId(filePath: string): string; /** Read + parse JSON, null on any failure. */ export declare function readJsonSafe>(filePath: string): T | null; /** * Active increment ids: `.specweave/state/active-increment.json` (`{ids:[]}`) * first, falling back to a metadata.json scan for status active|in-progress. * Only ids whose folder still exists are returned. */ export declare function readActiveIncrements(projectRoot: string): string[]; /** * Append one JSONL line to `.specweave/logs/hooks.jsonl`. Only warnings, * errors and blocks are logged (no per-invocation noise). The file is rotated * to `hooks.jsonl.1` once it exceeds {@link HOOK_LOG_MAX_BYTES}. Never throws. */ export declare function logHook(context: HookContext, handler: string, message: string, level?: HookLogLevel): void; //# sourceMappingURL=utils.d.ts.map