ccexport 0.1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ccc4798123b459b9c2f9eb8637d17c28d5168ac7f0ea965c23b56543636f832e
4
+ data.tar.gz: 30e8610415bf25386cd49dfec6a0e6f4b0ad8bfa401d1968dfdea4cff50443a9
5
+ SHA512:
6
+ metadata.gz: f33cbe1749351761a15927f669728b4fde3ff8e0c4043691b8ce53dd4ca990e14aff410d241e5269639661d587668e8f348d6b01cc1bfd73211d40b13a3da256
7
+ data.tar.gz: d687d278ab543a97b1ec4e875654029c922f1a069aa588f998977181fb27c2778296288e1009e8afdc42e9098f4a0997c8047cddeaf40919c36faa23b95cfdf7
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ claude-conversations/
2
+ docs/
3
+ .DS_Store
4
+ TEST.*
5
+
6
+ # Gem build artifacts
7
+ *.gem
data/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
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
+ ## [0.1.0] - 2024-08-17
11
+
12
+ ### Added
13
+ - Initial release of ccexport gem
14
+ - Export Claude Code conversations from JSONL session files to Markdown and HTML
15
+ - Multiple HTML templates: default, github, solarized with dark/light mode support
16
+ - Comprehensive syntax highlighting with Prism.js for Ruby, JavaScript, Python, TypeScript, JSON, Markdown, YAML, Bash
17
+ - TruffleHog integration for secret detection and redaction
18
+ - Date filtering and custom output paths
19
+ - HTML preview generation with automatic browser opening
20
+ - Command-line interface with extensive options
21
+ - Support for both single session and multi-session exports
22
+ - Path relativization for project files
23
+ - Comprehensive test suite with RSpec
data/CLAUDE.md ADDED
@@ -0,0 +1,156 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Development Commands
6
+
7
+ ### Testing
8
+ ```bash
9
+ # Run all tests
10
+ bundle exec rspec
11
+
12
+ # Run specific test file
13
+ bundle exec rspec spec/claude_conversation_exporter_spec.rb
14
+
15
+ # Run tests for a specific feature
16
+ bundle exec rspec spec/secret_detection_spec.rb
17
+
18
+ # Run tests with documentation output
19
+ bundle exec rspec --format documentation
20
+ ```
21
+
22
+ ### Installation & Dependencies
23
+ ```bash
24
+ # Install Ruby dependencies
25
+ bundle install
26
+
27
+ # Install TruffleHog (required for secret detection)
28
+ brew install trufflehog
29
+
30
+ # Install cmark-gfm (required for HTML preview generation)
31
+ brew install cmark-gfm
32
+ ```
33
+
34
+ ### Running the Tool
35
+ ```bash
36
+ # Basic export (all conversations)
37
+ ./bin/ccexport
38
+
39
+ # Export with HTML preview
40
+ ./bin/ccexport --preview
41
+
42
+ # Export specific date range
43
+ ./bin/ccexport --from 2024-01-01 --to 2024-01-31 --preview
44
+
45
+ # Generate VIBE examples for all templates
46
+ ./generate_vibe_samples
47
+ ```
48
+
49
+ ## Architecture Overview
50
+
51
+ ### Core Components
52
+
53
+ **ClaudeConversationExporter** (`lib/claude_conversation_exporter.rb`)
54
+ - Main class handling conversation discovery, parsing, and export
55
+ - Uses class methods for simple API: `ClaudeConversationExporter.export`
56
+ - Handles both single session and multi-session exports
57
+ - Integrates secret detection, path relativization, and HTML generation
58
+
59
+ **TruffleHogSecretDetector** (`lib/secret_detector.rb`)
60
+ - Wrapper around TruffleHog external command for secret detection
61
+ - Uses temporary files and JSON parsing to interface with TruffleHog
62
+ - Provides `scan()` and `redact()` methods with Finding objects
63
+ - Backward compatible with previous SecretDetector interface
64
+
65
+ **CLI Interface** (`bin/ccexport`)
66
+ - OptionParser-based command line interface
67
+ - Supports date filtering, custom paths, templates, and preview generation
68
+ - Handles both directory scanning and specific JSONL file processing
69
+
70
+ ### Data Flow
71
+
72
+ 1. **Discovery**: Finds Claude Code session files (`.jsonl`) in `~/.claude/projects/` subdirectories
73
+ 2. **Parsing**: Reads JSONL files line by line, extracting messages and metadata
74
+ 3. **Processing**:
75
+ - Pairs tool_use with tool_result messages across message boundaries
76
+ - Filters messages by date range if specified
77
+ - Applies specialized formatting for different tool types (Write, Bash, Edit, TodoWrite)
78
+ 4. **Path Relativization**: Converts absolute project paths to relative paths throughout content
79
+ 5. **Secret Detection**: Scans entire final markdown content with TruffleHog and redacts findings
80
+ 6. **Output**: Generates markdown and optional HTML preview
81
+
82
+ ### Template System
83
+
84
+ **Template Location**: `lib/templates/*.html.erb`
85
+ - `default.html.erb`: Clean modern styling with warm colors
86
+ - `github.html.erb`: GitHub-style rendering
87
+ - `solarized.html.erb`: Solarized color scheme with automatic dark/light mode detection and clickable theme toggle
88
+
89
+ **Template Features**:
90
+ - ERB templating with `<%= content %>` and `<%= title %>` variables
91
+ - Embedded Prism.js syntax highlighting from `lib/assets/`
92
+ - CSS custom properties for theme consistency
93
+ - Responsive design with proper mobile support
94
+
95
+ ### Syntax Highlighting (Prism.js)
96
+
97
+ **Current Language Support**: Markup/HTML, CSS, C-like, JavaScript, Ruby, Python, Markdown, TypeScript, JSON, YAML, Bash
98
+
99
+ **Adding New Languages**:
100
+ 1. Download language component from CDN:
101
+ ```bash
102
+ curl -s "https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-LANGUAGE.min.js" \
103
+ -o lib/assets/prism-LANGUAGE.js
104
+ ```
105
+
106
+ 2. Add component filename to `include_prism` method in `lib/claude_conversation_exporter.rb`:
107
+ ```ruby
108
+ language_components = %w[
109
+ prism-python.js
110
+ prism-markdown.js
111
+ prism-typescript.js
112
+ prism-json.js
113
+ prism-yaml.js
114
+ prism-bash.js
115
+ prism-LANGUAGE.js # <- Add new language here
116
+ ]
117
+ ```
118
+
119
+ 3. Update README.md language list if needed
120
+
121
+ **Language Component Files**: Kept separate in `lib/assets/prism-*.js` for maintainability. The `include_prism` method dynamically loads and concatenates all components.
122
+
123
+ ### Message Processing Pipeline
124
+
125
+ **Tool Pairing Logic**: Complex cross-message matching where `tool_use` messages are paired with subsequent `tool_result` messages based on tool ID, even when they appear in separate user/assistant message blocks.
126
+
127
+ **Content Extraction**: Handles different Claude message content types:
128
+ - `text`: Plain text content
129
+ - `tool_use`: Formatted as collapsible sections with syntax highlighting
130
+ - `thinking`: Displayed as blockquotes with special emoji indicators
131
+
132
+ **Filtering**: System-generated messages and leaf summaries are filtered out, with comprehensive logging in `*_skipped.jsonl` files.
133
+
134
+ ## Special Considerations
135
+
136
+ ### Secret Detection
137
+ - Runs TruffleHog on final markdown content (not individual messages)
138
+ - Creates `*_secrets.jsonl` logs with context information
139
+ - Uses `[REDACTED]` replacement strategy
140
+ - External dependency on `trufflehog` command
141
+
142
+ ### Claude Code Session Discovery
143
+ - Automatically discovers sessions in `~/.claude/projects/` subdirectories
144
+ - Handles complex project path mappings and multiple session files per project
145
+ - Session directory structure: `~/.claude/projects/{escaped-project-path}/`
146
+
147
+ ### VIBE Examples
148
+ - `VIBE.md` and `VIBE_*.html`: Limited examples (67 messages) for easy browsing
149
+ - `VIBE_full.md` and `VIBE_full.html`: Complete conversation (3,806 messages) demonstrating scalability
150
+ - `./generate_vibe_samples` script regenerates all template examples automatically
151
+
152
+ ### Testing Strategy
153
+ - 96 RSpec tests covering all major functionality
154
+ - Test fixtures in `spec/fixtures/` with real JSONL data samples
155
+ - Mocking of external dependencies (TruffleHog, cmark-gfm, system commands)
156
+ - Comprehensive secret detection testing with realistic secret formats
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in ccexport.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,36 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ccexport (0.1.0)
5
+ json (~> 2.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.6.2)
11
+ json (2.13.2)
12
+ rake (13.3.0)
13
+ rspec (3.13.1)
14
+ rspec-core (~> 3.13.0)
15
+ rspec-expectations (~> 3.13.0)
16
+ rspec-mocks (~> 3.13.0)
17
+ rspec-core (3.13.5)
18
+ rspec-support (~> 3.13.0)
19
+ rspec-expectations (3.13.5)
20
+ diff-lcs (>= 1.2.0, < 2.0)
21
+ rspec-support (~> 3.13.0)
22
+ rspec-mocks (3.13.5)
23
+ diff-lcs (>= 1.2.0, < 2.0)
24
+ rspec-support (~> 3.13.0)
25
+ rspec-support (3.13.4)
26
+
27
+ PLATFORMS
28
+ arm64-darwin-24
29
+
30
+ DEPENDENCIES
31
+ ccexport!
32
+ rake (~> 13.0)
33
+ rspec (~> 3.12)
34
+
35
+ BUNDLED WITH
36
+ 2.6.7
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Claude Code Conversation Exporter
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.