@ycodium-ai/plugin-tool-display 0.2.5763 → 0.2.5877

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/assets/ui.js CHANGED
@@ -362,22 +362,22 @@ var K=`/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */
362
362
  }
363
363
  }
364
364
  }
365
- `;var ge=window.__ycodiumPluginHost.react;var{Activity:Ye,Children:ea,Component:Ce,Fragment:he,Profiler:aa,PureComponent:ta,StrictMode:oa,Suspense:la,__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE:ra,__COMPILER_RUNTIME:ua,act:da,cache:sa,cacheSignal:fa,captureOwnerStack:ia,cloneElement:na,createContext:M,createElement:C,createRef:ca,forwardRef:R,isValidElement:pa,lazy:ma,memo:Se,startTransition:La,unstable_useCacheRefresh:xa,use:we,useActionState:Ia,useCallback:_,useContext:$,useDebugValue:ga,useDeferredValue:Ca,useEffect:ye,useEffectEvent:ha,useId:Sa,useImperativeHandle:wa,useInsertionEffect:H,useLayoutEffect:ya,useMemo:ke,useOptimistic:ka,useReducer:Pa,useRef:Pe,useState:q,useSyncExternalStore:Te,useTransition:Ta,version:ba}=ge;var Z=M(null),Q=Z.Provider;function w(){let e=$(Z);if(e===null)throw new Error("Tool display UI has not been registered.");return e}function be(e){return`__ycodium${e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")}Scope`}function Ae(e){let a=globalThis,t=be(e),o=(a[t]??0)+1;return a[t]=o,`ycodium-${e}-ui-${o}`}function E(e,a){let t=Ae(a),o=e.replaceAll(`.ycodium-${a}-ui`,`.${t}`),u=0,l=null;return{scopeClass:t,retain(){if(typeof document>"u")return()=>{};u===0&&(l=document.createElement("style"),l.setAttribute("data-ycodium-plugin-css",a),l.textContent=o,document.head.appendChild(l)),u+=1;let s=!1;return()=>{s||(s=!0,u=Math.max(0,u-1),u===0&&l!==null&&(l.remove(),l=null))}}}}var{jsx:r,jsxs:p,Fragment:N}=window.__ycodiumPluginHost.jsxRuntime;var Ga=M(null);var U=(...e)=>e.filter((a,t,o)=>!!a&&a.trim()!==""&&o.indexOf(a)===t).join(" ").trim();var J=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var j=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(a,t,o)=>o?o.toUpperCase():t.toLowerCase());var G=e=>{let a=j(e);return a.charAt(0).toUpperCase()+a.slice(1)};var Y={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var ee=e=>{for(let a in e)if(a.startsWith("aria-")||a==="role"||a==="title")return!0;return!1};var ae=R(({color:e="currentColor",size:a=24,strokeWidth:t=2,absoluteStrokeWidth:o,className:u="",children:l,iconNode:s,...i},f)=>C("svg",{ref:f,...Y,width:a,height:a,stroke:e,strokeWidth:o?Number(t)*24/Number(a):t,className:U("lucide",u),...!l&&!ee(i)&&{"aria-hidden":"true"},...i},[...s.map(([n,x])=>C(n,x)),...Array.isArray(l)?l:[l]]));var I=(e,a)=>{let t=R(({className:o,...u},l)=>C(ae,{ref:l,iconNode:a,className:U(`lucide-${J(G(e))}`,`lucide-${e}`,o),...u}));return t.displayName=G(e),t};var De=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],T=I("check",De);var Be=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],b=I("copy",Be);var ve=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],A=I("globe",ve);var Fe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],D=I("search",Fe);var Me=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],h=I("square-terminal",Me);var W="[a-zA-Z][a-zA-Z0-9:_-]*";var Re="ycodium",Rt=`${Re}:`,qt=new RegExp(String.raw`(^|\s)([$/])(${W})(?=\s|$)`,"g");var Ut=new RegExp(String.raw`([$/])(${W})(?=\s|$)`,"y");var Ot=new RegExp(String.raw`^/(${W})$`);function qe(e){let a=e.match(/:(\d+)$/);if(!a?.[1])return{path:e,line:void 0,column:void 0};let t=e.slice(0,-a[0].length),o=t.match(/:(\d+)$/);return o?.[1]?{path:t.slice(0,-o[0].length),line:o[1],column:a[1]}:{path:t,line:a[1],column:void 0}}function V(e){return e.replaceAll("\\","/")}function z(e){return/^\/[A-Za-z]:\//.test(e)?e.slice(1):e}function Ue(e){return z(V(e.replace(/[\\/]+$/,"")))}function Oe(e){return e.slice(e.lastIndexOf("/")+1)}function He(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}function Ee(e){return e.startsWith("\\\\")||/^[A-Za-z]:([/\\]|$)/.test(z(V(e)))}function y(e,a){let{path:t,line:o,column:u}=qe(e),l=z(V(t)),s=l;if(a){let i=Ue(a),f=Oe(i),n=Ee(a)?d=>d.toLowerCase():d=>d,x=n(l),m=n(i);if(x===m)s=f;else if(x.startsWith(`${m}/`))s=`${f}/${l.slice(i.length+1)}`;else if(!He(l)){let d=l.replace(/^\.\/+/,"").replace(/^\/+/,"");s=x.startsWith(`${n(f)}/`)?l:`${f}/${d}`}}return o?`${s}:${o}${u?`:${u}`:""}`:s}function g(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function B(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Ne({entry:e,details:a}){let t=a.input?.text??e.toolIo?.input;if(!t)return null;let o=B(t);return g(o)}function oe(e){let a=g(e.entry.toolData),t=e.entry.toolLabel?.name??a?.tool??e.entry.toolTitle??e.entry.label;return typeof t=="string"?t.toLowerCase().replace(/[ _-]/g,""):""}function le(e){return e.entry.toolLifecycleStatus==="completed"&&!e.entry.displayFailed&&(e.details.exitCode===void 0||e.details.exitCode===0)}function Ge(e,a){let t=e.entry.toolLabel?.path??a?.file_path;return typeof t=="string"&&t.trim()?y(t,e.workspaceRoot):null}function We(e){let{entry:a,details:t}=e;if(a.requestKind!=="command"&&a.itemType!=="command_execution")return null;let o=t.input?.text;return!o||t.raw?null:{kind:"terminal",command:o,output:t.output?.text??"",copyText:[o,t.output?.text].filter(u=>u!==void 0).join(`
365
+ `;var ge=window.__ycodiumPluginHost.react;var{Activity:Ye,Children:ea,Component:Ce,Fragment:he,Profiler:aa,PureComponent:ta,StrictMode:oa,Suspense:ra,__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE:la,__COMPILER_RUNTIME:ua,act:da,cache:sa,cacheSignal:fa,captureOwnerStack:ia,cloneElement:na,createContext:M,createElement:C,createRef:ca,forwardRef:R,isValidElement:pa,lazy:ma,memo:Se,startTransition:La,unstable_useCacheRefresh:xa,use:we,useActionState:Ia,useCallback:_,useContext:$,useDebugValue:ga,useDeferredValue:Ca,useEffect:ye,useEffectEvent:ha,useId:Sa,useImperativeHandle:wa,useInsertionEffect:H,useLayoutEffect:ya,useMemo:ke,useOptimistic:ka,useReducer:Pa,useRef:Pe,useState:q,useSyncExternalStore:Te,useTransition:Ta,version:ba}=ge;var Z=M(null),Q=Z.Provider;function w(){let e=$(Z);if(e===null)throw new Error("Tool display UI has not been registered.");return e}function be(e){return`__ycodium${e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")}Scope`}function Ae(e){let a=globalThis,t=be(e),o=(a[t]??0)+1;return a[t]=o,`ycodium-${e}-ui-${o}`}function E(e,a){let t=Ae(a),o=e.replaceAll(`.ycodium-${a}-ui`,`.${t}`),u=0,r=null;return{scopeClass:t,retain(){if(typeof document>"u")return()=>{};u===0&&(r=document.createElement("style"),r.setAttribute("data-ycodium-plugin-css",a),r.textContent=o,document.head.appendChild(r)),u+=1;let s=!1;return()=>{s||(s=!0,u=Math.max(0,u-1),u===0&&r!==null&&(r.remove(),r=null))}}}}var{jsx:l,jsxs:p,Fragment:N}=window.__ycodiumPluginHost.jsxRuntime;var Ga=M(null);var U=(...e)=>e.filter((a,t,o)=>!!a&&a.trim()!==""&&o.indexOf(a)===t).join(" ").trim();var J=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var j=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(a,t,o)=>o?o.toUpperCase():t.toLowerCase());var G=e=>{let a=j(e);return a.charAt(0).toUpperCase()+a.slice(1)};var Y={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var ee=e=>{for(let a in e)if(a.startsWith("aria-")||a==="role"||a==="title")return!0;return!1};var ae=R(({color:e="currentColor",size:a=24,strokeWidth:t=2,absoluteStrokeWidth:o,className:u="",children:r,iconNode:s,...i},f)=>C("svg",{ref:f,...Y,width:a,height:a,stroke:e,strokeWidth:o?Number(t)*24/Number(a):t,className:U("lucide",u),...!r&&!ee(i)&&{"aria-hidden":"true"},...i},[...s.map(([n,x])=>C(n,x)),...Array.isArray(r)?r:[r]]));var I=(e,a)=>{let t=R(({className:o,...u},r)=>C(ae,{ref:r,iconNode:a,className:U(`lucide-${J(G(e))}`,`lucide-${e}`,o),...u}));return t.displayName=G(e),t};var De=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],T=I("check",De);var Be=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],b=I("copy",Be);var ve=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],A=I("globe",ve);var Fe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],D=I("search",Fe);var Me=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],h=I("square-terminal",Me);var W="[a-zA-Z][a-zA-Z0-9:_-]*";var Re="ycodium",Rt=`${Re}:`,qt=new RegExp(String.raw`(^|\s)([$/])(${W})(?=\s|$)`,"g");var Ut=new RegExp(String.raw`([$/])(${W})(?=\s|$)`,"y");var Ot=new RegExp(String.raw`^/(${W})$`);function qe(e){let a=e.match(/:(\d+)$/);if(!a?.[1])return{path:e,line:void 0,column:void 0};let t=e.slice(0,-a[0].length),o=t.match(/:(\d+)$/);return o?.[1]?{path:t.slice(0,-o[0].length),line:o[1],column:a[1]}:{path:t,line:a[1],column:void 0}}function V(e){return e.replaceAll("\\","/")}function z(e){return/^\/[A-Za-z]:\//.test(e)?e.slice(1):e}function Ue(e){return z(V(e.replace(/[\\/]+$/,"")))}function Oe(e){return e.slice(e.lastIndexOf("/")+1)}function He(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}function Ee(e){return e.startsWith("\\\\")||/^[A-Za-z]:([/\\]|$)/.test(z(V(e)))}function y(e,a){let{path:t,line:o,column:u}=qe(e),r=z(V(t)),s=r;if(a){let i=Ue(a),f=Oe(i),n=Ee(a)?d=>d.toLowerCase():d=>d,x=n(r),m=n(i);if(x===m)s=f;else if(x.startsWith(`${m}/`))s=`${f}/${r.slice(i.length+1)}`;else if(!He(r)){let d=r.replace(/^\.\/+/,"").replace(/^\/+/,"");s=x.startsWith(`${n(f)}/`)?r:`${f}/${d}`}}return o?`${s}:${o}${u?`:${u}`:""}`:s}function g(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function B(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Ne({entry:e,details:a}){let t=a.input?.text??e.toolIo?.input;if(!t)return null;let o=B(t);return g(o)}function oe(e){let a=g(e.entry.toolData),t=e.entry.toolLabel?.name??a?.tool??e.entry.toolTitle??e.entry.label;return typeof t=="string"?t.toLowerCase().replace(/[ _-]/g,""):""}function re(e){return e.entry.toolLifecycleStatus==="completed"&&!e.entry.displayFailed&&(e.details.exitCode===void 0||e.details.exitCode===0)}function Ge(e,a){let t=e.entry.toolLabel?.path??a?.file_path;return typeof t=="string"&&t.trim()?y(t,e.workspaceRoot):null}function We(e){let{entry:a,details:t}=e;if(a.requestKind!=="command"&&a.itemType!=="command_execution")return null;let o=t.input?.text;return!o||t.raw?null:{kind:"terminal",command:o,output:t.output?.text??"",copyText:[o,t.output?.text].filter(u=>u!==void 0).join(`
366
366
 
367
- `)}}function Ve(e){let{entry:a,details:t}=e;if(a.requestKind!=="file-read"&&a.toolTitle!=="Read File"||a.displayFailed||t.raw||t.exitCode!==void 0&&t.exitCode!==0)return null;let o=Ge(e,Ne(e)),u=t.output?.text;if(!o||!u)return null;let l=[];for(let s of(u.endsWith(`
367
+ `)}}function Ve(e){let{entry:a,details:t}=e;if(a.requestKind!=="file-read"&&a.toolTitle!=="Read File"||a.displayFailed||t.raw||t.exitCode!==void 0&&t.exitCode!==0)return null;let o=Ge(e,Ne(e)),u=t.output?.text;if(!o||!u)return null;let r=[];for(let s of(u.endsWith(`
368
368
  `)?u.slice(0,-1):u).split(`
369
- `)){let i=/^\s*(\d+)→(.*)$/u.exec(s);if(!i)return null;let f=Number(i[1]);if(!Number.isSafeInteger(f)||f<1)return null;let n=l.at(-1);if(n&&f<=n.number)return null;l.push({number:f,text:i[2]})}return{kind:"read",path:o,lines:l,copyText:l.map(s=>s.text).join(`
370
- `)}}function ze(e){let{entry:a,details:t}=e;if(a.requestKind!=="file-change"&&a.itemType!=="file_change"||a.toolLifecycleStatus!=="completed"||a.displayFailed||t.exitCode!==void 0&&t.exitCode!==0)return null;let o=a.toolData;if(typeof o!="object"||o===null||Array.isArray(o))return null;let u=o.changes;if(!Array.isArray(u)||u.length===0)return null;let l=[];for(let[s,i]of u.entries()){if(typeof i!="object"||i===null||Array.isArray(i))return null;let{path:f,diff:n}=i;if(typeof f!="string"||!f.trim()||typeof n!="string"||!n)return null;let x=[],m=n.split(`
371
- `);for(let[d,c]of m.entries()){let L=c.startsWith("+++")||c.startsWith("---")?"context":c.startsWith("+")?"added":c.startsWith("-")?"removed":"context",X=x.at(-1);X?.kind===L?X.lines.push(c):x.push({line:d,kind:L,lines:[c]})}l.push({key:`${f}:${s}`,path:y(f,e.workspaceRoot),patch:n,parts:x})}return{kind:"change",files:l,copyText:l.map(s=>`${s.path}
369
+ `)){let i=/^\s*(\d+)→(.*)$/u.exec(s);if(!i)return null;let f=Number(i[1]);if(!Number.isSafeInteger(f)||f<1)return null;let n=r.at(-1);if(n&&f<=n.number)return null;r.push({number:f,text:i[2]})}return{kind:"read",path:o,lines:r,copyText:r.map(s=>s.text).join(`
370
+ `)}}function ze(e){let{entry:a,details:t}=e;if(a.requestKind!=="file-change"&&a.itemType!=="file_change"||a.toolLifecycleStatus!=="completed"||a.displayFailed||t.exitCode!==void 0&&t.exitCode!==0)return null;let o=a.toolData;if(typeof o!="object"||o===null||Array.isArray(o))return null;let u=o.changes;if(!Array.isArray(u)||u.length===0)return null;let r=[];for(let[s,i]of u.entries()){if(typeof i!="object"||i===null||Array.isArray(i))return null;let{path:f,diff:n}=i;if(typeof f!="string"||!f.trim()||typeof n!="string"||!n)return null;let x=[],m=n.split(`
371
+ `);for(let[d,c]of m.entries()){let L=c.startsWith("+++")||c.startsWith("---")?"context":c.startsWith("+")?"added":c.startsWith("-")?"removed":"context",X=x.at(-1);X?.kind===L?X.lines.push(c):x.push({line:d,kind:L,lines:[c]})}r.push({key:`${f}:${s}`,path:y(f,e.workspaceRoot),patch:n,parts:x})}return{kind:"change",files:r,copyText:r.map(s=>`${s.path}
372
372
  ${s.patch}`).join(`
373
373
 
374
- `)}}function Xe(e){if(!le(e))return null;let a=oe(e);if(a!=="grep"&&a!=="glob")return null;let t=e.details.output?.text;if(!t)return null;let o=g(B(e.details.input?.text??e.entry.toolIo?.input)),u=B(t),l=g(u),s=t.trimStart().startsWith("{")||t.trimStart().startsWith("[");if(l?.isError===!0||typeof l?.error=="string")return null;let i=typeof o?.pattern=="string"?o.pattern:e.entry.toolLabel?.detail??e.entry.label;if(a==="glob"){let m=l!==null||Array.isArray(u);if(!m&&s)return null;let d=l?l.filenames??l.paths:Array.isArray(u)?u:t.trim().split(`
375
- `);return!Array.isArray(d)||!d.every(c=>typeof c=="string"&&c.length>0)||!m&&!d.every(c=>/[/\\]|\.[a-z0-9]{1,12}$/i.test(c))?null:{kind:"search",resultKind:"paths",pattern:i,paths:d.map(c=>y(c,e.workspaceRoot)),copyText:t}}let f=typeof l?.content=="string"?l.content:t;if(l&&!Array.isArray(l.files)&&typeof l.content!="string"||!l&&s)return null;let n=new Map,x=(m,d,c)=>{let L=n.get(m)??[];L.push({line:d,text:c,key:`${d}:${L.length}`}),n.set(m,L)};if(Array.isArray(l?.files))for(let m of l.files){let d=g(m);if(typeof d?.path!="string"||!d.path||!Array.isArray(d.matches))return null;for(let c of d.matches){let L=g(c);if(typeof L?.lineNumber!="number"||!Number.isSafeInteger(L.lineNumber)||L.lineNumber<1||typeof L?.line!="string")return null;x(d.path,L.lineNumber,L.line)}}else for(let m of f.trimEnd().split(`
376
- `)){let d=/^(.+?):([1-9]\d*):(.*)$/u.exec(m);if(!d||!Number.isSafeInteger(Number(d[2])))return null;x(d[1],Number(d[2]),d[3])}return{kind:"search",resultKind:"matches",pattern:i,files:[...n].map(([m,d])=>({key:m,path:y(m,e.workspaceRoot),matches:d})),copyText:t}}function te(e){if(typeof e!="string")return null;try{let a=new URL(e);return(a.protocol==="http:"||a.protocol==="https:")&&!a.username&&!a.password?a.href:null}catch{return null}}function Ke(e){if(!le(e))return null;let a=oe(e);if(e.entry.itemType!=="web_search"&&a!=="websearch"&&a!=="webfetch"||a==="grep"||a==="glob")return null;let t=e.details.output?.text,o=B(t);if(!t)return null;let u=g(o);if(u?.isError===!0||typeof u?.error=="string")return null;let l=u?.sources??u?.results??(Array.isArray(o)?o:void 0),s=g(B(e.details.input?.text??e.entry.toolIo?.input)),i=typeof s?.query=="string"?s.query:e.entry.toolLabel?.detail??e.entry.label;if(Array.isArray(l)){let m=[];for(let d of l){let c=g(d),L=te(c?.url);if(!L||c?.title!==void 0&&typeof c.title!="string"||c?.snippet!==void 0&&typeof c.snippet!="string")return null;m.push({key:`${L}:${m.length}`,url:L,title:typeof c?.title=="string"?c.title:L,...typeof c?.snippet=="string"?{snippet:c.snippet}:{}})}return u?.answer!==void 0&&typeof u.answer!="string"?null:{kind:"web",query:i,sources:m,copyText:t,...typeof u?.answer=="string"?{answer:u.answer}:{}}}let f=te(u?.url),n=u?.statusCode;if(!f||typeof n!="number"||!Number.isInteger(n)||n<100||n>599)return null;let x=typeof u?.title=="string"?u.title:f;return{kind:"web",query:x,sources:[{key:f,url:f,title:x}],copyText:t,statusCode:n,...typeof u?.text=="string"?{answer:u.text}:{}}}var _e=[We,Ve,ze,Xe,Ke];function re(e){for(let a of _e){let t=a(e);if(t)return t}return null}function ue(e){return[e.input,e.output,e.raw].filter(a=>a!==void 0).map(a=>a.text).join(`
374
+ `)}}function Xe(e){if(!re(e))return null;let a=oe(e);if(a!=="grep"&&a!=="glob")return null;let t=e.details.output?.text;if(!t)return null;let o=g(B(e.details.input?.text??e.entry.toolIo?.input)),u=B(t),r=g(u),s=t.trimStart().startsWith("{")||t.trimStart().startsWith("[");if(r?.isError===!0||typeof r?.error=="string")return null;let i=typeof o?.pattern=="string"?o.pattern:e.entry.toolLabel?.detail??e.entry.label;if(a==="glob"){let m=r!==null||Array.isArray(u);if(!m&&s)return null;let d=r?r.filenames??r.paths:Array.isArray(u)?u:t.trim().split(`
375
+ `);return!Array.isArray(d)||!d.every(c=>typeof c=="string"&&c.length>0)||!m&&!d.every(c=>/[/\\]|\.[a-z0-9]{1,12}$/i.test(c))?null:{kind:"search",resultKind:"paths",pattern:i,paths:d.map(c=>y(c,e.workspaceRoot)),copyText:t}}let f=typeof r?.content=="string"?r.content:t;if(r&&!Array.isArray(r.files)&&typeof r.content!="string"||!r&&s)return null;let n=new Map,x=(m,d,c)=>{let L=n.get(m)??[];L.push({line:d,text:c,key:`${d}:${L.length}`}),n.set(m,L)};if(Array.isArray(r?.files))for(let m of r.files){let d=g(m);if(typeof d?.path!="string"||!d.path||!Array.isArray(d.matches))return null;for(let c of d.matches){let L=g(c);if(typeof L?.lineNumber!="number"||!Number.isSafeInteger(L.lineNumber)||L.lineNumber<1||typeof L?.line!="string")return null;x(d.path,L.lineNumber,L.line)}}else for(let m of f.trimEnd().split(`
376
+ `)){let d=/^(.+?):([1-9]\d*):(.*)$/u.exec(m);if(!d||!Number.isSafeInteger(Number(d[2])))return null;x(d[1],Number(d[2]),d[3])}return{kind:"search",resultKind:"matches",pattern:i,files:[...n].map(([m,d])=>({key:m,path:y(m,e.workspaceRoot),matches:d})),copyText:t}}function te(e){if(typeof e!="string")return null;try{let a=new URL(e);return(a.protocol==="http:"||a.protocol==="https:")&&!a.username&&!a.password?a.href:null}catch{return null}}function Ke(e){if(!re(e))return null;let a=oe(e);if(e.entry.itemType!=="web_search"&&a!=="websearch"&&a!=="webfetch"||a==="grep"||a==="glob")return null;let t=e.details.output?.text,o=B(t);if(!t)return null;let u=g(o);if(u?.isError===!0||typeof u?.error=="string")return null;let r=u?.sources??u?.results??(Array.isArray(o)?o:void 0),s=g(B(e.details.input?.text??e.entry.toolIo?.input)),i=typeof s?.query=="string"?s.query:e.entry.toolLabel?.detail??e.entry.label;if(Array.isArray(r)){let m=[];for(let d of r){let c=g(d),L=te(c?.url);if(!L||c?.title!==void 0&&typeof c.title!="string"||c?.snippet!==void 0&&typeof c.snippet!="string")return null;m.push({key:`${L}:${m.length}`,url:L,title:typeof c?.title=="string"?c.title:L,...typeof c?.snippet=="string"?{snippet:c.snippet}:{}})}return u?.answer!==void 0&&typeof u.answer!="string"?null:{kind:"web",query:i,sources:m,copyText:t,...typeof u?.answer=="string"?{answer:u.answer}:{}}}let f=te(u?.url),n=u?.statusCode;if(!f||typeof n!="number"||!Number.isInteger(n)||n<100||n>599)return null;let x=typeof u?.title=="string"?u.title:f;return{kind:"web",query:x,sources:[{key:f,url:f,title:x}],copyText:t,statusCode:n,...typeof u?.text=="string"?{answer:u.text}:{}}}var _e=[We,Ve,ze,Xe,Ke];function le(e){for(let a of _e){let t=a(e);if(t)return t}return null}function ue(e){return[e.input,e.output,e.raw].filter(a=>a!==void 0).map(a=>a.text).join(`
377
377
 
378
- `)}function v(...e){return e.filter(a=>typeof a=="string"&&a.length>0).join(" ")}function k(e){return(a=>C(w().ui[e],{...a,className:`ycodium-tool-display-ui ${typeof a.className=="string"?a.className:""}`}))}var O=k("Button"),de=k("Tooltip"),se=k("TooltipPopup"),fe=k("TooltipTrigger"),ie=k("Markdown"),ne=k("DetailViewport");function S(){return{t:w().i18n.usePluginTranslation()}}function ce({text:e}){let{t:a}=S(),t=w(),[o,u]=q(null),[l,s]=q(!1),i=o===e;return p("span",{className:"inline-flex items-center gap-1",children:[r(O,{type:"button",variant:"ghost-muted",size:"icon-xs","aria-label":a(i?"copied":"copy"),onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&f.stopPropagation()},onClick:()=>{Promise.resolve(t.writeClipboard(e)).then(()=>{u(e),s(!1)},()=>{s(!0),t.notify(a("copyFailed"),"error")})},children:i?r(T,{"aria-hidden":!0,className:"size-icon-1"}):r(b,{"aria-hidden":!0,className:"size-icon-1"})}),l?r("span",{role:"status",className:"tool-meta text-destructive-foreground",children:a("copyFailed")}):null]})}var pe=new Map;function P(e){pe.set(e.kind,e)}function me(e){return pe.get(e.kind)}function F({text:e}){return p(de,{children:[r(fe,{render:r("code",{className:"min-w-0 truncate text-foreground"}),children:e}),r(se,{className:"max-w-lg whitespace-pre-wrap break-words",children:e})]})}function $e({model:e}){let{t:a}=S();if(e.resultKind==="paths")return e.paths.length===0?r("p",{className:"px-2 pb-2 text-muted-foreground",children:a("noSearchResults")}):r("pre",{className:"tool-body whitespace-pre-wrap break-words px-2 pb-2 text-foreground",children:e.paths.slice(0,16).join(`
379
- `)});let t=16;return r("div",{className:"tool-body px-2 pb-2",children:e.files.length===0?r("p",{className:"text-muted-foreground",children:a("noSearchResults")}):e.files.map(o=>{let u=o.matches.slice(0,t);return t-=u.length,u.length===0?null:p("div",{"data-search-file":o.path,className:"mb-2 last:mb-0",children:[r("p",{className:"break-all font-medium text-foreground",children:o.path}),u.map(l=>p("div",{"data-search-line":l.line,className:"grid grid-cols-[3.5em_minmax(0,1fr)]",children:[r("span",{"aria-hidden":!0,className:"pe-3 text-end text-muted-foreground tabular-nums select-none",children:l.line}),r("span",{className:"whitespace-pre-wrap break-words text-foreground [overflow-wrap:anywhere]",children:l.text||`
380
- `})]},l.key))]},o.key)})})}function Ze({model:e,context:a}){let{t}=S();return p("div",{className:"space-y-2 px-2 pb-2 text-foreground",children:[e.statusCode!==void 0?r("p",{className:v("tool-meta",e.statusCode>=400&&"text-destructive-foreground"),children:t("httpStatus",{status:e.statusCode})}):null,e.answer?r("p",{className:"tool-process-text line-clamp-3 whitespace-pre-wrap",children:e.answer}):null,e.sources.length===0?r("p",{className:"tool-process-text text-muted-foreground",children:t("noWebSources")}):e.sources.slice(0,8).map(o=>p("div",{"data-web-source":o.url,className:"space-y-0.5",children:[o.title!==e.query?r("p",{className:"tool-process-text font-medium",children:o.title}):null,r(ie,{text:`<${o.url}>`,className:"tool-meta [&_p]:my-0",...a.threadRef===void 0?{}:{threadRef:a.threadRef},...a.workspaceRoot===void 0?{}:{cwd:a.workspaceRoot}}),o.snippet?r("p",{className:"tool-meta line-clamp-3 whitespace-pre-wrap text-muted-foreground",children:o.snippet}):null]},o.key))]})}P({kind:"terminal",heading:e=>p("span",{className:"flex min-w-0 items-center gap-2 text-foreground",children:[r(h,{"aria-hidden":!0,className:"size-4 shrink-0 text-muted-foreground"}),r(F,{text:e.command})]}),body:e=>r("pre",{className:"tool-body cursor-text whitespace-pre-wrap break-words px-2 pb-2 text-foreground select-text [overflow-wrap:anywhere]",children:e.output})});P({kind:"read",hiddenLines:e=>Math.max(0,e.lines.length-16),heading:e=>r(F,{text:e.path}),body:e=>r("div",{className:"tool-body cursor-text pb-2 text-foreground select-text",children:(e.lines.length>16?[...e.lines.slice(0,8),null,...e.lines.slice(-8)]:e.lines).map(a=>a===null?r("div",{"aria-hidden":!0,className:"ps-[3.5em] text-muted-foreground",children:"\u2026"},"gap"):p("div",{"data-source-line":a.number,className:"grid grid-cols-[3.5em_minmax(0,1fr)]",children:[r("span",{"aria-hidden":!0,className:"pe-3 text-end text-muted-foreground select-none tabular-nums",children:a.number}),r("span",{className:"whitespace-pre-wrap break-words pe-2 [overflow-wrap:anywhere]",children:a.text||`
381
- `})]},a.number))})});P({kind:"change",heading:e=>r(F,{text:e.files.map(a=>a.path).join(", ")}),body:e=>r("div",{className:"tool-body cursor-text pb-2 select-text",children:e.files.map(a=>p("div",{children:[e.files.length>1?r("p",{className:"px-2 py-1 text-foreground",children:a.path}):null,a.parts.length>64?r("pre",{className:"whitespace-pre-wrap break-words px-2 text-foreground [overflow-wrap:anywhere]",children:a.patch}):a.parts.map(t=>r("pre",{"data-change-line":t.kind,className:v("whitespace-pre-wrap break-words px-2 [overflow-wrap:anywhere]",t.kind==="removed"?"bg-destructive/5 text-destructive-foreground":t.kind==="added"?"bg-success/5 text-success-foreground":"text-muted-foreground"),children:t.lines.join(`
382
- `)},t.line))]},a.key))})});P({kind:"search",hasMoreResults:e=>e.resultKind==="paths"?e.paths.length>16:e.files.reduce((a,t)=>a+t.matches.length,0)>16,heading:e=>p("span",{className:"flex min-w-0 items-center gap-2",children:[r(D,{"aria-hidden":!0,className:"size-4 shrink-0"}),r(F,{text:e.pattern})]}),body:e=>r($e,{model:e})});P({kind:"web",hasMoreResults:e=>e.sources.length>8,heading:e=>p("span",{className:"flex min-w-0 items-center gap-2",children:[r(A,{"aria-hidden":!0,className:"size-4 shrink-0"}),r(F,{text:e.query})]}),body:(e,a)=>r(Ze,{model:e,context:a})});function Qe({text:e}){return r("pre",{className:"tool-body cursor-text whitespace-pre-wrap break-words px-2 pb-2 text-foreground select-text [overflow-wrap:anywhere]",children:e})}function Le({retain:e}){return H(()=>e(),[e]),null}function xe(e){let{t:a}=S(),t=re(e),o=t?me(t):void 0,u=t&&o?.hiddenLines?o.hiddenLines(t):0,l=t&&o?.hasMoreResults?o.hasMoreResults(t):!1,s=[e.details.input,e.details.output,e.details.raw].filter(n=>n!==void 0),i=t?.copyText??ue(e.details);if(!i&&!t)return null;let f=e.details.files.length>0&&t?.kind!=="change"&&t?.kind!=="search";return p("div",{className:v("ycodium-tool-display-ui",e.scopeClass,"min-w-0 rounded-md bg-background/60"),"data-tool-overview":!0,"data-tool-overview-kind":t?.kind??"generic",children:[p("div",{className:"tool-meta flex min-h-8 items-center gap-2 px-2 text-muted-foreground",children:[r("span",{className:"min-w-0 flex-1",children:t&&o?o.heading(t):null}),e.summary?r("span",{children:a("summary")}):null,s.some(n=>n.truncated)?r("span",{children:a("truncated")}):null,r(ce,{text:i})]}),r(ne,{threadKey:e.threadKey??"unscoped",stateKey:`${e.stateKey??e.entry.id}:overview`,maxHeight:"8lh",className:"tool-body",followTail:e.followOutputTail===!0,...e.onDisclosureChange===void 0?{}:{onDisclosureChange:e.onDisclosureChange},children:t&&o?o.body(t,e):r(Qe,{text:i})}),u||l?r(O,{size:"xs",variant:"ghost-muted",className:"m-1",disabled:e.onShowOutput===void 0,onClick:e.onShowOutput,children:u?a("showMoreLines",{count:u}):a("showAllResults")}):null,f?r("div",{className:"min-w-0 px-2 pb-2",children:r("pre",{className:"tool-body whitespace-pre-wrap break-words text-foreground select-text",children:e.details.files.join(`
383
- `)})}):null]})}function Je(e){if(["Button","Tooltip","TooltipTrigger","TooltipPopup","Markdown","DetailViewport"].some(u=>e.ui[u]===void 0)){let u=function(){let l=e.i18n.usePluginTranslation();return r("p",{role:"status",className:"p-3 text-sm text-muted-foreground",children:l("hostUpgradeRequired")})};var o=u;return{pages:{},panels:{},views:{toolCall:u}}}let t=E(K,"tool-display");return{pages:{},panels:{},views:{toolCall:function(l){return p(Q,{value:e,children:[r(Le,{retain:t.retain}),r(xe,{...l,scopeClass:t.scopeClass})]})}}}}export{Je as default};
378
+ `)}function v(...e){return e.filter(a=>typeof a=="string"&&a.length>0).join(" ")}function k(e){return(a=>C(w().ui[e],{...a,className:`ycodium-tool-display-ui ${typeof a.className=="string"?a.className:""}`}))}var O=k("Button"),de=k("Tooltip"),se=k("TooltipPopup"),fe=k("TooltipTrigger"),ie=k("Markdown"),ne=k("DetailViewport");function S(){return{t:w().i18n.usePluginTranslation()}}function ce({text:e}){let{t:a}=S(),t=w(),[o,u]=q(null),[r,s]=q(!1),i=o===e;return p("span",{className:"inline-flex items-center gap-1",children:[l(O,{type:"button",variant:"ghost-muted",size:"icon-xs","aria-label":a(i?"copied":"copy"),onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&f.stopPropagation()},onClick:()=>{Promise.resolve(t.writeClipboard(e)).then(()=>{u(e),s(!1)},()=>{s(!0),t.notify(a("copyFailed"),"error")})},children:i?l(T,{"aria-hidden":!0,className:"size-icon-1"}):l(b,{"aria-hidden":!0,className:"size-icon-1"})}),r?l("span",{role:"status",className:"tool-meta text-destructive-foreground",children:a("copyFailed")}):null]})}var pe=new Map;function P(e){pe.set(e.kind,e)}function me(e){return pe.get(e.kind)}function F({text:e}){return p(de,{children:[l(fe,{render:l("code",{className:"min-w-0 truncate text-foreground"}),children:e}),l(se,{className:"max-w-lg whitespace-pre-wrap break-words",children:e})]})}function $e({model:e}){let{t:a}=S();if(e.resultKind==="paths")return e.paths.length===0?l("p",{className:"px-2 pb-2 text-muted-foreground",children:a("noSearchResults")}):l("pre",{className:"tool-body whitespace-pre-wrap break-words px-2 pb-2 text-foreground",children:e.paths.slice(0,16).join(`
379
+ `)});let t=16;return l("div",{className:"tool-body px-2 pb-2",children:e.files.length===0?l("p",{className:"text-muted-foreground",children:a("noSearchResults")}):e.files.map(o=>{let u=o.matches.slice(0,t);return t-=u.length,u.length===0?null:p("div",{"data-search-file":o.path,className:"mb-2 last:mb-0",children:[l("p",{className:"break-all font-medium text-foreground",children:o.path}),u.map(r=>p("div",{"data-search-line":r.line,className:"grid grid-cols-[3.5em_minmax(0,1fr)]",children:[l("span",{"aria-hidden":!0,className:"pe-3 text-end text-muted-foreground tabular-nums select-none",children:r.line}),l("span",{className:"whitespace-pre-wrap break-words text-foreground [overflow-wrap:anywhere]",children:r.text||`
380
+ `})]},r.key))]},o.key)})})}function Ze({model:e,context:a}){let{t}=S();return p("div",{className:"space-y-2 px-2 pb-2 text-foreground",children:[e.statusCode!==void 0?l("p",{className:v("tool-meta",e.statusCode>=400&&"text-destructive-foreground"),children:t("httpStatus",{status:e.statusCode})}):null,e.answer?l("p",{className:"tool-process-text line-clamp-3 whitespace-pre-wrap",children:e.answer}):null,e.sources.length===0?l("p",{className:"tool-process-text text-muted-foreground",children:t("noWebSources")}):e.sources.slice(0,8).map(o=>p("div",{"data-web-source":o.url,className:"space-y-0.5",children:[o.title!==e.query?l("p",{className:"tool-process-text font-medium",children:o.title}):null,l(ie,{text:`<${o.url}>`,className:"tool-meta [&_p]:my-0",...a.threadRef===void 0?{}:{threadRef:a.threadRef},...a.workspaceRoot===void 0?{}:{cwd:a.workspaceRoot}}),o.snippet?l("p",{className:"tool-meta line-clamp-3 whitespace-pre-wrap text-muted-foreground",children:o.snippet}):null]},o.key))]})}P({kind:"terminal",heading:e=>p("span",{className:"flex min-w-0 items-center gap-2 text-foreground",children:[l(h,{"aria-hidden":!0,className:"size-4 shrink-0 text-muted-foreground"}),l(F,{text:e.command})]}),body:e=>l("pre",{className:"tool-body cursor-text whitespace-pre-wrap break-words px-2 pb-2 text-foreground select-text [overflow-wrap:anywhere]",children:e.output})});P({kind:"read",hiddenLines:e=>Math.max(0,e.lines.length-16),heading:e=>l(F,{text:e.path}),body:e=>l("div",{className:"tool-body cursor-text pb-2 text-foreground select-text",children:(e.lines.length>16?[...e.lines.slice(0,8),null,...e.lines.slice(-8)]:e.lines).map(a=>a===null?l("div",{"aria-hidden":!0,className:"ps-[3.5em] text-muted-foreground",children:"\u2026"},"gap"):p("div",{"data-source-line":a.number,className:"grid grid-cols-[3.5em_minmax(0,1fr)]",children:[l("span",{"aria-hidden":!0,className:"pe-3 text-end text-muted-foreground select-none tabular-nums",children:a.number}),l("span",{className:"whitespace-pre-wrap break-words pe-2 [overflow-wrap:anywhere]",children:a.text||`
381
+ `})]},a.number))})});P({kind:"change",heading:e=>l(F,{text:e.files.map(a=>a.path).join(", ")}),body:e=>l("div",{className:"tool-body cursor-text pb-2 select-text",children:e.files.map(a=>p("div",{children:[e.files.length>1?l("p",{className:"px-2 py-1 text-foreground",children:a.path}):null,a.parts.length>64?l("pre",{className:"whitespace-pre-wrap break-words px-2 text-foreground [overflow-wrap:anywhere]",children:a.patch}):a.parts.map(t=>l("pre",{"data-change-line":t.kind,className:v("whitespace-pre-wrap break-words px-2 [overflow-wrap:anywhere]",t.kind==="removed"?"bg-destructive/5 text-destructive-foreground":t.kind==="added"?"bg-success/5 text-success-foreground":"text-muted-foreground"),children:t.lines.join(`
382
+ `)},t.line))]},a.key))})});P({kind:"search",hasMoreResults:e=>e.resultKind==="paths"?e.paths.length>16:e.files.reduce((a,t)=>a+t.matches.length,0)>16,heading:e=>p("span",{className:"flex min-w-0 items-center gap-2",children:[l(D,{"aria-hidden":!0,className:"size-4 shrink-0"}),l(F,{text:e.pattern})]}),body:e=>l($e,{model:e})});P({kind:"web",hasMoreResults:e=>e.sources.length>8,heading:e=>p("span",{className:"flex min-w-0 items-center gap-2",children:[l(A,{"aria-hidden":!0,className:"size-4 shrink-0"}),l(F,{text:e.query})]}),body:(e,a)=>l(Ze,{model:e,context:a})});function Qe({text:e}){return l("pre",{className:"tool-body cursor-text whitespace-pre-wrap break-words px-2 pb-2 text-foreground select-text [overflow-wrap:anywhere]",children:e})}function Le({retain:e}){return H(()=>e(),[e]),null}function xe(e){let{t:a}=S(),t=le(e),o=t?me(t):void 0,u=t&&o?.hiddenLines?o.hiddenLines(t):0,r=t&&o?.hasMoreResults?o.hasMoreResults(t):!1,s=[e.details.input,e.details.output,e.details.raw].filter(n=>n!==void 0),i=t?.copyText??ue(e.details);if(!i&&!t)return null;let f=e.details.files.length>0&&t?.kind!=="change"&&t?.kind!=="search";return p("div",{className:v("ycodium-tool-display-ui",e.scopeClass,"min-w-0 rounded-md bg-background/60"),"data-tool-overview":!0,"data-tool-overview-kind":t?.kind??"generic",children:[p("div",{className:"tool-meta flex min-h-8 items-center gap-2 px-2 text-muted-foreground",children:[l("span",{className:"min-w-0 flex-1",children:t&&o?o.heading(t):null}),e.summary?l("span",{children:a("summary")}):null,s.some(n=>n.truncated)?l("span",{children:a("truncated")}):null,l(ce,{text:i})]}),l(ne,{threadKey:e.threadKey??"unscoped",stateKey:`${e.stateKey??e.entry.id}:overview`,maxHeight:"8lh",className:"tool-body",followTail:e.followOutputTail===!0,...e.onDisclosureChange===void 0?{}:{onDisclosureChange:e.onDisclosureChange},children:t&&o?o.body(t,e):l(Qe,{text:i})}),u||r?l(O,{size:"xs",variant:"ghost-muted",className:"m-1",disabled:e.onShowOutput===void 0,onClick:e.onShowOutput,children:u?a("showMoreLines",{count:u}):a("showAllResults")}):null,f?l("div",{className:"min-w-0 px-2 pb-2",children:l("pre",{className:"tool-body whitespace-pre-wrap break-words text-foreground select-text",children:e.details.files.join(`
383
+ `)})}):null]})}function Je(e){if(["Button","Tooltip","TooltipTrigger","TooltipPopup","Markdown","DetailViewport"].some(u=>e.ui[u]===void 0)){let u=function(){let r=e.i18n.usePluginTranslation();return l("p",{role:"status",className:"p-3 text-sm text-muted-foreground",children:r("hostUpgradeRequired")})};var o=u;return{pages:{},panels:{},views:{toolCall:u}}}let t=E(K,"tool-display");return{pages:{},panels:{},views:{toolCall:function(r){return p(Q,{value:e,children:[l(Le,{retain:t.retain}),l(xe,{...r,scopeClass:t.scopeClass})]})}}}}export{Je as default};
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { definePlugin } from "@ycodium-ai/plugin-api";
3
3
 
4
4
  // ../../packages/plugin-api/src/version.ts
5
- var PLUGIN_API_VERSION = 181;
5
+ var PLUGIN_API_VERSION = 184;
6
6
 
7
7
  // src/index.ts
8
8
  import { TOOL_DISPLAY_PLUGIN_ID } from "@ycodium-ai/plugin-api/tool-display";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/plugin-tool-display",
3
- "version": "0.2.5763",
3
+ "version": "0.2.5877",
4
4
  "description": "Renders command, read, change, search, and web tool calls from recorded facts.",
5
5
  "keywords": [
6
6
  "ycodium",
@@ -35,8 +35,8 @@
35
35
  "tailwindcss": "^4.0.0",
36
36
  "typescript": "~6.0.3",
37
37
  "vite-plus": "0.2.2",
38
- "ycodium-plugin-testing": "0.0.0",
39
- "@ycodium-ai/plugin-api": "0.2.5763"
38
+ "@ycodium-ai/plugin-api": "0.2.5877",
39
+ "ycodium-plugin-testing": "0.0.0"
40
40
  },
41
41
  "ycodium": {
42
42
  "plugin": "./dist/index.js",