@guilz-dev/belay 0.9.3 → 0.9.4

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.
Files changed (83) hide show
  1. package/README.md +35 -1
  2. package/dist/adapters/codex/hooks.d.ts +1 -0
  3. package/dist/adapters/codex/hooks.js +3 -0
  4. package/dist/adapters/cursor/dispatcher-generation.d.ts +3 -0
  5. package/dist/adapters/cursor/dispatcher-generation.js +5 -0
  6. package/dist/adapters/cursor/hook-dispatch-entry.d.ts +7 -0
  7. package/dist/adapters/cursor/hook-dispatch-entry.js +126 -0
  8. package/dist/adapters/cursor/hook-router.d.ts +23 -0
  9. package/dist/adapters/cursor/hook-router.js +266 -0
  10. package/dist/adapters/cursor/hooks.d.ts +4 -0
  11. package/dist/adapters/cursor/hooks.js +99 -8
  12. package/dist/adapters/cursor/routing-layout.d.ts +5 -0
  13. package/dist/adapters/cursor/routing-layout.js +29 -0
  14. package/dist/adapters/cursor/runtime-entry.d.ts +17 -0
  15. package/dist/adapters/cursor/runtime-entry.js +39 -39
  16. package/dist/adapters/layouts/scope.d.ts +5 -0
  17. package/dist/adapters/layouts/scope.js +71 -0
  18. package/dist/adapters/shared/gate-runtime.js +1 -0
  19. package/dist/bundle/claude-runtime.mjs +1932 -1740
  20. package/dist/bundle/codex-runtime.mjs +1934 -1742
  21. package/dist/bundle/cursor-dispatcher.mjs +443 -0
  22. package/dist/bundle/cursor-runtime.mjs +2017 -1821
  23. package/dist/commands/doctor.js +191 -15
  24. package/dist/commands/health-snapshot.js +9 -4
  25. package/dist/commands/recovery-checkpoints.d.ts +3 -3
  26. package/dist/config-io.js +11 -2
  27. package/dist/core/audit-legacy-archive.js +43 -25
  28. package/dist/core/classify-tool.js +16 -8
  29. package/dist/core/effect-ir/argv-delegate.d.ts +9 -0
  30. package/dist/core/effect-ir/argv-delegate.js +42 -0
  31. package/dist/core/effect-ir/shell-lower/argv-delegate-gate.d.ts +3 -0
  32. package/dist/core/effect-ir/shell-lower/argv-delegate-gate.js +40 -0
  33. package/dist/core/effect-ir/shell-lower/augment.d.ts +4 -0
  34. package/dist/core/effect-ir/shell-lower/augment.js +97 -0
  35. package/dist/core/effect-ir/shell-lower/context.d.ts +10 -0
  36. package/dist/core/effect-ir/shell-lower/context.js +1 -0
  37. package/dist/core/effect-ir/shell-lower/decode-process.d.ts +9 -0
  38. package/dist/core/effect-ir/shell-lower/decode-process.js +201 -0
  39. package/dist/core/effect-ir/shell-lower/decoders/belay.d.ts +2 -0
  40. package/dist/core/effect-ir/shell-lower/decoders/belay.js +29 -0
  41. package/dist/core/effect-ir/shell-lower/decoders/builtins.d.ts +7 -0
  42. package/dist/core/effect-ir/shell-lower/decoders/builtins.js +194 -0
  43. package/dist/core/effect-ir/shell-lower/decoders/decode-package-exec.d.ts +4 -0
  44. package/dist/core/effect-ir/shell-lower/decoders/decode-package-exec.js +68 -0
  45. package/dist/core/effect-ir/shell-lower/decoders/docker.d.ts +3 -0
  46. package/dist/core/effect-ir/shell-lower/decoders/docker.js +43 -0
  47. package/dist/core/effect-ir/shell-lower/decoders/filesystem.d.ts +9 -0
  48. package/dist/core/effect-ir/shell-lower/decoders/filesystem.js +217 -0
  49. package/dist/core/effect-ir/shell-lower/decoders/prisma.d.ts +2 -0
  50. package/dist/core/effect-ir/shell-lower/decoders/prisma.js +54 -0
  51. package/dist/core/effect-ir/shell-lower/decoders/ruby.d.ts +11 -0
  52. package/dist/core/effect-ir/shell-lower/decoders/ruby.js +147 -0
  53. package/dist/core/effect-ir/shell-lower/decoders/toolchain.d.ts +7 -0
  54. package/dist/core/effect-ir/shell-lower/decoders/toolchain.js +155 -0
  55. package/dist/core/effect-ir/shell-lower/requirement.d.ts +12 -0
  56. package/dist/core/effect-ir/shell-lower/requirement.js +65 -0
  57. package/dist/core/effect-ir/shell-lower/segment.d.ts +11 -0
  58. package/dist/core/effect-ir/shell-lower/segment.js +82 -0
  59. package/dist/core/effect-ir/shell-lower/tokens.d.ts +26 -0
  60. package/dist/core/effect-ir/shell-lower/tokens.js +183 -0
  61. package/dist/core/effect-ir/shell-lower.d.ts +2 -7
  62. package/dist/core/effect-ir/shell-lower.js +60 -1502
  63. package/dist/core/glob.js +32 -16
  64. package/dist/core/integrity.d.ts +2 -2
  65. package/dist/core/integrity.js +52 -12
  66. package/dist/core/replay-scrub.d.ts +2 -0
  67. package/dist/core/replay-scrub.js +8 -0
  68. package/dist/core/shell-substitution.js +2 -2
  69. package/dist/core/shell-unparseable.js +3 -1
  70. package/dist/defaults.d.ts +7 -3
  71. package/dist/defaults.js +29 -22
  72. package/dist/installer/bootstrap.d.ts +1 -0
  73. package/dist/installer/bootstrap.js +2 -2
  74. package/dist/installer/runtime-artifacts.js +43 -13
  75. package/dist/installer.js +44 -9
  76. package/dist/node-resolution.d.ts +1 -0
  77. package/dist/node-resolution.js +61 -0
  78. package/dist/templates.d.ts +7 -4
  79. package/dist/templates.js +42 -4
  80. package/dist/types.d.ts +1 -0
  81. package/dist/version.d.ts +1 -1
  82. package/dist/version.js +1 -1
  83. package/package.json +1 -1
