cliops 1.0.1__py3-none-any.whl → 1.0.3__py3-none-any.whl
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.
- cliops-1.0.3.data/scripts/post_install.py +15 -0
- {cliops-1.0.1.dist-info → cliops-1.0.3.dist-info}/METADATA +1 -1
- cliops-1.0.3.dist-info/RECORD +15 -0
- {cliops-1.0.1.dist-info → cliops-1.0.3.dist-info}/top_level.txt +1 -0
- core/state.py +14 -5
- presets.py +93 -0
- cliops-1.0.1.dist-info/RECORD +0 -13
- {cliops-1.0.1.dist-info → cliops-1.0.3.dist-info}/WHEEL +0 -0
- {cliops-1.0.1.dist-info → cliops-1.0.3.dist-info}/entry_points.txt +0 -0
- {cliops-1.0.1.dist-info → cliops-1.0.3.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
import os
|
2
|
+
import sys
|
3
|
+
from pathlib import Path
|
4
|
+
|
5
|
+
def add_to_path():
|
6
|
+
"""Add Python Scripts directory to PATH if not already present"""
|
7
|
+
scripts_dir = Path(sys.executable).parent / "Scripts"
|
8
|
+
current_path = os.environ.get('PATH', '')
|
9
|
+
|
10
|
+
if str(scripts_dir) not in current_path:
|
11
|
+
print(f"Add this to your PATH: {scripts_dir}")
|
12
|
+
print("Or run: setx PATH \"%PATH%;{}\"".format(scripts_dir))
|
13
|
+
|
14
|
+
if __name__ == "__main__":
|
15
|
+
add_to_path()
|
@@ -0,0 +1,15 @@
|
|
1
|
+
main.py,sha256=YwzFPWB6QDtjK7r9gKA9tixEgD_7_b7gXoj6Q2ETCqk,9255
|
2
|
+
presets.py,sha256=DKIfhwxtBZEC5fYHgXqhuBKou7KYQks_2M8cR3IeWao,3172
|
3
|
+
cliops-1.0.3.data/scripts/post_install.py,sha256=JS1QTVN_DlozPi01OTQGqdN59zNjS_Z38BcRMD00hQw,459
|
4
|
+
cliops-1.0.3.dist-info/licenses/LICENSE,sha256=2J5KKebeJ2AdMaxuYA1fX0ZuDs9MmWp3cpjZX-JqrZs,1079
|
5
|
+
core/__init__.py,sha256=aWl7MZaubJNqrafNCM5VRYg4SZ7sdifrxTWrJC8d-_s,24
|
6
|
+
core/analyzer.py,sha256=mwMmrlV-Pk31mMfKs0NPqBqY3cpNwCq_DWwGaurjPzI,4328
|
7
|
+
core/config.py,sha256=aoYCLt-EFM7WiR3_QN049_cfz9_SODuqnErte07DTVM,1388
|
8
|
+
core/optimizer.py,sha256=6hGdelQjWb71WAdXWr89EvYNinzb2gETQgaB3APuoV8,6196
|
9
|
+
core/patterns.py,sha256=BWiwb5fjQbWHLsJ68p0QbtSddFqzhYx3AeLkSY-WKbU,6464
|
10
|
+
core/state.py,sha256=BeosHqAwT3tcicaQs-gJabz2jrtwQp8t7J0ziGXv_QI,2668
|
11
|
+
cliops-1.0.3.dist-info/METADATA,sha256=3cNObmVrj8Gq_rPMSXaaRKc14cYZY_EgSZlHSm4YbPE,3818
|
12
|
+
cliops-1.0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
13
|
+
cliops-1.0.3.dist-info/entry_points.txt,sha256=F8ZncVlnk83ELj0TGXUYS-qYvmaP-owQyU20I7jRefg,37
|
14
|
+
cliops-1.0.3.dist-info/top_level.txt,sha256=dV-NRp_bb_IkCFfEXDbA1mHA5SshVNbUsxaF809itG8,18
|
15
|
+
cliops-1.0.3.dist-info/RECORD,,
|
core/state.py
CHANGED
@@ -17,9 +17,14 @@ class CLIState:
|
|
17
17
|
if self.file_path.exists():
|
18
18
|
try:
|
19
19
|
with open(self.file_path, 'r') as f:
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
content = f.read().strip()
|
21
|
+
if not content: # Empty file
|
22
|
+
return {}
|
23
|
+
return json.loads(content)
|
24
|
+
except (json.JSONDecodeError, ValueError):
|
25
|
+
# Only show warning in non-test environments
|
26
|
+
if not str(self.file_path).startswith('/tmp') and 'tmp' not in str(self.file_path):
|
27
|
+
console.print(f"[bold yellow]Warning:[/bold yellow] Could not decode JSON from {self.file_path}. Starting with empty state.", style="yellow")
|
23
28
|
return {}
|
24
29
|
return {}
|
25
30
|
|
@@ -32,7 +37,9 @@ class CLIState:
|
|
32
37
|
"""Sets a key-value pair in the state."""
|
33
38
|
self.state[key.upper()] = value
|
34
39
|
self._save_state()
|
35
|
-
|
40
|
+
# Only show output in non-test environments
|
41
|
+
if not str(self.file_path).startswith('/tmp') and 'tmp' not in str(self.file_path):
|
42
|
+
console.print(f"State '[bold green]{key.upper()}[/bold green]' set to '[cyan]{value}[/cyan]'.")
|
36
43
|
|
37
44
|
def get(self, key: str) -> str | None:
|
38
45
|
"""Gets a value from the state."""
|
@@ -57,4 +64,6 @@ class CLIState:
|
|
57
64
|
"""Clears all entries from the state."""
|
58
65
|
self.state = {}
|
59
66
|
self._save_state()
|
60
|
-
|
67
|
+
# Only show output in non-test environments
|
68
|
+
if not str(self.file_path).startswith('/tmp') and 'tmp' not in str(self.file_path):
|
69
|
+
console.print("CLI state cleared.", style="red")
|
presets.py
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
# presets.py
|
2
|
+
import json
|
3
|
+
import re
|
4
|
+
from pathlib import Path
|
5
|
+
|
6
|
+
BUILTIN_PRESETS = {
|
7
|
+
"react-tailwind": {
|
8
|
+
"ARCHITECTURE": "React + Tailwind CSS",
|
9
|
+
"FOCUS": "UI layout",
|
10
|
+
"PATTERNS": "context_aware_generation, state_anchoring",
|
11
|
+
"DEFAULT_PATTERN": "context_aware_generation"
|
12
|
+
},
|
13
|
+
"django-api": {
|
14
|
+
"ARCHITECTURE": "Django REST Framework",
|
15
|
+
"FOCUS": "API endpoints and serializers",
|
16
|
+
"PATTERNS": "bug_fix_precision",
|
17
|
+
"DEFAULT_PATTERN": "bug_fix_precision"
|
18
|
+
},
|
19
|
+
"bash-script": {
|
20
|
+
"ARCHITECTURE": "Shell scripting",
|
21
|
+
"FOCUS": "Automation and CLI behavior",
|
22
|
+
"PATTERNS": "context_aware_generation",
|
23
|
+
"DEFAULT_PATTERN": "context_aware_generation"
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
CUSTOM_PRESET_FILE = Path.home() / ".cliops_presets.json"
|
28
|
+
|
29
|
+
def suggest_preset_from_prompt(prompt: str) -> str | None:
|
30
|
+
prompt = prompt.lower()
|
31
|
+
if "tailwind" in prompt or "jsx" in prompt:
|
32
|
+
return "react-tailwind"
|
33
|
+
if "endpoint" in prompt or "serializer" in prompt or "django" in prompt:
|
34
|
+
return "django-api"
|
35
|
+
if re.search(r'#!/bin/bash|\\.sh|chmod|\\bcron\\b', prompt):
|
36
|
+
return "bash-script"
|
37
|
+
return None
|
38
|
+
|
39
|
+
def save_custom_preset(name, preset_dict):
|
40
|
+
if CUSTOM_PRESET_FILE.exists():
|
41
|
+
with open(CUSTOM_PRESET_FILE, 'r') as f:
|
42
|
+
all_presets = json.load(f)
|
43
|
+
else:
|
44
|
+
all_presets = {}
|
45
|
+
all_presets[name] = preset_dict
|
46
|
+
with open(CUSTOM_PRESET_FILE, 'w') as f:
|
47
|
+
json.dump(all_presets, f, indent=2)
|
48
|
+
print(f"✅ Custom preset '{name}' saved.")
|
49
|
+
|
50
|
+
def apply_preset_interactive(suggested_name, state):
|
51
|
+
print(f"\n🤖 Suggested preset based on your prompt: {suggested_name}")
|
52
|
+
use = input("Would you like to use this preset? (y/n): ").strip().lower()
|
53
|
+
if use != 'y':
|
54
|
+
print("❌ Preset declined.")
|
55
|
+
return
|
56
|
+
|
57
|
+
fields = {}
|
58
|
+
for key in BUILTIN_PRESETS.get(suggested_name, {}):
|
59
|
+
default = BUILTIN_PRESETS[suggested_name][key]
|
60
|
+
user_val = input(f"{key} [{default}]: ").strip()
|
61
|
+
fields[key] = user_val or default
|
62
|
+
state.set(key, fields[key])
|
63
|
+
|
64
|
+
save = input("Save this as a custom preset? (y/n): ").strip().lower()
|
65
|
+
if save == 'y':
|
66
|
+
name = input("Enter a name for your preset: ").strip()
|
67
|
+
if name:
|
68
|
+
save_custom_preset(name, fields)
|
69
|
+
|
70
|
+
def list_all_presets():
|
71
|
+
print("\n📦 Available Presets:")
|
72
|
+
for name in BUILTIN_PRESETS:
|
73
|
+
print(f" - {name} (built-in)")
|
74
|
+
if CUSTOM_PRESET_FILE.exists():
|
75
|
+
with open(CUSTOM_PRESET_FILE, 'r') as f:
|
76
|
+
custom = json.load(f)
|
77
|
+
for name in custom:
|
78
|
+
print(f" - {name} (custom)")
|
79
|
+
|
80
|
+
|
81
|
+
def apply_named_preset(name, state):
|
82
|
+
preset = BUILTIN_PRESETS.get(name)
|
83
|
+
if not preset and CUSTOM_PRESET_FILE.exists():
|
84
|
+
with open(CUSTOM_PRESET_FILE, 'r') as f:
|
85
|
+
preset = json.load(f).get(name)
|
86
|
+
|
87
|
+
if not preset:
|
88
|
+
print(f"❌ Preset '{name}' not found.")
|
89
|
+
return
|
90
|
+
|
91
|
+
for key, value in preset.items():
|
92
|
+
state.set(key, value)
|
93
|
+
print(f"✅ Preset '{name}' applied.")
|
cliops-1.0.1.dist-info/RECORD
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
main.py,sha256=YwzFPWB6QDtjK7r9gKA9tixEgD_7_b7gXoj6Q2ETCqk,9255
|
2
|
-
cliops-1.0.1.dist-info/licenses/LICENSE,sha256=2J5KKebeJ2AdMaxuYA1fX0ZuDs9MmWp3cpjZX-JqrZs,1079
|
3
|
-
core/__init__.py,sha256=aWl7MZaubJNqrafNCM5VRYg4SZ7sdifrxTWrJC8d-_s,24
|
4
|
-
core/analyzer.py,sha256=mwMmrlV-Pk31mMfKs0NPqBqY3cpNwCq_DWwGaurjPzI,4328
|
5
|
-
core/config.py,sha256=aoYCLt-EFM7WiR3_QN049_cfz9_SODuqnErte07DTVM,1388
|
6
|
-
core/optimizer.py,sha256=6hGdelQjWb71WAdXWr89EvYNinzb2gETQgaB3APuoV8,6196
|
7
|
-
core/patterns.py,sha256=BWiwb5fjQbWHLsJ68p0QbtSddFqzhYx3AeLkSY-WKbU,6464
|
8
|
-
core/state.py,sha256=dHdA9U0LNgGzyS_bSlcotjfpnwZGtMHfEz5JEbUqwf8,2055
|
9
|
-
cliops-1.0.1.dist-info/METADATA,sha256=b9z7-AZyNEDvsjWnuBQPVlJJUIL5Hqn4Bb3HqmBx4FA,3818
|
10
|
-
cliops-1.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
11
|
-
cliops-1.0.1.dist-info/entry_points.txt,sha256=F8ZncVlnk83ELj0TGXUYS-qYvmaP-owQyU20I7jRefg,37
|
12
|
-
cliops-1.0.1.dist-info/top_level.txt,sha256=rZwDY0-fkfo1lSqHk5h706nubQ_SMktR8ke523WorM0,10
|
13
|
-
cliops-1.0.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|