mythik 0.1.5 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/README.md +96 -36
  2. package/dist/actions/dispatcher.d.ts +2 -0
  3. package/dist/actions/dispatcher.d.ts.map +1 -1
  4. package/dist/actions/dispatcher.js +11 -2
  5. package/dist/actions/dispatcher.js.map +1 -1
  6. package/dist/actions/transaction-engine.d.ts +10 -0
  7. package/dist/actions/transaction-engine.d.ts.map +1 -1
  8. package/dist/actions/transaction-engine.js +13 -1
  9. package/dist/actions/transaction-engine.js.map +1 -1
  10. package/dist/agent-context/inventory.d.ts +62 -0
  11. package/dist/agent-context/inventory.d.ts.map +1 -0
  12. package/dist/agent-context/inventory.js +248 -0
  13. package/dist/agent-context/inventory.js.map +1 -0
  14. package/dist/contract/extractor.js +3 -0
  15. package/dist/contract/extractor.js.map +1 -1
  16. package/dist/data/data-sources.d.ts +16 -0
  17. package/dist/data/data-sources.d.ts.map +1 -1
  18. package/dist/data/data-sources.js +16 -1
  19. package/dist/data/data-sources.js.map +1 -1
  20. package/dist/editor-session/engine.d.ts +1 -0
  21. package/dist/editor-session/engine.d.ts.map +1 -1
  22. package/dist/editor-session/engine.js +5 -4
  23. package/dist/editor-session/engine.js.map +1 -1
  24. package/dist/fetch/framework-fetch.d.ts +1 -0
  25. package/dist/fetch/framework-fetch.d.ts.map +1 -1
  26. package/dist/fetch/framework-fetch.js +34 -4
  27. package/dist/fetch/framework-fetch.js.map +1 -1
  28. package/dist/fetch/interceptors/auth.d.ts +2 -0
  29. package/dist/fetch/interceptors/auth.d.ts.map +1 -1
  30. package/dist/fetch/interceptors/auth.js +31 -2
  31. package/dist/fetch/interceptors/auth.js.map +1 -1
  32. package/dist/fetch/types.d.ts +4 -0
  33. package/dist/fetch/types.d.ts.map +1 -1
  34. package/dist/index.d.ts +12 -2
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +5 -0
  37. package/dist/index.js.map +1 -1
  38. package/dist/renderer/engine.d.ts.map +1 -1
  39. package/dist/renderer/engine.js +29 -4
  40. package/dist/renderer/engine.js.map +1 -1
  41. package/dist/renderer/prop-schemas.d.ts +5 -0
  42. package/dist/renderer/prop-schemas.d.ts.map +1 -1
  43. package/dist/renderer/prop-schemas.js +11 -2
  44. package/dist/renderer/prop-schemas.js.map +1 -1
  45. package/dist/reveal/context.d.ts +22 -0
  46. package/dist/reveal/context.d.ts.map +1 -0
  47. package/dist/reveal/context.js +159 -0
  48. package/dist/reveal/context.js.map +1 -0
  49. package/dist/reveal/index.d.ts +7 -0
  50. package/dist/reveal/index.d.ts.map +1 -0
  51. package/dist/reveal/index.js +7 -0
  52. package/dist/reveal/index.js.map +1 -0
  53. package/dist/reveal/protocol.d.ts +28 -0
  54. package/dist/reveal/protocol.d.ts.map +1 -0
  55. package/dist/reveal/protocol.js +2 -0
  56. package/dist/reveal/protocol.js.map +1 -0
  57. package/dist/reveal/recorder.d.ts +20 -0
  58. package/dist/reveal/recorder.d.ts.map +1 -0
  59. package/dist/reveal/recorder.js +31 -0
  60. package/dist/reveal/recorder.js.map +1 -0
  61. package/dist/reveal/redaction.d.ts +12 -0
  62. package/dist/reveal/redaction.d.ts.map +1 -0
  63. package/dist/reveal/redaction.js +85 -0
  64. package/dist/reveal/redaction.js.map +1 -0
  65. package/dist/reveal/truncation.d.ts +4 -0
  66. package/dist/reveal/truncation.d.ts.map +1 -0
  67. package/dist/reveal/truncation.js +48 -0
  68. package/dist/reveal/truncation.js.map +1 -0
  69. package/dist/reveal/types.d.ts +104 -0
  70. package/dist/reveal/types.d.ts.map +1 -0
  71. package/dist/reveal/types.js +2 -0
  72. package/dist/reveal/types.js.map +1 -0
  73. package/dist/runtime/mount-spec-runtime.d.ts +7 -0
  74. package/dist/runtime/mount-spec-runtime.d.ts.map +1 -1
  75. package/dist/runtime/mount-spec-runtime.js +5 -1
  76. package/dist/runtime/mount-spec-runtime.js.map +1 -1
  77. package/dist/security/spec-validator.d.ts.map +1 -1
  78. package/dist/security/spec-validator.js +61 -0
  79. package/dist/security/spec-validator.js.map +1 -1
  80. package/dist/spec-stores/file.js +1 -1
  81. package/dist/spec-stores/file.js.map +1 -1
  82. package/dist/types.d.ts +8 -0
  83. package/dist/types.d.ts.map +1 -1
  84. package/docs/consumer/README.md +11 -0
  85. package/docs/consumer/WHERE-TO-LOOK.md +1 -1
  86. package/docs/consumer/ai-context-patterns.md +42 -7
  87. package/docs/consumer/ai-context-primitives.md +25 -2
  88. package/docs/consumer/ai-context-runtime-semantics.md +32 -19
  89. package/docs/consumer/ai-context.md +106 -20
  90. package/docs/consumer/reference-doc.md +170 -35
  91. package/docs/llms.txt +6 -1
  92. package/docs/wiki/compiled/README.md +13 -11
  93. package/docs/wiki/compiled/_gaps.md +1 -1
  94. package/docs/wiki/compiled/_index.md +11 -7
  95. package/docs/wiki/compiled/_inventory.md +22 -14
  96. package/docs/wiki/compiled/_lint.md +21 -17
  97. package/docs/wiki/compiled/antipattern-store-save-bypass.md +13 -8
  98. package/docs/wiki/compiled/cli-agent.md +70 -0
  99. package/docs/wiki/compiled/cli-existing-spec-edit-loop.md +9 -8
  100. package/docs/wiki/compiled/cli-overview.md +12 -7
  101. package/docs/wiki/compiled/cli-patch.md +14 -11
  102. package/docs/wiki/compiled/cli-programmatic-api.md +17 -7
  103. package/docs/wiki/compiled/cli-push.md +36 -24
  104. package/docs/wiki/compiled/cli-reveal.md +64 -0
  105. package/docs/wiki/compiled/cli-toon.md +9 -9
  106. package/docs/wiki/compiled/cli-versioning-author.md +19 -15
  107. package/docs/wiki/compiled/concept-agent-context-protocol.md +76 -0
  108. package/docs/wiki/compiled/concept-component-variants.md +39 -10
  109. package/docs/wiki/compiled/concept-mythik-reveal.md +63 -0
  110. package/docs/wiki/compiled/concept-package-layout.md +7 -6
  111. package/docs/wiki/compiled/concept-public-package-names.md +9 -5
  112. package/docs/wiki/compiled/concept-shape-animations.md +4 -2
  113. package/docs/wiki/compiled/concept-spec-store-interface.md +7 -4
  114. package/docs/wiki/compiled/concept-spec-store-layering.md +5 -5
  115. package/docs/wiki/compiled/concept-templates-vs-variants.md +77 -13
  116. package/docs/wiki/compiled/concept-versioned-store.md +8 -5
  117. package/docs/wiki/compiled/pattern-git-vs-db-versioning.md +8 -6
  118. package/docs/wiki/compiled/pattern-push-vs-patch.md +13 -12
  119. package/docs/wiki/compiled/pattern-reusable-components.md +42 -12
  120. package/package.json +1 -1
@@ -35,17 +35,28 @@ mythik manifest <screen>
35
35
  mythik elements <screen> <id1,id2,...>
36
36
 
37
37
  # Apply RFC 6902 patches
38
- mythik patch <screen> --from-file patch.json
38
+ mythik patch <screen> --from-file patch.json --author <agent>
39
39
 
40
40
  # Export a full screen spec for backup/review
41
41
  mythik pull <screen>
42
42
 
43
- # Create or intentionally replace a full screen spec from stdin
44
- mythik push <screen>
43
+ # Create a new screen spec or intentionally replace a full screen spec
44
+ mythik push <screen> --from-file spec.json --author <agent>
45
+ mythik push <screen> --from-file spec.json --replace --author <agent>
45
46
 
46
47
  # Validate a screen spec
47
48
  mythik validate <screen>
48
49
 
50
+ # Start and query live runtime context for AI agents
51
+ mythik reveal start
52
+ mythik reveal apps --json
53
+ mythik reveal context --app <name>
54
+ mythik reveal element <element-id> --app <name>
55
+
56
+ # Install and refresh project-local AI operating context
57
+ mythik agent init codex|claude|all
58
+ mythik agent context --app <app-id> --include-screens --out .mythik/agent/context.md
59
+
49
60
  # Delete a screen (preview without --confirm)
50
61
  mythik delete <screen> --confirm
