trellis 3.2.0 → 3.2.3
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/CHANGELOG.md +7 -0
- package/README.md +61 -171
- package/dist/browser/index.d.ts +18 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +95 -0
- package/dist/{chunk-3ETIIPPB.js → chunk-2AACZRII.js} +312 -30
- package/dist/{chunk-3GDRZTAW.js → chunk-5KSGGKET.js} +1 -1
- package/dist/{chunk-MBNBTJCR.js → chunk-6GEZ6DN5.js} +2 -2
- package/dist/chunk-6RWGFC3N.js +403 -0
- package/dist/{chunk-X762XWVC.js → chunk-7DUMWO5L.js} +1 -1
- package/dist/chunk-CAG4FULI.js +121 -0
- package/dist/{chunk-GD5QJXSS.js → chunk-FWRS4CSC.js} +2 -2
- package/dist/{chunk-36VSSTL7.js → chunk-GU374KWZ.js} +1 -1
- package/dist/{chunk-BJ7EZ7FP.js → chunk-JHHEXEDM.js} +17 -0
- package/dist/{chunk-7WQGTFVJ.js → chunk-L5N5PR2S.js} +130 -75
- package/dist/{chunk-BXSTJVE3.js → chunk-N6MYZT4O.js} +2 -1
- package/dist/chunk-NWSW5YNS.js +225 -0
- package/dist/{chunk-HO4TURXW.js → chunk-S3XLFZ27.js} +28 -11
- package/dist/{chunk-BQBUVMRN.js → chunk-S6GBJ2ZB.js} +25 -14
- package/dist/{chunk-B3ZIFA2O.js → chunk-VBYUTRXX.js} +1 -1
- package/dist/cli/deploy-cli.d.ts +18 -0
- package/dist/cli/deploy-cli.d.ts.map +1 -0
- package/dist/cli/deploy-cli.js +67 -0
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +153 -100
- package/dist/client/index.browser.d.ts +29 -0
- package/dist/client/index.browser.d.ts.map +1 -0
- package/dist/client/index.browser.js +64 -0
- package/dist/client/index.js +10 -10
- package/dist/client/sdk.browser.d.ts +131 -0
- package/dist/client/sdk.browser.d.ts.map +1 -0
- package/dist/{sdk-LZ7W3EEY.js → client/sdk.browser.js} +2 -2
- package/dist/client/sdk.js +1 -1
- package/dist/db/index.js +16 -16
- package/dist/db/inspector.js +6 -6
- package/dist/decisions/index.js +2 -2
- package/dist/embeddings/auto-embed.d.ts.map +1 -1
- package/dist/embeddings/index.js +1 -1
- package/dist/embeddings/store.d.ts.map +1 -1
- package/dist/engine.d.ts +27 -7
- package/dist/engine.d.ts.map +1 -1
- package/dist/index.js +6 -6
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/react/index.js +2 -2
- package/dist/react/schema-hooks.js +7 -7
- package/dist/{remote-manager-SG545WNY.js → remote-manager-ODE3T2KR.js} +5 -5
- package/dist/scaffold/seed.d.ts.map +1 -1
- package/dist/scaffold/write.d.ts +1 -1
- package/dist/scaffold/write.d.ts.map +1 -1
- package/dist/schema/index.js +4 -3
- package/dist/server/cors.d.ts +13 -0
- package/dist/server/cors.d.ts.map +1 -0
- package/dist/server/deploy-meta.d.ts +25 -0
- package/dist/server/deploy-meta.d.ts.map +1 -0
- package/dist/server/deploy.d.ts +8 -3
- package/dist/server/deploy.d.ts.map +1 -1
- package/dist/server/deploy.js +9 -0
- package/dist/server/index.d.ts +5 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +51 -17
- package/dist/server/realtime.d.ts +4 -1
- package/dist/server/realtime.d.ts.map +1 -1
- package/dist/server/server.d.ts +1 -0
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/sprites.d.ts +18 -1
- package/dist/server/sprites.d.ts.map +1 -1
- package/dist/server/tenancy.d.ts +4 -0
- package/dist/server/tenancy.d.ts.map +1 -1
- package/dist/server/usage-meter.d.ts +53 -0
- package/dist/server/usage-meter.d.ts.map +1 -0
- package/dist/{server-IGBIIJSF.js → server-OGVWNDNK.js} +6 -1
- package/dist/sprites-KQGTGM6W.js +27 -0
- package/dist/{tenancy-OP34NFFS.js → tenancy-POMWQP6M.js} +5 -3
- package/dist/vcs/index.js +3 -3
- package/dist/vcs/types.d.ts +2 -0
- package/dist/vcs/types.d.ts.map +1 -1
- package/package.json +17 -6
- package/dist/better-sqlite-backend-PII64VE6.js +0 -159
- package/dist/better-sqlite-backend-VUBVQ7SN.js +0 -209
- package/dist/better-sqlite-backend-Y3AQN65E.js +0 -159
- package/dist/better-sqlite-backend-Y3M7DXOX.js +0 -159
- package/dist/boot-middleware-FJDGVUM4.js +0 -9
- package/dist/boot-middleware-MLJUTLUM.js +0 -9
- package/dist/boot-middleware-ZZPDZNYR.js +0 -9
- package/dist/chunk-276LKLZR.js +0 -359
- package/dist/chunk-2CX5UCRV.js +0 -111
- package/dist/chunk-2ESYSVXG.js +0 -48
- package/dist/chunk-2I5JU73Y.js +0 -340
- package/dist/chunk-2UNSRRNB.js +0 -171
- package/dist/chunk-335UEHQR.js +0 -907
- package/dist/chunk-4CF2L46N.js +0 -29
- package/dist/chunk-5CINODKT.js +0 -41
- package/dist/chunk-5ESGWJ5L.js +0 -45
- package/dist/chunk-5FGLQGMF.js +0 -1676
- package/dist/chunk-5IQZFITY.js +0 -357
- package/dist/chunk-5JWFAQDW.js +0 -150
- package/dist/chunk-62UHTVU3.js +0 -141
- package/dist/chunk-66UJQT2I.js +0 -35
- package/dist/chunk-6RNNVOAS.js +0 -355
- package/dist/chunk-6X23PZ6H.js +0 -969
- package/dist/chunk-7C7LL6MB.js +0 -315
- package/dist/chunk-7F4HM3JG.js +0 -394
- package/dist/chunk-7KJ7T4D3.js +0 -910
- package/dist/chunk-7QQQNUB5.js +0 -92
- package/dist/chunk-7QWJBS72.js +0 -946
- package/dist/chunk-7R36OZK3.js +0 -957
- package/dist/chunk-7UPKCOHE.js +0 -946
- package/dist/chunk-A3BONW34.js +0 -35
- package/dist/chunk-AHMDVHBL.js +0 -141
- package/dist/chunk-AW6A4OZY.js +0 -171
- package/dist/chunk-BJ5EKCJ5.js +0 -458
- package/dist/chunk-BRGYDO7D.js +0 -223
- package/dist/chunk-C5KPSEDN.js +0 -359
- package/dist/chunk-CCTNYTUC.js +0 -940
- package/dist/chunk-CYQ2OVD2.js +0 -35
- package/dist/chunk-DDAK7YOE.js +0 -299
- package/dist/chunk-DRILKBY6.js +0 -965
- package/dist/chunk-DXE24HNN.js +0 -45
- package/dist/chunk-E7ICUNW7.js +0 -945
- package/dist/chunk-EAL2PUOE.js +0 -10022
- package/dist/chunk-ELT7MLZB.js +0 -109
- package/dist/chunk-EWEIRF6G.js +0 -171
- package/dist/chunk-F5VDGQJC.js +0 -120
- package/dist/chunk-FCPL3IEQ.js +0 -98
- package/dist/chunk-FDPKYSV7.js +0 -96
- package/dist/chunk-FES3TC24.js +0 -171
- package/dist/chunk-FF36CQHZ.js +0 -61
- package/dist/chunk-FOWKR5TW.js +0 -129
- package/dist/chunk-FZVCXDYW.js +0 -150
- package/dist/chunk-G3XIHPSQ.js +0 -361
- package/dist/chunk-GKJLYLVU.js +0 -359
- package/dist/chunk-GNXHXNVQ.js +0 -113
- package/dist/chunk-GSR6ILTM.js +0 -277
- package/dist/chunk-GWRIMRSX.js +0 -45
- package/dist/chunk-H72UW2HJ.js +0 -45
- package/dist/chunk-HGI74PXB.js +0 -7417
- package/dist/chunk-HGRA37LO.js +0 -145
- package/dist/chunk-HXSRQO3L.js +0 -145
- package/dist/chunk-IG2X2BVO.js +0 -373
- package/dist/chunk-IIJVDD54.js +0 -373
- package/dist/chunk-IUWVEEOX.js +0 -145
- package/dist/chunk-IX4BBOIT.js +0 -394
- package/dist/chunk-IXU4RMQM.js +0 -349
- package/dist/chunk-J6OUIION.js +0 -857
- package/dist/chunk-K46RNFDE.js +0 -171
- package/dist/chunk-KAGU2XMY.js +0 -359
- package/dist/chunk-KCVYJNVX.js +0 -394
- package/dist/chunk-KKDRMIV6.js +0 -419
- package/dist/chunk-KYLIQ3YI.js +0 -399
- package/dist/chunk-KZYJJIRN.js +0 -946
- package/dist/chunk-LFOX744K.js +0 -96
- package/dist/chunk-LHOVJEWR.js +0 -7403
- package/dist/chunk-LOPXTPF3.js +0 -120
- package/dist/chunk-LZR3VIFU.js +0 -907
- package/dist/chunk-MCKGQKYU.js +0 -15
- package/dist/chunk-MU6EOS6F.js +0 -0
- package/dist/chunk-MWRQ2TXT.js +0 -357
- package/dist/chunk-NO73OK2I.js +0 -102
- package/dist/chunk-NPE2YJHK.js +0 -394
- package/dist/chunk-NSDXU6QX.js +0 -2213
- package/dist/chunk-NXIRDSZ6.js +0 -145
- package/dist/chunk-NZWFNHCS.js +0 -407
- package/dist/chunk-OB4CMMX6.js +0 -260
- package/dist/chunk-OBKU74FU.js +0 -7411
- package/dist/chunk-OQNDWRDE.js +0 -145
- package/dist/chunk-OVWAJMB6.js +0 -394
- package/dist/chunk-PDHLBTTD.js +0 -45
- package/dist/chunk-PEQNRKLG.js +0 -210
- package/dist/chunk-QERIS7QY.js +0 -7403
- package/dist/chunk-QHA2DM3C.js +0 -373
- package/dist/chunk-QLM4HSYC.js +0 -45
- package/dist/chunk-S2OT3TQJ.js +0 -283
- package/dist/chunk-S5PHSN5K.js +0 -907
- package/dist/chunk-SIAA4J6H.js +0 -21
- package/dist/chunk-SQBNLUIA.js +0 -171
- package/dist/chunk-STLN6A6B.js +0 -355
- package/dist/chunk-U7HV7GU2.js +0 -17
- package/dist/chunk-UGZHOGRA.js +0 -39
- package/dist/chunk-UICF66FS.js +0 -359
- package/dist/chunk-UK3EQREE.js +0 -1078
- package/dist/chunk-UPKPURVY.js +0 -394
- package/dist/chunk-URC74VCN.js +0 -959
- package/dist/chunk-V3G7Q3QQ.js +0 -102
- package/dist/chunk-VUJ6SA55.js +0 -303
- package/dist/chunk-VUJQLIML.js +0 -141
- package/dist/chunk-VWKLKLYB.js +0 -267
- package/dist/chunk-VYC3RZMK.js +0 -277
- package/dist/chunk-WMERMSWI.js +0 -154
- package/dist/chunk-WMR777PO.js +0 -2213
- package/dist/chunk-X46IECAC.js +0 -517
- package/dist/chunk-XEN3OEYY.js +0 -2234
- package/dist/chunk-XZQ66K7A.js +0 -124
- package/dist/chunk-YY3GF7DH.js +0 -7411
- package/dist/chunk-ZE5R3H4C.js +0 -907
- package/dist/chunk-ZHVI7BQN.js +0 -1077
- package/dist/chunk-ZMN5LUB7.js +0 -7411
- package/dist/chunk-ZUV4MD5U.js +0 -94
- package/dist/config-KMY6RRK3.js +0 -19
- package/dist/config-VDMK2DUJ.js +0 -19
- package/dist/db/trellis.css +0 -1
- package/dist/deploy-66EC752W.js +0 -9
- package/dist/deploy-SO7AFK6L.js +0 -9
- package/dist/engine-7GXBM4IT.js +0 -7
- package/dist/engine-NSR6BIF7.js +0 -7
- package/dist/factory-2P64OC7M.js +0 -34
- package/dist/factory-YP4ZZK5K.js +0 -34
- package/dist/import-AJLYHFIA.js +0 -10
- package/dist/launch-explorer-AI6L2AWJ.js +0 -91
- package/dist/query-GJL3CVGN.js +0 -31
- package/dist/query-MBJSK3EB.js +0 -31
- package/dist/query-TJHEVSKL.js +0 -31
- package/dist/query-WUIKOHPE.js +0 -524
- package/dist/remote-manager-BLJZ6KF6.js +0 -224
- package/dist/remote-manager-BPYE46SI.js +0 -223
- package/dist/remote-manager-FMESEAFA.js +0 -224
- package/dist/remote-manager-K2WZ5RHY.js +0 -223
- package/dist/remote-manager-SG5PQKCH.js +0 -224
- package/dist/remote-manager-WGP6MIQZ.js +0 -224
- package/dist/sdk-3KBB3E6V.js +0 -16
- package/dist/sdk-4ZQO6UTU.js +0 -16
- package/dist/sdk-6JA6GV3G.js +0 -16
- package/dist/sdk-6VTP5UTZ.js +0 -16
- package/dist/sdk-7VS6TYCD.js +0 -16
- package/dist/sdk-HQ3FTLRT.js +0 -16
- package/dist/sdk-HZ7NU3XE.js +0 -15
- package/dist/sdk-KBQE2OXT.js +0 -16
- package/dist/sdk-MSCDZ7JU.js +0 -15
- package/dist/sdk-WNZOGO3S.js +0 -15
- package/dist/sdk-YLV33ZCW.js +0 -9
- package/dist/sdk-ZSUD2LLJ.js +0 -16
- package/dist/server-AFXFFBWA.js +0 -11
- package/dist/server-AGHC4VUL.js +0 -11
- package/dist/server-BOH7M4TT.js +0 -13
- package/dist/server-DBUY2KY5.js +0 -11
- package/dist/server-GWBQJPRG.js +0 -11
- package/dist/server-JZZFULVU.js +0 -11
- package/dist/server-L5XAF4M5.js +0 -11
- package/dist/server-NYFUHANA.js +0 -12
- package/dist/server-OABUB2LO.js +0 -12
- package/dist/server-P2CKZWWV.js +0 -12
- package/dist/sprites-RU3E4XQN.js +0 -15
- package/dist/sprites-XVSMQLSI.js +0 -15
- package/dist/sql-wasm-FORCZFHZ.js +0 -2148
- package/dist/sql-wasm-JZH76RLO.js +0 -2148
- package/dist/sqljs-backend-CJQOIQYE.js +0 -266
- package/dist/sqljs-backend-KWXBUDUO.js +0 -266
- package/dist/state-demo.bundle.js +0 -1033
- package/dist/tenancy-CBWYEVUB.js +0 -11
- package/dist/tenancy-FO6WVYFN.js +0 -13
- package/dist/tenancy-FWDBESMX.js +0 -14
- package/dist/tenancy-HGPIS5QA.js +0 -13
- package/dist/tenancy-HXFALA37.js +0 -14
- package/dist/tenancy-S676GLID.js +0 -14
- package/dist/tenancy-V7ARWNNV.js +0 -14
- package/dist/tenancy-ZDN4GXK5.js +0 -13
- package/dist/tenancy-ZT5VMY7B.js +0 -14
- package/dist/vm-config-YZRJ3KUB.js +0 -21
- /package/dist/{chunk-2BRTCEHB.js → chunk-PZ4XYZ4J.js} +0 -0
- /package/dist/{chunk-EO3J7GRP.js → chunk-WXSWA3MV.js} +0 -0
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getDecision,
|
|
3
|
+
getDecisionChain,
|
|
4
|
+
init_decisions,
|
|
5
|
+
queryDecisions,
|
|
6
|
+
recordDecision
|
|
7
|
+
} from "./chunk-GU374KWZ.js";
|
|
1
8
|
import {
|
|
2
9
|
EAVStore,
|
|
3
10
|
init_eav_store
|
|
@@ -59,18 +66,11 @@ import {
|
|
|
59
66
|
unblockIssue,
|
|
60
67
|
updateIssue,
|
|
61
68
|
updateLaneHead
|
|
62
|
-
} from "./chunk-
|
|
63
|
-
import {
|
|
64
|
-
getDecision,
|
|
65
|
-
getDecisionChain,
|
|
66
|
-
init_decisions,
|
|
67
|
-
queryDecisions,
|
|
68
|
-
recordDecision
|
|
69
|
-
} from "./chunk-36VSSTL7.js";
|
|
69
|
+
} from "./chunk-VBYUTRXX.js";
|
|
70
70
|
import {
|
|
71
71
|
DEFAULT_CONFIG,
|
|
72
72
|
init_types
|
|
73
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-N6MYZT4O.js";
|
|
74
74
|
import {
|
|
75
75
|
createVcsOp,
|
|
76
76
|
init_ops,
|
|
@@ -743,7 +743,7 @@ function writeTrellisHooks(rootPath, ide) {
|
|
|
743
743
|
renderCyclePlanningScript(),
|
|
744
744
|
"utf-8"
|
|
745
745
|
);
|
|
746
|
-
const adapterName =
|
|
746
|
+
const adapterName = `${ide}-adapter.sh`;
|
|
747
747
|
writeFileSync2(
|
|
748
748
|
join4(adaptersDir, adapterName),
|
|
749
749
|
renderAdapterScript(ide),
|
|
@@ -757,10 +757,10 @@ function writeTrellisHooks(rootPath, ide) {
|
|
|
757
757
|
"utf-8"
|
|
758
758
|
);
|
|
759
759
|
break;
|
|
760
|
-
case "
|
|
760
|
+
case "devin":
|
|
761
761
|
writeFileSync2(
|
|
762
|
-
join4(rootPath, ".
|
|
763
|
-
JSON.stringify(
|
|
762
|
+
join4(rootPath, ".devin", "hooks.json"),
|
|
763
|
+
JSON.stringify(renderDevinHooksConfig(), null, 2),
|
|
764
764
|
"utf-8"
|
|
765
765
|
);
|
|
766
766
|
break;
|
|
@@ -968,13 +968,13 @@ You are working in a Trellis-tracked repository. See \`.trellis/agents/AGENTS.md
|
|
|
968
968
|
*Auto-generated by Trellis. Run \`trellis seed\` to refresh context.*
|
|
969
969
|
`;
|
|
970
970
|
}
|
|
971
|
-
function
|
|
971
|
+
function renderDevinRules(input) {
|
|
972
972
|
const projectName = input.context.name ?? "this project";
|
|
973
973
|
const domain = input.context.domain ?? "general";
|
|
974
974
|
const eco = input.context.ecosystem ?? "unknown";
|
|
975
975
|
const framework = input.framework && input.framework !== "none" ? input.framework : "vanilla";
|
|
976
976
|
const plugins = input.plugins.length > 0 ? input.plugins.map((p) => `- ${p}`).join("\n") : "(none selected)";
|
|
977
|
-
return `#
|
|
977
|
+
return `# Devin Rules for ${projectName}
|
|
978
978
|
|
|
979
979
|
> Generated by \`trellis init\`
|
|
980
980
|
|
|
@@ -1122,7 +1122,7 @@ if [ -f ".trellis/config.json" ]; then
|
|
|
1122
1122
|
EOF
|
|
1123
1123
|
;;
|
|
1124
1124
|
*)
|
|
1125
|
-
# Default stdout for Cursor/
|
|
1125
|
+
# Default stdout for Cursor/Devin/Claude
|
|
1126
1126
|
echo ""
|
|
1127
1127
|
echo "\u{1F33F} Trellis Context ($ORIGIN):"
|
|
1128
1128
|
echo " Recent memories: $(echo "$CONTEXT_OUTPUT" | jq -r '.entities | length' 2>/dev/null || echo "0")"
|
|
@@ -1332,7 +1332,7 @@ EOF
|
|
|
1332
1332
|
fi
|
|
1333
1333
|
;;
|
|
1334
1334
|
*)
|
|
1335
|
-
# Default stdout for Cursor/
|
|
1335
|
+
# Default stdout for Cursor/Devin/Claude
|
|
1336
1336
|
if [ \${#RECOMMENDATIONS[@]} -gt 0 ]; then
|
|
1337
1337
|
echo ""
|
|
1338
1338
|
echo "\u{1F33F} Trellis Session Summary ($ORIGIN):"
|
|
@@ -1387,17 +1387,17 @@ case "$EVENT_TYPE" in
|
|
|
1387
1387
|
exit 1
|
|
1388
1388
|
;;
|
|
1389
1389
|
esac`;
|
|
1390
|
-
case "
|
|
1390
|
+
case "devin":
|
|
1391
1391
|
return `#!/usr/bin/env bash
|
|
1392
|
-
#
|
|
1393
|
-
# Translates
|
|
1392
|
+
# Devin adapter for Trellis harness
|
|
1393
|
+
# Translates Devin events to normalized contract
|
|
1394
1394
|
set -euo pipefail
|
|
1395
1395
|
|
|
1396
1396
|
# Import desk root detection
|
|
1397
1397
|
source "$(dirname "$0")/../desk-root.sh"
|
|
1398
1398
|
|
|
1399
1399
|
# Set origin
|
|
1400
|
-
export TRELLIS_ORIGIN="
|
|
1400
|
+
export TRELLIS_ORIGIN="devin"
|
|
1401
1401
|
export TRELLIS_DESK_ROOT="$PWD"
|
|
1402
1402
|
|
|
1403
1403
|
# Route based on event type
|
|
@@ -1596,9 +1596,7 @@ function renderCursorHooksConfig() {
|
|
|
1596
1596
|
return {
|
|
1597
1597
|
version: 1,
|
|
1598
1598
|
hooks: {
|
|
1599
|
-
sessionStart: [
|
|
1600
|
-
{ command: hookCmd("session-start"), timeout: 15 }
|
|
1601
|
-
],
|
|
1599
|
+
sessionStart: [{ command: hookCmd("session-start"), timeout: 15 }],
|
|
1602
1600
|
postToolUse: [{ command: hookCmd("post-tool-use"), timeout: 10 }],
|
|
1603
1601
|
afterShellExecution: [{ command: hookCmd("after-shell"), timeout: 10 }],
|
|
1604
1602
|
afterMCPExecution: [{ command: hookCmd("after-mcp"), timeout: 10 }],
|
|
@@ -1607,24 +1605,24 @@ function renderCursorHooksConfig() {
|
|
|
1607
1605
|
}
|
|
1608
1606
|
};
|
|
1609
1607
|
}
|
|
1610
|
-
function
|
|
1608
|
+
function renderDevinHooksConfig() {
|
|
1611
1609
|
return {
|
|
1612
1610
|
hooks: {
|
|
1613
1611
|
pre_user_prompt: [
|
|
1614
1612
|
{
|
|
1615
|
-
command: "bash .cursor/hooks/adapters/
|
|
1613
|
+
command: "bash .cursor/hooks/adapters/devin-adapter.sh pre-prompt",
|
|
1616
1614
|
show_output: true
|
|
1617
1615
|
}
|
|
1618
1616
|
],
|
|
1619
1617
|
post_write_code: [
|
|
1620
1618
|
{
|
|
1621
|
-
command: "bash .cursor/hooks/adapters/
|
|
1619
|
+
command: "bash .cursor/hooks/adapters/devin-adapter.sh post-tool",
|
|
1622
1620
|
show_output: false
|
|
1623
1621
|
}
|
|
1624
1622
|
],
|
|
1625
1623
|
post_cascade_response: [
|
|
1626
1624
|
{
|
|
1627
|
-
command: "bash .cursor/hooks/adapters/
|
|
1625
|
+
command: "bash .cursor/hooks/adapters/devin-adapter.sh post-response",
|
|
1628
1626
|
show_output: true
|
|
1629
1627
|
}
|
|
1630
1628
|
]
|
|
@@ -1747,7 +1745,7 @@ function renderGeminiHooksConfig() {
|
|
|
1747
1745
|
type: "command",
|
|
1748
1746
|
command: "bash .cursor/hooks/adapters/gemini-adapter.sh before-agent",
|
|
1749
1747
|
timeout: 15e3,
|
|
1750
|
-
description: "Mirror
|
|
1748
|
+
description: "Mirror Devin pre_user_prompt desk context refresh"
|
|
1751
1749
|
}
|
|
1752
1750
|
]
|
|
1753
1751
|
}
|
|
@@ -1809,18 +1807,18 @@ function writeIdeScaffold(rootPath, input) {
|
|
|
1809
1807
|
}
|
|
1810
1808
|
break;
|
|
1811
1809
|
}
|
|
1812
|
-
case "
|
|
1813
|
-
const
|
|
1814
|
-
if (!existsSync3(
|
|
1815
|
-
mkdirSync2(
|
|
1810
|
+
case "devin": {
|
|
1811
|
+
const devinDir = join4(rootPath, ".devin");
|
|
1812
|
+
if (!existsSync3(devinDir)) {
|
|
1813
|
+
mkdirSync2(devinDir, { recursive: true });
|
|
1816
1814
|
}
|
|
1817
1815
|
writeFileSync2(
|
|
1818
|
-
join4(
|
|
1819
|
-
|
|
1816
|
+
join4(devinDir, "rules.md"),
|
|
1817
|
+
renderDevinRules(fullInput),
|
|
1820
1818
|
"utf-8"
|
|
1821
1819
|
);
|
|
1822
1820
|
if (footprint === "full") {
|
|
1823
|
-
writeTrellisHooks(rootPath, "
|
|
1821
|
+
writeTrellisHooks(rootPath, "devin");
|
|
1824
1822
|
}
|
|
1825
1823
|
break;
|
|
1826
1824
|
}
|
|
@@ -6051,7 +6049,7 @@ var init_engine = __esm({
|
|
|
6051
6049
|
"vcs:issueBlock",
|
|
6052
6050
|
"vcs:issueUnblock"
|
|
6053
6051
|
]);
|
|
6054
|
-
TrellisVcsEngine = class {
|
|
6052
|
+
TrellisVcsEngine = class _TrellisVcsEngine {
|
|
6055
6053
|
config;
|
|
6056
6054
|
store;
|
|
6057
6055
|
opLog;
|
|
@@ -6080,44 +6078,41 @@ var init_engine = __esm({
|
|
|
6080
6078
|
ignorePatterns: mergedIgnore,
|
|
6081
6079
|
debounceMs: opts.debounceMs ?? DEFAULT_CONFIG.debounceMs,
|
|
6082
6080
|
defaultBranch: opts.defaultBranch ?? DEFAULT_CONFIG.defaultBranch,
|
|
6083
|
-
dbPath: opts.dbPath ?? DEFAULT_CONFIG.dbPath
|
|
6081
|
+
dbPath: opts.dbPath ?? DEFAULT_CONFIG.dbPath,
|
|
6082
|
+
indexWorkspace: opts.indexWorkspace ?? DEFAULT_CONFIG.indexWorkspace
|
|
6084
6083
|
};
|
|
6085
6084
|
this.agentId = opts.agentId ?? `agent:${process.env.USER ?? "unknown"}`;
|
|
6086
6085
|
this.store = new EAVStore();
|
|
6087
6086
|
this.opLog = opts.opLog ?? new JsonOpLog(join5(this.config.rootPath, ".trellis", "ops.json"));
|
|
6088
6087
|
}
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
ensureTrellisGitignoreEntry(this.config.rootPath);
|
|
6097
|
-
const trellisDir = join5(this.config.rootPath, ".trellis");
|
|
6098
|
-
if (!existsSync4(trellisDir)) {
|
|
6099
|
-
mkdirSync3(trellisDir, { recursive: true });
|
|
6088
|
+
readPersistedConfig() {
|
|
6089
|
+
const configPath = join5(this.config.rootPath, ".trellis", "config.json");
|
|
6090
|
+
if (!existsSync4(configPath)) return null;
|
|
6091
|
+
try {
|
|
6092
|
+
return JSON.parse(readFileSync4(configPath, "utf-8"));
|
|
6093
|
+
} catch {
|
|
6094
|
+
return null;
|
|
6100
6095
|
}
|
|
6101
|
-
|
|
6102
|
-
|
|
6096
|
+
}
|
|
6097
|
+
writePersistedConfig(createdAt) {
|
|
6098
|
+
const existing = this.readPersistedConfig();
|
|
6103
6099
|
const persistedConfig = {
|
|
6104
6100
|
rootPath: this.config.rootPath,
|
|
6105
6101
|
ignorePatterns: this.config.ignorePatterns,
|
|
6106
6102
|
debounceMs: this.config.debounceMs,
|
|
6107
6103
|
defaultBranch: this.config.defaultBranch,
|
|
6104
|
+
indexWorkspace: this.config.indexWorkspace,
|
|
6108
6105
|
agentId: this.agentId,
|
|
6109
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
6106
|
+
createdAt: createdAt ?? existing?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
6110
6107
|
};
|
|
6108
|
+
const configPath = join5(this.config.rootPath, ".trellis", "config.json");
|
|
6111
6109
|
writeFileSync3(configPath, JSON.stringify(persistedConfig, null, 2));
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
}
|
|
6119
|
-
});
|
|
6120
|
-
await this.applyOp(branchOp);
|
|
6110
|
+
return persistedConfig;
|
|
6111
|
+
}
|
|
6112
|
+
async indexExistingFiles(opts) {
|
|
6113
|
+
if (!this._blobStore) {
|
|
6114
|
+
this._blobStore = new BlobStore(join5(this.config.rootPath, ".trellis"));
|
|
6115
|
+
}
|
|
6121
6116
|
const scanner = new FileWatcher({
|
|
6122
6117
|
rootPath: this.config.rootPath,
|
|
6123
6118
|
ignorePatterns: [...this.config.ignorePatterns, ".trellis"],
|
|
@@ -6125,7 +6120,7 @@ var init_engine = __esm({
|
|
|
6125
6120
|
onEvent: () => {
|
|
6126
6121
|
}
|
|
6127
6122
|
});
|
|
6128
|
-
const
|
|
6123
|
+
const scanEvents = await scanner.scan({
|
|
6129
6124
|
onProgress: (progress) => {
|
|
6130
6125
|
if (progress.phase === "done") {
|
|
6131
6126
|
return;
|
|
@@ -6138,13 +6133,15 @@ var init_engine = __esm({
|
|
|
6138
6133
|
});
|
|
6139
6134
|
}
|
|
6140
6135
|
});
|
|
6141
|
-
|
|
6136
|
+
const trackedPaths = new Set(this.trackedFiles().map((f) => f.path));
|
|
6137
|
+
const events = scanEvents.filter((event) => !trackedPaths.has(event.path));
|
|
6142
6138
|
opts?.onProgress?.({
|
|
6143
6139
|
phase: "recording",
|
|
6144
6140
|
current: 0,
|
|
6145
6141
|
total: events.length,
|
|
6146
6142
|
message: `Scanning ${events.length} initial file operations\u2026`
|
|
6147
6143
|
});
|
|
6144
|
+
let opsCreated = 0;
|
|
6148
6145
|
for (const event of events) {
|
|
6149
6146
|
if (event.contentHash) {
|
|
6150
6147
|
try {
|
|
@@ -6165,16 +6162,52 @@ var init_engine = __esm({
|
|
|
6165
6162
|
});
|
|
6166
6163
|
await this.applyOp(op);
|
|
6167
6164
|
opsCreated++;
|
|
6168
|
-
|
|
6169
|
-
if (scannedFiles % 25 === 0 || scannedFiles === events.length) {
|
|
6165
|
+
if (opsCreated % 25 === 0 || opsCreated === events.length) {
|
|
6170
6166
|
opts?.onProgress?.({
|
|
6171
6167
|
phase: "recording",
|
|
6172
|
-
current:
|
|
6168
|
+
current: opsCreated,
|
|
6173
6169
|
total: events.length,
|
|
6174
|
-
message: `Scanned ${
|
|
6170
|
+
message: `Scanned ${opsCreated}/${events.length} initial file ops`
|
|
6175
6171
|
});
|
|
6176
6172
|
}
|
|
6177
6173
|
}
|
|
6174
|
+
return {
|
|
6175
|
+
opsCreated,
|
|
6176
|
+
filesIndexed: events.length
|
|
6177
|
+
};
|
|
6178
|
+
}
|
|
6179
|
+
// -------------------------------------------------------------------------
|
|
6180
|
+
// Lifecycle
|
|
6181
|
+
// -------------------------------------------------------------------------
|
|
6182
|
+
/**
|
|
6183
|
+
* Initialize a new TrellisVCS repo. Creates .trellis/ directory and config.
|
|
6184
|
+
*/
|
|
6185
|
+
async initRepo(opts) {
|
|
6186
|
+
const indexWorkspace = opts?.indexWorkspace ?? this.config.indexWorkspace;
|
|
6187
|
+
this.config.indexWorkspace = indexWorkspace;
|
|
6188
|
+
ensureTrellisGitignoreEntry(this.config.rootPath);
|
|
6189
|
+
const trellisDir = join5(this.config.rootPath, ".trellis");
|
|
6190
|
+
if (!existsSync4(trellisDir)) {
|
|
6191
|
+
mkdirSync3(trellisDir, { recursive: true });
|
|
6192
|
+
}
|
|
6193
|
+
this._blobStore = new BlobStore(trellisDir);
|
|
6194
|
+
this.writePersistedConfig();
|
|
6195
|
+
this.opLog.load();
|
|
6196
|
+
const branchOp = await createVcsOp("vcs:branchCreate", {
|
|
6197
|
+
agentId: this.agentId,
|
|
6198
|
+
previousHash: this.opLog.getLastOp()?.hash,
|
|
6199
|
+
vcs: {
|
|
6200
|
+
branchName: this.config.defaultBranch
|
|
6201
|
+
}
|
|
6202
|
+
});
|
|
6203
|
+
await this.applyOp(branchOp);
|
|
6204
|
+
let opsCreated = 1;
|
|
6205
|
+
let filesIndexed = 0;
|
|
6206
|
+
if (indexWorkspace) {
|
|
6207
|
+
const indexed = await this.indexExistingFiles(opts);
|
|
6208
|
+
opsCreated += indexed.opsCreated;
|
|
6209
|
+
filesIndexed = indexed.filesIndexed;
|
|
6210
|
+
}
|
|
6178
6211
|
await this.flushAutoCheckpoint();
|
|
6179
6212
|
opts?.onProgress?.({
|
|
6180
6213
|
phase: "scaffolding",
|
|
@@ -6183,7 +6216,7 @@ var init_engine = __esm({
|
|
|
6183
6216
|
message: "Inferring project context\u2026"
|
|
6184
6217
|
});
|
|
6185
6218
|
const context = await inferProjectContext(this.config.rootPath, {
|
|
6186
|
-
precomputedFileCount:
|
|
6219
|
+
precomputedFileCount: filesIndexed
|
|
6187
6220
|
});
|
|
6188
6221
|
const profile = loadProfile();
|
|
6189
6222
|
writeAgentScaffold(this.config.rootPath, { profile, context });
|
|
@@ -6191,9 +6224,9 @@ var init_engine = __esm({
|
|
|
6191
6224
|
phase: "done",
|
|
6192
6225
|
current: opsCreated,
|
|
6193
6226
|
total: opsCreated,
|
|
6194
|
-
message: `Initialized repository with ${opsCreated} operations`
|
|
6227
|
+
message: indexWorkspace ? `Initialized repository with ${opsCreated} operations` : "Initialized minimal repository without workspace indexing"
|
|
6195
6228
|
});
|
|
6196
|
-
return { opsCreated, context };
|
|
6229
|
+
return { opsCreated, filesIndexed, indexWorkspace, context };
|
|
6197
6230
|
}
|
|
6198
6231
|
/**
|
|
6199
6232
|
* Open an existing TrellisVCS repo. Loads ops and replays into EAV store.
|
|
@@ -6202,10 +6235,8 @@ var init_engine = __esm({
|
|
|
6202
6235
|
this.opLog.load();
|
|
6203
6236
|
const trellisDir = join5(this.config.rootPath, ".trellis");
|
|
6204
6237
|
this._blobStore = new BlobStore(trellisDir);
|
|
6205
|
-
const
|
|
6206
|
-
if (
|
|
6207
|
-
const raw = readFileSync4(configPath, "utf-8");
|
|
6208
|
-
const persisted = JSON.parse(raw);
|
|
6238
|
+
const persisted = this.readPersistedConfig();
|
|
6239
|
+
if (persisted) {
|
|
6209
6240
|
this.agentId = persisted.agentId;
|
|
6210
6241
|
const filePatterns = readIgnorePatterns(this.config.rootPath);
|
|
6211
6242
|
this.config.ignorePatterns = [
|
|
@@ -6213,6 +6244,7 @@ var init_engine = __esm({
|
|
|
6213
6244
|
];
|
|
6214
6245
|
this.config.debounceMs = persisted.debounceMs;
|
|
6215
6246
|
this.config.defaultBranch = persisted.defaultBranch;
|
|
6247
|
+
this.config.indexWorkspace = persisted.indexWorkspace ?? DEFAULT_CONFIG.indexWorkspace;
|
|
6216
6248
|
}
|
|
6217
6249
|
this.loadCurrentBranch();
|
|
6218
6250
|
const integrationOps = this.opLog.readAll();
|
|
@@ -6224,10 +6256,29 @@ var init_engine = __esm({
|
|
|
6224
6256
|
opsReplayed: this.materializationStats.integrationOpsReplayed + laneReplayed
|
|
6225
6257
|
};
|
|
6226
6258
|
}
|
|
6259
|
+
/**
|
|
6260
|
+
* Index all untracked files currently on disk into the Trellis graph.
|
|
6261
|
+
*/
|
|
6262
|
+
async indexWorkspace(opts) {
|
|
6263
|
+
if (!_TrellisVcsEngine.isRepo(this.config.rootPath)) {
|
|
6264
|
+
throw new Error(
|
|
6265
|
+
`Not a Trellis workspace: ${this.config.rootPath}. Run trellis init first.`
|
|
6266
|
+
);
|
|
6267
|
+
}
|
|
6268
|
+
if (this.getOpCount() === 0) {
|
|
6269
|
+
this.open();
|
|
6270
|
+
}
|
|
6271
|
+
const result = await this.indexExistingFiles(opts);
|
|
6272
|
+
await this.flushAutoCheckpoint();
|
|
6273
|
+
this.config.indexWorkspace = true;
|
|
6274
|
+
this.writePersistedConfig();
|
|
6275
|
+
return result;
|
|
6276
|
+
}
|
|
6227
6277
|
/**
|
|
6228
6278
|
* Start watching the filesystem for changes.
|
|
6229
6279
|
*/
|
|
6230
|
-
watch() {
|
|
6280
|
+
watch(opts) {
|
|
6281
|
+
const reconcileExisting = opts?.reconcileExisting ?? this.config.indexWorkspace;
|
|
6231
6282
|
this.ingestion = new Ingestion({
|
|
6232
6283
|
agentId: this.agentId,
|
|
6233
6284
|
lastOpHash: this.getActiveJournal().getLastOp()?.hash,
|
|
@@ -6249,6 +6300,10 @@ var init_engine = __esm({
|
|
|
6249
6300
|
await this.ingestion.process(event);
|
|
6250
6301
|
}
|
|
6251
6302
|
});
|
|
6303
|
+
if (!reconcileExisting) {
|
|
6304
|
+
this.watcher.start();
|
|
6305
|
+
return;
|
|
6306
|
+
}
|
|
6252
6307
|
this.watcher.scan().then(async (scanEvents) => {
|
|
6253
6308
|
const trackedPaths = new Set(this.trackedFiles().map((f) => f.path));
|
|
6254
6309
|
for (const event of scanEvents) {
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SPRITE_ENSURE_BUN_SH,
|
|
3
|
+
assertSpriteCli,
|
|
4
|
+
ensureSprite,
|
|
5
|
+
ensureSpritePublicAccess,
|
|
6
|
+
resolveSpritePublicUrl,
|
|
7
|
+
runSpriteCopy,
|
|
8
|
+
runSpriteExec
|
|
9
|
+
} from "./chunk-CAG4FULI.js";
|
|
10
|
+
import {
|
|
11
|
+
updateConfig
|
|
12
|
+
} from "./chunk-JA7AIHRK.js";
|
|
13
|
+
|
|
14
|
+
// src/server/deploy.ts
|
|
15
|
+
import { execFile } from "child_process";
|
|
16
|
+
import { existsSync, writeFileSync, mkdirSync } from "fs";
|
|
17
|
+
import { join, resolve } from "path";
|
|
18
|
+
import { promisify } from "util";
|
|
19
|
+
|
|
20
|
+
// src/server/deploy-meta.ts
|
|
21
|
+
var DEPLOY_NAME_RE = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
|
|
22
|
+
var MIN_LEN = 3;
|
|
23
|
+
var MAX_LEN = 32;
|
|
24
|
+
var DeployNameError = class extends Error {
|
|
25
|
+
constructor(message) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.name = "DeployNameError";
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
function normalizeDeployName(name) {
|
|
31
|
+
return name.trim().toLowerCase();
|
|
32
|
+
}
|
|
33
|
+
function validateDeployName(name) {
|
|
34
|
+
const normalized = normalizeDeployName(name);
|
|
35
|
+
if (!normalized) {
|
|
36
|
+
throw new DeployNameError("Deploy name is required.");
|
|
37
|
+
}
|
|
38
|
+
if (normalized.length < MIN_LEN || normalized.length > MAX_LEN) {
|
|
39
|
+
throw new DeployNameError(
|
|
40
|
+
`Deploy name must be ${MIN_LEN}\u2013${MAX_LEN} characters (got ${normalized.length}).`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
if (normalized.includes("--")) {
|
|
44
|
+
throw new DeployNameError(
|
|
45
|
+
"Deploy name cannot contain consecutive hyphens."
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
if (!DEPLOY_NAME_RE.test(normalized)) {
|
|
49
|
+
throw new DeployNameError(
|
|
50
|
+
"Deploy name must start with a letter and use only lowercase letters, numbers, and single hyphens (e.g. my-app)."
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
return normalized;
|
|
54
|
+
}
|
|
55
|
+
function buildDeployUrl(name) {
|
|
56
|
+
const slug = validateDeployName(name);
|
|
57
|
+
return `https://${slug}.sprites.app`;
|
|
58
|
+
}
|
|
59
|
+
var SPRITE_PUBLIC_HTTP_PORT = 8080;
|
|
60
|
+
|
|
61
|
+
// src/server/deploy.ts
|
|
62
|
+
async function deploy(opts) {
|
|
63
|
+
const { configDir = ".", onProgress = () => {
|
|
64
|
+
} } = opts;
|
|
65
|
+
const listenPort = opts.port ?? SPRITE_PUBLIC_HTTP_PORT;
|
|
66
|
+
const name = validateDeployName(opts.name);
|
|
67
|
+
const apiKey = opts.apiKey ?? generateSecret("spk_");
|
|
68
|
+
const jwtSecret = opts.jwtSecret ?? generateSecret("jws_");
|
|
69
|
+
if (opts.stub) {
|
|
70
|
+
const url2 = buildDeployUrl(name);
|
|
71
|
+
onProgress("Stub deploy \u2014 skipping Sprites provisioning");
|
|
72
|
+
onProgress("Writing .trellis-db.json...");
|
|
73
|
+
writeRemoteDeployConfig({ name, url: url2, apiKey, configDir });
|
|
74
|
+
return { url: url2, name, apiKey };
|
|
75
|
+
}
|
|
76
|
+
onProgress("Checking Sprites CLI...");
|
|
77
|
+
await assertSpriteCli();
|
|
78
|
+
onProgress("Writing server entrypoint...");
|
|
79
|
+
const tmpDir = resolve(configDir, ".trellis-deploy");
|
|
80
|
+
if (!existsSync(tmpDir)) mkdirSync(tmpDir, { recursive: true });
|
|
81
|
+
const entrypoint = join(tmpDir, "server-entry.ts");
|
|
82
|
+
writeFileSync(
|
|
83
|
+
entrypoint,
|
|
84
|
+
generateServerEntrypoint({ port: listenPort, apiKey, jwtSecret })
|
|
85
|
+
);
|
|
86
|
+
onProgress("Bundling server with Bun...");
|
|
87
|
+
const bundlePath = join(tmpDir, "server.js");
|
|
88
|
+
await runBun([
|
|
89
|
+
"build",
|
|
90
|
+
entrypoint,
|
|
91
|
+
"--outfile",
|
|
92
|
+
bundlePath,
|
|
93
|
+
"--target",
|
|
94
|
+
"bun",
|
|
95
|
+
"--format",
|
|
96
|
+
"esm"
|
|
97
|
+
]);
|
|
98
|
+
onProgress(`Ensuring Sprite: ${name}...`);
|
|
99
|
+
await ensureSprite(name);
|
|
100
|
+
onProgress("Configuring public URL...");
|
|
101
|
+
await ensureSpritePublicAccess(name);
|
|
102
|
+
const url = await resolveSpritePublicUrl(name);
|
|
103
|
+
onProgress(`Uploading to Sprite: ${name}...`);
|
|
104
|
+
await runSpriteExec(name, "mkdir -p /home/sprite/trellis-db");
|
|
105
|
+
await runSpriteCopy(bundlePath, name, "/home/sprite/trellis-db/server.js");
|
|
106
|
+
onProgress("Ensuring Bun is installed...");
|
|
107
|
+
const bunPath = await runSpriteExec(name, SPRITE_ENSURE_BUN_SH);
|
|
108
|
+
if (!bunPath.includes("bun")) {
|
|
109
|
+
throw new Error(`Bun install failed on sprite ${name}: ${bunPath || "(no output)"}`);
|
|
110
|
+
}
|
|
111
|
+
onProgress("Starting server (sprite-env service)...");
|
|
112
|
+
const bun = bunPath.trim().split("\n").pop().trim();
|
|
113
|
+
await runSpriteExec(
|
|
114
|
+
name,
|
|
115
|
+
`
|
|
116
|
+
export PATH="$HOME/.bun/bin:$PATH"
|
|
117
|
+
ENV="/.sprite/bin/sprite-env"
|
|
118
|
+
BUN="${bun}"
|
|
119
|
+
$ENV services delete trellis-db 2>/dev/null || true
|
|
120
|
+
$ENV services create trellis-db \\
|
|
121
|
+
--cmd "$BUN" \\
|
|
122
|
+
--args run,server.js \\
|
|
123
|
+
--dir /home/sprite/trellis-db \\
|
|
124
|
+
--http-port ${listenPort} \\
|
|
125
|
+
--no-stream
|
|
126
|
+
`.trim()
|
|
127
|
+
);
|
|
128
|
+
onProgress("Waiting for health check...");
|
|
129
|
+
await waitForDeployHealth(url, 6e4);
|
|
130
|
+
onProgress("Writing .trellis-db.json...");
|
|
131
|
+
writeRemoteDeployConfig({ name, url, apiKey, configDir });
|
|
132
|
+
return { url, name, apiKey };
|
|
133
|
+
}
|
|
134
|
+
function writeRemoteDeployConfig(opts) {
|
|
135
|
+
updateConfig(
|
|
136
|
+
{
|
|
137
|
+
mode: "remote",
|
|
138
|
+
url: opts.url,
|
|
139
|
+
apiKey: opts.apiKey,
|
|
140
|
+
spriteName: opts.name,
|
|
141
|
+
deployedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
142
|
+
},
|
|
143
|
+
opts.configDir
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
async function waitForDeployHealth(url, timeoutMs) {
|
|
147
|
+
const deadline = Date.now() + timeoutMs;
|
|
148
|
+
const healthUrl = `${url.replace(/\/$/, "")}/health`;
|
|
149
|
+
let lastStatus = 0;
|
|
150
|
+
while (Date.now() < deadline) {
|
|
151
|
+
try {
|
|
152
|
+
const res = await fetch(healthUrl);
|
|
153
|
+
lastStatus = res.status;
|
|
154
|
+
if (res.ok) return;
|
|
155
|
+
} catch {
|
|
156
|
+
}
|
|
157
|
+
await new Promise((r) => setTimeout(r, 2e3));
|
|
158
|
+
}
|
|
159
|
+
throw new Error(
|
|
160
|
+
`Deploy health check timed out (${healthUrl}${lastStatus ? `, last status ${lastStatus}` : ""})`
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
function generateSecret(prefix) {
|
|
164
|
+
const bytes = new Uint8Array(24);
|
|
165
|
+
crypto.getRandomValues(bytes);
|
|
166
|
+
const b64 = btoa(String.fromCharCode(...bytes)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
167
|
+
return `${prefix}${b64}`;
|
|
168
|
+
}
|
|
169
|
+
async function runBun(args) {
|
|
170
|
+
const execFileAsync = promisify(execFile);
|
|
171
|
+
try {
|
|
172
|
+
await execFileAsync("bun", args);
|
|
173
|
+
} catch (err) {
|
|
174
|
+
throw new Error(
|
|
175
|
+
`bun ${args[0]} failed (exit ${err.code ?? "?"}): ${err.stderr ?? err.message}`
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function resolveTrellisImports() {
|
|
180
|
+
const root = process.env.TRELLIS_NODE_ROOT?.trim();
|
|
181
|
+
if (root) {
|
|
182
|
+
return {
|
|
183
|
+
server: join(root, "dist/server/index.js").replace(/\\/g, "/"),
|
|
184
|
+
client: join(root, "dist/client/index.js").replace(/\\/g, "/")
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
return { server: "trellis/server", client: "trellis/client" };
|
|
188
|
+
}
|
|
189
|
+
function generateServerEntrypoint(opts) {
|
|
190
|
+
const { server, client } = resolveTrellisImports();
|
|
191
|
+
return `
|
|
192
|
+
import { TenantPool, startServer } from '${server}';
|
|
193
|
+
import { readConfig, defaultLocalConfig, writeConfig } from '${client}';
|
|
194
|
+
import { join } from 'path';
|
|
195
|
+
import { existsSync } from 'fs';
|
|
196
|
+
|
|
197
|
+
const dbPath = '/home/sprite/trellis-db/data';
|
|
198
|
+
const configDir = '/home/sprite/trellis-db';
|
|
199
|
+
|
|
200
|
+
writeConfig(defaultLocalConfig(dbPath, {
|
|
201
|
+
apiKey: '${opts.apiKey}',
|
|
202
|
+
jwtSecret: '${opts.jwtSecret}',
|
|
203
|
+
port: ${opts.port},
|
|
204
|
+
}), configDir);
|
|
205
|
+
|
|
206
|
+
const config = readConfig(configDir)!;
|
|
207
|
+
// Sprites VMs lack better-sqlite3 native bindings \u2014 use WASM sql.js backend.
|
|
208
|
+
const pool = new TenantPool(dbPath, { backend: { backend: 'sqljs' } });
|
|
209
|
+
await pool.preload();
|
|
210
|
+
|
|
211
|
+
const server = startServer({ port: ${opts.port}, config, pool });
|
|
212
|
+
|
|
213
|
+
console.log('Trellis DB running on port ${opts.port}');
|
|
214
|
+
console.log(\`Listening on port ${opts.port}\`);
|
|
215
|
+
`;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export {
|
|
219
|
+
DeployNameError,
|
|
220
|
+
normalizeDeployName,
|
|
221
|
+
validateDeployName,
|
|
222
|
+
buildDeployUrl,
|
|
223
|
+
SPRITE_PUBLIC_HTTP_PORT,
|
|
224
|
+
deploy
|
|
225
|
+
};
|