ghostrail 0.0.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 (218) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +16 -0
  3. package/README.md +56 -0
  4. package/dist/agent/claude-code.d.ts +37 -0
  5. package/dist/agent/claude-code.d.ts.map +1 -0
  6. package/dist/agent/claude-code.js +74 -0
  7. package/dist/agent/claude-code.js.map +1 -0
  8. package/dist/agent/index.d.ts +4 -0
  9. package/dist/agent/index.d.ts.map +1 -0
  10. package/dist/agent/index.js +4 -0
  11. package/dist/agent/index.js.map +1 -0
  12. package/dist/agent/prompt.d.ts +9 -0
  13. package/dist/agent/prompt.d.ts.map +1 -0
  14. package/dist/agent/prompt.js +15 -0
  15. package/dist/agent/prompt.js.map +1 -0
  16. package/dist/agent/result.d.ts +16 -0
  17. package/dist/agent/result.d.ts.map +1 -0
  18. package/dist/agent/result.js +56 -0
  19. package/dist/agent/result.js.map +1 -0
  20. package/dist/args.d.ts +27 -0
  21. package/dist/args.d.ts.map +1 -0
  22. package/dist/args.js +25 -0
  23. package/dist/args.js.map +1 -0
  24. package/dist/backend/container.d.ts +18 -0
  25. package/dist/backend/container.d.ts.map +1 -0
  26. package/dist/backend/container.js +70 -0
  27. package/dist/backend/container.js.map +1 -0
  28. package/dist/backend/docker.d.ts +22 -0
  29. package/dist/backend/docker.d.ts.map +1 -0
  30. package/dist/backend/docker.js +38 -0
  31. package/dist/backend/docker.js.map +1 -0
  32. package/dist/backend/fs.d.ts +9 -0
  33. package/dist/backend/fs.d.ts.map +1 -0
  34. package/dist/backend/fs.js +21 -0
  35. package/dist/backend/fs.js.map +1 -0
  36. package/dist/backend/index.d.ts +7 -0
  37. package/dist/backend/index.d.ts.map +1 -0
  38. package/dist/backend/index.js +6 -0
  39. package/dist/backend/index.js.map +1 -0
  40. package/dist/backend/local-worktree.d.ts +17 -0
  41. package/dist/backend/local-worktree.d.ts.map +1 -0
  42. package/dist/backend/local-worktree.js +51 -0
  43. package/dist/backend/local-worktree.js.map +1 -0
  44. package/dist/backend/proc.d.ts +24 -0
  45. package/dist/backend/proc.d.ts.map +1 -0
  46. package/dist/backend/proc.js +103 -0
  47. package/dist/backend/proc.js.map +1 -0
  48. package/dist/backend/types.d.ts +75 -0
  49. package/dist/backend/types.d.ts.map +1 -0
  50. package/dist/backend/types.js +12 -0
  51. package/dist/backend/types.js.map +1 -0
  52. package/dist/bin.d.ts +3 -0
  53. package/dist/bin.d.ts.map +1 -0
  54. package/dist/bin.js +10 -0
  55. package/dist/bin.js.map +1 -0
  56. package/dist/board/index.d.ts +4 -0
  57. package/dist/board/index.d.ts.map +1 -0
  58. package/dist/board/index.js +4 -0
  59. package/dist/board/index.js.map +1 -0
  60. package/dist/board/page.d.ts +3 -0
  61. package/dist/board/page.d.ts.map +1 -0
  62. package/dist/board/page.js +55 -0
  63. package/dist/board/page.js.map +1 -0
  64. package/dist/board/server.d.ts +36 -0
  65. package/dist/board/server.d.ts.map +1 -0
  66. package/dist/board/server.js +110 -0
  67. package/dist/board/server.js.map +1 -0
  68. package/dist/board/stats.d.ts +26 -0
  69. package/dist/board/stats.d.ts.map +1 -0
  70. package/dist/board/stats.js +57 -0
  71. package/dist/board/stats.js.map +1 -0
  72. package/dist/cli/commands.d.ts +39 -0
  73. package/dist/cli/commands.d.ts.map +1 -0
  74. package/dist/cli/commands.js +224 -0
  75. package/dist/cli/commands.js.map +1 -0
  76. package/dist/cli.d.ts +16 -0
  77. package/dist/cli.d.ts.map +1 -0
  78. package/dist/cli.js +45 -0
  79. package/dist/cli.js.map +1 -0
  80. package/dist/commands/help.d.ts +6 -0
  81. package/dist/commands/help.d.ts.map +1 -0
  82. package/dist/commands/help.js +29 -0
  83. package/dist/commands/help.js.map +1 -0
  84. package/dist/config/duration.d.ts +14 -0
  85. package/dist/config/duration.d.ts.map +1 -0
  86. package/dist/config/duration.js +25 -0
  87. package/dist/config/duration.js.map +1 -0
  88. package/dist/config/index.d.ts +5 -0
  89. package/dist/config/index.d.ts.map +1 -0
  90. package/dist/config/index.js +4 -0
  91. package/dist/config/index.js.map +1 -0
  92. package/dist/config/load.d.ts +26 -0
  93. package/dist/config/load.d.ts.map +1 -0
  94. package/dist/config/load.js +306 -0
  95. package/dist/config/load.js.map +1 -0
  96. package/dist/config/result.d.ts +18 -0
  97. package/dist/config/result.d.ts.map +1 -0
  98. package/dist/config/result.js +7 -0
  99. package/dist/config/result.js.map +1 -0
  100. package/dist/config/schema.d.ts +77 -0
  101. package/dist/config/schema.d.ts.map +1 -0
  102. package/dist/config/schema.js +35 -0
  103. package/dist/config/schema.js.map +1 -0
  104. package/dist/factory/build.d.ts +39 -0
  105. package/dist/factory/build.d.ts.map +1 -0
  106. package/dist/factory/build.js +85 -0
  107. package/dist/factory/build.js.map +1 -0
  108. package/dist/gate/gate.d.ts +12 -0
  109. package/dist/gate/gate.d.ts.map +1 -0
  110. package/dist/gate/gate.js +22 -0
  111. package/dist/gate/gate.js.map +1 -0
  112. package/dist/gate/index.d.ts +2 -0
  113. package/dist/gate/index.d.ts.map +1 -0
  114. package/dist/gate/index.js +2 -0
  115. package/dist/gate/index.js.map +1 -0
  116. package/dist/global/index.d.ts +3 -0
  117. package/dist/global/index.d.ts.map +1 -0
  118. package/dist/global/index.js +3 -0
  119. package/dist/global/index.js.map +1 -0
  120. package/dist/global/stage.d.ts +13 -0
  121. package/dist/global/stage.d.ts.map +1 -0
  122. package/dist/global/stage.js +24 -0
  123. package/dist/global/stage.js.map +1 -0
  124. package/dist/global/store.d.ts +30 -0
  125. package/dist/global/store.d.ts.map +1 -0
  126. package/dist/global/store.js +65 -0
  127. package/dist/global/store.js.map +1 -0
  128. package/dist/lock/file-lock.d.ts +16 -0
  129. package/dist/lock/file-lock.d.ts.map +1 -0
  130. package/dist/lock/file-lock.js +51 -0
  131. package/dist/lock/file-lock.js.map +1 -0
  132. package/dist/loop/branch.d.ts +14 -0
  133. package/dist/loop/branch.d.ts.map +1 -0
  134. package/dist/loop/branch.js +24 -0
  135. package/dist/loop/branch.js.map +1 -0
  136. package/dist/loop/engine.d.ts +37 -0
  137. package/dist/loop/engine.d.ts.map +1 -0
  138. package/dist/loop/engine.js +204 -0
  139. package/dist/loop/engine.js.map +1 -0
  140. package/dist/loop/index.d.ts +6 -0
  141. package/dist/loop/index.d.ts.map +1 -0
  142. package/dist/loop/index.js +3 -0
  143. package/dist/loop/index.js.map +1 -0
  144. package/dist/loop/ports.d.ts +97 -0
  145. package/dist/loop/ports.d.ts.map +1 -0
  146. package/dist/loop/ports.js +2 -0
  147. package/dist/loop/ports.js.map +1 -0
  148. package/dist/loop/record.d.ts +26 -0
  149. package/dist/loop/record.d.ts.map +1 -0
  150. package/dist/loop/record.js +2 -0
  151. package/dist/loop/record.js.map +1 -0
  152. package/dist/publish/gh.d.ts +24 -0
  153. package/dist/publish/gh.d.ts.map +1 -0
  154. package/dist/publish/gh.js +109 -0
  155. package/dist/publish/gh.js.map +1 -0
  156. package/dist/publish/githost.d.ts +54 -0
  157. package/dist/publish/githost.d.ts.map +1 -0
  158. package/dist/publish/githost.js +33 -0
  159. package/dist/publish/githost.js.map +1 -0
  160. package/dist/publish/github-publisher.d.ts +30 -0
  161. package/dist/publish/github-publisher.d.ts.map +1 -0
  162. package/dist/publish/github-publisher.js +51 -0
  163. package/dist/publish/github-publisher.js.map +1 -0
  164. package/dist/publish/index.d.ts +4 -0
  165. package/dist/publish/index.d.ts.map +1 -0
  166. package/dist/publish/index.js +4 -0
  167. package/dist/publish/index.js.map +1 -0
  168. package/dist/respond/index.d.ts +4 -0
  169. package/dist/respond/index.d.ts.map +1 -0
  170. package/dist/respond/index.js +4 -0
  171. package/dist/respond/index.js.map +1 -0
  172. package/dist/respond/respond.d.ts +42 -0
  173. package/dist/respond/respond.d.ts.map +1 -0
  174. package/dist/respond/respond.js +128 -0
  175. package/dist/respond/respond.js.map +1 -0
  176. package/dist/respond/select.d.ts +22 -0
  177. package/dist/respond/select.d.ts.map +1 -0
  178. package/dist/respond/select.js +31 -0
  179. package/dist/respond/select.js.map +1 -0
  180. package/dist/respond/store.d.ts +25 -0
  181. package/dist/respond/store.d.ts.map +1 -0
  182. package/dist/respond/store.js +49 -0
  183. package/dist/respond/store.js.map +1 -0
  184. package/dist/secrets/redact.d.ts +11 -0
  185. package/dist/secrets/redact.d.ts.map +1 -0
  186. package/dist/secrets/redact.js +21 -0
  187. package/dist/secrets/redact.js.map +1 -0
  188. package/dist/source/index.d.ts +2 -0
  189. package/dist/source/index.d.ts.map +1 -0
  190. package/dist/source/index.js +2 -0
  191. package/dist/source/index.js.map +1 -0
  192. package/dist/source/linear.d.ts +61 -0
  193. package/dist/source/linear.d.ts.map +1 -0
  194. package/dist/source/linear.js +166 -0
  195. package/dist/source/linear.js.map +1 -0
  196. package/dist/store/events.d.ts +105 -0
  197. package/dist/store/events.d.ts.map +1 -0
  198. package/dist/store/events.js +64 -0
  199. package/dist/store/events.js.map +1 -0
  200. package/dist/store/file-store.d.ts +49 -0
  201. package/dist/store/file-store.d.ts.map +1 -0
  202. package/dist/store/file-store.js +188 -0
  203. package/dist/store/file-store.js.map +1 -0
  204. package/dist/store/index.d.ts +3 -0
  205. package/dist/store/index.d.ts.map +1 -0
  206. package/dist/store/index.js +3 -0
  207. package/dist/store/index.js.map +1 -0
  208. package/dist/version.d.ts +3 -0
  209. package/dist/version.d.ts.map +1 -0
  210. package/dist/version.js +21 -0
  211. package/dist/version.js.map +1 -0
  212. package/package.json +52 -0
  213. package/templates/content-loop/README.md +23 -0
  214. package/templates/content-loop/ghostrail.toml +36 -0
  215. package/templates/content-loop/prompts/draft.md +29 -0
  216. package/templates/fix-bugs-local/README.md +23 -0
  217. package/templates/fix-bugs-local/ghostrail.toml +37 -0
  218. package/templates/fix-bugs-local/prompts/fix-bug.md +27 -0
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 2026 Timothy Jordan
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/NOTICE ADDED
@@ -0,0 +1,16 @@
1
+ Ghostrail
2
+ Copyright 2026 Timothy Jordan
3
+
4
+ This product includes software developed by Timothy Jordan and the Ghostrail
5
+ contributors.
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
8
+ this file except in compliance with the License. You may obtain a copy of the
9
+ License at:
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software distributed
14
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
15
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
16
+ specific language governing permissions and limitations under the License.
package/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # Ghostrail — open source software factory for coding agents
2
+
3
+ Config-driven loops, pluggable isolation backends (worktree, container, Firecracker, E2B), and a human merge gate. One light left on, on rails that hold.
4
+
5
+ Ghostrail turns a repo into a factory by dropping in one config file and one prompt. It finds eligible work in your tracker, isolates it, runs a sandboxed coding agent that only writes files, gates the result against a mirror of your CI, and opens a pull request. It never merges. That stays your call.
6
+
7
+ > **Status: pre-alpha.** Phase 0 (the MVP that self-hosts and replaces a bespoke bash factory) is complete: the config-driven loop, the Linear source, the claude-code agent, the worktree and container backends, the gate, the git publisher, the respond pass, the run store, and the board all ship. See [`SPEC.md`](./SPEC.md) for the design.
8
+
9
+ ## Why
10
+
11
+ A software factory is thin glue over three primitive layers: where work comes from, what agent does the work, and where the work runs in isolation. Most people rebuild that glue per repo. Ghostrail extracts it once, so the tracker, the agent job, the gate, and the isolation backend are all configuration:
12
+
13
+ - **Config-driven.** A `ghostrail.toml` plus a prompt file is the whole factory.
14
+ - **Pluggable backends.** `local-worktree` and `container-per-run` ship first-class; Firecracker, E2B, and remote sandboxes are adapters behind the same five-verb interface.
15
+ - **Pluggable agents.** Claude Code headless is the day-one agent, behind an `[agent]` seam so other agents can slot in.
16
+ - **Local and simple by default.** The quickstart runs on your own hardware with zero infrastructure and no additional cost. Cloud backends and a hosted board are opt-in.
17
+ - **Human merge gate.** `auto_merge` defaults to false. A person owns every merge.
18
+
19
+ ## Quickstart
20
+
21
+ ```bash
22
+ npm i -g ghostrail
23
+ ghostrail init fix-bugs-local # or: content-loop
24
+ export LINEAR_API_KEY=... # a Linear personal API key; gh must be authed
25
+ ghostrail run # one tick: claim, isolate, run, gate, open PRs
26
+ ghostrail respond # fold new human PR comments back into branches
27
+ ghostrail board # watch runs at http://127.0.0.1:4369/
28
+ ```
29
+
30
+ `ghostrail artifacts` lists the shared references in your global store
31
+ (`~/.config/ghostrail/artifacts/`), staged into each run so the same voice and
32
+ rules apply across every factory instance.
33
+
34
+ ## Self-host and cutover
35
+
36
+ Ghostrail builds itself: [`ghostrail.toml`](./ghostrail.toml) +
37
+ [`prompts/fix-bug.md`](./prompts/fix-bug.md) point the factory at its own repo.
38
+ To replace the bespoke bash factories in `echotime`, `tjwrite`, and `research`,
39
+ see [`docs/cutover.md`](./docs/cutover.md) and the configs in
40
+ [`examples/`](./examples/).
41
+
42
+ ## Development
43
+
44
+ Requires Node 22+ and pnpm (via [corepack](https://nodejs.org/api/corepack.html): `corepack enable`).
45
+
46
+ ```bash
47
+ pnpm install
48
+ pnpm test:unit # run the unit tests
49
+ pnpm typecheck # type-check src + tests
50
+ pnpm lint # lint + format check (Biome)
51
+ pnpm build # compile to dist/
52
+ ```
53
+
54
+ ## License
55
+
56
+ [Apache-2.0](./LICENSE).
@@ -0,0 +1,37 @@
1
+ import type { Agent, AgentContext, AgentOutcome } from "../loop/ports.js";
2
+ /** Path, relative to the workspace root, where the agent writes its result. */
3
+ export declare const RESULT_PATH = ".ghostrail/result.json";
4
+ export interface ClaudeArgsOptions {
5
+ /** The rendered prompt text (passed as the positional argument to `-p`). */
6
+ prompt: string;
7
+ /** Tools the agent may use; joined comma-separated for `--allowedTools`. */
8
+ allowedTools: readonly string[];
9
+ /** Directory to grant access to via `--add-dir` (the workspace root, "."). */
10
+ addDir: string;
11
+ /** `--output-format`; defaults to `json`. */
12
+ outputFormat?: "text" | "json" | "stream-json";
13
+ /** `--permission-mode`; defaults to `acceptEdits`. */
14
+ permissionMode?: string;
15
+ /** `--max-budget-usd`, when set. */
16
+ maxBudgetUsd?: number;
17
+ /** `--model`, when set. */
18
+ model?: string;
19
+ }
20
+ /**
21
+ * Build the `claude` CLI arguments (everything after the binary) for a headless
22
+ * run. Flags confirmed against Claude Code: `-p` takes the prompt positionally,
23
+ * `--allowedTools` is a single comma-separated value, and `--max-budget-usd`
24
+ * caps spend. The argument order is fixed and deterministic.
25
+ */
26
+ export declare function buildClaudeArgs(options: ClaudeArgsOptions): string[];
27
+ /**
28
+ * The claude-code headless agent adapter. Reads the prompt file from the
29
+ * workspace, renders it with the item, and runs `claude -p` through the backend
30
+ * so it executes wherever the workspace lives. The agent only ever writes files;
31
+ * it reports its outcome by writing {@link RESULT_PATH}, which this adapter reads
32
+ * and parses. Budget and timeout come from the guardrails.
33
+ */
34
+ export declare class ClaudeCodeAgent implements Agent {
35
+ run(context: AgentContext): Promise<AgentOutcome>;
36
+ }
37
+ //# sourceMappingURL=claude-code.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-code.d.ts","sourceRoot":"","sources":["../../src/agent/claude-code.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAI1E,+EAA+E;AAC/E,eAAO,MAAM,WAAW,2BAA2B,CAAC;AAEpD,MAAM,WAAW,iBAAiB;IAChC,4EAA4E;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,8EAA8E;IAC9E,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,CAAC;IAC/C,sDAAsD;IACtD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oCAAoC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,EAAE,CAqBpE;AAYD;;;;;;GAMG;AACH,qBAAa,eAAgB,YAAW,KAAK;IACrC,GAAG,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;CA+BxD"}
@@ -0,0 +1,74 @@
1
+ import { renderPrompt } from "./prompt.js";
2
+ import { parseAgentResult } from "./result.js";
3
+ /** Path, relative to the workspace root, where the agent writes its result. */
4
+ export const RESULT_PATH = ".ghostrail/result.json";
5
+ /**
6
+ * Build the `claude` CLI arguments (everything after the binary) for a headless
7
+ * run. Flags confirmed against Claude Code: `-p` takes the prompt positionally,
8
+ * `--allowedTools` is a single comma-separated value, and `--max-budget-usd`
9
+ * caps spend. The argument order is fixed and deterministic.
10
+ */
11
+ export function buildClaudeArgs(options) {
12
+ const args = [
13
+ "-p",
14
+ options.prompt,
15
+ "--output-format",
16
+ options.outputFormat ?? "json",
17
+ "--permission-mode",
18
+ options.permissionMode ?? "acceptEdits",
19
+ "--add-dir",
20
+ options.addDir,
21
+ ];
22
+ if (options.allowedTools.length > 0) {
23
+ args.push("--allowedTools", options.allowedTools.join(","));
24
+ }
25
+ if (options.maxBudgetUsd !== undefined) {
26
+ args.push("--max-budget-usd", String(options.maxBudgetUsd));
27
+ }
28
+ if (options.model !== undefined) {
29
+ args.push("--model", options.model);
30
+ }
31
+ return args;
32
+ }
33
+ /** Read a workspace file through the backend; undefined if it does not exist. */
34
+ async function readFile(backend, workspace, path) {
35
+ const result = await backend.exec(workspace, ["cat", path]);
36
+ return result.exitCode === 0 ? result.stdout : undefined;
37
+ }
38
+ /**
39
+ * The claude-code headless agent adapter. Reads the prompt file from the
40
+ * workspace, renders it with the item, and runs `claude -p` through the backend
41
+ * so it executes wherever the workspace lives. The agent only ever writes files;
42
+ * it reports its outcome by writing {@link RESULT_PATH}, which this adapter reads
43
+ * and parses. Budget and timeout come from the guardrails.
44
+ */
45
+ export class ClaudeCodeAgent {
46
+ async run(context) {
47
+ const { backend, workspace, item, agent, guardrails } = context;
48
+ const template = await readFile(backend, workspace, agent.prompt);
49
+ if (template === undefined) {
50
+ return { status: "failed", error: `could not read prompt file: ${agent.prompt}` };
51
+ }
52
+ const args = buildClaudeArgs({
53
+ prompt: renderPrompt(template, item),
54
+ allowedTools: agent.allowedTools,
55
+ addDir: ".",
56
+ maxBudgetUsd: guardrails.budgetUsdPerItem,
57
+ });
58
+ const run = await backend.exec(workspace, ["claude", ...args], {
59
+ timeoutMs: guardrails.timeoutMs,
60
+ });
61
+ if (run.timedOut) {
62
+ return { status: "failed", error: "agent timed out" };
63
+ }
64
+ const raw = await readFile(backend, workspace, RESULT_PATH);
65
+ if (raw !== undefined && raw.trim().length > 0) {
66
+ return parseAgentResult(raw);
67
+ }
68
+ if (run.exitCode !== 0) {
69
+ return { status: "failed", error: `claude exited ${run.exitCode}: ${run.stderr.trim()}` };
70
+ }
71
+ return { status: "noop" };
72
+ }
73
+ }
74
+ //# sourceMappingURL=claude-code.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-code.js","sourceRoot":"","sources":["../../src/agent/claude-code.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,4 @@
1
+ export { buildClaudeArgs, type ClaudeArgsOptions, ClaudeCodeAgent, RESULT_PATH, } from "./claude-code.js";
2
+ export { renderPrompt } from "./prompt.js";
3
+ export { parseAgentResult } from "./result.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,KAAK,iBAAiB,EACtB,eAAe,EACf,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { buildClaudeArgs, ClaudeCodeAgent, RESULT_PATH, } from "./claude-code.js";
2
+ export { renderPrompt } from "./prompt.js";
3
+ export { parseAgentResult } from "./result.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAEf,eAAe,EACf,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { WorkItem } from "../loop/ports.js";
2
+ /**
3
+ * Render a prompt template for an item by replacing the placeholders
4
+ * `{{id}}`, `{{title}}`, and `{{url}}` with the item's fields (every occurrence).
5
+ * A missing `url` renders as an empty string. Unknown `{{...}}` placeholders are
6
+ * left untouched.
7
+ */
8
+ export declare function renderPrompt(template: string, item: WorkItem): string;
9
+ //# sourceMappingURL=prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/agent/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,CAOrE"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Render a prompt template for an item by replacing the placeholders
3
+ * `{{id}}`, `{{title}}`, and `{{url}}` with the item's fields (every occurrence).
4
+ * A missing `url` renders as an empty string. Unknown `{{...}}` placeholders are
5
+ * left untouched.
6
+ */
7
+ export function renderPrompt(template, item) {
8
+ const values = {
9
+ id: item.id,
10
+ title: item.title,
11
+ url: item.url ?? "",
12
+ };
13
+ return template.replace(/\{\{(id|title|url)\}\}/g, (_match, key) => values[key] ?? "");
14
+ }
15
+ //# sourceMappingURL=prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/agent/prompt.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,QAAgB,EAAE,IAAc;IAC3D,MAAM,MAAM,GAA2B;QACrC,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,EAAE;KACpB,CAAC;IACF,OAAO,QAAQ,CAAC,OAAO,CAAC,yBAAyB,EAAE,CAAC,MAAM,EAAE,GAAW,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;AACjG,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { AgentOutcome } from "../loop/ports.js";
2
+ /**
3
+ * Parse the result document the agent writes at the end of a run into an
4
+ * {@link AgentOutcome}. The document is JSON with a `status` of `done`,
5
+ * `blocked`, `failed`, or `noop`:
6
+ * - `done` requires a string `summary` (missing/empty becomes "").
7
+ * - `blocked` requires a string `questions`.
8
+ * - `failed` requires a string `error`.
9
+ * - `noop` needs nothing else.
10
+ *
11
+ * Anything unparseable, missing a valid `status`, or missing the field its
12
+ * status requires is reported as a `failed` outcome describing the problem, so a
13
+ * malformed result never crashes the loop.
14
+ */
15
+ export declare function parseAgentResult(raw: string): AgentOutcome;
16
+ //# sourceMappingURL=result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../src/agent/result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAuC1D"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Parse the result document the agent writes at the end of a run into an
3
+ * {@link AgentOutcome}. The document is JSON with a `status` of `done`,
4
+ * `blocked`, `failed`, or `noop`:
5
+ * - `done` requires a string `summary` (missing/empty becomes "").
6
+ * - `blocked` requires a string `questions`.
7
+ * - `failed` requires a string `error`.
8
+ * - `noop` needs nothing else.
9
+ *
10
+ * Anything unparseable, missing a valid `status`, or missing the field its
11
+ * status requires is reported as a `failed` outcome describing the problem, so a
12
+ * malformed result never crashes the loop.
13
+ */
14
+ export function parseAgentResult(raw) {
15
+ let value;
16
+ try {
17
+ value = JSON.parse(raw);
18
+ }
19
+ catch {
20
+ return { status: "failed", error: "agent result was not valid JSON" };
21
+ }
22
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
23
+ return { status: "failed", error: "agent result was not a JSON object" };
24
+ }
25
+ const record = value;
26
+ const status = record.status;
27
+ switch (status) {
28
+ case "done":
29
+ return { status: "done", summary: asString(record.summary) };
30
+ case "noop":
31
+ return { status: "noop" };
32
+ case "blocked": {
33
+ const questions = record.questions;
34
+ if (typeof questions !== "string" || questions.length === 0) {
35
+ return { status: "failed", error: "agent result 'blocked' is missing 'questions'" };
36
+ }
37
+ return { status: "blocked", questions };
38
+ }
39
+ case "failed": {
40
+ const error = record.error;
41
+ if (typeof error !== "string" || error.length === 0) {
42
+ return { status: "failed", error: "agent reported failure without an 'error' message" };
43
+ }
44
+ return { status: "failed", error };
45
+ }
46
+ default:
47
+ return {
48
+ status: "failed",
49
+ error: `agent result had an unknown status: ${JSON.stringify(status)}`,
50
+ };
51
+ }
52
+ }
53
+ function asString(value) {
54
+ return typeof value === "string" ? value : "";
55
+ }
56
+ //# sourceMappingURL=result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/agent/result.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAW;IAC1C,IAAI,KAAc,CAAC;IACnB,IAAI,CAAC;QACH,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,iCAAiC,EAAE,CAAC;IACxE,CAAC;IACD,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACxE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,oCAAoC,EAAE,CAAC;IAC3E,CAAC;IAED,MAAM,MAAM,GAAG,KAAgC,CAAC;IAChD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAE7B,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,MAAM;YACT,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/D,KAAK,MAAM;YACT,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QAC5B,KAAK,SAAS,CAAC,CAAC,CAAC;YACf,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;YACnC,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC5D,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,+CAA+C,EAAE,CAAC;YACtF,CAAC;YACD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;QAC1C,CAAC;QACD,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;YAC3B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACpD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,mDAAmD,EAAE,CAAC;YAC1F,CAAC;YACD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QACrC,CAAC;QACD;YACE,OAAO;gBACL,MAAM,EAAE,QAAQ;gBAChB,KAAK,EAAE,uCAAuC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE;aACvE,CAAC;IACN,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAChD,CAAC"}
package/dist/args.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ /**
2
+ * A parsed top-level ghostrail command.
3
+ *
4
+ * The Phase 0 scaffold recognizes only `help` and `version`; the loop
5
+ * subcommands (`run`, `respond`, `board`, ...) arrive in later sub-issues.
6
+ */
7
+ export type ParsedCommand = {
8
+ command: "version";
9
+ } | {
10
+ command: "help";
11
+ } | {
12
+ command: "unknown";
13
+ raw: string;
14
+ };
15
+ /**
16
+ * Parse ghostrail CLI arguments (argv with the node binary and script path
17
+ * already stripped) into a single command.
18
+ *
19
+ * Intent:
20
+ * - No arguments shows help.
21
+ * - The left-most recognized token wins: `--version`/`-v`/`version` report the
22
+ * version, `--help`/`-h`/`help` show help.
23
+ * - If no token is recognized, the command is `unknown` and the first token is
24
+ * echoed back so the caller can name it in an error.
25
+ */
26
+ export declare function parseArgs(argv: readonly string[]): ParsedCommand;
27
+ //# sourceMappingURL=args.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GACrB;IAAE,OAAO,EAAE,SAAS,CAAA;CAAE,GACtB;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GACnB;IAAE,OAAO,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAKxC;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,aAAa,CAShE"}
package/dist/args.js ADDED
@@ -0,0 +1,25 @@
1
+ const VERSION_TOKENS = new Set(["--version", "-v", "version"]);
2
+ const HELP_TOKENS = new Set(["--help", "-h", "help"]);
3
+ /**
4
+ * Parse ghostrail CLI arguments (argv with the node binary and script path
5
+ * already stripped) into a single command.
6
+ *
7
+ * Intent:
8
+ * - No arguments shows help.
9
+ * - The left-most recognized token wins: `--version`/`-v`/`version` report the
10
+ * version, `--help`/`-h`/`help` show help.
11
+ * - If no token is recognized, the command is `unknown` and the first token is
12
+ * echoed back so the caller can name it in an error.
13
+ */
14
+ export function parseArgs(argv) {
15
+ if (argv.length === 0)
16
+ return { command: "help" };
17
+ for (const arg of argv) {
18
+ if (VERSION_TOKENS.has(arg))
19
+ return { command: "version" };
20
+ if (HELP_TOKENS.has(arg))
21
+ return { command: "help" };
22
+ }
23
+ return { command: "unknown", raw: argv[0] ?? "" };
24
+ }
25
+ //# sourceMappingURL=args.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"args.js","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAWA,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;AAC/D,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;AAEtD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,SAAS,CAAC,IAAuB;IAC/C,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAElD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;QAC3D,IAAI,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IACvD,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;AACpD,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { Backend, ExecOptions, ExecResult, LogLine, ProvisionSpec, Workspace } from "./types.js";
2
+ /**
3
+ * The recommended default for a shared tool: a fresh, disposable container per
4
+ * item, on its own branch, with a clean filesystem and nothing bleeding between
5
+ * runs. The repo is cloned on the host onto the new branch and copied into the
6
+ * container, so the image only needs a shell (not git); commands run via
7
+ * `docker exec`. Teardown force-removes the container.
8
+ */
9
+ export declare class ContainerBackend implements Backend {
10
+ readonly kind = "container";
11
+ /** True if the Docker CLI and daemon are reachable. */
12
+ static isAvailable(): Promise<boolean>;
13
+ provision(spec: ProvisionSpec): Promise<Workspace>;
14
+ exec(workspace: Workspace, command: readonly string[], options?: ExecOptions): Promise<ExecResult>;
15
+ stream(workspace: Workspace, command: readonly string[], onLog: (line: LogLine) => void, options?: ExecOptions): Promise<ExecResult>;
16
+ teardown(workspace: Workspace): Promise<void>;
17
+ }
18
+ //# sourceMappingURL=container.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/backend/container.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,OAAO,EACP,WAAW,EACX,UAAU,EACV,OAAO,EACP,aAAa,EACb,SAAS,EACV,MAAM,YAAY,CAAC;AAQpB;;;;;;GAMG;AACH,qBAAa,gBAAiB,YAAW,OAAO;IAC9C,QAAQ,CAAC,IAAI,eAAQ;IAErB,uDAAuD;WAC1C,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAKtC,SAAS,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,SAAS,CAAC;IAiCxD,IAAI,CACF,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,UAAU,CAAC;IAItB,MAAM,CACJ,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,KAAK,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,EAC9B,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,UAAU,CAAC;IAQhB,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;CAGpD"}