8000 feat: environment variables, a project settings page and a default program per project by aorumbayev · Pull Request #117 · kagan-sh/kagan · GitHub
[go: up one dir, main page]

Skip to content

feat: environment variables, a project settings page and a default program per project - #117

Merged
aorumbayev merged 12 commits into
mainfrom
feat/project-settings
Nov 10, 2026
Merged

aorumbayev merged 12 commits into
mainfrom
feat/project-settings

Conversation

@aorumbayev
Copy link
Copy Markdown
Member

What changed

  • Environment variables. kg env list, kg env set NAME [--project id] (the value comes from stdin or a hidden prompt), and kg env remove. Settings → General has a group for global variables. Values are stored in <data>/environment.json, created with mode 0600. A project's value wins over the global one.
  • Who gets them. A thread's program, its extra terminals, and its setup and teardown scripts get them. Plugin processes and git do not.
  • Project page. "Project settings…" in the project menu (or kg settings project <id>) opens a window page with the project's variables, its default program, and its agent rules. The rules use the same editor the menu's "Agent rules…" opens.
  • Default program per project. A new thread in the project starts with its program when it is installed. The page names a stored program that is not installed.
  • Fix round (review findings).
    • A request that names a thread cannot set or remove a variable.
    • Every read-modify-write of the file holds one lock.
    • An unreadable file is moved aside on a change and named in a warning. Thread starts still fail, with the path.
    • Removing a project forgets its values best-effort.
    • Escape leaves the project page. The Close control matches Settings.
    • Windows names fold case when the project value is matched.
  • Decisions 220 and 221. 220 records the storage choice, why it is not the keychain, the thread guard, and the size count.

Checked

  • Full workspace tests: 1981 passed, with --no-fail-fast.
  • cargo fmt --check, and cargo clippy --workspace --all-targets --locked -- -D warnings.
  • Repo scripts: size budget (74,652 lines, exact), crate boundaries, glossary, view colors, decisions, test env.
  • scripts/smoke.sh.
  • cargo deny and cargo shear, run locally, pass. typos passes. jscpd finds no clone in changed code.
  • Each behaviour fix has a test that was shown failing before the fix. Races: a test with eight threads lost 169 of 200 writes without the lock.
  • Screenshots of the project page (light and dark, with the missing-program line) and of Settings → General, from an isolated app in a fresh data folder.

Not proven

  • Windows: the file's ACL, and the Windows name fold. Only CI runs Windows, and its tests are behind cfg(unix) where they need unix.
  • The sidebar menu by right-click, by hand. Its position and the op path are covered by tests.
  • Thread-guard strength. The guard keys off the thread id that KG_THREAD_ID sends. A program can drop KG_THREAD_ID and send the same request. Decision 220 says so.
  • The keychain. Values are plain text on disk, mode 0600. Decision 220 lists the steps for a later move.
  • Keyboard reach of the sidebar project menu.

Adds the EnvOp (list, set, remove) and the name and value checks, a
project program column with its SetProgram op, and a ProgramOp scope
for the project's default.
Variables live in one 0600 file in the data folder, never in the
database or a reply. A program gets the global ones and its project's,
with the project's winning, before kagan's own KG_* names. A removed
project takes its values with it. A project's installed program is the
new-thread default.
A value comes from stdin or a prompt that does not show it, and is never
taken from the command line.
General lists the variables every program gets. A project's menu opens its
page, which holds its variables, its default program, and a spot for agent
rules. New threads in that project start with the default when it is
installed.
Decisions 211 and 212 say why values sit in a 0600 file and why the
project page is its own window page. The product Rust ceiling rises by the
813 lines this feature needs.
The sidebar's Project settings item and kg settings project send the op, so
the page is reachable by agents and tests too. A project id that is not
live is refused. A new thread's default program can come from a project
that is not in the program list, because it is listed as a recent program.
Setup and teardown scripts run with kagan's own environment, so they do not
get the variables yet. The page op is in behaviour and decision 212.
Renumbers the environment variable and project page decisions to 220 and 221,
puts the project page's agent rules on the shared editor, and gives setup and
teardown scripts the same variables.
…dable file aside

A request that names a thread cannot set or remove a variable, and the check
runs before anything is read. Every read-modify-write holds one lock. An
unreadable values file is moved aside on a change and named in a warning;
starts still fail with its path. Removing a project forgets its values
best-effort. An empty project entry is dropped. Windows names fold case.
The page takes focus when it opens, binds escape, and its Close control
matches Settings. A stored program that is not installed is named on the page
instead of silently falling back.
… size count

The decision now says which requests are refused and that the thread check
keys off the op's thread id. It names the Windows ACL, the keychain steps as a
list, and the one Cost line with the exact count.
@aorumbayev
aorumbayev merged commit 6ac6da2 into main Nov 10, 2026
19 checks passed
@aorumbayev
aorumbayev deleted the feat/project-settings branch November 10, 2026 15:07
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