(targetPath, options = {})
| 340 | } |
| 341 | |
| 342 | export async function buildWorkflowGuide(targetPath, options = {}) { |
| 343 | const target = await resolveTarget(targetPath); |
| 344 | const status = { |
| 345 | hasBenchmarkConfig: await pathExists(benchmarkConfigPath(target)), |
| 346 | hasUsageLog: await pathExists(usageLogPath(target)), |
| 347 | }; |
| 348 | const requestMatch = inferGoalFromRequest(options.request || ""); |
| 349 | |
| 350 | const entries = [ |
| 351 | createEntry("analysis", target, status), |
| 352 | createEntry("evaluate", target, status), |
| 353 | createEntry("budget", target, status), |
| 354 | createEntry("measure", target, status), |
| 355 | createEntry("benchmark", target, status), |
| 356 | createEntry("next", target, status), |
| 357 | ]; |
| 358 | |
| 359 | const requestedGoal = options.goal || requestMatch?.goal || null; |
| 360 | const recommendedGoal = inferRecommendedGoal(status, requestedGoal); |
| 361 | const recommendedWorkflow = entries.find((entry) => entry.id === recommendedGoal) || entries[0]; |
| 362 | const routedRequest = options.request || recommendedWorkflow.chatPrompt; |
| 363 | const commandTargetPath = formatCommandPath(target.path); |
| 364 | const routingExplanation = requestMatch |
| 365 | ? `Plugin Eval routed "${options.request}" to ${recommendedWorkflow.label} because ${requestMatch.reason}.` |
| 366 | : `Plugin Eval recommended ${recommendedWorkflow.label} from the current local state for this ${targetLabel(target)}.`; |
| 367 | |
| 368 | const payload = { |
| 369 | kind: "workflow-guide", |
| 370 | createdAt: new Date().toISOString(), |
| 371 | target: { |
| 372 | ...target, |
| 373 | relativePath: relativePath(process.cwd(), target.path), |
| 374 | }, |
| 375 | requestedGoal, |
| 376 | requestedChatPrompt: options.request || null, |
| 377 | requestRouting: requestMatch, |
| 378 | recommendedWorkflowId: recommendedWorkflow.id, |
| 379 | recommendedWorkflow, |
| 380 | workflowStatus: status, |
| 381 | beginnerSummary: |
| 382 | "Start with a natural chat request, then let plugin-eval show the exact local command sequence behind it.", |
| 383 | startHere: { |
| 384 | chatPrompt: routedRequest, |
| 385 | label: recommendedWorkflow.label, |
| 386 | summary: recommendedWorkflow.summary, |
| 387 | routingExplanation, |
| 388 | startCommand: `plugin-eval start ${commandTargetPath} --request ${shellQuote(routedRequest)} --format markdown`, |
| 389 | firstCommand: recommendedWorkflow.firstCommand, |
| 390 | commands: recommendedWorkflow.commands, |
| 391 | }, |
| 392 | entrypoints: entries, |
| 393 | nextSteps: recommendedWorkflow.commands, |
| 394 | }; |
| 395 | payload.nextAction = createWorkflowGuideNextAction(payload); |
| 396 | return payload; |
| 397 | } |
no test coverage detected