-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Expand file tree
/
Copy pathadapters.test.ts
More file actions
656 lines (565 loc) · 26.8 KB
/
adapters.test.ts
File metadata and controls
656 lines (565 loc) · 26.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
import { describe, it, expect } from 'vitest';
import os from 'os';
import path from 'path';
import { amazonQAdapter } from '../../../src/core/command-generation/adapters/amazon-q.js';
import { antigravityAdapter } from '../../../src/core/command-generation/adapters/antigravity.js';
import { auggieAdapter } from '../../../src/core/command-generation/adapters/auggie.js';
import { avianAdapter } from '../../../src/core/command-generation/adapters/avian.js';
import { claudeAdapter } from '../../../src/core/command-generation/adapters/claude.js';
import { clineAdapter } from '../../../src/core/command-generation/adapters/cline.js';
import { codexAdapter } from '../../../src/core/command-generation/adapters/codex.js';
import { codebuddyAdapter } from '../../../src/core/command-generation/adapters/codebuddy.js';
import { continueAdapter } from '../../../src/core/command-generation/adapters/continue.js';
import { costrictAdapter } from '../../../src/core/command-generation/adapters/costrict.js';
import { crushAdapter } from '../../../src/core/command-generation/adapters/crush.js';
import { cursorAdapter } from '../../../src/core/command-generation/adapters/cursor.js';
import { factoryAdapter } from '../../../src/core/command-generation/adapters/factory.js';
import { geminiAdapter } from '../../../src/core/command-generation/adapters/gemini.js';
import { githubCopilotAdapter } from '../../../src/core/command-generation/adapters/github-copilot.js';
import { iflowAdapter } from '../../../src/core/command-generation/adapters/iflow.js';
import { kilocodeAdapter } from '../../../src/core/command-generation/adapters/kilocode.js';
import { opencodeAdapter } from '../../../src/core/command-generation/adapters/opencode.js';
import { piAdapter } from '../../../src/core/command-generation/adapters/pi.js';
import { qoderAdapter } from '../../../src/core/command-generation/adapters/qoder.js';
import { qwenAdapter } from '../../../src/core/command-generation/adapters/qwen.js';
import { roocodeAdapter } from '../../../src/core/command-generation/adapters/roocode.js';
import { windsurfAdapter } from '../../../src/core/command-generation/adapters/windsurf.js';
import type { CommandContent } from '../../../src/core/command-generation/types.js';
describe('command-generation/adapters', () => {
const sampleContent: CommandContent = {
id: 'explore',
name: 'OpenSpec Explore',
description: 'Enter explore mode for thinking',
category: 'Workflow',
tags: ['workflow', 'explore', 'experimental'],
body: 'This is the command body.\n\nWith multiple lines.',
};
describe('claudeAdapter', () => {
it('should have correct toolId', () => {
expect(claudeAdapter.toolId).toBe('claude');
});
it('should generate correct file path', () => {
const filePath = claudeAdapter.getFilePath('explore');
expect(filePath).toBe(path.join('.claude', 'commands', 'opsx', 'explore.md'));
});
it('should generate correct file path for different command IDs', () => {
expect(claudeAdapter.getFilePath('new')).toBe(path.join('.claude', 'commands', 'opsx', 'new.md'));
expect(claudeAdapter.getFilePath('bulk-archive')).toBe(path.join('.claude', 'commands', 'opsx', 'bulk-archive.md'));
});
it('should format file with correct YAML frontmatter', () => {
const output = claudeAdapter.formatFile(sampleContent);
expect(output).toContain('---\n');
expect(output).toContain('name: OpenSpec Explore');
expect(output).toContain('description: Enter explore mode for thinking');
expect(output).toContain('category: Workflow');
expect(output).toContain('tags: [workflow, explore, experimental]');
expect(output).toContain('---\n\n');
expect(output).toContain('This is the command body.\n\nWith multiple lines.');
});
it('should handle empty tags', () => {
const contentNoTags: CommandContent = { ...sampleContent, tags: [] };
const output = claudeAdapter.formatFile(contentNoTags);
expect(output).toContain('tags: []');
});
});
describe('cursorAdapter', () => {
it('should have correct toolId', () => {
expect(cursorAdapter.toolId).toBe('cursor');
});
it('should generate correct file path with opsx- prefix', () => {
const filePath = cursorAdapter.getFilePath('explore');
expect(filePath).toBe(path.join('.cursor', 'commands', 'opsx-explore.md'));
});
it('should generate correct file paths for different commands', () => {
expect(cursorAdapter.getFilePath('new')).toBe(path.join('.cursor', 'commands', 'opsx-new.md'));
expect(cursorAdapter.getFilePath('bulk-archive')).toBe(path.join('.cursor', 'commands', 'opsx-bulk-archive.md'));
});
it('should format file with Cursor-specific frontmatter', () => {
const output = cursorAdapter.formatFile(sampleContent);
expect(output).toContain('---\n');
expect(output).toContain('name: /opsx-explore');
expect(output).toContain('id: opsx-explore');
expect(output).toContain('category: Workflow');
expect(output).toContain('description: Enter explore mode for thinking');
expect(output).toContain('---\n\n');
expect(output).toContain('This is the command body.');
});
it('should not include tags in Cursor format', () => {
const output = cursorAdapter.formatFile(sampleContent);
expect(output).not.toContain('tags:');
});
});
describe('windsurfAdapter', () => {
it('should have correct toolId', () => {
expect(windsurfAdapter.toolId).toBe('windsurf');
});
it('should generate correct file path', () => {
const filePath = windsurfAdapter.getFilePath('explore');
expect(filePath).toBe(path.join('.windsurf', 'workflows', 'opsx-explore.md'));
});
it('should format file similar to Claude format', () => {
const output = windsurfAdapter.formatFile(sampleContent);
expect(output).toContain('---\n');
expect(output).toContain('name: OpenSpec Explore');
expect(output).toContain('description: Enter explore mode for thinking');
expect(output).toContain('category: Workflow');
expect(output).toContain('tags: [workflow, explore, experimental]');
expect(output).toContain('---\n\n');
expect(output).toContain('This is the command body.');
});
});
describe('amazonQAdapter', () => {
it('should have correct toolId', () => {
expect(amazonQAdapter.toolId).toBe('amazon-q');
});
it('should generate correct file path', () => {
const filePath = amazonQAdapter.getFilePath('explore');
expect(filePath).toBe(path.join('.amazonq', 'prompts', 'opsx-explore.md'));
});
it('should format file with description frontmatter', () => {
const output = amazonQAdapter.formatFile(sampleContent);
expect(output).toContain('---\n');
expect(output).toContain('description: Enter explore mode for thinking');
expect(output).toContain('---\n\n');
expect(output).toContain('This is the command body.');
});
});
describe('antigravityAdapter', () => {
it('should have correct toolId', () => {
expect(antigravityAdapter.toolId).toBe('antigravity');
});
it('should generate correct file path', () => {
const filePath = antigravityAdapter.getFilePath('explore');
expect(filePath).toBe(path.join('.agent', 'workflows', 'opsx-explore.md'));
});
it('should format file with description frontmatter', () => {
const output = antigravityAdapter.formatFile(sampleContent);
expect(output).toContain('---\n');
expect(output).toContain('description: Enter explore mode for thinking');
expect(output).toContain('---\n\n');
expect(output).toContain('This is the command body.');
});
});
describe('auggieAdapter', () => {
it('should have correct toolId', () => {
expect(auggieAdapter.toolId).toBe('auggie');
});
it('should generate correct file path', () => {
const filePath = auggieAdapter.getFilePath('explore');
expect(filePath).toBe(path.join('.augment', 'commands', 'opsx-explore.md'));
});
it('should format file with description and argument-hint', () => {
const output = auggieAdapter.formatFile(sampleContent);
expect(output).toContain('---\n');
expect(output).toContain('description: Enter explore mode for thinking');
expect(output).toContain('argument-hint: command arguments');
expect(output).toContain('---\n\n');
expect(output).toContain('This is the command body.');
});
});
describe('avianAdapter', () => {
it('should have correct toolId', () => {
expect(avianAdapter.toolId).toBe('avian');
});
it('should generate correct file path with nested opsx folder', () => {
const filePath = avianAdapter.getFilePath('explore');
expect(filePath).toBe(path.join('.avian', 'commands', 'opsx', 'explore.md'));
});
it('should generate correct file paths for different commands', () => {
expect(avianAdapter.getFilePath('new')).toBe(path.join('.avian', 'commands', 'opsx', 'new.md'));
expect(avianAdapter.getFilePath('bulk-archive')).toBe(path.join('.avian', 'commands', 'opsx', 'bulk-archive.md'));
});
it('should format file with name, description, category, and tags', () => {
const output = avianAdapter.formatFile(sampleContent);
expect(output).toContain('---\n');
expect(output).toContain('name: OpenSpec Explore');
expect(output).toContain('description: Enter explore mode for thinking');
expect(output).toContain('category: Workflow');
expect(output).toContain('tags: [workflow, explore, experimental]');
expect(output).toContain('---\n\n');
expect(output).toContain('This is the command body.\n\nWith multiple lines.');
});
it('should handle empty tags', () => {
const contentNoTags: CommandContent = { ...sampleContent, tags: [] };
const output = avianAdapter.formatFile(contentNoTags);
expect(output).toContain('tags: []');
});
});
describe('clineAdapter', () => {
it('should have correct toolId', () => {
expect(clineAdapter.toolId).toBe('cline');
});
it('should generate correct file path', () => {
const filePath = clineAdapter.getFilePath('explore');
expect(filePath).toBe(path.join('.clinerules', 'workflows', 'opsx-explore.md'));
});
it('should format file with markdown header (no YAML frontmatter)', () => {
const output = clineAdapter.formatFile(sampleContent);
expect(output).toContain('# OpenSpec Explore');
expect(output).toContain('Enter explore mode for thinking');
expect(output).toContain('This is the command body.');
expect(output).not.toContain('---');
});
});
describe('codexAdapter', () => {
it('should have correct toolId', () => {
expect(codexAdapter.toolId).toBe('codex');
});
it('should return an absolute path', () => {
const filePath = codexAdapter.getFilePath('explore');
expect(path.isAbsolute(filePath)).toBe(true);
});
it('should generate path ending with correct structure', () => {
const filePath = codexAdapter.getFilePath('explore');
expect(filePath).toMatch(/prompts[/\\]opsx-explore\.md$/);
});
it('should default to homedir/.codex', () => {
const original = process.env.CODEX_HOME;
delete process.env.CODEX_HOME;
try {
const filePath = codexAdapter.getFilePath('explore');
const expected = path.join(os.homedir(), '.codex', 'prompts', 'opsx-explore.md');
expect(filePath).toBe(expected);
} finally {
if (original !== undefined) {
process.env.CODEX_HOME = original;
}
}
});
it('should respect CODEX_HOME env var', () => {
const original = process.env.CODEX_HOME;
process.env.CODEX_HOME = '/custom/codex-home';
try {
const filePath = codexAdapter.getFilePath('explore');
expect(filePath).toBe(path.join(path.resolve('/custom/codex-home'), 'prompts', 'opsx-explore.md'));
} finally {
if (original !== undefined) {
process.env.CODEX_HOME = original;
} else {
delete process.env.CODEX_HOME;
}
}
});
it('should format file with description and argument-hint', () => {
const output = codexAdapter.formatFile(sampleContent);
expect(output).toContain('---\n');
expect(output).toContain('description: Enter explore mode for thinking');
expect(output).toContain('argument-hint: command arguments');
expect(output).toContain('---\n\n');
expect(output).toContain('This is the command body.');
});
});
describe('codebuddyAdapter', () => {
it('should have correct toolId', () => {
expect(codebuddyAdapter.toolId).toBe('codebuddy');
});
it('should generate correct file path with nested opsx folder', () => {
const filePath = codebuddyAdapter.getFilePath('explore');
expect(filePath).toBe(path.join('.codebuddy', 'commands', 'opsx', 'explore.md'));
});
it('should format file with name, description, and argument-hint', () => {
const output = codebuddyAdapter.formatFile(sampleContent);
expect(output).toContain('---\n');
expect(output).toContain('name: OpenSpec Explore');
expect(output).toContain('description: "Enter explore mode for thinking"');
expect(output).toContain('argument-hint: "[command arguments]"');
expect(output).toContain('---\n\n');
expect(output).toContain('This is the command body.');
});
});
describe('continueAdapter', () => {
it('should have correct toolId', () => {
expect(continueAdapter.toolId).toBe('continue');
});
it('should generate correct file path with .prompt extension', () => {
const filePath = continueAdapter.getFilePath('explore');
expect(filePath).toBe(path.join('.continue', 'prompts', 'opsx-explore.prompt'));
});
it('should format file with name, description, and invokable', () => {
const output = continueAdapter.formatFile(sampleContent);
expect(output).toContain('---\n');
expect(output).toContain('name: opsx-explore');
expect(output).toContain('description: Enter explore mode for thinking');
expect(output).toContain('invokable: true');
expect(output).toContain('---\n\n');
expect(output).toContain('This is the command body.');
});
});
describe('costrictAdapter', () => {
it('should have correct toolId', () => {
expect(costrictAdapter.toolId).toBe('costrict');
});
it('should generate correct file path', () => {
const filePath = costrictAdapter.getFilePath('explore');
expect(filePath).toBe(path.join('.cospec', 'openspec', 'commands', 'opsx-explore.md'));
});
it('should format file with description and argument-hint', () => {
const output = costrictAdapter.formatFile(sampleContent);
expect(output).toContain('---\n');
expect(output).toContain('description: "Enter explore mode for thinking"');
expect(output).toContain('argument-hint: command arguments');
expect(output).toContain('---\n\n');
expect(output).toContain('This is the command body.');
});
});
describe('crushAdapter', () => {
it('should have correct toolId', () => {
expect(crushAdapter.toolId).toBe('crush');
});
it('should generate correct file path with nested opsx folder', () => {
const filePath = crushAdapter.getFilePath('explore');
expect(filePath).toBe(path.join('.crush', 'commands', 'opsx', 'explore.md'));
});
it('should format file with name, description, category, and tags', () => {
const output = crushAdapter.formatFile(sampleContent);
expect(output).toContain('---\n');
expect(output).toContain('name: OpenSpec Explore');
expect(output).toContain('description: Enter explore mode for thinking');
expect(output).toContain('category: Workflow');
expect(output).toContain('tags: [workflow, explore, experimental]');
expect(output).toContain('---\n\n');
expect(output).toContain('This is the command body.');
});
});
describe('factoryAdapter', () => {
it('should have correct toolId', () => {
expect(factoryAdapter.toolId).toBe('factory');
});
it('should generate correct file path', () => {
const filePath = factoryAdapter.getFilePath('explore');
expect(filePath).toBe(path.join('.factory', 'commands', 'opsx-explore.md'));
});
it('should format file with description and argument-hint', () => {
const output = factoryAdapter.formatFile(sampleContent);
expect(output).toContain('---\n');
expect(output).toContain('description: Enter explore mode for thinking');
expect(output).toContain('argument-hint: command arguments');
expect(output).toContain('---\n\n');
expect(output).toContain('This is the command body.');
});
});
describe('geminiAdapter', () => {
it('should have correct toolId', () => {
expect(geminiAdapter.toolId).toBe('gemini');
});
it('should generate correct file path with .toml extension', () => {
const filePath = geminiAdapter.getFilePath('explore');
expect(filePath).toBe(path.join('.gemini', 'commands', 'opsx', 'explore.toml'));
});
it('should format file in TOML format', () => {
const output = geminiAdapter.formatFile(sampleContent);
expect(output).toContain('description = "Enter explore mode for thinking"');
expect(output).toContain('prompt = """');
expect(output).toContain('This is the command body.');
expect(output).toContain('"""');
});
});
describe('githubCopilotAdapter', () => {
it('should have correct toolId', () => {
expect(githubCopilotAdapter.toolId).toBe('github-copilot');
});
it('should generate correct file path with .prompt.md extension', () => {
const filePath = githubCopilotAdapter.getFilePath('explore');
expect(filePath).toBe(path.join('.github', 'prompts', 'opsx-explore.prompt.md'));
});
it('should format file with description frontmatter', () => {
const output = githubCopilotAdapter.formatFile(sampleContent);
expect(output).toContain('---\n');
expect(output).toContain('description: Enter explore mode for thinking');
expect(output).toContain('---\n\n');
expect(output).toContain('This is the command body.');
});
});
describe('iflowAdapter', () => {
it('should have correct toolId', () => {
expect(iflowAdapter.toolId).toBe('iflow');
});
it('should generate correct file path', () => {
const filePath = iflowAdapter.getFilePath('explore');
expect(filePath).toBe(path.join('.iflow', 'commands', 'opsx-explore.md'));
});
it('should format file with name, id, category, and description', () => {
const output = iflowAdapter.formatFile(sampleContent);
expect(output).toContain('---\n');
expect(output).toContain('name: /opsx-explore');
expect(output).toContain('id: opsx-explore');
expect(output).toContain('category: Workflow');
expect(output).toContain('description: Enter explore mode for thinking');
expect(output).toContain('---\n\n');
expect(output).toContain('This is the command body.');
});
});
describe('kilocodeAdapter', () => {
it('should have correct toolId', () => {
expect(kilocodeAdapter.toolId).toBe('kilocode');
});
it('should generate correct file path', () => {
const filePath = kilocodeAdapter.getFilePath('explore');
expect(filePath).toBe(path.join('.kilocode', 'workflows', 'opsx-explore.md'));
});
it('should format file without frontmatter', () => {
const output = kilocodeAdapter.formatFile(sampleContent);
expect(output).not.toContain('---');
expect(output).toContain('This is the command body.');
});
});
describe('opencodeAdapter', () => {
it('should have correct toolId', () => {
expect(opencodeAdapter.toolId).toBe('opencode');
});
it('should generate correct file path', () => {
const filePath = opencodeAdapter.getFilePath('explore');
expect(filePath).toBe(path.join('.opencode', 'commands', 'opsx-explore.md'));
});
it('should format file with description frontmatter', () => {
const output = opencodeAdapter.formatFile(sampleContent);
expect(output).toContain('---\n');
expect(output).toContain('description: Enter explore mode for thinking');
expect(output).toContain('---\n\n');
expect(output).toContain('This is the command body.');
});
it('should transform colon-based command references to hyphen-based', () => {
const contentWithCommands: CommandContent = {
...sampleContent,
body: 'Use /opsx:new to start, then /opsx:apply to implement.',
};
const output = opencodeAdapter.formatFile(contentWithCommands);
expect(output).toContain('/opsx-new');
expect(output).toContain('/opsx-apply');
expect(output).not.toContain('/opsx:new');
expect(output).not.toContain('/opsx:apply');
});
it('should handle multiple command references in body', () => {
const contentWithMultipleCommands: CommandContent = {
...sampleContent,
body: `/opsx:explore for ideas
/opsx:new to create
/opsx:continue to proceed
/opsx:apply to implement`,
};
const output = opencodeAdapter.formatFile(contentWithMultipleCommands);
expect(output).toContain('/opsx-explore');
expect(output).toContain('/opsx-new');
expect(output).toContain('/opsx-continue');
expect(output).toContain('/opsx-apply');
});
});
describe('qoderAdapter', () => {
it('should have correct toolId', () => {
expect(qoderAdapter.toolId).toBe('qoder');
});
it('should generate correct file path with nested opsx folder', () => {
const filePath = qoderAdapter.getFilePath('explore');
expect(filePath).toBe(path.join('.qoder', 'commands', 'opsx', 'explore.md'));
});
it('should format file with name, description, category, and tags', () => {
const output = qoderAdapter.formatFile(sampleContent);
expect(output).toContain('---\n');
expect(output).toContain('name: OpenSpec Explore');
expect(output).toContain('description: Enter explore mode for thinking');
expect(output).toContain('category: Workflow');
expect(output).toContain('tags: [workflow, explore, experimental]');
expect(output).toContain('---\n\n');
expect(output).toContain('This is the command body.');
});
});
describe('qwenAdapter', () => {
it('should have correct toolId', () => {
expect(qwenAdapter.toolId).toBe('qwen');
});
it('should generate correct file path with .toml extension', () => {
const filePath = qwenAdapter.getFilePath('explore');
expect(filePath).toBe(path.join('.qwen', 'commands', 'opsx-explore.toml'));
});
it('should format file in TOML format', () => {
const output = qwenAdapter.formatFile(sampleContent);
expect(output).toContain('description = "Enter explore mode for thinking"');
expect(output).toContain('prompt = """');
expect(output).toContain('This is the command body.');
expect(output).toContain('"""');
});
});
describe('piAdapter', () => {
it('should have correct toolId', () => {
expect(piAdapter.toolId).toBe('pi');
});
it('should generate correct file path', () => {
const filePath = piAdapter.getFilePath('explore');
expect(filePath).toBe(path.join('.pi', 'prompts', 'opsx-explore.md'));
});
it('should generate correct file paths for different commands', () => {
expect(piAdapter.getFilePath('new')).toBe(path.join('.pi', 'prompts', 'opsx-new.md'));
expect(piAdapter.getFilePath('bulk-archive')).toBe(path.join('.pi', 'prompts', 'opsx-bulk-archive.md'));
});
it('should format file with description frontmatter', () => {
const output = piAdapter.formatFile(sampleContent);
expect(output).toContain('---\n');
expect(output).toContain('description: Enter explore mode for thinking');
expect(output).toContain('---\n\n');
expect(output).toContain('This is the command body.');
});
it('should escape YAML special characters in description', () => {
const contentWithSpecialChars: CommandContent = {
...sampleContent,
description: 'Fix: regression in "auth" feature',
};
const output = piAdapter.formatFile(contentWithSpecialChars);
expect(output).toContain('description: "Fix: regression in \\"auth\\" feature"');
});
it('should escape newlines in description', () => {
const contentWithNewline: CommandContent = {
...sampleContent,
description: 'Line 1\nLine 2',
};
const output = piAdapter.formatFile(contentWithNewline);
expect(output).toContain('description: "Line 1\\nLine 2"');
});
});
describe('roocodeAdapter', () => {
it('should have correct toolId', () => {
expect(roocodeAdapter.toolId).toBe('roocode');
});
it('should generate correct file path', () => {
const filePath = roocodeAdapter.getFilePath('explore');
expect(filePath).toBe(path.join('.roo', 'commands', 'opsx-explore.md'));
});
it('should format file with markdown header (no YAML frontmatter)', () => {
const output = roocodeAdapter.formatFile(sampleContent);
expect(output).toContain('# OpenSpec Explore');
expect(output).toContain('Enter explore mode for thinking');
expect(output).toContain('This is the command body.');
expect(output).not.toContain('---');
});
});
describe('cross-platform path handling', () => {
it('Claude adapter uses path.join for paths', () => {
// path.join handles platform-specific separators
const filePath = claudeAdapter.getFilePath('test');
// On any platform, path.join returns the correct separator
expect(filePath.split(path.sep)).toEqual(['.claude', 'commands', 'opsx', 'test.md']);
});
it('Cursor adapter uses path.join for paths', () => {
const filePath = cursorAdapter.getFilePath('test');
expect(filePath.split(path.sep)).toEqual(['.cursor', 'commands', 'opsx-test.md']);
});
it('Windsurf adapter uses path.join for paths', () => {
const filePath = windsurfAdapter.getFilePath('test');
expect(filePath.split(path.sep)).toEqual(['.windsurf', 'workflows', 'opsx-test.md']);
});
it('All adapters use path.join for paths', () => {
// Verify all adapters produce valid paths
const adapters = [
amazonQAdapter, antigravityAdapter, auggieAdapter, avianAdapter, clineAdapter,
codexAdapter, codebuddyAdapter, continueAdapter, costrictAdapter,
crushAdapter, factoryAdapter, geminiAdapter, githubCopilotAdapter,
iflowAdapter, kilocodeAdapter, opencodeAdapter, piAdapter, qoderAdapter,
qwenAdapter, roocodeAdapter
];
for (const adapter of adapters) {
const filePath = adapter.getFilePath('test');
expect(filePath.length).toBeGreaterThan(0);
expect(filePath.includes(path.sep) || filePath.includes('.')).toBe(true);
}
});
});
});