@intentius/behold 0.29.25 → 0.29.26
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/AGENTS.md +3 -1
- package/demos.json +15 -0
- package/dist/cli.js +604 -371
- package/example-choudoufu-estate/README.md +2 -2
- package/example-choudoufu-estate/scripts/choudoufu-up.sh +2 -2
- package/example-terralith/README.md +32 -0
- package/example-terralith/phases/adopt/migrations/adopt.yml +12 -0
- package/example-terralith/phases/adopt/terralith/main.tf +138 -0
- package/example-terralith/phases/split/migrations/split.yml +29 -0
- package/example-terralith/phases/split/team-a/main.tf +52 -0
- package/example-terralith/phases/split/team-b/main.tf +52 -0
- package/example-terralith/phases/split/team-c/main.tf +52 -0
- package/example-terralith/phases/split/terralith/main.tf +27 -0
- package/example-terralith/scripts/lib.sh +64 -0
- package/example-terralith/scripts/terralith-down.sh +9 -0
- package/example-terralith/scripts/terralith-step.sh +88 -0
- package/example-terralith/scripts/terralith-up.sh +50 -0
- package/example-terralith/terralith/main.tf +141 -0
- package/package.json +2 -1
- package/web/app.js +51 -7
- package/web/identity-mark.js +61 -0
- package/web/identity-mark.test.js +32 -0
- package/web/pending.js +2 -0
- package/web/pending.test.js +7 -0
- package/web/terralith-steps.js +93 -0
- package/web/terralith-steps.test.js +71 -0
- package/web/terralith.html +105 -0
- package/web/terralith.js +211 -0
- /package/example-choudoufu-estate/monolith/{carve.json → split.json} +0 -0
package/dist/cli.js
CHANGED
|
@@ -3066,11 +3066,18 @@ function verdictFor(address, ls, plan) {
|
|
|
3066
3066
|
const listing = gap ? { listing: gap.detail } : {};
|
|
3067
3067
|
if (bound) {
|
|
3068
3068
|
const id = bound.identity || item?.id;
|
|
3069
|
+
const marked = !!item;
|
|
3069
3070
|
return {
|
|
3070
3071
|
_status: "good",
|
|
3071
3072
|
...id ? { physicalId: id } : {},
|
|
3072
3073
|
ownership: "owned",
|
|
3073
|
-
attrs: {
|
|
3074
|
+
attrs: {
|
|
3075
|
+
bound: BOUND_WORDS[bound.source] ?? bound.source,
|
|
3076
|
+
marker: marked ? MARKER_ON : MARKER_NONE,
|
|
3077
|
+
_identity: { source: bound.source, marked },
|
|
3078
|
+
...bound.identity_values ? { identity: bound.identity_values } : {},
|
|
3079
|
+
...listing
|
|
3080
|
+
}
|
|
3074
3081
|
};
|
|
3075
3082
|
}
|
|
3076
3083
|
if (omission) {
|
|
@@ -3126,10 +3133,10 @@ function verdictFor(address, ls, plan) {
|
|
|
3126
3133
|
return void 0;
|
|
3127
3134
|
}
|
|
3128
3135
|
function paintChoudoufu(ir, ls, plan, estate) {
|
|
3129
|
-
const
|
|
3136
|
+
const declared2 = /* @__PURE__ */ new Set();
|
|
3130
3137
|
for (const n of ir.nodes) {
|
|
3131
3138
|
if (n.lexicon !== CHOUDOUFU_LEXICON || isRecord3(n.attrs.producer)) continue;
|
|
3132
|
-
|
|
3139
|
+
declared2.add(n.id);
|
|
3133
3140
|
const v = verdictFor(n.id, ls, plan) ?? {
|
|
3134
3141
|
_status: "neutral",
|
|
3135
3142
|
_unobserved: plan ? "not mentioned by live-plan or live-ls" : "no live-plan document for this estate",
|
|
@@ -3140,8 +3147,8 @@ function paintChoudoufu(ir, ls, plan, estate) {
|
|
|
3140
3147
|
if (v.ownership) n.ownership = v.ownership;
|
|
3141
3148
|
}
|
|
3142
3149
|
for (const item of ls?.items ?? []) {
|
|
3143
|
-
if (!item.address ||
|
|
3144
|
-
|
|
3150
|
+
if (!item.address || declared2.has(item.address)) continue;
|
|
3151
|
+
declared2.add(item.address);
|
|
3145
3152
|
ir.nodes.push({
|
|
3146
3153
|
id: item.address,
|
|
3147
3154
|
kind: item.type,
|
|
@@ -3212,7 +3219,7 @@ function choudoufuDiffNodes(check, ls, plan, member, drift) {
|
|
|
3212
3219
|
seen.add(i.address);
|
|
3213
3220
|
const v = verdictFor(i.address, ls, plan);
|
|
3214
3221
|
const health = !v ? "unknown" : v._status === "good" ? "healthy" : v._status === "warn" ? "degraded" : "unknown";
|
|
3215
|
-
const detail = !v ? "not mentioned by live-plan or live-ls" : typeof v.attrs.bound === "string" ? `bound ${v.attrs.bound}` : typeof v.attrs.omission === "string" ? `${v.attrs.omission}: ${String(v.attrs.detail ?? "")}` : v._unobserved ?? (typeof v.attrs.listing === "string" ? v.attrs.listing : void 0);
|
|
3222
|
+
const detail = !v ? "not mentioned by live-plan or live-ls" : typeof v.attrs.bound === "string" ? `bound ${v.attrs.bound}${v.attrs.marker === MARKER_NONE ? `; ${MARKER_NONE}` : ""}` : typeof v.attrs.omission === "string" ? `${v.attrs.omission}: ${String(v.attrs.detail ?? "")}` : v._unobserved ?? (typeof v.attrs.listing === "string" ? v.attrs.listing : void 0);
|
|
3216
3223
|
out[key2(i.address)] = {
|
|
3217
3224
|
observed: v ? {
|
|
3218
3225
|
type: i.type,
|
|
@@ -3244,7 +3251,7 @@ function choudoufuDiffNodes(check, ls, plan, member, drift) {
|
|
|
3244
3251
|
}
|
|
3245
3252
|
return out;
|
|
3246
3253
|
}
|
|
3247
|
-
var isRecord3, refuse3, CREDS, REASON_TONE, UNOBSERVED_REASONS, BOUND_WORDS, choudoufuVia, choudoufuSpec;
|
|
3254
|
+
var isRecord3, refuse3, CREDS, REASON_TONE, UNOBSERVED_REASONS, BOUND_WORDS, MARKER_ON, MARKER_NONE, choudoufuVia, choudoufuSpec;
|
|
3248
3255
|
var init_choudoufu_live = __esm({
|
|
3249
3256
|
"src/choudoufu-live.ts"() {
|
|
3250
3257
|
"use strict";
|
|
@@ -3268,16 +3275,20 @@ var init_choudoufu_live = __esm({
|
|
|
3268
3275
|
UNOBSERVED_REASONS = /* @__PURE__ */ new Set(["FAILED", "CYCLE", "SUPERSEDED", "UNREADABLE", "INCOMPLETE_BLOCK"]);
|
|
3269
3276
|
BOUND_WORDS = {
|
|
3270
3277
|
marker: "by its marker (the estate-wide tag sweep)",
|
|
3271
|
-
// #393 item 8
|
|
3272
|
-
//
|
|
3273
|
-
//
|
|
3274
|
-
//
|
|
3275
|
-
//
|
|
3276
|
-
//
|
|
3277
|
-
|
|
3278
|
+
// #393 item 8 read this as "no marker yet", and that holds only for an
|
|
3279
|
+
// object that carries none. choudoufu binds a named instance (an IAM role,
|
|
3280
|
+
// a log group) by the name the configuration states whether or not a
|
|
3281
|
+
// marker is on it (internal/command/views/live_plan.go,
|
|
3282
|
+
// LivePlanBoundDerived: "no marker sweep and no record store involved"),
|
|
3283
|
+
// and a stamped log group still reads `derived`. Whether the object
|
|
3284
|
+
// carries the marker is live-ls's answer, so it is its own row, `marker`,
|
|
3285
|
+
// below.
|
|
3286
|
+
derived: "by derived identity (the name the configuration states)",
|
|
3278
3287
|
record: "from the estate's record store",
|
|
3279
3288
|
cache: "from the local state cache"
|
|
3280
3289
|
};
|
|
3290
|
+
MARKER_ON = "on the object (tofu-estate, tofu-address)";
|
|
3291
|
+
MARKER_NONE = "no marker on the object";
|
|
3281
3292
|
choudoufuVia = {
|
|
3282
3293
|
tool: () => {
|
|
3283
3294
|
const v = choudoufuVersion();
|
|
@@ -3548,12 +3559,12 @@ function readWorkspaces(projectDir) {
|
|
|
3548
3559
|
function detectProjectShape(projectDir) {
|
|
3549
3560
|
const configFile = chantConfigPath(projectDir);
|
|
3550
3561
|
if (configFile) return { kind: "project", configFile };
|
|
3551
|
-
const
|
|
3552
|
-
const from =
|
|
3562
|
+
const declared2 = loadBeholdConfig(projectDir).members;
|
|
3563
|
+
const from = declared2 ? "behold-config" : "workspaces";
|
|
3553
3564
|
const members = [];
|
|
3554
3565
|
const invalid = [];
|
|
3555
|
-
if (
|
|
3556
|
-
for (const m of
|
|
3566
|
+
if (declared2) {
|
|
3567
|
+
for (const m of declared2) {
|
|
3557
3568
|
if ("invalid" in m) {
|
|
3558
3569
|
invalid.push(m);
|
|
3559
3570
|
continue;
|
|
@@ -11201,8 +11212,8 @@ var init_declaration = __esm({
|
|
|
11201
11212
|
});
|
|
11202
11213
|
|
|
11203
11214
|
// src/cli.ts
|
|
11204
|
-
import { resolve as resolve35, dirname as dirname21, join as
|
|
11205
|
-
import { realpathSync as realpathSync3, existsSync as
|
|
11215
|
+
import { resolve as resolve35, dirname as dirname21, join as join56 } from "node:path";
|
|
11216
|
+
import { realpathSync as realpathSync3, existsSync as existsSync35, readFileSync as readFileSync44, rmSync as rmSync4 } from "node:fs";
|
|
11206
11217
|
import { fileURLToPath as fileURLToPath12 } from "node:url";
|
|
11207
11218
|
import { spawn as spawn9, spawnSync as spawnSync4 } from "node:child_process";
|
|
11208
11219
|
|
|
@@ -11239,13 +11250,13 @@ async function k8sClient() {
|
|
|
11239
11250
|
}
|
|
11240
11251
|
}
|
|
11241
11252
|
function resolveK8sTarget(profiles, env, kubeconfig) {
|
|
11242
|
-
const
|
|
11243
|
-
const context =
|
|
11253
|
+
const declared2 = env ? profiles?.[env]?.context : void 0;
|
|
11254
|
+
const context = declared2 ?? kubeconfig.currentContext;
|
|
11244
11255
|
if (!context) return void 0;
|
|
11245
11256
|
const cluster = kubeconfig.contexts.get(context);
|
|
11246
11257
|
const endpoint = cluster ? kubeconfig.servers.get(cluster) : void 0;
|
|
11247
11258
|
if (!endpoint) return void 0;
|
|
11248
|
-
return { name: "k8s", label: context, endpoint, source:
|
|
11259
|
+
return { name: "k8s", label: context, endpoint, source: declared2 ? "profile" : "current-context" };
|
|
11249
11260
|
}
|
|
11250
11261
|
function contextBindsCluster(context, clusterName) {
|
|
11251
11262
|
if (!clusterName) return void 0;
|
|
@@ -11260,8 +11271,8 @@ import { serve } from "@hono/node-server";
|
|
|
11260
11271
|
import { fileURLToPath as fileURLToPath10 } from "node:url";
|
|
11261
11272
|
import { execFile as execFile5 } from "node:child_process";
|
|
11262
11273
|
import { promisify as promisify3 } from "node:util";
|
|
11263
|
-
import { existsSync as
|
|
11264
|
-
import { basename as basename6, dirname as dirname18, join as
|
|
11274
|
+
import { existsSync as existsSync32, readFileSync as readFileSync40 } from "node:fs";
|
|
11275
|
+
import { basename as basename6, dirname as dirname18, join as join52, relative as relative11, resolve as resolve32, sep as sep10 } from "node:path";
|
|
11265
11276
|
|
|
11266
11277
|
// src/recents.ts
|
|
11267
11278
|
import { readFileSync, writeFileSync, mkdirSync, existsSync } from "node:fs";
|
|
@@ -11361,9 +11372,9 @@ function declaredChartNames(ir) {
|
|
|
11361
11372
|
}
|
|
11362
11373
|
return names;
|
|
11363
11374
|
}
|
|
11364
|
-
function matchesDeclaredChart(chart,
|
|
11375
|
+
function matchesDeclaredChart(chart, declared2) {
|
|
11365
11376
|
if (typeof chart !== "string" || chart.length === 0) return false;
|
|
11366
|
-
for (const name of
|
|
11377
|
+
for (const name of declared2) {
|
|
11367
11378
|
if (chart === name || chart.startsWith(`${name}-`)) return true;
|
|
11368
11379
|
}
|
|
11369
11380
|
return false;
|
|
@@ -11404,14 +11415,14 @@ function discoverReleaseUnits(projectDir) {
|
|
|
11404
11415
|
}
|
|
11405
11416
|
function synthesizeHelmReleases(ir, observed, owners) {
|
|
11406
11417
|
if (!observed) return 0;
|
|
11407
|
-
const
|
|
11418
|
+
const declared2 = declaredChartNames(ir);
|
|
11408
11419
|
const have = new Set(ir.nodes.map((n) => n.id));
|
|
11409
11420
|
let added = 0;
|
|
11410
11421
|
for (const [key2, o] of Object.entries(observed)) {
|
|
11411
11422
|
const m = RELEASE_KEY.exec(key2);
|
|
11412
11423
|
if (!m || have.has(key2)) continue;
|
|
11413
11424
|
const [, namespace, name] = m;
|
|
11414
|
-
if (matchesDeclaredChart(o.attributes?.chart,
|
|
11425
|
+
if (matchesDeclaredChart(o.attributes?.chart, declared2)) continue;
|
|
11415
11426
|
const component = owners.get(name);
|
|
11416
11427
|
const deployed = o.status === "deployed";
|
|
11417
11428
|
const node = {
|
|
@@ -12601,8 +12612,8 @@ function addValueMatchEdges(ir) {
|
|
|
12601
12612
|
}
|
|
12602
12613
|
}
|
|
12603
12614
|
if (owner.size === 0) return ir;
|
|
12604
|
-
const
|
|
12605
|
-
for (const e of ir.edges)
|
|
12615
|
+
const declared2 = /* @__PURE__ */ new Set();
|
|
12616
|
+
for (const e of ir.edges) declared2.add(`${e.from}\0${e.to}`);
|
|
12606
12617
|
const added = /* @__PURE__ */ new Set();
|
|
12607
12618
|
for (const a of nodes) {
|
|
12608
12619
|
for (const { path, value } of stringLeaves(a.attrs)) {
|
|
@@ -12610,7 +12621,7 @@ function addValueMatchEdges(ir) {
|
|
|
12610
12621
|
const b = owner.get(value);
|
|
12611
12622
|
if (!b || b === a.id) continue;
|
|
12612
12623
|
const key2 = `${a.id}\0${b}`;
|
|
12613
|
-
if (
|
|
12624
|
+
if (declared2.has(key2) || added.has(key2)) continue;
|
|
12614
12625
|
added.add(key2);
|
|
12615
12626
|
ir.edges.push({ from: a.id, to: b, kind: "ref", viaAttr: path, inferred: true });
|
|
12616
12627
|
}
|
|
@@ -13526,8 +13537,8 @@ function estateMembers(projectDirs) {
|
|
|
13526
13537
|
return projectDirs.map((dir, i) => ({ name: names[i], dir, kind: kindOf2(dir) }));
|
|
13527
13538
|
}
|
|
13528
13539
|
function estateMemberNames(projectDirs) {
|
|
13529
|
-
const
|
|
13530
|
-
if (
|
|
13540
|
+
const declared2 = projectDirs.map((d) => workspaceMemberOf(d)?.name);
|
|
13541
|
+
if (declared2.every((n) => n !== void 0)) return declared2;
|
|
13531
13542
|
return shortStackNames([...projectDirs]);
|
|
13532
13543
|
}
|
|
13533
13544
|
function unreadableStacks(projectDirs) {
|
|
@@ -13537,10 +13548,10 @@ function unreadableStacks(projectDirs) {
|
|
|
13537
13548
|
}
|
|
13538
13549
|
var memberViaFor = (dir) => {
|
|
13539
13550
|
const own = memberKindSpec(memberKindOf(dir) ?? "chant")?.via ?? chantVia;
|
|
13540
|
-
const
|
|
13551
|
+
const declared2 = workspaceMemberOf(dir);
|
|
13541
13552
|
const ws = servedWorkspace();
|
|
13542
|
-
if (!
|
|
13543
|
-
return
|
|
13553
|
+
if (!declared2 || !ws || !CONTRACT_READ_KINDS.has(declared2.kind)) return own;
|
|
13554
|
+
return declared2.kind === "choudoufu" ? choudoufuWorkspaceVia(declared2, ws.root) : workspaceVia(declared2, ws.root, own);
|
|
13544
13555
|
};
|
|
13545
13556
|
function forMember(dir, opts) {
|
|
13546
13557
|
if (!opts.traffic || memberTakesTraffic(dir, memberKindOf(dir) ?? "chant")) return opts;
|
|
@@ -13630,8 +13641,8 @@ function declaredSegments(path) {
|
|
|
13630
13641
|
if (segs.length === 0 || segs.includes("..")) return void 0;
|
|
13631
13642
|
return segs;
|
|
13632
13643
|
}
|
|
13633
|
-
function pathAlignment(
|
|
13634
|
-
const want = declaredSegments(
|
|
13644
|
+
function pathAlignment(declared2, dir, isDir = realIsDir) {
|
|
13645
|
+
const want = declaredSegments(declared2);
|
|
13635
13646
|
if (!want) return 0;
|
|
13636
13647
|
const root = resolve11(dir);
|
|
13637
13648
|
const have = root.split(sep5).filter(Boolean);
|
|
@@ -13667,10 +13678,10 @@ function joinNamespaceBindings(members, isDir = realIsDir) {
|
|
|
13667
13678
|
if (!winner || tied) continue;
|
|
13668
13679
|
const prev = best.get(winner.dir);
|
|
13669
13680
|
if (prev === "ambiguous") continue;
|
|
13670
|
-
const
|
|
13671
|
-
if (!prev) best.set(winner.dir, { score: winner.score, join:
|
|
13681
|
+
const join57 = { dir: winner.dir, namespace: b.namespace, path: b.path, declaredBy: b.declaredBy };
|
|
13682
|
+
if (!prev) best.set(winner.dir, { score: winner.score, join: join57 });
|
|
13672
13683
|
else if (prev.join.namespace !== b.namespace) best.set(winner.dir, "ambiguous");
|
|
13673
|
-
else if (winner.score > prev.score) best.set(winner.dir, { score: winner.score, join:
|
|
13684
|
+
else if (winner.score > prev.score) best.set(winner.dir, { score: winner.score, join: join57 });
|
|
13674
13685
|
}
|
|
13675
13686
|
return [...best.values()].filter((v) => v !== "ambiguous").map((v) => v.join);
|
|
13676
13687
|
}
|
|
@@ -13746,7 +13757,7 @@ async function composeEstateOverlay(projectDirs, opts, classify, observe = {}) {
|
|
|
13746
13757
|
|
|
13747
13758
|
// src/helm-drift.ts
|
|
13748
13759
|
function renderIdentity(record, observed) {
|
|
13749
|
-
const
|
|
13760
|
+
const declared2 = {
|
|
13750
13761
|
...record.inputDigest ? { inputDigest: record.inputDigest } : {},
|
|
13751
13762
|
...record.contentDigest ? { contentDigest: record.contentDigest } : {}
|
|
13752
13763
|
};
|
|
@@ -13756,14 +13767,14 @@ function renderIdentity(record, observed) {
|
|
|
13756
13767
|
...typeof a.inputDigest === "string" ? { inputDigest: a.inputDigest } : {},
|
|
13757
13768
|
...typeof a.contentDigest === "string" ? { contentDigest: a.contentDigest } : {}
|
|
13758
13769
|
};
|
|
13759
|
-
const base = { declared, observed: obs };
|
|
13760
|
-
if (!
|
|
13770
|
+
const base = { declared: declared2, observed: obs };
|
|
13771
|
+
if (!declared2.inputDigest && !declared2.contentDigest) return { match: "unpinned", ...base };
|
|
13761
13772
|
if (!obs.inputDigest && !obs.contentDigest) return { match: "unrecorded", ...base };
|
|
13762
|
-
if (
|
|
13763
|
-
return { match:
|
|
13773
|
+
if (declared2.contentDigest && obs.contentDigest) {
|
|
13774
|
+
return { match: declared2.contentDigest === obs.contentDigest ? "content" : "mismatch", ...base };
|
|
13764
13775
|
}
|
|
13765
|
-
if (
|
|
13766
|
-
return { match:
|
|
13776
|
+
if (declared2.inputDigest && obs.inputDigest) {
|
|
13777
|
+
return { match: declared2.inputDigest === obs.inputDigest ? "input" : "mismatch", ...base };
|
|
13767
13778
|
}
|
|
13768
13779
|
return { match: "unrecorded", ...base };
|
|
13769
13780
|
}
|
|
@@ -15078,14 +15089,14 @@ function componentRepresentatives(ir, dag) {
|
|
|
15078
15089
|
}
|
|
15079
15090
|
function addCompositeDeps(ir, dag) {
|
|
15080
15091
|
const compToNode = componentRepresentatives(ir, dag);
|
|
15081
|
-
const
|
|
15092
|
+
const declared2 = new Set(ir.edges.map((e) => `${e.from}\0${e.to}`));
|
|
15082
15093
|
for (const e of dag.edges) {
|
|
15083
15094
|
const from = compToNode.get(e.from);
|
|
15084
15095
|
const to = compToNode.get(e.to);
|
|
15085
15096
|
if (!from || !to || from === to) continue;
|
|
15086
15097
|
const key2 = `${from}\0${to}`;
|
|
15087
|
-
if (
|
|
15088
|
-
|
|
15098
|
+
if (declared2.has(key2)) continue;
|
|
15099
|
+
declared2.add(key2);
|
|
15089
15100
|
ir.edges.push({ from, to, kind: "ref", viaAttr: "dependsOn", inferred: true });
|
|
15090
15101
|
}
|
|
15091
15102
|
return ir;
|
|
@@ -15209,8 +15220,8 @@ function configKeys(file) {
|
|
|
15209
15220
|
};
|
|
15210
15221
|
}
|
|
15211
15222
|
function pipelineForge(decl, dir, config) {
|
|
15212
|
-
const
|
|
15213
|
-
if (
|
|
15223
|
+
const declared2 = forgeOfName(decl?.pipeline.forge);
|
|
15224
|
+
if (declared2) return { forge: declared2, from: "declared" };
|
|
15214
15225
|
const configured = forgeOfName(configKeys(config).forge);
|
|
15215
15226
|
if (configured) return { forge: configured, from: "config" };
|
|
15216
15227
|
const byPath = decl?.pipeline.path ? forgeOfPipelinePath(decl.pipeline.path) : void 0;
|
|
@@ -18666,13 +18677,13 @@ function predicateText(predicate) {
|
|
|
18666
18677
|
function actionText(action) {
|
|
18667
18678
|
return action.kind === "run" ? `run(${action.op})` : `report: ${action.reason}`;
|
|
18668
18679
|
}
|
|
18669
|
-
function ruleStatus(rule,
|
|
18680
|
+
function ruleStatus(rule, declared2) {
|
|
18670
18681
|
if (rule.then.kind !== "run") return "neutral";
|
|
18671
|
-
return
|
|
18682
|
+
return declared2.has(rule.then.op) ? "accent" : "warn";
|
|
18672
18683
|
}
|
|
18673
|
-
function ruleNode(op, table, rule,
|
|
18674
|
-
const dispatches = rule.then.kind === "run" &&
|
|
18675
|
-
const dangling = rule.then.kind === "run" && !
|
|
18684
|
+
function ruleNode(op, table, rule, declared2) {
|
|
18685
|
+
const dispatches = rule.then.kind === "run" && declared2.has(rule.then.op) ? rule.then.op : void 0;
|
|
18686
|
+
const dangling = rule.then.kind === "run" && !declared2.has(rule.then.op) ? rule.then.op : void 0;
|
|
18676
18687
|
return {
|
|
18677
18688
|
id: ruleId(op.name, rule),
|
|
18678
18689
|
// The card's kind, as an activity's is its `fn`: a converge rule is what
|
|
@@ -18680,7 +18691,7 @@ function ruleNode(op, table, rule, declared) {
|
|
|
18680
18691
|
kind: "ConvergeRule",
|
|
18681
18692
|
lexicon: "op",
|
|
18682
18693
|
attrs: {
|
|
18683
|
-
_status: ruleStatus(rule,
|
|
18694
|
+
_status: ruleStatus(rule, declared2),
|
|
18684
18695
|
_step: "rule",
|
|
18685
18696
|
rule: rule.id,
|
|
18686
18697
|
op: op.name,
|
|
@@ -18792,7 +18803,7 @@ function opsToIr(ops) {
|
|
|
18792
18803
|
const edges = [];
|
|
18793
18804
|
const byStack = {};
|
|
18794
18805
|
const endpoints = /* @__PURE__ */ new Map();
|
|
18795
|
-
const
|
|
18806
|
+
const declared2 = new Set(ops.map((o) => o.name));
|
|
18796
18807
|
const dispatches = [];
|
|
18797
18808
|
for (const op of ops) {
|
|
18798
18809
|
const placed = placeSteps(op);
|
|
@@ -18817,7 +18828,7 @@ function opsToIr(ops) {
|
|
|
18817
18828
|
const table = convergeTable(op);
|
|
18818
18829
|
if (!table) continue;
|
|
18819
18830
|
for (const rule of table.rules) {
|
|
18820
|
-
const node = ruleNode(op, table, rule,
|
|
18831
|
+
const node = ruleNode(op, table, rule, declared2);
|
|
18821
18832
|
nodes.push(node);
|
|
18822
18833
|
(byStack[RULE_BOX(op.name)] ??= []).push(node.id);
|
|
18823
18834
|
edges.push({ from: table.tickStepId, to: node.id, kind: "ref", viaAttr: "rule" });
|
|
@@ -18845,7 +18856,7 @@ function opsToIr(ops) {
|
|
|
18845
18856
|
function opCardFields(node) {
|
|
18846
18857
|
const step = node.attrs._step;
|
|
18847
18858
|
const phase2 = typeof node.attrs.phase === "string" ? node.attrs.phase : void 0;
|
|
18848
|
-
const
|
|
18859
|
+
const declared2 = step === "gate" ? [
|
|
18849
18860
|
{ label: "gate", value: String(node.attrs.gate ?? "") },
|
|
18850
18861
|
{ label: "timeout", value: String(node.attrs.timeout ?? "") }
|
|
18851
18862
|
] : step === "effect" ? [
|
|
@@ -18864,9 +18875,9 @@ function opCardFields(node) {
|
|
|
18864
18875
|
{ label: "then", value: String(node.attrs.then ?? "") }
|
|
18865
18876
|
] : void 0
|
|
18866
18877
|
);
|
|
18867
|
-
if (!
|
|
18878
|
+
if (!declared2) return void 0;
|
|
18868
18879
|
const run3 = typeof node.attrs.run === "string" ? node.attrs.run : void 0;
|
|
18869
|
-
return run3 ? [{ label: "run", value: run3 }, ...
|
|
18880
|
+
return run3 ? [{ label: "run", value: run3 }, ...declared2.slice(0, 1)] : declared2;
|
|
18870
18881
|
}
|
|
18871
18882
|
function opsNote(ops, ir) {
|
|
18872
18883
|
const gates = ir.nodes.filter((n) => n.attrs._step === "gate").length;
|
|
@@ -19927,6 +19938,7 @@ function composeMembersEstate(members) {
|
|
|
19927
19938
|
boxes: boxes.map((b) => ({ ...b, y: height - b.y }))
|
|
19928
19939
|
};
|
|
19929
19940
|
}
|
|
19941
|
+
var spawnedBoxTitle = (estate) => `${estate} \u2014 new estate`;
|
|
19930
19942
|
function renderMoveMorph(members, moves, opts = {}) {
|
|
19931
19943
|
const estateOf = opts.estateOf ?? ((m) => m.panel);
|
|
19932
19944
|
const prefixed = members.map((m) => {
|
|
@@ -19943,10 +19955,24 @@ function renderMoveMorph(members, moves, opts = {}) {
|
|
|
19943
19955
|
});
|
|
19944
19956
|
const before = composeMembersEstate(prefixed);
|
|
19945
19957
|
const after2 = prefixed.map((m) => ({ ...m, ir: { ...m.ir, nodes: [...m.ir.nodes], edges: [...m.ir.edges] } }));
|
|
19958
|
+
const spawned = /* @__PURE__ */ new Map();
|
|
19959
|
+
const servedBox = (estate) => after2.find((m) => ![...spawned.values()].includes(m) && estateOf(m) === estate);
|
|
19960
|
+
const destination = (estate) => {
|
|
19961
|
+
const served2 = servedBox(estate);
|
|
19962
|
+
if (served2) return served2;
|
|
19963
|
+
let box = spawned.get(estate);
|
|
19964
|
+
if (!box) {
|
|
19965
|
+
box = { name: `new:${estate}`, title: spawnedBoxTitle(estate), panel: `estate ${estate}`, ir: { nodes: [], edges: [], groups: {} } };
|
|
19966
|
+
spawned.set(estate, box);
|
|
19967
|
+
after2.push(box);
|
|
19968
|
+
}
|
|
19969
|
+
return box;
|
|
19970
|
+
};
|
|
19946
19971
|
for (const mv of moves) {
|
|
19947
|
-
const src =
|
|
19948
|
-
|
|
19949
|
-
|
|
19972
|
+
const src = servedBox(mv.from);
|
|
19973
|
+
if (!src || !src.ir.nodes.some((n) => n.id === `${src.name}/${mv.address}`)) continue;
|
|
19974
|
+
const dst = destination(mv.to);
|
|
19975
|
+
if (src === dst) continue;
|
|
19950
19976
|
const ids = new Set([mv.address, ...mv.followers ?? []].map((a) => `${src.name}/${a}`));
|
|
19951
19977
|
const moving = src.ir.nodes.filter((n) => ids.has(n.id));
|
|
19952
19978
|
if (!moving.length) continue;
|
|
@@ -21251,11 +21277,11 @@ var RAN = { ok: "ok", fail: "failed", skipped: "skipped" };
|
|
|
21251
21277
|
function tookLabel(ms) {
|
|
21252
21278
|
return ms < 1e3 ? `${ms}ms` : `${(ms / 1e3).toFixed(1)}s`;
|
|
21253
21279
|
}
|
|
21254
|
-
function paintPlayhead(ir,
|
|
21255
|
-
if (!
|
|
21280
|
+
function paintPlayhead(ir, join57, gate) {
|
|
21281
|
+
if (!join57.byNode.size && !join57.at) return ir;
|
|
21256
21282
|
const nodes = ir.nodes.map((node) => {
|
|
21257
|
-
const run3 =
|
|
21258
|
-
const here =
|
|
21283
|
+
const run3 = join57.byNode.get(node.id);
|
|
21284
|
+
const here = join57.at === node.id;
|
|
21259
21285
|
if (!run3 && !here) return node;
|
|
21260
21286
|
const isGate = node.attrs?._step === "gate";
|
|
21261
21287
|
const attrs = { ...node.attrs };
|
|
@@ -21270,7 +21296,7 @@ function paintPlayhead(ir, join56, gate) {
|
|
|
21270
21296
|
if (here) {
|
|
21271
21297
|
attrs._playhead = true;
|
|
21272
21298
|
attrs._status = isGate && gate ? "warn" : "accent";
|
|
21273
|
-
attrs.run = isGate && gate ? `waiting for approval since ${gate.since}` :
|
|
21299
|
+
attrs.run = isGate && gate ? `waiting for approval since ${gate.since}` : join57.atReason ?? "here";
|
|
21274
21300
|
if (isGate && gate?.description) attrs.gateDescription = gate.description;
|
|
21275
21301
|
}
|
|
21276
21302
|
return { ...node, attrs };
|
|
@@ -21292,11 +21318,11 @@ function pendingGateCard(op, gate, ir) {
|
|
|
21292
21318
|
}
|
|
21293
21319
|
};
|
|
21294
21320
|
}
|
|
21295
|
-
function playheadNote(state,
|
|
21321
|
+
function playheadNote(state, join57) {
|
|
21296
21322
|
if (!state.op) {
|
|
21297
21323
|
return "No run state: nothing has been run from this behold session, so every step paints as declared.";
|
|
21298
21324
|
}
|
|
21299
|
-
const settled =
|
|
21325
|
+
const settled = join57 ? join57.byNode.size : state.records.length;
|
|
21300
21326
|
const bits = [];
|
|
21301
21327
|
const head = state.status === "idle" ? `Run state for ${state.op}: no per-step records \u2014 this behold session didn't start the run, so only the gate query answers` : `Run: ${state.op} (${state.mode === "temporal" ? "durable" : "local executor"}) \u2014 ${settled} step${settled === 1 ? "" : "s"} settled`;
|
|
21302
21328
|
if (state.status === "running") {
|
|
@@ -21312,9 +21338,9 @@ function playheadNote(state, join56) {
|
|
|
21312
21338
|
} else if (state.gateNote) {
|
|
21313
21339
|
bits.push(`gate state unavailable \u2014 ${state.gateNote}`);
|
|
21314
21340
|
}
|
|
21315
|
-
if (
|
|
21341
|
+
if (join57?.unplaced.length) {
|
|
21316
21342
|
bits.push(
|
|
21317
|
-
`${
|
|
21343
|
+
`${join57.unplaced.length} record${join57.unplaced.length === 1 ? "" : "s"} matched no declared step and ${join57.unplaced.length === 1 ? "is" : "are"} not painted`
|
|
21318
21344
|
);
|
|
21319
21345
|
}
|
|
21320
21346
|
if (!bits.length) return `${head}.`;
|
|
@@ -21805,8 +21831,8 @@ var OpRunner = class {
|
|
|
21805
21831
|
* thing that gates the strip. Broadcast on a change so a project rebuilt (or
|
|
21806
21832
|
* switched, #195) under an open tab grows or loses its strip without a reload.
|
|
21807
21833
|
*/
|
|
21808
|
-
noteDeclaredConvergeOps(
|
|
21809
|
-
return this.foldOperator({ ...this.lastOperatorState, declared });
|
|
21834
|
+
noteDeclaredConvergeOps(declared2) {
|
|
21835
|
+
return this.foldOperator({ ...this.lastOperatorState, declared: declared2 });
|
|
21810
21836
|
}
|
|
21811
21837
|
/**
|
|
21812
21838
|
* Fold a `chant operator status --json` read (src/operator.ts's
|
|
@@ -22035,8 +22061,8 @@ var REFUSED_READS = [
|
|
|
22035
22061
|
[/^\/api\/substrates$/, "it probes this machine's tools"],
|
|
22036
22062
|
[/^\/api\/history$/, "it runs git against the checkout"],
|
|
22037
22063
|
[/^\/api\/workspace\/(gates|why)$/, "it runs chant against the workspace"],
|
|
22038
|
-
[/^\/api\/choudoufu\/moves$/, "it runs choudoufu"],
|
|
22039
|
-
[/^\/choudoufu\/morph$/, "it runs choudoufu"],
|
|
22064
|
+
[/^\/api\/choudoufu\/(moves|split)$/, "it runs choudoufu"],
|
|
22065
|
+
[/^\/choudoufu\/(morph|split)$/, "it runs choudoufu"],
|
|
22040
22066
|
[/^\/api\/sql-yodeler\/lifecycle$/, "a public view shows a terragucci repo"]
|
|
22041
22067
|
];
|
|
22042
22068
|
var LIVE_PARAMS = ["env", "target", "consistent", "plan", "live"];
|
|
@@ -22647,8 +22673,8 @@ async function predictMember(member, env, traffic, deps, fresh = false) {
|
|
|
22647
22673
|
const dir = resolve19(member.dir);
|
|
22648
22674
|
if (member.kind === "terraform") {
|
|
22649
22675
|
try {
|
|
22650
|
-
const
|
|
22651
|
-
return
|
|
22676
|
+
const declared2 = reportFromIr(await memberIr(dir, { traffic }, terraformVia));
|
|
22677
|
+
return declared2 ? { declared: declared2 } : {};
|
|
22652
22678
|
} catch (err) {
|
|
22653
22679
|
return { note: `declared prediction unavailable: ${said2(err)}` };
|
|
22654
22680
|
}
|
|
@@ -22665,13 +22691,13 @@ async function predictMember(member, env, traffic, deps, fresh = false) {
|
|
|
22665
22691
|
return void 0;
|
|
22666
22692
|
}
|
|
22667
22693
|
};
|
|
22668
|
-
const [live2,
|
|
22669
|
-
return { ...live2 ? { live: live2 } : {}, ...
|
|
22694
|
+
const [live2, declared2] = await Promise.all([env === void 0 ? void 0 : side("live"), side("declared")]);
|
|
22695
|
+
return { ...live2 ? { live: live2 } : {}, ...declared2 ? { declared: declared2 } : {}, ...notes.length ? { note: notes.join("; ") } : {} };
|
|
22670
22696
|
}
|
|
22671
22697
|
if (member.kind === "chant" && memberTakesTraffic(dir, "chant")) {
|
|
22672
22698
|
try {
|
|
22673
|
-
const
|
|
22674
|
-
return
|
|
22699
|
+
const declared2 = reportFromIr(await memberIr(dir, { traffic }));
|
|
22700
|
+
return declared2 ? { declared: declared2 } : {};
|
|
22675
22701
|
} catch (err) {
|
|
22676
22702
|
return { note: `declared prediction unavailable: ${said2(err)}` };
|
|
22677
22703
|
}
|
|
@@ -22705,17 +22731,17 @@ function figureOf(meta, blocks, onMixed) {
|
|
|
22705
22731
|
}
|
|
22706
22732
|
return { perHour: round62(blocks.reduce((sum, b) => sum + b.cost.perHour, 0)), currency: currencies[0], basis: "sum" };
|
|
22707
22733
|
}
|
|
22708
|
-
function deltaOf(live2,
|
|
22709
|
-
if (!live2 || !
|
|
22710
|
-
if (live2.currency !==
|
|
22711
|
-
diagnostics.push(`no delta for ${label}: the live figure is in ${live2.currency} and the declared one in ${
|
|
22734
|
+
function deltaOf(live2, declared2, label, diagnostics) {
|
|
22735
|
+
if (!live2 || !declared2) return void 0;
|
|
22736
|
+
if (live2.currency !== declared2.currency) {
|
|
22737
|
+
diagnostics.push(`no delta for ${label}: the live figure is in ${live2.currency} and the declared one in ${declared2.currency}`);
|
|
22712
22738
|
return void 0;
|
|
22713
22739
|
}
|
|
22714
|
-
if (live2.basis !==
|
|
22740
|
+
if (live2.basis !== declared2.basis) {
|
|
22715
22741
|
diagnostics.push(`no delta for ${label}: one side is the engine's own total and the other is behold's sum, and those are not the same kind of figure`);
|
|
22716
22742
|
return void 0;
|
|
22717
22743
|
}
|
|
22718
|
-
return { perHour: round62(live2.perHour -
|
|
22744
|
+
return { perHour: round62(live2.perHour - declared2.perHour), currency: live2.currency };
|
|
22719
22745
|
}
|
|
22720
22746
|
function attachBehaviourDelta(ir, members, behaviour) {
|
|
22721
22747
|
const diagnostics = [...behaviour.diagnostics ?? []];
|
|
@@ -22728,7 +22754,7 @@ function attachBehaviourDelta(ir, members, behaviour) {
|
|
|
22728
22754
|
const liveMeta = m.liveMeta === void 0 ? void 0 : validateBehaviourMeta(m.liveMeta);
|
|
22729
22755
|
const liveBlocks = slice.map((n) => n.attrs?._behaviour).filter((b) => !!b);
|
|
22730
22756
|
const live3 = behaviour.refusal ? void 0 : figureOf(liveMeta?.ok ? liveMeta.value : void 0, liveBlocks, (cs) => diagnostics.push(`no live figure for ${label}: the figures are in ${cs.join(" and ")}`));
|
|
22731
|
-
let
|
|
22757
|
+
let declared3;
|
|
22732
22758
|
const report = m.prediction.declared;
|
|
22733
22759
|
if (report) {
|
|
22734
22760
|
const meta = validateBehaviourMeta(report.meta);
|
|
@@ -22746,11 +22772,11 @@ function attachBehaviourDelta(ir, members, behaviour) {
|
|
|
22746
22772
|
const node = byId.get(idFor(m.name, address));
|
|
22747
22773
|
if (node) node.attrs = { ...node.attrs, [DECLARED_ATTR]: v.value };
|
|
22748
22774
|
}
|
|
22749
|
-
|
|
22775
|
+
declared3 = figureOf(meta.value, blocks, (cs) => diagnostics.push(`no declared figure for ${label}: the figures are in ${cs.join(" and ")}`));
|
|
22750
22776
|
}
|
|
22751
22777
|
}
|
|
22752
|
-
const delta2 = deltaOf(live3,
|
|
22753
|
-
if (live3 ||
|
|
22778
|
+
const delta2 = deltaOf(live3, declared3, label, diagnostics);
|
|
22779
|
+
if (live3 || declared3) perMember[label] = { ...live3 ? { live: live3 } : {}, ...declared3 ? { declared: declared3 } : {}, ...delta2 ? { delta: delta2 } : {} };
|
|
22754
22780
|
}
|
|
22755
22781
|
const rows = Object.values(perMember);
|
|
22756
22782
|
const addUp = (side) => {
|
|
@@ -22761,9 +22787,9 @@ function attachBehaviourDelta(ir, members, behaviour) {
|
|
|
22761
22787
|
return { perHour: round62(figures.reduce((sum, f) => sum + f.perHour, 0)), currency: figures[0].currency, basis };
|
|
22762
22788
|
};
|
|
22763
22789
|
const live2 = addUp("live");
|
|
22764
|
-
const
|
|
22790
|
+
const declared2 = addUp("declared");
|
|
22765
22791
|
const allDeltas = rows.length > 0 && rows.every((r) => r.delta);
|
|
22766
|
-
const delta = live2 &&
|
|
22792
|
+
const delta = live2 && declared2 && allDeltas ? { perHour: round62(live2.perHour - declared2.perHour), currency: live2.currency } : void 0;
|
|
22767
22793
|
const out = { ...behaviour };
|
|
22768
22794
|
const stated = rows.filter((r) => r.live?.basis === "total").length;
|
|
22769
22795
|
if (live2 && stated > 1) {
|
|
@@ -22772,7 +22798,7 @@ function attachBehaviourDelta(ir, members, behaviour) {
|
|
|
22772
22798
|
if (at2 >= 0) diagnostics.splice(at2, 1);
|
|
22773
22799
|
}
|
|
22774
22800
|
if (live2) out.live = live2;
|
|
22775
|
-
if (
|
|
22801
|
+
if (declared2) out.declared = declared2;
|
|
22776
22802
|
if (delta) out.delta = delta;
|
|
22777
22803
|
if (rows.length && members.some((m) => m.name !== void 0)) out.members = perMember;
|
|
22778
22804
|
if (diagnostics.length) out.diagnostics = diagnostics;
|
|
@@ -22810,8 +22836,8 @@ function attachDeclaredBehaviour(ir, members) {
|
|
|
22810
22836
|
const node = byId.get(idFor(m.name, address));
|
|
22811
22837
|
if (node) node.attrs = { ...node.attrs, _behaviour: v.value };
|
|
22812
22838
|
}
|
|
22813
|
-
const
|
|
22814
|
-
if (
|
|
22839
|
+
const declared3 = figureOf(meta.value, blocks, (cs) => diagnostics.push(`no declared figure for ${label}: the figures are in ${cs.join(" and ")}`));
|
|
22840
|
+
if (declared3) perMember[label] = { declared: declared3 };
|
|
22815
22841
|
}
|
|
22816
22842
|
if (!first) {
|
|
22817
22843
|
return {
|
|
@@ -22821,12 +22847,12 @@ function attachDeclaredBehaviour(ir, members) {
|
|
|
22821
22847
|
}
|
|
22822
22848
|
const figures = Object.values(perMember).map((r) => r.declared);
|
|
22823
22849
|
const oneCurrency = new Set(figures.map((f) => f.currency)).size === 1;
|
|
22824
|
-
const
|
|
22850
|
+
const declared2 = figures.length && oneCurrency ? { perHour: round62(figures.reduce((sum, f) => sum + f.perHour, 0)), currency: figures[0].currency, basis: figures.length === 1 ? figures[0].basis : "sum" } : void 0;
|
|
22825
22851
|
return {
|
|
22826
22852
|
...first.engine ? { engine: first.engine } : {},
|
|
22827
22853
|
...first.version ? { version: first.version } : {},
|
|
22828
22854
|
...first.at ? { at: first.at } : {},
|
|
22829
|
-
...
|
|
22855
|
+
...declared2 ? { declared: declared2 } : {},
|
|
22830
22856
|
...members.some((m) => m.name !== void 0) && figures.length ? { members: perMember } : {},
|
|
22831
22857
|
...diagnostics.length ? { diagnostics } : {}
|
|
22832
22858
|
};
|
|
@@ -23048,18 +23074,180 @@ function cacheChoudoufuPlan(dir, stamp, drift) {
|
|
|
23048
23074
|
// src/server.ts
|
|
23049
23075
|
init_choudoufu_refs();
|
|
23050
23076
|
|
|
23077
|
+
// src/terralith-demo.ts
|
|
23078
|
+
import { existsSync as existsSync23, readdirSync as readdirSync15, readFileSync as readFileSync27 } from "node:fs";
|
|
23079
|
+
import { join as join36 } from "node:path";
|
|
23080
|
+
var TERRALITH_PHASES = [
|
|
23081
|
+
{ id: "stock", n: 1, dir: "1-stock" },
|
|
23082
|
+
{ id: "adopt", n: 2, dir: "2-adopt" },
|
|
23083
|
+
{ id: "split", n: 3, dir: "3-split" }
|
|
23084
|
+
];
|
|
23085
|
+
var isRecord12 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
23086
|
+
function readJson(path, notes, label) {
|
|
23087
|
+
if (!existsSync23(path)) return void 0;
|
|
23088
|
+
try {
|
|
23089
|
+
return JSON.parse(readFileSync27(path, "utf8"));
|
|
23090
|
+
} catch (err) {
|
|
23091
|
+
notes.push(`${label}: ${err instanceof Error ? err.message : String(err)}`);
|
|
23092
|
+
return void 0;
|
|
23093
|
+
}
|
|
23094
|
+
}
|
|
23095
|
+
function parseRatification(text2) {
|
|
23096
|
+
const out = /* @__PURE__ */ new Map();
|
|
23097
|
+
let status2;
|
|
23098
|
+
for (const line of text2.split("\n")) {
|
|
23099
|
+
const head = /^([A-Z_]+) \(\d+\) - /.exec(line);
|
|
23100
|
+
if (head) {
|
|
23101
|
+
status2 = ["VERIFIED", "DRIFTED", "MISSING", "UNTAGGABLE", "UNADMITTED_TYPE"].includes(head[1]) ? head[1] : void 0;
|
|
23102
|
+
continue;
|
|
23103
|
+
}
|
|
23104
|
+
if (/eligible for stamping/.test(line)) status2 = void 0;
|
|
23105
|
+
const row = /^ {2}(\S+)\s+(\S+)\s+live id: (\S+)\s*$/.exec(line);
|
|
23106
|
+
if (status2 && row) out.set(row[1], { status: status2.toLowerCase(), ...row[3] !== "-" ? { liveId: row[3] } : {} });
|
|
23107
|
+
}
|
|
23108
|
+
return out;
|
|
23109
|
+
}
|
|
23110
|
+
function declared(doc) {
|
|
23111
|
+
if (!isRecord12(doc) || !Array.isArray(doc.instances)) return [];
|
|
23112
|
+
return doc.instances.flatMap((i) => isRecord12(i) && typeof i.address === "string" ? [{ address: i.address, type: typeof i.type === "string" ? i.type : i.address.split(".")[0] }] : []);
|
|
23113
|
+
}
|
|
23114
|
+
function stateIds(doc) {
|
|
23115
|
+
const out = /* @__PURE__ */ new Map();
|
|
23116
|
+
const walk = (mod) => {
|
|
23117
|
+
if (!isRecord12(mod)) return;
|
|
23118
|
+
for (const r of Array.isArray(mod.resources) ? mod.resources : []) {
|
|
23119
|
+
if (isRecord12(r) && typeof r.address === "string" && r.mode === "managed") {
|
|
23120
|
+
const id = isRecord12(r.values) && typeof r.values.id === "string" ? r.values.id : "";
|
|
23121
|
+
out.set(r.address, id);
|
|
23122
|
+
}
|
|
23123
|
+
}
|
|
23124
|
+
for (const c of Array.isArray(mod.child_modules) ? mod.child_modules : []) walk(c);
|
|
23125
|
+
};
|
|
23126
|
+
if (isRecord12(doc) && isRecord12(doc.values)) walk(doc.values.root_module);
|
|
23127
|
+
return out;
|
|
23128
|
+
}
|
|
23129
|
+
var cardOrder = (a, b) => {
|
|
23130
|
+
const name = (c) => c.id.split(".").slice(1).join(".");
|
|
23131
|
+
return name(a).localeCompare(name(b)) || a.type.localeCompare(b.type);
|
|
23132
|
+
};
|
|
23133
|
+
function retagsOf(dir, notes) {
|
|
23134
|
+
const out = /* @__PURE__ */ new Map();
|
|
23135
|
+
const mv = join36(dir, "live-mv");
|
|
23136
|
+
if (!existsSync23(mv)) return out;
|
|
23137
|
+
for (const f of readdirSync15(mv).sort()) {
|
|
23138
|
+
if (!f.endsWith(".json") || f.endsWith(".dry-run.json")) continue;
|
|
23139
|
+
const doc = readJson(join36(mv, f), notes, `live-mv/${f}`);
|
|
23140
|
+
if (!isRecord12(doc) || !isRecord12(doc.from) || !isRecord12(doc.to) || doc.written !== true) continue;
|
|
23141
|
+
const from = String(doc.from.estate ?? "");
|
|
23142
|
+
const to = String(doc.to.estate ?? "");
|
|
23143
|
+
const address = String(doc.to.address ?? doc.from.address ?? "");
|
|
23144
|
+
if (!address) continue;
|
|
23145
|
+
out.set(address, { from, to });
|
|
23146
|
+
for (const fo of Array.isArray(doc.followers) ? doc.followers : []) {
|
|
23147
|
+
if (isRecord12(fo) && typeof fo.address === "string") out.set(fo.address, { from, to, follows: address });
|
|
23148
|
+
}
|
|
23149
|
+
}
|
|
23150
|
+
return out;
|
|
23151
|
+
}
|
|
23152
|
+
function readTerralithPhase(snapshots, phase2, before) {
|
|
23153
|
+
const dir = join36(snapshots, phase2.dir);
|
|
23154
|
+
const notes = [];
|
|
23155
|
+
const meta = readJson(join36(dir, "phase.json"), notes, "phase.json");
|
|
23156
|
+
if (!isRecord12(meta)) return void 0;
|
|
23157
|
+
const roots = Array.isArray(meta.roots) ? meta.roots.filter((r) => typeof r === "string") : [];
|
|
23158
|
+
const retags = retagsOf(dir, notes);
|
|
23159
|
+
const seen = new Set(before?.boxes.map((b) => b.id) ?? []);
|
|
23160
|
+
const boxes = roots.map((root) => {
|
|
23161
|
+
const at2 = (f) => join36(dir, root, f);
|
|
23162
|
+
const check = readJson(at2("live-check.json"), notes, `${root}/live-check.json`);
|
|
23163
|
+
const estate = isRecord12(check) && typeof check.estate === "string" && check.estate ? check.estate : void 0;
|
|
23164
|
+
const state = readJson(at2("state.json"), notes, `${root}/state.json`);
|
|
23165
|
+
const ls = readJson(at2("live-ls.json"), notes, `${root}/live-ls.json`);
|
|
23166
|
+
const plan = readJson(at2("live-plan.json"), notes, `${root}/live-plan.json`);
|
|
23167
|
+
const ratified = existsSync23(at2("live-import.txt")) ? parseRatification(readFileSync27(at2("live-import.txt"), "utf8")) : /* @__PURE__ */ new Map();
|
|
23168
|
+
const ids = stateIds(state);
|
|
23169
|
+
const listed = /* @__PURE__ */ new Map();
|
|
23170
|
+
if (isRecord12(ls) && Array.isArray(ls.items)) {
|
|
23171
|
+
for (const i of ls.items) {
|
|
23172
|
+
if (isRecord12(i) && typeof i.address === "string" && isRecord12(i.tags) && i.tags["tofu-estate"] === estate) listed.set(i.address, String(i.id ?? ""));
|
|
23173
|
+
}
|
|
23174
|
+
}
|
|
23175
|
+
const bound = /* @__PURE__ */ new Map();
|
|
23176
|
+
if (isRecord12(plan) && Array.isArray(plan.bound)) {
|
|
23177
|
+
for (const b of plan.bound) {
|
|
23178
|
+
if (isRecord12(b) && typeof b.addr === "string") bound.set(b.addr, { source: String(b.source ?? ""), ...typeof b.identity === "string" ? { identity: b.identity } : {} });
|
|
23179
|
+
}
|
|
23180
|
+
}
|
|
23181
|
+
const cards = declared(check).map((d) => {
|
|
23182
|
+
const b = bound.get(d.address);
|
|
23183
|
+
const r = ratified.get(d.address);
|
|
23184
|
+
const source2 = !estate ? "state" : b && ["marker", "derived", "record", "cache"].includes(b.source) ? b.source : "unbound";
|
|
23185
|
+
const liveId = b?.identity || listed.get(d.address) || ids.get(d.address) || r?.liveId;
|
|
23186
|
+
const moved = retags.get(d.address);
|
|
23187
|
+
return {
|
|
23188
|
+
id: d.address,
|
|
23189
|
+
type: d.type,
|
|
23190
|
+
root,
|
|
23191
|
+
identity: { source: source2, marked: listed.has(d.address) },
|
|
23192
|
+
...liveId ? { liveId } : {},
|
|
23193
|
+
...r ? { ratified: r.status } : {},
|
|
23194
|
+
...moved && moved.to === estate ? { moved } : {}
|
|
23195
|
+
};
|
|
23196
|
+
});
|
|
23197
|
+
cards.sort(cardOrder);
|
|
23198
|
+
return { id: root, ...estate ? { estate } : {}, stock: !estate, spawned: !!before && !seen.has(root), cards };
|
|
23199
|
+
});
|
|
23200
|
+
const all = boxes.flatMap((b) => b.cards);
|
|
23201
|
+
return {
|
|
23202
|
+
id: phase2.id,
|
|
23203
|
+
n: phase2.n,
|
|
23204
|
+
...typeof meta.at === "string" ? { at: meta.at } : {},
|
|
23205
|
+
...typeof meta.choudoufu === "string" ? { choudoufu: meta.choudoufu } : {},
|
|
23206
|
+
boxes,
|
|
23207
|
+
counts: {
|
|
23208
|
+
cards: all.length,
|
|
23209
|
+
marked: all.filter((c) => c.identity.marked).length,
|
|
23210
|
+
marker: all.filter((c) => c.identity.source === "marker").length,
|
|
23211
|
+
derived: all.filter((c) => c.identity.source === "derived").length,
|
|
23212
|
+
state: all.filter((c) => c.identity.source === "state").length,
|
|
23213
|
+
moved: all.filter((c) => c.moved).length
|
|
23214
|
+
},
|
|
23215
|
+
notes
|
|
23216
|
+
};
|
|
23217
|
+
}
|
|
23218
|
+
function phaseCommand(id) {
|
|
23219
|
+
return id === "stock" ? "bash scripts/terralith-up.sh" : `bash scripts/terralith-step.sh ${id}`;
|
|
23220
|
+
}
|
|
23221
|
+
function readTerralith(root) {
|
|
23222
|
+
const snapshots = join36(root, "snapshots");
|
|
23223
|
+
const phases = [];
|
|
23224
|
+
for (const p of TERRALITH_PHASES) {
|
|
23225
|
+
const read = readTerralithPhase(snapshots, p, phases[phases.length - 1]);
|
|
23226
|
+
if (!read) break;
|
|
23227
|
+
phases.push(read);
|
|
23228
|
+
}
|
|
23229
|
+
const nextPhase = TERRALITH_PHASES[phases.length];
|
|
23230
|
+
const notes = [];
|
|
23231
|
+
const split = readJson(join36(root, "split.json"), notes, "split.json");
|
|
23232
|
+
return {
|
|
23233
|
+
phases,
|
|
23234
|
+
...nextPhase ? { next: { id: nextPhase.id, n: nextPhase.n, command: phaseCommand(nextPhase.id) } } : {},
|
|
23235
|
+
...isRecord12(split) && Array.isArray(split.moves) ? { split: { moves: split.moves.length, estates: Array.isArray(split.estates) ? split.estates.filter((e) => typeof e === "string") : [] } } : {}
|
|
23236
|
+
};
|
|
23237
|
+
}
|
|
23238
|
+
|
|
23051
23239
|
// src/choudoufu-moves.ts
|
|
23052
23240
|
init_choudoufu_member();
|
|
23053
23241
|
init_choudoufu_live();
|
|
23054
|
-
import { existsSync as
|
|
23055
|
-
import { join as
|
|
23056
|
-
var
|
|
23242
|
+
import { existsSync as existsSync24, readFileSync as readFileSync28 } from "node:fs";
|
|
23243
|
+
import { join as join37, relative as relative7 } from "node:path";
|
|
23244
|
+
var isRecord13 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
23057
23245
|
var refuse8 = (error, remedy) => ({ ok: false, refusal: { error, code: "choudoufu-live-check", remedy } });
|
|
23058
|
-
var HOW_TO_GET_ONE2 = "A plan is
|
|
23059
|
-
function
|
|
23060
|
-
if (!
|
|
23246
|
+
var HOW_TO_GET_ONE2 = "A split plan is split.json: `{from, estates[], moves[{address, from, to}]}`. The live-mv workbench's plan phase writes one as carve.json, which reads the same; or write it by hand.";
|
|
23247
|
+
function parseSplitPlan(value) {
|
|
23248
|
+
if (!isRecord13(value)) return refuse8("That file is not a move plan \u2014 its top level is not a JSON object.", HOW_TO_GET_ONE2);
|
|
23061
23249
|
if (!Array.isArray(value.moves)) return refuse8("That JSON is not a move plan \u2014 it has no `moves` array.", HOW_TO_GET_ONE2);
|
|
23062
|
-
const bad2 = value.moves.findIndex((m) => !
|
|
23250
|
+
const bad2 = value.moves.findIndex((m) => !isRecord13(m) || typeof m.address !== "string" || typeof m.from !== "string" || typeof m.to !== "string");
|
|
23063
23251
|
if (bad2 >= 0) return refuse8(`moves[${bad2}] is not a move (needs string \`address\`, \`from\` and \`to\`).`, HOW_TO_GET_ONE2);
|
|
23064
23252
|
const moves = value.moves;
|
|
23065
23253
|
return {
|
|
@@ -23072,7 +23260,7 @@ function parseCarvePlan(value) {
|
|
|
23072
23260
|
}
|
|
23073
23261
|
};
|
|
23074
23262
|
}
|
|
23075
|
-
function
|
|
23263
|
+
function readSplitPlan(path, readFile2 = (p) => readFileSync28(p, "utf8")) {
|
|
23076
23264
|
let text2;
|
|
23077
23265
|
try {
|
|
23078
23266
|
text2 = readFile2(path);
|
|
@@ -23080,16 +23268,17 @@ function readCarvePlan(path, readFile2 = (p) => readFileSync27(p, "utf8")) {
|
|
|
23080
23268
|
return refuse8(`Couldn't read ${path}: ${err instanceof Error ? err.message : String(err)}`, HOW_TO_GET_ONE2);
|
|
23081
23269
|
}
|
|
23082
23270
|
try {
|
|
23083
|
-
return
|
|
23271
|
+
return parseSplitPlan(JSON.parse(text2));
|
|
23084
23272
|
} catch (err) {
|
|
23085
23273
|
return refuse8(`${path} is not JSON: ${err instanceof Error ? err.message : String(err)}`, HOW_TO_GET_ONE2);
|
|
23086
23274
|
}
|
|
23087
23275
|
}
|
|
23088
|
-
|
|
23276
|
+
var SPLIT_PLAN_FILES = ["split.json", "carve.json"];
|
|
23277
|
+
function discoverSplitPlans(memberDirs, base) {
|
|
23089
23278
|
const out = [];
|
|
23090
23279
|
for (const dir of memberDirs) {
|
|
23091
|
-
const
|
|
23092
|
-
if (
|
|
23280
|
+
const file = SPLIT_PLAN_FILES.find((f) => existsSync24(join37(dir, f)));
|
|
23281
|
+
if (file) out.push(relative7(base, join37(dir, file)));
|
|
23093
23282
|
}
|
|
23094
23283
|
return out;
|
|
23095
23284
|
}
|
|
@@ -23103,7 +23292,7 @@ function parseLiveMv(run3, what) {
|
|
|
23103
23292
|
} catch {
|
|
23104
23293
|
return refuse8(`choudoufu live-mv printed something that is not JSON for ${what}.`, "Run the line by hand to see choudoufu's own words.");
|
|
23105
23294
|
}
|
|
23106
|
-
if (!
|
|
23295
|
+
if (!isRecord13(json2) || !isRecord13(json2.from) || !isRecord13(json2.to) || typeof json2.dry_run !== "boolean") {
|
|
23107
23296
|
return refuse8(`That is not a live-mv document (${what}).`, "Upgrade choudoufu to 0.16.0 or newer.");
|
|
23108
23297
|
}
|
|
23109
23298
|
return { ok: true, doc: json2 };
|
|
@@ -23258,7 +23447,7 @@ async function readPolicyOverride(dir, g, read = gitLifecycleReader) {
|
|
|
23258
23447
|
}
|
|
23259
23448
|
|
|
23260
23449
|
// src/workspace-gates.ts
|
|
23261
|
-
var
|
|
23450
|
+
var isRecord14 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
23262
23451
|
var str10 = (v) => typeof v === "string" && v ? v : null;
|
|
23263
23452
|
function gateKey(member, op, gate) {
|
|
23264
23453
|
return `${member}/${op}/${gate}`;
|
|
@@ -23269,16 +23458,16 @@ function approveArgs(g) {
|
|
|
23269
23458
|
function gatesFromStatus(doc, root) {
|
|
23270
23459
|
const contract = contractRefusal(doc, "status");
|
|
23271
23460
|
if (contract) return { ok: false, refusal: contract };
|
|
23272
|
-
if (
|
|
23461
|
+
if (isRecord14(doc.error)) {
|
|
23273
23462
|
const code = String(doc.error.code ?? "unknown");
|
|
23274
23463
|
return { ok: false, refusal: { error: `chant could not read the workspace's status: ${code}: ${String(doc.error.message ?? "")}`, code, remedy: "`chant workspace check` names the problem and where it is." } };
|
|
23275
23464
|
}
|
|
23276
23465
|
const gates = [];
|
|
23277
23466
|
for (const m of Array.isArray(doc.members) ? doc.members : []) {
|
|
23278
|
-
if (!
|
|
23467
|
+
if (!isRecord14(m) || typeof m.name !== "string") continue;
|
|
23279
23468
|
const dir = typeof m.dir === "string" ? m.dir === "." ? resolve20(root) : resolve20(root, m.dir) : resolve20(root);
|
|
23280
23469
|
for (const g of Array.isArray(m.gates) ? m.gates : []) {
|
|
23281
|
-
if (!
|
|
23470
|
+
if (!isRecord14(g)) continue;
|
|
23282
23471
|
const op = str10(g.component);
|
|
23283
23472
|
const gate = str10(g.name);
|
|
23284
23473
|
if (!op || !gate) continue;
|
|
@@ -23286,7 +23475,7 @@ function gatesFromStatus(doc, root) {
|
|
|
23286
23475
|
if (g.state !== void 0 && g.state !== "pending" && !keepApproved) continue;
|
|
23287
23476
|
const env = str10(g.env);
|
|
23288
23477
|
const planDigest = str10(g.planDigest);
|
|
23289
|
-
const approvals = (Array.isArray(g.approvals) ? g.approvals : []).filter(
|
|
23478
|
+
const approvals = (Array.isArray(g.approvals) ? g.approvals : []).filter(isRecord14).map((a) => ({
|
|
23290
23479
|
principal: String(a.principal ?? "unknown"),
|
|
23291
23480
|
at: str10(a.at),
|
|
23292
23481
|
channel: str10(a.channel)
|
|
@@ -23303,11 +23492,11 @@ function gatesFromStatus(doc, root) {
|
|
|
23303
23492
|
needed: typeof g.needed === "number" ? g.needed : 1,
|
|
23304
23493
|
recordedAt: str10(g.recordedAt),
|
|
23305
23494
|
expiresAt: str10(g.expiresAt),
|
|
23306
|
-
signed:
|
|
23495
|
+
signed: isRecord14(g.signed),
|
|
23307
23496
|
// status's line already carries --sign for a signed gate; only the
|
|
23308
23497
|
// line built here needs it added.
|
|
23309
23498
|
state: keepApproved ? "approved" : "pending",
|
|
23310
|
-
approve: str10(g.approve) ?? ["chant", ...approveArgs({ op, gate, env, planDigest }), ...
|
|
23499
|
+
approve: str10(g.approve) ?? ["chant", ...approveArgs({ op, gate, env, planDigest }), ...isRecord14(g.signed) ? ["--sign"] : []].join(" ")
|
|
23311
23500
|
});
|
|
23312
23501
|
}
|
|
23313
23502
|
}
|
|
@@ -23343,7 +23532,7 @@ function localApprover(env = process.env) {
|
|
|
23343
23532
|
|
|
23344
23533
|
// src/workspace-why.ts
|
|
23345
23534
|
var WHY_COMMITS_SHOWN = 8;
|
|
23346
|
-
var
|
|
23535
|
+
var isRecord15 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
23347
23536
|
var str11 = (v) => typeof v === "string" && v ? v : null;
|
|
23348
23537
|
var num2 = (v) => typeof v === "number" && Number.isFinite(v) ? v : 0;
|
|
23349
23538
|
var strings3 = (v) => Array.isArray(v) ? v.filter((x) => typeof x === "string") : [];
|
|
@@ -23368,12 +23557,12 @@ function hudReviewUrl(hud, record) {
|
|
|
23368
23557
|
return `${hud.replace(/\/+$/, "")}/decisions#${encodeURIComponent(record)}`;
|
|
23369
23558
|
}
|
|
23370
23559
|
function whyFromIntent(doc, hud = null) {
|
|
23371
|
-
if (
|
|
23560
|
+
if (isRecord15(doc.error)) {
|
|
23372
23561
|
const code = String(doc.error.code ?? "unknown");
|
|
23373
23562
|
return refuse9(`chant couldn't read that region: ${code}: ${String(doc.error.message ?? "")}`, code, code === "intent-region-invalid" ? "chant reads a node's why from the file that declares it; a card behold added (a live-only or ops card) has none." : "Run `chant workspace graph --intent <region>` in the workspace root.");
|
|
23374
23563
|
}
|
|
23375
23564
|
const nodes = /* @__PURE__ */ new Map();
|
|
23376
|
-
for (const n of Array.isArray(doc.nodes) ? doc.nodes : []) if (
|
|
23565
|
+
for (const n of Array.isArray(doc.nodes) ? doc.nodes : []) if (isRecord15(n) && typeof n.id === "string") nodes.set(n.id, n);
|
|
23377
23566
|
const regionId = String(doc.region ?? "");
|
|
23378
23567
|
const regionNode = nodes.get(regionId);
|
|
23379
23568
|
const base = {
|
|
@@ -23383,12 +23572,12 @@ function whyFromIntent(doc, hud = null) {
|
|
|
23383
23572
|
chant: String(doc.chant ?? "")
|
|
23384
23573
|
};
|
|
23385
23574
|
const why = doc.why;
|
|
23386
|
-
if (!
|
|
23575
|
+
if (!isRecord15(why)) {
|
|
23387
23576
|
return { ok: true, why: { ...base, answered: false, explained: false, decisions: [], runs: [], commits: [], commitsTotal: 0, uncommittedLines: 0, gaps: [] } };
|
|
23388
23577
|
}
|
|
23389
23578
|
const decisions = [];
|
|
23390
23579
|
for (const d of Array.isArray(why.decisions) ? why.decisions : []) {
|
|
23391
|
-
if (!
|
|
23580
|
+
if (!isRecord15(d) || typeof d.decision !== "string") continue;
|
|
23392
23581
|
const n = nodes.get(d.decision) ?? {};
|
|
23393
23582
|
const id = str11(n.record) ?? after(d.decision, "record:").replace(/^[^/]*\//, "");
|
|
23394
23583
|
const state = str11(n.state);
|
|
@@ -23407,28 +23596,28 @@ function whyFromIntent(doc, hud = null) {
|
|
|
23407
23596
|
}
|
|
23408
23597
|
const commitOf = (id) => {
|
|
23409
23598
|
const n = nodes.get(id) ?? {};
|
|
23410
|
-
const joins =
|
|
23599
|
+
const joins = isRecord15(n.joins) ? n.joins : {};
|
|
23411
23600
|
return {
|
|
23412
23601
|
sha: str11(n.sha) ?? after(id, "commit:"),
|
|
23413
23602
|
subject: str11(n.subject),
|
|
23414
23603
|
date: str11(n.date),
|
|
23415
|
-
author:
|
|
23604
|
+
author: isRecord15(n.author) ? str11(n.author.name) : null,
|
|
23416
23605
|
pullRequest: typeof n.pullRequest === "number" ? n.pullRequest : null,
|
|
23417
23606
|
run: str11(joins.run)
|
|
23418
23607
|
};
|
|
23419
23608
|
};
|
|
23420
23609
|
const runs2 = [];
|
|
23421
23610
|
for (const r of Array.isArray(why.runs) ? why.runs : []) {
|
|
23422
|
-
if (!
|
|
23611
|
+
if (!isRecord15(r) || typeof r.run !== "string") continue;
|
|
23423
23612
|
const n = nodes.get(r.run) ?? {};
|
|
23424
|
-
const unit =
|
|
23613
|
+
const unit = isRecord15(r.unit) ? str11(r.unit.id) : null;
|
|
23425
23614
|
runs2.push({
|
|
23426
23615
|
id: str11(n.run) ?? after(r.run, "run:"),
|
|
23427
23616
|
lines: num2(r.lines),
|
|
23428
23617
|
commits: strings3(r.commits).map((c) => commitOf(c).sha),
|
|
23429
23618
|
unit,
|
|
23430
23619
|
by: str11(n.by),
|
|
23431
|
-
harness:
|
|
23620
|
+
harness: isRecord15(n.harness) ? str11(n.harness.name) : null,
|
|
23432
23621
|
model: str11(n.model),
|
|
23433
23622
|
outcome: str11(n.outcome),
|
|
23434
23623
|
startedAt: str11(n.startedAt),
|
|
@@ -23436,7 +23625,7 @@ function whyFromIntent(doc, hud = null) {
|
|
|
23436
23625
|
decisions: strings3(r.decisions).map((d) => str11(nodes.get(d)?.record) ?? after(d, "record:"))
|
|
23437
23626
|
});
|
|
23438
23627
|
}
|
|
23439
|
-
const blame = (Array.isArray(why.blame) ? why.blame : []).filter(
|
|
23628
|
+
const blame = (Array.isArray(why.blame) ? why.blame : []).filter(isRecord15);
|
|
23440
23629
|
let uncommittedLines = 0;
|
|
23441
23630
|
const ids = [];
|
|
23442
23631
|
for (const span of blame) {
|
|
@@ -23463,7 +23652,7 @@ function whyFromIntent(doc, hud = null) {
|
|
|
23463
23652
|
commits: commits.slice(0, WHY_COMMITS_SHOWN),
|
|
23464
23653
|
commitsTotal: commits.length,
|
|
23465
23654
|
uncommittedLines,
|
|
23466
|
-
gaps: (Array.isArray(why.gaps) ? why.gaps : []).filter(
|
|
23655
|
+
gaps: (Array.isArray(why.gaps) ? why.gaps : []).filter(isRecord15).map((g) => ({ code: String(g.code ?? ""), message: String(g.message ?? "") }))
|
|
23467
23656
|
}
|
|
23468
23657
|
};
|
|
23469
23658
|
}
|
|
@@ -23589,10 +23778,10 @@ function chantCheck(root, targets, estate) {
|
|
|
23589
23778
|
}
|
|
23590
23779
|
return { name: "chant", status: "pass", detail: `${versions}${floor ? ` (behold's floor ${floor})` : ""}` };
|
|
23591
23780
|
}
|
|
23592
|
-
function lexiconCheck(root,
|
|
23781
|
+
function lexiconCheck(root, declared2, estate) {
|
|
23593
23782
|
const missing = [];
|
|
23594
23783
|
const found = [];
|
|
23595
|
-
for (const [target, lexicons] of
|
|
23784
|
+
for (const [target, lexicons] of declared2) {
|
|
23596
23785
|
const label = labelFor(root, target, estate);
|
|
23597
23786
|
for (const r of resolveLexicons(target, lexicons)) {
|
|
23598
23787
|
(r.installed ? found : missing).push(`${label}${r.lexicon}${r.installed && r.version ? ` ${r.version}` : ""}`);
|
|
@@ -23611,8 +23800,8 @@ function lexiconCheck(root, declared, estate) {
|
|
|
23611
23800
|
}
|
|
23612
23801
|
return { name: "lexicons", status: "pass", detail: `${found.length} installed: ${list2(found)}` };
|
|
23613
23802
|
}
|
|
23614
|
-
function targetCheck(
|
|
23615
|
-
const lexicons = [...new Set([...
|
|
23803
|
+
function targetCheck(declared2) {
|
|
23804
|
+
const lexicons = [...new Set([...declared2.values()].flat())].sort();
|
|
23616
23805
|
const routable = new Set(SUBSTRATE_TARGET_VARS.map((t2) => t2.lexicon));
|
|
23617
23806
|
const unlisted = lexicons.filter((l) => !routable.has(l) && !(l in NO_AMBIENT_TARGET));
|
|
23618
23807
|
if (!lexicons.length) return { name: "targets", status: "pass", detail: "no lexicon declared \u2014 nothing to aim" };
|
|
@@ -23863,7 +24052,7 @@ async function diagnose(dir, probes = {}) {
|
|
|
23863
24052
|
fix: kindsFix
|
|
23864
24053
|
} : { name: "project", status: "pass", detail: `${emptyDeclaration}${estateDetail}` } : { name: "project", status: "pass", detail: `${emptyDeclaration}chant project (${relative8(root, shape.configFile)})` };
|
|
23865
24054
|
const infos = await Promise.all(chantTargets.map(async (t2) => ({ target: t2, info: await detectProject(t2) })));
|
|
23866
|
-
const
|
|
24055
|
+
const declared2 = new Map(infos.map(({ target, info }) => [target, info.lexicons]));
|
|
23867
24056
|
const lexicons = [...new Set(infos.flatMap(({ info }) => info.lexicons))];
|
|
23868
24057
|
const envs = [...new Set(infos.flatMap(({ info }) => info.environments))];
|
|
23869
24058
|
const profiles = {};
|
|
@@ -23875,8 +24064,8 @@ async function diagnose(dir, probes = {}) {
|
|
|
23875
24064
|
const checks = [
|
|
23876
24065
|
projectCheck,
|
|
23877
24066
|
chantCheck(root, chantTargets, estate),
|
|
23878
|
-
lexiconCheck(root,
|
|
23879
|
-
targetCheck(
|
|
24067
|
+
lexiconCheck(root, declared2, estate),
|
|
24068
|
+
targetCheck(declared2),
|
|
23880
24069
|
// An estate root is not itself servable — the hint has to name its members
|
|
23881
24070
|
// (`behold serve a b c`, #31), which is what a stranger would otherwise
|
|
23882
24071
|
// discover by having the root serve nothing. The `.` member (#387) is the
|
|
@@ -23912,8 +24101,8 @@ init_read_stats();
|
|
|
23912
24101
|
init_foreign();
|
|
23913
24102
|
|
|
23914
24103
|
// src/events.ts
|
|
23915
|
-
import { watch, existsSync as
|
|
23916
|
-
import { join as
|
|
24104
|
+
import { watch, existsSync as existsSync25 } from "node:fs";
|
|
24105
|
+
import { join as join38 } from "node:path";
|
|
23917
24106
|
var Broadcaster = class {
|
|
23918
24107
|
listeners = /* @__PURE__ */ new Set();
|
|
23919
24108
|
subscribe(fn) {
|
|
@@ -23931,7 +24120,7 @@ var Broadcaster = class {
|
|
|
23931
24120
|
};
|
|
23932
24121
|
var IGNORE = /(^|[\\/])(node_modules|dist|\.git)([\\/]|$)/;
|
|
23933
24122
|
function watchSource(projectDir, onChange, debounceMs = 200) {
|
|
23934
|
-
const dir =
|
|
24123
|
+
const dir = existsSync25(join38(projectDir, "src")) ? join38(projectDir, "src") : projectDir;
|
|
23935
24124
|
let timer;
|
|
23936
24125
|
const watcher = watch(dir, { recursive: true }, (_event, file) => {
|
|
23937
24126
|
const name = typeof file === "string" ? file : "";
|
|
@@ -24235,13 +24424,13 @@ async function emulatorDown(projectDir) {
|
|
|
24235
24424
|
|
|
24236
24425
|
// src/terragucci-view.ts
|
|
24237
24426
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
24238
|
-
import { dirname as dirname13, join as
|
|
24427
|
+
import { dirname as dirname13, join as join44, relative as relative9, sep as sep8 } from "node:path";
|
|
24239
24428
|
init_terraform_member();
|
|
24240
24429
|
|
|
24241
24430
|
// src/terragucci-reports.ts
|
|
24242
|
-
import { readFileSync as
|
|
24431
|
+
import { readFileSync as readFileSync29, statSync as statSync11 } from "node:fs";
|
|
24243
24432
|
import { createRequire as createRequire4 } from "node:module";
|
|
24244
|
-
import { dirname as dirname10, join as
|
|
24433
|
+
import { dirname as dirname10, join as join39, resolve as resolve22 } from "node:path";
|
|
24245
24434
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
24246
24435
|
import { Ajv2020 } from "ajv/dist/2020.js";
|
|
24247
24436
|
var REPORT_SCHEMA = "terragucci.report/v1";
|
|
@@ -24274,34 +24463,34 @@ function attributeValues(a) {
|
|
|
24274
24463
|
}
|
|
24275
24464
|
var SCHEMA_FILES = { report: "report.schema.json", index: "report-index.schema.json", estate: "estate.schema.json" };
|
|
24276
24465
|
var SCHEMA_IDS = { report: REPORT_SCHEMA, index: INDEX_SCHEMA, estate: ESTATE_SCHEMA };
|
|
24277
|
-
var
|
|
24466
|
+
var isRecord16 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
24278
24467
|
var str12 = (v) => typeof v === "string";
|
|
24279
24468
|
function structural(name, doc) {
|
|
24280
|
-
if (!
|
|
24469
|
+
if (!isRecord16(doc)) return "it is not a JSON object";
|
|
24281
24470
|
if (doc.schema !== SCHEMA_IDS[name]) return `its schema is ${JSON.stringify(doc.schema)}, not ${SCHEMA_IDS[name]}`;
|
|
24282
24471
|
if (name === "index") {
|
|
24283
24472
|
if (!Array.isArray(doc.reports)) return "it has no reports array";
|
|
24284
24473
|
for (const [i, r] of doc.reports.entries()) {
|
|
24285
|
-
if (!
|
|
24474
|
+
if (!isRecord16(r) || !str12(r.project) || !str12(r.commit) || !str12(r.stage) || !str12(r.finished) || !str12(r.path)) return `row ${i} lacks project, commit, stage, finished or path`;
|
|
24286
24475
|
}
|
|
24287
24476
|
} else if (name === "report") {
|
|
24288
24477
|
const run3 = doc.run;
|
|
24289
|
-
if (!
|
|
24478
|
+
if (!isRecord16(run3) || !str12(run3.project) || !str12(run3.commit) || !str12(run3.stage) || !str12(run3.finished)) return "its run lacks project, commit, stage or finished";
|
|
24290
24479
|
if (!Array.isArray(doc.roots) || !Array.isArray(doc.waves)) return "it has no roots or waves array";
|
|
24291
24480
|
for (const [i, r] of doc.roots.entries()) {
|
|
24292
|
-
if (!
|
|
24293
|
-
for (const c of r.changes) if (!
|
|
24481
|
+
if (!isRecord16(r) || !str12(r.path) || r.status !== "planned" && r.status !== "failed" || !Array.isArray(r.changes)) return `root ${i} lacks path, status or changes`;
|
|
24482
|
+
for (const c of r.changes) if (!isRecord16(c) || !str12(c.address) || !str12(c.action)) return `a change in root ${String(r.path)} lacks address or action`;
|
|
24294
24483
|
}
|
|
24295
24484
|
} else {
|
|
24296
|
-
if (!str12(doc.generated) || !
|
|
24297
|
-
for (const p of doc.projects) if (!
|
|
24485
|
+
if (!str12(doc.generated) || !isRecord16(doc.totals) || !Array.isArray(doc.projects)) return "it lacks generated, totals or projects";
|
|
24486
|
+
for (const p of doc.projects) if (!isRecord16(p) || !str12(p.project) || !Array.isArray(p.waiting)) return "a project lacks project or waiting";
|
|
24298
24487
|
}
|
|
24299
24488
|
return void 0;
|
|
24300
24489
|
}
|
|
24301
24490
|
var compiledSchemas = /* @__PURE__ */ new Map();
|
|
24302
24491
|
function schemaStamp(dist) {
|
|
24303
24492
|
try {
|
|
24304
|
-
const files = [
|
|
24493
|
+
const files = [join39(dist, "..", "package.json"), ...Object.values(SCHEMA_FILES).map((f) => join39(dist, f))];
|
|
24305
24494
|
return [dist, ...files.map((f) => {
|
|
24306
24495
|
const st = statSync11(f);
|
|
24307
24496
|
return `${st.mtimeMs}:${st.size}`;
|
|
@@ -24311,15 +24500,15 @@ function schemaStamp(dist) {
|
|
|
24311
24500
|
}
|
|
24312
24501
|
}
|
|
24313
24502
|
function compileSchemas(dist) {
|
|
24314
|
-
const version = JSON.parse(
|
|
24503
|
+
const version = JSON.parse(readFileSync29(join39(dist, "..", "package.json"), "utf8")).version ?? "";
|
|
24315
24504
|
const ajv = new Ajv2020({ strict: false, allErrors: false });
|
|
24316
24505
|
const compiled4 = Object.fromEntries(
|
|
24317
|
-
Object.keys(SCHEMA_FILES).map((n) => [n, ajv.compile(JSON.parse(
|
|
24506
|
+
Object.keys(SCHEMA_FILES).map((n) => [n, ajv.compile(JSON.parse(readFileSync29(join39(dist, SCHEMA_FILES[n]), "utf8")))])
|
|
24318
24507
|
);
|
|
24319
24508
|
return {
|
|
24320
24509
|
validation: { by: "schema", terragucci: version },
|
|
24321
24510
|
check(name, doc) {
|
|
24322
|
-
const id =
|
|
24511
|
+
const id = isRecord16(doc) ? doc.schema : void 0;
|
|
24323
24512
|
if (id !== SCHEMA_IDS[name]) return `its schema is ${JSON.stringify(id)}, not ${SCHEMA_IDS[name]}`;
|
|
24324
24513
|
if (compiled4[name](doc)) return void 0;
|
|
24325
24514
|
const e = compiled4[name].errors?.[0];
|
|
@@ -24331,7 +24520,7 @@ function terragucciValidator(dirs = []) {
|
|
|
24331
24520
|
for (const from of [...dirs, dirname10(fileURLToPath5(import.meta.url))]) {
|
|
24332
24521
|
let entry;
|
|
24333
24522
|
try {
|
|
24334
|
-
entry = createRequire4(
|
|
24523
|
+
entry = createRequire4(join39(resolve22(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json");
|
|
24335
24524
|
} catch {
|
|
24336
24525
|
continue;
|
|
24337
24526
|
}
|
|
@@ -24688,9 +24877,9 @@ function joinTerragucci(read, nodes, roots) {
|
|
|
24688
24877
|
}
|
|
24689
24878
|
|
|
24690
24879
|
// src/terragucci-timeline.ts
|
|
24691
|
-
import { readFileSync as
|
|
24880
|
+
import { readFileSync as readFileSync30, statSync as statSync12 } from "node:fs";
|
|
24692
24881
|
import { createRequire as createRequire5 } from "node:module";
|
|
24693
|
-
import { dirname as dirname11, join as
|
|
24882
|
+
import { dirname as dirname11, join as join40, resolve as resolve23 } from "node:path";
|
|
24694
24883
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
24695
24884
|
import { Ajv2020 as Ajv20202 } from "ajv/dist/2020.js";
|
|
24696
24885
|
var AUDIT_SCHEMA = "terragucci.audit/v1";
|
|
@@ -24700,17 +24889,17 @@ var WHAT_IS_ROOT = /* @__PURE__ */ new Set(["override-requested", "override", "o
|
|
|
24700
24889
|
var TIMELINE_LIMIT = 200;
|
|
24701
24890
|
var TIMELINE_MAX = 1e3;
|
|
24702
24891
|
var TIMELINE_TTL_MS = 3e4;
|
|
24703
|
-
var
|
|
24892
|
+
var isRecord17 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
24704
24893
|
var str13 = (v) => typeof v === "string";
|
|
24705
24894
|
function structuralAudit(doc) {
|
|
24706
|
-
if (!
|
|
24895
|
+
if (!isRecord17(doc)) return "it is not a JSON object";
|
|
24707
24896
|
if (doc.schema !== AUDIT_SCHEMA) return `its schema is ${JSON.stringify(doc.schema)}, not ${AUDIT_SCHEMA}`;
|
|
24708
24897
|
for (const f of ["id", "kind", "project", "at", "what", "result"]) if (!str13(doc[f])) return `its ${f} is not a string`;
|
|
24709
24898
|
if (Number.isNaN(Date.parse(doc.at))) return `its at, ${JSON.stringify(doc.at)}, is not a time`;
|
|
24710
24899
|
if (doc.who !== null && !str13(doc.who)) return "its who is neither a string nor null";
|
|
24711
24900
|
if (doc.digest !== null && !str13(doc.digest)) return "its digest is neither a string nor null";
|
|
24712
|
-
if (!
|
|
24713
|
-
if (doc.detail !== void 0 && !
|
|
24901
|
+
if (!isRecord17(doc.evidence) || !str13(doc.evidence.source)) return "its evidence has no source";
|
|
24902
|
+
if (doc.detail !== void 0 && !isRecord17(doc.detail)) return "its detail is not an object";
|
|
24714
24903
|
return void 0;
|
|
24715
24904
|
}
|
|
24716
24905
|
function compileAuditSchema(schema, version) {
|
|
@@ -24718,7 +24907,7 @@ function compileAuditSchema(schema, version) {
|
|
|
24718
24907
|
return {
|
|
24719
24908
|
validation: { by: "schema", terragucci: version },
|
|
24720
24909
|
check(doc) {
|
|
24721
|
-
const id =
|
|
24910
|
+
const id = isRecord17(doc) ? doc.schema : void 0;
|
|
24722
24911
|
if (id !== AUDIT_SCHEMA) return `its schema is ${JSON.stringify(id)}, not ${AUDIT_SCHEMA}`;
|
|
24723
24912
|
if (v(doc)) return void 0;
|
|
24724
24913
|
const e = v.errors?.[0];
|
|
@@ -24731,12 +24920,12 @@ function auditValidator(dirs = []) {
|
|
|
24731
24920
|
for (const from of [...dirs, dirname11(fileURLToPath6(import.meta.url))]) {
|
|
24732
24921
|
let dist;
|
|
24733
24922
|
try {
|
|
24734
|
-
dist = dirname11(createRequire5(
|
|
24923
|
+
dist = dirname11(createRequire5(join40(resolve23(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json"));
|
|
24735
24924
|
} catch {
|
|
24736
24925
|
continue;
|
|
24737
24926
|
}
|
|
24738
|
-
const pkg =
|
|
24739
|
-
const file =
|
|
24927
|
+
const pkg = join40(dist, "..", "package.json");
|
|
24928
|
+
const file = join40(dist, AUDIT_SCHEMA_FILE);
|
|
24740
24929
|
let stamp;
|
|
24741
24930
|
try {
|
|
24742
24931
|
stamp = [dist, ...[pkg, file].map((f) => {
|
|
@@ -24750,8 +24939,8 @@ function auditValidator(dirs = []) {
|
|
|
24750
24939
|
if (hit) return hit;
|
|
24751
24940
|
let v;
|
|
24752
24941
|
try {
|
|
24753
|
-
const version = JSON.parse(
|
|
24754
|
-
v = compileAuditSchema(JSON.parse(
|
|
24942
|
+
const version = JSON.parse(readFileSync30(pkg, "utf8")).version ?? "";
|
|
24943
|
+
v = compileAuditSchema(JSON.parse(readFileSync30(file, "utf8")), version);
|
|
24755
24944
|
} catch {
|
|
24756
24945
|
continue;
|
|
24757
24946
|
}
|
|
@@ -24793,8 +24982,8 @@ function ownRoots(e) {
|
|
|
24793
24982
|
if (Array.isArray(listed)) {
|
|
24794
24983
|
for (const r of listed) {
|
|
24795
24984
|
if (str13(r)) roots.add(r);
|
|
24796
|
-
else if (
|
|
24797
|
-
else if (
|
|
24985
|
+
else if (isRecord17(r) && str13(r.root)) roots.add(r.root);
|
|
24986
|
+
else if (isRecord17(r) && str13(r.path)) roots.add(r.path);
|
|
24798
24987
|
}
|
|
24799
24988
|
}
|
|
24800
24989
|
if (WHAT_IS_ROOT.has(e.kind)) roots.add(e.what);
|
|
@@ -24947,7 +25136,7 @@ function terragucciTimelineRoute(app, source2, opts = {}) {
|
|
|
24947
25136
|
// src/terragucci-poll.ts
|
|
24948
25137
|
import { createHash as createHash10 } from "node:crypto";
|
|
24949
25138
|
import { stat } from "node:fs/promises";
|
|
24950
|
-
import { join as
|
|
25139
|
+
import { join as join41, resolve as resolve24 } from "node:path";
|
|
24951
25140
|
import { streamSSE } from "hono/streaming";
|
|
24952
25141
|
var TERRAGUCCI_POLL_SECS = 30;
|
|
24953
25142
|
var INDEX_KEY = "index.json";
|
|
@@ -24998,7 +25187,7 @@ function indexProbe(spec2, opts = {}) {
|
|
|
24998
25187
|
return verdict2(prev, etag);
|
|
24999
25188
|
};
|
|
25000
25189
|
}
|
|
25001
|
-
const file =
|
|
25190
|
+
const file = join41(resolve24(opts.cwd ?? process.cwd(), spec2), name);
|
|
25002
25191
|
return async (prev) => {
|
|
25003
25192
|
try {
|
|
25004
25193
|
const s = await stat(file);
|
|
@@ -25153,29 +25342,29 @@ function terragucciLaneRoutes(app, o, base, forget) {
|
|
|
25153
25342
|
}
|
|
25154
25343
|
|
|
25155
25344
|
// src/terragucci-progress.ts
|
|
25156
|
-
import { readFileSync as
|
|
25345
|
+
import { readFileSync as readFileSync31, statSync as statSync13 } from "node:fs";
|
|
25157
25346
|
import { createRequire as createRequire6 } from "node:module";
|
|
25158
|
-
import { dirname as dirname12, join as
|
|
25347
|
+
import { dirname as dirname12, join as join42, resolve as resolve25 } from "node:path";
|
|
25159
25348
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
25160
25349
|
import { Ajv2020 as Ajv20203 } from "ajv/dist/2020.js";
|
|
25161
25350
|
var RUN_SCHEMA = "terragucci.run/v1";
|
|
25162
25351
|
var RUN_SCHEMA_FILE = "run.schema.json";
|
|
25163
25352
|
var PROGRESS_TTL_MS = 3e4;
|
|
25164
25353
|
var PROGRESS_STATUSES = ["done", "in-flight", "waiting", "not-applied"];
|
|
25165
|
-
var
|
|
25354
|
+
var isRecord18 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
25166
25355
|
var str14 = (v) => typeof v === "string";
|
|
25167
25356
|
function structuralRun(doc) {
|
|
25168
|
-
if (!
|
|
25357
|
+
if (!isRecord18(doc)) return "it is not a JSON object";
|
|
25169
25358
|
if (doc.schema !== RUN_SCHEMA) return `its schema is ${JSON.stringify(doc.schema)}, not ${RUN_SCHEMA}`;
|
|
25170
25359
|
for (const f of ["project", "commit", "updated"]) if (!str14(doc[f])) return `its ${f} is not a string`;
|
|
25171
25360
|
if (!Array.isArray(doc.waves)) return "it has no waves array";
|
|
25172
25361
|
for (const [i, w] of doc.waves.entries()) {
|
|
25173
|
-
if (!
|
|
25362
|
+
if (!isRecord18(w) || typeof w.number !== "number" || !str14(w.state) || !str14(w.gate) || !Array.isArray(w.roots)) return `wave ${i} lacks number, state, gate or roots`;
|
|
25174
25363
|
if (w.progress === void 0) continue;
|
|
25175
25364
|
const p = w.progress;
|
|
25176
|
-
if (!
|
|
25365
|
+
if (!isRecord18(p) || !str14(p.read) || !Array.isArray(p.resources)) return `wave ${String(w.number)}'s progress lacks read or resources`;
|
|
25177
25366
|
for (const r of p.resources) {
|
|
25178
|
-
if (!
|
|
25367
|
+
if (!isRecord18(r) || !str14(r.root) || !str14(r.address) || !str14(r.action)) return `a resource of wave ${String(w.number)}'s progress lacks root, address or action`;
|
|
25179
25368
|
if (!PROGRESS_STATUSES.includes(r.status)) return `a resource of wave ${String(w.number)}'s progress has status ${JSON.stringify(r.status)}`;
|
|
25180
25369
|
if (r.done_at !== void 0 && !str14(r.done_at)) return `a resource of wave ${String(w.number)}'s progress has a done_at that is not a string`;
|
|
25181
25370
|
}
|
|
@@ -25187,7 +25376,7 @@ function compileRunSchema(schema, version) {
|
|
|
25187
25376
|
return {
|
|
25188
25377
|
validation: { by: "schema", terragucci: version },
|
|
25189
25378
|
check(doc) {
|
|
25190
|
-
const id =
|
|
25379
|
+
const id = isRecord18(doc) ? doc.schema : void 0;
|
|
25191
25380
|
if (id !== RUN_SCHEMA) return `its schema is ${JSON.stringify(id)}, not ${RUN_SCHEMA}`;
|
|
25192
25381
|
if (v(doc)) return void 0;
|
|
25193
25382
|
const e = v.errors?.[0];
|
|
@@ -25200,12 +25389,12 @@ function runValidator(dirs = []) {
|
|
|
25200
25389
|
for (const from of [...dirs, dirname12(fileURLToPath7(import.meta.url))]) {
|
|
25201
25390
|
let dist;
|
|
25202
25391
|
try {
|
|
25203
|
-
dist = dirname12(createRequire6(
|
|
25392
|
+
dist = dirname12(createRequire6(join42(resolve25(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json"));
|
|
25204
25393
|
} catch {
|
|
25205
25394
|
continue;
|
|
25206
25395
|
}
|
|
25207
|
-
const pkg =
|
|
25208
|
-
const file =
|
|
25396
|
+
const pkg = join42(dist, "..", "package.json");
|
|
25397
|
+
const file = join42(dist, RUN_SCHEMA_FILE);
|
|
25209
25398
|
let stamp;
|
|
25210
25399
|
try {
|
|
25211
25400
|
stamp = [dist, ...[pkg, file].map((f) => {
|
|
@@ -25219,8 +25408,8 @@ function runValidator(dirs = []) {
|
|
|
25219
25408
|
if (hit) return hit;
|
|
25220
25409
|
let v;
|
|
25221
25410
|
try {
|
|
25222
|
-
const version = JSON.parse(
|
|
25223
|
-
v = compileRunSchema(JSON.parse(
|
|
25411
|
+
const version = JSON.parse(readFileSync31(pkg, "utf8")).version ?? "";
|
|
25412
|
+
v = compileRunSchema(JSON.parse(readFileSync31(file, "utf8")), version);
|
|
25224
25413
|
} catch {
|
|
25225
25414
|
continue;
|
|
25226
25415
|
}
|
|
@@ -25513,19 +25702,19 @@ function terragucciProgressRoute(app, progress) {
|
|
|
25513
25702
|
}
|
|
25514
25703
|
|
|
25515
25704
|
// src/terragucci-demo.ts
|
|
25516
|
-
import { readFileSync as
|
|
25517
|
-
import { join as
|
|
25705
|
+
import { readFileSync as readFileSync32 } from "node:fs";
|
|
25706
|
+
import { join as join43 } from "node:path";
|
|
25518
25707
|
var DEMO_KEY = "demo.json";
|
|
25519
25708
|
var DEMO_READ_TTL_MS = 2e3;
|
|
25520
25709
|
var DEMO_STEPS = ["pull-request", "planned", "merged", "applying", "waiting", "approved", "failed", "resumed", "applied", "reset", "stalled"];
|
|
25521
25710
|
var DEMO_ABOUT_FIELDS = ["changes", "watch", "shows"];
|
|
25522
25711
|
var UTC = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/;
|
|
25523
|
-
var
|
|
25712
|
+
var isRecord19 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
25524
25713
|
var str15 = (v) => typeof v === "string";
|
|
25525
25714
|
var int2 = (v) => typeof v === "number" && Number.isInteger(v);
|
|
25526
25715
|
var positive = (v) => int2(v) && v > 0 ? v : null;
|
|
25527
25716
|
function demoProblem(doc) {
|
|
25528
|
-
if (!
|
|
25717
|
+
if (!isRecord19(doc)) return "it is not an object";
|
|
25529
25718
|
if (!int2(doc.cycle)) return "cycle is not an integer";
|
|
25530
25719
|
if (!str15(doc.scenario) || !doc.scenario) return "scenario is not a string";
|
|
25531
25720
|
if (!str15(doc.title)) return "title is not a string";
|
|
@@ -25533,14 +25722,14 @@ function demoProblem(doc) {
|
|
|
25533
25722
|
if (!str15(doc.label)) return "label is not a string";
|
|
25534
25723
|
if (!str15(doc.started_at) || !UTC.test(doc.started_at)) return "started_at is not a UTC time (YYYY-MM-DDTHH:MM:SSZ)";
|
|
25535
25724
|
if (doc.next !== null) {
|
|
25536
|
-
if (!
|
|
25725
|
+
if (!isRecord19(doc.next)) return "next is neither an object nor null";
|
|
25537
25726
|
if (!str15(doc.next.action)) return "next.action is not a string";
|
|
25538
25727
|
if (doc.next.at !== null && !(str15(doc.next.at) && UTC.test(doc.next.at))) return "next.at is neither a UTC time nor null";
|
|
25539
25728
|
}
|
|
25540
25729
|
if (doc.pull !== null && !int2(doc.pull)) return "pull is neither an integer nor null";
|
|
25541
25730
|
if (doc.commit !== null && !str15(doc.commit)) return "commit is neither a string nor null";
|
|
25542
25731
|
if (doc.about !== void 0 && doc.about !== null) {
|
|
25543
|
-
if (!
|
|
25732
|
+
if (!isRecord19(doc.about)) return "about is neither an object nor null";
|
|
25544
25733
|
for (const f of DEMO_ABOUT_FIELDS) if (!str15(doc.about[f]) || !doc.about[f].trim()) return `about.${f} is not a non-empty string`;
|
|
25545
25734
|
}
|
|
25546
25735
|
return void 0;
|
|
@@ -25604,7 +25793,7 @@ function kioskRoute(app, webRoot2, enabled) {
|
|
|
25604
25793
|
if (!enabled) {
|
|
25605
25794
|
return c.html(disabledPage, 404);
|
|
25606
25795
|
}
|
|
25607
|
-
return new Response(
|
|
25796
|
+
return new Response(readFileSync32(join43(webRoot2, "kiosk.html"), "utf8"), { headers: { "content-type": "text/html; charset=utf-8", "cache-control": "no-cache" } });
|
|
25608
25797
|
});
|
|
25609
25798
|
}
|
|
25610
25799
|
var VENDOR_TOOLS = ["terraform", "terragrunt", "cdk-terrain", "choudoufu", "chant"];
|
|
@@ -25613,7 +25802,7 @@ var cycleKey = (tool) => `cycles/${tool}/latest.json`;
|
|
|
25613
25802
|
var CYCLE_READ_TTL_MS = 1e4;
|
|
25614
25803
|
var timeOrNull2 = (v) => v === null || v === void 0 || str15(v) && UTC.test(v);
|
|
25615
25804
|
function cycleProblem(doc, tool) {
|
|
25616
|
-
if (!
|
|
25805
|
+
if (!isRecord19(doc)) return "it is not an object";
|
|
25617
25806
|
if (doc.schema !== void 0 && doc.schema !== "demo.cycle/v1") return `schema is ${JSON.stringify(doc.schema)}, not demo.cycle/v1`;
|
|
25618
25807
|
if (doc.tool !== tool) return `tool is ${JSON.stringify(doc.tool)}, not ${tool}`;
|
|
25619
25808
|
if (!str15(doc.repo) || !doc.repo) return "repo is not a string";
|
|
@@ -25684,7 +25873,7 @@ function vendorRoutes(app, webRoot2, enabled) {
|
|
|
25684
25873
|
for (const tool of VENDOR_TOOLS) {
|
|
25685
25874
|
app.get(`/${tool}`, (c) => {
|
|
25686
25875
|
if (!enabled) return c.html(disabledPage, 404);
|
|
25687
|
-
const html = vendorPage(
|
|
25876
|
+
const html = vendorPage(readFileSync32(join43(webRoot2, "kiosk.html"), "utf8"), tool);
|
|
25688
25877
|
return new Response(html, { headers: { "content-type": "text/html; charset=utf-8", "cache-control": "no-cache" } });
|
|
25689
25878
|
});
|
|
25690
25879
|
}
|
|
@@ -25733,7 +25922,7 @@ function checkoutRoots(dirs, base = repoBase(dirs)) {
|
|
|
25733
25922
|
for (const m of estateMembers(dirs)) {
|
|
25734
25923
|
if (m.kind !== "terraform") continue;
|
|
25735
25924
|
for (const r of checkoutRootDirs(m.dir)) {
|
|
25736
|
-
const path = relative9(base,
|
|
25925
|
+
const path = relative9(base, join44(m.dir, r.dir)).split(sep8).join("/") || ".";
|
|
25737
25926
|
out.push({ member: m.name, name: r.name, path });
|
|
25738
25927
|
}
|
|
25739
25928
|
}
|
|
@@ -26040,8 +26229,8 @@ function metricsRoute(app, opts) {
|
|
|
26040
26229
|
|
|
26041
26230
|
// src/view-repos.ts
|
|
26042
26231
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
26043
|
-
import { existsSync as
|
|
26044
|
-
import { join as
|
|
26232
|
+
import { existsSync as existsSync26, readdirSync as readdirSync16, readFileSync as readFileSync33 } from "node:fs";
|
|
26233
|
+
import { join as join45, resolve as resolve26 } from "node:path";
|
|
26045
26234
|
var NAME2 = /^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/;
|
|
26046
26235
|
function repoName(value) {
|
|
26047
26236
|
const v = value.trim().replace(/\.git$/, "");
|
|
@@ -26051,11 +26240,11 @@ function repoName(value) {
|
|
|
26051
26240
|
function listCheckouts(parent) {
|
|
26052
26241
|
let names;
|
|
26053
26242
|
try {
|
|
26054
|
-
names =
|
|
26243
|
+
names = readdirSync16(parent, { withFileTypes: true }).filter((e) => e.isDirectory() && NAME2.test(e.name)).map((e) => e.name).sort();
|
|
26055
26244
|
} catch {
|
|
26056
26245
|
return [];
|
|
26057
26246
|
}
|
|
26058
|
-
return names.map((name) => ({ name, dir: resolve26(parent, name) })).filter((c) =>
|
|
26247
|
+
return names.map((name) => ({ name, dir: resolve26(parent, name) })).filter((c) => existsSync26(join45(c.dir, ".git")));
|
|
26059
26248
|
}
|
|
26060
26249
|
var scope = new AsyncLocalStorage2();
|
|
26061
26250
|
function scopeServedDirs(cfg) {
|
|
@@ -26097,7 +26286,7 @@ var SHA = /^[0-9a-f]{40}([0-9a-f]{24})?$/;
|
|
|
26097
26286
|
function checkoutCommit(dir) {
|
|
26098
26287
|
const read = (f) => {
|
|
26099
26288
|
try {
|
|
26100
|
-
return
|
|
26289
|
+
return readFileSync33(join45(dir, ".git", f), "utf8");
|
|
26101
26290
|
} catch {
|
|
26102
26291
|
return void 0;
|
|
26103
26292
|
}
|
|
@@ -26127,8 +26316,8 @@ function viewRepoFacts(repos, servedDir) {
|
|
|
26127
26316
|
}
|
|
26128
26317
|
|
|
26129
26318
|
// src/lifecycle-releases.ts
|
|
26130
|
-
import { existsSync as
|
|
26131
|
-
import { join as
|
|
26319
|
+
import { existsSync as existsSync27, readFileSync as readFileSync34 } from "node:fs";
|
|
26320
|
+
import { join as join46 } from "node:path";
|
|
26132
26321
|
|
|
26133
26322
|
// node_modules/@intentius/chant/src/lifecycle/legacy-digest.ts
|
|
26134
26323
|
import { resolve as resolve27 } from "node:path";
|
|
@@ -26241,10 +26430,10 @@ function memberNote(l) {
|
|
|
26241
26430
|
// src/lifecycle-releases.ts
|
|
26242
26431
|
var WAVES_SPEC_FILE = "yodel-waves.json";
|
|
26243
26432
|
function waveOrder(checkout) {
|
|
26244
|
-
const p =
|
|
26245
|
-
if (!
|
|
26433
|
+
const p = join46(checkout, WAVES_SPEC_FILE);
|
|
26434
|
+
if (!existsSync27(p)) return void 0;
|
|
26246
26435
|
try {
|
|
26247
|
-
const doc = JSON.parse(
|
|
26436
|
+
const doc = JSON.parse(readFileSync34(p, "utf8"));
|
|
26248
26437
|
const names = (doc.waves ?? []).map((w) => w?.name).filter((n) => typeof n === "string" && n.length > 0);
|
|
26249
26438
|
return names.length ? [...new Set(names)] : void 0;
|
|
26250
26439
|
} catch {
|
|
@@ -26252,7 +26441,7 @@ function waveOrder(checkout) {
|
|
|
26252
26441
|
}
|
|
26253
26442
|
}
|
|
26254
26443
|
function hasReleaseLedgerHint(checkout) {
|
|
26255
|
-
return
|
|
26444
|
+
return existsSync27(join46(checkout, "yodel.config.ts")) || existsSync27(join46(checkout, WAVES_SPEC_FILE));
|
|
26256
26445
|
}
|
|
26257
26446
|
function orderEnvironments(envs, waves) {
|
|
26258
26447
|
const seen = new Set(envs);
|
|
@@ -26294,7 +26483,7 @@ function releaseCells(ledgers, order, sources) {
|
|
|
26294
26483
|
}
|
|
26295
26484
|
async function copyCheckoutRef(git3, checkout, cache6) {
|
|
26296
26485
|
assertScratch(cache6.split(/[\\/]/).pop());
|
|
26297
|
-
if (!
|
|
26486
|
+
if (!existsSync27(join46(cache6, "HEAD"))) {
|
|
26298
26487
|
const init = await git3(["init", "--bare", "-q", cache6]);
|
|
26299
26488
|
if (init.code !== 0) return false;
|
|
26300
26489
|
}
|
|
@@ -26397,8 +26586,8 @@ function releasesRoutes(app, base, opts = {}) {
|
|
|
26397
26586
|
}
|
|
26398
26587
|
|
|
26399
26588
|
// src/sql-yodeler-lane.ts
|
|
26400
|
-
import { existsSync as
|
|
26401
|
-
import { join as
|
|
26589
|
+
import { existsSync as existsSync28, readdirSync as readdirSync17, readFileSync as readFileSync35 } from "node:fs";
|
|
26590
|
+
import { join as join47 } from "node:path";
|
|
26402
26591
|
var YODEL_APPLY_OP = "yodel-apply";
|
|
26403
26592
|
var YODEL_HEAD_PLANS_DIR = headPlansPath(YODEL_APPLY_OP, "").dir;
|
|
26404
26593
|
function parseYodelWaves(text2, path = WAVES_SPEC_FILE) {
|
|
@@ -26430,19 +26619,19 @@ function parseYodelWaves(text2, path = WAVES_SPEC_FILE) {
|
|
|
26430
26619
|
return { path, waves };
|
|
26431
26620
|
}
|
|
26432
26621
|
function readYodelWaves(checkout) {
|
|
26433
|
-
const p =
|
|
26434
|
-
if (!
|
|
26622
|
+
const p = join47(checkout, WAVES_SPEC_FILE);
|
|
26623
|
+
if (!existsSync28(p)) return void 0;
|
|
26435
26624
|
try {
|
|
26436
|
-
return parseYodelWaves(
|
|
26625
|
+
return parseYodelWaves(readFileSync35(p, "utf8"));
|
|
26437
26626
|
} catch (e) {
|
|
26438
26627
|
return { path: WAVES_SPEC_FILE, waves: [], error: e instanceof Error ? e.message : String(e) };
|
|
26439
26628
|
}
|
|
26440
26629
|
}
|
|
26441
26630
|
function migrateOpEnvironments(checkout) {
|
|
26442
|
-
const dir =
|
|
26443
|
-
if (!
|
|
26631
|
+
const dir = join47(checkout, "ops");
|
|
26632
|
+
if (!existsSync28(dir)) return [];
|
|
26444
26633
|
try {
|
|
26445
|
-
return
|
|
26634
|
+
return readdirSync17(dir).map((f) => /^migrate-(.+)\.op\.ts$/.exec(f)?.[1]).filter((e) => !!e).sort();
|
|
26446
26635
|
} catch {
|
|
26447
26636
|
return [];
|
|
26448
26637
|
}
|
|
@@ -26562,16 +26751,16 @@ function sqlYodelerLaneRoute(app, checkout, opts = {}) {
|
|
|
26562
26751
|
|
|
26563
26752
|
// src/terragucci-estate.ts
|
|
26564
26753
|
init_yaml();
|
|
26565
|
-
import { existsSync as
|
|
26754
|
+
import { existsSync as existsSync29, readFileSync as readFileSync36, statSync as statSync14 } from "node:fs";
|
|
26566
26755
|
import { createRequire as createRequire7 } from "node:module";
|
|
26567
|
-
import { dirname as dirname14, extname as extname2, join as
|
|
26756
|
+
import { dirname as dirname14, extname as extname2, join as join48, resolve as resolve28 } from "node:path";
|
|
26568
26757
|
import { fileURLToPath as fileURLToPath8 } from "node:url";
|
|
26569
26758
|
import { Ajv2020 as Ajv20204 } from "ajv/dist/2020.js";
|
|
26570
26759
|
var RUN_SCHEMA2 = "terragucci.run/v1";
|
|
26571
26760
|
function configProjects(file) {
|
|
26572
26761
|
let text2;
|
|
26573
26762
|
try {
|
|
26574
|
-
text2 =
|
|
26763
|
+
text2 = readFileSync36(file, "utf8");
|
|
26575
26764
|
} catch {
|
|
26576
26765
|
return void 0;
|
|
26577
26766
|
}
|
|
@@ -26599,21 +26788,21 @@ function controlRepo(dirs, roots = () => checkoutRoots(dirs).length) {
|
|
|
26599
26788
|
}
|
|
26600
26789
|
return n === 0 ? { config, projects } : void 0;
|
|
26601
26790
|
}
|
|
26602
|
-
var
|
|
26791
|
+
var isRecord20 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
26603
26792
|
var str16 = (v) => typeof v === "string";
|
|
26604
26793
|
var int3 = (v) => typeof v === "number" && Number.isInteger(v);
|
|
26605
26794
|
function structuralRun2(doc) {
|
|
26606
|
-
if (!
|
|
26795
|
+
if (!isRecord20(doc)) return "it is not a JSON object";
|
|
26607
26796
|
if (doc.schema !== RUN_SCHEMA2) return `its schema is ${JSON.stringify(doc.schema)}, not ${RUN_SCHEMA2}`;
|
|
26608
26797
|
if (!str16(doc.project) || !str16(doc.commit) || !str16(doc.updated)) return "it lacks project, commit or updated";
|
|
26609
26798
|
if (!Array.isArray(doc.roots) || !Array.isArray(doc.waves)) return "it has no roots or waves array";
|
|
26610
26799
|
for (const [i, r] of doc.roots.entries()) {
|
|
26611
|
-
if (!
|
|
26612
|
-
if (r.state !== void 0 && !(
|
|
26613
|
-
if (r.external !== void 0 && !(Array.isArray(r.external) && r.external.every((x) =>
|
|
26800
|
+
if (!isRecord20(r) || !str16(r.root) || !int3(r.wave) || !Array.isArray(r.reads) || !r.reads.every(str16)) return `root ${i} lacks root, wave or reads`;
|
|
26801
|
+
if (r.state !== void 0 && !(isRecord20(r.state) && str16(r.state.key))) return `root ${String(r.root)}'s state has no key`;
|
|
26802
|
+
if (r.external !== void 0 && !(Array.isArray(r.external) && r.external.every((x) => isRecord20(x) && str16(x.data) && str16(x.key)))) return `root ${String(r.root)}'s external reads lack data or key`;
|
|
26614
26803
|
}
|
|
26615
26804
|
for (const [i, w] of doc.waves.entries()) {
|
|
26616
|
-
if (!
|
|
26805
|
+
if (!isRecord20(w) || !int3(w.number) || !Array.isArray(w.roots) || !Array.isArray(w.reads) || !str16(w.state) || !str16(w.gate)) return `wave ${i} lacks number, roots, reads, state or gate`;
|
|
26617
26806
|
}
|
|
26618
26807
|
return void 0;
|
|
26619
26808
|
}
|
|
@@ -26622,16 +26811,16 @@ function runViewValidator(dirs = []) {
|
|
|
26622
26811
|
for (const from of [...dirs, dirname14(fileURLToPath8(import.meta.url))]) {
|
|
26623
26812
|
let entry;
|
|
26624
26813
|
try {
|
|
26625
|
-
entry = createRequire7(
|
|
26814
|
+
entry = createRequire7(join48(resolve28(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json");
|
|
26626
26815
|
} catch {
|
|
26627
26816
|
continue;
|
|
26628
26817
|
}
|
|
26629
26818
|
const dist = dirname14(entry);
|
|
26630
|
-
const schema =
|
|
26819
|
+
const schema = join48(dist, "run.schema.json");
|
|
26631
26820
|
let stamp;
|
|
26632
26821
|
try {
|
|
26633
26822
|
const st = statSync14(schema);
|
|
26634
|
-
const pkg = statSync14(
|
|
26823
|
+
const pkg = statSync14(join48(dist, "..", "package.json"));
|
|
26635
26824
|
stamp = `${schema}\0${st.mtimeMs}:${st.size}\0${pkg.mtimeMs}`;
|
|
26636
26825
|
} catch {
|
|
26637
26826
|
continue;
|
|
@@ -26640,12 +26829,12 @@ function runViewValidator(dirs = []) {
|
|
|
26640
26829
|
if (hit) return hit;
|
|
26641
26830
|
let v;
|
|
26642
26831
|
try {
|
|
26643
|
-
const version = JSON.parse(
|
|
26644
|
-
const validate = new Ajv20204({ strict: false, allErrors: false }).compile(JSON.parse(
|
|
26832
|
+
const version = JSON.parse(readFileSync36(join48(dist, "..", "package.json"), "utf8")).version ?? "";
|
|
26833
|
+
const validate = new Ajv20204({ strict: false, allErrors: false }).compile(JSON.parse(readFileSync36(schema, "utf8")));
|
|
26645
26834
|
v = {
|
|
26646
26835
|
validation: { by: "schema", terragucci: version },
|
|
26647
26836
|
check(doc) {
|
|
26648
|
-
const id =
|
|
26837
|
+
const id = isRecord20(doc) ? doc.schema : void 0;
|
|
26649
26838
|
if (id !== RUN_SCHEMA2) return `its schema is ${JSON.stringify(id)}, not ${RUN_SCHEMA2}`;
|
|
26650
26839
|
if (validate(doc)) return void 0;
|
|
26651
26840
|
const e = validate.errors?.[0];
|
|
@@ -26696,8 +26885,8 @@ function controlEdges(views) {
|
|
|
26696
26885
|
function siblingCheckout(project, base, projectOf = checkoutProject) {
|
|
26697
26886
|
const name = project.split("/").filter(Boolean).pop();
|
|
26698
26887
|
if (!name) return void 0;
|
|
26699
|
-
const dir =
|
|
26700
|
-
if (dir === resolve28(base) || !
|
|
26888
|
+
const dir = join48(dirname14(resolve28(base)), name);
|
|
26889
|
+
if (dir === resolve28(base) || !existsSync29(join48(dir, ".git"))) return void 0;
|
|
26701
26890
|
return projectOf(dir) === project ? dir : void 0;
|
|
26702
26891
|
}
|
|
26703
26892
|
var shellWord = (s) => /^[A-Za-z0-9_./:@%+=,-]+$/.test(s) ? s : `'${s.replace(/'/g, `'\\''`)}'`;
|
|
@@ -26904,9 +27093,9 @@ function controlRepoInfo(dirs) {
|
|
|
26904
27093
|
}
|
|
26905
27094
|
|
|
26906
27095
|
// src/yodel-report.ts
|
|
26907
|
-
import { readdirSync as
|
|
27096
|
+
import { readdirSync as readdirSync18, readFileSync as readFileSync37, statSync as statSync15 } from "node:fs";
|
|
26908
27097
|
import { createRequire as createRequire8 } from "node:module";
|
|
26909
|
-
import { basename as basename5, dirname as dirname15, join as
|
|
27098
|
+
import { basename as basename5, dirname as dirname15, join as join49, resolve as resolve29 } from "node:path";
|
|
26910
27099
|
import { fileURLToPath as fileURLToPath9 } from "node:url";
|
|
26911
27100
|
import { Ajv2020 as Ajv20205 } from "ajv/dist/2020.js";
|
|
26912
27101
|
|
|
@@ -27335,13 +27524,13 @@ var installed = /* @__PURE__ */ new Map();
|
|
|
27335
27524
|
function packageRoot(from) {
|
|
27336
27525
|
let entry;
|
|
27337
27526
|
try {
|
|
27338
|
-
entry = createRequire8(
|
|
27527
|
+
entry = createRequire8(join49(resolve29(from), "noop.js")).resolve("@intentius/sql-yodeler");
|
|
27339
27528
|
} catch {
|
|
27340
27529
|
return void 0;
|
|
27341
27530
|
}
|
|
27342
27531
|
for (let d = dirname15(entry); d !== dirname15(d); d = dirname15(d)) {
|
|
27343
27532
|
try {
|
|
27344
|
-
const pkg = JSON.parse(
|
|
27533
|
+
const pkg = JSON.parse(readFileSync37(join49(d, "package.json"), "utf8"));
|
|
27345
27534
|
if (pkg.name === "@intentius/sql-yodeler") return d;
|
|
27346
27535
|
} catch {
|
|
27347
27536
|
}
|
|
@@ -27353,11 +27542,11 @@ function yodelValidator(dirs = []) {
|
|
|
27353
27542
|
const root = packageRoot(from);
|
|
27354
27543
|
if (!root) continue;
|
|
27355
27544
|
try {
|
|
27356
|
-
const version = JSON.parse(
|
|
27545
|
+
const version = JSON.parse(readFileSync37(join49(root, "package.json"), "utf8")).version ?? "";
|
|
27357
27546
|
const key2 = `${root}\0${version}`;
|
|
27358
27547
|
let v = installed.get(key2);
|
|
27359
27548
|
if (!v) {
|
|
27360
|
-
const load2 = (n) => JSON.parse(
|
|
27549
|
+
const load2 = (n) => JSON.parse(readFileSync37(join49(root, "schemas", `${n}.schema.json`), "utf8"));
|
|
27361
27550
|
v = compile({ common: load2("common"), report: load2("report"), drift: load2("drift") }, { by: "schema", from: "package", sqlYodeler: version });
|
|
27362
27551
|
installed.set(key2, v);
|
|
27363
27552
|
}
|
|
@@ -27368,9 +27557,9 @@ function yodelValidator(dirs = []) {
|
|
|
27368
27557
|
pinned ??= compile({ common: common_schema_default, report: report_schema_default, drift: drift_schema_default }, { by: "schema", from: "pinned", commit: PINNED_COMMIT.slice(0, 7) });
|
|
27369
27558
|
return pinned;
|
|
27370
27559
|
}
|
|
27371
|
-
var
|
|
27372
|
-
var looksLikeReport = (d) =>
|
|
27373
|
-
var looksLikeDrift = (d) =>
|
|
27560
|
+
var isRecord21 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
27561
|
+
var looksLikeReport = (d) => isRecord21(d) && "generatedAt" in d && "environments" in d;
|
|
27562
|
+
var looksLikeDrift = (d) => isRecord21(d) && "environment" in d && ("drifted" in d || "changed" in d);
|
|
27374
27563
|
function filesOf(source2) {
|
|
27375
27564
|
let st;
|
|
27376
27565
|
try {
|
|
@@ -27379,7 +27568,7 @@ function filesOf(source2) {
|
|
|
27379
27568
|
return refuse14(`--yodel-report ${source2}: no such file or directory`, "Point --yodel-report at the file `yodel report --json` wrote, or the directory holding it.");
|
|
27380
27569
|
}
|
|
27381
27570
|
const dir = st.isDirectory() ? source2 : dirname15(source2);
|
|
27382
|
-
const files =
|
|
27571
|
+
const files = readdirSync18(dir).filter((f) => f.endsWith(".json")).sort().map((f) => join49(dir, f));
|
|
27383
27572
|
return st.isDirectory() ? { dir, files } : { dir, files, named: resolve29(source2) };
|
|
27384
27573
|
}
|
|
27385
27574
|
function readYodelReport(source2, validator2) {
|
|
@@ -27391,7 +27580,7 @@ function readYodelReport(source2, validator2) {
|
|
|
27391
27580
|
for (const file of files) {
|
|
27392
27581
|
let doc;
|
|
27393
27582
|
try {
|
|
27394
|
-
doc = JSON.parse(
|
|
27583
|
+
doc = JSON.parse(readFileSync37(file, "utf8"));
|
|
27395
27584
|
} catch (e) {
|
|
27396
27585
|
if (file === named) refuse14(`${basename5(file)} is not JSON: ${e instanceof Error ? e.message : String(e)}`, remedy);
|
|
27397
27586
|
ignored.push(basename5(file));
|
|
@@ -27478,24 +27667,24 @@ function yodelReportRoute(app, source2, dirs) {
|
|
|
27478
27667
|
|
|
27479
27668
|
// src/demo-pins.ts
|
|
27480
27669
|
init_terraform_member();
|
|
27481
|
-
import { existsSync as
|
|
27482
|
-
import { dirname as dirname16, join as
|
|
27483
|
-
var
|
|
27670
|
+
import { existsSync as existsSync30, lstatSync as lstatSync2, mkdirSync as mkdirSync7, readFileSync as readFileSync38, readlinkSync as readlinkSync2, symlinkSync as symlinkSync2, writeFileSync as writeFileSync6 } from "node:fs";
|
|
27671
|
+
import { dirname as dirname16, join as join50, resolve as resolve30 } from "node:path";
|
|
27672
|
+
var isRecord22 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
27484
27673
|
function linkDemoPins(work, probes = {}) {
|
|
27485
|
-
const file =
|
|
27486
|
-
if (!
|
|
27674
|
+
const file = join50(work, "chant.workspace.json");
|
|
27675
|
+
if (!existsSync30(file)) return { ok: true, linked: [] };
|
|
27487
27676
|
let decl;
|
|
27488
27677
|
try {
|
|
27489
|
-
decl = JSON.parse(
|
|
27678
|
+
decl = JSON.parse(readFileSync38(file, "utf8"));
|
|
27490
27679
|
} catch {
|
|
27491
27680
|
return { ok: true, linked: [] };
|
|
27492
27681
|
}
|
|
27493
|
-
if (!
|
|
27682
|
+
if (!isRecord22(decl) || !Array.isArray(decl.pins)) return { ok: true, linked: [] };
|
|
27494
27683
|
const find = probes.resolve ?? ((pkg) => resolvedPackage(pkg));
|
|
27495
27684
|
const linked = [];
|
|
27496
27685
|
let rewrite = false;
|
|
27497
27686
|
for (const pin of decl.pins) {
|
|
27498
|
-
if (!
|
|
27687
|
+
if (!isRecord22(pin) || typeof pin.package !== "string") continue;
|
|
27499
27688
|
const pkg = pin.package;
|
|
27500
27689
|
if (pkg === TERRAFORM_LEXICON_PKG) {
|
|
27501
27690
|
const refusal2 = (probes.reader ?? terraformReaderState)().refusal;
|
|
@@ -27509,7 +27698,7 @@ function linkDemoPins(work, probes = {}) {
|
|
|
27509
27698
|
remedy: `Install ${pkg} beside behold, then load the demo again.`
|
|
27510
27699
|
};
|
|
27511
27700
|
}
|
|
27512
|
-
const link =
|
|
27701
|
+
const link = join50(work, "node_modules", ...pkg.split("/"));
|
|
27513
27702
|
if (!present(link)) {
|
|
27514
27703
|
mkdirSync7(dirname16(link), { recursive: true });
|
|
27515
27704
|
symlinkSync2(found.dir, link, "junction");
|
|
@@ -27544,13 +27733,13 @@ function linksTo(link, target) {
|
|
|
27544
27733
|
}
|
|
27545
27734
|
|
|
27546
27735
|
// src/demos.ts
|
|
27547
|
-
import { readFileSync as
|
|
27548
|
-
import { dirname as dirname17, isAbsolute as isAbsolute5, join as
|
|
27736
|
+
import { readFileSync as readFileSync39, existsSync as existsSync31, cpSync, mkdirSync as mkdirSync8 } from "node:fs";
|
|
27737
|
+
import { dirname as dirname17, isAbsolute as isAbsolute5, join as join51, relative as relative10, resolve as resolve31, sep as sep9 } from "node:path";
|
|
27549
27738
|
import { spawn as spawn8, spawnSync as spawnSync3 } from "node:child_process";
|
|
27550
27739
|
function readCatalog(file, catalog) {
|
|
27551
27740
|
let raw;
|
|
27552
27741
|
try {
|
|
27553
|
-
raw = JSON.parse(
|
|
27742
|
+
raw = JSON.parse(readFileSync39(file, "utf8"));
|
|
27554
27743
|
} catch {
|
|
27555
27744
|
return [];
|
|
27556
27745
|
}
|
|
@@ -27579,6 +27768,7 @@ function validEntry(e) {
|
|
|
27579
27768
|
if (d.serve.dirs !== void 0 && (!Array.isArray(d.serve.dirs) || d.serve.dirs.some((x) => typeof x !== "string") || !d.serve.dirs.length)) return false;
|
|
27580
27769
|
if (d.serve.spawnEnv !== void 0 && (typeof d.serve.spawnEnv !== "object" || d.serve.spawnEnv === null || Array.isArray(d.serve.spawnEnv) || Object.values(d.serve.spawnEnv).some((v) => typeof v !== "string")))
|
|
27581
27770
|
return false;
|
|
27771
|
+
if (d.serve.terralith !== void 0 && typeof d.serve.terralith !== "boolean") return false;
|
|
27582
27772
|
if (d.serve.carve !== void 0) {
|
|
27583
27773
|
const c = d.serve.carve;
|
|
27584
27774
|
const rel = (v) => typeof v === "string" && !!v && !v.startsWith("/") && !v.split("/").includes("..");
|
|
@@ -27590,10 +27780,10 @@ function validEntry(e) {
|
|
|
27590
27780
|
return true;
|
|
27591
27781
|
}
|
|
27592
27782
|
function loadDemoRegistry(pkgRoot3) {
|
|
27593
|
-
const merged = readCatalog(
|
|
27783
|
+
const merged = readCatalog(join51(pkgRoot3, "demos.json"), "demos");
|
|
27594
27784
|
const seen = new Set(merged.map((e) => e.name));
|
|
27595
27785
|
const named = process.env.BEHOLD_WORKBENCH;
|
|
27596
|
-
for (const e of [...readCatalog(
|
|
27786
|
+
for (const e of [...readCatalog(join51(pkgRoot3, "workbench.json"), "workbench"), ...named ? readCatalog(resolve31(named), "workbench") : []]) {
|
|
27597
27787
|
if (seen.has(e.name)) {
|
|
27598
27788
|
process.stderr.write(`behold: workbench entry "${e.name}" collides with a demo already in the catalog \u2014 dropped
|
|
27599
27789
|
`);
|
|
@@ -27612,11 +27802,11 @@ function missingRequirements(entry) {
|
|
|
27612
27802
|
const bins = entry.source === "git" && !entry.requires.includes("git") ? [...entry.requires, "git"] : entry.requires;
|
|
27613
27803
|
const finder = process.platform === "win32" ? "where" : "which";
|
|
27614
27804
|
const missing = bins.filter((bin) => {
|
|
27615
|
-
if (bin === "choudoufu" && process.env.CHOUDOUFU_BIN &&
|
|
27805
|
+
if (bin === "choudoufu" && process.env.CHOUDOUFU_BIN && existsSync31(process.env.CHOUDOUFU_BIN)) return false;
|
|
27616
27806
|
return spawnSync3(finder, [bin], { stdio: "ignore" }).status !== 0;
|
|
27617
27807
|
});
|
|
27618
27808
|
const local = demoLocalPath(entry);
|
|
27619
|
-
if (local && !
|
|
27809
|
+
if (local && !existsSync31(local)) missing.push(`${entry.path} (not checked out)`);
|
|
27620
27810
|
return missing;
|
|
27621
27811
|
}
|
|
27622
27812
|
function fetchesFromNetwork(entry) {
|
|
@@ -27626,7 +27816,7 @@ function demoTargetDir(entry, cwd = process.cwd()) {
|
|
|
27626
27816
|
const inPlace = entry.inPlace ? demoLocalPath(entry) : void 0;
|
|
27627
27817
|
if (inPlace) return inPlace;
|
|
27628
27818
|
const legacy = resolve31(cwd, "behold-demo");
|
|
27629
|
-
if (entry.name === "writes" &&
|
|
27819
|
+
if (entry.name === "writes" && existsSync31(legacy)) return legacy;
|
|
27630
27820
|
return resolve31(cwd, "behold-demos", entry.name);
|
|
27631
27821
|
}
|
|
27632
27822
|
async function loadDemo(entry, opts) {
|
|
@@ -27636,12 +27826,12 @@ async function loadDemo(entry, opts) {
|
|
|
27636
27826
|
const inPlace = entry.source === "local" && entry.inPlace;
|
|
27637
27827
|
const work = inPlace ? local : target;
|
|
27638
27828
|
if (inPlace) {
|
|
27639
|
-
if (!
|
|
27829
|
+
if (!existsSync31(work)) return { ok: false, error: `${entry.path} is not checked out (looked in ${work})` };
|
|
27640
27830
|
say(`serving ${work} where it is \u2014 nothing copied`);
|
|
27641
|
-
} else if (!
|
|
27831
|
+
} else if (!existsSync31(target)) {
|
|
27642
27832
|
if (entry.source === "bundled" || entry.source === "local" && local) {
|
|
27643
|
-
const from = entry.source === "bundled" ?
|
|
27644
|
-
if (!
|
|
27833
|
+
const from = entry.source === "bundled" ? join51(pkgRoot3, entry.dir) : local;
|
|
27834
|
+
if (!existsSync31(from)) return { ok: false, error: entry.source === "bundled" ? `this install has no bundled ${entry.dir}` : `${entry.path} is not checked out (looked in ${from})` };
|
|
27645
27835
|
say(`copying to ${target} (it's yours \u2014 edit it)`);
|
|
27646
27836
|
try {
|
|
27647
27837
|
cpSync(from, target, {
|
|
@@ -27672,7 +27862,7 @@ async function loadDemo(entry, opts) {
|
|
|
27672
27862
|
if (!pins.ok) return { ok: false, error: `${pins.error} ${pins.remedy}` };
|
|
27673
27863
|
for (const p of pins.linked) say(`linked ${p.pkg} ${p.version} into the copy${p.was ? ` (the declaration pinned ${p.was}; now ${p.version})` : ""}`);
|
|
27674
27864
|
}
|
|
27675
|
-
if (!inPlace &&
|
|
27865
|
+
if (!inPlace && existsSync31(join51(work, "package.json")) && !existsSync31(join51(work, "node_modules"))) {
|
|
27676
27866
|
say("npm install\u2026");
|
|
27677
27867
|
if (await runStep("npm", ["install"], { cwd: work, shell: process.platform === "win32" }) !== 0) {
|
|
27678
27868
|
return { ok: false, error: `npm install failed in ${work}` };
|
|
@@ -27689,7 +27879,7 @@ async function loadDemo(entry, opts) {
|
|
|
27689
27879
|
return { ok: false, error: `setup failed (${entry.setup})` };
|
|
27690
27880
|
}
|
|
27691
27881
|
}
|
|
27692
|
-
return { ok: true, serveDirs: entry.serve.dirs?.length ? entry.serve.dirs.map((d) =>
|
|
27882
|
+
return { ok: true, serveDirs: entry.serve.dirs?.length ? entry.serve.dirs.map((d) => join51(work, d)) : [work] };
|
|
27693
27883
|
}
|
|
27694
27884
|
function runStep(cmd, args, opts = {}) {
|
|
27695
27885
|
return new Promise((res) => {
|
|
@@ -27700,8 +27890,8 @@ function runStep(cmd, args, opts = {}) {
|
|
|
27700
27890
|
}
|
|
27701
27891
|
|
|
27702
27892
|
// src/server.ts
|
|
27703
|
-
var pkgRoot =
|
|
27704
|
-
var webRoot =
|
|
27893
|
+
var pkgRoot = join52(dirname18(fileURLToPath10(import.meta.url)), "..");
|
|
27894
|
+
var webRoot = join52(pkgRoot, "web");
|
|
27705
27895
|
var execFileP = async (cmd, args) => (await promisify3(execFile5)(cmd, args, { encoding: "utf8", timeout: 1e4 })).stdout;
|
|
27706
27896
|
function optsFromQuery(url, tierEnvVar, projectDir) {
|
|
27707
27897
|
const q = url.searchParams;
|
|
@@ -27752,7 +27942,7 @@ function tierFailure(tier, message2) {
|
|
|
27752
27942
|
function beholdVersion() {
|
|
27753
27943
|
try {
|
|
27754
27944
|
const here = dirname18(fileURLToPath10(import.meta.url));
|
|
27755
|
-
return JSON.parse(
|
|
27945
|
+
return JSON.parse(readFileSync40(join52(here, "..", "package.json"), "utf8")).version ?? "unknown";
|
|
27756
27946
|
} catch {
|
|
27757
27947
|
return "unknown";
|
|
27758
27948
|
}
|
|
@@ -27798,8 +27988,13 @@ async function captureFrame(projectDir, env, frames, broadcaster) {
|
|
|
27798
27988
|
return null;
|
|
27799
27989
|
}
|
|
27800
27990
|
}
|
|
27991
|
+
function terralithRoutes(app, demo) {
|
|
27992
|
+
app.get("/api/terralith", (c) => c.json(readTerralith(demo.root)));
|
|
27993
|
+
app.get("/terralith", serveStatic({ path: join52(relative11(process.cwd(), webRoot) || ".", "terralith.html") }));
|
|
27994
|
+
app.get("/", (c) => c.redirect("/terralith"));
|
|
27995
|
+
}
|
|
27801
27996
|
function carveRoutes(app, reportPath, demo) {
|
|
27802
|
-
const load2 = () => readCarveReport(reportPath, (p) =>
|
|
27997
|
+
const load2 = () => readCarveReport(reportPath, (p) => readFileSync40(p, "utf8"));
|
|
27803
27998
|
const carveDirs = [dirname18(reportPath), ...demo ? [demo.out] : []];
|
|
27804
27999
|
const carveStates = () => readCarveStates(carveDirs, nodeCarveIo, 0);
|
|
27805
28000
|
const emittedNodes = async (states) => {
|
|
@@ -28099,6 +28294,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
|
|
|
28099
28294
|
const r = guardedRepo();
|
|
28100
28295
|
return r?.product === "sql-yodeler" ? dirname18(r.config) : void 0;
|
|
28101
28296
|
});
|
|
28297
|
+
if (cfg.terralithDemo) terralithRoutes(app, cfg.terralithDemo);
|
|
28102
28298
|
if (cfg.carveReport) carveRoutes(app, cfg.carveReport, cfg.carveDemo);
|
|
28103
28299
|
const predictDeps = cfg.behaviour ?? { read: graphIr };
|
|
28104
28300
|
let beholdConfig = loadBeholdConfig(cfg.projectDir);
|
|
@@ -28215,9 +28411,9 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
|
|
|
28215
28411
|
return c.json({ started: true, name, ran: label });
|
|
28216
28412
|
});
|
|
28217
28413
|
app.post("/api/local/reset", (c) => {
|
|
28218
|
-
const down =
|
|
28219
|
-
const up =
|
|
28220
|
-
if (!
|
|
28414
|
+
const down = join52(cfg.projectDir, "scripts/local/local-down.sh");
|
|
28415
|
+
const up = join52(cfg.projectDir, "scripts/local/local-up.sh");
|
|
28416
|
+
if (!existsSync32(down) || !existsSync32(up)) {
|
|
28221
28417
|
return c.json({ error: "no local-down.sh / local-up.sh in scripts/local \u2014 reset is only for local emulator projects" }, 400);
|
|
28222
28418
|
}
|
|
28223
28419
|
if (!runner.bringUp("reset local emulator", "bash", ["-c", "bash scripts/local/local-down.sh && bash scripts/local/local-up.sh"], cfg.projectDir)) {
|
|
@@ -28236,20 +28432,20 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
|
|
|
28236
28432
|
});
|
|
28237
28433
|
const convergeDirs = () => {
|
|
28238
28434
|
const dirs = [];
|
|
28239
|
-
const
|
|
28435
|
+
const declared2 = [];
|
|
28240
28436
|
for (const f of discoverOpIrs(estateDirs())) {
|
|
28241
|
-
const parsed = readOpIr(f.path, (p) =>
|
|
28437
|
+
const parsed = readOpIr(f.path, (p) => readFileSync40(p, "utf8"));
|
|
28242
28438
|
if (!parsed.ok) continue;
|
|
28243
28439
|
const mine = declaredConvergeOps([parsed.ir]);
|
|
28244
28440
|
if (!mine.length) continue;
|
|
28245
|
-
|
|
28441
|
+
declared2.push(...mine);
|
|
28246
28442
|
if (!dirs.includes(f.dir)) dirs.push(f.dir);
|
|
28247
28443
|
}
|
|
28248
|
-
return { dirs, declared };
|
|
28444
|
+
return { dirs, declared: declared2 };
|
|
28249
28445
|
};
|
|
28250
28446
|
app.get("/api/operator/status", async (c) => {
|
|
28251
|
-
const { dirs, declared } = convergeDirs();
|
|
28252
|
-
runner.noteDeclaredConvergeOps(
|
|
28447
|
+
const { dirs, declared: declared2 } = convergeDirs();
|
|
28448
|
+
runner.noteDeclaredConvergeOps(declared2);
|
|
28253
28449
|
if (!dirs.length) {
|
|
28254
28450
|
const state2 = runner.noteOperator({
|
|
28255
28451
|
ok: false,
|
|
@@ -28423,7 +28619,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
|
|
|
28423
28619
|
const axes = deployAxes(tierEnvVar, lexicons, k8sTarget);
|
|
28424
28620
|
const emittedOps = discoverOpIrs(estateDirs()).length;
|
|
28425
28621
|
const carveState = carveStatePayload(await carveStatesUnder(estateDirs()));
|
|
28426
|
-
const plans =
|
|
28622
|
+
const plans = discoverSplitPlans(
|
|
28427
28623
|
(cfg.projectDirs ?? [cfg.projectDir]).filter((d) => memberKindOf(d) === "choudoufu"),
|
|
28428
28624
|
cfg.projectDir
|
|
28429
28625
|
);
|
|
@@ -28546,8 +28742,8 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
|
|
|
28546
28742
|
if (cfg.previewMode) return c.json({ error: "switching projects is locked in preview mode" }, 403);
|
|
28547
28743
|
const body = await c.req.json().catch(() => ({}));
|
|
28548
28744
|
const dir = typeof body.dir === "string" && body.dir.trim() ? resolve32(body.dir.trim()) : "";
|
|
28549
|
-
if (!dir || !
|
|
28550
|
-
if (!
|
|
28745
|
+
if (!dir || !existsSync32(dir)) return c.json({ error: `no such directory: ${dir || "(no dir given)"}` }, 400);
|
|
28746
|
+
if (!existsSync32(join52(dir, "chant.config.ts"))) {
|
|
28551
28747
|
return c.json({ error: `${dir} doesn't look like a chant project \u2014 no chant.config.ts` }, 400);
|
|
28552
28748
|
}
|
|
28553
28749
|
switchServedProject([dir]);
|
|
@@ -28598,14 +28794,14 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
|
|
|
28598
28794
|
fetches: fetchesFromNetwork(e),
|
|
28599
28795
|
...e.repo ? { repo: e.repo } : {},
|
|
28600
28796
|
target,
|
|
28601
|
-
loaded:
|
|
28797
|
+
loaded: existsSync32(target),
|
|
28602
28798
|
satisfiable: missing.length === 0,
|
|
28603
28799
|
// #254: the carve walkthrough runs fine here — it just isn't a project
|
|
28604
28800
|
// to switch INTO. Carve mode claims `/api/graph` and `/api/project` at
|
|
28605
28801
|
// app creation (see carveRoutes), so a running server cannot become one;
|
|
28606
28802
|
// the row stays in the catalog, disabled, saying what to run instead.
|
|
28607
|
-
...e.serve.carve ? { switchable: false } : {},
|
|
28608
|
-
...missing.length ? { reason: `needs ${missing.join(", ")} on PATH` } : e.serve.carve ? { reason: `serves a carve report, not a project \u2014 run \`behold demo ${e.name}\`` } : {}
|
|
28803
|
+
...e.serve.carve || e.serve.terralith ? { switchable: false } : {},
|
|
28804
|
+
...missing.length ? { reason: `needs ${missing.join(", ")} on PATH` } : e.serve.carve ? { reason: `serves a carve report, not a project \u2014 run \`behold demo ${e.name}\`` } : e.serve.terralith ? { reason: `a walkthrough page of its own \u2014 run \`behold demo ${e.name}\`` } : {}
|
|
28609
28805
|
};
|
|
28610
28806
|
};
|
|
28611
28807
|
app.get(
|
|
@@ -28635,6 +28831,9 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
|
|
|
28635
28831
|
400
|
|
28636
28832
|
);
|
|
28637
28833
|
}
|
|
28834
|
+
if (entry.serve.terralith) {
|
|
28835
|
+
return c.json({ error: `${entry.name} is a walkthrough page of its own, served by its own behold.`, remedy: `Run \`behold demo ${entry.name}\` in a terminal.` }, 400);
|
|
28836
|
+
}
|
|
28638
28837
|
if (loadingDemo) return c.json({ error: `${loadingDemo} is still loading` }, 409);
|
|
28639
28838
|
loadingDemo = entry.name;
|
|
28640
28839
|
try {
|
|
@@ -28680,8 +28879,8 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
|
|
|
28680
28879
|
if (!(c.req.header("content-type") ?? "").includes("application/json")) {
|
|
28681
28880
|
return c.json({ error: "send application/json", code: "bad-layout" }, 415);
|
|
28682
28881
|
}
|
|
28683
|
-
const
|
|
28684
|
-
if (
|
|
28882
|
+
const declared2 = Number(c.req.header("content-length") ?? 0);
|
|
28883
|
+
if (declared2 > MAX_BODY_BYTES) return c.json({ error: `a layout body is capped at ${MAX_BODY_BYTES} bytes`, code: "too-large" }, 413);
|
|
28685
28884
|
const text2 = await c.req.text().catch(() => "");
|
|
28686
28885
|
if (text2.length > MAX_BODY_BYTES) return c.json({ error: `a layout body is capped at ${MAX_BODY_BYTES} bytes`, code: "too-large" }, 413);
|
|
28687
28886
|
let body;
|
|
@@ -28769,10 +28968,12 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
|
|
|
28769
28968
|
{ method: "GET", path: "/api/components/compare", desc: "cross-env digest comparison: ?env=&to= \u2014 is one env running what the other tested (ledger-only)" },
|
|
28770
28969
|
{
|
|
28771
28970
|
method: "GET",
|
|
28772
|
-
path: "/api/choudoufu/
|
|
28773
|
-
desc: "a choudoufu
|
|
28971
|
+
path: "/api/choudoufu/split",
|
|
28972
|
+
desc: "a choudoufu split plan (split.json, or the workbench's carve.json) as previews: ?plan=<path inside a served member> [&dryrun=1: choudoufu's own live-mv -dry-run per move] [&receipt=1: the listing after a human ran the lines]. The lines are handed back; there is no endpoint that runs live-mv."
|
|
28774
28973
|
},
|
|
28775
|
-
{ method: "GET", path: "/choudoufu/
|
|
28974
|
+
{ method: "GET", path: "/api/choudoufu/moves", desc: "the same previews under their name from before the split rename" },
|
|
28975
|
+
{ method: "GET", path: "/choudoufu/split", desc: "the split plan as a morph page: every member a box, a box for each estate the plan names that is not served yet, the moved cards gliding to their destination \u2014 ?plan=<path>" },
|
|
28976
|
+
{ method: "GET", path: "/choudoufu/morph", desc: "redirects to /choudoufu/split, its name from before the split rename" },
|
|
28776
28977
|
{ method: "GET", path: "/api/ci", desc: "generated CI pipeline projection {stages, jobs, forge}" },
|
|
28777
28978
|
{ method: "GET", path: "/api/substrates", desc: "substrate readiness {substrates: [{name, label, status, detail, bringUp?}]}" },
|
|
28778
28979
|
{ method: "GET", path: "/api/ops", desc: "committed Ops + adopt lexicons + apply progress + run playhead" },
|
|
@@ -28902,7 +29103,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
|
|
|
28902
29103
|
}
|
|
28903
29104
|
const parsedOps = [];
|
|
28904
29105
|
for (const f of files) {
|
|
28905
|
-
const parsed = readOpIr(f.path, (p) =>
|
|
29106
|
+
const parsed = readOpIr(f.path, (p) => readFileSync40(p, "utf8"));
|
|
28906
29107
|
if (!parsed.ok) return c.json(parsed.refusal, 422);
|
|
28907
29108
|
parsedOps.push(parsed.ir);
|
|
28908
29109
|
}
|
|
@@ -28915,8 +29116,8 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
|
|
|
28915
29116
|
}
|
|
28916
29117
|
const runState = runner.runState;
|
|
28917
29118
|
const ranOp = runState.op ? parsedOps.find((o) => o.name === runState.op) : void 0;
|
|
28918
|
-
const
|
|
28919
|
-
const opsIr =
|
|
29119
|
+
const join57 = ranOp ? joinRun(ranOp, runState.records, runState.gate) : null;
|
|
29120
|
+
const opsIr = join57 ? paintPlayhead(declaredIr, join57, runState.gate) : declaredIr;
|
|
28920
29121
|
const { svg: svg2 } = renderGraph(opsIr, { boxes: "byStack" });
|
|
28921
29122
|
const operator = runner.noteDeclaredConvergeOps(declaredConvergeOps(parsedOps));
|
|
28922
29123
|
return c.json({
|
|
@@ -28929,7 +29130,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
|
|
|
28929
29130
|
target: null,
|
|
28930
29131
|
mode: "ops",
|
|
28931
29132
|
ops: parsedOps.length,
|
|
28932
|
-
note: `${opsNote(parsedOps, opsIr)} ${playheadNote(runState,
|
|
29133
|
+
note: `${opsNote(parsedOps, opsIr)} ${playheadNote(runState, join57)} ${operatorNote(operator)}`,
|
|
28933
29134
|
// The operator strip's own model: the ConvergeOps this project
|
|
28934
29135
|
// declares, plus whatever the last status read said. `declared`
|
|
28935
29136
|
// without a `strip` is the honest starting state — a loop exists and
|
|
@@ -29042,7 +29243,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
|
|
|
29042
29243
|
srcCompositeEdgesAttached = 0;
|
|
29043
29244
|
}
|
|
29044
29245
|
}
|
|
29045
|
-
if (!multi && !components && !logical && !opts.lens && !ownKindVia && ir.nodes.length === 0 && !
|
|
29246
|
+
if (!multi && !components && !logical && !opts.lens && !ownKindVia && ir.nodes.length === 0 && !existsSync32(join52(cfg.projectDir, "chant.config.ts"))) {
|
|
29046
29247
|
return c.json(noProjectError(cfg.projectDir), 404);
|
|
29047
29248
|
}
|
|
29048
29249
|
const radial = new URL(c.req.url).searchParams.get("radial") === "1";
|
|
@@ -29274,7 +29475,16 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
|
|
|
29274
29475
|
// is already on screen, so this is id -> status and nothing more.
|
|
29275
29476
|
statuses: Object.fromEntries(
|
|
29276
29477
|
memberIrDoc.nodes.map((n) => [`${name}/${n.id}`, n.attrs?._status ?? "neutral"])
|
|
29277
|
-
)
|
|
29478
|
+
),
|
|
29479
|
+
// A choudoufu card's marker-vs-derived mark rides the same frame,
|
|
29480
|
+
// only for the cards that carry one.
|
|
29481
|
+
...(() => {
|
|
29482
|
+
const ids = memberIrDoc.nodes.flatMap((n) => {
|
|
29483
|
+
const i = n.attrs?._identity;
|
|
29484
|
+
return i ? [[`${name}/${n.id}`, i]] : [];
|
|
29485
|
+
});
|
|
29486
|
+
return ids.length ? { identities: Object.fromEntries(ids) } : {};
|
|
29487
|
+
})()
|
|
29278
29488
|
}));
|
|
29279
29489
|
}
|
|
29280
29490
|
}).catch((err) => broadcaster.emit("member", JSON.stringify({ error: err instanceof Error ? err.message.split("\n")[0] : String(err) })));
|
|
@@ -29548,11 +29758,11 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
|
|
|
29548
29758
|
return c.json({ env, nodes });
|
|
29549
29759
|
});
|
|
29550
29760
|
const choudoufuPlanPath = (plan) => {
|
|
29551
|
-
if (!plan) return { error: "no plan named", code: "choudoufu_no_plan", remedy: "pass ?plan=<path to a
|
|
29761
|
+
if (!plan) return { error: "no plan named", code: "choudoufu_no_plan", remedy: "pass ?plan=<path to a split.json inside a served choudoufu member> \u2014 GET /api/project lists the ones found" };
|
|
29552
29762
|
const abs = resolve32(cfg.projectDir, plan);
|
|
29553
29763
|
const members = (cfg.projectDirs ?? [cfg.projectDir]).filter((d) => memberKindOf(d) === "choudoufu");
|
|
29554
29764
|
const inside = members.some((d) => abs.startsWith(resolve32(d) + sep10));
|
|
29555
|
-
if (!inside) return { error: `${plan} is not inside a served choudoufu member`, code: "choudoufu_plan_outside", remedy: "a plan lives in the estate it moves; point ?plan= at a
|
|
29765
|
+
if (!inside) return { error: `${plan} is not inside a served choudoufu member`, code: "choudoufu_plan_outside", remedy: "a plan lives in the estate it moves; point ?plan= at a split.json under one of the served members" };
|
|
29556
29766
|
return { path: abs };
|
|
29557
29767
|
};
|
|
29558
29768
|
const choudoufuMembersServed = async () => {
|
|
@@ -29560,22 +29770,25 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
|
|
|
29560
29770
|
const all = estateMembers(cfg.projectDirs ?? [cfg.projectDir]).filter((m) => m.kind === "choudoufu");
|
|
29561
29771
|
return moveMembers(all, run3);
|
|
29562
29772
|
};
|
|
29563
|
-
|
|
29773
|
+
const splitPreviews = async (c) => {
|
|
29564
29774
|
const q = new URL(c.req.url).searchParams;
|
|
29565
29775
|
const where = choudoufuPlanPath(q.get("plan") ?? void 0);
|
|
29566
29776
|
if ("error" in where) return c.json(where, 400);
|
|
29567
|
-
const parsed =
|
|
29777
|
+
const parsed = readSplitPlan(where.path);
|
|
29568
29778
|
if (!parsed.ok) return c.json(parsed.refusal, 422);
|
|
29569
29779
|
const members = await choudoufuMembersServed();
|
|
29570
29780
|
const payload = await movesPayload(parsed.plan, members, { dryRun: q.get("dryrun") === "1", run: cfg.choudoufu?.run });
|
|
29571
29781
|
const receipt = q.get("receipt") === "1" ? await moveReceipt(parsed.plan, members, cfg.choudoufu?.run) : void 0;
|
|
29572
29782
|
return c.json({ planPath: relative11(cfg.projectDir, where.path), ...payload, ...receipt ? { receipt } : {} });
|
|
29573
|
-
}
|
|
29574
|
-
app.get("/choudoufu/
|
|
29783
|
+
};
|
|
29784
|
+
app.get("/api/choudoufu/split", splitPreviews);
|
|
29785
|
+
app.get("/api/choudoufu/moves", splitPreviews);
|
|
29786
|
+
app.get("/choudoufu/morph", (c) => c.redirect(`/choudoufu/split${new URL(c.req.url).search}`, 301));
|
|
29787
|
+
app.get("/choudoufu/split", async (c) => {
|
|
29575
29788
|
const q = new URL(c.req.url).searchParams;
|
|
29576
29789
|
const where = choudoufuPlanPath(q.get("plan") ?? void 0);
|
|
29577
29790
|
if ("error" in where) return c.json(where, 400);
|
|
29578
|
-
const parsed =
|
|
29791
|
+
const parsed = readSplitPlan(where.path);
|
|
29579
29792
|
if (!parsed.ok) return c.json(parsed.refusal, 422);
|
|
29580
29793
|
const members = await choudoufuMembersServed();
|
|
29581
29794
|
const morphMembers = await Promise.all(
|
|
@@ -29592,7 +29805,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
|
|
|
29592
29805
|
...p.newAddress ? { newAddress: p.newAddress } : {},
|
|
29593
29806
|
...p.dryRun && "followers" in p.dryRun && p.dryRun.followers ? { followers: p.dryRun.followers.map((f) => f.address) } : {}
|
|
29594
29807
|
}));
|
|
29595
|
-
const html = renderMoveMorph(morphMembers, moves, { title: `
|
|
29808
|
+
const html = renderMoveMorph(morphMembers, moves, { title: `split \u2014 ${relative11(cfg.projectDir, where.path)}`, estateOf: (m) => m.panel.replace(/^estate /, "") });
|
|
29596
29809
|
return c.html(html);
|
|
29597
29810
|
});
|
|
29598
29811
|
app.get("/api/diff/:node", async (c) => {
|
|
@@ -29687,7 +29900,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
|
|
|
29687
29900
|
if (!c.req.path.startsWith("/api/") && c.res.ok && !c.res.headers.has("cache-control")) c.res.headers.set("cache-control", "no-cache");
|
|
29688
29901
|
});
|
|
29689
29902
|
app.use("/*", serveStatic({ root: rel }));
|
|
29690
|
-
app.get("/", serveStatic({ path:
|
|
29903
|
+
app.get("/", serveStatic({ path: join52(rel, "index.html") }));
|
|
29691
29904
|
if (cfg.terragucci) vendorFallback(app);
|
|
29692
29905
|
return app;
|
|
29693
29906
|
}
|
|
@@ -29717,7 +29930,7 @@ async function bootLocalEmulators(dir, who) {
|
|
|
29717
29930
|
async function startServer(cfg) {
|
|
29718
29931
|
if (cfg.local) cfg.emulators = await bootLocalEmulators(cfg.projectDir, "behold serve --local");
|
|
29719
29932
|
for (const dir of cfg.projectDirs ?? [cfg.projectDir]) {
|
|
29720
|
-
if (
|
|
29933
|
+
if (existsSync32(join52(dir, "chant.config.ts"))) addRecent(dir);
|
|
29721
29934
|
}
|
|
29722
29935
|
const broadcaster = new Broadcaster();
|
|
29723
29936
|
const frames = new FrameBuffer();
|
|
@@ -29786,7 +29999,7 @@ async function startServer(cfg) {
|
|
|
29786
29999
|
}
|
|
29787
30000
|
}
|
|
29788
30001
|
};
|
|
29789
|
-
const carve = !!cfg.carveReport;
|
|
30002
|
+
const carve = !!cfg.carveReport || !!cfg.terralithDemo;
|
|
29790
30003
|
let stopWatch = carve ? () => {
|
|
29791
30004
|
} : watchSources(cfg.projectDirs ?? [cfg.projectDir], onMemberSourceChange);
|
|
29792
30005
|
let pollScopes = /* @__PURE__ */ new Map();
|
|
@@ -29841,6 +30054,16 @@ async function startServer(cfg) {
|
|
|
29841
30054
|
process.on("SIGTERM", shutdown);
|
|
29842
30055
|
const hostname = cfg.host ?? process.env.BEHOLD_HOST ?? "127.0.0.1";
|
|
29843
30056
|
const server = serve({ fetch: app.fetch, port: cfg.port, hostname }, (info) => {
|
|
30057
|
+
if (cfg.terralithDemo) {
|
|
30058
|
+
process.stdout.write(
|
|
30059
|
+
`behold \u2192 http://localhost:${info.port}/terralith
|
|
30060
|
+
terralith walkthrough: ${cfg.terralithDemo.root}
|
|
30061
|
+
reads snapshots/ in the copy; each phase is a script line you run there.
|
|
30062
|
+
scratch floci: ${cfg.terralithDemo.endpoint}. Ctrl-C stops behold; scripts/terralith-down.sh removes the emulator.
|
|
30063
|
+
`
|
|
30064
|
+
);
|
|
30065
|
+
return;
|
|
30066
|
+
}
|
|
29844
30067
|
if (carve) {
|
|
29845
30068
|
process.stdout.write(
|
|
29846
30069
|
`behold \u2192 http://localhost:${info.port}
|
|
@@ -29892,8 +30115,8 @@ init_chant();
|
|
|
29892
30115
|
|
|
29893
30116
|
// src/workspace-convert.ts
|
|
29894
30117
|
init_chant();
|
|
29895
|
-
import { existsSync as
|
|
29896
|
-
import { basename as basename7, dirname as dirname19, join as
|
|
30118
|
+
import { existsSync as existsSync33, mkdirSync as mkdirSync9, readFileSync as readFileSync41, renameSync as renameSync2, writeFileSync as writeFileSync7 } from "node:fs";
|
|
30119
|
+
import { basename as basename7, dirname as dirname19, join as join53, relative as relative12, resolve as resolve33, sep as sep11 } from "node:path";
|
|
29897
30120
|
import { shortStackNames as shortStackNames2 } from "@intentius/pinhole";
|
|
29898
30121
|
init_project();
|
|
29899
30122
|
init_terraform_member();
|
|
@@ -29911,10 +30134,10 @@ function unique(name, taken) {
|
|
|
29911
30134
|
var posix5 = (p) => p.split(sep11).join("/");
|
|
29912
30135
|
function installedVersion(pkg, dir) {
|
|
29913
30136
|
for (let at2 = resolve33(dir); ; at2 = dirname19(at2)) {
|
|
29914
|
-
const manifest =
|
|
29915
|
-
if (
|
|
30137
|
+
const manifest = join53(at2, "node_modules", ...pkg.split("/"), "package.json");
|
|
30138
|
+
if (existsSync33(manifest)) {
|
|
29916
30139
|
try {
|
|
29917
|
-
const v = JSON.parse(
|
|
30140
|
+
const v = JSON.parse(readFileSync41(manifest, "utf8")).version;
|
|
29918
30141
|
return typeof v === "string" ? v : void 0;
|
|
29919
30142
|
} catch {
|
|
29920
30143
|
return void 0;
|
|
@@ -29925,7 +30148,7 @@ function installedVersion(pkg, dir) {
|
|
|
29925
30148
|
}
|
|
29926
30149
|
function planConversion(rootArg) {
|
|
29927
30150
|
const root = resolve33(rootArg);
|
|
29928
|
-
const existing = DECLARATION_FILES.find((f) =>
|
|
30151
|
+
const existing = DECLARATION_FILES.find((f) => existsSync33(join53(root, f)));
|
|
29929
30152
|
if (existing) return { ok: false, error: `${root} already has ${existing}; there is nothing to convert.` };
|
|
29930
30153
|
const shape = detectProjectShape(root);
|
|
29931
30154
|
if (shape.kind !== "estate" || !shape.members?.length || shape.membersFrom === "itself") {
|
|
@@ -29946,10 +30169,10 @@ function planConversion(rootArg) {
|
|
|
29946
30169
|
const scan = discoverTerraformRoots(abs[i]);
|
|
29947
30170
|
for (const r of scan.roots) {
|
|
29948
30171
|
const name2 = unique(declarationName(r.name), taken);
|
|
29949
|
-
members.push({ name: name2, dir: r.dir === "." ? dir : posix5(
|
|
30172
|
+
members.push({ name: name2, dir: r.dir === "." ? dir : posix5(join53(dir, r.dir)), kind: "terraform" });
|
|
29950
30173
|
moves.push({ from: `${short}/${r.name}/`, to: `${name2}/${name2}/` });
|
|
29951
30174
|
}
|
|
29952
|
-
for (const s of scan.skipped) notes.push(`${posix5(
|
|
30175
|
+
for (const s of scan.skipped) notes.push(`${posix5(join53(dir, s.dir))} is not declared: ${s.why}.`);
|
|
29953
30176
|
if (scan.roots.length > 1) notes.push(`${dir} held ${scan.roots.length} Terraform roots; each is its own member now, since a chant terraform member is one root.`);
|
|
29954
30177
|
return;
|
|
29955
30178
|
}
|
|
@@ -29977,7 +30200,7 @@ function planConversion(rootArg) {
|
|
|
29977
30200
|
};
|
|
29978
30201
|
const firstLayout = layoutPath(abs[0]);
|
|
29979
30202
|
moves.sort((a, b) => b.from.length - a.from.length);
|
|
29980
|
-
return { ok: true, plan: { root, from: shape.membersFrom === "behold-config" ? "behold-config" : "workspaces", declaration, moves, ...
|
|
30203
|
+
return { ok: true, plan: { root, from: shape.membersFrom === "behold-config" ? "behold-config" : "workspaces", declaration, moves, ...existsSync33(firstLayout) ? { layoutFrom: firstLayout } : {}, notes } };
|
|
29981
30204
|
}
|
|
29982
30205
|
function moveLayoutIds(file, moves) {
|
|
29983
30206
|
const lenses = {};
|
|
@@ -29992,18 +30215,18 @@ function moveLayoutIds(file, moves) {
|
|
|
29992
30215
|
return { version: 1, lenses };
|
|
29993
30216
|
}
|
|
29994
30217
|
function applyConversion(plan) {
|
|
29995
|
-
const declarationFile =
|
|
29996
|
-
if (
|
|
30218
|
+
const declarationFile = join53(plan.root, DECLARATION_FILES[0]);
|
|
30219
|
+
if (existsSync33(declarationFile)) throw new Error(`${declarationFile} appeared while converting; nothing was written`);
|
|
29997
30220
|
writeFileSync7(declarationFile, `${JSON.stringify(plan.declaration, null, 2)}
|
|
29998
30221
|
`);
|
|
29999
30222
|
let layout;
|
|
30000
30223
|
const target = layoutPath(plan.root);
|
|
30001
30224
|
if (!plan.layoutFrom) layout = { skipped: "no saved layout to move" };
|
|
30002
30225
|
else if (resolve33(plan.layoutFrom) === resolve33(target)) layout = { skipped: "the saved layout is already in the root" };
|
|
30003
|
-
else if (
|
|
30226
|
+
else if (existsSync33(target)) layout = { skipped: `${target} already exists; the layout in ${plan.layoutFrom} was left alone` };
|
|
30004
30227
|
else {
|
|
30005
30228
|
const moved = moveLayoutIds(readLayoutFile(dirname19(dirname19(plan.layoutFrom))), plan.moves);
|
|
30006
|
-
mkdirSync9(
|
|
30229
|
+
mkdirSync9(join53(plan.root, LAYOUT_DIR), { recursive: true });
|
|
30007
30230
|
const tmp = `${target}.tmp`;
|
|
30008
30231
|
writeFileSync7(tmp, `${JSON.stringify(moved, null, 2)}
|
|
30009
30232
|
`);
|
|
@@ -30014,9 +30237,9 @@ function applyConversion(plan) {
|
|
|
30014
30237
|
}
|
|
30015
30238
|
|
|
30016
30239
|
// src/export.ts
|
|
30017
|
-
import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync8, copyFileSync, cpSync as cpSync2, readFileSync as
|
|
30240
|
+
import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync8, copyFileSync, cpSync as cpSync2, readFileSync as readFileSync42, readdirSync as readdirSync19, existsSync as existsSync34, realpathSync as realpathSync2 } from "node:fs";
|
|
30018
30241
|
import { homedir as homedir3 } from "node:os";
|
|
30019
|
-
import { join as
|
|
30242
|
+
import { join as join54, dirname as dirname20, basename as basename8, relative as relative13, resolve as resolve34, sep as sep12 } from "node:path";
|
|
30020
30243
|
import { createHash as createHash11 } from "node:crypto";
|
|
30021
30244
|
import { fileURLToPath as fileURLToPath11 } from "node:url";
|
|
30022
30245
|
var LENS_PARAMS = ["collapse", "components", "detail", "env", "logical", "ops", "radial", "stacks", "tier"];
|
|
@@ -30073,24 +30296,24 @@ function captureKeys(axes) {
|
|
|
30073
30296
|
return [...keys];
|
|
30074
30297
|
}
|
|
30075
30298
|
function webDir() {
|
|
30076
|
-
return
|
|
30299
|
+
return join54(dirname20(fileURLToPath11(import.meta.url)), "..", "web");
|
|
30077
30300
|
}
|
|
30078
30301
|
function pkgRoot2() {
|
|
30079
|
-
return
|
|
30302
|
+
return join54(dirname20(fileURLToPath11(import.meta.url)), "..");
|
|
30080
30303
|
}
|
|
30081
30304
|
var NOTICE_FILES = ["LICENSE", "THIRD_PARTY.md"];
|
|
30082
30305
|
function copyNotices(outDir, root = pkgRoot2()) {
|
|
30083
30306
|
const copied = [];
|
|
30084
30307
|
for (const f of NOTICE_FILES) {
|
|
30085
|
-
if (!
|
|
30086
|
-
copyFileSync(
|
|
30308
|
+
if (!existsSync34(join54(root, f))) continue;
|
|
30309
|
+
copyFileSync(join54(root, f), join54(outDir, f));
|
|
30087
30310
|
copied.push(f);
|
|
30088
30311
|
}
|
|
30089
|
-
const lic =
|
|
30090
|
-
if (
|
|
30091
|
-
mkdirSync10(
|
|
30092
|
-
for (const f of
|
|
30093
|
-
copyFileSync(
|
|
30312
|
+
const lic = join54(root, "licenses");
|
|
30313
|
+
if (existsSync34(lic)) {
|
|
30314
|
+
mkdirSync10(join54(outDir, "licenses"), { recursive: true });
|
|
30315
|
+
for (const f of readdirSync19(lic)) {
|
|
30316
|
+
copyFileSync(join54(lic, f), join54(outDir, "licenses", f));
|
|
30094
30317
|
copied.push(`licenses/${f}`);
|
|
30095
30318
|
}
|
|
30096
30319
|
}
|
|
@@ -30115,7 +30338,7 @@ async function runExport(cfg, outDir, opts = {}) {
|
|
|
30115
30338
|
...proj.sqlYodeler ? { sqlYodeler: true } : {}
|
|
30116
30339
|
};
|
|
30117
30340
|
const scrub = exportScrubber(cfg);
|
|
30118
|
-
const snapDir =
|
|
30341
|
+
const snapDir = join54(outDir, "snapshots");
|
|
30119
30342
|
mkdirSync10(snapDir, { recursive: true });
|
|
30120
30343
|
const keyToFile = {};
|
|
30121
30344
|
let ok = 0;
|
|
@@ -30124,7 +30347,7 @@ async function runExport(cfg, outDir, opts = {}) {
|
|
|
30124
30347
|
const res = await app.request(`${key2}${key2.includes("?") ? "&" : "?"}layout=1`);
|
|
30125
30348
|
const body = scrub(shapeSnapshot(key2, await res.text(), opts));
|
|
30126
30349
|
const file = slug3(key2, body);
|
|
30127
|
-
writeFileSync8(
|
|
30350
|
+
writeFileSync8(join54(snapDir, file), body);
|
|
30128
30351
|
keyToFile[key2] = `snapshots/${file}`;
|
|
30129
30352
|
if (res.ok) ok++;
|
|
30130
30353
|
else failed++;
|
|
@@ -30146,29 +30369,29 @@ async function runExport(cfg, outDir, opts = {}) {
|
|
|
30146
30369
|
axes,
|
|
30147
30370
|
keyToFile
|
|
30148
30371
|
};
|
|
30149
|
-
writeFileSync8(
|
|
30150
|
-
const html =
|
|
30372
|
+
writeFileSync8(join54(outDir, "manifest.json"), JSON.stringify(manifest, null, 2));
|
|
30373
|
+
const html = readFileSync42(join54(webDir(), "index.html"), "utf8").replace(
|
|
30151
30374
|
/<\/head>/i,
|
|
30152
30375
|
` <script>window.__BEHOLD_STATIC__ = true;</script>
|
|
30153
30376
|
</head>`
|
|
30154
30377
|
);
|
|
30155
|
-
writeFileSync8(
|
|
30156
|
-
for (const f of
|
|
30378
|
+
writeFileSync8(join54(outDir, "index.html"), html);
|
|
30379
|
+
for (const f of readdirSync19(webDir())) {
|
|
30157
30380
|
if (f === "index.html" || f.endsWith(".test.js")) continue;
|
|
30158
|
-
cpSync2(
|
|
30381
|
+
cpSync2(join54(webDir(), f), join54(outDir, f), { recursive: true });
|
|
30159
30382
|
}
|
|
30160
|
-
writeFileSync8(
|
|
30383
|
+
writeFileSync8(join54(outDir, "README.md"), BUNDLE_README);
|
|
30161
30384
|
copyNotices(outDir);
|
|
30162
30385
|
const name = workerName(cfg.projectDir, opts.name);
|
|
30163
30386
|
writeFileSync8(
|
|
30164
|
-
|
|
30387
|
+
join54(outDir, "wrangler.jsonc"),
|
|
30165
30388
|
JSON.stringify(
|
|
30166
30389
|
{ $schema: "node_modules/wrangler/config-schema.json", name, compatibility_date: "2025-06-01", assets: { directory: "." } },
|
|
30167
30390
|
null,
|
|
30168
30391
|
2
|
|
30169
30392
|
) + "\n"
|
|
30170
30393
|
);
|
|
30171
|
-
writeFileSync8(
|
|
30394
|
+
writeFileSync8(join54(outDir, "manifest.json"), JSON.stringify({ ...manifest, files: bundleFiles(outDir).filter((f) => f !== "manifest.json") }, null, 2));
|
|
30172
30395
|
process.stdout.write(
|
|
30173
30396
|
`behold export \u2192 ${outDir}
|
|
30174
30397
|
${ok} snapshots${failed ? ` (${failed} endpoint error(s) captured as-is)` : ""}
|
|
@@ -30177,11 +30400,11 @@ async function runExport(cfg, outDir, opts = {}) {
|
|
|
30177
30400
|
`
|
|
30178
30401
|
);
|
|
30179
30402
|
}
|
|
30180
|
-
var
|
|
30403
|
+
var isRecord23 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
30181
30404
|
function dropSource(v) {
|
|
30182
30405
|
if (Array.isArray(v)) return v.forEach(dropSource);
|
|
30183
|
-
if (!
|
|
30184
|
-
if (
|
|
30406
|
+
if (!isRecord23(v)) return;
|
|
30407
|
+
if (isRecord23(v.attrs)) delete v.attrs.source;
|
|
30185
30408
|
for (const x of Object.values(v)) dropSource(x);
|
|
30186
30409
|
}
|
|
30187
30410
|
function shapeSnapshot(key2, body, opts = {}) {
|
|
@@ -30191,7 +30414,7 @@ function shapeSnapshot(key2, body, opts = {}) {
|
|
|
30191
30414
|
} catch {
|
|
30192
30415
|
return body;
|
|
30193
30416
|
}
|
|
30194
|
-
if (!
|
|
30417
|
+
if (!isRecord23(doc)) return body;
|
|
30195
30418
|
if (key2 === "/api/project") {
|
|
30196
30419
|
delete doc.recents;
|
|
30197
30420
|
delete doc.approver;
|
|
@@ -30261,11 +30484,11 @@ function manifestFiles(text2) {
|
|
|
30261
30484
|
} catch {
|
|
30262
30485
|
return [];
|
|
30263
30486
|
}
|
|
30264
|
-
const map =
|
|
30487
|
+
const map = isRecord23(doc) && isRecord23(doc.keyToFile) ? doc.keyToFile : {};
|
|
30265
30488
|
return Object.values(map).filter((f) => typeof f === "string" && /^snapshots\/[A-Za-z0-9=_.-]+$/.test(f) && !f.includes(".."));
|
|
30266
30489
|
}
|
|
30267
30490
|
function bundleFiles(outDir) {
|
|
30268
|
-
return
|
|
30491
|
+
return readdirSync19(outDir, { recursive: true, withFileTypes: true }).filter((d) => d.isFile()).map((d) => relative13(outDir, join54(d.parentPath, d.name)).split(sep12).join("/")).sort();
|
|
30269
30492
|
}
|
|
30270
30493
|
async function publishBundle(outDir, target, client) {
|
|
30271
30494
|
const files = bundleFiles(outDir);
|
|
@@ -30281,7 +30504,7 @@ async function publishBundle(outDir, target, client) {
|
|
|
30281
30504
|
}
|
|
30282
30505
|
const last = ["manifest.json", "index.html"];
|
|
30283
30506
|
const order = [...files.filter((f) => !last.includes(f)), ...last.filter((f) => files.includes(f))];
|
|
30284
|
-
for (const f of order) await client.put(at2(f),
|
|
30507
|
+
for (const f of order) await client.put(at2(f), readFileSync42(join54(outDir, f)), contentType(f), CONTENT_ADDRESSED.test(f) ? IMMUTABLE : NO_CACHE);
|
|
30285
30508
|
const wrote = new Set(files);
|
|
30286
30509
|
const removed = [];
|
|
30287
30510
|
for (const f of previous) {
|
|
@@ -30333,8 +30556,8 @@ It's just files \u2014 GitHub Pages, S3, nginx, or Cloudflare Pages
|
|
|
30333
30556
|
|
|
30334
30557
|
// src/publish-snapshots.ts
|
|
30335
30558
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
30336
|
-
import { readFileSync as
|
|
30337
|
-
import { join as
|
|
30559
|
+
import { readFileSync as readFileSync43 } from "node:fs";
|
|
30560
|
+
import { join as join55 } from "node:path";
|
|
30338
30561
|
var DEFAULT_KEEP = 30;
|
|
30339
30562
|
var SNAPSHOT_REPORTS_BASE = "../../../";
|
|
30340
30563
|
var COMMIT2 = /^[0-9a-f]{7,64}$/;
|
|
@@ -30359,12 +30582,12 @@ function resolveCommit2(dir, given) {
|
|
|
30359
30582
|
return { sha };
|
|
30360
30583
|
}
|
|
30361
30584
|
}
|
|
30362
|
-
var
|
|
30585
|
+
var isRecord24 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
30363
30586
|
function parseHistory(text2) {
|
|
30364
30587
|
const doc = JSON.parse(text2);
|
|
30365
30588
|
if (!Array.isArray(doc)) throw new Error("history.json is not an array");
|
|
30366
30589
|
const str17 = (v) => typeof v === "string" ? v : "";
|
|
30367
|
-
return doc.filter((e) =>
|
|
30590
|
+
return doc.filter((e) => isRecord24(e) && typeof e.commit === "string" && COMMIT2.test(e.commit)).map((e) => ({ commit: e.commit, at: str17(e.at), project: str17(e.project), generated: str17(e.generated) }));
|
|
30368
30591
|
}
|
|
30369
30592
|
function nextHistory(old, entry, keep) {
|
|
30370
30593
|
const all = [entry, ...old.filter((e) => e.commit !== entry.commit)];
|
|
@@ -30376,9 +30599,9 @@ var BUNDLE_PATH = /^[A-Za-z0-9=_.@+-]+(\/[A-Za-z0-9=_.@+-]+)*$/;
|
|
|
30376
30599
|
var insideBundle = (f) => typeof f === "string" && BUNDLE_PATH.test(f) && !f.split("/").some((p) => p === "." || p === "..");
|
|
30377
30600
|
function commitFiles(manifestText) {
|
|
30378
30601
|
const doc = JSON.parse(manifestText);
|
|
30379
|
-
if (!
|
|
30602
|
+
if (!isRecord24(doc)) return ["manifest.json"];
|
|
30380
30603
|
const listed = Array.isArray(doc.files) ? doc.files.filter(insideBundle) : [];
|
|
30381
|
-
const snaps =
|
|
30604
|
+
const snaps = isRecord24(doc.keyToFile) ? Object.values(doc.keyToFile).filter(insideBundle) : [];
|
|
30382
30605
|
const rest = [.../* @__PURE__ */ new Set([...listed, ...snaps])].filter((f) => f !== "index.html" && f !== "manifest.json").sort();
|
|
30383
30606
|
return ["index.html", ...rest, "manifest.json"];
|
|
30384
30607
|
}
|
|
@@ -30422,7 +30645,7 @@ async function publishSnapshot(outDir, target, commit, client, opts = {}) {
|
|
|
30422
30645
|
const keep = opts.keep ?? DEFAULT_KEEP;
|
|
30423
30646
|
if (!Number.isInteger(keep) || keep < 1) throw new Error(`--keep takes a whole number of at least 1, not ${keep}`);
|
|
30424
30647
|
const at2 = (f) => `${target.prefix}/${f}`;
|
|
30425
|
-
const local = JSON.parse(
|
|
30648
|
+
const local = JSON.parse(readFileSync43(join55(outDir, "manifest.json"), "utf8"));
|
|
30426
30649
|
const generated = local.capturedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
30427
30650
|
const entry = { commit: sha, at: commit.at ?? generated, project: opts.project ?? local.projectDir ?? "", generated };
|
|
30428
30651
|
const bundle = await publishBundle(outDir, { bucket: target.bucket, prefix: at2(sha) }, client);
|
|
@@ -30938,7 +31161,7 @@ function warnIfNotChantProject(dir) {
|
|
|
30938
31161
|
if (shape.kind === "estate") {
|
|
30939
31162
|
process.stderr.write(
|
|
30940
31163
|
`behold: warning \u2014 ${dir} is an estate root, not a chant project itself.
|
|
30941
|
-
Serve its members composed: behold serve ${shape.members.map((m) =>
|
|
31164
|
+
Serve its members composed: behold serve ${shape.members.map((m) => join56(dir, m.dir)).join(" ")}
|
|
30942
31165
|
`
|
|
30943
31166
|
);
|
|
30944
31167
|
return;
|
|
@@ -30974,7 +31197,7 @@ async function runCarve(rest) {
|
|
|
30974
31197
|
process.exit(2);
|
|
30975
31198
|
}
|
|
30976
31199
|
const reportPath = resolve35(fileArg);
|
|
30977
|
-
const parsed = readCarveReport(reportPath, (p) =>
|
|
31200
|
+
const parsed = readCarveReport(reportPath, (p) => readFileSync44(p, "utf8"));
|
|
30978
31201
|
if (!parsed.ok) {
|
|
30979
31202
|
process.stderr.write(`behold carve: ${parsed.refusal.error}
|
|
30980
31203
|
${parsed.refusal.remedy}
|
|
@@ -31003,7 +31226,7 @@ async function runDoctor(rest) {
|
|
|
31003
31226
|
}
|
|
31004
31227
|
}
|
|
31005
31228
|
const dir = dirArg ?? ".";
|
|
31006
|
-
if (!
|
|
31229
|
+
if (!existsSync35(resolve35(dir))) {
|
|
31007
31230
|
process.stderr.write(`behold doctor: no such directory: ${resolve35(dir)}
|
|
31008
31231
|
`);
|
|
31009
31232
|
process.exit(2);
|
|
@@ -31040,7 +31263,7 @@ ${check.stdout || check.stderr}
|
|
|
31040
31263
|
if (check.code !== 0) process.exitCode = 1;
|
|
31041
31264
|
}
|
|
31042
31265
|
async function runDemo(rest) {
|
|
31043
|
-
const pkgRoot3 =
|
|
31266
|
+
const pkgRoot3 = join56(dirname21(fileURLToPath12(import.meta.url)), "..");
|
|
31044
31267
|
const registry2 = loadDemoRegistry(pkgRoot3);
|
|
31045
31268
|
let port = 4600;
|
|
31046
31269
|
let live2 = false;
|
|
@@ -31110,6 +31333,10 @@ async function runDemo(rest) {
|
|
|
31110
31333
|
`);
|
|
31111
31334
|
process.exit(1);
|
|
31112
31335
|
}
|
|
31336
|
+
if (entry.serve.terralith) {
|
|
31337
|
+
await serveTerralithDemo(target, port);
|
|
31338
|
+
return;
|
|
31339
|
+
}
|
|
31113
31340
|
if (entry.serve.carve) {
|
|
31114
31341
|
await serveCarveDemo(target, entry.serve.carve, port, live2);
|
|
31115
31342
|
return;
|
|
@@ -31134,6 +31361,12 @@ function spawnStep(cmd, args, cwd) {
|
|
|
31134
31361
|
child.on("close", (code) => res(code ?? 1));
|
|
31135
31362
|
});
|
|
31136
31363
|
}
|
|
31364
|
+
async function serveTerralithDemo(target, port) {
|
|
31365
|
+
const endpoint = `http://127.0.0.1:${process.env.TERRALITH_PORT ?? "4652"}`;
|
|
31366
|
+
process.stdout.write(`behold demo terralith \u2192 serving the walkthrough. Next, in ${target}: bash scripts/terralith-step.sh adopt
|
|
31367
|
+
`);
|
|
31368
|
+
await startServer({ projectDir: target, terralithDemo: { root: target, endpoint }, port });
|
|
31369
|
+
}
|
|
31137
31370
|
async function serveCarveDemo(target, carve, port, live2 = false) {
|
|
31138
31371
|
const at2 = (rel) => resolve35(target, rel);
|
|
31139
31372
|
const project = at2(carve.project);
|
|
@@ -31175,7 +31408,7 @@ async function serveCarveDemo(target, carve, port, live2 = false) {
|
|
|
31175
31408
|
};
|
|
31176
31409
|
process.stdout.write("behold demo carve --live \u2192 the tfstate is real now; the advisor reads what terraform wrote.\n");
|
|
31177
31410
|
}
|
|
31178
|
-
if (
|
|
31411
|
+
if (existsSync35(join56(project, "package.json")) && !existsSync35(join56(project, "node_modules"))) {
|
|
31179
31412
|
process.stdout.write(`behold demo carve \u2192 npm install in ${carve.project}/ (the chant this walkthrough shells)\u2026
|
|
31180
31413
|
`);
|
|
31181
31414
|
const code = await spawnStep("npm", ["install"], project);
|
|
@@ -31186,7 +31419,7 @@ async function serveCarveDemo(target, carve, port, live2 = false) {
|
|
|
31186
31419
|
}
|
|
31187
31420
|
}
|
|
31188
31421
|
let degraded;
|
|
31189
|
-
if (!
|
|
31422
|
+
if (!existsSync35(join56(target, "node_modules", ...HCL_PARSER_PKG.split("/")))) {
|
|
31190
31423
|
process.stdout.write(`behold demo carve \u2192 npm install ${HCL_PARSER_PKG} (chant's HCL parser, ~2MB, once)\u2026
|
|
31191
31424
|
`);
|
|
31192
31425
|
const code = await spawnStep("npm", ["install", "--no-save", "--no-package-lock", HCL_PARSER_PKG], target);
|
|
@@ -31203,7 +31436,7 @@ async function serveCarveDemo(target, carve, port, live2 = false) {
|
|
|
31203
31436
|
);
|
|
31204
31437
|
if (code !== 0) degraded = `chant carve advise exited ${code}`;
|
|
31205
31438
|
}
|
|
31206
|
-
const serving = !degraded &&
|
|
31439
|
+
const serving = !degraded && existsSync35(report) ? report : committed;
|
|
31207
31440
|
if (degraded) {
|
|
31208
31441
|
process.stderr.write(
|
|
31209
31442
|
`behold demo carve: ${degraded}
|
|
@@ -31211,7 +31444,7 @@ async function serveCarveDemo(target, carve, port, live2 = false) {
|
|
|
31211
31444
|
`
|
|
31212
31445
|
);
|
|
31213
31446
|
}
|
|
31214
|
-
if (!
|
|
31447
|
+
if (!existsSync35(serving)) {
|
|
31215
31448
|
process.stderr.write(`behold demo carve: no carve report at ${serving}
|
|
31216
31449
|
`);
|
|
31217
31450
|
process.exit(2);
|
|
@@ -31257,7 +31490,7 @@ async function runPreview(rest) {
|
|
|
31257
31490
|
process.exit(2);
|
|
31258
31491
|
}
|
|
31259
31492
|
const projectDir = resolve35(dirArg ?? process.cwd());
|
|
31260
|
-
if (!
|
|
31493
|
+
if (!existsSync35(projectDir)) {
|
|
31261
31494
|
process.stderr.write(`behold preview: project not found at ${projectDir}
|
|
31262
31495
|
`);
|
|
31263
31496
|
process.exit(2);
|
|
@@ -31348,7 +31581,7 @@ async function runExportCmd(rest) {
|
|
|
31348
31581
|
injectEmulatorEnv(env);
|
|
31349
31582
|
env ??= "local";
|
|
31350
31583
|
}
|
|
31351
|
-
if (!
|
|
31584
|
+
if (!existsSync35(projectDir)) {
|
|
31352
31585
|
process.stderr.write(`behold export: project not found at ${projectDir}
|
|
31353
31586
|
`);
|
|
31354
31587
|
process.exit(2);
|