@hasna/hooks 0.1.1 → 0.2.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 (111) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +41 -6
  3. package/bin/index.js +56 -63
  4. package/dist/index.js +20 -14
  5. package/hooks/hook-agentmessages/CLAUDE.md +1 -1
  6. package/hooks/hook-agentmessages/LICENSE +191 -21
  7. package/hooks/hook-agentmessages/README.md +3 -3
  8. package/hooks/hook-agentmessages/package.json +5 -5
  9. package/hooks/hook-autoformat/README.md +1 -1
  10. package/hooks/hook-autoformat/package.json +1 -1
  11. package/hooks/hook-autoformat/tsconfig.json +25 -0
  12. package/hooks/hook-autostage/README.md +1 -1
  13. package/hooks/hook-autostage/package.json +1 -1
  14. package/hooks/hook-branchprotect/README.md +2 -2
  15. package/hooks/hook-branchprotect/package.json +4 -4
  16. package/hooks/hook-branchprotect/src/cli.ts +1 -1
  17. package/hooks/hook-branchprotect/tsconfig.json +25 -0
  18. package/hooks/hook-checkbugs/LICENSE +191 -21
  19. package/hooks/hook-checkbugs/README.md +5 -5
  20. package/hooks/hook-checkbugs/package.json +4 -4
  21. package/hooks/hook-checkbugs/src/cli.ts +2 -2
  22. package/hooks/hook-checkbugs/tsconfig.json +15 -0
  23. package/hooks/hook-checkdocs/README.md +5 -5
  24. package/hooks/hook-checkdocs/package.json +4 -4
  25. package/hooks/hook-checkdocs/src/cli.ts +2 -2
  26. package/hooks/hook-checkdocs/tsconfig.json +15 -0
  27. package/hooks/hook-checkfiles/LICENSE +191 -21
  28. package/hooks/hook-checkfiles/README.md +5 -5
  29. package/hooks/hook-checkfiles/package.json +4 -4
  30. package/hooks/hook-checkfiles/src/cli.ts +2 -2
  31. package/hooks/hook-checkfiles/tsconfig.json +15 -0
  32. package/hooks/hook-checklint/LICENSE +191 -21
  33. package/hooks/hook-checklint/README.md +5 -5
  34. package/hooks/hook-checklint/package.json +4 -4
  35. package/hooks/hook-checklint/src/cli.ts +2 -2
  36. package/hooks/hook-checklint/tsconfig.json +15 -0
  37. package/hooks/hook-checkpoint/README.md +2 -2
  38. package/hooks/hook-checkpoint/package.json +4 -4
  39. package/hooks/hook-checkpoint/src/cli.ts +1 -1
  40. package/hooks/hook-checkpoint/tsconfig.json +25 -0
  41. package/hooks/hook-checksecurity/LICENSE +191 -21
  42. package/hooks/hook-checksecurity/README.md +8 -8
  43. package/hooks/hook-checksecurity/package.json +4 -4
  44. package/hooks/hook-checksecurity/src/cli.ts +2 -2
  45. package/hooks/hook-checksecurity/tsconfig.json +15 -0
  46. package/hooks/hook-checktasks/README.md +5 -5
  47. package/hooks/hook-checktasks/package.json +4 -4
  48. package/hooks/hook-checktasks/src/cli.ts +2 -2
  49. package/hooks/hook-checktasks/tsconfig.json +20 -0
  50. package/hooks/hook-checktests/LICENSE +191 -21
  51. package/hooks/hook-checktests/README.md +5 -5
  52. package/hooks/hook-checktests/package.json +4 -4
  53. package/hooks/hook-checktests/src/cli.ts +2 -2
  54. package/hooks/hook-checktests/tsconfig.json +15 -0
  55. package/hooks/hook-commandlog/README.md +1 -1
  56. package/hooks/hook-commandlog/package.json +1 -1
  57. package/hooks/hook-contextrefresh/README.md +2 -2
  58. package/hooks/hook-contextrefresh/package.json +4 -4
  59. package/hooks/hook-contextrefresh/src/cli.ts +1 -1
  60. package/hooks/hook-contextrefresh/tsconfig.json +25 -0
  61. package/hooks/hook-costwatch/README.md +1 -1
  62. package/hooks/hook-costwatch/package.json +1 -1
  63. package/hooks/hook-desktopnotify/README.md +1 -1
  64. package/hooks/hook-desktopnotify/package.json +1 -1
  65. package/hooks/hook-desktopnotify/tsconfig.json +25 -0
  66. package/hooks/hook-envsetup/README.md +1 -1
  67. package/hooks/hook-envsetup/package.json +1 -1
  68. package/hooks/hook-envsetup/tsconfig.json +25 -0
  69. package/hooks/hook-errornotify/README.md +1 -1
  70. package/hooks/hook-errornotify/package.json +1 -1
  71. package/hooks/hook-gitguard/README.md +2 -2
  72. package/hooks/hook-gitguard/package.json +4 -4
  73. package/hooks/hook-gitguard/src/cli.ts +1 -1
  74. package/hooks/hook-gitguard/tsconfig.json +25 -0
  75. package/hooks/hook-packageage/README.md +2 -2
  76. package/hooks/hook-packageage/package.json +4 -4
  77. package/hooks/hook-packageage/src/cli.ts +1 -1
  78. package/hooks/hook-packageage/tsconfig.json +25 -0
  79. package/hooks/hook-permissionguard/README.md +1 -1
  80. package/hooks/hook-permissionguard/package.json +1 -1
  81. package/hooks/hook-permissionguard/tsconfig.json +25 -0
  82. package/hooks/hook-phonenotify/README.md +2 -2
  83. package/hooks/hook-phonenotify/package.json +4 -4
  84. package/hooks/hook-phonenotify/src/cli.ts +1 -1
  85. package/hooks/hook-phonenotify/tsconfig.json +25 -0
  86. package/hooks/hook-precompact/README.md +2 -2
  87. package/hooks/hook-precompact/package.json +4 -4
  88. package/hooks/hook-precompact/src/cli.ts +1 -1
  89. package/hooks/hook-precompact/tsconfig.json +25 -0
  90. package/hooks/hook-promptguard/README.md +1 -1
  91. package/hooks/hook-promptguard/package.json +1 -1
  92. package/hooks/hook-protectfiles/README.md +1 -1
  93. package/hooks/hook-protectfiles/package.json +1 -1
  94. package/hooks/hook-protectfiles/tsconfig.json +25 -0
  95. package/hooks/hook-sessionlog/README.md +1 -1
  96. package/hooks/hook-sessionlog/package.json +1 -1
  97. package/hooks/hook-slacknotify/README.md +1 -1
  98. package/hooks/hook-slacknotify/package.json +1 -1
  99. package/hooks/hook-soundnotify/README.md +1 -1
  100. package/hooks/hook-soundnotify/package.json +1 -1
  101. package/hooks/hook-taskgate/README.md +1 -1
  102. package/hooks/hook-taskgate/package.json +1 -1
  103. package/hooks/hook-tddguard/README.md +1 -1
  104. package/hooks/hook-tddguard/package.json +1 -1
  105. package/package.json +17 -3
  106. package/.claude/settings.json +0 -24
  107. package/.npmrc.example +0 -2
  108. package/AGENTS.md +0 -54
  109. package/CLAUDE.md +0 -70
  110. package/CONTRIBUTING.md +0 -45
  111. package/hooks/hook-agentmessages/bin/cli.ts +0 -125
