closecode 0.1.0__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.
closecode/__init__.py ADDED
@@ -0,0 +1,4 @@
1
+ """Close Code — Terminal AI engineering agent powered by LLMesh."""
2
+
3
+ __version__ = "0.1.0"
4
+ __app_name__ = "Close Code"
closecode/__main__.py ADDED
@@ -0,0 +1,6 @@
1
+ """Entry point for `python -m closecode`."""
2
+
3
+ from closecode.app import main
4
+
5
+ if __name__ == "__main__":
6
+ main()
@@ -0,0 +1,79 @@
1
+ """Agent state — core state model for Close Code.
2
+
3
+ Simplified: just tracks connection, model, messages, and streaming status.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ from enum import Enum
9
+ from typing import List, Dict, Any
10
+ from dataclasses import dataclass, field
11
+ from datetime import datetime
12
+
13
+
14
+ class AgentStatus(Enum):
15
+ """What Close Code is currently doing."""
16
+ IDLE = "idle"
17
+ STREAMING = "streaming"
18
+ FAILED = "failed"
19
+
20
+
21
+ @dataclass
22
+ class ChatMessage:
23
+ """A single chat message."""
24
+ role: str # user | assistant | system
25
+ content: str
26
+ timestamp: datetime = field(default_factory=datetime.now)
27
+ model: str = ""
28
+
29
+
30
+ @dataclass
31
+ class AgentState:
32
+ """Complete state — single source of truth.
33
+
34
+ The Textual UI observes this and renders accordingly.
35
+ """
36
+
37
+ # Status
38
+ status: AgentStatus = AgentStatus.IDLE
39
+ status_message: str = ""
40
+
41
+ # Model
42
+ model: str = ""
43
+ provider: str = ""
44
+
45
+ # Connection
46
+ connected: bool = False
47
+
48
+ # Conversation
49
+ messages: List[ChatMessage] = field(default_factory=list)
50
+
51
+ # Context estimate
52
+ context_used: int = 0
53
+ context_total: int = 128_000
54
+
55
+ def add_message(self, role: str, content: str, **kwargs) -> ChatMessage:
56
+ """Add a message to the conversation."""
57
+ msg = ChatMessage(role=role, content=content, **kwargs)
58
+ self.messages.append(msg)
59
+ return msg
60
+
61
+ def get_messages_for_api(self, system_prompt: str = "") -> List[Dict[str, str]]:
62
+ """Build the message list for the LLMesh API."""
63
+ api_msgs = []
64
+ if system_prompt:
65
+ api_msgs.append({"role": "system", "content": system_prompt})
66
+ for msg in self.messages:
67
+ if msg.role in ("user", "assistant", "system"):
68
+ api_msgs.append({"role": msg.role, "content": msg.content})
69
+ return api_msgs
70
+
71
+ def clear_conversation(self):
72
+ """Clear messages but keep model state."""
73
+ self.messages.clear()
74
+ self.context_used = 0
75
+ self.status = AgentStatus.IDLE
76
+
77
+ @property
78
+ def message_count(self) -> int:
79
+ return len(self.messages)