ai-code-switcher 0.1.6__tar.gz → 0.1.7__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.
Files changed (19) hide show
  1. {ai_code_switcher-0.1.6 → ai_code_switcher-0.1.7}/PKG-INFO +1 -1
  2. {ai_code_switcher-0.1.6 → ai_code_switcher-0.1.7}/pyproject.toml +1 -1
  3. {ai_code_switcher-0.1.6 → ai_code_switcher-0.1.7}/src/ai_code_switcher.egg-info/PKG-INFO +1 -1
  4. {ai_code_switcher-0.1.6 → ai_code_switcher-0.1.7}/src/code_ai/launcher.py +15 -4
  5. {ai_code_switcher-0.1.6 → ai_code_switcher-0.1.7}/src/code_ai/models.py +1 -1
  6. {ai_code_switcher-0.1.6 → ai_code_switcher-0.1.7}/tests/test_integration.py +4 -4
  7. {ai_code_switcher-0.1.6 → ai_code_switcher-0.1.7}/tests/test_launcher.py +4 -4
  8. {ai_code_switcher-0.1.6 → ai_code_switcher-0.1.7}/README.md +0 -0
  9. {ai_code_switcher-0.1.6 → ai_code_switcher-0.1.7}/setup.cfg +0 -0
  10. {ai_code_switcher-0.1.6 → ai_code_switcher-0.1.7}/src/ai_code_switcher.egg-info/SOURCES.txt +0 -0
  11. {ai_code_switcher-0.1.6 → ai_code_switcher-0.1.7}/src/ai_code_switcher.egg-info/dependency_links.txt +0 -0
  12. {ai_code_switcher-0.1.6 → ai_code_switcher-0.1.7}/src/ai_code_switcher.egg-info/entry_points.txt +0 -0
  13. {ai_code_switcher-0.1.6 → ai_code_switcher-0.1.7}/src/ai_code_switcher.egg-info/requires.txt +0 -0
  14. {ai_code_switcher-0.1.6 → ai_code_switcher-0.1.7}/src/ai_code_switcher.egg-info/top_level.txt +0 -0
  15. {ai_code_switcher-0.1.6 → ai_code_switcher-0.1.7}/src/code_ai/__init__.py +0 -0
  16. {ai_code_switcher-0.1.6 → ai_code_switcher-0.1.7}/src/code_ai/cli.py +0 -0
  17. {ai_code_switcher-0.1.6 → ai_code_switcher-0.1.7}/src/code_ai/config.py +0 -0
  18. {ai_code_switcher-0.1.6 → ai_code_switcher-0.1.7}/src/code_ai/profiles.py +0 -0
  19. {ai_code_switcher-0.1.6 → ai_code_switcher-0.1.7}/tests/test_models.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ai-code-switcher
3
- Version: 0.1.6
3
+ Version: 0.1.7
4
4
  Summary: Switch AI coding tool profiles and launch the correct CLI
5
5
  License-Expression: MIT
6
6
  Requires-Python: >=3.8
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ai-code-switcher"
7
- version = "0.1.6"
7
+ version = "0.1.7"
8
8
  description = "Switch AI coding tool profiles and launch the correct CLI"
9
9
  license = "MIT"
10
10
  requires-python = ">=3.8"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ai-code-switcher
3
- Version: 0.1.6
3
+ Version: 0.1.7
4
4
  Summary: Switch AI coding tool profiles and launch the correct CLI
5
5
  License-Expression: MIT
6
6
  Requires-Python: >=3.8
@@ -14,7 +14,7 @@ ENV_MAP = {
14
14
  "cmd": "gemini",
15
15
  },
16
16
  "codex": {
17
- "env": {"OPENAI_API_KEY": "api_key"},
17
+ "env": {"OPENAI_BASE_URL": "base_url", "OPENAI_API_KEY": "api_key"},
18
18
  "cmd": "codex",
19
19
  },
20
20
  }
@@ -37,9 +37,20 @@ def prepare_environment(profile):
37
37
  env.pop(env_var, None)
38
38
  # Expand ~ to home directory
39
39
  credentials_path = os.path.expanduser(profile.credentials_path)
