claude-session-share 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/LICENSE +21 -0
- package/README.md +313 -0
- package/dist/__tests__/e2e.test.js +532 -0
- package/dist/__tests__/gist-client.test.js +341 -0
- package/dist/__tests__/index.test.js +16 -0
- package/dist/__tests__/mcp-integration.test.js +403 -0
- package/dist/__tests__/path-encoding.test.js +77 -0
- package/dist/__tests__/pipeline.test.js +342 -0
- package/dist/__tests__/redactor.test.js +162 -0
- package/dist/__tests__/sanitizer.test.js +345 -0
- package/dist/__tests__/session-importer.test.js +216 -0
- package/dist/__tests__/session-reader.test.js +298 -0
- package/dist/__tests__/session-uploader.test.js +216 -0
- package/dist/__tests__/session-writer.test.js +286 -0
- package/dist/__tests__/uuid-mapper.test.js +249 -0
- package/dist/gist/client.js +199 -0
- package/dist/gist/types.js +7 -0
- package/dist/index.js +214 -0
- package/dist/sanitization/pipeline.js +48 -0
- package/dist/sanitization/redactor.js +48 -0
- package/dist/sanitization/sanitizer.js +87 -0
- package/dist/services/session-importer.js +88 -0
- package/dist/services/session-uploader.js +64 -0
- package/dist/session/finder.js +65 -0
- package/dist/session/metadata.js +55 -0
- package/dist/session/reader.js +101 -0
- package/dist/session/types.js +11 -0
- package/dist/session/writer.js +74 -0
- package/dist/utils/path-encoding.js +54 -0
- package/dist/utils/uuid-mapper.js +73 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Omkar Kovvali
|
|
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,313 @@
|
|
|
1
|
+
# claude-session-share
|
|
2
|
+
|
|
3
|
+
> **MCP server for sharing Claude Code sessions via GitHub Gist with automatic privacy protection**
|
|
4
|
+
|
|
5
|
+
Share your Claude Code conversations effortlessly while keeping your private data safe. This MCP server enables you to export sessions to shareable GitHub Gist links and import them backβall through natural language.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/claude-session-share)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
|
+
|
|
10
|
+
## β¨ Features
|
|
11
|
+
|
|
12
|
+
- **π One-Click Sharing** - Export sessions to GitHub Gist with a simple command
|
|
13
|
+
- **π Privacy First** - Automatically strips thinking blocks, sanitizes paths, and redacts secrets
|
|
14
|
+
- **π₯ Seamless Import** - Import shared sessions that work exactly like native Claude Code sessions
|
|
15
|
+
- **π¬ Natural Language** - Just ask Claude to "share my session" or "import from [link]"
|
|
16
|
+
- **π Full Compatibility** - Imported sessions appear in `claude --resume` and preserve conversation context
|
|
17
|
+
|
|
18
|
+
## π¦ Installation
|
|
19
|
+
|
|
20
|
+
### Prerequisites
|
|
21
|
+
|
|
22
|
+
- Node.js 18+
|
|
23
|
+
- Claude Code CLI
|
|
24
|
+
- GitHub Personal Access Token with `gist` scope
|
|
25
|
+
|
|
26
|
+
### Install via npm
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install -g claude-session-share
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Setup GitHub Token
|
|
33
|
+
|
|
34
|
+
1. Go to [GitHub Settings > Personal Access Tokens](https://github.com/settings/tokens)
|
|
35
|
+
2. Click "Generate new token (classic)"
|
|
36
|
+
3. Give it a name like "Claude Session Share"
|
|
37
|
+
4. Check the **`gist`** scope
|
|
38
|
+
5. Generate and copy the token
|
|
39
|
+
|
|
40
|
+
## βοΈ Configuration
|
|
41
|
+
|
|
42
|
+
Add the MCP server to your Claude Code configuration:
|
|
43
|
+
|
|
44
|
+
### Option 1: User Config (Recommended)
|
|
45
|
+
|
|
46
|
+
Create or edit `~/.claude/mcp.json`:
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"mcpServers": {
|
|
51
|
+
"claude-session-share": {
|
|
52
|
+
"command": "npx",
|
|
53
|
+
"args": ["-y", "claude-session-share"],
|
|
54
|
+
"env": {
|
|
55
|
+
"GITHUB_TOKEN": "ghp_your_token_here"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Option 2: Project-Specific Config
|
|
63
|
+
|
|
64
|
+
Create `.mcp.json` in your project directory with the same structure.
|
|
65
|
+
|
|
66
|
+
### Verify Installation
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# Check if the MCP server is recognized
|
|
70
|
+
claude # Start Claude Code
|
|
71
|
+
# Then type: /mcp
|
|
72
|
+
# You should see "claude-session-share" in the list
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## π Usage
|
|
76
|
+
|
|
77
|
+
### Sharing a Session
|
|
78
|
+
|
|
79
|
+
In any Claude Code conversation, simply say:
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
"Share my current session to GitHub Gist"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Claude will:
|
|
86
|
+
1. Find your current session
|
|
87
|
+
2. Remove thinking blocks and sanitize paths/secrets
|
|
88
|
+
3. Upload to a secret (unlisted) GitHub Gist
|
|
89
|
+
4. Return a shareable link
|
|
90
|
+
|
|
91
|
+
**Example output:**
|
|
92
|
+
```
|
|
93
|
+
β Session shared successfully!
|
|
94
|
+
Link: https://gist.github.com/username/abc123...
|
|
95
|
+
|
|
96
|
+
Share this link with anyone. They can import it with:
|
|
97
|
+
"Import session from https://gist.github.com/username/abc123..."
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Importing a Session
|
|
101
|
+
|
|
102
|
+
To import a shared session:
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
"Import this session: https://gist.github.com/username/abc123..."
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Claude will:
|
|
109
|
+
1. Fetch the session from the Gist
|
|
110
|
+
2. Remap UUIDs to avoid conflicts
|
|
111
|
+
3. Write to your local `.claude/projects/` directory
|
|
112
|
+
4. Make it available for resuming
|
|
113
|
+
|
|
114
|
+
### Resuming an Imported Session
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
cd your-project-directory
|
|
118
|
+
claude --resume
|
|
119
|
+
# Select the imported session from the list
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
The imported session works exactly like a native Claude Code sessionβfull conversation history, no thinking blocks, perfect privacy.
|
|
123
|
+
|
|
124
|
+
## π Privacy Protection
|
|
125
|
+
|
|
126
|
+
Every shared session is automatically sanitized:
|
|
127
|
+
|
|
128
|
+
### β
What Gets Removed/Sanitized
|
|
129
|
+
|
|
130
|
+
- **Thinking Blocks** - Internal reasoning stripped completely
|
|
131
|
+
- **Absolute Paths** - `/Users/you/project/file.ts` β `file.ts`
|
|
132
|
+
- **API Keys** - `sk_test_abc123`, `ghp_token`, AWS keys β `[REDACTED]`
|
|
133
|
+
- **Tokens** - Bearer tokens, OAuth tokens β `[REDACTED]`
|
|
134
|
+
- **Secrets** - Environment variables, passwords (key=value format) β `[REDACTED]`
|
|
135
|
+
|
|
136
|
+
### β
What Gets Preserved
|
|
137
|
+
|
|
138
|
+
- Conversation flow and context
|
|
139
|
+
- Code examples and explanations
|
|
140
|
+
- File names and relative paths
|
|
141
|
+
- Tool use history
|
|
142
|
+
- UUIDs and message chains (remapped on import)
|
|
143
|
+
|
|
144
|
+
### Known Limitations
|
|
145
|
+
|
|
146
|
+
- Passwords in connection strings (e.g., `postgresql://user:pass@host/db`) are not detected
|
|
147
|
+
- Secrets in natural language (not key=value format) may not be redacted
|
|
148
|
+
- These tradeoffs prevent false positives on legitimate content
|
|
149
|
+
|
|
150
|
+
## π MCP Tools Reference
|
|
151
|
+
|
|
152
|
+
The server provides two MCP tools:
|
|
153
|
+
|
|
154
|
+
### `share_session`
|
|
155
|
+
|
|
156
|
+
Exports the current session to GitHub Gist.
|
|
157
|
+
|
|
158
|
+
**Parameters:**
|
|
159
|
+
- `sessionPath` (optional) - Path to session file (defaults to most recent)
|
|
160
|
+
|
|
161
|
+
**Returns:**
|
|
162
|
+
- `gistUrl` - Shareable GitHub Gist URL
|
|
163
|
+
- `messageCount` - Number of messages exported
|
|
164
|
+
|
|
165
|
+
### `import_session`
|
|
166
|
+
|
|
167
|
+
Imports a session from a GitHub Gist.
|
|
168
|
+
|
|
169
|
+
**Parameters:**
|
|
170
|
+
- `gistUrl` - GitHub Gist URL (e.g., `https://gist.github.com/user/abc123`)
|
|
171
|
+
- `projectPath` (optional) - Local project directory (defaults to current directory)
|
|
172
|
+
|
|
173
|
+
**Returns:**
|
|
174
|
+
- `sessionPath` - Path to imported session file
|
|
175
|
+
- `sessionId` - New session ID
|
|
176
|
+
- `messageCount` - Number of messages imported
|
|
177
|
+
|
|
178
|
+
## π οΈ Development
|
|
179
|
+
|
|
180
|
+
### Clone and Setup
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
git clone https://github.com/OmkarKovvali/claude-session-share.git
|
|
184
|
+
cd claude-session-share
|
|
185
|
+
npm install
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Build
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
npm run build
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Run Tests
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
npm test
|
|
198
|
+
# 337 tests with full coverage
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Project Structure
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
claude-session-share/
|
|
205
|
+
βββ src/
|
|
206
|
+
β βββ index.ts # MCP server entry point
|
|
207
|
+
β βββ gist/ # GitHub Gist integration
|
|
208
|
+
β βββ sanitization/ # Privacy protection
|
|
209
|
+
β βββ services/ # Share/import orchestration
|
|
210
|
+
β βββ session/ # Session read/write
|
|
211
|
+
β βββ utils/ # UUID remapping, etc.
|
|
212
|
+
βββ dist/ # Compiled output
|
|
213
|
+
βββ .planning/ # Project planning docs
|
|
214
|
+
βββ package.json
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## π§ͺ Testing
|
|
218
|
+
|
|
219
|
+
The project includes comprehensive test coverage:
|
|
220
|
+
|
|
221
|
+
- **Unit Tests** - All modules tested individually
|
|
222
|
+
- **Integration Tests** - Service orchestration verified
|
|
223
|
+
- **E2E Tests** - Full shareβimportβresume workflow validated
|
|
224
|
+
- **Real API Tests** - GitHub Gist integration tested with actual API
|
|
225
|
+
|
|
226
|
+
Run tests:
|
|
227
|
+
```bash
|
|
228
|
+
npm test # All tests
|
|
229
|
+
npm test -- session-reader # Specific test file
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## π€ Contributing
|
|
233
|
+
|
|
234
|
+
Contributions welcome! Please:
|
|
235
|
+
|
|
236
|
+
1. Fork the repository
|
|
237
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
238
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
239
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
240
|
+
5. Open a Pull Request
|
|
241
|
+
|
|
242
|
+
### Code Style
|
|
243
|
+
|
|
244
|
+
- TypeScript with strict mode
|
|
245
|
+
- ESM modules
|
|
246
|
+
- Functional programming style (immutable transformations)
|
|
247
|
+
- Comprehensive tests for new features
|
|
248
|
+
|
|
249
|
+
## π Roadmap
|
|
250
|
+
|
|
251
|
+
- [x] Core share/import functionality
|
|
252
|
+
- [x] Privacy sanitization
|
|
253
|
+
- [x] MCP server integration
|
|
254
|
+
- [x] End-to-end testing
|
|
255
|
+
- [ ] Web interface for browsing shared sessions
|
|
256
|
+
- [ ] Session versioning and updates
|
|
257
|
+
- [ ] Organization/team sharing features
|
|
258
|
+
- [ ] Custom sanitization rules
|
|
259
|
+
|
|
260
|
+
## π Troubleshooting
|
|
261
|
+
|
|
262
|
+
### "Not authenticated" Error
|
|
263
|
+
|
|
264
|
+
Make sure your `GITHUB_TOKEN` is set in the MCP configuration:
|
|
265
|
+
```json
|
|
266
|
+
"env": {
|
|
267
|
+
"GITHUB_TOKEN": "ghp_your_token_here"
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### "No sessions found" Error
|
|
272
|
+
|
|
273
|
+
Ensure you're in a directory with an active Claude Code session. Sessions are stored in `~/.claude/projects/`.
|
|
274
|
+
|
|
275
|
+
### Imported Session Doesn't Appear
|
|
276
|
+
|
|
277
|
+
Check that the session was written to the correct location:
|
|
278
|
+
```bash
|
|
279
|
+
ls -la ~/.claude/projects/*/
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
Each project directory should have a `.jsonl` fileβthat's your session.
|
|
283
|
+
|
|
284
|
+
### MCP Server Not Listed
|
|
285
|
+
|
|
286
|
+
Verify your MCP configuration:
|
|
287
|
+
```bash
|
|
288
|
+
cat ~/.claude/mcp.json
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
Then restart Claude Code.
|
|
292
|
+
|
|
293
|
+
## π License
|
|
294
|
+
|
|
295
|
+
MIT Β© Omkar Kovvali
|
|
296
|
+
|
|
297
|
+
See [LICENSE](LICENSE) file for details.
|
|
298
|
+
|
|
299
|
+
## π Acknowledgments
|
|
300
|
+
|
|
301
|
+
- Built with [Model Context Protocol](https://modelcontextprotocol.io/)
|
|
302
|
+
- Uses [GitHub Gist API](https://docs.github.com/en/rest/gists)
|
|
303
|
+
- Powered by [Claude Code](https://www.anthropic.com/claude)
|
|
304
|
+
|
|
305
|
+
## π Support
|
|
306
|
+
|
|
307
|
+
- **Issues**: [GitHub Issues](https://github.com/OmkarKovvali/claude-session-share/issues)
|
|
308
|
+
- **Discussions**: [GitHub Discussions](https://github.com/OmkarKovvali/claude-session-share/discussions)
|
|
309
|
+
- **Email**: okovvali5@gmail.com
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
**Made with β€οΈ for the Claude Code community**
|