AI-native design editor. Open-source Figma alternative.
Spawn MCP server as subprocess instead of SSR module
Danila Poyarkovdfb050538c79
diff --git a/oxlint.json b/oxlint.jsonindex 7347fec94..8e86530c2 100644--- a/oxlint.json+++ b/oxlint.json@@ -1,7 +1,14 @@{"$schema": "./node_modules/oxlint/configuration_schema.json",- "plugins": ["typescript", "import", "unicorn", "vue"],- "jsPlugins": ["./lint/plugin.js"],+ "plugins": [+ "typescript",+ "import",+ "unicorn",+ "vue"+ ],+ "jsPlugins": [+ "./lint/plugin.js"+ ],"env": {"browser": true,"es2024": true@@ -9,21 +16,50 @@"rules": {"no-unused-vars": "warn","no-console": "off",- "no-restricted-imports": ["error", {- "paths": [- { "name": "@/types", "message": "Import types directly from @open-pencil/core." }- ],- "patterns": [{- "group": ["@/engine/*"],- "message": "Import from @open-pencil/core unless the module adds platform-specific logic.",- "allowImportNames": ["loadFont", "listFamilies", "preloadFonts"]- }]- }],-+ "no-restricted-imports": [+ "error",+ {+ "paths": [+ {+ "name": "@/types",+ "message": "Import types directly from @open-pencil/core."+ }+ ],+ "patterns": [+ {+ "group": [+ "@/engine/*"+ ],+ "message": "Import from @open-pencil/core unless the module adds platform-specific logic.",+ "allowImportNames": [+ "loadFont",+ "listFamilies",+ "preloadFonts"+ ]+ },+ {+ "group": [+ "../../packages/*",+ "../../../packages/*"+ ],+ "message": "Use the workspace package name (e.g. @open-pencil/core) instead of relative paths to packages/."+ }+ ]+ }+ ],"no-empty-function": "error",- "max-lines": ["warn", { "max": 600 }],- "complexity": ["error", { "max": 20 }],-+ "max-lines": [+ "warn",+ {+ "max": 600+ }+ ],+ "complexity": [+ "error",+ {+ "max": 20+ }+ ],"typescript/no-explicit-any": "warn","typescript/no-non-null-assertion": "warn","typescript/no-floating-promises": "error",@@ -38,22 +74,18 @@"typescript/no-unnecessary-type-arguments": "error","typescript/prefer-optional-chain": "error","typescript/prefer-for-of": "error",-"import/no-cycle": "error","import/no-self-import": "error","import/no-duplicates": "error","import/no-mutable-exports": "error",-"unicorn/no-instanceof-array": "error","unicorn/no-typeof-undefined": "error","unicorn/no-nested-ternary": "error",-"unicorn/no-useless-fallback-in-spread": "error","unicorn/no-length-as-slice-end": "error","unicorn/no-unnecessary-await": "error","unicorn/prefer-string-starts-ends-with": "error","unicorn/consistent-existence-index-check": "error",-"vue/no-arrow-functions-in-watch": "error","vue/no-deprecated-destroyed-lifecycle": "error","vue/no-export-in-script-setup": "error",@@ -67,14 +99,16 @@"vue/define-emits-declaration": "error","vue/define-props-destructuring": "error","vue/require-typed-ref": "error",-- "open-pencil/no-inline-named-types": ["error", {- "Vector": "x:number,y:number",- "Color": "a:number,b:number,g:number,r:number",- "GUID": "localID:number,sessionID:number",- "Rect": "height:number,width:number,x:number,y:number",- "Matrix": "m00:number,m01:number,m02:number,m10:number,m11:number,m12:number"- }],+ "open-pencil/no-inline-named-types": [+ "error",+ {+ "Vector": "x:number,y:number",+ "Color": "a:number,b:number,g:number,r:number",+ "GUID": "localID:number,sessionID:number",+ "Rect": "height:number,width:number,x:number,y:number",+ "Matrix": "m00:number,m01:number,m02:number,m10:number,m11:number,m12:number"+ }+ ],"open-pencil/no-structuredclone-scene-arrays": "error","open-pencil/no-math-random": "error","open-pencil/no-hand-rolled-color": "error",@@ -83,28 +117,36 @@},"overrides": [{- "files": ["**/*.test.ts", "**/*.test.tsx"],+ "files": [+ "**/*.test.ts",+ "**/*.test.tsx"+ ],"rules": {"typescript/no-explicit-any": "off","typescript/no-non-null-assertion": "off","open-pencil/no-silent-catch": "off"}},-{- "files": ["**/tools/ai-adapter.ts"],+ "files": [+ "**/tools/ai-adapter.ts"+ ],"rules": {"typescript/no-explicit-any": "off"}},{- "files": ["**/render/render-jsx.ts"],+ "files": [+ "**/render/render-jsx.ts"+ ],"rules": {"typescript/no-implied-eval": "off"}},{- "files": ["**/kiwi/kiwi-schema/**"],+ "files": [+ "**/kiwi/kiwi-schema/**"+ ],"rules": {"typescript/no-explicit-any": "off","typescript/no-non-null-assertion": "off",@@ -128,11 +170,18 @@}},{- "files": ["packages/cli/src/commands/**"],+ "files": [+ "packages/cli/src/commands/**"+ ],"rules": {"open-pencil/no-raw-console-format": "error"}}],- "ignorePatterns": ["node_modules", "dist", "desktop", "*.config.*"]+ "ignorePatterns": [+ "node_modules",+ "dist",+ "desktop",+ "*.config.*"+ ]}diff --git a/src/automation/bridge.ts b/src/automation/bridge.tsdeleted file mode 100644index 4c8fcc863..000000000--- a/src/automation/bridge.ts+++ /dev/null@@ -1,6 +0,0 @@-import { serve } from '@hono/node-server'-import { startServer } from '@open-pencil/mcp'--const { app, httpPort } = startServer()--serve({ fetch: app.fetch, port: httpPort, hostname: '127.0.0.1' })diff --git a/src/automation/vite-plugin.ts b/src/automation/vite-plugin.tsindex a38472283..1a0dd3efe 100644--- a/src/automation/vite-plugin.ts+++ b/src/automation/vite-plugin.ts@@ -1,12 +1,25 @@+import { spawn } from 'node:child_process'+import type { Plugin } from 'vite'export function automationPlugin(): Plugin {+ let child: ReturnType<typeof spawn> | null = null+return {name: 'open-pencil-automation',- configureServer(server) {- server.ssrLoadModule('./src/automation/bridge').catch((e) => {- console.error('Failed to start automation bridge:', e)+ configureServer() {+ if (child) return++ child = spawn('bun', ['run', 'packages/mcp/src/index.ts'], {+ stdio: 'inherit',+ env: { ...process.env, PORT: '7600', WS_PORT: '7601' }})++ child.on('exit', () => { child = null })+ },+ buildEnd() {+ child?.kill()+ child = null}}}