ccoding 0.3.0__py3-none-any.whl → 0.4.0__py3-none-any.whl
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.
- ccode/__init__.py +1 -1
- ccode/api.py +3 -3
- ccode/config.py +14 -10
- ccode/env_schema.json +1553 -318
- ccode/ui.py +4 -1
- {ccoding-0.3.0.dist-info → ccoding-0.4.0.dist-info}/METADATA +3 -2
- {ccoding-0.3.0.dist-info → ccoding-0.4.0.dist-info}/RECORD +10 -10
- {ccoding-0.3.0.dist-info → ccoding-0.4.0.dist-info}/WHEEL +0 -0
- {ccoding-0.3.0.dist-info → ccoding-0.4.0.dist-info}/entry_points.txt +0 -0
- {ccoding-0.3.0.dist-info → ccoding-0.4.0.dist-info}/licenses/LICENSE +0 -0
ccode/__init__.py
CHANGED
ccode/api.py
CHANGED
|
@@ -7,7 +7,7 @@ import urllib.error
|
|
|
7
7
|
import urllib.request
|
|
8
8
|
from typing import Any
|
|
9
9
|
|
|
10
|
-
from .config import MODEL_KEYS, mask_secret
|
|
10
|
+
from .config import MODEL_ENV_VARS, MODEL_KEYS, REQUIRED_MODEL_KEYS, mask_secret
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
def _truncate_body(text: str, max_len: int = 200) -> str:
|
|
@@ -107,7 +107,7 @@ def build_env(config: dict[str, Any], masked: bool = False) -> dict[str, str]:
|
|
|
107
107
|
entry = config["models"].get(key, {})
|
|
108
108
|
model_id = entry.get("id")
|
|
109
109
|
if model_id:
|
|
110
|
-
env[
|
|
110
|
+
env[MODEL_ENV_VARS[key]] = model_id
|
|
111
111
|
for key, value in config.get("toggles", {}).items():
|
|
112
112
|
env[key] = str(value)
|
|
113
113
|
return env
|
|
@@ -118,7 +118,7 @@ def validate_launch_requirements(config: dict[str, Any]) -> str | None:
|
|
|
118
118
|
api_key = config.get("api_key", "").strip()
|
|
119
119
|
if not base_url or not api_key:
|
|
120
120
|
return "Base URL and API key are required."
|
|
121
|
-
for key in
|
|
121
|
+
for key in REQUIRED_MODEL_KEYS:
|
|
122
122
|
entry = config["models"].get(key, {})
|
|
123
123
|
if not entry.get("owned_by") or not entry.get("id"):
|
|
124
124
|
return "OPUS, SONNET, and HAIKU selections are required."
|
ccode/config.py
CHANGED
|
@@ -11,12 +11,20 @@ from typing import Any
|
|
|
11
11
|
CONFIG_DIR = Path.home() / ".ccode"
|
|
12
12
|
CONFIG_PATH = CONFIG_DIR / "config.json"
|
|
13
13
|
DEFAULT_BASE_URL = "http://127.0.0.1:8317"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
"
|
|
14
|
+
# 模型 key 及其对应的环境变量,dict 顺序即主界面展示顺序。
|
|
15
|
+
# auto 对应客户端 auto mode 分类器模型,其余沿用 ANTHROPIC_DEFAULT_<KEY>_MODEL。
|
|
16
|
+
MODEL_ENV_VARS = {
|
|
17
|
+
"opus": "ANTHROPIC_DEFAULT_OPUS_MODEL",
|
|
18
|
+
"sonnet": "ANTHROPIC_DEFAULT_SONNET_MODEL",
|
|
19
|
+
"haiku": "ANTHROPIC_DEFAULT_HAIKU_MODEL",
|
|
20
|
+
"auto": "CLAUDE_CODE_AUTO_MODE_MODEL",
|
|
19
21
|
}
|
|
22
|
+
MODEL_KEYS = tuple(MODEL_ENV_VARS)
|
|
23
|
+
MODEL_LABELS = {key: key.upper() for key in MODEL_KEYS}
|
|
24
|
+
|
|
25
|
+
# auto 为可选项,其余模型启动时必选
|
|
26
|
+
OPTIONAL_MODEL_KEYS = ("auto",)
|
|
27
|
+
REQUIRED_MODEL_KEYS = tuple(key for key in MODEL_KEYS if key not in OPTIONAL_MODEL_KEYS)
|
|
20
28
|
|
|
21
29
|
# toggles 的默认值:值统一用字符串存储
|
|
22
30
|
DEFAULT_TOGGLES: dict[str, str] = {
|
|
@@ -85,11 +93,7 @@ def default_config() -> dict[str, Any]:
|
|
|
85
93
|
return {
|
|
86
94
|
"base_url": DEFAULT_BASE_URL,
|
|
87
95
|
"api_key": "",
|
|
88
|
-
"models": {
|
|
89
|
-
"opus": {"owned_by": None, "id": None},
|
|
90
|
-
"sonnet": {"owned_by": None, "id": None},
|
|
91
|
-
"haiku": {"owned_by": None, "id": None},
|
|
92
|
-
},
|
|
96
|
+
"models": {key: {"owned_by": None, "id": None} for key in MODEL_KEYS},
|
|
93
97
|
"toggles": DEFAULT_TOGGLES.copy(),
|
|
94
98
|
"skip_permissions": False,
|
|
95
99
|
"remote": copy.deepcopy(DEFAULT_REMOTE),
|