|
| 1 | +# Regex Lab (`regex-lab`) |
| 2 | + |
| 3 | +A live regular-expression workbench that runs inside MiniMax Code. Type a pattern and some |
| 4 | +sample text, watch every match appear with its capture groups and named groups, and preview a |
| 5 | +replacement — all computed by the Mini App's own Node backend. Nothing is sent anywhere; the text |
| 6 | +never leaves the app. |
| 7 | + |
| 8 | +## What it does |
| 9 | + |
| 10 | +- **Live matching** against the sample text, with match position (`index`–`end`), the matched |
| 11 | + substring, numbered capture groups, and named capture groups. |
| 12 | +- **Replacement preview** using the standard `$1`, `$<name>`, `$$`, `$&`, `` $` ``, `$'` tokens. |
| 13 | +- **Flag toggles** for `g` / `i` / `m` / `s` / `u` / `y`, with a plain-text flag box if you prefer |
| 14 | + to type them. |
| 15 | +- **Invalid-pattern feedback** — a bad regex shows the engine's error instead of failing silently. |
| 16 | + |
| 17 | +The computation lives in `miniapp/node/regex-engine.mjs` (pure functions, no DOM), shared by the |
| 18 | +Node HTTP API and the unit tests, so the logic you see is the logic that runs. |
| 19 | + |
| 20 | +## Install |
| 21 | + |
| 22 | +Copy this directory, including the hidden `.minimax-plugin/`, into the MiniMax Code plugins |
| 23 | +directory as `regex-lab/` (`~/.minimax/plugins/regex-lab/` by default). Restart MiniMax Code and |
| 24 | +ask the Agent to "Open Regex Lab" (or "打开 Regex Lab 正则测试器"). |
| 25 | + |
| 26 | +## Tested environment |
| 27 | + |
| 28 | +- Validated locally with Node.js 22: `node scripts/validate.mjs plugins/lym308758/regex-lab` reports |
| 29 | + no errors, and `node --test plugins/lym308758/regex-lab/tests/` passes (engine + HTTP handler). |
| 30 | +- **Not verified in the MiniMax Code host UI**: this environment has no MiniMax Code desktop client, |
| 31 | + so the page was not opened inside the side panel and the in-app rendering/click-through was not |
| 32 | + exercised end to end. The Node backend (page serving + `/api/match` + `/api/replace`) is covered |
| 33 | + by `tests/server.test.mjs` against a real `node:http` server, and the regex engine by |
| 34 | + `tests/regex-engine.test.mjs`. |
| 35 | + |
| 36 | +## Data & access |
| 37 | + |
| 38 | +- **Files:** reads only its own `miniapp/client/index.html` to serve the page. Writes nothing. |
| 39 | +- **Network:** none beyond the Host loopback that serves the page and the JSON API to the page. |
| 40 | +- **Processes:** none spawned. |
| 41 | +- **Agent turns:** none; the Mini App declares no `agentAccess`. |
| 42 | +- **State:** none stored. Each evaluation runs on the text you paste into the page. |
| 43 | + |
| 44 | +## Files |
| 45 | + |
| 46 | +```text |
| 47 | +.minimax-plugin/plugin.json Plugin manifest |
| 48 | +package.json Mini App declaration |
| 49 | +miniapp/miniapp.json Payload roots, Node entry, page route |
| 50 | +miniapp/client/index.html The page served at /dashboard |
| 51 | +miniapp/node/server.mjs Node entry: start(context) -> { dispose } and the JSON API |
| 52 | +miniapp/node/regex-engine.mjs Pure regex functions (match / replace), shared with the tests |
| 53 | +icon.png Plugin icon |
| 54 | +tests/regex-engine.test.mjs Engine unit tests |
| 55 | +tests/server.test.mjs HTTP handler + start() lifecycle tests |
| 56 | +README.md This file |
| 57 | +README.zh-CN.md Chinese README |
| 58 | +LICENSE MIT |
| 59 | +``` |
| 60 | + |
| 61 | +## License |
| 62 | + |
| 63 | +[MIT](./LICENSE) |
0 commit comments