@guilz-dev/belay 0.10.0 → 0.10.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.
- package/dist/adapters/claude/runtime-entry.js +5 -18
- package/dist/adapters/codex/runtime-entry.js +10 -11
- package/dist/adapters/cursor/hook-router.d.ts +1 -0
- package/dist/adapters/cursor/hook-router.js +26 -3
- package/dist/adapters/cursor/hook-routing-health.d.ts +1 -0
- package/dist/adapters/cursor/hook-routing-health.js +53 -0
- package/dist/adapters/shared/gate-runtime.d.ts +0 -2
- package/dist/adapters/shared/gate-runtime.js +2 -53
- package/dist/bundle/claude-runtime.mjs +446 -196
- package/dist/bundle/codex-runtime.mjs +449 -219
- package/dist/bundle/cursor-dispatcher.mjs +20 -3
- package/dist/bundle/cursor-runtime.mjs +441 -178
- package/dist/commands/doctor.js +4 -0
- package/dist/core/capability/index.d.ts +1 -1
- package/dist/core/capability/index.js +1 -1
- package/dist/core/capability/policy-engine.d.ts +19 -0
- package/dist/core/capability/policy-engine.js +31 -0
- package/dist/core/classify-tool.js +372 -148
- package/dist/core/config.js +2 -2
- package/dist/core/gate-engine.js +2 -9
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -136,6 +136,7 @@ function findCursorRoutingRepoRoot(startPath) {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
// src/adapters/cursor/hook-router.ts
|
|
139
|
+
var CURSOR_GLOBAL_SENTINEL_BLOCK_MESSAGE = "belay project hook owner is unavailable; the global sentinel blocked this action.";
|
|
139
140
|
function canonicalExistingPath(value) {
|
|
140
141
|
if (!existsSync2(value)) {
|
|
141
142
|
return void 0;
|
|
@@ -289,6 +290,12 @@ function hasMatchingProjectShim(repoRoot, kind) {
|
|
|
289
290
|
}
|
|
290
291
|
return source.includes("from '../belay/runtime/dispatcher.mjs'") && source.includes(`origin: ${JSON.stringify({ scope: "project", repoRoot })}`);
|
|
291
292
|
}
|
|
293
|
+
function hasProjectOwnerInstallation(repoRoot) {
|
|
294
|
+
const hooksDir = cursorRoutingHooksDir(repoRoot);
|
|
295
|
+
return Boolean(
|
|
296
|
+
selectedRunnerPath(hooksDir) && isRegularFile(path4.join(cursorRoutingRuntimeDir(repoRoot), "dispatcher.mjs"))
|
|
297
|
+
);
|
|
298
|
+
}
|
|
292
299
|
function hasCallableProjectOwner(repoRoot, params) {
|
|
293
300
|
const hooksDir = cursorRoutingHooksDir(repoRoot);
|
|
294
301
|
const runnerPath = selectedRunnerPath(hooksDir);
|
|
@@ -331,6 +338,9 @@ function selectedActionPath(payload) {
|
|
|
331
338
|
}
|
|
332
339
|
return void 0;
|
|
333
340
|
}
|
|
341
|
+
function hasRoutingRootMarker(dir) {
|
|
342
|
+
return existsSync2(path4.join(dir, ".git")) || existsSync2(path4.join(dir, ".cursor")) && existsSync2(cursorRoutingConfigPath(dir));
|
|
343
|
+
}
|
|
334
344
|
function readInstallScope(repoRoot) {
|
|
335
345
|
const configPath = cursorRoutingConfigPath(repoRoot);
|
|
336
346
|
let source;
|
|
@@ -342,7 +352,10 @@ function readInstallScope(repoRoot) {
|
|
|
342
352
|
try {
|
|
343
353
|
const parsed = JSON.parse(source);
|
|
344
354
|
if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed) && parsed.installScope === "global") {
|
|
345
|
-
|
|
355
|
+
if (isTrustedCursorRoutingConfig(repoRoot, parsed)) {
|
|
356
|
+
return "global";
|
|
357
|
+
}
|
|
358
|
+
return hasProjectOwnerInstallation(repoRoot) ? "project" : "global";
|
|
346
359
|
}
|
|
347
360
|
} catch {
|
|
348
361
|
}
|
|
@@ -359,10 +372,14 @@ function routeCursorHook(params) {
|
|
|
359
372
|
if (!canonicalCwd) {
|
|
360
373
|
return { decision: "fail_closed", message: "belay could not determine the workspace." };
|
|
361
374
|
}
|
|
362
|
-
const
|
|
375
|
+
const discoveredRepoRoot = findCursorRoutingRepoRoot(canonicalCwd);
|
|
376
|
+
const repoRoot = canonicalExistingPath(discoveredRepoRoot);
|
|
363
377
|
if (!repoRoot) {
|
|
364
378
|
return { decision: "neutral" };
|
|
365
379
|
}
|
|
380
|
+
if (repoRoot === canonicalCwd && !hasRoutingRootMarker(repoRoot)) {
|
|
381
|
+
return { decision: "neutral" };
|
|
382
|
+
}
|
|
366
383
|
const installScope = readInstallScope(repoRoot);
|
|
367
384
|
if (installScope === "missing") {
|
|
368
385
|
return { decision: "neutral" };
|
|
@@ -377,7 +394,7 @@ function routeCursorHook(params) {
|
|
|
377
394
|
if (params.origin.scope === "global") {
|
|
378
395
|
return callableProjectOwner ? { decision: "neutral" } : {
|
|
379
396
|
decision: "fail_closed",
|
|
380
|
-
message:
|
|
397
|
+
message: `${CURSOR_GLOBAL_SENTINEL_BLOCK_MESSAGE} Run belay doctor from this repository to diagnose hook routing.`
|
|
381
398
|
};
|
|
382
399
|
}
|
|
383
400
|
const complete = callableProjectOwner && isRegularFile(path4.join(cursorRoutingRuntimeDir(repoRoot), "core.mjs"));
|