51
62
  ```
@@ -73,13 +84,13 @@ Set the env var once per session: `export MYTHIK_API_KEY="your-key"`. The CLI re
73
84
 
74
85
  **Preferred shell-safe path** - write patch JSON to a file:
75
86
  ```bash
76
- mythik patch task-manager --from-file patch.json
87
+ mythik patch task-manager --from-file patch.json --author <agent>
77
88
  ```
78
89
 
79
90
  `--from-file <path>` wins over ambient non-TTY stdin. Use `--from-file -` or pipe without `--from-file` when stdin is intentional:
80
91
  ```bash
81
- cat patch.json | mythik patch task-manager
82
- mythik patch task-manager --from-file -
92
+ cat patch.json | mythik patch task-manager --author <agent>
93
+ mythik patch task-manager --from-file - --author <agent>
83
94
  ```
84
95
 
85
96
  Inline JSON still works for tiny patches, but `--from-file` is preferred for anything containing `$state`, `$template`, `$auth`, or shell-sensitive quoting.
@@ -92,7 +103,7 @@ Use `--toon` for token-efficient output on `elements` and `patch` commands:
92
103
 
93
104
  ```bash
94
105
  mythik elements task-manager btn,nav --toon
95
- mythik patch task-manager --from-file patch.toon --toon
106
+ mythik patch task-manager --from-file patch.toon --toon --author <agent>
96
107
  ```
97
108
 
98
109
  TOON reduces output by ~40% vs JSON. Lossless roundtrip. Based on `@toon-format/toon` v2.
@@ -101,32 +112,140 @@ TOON reduces output by ~40% vs JSON. Lossless roundtrip. Based on `@toon-format/
101
112
 
102
113
  ```bash
103
114
  # JSON input (as before)
104
- mythik patch task-manager --from-file patch.json
115
+ mythik patch task-manager --from-file patch.json --author <agent>
105
116
 
106
117
  # TOON input (autodetected)
107
- mythik patch task-manager --from-file patch.toon
118
+ mythik patch task-manager --from-file patch.toon --author <agent>
108
119
  ```
109
120
 
110
121
  ### Workflow: Manifest → Elements → Patch
111
122
 
112
123
  1. **`mythik manifest <screen>`** — see the structure, decide what to modify
113
124
  2. **`mythik elements <screen> <ids>`** — inspect specific elements you need to change
114
- 3. **`mythik patch <screen> --from-file patch.json`** - apply surgical changes
115
- 4. **`mythik manifest <screen>`** — verify the result
125
+ 3. **`mythik patch <screen> --from-file patch.json --author <agent>`** - apply a surgical, versioned change
126
+ 4. **`mythik validate <screen>`** — validate the stored result
127
+ 5. **`mythik manifest <screen>`** — verify the changed structure
116
128
 
117
129
  This is the required default loop for AI agents editing an existing spec. Do not begin a small change by pulling the full spec and rewriting it. `manifest` gives the structural map, `elements` gives the exact JSON for the target nodes, and `patch --from-file` keeps the write validated, versionable, and reviewable. Use `pull` for backup/migration/review and `push` for new specs or deliberate full replacement only.
118
130
 
131
+ ### Mythik Sentinel - Agent Protocol Guardrail
132
+
133
+ Mythik Sentinel is built into the CLI so a fresh AI agent is not left
134
+ alone with generic command habits. It is advisory and best-effort: it
135
+ does not change the real command exit code, and it never stores specs,
136
+ patches, URLs, credentials, state values, or Reveal context.
137
+
138
+ Sentinel watches command intent per project. On first CLI use, it asks
139
+ the agent to run `mythik agent init codex|claude|all`. If it sees
140
+ repeated full replacement intent (`push --replace` or
141
+ `push --from-dir --replace`) with little/no `patch` usage, it warns the
142
+ agent back to `manifest -> elements -> patch --from-file --author ->
143
+ validate -> verify`.
144
+
145
+ Machine-readable output stays machine-readable. JSON object outputs may
146
+ receive `protocol.warnings`. TOON output and other machine formats are
147
+ not wrapped with human text. Use `MYTHIK_SENTINEL=off` only for
148
+ exceptional automation that needs to suppress advisory warnings.
149
+
150
+ `push --replace` also has no-diff protection. If the submitted document
151
+ is identical to the stored document, Mythik skips the write instead of
152
+ creating a new version. JSON output reports `skipped: true` and
153
+ `skipReason: "no-diff"`.
154
+
155
+ ### Mythik Reveal — Live Runtime Context for AI Agents
156
+
157
+ `mythik reveal` lets a running Mythik app expose its live contract,
158
+ state, actions, diagnostics, and environment as structured context for
159
+ AI agents. It complements the spec-edit loop:
160
+
161
+ - `manifest` and `elements` read stored specs.
162
+ - `lint` and `validate` check candidate specs before runtime.
163
+ - `reveal` reads the app that is actually running.
164
+
165
+ Use Reveal when the symptom is runtime behavior: a button does not
166
+ fire, a dataSource does not load, a screen renders the wrong branch, a
167
+ native app behaves differently from web, or a render error appears.
168
+ Do not guess from source files first when a Reveal-enabled app can
169
+ answer with live context.
170
+
171
+ Start the local bridge:
172
+
173
+ ```bash
174
+ mythik reveal start --port 17373
175
+ ```
176
+
177
+ The command prints:
178
+
179
+ ```text
180
+ MYTHIK_REVEAL_URL=http://127.0.0.1:17373
181
+ MYTHIK_REVEAL_TOKEN=<generated-token>
182
+ ```
183
+
184
+ Pass those values into the host runtime in development:
185
+
186
+ ```tsx
187
+ const reveal = React.useMemo(() => ({
188
+ enabled: import.meta.env.DEV,
189
+ appName: 'my-app',
190
+ bridgeUrl: import.meta.env.VITE_MYTHIK_REVEAL_URL,
191
+ token: import.meta.env.VITE_MYTHIK_REVEAL_TOKEN,
192
+ environment: { id: 'dev', source: 'host' as const },
193
+ includeStatePaths: ['/ui', '/form'],
194
+ redactStatePaths: ['/auth', '/secrets'],
195
+ }), []);
196
+
197
+ <MythikApp appSpec={appSpec} specStore={specStore} reveal={reveal} />
198
+ ```
199
+
200
+ Then query the connected app:
201
+
202
+ ```bash
203
+ mythik reveal apps --json
204
+ mythik reveal context --app my-app
205
+ mythik reveal current --app my-app
206
+ mythik reveal screen dashboard --app my-app
207
+ mythik reveal element save-button --app my-app
208
+ ```
209
+
210
+ Reveal context includes:
211
+
212
+ - runtime renderer (`react`, `react-native`, `server`, or `unknown`)
213
+ - app name, platform, and environment metadata
214
+ - spec summary and optional screen/element summary
215
+ - resolved public props for inspected elements
216
+ - dependency paths for inspected elements
217
+ - included state paths and omitted paths
218
+ - render errors and warnings
219
+ - action, transaction, dataSource, navigation, lifecycle, and render
220
+ error events
221
+ - patch target metadata when the host can identify a versioned spec
222
+ - redaction and truncation metadata
223
+
224
+ Security rules:
225
+
226
+ - Reveal is development tooling. Do not enable it in production.
227
+ - The bridge is local and token-protected. Never commit or publish the
228
+ token.
229
+ - Use narrow `includeStatePaths`; do not expose the whole store by
230
+ default.
231
+ - Redact `/auth`, `/secrets`, tokens, passwords, API keys, and session
232
+ values.
233
+ - React and React Native hosts should memoize the `reveal` config
234
+ object so the bridge client is stable across renders.
235
+ - For Android emulator testing, use `adb reverse tcp:17373 tcp:17373`
236
+ before querying the host bridge from the native app.
237
+
119
238
  ### Full Spec Lifecycle
120
239
 
121
240
  ```bash
122
- Create: mythik push <id> < spec.json
241
+ Create: mythik push <id> --from-file spec.json --author <agent>
123
242
  Read: mythik manifest <id> / mythik elements <id> ids / mythik pull <id>
124
- Modify: mythik patch <id> --from-file patch.json
243
+ Modify: mythik patch <id> --from-file patch.json --author <agent>
125
244
  Validate: mythik validate <id>
126
245
  Delete: mythik delete <id> --confirm
127
246
  Backup: mythik pull <id> > backup.json
128
- Restore: mythik push <id> < backup.json
129
- Migrate: mythik pull <id> --store A | mythik push <id> --store B
247
+ Restore: mythik push <id> --from-file backup.json --replace --author <agent>
248
+ Migrate: mythik push <id> --from-file exported.json --author <agent> --store B
130
249
  Tokens: mythik tokens --dna '{"primary":"#0D9488"}' --json
131
250
  ```
132
251
 
@@ -245,7 +364,7 @@ Every screen is a JSON Spec with a `root` ID, a flat `elements` map, and optiona
245
364
  | `style` | object | CSS styles (can contain expressions) |
246
365
  | `visible` | boolean or condition | Show/hide condition |
247
366
  | `permission` | object | Role-based access: `{ visible, editable, readonly }` |
