basis-design 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/LICENSE +177 -0
  2. package/NOTICE +7 -0
  3. package/README.md +135 -3
  4. package/bin/basis.js +6 -0
  5. package/index.html +16 -0
  6. package/package.json +66 -4
  7. package/preview.html +12 -0
  8. package/server/agent.ts +845 -0
  9. package/server/brief.ts +355 -0
  10. package/server/chatlog.ts +57 -0
  11. package/server/exec.ts +77 -0
  12. package/server/export.ts +180 -0
  13. package/server/guidelines.md +379 -0
  14. package/server/history.ts +107 -0
  15. package/server/index.ts +414 -0
  16. package/server/paths.ts +57 -0
  17. package/server/previews.ts +71 -0
  18. package/server/project.ts +151 -0
  19. package/server/projects.ts +213 -0
  20. package/server/reach.ts +192 -0
  21. package/server/rebase.ts +46 -0
  22. package/server/reviews.ts +156 -0
  23. package/server/setup.ts +219 -0
  24. package/server/snapshots.ts +67 -0
  25. package/server/workspace.ts +423 -0
  26. package/shared/annotations.ts +43 -0
  27. package/shared/contracts.ts +190 -0
  28. package/shared/contrast.ts +77 -0
  29. package/shared/design.ts +556 -0
  30. package/shared/diff.ts +26 -0
  31. package/shared/fixed-colors.ts +91 -0
  32. package/shared/frame.ts +223 -0
  33. package/shared/pattern-contracts.ts +229 -0
  34. package/shared/protocol.ts +226 -0
  35. package/shared/review.ts +145 -0
  36. package/shared/tokens.ts +102 -0
  37. package/src/App.tsx +22 -0
  38. package/src/Workbench.tsx +341 -0
  39. package/src/app.css +103 -0
  40. package/src/bridge.ts +163 -0
  41. package/src/chat/ChatPanel.module.css +759 -0
  42. package/src/chat/ChatPanel.tsx +326 -0
  43. package/src/chat/Composer.tsx +290 -0
  44. package/src/chat/Markdown.tsx +67 -0
  45. package/src/chat/images.ts +46 -0
  46. package/src/icon.svg +1 -0
  47. package/src/main.tsx +10 -0
  48. package/src/preview/Foundations.module.css +346 -0
  49. package/src/preview/Foundations.tsx +389 -0
  50. package/src/preview/FrameBar.tsx +74 -0
  51. package/src/preview/Gallery.module.css +232 -0
  52. package/src/preview/Gallery.tsx +163 -0
  53. package/src/preview/Impact.tsx +217 -0
  54. package/src/preview/Preview.module.css +103 -0
  55. package/src/preview/Preview.tsx +167 -0
  56. package/src/preview/Review.module.css +192 -0
  57. package/src/preview/Review.tsx +456 -0
  58. package/src/preview/SectionBoundary.tsx +70 -0
  59. package/src/preview/a11y.ts +123 -0
  60. package/src/preview/color.ts +53 -0
  61. package/src/preview/ds-module.d.ts +2 -0
  62. package/src/preview/ds.ts +33 -0
  63. package/src/preview/errors.ts +83 -0
  64. package/src/preview/main.tsx +283 -0
  65. package/src/preview/narrow.ts +95 -0
  66. package/src/preview/picker/PickLayer.module.css +90 -0
  67. package/src/preview/picker/PickLayer.tsx +151 -0
  68. package/src/preview/picker/annotate.ts +93 -0
  69. package/src/preview/preview.css +102 -0
  70. package/src/preview/progressive.ts +62 -0
  71. package/src/preview/specimens.tsx +379 -0
  72. package/src/shell/ChatResizer.tsx +69 -0
  73. package/src/shell/CreateDialog.tsx +132 -0
  74. package/src/shell/ExportDialog.tsx +232 -0
  75. package/src/shell/HistoryMenu.tsx +95 -0
  76. package/src/shell/InspectBanner.tsx +147 -0
  77. package/src/shell/PreviewFrame.tsx +101 -0
  78. package/src/shell/ProjectMenu.tsx +364 -0
  79. package/src/shell/ReviewBar.tsx +224 -0
  80. package/src/shell/Shell.module.css +1067 -0
  81. package/src/shell/Sidebar.module.css +211 -0
  82. package/src/shell/Sidebar.tsx +80 -0
  83. package/src/shell/TopBar.tsx +83 -0
  84. package/src/shell/history.ts +64 -0
  85. package/src/shell/navigation.tsx +150 -0
  86. package/src/shell/prefs.ts +81 -0
  87. package/src/shell/useReview.ts +114 -0
  88. package/template/LICENSE +16 -0
  89. package/template/components/Button.module.css +151 -0
  90. package/template/components/Button.specimen.tsx +74 -0
  91. package/template/components/Button.tsx +41 -0
  92. package/template/components/Controls.module.css +174 -0
  93. package/template/components/Controls.specimen.tsx +54 -0
  94. package/template/components/Controls.tsx +58 -0
  95. package/template/components/Display.module.css +251 -0
  96. package/template/components/Display.specimen.tsx +261 -0
  97. package/template/components/Display.tsx +126 -0
  98. package/template/components/Field.module.css +109 -0
  99. package/template/components/Field.specimen.tsx +138 -0
  100. package/template/components/Field.tsx +94 -0
  101. package/template/components/Overlay.module.css +237 -0
  102. package/template/components/Overlay.specimen.tsx +60 -0
  103. package/template/components/Overlay.tsx +69 -0
  104. package/template/components/Tabs.module.css +140 -0
  105. package/template/components/Tabs.specimen.tsx +51 -0
  106. package/template/components/Tabs.tsx +117 -0
  107. package/template/components/contracts.ts +24 -0
  108. package/template/components/index.ts +7 -0
  109. package/template/components/specimen.ts +88 -0
  110. package/template/components/util.ts +6 -0
  111. package/template/contract-check.ts +22 -0
  112. package/template/patterns/AppShell.module.css +36 -0
  113. package/template/patterns/AppShell.specimen.tsx +114 -0
  114. package/template/patterns/AppShell.tsx +25 -0
  115. package/template/patterns/Chat.module.css +437 -0
  116. package/template/patterns/Chat.specimen.tsx +298 -0
  117. package/template/patterns/Chat.tsx +236 -0
  118. package/template/patterns/Composer.module.css +184 -0
  119. package/template/patterns/Composer.specimen.tsx +106 -0
  120. package/template/patterns/Composer.tsx +183 -0
  121. package/template/patterns/DataTable.module.css +190 -0
  122. package/template/patterns/DataTable.specimen.tsx +189 -0
  123. package/template/patterns/DataTable.tsx +241 -0
  124. package/template/patterns/EmptyState.module.css +57 -0
  125. package/template/patterns/EmptyState.specimen.tsx +71 -0
  126. package/template/patterns/EmptyState.tsx +36 -0
  127. package/template/patterns/FormSection.module.css +69 -0
  128. package/template/patterns/FormSection.specimen.tsx +75 -0
  129. package/template/patterns/FormSection.tsx +40 -0
  130. package/template/patterns/Navbar.module.css +265 -0
  131. package/template/patterns/Navbar.specimen.tsx +118 -0
  132. package/template/patterns/Navbar.tsx +124 -0
  133. package/template/patterns/PageHeader.module.css +98 -0
  134. package/template/patterns/PageHeader.specimen.tsx +75 -0
  135. package/template/patterns/PageHeader.tsx +63 -0
  136. package/template/patterns/SidebarNav.module.css +186 -0
  137. package/template/patterns/SidebarNav.specimen.tsx +98 -0
  138. package/template/patterns/SidebarNav.tsx +81 -0
  139. package/template/patterns/StatCard.module.css +81 -0
  140. package/template/patterns/StatCard.specimen.tsx +61 -0
  141. package/template/patterns/StatCard.tsx +83 -0
  142. package/template/patterns/contracts.ts +25 -0
  143. package/template/patterns/icons.tsx +68 -0
  144. package/template/patterns/index.ts +12 -0
  145. package/template/patterns/specimen-data.ts +112 -0
  146. package/template/views/TeamMembers.specimen.tsx +147 -0
  147. package/vite.config.ts +9 -0
