Bundle CAD dashboard and keep verification status current

This commit is contained in:
gagushin committed 2026-11-21 21:40:06 +04:00
1 parent 449418d00f
commit b4ef20db39
10 files changed
+89 -15

No files matched your search

+5 -4
View File
@@ -1,9 +1,10 @@
import { Plugin } from "@opencode/plugin"
import { execFile } from "node:child_process"
import { join } from "node:path"
import { fileURLToPath } from "node:url"
import { promisify } from "node:util"
const run = promisify(execFile)
const bundledServer = fileURLToPath(new URL("./bundle/serve.py", import.meta.url))
export default Plugin.define({
id: "cad-dashboard",
@@ -12,7 +13,7 @@ export default Plugin.define({
editor.namespace({ name: "cad_dashboard", description: "Локальная панель CAD Factory" })
editor.add({
name: "ensure",
description: "Запускает или находит панель наблюдения для текущего CAD-проекта. Возвращает локальную ссылку, не открывая браузер.",
description: "Создаёт недостающие файлы в dashboard/ текущего CAD-проекта, запускает или находит панель и возвращает локальную ссылку.",
options: { namespace: "cad_dashboard", codemode: true },
input: { type: "object", properties: {}, additionalProperties: false },
async execute(_, context) {
@@ -27,12 +28,12 @@ export default Plugin.define({
const root = ctx.location.directory
try {
const { stdout } = await run("python3", [
"-I", join(root, "dashboard", "serve.py"), "--ensure", "--root", root,
"-I", bundledServer, "--install", "--ensure", "--root", root,
], { cwd: root, signal: context.signal, timeout: 15_000, maxBuffer: 8192 })
return { content: stdout.trim() }
} catch (error) {
if (context.signal.aborted) throw error
return { content: "Панель не удалось запустить. Из корня проекта можно попробовать вручную: python3 dashboard/serve.py" }
return { content: "Панель не удалось запустить. Для ручного запуска запустите bundle/serve.py из комплекта плагина с --root <каталог проекта>." }
}
},
})