meetsoma 0.4.0 → 0.22.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/thin-cli.js +140 -21
  2. package/package.json +5 -1
package/dist/thin-cli.js CHANGED
@@ -213,7 +213,7 @@ import { join as join3, dirname as dirname3 } from "path";
213
213
  import { homedir as homedir3, platform as platform2 } from "os";
214
214
  import { fileURLToPath } from "url";
215
215
  import { execSync as execSync2, execFileSync } from "child_process";
216
- import { randomBytes } from "crypto";
216
+ import { randomBytes, createHash } from "crypto";
217
217
 
218
218
  // personality.js
219
219
  var _state = {
@@ -1653,20 +1653,42 @@ async function healthCheck() {
1653
1653
  if (existsSync3(pkgPath)) {
1654
1654
  const pkg = JSON.parse(readFileSync3(pkgPath, "utf-8"));
1655
1655
  const declaredPi = (pkg.dependencies || {})["@mariozechner/pi-coding-agent"];
1656
- const piPkgPath = join3(CORE_DIR, "node_modules", "@mariozechner", "pi-coding-agent", "package.json");
1657
- if (existsSync3(piPkgPath)) {
1658
- const installedPi = JSON.parse(readFileSync3(piPkgPath, "utf-8")).version;
1659
- const declaredClean = (declaredPi || "").replace(/^[\^~]/, "");
1660
- if (declaredClean && installedPi && declaredClean !== installedPi) {
1661
- console.log(` ${yellow("\u26A0")} Pi runtime drift: declared ${cyan(declaredClean)}, installed ${cyan(installedPi)}`);
1662
- console.log(` ${dim("Fix:")} ${green("soma update")}`);
1663
- warnings++;
1664
- } else if (installedPi) {
1665
- console.log(` ${green("\u2713")} Pi runtime ${installedPi}`);
1656
+ const declaredClean = (declaredPi || "").replace(/^[\^~]/, "");
1657
+ let bundledPi = null;
1658
+ let bundledSource = null;
1659
+ const manifestPath = join3(CORE_DIR, "dist", "manifest.json");
1660
+ if (existsSync3(manifestPath)) {
1661
+ try {
1662
+ const m = JSON.parse(readFileSync3(manifestPath, "utf-8"));
1663
+ if (m.piVersion) {
1664
+ bundledPi = m.piVersion;
1665
+ bundledSource = "dist/manifest.json";
1666
+ }
1667
+ } catch {
1666
1668
  }
1667
- } else {
1668
- console.log(` ${yellow("\u26A0")} Pi not installed \u2014 run ${green("soma update")}`);
1669
+ }
1670
+ let fallbackUsed = false;
1671
+ if (!bundledPi) {
1672
+ const piPkgPath = join3(CORE_DIR, "node_modules", "@mariozechner", "pi-coding-agent", "package.json");
1673
+ if (existsSync3(piPkgPath)) {
1674
+ try {
1675
+ bundledPi = JSON.parse(readFileSync3(piPkgPath, "utf-8")).version;
1676
+ bundledSource = "node_modules (fallback \u2014 dist/manifest.json missing)";
1677
+ fallbackUsed = true;
1678
+ } catch {
1679
+ }
1680
+ }
1681
+ }
1682
+ if (!bundledPi) {
1683
+ console.log(` ${yellow("\u26A0")} Pi not found \u2014 run ${green("soma update")}`);
1684
+ warnings++;
1685
+ } else if (declaredClean && declaredClean !== bundledPi) {
1686
+ console.log(` ${yellow("\u26A0")} Pi runtime drift: declared ${cyan(declaredClean)}, bundled ${cyan(bundledPi)}`);
1687
+ console.log(` ${dim("Fix:")} ${green("soma update")}${fallbackUsed ? dim(" (also rebuild dist: node scripts/build-dist.mjs --clean)") : ""}`);
1669
1688
  warnings++;
1689
+ } else {
1690
+ const suffix = fallbackUsed ? dim(" (via node_modules fallback)") : "";
1691
+ console.log(` ${green("\u2713")} Pi runtime ${bundledPi}${suffix}`);
1670
1692
  }
1671
1693
  }
1672
1694
  } catch {
@@ -1710,7 +1732,7 @@ async function projectDoctor() {
1710
1732
  }
1711
1733
  printSigma();
1712
1734
  const agentV = getAgentVersion();
1713
- const projectV = getProjectVersion();
1735
+ let projectV = getProjectVersion();
1714
1736
  const installed = isInstalled();
1715
1737
  console.log(` ${bold("Soma")} \u2014 Doctor`);
1716
1738
  console.log("");
@@ -1733,11 +1755,29 @@ async function projectDoctor() {
1733
1755
  return;
1734
1756
  }
1735
1757
  if (!projectV) {
1736
- console.log(` ${yellow("\u26A0")} Project .soma/ has no version (pre-versioning).`);
1737
- console.log(` This project was likely created before v0.6.3.`);
1738
- console.log(` Run ${green("/soma doctor")} inside a session to migrate, or re-init with ${green("soma init")}.`);
1739
- console.log("");
1740
- return;
1758
+ console.log(` ${yellow("\u26A0")} Project .soma/ has no version (pre-versioning). Stamping...`);
1759
+ try {
1760
+ const settingsPath = join3(process.cwd(), ".soma", "settings.json");
1761
+ let cfg = {};
1762
+ if (existsSync3(settingsPath)) {
1763
+ try {
1764
+ cfg = JSON.parse(readFileSync3(settingsPath, "utf8"));
1765
+ } catch {
1766
+ }
1767
+ } else {
1768
+ mkdirSync2(dirname3(settingsPath), { recursive: true });
1769
+ }
1770
+ cfg.version = agentV;
1771
+ writeFileSync2(settingsPath, JSON.stringify(cfg, null, 2) + "\n");
1772
+ console.log(` ${green("\u2713")} Stamped .soma/settings.json \u2192 v${agentV}`);
1773
+ console.log("");
1774
+ projectV = agentV;
1775
+ } catch (e) {
1776
+ console.log(` ${red("\u2717")} Failed to stamp settings.json: ${e.message}`);
1777
+ console.log(` Run ${green("soma init")} to scaffold a fresh .soma/settings.json.`);
1778
+ console.log("");
1779
+ return;
1780
+ }
1741
1781
  }
1742
1782
  try {
1743
1783
  const softSomaDir = join3(process.cwd(), ".soma");
@@ -1840,6 +1880,66 @@ async function projectDoctor() {
1840
1880
  }
1841
1881
  } catch {
1842
1882
  }
1883
+ try {
1884
+ const softSomaDir = join3(process.cwd(), ".soma");
1885
+ if (existsSync3(softSomaDir)) {
1886
+ const templateRoots = [CORE_DIR, join3(CORE_DIR, "dist")];
1887
+ try {
1888
+ const devCore = readlinkSync2(join3(CORE_DIR, "core"));
1889
+ if (devCore) {
1890
+ const devRoot = dirname3(devCore);
1891
+ templateRoots.push(devRoot, join3(devRoot, "dist"));
1892
+ }
1893
+ } catch {
1894
+ }
1895
+ let registry = null;
1896
+ let bundledTemplatesDir = null;
1897
+ for (const root of templateRoots) {
1898
+ const regPath = join3(root, "migrations", "template-hashes.json");
1899
+ if (existsSync3(regPath) && !registry) {
1900
+ try {
1901
+ registry = JSON.parse(readFileSync3(regPath, "utf-8"));
1902
+ } catch {
1903
+ }
1904
+ }
1905
+ const td = join3(root, "templates", "default");
1906
+ if (existsSync3(td) && !bundledTemplatesDir) bundledTemplatesDir = td;
1907
+ }
1908
+ if (registry?.templates && bundledTemplatesDir) {
1909
+ const sha256 = (buf) => createHash("sha256").update(buf).digest("hex");
1910
+ let refreshed = 0;
1911
+ let customized = 0;
1912
+ const customizedFiles = [];
1913
+ for (const [filename, meta] of Object.entries(registry.templates)) {
1914
+ const localPath = join3(softSomaDir, "body", filename);
1915
+ const bundledPath = join3(bundledTemplatesDir, filename);
1916
+ if (!existsSync3(localPath) || !existsSync3(bundledPath)) continue;
1917
+ const localContent = readFileSync3(localPath);
1918
+ const bundledContent = readFileSync3(bundledPath);
1919
+ const localHash = sha256(localContent);
1920
+ const bundledHash = sha256(bundledContent);
1921
+ if (localHash === bundledHash) continue;
1922
+ const historical = (meta.historical || []).map((h) => h.sha256);
1923
+ if (historical.includes(localHash)) {
1924
+ writeFileSync2(localPath, bundledContent);
1925
+ console.log(` ${green("\u2713")} Refreshed body/${filename} (pristine older bundled \u2192 current)`);
1926
+ refreshed++;
1927
+ } else {
1928
+ customized++;
1929
+ customizedFiles.push(filename);
1930
+ }
1931
+ }
1932
+ if (refreshed > 0) console.log("");
1933
+ if (customized > 0) {
1934
+ console.log(` ${yellow("\u26A0")} Customized body files with bundled updates available: ${customizedFiles.join(", ")}`);
1935
+ console.log(` ${dim("Review updates: diff body/<file> vs " + bundledTemplatesDir + "/<file>")}`);
1936
+ console.log(` ${dim("To adopt bundled: rm body/<file> && soma init --force (safe \u2014 writeIfMissing preserves others)")}`);
1937
+ console.log("");
1938
+ }
1939
+ }
1940
+ }
1941
+ } catch {
1942
+ }
1843
1943
  if (agentV && semverCmp2(projectV, agentV) === 0) {
1844
1944
  console.log(` ${green("\u2713")} Project is up to date.`);
1845
1945
  console.log("");
@@ -1975,8 +2075,27 @@ async function projectDoctor() {
1975
2075
  const heatLine = projRaw.match(/^heat:.*$/m);
1976
2076
  const loadsLine = projRaw.match(/^loads:.*$/m);
1977
2077
  let updated = bundledRaw;
1978
- if (heatLine) updated = updated.replace(/^heat:.*$/m, heatLine[0]);
1979
- if (loadsLine) updated = updated.replace(/^loads:.*$/m, loadsLine[0]);
2078
+ const inject = [];
2079
+ if (heatLine) {
2080
+ if (/^heat:.*$/m.test(updated)) {
2081
+ updated = updated.replace(/^heat:.*$/m, heatLine[0]);
2082
+ } else {
2083
+ inject.push(heatLine[0]);
2084
+ }
2085
+ }
2086
+ if (loadsLine) {
2087
+ if (/^loads:.*$/m.test(updated)) {
2088
+ updated = updated.replace(/^loads:.*$/m, loadsLine[0]);
2089
+ } else {
2090
+ inject.push(loadsLine[0]);
2091
+ }
2092
+ }
2093
+ if (inject.length > 0) {
2094
+ updated = updated.replace(/^---\n([\s\S]*?)\n---/, `---
2095
+ $1
2096
+ ${inject.join("\n")}
2097
+ ---`);
2098
+ }
1980
2099
  writeFileSync2(join3(protoDir, f), updated);
1981
2100
  staleUpdated++;
1982
2101
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "meetsoma",
3
- "version": "0.4.0",
3
+ "version": "0.22.1",
4
4
  "description": "Soma — the AI coding agent with self-growing memory",
5
5
  "type": "module",
6
6
  "bin": {
@@ -40,5 +40,9 @@
40
40
  },
41
41
  "engines": {
42
42
  "node": ">=20.6.0"
43
+ },
44
+ "piConfig": {
45
+ "name": "soma",
46
+ "configDir": ".soma"
43
47
  }
44
48
  }