codedthemes-cli 0.1.12__tar.gz → 0.1.14__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.12 → codedthemes_cli-0.1.14}/PKG-INFO +10 -2
- {codedthemes_cli-0.1.12 → codedthemes_cli-0.1.14}/README.md +9 -1
- {codedthemes_cli-0.1.12 → codedthemes_cli-0.1.14}/codedthemes/cli.py +60 -19
- {codedthemes_cli-0.1.12 → codedthemes_cli-0.1.14}/codedthemes/config.py +22 -8
- {codedthemes_cli-0.1.12 → codedthemes_cli-0.1.14}/codedthemes/mcp_client.py +4 -1
- {codedthemes_cli-0.1.12 → codedthemes_cli-0.1.14}/codedthemes/repo_utils.py +8 -7
- {codedthemes_cli-0.1.12 → codedthemes_cli-0.1.14}/codedthemes_cli.egg-info/PKG-INFO +10 -2
- {codedthemes_cli-0.1.12 → codedthemes_cli-0.1.14}/pyproject.toml +1 -1
- {codedthemes_cli-0.1.12 → codedthemes_cli-0.1.14}/codedthemes/__init__.py +0 -0
- {codedthemes_cli-0.1.12 → codedthemes_cli-0.1.14}/codedthemes/patch_utils.py +0 -0
- {codedthemes_cli-0.1.12 → codedthemes_cli-0.1.14}/codedthemes/sync_manager.py +0 -0
- {codedthemes_cli-0.1.12 → codedthemes_cli-0.1.14}/codedthemes_cli.egg-info/SOURCES.txt +0 -0
- {codedthemes_cli-0.1.12 → codedthemes_cli-0.1.14}/codedthemes_cli.egg-info/dependency_links.txt +0 -0
- {codedthemes_cli-0.1.12 → codedthemes_cli-0.1.14}/codedthemes_cli.egg-info/entry_points.txt +0 -0
- {codedthemes_cli-0.1.12 → codedthemes_cli-0.1.14}/codedthemes_cli.egg-info/requires.txt +0 -0
- {codedthemes_cli-0.1.12 → codedthemes_cli-0.1.14}/codedthemes_cli.egg-info/top_level.txt +0 -0
- {codedthemes_cli-0.1.12 → codedthemes_cli-0.1.14}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codedthemes-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.14
|
|
4
4
|
Summary: CLI tool for Code Theme and Integration
|
|
5
5
|
Author: codedthemes
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -38,7 +38,15 @@ codedthemes login
|
|
|
38
38
|
```
|
|
39
39
|
*Enter your registered email and license key when prompted.*
|
|
40
40
|
|
|
41
|
-
### 2.
|
|
41
|
+
### 2. Logout
|
|
42
|
+
|
|
43
|
+
Log out from the current device to free up a license slot on the server.
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
codedthemes logout
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 3. Initialization (Optional)
|
|
42
50
|
|
|
43
51
|
Initialize your repository to establish a baseline for synchronization. This is recommended for first-time use in a project.
|
|
44
52
|
|
|
@@ -28,7 +28,15 @@ codedthemes login
|
|
|
28
28
|
```
|
|
29
29
|
*Enter your registered email and license key when prompted.*
|
|
30
30
|
|
|
31
|
-
### 2.
|
|
31
|
+
### 2. Logout
|
|
32
|
+
|
|
33
|
+
Log out from the current device to free up a license slot on the server.
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
codedthemes logout
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 3. Initialization (Optional)
|
|
32
40
|
|
|
33
41
|
Initialize your repository to establish a baseline for synchronization. This is recommended for first-time use in a project.
|
|
34
42
|
|
|
@@ -29,6 +29,7 @@ def handle_login(server_url: str = None):
|
|
|
29
29
|
choice = input("Switch account? (y/N): ").strip().lower()
|
|
30
30
|
if choice not in ['y', 'yes']:
|
|
31
31
|
print("Login cancelled.")
|
|
32
|
+
print("Please enter your credentials to log in.")
|
|
32
33
|
return
|
|
33
34
|
except:
|
|
34
35
|
pass
|
|
@@ -62,28 +63,25 @@ def handle_login(server_url: str = None):
|
|
|
62
63
|
"device_name": device_name
|
|
63
64
|
})
|
|
64
65
|
|
|
65
|
-
if
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
elif "message" in result and "Login failed" in result["message"]:
|
|
70
|
-
print(f"✖ {result['message']}")
|
|
66
|
+
if result.get("status") == "success":
|
|
67
|
+
token = result.get("access_token")
|
|
68
|
+
if not token:
|
|
69
|
+
print("✖ Login failed: No access token returned. Please check your credentials.")
|
|
71
70
|
sys.exit(1)
|
|
72
71
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
# LAZY CONFIG: Only save if login succeeded
|
|
73
|
+
save_config({
|
|
74
|
+
"access_token": token,
|
|
75
|
+
"server_url": client.server_url,
|
|
76
|
+
"device_id": device_id,
|
|
77
|
+
"license_key": license_key
|
|
78
|
+
})
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
"
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
print("✔ Login successful.")
|
|
86
|
-
print("\n🚀 Next Step: Run 'codedthemes init' to initialize your repository and sync it with the cloud.")
|
|
80
|
+
print(f"✔ {result.get('message')}")
|
|
81
|
+
print("\n🚀 Next Step: Run 'codedthemes init' to initialize your repository and sync it with the cloud.")
|
|
82
|
+
else:
|
|
83
|
+
print(f"✖ {result.get('message', 'Login failed')}")
|
|
84
|
+
sys.exit(1)
|
|
87
85
|
except Exception as e:
|
|
88
86
|
err_msg = str(e)
|
|
89
87
|
if "timed out" in err_msg.lower():
|
|
@@ -93,7 +91,45 @@ def handle_login(server_url: str = None):
|
|
|
93
91
|
sys.exit(1)
|
|
94
92
|
|
|
95
93
|
|
|
94
|
+
def handle_logout():
|
|
95
|
+
"""
|
|
96
|
+
Clears local session and notifies server to de-authenticate this device.
|
|
97
|
+
"""
|
|
98
|
+
try:
|
|
99
|
+
config = load_config()
|
|
100
|
+
token = config.get("access_token")
|
|
101
|
+
license_key = config.get("license_key")
|
|
102
|
+
|
|
103
|
+
if not token:
|
|
104
|
+
print("ℹ Not logged in.")
|
|
105
|
+
return
|
|
106
|
+
|
|
107
|
+
device_id = get_device_id()
|
|
108
|
+
client = MCPClient()
|
|
109
|
+
|
|
110
|
+
print("Logging out...")
|
|
111
|
+
if license_key:
|
|
112
|
+
try:
|
|
113
|
+
client.call("logout", {
|
|
114
|
+
"license_key": license_key,
|
|
115
|
+
"device_id": device_id
|
|
116
|
+
})
|
|
117
|
+
except Exception as e:
|
|
118
|
+
# Silently fail if server logout fails, we still want to clear local state
|
|
119
|
+
pass
|
|
120
|
+
|
|
121
|
+
# Local cleanup: Remove config.json but KEEP device.json
|
|
122
|
+
from .config import CONFIG_FILE
|
|
123
|
+
if CONFIG_FILE.exists():
|
|
124
|
+
CONFIG_FILE.unlink()
|
|
125
|
+
|
|
126
|
+
print("✔ Logged out successfully.")
|
|
127
|
+
except Exception as e:
|
|
128
|
+
print(f"✖ Logout failed: {e}")
|
|
129
|
+
|
|
130
|
+
|
|
96
131
|
def handle_init():
|
|
132
|
+
|
|
97
133
|
"""
|
|
98
134
|
Initializes the local repository and syncs it with the cloud.
|
|
99
135
|
"""
|
|
@@ -413,6 +449,8 @@ def main():
|
|
|
413
449
|
apply_parser.add_argument("query", help="Description of changes to make")
|
|
414
450
|
|
|
415
451
|
subparsers.add_parser("init", help="Initialize repository and sync to cloud")
|
|
452
|
+
subparsers.add_parser("logout", help="Log out from current device")
|
|
453
|
+
|
|
416
454
|
|
|
417
455
|
args = parser.parse_args()
|
|
418
456
|
|
|
@@ -426,6 +464,9 @@ def main():
|
|
|
426
464
|
handle_init()
|
|
427
465
|
elif args.command == "apply":
|
|
428
466
|
handle_apply(args.query)
|
|
467
|
+
elif args.command == "logout":
|
|
468
|
+
handle_logout()
|
|
469
|
+
|
|
429
470
|
|
|
430
471
|
|
|
431
472
|
if __name__ == "__main__":
|
|
@@ -29,27 +29,41 @@ def save_config(data: dict):
|
|
|
29
29
|
|
|
30
30
|
def get_device_id():
|
|
31
31
|
"""
|
|
32
|
-
|
|
32
|
+
Returns a unique device ID, stored globally in ~/.codedthemes/device.json.
|
|
33
33
|
"""
|
|
34
|
+
device_file = CONFIG_DIR / "device.json"
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
if device_file.exists():
|
|
37
|
+
try:
|
|
38
|
+
with open(device_file, "r") as f:
|
|
39
|
+
data = json.load(f)
|
|
40
|
+
if data.get("device_id"):
|
|
41
|
+
return data["device_id"]
|
|
42
|
+
except:
|
|
43
|
+
pass
|
|
44
|
+
|
|
45
|
+
# Generate new device ID
|
|
40
46
|
try:
|
|
41
47
|
hostname = socket.gethostname()
|
|
42
|
-
device_uuid = str(uuid.getnode())
|
|
48
|
+
device_uuid = str(uuid.getnode())
|
|
43
49
|
raw_id = f"{hostname}-{device_uuid}"
|
|
44
50
|
device_id = hashlib.sha256(raw_id.encode()).hexdigest()[:12]
|
|
45
51
|
except:
|
|
46
52
|
device_id = str(uuid.uuid4())[:12]
|
|
53
|
+
|
|
54
|
+
# Save globally (create dir if not exists)
|
|
55
|
+
CONFIG_DIR.mkdir(exist_ok=True)
|
|
56
|
+
try:
|
|
57
|
+
with open(device_file, "w") as f:
|
|
58
|
+
json.dump({"device_id": device_id}, f)
|
|
59
|
+
except:
|
|
60
|
+
pass
|
|
47
61
|
|
|
48
|
-
save_config({"device_id": device_id})
|
|
49
62
|
return device_id
|
|
50
63
|
|
|
51
64
|
|
|
52
65
|
|
|
66
|
+
|
|
53
67
|
def load_config():
|
|
54
68
|
"""
|
|
55
69
|
Loads the configuration data from the config file.
|
|
@@ -66,12 +66,15 @@ class MCPClient:
|
|
|
66
66
|
if self.token:
|
|
67
67
|
headers["Authorization"] = f"Bearer {self.token}"
|
|
68
68
|
|
|
69
|
-
# Login
|
|
69
|
+
# Login and Logout use dedicated endpoints
|
|
70
70
|
if tool_name == "login":
|
|
71
71
|
url = f"{self.server_url}/auth/login"
|
|
72
|
+
elif tool_name == "logout":
|
|
73
|
+
url = f"{self.server_url}/auth/logout"
|
|
72
74
|
else:
|
|
73
75
|
url = f"{self.server_url}/tools/{tool_name}"
|
|
74
76
|
|
|
77
|
+
|
|
75
78
|
response = requests.post(
|
|
76
79
|
url,
|
|
77
80
|
json=payload,
|
|
@@ -104,20 +104,21 @@ def _is_gitignored(rel_path, patterns):
|
|
|
104
104
|
|
|
105
105
|
def detect_repo_root(start_path=None):
|
|
106
106
|
"""
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
Checks if the current directory contains ai.json or .git.
|
|
108
|
+
Strictly restricted to the current path (no upward traversal) to avoid
|
|
109
|
+
incorrectly detecting parent repos.
|
|
109
110
|
"""
|
|
110
111
|
if not start_path:
|
|
111
112
|
start_path = os.getcwd()
|
|
112
113
|
|
|
113
114
|
current = Path(start_path).resolve()
|
|
114
115
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
if any((current / f).exists() for f in ["ai.json", ".git"]):
|
|
117
|
+
return current
|
|
118
|
+
|
|
119
|
+
raise Exception("No repository root found. Please run this command inside a Git repository or one initialized with 'codedthemes init'.")
|
|
120
|
+
|
|
119
121
|
|
|
120
|
-
raise Exception("No repository root found.")
|
|
121
122
|
|
|
122
123
|
|
|
123
124
|
def zip_repo(repo_root):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codedthemes-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.14
|
|
4
4
|
Summary: CLI tool for Code Theme and Integration
|
|
5
5
|
Author: codedthemes
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -38,7 +38,15 @@ codedthemes login
|
|
|
38
38
|
```
|
|
39
39
|
*Enter your registered email and license key when prompted.*
|
|
40
40
|
|
|
41
|
-
### 2.
|
|
41
|
+
### 2. Logout
|
|
42
|
+
|
|
43
|
+
Log out from the current device to free up a license slot on the server.
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
codedthemes logout
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 3. Initialization (Optional)
|
|
42
50
|
|
|
43
51
|
Initialize your repository to establish a baseline for synchronization. This is recommended for first-time use in a project.
|
|
44
52
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{codedthemes_cli-0.1.12 → codedthemes_cli-0.1.14}/codedthemes_cli.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|