@ai-hero/sandcastle 0.6.5 → 0.6.6

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 (227) hide show
  1. package/README.md +123 -54
  2. package/dist/{MountConfig.d.ts → MountConfig-CmXclHA5.d.ts} +3 -2
  3. package/dist/{SandboxProvider.d.ts → SandboxProvider-EkSMuBp8.d.ts} +25 -39
  4. package/dist/chunk-72UVAC7B.js +99 -0
  5. package/dist/chunk-72UVAC7B.js.map +1 -0
  6. package/dist/chunk-BIWNFKGV.js +22 -0
  7. package/dist/chunk-BIWNFKGV.js.map +1 -0
  8. package/dist/chunk-NGBM7T3E.js +76 -0
  9. package/dist/chunk-NGBM7T3E.js.map +1 -0
  10. package/dist/chunk-Q5W3WQVU.js +25569 -0
  11. package/dist/chunk-Q5W3WQVU.js.map +1 -0
  12. package/dist/chunk-UPDEQ2U7.js +362 -0
  13. package/dist/chunk-UPDEQ2U7.js.map +1 -0
  14. package/dist/chunk-Z7O2WNRU.js +26934 -0
  15. package/dist/chunk-Z7O2WNRU.js.map +1 -0
  16. package/dist/index.d.ts +920 -22
  17. package/dist/index.js +3212 -9
  18. package/dist/index.js.map +1 -1
  19. package/dist/main.d.ts +0 -2
  20. package/dist/main.js +19256 -13
  21. package/dist/main.js.map +1 -1
  22. package/dist/mountUtils-CCA-bbpK.d.ts +25 -0
  23. package/dist/sandboxes/daytona.d.ts +8 -5
  24. package/dist/sandboxes/daytona.js +118 -124
  25. package/dist/sandboxes/daytona.js.map +1 -1
  26. package/dist/sandboxes/docker.d.ts +10 -8
  27. package/dist/sandboxes/docker.js +8 -255
  28. package/dist/sandboxes/docker.js.map +1 -1
  29. package/dist/sandboxes/no-sandbox.d.ts +7 -4
  30. package/dist/sandboxes/no-sandbox.js +6 -114
  31. package/dist/sandboxes/no-sandbox.js.map +1 -1
  32. package/dist/sandboxes/podman.d.ts +10 -8
  33. package/dist/sandboxes/podman.js +287 -297
  34. package/dist/sandboxes/podman.js.map +1 -1
  35. package/dist/sandboxes/vercel.d.ts +7 -4
  36. package/dist/sandboxes/vercel.js +144 -165
  37. package/dist/sandboxes/vercel.js.map +1 -1
  38. package/package.json +15 -14
  39. package/dist/AgentProvider.d.ts +0 -134
  40. package/dist/AgentProvider.d.ts.map +0 -1
  41. package/dist/AgentProvider.js +0 -647
  42. package/dist/AgentProvider.js.map +0 -1
  43. package/dist/AgentStreamEmitter.d.ts +0 -36
  44. package/dist/AgentStreamEmitter.d.ts.map +0 -1
  45. package/dist/AgentStreamEmitter.js +0 -21
  46. package/dist/AgentStreamEmitter.js.map +0 -1
  47. package/dist/CopyToWorktree.d.ts +0 -15
  48. package/dist/CopyToWorktree.d.ts.map +0 -1
  49. package/dist/CopyToWorktree.js +0 -60
  50. package/dist/CopyToWorktree.js.map +0 -1
  51. package/dist/Display.d.ts +0 -58
  52. package/dist/Display.d.ts.map +0 -1
  53. package/dist/Display.js +0 -142
  54. package/dist/Display.js.map +0 -1
  55. package/dist/DockerLifecycle.d.ts +0 -54
  56. package/dist/DockerLifecycle.d.ts.map +0 -1
  57. package/dist/DockerLifecycle.js +0 -123
  58. package/dist/DockerLifecycle.js.map +0 -1
  59. package/dist/EnvResolver.d.ts +0 -11
  60. package/dist/EnvResolver.d.ts.map +0 -1
  61. package/dist/EnvResolver.js +0 -63
  62. package/dist/EnvResolver.js.map +0 -1
  63. package/dist/ErrorHandler.d.ts +0 -15
  64. package/dist/ErrorHandler.d.ts.map +0 -1
  65. package/dist/ErrorHandler.js +0 -85
  66. package/dist/ErrorHandler.js.map +0 -1
  67. package/dist/InitService.d.ts +0 -92
  68. package/dist/InitService.d.ts.map +0 -1
  69. package/dist/InitService.js +0 -836
  70. package/dist/InitService.js.map +0 -1
  71. package/dist/MountConfig.d.ts.map +0 -1
  72. package/dist/MountConfig.js +0 -7
  73. package/dist/MountConfig.js.map +0 -1
  74. package/dist/Orchestrator.d.ts +0 -56
  75. package/dist/Orchestrator.d.ts.map +0 -1
  76. package/dist/Orchestrator.js +0 -293
  77. package/dist/Orchestrator.js.map +0 -1
  78. package/dist/Output.d.ts +0 -107
  79. package/dist/Output.d.ts.map +0 -1
  80. package/dist/Output.js +0 -95
  81. package/dist/Output.js.map +0 -1
  82. package/dist/PodmanLifecycle.d.ts +0 -17
  83. package/dist/PodmanLifecycle.d.ts.map +0 -1
  84. package/dist/PodmanLifecycle.js +0 -45
  85. package/dist/PodmanLifecycle.js.map +0 -1
  86. package/dist/PromptArgumentSubstitution.d.ts +0 -32
  87. package/dist/PromptArgumentSubstitution.d.ts.map +0 -1
  88. package/dist/PromptArgumentSubstitution.js +0 -104
  89. package/dist/PromptArgumentSubstitution.js.map +0 -1
  90. package/dist/PromptPreprocessor.d.ts +0 -15
  91. package/dist/PromptPreprocessor.d.ts.map +0 -1
  92. package/dist/PromptPreprocessor.js +0 -55
  93. package/dist/PromptPreprocessor.js.map +0 -1
  94. package/dist/PromptResolver.d.ts +0 -21
  95. package/dist/PromptResolver.d.ts.map +0 -1
  96. package/dist/PromptResolver.js +0 -27
  97. package/dist/PromptResolver.js.map +0 -1
  98. package/dist/RecoveryMessage.d.ts +0 -15
  99. package/dist/RecoveryMessage.d.ts.map +0 -1
  100. package/dist/RecoveryMessage.js +0 -81
  101. package/dist/RecoveryMessage.js.map +0 -1
  102. package/dist/SandboxFactory.d.ts +0 -90
  103. package/dist/SandboxFactory.d.ts.map +0 -1
  104. package/dist/SandboxFactory.js +0 -324
  105. package/dist/SandboxFactory.js.map +0 -1
  106. package/dist/SandboxLifecycle.d.ts +0 -65
  107. package/dist/SandboxLifecycle.d.ts.map +0 -1
  108. package/dist/SandboxLifecycle.js +0 -296
  109. package/dist/SandboxLifecycle.js.map +0 -1
  110. package/dist/SandboxProvider.d.ts.map +0 -1
  111. package/dist/SandboxProvider.js +0 -28
  112. package/dist/SandboxProvider.js.map +0 -1
  113. package/dist/SessionStore.d.ts +0 -110
  114. package/dist/SessionStore.d.ts.map +0 -1
  115. package/dist/SessionStore.js +0 -330
  116. package/dist/SessionStore.js.map +0 -1
  117. package/dist/TextDeltaBuffer.d.ts +0 -24
  118. package/dist/TextDeltaBuffer.d.ts.map +0 -1
  119. package/dist/TextDeltaBuffer.js +0 -68
  120. package/dist/TextDeltaBuffer.js.map +0 -1
  121. package/dist/WorktreeManager.d.ts +0 -79
  122. package/dist/WorktreeManager.d.ts.map +0 -1
  123. package/dist/WorktreeManager.js +0 -283
  124. package/dist/WorktreeManager.js.map +0 -1
  125. package/dist/boundedTail.d.ts +0 -48
  126. package/dist/boundedTail.d.ts.map +0 -1
  127. package/dist/boundedTail.js +0 -64
  128. package/dist/boundedTail.js.map +0 -1
  129. package/dist/cli.d.ts +0 -30
  130. package/dist/cli.d.ts.map +0 -1
  131. package/dist/cli.js +0 -340
  132. package/dist/cli.js.map +0 -1
  133. package/dist/createSandbox.d.ts +0 -154
  134. package/dist/createSandbox.d.ts.map +0 -1
  135. package/dist/createSandbox.js +0 -476
  136. package/dist/createSandbox.js.map +0 -1
  137. package/dist/createWorktree.d.ts +0 -154
  138. package/dist/createWorktree.d.ts.map +0 -1
  139. package/dist/createWorktree.js +0 -391
  140. package/dist/createWorktree.js.map +0 -1
  141. package/dist/errors.d.ts +0 -227
  142. package/dist/errors.d.ts.map +0 -1
  143. package/dist/errors.js +0 -81
  144. package/dist/errors.js.map +0 -1
  145. package/dist/extractStructuredOutput.d.ts +0 -23
  146. package/dist/extractStructuredOutput.d.ts.map +0 -1
  147. package/dist/extractStructuredOutput.js +0 -102
  148. package/dist/extractStructuredOutput.js.map +0 -1
  149. package/dist/index.d.ts.map +0 -1
  150. package/dist/interactive.d.ts +0 -74
  151. package/dist/interactive.d.ts.map +0 -1
  152. package/dist/interactive.js +0 -279
  153. package/dist/interactive.js.map +0 -1
  154. package/dist/main.d.ts.map +0 -1
  155. package/dist/mergeProviderEnv.d.ts +0 -13
  156. package/dist/mergeProviderEnv.d.ts.map +0 -1
  157. package/dist/mergeProviderEnv.js +0 -23
  158. package/dist/mergeProviderEnv.js.map +0 -1
  159. package/dist/mountUtils.d.ts +0 -146
  160. package/dist/mountUtils.d.ts.map +0 -1
  161. package/dist/mountUtils.js +0 -301
  162. package/dist/mountUtils.js.map +0 -1
  163. package/dist/raceAbortSignal.d.ts +0 -18
  164. package/dist/raceAbortSignal.d.ts.map +0 -1
  165. package/dist/raceAbortSignal.js +0 -32
  166. package/dist/raceAbortSignal.js.map +0 -1
  167. package/dist/resolveCwd.d.ts +0 -24
  168. package/dist/resolveCwd.d.ts.map +0 -1
  169. package/dist/resolveCwd.js +0 -32
  170. package/dist/resolveCwd.js.map +0 -1
  171. package/dist/resumePrecheck.d.ts +0 -26
  172. package/dist/resumePrecheck.d.ts.map +0 -1
  173. package/dist/resumePrecheck.js +0 -40
  174. package/dist/resumePrecheck.js.map +0 -1
  175. package/dist/run.d.ts +0 -216
  176. package/dist/run.d.ts.map +0 -1
  177. package/dist/run.js +0 -313
  178. package/dist/run.js.map +0 -1
  179. package/dist/sandboxExec.d.ts +0 -12
  180. package/dist/sandboxExec.d.ts.map +0 -1
  181. package/dist/sandboxExec.js +0 -26
  182. package/dist/sandboxExec.js.map +0 -1
  183. package/dist/sandboxes/daytona.d.ts.map +0 -1
  184. package/dist/sandboxes/docker.d.ts.map +0 -1
  185. package/dist/sandboxes/no-sandbox.d.ts.map +0 -1
  186. package/dist/sandboxes/podman.d.ts.map +0 -1
  187. package/dist/sandboxes/test-bind-mount.d.ts +0 -17
  188. package/dist/sandboxes/test-bind-mount.d.ts.map +0 -1
  189. package/dist/sandboxes/test-bind-mount.js +0 -92
  190. package/dist/sandboxes/test-bind-mount.js.map +0 -1
  191. package/dist/sandboxes/test-isolated.d.ts +0 -17
  192. package/dist/sandboxes/test-isolated.d.ts.map +0 -1
  193. package/dist/sandboxes/test-isolated.js +0 -98
  194. package/dist/sandboxes/test-isolated.js.map +0 -1
  195. package/dist/sandboxes/vercel.d.ts.map +0 -1
  196. package/dist/shutdownRegistry.d.ts +0 -30
  197. package/dist/shutdownRegistry.d.ts.map +0 -1
  198. package/dist/shutdownRegistry.js +0 -73
  199. package/dist/shutdownRegistry.js.map +0 -1
  200. package/dist/startSandbox.d.ts +0 -50
  201. package/dist/startSandbox.d.ts.map +0 -1
  202. package/dist/startSandbox.js +0 -117
  203. package/dist/startSandbox.js.map +0 -1
  204. package/dist/syncIn.d.ts +0 -24
  205. package/dist/syncIn.d.ts.map +0 -1
  206. package/dist/syncIn.js +0 -107
  207. package/dist/syncIn.js.map +0 -1
  208. package/dist/syncOut.d.ts +0 -27
  209. package/dist/syncOut.d.ts.map +0 -1
  210. package/dist/syncOut.js +0 -271
  211. package/dist/syncOut.js.map +0 -1
  212. package/dist/templates.d.ts +0 -2
  213. package/dist/templates.d.ts.map +0 -1
  214. package/dist/templates.js +0 -26
  215. package/dist/templates.js.map +0 -1
  216. package/dist/terminalCleanup.d.ts +0 -30
  217. package/dist/terminalCleanup.d.ts.map +0 -1
  218. package/dist/terminalCleanup.js +0 -37
  219. package/dist/terminalCleanup.js.map +0 -1
  220. package/dist/testSandbox.d.ts +0 -8
  221. package/dist/testSandbox.d.ts.map +0 -1
  222. package/dist/testSandbox.js +0 -109
  223. package/dist/testSandbox.js.map +0 -1
  224. package/dist/testSetup.d.ts +0 -2
  225. package/dist/testSetup.d.ts.map +0 -1
  226. package/dist/testSetup.js +0 -29
  227. package/dist/testSetup.js.map +0 -1
