MCPcopy Create free account
hub / github.com/openai/plugins / buildWorkflowGuide

Function buildWorkflowGuide

plugins/plugin-eval/src/core/workflow-guide.js:342–397  ·  view source on GitHub ↗
(targetPath, options = {})

Source from the content-addressed store, hash-verified

340}
341
342export 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}

Callers 7

runCliFunction · 0.90
initializeBenchmarkFunction · 0.90
runBenchmarkFunction · 0.90
analyzePathFunction · 0.90
explainBudgetFunction · 0.90
recommendMeasuresFunction · 0.90

Calls 12

resolveTargetFunction · 0.90
pathExistsFunction · 0.90
formatCommandPathFunction · 0.90
relativePathFunction · 0.90
benchmarkConfigPathFunction · 0.85
usageLogPathFunction · 0.85
inferGoalFromRequestFunction · 0.85
createEntryFunction · 0.85
inferRecommendedGoalFunction · 0.85
targetLabelFunction · 0.70
shellQuoteFunction · 0.70

Tested by

no test coverage detected