Metadata-Version: 2.4
Name: chatenv
Version: 0.2.8
Summary: ChatArch typed environment profile manager
Author-email: rexwzh <1073853456@qq.com>
License-Expression: MIT
Project-URL: Homepage, https://arch.gh.wzhecnu.cn/ChatEnv/
Project-URL: Documentation, https://arch.gh.wzhecnu.cn/ChatEnv/
Project-URL: Repository, https://github.com/ChatArch/ChatEnv
Keywords: chatenv,chatarch,env
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: chatstyle<0.2.0,>=0.1.0
Requires-Dist: click<9.0,>=8.4.2
Requires-Dist: python-dotenv<2.0,>=1.2.2
Provides-Extra: dev
Requires-Dist: build>=1.0; extra == "dev"
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: twine>=5.0; extra == "dev"
Provides-Extra: docs
Requires-Dist: mkdocs<2.0,>=1.6; extra == "docs"
Requires-Dist: mkdocs-material<10.0,>=9.5; extra == "docs"
Requires-Dist: mkdocs-static-i18n<2.0,>=1.2; extra == "docs"
Requires-Dist: mkdocs-minify-plugin<1.0,>=0.8; extra == "docs"
Requires-Dist: mkdocs-redirects<2.0,>=1.2; extra == "docs"
Requires-Dist: mike<3.0,>=2.1; extra == "docs"
Dynamic: license-file

<div align="center">
    <a href="https://pypi.python.org/pypi/chatenv">
        <img src="https://img.shields.io/pypi/v/chatenv.svg" alt="PyPI version" />
    </a>
    <a href="https://github.com/ChatArch/ChatEnv/actions/workflows/ci.yml">
        <img src="https://github.com/ChatArch/ChatEnv/actions/workflows/ci.yml/badge.svg" alt="Tests" />
    </a>
    <a href="https://pypi.python.org/pypi/chatenv">
        <img src="https://img.shields.io/pypi/pyversions/chatenv.svg" alt="Python versions" />
    </a>
    <a href="LICENSE">
        <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License" />
    </a>
</div>

<div align="center">

# ChatEnv

ChatArch typed env/profile runtime.

</div>

ChatEnv 是 ChatArch / chatxxx 系列项目共用的 typed env/profile 底层包。它提供字段描述、配置基类、registry、路径、profile 文件读写、mask、paste 解析，以及 runtime token-store 的通用能力；具体业务变量、登录刷新和连通性语义由各项目自己定义并注册。

文档入口：https://arch.gh.wzhecnu.cn/ChatEnv/

## 安装

```bash
pip install chatenv --upgrade
chatenv --version
chatenv --tree
```

支持 Python `>=3.10`。

## 目录

```text
CHATARCH_HOME=${CHATARCH_HOME:-~/.chatarch}
$CHATARCH_HOME/envs/      # stable typed env/profile files
$CHATARCH_HOME/tokens/    # generated runtime tokens/sessions, parallel to env profiles
```

ChatEnv 只负责 stable env/profile 与 runtime token-store 的存储规则，不额外创建 config/cache/data/state，也不把 `tokens/` 当作第二个手工维护 secret/env 层。

## CLI 树

`chatenv --tree` 从当前安装包的 Click 注册表实时输出完整命令面：

```text
chatenv [--home <HOME>]  # Manage typed env profiles under $CHATARCH_HOME/envs.
├── --help  # Show this help message.
├── --version  # Show the installed package version.
├── --tree  # Print the registered command tree.
├── init [--type <CONFIG-TYPES>] [--interactive/--no-interactive]  # Create or update active typed env files.
├── new [NAME] [--type <CONFIG-TYPES>] [--yes] [--interactive/--no-interactive]  # Create a named typed profile without activating it.
├── paste [--value <VALUE>] [--stdin] [--profile <PROFILE>] [--yes] [--interactive/--no-interactive]  # Paste loose env text and import recognized keys.
├── use [NAME] [--type <CONFIG-TYPES>] [--interactive/--no-interactive]  # Activate a named profile for one config type.
├── list [--type <CONFIG-TYPES>]  # List active default and named profiles grouped by config type.
├── status [--type <CONFIG-TYPES>] [--detail]  # Show registered config platforms and provider ownership.
├── token  # Manage generic runtime token profiles.
│   ├── status <SERVICE> [PROFILE] [--format <OUTPUT-FORMAT>]  # Show safe runtime token metadata for SERVICE/PROFILE.
│   ├── refresh <SERVICE> [PROFILE] [--format <OUTPUT-FORMAT>]  # Refresh SERVICE/PROFILE through a registered service refresh provider.
│   ├── import <SERVICE> [PROFILE] [--stdin] [--file <VALUE-FILE>] [--token-type <TOKEN-TYPE>] [--summary <SUMMARY>] [--expires-at <EXPIRES-AT>] [--format <OUTPUT-FORMAT>]  # Explicitly import externally refreshed runtime token JSON.
│   ├── list [SERVICE] [--format <OUTPUT-FORMAT>]  # List runtime token profiles grouped by service.
│   └── clear <SERVICE> [PROFILE] [--execute] [--format <OUTPUT-FORMAT>]  # Clear a generic runtime token file for SERVICE/PROFILE.
├── cat [NAME] [--no-mask] [--type <CONFIG-TYPES>]  # Print active values, or a named typed profile with -t TYPE NAME.
├── get [KEY] [--interactive/--no-interactive]  # Get a configuration value from active typed env files.
├── set [KEY-VALUE] [--interactive/--no-interactive]  # Set a configuration value in the matching active typed env file.
├── save [NAME] [--type <CONFIG-TYPES>] [--yes] [--interactive/--no-interactive]  # Save current active values as a named profile.
├── delete [NAME] [--type <CONFIG-TYPES>] [--yes] [--interactive/--no-interactive]  # Delete a named profile for one config type.
└── test [--target <TARGET>] [--interactive/--no-interactive]  # Test a registered configuration schema.
```

## 常用命令

```bash
chatenv init -t example
chatenv status --detail
chatenv cat -t example
chatenv paste --stdin --profile work --yes
chatenv set EXAMPLE_API_KEY=sk-xxx
chatenv get EXAMPLE_API_KEY
chatenv token refresh PyPI RexWzh
chatenv token status PyPI RexWzh
```

敏感值默认 mask；`token status/list/clear` 只输出 safe metadata，不输出 raw token/cookie/CSRF values。

## Python API

```python
from chatenv import BaseEnvConfig, EnvField, EnvStore, get_paths

class ExampleConfig(BaseEnvConfig):
    _title = "Example Configuration"
    _aliases = ["example"]
    _storage_dir = "Example"

    EXAMPLE_API_KEY = EnvField("EXAMPLE_API_KEY", is_sensitive=True)

paths = get_paths()
store = EnvStore(paths.envs_dir)
store.save_active(ExampleConfig, {"EXAMPLE_API_KEY": "sk-..."})
```

## 文档

- https://arch.gh.wzhecnu.cn/ChatEnv/
- `docs/cli.md`：CLI 用法
- `docs/design.md`：路径、数据布局与注册策略
- `docs/developer-guide.md`：chatxxx 项目接入和 provider 开发指南
- `docs/development.md`：测试、构建与发布

## 开发

```bash
python -m pip install -e .[dev,docs]
python -m pytest -q
python -m mkdocs build --strict
python -m build
python -m twine check dist/*
```

## 开源协议

MIT License
