codedthemes-cli 0.1.10__tar.gz → 0.1.11__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.
- {codedthemes_cli-0.1.10 → codedthemes_cli-0.1.11}/PKG-INFO +1 -1
- {codedthemes_cli-0.1.10 → codedthemes_cli-0.1.11}/codedthemes/cli.py +29 -20
- codedthemes_cli-0.1.11/codedthemes/config.py +63 -0
- {codedthemes_cli-0.1.10 → codedthemes_cli-0.1.11}/codedthemes_cli.egg-info/PKG-INFO +1 -1
- {codedthemes_cli-0.1.10 → codedthemes_cli-0.1.11}/pyproject.toml +1 -1
- codedthemes_cli-0.1.10/codedthemes/config.py +0 -35
- {codedthemes_cli-0.1.10 → codedthemes_cli-0.1.11}/README.md +0 -0
- {codedthemes_cli-0.1.10 → codedthemes_cli-0.1.11}/codedthemes/__init__.py +0 -0
- {codedthemes_cli-0.1.10 → codedthemes_cli-0.1.11}/codedthemes/mcp_client.py +0 -0
- {codedthemes_cli-0.1.10 → codedthemes_cli-0.1.11}/codedthemes/patch_utils.py +0 -0
- {codedthemes_cli-0.1.10 → codedthemes_cli-0.1.11}/codedthemes/repo_utils.py +0 -0
- {codedthemes_cli-0.1.10 → codedthemes_cli-0.1.11}/codedthemes/sync_manager.py +0 -0
- {codedthemes_cli-0.1.10 → codedthemes_cli-0.1.11}/codedthemes_cli.egg-info/SOURCES.txt +0 -0
- {codedthemes_cli-0.1.10 → codedthemes_cli-0.1.11}/codedthemes_cli.egg-info/dependency_links.txt +0 -0
- {codedthemes_cli-0.1.10 → codedthemes_cli-0.1.11}/codedthemes_cli.egg-info/entry_points.txt +0 -0
- {codedthemes_cli-0.1.10 → codedthemes_cli-0.1.11}/codedthemes_cli.egg-info/requires.txt +0 -0
- {codedthemes_cli-0.1.10 → codedthemes_cli-0.1.11}/codedthemes_cli.egg-info/top_level.txt +0 -0
- {codedthemes_cli-0.1.10 → codedthemes_cli-0.1.11}/setup.cfg +0 -0
|
@@ -8,19 +8,37 @@ from getpass import getpass
|
|
|
8
8
|
import jwt
|
|
9
9
|
import requests
|
|
10
10
|
|
|
11
|
-
from .config import save_config, load_config
|
|
11
|
+
from .config import save_config, load_config, get_device_id
|
|
12
12
|
from .mcp_client import MCPClient
|
|
13
13
|
from .repo_utils import detect_repo_root, zip_repo
|
|
14
14
|
from .sync_manager import SyncManager
|
|
15
|
+
import socket
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
def handle_login(server_url: str = None):
|
|
18
19
|
"""
|
|
19
20
|
Handles user authentication with the MCP server.
|
|
20
21
|
"""
|
|
22
|
+
config = load_config()
|
|
23
|
+
existing_token = config.get("access_token")
|
|
24
|
+
if existing_token:
|
|
25
|
+
try:
|
|
26
|
+
decoded = jwt.decode(existing_token, options={"verify_signature": False})
|
|
27
|
+
existing_email = decoded.get("email", "unknown")
|
|
28
|
+
print(f"ℹ Currently logged in as: {existing_email}")
|
|
29
|
+
choice = input("Switch account? (y/N): ").strip().lower()
|
|
30
|
+
if choice not in ['y', 'yes']:
|
|
31
|
+
print("Login cancelled.")
|
|
32
|
+
return
|
|
33
|
+
except:
|
|
34
|
+
pass
|
|
35
|
+
|
|
21
36
|
email = input("Email: ").strip()
|
|
22
37
|
license_key = input("License key: ").strip()
|
|
23
38
|
|
|
39
|
+
device_id = get_device_id()
|
|
40
|
+
device_name = socket.gethostname()
|
|
41
|
+
|
|
24
42
|
client = MCPClient()
|
|
25
43
|
if server_url:
|
|
26
44
|
client.server_url = server_url
|
|
@@ -28,7 +46,9 @@ def handle_login(server_url: str = None):
|
|
|
28
46
|
try:
|
|
29
47
|
result = client.call("login", {
|
|
30
48
|
"email": email,
|
|
31
|
-
"license_key": license_key
|
|
49
|
+
"license_key": license_key,
|
|
50
|
+
"device_id": device_id,
|
|
51
|
+
"device_name": device_name
|
|
32
52
|
})
|
|
33
53
|
|
|
34
54
|
if isinstance(result, dict):
|
|
@@ -39,27 +59,13 @@ def handle_login(server_url: str = None):
|
|
|
39
59
|
print(f"✖ {result['message']}")
|
|
40
60
|
sys.exit(1)
|
|
41
61
|
|
|
42
|
-
# Get token from result
|
|
62
|
+
# Get token from result
|
|
43
63
|
token = result.get("access_token") if isinstance(result, dict) else None
|
|
44
64
|
|
|
45
|
-
if not token:
|
|
46
|
-
token_file = os.path.expanduser("~/.mcp_token")
|
|
47
|
-
if os.path.exists(token_file):
|
|
48
|
-
with open(token_file, 'r') as f:
|
|
49
|
-
token = f.read().strip()
|
|
50
|
-
|
|
51
65
|
if not token:
|
|
52
66
|
print("✖ Login failed: No access token returned. Please check your credentials.")
|
|
53
67
|
sys.exit(1)
|
|
54
68
|
|
|
55
|
-
# Store token for both local MCP and CLI config
|
|
56
|
-
token_file = os.path.expanduser("~/.mcp_token")
|
|
57
|
-
try:
|
|
58
|
-
with open(token_file, 'w') as f:
|
|
59
|
-
f.write(token)
|
|
60
|
-
except Exception as e:
|
|
61
|
-
print(f"Warning: Could not write {token_file}: {e}")
|
|
62
|
-
|
|
63
69
|
save_config({
|
|
64
70
|
"server_url": client.server_url,
|
|
65
71
|
"access_token": token
|
|
@@ -133,7 +139,8 @@ def handle_init():
|
|
|
133
139
|
print(' "mcpServers": {')
|
|
134
140
|
print(' "code-theme-mcp": {')
|
|
135
141
|
print(' "type": "sse",')
|
|
136
|
-
print(' "serverURL": "https://mcp.codedthemes.com/api/mcp"')
|
|
142
|
+
print(' "serverURL": "https://mcp.codedthemes.com/api/mcp",')
|
|
143
|
+
print(f' "env": {{ "CODEDTHEMES_TOKEN": "{client.token}" }}')
|
|
137
144
|
print(' }')
|
|
138
145
|
print(' }')
|
|
139
146
|
print(' }\n')
|
|
@@ -146,7 +153,8 @@ def handle_init():
|
|
|
146
153
|
print(' "servers": {')
|
|
147
154
|
print(' "code-theme-mcp": {')
|
|
148
155
|
print(' "url": "https://mcp.codedthemes.com/api/mcp",')
|
|
149
|
-
print(' "type": "http"')
|
|
156
|
+
print(' "type": "http",')
|
|
157
|
+
print(f' "env": {{ "CODEDTHEMES_TOKEN": "{client.token}" }}')
|
|
150
158
|
print(' }')
|
|
151
159
|
print(' },')
|
|
152
160
|
print(' "inputs": []')
|
|
@@ -160,7 +168,8 @@ def handle_init():
|
|
|
160
168
|
print(' "mcpServers": {')
|
|
161
169
|
print(' "code-theme-mcp": {')
|
|
162
170
|
print(' "transport": "sse",')
|
|
163
|
-
print(' "url": "https://mcp.codedthemes.com/api/mcp"')
|
|
171
|
+
print(' "url": "https://mcp.codedthemes.com/api/mcp",')
|
|
172
|
+
print(f' "env": {{ "CODEDTHEMES_TOKEN": "{client.token}" }}')
|
|
164
173
|
print(' }')
|
|
165
174
|
print(' }')
|
|
166
175
|
print(' }\n')
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import socket
|
|
3
|
+
import hashlib
|
|
4
|
+
import uuid
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
# Stores token at ~/.codedthemes/config.json
|
|
8
|
+
CONFIG_DIR = Path.home() / ".codedthemes"
|
|
9
|
+
CONFIG_FILE = CONFIG_DIR / "config.json"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def ensure_config_dir():
|
|
13
|
+
"""
|
|
14
|
+
Ensures the configuration directory exists.
|
|
15
|
+
"""
|
|
16
|
+
CONFIG_DIR.mkdir(exist_ok=True)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def save_config(data: dict):
|
|
20
|
+
"""
|
|
21
|
+
Saves the provided configuration data to the config file (merging with existing).
|
|
22
|
+
"""
|
|
23
|
+
ensure_config_dir()
|
|
24
|
+
existing = load_config()
|
|
25
|
+
existing.update(data)
|
|
26
|
+
with open(CONFIG_FILE, "w") as f:
|
|
27
|
+
json.dump(existing, f, indent=2)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def get_device_id():
|
|
31
|
+
"""
|
|
32
|
+
Generates or retrieves a unique device ID for the machine.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
config = load_config()
|
|
36
|
+
if "device_id" in config:
|
|
37
|
+
return config["device_id"]
|
|
38
|
+
|
|
39
|
+
# Generate a stable device ID based on hostname and machine UUID
|
|
40
|
+
try:
|
|
41
|
+
hostname = socket.gethostname()
|
|
42
|
+
device_uuid = str(uuid.getnode()) # MAC address based
|
|
43
|
+
raw_id = f"{hostname}-{device_uuid}"
|
|
44
|
+
device_id = hashlib.sha256(raw_id.encode()).hexdigest()[:12]
|
|
45
|
+
except:
|
|
46
|
+
device_id = str(uuid.uuid4())[:12]
|
|
47
|
+
|
|
48
|
+
save_config({"device_id": device_id})
|
|
49
|
+
return device_id
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def load_config():
|
|
54
|
+
"""
|
|
55
|
+
Loads the configuration data from the config file.
|
|
56
|
+
"""
|
|
57
|
+
if not CONFIG_FILE.exists():
|
|
58
|
+
return {}
|
|
59
|
+
with open(CONFIG_FILE, "r") as f:
|
|
60
|
+
try:
|
|
61
|
+
return json.load(f)
|
|
62
|
+
except json.JSONDecodeError:
|
|
63
|
+
return {}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import json
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
|
|
4
|
-
# Stores token at ~/.codedthemes/config.json
|
|
5
|
-
CONFIG_DIR = Path.home() / ".codedthemes"
|
|
6
|
-
CONFIG_FILE = CONFIG_DIR / "config.json"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def ensure_config_dir():
|
|
10
|
-
"""
|
|
11
|
-
Ensures the configuration directory exists.
|
|
12
|
-
"""
|
|
13
|
-
CONFIG_DIR.mkdir(exist_ok=True)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def save_config(data: dict):
|
|
17
|
-
"""
|
|
18
|
-
Saves the provided configuration data to the config file.
|
|
19
|
-
"""
|
|
20
|
-
ensure_config_dir()
|
|
21
|
-
with open(CONFIG_FILE, "w") as f:
|
|
22
|
-
json.dump(data, f, indent=2)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def load_config():
|
|
26
|
-
"""
|
|
27
|
-
Loads the configuration data from the config file.
|
|
28
|
-
"""
|
|
29
|
-
if not CONFIG_FILE.exists():
|
|
30
|
-
return {}
|
|
31
|
-
with open(CONFIG_FILE, "r") as f:
|
|
32
|
-
try:
|
|
33
|
-
return json.load(f)
|
|
34
|
-
except json.JSONDecodeError:
|
|
35
|
-
return {}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{codedthemes_cli-0.1.10 → codedthemes_cli-0.1.11}/codedthemes_cli.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|