@vpxa/aikit 0.1.43 → 0.1.44

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vpxa/aikit",
3
- "version": "0.1.43",
3
+ "version": "0.1.44",
4
4
  "type": "module",
5
5
  "description": "Local-first AI developer toolkit — knowledge base, code analysis, context management, and developer tools for LLM agents",
6
6
  "license": "MIT",
@@ -1,4 +1,7 @@
1
- function e(t){return t==null?`null`:Array.isArray(t)?`[${t.map(e).join(`, `)}]`:String(t)}function t(e){return e.replace(/[^a-zA-Z0-9_]/g,`_`)}function n(e){if(typeof e!=`object`||!e||!(`type`in e))return!1;let t=e;return`value`in t||typeof t.text==`string`||Array.isArray(t.headers)&&Array.isArray(t.rows)||typeof t.code==`string`||Array.isArray(t.items)||!!t.entries&&typeof t.entries==`object`&&!Array.isArray(t.entries)||!!t.columns&&typeof t.columns==`object`||`chartType`in t||Array.isArray(t.data)}function r(e){if(Array.isArray(e)){let t=e.filter(e=>typeof e==`object`&&!!e),n=t.map(e=>String(e.title??``)),r=Math.max(0,...t.map(e=>Array.isArray(e.items)?e.items.length:0));return{headers:n,rows:Array.from({length:r},(e,n)=>t.map(e=>Array.isArray(e.items)?e.items[n]??``:``))}}if(!e||typeof e!=`object`)return null;let t=e,n=Object.keys(t),r=Math.max(0,...n.map(e=>Array.isArray(t[e])?t[e].length:0));return{headers:n,rows:Array.from({length:r},(e,r)=>n.map(e=>Array.isArray(t[e])?t[e][r]??``:``))}}function i(e){let t=e,n=e;if(`value`in n||(typeof t.text==`string`?n={...n,value:t.text}:typeof t.code==`string`?n={...n,value:t.code}:Array.isArray(t.headers)&&Array.isArray(t.rows)?n={...n,value:{headers:t.headers,rows:t.rows}}:Array.isArray(t.items)?n={...n,value:{items:t.items}}:(`chartType`in t||Array.isArray(t.data))&&(n={...n,value:{chartType:t.chartType,data:t.data,xKey:t.xKey??`label`,yKeys:t.yKeys??[`value`]}})),n.type===`chart`){let e=n.value;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e,r=t.data&&typeof t.data==`object`&&!Array.isArray(t.data)?t.data:null,i=Array.isArray(t.labels)?t.labels:Array.isArray(r?.labels)?r.labels:null,a=Array.isArray(t.datasets)?t.datasets:Array.isArray(r?.datasets)?r.datasets:null,o=typeof t.type==`string`?t.type:typeof t.chartType==`string`?t.chartType:null;if(o&&i&&a&&!Array.isArray(t.data)){let e=a.map((e,t)=>String(e.label??`series${t+1}`)),t=i.map((e,t)=>{let n={label:String(e)};for(let[e,r]of a.entries()){let i=r,a=String(i.label??`series${e+1}`);n[a]=i.data?.[t]??0}return n});n={...n,value:{chartType:String(o),data:t,xKey:`label`,yKeys:e}}}}}let i=n;if(n.type===`text`||n.type===`paragraph`)return{...n,type:`markdown`};if(n.type===`heading`)return{...n,type:`markdown`,value:`## ${String(i.value??``)}`};if(n.type===`kv`){let e=t.entries&&typeof t.entries==`object`&&!Array.isArray(t.entries)?t.entries:i.value&&typeof i.value==`object`&&!Array.isArray(i.value)?i.value:null;if(e)return{...n,type:`table`,value:{headers:[`Key`,`Value`],rows:Object.entries(e).map(([e,t])=>[e,t])}}}if(n.type===`comparison`){let e=r(t.columns??(i.value&&typeof i.value==`object`?i.value.columns:void 0))??r(i.value);if(e)return{...n,type:`table`,value:e};let a=i.value;if(a&&typeof a==`object`&&!Array.isArray(a)){let e=a;if(Array.isArray(e.headers)&&Array.isArray(e.rows))return{...n,type:`table`}}}if(n.type===`timeline`){let e=i.value;if(Array.isArray(e)){let t=e.map(e=>{if(e&&typeof e==`object`){let t=e;return[String(t.status??t.state??``),String(t.time??t.date??t.timestamp??``),String(t.label??t.description??t.title??t.text??``)]}return[``,``,String(e)]});return{...n,type:`table`,value:{headers:[`Status`,`Time`,`Description`],rows:t}}}}return n}function a(e){let t=e.value;if(e.type===`separator`)return{type:`markdown`,title:e.title,value:`---`};if(e.type===`checklist`){if(!t||typeof t!=`object`||!Array.isArray(t.items))return e;let n=t.items.map(e=>{if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.label!=`string`)return null;let n=t.checked===!0?`x`:` `,r=typeof t.note==`string`&&t.note.length>0?` — ${t.note}`:``;return`- [${n}] ${t.label}${r}`}).filter(e=>typeof e==`string`);return n.length>0?{type:`markdown`,title:e.title,value:n.join(`
1
+ function e(t){return t==null?`null`:Array.isArray(t)?`[${t.map(e).join(`, `)}]`:String(t)}function t(e){return e.replace(/[^a-zA-Z0-9_]/g,`_`)}function n(e){if(typeof e!=`object`||!e||!(`type`in e))return!1;let t=e;return`value`in t||typeof t.text==`string`||Array.isArray(t.headers)&&Array.isArray(t.rows)||typeof t.code==`string`||Array.isArray(t.items)||!!t.entries&&typeof t.entries==`object`&&!Array.isArray(t.entries)||!!t.columns&&typeof t.columns==`object`||`chartType`in t||Array.isArray(t.data)}function r(e){if(Array.isArray(e)){let t=e.filter(e=>typeof e==`object`&&!!e),n=t.map(e=>String(e.title??``)),r=Math.max(0,...t.map(e=>Array.isArray(e.items)?e.items.length:0));return{headers:n,rows:Array.from({length:r},(e,n)=>t.map(e=>Array.isArray(e.items)?e.items[n]??``:``))}}if(!e||typeof e!=`object`)return null;let t=e,n=Object.keys(t),r=Math.max(0,...n.map(e=>Array.isArray(t[e])?t[e].length:0));return{headers:n,rows:Array.from({length:r},(e,r)=>n.map(e=>Array.isArray(t[e])?t[e][r]??``:``))}}function i(e){let t=e,n=e;if(`value`in n||(typeof t.text==`string`?n={...n,value:t.text}:typeof t.code==`string`?n={...n,value:t.code}:Array.isArray(t.headers)&&Array.isArray(t.rows)?n={...n,value:{headers:t.headers,rows:t.rows}}:Array.isArray(t.items)?n={...n,value:{items:t.items}}:(`chartType`in t||Array.isArray(t.data))&&(n={...n,value:{chartType:t.chartType,data:t.data,xKey:t.xKey??`label`,yKeys:t.yKeys??[`value`]}})),n.type===`chart`){let e=n.value;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e,r=t.data&&typeof t.data==`object`&&!Array.isArray(t.data)?t.data:null,i=Array.isArray(t.labels)?t.labels:Array.isArray(r?.labels)?r.labels:null,a=Array.isArray(t.datasets)?t.datasets:Array.isArray(r?.datasets)?r.datasets:null,o=typeof t.type==`string`?t.type:typeof t.chartType==`string`?t.chartType:null;if(o&&i&&a&&!Array.isArray(t.data)){let e=a.map((e,t)=>String(e.label??`series${t+1}`)),t=i.map((e,t)=>{let n={label:String(e)};for(let[e,r]of a.entries()){let i=r,a=String(i.label??`series${e+1}`);n[a]=i.data?.[t]??0}return n});n={...n,value:{chartType:String(o),data:t,xKey:`label`,yKeys:e}}}}}let i=n;if(n.type===`text`||n.type===`paragraph`)return{...n,type:`markdown`};if(n.type===`heading`)return{...n,type:`markdown`,value:`## ${String(i.value??``)}`};if(n.type===`kv`){let e=t.entries&&typeof t.entries==`object`&&!Array.isArray(t.entries)?t.entries:i.value&&typeof i.value==`object`&&!Array.isArray(i.value)?i.value:null;if(e)return{...n,type:`table`,value:{headers:[`Key`,`Value`],rows:Object.entries(e).map(([e,t])=>[e,t])}}}if(n.type===`comparison`){let e=r(t.columns??(i.value&&typeof i.value==`object`?i.value.columns:void 0))??r(i.value);if(e)return{...n,type:`table`,value:e};let a=i.value;if(a&&typeof a==`object`&&!Array.isArray(a)){let e=a;if(Array.isArray(e.headers)&&Array.isArray(e.rows))return{...n,type:`table`}}}if(n.type===`timeline`){let e=i.value;if(Array.isArray(e)){let t=e.map(e=>{if(e&&typeof e==`object`){let t=e;return[String(t.status??t.state??``),String(t.time??t.date??t.timestamp??``),String(t.label??t.description??t.title??t.text??``)]}return[``,``,String(e)]});return{...n,type:`table`,value:{headers:[`Status`,`Time`,`Description`],rows:t}}}}return n}function a(e){let t=e.value;if(e.type===`separator`)return{type:`markdown`,title:e.title,value:`---`};if(e.type===`checklist`){let n=Array.isArray(t)?t:t&&typeof t==`object`&&Array.isArray(t.items)?t.items:null;if(!n)return e;let r=n.map(e=>{if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.label!=`string`)return null;let n=t.checked===!0?`x`:` `,r=typeof t.note==`string`&&t.note.length>0?` — ${t.note}`:``;return`- [${n}] ${t.label}${r}`}).filter(e=>typeof e==`string`);return r.length>0?{type:`markdown`,title:e.title,value:r.join(`
2
2
  `)}:e}if(e.type===`status-board`){if(!t||typeof t!=`object`||!Array.isArray(t.items))return e;let n={success:`✅`,warning:`⚠️`,error:`❌`,info:`ℹ️`,pending:`⏳`},r=t.items.map(e=>{if(!e||typeof e!=`object`)return null;let t=e;return typeof t.label!=`string`||typeof t.status!=`string`?null:[n[t.status.toLowerCase()]??`●`,t.label,typeof t.detail==`string`?t.detail:``]}).filter(e=>Array.isArray(e));return r.length>0?{type:`table`,title:e.title,value:{headers:[`Status`,`Service`,`Detail`],rows:r}}:e}if(e.type===`prompt`){if(!t||typeof t!=`object`)return e;let n=t;if(typeof n.question!=`string`)return e;let r=[`**${n.question}**`];return typeof n.context==`string`&&n.context.length>0&&r.push(n.context),typeof n.placeholder==`string`&&n.placeholder.length>0&&r.push(`*${n.placeholder}*`),{type:`markdown`,title:e.title,value:r.join(`
3
3
 
4
- `)}}if(e.type===`progress`){if(!t||typeof t!=`object`||!Array.isArray(t.items))return e;let n=t.items.map(e=>{if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.label!=`string`||typeof t.value!=`number`)return null;let n=typeof t.max==`number`?t.max:100,r=Number.isFinite(n)&&n>0?n:100,i=Math.round(t.value/r*100);return[t.label,`${i}%`,`${t.value} / ${r}`]}).filter(e=>Array.isArray(e));return n.length>0?{type:`table`,title:e.title,value:{headers:[`Item`,`Progress`,`Value`],rows:n}}:e}if(e.type===`timeline`){if(!t||typeof t!=`object`||!Array.isArray(t.items))return e;let n={done:`✅`,active:`🔵`,pending:`⏳`,error:`❌`},r=t.items.map(e=>{if(!e||typeof e!=`object`)return null;let t=e;return typeof t.title==`string`?[n[typeof t.status==`string`?t.status.toLowerCase():``]??`●`,typeof t.phase==`string`&&t.phase.length>0?t.phase:t.title,typeof t.description==`string`?t.description:``]:null}).filter(e=>Array.isArray(e));return r.length>0?{type:`table`,title:e.title,value:{headers:[`Status`,`Phase`,`Description`],rows:r}}:e}if(!new Set([`markdown`,`table`,`code`,`chart`,`metrics`,`cards`,`tree`,`graph`,`mermaid`]).has(e.type)){let t=e.value;return typeof t==`string`?{type:`markdown`,title:e.title,value:t}:{type:`code`,title:e.title,value:JSON.stringify(t,null,2)}}return e}function o(e){return Array.isArray(e)?e.map(e=>n(e)?a(i(e)):e):e}export{e as formatValue,n as isTypedBlock,i as normalizeBlock,o as normalizeContentForApp,t as sanitizeId};
4
+ `)}}if(e.type===`progress`){if(!t||typeof t!=`object`||!Array.isArray(t.items))return e;let n=t.items.map(e=>{if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.label!=`string`||typeof t.value!=`number`)return null;let n=typeof t.max==`number`?t.max:100,r=Number.isFinite(n)&&n>0?n:100,i=Math.round(t.value/r*100);return[t.label,`${i}%`,`${t.value} / ${r}`]}).filter(e=>Array.isArray(e));return n.length>0?{type:`table`,title:e.title,value:{headers:[`Item`,`Progress`,`Value`],rows:n}}:e}if(e.type===`timeline`){if(!t||typeof t!=`object`||!Array.isArray(t.items))return e;let n={done:`✅`,active:`🔵`,pending:`⏳`,error:`❌`},r=t.items.map(e=>{if(!e||typeof e!=`object`)return null;let t=e;return typeof t.title==`string`?[n[typeof t.status==`string`?t.status.toLowerCase():``]??`●`,typeof t.phase==`string`&&t.phase.length>0?t.phase:t.title,typeof t.description==`string`?t.description:``]:null}).filter(e=>Array.isArray(e));return r.length>0?{type:`table`,title:e.title,value:{headers:[`Status`,`Phase`,`Description`],rows:r}}:e}if(e.type===`cards`&&Array.isArray(t)&&t.some(e=>e&&typeof e==`object`&&`category`in e)){let n={error:`🔴`,warning:`⚠️`,success:`✅`,info:`ℹ️`},r=t.map(e=>{if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.category!=`string`||!Array.isArray(t.items))return null;let r=t.items.map(e=>{if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.label!=`string`)return null;let r=typeof t.status==`string`?`${n[t.status]??`●`} `:``,i=typeof t.description==`string`&&t.description.length>0?` ${t.description}`:``;return`- ${r}${t.label}${i}`}).filter(Boolean);return`### ${t.category}\n${r.join(`
5
+ `)}`}).filter(Boolean);if(r.length>0)return{type:`markdown`,title:e.title,value:r.join(`
6
+
7
+ `)}}if(e.type===`table`&&typeof t==`string`)return{type:`markdown`,title:e.title,value:t};if(!new Set([`markdown`,`table`,`code`,`chart`,`metrics`,`cards`,`tree`,`graph`,`mermaid`]).has(e.type)){let t=e.value;return typeof t==`string`?{type:`markdown`,title:e.title,value:t}:{type:`code`,title:e.title,value:JSON.stringify(t,null,2)}}return e}function o(e){return Array.isArray(e)?e.map(e=>n(e)?a(i(e)):e):e}export{e as formatValue,n as isTypedBlock,i as normalizeBlock,o as normalizeContentForApp,t as sanitizeId};