8000 feat: agent rules from the window, per project, and kg instructions by aorumbayev · Pull Request #114 · kagan-sh/kagan · GitHub
[go: up one dir, main page]

Skip to content

feat: agent rules from the window, per project, and kg instructions - #114

Merged
aorumbayev merged 11 commits into
mainfrom
feat/agent-rules
Nov 10, 2026
Merged

aorumbayev merged 11 commits into
mainfrom
feat/agent-rules

Conversation

@aorumbayev
Copy link
Copy Markdown
Member

A person can set rules for their agents from the window, per project too, and from kg.

What changed

  • Settings → General → Agent rules: an editor for the global rules with Save (also Cmd/Ctrl+Enter), a byte count against the 16 KiB cap, and a line naming the programs that read them. Save waits until the file has loaded, a draft survives leaving Settings, and a hand-edited file over the cap says so and cannot be saved.
  • Per-project rules: <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; set takes text, --file <path> or --file -. Through Op::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.
  • Cap: 16 KiB per file (was 4 KiB), cut on a character boundary; up to 32 KiB per start.
  • kimi and opencode still get no rules: no documented way to append text (sources in decision 211). The editor says so.
  • Decision 211 (amends 172; agents may set rules like any preference, on purpose). Ceiling +417 lines with a 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.

…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.
@aorumbayev
aorumbayev merged commit c0c4619 into main Nov 10, 2026
19 checks passed
@aorumbayev
aorumbayev deleted the feat/agent-rules branch November 10, 2026 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0