RepoPackPy 0.1.1__tar.gz
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.
- repopackpy-0.1.1/.github/workflows/ci.yml +30 -0
- repopackpy-0.1.1/.github/workflows/publish.yml +69 -0
- repopackpy-0.1.1/.github/workflows/security.yml +33 -0
- repopackpy-0.1.1/.gitignore +218 -0
- repopackpy-0.1.1/CLAUDE.md +123 -0
- repopackpy-0.1.1/LICENSE +21 -0
- repopackpy-0.1.1/PKG-INFO +126 -0
- repopackpy-0.1.1/README.md +112 -0
- repopackpy-0.1.1/pyproject.toml +28 -0
- repopackpy-0.1.1/repopack/__init__.py +1 -0
- repopackpy-0.1.1/repopack/cli.py +58 -0
- repopackpy-0.1.1/repopack/mcp_server.py +41 -0
- repopackpy-0.1.1/repopack/packer.py +96 -0
- repopackpy-0.1.1/repopack/unpacker.py +60 -0
- repopackpy-0.1.1/repopack/utils.py +183 -0
- repopackpy-0.1.1/system_prompt.txt +142 -0
- repopackpy-0.1.1/tests/test_repopack.py +250 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["main"]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: ["main"]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
name: Test (Python ${{ matrix.python-version }})
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
strategy:
|
|
14
|
+
fail-fast: false
|
|
15
|
+
matrix:
|
|
16
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- uses: actions/setup-python@v5
|
|
22
|
+
with:
|
|
23
|
+
python-version: ${{ matrix.python-version }}
|
|
24
|
+
cache: pip
|
|
25
|
+
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: pip install -e ".[dev]"
|
|
28
|
+
|
|
29
|
+
- name: Run tests
|
|
30
|
+
run: pytest tests/ -v --tb=short
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
verify-tag:
|
|
9
|
+
name: Verify tag matches release
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
|
|
14
|
+
- name: Check tag matches package version
|
|
15
|
+
run: |
|
|
16
|
+
# Extract version from pyproject.toml
|
|
17
|
+
PKG_VERSION=$(python - <<'EOF'
|
|
18
|
+
import tomllib, pathlib
|
|
19
|
+
data = tomllib.loads(pathlib.Path("pyproject.toml").read_text())
|
|
20
|
+
print(data["project"]["version"])
|
|
21
|
+
EOF
|
|
22
|
+
)
|
|
23
|
+
# GitHub release tag (strip leading 'v' if present)
|
|
24
|
+
TAG="${{ github.ref_name }}"
|
|
25
|
+
TAG_VERSION="${TAG#v}"
|
|
26
|
+
echo "Package version : $PKG_VERSION"
|
|
27
|
+
echo "Release tag : $TAG_VERSION"
|
|
28
|
+
if [ "$PKG_VERSION" != "$TAG_VERSION" ]; then
|
|
29
|
+
echo "::error::Tag $TAG does not match package version $PKG_VERSION"
|
|
30
|
+
exit 1
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
build:
|
|
34
|
+
name: Build distribution
|
|
35
|
+
needs: verify-tag
|
|
36
|
+
runs-on: ubuntu-latest
|
|
37
|
+
steps:
|
|
38
|
+
- uses: actions/checkout@v4
|
|
39
|
+
|
|
40
|
+
- uses: actions/setup-python@v5
|
|
41
|
+
with:
|
|
42
|
+
python-version: "3.12"
|
|
43
|
+
cache: pip
|
|
44
|
+
|
|
45
|
+
- name: Build wheel and sdist
|
|
46
|
+
run: |
|
|
47
|
+
pip install build
|
|
48
|
+
python -m build
|
|
49
|
+
|
|
50
|
+
- uses: actions/upload-artifact@v4
|
|
51
|
+
with:
|
|
52
|
+
name: dist
|
|
53
|
+
path: dist/
|
|
54
|
+
|
|
55
|
+
publish:
|
|
56
|
+
name: Publish to PyPI (Trusted Publisher)
|
|
57
|
+
needs: build
|
|
58
|
+
runs-on: ubuntu-latest
|
|
59
|
+
environment: pypi
|
|
60
|
+
permissions:
|
|
61
|
+
id-token: write # required for OIDC trusted publisher
|
|
62
|
+
|
|
63
|
+
steps:
|
|
64
|
+
- uses: actions/download-artifact@v4
|
|
65
|
+
with:
|
|
66
|
+
name: dist
|
|
67
|
+
path: dist/
|
|
68
|
+
|
|
69
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: Security Audit
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["main"]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: ["main"]
|
|
8
|
+
schedule:
|
|
9
|
+
- cron: "0 6 * * 1" # every Monday at 06:00 UTC
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
audit:
|
|
13
|
+
name: Dependency & SAST audit
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- uses: actions/setup-python@v5
|
|
20
|
+
with:
|
|
21
|
+
python-version: "3.12"
|
|
22
|
+
cache: pip
|
|
23
|
+
|
|
24
|
+
- name: Install project and audit tools
|
|
25
|
+
run: |
|
|
26
|
+
pip install -e ".[dev]"
|
|
27
|
+
pip install pip-audit bandit
|
|
28
|
+
|
|
29
|
+
- name: pip-audit (known CVEs)
|
|
30
|
+
run: pip-audit --strict
|
|
31
|
+
|
|
32
|
+
- name: bandit (SAST)
|
|
33
|
+
run: bandit -r repopack/ -ll -ii
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
# Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
# poetry.lock
|
|
109
|
+
# poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
# pdm.lock
|
|
116
|
+
# pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
# pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# Redis
|
|
135
|
+
*.rdb
|
|
136
|
+
*.aof
|
|
137
|
+
*.pid
|
|
138
|
+
|
|
139
|
+
# RabbitMQ
|
|
140
|
+
mnesia/
|
|
141
|
+
rabbitmq/
|
|
142
|
+
rabbitmq-data/
|
|
143
|
+
|
|
144
|
+
# ActiveMQ
|
|
145
|
+
activemq-data/
|
|
146
|
+
|
|
147
|
+
# SageMath parsed files
|
|
148
|
+
*.sage.py
|
|
149
|
+
|
|
150
|
+
# Environments
|
|
151
|
+
.env
|
|
152
|
+
.envrc
|
|
153
|
+
.venv
|
|
154
|
+
env/
|
|
155
|
+
venv/
|
|
156
|
+
ENV/
|
|
157
|
+
env.bak/
|
|
158
|
+
venv.bak/
|
|
159
|
+
|
|
160
|
+
# Spyder project settings
|
|
161
|
+
.spyderproject
|
|
162
|
+
.spyproject
|
|
163
|
+
|
|
164
|
+
# Rope project settings
|
|
165
|
+
.ropeproject
|
|
166
|
+
|
|
167
|
+
# mkdocs documentation
|
|
168
|
+
/site
|
|
169
|
+
|
|
170
|
+
# mypy
|
|
171
|
+
.mypy_cache/
|
|
172
|
+
.dmypy.json
|
|
173
|
+
dmypy.json
|
|
174
|
+
|
|
175
|
+
# Pyre type checker
|
|
176
|
+
.pyre/
|
|
177
|
+
|
|
178
|
+
# pytype static type analyzer
|
|
179
|
+
.pytype/
|
|
180
|
+
|
|
181
|
+
# Cython debug symbols
|
|
182
|
+
cython_debug/
|
|
183
|
+
|
|
184
|
+
# PyCharm
|
|
185
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
186
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
188
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
189
|
+
# .idea/
|
|
190
|
+
|
|
191
|
+
# Abstra
|
|
192
|
+
# Abstra is an AI-powered process automation framework.
|
|
193
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
194
|
+
# Learn more at https://abstra.io/docs
|
|
195
|
+
.abstra/
|
|
196
|
+
|
|
197
|
+
# Visual Studio Code
|
|
198
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
199
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
200
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
201
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
202
|
+
# .vscode/
|
|
203
|
+
# Temporary file for partial code execution
|
|
204
|
+
tempCodeRunnerFile.py
|
|
205
|
+
|
|
206
|
+
# Ruff stuff:
|
|
207
|
+
.ruff_cache/
|
|
208
|
+
|
|
209
|
+
# PyPI configuration file
|
|
210
|
+
.pypirc
|
|
211
|
+
|
|
212
|
+
# Marimo
|
|
213
|
+
marimo/_static/
|
|
214
|
+
marimo/_lsp/
|
|
215
|
+
__marimo__/
|
|
216
|
+
|
|
217
|
+
# Streamlit
|
|
218
|
+
.streamlit/secrets.toml
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# RepoPack — CLAUDE.md
|
|
2
|
+
|
|
3
|
+
## Project Purpose
|
|
4
|
+
|
|
5
|
+
RepoPack is a Python CLI application and MCP server that packs/unpacks any source workspace (regardless of tech stack) into a structured JSON payload. It supports Python, Node.js, React, Angular, Vue, Rust, Go, Java, C#, and more.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Architecture
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
repopack/
|
|
13
|
+
├── pyproject.toml
|
|
14
|
+
├── README.md
|
|
15
|
+
└── repopack/
|
|
16
|
+
├── __init__.py
|
|
17
|
+
├── cli.py # Typer CLI entry point
|
|
18
|
+
├── mcp_server.py # FastMCP server (stdio)
|
|
19
|
+
├── packer.py # Directory walker & JSON builder
|
|
20
|
+
├── unpacker.py # JSON extractor & path-safe reconstructor
|
|
21
|
+
└── utils.py # Gitignore engine, binary detector, path safety
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Technical Stack
|
|
27
|
+
|
|
28
|
+
| Concern | Library |
|
|
29
|
+
|---|---|
|
|
30
|
+
| Python version | 3.10+ |
|
|
31
|
+
| CLI | `typer` |
|
|
32
|
+
| MCP integration | `mcp` (FastMCP) |
|
|
33
|
+
| Ignore matching | `pathspec` (Git wildmatch) |
|
|
34
|
+
| Packaging | `hatchling` or `flit` via `pyproject.toml` |
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## CLI Commands
|
|
39
|
+
|
|
40
|
+
Executable name: `repopack`
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
repopack pack [DIRECTORY] [-o OUTPUT.json] [--include-binary] [--custom-ignore ".next,dist"]
|
|
44
|
+
repopack unpack <INPUT.json> [-t TARGET_DIR] [--force]
|
|
45
|
+
repopack serve # starts stdio-based MCP server
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## MCP Server Tools (FastMCP)
|
|
51
|
+
|
|
52
|
+
**`export_workspace(workspace_path, output_json_path, include_binary)`**
|
|
53
|
+
- Scans and packs a directory into JSON.
|
|
54
|
+
- If `output_json_path` is given, writes to disk and returns summary stats; otherwise returns the JSON string directly.
|
|
55
|
+
|
|
56
|
+
**`import_workspace(json_input, destination_path, overwrite)`**
|
|
57
|
+
- Accepts a JSON file path or raw JSON string.
|
|
58
|
+
- Reconstructs directory hierarchy at `destination_path`.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Output JSON Schema (version 1.0)
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"version": "1.0",
|
|
67
|
+
"metadata": {
|
|
68
|
+
"created_at": "<ISO8601>",
|
|
69
|
+
"root_directory_name": "my-app",
|
|
70
|
+
"detected_stack": ["Node.js", "React"],
|
|
71
|
+
"total_files": 38,
|
|
72
|
+
"total_bytes": 128450
|
|
73
|
+
},
|
|
74
|
+
"files": [
|
|
75
|
+
{ "path": "src/App.tsx", "encoding": "utf-8", "content": "..." },
|
|
76
|
+
{ "path": "public/favicon.ico", "encoding": "base64", "content": "..." }
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Ignore Engine (utils.py / packer.py)
|
|
84
|
+
|
|
85
|
+
Precedence order:
|
|
86
|
+
1. Root `.gitignore` + any nested `.gitignore` files (monorepo support).
|
|
87
|
+
2. Universal stack-agnostic defaults when no `.gitignore` exists:
|
|
88
|
+
- **VCS/Meta:** `.git/`, `.svn/`, `.hg/`, `.DS_Store`, `Thumbs.db`
|
|
89
|
+
- **JS/TS (Node, React, Angular, Vue, Next, Nuxt):** `node_modules/`, `dist/`, `build/`, `.next/`, `.nuxt/`, `.angular/`, `.cache/`, `coverage/`, `.astro/`, `.turbo/`, `out/`
|
|
90
|
+
- **Python:** `__pycache__/`, `*.pyc`, `.venv/`, `venv/`, `.pytest_cache/`, `.mypy_cache/`, `.eggs/`, `*.egg-info/`, `sdist/`
|
|
91
|
+
- **Rust/Go/Java/C#/C++:** `target/`, `bin/`, `obj/`, `*.exe`, `*.so`, `*.dylib`, `*.dll`, `*.class`, `*.jar`, `*.o`, `*.a`
|
|
92
|
+
- **Secrets:** `.env`, `.env.local`, `.env.*.local` (warn/skip)
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Encoding Rules
|
|
97
|
+
|
|
98
|
+
- Text files (`.js`, `.jsx`, `.ts`, `.tsx`, `.py`, `.json`, `.html`, `.css`, `.scss`, `.md`, `.yaml`, etc.) → UTF-8 string.
|
|
99
|
+
- Binary files (`.png`, `.ico`, `.woff2`, etc.) → skipped by default; Base64 when `--include-binary` is set.
|
|
100
|
+
- Files larger than **5 MB** are skipped unless forced.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Security Constraints (unpacker.py)
|
|
105
|
+
|
|
106
|
+
- Validate every path in incoming JSON against `os.path.commonpath` to block directory traversal (`../`, absolute paths, `/etc/passwd`-style injections).
|
|
107
|
+
- All output must be anchored under the specified target directory.
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Implementation Notes
|
|
112
|
+
|
|
113
|
+
- Use `pathspec` for `.gitignore` wildmatch; do not roll a custom glob engine.
|
|
114
|
+
- `packer.py` reads files in streaming fashion to handle large repos.
|
|
115
|
+
- `unpacker.py` must reject any path that escapes the destination root before touching the filesystem.
|
|
116
|
+
- Stack detection logic (for `detected_stack` metadata) lives in `utils.py`; infer from files present (e.g., `package.json` → Node.js, `requirements.txt` / `pyproject.toml` → Python, `Cargo.toml` → Rust, `go.mod` → Go, `*.csproj` → C#).
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Testing Requirements
|
|
121
|
+
|
|
122
|
+
- Unit tests must cover mock workspaces for: Node/React/Angular projects, Python virtual environments, Rust crates, monorepos with nested `.gitignore` files.
|
|
123
|
+
- Path traversal attack vectors must have explicit negative tests in `unpacker` tests.
|
repopackpy-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Shan Konduru
|
|
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.
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: RepoPackPy
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Pack/unpack any source workspace into portable JSON, with MCP server support.
|
|
5
|
+
License: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Requires-Dist: mcp[cli]>=1.0
|
|
9
|
+
Requires-Dist: pathspec>=0.12
|
|
10
|
+
Requires-Dist: typer>=0.12
|
|
11
|
+
Provides-Extra: dev
|
|
12
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# RepoPack
|
|
16
|
+
|
|
17
|
+
Pack/unpack **any source workspace regardless of technology stack** (Python, Node.js, React, Angular, Vue, Rust, Go, Java, C#, and more) into a portable, structured JSON payload — and restore it faithfully from that payload.
|
|
18
|
+
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
- **Universal ignore engine** — respects root and nested `.gitignore` files plus stack-agnostic defaults (node_modules, __pycache__, .venv, target/, dist/, secrets, lock files, …)
|
|
22
|
+
- **Polyglot stack detection** — auto-detects Node.js, React, TypeScript, Angular, Next.js, Vue, Python, Rust, Go, Java, C# from project sentinel files
|
|
23
|
+
- **Binary safety** — text files encoded as UTF-8; binaries skipped by default or included as Base64 with `--include-binary`
|
|
24
|
+
- **5 MB guard** — files larger than 5 MB are skipped with a warning
|
|
25
|
+
- **Path traversal shield** — `unpack` validates every path against the destination root before writing anything
|
|
26
|
+
- **MCP server** — expose pack/unpack as tools to any MCP-compatible AI client (Claude Desktop, etc.)
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install RepoPackPy
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
For development:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install -e ".[dev]"
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Requires Python 3.10+.
|
|
41
|
+
|
|
42
|
+
## CLI Usage
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Pack a directory into JSON
|
|
46
|
+
repopack pack [DIRECTORY] [-o output.json] [--include-binary] [--custom-ignore ".next,dist"]
|
|
47
|
+
|
|
48
|
+
# Unpack JSON back into a directory
|
|
49
|
+
repopack unpack <input.json> [-t TARGET_DIR] [--force]
|
|
50
|
+
|
|
51
|
+
# Start the MCP server (stdio transport)
|
|
52
|
+
repopack serve
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Examples
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Pack current directory, write to file
|
|
59
|
+
repopack pack . -o workspace.json
|
|
60
|
+
|
|
61
|
+
# Pack a specific project, include binaries
|
|
62
|
+
repopack pack ~/projects/my-app -o my-app.json --include-binary
|
|
63
|
+
|
|
64
|
+
# Unpack into a new directory
|
|
65
|
+
repopack unpack workspace.json -t ./restored
|
|
66
|
+
|
|
67
|
+
# Unpack and overwrite existing files
|
|
68
|
+
repopack unpack workspace.json -t ./restored --force
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## JSON Payload Schema
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"version": "1.0",
|
|
76
|
+
"metadata": {
|
|
77
|
+
"created_at": "2026-07-26T12:00:00Z",
|
|
78
|
+
"root_directory_name": "my-app",
|
|
79
|
+
"detected_stack": ["Node.js", "React", "TypeScript"],
|
|
80
|
+
"total_files": 38,
|
|
81
|
+
"total_bytes": 128450
|
|
82
|
+
},
|
|
83
|
+
"files": [
|
|
84
|
+
{ "path": "src/App.tsx", "encoding": "utf-8", "content": "..." },
|
|
85
|
+
{ "path": "public/favicon.ico", "encoding": "base64", "content": "..." }
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## MCP Server Tools
|
|
91
|
+
|
|
92
|
+
When running `repopack serve`, two tools are registered via FastMCP:
|
|
93
|
+
|
|
94
|
+
| Tool | Description |
|
|
95
|
+
|---|---|
|
|
96
|
+
| `export_workspace(workspace_path, output_json_path, include_binary)` | Pack a directory into JSON |
|
|
97
|
+
| `import_workspace(json_input, destination_path, overwrite)` | Unpack JSON into a directory |
|
|
98
|
+
|
|
99
|
+
## Project Structure
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
repopack/
|
|
103
|
+
├── pyproject.toml
|
|
104
|
+
├── README.md
|
|
105
|
+
└── repopack/
|
|
106
|
+
├── __init__.py
|
|
107
|
+
├── cli.py # Typer CLI (pack / unpack / serve)
|
|
108
|
+
├── mcp_server.py # FastMCP server
|
|
109
|
+
├── packer.py # Directory walker & JSON builder
|
|
110
|
+
├── unpacker.py # JSON extractor & path-safe reconstructor
|
|
111
|
+
└── utils.py # Ignore engine, binary detector, stack detection
|
|
112
|
+
tests/
|
|
113
|
+
└── test_repopack.py # 26-test pytest suite
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Running Tests
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
pytest tests/ -v
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Dependencies
|
|
123
|
+
|
|
124
|
+
- [typer](https://typer.tiangolo.com/) — CLI framework
|
|
125
|
+
- [mcp](https://github.com/modelcontextprotocol/python-sdk) — MCP SDK (FastMCP)
|
|
126
|
+
- [pathspec](https://github.com/cpburnz/python-pathspec) — gitignore wildmatch pattern matching
|