@uniswap/ai-toolkit-nx-claude 0.5.30-next.2 → 0.5.30-next.3
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 +28 -27
- package/dist/cli-generator.cjs +4 -10
- package/dist/index.cjs +15 -845
- package/dist/packages/ai-toolkit-nx-claude/src/cli-generator.d.ts +1 -2
- package/dist/packages/ai-toolkit-nx-claude/src/cli-generator.d.ts.map +1 -1
- package/dist/packages/ai-toolkit-nx-claude/src/index.d.ts +0 -1
- package/dist/packages/ai-toolkit-nx-claude/src/index.d.ts.map +1 -1
- package/generators.json +0 -5
- package/package.json +2 -3
- package/dist/generators/hooks/CLAUDE.md +0 -378
- package/dist/generators/hooks/README.md +0 -220
- package/dist/generators/hooks/generator.cjs +0 -1265
- package/dist/generators/hooks/schema.json +0 -41
- package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/cli-parser.d.ts +0 -2
- package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/cli-parser.d.ts.map +0 -1
- package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/dependency-checker.d.ts +0 -46
- package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/dependency-checker.d.ts.map +0 -1
- package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/generator.d.ts +0 -9
- package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/generator.d.ts.map +0 -1
- package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/install-orchestrator.d.ts +0 -55
- package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/install-orchestrator.d.ts.map +0 -1
- package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/repo-manager.d.ts +0 -63
- package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/repo-manager.d.ts.map +0 -1
|
@@ -3,14 +3,13 @@
|
|
|
3
3
|
* Unified CLI wrapper for ai-toolkit-nx-claude generators.
|
|
4
4
|
*
|
|
5
5
|
* Available generators:
|
|
6
|
-
* - hooks: Install Claude Code notification hooks
|
|
7
6
|
* - addons: Install and configure Claude Code addons including MCP servers
|
|
8
7
|
*
|
|
9
8
|
* Usage:
|
|
10
9
|
* - No arguments -> shows interactive menu of generators
|
|
11
10
|
* - Specific generator name -> runs that generator
|
|
12
11
|
*
|
|
13
|
-
* Note: The init, add-command,
|
|
12
|
+
* Note: The init, add-command, add-agent, and hooks generators have been removed.
|
|
14
13
|
* For Claude Code setup, use the marketplace-based plugin architecture instead.
|
|
15
14
|
*/
|
|
16
15
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-generator.d.ts","sourceRoot":"","sources":["../../../../src/cli-generator.ts"],"names":[],"mappings":";AAEA
|
|
1
|
+
{"version":3,"file":"cli-generator.d.ts","sourceRoot":"","sources":["../../../../src/cli-generator.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;GAYG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,+BAA+B,CAAC"}
|
package/generators.json
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"generators": {
|
|
3
|
-
"hooks": {
|
|
4
|
-
"factory": "./dist/generators/hooks/generator",
|
|
5
|
-
"schema": "./dist/generators/hooks/schema.json",
|
|
6
|
-
"description": "Install Claude Code notification hooks"
|
|
7
|
-
},
|
|
8
3
|
"addons": {
|
|
9
4
|
"factory": "./dist/generators/addons/generator",
|
|
10
5
|
"schema": "./dist/generators/addons/schema.json",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniswap/ai-toolkit-nx-claude",
|
|
3
|
-
"version": "0.5.30-next.
|
|
3
|
+
"version": "0.5.30-next.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.cjs",
|
|
@@ -47,8 +47,7 @@
|
|
|
47
47
|
"additionalEntryPoints": [
|
|
48
48
|
"packages/ai-toolkit-nx-claude/src/index.ts",
|
|
49
49
|
"packages/ai-toolkit-nx-claude/src/scripts/claude-plus/index.ts",
|
|
50
|
-
"packages/ai-toolkit-nx-claude/src/generators/addons/generator.ts"
|
|
51
|
-
"packages/ai-toolkit-nx-claude/src/generators/hooks/generator.ts"
|
|
50
|
+
"packages/ai-toolkit-nx-claude/src/generators/addons/generator.ts"
|
|
52
51
|
],
|
|
53
52
|
"tsConfig": "packages/ai-toolkit-nx-claude/tsconfig.lib.json",
|
|
54
53
|
"bundle": true,
|
|
@@ -1,378 +0,0 @@
|
|
|
1
|
-
# CLAUDE.md - Hooks Generator
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
The `hooks` generator is a specialized Nx generator that automates the installation of notification hooks for Claude Code, providing audio and speech alerts when Claude needs user input during development sessions.
|
|
6
|
-
|
|
7
|
-
## Core Functionality
|
|
8
|
-
|
|
9
|
-
### What It Does
|
|
10
|
-
|
|
11
|
-
1. **Dependency Validation**: Checks for Node.js, npm, and Git installations
|
|
12
|
-
2. **Repository Management**: Clones or updates the awesome-claude-code repository
|
|
13
|
-
3. **Interactive Configuration**: Prompts for notification preferences (sound vs speech)
|
|
14
|
-
4. **Backup Management**: Creates timestamped backups of existing hook configurations
|
|
15
|
-
5. **Script Orchestration**: Executes awesome-claude-code's install-global.sh with user selections
|
|
16
|
-
6. **Installation Verification**: Validates that hooks were properly installed
|
|
17
|
-
7. **Rollback Support**: Restores from backup if installation fails
|
|
18
|
-
8. **Test Capability**: Optionally tests the installed hooks to verify functionality
|
|
19
|
-
|
|
20
|
-
### Key Design Decision
|
|
21
|
-
|
|
22
|
-
This generator provides a streamlined installation process that:
|
|
23
|
-
|
|
24
|
-
- Automatically downloads the latest hook implementations
|
|
25
|
-
- Handles all configuration and setup
|
|
26
|
-
- Manages backups and rollback
|
|
27
|
-
- Provides a consistent installation experience
|
|
28
|
-
|
|
29
|
-
## Architecture
|
|
30
|
-
|
|
31
|
-
### Module Structure
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
packages/ai-toolkit-nx-claude/src/generators/hooks/
|
|
35
|
-
├── generator.ts # Main generator orchestrator
|
|
36
|
-
├── generator.spec.ts # Test suite
|
|
37
|
-
├── schema.json # Configuration schema for Nx
|
|
38
|
-
├── schema.d.ts # TypeScript interface for options
|
|
39
|
-
├── dependency-checker.ts # System dependency validation
|
|
40
|
-
├── repo-manager.ts # Git repository operations
|
|
41
|
-
├── install-orchestrator.ts # Installation script execution
|
|
42
|
-
└── CLAUDE.md # This documentation file
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### Key Components
|
|
46
|
-
|
|
47
|
-
#### 1. Generator (generator.ts)
|
|
48
|
-
|
|
49
|
-
The main orchestrator that:
|
|
50
|
-
|
|
51
|
-
- Coordinates the entire installation flow
|
|
52
|
-
- Manages user prompts via schema-driven prompting
|
|
53
|
-
- Handles dry-run mode
|
|
54
|
-
- Provides verbose/quiet output modes
|
|
55
|
-
- Manages cleanup on success/failure
|
|
56
|
-
|
|
57
|
-
#### 2. Dependency Checker (dependency-checker.ts)
|
|
58
|
-
|
|
59
|
-
Validates system requirements:
|
|
60
|
-
|
|
61
|
-
- **checkDependencies()**: Returns status for Node, npm, and Git
|
|
62
|
-
- **validateDependencies()**: Logs detailed version information
|
|
63
|
-
- **checkAndValidateDependencies()**: Combined check with user-friendly output
|
|
64
|
-
- Cross-platform command detection (handles Windows/Unix differences)
|
|
65
|
-
|
|
66
|
-
#### 3. Repository Manager (repo-manager.ts)
|
|
67
|
-
|
|
68
|
-
Manages the hook file downloads:
|
|
69
|
-
|
|
70
|
-
- **ensureRepository()**: Main entry point that clones or updates
|
|
71
|
-
- **cloneRepository()**: Handles HTTPS/SSH fallback for cloning
|
|
72
|
-
- **updateRepository()**: Git pull with stash handling for uncommitted changes
|
|
73
|
-
- **getRepoStatus()**: Detailed repository state information
|
|
74
|
-
- **cleanupRepository()**: Removes temporary repository after installation
|
|
75
|
-
|
|
76
|
-
#### 4. Installation Orchestrator (install-orchestrator.ts)
|
|
77
|
-
|
|
78
|
-
Executes the actual installation:
|
|
79
|
-
|
|
80
|
-
- **runInstallation()**: Main installation coordinator
|
|
81
|
-
- **executeInstallScript()**: Spawns bash process with input piping
|
|
82
|
-
- **backupExistingHooks()**: Creates timestamped backups
|
|
83
|
-
- **verifyInstallation()**: Checks for expected files and settings
|
|
84
|
-
- **restoreBackup()**: Rollback capability on failure
|
|
85
|
-
- **testHooks()**: Triggers test notifications
|
|
86
|
-
|
|
87
|
-
## Installation Flow
|
|
88
|
-
|
|
89
|
-
### Step-by-Step Process
|
|
90
|
-
|
|
91
|
-
1. **Dependency Check**
|
|
92
|
-
|
|
93
|
-
- Validates Node.js, npm, and Git are available
|
|
94
|
-
- Can be skipped with `--force` flag (not recommended)
|
|
95
|
-
|
|
96
|
-
2. **User Prompting**
|
|
97
|
-
|
|
98
|
-
- Uses schema.json to generate prompts
|
|
99
|
-
- Reuses prompt-utils from init generator
|
|
100
|
-
- Options: notification type, voice selection, update, backup
|
|
101
|
-
|
|
102
|
-
3. **Hook Download**
|
|
103
|
-
|
|
104
|
-
- Downloads latest hook files to temp directory
|
|
105
|
-
- Always fetches latest version
|
|
106
|
-
- Handles download with automatic fallback
|
|
107
|
-
|
|
108
|
-
4. **Backup Creation**
|
|
109
|
-
|
|
110
|
-
- Backs up ~/.claude/hooks/\* if exists
|
|
111
|
-
- Saves settings.json state
|
|
112
|
-
- Creates timestamped backup directory
|
|
113
|
-
|
|
114
|
-
5. **Script Execution**
|
|
115
|
-
|
|
116
|
-
- Runs installation script
|
|
117
|
-
- Pipes user selections to script stdin
|
|
118
|
-
- Handles interactive script input programmatically
|
|
119
|
-
|
|
120
|
-
6. **Verification**
|
|
121
|
-
|
|
122
|
-
- Checks for notification.ts, stop.ts, subagent_stop.ts
|
|
123
|
-
- Validates settings.json has hooks configuration
|
|
124
|
-
- Returns list of installed files
|
|
125
|
-
|
|
126
|
-
7. **Optional Testing**
|
|
127
|
-
|
|
128
|
-
- In verbose mode, offers to test hooks
|
|
129
|
-
- Executes notification hook with test payload
|
|
130
|
-
- User should hear/see the notification
|
|
131
|
-
|
|
132
|
-
8. **Cleanup**
|
|
133
|
-
- Removes temporary repository (unless --verbose)
|
|
134
|
-
- Preserves backup for user reference
|
|
135
|
-
|
|
136
|
-
## Generator Options
|
|
137
|
-
|
|
138
|
-
### Schema Properties
|
|
139
|
-
|
|
140
|
-
```typescript
|
|
141
|
-
interface HooksGeneratorSchema {
|
|
142
|
-
notificationType?: 'sound' | 'speech'; // Default: 'sound'
|
|
143
|
-
voiceSelection?: string; // For speech mode
|
|
144
|
-
backup?: boolean; // Create backup (default: true)
|
|
145
|
-
'dry-run'?: boolean; // Preview without changes
|
|
146
|
-
force?: boolean; // Skip dependency checks
|
|
147
|
-
verbose?: boolean; // Detailed output
|
|
148
|
-
installMode?: 'default' | 'custom'; // Installation mode from parent generator (hidden)
|
|
149
|
-
}
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
### installMode Parameter
|
|
153
|
-
|
|
154
|
-
The `installMode` parameter is a **hidden** parameter designed for programmatic use only. It's passed from parent generators (like `init`) to control the prompting behavior:
|
|
155
|
-
|
|
156
|
-
- **`'default'`**: Skips all interactive prompts and uses default values for all options. This provides a streamlined, non-interactive installation experience.
|
|
157
|
-
- **`'custom'`**: (or undefined): Enables full interactive prompting, allowing users to configure all options through CLI prompts.
|
|
158
|
-
|
|
159
|
-
**Usage Pattern**:
|
|
160
|
-
|
|
161
|
-
```typescript
|
|
162
|
-
// Called programmatically from init generator in default mode
|
|
163
|
-
await hooksGenerator(tree, {
|
|
164
|
-
installMode: 'default', // Skips all prompts
|
|
165
|
-
force: false,
|
|
166
|
-
dry: false,
|
|
167
|
-
backup: true,
|
|
168
|
-
verbose: false,
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
// Called programmatically from init generator in custom mode (or standalone)
|
|
172
|
-
await hooksGenerator(tree, {
|
|
173
|
-
// installMode omitted or 'custom' - enables prompts
|
|
174
|
-
force: false,
|
|
175
|
-
});
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
**Implementation**: When `installMode === 'default'`, the generator bypasses the entire `promptForMissingOptions()` flow and constructs the normalized options directly using default values.
|
|
179
|
-
|
|
180
|
-
### Input Handling
|
|
181
|
-
|
|
182
|
-
The generator pipes input to the install-global.sh script based on options:
|
|
183
|
-
|
|
184
|
-
- Sound mode: Sends "1\n"
|
|
185
|
-
- Speech mode: Sends "2\n" followed by voice selection if provided
|
|
186
|
-
|
|
187
|
-
## File Operations
|
|
188
|
-
|
|
189
|
-
### Created Files
|
|
190
|
-
|
|
191
|
-
```
|
|
192
|
-
~/.claude/
|
|
193
|
-
├── hooks/
|
|
194
|
-
│ ├── notification.ts # User input needed hook
|
|
195
|
-
│ ├── stop.ts # Execution stopped hook
|
|
196
|
-
│ └── subagent_stop.ts # Subagent stopped hook
|
|
197
|
-
└── settings.json # Updated with hook paths
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
### Backup Structure
|
|
201
|
-
|
|
202
|
-
```
|
|
203
|
-
~/.claude/
|
|
204
|
-
└── hooks-backup-2024-01-01T12-00-00-000Z/
|
|
205
|
-
├── notification.ts
|
|
206
|
-
├── stop.ts
|
|
207
|
-
├── subagent_stop.ts
|
|
208
|
-
└── settings.json.backup
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
## Error Handling
|
|
212
|
-
|
|
213
|
-
### Failure Scenarios
|
|
214
|
-
|
|
215
|
-
1. **Missing Dependencies**: Clear error messages with installation instructions
|
|
216
|
-
2. **Git Clone Failure**: Falls back from HTTPS to SSH for default repo
|
|
217
|
-
3. **Script Execution Failure**: Captures exit codes and stderr
|
|
218
|
-
4. **Verification Failure**: Lists missing files, attempts rollback
|
|
219
|
-
5. **Backup Restoration**: Automatic rollback on installation failure
|
|
220
|
-
|
|
221
|
-
### Recovery Mechanisms
|
|
222
|
-
|
|
223
|
-
- Backup restoration on failure
|
|
224
|
-
- Force flag to bypass checks
|
|
225
|
-
- Verbose mode for debugging
|
|
226
|
-
- Dry-run for preview
|
|
227
|
-
|
|
228
|
-
## Cross-Platform Considerations
|
|
229
|
-
|
|
230
|
-
### Dependency Detection
|
|
231
|
-
|
|
232
|
-
- **Node/npm**: Uses `which` on Unix, `where` on Windows
|
|
233
|
-
- **Git**: Standard git commands work cross-platform
|
|
234
|
-
- **Paths**: Uses Node.js path module for OS-appropriate separators
|
|
235
|
-
|
|
236
|
-
### Notification Support
|
|
237
|
-
|
|
238
|
-
The hooks handle platform differences automatically:
|
|
239
|
-
|
|
240
|
-
- **macOS**: afplay for sound, say for speech
|
|
241
|
-
- **Windows**: PowerShell for sound, SAPI for speech
|
|
242
|
-
- **Linux**: aplay/paplay for sound, espeak/festival for speech
|
|
243
|
-
|
|
244
|
-
## Testing Strategy
|
|
245
|
-
|
|
246
|
-
### Unit Tests (generator.spec.ts)
|
|
247
|
-
|
|
248
|
-
Should test:
|
|
249
|
-
|
|
250
|
-
- Schema validation
|
|
251
|
-
- Dependency checking logic
|
|
252
|
-
- Repository management operations
|
|
253
|
-
- Backup/restore functionality
|
|
254
|
-
- Script execution with mocked child_process
|
|
255
|
-
|
|
256
|
-
### Integration Testing
|
|
257
|
-
|
|
258
|
-
Manual testing checklist:
|
|
259
|
-
|
|
260
|
-
1. Fresh installation with sound
|
|
261
|
-
2. Fresh installation with speech
|
|
262
|
-
3. Update existing installation
|
|
263
|
-
4. Dry-run mode verification
|
|
264
|
-
5. Force mode with missing dependencies
|
|
265
|
-
6. Backup and restore flow
|
|
266
|
-
7. Custom repository usage
|
|
267
|
-
|
|
268
|
-
## Development Notes
|
|
269
|
-
|
|
270
|
-
### Programmatic Usage Pattern
|
|
271
|
-
|
|
272
|
-
This generator implements the **installMode pattern** for sub-generators:
|
|
273
|
-
|
|
274
|
-
**Purpose**: Prevent duplicate prompting when generators are called programmatically from parent generators.
|
|
275
|
-
|
|
276
|
-
**Implementation**:
|
|
277
|
-
|
|
278
|
-
1. Add `installMode?: 'default' | 'custom'` to schema with `hidden: true`
|
|
279
|
-
2. Add `installMode?: 'default' | 'custom'` to TypeScript interface
|
|
280
|
-
3. In generator.ts, check `if (options.installMode === 'default')` before prompting
|
|
281
|
-
4. When 'default', construct normalized options with defaults instead of prompting
|
|
282
|
-
5. When undefined or 'custom', proceed with normal prompting flow
|
|
283
|
-
|
|
284
|
-
**Why This Works**:
|
|
285
|
-
|
|
286
|
-
- Hidden schema properties don't show up in CLI help or prompts
|
|
287
|
-
- Parent generators can pass the mode to control child behavior
|
|
288
|
-
- Avoids issues with `getExplicitlyProvidedOptions()` reading `process.argv`
|
|
289
|
-
- Each generator maintains backward compatibility (works standalone or programmatically)
|
|
290
|
-
|
|
291
|
-
**Pattern Applied**: This pattern is used across all sub-generators that are called from the `init` generator (hooks, addons, etc.).
|
|
292
|
-
|
|
293
|
-
### Adding New Features
|
|
294
|
-
|
|
295
|
-
To extend the generator:
|
|
296
|
-
|
|
297
|
-
1. Update schema.json with new options
|
|
298
|
-
2. Update schema.d.ts TypeScript interface
|
|
299
|
-
3. Modify generator.ts to handle new options
|
|
300
|
-
4. Update prompt flow if interactive
|
|
301
|
-
5. Add tests for new functionality
|
|
302
|
-
6. Update README.md and CLAUDE.md
|
|
303
|
-
|
|
304
|
-
### Debugging
|
|
305
|
-
|
|
306
|
-
Use verbose mode to debug issues:
|
|
307
|
-
|
|
308
|
-
```bash
|
|
309
|
-
npx nx generate @uniswap/ai-toolkit-nx-claude:hooks --verbose
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
This preserves the cloned repository and shows detailed output.
|
|
313
|
-
|
|
314
|
-
### Common Issues
|
|
315
|
-
|
|
316
|
-
1. **Script Permission Denied**: The generator runs `chmod +x` on install-global.sh
|
|
317
|
-
2. **Input Not Received**: Script stdin is properly ended after writing
|
|
318
|
-
3. **Repository Already Exists**: Handles existing repos, can force update
|
|
319
|
-
4. **Hooks Not Triggering**: Verification step ensures proper installation
|
|
320
|
-
|
|
321
|
-
## Integration with Nx
|
|
322
|
-
|
|
323
|
-
### Generator Registration
|
|
324
|
-
|
|
325
|
-
Registered in `packages/ai-toolkit-nx-claude/generators.json`:
|
|
326
|
-
|
|
327
|
-
```json
|
|
328
|
-
{
|
|
329
|
-
"generators": {
|
|
330
|
-
"hooks": {
|
|
331
|
-
"factory": "./dist/generators/hooks/generator",
|
|
332
|
-
"schema": "./dist/generators/hooks/schema.json",
|
|
333
|
-
"description": "Install Claude Code notification hooks using awesome-claude-code"
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
```
|
|
338
|
-
|
|
339
|
-
### Building and Testing
|
|
340
|
-
|
|
341
|
-
```bash
|
|
342
|
-
# Build the generator
|
|
343
|
-
npx nx build nx-claude
|
|
344
|
-
|
|
345
|
-
# Run tests
|
|
346
|
-
npx nx test nx-claude
|
|
347
|
-
|
|
348
|
-
# Test locally
|
|
349
|
-
npx nx generate @uniswap/ai-toolkit-nx-claude:hooks --dry-run
|
|
350
|
-
```
|
|
351
|
-
|
|
352
|
-
## Future Enhancements
|
|
353
|
-
|
|
354
|
-
Potential improvements (not yet implemented):
|
|
355
|
-
|
|
356
|
-
1. **Custom Sound Files**: Allow users to provide their own notification sounds
|
|
357
|
-
2. **Hook Templates**: Provide customizable hook templates
|
|
358
|
-
3. **Multiple Notification Channels**: Support multiple simultaneous notifications
|
|
359
|
-
4. **Notification Rules**: Configure when notifications should fire
|
|
360
|
-
5. **Integration with IDEs**: VS Code extension integration
|
|
361
|
-
6. **Metrics/Analytics**: Track notification patterns
|
|
362
|
-
|
|
363
|
-
## Maintenance Requirements
|
|
364
|
-
|
|
365
|
-
⚠️ **IMPORTANT**: This CLAUDE.md file must be updated whenever the hooks generator changes:
|
|
366
|
-
|
|
367
|
-
- New options or parameters
|
|
368
|
-
- Changes to installation flow
|
|
369
|
-
- Updates to file structure
|
|
370
|
-
- New dependencies or requirements
|
|
371
|
-
- Bug fixes that change behavior
|
|
372
|
-
- Integration with new hook versions
|
|
373
|
-
|
|
374
|
-
The documentation should always reflect the current state of the generator implementation to ensure AI assistants have accurate information.
|
|
375
|
-
|
|
376
|
-
## Credits
|
|
377
|
-
|
|
378
|
-
This generator provides an Nx-integrated installation experience for Claude Code notification hooks.
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
# Claude Code Hooks Generator
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
The `hooks` generator automatically installs notification hooks for Claude Code. These hooks provide audio notifications when Claude needs user input, improving the development workflow by alerting you when your attention is required.
|
|
6
|
-
|
|
7
|
-
## Features
|
|
8
|
-
|
|
9
|
-
- 🔔 **Sound Notifications**: Custom sound alerts when Claude needs input
|
|
10
|
-
- 🔄 **Auto-update**: Always installs the latest version
|
|
11
|
-
- 💾 **Backup & Restore**: Automatically backs up existing configurations
|
|
12
|
-
- 🧪 **Test Mode**: Verify hooks are working correctly
|
|
13
|
-
- 🌍 **Cross-platform**: Works on macOS, Windows, and Linux
|
|
14
|
-
|
|
15
|
-
## Prerequisites
|
|
16
|
-
|
|
17
|
-
The generator will check for these dependencies and warn if missing:
|
|
18
|
-
|
|
19
|
-
- **Node.js** (v16 or higher)
|
|
20
|
-
- **npm** (for executing TypeScript hooks)
|
|
21
|
-
- **Git** (for downloading hook files)
|
|
22
|
-
|
|
23
|
-
## Installation
|
|
24
|
-
|
|
25
|
-
### Run the Generator
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
# From any directory (installs globally to ~/.claude/hooks/)
|
|
29
|
-
npx nx generate @uniswap/ai-toolkit-nx-claude:hooks
|
|
30
|
-
|
|
31
|
-
# Or with npm
|
|
32
|
-
npm run nx generate @uniswap/ai-toolkit-nx-claude:hooks
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### Interactive Mode (Default)
|
|
36
|
-
|
|
37
|
-
When run without options, the generator will interactively prompt for:
|
|
38
|
-
|
|
39
|
-
1. **Backup**: Whether to backup existing configuration
|
|
40
|
-
2. **Dry Run**: Preview changes without installation
|
|
41
|
-
3. **Verbose**: Show detailed output
|
|
42
|
-
|
|
43
|
-
### Non-Interactive Examples
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
# Install with all defaults (using Nx's built-in flag)
|
|
47
|
-
npx nx generate @uniswap/ai-toolkit-nx-claude:hooks --no-interactive
|
|
48
|
-
|
|
49
|
-
# Dry run to preview changes
|
|
50
|
-
npx nx generate @uniswap/ai-toolkit-nx-claude:hooks --dry
|
|
51
|
-
|
|
52
|
-
# Also works with --dry-run alias for Nx compatibility
|
|
53
|
-
npx nx generate @uniswap/ai-toolkit-nx-claude:hooks --dry-run
|
|
54
|
-
|
|
55
|
-
# Skip backup during installation
|
|
56
|
-
npx nx generate @uniswap/ai-toolkit-nx-claude:hooks --backup=false --no-interactive
|
|
57
|
-
|
|
58
|
-
# Force installation (skip dependency checks)
|
|
59
|
-
npx nx generate @uniswap/ai-toolkit-nx-claude:hooks --force
|
|
60
|
-
|
|
61
|
-
# Verbose output for debugging
|
|
62
|
-
npx nx generate @uniswap/ai-toolkit-nx-claude:hooks --verbose
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## Generator Options
|
|
66
|
-
|
|
67
|
-
| Option | Type | Default | Description |
|
|
68
|
-
| --------- | --------- | ------- | --------------------------------------------- |
|
|
69
|
-
| `backup` | `boolean` | `true` | Backup existing hooks before installation |
|
|
70
|
-
| `dry` | `boolean` | `false` | Preview installation without making changes |
|
|
71
|
-
| `dry-run` | `boolean` | `false` | Alias for `dry` (for Nx compatibility) |
|
|
72
|
-
| `force` | `boolean` | `false` | Skip dependency checks and force installation |
|
|
73
|
-
| `verbose` | `boolean` | `false` | Show detailed output during installation |
|
|
74
|
-
|
|
75
|
-
**Note**: Use Nx's built-in `--no-interactive` flag to skip all prompts and use defaults.
|
|
76
|
-
|
|
77
|
-
## What Gets Installed
|
|
78
|
-
|
|
79
|
-
The generator installs the following hooks to `~/.claude/hooks/`:
|
|
80
|
-
|
|
81
|
-
### Hook Files
|
|
82
|
-
|
|
83
|
-
- **notification.ts**: Triggered when Claude needs user input
|
|
84
|
-
- **stop.ts**: Triggered when Claude stops execution
|
|
85
|
-
- **subagent_stop.ts**: Triggered when a subagent stops
|
|
86
|
-
|
|
87
|
-
### Configuration
|
|
88
|
-
|
|
89
|
-
The generator also updates `~/.claude/settings.json` to register the hooks:
|
|
90
|
-
|
|
91
|
-
```json
|
|
92
|
-
{
|
|
93
|
-
"hooks": {
|
|
94
|
-
"notification": "~/.claude/hooks/notification.ts",
|
|
95
|
-
"stop": "~/.claude/hooks/stop.ts",
|
|
96
|
-
"subagent_stop": "~/.claude/hooks/subagent_stop.ts"
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
## Platform Support
|
|
102
|
-
|
|
103
|
-
The notification system automatically detects and uses the appropriate audio playback method for your platform:
|
|
104
|
-
|
|
105
|
-
- **macOS**: Uses `afplay` (built-in)
|
|
106
|
-
- **Windows**: Uses PowerShell audio playback
|
|
107
|
-
- **Linux**: Uses `aplay` or `paplay`
|
|
108
|
-
|
|
109
|
-
## Testing the Installation
|
|
110
|
-
|
|
111
|
-
After installation, you can test the hooks:
|
|
112
|
-
|
|
113
|
-
```bash
|
|
114
|
-
# Run with verbose flag to get testing option
|
|
115
|
-
npx nx generate @uniswap/ai-toolkit-nx-claude:hooks --verbose
|
|
116
|
-
|
|
117
|
-
# When prompted, choose to test the hooks
|
|
118
|
-
# You should hear a notification sound
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
## Backup and Recovery
|
|
122
|
-
|
|
123
|
-
### Automatic Backup
|
|
124
|
-
|
|
125
|
-
By default, the generator creates a backup before modifying existing hooks:
|
|
126
|
-
|
|
127
|
-
- Backup location: `~/.claude/hooks-backup-[timestamp]/`
|
|
128
|
-
- Includes all hook files and settings.json
|
|
129
|
-
|
|
130
|
-
### Manual Recovery
|
|
131
|
-
|
|
132
|
-
If you need to restore a backup:
|
|
133
|
-
|
|
134
|
-
```bash
|
|
135
|
-
# List backups
|
|
136
|
-
ls -la ~/.claude/hooks-backup-*
|
|
137
|
-
|
|
138
|
-
# Restore a specific backup
|
|
139
|
-
cp -r ~/.claude/hooks-backup-2024-01-01T12-00-00/* ~/.claude/hooks/
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
## Troubleshooting
|
|
143
|
-
|
|
144
|
-
### Missing Dependencies
|
|
145
|
-
|
|
146
|
-
If you see dependency warnings:
|
|
147
|
-
|
|
148
|
-
```bash
|
|
149
|
-
# Install Node.js
|
|
150
|
-
# Visit https://nodejs.org or use a version manager like nvm
|
|
151
|
-
|
|
152
|
-
# Install Git
|
|
153
|
-
# macOS: brew install git
|
|
154
|
-
# Ubuntu/Debian: sudo apt-get install git
|
|
155
|
-
# Windows: Download from https://git-scm.com
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
### Hooks Not Working
|
|
159
|
-
|
|
160
|
-
1. **Verify Installation**:
|
|
161
|
-
|
|
162
|
-
```bash
|
|
163
|
-
ls -la ~/.claude/hooks/
|
|
164
|
-
cat ~/.claude/settings.json | grep hooks
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
2. **Check TypeScript Execution**:
|
|
168
|
-
|
|
169
|
-
```bash
|
|
170
|
-
npx tsx --version
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
3. **Test Manually**:
|
|
174
|
-
|
|
175
|
-
```bash
|
|
176
|
-
echo '{"hook_event_name":"Notification"}' | npx tsx ~/.claude/hooks/notification.ts
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
### Sound Not Playing
|
|
180
|
-
|
|
181
|
-
- **macOS**: Check System Preferences > Sound > Sound Effects volume
|
|
182
|
-
- **Windows**: Check Windows Volume Mixer settings
|
|
183
|
-
- **Linux**: Verify audio packages are installed (`sudo apt-get install alsa-utils`)
|
|
184
|
-
|
|
185
|
-
## Customization
|
|
186
|
-
|
|
187
|
-
### Modifying Installed Hooks
|
|
188
|
-
|
|
189
|
-
After installation, you can customize the hooks by editing files in `~/.claude/hooks/`. The TypeScript files can be modified to:
|
|
190
|
-
|
|
191
|
-
- Change notification sounds
|
|
192
|
-
- Customize speech messages
|
|
193
|
-
- Add logging or debugging
|
|
194
|
-
- Integrate with other tools
|
|
195
|
-
|
|
196
|
-
## How It Works
|
|
197
|
-
|
|
198
|
-
1. **Dependency Check**: Verifies Node.js, npm, and Git are installed
|
|
199
|
-
2. **Download**: Fetches the latest hook files
|
|
200
|
-
3. **Backup Creation**: Saves existing configuration if present
|
|
201
|
-
4. **Script Execution**: Runs the installation script
|
|
202
|
-
5. **Verification**: Confirms hooks are properly installed
|
|
203
|
-
6. **Cleanup**: Removes temporary files (unless --verbose is used)
|
|
204
|
-
|
|
205
|
-
## Credits
|
|
206
|
-
|
|
207
|
-
This generator provides an automated installation process for Claude Code notification hooks, integrated with the Nx toolchain.
|
|
208
|
-
|
|
209
|
-
## Contributing
|
|
210
|
-
|
|
211
|
-
To contribute to this generator:
|
|
212
|
-
|
|
213
|
-
1. Fork or pull down the AI Toolkit repository
|
|
214
|
-
2. Make your changes in `packages/ai-toolkit-nx-claude/src/generators/hooks/`
|
|
215
|
-
3. Add tests in `packages/ai-toolkit-nx-claude/src/generators/hooks/generator.spec.ts`
|
|
216
|
-
4. Submit a pull request
|
|
217
|
-
|
|
218
|
-
## License
|
|
219
|
-
|
|
220
|
-
This generator is part of the AI Toolkit project.
|