@@ -1,7 +1,10 @@
1
+ import type { CursorHookOrigin } from './adapters/cursor/hook-router.js';
2
+ import type { AdapterName } from './adapters/layouts/types.js';
1
3
  import type { BelayConfigV3 } from './core/config.js';
2
4
  export declare function renderConfig(config: BelayConfigV3): string;
3
- export declare function renderBeforeSubmitHook(): string;
4
- export declare function renderShellGateHook(): string;
5
- export declare function renderToolGateHook(): string;
6
- export declare function renderAuditHook(): string;
5
+ export declare function renderBeforeSubmitHook(adapter: AdapterName, cursorOrigin?: CursorHookOrigin): string;
6
+ export declare function renderShellGateHook(adapter: AdapterName, cursorOrigin?: CursorHookOrigin): string;
7
+ export declare function renderToolGateHook(adapter: AdapterName, cursorOrigin?: CursorHookOrigin): string;
8
+ export declare function renderAuditHook(adapter: AdapterName, cursorOrigin?: CursorHookOrigin): string;
9
+ export declare function renderCursorDispatcher(): Promise<string>;
7
10
  export declare function renderRuntimeCore(adapter?: 'cursor' | 'claude' | 'codex'): Promise<string>;
package/dist/templates.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { fileURLToPath } from 'node:url';
4
+ import { CURSOR_DISPATCHER_GENERATION_HEADER } from './adapters/cursor/dispatcher-generation.js';
4
5
  import { hashValue } from './core/fingerprint.js';
5
6
  import { PACKAGE_VERSION } from './version.js';
