/** * Skill Attribution Heuristics * * When a closure gate (judge-llm, rubric, code-reviewer) fails, it may or may * not be possible to trace the failure to a specific skill's instructions. * This module applies the attribution heuristics defined in 0671's plan.md * and returns the attributed skill slug (or null when attribution is * ambiguous — precision over recall). * * Priority order (first match wins): * 1. direct — the failing step's originating tool call was made from a * skill's Task() prompt * 2. slash — the increment was initiated with `/sw:` * 3. pattern — the failure evidence text contains a 6+ word phrase from a * skill's SKILL.md (exact-match) * 4. none — no signal is emitted * * @module core/skill-attribution */ export type AttributionMethod = 'direct' | 'slash' | 'pattern' | 'none'; export interface AttributeSkillInput { /** * The skill slug that originated the currently-executing Task() prompt, * if known. When present, this is the authoritative attribution. */ toolCallOrigin?: string; /** * The slash command that initiated the increment, e.g. `/sw:architect`. * Accepts either `/sw:architect` or `sw:architect`. */ slashCommand?: string; /** * The failure evidence text (e.g. judge-llm concerns, rubric rationale, * code-review finding description) to scan for skill-authored phrases. */ evidenceText?: string; /** * Directory containing skill plugin folders (each with a `SKILL.md`). Used * only for pattern-match attribution. When omitted, pattern-match is * skipped. */ skillsRoot?: string; } export interface AttributionResult { /** Skill slug (e.g. "sw:architect") or null when attribution fails. */ skill: string | null; /** Which heuristic produced the result. */ method: AttributionMethod; } /** * Attribute a gate failure to a specific skill. Returns `{skill: null, * method: "none"}` when no heuristic matches with enough confidence to emit. * * Attribution is intentionally precision-biased: gates should not emit a * refinement signal against a skill that may not have been at fault. */ export declare function attributeSkill(input: AttributeSkillInput): AttributionResult; /** * Extract a skill slug from a slash command, if one is present. Accepts * `/sw:architect`, `sw:architect`, or `/sw:architect some-args`. */ export declare function parseSlashCommand(cmd: string | undefined): string | null; /** * Extract skill slugs referenced directly in evidence text (e.g. "skill * 'sw:architect' advised microservices"). Used as a low-cost fallback before * the more expensive SKILL.md pattern scan. */ export declare function extractSlugsFromEvidence(evidenceText: string): string[]; /** * Scan skill plugin directories under `skillsRoot` for SKILL.md files and * check whether any contiguous 6-word phrase from a skill's SKILL.md appears * verbatim in the evidence text. Returns the first skill slug whose content * matches (skills are scanned in alphabetical order for deterministic output). * * Best-effort: swallows I/O errors and returns null rather than throwing. */ export declare function matchEvidenceToSkill(evidenceText: string, skillsRoot: string): string | null; //# sourceMappingURL=skill-attribution.d.ts.map