lcode-cli 0.50.0__py3-none-any.whl → 0.52.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 CHANGED
@@ -3,7 +3,7 @@
3
3
  From a program: `from lcode import Session` (see lcode.api).
4
4
  """
5
5
 
6
- __version__ = "0.50.0"
6
+ __version__ = "0.52.0"
7
7
 
8
8
  API = ("Session", "Result", "Options", "SetupError")
9
9
 
lcode/agent.py CHANGED
@@ -35,6 +35,7 @@ from lcode import (
35
35
  manual,
36
36
  notify,
37
37
  planning,
38
+ repoid,
38
39
  repomap,
39
40
  residency,
40
41
  review,
@@ -329,6 +330,7 @@ class Settings:
329
330
  sandbox_network: bool = False
330
331
  vision_model: str = "auto" # auto, off or an Ollama model that can see images
331
332
  memory: str = "off" # off, ask or auto: notes that carry over to later sessions (lcode.memory)
333
+ memory_check: bool = False # ask the model what's worth remembering when a conversation ends
332
334
  subagents: bool = False # the agent tool (lcode.subagents)
333
335
  trust_project: bool = False # use the repository's own commands, skills and agents (lcode.extensions)
334
336
  skills: str = "off" # all, lcode (only lcode's own skill folders) or off
@@ -431,6 +433,7 @@ class Agent:
431
433
  self.reply_trouble = "" # what went wrong with the last reply: "circles", "cut_off" or ""
432
434
  self.response = None # the streaming response, so another thread can abort it
433
435
  self.ctx_used = 0
436
+ self._repo: tuple[Path, repoid.Repo | None] | None = None # the workspace's repository, for saved sessions
434
437
  self.last_speed = 0.0
435
438
  self.usage = {"requests": 0, "prompt_tokens": 0, "prompt_ns": 0, "output_tokens": 0, "output_ns": 0}
436
439
  self.messages: list[dict] = []
@@ -701,8 +704,12 @@ class Agent:
701
704
  self.session_title = self.session_title or sessions.title_from(self.messages)
702
705
  f = self.session_file()
703
706
  f.parent.mkdir(parents=True, exist_ok=True)
707
+ repo = self.workspace_repo()
704
708
  data = {
705
709
  "cwd": str(self.workspace), # where `lcode -c` there finds it, wherever the shell moved
710
+ # /resume lists it under "this folder" in any checkout of the same repository, wherever it moves
711
+ **({"repo": repo.to_json()} if repo else {}),
712
+ "context": {"used": self.next_request_tokens(), "window": self.settings.context},
706
713
  "model": self.settings.model,
707
714
  "mode": self.settings.mode,
708
715
  "image_model": self.settings.image_model,
@@ -721,6 +728,12 @@ class Agent:
721
728
  partial.write_text(json.dumps(data))
722
729
  os.replace(partial, f)
723
730
 
731
+ def workspace_repo(self) -> repoid.Repo | None:
732
+ """The repository the workspace is in, looked up again when the workspace changes or gets its first commit."""
733
+ if self._repo is None or self._repo[0] != self.workspace or (self._repo[1] and not self._repo[1].first):
734
+ self._repo = (self.workspace, repoid.find(self.workspace))
735
+ return self._repo[1]
736
+
724
737
  def new_session(self) -> None:
725
738
  self.reset()
726
739
  self.skills_loaded.clear()
@@ -770,15 +783,18 @@ class Agent:
770
783
  self.tools.notes = [str(n) for n in data.get("notes") or []]
771
784
  self.tools.changed = dict.fromkeys(str(f) for f in data.get("changed") or [])
772
785
  self.reflected = len(self.messages) # checked for notes to remember when that session ended
773
- self.ctx_used = sum(len(json.dumps(m)) for m in self.messages) // 3
774
- self.counted_chars = None
786
+ saved = (data.get("context") or {}).get("used") if isinstance(data.get("context"), dict) else None
787
+ if isinstance(saved, int) and saved > 0: # what the model counted, plus what came after
788
+ self.ctx_used, self.counted_chars = saved, conversation_chars(self.messages)
789
+ else: # saved by a version before 0.52
790
+ self.ctx_used, self.counted_chars = sessions.estimate_tokens(self.messages), None
775
791
  return note
776
792
 
777
- def load_latest(self) -> bool:
778
- latest = sessions.list_sessions(self.workspace, limit=1)
779
- if latest:
780
- self.load(latest[0])
781
- return bool(latest)
793
+ def load_latest(self) -> str | None:
794
+ """Continue the latest conversation in this folder (or its repository). Returns a note about the working
795
+ directory ("" if it stayed), or None when there's nothing to continue."""
796
+ latest = sessions.latest(self.workspace)
797
+ return self.load(latest) if latest else None
782
798
 
