@ai-hero/sandcastle 0.12.0 → 0.14.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 -1368
- package/dist/LinuxCapability-B_PQfsY_.d.ts +32 -0
- package/dist/{SandboxProvider-EkSMuBp8.d.ts → SandboxProvider-Chsi-Zs6.d.ts} +31 -3
- package/dist/{chunk-NGBM7T3E.js → chunk-6NQPCXSG.js} +5 -2
- package/dist/chunk-6NQPCXSG.js.map +1 -0
- package/dist/chunk-7N7AMUYA.js +353 -0
- package/dist/chunk-7N7AMUYA.js.map +1 -0
- package/dist/chunk-ATA2V2TC.js +112 -0
- package/dist/chunk-ATA2V2TC.js.map +1 -0
- package/dist/chunk-BIF2X6QB.js +94 -0
- package/dist/chunk-BIF2X6QB.js.map +1 -0
- package/dist/{chunk-BIWNFKGV.js → chunk-BVZWLFFT.js} +2 -2
- package/dist/chunk-BVZWLFFT.js.map +1 -0
- package/dist/chunk-EXYXBRCX.js +60 -0
- package/dist/chunk-EXYXBRCX.js.map +1 -0
- package/dist/chunk-G2R53CVZ.js +3172 -0
- package/dist/chunk-G2R53CVZ.js.map +1 -0
- package/dist/{chunk-CP3TYXZA.js → chunk-GCLEXPXG.js} +95 -85
- package/dist/chunk-GCLEXPXG.js.map +1 -0
- package/dist/chunk-H2PEFS4W.js +1244 -0
- package/dist/chunk-H2PEFS4W.js.map +1 -0
- package/dist/chunk-HSXPRZKG.js +150 -0
- package/dist/chunk-HSXPRZKG.js.map +1 -0
- package/dist/chunk-IBK2XNSS.js +50 -0
- package/dist/chunk-IBK2XNSS.js.map +1 -0
- package/dist/chunk-RDW7FNN6.js +792 -0
- package/dist/chunk-RDW7FNN6.js.map +1 -0
- package/dist/{chunk-DJRHWPEH.js → chunk-S6UHPTRG.js} +284 -352
- package/dist/chunk-S6UHPTRG.js.map +1 -0
- package/dist/{chunk-VOG34SRF.js → chunk-STB2U7BB.js} +11823 -6977
- package/dist/chunk-STB2U7BB.js.map +1 -0
- package/dist/chunk-VRXR2T3S.js +24 -0
- package/dist/chunk-VRXR2T3S.js.map +1 -0
- package/dist/index.d.ts +241 -26
- package/dist/index.js +1082 -1679
- package/dist/index.js.map +1 -1
- package/dist/main.js +1248 -854
- package/dist/main.js.map +1 -1
- package/dist/sandboxes/bwrap.d.ts +58 -0
- package/dist/sandboxes/bwrap.js +296 -0
- package/dist/sandboxes/bwrap.js.map +1 -0
- package/dist/sandboxes/daytona.d.ts +1 -1
- package/dist/sandboxes/daytona.js +203 -98
- package/dist/sandboxes/daytona.js.map +1 -1
- package/dist/sandboxes/docker.d.ts +18 -4
- package/dist/sandboxes/docker.js +7 -4
- package/dist/sandboxes/e2b.d.ts +41 -0
- package/dist/sandboxes/e2b.js +202 -0
- package/dist/sandboxes/e2b.js.map +1 -0
- package/dist/sandboxes/modal.d.ts +78 -0
- package/dist/sandboxes/modal.js +171 -0
- package/dist/sandboxes/modal.js.map +1 -0
- package/dist/sandboxes/no-sandbox.d.ts +1 -1
- package/dist/sandboxes/no-sandbox.js +2 -2
- package/dist/sandboxes/podman.d.ts +18 -4
- package/dist/sandboxes/podman.js +72 -56
- package/dist/sandboxes/podman.js.map +1 -1
- package/dist/sandboxes/seatbelt.d.ts +65 -0
- package/dist/sandboxes/seatbelt.js +425 -0
- package/dist/sandboxes/seatbelt.js.map +1 -0
- package/dist/sandboxes/sprites.d.ts +54 -0
- package/dist/sandboxes/sprites.js +198 -0
- package/dist/sandboxes/sprites.js.map +1 -0
- package/dist/sandboxes/vercel.d.ts +12 -5
- package/dist/sandboxes/vercel.js +195 -126
- package/dist/sandboxes/vercel.js.map +1 -1
- package/dist/templates/parallel-planner/main.mts +13 -22
- package/dist/templates/parallel-planner-with-review/main.mts +13 -15
- package/package.json +63 -11
- package/dist/chunk-62WN33RK.js +0 -104
- package/dist/chunk-62WN33RK.js.map +0 -1
- package/dist/chunk-BIWNFKGV.js.map +0 -1
- package/dist/chunk-CP3TYXZA.js.map +0 -1
- package/dist/chunk-DJRHWPEH.js.map +0 -1
- package/dist/chunk-NGBM7T3E.js.map +0 -1
- package/dist/chunk-VOG34SRF.js.map +0 -1
- package/dist/mountUtils-CCA-bbpK.d.ts +0 -25
package/dist/main.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
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 { assertBwrapUsable } from './chunk-ATA2V2TC.js';
|
|
4
|
+
import { assertSeatbeltUsable } from './chunk-IBK2XNSS.js';
|
|
5
|
+
import { withFriendlyErrors } from './chunk-BIF2X6QB.js';
|
|
6
|
+
import { NodeContext_exports, NodeRuntime_exports } from './chunk-S6UHPTRG.js';
|
|
7
|
+
import { buildImage, removeImage } from './chunk-GCLEXPXG.js';
|
|
8
|
+
import { Display, ClackDisplay, defaultImageName, SANDBOX_REPO_DIR } from './chunk-G2R53CVZ.js';
|
|
9
|
+
import './chunk-EXYXBRCX.js';
|
|
10
|
+
import { InitError, FileSystem_exports, ConfigDirError, ImageNotFoundError, FileSystem, isQuitException, PodmanError, Terminal, QuitException, Path } from './chunk-RDW7FNN6.js';
|
|
11
|
+
import { CommitPrototype, dual, GenericTag, fromIterable, failSync, map2, reduce, Schema_exports, Effect_exports, Option_exports, Layer_exports, decode, mapError, TreeFormatter, empty, none, flatMap3, catchAll, match, fail3, map4 as map4$1, merge, some, right, left, isNonEmptyReadonlyArray, headNonEmpty, tailNonEmpty, isArray, identity, fromIterable2, fromIterable3, globalValue, contextWithEffect, getOrElse, getOption, appendAll, matchEffect, unify, catchSome, zipRight, matchLeft, pipe, zipLeft, log, succeed2 as succeed2$1, 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, try_, flatMap2, unsafeGet, drop, splitAt, tap, take, reduceRight, withMinimumLogLevel, error, mapInput, boolean, sort, contains, append, fromNullable, catchTags, when, set, pipeArguments, head, make10 as make10$1, suspend, get4, allocate, gen, updateAndGet, span, some2, sync, orElse2, has2, filter2, Config_exports, is, decodeUnknown, String$, fromString, make7 as make7$1, orElseFail, orDie, compose, NumberFromString, Int, Date$, findFirst, allLevels, updateEffect, flatten, fnUntraced, scoped, isNone, Literal, unlessEffect, asVoid, catchIf, runSync, of3 as of3$1, match3, filterOrDieMessage, filter3, 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-STB2U7BB.js';
|
|
12
|
+
import './chunk-BVZWLFFT.js';
|
|
13
|
+
import { __commonJS, __require, __toESM, __export } from './chunk-6NQPCXSG.js';
|
|
8
14
|
import * as clack from '@clack/prompts';
|
|
9
15
|
import { execSync, execFile } from 'child_process';
|
|
10
|
-
import { join, resolve, dirname } from 'path';
|
|
16
|
+
import { join, resolve, delimiter, dirname } from 'path';
|
|
11
17
|
import { styleText } from 'util';
|
|
12
18
|
import { fileURLToPath } from 'url';
|
|
13
19
|
import 'module';
|
|
@@ -4545,6 +4551,8 @@ var require_Alias = __commonJS({
|
|
|
4545
4551
|
* instance of the `source` anchor before this node.
|
|
4546
4552
|
*/
|
|
4547
4553
|
resolve(doc, ctx) {
|
|
4554
|
+
if (ctx?.maxAliasCount === 0)
|
|
4555
|
+
throw new ReferenceError("Alias resolution is disabled");
|
|
4548
4556
|
let nodes;
|
|
4549
4557
|
if (ctx?.aliasResolveCache) {
|
|
4550
4558
|
nodes = ctx.aliasResolveCache;
|
|
@@ -4566,36 +4574,38 @@ var require_Alias = __commonJS({
|
|
|
4566
4574
|
if (node.anchor === this.source)
|
|
4567
4575
|
found = node;
|
|
4568
4576
|
}
|
|
4577
|
+
if (found && ctx) {
|
|
4578
|
+
const { anchors: anchors2, doc: doc2, maxAliasCount } = ctx;
|
|
4579
|
+
let data = anchors2.get(found);
|
|
4580
|
+
if (!data) {
|
|
4581
|
+
toJS.toJS(found, null, ctx);
|
|
4582
|
+
data = anchors2.get(found);
|
|
4583
|
+
}
|
|
4584
|
+
if (data?.res === void 0) {
|
|
4585
|
+
const msg = "This should not happen: Alias anchor was not resolved?";
|
|
4586
|
+
throw new ReferenceError(msg);
|
|
4587
|
+
}
|
|
4588
|
+
if (maxAliasCount >= 0) {
|
|
4589
|
+
data.count += 1;
|
|
4590
|
+
if (data.aliasCount === 0)
|
|
4591
|
+
data.aliasCount = getAliasCount(doc2, found, anchors2);
|
|
4592
|
+
if (data.count * data.aliasCount > maxAliasCount) {
|
|
4593
|
+
const msg = "Excessive alias count indicates a resource exhaustion attack";
|
|
4594
|
+
throw new ReferenceError(msg);
|
|
4595
|
+
}
|
|
4596
|
+
}
|
|
4597
|
+
}
|
|
4569
4598
|
return found;
|
|
4570
4599
|
}
|
|
4571
4600
|
toJSON(_arg, ctx) {
|
|
4572
4601
|
if (!ctx)
|
|
4573
4602
|
return { source: this.source };
|
|
4574
|
-
const
|
|
4575
|
-
const source = this.resolve(doc, ctx);
|
|
4603
|
+
const source = this.resolve(ctx.doc, ctx);
|
|
4576
4604
|
if (!source) {
|
|
4577
4605
|
const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
|
4578
4606
|
throw new ReferenceError(msg);
|
|
4579
4607
|
}
|
|
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;
|
|
4608
|
+
return ctx.anchors.get(source).res;
|
|
4599
4609
|
}
|
|
4600
4610
|
toString(ctx, _onComment, _onChompKeep) {
|
|
4601
4611
|
const src = `*${this.source}`;
|
|
@@ -5337,6 +5347,7 @@ var require_stringify = __commonJS({
|
|
|
5337
5347
|
nullStr: "null",
|
|
5338
5348
|
simpleKeys: false,
|
|
5339
5349
|
singleQuote: null,
|
|
5350
|
+
trailingComma: false,
|
|
5340
5351
|
trueStr: "true",
|
|
5341
5352
|
verifyAliasOrder: true
|
|
5342
5353
|
}, doc.schema.toStringOptions, options3);
|
|
@@ -5606,18 +5617,18 @@ var require_merge = __commonJS({
|
|
|
5606
5617
|
};
|
|
5607
5618
|
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
5619
|
function addMergeToJSMap(ctx, map13, value2) {
|
|
5609
|
-
|
|
5610
|
-
if (identity2.isSeq(
|
|
5611
|
-
for (const it of
|
|
5620
|
+
const source = resolveAliasValue(ctx, value2);
|
|
5621
|
+
if (identity2.isSeq(source))
|
|
5622
|
+
for (const it of source.items)
|
|
5612
5623
|
mergeValue(ctx, map13, it);
|
|
5613
|
-
else if (Array.isArray(
|
|
5614
|
-
for (const it of
|
|
5624
|
+
else if (Array.isArray(source))
|
|
5625
|
+
for (const it of source)
|
|
5615
5626
|
mergeValue(ctx, map13, it);
|
|
5616
5627
|
else
|
|
5617
|
-
mergeValue(ctx, map13,
|
|
5628
|
+
mergeValue(ctx, map13, source);
|
|
5618
5629
|
}
|
|
5619
5630
|
function mergeValue(ctx, map13, value2) {
|
|
5620
|
-
const source = ctx
|
|
5631
|
+
const source = resolveAliasValue(ctx, value2);
|
|
5621
5632
|
if (!identity2.isMap(source))
|
|
5622
5633
|
throw new Error("Merge sources must be maps or map aliases");
|
|
5623
5634
|
const srcMap = source.toJSON(null, ctx, Map);
|
|
@@ -5638,6 +5649,9 @@ var require_merge = __commonJS({
|
|
|
5638
5649
|
}
|
|
5639
5650
|
return map13;
|
|
5640
5651
|
}
|
|
5652
|
+
function resolveAliasValue(ctx, value2) {
|
|
5653
|
+
return ctx && identity2.isAlias(value2) ? value2.resolve(ctx.doc, ctx) : value2;
|
|
5654
|
+
}
|
|
5641
5655
|
exports$1.addMergeToJSMap = addMergeToJSMap;
|
|
5642
5656
|
exports$1.isMergeKey = isMergeKey;
|
|
5643
5657
|
exports$1.merge = merge3;
|
|
@@ -5848,12 +5862,19 @@ ${indent3}${line4}` : "\n";
|
|
|
5848
5862
|
if (comment)
|
|
5849
5863
|
reqNewline = true;
|
|
5850
5864
|
let str = stringify2.stringify(item, itemCtx, () => comment = null);
|
|
5851
|
-
|
|
5865
|
+
reqNewline || (reqNewline = lines2.length > linesAtValue || str.includes("\n"));
|
|
5866
|
+
if (i < items.length - 1) {
|
|
5852
5867
|
str += ",";
|
|
5868
|
+
} else if (ctx.options.trailingComma) {
|
|
5869
|
+
if (ctx.options.lineWidth > 0) {
|
|
5870
|
+
reqNewline || (reqNewline = lines2.reduce((sum, line4) => sum + line4.length + 2, 2) + (str.length + 2) > ctx.options.lineWidth);
|
|
5871
|
+
}
|
|
5872
|
+
if (reqNewline) {
|
|
5873
|
+
str += ",";
|
|
5874
|
+
}
|
|
5875
|
+
}
|
|
5853
5876
|
if (comment)
|
|
5854
5877
|
str += stringifyComment.lineComment(str, itemIndent, commentString(comment));
|
|
5855
|
-
if (!reqNewline && (lines2.length > linesAtValue || str.includes("\n")))
|
|
5856
|
-
reqNewline = true;
|
|
5857
5878
|
lines2.push(str);
|
|
5858
5879
|
linesAtValue = lines2.length;
|
|
5859
5880
|
}
|
|
@@ -6257,7 +6278,7 @@ var require_stringifyNumber = __commonJS({
|
|
|
6257
6278
|
if (!isFinite(num))
|
|
6258
6279
|
return isNaN(num) ? ".nan" : num < 0 ? "-.inf" : ".inf";
|
|
6259
6280
|
let n = Object.is(value2, -0) ? "-0" : JSON.stringify(value2);
|
|
6260
|
-
if (!format && minFractionDigits && (!tag || tag === "tag:yaml.org,2002:float") &&
|
|
6281
|
+
if (!format && minFractionDigits && (!tag || tag === "tag:yaml.org,2002:float") && /^-?\d/.test(n) && !n.includes("e")) {
|
|
6261
6282
|
let i = n.indexOf(".");
|
|
6262
6283
|
if (i < 0) {
|
|
6263
6284
|
i = n.length;
|
|
@@ -8536,37 +8557,38 @@ var require_resolve_flow_scalar = __commonJS({
|
|
|
8536
8557
|
}
|
|
8537
8558
|
if (badChar)
|
|
8538
8559
|
onError(0, "BAD_SCALAR_START", `Plain value cannot start with ${badChar}`);
|
|
8539
|
-
return
|
|
8560
|
+
return unfoldLines(source);
|
|
8540
8561
|
}
|
|
8541
8562
|
function singleQuotedValue(source, onError) {
|
|
8542
8563
|
if (source[source.length - 1] !== "'" || source.length === 1)
|
|
8543
8564
|
onError(source.length, "MISSING_CHAR", "Missing closing 'quote");
|
|
8544
|
-
return
|
|
8565
|
+
return unfoldLines(source.slice(1, -1)).replace(/''/g, "'");
|
|
8545
8566
|
}
|
|
8546
|
-
function
|
|
8547
|
-
|
|
8567
|
+
function unfoldLines(source) {
|
|
8568
|
+
const line4 = /(.*?)\r?\n/sy;
|
|
8569
|
+
let match6 = line4.exec(source);
|
|
8570
|
+
if (!match6)
|
|
8571
|
+
return source;
|
|
8572
|
+
let trimEnd, trimBoth;
|
|
8548
8573
|
try {
|
|
8549
|
-
|
|
8550
|
-
|
|
8574
|
+
trimEnd = new RegExp("(?<![ ])[ ]+$");
|
|
8575
|
+
trimBoth = new RegExp("^[ ]+|(?<![ ])[ ]+$", "g");
|
|
8551
8576
|
} catch {
|
|
8552
|
-
|
|
8553
|
-
|
|
8577
|
+
trimEnd = /[ \t]+$/;
|
|
8578
|
+
trimBoth = /^[ \t]+|[ \t]+$/g;
|
|
8554
8579
|
}
|
|
8555
|
-
let
|
|
8556
|
-
if (!match6)
|
|
8557
|
-
return source;
|
|
8558
|
-
let res = match6[1];
|
|
8580
|
+
let res = match6[1].replace(trimEnd, "");
|
|
8559
8581
|
let sep = " ";
|
|
8560
|
-
let pos =
|
|
8561
|
-
line4.lastIndex = pos;
|
|
8582
|
+
let pos = line4.lastIndex;
|
|
8562
8583
|
while (match6 = line4.exec(source)) {
|
|
8563
|
-
|
|
8584
|
+
const lm = match6[1].replace(trimBoth, "");
|
|
8585
|
+
if (lm === "") {
|
|
8564
8586
|
if (sep === "\n")
|
|
8565
8587
|
res += sep;
|
|
8566
8588
|
else
|
|
8567
8589
|
sep = "\n";
|
|
8568
8590
|
} else {
|
|
8569
|
-
res += sep +
|
|
8591
|
+
res += sep + lm;
|
|
8570
8592
|
sep = " ";
|
|
8571
8593
|
}
|
|
8572
8594
|
pos = line4.lastIndex;
|
|
@@ -8600,7 +8622,7 @@ var require_resolve_flow_scalar = __commonJS({
|
|
|
8600
8622
|
while (next === " " || next === " ")
|
|
8601
8623
|
next = source[++i + 1];
|
|
8602
8624
|
} else if (next === "x" || next === "u" || next === "U") {
|
|
8603
|
-
const length =
|
|
8625
|
+
const length = next === "x" ? 2 : next === "u" ? 4 : 8;
|
|
8604
8626
|
res += parseCharCode(source, i + 1, length, onError);
|
|
8605
8627
|
i += length;
|
|
8606
8628
|
} else {
|
|
@@ -8675,12 +8697,13 @@ var require_resolve_flow_scalar = __commonJS({
|
|
|
8675
8697
|
const cc = source.substr(offset, length);
|
|
8676
8698
|
const ok = cc.length === length && /^[0-9a-fA-F]+$/.test(cc);
|
|
8677
8699
|
const code2 = ok ? parseInt(cc, 16) : NaN;
|
|
8678
|
-
|
|
8700
|
+
try {
|
|
8701
|
+
return String.fromCodePoint(code2);
|
|
8702
|
+
} catch {
|
|
8679
8703
|
const raw = source.substr(offset - 2, length + 2);
|
|
8680
8704
|
onError(offset - 2, "BAD_DQ_ESCAPE", `Invalid escape sequence ${raw}`);
|
|
8681
8705
|
return raw;
|
|
8682
8706
|
}
|
|
8683
|
-
return String.fromCodePoint(code2);
|
|
8684
8707
|
}
|
|
8685
8708
|
exports$1.resolveFlowScalar = resolveFlowScalar;
|
|
8686
8709
|
}
|
|
@@ -8827,17 +8850,22 @@ var require_compose_node = __commonJS({
|
|
|
8827
8850
|
case "block-map":
|
|
8828
8851
|
case "block-seq":
|
|
8829
8852
|
case "flow-collection":
|
|
8830
|
-
|
|
8831
|
-
|
|
8832
|
-
|
|
8853
|
+
try {
|
|
8854
|
+
node = composeCollection.composeCollection(CN, ctx, token, props, onError);
|
|
8855
|
+
if (anchor)
|
|
8856
|
+
node.anchor = anchor.source.substring(1);
|
|
8857
|
+
} catch (error3) {
|
|
8858
|
+
const message = error3 instanceof Error ? error3.message : String(error3);
|
|
8859
|
+
onError(token, "RESOURCE_EXHAUSTION", message);
|
|
8860
|
+
}
|
|
8833
8861
|
break;
|
|
8834
8862
|
default: {
|
|
8835
8863
|
const message = token.type === "error" ? token.message : `Unsupported token (type: ${token.type})`;
|
|
8836
8864
|
onError(token, "UNEXPECTED_TOKEN", message);
|
|
8837
|
-
node = composeEmptyNode(ctx, token.offset, void 0, null, props, onError);
|
|
8838
8865
|
isSrcToken = false;
|
|
8839
8866
|
}
|
|
8840
8867
|
}
|
|
8868
|
+
node ?? (node = composeEmptyNode(ctx, token.offset, void 0, null, props, onError));
|
|
8841
8869
|
if (anchor && node.anchor === "")
|
|
8842
8870
|
onError(anchor, "BAD_ALIAS", "Anchor cannot be an empty string");
|
|
8843
8871
|
if (atKey && ctx.options.stringKeys && (!identity2.isScalar(node) || typeof node.value !== "string" || node.tag && node.tag !== "tag:yaml.org,2002:str")) {
|
|
@@ -9020,8 +9048,10 @@ ${cb}` : comment;
|
|
|
9020
9048
|
}
|
|
9021
9049
|
}
|
|
9022
9050
|
if (afterDoc) {
|
|
9023
|
-
|
|
9024
|
-
|
|
9051
|
+
for (let i = 0; i < this.errors.length; ++i)
|
|
9052
|
+
doc.errors.push(this.errors[i]);
|
|
9053
|
+
for (let i = 0; i < this.warnings.length; ++i)
|
|
9054
|
+
doc.warnings.push(this.warnings[i]);
|
|
9025
9055
|
} else {
|
|
9026
9056
|
doc.errors = this.errors;
|
|
9027
9057
|
doc.warnings = this.warnings;
|
|
@@ -9749,7 +9779,7 @@ var require_lexer = __commonJS({
|
|
|
9749
9779
|
const n = (yield* this.pushCount(1)) + (yield* this.pushSpaces(true));
|
|
9750
9780
|
this.indentNext = this.indentValue + 1;
|
|
9751
9781
|
this.indentValue += n;
|
|
9752
|
-
return
|
|
9782
|
+
return "block-start";
|
|
9753
9783
|
}
|
|
9754
9784
|
return "doc";
|
|
9755
9785
|
}
|
|
@@ -10048,28 +10078,38 @@ var require_lexer = __commonJS({
|
|
|
10048
10078
|
return 0;
|
|
10049
10079
|
}
|
|
10050
10080
|
*pushIndicators() {
|
|
10051
|
-
|
|
10052
|
-
|
|
10053
|
-
|
|
10054
|
-
|
|
10055
|
-
|
|
10056
|
-
|
|
10057
|
-
|
|
10058
|
-
|
|
10059
|
-
|
|
10060
|
-
|
|
10061
|
-
|
|
10062
|
-
|
|
10063
|
-
|
|
10064
|
-
|
|
10065
|
-
|
|
10066
|
-
|
|
10067
|
-
|
|
10068
|
-
|
|
10081
|
+
let n = 0;
|
|
10082
|
+
loop: while (true) {
|
|
10083
|
+
switch (this.charAt(0)) {
|
|
10084
|
+
case "!":
|
|
10085
|
+
n += yield* this.pushTag();
|
|
10086
|
+
n += yield* this.pushSpaces(true);
|
|
10087
|
+
continue loop;
|
|
10088
|
+
case "&":
|
|
10089
|
+
n += yield* this.pushUntil(isNotAnchorChar);
|
|
10090
|
+
n += yield* this.pushSpaces(true);
|
|
10091
|
+
continue loop;
|
|
10092
|
+
case "-":
|
|
10093
|
+
// this is an error
|
|
10094
|
+
case "?":
|
|
10095
|
+
// this is an error outside flow collections
|
|
10096
|
+
case ":": {
|
|
10097
|
+
const inFlow = this.flowLevel > 0;
|
|
10098
|
+
const ch1 = this.charAt(1);
|
|
10099
|
+
if (isEmpty8(ch1) || inFlow && flowIndicatorChars.has(ch1)) {
|
|
10100
|
+
if (!inFlow)
|
|
10101
|
+
this.indentNext = this.indentValue + 1;
|
|
10102
|
+
else if (this.flowKey)
|
|
10103
|
+
this.flowKey = false;
|
|
10104
|
+
n += yield* this.pushCount(1);
|
|
10105
|
+
n += yield* this.pushSpaces(true);
|
|
10106
|
+
continue loop;
|
|
10107
|
+
}
|
|
10069
10108
|
}
|
|
10070
10109
|
}
|
|
10110
|
+
break loop;
|
|
10071
10111
|
}
|
|
10072
|
-
return
|
|
10112
|
+
return n;
|
|
10073
10113
|
}
|
|
10074
10114
|
*pushTag() {
|
|
10075
10115
|
if (this.charAt(1) === "<") {
|
|
@@ -10226,6 +10266,13 @@ var require_parser2 = __commonJS({
|
|
|
10226
10266
|
}
|
|
10227
10267
|
return prev.splice(i, prev.length);
|
|
10228
10268
|
}
|
|
10269
|
+
function arrayPushArray(target, source) {
|
|
10270
|
+
if (source.length < 1e5)
|
|
10271
|
+
Array.prototype.push.apply(target, source);
|
|
10272
|
+
else
|
|
10273
|
+
for (let i = 0; i < source.length; ++i)
|
|
10274
|
+
target.push(source[i]);
|
|
10275
|
+
}
|
|
10229
10276
|
function fixFlowSeqItems(fc) {
|
|
10230
10277
|
if (fc.start.type === "flow-seq-start") {
|
|
10231
10278
|
for (const it of fc.items) {
|
|
@@ -10235,11 +10282,11 @@ var require_parser2 = __commonJS({
|
|
|
10235
10282
|
delete it.key;
|
|
10236
10283
|
if (isFlowToken(it.value)) {
|
|
10237
10284
|
if (it.value.end)
|
|
10238
|
-
|
|
10285
|
+
arrayPushArray(it.value.end, it.sep);
|
|
10239
10286
|
else
|
|
10240
10287
|
it.value.end = it.sep;
|
|
10241
10288
|
} else
|
|
10242
|
-
|
|
10289
|
+
arrayPushArray(it.start, it.sep);
|
|
10243
10290
|
delete it.sep;
|
|
10244
10291
|
}
|
|
10245
10292
|
}
|
|
@@ -10594,7 +10641,7 @@ var require_parser2 = __commonJS({
|
|
|
10594
10641
|
const prev = map13.items[map13.items.length - 2];
|
|
10595
10642
|
const end = prev?.value?.end;
|
|
10596
10643
|
if (Array.isArray(end)) {
|
|
10597
|
-
|
|
10644
|
+
arrayPushArray(end, it.start);
|
|
10598
10645
|
end.push(this.sourceToken);
|
|
10599
10646
|
map13.items.pop();
|
|
10600
10647
|
return;
|
|
@@ -10782,7 +10829,7 @@ var require_parser2 = __commonJS({
|
|
|
10782
10829
|
const prev = seq.items[seq.items.length - 2];
|
|
10783
10830
|
const end = prev?.value?.end;
|
|
10784
10831
|
if (Array.isArray(end)) {
|
|
10785
|
-
|
|
10832
|
+
arrayPushArray(end, it.start);
|
|
10786
10833
|
end.push(this.sourceToken);
|
|
10787
10834
|
seq.items.pop();
|
|
10788
10835
|
return;
|
|
@@ -11182,17 +11229,17 @@ var fileParsers = {
|
|
|
11182
11229
|
tml: (content) => Toml.parse(content)
|
|
11183
11230
|
};
|
|
11184
11231
|
var read = (path2) => flatMap3(FileSystem, (fs) => matchEffect(fs.readFile(path2), {
|
|
11185
|
-
onFailure: (error3) =>
|
|
11186
|
-
onSuccess: (content) =>
|
|
11232
|
+
onFailure: (error3) => fail3(`Could not read file (${path2}): ${error3}`),
|
|
11233
|
+
onSuccess: (content) => succeed2$1([path2, content])
|
|
11187
11234
|
}));
|
|
11188
11235
|
var readString = (path2) => flatMap3(FileSystem, (fs) => matchEffect(fs.readFileString(path2), {
|
|
11189
|
-
onFailure: (error3) =>
|
|
11190
|
-
onSuccess: (content) =>
|
|
11236
|
+
onFailure: (error3) => fail3(`Could not read file (${path2}): ${error3}`),
|
|
11237
|
+
onSuccess: (content) => succeed2$1([path2, content])
|
|
11191
11238
|
}));
|
|
11192
11239
|
var parse4 = (path2, content, format) => {
|
|
11193
11240
|
const parser = fileParsers[format ?? path2.split(".").pop()];
|
|
11194
11241
|
if (parser === void 0) {
|
|
11195
|
-
return
|
|
11242
|
+
return fail3(`Unsupported file format: ${format}`);
|
|
11196
11243
|
}
|
|
11197
11244
|
return try_({
|
|
11198
11245
|
try: () => parser(content),
|
|
@@ -11866,7 +11913,7 @@ var changesUponFlatteningSafe = (self) => gen(function* () {
|
|
|
11866
11913
|
throw new Error("[BUG]: Doc.changesUponFlattening - unable to flatten a Cat document - please open an issue at https://github.com/IMax153/contentlayer/issues/new");
|
|
11867
11914
|
}
|
|
11868
11915
|
case "Nest": {
|
|
11869
|
-
return yield* pipe(changesUponFlatteningSafe(self.doc),
|
|
11916
|
+
return yield* pipe(changesUponFlatteningSafe(self.doc), map4$1(map5((doc) => nest(doc, self.indent))));
|
|
11870
11917
|
}
|
|
11871
11918
|
case "Union": {
|
|
11872
11919
|
return flattened(self.left);
|
|
@@ -11884,7 +11931,7 @@ var changesUponFlatteningSafe = (self) => gen(function* () {
|
|
|
11884
11931
|
return flattened(doc);
|
|
11885
11932
|
}
|
|
11886
11933
|
case "Annotated": {
|
|
11887
|
-
return yield* pipe(changesUponFlatteningSafe(self.doc),
|
|
11934
|
+
return yield* pipe(changesUponFlatteningSafe(self.doc), map4$1(map5((doc) => annotate(doc, self.annotation))));
|
|
11888
11935
|
}
|
|
11889
11936
|
}
|
|
11890
11937
|
});
|
|
@@ -12138,7 +12185,7 @@ var selectNicer = (fits, lineIndent, currentColumn, left2, right2) => {
|
|
|
12138
12185
|
let rightStream = void 0;
|
|
12139
12186
|
return fits(leftStream, lineIndent, currentColumn, () => rightStream ?? (rightStream = runSync(right2), rightStream)) ? leftStream : rightStream ?? runSync(right2);
|
|
12140
12187
|
};
|
|
12141
|
-
var compact = (self) => runSync(compactSafe(
|
|
12188
|
+
var compact = (self) => runSync(compactSafe(of3$1(self), 0));
|
|
12142
12189
|
var compactSafe = (docs, i) => gen(function* () {
|
|
12143
12190
|
if (isNil(docs)) {
|
|
12144
12191
|
return empty4;
|
|
@@ -12402,7 +12449,7 @@ var render = /* @__PURE__ */ dual(2, (self, config) => {
|
|
|
12402
12449
|
}
|
|
12403
12450
|
}
|
|
12404
12451
|
});
|
|
12405
|
-
var renderStream = (self) => runSync(renderSafe(self,
|
|
12452
|
+
var renderStream = (self) => runSync(renderSafe(self, of3$1(none2)));
|
|
12406
12453
|
var unsafePeek = (stack) => {
|
|
12407
12454
|
if (isNil(stack)) {
|
|
12408
12455
|
throw new Error("BUG: AnsiRender.unsafePeek - peeked at an empty stack - please report an issue at https://github.com/Effect-TS/printer/issues");
|
|
@@ -12421,30 +12468,30 @@ var renderSafe = (self, stack) => {
|
|
|
12421
12468
|
return dieMessage("BUG: AnsiRender.renderSafe - attempted to render a failed doc stream - please report an issue at https://github.com/Effect-TS/printer/issues");
|
|
12422
12469
|
}
|
|
12423
12470
|
case "EmptyStream": {
|
|
12424
|
-
return
|
|
12471
|
+
return succeed2$1("");
|
|
12425
12472
|
}
|
|
12426
12473
|
case "CharStream": {
|
|
12427
|
-
return
|
|
12474
|
+
return map4$1(suspend(() => renderSafe(self.stream, stack)), (rest) => self.char + rest);
|
|
12428
12475
|
}
|
|
12429
12476
|
case "TextStream": {
|
|
12430
|
-
return
|
|
12477
|
+
return map4$1(suspend(() => renderSafe(self.stream, stack)), (rest) => self.text + rest);
|
|
12431
12478
|
}
|
|
12432
12479
|
case "LineStream": {
|
|
12433
12480
|
let indent3 = "\n";
|
|
12434
12481
|
for (let i = 0; i < self.indentation; i++) {
|
|
12435
12482
|
indent3 = indent3 += " ";
|
|
12436
12483
|
}
|
|
12437
|
-
return
|
|
12484
|
+
return map4$1(suspend(() => renderSafe(self.stream, stack)), (rest) => indent3 + rest);
|
|
12438
12485
|
}
|
|
12439
12486
|
case "PushAnnotationStream": {
|
|
12440
12487
|
const currentStyle = unsafePeek(stack);
|
|
12441
12488
|
const nextStyle = combine2(self.annotation, currentStyle);
|
|
12442
|
-
return
|
|
12489
|
+
return map4$1(suspend(() => renderSafe(self.stream, cons(self.annotation, stack))), (rest) => stringify(nextStyle) + rest);
|
|
12443
12490
|
}
|
|
12444
12491
|
case "PopAnnotationStream": {
|
|
12445
12492
|
const [, styles] = unsafePop(stack);
|
|
12446
12493
|
const nextStyle = unsafePeek(styles);
|
|
12447
|
-
return
|
|
12494
|
+
return map4$1(suspend(() => renderSafe(self.stream, styles)), (rest) => stringify(nextStyle) + rest);
|
|
12448
12495
|
}
|
|
12449
12496
|
}
|
|
12450
12497
|
};
|
|
@@ -12788,7 +12835,7 @@ var runWithInput = (prompt4, terminal, input) => suspend(() => {
|
|
|
12788
12835
|
return flatMap3(runWithInput(op.prompt, terminal, input), (a) => runWithInput(op.onSuccess(a), terminal, input));
|
|
12789
12836
|
}
|
|
12790
12837
|
case "Succeed": {
|
|
12791
|
-
return
|
|
12838
|
+
return succeed2$1(op.value);
|
|
12792
12839
|
}
|
|
12793
12840
|
}
|
|
12794
12841
|
});
|
|
@@ -12861,7 +12908,7 @@ var windowsFigures = {
|
|
|
12861
12908
|
line: /* @__PURE__ */ text3("\u2500"),
|
|
12862
12909
|
pointer: /* @__PURE__ */ text3(">")
|
|
12863
12910
|
};
|
|
12864
|
-
var figures = /* @__PURE__ */
|
|
12911
|
+
var figures = /* @__PURE__ */ map4$1(/* @__PURE__ */ sync(() => process.platform === "win32"), (isWindows) => isWindows ? windowsFigures : defaultFigures);
|
|
12865
12912
|
function eraseText(text9, columns) {
|
|
12866
12913
|
if (columns === 0) {
|
|
12867
12914
|
return cat2(eraseLine3, cursorTo3(0));
|
|
@@ -13054,7 +13101,7 @@ var defaultLocales = {
|
|
|
13054
13101
|
function handleRender(options3) {
|
|
13055
13102
|
return (state, action) => {
|
|
13056
13103
|
return Action.$match(action, {
|
|
13057
|
-
Beep: () =>
|
|
13104
|
+
Beep: () => succeed2$1(renderBeep),
|
|
13058
13105
|
NextFrame: ({
|
|
13059
13106
|
state: state2
|
|
13060
13107
|
}) => renderNextFrame(state2, options3),
|
|
@@ -13066,21 +13113,21 @@ function handleProcess(options3) {
|
|
|
13066
13113
|
return (input, state) => {
|
|
13067
13114
|
switch (input.key.name) {
|
|
13068
13115
|
case "left": {
|
|
13069
|
-
return
|
|
13116
|
+
return succeed2$1(processCursorLeft(state));
|
|
13070
13117
|
}
|
|
13071
13118
|
case "right": {
|
|
13072
|
-
return
|
|
13119
|
+
return succeed2$1(processCursorRight(state));
|
|
13073
13120
|
}
|
|
13074
13121
|
case "k":
|
|
13075
13122
|
case "up": {
|
|
13076
|
-
return
|
|
13123
|
+
return succeed2$1(processUp(state));
|
|
13077
13124
|
}
|
|
13078
13125
|
case "j":
|
|
13079
13126
|
case "down": {
|
|
13080
|
-
return
|
|
13127
|
+
return succeed2$1(processDown(state));
|
|
13081
13128
|
}
|
|
13082
13129
|
case "tab": {
|
|
13083
|
-
return
|
|
13130
|
+
return succeed2$1(processNext(state));
|
|
13084
13131
|
}
|
|
13085
13132
|
case "enter":
|
|
13086
13133
|
case "return": {
|
|
@@ -13098,7 +13145,7 @@ function handleProcess(options3) {
|
|
|
13098
13145
|
}
|
|
13099
13146
|
default: {
|
|
13100
13147
|
const value2 = getOrElse(input.input, () => "");
|
|
13101
|
-
return
|
|
13148
|
+
return succeed2$1(defaultProcessor(value2, state));
|
|
13102
13149
|
}
|
|
13103
13150
|
}
|
|
13104
13151
|
};
|
|
@@ -13107,7 +13154,7 @@ var date = (options3) => {
|
|
|
13107
13154
|
const opts = {
|
|
13108
13155
|
initial: /* @__PURE__ */ new Date(),
|
|
13109
13156
|
dateMask: "YYYY-MM-DD HH:mm:ss",
|
|
13110
|
-
validate:
|
|
13157
|
+
validate: succeed2$1,
|
|
13111
13158
|
...options3,
|
|
13112
13159
|
locales: {
|
|
13113
13160
|
...defaultLocales,
|
|
@@ -13385,7 +13432,7 @@ function resolveCurrentPath(path2, options3) {
|
|
|
13385
13432
|
orDie(fs.exists(path3)).pipe(filterOrDieMessage(identity, `The provided starting path '${path3}' does not exist`), as(path3))
|
|
13386
13433
|
))
|
|
13387
13434
|
}),
|
|
13388
|
-
onSome: (path3) =>
|
|
13435
|
+
onSome: (path3) => succeed2$1(path3)
|
|
13389
13436
|
});
|
|
13390
13437
|
}
|
|
13391
13438
|
function getFileList(directory3, options3) {
|
|
@@ -13395,12 +13442,12 @@ function getFileList(directory3, options3) {
|
|
|
13395
13442
|
const files = yield* orDie(fs.readDirectory(directory3)).pipe(
|
|
13396
13443
|
// Always prepend the `".."` option to the file list but allow it
|
|
13397
13444
|
// to be filtered out if the user so desires
|
|
13398
|
-
|
|
13445
|
+
map4$1((files2) => ["..", ...files2])
|
|
13399
13446
|
);
|
|
13400
|
-
return yield*
|
|
13447
|
+
return yield* filter3(files, (file4) => {
|
|
13401
13448
|
const result = options3.filter(file4);
|
|
13402
|
-
const userDefinedFilter = isEffect(result) ? result :
|
|
13403
|
-
const directoryFilter = options3.type === "directory" ?
|
|
13449
|
+
const userDefinedFilter = isEffect(result) ? result : succeed2$1(result);
|
|
13450
|
+
const directoryFilter = options3.type === "directory" ? map4$1(orDie(fs.stat(path2.join(directory3, file4))), (info) => info.type === "Directory") : succeed2$1(true);
|
|
13404
13451
|
return zipWith(userDefinedFilter, directoryFilter, (a, b) => a && b);
|
|
13405
13452
|
}, {
|
|
13406
13453
|
concurrency: files.length
|
|
@@ -13517,7 +13564,7 @@ function renderSubmission2(value2, options3) {
|
|
|
13517
13564
|
function handleRender2(options3) {
|
|
13518
13565
|
return (_, action) => {
|
|
13519
13566
|
return Action.$match(action, {
|
|
13520
|
-
Beep: () =>
|
|
13567
|
+
Beep: () => succeed2$1(renderBeep2),
|
|
13521
13568
|
NextFrame: ({
|
|
13522
13569
|
state
|
|
13523
13570
|
}) => renderNextFrame2(state, options3),
|
|
@@ -13529,7 +13576,7 @@ function handleRender2(options3) {
|
|
|
13529
13576
|
}
|
|
13530
13577
|
function processCursorUp(state) {
|
|
13531
13578
|
const cursor = state.cursor - 1;
|
|
13532
|
-
return
|
|
13579
|
+
return succeed2$1(Action.NextFrame({
|
|
13533
13580
|
state: {
|
|
13534
13581
|
...state,
|
|
13535
13582
|
cursor: cursor < 0 ? state.files.length - 1 : cursor
|
|
@@ -13537,7 +13584,7 @@ function processCursorUp(state) {
|
|
|
13537
13584
|
}));
|
|
13538
13585
|
}
|
|
13539
13586
|
function processCursorDown(state) {
|
|
13540
|
-
return
|
|
13587
|
+
return succeed2$1(Action.NextFrame({
|
|
13541
13588
|
state: {
|
|
13542
13589
|
...state,
|
|
13543
13590
|
cursor: (state.cursor + 1) % state.files.length
|
|
@@ -13639,7 +13686,7 @@ var file = (options3 = {}) => {
|
|
|
13639
13686
|
message: options3.message ?? `Choose a file`,
|
|
13640
13687
|
startingPath: fromNullable(options3.startingPath),
|
|
13641
13688
|
maxPerPage: options3.maxPerPage ?? 10,
|
|
13642
|
-
filter: options3.filter ?? (() =>
|
|
13689
|
+
filter: options3.filter ?? (() => succeed2$1(true))
|
|
13643
13690
|
};
|
|
13644
13691
|
const initialState3 = gen(function* () {
|
|
13645
13692
|
const path2 = none();
|
|
@@ -13756,10 +13803,10 @@ function renderSubmission3(nextState, options3) {
|
|
|
13756
13803
|
}
|
|
13757
13804
|
function processBackspace(state) {
|
|
13758
13805
|
if (state.value.length <= 0) {
|
|
13759
|
-
return
|
|
13806
|
+
return succeed2$1(Action.Beep());
|
|
13760
13807
|
}
|
|
13761
13808
|
const value2 = state.value.slice(0, state.value.length - 1);
|
|
13762
|
-
return
|
|
13809
|
+
return succeed2$1(Action.NextFrame({
|
|
13763
13810
|
state: {
|
|
13764
13811
|
...state,
|
|
13765
13812
|
value: value2,
|
|
@@ -13769,7 +13816,7 @@ function processBackspace(state) {
|
|
|
13769
13816
|
}
|
|
13770
13817
|
function defaultIntProcessor(state, input) {
|
|
13771
13818
|
if (state.value.length === 0 && input === "-") {
|
|
13772
|
-
return
|
|
13819
|
+
return succeed2$1(Action.NextFrame({
|
|
13773
13820
|
state: {
|
|
13774
13821
|
...state,
|
|
13775
13822
|
value: "-",
|
|
@@ -13790,10 +13837,10 @@ function defaultIntProcessor(state, input) {
|
|
|
13790
13837
|
}
|
|
13791
13838
|
function defaultFloatProcessor(state, input) {
|
|
13792
13839
|
if (input === "." && state.value.includes(".")) {
|
|
13793
|
-
return
|
|
13840
|
+
return succeed2$1(Action.Beep());
|
|
13794
13841
|
}
|
|
13795
13842
|
if (state.value.length === 0 && input === "-") {
|
|
13796
|
-
return
|
|
13843
|
+
return succeed2$1(Action.NextFrame({
|
|
13797
13844
|
state: {
|
|
13798
13845
|
...state,
|
|
13799
13846
|
value: "-",
|
|
@@ -13820,7 +13867,7 @@ var initialState = {
|
|
|
13820
13867
|
function handleRenderInteger(options3) {
|
|
13821
13868
|
return (state, action) => {
|
|
13822
13869
|
return Action.$match(action, {
|
|
13823
|
-
Beep: () =>
|
|
13870
|
+
Beep: () => succeed2$1(renderBeep3),
|
|
13824
13871
|
NextFrame: ({
|
|
13825
13872
|
state: state2
|
|
13826
13873
|
}) => renderNextFrame3(state2, options3),
|
|
@@ -13836,7 +13883,7 @@ function handleProcessInteger(options3) {
|
|
|
13836
13883
|
}
|
|
13837
13884
|
case "k":
|
|
13838
13885
|
case "up": {
|
|
13839
|
-
return
|
|
13886
|
+
return succeed2$1(Action.NextFrame({
|
|
13840
13887
|
state: {
|
|
13841
13888
|
...state,
|
|
13842
13889
|
value: state.value === "" || state.value === "-" ? `${options3.incrementBy}` : `${Number.parseInt(state.value) + options3.incrementBy}`,
|
|
@@ -13846,7 +13893,7 @@ function handleProcessInteger(options3) {
|
|
|
13846
13893
|
}
|
|
13847
13894
|
case "j":
|
|
13848
13895
|
case "down": {
|
|
13849
|
-
return
|
|
13896
|
+
return succeed2$1(Action.NextFrame({
|
|
13850
13897
|
state: {
|
|
13851
13898
|
...state,
|
|
13852
13899
|
value: state.value === "" || state.value === "-" ? `-${options3.decrementBy}` : `${Number.parseInt(state.value) - options3.decrementBy}`,
|
|
@@ -13857,7 +13904,7 @@ function handleProcessInteger(options3) {
|
|
|
13857
13904
|
case "enter":
|
|
13858
13905
|
case "return": {
|
|
13859
13906
|
return matchEffect(parseInt2(state.value), {
|
|
13860
|
-
onFailure: () =>
|
|
13907
|
+
onFailure: () => succeed2$1(Action.NextFrame({
|
|
13861
13908
|
state: {
|
|
13862
13909
|
...state,
|
|
13863
13910
|
error: some("Must provide an integer value")
|
|
@@ -13891,12 +13938,12 @@ var integer = (options3) => {
|
|
|
13891
13938
|
decrementBy: 1,
|
|
13892
13939
|
validate: (n) => {
|
|
13893
13940
|
if (n < opts.min) {
|
|
13894
|
-
return
|
|
13941
|
+
return fail3(`${n} must be greater than or equal to ${opts.min}`);
|
|
13895
13942
|
}
|
|
13896
13943
|
if (n > opts.max) {
|
|
13897
|
-
return
|
|
13944
|
+
return fail3(`${n} must be less than or equal to ${opts.max}`);
|
|
13898
13945
|
}
|
|
13899
|
-
return
|
|
13946
|
+
return succeed2$1(n);
|
|
13900
13947
|
},
|
|
13901
13948
|
...options3
|
|
13902
13949
|
};
|
|
@@ -13909,7 +13956,7 @@ var integer = (options3) => {
|
|
|
13909
13956
|
function handleRenderFloat(options3) {
|
|
13910
13957
|
return (state, action) => {
|
|
13911
13958
|
return Action.$match(action, {
|
|
13912
|
-
Beep: () =>
|
|
13959
|
+
Beep: () => succeed2$1(renderBeep3),
|
|
13913
13960
|
NextFrame: ({
|
|
13914
13961
|
state: state2
|
|
13915
13962
|
}) => renderNextFrame3(state2, options3),
|
|
@@ -13925,7 +13972,7 @@ function handleProcessFloat(options3) {
|
|
|
13925
13972
|
}
|
|
13926
13973
|
case "k":
|
|
13927
13974
|
case "up": {
|
|
13928
|
-
return
|
|
13975
|
+
return succeed2$1(Action.NextFrame({
|
|
13929
13976
|
state: {
|
|
13930
13977
|
...state,
|
|
13931
13978
|
value: state.value === "" || state.value === "-" ? `${options3.incrementBy}` : `${Number.parseFloat(state.value) + options3.incrementBy}`,
|
|
@@ -13935,7 +13982,7 @@ function handleProcessFloat(options3) {
|
|
|
13935
13982
|
}
|
|
13936
13983
|
case "j":
|
|
13937
13984
|
case "down": {
|
|
13938
|
-
return
|
|
13985
|
+
return succeed2$1(Action.NextFrame({
|
|
13939
13986
|
state: {
|
|
13940
13987
|
...state,
|
|
13941
13988
|
value: state.value === "" || state.value === "-" ? `-${options3.decrementBy}` : `${Number.parseFloat(state.value) - options3.decrementBy}`,
|
|
@@ -13946,7 +13993,7 @@ function handleProcessFloat(options3) {
|
|
|
13946
13993
|
case "enter":
|
|
13947
13994
|
case "return": {
|
|
13948
13995
|
return matchEffect(parseFloat2(state.value), {
|
|
13949
|
-
onFailure: () =>
|
|
13996
|
+
onFailure: () => succeed2$1(Action.NextFrame({
|
|
13950
13997
|
state: {
|
|
13951
13998
|
...state,
|
|
13952
13999
|
error: some("Must provide a floating point value")
|
|
@@ -13981,12 +14028,12 @@ var float = (options3) => {
|
|
|
13981
14028
|
precision: 2,
|
|
13982
14029
|
validate: (n) => {
|
|
13983
14030
|
if (n < opts.min) {
|
|
13984
|
-
return
|
|
14031
|
+
return fail3(`${n} must be greater than or equal to ${opts.min}`);
|
|
13985
14032
|
}
|
|
13986
14033
|
if (n > opts.max) {
|
|
13987
|
-
return
|
|
14034
|
+
return fail3(`${n} must be less than or equal to ${opts.max}`);
|
|
13988
14035
|
}
|
|
13989
|
-
return
|
|
14036
|
+
return succeed2$1(n);
|
|
13990
14037
|
},
|
|
13991
14038
|
...options3
|
|
13992
14039
|
};
|
|
@@ -14089,33 +14136,33 @@ function renderSubmission4(state, options3) {
|
|
|
14089
14136
|
}
|
|
14090
14137
|
function processCursorUp2(state, choices) {
|
|
14091
14138
|
if (state === 0) {
|
|
14092
|
-
return
|
|
14139
|
+
return succeed2$1(Action.NextFrame({
|
|
14093
14140
|
state: choices.length - 1
|
|
14094
14141
|
}));
|
|
14095
14142
|
}
|
|
14096
|
-
return
|
|
14143
|
+
return succeed2$1(Action.NextFrame({
|
|
14097
14144
|
state: state - 1
|
|
14098
14145
|
}));
|
|
14099
14146
|
}
|
|
14100
14147
|
function processCursorDown2(state, choices) {
|
|
14101
14148
|
if (state === choices.length - 1) {
|
|
14102
|
-
return
|
|
14149
|
+
return succeed2$1(Action.NextFrame({
|
|
14103
14150
|
state: 0
|
|
14104
14151
|
}));
|
|
14105
14152
|
}
|
|
14106
|
-
return
|
|
14153
|
+
return succeed2$1(Action.NextFrame({
|
|
14107
14154
|
state: state + 1
|
|
14108
14155
|
}));
|
|
14109
14156
|
}
|
|
14110
14157
|
function processNext2(state, choices) {
|
|
14111
|
-
return
|
|
14158
|
+
return succeed2$1(Action.NextFrame({
|
|
14112
14159
|
state: (state + 1) % choices.length
|
|
14113
14160
|
}));
|
|
14114
14161
|
}
|
|
14115
14162
|
function handleRender3(options3) {
|
|
14116
14163
|
return (state, action) => {
|
|
14117
14164
|
return Action.$match(action, {
|
|
14118
|
-
Beep: () =>
|
|
14165
|
+
Beep: () => succeed2$1(renderBeep4),
|
|
14119
14166
|
NextFrame: ({
|
|
14120
14167
|
state: state2
|
|
14121
14168
|
}) => renderNextFrame4(state2, options3),
|
|
@@ -14156,14 +14203,14 @@ function handleProcess3(options3) {
|
|
|
14156
14203
|
case "return": {
|
|
14157
14204
|
const selected = options3.choices[state];
|
|
14158
14205
|
if (selected.disabled) {
|
|
14159
|
-
return
|
|
14206
|
+
return succeed2$1(Action.Beep());
|
|
14160
14207
|
}
|
|
14161
|
-
return
|
|
14208
|
+
return succeed2$1(Action.Submit({
|
|
14162
14209
|
value: selected.value
|
|
14163
14210
|
}));
|
|
14164
14211
|
}
|
|
14165
14212
|
default: {
|
|
14166
|
-
return
|
|
14213
|
+
return succeed2$1(Action.Beep());
|
|
14167
14214
|
}
|
|
14168
14215
|
}
|
|
14169
14216
|
};
|
|
@@ -14316,13 +14363,13 @@ function renderSubmission5(state, options3) {
|
|
|
14316
14363
|
}
|
|
14317
14364
|
function processBackspace2(state) {
|
|
14318
14365
|
if (state.cursor <= 0) {
|
|
14319
|
-
return
|
|
14366
|
+
return succeed2$1(Action.Beep());
|
|
14320
14367
|
}
|
|
14321
14368
|
const beforeCursor = state.value.slice(0, state.cursor - 1);
|
|
14322
14369
|
const afterCursor = state.value.slice(state.cursor);
|
|
14323
14370
|
const cursor = state.cursor - 1;
|
|
14324
14371
|
const value2 = `${beforeCursor}${afterCursor}`;
|
|
14325
|
-
return
|
|
14372
|
+
return succeed2$1(Action.NextFrame({
|
|
14326
14373
|
state: {
|
|
14327
14374
|
...state,
|
|
14328
14375
|
cursor,
|
|
@@ -14333,10 +14380,10 @@ function processBackspace2(state) {
|
|
|
14333
14380
|
}
|
|
14334
14381
|
function processCursorLeft2(state) {
|
|
14335
14382
|
if (state.cursor <= 0) {
|
|
14336
|
-
return
|
|
14383
|
+
return succeed2$1(Action.Beep());
|
|
14337
14384
|
}
|
|
14338
14385
|
const cursor = state.cursor - 1;
|
|
14339
|
-
return
|
|
14386
|
+
return succeed2$1(Action.NextFrame({
|
|
14340
14387
|
state: {
|
|
14341
14388
|
...state,
|
|
14342
14389
|
cursor,
|
|
@@ -14346,10 +14393,10 @@ function processCursorLeft2(state) {
|
|
|
14346
14393
|
}
|
|
14347
14394
|
function processCursorRight2(state) {
|
|
14348
14395
|
if (state.cursor >= state.value.length) {
|
|
14349
|
-
return
|
|
14396
|
+
return succeed2$1(Action.Beep());
|
|
14350
14397
|
}
|
|
14351
14398
|
const cursor = Math.min(state.cursor + 1, state.value.length);
|
|
14352
|
-
return
|
|
14399
|
+
return succeed2$1(Action.NextFrame({
|
|
14353
14400
|
state: {
|
|
14354
14401
|
...state,
|
|
14355
14402
|
cursor,
|
|
@@ -14359,11 +14406,11 @@ function processCursorRight2(state) {
|
|
|
14359
14406
|
}
|
|
14360
14407
|
function processTab(state, options3) {
|
|
14361
14408
|
if (state.value === options3.default) {
|
|
14362
|
-
return
|
|
14409
|
+
return succeed2$1(Action.Beep());
|
|
14363
14410
|
}
|
|
14364
14411
|
const value2 = getValue(state, options3);
|
|
14365
14412
|
const cursor = value2.length;
|
|
14366
|
-
return
|
|
14413
|
+
return succeed2$1(Action.NextFrame({
|
|
14367
14414
|
state: {
|
|
14368
14415
|
...state,
|
|
14369
14416
|
value: value2,
|
|
@@ -14377,7 +14424,7 @@ function defaultProcessor2(input, state) {
|
|
|
14377
14424
|
const afterCursor = state.value.slice(state.cursor);
|
|
14378
14425
|
const value2 = `${beforeCursor}${input}${afterCursor}`;
|
|
14379
14426
|
const cursor = state.cursor + input.length;
|
|
14380
|
-
return
|
|
14427
|
+
return succeed2$1(Action.NextFrame({
|
|
14381
14428
|
state: {
|
|
14382
14429
|
...state,
|
|
14383
14430
|
cursor,
|
|
@@ -14394,7 +14441,7 @@ var initialState2 = {
|
|
|
14394
14441
|
function handleRender4(options3) {
|
|
14395
14442
|
return (state, action) => {
|
|
14396
14443
|
return Action.$match(action, {
|
|
14397
|
-
Beep: () =>
|
|
14444
|
+
Beep: () => succeed2$1(renderBeep5),
|
|
14398
14445
|
NextFrame: ({
|
|
14399
14446
|
state: state2
|
|
14400
14447
|
}) => renderNextFrame5(state2, options3),
|
|
@@ -14449,7 +14496,7 @@ function basePrompt(options3, type) {
|
|
|
14449
14496
|
const opts = {
|
|
14450
14497
|
default: "",
|
|
14451
14498
|
type,
|
|
14452
|
-
validate:
|
|
14499
|
+
validate: succeed2$1,
|
|
14453
14500
|
...options3
|
|
14454
14501
|
};
|
|
14455
14502
|
return custom(initialState2, {
|
|
@@ -14530,17 +14577,17 @@ function renderSubmission6(value2, options3) {
|
|
|
14530
14577
|
}));
|
|
14531
14578
|
});
|
|
14532
14579
|
}
|
|
14533
|
-
var activate = /* @__PURE__ */
|
|
14580
|
+
var activate = /* @__PURE__ */ succeed2$1(/* @__PURE__ */ Action.NextFrame({
|
|
14534
14581
|
state: true
|
|
14535
14582
|
}));
|
|
14536
|
-
var deactivate = /* @__PURE__ */
|
|
14583
|
+
var deactivate = /* @__PURE__ */ succeed2$1(/* @__PURE__ */ Action.NextFrame({
|
|
14537
14584
|
state: false
|
|
14538
14585
|
}));
|
|
14539
14586
|
function handleRender5(options3) {
|
|
14540
14587
|
return (state, action) => {
|
|
14541
14588
|
switch (action._tag) {
|
|
14542
14589
|
case "Beep": {
|
|
14543
|
-
return
|
|
14590
|
+
return succeed2$1(renderBeep6);
|
|
14544
14591
|
}
|
|
14545
14592
|
case "NextFrame": {
|
|
14546
14593
|
return renderNextFrame6(state, options3);
|
|
@@ -14572,12 +14619,12 @@ function handleProcess5(input, state) {
|
|
|
14572
14619
|
}
|
|
14573
14620
|
case "enter":
|
|
14574
14621
|
case "return": {
|
|
14575
|
-
return
|
|
14622
|
+
return succeed2$1(Action.Submit({
|
|
14576
14623
|
value: state
|
|
14577
14624
|
}));
|
|
14578
14625
|
}
|
|
14579
14626
|
default: {
|
|
14580
|
-
return
|
|
14627
|
+
return succeed2$1(Action.Beep());
|
|
14581
14628
|
}
|
|
14582
14629
|
}
|
|
14583
14630
|
}
|
|
@@ -14785,7 +14832,7 @@ var validateInternal = (self, value2, config) => {
|
|
|
14785
14832
|
case "Bool": {
|
|
14786
14833
|
return map(value2, (str) => normalizeCase(config, str)).pipe(match({
|
|
14787
14834
|
onNone: () => orElseFail(self.defaultValue, () => `Missing default value for boolean parameter`),
|
|
14788
|
-
onSome: (value3) => isTrueValue(value3) ?
|
|
14835
|
+
onSome: (value3) => isTrueValue(value3) ? succeed2$1(true) : isFalseValue(value3) ? succeed2$1(false) : fail3(`Unable to recognize '${value3}' as a valid boolean`)
|
|
14789
14836
|
}));
|
|
14790
14837
|
}
|
|
14791
14838
|
case "Choice": {
|
|
@@ -14814,10 +14861,10 @@ var validateInternal = (self, value2, config) => {
|
|
|
14814
14861
|
});
|
|
14815
14862
|
}
|
|
14816
14863
|
case "Redacted": {
|
|
14817
|
-
return attempt(value2, getTypeNameInternal(self), decodeUnknown(String$)).pipe(
|
|
14864
|
+
return attempt(value2, getTypeNameInternal(self), decodeUnknown(String$)).pipe(map4$1((value3) => make7$1(value3)));
|
|
14818
14865
|
}
|
|
14819
14866
|
case "Secret": {
|
|
14820
|
-
return attempt(value2, getTypeNameInternal(self), decodeUnknown(String$)).pipe(
|
|
14867
|
+
return attempt(value2, getTypeNameInternal(self), decodeUnknown(String$)).pipe(map4$1((value3) => fromString(value3)));
|
|
14821
14868
|
}
|
|
14822
14869
|
case "Text": {
|
|
14823
14870
|
return attempt(value2, getTypeNameInternal(self), decodeUnknown(String$));
|
|
@@ -14827,22 +14874,22 @@ var validateInternal = (self, value2, config) => {
|
|
|
14827
14874
|
var attempt = (option, typeName, parse8) => orElseFail(option, () => `${typeName} options do not have a default value`).pipe(flatMap3((value2) => orElseFail(parse8(value2), () => `'${value2}' is not a ${typeName}`)));
|
|
14828
14875
|
var validatePathExistence = (path2, shouldPathExist, pathExists) => {
|
|
14829
14876
|
if (shouldPathExist === "no" && pathExists) {
|
|
14830
|
-
return
|
|
14877
|
+
return fail3(`Path '${path2}' must not exist`);
|
|
14831
14878
|
}
|
|
14832
14879
|
if (shouldPathExist === "yes" && !pathExists) {
|
|
14833
|
-
return
|
|
14880
|
+
return fail3(`Path '${path2}' must exist`);
|
|
14834
14881
|
}
|
|
14835
14882
|
return _void;
|
|
14836
14883
|
};
|
|
14837
14884
|
var validatePathType = (path2, pathType, fileSystem) => {
|
|
14838
14885
|
switch (pathType) {
|
|
14839
14886
|
case "file": {
|
|
14840
|
-
const checkIsFile = fileSystem.stat(path2).pipe(
|
|
14841
|
-
return
|
|
14887
|
+
const checkIsFile = fileSystem.stat(path2).pipe(map4$1((info) => info.type === "File"), orDie);
|
|
14888
|
+
return fail3(`Expected path '${path2}' to be a regular file`).pipe(unlessEffect(checkIsFile), asVoid);
|
|
14842
14889
|
}
|
|
14843
14890
|
case "directory": {
|
|
14844
|
-
const checkIsDirectory = fileSystem.stat(path2).pipe(
|
|
14845
|
-
return
|
|
14891
|
+
const checkIsDirectory = fileSystem.stat(path2).pipe(map4$1((info) => info.type === "Directory"), orDie);
|
|
14892
|
+
return fail3(`Expected path '${path2}' to be a directory`).pipe(unlessEffect(checkIsDirectory), asVoid);
|
|
14846
14893
|
}
|
|
14847
14894
|
case "either": {
|
|
14848
14895
|
return _void;
|
|
@@ -15121,7 +15168,7 @@ var render3 = (self, config) => {
|
|
|
15121
15168
|
onNone: () => empty6,
|
|
15122
15169
|
onSome: (s) => concat(space3, text4(s))
|
|
15123
15170
|
}) : empty6;
|
|
15124
|
-
const namesToShow = config.showAllNames ? self.names : self.names.length > 1 ? pipe(
|
|
15171
|
+
const namesToShow = config.showAllNames ? self.names : self.names.length > 1 ? pipe(filter2(self.names, (name) => name.startsWith("--")), head, map(of), getOrElse(() => self.names)) : self.names;
|
|
15125
15172
|
const nameInfo = text4(join$1(namesToShow, ", "));
|
|
15126
15173
|
return config.showAllNames && self.names.length > 1 ? of(spans([text4("("), nameInfo, typeInfo, text4(")")])) : of(concat(nameInfo, typeInfo));
|
|
15127
15174
|
}
|
|
@@ -15261,7 +15308,7 @@ var none3 = /* @__PURE__ */ (() => {
|
|
|
15261
15308
|
})();
|
|
15262
15309
|
var getHelp3 = (self) => getHelpInternal2(self);
|
|
15263
15310
|
var getUsage = (self) => getUsageInternal(self);
|
|
15264
|
-
var map9 = /* @__PURE__ */ dual(2, (self, f) => mapEffect(self, (a) =>
|
|
15311
|
+
var map9 = /* @__PURE__ */ dual(2, (self, f) => mapEffect(self, (a) => succeed2$1(f(a))));
|
|
15265
15312
|
var mapEffect = /* @__PURE__ */ dual(2, (self, f) => makeMap(self, f));
|
|
15266
15313
|
var validate2 = /* @__PURE__ */ dual(3, (self, args, config) => validateInternal2(self, args, config));
|
|
15267
15314
|
var wizard2 = /* @__PURE__ */ dual(2, (self, config) => wizardInternal2(self, config));
|
|
@@ -15409,7 +15456,7 @@ var makeBoth = (left2, right2) => {
|
|
|
15409
15456
|
var validateInternal2 = (self, args, config) => {
|
|
15410
15457
|
switch (self._tag) {
|
|
15411
15458
|
case "Empty": {
|
|
15412
|
-
return
|
|
15459
|
+
return succeed2$1([args, void 0]);
|
|
15413
15460
|
}
|
|
15414
15461
|
case "Single": {
|
|
15415
15462
|
return suspend(() => {
|
|
@@ -15417,15 +15464,15 @@ var validateInternal2 = (self, args, config) => {
|
|
|
15417
15464
|
onEmpty: () => {
|
|
15418
15465
|
const choices = getChoices(self.primitiveType);
|
|
15419
15466
|
if (isSome(self.pseudoName) && isSome(choices)) {
|
|
15420
|
-
return
|
|
15467
|
+
return fail3(missingValue(p(`Missing argument <${self.pseudoName.value}> with choices ${choices.value}`)));
|
|
15421
15468
|
}
|
|
15422
15469
|
if (isSome(self.pseudoName)) {
|
|
15423
|
-
return
|
|
15470
|
+
return fail3(missingValue(p(`Missing argument <${self.pseudoName.value}>`)));
|
|
15424
15471
|
}
|
|
15425
15472
|
if (isSome(choices)) {
|
|
15426
|
-
return
|
|
15473
|
+
return fail3(missingValue(p(`Missing argument ${getTypeName(self.primitiveType)} with choices ${choices.value}`)));
|
|
15427
15474
|
}
|
|
15428
|
-
return
|
|
15475
|
+
return fail3(missingValue(p(`Missing argument ${getTypeName(self.primitiveType)}`)));
|
|
15429
15476
|
},
|
|
15430
15477
|
onNonEmpty: (head2, tail) => validate(self.primitiveType, some(head2), config).pipe(mapBoth({
|
|
15431
15478
|
onFailure: (text9) => invalidArgument(p(text9)),
|
|
@@ -15436,38 +15483,38 @@ var validateInternal2 = (self, args, config) => {
|
|
|
15436
15483
|
}
|
|
15437
15484
|
case "Map": {
|
|
15438
15485
|
return validateInternal2(self.args, args, config).pipe(flatMap3(([leftover, a]) => matchEffect(self.f(a), {
|
|
15439
|
-
onFailure: (doc) =>
|
|
15440
|
-
onSuccess: (b) =>
|
|
15486
|
+
onFailure: (doc) => fail3(invalidArgument(doc)),
|
|
15487
|
+
onSuccess: (b) => succeed2$1([leftover, b])
|
|
15441
15488
|
})));
|
|
15442
15489
|
}
|
|
15443
15490
|
case "Both": {
|
|
15444
|
-
return validateInternal2(self.left, args, config).pipe(flatMap3(([args2, a]) => validateInternal2(self.right, args2, config).pipe(
|
|
15491
|
+
return validateInternal2(self.left, args, config).pipe(flatMap3(([args2, a]) => validateInternal2(self.right, args2, config).pipe(map4$1(([args3, b]) => [args3, [a, b]]))));
|
|
15445
15492
|
}
|
|
15446
15493
|
case "Variadic": {
|
|
15447
15494
|
const min1 = getOrElse(self.min, () => 0);
|
|
15448
15495
|
const max1 = getOrElse(self.max, () => Number.MAX_SAFE_INTEGER);
|
|
15449
15496
|
const loop = (args2, acc) => {
|
|
15450
15497
|
if (acc.length >= max1) {
|
|
15451
|
-
return
|
|
15498
|
+
return succeed2$1([args2, acc]);
|
|
15452
15499
|
}
|
|
15453
15500
|
return validateInternal2(self.args, args2, config).pipe(matchEffect({
|
|
15454
|
-
onFailure: (failure) => acc.length >= min1 && isEmptyReadonlyArray(args2) ?
|
|
15501
|
+
onFailure: (failure) => acc.length >= min1 && isEmptyReadonlyArray(args2) ? succeed2$1([args2, acc]) : fail3(failure),
|
|
15455
15502
|
onSuccess: ([args3, a]) => loop(args3, append(acc, a))
|
|
15456
15503
|
}));
|
|
15457
15504
|
};
|
|
15458
|
-
return loop(args, empty()).pipe(
|
|
15505
|
+
return loop(args, empty()).pipe(map4$1(([args2, acc]) => [args2, acc]));
|
|
15459
15506
|
}
|
|
15460
15507
|
case "WithDefault": {
|
|
15461
|
-
return validateInternal2(self.args, args, config).pipe(catchTag("MissingValue", () =>
|
|
15508
|
+
return validateInternal2(self.args, args, config).pipe(catchTag("MissingValue", () => succeed2$1([args, self.fallback])));
|
|
15462
15509
|
}
|
|
15463
15510
|
case "WithFallbackConfig": {
|
|
15464
|
-
return validateInternal2(self.args, args, config).pipe(catchTag("MissingValue", (e) =>
|
|
15511
|
+
return validateInternal2(self.args, args, config).pipe(catchTag("MissingValue", (e) => map4$1(catchAll(self.config, (e2) => {
|
|
15465
15512
|
if (isMissingDataOnly(e2)) {
|
|
15466
15513
|
const help = p(String(e2));
|
|
15467
15514
|
const error3 = invalidValue(help);
|
|
15468
|
-
return
|
|
15515
|
+
return fail3(error3);
|
|
15469
15516
|
}
|
|
15470
|
-
return
|
|
15517
|
+
return fail3(e);
|
|
15471
15518
|
}), (value2) => [args, value2])));
|
|
15472
15519
|
}
|
|
15473
15520
|
}
|
|
@@ -15475,7 +15522,7 @@ var validateInternal2 = (self, args, config) => {
|
|
|
15475
15522
|
var wizardInternal2 = (self, config) => {
|
|
15476
15523
|
switch (self._tag) {
|
|
15477
15524
|
case "Empty": {
|
|
15478
|
-
return
|
|
15525
|
+
return succeed2$1(empty());
|
|
15479
15526
|
}
|
|
15480
15527
|
case "Single": {
|
|
15481
15528
|
const help = getHelpInternal2(self);
|
|
@@ -15497,7 +15544,7 @@ var wizardInternal2 = (self, config) => {
|
|
|
15497
15544
|
message: toAnsiText(message).trimEnd(),
|
|
15498
15545
|
min: getMinSizeInternal(self),
|
|
15499
15546
|
max: getMaxSizeInternal(self)
|
|
15500
|
-
}).pipe(zipLeft(log()), flatMap3((n) => n <= 0 ?
|
|
15547
|
+
}).pipe(zipLeft(log()), flatMap3((n) => n <= 0 ? succeed2$1(empty()) : make4(empty()).pipe(flatMap3((ref) => wizardInternal2(self.args, config).pipe(flatMap3((args) => update(ref, appendAll(args))), repeatN(n - 1), zipRight(get2(ref)), tap((args) => validateInternal2(self, args, config)))))));
|
|
15501
15548
|
}
|
|
15502
15549
|
case "WithDefault": {
|
|
15503
15550
|
const defaultHelp = p(`This argument is optional - use the default?`);
|
|
@@ -15511,7 +15558,7 @@ var wizardInternal2 = (self, config) => {
|
|
|
15511
15558
|
title: "Custom",
|
|
15512
15559
|
value: false
|
|
15513
15560
|
}]
|
|
15514
|
-
}).pipe(zipLeft(log()), flatMap3((useFallback) => useFallback ?
|
|
15561
|
+
}).pipe(zipLeft(log()), flatMap3((useFallback) => useFallback ? succeed2$1(empty()) : wizardInternal2(self.args, config)));
|
|
15515
15562
|
}
|
|
15516
15563
|
case "WithFallbackConfig": {
|
|
15517
15564
|
const defaultHelp = p(`Try load this option from the environment?`);
|
|
@@ -15525,7 +15572,7 @@ var wizardInternal2 = (self, config) => {
|
|
|
15525
15572
|
title: "Custom",
|
|
15526
15573
|
value: false
|
|
15527
15574
|
}]
|
|
15528
|
-
}).pipe(zipLeft(log()), flatMap3((useFallback) => useFallback ?
|
|
15575
|
+
}).pipe(zipLeft(log()), flatMap3((useFallback) => useFallback ? succeed2$1(empty()) : wizardInternal2(self.args, config)));
|
|
15529
15576
|
}
|
|
15530
15577
|
}
|
|
15531
15578
|
};
|
|
@@ -15768,9 +15815,9 @@ var orElse4 = /* @__PURE__ */ dual(2, (self, that) => orElseEither(self, that).p
|
|
|
15768
15815
|
var orElseEither = /* @__PURE__ */ dual(2, (self, that) => makeOrElse(self, that));
|
|
15769
15816
|
var parse5 = /* @__PURE__ */ dual(3, (self, args, config) => parseInternal(self, args, config));
|
|
15770
15817
|
var processCommandLine = /* @__PURE__ */ dual(3, (self, args, config) => matchOptions(args, toParseableInstruction(self), config).pipe(flatMap3(([error3, commandArgs, matchedOptions]) => parseInternal(self, matchedOptions, config).pipe(catchAll((e) => match(error3, {
|
|
15771
|
-
onNone: () =>
|
|
15772
|
-
onSome: (err) =>
|
|
15773
|
-
})),
|
|
15818
|
+
onNone: () => fail3(e),
|
|
15819
|
+
onSome: (err) => fail3(err)
|
|
15820
|
+
})), map4$1((a) => [error3, commandArgs, a])))));
|
|
15774
15821
|
var repeated2 = (self) => makeVariadic(self, none(), none());
|
|
15775
15822
|
var withAlias = /* @__PURE__ */ dual(2, (self, alias) => modifySingle(self, (single) => {
|
|
15776
15823
|
const aliases = append(single.aliases, alias);
|
|
@@ -16170,26 +16217,26 @@ var parseInternal = (self, args, config) => {
|
|
|
16170
16217
|
const value2 = headNonEmpty(head2);
|
|
16171
16218
|
return validate(self.primitiveType, some(value2), config).pipe(mapError((e) => invalidValue(p(e))));
|
|
16172
16219
|
}
|
|
16173
|
-
return
|
|
16220
|
+
return fail3(multipleValuesDetected(empty7, head2));
|
|
16174
16221
|
}
|
|
16175
16222
|
const error4 = p(`More than one reference to option '${self.fullName}' detected`);
|
|
16176
|
-
return
|
|
16223
|
+
return fail3(invalidValue(error4));
|
|
16177
16224
|
}
|
|
16178
16225
|
const error3 = p(`Expected to find option: '${self.fullName}'`);
|
|
16179
|
-
return
|
|
16226
|
+
return fail3(missingValue(error3));
|
|
16180
16227
|
}
|
|
16181
16228
|
case "KeyValueMap": {
|
|
16182
16229
|
const extractKeyValue = (value2) => {
|
|
16183
16230
|
const split = value2.trim().split(keyValueSplitter, 2);
|
|
16184
16231
|
if (isNonEmptyReadonlyArray(split) && split.length === 2 && split[1] !== "") {
|
|
16185
|
-
return
|
|
16232
|
+
return succeed2$1(split);
|
|
16186
16233
|
}
|
|
16187
16234
|
const error3 = p(`Expected a key/value pair but received '${value2}'`);
|
|
16188
|
-
return
|
|
16235
|
+
return fail3(invalidArgument(error3));
|
|
16189
16236
|
};
|
|
16190
16237
|
return parseInternal(self.argumentOption, args, config).pipe(matchEffect({
|
|
16191
|
-
onFailure: (e) => isMultipleValuesDetected(e) ? forEach(e.values, (kv) => extractKeyValue(kv)).pipe(
|
|
16192
|
-
onSuccess: (kv) => extractKeyValue(kv).pipe(
|
|
16238
|
+
onFailure: (e) => isMultipleValuesDetected(e) ? forEach(e.values, (kv) => extractKeyValue(kv)).pipe(map4$1(fromIterable3)) : fail3(e),
|
|
16239
|
+
onSuccess: (kv) => extractKeyValue(kv).pipe(map4$1(make3))
|
|
16193
16240
|
}));
|
|
16194
16241
|
}
|
|
16195
16242
|
case "Map": {
|
|
@@ -16199,9 +16246,9 @@ var parseInternal = (self, args, config) => {
|
|
|
16199
16246
|
return parseInternal(self.left, args, config).pipe(catchAll((err1) => parseInternal(self.right, args, config).pipe(matchEffect({
|
|
16200
16247
|
onFailure: (err2) => {
|
|
16201
16248
|
const error3 = sequence(err1.error, err2.error);
|
|
16202
|
-
return
|
|
16249
|
+
return fail3(missingValue(error3));
|
|
16203
16250
|
},
|
|
16204
|
-
onSuccess: () =>
|
|
16251
|
+
onSuccess: () => fail3(err1)
|
|
16205
16252
|
}))), zip(parseInternal(self.right, args, config)));
|
|
16206
16253
|
}
|
|
16207
16254
|
case "OrElse": {
|
|
@@ -16214,12 +16261,12 @@ var parseInternal = (self, args, config) => {
|
|
|
16214
16261
|
onSuccess: (b) => right(b)
|
|
16215
16262
|
})),
|
|
16216
16263
|
onSuccess: (a) => parseInternal(self.right, args, config).pipe(matchEffect({
|
|
16217
|
-
onFailure: () =>
|
|
16264
|
+
onFailure: () => succeed2$1(left(a)),
|
|
16218
16265
|
onSuccess: () => {
|
|
16219
16266
|
const leftUid = getOrElse(getIdentifierInternal(self.left), () => "???");
|
|
16220
16267
|
const rightUid = getOrElse(getIdentifierInternal(self.right), () => "???");
|
|
16221
16268
|
const error3 = p(`Collision between two options detected - you can only specify one of either: ['${leftUid}', '${rightUid}']`);
|
|
16222
|
-
return
|
|
16269
|
+
return fail3(invalidValue(error3));
|
|
16223
16270
|
}
|
|
16224
16271
|
}))
|
|
16225
16272
|
}));
|
|
@@ -16232,12 +16279,12 @@ var parseInternal = (self, args, config) => {
|
|
|
16232
16279
|
if (values.length < min2) {
|
|
16233
16280
|
const name = self.argumentOption.fullName;
|
|
16234
16281
|
const error3 = `Expected at least ${min2} value(s) for option: '${name}'`;
|
|
16235
|
-
return
|
|
16282
|
+
return fail3(invalidValue(p(error3)));
|
|
16236
16283
|
}
|
|
16237
16284
|
if (values.length > max2) {
|
|
16238
16285
|
const name = self.argumentOption.fullName;
|
|
16239
16286
|
const error3 = `Expected at most ${max2} value(s) for option: '${name}'`;
|
|
16240
|
-
return
|
|
16287
|
+
return fail3(invalidValue(p(error3)));
|
|
16241
16288
|
}
|
|
16242
16289
|
const primitive = self.argumentOption.primitiveType;
|
|
16243
16290
|
const validatePrimitive = (value2) => validate(primitive, some(value2), config).pipe(mapError((e) => invalidValue(p(e))));
|
|
@@ -16247,12 +16294,12 @@ var parseInternal = (self, args, config) => {
|
|
|
16247
16294
|
return validateMinMax(empty());
|
|
16248
16295
|
}
|
|
16249
16296
|
return parseInternal(self.argumentOption, args, config).pipe(matchEffect({
|
|
16250
|
-
onFailure: (error3) => isMultipleValuesDetected(error3) ? validateMinMax(error3.values) :
|
|
16297
|
+
onFailure: (error3) => isMultipleValuesDetected(error3) ? validateMinMax(error3.values) : fail3(error3),
|
|
16251
16298
|
onSuccess: (value2) => validateMinMax(of(value2))
|
|
16252
16299
|
}));
|
|
16253
16300
|
}
|
|
16254
16301
|
case "WithDefault": {
|
|
16255
|
-
return parseInternal(self.options, args, config).pipe(catchTag("MissingValue", () =>
|
|
16302
|
+
return parseInternal(self.options, args, config).pipe(catchTag("MissingValue", () => succeed2$1(self.fallback)));
|
|
16256
16303
|
}
|
|
16257
16304
|
case "WithFallback": {
|
|
16258
16305
|
return parseInternal(self.options, args, config).pipe(catchTag("MissingValue", (e) => self.effect.pipe(catchAll((e2) => {
|
|
@@ -16262,9 +16309,9 @@ var parseInternal = (self, args, config) => {
|
|
|
16262
16309
|
if (isConfigError(e2) && !isMissingDataOnly(e2)) {
|
|
16263
16310
|
const help = p(String(e2));
|
|
16264
16311
|
const error3 = invalidValue(help);
|
|
16265
|
-
return
|
|
16312
|
+
return fail3(error3);
|
|
16266
16313
|
}
|
|
16267
|
-
return
|
|
16314
|
+
return fail3(e);
|
|
16268
16315
|
}))));
|
|
16269
16316
|
}
|
|
16270
16317
|
}
|
|
@@ -16272,7 +16319,7 @@ var parseInternal = (self, args, config) => {
|
|
|
16272
16319
|
var wizardInternal3 = (self, config) => {
|
|
16273
16320
|
switch (self._tag) {
|
|
16274
16321
|
case "Empty": {
|
|
16275
|
-
return
|
|
16322
|
+
return succeed2$1(empty());
|
|
16276
16323
|
}
|
|
16277
16324
|
case "Single": {
|
|
16278
16325
|
const help = getHelpInternal3(self);
|
|
@@ -16317,7 +16364,7 @@ var wizardInternal3 = (self, config) => {
|
|
|
16317
16364
|
message: toAnsiText(message).trimEnd(),
|
|
16318
16365
|
min: getMinSizeInternal2(self),
|
|
16319
16366
|
max: getMaxSizeInternal2(self)
|
|
16320
|
-
}).pipe(flatMap3((n) => n <= 0 ?
|
|
16367
|
+
}).pipe(flatMap3((n) => n <= 0 ? succeed2$1(empty()) : make4(empty()).pipe(flatMap3((ref) => wizardInternal3(self.argumentOption, config).pipe(flatMap3((args) => update(ref, appendAll(args))), repeatN(n - 1), zipRight(get2(ref)))))));
|
|
16321
16368
|
}
|
|
16322
16369
|
case "WithDefault": {
|
|
16323
16370
|
if (isBoolInternal(self.options)) {
|
|
@@ -16339,7 +16386,7 @@ var wizardInternal3 = (self, config) => {
|
|
|
16339
16386
|
value: false,
|
|
16340
16387
|
description: "use a custom value"
|
|
16341
16388
|
}]
|
|
16342
|
-
}).pipe(zipLeft(log()), flatMap3((useFallback) => useFallback ?
|
|
16389
|
+
}).pipe(zipLeft(log()), flatMap3((useFallback) => useFallback ? succeed2$1(empty()) : wizardInternal3(self.options, config)));
|
|
16343
16390
|
}
|
|
16344
16391
|
case "WithFallback": {
|
|
16345
16392
|
if (isBoolInternal(self.options)) {
|
|
@@ -16359,7 +16406,7 @@ var wizardInternal3 = (self, config) => {
|
|
|
16359
16406
|
title: "Custom",
|
|
16360
16407
|
value: false
|
|
16361
16408
|
}]
|
|
16362
|
-
}).pipe(zipLeft(log()), flatMap3((useFallback) => useFallback ?
|
|
16409
|
+
}).pipe(zipLeft(log()), flatMap3((useFallback) => useFallback ? succeed2$1(empty()) : wizardInternal3(self.options, config)));
|
|
16363
16410
|
}
|
|
16364
16411
|
}
|
|
16365
16412
|
};
|
|
@@ -16367,47 +16414,47 @@ var matchOptions = (input, options3, config) => {
|
|
|
16367
16414
|
if (isNonEmptyReadonlyArray(options3)) {
|
|
16368
16415
|
return findOptions(input, options3, config).pipe(flatMap3(([otherArgs, otherOptions, map1]) => {
|
|
16369
16416
|
if (isEmpty(map1)) {
|
|
16370
|
-
return
|
|
16417
|
+
return succeed2$1([none(), input, map1]);
|
|
16371
16418
|
}
|
|
16372
|
-
return matchOptions(otherArgs, otherOptions, config).pipe(
|
|
16373
|
-
}), catchAll((e) =>
|
|
16419
|
+
return matchOptions(otherArgs, otherOptions, config).pipe(map4$1(([error3, otherArgs2, map22]) => [error3, otherArgs2, merge2(map1, fromIterable(map22))]));
|
|
16420
|
+
}), catchAll((e) => succeed2$1([some(e), input, empty2()])));
|
|
16374
16421
|
}
|
|
16375
|
-
return isEmptyReadonlyArray(input) ?
|
|
16422
|
+
return isEmptyReadonlyArray(input) ? succeed2$1([none(), empty(), empty2()]) : succeed2$1([none(), input, empty2()]);
|
|
16376
16423
|
};
|
|
16377
16424
|
var findOptions = (input, options3, config) => matchLeft(options3, {
|
|
16378
|
-
onEmpty: () =>
|
|
16425
|
+
onEmpty: () => succeed2$1([input, empty(), empty2()]),
|
|
16379
16426
|
onNonEmpty: (head2, tail) => parseCommandLine(head2, input, config).pipe(flatMap3(({
|
|
16380
16427
|
leftover,
|
|
16381
16428
|
parsed
|
|
16382
16429
|
}) => match(parsed, {
|
|
16383
|
-
onNone: () => findOptions(leftover, tail, config).pipe(
|
|
16430
|
+
onNone: () => findOptions(leftover, tail, config).pipe(map4$1(([nextArgs, nextOptions, map13]) => [nextArgs, prepend(nextOptions, head2), map13])),
|
|
16384
16431
|
onSome: ({
|
|
16385
16432
|
name,
|
|
16386
16433
|
values
|
|
16387
|
-
}) =>
|
|
16434
|
+
}) => succeed2$1([leftover, tail, make3([name, values])])
|
|
16388
16435
|
})), catchTags({
|
|
16389
|
-
CorrectedFlag: (e) => findOptions(input, tail, config).pipe(catchSome(() => some(
|
|
16390
|
-
MissingFlag: () => findOptions(input, tail, config).pipe(
|
|
16391
|
-
UnclusteredFlag: (e) => matchUnclustered(e.unclustered, e.rest, options3, config).pipe(catchAll(() =>
|
|
16436
|
+
CorrectedFlag: (e) => findOptions(input, tail, config).pipe(catchSome(() => some(fail3(e))), flatMap3(([otherArgs, otherOptions, map13]) => fail3(e).pipe(when(() => isEmpty(map13)), as([otherArgs, prepend(otherOptions, head2), map13])))),
|
|
16437
|
+
MissingFlag: () => findOptions(input, tail, config).pipe(map4$1(([otherArgs, otherOptions, map13]) => [otherArgs, prepend(otherOptions, head2), map13])),
|
|
16438
|
+
UnclusteredFlag: (e) => matchUnclustered(e.unclustered, e.rest, options3, config).pipe(catchAll(() => fail3(e)))
|
|
16392
16439
|
}))
|
|
16393
16440
|
});
|
|
16394
16441
|
var CLUSTERED_REGEX = /^-{1}([^-]{2,}$)/;
|
|
16395
16442
|
var FLAG_REGEX = /^(--[^=]+)(?:=(.+))?$/;
|
|
16396
16443
|
var processArgs = (args) => matchLeft(args, {
|
|
16397
|
-
onEmpty: () =>
|
|
16444
|
+
onEmpty: () => succeed2$1(empty()),
|
|
16398
16445
|
onNonEmpty: (head2, tail) => {
|
|
16399
16446
|
const value2 = head2.trim();
|
|
16400
16447
|
if (CLUSTERED_REGEX.test(value2)) {
|
|
16401
16448
|
const unclustered = value2.substring(1).split("").map((c) => `-${c}`);
|
|
16402
|
-
return
|
|
16449
|
+
return fail3(unclusteredFlag(empty7, unclustered, tail));
|
|
16403
16450
|
}
|
|
16404
16451
|
if (FLAG_REGEX.test(value2)) {
|
|
16405
16452
|
const result = FLAG_REGEX.exec(value2);
|
|
16406
16453
|
if (result !== null && result[2] !== void 0) {
|
|
16407
|
-
return
|
|
16454
|
+
return succeed2$1(appendAll([result[1], result[2]], tail));
|
|
16408
16455
|
}
|
|
16409
16456
|
}
|
|
16410
|
-
return
|
|
16457
|
+
return succeed2$1(args);
|
|
16411
16458
|
}
|
|
16412
16459
|
});
|
|
16413
16460
|
var parseCommandLine = (self, args, config) => {
|
|
@@ -16416,7 +16463,7 @@ var parseCommandLine = (self, args, config) => {
|
|
|
16416
16463
|
return processArgs(args).pipe(flatMap3((args2) => matchLeft(args2, {
|
|
16417
16464
|
onEmpty: () => {
|
|
16418
16465
|
const error3 = p(`Expected to find option: '${self.fullName}'`);
|
|
16419
|
-
return
|
|
16466
|
+
return fail3(missingFlag(error3));
|
|
16420
16467
|
},
|
|
16421
16468
|
onNonEmpty: (head2, tail) => {
|
|
16422
16469
|
const normalize = (value2) => normalizeCase(config, value2);
|
|
@@ -16430,7 +16477,7 @@ var parseCommandLine = (self, args, config) => {
|
|
|
16430
16477
|
name: head2,
|
|
16431
16478
|
values: empty()
|
|
16432
16479
|
});
|
|
16433
|
-
return
|
|
16480
|
+
return succeed2$1({
|
|
16434
16481
|
parsed: parsed2,
|
|
16435
16482
|
leftover: tail
|
|
16436
16483
|
});
|
|
@@ -16441,7 +16488,7 @@ var parseCommandLine = (self, args, config) => {
|
|
|
16441
16488
|
name: head2,
|
|
16442
16489
|
values: of("true")
|
|
16443
16490
|
});
|
|
16444
|
-
return
|
|
16491
|
+
return succeed2$1({
|
|
16445
16492
|
parsed: parsed3,
|
|
16446
16493
|
leftover: leftover2
|
|
16447
16494
|
});
|
|
@@ -16451,7 +16498,7 @@ var parseCommandLine = (self, args, config) => {
|
|
|
16451
16498
|
name: head2,
|
|
16452
16499
|
values: of("false")
|
|
16453
16500
|
});
|
|
16454
|
-
return
|
|
16501
|
+
return succeed2$1({
|
|
16455
16502
|
parsed: parsed3,
|
|
16456
16503
|
leftover: leftover2
|
|
16457
16504
|
});
|
|
@@ -16460,7 +16507,7 @@ var parseCommandLine = (self, args, config) => {
|
|
|
16460
16507
|
name: head2,
|
|
16461
16508
|
values: empty()
|
|
16462
16509
|
});
|
|
16463
|
-
return
|
|
16510
|
+
return succeed2$1({
|
|
16464
16511
|
parsed: parsed2,
|
|
16465
16512
|
leftover: tail
|
|
16466
16513
|
});
|
|
@@ -16470,14 +16517,14 @@ var parseCommandLine = (self, args, config) => {
|
|
|
16470
16517
|
return matchLeft(tail, {
|
|
16471
16518
|
onEmpty: () => {
|
|
16472
16519
|
const error3 = p(`Expected a value following option: '${self.fullName}'`);
|
|
16473
|
-
return
|
|
16520
|
+
return fail3(missingValue(error3));
|
|
16474
16521
|
},
|
|
16475
16522
|
onNonEmpty: (value2, leftover2) => {
|
|
16476
16523
|
const parsed2 = some({
|
|
16477
16524
|
name: head2,
|
|
16478
16525
|
values: of(value2)
|
|
16479
16526
|
});
|
|
16480
|
-
return
|
|
16527
|
+
return succeed2$1({
|
|
16481
16528
|
parsed: parsed2,
|
|
16482
16529
|
leftover: leftover2
|
|
16483
16530
|
});
|
|
@@ -16487,10 +16534,10 @@ var parseCommandLine = (self, args, config) => {
|
|
|
16487
16534
|
if (head2.startsWith("-")) {
|
|
16488
16535
|
if (self.name.length > config.autoCorrectLimit + 1 && levensteinDistance(head2, self.fullName, config) <= config.autoCorrectLimit) {
|
|
16489
16536
|
const error4 = p(`The flag '${head2}' is not recognized. Did you mean '${self.fullName}'?`);
|
|
16490
|
-
return
|
|
16537
|
+
return fail3(correctedFlag(error4));
|
|
16491
16538
|
}
|
|
16492
16539
|
const error3 = p(`Expected to find option: '${self.fullName}'`);
|
|
16493
|
-
return
|
|
16540
|
+
return fail3(missingFlag(error3));
|
|
16494
16541
|
}
|
|
16495
16542
|
let optionIndex = -1;
|
|
16496
16543
|
let equalsValue = void 0;
|
|
@@ -16513,7 +16560,7 @@ var parseCommandLine = (self, args, config) => {
|
|
|
16513
16560
|
}
|
|
16514
16561
|
if (optionIndex === -1) {
|
|
16515
16562
|
const error3 = p(`Expected to find option: '${self.fullName}'`);
|
|
16516
|
-
return
|
|
16563
|
+
return fail3(missingFlag(error3));
|
|
16517
16564
|
}
|
|
16518
16565
|
const rawArg = tail[optionIndex];
|
|
16519
16566
|
const optionName = equalsValue !== void 0 ? FLAG_REGEX.exec(rawArg)[1] : rawArg;
|
|
@@ -16527,7 +16574,7 @@ var parseCommandLine = (self, args, config) => {
|
|
|
16527
16574
|
values: of("true")
|
|
16528
16575
|
});
|
|
16529
16576
|
const leftover3 = appendAll(beforeOption, afterOption);
|
|
16530
|
-
return
|
|
16577
|
+
return succeed2$1({
|
|
16531
16578
|
parsed: parsed3,
|
|
16532
16579
|
leftover: leftover3
|
|
16533
16580
|
});
|
|
@@ -16538,7 +16585,7 @@ var parseCommandLine = (self, args, config) => {
|
|
|
16538
16585
|
values: of("false")
|
|
16539
16586
|
});
|
|
16540
16587
|
const leftover3 = appendAll(beforeOption, afterOption);
|
|
16541
|
-
return
|
|
16588
|
+
return succeed2$1({
|
|
16542
16589
|
parsed: parsed3,
|
|
16543
16590
|
leftover: leftover3
|
|
16544
16591
|
});
|
|
@@ -16552,7 +16599,7 @@ var parseCommandLine = (self, args, config) => {
|
|
|
16552
16599
|
values: of("true")
|
|
16553
16600
|
});
|
|
16554
16601
|
const leftover3 = appendAll(beforeOption, afterOption.slice(1));
|
|
16555
|
-
return
|
|
16602
|
+
return succeed2$1({
|
|
16556
16603
|
parsed: parsed3,
|
|
16557
16604
|
leftover: leftover3
|
|
16558
16605
|
});
|
|
@@ -16563,7 +16610,7 @@ var parseCommandLine = (self, args, config) => {
|
|
|
16563
16610
|
values: of("false")
|
|
16564
16611
|
});
|
|
16565
16612
|
const leftover3 = appendAll(beforeOption, afterOption.slice(1));
|
|
16566
|
-
return
|
|
16613
|
+
return succeed2$1({
|
|
16567
16614
|
parsed: parsed3,
|
|
16568
16615
|
leftover: leftover3
|
|
16569
16616
|
});
|
|
@@ -16574,7 +16621,7 @@ var parseCommandLine = (self, args, config) => {
|
|
|
16574
16621
|
values: empty()
|
|
16575
16622
|
});
|
|
16576
16623
|
const leftover2 = appendAll(beforeOption, afterOption);
|
|
16577
|
-
return
|
|
16624
|
+
return succeed2$1({
|
|
16578
16625
|
parsed: parsed2,
|
|
16579
16626
|
leftover: leftover2
|
|
16580
16627
|
});
|
|
@@ -16585,14 +16632,14 @@ var parseCommandLine = (self, args, config) => {
|
|
|
16585
16632
|
values: of(equalsValue)
|
|
16586
16633
|
});
|
|
16587
16634
|
const leftover2 = appendAll(beforeOption, afterOption);
|
|
16588
|
-
return
|
|
16635
|
+
return succeed2$1({
|
|
16589
16636
|
parsed: parsed2,
|
|
16590
16637
|
leftover: leftover2
|
|
16591
16638
|
});
|
|
16592
16639
|
}
|
|
16593
16640
|
if (afterOption.length === 0) {
|
|
16594
16641
|
const error3 = p(`Expected a value following option: '${self.fullName}'`);
|
|
16595
|
-
return
|
|
16642
|
+
return fail3(missingValue(error3));
|
|
16596
16643
|
}
|
|
16597
16644
|
const optionValue = afterOption[0];
|
|
16598
16645
|
const parsed = some({
|
|
@@ -16600,7 +16647,7 @@ var parseCommandLine = (self, args, config) => {
|
|
|
16600
16647
|
values: of(optionValue)
|
|
16601
16648
|
});
|
|
16602
16649
|
const leftover = appendAll(beforeOption, afterOption.slice(1));
|
|
16603
|
-
return
|
|
16650
|
+
return succeed2$1({
|
|
16604
16651
|
parsed,
|
|
16605
16652
|
leftover
|
|
16606
16653
|
});
|
|
@@ -16610,7 +16657,7 @@ var parseCommandLine = (self, args, config) => {
|
|
|
16610
16657
|
case "KeyValueMap": {
|
|
16611
16658
|
const normalizedNames = map2(getNames(self.argumentOption), (name) => normalizeCase(config, name));
|
|
16612
16659
|
return matchLeft(args, {
|
|
16613
|
-
onEmpty: () =>
|
|
16660
|
+
onEmpty: () => succeed2$1({
|
|
16614
16661
|
parsed: none(),
|
|
16615
16662
|
leftover: args
|
|
16616
16663
|
}),
|
|
@@ -16645,7 +16692,7 @@ var parseCommandLine = (self, args, config) => {
|
|
|
16645
16692
|
const normalizedName = normalizeCase(config, head2);
|
|
16646
16693
|
if (contains(normalizedNames, normalizedName)) {
|
|
16647
16694
|
const [values2, leftover2] = loop(tail);
|
|
16648
|
-
return
|
|
16695
|
+
return succeed2$1({
|
|
16649
16696
|
parsed: some({
|
|
16650
16697
|
name: head2,
|
|
16651
16698
|
values: values2
|
|
@@ -16654,7 +16701,7 @@ var parseCommandLine = (self, args, config) => {
|
|
|
16654
16701
|
});
|
|
16655
16702
|
}
|
|
16656
16703
|
if (head2.startsWith("-")) {
|
|
16657
|
-
return
|
|
16704
|
+
return succeed2$1({
|
|
16658
16705
|
parsed: none(),
|
|
16659
16706
|
leftover: args
|
|
16660
16707
|
});
|
|
@@ -16669,7 +16716,7 @@ var parseCommandLine = (self, args, config) => {
|
|
|
16669
16716
|
}
|
|
16670
16717
|
}
|
|
16671
16718
|
if (optionIndex === -1) {
|
|
16672
|
-
return
|
|
16719
|
+
return succeed2$1({
|
|
16673
16720
|
parsed: none(),
|
|
16674
16721
|
leftover: args
|
|
16675
16722
|
});
|
|
@@ -16679,7 +16726,7 @@ var parseCommandLine = (self, args, config) => {
|
|
|
16679
16726
|
const afterOption = tail.slice(optionIndex + 1);
|
|
16680
16727
|
const [values, remaining] = loop(afterOption);
|
|
16681
16728
|
const leftover = appendAll(beforeOption, remaining);
|
|
16682
|
-
return
|
|
16729
|
+
return succeed2$1({
|
|
16683
16730
|
parsed: some({
|
|
16684
16731
|
name: optionName,
|
|
16685
16732
|
values
|
|
@@ -16716,7 +16763,7 @@ var parseCommandLine = (self, args, config) => {
|
|
|
16716
16763
|
name,
|
|
16717
16764
|
values
|
|
16718
16765
|
})));
|
|
16719
|
-
return
|
|
16766
|
+
return succeed2$1({
|
|
16720
16767
|
parsed,
|
|
16721
16768
|
leftover
|
|
16722
16769
|
});
|
|
@@ -16729,12 +16776,12 @@ var matchUnclustered = (input, tail, options3, config) => {
|
|
|
16729
16776
|
const otherFlags = tailNonEmpty(input);
|
|
16730
16777
|
return findOptions(of(flag), options3, config).pipe(flatMap3(([_, opts1, map1]) => {
|
|
16731
16778
|
if (isEmpty(map1)) {
|
|
16732
|
-
return
|
|
16779
|
+
return fail3(unclusteredFlag(empty7, empty(), tail));
|
|
16733
16780
|
}
|
|
16734
|
-
return matchUnclustered(otherFlags, tail, opts1, config).pipe(
|
|
16781
|
+
return matchUnclustered(otherFlags, tail, opts1, config).pipe(map4$1(([_2, opts2, map22]) => [tail, opts2, merge2(map1, fromIterable(map22))]));
|
|
16735
16782
|
}));
|
|
16736
16783
|
}
|
|
16737
|
-
return
|
|
16784
|
+
return succeed2$1([tail, options3, empty2()]);
|
|
16738
16785
|
};
|
|
16739
16786
|
var merge2 = (map1, map22) => {
|
|
16740
16787
|
if (isNonEmptyReadonlyArray(map22)) {
|
|
@@ -17203,14 +17250,14 @@ var parseInternal2 = (self, args, config) => {
|
|
|
17203
17250
|
const parseCommandLine2 = (self2, args2) => matchLeft(args2, {
|
|
17204
17251
|
onEmpty: () => {
|
|
17205
17252
|
const error3 = p(`Missing command name: '${self2.name}'`);
|
|
17206
|
-
return
|
|
17253
|
+
return fail3(commandMismatch(error3));
|
|
17207
17254
|
},
|
|
17208
17255
|
onNonEmpty: (head2, tail) => {
|
|
17209
17256
|
const normalizedArgv0 = normalizeCase(config, head2);
|
|
17210
17257
|
const normalizedCommandName = normalizeCase(config, self2.name);
|
|
17211
|
-
return
|
|
17258
|
+
return succeed2$1(tail).pipe(when(() => normalizedArgv0 === normalizedCommandName), flatten, catchTag("NoSuchElementException", () => {
|
|
17212
17259
|
const error3 = p(`Missing command name: '${self2.name}'`);
|
|
17213
|
-
return
|
|
17260
|
+
return fail3(commandMismatch(error3));
|
|
17214
17261
|
}));
|
|
17215
17262
|
}
|
|
17216
17263
|
});
|
|
@@ -17219,7 +17266,7 @@ var parseInternal2 = (self, args, config) => {
|
|
|
17219
17266
|
const parseBuiltInArgs = (args2) => matchLeft(args2, {
|
|
17220
17267
|
onEmpty: () => {
|
|
17221
17268
|
const error3 = p(`Missing command name: '${self.name}'`);
|
|
17222
|
-
return
|
|
17269
|
+
return fail3(commandMismatch(error3));
|
|
17223
17270
|
},
|
|
17224
17271
|
onNonEmpty: (argv0) => {
|
|
17225
17272
|
const normalizedArgv0 = normalizeCase(config, argv0);
|
|
@@ -17231,19 +17278,19 @@ var parseInternal2 = (self, args, config) => {
|
|
|
17231
17278
|
const argsWithoutCommand = drop(args2, 1);
|
|
17232
17279
|
return processCommandLine(options3, argsWithoutCommand, config).pipe(flatMap3((tuple3) => tuple3[2]), catchTag("NoSuchElementException", () => {
|
|
17233
17280
|
const error4 = p("No built-in option was matched");
|
|
17234
|
-
return
|
|
17235
|
-
}),
|
|
17281
|
+
return fail3(noBuiltInMatch(error4));
|
|
17282
|
+
}), map4$1(builtIn));
|
|
17236
17283
|
}
|
|
17237
17284
|
const error3 = p(`Missing command name: '${self.name}'`);
|
|
17238
|
-
return
|
|
17285
|
+
return fail3(commandMismatch(error3));
|
|
17239
17286
|
}
|
|
17240
17287
|
});
|
|
17241
17288
|
const parseUserDefinedArgs = (args2) => parseCommandLine2(self, args2).pipe(flatMap3((commandOptionsAndArgs) => {
|
|
17242
17289
|
const [optionsAndArgs, forcedCommandArgs] = splitForcedArgs(commandOptionsAndArgs);
|
|
17243
17290
|
return processCommandLine(self.options, optionsAndArgs, config).pipe(flatMap3(([error3, commandArgs, optionsType]) => validate2(self.args, appendAll(commandArgs, forcedCommandArgs), config).pipe(catchAll((e) => match(error3, {
|
|
17244
|
-
onNone: () =>
|
|
17245
|
-
onSome: (err) =>
|
|
17246
|
-
})),
|
|
17291
|
+
onNone: () => fail3(e),
|
|
17292
|
+
onSome: (err) => fail3(err)
|
|
17293
|
+
})), map4$1(([argsLeftover, argsType]) => userDefined(argsLeftover, {
|
|
17247
17294
|
name: self.name,
|
|
17248
17295
|
options: optionsType,
|
|
17249
17296
|
args: argsType
|
|
@@ -17260,20 +17307,20 @@ var parseInternal2 = (self, args, config) => {
|
|
|
17260
17307
|
return parseBuiltInArgs(make(self.name, "--version"));
|
|
17261
17308
|
}
|
|
17262
17309
|
const error3 = p(`Missing command name: '${self.name}'`);
|
|
17263
|
-
return
|
|
17310
|
+
return fail3(commandMismatch(error3));
|
|
17264
17311
|
};
|
|
17265
17312
|
return parseBuiltInArgs(args).pipe(orElse2(() => parseUserDefinedArgs(args)), catchSome((e) => {
|
|
17266
17313
|
if (isValidationError(e)) {
|
|
17267
17314
|
if (config.finalCheckBuiltIn) {
|
|
17268
|
-
return some(exhaustiveSearch(args).pipe(catchSome((_) => isValidationError(_) ? some(
|
|
17315
|
+
return some(exhaustiveSearch(args).pipe(catchSome((_) => isValidationError(_) ? some(fail3(e)) : none())));
|
|
17269
17316
|
}
|
|
17270
|
-
return some(
|
|
17317
|
+
return some(fail3(e));
|
|
17271
17318
|
}
|
|
17272
17319
|
return none();
|
|
17273
17320
|
}));
|
|
17274
17321
|
}
|
|
17275
17322
|
case "GetUserInput": {
|
|
17276
|
-
return parseCommandLine2(self, args).pipe(zipRight(run(self.prompt)), catchTag("QuitException", (e) => die(e)),
|
|
17323
|
+
return parseCommandLine2(self, args).pipe(zipRight(run(self.prompt)), catchTag("QuitException", (e) => die(e)), map4$1((value2) => userDefined(drop(args, 1), {
|
|
17277
17324
|
name: self.name,
|
|
17278
17325
|
value: value2
|
|
17279
17326
|
})));
|
|
@@ -17281,9 +17328,9 @@ var parseInternal2 = (self, args, config) => {
|
|
|
17281
17328
|
case "Map": {
|
|
17282
17329
|
return parseInternal2(self.command, args, config).pipe(flatMap3((directive) => {
|
|
17283
17330
|
if (isUserDefined(directive)) {
|
|
17284
|
-
return self.f(directive.value).pipe(
|
|
17331
|
+
return self.f(directive.value).pipe(map4$1((value2) => userDefined(directive.leftover, value2)));
|
|
17285
17332
|
}
|
|
17286
|
-
return
|
|
17333
|
+
return succeed2$1(directive);
|
|
17287
17334
|
}));
|
|
17288
17335
|
}
|
|
17289
17336
|
case "Subcommands": {
|
|
@@ -17295,7 +17342,7 @@ var parseInternal2 = (self, args, config) => {
|
|
|
17295
17342
|
const loop = (next) => {
|
|
17296
17343
|
return parseInternal2(next, argsForChildren, config).pipe(catchIf(isCommandMismatch, (e) => {
|
|
17297
17344
|
const next2 = iterator.next();
|
|
17298
|
-
return next2.done ?
|
|
17345
|
+
return next2.done ? fail3(e) : loop(next2.value);
|
|
17299
17346
|
}));
|
|
17300
17347
|
};
|
|
17301
17348
|
return loop(iterator.next().value);
|
|
@@ -17308,16 +17355,16 @@ var parseInternal2 = (self, args, config) => {
|
|
|
17308
17355
|
if (isBuiltIn(directive) && isShowHelp(directive.option)) {
|
|
17309
17356
|
const parentName = getOrElse(head(names), () => "");
|
|
17310
17357
|
const newDirective = builtIn(showHelp(concat2(named(of(parentName), none()), directive.option.usage), directive.option.helpDoc));
|
|
17311
|
-
return
|
|
17358
|
+
return succeed2$1(newDirective);
|
|
17312
17359
|
}
|
|
17313
|
-
return
|
|
17360
|
+
return fail3(invalidArgument(empty7));
|
|
17314
17361
|
}));
|
|
17315
17362
|
const wizardDirectiveForParent = sync(() => builtIn(showWizard(self)));
|
|
17316
17363
|
const wizardDirectiveForChild = parseChildren.pipe(flatMap3((directive) => {
|
|
17317
17364
|
if (isBuiltIn(directive) && isShowWizard(directive.option)) {
|
|
17318
|
-
return
|
|
17365
|
+
return succeed2$1(directive);
|
|
17319
17366
|
}
|
|
17320
|
-
return
|
|
17367
|
+
return fail3(invalidArgument(empty7));
|
|
17321
17368
|
}));
|
|
17322
17369
|
return suspend(() => parseInternal2(self.parent, parentArgs, config).pipe(flatMap3((directive) => {
|
|
17323
17370
|
switch (directive._tag) {
|
|
@@ -17328,18 +17375,18 @@ var parseInternal2 = (self, args, config) => {
|
|
|
17328
17375
|
if (isShowWizard(directive.option)) {
|
|
17329
17376
|
return orElse2(wizardDirectiveForChild, () => wizardDirectiveForParent);
|
|
17330
17377
|
}
|
|
17331
|
-
return
|
|
17378
|
+
return succeed2$1(directive);
|
|
17332
17379
|
}
|
|
17333
17380
|
case "UserDefined": {
|
|
17334
17381
|
const args2 = appendAll(directive.leftover, childArgs);
|
|
17335
17382
|
if (isNonEmptyReadonlyArray(args2)) {
|
|
17336
17383
|
return parseChildrenWith(args2).pipe(flatMap3((childDirective) => {
|
|
17337
17384
|
if (!isUserDefined(childDirective)) {
|
|
17338
|
-
return
|
|
17385
|
+
return succeed2$1(childDirective);
|
|
17339
17386
|
}
|
|
17340
17387
|
const childLeftover = childDirective.leftover;
|
|
17341
17388
|
if (isEmptyReadonlyArray(childLeftover)) {
|
|
17342
|
-
return
|
|
17389
|
+
return succeed2$1(userDefined(childLeftover, {
|
|
17343
17390
|
...directive.value,
|
|
17344
17391
|
subcommand: some(childDirective.value)
|
|
17345
17392
|
}));
|
|
@@ -17347,16 +17394,16 @@ var parseInternal2 = (self, args, config) => {
|
|
|
17347
17394
|
const parentArgsWithLeftover = appendAll(parentArgs, childLeftover);
|
|
17348
17395
|
return parseInternal2(self.parent, parentArgsWithLeftover, config).pipe(flatMap3((reParsedParentDirective) => {
|
|
17349
17396
|
if (!isUserDefined(reParsedParentDirective)) {
|
|
17350
|
-
return
|
|
17397
|
+
return succeed2$1(userDefined(childLeftover, {
|
|
17351
17398
|
...directive.value,
|
|
17352
17399
|
subcommand: some(childDirective.value)
|
|
17353
17400
|
}));
|
|
17354
17401
|
}
|
|
17355
|
-
return
|
|
17402
|
+
return succeed2$1(userDefined(reParsedParentDirective.leftover, {
|
|
17356
17403
|
...reParsedParentDirective.value,
|
|
17357
17404
|
subcommand: some(childDirective.value)
|
|
17358
17405
|
}));
|
|
17359
|
-
}), catchAll(() =>
|
|
17406
|
+
}), catchAll(() => succeed2$1(userDefined(childLeftover, {
|
|
17360
17407
|
...directive.value,
|
|
17361
17408
|
subcommand: some(childDirective.value)
|
|
17362
17409
|
}))));
|
|
@@ -17366,12 +17413,12 @@ var parseInternal2 = (self, args, config) => {
|
|
|
17366
17413
|
const childNames = map2(subcommands, ([name]) => `'${name}'`);
|
|
17367
17414
|
const oneOf = childNames.length === 1 ? "" : " one of";
|
|
17368
17415
|
const error3 = p(`Invalid subcommand for ${parentName} - use${oneOf} ${join$1(childNames, ", ")}`);
|
|
17369
|
-
return
|
|
17416
|
+
return fail3(commandMismatch(error3));
|
|
17370
17417
|
}
|
|
17371
|
-
return
|
|
17418
|
+
return fail3(err);
|
|
17372
17419
|
}));
|
|
17373
17420
|
}
|
|
17374
|
-
return
|
|
17421
|
+
return succeed2$1(userDefined(directive.leftover, {
|
|
17375
17422
|
...directive.value,
|
|
17376
17423
|
subcommand: none()
|
|
17377
17424
|
}));
|
|
@@ -17540,8 +17587,8 @@ var getBashCompletionsInternal = (self, executable) => traverseCommand(self, emp
|
|
|
17540
17587
|
const funcLines = isEmptyReadonlyArray(info.parentCommands) ? empty() : [`${caseName})`, ` cmd="${funcName}"`, " ;;"];
|
|
17541
17588
|
const cmdLines = [`${funcName})`, ` opts="${join$1(wordList, " ")}"`, ` if [[ \${cur} == -* || \${COMP_CWORD} -eq ${info.level + 1} ]] ; then`, ' COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )', " return 0", " fi", ' case "${prev}" in', ...indentAll(optionCases, 8), " *)", " COMPREPLY=()", " ;;", " esac", ' COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )', " return 0", " ;;"];
|
|
17542
17589
|
const lines2 = append(state, [funcLines, cmdLines]);
|
|
17543
|
-
return
|
|
17544
|
-
}).pipe(
|
|
17590
|
+
return succeed2$1(lines2);
|
|
17591
|
+
}).pipe(map4$1((lines2) => {
|
|
17545
17592
|
const rootCommand2 = unsafeGet(getNamesInternal(self), 0);
|
|
17546
17593
|
const scriptName = `_${rootCommand2}_bash_completions`;
|
|
17547
17594
|
const funcCases = flatMap2(lines2, ([funcLines]) => funcLines);
|
|
@@ -17560,7 +17607,7 @@ var getFishCompletionsInternal = (self, executable) => traverseCommand(self, emp
|
|
|
17560
17607
|
});
|
|
17561
17608
|
if (isEmptyReadonlyArray(info.parentCommands)) {
|
|
17562
17609
|
const conditionals2 = make("-n", '"__fish_use_subcommand"');
|
|
17563
|
-
return
|
|
17610
|
+
return succeed2$1(pipe(state, appendAll(rootCompletions(conditionals2)), appendAll(subcommandCompletions(conditionals2))));
|
|
17564
17611
|
}
|
|
17565
17612
|
const parentConditionals = pipe(
|
|
17566
17613
|
info.parentCommands,
|
|
@@ -17572,7 +17619,7 @@ var getFishCompletionsInternal = (self, executable) => traverseCommand(self, emp
|
|
|
17572
17619
|
const subcommandConditionals = map2(info.subcommands, ([name]) => `not __fish_seen_subcommand_from ${name}`);
|
|
17573
17620
|
const baseConditionals = pipe(appendAll(parentConditionals, subcommandConditionals), join$1("; and "));
|
|
17574
17621
|
const conditionals = make("-n", `"${baseConditionals}"`);
|
|
17575
|
-
return
|
|
17622
|
+
return succeed2$1(pipe(state, appendAll(rootCompletions(conditionals)), appendAll(subcommandCompletions(conditionals))));
|
|
17576
17623
|
});
|
|
17577
17624
|
var getZshCompletionsInternal = (self, executable) => traverseCommand(self, empty(), (state, info) => {
|
|
17578
17625
|
const preformatted = isEmptyReadonlyArray(info.parentCommands) ? of(info.command.name) : pipe(info.parentCommands, append(info.command.name), map2((command) => command.replace("-", "__")));
|
|
@@ -17586,8 +17633,8 @@ var getZshCompletionsInternal = (self, executable) => traverseCommand(self, empt
|
|
|
17586
17633
|
${join$1(indentAll(subcommands, 8), "\n")}
|
|
17587
17634
|
)`;
|
|
17588
17635
|
const handlerLines = [`(( $+functions[_${underscoreName}_commands] )) ||`, `_${underscoreName}_commands() {`, ` local commands; ${commands}`, ` _describe -t commands '${spaceName} commands' commands "$@"`, "}"];
|
|
17589
|
-
return
|
|
17590
|
-
}).pipe(
|
|
17636
|
+
return succeed2$1(appendAll(state, handlerLines));
|
|
17637
|
+
}).pipe(map4$1((handlers) => {
|
|
17591
17638
|
const rootCommand2 = unsafeGet(getNamesInternal(self), 0);
|
|
17592
17639
|
const cases = getZshSubcommandCases(self, empty(), empty());
|
|
17593
17640
|
const scriptName = `_${rootCommand2}_zsh_completions`;
|
|
@@ -17652,7 +17699,7 @@ var run2 = /* @__PURE__ */ dual(3, (self, args, execute) => contextWithEffect((c
|
|
|
17652
17699
|
const [executable, filteredArgs] = splitExecutable(self, args);
|
|
17653
17700
|
const prefixedArgs = appendAll(prefixCommand(self.command), filteredArgs);
|
|
17654
17701
|
return matchEffect(parse7(self.command, prefixedArgs, config), {
|
|
17655
|
-
onFailure: (e) => zipRight(printDocs(e.error),
|
|
17702
|
+
onFailure: (e) => zipRight(printDocs(e.error), fail3(e)),
|
|
17656
17703
|
onSuccess: unify((directive) => {
|
|
17657
17704
|
switch (directive._tag) {
|
|
17658
17705
|
case "UserDefined": {
|
|
@@ -17660,12 +17707,12 @@ var run2 = /* @__PURE__ */ dual(3, (self, args, execute) => contextWithEffect((c
|
|
|
17660
17707
|
onEmpty: () => execute(directive.value).pipe(catchSome((e) => isValidationError(e) && isHelpRequested(e) ? some(handleBuiltInOption(self, executable, filteredArgs, showHelp(getUsage4(e.command), getHelp6(e.command, config)), execute, config, args)) : none())),
|
|
17661
17708
|
onNonEmpty: (head2) => {
|
|
17662
17709
|
const error3 = p(`Received unknown argument: '${head2}'`);
|
|
17663
|
-
return zipRight(printDocs(error3),
|
|
17710
|
+
return zipRight(printDocs(error3), fail3(invalidValue(error3)));
|
|
17664
17711
|
}
|
|
17665
17712
|
});
|
|
17666
17713
|
}
|
|
17667
17714
|
case "BuiltIn": {
|
|
17668
|
-
return handleBuiltInOption(self, executable, filteredArgs, directive.option, execute, config, args).pipe(catchSome((e) => isValidationError(e) ? some(zipRight(printDocs(e.error),
|
|
17715
|
+
return handleBuiltInOption(self, executable, filteredArgs, directive.option, execute, config, args).pipe(catchSome((e) => isValidationError(e) ? some(zipRight(printDocs(e.error), fail3(e))) : none()));
|
|
17669
17716
|
}
|
|
17670
17717
|
}
|
|
17671
17718
|
})
|
|
@@ -17737,7 +17784,7 @@ var handleBuiltInOption = (self, executable, args, builtIn2, execute, config, or
|
|
|
17737
17784
|
const message = p(error2("\n\nQuitting wizard mode..."));
|
|
17738
17785
|
return log(toAnsiText(message));
|
|
17739
17786
|
}
|
|
17740
|
-
return
|
|
17787
|
+
return fail3(e);
|
|
17741
17788
|
}));
|
|
17742
17789
|
}
|
|
17743
17790
|
case "ShowVersion": {
|
|
@@ -17775,15 +17822,15 @@ var prefixCommand = (self) => {
|
|
|
17775
17822
|
};
|
|
17776
17823
|
var getWizardPrefix = (builtIn2, rootCommand2, commandLineArgs) => {
|
|
17777
17824
|
const subcommands = getSubcommands(builtIn2.command);
|
|
17778
|
-
const [parentArgs, childArgs] = span(commandLineArgs, (name) => !
|
|
17825
|
+
const [parentArgs, childArgs] = span(commandLineArgs, (name) => !has2(subcommands, name));
|
|
17779
17826
|
const args = matchLeft(childArgs, {
|
|
17780
|
-
onEmpty: () =>
|
|
17827
|
+
onEmpty: () => filter2(parentArgs, (arg) => arg !== "--wizard"),
|
|
17781
17828
|
onNonEmpty: (head2) => append(parentArgs, head2)
|
|
17782
17829
|
});
|
|
17783
17830
|
return appendAll(rootCommand2.split(/\s+/), args);
|
|
17784
17831
|
};
|
|
17785
17832
|
var renderWizardArgs = (args) => {
|
|
17786
|
-
const params = pipe(
|
|
17833
|
+
const params = pipe(filter2(args, (param) => param.length > 0), join$1(" "));
|
|
17787
17834
|
const executeMsg = text4("You may now execute your command directly with the following options and arguments:");
|
|
17788
17835
|
return blocks([p(strong(code("Wizard Mode Complete!"))), p(executeMsg), p(concat(text4(" "), highlight(params, cyan3)))]);
|
|
17789
17836
|
};
|
|
@@ -18032,33 +18079,32 @@ var podmanExec = (args) => Effect_exports.async((resume) => {
|
|
|
18032
18079
|
resume(
|
|
18033
18080
|
Effect_exports.fail(
|
|
18034
18081
|
new PodmanError({
|
|
18035
|
-
message: `podman ${args[0]} failed: ${stderr
|
|
18082
|
+
message: `podman ${args[0]} failed: ${stderr || error3.message}`
|
|
18036
18083
|
})
|
|
18037
18084
|
)
|
|
18038
18085
|
);
|
|
18039
18086
|
} else {
|
|
18040
|
-
resume(Effect_exports.succeed(stdout
|
|
18087
|
+
resume(Effect_exports.succeed(stdout));
|
|
18041
18088
|
}
|
|
18042
18089
|
}
|
|
18043
18090
|
);
|
|
18044
18091
|
});
|
|
18045
18092
|
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]);
|
|
18093
|
+
const containerfile = options3?.containerfile;
|
|
18094
|
+
const buildContext = containerfile !== void 0 && containerfile !== "" ? ["-f", resolve(containerfile), process.cwd()] : [resolve(containerfileDir)];
|
|
18095
|
+
yield* podmanExec(["build", "-t", imageName, ...buildContext]);
|
|
18061
18096
|
});
|
|
18097
|
+
var removeImage2 = (imageName) => podmanExec(["rmi", imageName]).pipe(
|
|
18098
|
+
Effect_exports.asVoid,
|
|
18099
|
+
Effect_exports.catchTag(
|
|
18100
|
+
"PodmanError",
|
|
18101
|
+
(error3) => error3.message.includes("image not known") ? Effect_exports.fail(
|
|
18102
|
+
new ImageNotFoundError({
|
|
18103
|
+
message: `Podman image '${imageName}' does not exist, so there is nothing to remove.`
|
|
18104
|
+
})
|
|
18105
|
+
) : Effect_exports.fail(error3)
|
|
18106
|
+
)
|
|
18107
|
+
);
|
|
18062
18108
|
var GITIGNORE = `.env
|
|
18063
18109
|
logs/
|
|
18064
18110
|
worktrees/
|
|
@@ -18099,62 +18145,71 @@ var LOCKFILES = [
|
|
|
18099
18145
|
["yarn.lock", "yarn"],
|
|
18100
18146
|
["package-lock.json", "npm"]
|
|
18101
18147
|
];
|
|
18102
|
-
var
|
|
18148
|
+
var PackageJson = Schema_exports.parseJson(
|
|
18149
|
+
Schema_exports.Record({ key: Schema_exports.String, value: Schema_exports.Unknown })
|
|
18150
|
+
);
|
|
18151
|
+
var readHostPackageJson = (repoDir) => Effect_exports.gen(function* () {
|
|
18103
18152
|
const fs = yield* FileSystem_exports.FileSystem;
|
|
18104
18153
|
const pkgPath = join(repoDir, "package.json");
|
|
18105
|
-
const
|
|
18106
|
-
if (
|
|
18107
|
-
|
|
18108
|
-
|
|
18109
|
-
|
|
18110
|
-
|
|
18111
|
-
|
|
18112
|
-
|
|
18113
|
-
|
|
18114
|
-
|
|
18115
|
-
|
|
18116
|
-
|
|
18154
|
+
const exists = yield* fs.exists(pkgPath).pipe(Effect_exports.orElseSucceed(() => false));
|
|
18155
|
+
if (!exists) {
|
|
18156
|
+
return Option_exports.none();
|
|
18157
|
+
}
|
|
18158
|
+
const content = yield* fs.readFileString(pkgPath).pipe(Effect_exports.orElseSucceed(() => ""));
|
|
18159
|
+
return Schema_exports.decodeUnknownOption(PackageJson)(content);
|
|
18160
|
+
});
|
|
18161
|
+
var detectPackageManager = (repoDir) => Effect_exports.gen(function* () {
|
|
18162
|
+
const fs = yield* FileSystem_exports.FileSystem;
|
|
18163
|
+
const pkg = yield* readHostPackageJson(repoDir);
|
|
18164
|
+
const field = Option_exports.getOrUndefined(pkg)?.["packageManager"];
|
|
18165
|
+
if (typeof field === "string") {
|
|
18166
|
+
const [name] = field.split("@");
|
|
18167
|
+
const match6 = PACKAGE_MANAGERS.find((pm) => pm === name);
|
|
18168
|
+
if (match6) {
|
|
18169
|
+
return match6;
|
|
18117
18170
|
}
|
|
18118
18171
|
}
|
|
18119
18172
|
for (const [file4, pm] of LOCKFILES) {
|
|
18120
18173
|
const exists = yield* fs.exists(join(repoDir, file4)).pipe(Effect_exports.orElseSucceed(() => false));
|
|
18121
|
-
if (exists)
|
|
18174
|
+
if (exists) {
|
|
18175
|
+
return pm;
|
|
18176
|
+
}
|
|
18122
18177
|
}
|
|
18123
18178
|
return "npm";
|
|
18124
18179
|
});
|
|
18125
18180
|
var addDependencyCommand = (packageManager, pkg) => {
|
|
18126
18181
|
switch (packageManager) {
|
|
18127
|
-
case "pnpm":
|
|
18182
|
+
case "pnpm": {
|
|
18128
18183
|
return `pnpm add ${pkg}`;
|
|
18129
|
-
|
|
18184
|
+
}
|
|
18185
|
+
case "yarn": {
|
|
18130
18186
|
return `yarn add ${pkg}`;
|
|
18131
|
-
|
|
18187
|
+
}
|
|
18188
|
+
case "bun": {
|
|
18132
18189
|
return `bun add ${pkg}`;
|
|
18133
|
-
|
|
18190
|
+
}
|
|
18191
|
+
case "npm": {
|
|
18134
18192
|
return `npm install ${pkg}`;
|
|
18193
|
+
}
|
|
18135
18194
|
}
|
|
18136
18195
|
};
|
|
18196
|
+
var runScriptCommand = (packageManager, script) => `${packageManager} run ${script}`;
|
|
18197
|
+
var installCommand = (packageManager) => `${packageManager} install`;
|
|
18137
18198
|
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 {
|
|
18199
|
+
const parsed = yield* readHostPackageJson(repoDir);
|
|
18200
|
+
if (Option_exports.isNone(parsed)) {
|
|
18156
18201
|
return false;
|
|
18157
18202
|
}
|
|
18203
|
+
const depMaps = [
|
|
18204
|
+
"dependencies",
|
|
18205
|
+
"devDependencies",
|
|
18206
|
+
"peerDependencies",
|
|
18207
|
+
"optionalDependencies"
|
|
18208
|
+
];
|
|
18209
|
+
return depMaps.some((key) => {
|
|
18210
|
+
const deps = parsed.value[key];
|
|
18211
|
+
return typeof deps === "object" && deps !== null && pkg in deps;
|
|
18212
|
+
});
|
|
18158
18213
|
});
|
|
18159
18214
|
var CLAUDE_CODE_DOCKERFILE = `FROM node:22-bookworm
|
|
18160
18215
|
|
|
@@ -18315,9 +18370,9 @@ USER \${AGENT_UID}:\${AGENT_GID}
|
|
|
18315
18370
|
|
|
18316
18371
|
WORKDIR /home/agent
|
|
18317
18372
|
|
|
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
|
|
18373
|
+
# In worktree sandbox mode, Sandcastle bind-mounts the git worktree at ${SANDBOX_REPO_DIR}
|
|
18374
|
+
# and overrides the working directory to ${SANDBOX_REPO_DIR} at container start.
|
|
18375
|
+
# Structure your Dockerfile so that ${SANDBOX_REPO_DIR} can serve as the project root.
|
|
18321
18376
|
ENTRYPOINT ["sleep", "infinity"]
|
|
18322
18377
|
`;
|
|
18323
18378
|
var COPILOT_DOCKERFILE = `FROM node:22-bookworm
|
|
@@ -18347,9 +18402,9 @@ USER \${AGENT_UID}:\${AGENT_GID}
|
|
|
18347
18402
|
|
|
18348
18403
|
WORKDIR /home/agent
|
|
18349
18404
|
|
|
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
|
|
18405
|
+
# In worktree sandbox mode, Sandcastle bind-mounts the git worktree at ${SANDBOX_REPO_DIR}
|
|
18406
|
+
# and overrides the working directory to ${SANDBOX_REPO_DIR} at container start.
|
|
18407
|
+
# Structure your Dockerfile so that ${SANDBOX_REPO_DIR} can serve as the project root.
|
|
18353
18408
|
ENTRYPOINT ["sleep", "infinity"]
|
|
18354
18409
|
`;
|
|
18355
18410
|
var AGENT_REGISTRY = [
|
|
@@ -18364,7 +18419,11 @@ var AGENT_REGISTRY = [
|
|
|
18364
18419
|
CLAUDE_CODE_OAUTH_TOKEN=
|
|
18365
18420
|
# Or use an Anthropic API key instead \u2014 uncomment and fill in:
|
|
18366
18421
|
# ANTHROPIC_API_KEY=`,
|
|
18367
|
-
setupCommand: `claude "$(cat ${SETUP_ISSUE_TRACKER_PATH})"
|
|
18422
|
+
setupCommand: `claude "$(cat ${SETUP_ISSUE_TRACKER_PATH})"`,
|
|
18423
|
+
hostCli: {
|
|
18424
|
+
command: "claude",
|
|
18425
|
+
install: "curl -fsSL https://claude.ai/install.sh | bash"
|
|
18426
|
+
}
|
|
18368
18427
|
},
|
|
18369
18428
|
{
|
|
18370
18429
|
name: "pi",
|
|
@@ -18374,7 +18433,11 @@ CLAUDE_CODE_OAUTH_TOKEN=
|
|
|
18374
18433
|
dockerfileTemplate: PI_DOCKERFILE,
|
|
18375
18434
|
envExample: `# Anthropic API key
|
|
18376
18435
|
ANTHROPIC_API_KEY=`,
|
|
18377
|
-
setupCommand: `pi "$(cat ${SETUP_ISSUE_TRACKER_PATH})"
|
|
18436
|
+
setupCommand: `pi "$(cat ${SETUP_ISSUE_TRACKER_PATH})"`,
|
|
18437
|
+
hostCli: {
|
|
18438
|
+
command: "pi",
|
|
18439
|
+
install: "npm install -g @mariozechner/pi-coding-agent"
|
|
18440
|
+
}
|
|
18378
18441
|
},
|
|
18379
18442
|
{
|
|
18380
18443
|
name: "codex",
|
|
@@ -18382,9 +18445,13 @@ ANTHROPIC_API_KEY=`,
|
|
|
18382
18445
|
defaultModel: "gpt-5.4",
|
|
18383
18446
|
factoryImport: "codex",
|
|
18384
18447
|
dockerfileTemplate: CODEX_DOCKERFILE,
|
|
18385
|
-
envExample: `# OpenAI API key
|
|
18386
|
-
|
|
18387
|
-
setupCommand: `codex "$(cat ${SETUP_ISSUE_TRACKER_PATH})"
|
|
18448
|
+
envExample: `# OpenAI API key from platform.openai.com (\`codex exec\` reads CODEX_API_KEY)
|
|
18449
|
+
CODEX_API_KEY=`,
|
|
18450
|
+
setupCommand: `codex "$(cat ${SETUP_ISSUE_TRACKER_PATH})"`,
|
|
18451
|
+
hostCli: {
|
|
18452
|
+
command: "codex",
|
|
18453
|
+
install: "npm install -g @openai/codex"
|
|
18454
|
+
}
|
|
18388
18455
|
},
|
|
18389
18456
|
{
|
|
18390
18457
|
name: "cursor",
|
|
@@ -18395,7 +18462,11 @@ OPENAI_KEY=`,
|
|
|
18395
18462
|
envExample: `# Cursor API key (recommended)
|
|
18396
18463
|
# You can also pass --api-key directly to the agent CLI.
|
|
18397
18464
|
CURSOR_API_KEY=`,
|
|
18398
|
-
setupCommand: `agent "$(cat ${SETUP_ISSUE_TRACKER_PATH})"
|
|
18465
|
+
setupCommand: `agent "$(cat ${SETUP_ISSUE_TRACKER_PATH})"`,
|
|
18466
|
+
hostCli: {
|
|
18467
|
+
command: "agent",
|
|
18468
|
+
install: "curl https://cursor.com/install -fsS | bash"
|
|
18469
|
+
}
|
|
18399
18470
|
},
|
|
18400
18471
|
{
|
|
18401
18472
|
name: "opencode",
|
|
@@ -18405,7 +18476,11 @@ CURSOR_API_KEY=`,
|
|
|
18405
18476
|
dockerfileTemplate: OPENCODE_DOCKERFILE,
|
|
18406
18477
|
envExample: `# OpenCode API key
|
|
18407
18478
|
OPENCODE_API_KEY=`,
|
|
18408
|
-
setupCommand: `opencode --prompt "$(cat ${SETUP_ISSUE_TRACKER_PATH})"
|
|
18479
|
+
setupCommand: `opencode --prompt "$(cat ${SETUP_ISSUE_TRACKER_PATH})"`,
|
|
18480
|
+
hostCli: {
|
|
18481
|
+
command: "opencode",
|
|
18482
|
+
install: "npm install -g opencode-ai@latest"
|
|
18483
|
+
}
|
|
18409
18484
|
},
|
|
18410
18485
|
{
|
|
18411
18486
|
name: "copilot",
|
|
@@ -18415,12 +18490,43 @@ OPENCODE_API_KEY=`,
|
|
|
18415
18490
|
dockerfileTemplate: COPILOT_DOCKERFILE,
|
|
18416
18491
|
envExample: `# GitHub token with the "Copilot Requests" permission
|
|
18417
18492
|
# (a fine-grained PAT, or any token from \`gh auth login\`).
|
|
18418
|
-
# COPILOT_GITHUB_TOKEN
|
|
18419
|
-
|
|
18420
|
-
|
|
18493
|
+
# Copilot CLI reads COPILOT_GITHUB_TOKEN first, then GH_TOKEN, then GITHUB_TOKEN,
|
|
18494
|
+
# so this key is used even when GH_TOKEN is set for the issue tracker.
|
|
18495
|
+
COPILOT_GITHUB_TOKEN=`,
|
|
18496
|
+
setupCommand: `copilot -i "$(cat ${SETUP_ISSUE_TRACKER_PATH})"`,
|
|
18497
|
+
hostCli: {
|
|
18498
|
+
command: "copilot",
|
|
18499
|
+
install: "npm install -g @github/copilot"
|
|
18500
|
+
}
|
|
18421
18501
|
}
|
|
18422
18502
|
];
|
|
18423
18503
|
var listAgents = () => AGENT_REGISTRY;
|
|
18504
|
+
var isFile = (fs, candidate) => fs.stat(candidate).pipe(
|
|
18505
|
+
Effect_exports.map((info) => info.type === "File"),
|
|
18506
|
+
Effect_exports.orElseSucceed(() => false)
|
|
18507
|
+
);
|
|
18508
|
+
var isOnHostPath = (command) => Effect_exports.gen(function* () {
|
|
18509
|
+
const fs = yield* FileSystem_exports.FileSystem;
|
|
18510
|
+
const pathValue = yield* Config_exports.string("PATH").pipe(
|
|
18511
|
+
Config_exports.withDefault(""),
|
|
18512
|
+
Effect_exports.orElseSucceed(() => "")
|
|
18513
|
+
);
|
|
18514
|
+
const pathExt = yield* Config_exports.string("PATHEXT").pipe(
|
|
18515
|
+
Config_exports.withDefault(".EXE;.CMD;.BAT"),
|
|
18516
|
+
Effect_exports.orElseSucceed(() => "")
|
|
18517
|
+
);
|
|
18518
|
+
const extensions = process.platform === "win32" ? ["", ...pathExt.split(";")] : [""];
|
|
18519
|
+
const candidates = pathValue.split(delimiter).filter((dir) => dir !== "").flatMap((dir) => extensions.map((ext) => join(dir, `${command}${ext}`)));
|
|
18520
|
+
const found = yield* Effect_exports.all(
|
|
18521
|
+
candidates.map((candidate) => isFile(fs, candidate)),
|
|
18522
|
+
{ concurrency: "unbounded" }
|
|
18523
|
+
);
|
|
18524
|
+
return found.includes(true);
|
|
18525
|
+
});
|
|
18526
|
+
var agentCliWarning = (agent, sandboxProvider) => Effect_exports.map(
|
|
18527
|
+
isOnHostPath(agent.hostCli.command),
|
|
18528
|
+
(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}`
|
|
18529
|
+
);
|
|
18424
18530
|
var GITHUB_CLI_TOOLS = `# Install GitHub CLI
|
|
18425
18531
|
RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \\
|
|
18426
18532
|
| dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \\
|
|
@@ -18428,6 +18534,25 @@ RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \\
|
|
|
18428
18534
|
| tee /etc/apt/sources.list.d/github-cli.list > /dev/null \\
|
|
18429
18535
|
&& apt-get update && apt-get install -y gh \\
|
|
18430
18536
|
&& rm -rf /var/lib/apt/lists/*`;
|
|
18537
|
+
var BEADS_VERSION = "1.3.2";
|
|
18538
|
+
var BEADS_SANDBOX_DIR = "/home/agent/host-beads";
|
|
18539
|
+
var BEADS_SANDBOX_OPTIONS = `// Beads keeps its database in .beads/, which git ignores, so a worktree
|
|
18540
|
+
// sandbox never gets it. Mount the host's .beads/ into every sandbox and point
|
|
18541
|
+
// bd at it, so every phase reads and closes issues in the one shared database.
|
|
18542
|
+
// Run this file from the repo root (hostPath is relative to the cwd).
|
|
18543
|
+
const sandboxOptions = {
|
|
18544
|
+
mounts: [{ hostPath: ".beads", sandboxPath: "${BEADS_SANDBOX_DIR}" }],
|
|
18545
|
+
env: { BEADS_DIR: "${BEADS_SANDBOX_DIR}" },
|
|
18546
|
+
};`;
|
|
18547
|
+
var BEADS_NATIVE_SANDBOX_OPTIONS = `// Beads keeps its database in .beads/, which git ignores, so a worktree
|
|
18548
|
+
// sandbox never gets it. Mount the host's .beads/ into every sandbox, at its
|
|
18549
|
+
// own path, and point bd at it, so every phase reads and closes issues in the
|
|
18550
|
+
// one shared database. Run this file from the repo root.
|
|
18551
|
+
const beadsDir = \`\${process.cwd()}/.beads\`;
|
|
18552
|
+
const sandboxOptions = {
|
|
18553
|
+
mounts: [{ hostPath: beadsDir, sandboxPath: beadsDir }],
|
|
18554
|
+
env: { BEADS_DIR: beadsDir },
|
|
18555
|
+
};`;
|
|
18431
18556
|
var BEADS_TOOLS = `# Install system dependencies for Beads
|
|
18432
18557
|
RUN apt-get update && apt-get install -y \\
|
|
18433
18558
|
dpkg-dev \\
|
|
@@ -18438,9 +18563,45 @@ RUN apt-get update && apt-get install -y \\
|
|
|
18438
18563
|
ln -s "$lib" "\${lib%.72}.74"; \\
|
|
18439
18564
|
done
|
|
18440
18565
|
|
|
18441
|
-
|
|
18566
|
+
# Pinned bd release. Every sandbox opens your host's beads database (see
|
|
18567
|
+
# sandboxOptions in main), so keep this equal to the host's \`bd version\`.
|
|
18568
|
+
ARG BEADS_VERSION=${BEADS_VERSION}
|
|
18569
|
+
RUN ARCH=$(dpkg --print-architecture) \\
|
|
18570
|
+
&& BEADS_TARBALL="beads_\${BEADS_VERSION}_linux_\${ARCH}.tar.gz" \\
|
|
18571
|
+
&& BEADS_URL="https://github.com/gastownhall/beads/releases/download/v\${BEADS_VERSION}" \\
|
|
18572
|
+
&& cd /tmp \\
|
|
18573
|
+
&& curl -fsSLO "\${BEADS_URL}/\${BEADS_TARBALL}" \\
|
|
18574
|
+
&& curl -fsSL "\${BEADS_URL}/checksums.txt" | grep " \${BEADS_TARBALL}$" | sha256sum -c - \\
|
|
18575
|
+
&& tar -xzf "\${BEADS_TARBALL}" -C /usr/local/bin bd \\
|
|
18576
|
+
&& rm "\${BEADS_TARBALL}" \\
|
|
18577
|
+
&& bd version
|
|
18442
18578
|
|
|
18443
18579
|
RUN corepack enable`;
|
|
18580
|
+
var parseBdVersion = (output) => /\bbd version v?(?<version>\d+\.\d+\.\d+)\b/u.exec(output)?.groups?.version;
|
|
18581
|
+
var compareVersions = (a, b) => {
|
|
18582
|
+
const pa = a.split(".").map(Number);
|
|
18583
|
+
const pb = b.split(".").map(Number);
|
|
18584
|
+
for (let i = 0; i < 3; i++) {
|
|
18585
|
+
const diff = (pa[i] ?? 0) - (pb[i] ?? 0);
|
|
18586
|
+
if (diff !== 0) {
|
|
18587
|
+
return diff;
|
|
18588
|
+
}
|
|
18589
|
+
}
|
|
18590
|
+
return 0;
|
|
18591
|
+
};
|
|
18592
|
+
var beadsVersionWarning = (hostVersion) => {
|
|
18593
|
+
if (hostVersion === BEADS_VERSION) {
|
|
18594
|
+
return void 0;
|
|
18595
|
+
}
|
|
18596
|
+
const shared = `the image installs bd ${BEADS_VERSION}, and every sandbox opens your .beads/ with it`;
|
|
18597
|
+
if (hostVersion === void 0) {
|
|
18598
|
+
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.`;
|
|
18599
|
+
}
|
|
18600
|
+
if (compareVersions(hostVersion, BEADS_VERSION) < 0) {
|
|
18601
|
+
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.`;
|
|
18602
|
+
}
|
|
18603
|
+
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.`;
|
|
18604
|
+
};
|
|
18444
18605
|
var CUSTOM_LIST_TASKS_SENTINEL = `echo 'No issue tracker configured \u2014 run ${SETUP_ISSUE_TRACKER_PATH} through your coding agent.' >&2; exit 1`;
|
|
18445
18606
|
var CUSTOM_VIEW_TASK_MARKER = `<view command \u2014 see ${SETUP_ISSUE_TRACKER_PATH}>`;
|
|
18446
18607
|
var CUSTOM_CLOSE_TASK_MARKER = `<close command \u2014 see ${SETUP_ISSUE_TRACKER_PATH}>`;
|
|
@@ -18471,7 +18632,9 @@ GH_TOKEN=`
|
|
|
18471
18632
|
CLOSE_TASK_COMMAND: `bd close <ID> --reason="Completed by Sandcastle"`,
|
|
18472
18633
|
ISSUE_TRACKER_TOOLS: BEADS_TOOLS
|
|
18473
18634
|
},
|
|
18474
|
-
envExample: ""
|
|
18635
|
+
envExample: "",
|
|
18636
|
+
sandboxOptions: BEADS_SANDBOX_OPTIONS,
|
|
18637
|
+
nativeSandboxOptions: BEADS_NATIVE_SANDBOX_OPTIONS
|
|
18475
18638
|
},
|
|
18476
18639
|
{
|
|
18477
18640
|
name: "custom",
|
|
@@ -18496,91 +18659,132 @@ var SANDBOX_PROVIDER_REGISTRY = [
|
|
|
18496
18659
|
{
|
|
18497
18660
|
name: "docker",
|
|
18498
18661
|
label: "Docker",
|
|
18499
|
-
containerfileName: "Dockerfile",
|
|
18500
|
-
cliNamespace: "docker"
|
|
18662
|
+
image: { containerfileName: "Dockerfile", cliNamespace: "docker" }
|
|
18501
18663
|
},
|
|
18502
18664
|
{
|
|
18503
18665
|
name: "podman",
|
|
18504
18666
|
label: "Podman",
|
|
18505
|
-
containerfileName: "Containerfile",
|
|
18506
|
-
|
|
18667
|
+
image: { containerfileName: "Containerfile", cliNamespace: "podman" }
|
|
18668
|
+
},
|
|
18669
|
+
{
|
|
18670
|
+
name: "bwrap",
|
|
18671
|
+
label: "Bubblewrap",
|
|
18672
|
+
nativePlatform: "linux",
|
|
18673
|
+
preflight: assertBwrapUsable
|
|
18674
|
+
},
|
|
18675
|
+
{
|
|
18676
|
+
name: "seatbelt",
|
|
18677
|
+
label: "Seatbelt",
|
|
18678
|
+
nativePlatform: "darwin",
|
|
18679
|
+
preflight: assertSeatbeltUsable
|
|
18507
18680
|
}
|
|
18508
18681
|
];
|
|
18509
18682
|
var listSandboxProviders = () => SANDBOX_PROVIDER_REGISTRY;
|
|
18683
|
+
var listSandboxProviderChoices = (platform) => {
|
|
18684
|
+
const native = SANDBOX_PROVIDER_REGISTRY.filter(
|
|
18685
|
+
(p3) => p3.nativePlatform === platform
|
|
18686
|
+
);
|
|
18687
|
+
const others = SANDBOX_PROVIDER_REGISTRY.filter(
|
|
18688
|
+
(p3) => p3.nativePlatform === void 0
|
|
18689
|
+
);
|
|
18690
|
+
return [
|
|
18691
|
+
...native.map((entry) => ({ entry, recommended: true })),
|
|
18692
|
+
...others.map((entry) => ({ entry, recommended: false }))
|
|
18693
|
+
];
|
|
18694
|
+
};
|
|
18695
|
+
var sandboxProviderPreflightWarning = (sandboxProvider) => {
|
|
18696
|
+
try {
|
|
18697
|
+
sandboxProvider.preflight?.();
|
|
18698
|
+
return void 0;
|
|
18699
|
+
} catch (error3) {
|
|
18700
|
+
const reason = error3 instanceof Error ? error3.message : String(error3);
|
|
18701
|
+
return `This host can't run ${sandboxProvider.name}() yet, so the scaffolded main file fails until you fix it. ${reason}`;
|
|
18702
|
+
}
|
|
18703
|
+
};
|
|
18510
18704
|
var getSandboxProvider = (name) => SANDBOX_PROVIDER_REGISTRY.find((p3) => p3.name === name);
|
|
18511
|
-
|
|
18705
|
+
var envNotes = (issueTracker, agent, sandboxProvider) => [
|
|
18706
|
+
...agent.name === "claude-code" ? [
|
|
18707
|
+
" 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."
|
|
18708
|
+
] : [],
|
|
18709
|
+
// A native sandbox hides the host's gh login, so gh authenticates only
|
|
18710
|
+
// from the env Sandcastle passes in.
|
|
18711
|
+
...issueTracker.name === "github-issues" && sandboxProvider.image === void 0 ? [
|
|
18712
|
+
` ${sandboxProvider.name}() hides your host's \`gh\` login from the agent, so put a GH_TOKEN in .sandcastle/.env for \`gh\` to use.`
|
|
18713
|
+
] : []
|
|
18714
|
+
];
|
|
18715
|
+
var customTrackerNextSteps = (agent, sandboxProvider) => {
|
|
18716
|
+
const hasImage = sandboxProvider.image !== void 0;
|
|
18717
|
+
return [
|
|
18718
|
+
"Next steps:",
|
|
18719
|
+
"1. Your custom issue tracker isn't wired up yet \u2014 runs hard-fail until you configure it.",
|
|
18720
|
+
`2. Feed the setup prompt to ${agent.label} on your host to finish wiring it up:`,
|
|
18721
|
+
` ${agent.setupCommand}`,
|
|
18722
|
+
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.)`,
|
|
18723
|
+
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.`
|
|
18724
|
+
];
|
|
18725
|
+
};
|
|
18726
|
+
var blankTemplateNextSteps = ({
|
|
18727
|
+
mainFilename,
|
|
18728
|
+
notes,
|
|
18729
|
+
runStep
|
|
18730
|
+
}) => [
|
|
18731
|
+
"Next steps:",
|
|
18732
|
+
`1. Set the required env vars in .sandcastle/.env (see .sandcastle/.env.example)`,
|
|
18733
|
+
...notes,
|
|
18734
|
+
"2. Read and customize .sandcastle/prompt.md to describe what you want the agent to do",
|
|
18735
|
+
`3. Customize .sandcastle/${mainFilename} \u2014 it uses the JS API (\`run()\`) to control how the agent runs`,
|
|
18736
|
+
`4. Add "sandcastle": "npx tsx .sandcastle/${mainFilename}" to your package.json scripts`,
|
|
18737
|
+
`5. ${runStep}`
|
|
18738
|
+
];
|
|
18739
|
+
var copyToWorktreeStep = (packageManager) => `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`}`;
|
|
18740
|
+
var planSchemaStep = (packageManager) => `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)`;
|
|
18741
|
+
var getNextStepsLines = (template, mainFilename, issueTracker, agent, packageManager, installedDependencies, sandboxProvider = SANDBOX_PROVIDER_REGISTRY[0]) => {
|
|
18742
|
+
const runStep = `Run \`${runScriptCommand(packageManager, "sandcastle")}\` to start the agent`;
|
|
18512
18743
|
if (issueTracker.name === "custom") {
|
|
18513
|
-
return
|
|
18514
|
-
"Next steps:",
|
|
18515
|
-
"1. Your custom issue tracker isn't wired up yet \u2014 runs hard-fail until you configure it.",
|
|
18516
|
-
`2. Feed the setup prompt to ${agent.label} on your host to finish wiring it up:`,
|
|
18517
|
-
` ${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.`
|
|
18520
|
-
];
|
|
18744
|
+
return customTrackerNextSteps(agent, sandboxProvider);
|
|
18521
18745
|
}
|
|
18522
18746
|
if (template === "blank") {
|
|
18523
|
-
|
|
18524
|
-
|
|
18525
|
-
|
|
18526
|
-
|
|
18527
|
-
|
|
18528
|
-
|
|
18529
|
-
|
|
18530
|
-
|
|
18531
|
-
|
|
18532
|
-
|
|
18533
|
-
|
|
18534
|
-
|
|
18535
|
-
|
|
18536
|
-
|
|
18537
|
-
)
|
|
18538
|
-
|
|
18539
|
-
|
|
18540
|
-
|
|
18541
|
-
|
|
18542
|
-
|
|
18543
|
-
|
|
18544
|
-
|
|
18545
|
-
|
|
18546
|
-
];
|
|
18547
|
-
if (agent.name === "claude-code") {
|
|
18548
|
-
lines2.push(
|
|
18549
|
-
" 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."
|
|
18550
|
-
);
|
|
18551
|
-
}
|
|
18552
|
-
lines2.push(
|
|
18553
|
-
`${step++}. Add "sandcastle": "npx tsx .sandcastle/${mainFilename}" to your package.json scripts`,
|
|
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`
|
|
18555
|
-
);
|
|
18556
|
-
if (usesPlanSchema) {
|
|
18557
|
-
lines2.push(
|
|
18558
|
-
`${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)`
|
|
18559
|
-
);
|
|
18560
|
-
}
|
|
18747
|
+
return blankTemplateNextSteps({
|
|
18748
|
+
mainFilename,
|
|
18749
|
+
notes: envNotes(issueTracker, agent, sandboxProvider),
|
|
18750
|
+
runStep
|
|
18751
|
+
});
|
|
18752
|
+
}
|
|
18753
|
+
const hasReviewer = template.includes("review");
|
|
18754
|
+
const needsPlanSchema = getTemplateDependencies(template).includes("zod") && !installedDependencies.includes("zod");
|
|
18755
|
+
let step = 1;
|
|
18756
|
+
const lines2 = [
|
|
18757
|
+
"Next steps:",
|
|
18758
|
+
`${step++}. Set the required env vars in .sandcastle/.env (see .sandcastle/.env.example)`,
|
|
18759
|
+
...envNotes(issueTracker, agent, sandboxProvider),
|
|
18760
|
+
`${step++}. Add "sandcastle": "npx tsx .sandcastle/${mainFilename}" to your package.json scripts`,
|
|
18761
|
+
`${step++}. ${copyToWorktreeStep(packageManager)}`
|
|
18762
|
+
];
|
|
18763
|
+
if (needsPlanSchema) {
|
|
18764
|
+
lines2.push(`${step++}. ${planSchemaStep(packageManager)}`);
|
|
18765
|
+
}
|
|
18766
|
+
lines2.push(
|
|
18767
|
+
`${step++}. Read and customize the prompt files in .sandcastle/ \u2014 they shape what the agent does`
|
|
18768
|
+
);
|
|
18769
|
+
if (hasReviewer) {
|
|
18561
18770
|
lines2.push(
|
|
18562
|
-
`${step++}.
|
|
18771
|
+
`${step++}. Customize .sandcastle/CODING_STANDARDS.md with your project's standards \u2014 the reviewer agent loads it during review`
|
|
18563
18772
|
);
|
|
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
18773
|
}
|
|
18572
|
-
}
|
|
18573
|
-
|
|
18774
|
+
lines2.push(`${step++}. ${runStep}`);
|
|
18775
|
+
return lines2;
|
|
18776
|
+
};
|
|
18777
|
+
var getTemplatesDir = () => {
|
|
18574
18778
|
const thisFile = fileURLToPath(import.meta.url);
|
|
18575
18779
|
return join(dirname(thisFile), "templates");
|
|
18576
|
-
}
|
|
18780
|
+
};
|
|
18577
18781
|
var getTemplateDir = (templateName) => Effect_exports.gen(function* () {
|
|
18578
18782
|
const template = TEMPLATES.find((t) => t.name === templateName);
|
|
18579
18783
|
if (!template) {
|
|
18580
18784
|
const names = TEMPLATES.map((t) => t.name).join(", ");
|
|
18581
|
-
yield*
|
|
18582
|
-
|
|
18583
|
-
);
|
|
18785
|
+
return yield* new InitError({
|
|
18786
|
+
message: `Unknown template: "${templateName}". Available: ${names}`
|
|
18787
|
+
});
|
|
18584
18788
|
}
|
|
18585
18789
|
return join(getTemplatesDir(), templateName);
|
|
18586
18790
|
});
|
|
@@ -18596,50 +18800,101 @@ var COMPILED_FILE_EXTENSIONS = [
|
|
|
18596
18800
|
];
|
|
18597
18801
|
var copyTemplateFiles = (templateDir, destDir, mainFilename) => Effect_exports.gen(function* () {
|
|
18598
18802
|
const fs = yield* FileSystem_exports.FileSystem;
|
|
18599
|
-
const files = yield* fs.readDirectory(templateDir).pipe(Effect_exports.mapError((e) => new
|
|
18803
|
+
const files = yield* fs.readDirectory(templateDir).pipe(Effect_exports.mapError((e) => new InitError({ message: e.message })));
|
|
18600
18804
|
yield* Effect_exports.all(
|
|
18601
18805
|
files.filter(
|
|
18602
18806
|
(f) => f !== "template.json" && f !== ".env.example" && !COMPILED_FILE_EXTENSIONS.some((ext) => f.endsWith(ext))
|
|
18603
18807
|
).map((f) => {
|
|
18604
18808
|
const destName = f === "main.mts" ? mainFilename : f;
|
|
18605
|
-
return fs.copyFile(join(templateDir, f), join(destDir, destName)).pipe(
|
|
18809
|
+
return fs.copyFile(join(templateDir, f), join(destDir, destName)).pipe(
|
|
18810
|
+
Effect_exports.mapError((e) => new InitError({ message: e.message }))
|
|
18811
|
+
);
|
|
18606
18812
|
}),
|
|
18607
18813
|
{ concurrency: "unbounded" }
|
|
18608
18814
|
);
|
|
18609
18815
|
});
|
|
18610
|
-
var
|
|
18816
|
+
var editMainFile = (choices, edit) => Effect_exports.gen(function* () {
|
|
18611
18817
|
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
|
-
|
|
18818
|
+
const mainTsPath = join(choices.configDir, choices.mainFilename);
|
|
18819
|
+
const exists = yield* fs.exists(mainTsPath).pipe(Effect_exports.mapError((e) => new InitError({ message: e.message })));
|
|
18820
|
+
if (!exists) {
|
|
18821
|
+
return;
|
|
18822
|
+
}
|
|
18823
|
+
const content = yield* fs.readFileString(mainTsPath).pipe(Effect_exports.mapError((e) => new InitError({ message: e.message })));
|
|
18824
|
+
const updated = yield* edit(content);
|
|
18825
|
+
yield* fs.writeFileString(mainTsPath, updated).pipe(Effect_exports.mapError((e) => new InitError({ message: e.message })));
|
|
18826
|
+
});
|
|
18827
|
+
var rewriteMainContent = (original, choices) => {
|
|
18828
|
+
const { agent, model, sandboxProvider, imageName } = choices;
|
|
18829
|
+
let content = original;
|
|
18830
|
+
if (choices.mainFilename === "main.ts") {
|
|
18831
|
+
content = content.replaceAll("main.mts", "main.ts");
|
|
18832
|
+
}
|
|
18833
|
+
content = content.replaceAll(/\bclaudeCode\b/gu, agent.factoryImport);
|
|
18620
18834
|
const factoryCallRe = new RegExp(
|
|
18621
18835
|
`${agent.factoryImport}\\(["']([^"']+)["']\\)`,
|
|
18622
|
-
"
|
|
18836
|
+
"gu"
|
|
18623
18837
|
);
|
|
18624
|
-
content = content.
|
|
18838
|
+
content = content.replaceAll(
|
|
18625
18839
|
factoryCallRe,
|
|
18626
18840
|
`${agent.factoryImport}("${model}")`
|
|
18627
18841
|
);
|
|
18628
|
-
content = content.
|
|
18629
|
-
|
|
18630
|
-
|
|
18842
|
+
content = content.replaceAll(/\bdocker\b/gu, sandboxProvider.name);
|
|
18843
|
+
if (imageName !== void 0 && sandboxProvider.image !== void 0) {
|
|
18844
|
+
content = content.replaceAll(
|
|
18845
|
+
new RegExp(`\\b${sandboxProvider.name}\\(\\)`, "gu"),
|
|
18846
|
+
`${sandboxProvider.name}({ imageName: ${JSON.stringify(imageName)} })`
|
|
18847
|
+
);
|
|
18848
|
+
}
|
|
18849
|
+
return content;
|
|
18850
|
+
};
|
|
18851
|
+
var rewriteMainTs = (choices) => editMainFile(
|
|
18852
|
+
choices,
|
|
18853
|
+
(content) => Effect_exports.succeed(rewriteMainContent(content, choices))
|
|
18854
|
+
);
|
|
18855
|
+
var applyIssueTrackerSandboxOptions = (choices) => {
|
|
18856
|
+
const { issueTracker, sandboxProvider, mainFilename } = choices;
|
|
18857
|
+
const sandboxOptions = sandboxProvider.image === void 0 ? issueTracker.nativeSandboxOptions ?? issueTracker.sandboxOptions : issueTracker.sandboxOptions;
|
|
18858
|
+
if (sandboxOptions === void 0 || sandboxOptions === "") {
|
|
18859
|
+
return Effect_exports.void;
|
|
18860
|
+
}
|
|
18861
|
+
const provider = sandboxProvider.name;
|
|
18862
|
+
const importRe = new RegExp(
|
|
18863
|
+
`^import \\{ ${provider} \\} from "@ai-hero/sandcastle/sandboxes/${provider}";$`,
|
|
18864
|
+
"mu"
|
|
18865
|
+
);
|
|
18866
|
+
return editMainFile(
|
|
18867
|
+
choices,
|
|
18868
|
+
(content) => importRe.test(content) ? Effect_exports.succeed(
|
|
18869
|
+
content.replace(importRe, (line4) => `${line4}
|
|
18870
|
+
|
|
18871
|
+
${sandboxOptions}`).replaceAll(
|
|
18872
|
+
new RegExp(`\\b${provider}\\(\\)`, "gu"),
|
|
18873
|
+
`${provider}(sandboxOptions)`
|
|
18874
|
+
)
|
|
18875
|
+
) : Effect_exports.fail(
|
|
18876
|
+
new InitError({
|
|
18877
|
+
message: `Cannot apply ${issueTracker.label} sandbox options: ${mainFilename} has no ${provider} import.`
|
|
18878
|
+
})
|
|
18879
|
+
)
|
|
18880
|
+
);
|
|
18881
|
+
};
|
|
18631
18882
|
var rewritePromptFiles = (configDir) => Effect_exports.gen(function* () {
|
|
18632
18883
|
const fs = yield* FileSystem_exports.FileSystem;
|
|
18633
|
-
const files = yield* fs.readDirectory(configDir).pipe(Effect_exports.mapError((e) => new
|
|
18884
|
+
const files = yield* fs.readDirectory(configDir).pipe(Effect_exports.mapError((e) => new InitError({ message: e.message })));
|
|
18634
18885
|
const mdFiles = files.filter((f) => f.endsWith(".md"));
|
|
18635
18886
|
yield* Effect_exports.all(
|
|
18636
18887
|
mdFiles.map(
|
|
18637
18888
|
(f) => Effect_exports.gen(function* () {
|
|
18638
18889
|
const filePath = join(configDir, f);
|
|
18639
|
-
const content = yield* fs.readFileString(filePath).pipe(
|
|
18640
|
-
|
|
18890
|
+
const content = yield* fs.readFileString(filePath).pipe(
|
|
18891
|
+
Effect_exports.mapError((e) => new InitError({ message: e.message }))
|
|
18892
|
+
);
|
|
18893
|
+
const updated = content.replaceAll(" --label Sandcastle", "");
|
|
18641
18894
|
if (updated !== content) {
|
|
18642
|
-
yield* fs.writeFileString(filePath, updated).pipe(
|
|
18895
|
+
yield* fs.writeFileString(filePath, updated).pipe(
|
|
18896
|
+
Effect_exports.mapError((e) => new InitError({ message: e.message }))
|
|
18897
|
+
);
|
|
18643
18898
|
}
|
|
18644
18899
|
})
|
|
18645
18900
|
),
|
|
@@ -18654,39 +18909,71 @@ var TEXT_FILE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
18654
18909
|
// Dockerfile / Containerfile have no extension — handled by name check below
|
|
18655
18910
|
]);
|
|
18656
18911
|
var isTextFile = (filename) => {
|
|
18657
|
-
if (filename === "Dockerfile" || filename === "Containerfile" || filename === ".gitignore")
|
|
18912
|
+
if (filename === "Dockerfile" || filename === "Containerfile" || filename === ".gitignore") {
|
|
18658
18913
|
return true;
|
|
18914
|
+
}
|
|
18659
18915
|
const dotIdx = filename.lastIndexOf(".");
|
|
18660
|
-
if (dotIdx === -1)
|
|
18916
|
+
if (dotIdx === -1) {
|
|
18917
|
+
return false;
|
|
18918
|
+
}
|
|
18661
18919
|
return TEXT_FILE_EXTENSIONS.has(filename.slice(dotIdx));
|
|
18662
18920
|
};
|
|
18663
18921
|
var substituteTemplateArgs = (configDir, issueTracker) => Effect_exports.gen(function* () {
|
|
18664
18922
|
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);
|
|
18923
|
+
const files = yield* fs.readDirectory(configDir).pipe(Effect_exports.mapError((e) => new InitError({ message: e.message })));
|
|
18924
|
+
const textFiles = files.filter((f) => isTextFile(f));
|
|
18667
18925
|
yield* Effect_exports.all(
|
|
18668
18926
|
textFiles.map(
|
|
18669
18927
|
(f) => Effect_exports.gen(function* () {
|
|
18670
18928
|
const filePath = join(configDir, f);
|
|
18671
|
-
let content = yield* fs.readFileString(filePath).pipe(
|
|
18929
|
+
let content = yield* fs.readFileString(filePath).pipe(
|
|
18930
|
+
Effect_exports.mapError((e) => new InitError({ message: e.message }))
|
|
18931
|
+
);
|
|
18672
18932
|
const original = content;
|
|
18673
18933
|
for (const [key, value2] of Object.entries(
|
|
18674
18934
|
issueTracker.templateArgs
|
|
18675
18935
|
)) {
|
|
18676
|
-
content = content.
|
|
18677
|
-
new RegExp(`\\{\\{${key}\\}\\}`, "
|
|
18936
|
+
content = content.replaceAll(
|
|
18937
|
+
new RegExp(`\\{\\{${key}\\}\\}`, "gu"),
|
|
18678
18938
|
value2
|
|
18679
18939
|
);
|
|
18680
18940
|
}
|
|
18681
18941
|
if (content !== original) {
|
|
18682
|
-
yield* fs.writeFileString(filePath, content).pipe(
|
|
18942
|
+
yield* fs.writeFileString(filePath, content).pipe(
|
|
18943
|
+
Effect_exports.mapError((e) => new InitError({ message: e.message }))
|
|
18944
|
+
);
|
|
18683
18945
|
}
|
|
18684
18946
|
})
|
|
18685
18947
|
),
|
|
18686
18948
|
{ concurrency: "unbounded" }
|
|
18687
18949
|
);
|
|
18688
18950
|
});
|
|
18689
|
-
var
|
|
18951
|
+
var buildImageShellCommand = (image, imageName) => `sandcastle ${image.cliNamespace} build-image${imageName === void 0 ? "" : ` --image-name ${imageName}`}`;
|
|
18952
|
+
var imageToolsStep = (buildCommand) => buildCommand === void 0 ? "" : `- **Dockerfile / Containerfile** \u2014 replace the line
|
|
18953
|
+
|
|
18954
|
+
\`\`\`
|
|
18955
|
+
${CUSTOM_TRACKER_TOOLS}
|
|
18956
|
+
\`\`\`
|
|
18957
|
+
|
|
18958
|
+
with the install steps for your tracker's CLI (if it needs one).
|
|
18959
|
+
|
|
18960
|
+
`;
|
|
18961
|
+
var verifySteps = (buildCommand) => buildCommand === void 0 ? `## 4. Verify
|
|
18962
|
+
|
|
18963
|
+
Run your **list** command and confirm it returns the open tasks as JSON. If it errors, fix the command or the auth.
|
|
18964
|
+
` : `## 4. Build the image
|
|
18965
|
+
|
|
18966
|
+
Once the files are wired up, build the sandbox image:
|
|
18967
|
+
|
|
18968
|
+
\`\`\`
|
|
18969
|
+
${buildCommand}
|
|
18970
|
+
\`\`\`
|
|
18971
|
+
|
|
18972
|
+
## 5. Verify
|
|
18973
|
+
|
|
18974
|
+
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.
|
|
18975
|
+
`;
|
|
18976
|
+
var buildSetupIssueTrackerDoc = (buildCommand) => `# Set up your custom issue tracker
|
|
18690
18977
|
|
|
18691
18978
|
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
18979
|
|
|
@@ -18711,15 +18998,7 @@ Work out, together with the user, the shell commands for:
|
|
|
18711
18998
|
|
|
18712
18999
|
## 3. Edit the scaffolded files in place
|
|
18713
19000
|
|
|
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
|
|
19001
|
+
${imageToolsStep(buildCommand)}- **Prompt files (\`.sandcastle/*.md\`)** \u2014 replace the sentinel
|
|
18723
19002
|
|
|
18724
19003
|
\`\`\`
|
|
18725
19004
|
${CUSTOM_LIST_TASKS_SENTINEL}
|
|
@@ -18729,35 +19008,60 @@ Work out, together with the user, the shell commands for:
|
|
|
18729
19008
|
|
|
18730
19009
|
- **\`.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
19010
|
|
|
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
|
-
`;
|
|
19011
|
+
${verifySteps(buildCommand)}`;
|
|
18744
19012
|
var detectMainFilename = (repoDir) => Effect_exports.gen(function* () {
|
|
19013
|
+
const pkg = yield* readHostPackageJson(repoDir);
|
|
19014
|
+
return Option_exports.getOrUndefined(pkg)?.["type"] === "module" ? "main.ts" : "main.mts";
|
|
19015
|
+
});
|
|
19016
|
+
var createConfigDir = (configDir) => Effect_exports.gen(function* () {
|
|
18745
19017
|
const fs = yield* FileSystem_exports.FileSystem;
|
|
18746
|
-
const
|
|
18747
|
-
|
|
18748
|
-
|
|
18749
|
-
|
|
18750
|
-
|
|
18751
|
-
const pkg = JSON.parse(content);
|
|
18752
|
-
return pkg["type"] === "module" ? "main.ts" : "main.mts";
|
|
18753
|
-
} catch {
|
|
18754
|
-
return "main.mts";
|
|
19018
|
+
const exists = yield* fs.exists(configDir).pipe(Effect_exports.mapError((e) => new InitError({ message: e.message })));
|
|
19019
|
+
if (exists) {
|
|
19020
|
+
return yield* new InitError({
|
|
19021
|
+
message: ".sandcastle/ directory already exists. Remove it first if you want to re-initialize."
|
|
19022
|
+
});
|
|
18755
19023
|
}
|
|
19024
|
+
yield* fs.makeDirectory(configDir, { recursive: false }).pipe(Effect_exports.mapError((e) => new InitError({ message: e.message })));
|
|
19025
|
+
});
|
|
19026
|
+
var writeScaffoldFiles = (choices, templateDir) => Effect_exports.gen(function* () {
|
|
19027
|
+
const fs = yield* FileSystem_exports.FileSystem;
|
|
19028
|
+
const { configDir, agent, issueTracker } = choices;
|
|
19029
|
+
const envExampleParts = [agent.envExample];
|
|
19030
|
+
if (issueTracker.envExample) {
|
|
19031
|
+
envExampleParts.push(issueTracker.envExample);
|
|
19032
|
+
}
|
|
19033
|
+
const envExampleContent = `${envExampleParts.join("\n")}
|
|
19034
|
+
`;
|
|
19035
|
+
const { image } = choices.sandboxProvider;
|
|
19036
|
+
yield* Effect_exports.all(
|
|
19037
|
+
[
|
|
19038
|
+
...image === void 0 ? [] : [
|
|
19039
|
+
fs.writeFileString(
|
|
19040
|
+
join(configDir, image.containerfileName),
|
|
19041
|
+
agent.dockerfileTemplate
|
|
19042
|
+
).pipe(
|
|
19043
|
+
Effect_exports.mapError((e) => new InitError({ message: e.message }))
|
|
19044
|
+
)
|
|
19045
|
+
],
|
|
19046
|
+
fs.writeFileString(join(configDir, ".gitignore"), GITIGNORE).pipe(Effect_exports.mapError((e) => new InitError({ message: e.message }))),
|
|
19047
|
+
fs.writeFileString(join(configDir, ".env.example"), envExampleContent).pipe(Effect_exports.mapError((e) => new InitError({ message: e.message }))),
|
|
19048
|
+
copyTemplateFiles(templateDir, configDir, choices.mainFilename)
|
|
19049
|
+
],
|
|
19050
|
+
{ concurrency: "unbounded" }
|
|
19051
|
+
);
|
|
19052
|
+
});
|
|
19053
|
+
var writeSetupIssueTrackerDoc = (choices) => Effect_exports.gen(function* () {
|
|
19054
|
+
const fs = yield* FileSystem_exports.FileSystem;
|
|
19055
|
+
const { image } = choices.sandboxProvider;
|
|
19056
|
+
yield* fs.writeFileString(
|
|
19057
|
+
join(choices.configDir, SETUP_ISSUE_TRACKER_DOC),
|
|
19058
|
+
buildSetupIssueTrackerDoc(
|
|
19059
|
+
image === void 0 ? void 0 : buildImageShellCommand(image, choices.imageName)
|
|
19060
|
+
)
|
|
19061
|
+
).pipe(Effect_exports.mapError((e) => new InitError({ message: e.message })));
|
|
18756
19062
|
});
|
|
18757
19063
|
var scaffold = (repoDir, options3) => Effect_exports.gen(function* () {
|
|
18758
19064
|
const {
|
|
18759
|
-
agent,
|
|
18760
|
-
model,
|
|
18761
19065
|
templateName = "blank",
|
|
18762
19066
|
createLabel = true,
|
|
18763
19067
|
issueTracker = ISSUE_TRACKER_REGISTRY[0],
|
|
@@ -18765,56 +19069,32 @@ var scaffold = (repoDir, options3) => Effect_exports.gen(function* () {
|
|
|
18765
19069
|
sandboxProvider = SANDBOX_PROVIDER_REGISTRY[0]
|
|
18766
19070
|
// default: docker
|
|
18767
19071
|
} = options3;
|
|
18768
|
-
const fs = yield* FileSystem_exports.FileSystem;
|
|
18769
19072
|
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
19073
|
const mainFilename = yield* detectMainFilename(repoDir);
|
|
18779
|
-
yield*
|
|
19074
|
+
yield* createConfigDir(configDir);
|
|
18780
19075
|
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(
|
|
19076
|
+
const choices = {
|
|
18799
19077
|
configDir,
|
|
18800
|
-
|
|
18801
|
-
|
|
19078
|
+
mainFilename,
|
|
19079
|
+
agent: options3.agent,
|
|
19080
|
+
model: options3.model,
|
|
18802
19081
|
sandboxProvider,
|
|
18803
|
-
|
|
18804
|
-
|
|
19082
|
+
issueTracker,
|
|
19083
|
+
imageName: options3.imageName
|
|
19084
|
+
};
|
|
19085
|
+
yield* writeScaffoldFiles(choices, templateDir);
|
|
19086
|
+
yield* rewriteMainTs(choices);
|
|
19087
|
+
yield* applyIssueTrackerSandboxOptions(choices);
|
|
18805
19088
|
yield* substituteTemplateArgs(configDir, issueTracker);
|
|
18806
19089
|
if (!createLabel) {
|
|
18807
19090
|
yield* rewritePromptFiles(configDir);
|
|
18808
19091
|
}
|
|
18809
19092
|
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)));
|
|
19093
|
+
yield* writeSetupIssueTrackerDoc(choices);
|
|
18814
19094
|
}
|
|
18815
19095
|
return { mainFilename };
|
|
18816
19096
|
});
|
|
18817
|
-
var VERSION = "0.
|
|
19097
|
+
var VERSION = "0.14.0";
|
|
18818
19098
|
|
|
18819
19099
|
// src/cli.ts
|
|
18820
19100
|
var imageNameOption = Options_exports.text("image-name").pipe(
|
|
@@ -18826,21 +19106,43 @@ var defaultUidBuildArgs = () => {
|
|
|
18826
19106
|
const args = {};
|
|
18827
19107
|
const uid = process.getuid?.();
|
|
18828
19108
|
const gid = process.getgid?.();
|
|
18829
|
-
if (uid !== void 0)
|
|
18830
|
-
|
|
19109
|
+
if (uid !== void 0) {
|
|
19110
|
+
args.AGENT_UID = String(uid);
|
|
19111
|
+
}
|
|
19112
|
+
if (gid !== void 0) {
|
|
19113
|
+
args.AGENT_GID = String(gid);
|
|
19114
|
+
}
|
|
18831
19115
|
return args;
|
|
18832
19116
|
};
|
|
18833
19117
|
var CONFIG_DIR = ".sandcastle";
|
|
18834
|
-
var requireConfigDir = (cwd) =>
|
|
18835
|
-
|
|
18836
|
-
|
|
18837
|
-
|
|
18838
|
-
|
|
18839
|
-
|
|
18840
|
-
|
|
18841
|
-
|
|
18842
|
-
|
|
19118
|
+
var requireConfigDir = (cwd) => FileSystem_exports.FileSystem.pipe(
|
|
19119
|
+
Effect_exports.flatMap((fs) => fs.exists(join(cwd, CONFIG_DIR))),
|
|
19120
|
+
Effect_exports.catchAll(() => Effect_exports.succeed(false)),
|
|
19121
|
+
Effect_exports.filterOrFail(
|
|
19122
|
+
(exists) => exists,
|
|
19123
|
+
() => new ConfigDirError({
|
|
19124
|
+
message: "No .sandcastle/ found. Run `sandcastle init` first."
|
|
19125
|
+
})
|
|
19126
|
+
),
|
|
19127
|
+
Effect_exports.asVoid
|
|
19128
|
+
);
|
|
19129
|
+
var nonInteractiveMessage = (flags) => `${flags.join(", ")} ${flags.length === 1 ? "is" : "are"} required in non-interactive mode (no TTY detected).`;
|
|
19130
|
+
var failInitUnless = (ok, message) => ok ? Effect_exports.void : Effect_exports.fail(new InitError({ message }));
|
|
19131
|
+
var registryEntry = (entry, what) => entry === void 0 ? Effect_exports.fail(new InitError({ message: `Unknown ${what}` })) : Effect_exports.succeed(entry);
|
|
19132
|
+
var selectName = (params) => Effect_exports.gen(function* () {
|
|
19133
|
+
if (params.flag._tag === "Some") {
|
|
19134
|
+
return params.flag.value;
|
|
19135
|
+
}
|
|
19136
|
+
if (!params.isInteractive) {
|
|
19137
|
+
return yield* new InitError({
|
|
19138
|
+
message: nonInteractiveMessage([params.flagName])
|
|
19139
|
+
});
|
|
19140
|
+
}
|
|
19141
|
+
const selected = yield* Effect_exports.promise(() => clack.select(params.prompt));
|
|
19142
|
+
if (clack.isCancel(selected)) {
|
|
19143
|
+
return yield* new InitError({ message: params.cancelMessage });
|
|
18843
19144
|
}
|
|
19145
|
+
return selected;
|
|
18844
19146
|
});
|
|
18845
19147
|
var templateOption = Options_exports.text("template").pipe(
|
|
18846
19148
|
Options_exports.withDescription(
|
|
@@ -18859,7 +19161,9 @@ var initModelOption = Options_exports.text("model").pipe(
|
|
|
18859
19161
|
Options_exports.optional
|
|
18860
19162
|
);
|
|
18861
19163
|
var sandboxOption = Options_exports.text("sandbox").pipe(
|
|
18862
|
-
Options_exports.withDescription(
|
|
19164
|
+
Options_exports.withDescription(
|
|
19165
|
+
"Sandbox provider to use (bwrap, seatbelt, docker or podman)"
|
|
19166
|
+
),
|
|
18863
19167
|
Options_exports.optional
|
|
18864
19168
|
);
|
|
18865
19169
|
var issueTrackerOption = Options_exports.text("issue-tracker").pipe(
|
|
@@ -18893,6 +19197,377 @@ var installTemplateDepsOption = Options_exports.choice("install-template-deps",
|
|
|
18893
19197
|
Options_exports.optional
|
|
18894
19198
|
);
|
|
18895
19199
|
var choiceToTriBool = (opt) => opt._tag === "Some" ? Option_exports.some(opt.value === "true") : Option_exports.none();
|
|
19200
|
+
var detectHostBdVersion = (cwd) => Effect_exports.async((resume) => {
|
|
19201
|
+
execFile(
|
|
19202
|
+
"bd",
|
|
19203
|
+
["version"],
|
|
19204
|
+
{ cwd, encoding: "utf8", timeout: 15e3 },
|
|
19205
|
+
(_error, stdout, stderr) => {
|
|
19206
|
+
resume(Effect_exports.succeed(parseBdVersion(`${stdout}
|
|
19207
|
+
${stderr}`)));
|
|
19208
|
+
}
|
|
19209
|
+
);
|
|
19210
|
+
});
|
|
19211
|
+
var validateRegistryFlags = (flags) => Effect_exports.gen(function* () {
|
|
19212
|
+
const { template } = flags;
|
|
19213
|
+
if (template._tag === "Some") {
|
|
19214
|
+
const templates = listTemplates();
|
|
19215
|
+
const names = templates.map((tmpl) => tmpl.name).join(", ");
|
|
19216
|
+
yield* failInitUnless(
|
|
19217
|
+
templates.some((tmpl) => tmpl.name === template.value),
|
|
19218
|
+
`Unknown template "${template.value}". Available: ${names}`
|
|
19219
|
+
);
|
|
19220
|
+
}
|
|
19221
|
+
if (flags.sandbox._tag === "Some") {
|
|
19222
|
+
const names = listSandboxProviders().map((p3) => p3.name).join(", ");
|
|
19223
|
+
yield* failInitUnless(
|
|
19224
|
+
getSandboxProvider(flags.sandbox.value) !== void 0,
|
|
19225
|
+
`Unknown sandbox provider "${flags.sandbox.value}". Available: ${names}`
|
|
19226
|
+
);
|
|
19227
|
+
}
|
|
19228
|
+
if (flags.issueTracker._tag === "Some") {
|
|
19229
|
+
const names = listIssueTrackers().map((t) => t.name).join(", ");
|
|
19230
|
+
yield* failInitUnless(
|
|
19231
|
+
getIssueTracker(flags.issueTracker.value) !== void 0,
|
|
19232
|
+
`Unknown issue tracker "${flags.issueTracker.value}". Available: ${names}`
|
|
19233
|
+
);
|
|
19234
|
+
}
|
|
19235
|
+
if (flags.agent._tag === "Some") {
|
|
19236
|
+
const names = listAgents().map((a) => a.name).join(", ");
|
|
19237
|
+
yield* failInitUnless(
|
|
19238
|
+
getAgent(flags.agent.value) !== void 0,
|
|
19239
|
+
`Unknown agent "${flags.agent.value}". Available: ${names}`
|
|
19240
|
+
);
|
|
19241
|
+
}
|
|
19242
|
+
});
|
|
19243
|
+
var resolveConfirmFlag = (params) => Effect_exports.gen(function* () {
|
|
19244
|
+
if (params.choice._tag === "Some") {
|
|
19245
|
+
return params.choice.value;
|
|
19246
|
+
}
|
|
19247
|
+
if (!params.isInteractive) {
|
|
19248
|
+
return yield* new InitError({
|
|
19249
|
+
message: nonInteractiveMessage([params.flag])
|
|
19250
|
+
});
|
|
19251
|
+
}
|
|
19252
|
+
const confirmed = yield* Effect_exports.promise(
|
|
19253
|
+
() => clack.confirm({
|
|
19254
|
+
message: params.promptMessage,
|
|
19255
|
+
initialValue: true
|
|
19256
|
+
})
|
|
19257
|
+
);
|
|
19258
|
+
if (clack.isCancel(confirmed)) {
|
|
19259
|
+
return yield* new InitError({ message: params.cancelMessage });
|
|
19260
|
+
}
|
|
19261
|
+
return confirmed;
|
|
19262
|
+
});
|
|
19263
|
+
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);
|
|
19264
|
+
var missingInitFlags = (flags, choices, cwd) => Effect_exports.gen(function* () {
|
|
19265
|
+
const tracker = Option_exports.getOrUndefined(flags.issueTracker);
|
|
19266
|
+
const { template } = flags;
|
|
19267
|
+
const missing = [];
|
|
19268
|
+
if (flags.agent._tag === "None") {
|
|
19269
|
+
missing.push("--agent");
|
|
19270
|
+
}
|
|
19271
|
+
if (flags.sandbox._tag === "None") {
|
|
19272
|
+
missing.push("--sandbox");
|
|
19273
|
+
}
|
|
19274
|
+
if (tracker === void 0) {
|
|
19275
|
+
missing.push("--issue-tracker");
|
|
19276
|
+
}
|
|
19277
|
+
if (template._tag === "None") {
|
|
19278
|
+
missing.push("--template");
|
|
19279
|
+
}
|
|
19280
|
+
if (tracker === "github-issues" && choices.createLabel._tag === "None") {
|
|
19281
|
+
missing.push("--create-label");
|
|
19282
|
+
}
|
|
19283
|
+
if (yield* asksToInstallTemplateDeps(
|
|
19284
|
+
template,
|
|
19285
|
+
choices.installTemplateDeps,
|
|
19286
|
+
cwd
|
|
19287
|
+
)) {
|
|
19288
|
+
missing.push("--install-template-deps");
|
|
19289
|
+
}
|
|
19290
|
+
const sandboxName = Option_exports.getOrUndefined(flags.sandbox);
|
|
19291
|
+
const providerHasImage = sandboxName === void 0 || getSandboxProvider(sandboxName)?.image !== void 0;
|
|
19292
|
+
if (tracker !== "custom" && providerHasImage && choices.buildImage._tag === "None") {
|
|
19293
|
+
missing.push("--build-image");
|
|
19294
|
+
}
|
|
19295
|
+
return missing;
|
|
19296
|
+
});
|
|
19297
|
+
var selectAgent = (flag, isInteractive) => selectName({
|
|
19298
|
+
flag,
|
|
19299
|
+
flagName: "--agent",
|
|
19300
|
+
isInteractive,
|
|
19301
|
+
cancelMessage: "Agent selection cancelled.",
|
|
19302
|
+
prompt: {
|
|
19303
|
+
message: "Select an agent:",
|
|
19304
|
+
initialValue: "claude-code",
|
|
19305
|
+
options: listAgents().map((a) => ({
|
|
19306
|
+
value: a.name,
|
|
19307
|
+
label: a.label,
|
|
19308
|
+
hint: `Default model: ${a.defaultModel}`
|
|
19309
|
+
}))
|
|
19310
|
+
}
|
|
19311
|
+
}).pipe(
|
|
19312
|
+
Effect_exports.flatMap((name) => registryEntry(getAgent(name), `agent "${name}"`))
|
|
19313
|
+
);
|
|
19314
|
+
var selectSandboxProvider = (flag, isInteractive) => {
|
|
19315
|
+
const sandboxChoices = listSandboxProviderChoices(process.platform);
|
|
19316
|
+
const recommendedSandbox = sandboxChoices.find((c) => c.recommended);
|
|
19317
|
+
return selectName({
|
|
19318
|
+
flag,
|
|
19319
|
+
flagName: "--sandbox",
|
|
19320
|
+
isInteractive,
|
|
19321
|
+
cancelMessage: "Sandbox provider selection cancelled.",
|
|
19322
|
+
prompt: {
|
|
19323
|
+
message: "Select a sandbox provider:",
|
|
19324
|
+
...recommendedSandbox === void 0 ? {} : { initialValue: recommendedSandbox.entry.name },
|
|
19325
|
+
options: sandboxChoices.map(({ entry, recommended }) => ({
|
|
19326
|
+
value: entry.name,
|
|
19327
|
+
label: recommended ? `${entry.label} (recommended)` : entry.label
|
|
19328
|
+
}))
|
|
19329
|
+
}
|
|
19330
|
+
}).pipe(
|
|
19331
|
+
Effect_exports.flatMap(
|
|
19332
|
+
(name) => registryEntry(getSandboxProvider(name), `sandbox provider "${name}"`)
|
|
19333
|
+
)
|
|
19334
|
+
);
|
|
19335
|
+
};
|
|
19336
|
+
var selectIssueTracker = (flag, isInteractive) => selectName({
|
|
19337
|
+
flag,
|
|
19338
|
+
flagName: "--issue-tracker",
|
|
19339
|
+
isInteractive,
|
|
19340
|
+
cancelMessage: "Issue tracker selection cancelled.",
|
|
19341
|
+
prompt: {
|
|
19342
|
+
message: "Select an issue tracker:",
|
|
19343
|
+
initialValue: "github-issues",
|
|
19344
|
+
options: listIssueTrackers().map((b) => ({
|
|
19345
|
+
value: b.name,
|
|
19346
|
+
label: b.label
|
|
19347
|
+
}))
|
|
19348
|
+
}
|
|
19349
|
+
}).pipe(
|
|
19350
|
+
Effect_exports.flatMap(
|
|
19351
|
+
(name) => registryEntry(getIssueTracker(name), `issue tracker "${name}"`)
|
|
19352
|
+
)
|
|
19353
|
+
);
|
|
19354
|
+
var selectTemplate = (flag, isInteractive) => selectName({
|
|
19355
|
+
flag,
|
|
19356
|
+
flagName: "--template",
|
|
19357
|
+
isInteractive,
|
|
19358
|
+
cancelMessage: "Template selection cancelled.",
|
|
19359
|
+
prompt: {
|
|
19360
|
+
message: "Select a template:",
|
|
19361
|
+
initialValue: "blank",
|
|
19362
|
+
options: listTemplates().map((tmpl) => ({
|
|
19363
|
+
value: tmpl.name,
|
|
19364
|
+
label: tmpl.name,
|
|
19365
|
+
hint: tmpl.description
|
|
19366
|
+
}))
|
|
19367
|
+
}
|
|
19368
|
+
});
|
|
19369
|
+
var selectInitChoices = (flags, isInteractive) => Effect_exports.gen(function* () {
|
|
19370
|
+
const agent = yield* selectAgent(flags.agent, isInteractive);
|
|
19371
|
+
const model = flags.model._tag === "Some" ? flags.model.value : agent.defaultModel;
|
|
19372
|
+
const sandboxProvider = yield* selectSandboxProvider(
|
|
19373
|
+
flags.sandbox,
|
|
19374
|
+
isInteractive
|
|
19375
|
+
);
|
|
19376
|
+
const issueTracker = yield* selectIssueTracker(
|
|
19377
|
+
flags.issueTracker,
|
|
19378
|
+
isInteractive
|
|
19379
|
+
);
|
|
19380
|
+
const template = yield* selectTemplate(flags.template, isInteractive);
|
|
19381
|
+
return { agent, model, sandboxProvider, issueTracker, template };
|
|
19382
|
+
});
|
|
19383
|
+
var offerSandcastleLabel = (selection, choice4, context) => Effect_exports.gen(function* () {
|
|
19384
|
+
if (selection.issueTracker.name !== "github-issues") {
|
|
19385
|
+
return false;
|
|
19386
|
+
}
|
|
19387
|
+
const shouldCreateLabel = yield* resolveConfirmFlag({
|
|
19388
|
+
choice: choice4,
|
|
19389
|
+
flag: "--create-label",
|
|
19390
|
+
isInteractive: context.isInteractive,
|
|
19391
|
+
promptMessage: 'Create a "Sandcastle" GitHub label? (Templates filter issues by this label)',
|
|
19392
|
+
cancelMessage: "Label selection cancelled."
|
|
19393
|
+
});
|
|
19394
|
+
if (shouldCreateLabel) {
|
|
19395
|
+
yield* Effect_exports.try({
|
|
19396
|
+
try: () => execSync(
|
|
19397
|
+
'gh label create "Sandcastle" --description "Issues for Sandcastle to work on" --color "F9A825" 2>/dev/null',
|
|
19398
|
+
{ cwd: context.cwd, stdio: "ignore" }
|
|
19399
|
+
),
|
|
19400
|
+
catch: () => void 0
|
|
19401
|
+
}).pipe(Effect_exports.ignore);
|
|
19402
|
+
}
|
|
19403
|
+
return shouldCreateLabel;
|
|
19404
|
+
});
|
|
19405
|
+
var warnHostPrerequisites = (selection, cwd) => Effect_exports.gen(function* () {
|
|
19406
|
+
const d = yield* Display;
|
|
19407
|
+
const { sandboxProvider } = selection;
|
|
19408
|
+
const preflightWarning = sandboxProviderPreflightWarning(sandboxProvider);
|
|
19409
|
+
if (preflightWarning !== void 0) {
|
|
19410
|
+
yield* d.status(preflightWarning, "warn");
|
|
19411
|
+
}
|
|
19412
|
+
if (sandboxProvider.image === void 0) {
|
|
19413
|
+
const agentWarning = yield* agentCliWarning(
|
|
19414
|
+
selection.agent,
|
|
19415
|
+
sandboxProvider
|
|
19416
|
+
);
|
|
19417
|
+
if (agentWarning !== void 0) {
|
|
19418
|
+
yield* d.status(agentWarning, "warn");
|
|
19419
|
+
}
|
|
19420
|
+
}
|
|
19421
|
+
if (selection.issueTracker.name === "beads" && sandboxProvider.image !== void 0) {
|
|
19422
|
+
const warning = beadsVersionWarning(yield* detectHostBdVersion(cwd));
|
|
19423
|
+
if (warning !== void 0) {
|
|
19424
|
+
yield* d.status(warning, "warn");
|
|
19425
|
+
}
|
|
19426
|
+
}
|
|
19427
|
+
});
|
|
19428
|
+
var tryInstall = (installCmd, cwd) => Effect_exports.sync(() => {
|
|
19429
|
+
try {
|
|
19430
|
+
execSync(installCmd, { cwd, stdio: "ignore" });
|
|
19431
|
+
return true;
|
|
19432
|
+
} catch {
|
|
19433
|
+
return false;
|
|
19434
|
+
}
|
|
19435
|
+
});
|
|
19436
|
+
var offerTemplateDeps = (template, choice4, context) => Effect_exports.gen(function* () {
|
|
19437
|
+
const { cwd, packageManager } = context;
|
|
19438
|
+
if (!getTemplateDependencies(template).includes("zod")) {
|
|
19439
|
+
return [];
|
|
19440
|
+
}
|
|
19441
|
+
if (yield* hostHasDependency(cwd, "zod")) {
|
|
19442
|
+
return ["zod"];
|
|
19443
|
+
}
|
|
19444
|
+
const installCmd = addDependencyCommand(packageManager, "zod");
|
|
19445
|
+
const shouldInstall = yield* resolveConfirmFlag({
|
|
19446
|
+
choice: choice4,
|
|
19447
|
+
flag: "--install-template-deps",
|
|
19448
|
+
isInteractive: context.isInteractive,
|
|
19449
|
+
promptMessage: `The ${template} template needs a schema validator. Install zod now (\`${installCmd}\`)?`,
|
|
19450
|
+
cancelMessage: "Install-template-deps selection cancelled."
|
|
19451
|
+
});
|
|
19452
|
+
if (!shouldInstall) {
|
|
19453
|
+
return [];
|
|
19454
|
+
}
|
|
19455
|
+
const d = yield* Display;
|
|
19456
|
+
const installed = yield* tryInstall(installCmd, cwd);
|
|
19457
|
+
yield* installed ? d.status(`Installed zod with ${packageManager}.`, "success") : d.status(
|
|
19458
|
+
`Couldn't install zod automatically. Run \`${installCmd}\` before running the agent.`,
|
|
19459
|
+
"warn"
|
|
19460
|
+
);
|
|
19461
|
+
return installed ? ["zod"] : [];
|
|
19462
|
+
});
|
|
19463
|
+
var buildDefaultImage = (sandboxProvider, imageName, cwd) => {
|
|
19464
|
+
const containerfileDir = join(cwd, CONFIG_DIR);
|
|
19465
|
+
return sandboxProvider.name === "podman" ? buildImage2(imageName, containerfileDir) : buildImage(imageName, containerfileDir, {
|
|
19466
|
+
buildArgs: defaultUidBuildArgs()
|
|
19467
|
+
});
|
|
19468
|
+
};
|
|
19469
|
+
var finishInit = (selection, choice4, context) => Effect_exports.gen(function* () {
|
|
19470
|
+
const d = yield* Display;
|
|
19471
|
+
const { sandboxProvider, issueTracker } = selection;
|
|
19472
|
+
const { imageName } = context;
|
|
19473
|
+
const providerLabel = sandboxProvider.label;
|
|
19474
|
+
const providerImage = sandboxProvider.image;
|
|
19475
|
+
if (providerImage === void 0) {
|
|
19476
|
+
return yield* d.status(
|
|
19477
|
+
issueTracker.name === "custom" ? "Init complete! Your custom issue tracker isn't configured yet \u2014 see the steps below." : "Init complete!",
|
|
19478
|
+
"success"
|
|
19479
|
+
);
|
|
19480
|
+
}
|
|
19481
|
+
if (issueTracker.name === "custom") {
|
|
19482
|
+
return yield* d.status(
|
|
19483
|
+
"Init complete! Your custom issue tracker isn't configured yet \u2014 see the steps below before building.",
|
|
19484
|
+
"success"
|
|
19485
|
+
);
|
|
19486
|
+
}
|
|
19487
|
+
const shouldBuild = yield* resolveConfirmFlag({
|
|
19488
|
+
choice: choice4,
|
|
19489
|
+
flag: "--build-image",
|
|
19490
|
+
isInteractive: context.isInteractive,
|
|
19491
|
+
promptMessage: `Build the default ${providerLabel} image now?`,
|
|
19492
|
+
cancelMessage: "Build-image selection cancelled."
|
|
19493
|
+
});
|
|
19494
|
+
if (!shouldBuild) {
|
|
19495
|
+
return yield* d.status(
|
|
19496
|
+
`Init complete! Run \`${buildImageShellCommand(providerImage, context.customImageName)}\` to build the ${providerLabel} image later.`,
|
|
19497
|
+
"success"
|
|
19498
|
+
);
|
|
19499
|
+
}
|
|
19500
|
+
yield* d.spinner(
|
|
19501
|
+
`Building ${providerLabel} image '${imageName}'...`,
|
|
19502
|
+
buildDefaultImage(sandboxProvider, imageName, context.cwd)
|
|
19503
|
+
);
|
|
19504
|
+
yield* d.status("Init complete! Image built successfully.", "success");
|
|
19505
|
+
});
|
|
19506
|
+
var decideInit = (flags) => Effect_exports.gen(function* () {
|
|
19507
|
+
const cwd = process.cwd();
|
|
19508
|
+
yield* validateRegistryFlags(flags);
|
|
19509
|
+
const choices = {
|
|
19510
|
+
createLabel: choiceToTriBool(flags.createLabel),
|
|
19511
|
+
buildImage: choiceToTriBool(flags.buildImage),
|
|
19512
|
+
installTemplateDeps: choiceToTriBool(flags.installTemplateDeps)
|
|
19513
|
+
};
|
|
19514
|
+
const isInteractive = process.stdin.isTTY === true;
|
|
19515
|
+
if (!isInteractive) {
|
|
19516
|
+
const missing = yield* missingInitFlags(flags, choices, cwd);
|
|
19517
|
+
yield* failInitUnless(
|
|
19518
|
+
missing.length === 0,
|
|
19519
|
+
nonInteractiveMessage(missing)
|
|
19520
|
+
);
|
|
19521
|
+
}
|
|
19522
|
+
const selection = yield* selectInitChoices(flags, isInteractive);
|
|
19523
|
+
return { cwd, isInteractive, choices, selection };
|
|
19524
|
+
});
|
|
19525
|
+
var scaffoldSelection = (selection, options3) => scaffold(options3.cwd, {
|
|
19526
|
+
agent: selection.agent,
|
|
19527
|
+
model: selection.model,
|
|
19528
|
+
templateName: selection.template,
|
|
19529
|
+
createLabel: options3.createLabel,
|
|
19530
|
+
issueTracker: selection.issueTracker,
|
|
19531
|
+
sandboxProvider: selection.sandboxProvider,
|
|
19532
|
+
imageName: selection.sandboxProvider.image === void 0 ? void 0 : options3.customImageName
|
|
19533
|
+
}).pipe(
|
|
19534
|
+
Effect_exports.mapError(
|
|
19535
|
+
(e) => new InitError({
|
|
19536
|
+
message: e instanceof Error ? e.message : e
|
|
19537
|
+
})
|
|
19538
|
+
)
|
|
19539
|
+
);
|
|
19540
|
+
var printLines = (lines2) => Effect_exports.gen(function* () {
|
|
19541
|
+
const d = yield* Display;
|
|
19542
|
+
for (const [i, line4] of lines2.entries()) {
|
|
19543
|
+
yield* d.text(i === 0 ? line4 : styleText("dim", line4));
|
|
19544
|
+
}
|
|
19545
|
+
});
|
|
19546
|
+
var completeInit = (selection, choices, context) => Effect_exports.gen(function* () {
|
|
19547
|
+
const { cwd, flags } = context;
|
|
19548
|
+
const packageManager = yield* detectPackageManager(cwd);
|
|
19549
|
+
const installedDependencies = yield* offerTemplateDeps(
|
|
19550
|
+
selection.template,
|
|
19551
|
+
choices.installTemplateDeps,
|
|
19552
|
+
{ ...context, packageManager }
|
|
19553
|
+
);
|
|
19554
|
+
yield* finishInit(selection, choices.buildImage, {
|
|
19555
|
+
...context,
|
|
19556
|
+
imageName: resolveImageName(flags.imageName, cwd),
|
|
19557
|
+
customImageName: Option_exports.getOrUndefined(flags.imageName)
|
|
19558
|
+
});
|
|
19559
|
+
yield* printLines(
|
|
19560
|
+
getNextStepsLines(
|
|
19561
|
+
selection.template,
|
|
19562
|
+
context.mainFilename,
|
|
19563
|
+
selection.issueTracker,
|
|
19564
|
+
selection.agent,
|
|
19565
|
+
packageManager,
|
|
19566
|
+
installedDependencies,
|
|
19567
|
+
selection.sandboxProvider
|
|
19568
|
+
)
|
|
19569
|
+
);
|
|
19570
|
+
});
|
|
18896
19571
|
var initCommand = Command_exports.make(
|
|
18897
19572
|
"init",
|
|
18898
19573
|
{
|
|
@@ -18906,308 +19581,32 @@ var initCommand = Command_exports.make(
|
|
|
18906
19581
|
buildImage: buildImageOption,
|
|
18907
19582
|
installTemplateDeps: installTemplateDepsOption
|
|
18908
19583
|
},
|
|
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* () {
|
|
19584
|
+
(flags) => Effect_exports.gen(function* () {
|
|
18920
19585
|
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
|
|
19586
|
+
const { cwd, isInteractive, choices, selection } = yield* decideInit(flags);
|
|
19587
|
+
const context = { cwd, isInteractive };
|
|
19588
|
+
const shouldCreateLabel = yield* offerSandcastleLabel(
|
|
19589
|
+
selection,
|
|
19590
|
+
choices.createLabel,
|
|
19591
|
+
context
|
|
18961
19592
|
);
|
|
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
19593
|
const scaffoldResult = yield* d.spinner(
|
|
19119
19594
|
"Scaffolding .sandcastle/ config directory...",
|
|
19120
|
-
|
|
19121
|
-
|
|
19122
|
-
model: selectedModel,
|
|
19123
|
-
templateName: selectedTemplate,
|
|
19595
|
+
scaffoldSelection(selection, {
|
|
19596
|
+
cwd,
|
|
19124
19597
|
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
|
|
19598
|
+
// Only an explicit --image-name is written into the scaffold;
|
|
19599
|
+
// without it the sandbox factory's own default resolves to the
|
|
19600
|
+
// same name as resolveImageName.
|
|
19601
|
+
customImageName: Option_exports.getOrUndefined(flags.imageName)
|
|
19602
|
+
})
|
|
19207
19603
|
);
|
|
19208
|
-
|
|
19209
|
-
|
|
19210
|
-
|
|
19604
|
+
yield* warnHostPrerequisites(selection, cwd);
|
|
19605
|
+
yield* completeInit(selection, choices, {
|
|
19606
|
+
...context,
|
|
19607
|
+
flags,
|
|
19608
|
+
mainFilename: scaffoldResult.mainFilename
|
|
19609
|
+
});
|
|
19211
19610
|
})
|
|
19212
19611
|
);
|
|
19213
19612
|
var dockerfileOption = Options_exports.file("dockerfile").pipe(
|
|
@@ -19343,11 +19742,8 @@ var cli = Command_exports.run(sandcastle, {
|
|
|
19343
19742
|
// src/terminalCleanup.ts
|
|
19344
19743
|
var SHOW_CURSOR = "\x1B[?25h";
|
|
19345
19744
|
var makeTerminalCleanupHandler = (stdin, stdout) => () => {
|
|
19346
|
-
if (stdin.isTTY && stdin.setRawMode) {
|
|
19347
|
-
|
|
19348
|
-
stdin.setRawMode(false);
|
|
19349
|
-
} catch {
|
|
19350
|
-
}
|
|
19745
|
+
if (stdin.isTTY === true && stdin.setRawMode !== void 0) {
|
|
19746
|
+
stdin.setRawMode(false);
|
|
19351
19747
|
}
|
|
19352
19748
|
stdout.write(SHOW_CURSOR);
|
|
19353
19749
|
};
|
|
@@ -19358,10 +19754,8 @@ var setupTerminalCleanup = () => {
|
|
|
19358
19754
|
// src/main.ts
|
|
19359
19755
|
setupTerminalCleanup();
|
|
19360
19756
|
var mainLayer = Layer_exports.merge(NodeContext_exports.layer, ClackDisplay.layer);
|
|
19361
|
-
|
|
19362
|
-
withFriendlyErrors,
|
|
19363
|
-
Effect_exports.provide(mainLayer),
|
|
19364
|
-
NodeRuntime_exports.runMain
|
|
19757
|
+
NodeRuntime_exports.runMain(
|
|
19758
|
+
cli(process.argv).pipe(withFriendlyErrors, Effect_exports.provide(mainLayer))
|
|
19365
19759
|
);
|
|
19366
19760
|
//# sourceMappingURL=main.js.map
|
|
19367
19761
|
//# sourceMappingURL=main.js.map
|