@hyperspell/openclaw-hyperspell 0.7.2 → 0.8.0

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,76 +0,0 @@
1
- # /// script
2
- # requires-python = ">=3.11"
3
- # dependencies = []
4
- # ///
5
- """
6
- Rate a wine recommendation to improve future suggestions.
7
- """
8
-
9
- import argparse
10
- import json
11
- import sys
12
- from datetime import datetime, timezone
13
- from pathlib import Path
14
-
15
- from wine_db import WINE_DB
16
-
17
- CONFIG_DIR = Path.home() / ".sommeliagent"
18
- RATINGS_FILE = CONFIG_DIR / "ratings.json"
19
-
20
- # Wine ID → tags mapping (derived from wine_db)
21
- WINE_TAGS = {w.id: w.tags for w in WINE_DB}
22
-
23
-
24
- def load_ratings() -> list[dict]:
25
- if RATINGS_FILE.exists():
26
- try:
27
- return json.loads(RATINGS_FILE.read_text())
28
- except (OSError, json.JSONDecodeError) as e:
29
- print(f"Warning: could not read {RATINGS_FILE}: {e}", file=sys.stderr)
30
- return []
31
- return []
32
-
33
-
34
- def save_ratings(ratings: list[dict]) -> None:
35
- import stat
36
- CONFIG_DIR.mkdir(parents=True, exist_ok=True)
37
- tmp = RATINGS_FILE.with_suffix(".tmp")
38
- tmp.write_text(json.dumps(ratings, indent=2))
39
- tmp.chmod(stat.S_IRUSR | stat.S_IWUSR)
40
- tmp.replace(RATINGS_FILE)
41
-
42
-
43
- def main():
44
- parser = argparse.ArgumentParser(description="Rate a wine recommendation")
45
- parser.add_argument("--wine-id", required=True, help="Wine ID from recommendation")
46
- parser.add_argument("--rating", type=int, required=True, choices=[1, 2, 3, 4, 5], help="Rating 1-5")
47
- parser.add_argument("--notes", default="", help="Optional tasting notes")
48
- args = parser.parse_args()
49
-
50
- tags = WINE_TAGS.get(args.wine_id)
51
- if tags is None:
52
- valid_ids = ", ".join(sorted(WINE_TAGS.keys()))
53
- print(f"Error: Unknown wine ID '{args.wine_id}'.", file=sys.stderr)
54
- print(f"Valid IDs: {valid_ids}", file=sys.stderr)
55
- sys.exit(1)
56
-
57
- ratings = load_ratings()
58
- ratings.append({
59
- "wine_id": args.wine_id,
60
- "rating": args.rating,
61
- "notes": args.notes,
62
- "tags": tags,
63
- "timestamp": datetime.now(timezone.utc).isoformat(),
64
- })
65
- save_ratings(ratings)
66
-
67
- label = {1: "hated it", 2: "not great", 3: "okay", 4: "liked it", 5: "loved it"}
68
- print(f"Rated {args.wine_id}: {args.rating}/5 ({label[args.rating]})")
69
- if args.notes:
70
- print(f"Notes: \"{args.notes}\"")
71
- print(f"Total ratings: {len(ratings)}")
72
- print("Future recommendations will factor this in.")
73
-
74
-
75
- if __name__ == "__main__":
76
- main()