githolon 0.57.1 → 0.58.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 +27 -4
  2. package/package.json +3 -3
package/dist/cli.mjs CHANGED
@@ -1967,7 +1967,7 @@ var init_engine = __esm({
1967
1967
 
1968
1968
  // src/local_holon.ts
1969
1969
  import { randomBytes } from "node:crypto";
1970
- import { existsSync as existsSync4, mkdirSync as mkdirSync4, readdirSync as readdirSync2, readFileSync as readFileSync5, statSync, writeFileSync as writeFileSync5 } from "node:fs";
1970
+ import { existsSync as existsSync4, mkdirSync as mkdirSync4, readdirSync as readdirSync2, readFileSync as readFileSync5, renameSync, statSync, writeFileSync as writeFileSync5 } from "node:fs";
1971
1971
  import { dirname as dirname3, join as join5 } from "node:path";
1972
1972
  import { File as File2, Directory as Directory2 } from "@bjorn3/browser_wasi_shim";
1973
1973
  async function fetchJsonCached(url, cacheFile) {
@@ -2006,7 +2006,27 @@ async function fetchRuntime(cloud) {
2006
2006
  const packages = await fetchJsonCached(`${cloud}/v1/runtime/packages`, join5(cache, "packages.json"));
2007
2007
  return { wasmBytes, packages };
2008
2008
  }
2009
+ function atomicWriteRuntime(target, data) {
2010
+ const tmp = `${target}.tmp-${Math.random().toString(16).slice(2)}${Math.random().toString(16).slice(2)}`;
2011
+ writeFileSync5(tmp, data);
2012
+ renameSync(tmp, target);
2013
+ }
2014
+ function runtimeDirIsWarm(runtimeDir) {
2015
+ try {
2016
+ const w = statSync(join5(runtimeDir, "holon.wasm")).mtimeMs;
2017
+ const p = statSync(join5(runtimeDir, "packages.json")).mtimeMs;
2018
+ return Date.now() - Math.min(w, p) < RUNTIME_FRESH_MS;
2019
+ } catch {
2020
+ return false;
2021
+ }
2022
+ }
2009
2023
  async function refreshRuntimeDir(cloud, runtimeDir) {
2024
+ const mode = String(process.env["NOMOS_RUNTIME_REFRESH"] || "auto").toLowerCase();
2025
+ if (mode === "never") return false;
2026
+ if (mode !== "always") {
2027
+ if (_refreshedDirsThisProcess.has(runtimeDir)) return false;
2028
+ if (runtimeDirIsWarm(runtimeDir)) return false;
2029
+ }
2010
2030
  try {
2011
2031
  const r = await fetch(`${cloud}/v1/runtime/holon.wasm`);
2012
2032
  if (!r.ok) throw new Error(`runtime wasm \u2192 ${r.status}`);
@@ -2015,8 +2035,9 @@ async function refreshRuntimeDir(cloud, runtimeDir) {
2015
2035
  if (!pkgs.ok) throw new Error(`runtime packages \u2192 ${pkgs.status}`);
2016
2036
  const pkgText = await pkgs.text();
2017
2037
  mkdirSync4(runtimeDir, { recursive: true });
2018
- writeFileSync5(join5(runtimeDir, "holon.wasm"), wasmBytes);
2019
- writeFileSync5(join5(runtimeDir, "packages.json"), pkgText, "utf8");
2038
+ atomicWriteRuntime(join5(runtimeDir, "holon.wasm"), wasmBytes);
2039
+ atomicWriteRuntime(join5(runtimeDir, "packages.json"), pkgText);
2040
+ _refreshedDirsThisProcess.add(runtimeDir);
2020
2041
  return true;
2021
2042
  } catch {
2022
2043
  return false;
@@ -2073,7 +2094,7 @@ function printVerdict(v) {
2073
2094
  err4(`chain INVALID at ${v["check"]}${v["atIndex"] !== void 0 ? ` (intent ${v["atIndex"]})` : ""}: ${v["error"]}`);
2074
2095
  return false;
2075
2096
  }
2076
- var out4, err4;
2097
+ var out4, err4, RUNTIME_FRESH_MS, _refreshedDirsThisProcess;
2077
2098
  var init_local_holon = __esm({
2078
2099
  "src/local_holon.ts"() {
2079
2100
  "use strict";
@@ -2081,6 +2102,8 @@ var init_local_holon = __esm({
2081
2102
  init_cloud();
2082
2103
  out4 = (s) => void process.stdout.write(s + "\n");
2083
2104
  err4 = (s) => void process.stderr.write("error: " + s + "\n");
2105
+ RUNTIME_FRESH_MS = 15 * 60 * 1e3;
2106
+ _refreshedDirsThisProcess = /* @__PURE__ */ new Set();
2084
2107
  }
2085
2108
  });
2086
2109
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "githolon",
3
- "version": "0.57.1",
3
+ "version": "0.58.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",
@@ -29,8 +29,8 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@bjorn3/browser_wasi_shim": "0.4.2",
32
- "@githolon/client": "^0.57.1",
33
- "@githolon/dsl": "^0.57.1",
32
+ "@githolon/client": "^0.58.1",
33
+ "@githolon/dsl": "^0.58.1",
34
34
  "isomorphic-git": "^1.38.4"
35
35
  },
36
36
  "devDependencies": {