rubber-ducky 1.4.0__py3-none-any.whl → 1.5.1__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.
ducky/config.py CHANGED
@@ -17,7 +17,7 @@ class ConfigManager:
17
17
  def load_config(self) -> Dict[str, Any]:
18
18
  """Load configuration from file, returning defaults if not found."""
19
19
  default_config = {
20
- "last_model": "qwen3-coder:480b-cloud",
20
+ "last_model": "glm-4.7:cloud",
21
21
  "last_host": "https://ollama.com"
22
22
  }
23
23
 
@@ -45,12 +45,12 @@ class ConfigManager:
45
45
 
46
46
  def get_last_model(self) -> tuple[str, str]:
47
47
  """Get the last used model and host.
48
-
48
+
49
49
  Returns:
50
50
  Tuple of (model_name, host)
51
51
  """
52
52
  config = self.load_config()
53
- return config.get("last_model", "qwen3-coder:480b-cloud"), config.get("last_host", "https://ollama.com")
53
+ return config.get("last_model", "glm-4.7:cloud"), config.get("last_host", "https://ollama.com")
54
54
 
55
55
  def save_last_model(self, model_name: str, host: str) -> None:
56
56
  """Save the last used model and host."""
ducky/crumb.py ADDED
@@ -0,0 +1,84 @@
1
+ import json
2
+ from datetime import UTC, datetime
3
+ from pathlib import Path
4
+ from typing import Dict, Any, Optional
5
+
6
+
7
+ class CrumbManager:
8
+ """Manages crumb storage for command shortcuts."""
9
+
10
+ def __init__(self, config_dir: Optional[Path] = None):
11
+ if config_dir is None:
12
+ config_dir = Path.home() / ".ducky"
13
+ self.config_dir = config_dir
14
+ self.crumbs_file = self.config_dir / "crumbs.json"
15
+ self.config_dir.mkdir(parents=True, exist_ok=True)
16
+
17
+ def load_crumbs(self) -> Dict[str, Any]:
18
+ """Load crumbs from JSON file, returning empty dict if not found."""
19
+ if not self.crumbs_file.exists():
20
+ return {}
21
+
22
+ try:
23
+ with open(self.crumbs_file, "r") as f:
24
+ return json.load(f)
25
+ except (json.JSONDecodeError, IOError):
26
+ return {}
27
+
28
+ def save_crumbs(self, crumbs: Dict[str, Any]) -> None:
29
+ """Save crumbs to JSON file."""
30
+ try:
31
+ with open(self.crumbs_file, "w") as f:
32
+ json.dump(crumbs, f, indent=2)
33
+ except IOError as e:
34
+ print(f"Warning: Could not save crumbs: {e}")
35
+
36
+ def save_crumb(
37
+ self,
38
+ name: str,
39
+ prompt: str,
40
+ response: str,
41
+ command: str,
42
+ ) -> None:
43
+ """Add or update a crumb."""
44
+ crumbs = self.load_crumbs()
45
+ crumbs[name] = {
46
+ "prompt": prompt,
47
+ "response": response,
48
+ "command": command,
49
+ "explanation": "",
50
+ "created_at": datetime.now(UTC).isoformat(),
51
+ }
52
+ self.save_crumbs(crumbs)
53
+
54
+ def get_crumb(self, name: str) -> Optional[Dict[str, Any]]:
55
+ """Retrieve a crumb by name."""
56
+ crumbs = self.load_crumbs()
57
+ return crumbs.get(name)
58
+
59
+ def list_crumbs(self) -> Dict[str, Any]:
60
+ """Return all crumbs."""
61
+ return self.load_crumbs()
62
+
63
+ def delete_crumb(self, name: str) -> bool:
64
+ """Remove a crumb. Returns True if deleted, False if not found."""
65
+ crumbs = self.load_crumbs()
66
+ if name in crumbs:
67
+ del crumbs[name]
68
+ self.save_crumbs(crumbs)
69
+ return True
70
+ return False
71
+
72
+ def update_explanation(self, name: str, explanation: str) -> bool:
73
+ """Update explanation for a crumb. Returns True if updated, False if not found."""
74
+ crumbs = self.load_crumbs()
75
+ if name in crumbs:
76
+ crumbs[name]["explanation"] = explanation
77
+ self.save_crumbs(crumbs)
78
+ return True
79
+ return False
80
+
81
+ def has_crumb(self, name: str) -> bool:
82
+ """Check if a crumb exists."""
83
+ crumbs = self.load_crumbs()
84
+ return name in crumbs