@heytherevibin/skillforge 0.2.1 → 0.7.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.
package/python/app/cli.py DELETED
@@ -1,78 +0,0 @@
1
- """Dev harness: terminal client for POST /chat (requires `skillforge start` + API key)."""
2
- import argparse
3
- import json
4
- import sys
5
- import uuid
6
-
7
- import httpx
8
-
9
-
10
- def main():
11
- ap = argparse.ArgumentParser()
12
- ap.add_argument("--url", default="http://localhost:8000")
13
- args = ap.parse_args()
14
-
15
- session_id = str(uuid.uuid4())
16
- conversation = []
17
- print(f"\nskillforge chat — session {session_id[:8]}")
18
- print("Commands: 'exit' to quit, 'reset' for new session\n")
19
-
20
- while True:
21
- try:
22
- prompt = input("you ▸ ").strip()
23
- except (EOFError, KeyboardInterrupt):
24
- print()
25
- break
26
- if not prompt:
27
- continue
28
- if prompt == "exit":
29
- break
30
- if prompt == "reset":
31
- session_id = str(uuid.uuid4())
32
- conversation = []
33
- print(f"[new session: {session_id[:8]}]\n")
34
- continue
35
-
36
- full = []
37
- picked = []
38
- try:
39
- with httpx.stream(
40
- "POST",
41
- f"{args.url}/chat",
42
- json={"prompt": prompt, "session_id": session_id, "conversation": conversation},
43
- timeout=120.0,
44
- ) as r:
45
- if r.status_code != 200:
46
- print(f"[error {r.status_code}] {r.read().decode()}")
47
- continue
48
- print("claude ▸ ", end="", flush=True)
49
- for line in r.iter_lines():
50
- if not line.startswith("data: "):
51
- continue
52
- try:
53
- data = json.loads(line[6:])
54
- except json.JSONDecodeError:
55
- continue
56
- if "delta" in data:
57
- sys.stdout.write(data["delta"])
58
- sys.stdout.flush()
59
- full.append(data["delta"])
60
- elif "done" in data:
61
- picked = data.get("picked", [])
62
- elif "error" in data:
63
- print(f"\n[stream error] {data['error']}")
64
- except httpx.HTTPError as e:
65
- print(f"\n[connection error] {e}")
66
- print("Is the server running? Try: skillforge start")
67
- continue
68
-
69
- print()
70
- if picked:
71
- print(f" \033[2m↳ skills used: {', '.join(picked)}\033[0m")
72
- print()
73
- conversation.append({"role": "user", "content": prompt})
74
- conversation.append({"role": "assistant", "content": "".join(full)})
75
-
76
-
77
- if __name__ == "__main__":
78
- main()