40
- # Set the appropriate CONFIG_DIR based on profile type
41
- config_dir_var = f"{ptype.upper()}_CONFIG_DIR"
42
- env[config_dir_var] = credentials_path
40
+ # Set the appropriate config dir env var based on profile type
41
+ # Claude uses CLAUDE_CONFIG_DIR, Codex uses CODEX_HOME
42
+ config_dir_vars = {"claude": "CLAUDE_CONFIG_DIR", "codex": "CODEX_HOME"}
43
+ config_dir_var = config_dir_vars.get(ptype)
44
+ if config_dir_var:
45
+ os.makedirs(credentials_path, exist_ok=True)
46
+ # For codex: ensure config.toml exists with default openai provider
47
+ # to prevent inheriting custom providers from ~/.codex/config.toml
48
+ if ptype == "codex":
49
+ config_toml = os.path.join(credentials_path, "config.toml")
50
+ if not os.path.exists(config_toml):
51
+ with open(config_toml, "w") as f:
52
+ f.write('model_provider = "openai"\n')
53
+ env[config_dir_var] = credentials_path
43
54
  elif isinstance(profile, ApiProfile):
44
55
  # API mode: set API environment variables
45
56
  for env_var, config_key in spec["env"].items():
@@ -22,7 +22,7 @@ class ApiProfile(BaseProfile):
22
22
 
23
23
  @dataclass
24
24
  class LoginProfile(BaseProfile):
25
- """Login mode: authenticate via OAuth credentials directory (Claude only)"""
25
+ """Login mode: authenticate via OAuth credentials directory (Claude/Codex)"""
26
26
  credentials_path: str = "" # Path to existing OAuth credentials
27
27
 
28
28
 
@@ -261,9 +261,9 @@ class TestCodexProfiles:
261
261
 
262
262
  # Test environment preparation
263
263
  env = prepare_environment(profile)
264
- # Should only have OPENAI_API_KEY, not OPENAI_BASE_URL
264
+ # Should have both OPENAI_API_KEY and OPENAI_BASE_URL
265
265
  assert env["OPENAI_API_KEY"] == "sk-test-key"
266
- assert "OPENAI_BASE_URL" not in env
266
+ assert env["OPENAI_BASE_URL"] == "https://api.openai.com/v1"
267
267
 
268
268
  def test_codex_login_profile(self, tmp_path):
269
269
  """Test codex login mode profile"""
@@ -305,7 +305,7 @@ class TestCodexProfiles:
305
305
  env = prepare_environment(profile)
306
306
  # Login mode should NOT have API environment variables
307
307
  assert "OPENAI_API_KEY" not in env
308
- # Should have CODEX_CONFIG_DIR with expanded path
308
+ # Should have CODEX_HOME with expanded path
309
309
  import os
310
310
  expected_path = os.path.expanduser("~/.codex-profiles/account-a")
311
- assert env["CODEX_CONFIG_DIR"] == expected_path
311
+ assert env["CODEX_HOME"] == expected_path
@@ -85,9 +85,9 @@ def test_prepare_env_codex_api_mode():
85
85
 
86
86
  env = prepare_environment(profile)
87
87
 
88
- # Should only have OPENAI_API_KEY, not OPENAI_BASE_URL
88
+ # Should have both OPENAI_API_KEY and OPENAI_BASE_URL
89
89
  assert env["OPENAI_API_KEY"] == "sk-test"
90
- assert "OPENAI_BASE_URL" not in env
90
+ assert env["OPENAI_BASE_URL"] == "https://api.openai.com/v1"
91
91
 
92
92
 
93
93
  def test_prepare_env_codex_login_mode():
@@ -102,6 +102,6 @@ def test_prepare_env_codex_login_mode():
102
102
 
103
103
  # Should NOT have API environment variables
104
104
  assert "OPENAI_API_KEY" not in env
105
- # Should have CODEX_CONFIG_DIR with expanded path
105
+ # Should have CODEX_HOME with expanded path
106
106
  expected_path = os.path.expanduser("~/.codex-profiles/account-a")
107
- assert env["CODEX_CONFIG_DIR"] == expected_path
107
+ assert env["CODEX_HOME"] == expected_path