@mulmoclaude/chart-plugin 0.1.0 → 0.1.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/core/paths.ts"],"names":[],"mappings":"AASA,8EAA8E;AAC9E,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,SAAU,GAAG,MAAM,CAO7E;AASD,MAAM,WAAW,SAAS;IACxB,gFAAgF;IAChF,OAAO,EAAE,MAAM,CAAC;IAChB,sEAAsE;IACtE,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,qFAAqF;AACrF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,GAAE,IAAiB,GAAG,SAAS,CAI9F"}
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/core/paths.ts"],"names":[],"mappings":"AAaA,8EAA8E;AAC9E,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,SAAU,GAAG,MAAM,CAc7E;AASD,MAAM,WAAW,SAAS;IACxB,gFAAgF;IAChF,OAAO,EAAE,MAAM,CAAC;IAChB,sEAAsE;IACtE,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,qFAAqF;AACrF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,GAAE,IAAiB,GAAG,SAAS,CAI9F"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/core/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAc,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEtF;;;mCAGmC;AACnC,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC;CAC/B;AAiBD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAM3E;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAU,SAAS,mBAAmB,EAAE,MAAM,SAAS,KAAG,OAAO,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAyBtH,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,cAAc,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,CAQpF,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/core/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAc,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEtF;;;mCAGmC;AACnC,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC;CAC/B;AAiBD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAM3E;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAU,SAAS,mBAAmB,EAAE,MAAM,SAAS,KAAG,OAAO,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAkCtH,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,cAAc,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,CAQpF,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC"}
package/dist/core.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./plugin-BrWEBWRb.cjs");exports.TOOL_DEFINITION=e.o,exports.TOOL_NAME=e.s,exports.chartArtifactPath=e.i,exports.executeChart=e.t,exports.isValidChartDocument=e.n,exports.pluginCore=e.r,exports.slugify=e.a;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./plugin-DmM0zBCB.cjs");exports.TOOL_DEFINITION=e.o,exports.TOOL_NAME=e.s,exports.chartArtifactPath=e.i,exports.executeChart=e.t,exports.isValidChartDocument=e.n,exports.pluginCore=e.r,exports.slugify=e.a;
package/dist/core.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "./plugin-DIFaou52.js";
1
+ import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "./plugin-DkH_ssdv.js";
2
2
  export { r as TOOL_DEFINITION, a as TOOL_NAME, t as chartArtifactPath, o as executeChart, n as isValidChartDocument, i as pluginCore, e as slugify };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./plugin-BrWEBWRb.cjs");require("./core.cjs"),exports.TOOL_DEFINITION=e.o,exports.TOOL_NAME=e.s,exports.chartArtifactPath=e.i,exports.executeChart=e.t,exports.isValidChartDocument=e.n,exports.pluginCore=e.r,exports.slugify=e.a;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./plugin-DmM0zBCB.cjs");require("./core.cjs"),exports.TOOL_DEFINITION=e.o,exports.TOOL_NAME=e.s,exports.chartArtifactPath=e.i,exports.executeChart=e.t,exports.isValidChartDocument=e.n,exports.pluginCore=e.r,exports.slugify=e.a;
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "./plugin-DIFaou52.js";
1
+ import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "./plugin-DkH_ssdv.js";
2
2
  import "./core.js";
3
3
  export { r as TOOL_DEFINITION, a as TOOL_NAME, t as chartArtifactPath, o as executeChart, n as isValidChartDocument, i as pluginCore, e as slugify };
@@ -46,15 +46,20 @@ var e = "presentChart", t = {
46
46
  },
47
47
  required: ["document"]
48
48
  }
49
- }, n = "charts", r = "artifacts";
50
- function i(e, t = "chart") {
51
- return e && e.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || t;
49
+ }, n = "charts", r = "artifacts", i = 120;
50
+ function a(e, t = "chart") {
51
+ if (!e) return t;
52
+ let n = e.toLowerCase().replace(/[^a-z0-9]+/g, "-"), r = 0, a = n.length;
53
+ for (; r < a && n[r] === "-";) r += 1;
54
+ for (; a > r && n[a - 1] === "-";) --a;
55
+ for (a - r > i && (a = r + i); a > r && n[a - 1] === "-";) --a;
56
+ return n.slice(r, a) || t;
52
57
  }
