aiwg
Version:
Deployment tool and support utility for AI context. Copies agents, skills, commands, rules, and behaviors into the paths each AI platform reads (Claude Code, Codex, Copilot, Cursor, Warp, OpenClaw, and 6 more) so one source of truth works across 10 platfo
141 lines • 5.24 kB
TypeScript
/**
* Skill→Command Translation Layer
*
* Generates command files from canonical SKILL.md sources for providers that
* require command format natively (Factory, OpenCode, Warp, Windsurf, Copilot,
* Codex, OpenClaw).
*
* Skills are the canonical source format; commands are deployment artifacts.
* See ADR: Skills as the Canonical Extension Type.
*
* @implements .aiwg/architecture/adr-skills-canonical-extension-type.md
* @issue #550
*/
export interface TranslationOptions {
/** Target provider name */
provider: string;
/** Target directory for generated command files */
targetDir: string;
/** If true, return results without writing files */
dryRun?: boolean;
/** If true, log verbose output */
verbose?: boolean;
/**
* Project root path. Used by per-provider dual-write paths (e.g., Copilot
* `.github/prompts/<id>.prompt.md`). When omitted, dual-write derives the
* root from `path.dirname(path.dirname(targetDir))` which works for
* standard `<root>/.github/commands/` layouts but not arbitrary test
* fixtures. Pass `projectPath` explicitly when targetDir is non-standard.
*/
projectPath?: string;
/**
* Optional filter — only skills whose name returns true from this predicate
* are translated. When omitted, all skills are translated. Used by Claude
* (PUW-015 #1116) to limit translation to flow-* skills + a small allowlist
* of operator-invocable command surfaces.
*/
nameFilter?: (skillName: string) => boolean;
}
export interface TranslatedCommand {
/** Skill source path */
sourcePath: string;
/** Skill name (from directory name) */
skillName: string;
/** Generated command filename */
commandFilename: string;
/** Generated command content */
content: string;
/** Whether the skill was skipped (e.g., userInvocable: false) */
skipped: boolean;
/** Reason for skipping */
skipReason?: string;
}
export interface TranslationResult {
/** Provider that was targeted */
provider: string;
/** Target directory for generated commands */
targetDir: string;
/** Successfully translated commands */
translated: TranslatedCommand[];
/** Skipped skills (background-only, etc.) */
skipped: TranslatedCommand[];
/** Errors encountered during translation */
errors: {
skillName: string;
error: string;
}[];
/** Total skills processed */
totalProcessed: number;
}
/**
* Parsed SKILL.md frontmatter fields relevant to command translation
*/
interface SkillFrontmatter {
description?: string;
commandHint?: {
argumentHint?: string;
allowedTools?: string | string[];
template?: string;
model?: string;
category?: string;
orchestration?: boolean;
executionSteps?: string[];
cliDisabled?: boolean;
};
userInvocable?: boolean;
effort?: number;
context?: string;
disableModelInvocation?: boolean;
allowedTools?: string | string[];
}
/**
* Check if a provider needs command files generated from skills.
*/
export declare function providerNeedsCommands(provider: string): boolean;
/**
* Check if a provider uses skills natively (no command translation).
*/
export declare function providerUsesSkillsNatively(provider: string): boolean;
/**
* Parse YAML-like frontmatter from a SKILL.md file.
*
* This is a lightweight parser that handles the subset of YAML used in
* SKILL.md frontmatter. For full YAML support, a library like js-yaml
* would be needed, but the frontmatter format is simple enough for this.
*/
export declare function parseFrontmatter(content: string): {
frontmatter: SkillFrontmatter;
body: string;
};
/**
* Generate a command .md file content from parsed skill data.
*
* Maps SKILL.md frontmatter to legacy command frontmatter format:
* - `description:` from skill description
* - `argument-hint:` from commandHint.argumentHint
* - `allowed-tools:` from commandHint.allowedTools (comma-separated)
*/
export declare function generateCommandContent(_skillName: string, frontmatter: SkillFrontmatter, body: string): string;
/**
* Translate all skills in a directory to command files.
*
* Reads each subdirectory in `skillsDir` as a skill, parses SKILL.md,
* and generates a corresponding command .md file.
*
* @param skillsDir - Source skills directory (e.g., `agentic/code/frameworks/sdlc-complete/skills/`)
* @param options - Translation options (provider, target dir, dry-run)
* @returns Translation result with counts and any errors
*/
export declare function translateSkillsToCommands(skillsDir: string, options: TranslationOptions): Promise<TranslationResult>;
/**
* Translate a single SKILL.md content string to command format.
*
* Convenience function for testing and one-off translations.
*
* @param skillName - Skill name (used for display only)
* @param skillContent - Raw SKILL.md file content
* @returns Generated command .md content, or null if skill should be skipped
*/
export declare function translateSingleSkill(skillName: string, skillContent: string): string | null;
export {};
//# sourceMappingURL=skill-command-translator.d.ts.map