throughline

Public

I started writing this as a tool that would compress a large session and import a reduced memory of that session into a new session. There are now tools that do this quite well, so I likely wont be finishing it.

35 Downloads

README

throughLine

throughLine keeps a long problem in focus in LM Studio, across many turns, context compactions and chats. It keeps the state of a project (goal, constraints, plan, findings with sources, decisions and open questions) in a ledger on disk, outside the conversation, and shows the model a compact view of it on every message.

It is meant to stay enabled everywhere. A chat with no project gets nothing added to its messages and no extra tools.

This is version 2.1 at milestone M3 of the design in throughLine-design-v2.md, with every planned feature in place. M4 is the evaluation.

How it works

  • A ledger per project. Each project lives in %USERPROFILE%\.lmstudio\throughline\projects\<name>\. ledger.json holds the state, ledger.md is a readable copy you can also edit, events.jsonl logs every change, and versions\ keeps the 50 most recent earlier states.
  • Projects start on their own. When two turns in a row each use three or more tools for real work (memory and clock lookups do not count), throughLine starts a project in that chat. Its goal is your requests from those two turns, word for word. A status line says so, and /tl off stops it; if the project is still empty, it is removed. /tl start starts one by hand.
  • Chats are bound to projects. A project is tied to the chat where it started and to any chat that opens it later. Each chat tracks at most one project.
  • What the model sees. In a project chat, each of your messages carries a short header with the goal, the current step and what changed since the last message, about 100 tokens. When the last full view of the project has scrolled out of the part of the context that context-compressor keeps word for word, the full state appears instead, capped at 600 tokens. In chats with an attached document, the state is shown once and then left out of your messages, because rag-v1 searches documents with the whole text of each message; the model can still read it with ledger_view.
  • Keeping the ledger current. After two turns that used tools without updating the ledger, the header reminds the model to record its work, at most once every three turns. A health line points out what throughLine can check mechanically: findings citing pages that were never read in the chat, findings without a source, no step or several steps in progress, questions left open for ten turns, and a step finished with nothing recorded during it. The state also tells the model to stay within the goal, and to give the result and stop once every step is done. If the model finishes a step and starts another in the same reply, or finishes the plan and adds more steps, the tool result asks whether the user's latest message asked for that; if not, the model is told to answer, name what could come next, and stop. This matters with context-compressor, which pauses long replies every few tool rounds and adds a note telling the model to continue; without the check, a model with a plan in view can read that as permission to work through the whole plan.
  • Sources are checked. A finding that cites a URL is checked against the pages the model actually read in the chat, including the address a page redirected to. It is marked verified when the page was read, and "not read" when it was not, until the page is read or the source corrected.
  • Your edits count. Edit ledger.md in any text editor, including ones that escape Markdown when saving, and the change is picked up on your next message (or first, if that message is a command), logged as yours, and shown to the model. Only what you changed is applied: if the model recorded something while you had the file open, its work is kept. The file's second line, an HTML comment with a version number, is how throughLine knows which version your copy started from; Markdown viewers hide it. If the file cannot be read back, your version is kept beside it as ledger.edit-not-applied-<time>.md and the ledger is left as it was.
  • Ask in your own words. A message that asks about your projects ("what's the status of my projects?") gets a list of them attached, in any chat.
  • Recall in long chats. context-compressor keeps a long chat going by summarizing older turns, which loses detail. Once a chat passes 24,000 tokens, throughLine keeps a searchable copy of its stored history and gives the model a recall tool that returns the original wording of earlier messages, with turn numbers, so an exact figure or quote can be found after it has been summarized away. This works in any chat, with or without a project, and adds nothing to your messages. Messages still in the model's view word for word are left out of results. Below the threshold nothing is copied.
  • Cleanup after deleted chats. When the plugin starts, it checks which chats still exist in LM Studio, by file name only. A deleted chat's state and recall copy are removed at once. A project whose every chat was deleted moves to the trash after 7 days unless it is opened again, and the trash is emptied after 30 days. If LM Studio's conversations folder cannot be read, nothing is removed.
  • What you see. A status line above each reply names the project and its progress, and says when a reminder went out or your edit was applied. It is shown to you only and costs no tokens. Your own message bubbles show only what you typed.

