likec4 1.57.0 → 1.59.0

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 (178) hide show
  1. package/__app__/codegen/react.mjs +7 -8
  2. package/__app__/codegen/webcomponent.mjs +78 -889
  3. package/__app__/src/aichat/index.mjs +8 -1
  4. package/__app__/src/chunks/AIChat.mjs +956 -0
  5. package/__app__/src/chunks/LikeC4Styles.mjs +2164 -0
  6. package/__app__/src/chunks/ProjectsOverview.mjs +537 -0
  7. package/__app__/src/chunks/es.mjs +439 -0
  8. package/__app__/src/chunks/hooks.mjs +458 -0
  9. package/__app__/src/chunks/libs/@floating-ui.mjs +2218 -0
  10. package/__app__/src/chunks/libs/@mantine.mjs +12974 -0
  11. package/__app__/src/chunks/libs/@tanstack-ai.mjs +1768 -0
  12. package/__app__/src/chunks/libs/@tanstack.mjs +2693 -0
  13. package/__app__/src/chunks/libs/@xstate/react.mjs +1996 -0
  14. package/__app__/src/chunks/libs/@xyflow/react.mjs +5280 -0
  15. package/__app__/src/chunks/libs/bezier-js.mjs +1006 -0
  16. package/__app__/src/chunks/libs/d3.mjs +2842 -0
  17. package/__app__/src/chunks/libs/fast-equals.mjs +268 -0
  18. package/__app__/src/chunks/libs/framer.mjs +5905 -0
  19. package/__app__/src/chunks/libs/zod.mjs +3173 -0
  20. package/__app__/src/chunks/rolldown-runtime.mjs +30 -0
  21. package/__app__/src/chunks/styled-system.mjs +1047 -0
  22. package/__app__/src/fonts.css +1 -1
  23. package/__app__/src/main.mjs +27659 -14
  24. package/__app__/src/style.css +1 -1
  25. package/dist/chunks/dist.mjs +10 -0
  26. package/dist/chunks/enableServer.mjs +1 -1
  27. package/dist/chunks/filenames.mjs +2 -2
  28. package/dist/chunks/index.d.mts +9 -9
  29. package/dist/chunks/index2.d.mts +2167 -867
  30. package/dist/chunks/libs/@chevrotain/gast.mjs +1 -1
  31. package/dist/chunks/libs/@chevrotain/regexp-to-ast.mjs +1 -1
  32. package/dist/chunks/libs/@logtape/logtape.mjs +4 -3
  33. package/dist/chunks/libs/@ts-graphviz/common.d.mts +1 -2
  34. package/dist/chunks/libs/@ts-graphviz/core.mjs +1 -1
  35. package/dist/chunks/libs/chevrotain-allstar.mjs +2 -2
  36. package/dist/chunks/libs/chevrotain.mjs +25 -25
  37. package/dist/chunks/libs/json5.mjs +1 -1
  38. package/dist/chunks/libs/langium.d.mts +2940 -2914
  39. package/dist/chunks/libs/langium.mjs +9 -9
  40. package/dist/chunks/libs/merge-error-cause.mjs +1 -1
  41. package/dist/chunks/libs/p-queue.mjs +1 -1
  42. package/dist/chunks/libs/package-manager-detector.mjs +1 -1
  43. package/dist/chunks/libs/pako.mjs +1 -1
  44. package/dist/chunks/libs/picomatch.mjs +1 -1
  45. package/dist/chunks/libs/pretty-ms.mjs +1 -1
  46. package/dist/chunks/libs/remeda.mjs +1 -1
  47. package/dist/chunks/libs/ufo.mjs +1 -1
  48. package/dist/chunks/libs/unstorage.d.mts +1 -0
  49. package/dist/chunks/libs/unstorage.mjs +1 -1
  50. package/dist/chunks/libs/which.mjs +1 -1
  51. package/dist/chunks/libs/zod.d.mts +48 -36
  52. package/dist/chunks/libs/zod.mjs +65 -0
  53. package/dist/chunks/logger.mjs +1 -0
  54. package/dist/chunks/node.mjs +65 -63
  55. package/dist/chunks/rolldown-runtime.mjs +1 -1
  56. package/dist/chunks/sequence-view.mjs +1 -1
  57. package/dist/chunks/{plugin.mjs → vite-plugin.mjs} +41 -41
  58. package/dist/cli/index.mjs +186 -144
  59. package/dist/index.d.mts +3 -4
  60. package/dist/index.mjs +1 -1
  61. package/dist/model/index.d.mts +6 -5
  62. package/dist/vite-plugin/index.d.mts +6 -9
  63. package/dist/vite-plugin/index.mjs +1 -1
  64. package/dist/vite-plugin/internal/index.d.mts +64 -64
  65. package/dist/vite-plugin/internal/index.mjs +946 -1
  66. package/package.json +51 -52
  67. package/react/index.d.mts +853 -134
  68. package/react/index.mjs +49718 -44030
  69. package/__app__/chunks/AIChat2.mjs +0 -2
  70. package/__app__/chunks/DiagramActorProvider.mjs +0 -10
  71. package/__app__/chunks/EmbedPage.mjs +0 -1
  72. package/__app__/chunks/ExportPage.mjs +0 -2
  73. package/__app__/chunks/LikeC4Diagram.mjs +0 -19
  74. package/__app__/chunks/LikeC4Styles.mjs +0 -48
  75. package/__app__/chunks/Markdown.mjs +0 -1
  76. package/__app__/chunks/NavigationPanel.mjs +0 -1
  77. package/__app__/chunks/ViewReact.mjs +0 -1
  78. package/__app__/chunks/adhoc-editor.mjs +0 -1
  79. package/__app__/chunks/aichat.mjs +0 -1
  80. package/__app__/chunks/box.mjs +0 -1
  81. package/__app__/chunks/create-style-context.mjs +0 -1
  82. package/__app__/chunks/css.mjs +0 -1
  83. package/__app__/chunks/factory.mjs +0 -1
  84. package/__app__/chunks/hooks.mjs +0 -1
  85. package/__app__/chunks/hstack.mjs +0 -1
  86. package/__app__/chunks/libs/@dagrejs/dagre.mjs +0 -1
  87. package/__app__/chunks/libs/@floating-ui/core.mjs +0 -1
  88. package/__app__/chunks/libs/@floating-ui/dom.mjs +0 -1
  89. package/__app__/chunks/libs/@floating-ui/react.mjs +0 -1
  90. package/__app__/chunks/libs/@mantine/core.mjs +0 -41
  91. package/__app__/chunks/libs/@mantine/hooks.mjs +0 -1
  92. package/__app__/chunks/libs/@nanostores/react.mjs +0 -1
  93. package/__app__/chunks/libs/@react-hookz/web.mjs +0 -1
  94. package/__app__/chunks/libs/@tabler/icons-react.mjs +0 -358
  95. package/__app__/chunks/libs/@tanstack/ai-client.mjs +0 -2
  96. package/__app__/chunks/libs/@tanstack/ai-react-ui.mjs +0 -1
  97. package/__app__/chunks/libs/@tanstack/ai-react.mjs +0 -1
  98. package/__app__/chunks/libs/@tanstack/ai.mjs +0 -2
  99. package/__app__/chunks/libs/@tanstack/history.mjs +0 -1
  100. package/__app__/chunks/libs/@tanstack/react-router.mjs +0 -3
  101. package/__app__/chunks/libs/@tanstack/router-core.mjs +0 -1
  102. package/__app__/chunks/libs/@xstate/react.mjs +0 -1
  103. package/__app__/chunks/libs/@xstate/store.mjs +0 -1
  104. package/__app__/chunks/libs/@xyflow/react.mjs +0 -7
  105. package/__app__/chunks/libs/@zag-js/anatomy.mjs +0 -1
  106. package/__app__/chunks/libs/@zag-js/collection.mjs +0 -1
  107. package/__app__/chunks/libs/@zag-js/core.mjs +0 -1
  108. package/__app__/chunks/libs/@zag-js/react.mjs +0 -1
  109. package/__app__/chunks/libs/@zag-js/tree-view.mjs +0 -1
  110. package/__app__/chunks/libs/bezier-js.mjs +0 -1
  111. package/__app__/chunks/libs/copy-anything.mjs +0 -1
  112. package/__app__/chunks/libs/d3-path.mjs +0 -1
  113. package/__app__/chunks/libs/d3-shape.mjs +0 -1
  114. package/__app__/chunks/libs/fast-equals.mjs +0 -1
  115. package/__app__/chunks/libs/framer-motion.mjs +0 -9
  116. package/__app__/chunks/libs/html-to-image.mjs +0 -2
  117. package/__app__/chunks/libs/motion-dom.mjs +0 -1
  118. package/__app__/chunks/libs/nanostores.mjs +0 -1
  119. package/__app__/chunks/libs/react-error-boundary.mjs +0 -1
  120. package/__app__/chunks/libs/react-resizable-panels.mjs +0 -1
  121. package/__app__/chunks/libs/remeda.mjs +0 -1
  122. package/__app__/chunks/libs/superjson.mjs +0 -1
  123. package/__app__/chunks/libs/zod.mjs +0 -64
  124. package/__app__/chunks/rolldown-runtime.mjs +0 -1
  125. package/__app__/chunks/styles.css.mjs +0 -1
  126. package/__app__/chunks/txt.mjs +0 -1
  127. package/__app__/chunks/useLikeC4Project.mjs +0 -1
  128. package/__app__/src/pages/AdHocViewEditor.mjs +0 -1
  129. package/__app__/src/pages/EmbedPage.mjs +0 -1
  130. package/__app__/src/pages/ExportPage.mjs +0 -1
  131. package/__app__/src/pages/ProjectsOverview.mjs +0 -1
  132. package/__app__/src/pages/ViewAsD2.mjs +0 -1
  133. package/__app__/src/pages/ViewAsDot.mjs +0 -1
  134. package/__app__/src/pages/ViewAsMmd.mjs +0 -1
  135. package/__app__/src/pages/ViewAsPuml.mjs +0 -1
  136. package/__app__/src/pages/ViewEditor.mjs +0 -1
  137. package/__app__/src/pages/ViewReact.mjs +0 -1
  138. package/dist/chunks/libs/@chevrotain/utils.mjs +0 -1
  139. package/dist/chunks/libs/@hono/mcp.mjs +0 -70
  140. package/dist/chunks/libs/@hono/node-server.mjs +0 -1
  141. package/dist/chunks/libs/@logtape/logtape.d.mts +0 -1023
  142. package/dist/chunks/libs/@modelcontextprotocol/sdk.mjs +0 -12
  143. package/dist/chunks/libs/ajv.mjs +0 -1
  144. package/dist/chunks/libs/ansi-align.mjs +0 -2
  145. package/dist/chunks/libs/ansi-regex.mjs +0 -1
  146. package/dist/chunks/libs/ansi-styles.mjs +0 -1
  147. package/dist/chunks/libs/atomically.mjs +0 -1
  148. package/dist/chunks/libs/boxen.mjs +0 -22
  149. package/dist/chunks/libs/conf.mjs +0 -1
  150. package/dist/chunks/libs/defu.mjs +0 -1
  151. package/dist/chunks/libs/destr.mjs +0 -1
  152. package/dist/chunks/libs/find-up-simple.mjs +0 -1
  153. package/dist/chunks/libs/get-port.mjs +0 -1
  154. package/dist/chunks/libs/hono.mjs +0 -1
  155. package/dist/chunks/libs/is-docker.mjs +0 -1
  156. package/dist/chunks/libs/is-error-instance.mjs +0 -1
  157. package/dist/chunks/libs/is-inside-container.mjs +0 -1
  158. package/dist/chunks/libs/is-plain-obj.mjs +0 -1
  159. package/dist/chunks/libs/isexe.mjs +0 -1
  160. package/dist/chunks/libs/ky.mjs +0 -3
  161. package/dist/chunks/libs/p-debounce.mjs +0 -1
  162. package/dist/chunks/libs/p-limit.mjs +0 -1
  163. package/dist/chunks/libs/p-timeout.mjs +0 -1
  164. package/dist/chunks/libs/package-up.mjs +0 -1
  165. package/dist/chunks/libs/parse-ms.mjs +0 -1
  166. package/dist/chunks/libs/safe-stringify.mjs +0 -1
  167. package/dist/chunks/libs/strip-indent.mjs +0 -1
  168. package/dist/chunks/libs/tinyrainbow.mjs +0 -1
  169. package/dist/chunks/libs/ts-graphviz.mjs +0 -1
  170. package/dist/chunks/libs/unctx.mjs +0 -1
  171. package/dist/chunks/libs/vscode-languageserver.mjs +0 -1
  172. package/dist/chunks/libs/word-wrap.mjs +0 -12
  173. package/dist/vite-plugin/internal/chunks/libs/@nanostores/react.mjs +0 -1
  174. package/dist/vite-plugin/internal/chunks/libs/birpc.mjs +0 -1
  175. package/dist/vite-plugin/internal/chunks/libs/fast-equals.mjs +0 -1
  176. package/dist/vite-plugin/internal/chunks/libs/nanostores.mjs +0 -1
  177. package/dist/vite-plugin/internal/chunks/libs/remeda.mjs +0 -1
  178. package/dist/vite-plugin/internal/chunks/rolldown-runtime.mjs +0 -1
