9.0 KiB
System Prompt as the Default Sovereign Browser Skill
Goal
The system prompt on sovereign://agents is essentially the default skill for
sovereign_browser. Instead of having a separate "System Prompt" field, we
treat it as an unsaved skill that the user can edit, save, and share —
matching how ai.html handles skills.
Current state
sovereign://agents(config page) has a "System Prompt" textarea saved tosovereign_browser.agent.system_promptin thed:user-settingsevent.sovereign://agents/chathas a skills list (kind 31123) with checkboxes.- The agent loop (
agent_loop.c) uses the system prompt from settings, OR the concatenated templates of selected skills (if any skills are selected).
Desired state
- Rename "System Prompt" to "Sovereign Browser Skill" on the config page.
- The system prompt is presented as an unsaved skill — a skill that exists locally but hasn't been published to Nostr yet.
- In the chat page, the "Sovereign Browser Skill" appears in the skills list as an unsaved skill (with a "Save" button to publish it as kind 31123).
- The user can edit the skill (name, description, template, tools) inline,
matching ai.html's
renderSkillsEditor()pattern. - The user can save the skill to Nostr (publishes kind 31123), making it available to other apps (client, didactyl).
- The user can modify saved skills the same way (if they're the author).
Design
On sovereign://agents (config page)
Replace the "System Prompt" section with a "Sovereign Browser Skill" section:
┌─────────────────────────────────────────────┐
│ Sovereign Browser Skill │
├─────────────────────────────────────────────┤
│ Name: [Sovereign Browser Default ] │
│ Description: [Default agent skill ] │
│ Template: │
│ ┌───────────────────────────────────────┐ │
│ │ You are an AI assistant embedded in │ │
│ │ a web browser. You have access to... │ │
│ └───────────────────────────────────────┘ │
│ Requires tools: [browser, fs, shell ] │
│ │
│ [💾 Save as Skill] (publishes to Nostr) │
└─────────────────────────────────────────────┘
- The template is the current system prompt value.
- "Save as Skill" publishes a kind 31123 event with the skill content.
- The skill is saved to
sovereign_browser.agent.system_promptlocally (as now) AND optionally published to Nostr as a skill.
On sovereign://agents/chat (chat page)
The skills list shows:
- Sovereign Browser Skill (unsaved) — always at the top, with a checkbox (selected by default), an edit button, and a "Save" button.
- Saved skills (kind 31123) — fetched from Nostr, with checkboxes, edit buttons (if user-authored), and delete buttons.
When the user selects the Sovereign Browser Skill, its template is used as
the system prompt (concatenated with any other selected skills, matching the
existing agent_skills_build_system_prompt() logic).
Skill editor (matching ai.html)
When the user clicks "Edit" on a skill (or the Sovereign Browser Skill), an
inline editor expands (like ai.html's renderSkillsEditor()):
▼ Sovereign Browser Default
┌──────────────────────────────────────────┐
│ Name: [Sovereign Browser Default ] │
│ Description: [Default agent skill ] │
│ Template: │
│ ┌────────────────────────────────────┐ │
│ │ You are an AI assistant embedded...│ │
│ └────────────────────────────────────┘ │
│ Requires tools: [browser, fs, shell ] │
│ │
│ [💾 Save / Update] [Cancel] │
└──────────────────────────────────────────┘
- For the Sovereign Browser Skill (unsaved): "Save" publishes it to Nostr as a new kind 31123 event AND updates the local system prompt.
- For saved skills (user-authored): "Save / Update" re-publishes the kind 31123 event with the edited content.
- For saved skills (not user-authored): "View Only (not your skill)" — no
edit, matching ai.html's
canSavelogic.
Implementation
Phase 1 — Rename + restructure the config page
-
www/agents/config.html+config.js— Replace the "System Prompt" section with a "Sovereign Browser Skill" section with Name, Description, Template, and Requires Tools fields. Add a "Save as Skill" button. -
src/nostr_bridge.c— Updatehandle_agents_set()to handle the new skill fields (agent.skill_name,agent.skill_description,agent.skill_template,agent.skill_requires_tools). These are saved tosovereign_browser.agentin thed:user-settingsevent (replacing the oldsystem_promptfield). -
src/agent_loop.c— Update the system prompt logic: usesovereign_browser.agent.skill_templateas the default system prompt (instead ofsystem_prompt). If skills are selected, concatenate their templates (as now).
Phase 2 — Show the Sovereign Browser Skill in the chat page
-
www/agents/chat.js— InrenderSkillList(), add the Sovereign Browser Skill at the top of the list as an "unsaved" skill. It has:- A checkbox (selected by default)
- The skill name (from
sovereign_browser.agent.skill_name) - An "Edit" button that opens the inline editor
- A "Save" button that publishes it to Nostr
-
src/agent_skills.c— Add a functionagent_skills_get_default()that returns the Sovereign Browser Skill from the local settings (not from Nostr). This is used by the chat page to show the unsaved skill. -
src/nostr_bridge.c— Add asovereign://agents/skills/defaultendpoint that returns the Sovereign Browser Skill from settings.
Phase 3 — Skill editor in the chat page
-
www/agents/chat.js— ImplementrenderSkillEditor(skill)matching ai.html'srenderSkillsEditor():- Expandable
<details>for each selected skill - Name, Description, Template, Requires Tools fields
- "Save / Update" button (for user-authored or unsaved skills)
- "View Only" for skills not authored by the user
- Expandable
-
src/nostr_bridge.c— Add asovereign://agents/skills/updateendpoint that re-publishes an existing skill (kind 31123) with edited content. For the Sovereign Browser Skill, this also updates the local settings. -
src/agent_skills.c— Addagent_skills_update(d_tag, name, description, content, requires_tools)that fetches the existing skill event, updates its content, re-signs, and re-publishes.
Phase 4 — Wire the default skill into the agent loop
-
src/agent_loop.c— The system prompt is now:- If the Sovereign Browser Skill is selected (default): use its template
- If other skills are selected: concatenate their templates
- If no skills selected: use the Sovereign Browser Skill template as fallback (it's always the default)
-
src/agent_skills.c— Updateagent_skills_build_system_prompt()to always include the Sovereign Browser Skill template (either as the base prompt, or concatenated with selected skills).
Files to modify
| File | Change |
|---|---|
www/agents/config.html |
Rename "System Prompt" to "Sovereign Browser Skill", restructure fields |
www/agents/config.js |
Handle new skill fields, "Save as Skill" button |
www/agents/chat.js |
Show Sovereign Browser Skill in skills list, implement skill editor |
www/agents/chat.css |
Style the skill editor (matching ai.html) |
src/nostr_bridge.c |
New endpoints: skills/default, skills/update; update handle_agents_set() |
src/agent_skills.c / .h |
agent_skills_get_default(), agent_skills_update() |
src/agent_loop.c |
Use skill template as system prompt |
src/settings.h / settings.c |
Rename agent_llm_system_prompt to agent_skill_template, add agent_skill_name, agent_skill_description, agent_skill_requires_tools |
Reference
~/lt/client/www/ai.htmllines 1454-1540 —renderSkillsEditor()pattern~/lt/client/www/ai.htmllines 1534-1538 — "Save / Update Skill" button~/lt/client/www/ai.htmllines 1471 —canSavelogic (only author can edit)