@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.
@@ -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
- return isTrustedCursorRoutingConfig(repoRoot, parsed) ? "global" : "project";
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 repoRoot = canonicalExistingPath(findCursorRoutingRepoRoot(canonicalCwd));
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: "belay project hook owner is unavailable; the global sentinel blocked this action."
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"));