import 'reflect-metadata'; import { type EsmOptions, type RemoteOptions, type SkillMetadata } from '../metadata'; import { type SkillValueRecord } from '../records'; import { type SkillEsmTargetRecord, type SkillRemoteRecord } from '../records/skill.record'; /** * Class decorator that marks a class as a Skill and provides metadata. * * Skills are knowledge/workflow packages that teach AI how to perform * multi-step tasks using tools. Unlike tools, skills don't execute * directly - they provide instructions and context for LLMs. * * Aligned with the Anthropic Agent Skills specification: * - `name`: kebab-case, max 64 chars, no consecutive hyphens * - `description`: 1–1024 chars, non-empty * - Supports `license`, `compatibility`, `specMetadata`, `allowedTools`, `resources` * * ## File path resolution * * When `instructions: { file: './…' }`, `resources.references: './…'`, or * `resources.examples: './…'` are relative, they are resolved relative to * the directory of the source file that declared the `@Skill` class — * **not** the process `cwd`. The directory is captured at decoration time * by walking the call stack. This matches the behaviour of the inline * `skill()` helper, and works under both CJS and ESM. If the caller * cannot be determined (e.g. an exotic loader strips stack frames), the * framework falls back to the build-time `_skills/manifest.json` for * bundled CLIs and otherwise to the legacy `cwd`-relative behaviour. * * @param providedMetadata - Skill metadata including name, description, and instructions * @returns Class decorator * * @example Basic skill (empty body — runtime drives loading) * ```typescript * @Skill({ * name: 'review-pr', * description: 'Review a GitHub pull request', * instructions: 'Step 1: Fetch PR details...', * tools: ['github_get_pr', 'github_add_comment'], * }) * class ReviewPRSkill extends SkillContext {} * ``` * * @example Skill with Agent Skills spec fields * ```typescript * @Skill({ * name: 'deploy-app', * description: 'Deploy application to production', * instructions: { file: './skills/deploy.md' }, * tools: ['docker_build', 'k8s_apply'], * tags: ['devops', 'deployment'], * license: 'MIT', * compatibility: 'Requires Docker 24+ and kubectl', * allowedTools: 'Read Edit Bash(docker build)', * }) * class DeploySkill extends SkillContext {} * ``` * * @example Skill with URL-based instructions * ```typescript * @Skill({ * name: 'security-audit', * description: 'Perform security audit on codebase', * instructions: { url: 'https://example.com/skills/security-audit.md' }, * tools: ['code_search', 'file_read'], * }) * class SecurityAuditSkill extends SkillContext {} * ``` */ declare function FrontMcpSkill(providedMetadata: SkillMetadata): ClassDecorator; /** * Function helper that creates an inline skill record. * * Use this when you want to define a skill without creating a class. * The skill is registered as a value record with a unique symbol token. * * Name must be kebab-case (max 64 chars, no consecutive hyphens). * Description: 1–1024 chars, non-empty. * * ## File path resolution * * When `instructions: { file: './…' }`, `resources.references: './…'`, or * `resources.examples: './…'` are relative, they are resolved relative to * the directory of the source file that called `skill()` — **not** the * process `cwd`. The directory is captured at call time by walking the * stack. Works under both CJS and ESM. * * @param providedMetadata - Skill metadata including name, description, and instructions * @returns A skill value record that can be passed to app/plugin skills array * * @example Inline skill * ```typescript * const reviewPRSkill = skill({ * name: 'review-pr', * description: 'Review a GitHub pull request', * instructions: ` * ## PR Review Process * 1. Fetch the PR details using github_get_pr * 2. Review each changed file... * `, * tools: [ * { name: 'github_get_pr', purpose: 'Fetch PR details', required: true }, * { name: 'github_add_comment', purpose: 'Add review comments' }, * ], * tags: ['github', 'code-review'], * license: 'MIT', * }); * * @FrontMcp({ * name: 'my-app', * skills: [reviewPRSkill], * }) * class MyApp {} * ``` * * @example Skill with file-based instructions * ```typescript * const deploySkill = skill({ * name: 'deploy-app', * description: 'Deploy application to production', * instructions: { file: './skills/deploy.md' }, * tools: ['docker_build', 'docker_push', 'k8s_apply'], * }); * ``` */ declare function frontMcpSkill(providedMetadata: SkillMetadata): SkillValueRecord; declare function skillEsm(specifier: string, targetName: string, options?: EsmOptions): SkillEsmTargetRecord; declare function skillRemote(url: string, targetName: string, options?: RemoteOptions): SkillRemoteRecord; type SkillDecorator = { (metadata: SkillMetadata): ClassDecorator; esm: typeof skillEsm; remote: typeof skillRemote; }; declare const Skill: SkillDecorator; export { FrontMcpSkill, Skill, frontMcpSkill, frontMcpSkill as skill }; /** * Check if a class has the @Skill decorator. */ export declare function isSkillDecorated(target: object): boolean; /** * Get skill metadata from a decorated class. */ export declare function getSkillMetadata(target: object): SkillMetadata | undefined; //# sourceMappingURL=skill.decorator.d.ts.map