claude-code-smart-fork 1.0.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.
- package/CHANGELOG.md +36 -0
- package/LICENSE +21 -0
- package/README.md +317 -0
- package/README.zh-CN.md +45 -0
- package/dist/cli/index.d.ts +8 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +351 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/__tests__/embedding.test.d.ts +2 -0
- package/dist/core/__tests__/embedding.test.d.ts.map +1 -0
- package/dist/core/__tests__/embedding.test.js +90 -0
- package/dist/core/__tests__/embedding.test.js.map +1 -0
- package/dist/core/config.d.ts +19 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +105 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/embedding.d.ts +28 -0
- package/dist/core/embedding.d.ts.map +1 -0
- package/dist/core/embedding.js +137 -0
- package/dist/core/embedding.js.map +1 -0
- package/dist/core/fork-detector.d.ts +38 -0
- package/dist/core/fork-detector.d.ts.map +1 -0
- package/dist/core/fork-detector.js +234 -0
- package/dist/core/fork-detector.js.map +1 -0
- package/dist/core/session-manager.d.ts +77 -0
- package/dist/core/session-manager.d.ts.map +1 -0
- package/dist/core/session-manager.js +525 -0
- package/dist/core/session-manager.js.map +1 -0
- package/dist/core/vector-store.d.ts +47 -0
- package/dist/core/vector-store.d.ts.map +1 -0
- package/dist/core/vector-store.js +204 -0
- package/dist/core/vector-store.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/claude-code.d.ts +53 -0
- package/dist/integrations/claude-code.d.ts.map +1 -0
- package/dist/integrations/claude-code.js +277 -0
- package/dist/integrations/claude-code.js.map +1 -0
- package/dist/types/index.d.ts +106 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +79 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Initial release of Claude Code Smart Fork
|
|
12
|
+
- Semantic search for sessions across projects
|
|
13
|
+
- Support for multiple embedding providers (local, OpenAI, Ollama)
|
|
14
|
+
- Support for multiple vector stores (local JSON, ChromaDB, Pinecone)
|
|
15
|
+
- CLI commands: `detect`, `fork-to`, `index`, `list`, `status`, `config`
|
|
16
|
+
- Claude Code slash command integration
|
|
17
|
+
- Session indexing and management
|
|
18
|
+
- Cross-project search capability
|
|
19
|
+
- Local data storage with privacy-focused design
|
|
20
|
+
- Configuration management
|
|
21
|
+
- Export and import session functionality
|
|
22
|
+
|
|
23
|
+
## [1.0.0] - 2026-03-01
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
- First stable release
|
|
27
|
+
- Complete documentation (English and Chinese)
|
|
28
|
+
- GitHub Actions CI/CD workflow
|
|
29
|
+
- Issue and PR templates
|
|
30
|
+
- Contributing guidelines
|
|
31
|
+
- Code of conduct
|
|
32
|
+
- Security policy
|
|
33
|
+
- MIT License
|
|
34
|
+
|
|
35
|
+
[Unreleased]: https://github.com/yourusername/claude-code-smart-fork/compare/v1.0.0...HEAD
|
|
36
|
+
[1.0.0]: https://github.com/yourusername/claude-code-smart-fork/releases/tag/v1.0.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Claude Code Smart Fork Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
# Claude Code Smart Fork
|
|
2
|
+
|
|
3
|
+
🔀 **Smart session forking for Claude Code** - Find and resume relevant historical sessions across all your projects using AI-powered semantic search.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/claude-code-smart-fork)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://github.com/yourusername/claude-code-smart-fork/actions)
|
|
8
|
+
|
|
9
|
+
## 🌟 Features
|
|
10
|
+
|
|
11
|
+
- 🔍 **Semantic Search** - Find relevant sessions based on meaning, not just keywords
|
|
12
|
+
- 🌐 **Cross-Project** - Search across all your projects, not just the current one
|
|
13
|
+
- 🤖 **AI-Powered** - Uses embeddings to understand context and intent
|
|
14
|
+
- ⚡ **Fast** - Local vector storage for instant results
|
|
15
|
+
- 🔒 **Private** - All data stays on your machine by default
|
|
16
|
+
- 🎯 **Easy Integration** - Works seamlessly with Claude Code as slash commands
|
|
17
|
+
|
|
18
|
+
## 📦 Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Install globally
|
|
22
|
+
npm install -g claude-code-smart-fork
|
|
23
|
+
|
|
24
|
+
# Or use npx (no installation needed)
|
|
25
|
+
npx claude-code-smart-fork
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## 🚀 Quick Start
|
|
29
|
+
|
|
30
|
+
### 1. Index Your Current Session
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
smart-fork index --summary "Implementing user authentication"
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 2. Later, Find Relevant Sessions
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
smart-fork detect
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### 3. Switch to a Session
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
smart-fork fork-to <session-id>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## 🛠️ Usage
|
|
49
|
+
|
|
50
|
+
### CLI Commands
|
|
51
|
+
|
|
52
|
+
| Command | Description |
|
|
53
|
+
|---------|-------------|
|
|
54
|
+
| `smart-fork index` | Index current session for future searching |
|
|
55
|
+
| `smart-fork detect` | Find relevant historical sessions |
|
|
56
|
+
| `smart-fork detect --all` | Search across all projects |
|
|
57
|
+
| `smart-fork list` | List all indexed sessions |
|
|
58
|
+
| `smart-fork status` | Show current status and suggestions |
|
|
59
|
+
| `smart-fork export <id>` | Export a session to JSON |
|
|
60
|
+
|
|
61
|
+
### Claude Code Integration
|
|
62
|
+
|
|
63
|
+
After installation, these slash commands are available in Claude Code:
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
/index-session - Index current session
|
|
67
|
+
/fork-detect - Find relevant sessions
|
|
68
|
+
/fork-to <id> - Switch to a session
|
|
69
|
+
/list-sessions - List all sessions
|
|
70
|
+
/fork-status - Show status and suggestions
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## ⚙️ Configuration
|
|
74
|
+
|
|
75
|
+
Create `~/.smart-fork/config.json`:
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"embedding": {
|
|
80
|
+
"provider": "local",
|
|
81
|
+
"model": "all-MiniLM-L6-v2",
|
|
82
|
+
"dimension": 384
|
|
83
|
+
},
|
|
84
|
+
"vectorStore": {
|
|
85
|
+
"provider": "local",
|
|
86
|
+
"collectionName": "smart-fork-sessions"
|
|
87
|
+
},
|
|
88
|
+
"storage": {
|
|
89
|
+
"sessionsDir": "~/.smart-fork/sessions",
|
|
90
|
+
"indexPath": "~/.smart-fork/index.json"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Embedding Providers
|
|
96
|
+
|
|
97
|
+
#### Local (Default) - No API key needed
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"embedding": {
|
|
101
|
+
"provider": "local",
|
|
102
|
+
"model": "all-MiniLM-L6-v2"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
#### OpenAI
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"embedding": {
|
|
111
|
+
"provider": "openai",
|
|
112
|
+
"model": "text-embedding-3-small"
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
Requires `OPENAI_API_KEY` environment variable.
|
|
117
|
+
|
|
118
|
+
#### Ollama
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"embedding": {
|
|
122
|
+
"provider": "ollama",
|
|
123
|
+
"model": "nomic-embed-text"
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
Requires a running Ollama server.
|
|
128
|
+
|
|
129
|
+
## 💡 Usage Examples
|
|
130
|
+
|
|
131
|
+
### Example 1: Index a Session with Conversation History
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
# Create a conversation history file
|
|
135
|
+
cat > conversation.json << 'EOF'
|
|
136
|
+
[
|
|
137
|
+
{
|
|
138
|
+
"id": "turn-1",
|
|
139
|
+
"timestamp": 1709400000000,
|
|
140
|
+
"userMessage": {
|
|
141
|
+
"content": "How do I implement user authentication?",
|
|
142
|
+
"metadata": { "files": ["auth.js"] }
|
|
143
|
+
},
|
|
144
|
+
"assistantMessage": {
|
|
145
|
+
"content": "I recommend using JWT + OAuth2. JWT is great for stateless auth, OAuth2 for third-party login.",
|
|
146
|
+
"toolCalls": [{"id": "1", "type": "search", "parameters": {"query": "JWT best practices"}}]
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"id": "turn-2",
|
|
151
|
+
"timestamp": 1709400100000,
|
|
152
|
+
"userMessage": {
|
|
153
|
+
"content": "Show me code examples"
|
|
154
|
+
},
|
|
155
|
+
"assistantMessage": {
|
|
156
|
+
"content": "Here's a Node.js example using jsonwebtoken...",
|
|
157
|
+
"toolCalls": [
|
|
158
|
+
{"id": "2", "type": "read_file", "parameters": {"path": "examples/auth.js"}},
|
|
159
|
+
{"id": "3", "type": "edit_file", "parameters": {"path": "src/auth.js"}}
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
EOF
|
|
165
|
+
|
|
166
|
+
# Index the session
|
|
167
|
+
smart-fork index --conversation conversation.json --summary "User authentication with JWT" --tags "auth,jwt,nodejs"
|
|
168
|
+
|
|
169
|
+
# Output:
|
|
170
|
+
# ✓ Session indexed successfully!
|
|
171
|
+
# Session ID: 096549e9-13bd-45bd-9f6c-659d55c78b35
|
|
172
|
+
# Conversation turns: 2
|
|
173
|
+
# Total messages: 4
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Example 2: Find and Resume a Session
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# Search for relevant sessions
|
|
180
|
+
smart-fork detect --query "authentication JWT code examples"
|
|
181
|
+
|
|
182
|
+
# Output:
|
|
183
|
+
# ✓ Found 1 relevant session(s):
|
|
184
|
+
#
|
|
185
|
+
# 1. my-first-app
|
|
186
|
+
# Path: D:\\claudecode\\MyAICodes\\my-first-app
|
|
187
|
+
# Relevance: 85%
|
|
188
|
+
# Summary: User authentication with JWT
|
|
189
|
+
# Last updated: 2026/3/2
|
|
190
|
+
|
|
191
|
+
# Fork to the session
|
|
192
|
+
smart-fork fork-to 096549e9-13bd-45bd-9f6c-659d55c78b35
|
|
193
|
+
|
|
194
|
+
# Output:
|
|
195
|
+
# 💬 Conversation History:
|
|
196
|
+
# ────────────────────────────────────────────────────────────
|
|
197
|
+
# [1] 👤 User:
|
|
198
|
+
# How do I implement user authentication?
|
|
199
|
+
# 🤖 Assistant:
|
|
200
|
+
# I recommend using JWT + OAuth2...
|
|
201
|
+
# 🔧 Tool calls: search
|
|
202
|
+
# ────────────────────────────────────────────────────────────
|
|
203
|
+
# [2] 👤 User:
|
|
204
|
+
# Show me code examples
|
|
205
|
+
# 🤖 Assistant:
|
|
206
|
+
# Here's a Node.js example...
|
|
207
|
+
# 🔧 Tool calls: read_file, edit_file
|
|
208
|
+
# ────────────────────────────────────────────────────────────
|
|
209
|
+
# ✨ Total turns: 2
|
|
210
|
+
# 💡 You can continue the conversation from here.
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Example 3: Cross-Project Search
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
# Index sessions in multiple projects
|
|
217
|
+
# Project A: API Gateway
|
|
218
|
+
cd ~/projects/api-gateway
|
|
219
|
+
smart-fork index --summary "Implementing rate limiting middleware"
|
|
220
|
+
|
|
221
|
+
# Project B: Frontend
|
|
222
|
+
cd ~/projects/frontend
|
|
223
|
+
smart-fork index --summary "Setting up React authentication context"
|
|
224
|
+
|
|
225
|
+
# Search across all projects
|
|
226
|
+
cd ~/projects/api-gateway
|
|
227
|
+
smart-fork detect --all --query "authentication middleware"
|
|
228
|
+
|
|
229
|
+
# Results will show relevant sessions from both projects!
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Example 4: Using with Claude Code Slash Commands
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
# In Claude Code, use slash commands:
|
|
236
|
+
|
|
237
|
+
# Index current session
|
|
238
|
+
/index-session Implementing user authentication --tags auth,jwt
|
|
239
|
+
|
|
240
|
+
# Later, find relevant sessions
|
|
241
|
+
/fork-detect
|
|
242
|
+
|
|
243
|
+
# Fork to a specific session
|
|
244
|
+
/fork-to 096549e9-13bd-45bd-9f6c-659d55c78b35
|
|
245
|
+
|
|
246
|
+
# List all sessions
|
|
247
|
+
/list-sessions
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## 📁 Data Storage
|
|
251
|
+
|
|
252
|
+
All data is stored locally in `~/.smart-fork/`:
|
|
253
|
+
|
|
254
|
+
```
|
|
255
|
+
~/.smart-fork/
|
|
256
|
+
├── sessions/ # Full session data (JSON)
|
|
257
|
+
├── index.json # Session index with embeddings
|
|
258
|
+
└── config.json # User configuration
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## 🔧 Development
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
# Clone the repository
|
|
265
|
+
git clone https://github.com/yourusername/claude-code-smart-fork.git
|
|
266
|
+
cd claude-code-smart-fork
|
|
267
|
+
|
|
268
|
+
# Install dependencies
|
|
269
|
+
npm install
|
|
270
|
+
|
|
271
|
+
# Build the project
|
|
272
|
+
npm run build
|
|
273
|
+
|
|
274
|
+
# Run tests
|
|
275
|
+
npm test
|
|
276
|
+
|
|
277
|
+
# Watch mode for development
|
|
278
|
+
npm run dev
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
## 📚 API Usage
|
|
282
|
+
|
|
283
|
+
```typescript
|
|
284
|
+
import { ForkDetector, SessionManager } from 'claude-code-smart-fork';
|
|
285
|
+
|
|
286
|
+
const detector = new ForkDetector();
|
|
287
|
+
await detector.initialize();
|
|
288
|
+
|
|
289
|
+
// Find relevant sessions
|
|
290
|
+
const results = await detector.findRelevantSessions({
|
|
291
|
+
text: "How to implement authentication?",
|
|
292
|
+
limit: 5
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
// Switch to a session
|
|
296
|
+
const sessionManager = new SessionManager();
|
|
297
|
+
await sessionManager.forkToSession(results[0].session.id);
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
## 🤝 Contributing
|
|
301
|
+
|
|
302
|
+
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
303
|
+
|
|
304
|
+
## 📄 License
|
|
305
|
+
|
|
306
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
307
|
+
|
|
308
|
+
## 🙏 Acknowledgments
|
|
309
|
+
|
|
310
|
+
- Inspired by the need for better session management in Claude Code
|
|
311
|
+
- Thanks to the open-source community for the amazing tools
|
|
312
|
+
|
|
313
|
+
## 📮 Support
|
|
314
|
+
|
|
315
|
+
- 🐛 [Report a bug](https://github.com/yourusername/claude-code-smart-fork/issues)
|
|
316
|
+
- 💡 [Request a feature](https://github.com/yourusername/claude-code-smart-fork/issues)
|
|
317
|
+
- 📧 Contact: your-email@example.com
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Claude Code Smart Fork 中文文档
|
|
2
|
+
|
|
3
|
+
🔀 **Claude Code 智能会话分支** - 使用 AI 驱动的语义搜索,在所有项目中查找并恢复相关的历史会话。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- 🔍 **语义搜索** - 基于含义而非关键词查找相关会话
|
|
8
|
+
- 🌐 **跨项目** - 在所有项目中搜索,不限于当前项目
|
|
9
|
+
- 🤖 **AI 驱动** - 使用嵌入向量理解上下文和意图
|
|
10
|
+
- ⚡ **快速** - 本地向量存储,即时返回结果
|
|
11
|
+
- 🔒 **隐私** - 默认所有数据保存在本地
|
|
12
|
+
|
|
13
|
+
## 快速开始
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# 安装
|
|
17
|
+
npm install -g claude-code-smart-fork
|
|
18
|
+
|
|
19
|
+
# 索引当前会话
|
|
20
|
+
smart-fork index --summary "实现用户认证功能"
|
|
21
|
+
|
|
22
|
+
# 查找相关会话
|
|
23
|
+
smart-fork detect
|
|
24
|
+
|
|
25
|
+
# 跨所有项目搜索
|
|
26
|
+
smart-fork detect --all
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Claude Code 集成
|
|
30
|
+
|
|
31
|
+
安装后,在 Claude Code 中可以使用以下命令:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
/index-session - 索引当前会话
|
|
35
|
+
/fork-detect - 查找相关会话
|
|
36
|
+
/fork-to <id> - 切换到指定会话
|
|
37
|
+
/list-sessions - 列出所有会话
|
|
38
|
+
/fork-status - 显示状态和建议
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## 更多文档
|
|
42
|
+
|
|
43
|
+
- [英文 README](./README.md)
|
|
44
|
+
- [贡献指南](./CONTRIBUTING.md)
|
|
45
|
+
- [更新日志](./CHANGELOG.md)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,QAAA,MAAM,OAAO,SAAgB,CAAC;AAmW9B,OAAO,EAAE,OAAO,EAAE,CAAC"}
|