@zgeoff/skill-gate 0.2.7 → 0.2.9

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/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # @zgeoff/skill-gate
2
2
 
3
- The skill gate is a Claude Code hook that denies an edit until the session has loaded every skill
4
- the path needs, and names the missing skills. It denies a call to a gated tool, such as an MCP tool,
5
- the same way until the session has loaded the skills and read the reference files the tool needs.
6
- After a Bash command, it compares `git status` with the status before the command, and it blocks
7
- when the command changed a gated file that the session lacks the skills for. The package holds no
8
- rules: each repo keeps its own in `.claude/skill-gate.json`, and a repo without that file has no
9
- gate.
3
+ The skill gate is a Claude Code and Codex CLI hook that denies an edit until the session has loaded
4
+ every skill the path needs, and names the missing skills. It denies a call to a gated tool, such as
5
+ an MCP tool, the same way until the session has loaded the skills and read the reference files the
6
+ tool needs. After a Bash command, it compares `git status` with the status before the command, and
7
+ it blocks when the command changed a gated file that the session lacks the skills for. The package
8
+ holds no rules: each repo keeps its own in `.claude/skill-gate.json`, and a repo without that file
9
+ has no gate.
10
10
 
11
11
  ## Install
12
12
 
@@ -23,9 +23,11 @@ The hook runs a file in the repo that calls the package's `runSkillGate`, at
23
23
  file from zgeoff/tools. `runSkillGate` reads the hook payload from stdin, prints the hook output,
24
24
  and exits the process.
25
25
 
26
- Register the entry point in `.claude/settings.json`, before a Bash command and after it. The
27
- `PreToolUse` matcher names each tool that a tool gate names, since the hook never sees a call that
28
- the matcher skips. This example gates `mcp__tracker__update_ticket`:
26
+ Register the entry point in `.claude/settings.json`, before a Bash command and after it. The command
27
+ runs Bun with `--no-install`, so the hook never fetches the package from npm: in a checkout with no
28
+ `node_modules`, the hook blocks each gated edit until `bun install` runs. The `PreToolUse` matcher
29
+ names each tool that a tool gate names, since the hook never sees a call that the matcher skips.
30
+ This example gates `mcp__tracker__update_ticket`:
29
31
 
30
32
  ```json
31
33
  {
@@ -36,7 +38,7 @@ the matcher skips. This example gates `mcp__tracker__update_ticket`:
36
38
  "hooks": [
37
39
  {
38
40
  "type": "command",
39
- "command": "bun \"$CLAUDE_PROJECT_DIR/.claude/hooks/skill-gate/skill-gate.ts\""
41
+ "command": "bun --no-install \"$CLAUDE_PROJECT_DIR/.claude/hooks/skill-gate/skill-gate.ts\""
40
42
  }
41
43
  ]
42
44
  }
@@ -47,7 +49,7 @@ the matcher skips. This example gates `mcp__tracker__update_ticket`:
47
49
  "hooks": [
48
50
  {
49
51
  "type": "command",
50
- "command": "bun \"$CLAUDE_PROJECT_DIR/.claude/hooks/skill-gate/skill-gate.ts\""
52
+ "command": "bun --no-install \"$CLAUDE_PROJECT_DIR/.claude/hooks/skill-gate/skill-gate.ts\""
51
53
  }
52
54
  ]
53
55
  }
@@ -58,7 +60,7 @@ the matcher skips. This example gates `mcp__tracker__update_ticket`:
58
60
  "hooks": [
59
61
  {
60
62
  "type": "command",
61
- "command": "bun \"$CLAUDE_PROJECT_DIR/.claude/hooks/skill-gate/skill-gate.ts\""
63
+ "command": "bun --no-install \"$CLAUDE_PROJECT_DIR/.claude/hooks/skill-gate/skill-gate.ts\""
62
64
  }
63
65
  ]
64
66
  }
@@ -67,6 +69,14 @@ the matcher skips. This example gates `mcp__tracker__update_ticket`:
67
69
  }
68
70
  ```
69
71
 
72
+ ## Codex
73
+
74
+ The same entry point runs as a Codex hook when its command passes `--harness codex`, and it gates
75
+ `apply_patch` edits, gated tools and Bash commands as it does under Claude Code. Codex has no Skill
76
+ tool, so the gate keeps a ledger of what each session loaded.
77
+ [Gating Codex edits](../../docs/guides/skill-gate-codex.md) holds the `.codex/hooks.json` example,
78
+ the trust step and the ledger rules.
79
+
70
80
  ## Rules
71
81
 
72
82
  `.claude/skill-gate.json` maps path globs to the skills each path needs, and the optional `tools`
@@ -1,4 +1,6 @@
1
+ import type { Harness } from './harness.ts';
1
2
  import type { BashChangeHookOutput, PostToolEvent } from './types.ts';
2
3
  export declare function buildBashChangeOutput(event: PostToolEvent, changedPaths: readonly string[], missing: readonly string[], context?: {
3
4
  readonly compacted?: boolean;
5
+ readonly harness?: Harness;
4
6
  }): BashChangeHookOutput | null;
@@ -1,4 +1,6 @@
1
+ import type { Harness } from './harness.ts';
1
2
  import type { SkillGateHookOutput } from './types.ts';
2
3
  export declare function buildBashSkillGateOutput(gatedPaths: readonly string[], missing: readonly string[], context?: {
3
4
  readonly compacted?: boolean;
5
+ readonly harness?: Harness;
4
6
  }): SkillGateHookOutput | null;
@@ -0,0 +1,3 @@
1
+ import type { Harness } from './harness.ts';
2
+ import type { EditEntry, SkillGateHookOutput, SkillGateOutputContext } from './types.ts';
3
+ export declare function buildEditOutput(harness: Harness, entries: readonly EditEntry[], context: SkillGateOutputContext): SkillGateHookOutput | null;
@@ -0,0 +1,2 @@
1
+ import type { EditEntry, SkillGateHookOutput, SkillGateOutputContext } from './types.ts';
2
+ export declare function buildPatchGateOutput(entries: readonly EditEntry[], context?: SkillGateOutputContext): SkillGateHookOutput | null;
@@ -0,0 +1,5 @@
1
+ export interface ClassifiedReads {
2
+ readonly skills: readonly string[];
3
+ readonly readPaths: readonly string[];
4
+ }
5
+ export declare function classifyCommandReads(readFiles: readonly string[], projectDir: string, references: readonly string[]): ClassifiedReads;
@@ -0,0 +1 @@
1
+ export declare function collectCommandReads(command: string, cwd: string): readonly string[];
@@ -0,0 +1 @@
1
+ export declare function collectPromptSkills(prompt: string): readonly string[];
@@ -0,0 +1,2 @@
1
+ import type { SkillGateOutputContext, UnknownSkill } from './types.ts';
2
+ export declare function collectRuleWarnings(unknown: readonly UnknownSkill[], context: SkillGateOutputContext): readonly string[];
@@ -0,0 +1 @@
1
+ export type Harness = 'claude-code' | 'codex';
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export { runSkillGate } from './run-skill-gate.ts';
2
+ export type { Harness } from './harness.ts';