@antigenic-oss/paint 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 (158) hide show
  1. package/LICENSE +178 -0
  2. package/NOTICE +4 -0
  3. package/README.md +180 -0
  4. package/bin/paint.js +266 -0
  5. package/next-env.d.ts +6 -0
  6. package/next.config.ts +19 -0
  7. package/package.json +81 -0
  8. package/postcss.config.mjs +8 -0
  9. package/public/dev-editor-inspector.js +1872 -0
  10. package/src/app/api/claude/analyze/route.ts +319 -0
  11. package/src/app/api/claude/apply/route.ts +185 -0
  12. package/src/app/api/claude/pick-folder/route.ts +64 -0
  13. package/src/app/api/claude/scan/route.ts +221 -0
  14. package/src/app/api/claude/status/route.ts +55 -0
  15. package/src/app/api/project/scan/route.ts +634 -0
  16. package/src/app/api/project-scan/css-variables/route.ts +238 -0
  17. package/src/app/api/project-scan/route.ts +40 -0
  18. package/src/app/api/project-scan/tailwind-config/route.ts +172 -0
  19. package/src/app/api/proxy/[[...path]]/route.ts +2400 -0
  20. package/src/app/docs/DocsClient.tsx +322 -0
  21. package/src/app/docs/layout.tsx +7 -0
  22. package/src/app/docs/page.tsx +855 -0
  23. package/src/app/globals.css +176 -0
  24. package/src/app/layout.tsx +19 -0
  25. package/src/app/page.tsx +46 -0
  26. package/src/bridge/api-handlers.ts +885 -0
  27. package/src/bridge/proxy-handler.ts +329 -0
  28. package/src/bridge/server.ts +113 -0
  29. package/src/components/BreakpointTabs.tsx +72 -0
  30. package/src/components/ChangeSummaryModal.tsx +267 -0
  31. package/src/components/ConnectModal.tsx +994 -0
  32. package/src/components/Editor.tsx +90 -0
  33. package/src/components/PageSelector.tsx +208 -0
  34. package/src/components/PreviewFrame.tsx +299 -0
  35. package/src/components/ProjectFolderBanner.tsx +91 -0
  36. package/src/components/ResponsiveToolbar.tsx +222 -0
  37. package/src/components/TargetSelector.tsx +243 -0
  38. package/src/components/TopBar.tsx +315 -0
  39. package/src/components/common/CollapsibleSection.tsx +36 -0
  40. package/src/components/common/ColorPicker.tsx +920 -0
  41. package/src/components/common/EditablePre.tsx +136 -0
  42. package/src/components/common/ErrorBoundary.tsx +65 -0
  43. package/src/components/common/ResizablePanel.tsx +83 -0
  44. package/src/components/common/ScanAnimation.tsx +76 -0
  45. package/src/components/common/ToastContainer.tsx +97 -0
  46. package/src/components/common/UnitInput.tsx +77 -0
  47. package/src/components/common/VariableColorPicker.tsx +622 -0
  48. package/src/components/left-panel/AddElementPanel.tsx +237 -0
  49. package/src/components/left-panel/ComponentsPanel.tsx +609 -0
  50. package/src/components/left-panel/IconSidebar.tsx +99 -0
  51. package/src/components/left-panel/LayerNode.tsx +874 -0
  52. package/src/components/left-panel/LayerSearch.tsx +23 -0
  53. package/src/components/left-panel/LayersPanel.tsx +52 -0
  54. package/src/components/left-panel/LeftPanel.tsx +122 -0
  55. package/src/components/left-panel/PagesPanel.tsx +114 -0
  56. package/src/components/left-panel/icons.tsx +162 -0
  57. package/src/components/left-panel/terminal/ScanOverlay.tsx +66 -0
  58. package/src/components/left-panel/terminal/TerminalPanel.tsx +217 -0
  59. package/src/components/right-panel/ElementLogBox.tsx +248 -0
  60. package/src/components/right-panel/PanelTabs.tsx +83 -0
  61. package/src/components/right-panel/RightPanel.tsx +41 -0
  62. package/src/components/right-panel/changes/AiScanResultPanel.tsx +285 -0
  63. package/src/components/right-panel/changes/ChangeEntry.tsx +59 -0
  64. package/src/components/right-panel/changes/ChangelogActions.tsx +105 -0
  65. package/src/components/right-panel/changes/ChangesPanel.tsx +1474 -0
  66. package/src/components/right-panel/claude/ApplyConfirmModal.tsx +376 -0
  67. package/src/components/right-panel/claude/ClaudeErrorState.tsx +125 -0
  68. package/src/components/right-panel/claude/ClaudeIntegrationPanel.tsx +482 -0
  69. package/src/components/right-panel/claude/ClaudeProgressIndicator.tsx +76 -0
  70. package/src/components/right-panel/claude/DiffCard.tsx +130 -0
  71. package/src/components/right-panel/claude/DiffViewer.tsx +54 -0
  72. package/src/components/right-panel/claude/ProjectRootSelector.tsx +275 -0
  73. package/src/components/right-panel/claude/ResultsSummary.tsx +119 -0
  74. package/src/components/right-panel/claude/SetupFlow.tsx +315 -0
  75. package/src/components/right-panel/console/ConsolePanel.tsx +209 -0
  76. package/src/components/right-panel/design/AppearanceSection.tsx +703 -0
  77. package/src/components/right-panel/design/BackgroundSection.tsx +516 -0
  78. package/src/components/right-panel/design/BorderSection.tsx +161 -0
  79. package/src/components/right-panel/design/CSSRawView.tsx +412 -0
  80. package/src/components/right-panel/design/DesignCSSTabToggle.tsx +51 -0
  81. package/src/components/right-panel/design/DesignPanel.tsx +275 -0
  82. package/src/components/right-panel/design/ElementBreadcrumb.tsx +51 -0
  83. package/src/components/right-panel/design/GradientEditor.tsx +726 -0
  84. package/src/components/right-panel/design/LayoutSection.tsx +1948 -0
  85. package/src/components/right-panel/design/PositionSection.tsx +865 -0
  86. package/src/components/right-panel/design/PropertiesSection.tsx +86 -0
  87. package/src/components/right-panel/design/SVGSection.tsx +361 -0
  88. package/src/components/right-panel/design/ShadowBlurSection.tsx +227 -0
  89. package/src/components/right-panel/design/SizeSection.tsx +183 -0
  90. package/src/components/right-panel/design/TextSection.tsx +719 -0
  91. package/src/components/right-panel/design/icons.tsx +948 -0
  92. package/src/components/right-panel/design/inputs/BoxModelPreview.tsx +467 -0
  93. package/src/components/right-panel/design/inputs/ColorInput.tsx +43 -0
  94. package/src/components/right-panel/design/inputs/CompactInput.tsx +333 -0
  95. package/src/components/right-panel/design/inputs/DraggableLabel.tsx +118 -0
  96. package/src/components/right-panel/design/inputs/IconToggleGroup.tsx +54 -0
  97. package/src/components/right-panel/design/inputs/LinkedInputPair.tsx +174 -0
  98. package/src/components/right-panel/design/inputs/SectionHeader.tsx +79 -0
  99. package/src/components/right-panel/variables/VariablesPanel.tsx +388 -0
  100. package/src/hooks/useBridge.ts +95 -0
  101. package/src/hooks/useChangeTracker.ts +563 -0
  102. package/src/hooks/useClaudeAPI.ts +118 -0
  103. package/src/hooks/useDOMTree.ts +25 -0
  104. package/src/hooks/useKeyboardShortcuts.ts +76 -0
  105. package/src/hooks/usePostMessage.ts +589 -0
  106. package/src/hooks/useProjectScan.ts +204 -0
  107. package/src/hooks/useResizable.ts +20 -0
  108. package/src/hooks/useSelectedElement.ts +51 -0
  109. package/src/hooks/useTargetUrl.ts +81 -0
  110. package/src/inspector/DOMTraverser.ts +71 -0
  111. package/src/inspector/ElementSelector.ts +23 -0
  112. package/src/inspector/HoverHighlighter.ts +54 -0
  113. package/src/inspector/SelectionHighlighter.ts +27 -0
  114. package/src/inspector/StyleExtractor.ts +19 -0
  115. package/src/inspector/inspector.ts +17 -0
  116. package/src/inspector/messaging.ts +30 -0
  117. package/src/lib/apiBase.ts +15 -0
  118. package/src/lib/classifyElement.ts +430 -0
  119. package/src/lib/claude-bin.ts +197 -0
  120. package/src/lib/claude-stream.ts +158 -0
  121. package/src/lib/clientProjectScanner.ts +344 -0
  122. package/src/lib/componentMatcher.ts +156 -0
  123. package/src/lib/constants.ts +573 -0
  124. package/src/lib/cssVariableUtils.ts +409 -0
  125. package/src/lib/diffParser.ts +206 -0
  126. package/src/lib/folderPicker.ts +84 -0
  127. package/src/lib/gradientParser.ts +160 -0
  128. package/src/lib/projectScanner.ts +355 -0
  129. package/src/lib/promptBuilder.ts +402 -0
  130. package/src/lib/shadowParser.ts +124 -0
  131. package/src/lib/tailwindClassParser.ts +248 -0
  132. package/src/lib/textShadowUtils.ts +106 -0
  133. package/src/lib/utils.ts +299 -0
  134. package/src/lib/validatePath.ts +40 -0
  135. package/src/proxy.ts +92 -0
  136. package/src/server/terminal-server.ts +104 -0
  137. package/src/store/changeSlice.ts +288 -0
  138. package/src/store/claudeSlice.ts +222 -0
  139. package/src/store/componentSlice.ts +90 -0
  140. package/src/store/consoleSlice.ts +51 -0
  141. package/src/store/cssVariableSlice.ts +94 -0
  142. package/src/store/elementSlice.ts +78 -0
  143. package/src/store/index.ts +35 -0
  144. package/src/store/terminalSlice.ts +30 -0
  145. package/src/store/treeSlice.ts +69 -0
  146. package/src/store/uiSlice.ts +327 -0
  147. package/src/types/changelog.ts +49 -0
  148. package/src/types/claude.ts +131 -0
  149. package/src/types/component.ts +49 -0
  150. package/src/types/cssVariables.ts +18 -0
  151. package/src/types/element.ts +21 -0
  152. package/src/types/file-system-access.d.ts +27 -0
  153. package/src/types/gradient.ts +12 -0
  154. package/src/types/messages.ts +392 -0
  155. package/src/types/shadow.ts +8 -0
  156. package/src/types/tree.ts +9 -0
  157. package/tsconfig.json +42 -0
  158. package/tsconfig.server.json +12 -0
