@jeffober/thatch 0.1.31 → 0.1.32

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jeffober/thatch",
3
- "version": "0.1.31",
3
+ "version": "0.1.32",
4
4
  "description": "Persistent memory for AI coding agents — local embeddings, SQLite stores, zero config. Works with OpenCode (as a plugin), Claude Code (as an MCP server), and Cursor (as an MCP server).",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
package/src/index.ts CHANGED
@@ -20,7 +20,7 @@ import { ExtractionPipeline, type ToolInteraction } from "./extraction";
20
20
  import { installSkills, SHARED_SKILLS, OPENCODE_ONLY_SKILLS } from "./skills";
21
21
  import { hygieneReport } from "./hygiene";
22
22
  import { seedDefaultBehaviors } from "./seed-behaviors";
23
- import { startVersionChecker, stopVersionChecker, getVersionChecker, readOnDiskVersion } from "./version-check";
23
+ import { startVersionChecker, stopVersionChecker, getVersionChecker, readOnDiskVersion, compareSemver } from "./version-check";
24
24
  import pkg from "../package.json";
25
25
 
26
26
  // ---------------------------------------------------------------------------
@@ -398,7 +398,7 @@ export const server: Plugin = async ({ client, worktree }) => {
398
398
  const onDisk = readOnDiskVersion();
399
399
  const checker = getVersionChecker();
400
400
  const npmUpdate = checker?.getUpdateWarning() ?? null;
401
- const skewWarning = onDisk && onDisk !== runningVersion
401
+ const skewWarning = onDisk && compareSemver(runningVersion, onDisk) < 0
402
402
  ? `thatch was upgraded to v${onDisk} but this session is running v${runningVersion}. Restart opencode to apply the update.`
403
403
  : null;
404
404
  const warning = skewWarning ?? npmUpdate;
@@ -4,6 +4,23 @@ import { tmpdir } from "node:os";
4
4
  import { join, dirname } from "node:path";
5
5
  import pkg from "../package.json";
6
6
 
7
+ /**
8
+ * Compares two semver strings (e.g. "0.1.30", "0.1.31"). Returns a negative
9
+ * number if a < b, positive if a > b, 0 if equal. Pre-release tags are not
10
+ * supported because @jeffober/thatch does not use them.
11
+ */
12
+ export function compareSemver(a: string, b: string): number {
13
+ const pa = a.split(".").map(Number);
14
+ const pb = b.split(".").map(Number);
15
+ for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
16
+ const va = pa[i] ?? 0;
17
+ const vb = pb[i] ?? 0;
18
+ if (va < vb) return -1;
19
+ if (va > vb) return 1;
20
+ }
21
+ return 0;
22
+ }
23
+
7
24
  /**
8
25
  * Version skew detection and npm update checking.
9
26
  *
@@ -198,7 +215,7 @@ class NpmVersionChecker {
198
215
  */
199
216
  isOutdated(): boolean {
200
217
  if (!this.#latestVersion) return false;
201
- return this.#latestVersion !== pkg.version;
218
+ return compareSemver(pkg.version, this.#latestVersion) < 0;
202
219
  }
203
220
 
204
221
  /**
@@ -309,7 +326,7 @@ export function readNpmCacheForUpdate(dbPath: string): string | null {
309
326
  const raw = readFileSync(path, "utf-8");
310
327
  const parsed = JSON.parse(raw) as NpmCacheEntry;
311
328
  if (!parsed.version) return null;
312
- if (parsed.version === pkg.version) return null;
329
+ if (compareSemver(pkg.version, parsed.version) >= 0) return null;
313
330
  return `thatch v${parsed.version} is available. ` +
314
331
  `Run \`npm update ${NPM_PACKAGE}\` to update, then restart your editor.`;
315
332
  } catch {