likec4 1.59.4 → 1.61.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 (186) hide show
  1. package/README.md +2 -0
  2. package/__app__/codegen/react.mjs +4 -10
  3. package/__app__/codegen/webcomponent.mjs +6 -131
  4. package/__app__/index.html +15 -15
  5. package/__app__/src/aichat/index.mjs +11 -7
  6. package/__app__/src/chunks/AIChat.mjs +1355 -739
  7. package/__app__/src/chunks/ErrorComponent.mjs +444 -0
  8. package/__app__/src/chunks/Header.mjs +269 -0
  9. package/__app__/src/chunks/ViewReact.mjs +438 -0
  10. package/__app__/src/chunks/find.mjs +38 -0
  11. package/__app__/src/chunks/hooks.mjs +158 -472
  12. package/__app__/src/chunks/libs/@tabler/icons-react.mjs +340 -0
  13. package/__app__/src/chunks/libs/@tanstack-ai.mjs +11841 -1417
  14. package/__app__/src/chunks/libs/@tanstack.mjs +5110 -2404
  15. package/__app__/src/chunks/libs/fast-equals.mjs +507 -214
  16. package/__app__/src/chunks/libs/html-to-image.mjs +613 -0
  17. package/__app__/src/chunks/libs/nanostores.mjs +170 -0
  18. package/__app__/src/chunks/libs/react-resizable-panels.mjs +2792 -0
  19. package/__app__/src/chunks/react.mjs +22 -0
  20. package/__app__/src/chunks/rolldown-runtime.mjs +16 -29
  21. package/__app__/src/chunks/router.mjs +106 -0
  22. package/__app__/src/chunks/scope.mjs +106 -0
  23. package/__app__/src/chunks/searchParams.mjs +29 -0
  24. package/__app__/src/chunks/single-index.mjs +465 -0
  25. package/__app__/src/chunks/styled-system.mjs +1826 -2528
  26. package/__app__/src/chunks/useAsync.mjs +69 -0
  27. package/__app__/src/chunks/useSyncedRef.mjs +16 -0
  28. package/__app__/src/components/ColorSchemeToggle.mjs +124 -0
  29. package/__app__/src/components/CopyToClipboard.mjs +53 -0
  30. package/__app__/src/components/ErrorComponent.mjs +1 -0
  31. package/__app__/src/components/NavigationPanel.mjs +63 -0
  32. package/__app__/src/components/NotFound.mjs +155 -0
  33. package/__app__/src/components/ViewOutlet.mjs +9 -0
  34. package/__app__/src/components/model-diff/CompareModelProvider.mjs +44 -0
  35. package/__app__/src/components/model-diff/ModelDiffPanel.mjs +179 -0
  36. package/__app__/src/components/model-diff/compare-model.mjs +76 -0
  37. package/__app__/src/components/model-diff/state.mjs +45 -0
  38. package/__app__/src/components/search/OverviewSearch.mjs +92 -0
  39. package/__app__/src/components/search/OverviewSearchAdapter.mjs +94 -0
  40. package/__app__/src/components/sidebar/DiagramTree.css.mjs +48 -0
  41. package/__app__/src/components/sidebar/DiagramsTree.mjs +304 -0
  42. package/__app__/src/components/sidebar/Drawer.mjs +178 -0
  43. package/__app__/src/components/sidebar/SidebarBurger.mjs +28 -0
  44. package/__app__/src/components/sidebar/data.mjs +94 -0
  45. package/__app__/src/components/sidebar/state.mjs +16 -0
  46. package/__app__/src/components/view-page/Header.mjs +1 -0
  47. package/__app__/src/components/view-page/SelectProject.mjs +258 -0
  48. package/__app__/src/components/view-page/ShareModal.mjs +111 -0
  49. package/__app__/src/components/view-page/share-modal/AlertLocalhost.mjs +31 -0
  50. package/__app__/src/components/view-page/share-modal/CopyButtonChild.mjs +36 -0
  51. package/__app__/src/components/view-page/share-modal/EmbedPanel.mjs +100 -0
  52. package/__app__/src/components/view-page/share-modal/WebcomponentsPanel.mjs +264 -0
  53. package/__app__/src/components/view-page/state.mjs +17 -0
  54. package/__app__/src/context/LikeC4CustomizationContext.mjs +26 -0
  55. package/__app__/src/context/LikeC4IconRendererContext.mjs +29 -0
  56. package/__app__/src/context/LikeC4ModelContext.mjs +34 -0
  57. package/__app__/src/context/LikeC4ProjectsContext.mjs +40 -0
  58. package/__app__/src/context/ModelDiffsContext.mjs +33 -0
  59. package/__app__/src/context/safeCtx.mjs +14 -0
  60. package/__app__/src/fonts.css +112 -1
  61. package/__app__/src/hooks.mjs +1 -0
  62. package/__app__/src/main.mjs +6 -29151
  63. package/__app__/src/pages/EmbedPage.mjs +93 -0
  64. package/__app__/src/pages/ExportPage.mjs +691 -0
  65. package/__app__/src/pages/ProjectsOverview.mjs +23 -0
  66. package/__app__/src/pages/ViewAsD2.mjs +105 -0
  67. package/__app__/src/pages/ViewAsDot.mjs +65 -0
  68. package/__app__/src/pages/ViewAsMmd.mjs +109 -0
  69. package/__app__/src/pages/ViewAsPuml.mjs +105 -0
  70. package/__app__/src/pages/ViewEditor.mjs +220 -0
  71. package/__app__/src/pages/ViewReact.mjs +1 -0
  72. package/__app__/src/pages/export-layout.mjs +95 -0
  73. package/__app__/src/pages/export-page-params.mjs +9 -0
  74. package/__app__/src/pages/styles.css.mjs +23 -0
  75. package/__app__/src/routeTree.gen.mjs +105 -0
  76. package/__app__/src/router.mjs +1 -0
  77. package/__app__/src/routes/__root.mjs +65 -0
  78. package/__app__/src/routes/index.css.mjs +29 -0
  79. package/__app__/src/routes/index.mjs +32 -0
  80. package/__app__/src/routes/project._projectId/-components.mjs +100 -0
  81. package/__app__/src/routes/project._projectId/embed._viewId.mjs +5 -0
  82. package/__app__/src/routes/project._projectId/export._viewId.mjs +24 -0
  83. package/__app__/src/routes/project._projectId/index.mjs +14 -0
  84. package/__app__/src/routes/project._projectId/route.mjs +93 -0
  85. package/__app__/src/routes/project._projectId/view._viewId.d2.mjs +34 -0
  86. package/__app__/src/routes/project._projectId/view._viewId.dot.mjs +41 -0
  87. package/__app__/src/routes/project._projectId/view._viewId.index.mjs +7 -0
  88. package/__app__/src/routes/project._projectId/view._viewId.mjs +23 -0
  89. package/__app__/src/routes/project._projectId/view._viewId.mmd.mjs +39 -0
  90. package/__app__/src/routes/project._projectId/view._viewId.puml.mjs +34 -0
  91. package/__app__/src/routes/projects.mjs +36 -0
  92. package/__app__/src/routes/single-index.mjs +1 -0
  93. package/__app__/src/routes/webcomponent._.mjs +94 -0
  94. package/__app__/src/style.css +18497 -1
  95. package/config/schema.json +146 -97
  96. package/dist/app/render-view-client.css +1 -1
  97. package/dist/app/render-view-client.js +394 -238
  98. package/dist/chunks/enableServer.mjs +1 -1
  99. package/dist/chunks/filenames.mjs +25 -17
  100. package/dist/chunks/generate-likec4.mjs +5 -0
  101. package/dist/chunks/index.d.mts +255 -194
  102. package/dist/chunks/index2.d.mts +8246 -3610
  103. package/dist/chunks/libs/@chenglou/pretext.mjs +9 -0
  104. package/dist/chunks/libs/@chevrotain/gast.mjs +27 -1
  105. package/dist/chunks/libs/@chevrotain/regexp-to-ast.mjs +81 -9
  106. package/dist/chunks/libs/@logtape/logtape.mjs +5 -4
  107. package/dist/chunks/libs/@lume/kiwi.mjs +1 -1
  108. package/dist/chunks/libs/@ts-graphviz/common.d.mts +2 -4
  109. package/dist/chunks/libs/@ts-graphviz/core.mjs +1 -1
  110. package/dist/chunks/libs/birpc.mjs +1 -1
  111. package/dist/chunks/libs/chevrotain-allstar.mjs +2 -2
  112. package/dist/chunks/libs/chevrotain.mjs +88 -36
  113. package/dist/chunks/libs/clone.mjs +1 -0
  114. package/dist/chunks/libs/eventemitter3.mjs +1 -1
  115. package/dist/chunks/libs/fast-equals.mjs +1 -0
  116. package/dist/chunks/libs/fontkit.mjs +1 -0
  117. package/dist/chunks/libs/json5.mjs +4 -4
  118. package/dist/chunks/libs/langium.d.mts +6707 -6715
  119. package/dist/chunks/libs/langium.mjs +16 -24
  120. package/dist/chunks/libs/merge-error-cause.mjs +1 -1
  121. package/dist/chunks/libs/p-limit.mjs +1 -0
  122. package/dist/chunks/libs/p-queue.mjs +1 -1
  123. package/dist/chunks/libs/package-manager-detector.mjs +1 -1
  124. package/dist/chunks/libs/pako.mjs +1 -1
  125. package/dist/chunks/libs/pathe.mjs +1 -1
  126. package/dist/chunks/libs/pretty-ms.mjs +1 -1
  127. package/dist/chunks/libs/remeda.mjs +1 -1
  128. package/dist/chunks/libs/ufo.mjs +1 -1
  129. package/dist/chunks/libs/unstorage.mjs +1 -1
  130. package/dist/chunks/libs/which.mjs +1 -1
  131. package/dist/chunks/node.mjs +111 -77
  132. package/dist/chunks/rolldown-runtime.mjs +1 -1
  133. package/dist/chunks/sequence-view.mjs +1 -1
  134. package/dist/chunks/vite-plugin.mjs +185 -166
  135. package/dist/cli/index.mjs +254 -1306
  136. package/dist/config/index.d.mts +66 -5
  137. package/dist/config/index.mjs +1 -1
  138. package/dist/generators/likec4.d.mts +6530 -0
  139. package/dist/generators/likec4.mjs +1 -0
  140. package/dist/index.d.mts +2 -4
  141. package/dist/model/index.d.mts +0 -7
  142. package/dist/vite-plugin/index.d.mts +83 -58
  143. package/dist/vite-plugin/index.mjs +1 -1
  144. package/dist/vite-plugin/internal/chunks/rolldown-runtime.mjs +8 -0
  145. package/dist/vite-plugin/internal/index.d.mts +92 -17
  146. package/dist/vite-plugin/internal/index.mjs +225 -126
  147. package/generators/likec4/package.json +4 -0
  148. package/package.json +134 -122
  149. package/react/index.d.mts +7496 -26659
  150. package/react/index.mjs +533 -63936
  151. package/react/rolldown-runtime-CfRud99p.js +1 -0
  152. package/skills/likec4-dsl/SKILL.md +474 -0
  153. package/skills/likec4-dsl/evals/evals-public.json +207 -0
  154. package/skills/likec4-dsl/evals/grading-spec.json +603 -0
  155. package/skills/likec4-dsl/references/bridge-leanix-drawio.md +42 -0
  156. package/skills/likec4-dsl/references/cli.md +168 -0
  157. package/skills/likec4-dsl/references/configuration.md +266 -0
  158. package/skills/likec4-dsl/references/deployment.md +160 -0
  159. package/skills/likec4-dsl/references/diffs.md +52 -0
  160. package/skills/likec4-dsl/references/dynamic-views.md +455 -0
  161. package/skills/likec4-dsl/references/examples.md +370 -0
  162. package/skills/likec4-dsl/references/identifier-validity.md +90 -0
  163. package/skills/likec4-dsl/references/include-predicates-wildcards.md +180 -0
  164. package/skills/likec4-dsl/references/model.md +182 -0
  165. package/skills/likec4-dsl/references/predicates.md +123 -0
  166. package/skills/likec4-dsl/references/relationships-bidirectional.md +176 -0
  167. package/skills/likec4-dsl/references/specification.md +79 -0
  168. package/skills/likec4-dsl/references/style-tokens-colors.md +150 -0
  169. package/skills/likec4-dsl/references/troubleshooting.md +101 -0
  170. package/skills/likec4-dsl/references/views.md +329 -0
  171. package/vite-plugin-modules.d.ts +126 -51
  172. package/__app__/src/chunks/LikeC4Styles.mjs +0 -2306
  173. package/__app__/src/chunks/ProjectsOverview.mjs +0 -537
  174. package/__app__/src/chunks/es.mjs +0 -439
  175. package/__app__/src/chunks/libs/@floating-ui.mjs +0 -2532
  176. package/__app__/src/chunks/libs/@mantine.mjs +0 -13868
  177. package/__app__/src/chunks/libs/@xstate/react.mjs +0 -2015
  178. package/__app__/src/chunks/libs/@xyflow/react.mjs +0 -5367
  179. package/__app__/src/chunks/libs/bezier-js.mjs +0 -1007
  180. package/__app__/src/chunks/libs/d3.mjs +0 -2817
  181. package/__app__/src/chunks/libs/framer.mjs +0 -5926
  182. package/__app__/src/chunks/libs/zod.mjs +0 -3176
  183. package/dist/chunks/libs/@chevrotain/types.d.mts +0 -108
  184. package/dist/chunks/libs/picomatch.mjs +0 -1
  185. package/dist/chunks/libs/zod.d.mts +0 -3840
  186. package/dist/chunks/libs/zod.mjs +0 -65