248
- | `repeat` | object | Iterate over array: `{ statePath, key }` or `{ source: expression, key }` |
367
+ | `repeat` | object | Iterate over array: `{ statePath, key }` or `{ source: expression, key }`; optional `layout` controls item row direction/gap/wrap |
249
368
  | `on` | object | Event handlers: `{ press: action, change: action }` |
250
369
  | `hover` | object | Style overrides when pointer enters (rendered via Motion) |
251
370
  | `active` | object | Style overrides when element is pressed (rendered via Motion) |
@@ -585,7 +704,7 @@ Each primitive accepts `style` (CSS object), `visible` (condition), and `permiss
585
704
 
586
705
  ### Icon Primitive
587
706
 
588
- The `icon` primitive renders icons from a connected icon library. By default it's a placeholder — apps connect a library via `plugins.overridePrimitive('icon', ...)`.
707
+ The `icon` primitive renders icons from a connected icon library. By default it's a placeholder — apps connect a library once via `plugins.setIconRenderer(Component)`. Built-in icons, table action icons, toast icons, and React Native icon consumers use that same registration.
589
708
 
590
709
  ```json
591
710
  { "type": "icon", "props": { "name": "pencil-simple", "size": 16, "weight": "bold", "color": "#666" } }
@@ -1227,6 +1346,18 @@ Use `source` for filtered/paginated lists:
1227
1346
 
1228
1347
  Inside repeated elements, use `$item` and `$index` to access the current item's data. These work in `props`, `style`, `visible`, and `on` (event params).
1229
1348
 
1349
+ Use `repeat.layout` when the repeated items should render as a horizontal or wrapping row:
1350
+
1351
+ ```json
1352
+ "repeat": {
1353
+ "source": { "$state": "/filters" },
1354
+ "key": "id",
1355
+ "layout": { "direction": "horizontal", "gap": 8, "wrap": true }
1356
+ }
1357
+ ```
1358
+
1359
+ Grouped repeats keep group headers/footers vertical and apply `repeat.layout` only to each group's item row.
1360
+
1230
1361
  ### Grouped Repeat (`groupBy`)
1231
1362
 
1232
1363
  Two modes — auto-detected:
@@ -1938,7 +2069,7 @@ Reference tokens or write custom values:
1938
2069
  37. **Device context is auto-tracked** — viewport, platform, orientation, OS color scheme write to `/ui/device/*` automatically. Use `$breakpoint` for responsive values, `$platform` for cross-platform branching, `$state` for orientation detection
1939
2070
  38. **Use `forms` for coordinated validation** — form-level `isValid`, cross-field rules, submit gating. Use inline `checks` on inputs for standalone fields without form coordination
1940
2071
  39. **Use `$auth` for user data, not `$state`** — `{ "$auth": "email" }` is safer (whitelisted fields only) and more stable than `{ "$state": "/auth/user/email" }`. `$auth` blocks access to tokens/passwords even if somehow in state
1941
- 40. **Auth headers are auto-injected** — specs don't need to specify auth headers in `fetch`/`submitForm`. The framework injects Bearer tokens automatically for configured `authDomains`
2072
+ 40. **Auth headers are auto-injected** — specs don't need to specify auth headers in `fetch`/`submitForm`. With `MythikApp apiBaseUrl`, framework-owned relative URLs inherit auth for that exact origin when `authDomains` is omitted or empty. Providing `authDomains` disables that automatic `apiBaseUrl` origin allowlist; list every trusted absolute host explicitly.
1942
2073
  41. **Login screen is a normal spec** — build login forms with regular primitives (input, button). The `login` action connects to the auth provider. No special components needed. Use `$bindState: "/login/username"` and `"/login/password"` for form fields. The `login` action receives `{ email: "$state /login/username", password: "$state /login/password" }`
1943
2074
  42. **Never trust client auth as security** — `AppAuthConfig` is UX routing (hide screens by role), not server-side security. Always validate tokens on the backend
1944
2075
  43. **Use `roleAccess` for centralized access control** — when defined, it's the sole source of truth. Roles not listed get zero access. `ScreenDefinition.roles` is only used when `roleAccess` is absent
@@ -1957,9 +2088,9 @@ Reference tokens or write custom values:
1957
2088
  56. **Auto-skeleton activates when spec has `fetch` in initialActions + loading + empty data** — zero config needed. Set `skeleton: false` on elements that show static content. Set `autoSkeleton={false}` on MythikRenderer to disable entirely
1958
2089
  57. **Use `export` action for data downloads, not custom fetch** — format `"csv"` is always available (built-in). For `"xlsx"` or `"pdf"`, register an ExportAdapter via `exportAdapters` prop on MythikRenderer
1959
2090
  58. **Export columns support formatting** — `format: "currency"` with `formatOptions: { currency: "USD", locale: "en-US", decimals: 2 }`. Same Intl formatters as `$format` expression handler
1960
- 59. **Use `variant` prop for consistent component styling** — don't copy style objects between elements. Define variants in `tokens.components.{type}.{variant}` and reference with `"variant": "primary"`
1961
- 60. **Element-level style/hover/active overrides variant** — variant is always the base. For one-off customizations, add explicit style/hover on the element. For reusable customizations, define a new variant
1962
- 61. **Use `$path` references in variant definitions** — `$colors.primary` resolves against active tokens so dark mode works automatically. No need for separate dark variant definitions unless the dark change isn't just a token swap
2091
+ 59. **Use `variant` prop for consistent primitive styling** — don't copy style objects between elements. Define variants in `tokens.components.{type}.{variant}` and reference with `props.variant`. Variants are for visual slots (`style`, `hover`, `active`, `focus`, `transition`, `animations`), not arbitrary primitive props.
2092
+ 60. **Element-level style/hover/active overrides variant** — variant is always the base. For one-off customizations, add explicit style/hover on the element. For reusable customizations, define a new variant. For reusable prop-bearing patterns such as table `headerStyle`/`rowStyle`, `columns`, `onRowClick`, or composed children, use `templates` or Layer 3 custom elements instead of copying props into every table/chip.
2093
+ 61. **Use `$path` references in variant definitions** — `$colors.primary` resolves against active tokens so dark mode works automatically. Variant definitions do not evaluate render-context expressions such as `$state`, `$item`, or `$prop`; keep state/item-specific active styling on the element or move the composition to a template/custom element.
1963
2094
  62. **AppSpec patches use `/layout/elements/` not `/elements/`** — Screen spec elements are at `/elements/{id}`. AppSpec layout elements are at `/layout/elements/{id}`. Use dot-notation with `mythik elements` for inspecting non-element sections (tokens, screens, etc.)
1964
2095
  63. **AppSpec is filtered without Bearer token** — `GET /api/app/:id` strips `roleAccess` and `protectedScreens` from the response when no valid Bearer token is present. This prevents information disclosure of the authorization model. With a valid Bearer, the full AppSpec is returned. The endpoint never returns 401 — only the payload changes
1965
2096
  64. **CLI warns on unknown prop names** — `mythik push` and `mythik validate` check prop names against known schemas for all 38 primitives. Unknown props generate warnings (not errors) with Levenshtein suggestions: `⚠ unknown prop "inputType" for type "input" — did you mean "type"?`. Warnings don't block saves
@@ -1990,13 +2121,13 @@ Reference tokens or write custom values:
1990
2121
  89. **Lazy bootstrap for existing specs** — first versioned save on an existing spec with no history automatically creates v1 (snapshot of current spec), then saves the change as v2. No migration script needed. Specs without history continue working via base `SpecStore.load()`
1991
2122
  90. **Use `navigateScreen` and `goBackScreen` in specs** — `navigateScreen` and `goBackScreen` are registered by MythikApp and call the AppEngine directly. The built-in `navigate` and `goBack` only set state intents. Always use `navigateScreen`/`goBackScreen` in specs for navigation that works. Example: `{ "action": "goBackScreen" }` goes back to the previous screen in the navigation history, regardless of which screen navigated to the current one
1992
2123
  91. **CLI `--table` flag overrides the current spec table** — all commands accept `--table <name>` to read/write from a different base table. Use `--table api_specs` to operate on api-specs. The flag overrides the base table for Supabase, SQL Server, PostgreSQL, MySQL, and SQLite stores. Version and environment tables are configured separately with `MYTHIK_VERSIONS_TABLE`, `MYTHIK_ENVIRONMENTS_TABLE`, or the equivalent `.mythikrc` SQL settings.
1993
- 92. **`push` and `patch` version automatically with `--author`**when `--author` is provided, both commands use `VersionedSpecStore.saveVersion()` instead of `SpecStore.save()`. The version includes author, source type (`push`/`patch`), and optional `--description`. Without `--author`, commands work as before (no versioning). Example: `mythik patch screen-id --author alice --description "Fixed layout"`
2124
+ 92. **`push` and `patch` require explicit write intent**persisted writes should use `--author <name>` so the resolved versioned store records a version through `VersionedSpecStore.saveVersion()`. Existing specs require `--replace` for full replacement. Use `--allow-unversioned` only for intentionally unversioned stores such as file-store smoke tests. The version includes author, source type (`push`/`patch`), and optional `--description`. Example: `mythik patch screen-id --from-file patch.json --author alice --description "Fixed layout"`
1994
2125
  93. **`mythik history` shows inline diffs** — each version in the history output shows the actual changes (before/after values), not just a summary. Uses `computeStructuralDiff` between consecutive versions. Example output: `~ element "btn" prop content: "Send" → "Submit"`
