@hasna/hooks 0.2.20 → 0.3.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 +45 -2
- package/bin/index.js +1157 -84
- package/dist/db/migrations/002_session_events.d.ts +10 -0
- package/dist/db/migrations/003_user_prompt_submit_event.d.ts +10 -0
- package/dist/db/pg-migrations.d.ts +1 -1
- package/dist/db/remote-storage.d.ts +9 -0
- package/dist/db/schema.d.ts +4 -3
- package/dist/db/storage-sync.d.ts +57 -0
- package/dist/index.d.ts +16 -3
- package/dist/index.js +1042 -58
- package/dist/lib/installer.d.ts +25 -5
- package/dist/lib/registry.d.ts +3 -1
- package/dist/storage.d.ts +4 -0
- package/dist/storage.js +696 -0
- package/hooks/codewith-native-common.test.ts +61 -0
- package/hooks/codewith-native-common.ts +478 -0
- package/hooks/hook-agent-rules-version-check/LICENSE +191 -0
- package/hooks/hook-agent-rules-version-check/README.md +50 -0
- package/hooks/hook-agent-rules-version-check/package.json +53 -0
- package/hooks/hook-agent-rules-version-check/src/hook.test.ts +104 -0
- package/hooks/hook-agent-rules-version-check/src/hook.ts +215 -0
- package/hooks/hook-agent-rules-version-check/tsconfig.json +25 -0
- package/hooks/hook-announce-start/README.md +7 -5
- package/hooks/hook-announce-start/package.json +2 -2
- package/hooks/hook-announce-start/src/hook.ts +33 -14
- package/hooks/hook-fleet-blockers-gate/LICENSE +191 -0
- package/hooks/hook-fleet-blockers-gate/README.md +39 -0
- package/hooks/hook-fleet-blockers-gate/package.json +52 -0
- package/hooks/hook-fleet-blockers-gate/src/hook.test.ts +106 -0
- package/hooks/hook-fleet-blockers-gate/src/hook.ts +242 -0
- package/hooks/hook-fleet-blockers-gate/tsconfig.json +25 -0
- package/hooks/hook-fleet-catchup/LICENSE +191 -0
- package/hooks/hook-fleet-catchup/README.md +40 -0
- package/hooks/hook-fleet-catchup/package.json +52 -0
- package/hooks/hook-fleet-catchup/src/hook.test.ts +156 -0
- package/hooks/hook-fleet-catchup/src/hook.ts +283 -0
- package/hooks/hook-fleet-catchup/tsconfig.json +25 -0
- package/hooks/pre-bash/README.md +17 -0
- package/hooks/pre-bash/package.json +12 -0
- package/hooks/pre-bash/src/hook.ts +103 -0
- package/hooks/prompt-guard/README.md +17 -0
- package/hooks/prompt-guard/package.json +12 -0
- package/hooks/prompt-guard/src/hook.ts +76 -0
- package/hooks/session-start/README.md +17 -0
- package/hooks/session-start/package.json +12 -0
- package/hooks/session-start/src/hook.ts +150 -0
- package/hooks/stop-sync/README.md +17 -0
- package/hooks/stop-sync/package.json +12 -0
- package/hooks/stop-sync/src/hook.ts +69 -0
- package/hooks/worktree-guard/README.md +17 -0
- package/hooks/worktree-guard/package.json +12 -0
- package/hooks/worktree-guard/src/hook.ts +88 -0
- package/package.json +14 -6
- package/dist/cli/components/App.d.ts +0 -7
- package/dist/cli/components/CategorySelect.d.ts +0 -7
- package/dist/cli/components/DataTable.d.ts +0 -11
- package/dist/cli/components/Header.d.ts +0 -7
- package/dist/cli/components/HookSelect.d.ts +0 -11
- package/dist/cli/components/InstallProgress.d.ts +0 -9
- package/dist/cli/components/SearchView.d.ts +0 -9
- package/dist/cli/index.d.ts +0 -2
- package/dist/lib/db-writer.d.ts +0 -9
- package/dist/mcp/http.d.ts +0 -16
- package/dist/mcp/server.d.ts +0 -17
package/dist/lib/installer.d.ts
CHANGED
|
@@ -2,14 +2,18 @@
|
|
|
2
2
|
* Hook installer - registers hooks in AI coding agent settings
|
|
3
3
|
*
|
|
4
4
|
* Supports:
|
|
5
|
-
* - Claude Code: ~/.claude/settings.json (PreToolUse, PostToolUse, Stop, Notification)
|
|
6
|
-
* - Gemini CLI: ~/.gemini/settings.json (BeforeTool, AfterTool, AfterAgent, Notification)
|
|
5
|
+
* - Claude Code: ~/.claude/settings.json (PreToolUse, PostToolUse, Stop, Notification, SessionStart, SessionEnd)
|
|
6
|
+
* - Gemini CLI: ~/.gemini/settings.json (BeforeTool, AfterTool, AfterAgent, Notification — no session events)
|
|
7
|
+
* - Codewith: emits TOML fragments by default; direct writes require explicit opt-in
|
|
7
8
|
*
|
|
8
9
|
* Hooks run directly from the globally installed @hasna/hooks package.
|
|
9
10
|
* No files are copied. The settings entry points to `hooks run <name>`.
|
|
10
11
|
*/
|
|
12
|
+
import type { HookEvent } from "./registry.js";
|
|
11
13
|
export type Scope = "global" | "project";
|
|
12
|
-
export type Target = "claude" | "gemini" | "all";
|
|
14
|
+
export type Target = "claude" | "gemini" | "codewith" | "all";
|
|
15
|
+
type SingleTarget = Exclude<Target, "all">;
|
|
16
|
+
export type CodewithInstallMode = "fragment" | "write";
|
|
13
17
|
export interface InstallResult {
|
|
14
18
|
hook: string;
|
|
15
19
|
success: boolean;
|
|
@@ -17,20 +21,36 @@ export interface InstallResult {
|
|
|
17
21
|
scope?: Scope;
|
|
18
22
|
target?: Target;
|
|
19
23
|
conflict?: string;
|
|
24
|
+
fragment?: string;
|
|
25
|
+
applied?: boolean;
|
|
26
|
+
note?: string;
|
|
27
|
+
configPath?: string;
|
|
20
28
|
}
|
|
21
29
|
export interface InstallOptions {
|
|
22
30
|
scope?: Scope;
|
|
23
31
|
overwrite?: boolean;
|
|
24
32
|
target?: Target;
|
|
25
33
|
profile?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Codewith installs default to "fragment" so @hasna/hooks does not blindly
|
|
36
|
+
* mutate managed ~/.codewith/config.toml. Use "write" only with an explicit
|
|
37
|
+
* config path or in tests/local experiments.
|
|
38
|
+
*/
|
|
39
|
+
codewithMode?: CodewithInstallMode;
|
|
40
|
+
/** Explicit Codewith config path for the direct-write mode and tests. */
|
|
41
|
+
codewithConfigPath?: string;
|
|
26
42
|
}
|
|
27
|
-
export declare function getSettingsPath(scope?: Scope, target?:
|
|
43
|
+
export declare function getSettingsPath(scope?: Scope, target?: SingleTarget, codewithConfigPath?: string): string;
|
|
28
44
|
export declare function getHookPath(name: string): string;
|
|
29
45
|
export declare function hookExists(name: string): boolean;
|
|
46
|
+
/** Whether a hook's event can be registered for the given target */
|
|
47
|
+
export declare function isEventSupported(internalEvent: HookEvent, target: SingleTarget): boolean;
|
|
48
|
+
export declare function buildCodewithTomlFragment(name: string, profile?: string): string;
|
|
30
49
|
export declare function installHook(name: string, options?: InstallOptions): InstallResult;
|
|
31
50
|
export declare function installHooks(names: string[], options?: InstallOptions): InstallResult[];
|
|
32
|
-
export declare function getRegisteredHooksForTarget(scope?: Scope, target?:
|
|
51
|
+
export declare function getRegisteredHooksForTarget(scope?: Scope, target?: SingleTarget): string[];
|
|
33
52
|
export declare function getRegisteredHooks(scope?: Scope): string[];
|
|
34
53
|
/** @deprecated Use getRegisteredHooks instead */
|
|
35
54
|
export declare const getInstalledHooks: typeof getRegisteredHooks;
|
|
36
55
|
export declare function removeHook(name: string, scope?: Scope, target?: Target): boolean;
|
|
56
|
+
export {};
|
package/dist/lib/registry.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Hook registry - metadata about all available hooks
|
|
3
3
|
*/
|
|
4
|
+
export type HookEvent = "PreToolUse" | "PostToolUse" | "Stop" | "Notification" | "SessionStart" | "SessionEnd" | "UserPromptSubmit";
|
|
5
|
+
export declare const HOOK_EVENTS: HookEvent[];
|
|
4
6
|
export interface HookMeta {
|
|
5
7
|
name: string;
|
|
6
8
|
displayName: string;
|
|
7
9
|
description: string;
|
|
8
10
|
version: string;
|
|
9
11
|
category: string;
|
|
10
|
-
event:
|
|
12
|
+
event: HookEvent;
|
|
11
13
|
matcher: string;
|
|
12
14
|
tags: string[];
|
|
13
15
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { HOOKS_STORAGE_ENV, HOOKS_STORAGE_FALLBACK_ENV, HOOKS_STORAGE_MODE_ENV, HOOKS_STORAGE_MODE_FALLBACK_ENV, HOOKS_STORAGE_TABLES, STORAGE_DATABASE_ENV, STORAGE_MODE_ENV, STORAGE_TABLES, getStorageDatabaseEnv, getStorageDatabaseEnvName, getStorageDatabaseUrl, getStorageMode, getStoragePg, getStorageStatus, getSyncMetaAll, parseStorageTables, resolveTables, runStorageMigrations, storagePull, storagePush, storageSync, } from "./db/storage-sync.js";
|
|
2
|
+
export type { StorageEnv, StorageMode, StorageStatus, SyncMeta, SyncResult } from "./db/storage-sync.js";
|
|
3
|
+
export { PgAdapterAsync } from "./db/remote-storage.js";
|
|
4
|
+
export { PG_MIGRATIONS } from "./db/pg-migrations.js";
|