lcode-cli 0.62.0__py3-none-any.whl → 0.63.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.
lcode/__init__.py CHANGED
@@ -3,7 +3,7 @@
3
3
  From a program: `from lcode import Session` (see lcode.api).
4
4
  """
5
5
 
6
- __version__ = "0.62.0"
6
+ __version__ = "0.63.1"
7
7
 
8
8
  API = ("Session", "Result", "Options", "SetupError")
9
9
 
lcode/agent.py CHANGED
@@ -44,27 +44,47 @@ if TYPE_CHECKING:
44
44
 
45
45
  MAX_STALLS = 2 # replies in a row that go round in circles or say nothing, before lcode stops the request
46
46
  MAX_STALLS_PER_REQUEST = 4 # such replies in one request, even with work in between
47
+ THOUGHT_TAIL = 1500 # characters of a stopped reply's thinking that the model gets back, so it needn't start over
47
48
  STALLED = {
48
49
  "circles": "the reply went round in circles, so lcode stopped it",
50
+ "overthought": "the reply thought at length without acting, so lcode stopped it",
49
51
  "cut_off": "the reply filled the context before it said anything",
50
52
  "": "the reply was empty",
51
53
  }
52
54
 
53
55
 
54
- def stall_note(trouble: str, thinking_off: bool = False) -> str:
55
- """What the model is told after a reply that went round in circles or ended without a word."""
56
+ def stall_note(trouble: str, thinking_off: bool = False, thought: str = "") -> str:
57
+ """What the model is told after a reply that went round in circles, thought too long or ended without a word.
58
+
59
+ `thought` is the stopped reply's thinking: for one that thought too long, its end goes back to the model, so
60
+ the next reply can act on where the reasoning got to instead of starting it over (#241)."""
56
61
  first = {
57
62
  "circles": "Your last reply went round in circles (the same thoughts over and over), so lcode stopped it.",
63
+ "overthought": "Your last reply thought at length without writing anything or making a tool call, so lcode "
64
+ "stopped it.",
58
65
  "cut_off": "Your last reply filled the rest of the context before you said anything.",
59
66
  "": "Your last reply was empty.",
60
67
  }[trouble]
61
68
  off = ": thinking is off for this reply" if thinking_off else ""
62
- return (
69
+ note = (
63
70
  f"[lcode] {first} Don't deliberate at length now{off}. Either make your next tool call, or, if you're stuck, "
64
71
  "tell the user in a few lines what you did, what fails, and what they could do. If you were about to check "
65
72
  "something by running it, run it now instead of reasoning about it: for a window, take a screenshot (with "
66
73
  "actions for clicks or keys)."
67
74
  )
75
+ if trouble == "overthought" and thought.strip():
76
+ note += f"\n\nWhere your thinking had got to (its last part):\n\n{thought_tail(thought)}"
77
+ return note
78
+
79
+
80
+ def thought_tail(thought: str) -> str:
81
+ """The end of a stopped reply's thinking, from a line or sentence start: about THOUGHT_TAIL characters."""
82
+ if len(thought) <= THOUGHT_TAIL:
83
+ return thought.strip()
84
+ tail = thought[-THOUGHT_TAIL:]
85
+ ends = [tail.find(end) + len(end) for end in ("\n", ". ", "? ", "! ", "… ") if end in tail]
86
+ starts = [i for i in ends if i < len(tail) // 2] or [tail.find(" ") + 1] # else at least a whole word
87
+ return "…" + tail[min(starts) :].strip()
68
88
 
69
89
 
70
90
  EVENT_OUTPUT = 4000 # characters of a tool's output in an event
@@ -343,7 +363,9 @@ class Agent(PromptParts, Sessions, Checks, ContextWindow, ModelCalls):
343
363
  continue
344
364
  if not calls and (self.reply_trouble == "circles" or not (reply.get("content") or "").strip()):
345
365
  stalls += 1
346
- stalled += 1
366
+ # A reply that only thought too long counts as one in a row, so one that goes nowhere after it ends
367
+ # the request, but not towards the limit per request: in a long task, hard steps think long.
368
+ stalled += self.reply_trouble != "overthought"
347
369
  dropped = self.messages.pop() # no answer, and circles would only fill the context
348
370
  kept = self.keep_dropped(dropped)
349
371
  if stalls < MAX_STALLS and stalled < MAX_STALLS_PER_REQUEST:
@@ -351,10 +373,14 @@ class Agent(PromptParts, Sessions, Checks, ContextWindow, ModelCalls):
351
373
  # the same deliberation over (all 6 polyglot-rust-c attempts on the dev slice, #241).
352
374
  pause = self.settings.think and self.can_skip_thinking()
353
375
  off = ", with thinking off" if pause else ""
354
- self.console.print(
355
- Text(f" ⎿ {STALLED[self.reply_trouble]}: asking for a short answer{off}{kept}", style="yellow")
356
- )
357
- note = stall_note(self.reply_trouble, thinking_off=pause)
376
+ what = STALLED[self.reply_trouble]
377
+ if self.reply_trouble == "overthought":
378
+ what = (
379
+ f"the reply thought for over {format_tokens(self.settings.think_budget)} tokens without "
380
+ "acting (think_budget), so lcode stopped it"
381
+ )
382
+ self.console.print(Text(f" ⎿ {what}: asking for a short answer{off}{kept}", style="yellow"))
383
+ note = stall_note(self.reply_trouble, thinking_off=pause, thought=dropped.get("thinking") or "")
358
384
  self.messages.append({"role": "user", "content": note})
359
385
  continue
360
386
  times = "twice in a row" if stalls >= MAX_STALLS else f"{stalled} times in this request"
lcode/agent_base.py CHANGED
@@ -86,6 +86,7 @@ class Settings:
86
86
  secret_check: bool = True # scan what git commit and git push would add (lcode.secretscan)
87
87
  compact_at: int = 0 # tokens: make room at this size even when the window is larger (0: only at 85%)
88
88
  repeat_limit: int = 3 # identical calls with identical results before the model is told (lcode.repeats)
89
+ think_budget: int = 7000 # tokens a reply may think before it writes or calls a tool (0: no limit)
89
90
  checks: str = "off" # the project's checks after a change (lcode.checks): auto, off or a command
90
91
  review: str = "off" # check a change against the request before the answer (lcode.review): auto or off
91
92
  escalate_model: str | None = None # a stronger model to ask when stuck (lcode.escalate): provider/model
@@ -191,7 +192,7 @@ class AgentBase:
191
192
  self.turn_status = "" # how the last request ended: success, max_steps, loop, blocked
192
193
  self.repeats = Repeats(settings.repeat_limit) # notices when the model repeats itself
193
194
  self.sites = Sites(NOTE_AT if settings.repeat_limit else 0) # notices a site this machine can't reach
194
- self.reply_trouble = "" # what went wrong with the last reply: "circles", "cut_off" or ""
195
+ self.reply_trouble = "" # what went wrong with the last reply: "circles", "overthought", "cut_off" or ""
195
196
  self.response = None # the streaming response, so another thread can abort it
196
197
  self.ctx_used = 0
197
198
  self._repo: tuple[Path, repoid.Repo | None] | None = None # the workspace's repository, for saved sessions
lcode/agent_model.py CHANGED
@@ -41,6 +41,8 @@ GPU_MEMORY_ERRORS = (
41
41
 
42
42
 
43
43
  SAFE_NUM_BATCH = 512 # Ollama's default prompt batch
44
+ # Characters a thinking token takes: qwen3.6's long thinking on the dev slice, as Ollama counted it (median 3.3).
45
+ THINK_CHARS_PER_TOKEN = 3.3
44
46
 
45
47
 
46
48
  class Progress:
@@ -229,7 +231,11 @@ class ModelCalls(AgentBase):
229
231
  """Stream one model response, rendering thinking/content live. Returns the assistant message.
230
232
 
231
233
  `think=False` asks for this reply without thinking, even when thinking is on: after a reply that went
232
- round in circles, so the model acts instead of starting the same deliberation over."""
234
+ round in circles, so the model acts instead of starting the same deliberation over.
235
+
236
+ A reply that thinks past `think_budget` tokens before it writes anything or calls a tool is stopped
237
+ (`reply_trouble` "overthought"): on the dev slice, 2 of 102 attempts that passed had one, against 42 of 110
238
+ that failed (#241)."""
233
239
  content, thinking, tool_calls, final = "", "", [], {}
234
240
  md = MarkdownStreamer(self.console)
235
241
  progress = Progress(steering=self.steering)
@@ -251,6 +257,7 @@ class ModelCalls(AgentBase):
251
257
 
252
258
  start_spinner()
253
259
  circles = Circles()
260
+ budget = self.settings.think_budget * THINK_CHARS_PER_TOKEN
254
261
  self.reply_trouble = ""
255
262
  stream = self.chat(self.messages, self.tool_schemas(), self.settings.think and think)
256
263
  try:
@@ -273,6 +280,10 @@ class ModelCalls(AgentBase):
273
280
  if self.settings.repeat_limit and circles.feed(msg["thinking"]):
274
281
  self.reply_trouble = "circles"
275
282
  break # closing the stream below stops the model
283
+ acted = content.strip() or (msg.get("content") or "").strip() or tool_calls or msg.get("tool_calls")
284
+ if budget and len(thinking) > budget and not acted:
285
+ self.reply_trouble = "overthought"
286
+ break
276
287
  if msg.get("content"):
277
288
  if printed_thinking:
278
289
  self.console.print("\n")
lcode/api.py CHANGED
@@ -266,6 +266,7 @@ def open_agent(cwd: Path, options: Options, console: Console, hw: Hardware | Non
266
266
  notify_after=cfg["notify_after"],
267
267
  secret_check=cfg["secret_check"],
268
268
  repeat_limit=cfg["repeat_limit"],
269
+ think_budget=cfg["think_budget"],
269
270
  checks=cfg["checks"],
270
271
  review=cfg["review"],
271
272
  escalate_model=cfg["escalate_model"],
@@ -345,6 +346,12 @@ def close_agent(agent: Agent) -> None:
345
346
  # ----------------------------------------------------------------------------- running
346
347
 
347
348
 
349
+ def request_status(agent: Agent) -> str:
350
+ """How a request that ran to its end went: success, or max_steps, loop or blocked when lcode stopped it. `lcode -p`
351
+ exits with its code (EXIT_CODES), with or without --output."""
352
+ return agent.turn_status if agent.turn_status in ("max_steps", "loop", "blocked") else "success"
353
+
354
+
348
355
  def run_request(agent: Agent, prompt: str) -> Result:
349
356
  """Run one request to its end and say how it went; errors end up in the result, not raised."""
350
357
  calls: dict[str, dict] = {}
@@ -369,7 +376,7 @@ def run_request(agent: Agent, prompt: str) -> Result:
369
376
 
370
377
  try:
371
378
  agent.run_turn(prompt)
372
- status = agent.turn_status if agent.turn_status in ("max_steps", "loop", "blocked") else "success"
379
+ status = request_status(agent)
373
380
  except KeyboardInterrupt:
374
381
  status, error = "interrupted", "interrupted before the request was done"
375
382
  except ModelError as e:
lcode/backends.py CHANGED
@@ -21,7 +21,7 @@ from urllib.parse import quote
21
21
 
22
22
  import requests
23
23
 
24
- from lcode.ollama import OllamaError, redact
24
+ from lcode.ollama import OllamaError, redact, reply_lines
25
25
 
26
26
  PRESETS = { # backend setting -> (the server's name, its default address)
27
27
  "lmstudio": ("LM Studio", "http://localhost:1234/v1"),
@@ -308,7 +308,7 @@ class OpenAICompatible:
308
308
  with r:
309
309
  if r.status_code != 200:
310
310
  raise self._failed(r.status_code, r.text)
311
- for line in r.iter_lines():
311
+ for line in reply_lines(r, self.name, self.host, BackendError):
312
312
  if not line or not line.startswith(b"data:"):
313
313
  continue
314
314
  data = line[5:].strip()
lcode/bench.py CHANGED
@@ -27,12 +27,12 @@ from rich.markup import escape
27
27
  from rich.table import Table
28
28
  from rich.text import Text
29
29
 
30
- from lcode import __version__, escalate
30
+ from lcode import __version__, escalate, residency
31
31
  from lcode.agent import Agent, Settings
32
32
  from lcode.bench_checks import Check, Task
33
33
  from lcode.bench_quick import TASKS
34
34
  from lcode.config import format_tokens
35
- from lcode.hardware import Hardware
35
+ from lcode.hardware import GIB, Hardware
36
36
  from lcode.ollama import Ollama, OllamaError
37
37
 
38
38
  SCHEMA_VERSION = 1
@@ -188,8 +188,10 @@ class ModelRun:
188
188
  think: bool = True
189
189
  load_seconds: float = 0.0
190
190
  prompt_tps: float | None = None # measured with a fresh prompt; see prompt_speed()
191
- memory_gb: float | None = None
192
- gpu_percent: int | None = None
191
+ memory_gb: float | None = None # as Ollama's /api/ps counts it, which can leave part of the model out
192
+ gpu_percent: int | None = None # of memory_gb, on the GPU
193
+ estimated_memory_gib: float | None = None # all of the model by the catalog's estimate, when Ollama leaves part out
194
+ estimated_gpu_percent: int | None = None # of estimated_memory_gib, on the GPU
193
195
  usage: dict = field(default_factory=dict)
194
196
  tasks: list[TaskResult] = field(default_factory=list)
195
197
  error: str | None = None # the model couldn't run at all
@@ -219,6 +221,14 @@ class ModelRun:
219
221
  def tool_errors(self) -> int:
220
222
  return sum(t.tool_errors for t in self.tasks)
221
223
 
224
+ def note_memory(self, where: residency.Placement) -> None:
225
+ """Ollama's count keeps the names it always had, so results compare with older ones. The estimate that the line
226
+ after the load shows goes next to it."""
227
+ self.memory_gb, self.gpu_percent = round(where.size / 1e9, 1), round(100 * where.vram / where.size)
228
+ if where.estimate > where.size:
229
+ self.estimated_memory_gib = round(where.estimate / GIB, 1)
230
+ self.estimated_gpu_percent = round(100 * where.gpu_share)
231
+
222
232
  def to_json(self) -> dict:
223
233
  data = asdict(self)
224
234
  rates = self.rates()
@@ -410,13 +420,11 @@ def _read_prompt(ollama: Ollama, settings: Settings, options: dict) -> float | N
410
420
  return round(count / (ns / 1e9), 1) if ns and count >= 1000 else None
411
421
 
412
422
 
413
- def memory_use(ollama: Ollama, model: str) -> tuple[float | None, int | None]:
414
- for entry in ollama.running():
415
- if entry.get("name") in (model, f"{model}:latest") or entry.get("model") in (model, f"{model}:latest"):
416
- size, vram = entry.get("size") or 0, entry.get("size_vram") or 0
417
- if size:
418
- return round(size / 1e9, 1), round(100 * vram / size)
419
- return None, None
423
+ def memory_use(ollama: Ollama, model: str, context: int) -> residency.Placement | None:
424
+ """How the loaded model sits in memory, counted as the line after a load counts it: Ollama 0.40 leaves out the
425
+ part of a Mixture-of-Experts model that stays mapped from its file in RAM (see residency.with_estimate)."""
426
+ where = residency.placement(ollama, model) # Ollama lists lcode-qwen3.6-35b as lcode-qwen3.6-35b:latest
427
+ return residency.with_estimate(where, model, context) if where and where.size else None
420
428
 
421
429
 
422
430
  def run_model(
@@ -455,14 +463,15 @@ def run_model(
455
463
  run.interrupted = True
456
464
  return run
457
465
  run.load_seconds = round(time.monotonic() - started, 1)
458
- run.memory_gb, run.gpu_percent = memory_use(ollama, settings.model)
466
+ if placed := memory_use(ollama, settings.model, settings.context):
467
+ run.note_memory(placed)
459
468
  try:
460
469
  with console.status(Elapsed(" Measuring prompt speed")):
461
470
  run.prompt_tps = prompt_speed(ollama, settings, options)
462
471
  except KeyboardInterrupt:
463
472
  run.interrupted = True
464
473
  return run
465
- where = f" · {run.memory_gb} GB, {run.gpu_percent}% on the GPU" if run.memory_gb else ""
474
+ where = f" · {placed.describe()}" if placed else ""
466
475
  reads = f" · reads prompts at {run.prompt_tps:,.0f} tok/s" if run.prompt_tps else ""
467
476
  if getattr(ollama, "kind", "ollama") == "ollama":
468
477
  console.print(f" [dim]Loaded in {run.load_seconds:.0f}s{where}{reads}[/]")
@@ -503,8 +512,8 @@ def run_model(
503
512
  run.pruned, run.compacted = pruned + shared.pruned, compacted + shared.compacted
504
513
  if run.interrupted:
505
514
  break
506
- if run.memory_gb is None:
507
- run.memory_gb, run.gpu_percent = memory_use(ollama, settings.model)
515
+ if run.memory_gb is None and (placed := memory_use(ollama, settings.model, settings.context)):
516
+ run.note_memory(placed)
508
517
  # lcode lowers the batch size or context if the GPU runs out of memory; report what was used.
509
518
  run.context, run.num_batch, run.think = settings.context, settings.num_batch, settings.think
510
519
  return run
@@ -521,6 +530,13 @@ def percent(share: float | None) -> str:
521
530
  return "–" if share is None else f"{share * 100:.0f}%"
522
531
 
523
532
 
533
+ def memory(run: ModelRun) -> str:
534
+ """'~23 GB, 42% on GPU' by lcode's estimate, as the line after the load counts it, or else what Ollama says."""
535
+ if run.estimated_memory_gib:
536
+ return f"~{run.estimated_memory_gib:.0f} GB, {run.estimated_gpu_percent}% on GPU"
537
+ return f"{run.memory_gb} GB, {run.gpu_percent}% on GPU" if run.memory_gb else "?"
538
+
539
+
524
540
  def summary_rows(runs: list[ModelRun], tasks: list[Task]) -> list[tuple[str, list[str]]]:
525
541
  rows = []
526
542
  for task in {t.id: t for t in tasks}.values(): # a task that ran several times: one row, a mark each
@@ -554,10 +570,7 @@ def summary_rows(runs: list[ModelRun], tasks: list[Task]) -> list[tuple[str, lis
554
570
  ("Generation", [cell(r, f"{r.generation_tps:.1f} tok/s" if r.generation_tps else "?") for r in runs]),
555
571
  ("Prompt reading", [cell(r, f"{r.prompt_tps:,.0f} tok/s" if r.prompt_tps else "?") for r in runs]),
556
572
  ("Tool-call errors", [cell(r, str(r.tool_errors)) for r in runs]),
557
- (
558
- "Memory",
559
- [cell(r, f"{r.memory_gb} GB, {r.gpu_percent}% on GPU" if r.memory_gb else "?") for r in runs],
560
- ),
573
+ ("Memory", [cell(r, memory(r)) for r in runs]),
561
574
  ("Context", [cell(r, format_tokens(r.context)) for r in runs]),
562
575
  ]
563
576
  if any(r.session for r in runs):
lcode/checks.py CHANGED
@@ -15,6 +15,7 @@ from __future__ import annotations
15
15
 
16
16
  import json
17
17
  import re
18
+ import shlex
18
19
  import shutil
19
20
  from collections.abc import Iterable
20
21
  from dataclasses import dataclass
@@ -208,8 +209,118 @@ def exit_code(result: str) -> int | None:
208
209
 
209
210
 
210
211
  def covers(check: Check, command: str) -> bool:
211
- """Whether a command the model ran is this check (`cd x && uv run pytest -q 2>&1 | tail` counts)."""
212
- return " ".join(check.command.split()) in " ".join(command.split())
212
+ """Whether a command the model ran is this check, all of it (`cd x && uv run pytest -q 2>&1 | tail` counts).
213
+
214
+ A run that adds a path or a test name after the check's words, or an option that picks tests (`-k`, `--ignore`,
215
+ `npm test -- --grep`), ran only part of it, and says nothing about the rest. Other options (`-x`, `--tb=short`)
216
+ leave it whole.
217
+ """
218
+ return whole_run(check, command) is not None
219
+
220
+
221
+ def whole_run(check: Check, command: str) -> re.Match[str] | None:
222
+ """The first place in a command that runs this check, all of it."""
223
+ if not check.command.split():
224
+ return None # `checks = " "`: there's no command to find
225
+ found = re.finditer(r"\s+".join(map(re.escape, check.command.split())), command)
226
+ return next((run for run in found if not narrows(check, command[run.end() :])), None)
227
+
228
+
229
+ # Per test runner: options that pick which tests run, or run none, so a run with one isn't the whole check; and
230
+ # options whose value can be the next word, which then isn't a path or a test name (`--tb short`).
231
+ PICKS_TESTS = {
232
+ "pytest": "-k -m --ignore --ignore-glob --deselect --lf --last-failed --sw --stepwise --sw-skip --stepwise-skip "
233
+ "--co --collect-only --setup-only --setup-plan --fixtures --fixtures-per-test --markers --cache-show",
234
+ "unittest": "-k -s -p --start-directory --pattern",
235
+ "js": "-t -g -f -o -w --workspace --filter --grep --fgrep --spec --ignore --exclude --testNamePattern "
236
+ "--testPathPattern --testPathPatterns --testPathIgnorePatterns --onlyChanged --onlyFailures --changedSince "
237
+ "--findRelatedTests --listTests --selectProjects --shard --project --changed --related --dir --dry-run "
238
+ "--test-name-pattern --test-skip-pattern --test-only",
239
+ "cargo": "-p --package --exclude --lib --bin --bins --test --tests --example --examples --bench --benches "
240
+ "--all-targets --doc --no-run --exact --skip --ignored --list",
241
+ "go": "-run -skip -short -list -c -n",
242
+ "make": "-n --dry-run --just-print --recon -q --question -t --touch -C --directory -f --file",
243
+ }
244
+ TAKES_VALUE = {
245
+ "pytest": "-p -n -c -o -W -r --tb --maxfail --durations --color --capture --rootdir --basetemp --confcutdir "
246
+ "--import-mode --timeout --log-level --log-cli-level --cov --cov-report --junitxml --dist",
247
+ "unittest": "-t --top-level-directory --durations",
248
+ "js": "--reporter --timeout --testTimeout --maxWorkers --config --env --pool",
249
+ "cargo": "-j --jobs -F --features --target --profile --manifest-path --color --test-threads --format",
250
+ "go": "-count -timeout -p -parallel -cpu -tags -coverprofile -covermode -o",
251
+ "make": "-j --jobs",
252
+ }
253
+ HELP = ("-h", "--help", "--version") # any runner's: help instead of tests
254
+ CHECK_RUNNERS = (
255
+ ("pytest", re.compile(r"\b(?:pytest|py\.test)\b")),
256
+ ("unittest", re.compile(r"\bunittest\b")),
257
+ ("js", re.compile(r"\b(?:npm|pnpm|yarn|bun)\b")),
258
+ ("cargo", re.compile(r"\bcargo\b")),
259
+ ("go", re.compile(r"\bgo\b")),
260
+ ("make", re.compile(r"\bmake\b")),
261
+ )
262
+ OPERATOR = frozenset("();|&<>\n") # characters of the shell's operators and redirections
263
+
264
+
265
+ def narrows(check: Check, rest: str) -> bool:
266
+ """Whether what follows the check's words in a command makes it run only part of the check: a path or a test
267
+ name before the next shell operator (redirections don't count), or an option that picks tests."""
268
+ last = check.command.split()[-1]
269
+ goes_on = re.match(r"[^\s\\();|&<>]", rest) is not None # the check's last word goes on
270
+ if goes_on and not last.startswith("-"):
271
+ return True # into another word: `-s tests/unit`, `npm test:unit`, `make test-fast`
272
+ words = run_words(rest)
273
+ if words is None:
274
+ return True # in quotes: `bash -c "…"` can't be told from `echo "…"`
275
+ if goes_on and words:
276
+ words[0] = last + words[0] # options run together: `-q` and `x` make `-qx`
277
+ runner = runner_of(check)
278
+ picks, takes_value = PICKS_TESTS.get(runner, "").split(), TAKES_VALUE.get(runner, "").split()
279
+ if runner == "unittest" and last == "unittest" and words[:1] == ["discover"]:
280
+ words = words[1:] # plain `python -m unittest` discovers too
281
+ value = False # this word is the value of the option before it
282
+ for word in words:
283
+ if value:
284
+ value = False
285
+ continue
286
+ if not word.startswith("-") or word == "-":
287
+ return True # a path or a test name
288
+ name = word.split("=", 1)[0]
289
+ if name in picks or name in HELP:
290
+ return True
291
+ value = name in takes_value and "=" not in word
292
+ return False
293
+
294
+
295
+ def runner_of(check: Check) -> str:
296
+ """The test runner that gets the words after the check's: its last command's (a key of PICKS_TESTS, or "")."""
297
+ command = re.split(r"&&|\|\||;", check.command)[-1]
298
+ return next((name for name, uses in CHECK_RUNNERS if uses.search(command)), "")
299
+
300
+
301
+ def run_words(rest: str) -> list[str] | None:
302
+ """The words the shell gives a program from the start of `rest` to its next operator, without redirections
303
+ (`> log.txt 2>&1`). None when quotes don't close."""
304
+ rest = re.sub(r"(?<!\S)\d+(?=[<>])", " ", rest.replace("\\\n", " ")) # the 2 of `2>&1` is no word
305
+ lexer = shlex.shlex(rest, posix=True, punctuation_chars="".join(OPERATOR))
306
+ lexer.whitespace, lexer.whitespace_split, lexer.commenters = " \t\r", True, ""
307
+ words: list[str] = []
308
+ target = False # this word is where a redirection goes
309
+ try:
310
+ for word in lexer:
311
+ if target:
312
+ target = False
313
+ elif word and set(word) <= OPERATOR:
314
+ if set(word) & set("()") or not set(word) & set("<>"):
315
+ break # `|`, `&&`, `;`, a new line, a subshell…: what follows is another command
316
+ target = True # a redirection
317
+ elif word.startswith("#"):
318
+ break # a comment
319
+ else:
320
+ words.append(word)
321
+ except ValueError:
322
+ return None
323
+ return words
213
324
 
214
325
 
215
326
  KEEPS_EXIT_CODE = re.compile(r"\d*>&\d+|&>>?|&&") # redirections and `&&`, after the check
@@ -223,7 +334,7 @@ def run_passed(check: Check, command: str, result: str) -> bool:
223
334
  the exit code isn't the check's, only the output can say: a test runner's summary, with nothing failing."""
224
335
  if exit_code(result) != 0:
225
336
  return False
226
- found = re.search(r"\s+".join(map(re.escape, check.command.split())), command)
337
+ found = whole_run(check, command)
227
338
  after = KEEPS_EXIT_CODE.sub(" ", command[found.end() :]).rstrip() if found else ""
228
339
  if not HIDES_EXIT_CODE.search(after):
229
340
  return True
lcode/cli.py CHANGED
@@ -560,7 +560,7 @@ def cmd_chat(args) -> None:
560
560
  print(json.dumps(result.to_json(), ensure_ascii=False, indent=None if output == "stream-json" else 2))
561
561
  exit_code = result.exit_code
562
562
  else:
563
- repl(agent, prompt=args.prompt, hardware=hw, cont=args.cont, resume=args.resume)
563
+ exit_code = repl(agent, prompt=args.prompt, hardware=hw, cont=args.cont, resume=args.resume)
564
564
  finally:
565
565
  api.close_agent(agent)
566
566
  if worktree is not None:
lcode/config.py CHANGED
@@ -85,6 +85,7 @@ SETTINGS: dict[str, tuple[object, type, str]] = {
85
85
  "escalate_url": (None, str, "the stronger model's server, if not its provider's (another Ollama, any OpenAI API)"),
86
86
  "escalate_price": (None, str, "its price in dollars per million tokens in/out, e.g. 3/15, for the cost shown"),
87
87
  "repeat_limit": (3, int, "identical tool calls with identical results before lcode steps in (0: never)"),
88
+ "think_budget": (7000, int, "tokens a reply may think before it acts; past that, lcode asks it to act (0: never)"),
88
89
  "secret_check": (True, bool, "before git commit and git push, look for passwords, keys and tokens they'd add"),
89
90
  "compact_at": (65536, int, "summarize at this many tokens even when the window is larger (0: only at 85%)"),
90
91
  "max_parallel_agents": (1, int, "subagents that may run at the same time (more needs OLLAMA_NUM_PARALLEL)"),
lcode/docs/automation.md CHANGED
@@ -25,6 +25,8 @@ lcode -p "Explain the retry logic" --output stream-json --max-steps 20
25
25
  lcode's usual output goes to stderr, so stdout holds only the JSON. The exit code says how it
26
26
  went: `0` success, `1` an error, `3` stopped at `--max-steps`, `4` stopped because the model
27
27
  [kept repeating itself](how-it-works.md#when-the-model-repeats-itself), `130` interrupted.
28
+ Without `--output`, `lcode -p` exits with the same codes, so in `lcode -p "…" && next-step`
29
+ the next step runs only after a request that succeeded.
28
30
 
29
31
  ### The result
30
32
 
lcode/docs/bench.md CHANGED
@@ -25,7 +25,7 @@ its memory use, so those columns stay empty.
25
25
  lcode bench · NVIDIA GeForce RTX 4080 Laptop GPU (12 GB VRAM), 31 GB RAM · Ollama 0.40.13
26
26
 
27
27
  lcode-qwen3.6-35b · 32K context · reasoning on · 8 tasks · 3 attempts each
28
- Loaded in 18s · 10.4 GB, 98% on the GPU · reads prompts at 905 tok/s
28
+ Loaded in 18s · ~23 GB, 42% on the GPU and the rest in system RAM · reads prompts at 905 tok/s
29
29
  Attempt 1 of 3
30
30
  ✓ fix-bug Fix a bug so the tests pass 22s the tests pass
31
31
  ✓ find-code Answer with file:line 8s next_wait at backoff.py:13
@@ -182,7 +182,7 @@ quick tasks once, as `lcode bench` did before 0.57.
182
182
  | **Generation** | Output tokens per second, across all the model's responses |
183
183
  | **Prompt reading** | Prompt tokens per second: how fast the model reads files and tool output. Measured per model with fresh 4,000-token prompts (the faster of two readings, since the first one after loading includes warm-up), because during the tasks Ollama serves most of each request from its prompt cache |
184
184
  | **Tool-call errors** | Tool calls that failed (wrong arguments, editing without reading first, unmatched edits) or that the model wrote as invalid JSON |
185
- | **Memory** | The model's memory use and how much of it is on the GPU, from Ollama |
185
+ | **Memory** | The model's memory and how much of it is on the GPU, counted as in the [line after a load](usage.md#whats-happening-under-the-hood). Ollama leaves out what stays mapped from the model's file in system RAM, so for a model in `lcode models` that's partly off the GPU, it's lcode's estimate of the whole model (`~23 GB`). Otherwise it's what Ollama says |
186
186
 
187
187
  Results depend on the context window, so `lcode bench` uses **32K** by default on every machine,
188
188
  which makes results comparable. When comparing models, each one is unloaded before the next starts
@@ -217,7 +217,7 @@ RTX 4080 Laptop GPU (12 GB) with 31 GB of RAM, Ollama 0.40.13, 32K context, reas
217
217
  | Generation | 64.0 tok/s |
218
218
  | Prompt reading | 851 tok/s |
219
219
  | Tool-call errors | 4 |
220
- | Memory | 10.5 GB, 98% on GPU |
220
+ | Memory | ~23 GB, 42% on GPU |
221
221
 
222
222
  What it missed:
223
223
  - one `spec-fix` attempt fixed the reported case but not all the docstring's rules;
@@ -226,6 +226,9 @@ What it missed:
226
226
  - every `runtime-bug` attempt settled for a band-aid: the window still grew, or still couldn't be
227
227
  made smaller.
228
228
 
229
+ The table shows memory as lcode counts it now. lcode 0.58.0 printed Ollama's count,
230
+ `10.5 GB, 98% on GPU`, which leaves out the ~12 GB of experts in system RAM.
231
+
229
232
  Two `wide-feature` attempts were first counted as failed. Their `budget list` printed `No budgets
230
233
  set.` without budgets, and one listed the budgeted categories first. The task asks for neither
231
234
  behavior, so the check now accepts both (0.59.0), and the table counts them as passed.
@@ -302,6 +305,8 @@ existing fields keep their meaning until `schema` changes.
302
305
  "prompt_tps": 904.6,
303
306
  "memory_gb": 10.4,
304
307
  "gpu_percent": 98,
308
+ "estimated_memory_gib": 22.7,
309
+ "estimated_gpu_percent": 42,
305
310
  "attempts": 3,
306
311
  "passed": 24,
307
312
  "total": 24,
@@ -328,7 +333,8 @@ existing fields keep their meaning until `schema` changes.
328
333
  | `ollama`, `server` | The Ollama version, or `null` with [another model server](servers.md); `server` names the server either way |
329
334
  | `runs[].model` | The name you gave (catalog key or Ollama tag); `ollama_model` is the model that ran |
330
335
  | `runs[].context`, `num_batch`, `think` | The settings used. lcode lowers the batch size or context if the GPU runs out of memory, and reports what it ended up using |
331
- | `runs[].memory_gb`, `gpu_percent` | From Ollama's `/api/ps`; `null` if unavailable |
336
+ | `runs[].memory_gb`, `gpu_percent` | The model's memory in GB and the share of it on the GPU, as Ollama's `/api/ps` counts them; `null` if unavailable. Ollama 0.40 leaves out what stays mapped from the model's file in system RAM: `qwen3.6-35b` at 32K on a 12 GB GPU shows as 10.4 GB, 98% of it on the GPU |
337
+ | `runs[].estimated_memory_gib`, `estimated_gpu_percent` | When Ollama's count leaves out part of a model in `lcode models`: lcode's estimate of the whole model in GiB, and the share of it on the GPU, as the summary shows them (`~23 GB, 42% on GPU`). `null` when Ollama counts the whole model (all of it on the GPU, or a model outside the catalog) and in older results |
332
338
  | `runs[].generation_tps` | Output tokens per second across the tasks; `null` if Ollama reported no timings |
333
339
  | `runs[].prompt_tps` | Prompt tokens per second for a fresh 4,000-token prompt (the faster of two readings); `null` if it couldn't be measured |
334
340
  | `runs[].usage` | Totals over the tasks as Ollama reports them. `prompt_tokens` includes tokens served from the prompt cache |
@@ -59,6 +59,7 @@ lcode config path # print the file location
59
59
  | `escalate_url` | — | Its server, when it isn't the provider's usual one: another Ollama, or any OpenAI-compatible API |
60
60
  | `escalate_price` | — | Its price in dollars per million tokens, input/output (e.g. `3/15`), for the cost shown before each use |
61
61
  | `repeat_limit` | `3` | Identical tool calls with identical results before lcode [steps in](how-it-works.md#when-the-model-repeats-itself); `0` turns it off, along with the checks for [unreachable sites](how-it-works.md#when-a-site-cant-be-reached) and [thinking in circles](how-it-works.md#when-a-reply-goes-nowhere) |
62
+ | `think_budget` | `7000` | Tokens a reply may [think](how-it-works.md#when-a-reply-goes-nowhere) before it writes anything or calls a tool. Past that, lcode stops the reply and asks for the next step with thinking off; `0` means no limit |
62
63
  | `secret_check` | `true` | Before `git commit` and `git push`, look for passwords, keys and tokens they'd add ([details](usage.md#secrets-in-commits)) |
63
64
  | `checkpoints` | `true` | Save a checkpoint before the model changes files, so [`/undo`](usage.md#undo-and-checkpoints) can restore them |
64
65
  | `trace` | `true` | Record each request's model calls, tool calls, times and tokens on this machine, for [`lcode trace`](traces.md) (kept 30 days) |
@@ -94,6 +94,17 @@ four in one request, lcode stops it (status `loop`), offering the
94
94
  [stronger model](usage.md#a-stronger-model-when-stuck) first when one is set. An answer the context
95
95
  cut off midway is kept, with a warning to `/compact` or use a larger `/context`.
96
96
 
97
+ A reply can also think for a long time without repeating itself: weighing one option after another,
98
+ never trying any. When a reply has thought for 7,000 tokens (`think_budget`) and hasn't yet written
99
+ anything or called a tool, lcode stops it the same way. The model gets back the last part of its
100
+ thinking, so it can act on where its reasoning got to, and the next reply runs with thinking off.
101
+ Once the model acts, thinking is back on. On the dev slice of the
102
+ [public benchmarks](public-benchmarks.md), about 1 reply in 100 thought that long. They came from 42
103
+ of the 110 attempts that failed and 2 of the 102 that passed. Such a reply doesn't count towards the
104
+ four per request, so a long task with several hard steps carries on, but a reply that goes nowhere
105
+ right after one stops the request as before. Change the budget with
106
+ `lcode config set think_budget 12000`, or turn it off with `0`.
107
+
97
108
  ## Subagents
98
109
 
99
110
  The `agent` tool starts a [subagent](agents.md): another agent loop with its own conversation, the
@@ -181,6 +181,9 @@ lcode update --check # only show which versions are out
181
181
  network and restart policy. The old one is kept until the new one answers with the new
182
182
  version, and is put back if it doesn't.
183
183
  - Your models stay: they're in the container's volume.
184
+ - A reply that an lcode session is getting while the container is replaced stops halfway. That
185
+ session [says so](troubleshooting.md#ollama-stopped-in-the-middle-of-a-reply) and carries on:
186
+ send the request again after the update.
184
187
  - **Ollama installed without Docker** gets the command that updates it: on Linux,
185
188
  `curl -fsSL https://ollama.com/install.sh | sh`; on macOS, `brew upgrade ollama` or the app
186
189
  itself.
lcode/docs/models.md CHANGED
@@ -258,7 +258,8 @@ RAM needed ≈ memory − GPU memory + ~10 GB for Ollama's server and prompt cac
258
258
 
259
259
  - **The part of the model that doesn't fit on the GPU.** A Mixture-of-Experts model's experts stay
260
260
  mapped from the model's file, so they have to stay in Linux's page cache. `ollama ps` leaves them out:
261
- it shows `qwen3.6-35b` at 32K as 10.5 GB, with ~12 GB more in RAM.
261
+ it shows `qwen3.6-35b` at 32K as 10.5 GB, with ~12 GB more in RAM. lcode counts them: after a load,
262
+ in `lcode doctor` and in `lcode bench`, it says `~23 GB, 42% on the GPU and the rest in system RAM`.
262
263
  - **Ollama's prompt cache**, which grows to 8 GB in a long session, next to 1–2 GB of the server's own.
263
264
 
264
265
  On a 12 GB GPU, `qwen3.6-35b` needs ~21 GB of RAM at 32K, ~23 GB at 128K and ~26 GB at 256K. On Linux,
lcode/docs/modes.md CHANGED
@@ -99,7 +99,8 @@ alone shows them.
99
99
  closes before an image arrives, the next request in image mode saves it.
100
100
  - **From scripts:** `lcode --mode image -p "a red fox in the snow --n 2"` makes the images and
101
101
  exits; with `--output json` it prints a result with the file paths, the model, the seeds, the size
102
- and the time.
102
+ and the time. It exits with `1` when no image came (no ComfyUI, a job that failed, Ctrl+C), and so
103
+ does `lcode -c -p "…"` when it carries on an image or video session.
103
104
  - **No Ollama needed:** `lcode --mode image` starts even when Ollama isn't running or the coding
104
105
  model isn't installed; `/mode code` then says what's missing.
105
106
 
lcode/docs/quickstart.md CHANGED
@@ -12,7 +12,7 @@ lcode
12
12
 
13
13
  ```text
14
14
  ╭──────────────────────────────────────────────╮
15
- │ lcode v0.62.0 — local coding agent │
15
+ │ lcode v0.63.1 — local coding agent │
16
16
  │ │
17
17
  │ model lcode-qwen3.6-35b │
18
18
  │ context 256K tokens │
@@ -23,6 +23,16 @@ Ollama isn't running (or isn't installed).
23
23
  as well (`docker volume prune -a`), so were the models: download them again with `lcode setup`.
24
24
  - Remote server: `lcode config set ollama_host http://host:11434`.
25
25
 
26
+ ### `Ollama stopped in the middle of a reply`
27
+
28
+ The connection to Ollama broke while the model was answering: Ollama stopped or restarted (a crash, or an
29
+ update that replaces its container, as `lcode update` does), or the network to a remote Ollama dropped.
30
+ The session carries on and keeps the conversation, without the reply that was cut off. Once Ollama is
31
+ running, send the request again. If it doesn't answer, `lcode doctor` checks it and says how to start it.
32
+
33
+ With `lcode -p --output json`, the result has `status` `error` with this message, and lcode exits with
34
+ `1`. LM Studio, llama-server, vLLM and MLX servers get the same message, with their own name.
35
+
26
36
  ### Docker: `all predefined address pools have been fully subnetted`
27
37
 
28
38
  Docker Compose can't create a network for the Ollama container. A VPN that routes all traffic (for example
@@ -84,8 +94,10 @@ need `lcode mcp login <name>`. More in [MCP servers: Troubleshooting](mcp.md#tro
84
94
  starts, and `keep_alive` keeps it loaded between requests.
85
95
  - Reading many large files takes a while the first time (~280 tokens/s on a 12 GB GPU, ~500 with
86
96
  `lcode config set num_batch 1024` if it fits); follow-up turns reuse the cache.
87
- - `ollama ps` shows how much of the model is on the GPU. Dense models are much slower when split;
88
- prefer the MoE models in `lcode models` on smaller GPUs.
97
+ - `lcode doctor` shows how much of the loaded model is on the GPU, for example
98
+ `Loaded ~23 GB, 42% on the GPU and the rest in system RAM · 32K context`. `ollama ps` leaves out the
99
+ part of a Mixture-of-Experts model that's in system RAM, so it can say 98%. Dense models are much
100
+ slower when split; prefer the MoE models in `lcode models` on smaller GPUs.
89
101
  - `--no-think` skips reasoning for simple requests.
90
102
 
91
103
  ### It starts fast, then gets about three times slower
lcode/docs/usage.md CHANGED
@@ -234,7 +234,10 @@ runs the project's checks itself before the answer is final:
234
234
  whether its change works. A suite that's simply this slow needs a faster command (below).
235
235
  - **When the model already ran them** after its last change and they passed, they aren't run again.
236
236
  A run piped into another program (`pytest -q | tail`) exits with that program's code, so it counts
237
- only if its output shows a test summary with nothing failing.
237
+ only if its output shows a test summary with nothing failing. A run of part of them doesn't count:
238
+ one with a path or a test name after the check's command (`pytest -q tests/test_calc.py`), or an
239
+ option that picks tests (`-k`, `--ignore`, `npm test -- --grep`). Options alone, like `-x` or
240
+ `--tb=short`, still count.
238
241
  - **Where they run:** in the project's root, wherever the model's shell went last. A command from your
239
242
  own `checks` setting runs in the folder you started lcode in.
240
243
  - **Permission:** they run like any other command, so in `ask` mode the first run asks (++a++ allows
@@ -409,7 +412,7 @@ stays loaded:
409
412
 
410
413
  | When | What it says |
411
414
  |---|---|
412
- | The model was loaded | `◆ Loaded qwen3.6-35b in 15s: 22.3 GB, 45% on the GPU and the rest in system RAM.`, and a warning when less of it is on the GPU than usual, because another program or model is using GPU memory |
415
+ | The model was loaded | `◆ Loaded qwen3.6-35b in 15s: ~23 GB, 42% on the GPU and the rest in system RAM.`, and a warning when less of it is on the GPU than usual, because another program or model is using GPU memory |
413
416
  | A dense model doesn't fit on the GPU (at startup and on `/model`) | `⚠ qwen3.8-27b is a dense model: all 27B parameters work on every token. It's capable, but slow here. Only about 61% of it fits in the 12 GB of GPU memory…`, with what to do instead |
414
417
  | The model that looks at images needs the memory | `Loading the vision model … to look at bug.png; qwen3.6-35b makes room and reloads afterwards`, then `◆ qwen3.6-35b was unloaded to make room…`, and the next step says `Reloading qwen3.6-35b into memory (it made room for the vision model …)` |
415
418
  | A tool needs the GPU to itself (an MCP server with `free_gpu`) | `◆ Unloaded qwen3.6-35b so the server can use the GPU; it reloads afterwards.` |
@@ -421,6 +424,12 @@ While the model loads in the background at startup, the status bar says
421
424
  part of them in system RAM. Dense ones slow down a lot, to a few tokens a second, which is why they
422
425
  get the warning.
423
426
 
427
+ The `~` marks lcode's estimate of the model's memory, the same one `lcode setup` and `lcode doctor`
428
+ show. Ollama leaves out what stays mapped from the model's file in system RAM: `ollama ps` shows
429
+ qwen3.6-35b at 32K on a 12 GB GPU as 10.5 GB, 98% of it on the GPU, while ~12 GB of its experts are
430
+ in RAM. So when part of a model in `lcode models` is off the GPU, lcode counts all of it. For other
431
+ models it repeats what Ollama says. `lcode doctor` shows the same line for the model in memory.
432
+
424
433
  ## Steer while it works
425
434
 
426
435
  A request can take minutes with a local model. You don't have to stop it to change course: type
@@ -822,4 +831,7 @@ lcode -p "Review the uncommitted changes (git diff) for bugs"
822
831
  lcode -p "Run the tests and fix any failures" --auto-edit
823
832
  ```
824
833
 
834
+ The exit code says how the request went: `0` when it succeeded, `1` for an error, and the other
835
+ codes in [Automation](automation.md#structured-output).
836
+
825
837
  Combine with `--yolo` only in disposable environments.
lcode/doctor.py CHANGED
@@ -110,15 +110,9 @@ def cmd_doctor(args) -> None:
110
110
  f"here (delete {limits.path()} to try again)",
111
111
  None,
112
112
  )
113
- loaded = [m for m in ollama.running() if m.get("name") == model or m.get("model") == model]
114
- if loaded:
115
- m = loaded[0]
116
- line(
117
- "Loaded",
118
- f"{m.get('size_vram', 0) / 1e9:.1f} GB on GPU of {m.get('size', 0) / 1e9:.1f} GB, "
119
- f"context {m.get('context_length', '?')}",
120
- True,
121
- )
113
+ if where := residency.placement(ollama, model): # Ollama lists lcode-qwen3.6-35b as lcode-qwen3.6-35b:latest
114
+ where = residency.with_estimate(where, model, ctx)
115
+ line("Loaded", where.describe() + (f" · {format_tokens(where.context)} context" if where.context else ""))
122
116
  except cli.NotInstalled as e:
123
117
  line("Model", str(e), False)
124
118
  ok = False
lcode/ollama.py CHANGED
@@ -33,6 +33,37 @@ def version_tuple(version: str) -> tuple[int, ...]:
33
33
  return tuple(int(x) for x in re.findall(r"\d+", version)[:3])
34
34
 
35
35
 
36
+ def stopped_halfway(server: str, host: str, error: requests.RequestException) -> str:
37
+ """What to say when the connection breaks in the middle of a reply: the server stopped or restarted (an update
38
+ that recreates its container, a crash), or the network dropped."""
39
+ why = error.args[0] if error.args else "" # requests wraps urllib3's error, whose first argument is its message
40
+ if isinstance(why, BaseException):
41
+ why = why.args[0] if why.args else type(why).__name__
42
+ return (
43
+ f"{server} stopped in the middle of a reply: the connection to {redact(host)} broke "
44
+ f"({why or type(error).__name__}). Once it's running, send the request again; `lcode doctor` checks it and "
45
+ "says how to start it."
46
+ )
47
+
48
+
49
+ def reply_lines(
50
+ response: requests.Response, server: str, host: str, error: type[OllamaError] = OllamaError
51
+ ) -> Iterator[bytes]:
52
+ """The lines of a streamed reply. A connection that breaks halfway raises `error`, which the agent reports and
53
+ the session survives, instead of a requests error that nothing catches.
54
+
55
+ A reply lcode stops from another thread (an editor's cancel, a stopped subagent: lcode.subagents.abort) breaks
56
+ the same way, whichever way the read fails. That's a stop, as anywhere else: KeyboardInterrupt."""
57
+ try:
58
+ yield from response.iter_lines()
59
+ except Exception as e:
60
+ if getattr(response, "aborted", False):
61
+ raise KeyboardInterrupt from e
62
+ if not isinstance(e, requests.RequestException):
63
+ raise
64
+ raise error(stopped_halfway(server, host, e)) from e
65
+
66
+
36
67
  class Ollama:
37
68
  kind = "ollama"
38
69
  name = "Ollama"
@@ -179,7 +210,7 @@ class Ollama:
179
210
  raise OllamaError(unauthorized(payload["model"], self.host))
180
211
  if r.status_code != 200:
181
212
  raise OllamaError(f"Ollama error {r.status_code}: {r.text[:500]}")
182
- for line in r.iter_lines():
213
+ for line in reply_lines(r, self.name, self.host):
183
214
  if line:
184
215
  chunk = json.loads(line)
185
216
  if "error" in chunk:
lcode/repl.py CHANGED
@@ -26,6 +26,7 @@ from rich.text import Text
26
26
 
27
27
  from lcode import (
28
28
  __version__,
29
+ api,
29
30
  assistant,
30
31
  backends,
31
32
  clipboard,
@@ -504,20 +505,25 @@ def git_command(agent: Agent, cmd: str, arg: str) -> None:
504
505
  agent.no_changes = ""
505
506
 
506
507
 
507
- def run_safely(agent: Agent, text: str) -> None:
508
+ def run_safely(agent: Agent, text: str) -> str:
509
+ """Run a request. An interrupt or a model error ends the request, not the session. Returns how it ended, as
510
+ `lcode -p --output json` says it: success, error, max_steps, loop, blocked or interrupted."""
508
511
  started = time.monotonic()
509
512
  reader = start_steering(agent) if agent.interactive else None
510
513
  try:
511
514
  agent.run_turn(text)
515
+ status = api.request_status(agent)
512
516
  except KeyboardInterrupt:
513
- pass
517
+ status = "interrupted"
514
518
  except OllamaError as e:
519
+ status = "error"
515
520
  agent.console.print(f"[red]{e}[/]")
516
521
  finally:
517
522
  if reader is not None:
518
523
  stop_steering(agent, reader)
519
524
  agent.save()
520
525
  agent.finished(text, time.monotonic() - started)
526
+ return status
521
527
 
522
528
 
523
529
  def start_steering(agent: Agent) -> KeyReader | None:
@@ -708,7 +714,10 @@ def handle_command(agent: Agent, line: str, hardware: Hardware) -> bool:
708
714
  return True
709
715
 
710
716
 
711
- def repl(agent: Agent, prompt: str | None, hardware: Hardware, cont: bool = False, resume: str | None = None) -> None:
717
+ def repl(agent: Agent, prompt: str | None, hardware: Hardware, cont: bool = False, resume: str | None = None) -> int:
718
+ """The interactive session, or with a prompt (`lcode -p`) that one request. Returns lcode's exit code, so a script
719
+ can tell a failed request from a done one: for a coding request, the one `--output json` gives (api.EXIT_CODES);
720
+ for an image or video request, 1 when it failed or was cancelled, as `lcode --mode image -p` exits; otherwise 0."""
712
721
  if cont:
713
722
  note = agent.load_latest()
714
723
  if note is None:
@@ -723,12 +732,10 @@ def repl(agent: Agent, prompt: str | None, hardware: Hardware, cont: bool = Fals
723
732
  if info:
724
733
  resume_session(agent, info)
725
734
  session_start(agent)
726
- if prompt and agent.settings.mode in ("image", "video"):
727
- respond(agent, prompt)
728
- return
735
+ if prompt and agent.settings.mode in ("image", "video"): # -c or --resume into an image or video session
736
+ return 0 if respond(agent, prompt) else 1
729
737
  if prompt:
730
- run_safely(agent, prompt)
731
- return
738
+ return api.EXIT_CODES.get(run_safely(agent, prompt), 1)
732
739
  banner(agent)
733
740
  if agent.settings.mode == "code" and is_cloud(agent.settings.model):
734
741
  agent.say(cloud_notice(agent.settings.model))
@@ -765,19 +772,20 @@ def repl(agent: Agent, prompt: str | None, hardware: Hardware, cont: bool = Fals
765
772
  respond(agent, line)
766
773
  memory_notes.reflect(agent)
767
774
  agent.console.print("[dim]Bye.[/]")
775
+ return 0
768
776
 
769
777
 
770
- def respond(agent: Agent, line: str) -> None:
778
+ def respond(agent: Agent, line: str) -> bool:
771
779
  """What a typed request does: the coding agent works on it, or image and video mode take it (a question about
772
- lcode is answered from its manual instead)."""
780
+ lcode is answered from its manual instead). Returns whether it went through: False when it failed or was
781
+ cancelled."""
773
782
  if agent.settings.mode in ("image", "video"): # no coding model involved
774
783
  if manual.is_question(line) and not media.RAW_FLAG.search(line):
775
784
  ask_manual(agent, line, typed=True)
776
- return
777
- make_image(agent, line)
778
- return
785
+ return True
786
+ return make_image(agent, line)
779
787
  agent.console.print(Rule(style="dim"))
780
- run_safely(agent, line)
788
+ return run_safely(agent, line) == "success"
781
789
 
782
790
 
783
791
  def manual_writer(agent: Agent):
lcode/repl_media.py CHANGED
@@ -297,9 +297,9 @@ def gallery(agent: Agent, everything: bool = False) -> None:
297
297
  )
298
298
 
299
299
 
300
- def make_image(agent: Agent, prompt: str = "", options=None, run=None) -> None:
300
+ def make_image(agent: Agent, prompt: str = "", options=None, run=None) -> bool:
301
301
  """Image mode: ComfyUI makes the images (a request, or `run(cancelled, ask)`); Esc or Ctrl+C cancels them
302
- there too."""
302
+ there too. Returns whether they came: False when the request failed or was cancelled."""
303
303
  steering = Steering()
304
304
  reader = KeyReader(steering)
305
305
  reading = agent.interactive and reader.start() # Esc sets steering.pause: here it cancels
@@ -309,6 +309,7 @@ def make_image(agent: Agent, prompt: str = "", options=None, run=None) -> None:
309
309
  return answer.strip().lower() in ("y", "yes")
310
310
 
311
311
  started = time.monotonic()
312
+ made = False
312
313
  try:
313
314
  asking = ask if agent.interactive else None
314
315
  if run is not None:
@@ -317,6 +318,7 @@ def make_image(agent: Agent, prompt: str = "", options=None, run=None) -> None:
317
318
  media.request(agent, prompt, cancelled=lambda: steering.pause, ask=asking)
318
319
  else:
319
320
  media.make(agent, prompt, options, cancelled=lambda: steering.pause, ask=asking)
321
+ made = True
320
322
  except media.MediaError as e:
321
323
  agent.console.print(f"[yellow]{escape(str(e))}[/]")
322
324
  except KeyboardInterrupt: # while ComfyUI was starting: nothing queued yet
@@ -332,3 +334,4 @@ def make_image(agent: Agent, prompt: str = "", options=None, run=None) -> None:
332
334
  agent.console.print(Text("✎ What you typed is in the prompt below.", style="cyan"))
333
335
  agent.save() # the gallery and options carry over when the session is resumed
334
336
  agent.finished(prompt or "image or video", time.monotonic() - started) # a long render: notify
337
+ return made
lcode/replay.py CHANGED
@@ -325,6 +325,7 @@ def replay_agent(start_event: dict, folder: Path, server: ReplayServer, console:
325
325
  **{k: v for k, v in recorded.items() if k in allowed},
326
326
  )
327
327
  settings.think = bool(start_event.get("think", True))
328
+ settings.think_budget = int(recorded.get("think_budget") or 0) # recorded before 0.63: no budget then
328
329
  settings.num_batch = options.get("num_batch")
329
330
  settings.max_parallel_agents = 1 # subagents one after another, in the order they were asked for
330
331
  settings.sandbox, settings.checkpoints, settings.notify = "off", False, False
lcode/residency.py CHANGED
@@ -12,17 +12,18 @@ from __future__ import annotations
12
12
 
13
13
  import threading
14
14
  import time
15
- from dataclasses import dataclass
15
+ from dataclasses import dataclass, replace
16
16
  from statistics import median
17
17
  from urllib.parse import urlsplit
18
18
 
19
19
  from lcode import catalog
20
20
  from lcode.cloud import is_cloud
21
21
  from lcode.config import format_tokens
22
- from lcode.hardware import Hardware
22
+ from lcode.hardware import GIB, Hardware
23
23
  from lcode.ollama import OllamaError
24
24
 
25
25
  GB = 1e9
26
+ ALL = 0.995 # this share of a model on the GPU counts as all of it, and 1 - ALL as none of it
26
27
  RELEASE_WAIT = 15.0 # seconds to wait for Ollama to give an unloaded model's GPU memory back
27
28
  SPLIT_WARNING = 0.95 # a dense model with less than this on the GPU runs much slower
28
29
  SHORTFALL = 0.25 # this much less on the GPU than expected: something else is using GPU memory
@@ -36,24 +37,30 @@ SESSION_COMMANDS = ("/ctx {}", "/model {}", "/models")
36
37
 
37
38
  @dataclass
38
39
  class Placement:
39
- """A loaded model, from Ollama's /api/ps."""
40
+ """A loaded model, from Ollama's /api/ps (see `with_estimate` for what that leaves out)."""
40
41
 
41
42
  name: str
42
- size: float # bytes in memory
43
+ size: float # bytes in memory, as Ollama counts them
43
44
  vram: float # bytes of it on the GPU
44
45
  context: int = 0 # the context window it was loaded with
46
+ estimate: float = 0.0 # bytes the model takes by the catalog's estimate, when Ollama's count leaves part out
47
+
48
+ @property
49
+ def total(self) -> float:
50
+ return max(self.size, self.estimate)
45
51
 
46
52
  @property
47
53
  def gpu_share(self) -> float:
48
- return self.vram / self.size if self.size else 0.0
54
+ return self.vram / self.total if self.total else 0.0
49
55
 
50
56
  def describe(self) -> str:
51
- """'22.3 GB, 44% on the GPU and the rest in system RAM'"""
52
- size = f"{self.size / GB:.1f} GB"
57
+ """'6.6 GB, all on the GPU', or with the catalog's estimate: '~23 GB, 42% on the GPU and the rest in system
58
+ RAM'. The estimate is shown as `lcode setup` and `lcode doctor` show it."""
59
+ size = f"~{self.estimate / GIB:.0f} GB" if self.estimate > self.size else f"{self.size / GB:.1f} GB"
53
60
  share = self.gpu_share
54
- if share >= 0.995:
61
+ if share >= ALL:
55
62
  return f"{size}, all on the GPU"
56
- if share <= 0.005:
63
+ if share <= 1 - ALL:
57
64
  return f"{size}, all in system RAM (on the CPU)"
58
65
  return f"{size}, {share:.0%} on the GPU and the rest in system RAM"
59
66
 
@@ -117,6 +124,20 @@ def placement(ollama, model: str) -> Placement | None:
117
124
  return found[0] if found else None
118
125
 
119
126
 
127
+ def with_estimate(where: Placement, model: str, context: int) -> Placement:
128
+ """`where`, counting the whole model when part of it is off the GPU: by the catalog's estimate (models outside
129
+ the catalog stay as Ollama counts them).
130
+
131
+ /api/ps counts the memory Ollama's runner allocates. The weights it keeps in system RAM aren't allocated: they
132
+ stay mapped from the model's file. So with Ollama 0.40, qwen3.6-35b at 32K on a 12 GB GPU shows as 10.5 GB, 98%
133
+ of it on the GPU, while ~12 GB of its experts are in RAM. A model all on the GPU is counted in full.
134
+ """
135
+ spec = catalog.find(model)
136
+ if spec is None or where.vram >= ALL * where.size:
137
+ return where
138
+ return replace(where, estimate=spec.memory_gib(where.context or context) * GIB)
139
+
140
+
120
141
  def is_moe(ollama, model: str) -> bool | None:
121
142
  """Whether the model is a Mixture-of-Experts (None: unknown)."""
122
143
  spec = catalog.find(model)
@@ -169,14 +190,17 @@ def load_report(
169
190
  ) -> str:
170
191
  """The line after a load: how long it took, how it fits, and a warning if it fits worse than it should."""
171
192
  took = f" in {seconds:.0f}s" if seconds >= 1 else ""
172
- line = f"{'Reloaded' if reload else 'Loaded'} {model}{took}" + (f": {where.describe()}." if where else ".")
193
+ line = f"{'Reloaded' if reload else 'Loaded'} {model}{took}"
173
194
  if where is None:
174
- return line
195
+ return f"{line}."
196
+ where = with_estimate(where, model, context)
197
+ line += f": {where.describe()}."
175
198
  expected = expected_share(model, context, hardware)
176
199
  if expected is not None and where.gpu_share < expected - SHORTFALL:
200
+ fits = "all of it fits" if expected >= ALL else f"up to {expected:.0%} fits"
177
201
  line += (
178
- f" Less of it is on the GPU than usual ({expected:.0%}): another program or model is using GPU "
179
- "memory, so it runs slower until that's closed."
202
+ f" Less of it is on the GPU than usual ({fits}): another program or model is using GPU memory, so it "
203
+ "runs slower until that's closed."
180
204
  )
181
205
  elif dense and where.gpu_share < SPLIT_WARNING:
182
206
  line += " It's a dense model split between GPU and CPU, so expect it to be slow."
lcode/subagents.py CHANGED
@@ -585,6 +585,7 @@ class Run:
585
585
  def abort(response) -> None:
586
586
  """Stop a streaming Ollama response from another thread (Ollama then cancels the request)."""
587
587
  with contextlib.suppress(Exception):
588
+ response.aborted = True # its stream breaks now: lcode.ollama.reply_lines takes that for the stop it is
588
589
  connection = getattr(response.raw, "_connection", None) or getattr(response.raw, "connection", None)
589
590
  sock = getattr(connection, "sock", None)
590
591
  if sock is not None:
lcode/traces.py CHANGED
@@ -57,8 +57,8 @@ SUMMARY_WIDTH = 70 # characters of a command, path or query in a one-line summa
57
57
  # The settings a request ran with that a replay of it uses too.
58
58
  REPLAYED = (
59
59
  "mode", "web", "memory", "subagents", "max_parallel_agents", "trust_project", "skills", "prune", "repo_map",
60
- "lsp", "embed_model", "checks", "review", "escalate_model", "repeat_limit", "compact_at", "secret_check",
61
- "sandbox", "vision_model",
60
+ "lsp", "embed_model", "checks", "review", "escalate_model", "repeat_limit", "think_budget", "compact_at",
61
+ "secret_check", "sandbox", "vision_model",
62
62
  ) # fmt: skip
63
63
  TERMINAL = ("COLUMNS", "LINES") # pytest and others fit their output to these: a replay's commands get the same
64
64
  ACTIONS = ("list", "show", "export", "replay", "path")
@@ -278,7 +278,7 @@ class Lane:
278
278
  if error:
279
279
  event["error"] = error[:4000]
280
280
  elif not finished:
281
- event["stopped"] = True # lcode closed the stream: it went round in circles, or was interrupted
281
+ event["stopped"] = True # lcode closed the stream: circles, thinking too long, or interrupted
282
282
  if not final and first is not None: # the server counts a reply only at its end: about what this took
283
283
  event["estimated_in"], event["estimated_out"] = estimate(payload, reply)
284
284
  self.recorder.add(estimated_in=event["estimated_in"], estimated_out=event["estimated_out"])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: lcode-cli
3
- Version: 0.62.0
3
+ Version: 0.63.1
4
4
  Summary: A local-first terminal coding agent powered by open-weight models on your own GPU or Mac, via Ollama.
5
5
  Project-URL: Homepage, https://nasser1941.github.io/lcode/
6
6
  Project-URL: Documentation, https://nasser1941.github.io/lcode/
@@ -1,42 +1,42 @@
1
1
  lcode/docs/agents.md,sha256=A1heI40IKf767li9ffAH1grLlo2RhfbmB7lHL2uhZ4g,6915
2
- lcode/docs/automation.md,sha256=wfpLlEjFuIsOgveKNIW8WU-Vu5HwJR-xMmOf58OENUA,9521
3
- lcode/docs/bench.md,sha256=GKbhecNRVI8PTLnsB0a7eU8B7wD1qo9Y9wGylONbagc,18960
2
+ lcode/docs/automation.md,sha256=VxkqfbIA_TLthH78F6Nosuenolpng12jEXbk9-vnWw0,9671
3
+ lcode/docs/bench.md,sha256=iCVRZXklLzy7Y1xl5HSHr2gPTJtgu9XCUeB7y1fWBxE,20092
4
4
  lcode/docs/commands.md,sha256=PpRcOoKZXw1OQyGxEbmipEPDYAid1fLDiaarHax7ynU,5973
5
- lcode/docs/configuration.md,sha256=9L5mZtN9HyDQ5cXugUpUX5AXxxR1qNrwLmNMUlxGKgc,11112
5
+ lcode/docs/configuration.md,sha256=_dSvlOt_UXwdiDMFu6Jl56amRfQA5y4UAWlDHANp1n0,11353
6
6
  lcode/docs/editors.md,sha256=9Ztqg_nyV5UTnMlJYrJrNvzY59X0d1HdWKYrs9-tZn4,3295
7
7
  lcode/docs/git.md,sha256=zX25G1CxCUNQCZ_gnXja_0UjeCQ8kj3SiZxEWzWpp3A,5394
8
8
  lcode/docs/hooks.md,sha256=3EvyYVlD0D8zB7c80yOgbs-fkx0niPM2NeiWXnX7AxQ,5214
9
- lcode/docs/how-it-works.md,sha256=RZimyQqXN-q--hM8T-uUHJGfCMheorw58YIlZRX6YwM,14518
9
+ lcode/docs/how-it-works.md,sha256=AzL29CBueTf5t6NF_xCer3QdXiWcGZ-y7-glm6zD4VU,15413
10
10
  lcode/docs/index.md,sha256=MbXP--ui-OwfNE4Q91oRh7TubdFNMH-RrliHkld6lYE,3815
11
- lcode/docs/installation.md,sha256=bzPxIxQfJgF1tN6HlLNZPSVSjNsEYhlNfD0Z1dOq3Js,7017
11
+ lcode/docs/installation.md,sha256=vaMYDEinR04A3neUUJx5bP2PlIyfhk6miarUrnq4rKg,7257
12
12
  lcode/docs/lsp.md,sha256=tou-eJFMPvAJt0_-NaCm-c4OtfgVhok4Ig8NJnj6Rhs,3405
13
13
  lcode/docs/mcp.md,sha256=Ol3ScuP4i2KsoN9xaSEbnm86Tvoc1qnUV7zkRprWwHo,15168
14
14
  lcode/docs/memory.md,sha256=XbsNnTwRdnUEYW7_2U1GHbtK0uOjTxR-s2EujgJbR0Y,6889
15
- lcode/docs/models.md,sha256=Un3iWRduCkjQ1abajv46roFaTuJYeuE8Rw2XtgWXbYU,18144
16
- lcode/docs/modes.md,sha256=vNQv5K-lk6egNQNlnOHk8YeIdoAsmyaWvSu-RbQeZnQ,34039
15
+ lcode/docs/models.md,sha256=OE_Lp_rLHiCSWPApHqKkv2GzRb81udGJqamGdx-Gy7A,18280
16
+ lcode/docs/modes.md,sha256=q5ut1jR1PWnyMmXNT0cq7adCqj-bWrZDD2Y2X-L5ty0,34197
17
17
  lcode/docs/public-benchmarks.md,sha256=vYv4-kUV0RN3G-FK_YCcr2_WkIgn41kgtA_DDqwKNkA,11052
18
- lcode/docs/quickstart.md,sha256=sI36KW-L0MbPs2X79gKzvGAAiwECO7kMmIFeawRZn6s,3403
18
+ lcode/docs/quickstart.md,sha256=RTvGNmy94AZNjmFvyr3gILNXrc4_ClfooGSYF--NHs0,3403
19
19
  lcode/docs/sandbox.md,sha256=-_jc2I0LXKQIYCz_JOuHGaP2ehVuEqEepKqMATlFpZY,4064
20
20
  lcode/docs/search.md,sha256=1Sqkfc9NRftpcfBFG9b_D8Ns-octH399AaaSNBPHq28,4251
21
21
  lcode/docs/servers.md,sha256=0ddumHseQXx0CP0nqzgwV-493s81kdEBa6qtUYe9t6k,5718
22
22
  lcode/docs/traces.md,sha256=_rP0XIgyeiZPld4VjP-ISlyf6ZPoKQBTQPLVbyp5fUE,10201
23
- lcode/docs/troubleshooting.md,sha256=ISHpvFtWNt3H1sANDOqicP12L4umpqNzkCw_o0X-89Y,8184
24
- lcode/docs/usage.md,sha256=BMQ0yXYXaH0-ZvFcdN1TYMMROXQElB0S8vyD30L026Y,51268
25
- lcode/__init__.py,sha256=WdoZUGYgPTCCB5Z7Yaulmg5d65rPDL3y0aLQ5W8Fi_U,473
23
+ lcode/docs/troubleshooting.md,sha256=iD72y6GOlwLK0HNA1mxfucSU40Iwp7kGyGJa_AX1OWs,9052
24
+ lcode/docs/usage.md,sha256=cIq3cQjnb71DRJN7JXW-DBLFC8bn9680PvU1249h_rI,52175
25
+ lcode/__init__.py,sha256=P4GUmWuUGc0syg6iFxtkWjnjp_qTeIutfDQe_424CF8,473
26
26
  lcode/__main__.py,sha256=s5N5pryX2FAu93GGZ3FxUrIXHWGzxz66lKUoaV_h8Ws,35
27
27
  lcode/acp.py,sha256=9S2n1ycB_IWeOv3zIbuwa6oFW2wyC-GKXcc3Jg5AfQk,30326
28
28
  lcode/action.py,sha256=wuT5F9EJCdEligPeytzmEi8FpahWBhXer528tpuTj_k,16711
29
- lcode/agent.py,sha256=Xd4dW9RJWBri435eQ4ECVxgaluwvjFDcI3xQmheUgkw,37778
30
- lcode/agent_base.py,sha256=55HSTcWzdUKAu6dqtDak8eMQRJf9kDqMfL0m9fe8ihQ,12958
29
+ lcode/agent.py,sha256=uVO28gnM9tndPyFRCmv5WpmfiuA6bn7MhpZsjIayuAw,39631
30
+ lcode/agent_base.py,sha256=EoifTheKCAJlZt9xOvXtVYLNn3uzFQlLvtQmvakRQ_w,13077
31
31
  lcode/agent_checks.py,sha256=CGmrbr7VWMHx5wHprv_ouCOe861eHHxiUUReV0FuYQA,9257
32
32
  lcode/agent_context.py,sha256=arKDF7qYmKEadtcjXDDkCWXBMjT1dut3Rhp7rzT1Yck,7894
33
- lcode/agent_model.py,sha256=LH7luk4OT_9muiDpb-otWi1eztaaLmbwO753Ih3C-B0,16446
33
+ lcode/agent_model.py,sha256=qK3TiFNk9o6FrR1FZgJQiZutS7dqspsPNRjCfV4SUrs,17191
34
34
  lcode/agent_prompt.py,sha256=zRWCQpjgUklZ-bwYIPpvfQuNh2OCnSHsGYg5qd6cdTM,13930
35
35
  lcode/agent_sessions.py,sha256=G_HH5vqb-9VS9_-cCRXLgudq7epXjqHUGLOgZ472-NQ,7526
36
- lcode/api.py,sha256=rsmTspYxc5XNGMYawD_4_gaqi38Z3Htpt2OQNHLEKWQ,20306
36
+ lcode/api.py,sha256=XffpGYz-0_LyVWJ_vYS2jtUvSIXbpC878roAnDD0Ce4,20611
37
37
  lcode/assistant.py,sha256=PccyaafD9FYTS_j_Wn_ZRyc6XMQ-rR8RwCf25ID3VX0,8073
38
- lcode/backends.py,sha256=343alwyDZin-bEhb5-Es4f8ek1oBQUzEvV6RFWR1VZo,21160
39
- lcode/bench.py,sha256=0SMX-wXokfat1HREoomiYCcHZuArJFTmUMxlkdDQh_c,26684
38
+ lcode/backends.py,sha256=PNlRef-ypcBILHGMyLOuG3WVGW0oFtGdxoEv3NbQ2nM,21209
39
+ lcode/bench.py,sha256=ef87Ty_PY8_bIjFcUFkrzlHzenwKYRTQiSehq6dTfFs,27913
40
40
  lcode/bench_backend.py,sha256=2KWk-lse3lo1xhoTiFytZcx84aAkixgTR51Rs8P7M58,14294
41
41
  lcode/bench_budgets.py,sha256=7X09kkOaUxskaNrAJP1OdPafpKxn_d7369rgHqu9jEM,16880
42
42
  lcode/bench_checks.py,sha256=oylPzsIx-4Y6WvDrPG5HYHRlamgy6jKFkg0ydrfqDa0,1539
@@ -48,17 +48,17 @@ lcode/bench_quotes.py,sha256=vdVqxrUEjnmP5Bb55ChRI4E0Qmk8IUrldUqukKzwkc4,21868
48
48
  lcode/bench_runtime.py,sha256=r2J9qkIMUftSB8X6PQnatBH8lFmJTytOXUQrnhfJIJU,6842
49
49
  lcode/catalog.py,sha256=eqTRyLBjLF32cIP8mnBK08cugbJ9kpovhX0qOA5V4lw,4938
50
50
  lcode/checkpoints.py,sha256=brfxR2lbE3UsdvQOzb82m2puDXWz0FfSUGIk6-rnTF4,18845
51
- lcode/checks.py,sha256=MxXBmlXr1c0_TL7jnAv3LZYizVmm8aPWAl48eZmvijo,21006
52
- lcode/cli.py,sha256=xj1SN3ohnndw21J9sHgQHUr_6jvWr5La6zfZwRj-q8s,32269
51
+ lcode/checks.py,sha256=PY9xNnlpjlPX8V1JIZGGn_kUq3jPlXSEVa0KSAJflNg,26791
52
+ lcode/cli.py,sha256=1_um19Ebhxj7HZSNJ_4fEYa_YSIPAwUGsGOI_7GsIL0,32281
53
53
  lcode/cli_args.py,sha256=LHxIRCGSPbVUkcFaRBF8h1H4YG9KV2p-lxg8HR-iuCg,12450
54
54
  lcode/clipboard.py,sha256=nTSdJyCXPdtjH947RjvB3QvRqnL5HZsS9KB8EkC42cc,5138
55
55
  lcode/clips.py,sha256=Xa44XGZM45i_yJiG1iyx6l4OYB2NlrjR1zaWfv_zZGE,2266
56
56
  lcode/cloud.py,sha256=q5Dl5GuqWvKzBCIso-eh6yomvEOsnQ0LW8ZgaAGwBxc,2131
57
57
  lcode/codesearch.py,sha256=Io8leN1nb_Y-Dvlm9xaGtwUWYXX-ooswuznJV6dGU1s,10766
58
58
  lcode/comfy.py,sha256=r4YXQGUPve3rVs6oczAPZVRzc9kq_39zoKtLhmbXv7g,26630
59
- lcode/config.py,sha256=2XyROX-jSwAcN-quPmayqle5MNFjOvqLbkE6L51ACQ0,14564
59
+ lcode/config.py,sha256=8dviuXgH7haKAhgT2Uj83oLnd0Z5LgQHpwviYfXLllU,14684
60
60
  lcode/context.py,sha256=wgK16ZcNNnq4ngHx0EmtyKHDFTImciGEmtC5NP8tKJQ,20435
61
- lcode/doctor.py,sha256=fBmzvYoqbeNS9QjsAJIpxP111IvU6VrOqIkR8UbUnLk,12792
61
+ lcode/doctor.py,sha256=sjs4QGHBSJkXFdiuty9R3LZFt3TFYIoiYr_kcs6alqU,12709
62
62
  lcode/edits.py,sha256=8NFVImwYdvY-B3WGLmVbIvtRL_L5F5d28oaNY3wrbys,13404
63
63
  lcode/escalate.py,sha256=BnmYi-hPqtXci6LCnOnwAN3gDKfJebyiNh0No-CT1Ac,15126
64
64
  lcode/extensions.py,sha256=Hp9R2JKJQUcgD1nRuHK8u7mVs2Cxf8uwwtFePVOZ11Q,16820
@@ -84,22 +84,22 @@ lcode/memory.py,sha256=uyGNn_yNdvn-ie1vnum25-VNieHyZip7lnzrcIzGNb0,24526
84
84
  lcode/models.toml,sha256=lt2G64zzo_Ryxv2ISRSNZoVD_JqCqYqsM01n8WoXGs8,4098
85
85
  lcode/modes.py,sha256=Ybn9Pe2JJjOCIsixZpg-AHvB1nUMckNEiDKGHBLFXjA,5190
86
86
  lcode/notify.py,sha256=uieDeXe7XwuVHjOk4tqVyZEW_85XWkoWQmFOWEf77oc,1538
87
- lcode/ollama.py,sha256=2-tH2ef9Paz-6916UJJN1ltxHoebTuwv6DBVQ09sEpg,8515
87
+ lcode/ollama.py,sha256=705trChad_XfGFfwKIh8JXpoJlVCRKw-Jy-mVP2tQNg,10142
88
88
  lcode/permissions.py,sha256=TXnX-2SS3QO1e9SUeMtZ6sRI3gJQllsDnTtnbIIHpkg,12297
89
89
  lcode/planning.py,sha256=a0rjnj57qwlxqremFgfDGCNgKO-fTKWj36Hj4fBmhbg,6562
90
90
  lcode/preview.py,sha256=ATzEs6yaI1__bfo2_juWznrTDXUD4QTc_aQMPRCytgA,6253
91
91
  lcode/qt_hook.py,sha256=NloRd9p86Gs7r0Zmfd3g7PhR5vMzaGS7UbTO88O7pKw,14463
92
92
  lcode/render.py,sha256=gMvf4W3qkLUJ4Vot3az_hP_zRDAItJC9pP-68dHFkfA,1375
93
93
  lcode/repeats.py,sha256=2lcH25X4EIbgIfNSYyVczRvKFyKhw_DxEzXOX7lRoY0,5986
94
- lcode/repl.py,sha256=u_9DUJL6AUz-drL-nXRoMHkficcQ6nlRTo3ePsG-1rs,39357
94
+ lcode/repl.py,sha256=t0Z1uu2HCGLF53K8TXtm39QuHgYYTdorZk10VNjzfKo,40208
95
95
  lcode/repl_history.py,sha256=gDmgWRklR0Q1FdqYidQ_7XQjXO15B1-WOBf4ReXybO0,12102
96
- lcode/repl_media.py,sha256=abBgNDzxCAXUEZTxZgS36dBdFgW3xMGJ1C6wZHJZWLY,16610
96
+ lcode/repl_media.py,sha256=FOXBnXHbs55jIEdXaFGfd6ZnDTPuGgrLOVTx3s46Jm4,16738
97
97
  lcode/repl_models.py,sha256=txLdULaDqRC0vm4Wlo5gPvneZxIaXiLFzy_gmCcvjJc,13150
98
98
  lcode/repl_sessions.py,sha256=3_3MSEZfxqH2N8-V-aH27Gqq6LibljnjXgvV_s0xiSQ,5812
99
- lcode/replay.py,sha256=98ktUevhOdgLwAtkyCI3BhgaFh22-qbPXtS2tNwXSko,29567
99
+ lcode/replay.py,sha256=aYtyI3TU1rag_cSYpdOFZrQ5N8gfBIW7Aj0XyksWEJY,29674
100
100
  lcode/repoid.py,sha256=jLIzr7aD5H0q0R5lu7s1ENo33Qlf_OQ5Vr2Ucrpl8pQ,2685
101
101
  lcode/repomap.py,sha256=1GRJgEUjBl9XHSXsF7tSGXBCEgsY-3CzwMohaTudZ_M,13969
102
- lcode/residency.py,sha256=MHiJdWVIMsBgaYA7yybiNCEiSjjid7w4_WAUSKolJWQ,15467
102
+ lcode/residency.py,sha256=kbVuqZb6x-IGOb1rNG-kL0sxBj_sHl0mOuYb2efP_vQ,16948
103
103
  lcode/review.py,sha256=275SuOckpaUx8ELKyXV243FChWS0V6DrcpCe0zjyYgo,4689
104
104
  lcode/sandbox.py,sha256=u_pkrVRXhCGhh-wFDPwuZ3jGG7UeXxXRAeBNsm37ZvE,8608
105
105
  lcode/screenshots.py,sha256=vyXN_Yr50DhunDn9jdCKmz2Hv-NEqyfSAJLeHmf_r0U,28481
@@ -107,7 +107,7 @@ lcode/screenshots_web.py,sha256=yuvdpeRhGlXJNsApaZEn2fPWWW0jgsb88nPdezJutpc,1676
107
107
  lcode/secretscan.py,sha256=6Euvfk2gCtK7lZbuQD84zgWuSECi6OnSw8V5rFu1tfU,13575
108
108
  lcode/sessions.py,sha256=kXeAlisBj4YTGyP58AUaRk5fLBa6KsVJMHfbcilaP0E,8897
109
109
  lcode/steer.py,sha256=TKOs82ReYfGA26HKRNU20lTuc_G9GrqtrYfY_hENtYY,12354
110
- lcode/subagents.py,sha256=ttMd1ejUuf8McNC2d6T6GH3L1ONtCczmCvHP_ji1W58,29462
110
+ lcode/subagents.py,sha256=nlBSIn3k9HPfn8M6YM3qtCbKPNL4GVw-JTWN13-q5_s,29575
111
111
  lcode/tool_helpers.py,sha256=207vbgVtO4jzLQYbpqE_v1tDmKO3BzeFVVfsHMXJ3kg,4347
112
112
  lcode/tool_schemas.py,sha256=HU_9i-TWWIWwhoOTStUZuaoS9w5sekqDyV-QjsWWVtM,14782
113
113
  lcode/tools.py,sha256=zzlpOND5qhPya3zqjJ8TgumSwW2MhAzg6IuoYJwQHeg,27294
@@ -116,7 +116,7 @@ lcode/tools_edit.py,sha256=IbZwGAggLjxfpsErr42ewK4EqHXnhxIY9MtGBVFp9KA,11114
116
116
  lcode/tools_shell.py,sha256=wIKsmDOn7nKfJsMFM4wgUhq5ycgkulphcBMSu15Vz4U,13553
117
117
  lcode/trace_export.py,sha256=F6bDL8hZkuCykzCQ1pTVsXJxx29UoqbLOCBZBotbeuU,6934
118
118
  lcode/trace_view.py,sha256=m-HylOvUk0MUdp5VucVj1aoIvpSR0lxJ5VJaoFoImoc,13587
119
- lcode/traces.py,sha256=CG7USBNUdcHSzvnmTszzFVb9xvN2lmtgigF8qt_GvKg,27946
119
+ lcode/traces.py,sha256=ywSaQHZjc9ObA4rB043X7meYb8mBrTGe4YPOP3Gaq2E,27960
120
120
  lcode/unreachable.py,sha256=TXrv41ljwX_amxdcf4CY6qGF2YkWetORvPUSvwceJXI,8685
121
121
  lcode/update.py,sha256=HywxgKBiQLcFsAoK7lZeQ83kDD1Mgo50lV33tf2cbt0,29202
122
122
  lcode/vision.py,sha256=w33QPmdGwP33wM4mvmAH4amFDZ1xzeXhEsSLJ-STSHY,4243
@@ -149,8 +149,8 @@ lcode/workflows/wan21-vace.json,sha256=vJsiRvLCXCjKIibOO0SGM3fT6bedAGxF8N2sN2vcP
149
149
  lcode/workflows/wan22-fun-inp-5b.json,sha256=4HbKEezik8MHvxTMP6PjQUPQPfCeSu10U9FrC-DHKYw,3327
150
150
  lcode/workflows/wan22-ti2v-5b.json,sha256=RcTehoC2pNizzlb7Ed3keJ56DiE7V5lhXmsvR2Y0smQ,3371
151
151
  lcode/workflows/z-image-turbo-t2i.json,sha256=sHsL7xnnuULOuWGYlQrDl4jOTySdAmb2T82c_cChv0s,1585
152
- lcode_cli-0.62.0.dist-info/METADATA,sha256=Nm6h7_9yT8bGYyk19HxhiI9E8FWV9D65ZRZwoD815DM,14260
153
- lcode_cli-0.62.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
154
- lcode_cli-0.62.0.dist-info/entry_points.txt,sha256=Hxsn_itbnbgft3U0FwxWdmEt0yoAV2LB-nJDnL9WT20,172
155
- lcode_cli-0.62.0.dist-info/licenses/LICENSE,sha256=JWjmoL7nNIC1XUa-dZm2hwLUgjUQMFo6k8APb0idNzs,1074
156
- lcode_cli-0.62.0.dist-info/RECORD,,
152
+ lcode_cli-0.63.1.dist-info/METADATA,sha256=6rdZty39fMGcGeH4_IB8zuE9uAUn7wfpEbrJ--ogNqc,14260
153
+ lcode_cli-0.63.1.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
154
+ lcode_cli-0.63.1.dist-info/entry_points.txt,sha256=Hxsn_itbnbgft3U0FwxWdmEt0yoAV2LB-nJDnL9WT20,172
155
+ lcode_cli-0.63.1.dist-info/licenses/LICENSE,sha256=JWjmoL7nNIC1XUa-dZm2hwLUgjUQMFo6k8APb0idNzs,1074
156
+ lcode_cli-0.63.1.dist-info/RECORD,,