lcode-cli 0.54.0__py3-none-any.whl → 0.56.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lcode/__init__.py +1 -1
- lcode/cli.py +6 -0
- lcode/docs/public-benchmarks.md +39 -2
- lcode/docs/quickstart.md +1 -1
- lcode/docs/traces.md +3 -1
- lcode/docs/usage.md +1 -0
- lcode/harbor.py +5 -3
- lcode/harbor_bench.py +286 -25
- lcode/ollama.py +7 -0
- lcode/traces.py +45 -3
- {lcode_cli-0.54.0.dist-info → lcode_cli-0.56.0.dist-info}/METADATA +2 -1
- {lcode_cli-0.54.0.dist-info → lcode_cli-0.56.0.dist-info}/RECORD +15 -15
- {lcode_cli-0.54.0.dist-info → lcode_cli-0.56.0.dist-info}/WHEEL +0 -0
- {lcode_cli-0.54.0.dist-info → lcode_cli-0.56.0.dist-info}/entry_points.txt +0 -0
- {lcode_cli-0.54.0.dist-info → lcode_cli-0.56.0.dist-info}/licenses/LICENSE +0 -0
lcode/__init__.py
CHANGED
lcode/cli.py
CHANGED
|
@@ -952,6 +952,12 @@ def build_subparsers() -> dict[str, argparse.ArgumentParser]:
|
|
|
952
952
|
help="public benchmarks instead: a slice of Terminal-Bench 2.0 and SWE-bench Verified, run with Harbor",
|
|
953
953
|
)
|
|
954
954
|
p.add_argument("--attempts", type=int, default=3, help="with --harbor: attempts per task (default: 3, for pass^3)")
|
|
955
|
+
p.add_argument(
|
|
956
|
+
"--agent",
|
|
957
|
+
choices=["lcode", "claude-code", "opencode", "codex"],
|
|
958
|
+
default="lcode",
|
|
959
|
+
help="with --harbor: the agent to run, for a comparison on the same model (default: lcode)",
|
|
960
|
+
)
|
|
955
961
|
p.add_argument(
|
|
956
962
|
"--docker-bridge",
|
|
957
963
|
action="store_true",
|
lcode/docs/public-benchmarks.md
CHANGED
|
@@ -82,7 +82,9 @@ With three attempts, the last line also gives each run's pass rate and the sprea
|
|
|
82
82
|
- **runs and spread**: the pass rate of each task's first attempt, its second and its third. Single
|
|
83
83
|
runs of the same setup differ by several points, so differences smaller than the spread are noise.
|
|
84
84
|
- **Time and tokens** per attempt, from lcode's own record of the request (its
|
|
85
|
-
[trace](traces.md)).
|
|
85
|
+
[trace](traces.md)). An attempt stopped at the task's time limit counts the tokens recorded
|
|
86
|
+
until then, and a reply lcode stopped counts with an estimate. `–` means no attempt of the task
|
|
87
|
+
has a record.
|
|
86
88
|
|
|
87
89
|
Attempts whose container didn't start (a failed image download, say) count neither as passed nor
|
|
88
90
|
as failed. The report shows how many there were.
|
|
@@ -90,10 +92,45 @@ as failed. The report shows how many there were.
|
|
|
90
92
|
Everything is saved in `~/.local/state/lcode/bench/<slice>-<time>/`:
|
|
91
93
|
|
|
92
94
|
- `lcode-bench.json`: the results, with the lcode and Harbor versions, the model, the context, the
|
|
93
|
-
machine, the
|
|
95
|
+
machine, when the run started and how long it took, and the command that reproduces them.
|
|
96
|
+
`--json FILE` saves a copy.
|
|
94
97
|
- Harbor's own results: each attempt's log, the task's test output, and lcode's trace and session.
|
|
95
98
|
`uvx --from harbor harbor view <folder>` browses them.
|
|
96
99
|
|
|
100
|
+
## Other agents on the same model
|
|
101
|
+
|
|
102
|
+
`--agent` runs Claude Code, OpenCode or Codex on the same tasks, with the same model, context
|
|
103
|
+
window and time limits, so you can compare them with lcode:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
lcode bench --harbor dev qwen3.6-35b --context 64k # lcode
|
|
107
|
+
lcode bench --harbor dev qwen3.6-35b --context 64k --agent claude-code
|
|
108
|
+
lcode bench --harbor dev qwen3.6-35b --context 64k --agent opencode
|
|
109
|
+
lcode bench --harbor dev qwen3.6-35b --context 64k --agent codex
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Harbor installs the agent in each task's container, with approvals off. lcode sets the agent up the
|
|
113
|
+
way `ollama launch` does, with the Ollama on your machine:
|
|
114
|
+
|
|
115
|
+
- **Claude Code** uses Ollama's Anthropic-compatible API, with the model for every tier (subagents
|
|
116
|
+
too) and `ollama launch claude`'s settings: no telemetry, error reports or feedback prompts. Like
|
|
117
|
+
`ollama launch claude`, it doesn't tell Claude Code the context window.
|
|
118
|
+
- **OpenCode** uses an Ollama provider on Ollama's OpenAI-compatible API. The model is marked as a
|
|
119
|
+
reasoning model, with the limits of its context window.
|
|
120
|
+
- **Codex** uses Ollama's Responses API and `ollama launch codex`'s model catalog. That catalog gives
|
|
121
|
+
local models no base instructions, so Codex runs without its own system prompt, as it does with
|
|
122
|
+
`ollama launch codex`.
|
|
123
|
+
|
|
124
|
+
These agents' APIs can't set the context window per request, and Ollama's default is small (4K on
|
|
125
|
+
GPUs under 24 GB), so lcode makes a copy of the model with the context set:
|
|
126
|
+
`lcode-qwen3.6-35b-64k` for 64K. It uses the model's files, so nothing is downloaded, and
|
|
127
|
+
`ollama rm lcode-qwen3.6-35b-64k` removes it. Ollama recommends at least 64K for these agents.
|
|
128
|
+
|
|
129
|
+
The time per task leaves out installing the agent, which Harbor does in every task's container: up to
|
|
130
|
+
three minutes for Claude Code, so its runs take longer overall. The results go to
|
|
131
|
+
`~/.local/state/lcode/bench/<slice>-<agent>-<time>/`, and `lcode-bench.json` adds the agent and its
|
|
132
|
+
version.
|
|
133
|
+
|
|
97
134
|
## With Harbor directly
|
|
98
135
|
|
|
99
136
|
`lcode.harbor:Lcode` is an ordinary Harbor agent, so every Harbor dataset and option works:
|
lcode/docs/quickstart.md
CHANGED
lcode/docs/traces.md
CHANGED
|
@@ -20,7 +20,9 @@ lcode trace path # the folder the traces are in
|
|
|
20
20
|
failed check, a note about a malformed tool call, a note you typed while it worked.
|
|
21
21
|
- **Each model call:** the answer (text, reasoning and tool calls), the time to the first token,
|
|
22
22
|
the total time, and the tokens in and out. With Ollama, also how long loading the model and
|
|
23
|
-
reading the prompt took.
|
|
23
|
+
reading the prompt took. The server counts a reply's tokens only when the reply ends, so for one
|
|
24
|
+
lcode stopped (it went round in circles, or you interrupted it) the trace has an estimate:
|
|
25
|
+
`estimated_in` and `estimated_out`, shown as "about".
|
|
24
26
|
- **Each tool call:** its arguments, the result the model got, and how long it took. A result
|
|
25
27
|
longer than 200,000 characters keeps its start and end. When lcode cut a long output for the
|
|
26
28
|
model, the result says where the full output was saved.
|
lcode/docs/usage.md
CHANGED
|
@@ -11,6 +11,7 @@ lcode media [install MODEL] # image and video models: what fits here, what's in
|
|
|
11
11
|
lcode config [set|unset] # show or change settings
|
|
12
12
|
lcode bench [models] # score models on small coding tasks on this machine
|
|
13
13
|
lcode bench --harbor dev # public benchmarks: Terminal-Bench 2.0 and SWE-bench Verified
|
|
14
|
+
lcode bench --harbor dev --agent codex # the same with another agent on your model, to compare
|
|
14
15
|
lcode trace [action] [N] # past requests: show one step by step, export or replay it (see Run traces)
|
|
15
16
|
lcode mcp [catalog|add|list] # connect MCP servers: Jira, GitHub, AWS, databases… (see MCP servers)
|
|
16
17
|
lcode acp # run inside an editor over the Agent Client Protocol (see Editors)
|
lcode/harbor.py
CHANGED
|
@@ -67,8 +67,10 @@ class Lcode(BaseInstalledAgent):
|
|
|
67
67
|
end = harbor_bench.trace_usage(Path(self.logs_dir) / "lcode")
|
|
68
68
|
if end is None:
|
|
69
69
|
return
|
|
70
|
-
context.n_input_tokens =
|
|
71
|
-
context.n_output_tokens = int(end.get("tokens_out") or 0)
|
|
70
|
+
context.n_input_tokens, context.n_output_tokens = harbor_bench.usage_tokens(end)
|
|
72
71
|
context.cost_usd = 0.0
|
|
73
|
-
keys = (
|
|
72
|
+
keys = (
|
|
73
|
+
*("status", "seconds", "steps", "model_calls", "tool_calls", "model_seconds", "tool_seconds"),
|
|
74
|
+
*("tokens_in", "tokens_out", "estimated_in", "estimated_out"), # the estimates: replies lcode stopped
|
|
75
|
+
)
|
|
74
76
|
context.metadata = {**(context.metadata or {}), "lcode": {key: end.get(key) for key in keys}}
|
lcode/harbor_bench.py
CHANGED
|
@@ -10,18 +10,25 @@ model can try overnight: Terminal-Bench 2.0 without model training and with at m
|
|
|
10
10
|
task, and SWE-bench Verified's two common difficulties. The dev slice is for everyday checks; the
|
|
11
11
|
held-out set is never used for tuning, only to confirm a change helps beyond the tasks it was
|
|
12
12
|
tuned on.
|
|
13
|
+
|
|
14
|
+
Other agents run on the same slices and the same model for comparison (`--agent`): Claude Code,
|
|
15
|
+
OpenCode and Codex, each set up the way `ollama launch` sets it up.
|
|
13
16
|
"""
|
|
14
17
|
|
|
15
18
|
from __future__ import annotations
|
|
16
19
|
|
|
17
20
|
import datetime as dt
|
|
18
21
|
import json
|
|
22
|
+
import os
|
|
19
23
|
import shlex
|
|
20
24
|
import statistics
|
|
21
25
|
import subprocess
|
|
26
|
+
import time
|
|
22
27
|
from dataclasses import asdict, dataclass, field
|
|
23
28
|
from pathlib import Path
|
|
24
29
|
|
|
30
|
+
from lcode.ollama import OllamaError
|
|
31
|
+
|
|
25
32
|
HARBOR = "harbor==0.25.0" # the Harbor these slices were made and checked with
|
|
26
33
|
HARBOR_PYTHON = "3.13"
|
|
27
34
|
AGENT = "lcode.harbor:Lcode"
|
|
@@ -66,6 +73,143 @@ LOG = "/logs/agent/lcode.txt"
|
|
|
66
73
|
ON_PATH = 'export PATH="$HOME/.local/bin:$PATH";' # where uv puts lcode and itself
|
|
67
74
|
|
|
68
75
|
|
|
76
|
+
# ----------------------------------------------------------------------------- other agents on the same model
|
|
77
|
+
|
|
78
|
+
# The agents compared with lcode (#198), by Harbor's names. Each is set up the way `ollama launch` sets it up (in
|
|
79
|
+
# Ollama's cmd/launch), with your machine's Ollama as a task's container reaches it, approvals off (Harbor's).
|
|
80
|
+
OTHER_AGENTS = ("claude-code", "opencode", "codex")
|
|
81
|
+
OLLAMA_FROM_TASKS = f"http://host.docker.internal:{OLLAMA_PORT}" # with the host-gateway entry in the overlay
|
|
82
|
+
CODEX_CATALOG = "/opt/lcode-bench/codex-models.json" # in the task's container
|
|
83
|
+
CLAUDE_CODE_ENV = { # what `ollama launch claude` sets besides the address, the key and each tier's model (Harbor's)
|
|
84
|
+
"ENABLE_CLAUDEAI_MCP_SERVERS": "false",
|
|
85
|
+
"CLAUDE_CODE_ATTRIBUTION_HEADER": "0",
|
|
86
|
+
"CLAUDE_CODE_TOTAL_TOKENS_REMINDER": "off",
|
|
87
|
+
"DISABLE_ERROR_REPORTING": "1",
|
|
88
|
+
"DISABLE_FEEDBACK_COMMAND": "1",
|
|
89
|
+
"CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY": "1",
|
|
90
|
+
"CLAUDE_CODE_AUTO_MODE_SERVER": "0",
|
|
91
|
+
}
|
|
92
|
+
CODEX_LEVELS = { # Codex's reasoning efforts for Ollama's thinking values, with Ollama's descriptions
|
|
93
|
+
"none": "Turn thinking off",
|
|
94
|
+
"minimal": "Thinking effort",
|
|
95
|
+
"low": "Fast responses with lighter thinking",
|
|
96
|
+
"medium": "Balances speed and thinking depth for everyday tasks",
|
|
97
|
+
"high": "Greater thinking depth for complex tasks",
|
|
98
|
+
"xhigh": "Thinking effort",
|
|
99
|
+
"max": "Maximum thinking depth for the hardest tasks",
|
|
100
|
+
"ultra": "Thinking effort",
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def variant_name(model: str, context: int) -> str:
|
|
105
|
+
"""The Ollama model the other agents get: `model` with its context window set (lcode-qwen3.6-35b-64k), since
|
|
106
|
+
the APIs they use (OpenAI's, Anthropic's) can't set it per request and Ollama's default is small."""
|
|
107
|
+
from lcode.config import format_tokens
|
|
108
|
+
|
|
109
|
+
return f"{model.removesuffix(':latest')}-{format_tokens(context).lower()}"
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def agent_overlay(bridge: bool, catalog: Path | None = None) -> str:
|
|
113
|
+
"""The Docker Compose override for another agent's tasks: host.docker.internal is your machine (Docker Desktop
|
|
114
|
+
has it; on Linux it's added), and Codex's model catalog is in the container."""
|
|
115
|
+
lines = ["services:", " main:"]
|
|
116
|
+
if bridge:
|
|
117
|
+
lines.append(" network_mode: bridge")
|
|
118
|
+
lines += [" extra_hosts:", ' - "host.docker.internal:host-gateway"']
|
|
119
|
+
if catalog is not None:
|
|
120
|
+
lines += [" volumes:", f" - {json.dumps(f'{catalog}:{CODEX_CATALOG}:ro')}"]
|
|
121
|
+
return "\n".join(lines) + "\n"
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def opencode_config(model: str, context: int, thinking: bool) -> dict:
|
|
125
|
+
"""`ollama launch opencode`'s provider: Ollama's OpenAI-compatible API, and the model with the limits of the
|
|
126
|
+
context it runs at (a quarter of it for output, at most 8K)."""
|
|
127
|
+
entry: dict = {"name": model}
|
|
128
|
+
if thinking: # a model that can think without levels: on, or "none"
|
|
129
|
+
entry["reasoning"] = True
|
|
130
|
+
entry["variants"] = {
|
|
131
|
+
"none": {"reasoningEffort": "none"},
|
|
132
|
+
"low": {"disabled": True},
|
|
133
|
+
"medium": {"disabled": True},
|
|
134
|
+
"high": {"disabled": True},
|
|
135
|
+
}
|
|
136
|
+
entry["limit"] = {"context": context, "input": context, "output": min(8192, context // 4)}
|
|
137
|
+
provider = {"npm": "@ai-sdk/openai-compatible", "name": "Ollama", "options": {"baseURL": f"{OLLAMA_FROM_TASKS}/v1"}}
|
|
138
|
+
return {"provider": {"ollama": {**provider, "models": {model: entry}}}}
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def codex_level(value: object) -> str | None:
|
|
142
|
+
if isinstance(value, bool):
|
|
143
|
+
return "high" if value else "none"
|
|
144
|
+
return value if isinstance(value, str) and value in CODEX_LEVELS and value != "none" else None
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def codex_catalog(model: str, context: int, thinking: dict | None) -> dict:
|
|
148
|
+
"""`ollama launch codex`'s model catalog entry, so Codex knows the model (otherwise it warns that it falls back
|
|
149
|
+
to defaults that "can degrade performance"). `thinking`: Ollama's, as `/api/show` gives it."""
|
|
150
|
+
values = list((thinking or {}).get("values") or [])
|
|
151
|
+
levels: list[str] = []
|
|
152
|
+
for value in values:
|
|
153
|
+
if value is True and "high" in values:
|
|
154
|
+
continue
|
|
155
|
+
level = codex_level(value)
|
|
156
|
+
if level is not None and level not in levels:
|
|
157
|
+
levels.append(level)
|
|
158
|
+
default = codex_level((thinking or {}).get("default"))
|
|
159
|
+
if default not in levels or (len(values) == 1 and False in values):
|
|
160
|
+
default = None
|
|
161
|
+
entry = {
|
|
162
|
+
"slug": model,
|
|
163
|
+
"display_name": model,
|
|
164
|
+
"context_window": context,
|
|
165
|
+
"shell_type": "default",
|
|
166
|
+
"visibility": "list",
|
|
167
|
+
"supported_in_api": True,
|
|
168
|
+
"priority": 0,
|
|
169
|
+
"truncation_policy": {"mode": "bytes", "limit": 10000},
|
|
170
|
+
"input_modalities": ["text"],
|
|
171
|
+
"base_instructions": "",
|
|
172
|
+
"support_verbosity": True,
|
|
173
|
+
"default_verbosity": "low",
|
|
174
|
+
"supports_parallel_tool_calls": False,
|
|
175
|
+
"supports_reasoning_summaries": False,
|
|
176
|
+
"supported_reasoning_levels": [{"effort": level, "description": CODEX_LEVELS[level]} for level in levels],
|
|
177
|
+
"default_reasoning_level": default,
|
|
178
|
+
"experimental_supported_tools": [],
|
|
179
|
+
}
|
|
180
|
+
return {"models": [entry]}
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def codex_config() -> dict:
|
|
184
|
+
"""`ollama launch codex`'s profile: Ollama's Responses API, and the model catalog."""
|
|
185
|
+
provider = {"name": "Ollama", "base_url": f"{OLLAMA_FROM_TASKS}/v1/", "wire_api": "responses"}
|
|
186
|
+
return {
|
|
187
|
+
"model_provider": "ollama-launch",
|
|
188
|
+
"model_providers": {"ollama-launch": provider},
|
|
189
|
+
"model_catalog_json": CODEX_CATALOG,
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def agent_setup(agent: str, model: str, context: int, show: dict, folder: Path) -> tuple[list[str], Path | None]:
|
|
194
|
+
"""Harbor's arguments for another agent on `model` (the Ollama model at `context`), and Codex's model catalog,
|
|
195
|
+
written in `folder`. `show`: Ollama's `/api/show` for the model."""
|
|
196
|
+
thinking = "thinking" in (show.get("capabilities") or [])
|
|
197
|
+
if agent == "claude-code":
|
|
198
|
+
return [arg for name, value in CLAUDE_CODE_ENV.items() for arg in ("--ae", f"{name}={value}")], None
|
|
199
|
+
if agent == "opencode":
|
|
200
|
+
return ["--ak", "opencode_config=" + json.dumps(opencode_config(model, context, thinking))], None
|
|
201
|
+
if agent == "codex":
|
|
202
|
+
catalog = folder / "codex-models.json"
|
|
203
|
+
catalog.write_text(json.dumps(codex_catalog(model, context, show.get("thinking") if thinking else None)))
|
|
204
|
+
return ["--ak", "config=" + json.dumps(codex_config())], catalog
|
|
205
|
+
raise ValueError(f"unknown agent {agent!r}")
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def harbor_env() -> dict[str, str]:
|
|
209
|
+
"""For Harbor itself: other agents reach Ollama through its `ollama/` provider, which needs a key (any)."""
|
|
210
|
+
return {"OLLAMA_BASE_URL": OLLAMA_FROM_TASKS, "OLLAMA_API_KEY": "ollama"}
|
|
211
|
+
|
|
212
|
+
|
|
69
213
|
def find_ollama(routes: str = "/proc/net/route") -> str:
|
|
70
214
|
"""Shell that sets OLLAMA_HOST, unless it's set, to Ollama on your machine as a task's container sees it:
|
|
71
215
|
host.docker.internal where Docker provides it (Docker Desktop), else the container's default gateway, which is
|
|
@@ -108,23 +252,63 @@ def run_env(model: str | None) -> dict[str, str]:
|
|
|
108
252
|
|
|
109
253
|
|
|
110
254
|
def trace_usage(home: Path) -> dict | None:
|
|
111
|
-
"""How the newest request traced in `home` (lcode's LCODE_HOME in the task) went: its end event.
|
|
255
|
+
"""How the newest request traced in `home` (lcode's LCODE_HOME in the task) went: its end event. When lcode
|
|
256
|
+
was stopped before the request ended (at the task's time limit), the totals of what its trace recorded."""
|
|
112
257
|
traces = sorted((home / "traces").glob("*.jsonl"), key=lambda path: path.stat().st_mtime)
|
|
113
258
|
for path in reversed(traces):
|
|
114
259
|
try:
|
|
115
260
|
lines = path.read_text(errors="replace").splitlines()
|
|
116
261
|
except OSError:
|
|
117
262
|
continue
|
|
118
|
-
|
|
263
|
+
events = []
|
|
264
|
+
for line in lines:
|
|
119
265
|
try:
|
|
120
266
|
event = json.loads(line)
|
|
121
267
|
except ValueError:
|
|
122
268
|
continue
|
|
123
|
-
if isinstance(event, dict)
|
|
124
|
-
|
|
269
|
+
if isinstance(event, dict):
|
|
270
|
+
events.append(event)
|
|
271
|
+
end = next((event for event in reversed(events) if event.get("type") == "end"), None)
|
|
272
|
+
if end is not None:
|
|
273
|
+
return end
|
|
274
|
+
if any(event.get("type") == "model" for event in events):
|
|
275
|
+
return unfinished_usage(events)
|
|
125
276
|
return None
|
|
126
277
|
|
|
127
278
|
|
|
279
|
+
def unfinished_usage(events: list[dict]) -> dict:
|
|
280
|
+
"""An end event's totals for a request that never ended, from the events its trace has."""
|
|
281
|
+
usage: dict = {"type": "end", "status": "unfinished", "steps": 0, "model_calls": 0, "tool_calls": 0}
|
|
282
|
+
usage.update(dict.fromkeys(("tokens_in", "tokens_out", "estimated_in", "estimated_out"), 0))
|
|
283
|
+
usage.update(seconds=0.0, model_seconds=0.0, tool_seconds=0.0)
|
|
284
|
+
for event in events:
|
|
285
|
+
usage["seconds"] = max(usage["seconds"], number(event.get("at")))
|
|
286
|
+
if event.get("type") == "model":
|
|
287
|
+
usage["model_calls"] += 1
|
|
288
|
+
for key in ("tokens_in", "tokens_out", "estimated_in", "estimated_out"):
|
|
289
|
+
usage[key] += int(number(event.get(key)))
|
|
290
|
+
usage["model_seconds"] += number(event.get("seconds"))
|
|
291
|
+
if event.get("lane", "main") == "main" and event.get("kind") == "step":
|
|
292
|
+
usage["steps"] = max(usage["steps"], int(number(event.get("step"))))
|
|
293
|
+
elif event.get("type") == "tool":
|
|
294
|
+
usage["tool_calls"] += 1
|
|
295
|
+
usage["tool_seconds"] += number(event.get("seconds"))
|
|
296
|
+
return usage
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
def number(value: object) -> float:
|
|
300
|
+
return float(value) if isinstance(value, (int, float)) and not isinstance(value, bool) else 0.0
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
def usage_tokens(usage: dict) -> tuple[int, int]:
|
|
304
|
+
"""Tokens in and out of a traced request, with the estimates for replies lcode stopped before the server
|
|
305
|
+
counted them."""
|
|
306
|
+
return (
|
|
307
|
+
int(number(usage.get("tokens_in")) + number(usage.get("estimated_in"))),
|
|
308
|
+
int(number(usage.get("tokens_out")) + number(usage.get("estimated_out"))),
|
|
309
|
+
)
|
|
310
|
+
|
|
311
|
+
|
|
128
312
|
# ----------------------------------------------------------------------------- running Harbor, and the report
|
|
129
313
|
|
|
130
314
|
|
|
@@ -140,17 +324,22 @@ def harbor_argv(
|
|
|
140
324
|
lcode_with: list[str] | None = None,
|
|
141
325
|
wheel: Path | None = None,
|
|
142
326
|
overlay: Path | None = None,
|
|
327
|
+
agent: str = "lcode",
|
|
328
|
+
agent_args: list[str] | None = None,
|
|
143
329
|
) -> list[str]:
|
|
144
|
-
"""`harbor run` for some tasks of a dataset, with uvx, and lcode next to Harbor so it can import the agent.
|
|
330
|
+
"""`harbor run` for some tasks of a dataset, with uvx, and lcode next to Harbor so it can import the agent.
|
|
331
|
+
Another `agent` (Harbor's name) gets `model` as Harbor's `ollama/` model and `agent_args` (agent_setup)."""
|
|
145
332
|
argv = ["uvx", "--python", HARBOR_PYTHON, "--from", HARBOR, *(lcode_with or []), "harbor", "run"]
|
|
146
|
-
|
|
333
|
+
harbor_agent, harbor_model = (AGENT, model) if agent == "lcode" else (agent, f"ollama/{model}")
|
|
334
|
+
argv += ["-d", DATASETS[dataset], "-a", harbor_agent, "-m", harbor_model, "-k", str(attempts), "-n", "1"]
|
|
147
335
|
argv += ["-o", str(jobs), "--job-name", job_name, "-y"]
|
|
148
336
|
for task in tasks:
|
|
149
337
|
argv += ["-i", task, "-i", f"*/{task}"] # the name alone, or with its organization in front
|
|
150
|
-
if context:
|
|
338
|
+
if context and agent == "lcode": # the others get a model with the context set (variant_name)
|
|
151
339
|
argv += ["--ak", f"context={context}"]
|
|
152
340
|
if wheel:
|
|
153
341
|
argv += ["--ak", f"wheel={wheel}"]
|
|
342
|
+
argv += agent_args or []
|
|
154
343
|
if overlay:
|
|
155
344
|
argv += ["--extra-docker-compose", str(overlay)]
|
|
156
345
|
return argv
|
|
@@ -165,9 +354,10 @@ class Trial:
|
|
|
165
354
|
reward: float | None # None: the task's tests didn't run (its container didn't start, say)
|
|
166
355
|
started: str = ""
|
|
167
356
|
seconds: float | None = None # lcode's time on the task
|
|
168
|
-
tokens_in: int =
|
|
169
|
-
tokens_out: int =
|
|
357
|
+
tokens_in: int | None = None # None: not known (no trace)
|
|
358
|
+
tokens_out: int | None = None
|
|
170
359
|
error: str = ""
|
|
360
|
+
version: str = "" # the agent's, in the task's container
|
|
171
361
|
|
|
172
362
|
|
|
173
363
|
def seconds_between(timing: dict | None) -> float | None:
|
|
@@ -194,6 +384,11 @@ def read_trials(job: Path, dataset: str) -> list[Trial]:
|
|
|
194
384
|
if error and problem.get("exception_message"):
|
|
195
385
|
error += ": " + str(problem["exception_message"]).strip().splitlines()[-1][:300]
|
|
196
386
|
name = str(result.get("task_name") or path.parent.name.rsplit("__", 1)[0])
|
|
387
|
+
tokens_in, tokens_out = agent.get("n_input_tokens"), agent.get("n_output_tokens")
|
|
388
|
+
if tokens_in is None and tokens_out is None: # lcode 0.54.0 gave none for an attempt stopped at its limit
|
|
389
|
+
usage = trace_usage(path.parent / "agent" / "lcode")
|
|
390
|
+
if usage is not None:
|
|
391
|
+
tokens_in, tokens_out = usage_tokens(usage)
|
|
197
392
|
trials.append(
|
|
198
393
|
Trial(
|
|
199
394
|
dataset=dataset,
|
|
@@ -201,9 +396,10 @@ def read_trials(job: Path, dataset: str) -> list[Trial]:
|
|
|
201
396
|
reward=float(reward) if isinstance(reward, (int, float)) else None,
|
|
202
397
|
started=str(result.get("started_at") or ""),
|
|
203
398
|
seconds=seconds_between(result.get("agent_execution")),
|
|
204
|
-
tokens_in=int(
|
|
205
|
-
tokens_out=int(
|
|
399
|
+
tokens_in=None if tokens_in is None else int(number(tokens_in)),
|
|
400
|
+
tokens_out=None if tokens_out is None else int(number(tokens_out)),
|
|
206
401
|
error=error,
|
|
402
|
+
version=str((result.get("agent_info") or {}).get("version") or ""),
|
|
207
403
|
)
|
|
208
404
|
)
|
|
209
405
|
return trials
|
|
@@ -216,8 +412,8 @@ class TaskResult:
|
|
|
216
412
|
passed: list[bool] = field(default_factory=list) # each attempt whose tests ran, in the order they ran
|
|
217
413
|
not_run: int = 0
|
|
218
414
|
seconds: float | None = None # per attempt, on average
|
|
219
|
-
tokens_in: int =
|
|
220
|
-
tokens_out: int =
|
|
415
|
+
tokens_in: int | None = None # per attempt, on average, of those whose tokens are known
|
|
416
|
+
tokens_out: int | None = None
|
|
221
417
|
|
|
222
418
|
|
|
223
419
|
@dataclass
|
|
@@ -242,6 +438,8 @@ def summarize(trials: list[Trial], attempts: int = ATTEMPTS) -> Summary:
|
|
|
242
438
|
for (dataset, task), group in groups.items():
|
|
243
439
|
ran = [t for t in group if t.reward is not None]
|
|
244
440
|
timed = [t.seconds for t in ran if t.seconds is not None]
|
|
441
|
+
counted_in = [t.tokens_in for t in ran if t.tokens_in is not None]
|
|
442
|
+
counted_out = [t.tokens_out for t in ran if t.tokens_out is not None]
|
|
245
443
|
tasks.append(
|
|
246
444
|
TaskResult(
|
|
247
445
|
dataset,
|
|
@@ -249,8 +447,8 @@ def summarize(trials: list[Trial], attempts: int = ATTEMPTS) -> Summary:
|
|
|
249
447
|
[(t.reward or 0) >= 1 for t in ran],
|
|
250
448
|
len(group) - len(ran),
|
|
251
449
|
statistics.fmean(timed) if timed else None,
|
|
252
|
-
round(statistics.fmean(
|
|
253
|
-
round(statistics.fmean(
|
|
450
|
+
round(statistics.fmean(counted_in)) if counted_in else None,
|
|
451
|
+
round(statistics.fmean(counted_out)) if counted_out else None,
|
|
254
452
|
)
|
|
255
453
|
)
|
|
256
454
|
scored = [t for t in tasks if t.passed]
|
|
@@ -278,7 +476,9 @@ def print_summary(console, summary: Summary) -> None:
|
|
|
278
476
|
for t in summary.tasks:
|
|
279
477
|
passed = f"{sum(t.passed)}/{len(t.passed)}" + (f" ({t.not_run} didn't run)" if t.not_run else "")
|
|
280
478
|
took = "–" if t.seconds is None else f"{t.seconds / 60:.1f} min"
|
|
281
|
-
|
|
479
|
+
tokens_in = "–" if t.tokens_in is None else f"{t.tokens_in:,}"
|
|
480
|
+
tokens_out = "–" if t.tokens_out is None else f"{t.tokens_out:,}"
|
|
481
|
+
table.add_row(t.task, t.dataset, passed, took, tokens_in, tokens_out)
|
|
282
482
|
console.print(table)
|
|
283
483
|
k = summary.attempts
|
|
284
484
|
line = f"pass@1 {percent(summary.pass_at_1)} · pass^{k} {percent(summary.pass_all)}"
|
|
@@ -289,6 +489,37 @@ def print_summary(console, summary: Summary) -> None:
|
|
|
289
489
|
console.print(f"[yellow]{summary.not_run} attempt(s) didn't run (their container didn't start, say).[/]")
|
|
290
490
|
|
|
291
491
|
|
|
492
|
+
def took(seconds: float) -> str:
|
|
493
|
+
hours, minutes = divmod(round(seconds / 60), 60)
|
|
494
|
+
return f"{hours} h {minutes} min" if hours else f"{minutes} min"
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
def context_variant(settings: dict, model: str, context: int, console) -> tuple[str, dict]:
|
|
498
|
+
"""The Ollama model for another agent (variant_name), made when it's missing, and Ollama's `/api/show` for it.
|
|
499
|
+
Making it copies nothing: it's the same files with one more parameter."""
|
|
500
|
+
from rich.markup import escape
|
|
501
|
+
|
|
502
|
+
from lcode.cli import NotInstalled, resolve_model
|
|
503
|
+
from lcode.config import format_tokens
|
|
504
|
+
from lcode.ollama import Ollama
|
|
505
|
+
|
|
506
|
+
if settings.get("backend", "ollama") != "ollama":
|
|
507
|
+
raise OllamaError("--agent runs the other agents on Ollama's models: lcode's backend here isn't Ollama.")
|
|
508
|
+
ollama = Ollama(settings["ollama_host"])
|
|
509
|
+
try:
|
|
510
|
+
tag, _ = resolve_model(ollama, model)
|
|
511
|
+
except NotInstalled as e:
|
|
512
|
+
raise OllamaError(str(e)) from e
|
|
513
|
+
name = variant_name(tag, context)
|
|
514
|
+
if name not in ollama.installed_names():
|
|
515
|
+
ollama.create_variant(name, tag, {"num_ctx": context})
|
|
516
|
+
console.print(
|
|
517
|
+
f"Made [bold]{escape(name)}[/]: {escape(tag)} with a {format_tokens(context)} context window, for the "
|
|
518
|
+
f"other agents, which can't set it per request. `ollama rm {escape(name)}` removes it."
|
|
519
|
+
)
|
|
520
|
+
return name, ollama.show(name)
|
|
521
|
+
|
|
522
|
+
|
|
292
523
|
def print_slice(console, name: str) -> None:
|
|
293
524
|
for dataset, tasks in SLICES[name].items():
|
|
294
525
|
console.print(f"[bold]{DATASETS[dataset]}[/] ({len(tasks)}): {', '.join(tasks)}")
|
|
@@ -317,6 +548,7 @@ def command(args, console) -> int:
|
|
|
317
548
|
model = args.models[0] if args.models else settings["model"]
|
|
318
549
|
# Always given: in a task's container lcode sees no GPU and would pick a context for the CPU.
|
|
319
550
|
context = config.parse_context(args.context or settings.get("context") or 32768)
|
|
551
|
+
agent = getattr(args, "agent", None) or "lcode"
|
|
320
552
|
attempts = max(1, args.attempts)
|
|
321
553
|
wanted = {name.strip() for name in args.tasks.split(",")} if args.tasks else None
|
|
322
554
|
picked = {
|
|
@@ -328,11 +560,25 @@ def command(args, console) -> int:
|
|
|
328
560
|
f"[red]Not in the {args.harbor} slice: {', '.join(unknown)}[/] (lcode bench --harbor {args.harbor} --list)"
|
|
329
561
|
)
|
|
330
562
|
return 2
|
|
331
|
-
|
|
563
|
+
ollama_model, show, agent_args, env = "", {}, None, None
|
|
564
|
+
if agent != "lcode": # on Ollama's model at the context, set up like `ollama launch` does
|
|
565
|
+
try:
|
|
566
|
+
ollama_model, show = context_variant(settings, model, context, console)
|
|
567
|
+
except OllamaError as e:
|
|
568
|
+
console.print(f"[red]{escape(str(e))}[/]")
|
|
569
|
+
return 1
|
|
570
|
+
named = args.harbor if agent == "lcode" else f"{args.harbor}-{agent}"
|
|
571
|
+
jobs = config.STATE_DIR / "bench" / f"{named}-{dt.datetime.now():%Y%m%d-%H%M%S}"
|
|
332
572
|
jobs.mkdir(parents=True, exist_ok=True)
|
|
333
573
|
install = update.lcode_install()
|
|
334
574
|
wheel = None
|
|
335
|
-
if
|
|
575
|
+
if agent != "lcode":
|
|
576
|
+
agent_args, catalog = agent_setup(agent, ollama_model, context, show, jobs)
|
|
577
|
+
overlay = jobs / "overlay.yaml"
|
|
578
|
+
overlay.write_text(agent_overlay(bool(args.docker_bridge), catalog))
|
|
579
|
+
lcode_with = None
|
|
580
|
+
env = {**os.environ, **harbor_env()}
|
|
581
|
+
elif install.kind == "checkout" and install.path: # this checkout, in Harbor and in the containers
|
|
336
582
|
lcode_with = ["--with-editable", str(install.path)]
|
|
337
583
|
build = ["uv", "build", "--wheel", "-q", "-o", str(jobs / "wheel"), str(install.path)]
|
|
338
584
|
if subprocess.run(build, capture_output=True, text=True).returncode != 0:
|
|
@@ -341,24 +587,34 @@ def command(args, console) -> int:
|
|
|
341
587
|
wheel = next((jobs / "wheel").glob("*.whl"), None)
|
|
342
588
|
else:
|
|
343
589
|
lcode_with = ["--with", f"lcode-cli=={__version__}"]
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
590
|
+
if agent == "lcode":
|
|
591
|
+
overlay = None
|
|
592
|
+
if args.docker_bridge:
|
|
593
|
+
overlay = jobs / "bridge.yaml"
|
|
594
|
+
overlay.write_text(BRIDGE_OVERLAY)
|
|
348
595
|
trials: list[Trial] = []
|
|
596
|
+
started, began = dt.datetime.now().astimezone(), time.monotonic()
|
|
349
597
|
for dataset, tasks in picked.items():
|
|
350
598
|
if not tasks:
|
|
351
599
|
continue
|
|
352
600
|
argv = harbor_argv(
|
|
353
|
-
dataset, tasks, model, jobs, dataset, attempts=attempts, context=context,
|
|
354
|
-
wheel=wheel, overlay=overlay,
|
|
601
|
+
dataset, tasks, ollama_model or model, jobs, dataset, attempts=attempts, context=context,
|
|
602
|
+
lcode_with=lcode_with, wheel=wheel, overlay=overlay, agent=agent, agent_args=agent_args,
|
|
355
603
|
) # fmt: skip
|
|
356
604
|
console.print(f"[bold]{DATASETS[dataset]}[/]: {len(tasks)} task(s), {attempts} attempt(s) each")
|
|
357
605
|
console.print(f"[dim]{escape(shlex.join(argv))}[/]")
|
|
358
|
-
|
|
606
|
+
if env is None:
|
|
607
|
+
subprocess.call(argv)
|
|
608
|
+
else:
|
|
609
|
+
subprocess.call(argv, env=env)
|
|
359
610
|
trials += read_trials(jobs / dataset, dataset)
|
|
360
611
|
summary = summarize(trials, attempts)
|
|
612
|
+
seconds = time.monotonic() - began
|
|
613
|
+
version = next((trial.version for trial in trials if trial.version), "")
|
|
614
|
+
if agent != "lcode":
|
|
615
|
+
console.print(f"[bold]{agent}[/] {escape(version)} on {escape(ollama_model)}")
|
|
361
616
|
print_summary(console, summary)
|
|
617
|
+
console.print(f"Took {took(seconds)}.")
|
|
362
618
|
if any("fully subnetted" in trial.error for trial in trials):
|
|
363
619
|
console.print(
|
|
364
620
|
"Docker couldn't make a network for the tasks: all its address ranges overlap your routes (a VPN that "
|
|
@@ -369,12 +625,17 @@ def command(args, console) -> int:
|
|
|
369
625
|
"lcode": __version__,
|
|
370
626
|
"harbor": HARBOR,
|
|
371
627
|
"slice": args.harbor,
|
|
628
|
+
"agent": agent,
|
|
629
|
+
"agent_version": version, # in the tasks' containers
|
|
372
630
|
"model": model,
|
|
631
|
+
"ollama_model": ollama_model or None, # the other agents': the model with the context set
|
|
373
632
|
"context": context,
|
|
374
633
|
"attempts": attempts,
|
|
375
634
|
"docker_bridge": bool(args.docker_bridge),
|
|
376
635
|
"machine": detect().describe(),
|
|
377
636
|
"date": dt.datetime.now().astimezone().isoformat(timespec="seconds"),
|
|
637
|
+
"started": started.isoformat(timespec="seconds"),
|
|
638
|
+
"seconds": round(seconds), # the whole run, every task's attempts
|
|
378
639
|
"command": "lcode " + shlex.join(sys.argv[1:]),
|
|
379
640
|
"tasks": picked,
|
|
380
641
|
"summary": {
|
lcode/ollama.py
CHANGED
|
@@ -125,6 +125,13 @@ class Ollama:
|
|
|
125
125
|
except requests.RequestException as e:
|
|
126
126
|
raise OllamaError(f"pull failed: {e}") from e
|
|
127
127
|
|
|
128
|
+
def create_variant(self, name: str, base: str, parameters: dict) -> None:
|
|
129
|
+
"""Create `name`: `base` with other parameters (a context window, say). It uses `base`'s files: nothing is
|
|
130
|
+
downloaded or copied."""
|
|
131
|
+
payload = {"model": name, "from": base, "parameters": parameters, "stream": False}
|
|
132
|
+
if self._post("/api/create", payload, timeout=600).get("status") != "success":
|
|
133
|
+
raise OllamaError(f"creating {name} failed")
|
|
134
|
+
|
|
128
135
|
def create_text_only(self, name: str, base: str) -> bool:
|
|
129
136
|
"""Create `name` from `base` without its vision projector. Returns False if `base` has none.
|
|
130
137
|
|
lcode/traces.py
CHANGED
|
@@ -6,11 +6,13 @@ in ~/.local/state/lcode/traces/<session id>-<request number>.jsonl. The lines, b
|
|
|
6
6
|
- start: the request as typed, the model and its settings, lcode's version, the folder;
|
|
7
7
|
- env: the git commit and the model's own sampling settings, looked up in the background;
|
|
8
8
|
- message: what lcode or the user added to the conversation for the model (the request, lcode's notes);
|
|
9
|
-
- model: one model call: its answer (text, thinking, tool calls), time to the first token, time and tokens
|
|
9
|
+
- model: one model call: its answer (text, thinking, tool calls), time to the first token, time and tokens. The
|
|
10
|
+
server counts a reply's tokens only when it ends, so a reply lcode stopped has 0 there and an estimate in
|
|
11
|
+
estimated_in and estimated_out (a token is about three characters);
|
|
10
12
|
- tool: one tool call: its arguments, the result the model got, how long it took;
|
|
11
13
|
- check: the project's checks, when lcode ran them; escalate: a stronger model's advice;
|
|
12
14
|
- compacted: the conversation was summarized; full: the trace reached its size limit;
|
|
13
|
-
- end: how the request ended, and its totals.
|
|
15
|
+
- end: how the request ended, and its totals (estimated_in and estimated_out: the stopped replies' estimates).
|
|
14
16
|
|
|
15
17
|
Events carry a "lane": the main agent's is "main", a subagent's "agent 1", "agent 2"…
|
|
16
18
|
|
|
@@ -88,6 +90,25 @@ def cut(text: str, limit: int = MAX_TEXT) -> str:
|
|
|
88
90
|
return f"{text[:head]}\n[… {len(text) - limit} characters left out of the trace …]\n{tail}"
|
|
89
91
|
|
|
90
92
|
|
|
93
|
+
def estimate(payload: dict, reply: dict) -> tuple[int, int]:
|
|
94
|
+
"""About how many tokens a model call took, in and out, for a reply the server never counted: a token is about
|
|
95
|
+
three characters, as lcode.sessions.estimate_tokens counts. For qwen3.6, Ollama counted 2.7 to 3.4 characters
|
|
96
|
+
a token in replies and 3.2 in tool results (the JSON), and about 3.9 in lcode's system prompt and tools. The
|
|
97
|
+
prompt is its messages' and tools' JSON, images left out."""
|
|
98
|
+
try:
|
|
99
|
+
messages = [
|
|
100
|
+
{k: v for k, v in m.items() if k != "images"} if isinstance(m, dict) else m
|
|
101
|
+
for m in payload.get("messages") or []
|
|
102
|
+
]
|
|
103
|
+
prompt = len(json.dumps(messages, default=str)) + len(json.dumps(payload.get("tools") or [], default=str))
|
|
104
|
+
calls = reply.get("tool_calls") or []
|
|
105
|
+
answer = len(str(reply.get("content") or "")) + len(str(reply.get("thinking") or ""))
|
|
106
|
+
answer += len(json.dumps(calls, default=str)) if calls else 0
|
|
107
|
+
return prompt // 3, answer // 3
|
|
108
|
+
except (TypeError, ValueError, RecursionError): # an estimate never costs the model event
|
|
109
|
+
return 0, 0
|
|
110
|
+
|
|
111
|
+
|
|
91
112
|
def nanos(value: Any) -> float | None:
|
|
92
113
|
return round(value / 1e9, 3) if isinstance(value, (int, float)) and value else None
|
|
93
114
|
|
|
@@ -115,6 +136,8 @@ class Recorder:
|
|
|
115
136
|
"tool_calls": 0,
|
|
116
137
|
"tokens_in": 0,
|
|
117
138
|
"tokens_out": 0,
|
|
139
|
+
"estimated_in": 0, # replies lcode stopped, which the server never counted
|
|
140
|
+
"estimated_out": 0,
|
|
118
141
|
"model_seconds": 0.0,
|
|
119
142
|
"tool_seconds": 0.0,
|
|
120
143
|
}
|
|
@@ -261,6 +284,9 @@ class Lane:
|
|
|
261
284
|
event["error"] = error[:4000]
|
|
262
285
|
elif not finished:
|
|
263
286
|
event["stopped"] = True # lcode closed the stream: it went round in circles, or was interrupted
|
|
287
|
+
if not final and first is not None: # the server counts a reply only at its end: about what this took
|
|
288
|
+
event["estimated_in"], event["estimated_out"] = estimate(payload, reply)
|
|
289
|
+
self.recorder.add(estimated_in=event["estimated_in"], estimated_out=event["estimated_out"])
|
|
264
290
|
self.recorder.add(model_calls=1, tokens_in=tokens_in, tokens_out=tokens_out, model_seconds=seconds)
|
|
265
291
|
self.recorder.write(event)
|
|
266
292
|
|
|
@@ -376,6 +402,16 @@ class Recording:
|
|
|
376
402
|
self.lane.model("chat", payload, began, None, answer, reply or {}, error)
|
|
377
403
|
|
|
378
404
|
|
|
405
|
+
def stopped_estimate(end: dict) -> str:
|
|
406
|
+
"""The end line's note on replies lcode stopped, which the server never counted."""
|
|
407
|
+
if not (end.get("estimated_in") or end.get("estimated_out")):
|
|
408
|
+
return ""
|
|
409
|
+
return (
|
|
410
|
+
f" (and about {format_tokens(end.get('estimated_in') or 0)} in, "
|
|
411
|
+
f"{format_tokens(end.get('estimated_out') or 0)} out in stopped replies)"
|
|
412
|
+
)
|
|
413
|
+
|
|
414
|
+
|
|
379
415
|
def next_number(folder: Path, session_id: str) -> int:
|
|
380
416
|
numbers = [0]
|
|
381
417
|
for f in folder.glob(f"{session_id}-*.jsonl"):
|
|
@@ -794,6 +830,11 @@ def show(info: Info, console: Console, verbose: bool = False) -> None:
|
|
|
794
830
|
else:
|
|
795
831
|
head = f"model ({e.get('purpose') or e.get('inside') or e.get('kind')})"
|
|
796
832
|
numbers = f"{format_tokens(e.get('tokens_in') or 0)} in · {format_tokens(e.get('tokens_out') or 0)} out"
|
|
833
|
+
if "estimated_out" in e: # stopped before the server counted it
|
|
834
|
+
numbers = (
|
|
835
|
+
f"about {format_tokens(e.get('estimated_in') or 0)} in · "
|
|
836
|
+
f"{format_tokens(e.get('estimated_out') or 0)} out"
|
|
837
|
+
)
|
|
797
838
|
if e.get("first_token") is not None:
|
|
798
839
|
numbers += f" · first token {duration(e['first_token'])}"
|
|
799
840
|
if (e.get("load_seconds") or 0) >= 1: # what the wait was: loading the model, reading the prompt
|
|
@@ -840,7 +881,8 @@ def show(info: Info, console: Console, verbose: bool = False) -> None:
|
|
|
840
881
|
console.print()
|
|
841
882
|
line = (
|
|
842
883
|
f"{escape(info.status)} · {end.get('model_calls', 0)} model call(s) · "
|
|
843
|
-
f"{format_tokens(end.get('tokens_in') or 0)} tokens in, {format_tokens(end.get('tokens_out') or 0)} out
|
|
884
|
+
f"{format_tokens(end.get('tokens_in') or 0)} tokens in, {format_tokens(end.get('tokens_out') or 0)} out"
|
|
885
|
+
f"{stopped_estimate(end)} · "
|
|
844
886
|
f"model {duration(end.get('model_seconds'))} · tools {duration(end.get('tool_seconds'))} "
|
|
845
887
|
f"({end.get('tool_calls', 0)} calls) · recording {end.get('trace_seconds', 0) * 1000:.0f} ms"
|
|
846
888
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: lcode-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.56.0
|
|
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/
|
|
@@ -182,6 +182,7 @@ lcode
|
|
|
182
182
|
| `lcode models` / `lcode doctor` | what fits this machine / check the installation |
|
|
183
183
|
| `lcode bench qwen3.6-35b qwen3.5-9b` | compare models on small coding tasks on this machine |
|
|
184
184
|
| `lcode bench --harbor dev` | run lcode on a slice of Terminal-Bench 2.0 and SWE-bench Verified, with Harbor |
|
|
185
|
+
| `lcode bench --harbor dev --agent codex` | the same with Claude Code, OpenCode or Codex on your model, to compare |
|
|
185
186
|
| `lcode trace` / `lcode trace show 1` | past requests, step by step with times and tokens; export or replay one |
|
|
186
187
|
| `/undo`, `/rewind` | take back the last request's file changes, or go back further |
|
|
187
188
|
| `lcode mcp catalog` / `lcode mcp add github` | ready-made MCP servers / add one |
|
|
@@ -14,15 +14,15 @@ lcode/docs/mcp.md,sha256=Ol3ScuP4i2KsoN9xaSEbnm86Tvoc1qnUV7zkRprWwHo,15168
|
|
|
14
14
|
lcode/docs/memory.md,sha256=XbsNnTwRdnUEYW7_2U1GHbtK0uOjTxR-s2EujgJbR0Y,6889
|
|
15
15
|
lcode/docs/models.md,sha256=d9wLOVBlMtnd8_2jQG9f0-qcEbGT6qtnwOdQSco-RD8,17121
|
|
16
16
|
lcode/docs/modes.md,sha256=vNQv5K-lk6egNQNlnOHk8YeIdoAsmyaWvSu-RbQeZnQ,34039
|
|
17
|
-
lcode/docs/public-benchmarks.md,sha256=
|
|
18
|
-
lcode/docs/quickstart.md,sha256=
|
|
17
|
+
lcode/docs/public-benchmarks.md,sha256=n6ef_v_sBIRfS8oJj9TFL0mvOA0SRRA-MPBN_YGPho4,8267
|
|
18
|
+
lcode/docs/quickstart.md,sha256=fZlRieXhoSB4sAs29XPonqihiFzoTUPe13lQxg8QBlU,3403
|
|
19
19
|
lcode/docs/sandbox.md,sha256=-_jc2I0LXKQIYCz_JOuHGaP2ehVuEqEepKqMATlFpZY,4064
|
|
20
20
|
lcode/docs/search.md,sha256=UKYrYG_xo67-bOLU1hLgiiTh3Dy6s9LG4nuc2JTQHa8,4249
|
|
21
21
|
lcode/docs/servers.md,sha256=0ddumHseQXx0CP0nqzgwV-493s81kdEBa6qtUYe9t6k,5718
|
|
22
|
-
lcode/docs/traces.md,sha256=
|
|
22
|
+
lcode/docs/traces.md,sha256=yY3ZT9twJeGqE-Yyo9Raynz3YqKS4uNoShBq8SPsYGI,10036
|
|
23
23
|
lcode/docs/troubleshooting.md,sha256=YcwmrpR6jcxnhDqV1-E7VQKeczfEC3xuokVkejkAoLo,6292
|
|
24
|
-
lcode/docs/usage.md,sha256=
|
|
25
|
-
lcode/__init__.py,sha256=
|
|
24
|
+
lcode/docs/usage.md,sha256=6l48yg2qX9j9oD_AkFn9jjRCg8q4Mc8uBuqy_Mlj43U,48133
|
|
25
|
+
lcode/__init__.py,sha256=rWKAMVTU480j3xZg74rG6FuQpSrWjQyUmVOzUax3W4I,473
|
|
26
26
|
lcode/__main__.py,sha256=s5N5pryX2FAu93GGZ3FxUrIXHWGzxz66lKUoaV_h8Ws,35
|
|
27
27
|
lcode/acp.py,sha256=eFNYdJNJd9tdCbF2UIj1N3UU4RnF2-pcMLA0KBYZbwE,29082
|
|
28
28
|
lcode/action.py,sha256=wuT5F9EJCdEligPeytzmEi8FpahWBhXer528tpuTj_k,16711
|
|
@@ -36,7 +36,7 @@ lcode/bench_runtime.py,sha256=EjzNgIvUkdbT8cbSy1TpmlyeIk6e-ipjlDFpM7Dnqx0,6835
|
|
|
36
36
|
lcode/catalog.py,sha256=pZ1azX9OH2r4JE2c6E5OfwywpgS39-W2oXzoCHJhmtM,4141
|
|
37
37
|
lcode/checkpoints.py,sha256=eqPtmPe44-aweWqc2H21ROogwzIt3NpvcUobsaCHoGY,18354
|
|
38
38
|
lcode/checks.py,sha256=haYYIPhadKavGYEhh8YWAaWrPMcfzrpT2i6638f4xjQ,12933
|
|
39
|
-
lcode/cli.py,sha256=
|
|
39
|
+
lcode/cli.py,sha256=AVZyuOYs4dR9zgUj1SX1FjekKfoOaeo8WRbUlRAmSaY,54561
|
|
40
40
|
lcode/clipboard.py,sha256=nTSdJyCXPdtjH947RjvB3QvRqnL5HZsS9KB8EkC42cc,5138
|
|
41
41
|
lcode/cloud.py,sha256=q5Dl5GuqWvKzBCIso-eh6yomvEOsnQ0LW8ZgaAGwBxc,2131
|
|
42
42
|
lcode/codesearch.py,sha256=Io8leN1nb_Y-Dvlm9xaGtwUWYXX-ooswuznJV6dGU1s,10766
|
|
@@ -49,8 +49,8 @@ lcode/extensions.py,sha256=W0HFDl0BvROzr7i_qtabHdIbacBgP5o5qIJLzoM2oNE,16806
|
|
|
49
49
|
lcode/film.py,sha256=nfffI6oMWeherp8AOU_yM7-Cok0JKoQMVeuVtVHKXo0,14455
|
|
50
50
|
lcode/frontmatter.py,sha256=Bx0n4vLPhp7ZCWx-g7xqzqNy5VoKBxyeeikh5UFB_gA,2441
|
|
51
51
|
lcode/gitflow.py,sha256=6j_nnCBZXkX1qhTI7K4CyZ5D0NAZLpH96weFEo64AkQ,27913
|
|
52
|
-
lcode/harbor.py,sha256=
|
|
53
|
-
lcode/harbor_bench.py,sha256=
|
|
52
|
+
lcode/harbor.py,sha256=DwD40Ga5z0GP6Tu3ixXttJb7j4LIhC4vAN5VfGMcLQ0,3314
|
|
53
|
+
lcode/harbor_bench.py,sha256=wWBszA758n14LMzbEOiJ0eb_tIi6fgRFykIv6Fzy3oE,30829
|
|
54
54
|
lcode/hardware.py,sha256=9j_gxSUYLAVtnSLIEL8FVU2q-jEEjHtMs2SVAax7yU8,5154
|
|
55
55
|
lcode/hooks.py,sha256=K0itOiAuH4rxndJ9gne_uCrqby6oWAzFPRrfB3tCq-E,9324
|
|
56
56
|
lcode/imageopts.py,sha256=qELIIdKUJT3GLv9mhnjr_TeYNhOXhTMW3tgHzpuqW-Q,9715
|
|
@@ -67,7 +67,7 @@ lcode/memory.py,sha256=uyGNn_yNdvn-ie1vnum25-VNieHyZip7lnzrcIzGNb0,24526
|
|
|
67
67
|
lcode/models.toml,sha256=lt2G64zzo_Ryxv2ISRSNZoVD_JqCqYqsM01n8WoXGs8,4098
|
|
68
68
|
lcode/modes.py,sha256=Ybn9Pe2JJjOCIsixZpg-AHvB1nUMckNEiDKGHBLFXjA,5190
|
|
69
69
|
lcode/notify.py,sha256=uieDeXe7XwuVHjOk4tqVyZEW_85XWkoWQmFOWEf77oc,1538
|
|
70
|
-
lcode/ollama.py,sha256=
|
|
70
|
+
lcode/ollama.py,sha256=2-tH2ef9Paz-6916UJJN1ltxHoebTuwv6DBVQ09sEpg,8515
|
|
71
71
|
lcode/permissions.py,sha256=q7CjDsc_Xrblw7t3_BbxA5LUjxFSswGs1RiJmtMi0po,12288
|
|
72
72
|
lcode/planning.py,sha256=a0rjnj57qwlxqremFgfDGCNgKO-fTKWj36Hj4fBmhbg,6562
|
|
73
73
|
lcode/preview.py,sha256=ATzEs6yaI1__bfo2_juWznrTDXUD4QTc_aQMPRCytgA,6253
|
|
@@ -86,7 +86,7 @@ lcode/sessions.py,sha256=EvopvWzoLeB_PTSKmWfZ9Rk_graFhYgoRXBgfyHgqg4,8913
|
|
|
86
86
|
lcode/steer.py,sha256=0vaqLxgRKgC0yGp8xoQfV1f9VEOzH3U4rCIb74eFnZ8,12127
|
|
87
87
|
lcode/subagents.py,sha256=_zFLuDAOHlzpLvl-V7W1wBq66MKifLtKByge9b7fLJk,29443
|
|
88
88
|
lcode/tools.py,sha256=XTdtcQe8Bg4GoanVSr8cbgkiFwQ-uqr_HyTT5MHVn9Q,69595
|
|
89
|
-
lcode/traces.py,sha256=
|
|
89
|
+
lcode/traces.py,sha256=v0B1RZCaarjg8TmiUnsKj-yzBPCi0v-k4EEPsLxHhik,47034
|
|
90
90
|
lcode/unreachable.py,sha256=TXrv41ljwX_amxdcf4CY6qGF2YkWetORvPUSvwceJXI,8685
|
|
91
91
|
lcode/update.py,sha256=HywxgKBiQLcFsAoK7lZeQ83kDD1Mgo50lV33tf2cbt0,29202
|
|
92
92
|
lcode/vision.py,sha256=w33QPmdGwP33wM4mvmAH4amFDZ1xzeXhEsSLJ-STSHY,4243
|
|
@@ -119,8 +119,8 @@ lcode/workflows/wan21-vace.json,sha256=vJsiRvLCXCjKIibOO0SGM3fT6bedAGxF8N2sN2vcP
|
|
|
119
119
|
lcode/workflows/wan22-fun-inp-5b.json,sha256=4HbKEezik8MHvxTMP6PjQUPQPfCeSu10U9FrC-DHKYw,3327
|
|
120
120
|
lcode/workflows/wan22-ti2v-5b.json,sha256=RcTehoC2pNizzlb7Ed3keJ56DiE7V5lhXmsvR2Y0smQ,3371
|
|
121
121
|
lcode/workflows/z-image-turbo-t2i.json,sha256=sHsL7xnnuULOuWGYlQrDl4jOTySdAmb2T82c_cChv0s,1585
|
|
122
|
-
lcode_cli-0.
|
|
123
|
-
lcode_cli-0.
|
|
124
|
-
lcode_cli-0.
|
|
125
|
-
lcode_cli-0.
|
|
126
|
-
lcode_cli-0.
|
|
122
|
+
lcode_cli-0.56.0.dist-info/METADATA,sha256=V0XC5ox-vmCxrWvbYcNtK7zowrJAvu-3iN_KJSvhO14,14260
|
|
123
|
+
lcode_cli-0.56.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
124
|
+
lcode_cli-0.56.0.dist-info/entry_points.txt,sha256=Hxsn_itbnbgft3U0FwxWdmEt0yoAV2LB-nJDnL9WT20,172
|
|
125
|
+
lcode_cli-0.56.0.dist-info/licenses/LICENSE,sha256=JWjmoL7nNIC1XUa-dZm2hwLUgjUQMFo6k8APb0idNzs,1074
|
|
126
|
+
lcode_cli-0.56.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|