[{"data":1,"prerenderedAt":899},["ShallowReactive",2],{"integrations-es:/integrations/opencode":3},{"id":4,"title":5,"active":6,"body":7,"description":888,"extension":439,"eyebrow":889,"icon":890,"image":891,"meta":892,"name":134,"navTitle":134,"navigation":6,"order":872,"path":893,"seo":894,"slug":252,"status":895,"stem":896,"summary":897,"toc":890,"__hash__":898},"integrations_en/integrations/opencode.md","OpenCode + OpenPets",true,{"type":8,"value":9,"toc":863},"minimark",[10,118,179,294,378,466,612,680,721,797],[11,12,16,17,16,22,16,26,16,111],"section",{"id":13,"className":14},"overview",[15],"docs-section","\n  ",[18,19,21],"h2",{"id":20},"what-this-integration-does","What this integration does",[23,24,25],"p",{},"\n    The OpenCode integration connects OpenCode activity to your OpenPets\n    desktop companion. It has two pieces: an OpenCode plugin for automatic\n    reactions, and an MCP server for intentional OpenPets tool calls.\n  ",[27,28,31,32,16],"div",{"className":29},[30],"docs-table-wrap","\n    ",[33,34,35,36,35,53,31],"table",{},"\n      ",[37,38,39,40,35],"thead",{},"\n        ",[41,42,43,47,50],"tr",{},[44,45,46],"th",{},"Part",[44,48,49],{},"What it does",[44,51,52],{},"Why it matters",[54,55,39,56,39,72,39,98,35],"tbody",{},[41,57,58,59,58,66,58,69,39],{},"\n          ",[60,61,62],"td",{},[63,64,65],"strong",{},"OpenCode plugin",[60,67,68],{},"Listens to OpenCode activity and maps useful events to pet reactions.",[60,70,71],{},"The pet can think, edit, test, wait, succeed, or show errors automatically.",[41,73,58,74,58,79,58,82,39],{},[60,75,76],{},[63,77,78],{},"MCP server",[60,80,81],{},"Registers OpenPets MCP tools with OpenCode.",[60,83,84,85,89,90,93,94,97],{},"OpenCode can intentionally call ",[86,87,88],"code",{},"openpets_status",", ",[86,91,92],{},"openpets_react",", and ",[86,95,96],{},"openpets_say",".",[41,99,58,100,58,105,58,108,39],{},[60,101,102],{},[63,103,104],{},"Managed instructions",[60,106,107],{},"Adds short safety guidance for OpenPets usage.",[60,109,110],{},"OpenCode knows to keep visible pet messages brief and non-sensitive.",[23,112,113,114,117],{},"\n    Runtime control is local. OpenCode loads the OpenPets plugin or MCP command,\n    those packages use ",[86,115,116],{},"@open-pets/client",", and the OpenPets desktop\n    app updates the pet window over local IPC.\n  ",[11,119,16,122,16,125,16,144,16,159,16,176],{"id":120,"className":121},"quick-install",[15],[18,123,124],{"id":120},"Quick install",[23,126,127,128,131,132,135,136,139,140,143],{},"\n    In the OpenPets desktop app, open ",[63,129,130],{},"Integrations"," and use the\n    ",[63,133,134],{},"OpenCode"," card. The card is the simple setup path for one\n    machine: click ",[63,137,138],{},"Install"," to write global OpenCode setup, or\n    click ",[63,141,142],{},"Configure"," to inspect the details first.\n  ",[145,146,31,149,31,155,16],"figure",{"className":147},[148],"docs-screenshot",[150,151],"img",{"src":152,"alt":153,"loading":154},"/docs/opencode-integrations-grid.png","OpenPets Integrations window showing the OpenCode card ready to install.","lazy",[156,157,158],"figcaption",{},"The integrations grid. OpenCode is active and ready; Install starts global setup, while Configure opens the detailed setup panel.",[160,161,31,162,31,168,31,173,16],"ul",{},[163,164,165,167],"li",{},[63,166,138],{}," writes global OpenCode config for the plugin, MCP server, and OpenPets instructions.",[163,169,170,172],{},[63,171,142],{}," opens the detailed global setup page with pet routing, command detection, install/remove, refresh, and config preview.",[163,174,175],{},"Restart OpenCode after setup changes so plugin and MCP config are loaded.",[23,177,178],{},"\n    Desktop setup is global. It can affect every OpenCode project on that\n    machine. For repository-specific setup, use the project-local CLI command\n    instead.\n  ",[11,180,16,183,16,187,16,190,16,200,16,268,16,275,16,280],{"id":181,"className":182},"global-setup",[15],[18,184,186],{"id":185},"global-desktop-setup","Global desktop setup",[23,188,189],{},"\n    The OpenCode detail panel manages global setup only. It detects OpenCode,\n    shows whether OpenPets global config is installed, lets you choose a pet,\n    and previews the JSON before writing anything.\n  ",[145,191,31,193,31,197,16],{"className":192},[148],[150,194],{"src":195,"alt":196,"loading":154},"/docs/opencode-global-setup.png","OpenCode setup detail page showing global setup status, pet routing, advanced detection, install and remove buttons, and config preview.",[156,198,199],{},"The global setup panel. Use it to inspect the target config file, selected pet, command path, and JSON preview before installing.",[27,201,31,203,16],{"className":202},[30],[33,204,35,205,35,218,31],{},[37,206,39,207,35],{},[41,208,209,212,215],{},[44,210,211],{},"Panel area",[44,213,214],{},"Purpose",[44,216,217],{},"What it changes",[54,219,39,220,39,231,39,242,39,257,35],{},[41,221,58,222,58,225,58,228,39],{},[60,223,224],{},"Global connection",[60,226,227],{},"Shows whether OpenCode is detected and whether global OpenPets setup is installed, ready, custom, conflicted, or errored.",[60,229,230],{},"Reads OpenCode command status and global OpenCode config files.",[41,232,58,233,58,236,58,239,39],{},[60,234,235],{},"Pet routing",[60,237,238],{},"Chooses which installed pet OpenCode should target.",[60,240,241],{},"Adds the pet ID to plugin options and the MCP command.",[41,243,58,244,58,247,58,254,39],{},[60,245,246],{},"Advanced detection",[60,248,249,250,253],{},"Lets you save a full OpenCode command path if ",[86,251,252],{},"opencode"," is not on PATH.",[60,255,256],{},"Used for detection and setup checks.",[41,258,58,259,58,262,58,265,39],{},[60,260,261],{},"Preview",[60,263,264],{},"Shows config file, instruction file, cleanup paths, and JSON preview.",[60,266,267],{},"Lets you audit the planned global config before installation.",[23,269,270,271,274],{},"\n    OpenCode may need npm or network access to load the published\n    ",[86,272,273],{},"@open-pets/opencode"," plugin unless it is already cached or\n    installed locally.\n  ",[276,277,279],"h3",{"id":278},"customization-ideas","Customization ideas",[160,281,31,282,31,285,31,288,31,291,16],{},[163,283,284],{},"Use global setup when you want OpenPets available in every OpenCode project.",[163,286,287],{},"Select a pet before installing if you want all global OpenCode activity to target one companion.",[163,289,290],{},"Use the config preview to confirm exactly which file will be written.",[163,292,293],{},"Use the command path field if your OpenCode binary is installed outside normal PATH locations.",[11,295,16,298,16,301,16,304,16,325,16,375],{"id":296,"className":297},"project-local-setup",[15],[18,299,300],{"id":296},"Project-local setup",[23,302,303],{},"\n    Project-local setup is better when a repository should own its OpenPets\n    configuration. It keeps plugin config and instructions in the project, so\n    different repos can target different pets or policies.\n  ",[27,305,31,308,31,319,16],{"className":306},[307],"docs-code",[27,309,312,316],{"className":310},[311],"docs-code-bar",[313,314,315],"span",{},"Project setup",[313,317,318],{},"bash",[320,321,322],"pre",{},[86,323,324],{},"npx -y @open-pets/cli@latest configure --agent opencode --pet \u003Cpet-id> --cwd .",[27,326,31,328,16],{"className":327},[30],[33,329,35,330,35,343,31],{},[37,331,39,332,35],{},[41,333,334,337,340],{},[44,335,336],{},"Setup style",[44,338,339],{},"Best for",[44,341,342],{},"Files",[54,344,39,345,39,358,35],{},[41,346,58,347,58,349,58,352,39],{},[60,348,186],{},[60,350,351],{},"Personal machine-wide OpenCode setup.",[60,353,354,355,97],{},"OpenCode config directory, such as ",[86,356,357],{},"~/.config/opencode/",[41,359,58,360,58,363,58,366,39],{},[60,361,362],{},"Project-local CLI setup",[60,364,365],{},"Repos that should explicitly carry OpenPets setup.",[60,367,368,371,372,97],{},[86,369,370],{},".opencode/opencode.jsonc"," and ",[86,373,374],{},".opencode/openpets.md",[23,376,377],{},"\n    If both global and project setup exist, prefer the project-local config for\n    repository-specific behavior and use global setup only as a default.\n  ",[11,379,16,382,16,386,16,389,16,393,16,396,16,412,16,422,16,426,16,429,16,445,16,448],{"id":380,"className":381},"managed-config",[15],[18,383,385],{"id":384},"managed-config-and-instructions","Managed config and instructions",[23,387,388],{},"\n    OpenPets writes plugin, MCP, and instruction entries with managed markers\n    or predictable config shapes. It uses JSONC-aware edits where possible so\n    existing comments and trailing commas can be preserved.\n  ",[276,390,392],{"id":391},"opencode-config","OpenCode config",[23,394,395],{},"\n    A project-local config loads the OpenPets plugin and starts the OpenPets\n    MCP server through the OpenPets CLI. Published setup pins the OpenPets\n    package versions it writes.\n  ",[27,397,31,399,31,407,16],{"className":398},[307],[27,400,402,404],{"className":401},[311],[313,403,370],{},[313,405,406],{},"json",[320,408,409],{},[86,410,411],{},"{\n  \"plugin\": [[\"@open-pets/opencode@\u003Cversion>\", { \"pet\": \"\u003Cpet-id>\" }]],\n  \"mcp\": {\n    \"openpets\": {\n      \"type\": \"local\",\n      \"command\": [\n        \"npx\",\n        \"-y\",\n        \"@open-pets/cli@\u003Cversion>\",\n        \"mcp\",\n        \"--pet\",\n        \"\u003Cpet-id>\"\n      ],\n      \"enabled\": true\n    }\n  }\n}",[23,413,414,415,417,418,421],{},"\n    The npm plugin package is ",[86,416,273],{},". The runtime\n    plugin ID exported by that package is ",[86,419,420],{},"open-pets-opencode",".\n  ",[276,423,425],{"id":424},"openpets-instructions","OpenPets instructions",[23,427,428],{},"\n    OpenPets writes a small instruction file so OpenCode uses visible pet\n    messages safely and sparingly. Keep your own notes outside the managed\n    block.\n  ",[27,430,31,432,31,440,16],{"className":431},[307],[27,433,435,437],{"className":434},[311],[313,436,374],{},[313,438,439],{},"md",[320,441,442],{},[86,443,444],{},"\u003C!-- OPENPETS:START -->\n## OpenPets\nOpenPets MCP tools may be available.\nUse OpenPets as a short visible status channel for meaningful coding progress:\n- Use openpets_say only for brief, user-facing, non-sensitive status updates.\n- Do not include code, logs, secrets, URLs, file paths, prompts, or private data.\n- Use openpets_react for small visual progress changes.\n- Use openpets_status only when checking availability or the targeted pet.\n- Do not spam every internal step.\n\u003C!-- OPENPETS:END -->",[276,446,279],{"id":447},"customization-ideas-1",[160,449,31,450,31,453,31,459,16],{},[163,451,452],{},"Add project-specific OpenCode rules outside the OpenPets managed block.",[163,454,455,456,97],{},"Pin a pet per repository by rerunning setup with a different ",[86,457,458],{},"--pet",[163,460,461,462,465],{},"Use ",[86,463,464],{},"--force"," only when you intentionally want to refresh managed OpenPets entries.",[11,467,16,470,16,474,16,477,16,609],{"id":468,"className":469},"plugin-events",[15],[18,471,473],{"id":472},"plugin-event-reactions","Plugin event reactions",[23,475,476],{},"\n    The plugin listens to OpenCode events and turns useful moments into pet\n    reactions. It ignores OpenPets MCP tools so the pet does not react to its\n    own status updates.\n  ",[27,478,31,480,16],{"className":479},[30],[33,481,35,482,35,498,31],{},[37,483,39,484,35],{},[41,485,486,489,492,495],{},[44,487,488],{},"OpenCode event",[44,490,491],{},"Condition",[44,493,494],{},"Reaction",[44,496,497],{},"Speech",[54,499,39,500,39,518,39,535,39,551,39,571,39,589,35],{},[41,501,502,507,510,515],{},[60,503,504],{},[86,505,506],{},"chat.message",[60,508,509],{},"Any chat message.",[60,511,512],{},[86,513,514],{},"thinking",[60,516,517],{},"None",[41,519,520,525,528,533],{},[60,521,522],{},[86,523,524],{},"tool.execute.before",[60,526,527],{},"Tool name contains edit, write, patch, or apply_patch.",[60,529,530],{},[86,531,532],{},"editing",[60,534,517],{},[41,536,537,541,544,549],{},[60,538,539],{},[86,540,524],{},[60,542,543],{},"Shell-like tool with test-like args.",[60,545,546],{},[86,547,548],{},"testing",[60,550,517],{},[41,552,553,558,561,566],{},[60,554,555],{},[86,556,557],{},"permission.asked",[60,559,560],{},"Permission request for a non-OpenPets tool.",[60,562,563],{},[86,564,565],{},"waiting",[60,567,568],{},[86,569,570],{},"Approval needed",[41,572,573,578,581,586],{},[60,574,575],{},[86,576,577],{},"session.error",[60,579,580],{},"OpenCode session error.",[60,582,583],{},[86,584,585],{},"error",[60,587,588],{},"Short error-pool message",[41,590,591,596,602,607],{},[60,592,593],{},[86,594,595],{},"session.status",[60,597,598,599,97],{},"Status becomes ",[86,600,601],{},"idle",[60,603,604],{},[86,605,606],{},"success",[60,608,517],{},[23,610,611],{},"\n    Shell/test detection is intentionally coarse. Tool arguments are used only\n    to classify the reaction; they are not copied into speech bubbles.\n  ",[11,613,16,616,16,619,16,622,16,677],{"id":614,"className":615},"mcp-tools",[15],[18,617,618],{"id":614},"MCP tools",[23,620,621],{},"\n    The MCP server gives OpenCode a deliberate way to talk to OpenPets. Use\n    MCP when OpenCode should intentionally show status, not just react to\n    lifecycle events.\n  ",[27,623,31,625,16],{"className":624},[30],[33,626,35,627,35,639,31],{},[37,628,39,629,35],{},[41,630,631,634,636],{},[44,632,633],{},"Tool",[44,635,214],{},[44,637,638],{},"Use it for",[54,640,39,641,39,653,39,665,35],{},[41,642,643,647,650],{},[60,644,645],{},[86,646,88],{},[60,648,649],{},"Checks desktop reachability and target pet.",[60,651,652],{},"Setup checks and debugging.",[41,654,655,659,662],{},[60,656,657],{},[86,658,92],{},[60,660,661],{},"Changes reaction without speech.",[60,663,664],{},"Quiet progress states.",[41,666,667,671,674],{},[60,668,669],{},[86,670,96],{},[60,672,673],{},"Shows one short safe message.",[60,675,676],{},"Meaningful progress, blockers, completion, or review handoff.",[23,678,679],{},"\n    Keep speech brief and non-sensitive. Do not put code, logs, file paths,\n    command output, prompts, URLs, tokens, or private data in pet bubbles.\n  ",[11,681,16,684,16,687,16,690,16,707],{"id":682,"className":683},"pet-targeting",[15],[18,685,235],{"id":686},"pet-routing",[23,688,689],{},"\n    If no pet is configured, OpenCode events target the desktop default pet.\n    If a pet ID is configured, the plugin and MCP command target that pet.\n  ",[27,691,31,693,31,702,16],{"className":692},[307],[27,694,696,699],{"className":695},[311],[313,697,698],{},"Runtime path",[313,700,701],{},"text",[320,703,704],{},[86,705,706],{},"OpenCode\n  -> OpenPets plugin or OpenPets MCP tools\n  -> @open-pets/client\n  -> OpenPets desktop local IPC\n  -> default pet or selected agent pet",[160,708,31,709,31,712,31,715,31,718,16],{},[163,710,711],{},"No configured pet: use the desktop default pet.",[163,713,714],{},"Configured installed pet: use an explicit agent pet lease.",[163,716,717],{},"Missing, invalid, or broken pet: fall back to the default pet.",[163,719,720],{},"Lease close or expiry: agent pet window closes when the last lease ends.",[11,722,16,725,16,729,16,732],{"id":723,"className":724},"safety",[15],[18,726,728],{"id":727},"safety-and-behavior","Safety and behavior",[23,730,731],{},"\n    OpenCode integration is fire-and-forget. It should not slow down OpenCode\n    or change OpenCode behavior if OpenPets is closed.\n  ",[27,733,31,735,16],{"className":734},[30],[33,736,35,737,35,747,31],{},[37,738,739],{},[41,740,741,744],{},[44,742,743],{},"Protection",[44,745,746],{},"Behavior",[54,748,39,749,39,757,39,765,39,773,39,781,39,789,35],{},[41,750,751,754],{},[60,752,753],{},"Feedback loops",[60,755,756],{},"OpenPets MCP tools are ignored by the plugin event mapper.",[41,758,759,762],{},[60,760,761],{},"Speech cooldown",[60,763,764],{},"Normal and error speech are throttled.",[41,766,767,770],{},[60,768,769],{},"Permission speech",[60,771,772],{},"Permission messages use their own shorter cooldown.",[41,774,775,778],{},[60,776,777],{},"Repeated reactions",[60,779,780],{},"Same reaction is suppressed briefly to avoid spam.",[41,782,783,786],{},[60,784,785],{},"Debug logs",[60,787,788],{},"Paths and secret-like values are sanitized.",[41,790,791,794],{},[60,792,793],{},"Config edits",[60,795,796],{},"Atomic writes, backups, permission checks, symlink rejection, and size limits.",[11,798,16,801,16,804,16,808,16,826,16,830,16,840,16,844,16,847],{"id":799,"className":800},"troubleshooting",[15],[18,802,803],{"id":799},"Troubleshooting",[276,805,807],{"id":806},"opencode-does-not-react","OpenCode does not react",[160,809,31,810,31,813,31,816,31,819,16],{},[163,811,812],{},"Confirm the OpenPets desktop app is running.",[163,814,815],{},"Restart OpenCode after changing plugin or MCP configuration.",[163,817,818],{},"Check that your global or project OpenCode config includes the OpenPets plugin and MCP server.",[163,820,821,822,825],{},"Use the desktop detail page ",[63,823,824],{},"Refresh"," action to re-check global setup.",[276,827,829],{"id":828},"status-says-custom-or-conflict","Status says custom or conflict",[23,831,832,833,371,836,839],{},"\n    Review the OpenCode config before forcing an update. Keep your own notes\n    outside ",[86,834,835],{},"OPENPETS:START",[86,837,838],{},"OPENPETS:END"," so OpenPets\n    can safely refresh its managed block.\n  ",[276,841,843],{"id":842},"the-wrong-pet-appears","The wrong pet appears",[23,845,846],{},"\n    Re-run setup with the pet ID you want. If that pet is not installed,\n    invalid, or broken, the desktop app falls back to the default pet.\n  ",[27,848,31,850,31,858,16],{"className":849},[307],[27,851,853,856],{"className":852},[311],[313,854,855],{},"Refresh project setup",[313,857,318],{},[320,859,860],{},[86,861,862],{},"npx -y @open-pets/cli@latest configure --agent opencode --pet \u003Cpet-id> --cwd . --force",{"title":864,"searchDepth":865,"depth":865,"links":866},"",2,[867,868,869,873,874,879,880,881,882,883],{"id":20,"depth":865,"text":21},{"id":120,"depth":865,"text":124},{"id":185,"depth":865,"text":186,"children":870},[871],{"id":278,"depth":872,"text":279},3,{"id":296,"depth":865,"text":300},{"id":384,"depth":865,"text":385,"children":875},[876,877,878],{"id":391,"depth":872,"text":392},{"id":424,"depth":872,"text":425},{"id":447,"depth":872,"text":279},{"id":472,"depth":865,"text":473},{"id":614,"depth":865,"text":618},{"id":686,"depth":865,"text":235},{"id":727,"depth":865,"text":728},{"id":799,"depth":865,"text":803,"children":884},[885,886,887],{"id":806,"depth":872,"text":807},{"id":828,"depth":872,"text":829},{"id":842,"depth":872,"text":843},"Connect OpenCode to OpenPets with the OpenPets plugin, MCP tools, global desktop setup, project-local setup, pet routing, and safe managed instructions.","Companion plugin",null,"/opencode.png",{},"/integrations/opencode",{"title":5,"description":888},"Active","integrations/opencode","Connect OpenCode to OpenPets with the OpenPets plugin, MCP tools, global setup, and project-local configuration.","_rBN4eE3gjZQYcbabTZj_DgC5c0EGuC7I9NSy9CgRwo",1781359999902]