This page walks you through writing an extension from scratch. It shows how many times the Agent has called tools in this session in the status band, plus a button that fills that count into the message box. You write the code in your editor, and the Agent handles init, testing, preview, and install.An extension can display content in two places:The plugin name must start with a lowercase letter and contain only lowercase letters and digits, joined by single Each session has its own development folder. The template runs as is. See A minimal extension for its contents.Then write the extension module: a Key points:The test sets the count directly through The first preview shows a permission card:Installing copies the development folder to The status band and panel disappear right away, the module unloads, and bundled MCP servers stop. Your files and saved data stay, and you can bring it back with another The code in that folder wasn’t written in this session, so:
- Status band: the strip above the message box, inside its border. All plugins share one band, and each draws a line or two in it. Its site name in code is
above-prompt. This page’s example draws here. - Panel: a tab in the conversation’s side panel on the right, next to tabs such as Files and Browser. Its site name in code is
pane.
Before you start
You develop extensions through the Agent’sextension tool. The tool has 5 actions:The Agent runs validation and tests for you. Each step is one sentence to the Agent.You need:
- MiniMax Code Desktop, working in a local session in the main window. See Where it runs.
- An editor that supports TypeScript, for type hints.
Generate the template
Tell the Agent (start with/extension-creator so the Agent follows the extension workflow):-, _, or . characters. It can be up to 80 characters long.The Agent returns the development folder, packagePath, at:init generates these files:Write the code
Open the development folder in your editor. With.minimax-plugin/types/ in place, the editor shows type hints and errors. Replace the two files below.First, declare the session state: a count that starts at 0.hooks/state.ts
tool.call observe event does the counting, and a ui.render hook draws the status band.hooks/register.tsx
- Keep the count in
ctx.state. It’s session state, and each session has its own copy. Don’t store session data in module-level variables, because all sessions share them. - Observe events don’t need a manual redraw. Drawing reads
toolCalls, so when the hook writes it, the host redraws the status band. ctx.prompt.fillnever sends for you. The defaultreplacemode only writes when the message box is empty. If there’s already text, it leaves it alone and returns{ written: false, reason: 'draft' }. The other tworeasonvalues aremodal(a dialog is open) andno-composer(no message box responded). To add after existing text, passmode: 'append'.- A button’s
onPressuses the enclosing hook’sctxthrough a closure. Writectxout in full and don’t destructure it. - Don’t leave out
await next(). Without it, the plugins after you can’t draw (EXTENSION_SHADOWING).
Preview only transpiles the code and runs static checks. It doesn’t type-check. Look for type errors in your editor. If you have TypeScript installed, you can also run
npx tsc -p .minimax-plugin/types in the development folder yourself.Add a test while you’re at it
test runs every *.test.tsx under hooks/. The template’s hooks/register.test.tsx checks the template button, so it fails once you change the code. Replace it with this:hooks/register.test.tsx
state and checks what the status band shows and what the button does. See Test and troubleshoot for more.Test
Tell the Agent:test first validates the package with the same rules as preview, then runs all tests. If a test fails or there are diagnostics, fix the code using the fix in each diagnostic and ask the Agent to test again until everything passes. See Diagnostic codes for what each code means.Preview
Tell the Agent:- Only this chat: later previews in this session (including other plugins) won’t ask again.
- Always allow: previews in all sessions won’t ask again.
Try it
Ask the Agent to do something that calls tools, such as “show me which files are in the current folder”. Each tool call in that turn adds one to the count in the status band.Click “Fill message box” and the count appears in the message box. If the message box already has text, you see “The message box already has text, so it was left as is”.Make changes
Once the preview is active, changes reload automatically and silently at the end of each turn, including newly added MCP servers, and you won’t be asked again. File changes don’t take effect in the middle of a turn.- If the Agent changes the code, it loads when the turn ends.
- If you change files in your editor yourself, send a message and wait for that turn to end, or ask the Agent to
previewagain.
Check diagnostics
When the extension doesn’t behave as expected, tell the Agent:inspect returns three parts:A hook that fails or times out 3 times in a row is paused in this session. If the paused hook is a drawing and no other plugin still draws in the same place, the status band shows “Paused · this session” and “Retry”. A paused observe hook shows no notice: in this example, if the
tool.call hook is paused, the count just stops going up. Ask the Agent to inspect and look for disabled hooks under runtime. Once you’ve fixed it, preview again. See Test and troubleshoot to troubleshoot by symptom.Install
A preview only works in the current session. To run the extension in all sessions, tell the Agent:<dataDir>/plugins/tool-counter/, without .minimax-plugin/types/. Before copying, the Agent sends you a message listing what the extension will add: the sites it draws, the MCP servers in calls:, the commands for bundled MCP servers that will start as processes, and the registered observe events.After install, the extension runs in all local sessions. Once the current session’s preview matches the installed version, the preview steps aside for the installed version. Like other plugins, you disable or uninstall an installed extension in plugin management.Installing means you trust the package, including any later changes to the installed copy. For day-to-day development, make changes in the development folder, check them with a preview, then install.
Withdraw a preview
When you no longer want the preview, tell the Agent:preview. withdraw only handles previews. To disable or uninstall an installed extension, go to plugin management.Preview a package in another folder
test and preview read the development folder returned by init by default. To preview a package somewhere else, such as a folder you got from someone else, ask the Agent to pass sourcePath (an absolute path):testshows a separate permission card asking whether to run the code in that folder. Once you allow it, this session stops asking about any extension test.previewneeds permission as usual.
sourcePath points to.Next steps
Interface: sites and elements
The status band height limit, opening and closing the panel, and the elements you can use.
Events (hooks)
What’s in
tool.call, turn.complete, and other events.Extension API
Fill text into the message box, call MCP, and call the model.
Test and troubleshoot
The test API and troubleshooting by symptom.