@@ -1,283 +0,0 @@
1
- import { Effect, Option } from "effect";
2
- import { FileSystem } from "@effect/platform";
3
- import { execFile } from "node:child_process";
4
- import { join, normalize } from "node:path";
5
- import { WorktreeError, WorktreeTimeoutError, withTimeout } from "./errors.js";
6
- const WORKTREE_TIMEOUT_MS = 30_000;
7
- /**
8
- * Git global flags that prevent `git worktree add -b` from writing upstream
9
- * tracking config to `.git/config`. Without these, a user's global
10
- * `branch.autoSetupMerge` or `push.autoSetupRemote` can cause a config write
11
- * that races with other processes holding `.git/config.lock`.
12
- */
13
- const NO_CONFIG_LOCK_FLAGS = [
14
- "-c",
15
- "branch.autoSetupMerge=false",
16
- "-c",
17
- "push.autoSetupRemote=false",
18
- ];
19
- /** Format a timestamp as YYYYMMDD-HHMMSS */
20
- const formatTimestamp = (date) => {
21
- const pad = (n) => String(n).padStart(2, "0");
22
- return (`${date.getFullYear()}${pad(date.getMonth() + 1)}${pad(date.getDate())}-` +
23
- `${pad(date.getHours())}${pad(date.getMinutes())}${pad(date.getSeconds())}`);
24
- };
25
- /** Sanitize a name for use in branch names and directory names. */
26
- export const sanitizeName = (name) => name.toLowerCase().replace(/[^a-z0-9]/g, "-");
27
- const execGit = (args, cwd) => Effect.async((resume) => {
28
- // Force the C locale so git emits English, machine-stable messages. Several
29
- // callers match git's stderr (e.g. "invalid reference") to decide control
30
- // flow; under a localized locale gettext translates those strings and the
31
- // matches silently fail, breaking worktree creation (issue #595).
32
- execFile("git", args, { cwd, env: { ...process.env, LC_ALL: "C" } }, (error, stdout, stderr) => {
33
- if (error) {
34
- resume(Effect.fail(new WorktreeError({
35
- message: stderr?.trim() || error.message,
36
- })));
37
- }
38
- else {
39
- resume(Effect.succeed(stdout));
40
- }
41
- });
42
- });
43
- /**
44
- * Generates a temporary branch name.
45
- * When name is provided: `sandcastle/<sanitized-name>/<YYYYMMDD-HHMMSS>`.
46
- * Otherwise: `sandcastle/<YYYYMMDD-HHMMSS>`.
47
- */
48
- export const generateTempBranchName = (name) => {
49
- const ts = formatTimestamp(new Date());
50
- if (name) {
51
- return `sandcastle/${sanitizeName(name)}/${ts}`;
52
- }
53
- return `sandcastle/${ts}`;
54
- };
55
- /** Returns the name of the currently checked-out branch in the given repo directory. */
56
- export const getCurrentBranch = (repoDir) => execGit(["rev-parse", "--abbrev-ref", "HEAD"], repoDir).pipe(Effect.map((output) => output.trim()));
57
- /**
58
- * Normalizes path separators to forward slashes.
59
- *
60
- * `git worktree list --porcelain` reports paths with forward slashes on every
61
- * platform, but `node:path.join` produces backslashes on Windows. Comparing
62
- * the two without normalizing fails on Windows, so all path comparisons in
63
- * this module run both sides through this first.
64
- */
65
- const normalizePath = (p) => p.replace(/\\/g, "/");
66
- /**
67
- * Finds an existing worktree that collides with `branch` or `worktreePath`.
68
- *
69
- * Matches by branch first, then falls back to a path match — covering the
70
- * mid-rebase detached-HEAD case where git reports a `null` branch. The path
71
- * fallback normalizes separators so it works on Windows.
72
- */
73
- export const findCollidingWorktree = (existing, branch, worktreePath) => existing.find((wt) => wt.branch === branch) ??
74
- existing.find((wt) => normalizePath(wt.path) === normalizePath(worktreePath));
75
- /**
76
- * Whether `worktreePath` lives under `worktreesDir` (i.e. is a worktree managed
77
- * by sandcastle rather than the main working tree or an external worktree).
78
- * Separators are normalized so the check holds on Windows.
79
- */
80
- export const isManagedWorktreePath = (worktreePath, worktreesDir) => normalizePath(worktreePath).startsWith(normalizePath(worktreesDir));
81
- /**
82
- * Whether a directory entry under `.sandcastle/worktrees/` is orphaned — not
83
- * present in the set of active worktree paths reported by git. Both sides are
84
- * normalized so paths from `join` (backslashes on Windows) match git's
85
- * forward-slash output.
86
- */
87
- export const isOrphanedWorktreePath = (entryPath, activeWorktreePaths) => {
88
- const normalizedEntry = normalizePath(entryPath);
89
- for (const active of activeWorktreePaths) {
90
- if (normalizePath(active) === normalizedEntry)
91
- return false;
92
- }
93
- return true;
94
- };
95
- /** Parses `git worktree list --porcelain` output into structured entries. */
96
- const listWorktrees = (repoDir) => execGit(["worktree", "list", "--porcelain"], repoDir).pipe(Effect.map((output) => {
97
- const entries = [];
98
- let currentPath = null;
99
- let currentBranch = null;
100
- for (const line of output.split("\n")) {
101
- if (line.startsWith("worktree ")) {
102
- if (currentPath !== null) {
103
- entries.push({ path: currentPath, branch: currentBranch });
104
- }
105
- currentPath = line.slice("worktree ".length).trim();
106
- currentBranch = null;
107
- }
108
- else if (line.startsWith("branch ")) {
109
- // "branch refs/heads/my-branch" -> "my-branch"
110
- currentBranch = line.slice("branch refs/heads/".length).trim();
111
- }
112
- }
113
- if (currentPath !== null) {
114
- entries.push({ path: currentPath, branch: currentBranch });
115
- }
116
- return entries;
117
- }));
118
- /**
119
- * Creates a git worktree at `.sandcastle/worktrees/<name>/`.
120
- *
121
- * - If `branch` is specified, checks out that branch.
122
- * - If not, creates a temporary `sandcastle/<timestamp>` branch.
123
- *
124
- * When `branch` collides with an existing managed worktree:
125
- * - Clean → reuses the existing worktree.
126
- * - Dirty (uncommitted changes) → reuses with a console warning (ADR 0003).
127
- *
128
- * Collisions with the main working tree or external worktrees always throw.
129
- */
130
- export const create = (repoDir, opts) => Effect.gen(function* () {
131
- const fs = yield* FileSystem.FileSystem;
132
- const worktreesDir = join(repoDir, ".sandcastle", "worktrees");
133
- yield* fs
134
- .makeDirectory(worktreesDir, { recursive: true })
135
- .pipe(Effect.mapError((e) => new WorktreeError({ message: e.message })));
136
- let branch;
137
- let worktreeName;
138
- if (opts?.branch) {
139
- branch = opts.branch;
140
- worktreeName = branch.replace(/\//g, "-");
141
- }
142
- else {
143
- const timestamp = formatTimestamp(new Date());
144
- if (opts?.name) {
145
- const sanitized = sanitizeName(opts.name);
146
- branch = `sandcastle/${sanitized}/${timestamp}`;
147
- worktreeName = `sandcastle-${sanitized}-${timestamp}`;
148
- }
149
- else {
150
- branch = `sandcastle/${timestamp}`;
151
- worktreeName = `sandcastle-${timestamp}`;
152
- }
153
- }
154
- const worktreePath = join(worktreesDir, worktreeName);
155
- if (opts?.branch) {
156
- // Proactively detect collision before git produces a confusing error.
157
- // Match by branch first; fall back to target path (covers mid-rebase
158
- // detached-HEAD state where the branch field is null).
159
- const existing = yield* listWorktrees(repoDir);
160
- const collision = findCollidingWorktree(existing, branch, worktreePath);
161
- if (collision) {
162
- // Only reuse worktrees managed by sandcastle (under .sandcastle/worktrees/)
163
- if (isManagedWorktreePath(collision.path, worktreesDir)) {
164
- const dirty = yield* hasUncommittedChanges(collision.path);
165
- if (dirty) {
166
- console.warn(`Reusing worktree at ${collision.path} (branch '${branch}') — worktree has uncommitted changes`);
167
- }
168
- else {
169
- console.log(`Reusing existing worktree at ${collision.path} (branch '${branch}')`);
170
- }
171
- // git reports forward slashes even on Windows; return a
172
- // platform-native path so downstream join/fs calls stay consistent.
173
- return { path: normalize(collision.path), branch };
174
- }
175
- // Branch is checked out in the main working tree or external worktree
176
- yield* Effect.fail(new WorktreeError({
177
- message: `Branch '${branch}' is already checked out in worktree at '${collision.path}'. ` +
178
- `Use a different branch name, or wait for the other run to finish.`,
179
- }));
180
- }
181
- yield* execGit([...NO_CONFIG_LOCK_FLAGS, "worktree", "add", worktreePath, branch], repoDir).pipe(Effect.catchAll((e) => {
182
- if (e.message.includes("invalid reference")) {
183
- return execGit([
184
- ...NO_CONFIG_LOCK_FLAGS,
185
- "worktree",
186
- "add",
187
- "-b",
188
- branch,
189
- worktreePath,
190
- opts?.baseBranch ?? "HEAD",
191
- ], repoDir);
192
- }
193
- return Effect.fail(e);
194
- }));
195
- }
196
- else {
197
- yield* execGit([
198
- ...NO_CONFIG_LOCK_FLAGS,
199
- "worktree",
200
- "add",
201
- "-b",
202
- branch,
203
- worktreePath,
204
- "HEAD",
205
- ], repoDir).pipe(Effect.catchAll((e) => {
206
- if (e.message.includes("already checked out") ||
207
- e.message.includes("already exists")) {
208
- return Effect.fail(new WorktreeError({
209
- message: `Branch '${branch}' is already checked out in another worktree. ` +
210
- `Use a different branch name, or wait for the other run to finish.`,
211
- }));
212
- }
213
- return Effect.fail(e);
214
- }));
215
- }
216
- return { path: worktreePath, branch };
217
- }).pipe(withTimeout(WORKTREE_TIMEOUT_MS, () => new WorktreeTimeoutError({
218
- message: `Worktree creation timed out after ${WORKTREE_TIMEOUT_MS}ms`,
219
- timeoutMs: WORKTREE_TIMEOUT_MS,
220
- path: repoDir,
221
- operation: "create",
222
- })));
223
- /**
224
- * Returns true if the worktree at `worktreePath` has any uncommitted changes:
225
- * unstaged modifications, staged changes, or untracked files.
226
- */
227
- export const hasUncommittedChanges = (worktreePath) => execGit(["status", "--porcelain"], worktreePath).pipe(Effect.map((output) => output.trim().length > 0));
228
- /**
229
- * Removes a worktree and its git metadata.
230
- *
231
- * The `worktreePath` must be a path inside `.sandcastle/worktrees/` so that
232
- * the main repository directory can be derived from it.
233
- */
234
- export const remove = (worktreePath) => {
235
- // Derive the main repo dir: worktreePath = <repoDir>/.sandcastle/worktrees/<name>
236
- const repoDir = join(worktreePath, "..", "..", "..");
237
- return execGit(["worktree", "remove", "--force", worktreePath], repoDir).pipe(Effect.asVoid);
238
- };
239
- /**
240
- * Prunes stale git worktree metadata and removes orphaned directories under
241
- * `.sandcastle/worktrees/`.
242
- */
243
- export const pruneStale = (repoDir) => Effect.gen(function* () {
244
- const fs = yield* FileSystem.FileSystem;
245
- // Let git clean up metadata for worktrees whose directories are gone
246
- yield* execGit(["worktree", "prune"], repoDir);
247
- const worktreesDir = join(repoDir, ".sandcastle", "worktrees");
248
- // Read directory entries — return null if directory doesn't exist
249
- const entries = yield* fs.readDirectory(worktreesDir).pipe(Effect.map((es) => es), Effect.catchSome((e) => e._tag === "SystemError" && e.reason === "NotFound"
250
- ? Option.some(Effect.succeed(null))
251
- : Option.none()), Effect.mapError((e) => new WorktreeError({ message: e.message })));
252
- if (entries === null)
253
- return;
254
- // `git worktree list` canonicalizes paths via realpath. If repoDir or
255
- // .sandcastle is a symlink, joining the un-canonicalized prefix produces
256
- // strings that never match git's output, and every active worktree looks
257
- // orphaned. Resolve the prefix once so the Set lookup below works.
258
- const realWorktreesDir = yield* fs
259
- .realPath(worktreesDir)
260
- .pipe(Effect.catchAll(() => Effect.succeed(worktreesDir)));
261
- // Get the list of active worktree paths from git
262
- const worktreeList = yield* execGit(["worktree", "list", "--porcelain"], repoDir);
263
- const activeWorktreePaths = new Set(worktreeList
264
- .split("\n")
265
- .filter((line) => line.startsWith("worktree "))
266
- .map((line) => line.slice("worktree ".length).trim()));
267
- // Remove any directory under .sandcastle/worktrees/ that is not an active worktree
268
- for (const entry of entries) {
269
- const entryPath = join(realWorktreesDir, entry);
270
- const isDir = yield* fs.stat(entryPath).pipe(Effect.map((s) => s.type === "Directory"), Effect.catchAll(() => Effect.succeed(false)));
271
- if (isDir && isOrphanedWorktreePath(entryPath, activeWorktreePaths)) {
272
- yield* fs.remove(entryPath, { recursive: true, force: true }).pipe(Effect.mapError((e) => new WorktreeError({
273
- message: `Failed to remove ${entryPath}: ${e.message}`,
274
- })));
275
- }
276
- }
277
- }).pipe(withTimeout(WORKTREE_TIMEOUT_MS, () => new WorktreeTimeoutError({
278
- message: `Worktree prune timed out after ${WORKTREE_TIMEOUT_MS}ms`,
279
- timeoutMs: WORKTREE_TIMEOUT_MS,
280
- path: repoDir,
281
- operation: "prune",
282
- })));
283
- //# sourceMappingURL=WorktreeManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WorktreeManager.js","sourceRoot":"","sources":["../src/WorktreeManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/E,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAEnC;;;;;GAKG;AACH,MAAM,oBAAoB,GAAG;IAC3B,IAAI;IACJ,6BAA6B;IAC7B,IAAI;IACJ,4BAA4B;CAC7B,CAAC;AAEF,4CAA4C;AAC5C,MAAM,eAAe,GAAG,CAAC,IAAU,EAAU,EAAE;IAC7C,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACtD,OAAO,CACL,GAAG,IAAI,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,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IACnF,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;QAChD,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAC1C,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC,EACzC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAC7C,CAAC;QACF,IAAI,KAAK,IAAI,sBAAsB,CAAC,SAAS,EAAE,mBAAmB,CAAC,EAAE,CAAC;YACpE,KAAK,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAChE,MAAM,CAAC,QAAQ,CACb,CAAC,CAAC,EAAE,EAAE,CACJ,IAAI,aAAa,CAAC;gBAChB,OAAO,EAAE,oBAAoB,SAAS,KAAK,CAAC,CAAC,OAAO,EAAE;aACvD,CAAC,CACL,CACF,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC,CAAC,CAAC,IAAI,CACL,WAAW,CACT,mBAAmB,EACnB,GAAG,EAAE,CACH,IAAI,oBAAoB,CAAC;IACvB,OAAO,EAAE,kCAAkC,mBAAmB,IAAI;IAClE,SAAS,EAAE,mBAAmB;IAC9B,IAAI,EAAE,OAAO;IACb,SAAS,EAAE,OAAO;CACnB,CAAC,CACL,CACF,CAAC"}
@@ -1,48 +0,0 @@
1
- /**
2
- * A bounded, rolling tail of streamed output — a pure, provider-agnostic
3
- * utility shared by every sandbox provider that streams `exec` output.
4
- *
5
- * When a provider streams output line-by-line, it accumulates the stream only
6
- * to build the returned `ExecResult.stdout`/`stderr`. Consumers read just the
7
- * tail of that value (e.g. the last lines of an error, or a fallback for the
8
- * agent's final result), so retaining the whole stream is unnecessary — and,
9
- * once the accumulated string passes V8's ~512MB max string length, fatal: a
10
- * naive `chunks.join()` throws `RangeError: Invalid string length`, which on a
11
- * long agent run crashes the whole orchestration.
12
- */
13
- /**
14
- * Default maximum number of characters retained in a bounded output tail.
15
- *
16
- * 64KiB sits comfortably above any agent completion signal or structured-output
17
- * payload while staying far below V8's max string length.
18
- */
19
- export declare const MAX_TAIL_CHARS: number;
20
- /**
21
- * A fixed-size rolling tail of strings, bounded by total character length.
22
- *
23
- * `push` appends to the tail; once the joined length would exceed `maxChars`,
24
- * the oldest items are dropped from the front. A single item longer than
25
- * `maxChars` is truncated to its own tail, so a newline-free blob can't
26
- * overflow on one push. `toString` joins the retained items, and its length is
27
- * always at most `maxChars`.
28
- *
29
- * The running length counter is encapsulated so callers can't desync it.
30
- */
31
- export declare class BoundedTail {
32
- private readonly items;
33
- private totalChars;
34
- private readonly maxChars;
35
- private readonly separator;
36
- /**
37
- * @param maxChars Maximum length of the joined tail. Defaults to {@link MAX_TAIL_CHARS}.
38
- * @param separator String placed between items by {@link toString}. Must match
39
- * how the caller would otherwise have joined the accumulated chunks (e.g.
40
- * `"\n"` for line streams, `""` for raw chunk streams).
41
- */
42
- constructor(maxChars?: number, separator?: string);
43
- /** Append one item to the tail, evicting oldest items to stay within budget. */
44
- push(item: string): void;
45
- /** Join the retained tail into a single string (length ≤ `maxChars`). */
46
- toString(): string;
47
- }
48
- //# sourceMappingURL=boundedTail.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"boundedTail.d.ts","sourceRoot":"","sources":["../src/boundedTail.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,cAAc,QAAY,CAAC;AAExC;;;;;;;;;;GAUG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IACtC,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IAEnC;;;;;OAKG;IACH,YAAY,QAAQ,GAAE,MAAuB,EAAE,SAAS,SAAK,EAG5D;IAED,gFAAgF;IAChF,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAYvB;IAED,yEAAyE;IACzE,QAAQ,IAAI,MAAM,CAEjB;CACF"}
@@ -1,64 +0,0 @@
1
- /**
2
- * A bounded, rolling tail of streamed output — a pure, provider-agnostic
3
- * utility shared by every sandbox provider that streams `exec` output.
4
- *
5
- * When a provider streams output line-by-line, it accumulates the stream only
6
- * to build the returned `ExecResult.stdout`/`stderr`. Consumers read just the
7
- * tail of that value (e.g. the last lines of an error, or a fallback for the
8
- * agent's final result), so retaining the whole stream is unnecessary — and,
9
- * once the accumulated string passes V8's ~512MB max string length, fatal: a
10
- * naive `chunks.join()` throws `RangeError: Invalid string length`, which on a
11
- * long agent run crashes the whole orchestration.
12
- */
13
- /**
14
- * Default maximum number of characters retained in a bounded output tail.
15
- *
16
- * 64KiB sits comfortably above any agent completion signal or structured-output
17
- * payload while staying far below V8's max string length.
18
- */
19
- export const MAX_TAIL_CHARS = 64 * 1024;
20
- /**
21
- * A fixed-size rolling tail of strings, bounded by total character length.
22
- *
23
- * `push` appends to the tail; once the joined length would exceed `maxChars`,
24
- * the oldest items are dropped from the front. A single item longer than
25
- * `maxChars` is truncated to its own tail, so a newline-free blob can't
26
- * overflow on one push. `toString` joins the retained items, and its length is
27
- * always at most `maxChars`.
28
- *
29
- * The running length counter is encapsulated so callers can't desync it.
30
- */
31
- export class BoundedTail {
32
- items = [];
33
- totalChars = 0;
34
- maxChars;
35
- separator;
36
- /**
37
- * @param maxChars Maximum length of the joined tail. Defaults to {@link MAX_TAIL_CHARS}.
38
- * @param separator String placed between items by {@link toString}. Must match
39
- * how the caller would otherwise have joined the accumulated chunks (e.g.
40
- * `"\n"` for line streams, `""` for raw chunk streams).
41
- */
42
- constructor(maxChars = MAX_TAIL_CHARS, separator = "") {
43
- this.maxChars = maxChars;
44
- this.separator = separator;
45
- }
46
- /** Append one item to the tail, evicting oldest items to stay within budget. */
47
- push(item) {
48
- const bounded = item.length > this.maxChars
49
- ? item.slice(item.length - this.maxChars)
50
- : item;
51
- this.totalChars +=
52
- bounded.length + (this.items.length > 0 ? this.separator.length : 0);
53
- this.items.push(bounded);
54
- while (this.totalChars > this.maxChars && this.items.length > 1) {
55
- const dropped = this.items.shift();
56
- this.totalChars -= dropped.length + this.separator.length;
57
- }
58
- }
59
- /** Join the retained tail into a single string (length ≤ `maxChars`). */
60
- toString() {
61
- return this.items.join(this.separator);
62
- }
63
- }
64
- //# sourceMappingURL=boundedTail.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"boundedTail.js","sourceRoot":"","sources":["../src/boundedTail.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,GAAG,IAAI,CAAC;AAExC;;;;;;;;;;GAUG;AACH,MAAM,OAAO,WAAW;IACL,KAAK,GAAa,EAAE,CAAC;IAC9B,UAAU,GAAG,CAAC,CAAC;IACN,QAAQ,CAAS;IACjB,SAAS,CAAS;IAEnC;;;;;OAKG;IACH,YAAY,QAAQ,GAAW,cAAc,EAAE,SAAS,GAAG,EAAE;QAC3D,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,gFAAgF;IAChF,IAAI,CAAC,IAAY;QACf,MAAM,OAAO,GACX,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ;YACzB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC;YACzC,CAAC,CAAC,IAAI,CAAC;QACX,IAAI,CAAC,UAAU;YACb,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACvE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChE,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,EAAG,CAAC;YACpC,IAAI,CAAC,UAAU,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,yEAAyE;IACzE,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACzC,CAAC;CACF"}
package/dist/cli.d.ts DELETED
@@ -1,30 +0,0 @@
1
- import { Command } from "@effect/cli";
2
- import { FileSystem } from "@effect/platform";
3
- import { Effect } from "effect";
4
- import { Display } from "./Display.js";
5
- import { ConfigDirError, InitError } from "./errors.js";
6
- export declare const sandcastle: Command.Command<"sandcastle", Display | FileSystem.FileSystem, ConfigDirError | import("./errors.js").DockerError | InitError | import("./errors.js").PodmanError, {
7
- readonly subcommand: import("effect/Option").Option<{
8
- readonly imageName: import("effect/Option").Option<string>;
9
- readonly template: import("effect/Option").Option<string>;
10
- readonly agent: import("effect/Option").Option<string>;
11
- readonly model: import("effect/Option").Option<string>;
12
- readonly sandbox: import("effect/Option").Option<string>;
13
- } | {
14
- readonly subcommand: import("effect/Option").Option<{
15
- readonly imageName: import("effect/Option").Option<string>;
16
- readonly dockerfile: import("effect/Option").Option<string>;
17
- } | {
18
- readonly imageName: import("effect/Option").Option<string>;
19
- }>;
20
- } | {
21
- readonly subcommand: import("effect/Option").Option<{
22
- readonly imageName: import("effect/Option").Option<string>;
23
- readonly containerfile: import("effect/Option").Option<string>;
24
- } | {
25
- readonly imageName: import("effect/Option").Option<string>;
26
- }>;
27
- }>;
28
- }>;
29
- export declare const cli: (args: readonly string[]) => Effect.Effect<void, ConfigDirError | import("./errors.js").DockerError | InitError | import("./errors.js").PodmanError | import("@effect/cli/ValidationError").ValidationError, Display | import("@effect/cli/CliApp").CliApp.Environment>;
30
- //# sourceMappingURL=cli.d.ts.map
package/dist/cli.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAW,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAOhC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AA2BvC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAohBxD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;EAEtB,CAAC;AAEF,eAAO,MAAM,GAAG,yQAGd,CAAC"}