53
- function a(e) {
58
+ function o(e) {
54
59
  return `${e.getUTCFullYear()}/${String(e.getUTCMonth() + 1).padStart(2, "0")}`;
55
60
  }
56
- function o(e, t = /* @__PURE__ */ new Date()) {
57
- let o = `${i(e)}-${t.getTime()}.chart.json`, s = `${n}/${a(t)}/${o}`;
61
+ function s(e, t = /* @__PURE__ */ new Date()) {
62
+ let i = `${a(e)}-${t.getTime()}.chart.json`, s = `${n}/${o(t)}/${i}`;
58
63
  return {
59
64
  relPath: s,
60
65
  filePath: `${r}/${s}`
@@ -62,21 +67,25 @@ function o(e, t = /* @__PURE__ */ new Date()) {
62
67
  }
63
68
  //#endregion
64
69
  //#region src/core/plugin.ts
65
- function s(e) {
66
- return typeof e == "object" && !!e && !Array.isArray(e);
67
- }
68
70
  function c(e) {
69
- return e === void 0 || typeof e == "string";
71
+ return typeof e == "object" && !!e && !Array.isArray(e);
70
72
  }
71
73
  function l(e) {
72
- return !s(e) || !c(e.title) || !c(e.type) ? !1 : s(e.option);
74
+ return e === void 0 || typeof e == "string";
73
75
  }
74
76
  function u(e) {
75
- return !s(e) || !c(e.title) || !Array.isArray(e.charts) || e.charts.length === 0 ? !1 : e.charts.every((e) => l(e));
77
+ return !c(e) || !l(e.title) || !l(e.type) ? !1 : c(e.option);
78
+ }
79
+ function d(e) {
80
+ return !c(e) || !l(e.title) || !Array.isArray(e.charts) || e.charts.length === 0 ? !1 : e.charts.every((e) => u(e));
76
81
  }
77
- var d = async (e, t) => {
82
+ var f = async (e, t) => {
83
+ if (!c(t)) return {
84
+ message: "presentChart args must be an object containing a `document`",
85
+ instructions: "Acknowledge the error and retry with { document: { charts: [{ option: {...} }] } }."
86
+ };
78
87
  let { document: n, title: r } = t;
79
- if (!u(n)) return {
88
+ if (!d(n)) return {
80
89
  message: "document must be { charts: [{ option: {...}, title?, type? }, ...] } with at least one entry",
81
90
  instructions: "Acknowledge that the chart could not be created and retry with a valid ECharts document shape."
82
91
  };
@@ -84,9 +93,9 @@ var d = async (e, t) => {
84
93
  message: "title must be a string when provided",
85
94
  instructions: "Acknowledge the error and retry with a string title (or omit it)."
86
95
  };
87
- let { relPath: i, filePath: a } = o(r ?? n.title ?? "chart");
96
+ let { relPath: i, filePath: a } = s(r ?? n.title ?? "chart");
88
97
  await e.files.artifacts.write(i, `${JSON.stringify(n, null, 2)}\n`);
89
- let s = n.charts.length;
98
+ let o = n.charts.length;
90
99
  return {
91
100
  message: `Saved chart document to ${a}`,
92
101
  data: {
@@ -94,13 +103,13 @@ var d = async (e, t) => {
94
103
  title: r,
95
104
  filePath: a
96
105
  },
97
- instructions: `Acknowledge that the chart(s) have been presented to the user. The document contains ${s} chart${s === 1 ? "" : "s"}.`
106
+ instructions: `Acknowledge that the chart(s) have been presented to the user. The document contains ${o} chart${o === 1 ? "" : "s"}.`
98
107
  };
99
- }, f = {
108
+ }, p = {
100
109
  toolDefinition: t,
101
- execute: d,
110
+ execute: f,
102
111
  generatingMessage: "Rendering chart…",
103
112
  isEnabled: () => !0
104
113
  };
105
114
  //#endregion
106
- export { i as a, o as i, u as n, t as o, f as r, e as s, d as t };
115
+ export { a, s as i, d as n, t as o, p as r, e as s, f as t };
@@ -0,0 +1 @@
1
+ var e=`presentChart`,t={type:`function`,name:e,description:"Save and present one or more Apache ECharts visualizations as a single document. Use this for line, bar, area, scatter, pie, candlestick, heatmap, sankey, or graph/network charts — anything ECharts supports. Pass ECharts option object(s) directly; the plugin calls setOption on each one. Use `charts: []` array form even for a single chart so multi-chart dashboards share the same slug.",parameters:{type:`object`,properties:{document:{type:`object`,description:`Chart document. Contains an optional title and an array of chart entries. Each entry has its own ECharts option object that the UI renders independently.`,properties:{title:{type:`string`,description:`Optional human-friendly title for the whole document. Used to derive the file slug and as the preview label.`},charts:{type:`array`,description:`List of charts to render, in order. Each charts[i].option is passed as-is to ECharts' setOption().`,items:{type:`object`,properties:{title:{type:`string`,description:`Optional short label for this specific chart (shown above it in the UI).`},type:{type:`string`,description:`Informational tag shown in the UI (e.g. 'line', 'bar', 'candlestick', 'sankey'). The actual chart type is determined by option.series[].type.`},option:{type:`object`,description:`Full ECharts option object. Include all series, axes, tooltip, legend, dataset — anything ECharts accepts. Keep data inline; large datasets are fine.`}},required:[`option`]}}},required:[`charts`]},title:{type:`string`,description:`Short label shown in the canvas preview sidebar. Defaults to document.title, or 'Chart' when both are blank.`}},required:[`document`]}},n=`charts`,r=`artifacts`,i=120;function a(e,t=`chart`){if(!e)return t;let n=e.toLowerCase().replace(/[^a-z0-9]+/g,`-`),r=0,a=n.length;for(;r<a&&n[r]===`-`;)r+=1;for(;a>r&&n[a-1]===`-`;)--a;for(a-r>i&&(a=r+i);a>r&&n[a-1]===`-`;)--a;return n.slice(r,a)||t}function o(e){return`${e.getUTCFullYear()}/${String(e.getUTCMonth()+1).padStart(2,`0`)}`}function s(e,t=new Date){let i=`${a(e)}-${t.getTime()}.chart.json`,s=`${n}/${o(t)}/${i}`;return{relPath:s,filePath:`${r}/${s}`}}function c(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function l(e){return e===void 0||typeof e==`string`}function u(e){return!c(e)||!l(e.title)||!l(e.type)?!1:c(e.option)}function d(e){return!c(e)||!l(e.title)||!Array.isArray(e.charts)||e.charts.length===0?!1:e.charts.every(e=>u(e))}var f=async(e,t)=>{if(!c(t))return{message:"presentChart args must be an object containing a `document`",instructions:`Acknowledge the error and retry with { document: { charts: [{ option: {...} }] } }.`};let{document:n,title:r}=t;if(!d(n))return{message:`document must be { charts: [{ option: {...}, title?, type? }, ...] } with at least one entry`,instructions:`Acknowledge that the chart could not be created and retry with a valid ECharts document shape.`};if(r!==void 0&&typeof r!=`string`)return{message:`title must be a string when provided`,instructions:`Acknowledge the error and retry with a string title (or omit it).`};let{relPath:i,filePath:a}=s(r??n.title??`chart`);await e.files.artifacts.write(i,`${JSON.stringify(n,null,2)}\n`);let o=n.charts.length;return{message:`Saved chart document to ${a}`,data:{document:n,title:r,filePath:a},instructions:`Acknowledge that the chart(s) have been presented to the user. The document contains ${o} chart${o===1?``:`s`}.`}},p={toolDefinition:t,execute:f,generatingMessage:`Rendering chart…`,isEnabled:()=>!0};Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return f}});
package/dist/vue.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=require("./plugin-BrWEBWRb.cjs");let l=require("vue"),u=require("echarts");u=s(u,1);let d=require("gui-chat-protocol/vue");var f={de:{untitled:`Diagramm`,chartCount:e=>`${e} Diagramm${e===1?``:`e`}`,chartTitle:e=>`Diagramm ${e}`,png:`PNG`},en:{untitled:`Chart`,chartCount:e=>`${e} chart${e===1?``:`s`}`,chartTitle:e=>`Chart ${e}`,png:`PNG`},es:{untitled:`Gráfico`,chartCount:e=>`${e} gráfico${e===1?``:`s`}`,chartTitle:e=>`Gráfico ${e}`,png:`PNG`},fr:{untitled:`Graphique`,chartCount:e=>`${e} graphique${e===1?``:`s`}`,chartTitle:e=>`Graphique ${e}`,png:`PNG`},ja:{untitled:`チャート`,chartCount:e=>`${e} チャート`,chartTitle:e=>`チャート ${e}`,png:`PNG`},ko:{untitled:`차트`,chartCount:e=>`${e}개 차트`,chartTitle:e=>`차트 ${e}`,png:`PNG`},"pt-BR":{untitled:`Gráfico`,chartCount:e=>`${e} gráfico${e===1?``:`s`}`,chartTitle:e=>`Gráfico ${e}`,png:`PNG`},zh:{untitled:`图表`,chartCount:e=>`${e} 个图表`,chartTitle:e=>`图表 ${e}`,png:`PNG`}};function p(e){return Object.prototype.hasOwnProperty.call(f,e)}function m(){let e=(0,l.inject)(d.PLUGIN_RUNTIME_KEY,void 0)?.locale??(0,l.ref)(`en`);return(0,l.computed)(()=>p(e.value)?f[e.value]:f.en)}var h={class:`h-full flex flex-col overflow-hidden`},g={class:`px-4 py-2 border-b border-gray-100 shrink-0 flex items-center justify-between`},_={class:`text-sm font-medium text-gray-700 truncate`},v={class:`text-xs text-gray-500 shrink-0`},y={class:`flex-1 overflow-y-auto p-4 space-y-4`},b=[`data-testid`],x={class:`px-3 py-2 border-b border-gray-100 flex items-center justify-between gap-2`},S={class:`flex items-center gap-2 min-w-0`},C={class:`text-sm font-medium text-gray-800 truncate`},w={key:0,class:`text-[10px] uppercase tracking-wide rounded px-1.5 py-0.5 bg-blue-50 text-blue-700 shrink-0`},T=[`data-testid`,`onClick`],E=[`data-testid`],D=(0,l.defineComponent)({__name:`View`,props:{selectedResult:{}},setup(e){let t=m(),n=e,r=(0,l.computed)(()=>n.selectedResult.data),i=(0,l.computed)(()=>r.value?.document?.charts??[]),a=(0,l.computed)(()=>r.value?.title??r.value?.document?.title),o=(0,l.ref)([]),s=[];function c(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function d(e,t){o.value[e]=t}function f(){for(let e of s)e.dispose();s.length=0}function p(e){let{dataZoom:t}=e;if(t==null)return e;let n=e=>c(e)?{...e,zoomOnMouseWheel:!1,moveOnMouseWheel:!1}:e,r=Array.isArray(t)?t.map(n):n(t);return{...e,dataZoom:r}}function D(){f();for(let e=0;e<i.value.length;e+=1){let t=o.value[e],n=i.value[e];if(!t||!n)continue;let r=u.init(t);try{r.setOption(p(n.option))}catch{}s[e]=r}}function O(){for(let e of s)e.resize()}(0,l.onMounted)(()=>{queueMicrotask(D),window.addEventListener(`resize`,O)}),(0,l.onBeforeUnmount)(()=>{window.removeEventListener(`resize`,O),f()}),(0,l.watch)(()=>r.value?.filePath,()=>queueMicrotask(D));function k(e,t){let n=s[e];if(!n)return;let r=n.getDataURL({type:`png`,pixelRatio:2,backgroundColor:`#ffffff`}),i=(t??a.value??`chart`).toLowerCase().replace(/[^a-z0-9-]+/g,`-`);for(;i.startsWith(`-`);)i=i.slice(1);for(;i.endsWith(`-`);)i=i.slice(0,-1);i||=`chart`;let o=document.createElement(`a`);o.href=r,o.download=`${i}-${e+1}.png`,document.body.appendChild(o),o.click(),document.body.removeChild(o)}return(e,n)=>((0,l.openBlock)(),(0,l.createElementBlock)(`div`,h,[(0,l.createElementVNode)(`div`,g,[(0,l.createElementVNode)(`span`,_,(0,l.toDisplayString)(a.value??(0,l.unref)(t).untitled),1),(0,l.createElementVNode)(`span`,v,(0,l.toDisplayString)((0,l.unref)(t).chartCount(i.value.length)),1)]),(0,l.createElementVNode)(`div`,y,[((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,null,(0,l.renderList)(i.value,(e,r)=>((0,l.openBlock)(),(0,l.createElementBlock)(`div`,{key:r,class:`border border-gray-200 rounded-lg bg-white`,"data-testid":`chart-card-${r}`},[(0,l.createElementVNode)(`div`,x,[(0,l.createElementVNode)(`div`,S,[(0,l.createElementVNode)(`span`,C,(0,l.toDisplayString)(e.title??(0,l.unref)(t).chartTitle(r+1)),1),e.type?((0,l.openBlock)(),(0,l.createElementBlock)(`span`,w,(0,l.toDisplayString)(e.type),1)):(0,l.createCommentVNode)(``,!0)]),(0,l.createElementVNode)(`button`,{class:`px-2 py-1 text-xs rounded border border-gray-300 text-gray-500 hover:bg-gray-50 shrink-0`,"data-testid":`chart-export-png-${r}`,onClick:t=>k(r,e.title)},[n[0]||=(0,l.createElementVNode)(`span`,{class:`material-icons text-sm align-middle`},`download`,-1),(0,l.createTextVNode)(` `+(0,l.toDisplayString)((0,l.unref)(t).png),1)],8,T)]),(0,l.createElementVNode)(`div`,{ref_for:!0,ref:e=>d(r,e),class:`w-full h-[400px]`,"data-testid":`chart-canvas-${r}`},null,8,E)],8,b))),128))])]))}}),O={class:`p-2 text-sm`},k={class:`font-medium text-gray-700 truncate mb-1`},A={key:0,class:`text-xs text-gray-500 leading-relaxed truncate`},j=(0,l.defineComponent)({__name:`Preview`,props:{result:{}},setup(e){let t=e,n=(0,l.computed)(()=>t.result.data),r=(0,l.computed)(()=>n.value?.title??n.value?.document?.title??`Chart`),i=(0,l.computed)(()=>{let e=n.value?.document?.charts??[];if(e.length===0)return``;let t=e.map(e=>e.type??a(e.option)).filter(e=>!!e).slice(0,3),r=e.length>t.length?`, …`:``,i=t.join(`, `),o=e.length===1?``:`s`,s=i?`: ${i}${r}`:``;return`${e.length} chart${o}${s}`});function a(e){let{series:t}=e;if(Array.isArray(t)&&t.length>0){let e=t[0];if(typeof e.type==`string`)return e.type}else if(t&&typeof t==`object`){let e=t.type;if(typeof e==`string`)return e}return null}return(e,t)=>((0,l.openBlock)(),(0,l.createElementBlock)(`div`,O,[(0,l.createElementVNode)(`div`,k,(0,l.toDisplayString)(r.value),1),i.value?((0,l.openBlock)(),(0,l.createElementBlock)(`div`,A,(0,l.toDisplayString)(i.value),1)):(0,l.createCommentVNode)(``,!0)]))}}),M={...c.r,viewComponent:D,previewComponent:j},N={plugin:M};exports.Preview=j,exports.TOOL_DEFINITION=c.o,exports.TOOL_NAME=c.s,exports.View=D,exports.default=N,exports.executeChart=c.t,exports.isValidChartDocument=c.n,exports.plugin=M,exports.pluginCore=c.r;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=require("./plugin-DmM0zBCB.cjs");let l=require("vue"),u=require("echarts");u=s(u,1);let d=require("gui-chat-protocol/vue");var f={de:{untitled:`Diagramm`,chartCount:e=>`${e} Diagramm${e===1?``:`e`}`,chartTitle:e=>`Diagramm ${e}`,png:`PNG`},en:{untitled:`Chart`,chartCount:e=>`${e} chart${e===1?``:`s`}`,chartTitle:e=>`Chart ${e}`,png:`PNG`},es:{untitled:`Gráfico`,chartCount:e=>`${e} gráfico${e===1?``:`s`}`,chartTitle:e=>`Gráfico ${e}`,png:`PNG`},fr:{untitled:`Graphique`,chartCount:e=>`${e} graphique${e===1?``:`s`}`,chartTitle:e=>`Graphique ${e}`,png:`PNG`},ja:{untitled:`チャート`,chartCount:e=>`${e} チャート`,chartTitle:e=>`チャート ${e}`,png:`PNG`},ko:{untitled:`차트`,chartCount:e=>`${e}개 차트`,chartTitle:e=>`차트 ${e}`,png:`PNG`},"pt-BR":{untitled:`Gráfico`,chartCount:e=>`${e} gráfico${e===1?``:`s`}`,chartTitle:e=>`Gráfico ${e}`,png:`PNG`},zh:{untitled:`图表`,chartCount:e=>`${e} 个图表`,chartTitle:e=>`图表 ${e}`,png:`PNG`}};function p(e){return Object.prototype.hasOwnProperty.call(f,e)}function m(){let e=(0,l.inject)(d.PLUGIN_RUNTIME_KEY,void 0)?.locale??(0,l.ref)(`en`);return(0,l.computed)(()=>p(e.value)?f[e.value]:f.en)}var h={class:`h-full flex flex-col overflow-hidden`},g={class:`px-4 py-2 border-b border-gray-100 shrink-0 flex items-center justify-between`},_={class:`text-sm font-medium text-gray-700 truncate`},v={class:`text-xs text-gray-500 shrink-0`},y={class:`flex-1 overflow-y-auto p-4 space-y-4`},b=[`data-testid`],x={class:`px-3 py-2 border-b border-gray-100 flex items-center justify-between gap-2`},S={class:`flex items-center gap-2 min-w-0`},C={class:`text-sm font-medium text-gray-800 truncate`},w={key:0,class:`text-[10px] uppercase tracking-wide rounded px-1.5 py-0.5 bg-blue-50 text-blue-700 shrink-0`},T=[`data-testid`,`onClick`],E=[`data-testid`],D=(0,l.defineComponent)({__name:`View`,props:{selectedResult:{}},setup(e){let t=m(),n=e,r=(0,l.computed)(()=>n.selectedResult.data),i=(0,l.computed)(()=>r.value?.document?.charts??[]),a=(0,l.computed)(()=>r.value?.title??r.value?.document?.title),o=(0,l.ref)([]),s=[];function c(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function d(e,t){o.value[e]=t}function f(){for(let e of s)e.dispose();s.length=0}function p(e){let{dataZoom:t}=e;if(t==null)return e;let n=e=>c(e)?{...e,zoomOnMouseWheel:!1,moveOnMouseWheel:!1}:e,r=Array.isArray(t)?t.map(n):n(t);return{...e,dataZoom:r}}function D(){f();for(let e=0;e<i.value.length;e+=1){let t=o.value[e],n=i.value[e];if(!t||!n)continue;let r=u.init(t);try{r.setOption(p(n.option))}catch{}s[e]=r}}function O(){for(let e of s)e.resize()}(0,l.onMounted)(()=>{queueMicrotask(D),window.addEventListener(`resize`,O)}),(0,l.onBeforeUnmount)(()=>{window.removeEventListener(`resize`,O),f()}),(0,l.watch)(()=>r.value?.filePath,()=>queueMicrotask(D));function k(e,t){let n=s[e];if(!n)return;let r=n.getDataURL({type:`png`,pixelRatio:2,backgroundColor:`#ffffff`}),i=(t??a.value??`chart`).toLowerCase().replace(/[^a-z0-9-]+/g,`-`);for(;i.startsWith(`-`);)i=i.slice(1);for(;i.endsWith(`-`);)i=i.slice(0,-1);i||=`chart`;let o=document.createElement(`a`);o.href=r,o.download=`${i}-${e+1}.png`,document.body.appendChild(o),o.click(),document.body.removeChild(o)}return(e,n)=>((0,l.openBlock)(),(0,l.createElementBlock)(`div`,h,[(0,l.createElementVNode)(`div`,g,[(0,l.createElementVNode)(`span`,_,(0,l.toDisplayString)(a.value??(0,l.unref)(t).untitled),1),(0,l.createElementVNode)(`span`,v,(0,l.toDisplayString)((0,l.unref)(t).chartCount(i.value.length)),1)]),(0,l.createElementVNode)(`div`,y,[((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,null,(0,l.renderList)(i.value,(e,r)=>((0,l.openBlock)(),(0,l.createElementBlock)(`div`,{key:r,class:`border border-gray-200 rounded-lg bg-white`,"data-testid":`chart-card-${r}`},[(0,l.createElementVNode)(`div`,x,[(0,l.createElementVNode)(`div`,S,[(0,l.createElementVNode)(`span`,C,(0,l.toDisplayString)(e.title??(0,l.unref)(t).chartTitle(r+1)),1),e.type?((0,l.openBlock)(),(0,l.createElementBlock)(`span`,w,(0,l.toDisplayString)(e.type),1)):(0,l.createCommentVNode)(``,!0)]),(0,l.createElementVNode)(`button`,{class:`px-2 py-1 text-xs rounded border border-gray-300 text-gray-500 hover:bg-gray-50 shrink-0`,"data-testid":`chart-export-png-${r}`,onClick:t=>k(r,e.title)},[n[0]||=(0,l.createElementVNode)(`span`,{class:`material-icons text-sm align-middle`},`download`,-1),(0,l.createTextVNode)(` `+(0,l.toDisplayString)((0,l.unref)(t).png),1)],8,T)]),(0,l.createElementVNode)(`div`,{ref_for:!0,ref:e=>d(r,e),class:`w-full h-[400px]`,"data-testid":`chart-canvas-${r}`},null,8,E)],8,b))),128))])]))}}),O={class:`p-2 text-sm`},k={class:`font-medium text-gray-700 truncate mb-1`},A={key:0,class:`text-xs text-gray-500 leading-relaxed truncate`},j=(0,l.defineComponent)({__name:`Preview`,props:{result:{}},setup(e){let t=e,n=(0,l.computed)(()=>t.result.data),r=(0,l.computed)(()=>n.value?.title??n.value?.document?.title??`Chart`),i=(0,l.computed)(()=>{let e=n.value?.document?.charts??[];if(e.length===0)return``;let t=e.map(e=>e.type??a(e.option)).filter(e=>!!e).slice(0,3),r=e.length>t.length?`, …`:``,i=t.join(`, `),o=e.length===1?``:`s`,s=i?`: ${i}${r}`:``;return`${e.length} chart${o}${s}`});function a(e){let{series:t}=e;if(Array.isArray(t)&&t.length>0){let e=t[0];if(typeof e.type==`string`)return e.type}else if(t&&typeof t==`object`){let e=t.type;if(typeof e==`string`)return e}return null}return(e,t)=>((0,l.openBlock)(),(0,l.createElementBlock)(`div`,O,[(0,l.createElementVNode)(`div`,k,(0,l.toDisplayString)(r.value),1),i.value?((0,l.openBlock)(),(0,l.createElementBlock)(`div`,A,(0,l.toDisplayString)(i.value),1)):(0,l.createCommentVNode)(``,!0)]))}}),M={...c.r,viewComponent:D,previewComponent:j},N={plugin:M};exports.Preview=j,exports.TOOL_DEFINITION=c.o,exports.TOOL_NAME=c.s,exports.View=D,exports.default=N,exports.executeChart=c.t,exports.isValidChartDocument=c.n,exports.plugin=M,exports.pluginCore=c.r;
package/dist/vue.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as e, o as t, r as n, s as r, t as i } from "./plugin-DIFaou52.js";
1
+ import { n as e, o as t, r as n, s as r, t as i } from "./plugin-DkH_ssdv.js";
2
2
  import { Fragment as a, computed as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createTextVNode as u, defineComponent as d, inject as f, onBeforeUnmount as p, onMounted as m, openBlock as h, ref as g, renderList as _, toDisplayString as v, unref as y, watch as b } from "vue";
3
3
  import * as x from "echarts";
4
4
  import { PLUGIN_RUNTIME_KEY as S } from "gui-chat-protocol/vue";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mulmoclaude/chart-plugin",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "ECharts visualization plugin (presentChart) — shared gui-chat-protocol plugin for MulmoClaude and MulmoTerminal. Server-side write goes through the generic files.artifacts runtime capability.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1 +0,0 @@
1
- var e=`presentChart`,t={type:`function`,name:e,description:"Save and present one or more Apache ECharts visualizations as a single document. Use this for line, bar, area, scatter, pie, candlestick, heatmap, sankey, or graph/network charts — anything ECharts supports. Pass ECharts option object(s) directly; the plugin calls setOption on each one. Use `charts: []` array form even for a single chart so multi-chart dashboards share the same slug.",parameters:{type:`object`,properties:{document:{type:`object`,description:`Chart document. Contains an optional title and an array of chart entries. Each entry has its own ECharts option object that the UI renders independently.`,properties:{title:{type:`string`,description:`Optional human-friendly title for the whole document. Used to derive the file slug and as the preview label.`},charts:{type:`array`,description:`List of charts to render, in order. Each charts[i].option is passed as-is to ECharts' setOption().`,items:{type:`object`,properties:{title:{type:`string`,description:`Optional short label for this specific chart (shown above it in the UI).`},type:{type:`string`,description:`Informational tag shown in the UI (e.g. 'line', 'bar', 'candlestick', 'sankey'). The actual chart type is determined by option.series[].type.`},option:{type:`object`,description:`Full ECharts option object. Include all series, axes, tooltip, legend, dataset — anything ECharts accepts. Keep data inline; large datasets are fine.`}},required:[`option`]}}},required:[`charts`]},title:{type:`string`,description:`Short label shown in the canvas preview sidebar. Defaults to document.title, or 'Chart' when both are blank.`}},required:[`document`]}},n=`charts`,r=`artifacts`;function i(e,t=`chart`){return e&&e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||t}function a(e){return`${e.getUTCFullYear()}/${String(e.getUTCMonth()+1).padStart(2,`0`)}`}function o(e,t=new Date){let o=`${i(e)}-${t.getTime()}.chart.json`,s=`${n}/${a(t)}/${o}`;return{relPath:s,filePath:`${r}/${s}`}}function s(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function c(e){return e===void 0||typeof e==`string`}function l(e){return!s(e)||!c(e.title)||!c(e.type)?!1:s(e.option)}function u(e){return!s(e)||!c(e.title)||!Array.isArray(e.charts)||e.charts.length===0?!1:e.charts.every(e=>l(e))}var d=async(e,t)=>{let{document:n,title:r}=t;if(!u(n))return{message:`document must be { charts: [{ option: {...}, title?, type? }, ...] } with at least one entry`,instructions:`Acknowledge that the chart could not be created and retry with a valid ECharts document shape.`};if(r!==void 0&&typeof r!=`string`)return{message:`title must be a string when provided`,instructions:`Acknowledge the error and retry with a string title (or omit it).`};let{relPath:i,filePath:a}=o(r??n.title??`chart`);await e.files.artifacts.write(i,`${JSON.stringify(n,null,2)}\n`);let s=n.charts.length;return{message:`Saved chart document to ${a}`,data:{document:n,title:r,filePath:a},instructions:`Acknowledge that the chart(s) have been presented to the user. The document contains ${s} chart${s===1?``:`s`}.`}},f={toolDefinition:t,execute:d,generatingMessage:`Rendering chart…`,isEnabled:()=>!0};Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return d}});