import { Rule } from './rule.js'; /** * Agent instruction files executed verbatim by an agent: `SKILL.md` anywhere; * markdown under `skills/`, `commands/`, or `agents/` of an agent config tree * (.agents, .claude, .cursor, .codex, .opencode) or of a Claude Code plugin * (`plugins//...`); Windsurf rules/workflows (`.windsurf/rules|workflows`, * `.windsurfrules`); Cline rules (`.clinerules/` dir or file, `.cursorrules`); * Cursor rule files (`.cursor/rules/*.mdc`); Gemini CLI custom commands * (`.gemini/commands/**.toml` and extension-root `commands/**.toml`, * prompt text with `!{...}` shell blocks); * Continue.dev workspace rules and prompts (`.continue/rules|prompts/*.md`, * injected into the model context); Trae project rules (`.trae/rules/*.md`, * plus the older `.trae/project_rules.md` / `.trae/user_rules.md`); Kiro * steering files (`.kiro/steering/*.md`, auto-loaded into every session); * Roo Code rules (`.roo/rules/` and mode-specific `.roo/rules-/` * directories, plus the single-file `.roorules` / `.roorules-`) and * project slash commands (`.roo/commands/*.md`, the filename becomes the * /command name); * root instruction files read verbatim by many agents — the agents.md * standard (`AGENTS.md`/`AGENT.md`, nested files apply to subtrees), * `CLAUDE.md`, `GEMINI.md`, Zed's `.rules`, and GitHub Copilot's * `.github/copilot-instructions.md`, path-specific * `.github/instructions/**.instructions.md`, prompt files * `.github/prompts/*.prompt.md`, and custom agents (`.github/agents/*.md`, * VS Code loads any .md in that folder as an agent — typically * `*.agent.md` / legacy `*.chatmode.md`) and the legacy chat-mode folder * (`.github/chatmodes/*.chatmode.md`, still loaded); Amazon Q Developer project rules * (`.amazonq/rules/**.md`, auto-loaded as chat context, subdirs allowed); JetBrains Junie * project guidelines (`.junie/guidelines.md`, auto-loaded into every Junie task); * OpenHands repository customization (`.openhands/skills/**.md` and the legacy * `.openhands/microagents/**.md`, auto-loaded as agent context per trigger or always); * goose local hints (`.goosehints` at the project root or in any directory, * added to the system prompt for every request in that tree); Factory Droid * repository customization (`.factory/skills/**.md` skill trees, * `.factory/commands/**.md` slash-command prompts, and `.factory/droids/*.md` * custom-droid system prompts, all loaded from the repo); Google Antigravity * workspace rules and workflows (`.agents/{rules,workflows}/*.md`, legacy * `.agent/{rules,workflows}/*.md`; workflows run as /slash commands); * Roo Code project custom modes (`.roomodes`, YAML or legacy JSON — * roleDefinition/customInstructions text is placed in the system prompt); * Kilo Code project trees (`.kilocode/` plus the newer `.kilo/`): rules * (`rules/`, mode-specific `rules-/`, legacy `.kilocoderules`), * workflows (`workflows/*.md`, run as /slash commands; the newer extension * stores project slash commands in `.kilo/commands/*.md`), custom modes * (`.kilocodemodes`, YAML or JSON), and full system-prompt overrides * (`system-prompt-`, no extension). */ export declare const SKILL_FILE: RegExp; /** Extract the `allowed-tools` frontmatter value(s) from a SKILL.md file. */ export declare function parseAllowedTools(content: string): string[]; /** Factory Droid settings (project `.factory/settings.json` plus `settings.local.json` overrides); `commandAllowlist` entries and high autonomy pre-authorize execution for anyone opening the project. */ export declare const FACTORY_SETTINGS_FILE: RegExp; /** Crush (Charm) legacy JSON config (project `.crush.json`/`crush.json`, user `.config/crush/crush.json`, JSONC). */ export declare const CRUSH_CONFIG_FILE: RegExp; /** Crush `crushrc`/`.crushrc` — a Bash program Crush executes with shell privileges at startup. */ export declare const CRUSHRC_FILE: RegExp; /** Parse JSON tolerating the JSONC forms Claude Code accepts: comments and trailing commas. */ export declare function parseJsonc(content: string): unknown; export declare const skillOverprivilegeRule: Rule; /** * Extract dynamic-context commands: inline `` !`cmd` `` placeholders * (recognized at line start or after whitespace), ```! fenced blocks, and * Gemini CLI `!{cmd}` shell-injection blocks. These run as shell commands * when the skill or command loads. */ export declare function extractDynamicCommands(content: string): { command: string; line: number; }[]; /** * Copilot CLI project extensions: each `.github/extensions//extension.{mjs,cjs,js}` * is forked as a Node child process on session start and registers tools/hooks * with the agent. Plugins ship extensions the same way under a * `com.github.copilot/extensions/` directory. */ export declare const COPILOT_EXTENSION_FILE: RegExp; /** * String literals assigned to `description:` keys in extension source — * tool/canvas descriptions registered via `joinSession({tools, canvases})` * are injected into the model's context, so they are a text surface like a * tool description in an MCP server. Template literals with interpolation * are skipped (their content is not statically known). */ export declare function extractDescriptionLiterals(content: string): { text: string; line: number; }[]; /** * Classify a hook/task command against RISKY_COMMANDS. Literals printed by * echo/printf are masked first — text like `echo 'run: curl … | sh'` is a * message, not a pipeline. Double-quoted strings are masked only when free of * interpolation (`$`/backtick), so a printed value can't hide a live command. */ export declare function classifyRiskyCommand(command: string): { severity: 'critical' | 'high'; risk: string; } | undefined; /** Classify inline Python code (Goose `inline_python` recipe extensions) against shell + Python risk patterns. */ export declare function classifyRiskyPythonCode(code: string): { severity: 'critical' | 'high'; risk: string; } | undefined; /** Collect `type: "command"` hook commands from a Claude Code settings `hooks` object. */ export declare function extractHookCommands(hooks: unknown): string[]; /** Copilot CLI hook files (repo `.github/hooks/*.json`, user `~/.copilot/hooks/*.json`); command hooks run on lifecycle events. */ export declare const COPILOT_HOOKS_FILE: RegExp; /** Collect commands from a Copilot CLI hooks file (`{ hooks: { event: [{ type: "command", bash, powershell }] } }`). */ export declare function extractCopilotHookCommands(hooks: unknown): string[]; /** Copilot CLI settings files (repo `.github/copilot/settings.json(.local)`, user `.copilot/settings.json`); their inline `hooks` key uses the `.github/hooks/*.json` schema. */ export declare const COPILOT_SETTINGS_FILE: RegExp; /** Collect commands from an Antigravity hooks file (`{ hookName: { enabled?, Event: [{ matcher, hooks: [{ command }] } | { type: "command", command }] } }`). */ export declare function extractAntigravityHookCommands(doc: unknown): string[]; /** Command surfaces whose embedded commands AG-SK-003 classifies directly — the generic curl|sh text warning would only duplicate those findings. */ export declare const DEDICATED_COMMAND_SURFACE_FILE: RegExp; /** Collect the auto-executed command strings (with their config key) from a Cursor environment.json document. */ export declare function extractCursorEnvironmentCommands(doc: unknown): { key: string; command: string; }[]; export declare const PLUGIN_MANIFEST_FILE: RegExp; /** Agent Plugins spec (agent-plugins.org) manifests: a root-level `plugin.json` whose `$schema` carries this prefix is a portable plugin manifest with implicit `./skills` and `./mcp.json`, plus per-client `extensions` overlays (Codex reads `com.openai` as a legacy manifest for hooks). */ export declare const AGENT_PLUGIN_SCHEMA_PREFIX = "https://agent-plugins.org/schemas/"; /** Flatten a monitors array (`[{ name, command, description }]`) into its command strings. */ export declare function extractMonitorCommands(monitors: unknown): string[]; /** Flatten `{ name: { command, args } }` LSP server maps into full command lines (Copilot's Open Plugin Spec variant launches via `bash`/`powershell` scripts instead of `command`). */ export declare function extractLspCommands(servers: unknown): string[]; /** Collect the command strings of VS Code tasks that run automatically on folder open. */ export declare function extractFolderOpenTaskCommands(tasks: unknown): string[]; /** Collect commands from an Amazon Q agent `hooks` field ({ trigger: [{ command }] }). */ export declare function extractAmazonqHookCommands(hooks: unknown): string[]; /** * Goose recipe files (`recipe.yaml`/`recipe.json`, the documented generated/stored name); * `instructions`/`prompt`/`activities` become the agent's instructions for everyone who * runs the recipe. The parse gates on the documented recipe shape since the name is generic. */ export declare const GOOSE_RECIPE_FILE: RegExp; /** * Any YAML/JSON file can be a Goose recipe: subrecipes are referenced from a * main recipe's `sub_recipes[].path` under arbitrary names (e.g. * `subrecipes/security-analysis.yaml`), so gate on the documented recipe shape * (title + description + instructions|prompt) instead of the filename. */ export declare const GOOSE_RECIPE_CANDIDATE: RegExp; export interface GooseRecipeDoc { title: string; description: string; instructions?: unknown; prompt?: unknown; activities?: unknown; extensions?: unknown; } /** Parse a file as a Goose recipe; undefined when it is not shaped like one. */ export declare function parseGooseRecipeDoc(file: string, content: string): GooseRecipeDoc | undefined; /** Kiro agent hook files (`*.kiro.hook`, when/then schema); `then.type: "runCommand"` executes on IDE events. */ export declare const KIRO_AGENT_HOOK_FILE: RegExp; /** Collect `action.type: "command"` commands from a Kiro hook file's `hooks` array. */ export declare function extractKiroHookCommands(hooks: unknown): string[]; export declare const skillDynamicContextRule: Rule; /** 1-based line numbers that sit inside a fenced code block (``` or ~~~). */ export declare function fencedCodeLines(content: string): Set; export declare const skillPoisoningRule: Rule;