@@ -0,0 +1,10 @@
1
+ import"./rolldown-runtime.mjs";import{a as e,i as t,n as r,r as o,t as s}from"./libs/@logtape/logtape.mjs";import{n as c,t as u}from"./libs/merge-error-cause.mjs";function serializeValue(e,t,r,o){if(typeof e?.toJSON==`function`&&(e=e.toJSON()),!(typeof e==`object`&&e))return e;if(t.has(e)){if(!r)return`[Circular]`;let o=t.get(e);return`[Circular ${o===``?`*`:`*${o}`}]`}t.set(e,o);let s=Array.isArray(e)?[]:{};for(let[c,u]of Object.entries(e))s[c]=serializeValue(u,t,r,o===``?c:`${o}.${c}`);return t.delete(e),s}function safeStringify(e,{indentation:t,trace:r}={}){let o=serializeValue(e,new WeakMap,r,``);return JSON.stringify(o,void 0,t)}const parseStack=e=>e.split(`
2
+ `).map(e=>e.trim().replace(`file://`,``));function indent(e,t=2){e=Array.isArray(e)?e:e.split(`
3
+ `);let r=` `.repeat(t);return e.map(e=>`${r}${e}`).join(`
4
+ `)}function loggable(e){if(typeof e==`string`)return e;if(e instanceof Error){let t=u(e);if(t.stack){let e=parseStack(t.stack);return t.message+`
5
+ `+indent(e.slice(1))}return t.message}return safeStringify(e,{indentation:` `})}function wrapError(e,t){return c(e,t)}function getErrorFromLogRecord(e){let t=Object.entries(e.properties).flatMap(([e,t])=>{if(t instanceof Error){let e=u(t);return e.stack&&=parseStack(e.stack).join(`
6
+ `),[e]}return e===`error`||e===`err`?[Error(loggable(t))]:[]});return t.length===0?null:t.length===1?t[0]:AggregateError(t)}function errorFromLogRecord(e){let t=getErrorFromLogRecord(e);return t&&typeof e.rawMessage==`string`?c(t,e.rawMessage+`
7
+ `):t}function appendErrorToMessage(e,t=!1){let r=getErrorFromLogRecord(e.record);if(r){let o=r.message;return r.stack&&(o=o+`
8
+ `+indent(r.stack.split(`
9
+ `).slice(1))),t&&(o=`${m.red}${o}${p}`),{...e,message:e.message+`
10
+ `+indent(o)}}return e}const d={trace:`TRACE`,debug:`DEBUG`,info:`INFO `,warning:`WARN `,error:`ERROR`,fatal:`FATAL`};function getMessageOnlyFormatter(){return getTextFormatter({format:({message:e})=>e})}const level=e=>d[e];function getTextFormatter(e){let r=e?.format??(({timestamp:e,level:t,category:r,message:o})=>`${e} ${t} ${r} ${o}`);return t({timestamp:`time`,level,category:`.`,...e,format:e=>r(appendErrorToMessage(e))})}const p=`\x1B[0m`,m={red:`\x1B[31m`};function getAnsiColorFormatter(e){let t=e?.format??(({timestamp:e,level:t,category:r,message:o})=>`${e} ${t} ${r} ${o}`);return o({timestamp:`time`,level,categoryStyle:`bold`,categoryColor:`cyan`,category:`.`,levelColors:{trace:`black`,debug:`blue`,info:`green`,warning:`yellow`,error:`red`,fatal:`magenta`},...e,format:e=>t(appendErrorToMessage(e,!0))})}function getConsoleFormatter(e){let t=e?.messageFormatter;return t?e=>{let{properties:r}=e;return r&&Object.keys(r).length>0?[t(e),r]:[t(e)]}:e=>{let{message:t,properties:r}=e;return r&&Object.keys(r).length>0?[...t,r]:t}}function getConsoleSink(e){return r({formatter:getConsoleFormatter(),...e})}function getConsoleStderrSink(e){let t=e?.formatter??getConsoleFormatter();return e=>{let r=t(e);if(typeof r==`string`){let e=r.replace(/\r?\n$/,``);console.error(e)}else console.error(...r)}}const h=e(`likec4`);function createLogger(e){return h.getChild(e)}function configureLogger(e){try{let{sinks:t={},loggers:r,...o}=e??{},c={console:getConsoleSink(),...t};s({reset:!0,...o,sinks:c,loggers:[{category:[`logtape`,`meta`],sinks:[`console`],lowestLevel:`warning`},...e?.loggers??[{category:`likec4`,sinks:[`console`],lowestLevel:`debug`}]]})}catch(e){console.error(e)}}var g={reset:[0,0],bold:[1,22,`\x1B[22m\x1B[1m`],dim:[2,22,`\x1B[22m\x1B[2m`],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]};function i(e){return String(e)}i.open=``,i.close=``;function B(){let e=typeof process<`u`?process:void 0,t=e?.env||{},r=t.FORCE_TTY!==`false`,o=e?.argv||[];return!(`NO_COLOR`in t||o.includes(`--no-color`))&&(`FORCE_COLOR`in t||o.includes(`--color`)||e?.platform===`win32`||r&&t.TERM!==`dumb`||`CI`in t)||typeof window<`u`&&!!window.chrome}function C({force:e}={}){let t=e||B(),a=(e,t,r,o)=>{let s=``,c=0;do s+=e.substring(c,o)+r,c=o+t.length,o=e.indexOf(t,c);while(~o);return s+e.substring(c)},l=(e,t,r=e)=>{let n=o=>{let s=String(o),c=s.indexOf(t,e.length);return~c?e+a(s,t,r,c)+t:e+s+t};return n.open=e,n.close=t,n},r={isColorSupported:t},f=e=>`\x1B[${e}m`;for(let e in g){let o=g[e];r[e]=t?l(f(o[0]),f(o[1]),o[2]):i}return r}var _=C();export{getConsoleSink as a,getAnsiColorFormatter as c,getTextFormatter as d,loggable as f,h as i,getConsoleFormatter as l,configureLogger as n,getConsoleStderrSink as o,wrapError as p,createLogger as r,errorFromLogRecord as s,_ as t,getMessageOnlyFormatter as u};
@@ -1 +1 @@
1
- import"./rolldown-runtime.mjs";import{$ as e,Q as t,at as n,et as r,it as i,lt as a,nt as o,ot as s}from"./libs/@hono/mcp.mjs";import{u as c}from"./plugin.mjs";import{ElementShapes as l}from"@likec4/core/styles";import{invariant as u}from"@likec4/core";import{Readable as d}from"node:stream";import{chat as f,convertMessagesToModelMessages as p,toServerSentEventsResponse as m,toolDefinition as h}from"@tanstack/ai";const g=s({id:a().meta({description:`Node ID`}),title:a(),shape:t(l),color:a().meta({description:`Node color, from theme or custom`}),icon:a().nullish(),parentId:a().nullish().meta({description:`Parent node ID (if node is nested)`}),children:e(a()).nullish().meta({description:`Nested node IDs (if node is compound)`}),x:n(),y:n(),width:n(),height:n(),modelFqn:a().nullish().meta({description:`Model element FQN (if node has reference)`})}),_=h({name:`read_ui`,description:`Read current UI state. Use arguments to include additional data.`,needsApproval:!1,inputSchema:s({selectedNode:r().default(!1).meta({description:`Include selected node (if any)`}),nodes:r().default(!1).meta({description:`Include all nodes from the view`})}),outputSchema:s({projectId:a(),editMode:r().meta({description:`Whether the UI is in edit mode`}),view:s({id:a(),title:a(),type:t([`element`,`deployment`,`dynamic`]).meta({description:`Type of the current view`})}).meta({description:`Current view`}),nodes:e(g).nullish(),selectedNode:g.nullish()})}),v=h({name:`update_ui`,description:`Update UI state by executing a command.`,needsApproval:!1,inputSchema:s({command:o(`type`,[s({type:i(`focus`),elementId:a().meta({description:`Element ID (FQN)`})}).meta({description:`Focus UI on an element by its FQN`}),s({type:i(`fitview`)}).meta({description:`Zoom out to fit all elements in the viewport, and clear any selection/focus`})])}),outputSchema:s({})}),y=h({name:`navigate_to`,description:`Navigates UI to another view`,needsApproval:!1,inputSchema:s({viewId:a().meta({description:`View ID`})}),outputSchema:s({})});async function readJsonBody(e){let t=[];c.info(`Reading request`);for await(let n of e){let e=Buffer.from(n).toString();process.stdout.write(e),t.push(e)}return JSON.parse(t.join(``))}function enableAIServer(e){let{ai:t,server:n,logger:r}=e;u(t,`AI is not configured`),n.middlewares.use(`/__likec4_ai`,async(e,n,i)=>{if(e.method!==`POST`){i();return}try{let i=await readJsonBody(d.toWeb(e)),a=p(i.messages??[]),o=m(f({...t,messages:a,debug:!0,conversationId:i.data.conversationId,systemPrompts:[`You are a helpful assistant that can answer questions about LikeC4 model and update UI.`],tools:[y,v,_]}));if(o.headers.forEach((e,t)=>{n.setHeader(t,e)}),n.writeHead(o.status,o.statusText),!o.body){n.end();return}d.fromWeb(o.body).on(`error`,e=>{r.error(`AI stream error`,{error:e}),n.writableEnded||n.end()}).pipe(n,{end:!0})}catch(e){r.error(`AI request failed`,{error:e}),n.headersSent?n.end():(n.writeHead(500,{"Content-Type":`application/json`}),n.end(JSON.stringify({error:e instanceof Error?e.message:String(e)})))}})}export{enableAIServer};
1
+ import"./rolldown-runtime.mjs";import{a as e,c as t,d as n,h as r,l as i,v as a,w as o,y as s}from"./libs/zod.mjs";import{n as c}from"./logger.mjs";import{ElementShapes as l}from"@likec4/core/styles";import{invariant as u}from"@likec4/core";import{Readable as d}from"node:stream";import{chat as f,convertMessagesToModelMessages as p,toServerSentEventsResponse as m,toolDefinition as h}from"@tanstack/ai";const g=s({id:o().meta({description:`Node ID`}),title:o(),shape:e(l),color:o().meta({description:`Node color, from theme or custom`}),icon:o().nullish(),parentId:o().nullish().meta({description:`Parent node ID (if node is nested)`}),children:t(o()).nullish().meta({description:`Nested node IDs (if node is compound)`}),x:a(),y:a(),width:a(),height:a(),modelFqn:o().nullish().meta({description:`Model element FQN (if node has reference)`})}),_=h({name:`read_ui`,description:`Read current UI state. Use arguments to include additional data.`,needsApproval:!1,inputSchema:s({selectedNode:i().default(!1).meta({description:`Include selected node (if any)`}),nodes:i().default(!1).meta({description:`Include all nodes from the view`})}),outputSchema:s({projectId:o(),editMode:i().meta({description:`Whether the UI is in edit mode`}),view:s({id:o(),title:o(),type:e([`element`,`deployment`,`dynamic`]).meta({description:`Type of the current view`})}).meta({description:`Current view`}),nodes:t(g).nullish(),selectedNode:g.nullish()})}),v=h({name:`update_ui`,description:`Update UI state by executing a command.`,needsApproval:!1,inputSchema:s({command:n(`type`,[s({type:r(`focus`),elementId:o().meta({description:`Element ID (FQN)`})}).meta({description:`Focus UI on an element by its FQN`}),s({type:r(`fitview`)}).meta({description:`Zoom out to fit all elements in the viewport, and clear any selection/focus`})])}),outputSchema:s({})}),y=h({name:`navigate_to`,description:`Navigates UI to another view`,needsApproval:!1,inputSchema:s({viewId:o().meta({description:`View ID`})}),outputSchema:s({})});async function readJsonBody(e){let t=[];c.info(`Reading request`);for await(let n of e){let e=Buffer.from(n).toString();process.stdout.write(e),t.push(e)}return JSON.parse(t.join(``))}function enableAIServer(e){let{ai:t,server:n,logger:r}=e;u(t,`AI is not configured`),n.middlewares.use(`/__likec4_ai`,async(e,n,i)=>{if(e.method!==`POST`){i();return}try{let i=await readJsonBody(d.toWeb(e)),a=p(i.messages??[]),o=m(f({...t,messages:a,debug:!0,conversationId:i.data.conversationId,systemPrompts:[`You are a helpful assistant that can answer questions about LikeC4 model and update UI.`],tools:[y,v,_]}));if(o.headers.forEach((e,t)=>{n.setHeader(t,e)}),n.writeHead(o.status,o.statusText),!o.body){n.end();return}d.fromWeb(o.body).on(`error`,e=>{r.error(`AI stream error`,{error:e}),n.writableEnded||n.end()}).pipe(n,{end:!0})}catch(e){r.error(`AI request failed`,{error:e}),n.headersSent?n.end():(n.writeHead(500,{"Content-Type":`application/json`}),n.end(JSON.stringify({error:e instanceof Error?e.message:String(e)})))}})}export{enableAIServer};
@@ -1,4 +1,4 @@
1
- import"./rolldown-runtime.mjs";import{t as e}from"./libs/json5.mjs";import{Y as t}from"./libs/@hono/mcp.mjs";import{BorderStyles as n,ElementShapes as r,IconPositions as i,RelationshipArrowTypes as a,Sizes as o,ThemeColors as s,computeColorValues as c}from"@likec4/core/styles";import{exact as l}from"@likec4/core/types";const u=/^@[A-Za-z0-9_-]*$/,d=/^(?!\/|[A-Za-z]:[\\\/])(?!.*:\/\/).*$/,f=t.string().min(1,`Image alias key cannot be empty`).regex(u,`Image alias key must match /^@\\w+$/`),p=t.string().min(1,`Image alias value cannot be empty`).regex(d,`Image alias value must be a relative path (no leading slash or protocol)`),m=t.record(f,p).meta({id:`ImageAliases`,description:`Map of image alias prefixes to relative paths (keys must match /^@\\w+$/; values must be relative paths without protocol or leading slash).`}),h=t.string().min(1,`Include path cannot be empty`).regex(/^(?!\/|[A-Za-z]:[\\\/])(?!.*:\/\/).*$/,`Include path must be a relative path (no leading slash, drive letter, or protocol)`),g=t.strictObject({paths:t.array(h).meta({description:[`Additional relative directory paths to include LikeC4 source files from, searched recursively.`,`Paths are relative to the project folder (the folder containing this config file).`,`Example: ["../shared", "../common/specs"]`].join(`
1
+ import"./rolldown-runtime.mjs";import{t as e}from"./libs/json5.mjs";import{t}from"./libs/zod.mjs";import{BorderStyles as n,ElementShapes as r,IconPositions as i,RelationshipArrowTypes as a,Sizes as o,ThemeColors as s,computeColorValues as c}from"@likec4/core/styles";import{exact as l}from"@likec4/core/types";const u=/^@[A-Za-z0-9_-]*$/,d=/^(?!\/|[A-Za-z]:[\\\/])(?!.*:\/\/).*$/,f=t.string().min(1,`Image alias key cannot be empty`).regex(u,`Image alias key must match /^@\\w+$/`),p=t.string().min(1,`Image alias value cannot be empty`).regex(d,`Image alias value must be a relative path (no leading slash or protocol)`),m=t.record(f,p).meta({id:`ImageAliases`,description:`Map of image alias prefixes to relative paths (keys must match /^@\\w+$/; values must be relative paths without protocol or leading slash).`}),h=t.string().min(1,`Include path cannot be empty`).regex(/^(?!\/|[A-Za-z]:[\\\/])(?!.*:\/\/).*$/,`Include path must be a relative path (no leading slash, drive letter, or protocol)`),g=t.strictObject({paths:t.array(h).meta({description:[`Additional relative directory paths to include LikeC4 source files from, searched recursively.`,`Paths are relative to the project folder (the folder containing this config file).`,`Example: ["../shared", "../common/specs"]`].join(`
2
2
  `)}),maxDepth:t.number().int().min(1).max(20).default(3).meta({description:[`Maximum directory depth to scan when searching for .c4 files in include paths.`,`Prevents excessive scanning of deeply nested directories.`,`Default: 3`].join(`
3
3
  `)}),fileThreshold:t.number().int().min(1).max(1e4).default(30).meta({description:[`Maximum number of files to load from include paths before warning.`,`Helps identify performance issues from accidentally including large directories.`,`Default: 30`].join(`
4
4
  `)})}).meta({id:`include-config`,description:[`Configuration for including additional LikeC4 source files from other directories.`,`Example: { "paths": ["../shared", "../common/specs"], "maxDepth": 5, "fileThreshold": 50 }`].join(`
@@ -10,7 +10,7 @@ These values will be used if such property is not defined`}),L=t.strictObject({c
10
10
  These values will be used if such property is not defined`}),relationship:I.optional().meta({description:`Override default values for relationship style properties
11
11
  These values will be used if such property is not defined`})}).meta({id:`DefaultStyleValues`}),R=t.union([t.string().min(1,`Custom CSS file path cannot be empty`),t.array(t.string().min(1,`Custom CSS file path cannot be empty`))]).meta({id:`CustomStylesheets`}),z=t.strictObject({theme:P.optional().meta({description:`Project theme customization`}),defaults:L.optional().meta({description:`Override default values for style properties
12
12
  These values will be used if such property is not defined`}),customCss:R.optional().meta({description:`Custom CSS (or list of CSS files) to be included in the generated diagrams`})}).transform(({theme:e,defaults:t,customCss:n})=>l({defaults:normalizeDefaults(t),customCss:normalizeStylesheets(n),theme:e}));function normalizeDefaults(e){if(!e)return;let{relationship:t,group:n,...r}=e;return l({...r,relationship:t&&l(t),group:n&&l(n)})}function normalizeStylesheets(e){if(!e)return;let t=(Array.isArray(e)?e:[e]).filter(Boolean);if(t.length!==0)return{paths:t,content:``}}const B=t.strictObject({outDir:t.string().default(`.likec4`).meta({description:[`Path to the directory where manual layouts will be stored,`,`relative to the folder containing the project config. `,``,`Defaults to '.likec4'.`].join(`
13
- `)})}).meta({id:`ManualLayoutsConfig`,description:`Configuration for manual layouts`}),V=t.union([t.strictObject({redirect:t.literal(!0)}),t.strictObject({include:t.array(t.string().nonempty().refine(e=>e!==`#`,{message:`selector cannot be "#"`})).nonempty(`include list cannot be empty`)}),t.strictObject({exclude:t.array(t.string().nonempty().refine(e=>e!==`#`,{message:`selector cannot be "#"`})).nonempty(`exclude list cannot be empty`)})]).meta({id:`LandingPageConfig`,description:`Configure the landing page. Use redirect to go to the index view, or include/exclude to filter the view grid.`}),H=t.object({name:t.string().nonempty(`Project name cannot be empty`).refine(e=>e!==`default`,{abort:!0,error:`Project name cannot be "default"`}).refine(e=>!e.includes(`.`)&&!e.includes(`@`)&&!e.includes(`#`),{abort:!0,error:`Project name cannot contain ".", "@" or "#", try to use A-z, 0-9, _ and -`}).meta({description:`Project name, must be unique in the workspace`}),extends:t.union([t.string().min(1,`Extend path cannot be empty`),t.array(t.string().min(1,`Extend path cannot be empty`)).min(1,`Extend list cannot be empty`)]).optional().meta({description:`Extend styles from other config files`}),title:t.string().nonempty(`Project title cannot be empty if specified`).optional().meta({description:`A human readable title for the project`}),contactPerson:t.string().nonempty(`Contact person cannot be empty if specified`).optional().meta({description:`A person who has been involved in creating or maintaining this project`}),metadata:t.record(t.string(),t.any()).optional().meta({description:`Arbitrary metadata as key-value pairs for custom project information`}),styles:z.optional().meta({description:`Project styles customization`}),imageAliases:m.optional(),include:g.optional(),exclude:t.array(t.string()).optional().meta({description:`List of file patterns to exclude from the project, default is ["**/node_modules/**"]`}),manualLayouts:B.optional(),inferTechnologyFromIcon:t.boolean().optional().meta({description:[`Automatically derive element technology from icon name when technology is not set explicitly.`,`Applies to aws:, azure:, gcp:, and tech: icons. Bootstrap icons are excluded.`,`Defaults to true.`].join(`
13
+ `)})}).meta({id:`ManualLayoutsConfig`,description:`Configuration for manual layouts`}),V=t.union([t.strictObject({redirect:t.literal(!0)}),t.strictObject({include:t.array(t.string().nonempty().refine(e=>e!==`#`,{message:`selector cannot be "#"`})).nonempty(`include list cannot be empty`)}),t.strictObject({exclude:t.array(t.string().nonempty().refine(e=>e!==`#`,{message:`selector cannot be "#"`})).nonempty(`exclude list cannot be empty`)})]).meta({id:`LandingPageConfig`,description:`Configure the landing page. Use redirect to go to the index view, or include/exclude to filter the view grid.`}),H=t.object({name:t.string().nonempty(`Project name cannot be empty`).refine(e=>e!=="default",{abort:!0,error:`Project name cannot be "default"`}).refine(e=>!e.includes(`.`)&&!e.includes(`@`)&&!e.includes(`#`),{abort:!0,error:`Project name cannot contain ".", "@" or "#", try to use A-z, 0-9, _ and -`}).meta({description:`Project name, must be unique in the workspace`}),extends:t.union([t.string().min(1,`Extend path cannot be empty`),t.array(t.string().min(1,`Extend path cannot be empty`)).min(1,`Extend list cannot be empty`)]).optional().meta({description:`Extend styles from other config files`}),title:t.string().nonempty(`Project title cannot be empty if specified`).optional().meta({description:`A human readable title for the project`}),contactPerson:t.string().nonempty(`Contact person cannot be empty if specified`).optional().meta({description:`A person who has been involved in creating or maintaining this project`}),metadata:t.record(t.string(),t.any()).optional().meta({description:`Arbitrary metadata as key-value pairs for custom project information`}),styles:z.optional().meta({description:`Project styles customization`}),imageAliases:m.optional(),include:g.optional(),exclude:t.array(t.string()).optional().meta({description:`List of file patterns to exclude from the project, default is ["**/node_modules/**"]`}),manualLayouts:B.optional(),inferTechnologyFromIcon:t.boolean().optional().meta({description:[`Automatically derive element technology from icon name when technology is not set explicitly.`,`Applies to aws:, azure:, gcp:, and tech: icons. Bootstrap icons are excluded.`,`Defaults to true.`].join(`
14
14
  `)}),implicitViews:t.boolean().optional().meta({description:`Auto-generate scoped views for elements without explicit views. Defaults to false.`}),landingPage:V.optional()}).meta({id:`LikeC4ProjectConfig`,description:`LikeC4 Project Configuration`}),U=t.instanceof(Function),W=t.record(t.string(),U),G=H.extend({generators:W.optional()});function validateProjectConfig(e){let n=e.landingPage,r=null;if(n!=null){let e=V.safeParse(n);if(!e.success)throw Error(`Config validation failed:
15
15
  `+t.prettifyError(e.error));r=e.data}let i=H.safeParse(e);if(!i.success)throw Error(`Config validation failed:
16
16
  `+t.prettifyError(i.error));let a=i.data;r!==null&&(a={...a,landingPage:r});let o=e.generators;if(typeof o==`object`&&o&&!Array.isArray(o)){let e=W.safeParse(o);if(!e.success)throw Error(`Config validation failed (generators):
@@ -2,15 +2,15 @@ import { i as __name } from "./rolldown-runtime.mjs";
2
2
  import { _ as input, a as ZodDefault, b as $strict, c as ZodLiteral, d as ZodOptional, f as ZodPipe, g as ZodUnion, h as ZodTransform, i as ZodCustom, l as ZodNumber, m as ZodString, n as ZodArray, o as ZodEnum, p as ZodRecord, r as ZodBoolean, s as ZodInt, t as ZodAny, u as ZodObject, v as output, x as $strip, y as $partial } from "./libs/zod.mjs";
3
3
  import { LikeC4ProjectStylesConfig, LikeC4ProjectTheme, ProjectId, ThemeColorValues as ThemeColorValues$1, aux } from "@likec4/core/types";
4
4
  import { DeploymentElementModel, DeploymentRelationModel, ElementModel, LikeC4Model, LikeC4ViewModel, RelationshipModel } from "@likec4/core/model";
5
-
6
- //#region ../config/dist/index.d.mts
5
+ //#region ../config/dist/chunks/index.d.mts
7
6
  //#region src/schema.include.d.ts
8
7
  declare const IncludeSchema: ZodObject<{
9
8
  paths: ZodArray<ZodString>;
10
9
  maxDepth: ZodDefault<ZodNumber>;
11
10
  fileThreshold: ZodDefault<ZodNumber>;
12
11
  }, $strict>;
13
- type IncludeConfig = output<typeof IncludeSchema>; //#endregion
12
+ type IncludeConfig = output<typeof IncludeSchema>;
13
+ //#endregion
14
14
  //#region src/schema.d.ts
15
15
  interface VscodeURI {
16
16
  readonly scheme: string;
@@ -293,7 +293,8 @@ declare const LikeC4ProjectConfigOps: {
293
293
  parse: typeof parseProjectConfigJSON;
294
294
  validate: typeof validateProjectConfig;
295
295
  normalizeInclude: (include: input<typeof IncludeSchema> | undefined) => IncludeConfig;
296
- }; //#endregion
296
+ };
297
+ //#endregion
297
298
  //#region src/schema.theme.d.ts
298
299
  declare const ThemeColorValuesSchema: ZodPipe<ZodUnion<[ZodPipe<ZodObject<{
299
300
  elements: ZodUnion<[ZodPipe<ZodObject<{
@@ -469,9 +470,7 @@ declare const LikeC4StylesConfigSchema: ZodPipe<ZodObject<{
469
470
  customCss?: string | string[] | undefined;
470
471
  }>>;
471
472
  interface LikeC4StylesConfig extends output<typeof LikeC4StylesConfigSchema> {}
472
- type LikeC4StylesConfigInput = input<typeof LikeC4StylesConfigSchema>; //#endregion
473
- //#region src/filenames.d.ts
474
- /** All known LikeC4 config filenames (JSON and non-JSON). */
473
+ type LikeC4StylesConfigInput = input<typeof LikeC4StylesConfigSchema>;
475
474
  /** Returns true if the **basename** of the given path matches a known config filename. */
476
475
  declare function isLikeC4JsonConfig(filename: string): boolean;
477
476
  /**
@@ -481,7 +480,8 @@ declare function isLikeC4NonJsonConfig(filename: string): boolean;
481
480
  /**
482
481
  * Returns true if the **basename** of the given path matches a known LikeC4 config file (JSON or non-JSON).
483
482
  */
484
- declare function isLikeC4Config(filename: string): boolean; //#endregion
483
+ declare function isLikeC4Config(filename: string): boolean;
484
+ //#endregion
485
485
  //#region src/define-config.d.ts
486
486
  /**
487
487
  * Defines LikeC4 Project, allows custom generators that can be executed using CLI:
@@ -588,6 +588,6 @@ declare function defineTheme<const S extends LikeC4ConfigThemeInput>(theme: S):
588
588
  * }
589
589
  * })
590
590
  */
591
- declare function defineStyle<const S extends LikeC4StylesConfigInput>(styles: S): LikeC4ProjectStylesConfig; //#endregion
591
+ declare function defineStyle<const S extends LikeC4StylesConfigInput>(styles: S): LikeC4ProjectStylesConfig;
592
592
  //#endregion
593
593
  export { isLikeC4JsonConfig as _, LikeC4ProjectConfig as a, LikeC4ProjectJsonConfig as c, defineConfig as d, defineGenerators as f, isLikeC4Config as g, defineThemeColor as h, IncludeConfig as i, LikeC4StylesConfig as l, defineTheme as m, GeneratorFnContext as n, LikeC4ProjectConfigInput as o, defineStyle as p, GeneratorFnParams as r, LikeC4ProjectConfigOps as s, GeneratorFn as t, LikeC4StylesConfigInput as u, isLikeC4NonJsonConfig as v };