| 92 | } |
| 93 | |
| 94 | export const call: LocalCommandCall = async args => { |
| 95 | const definitions = await getWorkflowDefinitions(getCwd()) |
| 96 | const workflows = definitions.filter( |
| 97 | ( |
| 98 | definition, |
| 99 | ): definition is WorkflowDefinition & { command: WorkflowPromptCommand } => |
| 100 | definition.command.type === 'prompt', |
| 101 | ) |
| 102 | |
| 103 | if (workflows.length === 0) { |
| 104 | return { type: 'text', value: formatNoWorkflowsMessage() } |
| 105 | } |
| 106 | |
| 107 | const query = normalizeWorkflowQuery(args) |
| 108 | if (!query) { |
| 109 | return { type: 'text', value: formatWorkflowList(workflows) } |
| 110 | } |
| 111 | |
| 112 | const match = workflows.find( |
| 113 | ({ command }) => |
| 114 | command.name === query || getCommandName(command) === query, |
| 115 | ) |
| 116 | |
| 117 | if (!match) { |
| 118 | return { |
| 119 | type: 'text', |
| 120 | value: [ |
| 121 | `Workflow not found: ${query}`, |
| 122 | '', |
| 123 | formatWorkflowList(workflows), |
| 124 | ].join('\n'), |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | return { type: 'text', value: formatWorkflowDetail(match) } |
| 129 | } |
nothing calls this directly
no test coverage detected