viewspec 0.2.0__tar.gz → 0.3.0b2__tar.gz

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 (151) hide show
  1. {viewspec-0.2.0 → viewspec-0.3.0b2}/.gitignore +16 -14
  2. {viewspec-0.2.0 → viewspec-0.3.0b2}/LICENSE +21 -21
  3. viewspec-0.3.0b2/PKG-INFO +311 -0
  4. viewspec-0.3.0b2/README.md +274 -0
  5. {viewspec-0.2.0 → viewspec-0.3.0b2}/pyproject.toml +74 -57
  6. viewspec-0.3.0b2/src/viewspec/__init__.py +335 -0
  7. viewspec-0.3.0b2/src/viewspec/__main__.py +9 -0
  8. viewspec-0.3.0b2/src/viewspec/_version.py +3 -0
  9. viewspec-0.3.0b2/src/viewspec/a11y.py +206 -0
  10. viewspec-0.3.0b2/src/viewspec/aesthetics.py +667 -0
  11. viewspec-0.3.0b2/src/viewspec/agent.py +2045 -0
  12. viewspec-0.3.0b2/src/viewspec/agent_assets.py +275 -0
  13. viewspec-0.3.0b2/src/viewspec/app_agent_schema.py +687 -0
  14. viewspec-0.3.0b2/src/viewspec/app_bundle.py +276 -0
  15. viewspec-0.3.0b2/src/viewspec/app_diff.py +426 -0
  16. viewspec-0.3.0b2/src/viewspec/app_errors.py +35 -0
  17. viewspec-0.3.0b2/src/viewspec/app_paths.py +164 -0
  18. viewspec-0.3.0b2/src/viewspec/app_pipeline.py +504 -0
  19. viewspec-0.3.0b2/src/viewspec/app_prepared.py +29 -0
  20. viewspec-0.3.0b2/src/viewspec/app_react.py +984 -0
  21. viewspec-0.3.0b2/src/viewspec/app_react_verify.py +308 -0
  22. viewspec-0.3.0b2/src/viewspec/app_reports.py +872 -0
  23. viewspec-0.3.0b2/src/viewspec/app_resource_binding.py +306 -0
  24. viewspec-0.3.0b2/src/viewspec/app_screens.py +148 -0
  25. viewspec-0.3.0b2/src/viewspec/app_shell.py +705 -0
  26. viewspec-0.3.0b2/src/viewspec/app_shell_writer.py +127 -0
  27. viewspec-0.3.0b2/src/viewspec/app_starters.py +265 -0
  28. viewspec-0.3.0b2/src/viewspec/app_state_artifacts.py +171 -0
  29. viewspec-0.3.0b2/src/viewspec/app_tools.py +353 -0
  30. viewspec-0.3.0b2/src/viewspec/app_validation.py +1133 -0
  31. viewspec-0.3.0b2/src/viewspec/app_visibility.py +91 -0
  32. viewspec-0.3.0b2/src/viewspec/cli.py +1205 -0
  33. viewspec-0.3.0b2/src/viewspec/compiler.py +1938 -0
  34. viewspec-0.3.0b2/src/viewspec/compiler_benchmarks.py +1239 -0
  35. viewspec-0.3.0b2/src/viewspec/compiler_refs.py +56 -0
  36. viewspec-0.3.0b2/src/viewspec/design_md.py +713 -0
  37. viewspec-0.3.0b2/src/viewspec/emitters/__init__.py +7 -0
  38. viewspec-0.3.0b2/src/viewspec/emitters/base.py +123 -0
  39. viewspec-0.3.0b2/src/viewspec/emitters/html_tailwind/__init__.py +655 -0
  40. viewspec-0.3.0b2/src/viewspec/emitters/react_tailwind_tsx/__init__.py +550 -0
  41. viewspec-0.3.0b2/src/viewspec/emitters/react_tailwind_tsx/a11y.py +172 -0
  42. viewspec-0.3.0b2/src/viewspec/emitters/react_tailwind_tsx/recipes.py +859 -0
  43. viewspec-0.3.0b2/src/viewspec/emitters/react_tsx/__init__.py +628 -0
  44. viewspec-0.3.0b2/src/viewspec/error_codes.py +429 -0
  45. viewspec-0.3.0b2/src/viewspec/host_verify.py +880 -0
  46. viewspec-0.3.0b2/src/viewspec/host_verify_template/__init__.py +1 -0
  47. viewspec-0.3.0b2/src/viewspec/host_verify_template/index.html +12 -0
  48. viewspec-0.3.0b2/src/viewspec/host_verify_template/package-lock.json +1349 -0
  49. viewspec-0.3.0b2/src/viewspec/host_verify_template/package.json +24 -0
  50. viewspec-0.3.0b2/src/viewspec/host_verify_template/playwright.config.ts +25 -0
  51. viewspec-0.3.0b2/src/viewspec/host_verify_template/src/App.tsx +15 -0
  52. viewspec-0.3.0b2/src/viewspec/host_verify_template/src/index.css +12 -0
  53. viewspec-0.3.0b2/src/viewspec/host_verify_template/src/main.tsx +16 -0
  54. viewspec-0.3.0b2/src/viewspec/host_verify_template/tests/host-verify.spec.ts +347 -0
  55. viewspec-0.3.0b2/src/viewspec/host_verify_template/tsconfig.json +20 -0
  56. viewspec-0.3.0b2/src/viewspec/host_verify_template/vite.config.ts +17 -0
  57. viewspec-0.3.0b2/src/viewspec/intent_tools.py +1503 -0
  58. viewspec-0.3.0b2/src/viewspec/local_tools.py +550 -0
  59. viewspec-0.3.0b2/src/viewspec/local_tools_constants.py +165 -0
  60. viewspec-0.3.0b2/src/viewspec/local_tools_hash.py +13 -0
  61. viewspec-0.3.0b2/src/viewspec/local_tools_io.py +115 -0
  62. viewspec-0.3.0b2/src/viewspec/local_tools_response.py +90 -0
  63. viewspec-0.3.0b2/src/viewspec/local_tools_validators.py +1979 -0
  64. viewspec-0.3.0b2/src/viewspec/manifest_summary.py +118 -0
  65. viewspec-0.3.0b2/src/viewspec/mcp_server.py +354 -0
  66. viewspec-0.3.0b2/src/viewspec/motif_compilers.py +593 -0
  67. viewspec-0.3.0b2/src/viewspec/motif_plugins.py +497 -0
  68. viewspec-0.3.0b2/src/viewspec/native_agents.py +261 -0
  69. viewspec-0.3.0b2/src/viewspec/prove.py +1060 -0
  70. viewspec-0.3.0b2/src/viewspec/py.typed +0 -0
  71. viewspec-0.3.0b2/src/viewspec/raw_html.py +974 -0
  72. {viewspec-0.2.0 → viewspec-0.3.0b2}/src/viewspec/sdk/builder.py +306 -0
  73. viewspec-0.3.0b2/src/viewspec/state_ir.py +1894 -0
  74. {viewspec-0.2.0 → viewspec-0.3.0b2}/src/viewspec/types.py +998 -762
  75. viewspec-0.2.0/.github/workflows/ci.yml +0 -52
  76. viewspec-0.2.0/.github/workflows/pages.yml +0 -30
  77. viewspec-0.2.0/PKG-INFO +0 -239
  78. viewspec-0.2.0/README.md +0 -207
  79. viewspec-0.2.0/demos/CNAME +0 -1
  80. viewspec-0.2.0/demos/SPEC-DEMO-FIFTEEN-LINES.md +0 -96
  81. viewspec-0.2.0/demos/SPEC-DEMO-INVARIANTS.md +0 -89
  82. viewspec-0.2.0/demos/SPEC-DEMO-LANDING.md +0 -101
  83. viewspec-0.2.0/demos/SPEC-DEMO-LIVE-BUILDER.md +0 -102
  84. viewspec-0.2.0/demos/SPEC-DEMO-MOTIF-SWITCHER.md +0 -91
  85. viewspec-0.2.0/demos/SPEC-DEMO-PROVENANCE-INSPECTOR.md +0 -104
  86. viewspec-0.2.0/demos/agent-intent-bundle.schema.json +0 -156
  87. viewspec-0.2.0/demos/agent-system-prompt.txt +0 -40
  88. viewspec-0.2.0/demos/build_fifteen_lines.py +0 -572
  89. viewspec-0.2.0/demos/build_invariants.py +0 -644
  90. viewspec-0.2.0/demos/build_landing.py +0 -83
  91. viewspec-0.2.0/demos/build_live_builder.py +0 -446
  92. viewspec-0.2.0/demos/build_motif_switcher.py +0 -343
  93. viewspec-0.2.0/demos/build_provenance_inspector.py +0 -424
  94. viewspec-0.2.0/demos/build_style_derivation.py +0 -533
  95. viewspec-0.2.0/demos/fifteen-lines/index.html +0 -575
  96. viewspec-0.2.0/demos/index.html +0 -1423
  97. viewspec-0.2.0/demos/invariants/index.html +0 -435
  98. viewspec-0.2.0/demos/landing-compiled/diagnostics.json +0 -1
  99. viewspec-0.2.0/demos/landing-compiled/index.html +0 -25
  100. viewspec-0.2.0/demos/landing-compiled/intent_bundle.json +0 -408
  101. viewspec-0.2.0/demos/landing-compiled/provenance_manifest.json +0 -523
  102. viewspec-0.2.0/demos/live-builder/index.html +0 -326
  103. viewspec-0.2.0/demos/llms-full.txt +0 -137
  104. viewspec-0.2.0/demos/llms.txt +0 -51
  105. viewspec-0.2.0/demos/motif-switcher/index.html +0 -1409
  106. viewspec-0.2.0/demos/openapi.json +0 -167
  107. viewspec-0.2.0/demos/provenance-inspector/index.html +0 -1624
  108. viewspec-0.2.0/demos/robots.txt +0 -4
  109. viewspec-0.2.0/demos/serve.py +0 -13
  110. viewspec-0.2.0/demos/shared/landing-config.js +0 -62
  111. viewspec-0.2.0/demos/shared/landing-emitter.js +0 -110
  112. viewspec-0.2.0/demos/shared/landing-payload.js +0 -745
  113. viewspec-0.2.0/demos/shared/landing-playground.js +0 -737
  114. viewspec-0.2.0/demos/shared/nav.js +0 -64
  115. viewspec-0.2.0/demos/shared/pretext-canvas-surfaces.js +0 -208
  116. viewspec-0.2.0/demos/sitemap.xml +0 -45
  117. viewspec-0.2.0/demos/style-derivation/index.html +0 -580
  118. viewspec-0.2.0/demos/vendor/pretext/LICENSE +0 -2
  119. viewspec-0.2.0/demos/vendor/pretext/README.md +0 -8
  120. viewspec-0.2.0/demos/vendor/pretext/dist/analysis.mjs +0 -6
  121. viewspec-0.2.0/demos/vendor/pretext/dist/line-break.mjs +0 -3
  122. viewspec-0.2.0/demos/vendor/pretext/dist/line-text.mjs +0 -3
  123. viewspec-0.2.0/demos/vendor/pretext/dist/measurement.mjs +0 -3
  124. viewspec-0.2.0/demos/vendor/pretext/package.json +0 -14
  125. viewspec-0.2.0/demos/vendor/pretext/pretext.esm.js +0 -3
  126. viewspec-0.2.0/docs/agent-integration.md +0 -129
  127. viewspec-0.2.0/docs/free-sdk-reliability.md +0 -45
  128. viewspec-0.2.0/examples/comparison_view.py +0 -16
  129. viewspec-0.2.0/examples/emit_html.py +0 -29
  130. viewspec-0.2.0/examples/invoice_table.py +0 -21
  131. viewspec-0.2.0/examples/kpi_dashboard.py +0 -20
  132. viewspec-0.2.0/src/viewspec/__init__.py +0 -96
  133. viewspec-0.2.0/src/viewspec/agent.py +0 -851
  134. viewspec-0.2.0/src/viewspec/compiler.py +0 -1005
  135. viewspec-0.2.0/src/viewspec/emitters/__init__.py +0 -1
  136. viewspec-0.2.0/src/viewspec/emitters/base.py +0 -16
  137. viewspec-0.2.0/src/viewspec/emitters/html_tailwind/__init__.py +0 -190
  138. viewspec-0.2.0/tests/__init__.py +0 -1
  139. viewspec-0.2.0/tests/landing_config_smoke.mjs +0 -36
  140. viewspec-0.2.0/tests/landing_payload_smoke.mjs +0 -90
  141. viewspec-0.2.0/tests/seo_static_smoke.mjs +0 -75
  142. viewspec-0.2.0/tests/test_agent.py +0 -181
  143. viewspec-0.2.0/tests/test_compiler.py +0 -136
  144. viewspec-0.2.0/tests/test_emitter_contract.py +0 -73
  145. viewspec-0.2.0/tests/test_examples.py +0 -58
  146. viewspec-0.2.0/tests/test_reliability.py +0 -143
  147. viewspec-0.2.0/tests/test_remote_client.py +0 -96
  148. viewspec-0.2.0/tests/test_roundtrip.py +0 -111
  149. {viewspec-0.2.0 → viewspec-0.3.0b2}/src/viewspec/schema/__init__.py +0 -0
  150. {viewspec-0.2.0 → viewspec-0.3.0b2}/src/viewspec/schema/viewspec_pb2.py +0 -0
  151. {viewspec-0.2.0 → viewspec-0.3.0b2}/src/viewspec/sdk/__init__.py +0 -0
