roughbook 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 (144) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +166 -2
  3. package/dist/agents/claude.js +214 -0
  4. package/dist/agents/claude.js.map +1 -0
  5. package/dist/agents/codex.js +179 -0
  6. package/dist/agents/codex.js.map +1 -0
  7. package/dist/agents/command.js +47 -0
  8. package/dist/agents/command.js.map +1 -0
  9. package/dist/agents/index.js +21 -0
  10. package/dist/agents/index.js.map +1 -0
  11. package/dist/agents/process.js +76 -0
  12. package/dist/agents/process.js.map +1 -0
  13. package/dist/agents/session.js +26 -0
  14. package/dist/agents/session.js.map +1 -0
  15. package/dist/agents/types.js +2 -0
  16. package/dist/agents/types.js.map +1 -0
  17. package/dist/api/client.js +138 -0
  18. package/dist/api/client.js.map +1 -0
  19. package/dist/api/errors.js +40 -0
  20. package/dist/api/errors.js.map +1 -0
  21. package/dist/api/outbox.js +105 -0
  22. package/dist/api/outbox.js.map +1 -0
  23. package/dist/api/types.js +4 -0
  24. package/dist/api/types.js.map +1 -0
  25. package/dist/cli.js +10 -0
  26. package/dist/cli.js.map +1 -0
  27. package/dist/commands/agents.js +39 -0
  28. package/dist/commands/agents.js.map +1 -0
  29. package/dist/commands/context.js +27 -0
  30. package/dist/commands/context.js.map +1 -0
  31. package/dist/commands/done.js +125 -0
  32. package/dist/commands/done.js.map +1 -0
  33. package/dist/commands/index.js +101 -0
  34. package/dist/commands/index.js.map +1 -0
  35. package/dist/commands/init.js +203 -0
  36. package/dist/commands/init.js.map +1 -0
  37. package/dist/commands/login.js +93 -0
  38. package/dist/commands/login.js.map +1 -0
  39. package/dist/commands/logout.js +34 -0
  40. package/dist/commands/logout.js.map +1 -0
  41. package/dist/commands/promote.js +105 -0
  42. package/dist/commands/promote.js.map +1 -0
  43. package/dist/commands/pull.js +45 -0
  44. package/dist/commands/pull.js.map +1 -0
  45. package/dist/commands/revert.js +39 -0
  46. package/dist/commands/revert.js.map +1 -0
  47. package/dist/commands/review.js +73 -0
  48. package/dist/commands/review.js.map +1 -0
  49. package/dist/commands/run.js +147 -0
  50. package/dist/commands/run.js.map +1 -0
  51. package/dist/commands/shared.js +81 -0
  52. package/dist/commands/shared.js.map +1 -0
  53. package/dist/commands/start.js +119 -0
  54. package/dist/commands/start.js.map +1 -0
  55. package/dist/commands/status.js +62 -0
  56. package/dist/commands/status.js.map +1 -0
  57. package/dist/config/credentials.js +17 -0
  58. package/dist/config/credentials.js.map +1 -0
  59. package/dist/config/server.js +29 -0
  60. package/dist/config/server.js.map +1 -0
  61. package/dist/config/settings.js +21 -0
  62. package/dist/config/settings.js.map +1 -0
  63. package/dist/config/userDir.js +18 -0
  64. package/dist/config/userDir.js.map +1 -0
  65. package/dist/fs/json.js +44 -0
  66. package/dist/fs/json.js.map +1 -0
  67. package/dist/fs/lock.js +38 -0
  68. package/dist/fs/lock.js.map +1 -0
  69. package/dist/io.js +26 -0
  70. package/dist/io.js.map +1 -0
  71. package/dist/launch/open.js +48 -0
  72. package/dist/launch/open.js.map +1 -0
  73. package/dist/launch/platform.js +38 -0
  74. package/dist/launch/platform.js.map +1 -0
  75. package/dist/launch/pty.js +61 -0
  76. package/dist/launch/pty.js.map +1 -0
  77. package/dist/launch/terminal.js +194 -0
  78. package/dist/launch/terminal.js.map +1 -0
  79. package/dist/launch/which.js +59 -0
  80. package/dist/launch/which.js.map +1 -0
  81. package/dist/repo/diff.js +26 -0
  82. package/dist/repo/diff.js.map +1 -0
  83. package/dist/repo/framework.js +41 -0
  84. package/dist/repo/framework.js.map +1 -0
  85. package/dist/repo/link.js +28 -0
  86. package/dist/repo/link.js.map +1 -0
  87. package/dist/repo/prep.js +447 -0
  88. package/dist/repo/prep.js.map +1 -0
  89. package/dist/repo/preview.js +144 -0
  90. package/dist/repo/preview.js.map +1 -0
  91. package/dist/repo/root.js +48 -0
  92. package/dist/repo/root.js.map +1 -0
  93. package/dist/repo/scratch.js +111 -0
  94. package/dist/repo/scratch.js.map +1 -0
  95. package/dist/runs/checks.js +160 -0
  96. package/dist/runs/checks.js.map +1 -0
  97. package/dist/runs/lifecycle.js +142 -0
  98. package/dist/runs/lifecycle.js.map +1 -0
  99. package/dist/runs/promote.js +185 -0
  100. package/dist/runs/promote.js.map +1 -0
  101. package/dist/runs/pull.js +182 -0
  102. package/dist/runs/pull.js.map +1 -0
  103. package/dist/runs/reviews.js +34 -0
  104. package/dist/runs/reviews.js.map +1 -0
  105. package/dist/runs/slots.js +96 -0
  106. package/dist/runs/slots.js.map +1 -0
  107. package/dist/runs/snapshot.js +265 -0
  108. package/dist/runs/snapshot.js.map +1 -0
  109. package/dist/runs/store.js +38 -0
  110. package/dist/runs/store.js.map +1 -0
  111. package/dist/runs/types.js +3 -0
  112. package/dist/runs/types.js.map +1 -0
  113. package/dist/runs/watch.js +42 -0
  114. package/dist/runs/watch.js.map +1 -0
  115. package/dist/screenshot/browser.js +163 -0
  116. package/dist/screenshot/browser.js.map +1 -0
  117. package/dist/screenshot/iteration.js +37 -0
  118. package/dist/screenshot/iteration.js.map +1 -0
  119. package/dist/server/app.js +321 -0
  120. package/dist/server/app.js.map +1 -0
  121. package/dist/server/security.js +44 -0
  122. package/dist/server/security.js.map +1 -0
  123. package/dist/server/studio.js +618 -0
  124. package/dist/server/studio.js.map +1 -0
  125. package/dist/server/terminals.js +142 -0
  126. package/dist/server/terminals.js.map +1 -0
  127. package/dist/ui/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
  128. package/dist/ui/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  129. package/dist/ui/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
  130. package/dist/ui/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
  131. package/dist/ui/assets/index-D-TSXfvz.css +1 -0
  132. package/dist/ui/assets/index-HGV8FKwI.js +27 -0
  133. package/dist/ui/assets/inter-latin-400-normal-C38fXH4l.woff2 +0 -0
  134. package/dist/ui/assets/inter-latin-400-normal-CyCys3Eg.woff +0 -0
  135. package/dist/ui/assets/inter-latin-500-normal-BL9OpVg8.woff +0 -0
  136. package/dist/ui/assets/inter-latin-500-normal-Cerq10X2.woff2 +0 -0
  137. package/dist/ui/assets/space-grotesk-latin-400-normal-BnQMeOim.woff +0 -0
  138. package/dist/ui/assets/space-grotesk-latin-400-normal-CJ-V5oYT.woff2 +0 -0
  139. package/dist/ui/assets/space-grotesk-latin-500-normal-CNSSEhBt.woff +0 -0
  140. package/dist/ui/assets/space-grotesk-latin-500-normal-lFbtlQH6.woff2 +0 -0
  141. package/dist/ui/index.html +14 -0
  142. package/dist/version.js +4 -0
  143. package/dist/version.js.map +1 -0
  144. package/package.json +68 -4
