feat: Session-Ergonomie — Namen, -c, context, Kosten, Budget, fork - #50
Merged
Conversation
Six small things from #28 that are unremarkable alone and together are the difference between usable and pleasant. Names. A session takes its name from its first prompt (kebab-case, five words, no LLM call — naming a session is not worth a provider roundtrip), and the name is what you resume by. A derived name that would collide gets a counter, because a collision would make resume-by-name ambiguous; renaming onto a name another session holds is refused. Ambiguity is still handled — it reports the candidates rather than silently picking one. Sessions saved before names existed keep loading. Continue. `smith -c "and now the tests"` runs one more turn on the last session; bare `-c` resumes it interactively. For that to mean anything, headless runs are now saved too — otherwise -c after a headless run would pick up an unrelated older chat. Context. `smith context` (and /context) shows where the window goes. build_system_prompt now returns labelled parts, and both the prompt and the breakdown are built from them, so the report cannot drift from the thing it describes; counting uses the same estimator compaction uses. The compaction line is only shown for a live session — a session read back from disk has no such history, and guessing would be worse. Cost. A new pricing.cr converts tokens to dollars per provider/model, with cache writes and reads at their own rates. Only models whose published rates are known are in the table: an unknown one prices as n/a, never as a guess, since a wrong figure is worse than none. Ollama is always free. Every rate is overridable from config, because a table baked into a release cannot track vendor changes. Budget. --max-budget-usd stops the loop once the estimate reaches the ceiling and exits 2, distinct from 1 for a failed turn, so automation can tell "too expensive" from "broken". Checked after each turn rather than before, so the answer just paid for is still delivered. Without a price for the model there is nothing to enforce, and that is said on stderr rather than leaving a run to believe it is capped. Fork. `smith fork <session>` copies the transcript under a new id and records where it came from, for taking one start two ways. ChatCommands now carries an argument, so /rename has somewhere to put the name; a slash invocation *with* arguments still belongs to the skill catalog, so /deploy staging is unaffected. Closes #28. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #28. Auf deinen Wunsch alles in einem PR statt in vier.
A+B — Namen und
-cEine Session bekommt ihren Namen aus dem ersten Prompt (kebab-case, fünf Wörter, ohne LLM-Call — dafür ist ein Provider-Roundtrip zu teuer), und über den Namen wird fortgesetzt.
fix-the-tests-2) — sonst wäre Resume-by-Name mehrdeutig. Einrenameauf einen belegten Namen wird abgelehnt.name/parent_idbleiben ladbar.Eine Erweiterung über das Issue hinaus: Headless-Läufe werden jetzt ebenfalls als Session gespeichert. Ohne das würde
smith -c "und jetzt die Tests"nach einem Headless-Lauf eine unbeteiligte ältere Chat-Session fortsetzen — genau das Beispiel aus dem Issue hätte also nicht funktioniert.C —
smith contextbuild_system_promptliefert jetzt beschriftete Teile; Prompt und Aufschlüsselung werden aus denselben Teilen gebaut, gezählt mit demselben Schätzer, den die Compaction benutzt. Eine Anzeige, die von der Entscheidung abweicht, die sie beschreibt, wäre schlimmer als keine.Die Compaction-Zeile erscheint nur bei einer laufenden Session — eine von der Platte gelesene hat diese Historie nicht, und sie zu raten wäre schlechter als sie wegzulassen.
D — Kosten
Neue
src/smith/pricing.cr, getrennte Sätze für Input, Output, Cache-Write und Cache-Read.n/a, nie eine geratene Zahl. In der Tabelle stehen nur Modelle, deren Preise tatsächlich bekannt sind.$0.00.[pricing."provider/model"]— eine ins Release eingebackene Tabelle kann Preisänderungen nicht folgen.E —
--max-budget-usdBeendet den Lauf mit Exit-Code 2, abgegrenzt von
1für einen Fehler. Geprüft nach jedem Turn statt davor, damit die gerade bezahlte Antwort noch ankommt.Ohne Preisbasis gibt es nichts durchzusetzen, und das steht auf stderr, statt eine automatisierte Ausführung in falscher Sicherheit zu lassen.
F —
smith forkKopie unter neuer ID mit
parent_id; Original unberührt, Checkpoints bleiben bei der Session, die sie erzeugt hat.Nebenbei
ChatCommands.parseliefert jetzt eineInvocationmit Argument, damit/rename <name>eines transportieren kann. Ein Slash-Aufruf mit Argumenten gehört weiterhin dem Skill-Katalog —/deploy stagingändert sich nicht.Verifikation
claude-sonnet-5: Headless-Lauf →smith listzeigt den abgeleiteten Namen →smith -csetzt dieselbe Session fort (4 statt 2 Messages) →rename→resumeüber den Namen →fork→contexttailden Code liefert), Warnung ohne Preisbasis geprüft🤖 Generated with Claude Code