@ai-hero/sandcastle 0.10.0 → 0.13.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.
- package/README.md +15 -1316
- package/dist/LinuxCapability-B_PQfsY_.d.ts +32 -0
- package/dist/{SandboxProvider-EkSMuBp8.d.ts → SandboxProvider-YCL97qco.d.ts} +30 -3
- package/dist/chunk-4EIVTSOZ.js +93 -0
- package/dist/chunk-4EIVTSOZ.js.map +1 -0
- package/dist/{chunk-NGBM7T3E.js → chunk-6NQPCXSG.js} +5 -2
- package/dist/chunk-6NQPCXSG.js.map +1 -0
- package/dist/chunk-767EAJVT.js +112 -0
- package/dist/chunk-767EAJVT.js.map +1 -0
- package/dist/chunk-7N7AMUYA.js +353 -0
- package/dist/chunk-7N7AMUYA.js.map +1 -0
- package/dist/{chunk-52CIJF45.js → chunk-A4C2FG74.js} +258 -327
- package/dist/chunk-A4C2FG74.js.map +1 -0
- package/dist/chunk-J5J5YJ5S.js +50 -0
- package/dist/chunk-J5J5YJ5S.js.map +1 -0
- package/dist/{chunk-5VM5QZ26.js → chunk-LWNC4UTZ.js} +12097 -3252
- package/dist/chunk-LWNC4UTZ.js.map +1 -0
- package/dist/chunk-NMQ5Z6YG.js +148 -0
- package/dist/chunk-NMQ5Z6YG.js.map +1 -0
- package/dist/{chunk-NSFQW6ML.js → chunk-U42XXICG.js} +92 -85
- package/dist/chunk-U42XXICG.js.map +1 -0
- package/dist/chunk-XCWKLDH4.js +24 -0
- package/dist/chunk-XCWKLDH4.js.map +1 -0
- package/dist/{chunk-BIWNFKGV.js → chunk-XCYK7I45.js} +2 -2
- package/dist/chunk-XCYK7I45.js.map +1 -0
- package/dist/index.d.ts +335 -39
- package/dist/index.js +2854 -2090
- package/dist/index.js.map +1 -1
- package/dist/main.js +1006 -627
- package/dist/main.js.map +1 -1
- package/dist/sandboxes/bwrap.d.ts +58 -0
- package/dist/sandboxes/bwrap.js +293 -0
- package/dist/sandboxes/bwrap.js.map +1 -0
- package/dist/sandboxes/daytona.d.ts +1 -1
- package/dist/sandboxes/daytona.js +78 -17
- package/dist/sandboxes/daytona.js.map +1 -1
- package/dist/sandboxes/docker.d.ts +19 -5
- package/dist/sandboxes/docker.js +4 -4
- package/dist/sandboxes/no-sandbox.d.ts +2 -2
- package/dist/sandboxes/no-sandbox.js +2 -2
- package/dist/sandboxes/podman.d.ts +19 -5
- package/dist/sandboxes/podman.js +69 -56
- package/dist/sandboxes/podman.js.map +1 -1
- package/dist/sandboxes/seatbelt.d.ts +65 -0
- package/dist/sandboxes/seatbelt.js +422 -0
- package/dist/sandboxes/seatbelt.js.map +1 -0
- package/dist/sandboxes/vercel.d.ts +13 -6
- package/dist/sandboxes/vercel.js +195 -126
- package/dist/sandboxes/vercel.js.map +1 -1
- package/dist/templates/blank/main.mts +1 -1
- package/dist/templates/parallel-planner/main.mts +14 -23
- package/dist/templates/parallel-planner-with-review/main.mts +14 -16
- package/dist/templates/simple-loop/main.mts +1 -1
- package/package.json +34 -10
- package/dist/chunk-52CIJF45.js.map +0 -1
- package/dist/chunk-5VM5QZ26.js.map +0 -1
- package/dist/chunk-72UVAC7B.js +0 -99
- package/dist/chunk-72UVAC7B.js.map +0 -1
- package/dist/chunk-BIWNFKGV.js.map +0 -1
- package/dist/chunk-NGBM7T3E.js.map +0 -1
- package/dist/chunk-NSFQW6ML.js.map +0 -1
- package/dist/mountUtils-CCA-bbpK.d.ts +0 -25
package/dist/main.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import './chunk-
|
|
7
|
-
import {
|
|
3
|
+
import { assertSeatbeltUsable } from './chunk-J5J5YJ5S.js';
|
|
4
|
+
import { withFriendlyErrors } from './chunk-4EIVTSOZ.js';
|
|
5
|
+
import { buildImage, removeImage } from './chunk-U42XXICG.js';
|
|
6
|
+
import { assertBwrapUsable } from './chunk-767EAJVT.js';
|
|
7
|
+
import { NodeContext_exports, NodeRuntime_exports } from './chunk-A4C2FG74.js';
|
|
8
|
+
import { CommitPrototype, dual, GenericTag, fromIterable, failSync, map2, reduce, Schema_exports, Effect_exports, Display, Option_exports, Layer_exports, ClackDisplay, decode, mapError, TreeFormatter, empty, none, flatMap3, catchAll, match, fail2 as fail2$1, map3, merge, some, right, left, isNonEmptyReadonlyArray, headNonEmpty, tailNonEmpty, isArray, identity, fromIterable2, fromIterable3, globalValue, contextWithEffect, getOrElse, getOption, appendAll, matchEffect, unify, catchSome, zipRight, matchLeft, InitError, FileSystem_exports, ConfigDirError, defaultImageName, ImageNotFoundError, pipe, zipLeft, log, succeed, isOption, make4, update, repeatN, get2, getSomes, map, zipWith, make3, as, prepend, make, isEmpty, empty2, isEmptyReadonlyArray, of, catchTag, isTagged, die, isConfigError, isMissingDataOnly, filterMap, get, every, mapBoth, zip, forEach, _void, orElse, match2, join as join$1, isConfig, isObject, toStringUnknown, isSome, getOrThrow, FileSystem, try_, flatMap2, unsafeGet, drop, splitAt, tap, take, isQuitException, reduceRight, withMinimumLogLevel, error, PodmanError, mapInput, boolean, sort, contains, append, fromNullable, catchTags, when, set, pipeArguments, head, make10 as make10$1, suspend, get4, allocate, gen, updateAndGet, span, some2, sync, orElse2, has, filter, SANDBOX_REPO_DIR, Config_exports, is, decodeUnknown, String$, fromString, make7 as make7$1, orElseFail, orDie, compose, NumberFromString, Int, Date$, findFirst, allLevels, updateEffect, flatten, fnUntraced, Terminal, QuitException, scoped, isNone, Literal, unlessEffect, asVoid, catchIf, runSync, of2, match3, filterOrDieMessage, Path, filter2, isEffect, taggedEnum, round, ensuring, cons, dieMessage, value, when2, orElse3, isNil, matchRight, symbol2, symbol, cached, findFirstIndex, flatMap, findLast, equals, combine, hash, string, string2, provide, provideServiceEffect, provideService, int } from './chunk-LWNC4UTZ.js';
|
|
9
|
+
import './chunk-XCYK7I45.js';
|
|
10
|
+
import { __commonJS, __require, __toESM, __export } from './chunk-6NQPCXSG.js';
|
|
8
11
|
import * as clack from '@clack/prompts';
|
|
9
12
|
import { execSync, execFile } from 'child_process';
|
|
10
|
-
import { join, resolve, dirname } from 'path';
|
|
13
|
+
import { join, resolve, delimiter, dirname } from 'path';
|
|
11
14
|
import { styleText } from 'util';
|
|
12
15
|
import { fileURLToPath } from 'url';
|
|
13
16
|
import 'module';
|
|
@@ -4545,6 +4548,8 @@ var require_Alias = __commonJS({
|
|
|
4545
4548
|
* instance of the `source` anchor before this node.
|
|
4546
4549
|
*/
|
|
4547
4550
|
resolve(doc, ctx) {
|
|
4551
|
+
if (ctx?.maxAliasCount === 0)
|
|
4552
|
+
throw new ReferenceError("Alias resolution is disabled");
|
|
4548
4553
|
let nodes;
|
|
4549
4554
|
if (ctx?.aliasResolveCache) {
|
|
4550
4555
|
nodes = ctx.aliasResolveCache;
|
|
@@ -4566,36 +4571,38 @@ var require_Alias = __commonJS({
|
|
|
4566
4571
|
if (node.anchor === this.source)
|
|
4567
4572
|
found = node;
|
|
4568
4573
|
}
|
|
4574
|
+
if (found && ctx) {
|
|
4575
|
+
const { anchors: anchors2, doc: doc2, maxAliasCount } = ctx;
|
|
4576
|
+
let data = anchors2.get(found);
|
|
4577
|
+
if (!data) {
|
|
4578
|
+
toJS.toJS(found, null, ctx);
|
|
4579
|
+
data = anchors2.get(found);
|
|
4580
|
+
}
|
|
4581
|
+
if (data?.res === void 0) {
|
|
4582
|
+
const msg = "This should not happen: Alias anchor was not resolved?";
|
|
4583
|
+
throw new ReferenceError(msg);
|
|
4584
|
+
}
|
|
4585
|
+
if (maxAliasCount >= 0) {
|
|
4586
|
+
data.count += 1;
|
|
4587
|
+
if (data.aliasCount === 0)
|
|
4588
|
+
data.aliasCount = getAliasCount(doc2, found, anchors2);
|
|
4589
|
+
if (data.count * data.aliasCount > maxAliasCount) {
|
|
4590
|
+
const msg = "Excessive alias count indicates a resource exhaustion attack";
|
|
4591
|
+
throw new ReferenceError(msg);
|
|
4592
|
+
}
|
|
4593
|
+
}
|
|
4594
|
+
}
|
|
4569
4595
|
return found;
|
|
4570
4596
|
}
|
|
4571
4597
|
toJSON(_arg, ctx) {
|
|
4572
4598
|
if (!ctx)
|
|
4573
4599
|
return { source: this.source };
|
|
4574
|
-
const
|
|
4575
|
-
const source = this.resolve(doc, ctx);
|
|
4600
|
+
const source = this.resolve(ctx.doc, ctx);
|
|
4576
4601
|
if (!source) {
|
|
4577
4602
|
const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
|
4578
4603
|
throw new ReferenceError(msg);
|
|
4579
4604
|
}
|
|
4580
|
-
|
|
4581
|
-
if (!data) {
|
|
4582
|
-
toJS.toJS(source, null, ctx);
|
|
4583
|
-
data = anchors2.get(source);
|
|
4584
|
-
}
|
|
4585
|
-
if (data?.res === void 0) {
|
|
4586
|
-
const msg = "This should not happen: Alias anchor was not resolved?";
|
|
4587
|
-
throw new ReferenceError(msg);
|
|
4588
|
-
}
|
|
4589
|
-
if (maxAliasCount >= 0) {
|
|
4590
|
-
data.count += 1;
|
|
4591
|
-
if (data.aliasCount === 0)
|
|
4592
|
-
data.aliasCount = getAliasCount(doc, source, anchors2);
|
|
4593
|
-
if (data.count * data.aliasCount > maxAliasCount) {
|
|
4594
|
-
const msg = "Excessive alias count indicates a resource exhaustion attack";
|
|
4595
|
-
throw new ReferenceError(msg);
|
|
4596
|
-
}
|
|
4597
|
-
}
|
|
4598
|
-
return data.res;
|
|
4605
|
+
return ctx.anchors.get(source).res;
|
|
4599
4606
|
}
|
|
4600
4607
|
toString(ctx, _onComment, _onChompKeep) {
|
|
4601
4608
|
const src = `*${this.source}`;
|
|
@@ -5337,6 +5344,7 @@ var require_stringify = __commonJS({
|
|
|
5337
5344
|
nullStr: "null",
|
|
5338
5345
|
simpleKeys: false,
|
|
5339
5346
|
singleQuote: null,
|
|
5347
|
+
trailingComma: false,
|
|
5340
5348
|
trueStr: "true",
|
|
5341
5349
|
verifyAliasOrder: true
|
|
5342
5350
|
}, doc.schema.toStringOptions, options3);
|
|
@@ -5606,18 +5614,18 @@ var require_merge = __commonJS({
|
|
|
5606
5614
|
};
|
|
5607
5615
|
var isMergeKey = (ctx, key) => (merge3.identify(key) || identity2.isScalar(key) && (!key.type || key.type === Scalar.Scalar.PLAIN) && merge3.identify(key.value)) && ctx?.doc.schema.tags.some((tag) => tag.tag === merge3.tag && tag.default);
|
|
5608
5616
|
function addMergeToJSMap(ctx, map13, value2) {
|
|
5609
|
-
|
|
5610
|
-
if (identity2.isSeq(
|
|
5611
|
-
for (const it of
|
|
5617
|
+
const source = resolveAliasValue(ctx, value2);
|
|
5618
|
+
if (identity2.isSeq(source))
|
|
5619
|
+
for (const it of source.items)
|
|
5612
5620
|
mergeValue(ctx, map13, it);
|
|
5613
|
-
else if (Array.isArray(
|
|
5614
|
-
for (const it of
|
|
5621
|
+
else if (Array.isArray(source))
|
|
5622
|
+
for (const it of source)
|
|
5615
5623
|
mergeValue(ctx, map13, it);
|
|
5616
5624
|
else
|
|
5617
|
-
mergeValue(ctx, map13,
|
|
5625
|
+
mergeValue(ctx, map13, source);
|
|
5618
5626
|
}
|
|
5619
5627
|
function mergeValue(ctx, map13, value2) {
|
|
5620
|
-
const source = ctx
|
|
5628
|
+
const source = resolveAliasValue(ctx, value2);
|
|
5621
5629
|
if (!identity2.isMap(source))
|
|
5622
5630
|
throw new Error("Merge sources must be maps or map aliases");
|
|
5623
5631
|
const srcMap = source.toJSON(null, ctx, Map);
|
|
@@ -5638,6 +5646,9 @@ var require_merge = __commonJS({
|
|
|
5638
5646
|
}
|
|
5639
5647
|
return map13;
|
|
5640
5648
|
}
|
|
5649
|
+
function resolveAliasValue(ctx, value2) {
|
|
5650
|
+
return ctx && identity2.isAlias(value2) ? value2.resolve(ctx.doc, ctx) : value2;
|
|
5651
|
+
}
|
|
5641
5652
|
exports$1.addMergeToJSMap = addMergeToJSMap;
|
|
5642
5653
|
exports$1.isMergeKey = isMergeKey;
|
|
5643
5654
|
exports$1.merge = merge3;
|
|
@@ -5848,12 +5859,19 @@ ${indent3}${line4}` : "\n";
|
|
|
5848
5859
|
if (comment)
|
|
5849
5860
|
reqNewline = true;
|
|
5850
5861
|
let str = stringify2.stringify(item, itemCtx, () => comment = null);
|
|
5851
|
-
|
|
5862
|
+
reqNewline || (reqNewline = lines2.length > linesAtValue || str.includes("\n"));
|
|
5863
|
+
if (i < items.length - 1) {
|
|
5852
5864
|
str += ",";
|
|
5865
|
+
} else if (ctx.options.trailingComma) {
|
|
5866
|
+
if (ctx.options.lineWidth > 0) {
|
|
5867
|
+
reqNewline || (reqNewline = lines2.reduce((sum, line4) => sum + line4.length + 2, 2) + (str.length + 2) > ctx.options.lineWidth);
|
|
5868
|
+
}
|
|
5869
|
+
if (reqNewline) {
|
|
5870
|
+
str += ",";
|
|
5871
|
+
}
|
|
5872
|
+
}
|
|
5853
5873
|
if (comment)
|
|
5854
5874
|
str += stringifyComment.lineComment(str, itemIndent, commentString(comment));
|
|
5855
|
-
if (!reqNewline && (lines2.length > linesAtValue || str.includes("\n")))
|
|
5856
|
-
reqNewline = true;
|
|
5857
5875
|
lines2.push(str);
|
|
5858
5876
|
linesAtValue = lines2.length;
|
|
5859
5877
|
}
|
|
@@ -6257,7 +6275,7 @@ var require_stringifyNumber = __commonJS({
|
|
|
6257
6275
|
if (!isFinite(num))
|
|
6258
6276
|
return isNaN(num) ? ".nan" : num < 0 ? "-.inf" : ".inf";
|
|
6259
6277
|
let n = Object.is(value2, -0) ? "-0" : JSON.stringify(value2);
|
|
6260
|
-
if (!format && minFractionDigits && (!tag || tag === "tag:yaml.org,2002:float") &&
|
|
6278
|
+
if (!format && minFractionDigits && (!tag || tag === "tag:yaml.org,2002:float") && /^-?\d/.test(n) && !n.includes("e")) {
|
|
6261
6279
|
let i = n.indexOf(".");
|
|
6262
6280
|
if (i < 0) {
|
|
6263
6281
|
i = n.length;
|
|
@@ -8536,37 +8554,38 @@ var require_resolve_flow_scalar = __commonJS({
|
|
|
8536
8554
|
}
|
|
8537
8555
|
if (badChar)
|
|
8538
8556
|
onError(0, "BAD_SCALAR_START", `Plain value cannot start with ${badChar}`);
|
|
8539
|
-
return
|
|
8557
|
+
return unfoldLines(source);
|
|
8540
8558
|
}
|
|
8541
8559
|
function singleQuotedValue(source, onError) {
|
|
8542
8560
|
if (source[source.length - 1] !== "'" || source.length === 1)
|
|
8543
8561
|
onError(source.length, "MISSING_CHAR", "Missing closing 'quote");
|
|
8544
|
-
return
|
|
8562
|
+
return unfoldLines(source.slice(1, -1)).replace(/''/g, "'");
|
|
8545
8563
|
}
|
|
8546
|
-
function
|
|
8547
|
-
|
|
8564
|
+
function unfoldLines(source) {
|
|
8565
|
+
const line4 = /(.*?)\r?\n/sy;
|
|
8566
|
+
let match6 = line4.exec(source);
|
|
8567
|
+
if (!match6)
|
|
8568
|
+
return source;
|
|
8569
|
+
let trimEnd, trimBoth;
|
|
8548
8570
|
try {
|
|
8549
|
-
|
|
8550
|
-
|
|
8571
|
+
trimEnd = new RegExp("(?<![ ])[ ]+$");
|
|
8572
|
+
trimBoth = new RegExp("^[ ]+|(?<![ ])[ ]+$", "g");
|
|
8551
8573
|
} catch {
|
|
8552
|
-
|
|
8553
|
-
|
|
8574
|
+
trimEnd = /[ \t]+$/;
|
|
8575
|
+
trimBoth = /^[ \t]+|[ \t]+$/g;
|
|
8554
8576
|
}
|
|
8555
|
-
let
|
|
8556
|
-
if (!match6)
|
|
8557
|
-
return source;
|
|
8558
|
-
let res = match6[1];
|
|
8577
|
+
let res = match6[1].replace(trimEnd, "");
|
|
8559
8578
|
let sep = " ";
|
|
8560
|
-
let pos =
|
|
8561
|
-
line4.lastIndex = pos;
|
|
8579
|
+
let pos = line4.lastIndex;
|
|
8562
8580
|
while (match6 = line4.exec(source)) {
|
|
8563
|
-
|
|
8581
|
+
const lm = match6[1].replace(trimBoth, "");
|
|
8582
|
+
if (lm === "") {
|
|
8564
8583
|
if (sep === "\n")
|
|
8565
8584
|
res += sep;
|
|
8566
8585
|
else
|
|
8567
8586
|
sep = "\n";
|
|
8568
8587
|
} else {
|
|
8569
|
-
res += sep +
|
|
8588
|
+
res += sep + lm;
|
|
8570
8589
|
sep = " ";
|
|
8571
8590
|
}
|
|
8572
8591
|
pos = line4.lastIndex;
|
|
@@ -8600,7 +8619,7 @@ var require_resolve_flow_scalar = __commonJS({
|
|
|
8600
8619
|
while (next === " " || next === " ")
|
|
8601
8620
|
next = source[++i + 1];
|
|
8602
8621
|
} else if (next === "x" || next === "u" || next === "U") {
|
|
8603
|
-
const length =
|
|
8622
|
+
const length = next === "x" ? 2 : next === "u" ? 4 : 8;
|
|
8604
8623
|
res += parseCharCode(source, i + 1, length, onError);
|
|
8605
8624
|
i += length;
|
|
8606
8625
|
} else {
|
|
@@ -8675,12 +8694,13 @@ var require_resolve_flow_scalar = __commonJS({
|
|
|
8675
8694
|
const cc = source.substr(offset, length);
|
|
8676
8695
|
const ok = cc.length === length && /^[0-9a-fA-F]+$/.test(cc);
|
|
8677
8696
|
const code2 = ok ? parseInt(cc, 16) : NaN;
|
|
8678
|
-
|
|
8697
|
+
try {
|
|
8698
|
+
return String.fromCodePoint(code2);
|
|
8699
|
+
} catch {
|
|
8679
8700
|
const raw = source.substr(offset - 2, length + 2);
|
|
8680
8701
|
onError(offset - 2, "BAD_DQ_ESCAPE", `Invalid escape sequence ${raw}`);
|
|
8681
8702
|
return raw;
|
|
8682
8703
|
}
|
|
8683
|
-
return String.fromCodePoint(code2);
|
|
8684
8704
|
}
|
|
8685
8705
|
exports$1.resolveFlowScalar = resolveFlowScalar;
|
|
8686
8706
|
}
|
|
@@ -8827,17 +8847,22 @@ var require_compose_node = __commonJS({
|
|
|
8827
8847
|
case "block-map":
|
|
8828
8848
|
case "block-seq":
|
|
8829
8849
|
case "flow-collection":
|
|
8830
|
-
|
|
8831
|
-
|
|
8832
|
-
|
|
8850
|
+
try {
|
|
8851
|
+
node = composeCollection.composeCollection(CN, ctx, token, props, onError);
|
|
8852
|
+
if (anchor)
|
|
8853
|
+
node.anchor = anchor.source.substring(1);
|
|
8854
|
+
} catch (error3) {
|
|
8855
|
+
const message = error3 instanceof Error ? error3.message : String(error3);
|
|
8856
|
+
onError(token, "RESOURCE_EXHAUSTION", message);
|
|
8857
|
+
}
|
|
8833
8858
|
break;
|
|
8834
8859
|
default: {
|
|
8835
8860
|
const message = token.type === "error" ? token.message : `Unsupported token (type: ${token.type})`;
|
|
8836
8861
|
onError(token, "UNEXPECTED_TOKEN", message);
|
|
8837
|
-
node = composeEmptyNode(ctx, token.offset, void 0, null, props, onError);
|
|
8838
8862
|
isSrcToken = false;
|
|
8839
8863
|
}
|
|
8840
8864
|
}
|
|
8865
|
+
node ?? (node = composeEmptyNode(ctx, token.offset, void 0, null, props, onError));
|
|
8841
8866
|
if (anchor && node.anchor === "")
|
|
8842
8867
|
onError(anchor, "BAD_ALIAS", "Anchor cannot be an empty string");
|
|
8843
8868
|
if (atKey && ctx.options.stringKeys && (!identity2.isScalar(node) || typeof node.value !== "string" || node.tag && node.tag !== "tag:yaml.org,2002:str")) {
|
|
@@ -9020,8 +9045,10 @@ ${cb}` : comment;
|
|
|
9020
9045
|
}
|
|
9021
9046
|
}
|
|
9022
9047
|
if (afterDoc) {
|
|
9023
|
-
|
|
9024
|
-
|
|
9048
|
+
for (let i = 0; i < this.errors.length; ++i)
|
|
9049
|
+
doc.errors.push(this.errors[i]);
|
|
9050
|
+
for (let i = 0; i < this.warnings.length; ++i)
|
|
9051
|
+
doc.warnings.push(this.warnings[i]);
|
|
9025
9052
|
} else {
|
|
9026
9053
|
doc.errors = this.errors;
|
|
9027
9054
|
doc.warnings = this.warnings;
|
|
@@ -9749,7 +9776,7 @@ var require_lexer = __commonJS({
|
|
|
9749
9776
|
const n = (yield* this.pushCount(1)) + (yield* this.pushSpaces(true));
|
|
9750
9777
|
this.indentNext = this.indentValue + 1;
|
|
9751
9778
|
this.indentValue += n;
|
|
9752
|
-
return
|
|
9779
|
+
return "block-start";
|
|
9753
9780
|
}
|
|
9754
9781
|
return "doc";
|
|
9755
9782
|
}
|
|
@@ -10048,28 +10075,38 @@ var require_lexer = __commonJS({
|
|
|
10048
10075
|
return 0;
|
|
10049
10076
|
}
|
|
10050
10077
|
*pushIndicators() {
|
|
10051
|
-
|
|
10052
|
-
|
|
10053
|
-
|
|
10054
|
-
|
|
10055
|
-
|
|
10056
|
-
|
|
10057
|
-
|
|
10058
|
-
|
|
10059
|
-
|
|
10060
|
-
|
|
10061
|
-
|
|
10062
|
-
|
|
10063
|
-
|
|
10064
|
-
|
|
10065
|
-
|
|
10066
|
-
|
|
10067
|
-
|
|
10068
|
-
|
|
10078
|
+
let n = 0;
|
|
10079
|
+
loop: while (true) {
|
|
10080
|
+
switch (this.charAt(0)) {
|
|
10081
|
+
case "!":
|
|
10082
|
+
n += yield* this.pushTag();
|
|
10083
|
+
n += yield* this.pushSpaces(true);
|
|
10084
|
+
continue loop;
|
|
10085
|
+
case "&":
|
|
10086
|
+
n += yield* this.pushUntil(isNotAnchorChar);
|
|
10087
|
+
n += yield* this.pushSpaces(true);
|
|
10088
|
+
continue loop;
|
|
10089
|
+
case "-":
|
|
10090
|
+
// this is an error
|
|
10091
|
+
case "?":
|
|
10092
|
+
// this is an error outside flow collections
|
|
10093
|
+
case ":": {
|
|
10094
|
+
const inFlow = this.flowLevel > 0;
|
|
10095
|
+
const ch1 = this.charAt(1);
|
|
10096
|
+
if (isEmpty8(ch1) || inFlow && flowIndicatorChars.has(ch1)) {
|
|
10097
|
+
if (!inFlow)
|
|
10098
|
+
this.indentNext = this.indentValue + 1;
|
|
10099
|
+
else if (this.flowKey)
|
|
10100
|
+
this.flowKey = false;
|
|
10101
|
+
n += yield* this.pushCount(1);
|
|
10102
|
+
n += yield* this.pushSpaces(true);
|
|
10103
|
+
continue loop;
|
|
10104
|
+
}
|
|
10069
10105
|
}
|
|
10070
10106
|
}
|
|
10107
|
+
break loop;
|
|
10071
10108
|
}
|
|
10072
|
-
return
|
|
10109
|
+
return n;
|
|
10073
10110
|
}
|
|
10074
10111
|
*pushTag() {
|
|
10075
10112
|
if (this.charAt(1) === "<") {
|
|
@@ -10226,6 +10263,13 @@ var require_parser2 = __commonJS({
|
|
|
10226
10263
|
}
|
|
10227
10264
|
return prev.splice(i, prev.length);
|
|
10228
10265
|
}
|
|
10266
|
+
function arrayPushArray(target, source) {
|
|
10267
|
+
if (source.length < 1e5)
|
|
10268
|
+
Array.prototype.push.apply(target, source);
|
|
10269
|
+
else
|
|
10270
|
+
for (let i = 0; i < source.length; ++i)
|
|
10271
|
+
target.push(source[i]);
|
|
10272
|
+
}
|
|
10229
10273
|
function fixFlowSeqItems(fc) {
|
|
10230
10274
|
if (fc.start.type === "flow-seq-start") {
|
|
10231
10275
|
for (const it of fc.items) {
|
|
@@ -10235,11 +10279,11 @@ var require_parser2 = __commonJS({
|
|
|
10235
10279
|
delete it.key;
|
|
10236
10280
|
if (isFlowToken(it.value)) {
|
|
10237
10281
|
if (it.value.end)
|
|
10238
|
-
|
|
10282
|
+
arrayPushArray(it.value.end, it.sep);
|
|
10239
10283
|
else
|
|
10240
10284
|
it.value.end = it.sep;
|
|
10241
10285
|
} else
|
|
10242
|
-
|
|
10286
|
+
arrayPushArray(it.start, it.sep);
|
|
10243
10287
|
delete it.sep;
|
|
10244
10288
|
}
|
|
10245
10289
|
}
|
|
@@ -10594,7 +10638,7 @@ var require_parser2 = __commonJS({
|
|
|
10594
10638
|
const prev = map13.items[map13.items.length - 2];
|
|
10595
10639
|
const end = prev?.value?.end;
|
|
10596
10640
|
if (Array.isArray(end)) {
|
|
10597
|
-
|
|
10641
|
+
arrayPushArray(end, it.start);
|
|
10598
10642
|
end.push(this.sourceToken);
|
|
10599
10643
|
map13.items.pop();
|
|
10600
10644
|
return;
|
|
@@ -10782,7 +10826,7 @@ var require_parser2 = __commonJS({
|
|
|
10782
10826
|
const prev = seq.items[seq.items.length - 2];
|
|
10783
10827
|
const end = prev?.value?.end;
|
|
10784
10828
|
if (Array.isArray(end)) {
|
|
10785
|
-
|
|
10829
|
+
arrayPushArray(end, it.start);
|
|
10786
10830
|
end.push(this.sourceToken);
|
|
10787
10831
|
seq.items.pop();
|
|
10788
10832
|
return;
|
|
@@ -18032,33 +18076,32 @@ var podmanExec = (args) => Effect_exports.async((resume) => {
|
|
|
18032
18076
|
resume(
|
|
18033
18077
|
Effect_exports.fail(
|
|
18034
18078
|
new PodmanError({
|
|
18035
|
-
message: `podman ${args[0]} failed: ${stderr
|
|
18079
|
+
message: `podman ${args[0]} failed: ${stderr || error3.message}`
|
|
18036
18080
|
})
|
|
18037
18081
|
)
|
|
18038
18082
|
);
|
|
18039
18083
|
} else {
|
|
18040
|
-
resume(Effect_exports.succeed(stdout
|
|
18084
|
+
resume(Effect_exports.succeed(stdout));
|
|
18041
18085
|
}
|
|
18042
18086
|
}
|
|
18043
18087
|
);
|
|
18044
18088
|
});
|
|
18045
18089
|
var buildImage2 = (imageName, containerfileDir, options3) => Effect_exports.gen(function* () {
|
|
18046
|
-
|
|
18047
|
-
|
|
18048
|
-
|
|
18049
|
-
"-t",
|
|
18050
|
-
imageName,
|
|
18051
|
-
"-f",
|
|
18052
|
-
resolve(options3.containerfile),
|
|
18053
|
-
process.cwd()
|
|
18054
|
-
]);
|
|
18055
|
-
} else {
|
|
18056
|
-
yield* podmanExec(["build", "-t", imageName, resolve(containerfileDir)]);
|
|
18057
|
-
}
|
|
18058
|
-
});
|
|
18059
|
-
var removeImage2 = (imageName) => Effect_exports.gen(function* () {
|
|
18060
|
-
yield* podmanExec(["rmi", imageName]);
|
|
18090
|
+
const containerfile = options3?.containerfile;
|
|
18091
|
+
const buildContext = containerfile !== void 0 && containerfile !== "" ? ["-f", resolve(containerfile), process.cwd()] : [resolve(containerfileDir)];
|
|
18092
|
+
yield* podmanExec(["build", "-t", imageName, ...buildContext]);
|
|
18061
18093
|
});
|
|
18094
|
+
var removeImage2 = (imageName) => podmanExec(["rmi", imageName]).pipe(
|
|
18095
|
+
Effect_exports.asVoid,
|
|
18096
|
+
Effect_exports.catchTag(
|
|
18097
|
+
"PodmanError",
|
|
18098
|
+
(error3) => error3.message.includes("image not known") ? Effect_exports.fail(
|
|
18099
|
+
new ImageNotFoundError({
|
|
18100
|
+
message: `Podman image '${imageName}' does not exist, so there is nothing to remove.`
|
|
18101
|
+
})
|
|
18102
|
+
) : Effect_exports.fail(error3)
|
|
18103
|
+
)
|
|
18104
|
+
);
|
|
18062
18105
|
var GITIGNORE = `.env
|
|
18063
18106
|
logs/
|
|
18064
18107
|
worktrees/
|
|
@@ -18099,62 +18142,71 @@ var LOCKFILES = [
|
|
|
18099
18142
|
["yarn.lock", "yarn"],
|
|
18100
18143
|
["package-lock.json", "npm"]
|
|
18101
18144
|
];
|
|
18102
|
-
var
|
|
18145
|
+
var PackageJson = Schema_exports.parseJson(
|
|
18146
|
+
Schema_exports.Record({ key: Schema_exports.String, value: Schema_exports.Unknown })
|
|
18147
|
+
);
|
|
18148
|
+
var readHostPackageJson = (repoDir) => Effect_exports.gen(function* () {
|
|
18103
18149
|
const fs = yield* FileSystem_exports.FileSystem;
|
|
18104
18150
|
const pkgPath = join(repoDir, "package.json");
|
|
18105
|
-
const
|
|
18106
|
-
if (
|
|
18107
|
-
|
|
18108
|
-
|
|
18109
|
-
|
|
18110
|
-
|
|
18111
|
-
|
|
18112
|
-
|
|
18113
|
-
|
|
18114
|
-
|
|
18115
|
-
|
|
18116
|
-
|
|
18151
|
+
const exists = yield* fs.exists(pkgPath).pipe(Effect_exports.orElseSucceed(() => false));
|
|
18152
|
+
if (!exists) {
|
|
18153
|
+
return Option_exports.none();
|
|
18154
|
+
}
|
|
18155
|
+
const content = yield* fs.readFileString(pkgPath).pipe(Effect_exports.orElseSucceed(() => ""));
|
|
18156
|
+
return Schema_exports.decodeUnknownOption(PackageJson)(content);
|
|
18157
|
+
});
|
|
18158
|
+
var detectPackageManager = (repoDir) => Effect_exports.gen(function* () {
|
|
18159
|
+
const fs = yield* FileSystem_exports.FileSystem;
|
|
18160
|
+
const pkg = yield* readHostPackageJson(repoDir);
|
|
18161
|
+
const field = Option_exports.getOrUndefined(pkg)?.["packageManager"];
|
|
18162
|
+
if (typeof field === "string") {
|
|
18163
|
+
const name = field.split("@")[0];
|
|
18164
|
+
const match6 = PACKAGE_MANAGERS.find((pm) => pm === name);
|
|
18165
|
+
if (match6) {
|
|
18166
|
+
return match6;
|
|
18117
18167
|
}
|
|
18118
18168
|
}
|
|
18119
18169
|
for (const [file4, pm] of LOCKFILES) {
|
|
18120
18170
|
const exists = yield* fs.exists(join(repoDir, file4)).pipe(Effect_exports.orElseSucceed(() => false));
|
|
18121
|
-
if (exists)
|
|
18171
|
+
if (exists) {
|
|
18172
|
+
return pm;
|
|
18173
|
+
}
|
|
18122
18174
|
}
|
|
18123
18175
|
return "npm";
|
|
18124
18176
|
});
|
|
18125
18177
|
var addDependencyCommand = (packageManager, pkg) => {
|
|
18126
18178
|
switch (packageManager) {
|
|
18127
|
-
case "pnpm":
|
|
18179
|
+
case "pnpm": {
|
|
18128
18180
|
return `pnpm add ${pkg}`;
|
|
18129
|
-
|
|
18181
|
+
}
|
|
18182
|
+
case "yarn": {
|
|
18130
18183
|
return `yarn add ${pkg}`;
|
|
18131
|
-
|
|
18184
|
+
}
|
|
18185
|
+
case "bun": {
|
|
18132
18186
|
return `bun add ${pkg}`;
|
|
18133
|
-
|
|
18187
|
+
}
|
|
18188
|
+
case "npm": {
|
|
18134
18189
|
return `npm install ${pkg}`;
|
|
18190
|
+
}
|
|
18135
18191
|
}
|
|
18136
18192
|
};
|
|
18193
|
+
var runScriptCommand = (packageManager, script) => `${packageManager} run ${script}`;
|
|
18194
|
+
var installCommand = (packageManager) => `${packageManager} install`;
|
|
18137
18195
|
var hostHasDependency = (repoDir, pkg) => Effect_exports.gen(function* () {
|
|
18138
|
-
const
|
|
18139
|
-
|
|
18140
|
-
const exists = yield* fs.exists(pkgPath).pipe(Effect_exports.orElseSucceed(() => false));
|
|
18141
|
-
if (!exists) return false;
|
|
18142
|
-
const content = yield* fs.readFileString(pkgPath).pipe(Effect_exports.orElseSucceed(() => ""));
|
|
18143
|
-
try {
|
|
18144
|
-
const parsed = JSON.parse(content);
|
|
18145
|
-
const depMaps = [
|
|
18146
|
-
"dependencies",
|
|
18147
|
-
"devDependencies",
|
|
18148
|
-
"peerDependencies",
|
|
18149
|
-
"optionalDependencies"
|
|
18150
|
-
];
|
|
18151
|
-
return depMaps.some((key) => {
|
|
18152
|
-
const deps = parsed[key];
|
|
18153
|
-
return typeof deps === "object" && deps !== null && pkg in deps;
|
|
18154
|
-
});
|
|
18155
|
-
} catch {
|
|
18196
|
+
const parsed = yield* readHostPackageJson(repoDir);
|
|
18197
|
+
if (Option_exports.isNone(parsed)) {
|
|
18156
18198
|
return false;
|
|
18157
18199
|
}
|
|
18200
|
+
const depMaps = [
|
|
18201
|
+
"dependencies",
|
|
18202
|
+
"devDependencies",
|
|
18203
|
+
"peerDependencies",
|
|
18204
|
+
"optionalDependencies"
|
|
18205
|
+
];
|
|
18206
|
+
return depMaps.some((key) => {
|
|
18207
|
+
const deps = parsed.value[key];
|
|
18208
|
+
return typeof deps === "object" && deps !== null && pkg in deps;
|
|
18209
|
+
});
|
|
18158
18210
|
});
|
|
18159
18211
|
var CLAUDE_CODE_DOCKERFILE = `FROM node:22-bookworm
|
|
18160
18212
|
|
|
@@ -18272,7 +18324,7 @@ ARG AGENT_UID=1000
|
|
|
18272
18324
|
ARG AGENT_GID=1000
|
|
18273
18325
|
|
|
18274
18326
|
# Rename the base image's "node" user to "agent" and align UID/GID.
|
|
18275
|
-
RUN groupmod -g $AGENT_GID node && usermod -u $AGENT_UID -g $AGENT_GID -d /home/agent -m -l agent node
|
|
18327
|
+
RUN groupmod -o -g $AGENT_GID node && usermod -o -u $AGENT_UID -g $AGENT_GID -d /home/agent -m -l agent node
|
|
18276
18328
|
USER \${AGENT_UID}:\${AGENT_GID}
|
|
18277
18329
|
|
|
18278
18330
|
# Install Cursor Agent CLI
|
|
@@ -18315,9 +18367,9 @@ USER \${AGENT_UID}:\${AGENT_GID}
|
|
|
18315
18367
|
|
|
18316
18368
|
WORKDIR /home/agent
|
|
18317
18369
|
|
|
18318
|
-
# In worktree sandbox mode, Sandcastle bind-mounts the git worktree at
|
|
18319
|
-
# and overrides the working directory to
|
|
18320
|
-
# Structure your Dockerfile so that
|
|
18370
|
+
# In worktree sandbox mode, Sandcastle bind-mounts the git worktree at ${SANDBOX_REPO_DIR}
|
|
18371
|
+
# and overrides the working directory to ${SANDBOX_REPO_DIR} at container start.
|
|
18372
|
+
# Structure your Dockerfile so that ${SANDBOX_REPO_DIR} can serve as the project root.
|
|
18321
18373
|
ENTRYPOINT ["sleep", "infinity"]
|
|
18322
18374
|
`;
|
|
18323
18375
|
var COPILOT_DOCKERFILE = `FROM node:22-bookworm
|
|
@@ -18347,16 +18399,16 @@ USER \${AGENT_UID}:\${AGENT_GID}
|
|
|
18347
18399
|
|
|
18348
18400
|
WORKDIR /home/agent
|
|
18349
18401
|
|
|
18350
|
-
# In worktree sandbox mode, Sandcastle bind-mounts the git worktree at
|
|
18351
|
-
# and overrides the working directory to
|
|
18352
|
-
# Structure your Dockerfile so that
|
|
18402
|
+
# In worktree sandbox mode, Sandcastle bind-mounts the git worktree at ${SANDBOX_REPO_DIR}
|
|
18403
|
+
# and overrides the working directory to ${SANDBOX_REPO_DIR} at container start.
|
|
18404
|
+
# Structure your Dockerfile so that ${SANDBOX_REPO_DIR} can serve as the project root.
|
|
18353
18405
|
ENTRYPOINT ["sleep", "infinity"]
|
|
18354
18406
|
`;
|
|
18355
18407
|
var AGENT_REGISTRY = [
|
|
18356
18408
|
{
|
|
18357
18409
|
name: "claude-code",
|
|
18358
18410
|
label: "Claude Code",
|
|
18359
|
-
defaultModel: "claude-opus-4-
|
|
18411
|
+
defaultModel: "claude-opus-4-8",
|
|
18360
18412
|
factoryImport: "claudeCode",
|
|
18361
18413
|
dockerfileTemplate: CLAUDE_CODE_DOCKERFILE,
|
|
18362
18414
|
envExample: `# Claude Code OAuth token \u2014 get one by running \`claude setup-token\` on your host.
|
|
@@ -18364,7 +18416,11 @@ var AGENT_REGISTRY = [
|
|
|
18364
18416
|
CLAUDE_CODE_OAUTH_TOKEN=
|
|
18365
18417
|
# Or use an Anthropic API key instead \u2014 uncomment and fill in:
|
|
18366
18418
|
# ANTHROPIC_API_KEY=`,
|
|
18367
|
-
setupCommand: `claude "$(cat ${SETUP_ISSUE_TRACKER_PATH})"
|
|
18419
|
+
setupCommand: `claude "$(cat ${SETUP_ISSUE_TRACKER_PATH})"`,
|
|
18420
|
+
hostCli: {
|
|
18421
|
+
command: "claude",
|
|
18422
|
+
install: "curl -fsSL https://claude.ai/install.sh | bash"
|
|
18423
|
+
}
|
|
18368
18424
|
},
|
|
18369
18425
|
{
|
|
18370
18426
|
name: "pi",
|
|
@@ -18374,7 +18430,11 @@ CLAUDE_CODE_OAUTH_TOKEN=
|
|
|
18374
18430
|
dockerfileTemplate: PI_DOCKERFILE,
|
|
18375
18431
|
envExample: `# Anthropic API key
|
|
18376
18432
|
ANTHROPIC_API_KEY=`,
|
|
18377
|
-
setupCommand: `pi "$(cat ${SETUP_ISSUE_TRACKER_PATH})"
|
|
18433
|
+
setupCommand: `pi "$(cat ${SETUP_ISSUE_TRACKER_PATH})"`,
|
|
18434
|
+
hostCli: {
|
|
18435
|
+
command: "pi",
|
|
18436
|
+
install: "npm install -g @mariozechner/pi-coding-agent"
|
|
18437
|
+
}
|
|
18378
18438
|
},
|
|
18379
18439
|
{
|
|
18380
18440
|
name: "codex",
|
|
@@ -18382,9 +18442,13 @@ ANTHROPIC_API_KEY=`,
|
|
|
18382
18442
|
defaultModel: "gpt-5.4",
|
|
18383
18443
|
factoryImport: "codex",
|
|
18384
18444
|
dockerfileTemplate: CODEX_DOCKERFILE,
|
|
18385
|
-
envExample: `# OpenAI API key
|
|
18386
|
-
|
|
18387
|
-
setupCommand: `codex "$(cat ${SETUP_ISSUE_TRACKER_PATH})"
|
|
18445
|
+
envExample: `# OpenAI API key from platform.openai.com (\`codex exec\` reads CODEX_API_KEY)
|
|
18446
|
+
CODEX_API_KEY=`,
|
|
18447
|
+
setupCommand: `codex "$(cat ${SETUP_ISSUE_TRACKER_PATH})"`,
|
|
18448
|
+
hostCli: {
|
|
18449
|
+
command: "codex",
|
|
18450
|
+
install: "npm install -g @openai/codex"
|
|
18451
|
+
}
|
|
18388
18452
|
},
|
|
18389
18453
|
{
|
|
18390
18454
|
name: "cursor",
|
|
@@ -18395,7 +18459,11 @@ OPENAI_KEY=`,
|
|
|
18395
18459
|
envExample: `# Cursor API key (recommended)
|
|
18396
18460
|
# You can also pass --api-key directly to the agent CLI.
|
|
18397
18461
|
CURSOR_API_KEY=`,
|
|
18398
|
-
setupCommand: `agent "$(cat ${SETUP_ISSUE_TRACKER_PATH})"
|
|
18462
|
+
setupCommand: `agent "$(cat ${SETUP_ISSUE_TRACKER_PATH})"`,
|
|
18463
|
+
hostCli: {
|
|
18464
|
+
command: "agent",
|
|
18465
|
+
install: "curl https://cursor.com/install -fsS | bash"
|
|
18466
|
+
}
|
|
18399
18467
|
},
|
|
18400
18468
|
{
|
|
18401
18469
|
name: "opencode",
|
|
@@ -18405,7 +18473,11 @@ CURSOR_API_KEY=`,
|
|
|
18405
18473
|
dockerfileTemplate: OPENCODE_DOCKERFILE,
|
|
18406
18474
|
envExample: `# OpenCode API key
|
|
18407
18475
|
OPENCODE_API_KEY=`,
|
|
18408
|
-
setupCommand: `opencode --prompt "$(cat ${SETUP_ISSUE_TRACKER_PATH})"
|
|
18476
|
+
setupCommand: `opencode --prompt "$(cat ${SETUP_ISSUE_TRACKER_PATH})"`,
|
|
18477
|
+
hostCli: {
|
|
18478
|
+
command: "opencode",
|
|
18479
|
+
install: "npm install -g opencode-ai@latest"
|
|
18480
|
+
}
|
|
18409
18481
|
},
|
|
18410
18482
|
{
|
|
18411
18483
|
name: "copilot",
|
|
@@ -18415,12 +18487,43 @@ OPENCODE_API_KEY=`,
|
|
|
18415
18487
|
dockerfileTemplate: COPILOT_DOCKERFILE,
|
|
18416
18488
|
envExample: `# GitHub token with the "Copilot Requests" permission
|
|
18417
18489
|
# (a fine-grained PAT, or any token from \`gh auth login\`).
|
|
18418
|
-
# COPILOT_GITHUB_TOKEN
|
|
18419
|
-
|
|
18420
|
-
|
|
18490
|
+
# Copilot CLI reads COPILOT_GITHUB_TOKEN first, then GH_TOKEN, then GITHUB_TOKEN,
|
|
18491
|
+
# so this key is used even when GH_TOKEN is set for the issue tracker.
|
|
18492
|
+
COPILOT_GITHUB_TOKEN=`,
|
|
18493
|
+
setupCommand: `copilot -i "$(cat ${SETUP_ISSUE_TRACKER_PATH})"`,
|
|
18494
|
+
hostCli: {
|
|
18495
|
+
command: "copilot",
|
|
18496
|
+
install: "npm install -g @github/copilot"
|
|
18497
|
+
}
|
|
18421
18498
|
}
|
|
18422
18499
|
];
|
|
18423
18500
|
var listAgents = () => AGENT_REGISTRY;
|
|
18501
|
+
var isFile = (fs, candidate) => fs.stat(candidate).pipe(
|
|
18502
|
+
Effect_exports.map((info) => info.type === "File"),
|
|
18503
|
+
Effect_exports.orElseSucceed(() => false)
|
|
18504
|
+
);
|
|
18505
|
+
var isOnHostPath = (command) => Effect_exports.gen(function* () {
|
|
18506
|
+
const fs = yield* FileSystem_exports.FileSystem;
|
|
18507
|
+
const pathValue = yield* Config_exports.string("PATH").pipe(
|
|
18508
|
+
Config_exports.withDefault(""),
|
|
18509
|
+
Effect_exports.orElseSucceed(() => "")
|
|
18510
|
+
);
|
|
18511
|
+
const pathExt = yield* Config_exports.string("PATHEXT").pipe(
|
|
18512
|
+
Config_exports.withDefault(".EXE;.CMD;.BAT"),
|
|
18513
|
+
Effect_exports.orElseSucceed(() => "")
|
|
18514
|
+
);
|
|
18515
|
+
const extensions = process.platform === "win32" ? ["", ...pathExt.split(";")] : [""];
|
|
18516
|
+
const candidates = pathValue.split(delimiter).filter((dir) => dir !== "").flatMap((dir) => extensions.map((ext) => join(dir, `${command}${ext}`)));
|
|
18517
|
+
const found = yield* Effect_exports.all(
|
|
18518
|
+
candidates.map((candidate) => isFile(fs, candidate)),
|
|
18519
|
+
{ concurrency: "unbounded" }
|
|
18520
|
+
);
|
|
18521
|
+
return found.includes(true);
|
|
18522
|
+
});
|
|
18523
|
+
var agentCliWarning = (agent, sandboxProvider) => Effect_exports.map(
|
|
18524
|
+
isOnHostPath(agent.hostCli.command),
|
|
18525
|
+
(found) => found ? void 0 : `The ${agent.label} CLI (\`${agent.hostCli.command}\`) isn't on your PATH, and ${sandboxProvider.name}() runs the host's own agent CLI. Install it with: ${agent.hostCli.install}`
|
|
18526
|
+
);
|
|
18424
18527
|
var GITHUB_CLI_TOOLS = `# Install GitHub CLI
|
|
18425
18528
|
RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \\
|
|
18426
18529
|
| dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \\
|
|
@@ -18428,6 +18531,25 @@ RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \\
|
|
|
18428
18531
|
| tee /etc/apt/sources.list.d/github-cli.list > /dev/null \\
|
|
18429
18532
|
&& apt-get update && apt-get install -y gh \\
|
|
18430
18533
|
&& rm -rf /var/lib/apt/lists/*`;
|
|
18534
|
+
var BEADS_VERSION = "1.3.2";
|
|
18535
|
+
var BEADS_SANDBOX_DIR = "/home/agent/host-beads";
|
|
18536
|
+
var BEADS_SANDBOX_OPTIONS = `// Beads keeps its database in .beads/, which git ignores, so a worktree
|
|
18537
|
+
// sandbox never gets it. Mount the host's .beads/ into every sandbox and point
|
|
18538
|
+
// bd at it, so every phase reads and closes issues in the one shared database.
|
|
18539
|
+
// Run this file from the repo root (hostPath is relative to the cwd).
|
|
18540
|
+
const sandboxOptions = {
|
|
18541
|
+
mounts: [{ hostPath: ".beads", sandboxPath: "${BEADS_SANDBOX_DIR}" }],
|
|
18542
|
+
env: { BEADS_DIR: "${BEADS_SANDBOX_DIR}" },
|
|
18543
|
+
};`;
|
|
18544
|
+
var BEADS_NATIVE_SANDBOX_OPTIONS = `// Beads keeps its database in .beads/, which git ignores, so a worktree
|
|
18545
|
+
// sandbox never gets it. Mount the host's .beads/ into every sandbox, at its
|
|
18546
|
+
// own path, and point bd at it, so every phase reads and closes issues in the
|
|
18547
|
+
// one shared database. Run this file from the repo root.
|
|
18548
|
+
const beadsDir = \`\${process.cwd()}/.beads\`;
|
|
18549
|
+
const sandboxOptions = {
|
|
18550
|
+
mounts: [{ hostPath: beadsDir, sandboxPath: beadsDir }],
|
|
18551
|
+
env: { BEADS_DIR: beadsDir },
|
|
18552
|
+
};`;
|
|
18431
18553
|
var BEADS_TOOLS = `# Install system dependencies for Beads
|
|
18432
18554
|
RUN apt-get update && apt-get install -y \\
|
|
18433
18555
|
dpkg-dev \\
|
|
@@ -18438,9 +18560,45 @@ RUN apt-get update && apt-get install -y \\
|
|
|
18438
18560
|
ln -s "$lib" "\${lib%.72}.74"; \\
|
|
18439
18561
|
done
|
|
18440
18562
|
|
|
18441
|
-
|
|
18563
|
+
# Pinned bd release. Every sandbox opens your host's beads database (see
|
|
18564
|
+
# sandboxOptions in main), so keep this equal to the host's \`bd version\`.
|
|
18565
|
+
ARG BEADS_VERSION=${BEADS_VERSION}
|
|
18566
|
+
RUN ARCH=$(dpkg --print-architecture) \\
|
|
18567
|
+
&& BEADS_TARBALL="beads_\${BEADS_VERSION}_linux_\${ARCH}.tar.gz" \\
|
|
18568
|
+
&& BEADS_URL="https://github.com/gastownhall/beads/releases/download/v\${BEADS_VERSION}" \\
|
|
18569
|
+
&& cd /tmp \\
|
|
18570
|
+
&& curl -fsSLO "\${BEADS_URL}/\${BEADS_TARBALL}" \\
|
|
18571
|
+
&& curl -fsSL "\${BEADS_URL}/checksums.txt" | grep " \${BEADS_TARBALL}$" | sha256sum -c - \\
|
|
18572
|
+
&& tar -xzf "\${BEADS_TARBALL}" -C /usr/local/bin bd \\
|
|
18573
|
+
&& rm "\${BEADS_TARBALL}" \\
|
|
18574
|
+
&& bd version
|
|
18442
18575
|
|
|
18443
18576
|
RUN corepack enable`;
|
|
18577
|
+
var parseBdVersion = (output) => /\bbd version v?(?<version>\d+\.\d+\.\d+)\b/u.exec(output)?.groups?.version;
|
|
18578
|
+
var compareVersions = (a, b) => {
|
|
18579
|
+
const pa = a.split(".").map(Number);
|
|
18580
|
+
const pb = b.split(".").map(Number);
|
|
18581
|
+
for (let i = 0; i < 3; i++) {
|
|
18582
|
+
const diff = (pa[i] ?? 0) - (pb[i] ?? 0);
|
|
18583
|
+
if (diff !== 0) {
|
|
18584
|
+
return diff;
|
|
18585
|
+
}
|
|
18586
|
+
}
|
|
18587
|
+
return 0;
|
|
18588
|
+
};
|
|
18589
|
+
var beadsVersionWarning = (hostVersion) => {
|
|
18590
|
+
if (hostVersion === BEADS_VERSION) {
|
|
18591
|
+
return void 0;
|
|
18592
|
+
}
|
|
18593
|
+
const shared = `the image installs bd ${BEADS_VERSION}, and every sandbox opens your .beads/ with it`;
|
|
18594
|
+
if (hostVersion === void 0) {
|
|
18595
|
+
return `bd isn't on your PATH, and ${shared}. Use bd ${BEADS_VERSION} on the host too, or an older host bd can no longer create issues once a sandbox has opened the database.`;
|
|
18596
|
+
}
|
|
18597
|
+
if (compareVersions(hostVersion, BEADS_VERSION) < 0) {
|
|
18598
|
+
return `Your host runs bd ${hostVersion}, but ${shared}. bd ${BEADS_VERSION} migrates the database, after which host bd ${hostVersion} can no longer create issues in it. Upgrade the host's bd to ${BEADS_VERSION} before you run.`;
|
|
18599
|
+
}
|
|
18600
|
+
return `Your host runs bd ${hostVersion}, but ${shared}, and an older bd can't safely write a database a newer one has migrated. Set ARG BEADS_VERSION in the Dockerfile to ${hostVersion} and rebuild the image, or use bd ${BEADS_VERSION} on the host.`;
|
|
18601
|
+
};
|
|
18444
18602
|
var CUSTOM_LIST_TASKS_SENTINEL = `echo 'No issue tracker configured \u2014 run ${SETUP_ISSUE_TRACKER_PATH} through your coding agent.' >&2; exit 1`;
|
|
18445
18603
|
var CUSTOM_VIEW_TASK_MARKER = `<view command \u2014 see ${SETUP_ISSUE_TRACKER_PATH}>`;
|
|
18446
18604
|
var CUSTOM_CLOSE_TASK_MARKER = `<close command \u2014 see ${SETUP_ISSUE_TRACKER_PATH}>`;
|
|
@@ -18471,7 +18629,9 @@ GH_TOKEN=`
|
|
|
18471
18629
|
CLOSE_TASK_COMMAND: `bd close <ID> --reason="Completed by Sandcastle"`,
|
|
18472
18630
|
ISSUE_TRACKER_TOOLS: BEADS_TOOLS
|
|
18473
18631
|
},
|
|
18474
|
-
envExample: ""
|
|
18632
|
+
envExample: "",
|
|
18633
|
+
sandboxOptions: BEADS_SANDBOX_OPTIONS,
|
|
18634
|
+
nativeSandboxOptions: BEADS_NATIVE_SANDBOX_OPTIONS
|
|
18475
18635
|
},
|
|
18476
18636
|
{
|
|
18477
18637
|
name: "custom",
|
|
@@ -18496,91 +18656,120 @@ var SANDBOX_PROVIDER_REGISTRY = [
|
|
|
18496
18656
|
{
|
|
18497
18657
|
name: "docker",
|
|
18498
18658
|
label: "Docker",
|
|
18499
|
-
containerfileName: "Dockerfile",
|
|
18500
|
-
cliNamespace: "docker"
|
|
18659
|
+
image: { containerfileName: "Dockerfile", cliNamespace: "docker" }
|
|
18501
18660
|
},
|
|
18502
18661
|
{
|
|
18503
18662
|
name: "podman",
|
|
18504
18663
|
label: "Podman",
|
|
18505
|
-
containerfileName: "Containerfile",
|
|
18506
|
-
|
|
18664
|
+
image: { containerfileName: "Containerfile", cliNamespace: "podman" }
|
|
18665
|
+
},
|
|
18666
|
+
{
|
|
18667
|
+
name: "bwrap",
|
|
18668
|
+
label: "Bubblewrap",
|
|
18669
|
+
nativePlatform: "linux",
|
|
18670
|
+
preflight: assertBwrapUsable
|
|
18671
|
+
},
|
|
18672
|
+
{
|
|
18673
|
+
name: "seatbelt",
|
|
18674
|
+
label: "Seatbelt",
|
|
18675
|
+
nativePlatform: "darwin",
|
|
18676
|
+
preflight: assertSeatbeltUsable
|
|
18507
18677
|
}
|
|
18508
18678
|
];
|
|
18509
18679
|
var listSandboxProviders = () => SANDBOX_PROVIDER_REGISTRY;
|
|
18680
|
+
var listSandboxProviderChoices = (platform) => {
|
|
18681
|
+
const native = SANDBOX_PROVIDER_REGISTRY.filter(
|
|
18682
|
+
(p3) => p3.nativePlatform === platform
|
|
18683
|
+
);
|
|
18684
|
+
const others = SANDBOX_PROVIDER_REGISTRY.filter(
|
|
18685
|
+
(p3) => p3.nativePlatform === void 0
|
|
18686
|
+
);
|
|
18687
|
+
return [
|
|
18688
|
+
...native.map((entry) => ({ entry, recommended: true })),
|
|
18689
|
+
...others.map((entry) => ({ entry, recommended: false }))
|
|
18690
|
+
];
|
|
18691
|
+
};
|
|
18692
|
+
var sandboxProviderPreflightWarning = (sandboxProvider) => {
|
|
18693
|
+
try {
|
|
18694
|
+
sandboxProvider.preflight?.();
|
|
18695
|
+
return void 0;
|
|
18696
|
+
} catch (error3) {
|
|
18697
|
+
const reason = error3 instanceof Error ? error3.message : String(error3);
|
|
18698
|
+
return `This host can't run ${sandboxProvider.name}() yet, so the scaffolded main file fails until you fix it. ${reason}`;
|
|
18699
|
+
}
|
|
18700
|
+
};
|
|
18510
18701
|
var getSandboxProvider = (name) => SANDBOX_PROVIDER_REGISTRY.find((p3) => p3.name === name);
|
|
18511
|
-
|
|
18702
|
+
var envNotes = (issueTracker, agent, sandboxProvider) => [
|
|
18703
|
+
...agent.name === "claude-code" ? [
|
|
18704
|
+
" To use your Claude subscription instead of an API key, run `claude setup-token` on your host and paste the result into CLAUDE_CODE_OAUTH_TOKEN."
|
|
18705
|
+
] : [],
|
|
18706
|
+
// A native sandbox hides the host's gh login, so gh authenticates only
|
|
18707
|
+
// from the env Sandcastle passes in.
|
|
18708
|
+
...issueTracker.name === "github-issues" && sandboxProvider.image === void 0 ? [
|
|
18709
|
+
` ${sandboxProvider.name}() hides your host's \`gh\` login from the agent, so put a GH_TOKEN in .sandcastle/.env for \`gh\` to use.`
|
|
18710
|
+
] : []
|
|
18711
|
+
];
|
|
18712
|
+
var getNextStepsLines = (template, mainFilename, issueTracker, agent, packageManager, installedDependencies, sandboxProvider = SANDBOX_PROVIDER_REGISTRY[0]) => {
|
|
18713
|
+
const runStep = `Run \`${runScriptCommand(packageManager, "sandcastle")}\` to start the agent`;
|
|
18512
18714
|
if (issueTracker.name === "custom") {
|
|
18715
|
+
const hasImage = sandboxProvider.image !== void 0;
|
|
18513
18716
|
return [
|
|
18514
18717
|
"Next steps:",
|
|
18515
18718
|
"1. Your custom issue tracker isn't wired up yet \u2014 runs hard-fail until you configure it.",
|
|
18516
18719
|
`2. Feed the setup prompt to ${agent.label} on your host to finish wiring it up:`,
|
|
18517
18720
|
` ${agent.setupCommand}`,
|
|
18518
|
-
` (Runs on the host \u2014 you need the ${agent.label} CLI installed locally, since the sandbox image isn't built yet.)`,
|
|
18519
|
-
`3. Follow .sandcastle/${SETUP_ISSUE_TRACKER_DOC} to edit the scaffolded files in place, build the image, and verify.`
|
|
18721
|
+
hasImage ? ` (Runs on the host \u2014 you need the ${agent.label} CLI installed locally, since the sandbox image isn't built yet.)` : ` (Runs on the host \u2014 you need the ${agent.label} CLI installed locally.)`,
|
|
18722
|
+
hasImage ? `3. Follow .sandcastle/${SETUP_ISSUE_TRACKER_DOC} to edit the scaffolded files in place, build the image, and verify.` : `3. Follow .sandcastle/${SETUP_ISSUE_TRACKER_DOC} to edit the scaffolded files in place and verify.`
|
|
18520
18723
|
];
|
|
18521
18724
|
}
|
|
18522
18725
|
if (template === "blank") {
|
|
18523
|
-
|
|
18726
|
+
return [
|
|
18524
18727
|
"Next steps:",
|
|
18525
|
-
`1. Set the required env vars in .sandcastle/.env (see .sandcastle/.env.example)
|
|
18526
|
-
|
|
18527
|
-
if (agent.name === "claude-code") {
|
|
18528
|
-
lines2.push(
|
|
18529
|
-
" To use your Claude subscription instead of an API key, run `claude setup-token` on your host and paste the result into CLAUDE_CODE_OAUTH_TOKEN."
|
|
18530
|
-
);
|
|
18531
|
-
}
|
|
18532
|
-
lines2.push(
|
|
18728
|
+
`1. Set the required env vars in .sandcastle/.env (see .sandcastle/.env.example)`,
|
|
18729
|
+
...envNotes(issueTracker, agent, sandboxProvider),
|
|
18533
18730
|
"2. Read and customize .sandcastle/prompt.md to describe what you want the agent to do",
|
|
18534
18731
|
`3. Customize .sandcastle/${mainFilename} \u2014 it uses the JS API (\`run()\`) to control how the agent runs`,
|
|
18535
18732
|
`4. Add "sandcastle": "npx tsx .sandcastle/${mainFilename}" to your package.json scripts`,
|
|
18536
|
-
|
|
18537
|
-
);
|
|
18538
|
-
return lines2;
|
|
18539
|
-
} else {
|
|
18540
|
-
const hasReviewer = template.includes("review");
|
|
18541
|
-
const usesPlanSchema = getTemplateDependencies(template).includes("zod");
|
|
18542
|
-
let step = 1;
|
|
18543
|
-
const lines2 = [
|
|
18544
|
-
"Next steps:",
|
|
18545
|
-
`${step++}. Set the required env vars in .sandcastle/.env (see .sandcastle/.env.example)`
|
|
18733
|
+
`5. ${runStep}`
|
|
18546
18734
|
];
|
|
18547
|
-
|
|
18548
|
-
|
|
18549
|
-
|
|
18550
|
-
|
|
18551
|
-
|
|
18735
|
+
}
|
|
18736
|
+
const hasReviewer = template.includes("review");
|
|
18737
|
+
const needsPlanSchema = getTemplateDependencies(template).includes("zod") && !installedDependencies.includes("zod");
|
|
18738
|
+
let step = 1;
|
|
18739
|
+
const lines2 = [
|
|
18740
|
+
"Next steps:",
|
|
18741
|
+
`${step++}. Set the required env vars in .sandcastle/.env (see .sandcastle/.env.example)`,
|
|
18742
|
+
...envNotes(issueTracker, agent, sandboxProvider),
|
|
18743
|
+
`${step++}. Add "sandcastle": "npx tsx .sandcastle/${mainFilename}" to your package.json scripts`,
|
|
18744
|
+
`${step++}. Templates use \`copyToWorktree: ["node_modules"]\` to copy your host node_modules into the sandbox for fast startup \u2014 the \`npm install\` in the onSandboxReady hook is a safety net for platform-specific binaries. ${packageManager === "npm" ? "Adjust both if you use a different package manager" : `This project uses ${packageManager}, so change the hook to \`${installCommand(packageManager)}\` and check \`copyToWorktree\` suits it`}`
|
|
18745
|
+
];
|
|
18746
|
+
if (needsPlanSchema) {
|
|
18552
18747
|
lines2.push(
|
|
18553
|
-
`${step++}.
|
|
18554
|
-
`${step++}. Templates use \`copyToWorktree: ["node_modules"]\` to copy your host node_modules into the sandbox for fast startup \u2014 the \`npm install\` in the onSandboxReady hook is a safety net for platform-specific binaries. Adjust both if you use a different package manager`
|
|
18748
|
+
`${step++}. Install a schema validator for the planner's \`<plan>\` output \u2014 the template uses Zod (\`${addDependencyCommand(packageManager, "zod")}\`), but Valibot, ArkType, or any Standard Schema library works (https://standardschema.dev)`
|
|
18555
18749
|
);
|
|
18556
|
-
|
|
18557
|
-
|
|
18558
|
-
|
|
18559
|
-
|
|
18560
|
-
|
|
18750
|
+
}
|
|
18751
|
+
lines2.push(
|
|
18752
|
+
`${step++}. Read and customize the prompt files in .sandcastle/ \u2014 they shape what the agent does`
|
|
18753
|
+
);
|
|
18754
|
+
if (hasReviewer) {
|
|
18561
18755
|
lines2.push(
|
|
18562
|
-
`${step++}.
|
|
18756
|
+
`${step++}. Customize .sandcastle/CODING_STANDARDS.md with your project's standards \u2014 the reviewer agent loads it during review`
|
|
18563
18757
|
);
|
|
18564
|
-
if (hasReviewer) {
|
|
18565
|
-
lines2.push(
|
|
18566
|
-
`${step++}. Customize .sandcastle/CODING_STANDARDS.md with your project's standards \u2014 the reviewer agent loads it during review`
|
|
18567
|
-
);
|
|
18568
|
-
}
|
|
18569
|
-
lines2.push(`${step++}. Run \`npm run sandcastle\` to start the agent`);
|
|
18570
|
-
return lines2;
|
|
18571
18758
|
}
|
|
18572
|
-
}
|
|
18573
|
-
|
|
18759
|
+
lines2.push(`${step++}. ${runStep}`);
|
|
18760
|
+
return lines2;
|
|
18761
|
+
};
|
|
18762
|
+
var getTemplatesDir = () => {
|
|
18574
18763
|
const thisFile = fileURLToPath(import.meta.url);
|
|
18575
18764
|
return join(dirname(thisFile), "templates");
|
|
18576
|
-
}
|
|
18765
|
+
};
|
|
18577
18766
|
var getTemplateDir = (templateName) => Effect_exports.gen(function* () {
|
|
18578
18767
|
const template = TEMPLATES.find((t) => t.name === templateName);
|
|
18579
18768
|
if (!template) {
|
|
18580
18769
|
const names = TEMPLATES.map((t) => t.name).join(", ");
|
|
18581
|
-
yield*
|
|
18582
|
-
|
|
18583
|
-
);
|
|
18770
|
+
return yield* new InitError({
|
|
18771
|
+
message: `Unknown template: "${templateName}". Available: ${names}`
|
|
18772
|
+
});
|
|
18584
18773
|
}
|
|
18585
18774
|
return join(getTemplatesDir(), templateName);
|
|
18586
18775
|
});
|
|
@@ -18596,50 +18785,101 @@ var COMPILED_FILE_EXTENSIONS = [
|
|
|
18596
18785
|
];
|
|
18597
18786
|
var copyTemplateFiles = (templateDir, destDir, mainFilename) => Effect_exports.gen(function* () {
|
|
18598
18787
|
const fs = yield* FileSystem_exports.FileSystem;
|
|
18599
|
-
const files = yield* fs.readDirectory(templateDir).pipe(Effect_exports.mapError((e) => new
|
|
18788
|
+
const files = yield* fs.readDirectory(templateDir).pipe(Effect_exports.mapError((e) => new InitError({ message: e.message })));
|
|
18600
18789
|
yield* Effect_exports.all(
|
|
18601
18790
|
files.filter(
|
|
18602
18791
|
(f) => f !== "template.json" && f !== ".env.example" && !COMPILED_FILE_EXTENSIONS.some((ext) => f.endsWith(ext))
|
|
18603
18792
|
).map((f) => {
|
|
18604
18793
|
const destName = f === "main.mts" ? mainFilename : f;
|
|
18605
|
-
return fs.copyFile(join(templateDir, f), join(destDir, destName)).pipe(
|
|
18794
|
+
return fs.copyFile(join(templateDir, f), join(destDir, destName)).pipe(
|
|
18795
|
+
Effect_exports.mapError((e) => new InitError({ message: e.message }))
|
|
18796
|
+
);
|
|
18606
18797
|
}),
|
|
18607
18798
|
{ concurrency: "unbounded" }
|
|
18608
18799
|
);
|
|
18609
18800
|
});
|
|
18610
|
-
var
|
|
18801
|
+
var editMainFile = (choices, edit) => Effect_exports.gen(function* () {
|
|
18611
18802
|
const fs = yield* FileSystem_exports.FileSystem;
|
|
18612
|
-
const mainTsPath = join(configDir, mainFilename);
|
|
18613
|
-
const exists = yield* fs.exists(mainTsPath).pipe(Effect_exports.mapError((e) => new
|
|
18614
|
-
if (!exists)
|
|
18615
|
-
|
|
18616
|
-
|
|
18617
|
-
|
|
18618
|
-
|
|
18619
|
-
|
|
18803
|
+
const mainTsPath = join(choices.configDir, choices.mainFilename);
|
|
18804
|
+
const exists = yield* fs.exists(mainTsPath).pipe(Effect_exports.mapError((e) => new InitError({ message: e.message })));
|
|
18805
|
+
if (!exists) {
|
|
18806
|
+
return;
|
|
18807
|
+
}
|
|
18808
|
+
const content = yield* fs.readFileString(mainTsPath).pipe(Effect_exports.mapError((e) => new InitError({ message: e.message })));
|
|
18809
|
+
const updated = yield* edit(content);
|
|
18810
|
+
yield* fs.writeFileString(mainTsPath, updated).pipe(Effect_exports.mapError((e) => new InitError({ message: e.message })));
|
|
18811
|
+
});
|
|
18812
|
+
var rewriteMainContent = (original, choices) => {
|
|
18813
|
+
const { agent, model, sandboxProvider, imageName } = choices;
|
|
18814
|
+
let content = original;
|
|
18815
|
+
if (choices.mainFilename === "main.ts") {
|
|
18816
|
+
content = content.replaceAll("main.mts", "main.ts");
|
|
18817
|
+
}
|
|
18818
|
+
content = content.replaceAll(/\bclaudeCode\b/gu, agent.factoryImport);
|
|
18620
18819
|
const factoryCallRe = new RegExp(
|
|
18621
18820
|
`${agent.factoryImport}\\(["']([^"']+)["']\\)`,
|
|
18622
|
-
"
|
|
18821
|
+
"gu"
|
|
18623
18822
|
);
|
|
18624
|
-
content = content.
|
|
18823
|
+
content = content.replaceAll(
|
|
18625
18824
|
factoryCallRe,
|
|
18626
18825
|
`${agent.factoryImport}("${model}")`
|
|
18627
18826
|
);
|
|
18628
|
-
content = content.
|
|
18629
|
-
|
|
18630
|
-
|
|
18827
|
+
content = content.replaceAll(/\bdocker\b/gu, sandboxProvider.name);
|
|
18828
|
+
if (imageName !== void 0 && sandboxProvider.image !== void 0) {
|
|
18829
|
+
content = content.replaceAll(
|
|
18830
|
+
new RegExp(`\\b${sandboxProvider.name}\\(\\)`, "gu"),
|
|
18831
|
+
`${sandboxProvider.name}({ imageName: ${JSON.stringify(imageName)} })`
|
|
18832
|
+
);
|
|
18833
|
+
}
|
|
18834
|
+
return content;
|
|
18835
|
+
};
|
|
18836
|
+
var rewriteMainTs = (choices) => editMainFile(
|
|
18837
|
+
choices,
|
|
18838
|
+
(content) => Effect_exports.succeed(rewriteMainContent(content, choices))
|
|
18839
|
+
);
|
|
18840
|
+
var applyIssueTrackerSandboxOptions = (choices) => {
|
|
18841
|
+
const { issueTracker, sandboxProvider, mainFilename } = choices;
|
|
18842
|
+
const sandboxOptions = sandboxProvider.image === void 0 ? issueTracker.nativeSandboxOptions ?? issueTracker.sandboxOptions : issueTracker.sandboxOptions;
|
|
18843
|
+
if (sandboxOptions === void 0 || sandboxOptions === "") {
|
|
18844
|
+
return Effect_exports.void;
|
|
18845
|
+
}
|
|
18846
|
+
const provider = sandboxProvider.name;
|
|
18847
|
+
const importRe = new RegExp(
|
|
18848
|
+
`^import \\{ ${provider} \\} from "@ai-hero/sandcastle/sandboxes/${provider}";$`,
|
|
18849
|
+
"mu"
|
|
18850
|
+
);
|
|
18851
|
+
return editMainFile(
|
|
18852
|
+
choices,
|
|
18853
|
+
(content) => importRe.test(content) ? Effect_exports.succeed(
|
|
18854
|
+
content.replace(importRe, (line4) => `${line4}
|
|
18855
|
+
|
|
18856
|
+
${sandboxOptions}`).replaceAll(
|
|
18857
|
+
new RegExp(`\\b${provider}\\(\\)`, "gu"),
|
|
18858
|
+
`${provider}(sandboxOptions)`
|
|
18859
|
+
)
|
|
18860
|
+
) : Effect_exports.fail(
|
|
18861
|
+
new InitError({
|
|
18862
|
+
message: `Cannot apply ${issueTracker.label} sandbox options: ${mainFilename} has no ${provider} import.`
|
|
18863
|
+
})
|
|
18864
|
+
)
|
|
18865
|
+
);
|
|
18866
|
+
};
|
|
18631
18867
|
var rewritePromptFiles = (configDir) => Effect_exports.gen(function* () {
|
|
18632
18868
|
const fs = yield* FileSystem_exports.FileSystem;
|
|
18633
|
-
const files = yield* fs.readDirectory(configDir).pipe(Effect_exports.mapError((e) => new
|
|
18869
|
+
const files = yield* fs.readDirectory(configDir).pipe(Effect_exports.mapError((e) => new InitError({ message: e.message })));
|
|
18634
18870
|
const mdFiles = files.filter((f) => f.endsWith(".md"));
|
|
18635
18871
|
yield* Effect_exports.all(
|
|
18636
18872
|
mdFiles.map(
|
|
18637
18873
|
(f) => Effect_exports.gen(function* () {
|
|
18638
18874
|
const filePath = join(configDir, f);
|
|
18639
|
-
const content = yield* fs.readFileString(filePath).pipe(
|
|
18640
|
-
|
|
18875
|
+
const content = yield* fs.readFileString(filePath).pipe(
|
|
18876
|
+
Effect_exports.mapError((e) => new InitError({ message: e.message }))
|
|
18877
|
+
);
|
|
18878
|
+
const updated = content.replaceAll(" --label Sandcastle", "");
|
|
18641
18879
|
if (updated !== content) {
|
|
18642
|
-
yield* fs.writeFileString(filePath, updated).pipe(
|
|
18880
|
+
yield* fs.writeFileString(filePath, updated).pipe(
|
|
18881
|
+
Effect_exports.mapError((e) => new InitError({ message: e.message }))
|
|
18882
|
+
);
|
|
18643
18883
|
}
|
|
18644
18884
|
})
|
|
18645
18885
|
),
|
|
@@ -18654,39 +18894,71 @@ var TEXT_FILE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
18654
18894
|
// Dockerfile / Containerfile have no extension — handled by name check below
|
|
18655
18895
|
]);
|
|
18656
18896
|
var isTextFile = (filename) => {
|
|
18657
|
-
if (filename === "Dockerfile" || filename === "Containerfile" || filename === ".gitignore")
|
|
18897
|
+
if (filename === "Dockerfile" || filename === "Containerfile" || filename === ".gitignore") {
|
|
18658
18898
|
return true;
|
|
18899
|
+
}
|
|
18659
18900
|
const dotIdx = filename.lastIndexOf(".");
|
|
18660
|
-
if (dotIdx === -1)
|
|
18901
|
+
if (dotIdx === -1) {
|
|
18902
|
+
return false;
|
|
18903
|
+
}
|
|
18661
18904
|
return TEXT_FILE_EXTENSIONS.has(filename.slice(dotIdx));
|
|
18662
18905
|
};
|
|
18663
18906
|
var substituteTemplateArgs = (configDir, issueTracker) => Effect_exports.gen(function* () {
|
|
18664
18907
|
const fs = yield* FileSystem_exports.FileSystem;
|
|
18665
|
-
const files = yield* fs.readDirectory(configDir).pipe(Effect_exports.mapError((e) => new
|
|
18666
|
-
const textFiles = files.filter(isTextFile);
|
|
18908
|
+
const files = yield* fs.readDirectory(configDir).pipe(Effect_exports.mapError((e) => new InitError({ message: e.message })));
|
|
18909
|
+
const textFiles = files.filter((f) => isTextFile(f));
|
|
18667
18910
|
yield* Effect_exports.all(
|
|
18668
18911
|
textFiles.map(
|
|
18669
18912
|
(f) => Effect_exports.gen(function* () {
|
|
18670
18913
|
const filePath = join(configDir, f);
|
|
18671
|
-
let content = yield* fs.readFileString(filePath).pipe(
|
|
18914
|
+
let content = yield* fs.readFileString(filePath).pipe(
|
|
18915
|
+
Effect_exports.mapError((e) => new InitError({ message: e.message }))
|
|
18916
|
+
);
|
|
18672
18917
|
const original = content;
|
|
18673
18918
|
for (const [key, value2] of Object.entries(
|
|
18674
18919
|
issueTracker.templateArgs
|
|
18675
18920
|
)) {
|
|
18676
|
-
content = content.
|
|
18677
|
-
new RegExp(`\\{\\{${key}\\}\\}`, "
|
|
18921
|
+
content = content.replaceAll(
|
|
18922
|
+
new RegExp(`\\{\\{${key}\\}\\}`, "gu"),
|
|
18678
18923
|
value2
|
|
18679
18924
|
);
|
|
18680
18925
|
}
|
|
18681
18926
|
if (content !== original) {
|
|
18682
|
-
yield* fs.writeFileString(filePath, content).pipe(
|
|
18927
|
+
yield* fs.writeFileString(filePath, content).pipe(
|
|
18928
|
+
Effect_exports.mapError((e) => new InitError({ message: e.message }))
|
|
18929
|
+
);
|
|
18683
18930
|
}
|
|
18684
18931
|
})
|
|
18685
18932
|
),
|
|
18686
18933
|
{ concurrency: "unbounded" }
|
|
18687
18934
|
);
|
|
18688
18935
|
});
|
|
18689
|
-
var
|
|
18936
|
+
var buildImageShellCommand = (image, imageName) => `sandcastle ${image.cliNamespace} build-image${imageName === void 0 ? "" : ` --image-name ${imageName}`}`;
|
|
18937
|
+
var imageToolsStep = (buildCommand) => buildCommand === void 0 ? "" : `- **Dockerfile / Containerfile** \u2014 replace the line
|
|
18938
|
+
|
|
18939
|
+
\`\`\`
|
|
18940
|
+
${CUSTOM_TRACKER_TOOLS}
|
|
18941
|
+
\`\`\`
|
|
18942
|
+
|
|
18943
|
+
with the install steps for your tracker's CLI (if it needs one).
|
|
18944
|
+
|
|
18945
|
+
`;
|
|
18946
|
+
var verifySteps = (buildCommand) => buildCommand === void 0 ? `## 4. Verify
|
|
18947
|
+
|
|
18948
|
+
Run your **list** command and confirm it returns the open tasks as JSON. If it errors, fix the command or the auth.
|
|
18949
|
+
` : `## 4. Build the image
|
|
18950
|
+
|
|
18951
|
+
Once the files are wired up, build the sandbox image:
|
|
18952
|
+
|
|
18953
|
+
\`\`\`
|
|
18954
|
+
${buildCommand}
|
|
18955
|
+
\`\`\`
|
|
18956
|
+
|
|
18957
|
+
## 5. Verify
|
|
18958
|
+
|
|
18959
|
+
Run your **list** command inside the built image and confirm it returns the open tasks as JSON. If it errors, fix the command or the auth and rebuild.
|
|
18960
|
+
`;
|
|
18961
|
+
var buildSetupIssueTrackerDoc = (buildCommand) => `# Set up your custom issue tracker
|
|
18690
18962
|
|
|
18691
18963
|
You are a coding agent. Finish wiring up the **custom issue tracker** for this Sandcastle project. It was scaffolded in a deliberately broken-until-configured state: until you complete the steps below, every Sandcastle run hard-fails with a pointer back to this file.
|
|
18692
18964
|
|
|
@@ -18711,15 +18983,7 @@ Work out, together with the user, the shell commands for:
|
|
|
18711
18983
|
|
|
18712
18984
|
## 3. Edit the scaffolded files in place
|
|
18713
18985
|
|
|
18714
|
-
- **
|
|
18715
|
-
|
|
18716
|
-
\`\`\`
|
|
18717
|
-
${CUSTOM_TRACKER_TOOLS}
|
|
18718
|
-
\`\`\`
|
|
18719
|
-
|
|
18720
|
-
with the install steps for your tracker's CLI (if it needs one).
|
|
18721
|
-
|
|
18722
|
-
- **Prompt files (\`.sandcastle/*.md\`)** \u2014 replace the sentinel
|
|
18986
|
+
${imageToolsStep(buildCommand)}- **Prompt files (\`.sandcastle/*.md\`)** \u2014 replace the sentinel
|
|
18723
18987
|
|
|
18724
18988
|
\`\`\`
|
|
18725
18989
|
${CUSTOM_LIST_TASKS_SENTINEL}
|
|
@@ -18729,35 +18993,60 @@ Work out, together with the user, the shell commands for:
|
|
|
18729
18993
|
|
|
18730
18994
|
- **\`.env.example\`** \u2014 replace the \`# TODO\` block with the real env var(s) your tracker needs, then tell the user to set them in \`.sandcastle/.env\`.
|
|
18731
18995
|
|
|
18732
|
-
|
|
18733
|
-
|
|
18734
|
-
Once the files are wired up, build the sandbox image:
|
|
18735
|
-
|
|
18736
|
-
\`\`\`
|
|
18737
|
-
sandcastle ${cliNamespace} build-image
|
|
18738
|
-
\`\`\`
|
|
18739
|
-
|
|
18740
|
-
## 5. Verify
|
|
18741
|
-
|
|
18742
|
-
Run your **list** command inside the built image and confirm it returns the open tasks as JSON. If it errors, fix the command or the auth and rebuild.
|
|
18743
|
-
`;
|
|
18996
|
+
${verifySteps(buildCommand)}`;
|
|
18744
18997
|
var detectMainFilename = (repoDir) => Effect_exports.gen(function* () {
|
|
18998
|
+
const pkg = yield* readHostPackageJson(repoDir);
|
|
18999
|
+
return Option_exports.getOrUndefined(pkg)?.["type"] === "module" ? "main.ts" : "main.mts";
|
|
19000
|
+
});
|
|
19001
|
+
var createConfigDir = (configDir) => Effect_exports.gen(function* () {
|
|
18745
19002
|
const fs = yield* FileSystem_exports.FileSystem;
|
|
18746
|
-
const
|
|
18747
|
-
|
|
18748
|
-
|
|
18749
|
-
|
|
18750
|
-
|
|
18751
|
-
|
|
18752
|
-
|
|
18753
|
-
|
|
18754
|
-
|
|
19003
|
+
const exists = yield* fs.exists(configDir).pipe(Effect_exports.mapError((e) => new InitError({ message: e.message })));
|
|
19004
|
+
if (exists) {
|
|
19005
|
+
return yield* new InitError({
|
|
19006
|
+
message: ".sandcastle/ directory already exists. Remove it first if you want to re-initialize."
|
|
19007
|
+
});
|
|
19008
|
+
}
|
|
19009
|
+
yield* fs.makeDirectory(configDir, { recursive: false }).pipe(Effect_exports.mapError((e) => new InitError({ message: e.message })));
|
|
19010
|
+
});
|
|
19011
|
+
var writeScaffoldFiles = (choices, templateDir) => Effect_exports.gen(function* () {
|
|
19012
|
+
const fs = yield* FileSystem_exports.FileSystem;
|
|
19013
|
+
const { configDir, agent, issueTracker } = choices;
|
|
19014
|
+
const envExampleParts = [agent.envExample];
|
|
19015
|
+
if (issueTracker.envExample) {
|
|
19016
|
+
envExampleParts.push(issueTracker.envExample);
|
|
18755
19017
|
}
|
|
19018
|
+
const envExampleContent = `${envExampleParts.join("\n")}
|
|
19019
|
+
`;
|
|
19020
|
+
const { image } = choices.sandboxProvider;
|
|
19021
|
+
yield* Effect_exports.all(
|
|
19022
|
+
[
|
|
19023
|
+
...image === void 0 ? [] : [
|
|
19024
|
+
fs.writeFileString(
|
|
19025
|
+
join(configDir, image.containerfileName),
|
|
19026
|
+
agent.dockerfileTemplate
|
|
19027
|
+
).pipe(
|
|
19028
|
+
Effect_exports.mapError((e) => new InitError({ message: e.message }))
|
|
19029
|
+
)
|
|
19030
|
+
],
|
|
19031
|
+
fs.writeFileString(join(configDir, ".gitignore"), GITIGNORE).pipe(Effect_exports.mapError((e) => new InitError({ message: e.message }))),
|
|
19032
|
+
fs.writeFileString(join(configDir, ".env.example"), envExampleContent).pipe(Effect_exports.mapError((e) => new InitError({ message: e.message }))),
|
|
19033
|
+
copyTemplateFiles(templateDir, configDir, choices.mainFilename)
|
|
19034
|
+
],
|
|
19035
|
+
{ concurrency: "unbounded" }
|
|
19036
|
+
);
|
|
19037
|
+
});
|
|
19038
|
+
var writeSetupIssueTrackerDoc = (choices) => Effect_exports.gen(function* () {
|
|
19039
|
+
const fs = yield* FileSystem_exports.FileSystem;
|
|
19040
|
+
const { image } = choices.sandboxProvider;
|
|
19041
|
+
yield* fs.writeFileString(
|
|
19042
|
+
join(choices.configDir, SETUP_ISSUE_TRACKER_DOC),
|
|
19043
|
+
buildSetupIssueTrackerDoc(
|
|
19044
|
+
image === void 0 ? void 0 : buildImageShellCommand(image, choices.imageName)
|
|
19045
|
+
)
|
|
19046
|
+
).pipe(Effect_exports.mapError((e) => new InitError({ message: e.message })));
|
|
18756
19047
|
});
|
|
18757
19048
|
var scaffold = (repoDir, options3) => Effect_exports.gen(function* () {
|
|
18758
19049
|
const {
|
|
18759
|
-
agent,
|
|
18760
|
-
model,
|
|
18761
19050
|
templateName = "blank",
|
|
18762
19051
|
createLabel = true,
|
|
18763
19052
|
issueTracker = ISSUE_TRACKER_REGISTRY[0],
|
|
@@ -18765,56 +19054,32 @@ var scaffold = (repoDir, options3) => Effect_exports.gen(function* () {
|
|
|
18765
19054
|
sandboxProvider = SANDBOX_PROVIDER_REGISTRY[0]
|
|
18766
19055
|
// default: docker
|
|
18767
19056
|
} = options3;
|
|
18768
|
-
const fs = yield* FileSystem_exports.FileSystem;
|
|
18769
19057
|
const configDir = join(repoDir, ".sandcastle");
|
|
18770
|
-
const exists = yield* fs.exists(configDir).pipe(Effect_exports.mapError((e) => new Error(e.message)));
|
|
18771
|
-
if (exists) {
|
|
18772
|
-
yield* Effect_exports.fail(
|
|
18773
|
-
new Error(
|
|
18774
|
-
".sandcastle/ directory already exists. Remove it first if you want to re-initialize."
|
|
18775
|
-
)
|
|
18776
|
-
);
|
|
18777
|
-
}
|
|
18778
19058
|
const mainFilename = yield* detectMainFilename(repoDir);
|
|
18779
|
-
yield*
|
|
19059
|
+
yield* createConfigDir(configDir);
|
|
18780
19060
|
const templateDir = yield* getTemplateDir(templateName);
|
|
18781
|
-
const
|
|
18782
|
-
if (issueTracker.envExample) {
|
|
18783
|
-
envExampleParts.push(issueTracker.envExample);
|
|
18784
|
-
}
|
|
18785
|
-
const envExampleContent = envExampleParts.join("\n") + "\n";
|
|
18786
|
-
yield* Effect_exports.all(
|
|
18787
|
-
[
|
|
18788
|
-
fs.writeFileString(
|
|
18789
|
-
join(configDir, sandboxProvider.containerfileName),
|
|
18790
|
-
agent.dockerfileTemplate
|
|
18791
|
-
).pipe(Effect_exports.mapError((e) => new Error(e.message))),
|
|
18792
|
-
fs.writeFileString(join(configDir, ".gitignore"), GITIGNORE).pipe(Effect_exports.mapError((e) => new Error(e.message))),
|
|
18793
|
-
fs.writeFileString(join(configDir, ".env.example"), envExampleContent).pipe(Effect_exports.mapError((e) => new Error(e.message))),
|
|
18794
|
-
copyTemplateFiles(templateDir, configDir, mainFilename)
|
|
18795
|
-
],
|
|
18796
|
-
{ concurrency: "unbounded" }
|
|
18797
|
-
);
|
|
18798
|
-
yield* rewriteMainTs(
|
|
19061
|
+
const choices = {
|
|
18799
19062
|
configDir,
|
|
18800
|
-
|
|
18801
|
-
|
|
19063
|
+
mainFilename,
|
|
19064
|
+
agent: options3.agent,
|
|
19065
|
+
model: options3.model,
|
|
18802
19066
|
sandboxProvider,
|
|
18803
|
-
|
|
18804
|
-
|
|
19067
|
+
issueTracker,
|
|
19068
|
+
imageName: options3.imageName
|
|
19069
|
+
};
|
|
19070
|
+
yield* writeScaffoldFiles(choices, templateDir);
|
|
19071
|
+
yield* rewriteMainTs(choices);
|
|
19072
|
+
yield* applyIssueTrackerSandboxOptions(choices);
|
|
18805
19073
|
yield* substituteTemplateArgs(configDir, issueTracker);
|
|
18806
19074
|
if (!createLabel) {
|
|
18807
19075
|
yield* rewritePromptFiles(configDir);
|
|
18808
19076
|
}
|
|
18809
19077
|
if (issueTracker.name === "custom") {
|
|
18810
|
-
yield*
|
|
18811
|
-
join(configDir, SETUP_ISSUE_TRACKER_DOC),
|
|
18812
|
-
buildSetupIssueTrackerDoc(sandboxProvider.cliNamespace)
|
|
18813
|
-
).pipe(Effect_exports.mapError((e) => new Error(e.message)));
|
|
19078
|
+
yield* writeSetupIssueTrackerDoc(choices);
|
|
18814
19079
|
}
|
|
18815
19080
|
return { mainFilename };
|
|
18816
19081
|
});
|
|
18817
|
-
var VERSION = "0.
|
|
19082
|
+
var VERSION = "0.13.0";
|
|
18818
19083
|
|
|
18819
19084
|
// src/cli.ts
|
|
18820
19085
|
var imageNameOption = Options_exports.text("image-name").pipe(
|
|
@@ -18826,21 +19091,43 @@ var defaultUidBuildArgs = () => {
|
|
|
18826
19091
|
const args = {};
|
|
18827
19092
|
const uid = process.getuid?.();
|
|
18828
19093
|
const gid = process.getgid?.();
|
|
18829
|
-
if (uid !== void 0)
|
|
18830
|
-
|
|
19094
|
+
if (uid !== void 0) {
|
|
19095
|
+
args.AGENT_UID = String(uid);
|
|
19096
|
+
}
|
|
19097
|
+
if (gid !== void 0) {
|
|
19098
|
+
args.AGENT_GID = String(gid);
|
|
19099
|
+
}
|
|
18831
19100
|
return args;
|
|
18832
19101
|
};
|
|
18833
19102
|
var CONFIG_DIR = ".sandcastle";
|
|
18834
|
-
var requireConfigDir = (cwd) =>
|
|
18835
|
-
|
|
18836
|
-
|
|
18837
|
-
|
|
18838
|
-
|
|
18839
|
-
|
|
18840
|
-
|
|
18841
|
-
|
|
18842
|
-
|
|
19103
|
+
var requireConfigDir = (cwd) => FileSystem_exports.FileSystem.pipe(
|
|
19104
|
+
Effect_exports.flatMap((fs) => fs.exists(join(cwd, CONFIG_DIR))),
|
|
19105
|
+
Effect_exports.catchAll(() => Effect_exports.succeed(false)),
|
|
19106
|
+
Effect_exports.filterOrFail(
|
|
19107
|
+
(exists) => exists,
|
|
19108
|
+
() => new ConfigDirError({
|
|
19109
|
+
message: "No .sandcastle/ found. Run `sandcastle init` first."
|
|
19110
|
+
})
|
|
19111
|
+
),
|
|
19112
|
+
Effect_exports.asVoid
|
|
19113
|
+
);
|
|
19114
|
+
var nonInteractiveMessage = (flags) => `${flags.join(", ")} ${flags.length === 1 ? "is" : "are"} required in non-interactive mode (no TTY detected).`;
|
|
19115
|
+
var failInitUnless = (ok, message) => ok ? Effect_exports.void : Effect_exports.fail(new InitError({ message }));
|
|
19116
|
+
var registryEntry = (entry, what) => entry === void 0 ? Effect_exports.fail(new InitError({ message: `Unknown ${what}` })) : Effect_exports.succeed(entry);
|
|
19117
|
+
var selectName = (params) => Effect_exports.gen(function* () {
|
|
19118
|
+
if (params.flag._tag === "Some") {
|
|
19119
|
+
return params.flag.value;
|
|
19120
|
+
}
|
|
19121
|
+
if (!params.isInteractive) {
|
|
19122
|
+
return yield* new InitError({
|
|
19123
|
+
message: nonInteractiveMessage([params.flagName])
|
|
19124
|
+
});
|
|
18843
19125
|
}
|
|
19126
|
+
const selected = yield* Effect_exports.promise(() => clack.select(params.prompt));
|
|
19127
|
+
if (clack.isCancel(selected)) {
|
|
19128
|
+
return yield* new InitError({ message: params.cancelMessage });
|
|
19129
|
+
}
|
|
19130
|
+
return selected;
|
|
18844
19131
|
});
|
|
18845
19132
|
var templateOption = Options_exports.text("template").pipe(
|
|
18846
19133
|
Options_exports.withDescription(
|
|
@@ -18859,7 +19146,9 @@ var initModelOption = Options_exports.text("model").pipe(
|
|
|
18859
19146
|
Options_exports.optional
|
|
18860
19147
|
);
|
|
18861
19148
|
var sandboxOption = Options_exports.text("sandbox").pipe(
|
|
18862
|
-
Options_exports.withDescription(
|
|
19149
|
+
Options_exports.withDescription(
|
|
19150
|
+
"Sandbox provider to use (bwrap, seatbelt, docker or podman)"
|
|
19151
|
+
),
|
|
18863
19152
|
Options_exports.optional
|
|
18864
19153
|
);
|
|
18865
19154
|
var issueTrackerOption = Options_exports.text("issue-tracker").pipe(
|
|
@@ -18893,6 +19182,377 @@ var installTemplateDepsOption = Options_exports.choice("install-template-deps",
|
|
|
18893
19182
|
Options_exports.optional
|
|
18894
19183
|
);
|
|
18895
19184
|
var choiceToTriBool = (opt) => opt._tag === "Some" ? Option_exports.some(opt.value === "true") : Option_exports.none();
|
|
19185
|
+
var detectHostBdVersion = (cwd) => Effect_exports.async((resume) => {
|
|
19186
|
+
execFile(
|
|
19187
|
+
"bd",
|
|
19188
|
+
["version"],
|
|
19189
|
+
{ cwd, encoding: "utf8", timeout: 15e3 },
|
|
19190
|
+
(_error, stdout, stderr) => {
|
|
19191
|
+
resume(Effect_exports.succeed(parseBdVersion(`${stdout}
|
|
19192
|
+
${stderr}`)));
|
|
19193
|
+
}
|
|
19194
|
+
);
|
|
19195
|
+
});
|
|
19196
|
+
var validateRegistryFlags = (flags) => Effect_exports.gen(function* () {
|
|
19197
|
+
const { template } = flags;
|
|
19198
|
+
if (template._tag === "Some") {
|
|
19199
|
+
const templates = listTemplates();
|
|
19200
|
+
const names = templates.map((tmpl) => tmpl.name).join(", ");
|
|
19201
|
+
yield* failInitUnless(
|
|
19202
|
+
templates.some((tmpl) => tmpl.name === template.value),
|
|
19203
|
+
`Unknown template "${template.value}". Available: ${names}`
|
|
19204
|
+
);
|
|
19205
|
+
}
|
|
19206
|
+
if (flags.sandbox._tag === "Some") {
|
|
19207
|
+
const names = listSandboxProviders().map((p3) => p3.name).join(", ");
|
|
19208
|
+
yield* failInitUnless(
|
|
19209
|
+
getSandboxProvider(flags.sandbox.value) !== void 0,
|
|
19210
|
+
`Unknown sandbox provider "${flags.sandbox.value}". Available: ${names}`
|
|
19211
|
+
);
|
|
19212
|
+
}
|
|
19213
|
+
if (flags.issueTracker._tag === "Some") {
|
|
19214
|
+
const names = listIssueTrackers().map((t) => t.name).join(", ");
|
|
19215
|
+
yield* failInitUnless(
|
|
19216
|
+
getIssueTracker(flags.issueTracker.value) !== void 0,
|
|
19217
|
+
`Unknown issue tracker "${flags.issueTracker.value}". Available: ${names}`
|
|
19218
|
+
);
|
|
19219
|
+
}
|
|
19220
|
+
if (flags.agent._tag === "Some") {
|
|
19221
|
+
const names = listAgents().map((a) => a.name).join(", ");
|
|
19222
|
+
yield* failInitUnless(
|
|
19223
|
+
getAgent(flags.agent.value) !== void 0,
|
|
19224
|
+
`Unknown agent "${flags.agent.value}". Available: ${names}`
|
|
19225
|
+
);
|
|
19226
|
+
}
|
|
19227
|
+
});
|
|
19228
|
+
var resolveConfirmFlag = (params) => Effect_exports.gen(function* () {
|
|
19229
|
+
if (params.choice._tag === "Some") {
|
|
19230
|
+
return params.choice.value;
|
|
19231
|
+
}
|
|
19232
|
+
if (!params.isInteractive) {
|
|
19233
|
+
return yield* new InitError({
|
|
19234
|
+
message: nonInteractiveMessage([params.flag])
|
|
19235
|
+
});
|
|
19236
|
+
}
|
|
19237
|
+
const confirmed = yield* Effect_exports.promise(
|
|
19238
|
+
() => clack.confirm({
|
|
19239
|
+
message: params.promptMessage,
|
|
19240
|
+
initialValue: true
|
|
19241
|
+
})
|
|
19242
|
+
);
|
|
19243
|
+
if (clack.isCancel(confirmed)) {
|
|
19244
|
+
return yield* new InitError({ message: params.cancelMessage });
|
|
19245
|
+
}
|
|
19246
|
+
return confirmed;
|
|
19247
|
+
});
|
|
19248
|
+
var asksToInstallTemplateDeps = (template, choice4, cwd) => template._tag === "Some" && choice4._tag === "None" && getTemplateDependencies(template.value).includes("zod") ? Effect_exports.map(hostHasDependency(cwd, "zod"), (has2) => !has2) : Effect_exports.succeed(false);
|
|
19249
|
+
var missingInitFlags = (flags, choices, cwd) => Effect_exports.gen(function* () {
|
|
19250
|
+
const tracker = Option_exports.getOrUndefined(flags.issueTracker);
|
|
19251
|
+
const { template } = flags;
|
|
19252
|
+
const missing = [];
|
|
19253
|
+
if (flags.agent._tag === "None") {
|
|
19254
|
+
missing.push("--agent");
|
|
19255
|
+
}
|
|
19256
|
+
if (flags.sandbox._tag === "None") {
|
|
19257
|
+
missing.push("--sandbox");
|
|
19258
|
+
}
|
|
19259
|
+
if (tracker === void 0) {
|
|
19260
|
+
missing.push("--issue-tracker");
|
|
19261
|
+
}
|
|
19262
|
+
if (template._tag === "None") {
|
|
19263
|
+
missing.push("--template");
|
|
19264
|
+
}
|
|
19265
|
+
if (tracker === "github-issues" && choices.createLabel._tag === "None") {
|
|
19266
|
+
missing.push("--create-label");
|
|
19267
|
+
}
|
|
19268
|
+
if (yield* asksToInstallTemplateDeps(
|
|
19269
|
+
template,
|
|
19270
|
+
choices.installTemplateDeps,
|
|
19271
|
+
cwd
|
|
19272
|
+
)) {
|
|
19273
|
+
missing.push("--install-template-deps");
|
|
19274
|
+
}
|
|
19275
|
+
const sandboxName = Option_exports.getOrUndefined(flags.sandbox);
|
|
19276
|
+
const providerHasImage = sandboxName === void 0 || getSandboxProvider(sandboxName)?.image !== void 0;
|
|
19277
|
+
if (tracker !== "custom" && providerHasImage && choices.buildImage._tag === "None") {
|
|
19278
|
+
missing.push("--build-image");
|
|
19279
|
+
}
|
|
19280
|
+
return missing;
|
|
19281
|
+
});
|
|
19282
|
+
var selectAgent = (flag, isInteractive) => selectName({
|
|
19283
|
+
flag,
|
|
19284
|
+
flagName: "--agent",
|
|
19285
|
+
isInteractive,
|
|
19286
|
+
cancelMessage: "Agent selection cancelled.",
|
|
19287
|
+
prompt: {
|
|
19288
|
+
message: "Select an agent:",
|
|
19289
|
+
initialValue: "claude-code",
|
|
19290
|
+
options: listAgents().map((a) => ({
|
|
19291
|
+
value: a.name,
|
|
19292
|
+
label: a.label,
|
|
19293
|
+
hint: `Default model: ${a.defaultModel}`
|
|
19294
|
+
}))
|
|
19295
|
+
}
|
|
19296
|
+
}).pipe(
|
|
19297
|
+
Effect_exports.flatMap((name) => registryEntry(getAgent(name), `agent "${name}"`))
|
|
19298
|
+
);
|
|
19299
|
+
var selectSandboxProvider = (flag, isInteractive) => {
|
|
19300
|
+
const sandboxChoices = listSandboxProviderChoices(process.platform);
|
|
19301
|
+
const recommendedSandbox = sandboxChoices.find((c) => c.recommended);
|
|
19302
|
+
return selectName({
|
|
19303
|
+
flag,
|
|
19304
|
+
flagName: "--sandbox",
|
|
19305
|
+
isInteractive,
|
|
19306
|
+
cancelMessage: "Sandbox provider selection cancelled.",
|
|
19307
|
+
prompt: {
|
|
19308
|
+
message: "Select a sandbox provider:",
|
|
19309
|
+
...recommendedSandbox === void 0 ? {} : { initialValue: recommendedSandbox.entry.name },
|
|
19310
|
+
options: sandboxChoices.map(({ entry, recommended }) => ({
|
|
19311
|
+
value: entry.name,
|
|
19312
|
+
label: recommended ? `${entry.label} (recommended)` : entry.label
|
|
19313
|
+
}))
|
|
19314
|
+
}
|
|
19315
|
+
}).pipe(
|
|
19316
|
+
Effect_exports.flatMap(
|
|
19317
|
+
(name) => registryEntry(getSandboxProvider(name), `sandbox provider "${name}"`)
|
|
19318
|
+
)
|
|
19319
|
+
);
|
|
19320
|
+
};
|
|
19321
|
+
var selectIssueTracker = (flag, isInteractive) => selectName({
|
|
19322
|
+
flag,
|
|
19323
|
+
flagName: "--issue-tracker",
|
|
19324
|
+
isInteractive,
|
|
19325
|
+
cancelMessage: "Issue tracker selection cancelled.",
|
|
19326
|
+
prompt: {
|
|
19327
|
+
message: "Select an issue tracker:",
|
|
19328
|
+
initialValue: "github-issues",
|
|
19329
|
+
options: listIssueTrackers().map((b) => ({
|
|
19330
|
+
value: b.name,
|
|
19331
|
+
label: b.label
|
|
19332
|
+
}))
|
|
19333
|
+
}
|
|
19334
|
+
}).pipe(
|
|
19335
|
+
Effect_exports.flatMap(
|
|
19336
|
+
(name) => registryEntry(getIssueTracker(name), `issue tracker "${name}"`)
|
|
19337
|
+
)
|
|
19338
|
+
);
|
|
19339
|
+
var selectTemplate = (flag, isInteractive) => selectName({
|
|
19340
|
+
flag,
|
|
19341
|
+
flagName: "--template",
|
|
19342
|
+
isInteractive,
|
|
19343
|
+
cancelMessage: "Template selection cancelled.",
|
|
19344
|
+
prompt: {
|
|
19345
|
+
message: "Select a template:",
|
|
19346
|
+
initialValue: "blank",
|
|
19347
|
+
options: listTemplates().map((tmpl) => ({
|
|
19348
|
+
value: tmpl.name,
|
|
19349
|
+
label: tmpl.name,
|
|
19350
|
+
hint: tmpl.description
|
|
19351
|
+
}))
|
|
19352
|
+
}
|
|
19353
|
+
});
|
|
19354
|
+
var selectInitChoices = (flags, isInteractive) => Effect_exports.gen(function* () {
|
|
19355
|
+
const agent = yield* selectAgent(flags.agent, isInteractive);
|
|
19356
|
+
const model = flags.model._tag === "Some" ? flags.model.value : agent.defaultModel;
|
|
19357
|
+
const sandboxProvider = yield* selectSandboxProvider(
|
|
19358
|
+
flags.sandbox,
|
|
19359
|
+
isInteractive
|
|
19360
|
+
);
|
|
19361
|
+
const issueTracker = yield* selectIssueTracker(
|
|
19362
|
+
flags.issueTracker,
|
|
19363
|
+
isInteractive
|
|
19364
|
+
);
|
|
19365
|
+
const template = yield* selectTemplate(flags.template, isInteractive);
|
|
19366
|
+
return { agent, model, sandboxProvider, issueTracker, template };
|
|
19367
|
+
});
|
|
19368
|
+
var offerSandcastleLabel = (selection, choice4, context) => Effect_exports.gen(function* () {
|
|
19369
|
+
if (selection.issueTracker.name !== "github-issues") {
|
|
19370
|
+
return false;
|
|
19371
|
+
}
|
|
19372
|
+
const shouldCreateLabel = yield* resolveConfirmFlag({
|
|
19373
|
+
choice: choice4,
|
|
19374
|
+
flag: "--create-label",
|
|
19375
|
+
isInteractive: context.isInteractive,
|
|
19376
|
+
promptMessage: 'Create a "Sandcastle" GitHub label? (Templates filter issues by this label)',
|
|
19377
|
+
cancelMessage: "Label selection cancelled."
|
|
19378
|
+
});
|
|
19379
|
+
if (shouldCreateLabel) {
|
|
19380
|
+
yield* Effect_exports.try({
|
|
19381
|
+
try: () => execSync(
|
|
19382
|
+
'gh label create "Sandcastle" --description "Issues for Sandcastle to work on" --color "F9A825" 2>/dev/null',
|
|
19383
|
+
{ cwd: context.cwd, stdio: "ignore" }
|
|
19384
|
+
),
|
|
19385
|
+
catch: () => void 0
|
|
19386
|
+
}).pipe(Effect_exports.ignore);
|
|
19387
|
+
}
|
|
19388
|
+
return shouldCreateLabel;
|
|
19389
|
+
});
|
|
19390
|
+
var warnHostPrerequisites = (selection, cwd) => Effect_exports.gen(function* () {
|
|
19391
|
+
const d = yield* Display;
|
|
19392
|
+
const { sandboxProvider } = selection;
|
|
19393
|
+
const preflightWarning = sandboxProviderPreflightWarning(sandboxProvider);
|
|
19394
|
+
if (preflightWarning !== void 0) {
|
|
19395
|
+
yield* d.status(preflightWarning, "warn");
|
|
19396
|
+
}
|
|
19397
|
+
if (sandboxProvider.image === void 0) {
|
|
19398
|
+
const agentWarning = yield* agentCliWarning(
|
|
19399
|
+
selection.agent,
|
|
19400
|
+
sandboxProvider
|
|
19401
|
+
);
|
|
19402
|
+
if (agentWarning !== void 0) {
|
|
19403
|
+
yield* d.status(agentWarning, "warn");
|
|
19404
|
+
}
|
|
19405
|
+
}
|
|
19406
|
+
if (selection.issueTracker.name === "beads" && sandboxProvider.image !== void 0) {
|
|
19407
|
+
const warning = beadsVersionWarning(yield* detectHostBdVersion(cwd));
|
|
19408
|
+
if (warning !== void 0) {
|
|
19409
|
+
yield* d.status(warning, "warn");
|
|
19410
|
+
}
|
|
19411
|
+
}
|
|
19412
|
+
});
|
|
19413
|
+
var tryInstall = (installCmd, cwd) => Effect_exports.sync(() => {
|
|
19414
|
+
try {
|
|
19415
|
+
execSync(installCmd, { cwd, stdio: "ignore" });
|
|
19416
|
+
return true;
|
|
19417
|
+
} catch {
|
|
19418
|
+
return false;
|
|
19419
|
+
}
|
|
19420
|
+
});
|
|
19421
|
+
var offerTemplateDeps = (template, choice4, context) => Effect_exports.gen(function* () {
|
|
19422
|
+
const { cwd, packageManager } = context;
|
|
19423
|
+
if (!getTemplateDependencies(template).includes("zod")) {
|
|
19424
|
+
return [];
|
|
19425
|
+
}
|
|
19426
|
+
if (yield* hostHasDependency(cwd, "zod")) {
|
|
19427
|
+
return ["zod"];
|
|
19428
|
+
}
|
|
19429
|
+
const installCmd = addDependencyCommand(packageManager, "zod");
|
|
19430
|
+
const shouldInstall = yield* resolveConfirmFlag({
|
|
19431
|
+
choice: choice4,
|
|
19432
|
+
flag: "--install-template-deps",
|
|
19433
|
+
isInteractive: context.isInteractive,
|
|
19434
|
+
promptMessage: `The ${template} template needs a schema validator. Install zod now (\`${installCmd}\`)?`,
|
|
19435
|
+
cancelMessage: "Install-template-deps selection cancelled."
|
|
19436
|
+
});
|
|
19437
|
+
if (!shouldInstall) {
|
|
19438
|
+
return [];
|
|
19439
|
+
}
|
|
19440
|
+
const d = yield* Display;
|
|
19441
|
+
const installed = yield* tryInstall(installCmd, cwd);
|
|
19442
|
+
yield* installed ? d.status(`Installed zod with ${packageManager}.`, "success") : d.status(
|
|
19443
|
+
`Couldn't install zod automatically. Run \`${installCmd}\` before running the agent.`,
|
|
19444
|
+
"warn"
|
|
19445
|
+
);
|
|
19446
|
+
return installed ? ["zod"] : [];
|
|
19447
|
+
});
|
|
19448
|
+
var buildDefaultImage = (sandboxProvider, imageName, cwd) => {
|
|
19449
|
+
const containerfileDir = join(cwd, CONFIG_DIR);
|
|
19450
|
+
return sandboxProvider.name === "podman" ? buildImage2(imageName, containerfileDir) : buildImage(imageName, containerfileDir, {
|
|
19451
|
+
buildArgs: defaultUidBuildArgs()
|
|
19452
|
+
});
|
|
19453
|
+
};
|
|
19454
|
+
var finishInit = (selection, choice4, context) => Effect_exports.gen(function* () {
|
|
19455
|
+
const d = yield* Display;
|
|
19456
|
+
const { sandboxProvider, issueTracker } = selection;
|
|
19457
|
+
const { imageName } = context;
|
|
19458
|
+
const providerLabel = sandboxProvider.label;
|
|
19459
|
+
const providerImage = sandboxProvider.image;
|
|
19460
|
+
if (providerImage === void 0) {
|
|
19461
|
+
return yield* d.status(
|
|
19462
|
+
issueTracker.name === "custom" ? "Init complete! Your custom issue tracker isn't configured yet \u2014 see the steps below." : "Init complete!",
|
|
19463
|
+
"success"
|
|
19464
|
+
);
|
|
19465
|
+
}
|
|
19466
|
+
if (issueTracker.name === "custom") {
|
|
19467
|
+
return yield* d.status(
|
|
19468
|
+
"Init complete! Your custom issue tracker isn't configured yet \u2014 see the steps below before building.",
|
|
19469
|
+
"success"
|
|
19470
|
+
);
|
|
19471
|
+
}
|
|
19472
|
+
const shouldBuild = yield* resolveConfirmFlag({
|
|
19473
|
+
choice: choice4,
|
|
19474
|
+
flag: "--build-image",
|
|
19475
|
+
isInteractive: context.isInteractive,
|
|
19476
|
+
promptMessage: `Build the default ${providerLabel} image now?`,
|
|
19477
|
+
cancelMessage: "Build-image selection cancelled."
|
|
19478
|
+
});
|
|
19479
|
+
if (!shouldBuild) {
|
|
19480
|
+
return yield* d.status(
|
|
19481
|
+
`Init complete! Run \`${buildImageShellCommand(providerImage, context.customImageName)}\` to build the ${providerLabel} image later.`,
|
|
19482
|
+
"success"
|
|
19483
|
+
);
|
|
19484
|
+
}
|
|
19485
|
+
yield* d.spinner(
|
|
19486
|
+
`Building ${providerLabel} image '${imageName}'...`,
|
|
19487
|
+
buildDefaultImage(sandboxProvider, imageName, context.cwd)
|
|
19488
|
+
);
|
|
19489
|
+
yield* d.status("Init complete! Image built successfully.", "success");
|
|
19490
|
+
});
|
|
19491
|
+
var decideInit = (flags) => Effect_exports.gen(function* () {
|
|
19492
|
+
const cwd = process.cwd();
|
|
19493
|
+
yield* validateRegistryFlags(flags);
|
|
19494
|
+
const choices = {
|
|
19495
|
+
createLabel: choiceToTriBool(flags.createLabel),
|
|
19496
|
+
buildImage: choiceToTriBool(flags.buildImage),
|
|
19497
|
+
installTemplateDeps: choiceToTriBool(flags.installTemplateDeps)
|
|
19498
|
+
};
|
|
19499
|
+
const isInteractive = process.stdin.isTTY === true;
|
|
19500
|
+
if (!isInteractive) {
|
|
19501
|
+
const missing = yield* missingInitFlags(flags, choices, cwd);
|
|
19502
|
+
yield* failInitUnless(
|
|
19503
|
+
missing.length === 0,
|
|
19504
|
+
nonInteractiveMessage(missing)
|
|
19505
|
+
);
|
|
19506
|
+
}
|
|
19507
|
+
const selection = yield* selectInitChoices(flags, isInteractive);
|
|
19508
|
+
return { cwd, isInteractive, choices, selection };
|
|
19509
|
+
});
|
|
19510
|
+
var scaffoldSelection = (selection, options3) => scaffold(options3.cwd, {
|
|
19511
|
+
agent: selection.agent,
|
|
19512
|
+
model: selection.model,
|
|
19513
|
+
templateName: selection.template,
|
|
19514
|
+
createLabel: options3.createLabel,
|
|
19515
|
+
issueTracker: selection.issueTracker,
|
|
19516
|
+
sandboxProvider: selection.sandboxProvider,
|
|
19517
|
+
imageName: selection.sandboxProvider.image === void 0 ? void 0 : options3.customImageName
|
|
19518
|
+
}).pipe(
|
|
19519
|
+
Effect_exports.mapError(
|
|
19520
|
+
(e) => new InitError({
|
|
19521
|
+
message: e instanceof Error ? e.message : e
|
|
19522
|
+
})
|
|
19523
|
+
)
|
|
19524
|
+
);
|
|
19525
|
+
var printLines = (lines2) => Effect_exports.gen(function* () {
|
|
19526
|
+
const d = yield* Display;
|
|
19527
|
+
for (const [i, line4] of lines2.entries()) {
|
|
19528
|
+
yield* d.text(i === 0 ? line4 : styleText("dim", line4));
|
|
19529
|
+
}
|
|
19530
|
+
});
|
|
19531
|
+
var completeInit = (selection, choices, context) => Effect_exports.gen(function* () {
|
|
19532
|
+
const { cwd, flags } = context;
|
|
19533
|
+
const packageManager = yield* detectPackageManager(cwd);
|
|
19534
|
+
const installedDependencies = yield* offerTemplateDeps(
|
|
19535
|
+
selection.template,
|
|
19536
|
+
choices.installTemplateDeps,
|
|
19537
|
+
{ ...context, packageManager }
|
|
19538
|
+
);
|
|
19539
|
+
yield* finishInit(selection, choices.buildImage, {
|
|
19540
|
+
...context,
|
|
19541
|
+
imageName: resolveImageName(flags.imageName, cwd),
|
|
19542
|
+
customImageName: Option_exports.getOrUndefined(flags.imageName)
|
|
19543
|
+
});
|
|
19544
|
+
yield* printLines(
|
|
19545
|
+
getNextStepsLines(
|
|
19546
|
+
selection.template,
|
|
19547
|
+
context.mainFilename,
|
|
19548
|
+
selection.issueTracker,
|
|
19549
|
+
selection.agent,
|
|
19550
|
+
packageManager,
|
|
19551
|
+
installedDependencies,
|
|
19552
|
+
selection.sandboxProvider
|
|
19553
|
+
)
|
|
19554
|
+
);
|
|
19555
|
+
});
|
|
18896
19556
|
var initCommand = Command_exports.make(
|
|
18897
19557
|
"init",
|
|
18898
19558
|
{
|
|
@@ -18906,308 +19566,32 @@ var initCommand = Command_exports.make(
|
|
|
18906
19566
|
buildImage: buildImageOption,
|
|
18907
19567
|
installTemplateDeps: installTemplateDepsOption
|
|
18908
19568
|
},
|
|
18909
|
-
({
|
|
18910
|
-
imageName: imageNameFlag,
|
|
18911
|
-
template,
|
|
18912
|
-
agent: agentFlag,
|
|
18913
|
-
model: modelFlag,
|
|
18914
|
-
sandbox: sandboxFlag,
|
|
18915
|
-
issueTracker: issueTrackerFlag,
|
|
18916
|
-
createLabel: createLabelFlag,
|
|
18917
|
-
buildImage: buildImageFlag,
|
|
18918
|
-
installTemplateDeps: installTemplateDepsFlag
|
|
18919
|
-
}) => Effect_exports.gen(function* () {
|
|
19569
|
+
(flags) => Effect_exports.gen(function* () {
|
|
18920
19570
|
const d = yield* Display;
|
|
18921
|
-
const cwd =
|
|
18922
|
-
const
|
|
18923
|
-
const
|
|
18924
|
-
|
|
18925
|
-
|
|
18926
|
-
|
|
18927
|
-
const names = templates.map((tmpl) => tmpl.name).join(", ");
|
|
18928
|
-
yield* Effect_exports.fail(
|
|
18929
|
-
new InitError({
|
|
18930
|
-
message: `Unknown template "${template.value}". Available: ${names}`
|
|
18931
|
-
})
|
|
18932
|
-
);
|
|
18933
|
-
}
|
|
18934
|
-
}
|
|
18935
|
-
if (sandboxFlag._tag === "Some") {
|
|
18936
|
-
const valid = getSandboxProvider(sandboxFlag.value);
|
|
18937
|
-
if (!valid) {
|
|
18938
|
-
const names = listSandboxProviders().map((p3) => p3.name).join(", ");
|
|
18939
|
-
yield* Effect_exports.fail(
|
|
18940
|
-
new InitError({
|
|
18941
|
-
message: `Unknown sandbox provider "${sandboxFlag.value}". Available: ${names}`
|
|
18942
|
-
})
|
|
18943
|
-
);
|
|
18944
|
-
}
|
|
18945
|
-
}
|
|
18946
|
-
if (issueTrackerFlag._tag === "Some") {
|
|
18947
|
-
const valid = getIssueTracker(issueTrackerFlag.value);
|
|
18948
|
-
if (!valid) {
|
|
18949
|
-
const names = listIssueTrackers().map((t) => t.name).join(", ");
|
|
18950
|
-
yield* Effect_exports.fail(
|
|
18951
|
-
new InitError({
|
|
18952
|
-
message: `Unknown issue tracker "${issueTrackerFlag.value}". Available: ${names}`
|
|
18953
|
-
})
|
|
18954
|
-
);
|
|
18955
|
-
}
|
|
18956
|
-
}
|
|
18957
|
-
const createLabelChoice = choiceToTriBool(createLabelFlag);
|
|
18958
|
-
const buildImageChoice = choiceToTriBool(buildImageFlag);
|
|
18959
|
-
const installTemplateDepsChoice = choiceToTriBool(
|
|
18960
|
-
installTemplateDepsFlag
|
|
19571
|
+
const { cwd, isInteractive, choices, selection } = yield* decideInit(flags);
|
|
19572
|
+
const context = { cwd, isInteractive };
|
|
19573
|
+
const shouldCreateLabel = yield* offerSandcastleLabel(
|
|
19574
|
+
selection,
|
|
19575
|
+
choices.createLabel,
|
|
19576
|
+
context
|
|
18961
19577
|
);
|
|
18962
|
-
const isInteractive = process.stdin.isTTY === true;
|
|
18963
|
-
const failIfNonInteractive = (flag) => Effect_exports.fail(
|
|
18964
|
-
new InitError({
|
|
18965
|
-
message: `${flag} is required in non-interactive mode (no TTY detected).`
|
|
18966
|
-
})
|
|
18967
|
-
);
|
|
18968
|
-
const resolveConfirmFlag = (params) => Effect_exports.gen(function* () {
|
|
18969
|
-
if (params.choice._tag === "Some") return params.choice.value;
|
|
18970
|
-
if (!isInteractive) {
|
|
18971
|
-
yield* failIfNonInteractive(params.flag);
|
|
18972
|
-
}
|
|
18973
|
-
const confirmed = yield* Effect_exports.promise(
|
|
18974
|
-
() => clack.confirm({
|
|
18975
|
-
message: params.promptMessage,
|
|
18976
|
-
initialValue: true
|
|
18977
|
-
})
|
|
18978
|
-
);
|
|
18979
|
-
if (clack.isCancel(confirmed)) {
|
|
18980
|
-
yield* Effect_exports.fail(
|
|
18981
|
-
new InitError({ message: params.cancelMessage })
|
|
18982
|
-
);
|
|
18983
|
-
}
|
|
18984
|
-
return confirmed === true;
|
|
18985
|
-
});
|
|
18986
|
-
const agents = listAgents();
|
|
18987
|
-
let selectedAgent;
|
|
18988
|
-
if (agentFlag._tag === "Some") {
|
|
18989
|
-
const entry = getAgent(agentFlag.value);
|
|
18990
|
-
if (!entry) {
|
|
18991
|
-
const names = agents.map((a) => a.name).join(", ");
|
|
18992
|
-
yield* Effect_exports.fail(
|
|
18993
|
-
new InitError({
|
|
18994
|
-
message: `Unknown agent "${agentFlag.value}". Available: ${names}`
|
|
18995
|
-
})
|
|
18996
|
-
);
|
|
18997
|
-
}
|
|
18998
|
-
selectedAgent = entry;
|
|
18999
|
-
} else {
|
|
19000
|
-
if (!isInteractive) {
|
|
19001
|
-
yield* failIfNonInteractive("--agent");
|
|
19002
|
-
}
|
|
19003
|
-
const selected = yield* Effect_exports.promise(
|
|
19004
|
-
() => clack.select({
|
|
19005
|
-
message: "Select an agent:",
|
|
19006
|
-
initialValue: "claude-code",
|
|
19007
|
-
options: agents.map((a) => ({
|
|
19008
|
-
value: a.name,
|
|
19009
|
-
label: a.label,
|
|
19010
|
-
hint: `Default model: ${a.defaultModel}`
|
|
19011
|
-
}))
|
|
19012
|
-
})
|
|
19013
|
-
);
|
|
19014
|
-
if (clack.isCancel(selected)) {
|
|
19015
|
-
yield* Effect_exports.fail(
|
|
19016
|
-
new InitError({ message: "Agent selection cancelled." })
|
|
19017
|
-
);
|
|
19018
|
-
}
|
|
19019
|
-
selectedAgent = getAgent(selected);
|
|
19020
|
-
}
|
|
19021
|
-
const selectedModel = modelFlag._tag === "Some" ? modelFlag.value : selectedAgent.defaultModel;
|
|
19022
|
-
const sandboxProviders = listSandboxProviders();
|
|
19023
|
-
let selectedSandboxProvider;
|
|
19024
|
-
if (sandboxFlag._tag === "Some") {
|
|
19025
|
-
selectedSandboxProvider = getSandboxProvider(sandboxFlag.value);
|
|
19026
|
-
} else {
|
|
19027
|
-
if (!isInteractive) {
|
|
19028
|
-
yield* failIfNonInteractive("--sandbox");
|
|
19029
|
-
}
|
|
19030
|
-
const selected = yield* Effect_exports.promise(
|
|
19031
|
-
() => clack.select({
|
|
19032
|
-
message: "Select a sandbox provider:",
|
|
19033
|
-
options: sandboxProviders.map((p3) => ({
|
|
19034
|
-
value: p3.name,
|
|
19035
|
-
label: p3.label
|
|
19036
|
-
}))
|
|
19037
|
-
})
|
|
19038
|
-
);
|
|
19039
|
-
if (clack.isCancel(selected)) {
|
|
19040
|
-
yield* Effect_exports.fail(
|
|
19041
|
-
new InitError({
|
|
19042
|
-
message: "Sandbox provider selection cancelled."
|
|
19043
|
-
})
|
|
19044
|
-
);
|
|
19045
|
-
}
|
|
19046
|
-
selectedSandboxProvider = getSandboxProvider(selected);
|
|
19047
|
-
}
|
|
19048
|
-
const issueTrackers = listIssueTrackers();
|
|
19049
|
-
let selectedIssueTracker;
|
|
19050
|
-
if (issueTrackerFlag._tag === "Some") {
|
|
19051
|
-
selectedIssueTracker = getIssueTracker(issueTrackerFlag.value);
|
|
19052
|
-
} else {
|
|
19053
|
-
if (!isInteractive) {
|
|
19054
|
-
yield* failIfNonInteractive("--issue-tracker");
|
|
19055
|
-
}
|
|
19056
|
-
const selected = yield* Effect_exports.promise(
|
|
19057
|
-
() => clack.select({
|
|
19058
|
-
message: "Select an issue tracker:",
|
|
19059
|
-
initialValue: "github-issues",
|
|
19060
|
-
options: issueTrackers.map((b) => ({
|
|
19061
|
-
value: b.name,
|
|
19062
|
-
label: b.label
|
|
19063
|
-
}))
|
|
19064
|
-
})
|
|
19065
|
-
);
|
|
19066
|
-
if (clack.isCancel(selected)) {
|
|
19067
|
-
yield* Effect_exports.fail(
|
|
19068
|
-
new InitError({
|
|
19069
|
-
message: "Issue tracker selection cancelled."
|
|
19070
|
-
})
|
|
19071
|
-
);
|
|
19072
|
-
}
|
|
19073
|
-
selectedIssueTracker = getIssueTracker(selected);
|
|
19074
|
-
}
|
|
19075
|
-
let selectedTemplate;
|
|
19076
|
-
if (template._tag === "Some") {
|
|
19077
|
-
selectedTemplate = template.value;
|
|
19078
|
-
} else {
|
|
19079
|
-
if (!isInteractive) {
|
|
19080
|
-
yield* failIfNonInteractive("--template");
|
|
19081
|
-
}
|
|
19082
|
-
const selected = yield* Effect_exports.promise(
|
|
19083
|
-
() => clack.select({
|
|
19084
|
-
message: "Select a template:",
|
|
19085
|
-
initialValue: "blank",
|
|
19086
|
-
options: templates.map((tmpl) => ({
|
|
19087
|
-
value: tmpl.name,
|
|
19088
|
-
label: tmpl.name,
|
|
19089
|
-
hint: tmpl.description
|
|
19090
|
-
}))
|
|
19091
|
-
})
|
|
19092
|
-
);
|
|
19093
|
-
if (clack.isCancel(selected)) {
|
|
19094
|
-
yield* Effect_exports.fail(
|
|
19095
|
-
new InitError({ message: "Template selection cancelled." })
|
|
19096
|
-
);
|
|
19097
|
-
}
|
|
19098
|
-
selectedTemplate = selected;
|
|
19099
|
-
}
|
|
19100
|
-
let shouldCreateLabel = false;
|
|
19101
|
-
if (selectedIssueTracker.name === "github-issues") {
|
|
19102
|
-
shouldCreateLabel = yield* resolveConfirmFlag({
|
|
19103
|
-
choice: createLabelChoice,
|
|
19104
|
-
flag: "--create-label",
|
|
19105
|
-
promptMessage: 'Create a "Sandcastle" GitHub label? (Templates filter issues by this label)',
|
|
19106
|
-
cancelMessage: "Label selection cancelled."
|
|
19107
|
-
});
|
|
19108
|
-
if (shouldCreateLabel) {
|
|
19109
|
-
yield* Effect_exports.try({
|
|
19110
|
-
try: () => execSync(
|
|
19111
|
-
'gh label create "Sandcastle" --description "Issues for Sandcastle to work on" --color "F9A825" 2>/dev/null',
|
|
19112
|
-
{ cwd, stdio: "ignore" }
|
|
19113
|
-
),
|
|
19114
|
-
catch: () => void 0
|
|
19115
|
-
}).pipe(Effect_exports.ignore);
|
|
19116
|
-
}
|
|
19117
|
-
}
|
|
19118
19578
|
const scaffoldResult = yield* d.spinner(
|
|
19119
19579
|
"Scaffolding .sandcastle/ config directory...",
|
|
19120
|
-
|
|
19121
|
-
|
|
19122
|
-
model: selectedModel,
|
|
19123
|
-
templateName: selectedTemplate,
|
|
19580
|
+
scaffoldSelection(selection, {
|
|
19581
|
+
cwd,
|
|
19124
19582
|
createLabel: shouldCreateLabel,
|
|
19125
|
-
|
|
19126
|
-
|
|
19127
|
-
|
|
19128
|
-
|
|
19129
|
-
|
|
19130
|
-
message: `${e instanceof Error ? e.message : e}`
|
|
19131
|
-
})
|
|
19132
|
-
)
|
|
19133
|
-
)
|
|
19134
|
-
);
|
|
19135
|
-
const packageManager = yield* detectPackageManager(cwd);
|
|
19136
|
-
if (getTemplateDependencies(selectedTemplate).includes("zod")) {
|
|
19137
|
-
const alreadyInstalled = yield* hostHasDependency(cwd, "zod");
|
|
19138
|
-
if (!alreadyInstalled) {
|
|
19139
|
-
const installCmd = addDependencyCommand(packageManager, "zod");
|
|
19140
|
-
const shouldInstall = yield* resolveConfirmFlag({
|
|
19141
|
-
choice: installTemplateDepsChoice,
|
|
19142
|
-
flag: "--install-template-deps",
|
|
19143
|
-
promptMessage: `The ${selectedTemplate} template needs a schema validator. Install zod now (\`${installCmd}\`)?`,
|
|
19144
|
-
cancelMessage: "Install-template-deps selection cancelled."
|
|
19145
|
-
});
|
|
19146
|
-
if (shouldInstall) {
|
|
19147
|
-
const installed = yield* Effect_exports.sync(() => {
|
|
19148
|
-
try {
|
|
19149
|
-
execSync(installCmd, { cwd, stdio: "ignore" });
|
|
19150
|
-
return true;
|
|
19151
|
-
} catch {
|
|
19152
|
-
return false;
|
|
19153
|
-
}
|
|
19154
|
-
});
|
|
19155
|
-
yield* installed ? d.status(`Installed zod with ${packageManager}.`, "success") : d.status(
|
|
19156
|
-
`Couldn't install zod automatically. Run \`${installCmd}\` before running the agent.`,
|
|
19157
|
-
"warn"
|
|
19158
|
-
);
|
|
19159
|
-
}
|
|
19160
|
-
}
|
|
19161
|
-
}
|
|
19162
|
-
const providerLabel = selectedSandboxProvider.label;
|
|
19163
|
-
if (selectedIssueTracker.name === "custom") {
|
|
19164
|
-
yield* d.status(
|
|
19165
|
-
"Init complete! Your custom issue tracker isn't configured yet \u2014 see the steps below before building.",
|
|
19166
|
-
"success"
|
|
19167
|
-
);
|
|
19168
|
-
} else {
|
|
19169
|
-
const shouldBuild = yield* resolveConfirmFlag({
|
|
19170
|
-
choice: buildImageChoice,
|
|
19171
|
-
flag: "--build-image",
|
|
19172
|
-
promptMessage: `Build the default ${providerLabel} image now?`,
|
|
19173
|
-
cancelMessage: "Build-image selection cancelled."
|
|
19174
|
-
});
|
|
19175
|
-
if (shouldBuild) {
|
|
19176
|
-
const containerfileDir = join(cwd, CONFIG_DIR);
|
|
19177
|
-
if (selectedSandboxProvider.name === "podman") {
|
|
19178
|
-
yield* d.spinner(
|
|
19179
|
-
`Building ${providerLabel} image '${imageName}'...`,
|
|
19180
|
-
buildImage2(imageName, containerfileDir)
|
|
19181
|
-
);
|
|
19182
|
-
} else {
|
|
19183
|
-
yield* d.spinner(
|
|
19184
|
-
`Building ${providerLabel} image '${imageName}'...`,
|
|
19185
|
-
buildImage(imageName, containerfileDir, {
|
|
19186
|
-
buildArgs: defaultUidBuildArgs()
|
|
19187
|
-
})
|
|
19188
|
-
);
|
|
19189
|
-
}
|
|
19190
|
-
yield* d.status(
|
|
19191
|
-
"Init complete! Image built successfully.",
|
|
19192
|
-
"success"
|
|
19193
|
-
);
|
|
19194
|
-
} else {
|
|
19195
|
-
yield* d.status(
|
|
19196
|
-
`Init complete! Run \`sandcastle ${selectedSandboxProvider.cliNamespace} build-image\` to build the ${providerLabel} image later.`,
|
|
19197
|
-
"success"
|
|
19198
|
-
);
|
|
19199
|
-
}
|
|
19200
|
-
}
|
|
19201
|
-
const nextSteps = getNextStepsLines(
|
|
19202
|
-
selectedTemplate,
|
|
19203
|
-
scaffoldResult.mainFilename,
|
|
19204
|
-
selectedIssueTracker,
|
|
19205
|
-
selectedAgent,
|
|
19206
|
-
packageManager
|
|
19583
|
+
// Only an explicit --image-name is written into the scaffold;
|
|
19584
|
+
// without it the sandbox factory's own default resolves to the
|
|
19585
|
+
// same name as resolveImageName.
|
|
19586
|
+
customImageName: Option_exports.getOrUndefined(flags.imageName)
|
|
19587
|
+
})
|
|
19207
19588
|
);
|
|
19208
|
-
|
|
19209
|
-
|
|
19210
|
-
|
|
19589
|
+
yield* warnHostPrerequisites(selection, cwd);
|
|
19590
|
+
yield* completeInit(selection, choices, {
|
|
19591
|
+
...context,
|
|
19592
|
+
flags,
|
|
19593
|
+
mainFilename: scaffoldResult.mainFilename
|
|
19594
|
+
});
|
|
19211
19595
|
})
|
|
19212
19596
|
);
|
|
19213
19597
|
var dockerfileOption = Options_exports.file("dockerfile").pipe(
|
|
@@ -19343,11 +19727,8 @@ var cli = Command_exports.run(sandcastle, {
|
|
|
19343
19727
|
// src/terminalCleanup.ts
|
|
19344
19728
|
var SHOW_CURSOR = "\x1B[?25h";
|
|
19345
19729
|
var makeTerminalCleanupHandler = (stdin, stdout) => () => {
|
|
19346
|
-
if (stdin.isTTY && stdin.setRawMode) {
|
|
19347
|
-
|
|
19348
|
-
stdin.setRawMode(false);
|
|
19349
|
-
} catch {
|
|
19350
|
-
}
|
|
19730
|
+
if (stdin.isTTY === true && stdin.setRawMode !== void 0) {
|
|
19731
|
+
stdin.setRawMode(false);
|
|
19351
19732
|
}
|
|
19352
19733
|
stdout.write(SHOW_CURSOR);
|
|
19353
19734
|
};
|
|
@@ -19358,10 +19739,8 @@ var setupTerminalCleanup = () => {
|
|
|
19358
19739
|
// src/main.ts
|
|
19359
19740
|
setupTerminalCleanup();
|
|
19360
19741
|
var mainLayer = Layer_exports.merge(NodeContext_exports.layer, ClackDisplay.layer);
|
|
19361
|
-
|
|
19362
|
-
withFriendlyErrors,
|
|
19363
|
-
Effect_exports.provide(mainLayer),
|
|
19364
|
-
NodeRuntime_exports.runMain
|
|
19742
|
+
NodeRuntime_exports.runMain(
|
|
19743
|
+
cli(process.argv).pipe(withFriendlyErrors, Effect_exports.provide(mainLayer))
|
|
19365
19744
|
);
|
|
19366
19745
|
//# sourceMappingURL=main.js.map
|
|
19367
19746
|
//# sourceMappingURL=main.js.map
|