@premierstudio/ai-hooks 1.1.6 → 1.1.7
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/adapters/all.d.ts +119 -1
- package/dist/adapters/all.js +2 -2
- package/dist/adapters/index.d.ts +36 -2
- package/dist/adapters/index.js +1 -1
- package/dist/{chunk-ZOWUSGNF.js → chunk-CUPA3Z37.js} +3 -3
- package/dist/{chunk-ZOWUSGNF.js.map → chunk-CUPA3Z37.js.map} +1 -1
- package/dist/{chunk-FHFRGMW6.js → chunk-S37FJXIJ.js} +3 -3
- package/dist/chunk-S37FJXIJ.js.map +1 -0
- package/dist/cli/bin.js +1 -1
- package/dist/cli/bin.js.map +1 -1
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.js +2 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-FHFRGMW6.js.map +0 -1
- package/dist/index-bRA_mZA5.d.ts +0 -148
package/dist/adapters/all.d.ts
CHANGED
|
@@ -1,2 +1,120 @@
|
|
|
1
|
+
import { a as HookEventType, H as HookDefinition } from '../hooks-CMnWrmJU.js';
|
|
1
2
|
|
|
2
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Capability flags indicating what a tool adapter supports.
|
|
5
|
+
* Used by the runtime to determine which hooks can be installed.
|
|
6
|
+
*/
|
|
7
|
+
type AdapterCapabilities = {
|
|
8
|
+
/** Tool supports native pre-execution hooks (can block). */
|
|
9
|
+
beforeHooks: boolean;
|
|
10
|
+
/** Tool supports native post-execution hooks (observe). */
|
|
11
|
+
afterHooks: boolean;
|
|
12
|
+
/** Tool supports MCP servers (fallback enforcement). */
|
|
13
|
+
mcp: boolean;
|
|
14
|
+
/** Tool supports config file generation. */
|
|
15
|
+
configFile: boolean;
|
|
16
|
+
/** Specific event types this adapter can handle. */
|
|
17
|
+
supportedEvents: HookEventType[];
|
|
18
|
+
/** Events that can be blocked (subset of supportedEvents). */
|
|
19
|
+
blockableEvents: HookEventType[];
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The output format for a tool's native configuration.
|
|
23
|
+
* Each adapter produces this, and the CLI writes it to disk.
|
|
24
|
+
*/
|
|
25
|
+
type GeneratedConfig = {
|
|
26
|
+
/** Relative path where the config should be written. */
|
|
27
|
+
path: string;
|
|
28
|
+
/** File content (JSON string, TOML, YAML, etc.). */
|
|
29
|
+
content: string;
|
|
30
|
+
/** File format for display purposes. */
|
|
31
|
+
format: "json" | "toml" | "yaml" | "jsonc" | "js" | "ts";
|
|
32
|
+
/** Whether this file should be gitignored. */
|
|
33
|
+
gitignore?: boolean;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* The adapter interface that every tool-specific package implements.
|
|
37
|
+
*
|
|
38
|
+
* Adapters translate between ai-hooks universal events and the
|
|
39
|
+
* tool's native hook/plugin system.
|
|
40
|
+
*/
|
|
41
|
+
interface Adapter {
|
|
42
|
+
/** Unique identifier (e.g., "claude-code", "codex", "gemini-cli"). */
|
|
43
|
+
readonly id: string;
|
|
44
|
+
/** Human-readable tool name. */
|
|
45
|
+
readonly name: string;
|
|
46
|
+
/** Tool version this adapter targets. */
|
|
47
|
+
readonly version: string;
|
|
48
|
+
/** What this adapter can do. */
|
|
49
|
+
readonly capabilities: AdapterCapabilities;
|
|
50
|
+
/**
|
|
51
|
+
* Detect if this tool is installed/available in the current environment.
|
|
52
|
+
*/
|
|
53
|
+
detect(): Promise<boolean>;
|
|
54
|
+
/**
|
|
55
|
+
* Generate the tool's native config files from universal hook definitions.
|
|
56
|
+
* Returns one or more files to write to disk.
|
|
57
|
+
*/
|
|
58
|
+
generate(hooks: HookDefinition[]): Promise<GeneratedConfig[]>;
|
|
59
|
+
/**
|
|
60
|
+
* Install/apply generated configs to the tool.
|
|
61
|
+
* May copy files, update settings, register MCP servers, etc.
|
|
62
|
+
*/
|
|
63
|
+
install(configs: GeneratedConfig[]): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Remove all ai-hooks configuration from this tool.
|
|
66
|
+
*/
|
|
67
|
+
uninstall(): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Map a universal event type to the tool's native event name(s).
|
|
70
|
+
*/
|
|
71
|
+
mapEvent(event: HookEventType): string[];
|
|
72
|
+
/**
|
|
73
|
+
* Map a tool's native event name back to universal event type(s).
|
|
74
|
+
*/
|
|
75
|
+
mapNativeEvent(nativeEvent: string): HookEventType[];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Factory function signature for creating an adapter.
|
|
79
|
+
*/
|
|
80
|
+
type AdapterFactory = (options?: Record<string, unknown>) => Adapter;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Global adapter registry.
|
|
84
|
+
* Adapters register themselves when imported, or can be manually added.
|
|
85
|
+
*/
|
|
86
|
+
declare class AdapterRegistry {
|
|
87
|
+
private adapters;
|
|
88
|
+
private factories;
|
|
89
|
+
/**
|
|
90
|
+
* Register an adapter instance.
|
|
91
|
+
*/
|
|
92
|
+
register(adapter: Adapter): void;
|
|
93
|
+
/**
|
|
94
|
+
* Register an adapter factory for lazy instantiation.
|
|
95
|
+
*/
|
|
96
|
+
registerFactory(id: string, factory: AdapterFactory): void;
|
|
97
|
+
/**
|
|
98
|
+
* Get a registered adapter by ID.
|
|
99
|
+
*/
|
|
100
|
+
get(id: string): Adapter | undefined;
|
|
101
|
+
/**
|
|
102
|
+
* Get all registered adapter IDs.
|
|
103
|
+
*/
|
|
104
|
+
list(): string[];
|
|
105
|
+
/**
|
|
106
|
+
* Detect which tools are available in the current environment.
|
|
107
|
+
* Returns adapters that successfully detect their tool.
|
|
108
|
+
*/
|
|
109
|
+
detectAll(): Promise<Adapter[]>;
|
|
110
|
+
/**
|
|
111
|
+
* Clear the registry. Useful for testing.
|
|
112
|
+
*/
|
|
113
|
+
clear(): void;
|
|
114
|
+
}
|
|
115
|
+
declare global {
|
|
116
|
+
var __premierstudio_ai_hooks_registry: AdapterRegistry | undefined;
|
|
117
|
+
}
|
|
118
|
+
declare const registry: AdapterRegistry;
|
|
119
|
+
|
|
120
|
+
export { type Adapter as A, type GeneratedConfig as G, type AdapterCapabilities as a, type AdapterFactory as b, registry as r };
|
package/dist/adapters/all.js
CHANGED
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1,2 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { A as Adapter, a as AdapterCapabilities, G as GeneratedConfig } from './all.js';
|
|
2
|
+
export { r as registry } from './all.js';
|
|
3
|
+
import { H as HookDefinition, a as HookEventType } from '../hooks-CMnWrmJU.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Base adapter class with shared utilities.
|
|
7
|
+
* Tool-specific adapters extend this and implement the abstract methods.
|
|
8
|
+
*/
|
|
9
|
+
declare abstract class BaseAdapter implements Adapter {
|
|
10
|
+
abstract readonly id: string;
|
|
11
|
+
abstract readonly name: string;
|
|
12
|
+
abstract readonly version: string;
|
|
13
|
+
abstract readonly capabilities: AdapterCapabilities;
|
|
14
|
+
abstract detect(): Promise<boolean>;
|
|
15
|
+
abstract generate(hooks: HookDefinition[]): Promise<GeneratedConfig[]>;
|
|
16
|
+
abstract mapEvent(event: HookEventType): string[];
|
|
17
|
+
abstract mapNativeEvent(nativeEvent: string): HookEventType[];
|
|
18
|
+
/**
|
|
19
|
+
* Default install: write generated configs to disk.
|
|
20
|
+
*/
|
|
21
|
+
install(configs: GeneratedConfig[]): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Default uninstall: remove generated config files.
|
|
24
|
+
*/
|
|
25
|
+
uninstall(): Promise<void>;
|
|
26
|
+
protected fileExists(path: string): Promise<boolean>;
|
|
27
|
+
protected readJsonFile<T>(path: string): Promise<T | null>;
|
|
28
|
+
protected writeJsonFile(path: string, data: unknown): Promise<void>;
|
|
29
|
+
protected removeFile(path: string): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Check if a CLI command exists on PATH.
|
|
32
|
+
*/
|
|
33
|
+
protected commandExists(command: string): Promise<boolean>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { BaseAdapter };
|
package/dist/adapters/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { registry, BaseAdapter } from './chunk-
|
|
1
|
+
import { registry, BaseAdapter } from './chunk-S37FJXIJ.js';
|
|
2
2
|
import { existsSync } from 'fs';
|
|
3
3
|
import { resolve } from 'path';
|
|
4
4
|
import { readFile } from 'fs/promises';
|
|
@@ -1941,5 +1941,5 @@ ${hookEntries}
|
|
|
1941
1941
|
};
|
|
1942
1942
|
var adapter9 = new OpenCodeAdapter();
|
|
1943
1943
|
registry.register(adapter9);
|
|
1944
|
-
//# sourceMappingURL=chunk-
|
|
1945
|
-
//# sourceMappingURL=chunk-
|
|
1944
|
+
//# sourceMappingURL=chunk-CUPA3Z37.js.map
|
|
1945
|
+
//# sourceMappingURL=chunk-CUPA3Z37.js.map
|