feat: @-Mentions — Dateien direkt im Prompt einbetten - #49
Merged
Conversation
Naming a file used to cost a full provider roundtrip: the model read the name, called read_file, waited. @path puts the file in the first request instead, and the model stops guessing at paths it was already given. The @path stays in the sentence so it still reads; content is appended below it in the same shape as a skill attachment. Directories are listed, never walked — inlining a tree is how a prompt silently becomes a megabyte. @ only counts at the start of a word, which is what keeps foo@bar.com out of it. Trailing sentence punctuation is not part of the path, so "@src/agent.cr." finds the file. Three guards, since a prompt does not always come from the user — a skill body could otherwise pull in @~/.ssh/id_rsa: - a path leaving the project is refused unless allow_outside is set, with the project dir normalised the same way candidate paths are so a symlinked project does not make every relative mention look like an escape - files over max_lines are truncated and marked; once max_total_bytes is spent, further mentions are reported rather than embedded - binary files are detected by a null byte in the first kilobyte A missing path stays in the text untouched with a warning rather than failing the turn: the user may have meant a literal @. Skills expand first, mentions second, so a skill body referencing @files resolves too — exactly one level, since what a mention pulls in is never scanned again. Closes #27. 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 #27.
Was drin ist
@pfadbettet die Datei in den ersten Request ein — derread_file-Roundtrip entfällt. Der@pfadbleibt im Satz stehen, der Inhalt hängt darunter, im selben Format wie ein Skill-Anhang.@src/agent.cr@src/tools/@"my notes.md"foo@bar.com@zählt nur am WortanfangZusätzlich:
~wird expandiert, und Satzzeichen am Ende gehören nicht zum Pfad (@src/agent.cr.findet die Datei).Schutz
Ein Prompt kommt nicht immer vom Nutzer — ein Skill-Body könnte sonst
@~/.ssh/id_rsaeinziehen:allow_outside = true. Das Projektverzeichnis wird dabei genauso normalisiert wie die Kandidatenpfade — sonst sähe unter einem symlinkten Projekt (/tmpauf macOS) jede relative Mention wie ein Ausbruch aus. Das ist derselbe Fehler, der bei den Permission-Rules schon einmal aufgetreten ist.max_lineswerden gekürzt und markiert; istmax_total_byteserschöpft, werden weitere Mentions vermerkt statt eingebettet.Ein nicht existierender Pfad bleibt unverändert stehen, mit Warnung — kein Abbruch, der Nutzer meinte vielleicht ein echtes
@.Reihenfolge
Erst Skills, dann Mentions — so löst auch ein Skill-Body mit
@-Referenzen auf. Genau eine Ebene: was eine Mention einzieht, wird nicht erneut gescannt, eine Datei kann sich also nicht über einen Skill selbst hereinholen. Ist als Spec festgehalten.Konfiguration
Sichtbarkeit
FilesMentioned-Event:📎 src/smith/agent.cr (174 lines)im Human-Renderer, strukturiert unter--json.Verifikation
spec/smith/mentions_spec.crclaude-sonnet-5:@sample.txtwird ohne Tool-Call korrekt zitiert;foo@bar.combleibt unberührt,@../../etc/passwdund@missing.crwerden mit Begründung übersprungen🤖 Generated with Claude Code