From 280e0a9a00a82f2577285a64a062cb28f063a26a Mon Sep 17 00:00:00 2001 From: skypata Date: Tue, 1 Dec 2026 22:03:41 +0800 Subject: [PATCH] Add prompt-enhancer Mini App --- README.md | 1 + README.zh-CN.md | 1 + .../.minimax-plugin/plugin.json | 17 + plugins/skypata/prompt-enhancer/LICENSE | 21 + plugins/skypata/prompt-enhancer/README.md | 69 +++ .../skypata/prompt-enhancer/README.zh-CN.md | 60 +++ plugins/skypata/prompt-enhancer/icon.png | Bin 0 -> 1574 bytes .../prompt-enhancer/miniapp/client/app.js | 215 +++++++++ .../prompt-enhancer/miniapp/client/index.html | 55 +++ .../prompt-enhancer/miniapp/client/styles.css | 202 +++++++++ .../prompt-enhancer/miniapp/miniapp.json | 27 ++ .../miniapp/node/prompts/system-prompt.md | 27 ++ .../node/prompts/user-prompt-template.md | 26 ++ .../prompt-enhancer/miniapp/node/server.mjs | 412 ++++++++++++++++++ plugins/skypata/prompt-enhancer/package.json | 6 + 15 files changed, 1139 insertions(+) create mode 100644 plugins/skypata/prompt-enhancer/.minimax-plugin/plugin.json create mode 100644 plugins/skypata/prompt-enhancer/LICENSE create mode 100644 plugins/skypata/prompt-enhancer/README.md create mode 100644 plugins/skypata/prompt-enhancer/README.zh-CN.md create mode 100644 plugins/skypata/prompt-enhancer/icon.png create mode 100644 plugins/skypata/prompt-enhancer/miniapp/client/app.js create mode 100644 plugins/skypata/prompt-enhancer/miniapp/client/index.html create mode 100644 plugins/skypata/prompt-enhancer/miniapp/client/styles.css create mode 100644 plugins/skypata/prompt-enhancer/miniapp/miniapp.json create mode 100644 plugins/skypata/prompt-enhancer/miniapp/node/prompts/system-prompt.md create mode 100644 plugins/skypata/prompt-enhancer/miniapp/node/prompts/user-prompt-template.md create mode 100644 plugins/skypata/prompt-enhancer/miniapp/node/server.mjs create mode 100644 plugins/skypata/prompt-enhancer/package.json diff --git a/README.md b/README.md index 86551113..e4c446ad 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ The MiniMax Code Agent communicates through the host MCP client. Business reques | MiniApp | What it does | Author | | --- | --- | --- | +| [Prompt Enhancer](plugins/skypata/prompt-enhancer/) | Rewrite a one-line request into a complete prompt for a coding assistant; the model list and reasoning levels come from MiniMax Code's own configuration, and the rewrite runs on your signed-in account | [skypata](https://github.com/skypata) | | [Postman Lite](plugins/ssugarr/postman-lite/) | A lightweight local API request tool: build requests, send them through a local proxy that sidesteps browser CORS limits, and inspect responses, with collections kept as plain JSON | [ssugarr](https://github.com/ssugarr) | | [Weekly Planner](plugins/alanhean/weekly-planner/) | A local weekly planner: add tasks with a date and a priority, review them day by day, tick them off, and track the week's completion rate | [Alanhean](https://github.com/Alanhean) | | [天气 · 新闻看板](plugins/lixiangroir-ideal/weather-news-board/) | One dashboard page for live weather, A-share and gold, silver, crude oil and Bitcoin quotes, and six switchable news columns, with precious metals always shown in CNY per gram | [lixiangroir-Ideal](https://github.com/lixiangroir-Ideal) | diff --git a/README.zh-CN.md b/README.zh-CN.md index 3178b68a..87fede4a 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -57,6 +57,7 @@ MiniMax Code Agent 通过宿主 MCP 客户端与 MiniApp 协作。业务请求 | MiniApp | 功能 | 作者 | | --- | --- | --- | +| [提示词增强器](plugins/skypata/prompt-enhancer/) | 把一句话改写成可以直接交给编码助手的完整提示词,模型清单与推理等级取自 MiniMax Code 自己的配置,改写走你已登录的账号 | [skypata](https://github.com/skypata) | | [Postman Lite](plugins/ssugarr/postman-lite/README.zh-CN.md) | 轻量的本地 API 请求工具:构建请求、通过本地代理转发(绕过浏览器 CORS 限制)、查看响应,集合以纯 JSON 保存 | [ssugarr](https://github.com/ssugarr) | | [周计划](plugins/alanhean/weekly-planner/README.zh-CN.md) | 本地周计划:手动录入任务、日期与优先级,按天查看安排,勾选完成并跟踪本周完成率 | [Alanhean](https://github.com/Alanhean) | | [天气 · 新闻看板](plugins/lixiangroir-ideal/weather-news-board/) | 一个看板页同时看实时天气、A 股与黄金白银原油比特币行情、六个可切换的新闻栏目,贵金属统一按人民币每克显示 | [lixiangroir-Ideal](https://github.com/lixiangroir-Ideal) | diff --git a/plugins/skypata/prompt-enhancer/.minimax-plugin/plugin.json b/plugins/skypata/prompt-enhancer/.minimax-plugin/plugin.json new file mode 100644 index 00000000..9d062ab2 --- /dev/null +++ b/plugins/skypata/prompt-enhancer/.minimax-plugin/plugin.json @@ -0,0 +1,17 @@ +{ + "schemaVersion": 1, + "name": "prompt-enhancer", + "displayName": "提示词增强器", + "version": "1.0.0", + "description": "把一句话改写成可直接提交给编码助手的完整提示词;模型清单取自 MiniMax Code 自己的配置。", + "author": "skypata", + "icon": "icon.png", + "category": "Productivity", + "exampleQueries": [ + "打开提示词增强器", + "把这句需求改写成完整提示词" + ], + "apps": [], + "mcpServers": [], + "skills": [] +} diff --git a/plugins/skypata/prompt-enhancer/LICENSE b/plugins/skypata/prompt-enhancer/LICENSE new file mode 100644 index 00000000..efdbf19f --- /dev/null +++ b/plugins/skypata/prompt-enhancer/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 skypata + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/plugins/skypata/prompt-enhancer/README.md b/plugins/skypata/prompt-enhancer/README.md new file mode 100644 index 00000000..d075f044 --- /dev/null +++ b/plugins/skypata/prompt-enhancer/README.md @@ -0,0 +1,69 @@ +# Prompt Enhancer (`prompt-enhancer`) + +Rewrite a one-line request into a complete prompt you can hand straight to a coding assistant. + +The rewrite template is fixed and bundled with the app: it keeps your language, never answers the +request, and expands it into scope, deliverable, format and acceptance criteria. The model list and +the reasoning levels come from MiniMax Code's own runtime configuration, and each rewrite runs +through the local `mcode` CLI, so it uses the account you are already signed in to. + +The page is deliberately small: one text box, one model picker, one send button. After a rewrite the +text box holds the rewritten prompt and an undo button appears in its corner; one click puts your +original sentence back. + +## Install + +Copy this directory, including the hidden `.minimax-plugin/`, into the MiniMax Code plugins +directory as `prompt-enhancer/` (`~/.minimax/plugins/prompt-enhancer/` by default; the root +README's Install section explains where that directory is). Restart MiniMax Code and ask the Agent to +"Open Prompt Enhancer". + +The `mcode` CLI ships with MiniMax Code and must be reachable from the app's process. If it is +missing, the app reports "找不到 mcode 命令" instead of failing silently. + +## Tested environment + +- MiniMax Code 3.1.20 on macOS 15.8.1 (arm64), installed from this directory and opened through the + Agent. +- Client acceptance exercised: the model list loaded from the runtime configuration; the model + picker opened and drilled from models into reasoning levels; a rewrite round-tripped - original + sentence in, rewritten prompt out, undo restored the original sentence; the selected reasoning + level reached the CLI as `--effort`. +- Not verified: Windows; a host with no configured model; a host where the `mcode` CLI is not on + PATH. + +## Data & access + +- Files: reads the MiniMax Code runtime configuration file `config.yaml` to build the model list. + It is located through `MAVIS_DATA_DIR`, `MINIMAX_DATA_DIR`, `__MAVIS_PARENT_DATA_DIR` or + `MCODE_CONFIG_DIR`, otherwise `~/.minimax/config.yaml`. **That layout is not a supported API + and may change between releases.** Nothing else is read. Nothing is written outside the + Host-provided data directory. +- Network: the page makes no network requests of its own. The spawned `mcode` CLI talks to your + own MiniMax Code account and provider. +- Processes: spawns the `mcode` CLI (`mcode exec`) once per rewrite and waits for it. The child is + killed on timeout and when the board is disposed. The temporary file it writes stays in the + Host-provided data directory and is deleted right after it is read. +- Agent turns: none. Conversations read: none. Tools called: none. +- Microphone, camera and notifications: none. Host navigation read: none. +- State: the typed text is kept in the page's local storage as view state and restored on reload. + Nothing else is stored. + +## Files + +```text +.minimax-plugin/plugin.json Plugin manifest +package.json Mini App declaration +miniapp/miniapp.json Payload roots, Node entry, page route +miniapp/client/index.html The page served at /dashboard +miniapp/client/styles.css Page styles +miniapp/client/app.js Page behaviour: model picker, rewrite, undo +miniapp/node/server.mjs Node entry: start(context) -> { dispose } +miniapp/node/prompts/system-prompt.md The fixed rewrite system prompt +miniapp/node/prompts/user-prompt-template.md The fixed rewrite user template +icon.png Plugin icon +``` + +## License + +[MIT](./LICENSE) diff --git a/plugins/skypata/prompt-enhancer/README.zh-CN.md b/plugins/skypata/prompt-enhancer/README.zh-CN.md new file mode 100644 index 00000000..27e0df1d --- /dev/null +++ b/plugins/skypata/prompt-enhancer/README.zh-CN.md @@ -0,0 +1,60 @@ +# 提示词增强器 (`prompt-enhancer`) + +把一句话改写成可以直接交给编码助手的完整提示词。 + +[English](./README.md) | 简体中文 + +改写模板固定内置在应用里:保持你的语言、不替你作答,把请求展开成范围、交付物、格式和验收标准。 +可用模型与推理等级来自 MiniMax Code 自己的运行时配置,每次改写都通过本机 `mcode` CLI 执行, +用的是你已经登录的账号。 + +界面刻意做得很小:一个输入框、一个模型选择器、一个发送按钮。改写完成后输入框里就是改写后的 +提示词,右上角会出现一个撤销按钮,点一下就把你原来那句放回去。 + +## 安装 + +把本目录(含隐藏的 `.minimax-plugin/`)复制到 MiniMax Code 的插件目录,命名为 +`prompt-enhancer/`(默认是 `~/.minimax/plugins/prompt-enhancer/`,具体位置见根 README 的 +Install 一节)。重启 MiniMax Code 后让 Agent "打开提示词增强器"。 + +`mcode` CLI 随 MiniMax Code 一起安装,必须能被应用进程找到;找不到时页面会提示 +"找不到 mcode 命令",不会静默失败。 + +## 测试环境 + +- MiniMax Code 3.1.20,macOS 15.8.1(arm64),从本目录安装并通过 Agent 打开。 +- 客户端验收覆盖:模型清单从运行时配置读出;模型选择器可从模型下钻到推理等级;一次改写完整 + 往返(输入原句 → 得到改写提示词 → 撤销恢复原句);所选推理等级以 `--effort` 传给 CLI。 +- 未验证:Windows;没有配置任何模型的宿主;`mcode` CLI 不在 PATH 上的宿主。 + +## 数据与权限 + +- 文件:读取 MiniMax Code 的运行时配置文件 `config.yaml` 来生成模型清单,位置由 + `MAVIS_DATA_DIR`、`MINIMAX_DATA_DIR`、`__MAVIS_PARENT_DATA_DIR` 或 `MCODE_CONFIG_DIR` + 决定,否则是 `~/.minimax/config.yaml`。**该布局不是受支持的 API,可能随版本变化。** + 不读其他文件,也不往宿主给的数据目录之外写任何东西。 +- 网络:页面自身不发网络请求;被拉起的 `mcode` CLI 走你自己已登录的 MiniMax Code 账号与服务商。 +- 进程:每次改写拉起一次 `mcode` CLI(`mcode exec`)并等待其结束;超时或应用被停止时会结束 + 该子进程。它写出的临时文件留在宿主给的数据目录里,读取后立即删除。 +- Agent 回合:无。读取的会话:无。调用的工具:无。 +- 麦克风、相机、通知:无。读取宿主导航:无。 +- 状态:输入的文本作为视图状态存在页面 localStorage 里,重载后恢复;不保存其它内容。 + +## 文件 + +```text +.minimax-plugin/plugin.json 插件清单 +package.json Mini App 声明 +miniapp/miniapp.json 运行时载荷根、Node 入口、页面路由 +miniapp/client/index.html /dashboard 上返回的页面 +miniapp/client/styles.css 页面样式 +miniapp/client/app.js 页面逻辑:模型选择、改写、撤销 +miniapp/node/server.mjs Node 入口:start(context) -> { dispose } +miniapp/node/prompts/system-prompt.md 固定的改写 system 提示词 +miniapp/node/prompts/user-prompt-template.md 固定的改写 user 提示词模板 +icon.png 插件图标 +``` + +## 许可证 + +[MIT](./LICENSE) diff --git a/plugins/skypata/prompt-enhancer/icon.png b/plugins/skypata/prompt-enhancer/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..299a26cbf5c1427dffa9cd575cf721307d570765 GIT binary patch literal 1574 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7xzrV7=|>;uumf=gr;N9Fb5F_7BDH zN*t40jx3m@A#jD`h{82~A;W#9hIKB=6V;QM-fp_!Iw3Du_^7z>7spdwD|5UT=(0U- z4vcs42{>&0A!&-l#UFng7Vv9zUfN`Qd~;|s@7+uz9O)JMQ;7Q z+VlNc*1f)P;(=w;neIK@5%Dq?bm#T^{r{9*@ia!gnj^~T2}4Q1*Th_Vu`>}GpIDCO z#4fN@Vt4rd)BClU(Q~fW#@QT3`o97jTK?xMOo;EM)AkEGZ>^la!>4}Tg|#orV!ID- z4G8cmi29Kul*I@Nov(+hUWIHbj*XAkN|#&6e?ev6^ZSxvcK?~yFA_-*H<;a0#(2g^ zzl72KdH~l2CW&?ibaY*)m{GcGsq4HCVQW8`+3MMAA9>%$$6x1gcEXjIh6=|UTHH*2 zPm^w)+0I})`*&FN5&Nu1Y+r6yc*L8(Sa9m$yrfKZ#~fa1&NHPdC8Y+RdyG?WF};29 zt~O0_E62oyX%mAzpJu)CiI9%EV`HT-k0aLM2a{@p^XrK&uP*%0esO=1w)UU=+zCGMvNmy= z|6P>ouW5@p2v)su`cxCfV?$ymt*7pfdX*%ncOdCuPzej4`!;F|NW(R z>9S1?D}6X`#NYh7GVkf}bgjz@`%TThovQS5e3ma}8>P8_foSNz|MS*u5I(ouy{)ZH zDAVlt_qYF?TCQcTsM{ODK6ko9)iJH7$x{Rh??u)A%=k6?)3WE!yQWM!akgaN_W!DX z-#&jmHN3X`^}*WR`-q(SpO3zY`t01fRdCqjHPcc83_B1GbPU2zNIsfpf)(T$7XRi5-O#h75#2n`^6HJMF!qC&lGw+h(&G*h? zk*k_rMVov+YqaeSTOYYZzjSt0F6+COd#ca&eqZ;_rtH&`lb%gyI!#lfHFBb5N}kls z$lZDCNY^>py$dH>z2A9YX;J*2GNpMejVH=I&vYJ{xB2|{X>r$mYq=dibJoiERAfK) zQ9W)K_T5@<--_8kB%7Wkzk0OuD!*pi4Mquhsb5FS-xaZWR zZ|9tq^y-Rf{wEFBD;u8QSW~|%f9dnxxlsofN1ZNZ>HPit!>su-YkBth3z|N4bh|s- zYxS08(KkMRy%ipDKxc+#k7En7+RrklI~Sdmo1bg6`PiN0n#CTy2vIV@izrM+Ju?Ht m|NpbhtN4MXJsYT)XJ&Z(ZtAoneFio_5e83JKbLh*2~7YK=FPVN literal 0 HcmV?d00001 diff --git a/plugins/skypata/prompt-enhancer/miniapp/client/app.js b/plugins/skypata/prompt-enhancer/miniapp/client/app.js new file mode 100644 index 00000000..be410832 --- /dev/null +++ b/plugins/skypata/prompt-enhancer/miniapp/client/app.js @@ -0,0 +1,215 @@ +(function () { + var $ = function (id) { return document.getElementById(id); }; + var state = { models: [], pick: { model: '', level: '' }, stage: 'model', previous: null }; + var STORAGE_KEY = 'prompt-enhancer-input'; + var ERROR_TEXT = { + empty_input: '请先输入提示词', + text_too_long: '提示词过长', + model_unavailable: '没有可用模型', + cli_unavailable: '找不到 mcode 命令', + empty_response: '模型没有返回可用结果', + timeout: '模型调用超时', + cancelled: '已取消', + internal_error: '服务端错误' + }; + + function setStatus(message, kind) { + var node = $('run-status'); + node.textContent = message || ''; + node.className = 'status' + (kind ? ' ' + kind : ''); + } + + function api(path, options) { + return fetch(path, options).then(function (response) { + return response.json().catch(function () { return null; }).then(function (payload) { + if (!response.ok) { + var failure = new Error((payload && payload.error) || ('HTTP_' + response.status)); + failure.payload = payload; + throw failure; + } + return payload; + }); + }); + } + + function shortName(id) { + return id.split('/').pop(); + } + + function selectedModel() { + for (var i = 0; i < state.models.length; i++) { + if (state.models[i].id === state.pick.model) return state.models[i]; + } + return null; + } + + function updateLabel() { + var model = selectedModel(); + var text = model ? shortName(model.id) : '选择模型'; + if (model && state.pick.level) text += ' · ' + state.pick.level; + $('pick-label').textContent = text; + } + + function row(text, tail, onClick) { + var button = document.createElement('button'); + button.type = 'button'; + button.className = 'pick-row'; + var label = document.createElement('span'); + label.textContent = text; + button.appendChild(label); + if (tail) { + var right = document.createElement('span'); + right.className = 'pick-tail'; + right.textContent = tail; + button.appendChild(right); + } + button.addEventListener('click', onClick); + return button; + } + + // 弹层默认向下展开;下方空间不够时翻到上方,避免被视口裁掉。 + function positionMenu() { + var menu = $('pick-menu'); + var picker = $('picker'); + var room = window.innerHeight - picker.getBoundingClientRect().bottom; + menu.classList.toggle('up', room < 280); + } + + function openMenu() { + showStage('model'); + $('pick-menu').hidden = false; + $('pick-btn').setAttribute('aria-expanded', 'true'); + positionMenu(); + } + + function closeMenu() { + $('pick-menu').hidden = true; + $('pick-btn').setAttribute('aria-expanded', 'false'); + } + + // 两个容器各自渲染一次,切换层级不重建被点的那一行(重建会把它从 DOM 摘掉, + // 事件冒泡到 document 时 closest('.picker') 会失配,把菜单误关)。 + function showStage(stage) { + state.stage = stage; + if (stage === 'model') { + $('pick-models').hidden = false; + $('pick-levels').hidden = true; + $('pick-head').hidden = true; + return; + } + $('pick-models').hidden = true; + $('pick-levels').hidden = false; + $('pick-head').hidden = false; + $('pick-head').textContent = shortName(state.pick.model); + var list = $('pick-levels'); + list.textContent = ''; + var model = selectedModel(); + (model && model.efforts ? model.efforts : []).forEach(function (level) { + list.appendChild(row(level, level === state.pick.level ? '✓' : '', function () { + state.pick.level = level; + updateLabel(); + closeMenu(); + })); + }); + } + + function buildModelRows() { + var list = $('pick-models'); + list.textContent = ''; + state.models.forEach(function (item) { + var levels = item.efforts || []; + list.appendChild(row(shortName(item.id), levels.length ? '›' : '', function () { + state.pick.model = item.id; + if (levels.length) { + state.pick.level = state.pick.level || item.defaultEffort || levels[0]; + showStage('level'); + updateLabel(); + return; + } + state.pick.level = ''; + updateLabel(); + closeMenu(); + })); + }); + } + + function loadModels() { + return api('/api/models').then(function (result) { + state.models = result.models || []; + state.models.forEach(function (item) { + if (item.id === result.defaultModel) { + state.pick.model = item.id; + state.pick.level = (item.efforts || []).length ? (item.defaultEffort || item.efforts[0]) : ''; + } + }); + buildModelRows(); + updateLabel(); + }).catch(function (error) { + setStatus('读取模型失败:' + (ERROR_TEXT[error.message] || error.message), 'error'); + }); + } + + function send() { + var input = $('input-text'); + var text = input.value.trim(); + var button = $('send-btn'); + if (!text) { setStatus(ERROR_TEXT.empty_input, 'error'); return; } + if (!state.pick.model) { setStatus(ERROR_TEXT.model_unavailable, 'error'); return; } + + setStatus('正在增强…'); + button.disabled = true; + api('/api/enhance', { + method: 'POST', + headers: { 'content-type': 'application/json' }, + body: JSON.stringify({ text: text, model: state.pick.model, effort: state.pick.level }) + }).then(function (result) { + if (result.error) { + setStatus((ERROR_TEXT[result.error] || result.error) + (result.detail ? (':' + result.detail) : ''), 'error'); + return; + } + state.previous = text; + $('undo-btn').hidden = false; + input.value = result.text || ''; + input.focus(); + setStatus('已增强 · ' + Math.round((result.durationMs || 0) / 100) / 10 + ' 秒', ''); + }).catch(function (error) { + setStatus((ERROR_TEXT[error.message] || error.message) + (error.payload && error.payload.detail ? (':' + error.payload.detail) : ''), 'error'); + }).then(function () { + button.disabled = false; + }); + } + + $('pick-btn').addEventListener('click', function () { + if ($('pick-menu').hidden) openMenu(); else closeMenu(); + }); + $('undo-btn').addEventListener('click', function () { + if (state.previous === null) return; + $('input-text').value = state.previous; + state.previous = null; + $('undo-btn').hidden = true; + $('input-text').focus(); + }); + $('send-btn').addEventListener('click', send); + $('input-text').addEventListener('keydown', function (event) { + if (event.key === 'Enter' && (event.metaKey || event.ctrlKey)) { + event.preventDefault(); + send(); + } + }); + document.addEventListener('keydown', function (event) { + if (event.key === 'Escape') closeMenu(); + }); + // 不做"点外面关闭":Electron 的 webview 会额外派发一次文档级点击, + // 那种点击会让菜单直接消失。菜单只在明确选择、再次点按钮或按 Esc 时关闭。 + document.addEventListener('visibilitychange', function () { + if (document.visibilityState !== 'hidden') return; + try { + localStorage.setItem(STORAGE_KEY, $('input-text').value); + } catch (error) { /* 视图状态存不进去不影响使用 */ } + }); + + try { + $('input-text').value = localStorage.getItem(STORAGE_KEY) || ''; + } catch (error) { /* 忽略损坏的视图状态 */ } + loadModels(); +})(); diff --git a/plugins/skypata/prompt-enhancer/miniapp/client/index.html b/plugins/skypata/prompt-enhancer/miniapp/client/index.html new file mode 100644 index 00000000..8a5caca8 --- /dev/null +++ b/plugins/skypata/prompt-enhancer/miniapp/client/index.html @@ -0,0 +1,55 @@ + + + + + + 提示词增强器 + + + +
+
+ + +
+
+ +
+ + +
+ +
+
+ + + diff --git a/plugins/skypata/prompt-enhancer/miniapp/client/styles.css b/plugins/skypata/prompt-enhancer/miniapp/client/styles.css new file mode 100644 index 00000000..e9f3ef8d --- /dev/null +++ b/plugins/skypata/prompt-enhancer/miniapp/client/styles.css @@ -0,0 +1,202 @@ +:root, +[data-theme='light'] { + --mcode-bg: #ffffff; + --mcode-surface-muted: #fafafa; + --mcode-text: #171717; + --mcode-text-muted: #666666; + --mcode-text-subtle: #adadad; + --mcode-border: #0a0a0a14; + --mcode-accent: #0094fc; + --mcode-danger: #f73646; + --mcode-primary-action-bg: #171717; + --mcode-primary-action-text: #ffffff; +} +[data-theme='dark'] { + --mcode-bg: #171717; + --mcode-surface-muted: #262626; + --mcode-text: #ededed; + --mcode-text-muted: #949494; + --mcode-text-subtle: #666666; + --mcode-border: #ffffff14; + --mcode-accent: #0077d9; + --mcode-danger: #e31937; + --mcode-primary-action-bg: #ffffff; + --mcode-primary-action-text: #171717; +} +@media (prefers-color-scheme: dark) { + :root:not([data-theme='light']) { + --mcode-bg: #171717; + --mcode-surface-muted: #262626; + --mcode-text: #ededed; + --mcode-text-muted: #949494; + --mcode-text-subtle: #666666; + --mcode-border: #ffffff14; + --mcode-accent: #0077d9; + --mcode-danger: #e31937; + --mcode-primary-action-bg: #ffffff; + --mcode-primary-action-text: #171717; + } +} + +* { box-sizing: border-box; } +html, body { height: 100%; } +body { + margin: 0; + background: var(--mcode-bg); + color: var(--mcode-text); + font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', Arial, sans-serif; + font-size: 14px; + line-height: 1.65; +} +.stage { + display: flex; + flex-direction: column; + gap: 10px; + padding: 20px; +} +.input-wrap { + position: relative; + display: flex; + flex: 0 0 auto; + min-height: 0; +} +.undo-btn { + position: absolute; + top: 8px; + right: 8px; + display: inline-flex; + align-items: center; + justify-content: center; + width: 26px; + height: 26px; + padding: 0; + color: var(--mcode-text-muted); + background: var(--mcode-surface); + border: 1px solid var(--mcode-border); + border-radius: 8px; + cursor: pointer; +} +.undo-btn[hidden] { display: none; } +.undo-btn:hover { color: var(--mcode-text); } +.undo-btn:focus-visible { + outline: none; + border-color: var(--mcode-accent); + box-shadow: 0 0 0 2px color-mix(in srgb, var(--mcode-accent) 22%, transparent); +} +textarea { + flex: 0 0 auto; + width: 100%; + field-sizing: content; + min-height: 88px; + max-height: 60vh; + overflow-y: auto; + padding: 14px 44px 14px 16px; + font-family: inherit; + font-size: 15px; + line-height: 1.65; + color: var(--mcode-text); + background: var(--mcode-surface-muted); + border: 1px solid var(--mcode-border); + border-radius: 12px; + resize: none; +} +textarea::placeholder { color: var(--mcode-text-subtle); } +textarea:focus { + outline: none; + border-color: var(--mcode-accent); + box-shadow: 0 0 0 2px color-mix(in srgb, var(--mcode-accent) 22%, transparent); +} +.composer { + display: flex; + align-items: center; + justify-content: flex-end; + gap: 8px; + flex: 0 0 auto; +} +.status { + margin-right: auto; + font-size: 12px; + color: var(--mcode-text-muted); +} +.status.error { color: var(--mcode-danger); } +.picker { position: relative; } +.pick-btn { + display: inline-flex; + align-items: center; + gap: 6px; + height: 34px; + max-width: 320px; + padding: 0 10px; + font-family: inherit; + font-size: 13px; + color: var(--mcode-text); + background: var(--mcode-surface-muted); + border: 1px solid var(--mcode-border); + border-radius: 8px; + cursor: pointer; +} +.pick-btn:hover { opacity: .82; } +.pick-btn:focus-visible { + outline: none; + border-color: var(--mcode-accent); + box-shadow: 0 0 0 2px color-mix(in srgb, var(--mcode-accent) 22%, transparent); +} +.caret { color: var(--mcode-text-subtle); font-size: 11px; } +.pick-menu { + position: absolute; + right: 0; + top: calc(100% + 8px); + min-width: 200px; + max-height: min(60vh, 320px); + overflow-y: auto; + padding: 6px; + background: var(--mcode-surface); + border: 1px solid var(--mcode-border); + border-radius: 12px; + box-shadow: 0 0 20px rgb(10 10 10 / 12%); + z-index: 10; +} +.pick-menu.up { + top: auto; + bottom: calc(100% + 8px); +} +.pick-head { + padding: 6px 8px; + font-size: 12px; + color: var(--mcode-text-subtle); + border-bottom: 1px solid var(--mcode-border); +} +.pick-head:empty { display: none; } +.pick-row { + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px; + width: 100%; + height: 34px; + padding: 0 8px; + font-family: inherit; + font-size: 13px; + text-align: left; + color: var(--mcode-text); + background: transparent; + border: none; + border-radius: 8px; + cursor: pointer; +} +.pick-row:hover { background: var(--mcode-surface-muted); } +.pick-tail { color: var(--mcode-text-subtle); font-size: 12px; } +.btn { + height: 34px; + padding: 0 16px; + border-radius: 8px; + border: none; + cursor: pointer; + font-family: inherit; + font-size: 13px; + white-space: nowrap; + background: var(--mcode-primary-action-bg); + color: var(--mcode-primary-action-text); +} +.btn:hover:not(:disabled) { opacity: .82; } +.btn:disabled { opacity: .45; cursor: not-allowed; } diff --git a/plugins/skypata/prompt-enhancer/miniapp/miniapp.json b/plugins/skypata/prompt-enhancer/miniapp/miniapp.json new file mode 100644 index 00000000..f69daea8 --- /dev/null +++ b/plugins/skypata/prompt-enhancer/miniapp/miniapp.json @@ -0,0 +1,27 @@ +{ + "schemaVersion": 1, + "artifacts": { + "client": [ + "./miniapp/client" + ], + "node": [ + "./miniapp/node" + ] + }, + "runtime": { + "kind": "process", + "entry": "./miniapp/node/server.mjs", + "lifecycle": "on-demand" + }, + "surface": { + "path": "/dashboard", + "window": { + "width": 860, + "height": 720, + "minWidth": 480, + "minHeight": 360, + "resizable": true + } + }, + "mcpEndpoints": [] +} \ No newline at end of file diff --git a/plugins/skypata/prompt-enhancer/miniapp/node/prompts/system-prompt.md b/plugins/skypata/prompt-enhancer/miniapp/node/prompts/system-prompt.md new file mode 100644 index 00000000..aa71f403 --- /dev/null +++ b/plugins/skypata/prompt-enhancer/miniapp/node/prompts/system-prompt.md @@ -0,0 +1,27 @@ +You are a prompt engineer. You turn a short user request into a complete, self-contained prompt for a coding assistant. + +GOAL +Rewrite the request so the assistant can act on it without guessing. Keep the original intent, topic, constraints and expected output. + +HOW TO WORK +1. Identify the objective, the deliverable, and anything the request left implicit. +2. State the scope explicitly: what to produce, in what form, for whom, under which constraints. +3. Add the specifics a competent engineer would need to start - the area of the codebase, the environment, the acceptance bar - and only those. Never invent facts the request does not imply. +4. Keep the user's constraints intact. Do not weaken them, do not add unrelated requirements. +5. Prefer concrete nouns over vague ones: "the login module" beats "the relevant code". + +BOUNDARIES +- Rewrite the request. Never answer it. +- Do not introduce a technology, library, framework, database or approach the user did not mention. +- Do not append a tutorial, a how-to guide, a code sample or a list of alternatives unless the user asked for one. +- Do not pad the result with filler or repeat the request with different wording. +- The result must read as one prompt that is ready to send. + +LANGUAGE +Reply in the language the user wrote in. If they write Chinese, write Chinese; if English, write English; if they mix languages, keep that mix natural. Never mention the language choice. + +LENGTH +Information-dense, not verbose. Hard limit 800 characters. + +OUTPUT +Only the rewritten prompt. No preamble, no label, no commentary, no surrounding quotes. diff --git a/plugins/skypata/prompt-enhancer/miniapp/node/prompts/user-prompt-template.md b/plugins/skypata/prompt-enhancer/miniapp/node/prompts/user-prompt-template.md new file mode 100644 index 00000000..a4c29bd1 --- /dev/null +++ b/plugins/skypata/prompt-enhancer/miniapp/node/prompts/user-prompt-template.md @@ -0,0 +1,26 @@ +Rewrite the request below into a complete prompt for a coding assistant. + +USER REQUEST: +{input} + +REQUIREMENTS +1. Keep the user's language. If they write Chinese, write Chinese; if English, write English; if they mix languages, keep the mix natural. Never output a language label. +2. Keep their intent, topic, constraints and the kind of output they expect. Do not answer the request itself. +3. Make it specific: name the scope, the deliverable, the format, and the acceptance criteria that follow from the request. +4. Add no technology, library, framework, or step-by-step guide the request did not imply. +5. Stay complete and dense. No unfinished list, no dangling colon, no meta commentary. + +EXAMPLES + +Request: 帮我看看这段代码 +Rewritten: 请审查这段代码:说明它的整体职责与执行流程,标出逻辑缺陷、边界条件缺失和安全隐患,按严重程度排序,并对必须修复的问题给出最小改动方案与受影响的调用方;用中文输出。 + +Request: Make the API faster +Rewritten: Analyse this API's request path and identify the dominant latency sources - network, database queries, serialisation, cold starts. For each, state the expected gain, the change required and the regression risk, ordered by impact. Keep the public contract unchanged. Output a prioritised table plus a short paragraph per item. + +BAD OUTPUT - never produce this +User input is in Chinese -> Response must be in Chinese. +帮我看看这段代码 + +GOOD OUTPUT +请审查这段代码:说明它的整体职责与执行流程,标出逻辑缺陷、边界条件缺失和安全隐患,按严重程度排序,并对必须修复的问题给出最小改动方案与受影响的调用方;用中文输出。 diff --git a/plugins/skypata/prompt-enhancer/miniapp/node/server.mjs b/plugins/skypata/prompt-enhancer/miniapp/node/server.mjs new file mode 100644 index 00000000..65428dfb --- /dev/null +++ b/plugins/skypata/prompt-enhancer/miniapp/node/server.mjs @@ -0,0 +1,412 @@ +// @ts-check + +import { readFile, writeFile, rename, mkdir, unlink } from 'node:fs/promises'; +import { existsSync, statSync } from 'node:fs'; +import { createServer } from 'node:http'; +import { join, delimiter } from 'node:path'; +import { homedir } from 'node:os'; +import { spawn } from 'node:child_process'; + +const MAX_TEXT = 20000; +const MAX_BODY = 512 * 1024; +const RUN_TIMEOUT_MS = 180000; +const activeChildren = new Set(); + +// context 由 MiniMax Code 宿主注入:{ pluginRoot, dataDir, listen:{host,port}, signal, logger } +export async function start(context) { + const systemPromptPath = join(context.pluginRoot, 'miniapp/node/prompts/system-prompt.md'); + const userTemplatePath = join(context.pluginRoot, 'miniapp/node/prompts/user-prompt-template.md'); + await mkdir(join(context.dataDir, 'work'), { recursive: true }); + + const server = createServer((request, response) => { + const url = new URL(request.url ?? '/', 'http://miniapp.local'); + handle(context, request, response, url, { systemPromptPath, userTemplatePath }).catch((error) => { + context.logger.error('miniapp.request.failed', { path: url.pathname, message: String(error?.message ?? error) }); + if (!response.headersSent) json(response, 500, { error: 'internal_error' }); + }); + }); + + await listen(server, context.listen.host, context.listen.port); + context.logger.info('miniapp.runtime.listening'); + + let disposed = false; + const dispose = async () => { + if (disposed) return; + disposed = true; + context.signal.removeEventListener('abort', onAbort); + for (const child of activeChildren) child.kill('SIGKILL'); + activeChildren.clear(); + await close(server); + }; + const onAbort = () => { + void dispose(); + }; + context.signal.addEventListener('abort', onAbort, { once: true }); + if (context.signal.aborted) await dispose(); + + return { dispose }; +} + +async function handle(context, request, response, url, paths) { + const path = url.pathname.replace(/\/$/, '') || '/'; + + if (request.method === 'GET' && (path === '/' || path === '/dashboard')) { + const html = await readFile(join(context.pluginRoot, 'miniapp/client/index.html')); + response.writeHead(200, { 'content-type': 'text/html; charset=utf-8', 'cache-control': 'no-store' }); + response.end(html); + return; + } + + if (request.method === 'GET' && (path === '/styles.css' || path === '/app.js')) { + const file = path === '/styles.css' ? 'styles.css' : 'app.js'; + const type = file.endsWith('.css') ? 'text/css; charset=utf-8' : 'text/javascript; charset=utf-8'; + const body = await readFile(join(context.pluginRoot, 'miniapp/client', file)); + response.writeHead(200, { 'content-type': type, 'cache-control': 'no-store' }); + response.end(body); + return; + } + + if (request.method === 'GET' && path === '/api/models') { + const config = await readConfig(); + json(response, 200, { + defaultModel: config.defaultModel, + models: buildModelList(config), + source: config.path, + }); + return; + } + + if (request.method === 'POST' && path === '/api/enhance') { + const body = await readJson(request); + const text = typeof body?.text === 'string' ? body.text.trim() : ''; + if (!text) { + json(response, 400, { error: 'empty_input' }); + return; + } + if (text.length > MAX_TEXT) { + json(response, 400, { error: 'text_too_long', limit: MAX_TEXT }); + return; + } + const config = await readConfig(); + const available = buildModelList(config); + const requested = typeof body?.model === 'string' ? body.model.trim() : ''; + const model = available.find((item) => item.id === requested) ?? available.find((item) => item.id === config.defaultModel); + if (!model) { + json(response, 400, { error: 'model_unavailable' }); + return; + } + const entry = available.find((item) => item.id === model.id); + const requestedEffort = typeof body?.effort === 'string' ? body.effort.trim() : ''; + const effort = requestedEffort && (entry?.efforts ?? []).includes(requestedEffort) ? requestedEffort : ''; + const userTemplate = await readFile(paths.userTemplatePath, 'utf-8'); + const result = await runEnhance(context, model.id, effort, userTemplate.replace('{input}', text), paths.systemPromptPath); + json(response, 200, result); + return; + } + + json(response, 404, { error: 'not_found' }); +} + +// 调 mcode exec:模型走 MiniMax Code 自己的配置与登录,提示词模板固定内置。 +function runEnhance(context, modelId, effort, userPrompt, systemPromptPath) { + return new Promise((resolve) => { + const workDir = join(context.dataDir, 'work'); + const outFile = join(workDir, 'last-message-' + Date.now() + '-' + Math.random().toString(36).slice(2, 8) + '.txt'); + const bin = resolveMcodeBin(); + const args = [ + 'exec', + '--model', modelId, + '--system-prompt-file', systemPromptPath, + '--input', '-', + '--input-format', 'text', + '--cwd', workDir, + '--permission', 'off', + ...(effort && effort !== 'default' ? ['--effort', effort] : []), + '--max-steps', '1', + '--output-format', 'text', + '-o', outFile, + ]; + + const startedAt = Date.now(); + let child; + try { + child = spawn(bin, args, { cwd: workDir, env: process.env, stdio: ['pipe', 'ignore', 'pipe'] }); + } catch (error) { + resolve({ error: 'cli_unavailable', detail: String(error?.message ?? error) }); + return; + } + + activeChildren.add(child); + let stderr = ''; + let finished = false; + const finish = (payload) => { + if (finished) return; + finished = true; + clearTimeout(timer); + context.signal.removeEventListener('abort', onAbort); + void unlink(outFile).catch(() => undefined); + resolve(payload); + }; + + child.stderr.on('data', (chunk) => { + if (stderr.length < 2000) stderr += String(chunk); + }); + child.on('error', (error) => { + finish({ error: 'cli_unavailable', detail: String(error?.message ?? error) }); + }); + child.on('close', (code) => { + activeChildren.delete(child); + readFile(outFile, 'utf-8') + .then((content) => { + const text = stripWrappingQuotes(content); + if (!text) { + finish({ error: 'empty_response', detail: stderr.slice(0, 300) || ('CLI 退出码 ' + code) }); + return; + } + finish({ text, model: modelId, durationMs: Date.now() - startedAt }); + }) + .catch(() => { + finish({ error: 'empty_response', detail: stderr.slice(0, 300) || ('CLI 退出码 ' + code) }); + }); + }); + + const timer = setTimeout(() => { + child.kill('SIGTERM'); + setTimeout(() => child.kill('SIGKILL'), 2000).unref?.(); + finish({ error: 'timeout', detail: '模型调用超过 ' + Math.round(RUN_TIMEOUT_MS / 1000) + ' 秒' }); + }, RUN_TIMEOUT_MS); + + const onAbort = () => { + child.kill('SIGTERM'); + finish({ error: 'cancelled' }); + }; + context.signal.addEventListener('abort', onAbort, { once: true }); + + child.stdin.on('error', () => undefined); + child.stdin.write(userPrompt); + child.stdin.end(); + }); +} + +// 剥掉模型输出可能带的首尾成对引号。 +function stripWrappingQuotes(text) { + let value = String(text ?? '').trim(); + value = value.replace(/^["'“”‘’]/, ''); + value = value.replace(/["'“”‘’]$/, ''); + return value; +} + +function resolveMcodeBin() { + const candidates = []; + if (process.env.MCODE_BIN) candidates.push(process.env.MCODE_BIN); + if (process.env.MCODE_INSTALL_DIR) candidates.push(join(process.env.MCODE_INSTALL_DIR, 'bin', 'mcode')); + candidates.push(join(homedir(), '.minimax-code', 'bin', 'mcode')); + for (const dir of (process.env.PATH ?? '').split(delimiter)) { + if (dir) candidates.push(join(dir, 'mcode')); + } + for (const candidate of candidates) { + try { + if (existsSync(candidate) && statSync(candidate).isFile()) return candidate; + } catch { + // 忽略不可读的候选路径 + } + } + return 'mcode'; +} + +function resolveDataDir() { + const fromEnv = ['MAVIS_DATA_DIR', 'MINIMAX_DATA_DIR', '__MAVIS_PARENT_DATA_DIR', 'MCODE_CONFIG_DIR']; + for (const key of fromEnv) { + const value = process.env[key]; + if (value && existsSync(join(value, 'config.yaml'))) return value; + } + const home = homedir(); + for (const candidate of [join(home, '.minimax'), join(home, '.minimax-code'), join(home, '.mavis')]) { + if (existsSync(join(candidate, 'config.yaml'))) return candidate; + } + return join(home, '.minimax'); +} + +async function readConfig() { + const dataDir = resolveDataDir(); + const path = join(dataDir, 'config.yaml'); + let text = ''; + try { + text = await readFile(path, 'utf-8'); + } catch { + return { path, defaultModel: '', providers: new Map() }; + } + const parsed = parseConfig(text); + return { path, defaultModel: parsed.defaultModel, defaultEffort: parsed.defaultEffort, providers: parsed.providers }; +} + +// 逐行扫描 config.yaml 的 provider 段:只取 models / model_order / whitelist 三项,不引 YAML 依赖。 +function parseConfig(text) { + const providers = new Map(); + let defaultModel = ''; + let defaultEffort = ''; + let topKey = ''; + let inProvider = false; + let providerId = ''; + let section = ''; + let modelId = ''; + let modelBlock = ''; + + for (const raw of text.split(/\r?\n/)) { + const line = raw.trim(); + if (!line || line.startsWith('#')) continue; + const indent = raw.length - raw.trimStart().length; + + if (indent === 0) { + topKey = line.replace(/:.*$/, ''); + inProvider = topKey === 'provider'; + if (topKey === 'defaultModel') defaultModel = unquote(line.slice(line.indexOf(':') + 1).trim()); + providerId = ''; + section = ''; + modelId = ''; + modelBlock = ''; + continue; + } + + if (topKey === 'defaultModelThinking' && indent === 2 && line.startsWith('effort:')) { + defaultEffort = unquote(line.slice(line.indexOf(':') + 1).trim()); + continue; + } + + if (!inProvider) continue; + + if (indent === 2 && line.endsWith(':')) { + providerId = line.slice(0, -1).trim(); + if (!providers.has(providerId)) { + providers.set(providerId, { models: [], order: [], info: new Map() }); + } + section = ''; + modelId = ''; + modelBlock = ''; + continue; + } + if (!providerId) continue; + const provider = providers.get(providerId); + + if (indent === 4) { + const key = line.replace(/:$/, ''); + section = key === 'models' ? 'models' : key === 'model_order' ? 'model_order' : ''; + modelId = ''; + modelBlock = ''; + continue; + } + + if (section === 'models' && indent === 6 && line.endsWith(':')) { + modelId = line.slice(0, -1).trim(); + provider.models.push(modelId); + provider.info.set(modelId, { name: modelId, enabled: true, efforts: [], defaultEffort: '' }); + modelBlock = ''; + continue; + } + + if (section === 'models' && indent === 8 && modelId) { + const info = provider.info.get(modelId); + if (line.startsWith('name:')) { info.name = unquote(line.slice(5).trim()); continue; } + if (line.startsWith('enabled:')) { info.enabled = line.slice(8).trim() !== 'false'; continue; } + modelBlock = line === 'thinking:' ? 'thinking' : ''; + continue; + } + + if (section === 'models' && modelBlock === 'thinking' && indent === 10 && modelId) { + const info = provider.info.get(modelId); + if (line.startsWith('effortOptions:')) { modelBlock = 'effortOptions'; continue; } + if (line.startsWith('defaultEffort:')) { + info.defaultEffort = unquote(line.slice(line.indexOf(':') + 1).trim()); + modelBlock = ''; + continue; + } + modelBlock = ''; + continue; + } + + if (section === 'models' && modelBlock === 'effortOptions' && indent === 12 && line.startsWith('- ')) { + provider.info.get(modelId).efforts.push(unquote(line.slice(2).trim())); + continue; + } + + if (section === 'model_order' && indent === 6 && line.startsWith('- ')) { + provider.order.push(unquote(line.slice(2).trim())); + continue; + } + } + return { defaultModel, defaultEffort, providers }; +} + +function unquote(value) { + return String(value ?? '').replace(/^["']|["']$/g, ''); +} + +function buildModelList(config) { + const list = []; + for (const [providerId, provider] of config.providers) { + const usable = provider.models.filter((id) => { + const info = provider.info.get(id); + return !info || info.enabled !== false; + }); + const remaining = new Set(usable); + const ordered = provider.order.filter((id) => remaining.delete(id)); + for (const model of [...ordered, ...usable.filter((id) => remaining.has(id))]) { + const info = provider.info.get(model) ?? {}; + const efforts = info.efforts ?? []; + const own = info.defaultEffort && info.defaultEffort !== 'default' ? info.defaultEffort : ''; + const global = efforts.includes(config.defaultEffort) ? config.defaultEffort : ''; + list.push({ + id: providerId + '/' + model, + provider: providerId, + model, + name: info.name ?? model, + efforts, + defaultEffort: own || global || info.defaultEffort || 'default', + }); + } + } + return list; +} + +async function readJson(request) { + const chunks = []; + let size = 0; + for await (const chunk of request) { + size += chunk.length; + if (size > MAX_BODY) throw new Error('payload_too_large'); + chunks.push(chunk); + } + const raw = Buffer.concat(chunks).toString('utf-8'); + if (!raw) return {}; + try { + return JSON.parse(raw); + } catch { + return {}; + } +} + +function json(response, status, body) { + const payload = JSON.stringify(body); + response.writeHead(status, { + 'content-type': 'application/json; charset=utf-8', + 'content-length': Buffer.byteLength(payload), + }); + response.end(payload); +} + +function listen(server, host, port) { + return new Promise((resolve, reject) => { + const onError = (error) => reject(error); + server.once('error', onError); + server.listen(port, host, () => { + server.off('error', onError); + resolve(); + }); + }); +} + +function close(server) { + return new Promise((resolve, reject) => { + server.close((error) => (error ? reject(error) : resolve())); + }); +} diff --git a/plugins/skypata/prompt-enhancer/package.json b/plugins/skypata/prompt-enhancer/package.json new file mode 100644 index 00000000..aab6b8dc --- /dev/null +++ b/plugins/skypata/prompt-enhancer/package.json @@ -0,0 +1,6 @@ +{ + "mcode": { + "schemaVersion": 2, + "miniApp": "./miniapp/miniapp.json" + } +}