codedthemes-cli 0.1.9__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codedthemes-cli
3
- Version: 0.1.9
3
+ Version: 0.1.11
4
4
  Summary: CLI tool for Code Theme and Integration
5
5
  Author: codedthemes
6
6
  Requires-Python: >=3.10
@@ -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 or local fallback
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
@@ -120,25 +126,58 @@ def handle_init():
120
126
  print("\n" + "="*60)
121
127
  print("Your repository is now synced to the cloud!")
122
128
  print("="*60)
123
- print("\n📌 Next Steps — Set up your IDE:")
124
- print("")
125
- print(" 1. Open your IDE (e.g. Antigravity / Cursor / VS Code)")
126
- print(" 2. Go to MCP Servers > Manage > Config")
127
- print(" 3. Add this to your MCP configuration:")
128
- print("")
129
- print(' {')
130
- print(' "mcpServers": {')
131
- print(' "code-theme-mcp": {')
132
- print(' "type": "sse",')
133
- print(' "serverURL": "https://mcp.codedthemes.com/api/mcp"')
134
- print(' }')
129
+
130
+ print("\n📌 Next Steps — Set up your IDE:\n")
131
+
132
+ print("Choose your editor and add the MCP server:\n")
133
+
134
+ # ---------------- ANTIGRAVITY ----------------
135
+ print("🔹 Antigravity")
136
+ print(" MCP Servers → Manage → Config\n")
137
+
138
+ print(' {')
139
+ print(' "mcpServers": {')
140
+ print(' "code-theme-mcp": {')
141
+ print(' "type": "sse",')
142
+ print(' "serverURL": "https://mcp.codedthemes.com/api/mcp",')
143
+ print(f' "env": {{ "CODEDTHEMES_TOKEN": "{client.token}" }}')
144
+ print(' }')
145
+ print(' }')
146
+ print(' }\n')
147
+
148
+ # ---------------- VS CODE ----------------
149
+ print("🔹 VS Code")
150
+ print(" Ctrl+Shift+P → MCP: Add MCP Server → http\n")
151
+
152
+ print(' {')
153
+ print(' "servers": {')
154
+ print(' "code-theme-mcp": {')
155
+ print(' "url": "https://mcp.codedthemes.com/api/mcp",')
156
+ print(' "type": "http",')
157
+ print(f' "env": {{ "CODEDTHEMES_TOKEN": "{client.token}" }}')
158
+ print(' }')
159
+ print(' },')
160
+ print(' "inputs": []')
161
+ print(' }\n')
162
+
163
+ # ---------------- CURSOR ----------------
164
+ print("🔹 Cursor")
165
+ print(" Settings → Features → MCP Servers\n")
166
+
167
+ print(' {')
168
+ print(' "mcpServers": {')
169
+ print(' "code-theme-mcp": {')
170
+ print(' "transport": "sse",')
171
+ print(' "url": "https://mcp.codedthemes.com/api/mcp",')
172
+ print(f' "env": {{ "CODEDTHEMES_TOKEN": "{client.token}" }}')
135
173
  print(' }')
136
174
  print(' }')
137
- print("")
138
- print(" 4. Save and verify the tools are detected.")
139
- print(" 5. You can now ask your AI assistant to plan and apply changes!")
140
- print("")
141
- print("💡 Example: \"Update the primary color to deep purple\"")
175
+ print(' }\n')
176
+
177
+ print(" Once saved, your AI assistant will detect available tools automatically.\n")
178
+
179
+ print('💡 Example: "Update the primary color to deep purple"')
180
+
142
181
  print("="*60)
143
182
 
144
183
  except Exception as e:
@@ -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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codedthemes-cli
3
- Version: 0.1.9
3
+ Version: 0.1.11
4
4
  Summary: CLI tool for Code Theme and Integration
5
5
  Author: codedthemes
6
6
  Requires-Python: >=3.10
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "codedthemes-cli"
7
- version = "0.1.9"
7
+ version = "0.1.11"
8
8
  description = "CLI tool for Code Theme and Integration"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -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 {}