@holmes-lab/holmes-kit 0.35.24 → 0.35.25

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,132 @@
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.scratchRootPath = scratchRootPath;
37
+ exports.trustedScratchRoot = trustedScratchRoot;
38
+ exports.ensureScratchRoot = ensureScratchRoot;
39
+ exports.newScratchDir = newScratchDir;
40
+ exports.isUnderScratchRoot = isUnderScratchRoot;
41
+ // @implements A-SPEC-773, A-SPEC-773.2, A-SPEC-773.3
42
+ const fs = __importStar(require("node:fs"));
43
+ const os = __importStar(require("node:os"));
44
+ const path = __importStar(require("node:path"));
45
+ /**
46
+ * @implements A-SPEC-773 — one Holmes-owned scratch root per user under the OS temporary directory. Agents make their
47
+ * temporary directories under it (`holmes-kit scratch --new <label>`), and the shared gate lets a recursive rm of a
48
+ * subdirectory through when the root is still this user's own 0700 directory (owner decision 2026-10-17). Per user,
49
+ * because a shared /tmp let another user pre-create the codex-oracle root (review, round 3 of that slice).
50
+ */
51
+ function who() {
52
+ if (typeof process.getuid === 'function')
53
+ return String(process.getuid());
54
+ try {
55
+ return os.userInfo().username.replace(/[^\w.-]/g, '_');
56
+ }
57
+ catch {
58
+ return 'user';
59
+ }
60
+ }
61
+ function scratchRootPath(tmpdir = os.tmpdir()) {
62
+ return path.join(tmpdir, `holmes-scratch-${who()}`);
63
+ }
64
+ /** The root's real path when it is this user's own directory, not a link, with no group or other bits; else null. */
65
+ function trustedScratchRoot(tmpdir = os.tmpdir(), lstat = fs.lstatSync, platform = process.platform) {
66
+ // @implements A-SPEC-773.2 — POSIX only: Windows has no getuid or mode bits to read, so nothing proves the root is this
67
+ // user's own; drive-letter targets were never admitted by the gate's shape filter either (round 1, quality).
68
+ if (platform === 'win32')
69
+ return null;
70
+ const root = scratchRootPath(tmpdir);
71
+ try {
72
+ const st = lstat(root);
73
+ if (!st.isDirectory() || st.isSymbolicLink())
74
+ return null;
75
+ if (typeof process.getuid === 'function' && st.uid !== process.getuid())
76
+ return null;
77
+ if ((st.mode & 0o077) !== 0)
78
+ return null;
79
+ return fs.realpathSync.native(root);
80
+ }
81
+ catch {
82
+ return null;
83
+ }
84
+ }
85
+ /** Makes the root (0700) when missing and returns its real path; throws when an existing root is not trusted. */
86
+ function ensureScratchRoot(tmpdir = os.tmpdir()) {
87
+ const root = scratchRootPath(tmpdir);
88
+ try {
89
+ fs.mkdirSync(root, { mode: 0o700 });
90
+ }
91
+ catch (e) {
92
+ if (e.code !== 'EEXIST')
93
+ throw e;
94
+ }
95
+ const trusted = trustedScratchRoot(tmpdir);
96
+ if (trusted !== null)
97
+ return trusted;
98
+ // @implements A-SPEC-773.2 — on Windows the directory is made and printed, but the gate never relaxes for it.
99
+ if (process.platform === 'win32')
100
+ return fs.realpathSync.native(root);
101
+ throw new Error(`${root} is not a directory of this user with mode 0700 (a link, another owner, or group/other bits) — remove it if it is yours, or point TMPDIR at a directory of your own when another user owns it, and retry`);
102
+ }
103
+ const LABEL = /^[A-Za-z0-9._-]{1,40}$/;
104
+ /** A fresh subdirectory `<root>/<label>-XXXXXX`. */
105
+ function newScratchDir(label = 'work', tmpdir = os.tmpdir()) {
106
+ if (!LABEL.test(label) || label === '.' || label === '..')
107
+ throw new Error(`invalid scratch label ${JSON.stringify(label)}: use 1–40 of A-Z a-z 0-9 . _ -`);
108
+ return fs.mkdtempSync(path.join(ensureScratchRoot(tmpdir), `${label}-`));
109
+ }
110
+ /** True when the target exists and its real path lies strictly under `root` (a real path). */
111
+ function isUnderScratchRoot(target, root) {
112
+ // @implements A-SPEC-773.2 — one realpath, no parent fallback: a missing target needs no removal and gets no signal
113
+ // (round 1, quality: 2,000 missing targets under a deep chain took 11 s).
114
+ // @implements A-SPEC-773.3 — judged as rm acts: rm removes a final link itself, so only the parent is resolved; with a
115
+ // trailing slash (or a final `/.`) rm acts through the link, so the whole path is (round 2: `rm -rf <outside>/outlink`
116
+ // was let through because the link's target was judged).
117
+ let resolved;
118
+ try {
119
+ if (/\/\.?$/.test(target))
120
+ resolved = fs.realpathSync.native(path.resolve(target));
121
+ else {
122
+ const abs = path.resolve(target);
123
+ fs.lstatSync(abs);
124
+ resolved = path.join(fs.realpathSync.native(path.dirname(abs)), path.basename(abs));
125
+ }
126
+ }
127
+ catch {
128
+ return false;
129
+ }
130
+ const rel = path.relative(root, resolved);
131
+ return rel !== '' && !rel.startsWith('..') && !path.isAbsolute(rel);
132
+ }
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.runDispatch = runDispatch;
37
- // @implements A-SPEC-751, A-SPEC-751.1, A-SPEC-751.5, A-SPEC-751.6, A-SPEC-754, A-SPEC-769.10, A-SPEC-772.1
37
+ // @implements A-SPEC-751, A-SPEC-751.1, A-SPEC-751.5, A-SPEC-751.6, A-SPEC-751.7, A-SPEC-754, A-SPEC-769.10, A-SPEC-772.1
38
38
  const path = __importStar(require("node:path"));
