@cloudstreamsoftware/claude-tools 1.2.1 → 1.2.2

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.
@@ -24,7 +24,8 @@ const CONFIG = {
24
24
  claudeDir: path.join(os.homedir(), '.claude'),
25
25
  knowledgeApiUrl: 'https://cloudstream-knowledge.broken-rain-0984.workers.dev',
26
26
  requiredDirs: [
27
- 'hooks/scripts',
27
+ 'scripts/hooks',
28
+ 'scripts/lib',
28
29
  'skills',
29
30
  'agents',
30
31
  'commands',
@@ -188,25 +189,43 @@ async function copyConfigWithMerge(sourceDir, targetDir) {
188
189
  }
189
190
 
190
191
  /**
191
- * Update hook paths to use absolute paths
192
+ * Merge hooks into ~/.claude/settings.json
193
+ * Claude Code reads hooks from settings.json, not from a separate hooks.json file
192
194
  */
193
- async function updateHookPaths() {
194
- const hooksJsonPath = path.join(CONFIG.claudeDir, 'hooks', 'hooks.json');
195
+ async function mergeHooksIntoSettings() {
196
+ const settingsPath = path.join(CONFIG.claudeDir, 'settings.json');
197
+ const packageHooksPath = path.join(__dirname, '..', 'hooks', 'hooks.json');
195
198
 
196
199
  try {
197
- const content = await fs.readFile(hooksJsonPath, 'utf8');
198
- let hooksConfig = JSON.parse(content);
200
+ // Read package hooks
201
+ const hooksContent = await fs.readFile(packageHooksPath, 'utf8');
202
+ const hooksConfig = JSON.parse(hooksContent);
199
203
 
200
- // Replace ${CLAUDE_PLUGIN_ROOT} with actual home directory path
204
+ // Update paths to absolute (replace placeholders)
201
205
  const homeDir = os.homedir().replace(/\\/g, '/');
202
- const updatedContent = JSON.stringify(hooksConfig, null, 2)
203
- .replace(/\$\{CLAUDE_PLUGIN_ROOT\}/g, `${homeDir}/.claude`)
204
- .replace(/\$\{HOME\}/g, homeDir);
206
+ const hooksWithAbsolutePaths = JSON.parse(
207
+ JSON.stringify(hooksConfig.hooks)
208
+ .replace(/\$\{CLAUDE_PLUGIN_ROOT\}/g, `${homeDir}/.claude`)
209
+ .replace(/\$\{HOME\}/g, homeDir)
210
+ );
211
+
212
+ // Read existing settings or create empty object
213
+ let settings = {};
214
+ try {
215
+ const existing = await fs.readFile(settingsPath, 'utf8');
216
+ settings = JSON.parse(existing);
217
+ } catch (e) {
218
+ // File doesn't exist, start fresh
219
+ }
205
220
 
206
- await fs.writeFile(hooksJsonPath, updatedContent);
207
- logSuccess('Hook paths updated to absolute paths');
221
+ // Merge hooks into settings
222
+ settings.hooks = hooksWithAbsolutePaths;
223
+
224
+ // Write back to settings.json
225
+ await fs.writeFile(settingsPath, JSON.stringify(settings, null, 2));
226
+ logSuccess('Hooks merged into settings.json');
208
227
  } catch (error) {
209
- logWarning(`Could not update hook paths: ${error.message}`);
228
+ logWarning(`Could not merge hooks into settings: ${error.message}`);
210
229
  }
211
230
  }
212
231
 
@@ -405,26 +424,32 @@ async function setup() {
405
424
  logWarning(`Some configuration files could not be copied: ${error.message}`);
406
425
  }
407
426
 
408
- // Copy hooks.json to ~/.claude/hooks/
409
- const packageHooksJson = path.join(__dirname, '..', 'hooks', 'hooks.json');
410
- const targetHooksJson = path.join(CONFIG.claudeDir, 'hooks', 'hooks.json');
427
+ // Merge hooks into settings.json (Claude Code reads hooks from settings.json)
411
428
  try {
412
- await fs.copyFile(packageHooksJson, targetHooksJson);
413
- await updateHookPaths();
429
+ await mergeHooksIntoSettings();
414
430
  logSuccess('Hooks configuration installed');
415
431
  } catch (error) {
416
- logWarning(`Hooks configuration could not be copied: ${error.message}`);
432
+ logWarning(`Hooks configuration could not be installed: ${error.message}`);
417
433
  }
418
434
 
419
- // Copy hook scripts to ~/.claude/hooks/scripts/
435
+ // Copy hook scripts to ~/.claude/scripts/hooks/ (where hooks.json expects them)
420
436
  const packageScriptsDir = path.join(__dirname, '..', 'scripts', 'hooks');
421
- const targetScriptsDir = path.join(CONFIG.claudeDir, 'hooks', 'scripts');
437
+ const targetScriptsDir = path.join(CONFIG.claudeDir, 'scripts', 'hooks');
422
438
  try {
423
439
  await copyConfigWithMerge(packageScriptsDir, targetScriptsDir);
424
440
  } catch (error) {
425
441
  // Scripts directory may not exist, that's ok
426
442
  }
427
443
 
444
+ // Copy lib scripts to ~/.claude/scripts/lib/ (shared utilities for hooks)
445
+ const packageLibDir = path.join(__dirname, '..', 'scripts', 'lib');
446
+ const targetLibDir = path.join(CONFIG.claudeDir, 'scripts', 'lib');
447
+ try {
448
+ await copyConfigWithMerge(packageLibDir, targetLibDir);
449
+ } catch (error) {
450
+ // Lib directory may not exist, that's ok
451
+ }
452
+
428
453
  // Step 6: Configure MCP server
429
454
  logStep('6/7', 'Configuring MCP server connection...');
430
455
  await configureMcpServer(licenseKey);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudstreamsoftware/claude-tools",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "CloudStream Claude Code productivity tools - hooks, skills, agents, and knowledge server integration",
5
5
  "main": "dist/index.js",
6
6
  "bin": {