@cleocode/caamp 2026.10.8 → 2026.10.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/dist/atomic.d.ts +184 -0
- package/dist/atomic.js +20 -0
- package/dist/{chunk-2FQWBKEG.js → chunk-2RZGY4XT.js} +54 -166
- package/dist/chunk-2RZGY4XT.js.map +1 -0
- package/dist/{chunk-HDZYZTR2.js → chunk-5INWYMO4.js} +1 -8
- package/dist/{chunk-HDZYZTR2.js.map → chunk-5INWYMO4.js.map} +1 -1
- package/dist/{chunk-ZL6FLO2H.js → chunk-5UAFS46N.js} +9 -5
- package/dist/{chunk-ZL6FLO2H.js.map → chunk-5UAFS46N.js.map} +1 -1
- package/dist/chunk-D6CWC4BX.js +195 -0
- package/dist/chunk-D6CWC4BX.js.map +1 -0
- package/dist/chunk-IYSZL7N7.js +1239 -0
- package/dist/chunk-IYSZL7N7.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +10 -0
- package/dist/cli.js +8 -6
- package/dist/cli.js.map +1 -1
- package/dist/hooks-HDXLOEX2.js +61 -0
- package/dist/hooks-HDXLOEX2.js.map +1 -0
- package/dist/hooks.d.ts +812 -0
- package/dist/{hooks-FHFZZENR.js → hooks.js} +8 -3
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +5 -916
- package/dist/index.js +15 -10
- package/dist/index.js.map +1 -1
- package/dist/{injector-FDRZD2DB.js → injector-3SMMI2FO.js} +5 -3
- package/dist/injector-3SMMI2FO.js.map +1 -0
- package/package.json +15 -7
- package/providers/hook-mappings.json +6 -2
- package/dist/chunk-2FQWBKEG.js.map +0 -1
- package/dist/chunk-YCAANESR.js +0 -294
- package/dist/chunk-YCAANESR.js.map +0 -1
- /package/dist/{hooks-FHFZZENR.js.map → atomic.js.map} +0 -0
- /package/dist/{injector-FDRZD2DB.js.map → chunk-PZ5AY32C.js.map} +0 -0
package/dist/hooks.d.ts
ADDED
|
@@ -0,0 +1,812 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CAAMP Hooks Normalizer - Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Defines the canonical CAAMP hook event taxonomy and provider mapping types.
|
|
5
|
+
* CAAMP provides a unified hook interface across all providers — consumers
|
|
6
|
+
* use canonical event names, and the normalizer translates to/from
|
|
7
|
+
* provider-native names.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Definition of a canonical hook event including its category and behavior.
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* Each canonical event has a category for grouping, a human-readable description,
|
|
15
|
+
* and a `canBlock` flag indicating whether a hook handler can prevent the
|
|
16
|
+
* associated action from proceeding.
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
interface CanonicalEventDefinition {
|
|
21
|
+
/** The lifecycle category this event belongs to (e.g. `"session"`, `"tool"`). */
|
|
22
|
+
category: HookCategory;
|
|
23
|
+
/** Human-readable description of when this event fires. */
|
|
24
|
+
description: string;
|
|
25
|
+
/** Whether a hook handler can block or cancel the associated action. */
|
|
26
|
+
canBlock: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The type of hook system a provider uses.
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* - `"config"` — hooks defined in a configuration file (e.g. Claude Code `.claude/settings.json`)
|
|
33
|
+
* - `"plugin"` — hooks implemented via a plugin/extension system
|
|
34
|
+
* - `"none"` — provider does not support hooks
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
type HookSystemType = 'config' | 'plugin' | 'extension' | 'none';
|
|
39
|
+
/**
|
|
40
|
+
* The mechanism a provider uses to execute hook handlers.
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* - `"command"` — shell command execution
|
|
44
|
+
* - `"http"` — HTTP webhook callback
|
|
45
|
+
* - `"prompt"` — LLM prompt injection
|
|
46
|
+
* - `"agent"` — sub-agent delegation
|
|
47
|
+
* - `"plugin"` — native plugin API call
|
|
48
|
+
*
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
type HookHandlerType = 'command' | 'http' | 'prompt' | 'agent' | 'plugin' | 'extension';
|
|
52
|
+
/**
|
|
53
|
+
* Mapping of a single canonical event to a provider's native representation.
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* Each entry in a provider's hook profile maps one canonical event to the
|
|
57
|
+
* provider's native event name. If `supported` is `false`, the provider
|
|
58
|
+
* does not fire this event. Optional `notes` capture caveats or limitations.
|
|
59
|
+
*
|
|
60
|
+
* @public
|
|
61
|
+
*/
|
|
62
|
+
interface HookMapping {
|
|
63
|
+
/** The provider-native event name, or `null` if the event has no native equivalent. */
|
|
64
|
+
nativeName: string | null;
|
|
65
|
+
/** Whether this canonical event is supported by the provider. */
|
|
66
|
+
supported: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Optional notes about support limitations or behavioral differences.
|
|
69
|
+
*
|
|
70
|
+
* @defaultValue `undefined`
|
|
71
|
+
*/
|
|
72
|
+
notes?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Complete hook profile for a single provider.
|
|
76
|
+
*
|
|
77
|
+
* @remarks
|
|
78
|
+
* Describes the provider's hook system type, configuration location, supported
|
|
79
|
+
* handler types, and the full mapping of canonical events to native names.
|
|
80
|
+
* This is the primary data structure loaded from `providers/hook-mappings.json`.
|
|
81
|
+
*
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
|
+
interface ProviderHookProfile {
|
|
85
|
+
/** The type of hook system the provider uses (`"config"`, `"plugin"`, or `"none"`). */
|
|
86
|
+
hookSystem: HookSystemType;
|
|
87
|
+
/** Filesystem path template to the provider's hook configuration file, or `null`. */
|
|
88
|
+
hookConfigPath: string | null;
|
|
89
|
+
/** The configuration format used for hooks (e.g. `"json"`, `"yaml"`), or `null`. */
|
|
90
|
+
hookFormat: string | null;
|
|
91
|
+
/** The handler execution mechanisms this provider supports. */
|
|
92
|
+
handlerTypes: HookHandlerType[];
|
|
93
|
+
/** Whether the provider's hook system is considered experimental or unstable. */
|
|
94
|
+
experimental: boolean;
|
|
95
|
+
/** Project-local delivery and version evidence; absence is unverified. */
|
|
96
|
+
projectDelivery?: ProviderProjectHookCapability;
|
|
97
|
+
/** Provider event mappings; domain-only canonical events have no native representation. */
|
|
98
|
+
mappings: Partial<Record<CanonicalHookEvent, HookMapping>>;
|
|
99
|
+
/** Optional registry context for extension-based providers. */
|
|
100
|
+
notes?: string;
|
|
101
|
+
/** Registry-owned native event catalog name. */
|
|
102
|
+
nativeEventCatalog?: string;
|
|
103
|
+
/** Native event names that exist only in this provider with no canonical equivalent. */
|
|
104
|
+
providerOnlyEvents: string[];
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* A fully resolved hook event with both canonical and native names.
|
|
108
|
+
*
|
|
109
|
+
* @remarks
|
|
110
|
+
* Returned by batch translation functions. Contains all the context needed
|
|
111
|
+
* to register or invoke a hook handler: the canonical name for CAAMP logic,
|
|
112
|
+
* the native name for provider-specific calls, and metadata about category
|
|
113
|
+
* and blocking behavior.
|
|
114
|
+
*
|
|
115
|
+
* @public
|
|
116
|
+
*/
|
|
117
|
+
interface NormalizedHookEvent {
|
|
118
|
+
/** The CAAMP canonical event name. */
|
|
119
|
+
canonical: CanonicalHookEvent;
|
|
120
|
+
/** The provider-native event name. */
|
|
121
|
+
native: string;
|
|
122
|
+
/** The provider this event was resolved for. */
|
|
123
|
+
providerId: string;
|
|
124
|
+
/** The lifecycle category of this event. */
|
|
125
|
+
category: HookCategory;
|
|
126
|
+
/** Whether a handler for this event can block the associated action. */
|
|
127
|
+
canBlock: boolean;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Result of querying whether a provider supports a specific canonical event.
|
|
131
|
+
*
|
|
132
|
+
* @remarks
|
|
133
|
+
* Returned by `getHookSupport()`. Includes the native name translation
|
|
134
|
+
* and any notes about support limitations. When `supported` is `false`,
|
|
135
|
+
* `native` will be `null`.
|
|
136
|
+
*
|
|
137
|
+
* @public
|
|
138
|
+
*/
|
|
139
|
+
interface HookSupportResult {
|
|
140
|
+
/** The canonical event that was queried. */
|
|
141
|
+
canonical: CanonicalHookEvent;
|
|
142
|
+
/** Whether the provider supports this event. */
|
|
143
|
+
supported: boolean;
|
|
144
|
+
/** The provider-native event name, or `null` if unsupported. */
|
|
145
|
+
native: string | null;
|
|
146
|
+
/**
|
|
147
|
+
* Optional notes about support caveats.
|
|
148
|
+
*
|
|
149
|
+
* @defaultValue `undefined`
|
|
150
|
+
*/
|
|
151
|
+
notes?: string;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Aggregated hook support summary for a single provider.
|
|
155
|
+
*
|
|
156
|
+
* @remarks
|
|
157
|
+
* Provides a high-level view of a provider's hook capabilities including
|
|
158
|
+
* counts, coverage percentage, and lists of supported/unsupported events.
|
|
159
|
+
* Useful for CLI display and provider comparison features.
|
|
160
|
+
*
|
|
161
|
+
* @public
|
|
162
|
+
*/
|
|
163
|
+
interface ProviderHookSummary {
|
|
164
|
+
/** The provider identifier. */
|
|
165
|
+
providerId: string;
|
|
166
|
+
/** The type of hook system the provider uses. */
|
|
167
|
+
hookSystem: HookSystemType;
|
|
168
|
+
/** Whether the provider's hook system is experimental. */
|
|
169
|
+
experimental: boolean;
|
|
170
|
+
/** Number of canonical events this provider supports. */
|
|
171
|
+
supportedCount: number;
|
|
172
|
+
/** Total number of canonical events in the taxonomy. */
|
|
173
|
+
totalCanonical: number;
|
|
174
|
+
/** List of canonical events this provider supports. */
|
|
175
|
+
supported: CanonicalHookEvent[];
|
|
176
|
+
/** List of canonical events this provider does not support. */
|
|
177
|
+
unsupported: CanonicalHookEvent[];
|
|
178
|
+
/** Native events unique to this provider with no canonical mapping. */
|
|
179
|
+
providerOnly: string[];
|
|
180
|
+
/** Percentage of canonical events supported (0-100). */
|
|
181
|
+
coverage: number;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Cross-provider hook support matrix comparing multiple providers.
|
|
185
|
+
*
|
|
186
|
+
* @remarks
|
|
187
|
+
* Built by `buildHookMatrix()`. Provides a two-dimensional view of which
|
|
188
|
+
* canonical events are supported by which providers, with native name
|
|
189
|
+
* translations. Used to render comparison tables in the CLI.
|
|
190
|
+
*
|
|
191
|
+
* @public
|
|
192
|
+
*/
|
|
193
|
+
interface CrossProviderMatrix {
|
|
194
|
+
/** The canonical events included in this matrix (rows). */
|
|
195
|
+
events: CanonicalHookEvent[];
|
|
196
|
+
/** The provider IDs included in this matrix (columns). */
|
|
197
|
+
providers: string[];
|
|
198
|
+
/** Nested record mapping each canonical event to each provider's hook mapping. */
|
|
199
|
+
matrix: Record<CanonicalHookEvent, Record<string, HookMapping>>;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Schema for the `providers/hook-mappings.json` data file.
|
|
203
|
+
*
|
|
204
|
+
* @remarks
|
|
205
|
+
* This interface represents the top-level structure of the hook mappings
|
|
206
|
+
* JSON file that serves as the single source of truth for all provider
|
|
207
|
+
* hook configurations. It is loaded and cached by the normalizer module.
|
|
208
|
+
*
|
|
209
|
+
* @public
|
|
210
|
+
*/
|
|
211
|
+
interface HookMappingsFile {
|
|
212
|
+
/** Semver version string of the hook mappings schema. */
|
|
213
|
+
version: string;
|
|
214
|
+
/** ISO 8601 date string of the last update to mappings data. */
|
|
215
|
+
lastUpdated: string;
|
|
216
|
+
/** Human-readable description of the mappings file purpose. */
|
|
217
|
+
description: string;
|
|
218
|
+
/** Definitions for every canonical event in the taxonomy. */
|
|
219
|
+
canonicalEvents: Record<CanonicalHookEvent, CanonicalEventDefinition>;
|
|
220
|
+
/** Hook profiles keyed by provider ID. */
|
|
221
|
+
providerMappings: Record<string, ProviderHookProfile>;
|
|
222
|
+
}
|
|
223
|
+
/** Registry evidence for project-local delivery; native trust is independent. */
|
|
224
|
+
interface ProviderProjectHookCapability {
|
|
225
|
+
/** Native command timeout units, when documented for project delivery. */
|
|
226
|
+
timeoutUnit?: 'seconds' | 'milliseconds';
|
|
227
|
+
/** Safe project-relative config destination, null when unsupported. */
|
|
228
|
+
configPath: string | null;
|
|
229
|
+
/** Documentation-reviewed versions, not live certifications. */
|
|
230
|
+
documentedVersions: string[];
|
|
231
|
+
/** Versions whose actual harness invocation was verified. */
|
|
232
|
+
verifiedVersions: string[];
|
|
233
|
+
/** Official evidence source. */
|
|
234
|
+
documentation: string;
|
|
235
|
+
/** Registry review date. */
|
|
236
|
+
reviewedAt: string;
|
|
237
|
+
/** Installation never grants native hook or project trust. */
|
|
238
|
+
trust: 'native-unverified';
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* All hook event categories (8 total).
|
|
243
|
+
* @public
|
|
244
|
+
*/
|
|
245
|
+
declare const HOOK_CATEGORIES: readonly ["agent", "context", "memory", "pipeline", "prompt", "session", "task", "tool"];
|
|
246
|
+
/** Union type of valid hook category strings. */
|
|
247
|
+
type HookCategory = (typeof HOOK_CATEGORIES)[number];
|
|
248
|
+
/**
|
|
249
|
+
* All canonical hook events (31 total: 16 provider, 15 domain).
|
|
250
|
+
*
|
|
251
|
+
* This replaces the previously hardcoded tuple in types.ts.
|
|
252
|
+
* Single source of truth: providers/hook-mappings.json
|
|
253
|
+
* @public
|
|
254
|
+
*/
|
|
255
|
+
declare const CANONICAL_HOOK_EVENTS: readonly ["ConfigChange", "Notification", "PermissionRequest", "PostCompact", "PostModel", "PostToolUse", "PostToolUseFailure", "PreCompact", "PreModel", "PreToolUse", "PromptSubmit", "ResponseComplete", "SessionEnd", "SessionStart", "SubagentStart", "SubagentStop", "ApprovalExpired", "ApprovalGranted", "ApprovalRequested", "MemoryDecisionStored", "MemoryLearningStored", "MemoryObserved", "MemoryPatternStored", "PipelineManifestAppended", "PipelineStageCompleted", "SessionEnded", "SessionStarted", "TaskBlocked", "TaskCompleted", "TaskCreated", "TaskStarted"];
|
|
256
|
+
/** Union type of all canonical hook event names. */
|
|
257
|
+
type CanonicalHookEvent = (typeof CANONICAL_HOOK_EVENTS)[number];
|
|
258
|
+
/** Complete fallback profiles generated from the registry. */
|
|
259
|
+
declare const GENERATED_PROVIDER_HOOK_PROFILES: Record<string, ProviderHookProfile>;
|
|
260
|
+
/** Provider native-to-canonical maps generated from the same registry. */
|
|
261
|
+
declare const PROVIDER_NATIVE_EVENT_MAPS: Record<string, Record<string, string>>;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* CAAMP Hooks Normalizer
|
|
265
|
+
*
|
|
266
|
+
* Translates between CAAMP canonical hook events and provider-native
|
|
267
|
+
* event names. Provides query functions for hook support, cross-provider
|
|
268
|
+
* comparison, and event normalization.
|
|
269
|
+
*
|
|
270
|
+
* This module follows the same pattern as `src/core/mcp/transforms.ts` —
|
|
271
|
+
* a translation layer that lets consumers use one canonical interface
|
|
272
|
+
* while CAAMP handles provider-specific differences.
|
|
273
|
+
*/
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Reset the cached hook mappings data.
|
|
277
|
+
*
|
|
278
|
+
* @remarks
|
|
279
|
+
* Clears the in-memory cache so the next query function call will
|
|
280
|
+
* re-read `providers/hook-mappings.json` from disk. This is primarily
|
|
281
|
+
* intended for test isolation — production code should not need to call this.
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* ```typescript
|
|
285
|
+
* import { resetHookMappings, getHookMappingsVersion } from "./normalizer.js";
|
|
286
|
+
*
|
|
287
|
+
* // Force a fresh load from disk
|
|
288
|
+
* resetHookMappings();
|
|
289
|
+
* const version = getHookMappingsVersion();
|
|
290
|
+
* ```
|
|
291
|
+
*
|
|
292
|
+
* @public
|
|
293
|
+
*/
|
|
294
|
+
declare function resetHookMappings(): void;
|
|
295
|
+
/**
|
|
296
|
+
* Get the canonical event definition (category, description, canBlock).
|
|
297
|
+
*
|
|
298
|
+
* @remarks
|
|
299
|
+
* Looks up the definition from the hook mappings data file. The returned
|
|
300
|
+
* object contains the event's category, human-readable description, and
|
|
301
|
+
* whether handlers can block the associated action.
|
|
302
|
+
*
|
|
303
|
+
* @param event - The canonical event name to look up.
|
|
304
|
+
* @returns The event definition containing category, description, and canBlock flag.
|
|
305
|
+
*
|
|
306
|
+
* @example
|
|
307
|
+
* ```typescript
|
|
308
|
+
* import { getCanonicalEvent } from "./normalizer.js";
|
|
309
|
+
*
|
|
310
|
+
* const def = getCanonicalEvent("PreToolUse");
|
|
311
|
+
* console.log(def.category); // "tool"
|
|
312
|
+
* console.log(def.canBlock); // true
|
|
313
|
+
* ```
|
|
314
|
+
*
|
|
315
|
+
* @public
|
|
316
|
+
*/
|
|
317
|
+
declare function getCanonicalEvent(event: CanonicalHookEvent): CanonicalEventDefinition;
|
|
318
|
+
/**
|
|
319
|
+
* Get all canonical event definitions.
|
|
320
|
+
*
|
|
321
|
+
* @remarks
|
|
322
|
+
* Returns the complete map of canonical event names to their definitions.
|
|
323
|
+
* Useful for iterating over the full taxonomy or building UI displays
|
|
324
|
+
* of all available events.
|
|
325
|
+
*
|
|
326
|
+
* @returns A record mapping every canonical event name to its definition.
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* ```typescript
|
|
330
|
+
* import { getAllCanonicalEvents } from "./normalizer.js";
|
|
331
|
+
*
|
|
332
|
+
* const events = getAllCanonicalEvents();
|
|
333
|
+
* for (const [name, def] of Object.entries(events)) {
|
|
334
|
+
* console.log(`${name}: ${def.description}`);
|
|
335
|
+
* }
|
|
336
|
+
* ```
|
|
337
|
+
*
|
|
338
|
+
* @public
|
|
339
|
+
*/
|
|
340
|
+
declare function getAllCanonicalEvents(): Record<CanonicalHookEvent, CanonicalEventDefinition>;
|
|
341
|
+
/**
|
|
342
|
+
* Get canonical events filtered by category.
|
|
343
|
+
*
|
|
344
|
+
* @remarks
|
|
345
|
+
* Filters the canonical event list to only those belonging to the specified
|
|
346
|
+
* category. Useful for displaying events grouped by lifecycle phase
|
|
347
|
+
* (e.g. all `"tool"` events or all `"session"` events).
|
|
348
|
+
*
|
|
349
|
+
* @param category - The hook category to filter by (e.g. `"session"`, `"tool"`).
|
|
350
|
+
* @returns Array of canonical event names that belong to the specified category.
|
|
351
|
+
*
|
|
352
|
+
* @example
|
|
353
|
+
* ```typescript
|
|
354
|
+
* import { getCanonicalEventsByCategory } from "./normalizer.js";
|
|
355
|
+
*
|
|
356
|
+
* const toolEvents = getCanonicalEventsByCategory("tool");
|
|
357
|
+
* // ["PreToolUse", "PostToolUse", "PostToolUseFailure"]
|
|
358
|
+
* ```
|
|
359
|
+
*
|
|
360
|
+
* @public
|
|
361
|
+
*/
|
|
362
|
+
declare function getCanonicalEventsByCategory(category: HookCategory): CanonicalHookEvent[];
|
|
363
|
+
/**
|
|
364
|
+
* Get the full hook profile for a provider.
|
|
365
|
+
*
|
|
366
|
+
* @remarks
|
|
367
|
+
* Returns the complete hook configuration for a provider including its
|
|
368
|
+
* hook system type, config path, handler types, and all event mappings.
|
|
369
|
+
* Returns `undefined` if the provider has no hook mappings defined.
|
|
370
|
+
*
|
|
371
|
+
* @param providerId - The provider identifier (e.g. `"claude-code"`, `"gemini-cli"`).
|
|
372
|
+
* @returns The provider's hook profile, or `undefined` if not found.
|
|
373
|
+
*
|
|
374
|
+
* @example
|
|
375
|
+
* ```typescript
|
|
376
|
+
* import { getProviderHookProfile } from "./normalizer.js";
|
|
377
|
+
*
|
|
378
|
+
* const profile = getProviderHookProfile("claude-code");
|
|
379
|
+
* if (profile) {
|
|
380
|
+
* console.log(profile.hookSystem); // "config"
|
|
381
|
+
* console.log(profile.experimental); // false
|
|
382
|
+
* }
|
|
383
|
+
* ```
|
|
384
|
+
*
|
|
385
|
+
* @public
|
|
386
|
+
*/
|
|
387
|
+
declare function getProviderHookProfile(providerId: string): ProviderHookProfile | undefined;
|
|
388
|
+
/**
|
|
389
|
+
* Get all provider IDs that have hook mappings.
|
|
390
|
+
*
|
|
391
|
+
* @remarks
|
|
392
|
+
* Returns the list of provider identifiers present in the hook mappings
|
|
393
|
+
* data file. This reflects all providers for which CAAMP has hook
|
|
394
|
+
* translation data, regardless of whether they support any events.
|
|
395
|
+
*
|
|
396
|
+
* @returns Array of provider ID strings.
|
|
397
|
+
*
|
|
398
|
+
* @example
|
|
399
|
+
* ```typescript
|
|
400
|
+
* import { getMappedProviderIds } from "./normalizer.js";
|
|
401
|
+
*
|
|
402
|
+
* const ids = getMappedProviderIds();
|
|
403
|
+
* // ["claude-code", "gemini-cli", "cursor", "kimi", ...]
|
|
404
|
+
* ```
|
|
405
|
+
*
|
|
406
|
+
* @public
|
|
407
|
+
*/
|
|
408
|
+
declare function getMappedProviderIds(): string[];
|
|
409
|
+
/**
|
|
410
|
+
* Translate a CAAMP canonical event name to the provider's native name.
|
|
411
|
+
*
|
|
412
|
+
* @remarks
|
|
413
|
+
* This is the primary forward-translation function. Given a canonical
|
|
414
|
+
* event and a provider ID, it returns the provider-specific event name
|
|
415
|
+
* that should be used when configuring hooks for that provider.
|
|
416
|
+
* Returns `null` if the provider is unknown or does not support the event.
|
|
417
|
+
*
|
|
418
|
+
* @param canonical - The CAAMP canonical event name to translate.
|
|
419
|
+
* @param providerId - The target provider identifier.
|
|
420
|
+
* @returns The native event name, or `null` if unsupported.
|
|
421
|
+
*
|
|
422
|
+
* @example
|
|
423
|
+
* ```typescript
|
|
424
|
+
* import { toNative } from "./normalizer.js";
|
|
425
|
+
*
|
|
426
|
+
* toNative("PreToolUse", "claude-code"); // "PreToolUse"
|
|
427
|
+
* toNative("PreToolUse", "gemini-cli"); // "BeforeTool"
|
|
428
|
+
* toNative("PreToolUse", "cursor"); // "preToolUse"
|
|
429
|
+
* toNative("PreToolUse", "kimi"); // null
|
|
430
|
+
* ```
|
|
431
|
+
*
|
|
432
|
+
* @public
|
|
433
|
+
*/
|
|
434
|
+
declare function toNative(canonical: CanonicalHookEvent, providerId: string): string | null;
|
|
435
|
+
/**
|
|
436
|
+
* Translate a provider-native event name to the CAAMP canonical name.
|
|
437
|
+
*
|
|
438
|
+
* @remarks
|
|
439
|
+
* This is the reverse-translation function. Scans all event mappings
|
|
440
|
+
* for the given provider to find a canonical match for the native name.
|
|
441
|
+
* Returns `null` if no mapping is found or the provider is unknown.
|
|
442
|
+
*
|
|
443
|
+
* @param nativeName - The provider-native event name to look up.
|
|
444
|
+
* @param providerId - The provider identifier to search within.
|
|
445
|
+
* @returns The canonical event name, or `null` if no mapping exists.
|
|
446
|
+
*
|
|
447
|
+
* @example
|
|
448
|
+
* ```typescript
|
|
449
|
+
* import { toCanonical } from "./normalizer.js";
|
|
450
|
+
*
|
|
451
|
+
* toCanonical("BeforeTool", "gemini-cli"); // "PreToolUse"
|
|
452
|
+
* toCanonical("stop", "cursor"); // "ResponseComplete"
|
|
453
|
+
* toCanonical("UserPromptSubmit", "claude-code"); // "PromptSubmit"
|
|
454
|
+
* ```
|
|
455
|
+
*
|
|
456
|
+
* @public
|
|
457
|
+
*/
|
|
458
|
+
declare function toCanonical(nativeName: string, providerId: string): CanonicalHookEvent | null;
|
|
459
|
+
/**
|
|
460
|
+
* Batch-translate multiple canonical events to native names for a provider.
|
|
461
|
+
*
|
|
462
|
+
* @remarks
|
|
463
|
+
* Translates an array of canonical events in a single call, returning
|
|
464
|
+
* only the events that the provider actually supports. Each result
|
|
465
|
+
* includes category and blocking metadata. Unsupported events are
|
|
466
|
+
* silently excluded from the output.
|
|
467
|
+
*
|
|
468
|
+
* @param canonicals - Array of canonical event names to translate.
|
|
469
|
+
* @param providerId - The target provider identifier.
|
|
470
|
+
* @returns Array of normalized events (only supported ones included).
|
|
471
|
+
*
|
|
472
|
+
* @example
|
|
473
|
+
* ```typescript
|
|
474
|
+
* import { toNativeBatch } from "./normalizer.js";
|
|
475
|
+
*
|
|
476
|
+
* const events = toNativeBatch(
|
|
477
|
+
* ["PreToolUse", "PostToolUse", "ConfigChange"],
|
|
478
|
+
* "claude-code",
|
|
479
|
+
* );
|
|
480
|
+
* // Returns NormalizedHookEvent[] for supported events only
|
|
481
|
+
* ```
|
|
482
|
+
*
|
|
483
|
+
* @public
|
|
484
|
+
*/
|
|
485
|
+
declare function toNativeBatch(canonicals: CanonicalHookEvent[], providerId: string): NormalizedHookEvent[];
|
|
486
|
+
/**
|
|
487
|
+
* Check if a provider supports a specific canonical hook event.
|
|
488
|
+
*
|
|
489
|
+
* @remarks
|
|
490
|
+
* A quick boolean check that avoids returning the full mapping details.
|
|
491
|
+
* Returns `false` if the provider is unknown or the event is not supported.
|
|
492
|
+
*
|
|
493
|
+
* @param canonical - The canonical event name to check.
|
|
494
|
+
* @param providerId - The provider identifier to check against.
|
|
495
|
+
* @returns `true` if the provider supports this canonical event, `false` otherwise.
|
|
496
|
+
*
|
|
497
|
+
* @example
|
|
498
|
+
* ```typescript
|
|
499
|
+
* import { supportsHook } from "./normalizer.js";
|
|
500
|
+
*
|
|
501
|
+
* supportsHook("PreToolUse", "claude-code"); // true
|
|
502
|
+
* supportsHook("PreToolUse", "kimi"); // false
|
|
503
|
+
* ```
|
|
504
|
+
*
|
|
505
|
+
* @public
|
|
506
|
+
*/
|
|
507
|
+
declare function supportsHook(canonical: CanonicalHookEvent, providerId: string): boolean;
|
|
508
|
+
/**
|
|
509
|
+
* Get full hook support details for a canonical event on a provider.
|
|
510
|
+
*
|
|
511
|
+
* @remarks
|
|
512
|
+
* Returns a structured result with the native name translation and any
|
|
513
|
+
* notes about support limitations. Unlike `supportsHook()`, this always
|
|
514
|
+
* returns a result object even when the provider is unknown (with
|
|
515
|
+
* `supported: false`).
|
|
516
|
+
*
|
|
517
|
+
* @param canonical - The canonical event name to query.
|
|
518
|
+
* @param providerId - The provider identifier to query against.
|
|
519
|
+
* @returns Support result including native name and optional notes.
|
|
520
|
+
*
|
|
521
|
+
* @example
|
|
522
|
+
* ```typescript
|
|
523
|
+
* import { getHookSupport } from "./normalizer.js";
|
|
524
|
+
*
|
|
525
|
+
* const result = getHookSupport("PreToolUse", "claude-code");
|
|
526
|
+
* console.log(result.supported); // true
|
|
527
|
+
* console.log(result.native); // "PreToolUse"
|
|
528
|
+
* ```
|
|
529
|
+
*
|
|
530
|
+
* @public
|
|
531
|
+
*/
|
|
532
|
+
declare function getHookSupport(canonical: CanonicalHookEvent, providerId: string): HookSupportResult;
|
|
533
|
+
/**
|
|
534
|
+
* Get all supported canonical events for a provider.
|
|
535
|
+
*
|
|
536
|
+
* @remarks
|
|
537
|
+
* Filters the full canonical event list to only those that the provider
|
|
538
|
+
* supports. Returns an empty array if the provider is unknown.
|
|
539
|
+
*
|
|
540
|
+
* @param providerId - The provider identifier to query.
|
|
541
|
+
* @returns Array of canonical event names the provider supports.
|
|
542
|
+
*
|
|
543
|
+
* @example
|
|
544
|
+
* ```typescript
|
|
545
|
+
* import { getSupportedEvents } from "./normalizer.js";
|
|
546
|
+
*
|
|
547
|
+
* const events = getSupportedEvents("claude-code");
|
|
548
|
+
* // ["SessionStart", "SessionEnd", "PreToolUse", ...]
|
|
549
|
+
* ```
|
|
550
|
+
*
|
|
551
|
+
* @public
|
|
552
|
+
*/
|
|
553
|
+
declare function getSupportedEvents(providerId: string): CanonicalHookEvent[];
|
|
554
|
+
/**
|
|
555
|
+
* Get all unsupported canonical events for a provider.
|
|
556
|
+
*
|
|
557
|
+
* @remarks
|
|
558
|
+
* Returns the complement of `getSupportedEvents()`. If the provider is
|
|
559
|
+
* unknown, all canonical events are returned since none are supported.
|
|
560
|
+
*
|
|
561
|
+
* @param providerId - The provider identifier to query.
|
|
562
|
+
* @returns Array of canonical event names the provider does not support.
|
|
563
|
+
*
|
|
564
|
+
* @example
|
|
565
|
+
* ```typescript
|
|
566
|
+
* import { getUnsupportedEvents } from "./normalizer.js";
|
|
567
|
+
*
|
|
568
|
+
* const missing = getUnsupportedEvents("kimi");
|
|
569
|
+
* // Returns all canonical events (kimi has no hook support)
|
|
570
|
+
* ```
|
|
571
|
+
*
|
|
572
|
+
* @public
|
|
573
|
+
*/
|
|
574
|
+
declare function getUnsupportedEvents(providerId: string): CanonicalHookEvent[];
|
|
575
|
+
/**
|
|
576
|
+
* Get providers that support a specific canonical event.
|
|
577
|
+
*
|
|
578
|
+
* @remarks
|
|
579
|
+
* Scans all provider mappings and returns the IDs of those that support
|
|
580
|
+
* the given canonical event. Useful for determining which providers can
|
|
581
|
+
* be targeted when configuring a specific hook.
|
|
582
|
+
*
|
|
583
|
+
* @param canonical - The canonical event name to search for.
|
|
584
|
+
* @returns Array of provider IDs that support this event.
|
|
585
|
+
*
|
|
586
|
+
* @example
|
|
587
|
+
* ```typescript
|
|
588
|
+
* import { getProvidersForEvent } from "./normalizer.js";
|
|
589
|
+
*
|
|
590
|
+
* const providers = getProvidersForEvent("PreToolUse");
|
|
591
|
+
* // ["claude-code", "gemini-cli", "cursor"]
|
|
592
|
+
* ```
|
|
593
|
+
*
|
|
594
|
+
* @public
|
|
595
|
+
*/
|
|
596
|
+
declare function getProvidersForEvent(canonical: CanonicalHookEvent): string[];
|
|
597
|
+
/**
|
|
598
|
+
* Get canonical events common to all specified providers.
|
|
599
|
+
*
|
|
600
|
+
* @remarks
|
|
601
|
+
* Computes the intersection of supported events across multiple providers.
|
|
602
|
+
* Returns only events that every listed provider supports. Useful for
|
|
603
|
+
* determining which hooks can be configured uniformly across a set of
|
|
604
|
+
* target providers.
|
|
605
|
+
*
|
|
606
|
+
* @param providerIds - Array of provider IDs to intersect.
|
|
607
|
+
* @returns Array of canonical events supported by all specified providers.
|
|
608
|
+
*
|
|
609
|
+
* @example
|
|
610
|
+
* ```typescript
|
|
611
|
+
* import { getCommonEvents } from "./normalizer.js";
|
|
612
|
+
*
|
|
613
|
+
* const common = getCommonEvents(["claude-code", "gemini-cli"]);
|
|
614
|
+
* // Returns only events both providers support
|
|
615
|
+
* ```
|
|
616
|
+
*
|
|
617
|
+
* @public
|
|
618
|
+
*/
|
|
619
|
+
declare function getCommonEvents(providerIds: string[]): CanonicalHookEvent[];
|
|
620
|
+
/**
|
|
621
|
+
* Get a summary of hook support for a provider.
|
|
622
|
+
*
|
|
623
|
+
* @remarks
|
|
624
|
+
* Builds an aggregated view of a provider's hook capabilities including
|
|
625
|
+
* counts, coverage percentage, and categorized event lists. Returns
|
|
626
|
+
* `undefined` if the provider has no hook mappings. Used by the CLI
|
|
627
|
+
* `hooks show` command for provider overviews.
|
|
628
|
+
*
|
|
629
|
+
* @param providerId - The provider identifier to summarize.
|
|
630
|
+
* @returns The hook support summary, or `undefined` if the provider is not found.
|
|
631
|
+
*
|
|
632
|
+
* @example
|
|
633
|
+
* ```typescript
|
|
634
|
+
* import { getProviderSummary } from "./normalizer.js";
|
|
635
|
+
*
|
|
636
|
+
* const summary = getProviderSummary("claude-code");
|
|
637
|
+
* if (summary) {
|
|
638
|
+
* console.log(`${summary.coverage}% coverage`);
|
|
639
|
+
* console.log(`${summary.supportedCount}/${summary.totalCanonical} events`);
|
|
640
|
+
* }
|
|
641
|
+
* ```
|
|
642
|
+
*
|
|
643
|
+
* @public
|
|
644
|
+
*/
|
|
645
|
+
declare function getProviderSummary(providerId: string): ProviderHookSummary | undefined;
|
|
646
|
+
/**
|
|
647
|
+
* Build a cross-provider hook support matrix.
|
|
648
|
+
*
|
|
649
|
+
* @remarks
|
|
650
|
+
* Constructs a two-dimensional matrix showing which canonical events are
|
|
651
|
+
* supported by which providers, with native name translations. When no
|
|
652
|
+
* provider IDs are specified, all mapped providers are included. Used by
|
|
653
|
+
* the CLI `hooks matrix` command for comparison tables.
|
|
654
|
+
*
|
|
655
|
+
* @param providerIds - Optional array of provider IDs to include. Defaults to all mapped providers.
|
|
656
|
+
* @returns The cross-provider matrix with events, providers, and mapping data.
|
|
657
|
+
*
|
|
658
|
+
* @example
|
|
659
|
+
* ```typescript
|
|
660
|
+
* import { buildHookMatrix } from "./normalizer.js";
|
|
661
|
+
*
|
|
662
|
+
* const matrix = buildHookMatrix(["claude-code", "gemini-cli"]);
|
|
663
|
+
* for (const event of matrix.events) {
|
|
664
|
+
* for (const provider of matrix.providers) {
|
|
665
|
+
* console.log(`${event} @ ${provider}: ${matrix.matrix[event][provider].supported}`);
|
|
666
|
+
* }
|
|
667
|
+
* }
|
|
668
|
+
* ```
|
|
669
|
+
*
|
|
670
|
+
* @public
|
|
671
|
+
*/
|
|
672
|
+
declare function buildHookMatrix(providerIds?: string[]): CrossProviderMatrix;
|
|
673
|
+
/**
|
|
674
|
+
* Get the hook system type for a provider.
|
|
675
|
+
*
|
|
676
|
+
* @remarks
|
|
677
|
+
* Returns the provider's hook system type: `"config"` for file-based hooks,
|
|
678
|
+
* `"plugin"` for extension-based hooks, or `"none"` if the provider does
|
|
679
|
+
* not support hooks. Returns `"none"` for unknown providers.
|
|
680
|
+
*
|
|
681
|
+
* @param providerId - The provider identifier to query.
|
|
682
|
+
* @returns The hook system type (`"config"`, `"plugin"`, or `"none"`).
|
|
683
|
+
*
|
|
684
|
+
* @example
|
|
685
|
+
* ```typescript
|
|
686
|
+
* import { getHookSystemType } from "./normalizer.js";
|
|
687
|
+
*
|
|
688
|
+
* getHookSystemType("claude-code"); // "config"
|
|
689
|
+
* getHookSystemType("unknown"); // "none"
|
|
690
|
+
* ```
|
|
691
|
+
*
|
|
692
|
+
* @public
|
|
693
|
+
*/
|
|
694
|
+
declare function getHookSystemType(providerId: string): HookSystemType;
|
|
695
|
+
/**
|
|
696
|
+
* Get the resolved hook config path for a provider.
|
|
697
|
+
*
|
|
698
|
+
* @remarks
|
|
699
|
+
* Resolves the provider's hook configuration file path by expanding
|
|
700
|
+
* registry template variables (e.g. `~` to the home directory). Returns
|
|
701
|
+
* `null` if the provider has no hook config path defined or is unknown.
|
|
702
|
+
*
|
|
703
|
+
* @param providerId - The provider identifier to query.
|
|
704
|
+
* @returns The resolved filesystem path, or `null` if not available.
|
|
705
|
+
*
|
|
706
|
+
* @example
|
|
707
|
+
* ```typescript
|
|
708
|
+
* import { getHookConfigPath } from "./normalizer.js";
|
|
709
|
+
*
|
|
710
|
+
* const path = getHookConfigPath("claude-code");
|
|
711
|
+
* // "/home/user/.claude/settings.json" (resolved from template)
|
|
712
|
+
* ```
|
|
713
|
+
*
|
|
714
|
+
* @public
|
|
715
|
+
*/
|
|
716
|
+
declare function getHookConfigPath(providerId: string): string | null;
|
|
717
|
+
/**
|
|
718
|
+
* Get provider-only events (native events with no canonical mapping).
|
|
719
|
+
*
|
|
720
|
+
* @remarks
|
|
721
|
+
* Some providers define hook events that have no equivalent in the CAAMP
|
|
722
|
+
* canonical taxonomy. This function returns those provider-specific event
|
|
723
|
+
* names. Returns an empty array for unknown providers.
|
|
724
|
+
*
|
|
725
|
+
* @param providerId - The provider identifier to query.
|
|
726
|
+
* @returns Array of native event names unique to this provider.
|
|
727
|
+
*
|
|
728
|
+
* @example
|
|
729
|
+
* ```typescript
|
|
730
|
+
* import { getProviderOnlyEvents } from "./normalizer.js";
|
|
731
|
+
*
|
|
732
|
+
* const extras = getProviderOnlyEvents("claude-code");
|
|
733
|
+
* // Returns any events specific to Claude Code with no canonical equivalent
|
|
734
|
+
* ```
|
|
735
|
+
*
|
|
736
|
+
* @public
|
|
737
|
+
*/
|
|
738
|
+
declare function getProviderOnlyEvents(providerId: string): string[];
|
|
739
|
+
/**
|
|
740
|
+
* Translate a canonical event to native names across multiple providers.
|
|
741
|
+
*
|
|
742
|
+
* @remarks
|
|
743
|
+
* Performs a fan-out translation of a single canonical event to all
|
|
744
|
+
* specified providers simultaneously. The result record only includes
|
|
745
|
+
* providers that actually support the event — unsupported providers
|
|
746
|
+
* are silently excluded.
|
|
747
|
+
*
|
|
748
|
+
* @param canonical - The canonical event name to translate.
|
|
749
|
+
* @param providerIds - Array of provider IDs to translate for.
|
|
750
|
+
* @returns Record mapping provider IDs to their native event names (supported only).
|
|
751
|
+
*
|
|
752
|
+
* @example
|
|
753
|
+
* ```typescript
|
|
754
|
+
* import { translateToAll } from "./normalizer.js";
|
|
755
|
+
*
|
|
756
|
+
* const result = translateToAll("PreToolUse", ["claude-code", "gemini-cli", "kimi"]);
|
|
757
|
+
* // { "claude-code": "PreToolUse", "gemini-cli": "BeforeTool" }
|
|
758
|
+
* // (kimi excluded — unsupported)
|
|
759
|
+
* ```
|
|
760
|
+
*
|
|
761
|
+
* @public
|
|
762
|
+
*/
|
|
763
|
+
declare function translateToAll(canonical: CanonicalHookEvent, providerIds: string[]): Record<string, string>;
|
|
764
|
+
/**
|
|
765
|
+
* Find the best canonical match for a native event name across all providers.
|
|
766
|
+
*
|
|
767
|
+
* @remarks
|
|
768
|
+
* Scans every provider's mappings to find canonical events that match the
|
|
769
|
+
* given native name. Useful when you have a native name but do not know
|
|
770
|
+
* which provider it belongs to. Multiple results are possible if different
|
|
771
|
+
* providers use the same native name for different canonical events.
|
|
772
|
+
*
|
|
773
|
+
* @param nativeName - The provider-native event name to resolve.
|
|
774
|
+
* @returns Array of matches, each containing the provider ID and canonical event name.
|
|
775
|
+
*
|
|
776
|
+
* @example
|
|
777
|
+
* ```typescript
|
|
778
|
+
* import { resolveNativeEvent } from "./normalizer.js";
|
|
779
|
+
*
|
|
780
|
+
* const matches = resolveNativeEvent("BeforeTool");
|
|
781
|
+
* // [{ providerId: "gemini-cli", canonical: "PreToolUse" }]
|
|
782
|
+
* ```
|
|
783
|
+
*
|
|
784
|
+
* @public
|
|
785
|
+
*/
|
|
786
|
+
declare function resolveNativeEvent(nativeName: string): Array<{
|
|
787
|
+
providerId: string;
|
|
788
|
+
canonical: CanonicalHookEvent;
|
|
789
|
+
}>;
|
|
790
|
+
/**
|
|
791
|
+
* Get the version of the hook mappings data.
|
|
792
|
+
*
|
|
793
|
+
* @remarks
|
|
794
|
+
* Returns the semver version string from the hook mappings JSON file.
|
|
795
|
+
* This can be used to check compatibility or display the data version
|
|
796
|
+
* in diagnostic output.
|
|
797
|
+
*
|
|
798
|
+
* @returns The semver version string of the loaded hook mappings data.
|
|
799
|
+
*
|
|
800
|
+
* @example
|
|
801
|
+
* ```typescript
|
|
802
|
+
* import { getHookMappingsVersion } from "./normalizer.js";
|
|
803
|
+
*
|
|
804
|
+
* const version = getHookMappingsVersion();
|
|
805
|
+
* console.log(`Hook mappings v${version}`);
|
|
806
|
+
* ```
|
|
807
|
+
*
|
|
808
|
+
* @public
|
|
809
|
+
*/
|
|
810
|
+
declare function getHookMappingsVersion(): string;
|
|
811
|
+
|
|
812
|
+
export { CANONICAL_HOOK_EVENTS, type CanonicalEventDefinition, type CanonicalHookEvent, type CrossProviderMatrix, GENERATED_PROVIDER_HOOK_PROFILES, HOOK_CATEGORIES, type HookCategory, type HookHandlerType, type HookMapping, type HookMappingsFile, type HookSupportResult, type HookSystemType, type NormalizedHookEvent, PROVIDER_NATIVE_EVENT_MAPS, type ProviderHookProfile, type ProviderHookSummary, type ProviderProjectHookCapability, buildHookMatrix, getAllCanonicalEvents, getCanonicalEvent, getCanonicalEventsByCategory, getCommonEvents, getHookConfigPath, getHookMappingsVersion, getHookSupport, getHookSystemType, getMappedProviderIds, getProviderHookProfile, getProviderOnlyEvents, getProviderSummary, getProvidersForEvent, getSupportedEvents, getUnsupportedEvents, resetHookMappings, resolveNativeEvent, supportsHook, toCanonical, toNative, toNativeBatch, translateToAll };
|