@holmes-lab/holmes-kit 0.7.0 → 0.8.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.
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.NPM_URL = void 0;
37
+ exports.compareSemver = compareSemver;
38
+ exports.readCache = readCache;
39
+ exports.installModeGuide = installModeGuide;
40
+ exports.composeBanner = composeBanner;
41
+ exports.shouldQuery = shouldQuery;
42
+ exports.cacheIsStale = cacheIsStale;
43
+ // @implements A-SPEC-531.1
44
+ // The session banner and update notice, as a PURE core. Every side channel — the filesystem, the
45
+ // clock, the environment — is a parameter, so the whole module verifies offline. The delivery
46
+ // points (SessionStart hook, MCP instructions, init wiring) consume this in A-SPEC-531.2.
47
+ //
48
+ // No new dependency: semver comparison is a three-integer compare (our versions are plain
49
+ // major.minor.patch — a full semver library would carry prerelease/build code this never runs), and
50
+ // the registry query (A-SPEC-531.2) uses Node's built-in https.
51
+ const path = __importStar(require("node:path"));
52
+ exports.NPM_URL = 'https://www.npmjs.com/package/@holmes-lab/holmes-kit';
53
+ const DEFAULT_TTL_MS = 24 * 3600_000;
54
+ /** Parse `major.minor.patch` to a 3-tuple; a non-numeric field becomes 0 (never throws). */
55
+ function triple(v) {
56
+ const parts = String(v).split('.');
57
+ const n = (i) => { const x = Number.parseInt(parts[i] ?? '', 10); return Number.isFinite(x) ? x : 0; };
58
+ return [n(0), n(1), n(2)];
59
+ }
60
+ /** -1 if a<b, 0 if equal, 1 if a>b — NUMERIC per field, so 0.9.0 < 0.10.0 (a string compare fails). */
61
+ function compareSemver(a, b) {
62
+ const x = triple(a);
63
+ const y = triple(b);
64
+ for (let i = 0; i < 3; i++) {
65
+ if (x[i] < y[i])
66
+ return -1;
67
+ if (x[i] > y[i])
68
+ return 1;
69
+ }
70
+ return 0;
71
+ }
72
+ /** The cache file, read only — no network, no write. Anything unreadable/malformed/mis-shaped → null. */
73
+ function readCache(home, readFile) {
74
+ let raw;
75
+ try {
76
+ raw = readFile(path.join(home, '.holmes', 'update-check.json'));
77
+ }
78
+ catch {
79
+ return null;
80
+ }
81
+ if (!raw)
82
+ return null;
83
+ try {
84
+ const v = JSON.parse(raw);
85
+ if (v && typeof v === 'object'
86
+ && typeof v.latest === 'string'
87
+ && typeof v.checkedAt === 'number') {
88
+ return { latest: v.latest, checkedAt: v.checkedAt };
89
+ }
90
+ return null;
91
+ }
92
+ catch {
93
+ return null;
94
+ }
95
+ }
96
+ /** The one-line update guidance, branched by install mode. `source` returns null (git updates it). */
97
+ function installModeGuide(mode, latest, current) {
98
+ const head = `[Holmes-Kit] Update available: ${latest} (current ${current}).`;
99
+ switch (mode) {
100
+ case 'global-npx':
101
+ return `${head} Run: npm i -g @holmes-lab/holmes-kit@latest, then holmes-kit init --force (re-pins wiring; requires HOLMES_APPROVAL).`;
102
+ case 'local-dep':
103
+ return `${head} Run: npm i -D @holmes-lab/holmes-kit@latest`;
104
+ case 'source':
105
+ return null;
106
+ }
107
+ }
108
+ /**
109
+ * The banner: always an English intro line (version + governance rule + npm page). If the cache
110
+ * knows a newer version AND the install mode has an update path, a second guidance line follows.
111
+ */
112
+ function composeBanner(input) {
113
+ const intro = `[Holmes-Kit] This session is governed by Holmes-Kit v${input.current} (No Spec, No Code) — ${input.npmUrl}`;
114
+ const latest = input.cached?.latest;
115
+ if (latest && compareSemver(latest, input.current) > 0) {
116
+ const guide = installModeGuide(input.mode, latest, input.current);
117
+ if (guide)
118
+ return `${intro}\n${guide}`;
119
+ }
120
+ return intro;
121
+ }
122
+ /** Whether a network refresh is allowed at all. Opt-out via HOLMES_NO_UPDATE_CHECK or CI. */
123
+ function shouldQuery(env) {
124
+ return !env.HOLMES_NO_UPDATE_CHECK && !env.CI;
125
+ }
126
+ /** Whether the cache is old enough to refresh. A missing cache is stale. */
127
+ function cacheIsStale(cached, now, ttlMs = DEFAULT_TTL_MS) {
128
+ if (!cached)
129
+ return true;
130
+ return now - cached.checkedAt > ttlMs;
131
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "//": "@implements A-SPEC-209",
3
3
  "name": "@holmes-lab/holmes-kit",
4
- "version": "0.7.0",
4
+ "version": "0.8.1",
5
5
  "description": "Holmes-Kit — deterministic Agentic Software Engineering (ASE) harness with causal traceability (spec chain + D-CPG + RTM + phase guardrail)",
6
6
  "main": "dist/holmes/mcp/server.js",
7
7
  "types": "dist/holmes/mcp/server.d.ts",