package/LICENSE ADDED
@@ -0,0 +1,201 @@
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
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,167 @@
1
- # Temporary Holding Version
1
+ # Roughbook studio
2
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.
3
+ Design iterations inside your own repo, with the coding agent and editor you already use. The
4
+ studio links a repo to a Roughbook project, writes each iteration's prompt into `rough/`, hands it
5
+ to your agent, checks what came back, and lets you review, select and promote from a local UI.
6
+ Your code stays on your machine: the server only ever sees ids, review decisions and run metadata.
7
+
8
+ Runs on Windows, macOS and Linux, with Node 22 or later.
9
+
10
+ ## Commands
11
+
12
+ | Command | Does |
13
+ | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
14
+ | `roughbook login [--server <url>] [--no-browser]` | Signs this machine in: shows a code to enter at the web's `/link` page and opens it |
15
+ | `roughbook init` | In an app's repo: links it to a project and prepares it, showing every change first |
16
+ | `roughbook start [--port <port>] [--dev-url <url>]` | Opens the local UI in your browser: the project's components, their iterations live, compare, review, runs with the built-in terminal, Done and promote |
17
+ | `roughbook run <page>/<component> …` | Starts iterations: `--direction <idea>` (up to eight), `--fork <iteration>`, or `--refine <iteration> --intent <text>`; opens your agent in a terminal, or `--headless` runs it unattended |
18
+ | `roughbook done [<run or iteration>]` | Finishes a run: checks the iteration, lists files changed outside it, takes screenshots, reports it |
19
+ | `roughbook review <page>/<component>/<iteration> …` | `--select`, `--reject <reason> [--why <text>]`, or `--note <observation>`; saved on the server, so the next prompt remembers |
20
+ | `roughbook revert <page>/<component>/<iteration> <file>` | Puts back a file the run changed outside its iteration |
21
+ | `roughbook pull <page>/<component>[/<sketch>]` | Lists the component's web sketches, or brings one into `rough/` as the next local iteration |
22
+ | `roughbook promote <page>/<component>` | Hands the selected iteration to your agent to write the real component (`--to <file>`, `--iteration <id>`) |
23
+ | `roughbook agents [--default <agent>]` | Lists the coding agents found here, their sign-in and whether they can run unattended; sets the default |
24
+ | `roughbook status` | The sign-in, the linked project, and what is waiting to be sent |
25
+ | `roughbook logout` | Signs this machine out, here and on the server |
26
+
27
+ `init` asks which project the repo works on (or `--project <slug>`, `--new <name>`, with
28
+ `--org <id>` when two organizations share a slug) and whether to commit `rough/` (`--commit`, the
29
+ default, or `--no-commit`); `--yes` applies without asking. `--scratch <dir>` first makes a minimal
30
+ Next.js 16 app with Tailwind v4 and a git repository there. It then:
31
+
32
+ - writes `rough/` with `README.md`, `AGENTS.md` (the iteration rules every agent reads),
33
+ `CLAUDE.md` (pointing at them) and `roughbook.json` (the organization and project, no paths);
34
+ - adds the development-only preview route under the App Router, `rough/preview.tsx` for the app's
35
+ providers, and the generated `rough/preview-registry.ts`;
36
+ - excludes `rough/` and the route from TypeScript and ESLint, and adds an `@source` line so
37
+ Tailwind v4 sees the classes in `rough/`;
38
+ - tells git what to keep: run state, screenshots, the registry and the route are never committed,
39
+ and `rough/` itself only when you choose not to commit it.
40
+
41
+ A file the studio did not write is never replaced; it is listed for you to change by hand. Running
42
+ `init` again changes nothing, and it adopts a repo prepared by Roughbook v2.
43
+
44
+ ## Local UI
45
+
46
+ `roughbook start` serves the local UI on `127.0.0.1` (port 4848, or `--port`, which is kept
47
+ for next time) and opens it. It shows each component's iterations rendered live by the app's own
48
+ dev server (`--dev-url`, `ROUGHBOOK_DEV_URL`, or `http://localhost:3000`), with the last
49
+ screenshot when the dev server is not answering; Compare; the review drawer, notes, select, reject
50
+ and refine; a run panel for new directions, forks and refinements with the agent of your choice;
51
+ each run's Done, its report, and Put it back for files changed outside it; the component's web
52
+ sketches, each with Pull; and Deliver. The brief is read-only here, with a link to edit it on the web. While it runs, it keeps
53
+ `rough/preview-registry.ts` in step with the iteration folders and sends what waits in the
54
+ outbox.
55
+
56
+ Runs open in the **built-in terminal** in the page (xterm.js on `node-pty`), or in your own
57
+ terminal if you choose. A session runs the agent itself, never a shell, and belongs to its run:
58
+ closing or reloading the page leaves it running, and joining again replays what it printed. It is
59
+ used on Windows, macOS and glibc Linux, where `node-pty` installs and starts; elsewhere, and with
60
+ `ROUGHBOOK_TERMINAL=external`, runs open in your own terminal.
61
+
62
+ The server answers only `127.0.0.1` and `localhost` as its Host, and its API and terminal only
63
+ the page it opened: a token made at each start reaches the page in the link's fragment, and every
64
+ call carries it. Iterations load the project's and library's asset files from
65
+ `http://127.0.0.1:<port>/api/files/…`, which this server fetches from the backend with your
66
+ sign-in; prompts name that address, so keep the port.
67
+
68
+ ## Development
69
+
70
+ ```bash
71
+ npm install
72
+ npm run dev -- --help
73
+ ```
74
+
75
+ | Script | Does |
76
+ | -------------------- | -------------------------------------------------------- |
77
+ | `npm run dev -- <…>` | Runs the CLI from source through `tsx` |
78
+ | `npm test` | `node --test` over `src/**/*.test.ts`, never the network |
79
+ | `npm run type-check` | `tsc --noEmit` for the CLI and the local UI |
80
+ | `npm run lint` | ESLint, including the studio's own rules (`AGENTS.md`) |
81
+ | `npm run build` | Compiles to `dist/` and the UI to `dist/ui/` |
82
+ | `npm run build:ui` | The local UI alone, with Vite |
83
+
84
+ The backend is `roughbook-backend`. The studio talks to `http://localhost:4000` unless
85
+ `ROUGHBOOK_SERVER` or `roughbook login --server` says otherwise; anything but this machine must be
86
+ https.
87
+
88
+ ## Where things are kept
89
+
90
+ | What | Where |
91
+ | ------------------------------ | ---------------------------------------------------- |
92
+ | Your sign-in (install token) | The user config folder (below), readable only by you |
93
+ | The repo's link to its project | `rough/roughbook.json`, committed with `rough/` |
94
+ | The default agent, local port | `settings.json` in the user config folder |
95
+ | Runs, snapshots, the outbox | `rough/.roughbook/`, never committed |
96
+ | Screenshots | `rough/.screenshots/`, never committed |
97
+
98
+ The user config folder is `%APPDATA%\Roughbook` on Windows, `~/Library/Application Support/Roughbook`
99
+ on macOS, and `$XDG_CONFIG_HOME/roughbook` (or `~/.config/roughbook`) on Linux.
100
+ `ROUGHBOOK_CONFIG_DIR` overrides it.
101
+
102
+ ## Runs
103
+
104
+ A run starts with the backend: it allocates the iteration and compiles the prompt. The studio then
105
+ records every file in the repo by hash (copying aside any with uncommitted changes), writes the
106
+ iteration's folder (a placeholder, or a copy of the parent for a fork or refinement) and the prompt
107
+ in `rough/<page>/<component>/prompts/<run>.md`, and hands the agent one line:
108
+ `Follow the instructions in <prompt file>`. At Done it applies the backend's checks (the entry
109
+ file exists and is not the placeholder, a fork changed from its parent, the approved headline
110
+ appears) and its own (nothing outside `rough/` imports from it), lists every file changed outside
111
+ the run's folder, and sends the outcome, warning codes and counts. Any such file can be put back:
112
+ a new one is removed, an uncommitted one comes back from its copy, a committed one from git.
113
+
114
+ Reviews and run results are written to the outbox first and sent in order when the backend can be
115
+ reached, so nothing is lost offline; the server applies one sent twice once. `run` sends what is
116
+ waiting before it asks for a prompt, so a rejection always reaches the next one.
117
+
118
+ Claude Code and Codex are supported. A run opens the agent in a terminal: Windows Terminal or a
119
+ console window on Windows, Terminal or iTerm on macOS (`ROUGHBOOK_TERMINAL=iterm`), and
120
+ `$TERMINAL`, `x-terminal-emulator`, GNOME Terminal, Konsole or xterm on Linux; otherwise it prints
121
+ the command to paste. `--headless` runs the agent unattended, only with your own API key
122
+ (`ANTHROPIC_API_KEY` for Claude Code, `CODEX_API_KEY` or `OPENAI_API_KEY` for Codex), confined
123
+ to the run's folder, and reports its token counts. `done` takes desktop and phone screenshots
124
+ through the app's dev server (`--dev-url`, `ROUGHBOOK_DEV_URL`, or `http://localhost:3000`) with
125
+ Chrome, Chromium or Edge (`ROUGHBOOK_BROWSER` names another), into `rough/.screenshots/`.
126
+
127
+ ## Pull
128
+
129
+ `pull` brings a web sketch into the repo as the starting point of a local iteration: a fork whose
130
+ parent is the sketch. The backend allocates the next number and sends the sketch's files; the
131
+ studio checks every path before writing (its own folder only, known file types, a few folders
132
+ deep), never writes over an iteration, points the sketch's `/api/files/…` URLs at the local server,
133
+ and regenerates the preview registry. The iteration is generated already, so it can be reviewed,
134
+ refined (`run --refine`) and promoted like any other. Sketches use React, Tailwind and a few allowed
135
+ packages (motion, lucide-react, clsx, three, model-viewer); `pull` names any the app's
136
+ `package.json` does not list, with the command that adds them. A run going at the time does not
137
+ count the pulled files as its own writes. Nothing local goes up.
138
+
139
+ ## Promote
140
+
141
+ `promote` takes the component's selected iteration (or `--iteration`). The backend writes the
142
+ prompt from the brief; the studio copies the project and library assets the iteration uses into
143
+ `public/rough/<page>/<component>/` (beside the app's `package.json`, or `--public <folder>`), the
144
+ approved copy to `rough/<page>/<component>/copy.md`, fills in the component file
145
+ (`src/components/<Name>.tsx` by default, or `--to <file>`), and opens your agent with the prompt.
146
+ The server never hears the file's path. An existing file is never overwritten, and nothing is
147
+ committed: you review the diff.
148
+
149
+ ## Layout
150
+
151
+ ```text
152
+ src/
153
+ cli.ts the only process.cwd(); finds the repo root; runs a command
154
+ commands/ one file per command, and the registry
155
+ api/ the typed client for /studio, its errors, and the outbox
156
+ config/ sign-in, server address, the user config folder
157
+ agents/ one adapter per coding agent: finding it, terminal sessions, unattended runs
158
+ launch/ everything that differs by OS: terminals, opening a browser, naming the OS
159
+ screenshot/ headless Chrome, Chromium or Edge, at desktop and phone widths
160
+ runs/ local runs: slots and prompt files, the checks, snapshots and revert, the watcher,
161
+ review decisions, sketch pulls, and promotion
162
+ repo/ the repo root, repo prep and the preview route, the link file, scratch apps
163
+ fs/ whole-file JSON writes and the lock the CLI and local server share
164
+ server/ the local server: its API, the built-in terminal's sessions, who may ask
165
+ tests/
166
+ ui/ the local UI: Vite, React and @roughbook/ui, built into dist/ui
167
+ ```
@@ -0,0 +1,214 @@
1
+ // Claude Code. Flags checked against `claude --help` in Claude Code 2.1.286 (2026-10-05), and
2
+ // the permission rules against its permissions docs: `--permission-mode` no longer takes
3
+ // "default", so a headless run uses "dontAsk", which refuses anything not allowed instead of
4
+ // asking, with one allow rule for the run's folder. `--bare` makes the CLI use only an Anthropic
5
+ // API key (ANTHROPIC_API_KEY), never a claude.ai login, which is the split plan's rule for
6
+ // unattended runs. The stream-json field names follow its docs; check them against the first
7
+ // real headless run.
8
+ import path from 'node:path';
9
+ import { compareVersions, findNpmScript, findOnPath, fromEnv } from '../launch/which.js';
10
+ import { diskProbe } from '../launch/platform.js';
11
+ import { count, record, runCommand } from './command.js';
12
+ const NOT_FOUND = 'Claude Code was not found. Install it, or set ROUGHBOOK_CLAUDE_BIN to the full path of claude.';
13
+ /** The copy the Claude desktop app keeps: <data>/Claude/claude-code/<version>/[<build>/]claude. */
14
+ function desktopCopy(lookup) {
15
+ const windows = lookup.platform === 'win32';
16
+ const p = windows ? path.win32 : path.posix;
17
+ const probe = lookup.probe ?? diskProbe;
18
+ const data = windows
19
+ ? lookup.env.APPDATA
20
+ : lookup.platform === 'darwin'
21
+ ? p.join(lookup.home, 'Library', 'Application Support')
22
+ : null;
23
+ if (!data)
24
+ return null;
25
+ const root = p.join(data, 'Claude', 'claude-code');
26
+ const executable = windows ? 'claude.exe' : 'claude';
27
+ for (const version of probe.dirs(root).sort((a, b) => compareVersions(b, a))) {
28
+ const direct = p.join(root, version, executable);
29
+ if (probe.exists(direct))
30
+ return direct;
31
+ for (const build of probe.dirs(p.join(root, version))) {
32
+ const nested = p.join(root, version, build, executable);
33
+ if (probe.exists(nested))
34
+ return nested;
35
+ }
36
+ }
37
+ return null;
38
+ }
39
+ /** What a headless run may do: write its folder; never run commands, fetch, or read secrets. */
40
+ export function headlessSettings(targetFolder) {
41
+ return {
42
+ permissions: {
43
+ allow: [`Edit(./${targetFolder}/**)`],
44
+ deny: [
45
+ 'Bash',
46
+ 'PowerShell',
47
+ 'WebFetch',
48
+ 'WebSearch',
49
+ 'Read(./.env)',
50
+ 'Read(./.env.*)',
51
+ 'Read(./**/.env)',
52
+ 'Read(./**/.env.*)'
53
+ ]
54
+ }
55
+ };
56
+ }
57
+ export function parseClaudeLine(line) {
58
+ let parsed;
59
+ try {
60
+ parsed = record(JSON.parse(line.trim()));
61
+ }
62
+ catch {
63
+ return {};
64
+ }
65
+ switch (parsed.type) {
66
+ case 'system':
67
+ return parsed.subtype === 'init' && typeof parsed.session_id === 'string'
68
+ ? { event: { kind: 'session', id: parsed.session_id } }
69
+ : {};
70
+ case 'assistant': {
71
+ const content = record(parsed.message).content;
72
+ for (const block of Array.isArray(content) ? content.map(record) : []) {
73
+ if (block.type === 'text' && typeof block.text === 'string' && block.text.trim()) {
74
+ return { event: { kind: 'message', text: block.text } };
75
+ }
76
+ if (block.type === 'tool_use' && typeof block.name === 'string') {
77
+ return { event: { kind: 'tool', name: block.name } };
78
+ }
79
+ }
80
+ return {};
81
+ }
82
+ case 'result': {
83
+ const usage = record(parsed.usage);
84
+ const models = Object.keys(record(parsed.modelUsage));
85
+ const text = typeof parsed.result === 'string' && parsed.result.trim() ? parsed.result.trim() : null;
86
+ return {
87
+ event: {
88
+ kind: 'result',
89
+ ok: parsed.subtype === 'success' && parsed.is_error !== true,
90
+ text
91
+ },
92
+ usage: {
93
+ model: models[0] ?? '',
94
+ inputTokens: count(usage.input_tokens),
95
+ outputTokens: count(usage.output_tokens),
96
+ cacheReadTokens: count(usage.cache_read_input_tokens),
97
+ cacheWriteTokens: count(usage.cache_creation_input_tokens)
98
+ }
99
+ };
100
+ }
101
+ default:
102
+ return {};
103
+ }
104
+ }
105
+ export const claudeCode = {
106
+ id: 'claude-code',
107
+ name: 'Claude Code',
108
+ kind: 'terminal',
109
+ capabilities: { interactive: true, headless: true, permissions: true, usage: true },
110
+ notFound: NOT_FOUND,
111
+ find(lookup) {
112
+ const p = lookup.platform === 'win32' ? path.win32 : path.posix;
113
+ const probe = lookup.probe ?? diskProbe;
114
+ const explicit = fromEnv('ROUGHBOOK_CLAUDE_BIN', lookup);
115
+ if (explicit)
116
+ return explicit;
117
+ const onPath = findOnPath('claude', lookup);
118
+ if (onPath)
119
+ return { command: onPath, prefixArgs: [], source: 'PATH' };
120
+ const npm = findNpmScript('claude', '@anthropic-ai/claude-code', 'cli.js', lookup);
121
+ if (npm)
122
+ return npm;
123
+ const native = p.join(lookup.home, '.local', 'bin', lookup.platform === 'win32' ? 'claude.exe' : 'claude');
124
+ if (probe.exists(native))
125
+ return { command: native, prefixArgs: [], source: 'native install' };
126
+ const desktop = desktopCopy(lookup);
127
+ return desktop ? { command: desktop, prefixArgs: [], source: 'Claude desktop app' } : null;
128
+ },
129
+ async detect(lookup) {
130
+ const base = {
131
+ id: this.id,
132
+ name: this.name,
133
+ kind: this.kind,
134
+ capabilities: this.capabilities
135
+ };
136
+ const executable = this.find(lookup);
137
+ if (!executable) {
138
+ return {
139
+ ...base,
140
+ found: false,
141
+ executable: null,
142
+ version: null,
143
+ signedIn: null,
144
+ signIn: null,
145
+ headless: { ready: false, reason: NOT_FOUND }
146
+ };
147
+ }
148
+ const version = await runCommand(executable, ['--version']);
149
+ let signedIn = null;
150
+ let signIn = null;
151
+ const status = await runCommand(executable, ['auth', 'status', '--json']);
152
+ try {
153
+ const parsed = record(JSON.parse(status.stdout));
154
+ if (typeof parsed.loggedIn === 'boolean')
155
+ signedIn = parsed.loggedIn;
156
+ if (parsed.loggedIn === true)
157
+ signIn = typeof parsed.authMethod === 'string' ? parsed.authMethod : 'signed in';
158
+ else if (parsed.loggedIn === false)
159
+ signIn = 'not signed in';
160
+ }
161
+ catch {
162
+ signIn = null;
163
+ }
164
+ const headless = lookup.env.ANTHROPIC_API_KEY?.trim()
165
+ ? { ready: true }
166
+ : {
167
+ ready: false,
168
+ reason: 'Unattended runs use your own Anthropic API key: set ANTHROPIC_API_KEY. A claude.ai login works for terminal sessions.'
169
+ };
170
+ return {
171
+ ...base,
172
+ found: version.ok,
173
+ executable,
174
+ version: (version.stdout || version.stderr).trim().split(/\s+/)[0] || null,
175
+ signedIn,
176
+ signIn,
177
+ headless: version.ok ? headless : { ready: false, reason: 'Claude Code could not be run.' }
178
+ };
179
+ },
180
+ interactiveArgs(run) {
181
+ return [...(run.model ? ['--model', run.model] : []), '--name', run.title, run.instruction];
182
+ },
183
+ headless(run, executable, env) {
184
+ if (!env.ANTHROPIC_API_KEY?.trim()) {
185
+ return {
186
+ refused: 'Unattended runs use your own Anthropic API key: set ANTHROPIC_API_KEY, or run it in a terminal session.'
187
+ };
188
+ }
189
+ return {
190
+ command: executable.command,
191
+ args: [
192
+ ...executable.prefixArgs,
193
+ '--bare',
194
+ '-p',
195
+ '--output-format',
196
+ 'stream-json',
197
+ '--verbose',
198
+ '--session-id',
199
+ run.sessionId,
200
+ '--permission-mode',
201
+ 'dontAsk',
202
+ '--settings',
203
+ JSON.stringify(headlessSettings(run.targetFolder)),
204
+ ...(run.model ? ['--model', run.model] : []),
205
+ run.instruction
206
+ ],
207
+ cwd: run.repoRoot,
208
+ stdin: null,
209
+ env: {}
210
+ };
211
+ },
212
+ parseLine: parseClaudeLine
213
+ };
214
+ //# sourceMappingURL=claude.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude.js","sourceRoot":"","sources":["../../src/agents/claude.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,yFAAyF;AACzF,6FAA6F;AAC7F,iGAAiG;AACjG,2FAA2F;AAC3F,6FAA6F;AAC7F,qBAAqB;AACrB,OAAO,IAAI,MAAM,WAAW,CAAC;AA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