mkctx 4.0.0 โ†’ 5.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 (3) hide show
  1. package/README.md +161 -140
  2. package/bin/mkctx.js +473 -506
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- <h1 align="center">mkctx - Make Context</h1>
1
+ # mkctx - Make Context
2
2
 
3
3
  <p align="center">
4
4
  <picture>
@@ -8,63 +8,52 @@
8
8
  </picture>
9
9
  </p>
10
10
 
11
- <p align="center">
12
- A powerful command-line tool that generates comprehensive markdown context files from your project code, perfect for AI prompts and code analysis.
13
- </p>
11
+ A powerful command-line tool that generates comprehensive context files from your project code, perfect for AI prompts and code analysis.
14
12
 
15
- <p align="center">
16
- <a href="https://www.npmjs.com/package/mkctx"><img src="https://img.shields.io/npm/v/mkctx.svg" alt="npm version"></a>
17
- <a href="https://www.npmjs.com/package/mkctx"><img src="https://img.shields.io/npm/dm/mkctx.svg" alt="npm downloads"></a>
18
- <a href="https://github.com/pnkkzero/mkctx/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/mkctx.svg" alt="license"></a>
19
- </p>
13
+ [![npm version](https://img.shields.io/npm/v/mkctx.svg)](https://www.npmjs.com/package/mkctx)
14
+ [![npm downloads](https://img.shields.io/npm/dm/mkctx.svg)](https://www.npmjs.com/package/mkctx)
15
+ [![license](https://img.shields.io/npm/l/mkctx.svg)](https://github.com/pnkkzero/mkctx/blob/main/LICENSE)
20
16
 
21
- ## โœจ Features
17
+ ## Features
22
18
 
23
- - ๐Ÿš€ **Multi-platform** - Works on Windows, macOS, and Linux
24
- - ๐Ÿ“ **Smart Ignoring** - Respects custom ignore patterns and common system files
25
- - โš™๏ธ **Configurable** - Customize source directories, output locations, and comments
26
- - โœ๏ธ **Custom Naming** - Specify custom filenames for your outputs or use the default 'context'
27
- - ๐ŸŽฏ **AI-Friendly** - Outputs code in markdown format ideal for AI prompts
28
- - ๐ŸŽจ **Syntax Highlighting** - Proper language detection for code blocks
29
- - ๐Ÿ”„ **Dynamic Mode** - Interactive path selection when needed
30
- - ๐Ÿ“Š **Context Statistics** - Token estimation and file analysis
19
+ - ๐Ÿš€ **Multi-platform** โ€” Works on Windows, macOS, and Linux
20
+ - ๐Ÿ“ **Smart Ignoring** โ€” Respects custom ignore patterns and common system files
21
+ - โš™๏ธ **Configurable** โ€” Customize source directories, output locations, and comments
22
+ - โœ๏ธ **Custom Naming** โ€” Specify custom filenames for your outputs or use the default `context`
23
+ - ๐ŸŽฏ **AI-Friendly** โ€” Outputs code in markdown format ideal for AI prompts
24
+ - ๐ŸŽจ **Syntax Highlighting** โ€” Proper language detection for code blocks
25
+ - ๐Ÿ”„ **Dual Mode** โ€” Interactive menu or fully non-interactive via CLI flags
26
+ - ๐Ÿ“Š **Context Statistics** โ€” Token estimation and file analysis
31
27
 
32
- ## ๐Ÿ“ฆ Installation
28
+ ## Installation
33
29
 
34
30
  ```bash
35
31
  npm install -g mkctx
36
32
  ```
37
33
 
38
- ### Requirements
39
-
40
- - **Node.js** 18.0+
34
+ **Requirements:** Node.js 18.0+
41
35
 
42
- ## ๐Ÿš€ Quick Start
36
+ ## Quick Start
43
37
 
44
- ### Interactive Mode (Recommended)
38
+ ### Interactive mode
45
39
 
46
40
  ```bash
47
41
  mkctx
48
42
  ```
49
43
 
50
- This opens an interactive menu where you can:
51
- 1. Generate context from config file or dynamically
52
- 2. View context statistics
53
- 3. Choose output formats and save with a custom name
44
+ Opens a menu where you can generate context, choose output formats, and save with a custom name.
54
45
 
55
- ### Create Configuration File
46
+ ### Non-interactive mode (no prompts)
56
47
 
57
48
  ```bash
58
- mkctx config
49
+ mkctx --src ./src --format md --name my-project
59
50
  ```
60
51
 
61
- ### Show Help
52
+ Pass flags directly and the tool runs to completion without asking anything.
62
53
 
63
- ```bash
64
- mkctx help
65
- ```
54
+ ## Usage
66
55
 
67
- ## ๐Ÿ“‹ Usage
56
+ ### Interactive menu
68
57
 
69
58
  ```
70
59
  โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
@@ -78,14 +67,13 @@ mkctx help
78
67
  โŒ Exit
79
68
  ```
80
69
 
81
- After generating context:
70
+ After scanning, you choose a format and optionally a filename:
82
71
 
83
72
  ```
84
73
  ๐Ÿ“Š Context Summary:
85
74
  Files: 42
86
75
  Lines: 3,847
87
- Size: 156.23 KB
88
- Est. tokens: ~39,058
76
+ Size: 156.23 KB
89
77
 
90
78
  ? Select output format:
91
79
  โฏ ๐Ÿ“ฆ All formats (MD, JSON, TOON, XML)
@@ -97,15 +85,49 @@ After generating context:
97
85
  ? Enter a name for the output files: (context)
98
86
  ```
99
87
 
100
- > **Note:** Simply press Enter to use the default name `context`.
88
+ ### CLI flags (non-interactive)
89
+
90
+ When any of the following flags are passed, mkctx skips all prompts and runs directly.
91
+
92
+ | Flag | Alias | Description | Default |
93
+ | ------------------------ | ----- | --------------------------------- | --------- |
94
+ | `--src <path>` | `-s` | Source directory to scan | `.` |
95
+ | `--output <path>` | `-o` | Output directory | `./mkctx` |
96
+ | `--format <fmt>` | `-f` | Output format (see below) | `md` |
97
+ | `--name <filename>` | `-n` | Base name for output files | `context` |
98
+ | `--ignore <patterns>` | | Comma-separated ignore patterns | |
99
+ | `--first-comment <text>` | | Override the first comment header | |
100
+ | `--last-comment <text>` | | Override the last comment footer | |
101
101
 
102
- ## โš™๏ธ Configuration
102
+ **Format values:** `md`, `json`, `toon`, `xml`, `all`, or comma-separated combinations.
103
+
104
+ ```bash
105
+ # Single format
106
+ mkctx --src ./src --format md
103
107
 
104
- ### Project Configuration (`mkctx.config.json`)
108
+ # Multiple formats
109
+ mkctx --src . --format md,json --name snapshot
110
+
111
+ # All formats with custom output directory
112
+ mkctx --src . --format all --name my-project --output ./docs
113
+
114
+ # Using short aliases
115
+ mkctx -s ./src -f toon -n snapshot
116
+
117
+ # With extra ignore patterns
118
+ mkctx --src ./app --format md --ignore "*.test.ts,__tests__/"
119
+
120
+ # Using = syntax
121
+ mkctx --src=./src --format=md,json --name=snapshot
122
+ ```
123
+
124
+ ## Configuration file
125
+
126
+ Run `mkctx config` to create a `mkctx.config.json` in the current directory:
105
127
 
106
128
  ```json
107
129
  {
108
- "src": "./src",
130
+ "src": ".",
109
131
  "ignore": "*.log, temp/, node_modules/, .git/, dist/, build/",
110
132
  "output": "./mkctx",
111
133
  "first_comment": "/* Project Context */",
@@ -113,127 +135,121 @@ After generating context:
113
135
  }
114
136
  ```
115
137
 
116
- | Option | Description | Default |
117
- |--------|-------------|---------|
118
- | `src` | Source directory to scan | `"."` |
119
- | `ignore` | Comma-separated patterns to ignore | See defaults |
120
- | `output` | Output directory for context file | `"./mkctx"` |
121
- | `first_comment` | Comment at the beginning | `"/* Project Context */"` |
122
- | `last_comment` | Comment at the end | `"/* End of Context */"` |
123
-
124
- ## ๐Ÿ”ง CLI Options
125
-
126
- ```bash
127
- mkctx # Interactive mode (recommended)
128
- mkctx config # Create configuration file
129
- mkctx help # Show help message
130
- mkctx version # Show version
131
- ```
138
+ | Option | Description | Default |
139
+ | --------------- | -------------------------------------- | ------------------------- |
140
+ | `src` | Source directory to scan | `"."` |
141
+ | `ignore` | Comma-separated patterns to ignore | See defaults |
142
+ | `output` | Output directory for context files | `"./mkctx"` |
143
+ | `first_comment` | Comment at the beginning of the output | `"/* Project Context */"` |
144
+ | `last_comment` | Comment at the end of the output | `"/* End of Context */"` |
132
145
 
133
- ## ๐Ÿ“‚ Ignore Patterns
146
+ When a config file is present and CLI flags are also passed, the flags take priority over the file values.
134
147
 
135
- mkctx supports several pattern types:
148
+ ## Ignore patterns
136
149
 
137
- - **Wildcards**: `*.log`, `*.test.js`, `*.spec.ts`
138
- - **Directories**: `temp/`, `dist/`, `build/`
139
- - **Glob patterns**: `**/.cache/`, `**/node_modules/`
140
- - **Exact match**: `config.local.json`
150
+ Supported pattern types:
141
151
 
142
- ### Default System Ignores
152
+ - **Wildcards:** `*.log`, `*.test.js`, `*.spec.ts`
153
+ - **Directories:** `temp/`, `dist/`, `build/`
154
+ - **Glob patterns:** `**/.cache/`, `**/node_modules/`
155
+ - **Exact match:** `config.local.json`
143
156
 
144
- These are always ignored automatically:
157
+ The following are always ignored automatically: `.git`, `.svn`, `.hg`, `node_modules`, `__pycache__`, `.DS_Store`, `Thumbs.db`, `.vscode`, `.idea`, binary files, images, and archives.
145
158
 
146
- - `.git`, `.svn`, `.hg`
147
- - `node_modules`, `__pycache__`
148
- - `.DS_Store`, `Thumbs.db`
149
- - `.vscode`, `.idea`
150
- - Binary files, images, archives
159
+ ## Output formats
151
160
 
152
- ## ๐Ÿ“„ Output Format
161
+ | Format | Extension | Description |
162
+ | ------ | --------- | ------------------------------------------------------- |
163
+ | `md` | `.md` | Markdown with fenced code blocks and project structure |
164
+ | `json` | `.json` | Simple JSON array of file objects |
165
+ | `toon` | `.toon` | Token-Oriented Object Notation โ€” compact, LLM-optimized |
166
+ | `xml` | `.xml` | XML with CDATA sections |
153
167
 
154
- The generated file contains your project code. When saving, you can specify a filename (e.g., `my_project_docs.md`) or use the default.
168
+ ### Markdown output example
155
169
 
156
170
  ````markdown
157
- /* Project Context */
171
+ /_ Project Context _/
158
172
 
159
173
  ## Project Structure
160
174
 
161
- ```
175
+ \```
162
176
  ๐Ÿ“ src/
163
177
  ๐Ÿ“ src/components/
164
- ๐Ÿ“ src/utils/
165
178
 
166
179
  42 files total
167
- ```
180
+ \```
168
181
 
169
182
  ## Source Files
170
183
 
171
184
  ### src/index.ts
172
185
 
173
- ```typescript
186
+ \```typescript
174
187
  import { App } from './app';
175
-
176
188
  const app = new App();
177
189
  app.start();
178
- ```
179
-
180
- ### src/utils/helpers.ts
190
+ \```
181
191
 
182
- ```typescript
183
- export function helper() {
184
- return true;
185
- }
186
- ```
187
-
188
- /* End of Context */
192
+ /_ End of Context _/
189
193
  ````
190
194
 
191
- ## ๐ŸŽจ Supported Languages
192
-
193
- mkctx automatically detects and applies proper syntax highlighting for:
194
-
195
- | Category | Extensions |
196
- |----------|------------|
197
- | **JavaScript/TypeScript** | `.js`, `.ts`, `.jsx`, `.tsx`, `.mjs`, `.cjs` |
198
- | **Python** | `.py`, `.pyw` |
199
- | **Go** | `.go` |
200
- | **Rust** | `.rs` |
201
- | **Java/Kotlin** | `.java`, `.kt`, `.scala` |
202
- | **C/C++** | `.c`, `.cpp`, `.h`, `.hpp` |
203
- | **PHP** | `.php` |
204
- | **Ruby** | `.rb`, `.rake` |
205
- | **Shell** | `.sh`, `.bash`, `.zsh`, `.ps1` |
206
- | **Web** | `.html`, `.css`, `.scss`, `.vue`, `.svelte` |
207
- | **Data** | `.json`, `.yaml`, `.yml`, `.xml`, `.toml` |
208
- | **And many more...** | `.sql`, `.graphql`, `.proto`, `.prisma`, `.sol` |
195
+ ### JSON output example
209
196
 
210
- ## ๐Ÿ’ก Use Cases
211
-
212
- - **๐Ÿค– AI Code Analysis** - Feed your codebase to ChatGPT, Claude, or other AI tools
213
- - **๐Ÿ“š Code Understanding** - Share project overview for quick understanding
214
- - **๐Ÿ‘ฅ Code Reviews** - Share project overview with reviewers
215
- - **๐ŸŽ“ Onboarding** - Help new developers understand the project
216
- - **๐Ÿ“ Documentation** - Generate a snapshot of your codebase with custom naming
217
-
218
- ## ๐Ÿ–ฅ๏ธ Platform Support
219
-
220
- | Platform | Status |
221
- |----------|--------|
222
- | **macOS** | โœ… Full support |
223
- | **Linux** | โœ… Full support |
224
- | **Windows** | โœ… Full support |
225
-
226
- ## ๐Ÿ”ง Troubleshooting
227
-
228
- ### Command Not Found
229
-
230
- If `mkctx` is not found after installation:
197
+ ```json
198
+ [
199
+ {
200
+ "path": "src/index.ts",
201
+ "name": "index.ts",
202
+ "extension": "ts",
203
+ "language": "typescript",
204
+ "lines": 150,
205
+ "size": 4096,
206
+ "content": "..."
207
+ }
208
+ ]
209
+ ```
231
210
 
232
- 1. Make sure npm global bin is in your PATH
233
- 2. Try: `npm bin -g` to see where global packages are installed
211
+ ## Supported languages
212
+
213
+ | Category | Extensions |
214
+ | ----------------------- | ----------------------------------------------- |
215
+ | JavaScript / TypeScript | `.js`, `.ts`, `.jsx`, `.tsx`, `.mjs`, `.cjs` |
216
+ | Python | `.py`, `.pyw` |
217
+ | Go | `.go` |
218
+ | Rust | `.rs` |
219
+ | Java / Kotlin | `.java`, `.kt`, `.scala` |
220
+ | C / C++ | `.c`, `.cpp`, `.h`, `.hpp` |
221
+ | PHP | `.php` |
222
+ | Ruby | `.rb`, `.rake` |
223
+ | Shell | `.sh`, `.bash`, `.zsh`, `.ps1` |
224
+ | Web | `.html`, `.css`, `.scss`, `.vue`, `.svelte` |
225
+ | Data | `.json`, `.yaml`, `.yml`, `.xml`, `.toml` |
226
+ | Other | `.sql`, `.graphql`, `.proto`, `.prisma`, `.sol` |
227
+
228
+ ## Use cases
229
+
230
+ - **AI code analysis** โ€” Feed your codebase to ChatGPT, Claude, or other AI tools
231
+ - **Code reviews** โ€” Share a full project snapshot with reviewers
232
+ - **Onboarding** โ€” Help new developers get oriented quickly
233
+ - **Documentation** โ€” Generate a versioned snapshot of your codebase
234
+ - **CI/CD pipelines** โ€” Use non-interactive flags to automate context generation
235
+
236
+ ## Platform support
237
+
238
+ | Platform | Status |
239
+ | -------- | --------------- |
240
+ | macOS | โœ… Full support |
241
+ | Linux | โœ… Full support |
242
+ | Windows | โœ… Full support |
243
+
244
+ ## Troubleshooting
245
+
246
+ **Command not found after installation**
247
+
248
+ 1. Make sure the npm global bin directory is in your PATH
249
+ 2. Run `npm bin -g` to check where global packages are installed
234
250
  3. Restart your terminal
235
251
 
236
- ### Permission Errors (Unix)
252
+ **Permission errors on Unix**
237
253
 
238
254
  ```bash
239
255
  sudo npm install -g mkctx
@@ -241,33 +257,38 @@ sudo npm install -g mkctx
241
257
 
242
258
  Or fix npm permissions: https://docs.npmjs.com/resolving-eacces-permissions-errors
243
259
 
244
- ## ๐Ÿ“‹ Changelog
260
+ ## Changelog
261
+
262
+ ### v5.0.0
263
+
264
+ - โœจ Added non-interactive CLI flags (`--src`, `--format`, `--output`, `--name`, `--ignore`, etc.)
265
+ - ๐Ÿ”ค Added short aliases (`-s`, `-o`, `-f`, `-n`)
266
+ - ๐Ÿ”ง Support for `--key=value` syntax
267
+ - โ™ป๏ธ Internal refactor with clean code structure
245
268
 
246
269
  ### v4.0.0
247
270
 
248
- - โœ๏ธ Added interactive filename selection when saving (defaults to "context")
249
- - ๐ŸŽจ Improved UI/UX for file saving workflow
271
+ - โœ๏ธ Added interactive filename selection when saving (defaults to `context`)
272
+ - ๐ŸŽจ Improved UI/UX for the file saving workflow
250
273
 
251
274
  ### v3.0.0
252
275
 
253
276
  - ๐ŸŽฏ Simplified to focus on context generation
254
277
  - ๐Ÿ—‘๏ธ Removed Ollama chat integration
255
278
  - โšก Faster startup and smaller footprint
256
- - ๐Ÿงน Cleaner codebase
257
279
 
258
280
  ### v2.x
259
281
 
260
282
  - Ollama AI chat integration (removed in v3)
261
- - Interactive chat interface
262
283
 
263
284
  ### v1.x
264
285
 
265
286
  - Initial Go-based implementation
266
287
 
267
- ## ๐Ÿค Contributing
288
+ ## Contributing
268
289
 
269
- Contributions are welcome! Please feel free to submit pull requests or open issues.
290
+ Contributions are welcome! Feel free to open issues or submit pull requests.
270
291
 
271
- ## ๐Ÿ“„ License
292
+ ## License
272
293
 
273
- MIT License - see [LICENSE](LICENSE) file for details.
294
+ MIT License โ€” see [LICENSE](LICENSE) for details.