@zgeoff/skill-gate 0.2.9 → 0.2.12

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 (52) hide show
  1. package/README.md +25 -89
  2. package/dist/index.d.ts +3 -2
  3. package/dist/index.js +4 -13133
  4. package/package.json +7 -13
  5. package/dist/bash-snapshot-schema.d.ts +0 -9
  6. package/dist/build-bash-change-output.d.ts +0 -6
  7. package/dist/build-bash-check-failure-output.d.ts +0 -2
  8. package/dist/build-bash-skill-gate-output.d.ts +0 -6
  9. package/dist/build-edit-output.d.ts +0 -3
  10. package/dist/build-patch-gate-output.d.ts +0 -2
  11. package/dist/build-skill-gate-output.d.ts +0 -2
  12. package/dist/build-tool-gate-output.d.ts +0 -2
  13. package/dist/classify-command-reads.d.ts +0 -5
  14. package/dist/collect-bash-candidates.d.ts +0 -2
  15. package/dist/collect-changed-paths.d.ts +0 -2
  16. package/dist/collect-command-reads.d.ts +0 -1
  17. package/dist/collect-gate-skills.d.ts +0 -2
  18. package/dist/collect-prompt-skills.d.ts +0 -1
  19. package/dist/collect-rule-warnings.d.ts +0 -2
  20. package/dist/collect-session-loads.d.ts +0 -2
  21. package/dist/collect-written-paths.d.ts +0 -2
  22. package/dist/format-skill-list.d.ts +0 -1
  23. package/dist/format-unknown-key-warning.d.ts +0 -1
  24. package/dist/harness.d.ts +0 -1
  25. package/dist/load-ledger.d.ts +0 -6
  26. package/dist/parse-hook-input.d.ts +0 -3
  27. package/dist/parse-patch-paths.d.ts +0 -1
  28. package/dist/parse-shell-commands.d.ts +0 -4
  29. package/dist/parse-skill-gate-rules.d.ts +0 -2
  30. package/dist/pick-commit-range.d.ts +0 -2
  31. package/dist/pick-comparison-step.d.ts +0 -2
  32. package/dist/pick-harness-wording.d.ts +0 -3
  33. package/dist/pick-record-step.d.ts +0 -2
  34. package/dist/plan-bash-skill-gate.d.ts +0 -2
  35. package/dist/plan-skill-gate.d.ts +0 -2
  36. package/dist/plan-tool-gate.d.ts +0 -2
  37. package/dist/read-available-references.d.ts +0 -2
  38. package/dist/read-available-skills.d.ts +0 -1
  39. package/dist/read-commit-hashes.d.ts +0 -3
  40. package/dist/read-committed-paths.d.ts +0 -2
  41. package/dist/read-file-content.d.ts +0 -1
  42. package/dist/read-file-hashes.d.ts +0 -2
  43. package/dist/read-project-dir.d.ts +0 -1
  44. package/dist/read-session-loads.d.ts +0 -2
  45. package/dist/read-session-transcript.d.ts +0 -2
  46. package/dist/read-work-tree.d.ts +0 -3
  47. package/dist/record-codex-loads.d.ts +0 -3
  48. package/dist/resolve-state-dir.d.ts +0 -3
  49. package/dist/run-skill-gate.d.ts +0 -2
  50. package/dist/to-content-hash.d.ts +0 -1
  51. package/dist/types.d.ts +0 -209
  52. package/dist/with-ledger-lock.d.ts +0 -1
package/README.md CHANGED
@@ -1,100 +1,36 @@
1
- # @zgeoff/skill-gate
1
+ <div align="center">
2
+ <h1>@zgeoff/skill-gate</h1>
2
3
 
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.
4
+ <p>
5
+ <a href="https://www.npmjs.com/package/@zgeoff/skill-gate"><img src="https://img.shields.io/npm/v/@zgeoff/skill-gate" alt="npm version"></a>
6
+ <a href="./LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT license"></a>
7
+ </p>
10
8
 
11
- ## Install
12
-
13
- ```sh
14
- bun add -d @zgeoff/skill-gate
15
- ```
9
+ <p>
10
+ <a href="../../docs/README.md">Documentation</a> •
11
+ <a href="../agent-hooks/README.md">@zgeoff/agent-hooks</a>
12
+ </p>
13
+ </div>
16
14
 
