(targetPath, options = {})
| 92 | } |
| 93 | |
| 94 | export async function analyzePath(targetPath, options = {}) { |
| 95 | const target = await resolveTarget(targetPath); |
| 96 | const result = createEvaluationResult(target); |
| 97 | |
| 98 | if (target.kind === "skill") { |
| 99 | appendFragment(result, await evaluateSkill(target.path)); |
| 100 | } else if (target.kind === "plugin") { |
| 101 | appendFragment(result, await evaluatePlugin(target.path)); |
| 102 | } else { |
| 103 | result.checks.push( |
| 104 | createCheck({ |
| 105 | id: "generic-target-analysis", |
| 106 | category: "best-practice", |
| 107 | severity: "info", |
| 108 | status: "info", |
| 109 | message: "The target is not a skill or plugin root, so only generic code, coverage, and budget analysis will run.", |
| 110 | evidence: [path.resolve(target.path)], |
| 111 | remediation: ["Point the analyzer at a skill directory or plugin root for richer structural checks."], |
| 112 | }), |
| 113 | ); |
| 114 | } |
| 115 | |
| 116 | const baseline = await loadBudgetBaseline(); |
| 117 | const rawBudget = await computeBudgetProfile(target); |
| 118 | addBudgetFindings(result, applyBudgetBands(rawBudget, baseline), baseline.evidence); |
| 119 | |
| 120 | const observedUsageFragment = await analyzeObservedUsage(options.observedUsagePaths || [], rawBudget, target); |
| 121 | if (observedUsageFragment) { |
| 122 | result.observedUsage = observedUsageFragment.observedUsage; |
| 123 | appendFragment(result, observedUsageFragment); |
| 124 | } |
| 125 | |
| 126 | appendFragment(result, await analyzeCodeMetrics(target.path, target)); |
| 127 | appendFragment(result, await analyzeCoverageArtifacts(target.path)); |
| 128 | |
| 129 | const extensions = await runMetricPacks(target, options.metricPackManifests || []); |
| 130 | result.extensions = extensions.map(normalizeExtensionPayload); |
| 131 | |
| 132 | result.summary = computeSummary(result); |
| 133 | result.measurementPlan = buildMeasurementPlan(result); |
| 134 | result.artifacts.push(result.measurementPlan.artifact); |
| 135 | result.improvementBrief = buildImprovementBrief(result); |
| 136 | result.workflowGuide = await buildWorkflowGuide(target.path, { |
| 137 | goal: result.observedUsage?.sampleCount ? "measure" : "evaluate", |
| 138 | }); |
| 139 | result.measurementPlan.nextAction = createMeasurementPlanNextAction(result.measurementPlan); |
| 140 | applyEvaluationPresentation(result); |
| 141 | return result; |
| 142 | } |
| 143 | |
| 144 | export async function explainBudget(targetPath) { |
| 145 | const target = await resolveTarget(targetPath); |
no test coverage detected