@zgeoff/skill-gate 0.2.3 → 0.2.5
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 +117 -25
- package/dist/bash-snapshot-schema.d.ts +9 -0
- package/dist/build-bash-change-output.d.ts +4 -0
- package/dist/build-bash-check-failure-output.d.ts +2 -0
- package/dist/build-tool-gate-output.d.ts +2 -0
- package/dist/collect-bash-candidates.d.ts +2 -0
- package/dist/collect-changed-paths.d.ts +2 -0
- package/dist/collect-session-loads.d.ts +2 -0
- package/dist/format-unknown-key-warning.d.ts +1 -0
- package/dist/index.js +11802 -298
- package/dist/pick-commit-range.d.ts +2 -0
- package/dist/pick-comparison-step.d.ts +2 -0
- package/dist/pick-record-step.d.ts +2 -0
- package/dist/plan-tool-gate.d.ts +2 -0
- package/dist/read-available-references.d.ts +2 -0
- package/dist/read-commit-hashes.d.ts +3 -0
- package/dist/read-committed-paths.d.ts +2 -0
- package/dist/read-file-content.d.ts +1 -0
- package/dist/read-file-hashes.d.ts +2 -0
- package/dist/read-work-tree.d.ts +3 -0
- package/dist/to-content-hash.d.ts +1 -0
- package/dist/types.d.ts +90 -1
- package/package.json +9 -4
- package/dist/collect-loaded-skills.d.ts +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function readFileContent(filePath: string): Promise<Uint8Array | 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[];
|
|
@@ -6,9 +8,16 @@ export interface SkillGateRules {
|
|
|
6
8
|
readonly ignore: readonly string[];
|
|
7
9
|
readonly gates: readonly SkillGate[];
|
|
8
10
|
}
|
|
11
|
+
export interface ToolGate {
|
|
12
|
+
readonly tool: string;
|
|
13
|
+
readonly skills: readonly string[];
|
|
14
|
+
readonly references: readonly string[];
|
|
15
|
+
}
|
|
9
16
|
export type SkillGateRulesResult = {
|
|
10
17
|
readonly ok: true;
|
|
11
18
|
readonly rules: SkillGateRules;
|
|
19
|
+
readonly tools: readonly ToolGate[];
|
|
20
|
+
readonly unknownKeys: readonly string[];
|
|
12
21
|
} | {
|
|
13
22
|
readonly ok: false;
|
|
14
23
|
readonly error: string;
|
|
@@ -17,8 +26,9 @@ export interface UnknownSkill {
|
|
|
17
26
|
readonly match: string;
|
|
18
27
|
readonly skill: string;
|
|
19
28
|
}
|
|
20
|
-
export interface
|
|
29
|
+
export interface SessionLoads {
|
|
21
30
|
readonly skills: readonly string[];
|
|
31
|
+
readonly readPaths: readonly string[];
|
|
22
32
|
readonly compacted: boolean;
|
|
23
33
|
}
|
|
24
34
|
export interface SkillGateInput {
|
|
@@ -67,6 +77,25 @@ export interface WrittenPath {
|
|
|
67
77
|
export interface SkillGateOutputContext {
|
|
68
78
|
readonly compacted?: boolean;
|
|
69
79
|
readonly rulesError?: string;
|
|
80
|
+
readonly unknownKeys?: readonly string[];
|
|
81
|
+
}
|
|
82
|
+
export interface ToolGateInput {
|
|
83
|
+
readonly tools: readonly ToolGate[];
|
|
84
|
+
readonly toolName: string;
|
|
85
|
+
readonly skillsDir: string;
|
|
86
|
+
readonly loads: SessionLoads;
|
|
87
|
+
readonly availableSkills: readonly string[];
|
|
88
|
+
readonly availableReferences: readonly string[];
|
|
89
|
+
}
|
|
90
|
+
export interface UnknownToolRequirement {
|
|
91
|
+
readonly tool: string;
|
|
92
|
+
readonly kind: 'skill' | 'reference';
|
|
93
|
+
readonly name: string;
|
|
94
|
+
}
|
|
95
|
+
export interface ToolGatePlan {
|
|
96
|
+
readonly missingSkills: readonly string[];
|
|
97
|
+
readonly missingReferences: readonly string[];
|
|
98
|
+
readonly unknown: readonly UnknownToolRequirement[];
|
|
70
99
|
}
|
|
71
100
|
export interface SkillGateHookOutput {
|
|
72
101
|
readonly systemMessage?: string;
|
|
@@ -77,3 +106,63 @@ export interface SkillGateHookOutput {
|
|
|
77
106
|
readonly additionalContext?: string;
|
|
78
107
|
};
|
|
79
108
|
}
|
|
109
|
+
export type FileHashes = Readonly<Record<string, string | null>>;
|
|
110
|
+
export type PostToolEvent = 'PostToolUse' | 'PostToolUseFailure';
|
|
111
|
+
export type HookEvent = 'PreToolUse' | PostToolEvent;
|
|
112
|
+
export type BashChangeHookOutput = {
|
|
113
|
+
readonly decision: 'block';
|
|
114
|
+
readonly reason: string;
|
|
115
|
+
} | {
|
|
116
|
+
readonly hookSpecificOutput: {
|
|
117
|
+
readonly hookEventName: 'PostToolUseFailure';
|
|
118
|
+
readonly additionalContext: string;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
export interface WorkTree {
|
|
122
|
+
readonly head: string | null;
|
|
123
|
+
readonly dirtyPaths: readonly string[];
|
|
124
|
+
}
|
|
125
|
+
export type BashSnapshot = Readonly<z.infer<typeof bashSnapshotSchema>>;
|
|
126
|
+
export interface BashCheckFailureHookOutput {
|
|
127
|
+
readonly systemMessage: string;
|
|
128
|
+
readonly hookSpecificOutput: {
|
|
129
|
+
readonly hookEventName: PostToolEvent;
|
|
130
|
+
readonly additionalContext: string;
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
export interface CommitRange {
|
|
134
|
+
readonly from: string | null;
|
|
135
|
+
readonly to: string;
|
|
136
|
+
}
|
|
137
|
+
export interface BashCandidates {
|
|
138
|
+
readonly hashedPaths: readonly string[];
|
|
139
|
+
readonly cleanBefore: readonly string[];
|
|
140
|
+
}
|
|
141
|
+
export type ReadFileContent = (filePath: string) => Promise<Uint8Array | null>;
|
|
142
|
+
export type RecordedSnapshot = Extract<BashSnapshot, {
|
|
143
|
+
kind: 'recorded';
|
|
144
|
+
}>;
|
|
145
|
+
export type BashComparison = {
|
|
146
|
+
readonly kind: 'no-work-tree';
|
|
147
|
+
} | {
|
|
148
|
+
readonly kind: 'git-failed';
|
|
149
|
+
readonly error: string;
|
|
150
|
+
} | {
|
|
151
|
+
readonly kind: 'compared';
|
|
152
|
+
readonly changedPaths: readonly string[];
|
|
153
|
+
};
|
|
154
|
+
export type BashResultStep = {
|
|
155
|
+
readonly kind: 'skip';
|
|
156
|
+
} | {
|
|
157
|
+
readonly kind: 'report';
|
|
158
|
+
readonly error: string;
|
|
159
|
+
} | {
|
|
160
|
+
readonly kind: 'gate';
|
|
161
|
+
readonly changedPaths: readonly string[];
|
|
162
|
+
};
|
|
163
|
+
export type RecordStep = Exclude<BashResultStep, {
|
|
164
|
+
kind: 'gate';
|
|
165
|
+
}> | {
|
|
166
|
+
readonly kind: 'compare';
|
|
167
|
+
readonly recorded: RecordedSnapshot;
|
|
168
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zgeoff/skill-gate",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "A Claude Code
|
|
3
|
+
"version": "0.2.5",
|
|
4
|
+
"description": "A Claude Code hook that denies an edit or a gated tool call until the session loads the skills and reads the reference files it 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": "
|
|
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
|
-
"
|
|
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"
|