-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Expand file tree
/
Copy pathcommand-surface.ts
More file actions
43 lines (34 loc) · 1.77 KB
/
Copy pathcommand-surface.ts
File metadata and controls
43 lines (34 loc) · 1.77 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
import { CommandAdapterRegistry } from './command-generation/index.js';
import { getInvocationForAdapter, type CommandInvocation } from './command-generation/invocation.js';
import type { Delivery } from './global-config.js';
export type CommandSurfaceCapability = 'adapter-backed' | 'skills-invocable' | 'none';
/**
* How the tool spells its OpenSpec commands: the name from the command files
* its adapter writes, the prefix the adapter declares. Returns undefined for
* tools with no command adapter, which have no command names to spell.
*/
export function resolveCommandInvocation(toolId: string): CommandInvocation | undefined {
const adapter = CommandAdapterRegistry.get(toolId);
return adapter ? getInvocationForAdapter(adapter) : undefined;
}
export function resolveCommandSurfaceCapability(toolId: string): CommandSurfaceCapability {
if (CommandAdapterRegistry.has(toolId)) {
return 'adapter-backed';
}
if (toolId === 'codex' || toolId === 'warp') {
return 'skills-invocable';
}
return 'none';
}
export function shouldGenerateSkillsForTool(toolId: string, delivery: Delivery): boolean {
return delivery !== 'commands' || resolveCommandSurfaceCapability(toolId) === 'skills-invocable';
}
export function shouldRemoveSkillsForTool(toolId: string, delivery: Delivery): boolean {
return delivery === 'commands' && resolveCommandSurfaceCapability(toolId) !== 'skills-invocable';
}
export function shouldGenerateCommandsForTool(toolId: string, delivery: Delivery): boolean {
return delivery !== 'skills' && resolveCommandSurfaceCapability(toolId) === 'adapter-backed';
}
export function shouldReconcileCommandFilesForTool(toolId: string, delivery: Delivery): boolean {
return delivery === 'skills' && resolveCommandSurfaceCapability(toolId) === 'adapter-backed';
}