A local-first multi-agent app development platform, built on PenguinHarness
Hooks in core, goal mode and continual learning as plugins, and the skill library becomes a plugin library
- Date: 2026-08-29
- Type: feature
- Scope:
core,plugins,server,web,cli,desktop,docs - PR: #542
- Breaking: yes — the
goal_statetable is dropped by the first restart-only migration, and built-in goal mode is replaced by thegoalplugin
The Session gained a generic hook mechanism: core codes the hook points — stop, the moment a Task ends, pre_tool_use and user_prompt — and the hooks themselves come from plugins as hook packages, plain Node scripts installed into agent_state/hooks/ beside agent_state/skills/. Goal mode moved out of core entirely and became the goal plugin's stop hook, ralph-loop style: a state file the hook reads and rewrites after every Task. A second hook package, continual-learning, hands a long task's findings to a background subagent. The skill library was reshaped into a plugin library — one npm package per plugin (@penguinharness/<name>), skills and hook packages inside, versions by date, loaded by @prismshadow/penguin-core — and @prismshadow/penguin-skills is deprecated.
Stop hooks
- After every Task of a
runcall the Session consults the Agent's installed hook packages (top-level Sessions only), running eachstopcommand as a subprocess with{ hook, session_id, trace_path }on stdin — nothing more. Token usage, turn counts, how the Task ended and any state file are the script's to derive from the Trace. - A script answers
continue(with the next Task's user text asinput),stop, asubagentrequest ({ prompt, agent_id? }— the Session spawns a detached background child Session that inherits the run's approval callback, records its session id on the event and streams the child'ssession_metaright behind that event, so the server registers the child session — it gets a session row and appears with the other subagent sessions, without entering the parent's nested subagent view — instead of leaving an id nothing can open), or nothing. Every non-empty answer becomes one generichookevent message —hook,name(the package),decision,reason, scalaroutput— streamed and written to the Trace; the injected input is the user message that follows it, stampedsender: "harness"— the structural origin mark hosts render and key on, with no text protocol. The firstcontinuedrives the next Task inside the samerun; after a cutoff or an aborted signal acontinueis recorded but never run — themax_turnscap now counts as a cutoff (RunCutoff.kind: "max_turns", where the engine used to returnnull), so no hook can re-fire a Task the cap closed; a subagent round that hits its cap reports as failed with that cause instead of handing its notice over as an answer. A script that crashes, prints non-JSON or times out (default 60 s) is recorded and treated as no opinion. - A third hook point,
user_prompt, expands a submitted prompt. Hooks run in core and nowhere else: the host triggers it throughSession.runUserPromptHookwhen it accepts a prompt for the flow the package owns, and the answer'scontextis sent right behind the user's message, harness-stamped. Goal mode's start is the shipped use — the goal plugin'sstart.mjsis itsuser_promptcommand. - A second hook point,
pre_tool_use, runs before each tool call's approval (hooks.jsonpre_tool_usecommands; stdin additionally carriestool_name,tool_call_idand the rawargumentsJSON):denyrefuses the call without consulting approval — the model reads the hook's name and reason as the tool's output — andallowapproves without asking; the project command policy still outranks an allow (hook packages live in agent-writable state), and no built-in plugin ships one — the point is for custom guards. - SDK embedders can still register in-process hooks (
SessionConfig.hooks.stop/.preToolUse); the subprocess runner (runHookScript) is exported for hosts that call a package's other scripts. - The trace page renders
hookevents; the CLI prints one dim line per non-goal hook answer.
Goal mode as the goal plugin
- Core knows nothing about goals any more —
session.run'sgoaloption, the goal file helpers,goalOutcomeOfand the[goal]marker itself are gone (thegoal-blockmarker module included). Round messages are plain user text: no protocol block, origin carried by thesender: "harness"stamp alone. The plugin (preinstalled ondefault_agent) shipsstart.mjs, which writesGOAL.json(objective,status,budget,round,tokens_used, andendedonce the hook has acted on a terminal status) and composes round 1's protocol message, andstop.mjs, which after every Task reads the round's usage off the Trace (windowed from the round's injected input; completion notices share the stamp but are not boundaries), applies the same decision order as before (model verdict → cutoff → wrap-up → 100-round cap → budget → next round) and rewrites the file. - The server gates
goal: { budget }on the package being installed (409 goal_plugin_not_installed), runsagent_state/hooks/goal/start.mjs, and submits your message exactly as typed (text and images) with the protocol message it prints right behind it, harness-stamped; later rounds restate the objective from the goal file.GET /goalreadsGOAL.json(a live status while the Session is idle reads asaborted; the response no longer carriesupdatedAt). The plugin's start hook runs under the session lock after the idle check, so a second goal submitted over a running one is refused before it can overwrite the goal file. Thegoal_*server events, the chat banner, the/goalcommand andpenguin run --goalbehave as before —goal_roundand the CLI's round line now count harness-injected inputs instead of parsing text; the CLI reads the outcome from thegoal_finishedserver event. File attachments are refused. Fixed along the way:startGoalnever published the seeded round-1 messages to the session channel (core never yields a run's initial input), so a second goal on the same session showed neither the user's message nor the protocol message — and no task boundary or stats row — until a reload;goal_roundfor round 1 is now actually emitted, counted off the seeded input. - The Web App shows a toast when a goal is started on an Agent without the plugin. Round messages render as a compact collapsed card ("Injected by the harness", the background notices' form, expanding to the full text) — the goal-round collapse ("Goal · round N") is gone; input history and the conversation outline skip harness-injected inputs by the stamp (background completion notices keep their turn).
The continual-learning plugin
- Not preinstalled. When the Task that just ended ran more than 30 completed turns, its stop script condenses that Task (clipped user/assistant text, tool calls and outputs) and answers with a
subagentrequest whose prompt asks the child to fold durable findings into the relevantSKILL.mdfiles and bump their version. The window is the Task itself, so a Task triggers at most once — at its end — and short Tasks never do. An Agent with no installed skill never fires it.
The plugin library
- Every plugin is its own npm package:
@penguinharness/<name>, one workspace package per plugin under the repo root'splugins/(plugin.json+icon.svg+skills/<name>/+hooks/); the loader lives in@prismshadow/penguin-core(replacingpackages/skills), reads the plugin names off the host package's dependency list and resolves each package through Node from its own location — the workspace, an npm install and the desktop app all land on their own copy (the desktop app declares the packages as dependencies, electron-builder collects them into the packed app, and the packed-app check verifies every one is there). Four merged multi-skill plugins:software-development(software-engineering + web-design),model-development(llamafactory + ollama + vllm),agent-development(penguin-sdk +unified-llm-api— renamed from agenthub-models — +penguin-config— renamed from penguin-cli — + penguin-orchestration) andagent-tuning(initialization + benchmark-design + evaluation + optimization); the rest stay single-plugin packages, preinstall unchanged; a plugin built around someone else's product carries ause-prefix —use-firecrawl,use-bento-slides,use-claude-code— so the package name says what it is for rather than claiming the product (the skills inside keep their names). Three categories: Office Productivity (the two hook packages included — goal mode and continual learning serve that audience), Software Development and AI App Development (agent-tuningincluded; the Agent Tuning and Session Hooks categories are gone). Versions areYYYY-MM-DD.N, andplugin.jsonis the single metadata holder — a librarySKILL.md's frontmatter carries onlynameanddescription, with the plugin's short descriptions and version stamped into the installable copy by the loader (the installed frontmatter stays self-describing for update checks and the UI). The icon belongs to the plugin —icon.svgbesideplugin.json, every built-in plugin ships one — and everything it ships inherits it: the loader stamps it onto each skill, an install writes it beside the skill'sSKILL.mdand beside the hook package'shooks.json, and the settings Skills and Hooks tabs, the composer's skill picker and the chat's skill chips show it. A subject with no icon falls back to one uniform mark for its kind — the book for a skill, the hook for a hook package, the puzzle piece for a plugin — the same puzzle piece that now marks the plugin library in the navigation (the open book stays the mark of skills). The natural-numberversionand theupdatedtimestamp are gone. - Agent State:
agent_state/hooks/<plugin>/holds a hook package (hooks.jsongenerated from the manifest —name,description,description_zh,versionand one command list per hook point — plus the scripts) besideagent_state/skills/;installPlugin,installHook,removeHookandlistInstalledHooksjoin the state layer.default_agentpreinstalls every plugin not markedpreinstall: false. Installing or uninstalling a hook package through the API invalidates the Agent's cached runtimes, since hooks are bound when a Session is built. The loader refuses to load with a declared plugin package missing or a brokenplugin.json(a broken install, never a silently smaller library). - API:
GET /api/plugins(categories → plugins with their skills' metadata and hook points),GET /api/plugins/:plugin/files(everything a plugin ships as text keyed by path: each skill's installableSKILL.mdand reference files, the hook scripts),POST …/agents/:a/plugins { names }(whole-plugin install; reinstall = update),GET|DELETE …/agents/:a/hooks[/:name](HookItemcarries the plugin'sicon;PluginItemcarries nopreinstall).GET /api/skillsandPOST …/skills { names }are gone; the installed-skill routes (list, archive import/export, uninstall) stay. Agent creation takespluginsinstead ofskills;AgentSummaryreportshookCountandpluginUpdates(wasskillUpdates);SkillMetadataItem.versionis a string andupdatedis gone. - Web App: the skill library page is the plugin library (
/plugins) — each card carries a semantic metadata line (v<version> · updated N days ago · used by N agents, the date parsed straight from the version) and opens a detail Modal: full description and hook points, then a file browser over everything the plugin ships in the benchmark case browser's shape — a tree on the left with one collapsible group per skill and one for the hook scripts (any number open at once) and a preview on the right, so opening a file never replaces the summary or the tree; install and update whole plugins; the Agent settings page gained a Hooks tab; the create dialog seeds plugins. CLI:penguin agent create --plugins. - The design spec was updated to match (penguin-harness-design #86).
Compatibility
Recorded in full in Backward compatibility: the goal_state table is dropped by migration 3 (drop-goal-state, the first restart-only migration — a hot push onto a running runtime is refused until it is restarted; a normal restart applies it at open), existing Agents get no hook packages (goal mode answers 409 goal_plugin_not_installed until goal is installed from the library), skills installed from the old library read as updatable once and keep their old icon until updated, old Traces' goal_finished records and [goal] rounds read as an unknown event and plain text, @prismshadow/penguin-skills is deprecated, and Agent creation's skills / --skills are plugins / --plugins.