iblai-vibe-os-agent-code-mode
Skill15 starsChanged 2 months agoMITView on GitHub
Add the OS app's Code mode to a vibe Next.js + Tauri app — a "Code" pill in the chat composer that turns the agent into an agentic coding tool (opencode over ACP) editing files, running commands, and committing in a workspace on the user's machine, with per-operation Allow/Deny permission cards, a loopback proxy that never hands the agent the real token, per-agent skills synced from the platform, and phone access by pairing a mobile build to a desktop. Ships the Tauri Rust modules from src-tauri plus the OS chat pieces. Use when the user mentions 'code mode', 'coding mode', 'opencode', 'agentic coding', 'let the agent edit my files', 'run commands from chat', or 'use Code from my phone'. Needs /iblai-vibe-ops-build first; for on-device models see /iblai-vibe-local-llm.
- Reads credentials
- Installs packages
In this repository158 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- iblai-vibe-pr-reviewSkill
- iblai-api-agent-accessSkill
- iblai-api-agent-auditSkill
- iblai-api-agent-chatSkill
- iblai-api-agent-createSkill
- iblai-api-agent-datasetSkill
- iblai-api-agent-disclaimerSkill
- iblai-api-agent-embedSkill
- iblai-api-agent-evalSkill
- iblai-api-agent-historySkill
- iblai-api-agent-llmSkill
- iblai-api-agent-mcpSkill
- iblai-api-agent-memorySkill
- iblai-api-agent-privacySkill
- iblai-api-agent-promptSkill
- iblai-api-agent-safetySkill
- iblai-api-agent-sandboxSkill
- iblai-api-agent-sessionSkill
- iblai-api-agent-settingSkill
- iblai-api-agent-skillSkill
- iblai-api-agent-supportSkill
- iblai-api-agent-toolSkill
- iblai-api-inferenceSkill
- iblai-api-searchSkill
- iblai-vibe-agent-accessSkill
- iblai-vibe-agent-apiSkill
- iblai-vibe-agent-auditSkill
- iblai-vibe-agent-billingSkill
- iblai-vibe-agent-chat-sidebarSkill
- iblai-vibe-agent-chatSkill
- iblai-vibe-agent-createSkill
- iblai-vibe-agent-datasetSkill
- iblai-vibe-agent-disclaimerSkill
- iblai-vibe-agent-embedSkill
- iblai-vibe-agent-evalsSkill
- iblai-vibe-agent-graderSkill
- iblai-vibe-agent-historySkill
- iblai-vibe-agent-llmSkill
- iblai-vibe-agent-ltiSkill
- iblai-vibe-agent-mcpSkill
- iblai-vibe-agent-memorySkill
- iblai-vibe-agent-privacySkill
- iblai-vibe-agent-promptSkill
- iblai-vibe-agent-safetySkill
- iblai-vibe-agent-sandboxSkill
- iblai-vibe-agent-searchSkill
- iblai-vibe-agent-settingSkill
- iblai-vibe-agentSkill
- iblai-vibe-agent-skillsSkill
- iblai-vibe-agent-supportSkill
- iblai-vibe-agent-taskSkill
- iblai-vibe-agent-toolSkill
- iblai-vibe-agent-virtual-machineSkill
- iblai-vibe-agent-voiceSkill
- iblai-vibe-local-llmSkill
- iblai-vibe-projectSkill
- iblai-vibe-workflowSkill
- iblai-api-analyticsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
Add Code mode — the OS app's agentic coding tool — to a vibe Next.js + Tauri app.
- Distinctive: line 64
Ask the user for a real agent UUID for testing.
- Very specific: line 199
Never pick auto for them.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
/iblai-vibe-os-agent-code-mode
Add Code mode — the OS app's agentic coding tool — to a vibe Next.js + Tauri app. With the Code pill on in the chat composer, a chat turn no longer goes to the hosted agent: the Tauri backend spawns opencode as a per-chat subprocess, drives it over the Agent Client Protocol, and points its model calls at ibl.ai's OpenAI-compatible API through a loopback proxy. The agent edits files, runs shell commands, and commits changes in a git-backed workspace on the user's machine, and every operation it wants surfaces as a permission card inside the reply the user Allows or Denies (or, once chosen, approves automatically). A mobile build can't spawn binaries, so a phone pairs to a desktop over the LAN by QR and runs the same turns against it.
Image: Phone, paired — Connected To the desktop, its workspace, Select / New Workspace, Disconnect
Image: Phone, Code on — picking one of the desktop's workspaces
Ships code, not a contract. Unlike
/iblai-vibe-local-llm, this skill carries the OS app's actual implementation: the Rust modules inassets/tauri/src-tauri/(copy into yoursrc-tauri/, same layout as/iblai-vibe-ops-build's templates, no.j2to render) and the chat pieces inassets/nextjs/. The mechanics, every command and event, and the wiring are inreferences/.
Common setup (brand, conventions, env files, verification): see docs/skill-setup.md.
Prerequisites
- Tauri shell via
/iblai-vibe-ops-build—src-tauri/with the templatelib.rs, plus the Rust toolchain. - Sign-in via
/iblai-vibe-auth— Code reads the org key and DM token from the SDK's auth storage. - Platform: macOS or Linux desktop for the agent itself (Linux also
needs
bwrap/bubblewrap on PATH for the sandbox); iOS/Android only as a paired client. Windows is not supported —install_opencodereturns an error and the pill hides. A Mac App Store build hides it too: under the App Sandbox (APP_SANDBOX_CONTAINER_IDset) the app can't spawn the downloaded binary, so ship Code in the Developer ID / notarized.dmgbuild from/iblai-vibe-ops-build, not the MAS one. - Your own chat surface. The SDK's
<Chat>transport already routes Code turns, but<Chat>has no composer slot and does not render reasoning, tool calls, or permission cards — the OS app owns those pieces (shipped here). If your app mounts the SDK<Chat>unchanged, you get streaming Code replies but no way to answer permission prompts: every manual-mode operation times out as denied after 180 s. Either host the shipped components in your own composer/message bubble, or consciously chooseautoapprovals (see Security). - Ask the user for a real agent UUID for testing. Do NOT invent one.
Step 1: Rust — drop in the modules
cp -R <skill>/assets/tauri/src-tauri/src/* src-tauri/src/
cp <skill>/assets/tauri/src-tauri/permissions/code-mode.toml src-tauri/permissions/
cp <skill>/assets/tauri/src-tauri/capabilities/mobile-pairing.json src-tauri/capabilities/| File | What it is |
opencode_acp.rs | The ACP transport: one opencode acp child per chat, sandboxing (macOS sandbox-exec, Linux bwrap), permission cards, workspaces, per-agent skills dir, session reuse and reaping |
opencode_proxy.rs | Loopback token-injecting proxy the agent's model calls go through; mints the scoped IBLAI_API_KEY; composes AGENTS.md guidance |
opencode_installer.rs | Downloads the pinned opencode release (OPENCODE_VERSION), writes opencode.json, syncs the latest iblai/vibe release into the agent's skills |
opencode_build_prompt.txt | System-prompt line compiled in via include_str! — keep the name |
remote_code.rs | Desktop phone-access host: opencode serve + pairing QR |
remote_code_client.rs | Mobile: the same opencode_* commands proxied to a paired desktop over HTTP + SSE |
permissions/code-mode.toml | One allow-* per command, grouped as the code-mode set |
capabilities/mobile-pairing.json | Camera permissions for scanning the pairing QR (iOS/Android only) |
Then wire them — module declarations with their cfg gates, the
emit_on_main helper, log_fe, plugins, setup hooks, the two
generate_handler! lists, and the exit hook — exactly as in
references/lib-rs-wiring.md. Add the
Cargo entries from references/cargo-deps.toml
and reference the code-mode set from capabilities/default.json per
references/capabilities.md.
On-device models: opencode_acp.rs can run Code against a local
Ollama/Foundry model and reaches into the local-LLM modules for that. If you
have not implemented /iblai-vibe-local-llm,
add the two small stubs in the wiring reference (§4) — cloud Code never
touches them.
cd src-tauri && cargo check # must compile before touching the frontendStep 2: Frontend — the transport is already in the SDK
useChatV2 (in @iblai/web-utils, used by the SDK <Chat> and by the OS
chat) routes a turn to opencode_chat_stream whenever both hold:
isTauriCodeHost()— a Tauri desktop, or a Tauri mobile app withlocalStorage.ibl_remote_code_ready === "true"(set by pairing);localStorage.ibl_coding_mode_enabled === "true".
It reads ibl_coding_mode_model (provider/model, default openai/gpt-4o)
and ibl_coding_mode_mentor (the active agent UUID, for that agent's synced
skills), calls the command with the DM token, and listens on ollama:token
/ ollama:done / ollama:error / ollama:restart plus opencode:reasoning
/ opencode:tool_call, populating reasoningContent and toolCalls on the
streaming message. Stop → opencode_stop; chat closed → opencode_close.
Nothing per-surface to wire for the transport.
Step 3: Frontend — host the OS chat pieces
Copy assets/nextjs/ into your app and adapt the @/…
imports. These are the OS app's components (paths in the OS repo shown),
not SDK exports:
| Asset | OS path | Role |
components/chat-input-form/coding-mode-button.tsx | components/chat-input-form/coding-mode-button.tsx | The Code pill + popover: enable toggle, first-run Approvals dialog (Ask Me / Automatic), workspace picker (Select / New / open folder), install + vibe-skills status, desktop phone access (QR), mobile pairing (scan / manual, Your Computer card, Disconnect). Writes the ibl_coding_mode_* flags and mirrors permission_mode to platform user-metadata under code_mode |
components/chat/code-permission-card.tsx | components/chat/code-permission-card.tsx | <CodePermissionCards> — listens on opencode:permission_request / opencode:permission_resolved, renders Allow / Deny inside the reply bubble, answers with opencode_permission_respond. This is the security boundary |
components/chat/tool-call-indicator.tsx, tool-call-item.tsx, tool-call-utils.ts | components/chat/… | Collapsible tool-activity list for the toolCalls the transport fills (TOOL_NAME_MAP / ToolCallInfo from @iblai/web-utils) |
components/chat/reasoning-section.tsx | components/chat/reasoning-section.tsx | Collapsible "thinking" panel for reasoningContent |
hooks/use-opencode-skill-sync.ts | hooks/use-opencode-skill-sync.ts | Fetches the active agent's Agent Skills + resources (useLazyGetAgentSkillsQuery, useLazyGetMentorSkillAssignmentsQuery, useLazyGetAgentSkillResourcesQuery from @iblai/data-layer) and materialises them on disk via begin_opencode_skills_sync + set_opencode_skills, with bounded retries |
hooks/use-opencode-learner.ts | hooks/use-opencode-learner.ts | On sign-in calls set_opencode_learner (who the agent acts as, DM base, platform domain, auth URL) and pre-warms ensure_opencode_platform_key |
messages/code-mode.en.json | messages/en.json (chatInputFormCodingModeButton, chatCodePermissionCard) | The next-intl strings the button and cards use |
Adapt these imports (everything else is shadcn primitives + SDK):
| In the asset | In a vibe-starter app |
@/lib/config → config.dmUrl(), getEnv('NEXT_PUBLIC_AUTH_URL') | @/lib/iblai/config — same config.dmUrl(), config.authUrl(), config.platformBaseDomain(), getEnv |
@/types/tauri → isTauriApp, isTauriMobile | drop /iblai-vibe-local-llm's types/tauri.ts in, or copy the two probes (__TAURI__ on window; platform() from @tauri-apps/plugin-os ∈ ios/android) |
@/hooks/use-mentors/use-mentor-settings → llmProvider, llmName | useGetMentorSettingsQuery from @iblai/data-layer (used only to pre-select the agent's model) |
@/hooks/use-tauri-offline → isTauriOfflineMode() | () => localStorage.getItem('ibl_local_llm_enabled') === 'true' if you have local models, else () => false |
@/lib/utils → getUserOS() | platform() from @tauri-apps/plugin-os |
@/hooks/use-user, @/features/utils → useUsername, getUserEmail | read userData from localStorage (user_nicename, user_email) |
@/components/markdown | your Markdown renderer (the SDK Chat uses react-markdown) |
@/components/ui/{popover,switch,tooltip,alert-dialog,collapsible} | npx shadcn@latest add popover switch tooltip alert-dialog collapsible |
next-intl useTranslations('…') | pnpm add next-intl and load messages/code-mode.en.json, or inline the strings |
Mount them: <CodingModeButton sessionId={…} skillSync={useOpencodeSkillSync({ org, mentorUniqueId })} />
in your composer's button row (the OS gates it to Tauri after mount, never
during hydration), <CodePermissionCards generationId={…} /> +
<ReasoningSection> + <ToolCallIndicator> inside the assistant bubble,
and useOpencodeLearner() once near the app root. Frontend deps:
pnpm add @tauri-apps/plugin-os @tauri-apps/plugin-dialog @tauri-apps/plugin-opener
pnpm add @tauri-apps/plugin-barcode-scanner # mobile builds onlyStep 4: Use MCP tools for the SDK side
get_hook_info("useChatV2")
get_component_info("Chat")
get_api_query_info("useGetAgentSkillsQuery")Linked SDK exports
From @iblai/iblai-js/web-utils (the transport lives here):
useChatV2— routes turns to Code when the flags are set; fillsreasoningContent/toolCallson the streaming message.isTauriDesktop(),isTauriEmbeddedLLMHost()— the public platform predicates (the streaming internals ofopencode-client.tsare deliberately private;isTauriCodeHostis used byuseChatV2).TOOL_NAME_MAP,ToolCallInfo— what the tool-call components render.
From @iblai/iblai-js/data-layer:
useLazyGetAgentSkillsQuery,useLazyGetMentorSkillAssignmentsQuery,useLazyGetAgentSkillResourcesQuery— the skills sync source (/iblai-vibe-agent-skills).useGetUserPlatformMetadataQuery,useUpdateUserPlatformMetadataMutation— thecode_mode.permission_modepreference that follows the user (/iblai-vibe-user-metadata).useGetMentorSettingsQuery— the agent's LLM provider/model, pre-selected as the Code model.
Security (read before shipping)
- Permission cards are the boundary. The agent runs at the user's own
privilege; the sandbox only hides secrets and confines writes. Rust pins
permission: "ask"into the config on every spawn — it cannot be loosened on disk. Render the cards. - No default approval mode.
get_opencode_permission_mode()isnulluntil the user chooses; the button raises the first-run dialog. Never pickautofor them. - The DM token never reaches the agent — the loopback proxy injects
it. The one credential handed over is a scoped, week-long, revocable
platform API key (
IBLAI_API_KEY), so the syncediblai-*skills can act on the platform; non-admins get none and turns continue. - Phone access binds
0.0.0.0with a fresh password per enable and is killed with the app. Show the QR only to the person at the desk.
Full rationale, on-disk layout, and the agent's environment:
references/architecture.md.
Verify
cd src-tauri && cargo check— zero errors.pnpm build— zero errors;pnpm testpasses.pnpm exec tauri dev(desktop): open a chat, click Code — first click installs opencode (log lines onmodel:installation-log) and asks for an approval mode; ask the agent to "create hello.txt with one line"; a permission card appears in the reply; Allow; the file exists under~/.local/share/iblai/workspaces/….pnpm exec tauri ios dev "<device>"after phone access is on the desktop: scan the QR, send the same prompt, see the same card.- Screenshot the composer with the pill on:
npx playwright screenshot http://localhost:3000/ /tmp/code-mode.png
Platform data
| Call | Purpose |
POST {asgi}/api/ai-mentor/orgs/{org}/v1/chat/completions | the agent's model calls, via the loopback proxy with the DM token injected |
GET {dm}/api/ai-mentor/orgs/{org}/v1/models | the Code model picker |
GET …/orgs/{org}/agent-skills/, …/agents/{uuid}/skills/, …/agent-skill-resources/ | the agent's skills synced to disk — /iblai-api-agent-skill |
POST {dm}/api/core/platform/api-tokens/ (by platform_api_key) | the scoped IBLAI_API_KEY — /iblai-api-token |
GET/POST {dm}/api/core/users/platform-metadata/ (code_mode.permission_mode) | approval mode following the user — /iblai-api-profile-metadata |
https://github.com/iblai/vibe/releases/latest | the vibe skills the agent gets, resolved at every launch |
Related skills
/iblai-vibe-ops-build— the Tauri shell this drops into./iblai-vibe-local-llm— on-device models Code can run against; also thetypes/tauri.tsprobes./iblai-vibe-agent-chat— the SDK chat surface whose transport carries Code turns./iblai-vibe-agent-skills— the Agent Skills the sync hook materialises for the agent./iblai-vibe-agent-sandbox— the platform-side sandbox kinds (Computing Runtime / VM Shell / Claw); Code mode is the desktop-side runtime and is independent of them.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

