From 5778962ba5226f3984e21ddf8d7d17d69f58f926 Mon Sep 17 00:00:00 2001 From: ringo Date: Sun, 20 Sep 2026 12:13:10 +0800 Subject: [PATCH] =?UTF-8?q?fix(plugin):=20=E4=BA=A7=E5=93=81=E6=A1=A3?= =?UTF-8?q?=E4=BD=8D=E6=94=B9=E8=AF=BB=E6=8F=92=E4=BB=B6=E6=B8=85=E5=8D=95?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E7=BC=93=E5=AD=98=E5=B8=83=E5=B1=80=E4=B8=8B?= =?UTF-8?q?=E6=8A=8A=E7=89=88=E6=9C=AC=E5=8F=B7=E5=BD=93=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 症状(实测):宿主缓存布局是 <市场>/<插件>/<版本>/,deta-cli 原先用「自身目录名的上一级」推断产品名,于是 status 显示工作区 ~/.deta/0.3.3/workspace,doctor 会以 --profile 0.3.3 拉起服务并真的创建该目录。 修复:detectProfile 优先读 .codex-plugin/plugin.json 的 name(开发态与缓存态都对),DETA_PROFILE 仍可覆盖,清单不可读才回落目录名。studio 0.3.4 / writer 0.1.2。 验证:重装 0.3.4 后 status 显示 /Users/ringo/.deta/studio/workspace,doctor 以 --profile studio 握手成功 37 工具。 --- plugins/studio/.codex-plugin/plugin.json | 2 +- plugins/studio/bin/deta-cli.mjs | 13 +++++++++++-- plugins/studio/package-lock.json | 4 ++-- plugins/studio/package.json | 2 +- plugins/writer/.codex-plugin/plugin.json | 2 +- plugins/writer/bin/deta-cli.mjs | 13 +++++++++++-- plugins/writer/package-lock.json | 4 ++-- plugins/writer/package.json | 2 +- 8 files changed, 30 insertions(+), 12 deletions(-) diff --git a/plugins/studio/.codex-plugin/plugin.json b/plugins/studio/.codex-plugin/plugin.json index e642c02..623a00c 100644 --- a/plugins/studio/.codex-plugin/plugin.json +++ b/plugins/studio/.codex-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "studio", - "version": "0.3.3", + "version": "0.3.4", "description": "DETA Studio 插件:以 AML 为唯一事实源编辑建筑模型,编译为建筑模型并执行规则校验。", "author": { "name": "DETA", diff --git a/plugins/studio/bin/deta-cli.mjs b/plugins/studio/bin/deta-cli.mjs index 99c81ac..f2b2a73 100644 --- a/plugins/studio/bin/deta-cli.mjs +++ b/plugins/studio/bin/deta-cli.mjs @@ -23,8 +23,17 @@ import { fileURLToPath } from 'node:url'; const HERE = dirname(fileURLToPath(import.meta.url)); const HOME = homedir(); const DETA_DIR = join(HOME, '.deta'); -/** 产品档位:由本文件所在插件目录名决定(studio / writer),DETA_PROFILE 可覆盖 */ -const PROFILE = process.env.DETA_PROFILE || basename(join(HERE, '..')); +/** 产品档位:优先读插件清单的 name——开发态是 `plugins/studio`,而宿主缓存布局是 + * `<市场>/<插件>/<版本>/`,从路径取目录名会把版本号当成产品名(实测踩过)。 */ +function detectProfile() { + if (process.env.DETA_PROFILE) return process.env.DETA_PROFILE; + try { + const manifest = JSON.parse(readFileSync(join(HERE, '..', '.codex-plugin', 'plugin.json'), 'utf8')); + if (typeof manifest?.name === 'string' && manifest.name) return manifest.name; + } catch { /* 清单不可读时回落目录名(仅开发态正确) */ } + return basename(join(HERE, '..')); +} +const PROFILE = detectProfile(); function readToken() { if (process.env.DETA_TOKEN) return { source: '环境变量 DETA_TOKEN', token: process.env.DETA_TOKEN }; diff --git a/plugins/studio/package-lock.json b/plugins/studio/package-lock.json index 8cdaf84..bc48d86 100644 --- a/plugins/studio/package-lock.json +++ b/plugins/studio/package-lock.json @@ -1,12 +1,12 @@ { "name": "deta-studio-plugin", - "version": "0.3.3", + "version": "0.3.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "deta-studio-plugin", - "version": "0.3.3", + "version": "0.3.4", "license": "Proprietary" } } diff --git a/plugins/studio/package.json b/plugins/studio/package.json index eefad9a..b648cda 100644 --- a/plugins/studio/package.json +++ b/plugins/studio/package.json @@ -1,6 +1,6 @@ { "name": "deta-studio-plugin", - "version": "0.3.3", + "version": "0.3.4", "description": "DETA Studio:AML 建筑模型读写与编译校验(Codex 插件 / dsh 组合包 双壳)", "type": "module", "license": "Proprietary", diff --git a/plugins/writer/.codex-plugin/plugin.json b/plugins/writer/.codex-plugin/plugin.json index 214629c..ba874ce 100644 --- a/plugins/writer/.codex-plugin/plugin.json +++ b/plugins/writer/.codex-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "writer", - "version": "0.1.1", + "version": "0.1.2", "description": "DETA Writer 插件:读取建筑模型与模拟结果,产出报告 / 文档内容。", "author": { "name": "DETA", diff --git a/plugins/writer/bin/deta-cli.mjs b/plugins/writer/bin/deta-cli.mjs index 99c81ac..f2b2a73 100644 --- a/plugins/writer/bin/deta-cli.mjs +++ b/plugins/writer/bin/deta-cli.mjs @@ -23,8 +23,17 @@ import { fileURLToPath } from 'node:url'; const HERE = dirname(fileURLToPath(import.meta.url)); const HOME = homedir(); const DETA_DIR = join(HOME, '.deta'); -/** 产品档位:由本文件所在插件目录名决定(studio / writer),DETA_PROFILE 可覆盖 */ -const PROFILE = process.env.DETA_PROFILE || basename(join(HERE, '..')); +/** 产品档位:优先读插件清单的 name——开发态是 `plugins/studio`,而宿主缓存布局是 + * `<市场>/<插件>/<版本>/`,从路径取目录名会把版本号当成产品名(实测踩过)。 */ +function detectProfile() { + if (process.env.DETA_PROFILE) return process.env.DETA_PROFILE; + try { + const manifest = JSON.parse(readFileSync(join(HERE, '..', '.codex-plugin', 'plugin.json'), 'utf8')); + if (typeof manifest?.name === 'string' && manifest.name) return manifest.name; + } catch { /* 清单不可读时回落目录名(仅开发态正确) */ } + return basename(join(HERE, '..')); +} +const PROFILE = detectProfile(); function readToken() { if (process.env.DETA_TOKEN) return { source: '环境变量 DETA_TOKEN', token: process.env.DETA_TOKEN }; diff --git a/plugins/writer/package-lock.json b/plugins/writer/package-lock.json index e990d61..27b51dd 100644 --- a/plugins/writer/package-lock.json +++ b/plugins/writer/package-lock.json @@ -1,12 +1,12 @@ { "name": "deta-writer-plugin", - "version": "0.1.1", + "version": "0.1.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "deta-writer-plugin", - "version": "0.1.1", + "version": "0.1.2", "license": "Proprietary" } } diff --git a/plugins/writer/package.json b/plugins/writer/package.json index 874b7d0..3b0ea52 100644 --- a/plugins/writer/package.json +++ b/plugins/writer/package.json @@ -1,6 +1,6 @@ { "name": "deta-writer-plugin", - "version": "0.1.1", + "version": "0.1.2", "description": "DETA Writer:建筑性能报告与文档产出(Codex 插件 / dsh 组合包 双壳)", "type": "module", "license": "Proprietary",