@enruana/claude-orka 0.4.1 → 0.4.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 CHANGED
@@ -7,13 +7,14 @@
7
7
 
8
8
  ## What is Claude-Orka?
9
9
 
10
- Claude-Orka is a powerful SDK and CLI tool that enables you to:
10
+ Claude-Orka is a powerful SDK, CLI, and UI tool that enables you to:
11
11
 
12
12
  - 🎯 **Orchestrate multiple Claude Code sessions** using tmux
13
- - 🌿 **Create conversation forks** to explore different approaches
13
+ - 🌿 **Create conversation forks** to explore different approaches in parallel
14
14
  - 🔀 **Merge forks back to main** with context preservation
15
- - 💾 **Save and resume sessions** with full context
16
- - 📊 **Manage session state** across your projects
15
+ - 💾 **Save and resume sessions** with full conversation history
16
+ - 📊 **Visualize session hierarchy** in an interactive Electron UI
17
+ - 🔄 **Automatic recovery** from system restarts and crashes
17
18
 
18
19
  Perfect for complex development workflows where you need to explore multiple solutions in parallel!
19
20
 
@@ -25,29 +26,39 @@ npm install -g @enruana/claude-orka
25
26
 
26
27
  ## Prerequisites
27
28
 
28
- - Node.js >= 18.0.0
29
- - [tmux](https://github.com/tmux/tmux) - Terminal multiplexer
30
- - [Claude CLI](https://claude.ai/download) - Claude Code CLI
29
+ - **Node.js** >= 18.0.0
30
+ - **tmux** - Terminal multiplexer
31
+ - **Claude CLI** - Claude Code CLI
31
32
 
32
- **Quick setup (automatic):**
33
+ ### Quick Setup (Automatic)
33
34
 
34
35
  ```bash
35
- # Install dependencies automatically
36
+ # Install all dependencies automatically
36
37
  orka prepare
37
38
 
38
39
  # Verify installation
39
40
  orka doctor
40
41
  ```
41
42
 
42
- **Manual setup:**
43
- - macOS: `brew install tmux`
44
- - Ubuntu: `sudo apt-get install tmux`
45
- - Claude CLI: Download from [claude.ai](https://claude.ai/download)
43
+ ### Manual Setup
44
+
45
+ **macOS:**
46
+ ```bash
47
+ brew install tmux
48
+ ```
49
+
50
+ **Ubuntu/Debian:**
51
+ ```bash
52
+ sudo apt-get install tmux
53
+ ```
54
+
55
+ **Claude CLI:**
56
+ Download from [claude.ai/download](https://claude.ai/download)
46
57
 
47
58
  ## Quick Start
48
59
 
49
60
  ```bash
50
- # 1. Install dependencies (if needed)
61
+ # 1. Install dependencies
51
62
  orka prepare
52
63
 
53
64
  # 2. Initialize in your project
@@ -55,17 +66,33 @@ orka init
55
66
 
56
67
  # 3. Create a new session
57
68
  orka session create "Implement Feature X"
69
+ # → Opens Claude Code in tmux
70
+ # → Opens Electron UI for visual management
58
71
 
59
72
  # 4. Create a fork to explore an alternative
60
73
  orka fork create <session-id> "Try Alternative Approach"
61
74
 
62
- # 5. When done, merge the fork back to main
75
+ # 5. Export and merge the fork back to main
63
76
  orka merge auto <session-id> <fork-id>
64
77
 
65
78
  # 6. Check project status
66
79
  orka status
67
80
  ```
68
81
 
82
+ ---
83
+
84
+ ## Table of Contents
85
+
86
+ - [Features](#features)
87
+ - [CLI Reference](#cli-reference)
88
+ - [SDK API Reference](#sdk-api-reference)
89
+ - [Electron UI Guide](#electron-ui-guide)
90
+ - [Examples](#examples)
91
+ - [Architecture](#architecture)
92
+ - [Troubleshooting](#troubleshooting)
93
+
94
+ ---
95
+
69
96
  ## Features
70
97
 
71
98
  ### 🎯 Session Management
@@ -73,6 +100,7 @@ orka status
73
100
  - Create and manage multiple Claude Code sessions
74
101
  - Save sessions for later (preserves Claude context)
75
102
  - Resume sessions with full conversation history
103
+ - **Automatic recovery** - Resume sessions even after system restarts
76
104
  - List and filter sessions by status
77
105
 
78
106
  ### 🌿 Fork & Merge Workflow
@@ -81,153 +109,1634 @@ orka status
81
109
  - Each fork maintains its own Claude session
82
110
  - Generate summaries of fork explorations
83
111
  - Merge learnings back to main conversation
112
+ - **Validation** - Merge button disabled until fork is exported
113
+ - Track parent-child relationships in fork hierarchy
84
114
 
85
115
  ### 💾 State Persistence
86
116
 
87
117
  - All state stored in `.claude-orka/state.json`
88
118
  - Automatic context preservation via Claude's native sessions
89
119
  - Export summaries for fork integrations
120
+ - **Smart recovery** - Detects missing tmux sessions and recreates them
90
121
 
91
- ### 🎨 Beautiful CLI
122
+ ### 🎨 Beautiful CLI & UI
92
123
 
124
+ - **Electron UI** - Visual session tree with fork hierarchy
93
125
  - Colored output with chalk
94
126
  - Interactive tables with cli-table3
95
127
  - Progress spinners with ora
96
128
  - JSON output for scripting
97
129
 
98
- ## Commands
130
+ ### 🖥️ Electron UI
131
+
132
+ - **Visual session tree** showing fork hierarchy
133
+ - **Interactive nodes** - Click to select, view fork info
134
+ - **Quick actions** - Code, Terminal, Save & Close buttons
135
+ - **Real-time updates** - Automatically refreshes on state changes
136
+ - **Fork management** - Create, export, merge, and close forks visually
137
+ - **Status indicators** - Visual distinction for active, saved, merged, and closed forks
138
+
139
+ ---
140
+
141
+ ## CLI Reference
142
+
143
+ ### Setup Commands
144
+
145
+ #### `orka prepare`
146
+
147
+ Install and configure system dependencies automatically.
148
+
149
+ ```bash
150
+ orka prepare [options]
151
+ ```
152
+
153
+ **Options:**
154
+ - `-y, --yes` - Skip confirmation prompts
155
+
156
+ **What it does:**
157
+ - Detects your operating system
158
+ - Installs tmux via package manager (Homebrew, apt, yum)
159
+ - Checks for Claude CLI installation
160
+ - Provides installation instructions if dependencies are missing
161
+
162
+ **Example:**
163
+ ```bash
164
+ # Interactive installation
165
+ orka prepare
166
+
167
+ # Skip confirmations
168
+ orka prepare --yes
169
+ ```
170
+
171
+ ---
172
+
173
+ #### `orka doctor`
99
174
 
100
- ### Setup
175
+ Check system dependencies and configuration.
101
176
 
102
177
  ```bash
103
- orka prepare # Install system dependencies (tmux, etc.)
104
- orka doctor # Check system dependencies
105
- orka init # Initialize Claude-Orka in current project
178
+ orka doctor
179
+ ```
180
+
181
+ **What it checks:**
182
+ - Node.js version
183
+ - tmux installation and version
184
+ - Claude CLI installation and authentication
185
+ - Project initialization status
186
+
187
+ **Example output:**
188
+ ```
189
+ ✓ Node.js v20.18.0
190
+ ✓ tmux 3.5a
191
+ ✓ Claude CLI installed
192
+ ✓ Project initialized
106
193
  ```
107
194
 
108
- ### Project
195
+ ---
196
+
197
+ #### `orka init`
198
+
199
+ Initialize Claude-Orka in the current project.
109
200
 
110
201
  ```bash
111
- orka status # Show project status
202
+ orka init
112
203
  ```
113
204
 
114
- ### Sessions
205
+ **What it does:**
206
+ - Creates `.claude-orka/` directory
207
+ - Initializes `state.json` with empty state
208
+ - Sets up exports directory structure
209
+
210
+ ---
211
+
212
+ ### Project Commands
213
+
214
+ #### `orka status`
215
+
216
+ Show project status and session summary.
115
217
 
116
218
  ```bash
117
- orka session create [name] # Create new session
118
- orka session list # List all sessions
119
- orka session get <id> # Get session details
120
- orka session resume <id> # Resume saved session
121
- orka session close <id> # Close session (save for later)
122
- orka session delete <id> # Permanently delete session
219
+ orka status [options]
123
220
  ```
124
221
 
125
- ### Forks
222
+ **Options:**
223
+ - `--json` - Output in JSON format
126
224
 
225
+ **Example:**
127
226
  ```bash
128
- orka fork create <session-id> [name] # Create fork
129
- orka fork list <session-id> # List forks
130
- orka fork resume <session-id> <fork-id> # Resume fork
131
- orka fork close <session-id> <fork-id> # Close fork
132
- orka fork delete <session-id> <fork-id> # Delete fork
227
+ orka status
228
+
229
+ # Output:
230
+ # 📊 Project Summary
231
+ # ──────────────────
232
+ # Project Path: /path/to/project
233
+ # Total Sessions: 3
234
+ # Active: 1
235
+ # Saved: 2
236
+ # Last Updated: 11/20/2025, 6:48:46 AM
237
+ #
238
+ # 📝 Sessions:
239
+ # ✓ Feature Implementation
240
+ # ID: abc123...
241
+ # Status: active
242
+ # Total Forks: 2
133
243
  ```
134
244
 
135
- ### Merge
245
+ ---
246
+
247
+ ### Session Commands
248
+
249
+ #### `orka session create`
250
+
251
+ Create a new Claude Code session.
136
252
 
137
253
  ```bash
138
- orka merge export <session-id> <fork-id> # Generate export
139
- orka merge do <session-id> <fork-id> # Merge to main
140
- orka merge auto <session-id> <fork-id> # Export + merge (recommended)
254
+ orka session create [name] [options]
141
255
  ```
142
256
 
143
- ## Example Workflow
257
+ **Arguments:**
258
+ - `name` - Optional session name (default: "Session-{timestamp}")
259
+
260
+ **Options:**
261
+ - `--no-terminal` - Don't open terminal window
262
+ - `--no-ui` - Don't launch Electron UI
144
263
 
264
+ **What it does:**
265
+ 1. Creates new tmux session
266
+ 2. Launches Claude Code in the tmux session
267
+ 3. Opens terminal window
268
+ 4. Launches Electron UI for visual management
269
+ 5. Saves session state
270
+
271
+ **Example:**
145
272
  ```bash
146
- # 1. Start a new session for your feature
273
+ # Create with custom name
147
274
  orka session create "OAuth Implementation"
148
- # → Session ID: abc123...
149
275
 
150
- # 2. Work on the main approach...
151
- # (Claude Code opens in tmux)
276
+ # Create without opening terminal
277
+ orka session create --no-terminal
278
+
279
+ # Create without UI
280
+ orka session create --no-ui
281
+ ```
282
+
283
+ ---
284
+
285
+ #### `orka session list`
286
+
287
+ List all sessions in the project.
288
+
289
+ ```bash
290
+ orka session list [options]
291
+ ```
292
+
293
+ **Options:**
294
+ - `--status <status>` - Filter by status (active, saved)
295
+ - `--json` - Output in JSON format
296
+
297
+ **Example:**
298
+ ```bash
299
+ # List all sessions
300
+ orka session list
301
+
302
+ # List only active sessions
303
+ orka session list --status active
304
+
305
+ # Get JSON output
306
+ orka session list --json
307
+ ```
308
+
309
+ ---
310
+
311
+ #### `orka session get`
312
+
313
+ Get detailed information about a session.
314
+
315
+ ```bash
316
+ orka session get <session-id> [options]
317
+ ```
318
+
319
+ **Arguments:**
320
+ - `session-id` - Session ID to retrieve
321
+
322
+ **Options:**
323
+ - `--json` - Output in JSON format
324
+
325
+ **Example:**
326
+ ```bash
327
+ orka session get abc123
328
+ ```
329
+
330
+ ---
331
+
332
+ #### `orka session resume`
333
+
334
+ Resume a saved or detached session.
335
+
336
+ ```bash
337
+ orka session resume <session-id> [options]
338
+ ```
339
+
340
+ **Arguments:**
341
+ - `session-id` - Session ID to resume
342
+
343
+ **Options:**
344
+ - `--no-terminal` - Don't open terminal window
345
+ - `--no-ui` - Don't launch Electron UI
346
+
347
+ **What it does:**
348
+ 1. **If tmux session exists**: Reconnects to existing session
349
+ 2. **If tmux session missing**: Creates new tmux session and resumes Claude session
350
+ 3. Opens terminal window and launches UI
351
+ 4. Resumes all forks that weren't merged
352
+
353
+ **Recovery mechanism:**
354
+ - Detects if tmux session was lost (system restart, crash)
355
+ - Automatically creates new tmux session
356
+ - Resumes Claude session with full context
357
+ - Restores all fork panes
358
+
359
+ **Example:**
360
+ ```bash
361
+ orka session resume abc123
362
+ ```
363
+
364
+ ---
365
+
366
+ #### `orka session close`
367
+
368
+ Close and save a session for later.
369
+
370
+ ```bash
371
+ orka session close <session-id>
372
+ ```
373
+
374
+ **Arguments:**
375
+ - `session-id` - Session ID to close
376
+
377
+ **What it does:**
378
+ - Detaches from tmux session (session stays alive)
379
+ - Updates status to 'saved'
380
+ - Session can be resumed later with full context
381
+
382
+ **Example:**
383
+ ```bash
384
+ orka session close abc123
385
+ ```
386
+
387
+ ---
388
+
389
+ #### `orka session delete`
390
+
391
+ Permanently delete a session.
392
+
393
+ ```bash
394
+ orka session delete <session-id>
395
+ ```
396
+
397
+ **Arguments:**
398
+ - `session-id` - Session ID to delete
399
+
400
+ **What it does:**
401
+ - Kills tmux session
402
+ - Removes session from state
403
+ - **Warning**: This action cannot be undone
404
+
405
+ **Example:**
406
+ ```bash
407
+ orka session delete abc123
408
+ ```
409
+
410
+ ---
411
+
412
+ ### Fork Commands
413
+
414
+ #### `orka fork create`
415
+
416
+ Create a fork (conversation branch) from main or another fork.
417
+
418
+ ```bash
419
+ orka fork create <session-id> [name] [options]
420
+ ```
421
+
422
+ **Arguments:**
423
+ - `session-id` - Parent session ID
424
+ - `name` - Optional fork name (default: "Fork-{timestamp}")
425
+
426
+ **Options:**
427
+ - `--parent <parent-id>` - Parent fork ID (default: "main")
428
+ - `--vertical` - Split pane vertically instead of horizontally
429
+
430
+ **What it does:**
431
+ 1. Creates split pane in tmux
432
+ 2. Launches new Claude session in the fork
433
+ 3. Tracks parent-child relationship
434
+ 4. Updates session state
435
+
436
+ **Limitation:**
437
+ - Only one active fork allowed per parent branch
438
+ - Must merge or close existing fork before creating new one
439
+
440
+ **Example:**
441
+ ```bash
442
+ # Create fork from main
443
+ orka fork create abc123 "Try JWT Implementation"
444
+
445
+ # Create fork from another fork
446
+ orka fork create abc123 "Nested Approach" --parent def456
447
+
448
+ # Create with vertical split
449
+ orka fork create abc123 --vertical
450
+ ```
451
+
452
+ ---
453
+
454
+ #### `orka fork list`
455
+
456
+ List all forks in a session.
457
+
458
+ ```bash
459
+ orka fork list <session-id> [options]
460
+ ```
461
+
462
+ **Arguments:**
463
+ - `session-id` - Session ID
464
+
465
+ **Options:**
466
+ - `--json` - Output in JSON format
467
+
468
+ **Example:**
469
+ ```bash
470
+ orka fork list abc123
471
+ ```
472
+
473
+ ---
474
+
475
+ #### `orka fork resume`
476
+
477
+ Resume a saved fork.
478
+
479
+ ```bash
480
+ orka fork resume <session-id> <fork-id>
481
+ ```
482
+
483
+ **Arguments:**
484
+ - `session-id` - Session ID
485
+ - `fork-id` - Fork ID to resume
486
+
487
+ **What it does:**
488
+ - Creates new split pane in tmux
489
+ - Resumes Claude session for the fork
490
+ - Restores fork context
491
+
492
+ **Example:**
493
+ ```bash
494
+ orka fork resume abc123 def456
495
+ ```
496
+
497
+ ---
498
+
499
+ #### `orka fork close`
500
+
501
+ Close a fork without merging (abandon experiment).
502
+
503
+ ```bash
504
+ orka fork close <session-id> <fork-id>
505
+ ```
506
+
507
+ **Arguments:**
508
+ - `session-id` - Session ID
509
+ - `fork-id` - Fork ID to close
510
+
511
+ **What it does:**
512
+ - Kills fork's tmux pane
513
+ - Sets fork status to 'closed'
514
+ - Fork can be viewed in UI but not resumed
515
+ - No export or merge required
516
+
517
+ **Use case:**
518
+ - Experiment didn't work out
519
+ - Want to abandon this approach
520
+ - Don't need to merge learnings back
521
+
522
+ **Example:**
523
+ ```bash
524
+ orka fork close abc123 def456
525
+ ```
526
+
527
+ ---
528
+
529
+ #### `orka fork delete`
530
+
531
+ Permanently delete a fork.
532
+
533
+ ```bash
534
+ orka fork delete <session-id> <fork-id>
535
+ ```
536
+
537
+ **Arguments:**
538
+ - `session-id` - Session ID
539
+ - `fork-id` - Fork ID to delete
540
+
541
+ **What it does:**
542
+ - Removes fork from session state
543
+ - **Warning**: Cannot be undone
544
+
545
+ **Example:**
546
+ ```bash
547
+ orka fork delete abc123 def456
548
+ ```
549
+
550
+ ---
551
+
552
+ ### Merge Commands
553
+
554
+ #### `orka merge export`
555
+
556
+ Generate export summary for a fork.
557
+
558
+ ```bash
559
+ orka merge export <session-id> <fork-id>
560
+ ```
561
+
562
+ **Arguments:**
563
+ - `session-id` - Session ID
564
+ - `fork-id` - Fork ID to export
565
+
566
+ **What it does:**
567
+ 1. Sends prompt to Claude to generate summary
568
+ 2. Claude creates executive summary of fork exploration
569
+ 3. Claude exports to `.claude-orka/exports/fork-{id}.md`
570
+ 4. **Note**: Async operation - Claude does the work in background
571
+
572
+ **Example:**
573
+ ```bash
574
+ orka merge export abc123 def456
575
+ # Wait for Claude to complete (usually 10-15 seconds)
576
+ ```
577
+
578
+ ---
579
+
580
+ #### `orka merge do`
581
+
582
+ Merge a fork back to its parent.
583
+
584
+ ```bash
585
+ orka merge do <session-id> <fork-id>
586
+ ```
587
+
588
+ **Arguments:**
589
+ - `session-id` - Session ID
590
+ - `fork-id` - Fork ID to merge
591
+
592
+ **Prerequisites:**
593
+ - Fork must have been exported first
594
+ - Export file must exist
152
595
 
153
- # 3. Create a fork to try JWT tokens
154
- orka fork create abc123 "Try JWT Tokens"
155
- # Fork ID: def456...
596
+ **What it does:**
597
+ 1. Sends merge prompt to parent conversation
598
+ 2. Includes fork export summary
599
+ 3. Sets fork status to 'merged'
600
+ 4. Closes fork pane
156
601
 
157
- # 4. Work on the fork...
158
- # (Fork opens in new tmux pane)
602
+ **Example:**
603
+ ```bash
604
+ orka merge do abc123 def456
605
+ ```
606
+
607
+ ---
608
+
609
+ #### `orka merge auto`
610
+
611
+ Export and merge a fork (recommended).
612
+
613
+ ```bash
614
+ orka merge auto <session-id> <fork-id> [options]
615
+ ```
616
+
617
+ **Arguments:**
618
+ - `session-id` - Session ID
619
+ - `fork-id` - Fork ID to export and merge
620
+
621
+ **Options:**
622
+ - `--wait <ms>` - Wait time for export (default: 15000ms)
623
+
624
+ **What it does:**
625
+ 1. Generates export (Claude does this)
626
+ 2. Waits for export to complete
627
+ 3. Merges fork to parent
628
+ 4. Complete workflow in one command
159
629
 
160
- # 5. Merge the successful approach back
630
+ **Example:**
631
+ ```bash
632
+ # Use default wait time (15 seconds)
161
633
  orka merge auto abc123 def456
162
634
 
163
- # 6. Check final state
164
- orka status
635
+ # Custom wait time (20 seconds)
636
+ orka merge auto abc123 def456 --wait 20000
165
637
  ```
166
638
 
167
- ## SDK Usage
639
+ ---
640
+
641
+ ## SDK API Reference
168
642
 
169
- You can also use Claude-Orka programmatically:
643
+ ### Installation
170
644
 
171
645
  ```typescript
172
646
  import { ClaudeOrka } from '@enruana/claude-orka'
647
+ ```
173
648
 
174
- const orka = new ClaudeOrka('/path/to/project')
175
- await orka.initialize()
649
+ ### ClaudeOrka Class
176
650
 
177
- // Create session
178
- const session = await orka.createSession('My Feature')
651
+ Main SDK class for orchestrating Claude Code sessions.
179
652
 
180
- // Create fork
181
- const fork = await orka.createFork(session.id, 'Alternative')
653
+ #### Constructor
182
654
 
183
- // Generate export and merge
184
- await orka.generateExportAndMerge(session.id, fork.id)
655
+ ```typescript
656
+ new ClaudeOrka(projectPath: string)
657
+ ```
185
658
 
186
- // Get project summary
187
- const summary = await orka.getProjectSummary()
659
+ **Parameters:**
660
+ - `projectPath` - Absolute path to your project directory
661
+
662
+ **Example:**
663
+ ```typescript
664
+ const orka = new ClaudeOrka('/Users/username/my-project')
665
+ await orka.initialize()
188
666
  ```
189
667
 
190
- ## Architecture
668
+ ---
669
+
670
+ ### Initialization
671
+
672
+ #### `initialize()`
673
+
674
+ Initialize ClaudeOrka and create state directory.
191
675
 
676
+ ```typescript
677
+ async initialize(): Promise<void>
192
678
  ```
193
- .claude-orka/
194
- ├── state.json # Project state
195
- └── exports/ # Fork summaries (created on-demand)
196
- └── fork-*.md # Generated summaries
679
+
680
+ **Example:**
681
+ ```typescript
682
+ await orka.initialize()
197
683
  ```
198
684
 
199
- **Key Concepts:**
685
+ ---
200
686
 
201
- - **Session**: A Claude Code conversation with main + forks
202
- - **Main**: The primary conversation branch
203
- - **Fork**: A branched conversation to explore alternatives
204
- - **Export**: A summary of a fork's exploration
205
- - **Merge**: Integrate fork learnings into main
687
+ ### Session Methods
206
688
 
207
- ## Configuration
689
+ #### `createSession()`
208
690
 
209
- Claude-Orka uses native Claude CLI sessions, so no additional configuration is needed. Session IDs are automatically detected from `~/.claude/history.jsonl`.
691
+ Create a new Claude Code session.
210
692
 
211
- ## Troubleshooting
693
+ ```typescript
694
+ async createSession(
695
+ name?: string,
696
+ openTerminal?: boolean
697
+ ): Promise<Session>
698
+ ```
212
699
 
213
- ```bash
214
- # Check if everything is set up correctly
215
- orka doctor
700
+ **Parameters:**
701
+ - `name` - Optional session name (default: "Session-{timestamp}")
702
+ - `openTerminal` - Open terminal window (default: true)
703
+
704
+ **Returns:** `Session` object
216
705
 
217
- # Common issues:
218
- # - tmux not installed → brew install tmux
219
- # - Claude CLI not found → Install from claude.ai
220
- # - Project not initialized → orka init
706
+ **Example:**
707
+ ```typescript
708
+ const session = await orka.createSession('OAuth Implementation')
709
+ console.log(session.id) // abc123...
221
710
  ```
222
711
 
223
- ## Contributing
712
+ ---
224
713
 
225
- Contributions are welcome! Please feel free to submit a Pull Request.
714
+ #### `resumeSession()`
715
+
716
+ Resume a saved session.
717
+
718
+ ```typescript
719
+ async resumeSession(
720
+ sessionId: string,
721
+ openTerminal?: boolean
722
+ ): Promise<Session>
723
+ ```
724
+
725
+ **Parameters:**
726
+ - `sessionId` - Session ID to resume
727
+ - `openTerminal` - Open terminal window (default: true)
728
+
729
+ **Returns:** `Session` object
730
+
731
+ **Recovery behavior:**
732
+ - Checks if tmux session exists
733
+ - If yes: Reconnects to existing session
734
+ - If no: Creates new tmux session and resumes Claude session
735
+
736
+ **Example:**
737
+ ```typescript
738
+ const session = await orka.resumeSession('abc123')
739
+ ```
740
+
741
+ ---
742
+
743
+ #### `closeSession()`
744
+
745
+ Close a session.
746
+
747
+ ```typescript
748
+ async closeSession(sessionId: string): Promise<void>
749
+ ```
750
+
751
+ **Parameters:**
752
+ - `sessionId` - Session ID to close
753
+
754
+ **Example:**
755
+ ```typescript
756
+ await orka.closeSession('abc123')
757
+ ```
758
+
759
+ ---
760
+
761
+ #### `deleteSession()`
762
+
763
+ Permanently delete a session.
764
+
765
+ ```typescript
766
+ async deleteSession(sessionId: string): Promise<void>
767
+ ```
768
+
769
+ **Parameters:**
770
+ - `sessionId` - Session ID to delete
771
+
772
+ **Example:**
773
+ ```typescript
774
+ await orka.deleteSession('abc123')
775
+ ```
776
+
777
+ ---
778
+
779
+ #### `listSessions()`
780
+
781
+ List sessions with optional filters.
782
+
783
+ ```typescript
784
+ async listSessions(filters?: SessionFilters): Promise<Session[]>
785
+ ```
786
+
787
+ **Parameters:**
788
+ - `filters` - Optional filters (status, name)
789
+
790
+ **Returns:** Array of `Session` objects
791
+
792
+ **Example:**
793
+ ```typescript
794
+ // List all sessions
795
+ const sessions = await orka.listSessions()
796
+
797
+ // List only active sessions
798
+ const activeSessions = await orka.listSessions({ status: 'active' })
799
+ ```
800
+
801
+ ---
802
+
803
+ #### `getSession()`
804
+
805
+ Get a session by ID.
806
+
807
+ ```typescript
808
+ async getSession(sessionId: string): Promise<Session | null>
809
+ ```
810
+
811
+ **Parameters:**
812
+ - `sessionId` - Session ID
813
+
814
+ **Returns:** `Session` object or `null`
815
+
816
+ **Example:**
817
+ ```typescript
818
+ const session = await orka.getSession('abc123')
819
+ if (session) {
820
+ console.log(session.name)
821
+ }
822
+ ```
823
+
824
+ ---
825
+
826
+ #### `getProjectSummary()`
827
+
828
+ Get complete project summary with statistics.
829
+
830
+ ```typescript
831
+ async getProjectSummary(): Promise<ProjectSummary>
832
+ ```
833
+
834
+ **Returns:** `ProjectSummary` object
835
+
836
+ **Example:**
837
+ ```typescript
838
+ const summary = await orka.getProjectSummary()
839
+ console.log(`Total sessions: ${summary.totalSessions}`)
840
+ console.log(`Active: ${summary.activeSessions}`)
841
+ ```
842
+
843
+ ---
844
+
845
+ ### Fork Methods
846
+
847
+ #### `createFork()`
848
+
849
+ Create a fork (conversation branch).
850
+
851
+ ```typescript
852
+ async createFork(
853
+ sessionId: string,
854
+ name?: string,
855
+ parentId?: string,
856
+ vertical?: boolean
857
+ ): Promise<Fork>
858
+ ```
859
+
860
+ **Parameters:**
861
+ - `sessionId` - Session ID
862
+ - `name` - Optional fork name (default: "Fork-{timestamp}")
863
+ - `parentId` - Parent fork ID (default: "main")
864
+ - `vertical` - Split vertically (default: false)
865
+
866
+ **Returns:** `Fork` object
867
+
868
+ **Example:**
869
+ ```typescript
870
+ // Create fork from main
871
+ const fork = await orka.createFork('abc123', 'JWT Implementation')
872
+
873
+ // Create fork from another fork
874
+ const nestedFork = await orka.createFork(
875
+ 'abc123',
876
+ 'Nested Approach',
877
+ 'def456'
878
+ )
879
+
880
+ // Create with vertical split
881
+ const vFork = await orka.createFork('abc123', undefined, 'main', true)
882
+ ```
883
+
884
+ ---
885
+
886
+ #### `resumeFork()`
887
+
888
+ Resume a saved fork.
889
+
890
+ ```typescript
891
+ async resumeFork(sessionId: string, forkId: string): Promise<Fork>
892
+ ```
893
+
894
+ **Parameters:**
895
+ - `sessionId` - Session ID
896
+ - `forkId` - Fork ID
897
+
898
+ **Returns:** `Fork` object
899
+
900
+ **Example:**
901
+ ```typescript
902
+ const fork = await orka.resumeFork('abc123', 'def456')
903
+ ```
904
+
905
+ ---
906
+
907
+ #### `closeFork()`
908
+
909
+ Close a fork without merging.
910
+
911
+ ```typescript
912
+ async closeFork(sessionId: string, forkId: string): Promise<void>
913
+ ```
914
+
915
+ **Parameters:**
916
+ - `sessionId` - Session ID
917
+ - `forkId` - Fork ID
918
+
919
+ **Example:**
920
+ ```typescript
921
+ await orka.closeFork('abc123', 'def456')
922
+ ```
923
+
924
+ ---
925
+
926
+ #### `deleteFork()`
927
+
928
+ Permanently delete a fork.
929
+
930
+ ```typescript
931
+ async deleteFork(sessionId: string, forkId: string): Promise<void>
932
+ ```
933
+
934
+ **Parameters:**
935
+ - `sessionId` - Session ID
936
+ - `forkId` - Fork ID
937
+
938
+ **Example:**
939
+ ```typescript
940
+ await orka.deleteFork('abc123', 'def456')
941
+ ```
942
+
943
+ ---
944
+
945
+ ### Export & Merge Methods
946
+
947
+ #### `generateForkExport()`
948
+
949
+ Generate export summary for a fork.
950
+
951
+ ```typescript
952
+ async generateForkExport(
953
+ sessionId: string,
954
+ forkId: string
955
+ ): Promise<string>
956
+ ```
957
+
958
+ **Parameters:**
959
+ - `sessionId` - Session ID
960
+ - `forkId` - Fork ID
961
+
962
+ **Returns:** Path to export file (relative to project)
963
+
964
+ **Note:** Async - Claude generates the export in background
965
+
966
+ **Example:**
967
+ ```typescript
968
+ const exportPath = await orka.generateForkExport('abc123', 'def456')
969
+ console.log(`Export will be saved to: ${exportPath}`)
970
+ // Wait 10-15 seconds for Claude to complete
971
+ ```
972
+
973
+ ---
974
+
975
+ #### `merge()`
976
+
977
+ Merge a fork to its parent.
978
+
979
+ ```typescript
980
+ async merge(sessionId: string, forkId: string): Promise<void>
981
+ ```
982
+
983
+ **Parameters:**
984
+ - `sessionId` - Session ID
985
+ - `forkId` - Fork ID
986
+
987
+ **Prerequisites:**
988
+ - Fork must be exported first
989
+
990
+ **Example:**
991
+ ```typescript
992
+ await orka.merge('abc123', 'def456')
993
+ ```
994
+
995
+ ---
996
+
997
+ #### `generateExportAndMerge()`
998
+
999
+ Generate export and merge (recommended).
1000
+
1001
+ ```typescript
1002
+ async generateExportAndMerge(
1003
+ sessionId: string,
1004
+ forkId: string,
1005
+ waitTime?: number
1006
+ ): Promise<void>
1007
+ ```
1008
+
1009
+ **Parameters:**
1010
+ - `sessionId` - Session ID
1011
+ - `forkId` - Fork ID
1012
+ - `waitTime` - Wait time in ms (default: 15000)
1013
+
1014
+ **Example:**
1015
+ ```typescript
1016
+ // Use default wait time
1017
+ await orka.generateExportAndMerge('abc123', 'def456')
1018
+
1019
+ // Custom wait time
1020
+ await orka.generateExportAndMerge('abc123', 'def456', 20000)
1021
+ ```
1022
+
1023
+ ---
1024
+
1025
+ #### `generateExportMergeAndClose()`
1026
+
1027
+ Complete workflow: export, merge, and close.
1028
+
1029
+ ```typescript
1030
+ async generateExportMergeAndClose(
1031
+ sessionId: string,
1032
+ forkId: string,
1033
+ waitTime?: number
1034
+ ): Promise<void>
1035
+ ```
1036
+
1037
+ **Parameters:**
1038
+ - `sessionId` - Session ID
1039
+ - `forkId` - Fork ID
1040
+ - `waitTime` - Wait time in ms (default: 15000)
1041
+
1042
+ **Example:**
1043
+ ```typescript
1044
+ await orka.generateExportMergeAndClose('abc123', 'def456')
1045
+ ```
1046
+
1047
+ ---
1048
+
1049
+ ### Command Sending
1050
+
1051
+ #### `send()`
1052
+
1053
+ Send command to session or fork.
1054
+
1055
+ ```typescript
1056
+ async send(
1057
+ sessionId: string,
1058
+ command: string,
1059
+ target?: string
1060
+ ): Promise<void>
1061
+ ```
1062
+
1063
+ **Parameters:**
1064
+ - `sessionId` - Session ID
1065
+ - `command` - Command to send
1066
+ - `target` - Optional fork ID (default: main)
1067
+
1068
+ **Example:**
1069
+ ```typescript
1070
+ // Send to main
1071
+ await orka.send('abc123', 'ls -la')
1072
+
1073
+ // Send to fork
1074
+ await orka.send('abc123', 'npm test', 'def456')
1075
+ ```
1076
+
1077
+ ---
1078
+
1079
+ ### Type Definitions
1080
+
1081
+ #### Session
1082
+
1083
+ ```typescript
1084
+ interface Session {
1085
+ id: string // Unique session ID
1086
+ name: string // Session name
1087
+ tmuxSessionId: string // tmux session ID
1088
+ status: 'active' | 'saved' // Session status
1089
+ createdAt: string // ISO timestamp
1090
+ lastActivity: string // ISO timestamp
1091
+ main: MainBranch // Main conversation
1092
+ forks: Fork[] // Array of forks
1093
+ projectPath?: string // Project path
1094
+ }
1095
+ ```
1096
+
1097
+ #### MainBranch
1098
+
1099
+ ```typescript
1100
+ interface MainBranch {
1101
+ claudeSessionId: string // Claude session UUID
1102
+ tmuxPaneId?: string // tmux pane ID (if active)
1103
+ status: 'active' | 'saved' // Branch status
1104
+ contextPath?: string // Path to context export
1105
+ }
1106
+ ```
1107
+
1108
+ #### Fork
1109
+
1110
+ ```typescript
1111
+ interface Fork {
1112
+ id: string // Fork ID
1113
+ name: string // Fork name
1114
+ parentId: string // Parent ID ('main' or fork ID)
1115
+ claudeSessionId: string // Claude session UUID
1116
+ tmuxPaneId?: string // tmux pane ID (if active)
1117
+ createdAt: string // ISO timestamp
1118
+ status: 'active' | 'saved' | 'closed' | 'merged' // Fork status
1119
+ contextPath?: string // Path to export
1120
+ mergedToMain?: boolean // Merge status
1121
+ mergedAt?: string // Merge timestamp
1122
+ }
1123
+ ```
1124
+
1125
+ #### SessionFilters
1126
+
1127
+ ```typescript
1128
+ interface SessionFilters {
1129
+ status?: 'active' | 'saved' // Filter by status
1130
+ name?: string // Filter by name (partial match)
1131
+ }
1132
+ ```
1133
+
1134
+ #### ProjectSummary
1135
+
1136
+ ```typescript
1137
+ interface ProjectSummary {
1138
+ projectPath: string // Project path
1139
+ totalSessions: number // Total sessions
1140
+ activeSessions: number // Active sessions count
1141
+ savedSessions: number // Saved sessions count
1142
+ sessions: SessionSummary[] // Array of session summaries
1143
+ lastUpdated: string // ISO timestamp
1144
+ }
1145
+ ```
1146
+
1147
+ #### SessionSummary
1148
+
1149
+ ```typescript
1150
+ interface SessionSummary {
1151
+ id: string // Session ID
1152
+ name: string // Session name
1153
+ claudeSessionId: string // Claude session UUID
1154
+ status: 'active' | 'saved' // Status
1155
+ createdAt: string // ISO timestamp
1156
+ lastActivity: string // ISO timestamp
1157
+ totalForks: number // Total forks
1158
+ activeForks: number // Active forks count
1159
+ savedForks: number // Saved forks count
1160
+ mergedForks: number // Merged forks count
1161
+ forks: ForkSummary[] // Array of fork summaries
1162
+ }
1163
+ ```
1164
+
1165
+ #### ForkSummary
1166
+
1167
+ ```typescript
1168
+ interface ForkSummary {
1169
+ id: string // Fork ID
1170
+ name: string // Fork name
1171
+ claudeSessionId: string // Claude session UUID
1172
+ status: 'active' | 'saved' | 'closed' | 'merged' // Status
1173
+ createdAt: string // ISO timestamp
1174
+ hasContext: boolean // Has export
1175
+ contextPath?: string // Path to export
1176
+ mergedToMain: boolean // Merge status
1177
+ mergedAt?: string // Merge timestamp
1178
+ }
1179
+ ```
1180
+
1181
+ ---
1182
+
1183
+ ## Electron UI Guide
1184
+
1185
+ ### Overview
1186
+
1187
+ The Electron UI provides a visual interface for managing Claude Code sessions and forks. It automatically launches when you create or resume a session.
1188
+
1189
+ ### Features
1190
+
1191
+ #### Visual Session Tree
1192
+
1193
+ - **Hierarchical view** of main conversation and all forks
1194
+ - **Parent-child relationships** shown with connecting edges
1195
+ - **Color-coded status indicators**:
1196
+ - 🟢 Green: Active
1197
+ - 🟡 Yellow: Saved
1198
+ - 🔴 Red: Closed
1199
+ - 🔵 Green circle: Merged
1200
+
1201
+ #### Interactive Nodes
1202
+
1203
+ **Main Node:**
1204
+ - Large card showing "MAIN" branch
1205
+ - Click to select and view in action panel
1206
+
1207
+ **Fork Nodes (Active/Saved):**
1208
+ - Full cards with fork name and ID
1209
+ - Click to select
1210
+ - Shows fork status badge
1211
+
1212
+ **Fork Nodes (Closed/Merged):**
1213
+ - Compact circles (48px)
1214
+ - "C" for Closed (red border)
1215
+ - "M" for Merged (green border)
1216
+ - Click to open info modal with details
1217
+
1218
+ #### Header Actions
1219
+
1220
+ **Project Name:**
1221
+ - Shows current project name in window title
1222
+
1223
+ **Code Button:**
1224
+ - Opens project folder in Cursor (preferred)
1225
+ - Falls back to VSCode
1226
+ - Falls back to Finder
1227
+
1228
+ **Terminal Button:**
1229
+ - Focuses the terminal window
1230
+ - Brings tmux session to front
1231
+
1232
+ **Save & Close Button:**
1233
+ - Detaches from tmux (session stays alive)
1234
+ - Closes terminal window
1235
+ - Closes Electron app
1236
+ - Session can be resumed later
1237
+
1238
+ #### Action Panel
1239
+
1240
+ Located at the bottom, shows actions for selected node:
1241
+
1242
+ **New Fork:**
1243
+ - Creates fork from selected node
1244
+ - Opens dialog to enter fork name
1245
+ - Disabled if active fork already exists from this node
1246
+ - Tooltip explains Claude Code limitation
1247
+
1248
+ **Export:**
1249
+ - Generates export summary for selected fork
1250
+ - Sends prompt to Claude to create summary
1251
+ - Disabled for main branch
1252
+ - Shows progress "Exporting..."
1253
+
1254
+ **Merge:**
1255
+ - Merges selected fork to its parent
1256
+ - **Disabled until fork is exported**
1257
+ - Tooltip: "Export the fork first before merging"
1258
+ - Shows progress "Merging..."
1259
+
1260
+ **Close:**
1261
+ - Closes selected fork (abandon experiment)
1262
+ - No export or merge required
1263
+ - Fork marked as 'closed' (red circle in tree)
1264
+ - Can view info later but cannot resume
1265
+
1266
+ #### Fork Info Modal
1267
+
1268
+ For closed/merged forks, clicking shows modal with:
1269
+
1270
+ **Information displayed:**
1271
+ - Fork name
1272
+ - Fork ID
1273
+ - Claude Session ID
1274
+ - Status badge (color-coded)
1275
+ - Created date
1276
+ - Context path (if exported)
1277
+ - Merged date (if merged)
1278
+
1279
+ **Actions:**
1280
+ - **Open Export File** (merged forks only)
1281
+ - Opens export markdown in default app
1282
+ - Only shown if fork was merged and has export
1283
+
1284
+ ### Real-Time Updates
1285
+
1286
+ The UI automatically updates when:
1287
+ - State file changes (`.claude-orka/state.json`)
1288
+ - New forks are created
1289
+ - Forks are merged or closed
1290
+ - Session status changes
1291
+
1292
+ ### Window Controls
1293
+
1294
+ **Frameless design:**
1295
+ - Custom title bar with project name
1296
+ - Transparent background
1297
+ - Always on top (configurable)
1298
+ - Resizable (min 500x600, default 600x800)
1299
+
1300
+ ### Keyboard Shortcuts
1301
+
1302
+ - **Cmd/Ctrl + R**: Refresh (reload)
1303
+ - **Cmd/Ctrl + Q**: Quit application
1304
+ - **Cmd/Ctrl + W**: Close window (same as Save & Close)
1305
+
1306
+ ### Launch Options
1307
+
1308
+ **Automatic (default):**
1309
+ ```bash
1310
+ orka session create
1311
+ # UI launches automatically
1312
+ ```
1313
+
1314
+ **Manual control:**
1315
+ ```bash
1316
+ # Skip UI launch
1317
+ orka session create --no-ui
1318
+
1319
+ # Launch UI programmatically
1320
+ const orka = new ClaudeOrka('/path/to/project')
1321
+ await orka.createSession('Feature', true) // true = open terminal + UI
1322
+ ```
1323
+
1324
+ ---
1325
+
1326
+ ## Examples
1327
+
1328
+ ### Example 1: Basic Workflow
1329
+
1330
+ ```typescript
1331
+ import { ClaudeOrka } from '@enruana/claude-orka'
1332
+
1333
+ const orka = new ClaudeOrka('/Users/me/my-project')
1334
+ await orka.initialize()
1335
+
1336
+ // Create session
1337
+ const session = await orka.createSession('OAuth Implementation')
1338
+ console.log(`Session created: ${session.id}`)
1339
+
1340
+ // Work on main... then create fork
1341
+ const fork = await orka.createFork(session.id, 'Try JWT Tokens')
1342
+ console.log(`Fork created: ${fork.id}`)
1343
+
1344
+ // Work on fork... then merge back
1345
+ await orka.generateExportAndMerge(session.id, fork.id)
1346
+ console.log('Fork merged!')
1347
+
1348
+ // Check final state
1349
+ const summary = await orka.getProjectSummary()
1350
+ console.log(`Total sessions: ${summary.totalSessions}`)
1351
+ ```
1352
+
1353
+ ### Example 2: Multiple Forks
1354
+
1355
+ ```typescript
1356
+ const orka = new ClaudeOrka(process.cwd())
1357
+ await orka.initialize()
1358
+
1359
+ const session = await orka.createSession('Database Design')
1360
+
1361
+ // Create multiple forks to explore options
1362
+ const fork1 = await orka.createFork(session.id, 'PostgreSQL Approach')
1363
+ const fork2 = await orka.createFork(session.id, 'MongoDB Approach')
1364
+ const fork3 = await orka.createFork(session.id, 'Hybrid Approach')
1365
+
1366
+ // Work on each... then merge the winner
1367
+ await orka.generateExportAndMerge(session.id, fork1.id)
1368
+
1369
+ // Close the others
1370
+ await orka.closeFork(session.id, fork2.id)
1371
+ await orka.closeFork(session.id, fork3.id)
1372
+ ```
1373
+
1374
+ ### Example 3: Nested Forks
1375
+
1376
+ ```typescript
1377
+ const session = await orka.createSession('API Design')
1378
+
1379
+ // Main approach
1380
+ const restFork = await orka.createFork(session.id, 'REST API')
1381
+
1382
+ // Try variations of REST
1383
+ const restV1 = await orka.createFork(
1384
+ session.id,
1385
+ 'REST with Versioning',
1386
+ restFork.id // parent is the REST fork
1387
+ )
1388
+
1389
+ const restGraphQL = await orka.createFork(
1390
+ session.id,
1391
+ 'REST + GraphQL Hybrid',
1392
+ restFork.id
1393
+ )
1394
+
1395
+ // Merge best variation back to REST fork
1396
+ await orka.generateExportAndMerge(session.id, restV1.id)
1397
+
1398
+ // Then merge REST fork to main
1399
+ await orka.generateExportAndMerge(session.id, restFork.id)
1400
+ ```
1401
+
1402
+ ### Example 4: Session Recovery
1403
+
1404
+ ```typescript
1405
+ // Create session
1406
+ const session = await orka.createSession('Long Running Task')
1407
+
1408
+ // ... work on it ...
1409
+
1410
+ // Close session (detach from tmux)
1411
+ await orka.closeSession(session.id)
1412
+
1413
+ // Later... even after system restart
1414
+ const resumed = await orka.resumeSession(session.id)
1415
+ console.log('Session resumed with full context!')
1416
+
1417
+ // If tmux was lost (restart), ClaudeOrka:
1418
+ // 1. Detects missing tmux session
1419
+ // 2. Creates new tmux session
1420
+ // 3. Resumes Claude session with full history
1421
+ // 4. Restores all forks
1422
+ ```
1423
+
1424
+ ### Example 5: CLI Script
1425
+
1426
+ ```bash
1427
+ #!/bin/bash
1428
+
1429
+ # Create session
1430
+ SESSION_ID=$(orka session create "Feature X" --json | jq -r '.id')
1431
+
1432
+ # Create fork
1433
+ FORK_ID=$(orka fork create $SESSION_ID "Alternative" --json | jq -r '.id')
1434
+
1435
+ # Export and merge
1436
+ orka merge auto $SESSION_ID $FORK_ID
1437
+
1438
+ # Get final summary
1439
+ orka status
1440
+ ```
1441
+
1442
+ ---
1443
+
1444
+ ## Architecture
1445
+
1446
+ ### Directory Structure
1447
+
1448
+ ```
1449
+ .claude-orka/
1450
+ ├── state.json # Project state (sessions, forks)
1451
+ └── exports/ # Fork export summaries
1452
+ ├── fork-abc123.md # Export for fork abc123
1453
+ └── fork-def456.md # Export for fork def456
1454
+ ```
1455
+
1456
+ ### State File
1457
+
1458
+ **Location:** `.claude-orka/state.json`
1459
+
1460
+ **Structure:**
1461
+ ```json
1462
+ {
1463
+ "version": "1.0.0",
1464
+ "projectPath": "/path/to/project",
1465
+ "sessions": [
1466
+ {
1467
+ "id": "abc123...",
1468
+ "name": "Feature Implementation",
1469
+ "tmuxSessionId": "orka-abc123",
1470
+ "status": "active",
1471
+ "createdAt": "2025-11-20T10:00:00.000Z",
1472
+ "lastActivity": "2025-11-20T12:00:00.000Z",
1473
+ "main": {
1474
+ "claudeSessionId": "uuid-main",
1475
+ "tmuxPaneId": "%1",
1476
+ "status": "active"
1477
+ },
1478
+ "forks": [
1479
+ {
1480
+ "id": "def456",
1481
+ "name": "Alternative Approach",
1482
+ "parentId": "main",
1483
+ "claudeSessionId": "uuid-fork",
1484
+ "tmuxPaneId": "%2",
1485
+ "status": "merged",
1486
+ "createdAt": "2025-11-20T11:00:00.000Z",
1487
+ "contextPath": ".claude-orka/exports/fork-def456.md",
1488
+ "mergedToMain": true,
1489
+ "mergedAt": "2025-11-20T12:00:00.000Z"
1490
+ }
1491
+ ]
1492
+ }
1493
+ ],
1494
+ "lastUpdated": "2025-11-20T12:00:00.000Z"
1495
+ }
1496
+ ```
1497
+
1498
+ ### Key Concepts
1499
+
1500
+ **Session:**
1501
+ - A Claude Code conversation with main + forks
1502
+ - Runs in tmux session for multiplexing
1503
+ - Persists across tmux detach/attach
1504
+
1505
+ **Main Branch:**
1506
+ - Primary conversation thread
1507
+ - Cannot be deleted or merged
1508
+ - Always exists in a session
1509
+
1510
+ **Fork:**
1511
+ - Branched conversation from main or another fork
1512
+ - Independent Claude session
1513
+ - Can be merged back to parent
1514
+
1515
+ **Export:**
1516
+ - Summary of fork's exploration
1517
+ - Generated by Claude
1518
+ - Markdown format
1519
+ - Required before merge
1520
+
1521
+ **Merge:**
1522
+ - Integrates fork learnings into parent
1523
+ - Sends export summary to parent conversation
1524
+ - Marks fork as 'merged'
1525
+
1526
+ ### tmux Integration
1527
+
1528
+ **Session naming:** `orka-{session-id}`
1529
+ - Easy identification
1530
+ - Consistent naming
1531
+
1532
+ **Pane layout:**
1533
+ ```
1534
+ ┌─────────────────────────────────┐
1535
+ │ Main (MAIN) │
1536
+ ├─────────────────────────────────┤
1537
+ │ Fork 1 │
1538
+ ├─────────────────────────────────┤
1539
+ │ Fork 2 │
1540
+ └─────────────────────────────────┘
1541
+ ```
1542
+
1543
+ **Recovery:**
1544
+ - Detects if tmux session exists
1545
+ - If missing: creates new session + resumes Claude
1546
+ - If exists: reconnects to existing panes
1547
+
1548
+ ### Claude Integration
1549
+
1550
+ **Session detection:**
1551
+ - Reads `~/.claude/history.jsonl`
1552
+ - Finds most recent session ID
1553
+ - Associates with tmux pane
1554
+
1555
+ **Context preservation:**
1556
+ - Uses Claude's native session resume
1557
+ - Full conversation history maintained
1558
+ - Works across system restarts
1559
+
1560
+ ---
1561
+
1562
+ ## Troubleshooting
1563
+
1564
+ ### Common Issues
1565
+
1566
+ #### tmux not found
1567
+
1568
+ **Error:** `command not found: tmux`
1569
+
1570
+ **Solution:**
1571
+ ```bash
1572
+ # macOS
1573
+ brew install tmux
1574
+
1575
+ # Ubuntu
1576
+ sudo apt-get install tmux
1577
+
1578
+ # Or use orka prepare
1579
+ orka prepare
1580
+ ```
1581
+
1582
+ ---
1583
+
1584
+ #### Claude CLI not found
1585
+
1586
+ **Error:** `command not found: claude`
1587
+
1588
+ **Solution:**
1589
+ - Download from [claude.ai/download](https://claude.ai/download)
1590
+ - Or install via npm: `npm install -g @anthropic-ai/claude-cli`
1591
+ - Verify: `claude --version`
1592
+
1593
+ ---
1594
+
1595
+ #### Project not initialized
1596
+
1597
+ **Error:** `Project not initialized`
1598
+
1599
+ **Solution:**
1600
+ ```bash
1601
+ orka init
1602
+ ```
1603
+
1604
+ ---
1605
+
1606
+ #### Session recovery fails
1607
+
1608
+ **Error:** Session won't resume after restart
1609
+
1610
+ **Check:**
1611
+ 1. State file exists: `.claude-orka/state.json`
1612
+ 2. Claude session still valid in `~/.claude/history.jsonl`
1613
+ 3. Run `orka doctor` to check dependencies
1614
+
1615
+ **Recovery:**
1616
+ ```bash
1617
+ # Force resume
1618
+ orka session resume <session-id>
1619
+
1620
+ # If that fails, create new session
1621
+ orka session create
1622
+ ```
1623
+
1624
+ ---
1625
+
1626
+ #### Merge fails - no export
1627
+
1628
+ **Error:** `Cannot merge - fork not exported`
1629
+
1630
+ **Solution:**
1631
+ ```bash
1632
+ # Export first
1633
+ orka merge export <session-id> <fork-id>
1634
+
1635
+ # Wait 10-15 seconds for Claude
1636
+
1637
+ # Then merge
1638
+ orka merge do <session-id> <fork-id>
1639
+
1640
+ # Or use auto (recommended)
1641
+ orka merge auto <session-id> <fork-id>
1642
+ ```
1643
+
1644
+ ---
1645
+
1646
+ #### UI won't launch
1647
+
1648
+ **Error:** Electron UI doesn't open
1649
+
1650
+ **Check:**
1651
+ 1. Electron is installed: `npm list -g electron`
1652
+ 2. Display is available (not SSH session)
1653
+ 3. Permissions correct
1654
+
1655
+ **Manual launch:**
1656
+ ```bash
1657
+ # Check if UI process is running
1658
+ ps aux | grep electron
1659
+
1660
+ # Kill existing UI
1661
+ pkill -f "electron.*claude-orka"
1662
+
1663
+ # Try again
1664
+ orka session resume <session-id>
1665
+ ```
1666
+
1667
+ ---
1668
+
1669
+ #### Multiple sessions conflict
1670
+
1671
+ **Error:** Fork creation blocked
1672
+
1673
+ **Reason:** Claude Code limitation - only one fork per branch
1674
+
1675
+ **Solution:**
1676
+ ```bash
1677
+ # Merge or close existing fork first
1678
+ orka merge auto <session-id> <existing-fork-id>
1679
+
1680
+ # Or close it
1681
+ orka fork close <session-id> <existing-fork-id>
1682
+
1683
+ # Then create new fork
1684
+ orka fork create <session-id> "New Fork"
1685
+ ```
1686
+
1687
+ ---
1688
+
1689
+ ### Debug Mode
1690
+
1691
+ Enable debug logging:
1692
+
1693
+ ```bash
1694
+ # Set environment variable
1695
+ export CLAUDE_ORKA_DEBUG=1
1696
+
1697
+ # Run command
1698
+ orka session create
1699
+
1700
+ # Check logs
1701
+ cat .claude-orka/orka.log
1702
+ ```
1703
+
1704
+ ---
1705
+
1706
+ ### Getting Help
1707
+
1708
+ ```bash
1709
+ # Check system status
1710
+ orka doctor
1711
+
1712
+ # Get help for command
1713
+ orka session create --help
1714
+
1715
+ # View version
1716
+ orka --version
1717
+ ```
1718
+
1719
+ ---
1720
+
1721
+ ## Contributing
1722
+
1723
+ Contributions are welcome! Please feel free to submit a Pull Request.
1724
+
1725
+ **Areas for contribution:**
1726
+ - Windows support
1727
+ - Additional terminal emulators
1728
+ - UI enhancements
1729
+ - Documentation improvements
1730
+ - Bug fixes
1731
+
1732
+ ---
226
1733
 
227
1734
  ## License
228
1735
 
229
1736
  MIT © enruana
230
1737
 
1738
+ ---
1739
+
231
1740
  ## Links
232
1741
 
233
1742
  - [GitHub Repository](https://github.com/enruana/claude-orka)