39
39
  const node_child_process_1 = require("node:child_process");
40
40
  const binding_1 = require("./binding");
@@ -99,7 +99,7 @@ async function runDispatch(opts) {
99
99
  const budget = (0, hook_process_1.boundedHookBudget)(opts.hookBudgetMs, hook_process_1.HOOK_BUDGET_MS);
100
100
  const input = await hookInput(budget);
101
101
  const hints = hintsFromInput(input);
102
- if (process.env.CLAUDE_PROJECT_DIR)
102
+ if (process.env.CLAUDE_PROJECT_DIR && opts.harness === 'claude')
103
103
  hints.push(process.env.CLAUDE_PROJECT_DIR);
104
104
  const selection = (0, binding_1.selectRuntime)((0, binding_1.readRuntimeRegistry)(opts.registryPath), { cwd: process.cwd(), workspaceHints: hints, specsHint: process.env.HOLMES_SPECS });
105
105
  const child = (0, node_child_process_1.spawn)(process.execPath, [path.join(selection.packageRoot, 'dist/holmes/hooks/session-start.js')], {
@@ -145,7 +145,10 @@ async function runDispatch(opts) {
145
145
  }
146
146
  }
147
147
  const hints = input ? hintsFromInput(input) : [];
148
- if (process.env.CLAUDE_PROJECT_DIR)
148
+ // @implements A-SPEC-751.7 — CLAUDE_PROJECT_DIR is Claude Code's variable. Every process Claude launches passes it
149
+ // on, so a Codex or Antigravity session under one of them inherits a value naming ANOTHER workspace (measured
150
+ // 2026-10-17: every Codex tool call denied as "Conflicting runtime workspace hints").
151
+ if (process.env.CLAUDE_PROJECT_DIR && opts.harness === 'claude')
149
152
  hints.push(process.env.CLAUDE_PROJECT_DIR);
150
153
  const selection = (0, binding_1.selectRuntime)((0, binding_1.readRuntimeRegistry)(opts.registryPath), { cwd: process.cwd(), workspaceHints: hints, specsHint: process.env.HOLMES_SPECS });
151
154
  phaseSelection = Math.round(performance.now() - started) - (phaseInput ?? 0);
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.35.24",
4
+ "version": "0.35.25",
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",