[{"data":1,"prerenderedAt":396},["ShallowReactive",2],{"docs-\u002Fdocs\u002Fv2\u002Ftui\u002Fstructure\u002Fplugins":3},{"id":4,"title":5,"body":6,"description":388,"extension":389,"meta":390,"navigation":67,"path":392,"seo":393,"stem":394,"__hash__":395},"docs\u002Fdocs\u002Fv2\u002Ftui\u002Fstructure\u002Fplugins.md","plugins\u002F",{"type":7,"value":8,"toc":384},"minimark",[9,13,22,274,281,286,295,298,319,323,367,370,380],[10,11,5],"h1",{"id":12},"plugins",[14,15,16,17,21],"p",{},"Lifecycle code. Every ",[18,19,20],"code",{},".ts"," file in here loads on launch — no import, no export, no\nwrapper.",[23,24,29],"pre",{"className":25,"code":26,"language":27,"meta":28,"style":28},"language-ts shiki shiki-themes dark-plus","\u002F\u002F plugins\u002Fworklog.ts\nconst sent: string[] = []\n\ntui.hook(\"message:sent\", ({ content, instance }) => {\n    sent.push(`${instance.name}: ${content}`)\n})\n\ntui.hook(\"tui:shutdown\", async () => {\n    if (sent.length) await Bun.write(`${process.env.HOME}\u002Fworklog.md`, sent.join(\"\\n\"))\n})\n","ts","",[18,30,31,40,62,69,111,153,159,164,190,269],{"__ignoreMap":28},[32,33,36],"span",{"class":34,"line":35},"line",1,[32,37,39],{"class":38},"sOLPB","\u002F\u002F plugins\u002Fworklog.ts\n",[32,41,43,47,51,55,59],{"class":34,"line":42},2,[32,44,46],{"class":45},"scz_3","const",[32,48,50],{"class":49},"s9McN"," sent",[32,52,54],{"class":53},"sTNBD",": ",[32,56,58],{"class":57},"sNl3T","string",[32,60,61],{"class":53},"[] = []\n",[32,63,65],{"class":34,"line":64},3,[32,66,68],{"emptyLinePlaceholder":67},true,"\n",[32,70,72,76,79,83,86,90,93,96,99,102,105,108],{"class":34,"line":71},4,[32,73,75],{"class":74},"s3F5K","tui",[32,77,78],{"class":53},".",[32,80,82],{"class":81},"sCudf","hook",[32,84,85],{"class":53},"(",[32,87,89],{"class":88},"sKc5r","\"message:sent\"",[32,91,92],{"class":53},", ({ ",[32,94,95],{"class":74},"content",[32,97,98],{"class":53},", ",[32,100,101],{"class":74},"instance",[32,103,104],{"class":53}," }) ",[32,106,107],{"class":45},"=>",[32,109,110],{"class":53}," {\n",[32,112,114,117,119,122,124,127,130,132,134,137,140,142,144,146,148,150],{"class":34,"line":113},5,[32,115,116],{"class":74},"    sent",[32,118,78],{"class":53},[32,120,121],{"class":81},"push",[32,123,85],{"class":53},[32,125,126],{"class":88},"`",[32,128,129],{"class":45},"${",[32,131,101],{"class":74},[32,133,78],{"class":53},[32,135,136],{"class":74},"name",[32,138,139],{"class":45},"}",[32,141,54],{"class":88},[32,143,129],{"class":45},[32,145,95],{"class":74},[32,147,139],{"class":45},[32,149,126],{"class":88},[32,151,152],{"class":53},")\n",[32,154,156],{"class":34,"line":155},6,[32,157,158],{"class":53},"})\n",[32,160,162],{"class":34,"line":161},7,[32,163,68],{"emptyLinePlaceholder":67},[32,165,167,169,171,173,175,178,180,183,186,188],{"class":34,"line":166},8,[32,168,75],{"class":74},[32,170,78],{"class":53},[32,172,82],{"class":81},[32,174,85],{"class":53},[32,176,177],{"class":88},"\"tui:shutdown\"",[32,179,98],{"class":53},[32,181,182],{"class":45},"async",[32,184,185],{"class":53}," () ",[32,187,107],{"class":45},[32,189,110],{"class":53},[32,191,193,197,200,203,205,208,211,214,217,219,222,224,226,228,231,233,236,238,241,243,246,248,250,252,255,257,260,264,266],{"class":34,"line":192},9,[32,194,196],{"class":195},"sYbnZ","    if",[32,198,199],{"class":53}," (",[32,201,202],{"class":74},"sent",[32,204,78],{"class":53},[32,206,207],{"class":74},"length",[32,209,210],{"class":53},") ",[32,212,213],{"class":195},"await",[32,215,216],{"class":74}," Bun",[32,218,78],{"class":53},[32,220,221],{"class":81},"write",[32,223,85],{"class":53},[32,225,126],{"class":88},[32,227,129],{"class":45},[32,229,230],{"class":74},"process",[32,232,78],{"class":53},[32,234,235],{"class":74},"env",[32,237,78],{"class":53},[32,239,240],{"class":49},"HOME",[32,242,139],{"class":45},[32,244,245],{"class":88},"\u002Fworklog.md`",[32,247,98],{"class":53},[32,249,202],{"class":74},[32,251,78],{"class":53},[32,253,254],{"class":81},"join",[32,256,85],{"class":53},[32,258,259],{"class":88},"\"",[32,261,263],{"class":262},"svVle","\\n",[32,265,259],{"class":88},[32,267,268],{"class":53},"))\n",[32,270,272],{"class":34,"line":271},10,[32,273,158],{"class":53},[14,275,276,277,280],{},"Files load alphabetically, after ",[18,278,279],{},"main.ts",". Each is independent: one that throws disables\nitself and nothing else.",[282,283,285],"h2",{"id":284},"a-convention-not-a-capability","A convention, not a capability",[14,287,288,291,292,294],{},[18,289,290],{},"tui.hook()"," works from ",[18,293,279],{}," too, and a plugin can register commands and keys. The\nfolder exists so lifecycle code has somewhere obvious to live, and so it loads without\nyou importing it.",[14,296,297],{},"Just don't do both:",[23,299,301],{"className":25,"code":300,"language":27,"meta":28,"style":28},"\u002F\u002F main.ts\nimport \".\u002Fplugins\u002Fworklog\"   \u002F\u002F ✗ auto-loaded AND imported — registers twice\n",[18,302,303,308],{"__ignoreMap":28},[32,304,305],{"class":34,"line":35},[32,306,307],{"class":38},"\u002F\u002F main.ts\n",[32,309,310,313,316],{"class":34,"line":42},[32,311,312],{"class":195},"import",[32,314,315],{"class":88}," \".\u002Fplugins\u002Fworklog\"",[32,317,318],{"class":38},"   \u002F\u002F ✗ auto-loaded AND imported — registers twice\n",[282,320,322],{"id":321},"one-file-per-concern","One file per concern",[23,324,328],{"className":325,"code":326,"language":327,"meta":28,"style":28},"language-bash shiki shiki-themes dark-plus","plugins\u002F\n├── worklog.ts      # message:sent → disk\n├── resume.ts       # tui:shutdown \u002F tui:boot → last agent\n└── notify.ts       # message:received → desktop notification\n","bash",[18,329,330,335,346,356],{"__ignoreMap":28},[32,331,332],{"class":34,"line":35},[32,333,334],{"class":81},"plugins\u002F\n",[32,336,337,340,343],{"class":34,"line":42},[32,338,339],{"class":81},"├──",[32,341,342],{"class":88}," worklog.ts",[32,344,345],{"class":38},"      # message:sent → disk\n",[32,347,348,350,353],{"class":34,"line":64},[32,349,339],{"class":81},[32,351,352],{"class":88}," resume.ts",[32,354,355],{"class":38},"       # tui:shutdown \u002F tui:boot → last agent\n",[32,357,358,361,364],{"class":34,"line":71},[32,359,360],{"class":81},"└──",[32,362,363],{"class":88}," notify.ts",[32,365,366],{"class":38},"       # message:received → desktop notification\n",[14,368,369],{},"Nothing enforces this, but a throw contains itself to one file — so splitting means a\nbroken plugin costs you one behaviour instead of all of them.",[14,371,372,373,379],{},"See ",[374,375,377],"a",{"href":376},"\u002Fdocs\u002Fv2\u002Ftui\u002Fapi\u002Ftui#hooks",[18,378,290],{}," for every event and what each carries.",[381,382,383],"style",{},"html pre.shiki code .sOLPB, html code.shiki .sOLPB{--shiki-default:#6A9955}html pre.shiki code .scz_3, html code.shiki .scz_3{--shiki-default:#569CD6}html pre.shiki code .s9McN, html code.shiki .s9McN{--shiki-default:#4FC1FF}html pre.shiki code .sTNBD, html code.shiki .sTNBD{--shiki-default:#D4D4D4}html pre.shiki code .sNl3T, html code.shiki .sNl3T{--shiki-default:#4EC9B0}html pre.shiki code .s3F5K, html code.shiki .s3F5K{--shiki-default:#9CDCFE}html pre.shiki code .sCudf, html code.shiki .sCudf{--shiki-default:#DCDCAA}html pre.shiki code .sKc5r, html code.shiki .sKc5r{--shiki-default:#CE9178}html pre.shiki code .sYbnZ, html code.shiki .sYbnZ{--shiki-default:#C586C0}html pre.shiki code .svVle, html code.shiki .svVle{--shiki-default:#D7BA7D}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":28,"searchDepth":42,"depth":42,"links":385},[386,387],{"id":284,"depth":42,"text":285},{"id":321,"depth":42,"text":322},"Lifecycle code. Every .ts file in here loads on launch — no import, no export, no\nwrapper.","md",{"icon":391},"vscode-icons:folder-type-plugin","\u002Fdocs\u002Fv2\u002Ftui\u002Fstructure\u002Fplugins",{"title":5,"description":388},"docs\u002Fv2\u002Ftui\u002Fstructure\u002Fplugins","QQmCYTt3tn-wQM6vAFvubizfjEFTnX6pV4QIru6PAfk",1786791207933]