@@ -1,17 +1,19 @@
1
- __pycache__/
2
- *.pyc
3
- *.pyo
4
- *.egg-info/
5
- dist/
6
- !demos/vendor/pretext/dist/
7
- !demos/vendor/pretext/dist/*.mjs
8
- build/
9
- .eggs/
10
- *.egg
11
- .ruff_cache/
1
+ .claude/
2
+ __pycache__/
3
+ *.pyc
4
+ *.pyo
5
+ *.egg-info/
6
+ dist/
7
+ !demos/vendor/pretext/dist/
8
+ !demos/vendor/pretext/dist/*.mjs
9
+ build/
10
+ .eggs/
11
+ *.egg
12
+ .ruff_cache/
12
13
  .pytest_cache/
13
14
  .test-tmp*/
15
+ .tmp-*/
14
16
  output/
15
- viewspec_output/
16
- .venv/
17
- demos/server.*.log
17
+ viewspec_output/
18
+ .venv/
19
+ demos/server.*.log
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 nxrobins
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 nxrobins
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,311 @@
1
+ Metadata-Version: 2.4
2
+ Name: viewspec
3
+ Version: 0.3.0b2
4
+ Summary: Agent-native UI compiler. Agents describe intent; ViewSpec compiles concrete UI.
5
+ Project-URL: Homepage, https://github.com/nxrobins/viewspec
6
+ Project-URL: Repository, https://github.com/nxrobins/viewspec
7
+ Project-URL: Issues, https://github.com/nxrobins/viewspec/issues
8
+ Author: Nigel Robinson
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: agents,compiler,composition-ir,declarative,protobuf,semantic,ui,viewspec
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Software Development :: Code Generators
21
+ Classifier: Topic :: Software Development :: Compilers
22
+ Classifier: Topic :: Software Development :: User Interfaces
23
+ Requires-Python: >=3.11
24
+ Requires-Dist: protobuf>=5.0
25
+ Requires-Dist: pyyaml>=6.0
26
+ Provides-Extra: agents
27
+ Requires-Dist: mcp>=1.9.0; extra == 'agents'
28
+ Provides-Extra: dev
29
+ Requires-Dist: build>=1.2; extra == 'dev'
30
+ Requires-Dist: httpx>=0.27.0; extra == 'dev'
31
+ Requires-Dist: jsonschema>=4.18; extra == 'dev'
32
+ Requires-Dist: pytest>=8.0; extra == 'dev'
33
+ Requires-Dist: ruff>=0.4; extra == 'dev'
34
+ Provides-Extra: remote
35
+ Requires-Dist: httpx>=0.27.0; extra == 'remote'
36
+ Description-Content-Type: text/markdown
37
+
38
+ # ViewSpec
39
+
40
+ **Stop asking agents to write React, DOM, or State.**
41
+
42
+ ViewSpec is an agent-native UI compiler. It acts as a universal Intermediate Representation (IR) for AI Software Engineering. Agents describe UI and state intent as `IntentBundle` or `AppBundle` JSON; ViewSpec compiles that intent into deterministic HTML and React surfaces with the free local compiler, and SwiftUI or Flutter surfaces via the hosted compiler.
43
+
44
+ By totally decoupling intent from implementation, ViewSpec eliminates the "visual context window" problem. Agents no longer need to see pixels to build complex, perfectly styled, and deeply interactive applications.
45
+
46
+ 🌐 **[viewspec.dev](https://viewspec.dev)** — Compiled reference demos, pricing, and hosted compiler docs
47
+
48
+ ```bash
49
+ viewspec prove --out .viewspec-proof
50
+ viewspec init-intent --out viewspec.intent.json
51
+ viewspec init-design --out DESIGN.md
52
+ viewspec validate-intent viewspec.intent.json --json
53
+ viewspec diff-intent old.intent.json new.intent.json --json
54
+ viewspec init-app --out viewspec.app.json
55
+ viewspec validate-app viewspec.app.json --json
56
+ viewspec compile-app viewspec.app.json --out app-dist --target html-tailwind-app --json
57
+ viewspec prove-app --app viewspec.app.json --out .viewspec-app-proof --with-shell --json
58
+ viewspec compile viewspec.intent.json --design DESIGN.md --out dist/
59
+ viewspec check dist/
60
+ ```
61
+
62
+ ## What ViewSpec Does
63
+
64
+ The primary workflow is Intent-first compilation: semantic UI intent goes in, concrete renderer output plus a manifest comes out.
65
+
66
+ **Before ViewSpec:** Agents author DOM, CSS, and framework code directly. The model gets trapped in markup details instead of expressing structure, data, hierarchy, and interaction intent.
67
+
68
+ **After ViewSpec:** Agents author `IntentBundle` JSON. The compiler owns layout lowering, state generation, renderer output, design-token application, diagnostics, and provenance.
69
+
70
+ ```
71
+ IntentBundle JSON -> ViewSpec compiler -> HTML / React / SwiftUI / Flutter / CompositionIR
72
+ |-- validate agent contract
73
+ |-- apply DESIGN.md
74
+ |-- generate TypeScript Reducers (AppBundle V3)
75
+ |-- write provenance_manifest.json
76
+ `-- keep DOM and framework code as compiler output
77
+ ```
78
+
79
+ ## Three Invariants
80
+
81
+ ViewSpec enforces three deterministic invariants:
82
+
83
+ 1. **Exactly-once provenance.** Every valid data binding is routed exactly once. Conflicting or duplicate bindings are deterministically resolved (first occurrence wins) and flagged as a diagnostic — never silently dropped, duplicated, or hallucinated.
84
+ 2. **Semantic grouping.** Data is grouped by meaning, not by visual adjacency.
85
+ 3. **Strict ordering.** The original data order is preserved deterministically, including across serialization round-trips.
86
+
87
+ ## New: AppBundle V3 & State IR
88
+
89
+ ViewSpec is no longer just for static dashboards. With AppBundle V3, agents can declare fully interactive state mutations safely:
90
+
91
+ * **Declarative Mutation IR**: Agents define state transitions (`set`, `patch`, `toggle`, `append`, `move`, `increment`) in JSON.
92
+ * **Deterministic Reducer Generation**: The compiler automatically generates bulletproof TypeScript reducers (`reduceViewSpecState`).
93
+ * **State Replay Assertions**: Agents write expected state outputs; the compiler statically proves the generated logic against the Node.js runtime before the code even runs in a browser.
94
+
95
+ ## New: Custom Motif Plugins
96
+
97
+ Extend the local compiler securely with a microkernel architecture:
98
+
99
+ * **MotifPluginManifest**: Define strict input slots, ABI versions, and output guarantees for enterprise motifs (e.g., `financial_candlestick_chart`).
100
+ * **IR Portability**: Custom plugins lower directly into standard `CompositionIR`. You don't need to write custom HTML/React emitters for your new motifs!
101
+ * **Registry Support**: Pass a `motif_registry` to the `compile` pipeline for reusable, safe plugin execution.
102
+
103
+ ## Install
104
+
105
+ ```bash
106
+ pip install viewspec
107
+ ```
108
+
109
+ Requires Python 3.11+. AppBundle **V3** (`interactive_state`) reducer conformance additionally requires Node.js (>=18) on `PATH`; V1/V2 and all IntentBundle flows are Python-only and no-network.
110
+
111
+ Python package: <https://pypi.org/project/viewspec/>
112
+
113
+ Hosted compiler pricing starts with Free at 500 hosted compile calls/day. Pro is $149/month for 10,000 hosted compile calls/day and up to 5 custom motif instances per compile; Enterprise is custom volume and terms.
114
+
115
+ ## Runnable React App Golden Path
116
+
117
+ Generate a checked AppBundle V4 incident console, compile it into a complete Vite/React/Tailwind app, and run it:
118
+
119
+ ```bash
120
+ viewspec init-app --template react-app --out viewspec.app.json
121
+ viewspec compile-app viewspec.app.json --target react-tailwind-app --out app-dist
122
+ cd app-dist
123
+ npm ci
124
+ npm run dev
125
+ ```
126
+
127
+ The generated app wires browser-history routes, host-provided resources with fixture fallback, AppBundle mutations, selectors, and visibility into the checked React screen artifacts. `ViewSpecApp` exposes typed `resources`, `onNavigate`, `onAction`, `onStateChange`, and `onError` host boundaries.
128
+
129
+ Edit `viewspec.app.json`, then regenerate with `--force`; do not edit generated React. Run the exact-artifact build and Chromium proof with:
130
+
131
+ ```bash
132
+ viewspec prove-app --app viewspec.app.json --target react-tailwind-app --install
133
+ ```
134
+
135
+ This bounded target is a runnable frontend app and host bridge. Authentication, persistence, arbitrary API clients, optimistic updates, and production infrastructure remain host-owned.
136
+
137
+ ## IntentBundle-First Local Workflow
138
+
139
+ For a first proof, run:
140
+
141
+ ```bash
142
+ viewspec prove --out .viewspec-proof
143
+ ```
144
+
145
+ This generates a starter IntentBundle and DESIGN.md inside `.viewspec-proof/`, compiles through the public local path, runs artifact checks, records compact style-delta counts when profiles are present, and writes `.viewspec-proof/PROOF.md` for humans, `.viewspec-proof/proof_report.json` for tools, and `.viewspec-proof/support_bundle.json` for redacted local support triage. Read [ViewSpec Proof Bundle](docs/proof-bundle.md) when you need to interpret status, hashes, checks, failure codes, or local support triage. Machine reports include proof identity metadata under `proof_identity` for artifact, manifest, proof report, human summary, and support bundle hashes. It proves source artifact integrity and provenance for the generated artifact; ViewSpec prove is not pixel-perfect visual regression, accessibility certification, arbitrary host-app certification, or hosted compiler publish automation.
146
+
147
+ ### Core Commands
148
+
149
+ * `init-intent`: Writes a valid scaffold for all supported motifs.
150
+ * `init-design`: Scaffolds a local `DESIGN.md` for theming.
151
+ * `validate-intent`: Rejects malformed JSON and enforces the bounded local agent contract.
152
+ * `diff-intent`: Provides a semantic diff between intent states, including aesthetic profile changes, before generated HTML review; Python callers can format semantic changes with `intent_semantic_change_lines`.
153
+ * `compile`: Compiles the intent into HTML/React based on the target.
154
+ * `check`: Verifies the provenance manifest against the generated DOM.
155
+ * `doctor`: Reports the intent-first command surface and local agent prompt status.
156
+
157
+ **The Bounded Local Agent Contract**: The local schema enforces strict bounds to prevent agent hallucinations and infinite loops (e.g., max 256KB JSON, 32 regions, 400 bindings, 64 actions). Split larger products into smaller IntentBundles.
158
+
159
+ Generated outputs are artifacts, not source: standalone HTML writes `dist/index.html`, while React source targets write `react-output/ViewSpecView.tsx` plus checked `provenance_manifest.json` and `diagnostics.json`. Agents should edit `viewspec.intent.json` or `DESIGN.md`, then regenerate artifacts instead of patching generated files.
160
+
161
+ ## AppBundle: Narrow App Generation
162
+
163
+ For multi-screen internal tool contracts, use AppBundle JSON:
164
+
165
+ ```bash
166
+ viewspec init-app --out viewspec.app.json
167
+ viewspec init-app --resource-binding fixture-readonly-v0 --out viewspec.bound.app.json
168
+ viewspec validate-app viewspec.app.json --json
169
+ viewspec diff-app old.app.json new.app.json --json
170
+ viewspec compile-app viewspec.app.json --out app-dist --target html-tailwind-app --json
171
+ viewspec prove-app --app viewspec.app.json --out .viewspec-app-proof --with-shell --json
172
+ ```
173
+
174
+ * **V1**: Unbound fixtures reported as `unbound_v0`.
175
+ * **V2**: Strict readonly fixture resources reported as `fixture_readonly_v0` with declared per-screen views.
176
+ * **V3**: Adds bounded interactive state, declarative mutations, and a generated pure TypeScript reducer artifact.
177
+
178
+ `compile-app` defaults to a single `app-dist/index.html` Static Shell V0 proof artifact; that default is not browser navigation proof. Use `--target react-tailwind-app` for a runnable Vite/React/Tailwind app with browser-history routing, live resource/state rebinding, and exact-artifact host verification. Neither target generates authentication, persistence, arbitrary API clients, or backend infrastructure.
179
+
180
+ Aesthetic Profiles V1 are deterministic art-direction handles, not CSS: `aesthetic.calm_ops`, `aesthetic.premium_saas`, `aesthetic.data_dense`, `aesthetic.editorial_product`, `aesthetic.executive_review`, `aesthetic.brutalist`, `aesthetic.neon_cyber`, and `aesthetic.warm_organic`. Checked summaries expose compact style-delta counts and bounded layout deltas for profiled artifacts, not arbitrary CSS control, pixel-perfect visual proof, or design certification.
181
+
182
+ ## Import Existing HTML
183
+
184
+ The raw HTML path is an import/fallback tool for existing HTML. It sanitizes active content, applies local `DESIGN.md` tokens, writes deterministic provenance, and can report semantic diffs.
185
+
186
+ ```bash
187
+ viewspec compile input.html --design DESIGN.md --out dist/
188
+ viewspec lift input.html --out lift.json
189
+ viewspec diff old.html new.html --json
190
+ ```
191
+
192
+ ## Native Agent Use
193
+
194
+ Install managed instructions so coding agents natively understand how to use ViewSpec:
195
+
196
+ ```bash
197
+ viewspec init-agent --target codex
198
+ viewspec init-agent --target claude-code
199
+ viewspec init-agent --target cursor
200
+ viewspec init-agent --target copilot
201
+ ```
202
+
203
+ Use `--target all` to write every supported instruction file.
204
+
205
+ For schema-aware editors or agents, export the local contract assets:
206
+
207
+ ```bash
208
+ viewspec export-agent-assets --out .viewspec
209
+ viewspec check-agent-assets .viewspec --json
210
+ ```
211
+
212
+ Agent assets use schema version `11`, contract profile `local_v1`, and the same export/check commands shown above; exported files include the local intent schema, AppBundle schema, starter examples, prompt, and asset manifest without SDK network calls.
213
+
214
+ Optional **MCP tooling** is available behind the agent extra:
215
+
216
+ ```bash
217
+ python -m pip install "viewspec[agents]"
218
+ viewspec mcp
219
+ ```
220
+ The MCP server exposes all intent-first local tools without requiring shell commands, including `validate_intent_bundle_file`, `compile_intent_bundle_file`, `verify_host`, `prove`, `validate_app_file`, `diff_app_files`, `compile_app`, and `prove_app`.
221
+
222
+ For bounded React Tailwind runtime proof, run `viewspec prove --target react-tailwind-tsx --install --out .viewspec-proof --json` or `viewspec verify-host react-tailwind-output/ --target react-tailwind-tsx --install --json`. The host proof checks grid column/span counts, profiled aesthetic marker/layout assertions, and action payload behavior; JSON reports include `assertion_requirements` with `dom_count`, `style_assertion_count`, `aesthetic_layout_assertion_count`, `aesthetic_profile_assertion_count`, and `grid_span_assertion_count`.
223
+
224
+ ## viewspec.dev
225
+
226
+ The home page at [viewspec.dev](https://viewspec.dev) shows compiled reference artifacts across the aesthetic profiles, with inspectable IntentBundle, provenance manifest, and generated artifact source for each.
227
+
228
+ Agent and crawler entrypoints are published:
229
+ - `https://viewspec.dev/llms.txt` — concise LLM-facing product map
230
+ - `https://viewspec.dev/llms-full.txt` — expanded AI context and canonical facts
231
+ - `https://viewspec.dev/agent-assets.json` — versioned manifest with contract identity
232
+ - `https://viewspec.dev/openapi.json` — hosted compiler OpenAPI description
233
+
234
+ ## Demos
235
+
236
+ Reference demos are available at [viewspec.dev](https://viewspec.dev):
237
+
238
+ | Demo | What it shows |
239
+ |------|--------------|
240
+ | [Same Data, Three Motifs](https://viewspec.dev/motif-switcher/) | One dataset → table, dashboard, or comparison. |
241
+ | [Provenance Inspector](https://viewspec.dev/provenance-inspector/) | Hover any element. Trace DOM → IR → binding → address → raw data. |
242
+ | [The Invariants](https://viewspec.dev/invariants/) | Watch the compiler enforce each deterministic invariant. |
243
+ | [15 Lines → Full UI](https://viewspec.dev/fifteen-lines/) | An invoice table builds itself from 15 lines of Python. |
244
+ | [Style Derivation](https://viewspec.dev/style-derivation/) | Toggle five visual presets deterministically. |
245
+ | [One Spec, Four Surfaces](https://viewspec.dev/cross-platform-dashboard/) | One intent compiles to HTML, React, SwiftUI, and Flutter. |
246
+ | [Custom Motif Authoring](https://viewspec.dev/custom-motifs/) | Define an MDL motif contract and lower it into portable IR. |
247
+ | [Interactive Compose](https://viewspec.dev/interactive-compose/) | State IR compiled into event surfaces. |
248
+
249
+ ## Core Concepts
250
+
251
+ ### Semantic Substrate
252
+ The raw data graph. Nodes with typed attributes, slots, and edges. This is WHAT the data is — no visual intent.
253
+
254
+ ### ViewSpec
255
+ The declarative intent layer. Regions (WHERE), bindings (WHICH data goes WHERE), motifs (HOW it should be structured), and styles (how it should FEEL).
256
+
257
+ ### CompositionIR
258
+ The compiler's output. A strict hierarchical tree of UI primitives with full provenance tracking.
259
+
260
+ ### Emitters
261
+ Pluggable renderers that turn CompositionIR into concrete output. The local SDK ships `HtmlTailwindEmitter`, `ReactTsxEmitter`, and `ReactTailwindTsxEmitter`. Because custom local plugins lower into portable `CompositionIR`, emitters **do not** need custom code paths to support new motifs.
262
+
263
+ ## Motif Types
264
+
265
+ | Builder | Motif | Use case |
266
+ |---------|-------|----------|
267
+ | `add_table()` | `table` | Tabular data with label-value rows |
268
+ | `add_dashboard()` | `dashboard` | KPI cards with label-value pairs |
269
+ | `add_outline()` | `outline` | Hierarchical outlines and trees |
270
+ | `add_comparison()` | `comparison` | Side-by-side comparisons |
271
+ | `add_list()` | `list` | Ordered narrative or task lists |
272
+ | `add_form()` | `form` | Inert local form intent with text fields and action payloads |
273
+ | `add_detail()` | `detail` | Read-only record/profile/settings detail fields |
274
+ | `add_empty_state()` | `empty_state` | Absence, no-results, or first-run states |
275
+ | `add_loading_state()` | `loading_state` | Current loading state for a collection or region |
276
+ | `add_error_state()` | `error_state` | Current error state for a collection or region |
277
+ | `add_hero()` | `hero` | Intro/header sections with eyebrow, title, and description |
278
+ | `add_collection_action()` | action helper | `search`, `filter`, `sort`, `paginate`, or `bulk_action` events for a table/list |
279
+
280
+ ## Compilation
281
+
282
+ ### Reference Compiler (free, offline)
283
+ Handles the local V1 motifs and bounded collection action events locally. No API, no network, no LLM. Deterministic.
284
+
285
+ ```python
286
+ ast = compile(builder.build_bundle())
287
+ ```
288
+
289
+ ### Hosted Compiler (api.viewspec.dev)
290
+ For complex layouts, novel data shapes, advanced derivation, and the SwiftUI/Flutter emitters, which are hosted-only and not shipped in the local SDK.
291
+
292
+ * **Zero LLM calls at runtime** — deterministic layout resolution, same no-LLM contract as the local compiler.
293
+ * **Derivation tokens** — data-aware emphasis, narrative routing, palette energy.
294
+
295
+ ```python
296
+ from viewspec import compile_auto
297
+ # Try local first, fall back to hosted for unsupported motifs
298
+ ast = compile_auto(builder.build_bundle())
299
+ ```
300
+
301
+ The hosted fallback requires the `remote` extra: `python -m pip install "viewspec[remote]"` (adds `httpx`). Without it, `compile_auto` runs locally and raises `ImportError` only if a hosted fallback is actually needed.
302
+
303
+ ### Theming with DESIGN.md
304
+ The local SDK uses a strict YAML-front-matter `DESIGN.md` for offline HTML and IntentBundle compilation. The API requires exact sRGB hex values (e.g., `#FFFFFF`), enforcing strict design token discipline.
305
+
306
+ ## Compatibility & Versioning
307
+
308
+ The local contract is anchored by the `local_v1` profile: document schemas (IntentBundle V1, AppBundle V1-V4), the closed error-code registry (`viewspec.ERROR_CODES`), the CLI surface, every name in `viewspec.__all__`, and per-version determinism. Within a major version those surfaces evolve additively only — caps only rise, codes are never repurposed, commands are never removed — and anything breaking waits for a new major version with a new contract profile and migration notes. Cross-version artifact bytes and hashes are explicitly *not* promised; determinism is a within-version guarantee. The full policy, including what is deliberately out of scope, is in [docs/compatibility.md](docs/compatibility.md); changes ship documented in [CHANGELOG.md](CHANGELOG.md).
309
+
310
+ ## License
311
+ MIT