tunacode-cli 0.0.27__py3-none-any.whl → 0.0.29__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.
Potentially problematic release.
This version of tunacode-cli might be problematic. Click here for more details.
- tunacode/cli/commands.py +83 -4
- tunacode/configuration/defaults.py +1 -0
- tunacode/constants.py +1 -1
- tunacode/core/agents/main.py +83 -2
- tunacode/core/agents/orchestrator.py +109 -13
- tunacode/core/agents/readonly.py +18 -4
- tunacode/ui/output.py +1 -1
- tunacode_cli-0.0.29.dist-info/METADATA +121 -0
- {tunacode_cli-0.0.27.dist-info → tunacode_cli-0.0.29.dist-info}/RECORD +13 -13
- tunacode_cli-0.0.27.dist-info/METADATA +0 -567
- {tunacode_cli-0.0.27.dist-info → tunacode_cli-0.0.29.dist-info}/WHEEL +0 -0
- {tunacode_cli-0.0.27.dist-info → tunacode_cli-0.0.29.dist-info}/entry_points.txt +0 -0
- {tunacode_cli-0.0.27.dist-info → tunacode_cli-0.0.29.dist-info}/licenses/LICENSE +0 -0
- {tunacode_cli-0.0.27.dist-info → tunacode_cli-0.0.29.dist-info}/top_level.txt +0 -0
tunacode/cli/commands.py
CHANGED
|
@@ -521,13 +521,92 @@ class CompactCommand(SimpleCommand):
|
|
|
521
521
|
await ui.error("Compact command not available - process_request not configured")
|
|
522
522
|
return
|
|
523
523
|
|
|
524
|
-
#
|
|
525
|
-
|
|
526
|
-
|
|
524
|
+
# Count current messages
|
|
525
|
+
original_count = len(context.state_manager.session.messages)
|
|
526
|
+
|
|
527
|
+
# Generate summary with output captured
|
|
528
|
+
summary_prompt = (
|
|
529
|
+
"Summarize the conversation so far in a concise paragraph, "
|
|
530
|
+
"focusing on the main topics discussed and any important context "
|
|
531
|
+
"that should be preserved."
|
|
527
532
|
)
|
|
528
|
-
await
|
|
533
|
+
result = await process_request(
|
|
534
|
+
summary_prompt,
|
|
535
|
+
context.state_manager,
|
|
536
|
+
output=False, # We'll handle the output ourselves
|
|
537
|
+
)
|
|
538
|
+
|
|
539
|
+
# Extract summary text from result
|
|
540
|
+
summary_text = ""
|
|
541
|
+
|
|
542
|
+
# First try: standard result structure
|
|
543
|
+
if (
|
|
544
|
+
result
|
|
545
|
+
and hasattr(result, "result")
|
|
546
|
+
and result.result
|
|
547
|
+
and hasattr(result.result, "output")
|
|
548
|
+
):
|
|
549
|
+
summary_text = result.result.output
|
|
550
|
+
|
|
551
|
+
# Second try: check messages for assistant response
|
|
552
|
+
if not summary_text:
|
|
553
|
+
messages = context.state_manager.session.messages
|
|
554
|
+
# Look through new messages in reverse order
|
|
555
|
+
for i in range(len(messages) - 1, original_count - 1, -1):
|
|
556
|
+
msg = messages[i]
|
|
557
|
+
# Handle ModelResponse objects
|
|
558
|
+
if hasattr(msg, "parts") and msg.parts:
|
|
559
|
+
for part in msg.parts:
|
|
560
|
+
if hasattr(part, "content") and part.content:
|
|
561
|
+
content = part.content
|
|
562
|
+
# Skip JSON thought objects
|
|
563
|
+
if content.strip().startswith('{"thought"'):
|
|
564
|
+
lines = content.split("\n")
|
|
565
|
+
# Find the actual summary after the JSON
|
|
566
|
+
for i, line in enumerate(lines):
|
|
567
|
+
if (
|
|
568
|
+
line.strip()
|
|
569
|
+
and not line.strip().startswith("{")
|
|
570
|
+
and not line.strip().endswith("}")
|
|
571
|
+
):
|
|
572
|
+
summary_text = "\n".join(lines[i:]).strip()
|
|
573
|
+
break
|
|
574
|
+
else:
|
|
575
|
+
summary_text = content
|
|
576
|
+
if summary_text:
|
|
577
|
+
break
|
|
578
|
+
# Handle dict-style messages
|
|
579
|
+
elif isinstance(msg, dict):
|
|
580
|
+
if msg.get("role") == "assistant" and msg.get("content"):
|
|
581
|
+
summary_text = msg["content"]
|
|
582
|
+
break
|
|
583
|
+
# Handle other message types
|
|
584
|
+
elif hasattr(msg, "content") and hasattr(msg, "role"):
|
|
585
|
+
if getattr(msg, "role", None) == "assistant":
|
|
586
|
+
summary_text = msg.content
|
|
587
|
+
break
|
|
588
|
+
|
|
589
|
+
if summary_text:
|
|
590
|
+
break
|
|
591
|
+
|
|
592
|
+
if not summary_text:
|
|
593
|
+
await ui.error("Failed to generate summary - no assistant response found")
|
|
594
|
+
return
|
|
595
|
+
|
|
596
|
+
# Display summary in a formatted panel
|
|
597
|
+
from tunacode.ui import panels
|
|
598
|
+
|
|
599
|
+
await panels.panel("Conversation Summary", summary_text, border_style="cyan")
|
|
600
|
+
|
|
601
|
+
# Show statistics
|
|
602
|
+
await ui.info(f"Current message count: {original_count}")
|
|
603
|
+
await ui.info("After compaction: 3 (summary + last 2 messages)")
|
|
604
|
+
|
|
605
|
+
# Truncate the conversation history
|
|
529
606
|
context.state_manager.session.messages = context.state_manager.session.messages[-2:]
|
|
530
607
|
|
|
608
|
+
await ui.success("Context history has been summarized and truncated.")
|
|
609
|
+
|
|
531
610
|
|
|
532
611
|
class UpdateCommand(SimpleCommand):
|
|
533
612
|
"""Update TunaCode to the latest version."""
|
tunacode/constants.py
CHANGED
tunacode/core/agents/main.py
CHANGED
|
@@ -375,10 +375,91 @@ async def process_request(
|
|
|
375
375
|
if not response_state.has_user_response and i >= max_iterations and fallback_enabled:
|
|
376
376
|
patch_tool_messages("Task incomplete", state_manager=state_manager)
|
|
377
377
|
response_state.has_final_synthesis = True
|
|
378
|
+
|
|
379
|
+
# Extract context from the agent run
|
|
380
|
+
tool_calls_summary = []
|
|
381
|
+
files_modified = set()
|
|
382
|
+
commands_run = []
|
|
383
|
+
|
|
384
|
+
# Analyze message history for context
|
|
385
|
+
for msg in state_manager.session.messages:
|
|
386
|
+
if hasattr(msg, "parts"):
|
|
387
|
+
for part in msg.parts:
|
|
388
|
+
if hasattr(part, "part_kind") and part.part_kind == "tool-call":
|
|
389
|
+
tool_name = getattr(part, "tool_name", "unknown")
|
|
390
|
+
tool_calls_summary.append(tool_name)
|
|
391
|
+
|
|
392
|
+
# Track specific operations
|
|
393
|
+
if tool_name in ["write_file", "update_file"] and hasattr(part, "args"):
|
|
394
|
+
if "file_path" in part.args:
|
|
395
|
+
files_modified.add(part.args["file_path"])
|
|
396
|
+
elif tool_name in ["run_command", "bash"] and hasattr(part, "args"):
|
|
397
|
+
if "command" in part.args:
|
|
398
|
+
commands_run.append(part.args["command"])
|
|
399
|
+
|
|
400
|
+
# Build fallback response with context
|
|
378
401
|
fallback = FallbackResponse(
|
|
379
402
|
summary="Reached maximum iterations without producing a final response.",
|
|
380
|
-
progress=f"{i}
|
|
403
|
+
progress=f"Completed {i} iterations (limit: {max_iterations})",
|
|
404
|
+
)
|
|
405
|
+
|
|
406
|
+
# Get verbosity setting
|
|
407
|
+
verbosity = state_manager.session.user_config.get("settings", {}).get(
|
|
408
|
+
"fallback_verbosity", "normal"
|
|
409
|
+
)
|
|
410
|
+
|
|
411
|
+
if verbosity in ["normal", "detailed"]:
|
|
412
|
+
# Add what was attempted
|
|
413
|
+
if tool_calls_summary:
|
|
414
|
+
tool_counts = {}
|
|
415
|
+
for tool in tool_calls_summary:
|
|
416
|
+
tool_counts[tool] = tool_counts.get(tool, 0) + 1
|
|
417
|
+
|
|
418
|
+
fallback.issues.append(f"Executed {len(tool_calls_summary)} tool calls:")
|
|
419
|
+
for tool, count in sorted(tool_counts.items()):
|
|
420
|
+
fallback.issues.append(f" • {tool}: {count}x")
|
|
421
|
+
|
|
422
|
+
if verbosity == "detailed":
|
|
423
|
+
if files_modified:
|
|
424
|
+
fallback.issues.append(f"\nFiles modified ({len(files_modified)}):")
|
|
425
|
+
for f in sorted(files_modified)[:5]: # Limit to 5 files
|
|
426
|
+
fallback.issues.append(f" • {f}")
|
|
427
|
+
if len(files_modified) > 5:
|
|
428
|
+
fallback.issues.append(f" • ... and {len(files_modified) - 5} more")
|
|
429
|
+
|
|
430
|
+
if commands_run:
|
|
431
|
+
fallback.issues.append(f"\nCommands executed ({len(commands_run)}):")
|
|
432
|
+
for cmd in commands_run[:3]: # Limit to 3 commands
|
|
433
|
+
# Truncate long commands
|
|
434
|
+
display_cmd = cmd if len(cmd) <= 60 else cmd[:57] + "..."
|
|
435
|
+
fallback.issues.append(f" • {display_cmd}")
|
|
436
|
+
if len(commands_run) > 3:
|
|
437
|
+
fallback.issues.append(f" • ... and {len(commands_run) - 3} more")
|
|
438
|
+
|
|
439
|
+
# Add helpful next steps
|
|
440
|
+
fallback.next_steps.append(
|
|
441
|
+
"The task may be too complex - try breaking it into smaller steps"
|
|
381
442
|
)
|
|
443
|
+
fallback.next_steps.append("Check the output above for any errors or partial progress")
|
|
444
|
+
if files_modified:
|
|
445
|
+
fallback.next_steps.append("Review modified files to see what changes were made")
|
|
446
|
+
|
|
447
|
+
# Create comprehensive output
|
|
448
|
+
output_parts = [fallback.summary, ""]
|
|
449
|
+
|
|
450
|
+
if fallback.progress:
|
|
451
|
+
output_parts.append(f"Progress: {fallback.progress}")
|
|
452
|
+
|
|
453
|
+
if fallback.issues:
|
|
454
|
+
output_parts.append("\nWhat happened:")
|
|
455
|
+
output_parts.extend(fallback.issues)
|
|
456
|
+
|
|
457
|
+
if fallback.next_steps:
|
|
458
|
+
output_parts.append("\nSuggested next steps:")
|
|
459
|
+
for step in fallback.next_steps:
|
|
460
|
+
output_parts.append(f" • {step}")
|
|
461
|
+
|
|
462
|
+
comprehensive_output = "\n".join(output_parts)
|
|
382
463
|
|
|
383
464
|
# Create a wrapper object that mimics AgentRun with the required attributes
|
|
384
465
|
class AgentRunWrapper:
|
|
@@ -391,7 +472,7 @@ async def process_request(
|
|
|
391
472
|
# Delegate all other attributes to the wrapped object
|
|
392
473
|
return getattr(self._wrapped, name)
|
|
393
474
|
|
|
394
|
-
return AgentRunWrapper(agent_run, SimpleResult(
|
|
475
|
+
return AgentRunWrapper(agent_run, SimpleResult(comprehensive_output))
|
|
395
476
|
|
|
396
477
|
# For non-fallback cases, we still need to handle the response_state
|
|
397
478
|
# Create a minimal wrapper just to add response_state
|
|
@@ -13,7 +13,7 @@ import asyncio
|
|
|
13
13
|
import itertools
|
|
14
14
|
from typing import List
|
|
15
15
|
|
|
16
|
-
from ...types import AgentRun, ModelName
|
|
16
|
+
from ...types import AgentRun, FallbackResponse, ModelName, ResponseState
|
|
17
17
|
from ..llm.planner import make_plan
|
|
18
18
|
from ..state import StateManager
|
|
19
19
|
from . import main as agent_main
|
|
@@ -69,6 +69,9 @@ class OrchestratorAgent:
|
|
|
69
69
|
console = Console()
|
|
70
70
|
model = model or self.state.session.current_model
|
|
71
71
|
|
|
72
|
+
# Track response state across all sub-tasks
|
|
73
|
+
response_state = ResponseState()
|
|
74
|
+
|
|
72
75
|
# Show orchestrator is starting
|
|
73
76
|
console.print(
|
|
74
77
|
"\n[cyan]Orchestrator Mode: Analyzing request and creating execution plan...[/cyan]"
|
|
@@ -80,10 +83,28 @@ class OrchestratorAgent:
|
|
|
80
83
|
console.print(f"\n[cyan]Executing plan with {len(tasks)} tasks...[/cyan]")
|
|
81
84
|
|
|
82
85
|
results: List[AgentRun] = []
|
|
86
|
+
task_progress = []
|
|
87
|
+
|
|
83
88
|
for mutate_flag, group in itertools.groupby(tasks, key=lambda t: t.mutate):
|
|
84
89
|
if mutate_flag:
|
|
85
90
|
for t in group:
|
|
86
|
-
|
|
91
|
+
result = await self._run_sub_task(t, model)
|
|
92
|
+
results.append(result)
|
|
93
|
+
|
|
94
|
+
# Track task progress
|
|
95
|
+
task_progress.append(
|
|
96
|
+
{
|
|
97
|
+
"task": t,
|
|
98
|
+
"completed": True,
|
|
99
|
+
"had_output": hasattr(result, "result")
|
|
100
|
+
and result.result
|
|
101
|
+
and getattr(result.result, "output", None),
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
# Check if this task produced user-visible output
|
|
106
|
+
if hasattr(result, "response_state"):
|
|
107
|
+
response_state.has_user_response |= result.response_state.has_user_response
|
|
87
108
|
else:
|
|
88
109
|
# Show parallel execution
|
|
89
110
|
task_list = list(group)
|
|
@@ -92,26 +113,101 @@ class OrchestratorAgent:
|
|
|
92
113
|
f"\n[dim][Parallel Execution] Running {len(task_list)} read-only tasks concurrently...[/dim]"
|
|
93
114
|
)
|
|
94
115
|
coros = [self._run_sub_task(t, model) for t in task_list]
|
|
95
|
-
|
|
116
|
+
parallel_results = await asyncio.gather(*coros)
|
|
117
|
+
results.extend(parallel_results)
|
|
118
|
+
|
|
119
|
+
# Track parallel task progress
|
|
120
|
+
for t, result in zip(task_list, parallel_results):
|
|
121
|
+
task_progress.append(
|
|
122
|
+
{
|
|
123
|
+
"task": t,
|
|
124
|
+
"completed": True,
|
|
125
|
+
"had_output": hasattr(result, "result")
|
|
126
|
+
and result.result
|
|
127
|
+
and getattr(result.result, "output", None),
|
|
128
|
+
}
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
# Check if this task produced user-visible output
|
|
132
|
+
if hasattr(result, "response_state"):
|
|
133
|
+
response_state.has_user_response |= result.response_state.has_user_response
|
|
96
134
|
|
|
97
135
|
console.print("\n[green]Orchestrator completed all tasks successfully![/green]")
|
|
98
136
|
|
|
99
|
-
|
|
137
|
+
# Check if we need a fallback response
|
|
138
|
+
has_any_output = any(
|
|
100
139
|
hasattr(r, "result") and r.result and getattr(r.result, "output", None) for r in results
|
|
101
140
|
)
|
|
102
141
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
142
|
+
fallback_enabled = self.state.session.user_config.get("settings", {}).get(
|
|
143
|
+
"fallback_response", True
|
|
144
|
+
)
|
|
106
145
|
|
|
107
|
-
|
|
108
|
-
|
|
146
|
+
# Use has_any_output as the primary check since response_state might not be set for all agents
|
|
147
|
+
if not has_any_output and fallback_enabled:
|
|
148
|
+
# Generate a detailed fallback response
|
|
149
|
+
completed_count = sum(1 for tp in task_progress if tp["completed"])
|
|
150
|
+
output_count = sum(1 for tp in task_progress if tp["had_output"])
|
|
151
|
+
|
|
152
|
+
fallback = FallbackResponse(
|
|
153
|
+
summary="Orchestrator completed all tasks but no final response was generated.",
|
|
154
|
+
progress=f"Executed {completed_count}/{len(tasks)} tasks successfully",
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
# Add task details based on verbosity
|
|
158
|
+
verbosity = self.state.session.user_config.get("settings", {}).get(
|
|
159
|
+
"fallback_verbosity", "normal"
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
if verbosity in ["normal", "detailed"]:
|
|
163
|
+
# List what was done
|
|
164
|
+
if task_progress:
|
|
165
|
+
fallback.issues.append(f"Tasks executed: {completed_count}")
|
|
166
|
+
if output_count == 0:
|
|
167
|
+
fallback.issues.append("No tasks produced visible output")
|
|
168
|
+
|
|
169
|
+
if verbosity == "detailed":
|
|
170
|
+
# Add task descriptions
|
|
171
|
+
for i, tp in enumerate(task_progress, 1):
|
|
172
|
+
task_type = "WRITE" if tp["task"].mutate else "READ"
|
|
173
|
+
status = "✓" if tp["completed"] else "✗"
|
|
174
|
+
fallback.issues.append(
|
|
175
|
+
f"{status} Task {i} [{task_type}]: {tp['task'].description}"
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
# Suggest next steps
|
|
179
|
+
fallback.next_steps.append("Review the task execution above for any errors")
|
|
180
|
+
fallback.next_steps.append(
|
|
181
|
+
"Try running individual tasks separately for more detailed output"
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
# Create synthesized response
|
|
185
|
+
synthesis_parts = [fallback.summary, ""]
|
|
186
|
+
|
|
187
|
+
if fallback.progress:
|
|
188
|
+
synthesis_parts.append(f"Progress: {fallback.progress}")
|
|
189
|
+
|
|
190
|
+
if fallback.issues:
|
|
191
|
+
synthesis_parts.append("\nDetails:")
|
|
192
|
+
synthesis_parts.extend(f" • {issue}" for issue in fallback.issues)
|
|
193
|
+
|
|
194
|
+
if fallback.next_steps:
|
|
195
|
+
synthesis_parts.append("\nNext steps:")
|
|
196
|
+
synthesis_parts.extend(f" • {step}" for step in fallback.next_steps)
|
|
197
|
+
|
|
198
|
+
synthesis = "\n".join(synthesis_parts)
|
|
199
|
+
|
|
200
|
+
class FallbackResult:
|
|
201
|
+
def __init__(self, output: str, response_state: ResponseState):
|
|
109
202
|
self.output = output
|
|
203
|
+
self.response_state = response_state
|
|
110
204
|
|
|
111
|
-
class
|
|
112
|
-
def __init__(self):
|
|
113
|
-
self.result =
|
|
205
|
+
class FallbackRun:
|
|
206
|
+
def __init__(self, synthesis: str, response_state: ResponseState):
|
|
207
|
+
self.result = FallbackResult(synthesis, response_state)
|
|
208
|
+
self.response_state = response_state
|
|
114
209
|
|
|
115
|
-
|
|
210
|
+
response_state.has_final_synthesis = True
|
|
211
|
+
results.append(FallbackRun(synthesis, response_state))
|
|
116
212
|
|
|
117
213
|
return results
|
tunacode/core/agents/readonly.py
CHANGED
|
@@ -6,7 +6,7 @@ from typing import TYPE_CHECKING
|
|
|
6
6
|
|
|
7
7
|
from ...tools.grep import grep
|
|
8
8
|
from ...tools.read_file import read_file
|
|
9
|
-
from ...types import AgentRun, ModelName
|
|
9
|
+
from ...types import AgentRun, ModelName, ResponseState
|
|
10
10
|
from ..state import StateManager
|
|
11
11
|
|
|
12
12
|
if TYPE_CHECKING:
|
|
@@ -42,10 +42,24 @@ class ReadOnlyAgent:
|
|
|
42
42
|
async def process_request(self, request: str) -> AgentRun:
|
|
43
43
|
"""Process a request using only read-only tools."""
|
|
44
44
|
agent = self._get_agent()
|
|
45
|
+
response_state = ResponseState()
|
|
45
46
|
|
|
46
47
|
# Use iter() like main.py does to get the full run context
|
|
47
48
|
async with agent.iter(request) as agent_run:
|
|
48
|
-
async for
|
|
49
|
-
|
|
49
|
+
async for node in agent_run:
|
|
50
|
+
# Check if this node produced user-visible output
|
|
51
|
+
if hasattr(node, "result") and node.result and hasattr(node.result, "output"):
|
|
52
|
+
if node.result.output:
|
|
53
|
+
response_state.has_user_response = True
|
|
50
54
|
|
|
51
|
-
|
|
55
|
+
# Wrap the agent run to include response_state
|
|
56
|
+
class AgentRunWithState:
|
|
57
|
+
def __init__(self, wrapped_run):
|
|
58
|
+
self._wrapped = wrapped_run
|
|
59
|
+
self.response_state = response_state
|
|
60
|
+
|
|
61
|
+
def __getattr__(self, name):
|
|
62
|
+
# Delegate all other attributes to the wrapped object
|
|
63
|
+
return getattr(self._wrapped, name)
|
|
64
|
+
|
|
65
|
+
return AgentRunWithState(agent_run)
|
tunacode/ui/output.py
CHANGED
|
@@ -24,7 +24,7 @@ BANNER = """[bold cyan]
|
|
|
24
24
|
██║ ╚██████╔╝██║ ╚████║██║ ██║
|
|
25
25
|
╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═╝
|
|
26
26
|
|
|
27
|
-
██████╗ ██████╗ ██████╗ ███████╗
|
|
27
|
+
██████╗ ██████╗ ██████╗ ███████╗ dev
|
|
28
28
|
██╔════╝██╔═══██╗██╔══██╗██╔════╝
|
|
29
29
|
██║ ██║ ██║██║ ██║█████╗
|
|
30
30
|
██║ ██║ ██║██║ ██║██╔══╝
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tunacode-cli
|
|
3
|
+
Version: 0.0.29
|
|
4
|
+
Summary: Your agentic CLI developer.
|
|
5
|
+
Author-email: larock22 <noreply@github.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/larock22/tunacode
|
|
8
|
+
Project-URL: Repository, https://github.com/larock22/tunacode
|
|
9
|
+
Keywords: cli,agent,development,automation
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Topic :: Software Development
|
|
18
|
+
Classifier: Topic :: Utilities
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: typer==0.15.3
|
|
23
|
+
Requires-Dist: prompt_toolkit==3.0.51
|
|
24
|
+
Requires-Dist: pydantic-ai[logfire]==0.2.6
|
|
25
|
+
Requires-Dist: pygments==2.19.1
|
|
26
|
+
Requires-Dist: rich==14.0.0
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: build; extra == "dev"
|
|
29
|
+
Requires-Dist: black; extra == "dev"
|
|
30
|
+
Requires-Dist: flake8; extra == "dev"
|
|
31
|
+
Requires-Dist: isort; extra == "dev"
|
|
32
|
+
Requires-Dist: pytest; extra == "dev"
|
|
33
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
34
|
+
Requires-Dist: textual-dev; extra == "dev"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# TunaCode
|
|
38
|
+
|
|
39
|
+
<div align="center">
|
|
40
|
+
|
|
41
|
+
[](https://badge.fury.io/py/tunacode-cli)
|
|
42
|
+
[](https://www.python.org/downloads/)
|
|
43
|
+
[](https://opensource.org/licenses/MIT)
|
|
44
|
+
|
|
45
|
+
**AI-powered CLI coding assistant**
|
|
46
|
+
|
|
47
|
+

|
|
48
|
+
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Quick Install
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# Option 1: One-line install (Linux/macOS)
|
|
57
|
+
wget -qO- https://raw.githubusercontent.com/alchemiststudiosDOTai/tunacode/master/scripts/install_linux.sh | bash
|
|
58
|
+
|
|
59
|
+
# Option 2: pip install
|
|
60
|
+
pip install tunacode-cli
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Configuration
|
|
64
|
+
|
|
65
|
+
Choose your AI provider and set your API key:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# OpenAI
|
|
69
|
+
tunacode --model "openai:gpt-4o" --key "sk-your-openai-key"
|
|
70
|
+
|
|
71
|
+
# Anthropic Claude
|
|
72
|
+
tunacode --model "anthropic:claude-3.5-sonnet" --key "sk-ant-your-anthropic-key"
|
|
73
|
+
|
|
74
|
+
# OpenRouter (100+ models)
|
|
75
|
+
tunacode --model "openrouter:openai/gpt-4o" --key "sk-or-your-openrouter-key"
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Your config is saved to `~/.config/tunacode.json`
|
|
79
|
+
|
|
80
|
+
## Start Coding
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
tunacode
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Basic Commands
|
|
87
|
+
|
|
88
|
+
| Command | Description |
|
|
89
|
+
| ------- | ----------- |
|
|
90
|
+
| `/help` | Show all commands |
|
|
91
|
+
| `/model <provider:name>` | Switch model |
|
|
92
|
+
| `/clear` | Clear message history |
|
|
93
|
+
| `/compact` | Summarize conversation |
|
|
94
|
+
| `/branch <name>` | Create Git branch |
|
|
95
|
+
| `/yolo` | Skip confirmations |
|
|
96
|
+
| `!<command>` | Run shell command |
|
|
97
|
+
| `exit` | Exit TunaCode |
|
|
98
|
+
|
|
99
|
+
## Safety First
|
|
100
|
+
|
|
101
|
+
⚠️ **Important**: TunaCode can modify your codebase. Always:
|
|
102
|
+
- Use Git branches before making changes
|
|
103
|
+
- Review file modifications before confirming
|
|
104
|
+
- Keep backups of important work
|
|
105
|
+
|
|
106
|
+
## Documentation
|
|
107
|
+
|
|
108
|
+
- [**Features**](documentation/FEATURES.md) - All features, tools, and commands
|
|
109
|
+
- [**Advanced Configuration**](documentation/ADVANCED-CONFIG.md) - Provider setup, MCP, customization
|
|
110
|
+
- [**Architecture**](documentation/ARCHITECTURE.md) - Source code organization and design
|
|
111
|
+
- [**Development**](documentation/DEVELOPMENT.md) - Contributing and development setup
|
|
112
|
+
|
|
113
|
+
## Links
|
|
114
|
+
|
|
115
|
+
- [PyPI Package](https://pypi.org/project/tunacode-cli/)
|
|
116
|
+
- [GitHub Repository](https://github.com/alchemiststudiosDOTai/tunacode)
|
|
117
|
+
- [Report Issues](https://github.com/alchemiststudiosDOTai/tunacode/issues)
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
MIT License - see [LICENSE](LICENSE) file
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
tunacode/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
tunacode/constants.py,sha256=
|
|
2
|
+
tunacode/constants.py,sha256=yChcPTCk4tc0Q1JArwWxIZ2Zxi9S-vLgKiBOdMml6eI,3799
|
|
3
3
|
tunacode/context.py,sha256=6sterdRvPOyG3LU0nEAXpBsEPZbO3qtPyTlJBi-_VXE,2612
|
|
4
4
|
tunacode/exceptions.py,sha256=_Dyj6cC0868dMABekdQHXCg5XhucJumbGUMXaSDzgB4,2645
|
|
5
5
|
tunacode/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
6
|
tunacode/setup.py,sha256=dYn0NeAxtNIDSogWEmGSyjb9wsr8AonZ8vAo5sw9NIw,1909
|
|
7
7
|
tunacode/types.py,sha256=BciT-uxnQ44iC-4QiDY72OD23LOtqSyMOuK_N0ttlaA,7676
|
|
8
8
|
tunacode/cli/__init__.py,sha256=zgs0UbAck8hfvhYsWhWOfBe5oK09ug2De1r4RuQZREA,55
|
|
9
|
-
tunacode/cli/commands.py,sha256=
|
|
9
|
+
tunacode/cli/commands.py,sha256=OD3ZnNd5_TjJSAIuDT4rNgruTH_OOuAaR5OAoa8poFQ,34062
|
|
10
10
|
tunacode/cli/main.py,sha256=PIcFnfmIoI_pmK2y-zB_ouJbzR5fbSI7zsKQNPB_J8o,2406
|
|
11
11
|
tunacode/cli/repl.py,sha256=sXtRHYameAlMjlee82ix8P2JjRyWLrdFfHwxfaMKPb8,13722
|
|
12
12
|
tunacode/cli/textual_app.py,sha256=14-Nt0IIETmyHBrNn9uwSF3EwCcutwTp6gdoKgNm0sY,12593
|
|
13
13
|
tunacode/cli/textual_bridge.py,sha256=CTuf5Yjg5occQa7whyopS_erbJdS2UpWqaX_TVJ2D2A,6140
|
|
14
14
|
tunacode/configuration/__init__.py,sha256=MbVXy8bGu0yKehzgdgZ_mfWlYGvIdb1dY2Ly75nfuPE,17
|
|
15
|
-
tunacode/configuration/defaults.py,sha256=
|
|
15
|
+
tunacode/configuration/defaults.py,sha256=oLgmHprB3cTaFvT9dn_rgg206zoj09GRXRbI7MYijxA,801
|
|
16
16
|
tunacode/configuration/models.py,sha256=XPobkLM_TzKTuMIWhK-svJfGRGFT9r2LhKEM6rv6QHk,3756
|
|
17
17
|
tunacode/configuration/settings.py,sha256=lm2ov8rG1t4C5JIXMOhIKik5FAsjpuLVYtFmnE1ZQ3k,995
|
|
18
18
|
tunacode/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
19
|
tunacode/core/state.py,sha256=n1claG-gVVDMBCCS8cDmgas4XbKLJJwKRc-8CtXeTS8,1376
|
|
20
20
|
tunacode/core/tool_handler.py,sha256=OKx7jM8pml6pSEnoARu33_uBY8awJBqvhbVeBn6T4ow,1804
|
|
21
21
|
tunacode/core/agents/__init__.py,sha256=TiXwymGRNMuOqQaRLpNCAt7bZArg8rkadIRs4Nw21SQ,275
|
|
22
|
-
tunacode/core/agents/main.py,sha256=
|
|
23
|
-
tunacode/core/agents/orchestrator.py,sha256=
|
|
22
|
+
tunacode/core/agents/main.py,sha256=FCExe7pQ57z-GQh9p1RHEgaxHdMotJS21htdnHB-VK0,20612
|
|
23
|
+
tunacode/core/agents/orchestrator.py,sha256=SSJyd4O_WZzcI5zygoUx1nhzRpfT6DrPsp2XtK2UVzY,8607
|
|
24
24
|
tunacode/core/agents/planner_schema.py,sha256=pu2ehQVALjiJ5HJD7EN6xuZHCknsrXO9z0xHuVdlKW8,345
|
|
25
|
-
tunacode/core/agents/readonly.py,sha256=
|
|
25
|
+
tunacode/core/agents/readonly.py,sha256=jOG3CF5G1y9k4sBn7ChXN1GXWbmB_0pFGcaMMI4iaLs,2325
|
|
26
26
|
tunacode/core/background/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
27
|
tunacode/core/background/manager.py,sha256=rJdl3eDLTQwjbT7VhxXcJbZopCNR3M8ZGMbmeVnwwMc,1126
|
|
28
28
|
tunacode/core/llm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -53,7 +53,7 @@ tunacode/ui/decorators.py,sha256=e2KM-_pI5EKHa2M045IjUe4rPkTboxaKHXJT0K3461g,191
|
|
|
53
53
|
tunacode/ui/input.py,sha256=6LlEwKIXYXusNDI2PD0DDjRymQgu5mf2v06TsHbUln0,2957
|
|
54
54
|
tunacode/ui/keybindings.py,sha256=h0MlD73CW_3i2dQzb9EFSPkqy0raZ_isgjxUiA9u6ts,691
|
|
55
55
|
tunacode/ui/lexers.py,sha256=tmg4ic1enyTRLzanN5QPP7D_0n12YjX_8ZhsffzhXA4,1340
|
|
56
|
-
tunacode/ui/output.py,sha256=
|
|
56
|
+
tunacode/ui/output.py,sha256=wCLvAZb-OeKyLeR7KxD9WSW_GkHk0iX0PDAJilR0Upw,4508
|
|
57
57
|
tunacode/ui/panels.py,sha256=_8B1rGOhPnSLekGM4ZzDJw-dCuaPeacsaCmmCggqxwE,5950
|
|
58
58
|
tunacode/ui/prompt_manager.py,sha256=U2cntB34vm-YwOj3gzFRUK362zccrz8pigQfpxr5sv8,4650
|
|
59
59
|
tunacode/ui/tool_ui.py,sha256=S5-k1HwRlSqiQ8shGQ_QYGXQbuzb6Pg7u3CTqZwffdQ,6533
|
|
@@ -67,9 +67,9 @@ tunacode/utils/ripgrep.py,sha256=AXUs2FFt0A7KBV996deS8wreIlUzKOlAHJmwrcAr4No,583
|
|
|
67
67
|
tunacode/utils/system.py,sha256=FSoibTIH0eybs4oNzbYyufIiV6gb77QaeY2yGqW39AY,11381
|
|
68
68
|
tunacode/utils/text_utils.py,sha256=B9M1cuLTm_SSsr15WNHF6j7WdLWPvWzKZV0Lvfgdbjg,2458
|
|
69
69
|
tunacode/utils/user_configuration.py,sha256=IGvUH37wWtZ4M5xpukZEWYhtuKKyKcl6DaeObGXdleU,2610
|
|
70
|
-
tunacode_cli-0.0.
|
|
71
|
-
tunacode_cli-0.0.
|
|
72
|
-
tunacode_cli-0.0.
|
|
73
|
-
tunacode_cli-0.0.
|
|
74
|
-
tunacode_cli-0.0.
|
|
75
|
-
tunacode_cli-0.0.
|
|
70
|
+
tunacode_cli-0.0.29.dist-info/licenses/LICENSE,sha256=Btzdu2kIoMbdSp6OyCLupB1aRgpTCJ_szMimgEnpkkE,1056
|
|
71
|
+
tunacode_cli-0.0.29.dist-info/METADATA,sha256=QAJvK_x13W-wzNNNLr0WmSo3Xo1kHuskr3N9OFSGZxc,3619
|
|
72
|
+
tunacode_cli-0.0.29.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
73
|
+
tunacode_cli-0.0.29.dist-info/entry_points.txt,sha256=hbkytikj4dGu6rizPuAd_DGUPBGF191RTnhr9wdhORY,51
|
|
74
|
+
tunacode_cli-0.0.29.dist-info/top_level.txt,sha256=lKy2P6BWNi5XSA4DHFvyjQ14V26lDZctwdmhEJrxQbU,9
|
|
75
|
+
tunacode_cli-0.0.29.dist-info/RECORD,,
|
|
@@ -1,567 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: tunacode-cli
|
|
3
|
-
Version: 0.0.27
|
|
4
|
-
Summary: Your agentic CLI developer.
|
|
5
|
-
Author-email: larock22 <noreply@github.com>
|
|
6
|
-
License-Expression: MIT
|
|
7
|
-
Project-URL: Homepage, https://github.com/larock22/tunacode
|
|
8
|
-
Project-URL: Repository, https://github.com/larock22/tunacode
|
|
9
|
-
Keywords: cli,agent,development,automation
|
|
10
|
-
Classifier: Development Status :: 4 - Beta
|
|
11
|
-
Classifier: Intended Audience :: Developers
|
|
12
|
-
Classifier: Programming Language :: Python :: 3
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
-
Classifier: Topic :: Software Development
|
|
18
|
-
Classifier: Topic :: Utilities
|
|
19
|
-
Requires-Python: >=3.10
|
|
20
|
-
Description-Content-Type: text/markdown
|
|
21
|
-
License-File: LICENSE
|
|
22
|
-
Requires-Dist: typer==0.15.3
|
|
23
|
-
Requires-Dist: prompt_toolkit==3.0.51
|
|
24
|
-
Requires-Dist: pydantic-ai[logfire]==0.2.6
|
|
25
|
-
Requires-Dist: pygments==2.19.1
|
|
26
|
-
Requires-Dist: rich==14.0.0
|
|
27
|
-
Provides-Extra: dev
|
|
28
|
-
Requires-Dist: build; extra == "dev"
|
|
29
|
-
Requires-Dist: black; extra == "dev"
|
|
30
|
-
Requires-Dist: flake8; extra == "dev"
|
|
31
|
-
Requires-Dist: isort; extra == "dev"
|
|
32
|
-
Requires-Dist: pytest; extra == "dev"
|
|
33
|
-
Requires-Dist: pytest-cov; extra == "dev"
|
|
34
|
-
Requires-Dist: textual-dev; extra == "dev"
|
|
35
|
-
Dynamic: license-file
|
|
36
|
-
|
|
37
|
-
# TunaCode
|
|
38
|
-
|
|
39
|
-
<div align="center">
|
|
40
|
-
|
|
41
|
-
[](https://badge.fury.io/py/tunacode-cli)
|
|
42
|
-
[](https://www.python.org/downloads/)
|
|
43
|
-
[](https://opensource.org/licenses/MIT)
|
|
44
|
-
|
|
45
|
-
**Your AI-powered CLI coding assistant**
|
|
46
|
-
|
|
47
|
-

|
|
48
|
-
|
|
49
|
-
[Quick Start](#quick-start) • [Features](#features) • [Configuration](#configuration) • [Documentation](#documentation)
|
|
50
|
-
|
|
51
|
-
</div>
|
|
52
|
-
|
|
53
|
-
---
|
|
54
|
-
|
|
55
|
-
## Overview
|
|
56
|
-
|
|
57
|
-
> **⚠️ Safety First**: TunaCode can modify your codebase. Always use git branches before making major changes. The `/undo` command has been removed - use git for version control.
|
|
58
|
-
|
|
59
|
-
> **Beta Notice**: TunaCode is currently in beta. [Report issues](https://github.com/alchemiststudiosDOTai/tunacode/issues) or share feedback to help us improve!
|
|
60
|
-
|
|
61
|
-
---
|
|
62
|
-
|
|
63
|
-
### Recent Updates (v0.0.18)
|
|
64
|
-
|
|
65
|
-
- **Advanced Agent Orchestration**: New orchestrator system for complex multi-step tasks with planning visibility
|
|
66
|
-
- **Background Task Manager**: Asynchronous background processing for long-running operations
|
|
67
|
-
- **Read-Only Agent**: Specialized agent for safe codebase exploration without modification risks
|
|
68
|
-
- **Planning Transparency**: See the AI's planning process before execution with detailed task breakdowns
|
|
69
|
-
- **Shell Command Support**: Execute shell commands directly with `!command` or open interactive shell with `!`
|
|
70
|
-
- **Enhanced Bash Tool**: Advanced bash execution with timeouts, working directory, and environment variables
|
|
71
|
-
- **JSON Tool Parsing Fallback**: Automatic recovery when API providers fail with structured tool calling
|
|
72
|
-
- **Enhanced Reliability**: Fixed parameter naming issues that caused tool schema errors
|
|
73
|
-
- **Configuration Management**: New `/refresh` command to reload config without restart
|
|
74
|
-
- **Improved ReAct Reasoning**: Enhanced iteration limits (now defaults to 20) and better thought processing
|
|
75
|
-
- **New Debug Commands**: `/parsetools` for manual JSON parsing, `/iterations` for controlling reasoning depth
|
|
76
|
-
- **Better Error Recovery**: Multiple fallback mechanisms for various failure scenarios
|
|
77
|
-
|
|
78
|
-
### Core Features
|
|
79
|
-
|
|
80
|
-
<table>
|
|
81
|
-
<tr>
|
|
82
|
-
<td width="50%">
|
|
83
|
-
|
|
84
|
-
### **Multi-Provider Support**
|
|
85
|
-
|
|
86
|
-
- Anthropic Claude
|
|
87
|
-
- OpenAI GPT
|
|
88
|
-
- Google Gemini
|
|
89
|
-
- OpenRouter (100+ models)
|
|
90
|
-
- Any OpenAI-compatible API
|
|
91
|
-
|
|
92
|
-
### **Developer Tools**
|
|
93
|
-
|
|
94
|
-
- 6 core tools: bash, grep, read_file, write_file, update_file, run_command
|
|
95
|
-
- Direct shell command execution with `!` prefix
|
|
96
|
-
- MCP (Model Context Protocol) support
|
|
97
|
-
- File operation confirmations with diffs
|
|
98
|
-
- Per-project context guides (TUNACODE.md)
|
|
99
|
-
- JSON tool parsing fallback for API compatibility
|
|
100
|
-
|
|
101
|
-
</td>
|
|
102
|
-
<td width="50%">
|
|
103
|
-
|
|
104
|
-
### **Safety & Control**
|
|
105
|
-
|
|
106
|
-
- Git branch integration (`/branch`)
|
|
107
|
-
- No automatic commits
|
|
108
|
-
- Explicit file operation confirmations
|
|
109
|
-
- Permission tracking per session
|
|
110
|
-
- `/yolo` mode for power users
|
|
111
|
-
|
|
112
|
-
### **Architecture**
|
|
113
|
-
|
|
114
|
-
- Built on pydantic-ai
|
|
115
|
-
- Async throughout
|
|
116
|
-
- Modular command system
|
|
117
|
-
- Rich UI with syntax highlighting
|
|
118
|
-
- ReAct reasoning patterns
|
|
119
|
-
|
|
120
|
-
</td>
|
|
121
|
-
</tr>
|
|
122
|
-
</table>
|
|
123
|
-
|
|
124
|
-
---
|
|
125
|
-
|
|
126
|
-
## Quick Start
|
|
127
|
-
|
|
128
|
-
### Installation
|
|
129
|
-
|
|
130
|
-
#### PyPI
|
|
131
|
-
|
|
132
|
-
```bash
|
|
133
|
-
pip install tunacode-cli
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
#### Development Installation
|
|
137
|
-
|
|
138
|
-
```bash
|
|
139
|
-
# Clone the repository
|
|
140
|
-
git clone https://github.com/larock22/tunacode.git
|
|
141
|
-
cd tunacode
|
|
142
|
-
|
|
143
|
-
# Run the setup script
|
|
144
|
-
./scripts/setup_dev_env.sh
|
|
145
|
-
|
|
146
|
-
# Or manually:
|
|
147
|
-
python3 -m venv venv
|
|
148
|
-
source venv/bin/activate
|
|
149
|
-
pip install -e ".[dev]"
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed development setup.
|
|
153
|
-
|
|
154
|
-
#### One-line Install (Linux/macOS)
|
|
155
|
-
|
|
156
|
-
```bash
|
|
157
|
-
wget -qO- https://raw.githubusercontent.com/alchemiststudiosDOTai/tunacode/master/scripts/install_linux.sh | bash
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
### Uninstallation
|
|
161
|
-
|
|
162
|
-
To completely remove TunaCode from your system:
|
|
163
|
-
|
|
164
|
-
```bash
|
|
165
|
-
# Download and run the uninstall script
|
|
166
|
-
wget -qO- https://raw.githubusercontent.com/alchemiststudiosDOTai/tunacode/master/scripts/uninstall.sh | bash
|
|
167
|
-
|
|
168
|
-
# Or manually:
|
|
169
|
-
# 1. Remove the package
|
|
170
|
-
pipx uninstall tunacode # if installed via pipx
|
|
171
|
-
# OR
|
|
172
|
-
pip uninstall tunacode-cli # if installed via pip
|
|
173
|
-
|
|
174
|
-
# 2. Remove configuration files
|
|
175
|
-
rm -rf ~/.config/tunacode*
|
|
176
|
-
|
|
177
|
-
# 3. Remove any leftover binaries
|
|
178
|
-
rm -f ~/.local/bin/tunacode
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### Setup Options
|
|
182
|
-
|
|
183
|
-
<details>
|
|
184
|
-
<summary><b>Option 1: Interactive Setup (Beginner-friendly)</b></summary>
|
|
185
|
-
|
|
186
|
-
```bash
|
|
187
|
-
tunacode
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
Follow the interactive prompts to configure your preferred LLM provider.
|
|
191
|
-
|
|
192
|
-
</details>
|
|
193
|
-
|
|
194
|
-
<details>
|
|
195
|
-
<summary><b>Option 2: Direct CLI Setup (Recommended)</b></summary>
|
|
196
|
-
|
|
197
|
-
```bash
|
|
198
|
-
# OpenAI
|
|
199
|
-
tunacode --model "openai:gpt-4.1" --key "your-openai-key"
|
|
200
|
-
|
|
201
|
-
# Anthropic Claude
|
|
202
|
-
tunacode --model "anthropic:claude-3-opus" --key "your-anthropic-key"
|
|
203
|
-
|
|
204
|
-
# OpenRouter (Access to multiple models)
|
|
205
|
-
tunacode --baseurl "https://openrouter.ai/api/v1" \
|
|
206
|
-
--model "openrouter:openai/gpt-4.1" \
|
|
207
|
-
--key "your-openrouter-key"
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
</details>
|
|
211
|
-
|
|
212
|
-
> **Important**: Model names require provider prefixes (e.g., `openai:gpt-4.1`, not `gpt-4.1`)
|
|
213
|
-
|
|
214
|
-
---
|
|
215
|
-
|
|
216
|
-
## Configuration
|
|
217
|
-
|
|
218
|
-
### Config Location
|
|
219
|
-
|
|
220
|
-
Configuration is stored in `~/.config/tunacode.json`
|
|
221
|
-
|
|
222
|
-
### Model Format
|
|
223
|
-
|
|
224
|
-
```
|
|
225
|
-
provider:model-name
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
**Examples:**
|
|
229
|
-
|
|
230
|
-
- `openai:gpt-4.1`
|
|
231
|
-
- `anthropic:claude-3-opus`
|
|
232
|
-
- `google-gla:gemini-2.0-flash`
|
|
233
|
-
- `openrouter:mistralai/devstral-small`
|
|
234
|
-
|
|
235
|
-
### OpenRouter Integration
|
|
236
|
-
|
|
237
|
-
<details>
|
|
238
|
-
<summary><b>Click to expand OpenRouter setup</b></summary>
|
|
239
|
-
|
|
240
|
-
[OpenRouter](https://openrouter.ai) provides access to 100+ models through a single API:
|
|
241
|
-
|
|
242
|
-
```bash
|
|
243
|
-
tunacode --baseurl "https://openrouter.ai/api/v1" \
|
|
244
|
-
--model "openrouter:openai/gpt-4.1" \
|
|
245
|
-
--key "your-openrouter-key"
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
**Manual Configuration:**
|
|
249
|
-
|
|
250
|
-
```json
|
|
251
|
-
{
|
|
252
|
-
"env": {
|
|
253
|
-
"OPENROUTER_API_KEY": "<YOUR_KEY>",
|
|
254
|
-
"OPENAI_BASE_URL": "https://openrouter.ai/api/v1"
|
|
255
|
-
},
|
|
256
|
-
"default_model": "openrouter:openai/gpt-4.1"
|
|
257
|
-
}
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
**Popular Models:**
|
|
261
|
-
|
|
262
|
-
- `openrouter:mistralai/devstral-small`
|
|
263
|
-
- `openrouter:openai/gpt-4.1-mini`
|
|
264
|
-
- `openrouter:codex-mini-latest`
|
|
265
|
-
|
|
266
|
-
</details>
|
|
267
|
-
|
|
268
|
-
### MCP (Model Context Protocol) Support
|
|
269
|
-
|
|
270
|
-
<details>
|
|
271
|
-
<summary><b>Click to expand MCP configuration</b></summary>
|
|
272
|
-
|
|
273
|
-
Extend your AI's capabilities with MCP servers:
|
|
274
|
-
|
|
275
|
-
```json
|
|
276
|
-
{
|
|
277
|
-
"mcpServers": {
|
|
278
|
-
"fetch": {
|
|
279
|
-
"command": "uvx",
|
|
280
|
-
"args": ["mcp-server-fetch"]
|
|
281
|
-
},
|
|
282
|
-
"github": {
|
|
283
|
-
"command": "npx",
|
|
284
|
-
"args": ["-y", "@modelcontextprotocol/server-github"],
|
|
285
|
-
"env": {
|
|
286
|
-
"GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
Learn more at [modelcontextprotocol.io](https://modelcontextprotocol.io/)
|
|
294
|
-
|
|
295
|
-
</details>
|
|
296
|
-
|
|
297
|
-
---
|
|
298
|
-
|
|
299
|
-
## Commands Reference
|
|
300
|
-
|
|
301
|
-
### Core Commands
|
|
302
|
-
|
|
303
|
-
| Command | Description |
|
|
304
|
-
| -------------------------------- | -------------------------------- |
|
|
305
|
-
| `/help` | Show available commands |
|
|
306
|
-
| `/yolo` | Toggle confirmation skipping |
|
|
307
|
-
| `/clear` | Clear message history |
|
|
308
|
-
| `/compact` | Summarize and clear old messages |
|
|
309
|
-
| `/model` | Show current model |
|
|
310
|
-
| `/model <provider:name>` | Switch model |
|
|
311
|
-
| `/model <provider:name> default` | Set default model |
|
|
312
|
-
| `/branch <name>` | Create and switch Git branch |
|
|
313
|
-
| `/dump` | Show message history (debug) |
|
|
314
|
-
| `!<command>` | Run shell command |
|
|
315
|
-
| `!` | Open interactive shell |
|
|
316
|
-
| `exit` | Exit application |
|
|
317
|
-
|
|
318
|
-
### Debug & Recovery Commands
|
|
319
|
-
|
|
320
|
-
| Command | Description |
|
|
321
|
-
| -------------------------------- | -------------------------------- |
|
|
322
|
-
| `/thoughts` | Toggle ReAct thought display |
|
|
323
|
-
| `/iterations <1-50>` | Set max reasoning iterations |
|
|
324
|
-
| `/parsetools` | Parse JSON tool calls manually |
|
|
325
|
-
| `/fix` | Fix orphaned tool calls |
|
|
326
|
-
| `/refresh` | Reload configuration from defaults |
|
|
327
|
-
|
|
328
|
-
---
|
|
329
|
-
|
|
330
|
-
## Available Tools
|
|
331
|
-
|
|
332
|
-
### Bash Tool
|
|
333
|
-
The enhanced bash tool provides advanced shell command execution with safety features:
|
|
334
|
-
|
|
335
|
-
- **Working Directory Support**: Execute commands in specific directories
|
|
336
|
-
- **Environment Variables**: Set custom environment variables for commands
|
|
337
|
-
- **Timeout Control**: Configurable timeouts (1-300 seconds) to prevent hanging
|
|
338
|
-
- **Output Capture**: Full stdout/stderr capture with truncation for large outputs
|
|
339
|
-
- **Safety Checks**: Warns about potentially destructive commands
|
|
340
|
-
- **Error Guidance**: Helpful error messages for common issues (command not found, permission denied, etc.)
|
|
341
|
-
|
|
342
|
-
**Example usage by the AI:**
|
|
343
|
-
```python
|
|
344
|
-
# Simple command
|
|
345
|
-
await bash("ls -la")
|
|
346
|
-
|
|
347
|
-
# With working directory
|
|
348
|
-
await bash("npm install", cwd="/path/to/project")
|
|
349
|
-
|
|
350
|
-
# With timeout for long operations
|
|
351
|
-
await bash("npm run build", timeout=120)
|
|
352
|
-
|
|
353
|
-
# With environment variables
|
|
354
|
-
await bash("python script.py", env={"API_KEY": "secret"})
|
|
355
|
-
```
|
|
356
|
-
|
|
357
|
-
### Other Core Tools
|
|
358
|
-
- **grep**: Fast parallel content search across files
|
|
359
|
-
- **read_file**: Read file contents with line numbers
|
|
360
|
-
- **write_file**: Create new files (fails if file exists)
|
|
361
|
-
- **update_file**: Modify existing files with precise replacements
|
|
362
|
-
- **run_command**: Basic command execution (simpler than bash)
|
|
363
|
-
|
|
364
|
-
---
|
|
365
|
-
|
|
366
|
-
## Reliability Features
|
|
367
|
-
|
|
368
|
-
### JSON Tool Parsing Fallback
|
|
369
|
-
|
|
370
|
-
TunaCode automatically handles API provider failures with robust JSON parsing:
|
|
371
|
-
|
|
372
|
-
- **Automatic Recovery**: When structured tool calling fails, TunaCode parses JSON from text responses
|
|
373
|
-
- **Multiple Formats**: Supports inline JSON, code blocks, and complex nested structures
|
|
374
|
-
- **Manual Recovery**: Use `/parsetools` when automatic parsing needs assistance
|
|
375
|
-
- **Visual Feedback**: See `🔧 Recovered using JSON tool parsing` messages during fallback
|
|
376
|
-
|
|
377
|
-
### Enhanced Error Handling
|
|
378
|
-
|
|
379
|
-
- **Tool Schema Fixes**: Consistent parameter naming across all tools
|
|
380
|
-
- **Orphaned Tool Call Recovery**: Automatic cleanup with `/fix` command
|
|
381
|
-
- **Configuration Refresh**: Update settings without restart using `/refresh`
|
|
382
|
-
- **ReAct Reasoning**: Configurable iteration limits for complex problem solving
|
|
383
|
-
|
|
384
|
-
---
|
|
385
|
-
|
|
386
|
-
## Customization
|
|
387
|
-
|
|
388
|
-
### Project Guides
|
|
389
|
-
|
|
390
|
-
Create a `TUNACODE.md` file in your project root to customize TunaCode's behavior:
|
|
391
|
-
|
|
392
|
-
```markdown
|
|
393
|
-
# Project Guide
|
|
394
|
-
|
|
395
|
-
## Tech Stack
|
|
396
|
-
|
|
397
|
-
- Python 3.11
|
|
398
|
-
- FastAPI
|
|
399
|
-
- PostgreSQL
|
|
400
|
-
|
|
401
|
-
## Preferences
|
|
402
|
-
|
|
403
|
-
- Use type hints
|
|
404
|
-
- Follow PEP 8
|
|
405
|
-
- Write tests for new features
|
|
406
|
-
```
|
|
407
|
-
|
|
408
|
-
---
|
|
409
|
-
|
|
410
|
-
## Source Code Architecture
|
|
411
|
-
|
|
412
|
-
### Directory Structure
|
|
413
|
-
|
|
414
|
-
```
|
|
415
|
-
src/tunacode/
|
|
416
|
-
├── cli/ # Command Line Interface
|
|
417
|
-
│ ├── commands.py # Command registry and implementations
|
|
418
|
-
│ ├── main.py # Entry point and CLI setup (Typer)
|
|
419
|
-
│ └── repl.py # Interactive REPL loop
|
|
420
|
-
│
|
|
421
|
-
├── configuration/ # Configuration Management
|
|
422
|
-
│ ├── defaults.py # Default configuration values
|
|
423
|
-
│ ├── models.py # Configuration data models
|
|
424
|
-
│ └── settings.py # Settings loader and validator
|
|
425
|
-
│
|
|
426
|
-
├── core/ # Core Application Logic
|
|
427
|
-
│ ├── agents/ # AI Agent System
|
|
428
|
-
│ │ ├── main.py # Primary agent implementation (pydantic-ai)
|
|
429
|
-
│ │ ├── orchestrator.py # Complex task orchestration and planning
|
|
430
|
-
│ │ ├── planner_schema.py # Planning data models
|
|
431
|
-
│ │ └── readonly.py # Read-only agent for safe exploration
|
|
432
|
-
│ ├── background/ # Background Task Management
|
|
433
|
-
│ │ └── manager.py # Async background task execution
|
|
434
|
-
│ ├── llm/ # LLM Integration
|
|
435
|
-
│ │ └── planner.py # LLM-based task planning
|
|
436
|
-
│ ├── setup/ # Application Setup & Initialization
|
|
437
|
-
│ │ ├── agent_setup.py # Agent configuration
|
|
438
|
-
│ │ ├── base.py # Setup step base class
|
|
439
|
-
│ │ ├── config_setup.py # Configuration setup
|
|
440
|
-
│ │ ├── coordinator.py # Setup orchestration
|
|
441
|
-
│ │ ├── environment_setup.py # Environment validation
|
|
442
|
-
│ │ └── git_safety_setup.py # Git safety checks
|
|
443
|
-
│ ├── state.py # Application state management
|
|
444
|
-
│ └── tool_handler.py # Tool execution and validation
|
|
445
|
-
│
|
|
446
|
-
├── services/ # External Services
|
|
447
|
-
│ └── mcp.py # Model Context Protocol integration
|
|
448
|
-
│
|
|
449
|
-
├── tools/ # AI Agent Tools
|
|
450
|
-
│ ├── base.py # Tool base classes
|
|
451
|
-
│ ├── bash.py # Enhanced shell command execution
|
|
452
|
-
│ ├── grep.py # Parallel content search tool
|
|
453
|
-
│ ├── read_file.py # File reading tool
|
|
454
|
-
│ ├── run_command.py # Basic command execution tool
|
|
455
|
-
│ ├── update_file.py # File modification tool
|
|
456
|
-
│ └── write_file.py # File creation tool
|
|
457
|
-
│
|
|
458
|
-
├── ui/ # User Interface Components
|
|
459
|
-
│ ├── completers.py # Tab completion
|
|
460
|
-
│ ├── console.py # Rich console setup
|
|
461
|
-
│ ├── input.py # Input handling
|
|
462
|
-
│ ├── keybindings.py # Keyboard shortcuts
|
|
463
|
-
│ ├── lexers.py # Syntax highlighting
|
|
464
|
-
│ ├── output.py # Output formatting and banner
|
|
465
|
-
│ ├── panels.py # UI panels and layouts
|
|
466
|
-
│ ├── prompt_manager.py # Prompt toolkit integration
|
|
467
|
-
│ ├── tool_ui.py # Tool confirmation dialogs
|
|
468
|
-
│ └── validators.py # Input validation
|
|
469
|
-
│
|
|
470
|
-
├── utils/ # Utility Functions
|
|
471
|
-
│ ├── bm25.py # BM25 search algorithm (beta)
|
|
472
|
-
│ ├── diff_utils.py # Diff generation and formatting
|
|
473
|
-
│ ├── file_utils.py # File system operations
|
|
474
|
-
│ ├── ripgrep.py # Code search utilities
|
|
475
|
-
│ ├── system.py # System information
|
|
476
|
-
│ ├── text_utils.py # Text processing
|
|
477
|
-
│ └── user_configuration.py # User config management
|
|
478
|
-
│
|
|
479
|
-
├── constants.py # Application constants
|
|
480
|
-
├── context.py # Context management
|
|
481
|
-
├── exceptions.py # Custom exceptions
|
|
482
|
-
├── types.py # Type definitions
|
|
483
|
-
└── prompts/
|
|
484
|
-
└── system.md # System prompts for AI agent
|
|
485
|
-
```
|
|
486
|
-
|
|
487
|
-
### Key Components
|
|
488
|
-
|
|
489
|
-
| Component | Purpose | Key Files |
|
|
490
|
-
| -------------------- | ------------------------ | ------------------------------- |
|
|
491
|
-
| **CLI Layer** | Command parsing and REPL | `cli/main.py`, `cli/repl.py` |
|
|
492
|
-
| **Agent System** | AI-powered assistance | `core/agents/main.py` |
|
|
493
|
-
| **Orchestrator** | Complex task planning | `core/agents/orchestrator.py` |
|
|
494
|
-
| **Background Tasks** | Async task execution | `core/background/manager.py` |
|
|
495
|
-
| **Tool System** | File/command operations | `tools/*.py` |
|
|
496
|
-
| **State Management** | Session state tracking | `core/state.py` |
|
|
497
|
-
| **UI Framework** | Rich terminal interface | `ui/output.py`, `ui/console.py` |
|
|
498
|
-
| **Configuration** | User settings & models | `configuration/*.py` |
|
|
499
|
-
| **Setup System** | Initial configuration | `core/setup/*.py` |
|
|
500
|
-
|
|
501
|
-
### Data Flow
|
|
502
|
-
|
|
503
|
-
```
|
|
504
|
-
CLI Input → Command Registry → REPL → Agent → Tools → UI Output
|
|
505
|
-
↓ ↓ ↓ ↓ ↓ ↑
|
|
506
|
-
State Manager ←────────────────────────────────────────┘
|
|
507
|
-
```
|
|
508
|
-
|
|
509
|
-
---
|
|
510
|
-
|
|
511
|
-
## Development
|
|
512
|
-
|
|
513
|
-
### Requirements
|
|
514
|
-
|
|
515
|
-
- Python 3.10+
|
|
516
|
-
- Git (for version control)
|
|
517
|
-
|
|
518
|
-
### Development Setup
|
|
519
|
-
|
|
520
|
-
```bash
|
|
521
|
-
# Install development dependencies
|
|
522
|
-
make install
|
|
523
|
-
|
|
524
|
-
# Run linting
|
|
525
|
-
make lint
|
|
526
|
-
|
|
527
|
-
# Run tests
|
|
528
|
-
make test
|
|
529
|
-
```
|
|
530
|
-
|
|
531
|
-
---
|
|
532
|
-
|
|
533
|
-
## Links
|
|
534
|
-
|
|
535
|
-
<div align="center">
|
|
536
|
-
|
|
537
|
-
[](https://pypi.org/project/tunacode-cli/)
|
|
538
|
-
[](https://github.com/alchemiststudiosDOTai/tunacode)
|
|
539
|
-
[](https://github.com/alchemiststudiosDOTai/tunacode/issues)
|
|
540
|
-
|
|
541
|
-
</div>
|
|
542
|
-
|
|
543
|
-
---
|
|
544
|
-
|
|
545
|
-
## License
|
|
546
|
-
|
|
547
|
-
MIT License - see [LICENSE](LICENSE) file for details.
|
|
548
|
-
|
|
549
|
-
## Acknowledgments
|
|
550
|
-
|
|
551
|
-
TunaCode is a fork of [sidekick-cli](https://github.com/geekforbrains/sidekick-cli). Special thanks to the sidekick-cli team for creating the foundation that made TunaCode possible.
|
|
552
|
-
|
|
553
|
-
### Key Differences from sidekick-cli
|
|
554
|
-
|
|
555
|
-
While TunaCode builds on the foundation of sidekick-cli, we've made several architectural changes for our workflow:
|
|
556
|
-
|
|
557
|
-
- **JSON Tool Parsing Fallback**: Added fallback parsing for when API providers fail with structured tool calling
|
|
558
|
-
- **Parallel Search Tools**: New `bash` and `grep` tools with parallel execution for codebase navigation
|
|
559
|
-
- **Agent Orchestration**: Advanced orchestrator for complex multi-step tasks with planning transparency
|
|
560
|
-
- **Background Processing**: Asynchronous task manager for long-running operations
|
|
561
|
-
- **Read-Only Agent**: Safe exploration mode that prevents accidental modifications
|
|
562
|
-
- **ReAct Reasoning**: Implemented ReAct (Reasoning + Acting) patterns with configurable iteration limits
|
|
563
|
-
- **Dynamic Configuration**: Added `/refresh` command and modified configuration management
|
|
564
|
-
- **Safety Changes**: Removed automatic git commits and `/undo` command - requires explicit git usage
|
|
565
|
-
- **Error Recovery**: Multiple fallback mechanisms and orphaned tool call recovery
|
|
566
|
-
- **Tool System Rewrite**: Complete overhaul of internal tools with atomic operations and different confirmation UIs
|
|
567
|
-
- **Debug Commands**: Added `/parsetools`, `/thoughts`, `/iterations` for debugging
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|