/** * Agent frontmatter: schema, validation, and Claude Code compatibility shim. * * Agent definitions are Markdown files with YAML frontmatter, mirroring the * Claude Code subagent format so `.claude/agents/*.md` files import natively: * * --- * name: explore * description: When and why to use this agent (drives auto-delegation). * tools: Read, Grep, Glob, Bash # optional allowlist; omit = inherit all * model: sonnet # optional; sonnet|opus|haiku|inherit|pattern * --- * * * The body becomes the subagent system prompt. Validation is non-fatal: we emit * diagnostics (warnings) and still load the agent when possible, matching the * behavior of skills.ts. */ import type { ResourceDiagnostic } from "./diagnostics.js"; /** Where an agent definition came from. Used for precedence and diagnostics. */ export type AgentSource = "builtin" | "user" | "project" | "claude-user" | "claude-project"; /** Sentinel meaning "use the parent session's model" (Claude Code `model: inherit`). */ export declare const MODEL_INHERIT = "inherit"; /** * The built-in hoocode tools that an agent's `tools` allowlist is normalized * against; unknown tools are dropped with a diagnostic. Includes the opt-in web * tools (webfetch/websearch) so Claude Code's WebFetch/WebSearch map through. */ export declare const HOOCODE_TOOL_NAMES: readonly string[]; /** * Canonical registered names of the two opt-in tools. These are case-sensitive * identifiers the system prompt and tool gating match exactly, so downstream * callers should reference these constants instead of hardcoding the strings * (a mis-cased `"task"` silently disables the agents/skills prompt sections). */ export declare const TASK_TOOL_NAME = "Task"; export declare const TODO_WRITE_TOOL_NAME = "TodoWrite"; /** * D7 — Claude Code compatibility shim. * * Maps Claude Code tool names (case-insensitive) to their hoocode equivalents. * Claude tools without a hoocode counterpart (MultiEdit, Task, TodoWrite, * NotebookEdit, MCP tools, ...) are intentionally absent and get dropped during * normalization. * * `grep`/`glob`/`find` all land on `SearchCodebase`, the single code-discovery * tool that replaced the old grep/find/ls trio. `ls` has no counterpart at all — * directory listing is a shell job now — so it is deliberately absent and gets * dropped with a diagnostic rather than silently widening an agent to `bash`. * * Lookups are lower-cased, so every hoocode tool needs its own lower-case key * here to survive normalization; the `searchcodebase` entry is that case-folding * for `SearchCodebase`, not a legacy alias. `search` is deliberately absent: the * tool was renamed with no backward lookup, so an agent still naming it is * dropped with a diagnostic. */ export declare const CLAUDE_TOOL_ALIASES: Readonly>; /** A validated, normalized agent definition. */ export interface AgentDefinition { name: string; description: string; /** * Resolved hoocode tool allowlist. `undefined` means "inherit all parent * tools" (Claude Code behavior when `tools` is omitted). */ tools?: string[]; /** Resolved denylist subtracted from the agent's tool set. */ disallowedTools?: string[]; /** * Model alias/pattern, the `inherit` sentinel, or `undefined` for the * subagent default. */ model?: string; /** System prompt body (frontmatter stripped). */ prompt: string; /** Origin of this definition. */ source: AgentSource; /** Absolute path of the source file, when loaded from disk. */ filePath?: string; /** hoocode extension: optional per-agent turn cap. */ maxTurns?: number; /** When true, dispatch is non-blocking: the parent receives a handle and polls for the result. */ background?: boolean; /** When true, this agent may delegate via the Task tool, subject to the nesting cap. */ delegate?: boolean; /** Restricts delegation to these subagent types (undefined = any when `delegate` is true). */ delegateTo?: string[]; /** When true, the agent inherits the parent's full conversation (a fork). */ fork?: boolean; } /** * Normalize a raw `tools` allowlist into hoocode tool names via the Claude Code * alias map. Returns the deduped, resolved list plus diagnostics for any tokens * that could not be mapped. * * Emits a warning when `value` is a YAML list rather than a comma-separated * string — the Claude Code standard format is `tools: read, bash` (string). */ export declare function normalizeTools(value: string | string[], filePath?: string): { tools: string[]; diagnostics: ResourceDiagnostic[]; }; /** * Normalize a `model` frontmatter value. `inherit` is preserved as a sentinel; * any other non-empty string is passed through to the model resolver as-is * (so Claude aliases like `sonnet`/`opus`/`haiku` resolve via pattern match). */ export declare function normalizeModel(value: string | undefined): string | undefined; /** * Parse and validate a single agent definition from raw Markdown content. * * `fallbackName` is used when frontmatter omits `name` (e.g. the filename, or * the embedded-template key). Returns `agent: null` only when the definition * is unusable (missing description). Other problems surface as diagnostics. */ export declare function parseAgentDefinition(rawContent: string, options: { source: AgentSource; filePath?: string; fallbackName?: string; }): { agent: AgentDefinition | null; diagnostics: ResourceDiagnostic[]; }; //# sourceMappingURL=agent-frontmatter.d.ts.map