githolon 0.24.0 → 0.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.mjs +57 -10
  2. package/package.json +5 -3
package/dist/cli.mjs CHANGED
@@ -25,10 +25,14 @@ __export(governance_exports, {
25
25
  });
26
26
  import { createHash, createPrivateKey, createPublicKey } from "node:crypto";
27
27
  import { readFileSync, writeFileSync as writeFileSync2 } from "node:fs";
28
- import { connect } from "@githolon/client";
28
+ async function clientConnect() {
29
+ const mod = await import("@githolon/client");
30
+ return mod.connect;
31
+ }
29
32
  async function connectGovernance(cloud, parent) {
30
33
  const authToken = await sessionToken().catch(() => void 0);
31
34
  const clientId = `githolon-cli-${Date.now().toString(16)}`;
35
+ const connect = await clientConnect();
32
36
  return await connect({
33
37
  cloud,
34
38
  workspace: parent,
@@ -1493,7 +1497,43 @@ function runChildBirthLeg(eng, ws, lawHash, cb, frameworkHash) {
1493
1497
  if (cb.lawHashField !== void 0) payload[cb.lawHashField] = lawHash;
1494
1498
  const stamp = (/* @__PURE__ */ new Date()).toISOString();
1495
1499
  for (const f of cb.birthAutoStamped) payload[f] = stamp;
1496
- const res = author(eng, ws, cb.parentDomain, cb.birthDirectiveId, payload, lawHash);
1500
+ const actor = actorFromPayload(payload, cb.birthActorField);
1501
+ if (cb.birthRequiresRelation !== void 0 && actor === void 0) {
1502
+ return done(false, `child birth ${cb.parentDomain}/${cb.birthDirectiveId} is gated by .requires("${cb.birthRequiresRelation}") but the proof could not discover an actor field from the birth recipe \u2014 route the genesis step actor from a payload subject field`);
1503
+ }
1504
+ let parentWs = ws;
1505
+ if (cb.parentSetup !== void 0) {
1506
+ const setup = cb.parentSetup;
1507
+ const setupPayload = { ...setup.birthPayload };
1508
+ if (setup.frameworkHashField !== void 0) setupPayload[setup.frameworkHashField] = fw;
1509
+ if (setup.lawHashField !== void 0) setupPayload[setup.lawHashField] = lawHash;
1510
+ for (const f of setup.birthAutoStamped) setupPayload[f] = stamp;
1511
+ if (setup.birthActorField !== void 0 && cb.birthActorField !== void 0 && payload[cb.birthActorField] !== void 0) {
1512
+ setupPayload[setup.birthActorField] = payload[cb.birthActorField];
1513
+ }
1514
+ const setupActor = actorFromPayload(setupPayload, setup.birthActorField) ?? actor;
1515
+ const setupOpts = setupActor !== void 0 ? { actor: setupActor } : {};
1516
+ const setupRes = author(
1517
+ eng,
1518
+ ws,
1519
+ setup.parentDomain,
1520
+ setup.birthDirectiveId,
1521
+ setupPayload,
1522
+ lawHash,
1523
+ setupOpts
1524
+ );
1525
+ if (setupRes.ok === false) {
1526
+ return done(false, `parent setup ${setup.parentDomain}/${setup.birthDirectiveId} refused: ${setupRes.error ?? "unknown"} \u2014 the proof could not birth the parent workspace needed before gated child birth`);
1527
+ }
1528
+ const bornParent = (setupRes.born ?? []).map((b) => b?.workspace).find((w) => typeof w === "string" && w.length > 0);
1529
+ if (bornParent === void 0) {
1530
+ return done(false, `parent setup ${setup.parentDomain}/${setup.birthDirectiveId} admitted but spawned no parent workspace (born=${JSON.stringify(setupRes.born ?? [])})`);
1531
+ }
1532
+ parentWs = bornParent;
1533
+ lines.push(`\u2713 parent setup ${setup.parentDomain}/${setup.birthDirectiveId} \u2014 ${parentWs} born before gated child birth`);
1534
+ }
1535
+ const opts = actor !== void 0 ? { actor } : {};
1536
+ const res = author(eng, parentWs, cb.parentDomain, cb.birthDirectiveId, payload, lawHash, opts);
1497
1537
  if (res.ok === false) {
1498
1538
  return done(false, `child birth ${cb.parentDomain}/${cb.birthDirectiveId} refused: ${res.error ?? "unknown"} \u2014 the parent's own gate rejected the birth offer (check the .births() plan + payload)`);
1499
1539
  }
@@ -1547,6 +1587,11 @@ function runChildBirthLeg(eng, ws, lawHash, cb, frameworkHash) {
1547
1587
  lines.push(`\u2713 verify_chain GREEN on the born child ${childWs} (${verdict.plansRerun ?? "?"} plans re-run \u2014 it self-validates from intent 0 through its OWN gate)`);
1548
1588
  return done(true);
1549
1589
  }
1590
+ function actorFromPayload(payload, field) {
1591
+ if (field === void 0) return void 0;
1592
+ const value = payload[field];
1593
+ return typeof value === "string" && value.trim().length > 0 ? value : void 0;
1594
+ }
1550
1595
  async function runOfflineProofStandalone(proofPath, cloud, domain) {
1551
1596
  const src = readFileSync4(proofPath, "utf8");
1552
1597
  const packageName = basename(proofPath).replace(/\.proof\.mts$/, "");
@@ -1789,7 +1834,6 @@ Re-run with --force to replace it.`
1789
1834
 
1790
1835
  // src/cli.ts
1791
1836
  init_cloud();
1792
- init_governance();
1793
1837
 
1794
1838
  // src/compile.ts
1795
1839
  import { spawn, spawnSync } from "node:child_process";
@@ -3332,6 +3376,7 @@ ${commandHelp("status")}`);
3332
3376
  return runCloud(argv);
3333
3377
  }
3334
3378
  if (argv[0] === "key") {
3379
+ const { keyEnroll: keyEnroll2, keyExport: keyExport2, keyImport: keyImport2, keyShow: keyShow2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
3335
3380
  const { pos, opts, bad } = cloudArgs(argv.slice(1));
3336
3381
  if (bad !== void 0) {
3337
3382
  process.stderr.write(`error: ${bad}
@@ -3340,16 +3385,17 @@ ${USAGE}`);
3340
3385
  return 1;
3341
3386
  }
3342
3387
  const [sub] = pos;
3343
- if (sub === "enroll") return keyEnroll(opts);
3344
- if (sub === "show") return keyShow(opts);
3345
- if (sub === "import") return keyImport(opts);
3346
- if (sub === "export") return keyExport(opts);
3388
+ if (sub === "enroll") return keyEnroll2(opts);
3389
+ if (sub === "show") return keyShow2(opts);
3390
+ if (sub === "import") return keyImport2(opts);
3391
+ if (sub === "export") return keyExport2(opts);
3347
3392
  process.stderr.write(`error: expected: githolon key <enroll|show|import|export> [--principal <uid>]
3348
3393
 
3349
3394
  ${USAGE}`);
3350
3395
  return 1;
3351
3396
  }
3352
3397
  if (argv[0] === "gov") {
3398
+ const { governanceOffer: governanceOffer2, governanceRelay: governanceRelay2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
3353
3399
  const { pos, opts, bad } = cloudArgs(argv.slice(1));
3354
3400
  if (bad !== void 0) {
3355
3401
  process.stderr.write(`error: ${bad}
@@ -3365,7 +3411,7 @@ ${commandHelp("gov") ?? USAGE}`);
3365
3411
  ${commandHelp("gov") ?? USAGE}`);
3366
3412
  return 1;
3367
3413
  }
3368
- return governanceRelay(ws2, file, opts);
3414
+ return governanceRelay2(ws2, file, opts);
3369
3415
  }
3370
3416
  const [ws, directiveId] = pos;
3371
3417
  if (ws === void 0 || directiveId === void 0) {
@@ -3374,9 +3420,10 @@ ${commandHelp("gov") ?? USAGE}`);
3374
3420
  ${commandHelp("gov") ?? USAGE}`);
3375
3421
  return 1;
3376
3422
  }
3377
- return governanceOffer(ws, directiveId, opts);
3423
+ return governanceOffer2(ws, directiveId, opts);
3378
3424
  }
3379
3425
  if (argv[0] === "grant" || argv[0] === "revoke") {
3426
+ const { grantOrRevoke: grantOrRevoke2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
3380
3427
  const verb = argv[0];
3381
3428
  const { pos, opts, bad } = cloudArgs(argv.slice(1));
3382
3429
  if (bad !== void 0) {
@@ -3392,7 +3439,7 @@ ${USAGE}`);
3392
3439
  ${USAGE}`);
3393
3440
  return 1;
3394
3441
  }
3395
- return grantOrRevoke(verb, kind, subject, opts);
3442
+ return grantOrRevoke2(verb, kind, subject, opts);
3396
3443
  }
3397
3444
  if (argv[0] === "login") {
3398
3445
  const agent = argv.includes("--agent");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "githolon",
3
- "version": "0.24.0",
3
+ "version": "0.24.1",
4
4
  "type": "module",
5
5
  "description": "githolon — the Nomos developer CLI: Rails-style generators for @githolon/dsl domains + the package compiler. Kernel-independent.",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -21,14 +21,16 @@
21
21
  "scripts": {
22
22
  "build": "node build.mjs",
23
23
  "prepare": "npm run build",
24
+ "pretest": "npm run build",
24
25
  "holon": "tsx src/cli.ts",
25
26
  "test": "vitest run",
27
+ "pretypecheck": "npm run build",
26
28
  "typecheck": "tsc --noEmit"
27
29
  },
28
30
  "dependencies": {
29
31
  "@bjorn3/browser_wasi_shim": "0.4.2",
30
- "@githolon/client": "^0.24.0",
31
- "@githolon/dsl": "^0.24.0",
32
+ "@githolon/client": "^0.24.1",
33
+ "@githolon/dsl": "^0.24.1",
32
34
  "isomorphic-git": "^1.38.4"
33
35
  },
34
36
  "devDependencies": {