codex-model-change 1.0.0 → 1.0.2

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.
Files changed (2) hide show
  1. package/cx.py +7 -2
  2. package/package.json +2 -2
package/cx.py CHANGED
@@ -14,6 +14,8 @@
14
14
  """
15
15
  import json, os, re, glob, sqlite3, subprocess, sys, shutil, time, urllib.request, urllib.error
16
16
 
17
+ CX_VERSION = "1.0.2"
18
+
17
19
  CODEX_HOME = os.environ.get("CODEX_HOME", os.path.expanduser("~/.codex"))
18
20
  CONFIG = os.path.join(CODEX_HOME, "config.toml")
19
21
  CX_DIR = os.path.expanduser("~/.cx")
@@ -48,6 +50,7 @@ HELP = """cx — Codex 模型直连切换器
48
50
  fix-all <目标> 批量把所有老会话切换到目标模型(需退 App)
49
51
  用法: cx fix-all deepseek|gpt [--limit N]
50
52
  migrate-sessions 旧代理会话迁移(遗留命令,一般用 fix-all 即可)
53
+ version 显示 cx 版本
51
54
  help 显示本帮助
52
55
 
53
56
  要点:
@@ -207,6 +210,7 @@ def app_running():
207
210
  return subprocess.run(["pgrep", "-f", APP_PGREP], capture_output=True).returncode == 0
208
211
 
209
212
  def cmd_status():
213
+ print(f"cx 版本 : {CX_VERSION}")
210
214
  text = read_cfg()
211
215
  m = re.search(r'(?m)^model\s*=\s*"([^"]+)"', text)
212
216
  p = re.search(r'(?m)^model_provider\s*=\s*"([^"]+)"', text)
@@ -327,8 +331,8 @@ def cmd_fix_all():
327
331
  todo = []
328
332
  for tid, m, p, rp in rows:
329
333
  needs_model = (m != model or p != provider)
330
- needs_sanitize = (provider == "openai" and rp and os.path.exists(rp)
331
- and "rs_ocx_" in open(rp, encoding="utf-8", errors="ignore").read(2_000_000))
334
+ # 清洗判断不能只扫文件前缀:脏条目可能埋在大会话深处,只要目标是 openai 就全量清洗(幂等)
335
+ needs_sanitize = (provider == "openai" and rp and os.path.exists(rp))
332
336
  if needs_model or needs_sanitize:
333
337
  todo.append((tid, m, p, rp, needs_model))
334
338
  if not todo:
@@ -404,6 +408,7 @@ def main():
404
408
  elif c == "fix": cmd_fix()
405
409
  elif c == "fix-all": cmd_fix_all()
406
410
  elif c == "migrate-sessions": cmd_migrate()
411
+ elif c in ("version", "-V", "--version"): print(f"cx {CX_VERSION}")
407
412
  elif c in ("-h", "--help", "help"): print(HELP)
408
413
  else: err(f"未知命令: {c}(cx help 查看用法)")
409
414
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-model-change",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Switch OpenAI Codex (CLI / desktop app) between DeepSeek direct-connect and native ChatGPT. No proxy, no daemon.",
5
5
  "bin": {
6
6
  "cx": "bin/cx.js"
@@ -34,4 +34,4 @@
34
34
  "bugs": {
35
35
  "url": "https://github.com/git-sgg/codex-model-change/issues"
36
36
  }
37
- }
37
+ }