1995
2126
  95. **`ai-context.md` is the AI-optimized spec reference** — compressed from this reference-doc (1145 lines vs 2658). Use ai-context.md for spec generation, reference-doc for full human reference. Validated via agent-based testing with progressive difficulty levels (L1-L4). Test scenarios in `../ai-context-test-scenarios.md`, results in `../ai-context-test-results.md` (framework-dev, not part of consumer publish surface)
1996
2127
 
1997
2128
  94. **Generic SQL versioned stores are available** — `resolveVersionedStore` supports `sqlserver`, `postgres`, `mysql`, and `sqlite` store types. It creates a driver-backed `SqlVersionedSpecStore` (specs + version history) plus `SqlEnvironmentStore` (environment pointers). Requires `screens`, `screen_versions`, and `screen_environments`; initialize with `mythik init-store` or apply the DDL from `mythik init-store --dry-run`.
1998
2129
  96. **SupabaseVersionedSpecStore available** — `resolveVersionedStore` supports `supabase` store type. Uses PostgREST REST API (no `@supabase/supabase-js` dependency). Same snapshot+patches pattern as SqlServer. Environment upsert uses `on_conflict=screen_id,environment` for PostgREST compatibility. Requires `screen_versions` and `screen_environments` tables created in Supabase dashboard
1999
- 97. **`variant` is a universal prop** — any primitive can use `variant` when component variants are defined in `tokens.components.{type}.{variant}`. The validator accepts `variant` on all primitives (via `COMMON_PROPS`). The render engine resolves variants before passing props to the primitive
2130
+ 97. **`variant` is a universal prop** — any primitive can use `variant` when component variants are defined in `tokens.components.{type}.{variant}`. The validator accepts `variant` on all primitives (via `COMMON_PROPS`). The render engine resolves variants before passing props to the primitive. Put `variant` inside `props`, and use variants as the first-line reuse mechanism before duplicating visual style blocks.
2000
2131
  98. **Use DNA seeds for app identity** — define `tokens.dna` in AppSpec with 1-8 seed values. The framework derives all visual tokens (colors via OKLCH tonal palette, shape, typography, spacing, elevation, motion, opacity) plus auto dark mode. No manual color palette or radius scale needed — DNA generates it from `{ "primary": "#0D9488" }`
2001
2132
  99. **Three-layer token resolution** — Framework DEFAULTS (always present) → DNA derivation (if `dna` seed exists) → Manual overrides (explicit `tokens.*` values always win). Specs without tokens use defaults. Specs with only DNA get full derived identity. Specs with DNA + overrides get derived base with surgical customization
2002
2133
  100. **`$token` auto-converts elevation to CSS** — `{ "$token": "elevation.md" }` returns a CSS `boxShadow` string on web (e.g., `"0px 4px 12px rgba(0,0,0,0.15)"`). On RN, primitives handle elevation internally via native shadow props. No manual conversion needed
@@ -2009,7 +2140,7 @@ Reference tokens or write custom values:
2009
2140
  107. **`Element.key` forces remount on value change** — Add `key` to any element with a dynamic expression (e.g., `{ "$template": "preview-${/internal/tokenVersion}" }`). When the resolved value changes, React unmounts and remounts the element, re-triggering mount animations. Used by DNA Playground to re-animate preview on Apply DNA
2010
2141
  108. **Input supports `type: "color"`** — Renders native OS color picker. Use with `$bindState` for interactive color selection in specs
2011
2142
  109. **Slider label is display-only** — The slider primitive renders the `label` prop as-is without appending the current value. Use `$template` in the label to include the value if desired (e.g., `"label": { "$template": "Roundness: ${/dna/roundness}%" }`)
2012
- 110. **`--author` activates CLI versioning** — `mythik push` and `mythik patch` without `--author` write directly to the `screens` table with NO version history. With `--author ai-agent`, they use `VersionedSpecStore` which writes to both `screens` AND `screen_versions`, enabling `history`, `diff`, and `rollback` commands. Always use `--author` during development
2143
+ 110. **`--author` is the normal persisted-write path** — `mythik push` and `mythik patch` with `--author ai-agent` use `VersionedSpecStore` when available, writing to both `screens` and `screen_versions` and enabling `history`, `diff`, and `rollback` commands. Without `--author`, persisted writes are rejected unless `--allow-unversioned` is explicit. Always use `--author` during development.
2013
2144
  111. **Identity System — `tokens.identity` controls visual identity beyond DNA** — DNA controls continuous/color values. Identity controls categorical dimensions: `surface` (how containers render), `radiusPattern` (corner shape), `typographyHierarchy` (heading scale), `labelStyle` (label formatting), `textDecoration` (heading decoration), `depth` (shadow intensity 0-1), `shadowAngle` (shadow direction 0-360°), `colorScheme` (light/dark/colored polarity), `colorWeight` (where color appears), `accentApplication` (where accent appears). Set via `tokens.identity` in AppSpec or screen Spec. Lint validates deep identity enum/range values; for example use `colorScheme: "light-surface"`, not `"light"`
2014
2145
  112. **Surface Treatment — 6 types transform all containers** — `identity.surface`: `elevated` (shadow+border, material), `flat` (color blocks only, no borders/shadows), `outlined` (borders only, transparent bg, Linear-like), `glass` (backdrop-filter blur, semi-transparent), `bold` (thick 2-3px borders, brutalist), `neo` (neumorphic inset+outset shadows). Every input, button, card, modal, select, textarea, checkbox, accordion, table adapts automatically
2015
2146
  113. **Surface styles are explicit — every property set, no implicit values** — All 6 surface types define `border` and `boxShadow` explicitly for every component category. Properties are `'none'` when not used, never omitted. This prevents browser defaults from showing (e.g., native button borders in flat mode)
@@ -2052,7 +2183,7 @@ Reference tokens or write custom values:
2052
2183
  150. **Gradient interpolation in OKLCH** — All gradient text and gradient buttons use `linear-gradient(in oklch, ...)` for vibrant transitions. sRGB interpolation crosses through desaturated midpoints (purple→gold becomes muddy brown); OKLCH maintains saturation through the hue arc. Graceful degradation on older browsers
2053
2184
  151. **Gradient modes: vibrant, soft, muted** — `identity.gradients.text`, `identity.gradients.buttons`, and `identity.gradients.cards` accept `boolean | 'vibrant' | 'soft' | 'muted'`. For text and buttons: Vibrant = OKLCH primary→accent. Soft = OKLCH primaryLight→accentLight (subtle). Muted = sRGB primary→accent (desaturated center, luxury/editorial aesthetic). For cards: Vibrant = 33% primary alpha (dramatic). Muted = 20% primary alpha (balanced default). Soft = 8% primary alpha (subtle kiss). `true` maps to vibrant for text/buttons, muted for cards
2054
2185
  152. **Explicit accent hex preserved as-is** — When `dna.accent` is set explicitly, `deriveDna` uses the exact hex for `colors.accent` instead of passing through `generateTonalPalette` step 60. The palette is still generated (for `accentLight`), but the primary accent color is the user's exact choice
2055
- 153. **`setIconRenderer` replaces `overridePrimitive` for icons** — `plugins.setIconRenderer(Component)` registers a custom icon renderer. The framework's `icon.tsx` handles identity wrapping (container, weight default) while the registered component renders the actual icon. `overridePrimitive('icon', ...)` still works but bypasses identity features
2186
+ 153. **`setIconRenderer` replaces `overridePrimitive` for icons** — `plugins.setIconRenderer(Component)` registers a custom icon renderer. The framework's `icon.tsx` handles identity wrapping (container, weight default) while the registered component renders the actual icon. Table action icons, toast icons, and React Native icon consumers use the same registration. `overridePrimitive('icon', ...)` still works for full primitive replacement but bypasses identity features
2056
2187
  154. **Do not emit Box `backgroundBlobs`** — Box `backgroundBlobs` and legacy per-element blob rendering are not part of the public primitive contract. App-level background lives exclusively at `tokens.identity.background` (rule 147) and mounts at MythikRenderer via `<BackgroundStack>`. Box is a pure surface-styled wrapper; primitives do not rely on `dangerouslySetInnerHTML` for keyframe injection.
2057
2188
  155. **Do not emit `$token: "backgroundCSS"`** — `$token: "backgroundCSS"` does not resolve. For preset-aware app backgrounds, set `tokens.identity.background` as a LayerBackground (rule 147) — presets update that field directly so the root `<BackgroundStack>` re-resolves on preset switch. No token alias indirection needed.
2058
2189
  156. **Accordion `badge` prop** — `accordion` accepts optional `badge` prop (`string | number | boolean`). Renders as: solid 8px primary-colored dot for `true`, pill with text/number for string/number values. Hidden when `false`, `0`, `undefined`, or `''`. Use with `$state` for reactive indicators: `"badge": { "$state": "/modified/mySection" }`
@@ -2097,7 +2228,7 @@ Reference tokens or write custom values:
2097
2228
  }
