@uibot/evaluation 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,64 @@
1
+ import type { VisualEvaluationEvidence } from "@uibot/contracts";
2
+ import type { ShadowEvalResult } from "./types.js";
3
+ export interface RegressionCheckResult {
4
+ /** true if all checked regressions pass; false blocks promotion */
5
+ passed: boolean;
6
+ /** IDs of regression records that failed the check */
7
+ failures: string[];
8
+ /** IDs of all regressions that were actually evaluated (excludes skipped) */
9
+ checkedCaseIds: string[];
10
+ }
11
+ export type RegressionCheckFn = (proposedBody: string) => Promise<RegressionCheckResult>;
12
+ export interface AutoPromoterOptions {
13
+ /** Root directory containing `.uibot/skills/` */
14
+ rootDir: string;
15
+ /**
16
+ * Optional hard gate: run before committing the promotion. Returning
17
+ * `{ passed: false }` blocks even when `shadowResult.decision === "promoted"`
18
+ * and yields `PromotionResult = "rejected-regression"`. Throwing is also
19
+ * treated as a failure (conservative — inspired by Darwin-Skill's ratchet).
20
+ */
21
+ regressionCheck?: RegressionCheckFn;
22
+ }
23
+ export type PromotionResult = "promoted" | "pending" | "rejected" | "rejected-regression";
24
+ export interface PromotionDecision {
25
+ skillId: string;
26
+ proposalId: string;
27
+ fromVersion: string;
28
+ toVersion: string;
29
+ decision: PromotionResult;
30
+ meanDeltaScore: number;
31
+ safetyRegressions: string[];
32
+ caseCount: number;
33
+ timestamp: string;
34
+ visualEvidence?: Array<{
35
+ caseId: string;
36
+ parent?: VisualEvaluationEvidence;
37
+ proposed?: VisualEvaluationEvidence;
38
+ }>;
39
+ /** Regression IDs that failed the hard gate (only set when decision is "rejected-regression") */
40
+ regressionFailures?: string[];
41
+ /** All regression IDs that were evaluated (diagnostic) */
42
+ regressionChecked?: string[];
43
+ }
44
+ /**
45
+ * Atomically promotes a proposed skill version when shadow evaluation passes
46
+ * and (if configured) the regression hard gate holds.
47
+ *
48
+ * Promotion flow:
49
+ * 1. If shadow decision is not "promoted" → record decision as-is, return.
50
+ * 2. If `regressionCheck` is configured → run it; block on failure.
51
+ * 3. Read current SKILL.md version from frontmatter.
52
+ * 4. Archive current SKILL.md to `versions/<currentVersion>/SKILL.md`.
53
+ * 5. Write proposed body as new SKILL.md with incremented version.
54
+ * 6. Write `decision.json` with full promotion metadata.
55
+ *
56
+ * No external dependencies — pure fs operations for auditability.
57
+ */
58
+ export declare class AutoPromoter {
59
+ private readonly options;
60
+ constructor(options: AutoPromoterOptions);
61
+ tryPromote(shadowResult: ShadowEvalResult, proposedBody: string): Promise<PromotionResult>;
62
+ private performPromote;
63
+ private writeDecision;
64
+ }
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Design-quality linter — a deterministic anti-pattern detector for generated
3
+ * UI, giving UIBot a *measurable* design-quality signal instead of subjective
4
+ * review.
5
+ *
6
+ * The rule DATA (the SLOP "AI-generation tells" and the QUALITY accessibility /
7
+ * readability rules, plus the buzzword list and the regexes / thresholds) is
8
+ * adapted from the open-source **impeccable** project by Paul Bakaus
9
+ * (github.com/pbakaus/impeccable), licensed Apache-2.0. Attribution is required
10
+ * and retained here. We port only the framework-agnostic deterministic rule data
11
+ * (not impeccable's Puppeteer/live-edit machinery), and run it over the text /
12
+ * className strings present in a UIBot spec or rendered HTML — UIBot owns its
13
+ * render tree, so it never needs to scrape a live URL.
14
+ *
15
+ * The standout use is as a promotion gate: `createDesignQualityVisualScoreProvider()`
16
+ * adapts the linter to the evaluation runner's existing `VisualScoreProvider`
17
+ * seam, so ShadowRunner / AutoPromoter can score a candidate spec's design
18
+ * quality with no type changes. It is also usable standalone via
19
+ * `analyzeDesignQuality()`.
20
+ */
21
+ export type DesignQualitySeverity = "P0" | "P1" | "P2" | "P3";
22
+ export type DesignQualityCategory = "slop" | "quality";
23
+ /**
24
+ * `blocking` = readability / accessibility floor (the `quality` category): never
25
+ * exemptable, a page that trips it should not ship as-is. `advisory` = taste
26
+ * (the `slop` category): a brand guide may legitimately exempt it.
27
+ */
28
+ export type DesignQualityLevel = "blocking" | "advisory";
29
+ export interface DesignQualityFinding {
30
+ ruleId: string;
31
+ category: DesignQualityCategory;
32
+ severity: DesignQualitySeverity;
33
+ level: DesignQualityLevel;
34
+ message: string;
35
+ /** Number of times the anti-pattern fired (≥1). */
36
+ count: number;
37
+ }
38
+ export interface DesignQualityReport {
39
+ /** Quality score in [0, 1] — 1.0 = no anti-patterns detected. */
40
+ score: number;
41
+ /** Letter grade derived from `score`. */
42
+ grade: "A" | "B" | "C" | "D" | "F";
43
+ findings: DesignQualityFinding[];
44
+ /** True when any `blocking` finding fired. */
45
+ blocked: boolean;
46
+ }
47
+ export interface DesignQualityInput {
48
+ /** Rendered HTML (drives className / inline-style rules). */
49
+ html?: string;
50
+ /** Visible / source text (drives copy rules — buzzwords, cadence, em-dashes). */
51
+ text?: string;
52
+ /**
53
+ * Rule ids to skip, e.g. a dark brand guide exempting `github-dark-glow`.
54
+ * Only `advisory` rules can be exempted; the readability floor ignores this.
55
+ */
56
+ exempt?: readonly string[];
57
+ }
58
+ /**
59
+ * True when the body carries nothing to judge: an HTML page with no visible text
60
+ * or media/controls, or a spec with no text-like fields and almost no blocks.
61
+ * The rule scan finds no anti-patterns in such a shell, so scoring it would
62
+ * hand out a perfect grade for doing nothing. Deliberately conservative: any
63
+ * media, form control, or a handful of blocks counts as substance.
64
+ */
65
+ export declare function isEmptyDesignShell(body: string): boolean;
66
+ /**
67
+ * Run the deterministic design-quality rules over the given input and return a
68
+ * scored report. The score starts at 1.0 and each firing rule subtracts a
69
+ * severity-weighted penalty (capped per rule so one noisy rule can't dominate).
70
+ */
71
+ export declare function analyzeDesignQuality(input: DesignQualityInput): DesignQualityReport;
72
+ /** Convenience: just the [0,1] score. */
73
+ export declare function scoreDesignQuality(input: DesignQualityInput): number;
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ function b(e){return e==="quality"?"blocking":"advisory"}var v=["streamline your","empower your","supercharge your","unlock the power","best-in-class","enterprise-grade","next-generation","cutting-edge","revolutionize","game-changer","game changer","future-proof","seamless experience","drive growth","harness the power","take it to the next level","world-class","state-of-the-art","robust solution","powerful platform","effortlessly","seamlessly integrate","elevate your","transform your"],h=["Inter","Roboto","Geist","Fraunces","Plus Jakarta","Space Grotesk"];function n(e,r){let t=e.match(r);return t?t.length:0}var x=[{id:"marketing-buzzword",category:"slop",severity:"P2",message:"Marketing buzzwords read as AI filler \u2014 prefer concrete, specific copy.",detect:(e)=>{let r=e.toLowerCase();return v.reduce((t,s)=>t+(r.includes(s)?1:0),0)}},{id:"em-dash-overuse",category:"slop",severity:"P3",message:"Em-dash overuse (\u22655) is a strong AI-writing tell.",detect:(e)=>{let r=n(e,/[\u2014]|--(?=\S)/g);return r>=5?r-4:0}},{id:"aphoristic-cadence",category:"slop",severity:"P2",message:'Manufactured-contrast cadence ("Not an X. Just Y.") is a recognizable AI pattern.',detect:(e)=>{let r=n(e,/\bNot\s+(?:an?|just)\b[^.?!]*[.?!]/gi),t=n(e,/\b[A-Z][^.?!]*\.\s+(?:No|Just)\s+[a-z]/g),s=r+t;return s>=3?s:0}},{id:"numbered-section-markers",category:"slop",severity:"P3",message:"Numbered section scaffolding (01 / 02 / 03) is an overused AI layout tell.",detect:(e)=>{let r=e.match(/\b(0[1-9]|1[0-2])\b/g)??[],t=new Set(r);if(t.size<3)return 0;let s=[...t].map(Number).sort((c,i)=>c-i);return s.some((c,i)=>i>0&&c-s[i-1]===1)?t.size:0}}],D=[{id:"gradient-text",category:"slop",severity:"P2",message:"Gradient text (bg-clip-text + transparent) is a classic AI hero tell.",detect:(e)=>n(e,/bg-clip-text[^"']*text-transparent|text-transparent[^"']*bg-clip-text|-webkit-background-clip\s*:\s*text/gi)},{id:"ai-color-palette",category:"slop",severity:"P2",message:"Purple/violet gradient palette is the most recognizable AI color tell.",detect:(e)=>n(e,/(from|via|to)-(purple|violet|fuchsia|indigo)-\d{3}|linear-gradient\([^)]*(?:#(?:8b5cf6|a855f7|7c3aed|6366f1))/gi)},{id:"side-tab",category:"slop",severity:"P2",message:"Thick colored side-border on a card (border-l-4 + accent) is the single most recognizable AI card tell.",detect:(e)=>n(e,/border-l-(4|8)\s+border-(purple|violet|indigo|blue|primary)/gi)},{id:"overused-font",category:"slop",severity:"P3",message:"Over-represented font (Inter/Geist/\u2026) without a brand reason reads as default AI styling.",detect:(e)=>h.reduce((r,t)=>r+(new RegExp(`font-family[^;"']*${t}`,"i").test(e)?1:0),0)},{id:"emoji-icon",category:"slop",severity:"P2",message:"Emoji used as a heading/list/button icon is a stock AI tell \u2014 use a real icon or nothing.",detect:(e)=>n(e,/<(?:h[1-6]|li|button|summary|th)\b[^>]*>\s*(?:<[^>]+>\s*)*\p{Extended_Pictographic}/giu)},{id:"github-dark-glow",category:"slop",severity:"P3",message:"Flat #0D1117 background with a neon cyan/violet glow is the default AI dark-mode look.",detect:(e)=>/#0d1117/i.test(e)&&/(?:box-shadow|drop-shadow|text-shadow)[^;"']*(?:#06b6d4|#22d3ee|#00f0ff|#a78bfa|#8b5cf6|cyan|violet)/i.test(e)?1:0},{id:"tiny-text",category:"quality",severity:"P1",message:"Body text below ~14px (text-[10px]/[11px]/[12px]) harms readability and accessibility.",detect:(e)=>n(e,/text-\[(?:8|9|10|11|12)px\]|font-size\s*:\s*(?:8|9|10|11|12)px/gi)},{id:"gray-on-color",category:"quality",severity:"P1",message:"Gray text on a colored fill commonly fails WCAG contrast.",detect:(e)=>n(e,/bg-(?:primary|blue|indigo|violet|purple)-\d{3}[^"']*text-(?:gray|slate|zinc|neutral)-\d{3}/gi)}],y={P0:0.3,P1:0.15,P2:0.08,P3:0.04};function E(e){if(e>=0.9)return"A";if(e>=0.8)return"B";if(e>=0.65)return"C";if(e>=0.5)return"D";return"F"}var p=8,P=/<\/?[a-z][^>]*>/i,S=/<(img|svg|canvas|video|picture|iframe|input|textarea|select|button)\b/i,f="title|text|label|content|description|heading|subtitle|placeholder|body|caption|name",w=new RegExp(`["']?\\b(?:${f})["']?\\s*:\\s*["']([^"'\\n]*)["']`,"gi"),Q=new RegExp(`^\\s*-?\\s*(?:${f})\\s*:\\s*([^\\s"'{\\[][^\\n]*)$`,"gim"),T=/["']?\btype["']?\s*:/gi,k=2;function m(e){return(e.match(/[\p{L}\p{N}]/gu)??[]).length}function R(e){if(!e.trim())return!0;if(P.test(e)){if(S.test(e))return!1;let s=e.replace(/<(script|style)\b[\s\S]*?<\/\1>/gi," ").replace(/<!--[\s\S]*?-->/g," ").replace(/<[^>]*>/g," ");return m(s)<p}if((e.match(T)?.length??0)>=k)return!1;let t=0;for(let s of[w,Q])for(let o of e.matchAll(s))t+=m(o[1]??"");return t<p}function I(e){let r=e.text??e.html??"",t=e.html??e.text??"",s=new Set(e.exempt??[]),o=[],c=(a,g)=>{for(let l of a){let u=b(l.category);if(u==="advisory"&&s.has(l.id))continue;let d=l.detect(g);if(d>0)o.push({ruleId:l.id,category:l.category,severity:l.severity,level:u,message:l.message,count:d})}};c(x,r),c(D,t);let i=1;for(let a of o){let g=Math.min(y[a.severity]*(1+(a.count-1)/3),y[a.severity]*2);i-=g}return i=Math.max(0,Math.min(1,i)),{score:i,grade:E(i),findings:o,blocked:o.some((a)=>a.level==="blocking")}}function _(e){return I(e).score}export{I as analyzeDesignQuality,R as isEmptyDesignShell,_ as scoreDesignQuality};
@@ -0,0 +1,9 @@
1
+ import type { VisualScoreProvider } from "./types.js";
2
+ export * from "./design-quality-rules.js";
3
+ /**
4
+ * Adapt the linter to the evaluation runner's `VisualScoreProvider` seam so it
5
+ * can be injected into `EvalRunner` / `ShadowRunner` / `AutoPromoter` as the
6
+ * visual-quality scorer. The spec body (YAML/JSON) carries both copy and
7
+ * className strings, so both text and html rule sets apply to it.
8
+ */
9
+ export declare function createDesignQualityVisualScoreProvider(): VisualScoreProvider;
@@ -0,0 +1,27 @@
1
+ import type { ExecutionRuntime } from "@uibot/contracts";
2
+ import { type EvalRunnerOptions } from "./runner.js";
3
+ import type { EvalCase, EvalScore } from "./types.js";
4
+ export interface EvalRunnerWithExecutionOptions extends EvalRunnerOptions {
5
+ executionRuntime?: ExecutionRuntime;
6
+ /**
7
+ * Weight given to the execution-pass-rate component when folding it into
8
+ * the static `overallScore`. The final score is
9
+ * `static.overallScore * (1 - executionWeight) + executionPassRate * executionWeight`.
10
+ *
11
+ * Default `0.3` reflects a deliberate tradeoff: the static heuristic
12
+ * (renderable / schemaValid / visual) still dominates because it captures
13
+ * structural correctness that no single execution check verifies, but
14
+ * execution is given enough weight that a real runtime failure visibly
15
+ * moves the score. Bump toward `0.5` if execution checks cover the bulk
16
+ * of what you care about; toward `0.1` if checks are sanity probes.
17
+ */
18
+ executionWeight?: number;
19
+ }
20
+ export declare class EvalRunnerWithExecution {
21
+ private readonly staticRunner;
22
+ private readonly executionRuntime;
23
+ private readonly executionWeight;
24
+ constructor(options?: EvalRunnerWithExecutionOptions);
25
+ run(evalCase: EvalCase, skillBody: string): Promise<EvalScore>;
26
+ checkSafetyRegressions(parentBody: string, proposedBody: string): string[];
27
+ }
@@ -0,0 +1,14 @@
1
+ export type { EvalCase, EvalExecutionCheck, EvalExecutionResult, EvalScore, EvalReport, ShadowEvalResult, VisualScoreProvider, } from "./types.js";
2
+ export { EvalRunner } from "./runner.js";
3
+ export type { EvalRunnerOptions } from "./runner.js";
4
+ export { EvalRunnerWithExecution } from "./execution-runner.js";
5
+ export type { EvalRunnerWithExecutionOptions } from "./execution-runner.js";
6
+ export { ShadowRunner } from "./shadow-runner.js";
7
+ export type { ShadowRunnerOptions } from "./shadow-runner.js";
8
+ export { scoreCandidate, scoreCandidateSync, scoreCandidateDelta, createEvaluateCandidate, } from "./score-candidate.js";
9
+ export type { ScoreCandidateOptions, ScoreRunner } from "./score-candidate.js";
10
+ export { AutoPromoter } from "./auto-promoter.js";
11
+ export type { AutoPromoterOptions, PromotionResult, PromotionDecision } from "./auto-promoter.js";
12
+ export { analyzeDesignQuality, isEmptyDesignShell, scoreDesignQuality, createDesignQualityVisualScoreProvider, } from "./design-quality.js";
13
+ export type { DesignQualityReport, DesignQualityFinding, DesignQualityLevel, DesignQualityInput, DesignQualityCategory, DesignQualitySeverity, } from "./design-quality.js";
14
+ export { visualSubjectHash, isVisualScore } from "./visual-evidence.js";
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{createHash as B}from"crypto";function f(e,t){return B("sha256").update(JSON.stringify([e,t])).digest("hex")}function E(e){return typeof e==="number"&&Number.isFinite(e)&&e>=0&&e<=1}var H=new Set(["rule-scan","structural-heuristic","model-text","model-screenshot","legacy-provider","unassessed"]),W=new Set(["empty-input","invalid-score","provider-failed","provider-not-run","invalid-evidence","screenshot-unavailable","timeout"]);async function k(e,t,r){let s=f(t,r),o=(i)=>({status:"unavailable",method:"unassessed",subjectHash:s,reason:i});if(!t.trim())return o("empty-input");try{if(e.evaluate){let n=await e.evaluate(t,r);if(!n||n.subjectHash!==s||!H.has(n.method))return o("invalid-evidence");if(n.status==="scored"&&n.method!=="unassessed"&&E(n.score))return{status:"scored",method:n.method,subjectHash:s,score:n.score};if(n.status==="unavailable"&&n.score===void 0&&W.has(n.reason))return{status:"unavailable",method:n.method,subjectHash:s,reason:n.reason};return o("invalid-evidence")}let i=await e(t,r);return E(i)?{status:"scored",method:"legacy-provider",subjectHash:s,score:i}:o("invalid-score")}catch{return o("provider-failed")}}function m(e){let t=e.visualEvidence;return t!==void 0&&(t.status!=="scored"||!E(t.score)||t.method==="unassessed")}var z=[{label:"_js operator",re:/_js\s*:/g},{label:"_secret operator",re:/_secret\s*:/g},{label:"external URL",re:/https?:\/\/[^\s'"]+/g}];function U(e,t){let r=[];for(let{label:s,re:o}of z){let i=(e.match(o)??[]).length,n=(t.match(o)??[]).length;if(n>i)r.push(`New ${s} introduced (${i} \u2192 ${n})`)}return r}var h={layout:["PageLayout","Card","Box","Tabs","Drawer","Modal"],nav:["PageSiderMenu","Breadcrumb","MenuLink","Link"],data:["Table","List","Stat"],form:["Form","Form.Input","Form.Select","Form.TextArea","Form.Checkbox"],feedback:["Toast","Dialog","Skeleton"],content:["Heading","Paragraph","Markdown","Divider"],action:["Button"]},J=["Form.Submit","Button"];function K(e){let t=Object.values(h).filter((l)=>l.some((j)=>e.includes(j))).length,r=Object.keys(h).length,s=Math.min(1,t/(r*0.7)),o=e.split(`
3
+ `).filter((l)=>l.trim().length>0).map((l)=>l.match(/^(\s*)/)?.[1]?.length??0),i=o.length>0?Math.max(...o):0,n=Math.min(1,i/12),a=h.form.some((l)=>e.includes(l)),d=J.some((l)=>e.includes(l)),c=!a?1:d?1:0.4,u=[...h.layout,...h.data].some((l)=>e.includes(l)),g=[...h.content,...h.action].some((l)=>e.includes(l)),y=u&&g?1:u||g?0.6:0.2;return s*0.35+n*0.15+c*0.2+y*0.3}function D(e){let t=/```ya?ml[\s\S]*?```/i.test(e),r=/\bpage\s*:/i.test(e),s=/\bblocks\s*:/i.test(e);if(t)return 1;if(r&&s)return 0.9;if(r||s)return 0.5;return 0}function I(e,t,r){return e*0.4+t*0.35+r*0.25}class p{visualScoreProvider;constructor(e={}){this.visualScoreProvider=e.visualScoreProvider??void 0}async run(e,t){let r=D(t),s=e.expectedBlocks.filter((a)=>t.toLowerCase().includes(a.toLowerCase())),o=e.expectedBlocks.length===0?1:s.length/e.expectedBlocks.length,i=this.visualScoreProvider?await k(this.visualScoreProvider,t,e.intent):this.structuralEvidence(t,e.intent),n=i.status==="scored"?i.score:0;return{renderable:r,schemaValid:o,visualHeuristic:n,visualEvidence:i,overallScore:I(r,o,n),safetyOk:!0}}runSync(e,t){let r=D(t),s=e.expectedBlocks.filter((a)=>t.toLowerCase().includes(a.toLowerCase())),o=e.expectedBlocks.length===0?1:s.length/e.expectedBlocks.length,i=this.visualScoreProvider?{status:"unavailable",method:"unassessed",subjectHash:f(t,e.intent),reason:"provider-not-run"}:this.structuralEvidence(t,e.intent),n=i.status==="scored"?i.score:0;return{renderable:r,schemaValid:o,visualHeuristic:n,visualEvidence:i,overallScore:I(r,o,n),safetyOk:!0}}structuralEvidence(e,t){let r=f(e,t);return e.trim()?{status:"scored",method:"structural-heuristic",subjectHash:r,score:K(e)}:{status:"unavailable",method:"unassessed",subjectHash:r,reason:"empty-input"}}checkSafetyRegressions(e,t){return U(e,t)}}var G=0.3;function q(e){return Math.max(0,Math.min(1,e))}function Y(e,t){return Bun.deepEquals(e,t)}function X(e,t){if(!t.success)return{passed:!1,failureReason:t.errorMessage??t.errorCode??"execution failed"};for(let r of e.expectedStdoutIncludes??[])if(!t.stdout.includes(r))return{passed:!1,failureReason:`stdout missing expected text: ${r}`};for(let r of e.expectedStderrIncludes??[])if(!t.stderr.includes(r))return{passed:!1,failureReason:`stderr missing expected text: ${r}`};if(Object.hasOwn(e,"expectedReturnValue")&&!Y(t.returnValue,e.expectedReturnValue))return{passed:!1,failureReason:"returnValue did not match expected value"};return{passed:!0}}function Z(e,t){return{passed:t.passed,success:e.success,stdout:e.stdout,stderr:e.stderr,durationMs:e.durationMs,...e.errorCode?{errorCode:e.errorCode}:{},...e.errorMessage?{errorMessage:e.errorMessage}:{},...t.failureReason?{failureReason:t.failureReason}:{}}}function ee(){return{passed:!1,success:!1,stdout:"",stderr:"",durationMs:0,errorCode:"runtime-not-configured",errorMessage:"ExecutionRuntime is not configured",failureReason:"runtime not configured"}}function te(e){let t=e instanceof Error?e.message:String(e);return{passed:!1,success:!1,stdout:"",stderr:"",durationMs:0,errorCode:"internal-error",errorMessage:t,failureReason:t}}var re=/\{\{skillBody\}\}(?!Json)/,O="{{skillBodyJson}}";function ne(e,t,r){if(re.test(e))throw Error("EvalExecutionCheck.code contains unsafe `{{skillBody}}` placeholder. "+"Use `{{skillBodyJson}}` (JSON-encoded) instead \u2014 raw substitution lets "+"a malicious candidate body escape the eval template.");if(r==="shell"&&e.includes(O))throw Error('EvalExecutionCheck.code uses `{{skillBodyJson}}` in a shell check, but JSON encoding does not neutralize bash command substitution. Pass the skill body via `check.env` (e.g. SKILL_BODY) and read it inside the shell script with `"$SKILL_BODY"` instead.');return e.replaceAll(O,JSON.stringify(t))}function se(e,t){return{language:e.language,code:ne(e.code,t,e.language),...e.timeoutMs!==void 0?{timeout:e.timeoutMs}:{},fetchAllowed:e.fetchAllowed===!0,...e.env?{env:e.env}:{}}}class x{staticRunner;executionRuntime;executionWeight;constructor(e={}){this.staticRunner=new p(e.visualScoreProvider!==void 0?{visualScoreProvider:e.visualScoreProvider}:{}),this.executionRuntime=e.executionRuntime,this.executionWeight=q(e.executionWeight??G)}async run(e,t){let r=await this.staticRunner.run(e,t),s=e.executionChecks??[];if(s.length===0)return r;let o=[];for(let n of s){if(!this.executionRuntime){o.push(ee());continue}try{let a=await this.executionRuntime.run(se(n,t));o.push(Z(a,X(n,a)))}catch(a){o.push(te(a))}}let i=o.length===0?void 0:o.filter((n)=>n.passed).length/o.length;if(i===void 0)return r;return{...r,executionScore:i,executionResults:o,overallScore:r.overallScore*(1-this.executionWeight)+i*this.executionWeight}}checkSafetyRegressions(e,t){return this.staticRunner.checkSafetyRegressions(e,t)}}function V(e={}){if(e.runner)return e.runner;return new p(e.visualScoreProvider!==void 0?{visualScoreProvider:e.visualScoreProvider}:{})}async function R(e,t,r={}){return V(r).run(e,t)}function oe(e,t,r={}){return new p(r.visualScoreProvider!==void 0?{visualScoreProvider:r.visualScoreProvider}:{}).runSync(e,t)}async function _(e,t,r,s={}){let o=V(s),[i,n]=await Promise.all([o.run(e,t),o.run(e,r)]);if(m(i)||m(n))throw Error("visual-evaluation-unavailable");return n.overallScore-i.overallScore}function ie(e={}){let t=e.makeCase??((r)=>({id:`cand-${r.candidateIndex}`,intent:"tournament",expectedBlocks:[],skillId:r.skillId}));return async(r)=>{let s=t(r);if(!s)return 0;return _(s,r.currentBody,r.candidateBody,e)}}class L{runner;hasExecutionRuntime;staticRunner;constructor(e={}){this.staticRunner=new p(e),this.hasExecutionRuntime=e.executionRuntime!==void 0,this.runner=e.executionRuntime?new x({executionRuntime:e.executionRuntime,...e.visualScoreProvider!==void 0?{visualScoreProvider:e.visualScoreProvider}:{},...e.executionWeight!==void 0?{executionWeight:e.executionWeight}:{}}):new p(e.visualScoreProvider!==void 0?{visualScoreProvider:e.visualScoreProvider}:{})}async compare(e,t,r,s,o){let i=this.runner.checkSafetyRegressions(r,s),n=await Promise.all(o.map(async(c)=>{let u=await R(c,r,{runner:this.runner}),g=await R(c,s,{runner:this.runner}),y=g.overallScore-u.overallScore;return{caseId:c.id,parentScore:u,proposedScore:g,deltaScore:y,safetyRegression:i}})),a=n.length===0?0:n.reduce((c,u)=>c+u.deltaScore,0)/n.length,d=a>=0.05&&i.length===0&&!n.some((c)=>m(c.parentScore)||m(c.proposedScore))?"promoted":i.length>0?"rejected":"pending";return{skillId:e,proposalId:t,cases:n,meanDeltaScore:a,safetyRegressions:i,decision:d}}compareSync(e,t,r,s,o){if(this.hasExecutionRuntime)console.warn("[ShadowRunner] compareSync() ignores the injected executionRuntime; use compare() (async) to fold execution checks into the score.");let i=this.runner.checkSafetyRegressions(r,s),n=o.map((c)=>{let u=this.staticRunner,g=u.runSync(c,r),y=u.runSync(c,s),l=y.overallScore-g.overallScore;return{caseId:c.id,parentScore:g,proposedScore:y,deltaScore:l,safetyRegression:i}}),a=n.length===0?0:n.reduce((c,u)=>c+u.deltaScore,0)/n.length,d=a>=0.05&&i.length===0&&!n.some((c)=>m(c.parentScore)||m(c.proposedScore))?"promoted":i.length>0?"rejected":"pending";return{skillId:e,proposalId:t,cases:n,meanDeltaScore:a,safetyRegressions:i,decision:d}}}import{existsSync as ae,mkdirSync as w,readFileSync as ce,writeFileSync as b}from"fs";import{join as S}from"path";function ue(e){let t=e.split(".").map(Number);if(t.length!==3||t.some(Number.isNaN))return`${e}-promoted`;return`${t[0]}.${t[1]}.${(t[2]??0)+1}`}class A{options;constructor(e){this.options=e}async tryPromote(e,t){if(e.decision!=="promoted")return this.writeDecision(e,e.decision,"unknown","unknown"),e.decision;if(e.cases.some((r)=>m(r.parentScore)||m(r.proposedScore)))return this.writeDecision(e,"pending","unknown","unknown"),"pending";if(this.options.regressionCheck){let r;try{r=await this.options.regressionCheck(t)}catch(s){console.warn(`[auto-promoter] regression check threw; conservative reject: ${s instanceof Error?s.message:String(s)}`),r={passed:!1,failures:["__error__"],checkedCaseIds:[]}}if(!r.passed)return this.writeDecision(e,"rejected-regression","unknown","unknown",r),"rejected-regression";return this.performPromote(e,t,r)}return this.performPromote(e,t)}performPromote(e,t,r){let s=S(this.options.rootDir,".uibot","skills",e.skillId),o=S(s,"SKILL.md");if(!ae(o))return w(s,{recursive:!0}),b(o,t,"utf-8"),this.writeDecision(e,"promoted","0.0.0","1.0.0",r),"promoted";let i=ce(o,"utf-8"),n=i.match(/^version:\s*["']?([^"'\n]+)["']?\s*$/m),a=n?(n[1]??"1.0.0").trim():"1.0.0",d=ue(a),c=S(s,"versions",a);w(c,{recursive:!0}),b(S(c,"SKILL.md"),i,"utf-8");let u=t.replace(/^(version:\s*["']?)([^"'\n]+)(["']?\s*)$/m,`$1${d}$3`);return b(o,u,"utf-8"),this.writeDecision(e,"promoted",a,d,r),"promoted"}writeDecision(e,t,r,s,o){let i=S(this.options.rootDir,".uibot","skills",e.skillId);w(i,{recursive:!0});let n={skillId:e.skillId,proposalId:e.proposalId,fromVersion:r,toVersion:s,decision:t,meanDeltaScore:e.meanDeltaScore,safetyRegressions:e.safetyRegressions,caseCount:e.cases.length,timestamp:new Date().toISOString(),visualEvidence:e.cases.map((a)=>({caseId:a.caseId,...a.parentScore.visualEvidence?{parent:a.parentScore.visualEvidence}:{},...a.proposedScore.visualEvidence?{proposed:a.proposedScore.visualEvidence}:{}})),...o?{regressionChecked:o.checkedCaseIds,...o.failures.length>0?{regressionFailures:o.failures}:{}}:{}};b(S(i,"decision.json"),`${JSON.stringify(n,null,2)}
4
+ `,"utf-8")}}function le(e){return e==="quality"?"blocking":"advisory"}var de=["streamline your","empower your","supercharge your","unlock the power","best-in-class","enterprise-grade","next-generation","cutting-edge","revolutionize","game-changer","game changer","future-proof","seamless experience","drive growth","harness the power","take it to the next level","world-class","state-of-the-art","robust solution","powerful platform","effortlessly","seamlessly integrate","elevate your","transform your"],ge=["Inter","Roboto","Geist","Fraunces","Plus Jakarta","Space Grotesk"];function v(e,t){let r=e.match(t);return r?r.length:0}var me=[{id:"marketing-buzzword",category:"slop",severity:"P2",message:"Marketing buzzwords read as AI filler \u2014 prefer concrete, specific copy.",detect:(e)=>{let t=e.toLowerCase();return de.reduce((r,s)=>r+(t.includes(s)?1:0),0)}},{id:"em-dash-overuse",category:"slop",severity:"P3",message:"Em-dash overuse (\u22655) is a strong AI-writing tell.",detect:(e)=>{let t=v(e,/[\u2014]|--(?=\S)/g);return t>=5?t-4:0}},{id:"aphoristic-cadence",category:"slop",severity:"P2",message:'Manufactured-contrast cadence ("Not an X. Just Y.") is a recognizable AI pattern.',detect:(e)=>{let t=v(e,/\bNot\s+(?:an?|just)\b[^.?!]*[.?!]/gi),r=v(e,/\b[A-Z][^.?!]*\.\s+(?:No|Just)\s+[a-z]/g),s=t+r;return s>=3?s:0}},{id:"numbered-section-markers",category:"slop",severity:"P3",message:"Numbered section scaffolding (01 / 02 / 03) is an overused AI layout tell.",detect:(e)=>{let t=e.match(/\b(0[1-9]|1[0-2])\b/g)??[],r=new Set(t);if(r.size<3)return 0;let s=[...r].map(Number).sort((i,n)=>i-n);return s.some((i,n)=>n>0&&i-s[n-1]===1)?r.size:0}}],pe=[{id:"gradient-text",category:"slop",severity:"P2",message:"Gradient text (bg-clip-text + transparent) is a classic AI hero tell.",detect:(e)=>v(e,/bg-clip-text[^"']*text-transparent|text-transparent[^"']*bg-clip-text|-webkit-background-clip\s*:\s*text/gi)},{id:"ai-color-palette",category:"slop",severity:"P2",message:"Purple/violet gradient palette is the most recognizable AI color tell.",detect:(e)=>v(e,/(from|via|to)-(purple|violet|fuchsia|indigo)-\d{3}|linear-gradient\([^)]*(?:#(?:8b5cf6|a855f7|7c3aed|6366f1))/gi)},{id:"side-tab",category:"slop",severity:"P2",message:"Thick colored side-border on a card (border-l-4 + accent) is the single most recognizable AI card tell.",detect:(e)=>v(e,/border-l-(4|8)\s+border-(purple|violet|indigo|blue|primary)/gi)},{id:"overused-font",category:"slop",severity:"P3",message:"Over-represented font (Inter/Geist/\u2026) without a brand reason reads as default AI styling.",detect:(e)=>ge.reduce((t,r)=>t+(new RegExp(`font-family[^;"']*${r}`,"i").test(e)?1:0),0)},{id:"emoji-icon",category:"slop",severity:"P2",message:"Emoji used as a heading/list/button icon is a stock AI tell \u2014 use a real icon or nothing.",detect:(e)=>v(e,/<(?:h[1-6]|li|button|summary|th)\b[^>]*>\s*(?:<[^>]+>\s*)*\p{Extended_Pictographic}/giu)},{id:"github-dark-glow",category:"slop",severity:"P3",message:"Flat #0D1117 background with a neon cyan/violet glow is the default AI dark-mode look.",detect:(e)=>/#0d1117/i.test(e)&&/(?:box-shadow|drop-shadow|text-shadow)[^;"']*(?:#06b6d4|#22d3ee|#00f0ff|#a78bfa|#8b5cf6|cyan|violet)/i.test(e)?1:0},{id:"tiny-text",category:"quality",severity:"P1",message:"Body text below ~14px (text-[10px]/[11px]/[12px]) harms readability and accessibility.",detect:(e)=>v(e,/text-\[(?:8|9|10|11|12)px\]|font-size\s*:\s*(?:8|9|10|11|12)px/gi)},{id:"gray-on-color",category:"quality",severity:"P1",message:"Gray text on a colored fill commonly fails WCAG contrast.",detect:(e)=>v(e,/bg-(?:primary|blue|indigo|violet|purple)-\d{3}[^"']*text-(?:gray|slate|zinc|neutral)-\d{3}/gi)}],Q={P0:0.3,P1:0.15,P2:0.08,P3:0.04};function ve(e){if(e>=0.9)return"A";if(e>=0.8)return"B";if(e>=0.65)return"C";if(e>=0.5)return"D";return"F"}var T=8,fe=/<\/?[a-z][^>]*>/i,he=/<(img|svg|canvas|video|picture|iframe|input|textarea|select|button)\b/i,F="title|text|label|content|description|heading|subtitle|placeholder|body|caption|name",ye=new RegExp(`["']?\\b(?:${F})["']?\\s*:\\s*["']([^"'\\n]*)["']`,"gi"),Se=new RegExp(`^\\s*-?\\s*(?:${F})\\s*:\\s*([^\\s"'{\\[][^\\n]*)$`,"gim"),Ee=/["']?\btype["']?\s*:/gi,xe=2;function M(e){return(e.match(/[\p{L}\p{N}]/gu)??[]).length}function C(e){if(!e.trim())return!0;if(fe.test(e)){if(he.test(e))return!1;let s=e.replace(/<(script|style)\b[\s\S]*?<\/\1>/gi," ").replace(/<!--[\s\S]*?-->/g," ").replace(/<[^>]*>/g," ");return M(s)<T}if((e.match(Ee)?.length??0)>=xe)return!1;let r=0;for(let s of[ye,Se])for(let o of e.matchAll(s))r+=M(o[1]??"");return r<T}function N(e){let t=e.text??e.html??"",r=e.html??e.text??"",s=new Set(e.exempt??[]),o=[],i=(a,d)=>{for(let c of a){let u=le(c.category);if(u==="advisory"&&s.has(c.id))continue;let g=c.detect(d);if(g>0)o.push({ruleId:c.id,category:c.category,severity:c.severity,level:u,message:c.message,count:g})}};i(me,t),i(pe,r);let n=1;for(let a of o){let d=Math.min(Q[a.severity]*(1+(a.count-1)/3),Q[a.severity]*2);n-=d}return n=Math.max(0,Math.min(1,n)),{score:n,grade:ve(n),findings:o,blocked:o.some((a)=>a.level==="blocking")}}function P(e){return N(e).score}function Re(){let e=async(t)=>P({text:t,html:t});return e.evaluate=async(t,r)=>{let s=f(t,r);return!C(t)?{status:"scored",method:"rule-scan",subjectHash:s,score:P({text:t,html:t})}:{status:"unavailable",method:"unassessed",subjectHash:s,reason:"empty-input"}},e}export{A as AutoPromoter,p as EvalRunner,x as EvalRunnerWithExecution,L as ShadowRunner,N as analyzeDesignQuality,Re as createDesignQualityVisualScoreProvider,ie as createEvaluateCandidate,C as isEmptyDesignShell,E as isVisualScore,R as scoreCandidate,_ as scoreCandidateDelta,oe as scoreCandidateSync,P as scoreDesignQuality,f as visualSubjectHash};
@@ -0,0 +1,49 @@
1
+ import type { EvalCase, EvalScore, VisualScoreProvider } from "./types.js";
2
+ /**
3
+ * Static structural quality score.
4
+ *
5
+ * Dimensions (all normalised to [0, 1]) and their weights:
6
+ *
7
+ * diversity 0.35 — how many of the 7 block categories are present
8
+ * nesting 0.15 — max indentation depth of the spec body (more = richer structure)
9
+ * formCompl 0.20 — if Form blocks present, does a form-action block also appear?
10
+ * balance 0.30 — does the spec mix structural (layout/data) WITH content blocks?
11
+ */
12
+ declare function structuralVisualScore(body: string): number;
13
+ /**
14
+ * Detect whether a skill body looks like a renderable UIBot spec.
15
+ * Checks for: fenced YAML block, `page:` keyword, or `blocks:` list presence.
16
+ */
17
+ declare function detectRenderable(body: string): number;
18
+ export interface EvalRunnerOptions {
19
+ /**
20
+ * Optional model-based visual quality scorer.
21
+ * When provided, replaces the built-in `structuralVisualScore` heuristic.
22
+ * Failed or invalid assessments remain unavailable and block promotion.
23
+ */
24
+ visualScoreProvider?: VisualScoreProvider;
25
+ }
26
+ export declare class EvalRunner {
27
+ private readonly visualScoreProvider;
28
+ constructor(options?: EvalRunnerOptions);
29
+ /**
30
+ * Run a single eval case against a skill body.
31
+ * Returns an EvalScore.
32
+ *
33
+ * When a `visualScoreProvider` is configured it is called asynchronously;
34
+ * otherwise the synchronous structural heuristic is used.
35
+ */
36
+ run(evalCase: EvalCase, skillBody: string): Promise<EvalScore>;
37
+ /**
38
+ * Synchronous variant for callers that don't want async.
39
+ * A configured async provider is reported as unavailable, not silently bypassed.
40
+ */
41
+ runSync(evalCase: EvalCase, skillBody: string): EvalScore;
42
+ private structuralEvidence;
43
+ /**
44
+ * Detect safety regressions between two skill bodies.
45
+ * Returns a list of regression descriptions; empty = safe.
46
+ */
47
+ checkSafetyRegressions(parentBody: string, proposedBody: string): string[];
48
+ }
49
+ export { structuralVisualScore, detectRenderable };
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Single scoring entry for skill candidates (v2.27 SC-3).
3
+ *
4
+ * Both Best-of-N tournament (`evaluateCandidate`) and `ShadowRunner` route
5
+ * through this module so overallScore / delta semantics cannot drift.
6
+ */
7
+ import type { EvalCase, EvalScore } from "./types.js";
8
+ import { type EvalRunnerOptions } from "./runner.js";
9
+ export type ScoreRunner = {
10
+ run(evalCase: EvalCase, skillBody: string): Promise<EvalScore>;
11
+ };
12
+ export interface ScoreCandidateOptions extends EvalRunnerOptions {
13
+ /** Optional shared runner instance (tests / DI). */
14
+ runner?: ScoreRunner;
15
+ }
16
+ /** Score one skill body against one eval case. */
17
+ export declare function scoreCandidate(evalCase: EvalCase, skillBody: string, options?: ScoreCandidateOptions): Promise<EvalScore>;
18
+ /** Sync path; configured async visual providers cannot be bypassed. */
19
+ export declare function scoreCandidateSync(evalCase: EvalCase, skillBody: string, options?: ScoreCandidateOptions): EvalScore;
20
+ /**
21
+ * Delta overallScore (candidate − parent) — the tournament ranking signal.
22
+ * Uses the same `scoreCandidate` path as ShadowRunner case scoring.
23
+ */
24
+ export declare function scoreCandidateDelta(evalCase: EvalCase, parentBody: string, candidateBody: string, options?: ScoreCandidateOptions): Promise<number>;
25
+ /**
26
+ * Factory matching SkillEvolver `evaluateCandidate` signature.
27
+ * Control-plane / tournament wiring should prefer this over ad-hoc EvalRunner use.
28
+ */
29
+ export declare function createEvaluateCandidate(options?: ScoreCandidateOptions & {
30
+ /** Build the eval case for a skill/trigger. Default: first trigger, no expectedBlocks. */
31
+ makeCase?: (input: {
32
+ skillId: string;
33
+ candidateIndex: number;
34
+ currentBody: string;
35
+ candidateBody: string;
36
+ }) => EvalCase | null;
37
+ }): (input: {
38
+ skillId: string;
39
+ currentBody: string;
40
+ candidateBody: string;
41
+ candidateIndex: number;
42
+ }) => Promise<number>;
@@ -0,0 +1,42 @@
1
+ import type { ExecutionRuntime } from "@uibot/contracts";
2
+ import type { EvalCase, ShadowEvalResult, VisualScoreProvider } from "./types.js";
3
+ export interface ShadowRunnerOptions {
4
+ /**
5
+ * Optional model-based visual quality scorer passed through to the inner EvalRunner.
6
+ * When provided, the visual dimension of each score is computed by the model
7
+ * rather than the built-in structural heuristic.
8
+ */
9
+ visualScoreProvider?: VisualScoreProvider;
10
+ executionRuntime?: ExecutionRuntime;
11
+ executionWeight?: number;
12
+ }
13
+ /**
14
+ * Runs the same eval case set against two versions of a skill body and
15
+ * produces per-case EvalReports plus an aggregate ShadowEvalResult.
16
+ *
17
+ * Delta score is computed from `overallScore` (composite of renderable,
18
+ * schemaValid, and visualHeuristic) rather than schemaValid alone.
19
+ */
20
+ export declare class ShadowRunner {
21
+ private readonly runner;
22
+ private readonly hasExecutionRuntime;
23
+ private readonly staticRunner;
24
+ constructor(options?: ShadowRunnerOptions);
25
+ /**
26
+ * Compare `parentBody` vs `proposedBody` across all provided cases.
27
+ * Returns a ShadowEvalResult with mean delta score and safety regression list.
28
+ *
29
+ * Promotion requires delta >= +0.05, no safety regressions, and no unavailable visual assessment.
30
+ */
31
+ compare(skillId: string, proposalId: string, parentBody: string, proposedBody: string, cases: EvalCase[]): Promise<ShadowEvalResult>;
32
+ /**
33
+ * Synchronous variant; configured async visual providers remain unavailable.
34
+ * Useful in tests and quick scripts that don't need model evaluation.
35
+ *
36
+ * When an `executionRuntime` was injected at construction time, this method
37
+ * still runs the static path only (it cannot await the runtime). The
38
+ * mismatch is logged once per call so the caller learns to use `compare()`
39
+ * if execution-backed scoring matters.
40
+ */
41
+ compareSync(skillId: string, proposalId: string, parentBody: string, proposedBody: string, cases: EvalCase[]): ShadowEvalResult;
42
+ }
@@ -0,0 +1,98 @@
1
+ import type { ExecutionLanguage, VisualEvaluationEvidence } from "@uibot/contracts";
2
+ /**
3
+ * A single evaluation test case.
4
+ * Each case provides an intent, expected block types, and (optionally) a
5
+ * compiled-spec fixture path for the runner to verify output against.
6
+ */
7
+ export interface EvalCase {
8
+ id: string;
9
+ /** Natural-language intent that was used to generate the skill body */
10
+ intent: string;
11
+ /** Block type names that must appear in a passing generated spec */
12
+ expectedBlocks: string[];
13
+ /** Skill id this case belongs to */
14
+ skillId: string;
15
+ /** Optional path to a fixture JSON/YAML spec to compare against */
16
+ fixturePath?: string;
17
+ /** Optional code checks executed by EvalRunnerWithExecution. */
18
+ executionChecks?: EvalExecutionCheck[];
19
+ }
20
+ export interface EvalExecutionCheck {
21
+ language: ExecutionLanguage;
22
+ code: string;
23
+ timeoutMs?: number;
24
+ fetchAllowed?: boolean;
25
+ env?: Record<string, string>;
26
+ expectedStdoutIncludes?: string[];
27
+ expectedStderrIncludes?: string[];
28
+ expectedReturnValue?: unknown;
29
+ }
30
+ export interface EvalExecutionResult {
31
+ passed: boolean;
32
+ success: boolean;
33
+ stdout: string;
34
+ stderr: string;
35
+ durationMs: number;
36
+ errorCode?: string;
37
+ errorMessage?: string;
38
+ failureReason?: string;
39
+ }
40
+ /**
41
+ * Per-dimension scores for a single eval case run.
42
+ * All numeric fields are in [0, 1].
43
+ */
44
+ export interface EvalScore {
45
+ /** Static renderability hint from YAML/page/blocks markers; not a compiler result */
46
+ renderable: number;
47
+ /** Fraction of expected block types that appeared in the output */
48
+ schemaValid: number;
49
+ /**
50
+ * Structural quality score: block-category coverage, nesting, form completeness,
51
+ * content-structure balance. Range [0.0, 1.0].
52
+ * Provider method is recorded in visualEvidence; unavailable assessments project
53
+ * to 0 for numeric compatibility and cannot authorize promotion.
54
+ */
55
+ visualHeuristic: number;
56
+ /** Absent only on legacy persisted scores. Unavailable evidence blocks promotion. */
57
+ visualEvidence?: VisualEvaluationEvidence;
58
+ /**
59
+ * Composite quality: 0.40 * renderable + 0.35 * schemaValid + 0.25 * visualHeuristic.
60
+ * Used as the primary signal in shadow-eval delta computation.
61
+ */
62
+ overallScore: number;
63
+ /** True when no new `_js`, `_secret`, or external URLs appeared in the diff */
64
+ safetyOk: boolean;
65
+ /** Optional execution-backed score in [0, 1], present only when execution checks ran. */
66
+ executionScore?: number;
67
+ /** Per-check execution results, present only when execution checks ran. */
68
+ executionResults?: EvalExecutionResult[];
69
+ }
70
+ /** Callable compatibility interface; runners prefer evidence-aware evaluate when supplied. */
71
+ export type VisualScoreProvider = ((specBody: string, intent: string) => Promise<number>) & {
72
+ evaluate?: (specBody: string, intent: string) => Promise<VisualEvaluationEvidence>;
73
+ };
74
+ /** Report produced by ShadowRunner comparing parent vs proposed skill versions. */
75
+ export interface EvalReport {
76
+ caseId: string;
77
+ parentScore: EvalScore;
78
+ proposedScore: EvalScore;
79
+ /** Composite delta: proposedScore.overallScore minus parentScore.overallScore */
80
+ deltaScore: number;
81
+ /**
82
+ * List of safety-regression reasons.
83
+ * Empty array means the proposed version passed the safety gate.
84
+ */
85
+ safetyRegression: string[];
86
+ }
87
+ /** Aggregate result over all cases for a single promotion decision. */
88
+ export interface ShadowEvalResult {
89
+ skillId: string;
90
+ proposalId: string;
91
+ cases: EvalReport[];
92
+ /** Mean deltaScore across all cases */
93
+ meanDeltaScore: number;
94
+ /** Any safety regressions found across all cases */
95
+ safetyRegressions: string[];
96
+ /** Promotion decision */
97
+ decision: "promoted" | "pending" | "rejected";
98
+ }
@@ -0,0 +1,7 @@
1
+ import type { VisualEvaluationEvidence } from "@uibot/contracts";
2
+ import type { EvalScore, VisualScoreProvider } from "./types.js";
3
+ export declare function visualSubjectHash(body: string, intent: string): string;
4
+ export declare function isVisualScore(value: unknown): value is number;
5
+ export declare function evaluateVisualProvider(provider: VisualScoreProvider, body: string, intent: string): Promise<VisualEvaluationEvidence>;
6
+ /** Old persisted numeric records remain compatible; explicit failures never do. */
7
+ export declare function hasUnavailableVisualScore(score: EvalScore): boolean;
package/package.json CHANGED
@@ -1,6 +1,41 @@
1
1
  {
2
2
  "name": "@uibot/evaluation",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "license": "MIT",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/Foundj/uibot.git",
8
+ "directory": "packages/evaluation"
9
+ },
10
+ "type": "module",
11
+ "main": "./dist/index.js",
12
+ "module": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "default": "./dist/index.js"
18
+ },
19
+ "./design-quality": {
20
+ "types": "./dist/design-quality-rules.d.ts",
21
+ "default": "./dist/design-quality-rules.js"
22
+ }
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "!dist/**/*.map",
27
+ "!dist/**/*.test.d.ts",
28
+ "!dist/**/*.spec.d.ts"
29
+ ],
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "dependencies": {
34
+ "@uibot/contracts": "^0.2.0"
35
+ },
36
+ "scripts": {
37
+ "build": "rm -rf dist && bun build --minify ./src/index.ts ./src/design-quality-rules.ts --outdir ./dist --format esm --target bun && bun x tsc -p tsconfig.json",
38
+ "typecheck": "bun x tsc -p tsconfig.json --noEmit",
39
+ "test": "bun test"
40
+ }
41
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.