@craftpipe/contextpack 1.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.
- package/.contextpackrc.example.json +167 -0
- package/.env.example +5 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +26 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +15 -0
- package/.github/pull_request_template.md +9 -0
- package/CODE_OF_CONDUCT.md +40 -0
- package/CONTRIBUTING.md +59 -0
- package/LICENSE +21 -0
- package/README.md +100 -0
- package/SECURITY.md +21 -0
- package/index.js +428 -0
- package/lib/analyzer.js +547 -0
- package/lib/bundler.js +477 -0
- package/lib/config.js +269 -0
- package/lib/license.js +180 -0
- package/lib/premium/config-file.js +917 -0
- package/lib/premium/gate.js +13 -0
- package/lib/premium/html-report.js +1094 -0
- package/lib/premium/index.js +57 -0
- package/lib/premium/watch-mode.js +627 -0
- package/lib/scanner.js +480 -0
- package/lib/tokenizer.js +291 -0
- package/lib/validator.js +561 -0
- package/package.json +12 -0
- package/tests/analyzer.test.mjs +128 -0
- package/tests/bundler.test.mjs +126 -0
- package/tests/config.test.mjs +103 -0
- package/tests/gate.test.mjs +118 -0
- package/tests/index.test.mjs +103 -0
- package/tests/license.test.mjs +97 -0
- package/tests/scanner.test.mjs +110 -0
- package/tests/tokenizer.test.mjs +103 -0
- package/tests/validator.test.mjs +111 -0
- package/vitest.config.mjs +13 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "ContextPack configuration file. Copy this to .contextpackrc.json and customize as needed.",
|
|
3
|
+
|
|
4
|
+
"rootDir": ".",
|
|
5
|
+
|
|
6
|
+
"include": [
|
|
7
|
+
"**/*"
|
|
8
|
+
],
|
|
9
|
+
|
|
10
|
+
"exclude": [
|
|
11
|
+
"node_modules/**",
|
|
12
|
+
".git/**",
|
|
13
|
+
"dist/**",
|
|
14
|
+
"build/**",
|
|
15
|
+
"coverage/**",
|
|
16
|
+
".nyc_output/**",
|
|
17
|
+
"**/*.min.js",
|
|
18
|
+
"**/*.map",
|
|
19
|
+
"**/*.lock",
|
|
20
|
+
"**/*.log",
|
|
21
|
+
"tmp/**",
|
|
22
|
+
".cache/**"
|
|
23
|
+
],
|
|
24
|
+
|
|
25
|
+
"fileTypes": {
|
|
26
|
+
"extensions": [
|
|
27
|
+
".js",
|
|
28
|
+
".mjs",
|
|
29
|
+
".cjs",
|
|
30
|
+
".jsx",
|
|
31
|
+
".ts",
|
|
32
|
+
".tsx",
|
|
33
|
+
".json",
|
|
34
|
+
".md",
|
|
35
|
+
".py",
|
|
36
|
+
".rb",
|
|
37
|
+
".go",
|
|
38
|
+
".java",
|
|
39
|
+
".cs",
|
|
40
|
+
".php",
|
|
41
|
+
".swift",
|
|
42
|
+
".kt"
|
|
43
|
+
],
|
|
44
|
+
"excludeExtensions": [
|
|
45
|
+
".png",
|
|
46
|
+
".jpg",
|
|
47
|
+
".jpeg",
|
|
48
|
+
".gif",
|
|
49
|
+
".svg",
|
|
50
|
+
".ico",
|
|
51
|
+
".woff",
|
|
52
|
+
".woff2",
|
|
53
|
+
".ttf",
|
|
54
|
+
".eot",
|
|
55
|
+
".mp4",
|
|
56
|
+
".mp3",
|
|
57
|
+
".zip",
|
|
58
|
+
".tar",
|
|
59
|
+
".gz"
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
"output": "contextpack-output.json",
|
|
64
|
+
|
|
65
|
+
"format": "json",
|
|
66
|
+
|
|
67
|
+
"tokenLimit": 100000,
|
|
68
|
+
|
|
69
|
+
"maxFileSummaryLength": 500,
|
|
70
|
+
|
|
71
|
+
"includeDependencyMap": true,
|
|
72
|
+
|
|
73
|
+
"includeSymbolIndex": true,
|
|
74
|
+
|
|
75
|
+
"verbose": false,
|
|
76
|
+
|
|
77
|
+
"symbolExtraction": {
|
|
78
|
+
"enabled": true,
|
|
79
|
+
"extractFunctions": true,
|
|
80
|
+
"extractClasses": true,
|
|
81
|
+
"extractExports": true,
|
|
82
|
+
"extractImports": true,
|
|
83
|
+
"extractArrowFunctions": true,
|
|
84
|
+
"extractDefaultExports": true,
|
|
85
|
+
"languages": [
|
|
86
|
+
"javascript",
|
|
87
|
+
"typescript"
|
|
88
|
+
],
|
|
89
|
+
"minSymbolLength": 2,
|
|
90
|
+
"excludePrivate": false,
|
|
91
|
+
"excludePatterns": [
|
|
92
|
+
"^_",
|
|
93
|
+
"^test",
|
|
94
|
+
"^spec",
|
|
95
|
+
"^mock"
|
|
96
|
+
]
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
"directoryRules": [
|
|
100
|
+
{
|
|
101
|
+
"_comment": "Per-directory rules are a PRO feature. They are ignored in free tier.",
|
|
102
|
+
"directory": "src/",
|
|
103
|
+
"include": ["**/*.js", "**/*.ts"],
|
|
104
|
+
"exclude": ["**/*.test.js", "**/*.spec.js"],
|
|
105
|
+
"symbolExtraction": {
|
|
106
|
+
"extractFunctions": true,
|
|
107
|
+
"extractClasses": true
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"directory": "lib/",
|
|
112
|
+
"include": ["**/*.js"],
|
|
113
|
+
"exclude": [],
|
|
114
|
+
"symbolExtraction": {
|
|
115
|
+
"extractFunctions": true,
|
|
116
|
+
"extractClasses": true,
|
|
117
|
+
"extractExports": true
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"directory": "test/",
|
|
122
|
+
"include": [],
|
|
123
|
+
"exclude": ["**/*"],
|
|
124
|
+
"symbolExtraction": {
|
|
125
|
+
"enabled": false
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
],
|
|
129
|
+
|
|
130
|
+
"advancedExclusion": {
|
|
131
|
+
"_comment": "Advanced exclusion patterns are a PRO feature. They are ignored in free tier.",
|
|
132
|
+
"maxFileSizeBytes": 524288,
|
|
133
|
+
"excludeGeneratedFiles": true,
|
|
134
|
+
"generatedFilePatterns": [
|
|
135
|
+
"**/*.generated.*",
|
|
136
|
+
"**/*.auto.*",
|
|
137
|
+
"**/generated/**",
|
|
138
|
+
"**/auto-generated/**"
|
|
139
|
+
],
|
|
140
|
+
"excludeTestFiles": false,
|
|
141
|
+
"testFilePatterns": [
|
|
142
|
+
"**/*.test.*",
|
|
143
|
+
"**/*.spec.*",
|
|
144
|
+
"**/test/**",
|
|
145
|
+
"**/tests/**",
|
|
146
|
+
"**/__tests__/**"
|
|
147
|
+
]
|
|
148
|
+
},
|
|
149
|
+
|
|
150
|
+
"report": {
|
|
151
|
+
"_comment": "HTML report generation is a PRO feature. It is ignored in free tier.",
|
|
152
|
+
"enabled": false,
|
|
153
|
+
"outputFile": "contextpack-report.html",
|
|
154
|
+
"showExcludedFiles": true,
|
|
155
|
+
"showSymbolIndex": true,
|
|
156
|
+
"showTokenSavings": true,
|
|
157
|
+
"showDependencyGraph": true
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
"watchMode": {
|
|
161
|
+
"_comment": "Watch mode is a PRO feature. It is ignored in free tier.",
|
|
162
|
+
"enabled": false,
|
|
163
|
+
"debounceMs": 300,
|
|
164
|
+
"ignoreInitial": true,
|
|
165
|
+
"persistent": true
|
|
166
|
+
}
|
|
167
|
+
}
|
package/.env.example
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug Report
|
|
3
|
+
about: Report a bug to help us improve
|
|
4
|
+
title: "[Bug] "
|
|
5
|
+
labels: bug
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
**Describe the bug**
|
|
9
|
+
A clear description of what's wrong.
|
|
10
|
+
|
|
11
|
+
**To reproduce**
|
|
12
|
+
Steps to reproduce:
|
|
13
|
+
1. Run `...`
|
|
14
|
+
2. With input `...`
|
|
15
|
+
3. See error
|
|
16
|
+
|
|
17
|
+
**Expected behavior**
|
|
18
|
+
What should happen instead.
|
|
19
|
+
|
|
20
|
+
**Environment**
|
|
21
|
+
- OS: [e.g. Windows 11, macOS 14, Ubuntu 22]
|
|
22
|
+
- Node.js version: [e.g. 20.x]
|
|
23
|
+
- Product version: [e.g. 1.0.0]
|
|
24
|
+
|
|
25
|
+
**Additional context**
|
|
26
|
+
Error output, screenshots, etc.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature Request
|
|
3
|
+
about: Suggest a new feature
|
|
4
|
+
title: "[Feature] "
|
|
5
|
+
labels: enhancement
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
**Problem**
|
|
9
|
+
What problem does this solve?
|
|
10
|
+
|
|
11
|
+
**Proposed solution**
|
|
12
|
+
How should it work?
|
|
13
|
+
|
|
14
|
+
**Alternatives considered**
|
|
15
|
+
Other approaches you've thought about.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity
|
|
10
|
+
and orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to a positive environment:
|
|
15
|
+
|
|
16
|
+
* Using welcoming and inclusive language
|
|
17
|
+
* Being respectful of differing viewpoints and experiences
|
|
18
|
+
* Gracefully accepting constructive criticism
|
|
19
|
+
* Focusing on what is best for the community
|
|
20
|
+
* Showing empathy towards other community members
|
|
21
|
+
|
|
22
|
+
Examples of unacceptable behavior:
|
|
23
|
+
|
|
24
|
+
* The use of sexualized language or imagery and unwelcome sexual attention
|
|
25
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
26
|
+
* Public or private harassment
|
|
27
|
+
* Publishing others' private information without explicit permission
|
|
28
|
+
* Other conduct which could reasonably be considered inappropriate
|
|
29
|
+
|
|
30
|
+
## Enforcement
|
|
31
|
+
|
|
32
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
33
|
+
reported to the project team. All complaints will be reviewed and investigated
|
|
34
|
+
and will result in a response that is deemed necessary and appropriate to the
|
|
35
|
+
circumstances.
|
|
36
|
+
|
|
37
|
+
## Attribution
|
|
38
|
+
|
|
39
|
+
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org),
|
|
40
|
+
version 2.1, available at https://www.contributor-covenant.org/version/2/1/code_of_conduct.html.
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for your interest in contributing! Here's how to get started.
|
|
4
|
+
|
|
5
|
+
## Reporting Issues
|
|
6
|
+
|
|
7
|
+
- Use [GitHub Issues](../../issues) to report bugs or suggest features
|
|
8
|
+
- Include steps to reproduce for bugs
|
|
9
|
+
- Check existing issues before creating a new one
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
git clone <this-repo>
|
|
15
|
+
cd contextpack
|
|
16
|
+
npm install
|
|
17
|
+
npm test # run tests
|
|
18
|
+
node index.js --help
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Pull Requests
|
|
22
|
+
|
|
23
|
+
1. Fork the repository
|
|
24
|
+
2. Create a feature branch: `git checkout -b feat/my-feature`
|
|
25
|
+
3. Make your changes
|
|
26
|
+
4. Run tests (see below)
|
|
27
|
+
5. Commit with a clear message: `git commit -m "feat: add my feature"`
|
|
28
|
+
6. Push and open a Pull Request
|
|
29
|
+
|
|
30
|
+
## Code Style
|
|
31
|
+
|
|
32
|
+
- Plain JavaScript — no TypeScript, no build step
|
|
33
|
+
- `'use strict'` at the top of every file
|
|
34
|
+
- CommonJS modules (`require`/`module.exports`)
|
|
35
|
+
- Handle errors gracefully — no unhandled throws
|
|
36
|
+
- All exported functions must handle `null`/`undefined` arguments without crashing
|
|
37
|
+
- No hardcoded credentials or brand names in source files
|
|
38
|
+
|
|
39
|
+
## Testing
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm test # run vitest
|
|
43
|
+
npm run test:coverage # run with coverage report
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
- Tests live in `tests/`
|
|
47
|
+
- Test behavior, not implementation details
|
|
48
|
+
- Test edge cases: null, undefined, empty string, empty array
|
|
49
|
+
- All tests must pass before merging
|
|
50
|
+
|
|
51
|
+
## Architecture
|
|
52
|
+
|
|
53
|
+
- `index.js` — CLI entry point (argument parsing, command routing)
|
|
54
|
+
- `lib/*.js` — core modules (each with a single responsibility)
|
|
55
|
+
- `tests/` — vitest unit tests
|
|
56
|
+
|
|
57
|
+
## License
|
|
58
|
+
|
|
59
|
+
By contributing, you agree that your contributions will be licensed under the MIT License.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Craftpipe (Heijnes Digital)
|
|
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
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# ContextPack
|
|
2
|
+
|
|
3
|
+
A CLI tool that analyzes your codebase and generates token-optimized context bundles for AI coding sessions.
|
|
4
|
+
|
|
5
|
+
## What It Does
|
|
6
|
+
|
|
7
|
+
ContextPack scans your project, extracts symbols, dependencies, and file summaries, then bundles everything into a single structured context file. Feed it to your AI assistant once instead of re-explaining your codebase every session.
|
|
8
|
+
|
|
9
|
+
**Key Features:**
|
|
10
|
+
- Automatic codebase analysis and summarization
|
|
11
|
+
- Token-optimized output formats
|
|
12
|
+
- Smart filtering by file type or directory
|
|
13
|
+
- Multi-step pipeline: scan → summarize → bundle → validate
|
|
14
|
+
- Support for multiple output formats (JSON, Markdown, XML)
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install -g contextpack
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Or use directly:
|
|
23
|
+
```bash
|
|
24
|
+
npx contextpack
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
### Basic Usage
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
contextpack scan ./src
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Generates a context bundle from your `src` directory.
|
|
36
|
+
|
|
37
|
+
### With Options
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
contextpack scan ./src --output context.json --format json
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Filter by File Type
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
contextpack scan ./src --include "*.js,*.ts" --exclude "*.test.js"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Full Pipeline
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
contextpack analyze ./src --summarize --validate --output bundle.md
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Common Commands
|
|
56
|
+
|
|
57
|
+
| Command | Description |
|
|
58
|
+
|---------|-------------|
|
|
59
|
+
| `contextpack scan <path>` | Analyze directory structure |
|
|
60
|
+
| `contextpack summarize <path>` | Generate file summaries |
|
|
61
|
+
| `contextpack bundle <path>` | Create context bundle |
|
|
62
|
+
| `contextpack validate <file>` | Validate bundle integrity |
|
|
63
|
+
|
|
64
|
+
## Output Formats
|
|
65
|
+
|
|
66
|
+
- **JSON** — Structured data for programmatic use
|
|
67
|
+
- **Markdown** — Human-readable format
|
|
68
|
+
- **XML** — Integration with other tools
|
|
69
|
+
|
|
70
|
+
## FAQ
|
|
71
|
+
|
|
72
|
+
**Q: How much does it reduce token usage?**
|
|
73
|
+
A: Typically 40-60% reduction through smart summarization and deduplication.
|
|
74
|
+
|
|
75
|
+
**Q: Can I exclude node_modules and build files?**
|
|
76
|
+
A: Yes, use `--exclude "node_modules,dist,build"` or create a `.contextpackignore` file.
|
|
77
|
+
|
|
78
|
+
**Q: What file types are supported?**
|
|
79
|
+
A: All text-based files. Binary files are skipped automatically.
|
|
80
|
+
|
|
81
|
+
**Q: Can I use this in CI/CD?**
|
|
82
|
+
A: Yes, it's designed for automation. Use `--json` for machine-readable output.
|
|
83
|
+
|
|
84
|
+
**Q: How do I customize what gets included?**
|
|
85
|
+
A: Use `.contextpackignore` in your project root (similar to `.gitignore`).
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
Built with AI by Craftpipe
|
|
90
|
+
Support: support@heijnesdigital.com
|
|
91
|
+
## Pro Features
|
|
92
|
+
|
|
93
|
+
Upgrade to Pro for:
|
|
94
|
+
- html report
|
|
95
|
+
- watch mode
|
|
96
|
+
- config file
|
|
97
|
+
|
|
98
|
+
Get it at: https://craftpipe.gumroad.com
|
|
99
|
+
|
|
100
|
+
Set `PRO_LICENSE=<your-key>` to unlock.
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
| Version | Supported |
|
|
6
|
+
|---------|-----------|
|
|
7
|
+
| Latest | Yes |
|
|
8
|
+
|
|
9
|
+
## Reporting a Vulnerability
|
|
10
|
+
|
|
11
|
+
If you discover a security vulnerability, please report it responsibly:
|
|
12
|
+
|
|
13
|
+
1. **Do NOT** open a public GitHub issue
|
|
14
|
+
2. Email us at **security@heijnesdigital.com**
|
|
15
|
+
3. Include a description of the vulnerability and steps to reproduce
|
|
16
|
+
4. We will acknowledge receipt within 48 hours
|
|
17
|
+
5. We will provide a fix or mitigation within 7 days
|
|
18
|
+
|
|
19
|
+
## Scope
|
|
20
|
+
|
|
21
|
+
This policy applies to the latest version of this project. We take all security reports seriously.
|