2098
2229
  ```
2099
2230
 
2100
- **`authDomains` matcher behavior:** the matcher compares the URL's hostname only the port is stripped. `"myproject.supabase.co"` matches requests to that hostname on any port. In dev, use `["localhost"]` (NOT `["localhost:5173"]`) the port in the entry never matches because URL hostnames never contain ports. Subdomain matching is also supported: `"example.com"` matches `api.example.com`. See `ai-context-runtime-semantics.md § 4.1` for the full contract including URL scheme filter and subdomain rules.
2231
+ **`apiBaseUrl` + `authDomains` matcher behavior:** when a React host passes `apiBaseUrl`, framework-owned relative runtime URLs such as `/api/orders` resolve against that base before URL guards, auth interceptors, and fetch execution. If auth is enabled and `authDomains` is omitted or empty, the exact origin of `apiBaseUrl` (`protocol + host + port`) becomes the default auth target. Same-host services on other ports do not inherit that token. If `authDomains` is provided, the automatic `apiBaseUrl` origin allowlist is disabled; list every trusted absolute host explicitly. The matcher compares hostname only, strips ports, and supports exact/subdomain matching. See `ai-context-runtime-semantics.md § 4.1`.
2101
2232
 
2102
2233
  ### `$auth` Expression
2103
2234
 
@@ -2225,7 +2356,7 @@ The `statePolicy: "reset"` is what clears `/screens/login` on every navigation t
2225
2356
 
2226
2357
  - Tokens NEVER exist in the state store — only in engine closure
2227
2358
  - `$auth` blocks token/password fields via whitelist
2228
- - Auth headers only injected for `authDomains` URLs
2359
+ - Auth headers only injected for the host `apiBaseUrl` exact origin or explicit `authDomains` URLs
2229
2360
  - Credentials cleared from state after login (success AND failure)
2230
2361
  - Refresh mutex: max 1 concurrent refresh (anti-stampede)
2231
2362
  - Login rate limit: 5 attempts/min with exponential backoff
@@ -2253,7 +2384,7 @@ The framework uses a scoped fetch wrapper (NOT `globalThis.fetch`). All `fetch`
2253
2384
 
2254
2385
  | Interceptor | Config | Behavior |
2255
2386
  |-------------|--------|----------|
2256
- | **Auth** | Auto when auth configured | Injects Bearer token for `authDomains` URLs. Triggers refresh+retry on 401. |
2387
+ | **Auth** | Auto when auth configured | Injects Bearer token for the host `apiBaseUrl` exact origin or explicit `authDomains` URLs. Triggers refresh+retry on 401. |
2257
2388
  | **Logging** | `"logging": true` | Logs request method/URL and response status. Redacts sensitive query params (token, password, key). |
2258
2389
  | **Timeout** | `"timeout": { "ms": 15000 }` | Aborts request after configured milliseconds. Uses AbortController. |
2259
2390
  | **Retry** | `"retryOnError": { ... }` | Retries on transient server errors (502, 503, 504) with exponential backoff. |
@@ -3058,7 +3189,7 @@ The current background and motion stack combines app-level `LayerBackground`, an
3058
3189
 
3059
3190
  211. **`useShapeAnimations(ref, animations, options)` — Layer 3 web runner** — Exported from `mythik-react` via `packages/react/src/animation/useShapeAnimations.ts`. React hook for SVG-child animations (`<path>`/`<circle>`/`<rect>`/`<g>`…). Consumes the same `ElementAnimations` contract as `useElementAnimations` but narrowed to the `ambient` trigger ONLY; shape children have no hover/focus/active contract and no distinct mount ceremony. Attaches CSS animations via `el.style.animation` (surgical, preserves other inline styles); keyframes register once through the CSSOM singleton (zero `dangerouslySetInnerHTML`) and dedupe by hash so multiple shape instances with the same recipe share one CSS rule. Dev mode warns when non-ambient triggers are passed. Production silently ignores them. `options.recipes` SHOULD be stable for useMemo performance.
3060
3191
 
3061
- 212. **`useShapeAnimations(animations, options)` — Layer 3 RN runner** — Published through `mythik-react-native` from `packages/react-native/src/animation/useShapeAnimations.ts`. Reanimated parity of rule 211: returns `{ animatedProps }` that the consumer spreads onto `Animated.createAnimatedComponent(Path)` from `react-native-svg`. Uses the `HARD_PER_TRIGGER` (=6) fixed-pool `useSharedValue` pattern (`useSharedValueArray` helper, also exported) so React Hook count stays stable. Reuses `composeRNStyle(contributions, interpolate, interpolateColor)` shared with `useElementAnimations` — single composition pipeline for View-style and animated SVG props. Relies on `react-native-svg` v13+ auto-translating the transform array into SVG `transform="..."` strings. Same dev-mode non-ambient-trigger warning as the web hook.
3192
+ 212. **`useShapeAnimations(animations, options)` — Layer 3 RN runner** — Implemented inside `mythik-react-native` at `packages/react-native/src/animation/useShapeAnimations.ts` for the native blob/background renderer. It is not exported from the package root as a standalone public hook. Reanimated parity of rule 211: returns `{ animatedProps }` that the renderer spreads onto `Animated.createAnimatedComponent(Path)` from `react-native-svg`. Uses the `HARD_PER_TRIGGER` (=6) fixed-pool `useSharedValue` pattern (`useSharedValueArray` helper) so React Hook count stays stable. Reuses `composeRNStyle(contributions, interpolate, interpolateColor)` shared with `useElementAnimations` — single composition pipeline for View-style and animated SVG props. Relies on `react-native-svg` v13+ auto-translating the transform array into SVG `transform="..."` strings. Same dev-mode non-ambient-trigger warning as the web hook.
3062
3193
 
3063
3194
  213. **Cross-platform Layer 3 parity pins** — `buildCSSKeyframes` (web) and `buildReanimatedSpec` (RN) interpret the same resolved `AnimationSpec` identically on load-bearing invariants: duration agreement (ms count matches regardless of input form `'28s'`/`'28000'`), keyframe stop count (web `%` markers match RN `inputRange` length), direction semantic (`'alternate'` token ⇔ `timing.reverse=true`), iterations `'infinite'`/numeric count, animated-prop enumeration (`translateX/Y`/`rotateDeg`/`scale`).
3064
3195
 
@@ -3134,7 +3265,7 @@ The current background and motion stack combines app-level `LayerBackground`, an
3134
3265
 
3135
3266
  247. **`derive` and `dataSources` are processed at runtime per spec mount** (v0.1.0). When `spec.derive` is present, the framework instantiates a `DeriveEngine`, evaluates all derive paths in topological order at mount, and re-evaluates dirty paths reactively on state changes. Derive paths are protected: setState targeting a derive path errors at validate time and runtime. When `spec.dataSources` is present, the framework instantiates a `DataSourcesEngine`, performs initial fetches (deferred to reactive resolution when URL template deps are undefined), and re-fetches reactively when dependencies change. The action `refreshDataSource` (params: `{ id: string }`) is automatically registered for any spec with dataSources. URL templating requires the explicit `{ $template: '...' }` form — plain strings with `${...}` are NOT substituted (validator catches at load). See `ai-context-runtime-semantics.md` for lifecycle, ordering, error degradation, and state protection details.
3136
3267
 
3137
- 248. **CLI is the only approved path for spec writes** (v0.1.0). Three approved forms: (a) **Shell** - `mythik push <id> --from-file spec.json` / `mythik patch <id> --from-file patch.json` (or intentional stdin via `--from-file -` / pipe without `--from-file`); (b) **Bulk** - `mythik push --from-dir ./specs/` (sequential, continue-on-error, no rollback; partial state on failure recovers by fixing failures and re-running the same command); (c) **Programmatic** - `import { runPush, runPatch } from 'mythik-cli/api'` for IDE tooling, test harnesses, CI scripts. NEVER call `SpecStore.save()` directly from application code. It is an internal persistence primitive marked `@internal`; validation happens at the CLI / engine tier. Bypassing this path skips validation and can produce runtime errors visible only at render time. `mythik patch --from-file <path>` is preferred over inline JSON for any patch containing `$state`, `$template`, `$auth`, or `$row` references (PowerShell expands `$<word>` in double-quoted strings).
3268
+ 248. **CLI is the only approved path for spec writes** (v0.1.0). Three approved forms: (a) **Shell** - `mythik push <id> --from-file spec.json --author <name>` / `mythik patch <id> --from-file patch.json --author <name>` (or intentional stdin via `--from-file -` / pipe without `--from-file` plus `--author`); (b) **Bulk** - `mythik push --from-dir ./specs/ --author <name>` (sequential, continue-on-error, no rollback; partial state on failure recovers by fixing failures and re-running the same command); (c) **Programmatic** - `import { runPush, runPatch } from 'mythik-cli/api'` for IDE tooling, test harnesses, CI scripts. NEVER call `SpecStore.save()` directly from application code. It is an internal persistence primitive marked `@internal`; validation happens at the CLI / engine tier. Bypassing this path skips validation and can produce runtime errors visible only at render time. `mythik patch --from-file <path>` is preferred over inline JSON for any patch containing `$state`, `$template`, `$auth`, or `$row` references (PowerShell expands `$<word>` in double-quoted strings). Existing full-spec replacement requires `--replace`; intentionally unversioned writes require `--allow-unversioned`.
3138
3269
 
3139
3270
  249. **`mythik lint` detects known anti-patterns in specs and consumer code** (v0.1.0).
3140
3271
 
@@ -3149,7 +3280,7 @@ A new CLI command + programmatic API:
3149
3280
  - `spec-row-literal` (warning) — `$row` is not an expression handler; use `$state: '/ui/selectedRow/<key>'`. Validator-resident in `spec-validator.ts` (also surfaces during `mythik push` and `mythik validate`).
3150
3281
  - `spec-crud-id-collision` (error) — `endpoint.path` ending `/:id` combined with `crud: {}` produces `/path/:id/:id`. Strip trailing `/:id`. Walks the object-shaped `endpoints: Record<string, EndpointConfig>`; emits JSON Pointer paths `/endpoints/<name>/path`.
3151
3282
  - `spec-auth-domains-port` (warning) — `auth.authDomains[i]` containing `:port` strips the port silently (matcher uses hostname-only via `URL.hostname`). Walks the `string[]` shape; emits JSON Pointer paths `/auth/authDomains/<index>`.
3152
- - `code-store-save-bypass` (error) — calling `*store*.save()` outside `packages/core/` and `packages/cli/` bypasses validation. Use `runPush` from `mythik-cli/api` or `mythik push --from-file`. **Known scope**: matches `<Identifier>.save()` callees only (e.g. `myStore.save(...)`). Does NOT detect `this.store.save()`, `<obj>.<store>.save()`, or `(await getStore()).save()` patterns — these slip through the AST scanner. Generation-level guidance in `ai-context.md` (anti-patterns section) covers all variants; the lint rule is one layer of defense-in-depth, not a complete catch. Widening the scanner to handle `PropertyAccessExpression` callees is tracked as a v0.2+ candidate if real consumer code shows these patterns slipping through generation guidance.
3283
+ - `code-store-save-bypass` (error) — calling `*store*.save()` outside `packages/core/` and `packages/cli/` bypasses validation. Use `runPush` from `mythik-cli/api` with `author` or `mythik push --from-file ... --author <name>`. **Known scope**: matches `<Identifier>.save()` callees only (e.g. `myStore.save(...)`). Does NOT detect `this.store.save()`, `<obj>.<store>.save()`, or `(await getStore()).save()` patterns — these slip through the AST scanner. Generation-level guidance in `ai-context.md` (anti-patterns section) covers all variants; the lint rule is one layer of defense-in-depth, not a complete catch. Widening the scanner to handle `PropertyAccessExpression` callees is tracked as a v0.2+ candidate if real consumer code shows these patterns slipping through generation guidance.
3153
3284
 
3154
3285
  **Code rules require TypeScript ^5.0.0 as peerDependency** (optional). If not installed, code rules emit one warning finding `lint-meta-no-typescript` (severity matches `LintSeverity = 'error' | 'warning'`) and skip cleanly. Spec rules run independently.
3155
3286
 
@@ -3161,7 +3292,7 @@ See `ai-context.md` for spec-gen anti-patterns the AI must NOT generate.
3161
3292
 
3162
3293
  250. **Storage tables are initialized explicitly, never silently at runtime** (v0.1.0). SQL-backed stores operate against three tables the consumer database must already have: `screens` (base, required), `screen_versions` (version history), and `screen_environments` (environment promotions). Use `mythik init-store --dialect <sqlserver|postgres|mysql|sqlite> --dry-run` to inspect canonical idempotent DDL, initialize a local SQLite file with `mythik init-store --dialect sqlite --target ./mythik.db`, or initialize a reachable SQL Server store with explicit `--server`, `--database`, `--user`, `--password`, `--encrypt`, and `--trust-server-certificate` flags. The same schema is described in `ai-context.md § Storage Setup`. Runtime reads/writes do not create missing tables. Production deployment scripts should verify required columns after apply.
3163
3294
  251. **`security.exposeErrors` controls render error detail** (v0.1.0). Default is `true`; set `createMythik({ security: { exposeErrors: false } })` for production-like hosts that must avoid leaking error messages/stacks. `_error` render nodes write diagnostics to `/ui/renderErrors` only when exposure is enabled. Primitive/component exceptions are caught by `MythikRenderer`'s error boundary: development + exposed mode shows an overlay with message and component stack; production or `exposeErrors: false` shows a neutral placeholder. The overlay resets when the spec changes so a corrected spec can recover without remounting the host.
3164
- 252. **Icon packs register through `plugins.setIconRenderer`** (v0.1.0). Mythik does not bundle Phosphor/Lucide/etc. Register one host-level renderer from `MythikApp.onPlugins`; the built-in `icon` primitive keeps identity behavior and calls the renderer with `{ name, size, weight, color, style }`. If the placeholder circle renders, verify `onPlugins` registered the renderer and the consumer is not validating against stale tarballs or source aliases.
3295
+ 252. **Icon packs register through `plugins.setIconRenderer`** (v0.1.0). Mythik does not bundle Phosphor/Lucide/etc. Register one host-level renderer from `MythikApp.onPlugins`; the built-in `icon` primitive, table action icons, toast icons, and React Native icon consumers use that same registration. The built-in `icon` primitive keeps identity behavior and calls the renderer with `{ name, size, weight, color, style }`. If the placeholder circle renders, verify `onPlugins` registered the renderer and the consumer is not validating against stale tarballs or source aliases.
3165
3296
  253. **`overridePrimitive('icon')` returns a RenderNode, not JSX** (v0.1.0). Use it only for full primitive replacement. The renderer function must return `{ type, props, children }` with `_component` in props when targeting React. Returning `<Icon />` directly is not the primitive renderer contract and bypasses the built-in icon identity wrapper.
3166
3297
  254. **CLI explicit input wins over ambient stdin** (v0.1.0). For `mythik push`/`mythik patch`, `--from-file <path>` reads the file even if the host process exposes non-TTY stdin. Intentional stdin remains supported through `--from-file -` or by piping without an explicit file. `--from-file` plus a positional patch argument is still a conflict.
3167
3298
  255. **`runPatch` versions in every output mode when `author` is provided** (v0.1.0). `SpecEngine.patch` applies and validates patches. CLI/API `runPatch` persists through the normal `store.save` path without `author`; with a versioned store + `author`, it captures the patched document and writes once through `saveVersion`, preserving lazy-bootstrap pre-patch history. JSON/TOON success output includes additive `versioned` and `version` metadata.
@@ -3214,17 +3345,21 @@ See `ai-context.md` for spec-gen anti-patterns the AI must NOT generate.
3214
3345
 
3215
3346
  281. **`MythikApp.fetcher` supplies editor persistence when auth fetch is absent** - React hosts can pass `fetcher={(url, options) => ...}` to `MythikApp` so `editorSave` and `navigationGuardSaveAndProceed` have a transport in non-auth apps. When auth is configured, the framework fetch with auth interceptors remains the active fetcher. Save actions do not read global `/ui/lastError`; editor save status, errors, and attempts are reported under `/ui/editorSessions/<id>`.
3216
3347
 
3217
- 282. **Existing spec edits must use the CLI inspection-then-patch loop** - For an existing screen/app/api spec, AI agents should run `mythik manifest <id>` first, inspect only the target nodes with `mythik elements <id> <ids>`, apply a small RFC 6902 patch with `mythik patch <id> --from-file patch.json`, and verify with `manifest` or `elements`. This keeps edits surgical, validated, versionable, and reviewable. `pull` is for backup, migration, review, or full-document work; `push` is for new specs or intentional full replacement. Direct database edits and direct `SpecStore.save()` calls bypass validation and are not approved spec-write paths.
3348
+ 282. **Existing spec edits must use the CLI inspection-then-patch loop** - For an existing screen/app/api spec, AI agents should run `mythik manifest <id>` first, inspect only the target nodes with `mythik elements <id> <ids>`, apply a small RFC 6902 patch with `mythik patch <id> --from-file patch.json --author <agent>`, validate, and verify with `manifest` or `elements`. This keeps edits surgical, validated, versionable, and reviewable. `pull` is for backup, migration, review, or full-document work; `push` is for new specs or intentional full replacement with explicit `--replace`. Direct database edits and direct `SpecStore.save()` calls bypass validation and are not approved spec-write paths.
3218
3349
  283. **Bundled AI docs are part of the install surface** - The `mythik` package includes `docs/llms.txt`, `docs/consumer/*`, and `docs/wiki/compiled/*`. Agents should run `mythik docs path` before spec generation and read the bundled docs rather than guessing from package source. Use `mythik docs copy ./mythik-docs` to create a project-local copy when the host workflow needs explicit files.
3219
3350
  284. **DNA numeric seeds are canonical `0–1`, with legacy `0–100` normalization** - Generate `tokens.dna.roundness`, `density`, `depth`, and `formality` as `0–1` numbers (`0.7`, not `70`). The runtime normalizes numeric seed values greater than `1` by dividing by `100` inside DNA derivation, so initial AppSpec load and runtime `updateTokens` share the same backward-compatible behavior.
3220
3351
  285. **Scoped pagination counts filter before aggregation** - Query endpoints may combine `pagination: "offset"` with `scopeFilter`. For generated counts, the server applies the scope filter to the query source first and then counts the scoped source, so the response `total` matches the same tenant/role slice as `data`. Prefer generated counts. If custom `endpoint.count` is truly needed with `scopeFilter`, it must include `{{scopeWhere[:alias]}}` or `{{scopeAnd[:alias]}}`; Mythik expands the macro to the correct scope predicate and removes it for bypass roles. Other custom count SQL is left verbatim. Specs should use `:alias` for JOIN/subquery counts and should not reference internal scope parameter names directly.
3221
3352
  286. **Transaction fetch failures preserve backend error details** - When a transaction `confirm` uses `fetch` and the backend returns an HTTP error payload such as `{ error: { code, message } }`, `/tx/error` is written after rollback with the best backend message plus `code`, HTTP `status`, and raw `data`. `onError` should read `/tx/error/message`; transaction specs should not read global `/ui/lastError`.
3222
- 287. **SQL-backed stores and servers use one dialect-aware `mythik/server` boundary** - Import `createSqlDriver`, `SqlSpecStore`, `SqlVersionedSpecStore`, `SqlEnvironmentStore`, and `getSqlStoreDdl` from `mythik/server` for Node-side SQL work. Supported dialects are `sqlserver`, `postgres`, `mysql`, and `sqlite`. Initialize store tables with `mythik init-store --dialect <dialect>` for reachable SQL stores, `--target` for SQLite, or `--dry-run` for review/apply through a deployment process. SQL Server `init-store` accepts explicit `--server`, `--database`, `--user`, `--password`, `--encrypt`, and `--trust-server-certificate` flags. CLI commands share the same store flags/env vars and must keep existing-spec edits on the `manifest -> elements -> patch --from-file -> validate` loop. ApiSpec `dialect` controls generated CRUD/catalog/pagination/scope SQL; custom SQL remains dialect-native with Mythik named params (`@name`) and is not translated between dialects.
3353
+ 287. **SQL-backed stores and servers use one dialect-aware `mythik/server` boundary** - Import `createSqlDriver`, `SqlSpecStore`, `SqlVersionedSpecStore`, `SqlEnvironmentStore`, and `getSqlStoreDdl` from `mythik/server` for Node-side SQL work. Supported dialects are `sqlserver`, `postgres`, `mysql`, and `sqlite`. Initialize store tables with `mythik init-store --dialect <dialect>` for reachable SQL stores, `--target` for SQLite, or `--dry-run` for review/apply through a deployment process. SQL Server `init-store` accepts explicit `--server`, `--database`, `--user`, `--password`, `--encrypt`, and `--trust-server-certificate` flags. CLI commands share the same store flags/env vars and must keep existing-spec edits on the `manifest -> elements -> patch --from-file --author -> validate -> verify` loop. ApiSpec `dialect` controls generated CRUD/catalog/pagination/scope SQL; custom SQL remains dialect-native with Mythik named params (`@name`) and is not translated between dialects.
3223
3354
  288. **Event arrays may mix actions and transactions** - Event bindings can be a single action, a single transaction, or an array containing both normal action bindings and transaction bindings. Mythik executes the array sequentially and awaits each transaction before continuing. Transaction phases cannot contain nested transactions.
3224
3355
  289. **`$let` dotted references read nested binding values** - A `$ref` may target an object binding path such as `{ "$ref": "user.name" }`, and `$template` placeholders may read the same path as `${user.name}`. Use this for object values produced by `$let`; missing dotted `$ref` segments are invalid references and should be fixed instead of treated as optional data.
3225
3356
  290. **`params.skipIf` is a dispatch-time action guard** - Any action binding may include `params.skipIf`. Mythik resolves it before resolving the rest of the params; when truthy, the action is skipped and the action chain continues. The action handler never receives `skipIf`.
3226
3357
  291. **Direct `fetch` supports `errorTarget` for visible screen-load failures** - `fetch.params.errorTarget` writes HTTP/network errors to a consumer-owned state path and clears it on success. Use it for critical `initialActions` loads so the screen can render a local banner/empty state; `/ui/lastError` remains global compatibility state and can be overwritten by unrelated fetches.
3227
- 292. **`select` supports catalog keys and invalid-option diagnostics** - `select.options` may be strings, `{ label, value }`, or catalog-shaped objects when `labelKey`/`valueKey` are provided. Values emitted from the primitive are strings. Malformed option data renders as disabled diagnostics instead of blank clickable options or crashes, so AI-generated catalog bindings fail visibly.
3358
+ 292. **`select` supports catalog keys, normalized matching, and invalid-option diagnostics** - `select.options` may be strings, `{ label, value }`, or catalog-shaped objects when `labelKey`/`valueKey` are provided. The current value is matched against options by normalized scalar key, so DB integer IDs and string option values match for display. `0` is a valid selected value. Null/undefined show the placeholder. Values emitted from the primitive remain string-compatible. Malformed option data renders as disabled diagnostics instead of blank clickable options or crashes, so AI-generated catalog bindings fail visibly.
3228
3359
  293. **SQL adapters are optional peer dependencies** - `mythik` does not install SQL drivers by default. Browser-only apps install `mythik mythik-react`. SQL-backed stores/servers must install exactly the selected adapter (`mssql`, `pg`, `mysql2`, or `better-sqlite3`). SQLite uses native `better-sqlite3`; warnings from its transitive native-build helpers are adapter-level install warnings, not Mythik runtime failures.
3229
3360
  294. **Missing SQL adapter errors are actionable** - If a SQL-backed store or server uses a dialect whose adapter package is not installed, Mythik throws `SqlDriverError` with `code: "SQL_DRIVER_DEPENDENCY_MISSING"`, `packageName`, `installCommand`, and a message containing the exact `npm install ...` command.
3230
3361
  295. **`mythik-react-native` publishes an explicit native support contract** - Expo apps should install React Native/Expo peer packages with `npx expo install ...`, including `react-native-reanimated` and its Expo-matched `react-native-worklets` peer, before installing `mythik mythik-react-native`, so Expo selects native module versions that match the app SDK. Keep `react-native-reanimated/plugin` last in the app Babel config. The package exports `REACT_NATIVE_PRIMITIVE_SUPPORT` and `getReactNativePrimitiveSupport(name)`. Supported native primitives are `box`, `stack`, `grid`, `scroll`, `divider`, `spacer`, `text`, `image`, `icon`, `input`, `textarea`, `select`, `checkbox`, `toggle`, `slider`, `button`, `touchable`, `list`, `modal`, `drawer`, `tabs`, `accordion`, `wizard`, `screen`, `screen-outlet`, `toast-container`, and `skeleton`. Native-milestone primitives are `bar-chart`, `line-chart`, `pie-chart`, `area-chart`, `table`, `kanban-board`, `spatial-map`, `file-upload`, `camera`, `signature`, and `audio-player`; they should surface diagnostics instead of silently rendering broken UI. Keep `root` as a stable string and use `$platform` only in localized props/style/children/value branches.
3362
+ 296. **Mythik Reveal is the live-context bridge for AI agents** - Before guessing about running-app behavior, start `mythik reveal start`, wire the host `reveal` config in development, and inspect with `mythik reveal apps`, `context`, `current`, `screen`, or `element`. Reveal exposes renderer/environment/spec summaries, selected state paths, resolved public props, dependencies, render errors, warnings, events, patch-target metadata, and redaction/truncation metadata as structured JSON. It complements `manifest -> elements -> patch`: use the CLI loop to edit stored specs, and use Reveal to understand the app that is actually running. Keep it development-only, never commit tokens, memoize React/RN reveal config objects, use narrow `includeStatePaths`, and redact secrets deliberately.
3363
+ 297. **`mythik agent context`, `mythik agent init`, and Mythik Sentinel install and reinforce the AI operating contract**. Use `mythik agent init codex`, `mythik agent init claude`, or `mythik agent init all` to create `.mythik/agent/*` plus thin agent adapters. `codex` creates/updates `AGENTS.md`, `claude` creates/updates `CLAUDE.md`, and `all` updates both; existing file content outside the Mythik-managed `<!-- mythik-agent-protocol:start -->` / `<!-- mythik-agent-protocol:end -->` block is preserved. Use `mythik agent context --app <id> --include-screens` to generate the project-specific operating map. The generated protocol requires existing stored specs to use `manifest -> elements -> patch --from-file --author -> validate -> verify`, names the active store as the source of truth, recommends TOON for token-efficient reads when supported, and scopes `lint` to local drafts, replacement files, bulk import/migration folders, and relevant consumer code. Sentinel runs as advisory CLI coaching: first project use points agents to `agent init`, repeated full-replacement intent warns back to patch-first edits, identical `push --replace` writes are skipped as `skipped: true`, machine-readable outputs stay parseable, and no specs or credentials are persisted in the Sentinel cache. Disable only with `MYTHIK_SENTINEL=off` for exceptional automation.
3364
+ 298. **`repeat.layout` controls repeated item rows**. `repeat.layout` accepts `{ direction, gap, wrap }` and lets repeated items render horizontally or wrap without changing the child primitive. In grouped repeats, group headers and footers keep the outer vertical flow; the layout applies only to the group item row.
3365
+ 299. **`text.on.press` is supported for inline interactive text**. Web text receives button semantics, `tabIndex=0`, pointer cursor, and Enter/Space keyboard activation. React Native text uses a pressable wrapper with `accessibilityRole="button"`. Use `button` or `touchable` for primary actions and larger tap targets.
package/docs/llms.txt CHANGED
@@ -10,8 +10,13 @@ Start here:
10
10
  - wiki/compiled/README.md
11
11
  - wiki/compiled/_index.md
12
12
 
13
+ Project-local agent protocol:
14
+ 1. mythik agent init codex|claude|all
15
+ 2. mythik agent context --app <app-id> --include-screens --out .mythik/agent/context.md
16
+
13
17
  Required edit loop for existing persisted specs:
14
18
  1. mythik manifest <spec-id>
15
19
  2. mythik elements <spec-id> <element-ids>
16
- 3. mythik patch <spec-id> --from-file <patch.json>
20
+ 3. mythik patch <spec-id> --from-file <patch.json> --author <agent-name>
17
21
  4. mythik validate <spec-id>
22
+ 5. mythik manifest <spec-id> or mythik elements <spec-id> <element-ids> to verify
@@ -1,6 +1,6 @@
1
1
  # Mythik - Compiled Wiki
2
2
 
3
- Compiled from `docs/consumer/` into **327 atomic articles**. The wiki is optimized for AI consumption: each article is one concept, and `_index.md` is the flat searchable graph.
3
+ Compiled from `docs/consumer/` into **331 atomic articles**. The wiki is optimized for AI consumption: each article is one concept, and `_index.md` is the flat searchable graph.
4
4
 
5
5
  ## Reading order for first-time spec authoring
6
6
 
@@ -9,22 +9,24 @@ Compiled from `docs/consumer/` into **327 atomic articles**. The wiki is optimiz
9
9
  3. [concept-spec-types](concept-spec-types.md) - Screen vs AppSpec vs ApiSpec.
10
10
  4. [concept-expression-contexts](concept-expression-contexts.md) and [concept-expression-timing](concept-expression-timing.md) - where expressions work and when they resolve.
11
11
  5. [concept-primitives-overview](concept-primitives-overview.md) and [primitive-spatial-map](primitive-spatial-map.md) - primitives, including the spatial-map editor surface.
12
- 6. [cli-existing-spec-edit-loop](cli-existing-spec-edit-loop.md) - required loop for modifying existing persisted specs.
13
- 7. [cli-docs](cli-docs.md) - locate or copy the bundled AI documentation after `npm install`.
12
+ 6. [cli-existing-spec-edit-loop](cli-existing-spec-edit-loop.md) - required loop for modifying existing persisted specs.
13
+ 7. [concept-mythik-reveal](concept-mythik-reveal.md) and [cli-reveal](cli-reveal.md) - inspect live runtime context before guessing.
14
+ 8. [concept-agent-context-protocol](concept-agent-context-protocol.md) and [cli-agent](cli-agent.md) - install the project-local AI operating contract.
15
+ 9. [cli-docs](cli-docs.md) - locate or copy the bundled AI documentation after `npm install`.
14
16
 
15
- ## Publish notes
16
-
17
- - Public package names are unscoped: `mythik`, `mythik-react`, `mythik-cli`, `mythik-server`, `mythik-react-native`.
18
- - `mythik-react-native` is a public preview release line with an explicit support matrix.
19
- - The wiki metadata folder is not publish content.
20
- - `docs/consumer` remains the canonical source.
17
+ ## Publish notes
18
+
19
+ - Public package names are unscoped: `mythik`, `mythik-react`, `mythik-cli`, `mythik-server`, `mythik-react-native`.
20
+ - `mythik-react-native` is a public preview release line with an explicit support matrix.
21
+ - The wiki metadata folder is not publish content.
22
+ - `docs/consumer` remains the canonical source.
21
23
 
22
24
  ## Catalog
23
25
 
24
26
  - [Actions](#actions) - 19
25
27
  - [Anti-patterns](#anti-patterns) - 21
26
- - [CLI](#cli) - 19
27
- - [Concepts](#concepts) - 177
28
+ - [CLI](#cli) - 21
29
+ - [Concepts](#concepts) - 179
28
30
  - [Expressions](#expressions) - 22
29
31
  - [Paths](#paths) - 13
30
32
  - [Patterns](#patterns) - 18
@@ -6,7 +6,7 @@ Per the compilation rules: **never fabricate, surface as a gap.**
6
6
 
7
7
  ## Status: 0 gaps detected during compilation
8
8
 
9
- All 326 articles were written from raw content present in the source
9
+ All 331 articles were written from raw content present in the source
10
10
  files. Every fact in the compiled wiki traces to a `docs/consumer/<file>.md`
11
11
  section listed in the article's `sources:` frontmatter.
12
12
 
@@ -48,14 +48,15 @@ Flat catalog generated from `docs/wiki/compiled`. Use the article ID for wikilin
48
48
  @antipattern-style-block-duplication :: antipattern-style-block-duplication.md :: Anti-pattern — duplicate style blocks
49
49
  @antipattern-submit-form-in-tx-confirm :: antipattern-submit-form-in-tx-confirm.md :: Anti-pattern — `submitForm` in `transaction.confirm`
50
50
 
51
- ## CLI (19)
51
+ ## CLI (21)
52
52
 
53
- @cli-app-spec :: cli-app-spec.md :: CLI on AppSpecs
53
+ @cli-app-spec :: cli-app-spec.md :: CLI on AppSpecs
54
+ @cli-agent :: cli-agent.md :: `mythik agent` - project-local AI operating context
54
55
  @cli-config :: cli-config.md :: CLI config — `.mythikrc` + env vars
55
56
  @cli-contract :: cli-contract.md :: `mythik contract` — frontend↔backend cross-validation
56
- @cli-delete :: cli-delete.md :: `mythik delete` — with safety gate
57
- @cli-docs :: cli-docs.md :: `mythik docs` — bundled AI documentation
58
- @cli-elements :: cli-elements.md :: `mythik elements` — inspect specific elements
57
+ @cli-delete :: cli-delete.md :: `mythik delete` — with safety gate
58
+ @cli-docs :: cli-docs.md :: `mythik docs` — bundled AI documentation
59
+ @cli-elements :: cli-elements.md :: `mythik elements` — inspect specific elements
59
60
  @cli-existing-spec-edit-loop :: cli-existing-spec-edit-loop.md :: Existing spec edit loop
60
61
  @cli-history :: cli-history.md :: `mythik history` — version history with diffs
61
62
  @cli-lint :: cli-lint.md :: `mythik lint` — anti-pattern detection
@@ -65,12 +66,13 @@ Flat catalog generated from `docs/wiki/compiled`. Use the article ID for wikilin
65
66
  @cli-programmatic-api :: cli-programmatic-api.md :: Programmatic API — `mythik-cli/api`
66
67
  @cli-pull :: cli-pull.md :: `mythik pull` — export spec
67
68
  @cli-push :: cli-push.md :: `mythik push` — three approved write paths
69
+ @cli-reveal :: cli-reveal.md :: `mythik reveal` - live runtime context
68
70
  @cli-tokens :: cli-tokens.md :: `mythik tokens` — DNA inspection
69
71
  @cli-toon :: cli-toon.md :: `--toon` - token-efficient format
70
72
  @cli-validate :: cli-validate.md :: `mythik validate`
71
73
  @cli-versioning-author :: cli-versioning-author.md :: `--author` flag — activates versioning
72
74
 
73
- ## Concepts (177)
75
+ ## Concepts (179)
74
76
 
75
77
  @concept-action-chains :: concept-action-chains.md :: Action chains — sequential execution
76
78
  @concept-action-middleware :: concept-action-middleware.md :: Action middleware
@@ -81,7 +83,8 @@ Flat catalog generated from `docs/wiki/compiled`. Use the article ID for wikilin
81
83
  @concept-animation-null-semantics :: concept-animation-null-semantics.md :: Animation null semantics
82
84
  @concept-animation-recipes :: concept-animation-recipes.md :: 15 animation recipes
83
85
  @concept-animation-triggers :: concept-animation-triggers.md :: Animation triggers — 7 triggers
84
- @concept-animations-engine :: concept-animations-engine.md :: `animations` engine (preferred)
86
+ @concept-animations-engine :: concept-animations-engine.md :: `animations` engine (preferred)
87
+ @concept-agent-context-protocol :: concept-agent-context-protocol.md :: Mythik Agent Context and Agent Protocol
85
88
  @concept-api-audit :: concept-api-audit.md :: `audit` — auto-inject user + timestamp
86
89
  @concept-api-auth :: concept-api-auth.md :: API auth (`auth` block)
87
90
  @concept-api-catalogs :: concept-api-catalogs.md :: API catalogs — dropdown sources
@@ -179,6 +182,7 @@ Flat catalog generated from `docs/wiki/compiled`. Use the article ID for wikilin
179
182
  @concept-layer-background :: concept-layer-background.md :: `tokens.identity.background` — LayerBackground v2
180
183
  @concept-motion-field :: concept-motion-field.md :: `motion` field (legacy Framer-Motion)
181
184
  @concept-mount-spec-runtime :: concept-mount-spec-runtime.md :: `mountSpecRuntime` — internal mount helper
185
+ @concept-mythik-reveal :: concept-mythik-reveal.md :: Mythik Reveal - live runtime context for AI agents
182
186
  @concept-mythik-renderer :: concept-mythik-renderer.md :: `MythikRenderer` - root mount
183
187
  @concept-navigation :: concept-navigation.md :: Navigation config
184
188
  @concept-navigation-dirty-guard :: concept-navigation-dirty-guard.md :: Navigation dirty guard