1+ /**
2+ * Qwen slash command configurator for OpenSpec integration.
3+ * This class handles the generation of Qwen-specific slash command files
4+ * in the .qwen/commands directory structure.
5+ *
6+ * @implements {SlashCommandConfigurator}
7+ */
8+ import { SlashCommandConfigurator } from './base.js' ;
9+ import { SlashCommandId } from '../../templates/index.js' ;
10+
11+ /**
12+ * Mapping of slash command IDs to their corresponding file paths in .qwen/commands directory.
13+ * @type {Record<SlashCommandId, string> }
14+ */
15+ const FILE_PATHS : Record < SlashCommandId , string > = {
16+ proposal : '.qwen/commands/openspec-proposal.md' ,
17+ apply : '.qwen/commands/openspec-apply.md' ,
18+ archive : '.qwen/commands/openspec-archive.md'
19+ } ;
20+
21+ /**
22+ * YAML frontmatter definitions for Qwen command files.
23+ * These provide metadata for each slash command to ensure proper recognition by Qwen Code.
24+ * @type {Record<SlashCommandId, string> }
25+ */
26+ const FRONTMATTER : Record < SlashCommandId , string > = {
27+ proposal : `---
28+ name: /openspec-proposal
29+ id: openspec-proposal
30+ category: OpenSpec
31+ description: Scaffold a new OpenSpec change and validate strictly.
32+ ---` ,
33+ apply : `---
34+ name: /openspec-apply
35+ id: openspec-apply
36+ category: OpenSpec
37+ description: Implement an approved OpenSpec change and keep tasks in sync.
38+ ---` ,
39+ archive : `---
40+ name: /openspec-archive
41+ id: openspec-archive
42+ category: OpenSpec
43+ description: Archive a deployed OpenSpec change and update specs.
44+ ---`
45+ } ;
46+
47+ /**
48+ * QwenSlashCommandConfigurator class provides integration with Qwen Code
49+ * by creating the necessary slash command files in the .qwen/commands directory.
50+ *
51+ * The slash commands include:
52+ * - /openspec-proposal: Create an OpenSpec change proposal
53+ * - /openspec-apply: Apply an approved OpenSpec change
54+ * - /openspec-archive: Archive a deployed OpenSpec change
55+ */
56+ export class QwenSlashCommandConfigurator extends SlashCommandConfigurator {
57+ /** Unique identifier for the Qwen tool */
58+ readonly toolId = 'qwen' ;
59+
60+ /** Availability status for the Qwen tool */
61+ readonly isAvailable = true ;
62+
63+ /**
64+ * Returns the relative file path for a given slash command ID.
65+ * @param {SlashCommandId } id - The slash command identifier
66+ * @returns {string } The relative path to the command file
67+ */
68+ protected getRelativePath ( id : SlashCommandId ) : string {
69+ return FILE_PATHS [ id ] ;
70+ }
71+
72+ /**
73+ * Returns the YAML frontmatter for a given slash command ID.
74+ * @param {SlashCommandId } id - The slash command identifier
75+ * @returns {string } The YAML frontmatter string
76+ */
77+ protected getFrontmatter ( id : SlashCommandId ) : string {
78+ return FRONTMATTER [ id ] ;
79+ }
80+ }
0 commit comments