codenaut 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.
- agent/__init__.py +1 -0
- agent/agent.py +236 -0
- agent/events.py +145 -0
- agent/persistence.py +123 -0
- agent/session.py +99 -0
- client/__init__.py +1 -0
- client/llm_client.py +266 -0
- client/response.py +88 -0
- codenaut-0.1.0.dist-info/METADATA +199 -0
- codenaut-0.1.0.dist-info/RECORD +63 -0
- codenaut-0.1.0.dist-info/WHEEL +5 -0
- codenaut-0.1.0.dist-info/entry_points.txt +3 -0
- codenaut-0.1.0.dist-info/licenses/LICENSE +21 -0
- codenaut-0.1.0.dist-info/top_level.txt +12 -0
- config/__init__.py +1 -0
- config/config.py +173 -0
- config/loader.py +173 -0
- context/__init__.py +1 -0
- context/compaction.py +96 -0
- context/loop_detector.py +49 -0
- context/manager.py +257 -0
- hooks/__init__.py +1 -0
- hooks/hook_system.py +140 -0
- main.py +422 -0
- prompts/__init__.py +1 -0
- prompts/system.py +380 -0
- safety/__init__.py +1 -0
- safety/approval.py +157 -0
- skills/__init__.py +9 -0
- skills/discovery.py +97 -0
- skills/models.py +14 -0
- skills/registry.py +56 -0
- tools/__init__.py +1 -0
- tools/base.py +200 -0
- tools/builtin/__init__.py +67 -0
- tools/builtin/apply_patch.py +388 -0
- tools/builtin/edit_file.py +211 -0
- tools/builtin/glob.py +80 -0
- tools/builtin/grep.py +117 -0
- tools/builtin/list_dir.py +60 -0
- tools/builtin/memory.py +115 -0
- tools/builtin/read_file.py +133 -0
- tools/builtin/shell.py +160 -0
- tools/builtin/tasks.py +336 -0
- tools/builtin/web_fetch.py +55 -0
- tools/builtin/web_search.py +60 -0
- tools/builtin/write_file.py +111 -0
- tools/discovery.py +70 -0
- tools/mcp/__init__.py +1 -0
- tools/mcp/client.py +127 -0
- tools/mcp/mcp_manager.py +83 -0
- tools/mcp/mcp_tool.py +51 -0
- tools/registry.py +156 -0
- tools/subagents.py +148 -0
- ui/__init__.py +12 -0
- ui/completer.py +160 -0
- ui/prompt.py +65 -0
- ui/tui.py +669 -0
- utils/__init__.py +1 -0
- utils/errors.py +49 -0
- utils/file_tags.py +83 -0
- utils/paths.py +40 -0
- utils/text.py +79 -0
main.py
ADDED
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
from langsmith import traceable
|
|
2
|
+
import asyncio
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
import sys
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
|
+
|
|
7
|
+
import click
|
|
8
|
+
|
|
9
|
+
from config.config import ApprovalPolicy, Config
|
|
10
|
+
from config.loader import get_system_config_path, load_config, save_system_config
|
|
11
|
+
from ui.tui import TUI, get_console
|
|
12
|
+
|
|
13
|
+
if TYPE_CHECKING:
|
|
14
|
+
from agent.agent import Agent
|
|
15
|
+
|
|
16
|
+
console = get_console()
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def configure_credentials_interactively(config: Config | None = None) -> Config:
|
|
20
|
+
config = config or load_config(cwd=None)
|
|
21
|
+
current_base_url = config.base_url or ""
|
|
22
|
+
|
|
23
|
+
console.print("[bold]Credential Setup[/bold]")
|
|
24
|
+
api_key = click.prompt("API key", hide_input=True).strip()
|
|
25
|
+
base_url = click.prompt(
|
|
26
|
+
"Base URL (leave blank for provider default)",
|
|
27
|
+
default=current_base_url,
|
|
28
|
+
show_default=bool(current_base_url),
|
|
29
|
+
).strip()
|
|
30
|
+
|
|
31
|
+
save_system_config(
|
|
32
|
+
{
|
|
33
|
+
"api_key": api_key,
|
|
34
|
+
"base_url": base_url or None,
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
config.set_credentials(api_key=api_key, base_url=base_url or None)
|
|
38
|
+
console.print(
|
|
39
|
+
f"[success]Credentials saved to {get_system_config_path()}[/success]"
|
|
40
|
+
)
|
|
41
|
+
return config
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class CLI:
|
|
45
|
+
def __init__(self, config: Config):
|
|
46
|
+
from agent.persistence import PersistenceManager, SessionSnapshot
|
|
47
|
+
from ui.prompt import InteractivePrompt
|
|
48
|
+
|
|
49
|
+
self.agent: Agent | None = None
|
|
50
|
+
self.config = config
|
|
51
|
+
self.tui = TUI(config, console)
|
|
52
|
+
self.interactive_prompt = InteractivePrompt(self.config.cwd)
|
|
53
|
+
self._persistence_manager_cls = PersistenceManager
|
|
54
|
+
self._session_snapshot_cls = SessionSnapshot
|
|
55
|
+
|
|
56
|
+
async def run_single(self, message: str) -> str | None:
|
|
57
|
+
from agent.agent import Agent
|
|
58
|
+
|
|
59
|
+
async with Agent(self.config) as agent:
|
|
60
|
+
self.agent = agent
|
|
61
|
+
return await self._process_message(message)
|
|
62
|
+
|
|
63
|
+
async def run_interactive(self) -> str | None:
|
|
64
|
+
from agent.agent import Agent
|
|
65
|
+
|
|
66
|
+
self.tui.print_welcome(
|
|
67
|
+
"codenaut",
|
|
68
|
+
lines=[
|
|
69
|
+
f"model: {self.config.model_name}",
|
|
70
|
+
f"cwd: {self.config.cwd}",
|
|
71
|
+
"commands: /help /config /approval /setup /model /exit",
|
|
72
|
+
],
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
async with Agent(
|
|
76
|
+
self.config,
|
|
77
|
+
confirmation_callback=self.tui.handle_confirmation,
|
|
78
|
+
) as agent:
|
|
79
|
+
self.agent = agent
|
|
80
|
+
|
|
81
|
+
while True:
|
|
82
|
+
try:
|
|
83
|
+
self.tui.print_current_state()
|
|
84
|
+
console.print()
|
|
85
|
+
user_input = await self.interactive_prompt.get_input()
|
|
86
|
+
if not user_input:
|
|
87
|
+
continue
|
|
88
|
+
|
|
89
|
+
if user_input.startswith("/"):
|
|
90
|
+
should_continue = await self._handle_command(user_input)
|
|
91
|
+
if not should_continue:
|
|
92
|
+
break
|
|
93
|
+
continue
|
|
94
|
+
|
|
95
|
+
await self._process_message(user_input)
|
|
96
|
+
self.interactive_prompt.refresh_completions()
|
|
97
|
+
except KeyboardInterrupt:
|
|
98
|
+
console.print("\n[dim]Use /exit to quit[/dim]")
|
|
99
|
+
except EOFError:
|
|
100
|
+
break
|
|
101
|
+
|
|
102
|
+
console.print("\n[dim]Goodbye![/dim]")
|
|
103
|
+
|
|
104
|
+
def _get_tool_kind(self, tool_name: str) -> str | None:
|
|
105
|
+
tool = self.agent.session.tool_registry.get(tool_name)
|
|
106
|
+
if not tool:
|
|
107
|
+
return None
|
|
108
|
+
return tool.kind.value
|
|
109
|
+
@traceable
|
|
110
|
+
async def _process_message(self, message: str) -> str | None:
|
|
111
|
+
from agent.events import AgentEventType
|
|
112
|
+
from utils.file_tags import resolve_file_tags
|
|
113
|
+
from utils.paths import display_path_rel_to_cwd
|
|
114
|
+
|
|
115
|
+
if not self.agent:
|
|
116
|
+
return None
|
|
117
|
+
|
|
118
|
+
enriched_message, tagged_files = resolve_file_tags(message, self.config.cwd)
|
|
119
|
+
if tagged_files:
|
|
120
|
+
file_names = ", ".join(
|
|
121
|
+
display_path_rel_to_cwd(str(f), self.config.cwd) for f in tagged_files
|
|
122
|
+
)
|
|
123
|
+
console.print(f"[dim]📎 Tagged {len(tagged_files)} file(s): {file_names}[/dim]")
|
|
124
|
+
message = enriched_message
|
|
125
|
+
|
|
126
|
+
assistant_streaming = True
|
|
127
|
+
final_response: str | None = None
|
|
128
|
+
|
|
129
|
+
async for event in self.agent.run(message):
|
|
130
|
+
if event.type == AgentEventType.TEXT_DELTA:
|
|
131
|
+
content = event.data.get("content", "")
|
|
132
|
+
if not assistant_streaming:
|
|
133
|
+
self.tui.begin_assistant()
|
|
134
|
+
assistant_streaming = True
|
|
135
|
+
self.tui.stream_assistant_delta(content)
|
|
136
|
+
elif event.type == AgentEventType.TEXT_COMPLETE:
|
|
137
|
+
final_response = event.data.get("content")
|
|
138
|
+
if assistant_streaming:
|
|
139
|
+
self.tui.end_assistant()
|
|
140
|
+
assistant_streaming = False
|
|
141
|
+
elif event.type == AgentEventType.AGENT_ERROR:
|
|
142
|
+
error = event.data.get("error", "Unknown error")
|
|
143
|
+
console.print(f"\n[error]Error: {error}[/error]")
|
|
144
|
+
elif event.type == AgentEventType.COMPACTION_START:
|
|
145
|
+
console.print("\n[dim]Compacting conversation context...[/dim]")
|
|
146
|
+
elif event.type == AgentEventType.COMPACTION_COMPLETE:
|
|
147
|
+
console.print("[success]Context compacted.[/success]")
|
|
148
|
+
elif event.type == AgentEventType.COMPACTION_ERROR:
|
|
149
|
+
error = event.data.get("error", "Compaction failed")
|
|
150
|
+
console.print(f"\n[error]Context compaction failed: {error}[/error]")
|
|
151
|
+
elif event.type == AgentEventType.TOOL_CALL_START:
|
|
152
|
+
tool_name = event.data.get("name", "unknown")
|
|
153
|
+
tool_kind = self._get_tool_kind(tool_name)
|
|
154
|
+
self.tui.tool_call_start(
|
|
155
|
+
event.data.get("call_id", ""),
|
|
156
|
+
tool_name,
|
|
157
|
+
tool_kind,
|
|
158
|
+
event.data.get("arguments", {}),
|
|
159
|
+
)
|
|
160
|
+
elif event.type == AgentEventType.TOOL_CALL_COMPLETE:
|
|
161
|
+
tool_name = event.data.get("name", "unknown")
|
|
162
|
+
tool_kind = self._get_tool_kind(tool_name)
|
|
163
|
+
self.tui.tool_call_complete(
|
|
164
|
+
event.data.get("call_id", ""),
|
|
165
|
+
tool_name,
|
|
166
|
+
tool_kind,
|
|
167
|
+
event.data.get("success", False),
|
|
168
|
+
event.data.get("output", ""),
|
|
169
|
+
event.data.get("error"),
|
|
170
|
+
event.data.get("metadata"),
|
|
171
|
+
event.data.get("diff"),
|
|
172
|
+
event.data.get("truncated", False),
|
|
173
|
+
event.data.get("exit_code"),
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
return final_response
|
|
177
|
+
|
|
178
|
+
async def _handle_command(self, command: str) -> bool:
|
|
179
|
+
cmd = command.lower().strip()
|
|
180
|
+
parts = cmd.split(maxsplit=1)
|
|
181
|
+
cmd_name = parts[0]
|
|
182
|
+
cmd_args = parts[1] if len(parts) > 1 else ""
|
|
183
|
+
if cmd_name == "/exit" or cmd_name == "/quit":
|
|
184
|
+
return False
|
|
185
|
+
elif command == "/help":
|
|
186
|
+
self.tui.show_help()
|
|
187
|
+
elif command == "/clear":
|
|
188
|
+
self.agent.session.context_manager.clear()
|
|
189
|
+
self.agent.session.loop_detector.clear()
|
|
190
|
+
console.print("[success]Conversation cleared [/success]")
|
|
191
|
+
elif command == "/config":
|
|
192
|
+
console.print("\n[bold]Current Configuration[/bold]")
|
|
193
|
+
console.print(f" Model: {self.config.model_name}")
|
|
194
|
+
console.print(f" Temperature: {self.config.temperature}")
|
|
195
|
+
console.print(f" Approval: {self.config.approval.value}")
|
|
196
|
+
console.print(f" Working Dir: {self.config.cwd}")
|
|
197
|
+
console.print(f" Max Turns: {self.config.max_turns}")
|
|
198
|
+
console.print(f" Hooks Enabled: {self.config.hooks_enabled}")
|
|
199
|
+
console.print(f" Base URL: {self.config.base_url or 'provider default'}")
|
|
200
|
+
elif cmd_name == "/model":
|
|
201
|
+
if cmd_args:
|
|
202
|
+
self.config.model_name = cmd_args
|
|
203
|
+
console.print(f"[success]Model changed to: {cmd_args} [/success]")
|
|
204
|
+
else:
|
|
205
|
+
console.print(f"Current model: {self.config.model_name}")
|
|
206
|
+
elif cmd_name == "/approval":
|
|
207
|
+
if cmd_args:
|
|
208
|
+
try:
|
|
209
|
+
approval = ApprovalPolicy(cmd_args)
|
|
210
|
+
self.config.approval = approval
|
|
211
|
+
console.print(
|
|
212
|
+
f"[success]Approval policy changed to: {cmd_args} [/success]"
|
|
213
|
+
)
|
|
214
|
+
except ValueError:
|
|
215
|
+
console.print(
|
|
216
|
+
f"[error]Incorrect approval policy: {cmd_args} [/error]"
|
|
217
|
+
)
|
|
218
|
+
console.print(
|
|
219
|
+
f"Valid options: {', '.join(p.value for p in ApprovalPolicy)}"
|
|
220
|
+
)
|
|
221
|
+
else:
|
|
222
|
+
console.print(f"Current approval policy: {self.config.approval.value}")
|
|
223
|
+
elif cmd_name == "/setup":
|
|
224
|
+
self.config = configure_credentials_interactively(self.config)
|
|
225
|
+
self.tui = TUI(self.config, console)
|
|
226
|
+
elif cmd_name == "/stats":
|
|
227
|
+
stats = self.agent.session.get_stats()
|
|
228
|
+
console.print("\n[bold]Session Statistics [/bold]")
|
|
229
|
+
for key, value in stats.items():
|
|
230
|
+
console.print(f" {key}: {value}")
|
|
231
|
+
elif cmd_name == "/tools":
|
|
232
|
+
tools = self.agent.session.tool_registry.get_tools()
|
|
233
|
+
console.print(f"\n[bold]Available tools ({len(tools)}) [/bold]")
|
|
234
|
+
for tool in tools:
|
|
235
|
+
console.print(f" • {tool.name}")
|
|
236
|
+
elif cmd_name == "/mcp":
|
|
237
|
+
mcp_servers = self.agent.session.mcp_manager.get_all_servers()
|
|
238
|
+
console.print(f"\n[bold]MCP Servers ({len(mcp_servers)}) [/bold]")
|
|
239
|
+
for server in mcp_servers:
|
|
240
|
+
status = server["status"]
|
|
241
|
+
status_color = "green" if status == "connected" else "red"
|
|
242
|
+
console.print(
|
|
243
|
+
f" • {server['name']}: [{status_color}]{status}[/{status_color}] ({server['tools']} tools)"
|
|
244
|
+
)
|
|
245
|
+
elif cmd_name == "/save":
|
|
246
|
+
persistence_manager = self._persistence_manager_cls()
|
|
247
|
+
session_snapshot = self._session_snapshot_cls(
|
|
248
|
+
session_id=self.agent.session.session_id,
|
|
249
|
+
created_at=self.agent.session.created_at,
|
|
250
|
+
updated_at=self.agent.session.updated_at,
|
|
251
|
+
turn_count=self.agent.session.turn_count,
|
|
252
|
+
messages=self.agent.session.context_manager.get_messages(),
|
|
253
|
+
total_usage=self.agent.session.context_manager.total_usage,
|
|
254
|
+
)
|
|
255
|
+
persistence_manager.save_session(session_snapshot)
|
|
256
|
+
console.print(
|
|
257
|
+
f"[success]Session saved: {self.agent.session.session_id}[/success]"
|
|
258
|
+
)
|
|
259
|
+
elif cmd_name == "/sessions":
|
|
260
|
+
persistence_manager = self._persistence_manager_cls()
|
|
261
|
+
sessions = persistence_manager.list_sessions()
|
|
262
|
+
console.print("\n[bold]Saved Sessions[/bold]")
|
|
263
|
+
for saved_session in sessions:
|
|
264
|
+
console.print(
|
|
265
|
+
f" • {saved_session['session_id']} (turns: {saved_session['turn_count']}, updated: {saved_session['updated_at']})"
|
|
266
|
+
)
|
|
267
|
+
elif cmd_name == "/resume":
|
|
268
|
+
if not cmd_args:
|
|
269
|
+
console.print("[error]Usage: /resume <session_id> [/error]")
|
|
270
|
+
else:
|
|
271
|
+
from agent.session import Session
|
|
272
|
+
|
|
273
|
+
persistence_manager = self._persistence_manager_cls()
|
|
274
|
+
snapshot = persistence_manager.load_session(cmd_args)
|
|
275
|
+
if not snapshot:
|
|
276
|
+
console.print("[error]Session does not exist [/error]")
|
|
277
|
+
else:
|
|
278
|
+
session = Session(config=self.config)
|
|
279
|
+
await session.initialize()
|
|
280
|
+
session.session_id = snapshot.session_id
|
|
281
|
+
session.created_at = snapshot.created_at
|
|
282
|
+
session.updated_at = snapshot.updated_at
|
|
283
|
+
session.turn_count = snapshot.turn_count
|
|
284
|
+
session.context_manager.total_usage = snapshot.total_usage
|
|
285
|
+
|
|
286
|
+
for msg in snapshot.messages:
|
|
287
|
+
if msg.get("role") == "system":
|
|
288
|
+
continue
|
|
289
|
+
elif msg["role"] == "user":
|
|
290
|
+
session.context_manager.add_user_message(
|
|
291
|
+
msg.get("content", "")
|
|
292
|
+
)
|
|
293
|
+
elif msg["role"] == "assistant":
|
|
294
|
+
session.context_manager.add_assistant_message(
|
|
295
|
+
msg.get("content", ""),
|
|
296
|
+
msg.get("tool_calls"),
|
|
297
|
+
)
|
|
298
|
+
elif msg["role"] == "tool":
|
|
299
|
+
session.context_manager.add_tool_result(
|
|
300
|
+
msg.get("tool_call_id", ""),
|
|
301
|
+
msg.get("content", ""),
|
|
302
|
+
)
|
|
303
|
+
|
|
304
|
+
await self.agent.session.client.close()
|
|
305
|
+
await self.agent.session.mcp_manager.shutdown()
|
|
306
|
+
|
|
307
|
+
self.agent.session = session
|
|
308
|
+
console.print(
|
|
309
|
+
f"[success]Resumed session: {session.session_id}[/success]"
|
|
310
|
+
)
|
|
311
|
+
elif cmd_name == "/checkpoint":
|
|
312
|
+
persistence_manager = self._persistence_manager_cls()
|
|
313
|
+
session_snapshot = self._session_snapshot_cls(
|
|
314
|
+
session_id=self.agent.session.session_id,
|
|
315
|
+
created_at=self.agent.session.created_at,
|
|
316
|
+
updated_at=self.agent.session.updated_at,
|
|
317
|
+
turn_count=self.agent.session.turn_count,
|
|
318
|
+
messages=self.agent.session.context_manager.get_messages(),
|
|
319
|
+
total_usage=self.agent.session.context_manager.total_usage,
|
|
320
|
+
)
|
|
321
|
+
checkpoint_id = persistence_manager.save_checkpoint(session_snapshot)
|
|
322
|
+
console.print(f"[success]Checkpoint created: {checkpoint_id}[/success]")
|
|
323
|
+
elif cmd_name == "/restore":
|
|
324
|
+
if not cmd_args:
|
|
325
|
+
console.print("[error]Usage: /restore <checkpoint_id> [/error]")
|
|
326
|
+
else:
|
|
327
|
+
from agent.session import Session
|
|
328
|
+
|
|
329
|
+
persistence_manager = self._persistence_manager_cls()
|
|
330
|
+
snapshot = persistence_manager.load_checkpoint(cmd_args)
|
|
331
|
+
if not snapshot:
|
|
332
|
+
console.print("[error]Checkpoint does not exist [/error]")
|
|
333
|
+
else:
|
|
334
|
+
session = Session(config=self.config)
|
|
335
|
+
await session.initialize()
|
|
336
|
+
session.session_id = snapshot.session_id
|
|
337
|
+
session.created_at = snapshot.created_at
|
|
338
|
+
session.updated_at = snapshot.updated_at
|
|
339
|
+
session.turn_count = snapshot.turn_count
|
|
340
|
+
session.context_manager.total_usage = snapshot.total_usage
|
|
341
|
+
|
|
342
|
+
for msg in snapshot.messages:
|
|
343
|
+
if msg.get("role") == "system":
|
|
344
|
+
continue
|
|
345
|
+
elif msg["role"] == "user":
|
|
346
|
+
session.context_manager.add_user_message(
|
|
347
|
+
msg.get("content", "")
|
|
348
|
+
)
|
|
349
|
+
elif msg["role"] == "assistant":
|
|
350
|
+
session.context_manager.add_assistant_message(
|
|
351
|
+
msg.get("content", ""),
|
|
352
|
+
msg.get("tool_calls"),
|
|
353
|
+
)
|
|
354
|
+
elif msg["role"] == "tool":
|
|
355
|
+
session.context_manager.add_tool_result(
|
|
356
|
+
msg.get("tool_call_id", ""),
|
|
357
|
+
msg.get("content", ""),
|
|
358
|
+
)
|
|
359
|
+
|
|
360
|
+
await self.agent.session.client.close()
|
|
361
|
+
await self.agent.session.mcp_manager.shutdown()
|
|
362
|
+
|
|
363
|
+
self.agent.session = session
|
|
364
|
+
console.print(
|
|
365
|
+
f"[success]Resumed session: {session.session_id}, checkpoint: {cmd_args}[/success]"
|
|
366
|
+
)
|
|
367
|
+
else:
|
|
368
|
+
console.print(f"[error]Unknown command: {cmd_name}[/error]")
|
|
369
|
+
|
|
370
|
+
return True
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
@click.command()
|
|
374
|
+
@click.argument("prompt", required=False)
|
|
375
|
+
@click.option(
|
|
376
|
+
"--cwd",
|
|
377
|
+
"-c",
|
|
378
|
+
type=click.Path(exists=True, file_okay=False, path_type=Path),
|
|
379
|
+
help="Current working directory",
|
|
380
|
+
)
|
|
381
|
+
@click.option(
|
|
382
|
+
"--configure",
|
|
383
|
+
is_flag=True,
|
|
384
|
+
help="Prompt for API credentials and save them to the user config file.",
|
|
385
|
+
)
|
|
386
|
+
def main(prompt: str | None, cwd: Path | None, configure: bool) -> None:
|
|
387
|
+
try:
|
|
388
|
+
config = load_config(cwd=cwd)
|
|
389
|
+
except Exception as error:
|
|
390
|
+
console.print(f"[error]Configuration Error: {error}[/error]")
|
|
391
|
+
sys.exit(1)
|
|
392
|
+
|
|
393
|
+
if configure:
|
|
394
|
+
configure_credentials_interactively(config)
|
|
395
|
+
return
|
|
396
|
+
|
|
397
|
+
if not config.api_key:
|
|
398
|
+
if click.confirm("No API key configured. Set it up now?", default=True):
|
|
399
|
+
config = configure_credentials_interactively(config)
|
|
400
|
+
else:
|
|
401
|
+
console.print(
|
|
402
|
+
"[error]No API key found. Run `codenaut --configure` to save one.[/error]"
|
|
403
|
+
)
|
|
404
|
+
sys.exit(1)
|
|
405
|
+
|
|
406
|
+
errors = config.validate()
|
|
407
|
+
if errors:
|
|
408
|
+
for error in errors:
|
|
409
|
+
console.print(f"[error]{error}[/error]")
|
|
410
|
+
sys.exit(1)
|
|
411
|
+
|
|
412
|
+
cli = CLI(config)
|
|
413
|
+
if prompt:
|
|
414
|
+
result = asyncio.run(cli.run_single(prompt))
|
|
415
|
+
if result is None:
|
|
416
|
+
sys.exit(1)
|
|
417
|
+
else:
|
|
418
|
+
asyncio.run(cli.run_interactive())
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
if __name__ == "__main__":
|
|
422
|
+
main()
|
prompts/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Prompt templates and builders."""
|