chatenv 0.2.15__tar.gz → 0.2.16__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.15/src/chatenv.egg-info → chatenv-0.2.16}/PKG-INFO +7 -1
- {chatenv-0.2.15 → chatenv-0.2.16}/README.md +6 -0
- {chatenv-0.2.15 → chatenv-0.2.16}/src/chatenv/__init__.py +1 -1
- {chatenv-0.2.15 → chatenv-0.2.16}/src/chatenv/registry.py +15 -9
- {chatenv-0.2.15 → chatenv-0.2.16/src/chatenv.egg-info}/PKG-INFO +7 -1
- {chatenv-0.2.15 → chatenv-0.2.16}/src/chatenv.egg-info/SOURCES.txt +1 -0
- chatenv-0.2.16/tests/test_registry_selection.py +93 -0
- {chatenv-0.2.15 → chatenv-0.2.16}/tests/test_version.py +1 -1
- {chatenv-0.2.15 → chatenv-0.2.16}/LICENSE +0 -0
- {chatenv-0.2.15 → chatenv-0.2.16}/pyproject.toml +0 -0
- {chatenv-0.2.15 → chatenv-0.2.16}/setup.cfg +0 -0
- {chatenv-0.2.15 → chatenv-0.2.16}/src/chatenv/cli.py +0 -0
- {chatenv-0.2.15 → chatenv-0.2.16}/src/chatenv/configs.py +0 -0
- {chatenv-0.2.15 → chatenv-0.2.16}/src/chatenv/discovery.py +0 -0
- {chatenv-0.2.15 → chatenv-0.2.16}/src/chatenv/fields.py +0 -0
- {chatenv-0.2.15 → chatenv-0.2.16}/src/chatenv/paste.py +0 -0
- {chatenv-0.2.15 → chatenv-0.2.16}/src/chatenv/paths.py +0 -0
- {chatenv-0.2.15 → chatenv-0.2.16}/src/chatenv/policy.py +0 -0
- {chatenv-0.2.15 → chatenv-0.2.16}/src/chatenv/presets/__init__.py +0 -0
- {chatenv-0.2.15 → chatenv-0.2.16}/src/chatenv/source_chain.py +0 -0
- {chatenv-0.2.15 → chatenv-0.2.16}/src/chatenv/store.py +0 -0
- {chatenv-0.2.15 → chatenv-0.2.16}/src/chatenv/token_refreshers.py +0 -0
- {chatenv-0.2.15 → chatenv-0.2.16}/src/chatenv/tokens.py +0 -0
- {chatenv-0.2.15 → chatenv-0.2.16}/src/chatenv/utils.py +0 -0
- {chatenv-0.2.15 → chatenv-0.2.16}/src/chatenv.egg-info/dependency_links.txt +0 -0
- {chatenv-0.2.15 → chatenv-0.2.16}/src/chatenv.egg-info/entry_points.txt +0 -0
- {chatenv-0.2.15 → chatenv-0.2.16}/src/chatenv.egg-info/requires.txt +0 -0
- {chatenv-0.2.15 → chatenv-0.2.16}/src/chatenv.egg-info/top_level.txt +0 -0
- {chatenv-0.2.15 → chatenv-0.2.16}/tests/test_chatenv_core.py +0 -0
- {chatenv-0.2.15 → chatenv-0.2.16}/tests/test_docs_contract.py +0 -0
- {chatenv-0.2.15 → chatenv-0.2.16}/tests/test_secret_display.py +0 -0
- {chatenv-0.2.15 → chatenv-0.2.16}/tests/test_test_profiles.py +0 -0
- {chatenv-0.2.15 → chatenv-0.2.16}/tests/test_workflow_contract.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: chatenv
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.16
|
|
4
4
|
Summary: ChatArch typed environment profile manager
|
|
5
5
|
Author-email: rexwzh <1073853456@qq.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -138,6 +138,12 @@ chatenv token status PyPI RexWzh
|
|
|
138
138
|
|
|
139
139
|
敏感值默认完整遮罩:`init` 的已有值提示、默认 `cat` 和 `status --detail` 不展示密码/密钥的首尾片段;明确使用 `cat --no-mask` 才主动取原值。遮罩仅影响显示,不把星号写回 profile;`token status/list/clear` 只输出 safe metadata,不输出 raw token/cookie/CSRF values。
|
|
140
140
|
|
|
141
|
+
## 配置类型精确选择
|
|
142
|
+
|
|
143
|
+
`-t/--type` 对每个选择词先匹配完整类型名、存储名或别名;没有精确匹配时才回退前缀匹配。匹配不区分大小写。多个选择词合并并去重,真正重名或前缀匹配多个类型时,要求单类型的命令仍会拒绝歧义。
|
|
144
|
+
|
|
145
|
+
例如安装 ChatCRS 后,`chatenv status -t crs` 和 `chatenv status -t chatcrs` 只选 CRS;`-t codex` 和 `-t chatcrs-codex` 只选 Codex。旧别名和 profile/token 存储目录不变,不会隐式切换配置。
|
|
146
|
+
|
|
141
147
|
## Python API
|
|
142
148
|
|
|
143
149
|
```python
|
|
@@ -107,6 +107,12 @@ chatenv token status PyPI RexWzh
|
|
|
107
107
|
|
|
108
108
|
敏感值默认完整遮罩:`init` 的已有值提示、默认 `cat` 和 `status --detail` 不展示密码/密钥的首尾片段;明确使用 `cat --no-mask` 才主动取原值。遮罩仅影响显示,不把星号写回 profile;`token status/list/clear` 只输出 safe metadata,不输出 raw token/cookie/CSRF values。
|
|
109
109
|
|
|
110
|
+
## 配置类型精确选择
|
|
111
|
+
|
|
112
|
+
`-t/--type` 对每个选择词先匹配完整类型名、存储名或别名;没有精确匹配时才回退前缀匹配。匹配不区分大小写。多个选择词合并并去重,真正重名或前缀匹配多个类型时,要求单类型的命令仍会拒绝歧义。
|
|
113
|
+
|
|
114
|
+
例如安装 ChatCRS 后,`chatenv status -t crs` 和 `chatenv status -t chatcrs` 只选 CRS;`-t codex` 和 `-t chatcrs-codex` 只选 Codex。旧别名和 profile/token 存储目录不变,不会隐式切换配置。
|
|
115
|
+
|
|
110
116
|
## Python API
|
|
111
117
|
|
|
112
118
|
```python
|
|
@@ -7,19 +7,25 @@ def resolve_config_types(config_types: tuple[str, ...] | list[str] | None) -> li
|
|
|
7
7
|
if not config_types:
|
|
8
8
|
return None
|
|
9
9
|
normalized = [item.lower() for item in config_types]
|
|
10
|
-
|
|
10
|
+
candidates = []
|
|
11
11
|
for config_cls in BaseEnvConfig._registry:
|
|
12
12
|
title = getattr(config_cls, "_title", config_cls.__name__).lower()
|
|
13
13
|
aliases = [alias.lower() for alias in getattr(config_cls, "_aliases", [])]
|
|
14
14
|
storage_name = config_cls.get_storage_name().lower()
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
candidates.append((config_cls, [title, storage_name, *aliases]))
|
|
16
|
+
|
|
17
|
+
selected: set[type[BaseEnvConfig]] = set()
|
|
18
|
+
for item in normalized:
|
|
19
|
+
exact = [config_cls for config_cls, names in candidates if item in names]
|
|
20
|
+
if exact:
|
|
21
|
+
selected.update(exact)
|
|
22
|
+
else:
|
|
23
|
+
selected.update(
|
|
24
|
+
config_cls
|
|
25
|
+
for config_cls, names in candidates
|
|
26
|
+
if any(name.startswith(item) for name in names)
|
|
27
|
+
)
|
|
28
|
+
return [config_cls for config_cls in BaseEnvConfig._registry if config_cls in selected]
|
|
23
29
|
|
|
24
30
|
|
|
25
31
|
def require_single_config(config_types: tuple[str, ...] | list[str] | None, action: str) -> type[BaseEnvConfig]:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: chatenv
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.16
|
|
4
4
|
Summary: ChatArch typed environment profile manager
|
|
5
5
|
Author-email: rexwzh <1073853456@qq.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -138,6 +138,12 @@ chatenv token status PyPI RexWzh
|
|
|
138
138
|
|
|
139
139
|
敏感值默认完整遮罩:`init` 的已有值提示、默认 `cat` 和 `status --detail` 不展示密码/密钥的首尾片段;明确使用 `cat --no-mask` 才主动取原值。遮罩仅影响显示,不把星号写回 profile;`token status/list/clear` 只输出 safe metadata,不输出 raw token/cookie/CSRF values。
|
|
140
140
|
|
|
141
|
+
## 配置类型精确选择
|
|
142
|
+
|
|
143
|
+
`-t/--type` 对每个选择词先匹配完整类型名、存储名或别名;没有精确匹配时才回退前缀匹配。匹配不区分大小写。多个选择词合并并去重,真正重名或前缀匹配多个类型时,要求单类型的命令仍会拒绝歧义。
|
|
144
|
+
|
|
145
|
+
例如安装 ChatCRS 后,`chatenv status -t crs` 和 `chatenv status -t chatcrs` 只选 CRS;`-t codex` 和 `-t chatcrs-codex` 只选 Codex。旧别名和 profile/token 存储目录不变,不会隐式切换配置。
|
|
146
|
+
|
|
141
147
|
## Python API
|
|
142
148
|
|
|
143
149
|
```python
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"""Exact selectors must not expand into another provider's prefixed alias."""
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
import pytest
|
|
5
|
+
from click.testing import CliRunner
|
|
6
|
+
|
|
7
|
+
import chatenv.cli as cli_module
|
|
8
|
+
from chatenv.cli import cli
|
|
9
|
+
from chatenv.fields import BaseEnvConfig, EnvField
|
|
10
|
+
from chatenv.registry import require_single_config, resolve_config_types
|
|
11
|
+
from chatenv.store import EnvStore
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@pytest.fixture
|
|
15
|
+
def schemas(monkeypatch):
|
|
16
|
+
monkeypatch.setattr(BaseEnvConfig, "_registry", [])
|
|
17
|
+
monkeypatch.setattr(BaseEnvConfig, "_registry_keys", {})
|
|
18
|
+
monkeypatch.setattr(cli_module, "load_config_providers", lambda: None)
|
|
19
|
+
|
|
20
|
+
class RelayConfig(BaseEnvConfig):
|
|
21
|
+
_title = "CRS Configuration"
|
|
22
|
+
_storage_dir = "CRS"
|
|
23
|
+
_aliases = ["crs", "chatcrs"]
|
|
24
|
+
CRS_API_KEY = EnvField("CRS_API_KEY", is_sensitive=True)
|
|
25
|
+
|
|
26
|
+
class OAuthConfig(BaseEnvConfig):
|
|
27
|
+
_title = "Codex OAuth Configuration"
|
|
28
|
+
_storage_dir = "Codex"
|
|
29
|
+
_aliases = ["codex", "chatcrs-codex"]
|
|
30
|
+
OPENAI_REFRESH_TOKEN = EnvField("OPENAI_REFRESH_TOKEN", is_sensitive=True)
|
|
31
|
+
|
|
32
|
+
return RelayConfig, OAuthConfig
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@pytest.mark.parametrize("query,index", [("crs", 0), ("chatcrs", 0), ("CRS", 0), ("CHATCRS", 0), ("codex", 1), ("chatcrs-codex", 1), ("Codex OAuth Configuration", 1)])
|
|
36
|
+
def test_exact_storage_title_or_alias_wins_over_prefix(schemas, query, index):
|
|
37
|
+
assert resolve_config_types([query]) == [schemas[index]]
|
|
38
|
+
assert require_single_config([query], "save") is schemas[index]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def test_prefix_fallback_and_explicit_multi_select_keep_registry_order(schemas):
|
|
42
|
+
relay, oauth = schemas
|
|
43
|
+
assert resolve_config_types(["chatcr"]) == [relay, oauth]
|
|
44
|
+
with pytest.raises(ValueError, match="exactly one"):
|
|
45
|
+
require_single_config(["chatcr"], "save")
|
|
46
|
+
assert resolve_config_types(["codex", "chatcrs", "codex"]) == [relay, oauth]
|
|
47
|
+
assert resolve_config_types(["chatcrs", "not-a-type"]) == [relay]
|
|
48
|
+
assert resolve_config_types(["missing"]) == []
|
|
49
|
+
assert resolve_config_types(None) is None
|
|
50
|
+
assert resolve_config_types([]) is None
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_exact_alias_collision_remains_ambiguous(schemas):
|
|
54
|
+
relay, oauth = schemas
|
|
55
|
+
relay._aliases = [*relay._aliases, "shared"]
|
|
56
|
+
oauth._aliases = [*oauth._aliases, "shared"]
|
|
57
|
+
assert resolve_config_types(["shared"]) == [relay, oauth]
|
|
58
|
+
with pytest.raises(ValueError, match="exactly one"):
|
|
59
|
+
require_single_config(["shared"], "save")
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@pytest.mark.parametrize("selector,index", [("crs", 0), ("chatcrs", 0), ("codex", 1), ("chatcrs-codex", 1)])
|
|
63
|
+
def test_dispatcher_profile_write_never_crosses_namespace(schemas, tmp_path, selector, index):
|
|
64
|
+
home = tmp_path / "arch"
|
|
65
|
+
store = EnvStore(home / "envs")
|
|
66
|
+
relay, oauth = schemas
|
|
67
|
+
store.save_active(relay, {"CRS_API_KEY": "DUMMY_RELAY_CANARY"})
|
|
68
|
+
store.save_active(oauth, {"OPENAI_REFRESH_TOKEN": "DUMMY_OAUTH_CANARY"})
|
|
69
|
+
before = {c: store.active_path(c).read_bytes() for c in schemas}
|
|
70
|
+
token = home / "tokens" / "Codex" / "receipt.json"
|
|
71
|
+
token.parent.mkdir(parents=True)
|
|
72
|
+
token.write_text('{"synthetic": true}', encoding="utf-8")
|
|
73
|
+
token_before = token.read_bytes()
|
|
74
|
+
runner = CliRunner()
|
|
75
|
+
status = runner.invoke(cli, ["--home", str(home), "status", "-t", selector])
|
|
76
|
+
assert status.exit_code == 0, status.output
|
|
77
|
+
assert "Registered config platforms: 1" in status.output
|
|
78
|
+
saved = runner.invoke(cli, ["--home", str(home), "save", "isolated", "-t", selector, "-I", "--yes"])
|
|
79
|
+
assert saved.exit_code == 0, saved.output
|
|
80
|
+
selected, other = schemas[index], schemas[1 - index]
|
|
81
|
+
assert store.profile_path(selected, "isolated").exists()
|
|
82
|
+
assert not store.profile_path(other, "isolated").exists()
|
|
83
|
+
for cls in schemas:
|
|
84
|
+
assert store.active_path(cls).read_bytes() == before[cls]
|
|
85
|
+
assert token.read_bytes() == token_before
|
|
86
|
+
cat = runner.invoke(cli, ["--home", str(home), "cat", "-t", selector])
|
|
87
|
+
assert cat.exit_code == 0, cat.output
|
|
88
|
+
expected = "CRS_API_KEY" if index == 0 else "OPENAI_REFRESH_TOKEN"
|
|
89
|
+
excluded = "OPENAI_REFRESH_TOKEN" if index == 0 else "CRS_API_KEY"
|
|
90
|
+
assert expected in cat.output
|
|
91
|
+
assert excluded not in cat.output
|
|
92
|
+
assert "DUMMY_RELAY_CANARY" not in cat.output
|
|
93
|
+
assert "DUMMY_OAUTH_CANARY" not in cat.output
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|