feat: allow setting system prompt from a file #94
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/system-prompt-from-file"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
glchat could only take a system prompt inline, with
--system. A prompt of any length lives better in a file, so this adds--system-file <path>:Behaviour
The file is read by
glchat.ReadTextFile, the checks/readalready applied, now factored out so both share them: regular files only, at most 1 MiB, UTF-8 without NULs, non-empty. Trailing whitespace is trimmed, so the newline an editor leaves is not part of the prompt, and a leading~is expanded (the shell does not expand it in--system-file=~/x).--systemand--system-fileare mutually exclusive. Ranking one above the other would leave the losing flag unread, and a mistyped path would then start a conversation with no mention of the file.An empty name (
--system-file "", typically an unset variable in a script) is an error rather than "no system prompt".A file that cannot be used is reported before discovery and before the TUI starts, against the flag that named it:
The regular-file check matters more here than it does for
/read: this read happens before the UI is up, so a plainos.ReadFileon a fifo is a client that prints nothing and never starts./readitself is unchanged in behaviour; its error messages are byte-for-byte the same, now produced by wrappingReadTextFile's error with the/read:prefix.Testing
internal/glchat:ReadTextFiletrims only the tail and reports the on-disk size; a device is refused from the stat without being opened. The existing/readrejection table still passes unchanged.cmd/glchat(new test file): the two flags are refused together; a missing file, a directory, a device, an empty file and an empty name each fail with an error led by--system-file:. These cases all return before discovery, so nothing is dialled.gofmt,go build ./...,go vet ./...andgo test ./...are clean.--system-fileis refused immediately, where it previously blocked.README and AGENTS.md are updated; AGENTS.md records that any new path putting a file's text in front of the model goes through
ReadTextFile.🤖 Generated with Claude Code
The latest review couldn't run.
Jump to the current review
Review history
r-b98bfc-fa072fr-b9a0d7-40cfdcr-b9a188-0ccbc7r-b9a205-d05dd0r-b9c52a-87c7ber-b9c5f1-ef593ar-b9c715-8031eer-b9c7fb-7b37cfr-be22a4-af2ea1r-bedf90-89a512r-bedfd1-0924e6· current@pr-reviewer-bot review
Superseded — a newer review is further down this thread. This pass is kept on the dashboard as
r-b9a188-0ccbc7.@pr-reviewer-bot review
Superseded — a newer review is further down this thread. This pass is kept on the dashboard as
r-b9a205-d05dd0.@pr-reviewer-bot review
Superseded — a newer review is further down this thread. This pass is kept on the dashboard as
r-b9c52a-87c7be.@pr-reviewer-bot review
Superseded — a newer review is further down this thread. This pass is kept on the dashboard as
r-b9c5f1-ef593a.@pr-reviewer-bot review
Superseded — a newer review is further down this thread. This pass is kept on the dashboard as
r-b9c7fb-7b37cf.9760238de52ac7166bc0@pr-reviewer-bot review again
Superseded — a newer review is further down this thread. This pass is kept on the dashboard as
r-bedfd1-0924e6.--system-file read its file with a bare os.ReadFile, and only when --system was empty. That left several ways for it to go wrong quietly: - A fifo or device blocked the read, before the TUI was up, so the client printed nothing and never started. - With both flags given, --system won and the file was never opened, so a mistyped path went unreported. - The file's trailing newline became part of the system prompt, and an empty file meant no system prompt at all, without a word. /read already had the checks this needs. They move into an exported glchat.ReadTextFile -- regular files only, at most 1 MiB, UTF-8 without NULs, non-empty, trailing whitespace trimmed, a leading ~ expanded -- which /read and --system-file now both call. /read's messages are unchanged. --system and --system-file are now mutually exclusive rather than ranked, and an empty --system-file name is an error rather than "no prompt". Errors lead with the flag, as the other commands' do: glchat: --system-file: /tmp/pipe is not a regular file Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>5f425ac359b17afdafe3@pr-reviewer-bot review
Automated review by pr-reviewer v0.52.3 | Safety Check | Ministral 3 Instruct | tracking id
r-bedfd1-0924e6This is an AI-generated review and may contain mistakes.
Status: ❌ Failed
This review couldn't be completed: that model isn't loaded on the inference service right now, and no alternate model was able to review it either. Consider splitting this PR into smaller changes. Tracking id
r-bedfd1-0924e6.Comment
@pr-reviewer-bot retryto try again.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.