@ycodium-ai/plugin-tool-display 0.2.2880 → 0.2.2882

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
@@ -1,4 +1,4 @@
1
- var W=`/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */
1
+ var E=`/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */
2
2
  @layer properties, theme, base, components, utilities;
3
3
  @layer properties;
4
4
  @layer utilities {
@@ -212,22 +212,22 @@ var W=`/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */
212
212
  }
213
213
  }
214
214
  }
215
- `;var Le=window.__ycodiumPluginHost.react;var{Activity:Ve,Children:ze,Component:Ne,Fragment:Xe,Profiler:Ke,PureComponent:Ze,StrictMode:_e,Suspense:Qe,__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE:Je,__COMPILER_RUNTIME:$e,act:je,cache:Ye,cacheSignal:ea,captureOwnerStack:aa,cloneElement:ta,createContext:V,createElement:g,createRef:oa,forwardRef:b,isValidElement:ua,lazy:la,memo:da,startTransition:ra,unstable_useCacheRefresh:sa,use:fa,useActionState:ia,useCallback:na,useContext:z,useDebugValue:ca,useDeferredValue:pa,useEffect:ma,useEffectEvent:La,useId:Ia,useImperativeHandle:xa,useInsertionEffect:N,useLayoutEffect:Ca,useMemo:ha,useOptimistic:ga,useReducer:Sa,useRef:wa,useState:U,useSyncExternalStore:ka,useTransition:ya,version:Pa}=Le;var X=V(null),K=X.Provider;function w(){let e=z(X);if(e===null)throw new Error("Tool display UI has not been registered.");return e}var Ie=".ycodium-tool-display-ui";function xe(){let e=globalThis,a=(e.__ycodiumToolDisplayScope??0)+1;return e.__ycodiumToolDisplayScope=a,`ycodium-tool-display-ui-${a}`}function Z(e,a="tool-display"){let t=xe(),o=e.replaceAll(Ie,`.${t}`),u=0,l=null;return{scopeClass:t,retain(){return typeof document>"u"?()=>{}:(u===0&&(l=document.createElement("style"),l.setAttribute("data-ycodium-plugin-css",a),l.textContent=o,document.head.appendChild(l)),u+=1,()=>{u-=1,u===0&&l!==null&&(l.remove(),l=null)})}}}function C(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function P(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Ce({entry:e,details:a}){let t=a.input?.text??e.toolIo?.input;if(!t)return null;let o=P(t);return C(o)}function Q(e){let a=C(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 J(e){return e.entry.toolLifecycleStatus==="completed"&&!e.entry.displayFailed&&(e.details.exitCode===void 0||e.details.exitCode===0)}function he(e){let a=e,t=a.match(/:(\d+)$/);if(!t?.[1])return{path:a,line:void 0,column:void 0};let o=t[1];a=a.slice(0,-t[0].length);let u=a.match(/:(\d+)$/);return u?.[1]?{path:a.slice(0,-u[0].length),line:u[1],column:o}:{path:a,line:o,column:void 0}}function O(e){return e.replaceAll("\\","/")}function H(e){return/^\/[A-Za-z]:\//.test(e)?e.slice(1):e}function ge(e){return e.replace(/[\\/]+$/,"")}function Se(e){let a=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return a>=0?e.slice(a+1):e}function we(e){return e.replace(/^\.\/+/,"").replace(/^\/+/,"")}function ke(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}function ye(e){return e.startsWith("\\\\")||/^[A-Za-z]:([/\\]|$)/.test(H(O(e)))}function R(e,a){let{path:t,line:o,column:u}=he(e),l=H(O(t)),i=l;if(a){let f=H(O(ge(a))),r=Se(f),n=ye(a),I=n?l.toLowerCase():l,p=n?f.toLowerCase():f,c=`${p}/`,s=`${n?r.toLowerCase():r}/`;if(I===p)i=r;else if(I.startsWith(c))i=`${r}/${l.slice(f.length+1)}`;else if(!ke(l)){let m=we(l);i=I.startsWith(s)?l:`${r}/${m}`}}return o?`${i}:${o}${u?`:${u}`:""}`:i}function Pe(e,a){let t=e.entry.toolLabel?.path??a?.file_path;return typeof t=="string"&&t.trim()?R(t,e.workspaceRoot):null}function Ae(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(`
215
+ `;var Le=window.__ycodiumPluginHost.react;var{Activity:Ee,Children:Ve,Component:ze,Fragment:Ne,Profiler:Xe,PureComponent:Ke,StrictMode:Ze,Suspense:_e,__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE:Qe,__COMPILER_RUNTIME:Je,act:$e,cache:je,cacheSignal:Ye,captureOwnerStack:ea,cloneElement:aa,createContext:V,createElement:g,createRef:ta,forwardRef:R,isValidElement:oa,lazy:ua,memo:la,startTransition:da,unstable_useCacheRefresh:ra,use:sa,useActionState:fa,useCallback:ia,useContext:z,useDebugValue:na,useDeferredValue:ca,useEffect:pa,useEffectEvent:ma,useId:La,useImperativeHandle:Ia,useInsertionEffect:N,useLayoutEffect:xa,useMemo:Ca,useOptimistic:ha,useReducer:ga,useRef:Sa,useState:U,useSyncExternalStore:wa,useTransition:ka,version:ya}=Le;var X=V(null),K=X.Provider;function w(){let e=z(X);if(e===null)throw new Error("Tool display UI has not been registered.");return e}var Ie=".ycodium-tool-display-ui";function xe(){let e=globalThis,a=(e.__ycodiumToolDisplayScope??0)+1;return e.__ycodiumToolDisplayScope=a,`ycodium-tool-display-ui-${a}`}function Z(e,a="tool-display"){let t=xe(),o=e.replaceAll(Ie,`.${t}`),l=0,u=null;return{scopeClass:t,retain(){return typeof document>"u"?()=>{}:(l===0&&(u=document.createElement("style"),u.setAttribute("data-ycodium-plugin-css",a),u.textContent=o,document.head.appendChild(u)),l+=1,()=>{l-=1,l===0&&u!==null&&(u.remove(),u=null)})}}}function Ce(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 O(e){return e.replaceAll("\\","/")}function H(e){return/^\/[A-Za-z]:\//.test(e)?e.slice(1):e}function he(e){return H(O(e.replace(/[\\/]+$/,"")))}function ge(e){return e.slice(e.lastIndexOf("/")+1)}function Se(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}function we(e){return e.startsWith("\\\\")||/^[A-Za-z]:([/\\]|$)/.test(H(O(e)))}function P(e,a){let{path:t,line:o,column:l}=Ce(e),u=H(O(t)),f=u;if(a){let i=he(a),s=ge(i),n=we(a)?r=>r.toLowerCase():r=>r,I=n(u),p=n(i);if(I===p)f=s;else if(I.startsWith(`${p}/`))f=`${s}/${u.slice(i.length+1)}`;else if(!Se(u)){let r=u.replace(/^\.\/+/,"").replace(/^\/+/,"");f=I.startsWith(`${n(s)}/`)?u:`${s}/${r}`}}return o?`${f}:${o}${l?`:${l}`:""}`:f}function C(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function A(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function ke({entry:e,details:a}){let t=a.input?.text??e.toolIo?.input;if(!t)return null;let o=A(t);return C(o)}function Q(e){let a=C(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 J(e){return e.entry.toolLifecycleStatus==="completed"&&!e.entry.displayFailed&&(e.details.exitCode===void 0||e.details.exitCode===0)}function ye(e,a){let t=e.entry.toolLabel?.path??a?.file_path;return typeof t=="string"&&t.trim()?P(t,e.workspaceRoot):null}function Pe(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(l=>l!==void 0).join(`
216
216
 
217
- `)}}function De(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=Pe(e,Ce(e)),u=t.output?.text;if(!o||!u)return null;let l=[];for(let i of(u.endsWith(`
218
- `)?u.slice(0,-1):u).split(`
219
- `)){let f=/^\s*(\d+)→(.*)$/u.exec(i);if(!f)return null;let r=Number(f[1]);if(!Number.isSafeInteger(r)||r<1)return null;let n=l.at(-1);if(n&&r<=n.number)return null;l.push({number:r,text:f[2]})}return{kind:"read",path:o,lines:l,copyText:l.map(i=>i.text).join(`
220
- `)}}function Be(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[i,f]of u.entries()){if(typeof f!="object"||f===null||Array.isArray(f))return null;let{path:r,diff:n}=f;if(typeof r!="string"||!r.trim()||typeof n!="string"||!n)return null;let I=[],p=n.split(`
221
- `);for(let[c,s]of p.entries()){let m=s.startsWith("+++")||s.startsWith("---")?"context":s.startsWith("+")?"added":s.startsWith("-")?"removed":"context",E=I.at(-1);E?.kind===m?E.lines.push(s):I.push({line:c,kind:m,lines:[s]})}l.push({key:`${r}:${i}`,path:R(r,e.workspaceRoot),patch:n,parts:I})}return{kind:"change",files:l,copyText:l.map(i=>`${i.path}
222
- ${i.patch}`).join(`
217
+ `)}}function Ae(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=ye(e,ke(e)),l=t.output?.text;if(!o||!l)return null;let u=[];for(let f of(l.endsWith(`
218
+ `)?l.slice(0,-1):l).split(`
219
+ `)){let i=/^\s*(\d+)→(.*)$/u.exec(f);if(!i)return null;let s=Number(i[1]);if(!Number.isSafeInteger(s)||s<1)return null;let n=u.at(-1);if(n&&s<=n.number)return null;u.push({number:s,text:i[2]})}return{kind:"read",path:o,lines:u,copyText:u.map(f=>f.text).join(`
220
+ `)}}function De(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 l=o.changes;if(!Array.isArray(l)||l.length===0)return null;let u=[];for(let[f,i]of l.entries()){if(typeof i!="object"||i===null||Array.isArray(i))return null;let{path:s,diff:n}=i;if(typeof s!="string"||!s.trim()||typeof n!="string"||!n)return null;let I=[],p=n.split(`
221
+ `);for(let[r,c]of p.entries()){let m=c.startsWith("+++")||c.startsWith("---")?"context":c.startsWith("+")?"added":c.startsWith("-")?"removed":"context",W=I.at(-1);W?.kind===m?W.lines.push(c):I.push({line:r,kind:m,lines:[c]})}u.push({key:`${s}:${f}`,path:P(s,e.workspaceRoot),patch:n,parts:I})}return{kind:"change",files:u,copyText:u.map(f=>`${f.path}
222
+ ${f.patch}`).join(`
223
223
 
224
- `)}}function Te(e){if(!J(e))return null;let a=Q(e);if(a!=="grep"&&a!=="glob")return null;let t=e.details.output?.text;if(!t)return null;let o=C(P(e.details.input?.text??e.entry.toolIo?.input)),u=P(t),l=C(u),i=t.trimStart().startsWith("{")||t.trimStart().startsWith("[");if(l?.isError===!0||typeof l?.error=="string")return null;let f=typeof o?.pattern=="string"?o.pattern:e.entry.toolLabel?.detail??e.entry.label;if(a==="glob"){let p=l!==null||Array.isArray(u);if(!p&&i)return null;let c=l?l.filenames??l.paths:Array.isArray(u)?u:t.trim().split(`
225
- `);return!Array.isArray(c)||!c.every(s=>typeof s=="string"&&s.length>0)||!p&&!c.every(s=>/[/\\]|\.[a-z0-9]{1,12}$/i.test(s))?null:{kind:"search",resultKind:"paths",pattern:f,paths:c.map(s=>R(s,e.workspaceRoot)),copyText:t}}let r=typeof l?.content=="string"?l.content:t;if(l&&!Array.isArray(l.files)&&typeof l.content!="string"||!l&&i)return null;let n=new Map,I=(p,c,s)=>{let m=n.get(p)??[];m.push({line:c,text:s,key:`${c}:${m.length}`}),n.set(p,m)};if(Array.isArray(l?.files))for(let p of l.files){let c=C(p);if(typeof c?.path!="string"||!c.path||!Array.isArray(c.matches))return null;for(let s of c.matches){let m=C(s);if(typeof m?.lineNumber!="number"||!Number.isSafeInteger(m.lineNumber)||m.lineNumber<1||typeof m?.line!="string")return null;I(c.path,m.lineNumber,m.line)}}else for(let p of r.trimEnd().split(`
226
- `)){let c=/^(.+?):([1-9]\d*):(.*)$/u.exec(p);if(!c||!Number.isSafeInteger(Number(c[2])))return null;I(c[1],Number(c[2]),c[3])}return{kind:"search",resultKind:"matches",pattern:f,files:[...n].map(([p,c])=>({key:p,path:R(p,e.workspaceRoot),matches:c})),copyText:t}}function _(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 Fe(e){if(!J(e))return null;let a=Q(e);if(e.entry.itemType!=="web_search"&&a!=="websearch"&&a!=="webfetch"||a==="grep"||a==="glob")return null;let t=e.details.output?.text,o=P(t);if(!t)return null;let u=C(o);if(u?.isError===!0||typeof u?.error=="string")return null;let l=u?.sources??u?.results??(Array.isArray(o)?o:void 0),i=C(P(e.details.input?.text??e.entry.toolIo?.input)),f=typeof i?.query=="string"?i.query:e.entry.toolLabel?.detail??e.entry.label;if(Array.isArray(l)){let p=[];for(let c of l){let s=C(c),m=_(s?.url);if(!m||s?.title!==void 0&&typeof s.title!="string"||s?.snippet!==void 0&&typeof s.snippet!="string")return null;p.push({key:`${m}:${p.length}`,url:m,title:typeof s?.title=="string"?s.title:m,...typeof s?.snippet=="string"?{snippet:s.snippet}:{}})}return u?.answer!==void 0&&typeof u.answer!="string"?null:{kind:"web",query:f,sources:p,copyText:t,...typeof u?.answer=="string"?{answer:u.answer}:{}}}let r=_(u?.url),n=u?.statusCode;if(!r||typeof n!="number"||!Number.isInteger(n)||n<100||n>599)return null;let I=typeof u?.title=="string"?u.title:r;return{kind:"web",query:I,sources:[{key:r,url:r,title:I}],copyText:t,statusCode:n,...typeof u?.text=="string"?{answer:u.text}:{}}}var Me=[Ae,De,Be,Te,Fe];function $(e){for(let a of Me){let t=a(e);if(t)return t}return null}function j(e){return[e.input,e.output,e.raw].filter(a=>a!==void 0).map(a=>a.text).join(`
224
+ `)}}function Be(e){if(!J(e))return null;let a=Q(e);if(a!=="grep"&&a!=="glob")return null;let t=e.details.output?.text;if(!t)return null;let o=C(A(e.details.input?.text??e.entry.toolIo?.input)),l=A(t),u=C(l),f=t.trimStart().startsWith("{")||t.trimStart().startsWith("[");if(u?.isError===!0||typeof u?.error=="string")return null;let i=typeof o?.pattern=="string"?o.pattern:e.entry.toolLabel?.detail??e.entry.label;if(a==="glob"){let p=u!==null||Array.isArray(l);if(!p&&f)return null;let r=u?u.filenames??u.paths:Array.isArray(l)?l:t.trim().split(`
225
+ `);return!Array.isArray(r)||!r.every(c=>typeof c=="string"&&c.length>0)||!p&&!r.every(c=>/[/\\]|\.[a-z0-9]{1,12}$/i.test(c))?null:{kind:"search",resultKind:"paths",pattern:i,paths:r.map(c=>P(c,e.workspaceRoot)),copyText:t}}let s=typeof u?.content=="string"?u.content:t;if(u&&!Array.isArray(u.files)&&typeof u.content!="string"||!u&&f)return null;let n=new Map,I=(p,r,c)=>{let m=n.get(p)??[];m.push({line:r,text:c,key:`${r}:${m.length}`}),n.set(p,m)};if(Array.isArray(u?.files))for(let p of u.files){let r=C(p);if(typeof r?.path!="string"||!r.path||!Array.isArray(r.matches))return null;for(let c of r.matches){let m=C(c);if(typeof m?.lineNumber!="number"||!Number.isSafeInteger(m.lineNumber)||m.lineNumber<1||typeof m?.line!="string")return null;I(r.path,m.lineNumber,m.line)}}else for(let p of s.trimEnd().split(`
226
+ `)){let r=/^(.+?):([1-9]\d*):(.*)$/u.exec(p);if(!r||!Number.isSafeInteger(Number(r[2])))return null;I(r[1],Number(r[2]),r[3])}return{kind:"search",resultKind:"matches",pattern:i,files:[...n].map(([p,r])=>({key:p,path:P(p,e.workspaceRoot),matches:r})),copyText:t}}function _(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 Te(e){if(!J(e))return null;let a=Q(e);if(e.entry.itemType!=="web_search"&&a!=="websearch"&&a!=="webfetch"||a==="grep"||a==="glob")return null;let t=e.details.output?.text,o=A(t);if(!t)return null;let l=C(o);if(l?.isError===!0||typeof l?.error=="string")return null;let u=l?.sources??l?.results??(Array.isArray(o)?o:void 0),f=C(A(e.details.input?.text??e.entry.toolIo?.input)),i=typeof f?.query=="string"?f.query:e.entry.toolLabel?.detail??e.entry.label;if(Array.isArray(u)){let p=[];for(let r of u){let c=C(r),m=_(c?.url);if(!m||c?.title!==void 0&&typeof c.title!="string"||c?.snippet!==void 0&&typeof c.snippet!="string")return null;p.push({key:`${m}:${p.length}`,url:m,title:typeof c?.title=="string"?c.title:m,...typeof c?.snippet=="string"?{snippet:c.snippet}:{}})}return l?.answer!==void 0&&typeof l.answer!="string"?null:{kind:"web",query:i,sources:p,copyText:t,...typeof l?.answer=="string"?{answer:l.answer}:{}}}let s=_(l?.url),n=l?.statusCode;if(!s||typeof n!="number"||!Number.isInteger(n)||n<100||n>599)return null;let I=typeof l?.title=="string"?l.title:s;return{kind:"web",query:I,sources:[{key:s,url:s,title:I}],copyText:t,statusCode:n,...typeof l?.text=="string"?{answer:l.text}:{}}}var Fe=[Pe,Ae,De,Be,Te];function $(e){for(let a of Fe){let t=a(e);if(t)return t}return null}function j(e){return[e.input,e.output,e.raw].filter(a=>a!==void 0).map(a=>a.text).join(`
227
227
 
228
- `)}function A(...e){return e.filter(a=>typeof a=="string"&&a.length>0).join(" ")}var v=(...e)=>e.filter((a,t,o)=>!!a&&a.trim()!==""&&o.indexOf(a)===t).join(" ").trim();var Y=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var ee=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(a,t,o)=>o?o.toUpperCase():t.toLowerCase());var G=e=>{let a=ee(e);return a.charAt(0).toUpperCase()+a.slice(1)};var ae={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 te=e=>{for(let a in e)if(a.startsWith("aria-")||a==="role"||a==="title")return!0;return!1};var oe=b(({color:e="currentColor",size:a=24,strokeWidth:t=2,absoluteStrokeWidth:o,className:u="",children:l,iconNode:i,...f},r)=>g("svg",{ref:r,...ae,width:a,height:a,stroke:e,strokeWidth:o?Number(t)*24/Number(a):t,className:v("lucide",u),...!l&&!te(f)&&{"aria-hidden":"true"},...f},[...i.map(([n,I])=>g(n,I)),...Array.isArray(l)?l:[l]]));var x=(e,a)=>{let t=b(({className:o,...u},l)=>g(oe,{ref:l,iconNode:a,className:v(`lucide-${Y(G(e))}`,`lucide-${e}`,o),...u}));return t.displayName=G(e),t};var be=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],D=x("check",be);var Re=[["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=x("copy",Re);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"}]],T=x("globe",ve);var qe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],F=x("search",qe);var Ue=[["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=x("square-terminal",Ue);function k(e){return(a=>g(w().ui[e],{...a,className:`ycodium-tool-display-ui ${typeof a.className=="string"?a.className:""}`}))}var q=k("Button"),ue=k("Tooltip"),le=k("TooltipPopup"),de=k("TooltipTrigger"),re=k("Markdown"),se=k("DetailViewport");function S(){return{t:w().i18n.usePluginTranslation()}}var{jsx:d,jsxs:L,Fragment:xt}=window.__ycodiumPluginHost.jsxRuntime;function fe({text:e}){let{t:a}=S(),t=w(),[o,u]=U(null),[l,i]=U(!1),f=o===e;return L("span",{className:"inline-flex items-center gap-1",children:[d(q,{type:"button",variant:"ghost-muted",size:"icon-xs","aria-label":a(f?"copied":"copy"),onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&r.stopPropagation()},onClick:()=>{Promise.resolve(t.writeClipboard(e)).then(()=>{u(e),i(!1)},()=>i(!0))},children:f?d(D,{"aria-hidden":!0,className:"size-icon-1"}):d(B,{"aria-hidden":!0,className:"size-icon-1"})}),l?d("span",{role:"status",className:"tool-meta text-destructive",children:a("copyFailed")}):null]})}var ie=new Map;function y(e){ie.set(e.kind,e)}function ne(e){return ie.get(e.kind)}function M({text:e}){return L(ue,{children:[d(de,{render:d("code",{className:"min-w-0 truncate text-foreground"}),children:e}),d(le,{className:"max-w-lg whitespace-pre-wrap break-words",children:e})]})}function Oe({model:e}){let{t:a}=S();if(e.resultKind==="paths")return e.paths.length===0?d("p",{className:"px-2 pb-2 text-muted-foreground",children:a("noSearchResults")}):d("pre",{className:"tool-body whitespace-pre-wrap break-words px-2 pb-2 text-foreground",children:e.paths.slice(0,16).join(`
229
- `)});let t=16;return d("div",{className:"tool-body px-2 pb-2",children:e.files.length===0?d("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:L("div",{"data-search-file":o.path,className:"mb-2 last:mb-0",children:[d("p",{className:"break-all font-medium text-foreground",children:o.path}),u.map(l=>L("div",{"data-search-line":l.line,className:"grid grid-cols-[3.5em_minmax(0,1fr)]",children:[d("span",{"aria-hidden":!0,className:"pe-3 text-end text-muted-foreground tabular-nums select-none",children:l.line}),d("span",{className:"whitespace-pre-wrap break-words text-foreground [overflow-wrap:anywhere]",children:l.text||`
230
- `})]},l.key))]},o.key)})})}function He({model:e,context:a}){let{t}=S();return L("div",{className:"space-y-2 px-2 pb-2 text-foreground",children:[e.statusCode!==void 0?d("p",{className:A("tool-meta",e.statusCode>=400&&"text-destructive-foreground"),children:t("httpStatus",{status:e.statusCode})}):null,e.answer?d("p",{className:"tool-process-text line-clamp-3 whitespace-pre-wrap",children:e.answer}):null,e.sources.length===0?d("p",{className:"tool-process-text text-muted-foreground",children:t("noWebSources")}):e.sources.slice(0,8).map(o=>L("div",{"data-web-source":o.url,className:"space-y-0.5",children:[o.title!==e.query?d("p",{className:"tool-process-text font-medium",children:o.title}):null,d(re,{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?d("p",{className:"tool-meta line-clamp-3 whitespace-pre-wrap text-muted-foreground",children:o.snippet}):null]},o.key))]})}y({kind:"terminal",heading:e=>L("span",{className:"flex min-w-0 items-center gap-2 text-foreground",children:[d(h,{"aria-hidden":!0,className:"size-4 shrink-0 text-muted-foreground"}),d(M,{text:e.command})]}),body:e=>d("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})});y({kind:"read",hiddenLines:e=>Math.max(0,e.lines.length-16),heading:e=>d(M,{text:e.path}),body:e=>d("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?d("div",{"aria-hidden":!0,className:"ps-[3.5em] text-muted-foreground",children:"\u2026"},"gap"):L("div",{"data-source-line":a.number,className:"grid grid-cols-[3.5em_minmax(0,1fr)]",children:[d("span",{"aria-hidden":!0,className:"pe-3 text-end text-muted-foreground select-none tabular-nums",children:a.number}),d("span",{className:"whitespace-pre-wrap break-words pe-2 [overflow-wrap:anywhere]",children:a.text||`
231
- `})]},a.number))})});y({kind:"change",heading:e=>d(M,{text:e.files.map(a=>a.path).join(", ")}),body:e=>d("div",{className:"tool-body cursor-text pb-2 select-text",children:e.files.map(a=>L("div",{children:[e.files.length>1?d("p",{className:"px-2 py-1 text-foreground",children:a.path}):null,a.parts.length>64?d("pre",{className:"whitespace-pre-wrap break-words px-2 text-foreground [overflow-wrap:anywhere]",children:a.patch}):a.parts.map(t=>d("pre",{"data-change-line":t.kind,className:A("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(`
232
- `)},t.line))]},a.key))})});y({kind:"search",hasMoreResults:e=>e.resultKind==="paths"?e.paths.length>16:e.files.reduce((a,t)=>a+t.matches.length,0)>16,heading:e=>L("span",{className:"flex min-w-0 items-center gap-2",children:[d(F,{"aria-hidden":!0,className:"size-4 shrink-0"}),d(M,{text:e.pattern})]}),body:e=>d(Oe,{model:e})});y({kind:"web",hasMoreResults:e=>e.sources.length>8,heading:e=>L("span",{className:"flex min-w-0 items-center gap-2",children:[d(T,{"aria-hidden":!0,className:"size-4 shrink-0"}),d(M,{text:e.query})]}),body:(e,a)=>d(He,{model:e,context:a})});function Ge({text:e}){return d("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 ce({retain:e}){return N(()=>e(),[e]),null}function pe(e){let{t:a}=S(),t=$(e),o=t?ne(t):void 0,u=t&&o?.hiddenLines?o.hiddenLines(t):0,l=t&&o?.hasMoreResults?o.hasMoreResults(t):!1,i=[e.details.input,e.details.output,e.details.raw].filter(n=>n!==void 0),f=t?.copyText??j(e.details);if(!f&&!t)return null;let r=e.details.files.length>0&&t?.kind!=="change"&&t?.kind!=="search";return L("div",{className:A("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:[L("div",{className:"tool-meta flex min-h-8 items-center gap-2 px-2 text-muted-foreground",children:[d("span",{className:"min-w-0 flex-1",children:t&&o?o.heading(t):null}),e.summary?d("span",{children:a("summary")}):null,i.some(n=>n.truncated)?d("span",{children:a("truncated")}):null,d(fe,{text:f})]}),d(se,{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):d(Ge,{text:f})}),u||l?d(q,{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,r?d("div",{className:"min-w-0 px-2 pb-2",children:d("pre",{className:"tool-body whitespace-pre-wrap break-words text-foreground select-text",children:e.details.files.join(`
233
- `)})}):null]})}function Ee(e){if(["Button","Tooltip","TooltipTrigger","TooltipPopup","Markdown","DetailViewport"].some(u=>e.ui[u]===void 0)){let u=function(){let l=e.i18n.usePluginTranslation();return d("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=Z(W);return{pages:{},panels:{},views:{toolCall:function(l){return L(K,{value:e,children:[d(ce,{retain:t.retain}),d(pe,{...l,scopeClass:t.scopeClass})]})}}}}export{Ee as default};
228
+ `)}function D(...e){return e.filter(a=>typeof a=="string"&&a.length>0).join(" ")}var v=(...e)=>e.filter((a,t,o)=>!!a&&a.trim()!==""&&o.indexOf(a)===t).join(" ").trim();var Y=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var ee=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(a,t,o)=>o?o.toUpperCase():t.toLowerCase());var G=e=>{let a=ee(e);return a.charAt(0).toUpperCase()+a.slice(1)};var ae={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 te=e=>{for(let a in e)if(a.startsWith("aria-")||a==="role"||a==="title")return!0;return!1};var oe=R(({color:e="currentColor",size:a=24,strokeWidth:t=2,absoluteStrokeWidth:o,className:l="",children:u,iconNode:f,...i},s)=>g("svg",{ref:s,...ae,width:a,height:a,stroke:e,strokeWidth:o?Number(t)*24/Number(a):t,className:v("lucide",l),...!u&&!te(i)&&{"aria-hidden":"true"},...i},[...f.map(([n,I])=>g(n,I)),...Array.isArray(u)?u:[u]]));var x=(e,a)=>{let t=R(({className:o,...l},u)=>g(oe,{ref:u,iconNode:a,className:v(`lucide-${Y(G(e))}`,`lucide-${e}`,o),...l}));return t.displayName=G(e),t};var Me=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],B=x("check",Me);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"}]],T=x("copy",be);var Re=[["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"}]],F=x("globe",Re);var ve=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],M=x("search",ve);var qe=[["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=x("square-terminal",qe);function k(e){return(a=>g(w().ui[e],{...a,className:`ycodium-tool-display-ui ${typeof a.className=="string"?a.className:""}`}))}var q=k("Button"),ue=k("Tooltip"),le=k("TooltipPopup"),de=k("TooltipTrigger"),re=k("Markdown"),se=k("DetailViewport");function S(){return{t:w().i18n.usePluginTranslation()}}var{jsx:d,jsxs:L,Fragment:Ct}=window.__ycodiumPluginHost.jsxRuntime;function fe({text:e}){let{t:a}=S(),t=w(),[o,l]=U(null),[u,f]=U(!1),i=o===e;return L("span",{className:"inline-flex items-center gap-1",children:[d(q,{type:"button",variant:"ghost-muted",size:"icon-xs","aria-label":a(i?"copied":"copy"),onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&s.stopPropagation()},onClick:()=>{Promise.resolve(t.writeClipboard(e)).then(()=>{l(e),f(!1)},()=>f(!0))},children:i?d(B,{"aria-hidden":!0,className:"size-icon-1"}):d(T,{"aria-hidden":!0,className:"size-icon-1"})}),u?d("span",{role:"status",className:"tool-meta text-destructive",children:a("copyFailed")}):null]})}var ie=new Map;function y(e){ie.set(e.kind,e)}function ne(e){return ie.get(e.kind)}function b({text:e}){return L(ue,{children:[d(de,{render:d("code",{className:"min-w-0 truncate text-foreground"}),children:e}),d(le,{className:"max-w-lg whitespace-pre-wrap break-words",children:e})]})}function Ue({model:e}){let{t:a}=S();if(e.resultKind==="paths")return e.paths.length===0?d("p",{className:"px-2 pb-2 text-muted-foreground",children:a("noSearchResults")}):d("pre",{className:"tool-body whitespace-pre-wrap break-words px-2 pb-2 text-foreground",children:e.paths.slice(0,16).join(`
229
+ `)});let t=16;return d("div",{className:"tool-body px-2 pb-2",children:e.files.length===0?d("p",{className:"text-muted-foreground",children:a("noSearchResults")}):e.files.map(o=>{let l=o.matches.slice(0,t);return t-=l.length,l.length===0?null:L("div",{"data-search-file":o.path,className:"mb-2 last:mb-0",children:[d("p",{className:"break-all font-medium text-foreground",children:o.path}),l.map(u=>L("div",{"data-search-line":u.line,className:"grid grid-cols-[3.5em_minmax(0,1fr)]",children:[d("span",{"aria-hidden":!0,className:"pe-3 text-end text-muted-foreground tabular-nums select-none",children:u.line}),d("span",{className:"whitespace-pre-wrap break-words text-foreground [overflow-wrap:anywhere]",children:u.text||`
230
+ `})]},u.key))]},o.key)})})}function Oe({model:e,context:a}){let{t}=S();return L("div",{className:"space-y-2 px-2 pb-2 text-foreground",children:[e.statusCode!==void 0?d("p",{className:D("tool-meta",e.statusCode>=400&&"text-destructive-foreground"),children:t("httpStatus",{status:e.statusCode})}):null,e.answer?d("p",{className:"tool-process-text line-clamp-3 whitespace-pre-wrap",children:e.answer}):null,e.sources.length===0?d("p",{className:"tool-process-text text-muted-foreground",children:t("noWebSources")}):e.sources.slice(0,8).map(o=>L("div",{"data-web-source":o.url,className:"space-y-0.5",children:[o.title!==e.query?d("p",{className:"tool-process-text font-medium",children:o.title}):null,d(re,{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?d("p",{className:"tool-meta line-clamp-3 whitespace-pre-wrap text-muted-foreground",children:o.snippet}):null]},o.key))]})}y({kind:"terminal",heading:e=>L("span",{className:"flex min-w-0 items-center gap-2 text-foreground",children:[d(h,{"aria-hidden":!0,className:"size-4 shrink-0 text-muted-foreground"}),d(b,{text:e.command})]}),body:e=>d("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})});y({kind:"read",hiddenLines:e=>Math.max(0,e.lines.length-16),heading:e=>d(b,{text:e.path}),body:e=>d("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?d("div",{"aria-hidden":!0,className:"ps-[3.5em] text-muted-foreground",children:"\u2026"},"gap"):L("div",{"data-source-line":a.number,className:"grid grid-cols-[3.5em_minmax(0,1fr)]",children:[d("span",{"aria-hidden":!0,className:"pe-3 text-end text-muted-foreground select-none tabular-nums",children:a.number}),d("span",{className:"whitespace-pre-wrap break-words pe-2 [overflow-wrap:anywhere]",children:a.text||`
231
+ `})]},a.number))})});y({kind:"change",heading:e=>d(b,{text:e.files.map(a=>a.path).join(", ")}),body:e=>d("div",{className:"tool-body cursor-text pb-2 select-text",children:e.files.map(a=>L("div",{children:[e.files.length>1?d("p",{className:"px-2 py-1 text-foreground",children:a.path}):null,a.parts.length>64?d("pre",{className:"whitespace-pre-wrap break-words px-2 text-foreground [overflow-wrap:anywhere]",children:a.patch}):a.parts.map(t=>d("pre",{"data-change-line":t.kind,className:D("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(`
232
+ `)},t.line))]},a.key))})});y({kind:"search",hasMoreResults:e=>e.resultKind==="paths"?e.paths.length>16:e.files.reduce((a,t)=>a+t.matches.length,0)>16,heading:e=>L("span",{className:"flex min-w-0 items-center gap-2",children:[d(M,{"aria-hidden":!0,className:"size-4 shrink-0"}),d(b,{text:e.pattern})]}),body:e=>d(Ue,{model:e})});y({kind:"web",hasMoreResults:e=>e.sources.length>8,heading:e=>L("span",{className:"flex min-w-0 items-center gap-2",children:[d(F,{"aria-hidden":!0,className:"size-4 shrink-0"}),d(b,{text:e.query})]}),body:(e,a)=>d(Oe,{model:e,context:a})});function He({text:e}){return d("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 ce({retain:e}){return N(()=>e(),[e]),null}function pe(e){let{t:a}=S(),t=$(e),o=t?ne(t):void 0,l=t&&o?.hiddenLines?o.hiddenLines(t):0,u=t&&o?.hasMoreResults?o.hasMoreResults(t):!1,f=[e.details.input,e.details.output,e.details.raw].filter(n=>n!==void 0),i=t?.copyText??j(e.details);if(!i&&!t)return null;let s=e.details.files.length>0&&t?.kind!=="change"&&t?.kind!=="search";return L("div",{className:D("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:[L("div",{className:"tool-meta flex min-h-8 items-center gap-2 px-2 text-muted-foreground",children:[d("span",{className:"min-w-0 flex-1",children:t&&o?o.heading(t):null}),e.summary?d("span",{children:a("summary")}):null,f.some(n=>n.truncated)?d("span",{children:a("truncated")}):null,d(fe,{text:i})]}),d(se,{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):d(He,{text:i})}),l||u?d(q,{size:"xs",variant:"ghost-muted",className:"m-1",disabled:e.onShowOutput===void 0,onClick:e.onShowOutput,children:l?a("showMoreLines",{count:l}):a("showAllResults")}):null,s?d("div",{className:"min-w-0 px-2 pb-2",children:d("pre",{className:"tool-body whitespace-pre-wrap break-words text-foreground select-text",children:e.details.files.join(`
233
+ `)})}):null]})}function Ge(e){if(["Button","Tooltip","TooltipTrigger","TooltipPopup","Markdown","DetailViewport"].some(l=>e.ui[l]===void 0)){let l=function(){let u=e.i18n.usePluginTranslation();return d("p",{role:"status",className:"p-3 text-sm text-muted-foreground",children:u("hostUpgradeRequired")})};var o=l;return{pages:{},panels:{},views:{toolCall:l}}}let t=Z(E);return{pages:{},panels:{},views:{toolCall:function(u){return L(K,{value:e,children:[d(ce,{retain:t.retain}),d(pe,{...u,scopeClass:t.scopeClass})]})}}}}export{Ge as default};
package/dist/models.d.ts CHANGED
@@ -66,7 +66,6 @@ export type ToolDisplayOverview = {
66
66
  readonly statusCode?: number;
67
67
  };
68
68
  export type ToolDisplayOverviewKind = ToolDisplayOverview["kind"];
69
- export declare function formatToolDisplayPath(pathWithPosition: string, workspaceRoot: string | undefined): string;
70
69
  /** 只认明确的命令执行项;无命令原文或 MCP raw 时回退,不把任意输入猜成 shell。 */
71
70
  export declare function commandOverviewModel(context: ToolDisplayContext): Extract<ToolDisplayOverview, {
72
71
  kind: "terminal";
package/dist/models.js CHANGED
@@ -1,40 +1,17 @@
1
- // src/models.ts
2
- function record(value) {
3
- return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
4
- }
5
- function parseJson(text) {
6
- if (!text) return null;
7
- try {
8
- return JSON.parse(text);
9
- } catch {
10
- return null;
11
- }
12
- }
13
- function inputRecord({ entry, details }) {
14
- const input = details.input?.text ?? entry.toolIo?.input;
15
- if (!input) return null;
16
- const value = parseJson(input);
17
- return record(value);
18
- }
19
- function toolName(context) {
20
- const raw = record(context.entry.toolData);
21
- const value = context.entry.toolLabel?.name ?? raw?.tool ?? context.entry.toolTitle ?? context.entry.label;
22
- return typeof value === "string" ? value.toLowerCase().replace(/[ _-]/g, "") : "";
23
- }
24
- function completed(context) {
25
- return context.entry.toolLifecycleStatus === "completed" && !context.entry.displayFailed && (context.details.exitCode === void 0 || context.details.exitCode === 0);
26
- }
1
+ // ../../packages/ycodium-workspace-path/src/workspacePath.ts
27
2
  function splitPathAndPosition(value) {
28
- let path = value;
29
- const columnMatch = path.match(/:(\d+)$/);
30
- if (!columnMatch?.[1]) return { path, line: void 0, column: void 0 };
31
- let column = columnMatch[1];
32
- path = path.slice(0, -columnMatch[0].length);
3
+ const columnMatch = value.match(/:(\d+)$/);
4
+ if (!columnMatch?.[1]) return { path: value, line: void 0, column: void 0 };
5
+ const path = value.slice(0, -columnMatch[0].length);
33
6
  const lineMatch = path.match(/:(\d+)$/);
34
7
  if (lineMatch?.[1]) {
35
- return { path: path.slice(0, -lineMatch[0].length), line: lineMatch[1], column };
8
+ return {
9
+ path: path.slice(0, -lineMatch[0].length),
10
+ line: lineMatch[1],
11
+ column: columnMatch[1]
12
+ };
36
13
  }
37
- return { path, line: column, column: void 0 };
14
+ return { path, line: columnMatch[1], column: void 0 };
38
15
  }
39
16
  function normalizePathSeparators(path) {
40
17
  return path.replaceAll("\\", "/");
@@ -42,15 +19,13 @@ function normalizePathSeparators(path) {
42
19
  function canonicalizeWindowsDrivePath(path) {
43
20
  return /^\/[A-Za-z]:\//.test(path) ? path.slice(1) : path;
44
21
  }
45
- function trimTrailingPathSeparators(path) {
46
- return path.replace(/[\\/]+$/, "");
22
+ function normalizeWorkspaceRoot(workspaceRoot) {
23
+ return canonicalizeWindowsDrivePath(
24
+ normalizePathSeparators(workspaceRoot.replace(/[\\/]+$/, ""))
25
+ );
47
26
  }
48
27
  function basenameOfPath(path) {
49
- const separatorIndex = Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"));
50
- return separatorIndex >= 0 ? path.slice(separatorIndex + 1) : path;
51
- }
52
- function stripRelativePrefixes(path) {
53
- return path.replace(/^\.\/+/, "").replace(/^\/+/, "");
28
+ return path.slice(path.lastIndexOf("/") + 1);
54
29
  }
55
30
  function isAbsolutePath(path) {
56
31
  return path.startsWith("/") || /^[A-Za-z]:\//.test(path);
@@ -58,35 +33,58 @@ function isAbsolutePath(path) {
58
33
  function isCaseInsensitiveWorkspaceRoot(workspaceRoot) {
59
34
  return workspaceRoot.startsWith("\\\\") || /^[A-Za-z]:([/\\]|$)/.test(canonicalizeWindowsDrivePath(normalizePathSeparators(workspaceRoot)));
60
35
  }
61
- function formatToolDisplayPath(pathWithPosition, workspaceRoot) {
36
+ function formatWorkspaceRelativePath(pathWithPosition, workspaceRoot) {
62
37
  const { path, line, column } = splitPathAndPosition(pathWithPosition);
63
38
  const normalizedPath = canonicalizeWindowsDrivePath(normalizePathSeparators(path));
64
39
  let displayPath = normalizedPath;
65
40
  if (workspaceRoot) {
66
- const normalizedWorkspaceRoot = canonicalizeWindowsDrivePath(
67
- normalizePathSeparators(trimTrailingPathSeparators(workspaceRoot))
68
- );
41
+ const normalizedWorkspaceRoot = normalizeWorkspaceRoot(workspaceRoot);
69
42
  const workspaceLabel = basenameOfPath(normalizedWorkspaceRoot);
70
- const caseInsensitive = isCaseInsensitiveWorkspaceRoot(workspaceRoot);
71
- const pathForCompare = caseInsensitive ? normalizedPath.toLowerCase() : normalizedPath;
72
- const workspaceForCompare = caseInsensitive ? normalizedWorkspaceRoot.toLowerCase() : normalizedWorkspaceRoot;
73
- const workspaceWithSeparator = `${workspaceForCompare}/`;
74
- const workspaceLabelWithSeparator = `${caseInsensitive ? workspaceLabel.toLowerCase() : workspaceLabel}/`;
43
+ const fold = isCaseInsensitiveWorkspaceRoot(workspaceRoot) ? (value) => value.toLowerCase() : (value) => value;
44
+ const pathForCompare = fold(normalizedPath);
45
+ const workspaceForCompare = fold(normalizedWorkspaceRoot);
75
46
  if (pathForCompare === workspaceForCompare) {
76
47
  displayPath = workspaceLabel;
77
- } else if (pathForCompare.startsWith(workspaceWithSeparator)) {
48
+ } else if (pathForCompare.startsWith(`${workspaceForCompare}/`)) {
78
49
  displayPath = `${workspaceLabel}/${normalizedPath.slice(normalizedWorkspaceRoot.length + 1)}`;
79
50
  } else if (!isAbsolutePath(normalizedPath)) {
80
- const relativePath = stripRelativePrefixes(normalizedPath);
81
- displayPath = pathForCompare.startsWith(workspaceLabelWithSeparator) ? normalizedPath : `${workspaceLabel}/${relativePath}`;
51
+ const relativePath = normalizedPath.replace(/^\.\/+/, "").replace(/^\/+/, "");
52
+ displayPath = pathForCompare.startsWith(`${fold(workspaceLabel)}/`) ? normalizedPath : `${workspaceLabel}/${relativePath}`;
82
53
  }
83
54
  }
84
55
  if (!line) return displayPath;
85
56
  return `${displayPath}:${line}${column ? `:${column}` : ""}`;
86
57
  }
58
+
59
+ // src/models.ts
60
+ function record(value) {
61
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
62
+ }
63
+ function parseJson(text) {
64
+ if (!text) return null;
65
+ try {
66
+ return JSON.parse(text);
67
+ } catch {
68
+ return null;
69
+ }
70
+ }
71
+ function inputRecord({ entry, details }) {
72
+ const input = details.input?.text ?? entry.toolIo?.input;
73
+ if (!input) return null;
74
+ const value = parseJson(input);
75
+ return record(value);
76
+ }
77
+ function toolName(context) {
78
+ const raw = record(context.entry.toolData);
79
+ const value = context.entry.toolLabel?.name ?? raw?.tool ?? context.entry.toolTitle ?? context.entry.label;
80
+ return typeof value === "string" ? value.toLowerCase().replace(/[ _-]/g, "") : "";
81
+ }
82
+ function completed(context) {
83
+ return context.entry.toolLifecycleStatus === "completed" && !context.entry.displayFailed && (context.details.exitCode === void 0 || context.details.exitCode === 0);
84
+ }
87
85
  function reportedPath(context, input) {
88
86
  const value = context.entry.toolLabel?.path ?? input?.file_path;
89
- return typeof value === "string" && value.trim() ? formatToolDisplayPath(value, context.workspaceRoot) : null;
87
+ return typeof value === "string" && value.trim() ? formatWorkspaceRelativePath(value, context.workspaceRoot) : null;
90
88
  }
91
89
  function commandOverviewModel(context) {
92
90
  const { entry, details } = context;
@@ -145,7 +143,7 @@ function changeOverviewModel(context) {
145
143
  }
146
144
  files.push({
147
145
  key: `${path}:${changeIndex}`,
148
- path: formatToolDisplayPath(path, context.workspaceRoot),
146
+ path: formatWorkspaceRelativePath(path, context.workspaceRoot),
149
147
  patch: diff,
150
148
  parts
151
149
  });
@@ -180,7 +178,7 @@ function searchOverviewModel(context) {
180
178
  kind: "search",
181
179
  resultKind: "paths",
182
180
  pattern,
183
- paths: paths.map((path) => formatToolDisplayPath(path, context.workspaceRoot)),
181
+ paths: paths.map((path) => formatWorkspaceRelativePath(path, context.workspaceRoot)),
184
182
  copyText: output
185
183
  };
186
184
  }
@@ -218,7 +216,7 @@ function searchOverviewModel(context) {
218
216
  files: [...files].map(
219
217
  ([path, matches]) => ({
220
218
  key: path,
221
- path: formatToolDisplayPath(path, context.workspaceRoot),
219
+ path: formatWorkspaceRelativePath(path, context.workspaceRoot),
222
220
  matches
223
221
  })
224
222
  ),
@@ -305,7 +303,6 @@ function recordedToolDisplayText(details) {
305
303
  export {
306
304
  changeOverviewModel,
307
305
  commandOverviewModel,
308
- formatToolDisplayPath,
309
306
  readOverviewModel,
310
307
  recordedToolDisplayText,
311
308
  resolveToolDisplayOverview,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/plugin-tool-display",
3
- "version": "0.2.2880",
3
+ "version": "0.2.2882",
4
4
  "description": "Renders command, read, change, search, and web tool calls from recorded facts.",
5
5
  "keywords": [
6
6
  "ycodium",
@@ -35,7 +35,8 @@
35
35
  "tailwindcss": "^4.0.0",
36
36
  "typescript": "~6.0.3",
37
37
  "vite-plus": "0.2.2",
38
- "@ycodium-ai/plugin-api": "0.2.2880"
38
+ "@ycodium-ai/plugin-api": "0.2.2882",
39
+ "ycodium-workspace-path": "0.0.0"
39
40
  },
40
41
  "ycodium": {
41
42
  "plugin": "./dist/index.js",