Repository navigation
feat: agent rules from the window, per project, and kg instructions - #114
Merged
Merged
Conversation
…nstructions command The global rules file keeps its place. A project may have .kagan/instructions.md, and a start adds it after the global rules. Each file is cut at 16 KiB. kg instructions get, set and clear edit them; set takes text, --file or stdin.
Settings > General gets an Agent rules editor for the global rules, with a byte count against the 16 KiB cap and a line naming the programs that get them. A project's row menu opens its rules in the same editor, in a dialog. The product size ceiling rises by 390 lines, as the decision records.
The global rules were read once at startup, so a change made with kg instructions set did not show in the page until the app restarted.
… not UTF-8 Before, any read error came back as an empty file, so Save would then clear it. Only a missing file is empty now. Thread starts still read leniently and cut at the cap. The two tests failed before this change.
… writes atomically Set created every missing folder on the way to the file, so a project whose folder was gone got a stray tree back. Now only .kagan is created, and a missing project folder is refused. The file is written to a temp file and renamed into place. The missing-folder test failed before this change. There is no deterministic test for the atomic write; a temp file is removed on error.
…s when a file is too long Save was enabled before the file was read, and an empty box meant Clear, so a fast click could delete rules. Save now waits for a successful read. Reopening Settings keeps a draft the person typed. Over-cap text disables Save and says whether the file or the draft is too long. Save reports its state to kg ui, the rules row is in the Agents group, the box takes focus when the project dialog opens, and Cmd+Enter saves. Cmd+Enter inserts a newline before it saves, so trailing whitespace is trimmed on save. The new tests failed before this change, and the Failed state has no test of its own: a read cannot be forced to fail through the UI.
Agents may set the rules on purpose, as they may set preferences. The kimi and opencode research now names its versions, dates, and the pages it read. The glossary keeps the instructions name for the file and command, and the size ceiling and Cost line match the measured lines.
open_project focuses the box itself, so the helper was never called and clippy rejected it under -D warnings.
The helper removal moved the product count to 72016, so the ceiling is set to that number and the Cost line says so.
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.
A person can set rules for their agents from the window, per project too, and from
kg.What changed
<project>/.kagan/instructions.md, added after the global rules for that project's threads. The project row menu → "Agent rules…" opens the same editor in a dialog.kg instructions get | set | clear, global by default,--project <id>for one project;settakes text,--file <path>or--file -. ThroughOp::Instructions. Set refuses over-cap text and never rebuilds a missing project folder; writes are atomic; reads stop at 1 MiB and refuse non-UTF-8.Cost:line.Checked
fmt, clippy
-D warnings, 1852 tests, scripts,scripts/smoke.sh. A fresh reviewer's findings are fixed, each behaviour fix with a test shown failing first. Light, dark and over-cap screenshots.Not in this change
No screenshot of the project dialog (the test driver cannot right-click); two UI tests cover it.