@hasna/hooks 0.2.19 → 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.
Files changed (61) hide show
  1. package/README.md +45 -5
  2. package/bin/index.js +1262 -9569
  3. package/dist/db/index.d.ts +11 -0
  4. package/dist/db/legacy-import.d.ts +11 -0
  5. package/dist/db/migrations/001_initial.d.ts +6 -0
  6. package/dist/db/migrations/002_session_events.d.ts +10 -0
  7. package/dist/db/migrations/003_user_prompt_submit_event.d.ts +10 -0
  8. package/dist/db/migrations/index.d.ts +7 -0
  9. package/dist/db/pg-migrations.d.ts +7 -0
  10. package/dist/db/remote-storage.d.ts +9 -0
  11. package/dist/db/retention.d.ts +8 -0
  12. package/dist/db/schema.d.ts +22 -0
  13. package/dist/db/storage-sync.d.ts +57 -0
  14. package/dist/index.d.ts +72 -0
  15. package/dist/index.js +1042 -58
  16. package/dist/lib/installer.d.ts +56 -0
  17. package/dist/lib/profiles.d.ts +33 -0
  18. package/dist/lib/registry.d.ts +21 -0
  19. package/dist/storage.d.ts +4 -0
  20. package/dist/storage.js +696 -0
  21. package/hooks/codewith-native-common.test.ts +61 -0
  22. package/hooks/codewith-native-common.ts +478 -0
  23. package/hooks/hook-agent-rules-version-check/LICENSE +191 -0
  24. package/hooks/hook-agent-rules-version-check/README.md +50 -0
  25. package/hooks/hook-agent-rules-version-check/package.json +53 -0
  26. package/hooks/hook-agent-rules-version-check/src/hook.test.ts +104 -0
  27. package/hooks/hook-agent-rules-version-check/src/hook.ts +215 -0
  28. package/hooks/hook-agent-rules-version-check/tsconfig.json +25 -0
  29. package/hooks/hook-announce-start/README.md +7 -5
  30. package/hooks/hook-announce-start/package.json +2 -2
  31. package/hooks/hook-announce-start/src/hook.ts +33 -14
  32. package/hooks/hook-fleet-blockers-gate/LICENSE +191 -0
  33. package/hooks/hook-fleet-blockers-gate/README.md +39 -0
  34. package/hooks/hook-fleet-blockers-gate/package.json +52 -0
  35. package/hooks/hook-fleet-blockers-gate/src/hook.test.ts +106 -0
  36. package/hooks/hook-fleet-blockers-gate/src/hook.ts +242 -0
  37. package/hooks/hook-fleet-blockers-gate/tsconfig.json +25 -0
  38. package/hooks/hook-fleet-catchup/LICENSE +191 -0
  39. package/hooks/hook-fleet-catchup/README.md +40 -0
  40. package/hooks/hook-fleet-catchup/package.json +52 -0
  41. package/hooks/hook-fleet-catchup/src/hook.test.ts +156 -0
  42. package/hooks/hook-fleet-catchup/src/hook.ts +283 -0
  43. package/hooks/hook-fleet-catchup/tsconfig.json +25 -0
  44. package/hooks/pre-bash/README.md +17 -0
  45. package/hooks/pre-bash/package.json +12 -0
  46. package/hooks/pre-bash/src/hook.ts +103 -0
  47. package/hooks/prompt-guard/README.md +17 -0
  48. package/hooks/prompt-guard/package.json +12 -0
  49. package/hooks/prompt-guard/src/hook.ts +76 -0
  50. package/hooks/session-start/README.md +17 -0
  51. package/hooks/session-start/package.json +12 -0
  52. package/hooks/session-start/src/hook.ts +150 -0
  53. package/hooks/stop-sync/README.md +17 -0
  54. package/hooks/stop-sync/package.json +12 -0
  55. package/hooks/stop-sync/src/hook.ts +69 -0
  56. package/hooks/worktree-guard/README.md +17 -0
  57. package/hooks/worktree-guard/package.json +12 -0
  58. package/hooks/worktree-guard/src/hook.ts +88 -0
  59. package/package.json +14 -7
  60. package/hooks/hook-affected-tests/dist/hook.js +0 -106
  61. package/hooks/hook-announce-start/dist/hook.js +0 -98
package/README.md CHANGED
@@ -26,16 +26,56 @@ hooks --help
26
26
  - `hooks doctor`
27
27
  - `hooks run`
28
28
 
29
- ## Cloud Sync
29
+ ## Codewith-native hooks
30
30
 
31
- This package supports cloud sync via `@hasna/cloud`:
31
+ @hasna/hooks includes five unprefixed Codewith-native hook names:
32
+
33
+ - `session-start` — `SessionStart` digest and additional context.
34
+ - `prompt-guard` — `UserPromptSubmit` guard for pasted fake policy/freeze/run-this-now content.
35
+ - `pre-bash` — `PreToolUse` Bash gate for staged secrets scans and risky-op comms checks.
36
+ - `worktree-guard` — `PreToolUse` guard for managed repos worktree boundaries.
37
+ - `stop-sync` — `Stop` turn-end heartbeat/evidence best effort.
38
+
39
+ For Codewith, the installer is renderer-safe by default: it emits a TOML
40
+ fragment instead of mutating managed `~/.codewith/config.toml`.
41
+
42
+ ```bash
43
+ hooks install session-start prompt-guard pre-bash worktree-guard stop-sync --target codewith
44
+ ```
45
+
46
+ Apply that fragment through `open-configs` or the managed config renderer. A
47
+ direct write path exists only for explicit local/test use:
48
+
49
+ ```bash
50
+ hooks install session-start --target codewith --apply-codewith --codewith-config /tmp/codewith-config.toml
51
+ ```
52
+
53
+ ## Storage
54
+
55
+ Hooks stores data locally by default in `~/.hasna/hooks/` and uses SQLite
56
+ directly for hook event history. The package owns its database schema and
57
+ migrations; it does not depend on the deprecated shared runtime or its CLI.
58
+ The repo includes its own PostgreSQL migration definitions for optional remote
59
+ storage deployments. Use the `hooks log` commands to inspect local hook event
60
+ data.
32
61
 
33
62
  ```bash
34
- cloud setup
35
- cloud sync push --service hooks
36
- cloud sync pull --service hooks
63
+ hooks storage status --json
64
+ HASNA_HOOKS_DATABASE_URL=postgres://... hooks storage push --tables hook_events,feedback --json
65
+ hooks storage pull --json
66
+ hooks storage sync --json
37
67
  ```
38
68
 
69
+ Configure database storage with `HASNA_HOOKS_DATABASE_URL` or fallback
70
+ `HOOKS_DATABASE_URL`. Optional storage mode env vars are
71
+ `HASNA_HOOKS_STORAGE_MODE` and `HOOKS_STORAGE_MODE`, with `local`, `hybrid`, or
72
+ `remote` values.
73
+
74
+ ## Runtime model
75
+
76
+ This package is an npm/local CLI, MCP server, and static dashboard package. It
77
+ does not require a deployed cloud or self-hosted runtime to install or run hooks.
78
+
39
79
  ## Data Directory
40
80
 
41
81
  Data is stored in `~/.hasna/hooks/`.