package/LICENSE ADDED
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
package/NOTICE ADDED
@@ -0,0 +1,7 @@
1
+ Basis
2
+ Copyright 2026 Lucas Skog
3
+
4
+ Licensed under the Apache License, Version 2.0 (see LICENSE). The starter
5
+ components, patterns and views in template/ are licensed under MIT-0 (see
6
+ template/LICENSE), so the design systems made from them belong to whoever
7
+ makes them, without conditions.
package/README.md CHANGED
@@ -1,3 +1,135 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ <img src="src/icon.svg" width="72" height="72" alt="">
2
+
3
+ # Basis
4
+
5
+ Prompt a complete design system into existence, then refine it down to the last transition.
6
+
7
+ Basis is a local web app with two halves. On the left you talk to a coding agent, either Claude Code or Codex. On the right is a live specimen of your design system: colour roles with contrast checks, type, spacing, shape, motion, and every component in every state (default, hover, pressed, focus, disabled, loading, invalid, checked, indeterminate…). Start broad ("warm editorial, serif headings") and go as deep as you like ("softer button press", "make the tab indicator slide").
8
+
9
+ The agent owns both the tokens and the component source, so the result is a real starting point for a project rather than a theme.
10
+
11
+ The agent runs over the [Agent Client Protocol](https://agentclientprotocol.com) on your machine, using the CLI login you already have. You need no API keys, and usage runs on your own Claude or ChatGPT subscription.
12
+
13
+ ## Run it
14
+
15
+ ```bash
16
+ npx basis-design
17
+ ```
18
+
19
+ Or install it once with `npm install -g basis-design` and start it with `basis`. Open http://localhost:5320. Basis starts Claude Code by default (shown as Claude in the picker above the chat); switch to Codex there. Basis needs Node.js 22.12 or later and `git` on the PATH.
20
+
21
+ - **Claude Code:** log in once with `claude` in a terminal. Basis starts it through `@agentclientprotocol/claude-agent-acp`.
22
+ - **Codex:** log in once with `codex login`. Basis starts it through `npx @agentclientprotocol/codex-acp`, at a fixed version that npx fetches on first use.
23
+
24
+ Usage counts against your own plan. A turn can take up to three agent runs (the turn and up to two fix-ups), and ×2 or ×3 alternatives multiply that.
25
+
26
+ The first install is large, about 300 MB, because the Claude adapter brings its own copy of Claude Code. To work on Basis itself, clone the repository and run `npm install` and `npm run dev`.
27
+
28
+ | Variable | Default | Purpose |
29
+ | --- | --- | --- |
30
+ | `BASIS_HOME` | `~/.basis` | Where the project list (`basis.projects.json`) and new projects (`workspaces/`) live |
31
+ | `BASIS_WORKSPACE` | | Opens just this workspace for one run, without touching the project list (for tests and one-off use) |
32
+ | `BASIS_AGENT` | `claude` | Agent started on boot (`claude` or `codex`) |
33
+ | `PORT` | `5320` | Port of the Basis app (bound to 127.0.0.1 only) |
34
+ | `BASIS_PREVIEW_PORT` | `PORT + 1` | Port of the sandboxed preview origin |
35
+
36
+ ## Projects
37
+
38
+ Each project is a workspace of its own: its own design system, history, chat and review. Switch, create and open projects from the menu with the project's name at the top left.
39
+
40
+ A project can link the **product repo** it designs for (project menu, **Link product repo…**). The agent reads and searches it without asking, to match the product's look, components and terms, and never writes there: writes outside the workspace are refused. **New project…** can also start from a product repo: the project takes the repo folder's name unless you give one, links the repo and starts by bringing in its design. **Bring in its design** (offered when you link, and in the project menu) starts a guided turn: the agent maps the repo's tokens onto `design-system.json`, restyles the components and patterns to resemble the product's, writes what it learned to `product.md` (where the tokens live, an inventory of the product's components and their Basis counterparts, terms to reuse) and opens a review.
41
+
42
+ - **New project** starts from Basis' defaults, or as a copy of the open project's tokens and components (not its history). It lives in `~/.basis/workspaces/`.
43
+ - **Open folder** adds a workspace from anywhere, or an empty or new folder for Basis to set up, inside a product repo for instance. Basis refuses a folder that already has other files, so it never starts a history in someone's project.
44
+ - Switching waits while the agent works. The agent of the project you leave stops, and coming back resumes its conversation, so it remembers where you were. The export remembers its target folder per project.
45
+ - Removing a project from the list never deletes its folder. Earlier versions kept the project list in the Basis folder; it moves to `~/.basis` on first start, and its projects stay where they are. The `./workspace` of versions before projects becomes the first project.
46
+
47
+ ## The workspace
48
+
49
+ ```
50
+ workspace/
51
+ design-system.json tokens, validated against shared/design.ts
52
+ components/ React + CSS Modules source of every component (seeded from template/)
53
+ *.specimen.tsx how the gallery shows each component: one section per specimen
54
+ contracts.ts the API of every component added beyond the Basis baseline
55
+ patterns/ larger building blocks composed from components/ (seeded from template/)
56
+ review.json written by the agent to open or update a review (not in history)
57
+ product.md what the agent learned about a linked product repo
58
+ .git/ history: one commit per agent turn, approved review, restore or hand edit
59
+ AGENTS.md, CLAUDE.md the agent's instructions (generated)
60
+ tsconfig.json, .basis/ type-check setup and contracts (generated), the open review, its snapshot, the chat
61
+ ```
62
+
63
+ The agent may edit `design-system.json`, `review.json` and anything under `components/` and `patterns/`, and nothing else. Components style themselves with the token CSS variables, so tokens stay the single source of truth for look and feel. Component code covers structure and behaviour. A component the agent adds gets a token group of its own under `components` in `design-system.json` (`components.starRating.iconSize` becomes `--star-rating-icon-size`), so it is tuned, reviewed and exported like the baseline ones.
64
+
65
+ Every `components/*.specimen.tsx` file becomes a gallery section and a sidebar entry. A specimen lists blocks: a `matrix` of variants × states, a `grid` of labelled examples, a pattern's data `states` (populated, empty, loading, error, long content), or free `row` and `block` content for live demos (the format is in `components/specimen.ts`). The agent writes specimens alongside components, so a new component or variant shows up in the gallery as soon as it exists. Basis owns only the foundation sections: colour, type, shape and motion.
66
+
67
+ `patterns/` holds composed components such as Navbar, SidebarNav, PageHeader, DataTable with Pagination, StatCard, FormSection, EmptyState, AppShell, and for AI products a Composer and a chat (ChatThread, ChatMessage, ChatWelcome). They import only from `../components`, have their own specimens, and appear on the gallery's **Patterns** page, which you switch to in the top bar. The agent edits and extends them like everything else, so a token or base-component change flows through to every pattern. **Show at** above the specimens renders every block at mobile, tablet or desktop width and in both themes at once. Each copy is a size container, so patterns respond with `@container` rules to the width they are shown at.
68
+
69
+ `shared/contracts.ts` (copied to `.basis/contracts.ts`) is the baseline API every design system keeps. A component can change completely and gain props or variants, but it must keep its export and accept the contract's props. Components the design system adds get their contract in `components/contracts.ts`, which the agent writes when it creates them; every export of `components/index.ts` needs a contract in one of the two files. Patterns work the same way: `shared/pattern-contracts.ts` (copied to `.basis/pattern-contracts.ts`) is the baseline for the starter patterns, and `patterns/contracts.ts` holds the contracts of patterns the design system adds.
70
+
71
+ `views/` holds **views**: whole screens of a product's flows, built only from the components and patterns, on the gallery's **Views** page. A view is a specimen with a `flow` block: its screens show one at a time with a strip to jump between them, and buttons in a screen move through the flow (a row opens its detail, Save goes back). Views fill with realistic made-up data, and they are left out of the export: they prototype a product, they are not part of the design system. **New view** at the bottom of the Views sidebar takes a name and the feature, or a whole ticket, and starts a guided turn: the agent works out the screens, builds the flow from your patterns (adding a pattern when one is missing), and opens it in a review. A review of a view can show just some of its screens, and its panes move through the flow together, so before and after, blink and alternatives always compare the same screen.
72
+
73
+ **New component** and **New pattern** at the bottom of the sidebar ask for a name and what it is for, then start a guided agent turn: it checks for an existing component with the same job, creates the source, contract (for base components), export and specimen, and the result appears in the gallery. You can ask for the same thing in the chat.
74
+
75
+ ## How it works
76
+
77
+ - **Live preview:** the gallery runs on its own origin (`BASIS_PREVIEW_PORT`) in a sandboxed iframe, because it executes code the agent writes. That code cannot reach the bridge to the agent or the Basis UI. Vite compiles `components/` on the fly, so saved edits hot-reload in place, and token changes arrive over `postMessage`.
78
+ - **Problems loop:** after every turn Basis validates the tokens, type-checks `components/` and `patterns/`, checks the components against their contracts, and collects render errors and malformed specimens from the preview. A broken section shows its error instead of taking down the gallery. Anything wrong is sent back to the agent automatically, at most twice per turn, and is listed above the composer.
79
+ - **Accessibility checks** run alongside: the colour roles are checked for WCAG 2 AA contrast in both themes, and axe-core checks the live demos (gallery sections and the review's live side) for serious and critical WCAG A and AA violations once the preview settles. Findings are listed apart above the composer, with a button to ask the agent to fix them. The agent hears only about findings its own change introduced, so an existing one does not send it off on every turn, and a colour you asked for on purpose is kept.
80
+ - **History:** the workspace is a git repository. Each agent turn becomes one commit, labelled with its prompt and with the tokens and files it changed. Click an entry to inspect it. The preview shows that version's tokens, and a banner lists the token and component-code differences from now. You can step through versions or restore one; restoring brings back tokens and code alike. Undo walks back through the steps instead of toggling between two of them.
81
+ - **Reviews:** ask for something specific ("make the danger button feel more urgent") and the agent opens a review once it has a first version, by writing `review.json`. The preview then shows just that, narrowed to a block and its rows or columns, as it was when the review started next to how it is now. You keep iterating in the chat until you **Approve** (everything becomes one history entry) or **Discard** (everything goes back).
82
+ - While a review is open, every agent turn and hand edit becomes an iteration of it, not a history entry. Iterations live on a git ref outside the history, so you can go back to an earlier one, and the review survives a restart. Undo and History wait until the review ends.
83
+ - The "before" side runs the starting point's own component code with its own tokens, from a read-only copy in `.basis/snapshots/`. If the agent adds a block to show a new state, the before side runs today's demo on the starting point's components, so it still compares old with new.
84
+ - **Also changed** lists other sections that now look different, found by rendering them before and after offscreen and comparing structure and computed styles. Only sections the change can reach are checked: those whose specimen, through its imports, uses a changed file or a CSS variable whose value changed. Tokens are global, so this is where you see what else a change reached; click one to add it to the review.
85
+ - A review shows its targets **side by side**, **stacked**, or with **blink**, which shows one version at a time in the same place so subtle differences stand out: click a pane or tap B to switch, hold B to see before, or let it switch by itself. A target can ask for widths, like Show at; it shows one theme at a time, and you switch with Light and Dark in the top bar.
86
+ - **Alternatives:** pick ×2 or ×3 next to Send, and the agent makes that many takes on the request, one after another from the same starting point. The review shows where they started next to each one, and **Continue with** in the review bar picks the one to keep iterating on. Each take is an iteration, so the others stay reachable.
87
+ - Approve waits while the agent works, while there are problems, or until an alternative is chosen. Errors on the before side are shown in place and never sent to the agent, and Pick only attaches components from the live side.
88
+ - **Composer:**
89
+ - The conversation survives a restart, and Claude Code picks up the same session, so it remembers what was said.
90
+ - Messages sent while the agent works are queued and run, in order, when it is done; remove one with its ×. Stop drops the queue too, and ends a set of alternatives after the take being made.
91
+ - Up and Down recall earlier messages, and an unsent message survives a reload.
92
+ - Paste, drop or attach images. They are sent as ACP image blocks when the agent supports them.
93
+ - Press **Pick** and click components in the preview. Each pick is attached as a numbered annotation carrying its variant, state, theme, driving tokens and computed styles, so "make [1] softer" is unambiguous. Pick mode stays on until Done or Esc, and you can click a component again to remove it.
94
+ - **Layout:**
95
+ - The sidebar scrolls the preview to each section and can collapse to an icon rail.
96
+ - The chat can be resized by dragging its edge (double-click resets) and hidden with the toggle in the top bar or Ctrl+B.
97
+ - **Permissions:** reads inside the workspace and edits to the files the agent may change are approved automatically. Anything else, such as shell commands, web fetches or other files, shows up in the chat for you to approve. Paths are compared after following links, so a link inside the workspace that leads out of it is not approved.
98
+ - The agent always starts in the mode that asks: Claude Code in its default mode and Codex in read-only mode, whatever your own settings default to. Codex still runs read-only commands in its sandbox without asking.
99
+ - Claude Code runs without your own `~/.claude` setup (CLAUDE.md, skills, hooks, permission rules, claude.ai connectors and auto memory), so rules meant for your coding neither steer the design agent nor approve anything for it. Basis' instructions arrive as its system prompt.
100
+ - A linked product repo is read without asking, so text in it can steer the agent like any prompt. Approve shell commands with that in mind.
101
+ - **Export:** the **Starter kit** tab packages the whole design system for a new project. You can download it as a zip or write it straight into a project folder; if any file there would change, nothing is written until you confirm. The kit contains:
102
+ - `components/`, with imports rewritten to extensionless form so any bundler and default `tsconfig` accept them,
103
+ - `tokens.css`, CSS custom properties with dark mode via `data-theme` or the OS setting,
104
+ - `theme.tailwind.css`, a Tailwind v4 entry stylesheet,
105
+ - `design-system.json`,
106
+ - a README on wiring it up.
107
+
108
+ The kit needs React 18+ and CSS Modules, nothing else. The other tabs export the token formats one at a time.
109
+
110
+ ## Privacy
111
+
112
+ Basis runs on your machine and answers only on localhost. It sends no telemetry. What leaves your machine is what the agent sends to Anthropic or OpenAI under your own account (your prompts, attachments, and the files it reads, including a linked product repo), web fonts that your design system imports from Google Fonts or Bunny Fonts, and the Codex adapter that npx downloads on first use.
113
+
114
+ ## Troubleshooting
115
+
116
+ - **"Basis needs git on the PATH":** install git, then start Basis again.
117
+ - **"Port 5320 is in use":** another Basis is probably running. Stop it, or start this one with another `PORT`. The preview takes `PORT + 1`.
118
+ - **The agent asks you to log in:** run `claude` (or `codex login`) in a terminal, then pick the agent again in the picker.
119
+ - **"Usage limit":** your plan's limit is reached. It resets after a while, and the conversation is kept until then.
120
+ - **"Another Claude Code process is refreshing it":** several Claude Code processes refreshed their login at once. Send the message again.
121
+ - **"A newer version of Basis has opened this project":** update Basis. An older Basis refuses such a project rather than misreading it.
122
+
123
+ ## Stack
124
+
125
+ React 19 + Vite with CSS Modules and plain CSS custom properties. The server is plain Node (`server/`). It acts as an ACP client via `@agentclientprotocol/sdk` and runs two Vite instances in middleware mode, one for the app and one for the sandboxed preview. Basis always runs through Vite, because the preview compiles workspace code live.
126
+
127
+ ```bash
128
+ npm run check
129
+ ```
130
+
131
+ `npm run check` runs the type check, oxlint, Prettier and the tests. [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md) covers the architecture, how to work on Basis, the gotchas and where the work stands.
132
+
133
+ ## License
134
+
135
+ Basis is licensed under the [Apache License 2.0](LICENSE). The starter components, patterns and views in `template/` are licensed under [MIT-0](template/LICENSE): what you build from them and export is yours, with no attribution required.
package/bin/basis.js ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ // Starts Basis. The server is TypeScript run as it is (Vite compiles workspace code live anyway), so tsx loads it.
3
+ import { register } from "tsx/esm/api";
4
+
5
+ register();
6
+ await import("../server/index.ts");
package/index.html ADDED
@@ -0,0 +1,16 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Basis</title>
7
+ <link
8
+ rel="icon"
9
+ href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='14' fill='%23121210'/%3E%3Crect x='12' y='12' width='18' height='18' rx='4' fill='%23c8f25a'/%3E%3Crect x='34' y='12' width='18' height='18' rx='9' fill='%23c8f25a'/%3E%3Crect x='12' y='35' width='40' height='17' rx='4' fill='%23c8f25a'/%3E%3C/svg%3E"
10
+ />
11
+ </head>
12
+ <body>
13
+ <div id="root"></div>
14
+ <script type="module" src="/src/main.tsx"></script>
15
+ </body>
16
+ </html>
package/package.json CHANGED
@@ -1,6 +1,68 @@
1
1
  {
2
2
  "name": "basis-design",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Prompt a complete design system into existence with your own coding agent over ACP.",
5
+ "keywords": [
6
+ "design-system",
7
+ "design-tokens",
8
+ "react",
9
+ "claude-code",
10
+ "codex",
11
+ "agent-client-protocol"
12
+ ],
13
+ "license": "Apache-2.0",
14
+ "author": "Lucas Skog",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/sockulags/basis-design.git"
18
+ },
19
+ "type": "module",
20
+ "bin": {
21
+ "basis": "bin/basis.js"
22
+ },
23
+ "files": [
24
+ "bin",
25
+ "server",
26
+ "shared",
27
+ "src",
28
+ "template",
29
+ "index.html",
30
+ "preview.html",
31
+ "vite.config.ts",
32
+ "NOTICE"
33
+ ],
34
+ "engines": {
35
+ "node": ">=22.12.0"
36
+ },
37
+ "scripts": {
38
+ "dev": "tsx server/index.ts",
39
+ "start": "tsx server/index.ts",
40
+ "typecheck": "tsc --noEmit",
41
+ "test": "node --import tsx --test \"test/*.test.ts\"",
42
+ "lint": "oxlint",
43
+ "format": "prettier --write .",
44
+ "check": "tsc --noEmit && oxlint && prettier --check . && npm test"
45
+ },
46
+ "dependencies": {
47
+ "@agentclientprotocol/claude-agent-acp": "0.92.0",
48
+ "@agentclientprotocol/sdk": "^1.9.0",
49
+ "@types/react": "^19.3.0",
50
+ "@types/react-dom": "^19.3.0",
51
+ "@vitejs/plugin-react": "^6.1.2",
52
+ "axe-core": "^4.14.0",
53
+ "fflate": "^0.8.3",
54
+ "react": "^19.3.1",
55
+ "react-dom": "^19.3.1",
56
+ "tsx": "^4.23.15",
57
+ "typescript": "^7.0.2",
58
+ "vite": "^8.3.4",
59
+ "ws": "^8.22.0",
60
+ "zod": "^4.6.7"
61
+ },
62
+ "devDependencies": {
63
+ "@types/node": "^26.6.5",
64
+ "@types/ws": "^8.18.2",
65
+ "oxlint": "1.88.0",
66
+ "prettier": "3.9.10"
67
+ }
68
+ }
package/preview.html ADDED
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Basis preview</title>
7
+ </head>
8
+ <body>
9
+ <div id="root"></div>
10
+ <script type="module" src="/src/preview/main.tsx"></script>
11
+ </body>
12
+ </html>