ccs-cloner 0.3.1 → 0.3.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 +26 -19
- package/dist/cli.js +17480 -26683
- package/package.json +8 -10
package/README.md
CHANGED
|
@@ -8,10 +8,9 @@ Claude Code sessions accumulate context over time: tool calls with large inputs/
|
|
|
8
8
|
|
|
9
9
|
ccs-cloner creates a lean copy of a session by:
|
|
10
10
|
|
|
11
|
-
1.
|
|
12
|
-
2.
|
|
13
|
-
3.
|
|
14
|
-
4. Automatically removing thinking blocks when tools are modified
|
|
11
|
+
1. Removing tool calls from old turns while preserving recent ones
|
|
12
|
+
2. Truncating tool content in intermediate turns for gradual context reduction
|
|
13
|
+
3. Automatically removing thinking blocks when `--strip-tools` is used
|
|
15
14
|
|
|
16
15
|
The cloned session appears in `claude --resume` and can be continued with reduced context.
|
|
17
16
|
|
|
@@ -30,10 +29,12 @@ cd ccs-cloner
|
|
|
30
29
|
bun install && bun link
|
|
31
30
|
```
|
|
32
31
|
|
|
33
|
-
Requires Bun 1.0+ or Node.js
|
|
32
|
+
Requires Bun 1.0+ or Node.js 18+.
|
|
34
33
|
|
|
35
34
|
## Quick Start
|
|
36
35
|
|
|
36
|
+
**TIP:** Configure Claude Code to show session ID in status line for easy access.
|
|
37
|
+
|
|
37
38
|
```bash
|
|
38
39
|
# List recent sessions to find the session ID
|
|
39
40
|
ccs-cloner list
|
|
@@ -107,11 +108,18 @@ ccs-cloner clone <sessionId> [options]
|
|
|
107
108
|
|------|-------------|
|
|
108
109
|
| `--strip-tools` | Remove tools using default preset |
|
|
109
110
|
| `--strip-tools=<preset>` | Remove tools using named preset (default, aggressive, extreme, or custom) |
|
|
111
|
+
| `--dsp` | Include `--dangerously-skip-permissions` in resume command |
|
|
110
112
|
| `--output, -o <path>` | Output path (default: auto-generated in same project directory) |
|
|
111
113
|
| `--claude-dir <path>` | Claude data directory (default: `~/.claude`) |
|
|
112
114
|
| `--json` | Output result as JSON |
|
|
113
115
|
| `--verbose, -v` | Verbose output with statistics |
|
|
114
116
|
|
|
117
|
+
**Known Issue:** `--strip-tools` consumes the next flag as its value. Put other flags BEFORE it:
|
|
118
|
+
```bash
|
|
119
|
+
ccs-cloner clone <id> --dsp --strip-tools # works
|
|
120
|
+
ccs-cloner clone <id> --strip-tools --dsp # fails
|
|
121
|
+
```
|
|
122
|
+
|
|
115
123
|
**Examples:**
|
|
116
124
|
|
|
117
125
|
```bash
|
|
@@ -124,11 +132,14 @@ ccs-cloner clone abc-123-def --strip-tools=aggressive
|
|
|
124
132
|
# Extreme: remove all tools
|
|
125
133
|
ccs-cloner clone abc-123-def --strip-tools=extreme
|
|
126
134
|
|
|
135
|
+
# Include --dangerously-skip-permissions in resume command
|
|
136
|
+
ccs-cloner clone abc-123-def --dsp --strip-tools
|
|
137
|
+
|
|
127
138
|
# Custom output location
|
|
128
139
|
ccs-cloner clone abc-123-def --strip-tools -o ./backup.jsonl
|
|
129
140
|
|
|
130
141
|
# JSON output for scripting
|
|
131
|
-
ccs-cloner clone abc-123-def --strip-tools
|
|
142
|
+
ccs-cloner clone abc-123-def --json --strip-tools
|
|
132
143
|
```
|
|
133
144
|
|
|
134
145
|
### list
|
|
@@ -250,11 +261,13 @@ Configuration sources are merged in order (later overrides earlier):
|
|
|
250
261
|
|
|
251
262
|
## How It Works
|
|
252
263
|
|
|
253
|
-
### Active Branch Extraction
|
|
264
|
+
### Active Branch Extraction (Disabled)
|
|
265
|
+
|
|
266
|
+
> **Note:** This feature is currently disabled due to issues with cross-file parent references (subagent sessions). It is being evaluated for fixing or removal.
|
|
254
267
|
|
|
255
268
|
Claude Code sessions are stored as JSONL files with a tree structure using `uuid` and `parentUuid` fields. When you use rollback or continue from an earlier point, the old branch becomes orphaned but remains in the file.
|
|
256
269
|
|
|
257
|
-
ccs-cloner walks the `parentUuid` chain from the leaf node
|
|
270
|
+
When enabled, ccs-cloner walks the `parentUuid` chain from the leaf node back to the root, keeping only entries in the active conversation path. Orphaned branches would be discarded.
|
|
258
271
|
|
|
259
272
|
### Tool Removal Algorithm
|
|
260
273
|
|
|
@@ -292,7 +305,6 @@ import {
|
|
|
292
305
|
listSessionsInProject,
|
|
293
306
|
findSessionFileById,
|
|
294
307
|
parseSessionFile,
|
|
295
|
-
extractActiveBranchFromSession,
|
|
296
308
|
removeToolCallsFromHistory,
|
|
297
309
|
BUILT_IN_PRESETS,
|
|
298
310
|
resolveToolRemovalOptions,
|
|
@@ -337,13 +349,9 @@ for (const project of projects) {
|
|
|
337
349
|
const sessionPath = await findSessionFileById("abc-123-def");
|
|
338
350
|
const { entries } = await parseSessionFile(sessionPath);
|
|
339
351
|
|
|
340
|
-
// Extract active branch from entries
|
|
341
|
-
const activeBranch = extractActiveBranchFromSession(entries);
|
|
342
|
-
console.log(activeBranch.extractionStatistics.orphanedEntriesDiscarded);
|
|
343
|
-
|
|
344
352
|
// Remove tools from entries directly
|
|
345
353
|
const resolved = resolveToolRemovalOptions({ preset: "default" });
|
|
346
|
-
const removalResult = removeToolCallsFromHistory(
|
|
354
|
+
const removalResult = removeToolCallsFromHistory(entries, resolved);
|
|
347
355
|
console.log(removalResult.statistics.turnsWithToolsRemoved);
|
|
348
356
|
console.log(removalResult.statistics.turnsWithToolsTruncated);
|
|
349
357
|
console.log(removalResult.statistics.turnsWithToolsPreserved);
|
|
@@ -354,7 +362,6 @@ console.log(removalResult.statistics.turnsWithToolsPreserved);
|
|
|
354
362
|
**Core Operations:**
|
|
355
363
|
|
|
356
364
|
- `executeCloneOperation(options)` - Full clone pipeline
|
|
357
|
-
- `extractActiveBranchFromSession(entries, leafUuid?)` - Extract active branch
|
|
358
365
|
- `removeToolCallsFromHistory(entries, options)` - Remove/truncate tools
|
|
359
366
|
- `filterCloneableEntries(entries)` - Filter non-cloneable entry types
|
|
360
367
|
- `repairBrokenParentReferences(entries)` - Fix parent chain after filtering
|
|
@@ -406,10 +413,6 @@ import type {
|
|
|
406
413
|
ToolRemovalPreset,
|
|
407
414
|
ResolvedToolRemovalOptions,
|
|
408
415
|
|
|
409
|
-
// Branch types
|
|
410
|
-
ActiveBranchChain,
|
|
411
|
-
UuidGraph,
|
|
412
|
-
|
|
413
416
|
// Configuration
|
|
414
417
|
UserConfiguration,
|
|
415
418
|
ResolvedConfiguration,
|
|
@@ -453,6 +456,10 @@ src/
|
|
|
453
456
|
errors/ # Custom error classes
|
|
454
457
|
```
|
|
455
458
|
|
|
459
|
+
## Changelog
|
|
460
|
+
|
|
461
|
+
See [CHANGELOG.md](CHANGELOG.md) for version history.
|
|
462
|
+
|
|
456
463
|
## License
|
|
457
464
|
|
|
458
465
|
MIT
|