Commands

Type a command as the whole message.

CommandEffect
/tl start [goal]Start a project in this chat. Without a goal, your first message in the chat is used, word for word.
/tl open <name>Continue an existing project in this chat. The start of the name is enough if it is unique.
/tl listList projects with their progress.
/tl goal <text>Set or replace the goal. Without text, shows it.
/tl constraint <text>Add a rule for the project.
/tl statusShow the project's full state and where its ledger file is.
/tl undoUndo the last change to the ledger. Repeat to go further back, up to 50 changes.
/tl handoffWrite handoff.md in the project folder: goal, constraints and decisions; the plan, findings and open questions; and the last four exchanges of this chat.
/tl recall offStop recall in this chat and delete its searchable copy. /tl recall on resumes it.
/tl offStop tracking a project in this chat, and stop this chat from starting one on its own. The project is kept, unless it started automatically and is still empty.
/tl forget <name>Move a project to the trash. The full name is required.
/tl helpList the commands.

Only you can change the goal and constraints, and only you can undo. The model can propose changes but has no tool for them.

Tools the model gets

The four ledger tools appear only in a chat with a project, and recall only in a long chat:

ToolWhat it does
ledger_viewShows the whole ledger or one section.
ledger_planAdds steps, or changes a step's status, note or wording.
ledger_recordRecords a finding with its source, a decision with its reason, or an open question. Entries that read like personal facts about you are refused; those belong in memory.
ledger_resolveCloses an open question, optionally recording the answer as a finding.
recallIn long chats, with or without a project: searches the chat's earlier messages and returns their original wording with turn numbers.

Each tool returns a few lines: what changed, where the plan stands, and what to do next.

Settings

In the plugin's settings in LM Studio:

SettingDefaultMeaning
RecallOnKeep a searchable copy of long chats and offer the recall tool.
Recall starts at24,000 tokensChat length at which recall starts.
Start projects automaticallyOnStart a project after two research-heavy turns in a row.
Tool calls for a heavy turn3Tool calls after one message that make it count toward an automatic start.
Remind after turns2Turns that used tools without a ledger update before the reminder.
Full state cap600 tokensLargest size of the full project state.
Verbatim window6,000 tokensShould match context-compressor's "Recent context kept verbatim".
Status lineOnThe progress line above each reply.

Suggested system prompt lines

[PROJECTS]
When a message carries throughLine state, keep the project's ledger current: plan steps with ledger_plan, and record findings with their sources, decisions with their reasons, and blocking questions with ledger_record as you establish them. Keep one step marked doing, and mark it done when it is.
Facts about the user go to memory, never to the ledger, and project state never goes to memory.
If a /tl command reaches you as typed, throughLine is not enabled in this chat: say so in one sentence and do nothing else.

Plugins are switched on per chat in LM Studio. Switch throughLine on once; new chats keep the plugins that were on in the last one.

Privacy

Everything stays in .lmstudio\throughline\ on your machine. The plugin makes no network requests. Ledgers hold whatever the model records about a project. A recall copy is a second copy of a long chat's text; it is deleted as soon as the chat is, /tl recall off deletes it on request, and recall can be turned off entirely in the settings. Cleanup reads only the names of LM Studio's chat files, never their contents. In chats with an attached document, diagnostics.jsonl records one true or false value per message: whether rag-v1 had already processed the message when throughLine received it. Nothing else is written there.

Building

With Node 20 or newer, from this folder:

npm install
npm test

npm test builds .lmstudio/production.js and runs the tests. To install, copy manifest.json, package.json, install-state.json, .lmstudio\ and node_modules\ into %USERPROFILE%\.lmstudio\extensions\plugins\attitudejacket\throughline\ and restart LM Studio.

License

PolyForm Noncommercial 1.0.0: free for personal and other noncommercial use. Selling it or using it in a paid product or service needs permission from attitudejacket. See LICENSE.txt.