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,150 @@
1
+ # Style Tokens and Colors (LikeC4 DSL)
2
+
3
+ ## Canonical color tokens (semantic names)
4
+
5
+ LikeC4 provides a curated set of semantic color tokens. **Prefer these named tokens over raw hex colors** for consistency and automatic light/dark theme adaptation.
6
+
7
+ ### Core semantic token palette
8
+
9
+ | Token | Usage | Light appearance | Dark appearance |
10
+ | ----------- | ---------------------------------- | ---------------- | --------------- |
11
+ | `primary` | Primary brand color, main emphasis | #2F80ED (blue) | lighter blue |
12
+ | `secondary` | Secondary accent, de-emphasis | #7C3AED (purple) | lighter purple |
13
+ | `muted` | Muted text, disabled states | #9CA3AF (gray) | lighter gray |
14
+ | `slate` | Neutral backgrounds, borders | #475569 | lighter slate |
15
+ | `blue` | Technical/IT systems | #3B82F6 | lighter blue |
16
+ | `indigo` | Data/analytics systems | #6366F1 | lighter indigo |
17
+ | `sky` | Cloud, external services | #0EA5E9 | lighter sky |
18
+ | `red` | Alerts, critical systems | #EF4444 | lighter red |
19
+ | `gray` | Infrastructure, generic | #6B7280 | lighter gray |
20
+ | `green` | Success, operational systems | #10B981 | lighter green |
21
+ | `amber` | Warnings, async/queue patterns | #F59E0B | lighter amber |
22
+
23
+ ## Correct usage: semantic tokens
24
+
25
+ ```likec4
26
+ specification {
27
+ element service {
28
+ style { color primary } // ✓ Correct: semantic token
29
+ }
30
+ element critical {
31
+ style { color red } // ✓ Correct: semantic token
32
+ }
33
+ element queue {
34
+ style { color amber } // ✓ Correct: semantic token
35
+ }
36
+ }
37
+ ```
38
+
39
+ ## When hex colors are acceptable
40
+
41
+ Hex colors can be used if you define a custom named color in the specification:
42
+
43
+ ```likec4
44
+ specification {
45
+ color my-brand-blue #003366 // Define a custom named token
46
+
47
+ element service {
48
+ style { color my-brand-blue } // Reference the custom token
49
+ }
50
+ }
51
+ ```
52
+
53
+ **Do not use raw hex colors directly in styles without first defining them as named tokens in the specification.**
54
+
55
+ ## What NOT to do
56
+
57
+ ```likec4
58
+ style { color #FF5733 } // ✗ Wrong: raw hex color
59
+ style { color rgb(255,87,51) } // ✗ Wrong: rgb() notation
60
+ style { color "primary" } // ✗ Wrong: quoted string (remove quotes)
61
+ ```
62
+
63
+ ## Style tokens vs. theme colors
64
+
65
+ - **Semantic tokens** (`primary`, `secondary`, `muted`, etc.) automatically adapt to light/dark mode.
66
+ - **Custom named colors** defined in specification are explicit hex values; use them sparingly for brand colors.
67
+ - **Raw hex** in a style property is not recommended — always register in specification first.
68
+
69
+ ## Icon packs
70
+
71
+ Icons use the format `group:name` (e.g. `tech:react`, `aws:lambda`, `azure:app-service`). Five built-in groups are available:
72
+
73
+ | Group | Count | Examples |
74
+ | ----------- | ----- | ---------------------------------------------- |
75
+ | `aws` | ~307 | `aws:lambda`, `aws:s3`, `aws:dynamo-db` |
76
+ | `azure` | ~614 | `azure:app-service`, `azure:cosmos-db` |
77
+ | `gcp` | ~216 | `gcp:cloud-run`, `gcp:bigquery` |
78
+ | `tech` | ~2000 | `tech:react`, `tech:postgresql`, `tech:docker` |
79
+ | `bootstrap` | ~2051 | `bootstrap:gear`, `bootstrap:person` |
80
+
81
+ To get the full up-to-date list, run `likec4 list-icons` or `likec4 list-icons --group tech` (see `references/cli.md`)
82
+
83
+ ## Complete style example
84
+
85
+ ```likec4
86
+ specification {
87
+ color brand-orange #FF8C42 // Custom brand color
88
+
89
+ element actor {
90
+ style {
91
+ shape person
92
+ color primary
93
+ icon tech:user
94
+ }
95
+ }
96
+
97
+ element service {
98
+ style {
99
+ shape component
100
+ color primary
101
+ icon tech:gear
102
+ }
103
+ }
104
+
105
+ element critical-service {
106
+ style {
107
+ shape component
108
+ color red // Critical system
109
+ icon tech:alert
110
+ }
111
+ }
112
+
113
+ element queue {
114
+ style {
115
+ shape queue
116
+ color amber // Async/queue pattern
117
+ }
118
+ }
119
+ }
120
+
121
+ model {
122
+ customer = actor {
123
+ style { color primary }
124
+ }
125
+
126
+ api = service {
127
+ style { color primary }
128
+ }
129
+
130
+ alert-responder = critical-service {
131
+ style { color red }
132
+ }
133
+
134
+ job-queue = queue {
135
+ style { color amber }
136
+ }
137
+ }
138
+ ```
139
+
140
+ ## Summary
141
+
142
+ | Use case | Correct | Incorrect |
143
+ | --------------------- | ------------------------------------------------------------------------------------ | --------------------------- |
144
+ | Brand primary color | `style { color primary }` | `style { color "#2F80ED" }` |
145
+ | Critical system alert | `style { color red }` | `style { color "#FF0000" }` |
146
+ | Async/queue pattern | `style { color amber }` | `style { color "#FFC107" }` |
147
+ | Custom brand color | Define in spec + use token: `color my-brand #XXXXXX` then `style { color my-brand }` | Use raw hex in style |
148
+ | Theme-aware styling | Use semantic tokens (`primary`, `secondary`, etc.) | Use fixed hex values |
149
+
150
+ **Best practice:** Use semantic color tokens for all element and relationship coloring. Define custom named colors in specification only for brand compliance, never use raw hex in styles.
@@ -0,0 +1,101 @@
1
+ # Common Mistakes & Debugging (LikeC4 DSL)
2
+
3
+ Load this file when encountering validation errors, unexpected rendering, or when an eval answer is failing.
4
+
5
+ ## Syntax Errors
6
+
7
+ | Error | Cause | Fix |
8
+ | ---------------------------------------- | ----------------------------------------- | ------------------------------------------------------------------ |
9
+ | "Identifier PAYMENT.API not found" | Dots in identifier name | Use `payment-api` not `payment.api`; dots are FQN separators only |
10
+ | "Unknown kind SERVICE" | Kind not in specification | Define `element service { ... }` in the specification block |
11
+ | "Duplicate FQN cloud.backend" | Element ID repeated under the same parent | Rename one element; each sibling must have a unique identifier |
12
+ | "Expected property TYPE after include *" | Malformed filter predicate | Use `include * where kind is component`, not `include * component` |
13
+ | "Invalid relationship kind async-cache" | Kind not found in specification | Define `relationship async-cache { ... }` in specification first |
14
+
15
+ ## Model & Hierarchy
16
+
17
+ | Error | Cause | Fix |
18
+ | ------------------------------------------------ | ------------------------------------------------------------------ | ----------------------------------------------------------------------------- |
19
+ | Element shows but relationships don't render | Relationship references FQN incorrectly | Use exact FQN matching the model hierarchy |
20
+ | "Can't define relationship from parent to child" | Direct parent-child relationships are forbidden | Move the relationship outside the parent element or use implicit notation |
21
+ | Child element not visible from other files | Referencing by short name instead of FQN | Import or use full FQN: `cloud.backend.api` |
22
+ | Extend block adds duplicate tags | Tags stack on merge | Use consistent tag names; duplicates are not deduplicated automatically |
23
+ | Warning `Element 'api' not found` on `[[api]]` | Markdown link target is not an absolute FQN of the current project | Use the full FQN: `[[cloud.backend.api]]`; imported elements cannot be linked |
24
+ | Warning `Unknown link namespace 'deployment'` | Only `view:` is a known prefix in `[[…]]` | Use `[[view:id]]` or an element FQN |
25
+ | `[[cloud.api]]` shows as raw text | Plain `'…'` string, or inside inline/fenced code | Use a Markdown value `'''…'''`; move the link out of code |
26
+
27
+ Labelled link breaks a Markdown table cell: a bare pipe splits GFM table cells, so inside tables write the separator as `\\|`, e.g. `[[cloud.api\\|API]]`.
28
+
29
+ ## View Predicates
30
+
31
+ | Error | Cause | Fix |
32
+ | ------------------------------------------- | ---------------------------------- | --------------------------------------------------------------------------------- |
33
+ | `include *` shows grandchildren | Confusing `*` with `**` | `*` = direct children only; use `**` for recursive descent |
34
+ | Relationships disappear in scoped view | Neighbors not explicitly included | Add `include -> scope` or `include <-> scope` to pull in inbound/outbound sources |
35
+ | "WHERE predicate not matching any elements" | Tag or kind name is case-sensitive | Use exact case: `#Critical` ≠ `#critical` |
36
+ | Element included but styled differently | Global vs. local style conflict | Local view styles override global; audit style rules order in the view block |
37
+
38
+ ## Deployment
39
+
40
+ | Error | Cause | Fix |
41
+ | --------------------------------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------ |
42
+ | `instanceOf` doesn't resolve | Instance refers to wrong FQN | Use the exact logical model FQN, not the deployment node identifier |
43
+ | "Undefined DEPLOYMENT_KIND" | Kind referenced but not in specification | Define `deploymentNode vm { ... }` in specification |
44
+ | Deployment relationship inherits unexpectedly | Logical model edges are inherited automatically | Suppress inherited relationships explicitly in the deployment view if unwanted |
45
+
46
+ ## Dynamic Views
47
+
48
+ | Error | Cause | Fix |
49
+ | ------------------------------------------------- | ----------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
50
+ | `Nested parallel blocks are not allowed` | Nested `parallel { parallel { ... } }` (or `par`) | Flatten: put all concurrent steps in a single `parallel { }` block. Other flow blocks (`opt`/`loop`/`try`/`alt`) may nest freely |
51
+ | `"loop" can not be used as an alternative branch` | Non-branch block (`loop`/`opt`/`parallel`/`try`) placed directly inside `alt` | `alt` accepts only `when`/`if`/`else` branches; nest the block inside a branch |
52
+ | `"when" alternative branch must be inside "alt"` | `when`/`if`/`else` used at top level or inside a non-`alt` block | Wrap the branches in an `alt { ... }` block |
53
+ | `catch`/`finally` rejected | `catch` without a preceding `try`, or `catch` after `finally` | Keep order `try` → `catch?` → `finally?` |
54
+ | Response arrows (`<-`) show wrong direction | Chained `<-` steps are not supported | After `a -> b -> c`, write one `<-` step per hop: `b <- c`, then `a <- b`. `<-` cannot be chained (`a <- b <- c` is a parse error) |
55
+ | `navigateTo` link doesn't work | Target view name does not exist | Ensure the target view name exists in the same project; from a dynamic step it must be another `dynamic view` |
56
+ | `variant sequence` is ignored | Wrong keyword or spelling | Use exact: `variant sequence` (not `type`, `mode`, or `sequence` alone) |
57
+
58
+ ## Validation & Import
59
+
60
+ | Most Common | Solution |
61
+ | --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
62
+ | `validate` reports config not found | Ensure `likec4.config.json` exists in the project root directory |
63
+ | `Imported project not found` | `import` takes another project's `name` (from its `likec4.config`), not a file path: `import { x } from 'other-project'`. Files of the same project need no import; reference elements by full FQN |
64
+ | Symbol from import invisible in model | Symbol must be public (defined at top level); nested elements need FQN |
65
+ | Large error count in project but your file is clean | Use `likec4 validate --json --no-layout --file <edited-file> <project-dir>` and check `filteredErrors`/`filteredFiles`; text mode can also print diagnostics from other workspace files before the filtered summary |
66
+
67
+ ## Performance & Large Models
68
+
69
+ | Symptom | Cause | Action |
70
+ | ------------------------------ | ---------------------------------------------------------- | ------------------------------------------------------------------ |
71
+ | Validation takes >30s | Specification changes trigger full project re-parse | Keep specification in a separate file; avoid editing it frequently |
72
+ | Export generates a partial PNG | Layout engine timeout on complex view | Split large views with `navigateTo` or reduce the element count |
73
+ | IDE responsiveness slow | Too many open files or large specification in working file | Split into `spec.c4` + `model.c4` + `views.c4` |
74
+
75
+ ## Debugging Workflow
76
+
77
+ When encountering errors, follow these steps in order:
78
+
79
+ 1. **Run validation with `--file` and check `filteredErrors`:**
80
+ ```bash
81
+ likec4 validate --json --no-layout --file <your-file> <project-dir>
82
+ ```
83
+ If `filteredErrors` = 0 but `totalErrors` > 0, your file is clean; the error is in an upstream file.
84
+
85
+ 2. **Check FQN integrity:** Find the identifier from the error message and verify it matches the model hierarchy exactly.
86
+
87
+ 3. **Isolate predicate issues:** Copy the failing `include`/`exclude` rule into a new minimal test view to confirm predicate semantics in isolation.
88
+
89
+ 4. **Validate specification first:** Comment out `model`, `deployment`, and `views`; validate the `specification` block alone. If it passes, uncomment the next block and repeat.
90
+
91
+ 5. **Use `extend` strategically:** When enriching elements across files, use `extend FQN { }` rather than re-declaring — re-declarations cause duplicate FQN errors.
92
+
93
+ ## Skill Best Practices
94
+
95
+ 1. **Always start with project structure understanding.** Use the `understand-project-structure` skill before making changes to an unfamiliar project.
96
+ 2. **For relationship ambiguity, always include KIND + TITLE.** When source/target/kind match multiple relationships, include title in the matcher to avoid silently targeting the wrong one.
97
+ 3. **Response discipline on strict prompts.** Output one final answer first (no alternatives) when the prompt says "exact", "minimal", or "paste-ready".
98
+ 4. **Validate after each file edit.** Always run `likec4 validate --json --no-layout --file <edited-file> <project-dir>` after changes; use `--file` to focus on your changes only.
99
+ 5. **Cross-file references use FQN.** Never assume short names resolve across file boundaries; they don't.
100
+ 6. **Keep specification stable.** Changes invalidate the entire model parse; prefer a separate `spec.c4` file and minimize changes to it.
101
+ 7. **Test wildcard semantics locally.** When unsure whether `*` or `**` is correct, create a minimal test view to confirm behavior before committing.
@@ -0,0 +1,329 @@
1
+ # Views
2
+
3
+ Three types of views are supported:
4
+
5
+ 1. Element views - projections of the model, based on predicates
6
+ 2. Dynamic views - step-by-step sequence of interactions between elements
7
+ 3. Deployment views - projections of the deployment model, based on predicates
8
+
9
+ View IDENTIFIER must be unique within the project, available across all files. Duplicate identifiers will result in a validation error.
10
+ There is special view - `index`, if not defined, it will be automatically created to include all top-level elements.
11
+
12
+ Syntax:
13
+
14
+ ```likec4
15
+ views {
16
+
17
+ LOCAL_STYLE_RULES // optional style rules, applied to all views in this block
18
+
19
+ // element view
20
+ view IDENTIFIER {
21
+ TAGS // optional tags, must come first if present, before any properties
22
+ PROPERTIES // optional, but must come before any view rules
23
+ ELEMENT_VIEW_RULES
24
+ }
25
+ // element view can also be scoped to a specific element, explained below
26
+ view IDENTIFIER of ELEMENT_ID {
27
+ TAGS
28
+ PROPERTIES
29
+ ELEMENT_VIEW_RULES
30
+ }
31
+ // dynamic views
32
+ dynamic view IDENTIFIER {
33
+ TAGS
34
+ PROPERTIES
35
+ DYNAMIC_VIEW_RULES
36
+ }
37
+ // deployment views
38
+ deployment view IDENTIFIER {
39
+ TAGS
40
+ PROPERTIES
41
+ DEPLOYMENT_VIEW_RULES
42
+ }
43
+ }
44
+ ```
45
+
46
+ ## Element View Rules
47
+
48
+ Syntax:
49
+
50
+ ```likec4
51
+ include PREDICATE, PREDICATE, ...
52
+ exclude PREDICATE, PREDICATE, ...
53
+ style ELEMENT_EXPRESSION, ... {
54
+ // Apply style properties to elements matching the expressions
55
+ }
56
+ global style STYLE_GROUP_IDENTIFIER
57
+ autoLayout TopBottom|BottomTop|LeftRight|RightLeft [rankSep] [nodeSep] [spline|ortho]
58
+ ```
59
+
60
+ See [Predicates](./predicates.md) for more information on predicates and expressions.
61
+
62
+ **Important:**
63
+
64
+ - Rules order matters, as every next rule applies on top of the previous, accumulating result.
65
+ - `exclude` only removes elements that were included by previous rules.
66
+ - `style` rules override previously applied styles.
67
+ - Style cascade (each override the previous): Spec defaults → element properties → local styles → view-level styles → customized predicates
68
+
69
+ ## Edge routing
70
+
71
+ To draw relationships with right-angle bends, set `routing ortho` in a view:
72
+
73
+ ```likec4
74
+ view {
75
+ routing ortho
76
+ include *
77
+ }
78
+ ```
79
+
80
+ Use `spline` for curved relationships or `ortho` for horizontal and vertical segments. The default is `spline`. Routing applies to element, dynamic, and deployment views. Sequence diagrams ignore this setting.
81
+
82
+ LikeC4 uses the first value defined in this precedence order:
83
+
84
+ 1. The view's `routing` property.
85
+ 2. The last `autoLayout` rule's routing parameter.
86
+ 3. The project default, `styles.defaults.view.routing`.
87
+ 4. The built-in default, `spline`.
88
+
89
+ If both the view property and `autoLayout` set routing, the property takes precedence and the language server reports a warning. Changing routing alone preserves saved node positions and control points without invalidating the layout.
90
+
91
+ Graphviz can route relationships through unrelated group boxes or place parallel routes close together. To reduce crowding, show fewer relationships or edit individual connections. Increasing `autoLayout` spacing gives nodes more room, but doesn't guarantee separation between routes.
92
+
93
+ Edited edges that share a straight segment move onto separate tracks where space at their endpoints permits. Unedited Graphviz routes keep their positions. Automatic label placement avoids nodes, other labels, and routes where space permits; dense views can still contain overlaps.
94
+
95
+ ## Dynamic View Rules
96
+
97
+ Syntax:
98
+
99
+ ```text
100
+ STEP ::=
101
+ SOURCE -> TARGET [LABEL] // forward message
102
+ | SOURCE <- TARGET [LABEL] // backward message
103
+ [{
104
+ RELATIONSHIP_PROPERTIES
105
+ RELATIONSHIP_STYLE_PROPERTIES
106
+ }]
107
+
108
+
109
+ DYNAMIC_VIEW_STYLE_RULE ::=
110
+ style EXPRESSION, ... {
111
+ // Apply style properties to elements matching the expressions
112
+ }
113
+
114
+
115
+ DYNAMIC_VIEW_RULES ::=
116
+ STEP
117
+ STEP
118
+ DYNAMIC_VIEW_STYLE_RULE
119
+ ...
120
+ ```
121
+
122
+ ## Local Style Rules
123
+
124
+ Styles placed inside `views {}` but outside any `view {}` apply to all views in that block:
125
+
126
+ ```likec4
127
+ views {
128
+ // This style applies to ALL views in this block
129
+ style * { color green }
130
+
131
+ view view1 {
132
+ include * // All elements are green
133
+ }
134
+ view index {
135
+ include *
136
+ style backend { color red } // All elements are green, except backend which is red
137
+ }
138
+ }
139
+ ```
140
+
141
+ ## Global Style Groups
142
+
143
+ Reusable style groups defined in `global { ... }`:
144
+
145
+ Syntax:
146
+
147
+ ```likec4
148
+ global {
149
+ styleGroup GROUP_IDENTIFIER {
150
+ style EXPRESSION { ... }
151
+ style EXPRESSION { ... }
152
+ }
153
+ }
154
+
155
+ views {
156
+ view index {
157
+ global style GROUP_IDENTIFIER
158
+ }
159
+ }
160
+ ```
161
+
162
+ ```likec4
163
+ global {
164
+ styleGroup brandColors {
165
+ style * { color primary }
166
+ style element.tag = #deprecated { color muted; opacity 30% }
167
+ style element.tag = #critical { color red; border dashed }
168
+ }
169
+ }
170
+
171
+ views {
172
+ view index {
173
+ include *
174
+ global style brandColors // Apply the style group
175
+ }
176
+ }
177
+ ```
178
+
179
+ Style groups can contain multiple `style` rules. They are applied in the order defined within the group. When used in a view, global styles sit between local styles and view-level styles in the cascade.
180
+
181
+ # Dynamic Views — Detailed Reference
182
+
183
+ ## Steps
184
+
185
+ Each step represents an interaction between two elements:
186
+
187
+ ```likec4
188
+ // Forward step
189
+ customer -> frontend "opens app"
190
+
191
+ // Backward step (response/return flow)
192
+ frontend <- backend "returns data"
193
+
194
+ // Step with full properties
195
+ customer -> frontend "places order" {
196
+ title "Customer places an order" // Override step label
197
+ description "Detailed description"
198
+ technology "HTTPS"
199
+ notes '''
200
+ Additional notes displayed in sidebar.
201
+ Supports **Markdown** formatting.
202
+ '''
203
+ color red
204
+ navigateTo order-detail // Link to another dynamic view
205
+ }
206
+ ```
207
+
208
+ Step properties: `title`, `description`, `technology`, `notes`, `navigateTo`, all relationship properties.
209
+
210
+ ### Chained Steps
211
+
212
+ Steps can be chained to reduce repetition:
213
+
214
+ ```likec4
215
+ customer
216
+ -> frontend "opens" // Read as "customer opens frontend"
217
+ -> backend "requests" // Read as "frontend requests backend"
218
+ -> database "queries" // Read as "backend queries database"
219
+ backend <- database "responds" // Read as "database responds to backend"
220
+ ```
221
+
222
+ Each arrow in the chain creates a separate step. The target of the previous step becomes the source of the next. A chain can continue with `->` or a relationship-kind arrow such as `-[kind]->`. A chain cannot continue with `<-`, so write a response as its own step.
223
+
224
+ ## Parallel Steps
225
+
226
+ Use `parallel` (or `par`) blocks for concurrent interactions:
227
+
228
+ ```likec4
229
+ dynamic view flow {
230
+ frontend -> backend "requests data"
231
+
232
+ parallel {
233
+ backend -> cache "checks cache"
234
+ backend -> database "queries DB"
235
+ backend -> external-api "fetches enrichment"
236
+ }
237
+
238
+ backend -> frontend "returns aggregated data"
239
+ }
240
+ ```
241
+
242
+ Parallel blocks can be mixed with sequential steps, but cannot be nested inside another `parallel`/`par` block (`Nested parallel blocks are not allowed`).
243
+
244
+ ## Variants
245
+
246
+ | Variant | Rendering | Use case |
247
+ | ------------------- | ----------------------------- | ---------------------------------- |
248
+ | `diagram` (default) | Animated box-and-line diagram | General flow visualization |
249
+ | `sequence` | UML sequence diagram | API call sequences, protocol flows |
250
+
251
+ ### Using `variant sequence`
252
+
253
+ The `variant sequence` keyword renders the dynamic view as a UML sequence diagram. This is especially useful for API call sequences and protocol flows.
254
+
255
+ **Key syntax points:**
256
+
257
+ - Use `variant sequence` at the start of the dynamic view block
258
+ - Use `->` for forward/call direction
259
+ - Use `<-` for backward/return direction (not `->` with different semantics)
260
+ - Sequence diagrams work best with leaf elements (not containers)
261
+
262
+ ```likec4
263
+ dynamic view api-sequence {
264
+ variant sequence
265
+
266
+ client -> gateway "POST /orders"
267
+ gateway -> auth "validate token"
268
+ auth <- gateway "200 OK"
269
+ gateway -> orders "create order"
270
+ orders -> db "INSERT"
271
+ orders <- db "order_id"
272
+ gateway <- orders "201 Created"
273
+ client <- gateway "201 Created"
274
+ }
275
+ ```
276
+
277
+ **Common mistake:** Using `->` for returns instead of `<-`. The arrow direction indicates message flow:
278
+
279
+ - `a -> b` means "a sends to b" (request/call)
280
+ - `a <- b` means "b sends to a" (response/return)
281
+
282
+ ```likec4
283
+ // ❌ WRONG - using -> for returns
284
+ dynamic view wrong {
285
+ variant sequence
286
+ client -> gateway "request"
287
+ gateway -> client "response" // This renders incorrectly!
288
+ }
289
+
290
+ // ✅ CORRECT - using <- for returns
291
+ dynamic view correct {
292
+ variant sequence
293
+ client -> gateway "request"
294
+ client <- gateway "response" // Proper return flow
295
+ }
296
+ ```
297
+
298
+ ## Include in Dynamic Views
299
+
300
+ Dynamic views support element-view predicates for context elements that do not participate in steps. Predicates do not generate or filter the step sequence itself.
301
+
302
+ ```likec4
303
+ dynamic view flow {
304
+ customer -> frontend "opens"
305
+ frontend -> backend "requests"
306
+
307
+ // Add parent containers as visual context
308
+ include cloud with {
309
+ color muted
310
+ opacity 10%
311
+ }
312
+ include amazon
313
+ }
314
+ ```
315
+
316
+ ## Styling in Dynamic Views
317
+
318
+ Same styling rules as element views:
319
+
320
+ ```likec4
321
+ dynamic view flow {
322
+ customer -> frontend "opens"
323
+ frontend -> backend "requests"
324
+
325
+ style customer { color green }
326
+ style * { size sm }
327
+ style frontend { color muted }
328
+ }
329
+ ```