Metadata-Version: 2.4
Name: RepoPackPy
Version: 0.1.8
Summary: Pack/unpack any source workspace into portable JSON, with MCP server support.
License: MIT
License-File: LICENSE
Requires-Python: >=3.10
Requires-Dist: mcp[cli]>=1.0
Requires-Dist: pathspec>=0.12
Requires-Dist: typer>=0.12
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == 'dev'
Description-Content-Type: text/markdown

# RepoPack

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.

## Features

- **Universal ignore engine** — respects root and nested `.gitignore` files plus stack-agnostic defaults (node_modules, __pycache__, .venv, target/, dist/, secrets, lock files, …)
- **Polyglot stack detection** — auto-detects Node.js, React, TypeScript, Angular, Next.js, Vue, Python, Rust, Go, Java, C# from project sentinel files
- **Binary safety** — text files encoded as UTF-8; binaries skipped by default or included as Base64 with `--include-binary`
- **5 MB guard** — files larger than 5 MB are skipped with a warning
- **Path traversal shield** — `unpack` validates every path against the destination root before writing anything
- **MCP server** — expose pack/unpack as tools to any MCP-compatible AI client (Claude Desktop, etc.)

## Installation

### From PyPI (recommended)

Install the latest stable release:

```bash
pip install RepoPackPy
```

Pin to a specific version:

```bash
pip install RepoPackPy==0.1.1
```

Requires Python 3.10+.

### Quick start after install

```bash
# Verify the install
repopack --help

# Pack your project
repopack pack . -o my-workspace.json

# Restore it somewhere else
repopack unpack my-workspace.json -t ./restored
```

### For development

Clone the repo and install in editable mode with test dependencies:

```bash
git clone https://github.com/ShanKonduru/RepoPack.git
cd RepoPack
pip install -e ".[dev]"
```

## CLI Usage

```bash
# Pack a directory into JSON
repopack pack [DIRECTORY] [-o output.json] [--include-binary] [--custom-ignore ".next,dist"]

# Unpack JSON back into a directory
repopack unpack <input.json> [-t TARGET_DIR] [--force]

# Start the MCP server (stdio transport)
repopack serve
```

### Examples

```bash
# Pack current directory, write to file
repopack pack . -o workspace.json

# Pack a specific project, include binaries
repopack pack ~/projects/my-app -o my-app.json --include-binary

# Unpack into a new directory
repopack unpack workspace.json -t ./restored

# Unpack and overwrite existing files
repopack unpack workspace.json -t ./restored --force
```

## JSON Payload Schema

```json
{
  "version": "1.0",
  "metadata": {
    "created_at": "2026-07-26T12:00:00Z",
    "root_directory_name": "my-app",
    "detected_stack": ["Node.js", "React", "TypeScript"],
    "total_files": 38,
    "total_bytes": 128450
  },
  "files": [
    { "path": "src/App.tsx", "encoding": "utf-8", "content": "..." },
    { "path": "public/favicon.ico", "encoding": "base64", "content": "..." }
  ]
}
```

## MCP Server Tools

When running `repopack serve`, two tools are registered via FastMCP:

| Tool | Description |
|---|---|
| `export_workspace(workspace_path, output_json_path, include_binary)` | Pack a directory into JSON |
| `import_workspace(json_input, destination_path, overwrite)` | Unpack JSON into a directory |

## Project Structure

```
repopack/
├── pyproject.toml
├── README.md
└── repopack/
    ├── __init__.py
    ├── cli.py          # Typer CLI (pack / unpack / serve)
    ├── mcp_server.py   # FastMCP server
    ├── packer.py       # Directory walker & JSON builder
    ├── unpacker.py     # JSON extractor & path-safe reconstructor
    └── utils.py        # Ignore engine, binary detector, stack detection
tests/
└── test_repopack.py    # 26-test pytest suite
```

## Running Tests

```bash
pytest tests/ -v
```

## Dependencies

- [typer](https://typer.tiangolo.com/) — CLI framework
- [mcp](https://github.com/modelcontextprotocol/python-sdk) — MCP SDK (FastMCP)
- [pathspec](https://github.com/cpburnz/python-pathspec) — gitignore wildmatch pattern matching
