Metadata-Version: 2.4
Name: envpact
Version: 0.2.0
Summary: Centralized, serverless secrets manager for solo developers — Python module
Project-URL: Homepage, https://envpact.oriz.in
Project-URL: Repository, https://github.com/chirag127/envpact-python
Project-URL: Issues, https://github.com/chirag127/envpact-python/issues
Project-URL: Changelog, https://github.com/chirag127/envpact-python/blob/main/CHANGELOG.md
Author-email: Chirag Singhal <whyiswhen@gmail.com>
License: MIT License
        
        Copyright (c) 2026 Chirag Singhal
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: dotenv,env,environment-variables,envpact,secrets,secrets-manager
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Build Tools
Requires-Python: >=3.10
Provides-Extra: dev
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Description-Content-Type: text/markdown

# envpact (Python)

[![PyPI version](https://img.shields.io/pypi/v/envpact.svg)](https://pypi.org/project/envpact/)
[![Python](https://img.shields.io/pypi/pyversions/envpact.svg)](https://pypi.org/project/envpact/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![CI](https://github.com/chirag127/envpact-python/actions/workflows/ci.yml/badge.svg)](https://github.com/chirag127/envpact-python/actions/workflows/ci.yml)

Zero-dependency Python module for **envpact** — a centralized,
serverless, Git-backed secrets manager for solo developers.

> Read & write the same vault that envpact-cli, envpact-mcp, and
> envpact-vscode use. Identical semantics, native Python API.

Part of the [envpact](https://github.com/chirag127/envpact)
ecosystem.

## Installation

```bash
pip install envpact
```

Python 3.10+. No runtime dependencies — just stdlib.

## Quick Start

If you don't have a vault yet, bootstrap it once with the Node CLI:

```bash
npx envpact-cli --init auto
```

Then use Python directly:

```python
from envpact import EnvPact

pact = EnvPact()
pact.generate_env()                 # writes .env for the current project
pact.add_shared("OPENAI_API_KEY", "sk-…")
pact.rotate("OPENAI_API_KEY", "sk-new")
pact.sync_github(project_name="my-app")
```

## CLI

The package also ships a thin CLI mirroring `envpact-cli`:

```bash
python -m envpact          # generate .env
python -m envpact --list   # list projects
python -m envpact --rotate OPENAI_API_KEY
```

After installation, the `envpact` script is also on your `$PATH`.

## API

### `EnvPact(...)`

```python
EnvPact(
    *,
    vault_file: Path | str | None = None,
    secrets_dir: Path | str | None = None,
    project_name: str | None = None,
    environment: str | None = None,
    auto_pull: bool = True,
    auto_push: bool = True,
)
```

### Methods

| Method | Returns |
| :--- | :--- |
| `resolve(project_name=None, environment=None)` | `dict` with `resolved`, `unresolved`, `invalid`, `environment`, `missing` |
| `generate_env(...)` | `dict` with `output_path`, `resolved_count`, `missing` |
| `list_projects()` | `list[str]` |
| `list_shared()` | `list[str]` (names only) |
| `list_environments(project_name)` | `list[str]` |
| `add_secret(project, key, value, environment=None)` | push status |
| `add_shared(key, value)` | push status |
| `rotate(key, new_value)` | references + push status |
| `sync_github(...)` | sync stats |
| `pull()` / `push(message)` | git result |

### Resolver helpers

```python
from envpact import resolve_project, resolve_string, list_project_environments

# Pure functions over a parsed vault dict — useful for tests.
result = resolve_project(vault_dict, "my-app", "production")
```

## Vault Schema

Identical to envpact-cli — see
[SHARED_SPEC](https://github.com/chirag127/envpact/blob/main/_build/specs/SHARED_SPEC.md) §1.

## Security

- Vault values are read directly from the user's local clone at
  `~/.envpact/secrets/`. Nothing is ever sent to a third party.
- `list_shared()` returns names only.
- `.env` files are written with mode 0600 where the OS supports it.
- All vault commits are signed-off (`-s`).

## License

MIT © Chirag Singhal — see [LICENSE](./LICENSE).
