selftune 0.2.19 → 0.2.21
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.
- package/apps/local-dashboard/dist/assets/{index-DnhnXQm6.js → index-D8O-RG1I.js} +2 -2
- package/apps/local-dashboard/dist/index.html +1 -1
- package/cli/selftune/dashboard-contract.ts +4 -0
- package/cli/selftune/eval/family-overlap.ts +320 -1
- package/cli/selftune/evolution/evidence.ts +5 -0
- package/cli/selftune/evolution/evolve-body.ts +86 -2
- package/cli/selftune/evolution/evolve.ts +58 -1
- package/cli/selftune/evolution/validate-body.ts +10 -0
- package/cli/selftune/evolution/validate-host-replay.ts +624 -0
- package/cli/selftune/evolution/validate-proposal.ts +10 -0
- package/cli/selftune/evolution/validate-routing.ts +112 -5
- package/cli/selftune/localdb/direct-write.ts +8 -3
- package/cli/selftune/localdb/materialize.ts +7 -2
- package/cli/selftune/localdb/queries.ts +11 -1
- package/cli/selftune/localdb/schema.ts +10 -1
- package/cli/selftune/routes/skill-report.ts +6 -1
- package/cli/selftune/types.ts +54 -0
- package/cli/selftune/utils/text-similarity.ts +73 -0
- package/package.json +1 -1
- package/packages/ui/src/components/EvidenceViewer.tsx +85 -2
- package/packages/ui/src/components/EvolutionTimeline.tsx +23 -1
- package/packages/ui/src/types.ts +4 -0
- package/skill/Workflows/Composability.md +15 -1
- package/skill/Workflows/Evolve.md +39 -0
|
@@ -55,6 +55,6 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
55
55
|
`});++r<e.length;)r&&n.push({type:`text`,value:`
|
|
56
56
|
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
|
|
57
57
|
`}),n}function om(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function sm(e,t){let n=tm(e,t),r=n.one(e,void 0),i=Bp(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
|
|
58
|
-
`},i)),a}function cm(e,t){return e&&`run`in e?async function(n,r){let i=sm(n,{file:r,...t});await e.run(i,r)}:function(n,r){return sm(n,{file:r,...e||t})}}function lm(e){if(e)throw e}var um=n(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function dm(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function fm(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?pm(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function pm(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var mm={basename:hm,dirname:gm,extname:_m,join:vm,sep:`/`};function hm(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);xm(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function gm(e){if(xm(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function _m(e){xm(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function vm(...e){let t=-1,n;for(;++t<e.length;)xm(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:ym(n)}function ym(e){xm(e);let t=e.codePointAt(0)===47,n=bm(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function bm(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(!(i===o-1||a===1))if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function xm(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var Sm={cwd:Cm};function Cm(){return`/`}function wm(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function Tm(e){if(typeof e==`string`)e=new URL(e);else if(!wm(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return Em(e)}function Em(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var Dm=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],Om=class{constructor(e){let t;t=e?wm(e)?{path:e}:typeof e==`string`||Mm(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:Sm.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<Dm.length;){let e=Dm[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)Dm.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?mm.basename(this.path):void 0}set basename(e){Am(e,`basename`),km(e,`basename`),this.path=mm.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?mm.dirname(this.path):void 0}set dirname(e){jm(this.basename,`dirname`),this.path=mm.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?mm.extname(this.path):void 0}set extname(e){if(km(e,`extname`),jm(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=mm.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){wm(e)&&(e=Tm(e)),Am(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?mm.basename(this.path,this.extname):void 0}set stem(e){Am(e,`stem`),km(e,`stem`),this.path=mm.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new X(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function km(e,t){if(e&&e.includes(mm.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+mm.sep+"`")}function Am(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function jm(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function Mm(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var Nm=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),Pm=t(um(),1),Fm={}.hasOwnProperty,Im=new class e extends Nm{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=fm()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,Pm.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(zm(`data`,this.frozen),this.namespace[e]=t,this):Fm.call(this.namespace,e)&&this.namespace[e]||void 0:e?(zm(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=Hm(e),n=this.parser||this.Parser;return Lm(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),Lm(`process`,this.parser||this.Parser),Rm(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=Hm(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);Wm(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),Lm(`processSync`,this.parser||this.Parser),Rm(`processSync`,this.compiler||this.Compiler),this.process(e,r),Vm(`processSync`,`process`,t),n;function r(e,r){t=!0,lm(e),n=r}}run(e,t,n){Bm(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=Hm(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),Vm(`runSync`,`run`,n),r;function i(e,t){lm(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=Hm(t),r=this.compiler||this.Compiler;return Rm(`stringify`,r),Bm(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(zm(`use`,this.frozen),e!=null)if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`)if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e);else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,Pm.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null)if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];dm(o)&&dm(r)&&(r=(0,Pm.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function Lm(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function Rm(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function zm(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Bm(e){if(!dm(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function Vm(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function Hm(e){return Um(e)?e:new Om(e)}function Um(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function Wm(e){return typeof e==`string`||Gm(e)}function Gm(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var Km=[],qm={allowDangerousHtml:!0},Jm=/^(https?|ircs?|mailto|xmpp)$/i,Ym=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function Xm(e){let t=Zm(e),n=Qm(e);return $m(t.runSync(t.parse(n),n),e)}function Zm(e){let t=e.rehypePlugins||Km,n=e.remarkPlugins||Km,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...qm}:qm;return Im().use(Jf).use(n).use(cm,r).use(t)}function Qm(e){let t=e.children||``,n=new Om;return typeof t==`string`?n.value=t:``+t,n}function $m(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||eh;for(let e of Ym)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return Qp(e,l),El(e,{Fragment:F.Fragment,components:i,ignoreInvalidStyle:!0,jsx:F.jsx,jsxs:F.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in Jl)if(Object.hasOwn(Jl,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=Jl[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function eh(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||Jm.test(e.slice(0,t))?e:``}var th={created:`outline`,validated:`secondary`,deployed:`default`,rejected:`destructive`,rolled_back:`destructive`};function nh(e){return e.replace(/_/g,` `)}function rh(e){switch(e){case`rejected`:return{title:`Proposal rejected`,summary:`Selftune proposed a change, but blocked it before your live skill was updated.`,tone:`border-red-500/20 bg-red-500/8 text-red-700 dark:text-red-50`,icon:(0,F.jsx)(h,{className:`size-4 text-red-400`}),liveSkillNote:`Your live skill is unchanged.`};case`validated`:return{title:`Proposal validated`,summary:`The proposed change improved the eval signal and is ready for review or deploy.`,tone:`border-emerald-500/20 bg-emerald-500/8 text-emerald-700 dark:text-emerald-50`,icon:(0,F.jsx)(Ge,{className:`size-4 text-emerald-400`}),liveSkillNote:`Your live skill has not changed until this proposal is deployed.`};case`deployed`:return{title:`Proposal deployed`,summary:`The proposed change passed validation and was applied to the live skill.`,tone:`border-primary/25 bg-primary/8 text-foreground`,icon:(0,F.jsx)(A,{className:`size-4 text-primary`}),liveSkillNote:`Your live skill now includes this change.`};case`rolled_back`:return{title:`Proposal rolled back`,summary:`A deployed change was later reversed because follow-up evidence showed risk.`,tone:`border-amber-500/20 bg-amber-500/8 text-amber-800 dark:text-amber-50`,icon:(0,F.jsx)(Oe,{className:`size-4 text-amber-400`}),liveSkillNote:`Your live skill no longer uses this proposal.`};default:return{title:`Proposal under review`,summary:`Selftune found a possible improvement and recorded the proposed change.`,tone:`border-border/30 bg-muted/25 text-foreground`,icon:(0,F.jsx)(ve,{className:`size-4 text-muted-foreground`}),liveSkillNote:`Your live skill is unchanged until a proposal is validated and deployed.`}}}function ih(e){let t=e.split(`
|
|
58
|
+
`},i)),a}function cm(e,t){return e&&`run`in e?async function(n,r){let i=sm(n,{file:r,...t});await e.run(i,r)}:function(n,r){return sm(n,{file:r,...e||t})}}function lm(e){if(e)throw e}var um=n(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function dm(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function fm(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?pm(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function pm(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var mm={basename:hm,dirname:gm,extname:_m,join:vm,sep:`/`};function hm(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);xm(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function gm(e){if(xm(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function _m(e){xm(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function vm(...e){let t=-1,n;for(;++t<e.length;)xm(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:ym(n)}function ym(e){xm(e);let t=e.codePointAt(0)===47,n=bm(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function bm(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(!(i===o-1||a===1))if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function xm(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var Sm={cwd:Cm};function Cm(){return`/`}function wm(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function Tm(e){if(typeof e==`string`)e=new URL(e);else if(!wm(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return Em(e)}function Em(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var Dm=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],Om=class{constructor(e){let t;t=e?wm(e)?{path:e}:typeof e==`string`||Mm(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:Sm.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<Dm.length;){let e=Dm[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)Dm.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?mm.basename(this.path):void 0}set basename(e){Am(e,`basename`),km(e,`basename`),this.path=mm.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?mm.dirname(this.path):void 0}set dirname(e){jm(this.basename,`dirname`),this.path=mm.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?mm.extname(this.path):void 0}set extname(e){if(km(e,`extname`),jm(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=mm.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){wm(e)&&(e=Tm(e)),Am(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?mm.basename(this.path,this.extname):void 0}set stem(e){Am(e,`stem`),km(e,`stem`),this.path=mm.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new X(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function km(e,t){if(e&&e.includes(mm.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+mm.sep+"`")}function Am(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function jm(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function Mm(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var Nm=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),Pm=t(um(),1),Fm={}.hasOwnProperty,Im=new class e extends Nm{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=fm()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,Pm.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(zm(`data`,this.frozen),this.namespace[e]=t,this):Fm.call(this.namespace,e)&&this.namespace[e]||void 0:e?(zm(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=Hm(e),n=this.parser||this.Parser;return Lm(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),Lm(`process`,this.parser||this.Parser),Rm(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=Hm(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);Wm(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),Lm(`processSync`,this.parser||this.Parser),Rm(`processSync`,this.compiler||this.Compiler),this.process(e,r),Vm(`processSync`,`process`,t),n;function r(e,r){t=!0,lm(e),n=r}}run(e,t,n){Bm(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=Hm(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),Vm(`runSync`,`run`,n),r;function i(e,t){lm(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=Hm(t),r=this.compiler||this.Compiler;return Rm(`stringify`,r),Bm(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(zm(`use`,this.frozen),e!=null)if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`)if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e);else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,Pm.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null)if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];dm(o)&&dm(r)&&(r=(0,Pm.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function Lm(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function Rm(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function zm(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Bm(e){if(!dm(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function Vm(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function Hm(e){return Um(e)?e:new Om(e)}function Um(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function Wm(e){return typeof e==`string`||Gm(e)}function Gm(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var Km=[],qm={allowDangerousHtml:!0},Jm=/^(https?|ircs?|mailto|xmpp)$/i,Ym=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function Xm(e){let t=Zm(e),n=Qm(e);return $m(t.runSync(t.parse(n),n),e)}function Zm(e){let t=e.rehypePlugins||Km,n=e.remarkPlugins||Km,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...qm}:qm;return Im().use(Jf).use(n).use(cm,r).use(t)}function Qm(e){let t=e.children||``,n=new Om;return typeof t==`string`?n.value=t:``+t,n}function $m(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||eh;for(let e of Ym)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return Qp(e,l),El(e,{Fragment:F.Fragment,components:i,ignoreInvalidStyle:!0,jsx:F.jsx,jsxs:F.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in Jl)if(Object.hasOwn(Jl,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=Jl[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function eh(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||Jm.test(e.slice(0,t))?e:``}var th={created:`outline`,validated:`secondary`,deployed:`default`,rejected:`destructive`,rolled_back:`destructive`};function nh(e){switch(e){case`host_replay`:return{label:`Replay-backed validation`,variant:`default`,description:`Validated against a controlled replay fixture instead of a free-form judge prompt.`};case`llm_judge`:return{label:`Model judgment`,variant:`secondary`,description:`Validated by an LLM trigger check rather than a replay fixture.`};case`structural_guard`:return{label:`Structural guard`,variant:`outline`,description:`Only deterministic structural checks ran; no replay or judge validation was needed.`};default:return null}}function rh(e){return e.replace(/_/g,` `)}function ih(e){switch(e){case`rejected`:return{title:`Proposal rejected`,summary:`Selftune proposed a change, but blocked it before your live skill was updated.`,tone:`border-red-500/20 bg-red-500/8 text-red-700 dark:text-red-50`,icon:(0,F.jsx)(h,{className:`size-4 text-red-400`}),liveSkillNote:`Your live skill is unchanged.`};case`validated`:return{title:`Proposal validated`,summary:`The proposed change improved the eval signal and is ready for review or deploy.`,tone:`border-emerald-500/20 bg-emerald-500/8 text-emerald-700 dark:text-emerald-50`,icon:(0,F.jsx)(Ge,{className:`size-4 text-emerald-400`}),liveSkillNote:`Your live skill has not changed until this proposal is deployed.`};case`deployed`:return{title:`Proposal deployed`,summary:`The proposed change passed validation and was applied to the live skill.`,tone:`border-primary/25 bg-primary/8 text-foreground`,icon:(0,F.jsx)(A,{className:`size-4 text-primary`}),liveSkillNote:`Your live skill now includes this change.`};case`rolled_back`:return{title:`Proposal rolled back`,summary:`A deployed change was later reversed because follow-up evidence showed risk.`,tone:`border-amber-500/20 bg-amber-500/8 text-amber-800 dark:text-amber-50`,icon:(0,F.jsx)(Oe,{className:`size-4 text-amber-400`}),liveSkillNote:`Your live skill no longer uses this proposal.`};default:return{title:`Proposal under review`,summary:`Selftune found a possible improvement and recorded the proposed change.`,tone:`border-border/30 bg-muted/25 text-foreground`,icon:(0,F.jsx)(ve,{className:`size-4 text-muted-foreground`}),liveSkillNote:`Your live skill is unchanged until a proposal is validated and deployed.`}}}function ah(e){let t=e.split(`
|
|
59
59
|
`);if(t.length<3||t[0].trim()!==`---`)return{meta:{},body:e};let n=-1;for(let e=1;e<t.length;e++)if(t[e].trim()===`---`){n=e;break}if(n===-1)return{meta:{},body:e};let r={};for(let e of t.slice(1,n)){let t=e.indexOf(`:`);if(t>0){let n=e.slice(0,t).trim(),i=e.slice(t+1).trim();n&&i&&(r[n]=i)}}return{meta:r,body:t.slice(n+1).join(`
|
|
60
|
-
`)}}function ah({meta:e}){let t=Object.entries(e);return t.length===0?null:(0,F.jsx)(`div`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs`,children:t.map(([e,t])=>(0,F.jsxs)(`div`,{className:`contents`,children:[(0,F.jsx)(`span`,{className:`font-medium text-muted-foreground capitalize`,children:e}),(0,F.jsx)(`span`,{className:`text-foreground truncate`,children:t})]},e))})}function oh({label:e,text:t,variant:n}){let{meta:r,body:i}=ih(t),a=Object.keys(r).length>0;return(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(se,{className:`size-3.5 text-muted-foreground`}),(0,F.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:e}),n===`proposed`&&(0,F.jsx)(P,{variant:`secondary`,className:`text-[10px]`,children:`New`})]}),a&&(0,F.jsx)(`div`,{className:`rounded-md border bg-muted/30 p-3`,children:(0,F.jsx)(ah,{meta:r})}),(0,F.jsx)(`div`,{className:`skill-markdown rounded-md border bg-card p-4`,children:(0,F.jsx)(Xm,{children:i})})]})}function sh(e,t){if(typeof t==`boolean`)return t?(0,F.jsx)(Ge,{className:`size-3.5 text-emerald-500 inline`}):(0,F.jsx)(h,{className:`size-3.5 text-red-500 inline`});if(typeof t==`number`){if(e.includes(`rate`)||e.includes(`change`)||t>=-1&&t<=1&&e!==`count`){let n=(t*100).toFixed(1);return(0,F.jsxs)(`span`,{className:`font-mono`,children:[t>0&&e.includes(`change`)?`+`:``,n,`%`]})}return(0,F.jsx)(`span`,{className:`font-mono`,children:t})}return t==null?(0,F.jsx)(`span`,{className:`text-muted-foreground`,children:`--`}):typeof t==`string`?(0,F.jsx)(`span`,{children:t}):Array.isArray(t)?t.length===0?(0,F.jsx)(`span`,{className:`text-muted-foreground italic`,children:`none`}):(0,F.jsxs)(`span`,{className:`font-mono`,children:[t.length,` entries`]}):typeof t==`object`?(0,F.jsx)(`span`,{className:`font-mono`,children:`1 entry`}):(0,F.jsx)(`span`,{children:String(t)})}function ch({entry:e}){let t=e.entry,n=t?.query??e.query??e.prompt??e.input??e.text,r=t?.should_trigger??e.should_trigger,i=t?.invocation_type??e.invocation_type,a=e.before_pass??e.before??e.original_triggered??e.baseline,o=e.after_pass??e.after??e.triggered??e.result,s=e.passed??e.matched,c=typeof o==`boolean`?o:typeof s==`boolean`?s:null;return(0,F.jsxs)(`div`,{className:`flex items-start gap-2 text-xs py-1.5 border-b border-border/50 last:border-0`,children:[c===null?(0,F.jsx)(ve,{className:`size-3.5 text-muted-foreground shrink-0 mt-0.5`}):c?(0,F.jsx)(Ge,{className:`size-3.5 text-emerald-500 shrink-0 mt-0.5`}):(0,F.jsx)(h,{className:`size-3.5 text-red-500 shrink-0 mt-0.5`}),(0,F.jsx)(`span`,{className:`flex-1 min-w-0 line-clamp-2`,children:n?String(n):JSON.stringify(e)}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[typeof a==`boolean`&&typeof o==`boolean`&&(0,F.jsxs)(`span`,{className:`text-[10px] text-muted-foreground font-mono`,children:[a?`pass`:`fail`,` → `,o?`pass`:`fail`]}),r!==void 0&&(0,F.jsxs)(P,{variant:`secondary`,className:`text-[9px]`,children:[`expect: `,String(r)]}),i!=null&&(0,F.jsx)(P,{variant:`secondary`,className:`text-[9px]`,children:String(i)})]})]})}function lh({validation:e}){let{improved:t,before_pass_rate:n,after_pass_rate:r,net_change:i,regressions:a,new_passes:o,per_entry_results:s,...c}=e,l=Array.isArray(a)?a:[],u=Array.isArray(o)?o:[],d=Array.isArray(s)?s:[];return(0,F.jsxs)(`div`,{className:`rounded-md border bg-muted/30 p-3 space-y-3`,children:[(0,F.jsxs)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:[`Validation Results`,(0,F.jsx)(`span`,{className:`font-normal text-muted-foreground/60 ml-1.5`,children:`— Before/after comparison from eval tests`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[t!==void 0&&(0,F.jsx)(P,{variant:t?`default`:`destructive`,className:`text-[10px]`,children:t?`Improved`:`Regressed`}),typeof n==`number`&&typeof r==`number`&&(0,F.jsxs)(`span`,{className:`text-xs font-mono text-muted-foreground`,children:[(n*100).toFixed(1),`% → `,(r*100).toFixed(1),`%`]}),typeof i==`number`&&(0,F.jsxs)(`span`,{className:`text-xs font-mono font-semibold ${i>0?`text-emerald-600 dark:text-emerald-400`:i<0?`text-red-500`:`text-muted-foreground`}`,children:[i>0?`+`:``,(i*100).toFixed(1),`%`]})]}),u.length>0&&(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`p`,{className:`text-[11px] font-medium text-emerald-600 dark:text-emerald-400 mb-1`,children:[`New Passes (`,u.length,`)`]}),(0,F.jsx)(`div`,{className:`rounded border bg-card p-2`,children:u.map((e,t)=>(0,F.jsx)(ch,{entry:typeof e==`object`&&e?e:{value:e}},t))})]}),l.length>0&&(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`p`,{className:`text-[11px] font-medium text-red-500 mb-1`,children:[`Regressions (`,l.length,`)`]}),(0,F.jsx)(`div`,{className:`rounded border border-red-200 dark:border-red-900/50 bg-card p-2`,children:l.map((e,t)=>(0,F.jsx)(ch,{entry:typeof e==`object`&&e?e:{value:e}},t))})]}),d.length>0&&(0,F.jsx)(uh,{entries:d}),Object.keys(c).length>0&&(0,F.jsx)(`div`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs`,children:Object.entries(c).map(([e,t])=>(0,F.jsxs)(`div`,{className:`contents`,children:[(0,F.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:e}),(0,F.jsx)(`span`,{className:`text-foreground`,children:sh(e,t)})]},e))})]})}function uh({entries:e}){let[t,n]=(0,M.useState)(!1),r=e.filter(e=>{if(typeof e!=`object`||!e)return!1;let t=e;return t.passed===!0||t.matched===!0||t.triggered===!0||t.after===!0||t.result===!0}).length,i=t?e:e.slice(0,5);return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,F.jsxs)(`p`,{className:`text-[11px] font-medium text-muted-foreground`,children:[`Individual Test Cases (`,r,`/`,e.length,` passed)`]}),e.length>5&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>n(!t),className:`text-[10px] text-primary hover:underline`,children:t?`Show less`:`Show all ${e.length}`})]}),(0,F.jsx)(`div`,{className:`h-1.5 rounded-full bg-muted overflow-hidden mb-2`,children:(0,F.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500 transition-all`,style:{width:`${e.length>0?r/e.length*100:0}%`}})}),(0,F.jsx)(`div`,{className:`rounded border bg-card p-2 max-h-[300px] overflow-y-auto`,children:i.map((e,t)=>(0,F.jsx)(ch,{entry:typeof e==`object`&&e?e:{value:e}},t))})]})}function dh(e){if(!e.validation)return null;let t=e.validation.after_pass_rate;return typeof t==`number`?t:null}function fh({prev:e,curr:t}){if(e===null||t===null)return null;let n=t-e;if(n===0)return null;let r=(n*100).toFixed(1),i=n>0;return(0,F.jsxs)(`span`,{className:`text-[10px] font-mono font-semibold ${i?`text-emerald-600 dark:text-emerald-400`:`text-red-500`}`,children:[i?`+`:``,r,`% vs previous`]})}function ph({evalSet:e}){let[t,n]=(0,M.useState)(!1),r=e.filter(e=>(e.passed??e.result)===!0).length;return(0,F.jsxs)(`div`,{className:`rounded-md border bg-muted/30 p-3 space-y-2`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:`flex items-center gap-1.5 w-full text-left`,children:[t?(0,F.jsx)(Ee,{className:`size-3.5 text-muted-foreground shrink-0`}):(0,F.jsx)(Ve,{className:`size-3.5 text-muted-foreground shrink-0`}),(0,F.jsx)(C,{className:`size-3.5 text-muted-foreground`}),(0,F.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:[`Eval Set (`,r,`/`,e.length,` passed)`]})]}),t&&(0,F.jsx)(`div`,{className:`space-y-1`,children:e.map((e,t)=>{let n=e.query??e.prompt??e.input,r=e.expected??e.should_trigger,i=e.passed??e.result;return(0,F.jsxs)(`div`,{className:`flex items-start gap-2 text-xs py-1 border-b border-border/50 last:border-0`,children:[typeof i==`boolean`?i?(0,F.jsx)(Ge,{className:`size-3.5 text-emerald-500 shrink-0 mt-0.5`}):(0,F.jsx)(h,{className:`size-3.5 text-red-500 shrink-0 mt-0.5`}):(0,F.jsx)(ve,{className:`size-3.5 text-muted-foreground shrink-0 mt-0.5`}),(0,F.jsx)(`span`,{className:`flex-1 min-w-0 line-clamp-2`,children:String(n??JSON.stringify(e))}),r!==void 0&&(0,F.jsxs)(P,{variant:`secondary`,className:`text-[9px] shrink-0`,children:[`expect: `,String(r)]})]},t)})})]})}function mh({entry:e,roundLabel:t,roundStatus:n,prevPassRate:r,currPassRate:i}){let a=n!==`single`;return(0,F.jsxs)(L,{className:n===`final`?`border-primary/50 shadow-sm`:void 0,children:[(0,F.jsx)(R,{className:`pb-3`,children:(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsxs)(z,{className:`text-sm flex items-center gap-2`,children:[(0,F.jsx)(ee,{className:`size-4 text-muted-foreground`}),`Evidence: `,e.target,a&&t&&(0,F.jsx)(`span`,{className:`text-[10px] font-mono text-muted-foreground`,children:t}),n===`final`&&(0,F.jsx)(P,{variant:`default`,className:`text-[10px]`,children:`Final`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a&&(0,F.jsx)(fh,{prev:r,curr:i}),(0,F.jsx)(P,{variant:`secondary`,className:`text-[10px]`,children:e.stage}),e.confidence!==null&&(0,F.jsxs)(P,{variant:e.confidence>=.8?`default`:e.confidence>=.5?`secondary`:`destructive`,className:`text-[10px] font-mono`,children:[Un(e.confidence),` confidence`]}),(0,F.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Gn(e.timestamp)})]})]})}),(0,F.jsxs)(B,{className:`space-y-4`,children:[e.rationale&&(0,F.jsxs)(`div`,{className:`rounded-md border-l-2 border-primary/40 bg-primary/5 px-3 py-2`,children:[(0,F.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Rationale`}),(0,F.jsx)(`p`,{className:`text-sm leading-relaxed`,children:e.rationale})]}),e.details&&(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:e.details}),(e.original_text||e.proposed_text)&&(0,F.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[e.original_text&&(0,F.jsx)(oh,{label:`Original`,text:e.original_text,variant:`original`}),e.proposed_text&&(0,F.jsx)(oh,{label:`Proposed`,text:e.proposed_text,variant:`proposed`})]}),e.eval_set&&e.eval_set.length>0&&(0,F.jsx)(ph,{evalSet:e.eval_set}),e.validation&&Object.keys(e.validation).length>0&&(0,F.jsx)(lh,{validation:e.validation})]})]})}function hh({entry:e,roundLabel:t,onExpand:n}){let r=dh(e),i=e.validation?.improved;return(0,F.jsxs)(`button`,{type:`button`,onClick:n,className:`flex items-center gap-3 w-full rounded-lg border border-dashed px-4 py-3 text-left hover:bg-accent/50 transition-colors`,children:[(0,F.jsx)(Ve,{className:`size-4 text-muted-foreground shrink-0`}),(0,F.jsx)(ee,{className:`size-3.5 text-muted-foreground shrink-0`}),(0,F.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.target}),(0,F.jsx)(`span`,{className:`text-[10px] font-mono text-muted-foreground`,children:t}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto shrink-0`,children:[r!==null&&(0,F.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground`,children:[(r*100).toFixed(1),`% pass rate`]}),typeof i==`boolean`&&(0,F.jsx)(P,{variant:i?`default`:`destructive`,className:`text-[9px]`,children:i?`Improved`:`Regressed`}),(0,F.jsx)(P,{variant:`secondary`,className:`text-[10px]`,children:e.stage}),(0,F.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Gn(e.timestamp)})]})]})}function gh({proposalId:e,evolution:t,evidence:n,showContextBanner:r=!0}){let i=(0,M.useMemo)(()=>t.filter(t=>t.proposal_id===e).sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime()),[t,e]),a=(0,M.useMemo)(()=>n.filter(t=>t.proposal_id===e).sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime()),[n,e]),[o,s]=(0,M.useState)(new Set),[c,l]=(0,M.useState)(new Set),u=e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},d=e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},f=(0,M.useMemo)(()=>{for(let e=i.length-1;e>=0;e--)if(i[e].eval_snapshot)return i[e].eval_snapshot;return null},[i]),{proposalEntries:p,validationsByTarget:m}=(0,M.useMemo)(()=>{let e=[],t=new Map;for(let n of a)if(n.stage!==`validated`)e.push(n);else{let e=n.target;t.has(e)||t.set(e,[]),t.get(e).push(n)}return{proposalEntries:e,validationsByTarget:t}},[a]),h=i[i.length-1]??null,g=i.map(e=>e.action.replace(`_`,` `)).join(` -> `),_=rh(h?.action),v=(0,M.useMemo)(()=>{for(let e=p.length-1;e>=0;e--)if(p[e].confidence!==null)return p[e].confidence;return null},[p]),y=(0,M.useMemo)(()=>{let e=new Map;for(let t of p){let n=t.target||`proposal`,r=e.get(n)??[];r.push(t),e.set(n,r)}return Array.from(e.entries()).map(([e,t])=>{let n=t[t.length-1];for(let e=t.length-1;e>=0;e--)if(t[e].original_text||t[e].proposed_text||t[e].rationale){n=t[e];break}let r=t.findIndex(e=>e===n);return{target:e,primaryEntry:n,historyEntries:t.filter((e,t)=>t!==r),entries:t}})},[p]);return(0,F.jsxs)(`div`,{className:`space-y-4`,children:[r&&(0,F.jsxs)(`div`,{className:`flex items-start gap-2.5 rounded-lg border border-primary/20 bg-primary/5 px-3.5 py-2.5`,children:[(0,F.jsx)(ae,{className:`mt-0.5 size-4 shrink-0 text-primary/60`}),(0,F.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`This view shows the complete evidence trail for a skill evolution proposal — how the skill was changed, the eval test results before and after, and whether the change improved performance.`})]}),(0,F.jsxs)(L,{className:`border-border/15 bg-muted/10`,children:[(0,F.jsx)(R,{className:`pb-3`,children:(0,F.jsxs)(z,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,F.jsx)(`span`,{children:`Proposal Summary`}),(0,F.jsxs)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:[`#`,e.slice(0,12)]})]})}),(0,F.jsxs)(B,{className:`space-y-3`,children:[(0,F.jsx)(`div`,{className:`rounded-lg border px-4 py-3 ${_.tone}`,children:(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.jsx)(`div`,{className:`mt-0.5 shrink-0`,children:_.icon}),(0,F.jsxs)(`div`,{className:`min-w-0 space-y-1.5`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`p`,{className:`text-sm font-semibold`,children:_.title}),h&&(0,F.jsx)(P,{variant:th[h.action]??`secondary`,className:`text-[10px] capitalize`,children:nh(h.action)})]}),(0,F.jsx)(`p`,{className:`text-sm leading-6 text-current/90`,children:_.summary}),h?.details&&(0,F.jsx)(`div`,{className:`rounded-md bg-black/10 px-3 py-2 text-sm leading-6 text-current/90 dark:bg-black/20`,children:h.details}),(0,F.jsx)(`p`,{className:`text-xs font-medium text-current/75`,children:_.liveSkillNote})]})]})}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[h?.timestamp&&(0,F.jsx)(`span`,{className:`text-[10px] font-mono text-muted-foreground`,children:Gn(h.timestamp)}),(0,F.jsxs)(P,{variant:`outline`,className:`text-[10px]`,children:[a.length,` evidence `,a.length===1?`row`:`rows`]}),v!=null&&(0,F.jsxs)(P,{variant:`secondary`,className:`text-[10px]`,children:[Math.round(v*100),`% confidence`]})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,F.jsx)(`span`,{className:`font-headline uppercase tracking-[0.16em] text-muted-foreground/80`,children:`Lifecycle`}),(0,F.jsx)(`span`,{children:g?nh(g):`No lifecycle recorded`})]}),typeof f?.net_change==`number`&&typeof f.before_pass_rate==`number`&&typeof f.after_pass_rate==`number`&&(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-md border bg-muted/20 px-3 py-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1`,children:[f.net_change>0?(0,F.jsx)(A,{className:`size-3.5 text-emerald-500`}):f.net_change<0?(0,F.jsx)(Oe,{className:`size-3.5 text-red-500`}):(0,F.jsx)(ve,{className:`size-3.5 text-muted-foreground`}),(0,F.jsxs)(`span`,{className:`text-sm font-mono font-semibold ${f.net_change>0?`text-emerald-600 dark:text-emerald-400`:f.net_change<0?`text-red-500`:`text-muted-foreground`}`,children:[f.net_change>0?`+`:``,Math.round(f.net_change*100),`%`]})]}),(0,F.jsxs)(`span`,{className:`text-xs font-mono text-muted-foreground`,children:[Math.round(f.before_pass_rate*100),`% →`,` `,Math.round(f.after_pass_rate*100),`%`]}),f.net_change>0?(0,F.jsx)(P,{variant:`default`,className:`text-[10px]`,children:`Improved`}):f.net_change<0?(0,F.jsx)(P,{variant:`destructive`,className:`text-[10px]`,children:`Regressed`}):(0,F.jsx)(P,{variant:`outline`,className:`text-[10px]`,children:`No change`})]})]})]}),y.length>0&&(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsxs)(`div`,{className:`space-y-1`,children:[(0,F.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.18em] text-muted-foreground/80`,children:`What changed`}),(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This is the actual skill text selftune proposed changing.`})]}),y.map(e=>{let t=e.historyEntries.length>0,n=c.has(e.target);return(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(mh,{entry:e.primaryEntry,roundLabel:t?`Latest draft of ${e.entries.length}`:null,roundStatus:t?`final`:`single`,prevPassRate:null,currPassRate:null}),t&&(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>d(e.target),className:`flex items-center gap-1 px-1 text-[10px] text-muted-foreground transition-colors hover:text-foreground`,children:[n?(0,F.jsx)(Ee,{className:`size-3`}):(0,F.jsx)(Ve,{className:`size-3`}),n?`Hide`:`Show`,` `,e.historyEntries.length,` earlier`,` `,e.historyEntries.length===1?`draft`:`drafts`]}),n&&e.historyEntries.map((t,n)=>(0,F.jsx)(mh,{entry:t,roundLabel:`Draft ${n+1} of ${e.historyEntries.length}`,roundStatus:`intermediate`,prevPassRate:null,currPassRate:null},`proposal-history-${e.target}-${t.timestamp}-${n}`))]})]},`proposal-${e.target}`)})]}),Array.from(m.entries()).length>0&&(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsxs)(`div`,{className:`space-y-1`,children:[(0,F.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.18em] text-muted-foreground/80`,children:`How it was tested`}),(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Validation evidence shows whether the proposal improved the eval signal.`})]}),Array.from(m.entries()).map(([e,t])=>{let n=t.length>1;return(0,F.jsx)(`div`,{className:`space-y-2`,children:t.map((r,i)=>{let a=i===t.length-1,s=n?`Round ${i+1} of ${t.length}`:null,c=i>0?dh(t[i-1]):null,l=dh(r),d=`${e}-${r.timestamp}`,f=n?a?`final`:`intermediate`:`single`;return f===`intermediate`&&!o.has(d)?(0,F.jsx)(hh,{entry:r,roundLabel:s,onExpand:()=>u(d)},d):f===`intermediate`&&o.has(d)?(0,F.jsxs)(`div`,{className:`space-y-1`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>u(d),className:`flex items-center gap-1 px-1 text-[10px] text-muted-foreground transition-colors hover:text-foreground`,children:[(0,F.jsx)(Ee,{className:`size-3`}),`Collapse `,s]}),(0,F.jsx)(mh,{entry:r,roundLabel:s,roundStatus:f,prevPassRate:c,currPassRate:l})]},d):(0,F.jsx)(mh,{entry:r,roundLabel:s,roundStatus:f,prevPassRate:c,currPassRate:l},d)})},e)})]}),a.length===0&&(0,F.jsx)(`div`,{className:`flex items-center justify-center rounded-lg border border-dashed py-8`,children:(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No evidence entries for this proposal`})})]})}var _h={created:(0,F.jsx)(ve,{className:`size-3.5`}),validated:(0,F.jsx)(k,{className:`size-3.5`}),deployed:(0,F.jsx)(D,{className:`size-3.5`}),rejected:(0,F.jsx)(h,{className:`size-3.5`}),rolled_back:(0,F.jsx)(b,{className:`size-3.5`})},vh={created:`bg-primary/15`,validated:`bg-primary/25`,deployed:`bg-primary/30`,rejected:`bg-destructive/20`,rolled_back:`bg-destructive/15`},yh={created:`text-primary/70`,validated:`text-primary/85`,deployed:`text-primary`,rejected:`text-destructive`,rolled_back:`text-destructive/70`},bh={created:`ring-primary/15`,validated:`ring-primary/25`,deployed:`ring-primary/30`,rejected:`ring-destructive/25`,rolled_back:`ring-destructive/15`},xh={created:`bg-primary/40 ring-primary/30`,validated:`bg-primary/60 ring-primary/40`,deployed:`bg-primary ring-primary/50`,rejected:`bg-destructive/60 ring-destructive/40`,rolled_back:`bg-destructive/40 ring-destructive/30`},Sh={created:`bg-primary/15`,validated:`bg-primary/20`,deployed:`bg-primary/25`,rejected:`bg-destructive/20`,rolled_back:`bg-destructive/15`};function Ch(e){let t=new Map;for(let n of e){let e=t.get(n.proposal_id)??[];e.push(n),t.set(n.proposal_id,e)}for(let e of t.values())e.sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime());return Array.from(t.entries()).sort((e,t)=>{let n=e[1][e[1].length-1],r=t[1][t[1].length-1];return new Date(r.timestamp).getTime()-new Date(n.timestamp).getTime()})}function wh(e){return e[e.length-1].action}function Th(e){for(let t=e.length-1;t>=0;t--)if(e[t].eval_snapshot)return e[t].eval_snapshot;return null}function Eh({snapshot:e}){let t=e.net_change;if(t==null)return null;let n=Math.round(t*100),r=n>0;return(0,F.jsxs)(`span`,{className:N(`inline-flex items-center gap-0.5 text-[10px] font-mono font-medium`,r?`text-primary`:`text-destructive`),children:[r?(0,F.jsx)(A,{className:`size-2.5`}):(0,F.jsx)(Oe,{className:`size-2.5`}),r?`+`:``,n,`%`]})}var Dh=[{action:`created`,label:`Created`,desc:`Proposal generated from session data`},{action:`validated`,label:`Validated`,desc:`Eval tests run, awaiting deployment`},{action:`deployed`,label:`Deployed`,desc:`Accepted and applied to skill file`},{action:`rejected`,label:`Rejected`,desc:`Failed validation criteria`},{action:`rolled_back`,label:`Rolled Back`,desc:`Reverted after deployment`}];function Oh(){let[e,t]=(0,M.useState)(!1);return(0,F.jsxs)(`div`,{className:`px-2 pb-3`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>t(!e),"aria-expanded":e,"aria-controls":`evolution-lifecycle-stages`,className:`flex w-full items-center gap-1 text-[10px] text-muted-foreground/70 transition-colors hover:text-muted-foreground`,children:[e?(0,F.jsx)(Ee,{className:`size-3`}):(0,F.jsx)(Ve,{className:`size-3`}),`Lifecycle stages`]}),e&&(0,F.jsx)(`div`,{id:`evolution-lifecycle-stages`,className:`mt-1.5 space-y-2.5 rounded-md border bg-muted/30 p-2`,children:Dh.map(e=>(0,F.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,F.jsx)(`div`,{className:N(`size-2 rounded-full shrink-0 ring-1 mt-[3px]`,xh[e.action])}),(0,F.jsxs)(`div`,{className:`min-w-0 flex flex-col gap-0.5`,children:[(0,F.jsx)(`span`,{className:`text-[10px] font-medium leading-none`,children:e.label}),(0,F.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 leading-tight`,children:e.desc})]})]},e.action))})]})}function kh({entries:e,selectedProposalId:t,onSelect:n}){let r=Ch(e);return r.length===0?(0,F.jsx)(`div`,{className:`flex items-center justify-center rounded-lg border border-dashed py-6 px-3`,children:(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No evolution history yet`})}):(0,F.jsxs)(`div`,{className:`flex flex-col gap-0`,children:[(0,F.jsx)(`h2`,{className:`px-2 pb-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground/80`,children:`Evolution`}),(0,F.jsx)(Oh,{}),(0,F.jsx)(`nav`,{className:`flex flex-col`,children:r.map(([e,i],a)=>{let o=wh(i),s=t===e,c=i[i.length-1],l=vh[o]??`bg-muted-foreground/20`,u=yh[o]??`text-muted-foreground`,d=bh[o]??`ring-muted-foreground/30`,f=Sh[o]??`bg-border`,p=a===r.length-1,m=Th(i);return(0,F.jsxs)(`div`,{className:`relative flex gap-3`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,F.jsx)(`div`,{className:N(`flex items-center justify-center size-7 rounded-full ring-2 shrink-0 z-10`,l,d,u),children:_h[o]??(0,F.jsx)(ve,{className:`size-3.5`})}),!p&&(0,F.jsx)(`div`,{className:N(`w-0.5 flex-1 min-h-[8px] my-1`,f)})]}),(0,F.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:N(`flex-1 min-w-0 rounded-md px-2.5 py-2 text-left transition-all mb-1`,`hover:bg-accent/50`,s?`bg-primary/5 ring-1 ring-primary/20`:``),children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(P,{variant:o===`deployed`?`default`:o===`rejected`||o===`rolled_back`?`destructive`:`secondary`,className:`text-[10px] capitalize`,children:o.replace(`_`,` `)}),(0,F.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Gn(c.timestamp)})]}),m&&(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,F.jsx)(Eh,{snapshot:m}),m.before_pass_rate!==void 0&&m.after_pass_rate!==void 0&&(0,F.jsxs)(`span`,{className:`text-[10px] text-muted-foreground/60 font-mono`,children:[Math.round(m.before_pass_rate*100),`→`,Math.round(m.after_pass_rate*100),`%`]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,F.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground/70`,children:[`#`,e.slice(0,8)]}),i.length>1&&(0,F.jsx)(`div`,{className:`flex gap-0.5 ml-auto`,children:i.map((e,t)=>(0,F.jsx)(`div`,{className:N(`size-1.5 rounded-full`,xh[e.action]??`bg-muted-foreground/40`)},`${e.action}-${t}`))})]}),c.details&&(0,F.jsx)(`p`,{className:`text-[11px] text-muted-foreground/80 line-clamp-2 mt-1 leading-snug`,children:c.details})]})]},e)})})]})}function Ah({text:e}){return(0,F.jsxs)(mt,{children:[(0,F.jsx)(ht,{className:`inline-flex items-center text-muted-foreground/50 hover:text-muted-foreground transition-colors cursor-help`,onClick:e=>e.preventDefault(),children:(0,F.jsx)(ae,{className:`size-3`})}),(0,F.jsx)(gt,{side:`top`,className:`max-w-[220px]`,children:e})]})}M.createContext(null);function jh(e){switch(e){case`repaired_contextual_miss`:return{label:`repaired miss`,variant:`destructive`};case`repaired_trigger`:return{label:`repaired trigger`,variant:`secondary`};case`legacy_materialized`:return{label:`legacy row`,variant:`outline`};default:return null}}function Mh(e){switch(e){case`previously_missed`:return{label:`previously missed`,variant:`secondary`};default:return null}}function Nh({row:e}){let t=e.workspace_path?e.workspace_path.split(`/`).slice(-2).join(`/`):null,n=jh(e.observation_kind),r=Mh(e.historical_context);return(0,F.jsxs)(st,{className:e.triggered?``:`bg-destructive/5`,children:[(0,F.jsx)(H,{className:`max-w-[420px] truncate py-2 text-[12px]`,title:e.query_text||void 0,children:e.query_text||(0,F.jsx)(`span`,{className:`italic text-muted-foreground/40`,children:`No prompt recorded`})}),(0,F.jsx)(H,{className:`py-2`,children:(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[e.triggered?(0,F.jsx)(P,{variant:`outline`,className:`border-green-600/30 text-[10px] font-normal text-green-600`,children:`triggered`}):(0,F.jsx)(P,{variant:`destructive`,className:`text-[10px] font-normal`,children:`missed`}),n&&(0,F.jsx)(P,{variant:n.variant,className:`text-[10px] font-normal`,children:n.label}),r&&(0,F.jsx)(P,{variant:r.variant,className:`text-[10px] font-normal`,children:r.label})]})}),(0,F.jsx)(H,{className:`py-2 font-mono text-[11px] tabular-nums text-muted-foreground`,children:e.confidence==null?`Not recorded`:`${Math.round(e.confidence*100)}%`}),(0,F.jsx)(H,{className:`py-2`,children:e.invocation_mode?(0,F.jsx)(P,{variant:`secondary`,className:`text-[10px] font-normal`,children:e.invocation_mode}):(0,F.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Unknown mode`})}),(0,F.jsx)(H,{className:`py-2 text-[11px] text-muted-foreground`,children:e.prompt_kind??`Unclassified`}),(0,F.jsx)(H,{className:`py-2 text-[11px] text-muted-foreground`,children:e.source??`No data`}),(0,F.jsx)(H,{className:`py-2 text-[11px] text-muted-foreground`,children:e.platform??`No data`}),(0,F.jsx)(H,{className:`py-2 font-mono text-[11px] text-muted-foreground`,title:e.workspace_path??void 0,children:t??`No data`}),(0,F.jsx)(H,{className:`py-2`,children:(0,F.jsx)(P,{variant:e.query_origin===`inline_query`?`outline`:e.query_origin===`matched_prompt`?`secondary`:`destructive`,className:`text-[10px] font-normal`,children:e.query_origin})})]})}function Ph({rows:e,emptyMessage:t}){return e.length===0?(0,F.jsx)(`div`,{className:`flex items-center justify-center py-12 text-sm text-muted-foreground`,children:t}):(0,F.jsx)(`div`,{className:`themed-scroll max-h-[340px] overflow-auto`,children:(0,F.jsxs)(it,{children:[(0,F.jsx)(at,{children:(0,F.jsxs)(st,{className:`sticky top-0 z-10 bg-muted/70 backdrop-blur hover:bg-muted/70`,children:[(0,F.jsx)(V,{className:`h-8 font-headline text-[10px] uppercase tracking-[0.15em]`,children:`Prompt`}),(0,F.jsx)(V,{className:`h-8 w-[80px] font-headline text-[10px] uppercase tracking-[0.15em]`,children:`Status`}),(0,F.jsx)(V,{className:`h-8 w-[70px] font-headline text-[10px] uppercase tracking-[0.15em]`,children:`Confidence`}),(0,F.jsx)(V,{className:`h-8 w-[80px] font-headline text-[10px] uppercase tracking-[0.15em]`,children:`Mode`}),(0,F.jsx)(V,{className:`h-8 w-[80px] font-headline text-[10px] uppercase tracking-[0.15em]`,children:`Kind`}),(0,F.jsx)(V,{className:`h-8 w-[70px] font-headline text-[10px] uppercase tracking-[0.15em]`,children:`Source`}),(0,F.jsx)(V,{className:`h-8 w-[70px] font-headline text-[10px] uppercase tracking-[0.15em]`,children:`Platform`}),(0,F.jsx)(V,{className:`h-8 w-[100px] font-headline text-[10px] uppercase tracking-[0.15em]`,children:`Workspace`}),(0,F.jsx)(V,{className:`h-8 w-[100px] font-headline text-[10px] uppercase tracking-[0.15em]`,children:`Origin`})]})}),(0,F.jsx)(ot,{children:e.map((e,t)=>(0,F.jsx)(Nh,{row:e},`${e.session_id}-${t}`))})]})})}function Fh({label:e,value:t,warn:n}){let r=t==null?null:Math.round(t*100);return(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`span`,{className:`w-40 shrink-0 font-headline text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:e}),(0,F.jsx)(`div`,{className:`h-2 flex-1 overflow-hidden rounded-full bg-muted`,children:r!=null&&(0,F.jsx)(`div`,{className:`h-full rounded-full transition-all ${n?`bg-destructive`:`bg-primary`}`,style:{width:`${Math.min(r,100)}%`}})}),(0,F.jsx)(`span`,{className:`w-10 text-right font-mono text-xs tabular-nums ${n?`text-destructive`:`text-muted-foreground`}`,children:r==null?`No data`:`${r}%`})]})}function Ih({title:e,data:t}){if(!t||t.length===0)return null;let n=e=>{switch(e){case`repaired_contextual_miss`:return`repaired contextual miss`;case`repaired_trigger`:return`repaired trigger`;case`legacy_materialized`:return`legacy materialized`;default:return e}},r=t.map(e=>[n(e.source??e.kind??`(unknown)`),e.count]).sort(([,e],[,t])=>t-e),i=r.reduce((e,[,t])=>e+t,0);return(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h4`,{className:`mb-2 font-headline text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:e}),(0,F.jsxs)(it,{children:[(0,F.jsx)(at,{children:(0,F.jsxs)(st,{className:`hover:bg-transparent`,children:[(0,F.jsx)(V,{className:`h-7 font-headline text-[10px] uppercase tracking-[0.15em]`,children:`Value`}),(0,F.jsx)(V,{className:`h-7 w-[80px] text-right font-headline text-[10px] uppercase tracking-[0.15em]`,children:`Count`}),(0,F.jsx)(V,{className:`h-7 w-[80px] text-right font-headline text-[10px] uppercase tracking-[0.15em]`,children:`Rate`})]})}),(0,F.jsx)(ot,{children:r.map(([e,t])=>(0,F.jsxs)(st,{children:[(0,F.jsx)(H,{className:`py-2 text-[11px]`,children:e}),(0,F.jsx)(H,{className:`py-2 text-right font-mono text-[11px]`,children:t}),(0,F.jsx)(H,{className:`py-2 text-right font-mono text-[11px] text-muted-foreground`,children:i>0?`${Math.round(t/i*100)}%`:`0%`})]},e))})]})]})}function Lh({nextAction:e,latestDecision:t}){let n=e.variant===`destructive`?`border-destructive/25`:e.variant===`default`?`border-primary/20`:`border-border/15`;return(0,F.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 @4xl/main:grid-cols-12`,children:[(0,F.jsx)(L,{className:`rounded-xl border bg-muted/35 shadow-none ${t?`@4xl/main:col-span-8`:`@4xl/main:col-span-12`} ${n}`,children:(0,F.jsxs)(B,{className:`flex items-start gap-3 px-4 py-4`,children:[(0,F.jsx)(`div`,{className:`shrink-0 pt-0.5`,children:e.icon}),(0,F.jsxs)(`div`,{className:`flex-1`,children:[(0,F.jsx)(`h3`,{className:`mb-1 font-headline text-[10px] uppercase tracking-[0.18em] text-muted-foreground`,children:`Next Best Action`}),(0,F.jsx)(`p`,{className:`text-[15px] font-medium leading-6 text-foreground`,children:e.text})]}),(0,F.jsx)(P,{variant:e.variant,className:`shrink-0 self-start text-[10px]`,children:e.actionLabel})]})}),t&&(0,F.jsx)(L,{className:`rounded-xl border border-border/10 bg-muted/20 @4xl/main:col-span-4`,children:(0,F.jsxs)(B,{className:`flex h-full items-start gap-3 px-4 py-4`,children:[(0,F.jsx)(ze,{className:`mt-0.5 size-4 shrink-0 text-primary/80`}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`h3`,{className:`mb-1 font-headline text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Latest Decision`}),(0,F.jsx)(`p`,{className:`truncate text-sm font-medium leading-6`,children:t.action}),t.timestamp&&(0,F.jsx)(`p`,{className:`mt-0.5 font-mono text-[10px] text-muted-foreground`,children:Gn(t.timestamp)})]}),(0,F.jsxs)(P,{variant:`outline`,className:`shrink-0 self-start text-[9px]`,children:[t.evolutionCount,` evolution`,t.evolutionCount===1?``:`s`]})]})})]})}function Rh({checks:e,sessions:t,promptLinkRate:n}){return`Selftune watched ${e} skill checks across ${t} sessions.${n==null?``:` It could link ${Un(n)} of those checks back to prompts.`}`}function zh({missRate:e,missedTriggers:t,systemLikeRate:n}){return(t??0)>0&&e!=null?`It found ${t} likely misses (${Un(e)} miss rate), which means people asked for this skill and it probably should have triggered.`:(n??0)>.05?`Routing looks mostly stable, but some records appear system-generated, so selftune is being cautious about making strong claims.`:`Routing looks consistent in the current sample, with no strong signs that this skill is missing obvious requests.`}function Bh({trustState:e,latestAction:t,nextActionText:n}){switch(e){case`validated`:return`Selftune found a candidate that looks promising, but it has not been deployed yet. ${n}`;case`deployed`:return`A change has already been deployed for this skill. Selftune is now watching for regressions in real use.`;case`rolled_back`:return`A previous change was rolled back, so the live skill is back on the safer version while selftune keeps observing.`;case`watch`:return`Selftune sees enough signal to keep a close eye on this skill, but not enough to blindly change it. ${n}`;case`observed`:return`Selftune is still learning how people use this skill before making stronger recommendations.`;case`low_sample`:return`There is not enough evidence yet to trust a big change here. Selftune is still collecting examples.`;default:return t?`The latest automated decision for this skill was ${t}. ${n}`:n}}function Vh({title:e,icon:t,body:n}){return(0,F.jsxs)(`div`,{className:`rounded-xl border border-border/10 bg-muted/20 p-4`,children:[(0,F.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,F.jsx)(`div`,{className:`text-primary/80`,children:t}),(0,F.jsx)(`h3`,{className:`font-headline text-[10px] uppercase tracking-[0.18em] text-muted-foreground`,children:e})]}),(0,F.jsx)(`p`,{className:`text-sm leading-6 text-foreground/90`,children:n})]})}function Hh({trustState:e,coverage:t,evidenceQuality:n,routingQuality:r,evolutionState:i,dataHygiene:a,fallbackChecks:o,fallbackSessions:s,nextActionText:c,onOpenGuide:l}){let u=t?.checks??o,d=t?.sessions??s,f=a?.raw_checks??u,p=a?.internal_prompt_rows??0,m=a?.legacy_rows??0,h=a?.repaired_rows??0,g=Math.max(f-u,0)>0||m>0||h>0;return(0,F.jsxs)(L,{className:`rounded-xl border border-border/10 bg-card/95`,children:[(0,F.jsx)(R,{className:`gap-2 px-4 py-4`,children:(0,F.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,F.jsxs)(`div`,{className:`space-y-1`,children:[(0,F.jsx)(z,{className:`text-base`,children:`How selftune is improving this skill`}),(0,F.jsx)(nt,{children:`Read this first if you want the plain-English version before diving into the evidence below.`})]}),l&&(0,F.jsx)(I,{variant:`outline`,size:`sm`,onClick:l,children:`How to read this page`})]})}),(0,F.jsxs)(B,{className:`space-y-4 px-4 pb-4 pt-0`,children:[g&&(0,F.jsxs)(`div`,{className:`rounded-xl border border-primary/10 bg-primary/5 px-4 py-3 text-sm text-muted-foreground`,children:[(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:`Trust note:`}),` This summary is based on `,(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:u}),` operational checks from real usage.`,p>0&&(0,F.jsxs)(F.Fragment,{children:[` `,(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:p}),` internal selftune eval or optimizer prompts are excluded from trust scoring.`]}),m>0&&(0,F.jsxs)(F.Fragment,{children:[` `,(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:m}),` legacy rows stay in history only.`]}),h>0&&(0,F.jsxs)(F.Fragment,{children:[` `,(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:h}),` repaired misses come from transcript replay rather than first-party trigger events.`]})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 @4xl/main:grid-cols-3`,children:[(0,F.jsx)(Vh,{title:`What selftune saw`,icon:(0,F.jsx)(Me,{className:`size-4`}),body:Rh({checks:u,sessions:d,promptLinkRate:n?.prompt_link_rate})}),(0,F.jsx)(Vh,{title:`Why it acted`,icon:(0,F.jsx)(w,{className:`size-4`}),body:zh({missRate:r?.miss_rate,missedTriggers:r?.missed_triggers,systemLikeRate:n?.system_like_rate})}),(0,F.jsx)(Vh,{title:`What happened next`,icon:(0,F.jsx)(ze,{className:`size-4`}),body:Bh({trustState:e,latestAction:i?.latest_action,nextActionText:c})})]}),(0,F.jsx)(`div`,{className:`rounded-xl border border-border/10 bg-muted/15 px-4 py-3 text-sm text-muted-foreground`,children:`If a proposal is rejected or still pending, your live skill has not changed yet. Selftune only earns trust by testing changes before deployment.`})]})]})}function Uh({coverage:e,evidenceQuality:t,routingQuality:n,evolutionState:r,fallbackChecks:i,fallbackSessions:a,fallbackEvidenceRows:o,fallbackEvolutionRows:s,fallbackLatestAction:c}){let l=(r?.evolution_rows??s)>0;return(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`mb-2 font-headline text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Trust Signals`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 @xl/main:grid-cols-2 @5xl/main:grid-cols-4`,children:[(0,F.jsx)(L,{className:`rounded-xl border border-border/10 bg-muted/20 transition-colors hover:border-border/20 @container/card`,children:(0,F.jsxs)(R,{className:`gap-2 px-4 py-3`,children:[(0,F.jsxs)(nt,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(Me,{className:`size-3.5`}),(0,F.jsx)(`span`,{className:`font-headline text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Coverage`})]}),(0,F.jsx)(z,{className:`text-[32px] font-semibold leading-none tabular-nums text-foreground`,children:e?.checks??i}),(0,F.jsx)(rt,{children:(0,F.jsxs)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:[e?.sessions??a,` sessions /`,` `,e?.workspaces??`No data`,` dirs`]})})]})}),(0,F.jsx)(L,{className:`rounded-xl border border-border/10 bg-muted/20 transition-colors hover:border-border/20 @container/card`,children:(0,F.jsxs)(R,{className:`gap-2 px-4 py-3`,children:[(0,F.jsxs)(nt,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(w,{className:`size-3.5`}),(0,F.jsx)(`span`,{className:`font-headline text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Evidence Quality`}),(0,F.jsx)(Ah,{text:`How well prompts are linked to invocations. Higher prompt-link rate = more trustworthy data.`})]}),(0,F.jsx)(z,{className:`text-[32px] font-semibold leading-none tabular-nums text-foreground`,children:t?.prompt_link_rate==null?`No data`:Un(t.prompt_link_rate)}),(0,F.jsx)(rt,{children:(0,F.jsxs)(`div`,{className:`flex flex-col items-end gap-0.5`,children:[(0,F.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`inline:`,` `,t?.inline_query_rate==null?`No data`:Un(t.inline_query_rate)]}),(t?.system_like_rate??0)>.05&&(0,F.jsxs)(P,{variant:`destructive`,className:`text-[9px]`,children:[Un(t?.system_like_rate??0),` system-like`]})]})})]})}),(0,F.jsx)(L,{className:`rounded-xl border border-border/10 bg-muted/20 transition-colors hover:border-border/20 @container/card`,children:(0,F.jsxs)(R,{className:`gap-2 px-4 py-3`,children:[(0,F.jsxs)(nt,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(g,{className:`size-3.5`}),(0,F.jsx)(`span`,{className:`font-headline text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Routing`}),(0,F.jsx)(Ah,{text:`Routing accuracy: average confidence when triggering, and miss rate`})]}),(0,F.jsx)(z,{className:`text-[32px] font-semibold leading-none tabular-nums text-foreground`,children:n?.avg_confidence==null?`No data`:Un(n.avg_confidence)}),(0,F.jsx)(rt,{children:(0,F.jsxs)(`div`,{className:`flex flex-col items-end gap-0.5`,children:[(0,F.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`miss:`,` `,n?.miss_rate==null?`No data`:Un(n.miss_rate)]}),(0,F.jsxs)(`span`,{className:`text-[10px] tabular-nums text-muted-foreground`,children:[n?.missed_triggers??`No data`,` missed`]})]})})]})}),(0,F.jsx)(L,{className:`rounded-xl border border-border/10 bg-muted/20 transition-colors hover:border-border/20 @container/card`,children:(0,F.jsxs)(R,{className:`gap-2 px-4 py-3`,children:[(0,F.jsxs)(nt,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(ze,{className:`size-3.5`}),(0,F.jsx)(`span`,{className:`font-headline text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Evolution`})]}),l?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(z,{className:`text-sm font-medium leading-6`,children:r?.latest_action??c??`No data`}),(0,F.jsx)(rt,{children:(0,F.jsxs)(`div`,{className:`flex flex-col items-end gap-0.5`,children:[(0,F.jsxs)(`span`,{className:`text-[10px] tabular-nums text-muted-foreground`,children:[r?.evidence_rows??o,` evidence`]}),(0,F.jsxs)(`span`,{className:`text-[10px] tabular-nums text-muted-foreground`,children:[r?.evolution_rows??s,` evolution`]}),r?.latest_timestamp&&(0,F.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:Gn(r.latest_timestamp)})]})})]}):(0,F.jsx)(z,{className:`text-sm font-normal text-muted-foreground`,children:`No evolution yet`})]})})]})]})}function Wh({examples:e}){return!e||e.good.length===0&&e.missed.length===0&&e.noisy.length===0?null:(0,F.jsxs)(L,{className:`rounded-xl border border-border/10 bg-card/90`,children:[(0,F.jsx)(R,{className:`px-4 pb-2 pt-4`,children:(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(z,{className:`font-headline text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Prompt Evidence`}),(0,F.jsx)(nt,{children:`Representative real usage first. Internal selftune traffic is separated so it does not masquerade as normal skill use.`})]}),(0,F.jsxs)(`div`,{className:`hidden items-center gap-2 text-[10px] text-muted-foreground @3xl/main:flex`,children:[(0,F.jsxs)(`span`,{children:[e.good.length,` successful`]}),(0,F.jsx)(`span`,{className:`text-border`,children:`|`}),(0,F.jsxs)(`span`,{children:[e.missed.length,` missed`]}),(0,F.jsx)(`span`,{className:`text-border`,children:`|`}),(0,F.jsxs)(`span`,{children:[e.noisy.length,` internal/polluted`]})]})]})}),(0,F.jsx)(B,{className:`px-4 pb-4 pt-0`,children:(0,F.jsxs)(ct,{defaultValue:`good`,children:[(0,F.jsxs)(ut,{variant:`line`,className:`min-h-0 rounded-xl border border-border/10 bg-muted/20 px-1.5 py-1`,children:[(0,F.jsxs)(dt,{value:`good`,className:`rounded-lg px-3 data-active:bg-background/70 data-active:text-foreground`,children:[`Successful Triggers`,(0,F.jsx)(P,{variant:`outline`,className:`ml-1.5 text-[10px]`,children:e.good.length})]}),(0,F.jsxs)(dt,{value:`missed`,className:`rounded-lg px-3 data-active:bg-background/70 data-active:text-foreground`,children:[`Missed Real Usage`,(0,F.jsx)(P,{variant:e.missed.length>0?`destructive`:`outline`,className:`ml-1.5 text-[10px]`,children:e.missed.length})]}),(0,F.jsxs)(dt,{value:`noisy`,className:`rounded-lg px-3 data-active:bg-background/70 data-active:text-foreground`,children:[`Internal / Polluted`,(0,F.jsx)(P,{variant:e.noisy.length>0?`destructive`:`outline`,className:`ml-1.5 text-[10px]`,children:e.noisy.length})]})]}),(0,F.jsx)(ft,{value:`good`,className:`mt-2`,children:(0,F.jsx)(Ph,{rows:e.good,emptyMessage:`No successful trigger samples yet.`})}),(0,F.jsx)(ft,{value:`missed`,className:`mt-2`,children:(0,F.jsx)(Ph,{rows:e.missed,emptyMessage:`No missed real-usage samples detected.`})}),(0,F.jsx)(ft,{value:`noisy`,className:`mt-2`,children:(0,F.jsx)(Ph,{rows:e.noisy,emptyMessage:`No internal or polluted samples detected.`})})]})})]})}function Gh({evidenceQuality:e,dataHygiene:t}){return(0,F.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 @5xl/main:grid-cols-2 @5xl/main:items-start`,children:[(0,F.jsxs)(L,{className:`rounded-2xl border border-border/15 bg-card`,children:[(0,F.jsx)(R,{children:(0,F.jsxs)(z,{className:`flex items-center gap-2 font-headline text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:[(0,F.jsx)(Ie,{className:`size-4`}),`Evidence Quality Rates`]})}),(0,F.jsxs)(B,{className:`space-y-3 p-4`,children:[(0,F.jsx)(Fh,{label:`Prompt-linked`,value:e?.prompt_link_rate}),(0,F.jsx)(Fh,{label:`Inline query`,value:e?.inline_query_rate}),(0,F.jsx)(Fh,{label:`User prompt`,value:e?.user_prompt_rate}),(0,F.jsx)(Fh,{label:`Meta prompt`,value:e?.meta_prompt_rate}),(0,F.jsx)(Fh,{label:`No prompt`,value:e?.no_prompt_rate}),(0,F.jsx)(Fh,{label:`System-like`,value:e?.system_like_rate,warn:(e?.system_like_rate??0)>.05}),(0,F.jsx)(`div`,{className:`mt-3 border-t border-border/40 pt-3`}),(0,F.jsx)(Fh,{label:`Invocation mode`,value:e?.invocation_mode_coverage}),(0,F.jsx)(Fh,{label:`Confidence`,value:e?.confidence_coverage}),(0,F.jsx)(Fh,{label:`Source`,value:e?.source_coverage}),(0,F.jsx)(Fh,{label:`Scope`,value:e?.scope_coverage})]})]}),t&&(0,F.jsxs)(L,{className:`rounded-2xl border border-border/15 bg-card`,children:[(0,F.jsx)(R,{children:(0,F.jsxs)(z,{className:`flex items-center gap-2 font-headline text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:[(0,F.jsx)(te,{className:`size-4`}),`Data Hygiene`]})}),(0,F.jsxs)(B,{className:`space-y-6 p-4`,children:[(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,F.jsxs)(`div`,{className:`rounded-xl border border-border/15 bg-muted/30 p-3`,children:[(0,F.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Raw vs Operational`}),(0,F.jsxs)(`div`,{className:`mt-2 flex items-end gap-2`,children:[(0,F.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-foreground`,children:t.operational_checks}),(0,F.jsxs)(`div`,{className:`pb-0.5 text-xs text-muted-foreground`,children:[`of `,t.raw_checks,` checks`]})]}),(0,F.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:`Operational checks exclude internal selftune eval and optimizer traffic.`})]}),(0,F.jsxs)(`div`,{className:`rounded-xl border border-border/15 bg-muted/30 p-3`,children:[(0,F.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Historical Residue`}),(0,F.jsxs)(`div`,{className:`mt-2 flex items-end gap-2`,children:[(0,F.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-foreground`,children:t.legacy_rows}),(0,F.jsxs)(`div`,{className:`pb-0.5 text-xs text-muted-foreground`,children:[`legacy / `,t.repaired_rows,` repaired`]})]}),(0,F.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:`Legacy rows are older materialized history. Repaired rows are transcript-based reconstructions.`})]})]}),t.naming_variants&&t.naming_variants.length>1&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h4`,{className:`mb-2 font-headline text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Naming Variants`}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.naming_variants.map(e=>(0,F.jsx)(P,{variant:`outline`,className:`font-mono text-[10px]`,children:e},e))}),(0,F.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:`Multiple naming variants may indicate inconsistent skill registration.`})]}),(0,F.jsx)(Ih,{title:`Source Breakdown`,data:t.source_breakdown}),(0,F.jsx)(Ih,{title:`Prompt Kind Breakdown`,data:t.prompt_kind_breakdown}),(0,F.jsx)(Ih,{title:`Observation Breakdown`,data:t.observation_breakdown})]})]})]})}var Kh=6e4;function qh(e){return Vn({queryKey:[`skill-report`,e],queryFn:()=>Fs(e),enabled:!!e,staleTime:5e3,refetchInterval:Kh,retry:(e,t)=>t instanceof Rs?!1:e<2})}var Jh=`selftune.skill-report-onboarding-dismissed`;function Yh({open:e,onOpenChange:t}){return(0,F.jsx)(Kn,{open:e,onOpenChange:t,children:(0,F.jsxs)(Yn,{side:`right`,className:`overflow-y-auto sm:max-w-lg`,children:[(0,F.jsxs)(Xn,{className:`space-y-2 border-b border-border/10 pb-4`,children:[(0,F.jsx)(Zn,{children:`How to read this page`}),(0,F.jsx)(Qn,{children:`selftune earns trust by showing what it observed, what it proposed, how it tested the change, and what happened next.`})]}),(0,F.jsxs)(`div`,{className:`space-y-6 p-4`,children:[(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(`h3`,{className:`font-headline text-[10px] uppercase tracking-[0.18em] text-muted-foreground`,children:`The improvement loop`}),(0,F.jsxs)(`div`,{className:`space-y-3 text-sm text-muted-foreground`,children:[(0,F.jsxs)(`p`,{children:[(0,F.jsx)(`strong`,{className:`text-foreground`,children:`1. Observe.`}),` selftune watches real sessions and notes when a skill triggered, missed, or looked noisy.`]}),(0,F.jsxs)(`p`,{children:[(0,F.jsx)(`strong`,{className:`text-foreground`,children:`2. Propose.`}),` when the signal is strong enough, it suggests a wording change to the skill.`]}),(0,F.jsxs)(`p`,{children:[(0,F.jsx)(`strong`,{className:`text-foreground`,children:`3. Validate.`}),` it checks whether the new wording improves routing without breaking important cases.`]}),(0,F.jsxs)(`p`,{children:[(0,F.jsx)(`strong`,{className:`text-foreground`,children:`4. Decide.`}),` only validated winners should be deployed. Rejected or pending proposals do not change the live skill.`]})]})]}),(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(`h3`,{className:`font-headline text-[10px] uppercase tracking-[0.18em] text-muted-foreground`,children:`What each section means`}),(0,F.jsxs)(`div`,{className:`space-y-3 text-sm text-muted-foreground`,children:[(0,F.jsxs)(`p`,{children:[(0,F.jsx)(`strong`,{className:`text-foreground`,children:`Next Best Action`}),` tells you whether you should review, deploy, or simply keep observing.`]}),(0,F.jsxs)(`p`,{children:[(0,F.jsx)(`strong`,{className:`text-foreground`,children:`How selftune is improving this skill`}),` `,`explains the current state in plain language.`]}),(0,F.jsxs)(`p`,{children:[(0,F.jsx)(`strong`,{className:`text-foreground`,children:`Trust Signals`}),` are the condensed metrics behind that story: coverage, evidence quality, routing quality, and evolution state.`]}),(0,F.jsxs)(`p`,{children:[(0,F.jsx)(`strong`,{className:`text-foreground`,children:`Evidence`}),` shows what changed and why a proposal was accepted, rejected, or left pending.`]}),(0,F.jsxs)(`p`,{children:[(0,F.jsx)(`strong`,{className:`text-foreground`,children:`Invocations`}),` shows real prompts where this skill triggered or likely should have triggered.`]}),(0,F.jsxs)(`p`,{children:[(0,F.jsx)(`strong`,{className:`text-foreground`,children:`Data Quality`}),` tells you how trustworthy the underlying telemetry is.`]})]})]}),(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(`h3`,{className:`font-headline text-[10px] uppercase tracking-[0.18em] text-muted-foreground`,children:`FAQ`}),(0,F.jsxs)(`div`,{className:`space-y-4 text-sm text-muted-foreground`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`font-medium text-foreground`,children:`What is a missed trigger?`}),(0,F.jsx)(`p`,{children:`A case where selftune believes the skill should have been used, but the agent did not invoke it.`})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`font-medium text-foreground`,children:`Why was a proposal rejected?`}),(0,F.jsx)(`p`,{children:`Usually because validation showed the new wording would regress existing behavior, or because it violated a hard rule like dropping an important anchor phrase.`})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`font-medium text-foreground`,children:`When should I trust a recommendation?`}),(0,F.jsx)(`p`,{children:`Trust it more when the page shows broad coverage, prompt-linked evidence, and a validated result. Trust it less when the sample is tiny or the data is noisy.`})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`font-medium text-foreground`,children:`Do I need to understand every metric?`}),(0,F.jsx)(`p`,{children:`No. Start with the plain-English summary and next best action. Use the deeper tabs only when you want to inspect the evidence yourself.`})]})]})]})]})]})})}var Xh={low_sample:{label:`Low Sample`,variant:`secondary`,icon:(0,F.jsx)(O,{className:`size-3`})},observed:{label:`Observed`,variant:`outline`,icon:(0,F.jsx)(oe,{className:`size-3`})},watch:{label:`Watch`,variant:`secondary`,icon:(0,F.jsx)(ee,{className:`size-3`})},validated:{label:`Validated`,variant:`default`,icon:(0,F.jsx)(k,{className:`size-3`})},deployed:{label:`Deployed`,variant:`default`,icon:(0,F.jsx)(k,{className:`size-3`})},rolled_back:{label:`Rolled Back`,variant:`destructive`,icon:(0,F.jsx)(De,{className:`size-3`})}};function Zh({sessionId:e,meta:t,invocations:n,defaultExpanded:r}){let[i,a]=(0,M.useState)(r),o=t?.started_at??n[0]?.timestamp,s=n.reduce((e,t)=>{let n=t.invocation_mode??`unknown`;return e[n]=(e[n]??0)+1,e},{}),c=e=>{let n=t?.agent_cli?.replace(/_/g,` `),r=t?.platform?.replace(/_/g,` `);return e.agent_type&&e.agent_type!==`main`?{label:e.agent_type,hint:n?`${n} subagent`:`subagent invocation`}:n?{label:n,hint:e.agent_type===`main`?`main agent invocation`:`session agent that invoked the skill`}:r?{label:r,hint:e.agent_type===`main`?`main agent invocation`:`session platform`}:e.agent_type?{label:e.agent_type,hint:`recorded subagent type`}:{label:`No data`,hint:`invoker was not captured in this record`}};return(0,F.jsxs)(`div`,{className:`rounded-lg border border-border/60 overflow-hidden transition-colors`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-muted/40 active:bg-muted/60 transition-colors`,onClick:()=>a(!i),children:[(0,F.jsx)(Ve,{className:`size-3.5 text-muted-foreground shrink-0 transition-transform duration-150 ${i?`rotate-90`:``}`}),(0,F.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0 flex-1`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsxs)(`span`,{className:`text-sm font-medium`,children:[n.length,` invocation`,n.length===1?``:`s`]}),(0,F.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:o?Gn(o):``})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[t?.model&&(0,F.jsx)(P,{variant:`secondary`,className:`text-[10px] font-normal`,children:t.model}),t?.workspace_path&&(0,F.jsx)(`span`,{className:`text-[11px] text-muted-foreground font-mono`,title:t.workspace_path,children:t.workspace_path.split(`/`).slice(-2).join(`/`)})]})]}),!i&&(0,F.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:Object.entries(s).map(([e,t])=>(0,F.jsxs)(P,{variant:`outline`,className:`text-[10px] font-normal gap-1`,children:[e,` `,(0,F.jsx)(`span`,{className:`text-muted-foreground`,children:t})]},e))}),(0,F.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 font-mono shrink-0`,children:e.substring(0,8)})]}),i&&(0,F.jsx)(`div`,{className:`border-t border-border/40 overflow-x-auto`,children:(0,F.jsxs)(it,{children:[(0,F.jsx)(at,{children:(0,F.jsxs)(st,{className:`hover:bg-transparent bg-muted/40`,children:[(0,F.jsxs)(V,{className:`font-headline text-[10px] uppercase tracking-[0.15em] h-8`,children:[`Prompt `,(0,F.jsx)(Ah,{text:`The user prompt that led to this skill being invoked`})]}),(0,F.jsxs)(V,{className:`font-headline text-[10px] uppercase tracking-[0.15em] h-8 w-[90px]`,children:[`Mode`,` `,(0,F.jsx)(Ah,{text:`explicit = user typed /skillname; implicit = user mentioned skill by name; inferred = agent chose skill autonomously`})]}),(0,F.jsxs)(V,{className:`font-headline text-[10px] uppercase tracking-[0.15em] h-8 w-[70px]`,children:[`Confidence`,` `,(0,F.jsx)(Ah,{text:`Model's confidence score (0-100%) when routing this prompt to the skill`})]}),(0,F.jsxs)(V,{className:`font-headline text-[10px] uppercase tracking-[0.15em] h-8 w-[110px]`,children:[`Invoker`,` `,(0,F.jsx)(Ah,{text:`Who invoked the skill. Prefers subagent type when present, otherwise falls back to the session agent or platform.`})]}),(0,F.jsx)(V,{className:`font-headline text-[10px] uppercase tracking-[0.15em] h-8 w-[120px]`,children:`Evidence`}),(0,F.jsx)(V,{className:`font-headline text-[10px] uppercase tracking-[0.15em] h-8 w-[70px] text-right`,children:`Time`})]})}),(0,F.jsx)(ot,{children:n.map((e,t)=>(0,F.jsxs)(st,{className:e.triggered?``:`bg-destructive/5`,children:[(0,F.jsxs)(H,{className:`max-w-[500px] truncate text-sm py-2`,title:e.query||void 0,children:[e.query||(0,F.jsx)(`span`,{className:`text-muted-foreground/40 italic`,children:`No prompt recorded`}),!e.triggered&&(0,F.jsx)(P,{variant:`destructive`,className:`text-[10px] font-normal ml-2`,children:`missed`})]}),(0,F.jsx)(H,{className:`py-2`,children:e.invocation_mode?(0,F.jsx)(P,{variant:`secondary`,className:`text-[10px] font-normal`,children:e.invocation_mode}):(0,F.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Unknown mode`})}),(0,F.jsx)(H,{className:`py-2 font-mono text-xs text-muted-foreground tabular-nums`,children:e.confidence===null?`Not recorded`:`${Math.round(e.confidence*100)}%`}),(0,F.jsx)(H,{className:`py-2`,children:(()=>{let t=c(e);return t.label===`No data`?(0,F.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,title:t.hint,children:t.label}):(0,F.jsx)(P,{variant:e.agent_type&&e.agent_type!==`main`?`outline`:`secondary`,className:`text-[10px] font-normal capitalize`,title:t.hint,children:t.label})})()}),(0,F.jsx)(H,{className:`py-2`,children:(()=>{let t=jh(e.observation_kind),n=Mh(e.historical_context);return t?(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,F.jsx)(P,{variant:t.variant,className:`text-[10px] font-normal`,children:t.label}),n&&(0,F.jsx)(P,{variant:n.variant,className:`text-[10px] font-normal`,children:n.label})]}):(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`canonical`}),n&&(0,F.jsx)(P,{variant:n.variant,className:`text-[10px] font-normal`,children:n.label})]})})()}),(0,F.jsx)(H,{className:`py-2 font-mono text-[11px] text-muted-foreground text-right whitespace-nowrap`,children:e.timestamp?Gn(e.timestamp):``})]},t))})]})})]})}function Qh(e,t,n,r,i){return e===`low_sample`?{icon:(0,F.jsx)(oe,{className:`size-5`}),text:`Keep observing. This skill needs more sessions before trust can be assessed.`,actionLabel:`Keep observing`,variant:`secondary`}:e===`rolled_back`?{icon:(0,F.jsx)(y,{className:`size-5 text-destructive`}),text:`Inspect rollback evidence before re-deploying.`,actionLabel:`Inspect rollback`,variant:`destructive`}:e===`watch`&&(n??0)>.05?{icon:(0,F.jsx)(y,{className:`size-5 text-amber-500`}),text:`Clean source-truth data or routing data before trusting this report.`,actionLabel:`Clean data`,variant:`secondary`}:e===`watch`&&(t??0)>0?{icon:(0,F.jsx)(w,{className:`size-5 text-amber-500`}),text:`Generate evals to investigate missed triggers.`,actionLabel:`Generate evals`,variant:`secondary`}:e===`watch`?{icon:(0,F.jsx)(oe,{className:`size-5 text-amber-500`}),text:`This skill is under active observation. Review recent invocations to verify routing accuracy.`,actionLabel:`Review invocations`,variant:`secondary`}:r?{icon:(0,F.jsx)(ze,{className:`size-5 text-primary`}),text:`Review pending proposal.`,actionLabel:`Review proposal`,variant:`default`}:e===`validated`?{icon:(0,F.jsx)(be,{className:`size-5 text-primary`}),text:`Deploy the validated candidate.`,actionLabel:`Deploy candidate`,variant:`default`}:e===`deployed`?{icon:(0,F.jsx)(Ge,{className:`size-5 text-green-500`}),text:`No action needed. Skill is healthy and being monitored.`,actionLabel:`Healthy`,variant:`outline`}:e===`observed`?{icon:(0,F.jsx)(oe,{className:`size-5 text-muted-foreground`}),text:`No action needed. Selftune is still observing this skill and building confidence from real usage.`,actionLabel:`Observed`,variant:`outline`}:{icon:(0,F.jsx)(oe,{className:`size-5`}),text:`Continue monitoring this skill.`,actionLabel:`Monitor`,variant:`outline`}}function $h({evolution:e,activeProposal:t,onSelect:n}){let r=new Set(e.map(e=>e.proposal_id)).size,i=r>6,[a,o]=(0,M.useState)(!i),s=(0,M.useMemo)(()=>{if(a)return e;let t=new Set,n=[];for(let r of e){if(!t.has(r.proposal_id)){if(t.size>=6)continue;t.add(r.proposal_id)}n.push(r)}return n},[6,e,a]);return(0,F.jsx)(`aside`,{className:`w-full px-4 py-4 @5xl/main:w-[252px] @5xl/main:self-start @5xl/main:pr-0`,children:(0,F.jsx)(`div`,{className:`@5xl/main:sticky @5xl/main:top-16`,children:(0,F.jsxs)(`div`,{className:`rounded-xl border border-border/10 bg-muted/20 px-3 py-3 text-xs ${a?`themed-scroll max-h-[26rem] overflow-y-auto @5xl/main:max-h-[calc(100svh-6rem)]`:`overflow-visible`}`,children:[(0,F.jsx)(kh,{entries:s,selectedProposalId:t,onSelect:n}),i&&(0,F.jsxs)(`button`,{type:`button`,onClick:()=>o(!a),className:`mt-2 flex w-full items-center justify-center gap-1.5 py-2 text-[11px] text-muted-foreground transition-colors hover:text-foreground`,children:[(0,F.jsx)(Ee,{className:`size-3 transition-transform duration-150 ${a?`rotate-180`:``}`}),a?`Collapse timeline`:`Show full timeline (${r} proposals)`]})]})})})}function eg(){let{name:e}=f(),[t,n]=i(),{data:r,isPending:a,isError:o,error:s,refetch:c}=qh(e),[u,d]=(0,M.useState)(!1),[p,m]=(0,M.useState)(!0),[h,g]=(0,M.useState)(`invocations`),[_,v]=(0,M.useState)(`all`),y=r?.evolution??[],b=new Set(y.map(e=>e.proposal_id)),x=t.get(`proposal`),S=x&&b.has(x)?x:y.length>0?y[0].proposal_id:null;(0,M.useEffect)(()=>{let e=t.get(`proposal`);if(S&&e!==S){let e=new URLSearchParams(t);e.set(`proposal`,S),n(e,{replace:!0});return}if(!S&&e){let e=new URLSearchParams(t);e.delete(`proposal`),n(e,{replace:!0})}},[S,t,n]),(0,M.useEffect)(()=>{typeof window>`u`||window.localStorage.getItem(Jh)===`1`&&m(!1)},[]);let C=e=>{let r=new URLSearchParams(t);r.set(`proposal`,e),n(r,{replace:!0})},w=()=>{m(!1),typeof window<`u`&&window.localStorage.setItem(Jh,`1`)},E=r?.trust,D=r?.coverage,O=r?.evidence_quality,k=r?.routing_quality,A=r?.evolution_state,ee=r?.data_hygiene,te=r?.examples,ne=ee?.raw_checks??D?.checks??r?.usage.total_checks??0,re=ee?.operational_checks??D?.checks??r?.usage.total_checks??0,ie=Math.max(ne-re,0),ae=(A?.evolution_rows??y.length)>0,se=ae?`evidence`:`invocations`;(0,M.useEffect)(()=>{g(se)},[se]);let ce=(0,M.useMemo)(()=>{let e=(r?.canonical_invocations??[]).map(e=>({timestamp:e.timestamp||e.occurred_at||null,session_id:e.session_id,triggered:e.triggered,query:e.query??``,source:e.source??``,invocation_mode:e.invocation_mode??null,confidence:e.confidence??null,tool_name:e.tool_name??null,agent_type:e.agent_type??null,observation_kind:e.observation_kind??`canonical`,historical_context:e.historical_context??null}));return e.sort((e,t)=>(t.timestamp??``).localeCompare(e.timestamp??``)),e},[r?.canonical_invocations]),le=(0,M.useMemo)(()=>{switch(_){case`misses`:return ce.filter(e=>!e.triggered);case`low_confidence`:return ce.filter(e=>e.confidence!==null&&e.confidence<.5);case`system_meta`:return ce.filter(e=>e.invocation_mode===`system`||e.invocation_mode===`meta`);default:return ce}},[ce,_]),ue=(0,M.useMemo)(()=>new Map((r?.session_metadata??[]).map(e=>[e.session_id,e])),[r?.session_metadata]),de=(0,M.useMemo)(()=>{let e=new Map;for(let t of le){let n=t.session_id??`unknown`,r=e.get(n);r?r.push(t):e.set(n,[t])}return[...e.entries()].sort(([,e],[,t])=>(t[0]?.timestamp??``).localeCompare(e[0]?.timestamp??``))},[le]);if(!e)return(0,F.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-16`,children:(0,F.jsx)(`p`,{className:`text-sm text-destructive`,children:`No skill name provided`})});if(a)return(0,F.jsxs)(`div`,{className:`@container/main flex flex-1 flex-col gap-6 p-4 lg:p-6`,children:[(0,F.jsx)(W,{className:`h-10 w-64`}),(0,F.jsx)(`div`,{className:`grid grid-cols-1 gap-4 @xl/main:grid-cols-2 @5xl/main:grid-cols-4`,children:Array.from({length:4}).map((e,t)=>(0,F.jsx)(W,{className:`h-28 rounded-2xl`},t))}),(0,F.jsx)(W,{className:`h-20 rounded-2xl`}),(0,F.jsx)(W,{className:`h-64 rounded-2xl`})]});if(o)return(0,F.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-4 py-16`,children:[(0,F.jsx)(Pe,{className:`size-10 text-destructive`}),(0,F.jsx)(`p`,{className:`text-sm font-medium text-destructive`,children:s instanceof Error?s.message:`Unknown error`}),(0,F.jsxs)(I,{variant:`outline`,size:`sm`,onClick:()=>c(),children:[(0,F.jsx)(j,{className:`mr-2 size-3.5`}),`Retry`]})]});if(!r)return(0,F.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-16`,children:(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No data yet`})});if((D?.checks??r.usage.total_checks)===0&&r.evidence.length===0&&r.evolution.length===0&&(r.canonical_invocations?.length??0)===0)return(0,F.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-4 py-16`,children:[(0,F.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No data found for skill "`,e,`".`]}),(0,F.jsxs)(I,{variant:`outline`,size:`sm`,render:(0,F.jsx)(l,{to:`/`}),children:[(0,F.jsx)(Re,{className:`mr-2 size-3.5`}),`Back to Overview`]})]});let fe=E?.state??`low_sample`,pe=Xh[fe],me=Qh(fe,k?.miss_rate,O?.system_like_rate,A?.has_pending_proposals??r.pending_proposals.length>0,ae);return(0,F.jsxs)(ct,{value:h,onValueChange:g,children:[(0,F.jsx)(Yh,{open:u,onOpenChange:d}),(0,F.jsxs)(`div`,{className:`@container/main flex flex-1 flex-col gap-5 p-4 lg:px-6 lg:pb-6 lg:pt-0`,children:[(0,F.jsxs)(`div`,{className:`sticky top-0 z-30 space-y-2 border-b border-border/15 bg-background/95 py-2.5 backdrop-blur supports-[backdrop-filter]:bg-background/85`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(I,{variant:`outline`,size:`sm`,render:(0,F.jsx)(l,{to:`/`}),className:`shrink-0`,children:(0,F.jsx)(Re,{className:`size-3.5`})}),(0,F.jsx)(`h1`,{className:`text-base font-semibold tracking-tight lg:text-lg font-headline shrink-0`,children:r.skill_name}),(0,F.jsxs)(P,{variant:pe.variant,className:`gap-1 shrink-0 text-[10px]`,children:[pe.icon,pe.label]}),(0,F.jsxs)(`div`,{className:`ml-auto flex items-center gap-4 shrink-0`,children:[(0,F.jsx)(I,{variant:`outline`,size:`sm`,onClick:()=>d(!0),children:`How this works`}),(0,F.jsxs)(`div`,{className:`hidden @xl/main:flex items-center gap-3 text-xs text-muted-foreground`,children:[(0,F.jsxs)(`span`,{className:`tabular-nums`,children:[(0,F.jsx)(`strong`,{className:`text-foreground`,children:D?.checks??r.usage.total_checks}),` `,`checks`]}),(0,F.jsx)(`span`,{className:`text-border`,children:`|`}),(0,F.jsxs)(`span`,{className:`tabular-nums`,children:[(0,F.jsx)(`strong`,{className:`text-foreground`,children:D?.sessions??r.sessions_with_skill}),` `,`sessions`]}),(0,F.jsx)(`span`,{className:`text-border`,children:`|`}),(0,F.jsxs)(`span`,{className:`tabular-nums`,children:[(0,F.jsx)(`strong`,{className:`text-foreground`,children:D?.workspaces??`No data`}),` `,`workspaces`]})]}),(D?.first_seen||D?.last_seen)&&(0,F.jsxs)(`div`,{className:`hidden @3xl/main:flex items-center gap-2 text-[10px] text-muted-foreground font-mono`,children:[D.first_seen&&(0,F.jsx)(`span`,{title:`First seen`,children:Gn(D.first_seen)}),D.first_seen&&D.last_seen&&(0,F.jsx)(`span`,{children:`-`}),D.last_seen&&(0,F.jsx)(`span`,{title:`Last seen`,children:Gn(D.last_seen)})]})]})]}),E?.summary&&(0,F.jsxs)(`div`,{className:`space-y-1.5 text-sm leading-relaxed text-muted-foreground`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,F.jsx)(`span`,{children:E.summary}),A?.latest_action&&A?.latest_timestamp&&(0,F.jsxs)(`span`,{className:`text-[11px] text-muted-foreground/70 font-mono`,children:[`Latest: `,A.latest_action,` (`,Gn(A.latest_timestamp),`)`]})]}),ie>0&&(0,F.jsxs)(`div`,{className:`text-[12px] text-muted-foreground/80`,children:[`Based on `,(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:re}),` `,`real checks. `,(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:ie}),` `,`internal or legacy rows are excluded from trust scoring.`]})]})]}),p&&(0,F.jsx)(L,{className:`rounded-xl border border-primary/15 bg-primary/5`,children:(0,F.jsxs)(B,{className:`flex flex-wrap items-center justify-between gap-3 px-4 py-3`,children:[(0,F.jsxs)(`div`,{className:`text-sm text-muted-foreground`,children:[(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:`New to selftune?`}),` Start with the summary below, then open the guide if you want the full improvement loop explained step by step.`]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(I,{variant:`outline`,size:`sm`,onClick:()=>d(!0),children:`Open guide`}),(0,F.jsx)(I,{variant:`ghost`,size:`sm`,onClick:w,children:`Hide`})]})]})}),(0,F.jsxs)(`div`,{className:`space-y-4`,children:[(0,F.jsx)(Lh,{nextAction:me,latestDecision:ae&&A?.latest_action?{action:A.latest_action,timestamp:A.latest_timestamp,evolutionCount:A.evolution_rows??y.length}:void 0}),(0,F.jsx)(Hh,{trustState:fe,coverage:D,evidenceQuality:O,routingQuality:k,evolutionState:A,dataHygiene:ee,fallbackChecks:r.usage.total_checks,fallbackSessions:r.sessions_with_skill,nextActionText:me.text,onOpenGuide:()=>d(!0)}),(0,F.jsx)(Uh,{coverage:D,evidenceQuality:O,routingQuality:k,evolutionState:A,fallbackChecks:r.usage.total_checks,fallbackSessions:r.sessions_with_skill,fallbackEvidenceRows:r.evidence.length,fallbackEvolutionRows:y.length,fallbackLatestAction:y[0]?.action})]}),(0,F.jsxs)(`div`,{className:`space-y-4 border-t border-border/10 pt-4`,children:[(0,F.jsxs)(ut,{variant:`line`,className:`rounded-xl border border-border/10 bg-muted/20 px-1.5 py-1`,children:[ae&&(0,F.jsxs)(mt,{children:[(0,F.jsx)(ht,{render:(0,F.jsx)(dt,{value:`evidence`,className:`rounded-lg px-3 font-headline text-xs uppercase tracking-wider data-active:bg-background/70 data-active:text-foreground`}),children:`Evidence`}),(0,F.jsx)(gt,{children:`Change history and validation results`})]}),(0,F.jsxs)(mt,{children:[(0,F.jsxs)(ht,{render:(0,F.jsx)(dt,{value:`invocations`,className:`rounded-lg px-3 font-headline text-xs uppercase tracking-wider data-active:bg-background/70 data-active:text-foreground`}),children:[`Invocations`,(0,F.jsx)(P,{variant:`secondary`,className:`ml-1.5 text-[10px]`,children:ce.length})]}),(0,F.jsx)(gt,{children:`Real usage and repaired misses only. Internal selftune traffic and legacy residue are excluded from this working set.`})]}),(0,F.jsxs)(mt,{children:[(0,F.jsx)(ht,{render:(0,F.jsx)(dt,{value:`data-quality`,className:`rounded-lg px-3 font-headline text-xs uppercase tracking-wider data-active:bg-background/70 data-active:text-foreground`}),children:`Data Quality`}),(0,F.jsx)(gt,{children:`Evidence quality metrics and data hygiene`})]})]}),ae&&(0,F.jsxs)(ft,{value:`evidence`,className:`space-y-6`,children:[(0,F.jsx)(Wh,{examples:te}),(0,F.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/15 bg-card`,children:(0,F.jsxs)(`div`,{className:`flex flex-col @5xl/main:grid @5xl/main:grid-cols-[252px_minmax(0,1fr)] @5xl/main:items-start`,children:[y.length>0&&(0,F.jsx)($h,{evolution:y,activeProposal:S,onSelect:C}),(0,F.jsx)(`div`,{className:`min-w-0 p-4 @xl/main:p-5`,children:S?(0,F.jsx)(gh,{proposalId:S,evolution:y,evidence:r.evidence,showContextBanner:!1}):(0,F.jsx)(L,{className:`rounded-2xl`,children:(0,F.jsx)(B,{className:`py-12`,children:(0,F.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 text-center`,children:[(0,F.jsx)(oe,{className:`size-8 text-muted-foreground/40`}),(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This skill is being observed but has no reviewable evolution evidence yet.`})]})})})})]})})]}),(0,F.jsx)(ft,{value:`invocations`,children:ce.length===0?(0,F.jsx)(L,{className:`rounded-2xl`,children:(0,F.jsx)(B,{className:`py-12`,children:(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground text-center`,children:`No invocation records yet.`})})}):(0,F.jsxs)(`div`,{className:`space-y-2`,children:[ie>0&&(0,F.jsxs)(`div`,{className:`rounded-xl border border-border/10 bg-muted/20 px-4 py-3 text-sm text-muted-foreground`,children:[`Showing`,` `,(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:ce.length}),` `,`operational invocations.`,` `,(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:ie}),` internal or legacy rows are tracked in Data Quality instead of being mixed into this working set.`]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(T,{className:`size-3.5 text-muted-foreground`}),[[`all`,`All`],[`misses`,`Misses`],[`low_confidence`,`Low confidence`],[`system_meta`,`System/meta`]].map(([e,t])=>(0,F.jsx)(`button`,{type:`button`,onClick:()=>v(e),className:`inline-block`,children:(0,F.jsx)(P,{variant:_===e?`default`:`outline`,className:`text-[10px] cursor-pointer`,children:t})},e))]}),(0,F.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[le.length,` invocations across `,de.length,` `,`sessions`]})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-muted-foreground`,children:[(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/70`}),`explicit = user typed /skill`]}),(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/70`}),`implicit = mentioned by name`]}),(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/70`}),`inferred = agent chose autonomously`]}),(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`size-1.5 rounded-full bg-destructive/70`}),`repaired miss = transcript showed skill read without invocation`]})]}),de.length===0?(0,F.jsx)(`div`,{className:`flex items-center justify-center py-8 text-sm text-muted-foreground`,children:`No invocations match this filter.`}):de.map(([e,t],n)=>(0,F.jsx)(Zh,{sessionId:e,meta:ue.get(e),invocations:t,defaultExpanded:n<3},e))]})}),(0,F.jsx)(ft,{value:`data-quality`,children:(0,F.jsx)(Gh,{evidenceQuality:O,dataHygiene:ee})})]})]})]})}var tg=[{key:`ALL`,label:`All Skills`},{key:`HEALTHY`,label:`Healthy`},{key:`WARNING`,label:`Warning`},{key:`CRITICAL`,label:`Critical`},{key:`UNGRADED`,label:`Ungraded`}],ng={HEALTHY:{text:`text-primary`,bg:`bg-primary`,label:`Deployed`},WARNING:{text:`text-primary-accent`,bg:`bg-primary-accent`,label:`Needs Attention`},CRITICAL:{text:`text-destructive`,bg:`bg-destructive`,label:`Critical`},UNGRADED:{text:`text-muted-foreground`,bg:`bg-muted-foreground`,label:`Ungraded`},UNKNOWN:{text:`text-muted-foreground`,bg:`bg-muted-foreground`,label:`Unknown`}};function rg(e){return e===null?0:Math.round(e*100)}function ig(e){return Wn(e.map(e=>({name:e.skill_name,scope:e.skill_scope,passRate:e.total_checks>0?e.pass_rate:null,checks:e.total_checks,status:Hn(e.pass_rate,e.total_checks),uniqueSessions:e.unique_sessions,triggeredCount:e.triggered_count,lastSeen:e.last_seen})))}function ag(e){let t=e.filter(e=>e.total_checks>=5);if(t.length===0)return null;let n=t.reduce((e,t)=>e+t.total_checks,0),r=t.reduce((e,t)=>e+Math.round(t.pass_rate*t.total_checks),0);return n>0?r/n:null}function og(e,t){let n=[...t].filter(e=>e.skill_name).sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime());for(let t of n){let n=e.find(e=>e.skill_name===t.skill_name);if(n)return{skill:n,latestEvolution:t}}return e.length>0?{skill:[...e].sort((e,t)=>t.total_checks-e.total_checks)[0],latestEvolution:n[0]??null}:null}function sg(e){if(!e)return`never`;let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function cg(){return(0,F.jsxs)(`div`,{className:`flex flex-1 flex-col gap-8 p-6 md:p-10 animate-in fade-in duration-500`,children:[(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(W,{className:`h-12 w-64`}),(0,F.jsx)(W,{className:`h-5 w-96`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-12 gap-6`,children:[(0,F.jsx)(W,{className:`col-span-8 h-72 rounded-xl`}),(0,F.jsxs)(`div`,{className:`col-span-4 flex flex-col gap-6`,children:[(0,F.jsx)(W,{className:`h-32 rounded-xl`}),(0,F.jsx)(W,{className:`h-32 rounded-xl`})]})]}),(0,F.jsx)(`div`,{className:`grid grid-cols-3 gap-6`,children:Array.from({length:6}).map((e,t)=>(0,F.jsx)(W,{className:`h-52 rounded-xl`},`skel-${t}`))})]})}function lg({skill:e,latestEvolution:t}){let n=Hn(e.pass_rate,e.total_checks);return(0,F.jsxs)(L,{className:`col-span-12 lg:col-span-8 rounded-3xl border border-border/15 p-8 relative overflow-hidden flex flex-col`,children:[(0,F.jsx)(`div`,{className:`absolute top-0 left-0 w-full h-1 bg-input`,children:(0,F.jsx)(`div`,{className:`h-full bg-primary shadow-[0_0_15px_rgba(79,242,255,0.6)] transition-all duration-700`,style:{width:`${rg(e.total_checks>0?e.pass_rate:null)}%`}})}),(0,F.jsxs)(`div`,{className:`flex justify-between items-start mb-6`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,F.jsx)(`span`,{className:`px-2 py-0.5 rounded text-[10px] font-bold bg-primary/10 text-primary uppercase tracking-widest`,children:n===`HEALTHY`?`Deployed`:`Evolving`}),(0,F.jsxs)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:[e.skill_scope??`global`,` scope`]})]}),(0,F.jsx)(`h2`,{className:`font-headline text-3xl font-bold text-foreground`,children:e.skill_name})]}),(0,F.jsxs)(`div`,{className:`text-right`,children:[(0,F.jsx)(`span`,{className:`text-4xl font-headline font-light text-primary`,children:Un(e.total_checks>0?e.pass_rate:null)}),(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground uppercase tracking-widest mt-1`,children:t?`Evolved ${sg(t.timestamp)}`:`Pass Rate`})]})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-3 gap-8 mb-8`,children:[(0,F.jsxs)(`div`,{className:`bg-muted p-4 rounded-2xl border border-border/15`,children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground uppercase tracking-widest mb-1`,children:`Total Checks`}),(0,F.jsx)(`p`,{className:`text-xl font-bold font-headline tabular-nums`,children:e.total_checks.toLocaleString()})]}),(0,F.jsxs)(`div`,{className:`bg-muted p-4 rounded-2xl border border-border/15`,children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground uppercase tracking-widest mb-1`,children:`Pass Rate`}),(0,F.jsx)(`p`,{className:`text-xl font-bold font-headline tabular-nums ${ng[n].text}`,children:Un(e.total_checks>0?e.pass_rate:null)})]}),(0,F.jsxs)(`div`,{className:`bg-muted p-4 rounded-2xl border border-border/15`,children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground uppercase tracking-widest mb-1`,children:`Unique Sessions`}),(0,F.jsx)(`p`,{className:`text-xl font-bold font-headline tabular-nums`,children:e.unique_sessions.toLocaleString()})]})]}),(0,F.jsxs)(`div`,{className:`flex justify-end gap-4`,children:[(0,F.jsx)(l,{to:`/skills/${encodeURIComponent(e.skill_name)}`,className:`px-6 py-2 rounded-xl text-muted-foreground font-bold hover:bg-input transition-colors`,children:`Configure`}),(0,F.jsx)(l,{to:`/skills/${encodeURIComponent(e.skill_name)}`,className:`px-8 py-2 bg-primary text-primary-foreground font-bold rounded-xl shadow-[0_4px_20px_rgba(79,242,255,0.2)] hover:shadow-[0_4px_25px_rgba(79,242,255,0.4)] transition-all`,children:`View Report`})]})]})}function ug({skills:e}){let t=ag(e),n=e.filter(e=>e.total_checks>=5).length;return(0,F.jsxs)(L,{className:`rounded-3xl border border-border/15 p-6 flex flex-col justify-center`,children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground uppercase tracking-widest mb-4`,children:`Library Health`}),(0,F.jsx)(`div`,{className:`flex items-end gap-2 mb-2`,children:(0,F.jsx)(`span`,{className:`text-5xl font-headline font-bold tabular-nums`,children:t===null?`--`:`${Math.round(t*100)}%`})}),(0,F.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Aggregate pass rate across `,n,` graded skill`,n===1?``:`s`,`.`]})]})}function dg({proposals:e}){return e.length===0?(0,F.jsxs)(L,{className:`rounded-3xl p-6 flex flex-col gap-3 border border-border/15 border-l-4 border-l-primary/40`,children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground uppercase tracking-widest mb-2`,children:`Pending Proposals`}),(0,F.jsx)(`h3`,{className:`font-headline font-bold text-lg`,children:`No proposals pending`})]}):(0,F.jsxs)(L,{className:`rounded-3xl p-6 flex flex-col gap-3 border border-border/15 border-l-4 border-l-primary/40`,children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground uppercase tracking-widest mb-2`,children:`Pending Proposals`}),(0,F.jsxs)(`h3`,{className:`font-headline font-bold text-lg mb-4`,children:[`Awaiting Review`,(0,F.jsx)(P,{variant:`secondary`,className:`ml-2 h-5 px-2 text-[10px] bg-primary/15 text-primary border-none align-middle`,children:e.length})]}),(0,F.jsx)(`div`,{className:`space-y-3 max-h-32 overflow-y-auto themed-scroll`,children:e.map(e=>(0,F.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-muted rounded-xl`,children:[(0,F.jsx)(`span`,{className:`text-sm truncate`,children:e.skill_name??`Unknown`}),(0,F.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:e.action})]},e.proposal_id))})]})}function fg({skill:e}){let t=rg(e.passRate),n=ng[e.status];return(0,F.jsxs)(L,{className:`border border-border/15 p-6 hover:border-border/30 transition-all duration-300 flex flex-col`,children:[(0,F.jsxs)(`div`,{className:`flex justify-between items-start mb-4`,children:[(0,F.jsx)(`div`,{className:`w-12 h-12 rounded-xl bg-muted flex items-center justify-center`,children:(0,F.jsx)(`span`,{className:`size-3 rounded-full ${n.bg}`})}),(0,F.jsxs)(`div`,{className:`text-right`,children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground uppercase tracking-widest`,children:e.scope??`unknown`}),(0,F.jsx)(`p`,{className:`text-sm font-bold tabular-nums`,children:e.checks.toLocaleString()})]})]}),(0,F.jsx)(`h3`,{className:`font-headline font-bold text-xl tracking-tight text-foreground truncate mb-1`,children:e.name}),(0,F.jsxs)(`p`,{className:`text-sm text-muted-foreground mb-6`,children:[e.uniqueSessions,` sessions · Last seen `,sg(e.lastSeen)]}),(0,F.jsxs)(`div`,{className:`space-y-4`,children:[(0,F.jsxs)(`div`,{className:`flex justify-between items-end text-xs uppercase tracking-tighter`,children:[(0,F.jsx)(`span`,{className:`text-muted-foreground`,children:`Pass Rate`}),(0,F.jsx)(`span`,{className:`font-bold ${n.text}`,children:n.label})]}),(0,F.jsx)(`div`,{className:`w-full h-1 bg-input rounded-full overflow-hidden`,children:(0,F.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500 ${n.bg}`,style:{width:`${t}%`}})}),(0,F.jsxs)(`div`,{className:`pt-4 flex gap-3`,children:[(0,F.jsx)(l,{to:`/skills/${encodeURIComponent(e.name)}`,className:`flex-1 py-2 text-xs font-bold text-muted-foreground bg-muted rounded-lg text-center hover:bg-input transition-colors`,children:`Configure`}),(0,F.jsx)(l,{to:`/skills/${encodeURIComponent(e.name)}`,className:`flex-1 py-2 text-xs font-bold text-muted-foreground bg-secondary rounded-lg text-center hover:bg-input hover:text-foreground transition-all`,children:`View Report`})]})]})]})}function pg({overviewQuery:e}){let{data:t,isLoading:n,isError:r,error:i,refetch:a}=e,[o,s]=(0,M.useState)(`ALL`),[c,l]=(0,M.useState)(!0),u=(0,M.useMemo)(()=>t?ig(t.skills):[],[t]),d=(0,M.useMemo)(()=>{let e=u;return o!==`ALL`&&(e=e.filter(e=>e.status===o)),c?e.reduceRight((e,t)=>(e.push(t),e),[]):e},[u,o,c]),f=(0,M.useMemo)(()=>t?og(t.skills,t.overview.evolution):null,[t]);if(n)return(0,F.jsx)(cg,{});if(r)return(0,F.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-4 py-16`,children:[(0,F.jsx)(Pe,{className:`size-10 text-destructive`}),(0,F.jsx)(`p`,{className:`text-sm font-medium text-destructive`,children:i instanceof Error?i.message:`Failed to load skills library.`}),(0,F.jsxs)(I,{variant:`outline`,size:`sm`,onClick:()=>a(),children:[(0,F.jsx)(j,{className:`mr-2 size-3.5`}),`Retry`]})]});if(!t)return(0,F.jsx)(cg,{});let p=t.overview.pending_proposals;return(0,F.jsxs)(`div`,{className:`@container/main flex flex-1 flex-col gap-8 py-8 px-4 lg:px-6 animate-in fade-in duration-500`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h1`,{className:`font-headline text-4xl font-bold tracking-tight text-foreground`,children:`Skills Library`}),(0,F.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground max-w-2xl`,children:`Monitor and manage your evolving skill definitions across all scopes.`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-12 gap-6`,children:[f?(0,F.jsx)(lg,{skill:f.skill,latestEvolution:f.latestEvolution}):(0,F.jsx)(L,{className:`col-span-12 lg:col-span-8 border border-border/15 p-8 flex items-center justify-center`,children:(0,F.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,F.jsx)(Ue,{className:`size-10 text-muted-foreground mx-auto`}),(0,F.jsx)(`p`,{className:`text-muted-foreground`,children:`No evolution activity yet. Run an evolution cycle to see your most active skill.`})]})}),(0,F.jsxs)(`div`,{className:`col-span-12 lg:col-span-4 flex flex-col gap-6`,children:[(0,F.jsx)(ug,{skills:t.skills}),(0,F.jsx)(dg,{proposals:p})]})]}),(0,F.jsxs)(`div`,{className:`space-y-6`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-4 flex-wrap`,children:[(0,F.jsx)(`div`,{className:`flex gap-1 bg-muted rounded-xl p-1`,children:tg.map(e=>{let t=e.key===`ALL`?u.length:u.filter(t=>t.status===e.key).length;return(0,F.jsxs)(`button`,{type:`button`,onClick:()=>s(e.key),className:`px-4 py-2 rounded-lg text-sm font-headline font-semibold transition-all duration-200 ${o===e.key?`bg-card text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,children:[e.label,(0,F.jsx)(`span`,{className:`ml-1.5 text-xs opacity-60`,children:t})]},e.key)})}),(0,F.jsxs)(mt,{children:[(0,F.jsxs)(ht,{render:(0,F.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),className:`flex items-center gap-2 px-3 py-2 text-sm text-muted-foreground hover:text-foreground transition-colors font-headline`}),children:[(0,F.jsx)(_e,{className:`size-4`}),(0,F.jsx)(`span`,{children:`Sort by Performance`})]}),(0,F.jsx)(gt,{children:c?`Highest pass rate first`:`Lowest pass rate first`})]})]}),d.length>0?(0,F.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-6`,children:d.map(e=>(0,F.jsx)(fg,{skill:e},e.name))}):(0,F.jsxs)(L,{className:`border border-border/15 p-12 text-center`,children:[(0,F.jsx)(ve,{className:`size-8 text-muted-foreground mx-auto mb-3`}),(0,F.jsx)(`p`,{className:`text-muted-foreground font-headline`,children:`No skills match the current filter`})]})]})]})}var mg=6e4;function hg(){return Vn({queryKey:[`doctor`],queryFn:Ls,staleTime:5e3,refetchInterval:mg})}var gg={pass:{color:`text-primary`,label:`Pass`,dotColor:`bg-primary`,dotGlow:`shadow-[0_0_8px_rgba(79,242,255,0.6)]`,animate:!0},warn:{color:`text-amber-400`,label:`Warn`,dotColor:`bg-amber-400`,dotGlow:``,animate:!1},fail:{color:`text-destructive`,label:`Fail`,dotColor:`bg-destructive`,dotGlow:`shadow-[0_0_8px_rgba(255,180,171,0.6)]`,animate:!1}},_g={config:{label:`Configuration`,description:`selftune.json exists and contains valid agent_type and llm_mode`,icon:(0,F.jsx)(x,{className:`size-4`})},log_session_telemetry:{label:`Session Telemetry Log`,description:`session_telemetry_log.jsonl exists and records parse correctly`,icon:(0,F.jsx)(se,{className:`size-4`})},log_skill_usage:{label:`Skill Usage Log`,description:`skill_usage_log.jsonl exists and records parse correctly`,icon:(0,F.jsx)(se,{className:`size-4`})},log_all_queries:{label:`Query Log`,description:`all_queries_log.jsonl exists and records parse correctly`,icon:(0,F.jsx)(se,{className:`size-4`})},log_evolution_audit:{label:`Evolution Audit Log`,description:`evolution_audit_log.jsonl exists and records parse correctly`,icon:(0,F.jsx)(se,{className:`size-4`})},hook_settings:{label:`Hook Installation`,description:`Claude Code settings.json has all required selftune hooks configured`,icon:(0,F.jsx)(Qe,{className:`size-4`})},evolution_audit:{label:`Evolution Health`,description:`Evolution audit log is intact and records are well-formed`,icon:(0,F.jsx)(k,{className:`size-4`})},dashboard_freshness_mode:{label:`Dashboard Freshness`,description:`The current dashboard still invalidates live updates from JSONL log watchers. SQLite WAL live invalidation has not been cut over yet.`,icon:(0,F.jsx)(E,{className:`size-4`})}};function vg(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.workspace_root==`string`&&typeof t.git_sha==`string`&&typeof t.db_path==`string`&&typeof t.process_mode==`string`&&(t.watcher_mode===`wal`||t.watcher_mode===`jsonl`||t.watcher_mode===`none`)}function yg({refreshKey:e}){let[t,n]=(0,M.useState)(null);if((0,M.useEffect)(()=>{fetch(`/api/health`).then(e=>e.json()).then(e=>{vg(e)&&n(e)}).catch(()=>{})},[e]),!t)return null;let r=t.watcher_mode===`jsonl`?{className:`border-amber-400/25 bg-amber-400/10 text-amber-400`,label:`Legacy watcher path active`}:t.watcher_mode===`none`?{className:`border-muted-foreground/20 bg-muted/40 text-muted-foreground`,label:`Watcher inactive`}:{className:`border-primary/25 bg-primary/10 text-primary`,label:`Live invalidation active`};return(0,F.jsxs)(`section`,{className:`glass-panel rounded-2xl border border-border/15 p-6`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col gap-2 md:flex-row md:items-end md:justify-between`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`text-[10px] font-headline uppercase tracking-[0.2em] text-muted-foreground`,children:`Runtime Environment`}),(0,F.jsx)(`h2`,{className:`mt-1 font-headline text-xl font-semibold text-foreground`,children:`Active dashboard runtime`})]}),(0,F.jsx)(P,{variant:`outline`,className:r.className,children:r.label})]}),(0,F.jsxs)(`div`,{className:`mt-5 grid gap-3 md:grid-cols-2 xl:grid-cols-4`,children:[(0,F.jsxs)(`div`,{className:`rounded-xl border border-border/10 bg-background/35 p-4`,children:[(0,F.jsx)(`p`,{className:`text-[10px] font-headline uppercase tracking-[0.18em] text-muted-foreground`,children:`Process mode`}),(0,F.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-foreground`,children:t.process_mode})]}),(0,F.jsxs)(`div`,{className:`rounded-xl border border-border/10 bg-background/35 p-4`,children:[(0,F.jsx)(`p`,{className:`text-[10px] font-headline uppercase tracking-[0.18em] text-muted-foreground`,children:`Watcher mode`}),(0,F.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-foreground`,children:t.watcher_mode})]}),(0,F.jsxs)(`div`,{className:`rounded-xl border border-border/10 bg-background/35 p-4`,children:[(0,F.jsx)(`p`,{className:`text-[10px] font-headline uppercase tracking-[0.18em] text-muted-foreground`,children:`Git SHA`}),(0,F.jsx)(`p`,{className:`mt-2 truncate font-mono text-sm text-foreground`,children:t.git_sha})]}),(0,F.jsxs)(`div`,{className:`rounded-xl border border-border/10 bg-background/35 p-4`,children:[(0,F.jsx)(`p`,{className:`text-[10px] font-headline uppercase tracking-[0.18em] text-muted-foreground`,children:`Database path`}),(0,F.jsx)(`p`,{className:`mt-2 truncate font-mono text-sm text-foreground`,children:t.db_path})]})]}),(0,F.jsxs)(`div`,{className:`mt-3 rounded-xl border border-border/10 bg-background/35 p-4`,children:[(0,F.jsx)(`p`,{className:`text-[10px] font-headline uppercase tracking-[0.18em] text-muted-foreground`,children:`Workspace root`}),(0,F.jsx)(`p`,{className:`mt-2 break-all font-mono text-sm text-foreground`,children:t.workspace_root})]})]})}function bg({check:e}){let t=_g[e.name]??{label:e.name,description:``,icon:(0,F.jsx)(E,{className:`size-4`})},n=gg[e.status]??{color:`text-muted-foreground`,label:e.status,dotColor:`bg-muted-foreground`,dotGlow:``,animate:!1};return(0,F.jsxs)(`div`,{className:`group flex items-start gap-4 px-6 py-4 border-b border-border/10 last:border-b-0 hover:bg-secondary/40 transition-colors`,children:[(0,F.jsx)(`div`,{className:`mt-1.5 flex-shrink-0`,children:(0,F.jsx)(`span`,{className:`block size-1.5 rounded-full ${n.dotColor} ${n.dotGlow} ${n.animate?`animate-pulse`:``}`})}),(0,F.jsx)(`div`,{className:`flex-shrink-0 mt-0.5 text-muted-foreground`,children:t.icon}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`text-sm font-semibold text-foreground`,children:t.label}),t.description&&(0,F.jsx)(Ah,{text:t.description})]}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 leading-relaxed`,children:e.message||`No details`}),e.path&&(0,F.jsx)(`p`,{className:`text-[11px] text-muted-foreground/60 font-mono mt-1 truncate`,children:e.path})]}),(0,F.jsx)(`div`,{className:`flex-shrink-0`,children:(0,F.jsxs)(`div`,{className:`inline-flex items-center gap-2 px-2 py-1 rounded-md ${e.status===`pass`?`bg-primary/10`:e.status===`fail`?`bg-destructive/10`:`bg-amber-400/10`}`,children:[(0,F.jsx)(`span`,{className:`size-1.5 rounded-full ${n.dotColor} ${n.animate?`animate-pulse`:``}`}),(0,F.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-tighter font-headline ${n.color}`,children:n.label})]})})]})}function xg(){let{data:e,isPending:t,isError:n,error:r,refetch:i}=hg(),[a,o]=(0,M.useState)(0);if(t)return(0,F.jsxs)(`div`,{className:`flex flex-1 flex-col gap-8 p-8`,children:[(0,F.jsx)(W,{className:`h-12 w-64`}),(0,F.jsx)(W,{className:`h-24 rounded-xl`}),(0,F.jsx)(W,{className:`h-[400px] rounded-xl`})]});if(n)return(0,F.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-4 py-16`,children:[(0,F.jsx)(Pe,{className:`size-10 text-destructive`}),(0,F.jsx)(`p`,{className:`text-sm font-medium text-destructive`,children:r instanceof Error?r.message:`Unknown error`}),(0,F.jsxs)(I,{variant:`outline`,size:`sm`,onClick:()=>i(),children:[(0,F.jsx)(j,{className:`mr-2 size-3.5`}),`Retry`]})]});if(!e)return(0,F.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-16`,children:(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No diagnostics data available.`})});let{checks:s,summary:c,healthy:l=!1,timestamp:u}=e,d=s??[],f=c??{pass:0,warn:0,fail:0},p=f.pass+f.warn+f.fail,m=d.filter(e=>e.name===`config`),h=d.filter(e=>e.name.startsWith(`log_`)),g=d.filter(e=>e.name===`hook_settings`),_=d.filter(e=>e.name===`evolution_audit`),v=d.filter(e=>e.name===`dashboard_freshness_mode`),y=new Set([`config`,...h.map(e=>e.name),`hook_settings`,`evolution_audit`,`dashboard_freshness_mode`]),b=d.filter(e=>!y.has(e.name)),x=[{title:`Configuration`,checks:m},{title:`Log Files`,checks:h},{title:`Hooks`,checks:g},{title:`Evolution`,checks:_},{title:`Integrity`,checks:v},{title:`Other`,checks:b}].filter(e=>e.checks.length>0);return(0,F.jsxs)(`div`,{className:`flex flex-1 flex-col gap-8 p-8 max-w-5xl mx-auto w-full`,children:[(0,F.jsxs)(`section`,{className:`flex flex-col md:flex-row md:items-end justify-between gap-4`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h1`,{className:`font-headline text-4xl font-bold tracking-tight text-foreground`,children:`System Status`}),(0,F.jsx)(`p`,{className:`text-muted-foreground max-w-md mt-1`,children:`Diagnostics and health checks for selftune infrastructure.`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsxs)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-widest font-headline`,children:[`Last checked `,u?Gn(u):`—`]}),(0,F.jsx)(I,{"aria-label":`Refresh status`,variant:`ghost`,size:`sm`,onClick:()=>{o(e=>e+1),i()},className:`shrink-0`,children:(0,F.jsx)(j,{className:`size-3.5`})})]})]}),(0,F.jsxs)(`div`,{className:`glass-panel rounded-2xl border border-border/15 p-6 flex items-center justify-between overflow-hidden relative`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-8`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col`,children:[(0,F.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-[0.2em] font-headline mb-1`,children:`Overall`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l?(0,F.jsx)(`span`,{className:`size-3 rounded-full bg-primary animate-pulse shadow-[0_0_12px_rgba(79,242,255,0.6)]`}):(0,F.jsx)(`span`,{className:`size-3 rounded-full bg-destructive shadow-[0_0_12px_rgba(255,180,171,0.6)]`}),(0,F.jsx)(`span`,{className:`font-headline text-2xl font-bold text-foreground`,children:l?`Healthy`:`Unhealthy`})]})]}),(0,F.jsx)(`div`,{className:`h-10 w-px bg-border/20`}),(0,F.jsxs)(`div`,{className:`flex flex-col`,children:[(0,F.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-[0.2em] font-headline mb-1`,children:`Passed`}),(0,F.jsx)(`span`,{className:`font-headline text-2xl font-bold text-primary`,children:f.pass})]}),(0,F.jsxs)(`div`,{className:`flex flex-col`,children:[(0,F.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-[0.2em] font-headline mb-1`,children:`Warnings`}),(0,F.jsx)(`span`,{className:`font-headline text-2xl font-bold ${f.warn>0?`text-amber-400`:`text-foreground`}`,children:f.warn})]}),(0,F.jsxs)(`div`,{className:`flex flex-col`,children:[(0,F.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-[0.2em] font-headline mb-1`,children:`Failed`}),(0,F.jsx)(`span`,{className:`font-headline text-2xl font-bold ${f.fail>0?`text-destructive`:`text-foreground`}`,children:f.fail})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsxs)(`div`,{className:`text-right`,children:[(0,F.jsxs)(`p`,{className:`text-xs font-bold text-foreground font-headline`,children:[p,` Checks`]}),(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:f.pass===p?`All checks passing`:`${f.fail+f.warn} issue${f.fail+f.warn===1?``:`s`} detected`})]}),(0,F.jsx)(`div`,{className:`size-12 rounded-full flex items-center justify-center border-4 border-primary/20 border-t-primary`,children:(0,F.jsx)(S,{className:`size-5 text-primary`})})]}),(0,F.jsx)(`div`,{className:`absolute -right-20 -bottom-20 w-64 h-64 bg-primary/5 blur-3xl rounded-full pointer-events-none`})]}),(0,F.jsx)(yg,{refreshKey:a}),(0,F.jsx)(`div`,{className:`bg-muted rounded-2xl border border-border/15 overflow-hidden`,children:x.map((e,t)=>(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`px-6 py-3 bg-secondary/60 border-b border-border/15`,children:[(0,F.jsx)(`span`,{className:`text-[10px] font-bold text-muted-foreground uppercase tracking-[0.2em] font-headline`,children:e.title}),(0,F.jsx)(P,{variant:`outline`,className:`ml-3 text-[10px] px-1.5 py-0 border-border/40 text-muted-foreground`,children:e.checks.length})]}),e.checks.map((e,t)=>(0,F.jsx)(bg,{check:e},`${e.name}-${t}`)),t<x.length-1&&(0,F.jsx)(`div`,{className:`border-b border-border/25`})]},e.title))})]})}var Sg=new wn({defaultOptions:{queries:{refetchOnWindowFocus:!0,gcTime:300*1e3}}});function Cg(){qs();let[e,t]=(0,M.useState)(`ALL`),n=Bs(),{data:r}=n;return(0,F.jsxs)(lr,{children:[(0,F.jsx)(_r,{version:r?.version}),(0,F.jsxs)(fr,{children:[(0,F.jsx)(Us,{}),(0,F.jsxs)(s,{children:[(0,F.jsx)(d,{path:`/`,element:(0,F.jsx)(mc,{search:``,statusFilter:e,onStatusFilterChange:t,overviewQuery:n})}),(0,F.jsx)(d,{path:`/skills-library`,element:(0,F.jsx)(pg,{overviewQuery:n})}),(0,F.jsx)(d,{path:`/analytics`,element:(0,F.jsx)(bc,{})}),(0,F.jsx)(d,{path:`/skills/:name`,element:(0,F.jsx)(eg,{})}),(0,F.jsx)(d,{path:`/status`,element:(0,F.jsx)(xg,{})})]})]}),(0,F.jsx)(yr,{})]})}function wg(){return(0,F.jsx)(Dn,{client:Sg,children:(0,F.jsx)(p,{children:(0,F.jsx)(Ks,{defaultTheme:`dark`,children:(0,F.jsxs)(pt,{children:[(0,F.jsx)(Cg,{}),!1]})})})})}(0,$e.createRoot)(document.getElementById(`root`)).render((0,F.jsx)(M.StrictMode,{children:(0,F.jsx)(wg,{})}));
|
|
60
|
+
`)}}function oh({meta:e}){let t=Object.entries(e);return t.length===0?null:(0,F.jsx)(`div`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs`,children:t.map(([e,t])=>(0,F.jsxs)(`div`,{className:`contents`,children:[(0,F.jsx)(`span`,{className:`font-medium text-muted-foreground capitalize`,children:e}),(0,F.jsx)(`span`,{className:`text-foreground truncate`,children:t})]},e))})}function sh({label:e,text:t,variant:n}){let{meta:r,body:i}=ah(t),a=Object.keys(r).length>0;return(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(se,{className:`size-3.5 text-muted-foreground`}),(0,F.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:e}),n===`proposed`&&(0,F.jsx)(P,{variant:`secondary`,className:`text-[10px]`,children:`New`})]}),a&&(0,F.jsx)(`div`,{className:`rounded-md border bg-muted/30 p-3`,children:(0,F.jsx)(oh,{meta:r})}),(0,F.jsx)(`div`,{className:`skill-markdown rounded-md border bg-card p-4`,children:(0,F.jsx)(Xm,{children:i})})]})}function ch(e,t){if(typeof t==`boolean`)return t?(0,F.jsx)(Ge,{className:`size-3.5 text-emerald-500 inline`}):(0,F.jsx)(h,{className:`size-3.5 text-red-500 inline`});if(typeof t==`number`){if(e.includes(`rate`)||e.includes(`change`)||t>=-1&&t<=1&&e!==`count`){let n=(t*100).toFixed(1);return(0,F.jsxs)(`span`,{className:`font-mono`,children:[t>0&&e.includes(`change`)?`+`:``,n,`%`]})}return(0,F.jsx)(`span`,{className:`font-mono`,children:t})}return t==null?(0,F.jsx)(`span`,{className:`text-muted-foreground`,children:`--`}):typeof t==`string`?(0,F.jsx)(`span`,{children:t}):Array.isArray(t)?t.length===0?(0,F.jsx)(`span`,{className:`text-muted-foreground italic`,children:`none`}):(0,F.jsxs)(`span`,{className:`font-mono`,children:[t.length,` entries`]}):typeof t==`object`?(0,F.jsx)(`span`,{className:`font-mono`,children:`1 entry`}):(0,F.jsx)(`span`,{children:String(t)})}function lh({entry:e}){let t=e.entry,n=t?.query??e.query??e.prompt??e.input??e.text,r=t?.should_trigger??e.should_trigger,i=t?.invocation_type??e.invocation_type,a=e.before_pass??e.before??e.original_triggered??e.baseline,o=e.after_pass??e.after??e.triggered??e.result,s=e.passed??e.matched,c=typeof o==`boolean`?o:typeof s==`boolean`?s:null;return(0,F.jsxs)(`div`,{className:`flex items-start gap-2 text-xs py-1.5 border-b border-border/50 last:border-0`,children:[c===null?(0,F.jsx)(ve,{className:`size-3.5 text-muted-foreground shrink-0 mt-0.5`}):c?(0,F.jsx)(Ge,{className:`size-3.5 text-emerald-500 shrink-0 mt-0.5`}):(0,F.jsx)(h,{className:`size-3.5 text-red-500 shrink-0 mt-0.5`}),(0,F.jsx)(`span`,{className:`flex-1 min-w-0 line-clamp-2`,children:n?String(n):JSON.stringify(e)}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[typeof a==`boolean`&&typeof o==`boolean`&&(0,F.jsxs)(`span`,{className:`text-[10px] text-muted-foreground font-mono`,children:[a?`pass`:`fail`,` → `,o?`pass`:`fail`]}),r!==void 0&&(0,F.jsxs)(P,{variant:`secondary`,className:`text-[9px]`,children:[`expect: `,String(r)]}),i!=null&&(0,F.jsx)(P,{variant:`secondary`,className:`text-[9px]`,children:String(i)})]})]})}function uh({validation:e}){let{improved:t,before_pass_rate:n,after_pass_rate:r,net_change:i,regressions:a,new_passes:o,per_entry_results:s,validation_mode:c,validation_agent:l,validation_fixture_id:u,validation_evidence_ref:d,...f}=e,p=Array.isArray(a)?a:[],m=Array.isArray(o)?o:[],h=Array.isArray(s)?s:[],g=typeof c==`string`?nh(c):null;return(0,F.jsxs)(`div`,{className:`rounded-md border bg-muted/30 p-3 space-y-3`,children:[(0,F.jsxs)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:[`Validation Results`,(0,F.jsx)(`span`,{className:`font-normal text-muted-foreground/60 ml-1.5`,children:`— Before/after comparison from eval tests`})]}),g&&(0,F.jsxs)(`div`,{className:`rounded-md border bg-card px-3 py-2`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(P,{variant:g.variant,className:`text-[10px]`,children:g.label}),typeof l==`string`&&l.trim()&&(0,F.jsxs)(P,{variant:`outline`,className:`text-[10px]`,children:[`agent: `,l]}),typeof u==`string`&&u.trim()&&(0,F.jsxs)(P,{variant:`outline`,className:`text-[10px]`,children:[`fixture: `,u]})]}),(0,F.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-muted-foreground`,children:g.description}),typeof d==`string`&&d.trim()&&(0,F.jsx)(`p`,{className:`mt-1 text-[10px] font-mono text-muted-foreground/70`,children:d})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[t!==void 0&&(0,F.jsx)(P,{variant:t?`default`:`destructive`,className:`text-[10px]`,children:t?`Improved`:`Regressed`}),typeof n==`number`&&typeof r==`number`&&(0,F.jsxs)(`span`,{className:`text-xs font-mono text-muted-foreground`,children:[(n*100).toFixed(1),`% → `,(r*100).toFixed(1),`%`]}),typeof i==`number`&&(0,F.jsxs)(`span`,{className:`text-xs font-mono font-semibold ${i>0?`text-emerald-600 dark:text-emerald-400`:i<0?`text-red-500`:`text-muted-foreground`}`,children:[i>0?`+`:``,(i*100).toFixed(1),`%`]})]}),m.length>0&&(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`p`,{className:`text-[11px] font-medium text-emerald-600 dark:text-emerald-400 mb-1`,children:[`New Passes (`,m.length,`)`]}),(0,F.jsx)(`div`,{className:`rounded border bg-card p-2`,children:m.map((e,t)=>(0,F.jsx)(lh,{entry:typeof e==`object`&&e?e:{value:e}},t))})]}),p.length>0&&(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`p`,{className:`text-[11px] font-medium text-red-500 mb-1`,children:[`Regressions (`,p.length,`)`]}),(0,F.jsx)(`div`,{className:`rounded border border-red-200 dark:border-red-900/50 bg-card p-2`,children:p.map((e,t)=>(0,F.jsx)(lh,{entry:typeof e==`object`&&e?e:{value:e}},t))})]}),h.length>0&&(0,F.jsx)(dh,{entries:h}),Object.keys(f).length>0&&(0,F.jsx)(`div`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs`,children:Object.entries(f).map(([e,t])=>(0,F.jsxs)(`div`,{className:`contents`,children:[(0,F.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:e}),(0,F.jsx)(`span`,{className:`text-foreground`,children:ch(e,t)})]},e))})]})}function dh({entries:e}){let[t,n]=(0,M.useState)(!1),r=e.filter(e=>{if(typeof e!=`object`||!e)return!1;let t=e;return t.passed===!0||t.matched===!0||t.triggered===!0||t.after===!0||t.result===!0}).length,i=t?e:e.slice(0,5);return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,F.jsxs)(`p`,{className:`text-[11px] font-medium text-muted-foreground`,children:[`Individual Test Cases (`,r,`/`,e.length,` passed)`]}),e.length>5&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>n(!t),className:`text-[10px] text-primary hover:underline`,children:t?`Show less`:`Show all ${e.length}`})]}),(0,F.jsx)(`div`,{className:`h-1.5 rounded-full bg-muted overflow-hidden mb-2`,children:(0,F.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500 transition-all`,style:{width:`${e.length>0?r/e.length*100:0}%`}})}),(0,F.jsx)(`div`,{className:`rounded border bg-card p-2 max-h-[300px] overflow-y-auto`,children:i.map((e,t)=>(0,F.jsx)(lh,{entry:typeof e==`object`&&e?e:{value:e}},t))})]})}function fh(e){if(!e.validation)return null;let t=e.validation.after_pass_rate;return typeof t==`number`?t:null}function ph({prev:e,curr:t}){if(e===null||t===null)return null;let n=t-e;if(n===0)return null;let r=(n*100).toFixed(1),i=n>0;return(0,F.jsxs)(`span`,{className:`text-[10px] font-mono font-semibold ${i?`text-emerald-600 dark:text-emerald-400`:`text-red-500`}`,children:[i?`+`:``,r,`% vs previous`]})}function mh({evalSet:e}){let[t,n]=(0,M.useState)(!1),r=e.filter(e=>(e.passed??e.result)===!0).length;return(0,F.jsxs)(`div`,{className:`rounded-md border bg-muted/30 p-3 space-y-2`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:`flex items-center gap-1.5 w-full text-left`,children:[t?(0,F.jsx)(Ee,{className:`size-3.5 text-muted-foreground shrink-0`}):(0,F.jsx)(Ve,{className:`size-3.5 text-muted-foreground shrink-0`}),(0,F.jsx)(C,{className:`size-3.5 text-muted-foreground`}),(0,F.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:[`Eval Set (`,r,`/`,e.length,` passed)`]})]}),t&&(0,F.jsx)(`div`,{className:`space-y-1`,children:e.map((e,t)=>{let n=e.query??e.prompt??e.input,r=e.expected??e.should_trigger,i=e.passed??e.result;return(0,F.jsxs)(`div`,{className:`flex items-start gap-2 text-xs py-1 border-b border-border/50 last:border-0`,children:[typeof i==`boolean`?i?(0,F.jsx)(Ge,{className:`size-3.5 text-emerald-500 shrink-0 mt-0.5`}):(0,F.jsx)(h,{className:`size-3.5 text-red-500 shrink-0 mt-0.5`}):(0,F.jsx)(ve,{className:`size-3.5 text-muted-foreground shrink-0 mt-0.5`}),(0,F.jsx)(`span`,{className:`flex-1 min-w-0 line-clamp-2`,children:String(n??JSON.stringify(e))}),r!==void 0&&(0,F.jsxs)(P,{variant:`secondary`,className:`text-[9px] shrink-0`,children:[`expect: `,String(r)]})]},t)})})]})}function hh({entry:e,roundLabel:t,roundStatus:n,prevPassRate:r,currPassRate:i}){let a=n!==`single`;return(0,F.jsxs)(L,{className:n===`final`?`border-primary/50 shadow-sm`:void 0,children:[(0,F.jsx)(R,{className:`pb-3`,children:(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsxs)(z,{className:`text-sm flex items-center gap-2`,children:[(0,F.jsx)(ee,{className:`size-4 text-muted-foreground`}),`Evidence: `,e.target,a&&t&&(0,F.jsx)(`span`,{className:`text-[10px] font-mono text-muted-foreground`,children:t}),n===`final`&&(0,F.jsx)(P,{variant:`default`,className:`text-[10px]`,children:`Final`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a&&(0,F.jsx)(ph,{prev:r,curr:i}),(0,F.jsx)(P,{variant:`secondary`,className:`text-[10px]`,children:e.stage}),e.confidence!==null&&(0,F.jsxs)(P,{variant:e.confidence>=.8?`default`:e.confidence>=.5?`secondary`:`destructive`,className:`text-[10px] font-mono`,children:[Un(e.confidence),` confidence`]}),(0,F.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Gn(e.timestamp)})]})]})}),(0,F.jsxs)(B,{className:`space-y-4`,children:[e.rationale&&(0,F.jsxs)(`div`,{className:`rounded-md border-l-2 border-primary/40 bg-primary/5 px-3 py-2`,children:[(0,F.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Rationale`}),(0,F.jsx)(`p`,{className:`text-sm leading-relaxed`,children:e.rationale})]}),e.details&&(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:e.details}),(e.original_text||e.proposed_text)&&(0,F.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[e.original_text&&(0,F.jsx)(sh,{label:`Original`,text:e.original_text,variant:`original`}),e.proposed_text&&(0,F.jsx)(sh,{label:`Proposed`,text:e.proposed_text,variant:`proposed`})]}),e.eval_set&&e.eval_set.length>0&&(0,F.jsx)(mh,{evalSet:e.eval_set}),e.validation&&Object.keys(e.validation).length>0&&(0,F.jsx)(uh,{validation:e.validation})]})]})}function gh({entry:e,roundLabel:t,onExpand:n}){let r=fh(e),i=e.validation?.improved;return(0,F.jsxs)(`button`,{type:`button`,onClick:n,className:`flex items-center gap-3 w-full rounded-lg border border-dashed px-4 py-3 text-left hover:bg-accent/50 transition-colors`,children:[(0,F.jsx)(Ve,{className:`size-4 text-muted-foreground shrink-0`}),(0,F.jsx)(ee,{className:`size-3.5 text-muted-foreground shrink-0`}),(0,F.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.target}),(0,F.jsx)(`span`,{className:`text-[10px] font-mono text-muted-foreground`,children:t}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto shrink-0`,children:[r!==null&&(0,F.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground`,children:[(r*100).toFixed(1),`% pass rate`]}),typeof i==`boolean`&&(0,F.jsx)(P,{variant:i?`default`:`destructive`,className:`text-[9px]`,children:i?`Improved`:`Regressed`}),(0,F.jsx)(P,{variant:`secondary`,className:`text-[10px]`,children:e.stage}),(0,F.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Gn(e.timestamp)})]})]})}function _h({proposalId:e,evolution:t,evidence:n,showContextBanner:r=!0}){let i=(0,M.useMemo)(()=>t.filter(t=>t.proposal_id===e).sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime()),[t,e]),a=(0,M.useMemo)(()=>n.filter(t=>t.proposal_id===e).sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime()),[n,e]),[o,s]=(0,M.useState)(new Set),[c,l]=(0,M.useState)(new Set),u=e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},d=e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},f=(0,M.useMemo)(()=>{for(let e=i.length-1;e>=0;e--)if(i[e].eval_snapshot)return i[e].eval_snapshot;return null},[i]),{proposalEntries:p,validationsByTarget:m}=(0,M.useMemo)(()=>{let e=[],t=new Map;for(let n of a)if(n.stage!==`validated`)e.push(n);else{let e=n.target;t.has(e)||t.set(e,[]),t.get(e).push(n)}return{proposalEntries:e,validationsByTarget:t}},[a]),h=i[i.length-1]??null,g=i.map(e=>e.action.replace(`_`,` `)).join(` -> `),_=ih(h?.action),v=nh(h?.validation_mode),y=(0,M.useMemo)(()=>{for(let e=p.length-1;e>=0;e--)if(p[e].confidence!==null)return p[e].confidence;return null},[p]),b=(0,M.useMemo)(()=>{let e=new Map;for(let t of p){let n=t.target||`proposal`,r=e.get(n)??[];r.push(t),e.set(n,r)}return Array.from(e.entries()).map(([e,t])=>{let n=t[t.length-1];for(let e=t.length-1;e>=0;e--)if(t[e].original_text||t[e].proposed_text||t[e].rationale){n=t[e];break}let r=t.findIndex(e=>e===n);return{target:e,primaryEntry:n,historyEntries:t.filter((e,t)=>t!==r),entries:t}})},[p]);return(0,F.jsxs)(`div`,{className:`space-y-4`,children:[r&&(0,F.jsxs)(`div`,{className:`flex items-start gap-2.5 rounded-lg border border-primary/20 bg-primary/5 px-3.5 py-2.5`,children:[(0,F.jsx)(ae,{className:`mt-0.5 size-4 shrink-0 text-primary/60`}),(0,F.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`This view shows the complete evidence trail for a skill evolution proposal — how the skill was changed, the eval test results before and after, and whether the change improved performance.`})]}),(0,F.jsxs)(L,{className:`border-border/15 bg-muted/10`,children:[(0,F.jsx)(R,{className:`pb-3`,children:(0,F.jsxs)(z,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,F.jsx)(`span`,{children:`Proposal Summary`}),(0,F.jsxs)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:[`#`,e.slice(0,12)]})]})}),(0,F.jsxs)(B,{className:`space-y-3`,children:[(0,F.jsx)(`div`,{className:`rounded-lg border px-4 py-3 ${_.tone}`,children:(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.jsx)(`div`,{className:`mt-0.5 shrink-0`,children:_.icon}),(0,F.jsxs)(`div`,{className:`min-w-0 space-y-1.5`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`p`,{className:`text-sm font-semibold`,children:_.title}),h&&(0,F.jsx)(P,{variant:th[h.action]??`secondary`,className:`text-[10px] capitalize`,children:rh(h.action)})]}),(0,F.jsx)(`p`,{className:`text-sm leading-6 text-current/90`,children:_.summary}),h?.details&&(0,F.jsx)(`div`,{className:`rounded-md bg-black/10 px-3 py-2 text-sm leading-6 text-current/90 dark:bg-black/20`,children:h.details}),(0,F.jsx)(`p`,{className:`text-xs font-medium text-current/75`,children:_.liveSkillNote})]})]})}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[h?.timestamp&&(0,F.jsx)(`span`,{className:`text-[10px] font-mono text-muted-foreground`,children:Gn(h.timestamp)}),(0,F.jsxs)(P,{variant:`outline`,className:`text-[10px]`,children:[a.length,` evidence `,a.length===1?`row`:`rows`]}),v&&(0,F.jsx)(P,{variant:v.variant,className:`text-[10px]`,children:v.label}),h?.validation_fixture_id&&(0,F.jsxs)(P,{variant:`outline`,className:`text-[10px]`,children:[`fixture: `,h.validation_fixture_id]}),y!=null&&(0,F.jsxs)(P,{variant:`secondary`,className:`text-[10px]`,children:[Math.round(y*100),`% confidence`]})]}),v&&(0,F.jsx)(`p`,{className:`text-[11px] leading-relaxed text-muted-foreground`,children:v.description}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,F.jsx)(`span`,{className:`font-headline uppercase tracking-[0.16em] text-muted-foreground/80`,children:`Lifecycle`}),(0,F.jsx)(`span`,{children:g?rh(g):`No lifecycle recorded`})]}),typeof f?.net_change==`number`&&typeof f.before_pass_rate==`number`&&typeof f.after_pass_rate==`number`&&(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-md border bg-muted/20 px-3 py-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1`,children:[f.net_change>0?(0,F.jsx)(A,{className:`size-3.5 text-emerald-500`}):f.net_change<0?(0,F.jsx)(Oe,{className:`size-3.5 text-red-500`}):(0,F.jsx)(ve,{className:`size-3.5 text-muted-foreground`}),(0,F.jsxs)(`span`,{className:`text-sm font-mono font-semibold ${f.net_change>0?`text-emerald-600 dark:text-emerald-400`:f.net_change<0?`text-red-500`:`text-muted-foreground`}`,children:[f.net_change>0?`+`:``,Math.round(f.net_change*100),`%`]})]}),(0,F.jsxs)(`span`,{className:`text-xs font-mono text-muted-foreground`,children:[Math.round(f.before_pass_rate*100),`% →`,` `,Math.round(f.after_pass_rate*100),`%`]}),f.net_change>0?(0,F.jsx)(P,{variant:`default`,className:`text-[10px]`,children:`Improved`}):f.net_change<0?(0,F.jsx)(P,{variant:`destructive`,className:`text-[10px]`,children:`Regressed`}):(0,F.jsx)(P,{variant:`outline`,className:`text-[10px]`,children:`No change`})]})]})]}),b.length>0&&(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsxs)(`div`,{className:`space-y-1`,children:[(0,F.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.18em] text-muted-foreground/80`,children:`What changed`}),(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This is the actual skill text selftune proposed changing.`})]}),b.map(e=>{let t=e.historyEntries.length>0,n=c.has(e.target);return(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(hh,{entry:e.primaryEntry,roundLabel:t?`Latest draft of ${e.entries.length}`:null,roundStatus:t?`final`:`single`,prevPassRate:null,currPassRate:null}),t&&(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>d(e.target),className:`flex items-center gap-1 px-1 text-[10px] text-muted-foreground transition-colors hover:text-foreground`,children:[n?(0,F.jsx)(Ee,{className:`size-3`}):(0,F.jsx)(Ve,{className:`size-3`}),n?`Hide`:`Show`,` `,e.historyEntries.length,` earlier`,` `,e.historyEntries.length===1?`draft`:`drafts`]}),n&&e.historyEntries.map((t,n)=>(0,F.jsx)(hh,{entry:t,roundLabel:`Draft ${n+1} of ${e.historyEntries.length}`,roundStatus:`intermediate`,prevPassRate:null,currPassRate:null},`proposal-history-${e.target}-${t.timestamp}-${n}`))]})]},`proposal-${e.target}`)})]}),Array.from(m.entries()).length>0&&(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsxs)(`div`,{className:`space-y-1`,children:[(0,F.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.18em] text-muted-foreground/80`,children:`How it was tested`}),(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Validation evidence shows whether the proposal improved the eval signal.`})]}),Array.from(m.entries()).map(([e,t])=>{let n=t.length>1;return(0,F.jsx)(`div`,{className:`space-y-2`,children:t.map((r,i)=>{let a=i===t.length-1,s=n?`Round ${i+1} of ${t.length}`:null,c=i>0?fh(t[i-1]):null,l=fh(r),d=`${e}-${r.timestamp}`,f=n?a?`final`:`intermediate`:`single`;return f===`intermediate`&&!o.has(d)?(0,F.jsx)(gh,{entry:r,roundLabel:s,onExpand:()=>u(d)},d):f===`intermediate`&&o.has(d)?(0,F.jsxs)(`div`,{className:`space-y-1`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>u(d),className:`flex items-center gap-1 px-1 text-[10px] text-muted-foreground transition-colors hover:text-foreground`,children:[(0,F.jsx)(Ee,{className:`size-3`}),`Collapse `,s]}),(0,F.jsx)(hh,{entry:r,roundLabel:s,roundStatus:f,prevPassRate:c,currPassRate:l})]},d):(0,F.jsx)(hh,{entry:r,roundLabel:s,roundStatus:f,prevPassRate:c,currPassRate:l},d)})},e)})]}),a.length===0&&(0,F.jsx)(`div`,{className:`flex items-center justify-center rounded-lg border border-dashed py-8`,children:(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No evidence entries for this proposal`})})]})}var vh={created:(0,F.jsx)(ve,{className:`size-3.5`}),validated:(0,F.jsx)(k,{className:`size-3.5`}),deployed:(0,F.jsx)(D,{className:`size-3.5`}),rejected:(0,F.jsx)(h,{className:`size-3.5`}),rolled_back:(0,F.jsx)(b,{className:`size-3.5`})},yh={created:`bg-primary/15`,validated:`bg-primary/25`,deployed:`bg-primary/30`,rejected:`bg-destructive/20`,rolled_back:`bg-destructive/15`},bh={created:`text-primary/70`,validated:`text-primary/85`,deployed:`text-primary`,rejected:`text-destructive`,rolled_back:`text-destructive/70`},xh={created:`ring-primary/15`,validated:`ring-primary/25`,deployed:`ring-primary/30`,rejected:`ring-destructive/25`,rolled_back:`ring-destructive/15`},Sh={created:`bg-primary/40 ring-primary/30`,validated:`bg-primary/60 ring-primary/40`,deployed:`bg-primary ring-primary/50`,rejected:`bg-destructive/60 ring-destructive/40`,rolled_back:`bg-destructive/40 ring-destructive/30`},Ch={created:`bg-primary/15`,validated:`bg-primary/20`,deployed:`bg-primary/25`,rejected:`bg-destructive/20`,rolled_back:`bg-destructive/15`};function wh(e){switch(e){case`host_replay`:return{label:`replay`,variant:`default`};case`llm_judge`:return{label:`judge`,variant:`secondary`};case`structural_guard`:return{label:`structural`,variant:`outline`};default:return null}}function Th(e){let t=new Map;for(let n of e){let e=t.get(n.proposal_id)??[];e.push(n),t.set(n.proposal_id,e)}for(let e of t.values())e.sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime());return Array.from(t.entries()).sort((e,t)=>{let n=e[1][e[1].length-1],r=t[1][t[1].length-1];return new Date(r.timestamp).getTime()-new Date(n.timestamp).getTime()})}function Eh(e){return e[e.length-1].action}function Dh(e){for(let t=e.length-1;t>=0;t--)if(e[t].eval_snapshot)return e[t].eval_snapshot;return null}function Oh({snapshot:e}){let t=e.net_change;if(t==null)return null;let n=Math.round(t*100),r=n>0;return(0,F.jsxs)(`span`,{className:N(`inline-flex items-center gap-0.5 text-[10px] font-mono font-medium`,r?`text-primary`:`text-destructive`),children:[r?(0,F.jsx)(A,{className:`size-2.5`}):(0,F.jsx)(Oe,{className:`size-2.5`}),r?`+`:``,n,`%`]})}var kh=[{action:`created`,label:`Created`,desc:`Proposal generated from session data`},{action:`validated`,label:`Validated`,desc:`Eval tests run, awaiting deployment`},{action:`deployed`,label:`Deployed`,desc:`Accepted and applied to skill file`},{action:`rejected`,label:`Rejected`,desc:`Failed validation criteria`},{action:`rolled_back`,label:`Rolled Back`,desc:`Reverted after deployment`}];function Ah(){let[e,t]=(0,M.useState)(!1);return(0,F.jsxs)(`div`,{className:`px-2 pb-3`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>t(!e),"aria-expanded":e,"aria-controls":`evolution-lifecycle-stages`,className:`flex w-full items-center gap-1 text-[10px] text-muted-foreground/70 transition-colors hover:text-muted-foreground`,children:[e?(0,F.jsx)(Ee,{className:`size-3`}):(0,F.jsx)(Ve,{className:`size-3`}),`Lifecycle stages`]}),e&&(0,F.jsx)(`div`,{id:`evolution-lifecycle-stages`,className:`mt-1.5 space-y-2.5 rounded-md border bg-muted/30 p-2`,children:kh.map(e=>(0,F.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,F.jsx)(`div`,{className:N(`size-2 rounded-full shrink-0 ring-1 mt-[3px]`,Sh[e.action])}),(0,F.jsxs)(`div`,{className:`min-w-0 flex flex-col gap-0.5`,children:[(0,F.jsx)(`span`,{className:`text-[10px] font-medium leading-none`,children:e.label}),(0,F.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 leading-tight`,children:e.desc})]})]},e.action))})]})}function jh({entries:e,selectedProposalId:t,onSelect:n}){let r=Th(e);return r.length===0?(0,F.jsx)(`div`,{className:`flex items-center justify-center rounded-lg border border-dashed py-6 px-3`,children:(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No evolution history yet`})}):(0,F.jsxs)(`div`,{className:`flex flex-col gap-0`,children:[(0,F.jsx)(`h2`,{className:`px-2 pb-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground/80`,children:`Evolution`}),(0,F.jsx)(Ah,{}),(0,F.jsx)(`nav`,{className:`flex flex-col`,children:r.map(([e,i],a)=>{let o=Eh(i),s=t===e,c=i[i.length-1],l=yh[o]??`bg-muted-foreground/20`,u=bh[o]??`text-muted-foreground`,d=xh[o]??`ring-muted-foreground/30`,f=Ch[o]??`bg-border`,p=a===r.length-1,m=Dh(i),h=wh(c.validation_mode);return(0,F.jsxs)(`div`,{className:`relative flex gap-3`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,F.jsx)(`div`,{className:N(`flex items-center justify-center size-7 rounded-full ring-2 shrink-0 z-10`,l,d,u),children:vh[o]??(0,F.jsx)(ve,{className:`size-3.5`})}),!p&&(0,F.jsx)(`div`,{className:N(`w-0.5 flex-1 min-h-[8px] my-1`,f)})]}),(0,F.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:N(`flex-1 min-w-0 rounded-md px-2.5 py-2 text-left transition-all mb-1`,`hover:bg-accent/50`,s?`bg-primary/5 ring-1 ring-primary/20`:``),children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(P,{variant:o===`deployed`?`default`:o===`rejected`||o===`rolled_back`?`destructive`:`secondary`,className:`text-[10px] capitalize`,children:o.replace(`_`,` `)}),(0,F.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Gn(c.timestamp)}),h&&(0,F.jsx)(P,{variant:h.variant,className:`text-[9px] uppercase`,children:h.label})]}),m&&(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,F.jsx)(Oh,{snapshot:m}),m.before_pass_rate!==void 0&&m.after_pass_rate!==void 0&&(0,F.jsxs)(`span`,{className:`text-[10px] text-muted-foreground/60 font-mono`,children:[Math.round(m.before_pass_rate*100),`→`,Math.round(m.after_pass_rate*100),`%`]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,F.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground/70`,children:[`#`,e.slice(0,8)]}),i.length>1&&(0,F.jsx)(`div`,{className:`flex gap-0.5 ml-auto`,children:i.map((e,t)=>(0,F.jsx)(`div`,{className:N(`size-1.5 rounded-full`,Sh[e.action]??`bg-muted-foreground/40`)},`${e.action}-${t}`))})]}),c.details&&(0,F.jsx)(`p`,{className:`text-[11px] text-muted-foreground/80 line-clamp-2 mt-1 leading-snug`,children:c.details})]})]},e)})})]})}function Mh({text:e}){return(0,F.jsxs)(mt,{children:[(0,F.jsx)(ht,{className:`inline-flex items-center text-muted-foreground/50 hover:text-muted-foreground transition-colors cursor-help`,onClick:e=>e.preventDefault(),children:(0,F.jsx)(ae,{className:`size-3`})}),(0,F.jsx)(gt,{side:`top`,className:`max-w-[220px]`,children:e})]})}M.createContext(null);function Nh(e){switch(e){case`repaired_contextual_miss`:return{label:`repaired miss`,variant:`destructive`};case`repaired_trigger`:return{label:`repaired trigger`,variant:`secondary`};case`legacy_materialized`:return{label:`legacy row`,variant:`outline`};default:return null}}function Ph(e){switch(e){case`previously_missed`:return{label:`previously missed`,variant:`secondary`};default:return null}}function Fh({row:e}){let t=e.workspace_path?e.workspace_path.split(`/`).slice(-2).join(`/`):null,n=Nh(e.observation_kind),r=Ph(e.historical_context);return(0,F.jsxs)(st,{className:e.triggered?``:`bg-destructive/5`,children:[(0,F.jsx)(H,{className:`max-w-[420px] truncate py-2 text-[12px]`,title:e.query_text||void 0,children:e.query_text||(0,F.jsx)(`span`,{className:`italic text-muted-foreground/40`,children:`No prompt recorded`})}),(0,F.jsx)(H,{className:`py-2`,children:(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[e.triggered?(0,F.jsx)(P,{variant:`outline`,className:`border-green-600/30 text-[10px] font-normal text-green-600`,children:`triggered`}):(0,F.jsx)(P,{variant:`destructive`,className:`text-[10px] font-normal`,children:`missed`}),n&&(0,F.jsx)(P,{variant:n.variant,className:`text-[10px] font-normal`,children:n.label}),r&&(0,F.jsx)(P,{variant:r.variant,className:`text-[10px] font-normal`,children:r.label})]})}),(0,F.jsx)(H,{className:`py-2 font-mono text-[11px] tabular-nums text-muted-foreground`,children:e.confidence==null?`Not recorded`:`${Math.round(e.confidence*100)}%`}),(0,F.jsx)(H,{className:`py-2`,children:e.invocation_mode?(0,F.jsx)(P,{variant:`secondary`,className:`text-[10px] font-normal`,children:e.invocation_mode}):(0,F.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Unknown mode`})}),(0,F.jsx)(H,{className:`py-2 text-[11px] text-muted-foreground`,children:e.prompt_kind??`Unclassified`}),(0,F.jsx)(H,{className:`py-2 text-[11px] text-muted-foreground`,children:e.source??`No data`}),(0,F.jsx)(H,{className:`py-2 text-[11px] text-muted-foreground`,children:e.platform??`No data`}),(0,F.jsx)(H,{className:`py-2 font-mono text-[11px] text-muted-foreground`,title:e.workspace_path??void 0,children:t??`No data`}),(0,F.jsx)(H,{className:`py-2`,children:(0,F.jsx)(P,{variant:e.query_origin===`inline_query`?`outline`:e.query_origin===`matched_prompt`?`secondary`:`destructive`,className:`text-[10px] font-normal`,children:e.query_origin})})]})}function Ih({rows:e,emptyMessage:t}){return e.length===0?(0,F.jsx)(`div`,{className:`flex items-center justify-center py-12 text-sm text-muted-foreground`,children:t}):(0,F.jsx)(`div`,{className:`themed-scroll max-h-[340px] overflow-auto`,children:(0,F.jsxs)(it,{children:[(0,F.jsx)(at,{children:(0,F.jsxs)(st,{className:`sticky top-0 z-10 bg-muted/70 backdrop-blur hover:bg-muted/70`,children:[(0,F.jsx)(V,{className:`h-8 font-headline text-[10px] uppercase tracking-[0.15em]`,children:`Prompt`}),(0,F.jsx)(V,{className:`h-8 w-[80px] font-headline text-[10px] uppercase tracking-[0.15em]`,children:`Status`}),(0,F.jsx)(V,{className:`h-8 w-[70px] font-headline text-[10px] uppercase tracking-[0.15em]`,children:`Confidence`}),(0,F.jsx)(V,{className:`h-8 w-[80px] font-headline text-[10px] uppercase tracking-[0.15em]`,children:`Mode`}),(0,F.jsx)(V,{className:`h-8 w-[80px] font-headline text-[10px] uppercase tracking-[0.15em]`,children:`Kind`}),(0,F.jsx)(V,{className:`h-8 w-[70px] font-headline text-[10px] uppercase tracking-[0.15em]`,children:`Source`}),(0,F.jsx)(V,{className:`h-8 w-[70px] font-headline text-[10px] uppercase tracking-[0.15em]`,children:`Platform`}),(0,F.jsx)(V,{className:`h-8 w-[100px] font-headline text-[10px] uppercase tracking-[0.15em]`,children:`Workspace`}),(0,F.jsx)(V,{className:`h-8 w-[100px] font-headline text-[10px] uppercase tracking-[0.15em]`,children:`Origin`})]})}),(0,F.jsx)(ot,{children:e.map((e,t)=>(0,F.jsx)(Fh,{row:e},`${e.session_id}-${t}`))})]})})}function Lh({label:e,value:t,warn:n}){let r=t==null?null:Math.round(t*100);return(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`span`,{className:`w-40 shrink-0 font-headline text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:e}),(0,F.jsx)(`div`,{className:`h-2 flex-1 overflow-hidden rounded-full bg-muted`,children:r!=null&&(0,F.jsx)(`div`,{className:`h-full rounded-full transition-all ${n?`bg-destructive`:`bg-primary`}`,style:{width:`${Math.min(r,100)}%`}})}),(0,F.jsx)(`span`,{className:`w-10 text-right font-mono text-xs tabular-nums ${n?`text-destructive`:`text-muted-foreground`}`,children:r==null?`No data`:`${r}%`})]})}function Rh({title:e,data:t}){if(!t||t.length===0)return null;let n=e=>{switch(e){case`repaired_contextual_miss`:return`repaired contextual miss`;case`repaired_trigger`:return`repaired trigger`;case`legacy_materialized`:return`legacy materialized`;default:return e}},r=t.map(e=>[n(e.source??e.kind??`(unknown)`),e.count]).sort(([,e],[,t])=>t-e),i=r.reduce((e,[,t])=>e+t,0);return(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h4`,{className:`mb-2 font-headline text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:e}),(0,F.jsxs)(it,{children:[(0,F.jsx)(at,{children:(0,F.jsxs)(st,{className:`hover:bg-transparent`,children:[(0,F.jsx)(V,{className:`h-7 font-headline text-[10px] uppercase tracking-[0.15em]`,children:`Value`}),(0,F.jsx)(V,{className:`h-7 w-[80px] text-right font-headline text-[10px] uppercase tracking-[0.15em]`,children:`Count`}),(0,F.jsx)(V,{className:`h-7 w-[80px] text-right font-headline text-[10px] uppercase tracking-[0.15em]`,children:`Rate`})]})}),(0,F.jsx)(ot,{children:r.map(([e,t])=>(0,F.jsxs)(st,{children:[(0,F.jsx)(H,{className:`py-2 text-[11px]`,children:e}),(0,F.jsx)(H,{className:`py-2 text-right font-mono text-[11px]`,children:t}),(0,F.jsx)(H,{className:`py-2 text-right font-mono text-[11px] text-muted-foreground`,children:i>0?`${Math.round(t/i*100)}%`:`0%`})]},e))})]})]})}function zh({nextAction:e,latestDecision:t}){let n=e.variant===`destructive`?`border-destructive/25`:e.variant===`default`?`border-primary/20`:`border-border/15`;return(0,F.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 @4xl/main:grid-cols-12`,children:[(0,F.jsx)(L,{className:`rounded-xl border bg-muted/35 shadow-none ${t?`@4xl/main:col-span-8`:`@4xl/main:col-span-12`} ${n}`,children:(0,F.jsxs)(B,{className:`flex items-start gap-3 px-4 py-4`,children:[(0,F.jsx)(`div`,{className:`shrink-0 pt-0.5`,children:e.icon}),(0,F.jsxs)(`div`,{className:`flex-1`,children:[(0,F.jsx)(`h3`,{className:`mb-1 font-headline text-[10px] uppercase tracking-[0.18em] text-muted-foreground`,children:`Next Best Action`}),(0,F.jsx)(`p`,{className:`text-[15px] font-medium leading-6 text-foreground`,children:e.text})]}),(0,F.jsx)(P,{variant:e.variant,className:`shrink-0 self-start text-[10px]`,children:e.actionLabel})]})}),t&&(0,F.jsx)(L,{className:`rounded-xl border border-border/10 bg-muted/20 @4xl/main:col-span-4`,children:(0,F.jsxs)(B,{className:`flex h-full items-start gap-3 px-4 py-4`,children:[(0,F.jsx)(ze,{className:`mt-0.5 size-4 shrink-0 text-primary/80`}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`h3`,{className:`mb-1 font-headline text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Latest Decision`}),(0,F.jsx)(`p`,{className:`truncate text-sm font-medium leading-6`,children:t.action}),t.timestamp&&(0,F.jsx)(`p`,{className:`mt-0.5 font-mono text-[10px] text-muted-foreground`,children:Gn(t.timestamp)})]}),(0,F.jsxs)(P,{variant:`outline`,className:`shrink-0 self-start text-[9px]`,children:[t.evolutionCount,` evolution`,t.evolutionCount===1?``:`s`]})]})})]})}function Bh({checks:e,sessions:t,promptLinkRate:n}){return`Selftune watched ${e} skill checks across ${t} sessions.${n==null?``:` It could link ${Un(n)} of those checks back to prompts.`}`}function Vh({missRate:e,missedTriggers:t,systemLikeRate:n}){return(t??0)>0&&e!=null?`It found ${t} likely misses (${Un(e)} miss rate), which means people asked for this skill and it probably should have triggered.`:(n??0)>.05?`Routing looks mostly stable, but some records appear system-generated, so selftune is being cautious about making strong claims.`:`Routing looks consistent in the current sample, with no strong signs that this skill is missing obvious requests.`}function Hh({trustState:e,latestAction:t,nextActionText:n}){switch(e){case`validated`:return`Selftune found a candidate that looks promising, but it has not been deployed yet. ${n}`;case`deployed`:return`A change has already been deployed for this skill. Selftune is now watching for regressions in real use.`;case`rolled_back`:return`A previous change was rolled back, so the live skill is back on the safer version while selftune keeps observing.`;case`watch`:return`Selftune sees enough signal to keep a close eye on this skill, but not enough to blindly change it. ${n}`;case`observed`:return`Selftune is still learning how people use this skill before making stronger recommendations.`;case`low_sample`:return`There is not enough evidence yet to trust a big change here. Selftune is still collecting examples.`;default:return t?`The latest automated decision for this skill was ${t}. ${n}`:n}}function Uh({title:e,icon:t,body:n}){return(0,F.jsxs)(`div`,{className:`rounded-xl border border-border/10 bg-muted/20 p-4`,children:[(0,F.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,F.jsx)(`div`,{className:`text-primary/80`,children:t}),(0,F.jsx)(`h3`,{className:`font-headline text-[10px] uppercase tracking-[0.18em] text-muted-foreground`,children:e})]}),(0,F.jsx)(`p`,{className:`text-sm leading-6 text-foreground/90`,children:n})]})}function Wh({trustState:e,coverage:t,evidenceQuality:n,routingQuality:r,evolutionState:i,dataHygiene:a,fallbackChecks:o,fallbackSessions:s,nextActionText:c,onOpenGuide:l}){let u=t?.checks??o,d=t?.sessions??s,f=a?.raw_checks??u,p=a?.internal_prompt_rows??0,m=a?.legacy_rows??0,h=a?.repaired_rows??0,g=Math.max(f-u,0)>0||m>0||h>0;return(0,F.jsxs)(L,{className:`rounded-xl border border-border/10 bg-card/95`,children:[(0,F.jsx)(R,{className:`gap-2 px-4 py-4`,children:(0,F.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,F.jsxs)(`div`,{className:`space-y-1`,children:[(0,F.jsx)(z,{className:`text-base`,children:`How selftune is improving this skill`}),(0,F.jsx)(nt,{children:`Read this first if you want the plain-English version before diving into the evidence below.`})]}),l&&(0,F.jsx)(I,{variant:`outline`,size:`sm`,onClick:l,children:`How to read this page`})]})}),(0,F.jsxs)(B,{className:`space-y-4 px-4 pb-4 pt-0`,children:[g&&(0,F.jsxs)(`div`,{className:`rounded-xl border border-primary/10 bg-primary/5 px-4 py-3 text-sm text-muted-foreground`,children:[(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:`Trust note:`}),` This summary is based on `,(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:u}),` operational checks from real usage.`,p>0&&(0,F.jsxs)(F.Fragment,{children:[` `,(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:p}),` internal selftune eval or optimizer prompts are excluded from trust scoring.`]}),m>0&&(0,F.jsxs)(F.Fragment,{children:[` `,(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:m}),` legacy rows stay in history only.`]}),h>0&&(0,F.jsxs)(F.Fragment,{children:[` `,(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:h}),` repaired misses come from transcript replay rather than first-party trigger events.`]})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 @4xl/main:grid-cols-3`,children:[(0,F.jsx)(Uh,{title:`What selftune saw`,icon:(0,F.jsx)(Me,{className:`size-4`}),body:Bh({checks:u,sessions:d,promptLinkRate:n?.prompt_link_rate})}),(0,F.jsx)(Uh,{title:`Why it acted`,icon:(0,F.jsx)(w,{className:`size-4`}),body:Vh({missRate:r?.miss_rate,missedTriggers:r?.missed_triggers,systemLikeRate:n?.system_like_rate})}),(0,F.jsx)(Uh,{title:`What happened next`,icon:(0,F.jsx)(ze,{className:`size-4`}),body:Hh({trustState:e,latestAction:i?.latest_action,nextActionText:c})})]}),(0,F.jsx)(`div`,{className:`rounded-xl border border-border/10 bg-muted/15 px-4 py-3 text-sm text-muted-foreground`,children:`If a proposal is rejected or still pending, your live skill has not changed yet. Selftune only earns trust by testing changes before deployment.`})]})]})}function Gh({coverage:e,evidenceQuality:t,routingQuality:n,evolutionState:r,fallbackChecks:i,fallbackSessions:a,fallbackEvidenceRows:o,fallbackEvolutionRows:s,fallbackLatestAction:c}){let l=(r?.evolution_rows??s)>0;return(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`mb-2 font-headline text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Trust Signals`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 @xl/main:grid-cols-2 @5xl/main:grid-cols-4`,children:[(0,F.jsx)(L,{className:`rounded-xl border border-border/10 bg-muted/20 transition-colors hover:border-border/20 @container/card`,children:(0,F.jsxs)(R,{className:`gap-2 px-4 py-3`,children:[(0,F.jsxs)(nt,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(Me,{className:`size-3.5`}),(0,F.jsx)(`span`,{className:`font-headline text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Coverage`})]}),(0,F.jsx)(z,{className:`text-[32px] font-semibold leading-none tabular-nums text-foreground`,children:e?.checks??i}),(0,F.jsx)(rt,{children:(0,F.jsxs)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:[e?.sessions??a,` sessions /`,` `,e?.workspaces??`No data`,` dirs`]})})]})}),(0,F.jsx)(L,{className:`rounded-xl border border-border/10 bg-muted/20 transition-colors hover:border-border/20 @container/card`,children:(0,F.jsxs)(R,{className:`gap-2 px-4 py-3`,children:[(0,F.jsxs)(nt,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(w,{className:`size-3.5`}),(0,F.jsx)(`span`,{className:`font-headline text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Evidence Quality`}),(0,F.jsx)(Mh,{text:`How well prompts are linked to invocations. Higher prompt-link rate = more trustworthy data.`})]}),(0,F.jsx)(z,{className:`text-[32px] font-semibold leading-none tabular-nums text-foreground`,children:t?.prompt_link_rate==null?`No data`:Un(t.prompt_link_rate)}),(0,F.jsx)(rt,{children:(0,F.jsxs)(`div`,{className:`flex flex-col items-end gap-0.5`,children:[(0,F.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`inline:`,` `,t?.inline_query_rate==null?`No data`:Un(t.inline_query_rate)]}),(t?.system_like_rate??0)>.05&&(0,F.jsxs)(P,{variant:`destructive`,className:`text-[9px]`,children:[Un(t?.system_like_rate??0),` system-like`]})]})})]})}),(0,F.jsx)(L,{className:`rounded-xl border border-border/10 bg-muted/20 transition-colors hover:border-border/20 @container/card`,children:(0,F.jsxs)(R,{className:`gap-2 px-4 py-3`,children:[(0,F.jsxs)(nt,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(g,{className:`size-3.5`}),(0,F.jsx)(`span`,{className:`font-headline text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Routing`}),(0,F.jsx)(Mh,{text:`Routing accuracy: average confidence when triggering, and miss rate`})]}),(0,F.jsx)(z,{className:`text-[32px] font-semibold leading-none tabular-nums text-foreground`,children:n?.avg_confidence==null?`No data`:Un(n.avg_confidence)}),(0,F.jsx)(rt,{children:(0,F.jsxs)(`div`,{className:`flex flex-col items-end gap-0.5`,children:[(0,F.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`miss:`,` `,n?.miss_rate==null?`No data`:Un(n.miss_rate)]}),(0,F.jsxs)(`span`,{className:`text-[10px] tabular-nums text-muted-foreground`,children:[n?.missed_triggers??`No data`,` missed`]})]})})]})}),(0,F.jsx)(L,{className:`rounded-xl border border-border/10 bg-muted/20 transition-colors hover:border-border/20 @container/card`,children:(0,F.jsxs)(R,{className:`gap-2 px-4 py-3`,children:[(0,F.jsxs)(nt,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(ze,{className:`size-3.5`}),(0,F.jsx)(`span`,{className:`font-headline text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Evolution`})]}),l?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(z,{className:`text-sm font-medium leading-6`,children:r?.latest_action??c??`No data`}),(0,F.jsx)(rt,{children:(0,F.jsxs)(`div`,{className:`flex flex-col items-end gap-0.5`,children:[(0,F.jsxs)(`span`,{className:`text-[10px] tabular-nums text-muted-foreground`,children:[r?.evidence_rows??o,` evidence`]}),(0,F.jsxs)(`span`,{className:`text-[10px] tabular-nums text-muted-foreground`,children:[r?.evolution_rows??s,` evolution`]}),r?.latest_timestamp&&(0,F.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:Gn(r.latest_timestamp)})]})})]}):(0,F.jsx)(z,{className:`text-sm font-normal text-muted-foreground`,children:`No evolution yet`})]})})]})]})}function Kh({examples:e}){return!e||e.good.length===0&&e.missed.length===0&&e.noisy.length===0?null:(0,F.jsxs)(L,{className:`rounded-xl border border-border/10 bg-card/90`,children:[(0,F.jsx)(R,{className:`px-4 pb-2 pt-4`,children:(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(z,{className:`font-headline text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Prompt Evidence`}),(0,F.jsx)(nt,{children:`Representative real usage first. Internal selftune traffic is separated so it does not masquerade as normal skill use.`})]}),(0,F.jsxs)(`div`,{className:`hidden items-center gap-2 text-[10px] text-muted-foreground @3xl/main:flex`,children:[(0,F.jsxs)(`span`,{children:[e.good.length,` successful`]}),(0,F.jsx)(`span`,{className:`text-border`,children:`|`}),(0,F.jsxs)(`span`,{children:[e.missed.length,` missed`]}),(0,F.jsx)(`span`,{className:`text-border`,children:`|`}),(0,F.jsxs)(`span`,{children:[e.noisy.length,` internal/polluted`]})]})]})}),(0,F.jsx)(B,{className:`px-4 pb-4 pt-0`,children:(0,F.jsxs)(ct,{defaultValue:`good`,children:[(0,F.jsxs)(ut,{variant:`line`,className:`min-h-0 rounded-xl border border-border/10 bg-muted/20 px-1.5 py-1`,children:[(0,F.jsxs)(dt,{value:`good`,className:`rounded-lg px-3 data-active:bg-background/70 data-active:text-foreground`,children:[`Successful Triggers`,(0,F.jsx)(P,{variant:`outline`,className:`ml-1.5 text-[10px]`,children:e.good.length})]}),(0,F.jsxs)(dt,{value:`missed`,className:`rounded-lg px-3 data-active:bg-background/70 data-active:text-foreground`,children:[`Missed Real Usage`,(0,F.jsx)(P,{variant:e.missed.length>0?`destructive`:`outline`,className:`ml-1.5 text-[10px]`,children:e.missed.length})]}),(0,F.jsxs)(dt,{value:`noisy`,className:`rounded-lg px-3 data-active:bg-background/70 data-active:text-foreground`,children:[`Internal / Polluted`,(0,F.jsx)(P,{variant:e.noisy.length>0?`destructive`:`outline`,className:`ml-1.5 text-[10px]`,children:e.noisy.length})]})]}),(0,F.jsx)(ft,{value:`good`,className:`mt-2`,children:(0,F.jsx)(Ih,{rows:e.good,emptyMessage:`No successful trigger samples yet.`})}),(0,F.jsx)(ft,{value:`missed`,className:`mt-2`,children:(0,F.jsx)(Ih,{rows:e.missed,emptyMessage:`No missed real-usage samples detected.`})}),(0,F.jsx)(ft,{value:`noisy`,className:`mt-2`,children:(0,F.jsx)(Ih,{rows:e.noisy,emptyMessage:`No internal or polluted samples detected.`})})]})})]})}function qh({evidenceQuality:e,dataHygiene:t}){return(0,F.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 @5xl/main:grid-cols-2 @5xl/main:items-start`,children:[(0,F.jsxs)(L,{className:`rounded-2xl border border-border/15 bg-card`,children:[(0,F.jsx)(R,{children:(0,F.jsxs)(z,{className:`flex items-center gap-2 font-headline text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:[(0,F.jsx)(Ie,{className:`size-4`}),`Evidence Quality Rates`]})}),(0,F.jsxs)(B,{className:`space-y-3 p-4`,children:[(0,F.jsx)(Lh,{label:`Prompt-linked`,value:e?.prompt_link_rate}),(0,F.jsx)(Lh,{label:`Inline query`,value:e?.inline_query_rate}),(0,F.jsx)(Lh,{label:`User prompt`,value:e?.user_prompt_rate}),(0,F.jsx)(Lh,{label:`Meta prompt`,value:e?.meta_prompt_rate}),(0,F.jsx)(Lh,{label:`No prompt`,value:e?.no_prompt_rate}),(0,F.jsx)(Lh,{label:`System-like`,value:e?.system_like_rate,warn:(e?.system_like_rate??0)>.05}),(0,F.jsx)(`div`,{className:`mt-3 border-t border-border/40 pt-3`}),(0,F.jsx)(Lh,{label:`Invocation mode`,value:e?.invocation_mode_coverage}),(0,F.jsx)(Lh,{label:`Confidence`,value:e?.confidence_coverage}),(0,F.jsx)(Lh,{label:`Source`,value:e?.source_coverage}),(0,F.jsx)(Lh,{label:`Scope`,value:e?.scope_coverage})]})]}),t&&(0,F.jsxs)(L,{className:`rounded-2xl border border-border/15 bg-card`,children:[(0,F.jsx)(R,{children:(0,F.jsxs)(z,{className:`flex items-center gap-2 font-headline text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:[(0,F.jsx)(te,{className:`size-4`}),`Data Hygiene`]})}),(0,F.jsxs)(B,{className:`space-y-6 p-4`,children:[(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,F.jsxs)(`div`,{className:`rounded-xl border border-border/15 bg-muted/30 p-3`,children:[(0,F.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Raw vs Operational`}),(0,F.jsxs)(`div`,{className:`mt-2 flex items-end gap-2`,children:[(0,F.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-foreground`,children:t.operational_checks}),(0,F.jsxs)(`div`,{className:`pb-0.5 text-xs text-muted-foreground`,children:[`of `,t.raw_checks,` checks`]})]}),(0,F.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:`Operational checks exclude internal selftune eval and optimizer traffic.`})]}),(0,F.jsxs)(`div`,{className:`rounded-xl border border-border/15 bg-muted/30 p-3`,children:[(0,F.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Historical Residue`}),(0,F.jsxs)(`div`,{className:`mt-2 flex items-end gap-2`,children:[(0,F.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-foreground`,children:t.legacy_rows}),(0,F.jsxs)(`div`,{className:`pb-0.5 text-xs text-muted-foreground`,children:[`legacy / `,t.repaired_rows,` repaired`]})]}),(0,F.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:`Legacy rows are older materialized history. Repaired rows are transcript-based reconstructions.`})]})]}),t.naming_variants&&t.naming_variants.length>1&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h4`,{className:`mb-2 font-headline text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Naming Variants`}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.naming_variants.map(e=>(0,F.jsx)(P,{variant:`outline`,className:`font-mono text-[10px]`,children:e},e))}),(0,F.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:`Multiple naming variants may indicate inconsistent skill registration.`})]}),(0,F.jsx)(Rh,{title:`Source Breakdown`,data:t.source_breakdown}),(0,F.jsx)(Rh,{title:`Prompt Kind Breakdown`,data:t.prompt_kind_breakdown}),(0,F.jsx)(Rh,{title:`Observation Breakdown`,data:t.observation_breakdown})]})]})]})}var Jh=6e4;function Yh(e){return Vn({queryKey:[`skill-report`,e],queryFn:()=>Fs(e),enabled:!!e,staleTime:5e3,refetchInterval:Jh,retry:(e,t)=>t instanceof Rs?!1:e<2})}var Xh=`selftune.skill-report-onboarding-dismissed`;function Zh({open:e,onOpenChange:t}){return(0,F.jsx)(Kn,{open:e,onOpenChange:t,children:(0,F.jsxs)(Yn,{side:`right`,className:`overflow-y-auto sm:max-w-lg`,children:[(0,F.jsxs)(Xn,{className:`space-y-2 border-b border-border/10 pb-4`,children:[(0,F.jsx)(Zn,{children:`How to read this page`}),(0,F.jsx)(Qn,{children:`selftune earns trust by showing what it observed, what it proposed, how it tested the change, and what happened next.`})]}),(0,F.jsxs)(`div`,{className:`space-y-6 p-4`,children:[(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(`h3`,{className:`font-headline text-[10px] uppercase tracking-[0.18em] text-muted-foreground`,children:`The improvement loop`}),(0,F.jsxs)(`div`,{className:`space-y-3 text-sm text-muted-foreground`,children:[(0,F.jsxs)(`p`,{children:[(0,F.jsx)(`strong`,{className:`text-foreground`,children:`1. Observe.`}),` selftune watches real sessions and notes when a skill triggered, missed, or looked noisy.`]}),(0,F.jsxs)(`p`,{children:[(0,F.jsx)(`strong`,{className:`text-foreground`,children:`2. Propose.`}),` when the signal is strong enough, it suggests a wording change to the skill.`]}),(0,F.jsxs)(`p`,{children:[(0,F.jsx)(`strong`,{className:`text-foreground`,children:`3. Validate.`}),` it checks whether the new wording improves routing without breaking important cases.`]}),(0,F.jsxs)(`p`,{children:[(0,F.jsx)(`strong`,{className:`text-foreground`,children:`4. Decide.`}),` only validated winners should be deployed. Rejected or pending proposals do not change the live skill.`]})]})]}),(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(`h3`,{className:`font-headline text-[10px] uppercase tracking-[0.18em] text-muted-foreground`,children:`What each section means`}),(0,F.jsxs)(`div`,{className:`space-y-3 text-sm text-muted-foreground`,children:[(0,F.jsxs)(`p`,{children:[(0,F.jsx)(`strong`,{className:`text-foreground`,children:`Next Best Action`}),` tells you whether you should review, deploy, or simply keep observing.`]}),(0,F.jsxs)(`p`,{children:[(0,F.jsx)(`strong`,{className:`text-foreground`,children:`How selftune is improving this skill`}),` `,`explains the current state in plain language.`]}),(0,F.jsxs)(`p`,{children:[(0,F.jsx)(`strong`,{className:`text-foreground`,children:`Trust Signals`}),` are the condensed metrics behind that story: coverage, evidence quality, routing quality, and evolution state.`]}),(0,F.jsxs)(`p`,{children:[(0,F.jsx)(`strong`,{className:`text-foreground`,children:`Evidence`}),` shows what changed and why a proposal was accepted, rejected, or left pending.`]}),(0,F.jsxs)(`p`,{children:[(0,F.jsx)(`strong`,{className:`text-foreground`,children:`Invocations`}),` shows real prompts where this skill triggered or likely should have triggered.`]}),(0,F.jsxs)(`p`,{children:[(0,F.jsx)(`strong`,{className:`text-foreground`,children:`Data Quality`}),` tells you how trustworthy the underlying telemetry is.`]})]})]}),(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(`h3`,{className:`font-headline text-[10px] uppercase tracking-[0.18em] text-muted-foreground`,children:`FAQ`}),(0,F.jsxs)(`div`,{className:`space-y-4 text-sm text-muted-foreground`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`font-medium text-foreground`,children:`What is a missed trigger?`}),(0,F.jsx)(`p`,{children:`A case where selftune believes the skill should have been used, but the agent did not invoke it.`})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`font-medium text-foreground`,children:`Why was a proposal rejected?`}),(0,F.jsx)(`p`,{children:`Usually because validation showed the new wording would regress existing behavior, or because it violated a hard rule like dropping an important anchor phrase.`})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`font-medium text-foreground`,children:`When should I trust a recommendation?`}),(0,F.jsx)(`p`,{children:`Trust it more when the page shows broad coverage, prompt-linked evidence, and a validated result. Trust it less when the sample is tiny or the data is noisy.`})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`font-medium text-foreground`,children:`Do I need to understand every metric?`}),(0,F.jsx)(`p`,{children:`No. Start with the plain-English summary and next best action. Use the deeper tabs only when you want to inspect the evidence yourself.`})]})]})]})]})]})})}var Qh={low_sample:{label:`Low Sample`,variant:`secondary`,icon:(0,F.jsx)(O,{className:`size-3`})},observed:{label:`Observed`,variant:`outline`,icon:(0,F.jsx)(oe,{className:`size-3`})},watch:{label:`Watch`,variant:`secondary`,icon:(0,F.jsx)(ee,{className:`size-3`})},validated:{label:`Validated`,variant:`default`,icon:(0,F.jsx)(k,{className:`size-3`})},deployed:{label:`Deployed`,variant:`default`,icon:(0,F.jsx)(k,{className:`size-3`})},rolled_back:{label:`Rolled Back`,variant:`destructive`,icon:(0,F.jsx)(De,{className:`size-3`})}};function $h({sessionId:e,meta:t,invocations:n,defaultExpanded:r}){let[i,a]=(0,M.useState)(r),o=t?.started_at??n[0]?.timestamp,s=n.reduce((e,t)=>{let n=t.invocation_mode??`unknown`;return e[n]=(e[n]??0)+1,e},{}),c=e=>{let n=t?.agent_cli?.replace(/_/g,` `),r=t?.platform?.replace(/_/g,` `);return e.agent_type&&e.agent_type!==`main`?{label:e.agent_type,hint:n?`${n} subagent`:`subagent invocation`}:n?{label:n,hint:e.agent_type===`main`?`main agent invocation`:`session agent that invoked the skill`}:r?{label:r,hint:e.agent_type===`main`?`main agent invocation`:`session platform`}:e.agent_type?{label:e.agent_type,hint:`recorded subagent type`}:{label:`No data`,hint:`invoker was not captured in this record`}};return(0,F.jsxs)(`div`,{className:`rounded-lg border border-border/60 overflow-hidden transition-colors`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-muted/40 active:bg-muted/60 transition-colors`,onClick:()=>a(!i),children:[(0,F.jsx)(Ve,{className:`size-3.5 text-muted-foreground shrink-0 transition-transform duration-150 ${i?`rotate-90`:``}`}),(0,F.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0 flex-1`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsxs)(`span`,{className:`text-sm font-medium`,children:[n.length,` invocation`,n.length===1?``:`s`]}),(0,F.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:o?Gn(o):``})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[t?.model&&(0,F.jsx)(P,{variant:`secondary`,className:`text-[10px] font-normal`,children:t.model}),t?.workspace_path&&(0,F.jsx)(`span`,{className:`text-[11px] text-muted-foreground font-mono`,title:t.workspace_path,children:t.workspace_path.split(`/`).slice(-2).join(`/`)})]})]}),!i&&(0,F.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:Object.entries(s).map(([e,t])=>(0,F.jsxs)(P,{variant:`outline`,className:`text-[10px] font-normal gap-1`,children:[e,` `,(0,F.jsx)(`span`,{className:`text-muted-foreground`,children:t})]},e))}),(0,F.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 font-mono shrink-0`,children:e.substring(0,8)})]}),i&&(0,F.jsx)(`div`,{className:`border-t border-border/40 overflow-x-auto`,children:(0,F.jsxs)(it,{children:[(0,F.jsx)(at,{children:(0,F.jsxs)(st,{className:`hover:bg-transparent bg-muted/40`,children:[(0,F.jsxs)(V,{className:`font-headline text-[10px] uppercase tracking-[0.15em] h-8`,children:[`Prompt `,(0,F.jsx)(Mh,{text:`The user prompt that led to this skill being invoked`})]}),(0,F.jsxs)(V,{className:`font-headline text-[10px] uppercase tracking-[0.15em] h-8 w-[90px]`,children:[`Mode`,` `,(0,F.jsx)(Mh,{text:`explicit = user typed /skillname; implicit = user mentioned skill by name; inferred = agent chose skill autonomously`})]}),(0,F.jsxs)(V,{className:`font-headline text-[10px] uppercase tracking-[0.15em] h-8 w-[70px]`,children:[`Confidence`,` `,(0,F.jsx)(Mh,{text:`Model's confidence score (0-100%) when routing this prompt to the skill`})]}),(0,F.jsxs)(V,{className:`font-headline text-[10px] uppercase tracking-[0.15em] h-8 w-[110px]`,children:[`Invoker`,` `,(0,F.jsx)(Mh,{text:`Who invoked the skill. Prefers subagent type when present, otherwise falls back to the session agent or platform.`})]}),(0,F.jsx)(V,{className:`font-headline text-[10px] uppercase tracking-[0.15em] h-8 w-[120px]`,children:`Evidence`}),(0,F.jsx)(V,{className:`font-headline text-[10px] uppercase tracking-[0.15em] h-8 w-[70px] text-right`,children:`Time`})]})}),(0,F.jsx)(ot,{children:n.map((e,t)=>(0,F.jsxs)(st,{className:e.triggered?``:`bg-destructive/5`,children:[(0,F.jsxs)(H,{className:`max-w-[500px] truncate text-sm py-2`,title:e.query||void 0,children:[e.query||(0,F.jsx)(`span`,{className:`text-muted-foreground/40 italic`,children:`No prompt recorded`}),!e.triggered&&(0,F.jsx)(P,{variant:`destructive`,className:`text-[10px] font-normal ml-2`,children:`missed`})]}),(0,F.jsx)(H,{className:`py-2`,children:e.invocation_mode?(0,F.jsx)(P,{variant:`secondary`,className:`text-[10px] font-normal`,children:e.invocation_mode}):(0,F.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Unknown mode`})}),(0,F.jsx)(H,{className:`py-2 font-mono text-xs text-muted-foreground tabular-nums`,children:e.confidence===null?`Not recorded`:`${Math.round(e.confidence*100)}%`}),(0,F.jsx)(H,{className:`py-2`,children:(()=>{let t=c(e);return t.label===`No data`?(0,F.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,title:t.hint,children:t.label}):(0,F.jsx)(P,{variant:e.agent_type&&e.agent_type!==`main`?`outline`:`secondary`,className:`text-[10px] font-normal capitalize`,title:t.hint,children:t.label})})()}),(0,F.jsx)(H,{className:`py-2`,children:(()=>{let t=Nh(e.observation_kind),n=Ph(e.historical_context);return t?(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,F.jsx)(P,{variant:t.variant,className:`text-[10px] font-normal`,children:t.label}),n&&(0,F.jsx)(P,{variant:n.variant,className:`text-[10px] font-normal`,children:n.label})]}):(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`canonical`}),n&&(0,F.jsx)(P,{variant:n.variant,className:`text-[10px] font-normal`,children:n.label})]})})()}),(0,F.jsx)(H,{className:`py-2 font-mono text-[11px] text-muted-foreground text-right whitespace-nowrap`,children:e.timestamp?Gn(e.timestamp):``})]},t))})]})})]})}function eg(e,t,n,r,i){return e===`low_sample`?{icon:(0,F.jsx)(oe,{className:`size-5`}),text:`Keep observing. This skill needs more sessions before trust can be assessed.`,actionLabel:`Keep observing`,variant:`secondary`}:e===`rolled_back`?{icon:(0,F.jsx)(y,{className:`size-5 text-destructive`}),text:`Inspect rollback evidence before re-deploying.`,actionLabel:`Inspect rollback`,variant:`destructive`}:e===`watch`&&(n??0)>.05?{icon:(0,F.jsx)(y,{className:`size-5 text-amber-500`}),text:`Clean source-truth data or routing data before trusting this report.`,actionLabel:`Clean data`,variant:`secondary`}:e===`watch`&&(t??0)>0?{icon:(0,F.jsx)(w,{className:`size-5 text-amber-500`}),text:`Generate evals to investigate missed triggers.`,actionLabel:`Generate evals`,variant:`secondary`}:e===`watch`?{icon:(0,F.jsx)(oe,{className:`size-5 text-amber-500`}),text:`This skill is under active observation. Review recent invocations to verify routing accuracy.`,actionLabel:`Review invocations`,variant:`secondary`}:r?{icon:(0,F.jsx)(ze,{className:`size-5 text-primary`}),text:`Review pending proposal.`,actionLabel:`Review proposal`,variant:`default`}:e===`validated`?{icon:(0,F.jsx)(be,{className:`size-5 text-primary`}),text:`Deploy the validated candidate.`,actionLabel:`Deploy candidate`,variant:`default`}:e===`deployed`?{icon:(0,F.jsx)(Ge,{className:`size-5 text-green-500`}),text:`No action needed. Skill is healthy and being monitored.`,actionLabel:`Healthy`,variant:`outline`}:e===`observed`?{icon:(0,F.jsx)(oe,{className:`size-5 text-muted-foreground`}),text:`No action needed. Selftune is still observing this skill and building confidence from real usage.`,actionLabel:`Observed`,variant:`outline`}:{icon:(0,F.jsx)(oe,{className:`size-5`}),text:`Continue monitoring this skill.`,actionLabel:`Monitor`,variant:`outline`}}function tg({evolution:e,activeProposal:t,onSelect:n}){let r=new Set(e.map(e=>e.proposal_id)).size,i=r>6,[a,o]=(0,M.useState)(!i),s=(0,M.useMemo)(()=>{if(a)return e;let t=new Set,n=[];for(let r of e){if(!t.has(r.proposal_id)){if(t.size>=6)continue;t.add(r.proposal_id)}n.push(r)}return n},[6,e,a]);return(0,F.jsx)(`aside`,{className:`w-full px-4 py-4 @5xl/main:w-[252px] @5xl/main:self-start @5xl/main:pr-0`,children:(0,F.jsx)(`div`,{className:`@5xl/main:sticky @5xl/main:top-16`,children:(0,F.jsxs)(`div`,{className:`rounded-xl border border-border/10 bg-muted/20 px-3 py-3 text-xs ${a?`themed-scroll max-h-[26rem] overflow-y-auto @5xl/main:max-h-[calc(100svh-6rem)]`:`overflow-visible`}`,children:[(0,F.jsx)(jh,{entries:s,selectedProposalId:t,onSelect:n}),i&&(0,F.jsxs)(`button`,{type:`button`,onClick:()=>o(!a),className:`mt-2 flex w-full items-center justify-center gap-1.5 py-2 text-[11px] text-muted-foreground transition-colors hover:text-foreground`,children:[(0,F.jsx)(Ee,{className:`size-3 transition-transform duration-150 ${a?`rotate-180`:``}`}),a?`Collapse timeline`:`Show full timeline (${r} proposals)`]})]})})})}function ng(){let{name:e}=f(),[t,n]=i(),{data:r,isPending:a,isError:o,error:s,refetch:c}=Yh(e),[u,d]=(0,M.useState)(!1),[p,m]=(0,M.useState)(!0),[h,g]=(0,M.useState)(`invocations`),[_,v]=(0,M.useState)(`all`),y=r?.evolution??[],b=new Set(y.map(e=>e.proposal_id)),x=t.get(`proposal`),S=x&&b.has(x)?x:y.length>0?y[0].proposal_id:null;(0,M.useEffect)(()=>{let e=t.get(`proposal`);if(S&&e!==S){let e=new URLSearchParams(t);e.set(`proposal`,S),n(e,{replace:!0});return}if(!S&&e){let e=new URLSearchParams(t);e.delete(`proposal`),n(e,{replace:!0})}},[S,t,n]),(0,M.useEffect)(()=>{typeof window>`u`||window.localStorage.getItem(Xh)===`1`&&m(!1)},[]);let C=e=>{let r=new URLSearchParams(t);r.set(`proposal`,e),n(r,{replace:!0})},w=()=>{m(!1),typeof window<`u`&&window.localStorage.setItem(Xh,`1`)},E=r?.trust,D=r?.coverage,O=r?.evidence_quality,k=r?.routing_quality,A=r?.evolution_state,ee=r?.data_hygiene,te=r?.examples,ne=ee?.raw_checks??D?.checks??r?.usage.total_checks??0,re=ee?.operational_checks??D?.checks??r?.usage.total_checks??0,ie=Math.max(ne-re,0),ae=(A?.evolution_rows??y.length)>0,se=ae?`evidence`:`invocations`;(0,M.useEffect)(()=>{g(se)},[se]);let ce=(0,M.useMemo)(()=>{let e=(r?.canonical_invocations??[]).map(e=>({timestamp:e.timestamp||e.occurred_at||null,session_id:e.session_id,triggered:e.triggered,query:e.query??``,source:e.source??``,invocation_mode:e.invocation_mode??null,confidence:e.confidence??null,tool_name:e.tool_name??null,agent_type:e.agent_type??null,observation_kind:e.observation_kind??`canonical`,historical_context:e.historical_context??null}));return e.sort((e,t)=>(t.timestamp??``).localeCompare(e.timestamp??``)),e},[r?.canonical_invocations]),le=(0,M.useMemo)(()=>{switch(_){case`misses`:return ce.filter(e=>!e.triggered);case`low_confidence`:return ce.filter(e=>e.confidence!==null&&e.confidence<.5);case`system_meta`:return ce.filter(e=>e.invocation_mode===`system`||e.invocation_mode===`meta`);default:return ce}},[ce,_]),ue=(0,M.useMemo)(()=>new Map((r?.session_metadata??[]).map(e=>[e.session_id,e])),[r?.session_metadata]),de=(0,M.useMemo)(()=>{let e=new Map;for(let t of le){let n=t.session_id??`unknown`,r=e.get(n);r?r.push(t):e.set(n,[t])}return[...e.entries()].sort(([,e],[,t])=>(t[0]?.timestamp??``).localeCompare(e[0]?.timestamp??``))},[le]);if(!e)return(0,F.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-16`,children:(0,F.jsx)(`p`,{className:`text-sm text-destructive`,children:`No skill name provided`})});if(a)return(0,F.jsxs)(`div`,{className:`@container/main flex flex-1 flex-col gap-6 p-4 lg:p-6`,children:[(0,F.jsx)(W,{className:`h-10 w-64`}),(0,F.jsx)(`div`,{className:`grid grid-cols-1 gap-4 @xl/main:grid-cols-2 @5xl/main:grid-cols-4`,children:Array.from({length:4}).map((e,t)=>(0,F.jsx)(W,{className:`h-28 rounded-2xl`},t))}),(0,F.jsx)(W,{className:`h-20 rounded-2xl`}),(0,F.jsx)(W,{className:`h-64 rounded-2xl`})]});if(o)return(0,F.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-4 py-16`,children:[(0,F.jsx)(Pe,{className:`size-10 text-destructive`}),(0,F.jsx)(`p`,{className:`text-sm font-medium text-destructive`,children:s instanceof Error?s.message:`Unknown error`}),(0,F.jsxs)(I,{variant:`outline`,size:`sm`,onClick:()=>c(),children:[(0,F.jsx)(j,{className:`mr-2 size-3.5`}),`Retry`]})]});if(!r)return(0,F.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-16`,children:(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No data yet`})});if((D?.checks??r.usage.total_checks)===0&&r.evidence.length===0&&r.evolution.length===0&&(r.canonical_invocations?.length??0)===0)return(0,F.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-4 py-16`,children:[(0,F.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No data found for skill "`,e,`".`]}),(0,F.jsxs)(I,{variant:`outline`,size:`sm`,render:(0,F.jsx)(l,{to:`/`}),children:[(0,F.jsx)(Re,{className:`mr-2 size-3.5`}),`Back to Overview`]})]});let fe=E?.state??`low_sample`,pe=Qh[fe],me=eg(fe,k?.miss_rate,O?.system_like_rate,A?.has_pending_proposals??r.pending_proposals.length>0,ae);return(0,F.jsxs)(ct,{value:h,onValueChange:g,children:[(0,F.jsx)(Zh,{open:u,onOpenChange:d}),(0,F.jsxs)(`div`,{className:`@container/main flex flex-1 flex-col gap-5 p-4 lg:px-6 lg:pb-6 lg:pt-0`,children:[(0,F.jsxs)(`div`,{className:`sticky top-0 z-30 space-y-2 border-b border-border/15 bg-background/95 py-2.5 backdrop-blur supports-[backdrop-filter]:bg-background/85`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(I,{variant:`outline`,size:`sm`,render:(0,F.jsx)(l,{to:`/`}),className:`shrink-0`,children:(0,F.jsx)(Re,{className:`size-3.5`})}),(0,F.jsx)(`h1`,{className:`text-base font-semibold tracking-tight lg:text-lg font-headline shrink-0`,children:r.skill_name}),(0,F.jsxs)(P,{variant:pe.variant,className:`gap-1 shrink-0 text-[10px]`,children:[pe.icon,pe.label]}),(0,F.jsxs)(`div`,{className:`ml-auto flex items-center gap-4 shrink-0`,children:[(0,F.jsx)(I,{variant:`outline`,size:`sm`,onClick:()=>d(!0),children:`How this works`}),(0,F.jsxs)(`div`,{className:`hidden @xl/main:flex items-center gap-3 text-xs text-muted-foreground`,children:[(0,F.jsxs)(`span`,{className:`tabular-nums`,children:[(0,F.jsx)(`strong`,{className:`text-foreground`,children:D?.checks??r.usage.total_checks}),` `,`checks`]}),(0,F.jsx)(`span`,{className:`text-border`,children:`|`}),(0,F.jsxs)(`span`,{className:`tabular-nums`,children:[(0,F.jsx)(`strong`,{className:`text-foreground`,children:D?.sessions??r.sessions_with_skill}),` `,`sessions`]}),(0,F.jsx)(`span`,{className:`text-border`,children:`|`}),(0,F.jsxs)(`span`,{className:`tabular-nums`,children:[(0,F.jsx)(`strong`,{className:`text-foreground`,children:D?.workspaces??`No data`}),` `,`workspaces`]})]}),(D?.first_seen||D?.last_seen)&&(0,F.jsxs)(`div`,{className:`hidden @3xl/main:flex items-center gap-2 text-[10px] text-muted-foreground font-mono`,children:[D.first_seen&&(0,F.jsx)(`span`,{title:`First seen`,children:Gn(D.first_seen)}),D.first_seen&&D.last_seen&&(0,F.jsx)(`span`,{children:`-`}),D.last_seen&&(0,F.jsx)(`span`,{title:`Last seen`,children:Gn(D.last_seen)})]})]})]}),E?.summary&&(0,F.jsxs)(`div`,{className:`space-y-1.5 text-sm leading-relaxed text-muted-foreground`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,F.jsx)(`span`,{children:E.summary}),A?.latest_action&&A?.latest_timestamp&&(0,F.jsxs)(`span`,{className:`text-[11px] text-muted-foreground/70 font-mono`,children:[`Latest: `,A.latest_action,` (`,Gn(A.latest_timestamp),`)`]})]}),ie>0&&(0,F.jsxs)(`div`,{className:`text-[12px] text-muted-foreground/80`,children:[`Based on `,(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:re}),` `,`real checks. `,(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:ie}),` `,`internal or legacy rows are excluded from trust scoring.`]})]})]}),p&&(0,F.jsx)(L,{className:`rounded-xl border border-primary/15 bg-primary/5`,children:(0,F.jsxs)(B,{className:`flex flex-wrap items-center justify-between gap-3 px-4 py-3`,children:[(0,F.jsxs)(`div`,{className:`text-sm text-muted-foreground`,children:[(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:`New to selftune?`}),` Start with the summary below, then open the guide if you want the full improvement loop explained step by step.`]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(I,{variant:`outline`,size:`sm`,onClick:()=>d(!0),children:`Open guide`}),(0,F.jsx)(I,{variant:`ghost`,size:`sm`,onClick:w,children:`Hide`})]})]})}),(0,F.jsxs)(`div`,{className:`space-y-4`,children:[(0,F.jsx)(zh,{nextAction:me,latestDecision:ae&&A?.latest_action?{action:A.latest_action,timestamp:A.latest_timestamp,evolutionCount:A.evolution_rows??y.length}:void 0}),(0,F.jsx)(Wh,{trustState:fe,coverage:D,evidenceQuality:O,routingQuality:k,evolutionState:A,dataHygiene:ee,fallbackChecks:r.usage.total_checks,fallbackSessions:r.sessions_with_skill,nextActionText:me.text,onOpenGuide:()=>d(!0)}),(0,F.jsx)(Gh,{coverage:D,evidenceQuality:O,routingQuality:k,evolutionState:A,fallbackChecks:r.usage.total_checks,fallbackSessions:r.sessions_with_skill,fallbackEvidenceRows:r.evidence.length,fallbackEvolutionRows:y.length,fallbackLatestAction:y[0]?.action})]}),(0,F.jsxs)(`div`,{className:`space-y-4 border-t border-border/10 pt-4`,children:[(0,F.jsxs)(ut,{variant:`line`,className:`rounded-xl border border-border/10 bg-muted/20 px-1.5 py-1`,children:[ae&&(0,F.jsxs)(mt,{children:[(0,F.jsx)(ht,{render:(0,F.jsx)(dt,{value:`evidence`,className:`rounded-lg px-3 font-headline text-xs uppercase tracking-wider data-active:bg-background/70 data-active:text-foreground`}),children:`Evidence`}),(0,F.jsx)(gt,{children:`Change history and validation results`})]}),(0,F.jsxs)(mt,{children:[(0,F.jsxs)(ht,{render:(0,F.jsx)(dt,{value:`invocations`,className:`rounded-lg px-3 font-headline text-xs uppercase tracking-wider data-active:bg-background/70 data-active:text-foreground`}),children:[`Invocations`,(0,F.jsx)(P,{variant:`secondary`,className:`ml-1.5 text-[10px]`,children:ce.length})]}),(0,F.jsx)(gt,{children:`Real usage and repaired misses only. Internal selftune traffic and legacy residue are excluded from this working set.`})]}),(0,F.jsxs)(mt,{children:[(0,F.jsx)(ht,{render:(0,F.jsx)(dt,{value:`data-quality`,className:`rounded-lg px-3 font-headline text-xs uppercase tracking-wider data-active:bg-background/70 data-active:text-foreground`}),children:`Data Quality`}),(0,F.jsx)(gt,{children:`Evidence quality metrics and data hygiene`})]})]}),ae&&(0,F.jsxs)(ft,{value:`evidence`,className:`space-y-6`,children:[(0,F.jsx)(Kh,{examples:te}),(0,F.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border/15 bg-card`,children:(0,F.jsxs)(`div`,{className:`flex flex-col @5xl/main:grid @5xl/main:grid-cols-[252px_minmax(0,1fr)] @5xl/main:items-start`,children:[y.length>0&&(0,F.jsx)(tg,{evolution:y,activeProposal:S,onSelect:C}),(0,F.jsx)(`div`,{className:`min-w-0 p-4 @xl/main:p-5`,children:S?(0,F.jsx)(_h,{proposalId:S,evolution:y,evidence:r.evidence,showContextBanner:!1}):(0,F.jsx)(L,{className:`rounded-2xl`,children:(0,F.jsx)(B,{className:`py-12`,children:(0,F.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 text-center`,children:[(0,F.jsx)(oe,{className:`size-8 text-muted-foreground/40`}),(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This skill is being observed but has no reviewable evolution evidence yet.`})]})})})})]})})]}),(0,F.jsx)(ft,{value:`invocations`,children:ce.length===0?(0,F.jsx)(L,{className:`rounded-2xl`,children:(0,F.jsx)(B,{className:`py-12`,children:(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground text-center`,children:`No invocation records yet.`})})}):(0,F.jsxs)(`div`,{className:`space-y-2`,children:[ie>0&&(0,F.jsxs)(`div`,{className:`rounded-xl border border-border/10 bg-muted/20 px-4 py-3 text-sm text-muted-foreground`,children:[`Showing`,` `,(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:ce.length}),` `,`operational invocations.`,` `,(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:ie}),` internal or legacy rows are tracked in Data Quality instead of being mixed into this working set.`]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(T,{className:`size-3.5 text-muted-foreground`}),[[`all`,`All`],[`misses`,`Misses`],[`low_confidence`,`Low confidence`],[`system_meta`,`System/meta`]].map(([e,t])=>(0,F.jsx)(`button`,{type:`button`,onClick:()=>v(e),className:`inline-block`,children:(0,F.jsx)(P,{variant:_===e?`default`:`outline`,className:`text-[10px] cursor-pointer`,children:t})},e))]}),(0,F.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[le.length,` invocations across `,de.length,` `,`sessions`]})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-muted-foreground`,children:[(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/70`}),`explicit = user typed /skill`]}),(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/70`}),`implicit = mentioned by name`]}),(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/70`}),`inferred = agent chose autonomously`]}),(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`size-1.5 rounded-full bg-destructive/70`}),`repaired miss = transcript showed skill read without invocation`]})]}),de.length===0?(0,F.jsx)(`div`,{className:`flex items-center justify-center py-8 text-sm text-muted-foreground`,children:`No invocations match this filter.`}):de.map(([e,t],n)=>(0,F.jsx)($h,{sessionId:e,meta:ue.get(e),invocations:t,defaultExpanded:n<3},e))]})}),(0,F.jsx)(ft,{value:`data-quality`,children:(0,F.jsx)(qh,{evidenceQuality:O,dataHygiene:ee})})]})]})]})}var rg=[{key:`ALL`,label:`All Skills`},{key:`HEALTHY`,label:`Healthy`},{key:`WARNING`,label:`Warning`},{key:`CRITICAL`,label:`Critical`},{key:`UNGRADED`,label:`Ungraded`}],ig={HEALTHY:{text:`text-primary`,bg:`bg-primary`,label:`Deployed`},WARNING:{text:`text-primary-accent`,bg:`bg-primary-accent`,label:`Needs Attention`},CRITICAL:{text:`text-destructive`,bg:`bg-destructive`,label:`Critical`},UNGRADED:{text:`text-muted-foreground`,bg:`bg-muted-foreground`,label:`Ungraded`},UNKNOWN:{text:`text-muted-foreground`,bg:`bg-muted-foreground`,label:`Unknown`}};function ag(e){return e===null?0:Math.round(e*100)}function og(e){return Wn(e.map(e=>({name:e.skill_name,scope:e.skill_scope,passRate:e.total_checks>0?e.pass_rate:null,checks:e.total_checks,status:Hn(e.pass_rate,e.total_checks),uniqueSessions:e.unique_sessions,triggeredCount:e.triggered_count,lastSeen:e.last_seen})))}function sg(e){let t=e.filter(e=>e.total_checks>=5);if(t.length===0)return null;let n=t.reduce((e,t)=>e+t.total_checks,0),r=t.reduce((e,t)=>e+Math.round(t.pass_rate*t.total_checks),0);return n>0?r/n:null}function cg(e,t){let n=[...t].filter(e=>e.skill_name).sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime());for(let t of n){let n=e.find(e=>e.skill_name===t.skill_name);if(n)return{skill:n,latestEvolution:t}}return e.length>0?{skill:[...e].sort((e,t)=>t.total_checks-e.total_checks)[0],latestEvolution:n[0]??null}:null}function lg(e){if(!e)return`never`;let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function ug(){return(0,F.jsxs)(`div`,{className:`flex flex-1 flex-col gap-8 p-6 md:p-10 animate-in fade-in duration-500`,children:[(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(W,{className:`h-12 w-64`}),(0,F.jsx)(W,{className:`h-5 w-96`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-12 gap-6`,children:[(0,F.jsx)(W,{className:`col-span-8 h-72 rounded-xl`}),(0,F.jsxs)(`div`,{className:`col-span-4 flex flex-col gap-6`,children:[(0,F.jsx)(W,{className:`h-32 rounded-xl`}),(0,F.jsx)(W,{className:`h-32 rounded-xl`})]})]}),(0,F.jsx)(`div`,{className:`grid grid-cols-3 gap-6`,children:Array.from({length:6}).map((e,t)=>(0,F.jsx)(W,{className:`h-52 rounded-xl`},`skel-${t}`))})]})}function dg({skill:e,latestEvolution:t}){let n=Hn(e.pass_rate,e.total_checks);return(0,F.jsxs)(L,{className:`col-span-12 lg:col-span-8 rounded-3xl border border-border/15 p-8 relative overflow-hidden flex flex-col`,children:[(0,F.jsx)(`div`,{className:`absolute top-0 left-0 w-full h-1 bg-input`,children:(0,F.jsx)(`div`,{className:`h-full bg-primary shadow-[0_0_15px_rgba(79,242,255,0.6)] transition-all duration-700`,style:{width:`${ag(e.total_checks>0?e.pass_rate:null)}%`}})}),(0,F.jsxs)(`div`,{className:`flex justify-between items-start mb-6`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,F.jsx)(`span`,{className:`px-2 py-0.5 rounded text-[10px] font-bold bg-primary/10 text-primary uppercase tracking-widest`,children:n===`HEALTHY`?`Deployed`:`Evolving`}),(0,F.jsxs)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:[e.skill_scope??`global`,` scope`]})]}),(0,F.jsx)(`h2`,{className:`font-headline text-3xl font-bold text-foreground`,children:e.skill_name})]}),(0,F.jsxs)(`div`,{className:`text-right`,children:[(0,F.jsx)(`span`,{className:`text-4xl font-headline font-light text-primary`,children:Un(e.total_checks>0?e.pass_rate:null)}),(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground uppercase tracking-widest mt-1`,children:t?`Evolved ${lg(t.timestamp)}`:`Pass Rate`})]})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-3 gap-8 mb-8`,children:[(0,F.jsxs)(`div`,{className:`bg-muted p-4 rounded-2xl border border-border/15`,children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground uppercase tracking-widest mb-1`,children:`Total Checks`}),(0,F.jsx)(`p`,{className:`text-xl font-bold font-headline tabular-nums`,children:e.total_checks.toLocaleString()})]}),(0,F.jsxs)(`div`,{className:`bg-muted p-4 rounded-2xl border border-border/15`,children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground uppercase tracking-widest mb-1`,children:`Pass Rate`}),(0,F.jsx)(`p`,{className:`text-xl font-bold font-headline tabular-nums ${ig[n].text}`,children:Un(e.total_checks>0?e.pass_rate:null)})]}),(0,F.jsxs)(`div`,{className:`bg-muted p-4 rounded-2xl border border-border/15`,children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground uppercase tracking-widest mb-1`,children:`Unique Sessions`}),(0,F.jsx)(`p`,{className:`text-xl font-bold font-headline tabular-nums`,children:e.unique_sessions.toLocaleString()})]})]}),(0,F.jsxs)(`div`,{className:`flex justify-end gap-4`,children:[(0,F.jsx)(l,{to:`/skills/${encodeURIComponent(e.skill_name)}`,className:`px-6 py-2 rounded-xl text-muted-foreground font-bold hover:bg-input transition-colors`,children:`Configure`}),(0,F.jsx)(l,{to:`/skills/${encodeURIComponent(e.skill_name)}`,className:`px-8 py-2 bg-primary text-primary-foreground font-bold rounded-xl shadow-[0_4px_20px_rgba(79,242,255,0.2)] hover:shadow-[0_4px_25px_rgba(79,242,255,0.4)] transition-all`,children:`View Report`})]})]})}function fg({skills:e}){let t=sg(e),n=e.filter(e=>e.total_checks>=5).length;return(0,F.jsxs)(L,{className:`rounded-3xl border border-border/15 p-6 flex flex-col justify-center`,children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground uppercase tracking-widest mb-4`,children:`Library Health`}),(0,F.jsx)(`div`,{className:`flex items-end gap-2 mb-2`,children:(0,F.jsx)(`span`,{className:`text-5xl font-headline font-bold tabular-nums`,children:t===null?`--`:`${Math.round(t*100)}%`})}),(0,F.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Aggregate pass rate across `,n,` graded skill`,n===1?``:`s`,`.`]})]})}function pg({proposals:e}){return e.length===0?(0,F.jsxs)(L,{className:`rounded-3xl p-6 flex flex-col gap-3 border border-border/15 border-l-4 border-l-primary/40`,children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground uppercase tracking-widest mb-2`,children:`Pending Proposals`}),(0,F.jsx)(`h3`,{className:`font-headline font-bold text-lg`,children:`No proposals pending`})]}):(0,F.jsxs)(L,{className:`rounded-3xl p-6 flex flex-col gap-3 border border-border/15 border-l-4 border-l-primary/40`,children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground uppercase tracking-widest mb-2`,children:`Pending Proposals`}),(0,F.jsxs)(`h3`,{className:`font-headline font-bold text-lg mb-4`,children:[`Awaiting Review`,(0,F.jsx)(P,{variant:`secondary`,className:`ml-2 h-5 px-2 text-[10px] bg-primary/15 text-primary border-none align-middle`,children:e.length})]}),(0,F.jsx)(`div`,{className:`space-y-3 max-h-32 overflow-y-auto themed-scroll`,children:e.map(e=>(0,F.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-muted rounded-xl`,children:[(0,F.jsx)(`span`,{className:`text-sm truncate`,children:e.skill_name??`Unknown`}),(0,F.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:e.action})]},e.proposal_id))})]})}function mg({skill:e}){let t=ag(e.passRate),n=ig[e.status];return(0,F.jsxs)(L,{className:`border border-border/15 p-6 hover:border-border/30 transition-all duration-300 flex flex-col`,children:[(0,F.jsxs)(`div`,{className:`flex justify-between items-start mb-4`,children:[(0,F.jsx)(`div`,{className:`w-12 h-12 rounded-xl bg-muted flex items-center justify-center`,children:(0,F.jsx)(`span`,{className:`size-3 rounded-full ${n.bg}`})}),(0,F.jsxs)(`div`,{className:`text-right`,children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground uppercase tracking-widest`,children:e.scope??`unknown`}),(0,F.jsx)(`p`,{className:`text-sm font-bold tabular-nums`,children:e.checks.toLocaleString()})]})]}),(0,F.jsx)(`h3`,{className:`font-headline font-bold text-xl tracking-tight text-foreground truncate mb-1`,children:e.name}),(0,F.jsxs)(`p`,{className:`text-sm text-muted-foreground mb-6`,children:[e.uniqueSessions,` sessions · Last seen `,lg(e.lastSeen)]}),(0,F.jsxs)(`div`,{className:`space-y-4`,children:[(0,F.jsxs)(`div`,{className:`flex justify-between items-end text-xs uppercase tracking-tighter`,children:[(0,F.jsx)(`span`,{className:`text-muted-foreground`,children:`Pass Rate`}),(0,F.jsx)(`span`,{className:`font-bold ${n.text}`,children:n.label})]}),(0,F.jsx)(`div`,{className:`w-full h-1 bg-input rounded-full overflow-hidden`,children:(0,F.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500 ${n.bg}`,style:{width:`${t}%`}})}),(0,F.jsxs)(`div`,{className:`pt-4 flex gap-3`,children:[(0,F.jsx)(l,{to:`/skills/${encodeURIComponent(e.name)}`,className:`flex-1 py-2 text-xs font-bold text-muted-foreground bg-muted rounded-lg text-center hover:bg-input transition-colors`,children:`Configure`}),(0,F.jsx)(l,{to:`/skills/${encodeURIComponent(e.name)}`,className:`flex-1 py-2 text-xs font-bold text-muted-foreground bg-secondary rounded-lg text-center hover:bg-input hover:text-foreground transition-all`,children:`View Report`})]})]})]})}function hg({overviewQuery:e}){let{data:t,isLoading:n,isError:r,error:i,refetch:a}=e,[o,s]=(0,M.useState)(`ALL`),[c,l]=(0,M.useState)(!0),u=(0,M.useMemo)(()=>t?og(t.skills):[],[t]),d=(0,M.useMemo)(()=>{let e=u;return o!==`ALL`&&(e=e.filter(e=>e.status===o)),c?e.reduceRight((e,t)=>(e.push(t),e),[]):e},[u,o,c]),f=(0,M.useMemo)(()=>t?cg(t.skills,t.overview.evolution):null,[t]);if(n)return(0,F.jsx)(ug,{});if(r)return(0,F.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-4 py-16`,children:[(0,F.jsx)(Pe,{className:`size-10 text-destructive`}),(0,F.jsx)(`p`,{className:`text-sm font-medium text-destructive`,children:i instanceof Error?i.message:`Failed to load skills library.`}),(0,F.jsxs)(I,{variant:`outline`,size:`sm`,onClick:()=>a(),children:[(0,F.jsx)(j,{className:`mr-2 size-3.5`}),`Retry`]})]});if(!t)return(0,F.jsx)(ug,{});let p=t.overview.pending_proposals;return(0,F.jsxs)(`div`,{className:`@container/main flex flex-1 flex-col gap-8 py-8 px-4 lg:px-6 animate-in fade-in duration-500`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h1`,{className:`font-headline text-4xl font-bold tracking-tight text-foreground`,children:`Skills Library`}),(0,F.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground max-w-2xl`,children:`Monitor and manage your evolving skill definitions across all scopes.`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-12 gap-6`,children:[f?(0,F.jsx)(dg,{skill:f.skill,latestEvolution:f.latestEvolution}):(0,F.jsx)(L,{className:`col-span-12 lg:col-span-8 border border-border/15 p-8 flex items-center justify-center`,children:(0,F.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,F.jsx)(Ue,{className:`size-10 text-muted-foreground mx-auto`}),(0,F.jsx)(`p`,{className:`text-muted-foreground`,children:`No evolution activity yet. Run an evolution cycle to see your most active skill.`})]})}),(0,F.jsxs)(`div`,{className:`col-span-12 lg:col-span-4 flex flex-col gap-6`,children:[(0,F.jsx)(fg,{skills:t.skills}),(0,F.jsx)(pg,{proposals:p})]})]}),(0,F.jsxs)(`div`,{className:`space-y-6`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-4 flex-wrap`,children:[(0,F.jsx)(`div`,{className:`flex gap-1 bg-muted rounded-xl p-1`,children:rg.map(e=>{let t=e.key===`ALL`?u.length:u.filter(t=>t.status===e.key).length;return(0,F.jsxs)(`button`,{type:`button`,onClick:()=>s(e.key),className:`px-4 py-2 rounded-lg text-sm font-headline font-semibold transition-all duration-200 ${o===e.key?`bg-card text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,children:[e.label,(0,F.jsx)(`span`,{className:`ml-1.5 text-xs opacity-60`,children:t})]},e.key)})}),(0,F.jsxs)(mt,{children:[(0,F.jsxs)(ht,{render:(0,F.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),className:`flex items-center gap-2 px-3 py-2 text-sm text-muted-foreground hover:text-foreground transition-colors font-headline`}),children:[(0,F.jsx)(_e,{className:`size-4`}),(0,F.jsx)(`span`,{children:`Sort by Performance`})]}),(0,F.jsx)(gt,{children:c?`Highest pass rate first`:`Lowest pass rate first`})]})]}),d.length>0?(0,F.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-6`,children:d.map(e=>(0,F.jsx)(mg,{skill:e},e.name))}):(0,F.jsxs)(L,{className:`border border-border/15 p-12 text-center`,children:[(0,F.jsx)(ve,{className:`size-8 text-muted-foreground mx-auto mb-3`}),(0,F.jsx)(`p`,{className:`text-muted-foreground font-headline`,children:`No skills match the current filter`})]})]})]})}var gg=6e4;function _g(){return Vn({queryKey:[`doctor`],queryFn:Ls,staleTime:5e3,refetchInterval:gg})}var vg={pass:{color:`text-primary`,label:`Pass`,dotColor:`bg-primary`,dotGlow:`shadow-[0_0_8px_rgba(79,242,255,0.6)]`,animate:!0},warn:{color:`text-amber-400`,label:`Warn`,dotColor:`bg-amber-400`,dotGlow:``,animate:!1},fail:{color:`text-destructive`,label:`Fail`,dotColor:`bg-destructive`,dotGlow:`shadow-[0_0_8px_rgba(255,180,171,0.6)]`,animate:!1}},yg={config:{label:`Configuration`,description:`selftune.json exists and contains valid agent_type and llm_mode`,icon:(0,F.jsx)(x,{className:`size-4`})},log_session_telemetry:{label:`Session Telemetry Log`,description:`session_telemetry_log.jsonl exists and records parse correctly`,icon:(0,F.jsx)(se,{className:`size-4`})},log_skill_usage:{label:`Skill Usage Log`,description:`skill_usage_log.jsonl exists and records parse correctly`,icon:(0,F.jsx)(se,{className:`size-4`})},log_all_queries:{label:`Query Log`,description:`all_queries_log.jsonl exists and records parse correctly`,icon:(0,F.jsx)(se,{className:`size-4`})},log_evolution_audit:{label:`Evolution Audit Log`,description:`evolution_audit_log.jsonl exists and records parse correctly`,icon:(0,F.jsx)(se,{className:`size-4`})},hook_settings:{label:`Hook Installation`,description:`Claude Code settings.json has all required selftune hooks configured`,icon:(0,F.jsx)(Qe,{className:`size-4`})},evolution_audit:{label:`Evolution Health`,description:`Evolution audit log is intact and records are well-formed`,icon:(0,F.jsx)(k,{className:`size-4`})},dashboard_freshness_mode:{label:`Dashboard Freshness`,description:`The current dashboard still invalidates live updates from JSONL log watchers. SQLite WAL live invalidation has not been cut over yet.`,icon:(0,F.jsx)(E,{className:`size-4`})}};function bg(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.workspace_root==`string`&&typeof t.git_sha==`string`&&typeof t.db_path==`string`&&typeof t.process_mode==`string`&&(t.watcher_mode===`wal`||t.watcher_mode===`jsonl`||t.watcher_mode===`none`)}function xg({refreshKey:e}){let[t,n]=(0,M.useState)(null);if((0,M.useEffect)(()=>{fetch(`/api/health`).then(e=>e.json()).then(e=>{bg(e)&&n(e)}).catch(()=>{})},[e]),!t)return null;let r=t.watcher_mode===`jsonl`?{className:`border-amber-400/25 bg-amber-400/10 text-amber-400`,label:`Legacy watcher path active`}:t.watcher_mode===`none`?{className:`border-muted-foreground/20 bg-muted/40 text-muted-foreground`,label:`Watcher inactive`}:{className:`border-primary/25 bg-primary/10 text-primary`,label:`Live invalidation active`};return(0,F.jsxs)(`section`,{className:`glass-panel rounded-2xl border border-border/15 p-6`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col gap-2 md:flex-row md:items-end md:justify-between`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`text-[10px] font-headline uppercase tracking-[0.2em] text-muted-foreground`,children:`Runtime Environment`}),(0,F.jsx)(`h2`,{className:`mt-1 font-headline text-xl font-semibold text-foreground`,children:`Active dashboard runtime`})]}),(0,F.jsx)(P,{variant:`outline`,className:r.className,children:r.label})]}),(0,F.jsxs)(`div`,{className:`mt-5 grid gap-3 md:grid-cols-2 xl:grid-cols-4`,children:[(0,F.jsxs)(`div`,{className:`rounded-xl border border-border/10 bg-background/35 p-4`,children:[(0,F.jsx)(`p`,{className:`text-[10px] font-headline uppercase tracking-[0.18em] text-muted-foreground`,children:`Process mode`}),(0,F.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-foreground`,children:t.process_mode})]}),(0,F.jsxs)(`div`,{className:`rounded-xl border border-border/10 bg-background/35 p-4`,children:[(0,F.jsx)(`p`,{className:`text-[10px] font-headline uppercase tracking-[0.18em] text-muted-foreground`,children:`Watcher mode`}),(0,F.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-foreground`,children:t.watcher_mode})]}),(0,F.jsxs)(`div`,{className:`rounded-xl border border-border/10 bg-background/35 p-4`,children:[(0,F.jsx)(`p`,{className:`text-[10px] font-headline uppercase tracking-[0.18em] text-muted-foreground`,children:`Git SHA`}),(0,F.jsx)(`p`,{className:`mt-2 truncate font-mono text-sm text-foreground`,children:t.git_sha})]}),(0,F.jsxs)(`div`,{className:`rounded-xl border border-border/10 bg-background/35 p-4`,children:[(0,F.jsx)(`p`,{className:`text-[10px] font-headline uppercase tracking-[0.18em] text-muted-foreground`,children:`Database path`}),(0,F.jsx)(`p`,{className:`mt-2 truncate font-mono text-sm text-foreground`,children:t.db_path})]})]}),(0,F.jsxs)(`div`,{className:`mt-3 rounded-xl border border-border/10 bg-background/35 p-4`,children:[(0,F.jsx)(`p`,{className:`text-[10px] font-headline uppercase tracking-[0.18em] text-muted-foreground`,children:`Workspace root`}),(0,F.jsx)(`p`,{className:`mt-2 break-all font-mono text-sm text-foreground`,children:t.workspace_root})]})]})}function Sg({check:e}){let t=yg[e.name]??{label:e.name,description:``,icon:(0,F.jsx)(E,{className:`size-4`})},n=vg[e.status]??{color:`text-muted-foreground`,label:e.status,dotColor:`bg-muted-foreground`,dotGlow:``,animate:!1};return(0,F.jsxs)(`div`,{className:`group flex items-start gap-4 px-6 py-4 border-b border-border/10 last:border-b-0 hover:bg-secondary/40 transition-colors`,children:[(0,F.jsx)(`div`,{className:`mt-1.5 flex-shrink-0`,children:(0,F.jsx)(`span`,{className:`block size-1.5 rounded-full ${n.dotColor} ${n.dotGlow} ${n.animate?`animate-pulse`:``}`})}),(0,F.jsx)(`div`,{className:`flex-shrink-0 mt-0.5 text-muted-foreground`,children:t.icon}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`text-sm font-semibold text-foreground`,children:t.label}),t.description&&(0,F.jsx)(Mh,{text:t.description})]}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 leading-relaxed`,children:e.message||`No details`}),e.path&&(0,F.jsx)(`p`,{className:`text-[11px] text-muted-foreground/60 font-mono mt-1 truncate`,children:e.path})]}),(0,F.jsx)(`div`,{className:`flex-shrink-0`,children:(0,F.jsxs)(`div`,{className:`inline-flex items-center gap-2 px-2 py-1 rounded-md ${e.status===`pass`?`bg-primary/10`:e.status===`fail`?`bg-destructive/10`:`bg-amber-400/10`}`,children:[(0,F.jsx)(`span`,{className:`size-1.5 rounded-full ${n.dotColor} ${n.animate?`animate-pulse`:``}`}),(0,F.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-tighter font-headline ${n.color}`,children:n.label})]})})]})}function Cg(){let{data:e,isPending:t,isError:n,error:r,refetch:i}=_g(),[a,o]=(0,M.useState)(0);if(t)return(0,F.jsxs)(`div`,{className:`flex flex-1 flex-col gap-8 p-8`,children:[(0,F.jsx)(W,{className:`h-12 w-64`}),(0,F.jsx)(W,{className:`h-24 rounded-xl`}),(0,F.jsx)(W,{className:`h-[400px] rounded-xl`})]});if(n)return(0,F.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-4 py-16`,children:[(0,F.jsx)(Pe,{className:`size-10 text-destructive`}),(0,F.jsx)(`p`,{className:`text-sm font-medium text-destructive`,children:r instanceof Error?r.message:`Unknown error`}),(0,F.jsxs)(I,{variant:`outline`,size:`sm`,onClick:()=>i(),children:[(0,F.jsx)(j,{className:`mr-2 size-3.5`}),`Retry`]})]});if(!e)return(0,F.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-16`,children:(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No diagnostics data available.`})});let{checks:s,summary:c,healthy:l=!1,timestamp:u}=e,d=s??[],f=c??{pass:0,warn:0,fail:0},p=f.pass+f.warn+f.fail,m=d.filter(e=>e.name===`config`),h=d.filter(e=>e.name.startsWith(`log_`)),g=d.filter(e=>e.name===`hook_settings`),_=d.filter(e=>e.name===`evolution_audit`),v=d.filter(e=>e.name===`dashboard_freshness_mode`),y=new Set([`config`,...h.map(e=>e.name),`hook_settings`,`evolution_audit`,`dashboard_freshness_mode`]),b=d.filter(e=>!y.has(e.name)),x=[{title:`Configuration`,checks:m},{title:`Log Files`,checks:h},{title:`Hooks`,checks:g},{title:`Evolution`,checks:_},{title:`Integrity`,checks:v},{title:`Other`,checks:b}].filter(e=>e.checks.length>0);return(0,F.jsxs)(`div`,{className:`flex flex-1 flex-col gap-8 p-8 max-w-5xl mx-auto w-full`,children:[(0,F.jsxs)(`section`,{className:`flex flex-col md:flex-row md:items-end justify-between gap-4`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h1`,{className:`font-headline text-4xl font-bold tracking-tight text-foreground`,children:`System Status`}),(0,F.jsx)(`p`,{className:`text-muted-foreground max-w-md mt-1`,children:`Diagnostics and health checks for selftune infrastructure.`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsxs)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-widest font-headline`,children:[`Last checked `,u?Gn(u):`—`]}),(0,F.jsx)(I,{"aria-label":`Refresh status`,variant:`ghost`,size:`sm`,onClick:()=>{o(e=>e+1),i()},className:`shrink-0`,children:(0,F.jsx)(j,{className:`size-3.5`})})]})]}),(0,F.jsxs)(`div`,{className:`glass-panel rounded-2xl border border-border/15 p-6 flex items-center justify-between overflow-hidden relative`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-8`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col`,children:[(0,F.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-[0.2em] font-headline mb-1`,children:`Overall`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l?(0,F.jsx)(`span`,{className:`size-3 rounded-full bg-primary animate-pulse shadow-[0_0_12px_rgba(79,242,255,0.6)]`}):(0,F.jsx)(`span`,{className:`size-3 rounded-full bg-destructive shadow-[0_0_12px_rgba(255,180,171,0.6)]`}),(0,F.jsx)(`span`,{className:`font-headline text-2xl font-bold text-foreground`,children:l?`Healthy`:`Unhealthy`})]})]}),(0,F.jsx)(`div`,{className:`h-10 w-px bg-border/20`}),(0,F.jsxs)(`div`,{className:`flex flex-col`,children:[(0,F.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-[0.2em] font-headline mb-1`,children:`Passed`}),(0,F.jsx)(`span`,{className:`font-headline text-2xl font-bold text-primary`,children:f.pass})]}),(0,F.jsxs)(`div`,{className:`flex flex-col`,children:[(0,F.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-[0.2em] font-headline mb-1`,children:`Warnings`}),(0,F.jsx)(`span`,{className:`font-headline text-2xl font-bold ${f.warn>0?`text-amber-400`:`text-foreground`}`,children:f.warn})]}),(0,F.jsxs)(`div`,{className:`flex flex-col`,children:[(0,F.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-[0.2em] font-headline mb-1`,children:`Failed`}),(0,F.jsx)(`span`,{className:`font-headline text-2xl font-bold ${f.fail>0?`text-destructive`:`text-foreground`}`,children:f.fail})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsxs)(`div`,{className:`text-right`,children:[(0,F.jsxs)(`p`,{className:`text-xs font-bold text-foreground font-headline`,children:[p,` Checks`]}),(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:f.pass===p?`All checks passing`:`${f.fail+f.warn} issue${f.fail+f.warn===1?``:`s`} detected`})]}),(0,F.jsx)(`div`,{className:`size-12 rounded-full flex items-center justify-center border-4 border-primary/20 border-t-primary`,children:(0,F.jsx)(S,{className:`size-5 text-primary`})})]}),(0,F.jsx)(`div`,{className:`absolute -right-20 -bottom-20 w-64 h-64 bg-primary/5 blur-3xl rounded-full pointer-events-none`})]}),(0,F.jsx)(xg,{refreshKey:a}),(0,F.jsx)(`div`,{className:`bg-muted rounded-2xl border border-border/15 overflow-hidden`,children:x.map((e,t)=>(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`px-6 py-3 bg-secondary/60 border-b border-border/15`,children:[(0,F.jsx)(`span`,{className:`text-[10px] font-bold text-muted-foreground uppercase tracking-[0.2em] font-headline`,children:e.title}),(0,F.jsx)(P,{variant:`outline`,className:`ml-3 text-[10px] px-1.5 py-0 border-border/40 text-muted-foreground`,children:e.checks.length})]}),e.checks.map((e,t)=>(0,F.jsx)(Sg,{check:e},`${e.name}-${t}`)),t<x.length-1&&(0,F.jsx)(`div`,{className:`border-b border-border/25`})]},e.title))})]})}var wg=new wn({defaultOptions:{queries:{refetchOnWindowFocus:!0,gcTime:300*1e3}}});function Tg(){qs();let[e,t]=(0,M.useState)(`ALL`),n=Bs(),{data:r}=n;return(0,F.jsxs)(lr,{children:[(0,F.jsx)(_r,{version:r?.version}),(0,F.jsxs)(fr,{children:[(0,F.jsx)(Us,{}),(0,F.jsxs)(s,{children:[(0,F.jsx)(d,{path:`/`,element:(0,F.jsx)(mc,{search:``,statusFilter:e,onStatusFilterChange:t,overviewQuery:n})}),(0,F.jsx)(d,{path:`/skills-library`,element:(0,F.jsx)(hg,{overviewQuery:n})}),(0,F.jsx)(d,{path:`/analytics`,element:(0,F.jsx)(bc,{})}),(0,F.jsx)(d,{path:`/skills/:name`,element:(0,F.jsx)(ng,{})}),(0,F.jsx)(d,{path:`/status`,element:(0,F.jsx)(Cg,{})})]})]}),(0,F.jsx)(yr,{})]})}function Eg(){return(0,F.jsx)(Dn,{client:wg,children:(0,F.jsx)(p,{children:(0,F.jsx)(Ks,{defaultTheme:`dark`,children:(0,F.jsxs)(pt,{children:[(0,F.jsx)(Tg,{}),!1]})})})})}(0,$e.createRoot)(document.getElementById(`root`)).render((0,F.jsx)(M.StrictMode,{children:(0,F.jsx)(Eg,{})}));
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>selftune — Dashboard</title>
|
|
7
7
|
<link rel="icon" type="image/png" href="/favicon.png" />
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-D8O-RG1I.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-Dw2cE7zH.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/vendor-react-CKkiCskZ.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/vendor-ui-CGEmUayx.js">
|
|
@@ -100,6 +100,10 @@ export interface EvolutionEntry {
|
|
|
100
100
|
action: string;
|
|
101
101
|
details: string;
|
|
102
102
|
eval_snapshot?: EvalSnapshot | null;
|
|
103
|
+
validation_mode?: "structural_guard" | "host_replay" | "llm_judge" | null;
|
|
104
|
+
validation_agent?: string | null;
|
|
105
|
+
validation_fixture_id?: string | null;
|
|
106
|
+
validation_evidence_ref?: string | null;
|
|
103
107
|
}
|
|
104
108
|
|
|
105
109
|
export interface UnmatchedQuery {
|