agentic-mermaid 0.5.4 → 0.5.6

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.
Files changed (133) hide show
  1. package/AGENT_NATIVE.md +5 -9
  2. package/CHANGELOG.md +66 -0
  3. package/Instructions_for_agents.md +171 -97
  4. package/README.md +1 -1
  5. package/dist/agent-core.d.ts +7 -7
  6. package/dist/agent-core.js +1 -1
  7. package/dist/agent.d.ts +9 -10
  8. package/dist/agent.js +1 -1
  9. package/dist/agentic-mermaid-mcp.js +1 -1
  10. package/dist/am.js +1 -1
  11. package/dist/browser-lazy/chunks/{agentic-producer-core-ECZ3CMZM.js → agentic-producer-core-MYYZCUJS.js} +1 -1
  12. package/dist/browser-lazy/chunks/{architecture-H5LTMKQW.js → architecture-OHEIJI33.js} +6 -6
  13. package/dist/browser-lazy/chunks/{block-566X6FNV.js → block-DMBSQUFZ.js} +6 -6
  14. package/dist/browser-lazy/chunks/{builtin-backends-VAFEZXKY.js → builtin-backends-JTN3XG37.js} +3 -3
  15. package/dist/browser-lazy/chunks/{c4-ZXFDLBFK.js → c4-TK5GVVGU.js} +3 -3
  16. package/dist/browser-lazy/chunks/{chunk-7UFOFWBA.js → chunk-2R6M4CUH.js} +1 -1
  17. package/dist/browser-lazy/chunks/{chunk-YVNJDVQO.js → chunk-3K25OV6X.js} +1 -1
  18. package/dist/browser-lazy/chunks/{chunk-QVSZOF5M.js → chunk-3QXHJBE3.js} +1 -1
  19. package/dist/browser-lazy/chunks/{chunk-IUI4DYC3.js → chunk-4G652M75.js} +1 -1
  20. package/dist/browser-lazy/chunks/{chunk-LBXXKLIR.js → chunk-4WON4RCG.js} +3 -3
  21. package/dist/browser-lazy/chunks/{chunk-V6I2VGNQ.js → chunk-5SZ2YBKG.js} +9 -9
  22. package/dist/browser-lazy/chunks/{chunk-XHU3A432.js → chunk-CJZMMNPO.js} +1 -1
  23. package/dist/browser-lazy/chunks/{chunk-5LKPDHPC.js → chunk-F4CQMYR2.js} +4 -4
  24. package/dist/browser-lazy/chunks/{chunk-G4JBA7HU.js → chunk-GK5PSUKH.js} +3 -3
  25. package/dist/browser-lazy/chunks/{chunk-VRZKI33U.js → chunk-HAMXYU5V.js} +1 -1
  26. package/dist/browser-lazy/chunks/{chunk-Z7UHFVKN.js → chunk-IFUYPCDA.js} +6 -6
  27. package/dist/browser-lazy/chunks/{chunk-3JTYTXA6.js → chunk-ILCWDEZN.js} +4 -4
  28. package/dist/browser-lazy/chunks/{chunk-64JFHCJC.js → chunk-JJFXEH35.js} +1 -1
  29. package/dist/browser-lazy/chunks/{chunk-PXTLV57R.js → chunk-KOO3MCMJ.js} +1 -1
  30. package/dist/browser-lazy/chunks/{chunk-A7V5VDKN.js → chunk-LO25KEJY.js} +1 -1
  31. package/dist/browser-lazy/chunks/{chunk-TT5GR5EJ.js → chunk-MGB5QQEH.js} +1 -1
  32. package/dist/browser-lazy/chunks/{chunk-PSZEE64O.js → chunk-NVZKY7UI.js} +8 -8
  33. package/dist/browser-lazy/chunks/{chunk-6UOOATQR.js → chunk-PA7YKMP5.js} +1 -1
  34. package/dist/browser-lazy/chunks/{chunk-NKW2ZNCD.js → chunk-PS4HSV54.js} +1 -1
  35. package/dist/browser-lazy/chunks/{chunk-OBI5U5XU.js → chunk-QG67RIGQ.js} +1 -1
  36. package/dist/browser-lazy/chunks/{chunk-J57YRC2M.js → chunk-QOIFBX26.js} +1 -1
  37. package/dist/browser-lazy/chunks/chunk-QQCKPJF3.js +1 -0
  38. package/dist/browser-lazy/chunks/{chunk-O34YYEQV.js → chunk-QXSPMZ67.js} +1 -1
  39. package/dist/browser-lazy/chunks/{chunk-4NILRBC7.js → chunk-QYORAVMZ.js} +1 -1
  40. package/dist/browser-lazy/chunks/{chunk-OFOS57WQ.js → chunk-SC7LXD2V.js} +1 -1
  41. package/dist/browser-lazy/chunks/{chunk-EIYLJ4FI.js → chunk-SZAI2WB4.js} +12 -12
  42. package/dist/browser-lazy/chunks/{chunk-37FZNMPR.js → chunk-TXYQEDUF.js} +1 -1
  43. package/dist/browser-lazy/chunks/{chunk-2JQXRKBC.js → chunk-VR6YRNUZ.js} +1 -1
  44. package/dist/browser-lazy/chunks/{chunk-7TTFBJYA.js → chunk-WNTLLJPT.js} +1 -1
  45. package/dist/browser-lazy/chunks/{chunk-62MR3LWJ.js → chunk-YYF5TS6K.js} +1 -1
  46. package/dist/browser-lazy/chunks/{class-XIFNVBFE.js → class-QOJOM2XO.js} +8 -8
  47. package/dist/browser-lazy/chunks/{er-VEUYJBGG.js → er-2W6UXQT7.js} +6 -6
  48. package/dist/browser-lazy/chunks/{eventmodeling-G7DITZX7.js → eventmodeling-IVAFIO2U.js} +9 -9
  49. package/dist/browser-lazy/chunks/{flowchart-SSFIU4EU.js → flowchart-Y6OWQ46O.js} +1 -1
  50. package/dist/browser-lazy/chunks/{gantt-HQNVDX2B.js → gantt-BXTFJPZM.js} +6 -6
  51. package/dist/browser-lazy/chunks/{gitgraph-Z5MN6M6L.js → gitgraph-PW6R75SQ.js} +4 -4
  52. package/dist/browser-lazy/chunks/{ishikawa-UEERNFQV.js → ishikawa-GFX3XQQZ.js} +2 -2
  53. package/dist/browser-lazy/chunks/{journey-3BEWWGB5.js → journey-Q3M2GVKJ.js} +7 -7
  54. package/dist/browser-lazy/chunks/{kanban-2WFNCWLB.js → kanban-WVGVXROE.js} +11 -11
  55. package/dist/browser-lazy/chunks/{mindmap-R2C6SNYR.js → mindmap-CEDNSFJ6.js} +6 -6
  56. package/dist/browser-lazy/chunks/{packet-GMVCI5YZ.js → packet-Z56OVP2O.js} +3 -3
  57. package/dist/browser-lazy/chunks/{pie-WER45DKC.js → pie-FOJURIAM.js} +7 -7
  58. package/dist/browser-lazy/chunks/{quadrant-NCUPSFKN.js → quadrant-OGUQEK5C.js} +4 -4
  59. package/dist/browser-lazy/chunks/{radar-WLYS4YC5.js → radar-XTAUIQIJ.js} +9 -9
  60. package/dist/browser-lazy/chunks/render-core-QRFSDWGQ.js +3 -0
  61. package/dist/browser-lazy/chunks/{requirement-AK3NWMJ6.js → requirement-KEJ7ILX2.js} +7 -7
  62. package/dist/browser-lazy/chunks/{sankey-C2DY6WVU.js → sankey-ODWGDRAM.js} +8 -8
  63. package/dist/browser-lazy/chunks/{sequence-D4WJB44W.js → sequence-4ZNQR7S7.js} +1 -1
  64. package/dist/browser-lazy/chunks/{state-YUQVESE7.js → state-6IWPVJ4C.js} +2 -2
  65. package/dist/browser-lazy/chunks/{timeline-BMBJJXWR.js → timeline-LPJMPVPV.js} +4 -4
  66. package/dist/browser-lazy/chunks/{treemap-B66XBZZ6.js → treemap-2KFOQZRA.js} +4 -4
  67. package/dist/browser-lazy/chunks/xychart-KIPWFNVQ.js +16 -0
  68. package/dist/browser-lazy/chunks/{zenuml-62RLYFWP.js → zenuml-2ABFLOUP.js} +6 -6
  69. package/dist/browser-lazy/index.js +1 -1
  70. package/dist/browser.global.js +436 -436
  71. package/dist/chunk-3QC3FE2X.js +4 -0
  72. package/dist/{chunk-XU5LPD2D.js → chunk-5BYN55G4.js} +1 -1
  73. package/dist/chunk-5XKELJT2.js +2 -0
  74. package/dist/chunk-7HIKKNPP.js +150 -0
  75. package/dist/chunk-A5TX2FW5.js +2 -0
  76. package/dist/chunk-AS6A6XHE.js +2 -0
  77. package/dist/{chunk-DOFB572I.js → chunk-CGCGMO4U.js} +15 -15
  78. package/dist/chunk-GO4CS5KS.js +52 -0
  79. package/dist/{chunk-KXMANAST.js → chunk-JRLCGATA.js} +47 -47
  80. package/dist/{chunk-7XYB2LNC.js → chunk-K6TYUPTW.js} +2 -2
  81. package/dist/{chunk-HINRNKPO.js → chunk-QVP364DJ.js} +2 -2
  82. package/dist/chunk-V5RFODN6.js +2 -0
  83. package/dist/cli-PVKOWT4V.js +191 -0
  84. package/dist/elk-constructor.js +1 -1
  85. package/dist/{index-Bvhprdxz.d.ts → index-Bs7imZCS.d.ts} +14 -4
  86. package/dist/index.d.ts +4 -4
  87. package/dist/index.js +1 -1
  88. package/dist/{jsonl-RPJY6YWO.js → jsonl-5N4DTV7P.js} +2 -2
  89. package/dist/mcp-cli-EPIA7DTH.js +2 -0
  90. package/dist/{paint-certification-BoLyr006.d.ts → paint-certification-aIPtFDcn.d.ts} +2 -2
  91. package/dist/server-X6OFY2ZN.js +527 -0
  92. package/dist/{svg-styles-BnCoXyYe.d.ts → svg-styles-DfHloZTH.d.ts} +1 -1
  93. package/dist/svg-styles.d.ts +1 -1
  94. package/dist/svg-styles.js +1 -1
  95. package/dist/svg.d.ts +4 -4
  96. package/dist/svg.js +1 -1
  97. package/dist/{types-CLVJCaH2.d.ts → types-DkUbM48-.d.ts} +1 -1
  98. package/dist/zenuml/chunks/{appearance-5RM5MVM2.js → appearance-ROFRJDW7.js} +1 -1
  99. package/dist/zenuml/chunks/{builtin-backends-UTNWL4N3.js → builtin-backends-LM2A6WWK.js} +2 -2
  100. package/dist/zenuml/chunks/{chunk-ZNZRIISS.js → chunk-E6ZQYSVJ.js} +2 -2
  101. package/dist/zenuml/chunks/{chunk-IARQ24W3.js → chunk-KCHXQ5UA.js} +2 -2
  102. package/dist/zenuml/chunks/{chunk-3A6S6GNB.js → chunk-TEDVLVJM.js} +1 -1
  103. package/dist/zenuml/chunks/{chunk-CNLL4BGF.js → chunk-WD3ZPN3X.js} +1 -1
  104. package/dist/zenuml/chunks/{chunk-6J4BGPB2.js → chunk-WUHZDXTF.js} +24 -24
  105. package/dist/zenuml/chunks/{chunk-55WS466K.js → chunk-ZGLUBUQJ.js} +9 -9
  106. package/dist/zenuml/chunks/{render-core-ECIWU5ZS.js → render-core-WTHYSKBN.js} +2 -2
  107. package/dist/zenuml/chunks/{zenuml-N3LZMB2G.js → zenuml-3TCHUQJZ.js} +8 -8
  108. package/dist/zenuml.d.ts +2 -2
  109. package/dist/zenuml.js +1 -1
  110. package/docs/api.md +84 -4
  111. package/docs/quality.md +6 -3
  112. package/docs/style-authoring.md +23 -0
  113. package/docs/testing-strategy.md +59 -52
  114. package/examples/styles/readme-hero.md +4 -3
  115. package/package.json +4 -4
  116. package/server.json +2 -2
  117. package/skills/agentic-mermaid-diagram-workflow/SKILL.md +19 -154
  118. package/skills/agentic-mermaid-diagram-workflow/references/code-mode.md +12 -2
  119. package/skills/agentic-mermaid-diagram-workflow/references/hosted-mcp.md +5 -1
  120. package/dist/browser-lazy/chunks/chunk-6GPDLZFQ.js +0 -1
  121. package/dist/browser-lazy/chunks/render-core-42UVWIPF.js +0 -3
  122. package/dist/browser-lazy/chunks/xychart-HAVFROGT.js +0 -16
  123. package/dist/chunk-2DNGDTJD.js +0 -2
  124. package/dist/chunk-4F2UGYTM.js +0 -4
  125. package/dist/chunk-EHJI3QYE.js +0 -52
  126. package/dist/chunk-MKE7GNYU.js +0 -146
  127. package/dist/chunk-U4MT3RRE.js +0 -2
  128. package/dist/chunk-VUFVLGTH.js +0 -2
  129. package/dist/chunk-WYIB6BUR.js +0 -2
  130. package/dist/cli-ZYIDBYNS.js +0 -226
  131. package/dist/mcp-cli-YVDCORWA.js +0 -2
  132. package/dist/server-4JGAVXR3.js +0 -524
  133. package/docs/MCP-DIRECTORY-LISTINGS.md +0 -145
