@xelth/eck-snapshot 3.0.0 β†’ 4.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.
Files changed (41) hide show
  1. package/README.md +120 -292
  2. package/index.js +14 -971
  3. package/package.json +30 -6
  4. package/setup.json +847 -0
  5. package/src/cli/cli.js +417 -0
  6. package/src/cli/commands/askGpt.js +29 -0
  7. package/src/cli/commands/autoDocs.js +150 -0
  8. package/src/cli/commands/consilium.js +86 -0
  9. package/src/cli/commands/createSnapshot.js +622 -0
  10. package/src/cli/commands/detectProfiles.js +98 -0
  11. package/src/cli/commands/detectProject.js +112 -0
  12. package/src/cli/commands/generateProfileGuide.js +91 -0
  13. package/src/cli/commands/pruneSnapshot.js +106 -0
  14. package/src/cli/commands/restoreSnapshot.js +173 -0
  15. package/src/cli/commands/setupGemini.js +149 -0
  16. package/src/cli/commands/setupGemini.test.js +115 -0
  17. package/src/cli/commands/showFile.js +39 -0
  18. package/src/cli/commands/trainTokens.js +38 -0
  19. package/src/cli/commands/updateSnapshot.js +75 -0
  20. package/src/config.js +81 -0
  21. package/src/core/skeletonizer.js +176 -0
  22. package/src/services/authService.js +20 -0
  23. package/src/services/claudeCliService.js +621 -0
  24. package/src/services/claudeCliService.test.js +267 -0
  25. package/src/services/dispatcherService.js +33 -0
  26. package/src/services/gptService.js +302 -0
  27. package/src/services/gptService.test.js +120 -0
  28. package/src/templates/agent-prompt.template.md +29 -0
  29. package/src/templates/architect-prompt.template.md +50 -0
  30. package/src/templates/envScanRequest.md +4 -0
  31. package/src/templates/gitWorkflow.md +32 -0
  32. package/src/templates/multiAgent.md +109 -0
  33. package/src/templates/skeleton-instruction.md +16 -0
  34. package/src/templates/update-prompt.template.md +19 -0
  35. package/src/templates/vectorMode.md +22 -0
  36. package/src/utils/aiHeader.js +477 -0
  37. package/src/utils/fileUtils.js +969 -0
  38. package/src/utils/gitUtils.js +44 -0
  39. package/src/utils/projectDetector.js +704 -0
  40. package/src/utils/tokenEstimator.js +198 -0
  41. package/.ecksnapshot.config.js +0 -35
