tunacode-cli 0.0.75__py3-none-any.whl → 0.0.76.1__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/implementations/model.py +33 -5
- tunacode/cli/main.py +10 -0
- tunacode/cli/repl.py +17 -1
- tunacode/configuration/defaults.py +2 -2
- tunacode/configuration/key_descriptions.py +275 -0
- tunacode/constants.py +1 -1
- tunacode/core/agents/agent_components/node_processor.py +40 -4
- tunacode/core/agents/agent_components/streaming.py +268 -0
- tunacode/core/agents/main.py +30 -15
- tunacode/core/setup/config_setup.py +67 -224
- tunacode/core/setup/config_wizard.py +229 -0
- tunacode/core/state.py +3 -1
- tunacode/prompts/system.md +43 -29
- tunacode/ui/config_dashboard.py +567 -0
- tunacode/ui/panels.py +92 -9
- tunacode/utils/config_comparator.py +340 -0
- {tunacode_cli-0.0.75.dist-info → tunacode_cli-0.0.76.1.dist-info}/METADATA +63 -6
- {tunacode_cli-0.0.75.dist-info → tunacode_cli-0.0.76.1.dist-info}/RECORD +21 -16
- {tunacode_cli-0.0.75.dist-info → tunacode_cli-0.0.76.1.dist-info}/WHEEL +0 -0
- {tunacode_cli-0.0.75.dist-info → tunacode_cli-0.0.76.1.dist-info}/entry_points.txt +0 -0
- {tunacode_cli-0.0.75.dist-info → tunacode_cli-0.0.76.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -104,7 +104,15 @@ class ModelCommand(SimpleCommand):
|
|
|
104
104
|
# Auto-select single result
|
|
105
105
|
model = models[0]
|
|
106
106
|
context.state_manager.session.current_model = model.full_id
|
|
107
|
-
|
|
107
|
+
# Persist selection to config by default
|
|
108
|
+
try:
|
|
109
|
+
user_configuration.set_default_model(model.full_id, context.state_manager)
|
|
110
|
+
await ui.success(
|
|
111
|
+
f"Switched to model: {model.full_id} - {model.name} (saved as default)"
|
|
112
|
+
)
|
|
113
|
+
except ConfigurationError as e:
|
|
114
|
+
await ui.error(str(e))
|
|
115
|
+
await ui.warning("Model switched for this session only; failed to save default.")
|
|
108
116
|
return None
|
|
109
117
|
|
|
110
118
|
# Show multiple results
|
|
@@ -159,7 +167,7 @@ class ModelCommand(SimpleCommand):
|
|
|
159
167
|
# Set the model
|
|
160
168
|
context.state_manager.session.current_model = model_name
|
|
161
169
|
|
|
162
|
-
# Check if setting as default
|
|
170
|
+
# Check if setting as default (preserve existing behavior)
|
|
163
171
|
if extra_args and extra_args[0] == "default":
|
|
164
172
|
try:
|
|
165
173
|
user_configuration.set_default_model(model_name, context.state_manager)
|
|
@@ -169,7 +177,13 @@ class ModelCommand(SimpleCommand):
|
|
|
169
177
|
await ui.error(str(e))
|
|
170
178
|
return None
|
|
171
179
|
|
|
172
|
-
|
|
180
|
+
# Persist selection to config by default (auto-persist)
|
|
181
|
+
try:
|
|
182
|
+
user_configuration.set_default_model(model_name, context.state_manager)
|
|
183
|
+
await ui.success(f"Switched to model: {model_name} (saved as default)")
|
|
184
|
+
except ConfigurationError as e:
|
|
185
|
+
await ui.error(str(e))
|
|
186
|
+
await ui.warning("Model switched for this session only; failed to save default.")
|
|
173
187
|
return None
|
|
174
188
|
|
|
175
189
|
# No colon - treat as search query
|
|
@@ -184,7 +198,15 @@ class ModelCommand(SimpleCommand):
|
|
|
184
198
|
# Single match - use it
|
|
185
199
|
model = models[0]
|
|
186
200
|
context.state_manager.session.current_model = model.full_id
|
|
187
|
-
|
|
201
|
+
# Persist selection to config by default
|
|
202
|
+
try:
|
|
203
|
+
user_configuration.set_default_model(model.full_id, context.state_manager)
|
|
204
|
+
await ui.success(
|
|
205
|
+
f"Switched to model: {model.full_id} - {model.name} (saved as default)"
|
|
206
|
+
)
|
|
207
|
+
except ConfigurationError as e:
|
|
208
|
+
await ui.error(str(e))
|
|
209
|
+
await ui.warning("Model switched for this session only; failed to save default.")
|
|
188
210
|
return None
|
|
189
211
|
|
|
190
212
|
# Multiple matches - show interactive selector with results
|
|
@@ -193,7 +215,13 @@ class ModelCommand(SimpleCommand):
|
|
|
193
215
|
|
|
194
216
|
if selected_model:
|
|
195
217
|
context.state_manager.session.current_model = selected_model
|
|
196
|
-
|
|
218
|
+
# Persist selection to config by default
|
|
219
|
+
try:
|
|
220
|
+
user_configuration.set_default_model(selected_model, context.state_manager)
|
|
221
|
+
await ui.success(f"Switched to model: {selected_model} (saved as default)")
|
|
222
|
+
except ConfigurationError as e:
|
|
223
|
+
await ui.error(str(e))
|
|
224
|
+
await ui.warning("Model switched for this session only; failed to save default.")
|
|
197
225
|
else:
|
|
198
226
|
await ui.info("Model selection cancelled")
|
|
199
227
|
|
tunacode/cli/main.py
CHANGED
|
@@ -30,6 +30,9 @@ def main(
|
|
|
30
30
|
wizard: bool = typer.Option(
|
|
31
31
|
False, "--wizard", help="Run interactive setup wizard for guided configuration."
|
|
32
32
|
),
|
|
33
|
+
show_config: bool = typer.Option(
|
|
34
|
+
False, "--show-config", help="Show configuration dashboard and exit."
|
|
35
|
+
),
|
|
33
36
|
baseurl: str = typer.Option(
|
|
34
37
|
None, "--baseurl", help="API base URL (e.g., https://openrouter.ai/api/v1)"
|
|
35
38
|
),
|
|
@@ -49,6 +52,13 @@ def main(
|
|
|
49
52
|
await ui.version()
|
|
50
53
|
return
|
|
51
54
|
|
|
55
|
+
if show_config:
|
|
56
|
+
from tunacode.ui.config_dashboard import show_config_dashboard
|
|
57
|
+
|
|
58
|
+
await ui.banner()
|
|
59
|
+
show_config_dashboard()
|
|
60
|
+
return
|
|
61
|
+
|
|
52
62
|
await ui.banner()
|
|
53
63
|
|
|
54
64
|
# Start update check in background
|
tunacode/cli/repl.py
CHANGED
|
@@ -320,7 +320,9 @@ async def process_request(text: str, state_manager: StateManager, output: bool =
|
|
|
320
320
|
if enable_streaming:
|
|
321
321
|
await ui.spinner(False, state_manager.session.spinner, state_manager)
|
|
322
322
|
state_manager.session.is_streaming_active = True
|
|
323
|
-
streaming_panel = ui.StreamingAgentPanel(
|
|
323
|
+
streaming_panel = ui.StreamingAgentPanel(
|
|
324
|
+
debug=bool(state_manager.session.show_thoughts)
|
|
325
|
+
)
|
|
324
326
|
await streaming_panel.start()
|
|
325
327
|
state_manager.session.streaming_panel = streaming_panel
|
|
326
328
|
|
|
@@ -337,6 +339,20 @@ async def process_request(text: str, state_manager: StateManager, output: bool =
|
|
|
337
339
|
await streaming_panel.stop()
|
|
338
340
|
state_manager.session.streaming_panel = None
|
|
339
341
|
state_manager.session.is_streaming_active = False
|
|
342
|
+
# Emit source-side streaming diagnostics if thoughts are enabled
|
|
343
|
+
if state_manager.session.show_thoughts:
|
|
344
|
+
try:
|
|
345
|
+
raw = getattr(state_manager.session, "_debug_raw_stream_accum", "") or ""
|
|
346
|
+
events = getattr(state_manager.session, "_debug_events", []) or []
|
|
347
|
+
raw_first5 = repr(raw[:5])
|
|
348
|
+
await ui.muted(
|
|
349
|
+
f"[debug] raw_stream_first5={raw_first5} total_len={len(raw)}"
|
|
350
|
+
)
|
|
351
|
+
for line in events:
|
|
352
|
+
await ui.muted(line)
|
|
353
|
+
except Exception:
|
|
354
|
+
# Don't let diagnostics break normal flow
|
|
355
|
+
pass
|
|
340
356
|
else:
|
|
341
357
|
res = await agent.process_request(
|
|
342
358
|
text,
|
|
@@ -5,7 +5,7 @@ Default configuration values for the TunaCode CLI.
|
|
|
5
5
|
Provides sensible defaults for user configuration and environment variables.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
-
from tunacode.constants import GUIDE_FILE_NAME
|
|
8
|
+
from tunacode.constants import GUIDE_FILE_NAME
|
|
9
9
|
from tunacode.types import UserConfig
|
|
10
10
|
|
|
11
11
|
DEFAULT_USER_CONFIG: UserConfig = {
|
|
@@ -19,7 +19,7 @@ DEFAULT_USER_CONFIG: UserConfig = {
|
|
|
19
19
|
"settings": {
|
|
20
20
|
"max_retries": 10,
|
|
21
21
|
"max_iterations": 40,
|
|
22
|
-
"tool_ignore": [
|
|
22
|
+
"tool_ignore": [],
|
|
23
23
|
"guide_file": GUIDE_FILE_NAME,
|
|
24
24
|
"fallback_response": True,
|
|
25
25
|
"fallback_verbosity": "normal", # Options: minimal, normal, detailed
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Module: tunacode.configuration.key_descriptions
|
|
3
|
+
|
|
4
|
+
Educational descriptions and examples for configuration keys to help users
|
|
5
|
+
understand what each setting does and how to configure it properly.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from dataclasses import dataclass
|
|
9
|
+
from typing import Any, Dict, Optional
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclass
|
|
13
|
+
class KeyDescription:
|
|
14
|
+
"""Description of a configuration key with examples and help text."""
|
|
15
|
+
|
|
16
|
+
name: str
|
|
17
|
+
description: str
|
|
18
|
+
example: Any
|
|
19
|
+
help_text: str
|
|
20
|
+
category: str
|
|
21
|
+
is_sensitive: bool = False
|
|
22
|
+
service_type: Optional[str] = None # For API keys: "openai", "anthropic", etc.
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# Configuration key descriptions organized by category
|
|
26
|
+
CONFIG_KEY_DESCRIPTIONS: Dict[str, KeyDescription] = {
|
|
27
|
+
# Root level keys
|
|
28
|
+
"default_model": KeyDescription(
|
|
29
|
+
name="default_model",
|
|
30
|
+
description="Which AI model TunaCode uses by default",
|
|
31
|
+
example="openrouter:openai/gpt-4.1",
|
|
32
|
+
help_text="Format: provider:model-name. Examples: openai:gpt-4, anthropic:claude-3-sonnet, google:gemini-pro",
|
|
33
|
+
category="AI Models",
|
|
34
|
+
),
|
|
35
|
+
"skip_git_safety": KeyDescription(
|
|
36
|
+
name="skip_git_safety",
|
|
37
|
+
description="Skip Git safety checks when making changes",
|
|
38
|
+
example=True,
|
|
39
|
+
help_text="When true, TunaCode won't create safety branches before making changes. Use with caution!",
|
|
40
|
+
category="Safety Settings",
|
|
41
|
+
),
|
|
42
|
+
# Environment variables (API Keys)
|
|
43
|
+
"env.OPENAI_API_KEY": KeyDescription(
|
|
44
|
+
name="OPENAI_API_KEY",
|
|
45
|
+
description="Your OpenAI API key for GPT models",
|
|
46
|
+
example="sk-proj-abc123...",
|
|
47
|
+
help_text="Get this from https://platform.openai.com/api-keys. Required for OpenAI models like GPT-4.",
|
|
48
|
+
category="API Keys",
|
|
49
|
+
is_sensitive=True,
|
|
50
|
+
service_type="openai",
|
|
51
|
+
),
|
|
52
|
+
"env.ANTHROPIC_API_KEY": KeyDescription(
|
|
53
|
+
name="ANTHROPIC_API_KEY",
|
|
54
|
+
description="Your Anthropic API key for Claude models",
|
|
55
|
+
example="sk-ant-api03-abc123...",
|
|
56
|
+
help_text="Get this from https://console.anthropic.com/. Required for Claude models.",
|
|
57
|
+
category="API Keys",
|
|
58
|
+
is_sensitive=True,
|
|
59
|
+
service_type="anthropic",
|
|
60
|
+
),
|
|
61
|
+
"env.OPENROUTER_API_KEY": KeyDescription(
|
|
62
|
+
name="OPENROUTER_API_KEY",
|
|
63
|
+
description="Your OpenRouter API key for accessing multiple models",
|
|
64
|
+
example="sk-or-v1-abc123...",
|
|
65
|
+
help_text="Get this from https://openrouter.ai/keys. Gives access to many different AI models.",
|
|
66
|
+
category="API Keys",
|
|
67
|
+
is_sensitive=True,
|
|
68
|
+
service_type="openrouter",
|
|
69
|
+
),
|
|
70
|
+
"env.GEMINI_API_KEY": KeyDescription(
|
|
71
|
+
name="GEMINI_API_KEY",
|
|
72
|
+
description="Your Google Gemini API key",
|
|
73
|
+
example="AIza123...",
|
|
74
|
+
help_text="Get this from Google AI Studio. Required for Gemini models.",
|
|
75
|
+
category="API Keys",
|
|
76
|
+
is_sensitive=True,
|
|
77
|
+
service_type="google",
|
|
78
|
+
),
|
|
79
|
+
"env.OPENAI_BASE_URL": KeyDescription(
|
|
80
|
+
name="OPENAI_BASE_URL",
|
|
81
|
+
description="Custom API endpoint for OpenAI-compatible services",
|
|
82
|
+
example="https://api.cerebras.ai/v1",
|
|
83
|
+
help_text="Use this to connect to local models (LM Studio, Ollama) or alternative providers like Cerebras.",
|
|
84
|
+
category="API Configuration",
|
|
85
|
+
),
|
|
86
|
+
# Settings
|
|
87
|
+
"settings.max_retries": KeyDescription(
|
|
88
|
+
name="max_retries",
|
|
89
|
+
description="How many times to retry failed API calls",
|
|
90
|
+
example=10,
|
|
91
|
+
help_text="Higher values = more resilient to temporary API issues, but slower when APIs are down.",
|
|
92
|
+
category="Behavior Settings",
|
|
93
|
+
),
|
|
94
|
+
"settings.max_iterations": KeyDescription(
|
|
95
|
+
name="max_iterations",
|
|
96
|
+
description="Maximum conversation turns before stopping",
|
|
97
|
+
example=40,
|
|
98
|
+
help_text="Prevents infinite loops. TunaCode will stop after this many back-and-forth exchanges.",
|
|
99
|
+
category="Behavior Settings",
|
|
100
|
+
),
|
|
101
|
+
"settings.tool_ignore": KeyDescription(
|
|
102
|
+
name="tool_ignore",
|
|
103
|
+
description="List of tools TunaCode should not use",
|
|
104
|
+
example=["read_file", "write_file"],
|
|
105
|
+
help_text="Useful for restricting what TunaCode can do. Empty list means all tools are available.",
|
|
106
|
+
category="Tool Configuration",
|
|
107
|
+
),
|
|
108
|
+
"settings.guide_file": KeyDescription(
|
|
109
|
+
name="guide_file",
|
|
110
|
+
description="Name of your project guide file",
|
|
111
|
+
example="TUNACODE.md",
|
|
112
|
+
help_text="TunaCode looks for this file to understand your project. Usually TUNACODE.md or README.md.",
|
|
113
|
+
category="Project Settings",
|
|
114
|
+
),
|
|
115
|
+
"settings.fallback_response": KeyDescription(
|
|
116
|
+
name="fallback_response",
|
|
117
|
+
description="Whether to provide a response when tools fail",
|
|
118
|
+
example=True,
|
|
119
|
+
help_text="When true, TunaCode will try to help even if some tools don't work properly.",
|
|
120
|
+
category="Behavior Settings",
|
|
121
|
+
),
|
|
122
|
+
"settings.fallback_verbosity": KeyDescription(
|
|
123
|
+
name="fallback_verbosity",
|
|
124
|
+
description="How detailed fallback responses should be",
|
|
125
|
+
example="normal",
|
|
126
|
+
help_text="Options: minimal, normal, detailed. Controls how much TunaCode explains when things go wrong.",
|
|
127
|
+
category="Behavior Settings",
|
|
128
|
+
),
|
|
129
|
+
"settings.context_window_size": KeyDescription(
|
|
130
|
+
name="context_window_size",
|
|
131
|
+
description="Maximum tokens TunaCode can use in one conversation",
|
|
132
|
+
example=200000,
|
|
133
|
+
help_text="Larger values = TunaCode remembers more context, but costs more. Adjust based on your model's limits.",
|
|
134
|
+
category="Performance Settings",
|
|
135
|
+
),
|
|
136
|
+
"settings.enable_streaming": KeyDescription(
|
|
137
|
+
name="enable_streaming",
|
|
138
|
+
description="Show AI responses as they're generated",
|
|
139
|
+
example=True,
|
|
140
|
+
help_text="When true, you see responses appear word-by-word. When false, you wait for complete responses.",
|
|
141
|
+
category="User Experience",
|
|
142
|
+
),
|
|
143
|
+
# Ripgrep settings
|
|
144
|
+
"settings.ripgrep.use_bundled": KeyDescription(
|
|
145
|
+
name="ripgrep.use_bundled",
|
|
146
|
+
description="Use TunaCode's built-in ripgrep instead of system version",
|
|
147
|
+
example=False,
|
|
148
|
+
help_text="Usually false is better - uses your system's ripgrep which may be newer/faster.",
|
|
149
|
+
category="Search Settings",
|
|
150
|
+
),
|
|
151
|
+
"settings.ripgrep.timeout": KeyDescription(
|
|
152
|
+
name="ripgrep.timeout",
|
|
153
|
+
description="How long to wait for search results (seconds)",
|
|
154
|
+
example=10,
|
|
155
|
+
help_text="Prevents searches from hanging. Increase for very large codebases.",
|
|
156
|
+
category="Search Settings",
|
|
157
|
+
),
|
|
158
|
+
"settings.ripgrep.max_buffer_size": KeyDescription(
|
|
159
|
+
name="ripgrep.max_buffer_size",
|
|
160
|
+
description="Maximum size of search results (bytes)",
|
|
161
|
+
example=1048576,
|
|
162
|
+
help_text="1MB by default. Prevents memory issues with huge search results.",
|
|
163
|
+
category="Search Settings",
|
|
164
|
+
),
|
|
165
|
+
"settings.ripgrep.max_results": KeyDescription(
|
|
166
|
+
name="ripgrep.max_results",
|
|
167
|
+
description="Maximum number of search results to return",
|
|
168
|
+
example=100,
|
|
169
|
+
help_text="Prevents overwhelming output. Increase if you need more comprehensive search results.",
|
|
170
|
+
category="Search Settings",
|
|
171
|
+
),
|
|
172
|
+
"settings.ripgrep.enable_metrics": KeyDescription(
|
|
173
|
+
name="ripgrep.enable_metrics",
|
|
174
|
+
description="Collect performance data about searches",
|
|
175
|
+
example=False,
|
|
176
|
+
help_text="Enable for debugging search performance. Usually not needed.",
|
|
177
|
+
category="Search Settings",
|
|
178
|
+
),
|
|
179
|
+
"settings.ripgrep.debug": KeyDescription(
|
|
180
|
+
name="ripgrep.debug",
|
|
181
|
+
description="Show detailed search debugging information",
|
|
182
|
+
example=False,
|
|
183
|
+
help_text="Enable for troubleshooting search issues. Creates verbose output.",
|
|
184
|
+
category="Search Settings",
|
|
185
|
+
),
|
|
186
|
+
# Tutorial/onboarding settings
|
|
187
|
+
"settings.enable_tutorial": KeyDescription(
|
|
188
|
+
name="enable_tutorial",
|
|
189
|
+
description="Show tutorial prompts for new users",
|
|
190
|
+
example=True,
|
|
191
|
+
help_text="Helps new users learn TunaCode. Disable once you're comfortable with the tool.",
|
|
192
|
+
category="User Experience",
|
|
193
|
+
),
|
|
194
|
+
"settings.first_installation_date": KeyDescription(
|
|
195
|
+
name="first_installation_date",
|
|
196
|
+
description="When TunaCode was first installed",
|
|
197
|
+
example="2025-09-11T11:50:40.167105",
|
|
198
|
+
help_text="Automatically set. Used for tracking usage patterns and showing relevant tips.",
|
|
199
|
+
category="System Information",
|
|
200
|
+
),
|
|
201
|
+
"settings.tutorial_declined": KeyDescription(
|
|
202
|
+
name="tutorial_declined",
|
|
203
|
+
description="Whether user declined the tutorial",
|
|
204
|
+
example=True,
|
|
205
|
+
help_text="Automatically set when you skip the tutorial. Prevents repeated tutorial prompts.",
|
|
206
|
+
category="User Experience",
|
|
207
|
+
),
|
|
208
|
+
# MCP Servers
|
|
209
|
+
"mcpServers": KeyDescription(
|
|
210
|
+
name="mcpServers",
|
|
211
|
+
description="Model Context Protocol server configurations",
|
|
212
|
+
example={},
|
|
213
|
+
help_text="Advanced feature for connecting external tools and services. Usually empty for basic usage.",
|
|
214
|
+
category="Advanced Features",
|
|
215
|
+
),
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
def get_key_description(key_path: str) -> Optional[KeyDescription]:
|
|
220
|
+
"""Get description for a configuration key by its path."""
|
|
221
|
+
return CONFIG_KEY_DESCRIPTIONS.get(key_path)
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
def get_service_type_for_api_key(key_name: str) -> Optional[str]:
|
|
225
|
+
"""Determine the service type for an API key."""
|
|
226
|
+
service_mapping = {
|
|
227
|
+
"OPENAI_API_KEY": "openai",
|
|
228
|
+
"ANTHROPIC_API_KEY": "anthropic",
|
|
229
|
+
"OPENROUTER_API_KEY": "openrouter",
|
|
230
|
+
"GEMINI_API_KEY": "google",
|
|
231
|
+
}
|
|
232
|
+
return service_mapping.get(key_name)
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
def get_categories() -> Dict[str, list[KeyDescription]]:
|
|
236
|
+
"""Get all configuration keys organized by category."""
|
|
237
|
+
categories: Dict[str, list[KeyDescription]] = {}
|
|
238
|
+
|
|
239
|
+
for desc in CONFIG_KEY_DESCRIPTIONS.values():
|
|
240
|
+
if desc.category not in categories:
|
|
241
|
+
categories[desc.category] = []
|
|
242
|
+
categories[desc.category].append(desc)
|
|
243
|
+
|
|
244
|
+
return categories
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
def get_configuration_glossary() -> str:
|
|
248
|
+
"""Generate a glossary of configuration terms for the help section."""
|
|
249
|
+
glossary = """
|
|
250
|
+
[bold]Configuration Key Glossary[/bold]
|
|
251
|
+
|
|
252
|
+
[cyan]What are configuration keys?[/cyan]
|
|
253
|
+
Configuration keys are setting names (like 'default_model', 'max_retries') that control how TunaCode behaves.
|
|
254
|
+
Think of them like preferences in any app - they let you customize TunaCode to work the way you want.
|
|
255
|
+
|
|
256
|
+
[cyan]Key Categories:[/cyan]
|
|
257
|
+
• [yellow]AI Models[/yellow]: Which AI to use (GPT-4, Claude, etc.)
|
|
258
|
+
• [yellow]API Keys[/yellow]: Your credentials for AI services
|
|
259
|
+
• [yellow]Behavior Settings[/yellow]: How TunaCode acts (retries, iterations, etc.)
|
|
260
|
+
• [yellow]Tool Configuration[/yellow]: Which tools TunaCode can use
|
|
261
|
+
• [yellow]Performance Settings[/yellow]: Memory and speed optimizations
|
|
262
|
+
• [yellow]User Experience[/yellow]: Interface and tutorial preferences
|
|
263
|
+
|
|
264
|
+
[cyan]Common Examples:[/cyan]
|
|
265
|
+
• default_model → Which AI model to use by default
|
|
266
|
+
• max_retries → How many times to retry failed requests
|
|
267
|
+
• OPENAI_API_KEY → Your OpenAI account credentials
|
|
268
|
+
• tool_ignore → List of tools TunaCode shouldn't use
|
|
269
|
+
• context_window_size → How much conversation history to remember
|
|
270
|
+
|
|
271
|
+
[cyan]Default vs Custom:[/cyan]
|
|
272
|
+
• 📋 Default: TunaCode's built-in settings (work for most people)
|
|
273
|
+
• 🔧 Custom: Settings you've changed to fit your needs
|
|
274
|
+
"""
|
|
275
|
+
return glossary.strip()
|
tunacode/constants.py
CHANGED
|
@@ -209,11 +209,32 @@ async def _process_node(
|
|
|
209
209
|
# Stream content to callback if provided
|
|
210
210
|
# Use this as fallback when true token streaming is not available
|
|
211
211
|
if streaming_callback and not STREAMING_AVAILABLE:
|
|
212
|
+
# Basic diagnostics for first-chunk behavior in fallback streaming
|
|
213
|
+
first_emitted = False
|
|
214
|
+
raw_accum = ""
|
|
212
215
|
for part in node.model_response.parts:
|
|
213
216
|
if hasattr(part, "content") and isinstance(part.content, str):
|
|
214
|
-
content = part.content
|
|
215
|
-
|
|
216
|
-
|
|
217
|
+
content = part.content
|
|
218
|
+
# Only check for empty content and JSON thoughts, don't strip whitespace
|
|
219
|
+
# as it may remove important leading spaces/characters
|
|
220
|
+
if content and not content.lstrip().startswith('{"thought"'):
|
|
221
|
+
if not first_emitted:
|
|
222
|
+
try:
|
|
223
|
+
import time as _t
|
|
224
|
+
|
|
225
|
+
ts_ns = _t.perf_counter_ns()
|
|
226
|
+
except Exception:
|
|
227
|
+
ts_ns = 0
|
|
228
|
+
# We cannot guarantee session access here; log via logger only
|
|
229
|
+
logger.debug(
|
|
230
|
+
"[src-fallback] first_chunk ts_ns=%s chunk_repr=%r len=%d",
|
|
231
|
+
ts_ns,
|
|
232
|
+
content[:5],
|
|
233
|
+
len(content),
|
|
234
|
+
)
|
|
235
|
+
first_emitted = True
|
|
236
|
+
raw_accum += content
|
|
237
|
+
# Stream the original content without stripping
|
|
217
238
|
if streaming_callback:
|
|
218
239
|
await streaming_callback(content)
|
|
219
240
|
|
|
@@ -448,7 +469,22 @@ async def _process_tool_calls(
|
|
|
448
469
|
f"[bold #00d7ff]{tool_desc}...[/bold #00d7ff]", state_manager
|
|
449
470
|
)
|
|
450
471
|
|
|
451
|
-
|
|
472
|
+
# Execute the tool with robust error handling so one failure doesn't crash the run
|
|
473
|
+
try:
|
|
474
|
+
await tool_callback(part, node)
|
|
475
|
+
except Exception as tool_err:
|
|
476
|
+
logger.error(
|
|
477
|
+
"Tool callback failed: tool=%s iter=%s err=%s",
|
|
478
|
+
getattr(part, "tool_name", "<unknown>"),
|
|
479
|
+
getattr(state_manager.session, "current_iteration", "?"),
|
|
480
|
+
tool_err,
|
|
481
|
+
exc_info=True,
|
|
482
|
+
)
|
|
483
|
+
# Surface to UI when thoughts are enabled, then continue gracefully
|
|
484
|
+
if getattr(state_manager.session, "show_thoughts", False):
|
|
485
|
+
await ui.warning(
|
|
486
|
+
f"❌ Tool failed: {getattr(part, 'tool_name', '<unknown>')} — continuing"
|
|
487
|
+
)
|
|
452
488
|
|
|
453
489
|
# Track tool calls in session
|
|
454
490
|
if is_processing_tools:
|