@@ -0,0 +1,4 @@
1
+ import{Ab as q,Cb as K,Db as X,Pa as U,Qa as B,Ta as N,Xa as j,Za as z,tb as H,ua as V,ub as Y}from"./chunk-JRLCGATA.js";import{K as k,Qd as W,T as D,Ua as w,Za as L,ab as y,bb as M,qb as G}from"./chunk-CGCGMO4U.js";import{a as he}from"./chunk-V5RFODN6.js";import{fileURLToPath as Ze}from"url";import{createRequire as Qe}from"module";import{tmpdir as et}from"os";import{basename as tt,dirname as le,join as T}from"path";import{existsSync as rt,mkdtempSync as nt,rmSync as ye,writeFileSync as st}from"fs";function J(e){if(!e.includes("auto-start-reverse"))return e;const r=L(e);const t=new Set(r.map(n=>y(n,"id")).filter(Boolean));const i=new Map;const s=[];for(const n of r){if(n.name!=="marker"||y(n,"orient")!=="auto-start-reverse")continue;const c=y(n,"id");if(!c||n.selfClosing)continue;const a=e.indexOf("</marker>",n.end);if(a<0)throw new Error(`Unclosed native marker ${c}`);const f=y(n,"viewBox")?.trim().split(/[\s,]+/).map(Number);const u=Number(y(n,"markerWidth")??3);const m=Number(y(n,"markerHeight")??3);const[p,l,b,O]=f??[0,0,u,m];const I=Number(y(n,"refX")??0);const S=Number(y(n,"refY")??0);if(![p,l,b,O,I,S].every(E=>typeof E==="number"&&Number.isFinite(E))){throw new Error(`Native marker ${c} requires numeric coordinates`)}let g=`${c}-native-start`;while(t.has(g))g+="-";t.add(g);i.set(c,g);const R=p+b/2,v=l+O/2;const $={id:w(g),orient:"auto",refX:String(2*R-I),refY:String(2*v-S)};let x=M(e.slice(n.start,n.end),E=>$[E.name]);for(const E of["refX","refY"]){if(!n.attributes.some(Re=>Re.name===E))x=x.replace(/>$/,` ${E}="${$[E]}">`)}s.push({at:a+"</marker>".length,content:`
2
+ ${x}<g transform="rotate(180 ${R} ${v})">${e.slice(n.end,a)}</g></marker>`})}let o=e;for(const n of s.reverse())o=o.slice(0,n.at)+n.content+o.slice(n.at);return M(o,(n,c)=>{if(c.name==="marker"&&n.name==="orient"&&n.value==="auto-start-reverse")return"auto";if(n.name!=="marker-start")return void 0;const a=/^url\(#([^)]*)\)$/.exec(y(c,"marker-start")??"")?.[1];const f=a?i.get(a):void 0;return f?`url(#${w(f)})`:void 0})}import{readdirSync as Fe,readFileSync as Te,statSync as Ae}from"fs";import{join as ve}from"path";import{decodeXML as Ee}from"entities";var Se=1668112752;var Pe=1953784678;var be=1330926671;var Oe=1953658213;function Ie(e){const r=new DataView(e.buffer,e.byteOffset,e.byteLength);try{if(r.getUint32(0)===Pe){const i=[];for(let s=0;s<r.getUint32(8);s++)i.push(Z(r,r.getUint32(12+s*4)));return i.filter(s=>s.length>0)}const t=Z(r,0);return t.length>0?[t]:[]}catch{return[]}}function Z(e,r){const t=e.getUint32(r);if(t!==65536&&t!==be&&t!==Oe)return[];const i=e.getUint16(r+4);for(let s=0;s<i;s++){const o=r+12+s*16;if(e.getUint32(o)===Se)return Ue(e,e.getUint32(o+8))}return[]}function Ue(e,r){const t=[];const i=e.getUint16(r+2);for(let s=0;s<i;s++){const o=r+4+s*8;const n=e.getUint16(o);const c=e.getUint16(o+2);if(!(n===0||n===3&&(c===1||c===10)))continue;const a=r+e.getUint32(o+4);const f=e.getUint16(a);if(f===4)t.push(xe(e,a));else if(f===12)t.push(we(e,a));else if(f===6)t.push(Me(e,a));else if(f===0)t.push(Ne(e,a))}return t}function xe(e,r){const t=e.getUint16(r+6)/2;const i=r+14;const s=i+t*2+2;const o=s+t*2;const n=o+t*2;return{has(c){if(c>65535)return false;let a=0,f=t-1;while(a<f){const l=a+f>>1;if(e.getUint16(i+l*2)<c)a=l+1;else f=l}if(e.getUint16(s+a*2)>c||c===65535)return false;const u=e.getUint16(n+a*2);if(u===0)return(c+e.getInt16(o+a*2)&65535)!==0;const m=n+a*2+u+(c-e.getUint16(s+a*2))*2;if(m+2>e.byteLength)return false;const p=e.getUint16(m);return p!==0&&(p+e.getInt16(o+a*2)&65535)!==0}}}function we(e,r){const t=e.getUint32(r+12);const i=r+16;return{has(s){let o=0,n=t-1;while(o<=n){const c=o+n>>1;const a=i+c*12;if(s<e.getUint32(a))n=c-1;else if(s>e.getUint32(a+4))o=c+1;else return e.getUint32(a+8)+s-e.getUint32(a)!==0}return false}}}function Me(e,r){const t=e.getUint16(r+6);const i=e.getUint16(r+8);return{has:s=>s>=t&&s<t+i&&e.getUint16(r+10+(s-t)*2)!==0}}function Ne(e,r){return{has:t=>t<256&&e.getUint8(r+6+t)!==0}}function Ce(e){let r="";for(const t of e.matchAll(/<text\b[^>]*>([\s\S]*?)<\/text>/g))r+=t[1].replace(/<[^>]*>/g,"");return Ee(r)}function _e(e){return e<=32||e===127||e>=8203&&e<=8207||e===8232||e===8233||e>=65024&&e<=65039||e===65279}function Q(e){if(e>=11904&&e<=40959||e>=44032&&e<=55295||e>=63744&&e<=64255||e>=131072&&e<=262143)return"CJK";if(e>=9728&&e<=10175||e>=126976&&e<=129791)return"emoji";if(e>=1424&&e<=1535)return"Hebrew";if(e>=1536&&e<=1919)return"Arabic";if(e>=2304&&e<=2431)return"Devanagari";return"other"}function ee(e,r){const t=r.flatMap(Ie);const i=new Map;for(const s of k(Ce(e))){const o=[...s].map(a=>a.codePointAt(0)).filter(a=>!_e(a));if(o.length===0)continue;const n=t.some(a=>o.every(f=>a.some(u=>u.has(f))));const c=s.includes("\u200D")||/\p{Mark}/u.test(s);if(n&&!c)continue;for(const a of o){const f=i.get(Q(a))??new Set;f.add(a);i.set(Q(a),f)}}return[...i].sort(([s],[o])=>s<o?-1:s>o?1:0).map(([s,o])=>({script:s,chars:[...o].sort((n,c)=>n-c).map(n=>String.fromCodePoint(n))}))}var $e=/\.(ttf|otf|ttc|otc)$/i;function te(e,r=4){if(r<0)return[];let t;try{t=Fe(e).sort()}catch{return[]}const i=[];for(const s of t){const o=ve(e,s);try{const n=Ae(o);if(n.isDirectory())i.push(...te(o,r-1));else if($e.test(s))i.push(o)}catch{}}return i}function ke(e){const r=[];for(const t of e){for(const i of te(t)){try{r.push(new Uint8Array(Te(i)))}catch{}}}return r}function re(e,r,t){return ee(e,[...t,...ke(r)])}function ne(e,r={}){return e.map(({script:t,chars:i})=>{const s=i.slice(0,5).join(" ");const o=r.systemFontsMayCover?" They are absent from bundled/caller-provided fonts; an installed system font may cover them, so final shaping is machine-dependent.":" They may draw as tofu or fail to shape as one grapheme.";return{code:"PNG_FONT_COVERAGE",script:t,chars:[...i],message:`no known loaded face covers ${i.length} ${t} character${i.length===1?"":"s"} (${s}) in one grapheme cluster.${o} Supply fontDirs (CLI: --font-dirs <dir>) with a face that covers the cluster.`}})}import{createHash as De}from"crypto";import{closeSync as C,constants as se,fstatSync as _,lstatSync as oe,openSync as Le,readSync as Ge,realpathSync as ie}from"fs";import{isAbsolute as ae,join as We,relative as ce,sep as F}from"path";var d=class extends Error{code;resourceId;constructor(r,t,i){super(`${r}: ${i}`);this.name="ResourceResolutionError";this.code=r;this.resourceId=t}};function fe(e){return typeof e==="object"&&e!==null&&"code"in e?String(e.code):void 0}function Ve(e){return De("sha256").update(e).digest("hex")}function Be(e,r){if(e==="linux")return`/proc/self/fd/${r}`;if(e==="darwin")return`/dev/fd/${r}`;return void 0}var P=class{#e;#t;#r;#n;#s;constructor(r,t,i={}){let s;try{s=U(t)}catch(n){const c=n instanceof Error?n.message.replace(/^INVALID_RESOURCE_MANIFEST:\s*/,""):String(n);throw new d("INVALID_RESOURCE_MANIFEST","resource-manifest",c)}const o=i.maxResourceBytes??16*1024*1024;if(!Number.isSafeInteger(o)||o<=0){throw new d("INVALID_RESOURCE_MANIFEST","resource-manifest","maxResourceBytes must be a positive safe integer")}try{this.#e=ie(r)}catch{throw new d("RESOURCE_MISSING","resource-manifest",`package root does not exist: ${r}`)}this.#t=s;this.#r=o;this.#n=Object.freeze({...i.mediaTypes??B});this.#s=new Map(this.#t.resources.map(n=>[n.identity.id,n]))}list(){return this.#t.resources}#o(r,t,i){const s=t.split("/");let o=this.#e;for(const c of s){o=We(o,c);let a;try{a=oe(o)}catch(f){if(fe(f)==="ENOENT"){throw new d(i,r.identity.id,`declared path is missing: ${t}`)}throw f}if(a.isSymbolicLink()){throw new d("RESOURCE_SYMLINK_REJECTED",r.identity.id,`symlink component is forbidden: ${t}`)}}const n=ce(this.#e,o);if(n===".."||n.startsWith(`..${F}`)||ae(n)){throw new d("RESOURCE_PATH_ESCAPE",r.identity.id,`path escapes package root: ${t}`)}return o}#i(r,t,i){const s=this.#o(r,t,i);let o;try{o=Le(s,se.O_RDONLY|se.O_NOFOLLOW)}catch(n){const c=fe(n);if(c==="ENOENT")throw new d(i,r.identity.id,`declared path is missing: ${t}`);if(c==="ELOOP")throw new d("RESOURCE_SYMLINK_REJECTED",r.identity.id,`symlink component is forbidden: ${t}`);throw n}try{const n=_(o);if(!n.isFile()){throw new d("RESOURCE_NOT_REGULAR",r.identity.id,`resource is not a regular file: ${t}`)}const c=Be(process.platform,o);if(c){const u=ie(c);if(u!==c&&!u.startsWith(`${c}${F}`)){const m=ce(this.#e,u);if(m===".."||m.startsWith(`..${F}`)||ae(m)){throw new d("RESOURCE_PATH_ESCAPE",r.identity.id,`opened file escapes package root: ${t}`)}}}const a=this.#o(r,t,i);const f=oe(a);if(!f.isFile()){throw new d("RESOURCE_NOT_REGULAR",r.identity.id,`resource is not a regular file: ${t}`)}if(n.dev!==f.dev||n.ino!==f.ino){throw new d("RESOURCE_PATH_ESCAPE",r.identity.id,`opened file identity no longer matches the rooted path: ${t}`)}return o}catch(n){C(o);throw n}}resolve(r){const t=this.#s.get(r);if(!t)throw new d("UNKNOWN_RESOURCE",r,`resource is not installed: ${r}`);if(t.bytes>this.#r){throw new d("RESOURCE_SIZE_LIMIT",r,`${t.bytes} exceeds the ${this.#r}-byte host limit`)}const i=this.#i(t,t.license.noticePath,"RESOURCE_LICENSE_NOTICE_MISSING");C(i);const s=this.#i(t,t.path,"RESOURCE_MISSING");let o;try{const f=_(s);if(f.size!==t.bytes){throw new d("RESOURCE_SIZE_MISMATCH",r,`declared ${t.bytes} bytes but found ${f.size}`)}const u=new Uint8Array(t.bytes+1);let m=0;while(m<u.byteLength){const l=Ge(s,u,m,u.byteLength-m,null);if(l===0)break;m+=l}const p=_(s);if(m!==t.bytes||p.size!==t.bytes){throw new d("RESOURCE_SIZE_MISMATCH",r,`declared ${t.bytes} bytes but securely read ${m}`)}o=u.slice(0,m)}finally{C(s)}const n=this.#n[t.mediaType];if(!n||!n(o)){throw new d("RESOURCE_MEDIA_TYPE_MISMATCH",r,`resource bytes do not match ${t.mediaType}`)}const c=Ve(o);if(c!==t.sha256){throw new d("RESOURCE_DIGEST_MISMATCH",r,`expected ${t.sha256}, received ${c}`)}const a=o.slice();return Object.freeze({entry:t,readBytes:()=>a.slice()})}verifyInstalled(){const r=[];const t=[];for(const i of this.#t.resources){try{r.push(this.resolve(i.identity.id))}catch(s){if(!i.required&&s instanceof d&&s.code==="RESOURCE_MISSING"){t.push(Object.freeze({code:"OPTIONAL_RESOURCE_MISSING",resourceId:i.identity.id,message:s.message}));continue}throw s}}return Object.freeze({resources:Object.freeze(r),diagnostics:Object.freeze(t)})}};import{tmpdir as je}from"os";import{dirname as ze,join as de}from"path";import{mkdirSync as He,mkdtempSync as Ye,readFileSync as qe,rmSync as Ke,writeFileSync as Xe}from"fs";var ue;function Je(e,r){const t=U(e);const i=new Map;for(const o of t.resources){i.set(o.path,{resourceId:o.identity.id,missingCode:"RESOURCE_MISSING"});if(!i.has(o.license.noticePath)){i.set(o.license.noticePath,{resourceId:o.identity.id,missingCode:"RESOURCE_LICENSE_NOTICE_MISSING"})}}const s=Ye(de(je(),"agentic-mermaid-embedded-resources-"));try{const o=new Set;for(const n of r){const c=i.get(n.manifestPath);if(!c){throw new d("UNKNOWN_RESOURCE",n.manifestPath,`embedded path is not declared by the font resource manifest: ${n.manifestPath}`)}if(o.has(n.manifestPath)){throw new d("INVALID_RESOURCE_MANIFEST",c.resourceId,`duplicate embedded path: ${n.manifestPath}`)}let a;try{a=qe(n.embeddedPath)}catch{throw new d(c.missingCode,c.resourceId,`embedded source is unavailable for declared path: ${n.manifestPath}`)}const f=de(s,n.manifestPath);He(ze(f),{recursive:true,mode:448});Xe(f,a,{flag:"wx",mode:256});o.add(n.manifestPath)}return new P(s,t).verifyInstalled()}finally{try{Ke(s,{recursive:true,force:true})}catch{}}}function me(e){return ue?Je(e,ue):void 0}var h;var pe=false;function ge(e){const r=nt(T(et(),"agentic-mermaid-fonts-"));try{const t=e.map(s=>s.readBytes());const i=t.map((s,o)=>{const n=T(r,`${o}-${tt(e[o].entry.path)}`);st(n,s,{flag:"wx",mode:256});return n});return Object.freeze({snapshotDirectory:r,buffers:Object.freeze(t),files:Object.freeze(i)})}catch(t){try{ye(r,{recursive:true,force:true})}catch{}throw t}}function ot(){if(h)return h;const e=typeof import.meta.url==="string"?Ze(import.meta.url):__filename;let r=le(e);for(let t=0;t<6;t++){const i=T(r,"assets","fonts");if(rt(i)){const o=new P(r,N).verifyInstalled();h=ge(o.resources);break}const s=le(r);if(s===r)break;r=s}if(!h){const t=me(N);if(t)h=ge(t.resources)}if(!h)throw new Error("RESOURCE_MISSING: required bundled font manifest could not be located");if(!pe){pe=true;process.once("exit",()=>{try{if(h)ye(h.snapshotDirectory,{recursive:true,force:true})}catch{}})}return h}function Yt(e,r={}){return it(e,r).png}function it(e,r={}){return A(e,r,{})}function qt(e={}){const r=W(e.backendPolicy);const t=D(e.textMeasurement);const i=Object.freeze({...r?{backendPolicy:r}:{},...t?{textMeasurement:t}:{}});return Object.freeze({renderMermaidPNG(s,o={}){return A(s,o,i).png},renderMermaidPNGWithReceipt(s,o={}){return A(s,o,i)}})}function A(e,r,t,i){const s=i?.input??V(e);const o=s.source;const n=r.onWarning;if(n!==void 0&&typeof n!=="function"){throw new TypeError("PNG onWarning must be a function")}const c=H(r);const a=Y(r);const f=X(o,a,c,{backendPolicy:t.backendPolicy,textMeasurement:t.textMeasurement,expectedFamilyId:s.expectedFamilyId},i?.consumeLayout);const u=f.outputPolicy;const m=K(J(G(f.svg)),f.rasterDimensions);const p=ot();const l=n??(R=>process.stderr.write(`agentic-mermaid renderMermaidPNG: warning ${R.code}: ${R.message}
3
+ `));for(const R of ne(re(m,u.fonts.callerDirectories,p.buffers),{systemFontsMayCover:u.fonts.loadSystemFonts}))l(R);for(const R of f.legibilityWarnings)l(R);const b={background:f.rasterBackground,fitTo:{mode:"zoom",value:1},font:{loadSystemFonts:u.fonts.loadSystemFonts,fontFiles:[...p.files],fontDirs:[...u.fonts.callerDirectories],defaultFontFamily:u.fonts.defaultFamily}};const{Resvg:O}=typeof Bun!=="undefined"?he("@resvg/resvg-js"):Qe(import.meta.url)("@resvg/resvg-js");const I=new O(m,b);const S=z(I.render().asPng());const g=j(S);if(g.width!==f.rasterDimensions.width||g.height!==f.rasterDimensions.height){throw new Error(`native PNG rasterizer returned ${g.width}\xD7${g.height}; expected ${f.rasterDimensions.width}\xD7${f.rasterDimensions.height}`)}return{png:new Uint8Array(S.buffer,S.byteOffset,S.byteLength),receipt:f.receipt,runtime:q(u.fonts)}}export{Yt as a,it as b,qt as c,A as d};
4
+ //# sourceMappingURL=chunk-3QC3FE2X.js.map
@@ -1,2 +1,2 @@
1
1
  var e="New diagrams: author Mermaid source directly, then parse \u2192 verify \u2192 render or return it.";var t="Existing structured diagrams: parse \u2192 narrow \u2192 mutate \u2192 verify \u2192 serialize.";var r="`buildMermaid(kind, ops)` / `createMermaid(kind)` build a diagram from typed ops when you are generating one programmatically (for example, from data).";var a="Narrowing selects a structured, typed family with an as* helper. It does not select one element or freeze layout coordinates.";var i=`${e} ${r}`;export{t as a,a as b,i as c};
2
- //# sourceMappingURL=chunk-XU5LPD2D.js.map
2
+ //# sourceMappingURL=chunk-5BYN55G4.js.map
@@ -0,0 +1,2 @@
1
+ import{d as L}from"./chunk-3QC3FE2X.js";import{Q as F,c as M,e as I,s as k,t as C}from"./chunk-A5TX2FW5.js";import{Xa as P,sa as w,ua as v}from"./chunk-JRLCGATA.js";import{jj as x}from"./chunk-GO4CS5KS.js";import{Za as b,ab as g}from"./chunk-CGCGMO4U.js";import{z as s}from"./chunk-O7H2UX5K.js";function A(e){if(e.kind==="node")return`node:${e.id}`;if(e.kind==="edge")return`edge:${e.id}`;if(e.kind==="label")return`label:${e.id}`;return`group:${e.id}`}function O(e){return e==="subgraph"?"cluster":e}function G(e,r){const t=e.parentId!==void 0&&e.parentKind!==void 0?A({id:e.parentId,kind:e.parentKind}):void 0;return{id:A(e),kind:O(e.kind),elementId:e.id,...t!==void 0&&r.has(t)?{parentId:t}:{},bounds:{x:s(e.canvasColStart),y:s(e.canvasRow),w:s(Math.max(1,e.canvasColEnd-e.canvasColStart)),h:s(Math.max(1,e.rowSpan??1))},...e.ownedCellSpans?{cellSpans:e.ownedCellSpans}:{},...e.occludedCellSpans?{occludedCellSpans:e.occludedCellSpans}:{},...e.sourceLine!==void 0?{sourceLine:e.sourceLine}:{}}}function y(e,r,t,o,p=new Set){const a=new Map(o.map(n=>[n.id,n]));const c=t.map(n=>{const u=n.regionId?a.get(n.regionId):void 0;return{...n,surface:e,disposition:e==="svg"&&u&&n.href!==void 0&&p.has(`${n.target}\0${n.href}`)?"embedded-inert":"sidecar-only",...u?{region:u}:{}}});const i=new Set(c.flatMap(n=>n.region?[n.region.id]:[]));return{version:1,format:e,coordinateSpace:r,regions:o.filter(n=>i.has(n.id)),actions:c}}function N(e){const r=new Set;for(const t of b(e)){const o=g(t,"data-href");const p=[g(t,"data-task"),g(t,"data-id")];if(o!==void 0){for(const i of p)if(i!==void 0)r.add(`${i}\0${o}`)}const a=g(t,"data-links");const c=p.find(i=>i!==void 0);if(a===void 0||c===void 0)continue;try{const i=JSON.parse(a);if(!i||typeof i!=="object"||Array.isArray(i))continue;for(const n of Object.values(i)){if(typeof n==="string")r.add(`${c}\0${n}`)}}catch{}}return r}function W(e,r,t){return e.map(o=>({...o,bounds:{x:s(o.bounds.x*r),y:s(o.bounds.y*t),w:s(o.bounds.w*r),h:s(o.bounds.h*t)}}))}function Y(e,r){const t=v(e);const o=t.source;if(r.format==="ascii"||r.format==="unicode"){const d=I(e,{...r.options??{},useAscii:r.format==="ascii"});const R=d.warnings.find(l=>l.code==="ASCII_RENDER_FAILED");if(R)throw new Error(R.message);const f=new Set(d.regions.map(A));const D=d.regions.map(l=>G(l,f));return{format:r.format,output:d.ascii,actionSurface:y(r.format,"cell",d.actions,D),warnings:d.warnings}}const p=r.options??{};const a=w(o);if(!a.ok)throw new Error(a.error.map(d=>d.message).join("; "));const c=typeof e==="string"?a.value:e;const i={};const n={validate:k,consume(d,R){const f=C(d,R,{debug:void 0});if(!f)throw new Error(`No public layout projection registered for Mermaid family "${c.kind}"`);f.regions=F(c,f);i.layout=f}};const u=M(a.value);if(r.format==="svg"){const d=x(o,p,"svg",void 0,{expectedFamilyId:t.expectedFamilyId},n).svg;return{format:"svg",output:d,actionSurface:y("svg","pixel",u,i.layout.regions??[],N(d))}}const S=L(e,p,{},{input:t,consumeLayout:n}).png;const m=i.layout;const h=P(S);const $=W(m.regions??[],m.bounds.w>0?h.width/m.bounds.w:1,m.bounds.h>0?h.height/m.bounds.h:1);return{format:"png",output:S,actionSurface:y("png","pixel",u,$)}}export{Y as a};
2
+ //# sourceMappingURL=chunk-5XKELJT2.js.map
@@ -0,0 +1,150 @@
1
+ import{b as N}from"./chunk-5BYN55G4.js";import{A as g,H as w,K as y,L as v,O as k}from"./chunk-O7H2UX5K.js";var I={"agent-instructions":{},ascii:{},markdown:{},certificates:{},help:{},json:{},jsonl:{},watch:{},open:{},force:{},"canonical-wrapper":{},"preserve-source":{},"system-fonts":{},suppress:{arg:"CODES"},"label-cap":{arg:"N"},op:{arg:"JSON"},style:{arg:"NAMES|file"},seed:{arg:"N"},options:{arg:"JSON|file"},"graph-layout":{arg:"elk|agentic"},"graph-layout-fallback":{arg:"none|elk"},ops:{arg:"JSON|file"},output:{arg:"FILE"},format:{arg:"fmt"},security:{arg:"mode"},dir:{arg:"DIR"},"font-dirs":{arg:"DIRS"},"gantt-today":{arg:"DATE"},"target-width":{arg:"CELLS"},scale:{arg:"N"},bg:{arg:"COLOR"},"fit-width":{arg:"PX"},"fit-height":{arg:"PX"},"min-label-px":{arg:"PX"},o:{arg:"FILE"}};var c=I;var u=new Set(Object.keys(c).filter(i=>!c[i].arg));function m(i,e){if(!u.has(e))throw new Error(`--${e} is not a boolean flag`);return Boolean(i.flags[e])}function L(i,e){if(!(e in c)||u.has(e))throw new Error(`--${e} is not a value flag`);const n=i.flags[e];return typeof n==="string"?n:void 0}var C=Object.freeze({scale:Object.freeze(["scale"]),background:Object.freeze(["bg"]),fitTo:Object.freeze(["fit-width","fit-height"]),minLabelPx:Object.freeze(["min-label-px"]),fontDirs:Object.freeze(["font-dirs"]),loadSystemFonts:Object.freeze(["system-fonts"]),onWarning:Object.freeze([])});var M=Object.freeze(Object.values(C).flat());var E={render:["help","json","certificates","watch","style","seed","options","graph-layout","graph-layout-fallback","output","format","security","gantt-today","target-width",...M,"o"],verify:["help","json","suppress","label-cap","style","markdown"],parse:["help","json"],serialize:["help"],mutate:["help","json","op","ops","preserve-source"],preview:["help","json","output","open","security"],format:["help","canonical-wrapper"],describe:["help","json","format"],capabilities:["help","json"],styles:["help","json"],"llms-txt":["help"],"init-agent":["help","json","dir","force"],batch:["help","jsonl"],"render-markdown":["help","ascii"]};var S=Object.freeze({render:{min:0,max:Number.POSITIVE_INFINITY},verify:{min:0,max:1},parse:{min:0,max:1},serialize:{min:0,max:0},mutate:{min:0,max:1},preview:{min:0,max:1},format:{min:0,max:1},describe:{min:0,max:1},capabilities:{min:0,max:0},styles:{min:0,max:0},"llms-txt":{min:0,max:0},"init-agent":{min:0,max:0},batch:{min:0,max:0},"render-markdown":{min:0,max:1}});function A(i){const e={positional:[],flags:{},errors:[]};const n=(t,s)=>{if(Object.prototype.hasOwnProperty.call(e.flags,t)){e.errors.push(`Flag --${t} may be supplied only once.`);return}e.flags[t]=s};let r=0;while(r<i.length){const t=i[r];if(t==="--"){for(const s of i.slice(r+1)){if(!e.command)e.command=s;else e.positional.push(s)}break}if(t.startsWith("--")){const s=t.indexOf("=");const o=t.slice(2,s===-1?void 0:s);if(s!==-1){if(u.has(o))e.errors.push(`Flag --${o} does not accept a value.`);n(o,t.slice(s+1))}else{const l=i[r+1];if(u.has(o)||l===void 0||l.startsWith("--"))n(o,true);else{n(o,l);r++}}}else if(!e.command)e.command=t;else e.positional.push(t);r++}return e}var f=`Usage: am <command> [options] [file|-]
2
+
3
+ Commands:
4
+ render <file|-> Render through a registered output adapter
5
+ verify <file|-> Verify; emits structured JSON warnings
6
+ parse <file|-> Parse; emits ValidDiagram JSON
7
+ serialize Read ValidDiagram JSON from stdin; emit canonical source
8
+ mutate <file|-> --op '<JSON>' Apply MutationOp(s); verify + emit source
9
+ preview <file|-> Write standalone HTML preview; optionally --open
10
+ format <file|-> Idempotent reformat
11
+ describe <file|-> Prose summary or AX-tree JSON
12
+ capabilities Emit JSON describing families + warning codes + mutation ops
13
+ batch Read JSONL ops from stdin; emit one JSON envelope per line
14
+ render-markdown <file> Render fenced mermaid blocks in Markdown (SVG or --ascii)
15
+ styles List registered styles (looks + themes); see also render --style
16
+ llms-txt Emit the agent discovery digest
17
+ init-agent Write a repo-local agent drop-in (AGENTS section, skill, MCP config)
18
+
19
+ Flags:
20
+ --json Structured JSON output
21
+ --ascii For render-markdown: ASCII instead of SVG
22
+ --op <JSON> For mutate: one MutationOp
23
+ --ops <JSON|file> For mutate: JSON array of MutationOps
24
+ --preserve-source For mutate: edit supported source ranges without regenerating opaque syntax
25
+ --output <FILE> Write render/preview output to FILE instead of stdout
26
+ --open For preview: open generated HTML in browser
27
+ --force For init-agent: refresh generated skill/MCP files
28
+ --style <NAMES|file> Style stack \u2014 comma-separated names and/or .json spec files
29
+ --options <JSON|file> Shared advanced render options across output adapters
30
+ --seed <N> Re-roll ink wobble of styled looks (never layout)
31
+ --font-dirs <DIRS> For render png: extra font directories, comma-separated (CJK/emoji coverage)
32
+ --system-fonts For render png: also load OS fonts (coverage warnings then skipped)
33
+ --suppress <CODES> For verify: comma-separated WarningCodes to suppress
34
+ --label-cap <N> For verify: LABEL_OVERFLOW char cap (default 40)
35
+ --certificates For render --format layout: include route/family certificates
36
+ --gantt-today <DATE> For render: draw the gantt today marker at DATE (rendering never reads the wall clock)
37
+ --target-width <CELLS> Hard terminal-cell bound for ASCII/Unicode output
38
+ --agent-instructions Print the canonical agent-use guide
39
+ --help Show this message (or per-command help: am <cmd> --help)
40
+
41
+ Exit codes:
42
+ 0 ok
43
+ 2 arg / parse error (bad flag, missing file, malformed JSON)
44
+ 3 verify reported errors (severity 'error')
45
+ 4 uncaught internal failure, or verify errors that are all INTERNAL_ERROR
46
+ `;function O(i){const e=Object.keys(g).filter(r=>g[r]===i);const n=[];for(const r of e){const t=n.at(-1);if(t!==void 0&&t.length+r.length+2<=100)n[n.length-1]=`${t}, ${r}`;else n.push(r)}return n.join(",\n")}var x={render:`am render <file|-> [--format ${y.join("|")}] [--json]
47
+ Render a diagram. Default is ${v.toUpperCase()}.
48
+ ${k()}
49
+ --certificates With --format layout, include route/family certificates
50
+ --style <S> Style stack: comma-separated names and/or .json spec files,
51
+ merged left \u2192 right (e.g. --style hand-drawn,dracula or
52
+ --style ./brand.json). Applies to graphical and terminal
53
+ projection. See: am styles
54
+ --options <JSON|file> Shared advanced RenderOptions object; convenience
55
+ flags override its fields
56
+ --graph-layout <elk|agentic> Graph geometry producer (default: elk)
57
+ --graph-layout-fallback <none|elk> Explicit Agentic fallback (default: none)
58
+ --seed <N> Re-roll ink wobble of styled looks; never moves layout
59
+ --font-dirs <DIRS> PNG only: extra font directories (comma-separated) for
60
+ scripts the bundled Inter/DejaVu fonts don't cover (CJK,
61
+ emoji); uncovered characters warn on stderr
62
+ --system-fonts PNG only: also load OS-installed fonts (trades cross-machine
63
+ determinism for coverage; skips coverage warnings)
64
+ --security strict Enforce the strict SVG output-security policy
65
+ --gantt-today <DATE> Gantt only: draw the today marker at DATE (in the
66
+ diagram's dateFormat or ISO YYYY-MM-DD); rendering never
67
+ reads the wall clock, so without this the marker is absent
68
+ --target-width <CELLS> ASCII/Unicode only: hard output bound in display cells;
69
+ impossible geometry fails with ASCII_TARGET_WIDTH_IMPOSSIBLE
70
+ --scale <N> PNG only: output scale multiplier (default ${w})
71
+ --bg <COLOR> PNG only: override the diagram background (white fallback)
72
+ --fit-width <PX> PNG only: fit output to this pixel width
73
+ --fit-height <PX> PNG only: fit output to this pixel height (mutually exclusive with --fit-width)
74
+ --min-label-px <PX> PNG only: warn below this effective text size
75
+ (provisional default 9; 0 disables)
76
+ --watch Re-render one input file on change (non-PNG only)
77
+ Multiple inputs emit a JSON results array for non-PNG formats.
78
+ With --json, textual forms wrap output as {"<format>": "..."}.`,styles:`am styles [--json]
79
+ List every registered style. A style is a partial description of how diagrams
80
+ look; a colors-only style is a palette, a full look sets stroke/fill/typography
81
+ too. Stack them with render --style (e.g. --style hand-drawn,dracula) and
82
+ re-roll ink with --seed. Custom styles are JSON records (docs/style-authoring.md);
83
+ pass a .json file path anywhere a name is accepted.
84
+ With --json: [{ name, canonicalId, kind: look|palette, isDefault, backend, intent?, blurb }].`,verify:`am verify <file|-> [--markdown] [--suppress A,B] [--label-cap N] [--style NAMES|file]
85
+ Always emits JSON: {ok, warnings[], layout}.
86
+ With --markdown: verify top-level Mermaid fences and emit {ok,file,blocks[]}.
87
+ Nested list/blockquote fences require host extraction; HTML examples are skipped.
88
+ Warnings use physical document lines; lineIsBlockStart marks a fallback when
89
+ no precise source line is available. Backtick and tilde fences are supported.
90
+ --style <S> Resolve the same named/file-backed Style used by render so
91
+ inspect-only Brand constraints evaluate the styled Scene.
92
+ Error codes flip ok=false:
93
+ ${O("error")}.
94
+ RENDER_FAILED: the strict render parser, layout, or theme colors reject the source
95
+ or its configuration; origin says which.
96
+ INTERNAL_ERROR: an Agentic Mermaid defect, not the source; defaultRender says
97
+ whether an ordinary render still produces output. Report it with the source.
98
+ BRAND_CONSTRAINT_ERROR: only when a Style constraint explicitly selects action=error.
99
+ Warning codes:
100
+ ${O("warning")}.
101
+ LABEL_OVERFLOW counts characters against --label-cap.
102
+ Brand constraints inspect without repainting or relayout; other Tier-3 lint is advisory.
103
+ Exit 0 if ok, 3 if verify reports severity='error', 4 if every such error is INTERNAL_ERROR.`,parse:`am parse <file|->
104
+ Emits ValidDiagram JSON (Maps serialized to objects). Exit 2 on parse error.
105
+ Pipe to 'am serialize' to round-trip.`,serialize:`am serialize (reads ValidDiagram JSON on stdin)
106
+ Emits canonical Mermaid source. Accepts the JSON shape that 'am parse' emits;
107
+ rebuilds the diagram via synthesizeFromGraph without re-parsing source.`,mutate:`am mutate <file|-> (--op '<JSON>' | --ops '<JSON array|file.json>') [--preserve-source] [--json]
108
+ Applies one or more MutationOps, verifies the final diagram, then emits source.
109
+ Registered families with mutationOps have typed mutation; discover the live roster,
110
+ narrowers, and op names with 'am capabilities --json'. Opaque-fallback diagrams
111
+ (unmodeled syntax) return a structured UNSUPPORTED_FAMILY error (exit 2). Verify failures
112
+ exit 3 (4 when every error is INTERNAL_ERROR) and omit source. An INTERNAL_ERROR the
113
+ source already had does not block the edit.
114
+ ${N}`,preview:`am preview <file|-> [--output preview.html] [--open] [--json] [--security strict]
115
+ Writes a standalone HTML preview containing strict-mode rendered SVG. Without
116
+ --output, emits HTML to stdout unless --open is set, in which case a temp HTML
117
+ file is written and opened. With --json, emits {ok,path,opened,bytes} for file output.`,format:`am format <file|-> [--canonical-wrapper]
118
+ Parse then re-serialize. Idempotent. The leading source wrapper (frontmatter,
119
+ %%{init}%% directives, comments before the header) is preserved byte-verbatim
120
+ by default; --canonical-wrapper instead synthesizes Mermaid's documented shape
121
+ (title/displayMode top-level, everything else under config:, directives folded).`,describe:`am describe <file|-> [--format text|json|facts] [--json]
122
+ Summarize a Mermaid diagram. Text format emits prose by default; --json wraps
123
+ it as {ok,text}. --format json emits the structured AX tree
124
+ {kind,nodes,edges,entryPoints,sinks}; with --json it wraps as {ok,tree}.
125
+ --format facts emits deterministic semantic fact lines; with --json it wraps as {ok,facts}.`,capabilities:`am capabilities [--json]
126
+ Emits a single JSON object describing the SDK's capability surface:
127
+ { sdkVersion, families: [{ id, hasMutate, hasExtractLabels, mutationOps, editPolicy, example }],
128
+ warningCodes: [{ code, tier, severity, origins }],
129
+ outputFormats: ${JSON.stringify(y)} }
130
+ editPolicy is "structured-when-narrowed" or "source-level-only". Use this to
131
+ introspect what the CLI can do without running every command.`,batch:`am batch [--jsonl] (reads JSONL from stdin; --jsonl names that mode)
132
+ Each line: { op: "render"|"verify"|"parse"|"serialize"|"mutate", source: string,
133
+ options?: {}, mutation?: MutationOp, mutations?: MutationOp[] }. Emits one JSON
134
+ envelope per nonblank line, in order, without waiting for EOF:
135
+ { ok, op, data?, error? }. Malformed JSON or unknown ops surface as ok:false;
136
+ the batch continues and exits 0 even if lines errored. Input/output failures
137
+ exit nonzero. Slow output consumers apply backpressure.`,"render-markdown":`am render-markdown <file.md> [--ascii]
138
+ Render fenced \`\`\`mermaid blocks. Bad diagrams yield ok:false entries and do
139
+ not abort the rest of the Markdown file.`,"llms-txt":`am llms-txt
140
+ Emit the committed agent-discovery digest generated from current capabilities.`,"init-agent":`am init-agent [--dir <path>] [--force] [--json]
141
+ Write a repo-local, agent-agnostic drop-in so coding agents discover the
142
+ parse \u2192 narrow \u2192 mutate \u2192 verify \u2192 serialize contract automatically. Creates
143
+ without clobbering by default:
144
+ - AGENTS.md marked section pointing agents at the workflow + hosted docs
145
+ - skills/agentic-mermaid-diagram-workflow/SKILL.md generic skill bundle
146
+ - .mcp.json sample agentic-mermaid MCP server config
147
+ --dir defaults to the current directory. --force overwrites skill/MCP files;
148
+ the AGENTS.md section is always appended only once, guarded by a marker.`};var h=0;var b=2;var G=3;var B=4;var R="# Agentic Mermaid \u2014 operating guide\n\nUse this guide to create, edit, verify and render Mermaid diagrams. It is also\nemitted by `am --agent-instructions` and served at\n`https://agentic-mermaid.dev/agent-instructions.md`. `am init-agent` installs a\ncopy with the consumer's skill, so the operating rules remain available offline.\n\n## Choose one channel\n\nDo not assume this repository is checked out. Use the first available channel\nthat fits the task, then stop discovering tools:\n\n| Available environment | Channel | Version-matched reference |\n|---|---|---|\n| JS/TS with the package installed | `agentic-mermaid/agent/core` for portable editing; `/agent` also supplies native PNG | Installed declarations and `am capabilities --json` |\n| Shell | `am \u2026` or `npx agentic-mermaid \u2026` | `am <command> --help` |\n| Connected local MCP | `agentic-mermaid-mcp` | `describe_sdk` and the connected tool list |\n| Network only, with permission to send the source | Hosted MCP at `https://agentic-mermaid.dev/mcp` | Connected tool list and `describe_sdk` |\n\nPrivate source should stay in a local library, CLI or self-hosted MCP. The\nhosted endpoint sends source to another service; package installation also\nmakes network requests. Do not ask the user to perform work that your available\nchannel can complete.\n\nCLI is convenient for one-shot work. In MCP, use the direct `verify`,\n`describe`, render, `mutate` or `build` tool when the connected server advertises\nit. Use `execute` for custom synchronous logic. The hosted and local tool lists\ndiffer: inspect the connected server instead of borrowing another channel's\nnames. Hosted tools are <!-- BEGIN GENERATED: hosted-mcp-tools -->`execute`, `describe_sdk`, `render_svg`, `render_ascii`, `render_png`, `verify`, `describe`, `mutate`, and `build`<!-- END GENERATED: hosted-mcp-tools -->.\n\nHosted MCP is stateless Streamable HTTP JSON-RPC, with no initialize handshake\nrequired. It has no REST render API. A raw verify request is\n`{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",\"params\":{\"name\":\"verify\",\"arguments\":{\"source\":\"flowchart TD\\n API --> DB\"}}}`.\nUse the published [MCP reference](https://agentic-mermaid.dev/docs/mcp/) for\ntransport and input limits; do not send private material merely to test access.\n\n## Discover the family's actual schema\n\nRun `am capabilities --json` for installed families, headers, examples, edit\npolicies, warning codes and operation fields. In MCP, use\n`describe_sdk({ family, detail: 'fields' })`; `detail: 'signatures'` is a compact\nmenu. These describe the installed or connected version. Online\n`https://agentic-mermaid.dev/capabilities.json` describes production and may be\nnewer than a local installation.\n\nChoose the family from the reader's task. Use its own header, narrower and\noperation vocabulary: state diagrams narrow with `asState`, not `asFlowchart`.\nMutation ops use a `kind` discriminator and family-specific fields; do not\ninvent synonyms or convenience flags. Pass one op to `mutate(d, op)`, not an\narray. Library `applyOps({ source, ops })` and MCP `mutate({ source, ops })`\nprovide atomic batches; Code Mode repeats `mermaid.mutate(d, op)` instead.\nFor painted geometry, discover `describe_sdk({ capability: 'resolved-scene' })`\nand use `renderResolvedScene`; its result limit and typed artwork failures are\npart of that capability's declaration.\n\n## Author or edit, then verify\n\n<!-- BEGIN GENERATED: agent-workflow -->New diagrams: author Mermaid source directly, then parse \u2192 verify \u2192 render or return it. `buildMermaid(kind, ops)` / `createMermaid(kind)` build a diagram from typed ops when you are generating one programmatically (for example, from data). Existing structured diagrams: parse \u2192 narrow \u2192 mutate \u2192 verify \u2192 serialize.<!-- END GENERATED: agent-workflow -->\n\n<!-- BEGIN GENERATED: family-narrowing -->Narrowing selects a structured, typed family with an as* helper. It does not select one element or freeze layout coordinates.<!-- END GENERATED: family-narrowing -->\n\nFor an existing structured diagram, retain its parsed value and apply the\nsmallest typed edit. Code Mode exposes synchronous `mermaid.*` methods and\nread-only returned diagrams; use mutation operations rather than assigning into\nthe body. It does not support imports, async functions, Promise jobs or local\nfile I/O. Library calls use the same names without the `mermaid.` prefix.\n\nThis existing-diagram example runs in Code Mode:\n\n```ts\nconst parsed = mermaid.parseRegisteredMermaid('flowchart TD\\n API --> DB')\nif (!parsed.ok) return { phase: 'parse', errors: parsed.error }\nconst flow = mermaid.asFlowchart(parsed.value)\nif (!flow) return { phase: 'narrow', family: parsed.value.kind }\nconst edited = mermaid.mutate(flow, { kind: 'add_node', id: 'Cache', label: 'Cache' })\nif (!edited.ok) return { phase: 'mutate', error: edited.error }\nconst verify = mermaid.verifyMermaid(edited.value)\nif (!verify.ok) return { phase: 'verify', warnings: verify.warnings }\nreturn { source: mermaid.serializeMermaid(edited.value) }\n```\n\nA new diagram needs no mutation step:\n\n```ts\nconst source = 'flowchart LR\\n API --> DB'\nconst parsed = mermaid.parseRegisteredMermaid(source)\nif (!parsed.ok) return { phase: 'parse', errors: parsed.error }\nconst verify = mermaid.verifyMermaid(parsed.value)\nif (!verify.ok) return { phase: 'verify', warnings: verify.warnings }\nreturn { source }\n```\n\nRun `verifyMermaid` at every commit point: before source is saved, sent or\nshown, and after the last edit before serialization. Inspect `ok`, `warnings`\nand layout evidence. For MCP `mutate` or `build`, require top-level `ok`, the\nintended `family` and `verify.ok`; inspect `verify.warnings`. If an op fails,\nkeep the previous artifact, inspect `opIndex` and the error, then rediscover\nits exact fields before retrying. In a hosted edit request, `source` is the\noriginal pre-edit input, byte-for-byte; express changes only in `ops`.\n\n<!-- BEGIN GENERATED: verify-result -->`verify.ok` means no unsuppressed error was detected, including measured content occlusion and explicit error policies. It is not a visual-quality or semantic-correctness score.<!-- END GENERATED: verify-result -->\n\n<!-- BEGIN SEMANTIC READBACK -->\nBefore returning, compare the result with the task. Preserve requested labels,\nvalues, prefixes, endpoints and relationships exactly; verification alone will\nnot catch an omitted transition label or visibility marker. Use\n`describeMermaidFacts(d)` / `checkMermaid(d, requiredFacts)` or MCP `describe`\nwith `format: 'facts'` for semantic read-back. For a new diagram, also check the\nintended family and whether its advertised narrower returns a structured body.\nIf it unexpectedly falls back to opaque, inspect the warning and the family's\ncapability example instead of calling a merely renderable result editable.\n<!-- END SEMANTIC READBACK -->\n\nDo not suppress error-severity findings or truncate authored content to make\nverification pass. For intentionally long labels, set `labelCharCap` or\n`am verify --label-cap N` to the intended policy. For `INTERNAL_ERROR`, report\nthe original source and diagnostic; do not rewrite the diagram to hide a\nrenderer defect. The [warning reference](https://agentic-mermaid.dev/warnings/)\nand [architecture reference](https://github.com/adewale/agentic-mermaid/blob/main/AGENT_NATIVE.md)\nexplain the generated warning catalog and its limits.\n\n## Source-preserved and opaque input\n\nUnmodeled syntax can remain as opaque source or verbatim segments. A null\nnarrower refuses structured mutation; it does not mean the source is empty.\nIf a task explicitly needs a source-level edit, make the smallest edit, say\n`source-level fallback`, then reparse and verify. Preserve comments and bytes\noutside the requested edit. Do not silently regenerate the diagram.\n\nFor bounded opaque Class/Flowchart edits, use\n`mutatePreservingSource(diagram, op)`: Class `add_member`/`remove_member`, or\nFlowchart `set_label`/`rename_node`. Save `value.source` exactly after inspecting\n`verifyMermaid(value.diagram)`. The body remains opaque and its portability\nwarning remains. Ambiguous ownership and unsupported dependencies refuse\natomically. Library `applyOps` and MCP `mutate` select these batches with\n`mode: 'source-preserving'`; CLI uses `--preserve-source`. Read the\n[mutation policy](https://agentic-mermaid.dev/docs/agent-mutation-policy/) for\noperation limits before choosing this path.\n\n## Render and inspect\n\nUse the requested SVG, PNG, ASCII, Unicode or layout output. Choose `style`\nfrom `am styles --json`, an inline data-only spec or a stack; validate untrusted\nspecs with `validateStyleSpec`. `seed` varies styled ink without moving layout.\nUse strict security when output must contain no external-fetch references;\nrender and verify with the same options. PNG sizing and font availability can\nchange readability: inspect the artifact rather than treating a successful\nrender or a `BELOW_READABLE_SIZE` warning as a general quality verdict.\nGantt has no implicit clock read: pass `ganttToday` to draw today's marker.\n\nFlowchart labels containing punctuation should be quoted. In a quoted label,\n`\\n` is a line break and canonical serialization uses `<br>`. A group is\n`subgraph id[\"Title\"] \u2026 end`; labeled and dotted edges use\n`A -- \"label\" --> B`, `A -.-> B` and `A -. \"label\" .-> B`. Use another family's\ncapability example for its syntax. The [API reference](https://agentic-mermaid.dev/docs/api/)\nseparates source objects, Scene parts and resolved painted primitives.\n\n## Ground the task and return the result\n\nRead supplied repositories, files and URLs when available. Every node and edge\nmust follow the supplied context or inspected source. Include each requested\nentity and relationship; do not merge them to simplify the task. Mark uncertain\nconnections or omit them with an explanation. When context leaves the scope or\nabstraction level open, choose the smallest consistent interpretation, keep\none abstraction level and state the assumptions. If the intended audience,\nmedium or improvement is unclear, inspect read-only information and ask for\nthe missing goal before changing the diagram.\n\nIn chat, return `Updated Mermaid` with the final source in a Mermaid fenced\ncode block, `Verification` with\nwhat was actually checked and any limitations, and `Trace` naming the channel\nand calls used. Include `Sources` for inspected files. Return additional\nartifacts when requested. In Code Mode, return `{ source }` after verification\nor an error object. If asked for one final fenced JSON tool request, finish\nall prose before its only fenced block and stop after the block.\n\nIf no Agentic Mermaid channel is available, return the best source and say\n`not verified \u2014 Agentic Mermaid unavailable`, naming what you tried. Label\nsecondary parser checks as secondary; never invent an Agentic Mermaid result.\nDo not modify project files unless the user asked for file changes.\n\nFor task recipes, read the [editing cookbook](https://agentic-mermaid.dev/docs/agent-api-cookbook/).\nUse local package declarations and discovery over newer online examples when\nworking with an older installed version.\n";function V(i){const e=A(i);const n=m(e,"json");const r=a=>{if(n)process.stdout.write(JSON.stringify({ok:false,error:{code:"ARG",message:a}})+"\n");process.stderr.write(`${a}
149
+ `);return b};if(e.errors.length>0)return{exitCode:r(e.errors.join(" "))};if(m(e,"agent-instructions")){process.stdout.write(R);return{exitCode:h}}if(m(e,"help")&&!e.command){process.stdout.write(f);return{exitCode:h}}if(!e.command){process.stdout.write(f);return{exitCode:b}}if(m(e,"help")){process.stdout.write((x[e.command]??f)+"\n");return{exitCode:h}}const t=Object.keys(e.flags).filter(a=>!(a in c));if(t.length>0){const a=`Unknown flag${t.length>1?"s":""}: ${t.map(p=>`--${p}`).join(", ")}. Run \`am --help\` or \`am ${e.command} --help\` for the flag list.`;return{exitCode:r(a)}}const s=Object.entries(e.flags).filter(([a,p])=>c[a]?.arg&&(typeof p!=="string"||p.length===0)).map(([a])=>a);if(s.length>0){return{exitCode:r(`Flag${s.length>1?"s":""} ${s.map(a=>`--${a}`).join(", ")} require${s.length===1?"s":""} a value.`)}}const o=new Set(E[e.command]??["help"]);const l=Object.keys(e.flags).filter(a=>!o.has(a));if(l.length>0){return{exitCode:r(`Flag${l.length>1?"s":""} ${l.map(a=>`--${a}`).join(", ")} ${l.length>1?"are":"is"} not valid for am ${e.command}.`)}}const d=S[e.command];if(d&&(e.positional.length<d.min||e.positional.length>d.max)){return{exitCode:r(`am ${e.command} accepts ${d.max===0?"no positional arguments":`at most ${d.max} positional input${d.max===1?"":"s"}`}; received ${e.positional.length}.`)}}return{args:e,json:n}}export{c as a,u as b,m as c,L as d,C as e,M as f,E as g,S as h,A as i,f as j,x as k,R as l,h as m,b as n,G as o,B as p,V as q};
150
+ //# sourceMappingURL=chunk-7HIKKNPP.js.map