|
| 1 | +import { SlashCommandConfigurator } from './base.js'; |
| 2 | +import { SlashCommandId } from '../../templates/index.js'; |
| 3 | + |
| 4 | +/** |
| 5 | + * File paths for Neovate slash commands |
| 6 | + * Maps each OpenSpec workflow stage to its command file location |
| 7 | + * Commands are stored in .neovate/commands/openspec/ directory |
| 8 | + */ |
| 9 | +const FILE_PATHS: Record<SlashCommandId, string> = { |
| 10 | + // Create and validate new change proposals |
| 11 | + proposal: '.neovate/commands/openspec/proposal.md', |
| 12 | + |
| 13 | + // Implement approved changes with task tracking |
| 14 | + apply: '.neovate/commands/openspec/apply.md', |
| 15 | + |
| 16 | + // Archive completed changes and update specs |
| 17 | + archive: '.neovate/commands/openspec/archive.md' |
| 18 | +}; |
| 19 | + |
| 20 | +/** |
| 21 | + * YAML frontmatter for Neovate slash commands |
| 22 | + * Defines metadata displayed in Neovate's command palette |
| 23 | + * Each command is categorized and tagged for easy discovery |
| 24 | + */ |
| 25 | +const FRONTMATTER: Record<SlashCommandId, string> = { |
| 26 | + proposal: `--- |
| 27 | +name: Proposal |
| 28 | +description: Scaffold a new OpenSpec change and validate strictly. |
| 29 | +---`, |
| 30 | + apply: `--- |
| 31 | +name: Apply |
| 32 | +description: Implement an approved OpenSpec change and keep tasks in sync. |
| 33 | +---`, |
| 34 | + archive: `--- |
| 35 | +name: Archive |
| 36 | +description: Archive a deployed OpenSpec change and update specs. |
| 37 | +---` |
| 38 | +}; |
| 39 | + |
| 40 | +/** |
| 41 | + * Neovate Slash Command Configurator |
| 42 | + * |
| 43 | + * Manages OpenSpec slash commands for Neovate Code AI assistant. |
| 44 | + * Creates three workflow commands: proposal, apply, and archive. |
| 45 | + * Uses colon-separated command format (/openspec:proposal). |
| 46 | + * |
| 47 | + * @extends {SlashCommandConfigurator} |
| 48 | + */ |
| 49 | +export class NeovateSlashCommandConfigurator extends SlashCommandConfigurator { |
| 50 | + /** Unique identifier for Neovate tool */ |
| 51 | + readonly toolId = 'neovate'; |
| 52 | + |
| 53 | + /** Indicates slash commands are available for this tool */ |
| 54 | + readonly isAvailable = true; |
| 55 | + |
| 56 | + /** |
| 57 | + * Get relative file path for a slash command |
| 58 | + * |
| 59 | + * @param {SlashCommandId} id - Command identifier (proposal, apply, or archive) |
| 60 | + * @returns {string} Relative path from project root to command file |
| 61 | + */ |
| 62 | + protected getRelativePath(id: SlashCommandId): string { |
| 63 | + return FILE_PATHS[id]; |
| 64 | + } |
| 65 | + |
| 66 | + /** |
| 67 | + * Get YAML frontmatter for a slash command |
| 68 | + * |
| 69 | + * Frontmatter defines how the command appears in Neovate's UI, |
| 70 | + * including display name, description, and categorization. |
| 71 | + * |
| 72 | + * @param {SlashCommandId} id - Command identifier (proposal, apply, or archive) |
| 73 | + * @returns {string} YAML frontmatter block with command metadata |
| 74 | + */ |
| 75 | + protected getFrontmatter(id: SlashCommandId): string { |
| 76 | + return FRONTMATTER[id]; |
| 77 | + } |
| 78 | +} |
0 commit comments