@mauribadnights/clooks 0.1.0 → 0.2.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.
- package/README.md +160 -70
- package/dist/cli.js +15 -1
- package/dist/constants.d.ts +8 -0
- package/dist/constants.js +10 -1
- package/dist/doctor.js +3 -1
- package/dist/filter.d.ts +11 -0
- package/dist/filter.js +42 -0
- package/dist/handlers.d.ts +3 -2
- package/dist/handlers.js +94 -35
- package/dist/index.d.ts +5 -2
- package/dist/index.js +15 -1
- package/dist/llm.d.ts +19 -0
- package/dist/llm.js +225 -0
- package/dist/manifest.js +29 -4
- package/dist/metrics.d.ts +21 -1
- package/dist/metrics.js +103 -0
- package/dist/prefetch.d.ts +11 -0
- package/dist/prefetch.js +71 -0
- package/dist/server.js +28 -2
- package/dist/types.d.ts +73 -16
- package/package.json +12 -2
package/dist/types.d.ts
CHANGED
|
@@ -14,34 +14,77 @@ export interface HookInput {
|
|
|
14
14
|
stop_hook_active?: boolean;
|
|
15
15
|
[key: string]: unknown;
|
|
16
16
|
}
|
|
17
|
-
/**
|
|
18
|
-
export type
|
|
19
|
-
/**
|
|
20
|
-
export
|
|
17
|
+
/** Supported LLM models */
|
|
18
|
+
export type LLMModel = 'claude-haiku-4-5' | 'claude-sonnet-4-6' | 'claude-opus-4-6';
|
|
19
|
+
/** Handler types — extended with 'llm' */
|
|
20
|
+
export type HandlerType = 'script' | 'inline' | 'llm';
|
|
21
|
+
/** LLM-specific handler config fields */
|
|
22
|
+
export interface LLMHandlerConfig {
|
|
21
23
|
id: string;
|
|
22
|
-
type:
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
type: 'llm';
|
|
25
|
+
model: LLMModel;
|
|
26
|
+
prompt: string;
|
|
27
|
+
batchGroup?: string;
|
|
28
|
+
maxTokens?: number;
|
|
29
|
+
temperature?: number;
|
|
30
|
+
filter?: string;
|
|
25
31
|
timeout?: number;
|
|
26
32
|
enabled?: boolean;
|
|
27
33
|
}
|
|
28
|
-
/**
|
|
34
|
+
/** Script handler config */
|
|
35
|
+
export interface ScriptHandlerConfig {
|
|
36
|
+
id: string;
|
|
37
|
+
type: 'script';
|
|
38
|
+
command: string;
|
|
39
|
+
filter?: string;
|
|
40
|
+
timeout?: number;
|
|
41
|
+
enabled?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/** Inline handler config */
|
|
44
|
+
export interface InlineHandlerConfig {
|
|
45
|
+
id: string;
|
|
46
|
+
type: 'inline';
|
|
47
|
+
module: string;
|
|
48
|
+
filter?: string;
|
|
49
|
+
timeout?: number;
|
|
50
|
+
enabled?: boolean;
|
|
51
|
+
}
|
|
52
|
+
/** Union of all handler configs */
|
|
53
|
+
export type HandlerConfig = ScriptHandlerConfig | InlineHandlerConfig | LLMHandlerConfig;
|
|
54
|
+
/** Prefetchable context keys */
|
|
55
|
+
export type PrefetchKey = 'transcript' | 'git_status' | 'git_diff';
|
|
56
|
+
/** Pre-fetched context data */
|
|
57
|
+
export interface PrefetchContext {
|
|
58
|
+
transcript?: string;
|
|
59
|
+
git_status?: string;
|
|
60
|
+
git_diff?: string;
|
|
61
|
+
}
|
|
62
|
+
/** Extended manifest with prefetch and LLM settings */
|
|
29
63
|
export interface Manifest {
|
|
30
64
|
handlers: Partial<Record<HookEvent, HandlerConfig[]>>;
|
|
65
|
+
prefetch?: PrefetchKey[];
|
|
31
66
|
settings?: {
|
|
32
67
|
port?: number;
|
|
33
68
|
logLevel?: 'debug' | 'info' | 'warn' | 'error';
|
|
69
|
+
anthropicApiKey?: string;
|
|
34
70
|
};
|
|
35
71
|
}
|
|
36
|
-
/**
|
|
37
|
-
export interface
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
output?: unknown;
|
|
41
|
-
error?: string;
|
|
42
|
-
duration_ms: number;
|
|
72
|
+
/** Token usage from API response */
|
|
73
|
+
export interface TokenUsage {
|
|
74
|
+
input_tokens: number;
|
|
75
|
+
output_tokens: number;
|
|
43
76
|
}
|
|
44
|
-
/**
|
|
77
|
+
/** Cost entry for tracking */
|
|
78
|
+
export interface CostEntry {
|
|
79
|
+
ts: string;
|
|
80
|
+
event: HookEvent;
|
|
81
|
+
handler: string;
|
|
82
|
+
model: LLMModel;
|
|
83
|
+
usage: TokenUsage;
|
|
84
|
+
cost_usd: number;
|
|
85
|
+
batched: boolean;
|
|
86
|
+
}
|
|
87
|
+
/** Extended metrics entry with optional cost fields */
|
|
45
88
|
export interface MetricEntry {
|
|
46
89
|
ts: string;
|
|
47
90
|
event: HookEvent;
|
|
@@ -49,6 +92,20 @@ export interface MetricEntry {
|
|
|
49
92
|
duration_ms: number;
|
|
50
93
|
ok: boolean;
|
|
51
94
|
error?: string;
|
|
95
|
+
filtered?: boolean;
|
|
96
|
+
usage?: TokenUsage;
|
|
97
|
+
cost_usd?: number;
|
|
98
|
+
}
|
|
99
|
+
/** Extended handler result with cost info */
|
|
100
|
+
export interface HandlerResult {
|
|
101
|
+
id: string;
|
|
102
|
+
ok: boolean;
|
|
103
|
+
output?: unknown;
|
|
104
|
+
error?: string;
|
|
105
|
+
duration_ms: number;
|
|
106
|
+
filtered?: boolean;
|
|
107
|
+
usage?: TokenUsage;
|
|
108
|
+
cost_usd?: number;
|
|
52
109
|
}
|
|
53
110
|
/** Runtime state for tracking consecutive failures */
|
|
54
111
|
export interface HandlerState {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mauribadnights/clooks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Persistent hook runtime for Claude Code — eliminates process spawning overhead and gives you observability",
|
|
5
5
|
"bin": {
|
|
6
6
|
"clooks": "./dist/cli.js"
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"build": "tsc",
|
|
12
12
|
"dev": "tsc --watch",
|
|
13
13
|
"test": "vitest run",
|
|
14
|
-
"test:watch": "vitest"
|
|
14
|
+
"test:watch": "vitest",
|
|
15
|
+
"bench": "npx tsx benchmarks/bench.ts"
|
|
15
16
|
},
|
|
16
17
|
"license": "MIT",
|
|
17
18
|
"author": "mauribadnights",
|
|
@@ -38,8 +39,17 @@
|
|
|
38
39
|
"commander": "^14.0.3",
|
|
39
40
|
"yaml": "^2.8.3"
|
|
40
41
|
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"@anthropic-ai/sdk": ">=0.30.0"
|
|
44
|
+
},
|
|
45
|
+
"peerDependenciesMeta": {
|
|
46
|
+
"@anthropic-ai/sdk": {
|
|
47
|
+
"optional": true
|
|
48
|
+
}
|
|
49
|
+
},
|
|
41
50
|
"devDependencies": {
|
|
42
51
|
"@types/node": "^25.5.0",
|
|
52
|
+
"tsx": "^4.21.0",
|
|
43
53
|
"typescript": "^6.0.2",
|
|
44
54
|
"vitest": "^4.1.1"
|
|
45
55
|
}
|