package/README.md CHANGED
@@ -1,292 +1,120 @@
1
- # eck-snapshot
2
-
3
- [![npm version](https://badge.fury.io/js/%40xelth%2Feck-snapshot.svg)](https://www.npmjs.com/package/@xelth/eck-snapshot)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/xelth-com/eckSnapshot/blob/main/LICENSE)
5
-
6
- A powerful CLI tool to create and restore single-file text snapshots of Git repositories and directories. Generate comprehensive snapshots containing directory structure and file contents, optimized for providing context to Large Language Models (LLMs) like Claude, Gemini, and ChatGPT.
7
-
8
- ## ✨ What's New in v3.0.0
9
-
10
- 🎯 **Universal Directory Support**: Works with any directory, not just Git repositories
11
- πŸ€– **Enhanced AI Instructions**: Improved headers with detailed guidance for AI assistants
12
- ⚑ **Auto-Detection**: Automatically switches to directory mode when Git isn't available
13
- 🧹 **Clean Mode**: Option to create snapshots without AI instructions
14
-
15
- ## Why eck-snapshot?
16
-
17
- When working with Large Language Models (LLMs), providing complete project context is crucial for accurate results. Manually copying and pasting dozens of files is tedious and error-prone.
18
-
19
- eck-snapshot automates this by generating a single, comprehensive text file of your entire project. This is particularly effective with models that support large context windows (like Gemini 2.0 Pro with 1M tokens), allowing the entire project to be analyzed at once.
20
-
21
- ## πŸš€ Key Features
22
-
23
- ### πŸ“ **Universal Compatibility**
24
- - **Git Repositories**: Leverages `git ls-files` and respects `.gitignore`
25
- - **Any Directory**: Recursively scans any folder structure
26
- - **Auto-Detection**: Automatically switches modes based on Git availability
27
-
28
- ### πŸ€– **AI-Optimized**
29
- - **Structured Headers**: Detailed instructions for AI assistants
30
- - **Clean Mode**: Option to skip AI headers for general use
31
- - **LLM-Ready Format**: Optimized for Claude, Gemini, ChatGPT, and other models
32
-
33
- ### ⚑ **Advanced Features**
34
- - **Multiple Formats**: Plain text (Markdown) and JSON output
35
- - **Compression**: Built-in gzip support for smaller files
36
- - **Smart Filtering**: Configurable ignore patterns and size limits
37
- - **Restore Capability**: Recreate entire project structures from snapshots
38
- - **Progress Tracking**: Real-time progress bars and detailed statistics
39
-
40
- ### πŸ”’ **Security & Performance**
41
- - **Path Validation**: Prevents directory traversal attacks
42
- - **Parallel Processing**: Concurrent file handling for speed
43
- - **Memory Efficient**: Handles large projects without memory issues
44
-
45
- ## πŸ“¦ Installation
46
-
47
- ```bash
48
- npm install -g @xelth/eck-snapshot
49
- ```
50
-
51
- ## 🎯 Quick Start
52
-
53
- ### Create Snapshots
54
-
55
- ```bash
56
- # Git repository (default mode)
57
- eck-snapshot
58
-
59
- # Any directory (auto-detects non-git folders)
60
- eck-snapshot /path/to/any/folder
61
-
62
- # Force directory mode (ignores git)
63
- eck-snapshot --dir .
64
-
65
- # Clean snapshot without AI instructions
66
- eck-snapshot --no-ai-header
67
-
68
- # Compressed JSON format
69
- eck-snapshot --format json --compress
70
- ```
71
-
72
- ### Restore from Snapshots
73
-
74
- ```bash
75
- # Basic restore
76
- eck-snapshot restore snapshot.md
77
-
78
- # Restore to specific directory
79
- eck-snapshot restore snapshot.md ./restored-project
80
-
81
- # Preview without writing files
82
- eck-snapshot restore snapshot.md --dry-run
83
-
84
- # Restore only specific files
85
- eck-snapshot restore snapshot.md --include "*.js" "*.json"
86
- ```
87
-
88
- ## πŸ“‹ Usage Examples
89
-
90
- ### For AI Development
91
-
92
- ```bash
93
- # Create AI-optimized snapshot for Gemini/Claude
94
- eck-snapshot --format md --compress
95
- # Result: project_snapshot_2025-01-19_12-00-00.md.gz
96
-
97
- # Clean snapshot for general documentation
98
- eck-snapshot --no-ai-header --output ./docs
99
- ```
100
-
101
- ### Project Backup & Migration
102
-
103
- ```bash
104
- # Full project backup
105
- eck-snapshot --include-hidden --format json --compress
106
-
107
- # Selective restore
108
- eck-snapshot restore backup.json.gz --exclude "node_modules/*" --include "src/*"
109
- ```
110
-
111
- ### Cross-Platform Development
112
-
113
- ```bash
114
- # Create snapshot on Windows
115
- eck-snapshot --output ./transfer
116
-
117
- # Restore on Linux/Mac
118
- eck-snapshot restore transfer/project_snapshot.md ./project
119
- ```
120
-
121
- ## βš™οΈ Configuration
122
-
123
- Create `.ecksnapshot.config.js` in your project root:
124
-
125
- ```javascript
126
- export default {
127
- // Files to ignore by name or pattern
128
- filesToIgnore: [
129
- 'package-lock.json',
130
- '*.log',
131
- '*.tmp'
132
- ],
133
-
134
- // File extensions to ignore
135
- extensionsToIgnore: [
136
- '.sqlite3',
137
- '.env',
138
- '.DS_Store',
139
- '.ico',
140
- '.png',
141
- '.jpg'
142
- ],
143
-
144
- // Directories to ignore
145
- dirsToIgnore: [
146
- 'node_modules/',
147
- '.git/',
148
- 'dist/',
149
- 'build/',
150
- 'coverage/'
151
- ],
152
-
153
- // Size and performance limits
154
- maxFileSize: '10MB',
155
- maxTotalSize: '100MB',
156
- maxDepth: 10,
157
- concurrency: 10
158
- };
159
- ```
160
-
161
- ## πŸ“– Command Reference
162
-
163
- ### Snapshot Command
164
-
165
- ```bash
166
- eck-snapshot [options] [path]
167
- ```
168
-
169
- **Core Options:**
170
- - `-o, --output <dir>` - Output directory (default: ./snapshots)
171
- - `-d, --dir` - Directory mode: scan any folder recursively
172
- - `--no-ai-header` - Skip AI instruction header (clean mode)
173
- - `-v, --verbose` - Show detailed processing information
174
-
175
- **Format & Compression:**
176
- - `--format <type>` - Output format: md (default) or json
177
- - `--compress` - Create gzipped output (.gz extension)
178
- - `--no-tree` - Exclude directory tree from output
179
-
180
- **Filtering:**
181
- - `--include-hidden` - Include hidden files (starting with .)
182
- - `--max-file-size <size>` - Maximum individual file size (e.g., 5MB)
183
- - `--max-total-size <size>` - Maximum total snapshot size (e.g., 50MB)
184
- - `--config <path>` - Path to custom configuration file
185
-
186
- ### Restore Command
187
-
188
- ```bash
189
- eck-snapshot restore [options] <snapshot_file> [target_directory]
190
- ```
191
-
192
- **Control Options:**
193
- - `-f, --force` - Skip confirmation prompts
194
- - `--dry-run` - Preview without writing files
195
- - `-v, --verbose` - Show detailed processing information
196
-
197
- **Filtering:**
198
- - `--include <patterns>` - Include only matching files (wildcards supported)
199
- - `--exclude <patterns>` - Exclude matching files (wildcards supported)
200
- - `--concurrency <number>` - Number of concurrent operations (default: 10)
201
-
202
- ## 🎭 Working with AI Models
203
-
204
- ### For Gemini 2.0 Pro (1M context)
205
- ```bash
206
- # Create comprehensive snapshot with AI instructions
207
- eck-snapshot --format md --compress
208
- ```
209
- The generated file includes detailed instructions for Gemini to analyze your project and provide structured commands for Claude Code.
210
-
211
- ### For Claude Code
212
- ```bash
213
- # Clean, focused snapshot
214
- eck-snapshot --no-ai-header --max-total-size 200MB
215
- ```
216
-
217
- ### For ChatGPT/Other Models
218
- ```bash
219
- # Standard snapshot with moderate size limits
220
- eck-snapshot --max-total-size 50MB --no-ai-header
221
- ```
222
-
223
- ## πŸ”§ Advanced Use Cases
224
-
225
- ### Monorepo Support
226
- ```bash
227
- # Snapshot specific package in monorepo
228
- eck-snapshot ./packages/core --dir --output ./snapshots/core
229
-
230
- # Multiple packages
231
- eck-snapshot ./packages/api --dir && eck-snapshot ./packages/web --dir
232
- ```
233
-
234
- ### CI/CD Integration
235
- ```bash
236
- # Create release snapshot
237
- eck-snapshot --format json --compress --output ./artifacts
238
-
239
- # Documentation generation
240
- eck-snapshot --no-ai-header --format md --output ./docs/snapshots
241
- ```
242
-
243
- ### Migration & Archival
244
- ```bash
245
- # Complete project archive
246
- eck-snapshot --include-hidden --format json --compress --max-total-size 1GB
247
-
248
- # Selective migration
249
- eck-snapshot restore archive.json.gz --include "src/*" "docs/*" --exclude "*.test.*"
250
- ```
251
-
252
- ## πŸ“Š Output Formats
253
-
254
- ### Markdown Format (Default)
255
- - Human-readable structure
256
- - AI instruction headers (optional)
257
- - Directory tree visualization
258
- - File content with clear delimiters
259
-
260
- ### JSON Format
261
- - Structured metadata
262
- - Programmatic processing friendly
263
- - Includes statistics and file information
264
- - Perfect for automation workflows
265
-
266
- ## πŸ›‘οΈ Security Features
267
-
268
- - **Path Validation**: Prevents directory traversal during restore
269
- - **File Sanitization**: Validates all file paths and names
270
- - **Confirmation Prompts**: Requires approval before overwriting files
271
- - **Size Limits**: Protects against extremely large operations
272
-
273
- ## πŸš€ Performance
274
-
275
- - **Parallel Processing**: Concurrent file operations for speed
276
- - **Progress Tracking**: Real-time progress bars for long operations
277
- - **Memory Efficient**: Streams large files to avoid memory issues
278
- - **Smart Caching**: Optimized for repeated operations
279
-
280
- ## πŸ“ License
281
-
282
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
283
-
284
- ## 🀝 Contributing
285
-
286
- Contributions are welcome! Please feel free to submit a Pull Request.
287
-
288
- ## πŸ“ž Support
289
-
290
- - **Issues**: [GitHub Issues](https://github.com/xelth-com/eckSnapshot/issues)
291
- - **Documentation**: This README and `--help` commands
292
- - **Examples**: See the examples directory in the repository
1
+
2
+ # eckSnapshot
3
+
4
+ A lightweight, platform-independent CLI for creating focused, AI-ready project snapshots.
5
+
6
+ `eckSnapshot` is a powerful command-line tool designed to solve a critical problem in AI-assisted development: providing clear, complete, and focused context to Large Language Models (LLMs). It allows you to package an entire project codebaseβ€”or just specific parts of itβ€”into a single, clean text file.
7
+
8
+ This tool is built for a modern workflow where you act as the architect, guiding the overall strategy, while AI agents handle the detailed implementation.
9
+
10
+ ## The Core Workflow
11
+
12
+ `eckSnapshot` is designed to support a two-part AI workflow for maximum efficiency and quality:
13
+
14
+ 1. **The Architect LLM (Gemini, GPT-4, Grok):** A model with a large context window. You provide it with a snapshot of your project, and it analyzes the codebase to create a high-level plan for new features or refactoring.
15
+ 2. **The Coder LLM (Claude Code, OpenAI Codex):** A model specialized in writing and modifying code. It takes the detailed instructions generated by the Architect and performs the hands-on coding tasks.
16
+
17
+ ## Requirements
18
+
19
+ 1. **Node.js** (v18.x or higher).
20
+ 2. **An AI Assistant CLI (at least one):**
21
+ * **Claude:** An active **Claude Pro** subscription and the `claude-code` CLI installed.
22
+ * **OpenAI:** An active **ChatGPT Plus/Pro** subscription and the `@openai/codex` CLI installed (`npm install -g @openai/codex`).
23
+
24
+ ## Installation
25
+
26
+ Install `eckSnapshot` globally on your system using npm:
27
+
28
+ ```bash
29
+ npm install -g @xelth/eck-snapshot
30
+ ```
31
+
32
+ Once installed, you can run the tool using the `eck-snapshot` command from any directory.
33
+
34
+ ## A Step-by-Step Guide to Using eckSnapshot
35
+
36
+ Here’s the most common workflow, from creating a full snapshot to focusing on specific features.
37
+
38
+ #### Step 1: Create a Full Project Snapshot
39
+
40
+ This is your primary command. It scans your project and packs all relevant code into a single file.
41
+
42
+ > **Usage:**
43
+ > ```bash
44
+ > dimi@xelth:/mnt/c/Users/xelth/myProject$ eck-snapshot
45
+ > ```
46
+
47
+ * **What it does:** Creates a file like `myProject_snapshot_... .md` in the `.eck/snapshots/` directory. This file contains your project's directory structure and the complete code. You can now pass this file to your Architect LLM for analysis.
48
+
49
+ #### Step 2: Handle Large Projects with Auto-Profiling
50
+
51
+ If your project is too large for an LLM's context window, `profile-detect` can automatically slice it into logical parts (profiles) using AI.
52
+
53
+ > **Usage:**
54
+ > ```bash
55
+ > dimi@xelth:/mnt/c/Users/xelth/myProject$ eck-snapshot profile-detect
56
+ > ```
57
+
58
+ * **Output Example:**
59
+ ```
60
+ ✨ Detected Profiles:
61
+ ---------------------------
62
+ - cli
63
+ - services
64
+ - core
65
+ - templates
66
+ - docs
67
+ - config
68
+ ```
69
+ * **What it does:** Analyzes your project and saves these logical groupings into a `.eck/profiles.json` file, which you can use in the next step.
70
+
71
+ #### Step 3: Use Profiles to Create Focused Snapshots
72
+
73
+ The `--profile` option gives you powerful control over what goes into a snapshot. You can combine profiles, exclude files, and even use ad-hoc patterns.
74
+
75
+ > **Example 1: Combine and Exclude Profiles**
76
+ >
77
+ > Create a snapshot of the core logic, services, and CLI, but exclude all documentation and configuration files.
78
+ > ```bash
79
+ > eck-snapshot --profile "core,services,cli,-docs,-config"
80
+ > ```
81
+
82
+ > **Example 2: Use Ad-Hoc Glob Patterns**
83
+ >
84
+ > Include all `.js` files in the `src` directory but exclude all test files, without using a pre-defined profile.
85
+ > ```bash
86
+ > eck-snapshot --profile "src/**/*.js,-**/*.test.js"
87
+ > ```
88
+ > *Note: Quotes are required when using complex patterns with wildcards (`*`) or commas.*
89
+
90
+ #### Step 4: Intelligently Prune a Snapshot
91
+
92
+ If a snapshot is still too large, `prune` uses AI to shrink it to a target size, keeping only the most important files for understanding the code.
93
+
94
+ > **Usage:**
95
+ > ```bash
96
+ > eck-snapshot prune myProject_snapshot.md --target-size 500KB
97
+ > ```
98
+
99
+ #### Step 5 (Alternative): Truncate Files by Line Count
100
+
101
+ A faster, non-AI method to reduce snapshot size. This command keeps only the top N lines of each file, which is useful for a high-level architectural overview.
102
+
103
+ > **Usage:**
104
+ > ```bash
105
+ > eck-snapshot --max-lines-per-file 200
106
+ > ```
107
+
108
+ ## Auxiliary Commands
109
+
110
+ * `restore <snapshot_file>`: Recreates a project's file structure from a snapshot.
111
+ * `generate-profile-guide`: Creates a guide for manual profile creation. Use this if `profile-detect` fails on very large projects, as it allows you to use an LLM with a larger context window (e.g., a web UI).
112
+ * `detect`: Shows how `eckSnapshot` has identified your project type and what default file filters are being applied.
113
+ * `ask-gpt` / `ask-claude`: Directly delegate a task to your configured AI coder agents from the command line.
114
+ * `setup-gemini`: A utility to automatically configure integration with the `gemini-cli`.
115
+
116
+ For a full list of commands and options, run `eck-snapshot --help`.
117
+
118
+ ## License
119
+
120
+ This project is licensed under the MIT License.