6
7
  function inlineJson(value) {
@@ -9,26 +10,54 @@ function inlineJson(value) {
9
10
  export function renderConfig(config) {
10
11
  return `${inlineJson(config)}\n`;
11
12
  }
12
- export function renderBeforeSubmitHook() {
13
+ function requireCursorOrigin(origin) {
14
+ if (!origin) {
15
+ throw new Error('Cursor hook origin is required when rendering dispatcher shims.');
16
+ }
17
+ return origin;
18
+ }
19
+ function renderCursorDispatchHook(origin, kind, eventName) {
20
+ return `import { dispatchCursorHook } from '../belay/runtime/dispatcher.mjs'
21
+
22
+ await dispatchCursorHook({
23
+ origin: ${JSON.stringify(origin)},
24
+ kind: ${JSON.stringify(kind)},
25
+ eventName: ${eventName},
26
+ })
27
+ `;
28
+ }
29
+ export function renderBeforeSubmitHook(adapter, cursorOrigin) {
30
+ if (adapter === 'cursor') {
31
+ return renderCursorDispatchHook(requireCursorOrigin(cursorOrigin), 'before-submit', JSON.stringify('beforeSubmitPrompt'));
32
+ }
13
33
  return `import { runBeforeSubmitPromptHook } from '../belay/runtime/core.mjs'
14
34
 
15
35
  await runBeforeSubmitPromptHook()
16
36
  `;
17
37
  }
18
- export function renderShellGateHook() {
38
+ export function renderShellGateHook(adapter, cursorOrigin) {
39
+ if (adapter === 'cursor') {
40
+ return renderCursorDispatchHook(requireCursorOrigin(cursorOrigin), 'shell-gate', JSON.stringify('beforeShellExecution'));
41
+ }
19
42
  return `import { runShellGateHook } from '../belay/runtime/core.mjs'
20
43
 
21
44
  await runShellGateHook()
22
45
  `;
23
46
  }
24
- export function renderToolGateHook() {
47
+ export function renderToolGateHook(adapter, cursorOrigin) {
48
+ if (adapter === 'cursor') {
49
+ return renderCursorDispatchHook(requireCursorOrigin(cursorOrigin), 'tool-gate', "process.argv[2] ?? 'preToolUse'");
50
+ }
25
51
  return `import { runToolGateHook } from '../belay/runtime/core.mjs'
26
52
 
27
53
  const eventName = process.argv[2] ?? 'preToolUse'
28
54
  await runToolGateHook(eventName)
29
55
  `;
30
56
  }
31
- export function renderAuditHook() {
57
+ export function renderAuditHook(adapter, cursorOrigin) {
58
+ if (adapter === 'cursor') {
59
+ return renderCursorDispatchHook(requireCursorOrigin(cursorOrigin), 'audit', "process.argv[2] ?? 'postToolUse'");
60
+ }
32
61
  return `import { runAuditHook } from '../belay/runtime/core.mjs'
33
62
 
34
63
  const eventName = process.argv[2] ?? 'postToolUse'
@@ -44,6 +73,15 @@ async function readRuntimeBundle(adapter = 'cursor') {
44
73
  throw new Error('Runtime bundle missing. Run pnpm build before belay init or upgrade.');
45
74
  }
46
75
  }
76
+ export async function renderCursorDispatcher() {
77
+ const bundlePath = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', 'dist', 'bundle', 'cursor-dispatcher.mjs');
78
+ try {
79
+ return `${CURSOR_DISPATCHER_GENERATION_HEADER}${await readFile(bundlePath, 'utf8')}`;
80
+ }
81
+ catch {
82
+ throw new Error('Runtime bundle missing. Run pnpm build before belay init or upgrade.');
83
+ }
84
+ }
47
85
  export async function renderRuntimeCore(adapter = 'cursor') {
48
86
  const bundle = await readRuntimeBundle(adapter);
49
87
  const withoutStamp = bundle
package/dist/types.d.ts CHANGED
@@ -7,6 +7,7 @@ import type { ApprovalRecord, ClassifyResult } from './core/types.js';
7
7
  export interface HookEntry {
8
8
  command: string;
9
9
  matcher?: string;
10
+ failClosed?: boolean;
10
11
  }
11
12
  export interface HooksFile {
12
13
  version: number;
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const PACKAGE_VERSION = "0.9.3";
1
+ export declare const PACKAGE_VERSION = "0.9.4";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by scripts/sync-version.mjs — do not edit.
2
- export const PACKAGE_VERSION = '0.9.3';
2
+ export const PACKAGE_VERSION = '0.9.4';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guilz-dev/belay",
3
- "version": "0.9.3",
3
+ "version": "0.9.4",
4
4
  "description": "Belay-style approval and audit gating for agent runtimes.",
5
5
  "type": "module",
6
6
  "license": "MIT",