@zgeoff/skill-gate 0.2.2 → 0.2.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.
@@ -0,0 +1,2 @@
1
+ import type { CommitRange } from './types.ts';
2
+ export declare function pickCommitRange(before: string | null, after: string | null): CommitRange | null;
@@ -0,0 +1,2 @@
1
+ import type { BashComparison, BashResultStep } from './types.ts';
2
+ export declare function pickComparisonStep(comparison: BashComparison): BashResultStep;
@@ -0,0 +1,2 @@
1
+ import type { BashSnapshot, RecordStep } from './types.ts';
2
+ export declare function pickRecordStep(record: BashSnapshot | null): RecordStep;
@@ -0,0 +1,3 @@
1
+ import type { SimpleGit } from 'simple-git';
2
+ import type { FileHashes } from './types.ts';
3
+ export declare function readCommitHashes(git: SimpleGit, commit: string | null, relativePaths: readonly string[]): Promise<FileHashes>;
@@ -0,0 +1,2 @@
1
+ import type { SimpleGit } from 'simple-git';
2
+ export declare function readCommittedPaths(git: SimpleGit, directory: string, from: string | null, to: string): Promise<readonly string[]>;
@@ -0,0 +1 @@
1
+ export declare function readFileContent(filePath: string): Promise<Uint8Array | null>;
@@ -0,0 +1,2 @@
1
+ import type { FileHashes, ReadFileContent } from './types.ts';
2
+ export declare function readFileHashes(readContent: ReadFileContent, projectDir: string, relativePaths: readonly string[]): Promise<FileHashes>;
@@ -0,0 +1,3 @@
1
+ import type { SimpleGit } from 'simple-git';
2
+ import type { WorkTree } from './types.ts';
3
+ export declare function readWorkTree(git: SimpleGit, directory: string): Promise<WorkTree | null>;
@@ -0,0 +1 @@
1
+ export declare function toContentHash(bytes: Uint8Array): string;
package/dist/types.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import type { z } from 'zod';
2
+ import type { bashSnapshotSchema } from './bash-snapshot-schema.ts';
1
3
  export interface SkillGate {
2
4
  readonly match: string;
3
5
  readonly skills: readonly string[];
@@ -77,3 +79,63 @@ export interface SkillGateHookOutput {
77
79
  readonly additionalContext?: string;
78
80
  };
79
81
  }
82
+ export type FileHashes = Readonly<Record<string, string | null>>;
83
+ export type PostToolEvent = 'PostToolUse' | 'PostToolUseFailure';
84
+ export type HookEvent = 'PreToolUse' | PostToolEvent;
85
+ export type BashChangeHookOutput = {
86
+ readonly decision: 'block';
87
+ readonly reason: string;
88
+ } | {
89
+ readonly hookSpecificOutput: {
90
+ readonly hookEventName: 'PostToolUseFailure';
91
+ readonly additionalContext: string;
92
+ };
93
+ };
94
+ export interface WorkTree {
95
+ readonly head: string | null;
96
+ readonly dirtyPaths: readonly string[];
97
+ }
98
+ export type BashSnapshot = Readonly<z.infer<typeof bashSnapshotSchema>>;
99
+ export interface BashCheckFailureHookOutput {
100
+ readonly systemMessage: string;
101
+ readonly hookSpecificOutput: {
102
+ readonly hookEventName: PostToolEvent;
103
+ readonly additionalContext: string;
104
+ };
105
+ }
106
+ export interface CommitRange {
107
+ readonly from: string | null;
108
+ readonly to: string;
109
+ }
110
+ export interface BashCandidates {
111
+ readonly hashedPaths: readonly string[];
112
+ readonly cleanBefore: readonly string[];
113
+ }
114
+ export type ReadFileContent = (filePath: string) => Promise<Uint8Array | null>;
115
+ export type RecordedSnapshot = Extract<BashSnapshot, {
116
+ kind: 'recorded';
117
+ }>;
118
+ export type BashComparison = {
119
+ readonly kind: 'no-work-tree';
120
+ } | {
121
+ readonly kind: 'git-failed';
122
+ readonly error: string;
123
+ } | {
124
+ readonly kind: 'compared';
125
+ readonly changedPaths: readonly string[];
126
+ };
127
+ export type BashResultStep = {
128
+ readonly kind: 'skip';
129
+ } | {
130
+ readonly kind: 'report';
131
+ readonly error: string;
132
+ } | {
133
+ readonly kind: 'gate';
134
+ readonly changedPaths: readonly string[];
135
+ };
136
+ export type RecordStep = Exclude<BashResultStep, {
137
+ kind: 'gate';
138
+ }> | {
139
+ readonly kind: 'compare';
140
+ readonly recorded: RecordedSnapshot;
141
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zgeoff/skill-gate",
3
- "version": "0.2.2",
4
- "description": "A Claude Code PreToolUse hook that denies an edit until the session loads the skills the path needs, and warns on a Bash command that writes a gated path",
3
+ "version": "0.2.4",
4
+ "description": "A Claude Code hook that denies an edit until the session loads the skills the path needs, and blocks after a Bash command that changed a gated file without them",
5
5
  "keywords": [
6
6
  "claude-code",
7
7
  "hook",
@@ -30,14 +30,19 @@
30
30
  "build": "rm -rf dist && bun run build:outdir dist",
31
31
  "build:outdir": "sh -c 'bun build src/index.ts --target bun --outdir \"$0\" && tsc -p tsconfig.build.json --outDir \"$0\"'",
32
32
  "prepare": "bun run build",
33
- "typecheck": "tsc"
33
+ "typecheck": "tsrs"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/bun": "1.4.2",
37
+ "@types/picomatch": "4.0.3",
37
38
  "@zgeoff/std": "0.3.0",
39
+ "picomatch": "4.0.7",
40
+ "simple-git": "4.0.2",
38
41
  "tiny-invariant": "1.3.3",
39
42
  "ts-pattern": "5.9.0",
40
- "typescript": "7.0.2"
43
+ "tsrs": "0.18.0-ts7.1.0-dev.20260929",
44
+ "typescript": "7.0.2",
45
+ "zod": "4.6.5"
41
46
  },
42
47
  "engines": {
43
48
  "bun": ">=1.3"