@brainervirus/workit-core 8.12.2 → 8.13.0

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.
@@ -63,7 +63,9 @@ export const CURSOR_DESCRIPTOR: HostDescriptor = {
63
63
  // `loop_limit: 1`, so the continuation's own stop never runs the hook.
64
64
  stop: { support: "native", native: "stop" },
65
65
  },
66
- shellPolicy: { deny: "native", channel: "exit2+json", failClosed: true },
66
+ // Fails open like every host: a payload Workit cannot parse (a renamed
67
+ // field in a Cursor release) must not block every shell command.
68
+ shellPolicy: { deny: "native", channel: "exit2+json", failClosed: false },
67
69
  context: {
68
70
  sessionStart: "native",
69
71
  perTurn: "none",
@@ -1,19 +1,28 @@
1
1
  import { shellBranchPolicyViolation } from "../core/route-intent";
2
2
  import type { HookDecision } from "./protocol";
3
- import type { ShellDialect } from "./shell-words";
3
+ import { analysisDenial } from "./raw-git";
4
+ import { ShellAnalysisError, type ShellDialect } from "./shell-words";
4
5
 
5
6
  /**
6
7
  * Branch policy for one shell command: a raw branch creation (`git switch -c`,
7
8
  * `checkout -b`, `branch`, `worktree add -b`, in any chain, directory or
8
9
  * wrapper) onto a noncompliant name is denied. Every other command keeps the
9
10
  * host's own permission decision. The reason carries the policy's correction.
11
+ * A command the hook cannot analyze is denied with how to split it; any other
12
+ * failure propagates to the host's fail policy.
10
13
  */
11
14
  export const shellPolicy = (
12
15
  cwd: string,
13
16
  command: string,
14
17
  dialect: ShellDialect = "posix",
15
18
  ): HookDecision => {
16
- const policy = shellBranchPolicyViolation(cwd, command, dialect);
19
+ let policy: ReturnType<typeof shellBranchPolicyViolation>;
20
+ try {
21
+ policy = shellBranchPolicyViolation(cwd, command, dialect);
22
+ } catch (error) {
23
+ if (error instanceof ShellAnalysisError) return analysisDenial(error);
24
+ throw error;
25
+ }
17
26
  return policy && !policy.ok
18
27
  ? { kind: "deny", reason: `branch_policy_denied: ${policy.error}`, unblock: null }
19
28
  : { kind: "none" };