( allWorkflows: WorkflowManifestEntry[], requestedWorkflowIds: string[] | undefined, ctx: PredicateContext, )
| 174 | * 4. Filter all by availability + predicates |
| 175 | */ |
| 176 | export function selectWorkflowsForMcp( |
| 177 | allWorkflows: WorkflowManifestEntry[], |
| 178 | requestedWorkflowIds: string[] | undefined, |
| 179 | ctx: PredicateContext, |
| 180 | ): WorkflowManifestEntry[] { |
| 181 | const selectedIds = new Set<string>(); |
| 182 | |
| 183 | // 1. Include auto-include workflows whose predicates pass |
| 184 | for (const wf of getAutoIncludeWorkflows(allWorkflows, ctx)) { |
| 185 | selectedIds.add(wf.id); |
| 186 | } |
| 187 | |
| 188 | // 2/3. Include requested or default-enabled workflows |
| 189 | if (requestedWorkflowIds && requestedWorkflowIds.length > 0) { |
| 190 | for (const id of requestedWorkflowIds) { |
| 191 | selectedIds.add(id); |
| 192 | } |
| 193 | } else { |
| 194 | for (const wf of getDefaultEnabledWorkflows(allWorkflows)) { |
| 195 | selectedIds.add(wf.id); |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | // Build final list from selected IDs |
| 200 | const selected = allWorkflows.filter((wf) => selectedIds.has(wf.id)); |
| 201 | |
| 202 | // 4. Filter by availability + predicates |
| 203 | return filterEnabledWorkflows(selected, ctx); |
| 204 | } |
no test coverage detected