/** * `specweave jev` — the local-environment half of the command. * * Argument parsing, the shipped-skill roster, `.specweave/config.json` writes, the * shared exit codes and printers, and the two environment subcommands (`doctor`, * `setup`). `jev.ts` keeps the dispatcher and the decision subcommands. * * Nothing here ever reads, prints or stores an API key VALUE — only env var NAMES. * * @module cli/commands/jev-helpers */ import { JevClient, runBrowse, type Json, type Question } from '../../core/jev/index.js'; /** Exit codes shared by every `specweave jev` subcommand (documented in the skill). */ export declare const EXIT: { readonly ok: 0; readonly error: 1; readonly warn: 2; readonly deny: 3; /** Jev is disabled or has no key — agents treat this as "continue without Jev". */ readonly unavailable: 4; }; /** Where the opt-in PreToolUse Bash guard marker lives. */ export declare function guardMarkerPath(projectRoot: string): string; /** Create or remove the Bash guard marker. Returns true when the marker exists after the call. */ export declare function setGuardMarker(projectRoot: string, on: boolean): boolean; /** * Merge a patch into the `jev` section of `.specweave/config.json`, keeping every * other key (and every other jev key) untouched. Returns the config path written. */ export declare function mergeJevConfig(projectRoot: string, patch: Record): string; /** The installed specweave package root (walks up from this module). */ export declare function packageRoot(): string; export interface ProjectHookState { /** Absolute path of `/.claude/settings.json` (whether or not it exists). */ path: string; present: boolean; /** Set when the settings file could not be read or written; it was left untouched. */ error?: string; } /** `/.claude/settings.json`. */ export declare function projectSettingsPath(projectRoot: string): string; /** * The exact command the hook entry runs. * * Absolute, because `CLAUDE_PLUGIN_ROOT` is NOT set for hooks declared in * settings.json — `${CLAUDE_PLUGIN_ROOT}` would expand to nothing. `run.mjs` * resolves its own plugin root from `import.meta.url`, so an absolute path is * all it needs. */ export declare function jevHookCommand(root?: string, scope?: HookScope): string; /** * `user`: the entry sits in `~/.claude/settings.json` and so runs in every * project; the launcher passes it at once unless an opted-in project's marker * is found (and defers to that project's own entry when Claude loaded it). */ export type HookScope = 'project' | 'user'; /** Matcher of the required-increment guard's PreToolUse group. */ export declare const EDIT_HOOK_MATCHER = "Edit|Write|MultiEdit|NotebookEdit"; /** Is the SpecWeave PreToolUse hook registered for `matcher` (default: the Jev Bash guard) right now? */ export declare function readProjectHook(projectRoot: string, matcher?: string): ProjectHookState; /** * Register or remove the Jev Bash guard in `/.claude/settings.json`. * * Idempotent: an entry already pointing at a `hooks/run.mjs pre-tool-use` is * rewritten in place (so a moved or reinstalled package updates rather than * duplicates) and never reordered. Removal takes out exactly our entries — other * PreToolUse groups survive — and then deletes the empty array and keys it left * behind. Every other key in the file is preserved byte-for-byte through the * JSON round trip. * * A settings.json that is missing or malformed is never overwritten blind: a * malformed file comes back as `{ error }` and is left exactly as it was. */ export declare function setProjectHook(projectRoot: string, on: boolean, packageDir?: string, matcher?: string, scope?: HookScope): ProjectHookState; export interface SkillEntry { name: string; description: string; } /** * Roster used when the shipped `plugins/specweave/skills/` tree cannot be read * (global install layouts differ). Keeps `jev route` useful everywhere. */ export declare const FALLBACK_SKILLS: readonly SkillEntry[]; /** * Shipped skill names + their frontmatter descriptions, for the SKILL_ROUTE question. * Falls back to {@link FALLBACK_SKILLS} when the plugin tree is unreadable. */ export declare function skillRoster(root?: string): SkillEntry[]; export interface ReadSources { cwd: string; /** Injected stdin (tests); when absent stdin is read from fd 0. */ stdin?: string; } /** Read stdin synchronously. Returns '' when there is nothing to read. */ export declare function readStdin(src: ReadSources): string; /** * Resolve a `--state` / `--questions` style argument: * `-` → stdin, `@path` → file contents, anything else → the literal value. */ export declare function readArgValue(value: string | undefined, src: ReadSources): string | undefined; /** Resolve a `[file|-]` positional: missing or `-` → stdin, otherwise the file. */ export declare function readFileOrStdin(value: string | undefined, src: ReadSources): string; /** JSON when the text parses as JSON, the plain string otherwise. */ export declare function parseJsonOrText(text: string): Json; /** Parse a `--questions` payload into the client's question map. */ export declare function parseQuestions(text: string): Record; /** Split repeatable `key=value` flags (`--option`, `--input`) into a record. */ export declare function parseKeyValues(list: string[] | undefined, flag: string): Record; /** * Build questions from the `--choice` / `--option` / `--noul` shorthands. * Returns an empty map when no shorthand was used. */ export declare function shorthandQuestions(opts: { choice?: string; option?: string[]; noul?: string; }): Record; /** Body of a `## ` section of a markdown doc, up to the next `## `. */ export declare function extractSection(markdown: string, heading: string): string; /** `0.0000155` → `$0.0000155`; small enough that toFixed(2) would read as $0.00. */ export declare function formatCost(cost: number | undefined): string; /** `{a: 0.91, b: 0.09}` → `a 0.91 · b 0.09`, highest first, top 5. */ export declare function formatProbabilities(probabilities: Record): string; export interface JevCommandOptions { json?: boolean; provider?: string; model?: string; guardBash?: boolean; disable?: boolean; state?: string; questions?: string; choice?: string; option?: string[]; noul?: string; increment?: string; goal?: string; url?: string; allowDomain?: string[]; input?: string[]; maxSteps?: string | number; screenshotDir?: string; allowSensitive?: boolean; cwd?: string; env?: NodeJS.ProcessEnv; fetch?: typeof fetch; client?: JevClient; stdin?: string; browse?: typeof runBrowse; } export declare const out: (s: string) => void; export declare const err: (s: string) => void; export declare const json: (value: unknown) => void; export declare function messageOf(error: unknown): string; export declare function jevDoctor(root: string, env: NodeJS.ProcessEnv, opts: JevCommandOptions): Promise; export declare function jevSetup(root: string, env: NodeJS.ProcessEnv, opts: JevCommandOptions): Promise; //# sourceMappingURL=jev-helpers.d.ts.map