@xelth/eck-snapshot 2.2.0 β†’ 4.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.
Files changed (36) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +119 -225
  3. package/index.js +14 -776
  4. package/package.json +25 -7
  5. package/setup.json +805 -0
  6. package/src/cli/cli.js +427 -0
  7. package/src/cli/commands/askGpt.js +29 -0
  8. package/src/cli/commands/autoDocs.js +150 -0
  9. package/src/cli/commands/consilium.js +86 -0
  10. package/src/cli/commands/createSnapshot.js +601 -0
  11. package/src/cli/commands/detectProfiles.js +98 -0
  12. package/src/cli/commands/detectProject.js +112 -0
  13. package/src/cli/commands/generateProfileGuide.js +91 -0
  14. package/src/cli/commands/pruneSnapshot.js +106 -0
  15. package/src/cli/commands/restoreSnapshot.js +173 -0
  16. package/src/cli/commands/setupGemini.js +149 -0
  17. package/src/cli/commands/setupGemini.test.js +115 -0
  18. package/src/cli/commands/trainTokens.js +38 -0
  19. package/src/config.js +81 -0
  20. package/src/services/authService.js +20 -0
  21. package/src/services/claudeCliService.js +621 -0
  22. package/src/services/claudeCliService.test.js +267 -0
  23. package/src/services/dispatcherService.js +33 -0
  24. package/src/services/gptService.js +302 -0
  25. package/src/services/gptService.test.js +120 -0
  26. package/src/templates/agent-prompt.template.md +29 -0
  27. package/src/templates/architect-prompt.template.md +50 -0
  28. package/src/templates/envScanRequest.md +4 -0
  29. package/src/templates/gitWorkflow.md +32 -0
  30. package/src/templates/multiAgent.md +164 -0
  31. package/src/templates/vectorMode.md +22 -0
  32. package/src/utils/aiHeader.js +303 -0
  33. package/src/utils/fileUtils.js +928 -0
  34. package/src/utils/projectDetector.js +704 -0
  35. package/src/utils/tokenEstimator.js +198 -0
  36. package/.ecksnapshot.config.js +0 -35
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Dmytro Surovtsev
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 CHANGED
@@ -1,226 +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 CLI tool to create and restore single-file text snapshots of a Git repository. It generates a single `.txt` file containing the directory structure and the content of all text-based files, which is ideal for providing context to Large Language Models (LLMs).
7
-
8
- ## Why eck-snapshot?
9
-
10
- When working with Large Language Models (LLMs), providing the full context of your project is crucial for getting accurate results. Manually copying and pasting dozens of files is tedious and inefficient.
11
-
12
- eck-snapshot automates this by generating a single, comprehensive text file of your entire repository. This is particularly effective with models that support large context windows (like Google's Gemini), as it often allows the entire project snapshot to be analyzed at onceβ€”a task that can be challenging with smaller context windows.
13
-
14
- ## Key Features
15
-
16
- * **Git Integration**: Automatically includes all files tracked by Git.
17
- * **Intelligent Ignoring**: Respects `.gitignore` rules and has its own configurable ignore lists for files, extensions, and directories.
18
- * **Advanced Restore**: Powerful `restore` command with filtering, dry-run mode, and parallel processing.
19
- * **Directory Tree**: Generates a clean, readable tree of the repository structure at the top of the snapshot.
20
- * **Multiple Formats**: Supports both plain text and JSON output formats.
21
- * **Configurable**: Customize behavior using an `.ecksnapshot.config.js` file.
22
- * **Progress and Stats**: Provides a progress bar and a detailed summary of what was included and skipped.
23
- * **Compression**: Supports gzipped (`.gz`) snapshots for smaller file sizes.
24
- * **Security**: Built-in path validation to prevent directory traversal attacks during restore.
25
-
26
- ## Demo
27
-
28
- Here's an example of `eck-snapshot` in action:
29
-
30
- ```
31
- πŸš€ Starting snapshot for repository: /path/to/your/project
32
- βœ… .gitignore patterns loaded
33
- πŸ“Š Found 152 total files in the repository
34
- 🌳 Generating directory tree...
35
- πŸ“ Processing files...
36
- Progress |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 100% | 152/152 files
37
-
38
- πŸ“Š Snapshot Summary
39
- ==================================================
40
- πŸŽ‰ Snapshot created successfully!
41
- πŸ“„ File saved to: /path/to/your/project/snapshots/project_snapshot_...txt
42
- πŸ“ˆ Included text files: 130 of 152
43
- ⏭️ Skipped files: 22
44
- ...
45
- ==================================================
46
- ```
47
-
48
- The beginning of the generated file will look like this:
49
-
50
- ```text
51
- Directory Structure:
52
-
53
- β”œβ”€β”€ .github/
54
- β”‚ └── workflows/
55
- β”‚ └── publish.yml
56
- β”œβ”€β”€ src/
57
- β”‚ β”œβ”€β”€ utils/
58
- β”‚ β”‚ └── formatters.js
59
- β”‚ └── index.js
60
- β”œβ”€β”€ .gitignore
61
- β”œβ”€β”€ package.json
62
- └── README.md
63
-
64
-
65
- --- File: /src/index.js ---
66
-
67
- #!/usr/bin/env node
68
- import { Command } from 'commander';
69
- // ... rest of the file content
70
-
71
- --- File: /package.json ---
72
-
73
- {
74
- "name": "eck-snapshot",
75
- "version": "2.1.0",
76
- // ... rest of the file content
77
- ```
78
-
79
- ## Installation
80
-
81
- To install the tool globally, run the following command:
82
-
83
- ```bash
84
- npm install -g @xelth/eck-snapshot
85
- ```
86
-
87
- ## Usage
88
-
89
- Once installed, you can run the tool from any directory in your terminal.
90
-
91
- ### Creating a Snapshot
92
-
93
- ```bash
94
- # Create a snapshot of the current directory
95
- eck-snapshot
96
-
97
- # Specify a path to another repository
98
- eck-snapshot /path/to/your/other/project
99
-
100
- # Save the snapshot to a different directory and exclude the tree view
101
- eck-snapshot --output ./backups --no-tree
102
-
103
- # Create a compressed JSON snapshot
104
- eck-snapshot --format json --compress
105
-
106
- # Include hidden files and set custom size limits
107
- eck-snapshot --include-hidden --max-file-size 5MB --max-total-size 50MB
108
- ```
109
-
110
- ### Restoring from a Snapshot
111
-
112
- ```bash
113
- # Basic restore to current directory
114
- eck-snapshot restore ./snapshots/project_snapshot_...txt
115
-
116
- # Restore to a specific directory without confirmation
117
- eck-snapshot restore snapshot.txt ./restored-project --force
118
-
119
- # Preview what would be restored (dry run)
120
- eck-snapshot restore snapshot.txt --dry-run
121
-
122
- # Restore only specific files using patterns
123
- eck-snapshot restore snapshot.txt --include "*.js" "*.json"
124
-
125
- # Restore everything except certain files
126
- eck-snapshot restore snapshot.txt --exclude "*.log" "node_modules/*"
127
-
128
- # Restore with custom concurrency and verbose output
129
- eck-snapshot restore snapshot.txt --concurrency 20 --verbose
130
-
131
- # Restore compressed snapshots
132
- eck-snapshot restore project_snapshot.txt.gz ./restored
133
- ```
134
-
135
- ## Configuration
136
-
137
- You can create a `.ecksnapshot.config.js` file in your project's root directory to customize the tool's behavior.
138
-
139
- **Example `.ecksnapshot.config.js`:**
140
-
141
- ```javascript
142
- export default {
143
- // Files to ignore by name or pattern
144
- filesToIgnore: [
145
- 'package-lock.json',
146
- '*.log',
147
- ],
148
- // File extensions to ignore
149
- extensionsToIgnore: [
150
- '.sqlite3',
151
- '.env',
152
- ],
153
- // Directories to ignore (must have a trailing slash)
154
- dirsToIgnore: [
155
- 'node_modules/',
156
- '.git/',
157
- 'dist/',
158
- ],
159
- // Size and performance settings
160
- maxFileSize: '10MB',
161
- maxTotalSize: '100MB',
162
- maxDepth: 10,
163
- concurrency: 10
164
- };
165
- ```
166
-
167
- ## Advanced Features
168
-
169
- ### Restore Command Options
170
-
171
- The restore command offers powerful filtering and control options:
172
-
173
- - **`--dry-run`**: Preview what files would be restored without actually writing them
174
- - **`--include <patterns>`**: Only restore files matching the specified patterns (supports wildcards)
175
- - **`--exclude <patterns>`**: Skip files matching the specified patterns (supports wildcards)
176
- - **`--concurrency <number>`**: Control how many files are processed simultaneously (default: 10)
177
- - **`--force`**: Skip confirmation prompts and overwrite existing files
178
- - **`--verbose`**: Show detailed information about each file being processed
179
-
180
- ### Supported Formats
181
-
182
- - **Plain Text** (`.txt`): Human-readable format, ideal for LLM context
183
- - **JSON** (`.json`): Structured format with metadata and statistics
184
- - **Compressed** (`.gz`): Any format can be gzipped for smaller file sizes
185
-
186
- ### Security Features
187
-
188
- - **Path Validation**: Prevents directory traversal attacks during restore operations
189
- - **File Sanitization**: Validates file paths and names for security
190
- - **Confirmation Prompts**: Requires user confirmation before overwriting files (unless `--force` is used)
191
-
192
- ## Command Reference
193
-
194
- ### Snapshot Command
195
- ```bash
196
- eck-snapshot [options] [repoPath]
197
- ```
198
-
199
- **Options:**
200
- - `-o, --output <dir>`: Output directory for snapshots
201
- - `--no-tree`: Exclude directory tree from output
202
- - `-v, --verbose`: Show detailed processing information
203
- - `--max-file-size <size>`: Maximum individual file size (e.g., 10MB)
204
- - `--max-total-size <size>`: Maximum total snapshot size (e.g., 100MB)
205
- - `--max-depth <number>`: Maximum directory depth for tree generation
206
- - `--config <path>`: Path to custom configuration file
207
- - `--compress`: Create gzipped output
208
- - `--include-hidden`: Include hidden files (starting with .)
209
- - `--format <type>`: Output format: txt or json
210
-
211
- ### Restore Command
212
- ```bash
213
- eck-snapshot restore [options] <snapshot_file> [target_directory]
214
- ```
215
-
216
- **Options:**
217
- - `-f, --force`: Force overwrite without confirmation
218
- - `-v, --verbose`: Show detailed processing information
219
- - `--dry-run`: Preview without actually writing files
220
- - `--include <patterns>`: Include only matching files
221
- - `--exclude <patterns>`: Exclude matching files
222
- - `--concurrency <number>`: Number of concurrent operations
223
-
224
- ## License
225
-
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
+
226
120
  This project is licensed under the MIT License.