@hasna/hooks 0.0.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 (110) hide show
  1. package/.npmrc.example +2 -0
  2. package/AGENTS.md +54 -0
  3. package/CLAUDE.md +70 -0
  4. package/CONTRIBUTING.md +45 -0
  5. package/README.md +232 -0
  6. package/bin/index.js +5171 -0
  7. package/hooks/hook-agentmessages/CLAUDE.md +79 -0
  8. package/hooks/hook-agentmessages/LICENSE +21 -0
  9. package/hooks/hook-agentmessages/README.md +107 -0
  10. package/hooks/hook-agentmessages/package.json +31 -0
  11. package/hooks/hook-agentmessages/src/check-messages.ts +151 -0
  12. package/hooks/hook-agentmessages/src/install.ts +126 -0
  13. package/hooks/hook-agentmessages/src/session-start.ts +255 -0
  14. package/hooks/hook-agentmessages/src/uninstall.ts +89 -0
  15. package/hooks/hook-branchprotect/CLAUDE.md +23 -0
  16. package/hooks/hook-branchprotect/README.md +25 -0
  17. package/hooks/hook-branchprotect/package.json +42 -0
  18. package/hooks/hook-branchprotect/src/cli.ts +126 -0
  19. package/hooks/hook-branchprotect/src/hook.ts +88 -0
  20. package/hooks/hook-branchprotect/tsconfig.json +25 -0
  21. package/hooks/hook-checkbugs/LICENSE +21 -0
  22. package/hooks/hook-checkbugs/README.md +140 -0
  23. package/hooks/hook-checkbugs/package.json +58 -0
  24. package/hooks/hook-checkbugs/src/cli.ts +628 -0
  25. package/hooks/hook-checkbugs/src/hook.ts +335 -0
  26. package/hooks/hook-checkbugs/tsconfig.json +15 -0
  27. package/hooks/hook-checkdocs/README.md +137 -0
  28. package/hooks/hook-checkdocs/package.json +57 -0
  29. package/hooks/hook-checkdocs/src/cli.ts +628 -0
  30. package/hooks/hook-checkdocs/src/hook.ts +310 -0
  31. package/hooks/hook-checkdocs/tsconfig.json +15 -0
  32. package/hooks/hook-checkfiles/LICENSE +21 -0
  33. package/hooks/hook-checkfiles/README.md +141 -0
  34. package/hooks/hook-checkfiles/package.json +56 -0
  35. package/hooks/hook-checkfiles/src/cli.ts +545 -0
  36. package/hooks/hook-checkfiles/src/hook.ts +321 -0
  37. package/hooks/hook-checkfiles/tsconfig.json +15 -0
  38. package/hooks/hook-checklint/LICENSE +21 -0
  39. package/hooks/hook-checklint/README.md +147 -0
  40. package/hooks/hook-checklint/package.json +57 -0
  41. package/hooks/hook-checklint/src/cli-patch.ts +32 -0
  42. package/hooks/hook-checklint/src/cli.ts +667 -0
  43. package/hooks/hook-checklint/src/hook.ts +473 -0
  44. package/hooks/hook-checklint/tsconfig.json +15 -0
  45. package/hooks/hook-checkpoint/CLAUDE.md +23 -0
  46. package/hooks/hook-checkpoint/README.md +37 -0
  47. package/hooks/hook-checkpoint/package.json +58 -0
  48. package/hooks/hook-checkpoint/src/cli.ts +191 -0
  49. package/hooks/hook-checkpoint/src/hook.ts +207 -0
  50. package/hooks/hook-checkpoint/tsconfig.json +25 -0
  51. package/hooks/hook-checksecurity/LICENSE +21 -0
  52. package/hooks/hook-checksecurity/README.md +158 -0
  53. package/hooks/hook-checksecurity/package.json +57 -0
  54. package/hooks/hook-checksecurity/src/cli.ts +601 -0
  55. package/hooks/hook-checksecurity/src/hook.ts +334 -0
  56. package/hooks/hook-checksecurity/tsconfig.json +15 -0
  57. package/hooks/hook-checktasks/README.md +144 -0
  58. package/hooks/hook-checktasks/package.json +55 -0
  59. package/hooks/hook-checktasks/src/cli.ts +578 -0
  60. package/hooks/hook-checktasks/src/hook.ts +308 -0
  61. package/hooks/hook-checktasks/tsconfig.json +20 -0
  62. package/hooks/hook-checktests/LICENSE +21 -0
  63. package/hooks/hook-checktests/README.md +137 -0
  64. package/hooks/hook-checktests/package.json +57 -0
  65. package/hooks/hook-checktests/src/cli.ts +627 -0
  66. package/hooks/hook-checktests/src/hook.ts +334 -0
  67. package/hooks/hook-checktests/tsconfig.json +15 -0
  68. package/hooks/hook-contextrefresh/CLAUDE.md +23 -0
  69. package/hooks/hook-contextrefresh/README.md +42 -0
  70. package/hooks/hook-contextrefresh/package.json +42 -0
  71. package/hooks/hook-contextrefresh/src/cli.ts +152 -0
  72. package/hooks/hook-contextrefresh/src/hook.ts +148 -0
  73. package/hooks/hook-contextrefresh/tsconfig.json +25 -0
  74. package/hooks/hook-gitguard/CLAUDE.md +22 -0
  75. package/hooks/hook-gitguard/README.md +30 -0
  76. package/hooks/hook-gitguard/package.json +57 -0
  77. package/hooks/hook-gitguard/src/cli.ts +159 -0
  78. package/hooks/hook-gitguard/src/hook.ts +129 -0
  79. package/hooks/hook-gitguard/tsconfig.json +25 -0
  80. package/hooks/hook-packageage/CLAUDE.md +23 -0
  81. package/hooks/hook-packageage/README.md +33 -0
  82. package/hooks/hook-packageage/package.json +42 -0
  83. package/hooks/hook-packageage/src/cli.ts +165 -0
  84. package/hooks/hook-packageage/src/hook.ts +177 -0
  85. package/hooks/hook-packageage/tsconfig.json +25 -0
  86. package/hooks/hook-phonenotify/CLAUDE.md +25 -0
  87. package/hooks/hook-phonenotify/README.md +44 -0
  88. package/hooks/hook-phonenotify/package.json +42 -0
  89. package/hooks/hook-phonenotify/src/cli.ts +196 -0
  90. package/hooks/hook-phonenotify/src/hook.ts +139 -0
  91. package/hooks/hook-phonenotify/tsconfig.json +25 -0
  92. package/hooks/hook-precompact/CLAUDE.md +23 -0
  93. package/hooks/hook-precompact/README.md +36 -0
  94. package/hooks/hook-precompact/package.json +42 -0
  95. package/hooks/hook-precompact/src/cli.ts +168 -0
  96. package/hooks/hook-precompact/src/hook.ts +122 -0
  97. package/hooks/hook-precompact/tsconfig.json +25 -0
  98. package/package.json +61 -0
  99. package/src/cli/components/App.tsx +191 -0
  100. package/src/cli/components/CategorySelect.tsx +37 -0
  101. package/src/cli/components/DataTable.tsx +133 -0
  102. package/src/cli/components/Header.tsx +18 -0
  103. package/src/cli/components/HookSelect.tsx +29 -0
  104. package/src/cli/components/InstallProgress.tsx +105 -0
  105. package/src/cli/components/SearchView.tsx +86 -0
  106. package/src/cli/index.tsx +218 -0
  107. package/src/index.ts +31 -0
  108. package/src/lib/installer.ts +288 -0
  109. package/src/lib/registry.ts +205 -0
  110. package/tsconfig.json +17 -0