783
799
  # -- model calls
784
800
  def options(self) -> dict:
lcode/api.py CHANGED
@@ -214,6 +214,7 @@ def open_agent(cwd: Path, options: Options, console: Console, hw: Hardware | Non
214
214
  sandbox_network=cfg["sandbox_network"],
215
215
  vision_model=cfg["vision_model"],
216
216
  memory=switch(options.memory, cfg["memory"], "ask"),
217
+ memory_check=cfg["memory_check"],
217
218
  subagents=cfg["subagents"],
218
219
  max_parallel_agents=cfg["max_parallel_agents"],
219
220
  trust_project=trust_project,
lcode/cli.py CHANGED
@@ -20,7 +20,7 @@ from rich.progress import BarColumn, DownloadColumn, Progress, TextColumn, TimeR
20
20
  from rich.prompt import Confirm
21
21
  from rich.table import Table
22
22
 
23
- from lcode import __version__, backends, catalog, config, limits, web
23
+ from lcode import __version__, backends, catalog, config, limits, sessions, web
24
24
  from lcode.agent import Settings
25
25
  from lcode.catalog import ModelSpec
26
26
  from lcode.cloud import is_cloud, signin_command
@@ -553,6 +553,7 @@ def cmd_doctor(args) -> None:
553
553
 
554
554
  project, user = Memory(Path.cwd()).counts()
555
555
  line("Memory", f"{cfg['memory']} · {project} note(s) for this repository, {user} for every repository", True)
556
+ line("Sessions", sessions_status(Path.cwd()), True)
556
557
  node = shutil.which("npx")
557
558
  line("Node.js", "found" if node else "not found (some MCP servers need npx)", True if node else None)
558
559
  sys.exit(0 if ok else 1)
@@ -775,6 +776,14 @@ def exit_on_hangup() -> None:
775
776
  signal.signal(sig, leave)
776
777
 
777
778
 
779
+ def sessions_status(cwd: Path) -> str:
780
+ """How many conversations are saved, and where: a terminal with another LCODE_HOME or XDG_STATE_HOME has
781
+ other ones."""
782
+ listing = sessions.grouped(cwd, everything=True)
783
+ saved = len(listing.here) + len(listing.elsewhere)
784
+ return f"{saved} saved, {len(listing.here)} for this folder · in {sessions.sessions_dir()}"
785
+
786
+
778
787
  def comfyui_status(cfg: dict) -> tuple[str, bool | None]:
779
788
  """lcode doctor's ComfyUI line: running or found, and whether the image model is there."""
780
789
  from lcode import comfy
lcode/config.py CHANGED
@@ -61,6 +61,11 @@ SETTINGS: dict[str, tuple[object, type, str]] = {
61
61
  "vision_model": ("auto", str, "model that looks at images: auto | off | an Ollama model with vision"),
62
62
  "mcp_tools": ("auto", str, "how MCP tools reach the model: auto | direct | search (on demand, saves context)"),
63
63
  "memory": ("ask", str, "notes that carry over to later sessions: off | ask (confirm each) | auto"),
64
+ "memory_check": (
65
+ False,
66
+ bool,
67
+ "when a conversation ends (quit, /clear, or before it's summarized), ask the model what's worth remembering",
68
+ ),
64
69
  "skills": ("all", str, "skills to offer the model: all (also other agents' folders) | lcode | off"),
65
70
  "repo_map": (True, bool, "give the model a ranked map of the repository's symbols"),
66
71
  "embed_model": ("auto", str, "embedding model for semantic code search (lcode index): auto | off | a model"),
@@ -42,6 +42,7 @@ lcode config path # print the file location
42
42
  | `vision_model` | `auto` | The model that [looks at images](usage.md#images): `auto`, `off` or an Ollama model that can see |
43
43
  | `mcp_tools` | `auto` | How [MCP](mcp.md#context) tool definitions reach the model: `auto`, `direct` or `search` (on demand) |
44
44
  | `memory` | `ask` | [Notes that carry over](memory.md) to later sessions: `ask` (confirm each), `auto` or `off` |
45
+ | `memory_check` | `false` | When a conversation ends, [ask the model what's worth remembering](memory.md#a-check-when-a-session-ends) (a model call before you can leave) |
45
46
  | `skills` | `all` | Which [skills](commands.md#skills) the model is offered: `all` (lcode's folders and the ones other agents share), `lcode` (only `.lcode/skills/` and `~/.config/lcode/skills/`) or `off` |
46
47
  | `repo_map` | `true` | Give the model a ranked [map of the repository](search.md) |
47
48
  | `embed_model` | `auto` | Embedding model for [semantic code search](search.md#semantic-code-search): `auto`, `off` or a model name |
@@ -93,20 +94,20 @@ Environment variables override the file, which is useful for one-off runs and CI
93
94
  | `LCODE_SANDBOX` | `sandbox` |
94
95
  | `LCODE_MEMORY` | `memory` |
95
96
  | `OLLAMA_API_KEY`, `BRAVE_API_KEY`, `TAVILY_API_KEY` | API key for that [search provider](usage.md#web-search) (never stored in the config file) |
96
- | `LCODE_HOME` | where sessions and prompt history are stored |
97
+ | `LCODE_HOME` | where sessions, notes and prompt history are stored, instead of `~/.local/state/lcode` |
97
98
 
98
99
  ## Files lcode creates
99
100
 
100
101
  | Path | Contents |
101
102
  |---|---|
102
103
  | `~/.config/lcode/config.toml` | Settings |
103
- | `~/.local/state/lcode/sessions/` | Saved conversations (for `lcode -c`) |
104
+ | `~/.local/state/lcode/sessions/` | Saved conversations (for `/resume` and `lcode -c`), one JSON file each |
104
105
  | `~/.local/state/lcode/history` | Prompt history (++up++ in the prompt) |
105
106
  | `~/.config/lcode/mcp.json` | [MCP servers](mcp.md) (readable only by you; may contain tokens) |
106
107
  | `~/.local/state/lcode/mcp-auth/` | Sign-in tokens for remote MCP servers (readable only by you) |
107
108
  | `~/.local/state/lcode/mcp-logs/` | Error output of local MCP servers |
108
109
  | `~/.local/state/lcode/checkpoints/` | Checkpoints for `/undo` (copies of your project's files; deleted after 14 days) |
109
- | `~/.local/state/lcode/memory/` | [Memory](memory.md) notes: `user/` for every repository, `projects/<repository>/` for each one |
110
+ | `~/.local/state/lcode/memory/` | [Memory](memory.md) notes: `user/` for every repository, `projects/<repository>/` for each one (`/memory path` shows this repository's) |
110
111
  | `~/.config/lcode/commands/`, `~/.config/lcode/skills/` | Your [commands and skills](commands.md) (a repository's go in `.lcode/`) |
111
112
  | `~/.local/state/lcode/extensions-approved.json` | Repositories whose commands, skills and agents you approved |
112
113
  | `~/.config/lcode/agents/` | Your [custom agents](agents.md#custom-agents) (a repository's go in `.lcode/agents/`) |
@@ -197,7 +197,8 @@ the Ollama server you configure, it only contacts the web when the model searche
197
197
  | `extensions.py` | Custom commands and skills, and approving a repository's own |
198
198
  | `frontmatter.py` | The `---` headers of notes, agents, commands and skills |
199
199
  | `planning.py` | Plan mode: what it allows, presenting a plan and approving it |
200
- | `memory.py` | Notes that carry over between sessions, and the end-of-session check |
200
+ | `memory.py` | Notes that carry over between sessions, and the optional end-of-session check |
201
+ | `sessions.py`, `repoid.py` | Saved conversations: listing them for this folder and elsewhere; which repository a folder is in, by its first commit |
201
202
  | `sandbox.py` | The optional container for shell commands |
202
203
  | `checkpoints.py` | Snapshots before the model changes files, for `/undo` and `/rewind` |
203
204
  | `catalog.py`, `models.toml` | Model catalog and memory estimates |
lcode/docs/memory.md CHANGED
@@ -49,29 +49,37 @@ instead ("staging credentials are in 1Password, vault Dev").
49
49
  `-g` saves it for every repository. Start with `feedback:`, `reference:` or `user:` to set the
50
50
  type (the default is `project`).
51
51
 
52
- - **At the end of a session**, because local models rarely save anything on their own, lcode
53
- asks the model one short question: is anything from this session worth remembering? It happens
54
- when you quit, on `/clear`, and before the conversation is compacted (the summary leaves details
55
- out). The model proposes at most three notes:
52
+ ## A check when a session ends
56
53
 
57
- ```text
58
- ╭─ Worth remembering? ────────────────────────────────────────────────────────╮
59
- │ 1 [feedback] Use pnpm, not npm (this repository) │
60
- │ 2 [project] Integration tests need `docker compose up db` first (this │
61
- │ repository) │
62
- ╰───────────────────────────────────────────────────────────────────────────────╯
63
- Save them? [y]es / numbers to keep, e.g. 1,3 / [n]o: 1
64
- ```
54
+ Local models rarely save notes on their own. With `memory_check` on, lcode asks the model one short
55
+ question when a conversation ends: is anything from it worth remembering? It happens when you
56
+ quit, on `/clear`, and before the conversation is summarized (the summary leaves details out). The
57
+ model proposes at most three notes:
58
+
59
+ ```text
60
+ ╭─ Worth remembering? ────────────────────────────────────────────────────────╮
61
+ │ 1 [feedback] Use pnpm, not npm (this repository) │
62
+ │ 2 [project] Integration tests need `docker compose up db` first (this │
63
+ │ repository) │
64
+ ╰───────────────────────────────────────────────────────────────────────────────╯
65
+ Save them? [y]es / numbers to keep, e.g. 1,3 / [n]o: 1
66
+ ```
65
67
 
66
- The question is quick: it reuses the conversation Ollama already has in memory, so the model
67
- only writes a few lines. Short sessions (one request and little work) are skipped, and Ctrl+C
68
- skips it too.
68
+ It's off by default, because it's a model call you wait for before you can leave. Turn it on with:
69
+
70
+ ```bash
71
+ lcode config set memory_check true
72
+ ```
73
+
74
+ The question reuses the conversation Ollama already has in memory, so the model only writes a few
75
+ lines. Short sessions (one request and little work) are skipped, and Ctrl+C skips it too. The
76
+ conversation itself is always saved, with or without the check.
69
77
 
70
78
  ## Asking first: the `memory` setting
71
79
 
72
80
  | `memory` | |
73
81
  |---|---|
74
- | `ask` (default) | Every note the model saves, and the end-of-session proposals, need your OK. Answer `a` once to allow the model's notes for the rest of the session. This holds in `yolo` mode too. |
82
+ | `ask` (default) | Every note the model saves, and the [end-of-session](#a-check-when-a-session-ends) proposals, need your OK. Answer `a` once to allow the model's notes for the rest of the session. This holds in `yolo` mode too. |
75
83
  | `auto` | Notes are saved without asking; lcode prints each one. |
76
84
  | `off` | No notes are loaded or saved, and the model has no `memory` tool. |
77
85
 
@@ -116,6 +124,13 @@ The dev dependencies are in a uv dependency group, which plain pytest doesn't se
116
124
 
117
125
  Each folder also has a `MEMORY.md` listing its notes, for reading; lcode regenerates it, so edit
118
126
  the notes rather than that file. A folder that isn't in a git repository gets its own notes.
127
+ `/memory path` shows where this repository's are.
128
+
129
+ A repository's notes follow it when you move or rename it, or clone it again: its folder has a
130
+ `repo.json` naming the repository's first commit, which every clone shares. Notes saved before
131
+ lcode 0.52 get that file the first time lcode runs in their repository. Notes of a repository
132
+ that moved before then are in a folder named after its old name; copy them into the new one
133
+ (`/memory path`) to keep them.
119
134
 
120
135
  At the start of a session, the model gets a one-line index of the notes (description, name, date)
121
136
  in its instructions. The index is capped at about 2,000 tokens, or 5% of a small context window;
lcode/docs/modes.md CHANGED
@@ -153,7 +153,8 @@ video ❯ /play
153
153
  ```
154
154
 
155
155
  - **Options:** the image options work here too (`--n`, `--ar`, `--seed`, `--quality`, `--style`,
156
- `--no`, and `/options`), plus `--seconds` (1 to 8; 5 by default, at 24 frames per second).
156
+ `--no`, and `/options`), plus `--seconds` (1 to 60; 5 by default, at 24 frames per second;
157
+ longer than 8, it's [made in parts](#longer-clips)).
157
158
  Clips are 16:9, or 9:16 from an upright start picture (cropped to it), unless you give a shape:
158
159
  Wan 2.2 knows those two shapes best, and a square or small clip can break up into streaks.
159
160
  - **Quality:** `fast` makes 864×480 in 12 steps, `balanced` (the default) 864×480 in 20 steps, and
@@ -176,6 +177,8 @@ video ❯ /play
176
177
  `tilt-down`, `zoom-in`, `zoom-out`, `dolly-in`, `dolly-out`, `rotate-left`, `rotate-right`,
177
178
  `static`), from a description or a start picture. Wan 2.1 Fun Camera 1.3B makes these, at 832×480
178
179
  and 16 frames per second: a 3 s move takes about 2 minutes.
180
+ - **Longer clips:** up to 60 seconds, also from a start to an end picture
181
+ (`@start.png @end.png the flower opens --seconds 25`). See [Longer clips](#longer-clips).
179
182
  - **Extend a clip:** `/extend 4 --seconds 3 it flies away` continues clip #4 from its last frame
180
183
  and joins the new part after it, as one longer clip (`…-extended.mp4`; 3 s more in about a
181
184
  minute at `fast`).
@@ -198,6 +201,60 @@ video ❯ /play
198
201
  - **Long renders:** progress shows the step and the time left. With `notify` on, lcode sends a
199
202
  desktop notification when a clip that took longer than `notify_after` seconds is done.
200
203
 
204
+ ## Longer clips
205
+
206
+ A video model makes up to 8 seconds at once. For a longer clip (`--seconds` up to 60), lcode makes
207
+ it in parts and joins them into one:
208
+
209
+ ```text
210
+ video ❯ @start.png @middle.png @end.png the tulip bud slowly opens into a full flower, gentle breeze --seconds 25 --quality fast
211
+ ◆ A 25 s clip: lcode makes it in 4 parts of 6.25 s, each going on from the last frame of the one before, and joins them. Parts 2 and 4 each go to your next picture, in order.
212
+ part 1 of 4: 6.25 s, made in 137 s
213
+ part 2 of 4: 6.25 s, made in 141 s
214
+ part 3 of 4: 6.25 s, made in 138 s
215
+ part 4 of 4: 6.25 s, made in 143 s
216
+ ◆ #2 .lcode/media/20261026-201311-the-tulip-bud-slowly-opens-into-a-full-f.mp4 864×480 · Wan 2.2 TI2V 5B + Wan 2.2 Fun InP 5B · seed 1496941735 · 561.9 s
217
+ ```
218
+
219
+ ![Frames at 0, 6, 9.6, 14.6, 21.7 and 25.3 s of that clip](assets/long-clip-tulip.jpg)
220
+
221
+ *Frames at 0, 6, 9.6, 14.6, 21.7 and 25.3 s of that clip, through a bud, a half-open and an open
222
+ tulip: the change comes in steps, with some drift (the light flare at 9.6 s).*
223
+
224
+ - **The parts:**
225
+ - as few as it takes, about equally long;
226
+ - the first comes from your description, or starts from your start picture;
227
+ - each next one starts on the last frame of the one before;
228
+ - with an end picture, the last part goes from there to your end picture (Wan 2.2 Fun InP), so
229
+ the clip ends exactly on it.
230
+ - **Where the change happens:** the change toward a picture happens in the part that ends on it.
231
+ With only a start and an end picture, the clip goes on from the start for most of its length
232
+ and reaches the end picture in its last part. On a tulip opening over 25 s, it stayed closed for
233
+ about 20 s and then opened within 2. Making the whole change once as a guide clip doesn't help:
234
+ Wan 2.2 Fun InP opens the tulip within its first frames, at `fast` and at `balanced`.
235
+ - **Pictures along the way:** for a change in steps, give more pictures, in order:
236
+ `@bud.png @half-open.png @open.png the tulip opens --seconds 25`. The clip gets an equal share
237
+ for each picture after the first, and the part that ends each share goes to that picture. Three
238
+ or more pictures work in a short clip too, one part to each.
239
+ - **One clip:** ffmpeg joins the parts, leaving out the frame each join would show twice, at the
240
+ first part's pace and size. It's numbered in the gallery like any clip. Its JSON lists the parts,
241
+ which stay in a `…-parts` folder next to it.
242
+ - **Extending:** `/extend 4 --seconds 20 it flies away` adds 20 s to clip #4 the same way.
243
+ - **Follow-ups work as for any clip:** `/again`, `/vary` and `/play`, and `/upscale`, `/smooth`
244
+ and `/sound` on the result.
245
+ - **Esc** stops it. The parts made so far are joined into a `…-partial.mp4` clip in the gallery.
246
+ - **Needs** ffmpeg (`apt install ffmpeg`, `brew install ffmpeg`).
247
+ - **Before it starts,** lcode says how many parts it makes. After a clip in the same session, it
248
+ also says about how long it takes, at that clip's pace.
249
+ - **What to expect:** each part follows the same description, so a long clip has the same action
250
+ throughout, slowly drifting; for a story with scenes, make a [film](#films). Grok Imagine makes
251
+ up to 15 s at once: a longer clip is made on your GPU.
252
+
253
+ - **Measured** on the RTX 4080 Laptop GPU (12 GB), a 25 s clip from a start to an end picture
254
+ (4 parts of 6.25 s, 864×480, 609 frames at 24 fps): 9.4 minutes at `fast` (about 140 s a part)
255
+ and 14.2 minutes at `balanced` (about 210 s a part). Through three pictures at `fast`: 9.4
256
+ minutes. The joins don't show: the frames on either side of each one match.
257
+
201
258
  ## Films
202
259
 
203
260
  From one idea, lcode makes a short film with the same characters in every shot:
lcode/docs/quickstart.md CHANGED
@@ -12,7 +12,7 @@ lcode
12
12
 
13
13
  ```text
14
14
  ╭──────────────────────────────────────────────╮
15
- │ lcode v0.50.0 — local coding agent │
15
+ │ lcode v0.52.0 — local coding agent │
16
16
  │ │
17
17
  │ model lcode-qwen3.6-35b │
18
18
  │ context 256K tokens │
lcode/docs/usage.md CHANGED
@@ -131,8 +131,8 @@ image ❯ /upscale 3 4
131
131
  (the [prompt assistant](modes.md#the-prompt-assistant)'s: `qwen3.5:4b` or the model you chose), loaded only for the
132
132
  answer so the GPU stays with ComfyUI. Without one, lcode shows the parts of the manual that match.
133
133
  - **Checked by lcode itself:** every command and option in an answer must exist in lcode, and the
134
- lines to type go through lcode's own option parser: `--seconds 25` is caught ("seconds is how long
135
- a video is: 1 to 8"). An answer that fails a check is asked for again once; what still fails is
134
+ lines to type go through lcode's own option parser: `--seconds 90` is caught ("seconds is how long
135
+ a video is: 1 to 60"). An answer that fails a check is asked for again once; what still fails is
136
136
  marked with ⚠, and isn't typed in for you.
137
137
 
138
138
  **Measured** on an RTX 4080 Laptop GPU (12 GB): 15 everyday questions (a 25-second clip between two
@@ -146,7 +146,7 @@ the context window…), each answer scored by hand:
146
146
  | `qwen3.6-35b` (code mode) | 12 | 2 | 1 (marked ⚠) | 6 to 7 s, once loaded |
147
147
 
148
148
  The checks caught every command that doesn't exist (`/image`, `/grok-video`, `/lcode`); before them,
149
- the small models answered `--seconds 25` and `/image …` without a warning. What's left: an extra
149
+ the small models answered `/image …` without a warning. What's left: an extra
150
150
  or out-of-order step now and then, and an odd claim in the sentences after the commands.
151
151
 
152
152
  ## What the model can do
@@ -712,40 +712,59 @@ Instructions that are only needed for some tasks fit better in a [command or ski
712
712
  which costs no context until it's used.
713
713
 
714
714
  What doesn't belong in `AGENTS.md` but should carry over, such as your corrections and preferences,
715
- goes into lcode's [memory](memory.md): short notes the model, you (`/remember`) or a short check at
716
- the end of a session save, and that every later session in the repository loads.
715
+ goes into lcode's [memory](memory.md): short notes the model or you (`/remember`) save, and that
716
+ every later session in the repository loads.
717
717
 
718
718
  ## Sessions
719
719
 
720
720
  Every conversation is saved after each request to `~/.local/state/lcode/sessions/`, so you can
721
- leave and pick up where you stopped.
721
+ leave and pick up where you stopped. Upgrading lcode keeps them, and the installed lcode and a
722
+ development checkout (`uv run lcode`) share them.
722
723
 
723
724
  ```text
724
725
  ❯ /rename auth refactor # name the current session
725
- ❯ /resume # list this folder's sessions and pick one
726
+ ❯ /resume # list the saved sessions and pick one
726
727
  ```
727
728
 
728
729
  ```text
729
- Saved sessions · /home/you/code/my-project
730
- # Session Last used Requests
731
- 1 auth refactor 2 h ago 14
730
+ This folder · ~/code/my-project
731
+ # Session Last used Requests Context
732
+ 1 auth refactor 2 h ago 14 41.3K / 128K (32%)
732
733
  Explain how login tokens are validated
733
- 2 The tests in tests/test_parser.py fail… yesterday 6
734
+ 2 The tests in tests/test_parser.py fail… yesterday 6 ~18K / 128K (14%)
735
+ in tests
736
+ Elsewhere
737
+ # Session Last used Requests Context Folder
738
+ 3 Set up the release script Oct 20 3 9.6K / 128K (8%) ~/code/tools
734
739
  Resume which session? (number or name, Enter to cancel): 1
735
740
  ```
736
741
 
742
+ - **This folder** lists the sessions saved in this folder, and anywhere else in its git
743
+ repository: a subfolder, a worktree, or another clone of the same repository (it has the same
744
+ first commit). A row from another folder says where it was.
745
+ - **Elsewhere** lists the 20 newest sessions from other folders. Sessions from temporary folders
746
+ that no longer exist, such as scripted test runs, are left out. `/resume all` lists everything.
747
+ - **Context** is what the conversation takes of the current context window. A `~` means it's an
748
+ estimate, for sessions saved before lcode 0.52. After resuming, the status bar shows it right
749
+ away, and a yellow number means lcode summarizes the conversation before your next request.
750
+
737
751
  Unnamed sessions are listed by their first request. After resuming, lcode shows your last request
738
752
  and the start of its last answer so you know where you left off.
739
753
 
740
754
  | From the shell | From a session | Resumes |
741
755
  |---|---|---|
742
- | `lcode -c` | | the most recently used session in this folder |
756
+ | `lcode -c` | | the latest session in this folder, else the latest under "This folder" |
743
757
  | `lcode --resume` | `/resume` | one you pick from a list |
744
758
  | `lcode --resume "auth refactor"` | `/resume auth refactor` | a session by name, list number, id or a unique part of its title |
745
- | | `/resume all` | a session from any folder (lcode switches to that folder) |
759
+ | `lcode --resume all` | `/resume all` | one you pick from every saved session |
760
+
761
+ A session from another folder takes lcode to that folder. `/clear` starts a new conversation and
762
+ keeps the old one saved. Files may have changed since a session was saved, so after resuming the
763
+ model has to read a file again before editing it.
746
764
 
747
- `/clear` starts a new conversation and keeps the old one saved. Files may have changed since a
748
- session was saved, so after resuming the model has to read a file again before editing it.
765
+ **Where are my sessions?** `lcode doctor` shows how many are saved and the folder they're in.
766
+ `LCODE_HOME`, or `XDG_STATE_HOME`, moves that folder: a terminal that sets one of them (some IDEs
767
+ and test scripts do) sees other sessions. `lcode bench` doesn't save its runs as sessions.
749
768
 
750
769
  ## Scripting
751
770
 
lcode/imageopts.py CHANGED
@@ -13,7 +13,8 @@ from dataclasses import asdict, dataclass, replace
13
13
 
14
14
  QUALITIES = ("fast", "balanced", "best")
15
15
  MAX_COUNT = 8
16
- MAX_SECONDS = 8 # video: longer clips need more memory than a laptop GPU has, and models drift
16
+ MAX_SECONDS = 60 # video: a clip longer than a part is made in parts and joined (lcode.media.long_clip)
17
+ PART_SECONDS = 8 # what a video model makes at once: longer needs more memory than a laptop GPU has, and models drift
17
18
  SIZES = { # names for aspect ratios
18
19
  "square": "1:1",
19
20
  "portrait": "3:4",
lcode/manual.py CHANGED
@@ -392,7 +392,7 @@ def is_question(text: str) -> bool:
392
392
  # What a model needs to know to read the manual right: how requests work in each mode (tests check that every
393
393
  # command and option here exists).
394
394
  BASICS = """- Image mode (/mode image): what the user types at the prompt is a description, and lcode makes pictures from it. There is no command for that (no /image, /imagine or /generate). Options go after the description, for example: a red fox in the snow --n 4 --ar 16:9 (--n: 1 to 8 pictures; --ar: the shape; also --seed, --quality fast|balanced|best, --style, --no). @photo.png in a request uses the user's picture, to edit or as a reference. Results are numbered in the session's gallery (#1, #2…), and follow-ups take the number: /upscale 3, /nobg 3, /edit 3 make the sky purple, /vary 3, /use 3, /animate 3. Files go to .lcode/media/ in the project.
395
- - Video mode (/mode video): what the user types is a description of a clip, and lcode makes it. There is no /video command. A clip is 1 to 8 seconds (--seconds). @start.png in the request starts the clip from that picture; @start.png @end.png goes from the first picture to the second. Other options: --camera zoom-in (and other moves), --quality, --n, --ar, --seed, --style, --no. Follow-ups take the clip's number: /extend 4 --seconds 3 (continues it), /sound 4, /smooth 4, /upscale 4, /play 4. /film makes a short film of several shots, with the same characters, from one idea.
395
+ - Video mode (/mode video): what the user types is a description of a clip, and lcode makes it. There is no /video command. A clip is 1 to 60 seconds (--seconds): longer than 8, lcode makes it in parts and joins them into one clip. @start.png in the request starts the clip from that picture; @start.png @end.png goes from the first picture to the second, also in a long clip (it ends on the second picture). Other options: --camera zoom-in (and other moves), --quality, --n, --ar, --seed, --style, --no. Follow-ups take the clip's number: /extend 4 --seconds 3 (continues it; up to 60 s), /sound 4, /smooth 4, /upscale 4, /play 4. /film makes a short film of several shots, with the same characters, from one idea.
396
396
  - Code mode (/mode code, the default): the user asks a coding agent to work on their project. Slash commands control lcode itself (/model, /context, /resume, /undo…), and lcode config set NAME VALUE, in a shell, changes a setting for good."""
397
397
  GUIDE = """You are the built-in help of lcode, a terminal program with three modes: code (a coding agent), image and video (they make pictures and clips on the user's GPU). The user is in {mode} mode now. Answer their question about lcode from what's below, and from nothing else.
398
398
 
@@ -425,7 +425,7 @@ EXTEND_PADS = {"left", "right", "top", "bottom"}
425
425
  PICTURE = re.compile(r'(?<!\S)@(?:"[^"]+"|\S+)')
426
426
  NUMBER = re.compile(r"^#?\d+$")
427
427
  OUTPUT_MARKS = ("◆", "✎", "⚠", "⎿", "●", "▀", "╭", "│", "╰", "…")
428
- PROMPT_MARK = re.compile(r"^\s*(?:(?:\w+\s*)?❯\s*|(?:code|image|video)\s+(?=/))") # a prompt shown before the line
428
+ PROMPT_MARK = re.compile(r"^\s*(?:(?:\w+\s*)?❯\s*|(?:code|image|video)\s+(?=[/@]))") # a prompt shown before the line
429
429
  NO_SLASH = re.compile(
430
430
  r"^(mode (code|image|video)|models?\b|(upscale|nobg|vary|play|open|animate|extend|sound|smooth|edit|restyle) #?\d+)\b"
431
431
  ) # a command without its slash
@@ -471,7 +471,7 @@ def mode_problem(command: str, mode: str) -> str:
471
471
 
472
472
  def problems(text: str, mode: str, manual: Manual) -> list[str]:
473
473
  """What in an answer wouldn't work in lcode: commands or options it doesn't have (anywhere in the text), and lines
474
- to type that its own parsers reject (--seconds 25: "seconds is how long a video is: 1 to 8")."""
474
+ to type that its own parsers reject (--seconds 90: "seconds is how long a video is: 1 to 60")."""
475
475
  found = [f"lcode has no {name}" for name in manual.unknown(text)]
476
476
  current = mode
477
477
  for line in typed_lines(text):