8000 feat(plugins): preview a local plugin in a hidden kagan by aorumbayev · Pull Request #152 · kagan-sh/kagan · GitHub
[go: up one dir, main page]

Skip to content

feat(plugins): preview a local plugin in a hidden kagan - #152

Merged
aorumbayev merged 27 commits into
mainfrom
feat/plugin-preview
Nov 13, 2026
Merged

aorumbayev merged 27 commits into
mainfrom
feat/plugin-preview

Conversation

@aorumbayev
Copy link
Copy Markdown
Member

Why

Building a plugin meant an agent installed it into the person's own kagan and drove and screenshotted the person's window, so the person could not work while the plugin was tested. A local checkout also could not sit beside the installed plugin with the same id.

What

  • kg plugin preview start <path>: asks the person once, in their own window, with the same power lines as an install. On approve, the person's app seeds a new data folder with an approved plugin record and a preview marker, starts kg --offscreen on that folder and its own socket, and starts the reload watch. It prints the two variables an agent exports to drive the preview with kg ui.
  • kg plugin preview stop <id>, kg plugin preview list.
  • In a preview, a reload whose powers grew fails with a clear sentence instead of asking a question no one can see.
  • No socket call, flag or environment variable makes any app trust a plugin.
  • Decision 274, behaviour, plugin-api, self-extend, CONTEXT, cli.md, guide map, and the plugin-authoring and kg-ui skills (preview first, install into the person's app last).

Proof

Harness tests for approve, decline, seed and the grown-powers refusal; a core test that opens a seeded folder; a live check (.plans/plugin-experience/live-check.sh, run with the person, who clicks Approve once).

Draft until the independent review and the live check pass.

Adds the preview Op (start, stop, list), its result types and the id, the CLI
text for each result, and the regenerated CLI reference. The runtime is a stub
until the next change.
A plugin that loads before the main window opens got window 0 in kg ui, because every open window was numbered. kg ui now numbers only kagan's own windows: the main window and the About window. The regression test loads a status plugin first and checks that window 0 is the main window.
seed_preview opens a new data folder, saves one plugin record and the
preview preference, and leaves the folder for a preview app to open.
kg plugin preview start approves the plugin in the person's window, seeds a
new data folder with it, starts an offscreen kagan on its own socket, and
starts a reload watch. Stop and archive or delete of the thread end it. A
preview refuses a reload whose powers grew, because no one can see a question
there. The preview's socket path length is checked before approval.
Records the three preview verbs, the dev loop with the preview first, the
preview marker, and the authoring and kg-ui skills that test in a preview.
…at/plugin-preview

# Conflicts:
#	.config/size-budget.txt
#	docs/decisions.md
… under its size

The guide map names each kg plugin preview command, and the plugin authoring
skill's steps 6 to 8 are shorter so the bundled skill stays under 4096 bytes.
# Conflicts:
#	.config/size-budget.txt
#	docs/decisions.md
#	docs/ui-driver.md
…ive one

Stop, archive, quit and a sweep of a crashed parent's folder ask the preview
to quit over its socket, wait for its app to exit, then kill the processes the
app started. The preview's id is reserved before its folder exists, so a sweep
from another start cannot remove it, and a start replaces the thread's old
preview only once its own app answers. A start whose app stops, or does not
answer, removes its folder and says what its log ends with. list shows only
previews that still run.

A preview refuses every question at once, and so do preview start and stop
inside a preview. Its quit skips the confirm nobody can answer. Start prints
the variables in front of each command, not as an export, and says it waits
for approval on stderr.
… sweep

Each must-fix has a test that fails when its fix is undone: the question
guard, the reservation that keeps a folder from the sweep, the quit over the
socket, and the removed folder of a failed start. Other tests cover the sweep
and what it keeps, stop of an unknown or known id, the child kill, archive,
list dropping an exited preview, a socket path over the limit, a start whose
app exits at once, the grown-powers refusal with the loaded code still
running, and kg preference refusing the marker.
# Conflicts:
#	.config/size-budget.txt
#	docs/decisions.md
exe() and list() no longer wrap a result that cannot fail, the start notice is a
helper so the CLI run stays under its line limit, and a test binding is used.
The snapshot of a preview's children was not tested, and it sent SIGKILL to
pids listed seconds earlier. It is removed; a preview ends with its app's
group and the wait's fallback. The Windows build failed on the unix-only
constant and the process helpers, so the constant is imported only by the
unix socket path.
A preview is quit over its socket, which never shows the prompt, so the
preview check in the menu quit path had no case to serve.
ask_for_person (approvals, thread delete, the standalone asks) and thread ask
now refuse at once in a preview, with NO_ONE_HERE from core. The plugin-side
check in choose is gone, and preview start and stop keep their own check.
Each core test fails with its guard removed.
…me is smaller

On the person's quit, each reload watch is killed and each preview is asked to
quit over its socket, without a wait: the app would be gone before a wait ends.
A stop, archive or delete drops the watch first, then asks the kagan to quit,
then kills it after the three-second wait.

Replace is one call that takes the thread's old preview and inserts the new
one, with a test. The local fetch is one function shared with reload. The
sweep skips a folder whose kagan answers instead of quitting it. The start is
split into prepare and boot, and the socket path takes only the folder.
…he personal project

kg plugin preview start checks the folder first, so the wait is said only when
the question is about to be raised. The authoring skill's step 7 names the
personal project and environment for kg thread run in a preview. CONTEXT.md
keeps Panel's avoid line under its entry. The budget drops the host line,
and the ceiling and decision carry the new count. The live check's header
says what a detached child escapes.
socket_for returns the socket path on both platforms, and the unix length
check is its own unix-only function, which runs before the person is asked.
The tests that use Op, ThreadOp and run are gated to unix, where they run.
…sion 274 names the booting gap

The quit test calls cx.quit() and requires it to return well before the three
second wait, so a quit that waits for the previews fails. Decision 274 names
the one gap: a start still booting when the person quits is not ended, and
the next start's sweep removes its folder.
@aorumbayev
aorumbayev marked this pull request as ready for review November 13, 2026 07:38
@aorumbayev
aorumbayev merged commit 8f3038b into main Nov 13, 2026
20 checks passed
@aorumbayev
aorumbayev deleted the feat/plugin-preview branch November 13, 2026 07:38
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