@@ -0,0 +1,140 @@
1
+ # @hasnaxyz/hook-checkbugs
2
+
3
+ Claude Code hook that checks for bugs via a headless Codex agent. Runs async (non-blocking) on PostToolUse after file edits.
4
+
5
+ ## Features
6
+
7
+ - **Edit tracking**: Monitors Edit, Write, NotebookEdit tools
8
+ - **Configurable threshold**: Run after N edits (3-7, default: 3)
9
+ - **Headless Codex**: Spawns Codex agent to analyze for bugs
10
+ - **Task dispatch**: Creates tasks via `service-implementation task dispatch`
11
+ - **Repo pattern check**: Only runs for repos matching `[prefix]-[name]` pattern
12
+ - **Session-aware**: Only runs for sessions matching configured keywords
13
+
14
+ ## Installation
15
+
16
+ ### Global CLI
17
+
18
+ ```bash
19
+ bun add -g @hasnaxyz/hook-checkbugs
20
+ hook-checkbugs install --global
21
+ ```
22
+
23
+ ### Project-specific
24
+
25
+ ```bash
26
+ cd /path/to/your/project
27
+ bunx @hasnaxyz/hook-checkbugs install
28
+ ```
29
+
30
+ ## Requirements
31
+
32
+ - `codex` CLI (for headless agent)
33
+ - `service-implementation` CLI (for task dispatch)
34
+
35
+ ## Usage
36
+
37
+ Once installed, the hook runs automatically after file edits.
38
+
39
+ ### Commands
40
+
41
+ ```bash
42
+ hook-checkbugs install [path] # Install the hook
43
+ hook-checkbugs config [path] # Update configuration
44
+ hook-checkbugs uninstall [path] # Remove the hook
45
+ hook-checkbugs status # Show hook status
46
+ hook-checkbugs run # Execute hook (called by Claude Code)
47
+ ```
48
+
49
+ ### Options
50
+
51
+ - `--global`, `-g`: Apply to global settings (`~/.claude/settings.json`)
52
+ - `/path/to/repo`: Apply to specific project path
53
+
54
+ ## Configuration
55
+
56
+ Configuration is stored in `.claude/settings.json`:
57
+
58
+ ```json
59
+ {
60
+ "hooks": {
61
+ "PostToolUse": [{
62
+ "matcher": { "tool_name": "^(Edit|Write|NotebookEdit)$" },
63
+ "hooks": [{
64
+ "type": "command",
65
+ "command": "bunx @hasnaxyz/hook-checkbugs@latest run",
66
+ "timeout": 120,
67
+ "async": true
68
+ }]
69
+ }]
70
+ },
71
+ "checkBugsConfig": {
72
+ "editThreshold": 3,
73
+ "taskListId": "myproject-bugfixes",
74
+ "keywords": ["dev"],
75
+ "enabled": true
76
+ }
77
+ }
78
+ ```
79
+
80
+ ### Options
81
+
82
+ | Option | Type | Default | Description |
83
+ |--------|------|---------|-------------|
84
+ | `editThreshold` | number | 3 | Run review after this many edits (3-7) |
85
+ | `taskListId` | string | auto | Task list for dispatching tasks (auto-detects `*-bugfixes`) |
86
+ | `keywords` | string[] | ["dev"] | Only run for matching sessions |
87
+ | `enabled` | boolean | true | Enable/disable the hook |
88
+
89
+ ## How It Works
90
+
91
+ 1. **Tracks edits**: Monitors Edit, Write, NotebookEdit tool calls
92
+ 2. **Counts edits**: Increments counter for each unique file edited
93
+ 3. **Threshold check**: After N edits, spawns headless Codex agent
94
+ 4. **Bug review**: Agent analyzes edited files for potential bugs
95
+ 5. **Task dispatch**: Creates tasks via `service-implementation task dispatch`
96
+ 6. **Reset**: Counter resets after each review
97
+
98
+ ## Bug Issues Detected
99
+
100
+ The hook checks for:
101
+
102
+ - Logic errors and off-by-one errors
103
+ - Null/undefined reference issues
104
+ - Race conditions and async bugs
105
+ - Memory leaks
106
+ - Unhandled edge cases
107
+ - Type mismatches
108
+ - Incorrect error handling
109
+ - Security vulnerabilities
110
+ - Performance issues
111
+ - Resource cleanup issues
112
+
113
+ ## Task Format
114
+
115
+ Tasks are dispatched with:
116
+
117
+ ```bash
118
+ service-implementation task dispatch "myproject-bugfixes" \
119
+ -s "BUG: [severity] - [brief description]" \
120
+ -d "[detailed description with file:line reference and suggested fix]"
121
+ ```
122
+
123
+ Severity levels: CRITICAL, HIGH, MEDIUM, LOW
124
+
125
+ ## Session State
126
+
127
+ State is persisted in `~/.claude/hook-state/checkbugs-{session_id}.json`:
128
+
129
+ ```json
130
+ {
131
+ "editCount": 2,
132
+ "editedFiles": ["src/utils.ts", "src/api.ts"],
133
+ "lastCheckRun": 1706500000000,
134
+ "checkInProgress": false
135
+ }
136
+ ```
137
+
138
+ ## License
139
+
140
+ MIT
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@hasnaxyz/hook-checkbugs",
3
+ "version": "0.1.6",
4
+ "description": "Claude Code hook that checks for bugs via Codex headless agent",
5
+ "type": "module",
6
+ "bin": {
7
+ "hook-checkbugs": "./dist/cli.js"
8
+ },
9
+ "main": "./dist/hook.js",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./dist/hook.js",
13
+ "types": "./dist/hook.d.ts"
14
+ },
15
+ "./cli": {
16
+ "import": "./dist/cli.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "README.md"
22
+ ],
23
+ "scripts": {
24
+ "build": "bun build ./src/cli.ts ./src/hook.ts --outdir ./dist --target node",
25
+ "prepublishOnly": "bun run build",
26
+ "typecheck": "tsc --noEmit"
27
+ },
28
+ "keywords": [
29
+ "claude-code",
30
+ "claude",
31
+ "codex",
32
+ "hook",
33
+ "bugs",
34
+ "review",
35
+ "headless",
36
+ "automation",
37
+ "cli"
38
+ ],
39
+ "author": "Hasna",
40
+ "license": "MIT",
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "https://github.com/hasnaxyz/hook-checkbugs.git"
44
+ },
45
+ "publishConfig": {
46
+ "access": "restricted",
47
+ "registry": "https://registry.npmjs.org/"
48
+ },
49
+ "engines": {
50
+ "node": ">=18",
51
+ "bun": ">=1.0"
52
+ },
53
+ "devDependencies": {
54
+ "@types/bun": "^1.3.8",
55
+ "@types/node": "^20",
56
+ "typescript": "^5.0.0"
57
+ }
58
+ }