Repository navigation
Send a block's long output to a file with out=file - #340
Merged
Merged
Conversation
A build log or test run swamped the document: its lines were all in the file, and every run's diff was the whole log. Step 4 and 5 of docs/spilled-output/design.md: - out=file[:path] writes stdout to <doc>.assets/<id>.log, or the path given, whether the block passed or failed, and only when the bytes changed. Output past docroot.MaxRead is cut at a line and the fence marked truncated. - The output fence becomes an include of the file. mdsh writes for=, exit=, exited, truncated, at= and <include file= on every run, and keeps the fence's window attributes (from, to, match, before, lines, until, number_on), checked at parse time like an include's. With none, the fence shows the first fold_output lines. - Copies are refilled the same way, each keeping its own window. - When the block ends, include blocks that name its file are read again, wherever they are, so one above the block shows this run. - history=N renames earlier logs as it does images and points their fences at them; naming an unnamed block renames its log and rewrites res://<old>. in its fences. - nosave writes no file and shows the window from memory; secret, tty and http blocks can't have out=file. The GUI's line count and link to the file, and Chroma-based symbol=, are later steps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W9mexoiqFA4n1PYQWSzMDS
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.
Requested by j · project thread
This is steps 4 and 5 of
docs/spilled-output/design.md, and it builds on #339 (include windows).What changes
out=file[:path]writes stdout to<doc>.assets/<id>.log, or to the path given, under the usual root rules. The file is written whether the block passed or failed, and only when its bytes changed. Output past 16 MB (docroot.MaxRead) is cut at a line boundary and the fence getstruncated.output {for=build exit=2 at=… <include file=res://build.log match="^FAIL" before=3 lines=20}.for=,exit=,exited,truncated,at=and<include file=on every run.from,to,match,before,lines,untilandnumber_on. They are checked at parse time, just as on an include block.fold_outputlines, or the whole file whenfold_output: 0.output {for=build}elsewhere) are refilled the same way, and each keeps its own window.out=fileblock ends, the session re-reads every include block that names its file, wherever it is in the document. An include above the block therefore shows this run's log.build.<time>.log, as images are, and their history fences point at the renamed file. Logs that write-back drops are tidied away.res://<old>.in its output fence and copies.secret,ttyandhttpblocks can't haveout=file(a parse error that names the attributes).nosavewrites no file at all; the window is shown from memory.One change from the design: the design said a
nosaveblock writes its log to a session temp directory. Nothing reads that file yet, so this PR doesn't write it. That can come with step 6's "open the log" link.Still to come in later PRs: the line count and link to the file in mdsh-gui's output bar, and
--html/--pdflinking the file (step 6); Chroma-basedsymbol=for other languages (step 7).Screenshot
mdsh-gui (
--serve) after Run all. The block's own fence shows the first 25 lines oftest.log. The copy under "The first failure" setsmatch="^--- FAIL" before=1 lines=4.Testing
go test ./...passes.run.TestSpill: the file is written, the default window, author windows kept on write-back, a copy's own window, an include above the block refilled,number_onin printing, an unchanged file not rewritten.TestSpillPathCapNoSave: an explicit path, a failing block, the 16 MB cap withtruncated,nosave.TestSpillParseandTestSpillHistory, for parse errors and log rotation.TestSpillNameBlocks, for auto-naming.cmd/mdsh-guivendor copy and the bundle are regenerated. There are no TypeScript changes.Generated by Claude Code