@@ -0,0 +1 @@
1
+ var e=Object.create,t=Object.defineProperty,__name=(e,n)=>t(e,`name`,{value:n,configurable:!0}),n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,__commonJSMin=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),__copyProps=(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},__toESM=(n,r,o)=>(o=n==null?{}:e(i(n)),__copyProps(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));export{__name as n,__toESM as r,__commonJSMin as t};
@@ -0,0 +1,474 @@
1
+ ---
2
+ name: likec4-dsl
3
+ description: Use when working with `.c4`/`.likec4` files or LikeC4 CLI/config questions where exact DSL/CLI syntax is required, especially for strict command/snippet-first answers, validate/export flags, predicates `*`/`_`/`**`, deployment snippets, dynamic views, or relationship extension matching.
4
+ ---
5
+
6
+ # LikeC4 DSL Skill
7
+
8
+ Architecture-as-code tool. Describe systems in `.c4`/`.likec4` files and LikeC4 generates interactive diagrams.
9
+
10
+ ## Rules
11
+
12
+ 1. **Projects** - it is possible to have multiple likec4 projects in a workspace, project is determined by presence of a config file (`.likec4rc`, `likec4.config.{ts,js,json}`). LikeC4 files belong to the project of the nearest config file in the directory hierarchy.
13
+ 2. **Top-level statements** — only `import`, `specification`, `model`, `deployment`, `views`, `global`, `diff` are allowed. Blocks can repeat, but at least one per file must be present.
14
+ 3. **Multi-file merge** — Top-level blocks across files are merged. For example, `model { ... }` blocks present in multiple files, parsed separately, and then merged into a single model.
15
+ 4. **Strings** — `'single'`, `"double"` — all support multi-line. Escape quotes with backslash: `\'` or `\"`. In a `title`, escape `\/` to include a literal `/` without it being read as a view-folder separator.
16
+ 5. **Markdown** — properties like `summary`/`description`/`notes` can contain Markdown. Use triple quotes `'''` or `"""`. Begin a new line after opening quotes and indent Markdown content for better formatting and syntax highlighting. Markdown can link to elements and views: `[[cloud.api]]`, `[[cloud.api|API]]`, `[[view:index]]` (see "Element links in Markdown" below).
17
+ 6. **Comments** — `// single line` and `/* multi-line */` comments supported anywhere.
18
+ 7. **Identifier** — letters, digits, hyphens, underscores only. No dots (dots are FQN separators). Can't start with a digit. Examples: `customer`, `payment-service`, `frontendApp`, `queue-1`. **Critical:** `payment-api` is valid; `payment.api` is NOT an identifier (dots separate FQN hierarchy). See `references/identifier-validity.md`.
19
+ 8. **FQN** — Fully Qualified Name (FQN) is a dot-separated path to an element, MUST be unique within the project. Examples: `customer`, `saas.backend.payment-service.paymentsApi`, `infra.eu.zone1.node1`.
20
+ 9. **References** — LikeC4 has lexical scoping with hoisting, nested scope may shadow outer, like in JavaScript. That scope does **not** carry across files: even with imports/includes in the same project, cross-file references must use full FQNs. Tiny reminder: `backend.api` does not survive a file boundary; across files write the full path such as `cloud.backend.api`.
21
+
22
+ ## Response Discipline (critical for evals)
23
+
24
+ - If prompt says **"minimal"**, **"paste-ready"**, **"strict"**, **"exact"**, or requires a specific **first line**, output exactly **one final command/snippet/verdict token first** (no alternatives, no fallback variants, no extra preamble).
25
+ - Do **not** add unrequested `title`, labels, alternate snippets, or long explanations unless explicitly asked.
26
+ - Prefer exact requested tokens/phrases in the first line when the prompt requires strict phrasing.
27
+ - For strict command prompts, avoid ambiguous wording like "equivalent command" unless prompt explicitly asks for alternatives.
28
+ - If the task is snippet-first or command-first, a prose-only answer is a failure even if the explanation is knowledgeable.
29
+
30
+ ## CLI Canonical Contracts (anti-substitution guardrails)
31
+
32
+ - Validate family: use `likec4 validate` (never substitute with `check`, `lint`, or `build`).
33
+ - Export family: use `likec4 export` (never substitute with other command families).
34
+ - Validation flags contract for strict evals: `--json --no-layout --file <path> ... <project-dir>`.
35
+ - Multi-file validation contract: repeat `--file` once per edited `.c4` / `.likec4` source file.
36
+ - Export output flags contract: prefer `--outdir` or `-o` (avoid invented aliases).
37
+
38
+ ## Exact Syntax Guardrails (high-signal only)
39
+
40
+ ### Deployment snippets
41
+
42
+ - If the prompt asks for **named deployment instances**, use `IDENTIFIER = instanceOf ELEMENT_ID`.
43
+ - Do **not** substitute anonymous `instanceOf ELEMENT_ID` lines when naming is required.
44
+ - If the prompt asks for a full fixture, keep the minimal executable structure: `specification`, `model`, `deployment`, and `views`.
45
+
46
+ ### Relationship-extension matchers
47
+
48
+ - Relationship identity is matched by **source + target + kind (+ title when needed)**.
49
+ - If typed relationships exist, omitting `KIND` is wrong for strict disambiguation prompts.
50
+ - If multiple relationships share source/target/kind, include the title in the matcher.
51
+ - Do not "simplify" a typed matcher to `extend SOURCE -> TARGET ...` when the prompt is testing exact relationship identity.
52
+
53
+ Triage anchor when typed alternatives coexist:
54
+
55
+ ```likec4
56
+ // Existing relationships
57
+ api -[async]-> queue "publishes"
58
+ api -[sync]-> queue "publishes"
59
+
60
+ // ✅ Correct: exact relationship selected
61
+ extend api -[async]-> queue "publishes" { metadata { retries "3" } }
62
+
63
+ // ⚠️ Ambiguous: kind omitted, async vs sync both match source/target/title family
64
+ extend api -> queue "publishes" { metadata { retries "3" } }
65
+
66
+ // ❌ Wrong: selects the other relationship
67
+ extend api -[sync]-> queue "publishes" { metadata { retries "3" } }
68
+ ```
69
+
70
+ Compact ambiguity rule:
71
+
72
+ - **Ambiguous** — kind omitted while multiple typed relationships share the same source/target/title family and you are only explaining why the matcher is underspecified.
73
+ - **Wrong** — kind omitted when the task asks for the **final** matcher/snippet for a specific async/sync relationship.
74
+
75
+ ## Workflow
76
+
77
+ 1. (Required) Find existing or create new project config (section below). Directory with project config defines the scope for all LikeC4 files in that directory and subdirectories. Ask user if you are uncertain about the scope.
78
+ 2. (Required) Find existing or create new `specification { ... }`, this enables what kinds of elements/deployments/relationships/tags you can use. See Specification section below.
79
+ 3. Architecture elements and relationships are defined in `model { ... }` block. See Model section below.
80
+ 4. Deployment topology is defined in `deployment { ... }` block. See Deployment section below.
81
+ 5. Views (diagrams) are defined in `views { ... }` block. See Views section below.
82
+ 6. After editing LikeC4 files, validate with the CLI
83
+
84
+ ## Generate → Self-check → Finalize
85
+
86
+ For strict command/snippet prompts, keep a compact loop:
87
+
88
+ 1. **Generate** only the requested final command/snippet.
89
+ 2. **Self-check** quickly:
90
+
91
+ - exact command family / required flags / repeated `--file` count
92
+ - snippet-first or first-line contract satisfied
93
+ - predicate semantics (`*`, `_`, `**`) stated precisely
94
+ - scope / FQN correctness
95
+ - deployment naming requirement satisfied
96
+ - relationship matcher specificity (`kind`, `title` when needed)
97
+ - dynamic view exactness: return arrows, chain form, single parallel block when requested, flow-control block placement (`alt` branches, no nested `parallel`, try/catch/finally order)
98
+ - Markdown links: `[[fqn]]` only inside `'''`/`"""`, full FQN that exists in the model, `\\|` as label separator inside tables
99
+
100
+ 3. **Finalize** by fixing in place (no extra alternatives unless explicitly requested).
101
+
102
+ Before final answer, verify the required tokens are literally present when the prompt depends on them (examples: `--no-layout`, `instanceOf`, `variant sequence`, `global predicate`, `-[async]->`, `parallel {`, `alt {`, `when`, `try {`, `<-`).
103
+
104
+ Never claim CLI execution happened unless it actually ran.
105
+
106
+ ## Validation
107
+
108
+ ```bash
109
+ <runtime> likec4 validate --json --no-layout --file <edited-file> <project-dir>
110
+ ```
111
+
112
+ Runtime launchers are equivalent for this command family:
113
+
114
+ ```bash
115
+ npx likec4 validate --json --no-layout --file <edited-file> <project-dir>
116
+ bunx likec4 validate --json --no-layout --file <edited-file> <project-dir>
117
+ pnpm dlx likec4 validate --json --no-layout --file <edited-file> <project-dir>
118
+ ```
119
+
120
+ - `--json` — structured output (stdout), logging goes to stderr
121
+ - `--no-layout` — skip layout drift checks (faster, only syntax+semantic)
122
+ - `--file <path>` — use with `--json` to scope results to the edited files. Without `--json`, text output still prints all diagnostics. Repeat once per edited source file.
123
+ - `--max-warnings <n>` — fail (`valid: false`, exit code 1) when there are more than `n` warnings; `0` fails on any warning. Without it, warnings never fail validation.
124
+ - `<project-dir>` — path to the project directory
125
+ - There is **no** `likec4 check` command; use `likec4 validate`.
126
+
127
+ For evals/gradings/executions, be **runner-tolerant** (`npx`/`bunx`/`pnpm dlx`), and judge correctness by subcommand + flags + project scope.
128
+
129
+ If workspace already has `likec4` as a dependency, check its version from package.json and ensure it is at least 1.53.0. If pinning is needed, use the active runner (`npx`/`bunx`/`pnpm dlx`) with `likec4@1.53.0`.
130
+
131
+ Example output:
132
+
133
+ ```json
134
+ {
135
+ "valid": false,
136
+ "errors": [
137
+ {
138
+ "message": "...",
139
+ "file": "/abs/path.c4",
140
+ "line": 5,
141
+ "range": { "start": { "line": 5, "character": 2 }, "end": { "line": 5, "character": 20 } }
142
+ }
143
+ ],
144
+ "warnings": [], // same shape as errors
145
+ "maxWarnings": null, // value of --max-warnings, null when not given
146
+ "stats": {
147
+ "totalFiles": 100, // Total number of files in the project
148
+ "totalErrors": 500, // Total number of errors in the project
149
+ "totalWarnings": 3, // Total number of warnings in the project
150
+ "filteredFiles": 1, // Number of files that match the --file filter
151
+ "filteredErrors": 1, // Number of errors in the filtered files
152
+ "filteredWarnings": 0 // Number of warnings in the filtered files
153
+ }
154
+ }
155
+ ```
156
+
157
+ Broken specification/model in a large project can cascade into lots of errors across all files. Always use `--file` to focus on the files you edited. If `filteredErrors` is 0 but `totalErrors` is high, your files are clean but something else in the project is broken (not your problem). Selfcheck that `filteredFiles` matches the number of files you passed to `--file`.
158
+
159
+ Field semantics (must be explicit in answers):
160
+
161
+ - `filteredFiles`: count of files actually included by repeated `--file` filters
162
+ - `filteredErrors`: errors in the filtered subset only
163
+ - `totalErrors`: errors across the full project model
164
+ - `filteredWarnings`: warnings in the filtered subset only; `--max-warnings` limits this count
165
+
166
+ Example edge case: if you pass 3 files but one is `likec4.config.json`, `filteredFiles` may be `2` because config JSON is not a `.c4`/`.likec4` source file for DSL validation.
167
+
168
+ ## Export PNG flags (precision)
169
+
170
+ Canonical output directory flags:
171
+
172
+ - `--outdir` (long form)
173
+ - `-o` (short form)
174
+
175
+ Do not invent flags like `--out-dir`. Depending on LikeC4 version, `--output` may appear as compatibility alias; prefer `--outdir`/`-o` for deterministic answers.
176
+
177
+ Full CLI reference → `references/cli.md`
178
+
179
+ ## Canonical Snippets for High-Variance Families
180
+
181
+ Use these as exactness anchors when the prompt is testing syntax, not broad explanation.
182
+
183
+ ### `predicateGroup` reusable predicate
184
+
185
+ ```likec4
186
+ global {
187
+ predicateGroup core-services {
188
+ include cloud.* where kind is service
189
+ exclude * where tag is #deprecated
190
+ }
191
+ }
192
+
193
+ views {
194
+ view service-overview {
195
+ global predicate core-services
196
+ }
197
+ }
198
+ ```
199
+
200
+ ### Deployment fixture with named instances
201
+
202
+ ```likec4
203
+ deployment {
204
+ vm appVm {
205
+ primary = instanceOf cloud.api
206
+ secondary = instanceOf cloud.api
207
+ }
208
+ }
209
+ ```
210
+
211
+ ### Scoped include semantics
212
+
213
+ ```likec4
214
+ views {
215
+ view backend of cloud.backend {
216
+ include *
217
+ include -> cloud.backend
218
+ }
219
+ }
220
+ ```
221
+
222
+ Interpretation anchor: in a scoped view, `include *` means the scoped element plus its **direct children** as the base include set; neighbors can still appear through scoped relationship visibility.
223
+
224
+ ### Metadata predicates
225
+
226
+ ```likec4
227
+ include * where metadata.region is "eu"
228
+ include * where metadata.regions is "eu"
229
+ exclude * where not metadata.owner
230
+ exclude * -> * where metadata.protocol is "http"
231
+ exclude * -> * where target.metadata.zone is "restricted"
232
+ ```
233
+
234
+ Truth card:
235
+
236
+ - Array containment: `metadata.regions is "eu"` matches if the array contains `"eu"`.
237
+ - Scope: unqualified `metadata.*` filters the matched element or relationship itself; `source.metadata.*` / `target.metadata.*` filters endpoints.
238
+ - Deployment views: instance tags are cumulative; instance metadata replaces logical metadata as a whole when present, otherwise logical metadata is the fallback.
239
+
240
+ ### Deployment-view styling guardrail
241
+
242
+ For strict repair prompts about deployment views, the safe answer is **local `style ... {}` inside the deployment view**.
243
+
244
+ | Need | Prefer | Avoid as the answer |
245
+ | -------------------------------------- | ------------------------------------------------------------------------- | ----------------------------------------------------------------- |
246
+ | Style one deployment view | `deployment view prod { include prod.** style prod._ { color primary } }` | `deployment view prod { include prod.** with { color primary } }` |
247
+ | Reuse styling in a deployment-view fix | local `style ... {}` rules in that deployment view | `global style theme` |
248
+
249
+ Mini-reminder: in deployment views, treat `include ... with {}` and `global style ...` as unsupported repair patterns. Use a local `style ... {}` rule inside the deployment view instead.
250
+
251
+ ### Element links in Markdown (`[[fqn]]`)
252
+
253
+ ```likec4
254
+ model {
255
+ cloud = system 'Cloud' {
256
+ ui = container 'Web UI'
257
+ api = container 'API' {
258
+ description '''
259
+ Called by [[cloud.ui]] and [[cloud.ui|the frontend]].
260
+ See [[view:index]] for context.
261
+ Literal brackets: \\[[not a link]]
262
+
263
+ | Caller | Protocol |
264
+ | --------------------- | -------- |
265
+ | [[cloud.ui\\|Web UI]] | HTTPS |
266
+ '''
267
+ }
268
+ }
269
+ }
270
+ ```
271
+
272
+ - `[[cloud.ui]]` — element link, rendered with the element title
273
+ - `[[cloud.ui|UI]]` — element link with custom label `UI`
274
+ - `[[view:index]]` — view link, rendered with the view title
275
+ - `\\[[` — literal `[[`, not a link
276
+ - `[[cloud.ui\\|UI]]` — labelled link inside a Markdown table cell
277
+
278
+ Truth card:
279
+
280
+ - Only in Markdown values (`'''…'''` / `"""…"""`): `description`, `summary`, `notes`, `title`, `technology`, metadata values. Plain `'…'` / `"…"` strings, inline code and fenced code blocks are not scanned.
281
+ - Target is an **absolute FQN** in the **current project**: no short names, no `this`, no imported elements. `view:` is the only namespace; any other `prefix:` is reserved.
282
+ - Escaping follows DSL strings (`\\` → `\` before Markdown sees it): literal `[[` is `\\[[`; inside tables write `\\|`, a bare `|` splits the cell.
283
+ - Missing element/view or unknown `prefix:` → **warning**, not error. `likec4 validate` lists it under `warnings` but stays `valid: true` unless `--max-warnings` is given (`--max-warnings 0` fails on any warning); editors show it as an LSP diagnostic.
284
+ - Exports and MCP replace links with the title (or label); the DSL generator keeps `[[…]]`.
285
+
286
+ Agent guidance: in descriptions prefer `[[fqn]]` over retyping an element's name (title stays in sync, readers can click it); link only FQNs that exist in the model; use `\\|` in tables.
287
+
288
+ ## LikeC4 Project Configuration
289
+
290
+ Config file (`likec4.config.json`, `.likec4rc`, or `likec4.config.{ts,js}`) defines a project. Its location sets the project scope (LikeC4 files belong to the project of the nearest config file in the directory hierarchy).
291
+
292
+ ```json
293
+ {
294
+ "$schema": "https://likec4.dev/schemas/config.json",
295
+ "name": "my-project",
296
+ "title": "Project Title"
297
+ }
298
+ ```
299
+
300
+ Key options: `name` (required, unique ID in the workspace), `title` (display name)
301
+ Full reference → `references/configuration.md`
302
+
303
+ ## Specification
304
+
305
+ Defines all named vocabularies: element kinds, deployment node kinds, relationship kinds, tags, and custom color tokens. Must appear before those kinds are used in `model` or `deployment` blocks.
306
+
307
+ Key reminders: all definitions are global across files; duplicate kind/tag identifiers cause a validation error; specification changes trigger a full project re-parse — keep it in a dedicated `spec.c4` file.
308
+
309
+ Full syntax, options per kind, and worked example → `references/specification.md`
310
+
311
+ ## Model
312
+
313
+ Hierarchical structure of elements and relationships. Elements have a kind (from specification), a unique identifier within their parent, and optional properties and nested elements.
314
+
315
+ Key reminders: `this`/`it` aliases the current element in nested relationships; cross-file references require full FQN; parent-child direct relationships are forbidden; `extend FQN { }` merges tags, metadata, and links into an existing element without redefining it.
316
+
317
+ Full syntax, extend patterns, property table, and worked example → `references/model.md`
318
+
319
+ ## Style
320
+
321
+ Style properties control visual appearance: `color`, `shape`, `border`, `opacity`, `size`, `padding`, `textSize`, `sizing`, `icon`, `iconColor`, `iconSize`, `iconPosition`, `multiple`. `sizing fixed` draws all elements of the same `size` with identical width/height (content shrinks to fit); default `auto` treats `size` as a minimum. Relationship style extends this with `line`, `head`, and `tail` arrow shapes.
322
+
323
+ Full color token table, all shape values, border/opacity/size tokens, icon pack prefixes (`aws:`, `azure:`, `gcp:`, `tech:`, `bootstrap:`), and correct usage patterns → `references/style-tokens-colors.md`
324
+
325
+ To discover available icons, use the CLI: `likec4 list-icons` (text, one per line). Filter by group with `--group <name>`. Icon groups and approximate counts: `aws` (~307), `azure` (~614), `gcp` (~216), `tech` (~2000), `bootstrap` (~2051) (see `references/cli.md` for details).
326
+
327
+ ## Deployment
328
+
329
+ Maps logical model elements to physical infrastructure nodes using `instanceOf`. Uses `deploymentNode` kinds from specification. Inherits all logical model relationships automatically; additional deployment-level relationships can be defined inline.
330
+
331
+ Named vs. anonymous instances, multi-environment fixture, deployment relationships, and deployment filter metadata rules → `references/deployment.md`
332
+
333
+ ## Views
334
+
335
+ Three view types: element views (`view id` or `view id of element`), dynamic views (`dynamic view id`), deployment views (`deployment view id`). View properties: `title`, `description`, `metadata`, `link`.
336
+
337
+ Include/exclude predicates, view-level style rules, groups, `autoLayout`, `extends`, `navigateTo`, and global predicate groups → `references/views.md`
338
+
339
+ ## Quick Decision Trees
340
+
341
+ ### "I need incoming relationship predicates"
342
+
343
+ ```text
344
+ Need inbound relation selection?
345
+ ├─ From any source to target element → `include -> target`
346
+ ├─ From explicit wildcard source → `include * -> target`
347
+ └─ Include both directions around X → `include -> X ->`
348
+ ```
349
+
350
+ `include -> X` and `include * -> X` are related but not interchangeable in all contexts; prefer the exact form requested by user/eval.
351
+
352
+ ### Scoped Predicate Truth Card (`*`, `_`, `**`)
353
+
354
+ | Selector | One-line truth | Typical use |
355
+ | ----------- | --------------------------------------------------------------------------------- | ----------------------------------- |
356
+ | `parent.*` | Direct children of `parent` only | Show immediate structure |
357
+ | `parent._` | Direct children of `parent` that have relationships with accumulated result | Keep only connected direct children |
358
+ | `parent.**` | Recursive descendants of `parent` that have relationships with accumulated result | Explore connected deep descendants |
359
+
360
+ Hard rule: do not describe `*` as recursive; do not describe `_` as wildcard-all; do not drop relationship-condition semantics for `_` / `**`.
361
+
362
+ ### "I need to create a diagram/view or show a flow or sequence"
363
+
364
+ ```text
365
+ What kind of diagram?
366
+ ├─ Interaction flow / sequence → Dynamic View
367
+ ├─ Infrastructure / deployment → Deployment View
368
+ ├─ From architecture model → Element View
369
+ │ ├─ Primary element known → Scoped view: `view name of element { ... }`
370
+ │ └─ Extend existing view → `view name extends other { ... }`
371
+ └─ Other → `view name { ... }`
372
+ ```
373
+
374
+ ### "I need to style ..."
375
+
376
+ ```text
377
+ Styling?
378
+ ├─ Style element(s) in a view → view `style` rule, see `references/views.md`
379
+ ├─ Style element(s) in some views, but not all
380
+ │ ├─ views in same file → local view rule, see `references/views.md`
381
+ │ └─ views in different files → global view rule, see `references/views.md`
382
+ ├─ Style element globally → property inside element definition, see Model section
383
+ ├─ Style all elements of a kind → property inside kind specification, see Specification section
384
+ ├─ Style by tag → view rule, see `references/views.md`
385
+ ├─ Style relationship(s) in a view → view rule, see `references/views.md`
386
+ ├─ Style relationship globally → property inside relationship definition, see Model section
387
+ ├─ Style all relationships of a kind → property inside kind specification, see Specification section
388
+ ├─ Reuse same styles across views → see `references/views.md`
389
+ ```
390
+
391
+ ### "I need to organize across files"
392
+
393
+ ```text
394
+ Multi-file project?
395
+ ├─ Import from another project → import { backend } from 'shared-project' (project name, not a file path)
396
+ ├─ Cross-file lookup → short names do not inherit lexical/container scope across files; use full FQN
397
+ ├─ Extend element → extend cloud.backend { service newSvc "New" }
398
+ ├─ Extend relationship → extend cloud -> amazon { metadata { ... } }
399
+ ├─ Metadata merge → Duplicate keys become arrays
400
+ ├─ Organize views → views "Use Cases" { ... } (folder label)
401
+ └─ All blocks are mergeable across files
402
+ ```
403
+
404
+ ### "I need to show a flow or sequence"
405
+
406
+ ```text
407
+ Flow / sequence diagram?
408
+ ├─ Basic steps → source -> target "title"
409
+ ├─ Response / backward → source <- target "returns"
410
+ ├─ Parallel actions → one `parallel { ... }` block (also: `par { ... }`)
411
+ ├─ Optional / repeated steps → `opt { ... }` / `loop { ... }` (optional title each)
412
+ ├─ Mutually exclusive branches → `alt { when '...' { } else '...' { } }`
413
+ ├─ Success + error handling → `try { } catch { } finally { }`
414
+ ├─ Chained steps → customer -> frontend "x" -> backend "y"
415
+ ├─ Step with notes → step { notes 'Markdown content' }
416
+ ├─ Link to another view → step { navigateTo other-view }
417
+ ├─ Sequence variant → dynamic view name { variant sequence }
418
+ └─ Full reference → references/dynamic-views.md
419
+ ```
420
+
421
+ Flow-control blocks (experimental) — all take an optional title and nest to any depth, except `parallel`/`par` which cannot nest. `when`/`if`/`else` are valid **only** directly inside `alt`; `loop`/`opt`/`parallel`/`try` cannot be a direct child of `alt` (nest them inside a branch). See `references/dynamic-views.md`.
422
+
423
+ Return-arrow precision:
424
+
425
+ - If the prompt asks for **response arrows back out**, prefer `<-` steps rather than replacing them with new forward arrows.
426
+ - If the prompt asks for a body on a specific hop in a chain, attach the block only to that hop.
427
+ - If the prompt asks for one fan-out, keep sibling actions in one `parallel { ... }` block instead of multiple one-step parallel blocks.
428
+
429
+ ## Anti-Patterns to Avoid in Strict Prompts
430
+
431
+ | Anti-pattern | Why it fails | Correct behavior |
432
+ | ------------------------------------------------------------------ | ----------------------------------------------------------------------------- | --------------------------------------------------------- |
433
+ | Substituting command families (`check`/`build`) for `validate` | Breaks exact command contract | Keep `likec4 validate` |
434
+ | Inventing/guessing flags | Creates non-portable invalid commands | Use canonical documented flags only |
435
+ | Multiple alternative snippets for one strict ask | Reduces precision; fails strict-output grading | Output one final answer unless alternatives are requested |
436
+ | Extending typed relationship without kind/title in ambiguous graph | Can target wrong relationship | Match with source + target + kind (+ title when needed) |
437
+ | Short or guessed FQN in `[[…]]`, e.g. `[[api]]` | Broken link is only a warning; validate passes unless `--max-warnings` is set | Use an existing full FQN: `[[cloud.backend.api]]` |
438
+
439
+ ## Common Mistakes & Debugging
440
+
441
+ When a model errors or an eval answer seems wrong, load `references/troubleshooting.md` which contains:
442
+
443
+ - **Syntax errors** — identifier format (dots forbidden in identifiers), unknown kinds, duplicate FQNs, malformed `where` predicates
444
+ - **Model & Hierarchy** — broken FQN references, parent-child relationship constraint, cross-file visibility
445
+ - **View Predicates** — `*` vs `**` confusion, missing neighbor elements, `WHERE` case sensitivity
446
+ - **Deployment** — `instanceOf` FQN resolution, undefined `deploymentNode` kinds
447
+ - **Dynamic Views** — flow-control blocks (`parallel`/`opt`/`loop`/`alt`/`try`), `alt`-branch placement rules, no nested `parallel`, response arrow symmetry, exact `variant sequence` keyword
448
+ - **Validation & Import** — config not found, import path resolution, upstream error cascade
449
+ - **Performance** — spec in separate file, splitting large views
450
+ - **5-step debugging workflow** — validation-first with `--file`, FQN integrity, predicate isolation, spec-first validation
451
+ - **7 Skill Best Practices** — response discipline, relationship disambiguation, FQN usage, safe editing rules
452
+
453
+ ## Reference Index
454
+
455
+ Load a reference file when the task involves the corresponding topic. Claude reads SKILL.md first; these files are loaded on demand only when needed.
456
+
457
+ | File | Purpose — load when... |
458
+ | -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
459
+ | `references/specification.md` | Writing/editing `specification { }` blocks, defining element/deploymentNode/relationship/tag/color kinds |
460
+ | `references/model.md` | Writing/editing `model { }` blocks, element hierarchy, relationships, `extend` patterns, property names, `[[fqn]]` links |
461
+ | `references/deployment.md` | Writing/editing `deployment { }` blocks, `instanceOf`, named instances, multi-environment topology, deployment metadata filters |
462
+ | `references/style-tokens-colors.md` | Applying colors, shapes, icons, or relationship line styles; need exact token names |
463
+ | `references/views.md` | Writing views, include/exclude rules, style rules in views, groups, autoLayout, global predicates |
464
+ | `references/predicates.md` | Complex `where` conditions, metadata filters, `with` overrides, global predicate groups, reusable predicates |
465
+ | `references/include-predicates-wildcards.md` | Wildcard confusion suspected (`*` vs `_` vs `**`); need exact scoped-view semantics |
466
+ | `references/dynamic-views.md` | Writing dynamic views: steps, return arrows, chained steps, flow-control blocks (`parallel`/`opt`/`loop`/`alt`/`try`), `variant sequence` |
467
+ | `references/identifier-validity.md` | Identifier vs FQN confusion; "dots in names" errors; understanding FQN construction |
468
+ | `references/relationships-bidirectional.md` | Bidirectional relationship syntax and `<->` view predicate patterns |
469
+ | `references/diffs.md` | Planned model changes (`diff` blocks), applying or discarding them, safe delete of elements |
470
+ | `references/bridge-leanix-drawio.md` | LeanIX bridge · `drawio --profile leanix` · round-trip · mapping · MCP vs bridge · sync/artifacts/managed cells |
471
+ | `references/cli.md` | Full CLI reference: serve, build, export, codegen, mcp, format; flag disambiguation |
472
+ | `references/configuration.md` | Project config options, multi-project setup, include/exclude paths, generators |
473
+ | `references/examples.md` | Compact real-world examples: extend, groups, globals, dynamic views, deployment, rank |
474
+ | `references/troubleshooting.md` | Errors, unexpected output, eval failures — 6 error tables, 5-step debug workflow, 7 best practices |