Each model visit now gets <run>/stages/<seq>-<stage>/ with input.md,
memory.md, output.md, private/ and a shared run-level public/. The model
reads the two input files, follows the stage's instructions verbatim and
returns complete markdown; only the # outcome section is parsed.
- add internal/turn layout, render and output parsing
- write input.md/memory.md before a visit and output.md from the final
message; inventory all turn files as stage artifacts
- accumulate completed turns and system-written public file additions in
memory, including across retries and resume
- remove the JSON envelope, strict field validation, line format and the
repair ladder for model stages
- republish pipeline authoring prompts and docs in the new style
Checks: go build ./..., go vet ./..., go test -count=1 ./..., gofmt -l .
Every OpenCode-harness model stage now writes its real session into its own
step artifacts directory as session.md and session.html, so the existing
bounded artifact listing, the /artifacts/<run>/<step>/<name> serving path and
the artifact scan find and serve them with no special casing, while the stage
keeps its bounded preview in the run record unchanged.
- internal/opencode/export.go adds the one shared native export invocation and
the exact session-ID/messages validation used by both Connection.Messages and
the new ExportSession, so the readback path does not diverge. The backend's
published subcommand is used (v1 `export <id>`, v2 `session export <id>`),
the source read is capped at 8 MiB, and a larger session is read as a prefix
and reported truncated instead of failing. boundedOutput.ReadFrom keeps the
cap effective so overflow and the truncation path are real.
- internal/stage/session_export.go renders markdown and html with a metadata
header, every role and every part (unknown part types as raw JSON, every
session text escaped in html), atomic temp+rename writes that never overwrite
an existing file, a visible truncation banner at both ends when the source or
the 2 MiB rendered cap cuts it, and an honest 0-message header for an empty
session rather than fabricated text.
- protocol.SessionExport and RunStep.SessionExport are stored in a new
step_session_exports table (CREATE TABLE IF NOT EXISTS, so an old database
gains an empty table with no migration) loaded through the existing main
SELECT alongside the other per-step evidence and deleted by run retention.
- internal/server/runner.go exports after the post-stage filediff capture and
before scanArtifacts, with context.WithTimeout(context.WithoutCancel(ctx),
10s); it never waits for session idleness and a failure or a Pi stage (no
native export path) records a sanitized diagnostic and continues, never
changing the stage status, outcome, target, timing or result validation.
Reflected where it belongs: the packaged skill references
(internal/author/skill/references/operations.md and delivery.md) carry the new
Session export rules and the run-artifacts bullet, and docs/stage-artifacts.md
documents the names, the <run>/<step> paths, the served URL, the caps, the
truncation labels, failure isolation and the Pi limitation. The packaged
templates (examples/*.md) only tell a stage to save its own artifacts and say
nothing about the server-written session export, so none needed updating; no
new reference file was added, so install.go's managed inventory is unchanged.
Shared documentation: README.md's per-step artifacts sentence is now stale - it
should name the exported session alongside images, screenshots, reports and
logs. It is deliberately not committed here; the shared documents are folded by
the single documentation writer.
Checks: gofmt -l on the touched packages produced no output; go vet ./...
passed; go test -race -count=1 ./... passed.
Every agent stage now writes into a per-run/step artifacts directory under
the data dir (<data>/artifacts/<run>/<step>), passed to Pi as
PIPELINES_ARTIFACTS_DIR, exposed on the OpenCode client env seam, and stated
in the agent prompt boilerplate so agents save images, screenshots, reports
and logs there.
After each step the server scans that directory with a bounded, symlink- and
traversal-safe inventory (os.OpenRoot + Lstat + O_NOFOLLOW) recording name,
size_bytes, content type (extension then 512-byte sniff fallback) and URL,
enforcing max files, per-file bytes and total bytes while counting skipped
and truncated entries. A missing, unreadable or oversized directory yields
only a best-effort diagnostic and never changes the step outcome.
The list is carried on protocol.RunStep as Artifacts []StageArtifact plus
skipped/truncated counters (omitempty, backwards compatible), persisted in a
new step_artifacts table keyed (run_id, sequence) alongside the
notifications/file-changes tables and loaded by GetRun.
GET /artifacts/{run}/{step}/{name} on the existing handler serves the bytes
with http.ServeContent, so Content-Type, Content-Length, HEAD and Range
(206/416) come from the stdlib; unknown runs/steps, absolute paths,
traversal, symlink escapes and non-regular files are refused.
The TUI lists each selected step's artifacts (name + human size) in the
retained-evidence section and adds an artifacts summary in the style of the
file-changes summary. Adds docs/stage-artifacts.md linked from README and an
artifacts subsection to the packaged operations skill reference.
Tests cover the scan records and caps, missing/oversized directories,
HTTP HEAD/Range/traversal/symlink/unknown refusals and protocol round-trips.