17
- Install it at the repo root, so that Bun resolves it from `.claude/hooks/`. The package runs on Bun.
15
+ A package that forwards to `@zgeoff/agent-hooks`, which holds the skill gate.
18
16
 
19
- ## Entry point
17
+ `runSkillGate` runs the hooks of [`@zgeoff/agent-hooks`](../agent-hooks/README.md), whose first
18
+ handler is the skill gate, so an entry point that calls it keeps working. A gate denial exits 2 with
19
+ the reason on stderr, which Claude Code and Codex both take as a block.
20
20
 
21
- The hook runs a file in the repo that calls the package's `runSkillGate`, at
22
- `.claude/hooks/skill-gate/skill-gate.ts`. The `hook-skill-gate` entry of repo-sync delivers this
23
- file from zgeoff/tools. `runSkillGate` reads the hook payload from stdin, prints the hook output,
24
- and exits the process.
25
-
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`:
31
-
32
- ```json
33
- {
34
- "hooks": {
35
- "PreToolUse": [
36
- {
37
- "matcher": "Edit|Write|MultiEdit|Bash|mcp__tracker__update_ticket",
38
- "hooks": [
39
- {
40
- "type": "command",
41
- "command": "bun --no-install \"$CLAUDE_PROJECT_DIR/.claude/hooks/skill-gate/skill-gate.ts\""
42
- }
43
- ]
44
- }
45
- ],
46
- "PostToolUse": [
47
- {
48
- "matcher": "Bash",
49
- "hooks": [
50
- {
51
- "type": "command",
52
- "command": "bun --no-install \"$CLAUDE_PROJECT_DIR/.claude/hooks/skill-gate/skill-gate.ts\""
53
- }
54
- ]
55
- }
56
- ],
57
- "PostToolUseFailure": [
58
- {
59
- "matcher": "Bash",
60
- "hooks": [
61
- {
62
- "type": "command",
63
- "command": "bun --no-install \"$CLAUDE_PROJECT_DIR/.claude/hooks/skill-gate/skill-gate.ts\""
64
- }
65
- ]
66
- }
67
- ]
68
- }
69
- }
70
- ```
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
-
80
- ## Rules
21
+ ## Install
81
22
 
82
- `.claude/skill-gate.json` maps path globs to the skills each path needs, and the optional `tools`
83
- list gates a tool call by name.
23
+ Install `@zgeoff/agent-hooks` instead, and run its start-up stub, as its README describes. First
24
+ take the `hook-start` entry of repo-sync and merge its pull request, so that the repo holds the stub
25
+ at `.claude/hooks/start.ts`. `agent-hooks init` refuses to run without the stub, and it replaces the
26
+ skill gate's older hook entries. Then run these commands at the repo root:
84
27
 
85
- ```json
86
- {
87
- "ignore": ["node_modules/", "dist/"],
88
- "gates": [{ "match": "**/*.md", "skills": ["docs-writing"] }],
89
- "tools": [{ "tool": "mcp__tracker__update_ticket", "skills": ["ticket-review"] }]
90
- }
28
+ ```sh
29
+ bun remove @zgeoff/skill-gate
30
+ bun add -d @zgeoff/agent-hooks
31
+ bunx agent-hooks init
91
32
  ```
92
33
 
93
- [Writing skill-gate rules](../../docs/guides/skill-gate-rules.md) covers each key, the glob shapes
94
- to avoid, and how the gate treats a mistake in the rules file.
95
-
96
34
  ## Documentation
97
35
 
98
- [The skill gate architecture](../../docs/architecture/skill-gate.md) describes how the entry point
99
- fails closed, which skill loads and reference reads the gate counts, and how it checks what a Bash
100
- command changed.
36
+ [The skill gate architecture](../../docs/architecture/skill-gate.md) describes what the gate denies.
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export { runSkillGate } from './run-skill-gate.ts';
2
- export type { Harness } from './harness.ts';
1
+ import type { Harness } from '@zgeoff/agent-hooks';
2
+ export type { Harness } from '@zgeoff/agent-hooks';
3
+ export declare function runSkillGate(harness?: Harness): Promise<never>;