chatenv 0.2.7__tar.gz → 0.2.8__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.
- chatenv-0.2.8/PKG-INFO +160 -0
- chatenv-0.2.8/README.md +129 -0
- {chatenv-0.2.7 → chatenv-0.2.8}/pyproject.toml +4 -3
- {chatenv-0.2.7 → chatenv-0.2.8}/src/chatenv/__init__.py +1 -1
- chatenv-0.2.8/src/chatenv.egg-info/PKG-INFO +160 -0
- {chatenv-0.2.7 → chatenv-0.2.8}/src/chatenv.egg-info/SOURCES.txt +3 -1
- {chatenv-0.2.7 → chatenv-0.2.8}/src/chatenv.egg-info/requires.txt +2 -1
- chatenv-0.2.8/tests/test_docs_contract.py +66 -0
- {chatenv-0.2.7 → chatenv-0.2.8}/tests/test_version.py +1 -1
- chatenv-0.2.8/tests/test_workflow_contract.py +46 -0
- chatenv-0.2.7/PKG-INFO +0 -194
- chatenv-0.2.7/README.md +0 -164
- chatenv-0.2.7/src/chatenv.egg-info/PKG-INFO +0 -194
- {chatenv-0.2.7 → chatenv-0.2.8}/LICENSE +0 -0
- {chatenv-0.2.7 → chatenv-0.2.8}/setup.cfg +0 -0
- {chatenv-0.2.7 → chatenv-0.2.8}/src/chatenv/cli.py +0 -0
- {chatenv-0.2.7 → chatenv-0.2.8}/src/chatenv/configs.py +0 -0
- {chatenv-0.2.7 → chatenv-0.2.8}/src/chatenv/discovery.py +0 -0
- {chatenv-0.2.7 → chatenv-0.2.8}/src/chatenv/fields.py +0 -0
- {chatenv-0.2.7 → chatenv-0.2.8}/src/chatenv/paste.py +0 -0
- {chatenv-0.2.7 → chatenv-0.2.8}/src/chatenv/paths.py +0 -0
- {chatenv-0.2.7 → chatenv-0.2.8}/src/chatenv/presets/__init__.py +0 -0
- {chatenv-0.2.7 → chatenv-0.2.8}/src/chatenv/registry.py +0 -0
- {chatenv-0.2.7 → chatenv-0.2.8}/src/chatenv/source_chain.py +0 -0
- {chatenv-0.2.7 → chatenv-0.2.8}/src/chatenv/store.py +0 -0
- {chatenv-0.2.7 → chatenv-0.2.8}/src/chatenv/token_refreshers.py +0 -0
- {chatenv-0.2.7 → chatenv-0.2.8}/src/chatenv/tokens.py +0 -0
- {chatenv-0.2.7 → chatenv-0.2.8}/src/chatenv/utils.py +0 -0
- {chatenv-0.2.7 → chatenv-0.2.8}/src/chatenv.egg-info/dependency_links.txt +0 -0
- {chatenv-0.2.7 → chatenv-0.2.8}/src/chatenv.egg-info/entry_points.txt +0 -0
- {chatenv-0.2.7 → chatenv-0.2.8}/src/chatenv.egg-info/top_level.txt +0 -0
- {chatenv-0.2.7 → chatenv-0.2.8}/tests/test_chatenv_core.py +0 -0
chatenv-0.2.8/PKG-INFO
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: chatenv
|
|
3
|
+
Version: 0.2.8
|
|
4
|
+
Summary: ChatArch typed environment profile manager
|
|
5
|
+
Author-email: rexwzh <1073853456@qq.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://arch.gh.wzhecnu.cn/ChatEnv/
|
|
8
|
+
Project-URL: Documentation, https://arch.gh.wzhecnu.cn/ChatEnv/
|
|
9
|
+
Project-URL: Repository, https://github.com/ChatArch/ChatEnv
|
|
10
|
+
Keywords: chatenv,chatarch,env
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: chatstyle<0.2.0,>=0.1.0
|
|
17
|
+
Requires-Dist: click<9.0,>=8.4.2
|
|
18
|
+
Requires-Dist: python-dotenv<2.0,>=1.2.2
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: build>=1.0; extra == "dev"
|
|
21
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
22
|
+
Requires-Dist: twine>=5.0; extra == "dev"
|
|
23
|
+
Provides-Extra: docs
|
|
24
|
+
Requires-Dist: mkdocs<2.0,>=1.6; extra == "docs"
|
|
25
|
+
Requires-Dist: mkdocs-material<10.0,>=9.5; extra == "docs"
|
|
26
|
+
Requires-Dist: mkdocs-static-i18n<2.0,>=1.2; extra == "docs"
|
|
27
|
+
Requires-Dist: mkdocs-minify-plugin<1.0,>=0.8; extra == "docs"
|
|
28
|
+
Requires-Dist: mkdocs-redirects<2.0,>=1.2; extra == "docs"
|
|
29
|
+
Requires-Dist: mike<3.0,>=2.1; extra == "docs"
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
<div align="center">
|
|
33
|
+
<a href="https://pypi.python.org/pypi/chatenv">
|
|
34
|
+
<img src="https://img.shields.io/pypi/v/chatenv.svg" alt="PyPI version" />
|
|
35
|
+
</a>
|
|
36
|
+
<a href="https://github.com/ChatArch/ChatEnv/actions/workflows/ci.yml">
|
|
37
|
+
<img src="https://github.com/ChatArch/ChatEnv/actions/workflows/ci.yml/badge.svg" alt="Tests" />
|
|
38
|
+
</a>
|
|
39
|
+
<a href="https://pypi.python.org/pypi/chatenv">
|
|
40
|
+
<img src="https://img.shields.io/pypi/pyversions/chatenv.svg" alt="Python versions" />
|
|
41
|
+
</a>
|
|
42
|
+
<a href="LICENSE">
|
|
43
|
+
<img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License" />
|
|
44
|
+
</a>
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
<div align="center">
|
|
48
|
+
|
|
49
|
+
# ChatEnv
|
|
50
|
+
|
|
51
|
+
ChatArch typed env/profile runtime.
|
|
52
|
+
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
ChatEnv 是 ChatArch / chatxxx 系列项目共用的 typed env/profile 底层包。它提供字段描述、配置基类、registry、路径、profile 文件读写、mask、paste 解析,以及 runtime token-store 的通用能力;具体业务变量、登录刷新和连通性语义由各项目自己定义并注册。
|
|
56
|
+
|
|
57
|
+
文档入口:https://arch.gh.wzhecnu.cn/ChatEnv/
|
|
58
|
+
|
|
59
|
+
## 安装
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pip install chatenv --upgrade
|
|
63
|
+
chatenv --version
|
|
64
|
+
chatenv --tree
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
支持 Python `>=3.10`。
|
|
68
|
+
|
|
69
|
+
## 目录
|
|
70
|
+
|
|
71
|
+
```text
|
|
72
|
+
CHATARCH_HOME=${CHATARCH_HOME:-~/.chatarch}
|
|
73
|
+
$CHATARCH_HOME/envs/ # stable typed env/profile files
|
|
74
|
+
$CHATARCH_HOME/tokens/ # generated runtime tokens/sessions, parallel to env profiles
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
ChatEnv 只负责 stable env/profile 与 runtime token-store 的存储规则,不额外创建 config/cache/data/state,也不把 `tokens/` 当作第二个手工维护 secret/env 层。
|
|
78
|
+
|
|
79
|
+
## CLI 树
|
|
80
|
+
|
|
81
|
+
`chatenv --tree` 从当前安装包的 Click 注册表实时输出完整命令面:
|
|
82
|
+
|
|
83
|
+
```text
|
|
84
|
+
chatenv [--home <HOME>] # Manage typed env profiles under $CHATARCH_HOME/envs.
|
|
85
|
+
├── --help # Show this help message.
|
|
86
|
+
├── --version # Show the installed package version.
|
|
87
|
+
├── --tree # Print the registered command tree.
|
|
88
|
+
├── init [--type <CONFIG-TYPES>] [--interactive/--no-interactive] # Create or update active typed env files.
|
|
89
|
+
├── new [NAME] [--type <CONFIG-TYPES>] [--yes] [--interactive/--no-interactive] # Create a named typed profile without activating it.
|
|
90
|
+
├── paste [--value <VALUE>] [--stdin] [--profile <PROFILE>] [--yes] [--interactive/--no-interactive] # Paste loose env text and import recognized keys.
|
|
91
|
+
├── use [NAME] [--type <CONFIG-TYPES>] [--interactive/--no-interactive] # Activate a named profile for one config type.
|
|
92
|
+
├── list [--type <CONFIG-TYPES>] # List active default and named profiles grouped by config type.
|
|
93
|
+
├── status [--type <CONFIG-TYPES>] [--detail] # Show registered config platforms and provider ownership.
|
|
94
|
+
├── token # Manage generic runtime token profiles.
|
|
95
|
+
│ ├── status <SERVICE> [PROFILE] [--format <OUTPUT-FORMAT>] # Show safe runtime token metadata for SERVICE/PROFILE.
|
|
96
|
+
│ ├── refresh <SERVICE> [PROFILE] [--format <OUTPUT-FORMAT>] # Refresh SERVICE/PROFILE through a registered service refresh provider.
|
|
97
|
+
│ ├── 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.
|
|
98
|
+
│ ├── list [SERVICE] [--format <OUTPUT-FORMAT>] # List runtime token profiles grouped by service.
|
|
99
|
+
│ └── clear <SERVICE> [PROFILE] [--execute] [--format <OUTPUT-FORMAT>] # Clear a generic runtime token file for SERVICE/PROFILE.
|
|
100
|
+
├── cat [NAME] [--no-mask] [--type <CONFIG-TYPES>] # Print active values, or a named typed profile with -t TYPE NAME.
|
|
101
|
+
├── get [KEY] [--interactive/--no-interactive] # Get a configuration value from active typed env files.
|
|
102
|
+
├── set [KEY-VALUE] [--interactive/--no-interactive] # Set a configuration value in the matching active typed env file.
|
|
103
|
+
├── save [NAME] [--type <CONFIG-TYPES>] [--yes] [--interactive/--no-interactive] # Save current active values as a named profile.
|
|
104
|
+
├── delete [NAME] [--type <CONFIG-TYPES>] [--yes] [--interactive/--no-interactive] # Delete a named profile for one config type.
|
|
105
|
+
└── test [--target <TARGET>] [--interactive/--no-interactive] # Test a registered configuration schema.
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## 常用命令
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
chatenv init -t example
|
|
112
|
+
chatenv status --detail
|
|
113
|
+
chatenv cat -t example
|
|
114
|
+
chatenv paste --stdin --profile work --yes
|
|
115
|
+
chatenv set EXAMPLE_API_KEY=sk-xxx
|
|
116
|
+
chatenv get EXAMPLE_API_KEY
|
|
117
|
+
chatenv token refresh PyPI RexWzh
|
|
118
|
+
chatenv token status PyPI RexWzh
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
敏感值默认 mask;`token status/list/clear` 只输出 safe metadata,不输出 raw token/cookie/CSRF values。
|
|
122
|
+
|
|
123
|
+
## Python API
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
from chatenv import BaseEnvConfig, EnvField, EnvStore, get_paths
|
|
127
|
+
|
|
128
|
+
class ExampleConfig(BaseEnvConfig):
|
|
129
|
+
_title = "Example Configuration"
|
|
130
|
+
_aliases = ["example"]
|
|
131
|
+
_storage_dir = "Example"
|
|
132
|
+
|
|
133
|
+
EXAMPLE_API_KEY = EnvField("EXAMPLE_API_KEY", is_sensitive=True)
|
|
134
|
+
|
|
135
|
+
paths = get_paths()
|
|
136
|
+
store = EnvStore(paths.envs_dir)
|
|
137
|
+
store.save_active(ExampleConfig, {"EXAMPLE_API_KEY": "sk-..."})
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## 文档
|
|
141
|
+
|
|
142
|
+
- https://arch.gh.wzhecnu.cn/ChatEnv/
|
|
143
|
+
- `docs/cli.md`:CLI 用法
|
|
144
|
+
- `docs/design.md`:路径、数据布局与注册策略
|
|
145
|
+
- `docs/developer-guide.md`:chatxxx 项目接入和 provider 开发指南
|
|
146
|
+
- `docs/development.md`:测试、构建与发布
|
|
147
|
+
|
|
148
|
+
## 开发
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
python -m pip install -e .[dev,docs]
|
|
152
|
+
python -m pytest -q
|
|
153
|
+
python -m mkdocs build --strict
|
|
154
|
+
python -m build
|
|
155
|
+
python -m twine check dist/*
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## 开源协议
|
|
159
|
+
|
|
160
|
+
MIT License
|
chatenv-0.2.8/README.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://pypi.python.org/pypi/chatenv">
|
|
3
|
+
<img src="https://img.shields.io/pypi/v/chatenv.svg" alt="PyPI version" />
|
|
4
|
+
</a>
|
|
5
|
+
<a href="https://github.com/ChatArch/ChatEnv/actions/workflows/ci.yml">
|
|
6
|
+
<img src="https://github.com/ChatArch/ChatEnv/actions/workflows/ci.yml/badge.svg" alt="Tests" />
|
|
7
|
+
</a>
|
|
8
|
+
<a href="https://pypi.python.org/pypi/chatenv">
|
|
9
|
+
<img src="https://img.shields.io/pypi/pyversions/chatenv.svg" alt="Python versions" />
|
|
10
|
+
</a>
|
|
11
|
+
<a href="LICENSE">
|
|
12
|
+
<img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License" />
|
|
13
|
+
</a>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<div align="center">
|
|
17
|
+
|
|
18
|
+
# ChatEnv
|
|
19
|
+
|
|
20
|
+
ChatArch typed env/profile runtime.
|
|
21
|
+
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
ChatEnv 是 ChatArch / chatxxx 系列项目共用的 typed env/profile 底层包。它提供字段描述、配置基类、registry、路径、profile 文件读写、mask、paste 解析,以及 runtime token-store 的通用能力;具体业务变量、登录刷新和连通性语义由各项目自己定义并注册。
|
|
25
|
+
|
|
26
|
+
文档入口:https://arch.gh.wzhecnu.cn/ChatEnv/
|
|
27
|
+
|
|
28
|
+
## 安装
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install chatenv --upgrade
|
|
32
|
+
chatenv --version
|
|
33
|
+
chatenv --tree
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
支持 Python `>=3.10`。
|
|
37
|
+
|
|
38
|
+
## 目录
|
|
39
|
+
|
|
40
|
+
```text
|
|
41
|
+
CHATARCH_HOME=${CHATARCH_HOME:-~/.chatarch}
|
|
42
|
+
$CHATARCH_HOME/envs/ # stable typed env/profile files
|
|
43
|
+
$CHATARCH_HOME/tokens/ # generated runtime tokens/sessions, parallel to env profiles
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
ChatEnv 只负责 stable env/profile 与 runtime token-store 的存储规则,不额外创建 config/cache/data/state,也不把 `tokens/` 当作第二个手工维护 secret/env 层。
|
|
47
|
+
|
|
48
|
+
## CLI 树
|
|
49
|
+
|
|
50
|
+
`chatenv --tree` 从当前安装包的 Click 注册表实时输出完整命令面:
|
|
51
|
+
|
|
52
|
+
```text
|
|
53
|
+
chatenv [--home <HOME>] # Manage typed env profiles under $CHATARCH_HOME/envs.
|
|
54
|
+
├── --help # Show this help message.
|
|
55
|
+
├── --version # Show the installed package version.
|
|
56
|
+
├── --tree # Print the registered command tree.
|
|
57
|
+
├── init [--type <CONFIG-TYPES>] [--interactive/--no-interactive] # Create or update active typed env files.
|
|
58
|
+
├── new [NAME] [--type <CONFIG-TYPES>] [--yes] [--interactive/--no-interactive] # Create a named typed profile without activating it.
|
|
59
|
+
├── paste [--value <VALUE>] [--stdin] [--profile <PROFILE>] [--yes] [--interactive/--no-interactive] # Paste loose env text and import recognized keys.
|
|
60
|
+
├── use [NAME] [--type <CONFIG-TYPES>] [--interactive/--no-interactive] # Activate a named profile for one config type.
|
|
61
|
+
├── list [--type <CONFIG-TYPES>] # List active default and named profiles grouped by config type.
|
|
62
|
+
├── status [--type <CONFIG-TYPES>] [--detail] # Show registered config platforms and provider ownership.
|
|
63
|
+
├── token # Manage generic runtime token profiles.
|
|
64
|
+
│ ├── status <SERVICE> [PROFILE] [--format <OUTPUT-FORMAT>] # Show safe runtime token metadata for SERVICE/PROFILE.
|
|
65
|
+
│ ├── refresh <SERVICE> [PROFILE] [--format <OUTPUT-FORMAT>] # Refresh SERVICE/PROFILE through a registered service refresh provider.
|
|
66
|
+
│ ├── 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.
|
|
67
|
+
│ ├── list [SERVICE] [--format <OUTPUT-FORMAT>] # List runtime token profiles grouped by service.
|
|
68
|
+
│ └── clear <SERVICE> [PROFILE] [--execute] [--format <OUTPUT-FORMAT>] # Clear a generic runtime token file for SERVICE/PROFILE.
|
|
69
|
+
├── cat [NAME] [--no-mask] [--type <CONFIG-TYPES>] # Print active values, or a named typed profile with -t TYPE NAME.
|
|
70
|
+
├── get [KEY] [--interactive/--no-interactive] # Get a configuration value from active typed env files.
|
|
71
|
+
├── set [KEY-VALUE] [--interactive/--no-interactive] # Set a configuration value in the matching active typed env file.
|
|
72
|
+
├── save [NAME] [--type <CONFIG-TYPES>] [--yes] [--interactive/--no-interactive] # Save current active values as a named profile.
|
|
73
|
+
├── delete [NAME] [--type <CONFIG-TYPES>] [--yes] [--interactive/--no-interactive] # Delete a named profile for one config type.
|
|
74
|
+
└── test [--target <TARGET>] [--interactive/--no-interactive] # Test a registered configuration schema.
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## 常用命令
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
chatenv init -t example
|
|
81
|
+
chatenv status --detail
|
|
82
|
+
chatenv cat -t example
|
|
83
|
+
chatenv paste --stdin --profile work --yes
|
|
84
|
+
chatenv set EXAMPLE_API_KEY=sk-xxx
|
|
85
|
+
chatenv get EXAMPLE_API_KEY
|
|
86
|
+
chatenv token refresh PyPI RexWzh
|
|
87
|
+
chatenv token status PyPI RexWzh
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
敏感值默认 mask;`token status/list/clear` 只输出 safe metadata,不输出 raw token/cookie/CSRF values。
|
|
91
|
+
|
|
92
|
+
## Python API
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from chatenv import BaseEnvConfig, EnvField, EnvStore, get_paths
|
|
96
|
+
|
|
97
|
+
class ExampleConfig(BaseEnvConfig):
|
|
98
|
+
_title = "Example Configuration"
|
|
99
|
+
_aliases = ["example"]
|
|
100
|
+
_storage_dir = "Example"
|
|
101
|
+
|
|
102
|
+
EXAMPLE_API_KEY = EnvField("EXAMPLE_API_KEY", is_sensitive=True)
|
|
103
|
+
|
|
104
|
+
paths = get_paths()
|
|
105
|
+
store = EnvStore(paths.envs_dir)
|
|
106
|
+
store.save_active(ExampleConfig, {"EXAMPLE_API_KEY": "sk-..."})
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## 文档
|
|
110
|
+
|
|
111
|
+
- https://arch.gh.wzhecnu.cn/ChatEnv/
|
|
112
|
+
- `docs/cli.md`:CLI 用法
|
|
113
|
+
- `docs/design.md`:路径、数据布局与注册策略
|
|
114
|
+
- `docs/developer-guide.md`:chatxxx 项目接入和 provider 开发指南
|
|
115
|
+
- `docs/development.md`:测试、构建与发布
|
|
116
|
+
|
|
117
|
+
## 开发
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
python -m pip install -e .[dev,docs]
|
|
121
|
+
python -m pytest -q
|
|
122
|
+
python -m mkdocs build --strict
|
|
123
|
+
python -m build
|
|
124
|
+
python -m twine check dist/*
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## 开源协议
|
|
128
|
+
|
|
129
|
+
MIT License
|
|
@@ -22,9 +22,9 @@ classifiers = [
|
|
|
22
22
|
]
|
|
23
23
|
|
|
24
24
|
[project.urls]
|
|
25
|
-
Homepage = "https://
|
|
25
|
+
Homepage = "https://arch.gh.wzhecnu.cn/ChatEnv/"
|
|
26
|
+
Documentation = "https://arch.gh.wzhecnu.cn/ChatEnv/"
|
|
26
27
|
Repository = "https://github.com/ChatArch/ChatEnv"
|
|
27
|
-
Documentation = "https://chatarch.github.io/ChatEnv/"
|
|
28
28
|
|
|
29
29
|
[tool.setuptools.dynamic]
|
|
30
30
|
version = {attr = "chatenv.__version__"}
|
|
@@ -46,7 +46,8 @@ dev = [
|
|
|
46
46
|
]
|
|
47
47
|
docs = [
|
|
48
48
|
"mkdocs>=1.6,<2.0",
|
|
49
|
-
"mkdocs-material>=9.5,<
|
|
49
|
+
"mkdocs-material>=9.5,<10.0",
|
|
50
|
+
"mkdocs-static-i18n>=1.2,<2.0",
|
|
50
51
|
"mkdocs-minify-plugin>=0.8,<1.0",
|
|
51
52
|
"mkdocs-redirects>=1.2,<2.0",
|
|
52
53
|
"mike>=2.1,<3.0",
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: chatenv
|
|
3
|
+
Version: 0.2.8
|
|
4
|
+
Summary: ChatArch typed environment profile manager
|
|
5
|
+
Author-email: rexwzh <1073853456@qq.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://arch.gh.wzhecnu.cn/ChatEnv/
|
|
8
|
+
Project-URL: Documentation, https://arch.gh.wzhecnu.cn/ChatEnv/
|
|
9
|
+
Project-URL: Repository, https://github.com/ChatArch/ChatEnv
|
|
10
|
+
Keywords: chatenv,chatarch,env
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: chatstyle<0.2.0,>=0.1.0
|
|
17
|
+
Requires-Dist: click<9.0,>=8.4.2
|
|
18
|
+
Requires-Dist: python-dotenv<2.0,>=1.2.2
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: build>=1.0; extra == "dev"
|
|
21
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
22
|
+
Requires-Dist: twine>=5.0; extra == "dev"
|
|
23
|
+
Provides-Extra: docs
|
|
24
|
+
Requires-Dist: mkdocs<2.0,>=1.6; extra == "docs"
|
|
25
|
+
Requires-Dist: mkdocs-material<10.0,>=9.5; extra == "docs"
|
|
26
|
+
Requires-Dist: mkdocs-static-i18n<2.0,>=1.2; extra == "docs"
|
|
27
|
+
Requires-Dist: mkdocs-minify-plugin<1.0,>=0.8; extra == "docs"
|
|
28
|
+
Requires-Dist: mkdocs-redirects<2.0,>=1.2; extra == "docs"
|
|
29
|
+
Requires-Dist: mike<3.0,>=2.1; extra == "docs"
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
<div align="center">
|
|
33
|
+
<a href="https://pypi.python.org/pypi/chatenv">
|
|
34
|
+
<img src="https://img.shields.io/pypi/v/chatenv.svg" alt="PyPI version" />
|
|
35
|
+
</a>
|
|
36
|
+
<a href="https://github.com/ChatArch/ChatEnv/actions/workflows/ci.yml">
|
|
37
|
+
<img src="https://github.com/ChatArch/ChatEnv/actions/workflows/ci.yml/badge.svg" alt="Tests" />
|
|
38
|
+
</a>
|
|
39
|
+
<a href="https://pypi.python.org/pypi/chatenv">
|
|
40
|
+
<img src="https://img.shields.io/pypi/pyversions/chatenv.svg" alt="Python versions" />
|
|
41
|
+
</a>
|
|
42
|
+
<a href="LICENSE">
|
|
43
|
+
<img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License" />
|
|
44
|
+
</a>
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
<div align="center">
|
|
48
|
+
|
|
49
|
+
# ChatEnv
|
|
50
|
+
|
|
51
|
+
ChatArch typed env/profile runtime.
|
|
52
|
+
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
ChatEnv 是 ChatArch / chatxxx 系列项目共用的 typed env/profile 底层包。它提供字段描述、配置基类、registry、路径、profile 文件读写、mask、paste 解析,以及 runtime token-store 的通用能力;具体业务变量、登录刷新和连通性语义由各项目自己定义并注册。
|
|
56
|
+
|
|
57
|
+
文档入口:https://arch.gh.wzhecnu.cn/ChatEnv/
|
|
58
|
+
|
|
59
|
+
## 安装
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pip install chatenv --upgrade
|
|
63
|
+
chatenv --version
|
|
64
|
+
chatenv --tree
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
支持 Python `>=3.10`。
|
|
68
|
+
|
|
69
|
+
## 目录
|
|
70
|
+
|
|
71
|
+
```text
|
|
72
|
+
CHATARCH_HOME=${CHATARCH_HOME:-~/.chatarch}
|
|
73
|
+
$CHATARCH_HOME/envs/ # stable typed env/profile files
|
|
74
|
+
$CHATARCH_HOME/tokens/ # generated runtime tokens/sessions, parallel to env profiles
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
ChatEnv 只负责 stable env/profile 与 runtime token-store 的存储规则,不额外创建 config/cache/data/state,也不把 `tokens/` 当作第二个手工维护 secret/env 层。
|
|
78
|
+
|
|
79
|
+
## CLI 树
|
|
80
|
+
|
|
81
|
+
`chatenv --tree` 从当前安装包的 Click 注册表实时输出完整命令面:
|
|
82
|
+
|
|
83
|
+
```text
|
|
84
|
+
chatenv [--home <HOME>] # Manage typed env profiles under $CHATARCH_HOME/envs.
|
|
85
|
+
├── --help # Show this help message.
|
|
86
|
+
├── --version # Show the installed package version.
|
|
87
|
+
├── --tree # Print the registered command tree.
|
|
88
|
+
├── init [--type <CONFIG-TYPES>] [--interactive/--no-interactive] # Create or update active typed env files.
|
|
89
|
+
├── new [NAME] [--type <CONFIG-TYPES>] [--yes] [--interactive/--no-interactive] # Create a named typed profile without activating it.
|
|
90
|
+
├── paste [--value <VALUE>] [--stdin] [--profile <PROFILE>] [--yes] [--interactive/--no-interactive] # Paste loose env text and import recognized keys.
|
|
91
|
+
├── use [NAME] [--type <CONFIG-TYPES>] [--interactive/--no-interactive] # Activate a named profile for one config type.
|
|
92
|
+
├── list [--type <CONFIG-TYPES>] # List active default and named profiles grouped by config type.
|
|
93
|
+
├── status [--type <CONFIG-TYPES>] [--detail] # Show registered config platforms and provider ownership.
|
|
94
|
+
├── token # Manage generic runtime token profiles.
|
|
95
|
+
│ ├── status <SERVICE> [PROFILE] [--format <OUTPUT-FORMAT>] # Show safe runtime token metadata for SERVICE/PROFILE.
|
|
96
|
+
│ ├── refresh <SERVICE> [PROFILE] [--format <OUTPUT-FORMAT>] # Refresh SERVICE/PROFILE through a registered service refresh provider.
|
|
97
|
+
│ ├── 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.
|
|
98
|
+
│ ├── list [SERVICE] [--format <OUTPUT-FORMAT>] # List runtime token profiles grouped by service.
|
|
99
|
+
│ └── clear <SERVICE> [PROFILE] [--execute] [--format <OUTPUT-FORMAT>] # Clear a generic runtime token file for SERVICE/PROFILE.
|
|
100
|
+
├── cat [NAME] [--no-mask] [--type <CONFIG-TYPES>] # Print active values, or a named typed profile with -t TYPE NAME.
|
|
101
|
+
├── get [KEY] [--interactive/--no-interactive] # Get a configuration value from active typed env files.
|
|
102
|
+
├── set [KEY-VALUE] [--interactive/--no-interactive] # Set a configuration value in the matching active typed env file.
|
|
103
|
+
├── save [NAME] [--type <CONFIG-TYPES>] [--yes] [--interactive/--no-interactive] # Save current active values as a named profile.
|
|
104
|
+
├── delete [NAME] [--type <CONFIG-TYPES>] [--yes] [--interactive/--no-interactive] # Delete a named profile for one config type.
|
|
105
|
+
└── test [--target <TARGET>] [--interactive/--no-interactive] # Test a registered configuration schema.
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## 常用命令
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
chatenv init -t example
|
|
112
|
+
chatenv status --detail
|
|
113
|
+
chatenv cat -t example
|
|
114
|
+
chatenv paste --stdin --profile work --yes
|
|
115
|
+
chatenv set EXAMPLE_API_KEY=sk-xxx
|
|
116
|
+
chatenv get EXAMPLE_API_KEY
|
|
117
|
+
chatenv token refresh PyPI RexWzh
|
|
118
|
+
chatenv token status PyPI RexWzh
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
敏感值默认 mask;`token status/list/clear` 只输出 safe metadata,不输出 raw token/cookie/CSRF values。
|
|
122
|
+
|
|
123
|
+
## Python API
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
from chatenv import BaseEnvConfig, EnvField, EnvStore, get_paths
|
|
127
|
+
|
|
128
|
+
class ExampleConfig(BaseEnvConfig):
|
|
129
|
+
_title = "Example Configuration"
|
|
130
|
+
_aliases = ["example"]
|
|
131
|
+
_storage_dir = "Example"
|
|
132
|
+
|
|
133
|
+
EXAMPLE_API_KEY = EnvField("EXAMPLE_API_KEY", is_sensitive=True)
|
|
134
|
+
|
|
135
|
+
paths = get_paths()
|
|
136
|
+
store = EnvStore(paths.envs_dir)
|
|
137
|
+
store.save_active(ExampleConfig, {"EXAMPLE_API_KEY": "sk-..."})
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## 文档
|
|
141
|
+
|
|
142
|
+
- https://arch.gh.wzhecnu.cn/ChatEnv/
|
|
143
|
+
- `docs/cli.md`:CLI 用法
|
|
144
|
+
- `docs/design.md`:路径、数据布局与注册策略
|
|
145
|
+
- `docs/developer-guide.md`:chatxxx 项目接入和 provider 开发指南
|
|
146
|
+
- `docs/development.md`:测试、构建与发布
|
|
147
|
+
|
|
148
|
+
## 开发
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
python -m pip install -e .[dev,docs]
|
|
152
|
+
python -m pytest -q
|
|
153
|
+
python -m mkdocs build --strict
|
|
154
|
+
python -m build
|
|
155
|
+
python -m twine check dist/*
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## 开源协议
|
|
159
|
+
|
|
160
|
+
MIT License
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from chatenv.cli import cli, render_cli_tree
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
PUBLIC_DOCS = (
|
|
7
|
+
"README.md",
|
|
8
|
+
"README.en.md",
|
|
9
|
+
"docs/index.md",
|
|
10
|
+
"docs/index.en.md",
|
|
11
|
+
"docs/cli.md",
|
|
12
|
+
"docs/cli.en.md",
|
|
13
|
+
"docs/design.md",
|
|
14
|
+
"docs/design.en.md",
|
|
15
|
+
"docs/developer-guide.md",
|
|
16
|
+
"docs/developer-guide.en.md",
|
|
17
|
+
"docs/development.md",
|
|
18
|
+
"docs/development.en.md",
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def test_mkdocs_chatarch_i18n_material_contract() -> None:
|
|
23
|
+
mkdocs = Path("mkdocs.yml").read_text(encoding="utf-8")
|
|
24
|
+
pyproject = Path("pyproject.toml").read_text(encoding="utf-8")
|
|
25
|
+
|
|
26
|
+
assert "site_url: https://arch.gh.wzhecnu.cn/ChatEnv/" in mkdocs
|
|
27
|
+
assert 'Homepage = "https://arch.gh.wzhecnu.cn/ChatEnv/"' in pyproject
|
|
28
|
+
assert 'Documentation = "https://arch.gh.wzhecnu.cn/ChatEnv/"' in pyproject
|
|
29
|
+
assert 'Repository = "https://github.com/ChatArch/ChatEnv"' in pyproject
|
|
30
|
+
assert "mkdocs-material>=9.5,<10.0" in pyproject
|
|
31
|
+
assert "mkdocs-static-i18n>=1.2,<2.0" in pyproject
|
|
32
|
+
assert "name: material" in mkdocs
|
|
33
|
+
assert "pymdownx.emoji" in mkdocs
|
|
34
|
+
assert "material.extensions.emoji.twemoji" in mkdocs
|
|
35
|
+
assert "material.extensions.emoji.to_svg" in mkdocs
|
|
36
|
+
assert "i18n:" in mkdocs
|
|
37
|
+
assert "locale: en" in mkdocs
|
|
38
|
+
assert "/ChatEnv/en/" in mkdocs
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def test_public_docs_are_bilingual_and_use_chatarch_domain() -> None:
|
|
42
|
+
for rel in PUBLIC_DOCS:
|
|
43
|
+
path = Path(rel)
|
|
44
|
+
assert path.exists(), rel
|
|
45
|
+
text = path.read_text(encoding="utf-8")
|
|
46
|
+
assert "chatarch.github.io" not in text, rel
|
|
47
|
+
assert "github.io" not in text, rel
|
|
48
|
+
assert "template `hello`" not in text, rel
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def test_public_docs_keep_live_cli_tree_contract() -> None:
|
|
52
|
+
live_tree = render_cli_tree(cli)
|
|
53
|
+
required = [
|
|
54
|
+
"chatenv [--home <HOME>] # Manage typed env profiles",
|
|
55
|
+
"├── token # Manage generic runtime token profiles.",
|
|
56
|
+
"│ ├── refresh <SERVICE> [PROFILE]",
|
|
57
|
+
"│ ├── import <SERVICE> [PROFILE]",
|
|
58
|
+
"└── test [--target <TARGET>]",
|
|
59
|
+
]
|
|
60
|
+
for rel in ("README.md", "README.en.md", "docs/cli.md", "docs/cli.en.md"):
|
|
61
|
+
text = Path(rel).read_text(encoding="utf-8")
|
|
62
|
+
for line in required:
|
|
63
|
+
assert line in text, f"{rel} missing {line!r}"
|
|
64
|
+
for line in required:
|
|
65
|
+
assert line in live_tree
|
|
66
|
+
assert "hello" not in live_tree.lower()
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def test_ci_workflow_runs_matrix_and_installed_cli_smoke() -> None:
|
|
5
|
+
workflow = Path(".github/workflows/ci.yml").read_text(encoding="utf-8")
|
|
6
|
+
|
|
7
|
+
assert "python-version: [\"3.10\", \"3.11\", \"3.12\"]" in workflow
|
|
8
|
+
assert "python -m pytest -q" in workflow
|
|
9
|
+
assert "chatenv --version" in workflow
|
|
10
|
+
assert "chatenv --tree" in workflow
|
|
11
|
+
assert "python -m build" in workflow
|
|
12
|
+
assert "python -m twine check dist/*" in workflow
|
|
13
|
+
assert "mkdocs build --strict" in workflow
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def test_publish_workflow_uses_oidc_with_main_release_guard() -> None:
|
|
17
|
+
workflow = Path(".github/workflows/publish.yml").read_text(encoding="utf-8")
|
|
18
|
+
|
|
19
|
+
assert "id-token: write" in workflow
|
|
20
|
+
assert "pypa/gh-action-pypi-publish@release/v1" in workflow
|
|
21
|
+
assert "Publish to PyPI (OIDC)" in workflow
|
|
22
|
+
assert "workflow_dispatch" in workflow
|
|
23
|
+
assert "Check release commit is on default branch" in workflow
|
|
24
|
+
assert "git fetch --no-tags origin main:refs/remotes/origin/main" in workflow
|
|
25
|
+
assert 'git merge-base --is-ancestor "${GITHUB_SHA}" "origin/main"' in workflow
|
|
26
|
+
assert "git fetch origin main --tags" not in workflow
|
|
27
|
+
assert "git fetch origin master --tags" not in workflow
|
|
28
|
+
assert "environment: pypi" not in workflow
|
|
29
|
+
assert "TWINE_PASSWORD" not in workflow
|
|
30
|
+
assert "PYPI_API_TOKEN" not in workflow
|
|
31
|
+
assert "secrets.PYPI" not in workflow
|
|
32
|
+
assert "https://pypi.org/pypi/chatenv/" in workflow
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_docs_workflows_target_chatarch_pages() -> None:
|
|
36
|
+
preview = Path(".github/workflows/preview.yaml").read_text(encoding="utf-8")
|
|
37
|
+
deploy = Path(".github/workflows/deploy.yaml").read_text(encoding="utf-8")
|
|
38
|
+
|
|
39
|
+
assert "Preview Docs" in preview
|
|
40
|
+
assert "CHATARCH_PREVIEW_URL" in preview
|
|
41
|
+
assert "mike deploy dev" in preview
|
|
42
|
+
assert "https://arch.gh.wzhecnu.cn/${{ github.event.repository.name }}/dev/" in preview
|
|
43
|
+
assert "Deploy Docs" in deploy
|
|
44
|
+
assert "mkdocs gh-deploy --force" in deploy
|
|
45
|
+
assert "github.io" not in preview
|
|
46
|
+
assert "github.io" not in deploy
|
chatenv-0.2.7/PKG-INFO
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: chatenv
|
|
3
|
-
Version: 0.2.7
|
|
4
|
-
Summary: ChatArch typed environment profile manager
|
|
5
|
-
Author-email: rexwzh <1073853456@qq.com>
|
|
6
|
-
License-Expression: MIT
|
|
7
|
-
Project-URL: Homepage, https://github.com/ChatArch/ChatEnv
|
|
8
|
-
Project-URL: Repository, https://github.com/ChatArch/ChatEnv
|
|
9
|
-
Project-URL: Documentation, https://chatarch.github.io/ChatEnv/
|
|
10
|
-
Keywords: chatenv,chatarch,env
|
|
11
|
-
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Classifier: Operating System :: OS Independent
|
|
13
|
-
Requires-Python: >=3.10
|
|
14
|
-
Description-Content-Type: text/markdown
|
|
15
|
-
License-File: LICENSE
|
|
16
|
-
Requires-Dist: chatstyle<0.2.0,>=0.1.0
|
|
17
|
-
Requires-Dist: click<9.0,>=8.4.2
|
|
18
|
-
Requires-Dist: python-dotenv<2.0,>=1.2.2
|
|
19
|
-
Provides-Extra: dev
|
|
20
|
-
Requires-Dist: build>=1.0; extra == "dev"
|
|
21
|
-
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
22
|
-
Requires-Dist: twine>=5.0; extra == "dev"
|
|
23
|
-
Provides-Extra: docs
|
|
24
|
-
Requires-Dist: mkdocs<2.0,>=1.6; extra == "docs"
|
|
25
|
-
Requires-Dist: mkdocs-material<9.7,>=9.5; extra == "docs"
|
|
26
|
-
Requires-Dist: mkdocs-minify-plugin<1.0,>=0.8; extra == "docs"
|
|
27
|
-
Requires-Dist: mkdocs-redirects<2.0,>=1.2; extra == "docs"
|
|
28
|
-
Requires-Dist: mike<3.0,>=2.1; extra == "docs"
|
|
29
|
-
Dynamic: license-file
|
|
30
|
-
|
|
31
|
-
<div align="center">
|
|
32
|
-
<a href="https://pypi.python.org/pypi/chatenv">
|
|
33
|
-
<img src="https://img.shields.io/pypi/v/chatenv.svg" alt="PyPI version" />
|
|
34
|
-
</a>
|
|
35
|
-
<a href="https://github.com/ChatArch/ChatEnv/actions/workflows/ci.yml">
|
|
36
|
-
<img src="https://github.com/ChatArch/ChatEnv/actions/workflows/ci.yml/badge.svg" alt="Tests" />
|
|
37
|
-
</a>
|
|
38
|
-
<a href="https://pypi.python.org/pypi/chatenv">
|
|
39
|
-
<img src="https://img.shields.io/pypi/pyversions/chatenv.svg" alt="Python versions" />
|
|
40
|
-
</a>
|
|
41
|
-
<a href="LICENSE">
|
|
42
|
-
<img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License" />
|
|
43
|
-
</a>
|
|
44
|
-
</div>
|
|
45
|
-
|
|
46
|
-
<div align="center">
|
|
47
|
-
|
|
48
|
-
# ChatEnv
|
|
49
|
-
|
|
50
|
-
ChatArch typed env/profile runtime.
|
|
51
|
-
|
|
52
|
-
</div>
|
|
53
|
-
|
|
54
|
-
ChatEnv 是 ChatArch / chatxxx 系列项目共用的 typed env/profile 底层包。它提供字段描述、配置基类、registry、路径、profile 文件读写、mask 和 paste 解析等通用能力;同时内置少量跨工具共享 schema(当前为 OpenAI / Feishu)。工具私有变量仍由 ChatTool、ChatDNS 等项目自己定义并注册。
|
|
55
|
-
|
|
56
|
-
当前设计保持减法:只使用一个根变量 `CHATARCH_HOME`,只管理 env/profile 文件,不额外创建 config/cache/data/state。
|
|
57
|
-
|
|
58
|
-
支持 Python `>=3.10`。
|
|
59
|
-
|
|
60
|
-
## 安装
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
pip install chatenv --upgrade
|
|
64
|
-
pip install -e .[dev] # 仓库开发
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
## 目录
|
|
68
|
-
|
|
69
|
-
```text
|
|
70
|
-
CHATARCH_HOME=${CHATARCH_HOME:-~/.chatarch}
|
|
71
|
-
$CHATARCH_HOME/envs/ # stable typed env/profile files
|
|
72
|
-
$CHATARCH_HOME/tokens/ # generated runtime tokens/sessions, parallel to env profiles
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
实际布局由业务项目注册的 schema 决定,例如:
|
|
76
|
-
|
|
77
|
-
```text
|
|
78
|
-
~/.chatarch/envs/
|
|
79
|
-
Example/
|
|
80
|
-
.env
|
|
81
|
-
work.env
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
- `.env` 是当前 active profile;
|
|
85
|
-
- `name.env` 是 named profile;
|
|
86
|
-
- `use` 会把 named profile 复制为 active `.env`。
|
|
87
|
-
|
|
88
|
-
## CLI 概览
|
|
89
|
-
|
|
90
|
-
`chatenv` CLI 基于已注册 schema 工作。单独安装且没有项目注册 schema 时,它会提示需要先注册配置类型。业务项目通常会在自己的 CLI 中导入 schema 后复用这些能力。
|
|
91
|
-
|
|
92
|
-
```bash
|
|
93
|
-
chatenv --version
|
|
94
|
-
chatenv --tree
|
|
95
|
-
chatenv init -t example
|
|
96
|
-
chatenv status
|
|
97
|
-
chatenv status --detail
|
|
98
|
-
chatenv cat -t example
|
|
99
|
-
chatenv cat -t example --no-mask | chatenv paste --stdin --profile work --yes
|
|
100
|
-
chatenv set EXAMPLE_API_KEY=sk-xxx
|
|
101
|
-
chatenv get EXAMPLE_API_KEY
|
|
102
|
-
chatenv new -t example work
|
|
103
|
-
chatenv save -t example work
|
|
104
|
-
chatenv use -t example work
|
|
105
|
-
chatenv delete -t example work
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
单次命令可通过 `--home` 覆盖根目录:
|
|
109
|
-
|
|
110
|
-
```bash
|
|
111
|
-
chatenv --home /tmp/chatarch cat -t example
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
缺少必要命令参数时,ChatEnv 默认会在可交互终端中自动补问;显式 `-i` 始终强制补问,`-I` 始终禁用补问。自动化环境可设置:
|
|
115
|
-
|
|
116
|
-
```bash
|
|
117
|
-
export CHATARCH_AUTO_PROMPT=false
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
此时只有缺少必要参数的命令会直接报错;参数已经足够的命令行为不变。
|
|
121
|
-
|
|
122
|
-
`chatenv --tree` 可从当前安装包的 Click 注册表实时输出完整命令树,用于验收和脚本 readback。
|
|
123
|
-
|
|
124
|
-
更多用法见 `docs/cli.md`。
|
|
125
|
-
|
|
126
|
-
## Runtime tokens
|
|
127
|
-
|
|
128
|
-
ChatEnv 区分 stable env/profile 和动态 runtime token:
|
|
129
|
-
|
|
130
|
-
- `envs/<Service>/<profile>.env` 保存可长期维护的稳定配置,例如 base URL、账号、API key 或 refresh/login 所需输入;
|
|
131
|
-
- `tokens/<Service>/<profile>.json` 保存由登录或刷新流程生成的 access token、session、cookie/CSRF 等运行态;
|
|
132
|
-
- `chatenv token refresh SERVICE PROFILE` 会调用服务包通过 `chatenv.token_refreshers` 注册的刷新器,自动生成并更新 token-store;
|
|
133
|
-
- 手工 JSON 写入只保留为显式 `chatenv token import ... --stdin/--file`,用于迁移、调试或外部刷新器交接,不应作为日常维护入口。
|
|
134
|
-
|
|
135
|
-
ChatEnv 只负责路径、profile 校验、原子写入和 safe status/list/clear;具体登录、OAuth refresh、cookie 刷新等业务语义仍由 leaf package 负责。
|
|
136
|
-
|
|
137
|
-
## Paste
|
|
138
|
-
|
|
139
|
-
`paste` 是跨设备复制密钥的核心入口。输入不要求是严格 dotenv 文件,会从终端日志、shell prompt、复制文本里提取已注册 key;同一行里用空格分隔的多个 `KEY='VALUE'` 片段也会被逐个识别。
|
|
140
|
-
|
|
141
|
-
```bash
|
|
142
|
-
chatenv paste
|
|
143
|
-
chatenv paste --stdin --profile work
|
|
144
|
-
chatenv paste --value "EXAMPLE_API_KEY='sk-xxx'" --yes
|
|
145
|
-
chatenv paste --value "EXAMPLE_MODEL='gpt example' EXAMPLE_API_KEY='sk-xxx'" --yes
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
写入前会输出识别概要:识别到哪些类型、哪些 key、未知 key 被忽略。
|
|
149
|
-
|
|
150
|
-
## Python API
|
|
151
|
-
|
|
152
|
-
```python
|
|
153
|
-
from chatenv import BaseEnvConfig, EnvField, EnvStore, get_paths
|
|
154
|
-
|
|
155
|
-
class ExampleConfig(BaseEnvConfig):
|
|
156
|
-
_title = "Example Configuration"
|
|
157
|
-
_aliases = ["example"]
|
|
158
|
-
_storage_dir = "Example"
|
|
159
|
-
|
|
160
|
-
EXAMPLE_API_KEY = EnvField("EXAMPLE_API_KEY", is_sensitive=True)
|
|
161
|
-
|
|
162
|
-
paths = get_paths()
|
|
163
|
-
store = EnvStore(paths.envs_dir)
|
|
164
|
-
store.save_active(ExampleConfig, {"EXAMPLE_API_KEY": "sk-..."})
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
## 文档
|
|
168
|
-
|
|
169
|
-
- `docs/cli.md`:CLI 用法
|
|
170
|
-
- `docs/design.md`:路径、数据布局与注册策略
|
|
171
|
-
- `docs/developer-guide.md`:chatxxx 项目接入和 provider 开发指南
|
|
172
|
-
- `docs/development.md`:测试、构建与发布
|
|
173
|
-
- `mkdocs.yml`:Material for MkDocs 文档站点配置
|
|
174
|
-
|
|
175
|
-
## 开发
|
|
176
|
-
|
|
177
|
-
```bash
|
|
178
|
-
python -m pytest -q
|
|
179
|
-
python -m build
|
|
180
|
-
python -m twine check dist/*
|
|
181
|
-
python -m pip install -e .[docs]
|
|
182
|
-
python -m mkdocs serve
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
也可以用 ChatTool helper:
|
|
186
|
-
|
|
187
|
-
```bash
|
|
188
|
-
chattool pypi build --project-dir .
|
|
189
|
-
chattool pypi check --project-dir .
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
## 开源协议
|
|
193
|
-
|
|
194
|
-
MIT License
|
chatenv-0.2.7/README.md
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
<a href="https://pypi.python.org/pypi/chatenv">
|
|
3
|
-
<img src="https://img.shields.io/pypi/v/chatenv.svg" alt="PyPI version" />
|
|
4
|
-
</a>
|
|
5
|
-
<a href="https://github.com/ChatArch/ChatEnv/actions/workflows/ci.yml">
|
|
6
|
-
<img src="https://github.com/ChatArch/ChatEnv/actions/workflows/ci.yml/badge.svg" alt="Tests" />
|
|
7
|
-
</a>
|
|
8
|
-
<a href="https://pypi.python.org/pypi/chatenv">
|
|
9
|
-
<img src="https://img.shields.io/pypi/pyversions/chatenv.svg" alt="Python versions" />
|
|
10
|
-
</a>
|
|
11
|
-
<a href="LICENSE">
|
|
12
|
-
<img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License" />
|
|
13
|
-
</a>
|
|
14
|
-
</div>
|
|
15
|
-
|
|
16
|
-
<div align="center">
|
|
17
|
-
|
|
18
|
-
# ChatEnv
|
|
19
|
-
|
|
20
|
-
ChatArch typed env/profile runtime.
|
|
21
|
-
|
|
22
|
-
</div>
|
|
23
|
-
|
|
24
|
-
ChatEnv 是 ChatArch / chatxxx 系列项目共用的 typed env/profile 底层包。它提供字段描述、配置基类、registry、路径、profile 文件读写、mask 和 paste 解析等通用能力;同时内置少量跨工具共享 schema(当前为 OpenAI / Feishu)。工具私有变量仍由 ChatTool、ChatDNS 等项目自己定义并注册。
|
|
25
|
-
|
|
26
|
-
当前设计保持减法:只使用一个根变量 `CHATARCH_HOME`,只管理 env/profile 文件,不额外创建 config/cache/data/state。
|
|
27
|
-
|
|
28
|
-
支持 Python `>=3.10`。
|
|
29
|
-
|
|
30
|
-
## 安装
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
pip install chatenv --upgrade
|
|
34
|
-
pip install -e .[dev] # 仓库开发
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## 目录
|
|
38
|
-
|
|
39
|
-
```text
|
|
40
|
-
CHATARCH_HOME=${CHATARCH_HOME:-~/.chatarch}
|
|
41
|
-
$CHATARCH_HOME/envs/ # stable typed env/profile files
|
|
42
|
-
$CHATARCH_HOME/tokens/ # generated runtime tokens/sessions, parallel to env profiles
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
实际布局由业务项目注册的 schema 决定,例如:
|
|
46
|
-
|
|
47
|
-
```text
|
|
48
|
-
~/.chatarch/envs/
|
|
49
|
-
Example/
|
|
50
|
-
.env
|
|
51
|
-
work.env
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
- `.env` 是当前 active profile;
|
|
55
|
-
- `name.env` 是 named profile;
|
|
56
|
-
- `use` 会把 named profile 复制为 active `.env`。
|
|
57
|
-
|
|
58
|
-
## CLI 概览
|
|
59
|
-
|
|
60
|
-
`chatenv` CLI 基于已注册 schema 工作。单独安装且没有项目注册 schema 时,它会提示需要先注册配置类型。业务项目通常会在自己的 CLI 中导入 schema 后复用这些能力。
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
chatenv --version
|
|
64
|
-
chatenv --tree
|
|
65
|
-
chatenv init -t example
|
|
66
|
-
chatenv status
|
|
67
|
-
chatenv status --detail
|
|
68
|
-
chatenv cat -t example
|
|
69
|
-
chatenv cat -t example --no-mask | chatenv paste --stdin --profile work --yes
|
|
70
|
-
chatenv set EXAMPLE_API_KEY=sk-xxx
|
|
71
|
-
chatenv get EXAMPLE_API_KEY
|
|
72
|
-
chatenv new -t example work
|
|
73
|
-
chatenv save -t example work
|
|
74
|
-
chatenv use -t example work
|
|
75
|
-
chatenv delete -t example work
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
单次命令可通过 `--home` 覆盖根目录:
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
chatenv --home /tmp/chatarch cat -t example
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
缺少必要命令参数时,ChatEnv 默认会在可交互终端中自动补问;显式 `-i` 始终强制补问,`-I` 始终禁用补问。自动化环境可设置:
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
export CHATARCH_AUTO_PROMPT=false
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
此时只有缺少必要参数的命令会直接报错;参数已经足够的命令行为不变。
|
|
91
|
-
|
|
92
|
-
`chatenv --tree` 可从当前安装包的 Click 注册表实时输出完整命令树,用于验收和脚本 readback。
|
|
93
|
-
|
|
94
|
-
更多用法见 `docs/cli.md`。
|
|
95
|
-
|
|
96
|
-
## Runtime tokens
|
|
97
|
-
|
|
98
|
-
ChatEnv 区分 stable env/profile 和动态 runtime token:
|
|
99
|
-
|
|
100
|
-
- `envs/<Service>/<profile>.env` 保存可长期维护的稳定配置,例如 base URL、账号、API key 或 refresh/login 所需输入;
|
|
101
|
-
- `tokens/<Service>/<profile>.json` 保存由登录或刷新流程生成的 access token、session、cookie/CSRF 等运行态;
|
|
102
|
-
- `chatenv token refresh SERVICE PROFILE` 会调用服务包通过 `chatenv.token_refreshers` 注册的刷新器,自动生成并更新 token-store;
|
|
103
|
-
- 手工 JSON 写入只保留为显式 `chatenv token import ... --stdin/--file`,用于迁移、调试或外部刷新器交接,不应作为日常维护入口。
|
|
104
|
-
|
|
105
|
-
ChatEnv 只负责路径、profile 校验、原子写入和 safe status/list/clear;具体登录、OAuth refresh、cookie 刷新等业务语义仍由 leaf package 负责。
|
|
106
|
-
|
|
107
|
-
## Paste
|
|
108
|
-
|
|
109
|
-
`paste` 是跨设备复制密钥的核心入口。输入不要求是严格 dotenv 文件,会从终端日志、shell prompt、复制文本里提取已注册 key;同一行里用空格分隔的多个 `KEY='VALUE'` 片段也会被逐个识别。
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
chatenv paste
|
|
113
|
-
chatenv paste --stdin --profile work
|
|
114
|
-
chatenv paste --value "EXAMPLE_API_KEY='sk-xxx'" --yes
|
|
115
|
-
chatenv paste --value "EXAMPLE_MODEL='gpt example' EXAMPLE_API_KEY='sk-xxx'" --yes
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
写入前会输出识别概要:识别到哪些类型、哪些 key、未知 key 被忽略。
|
|
119
|
-
|
|
120
|
-
## Python API
|
|
121
|
-
|
|
122
|
-
```python
|
|
123
|
-
from chatenv import BaseEnvConfig, EnvField, EnvStore, get_paths
|
|
124
|
-
|
|
125
|
-
class ExampleConfig(BaseEnvConfig):
|
|
126
|
-
_title = "Example Configuration"
|
|
127
|
-
_aliases = ["example"]
|
|
128
|
-
_storage_dir = "Example"
|
|
129
|
-
|
|
130
|
-
EXAMPLE_API_KEY = EnvField("EXAMPLE_API_KEY", is_sensitive=True)
|
|
131
|
-
|
|
132
|
-
paths = get_paths()
|
|
133
|
-
store = EnvStore(paths.envs_dir)
|
|
134
|
-
store.save_active(ExampleConfig, {"EXAMPLE_API_KEY": "sk-..."})
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
## 文档
|
|
138
|
-
|
|
139
|
-
- `docs/cli.md`:CLI 用法
|
|
140
|
-
- `docs/design.md`:路径、数据布局与注册策略
|
|
141
|
-
- `docs/developer-guide.md`:chatxxx 项目接入和 provider 开发指南
|
|
142
|
-
- `docs/development.md`:测试、构建与发布
|
|
143
|
-
- `mkdocs.yml`:Material for MkDocs 文档站点配置
|
|
144
|
-
|
|
145
|
-
## 开发
|
|
146
|
-
|
|
147
|
-
```bash
|
|
148
|
-
python -m pytest -q
|
|
149
|
-
python -m build
|
|
150
|
-
python -m twine check dist/*
|
|
151
|
-
python -m pip install -e .[docs]
|
|
152
|
-
python -m mkdocs serve
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
也可以用 ChatTool helper:
|
|
156
|
-
|
|
157
|
-
```bash
|
|
158
|
-
chattool pypi build --project-dir .
|
|
159
|
-
chattool pypi check --project-dir .
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
## 开源协议
|
|
163
|
-
|
|
164
|
-
MIT License
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: chatenv
|
|
3
|
-
Version: 0.2.7
|
|
4
|
-
Summary: ChatArch typed environment profile manager
|
|
5
|
-
Author-email: rexwzh <1073853456@qq.com>
|
|
6
|
-
License-Expression: MIT
|
|
7
|
-
Project-URL: Homepage, https://github.com/ChatArch/ChatEnv
|
|
8
|
-
Project-URL: Repository, https://github.com/ChatArch/ChatEnv
|
|
9
|
-
Project-URL: Documentation, https://chatarch.github.io/ChatEnv/
|
|
10
|
-
Keywords: chatenv,chatarch,env
|
|
11
|
-
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Classifier: Operating System :: OS Independent
|
|
13
|
-
Requires-Python: >=3.10
|
|
14
|
-
Description-Content-Type: text/markdown
|
|
15
|
-
License-File: LICENSE
|
|
16
|
-
Requires-Dist: chatstyle<0.2.0,>=0.1.0
|
|
17
|
-
Requires-Dist: click<9.0,>=8.4.2
|
|
18
|
-
Requires-Dist: python-dotenv<2.0,>=1.2.2
|
|
19
|
-
Provides-Extra: dev
|
|
20
|
-
Requires-Dist: build>=1.0; extra == "dev"
|
|
21
|
-
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
22
|
-
Requires-Dist: twine>=5.0; extra == "dev"
|
|
23
|
-
Provides-Extra: docs
|
|
24
|
-
Requires-Dist: mkdocs<2.0,>=1.6; extra == "docs"
|
|
25
|
-
Requires-Dist: mkdocs-material<9.7,>=9.5; extra == "docs"
|
|
26
|
-
Requires-Dist: mkdocs-minify-plugin<1.0,>=0.8; extra == "docs"
|
|
27
|
-
Requires-Dist: mkdocs-redirects<2.0,>=1.2; extra == "docs"
|
|
28
|
-
Requires-Dist: mike<3.0,>=2.1; extra == "docs"
|
|
29
|
-
Dynamic: license-file
|
|
30
|
-
|
|
31
|
-
<div align="center">
|
|
32
|
-
<a href="https://pypi.python.org/pypi/chatenv">
|
|
33
|
-
<img src="https://img.shields.io/pypi/v/chatenv.svg" alt="PyPI version" />
|
|
34
|
-
</a>
|
|
35
|
-
<a href="https://github.com/ChatArch/ChatEnv/actions/workflows/ci.yml">
|
|
36
|
-
<img src="https://github.com/ChatArch/ChatEnv/actions/workflows/ci.yml/badge.svg" alt="Tests" />
|
|
37
|
-
</a>
|
|
38
|
-
<a href="https://pypi.python.org/pypi/chatenv">
|
|
39
|
-
<img src="https://img.shields.io/pypi/pyversions/chatenv.svg" alt="Python versions" />
|
|
40
|
-
</a>
|
|
41
|
-
<a href="LICENSE">
|
|
42
|
-
<img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License" />
|
|
43
|
-
</a>
|
|
44
|
-
</div>
|
|
45
|
-
|
|
46
|
-
<div align="center">
|
|
47
|
-
|
|
48
|
-
# ChatEnv
|
|
49
|
-
|
|
50
|
-
ChatArch typed env/profile runtime.
|
|
51
|
-
|
|
52
|
-
</div>
|
|
53
|
-
|
|
54
|
-
ChatEnv 是 ChatArch / chatxxx 系列项目共用的 typed env/profile 底层包。它提供字段描述、配置基类、registry、路径、profile 文件读写、mask 和 paste 解析等通用能力;同时内置少量跨工具共享 schema(当前为 OpenAI / Feishu)。工具私有变量仍由 ChatTool、ChatDNS 等项目自己定义并注册。
|
|
55
|
-
|
|
56
|
-
当前设计保持减法:只使用一个根变量 `CHATARCH_HOME`,只管理 env/profile 文件,不额外创建 config/cache/data/state。
|
|
57
|
-
|
|
58
|
-
支持 Python `>=3.10`。
|
|
59
|
-
|
|
60
|
-
## 安装
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
pip install chatenv --upgrade
|
|
64
|
-
pip install -e .[dev] # 仓库开发
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
## 目录
|
|
68
|
-
|
|
69
|
-
```text
|
|
70
|
-
CHATARCH_HOME=${CHATARCH_HOME:-~/.chatarch}
|
|
71
|
-
$CHATARCH_HOME/envs/ # stable typed env/profile files
|
|
72
|
-
$CHATARCH_HOME/tokens/ # generated runtime tokens/sessions, parallel to env profiles
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
实际布局由业务项目注册的 schema 决定,例如:
|
|
76
|
-
|
|
77
|
-
```text
|
|
78
|
-
~/.chatarch/envs/
|
|
79
|
-
Example/
|
|
80
|
-
.env
|
|
81
|
-
work.env
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
- `.env` 是当前 active profile;
|
|
85
|
-
- `name.env` 是 named profile;
|
|
86
|
-
- `use` 会把 named profile 复制为 active `.env`。
|
|
87
|
-
|
|
88
|
-
## CLI 概览
|
|
89
|
-
|
|
90
|
-
`chatenv` CLI 基于已注册 schema 工作。单独安装且没有项目注册 schema 时,它会提示需要先注册配置类型。业务项目通常会在自己的 CLI 中导入 schema 后复用这些能力。
|
|
91
|
-
|
|
92
|
-
```bash
|
|
93
|
-
chatenv --version
|
|
94
|
-
chatenv --tree
|
|
95
|
-
chatenv init -t example
|
|
96
|
-
chatenv status
|
|
97
|
-
chatenv status --detail
|
|
98
|
-
chatenv cat -t example
|
|
99
|
-
chatenv cat -t example --no-mask | chatenv paste --stdin --profile work --yes
|
|
100
|
-
chatenv set EXAMPLE_API_KEY=sk-xxx
|
|
101
|
-
chatenv get EXAMPLE_API_KEY
|
|
102
|
-
chatenv new -t example work
|
|
103
|
-
chatenv save -t example work
|
|
104
|
-
chatenv use -t example work
|
|
105
|
-
chatenv delete -t example work
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
单次命令可通过 `--home` 覆盖根目录:
|
|
109
|
-
|
|
110
|
-
```bash
|
|
111
|
-
chatenv --home /tmp/chatarch cat -t example
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
缺少必要命令参数时,ChatEnv 默认会在可交互终端中自动补问;显式 `-i` 始终强制补问,`-I` 始终禁用补问。自动化环境可设置:
|
|
115
|
-
|
|
116
|
-
```bash
|
|
117
|
-
export CHATARCH_AUTO_PROMPT=false
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
此时只有缺少必要参数的命令会直接报错;参数已经足够的命令行为不变。
|
|
121
|
-
|
|
122
|
-
`chatenv --tree` 可从当前安装包的 Click 注册表实时输出完整命令树,用于验收和脚本 readback。
|
|
123
|
-
|
|
124
|
-
更多用法见 `docs/cli.md`。
|
|
125
|
-
|
|
126
|
-
## Runtime tokens
|
|
127
|
-
|
|
128
|
-
ChatEnv 区分 stable env/profile 和动态 runtime token:
|
|
129
|
-
|
|
130
|
-
- `envs/<Service>/<profile>.env` 保存可长期维护的稳定配置,例如 base URL、账号、API key 或 refresh/login 所需输入;
|
|
131
|
-
- `tokens/<Service>/<profile>.json` 保存由登录或刷新流程生成的 access token、session、cookie/CSRF 等运行态;
|
|
132
|
-
- `chatenv token refresh SERVICE PROFILE` 会调用服务包通过 `chatenv.token_refreshers` 注册的刷新器,自动生成并更新 token-store;
|
|
133
|
-
- 手工 JSON 写入只保留为显式 `chatenv token import ... --stdin/--file`,用于迁移、调试或外部刷新器交接,不应作为日常维护入口。
|
|
134
|
-
|
|
135
|
-
ChatEnv 只负责路径、profile 校验、原子写入和 safe status/list/clear;具体登录、OAuth refresh、cookie 刷新等业务语义仍由 leaf package 负责。
|
|
136
|
-
|
|
137
|
-
## Paste
|
|
138
|
-
|
|
139
|
-
`paste` 是跨设备复制密钥的核心入口。输入不要求是严格 dotenv 文件,会从终端日志、shell prompt、复制文本里提取已注册 key;同一行里用空格分隔的多个 `KEY='VALUE'` 片段也会被逐个识别。
|
|
140
|
-
|
|
141
|
-
```bash
|
|
142
|
-
chatenv paste
|
|
143
|
-
chatenv paste --stdin --profile work
|
|
144
|
-
chatenv paste --value "EXAMPLE_API_KEY='sk-xxx'" --yes
|
|
145
|
-
chatenv paste --value "EXAMPLE_MODEL='gpt example' EXAMPLE_API_KEY='sk-xxx'" --yes
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
写入前会输出识别概要:识别到哪些类型、哪些 key、未知 key 被忽略。
|
|
149
|
-
|
|
150
|
-
## Python API
|
|
151
|
-
|
|
152
|
-
```python
|
|
153
|
-
from chatenv import BaseEnvConfig, EnvField, EnvStore, get_paths
|
|
154
|
-
|
|
155
|
-
class ExampleConfig(BaseEnvConfig):
|
|
156
|
-
_title = "Example Configuration"
|
|
157
|
-
_aliases = ["example"]
|
|
158
|
-
_storage_dir = "Example"
|
|
159
|
-
|
|
160
|
-
EXAMPLE_API_KEY = EnvField("EXAMPLE_API_KEY", is_sensitive=True)
|
|
161
|
-
|
|
162
|
-
paths = get_paths()
|
|
163
|
-
store = EnvStore(paths.envs_dir)
|
|
164
|
-
store.save_active(ExampleConfig, {"EXAMPLE_API_KEY": "sk-..."})
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
## 文档
|
|
168
|
-
|
|
169
|
-
- `docs/cli.md`:CLI 用法
|
|
170
|
-
- `docs/design.md`:路径、数据布局与注册策略
|
|
171
|
-
- `docs/developer-guide.md`:chatxxx 项目接入和 provider 开发指南
|
|
172
|
-
- `docs/development.md`:测试、构建与发布
|
|
173
|
-
- `mkdocs.yml`:Material for MkDocs 文档站点配置
|
|
174
|
-
|
|
175
|
-
## 开发
|
|
176
|
-
|
|
177
|
-
```bash
|
|
178
|
-
python -m pytest -q
|
|
179
|
-
python -m build
|
|
180
|
-
python -m twine check dist/*
|
|
181
|
-
python -m pip install -e .[docs]
|
|
182
|
-
python -m mkdocs serve
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
也可以用 ChatTool helper:
|
|
186
|
-
|
|
187
|
-
```bash
|
|
188
|
-
chattool pypi build --project-dir .
|
|
189
|
-
chattool pypi check --project-dir .
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
## 开源协议
|
|
193
|
-
|
|
194
|
-
MIT License
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|