Skip to content

Commit 2daea58

Browse files
authored
Merge pull request #358 from dwash96/v0.92.1
v0.92.1
2 parents 751af8d + 3067b68 commit 2daea58

46 files changed

Lines changed: 1052 additions & 567 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

benchmark/benchmark.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
# Cache for commit-hash -> version lookup
4141
_VERSION_CACHE = {}
4242

43-
BENCHMARK_DNAME = Path(os.environ.get("CECLIBENCHMARK_DIR", "tmp.benchmarks"))
43+
BENCHMARK_DNAME = Path(os.environ.get("CECLI_BENCHMARK_DIR", "tmp.benchmarks"))
4444
EXERCISES_DIR_DEFAULT = "cecli-cat"
4545
RESULTS_DIR_DEFAULT = "cat-results"
4646

@@ -209,9 +209,11 @@ def main(
209209
return 1
210210
results_dir = resolved_results_dir
211211

212-
if not dry and "CECLIDOCKER" not in os.environ:
212+
if not dry and "CECLI_DOCKER" not in os.environ:
213213
logger.warning("Warning: Benchmarking runs unvetted code. Run in a docker container.")
214-
logger.warning("Set CECLIDOCKER in the environment to by-pass this check at your own risk.")
214+
logger.warning(
215+
"Set CECLI_DOCKER in the environment to by-pass this check at your own risk."
216+
)
215217
return
216218

217219
# Check dirs exist

benchmark/benchmark_classic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
# Cache for commit-hash -> version lookup
3535
_VERSION_CACHE = {}
3636

37-
BENCHMARK_DNAME = Path(os.environ.get("CECLIBENCHMARK_DIR", "tmp.benchmarks"))
37+
BENCHMARK_DNAME = Path(os.environ.get("CECLI_BENCHMARK_DIR", "tmp.benchmarks"))
3838

3939
EXERCISES_DIR_DEFAULT = "polyglot-benchmark"
4040

@@ -267,7 +267,7 @@ def main(
267267
if repo.is_dirty():
268268
commit_hash += "-dirty"
269269

270-
if "CECLIDOCKER" not in os.environ:
270+
if "CECLI_DOCKER" not in os.environ:
271271
print("Warning: benchmarking runs unvetted code from GPT, run in a docker container")
272272
return
273273

cecli/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from packaging import version
22

3-
__version__ = "0.92.0.dev"
3+
__version__ = "0.92.1.dev"
44
safe_version = __version__
55

66
try:

cecli/args.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def get_parser(default_config_files, git_root):
3838
add_config_file_help=True,
3939
default_config_files=default_config_files,
4040
config_file_parser_class=configargparse.YAMLConfigFileParser,
41-
auto_env_var_prefix="CECLI",
41+
auto_env_var_prefix="CECLI_",
4242
)
4343
# List of valid edit formats for argparse validation & shtab completion.
4444
# Dynamically gather them from the registered coder classes so the list
@@ -567,7 +567,7 @@ def get_parser(default_config_files, git_root):
567567

568568
group.add_argument(
569569
"--cecli-ignore",
570-
metavar="CECLIIGNORE",
570+
metavar="CECLI_IGNORE",
571571
type=lambda path_str: resolve_cecli_ignore_path(path_str, git_root),
572572
default=default_cecli_ignore_file,
573573
help="Specify the cecli ignore file (default: .cecli.ignore in git root)",

cecli/coders/architect_coder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22

3-
from ..commands import SwitchCoder
3+
from ..commands import SwitchCoderSignal
44
from .ask_coder import AskCoder
55
from .base_coder import Coder
66

@@ -60,4 +60,4 @@ async def reply_completed(self):
6060
except Exception as e:
6161
self.io.tool_error(e)
6262

63-
raise SwitchCoder(main_model=self.main_model, edit_format="architect")
63+
raise SwitchCoderSignal(main_model=self.main_model, edit_format="architect")

cecli/coders/base_coder.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
import cecli.prompts.utils.system as prompts
3838
from cecli import __version__, models, urls, utils
39-
from cecli.commands import Commands, SwitchCoder
39+
from cecli.commands import Commands, SwitchCoderSignal
4040
from cecli.exceptions import LiteLLMExceptions
4141
from cecli.helpers import coroutines
4242
from cecli.helpers.profiler import TokenProfiler
@@ -1370,7 +1370,7 @@ async def _run_parallel(self, with_message=None, preproc=True):
13701370
if task.exception():
13711371
raise task.exception()
13721372

1373-
except (SwitchCoder, SystemExit):
1373+
except (SwitchCoderSignal, SystemExit):
13741374
# Re-raise SwitchCoder to be handled by outer try block
13751375
raise
13761376
except KeyboardInterrupt:
@@ -1461,7 +1461,7 @@ async def input_task(self, preproc):
14611461
self.io.set_placeholder("")
14621462
self.keyboard_interrupt()
14631463
await self.io.stop_task_streams()
1464-
except (SwitchCoder, SystemExit):
1464+
except (SwitchCoderSignal, SystemExit):
14651465
raise
14661466
except Exception as e:
14671467
if self.verbose or self.args.debug:
@@ -1496,7 +1496,7 @@ async def output_task(self, preproc):
14961496
if self.io.output_task.done():
14971497
exception = self.io.output_task.exception()
14981498
if exception:
1499-
if isinstance(exception, SwitchCoder):
1499+
if isinstance(exception, SwitchCoderSignal):
15001500
await self.io.output_task
15011501
raise exception
15021502

@@ -1519,7 +1519,7 @@ async def output_task(self, preproc):
15191519
self.io.stop_spinner()
15201520
self.keyboard_interrupt()
15211521
await self.io.stop_task_streams()
1522-
except (SwitchCoder, SystemExit):
1522+
except (SwitchCoderSignal, SystemExit):
15231523
raise
15241524
except Exception as e:
15251525
if self.verbose or self.args.debug:
@@ -2138,7 +2138,7 @@ def warm_cache(self, chunks):
21382138
return
21392139

21402140
delay = 5 * 60 - 5
2141-
delay = float(os.environ.get("CECLICACHE_KEEPALIVE_DELAY", delay))
2141+
delay = float(os.environ.get("CECLI_CACHE_KEEPALIVE_DELAY", delay))
21422142
self.next_cache_warm = time.time() + delay
21432143
self.warming_pings_left = self.num_cache_warming_pings
21442144
self.cache_warming_chunks = chunks
@@ -2741,7 +2741,7 @@ async def get_server_tools(server):
27412741
)
27422742
return (server.name, server_tools)
27432743
except Exception as e:
2744-
if server.name != "unnamed-server" and server.name != "local_tools":
2744+
if server.name != "unnamed-server" and server.name != "Local":
27452745
self.io.tool_warning(f"Error initializing MCP server {server.name}: {e}")
27462746
return None
27472747

cecli/commands/__init__.py

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
BaseCommand pattern for modular, testable command execution.
66
"""
77

8-
import sys
9-
import traceback
10-
from pathlib import Path
11-
128
from .add import AddCommand
139
from .agent import AgentCommand
1410
from .architect import ArchitectCommand
@@ -22,6 +18,7 @@
2218
from .context_management import ContextManagementCommand
2319
from .copy import CopyCommand
2420
from .copy_context import CopyContextCommand
21+
from .core import Commands, SwitchCoderSignal
2522
from .diff import DiffCommand
2623

2724
# Import and register commands
@@ -127,50 +124,6 @@
127124
CommandRegistry.register(LoadSkillCommand)
128125
CommandRegistry.register(RemoveSkillCommand)
129126

130-
# Import SwitchCoder and Commands directly from commands.py
131-
# We need to handle the circular import carefully
132-
133-
# Add parent directory to path to import commands.py directly
134-
parent_dir = str(Path(__file__).parent.parent)
135-
if parent_dir not in sys.path:
136-
sys.path.insert(0, parent_dir)
137-
138-
# Import the commands module directly
139-
try:
140-
import importlib.util
141-
142-
spec = importlib.util.spec_from_file_location(
143-
"cecli.commands_module", Path(__file__).parent.parent / "commands.py"
144-
)
145-
commands_module = importlib.util.module_from_spec(spec)
146-
sys.modules["cecli.commands_module"] = commands_module
147-
spec.loader.exec_module(commands_module)
148-
149-
# Get the classes from the module
150-
Commands = getattr(commands_module, "Commands", None)
151-
SwitchCoder = getattr(commands_module, "SwitchCoder", None)
152-
153-
if Commands is None or SwitchCoder is None:
154-
raise ImportError("Commands or SwitchCoder not found in commands.py")
155-
156-
except Exception as e:
157-
# Print the error for debugging
158-
print(f"Error importing commands.py: {e}")
159-
traceback.print_exc()
160-
161-
# Fallback: define simple placeholder classes
162-
class SwitchCoder(Exception):
163-
def __init__(self, placeholder=None, **kwargs):
164-
self.kwargs = kwargs
165-
self.placeholder = placeholder
166-
167-
class Commands:
168-
"""Placeholder for Commands class defined in original commands.py"""
169-
170-
def __init__(self, *args, **kwargs):
171-
# Accept any arguments but do nothing
172-
pass
173-
174127

175128
__all__ = [
176129
"BaseCommand",
@@ -234,6 +187,6 @@ def __init__(self, *args, **kwargs):
234187
"CommandPrefixCommand",
235188
"LoadSkillCommand",
236189
"RemoveSkillCommand",
237-
"SwitchCoder",
190+
"SwitchCoderSignal",
238191
"Commands",
239192
]

cecli/commands/add.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ async def execute(cls, io, coder, args, **kwargs):
137137
map_tokens = 0
138138
map_mul_no_files = 1
139139

140-
from cecli.commands import SwitchCoder
140+
from cecli.commands import SwitchCoderSignal
141141

142-
raise SwitchCoder(
142+
raise SwitchCoderSignal(
143143
edit_format=coder.edit_format,
144144
summarize_from_coder=False,
145145
from_coder=coder,
Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,32 @@
33
import sys
44
from pathlib import Path
55

6+
from cecli.commands.utils.registry import CommandRegistry
67
from cecli.helpers.file_searcher import handle_core_files
78
from cecli.repo import ANY_GIT_ERROR
89

9-
from .commands.utils.registry import CommandRegistry
1010

11+
class SwitchCoderSignal(BaseException):
12+
"""
13+
Signal to switch the current Coder instance to a new configuration.
14+
15+
This is NOT an error - it's a control flow signal used to propagate
16+
coder switching requests up through the async call stack. It carries
17+
the kwargs needed to create a new Coder instance.
18+
19+
Note: Inherits from BaseException (like KeyboardInterrupt and SystemExit)
20+
to avoid being caught by generic `except Exception` handlers, making the
21+
non-error nature of this signal explicit.
22+
23+
Attributes:
24+
kwargs: Configuration dict passed to Coder.create() for the new instance
25+
placeholder: Optional placeholder text for the input prompt
26+
"""
1127

12-
class SwitchCoder(Exception):
1328
def __init__(self, placeholder=None, **kwargs):
1429
self.kwargs = kwargs
1530
self.placeholder = placeholder
31+
super().__init__()
1632

1733

1834
class Commands:
@@ -119,7 +135,7 @@ async def do_run(self, cmd_name, args, **kwargs):
119135
except ANY_GIT_ERROR as err:
120136
self.io.tool_error(f"Unable to complete {cmd_name}: {err}")
121137
return
122-
except SwitchCoder as e:
138+
except SwitchCoderSignal as e:
123139
raise e
124140
except Exception as e:
125141
self.io.tool_error(f"Error executing command {cmd_name}: {str(e)}")

cecli/commands/drop.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,18 @@ async def execute(cls, io, coder, args, **kwargs):
8282
return format_command_result(io, "drop", "Removed files from chat")
8383

8484
finally:
85-
# This mimics the SwitchCoder behavior in the original cmd_drop
85+
# This mimics the SwitchCoderSignal behavior in the original cmd_drop
8686
if coder.repo_map:
8787
map_tokens = coder.repo_map.max_map_tokens
8888
map_mul_no_files = coder.repo_map.map_mul_no_files
8989
else:
9090
map_tokens = 0
9191
map_mul_no_files = 1
9292

93-
# Raise SwitchCoder to trigger coder recreation
94-
from . import SwitchCoder
93+
# Raise SwitchCoderSignal to trigger coder recreation
94+
from . import SwitchCoderSignal
9595

96-
raise SwitchCoder(
96+
raise SwitchCoderSignal(
9797
edit_format=coder.edit_format,
9898
summarize_from_coder=False,
9999
from_coder=coder,

0 commit comments

Comments
 (0)