Documentation
¶
Overview ¶
Package rtk puts a compressor between a leaf's shell and the work model's context. rtk (github.com/rtk-ai/rtk, Apache-2.0) is a proxy binary that runs an inspection command and prints a far shorter version of what it said: a `ps aux` that cost 254KB of context costs 3.5KB through it, a `git diff` 41% less, a bare `ls -la` a fifth. Every one of those bytes is paid for again on every later turn of the leaf, so the saving compounds the way spilling does.
Two properties are load-bearing, and everything in this package serves them.
codeaf stays the only thing anyone installs. rtk is never a build or install dependency: it is resolved at runtime, and fetched in the background if it is missing. While it is unavailable — offline, unsupported platform, download still in flight — commands run exactly as they did before. Nothing here may block or fail a leaf's work.
A leaf's shell never changes meaning because rtk was in the middle. rtk's own rewriter decides what it can compress, which is the honest source of truth and spares us a table of command syntax; but it is broader than we want — it will turn `git add .` into `rtk git add .` — so the last word on eligibility is here, and a wrapped run that goes wrong is answered by the plain one.
The head's belt deliberately does not use any of this. The head reads deliverables in order to answer the user in their own words; a compressed read would cost answer fidelity to save tokens on the one surface where the bytes are the point.
Index ¶
Constants ¶
const ( // Version is the pinned rtk release. Pinned rather than tracking latest so // that what a leaf sees does not change under it on someone else's release // schedule. To bump: read the notes at // https://github.com/rtk-ai/rtk/releases, set the tag here, and re-run the // integration test with CODEAF_TEST_RTK=1 — the one test that checks a real // binary still preserves exit codes. Version = "v0.45.0" // EnvBinary is the escape hatch: a path to a chosen rtk, or "off" to run // every command plain. It is read on every call so a running resident can // be taken out of the loop without a restart. EnvBinary = "CODEAF_RTK" // Off is the EnvBinary value that disables wrapping everywhere. Off = "off" )
Variables ¶
This section is empty.
Functions ¶
func BinDir ¶
BinDir is where a bootstrapped rtk lives. It is codeaf's own shelf, not the user's ~/.local/bin, because codeaf put it there and codeaf maintains it.
func Bootstrap ¶
Bootstrap fetches the pinned rtk if there is none, and is safe to call from a goroutine at startup and to ignore. It never returns an error because there is no caller for whom rtk's absence is a failure: every path through here ends with commands running exactly as they always have.
func Failed ¶
Failed reads a wrapped run's result for the one thing that means the wrapping broke rather than the command: rtk could not execute what it was handed. That is exit 127 — either rtk is no longer where we found it, or it fell through to a program that is not installed — and in both cases the plain command is the honest answer, whether it succeeds or reports the same absence itself.
func StripNudge ¶
StripNudge removes rtk's once-a-day hook advertisement from merged output.
Types ¶
type Class ¶
type Class int
Class is how much of a wrapped command's failure we are willing to believe.
A read is cheap to repeat and its failures are the ones a model most needs verbatim — "no such file" has to be the shell's sentence, not a proxy's — so any nonzero exit is answered by running it again plain. A check earns the opposite treatment: a failing test suite is reporting, not malfunctioning, and its compressed failure is the single most valuable thing rtk produces. Running it twice would cost the leaf the whole suite a second time, so a check's exit code is taken at face value unless rtk itself came apart.
type Tool ¶
type Tool struct {
Path string
// contains filtered or unexported fields
}
Tool is a resolved rtk binary and the memory of what it has been asked.
func Available ¶
Available answers where rtk is, and never fetches it. Everything it does is a local lookup, which is nothing beside the fork the caller is about to do.