package/AGENTS.md DELETED
@@ -1,54 +0,0 @@
1
- # AGENTS.md
2
-
3
- Guidance for AI agents working with this repository.
4
-
5
- ## Overview
6
-
7
- This is `@hasna/hooks`, an open-source monorepo of Claude Code hooks providing CLI installation and management of 15+ lifecycle hooks.
8
-
9
- ## Quick Commands
10
-
11
- ```bash
12
- bun install # Install dependencies
13
- bun run dev # Run CLI
14
- bun run build # Build
15
- bun run typecheck # Type check
16
- ```
17
-
18
- ## Adding Hooks
19
-
20
- 1. Copy to `hooks/hook-{name}/`
21
- 2. Ensure it follows the standard hook pattern (stdin JSON → stdout JSON)
22
- 3. Remove any internal references (hasnaxyz, etc.)
23
- 4. Verify no secrets or API keys are committed
24
- 5. Update `src/lib/registry.ts` to include the hook
25
-
26
- ## Structure
27
-
28
- ```
29
- hooks/hook-{name}/
30
- ├── src/
31
- │ ├── hook.ts # Main hook logic
32
- │ ├── cli.ts # CLI commands
33
- │ └── index.ts # Exports
34
- ├── package.json
35
- ├── CLAUDE.md
36
- └── README.md
37
- ```
38
-
39
- ## Hook Events
40
-
41
- | Event | Timing | Can Block | Use Case |
42
- |-------|--------|-----------|----------|
43
- | PreToolUse | Before tool | Yes | Security, safety guards |
44
- | PostToolUse | After tool | No | Quality checks, async tasks |
45
- | Stop | Session end | No | Notifications, cleanup |
46
- | Notification | On notify | No | Context management |
47
-
48
- ## Security Checks
49
-
50
- Before committing any hook:
51
- - [ ] No hardcoded API keys/tokens
52
- - [ ] No internal references (hasnaxyz)
53
- - [ ] Uses `@hasna` namespace for public packages
54
- - [ ] .env.example has placeholders only
package/CLAUDE.md DELETED
@@ -1,70 +0,0 @@
1
- # CLAUDE.md
2
-
3
- This file provides guidance to Claude Code when working with this repository.
4
-
5
- ## Project Overview
6
-
7
- `@hasna/hooks` is an open-source monorepo of Claude Code hooks. It provides a CLI to install hooks into projects and register them in Claude settings.
8
-
9
- ## Build & Run Commands
10
-
11
- ```bash
12
- # Install dependencies
13
- bun install
14
-
15
- # Run CLI in development
16
- bun run dev
17
-
18
- # Build for distribution
19
- bun run build
20
-
21
- # Type check
22
- bun run typecheck
23
- ```
24
-
25
- ## Code Style
26
-
27
- - TypeScript with strict mode
28
- - ESM modules (`type: module`)
29
- - Async/await for all async operations
30
- - Minimal dependencies: commander, chalk, ink (for CLI)
31
- - Type annotations required everywhere
32
-
33
- ## Project Structure
34
-
35
- ```
36
- ├── src/
37
- │ ├── cli/ # Interactive CLI (Ink/React)
38
- │ │ ├── components/
39
- │ │ └── index.tsx
40
- │ ├── lib/ # Core library
41
- │ │ ├── installer.ts
42
- │ │ └── registry.ts
43
- │ └── index.ts # Library exports
44
- ├── hooks/ # Individual hook packages
45
- │ └── hook-*/ # Each hook
46
- └── bin/ # Built CLI output
47
- ```
48
-
49
- ## Adding New Hooks
50
-
51
- When adding hooks:
52
-
53
- 1. Copy to `hooks/hook-{name}/`
54
- 2. Update `src/lib/registry.ts` to include the hook
55
- 3. Ensure no secrets or API keys are committed
56
- 4. Follow the standard hook structure (src/hook.ts, src/cli.ts)
57
-
58
- ## Hook Events
59
-
60
- - **PreToolUse**: Fires before tool execution, can block
61
- - **PostToolUse**: Fires after tool execution, async
62
- - **Stop**: Fires on session end, async
63
- - **Notification**: Fires on notification events, async
64
-
65
- ## Dependencies
66
-
67
- - commander: CLI argument parsing
68
- - chalk: Terminal styling
69
- - ink: React-based interactive CLI
70
- - ink-select-input: Selection component for Ink
package/CONTRIBUTING.md DELETED
@@ -1,45 +0,0 @@
1
- # Contributing
2
-
3
- Thanks for helping improve the hooks. Please follow these guidelines so we can keep publishing safe and consistent.
4
-
5
- ## NPM Auth (Optional)
6
-
7
- If you need a scoped registry token (publish or private installs), copy an example file and set `NPM_TOKEN`:
8
-
9
- ```bash
10
- cp .npmrc.example .npmrc
11
- ```
12
-
13
- - Do not commit `.npmrc` files with real tokens.
14
- - Use environment variables in CI: `NPM_TOKEN` only.
15
-
16
- ## Adding a New Hook
17
-
18
- 1. Create the hook directory: `hooks/hook-{name}/`
19
- 2. Follow the standard structure:
20
- ```
21
- hook-{name}/
22
- ├── src/
23
- │ ├── hook.ts # Main hook logic
24
- │ ├── cli.ts # CLI commands
25
- │ └── index.ts # Exports
26
- ├── package.json
27
- ├── CLAUDE.md
28
- ├── README.md
29
- └── tsconfig.json
30
- ```
31
- 3. Register it in `src/lib/registry.ts`
32
- 4. Test with `bun run dev`
33
-
34
- ## Hook Conventions
35
-
36
- - Hooks receive JSON on stdin and output JSON on stdout
37
- - PreToolUse hooks return `{ "decision": "approve" | "block", "reason": "..." }`
38
- - PostToolUse/Stop/Notification hooks return `{ "continue": true }`
39
- - Log diagnostic info to stderr, not stdout
40
- - No external dependencies (use Node.js builtins only)
41
-
42
- ## Secrets
43
-
44
- - Never commit `.env` files with real values.
45
- - Keep credentials in your local environment only.
@@ -1,125 +0,0 @@
1
- #!/usr/bin/env bun
2
- /**
3
- * CLI for hook-agentmessages
4
- *
5
- * Usage:
6
- * hook-agentmessages install - Install hooks into Claude Code
7
- * hook-agentmessages uninstall - Remove hooks from Claude Code
8
- * hook-agentmessages status - Show hook status
9
- */
10
-
11
- import { homedir } from 'os';
12
- import { join } from 'path';
13
-
14
- const CLAUDE_SETTINGS_FILE = join(homedir(), '.claude', 'settings.json');
15
-
16
- const args = process.argv.slice(2);
17
- const command = args[0];
18
-
19
- async function showStatus() {
20
- console.log('hook-agentmessages status\n');
21
-
22
- // Check if hooks are installed
23
- try {
24
- const file = Bun.file(CLAUDE_SETTINGS_FILE);
25
- if (await file.exists()) {
26
- const settings = await file.json();
27
-
28
- if (settings.hooks) {
29
- let installed = false;
30
-
31
- if (settings.hooks.SessionStart) {
32
- const hasHook = settings.hooks.SessionStart.some((h: any) =>
33
- h.hooks?.some((hook: any) => hook.command?.includes('hook-agentmessages'))
34
- );
35
- if (hasHook) {
36
- console.log(' SessionStart hook: installed');
37
- installed = true;
38
- }
39
- }
40
-
41
- if (settings.hooks.Stop) {
42
- const hasHook = settings.hooks.Stop.some((h: any) =>
43
- h.hooks?.some((hook: any) => hook.command?.includes('hook-agentmessages'))
44
- );
45
- if (hasHook) {
46
- console.log(' Stop hook: installed');
47
- installed = true;
48
- }
49
- }
50
-
51
- if (!installed) {
52
- console.log(' No hook-agentmessages hooks installed');
53
- }
54
- } else {
55
- console.log(' No hooks configured in Claude Code');
56
- }
57
- } else {
58
- console.log(' Claude Code settings not found');
59
- }
60
- } catch (err) {
61
- console.log(' Error reading settings:', (err as Error).message);
62
- }
63
-
64
- // Check service-message status
65
- const serviceDir = join(homedir(), '.service', 'service-message');
66
- const configFile = Bun.file(join(serviceDir, 'config.json'));
67
-
68
- console.log('\nservice-message integration:');
69
- if (await configFile.exists()) {
70
- const config = await configFile.json();
71
- console.log(` Agent ID: ${config.agentId || 'not set'}`);
72
- console.log(` Data dir: ${serviceDir}`);
73
- } else {
74
- console.log(' Not configured');
75
- }
76
- }
77
-
78
- function showHelp() {
79
- console.log(`
80
- hook-agentmessages - Claude Code hook for service-message integration
81
-
82
- Usage:
83
- hook-agentmessages <command>
84
-
85
- Commands:
86
- install Install hooks into Claude Code settings
87
- uninstall Remove hooks from Claude Code settings
88
- status Show current hook status
89
-
90
- Examples:
91
- hook-agentmessages install
92
- hook-agentmessages status
93
- `);
94
- }
95
-
96
- async function main() {
97
- if (!command || command === '--help' || command === '-h') {
98
- showHelp();
99
- return;
100
- }
101
-
102
- switch (command) {
103
- case 'install':
104
- await import('../src/install.ts');
105
- break;
106
-
107
- case 'uninstall':
108
- await import('../src/uninstall.ts');
109
- break;
110
-
111
- case 'status':
112
- await showStatus();
113
- break;
114
-
115
- default:
116
- console.error(`Unknown command: ${command}`);
117
- showHelp();
118
- process.exit(1);
119
- }
120
- }
121
-
122
- main().catch((err) => {
123
- console.error('Error:', err.message);
124
- process.exit(1);
125
- });