package/LICENSE ADDED
@@ -0,0 +1,178 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 Antigenic Research Institute
package/NOTICE ADDED
@@ -0,0 +1,4 @@
1
+ pAInt
2
+ Copyright 2026 Antigenic Research Institute
3
+
4
+ This product includes software developed at Antigenic Research Institute.
package/README.md ADDED
@@ -0,0 +1,180 @@
1
+ # pAInt
2
+
3
+ [![License](https://img.shields.io/github/license/Antigenic-OSS/pAInt)](https://github.com/Antigenic-OSS/pAInt/blob/main/LICENSE)
4
+ [![Stars](https://img.shields.io/github/stars/Antigenic-OSS/pAInt?style=social)](https://github.com/Antigenic-OSS/pAInt/stargazers)
5
+ [![Issues](https://img.shields.io/github/issues/Antigenic-OSS/pAInt)](https://github.com/Antigenic-OSS/pAInt/issues)
6
+ [![Bun](https://img.shields.io/badge/runtime-Bun-000000)](https://bun.sh)
7
+ [![Next.js](https://img.shields.io/badge/framework-Next.js-000000)](https://nextjs.org)
8
+ [![TypeScript](https://img.shields.io/badge/language-TypeScript-3178C6)](https://www.typescriptlang.org)
9
+
10
+ pAInt is a visual editor for localhost web projects. It helps you inspect elements, edit styles, manage CSS variables, and export changelogs for [Claude Code](https://claude.ai/claude-code).
11
+
12
+ ## Table of Contents
13
+
14
+ - [Project Status](#project-status)
15
+ - [Global CLI](#global-cli)
16
+ - [What You Can Do](#what-you-can-do)
17
+ - [Prerequisites](#prerequisites)
18
+ - [Quick Start](#quick-start)
19
+ - [Connection Modes](#connection-modes)
20
+ - [Core Workflow](#core-workflow)
21
+ - [Interface Layout](#interface-layout)
22
+ - [Commands](#commands)
23
+ - [Architecture Summary](#architecture-summary)
24
+ - [Security Notes](#security-notes)
25
+ - [Documentation](#documentation)
26
+ - [Contributing](#contributing)
27
+ - [Release Automation](#release-automation)
28
+ - [License](#license)
29
+
30
+ ## Project Status
31
+
32
+ - Stage: Active development
33
+ - Stability: Suitable for local development workflows
34
+ - Scope: Visual editing and changelog-driven code updates for localhost apps
35
+
36
+ ## Global CLI
37
+
38
+ Install globally with your package manager of choice:
39
+
40
+ ```bash
41
+ npm install -g @antigenic-oss/paint
42
+ pnpm add -g @antigenic-oss/paint
43
+ bun add -g @antigenic-oss/paint
44
+ ```
45
+
46
+ Then use:
47
+
48
+ ```bash
49
+ paint start # Builds on first run, then starts server
50
+ paint status # Show pid, URL, and log path
51
+ paint stop # Stop background server
52
+ paint restart --rebuild # Force a rebuild before start
53
+ paint logs # Print server logs
54
+ ```
55
+
56
+ Default URL: `http://127.0.0.1:4000`
57
+
58
+ ## What You Can Do
59
+
60
+ - Inspect and select any element in a live preview
61
+ - Edit typography, spacing, layout, colors, borders, shadows, and gradients
62
+ - Manage and reuse CSS custom properties
63
+ - Work across breakpoints (Mobile 375px, Tablet 768px, Desktop 1280px)
64
+ - Navigate and select through a DOM layers tree
65
+ - Insert new HTML elements from the Add Element panel
66
+ - Track every change and export a structured changelog
67
+ - Send changelogs to Claude Code for source-file application
68
+
69
+ ## Prerequisites
70
+
71
+ - [Bun](https://bun.sh)
72
+ - A localhost app running in development mode (Next.js, Vite, Astro, CRA, etc.)
73
+
74
+ ## Quick Start
75
+
76
+ ```bash
77
+ bun install
78
+ bun dev
79
+ ```
80
+
81
+ Open `http://localhost:4000`, then:
82
+
83
+ 1. Start your target app (for example `http://localhost:3000`)
84
+ 2. Select the target localhost port in pAInt
85
+ 3. Click **Connect**
86
+ 4. Start inspecting and editing
87
+
88
+ ## Connection Modes
89
+
90
+ ### Automatic proxy mode (default)
91
+
92
+ Click **Connect** and pAInt loads your page through its reverse proxy, injecting the inspector automatically.
93
+
94
+ ### Manual script mode
95
+
96
+ If auto-injection is not detected, add this script tag to your app layout and reload:
97
+
98
+ ```html
99
+ <script src="https://dev-editor-flow.vercel.app/dev-editor-inspector.js"></script>
100
+ ```
101
+
102
+ ### Vercel + local bridge mode
103
+
104
+ If the UI is hosted on Vercel, run the local bridge server:
105
+
106
+ ```bash
107
+ bun run bridge
108
+ ```
109
+
110
+ Bridge default: `http://localhost:4002`
111
+
112
+ ## Core Workflow
113
+
114
+ 1. Connect to your localhost app
115
+ 2. Select elements from preview or Layers
116
+ 3. Edit styles in Design/Variables panels
117
+ 4. Review edits in Changes
118
+ 5. Copy changelog or send it to Claude Code
119
+
120
+ ## Interface Layout
121
+
122
+ - Left panel: Layers, Pages, Components, Add Element, Terminal
123
+ - Center panel: Live iframe preview
124
+ - Right panel: Design, Variables, Changes, Claude, Console
125
+
126
+ ## Commands
127
+
128
+ ```bash
129
+ bun install # Install dependencies
130
+ bun dev # Start UI (localhost:4000)
131
+ bun run bridge # Start bridge server (localhost:4002)
132
+ bun run dev:terminal # Start terminal server
133
+ bun run dev:all # Start terminal + bridge + next dev
134
+ bun run build # Production build
135
+ bun run start # Production server (port 4000)
136
+ bun run lint # Biome check
137
+ ```
138
+
139
+ ## Architecture Summary
140
+
141
+ - Next.js App Router frontend running on Bun
142
+ - Proxy API route at `/api/proxy/*` for target-page loading and injection
143
+ - Inspector script communicates with editor via `window.postMessage`
144
+ - State managed with Zustand slices
145
+ - Changes persisted in localStorage per target URL
146
+
147
+ ## Security Notes
148
+
149
+ - Localhost targets only
150
+ - Proxy rejects non-local addresses
151
+ - Target-page scripts are stripped in proxy mode to reduce runtime interference
152
+ - CLI execution is spawned without shell-string interpolation
153
+
154
+ ## Documentation
155
+
156
+ - In-app docs: `/docs`
157
+ - Contributor guide: `CONTRIBUTING.md`
158
+ - Code of conduct: `CODE_OF_CONDUCT.md`
159
+ - Security reporting: `SECURITY.md`
160
+ - Support details: `SUPPORT.md`
161
+
162
+ ## Contributing
163
+
164
+ See `CONTRIBUTING.md` for setup, workflow, and pull request expectations.
165
+
166
+ ## Release Automation
167
+
168
+ - Versioning and release PRs are managed with Changesets.
169
+ - CI workflow: `.github/workflows/ci.yml`
170
+ - Release workflow: `.github/workflows/release.yml`
171
+ - Publishing requires `NPM_TOKEN` in GitHub repository secrets.
172
+ - To queue a release, add a changeset:
173
+
174
+ ```bash
175
+ bun run changeset
176
+ ```
177
+
178
+ ## License
179
+
180
+ Apache License 2.0. See `LICENSE`.
package/bin/paint.js ADDED
@@ -0,0 +1,266 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('node:fs')
4
+ const os = require('node:os')
5
+ const path = require('node:path')
6
+ const { spawn, spawnSync } = require('node:child_process')
7
+
8
+ const APP_ROOT = path.resolve(__dirname, '..')
9
+ const STATE_DIR = path.join(os.homedir(), '.paint')
10
+ const STATE_FILE = path.join(STATE_DIR, 'server.json')
11
+ const LOG_FILE = path.join(STATE_DIR, 'server.log')
12
+ const NEXT_BIN = path.join(APP_ROOT, 'node_modules', 'next', 'dist', 'bin', 'next')
13
+
14
+ function ensureStateDir() {
15
+ fs.mkdirSync(STATE_DIR, { recursive: true })
16
+ }
17
+
18
+ function now() {
19
+ return new Date().toISOString()
20
+ }
21
+
22
+ function parseArgs(argv) {
23
+ const parsed = {
24
+ command: argv[0] || 'help',
25
+ port: 4000,
26
+ host: '127.0.0.1',
27
+ rebuild: false,
28
+ }
29
+
30
+ for (let i = 1; i < argv.length; i += 1) {
31
+ const arg = argv[i]
32
+ if (arg === '--port' && argv[i + 1]) {
33
+ parsed.port = Number(argv[i + 1])
34
+ i += 1
35
+ continue
36
+ }
37
+ if (arg.startsWith('--port=')) {
38
+ parsed.port = Number(arg.slice('--port='.length))
39
+ continue
40
+ }
41
+ if (arg === '--host' && argv[i + 1]) {
42
+ parsed.host = argv[i + 1]
43
+ i += 1
44
+ continue
45
+ }
46
+ if (arg.startsWith('--host=')) {
47
+ parsed.host = arg.slice('--host='.length)
48
+ continue
49
+ }
50
+ if (arg === '--rebuild') {
51
+ parsed.rebuild = true
52
+ }
53
+ }
54
+
55
+ return parsed
56
+ }
57
+
58
+ function readState() {
59
+ try {
60
+ return JSON.parse(fs.readFileSync(STATE_FILE, 'utf8'))
61
+ } catch {
62
+ return null
63
+ }
64
+ }
65
+
66
+ function writeState(state) {
67
+ fs.writeFileSync(STATE_FILE, JSON.stringify(state, null, 2))
68
+ }
69
+
70
+ function removeState() {
71
+ if (fs.existsSync(STATE_FILE)) {
72
+ fs.unlinkSync(STATE_FILE)
73
+ }
74
+ }
75
+
76
+ function isProcessAlive(pid) {
77
+ if (!Number.isInteger(pid) || pid <= 0) return false
78
+ try {
79
+ process.kill(pid, 0)
80
+ return true
81
+ } catch {
82
+ return false
83
+ }
84
+ }
85
+
86
+ function ensureNextInstalled() {
87
+ if (!fs.existsSync(NEXT_BIN)) {
88
+ console.error('pAInt runtime is missing Next.js binaries. Reinstall the package.')
89
+ process.exit(1)
90
+ }
91
+ }
92
+
93
+ function ensureBuilt(forceRebuild) {
94
+ ensureStateDir()
95
+ ensureNextInstalled()
96
+
97
+ const buildIdPath = path.join(APP_ROOT, '.next', 'BUILD_ID')
98
+ if (!forceRebuild && fs.existsSync(buildIdPath)) {
99
+ return
100
+ }
101
+
102
+ console.log(forceRebuild ? 'Rebuilding pAInt…' : 'Building pAInt for first run…')
103
+ const result = spawnSync(process.execPath, [NEXT_BIN, 'build'], {
104
+ cwd: APP_ROOT,
105
+ env: process.env,
106
+ stdio: 'inherit',
107
+ })
108
+
109
+ if (result.status !== 0) {
110
+ process.exit(result.status || 1)
111
+ }
112
+ }
113
+
114
+ function stopProcess(pid) {
115
+ if (process.platform === 'win32') {
116
+ const result = spawnSync('taskkill', ['/PID', String(pid), '/T', '/F'], {
117
+ stdio: 'ignore',
118
+ })
119
+ return result.status === 0
120
+ }
121
+
122
+ try {
123
+ process.kill(-pid, 'SIGTERM')
124
+ return true
125
+ } catch {
126
+ try {
127
+ process.kill(pid, 'SIGTERM')
128
+ return true
129
+ } catch {
130
+ return false
131
+ }
132
+ }
133
+ }
134
+
135
+ function startServer({ port, host, rebuild }) {
136
+ if (!Number.isInteger(port) || port <= 0 || port > 65535) {
137
+ console.error(`Invalid --port value: ${port}`)
138
+ process.exit(1)
139
+ }
140
+
141
+ const existing = readState()
142
+ if (existing && isProcessAlive(existing.pid)) {
143
+ console.log(`pAInt is already running (pid ${existing.pid}) at http://${existing.host}:${existing.port}`)
144
+ process.exit(0)
145
+ }
146
+
147
+ ensureBuilt(rebuild)
148
+ ensureStateDir()
149
+
150
+ const logFd = fs.openSync(LOG_FILE, 'a')
151
+ fs.writeSync(logFd, `\n[${now()}] starting pAInt server\n`)
152
+
153
+ const child = spawn(
154
+ process.execPath,
155
+ [NEXT_BIN, 'start', '--port', String(port), '--hostname', host],
156
+ {
157
+ cwd: APP_ROOT,
158
+ env: process.env,
159
+ detached: true,
160
+ stdio: ['ignore', logFd, logFd],
161
+ },
162
+ )
163
+
164
+ child.unref()
165
+
166
+ writeState({
167
+ pid: child.pid,
168
+ host,
169
+ port,
170
+ startedAt: now(),
171
+ logFile: LOG_FILE,
172
+ })
173
+
174
+ console.log(`pAInt started (pid ${child.pid}) at http://${host}:${port}`)
175
+ console.log(`Logs: ${LOG_FILE}`)
176
+ }
177
+
178
+ function stopServer() {
179
+ const existing = readState()
180
+ if (!existing) {
181
+ console.log('pAInt is not running.')
182
+ return
183
+ }
184
+
185
+ if (!isProcessAlive(existing.pid)) {
186
+ removeState()
187
+ console.log('pAInt was not running. Cleared stale state.')
188
+ return
189
+ }
190
+
191
+ const ok = stopProcess(existing.pid)
192
+ removeState()
193
+
194
+ if (!ok) {
195
+ console.error(`Failed to stop process ${existing.pid}`)
196
+ process.exit(1)
197
+ }
198
+
199
+ console.log(`Stopped pAInt (pid ${existing.pid}).`)
200
+ }
201
+
202
+ function serverStatus() {
203
+ const existing = readState()
204
+ if (!existing || !isProcessAlive(existing.pid)) {
205
+ console.log('pAInt is not running.')
206
+ return
207
+ }
208
+
209
+ console.log(`pAInt is running (pid ${existing.pid})`)
210
+ console.log(`URL: http://${existing.host}:${existing.port}`)
211
+ console.log(`Started: ${existing.startedAt}`)
212
+ console.log(`Logs: ${existing.logFile}`)
213
+ }
214
+
215
+ function showHelp() {
216
+ console.log(`paint - pAInt server manager
217
+
218
+ Usage:
219
+ paint start [--port 4000] [--host 127.0.0.1] [--rebuild]
220
+ paint stop
221
+ paint restart [--port 4000] [--host 127.0.0.1] [--rebuild]
222
+ paint status
223
+ paint logs
224
+ paint help
225
+ `)
226
+ }
227
+
228
+ function showLogs() {
229
+ if (!fs.existsSync(LOG_FILE)) {
230
+ console.log('No logs found yet.')
231
+ return
232
+ }
233
+ const content = fs.readFileSync(LOG_FILE, 'utf8')
234
+ process.stdout.write(content)
235
+ }
236
+
237
+ function main() {
238
+ const options = parseArgs(process.argv.slice(2))
239
+
240
+ switch (options.command) {
241
+ case 'start':
242
+ startServer(options)
243
+ break
244
+ case 'stop':
245
+ stopServer()
246
+ break
247
+ case 'restart':
248
+ stopServer()
249
+ startServer(options)
250
+ break
251
+ case 'status':
252
+ serverStatus()
253
+ break
254
+ case 'logs':
255
+ showLogs()
256
+ break
257
+ case 'help':
258
+ case '--help':
259
+ case '-h':
260
+ default:
261
+ showHelp()
262
+ break
263
+ }
264
+ }
265
+
266
+ main()
package/next-env.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ /// <reference types="next" />
2
+ /// <reference types="next/image-types/global" />
3
+ import "./.next/types/routes.d.ts";
4
+
5
+ // NOTE: This file should not be edited
6
+ // see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
package/next.config.ts ADDED
@@ -0,0 +1,19 @@
1
+ import type { NextConfig } from 'next'
2
+
3
+ const nextConfig: NextConfig = {
4
+ async headers() {
5
+ return [
6
+ {
7
+ // Serve inspector script with CORS + CORP headers so it loads
8
+ // on target pages that set Cross-Origin-Embedder-Policy: require-corp
9
+ source: '/dev-editor-inspector.js',
10
+ headers: [
11
+ { key: 'Access-Control-Allow-Origin', value: '*' },
12
+ { key: 'Cross-Origin-Resource-Policy', value: 'cross-origin' },
13
+ ],
14
+ },
15
+ ]
16
+ },
17
+ }
18
+
19
+ export default nextConfig