@hasna/hooks 0.2.20 → 0.3.1

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 (69) hide show
  1. package/README.md +46 -2
  2. package/bin/index.js +1205 -93
  3. package/dist/db/migrations/002_session_events.d.ts +10 -0
  4. package/dist/db/migrations/003_user_prompt_submit_event.d.ts +10 -0
  5. package/dist/db/pg-migrations.d.ts +1 -1
  6. package/dist/db/remote-storage.d.ts +9 -0
  7. package/dist/db/schema.d.ts +4 -3
  8. package/dist/db/storage-sync.d.ts +57 -0
  9. package/dist/index.d.ts +16 -3
  10. package/dist/index.js +1092 -67
  11. package/dist/lib/installer.d.ts +26 -5
  12. package/dist/lib/registry.d.ts +5 -1
  13. package/dist/storage.d.ts +4 -0
  14. package/dist/storage.js +696 -0
  15. package/hooks/codewith-native-common.test.ts +61 -0
  16. package/hooks/codewith-native-common.ts +478 -0
  17. package/hooks/hook-agent-rules-version-check/LICENSE +191 -0
  18. package/hooks/hook-agent-rules-version-check/README.md +50 -0
  19. package/hooks/hook-agent-rules-version-check/package.json +53 -0
  20. package/hooks/hook-agent-rules-version-check/src/hook.test.ts +104 -0
  21. package/hooks/hook-agent-rules-version-check/src/hook.ts +215 -0
  22. package/hooks/hook-agent-rules-version-check/tsconfig.json +25 -0
  23. package/hooks/hook-announce-start/README.md +7 -5
  24. package/hooks/hook-announce-start/package.json +2 -2
  25. package/hooks/hook-announce-start/src/hook.ts +33 -14
  26. package/hooks/hook-fleet-blockers-gate/LICENSE +191 -0
  27. package/hooks/hook-fleet-blockers-gate/README.md +39 -0
  28. package/hooks/hook-fleet-blockers-gate/package.json +52 -0
  29. package/hooks/hook-fleet-blockers-gate/src/hook.test.ts +106 -0
  30. package/hooks/hook-fleet-blockers-gate/src/hook.ts +242 -0
  31. package/hooks/hook-fleet-blockers-gate/tsconfig.json +25 -0
  32. package/hooks/hook-fleet-catchup/LICENSE +191 -0
  33. package/hooks/hook-fleet-catchup/README.md +40 -0
  34. package/hooks/hook-fleet-catchup/package.json +52 -0
  35. package/hooks/hook-fleet-catchup/src/hook.test.ts +156 -0
  36. package/hooks/hook-fleet-catchup/src/hook.ts +283 -0
  37. package/hooks/hook-fleet-catchup/tsconfig.json +25 -0
  38. package/hooks/hook-knowledge-context/README.md +53 -0
  39. package/hooks/hook-knowledge-context/package.json +52 -0
  40. package/hooks/hook-knowledge-context/src/hook.test.ts +168 -0
  41. package/hooks/hook-knowledge-context/src/hook.ts +355 -0
  42. package/hooks/hook-knowledge-context/tsconfig.json +25 -0
  43. package/hooks/pre-bash/README.md +17 -0
  44. package/hooks/pre-bash/package.json +12 -0
  45. package/hooks/pre-bash/src/hook.ts +103 -0
  46. package/hooks/prompt-guard/README.md +17 -0
  47. package/hooks/prompt-guard/package.json +12 -0
  48. package/hooks/prompt-guard/src/hook.ts +76 -0
  49. package/hooks/session-start/README.md +17 -0
  50. package/hooks/session-start/package.json +12 -0
  51. package/hooks/session-start/src/hook.ts +150 -0
  52. package/hooks/stop-sync/README.md +17 -0
  53. package/hooks/stop-sync/package.json +12 -0
  54. package/hooks/stop-sync/src/hook.ts +69 -0
  55. package/hooks/worktree-guard/README.md +17 -0
  56. package/hooks/worktree-guard/package.json +12 -0
  57. package/hooks/worktree-guard/src/hook.ts +88 -0
  58. package/package.json +14 -6
  59. package/dist/cli/components/App.d.ts +0 -7
  60. package/dist/cli/components/CategorySelect.d.ts +0 -7
  61. package/dist/cli/components/DataTable.d.ts +0 -11
  62. package/dist/cli/components/Header.d.ts +0 -7
  63. package/dist/cli/components/HookSelect.d.ts +0 -11
  64. package/dist/cli/components/InstallProgress.d.ts +0 -9
  65. package/dist/cli/components/SearchView.d.ts +0 -9
  66. package/dist/cli/index.d.ts +0 -2
  67. package/dist/lib/db-writer.d.ts +0 -9
  68. package/dist/mcp/http.d.ts +0 -16
  69. package/dist/mcp/server.d.ts +0 -17
package/README.md CHANGED
@@ -26,12 +26,56 @@ hooks --help
26
26
  - `hooks doctor`
27
27
  - `hooks run`
28
28
 
29
+ ## Codewith-native hooks
30
+
31
+ @hasna/hooks includes 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
+ - `knowledge-context` — deterministic Knowledge context packs for `SessionStart`, `UserPromptSubmit`, and `SubagentStart`.
39
+
40
+ For Codewith, the installer is renderer-safe by default: it emits a TOML
41
+ fragment instead of mutating managed `~/.codewith/config.toml`.
42
+
43
+ ```bash
44
+ hooks install session-start prompt-guard pre-bash worktree-guard stop-sync knowledge-context --target codewith
45
+ ```
46
+
47
+ Apply that fragment through `open-configs` or the managed config renderer. A
48
+ direct write path exists only for explicit local/test use:
49
+
50
+ ```bash
51
+ hooks install knowledge-context --target codewith --apply-codewith --codewith-config /tmp/codewith-config.toml
52
+ ```
53
+
29
54
  ## Storage
30
55
 
31
56
  Hooks stores data locally by default in `~/.hasna/hooks/` and uses SQLite
32
57
  directly for hook event history. The package owns its database schema and
33
- migrations; it does not depend on the deprecated shared runtime or its CLI. Use
34
- the `hooks log` commands to inspect local hook event data.
58
+ migrations; it does not depend on the deprecated shared runtime or its CLI.
59
+ The repo includes its own PostgreSQL migration definitions for optional remote
60
+ storage deployments. Use the `hooks log` commands to inspect local hook event
61
+ data.
62
+
63
+ ```bash
64
+ hooks storage status --json
65
+ HASNA_HOOKS_DATABASE_URL=postgres://... hooks storage push --tables hook_events,feedback --json
66
+ hooks storage pull --json
67
+ hooks storage sync --json
68
+ ```
69
+
70
+ Configure database storage with `HASNA_HOOKS_DATABASE_URL` or fallback
71
+ `HOOKS_DATABASE_URL`. Optional storage mode env vars are
72
+ `HASNA_HOOKS_STORAGE_MODE` and `HOOKS_STORAGE_MODE`, with `local`, `hybrid`, or
73
+ `remote` values.
74
+
75
+ ## Runtime model
76
+
77
+ This package is an npm/local CLI, MCP server, and static dashboard package. It
78
+ does not require a deployed cloud or self-hosted runtime to install or run hooks.
35
79
 
36
80
  ## Data Directory
37
81