code-context-extractor 0.1.3 → 0.2.1
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 +31 -65
- package/dist/exporters/markdown.js +9 -4
- package/dist/exporters/skipSummary.js +21 -0
- package/dist/exporters/text.js +9 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,19 +12,25 @@ CodeContextExtractor is a local-only CLI that captures a deterministic snapshot
|
|
|
12
12
|
- Anyone who shares code with AI systems and wants safe defaults
|
|
13
13
|
|
|
14
14
|
## Quick start
|
|
15
|
+
1. Open a terminal at your project root (the folder you want to scan).
|
|
16
|
+
Example on Windows:
|
|
17
|
+
```bash
|
|
18
|
+
cd C:\projects\MyNewProject
|
|
19
|
+
```
|
|
20
|
+
2. Run the command (npx will install on first use if needed):
|
|
15
21
|
```bash
|
|
16
22
|
npx code-context-extractor extract . --verbose
|
|
17
23
|
```
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
3. Open the `code-context/` folder in your project (for example: `C:\projects\MyNewProject\code-context`).
|
|
25
|
+
4. Locate the newest file, named like:
|
|
20
26
|
```
|
|
21
27
|
code-context/<root>_context_YYYY-MM-DD_HHMMSS.txt
|
|
22
28
|
```
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
npx code-context-extractor extract C:\projects\MyNewProject --verbose
|
|
29
|
+
Example:
|
|
30
|
+
```
|
|
31
|
+
code-context/MyNewProject_context_2026-01-20_145743.txt
|
|
27
32
|
```
|
|
33
|
+
5. Paste that file into your AI tool when you want it to understand the codebase.
|
|
28
34
|
|
|
29
35
|
## Important: .gitignore your outputs
|
|
30
36
|
> **Warning ⚠️**
|
|
@@ -35,15 +41,7 @@ Add this line to your project's `.gitignore`:
|
|
|
35
41
|
code-context/
|
|
36
42
|
```
|
|
37
43
|
|
|
38
|
-
##
|
|
39
|
-
- `npm` is the package manager that installs tools and libraries.
|
|
40
|
-
- `npx` runs a tool. If it is not installed locally, it will try to download it.
|
|
41
|
-
- `npx` is great for one-off CLI runs without a global install.
|
|
42
|
-
|
|
43
|
-
## User journey (example)
|
|
44
|
-
You want to generate a context file for a project at `C:\projects\MyNewProject`.
|
|
45
|
-
|
|
46
|
-
### Step 1: Install CodeContextExtractor (one time)
|
|
44
|
+
## Install from GitHub (optional)
|
|
47
45
|
```bash
|
|
48
46
|
git clone https://github.com/Rwstrobe/CodeContextExtractor.git
|
|
49
47
|
cd CodeContextExtractor
|
|
@@ -52,59 +50,12 @@ npm run build
|
|
|
52
50
|
npm link
|
|
53
51
|
```
|
|
54
52
|
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
cd C:\projects\MyNewProject
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### Step 3: Generate the context file
|
|
61
|
-
```bash
|
|
62
|
-
code-context-extractor extract . --verbose
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
The output will be saved to:
|
|
66
|
-
```
|
|
67
|
-
.\code-context\MyNewProject_context_YYYY-MM-DD_HHMMSS.txt
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
### macOS/Linux variant
|
|
71
|
-
You can follow the same steps with a Unix-style path:
|
|
72
|
-
```bash
|
|
73
|
-
cd ~/projects/MyNewProject
|
|
74
|
-
code-context-extractor extract . --verbose
|
|
75
|
-
```
|
|
76
|
-
The output will be saved to:
|
|
77
|
-
```
|
|
78
|
-
./code-context/MyNewProject_context_YYYY-MM-DD_HHMMSS.txt
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
## Install from GitHub (beginner-friendly)
|
|
82
|
-
1. Clone the repository:
|
|
83
|
-
```bash
|
|
84
|
-
git clone https://github.com/Rwstrobe/CodeContextExtractor.git
|
|
85
|
-
```
|
|
86
|
-
2. Enter the project folder:
|
|
87
|
-
```bash
|
|
88
|
-
cd CodeContextExtractor
|
|
89
|
-
```
|
|
90
|
-
3. Install dependencies:
|
|
91
|
-
```bash
|
|
92
|
-
npm install
|
|
93
|
-
```
|
|
94
|
-
4. Build the CLI:
|
|
95
|
-
```bash
|
|
96
|
-
npm run build
|
|
97
|
-
```
|
|
98
|
-
5. Link the CLI so it is available on your PATH:
|
|
99
|
-
```bash
|
|
100
|
-
npm link
|
|
101
|
-
```
|
|
102
|
-
6. Run the extractor:
|
|
53
|
+
Run the linked CLI:
|
|
103
54
|
```bash
|
|
104
55
|
code-context-extractor extract . --verbose
|
|
105
56
|
```
|
|
106
57
|
|
|
107
|
-
|
|
58
|
+
Or run the built CLI directly:
|
|
108
59
|
```bash
|
|
109
60
|
node dist/cli.js extract . --verbose
|
|
110
61
|
```
|
|
@@ -152,7 +103,7 @@ Each output file contains:
|
|
|
152
103
|
- Metadata header (root path, timestamp, tool version, command, config summary)
|
|
153
104
|
- Folder tree (depth-limited)
|
|
154
105
|
- Included files summary (count and total size)
|
|
155
|
-
- Skipped files
|
|
106
|
+
- Skipped files summary (total, by reason, top roots)
|
|
156
107
|
- For each included file: path, size, last modified, and contents in fenced blocks
|
|
157
108
|
|
|
158
109
|
## Redaction
|
|
@@ -233,6 +184,21 @@ npm run build
|
|
|
233
184
|
npm test
|
|
234
185
|
```
|
|
235
186
|
|
|
187
|
+
## FAQ
|
|
188
|
+
**Does this upload my repo or call any APIs?**
|
|
189
|
+
No. It is local-only, with no network calls or telemetry.
|
|
190
|
+
|
|
191
|
+
**Why use npx?**
|
|
192
|
+
`npx` runs the CLI without a global install. It will download the package if needed.
|
|
193
|
+
|
|
194
|
+
**Why are `.git` and `node_modules` excluded?**
|
|
195
|
+
They add a lot of noise and size without improving architectural context.
|
|
196
|
+
|
|
197
|
+
**The output is huge. How do I reduce it?**
|
|
198
|
+
Use `--depth`, `--max-bytes`, and more `--exclude` globs, or add a config file.
|
|
199
|
+
|
|
236
200
|
## License
|
|
237
201
|
MIT
|
|
238
202
|
|
|
203
|
+
|
|
204
|
+
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.exportMarkdown = exportMarkdown;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const skipSummary_1 = require("./skipSummary");
|
|
8
9
|
const tree_1 = require("./tree");
|
|
9
10
|
const writer_1 = require("./writer");
|
|
10
11
|
function formatBytes(size) {
|
|
@@ -56,10 +57,14 @@ async function exportMarkdown(result, config, output, metadata) {
|
|
|
56
57
|
await (0, writer_1.writeText)(output, '- (none)\n\n');
|
|
57
58
|
}
|
|
58
59
|
else {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
const summary = (0, skipSummary_1.summarizeSkipped)(result.skipped);
|
|
61
|
+
const reasons = Object.entries(summary.byReason)
|
|
62
|
+
.map(([reason, count]) => `${reason} (${count})`)
|
|
63
|
+
.join(', ');
|
|
64
|
+
const roots = summary.topRoots.map((root) => `${root.name} (${root.count})`).join(', ');
|
|
65
|
+
await (0, writer_1.writeText)(output, `- Total: ${summary.total}\n`);
|
|
66
|
+
await (0, writer_1.writeText)(output, `- By reason: ${reasons}\n`);
|
|
67
|
+
await (0, writer_1.writeText)(output, `- Top skipped roots: ${roots}\n\n`);
|
|
63
68
|
}
|
|
64
69
|
await (0, writer_1.writeText)(output, '## Files\n\n');
|
|
65
70
|
for (const file of result.files) {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.summarizeSkipped = summarizeSkipped;
|
|
4
|
+
function getRootName(relativePath) {
|
|
5
|
+
const parts = relativePath.split('/');
|
|
6
|
+
return parts[0] || relativePath;
|
|
7
|
+
}
|
|
8
|
+
function summarizeSkipped(skipped, rootLimit = 10) {
|
|
9
|
+
const byReason = {};
|
|
10
|
+
const byRoot = {};
|
|
11
|
+
for (const entry of skipped) {
|
|
12
|
+
byReason[entry.reason] = (byReason[entry.reason] ?? 0) + 1;
|
|
13
|
+
const root = getRootName(entry.relativePath);
|
|
14
|
+
byRoot[root] = (byRoot[root] ?? 0) + 1;
|
|
15
|
+
}
|
|
16
|
+
const topRoots = Object.entries(byRoot)
|
|
17
|
+
.map(([name, count]) => ({ name, count }))
|
|
18
|
+
.sort((a, b) => b.count - a.count || a.name.localeCompare(b.name))
|
|
19
|
+
.slice(0, rootLimit);
|
|
20
|
+
return { total: skipped.length, byReason, topRoots };
|
|
21
|
+
}
|
package/dist/exporters/text.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.exportText = exportText;
|
|
4
|
+
const skipSummary_1 = require("./skipSummary");
|
|
4
5
|
const tree_1 = require("./tree");
|
|
5
6
|
const writer_1 = require("./writer");
|
|
6
7
|
function formatBytes(size) {
|
|
@@ -45,9 +46,14 @@ async function exportText(result, config, output, metadata) {
|
|
|
45
46
|
await (0, writer_1.writeText)(output, '(none)\n');
|
|
46
47
|
}
|
|
47
48
|
else {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
const summary = (0, skipSummary_1.summarizeSkipped)(result.skipped);
|
|
50
|
+
const reasons = Object.entries(summary.byReason)
|
|
51
|
+
.map(([reason, count]) => `${reason} (${count})`)
|
|
52
|
+
.join(', ');
|
|
53
|
+
const roots = summary.topRoots.map((root) => `${root.name} (${root.count})`).join(', ');
|
|
54
|
+
await (0, writer_1.writeText)(output, `Total: ${summary.total}\n`);
|
|
55
|
+
await (0, writer_1.writeText)(output, `By reason: ${reasons}\n`);
|
|
56
|
+
await (0, writer_1.writeText)(output, `Top skipped roots: ${roots}\n`);
|
|
51
57
|
}
|
|
52
58
|
await (0, writer_1.writeText)(output, '\nFiles\n');
|
|
53
59
|
for (const file of result.files) {
|
package/package.json
CHANGED