claude-code-smart-fork 1.0.3 → 1.0.4

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 (2) hide show
  1. package/package.json +1 -1
  2. package/scripts/install.js +70 -84
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-smart-fork",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Smart session forking for Claude Code - find and resume relevant historical sessions across projects",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -7,119 +7,105 @@ const fs = require('fs');
7
7
  const path = require('path');
8
8
  const os = require('os');
9
9
 
10
- function installClaudeHooks() {
10
+ function installClaudeSkills() {
11
11
  console.log('šŸ”§ Setting up Claude Code Smart Fork integration...\n');
12
12
 
13
- // Find Claude Code configuration directory
14
- const possiblePaths = [
15
- // Cross-platform: ~/.claude/settings.json (primary location for Claude Code)
16
- path.join(os.homedir(), '.claude', 'settings.json'),
17
- // macOS
18
- path.join(os.homedir(), 'Library', 'Application Support', 'Claude', 'settings.json'),
19
- // Linux
20
- path.join(os.homedir(), '.config', 'claude', 'settings.json'),
21
- // Windows
22
- path.join(os.homedir(), 'AppData', 'Roaming', 'Claude', 'settings.json'),
23
- ];
24
-
25
- // Check for CLAUDE_CONFIG environment variable
26
- if (process.env.CLAUDE_CONFIG) {
27
- possiblePaths.unshift(path.join(process.env.CLAUDE_CONFIG, 'settings.json'));
28
- }
29
-
30
- let claudeConfigPath = null;
31
- for (const p of possiblePaths) {
32
- if (fs.existsSync(p)) {
33
- claudeConfigPath = p;
34
- break;
35
- }
36
- }
13
+ // Claude Code commands directory
14
+ const commandsDir = path.join(os.homedir(), '.claude', 'commands');
37
15
 
38
- if (!claudeConfigPath) {
39
- console.log('āš ļø Claude Code configuration not found automatically.');
40
- console.log('To manually install slash commands, add the following to your Claude Code settings:\n');
41
- console.log(JSON.stringify({
42
- slashCommands: [
43
- {
44
- name: 'fork-detect',
45
- description: 'Find relevant historical sessions across all projects',
46
- entrypoint: 'npx smart-fork detect'
47
- },
48
- {
49
- name: 'fork-to',
50
- description: 'Switch to a specific historical session',
51
- entrypoint: 'npx smart-fork fork-to'
52
- },
53
- {
54
- name: 'index-session',
55
- description: 'Index current session for future searching',
56
- entrypoint: 'npx smart-fork index'
57
- },
58
- {
59
- name: 'list-sessions',
60
- description: 'List all indexed sessions',
61
- entrypoint: 'npx smart-fork list'
62
- }
63
- ]
64
- }, null, 2));
65
- return;
66
- }
67
-
68
- // Read existing config
69
- let config = {};
70
- try {
71
- config = JSON.parse(fs.readFileSync(claudeConfigPath, 'utf-8'));
72
- } catch {
73
- // File doesn't exist or is invalid, start fresh
74
- }
16
+ // Ensure commands directory exists
17
+ fs.mkdirSync(commandsDir, { recursive: true });
75
18
 
76
- // Add our slash commands
77
- config.slashCommands = config.slashCommands || [];
78
-
79
- const ourCommands = [
19
+ // Define our skills
20
+ const skills = [
80
21
  {
81
22
  name: 'fork-detect',
82
23
  description: 'Find relevant historical sessions across all projects',
83
- entrypoint: 'npx smart-fork detect'
24
+ content: `# /fork-detect
25
+
26
+ Find relevant historical sessions across all projects using AI-powered semantic search.
27
+
28
+ \`\`\`bash
29
+ npx smart-fork detect "$@"
30
+ \`\`\`
31
+ `
84
32
  },
85
33
  {
86
34
  name: 'fork-to',
87
35
  description: 'Switch to a specific historical session (usage: /fork-to <session-id>)',
88
- entrypoint: 'npx smart-fork fork-to'
36
+ content: `# /fork-to
37
+
38
+ Switch to a specific historical session.
39
+
40
+ Usage: /fork-to <session-id>
41
+
42
+ \`\`\`bash
43
+ npx smart-fork fork-to "$@"
44
+ \`\`\`
45
+ `
89
46
  },
90
47
  {
91
48
  name: 'index-session',
92
49
  description: 'Index current session for future searching',
93
- entrypoint: 'npx smart-fork index'
50
+ content: `# /index-session
51
+
52
+ Index current session for future searching.
53
+
54
+ \`\`\`bash
55
+ npx smart-fork index "$@"
56
+ \`\`\`
57
+ `
94
58
  },
95
59
  {
96
60
  name: 'list-sessions',
97
61
  description: 'List all indexed sessions',
98
- entrypoint: 'npx smart-fork list'
62
+ content: `# /list-sessions
63
+
64
+ List all indexed sessions.
65
+
66
+ \`\`\`bash
67
+ npx smart-fork list "$@"
68
+ \`\`\`
69
+ `
99
70
  },
100
71
  {
101
72
  name: 'fork-status',
102
73
  description: 'Show current fork status and suggestions',
103
- entrypoint: 'npx smart-fork status'
74
+ content: `# /fork-status
75
+
76
+ Show current fork status and suggestions.
77
+
78
+ \`\`\`bash
79
+ npx smart-fork status "$@"
80
+ \`\`\`
81
+ `
104
82
  }
105
83
  ];
106
84
 
107
- // Remove existing commands with same names
108
- config.slashCommands = config.slashCommands.filter(
109
- cmd => !ourCommands.some(our => our.name === cmd.name)
110
- );
85
+ // Install each skill
86
+ let installed = 0;
87
+ for (const skill of skills) {
88
+ const skillPath = path.join(commandsDir, `${skill.name}.md`);
111
89
 
112
- // Add our commands
113
- config.slashCommands.push(...ourCommands);
90
+ // Check if skill already exists
91
+ if (fs.existsSync(skillPath)) {
92
+ console.log(`āš ļø /${skill.name} already exists, skipping...`);
93
+ } else {
94
+ fs.writeFileSync(skillPath, skill.content);
95
+ console.log(`āœ… Created /${skill.name}`);
96
+ installed++;
97
+ }
98
+ }
114
99
 
115
- // Save config
116
- fs.mkdirSync(path.dirname(claudeConfigPath), { recursive: true });
117
- fs.writeFileSync(claudeConfigPath, JSON.stringify(config, null, 2));
100
+ if (installed === 0) {
101
+ console.log('\nāœ… All skills are already installed!\n');
102
+ } else {
103
+ console.log(`\nāœ… Installed ${installed} new skill(s)!\n`);
104
+ }
118
105
 
119
- console.log('āœ… Claude Code integration installed successfully!\n');
120
106
  console.log('Available slash commands:');
121
- ourCommands.forEach(cmd => {
122
- console.log(` /${cmd.name} - ${cmd.description}`);
107
+ skills.forEach(skill => {
108
+ console.log(` /${skill.name} - ${skill.description}`);
123
109
  });
124
110
  console.log('\nUsage:');
125
111
  console.log(' 1. Index your current session: /index-session');
@@ -128,4 +114,4 @@ function installClaudeHooks() {
128
114
  }
129
115
 
130
116
  // Run installation
131
- installClaudeHooks();
117
+ installClaudeSkills();