@promptframe/creation 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,7 @@
9
9
  "source": {
10
10
  "source": "npm",
11
11
  "package": "@promptframe/creation",
12
- "version": "0.2.2",
12
+ "version": "0.2.3",
13
13
  "registry": "https://registry.npmjs.org/"
14
14
  },
15
15
  "policy": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptframe-creation",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "使用自己的推理,通过 PromptFrame 的共用工具、作品和任务创作视频。",
5
5
  "author": {
6
6
  "name": "PromptFrame"
package/README.md CHANGED
@@ -7,10 +7,10 @@
7
7
  需要 Node.js 20+ 及支持插件的 Codex(最低0.160.0)。在 Studio 的“连接与授权”复制当前环境 API 地址,然后在本机终端执行:
8
8
 
9
9
  ```bash
10
- npx --yes @promptframe/creation@0.2.2 connect --endpoint <Studio提供的API地址>
10
+ npx --yes @promptframe/creation@0.2.3 connect --endpoint <Studio提供的API地址>
11
11
  ```
12
12
 
13
- 入口检查环境、准备用户级版本、注册并核回 Codex 插件,复用有效凭据;首次 Token 在终端隐藏输入,不粘进聊天。完成后按提示正常重载插件或开新聊天,确认 `creation-setup`、`video-creation` 与 MCP 工具一起加载。安装本身不接管作品、不启动付费制作。`npx` 单独运行或目录连通不等于当前聊天已加载插件。
13
+ 每次从 Studio 获取当前固定推荐版本;入口比较已安装版本,较新版本保留,不后台追踪 latest。入口检查环境、准备用户级版本、注册并核回 Codex 插件,复用有效凭据;首次 Token 在终端隐藏输入,不粘进聊天。完成后按提示正常重载插件或开新聊天,确认 `creation-setup`、`video-creation` 与 MCP 工具一起加载。安装本身不接管作品、不启动付费制作。`npx` 单独运行或目录连通不等于当前聊天已加载插件。
14
14
 
15
15
  API 使用 Studio 实际可达 origin 和 `/api` 或 `/api/mcp`,没有内置生产/私有地址。远程客户端不要改成自己的 localhost。另一个环境或账号显式使用 `--profile <名称>`;新旧桥各固定凭据路径,不热切环境。有效 Token 不因升级、新作品或接管轮换。详细安装、升级保旧、卸载和排障见[安装说明](docs/installing.md)。Linux、WSL、macOS 使用0700目录/0600凭据;原生Windows ACL尚未验证。
16
16
 
@@ -19,7 +19,7 @@ API 使用 Studio 实际可达 origin 和 `/api` 或 `/api/mcp`,没有内置
19
19
  | 版本或层次 | 适用范围 |
20
20
  | --- | --- |
21
21
  | 历史 npm0.1.1 / creation-v0.1.1 | 固定3da232e267117794fcbcbb1920cbdf9f3f294c14的基础setup/status/bridge;不是此版的聊天身份和插件安装功能 |
22
- | 0.2.2源码与包合同 | 宿主thread隔离、桥管理控制版本、自包含运行依赖、用户级安装/两类Skill/独立profile;是否已发行以registry和固定tag为准 |
22
+ | 0.2.3源码与包合同 | 宿主thread隔离、桥管理控制版本、自包含运行依赖、用户级安装/两类Skill/独立profile;是否已发行以registry和固定tag为准 |
23
23
  | 实际用户宿主 | 核已安装版本、Skill加载与MCP连接;源码提交或npm发行不代替宿主及完整创作验收 |
24
24
 
25
25
  公开目录 `.agents/plugins/marketplace.json` 固定 npm 包版本。用户级 connect 从当前完整包注册受管本地副本;两条路径都携带运行依赖,不要求在业务仓安装SDK。不要同时启用旧的手工MCP入口和新插件;旧入口识别与安全迁移见安装说明。
package/dist/cli.mjs CHANGED
@@ -7301,7 +7301,7 @@ var require_content_type = __commonJS({
7301
7301
  });
7302
7302
 
7303
7303
  // lib/version.mjs
7304
- var CLIENT_VERSION = "0.2.2";
7304
+ var CLIENT_VERSION = "0.2.3";
7305
7305
  var CLIENT_PROTOCOL = "creation-client/v1";
7306
7306
 
7307
7307
  // lib/cli.mjs
@@ -19858,9 +19858,24 @@ import { homedir as homedir2 } from "node:os";
19858
19858
  import path2 from "node:path";
19859
19859
  var execute = promisify(execFile);
19860
19860
  var hash = (b) => createHash("sha256").update(b).digest("hex");
19861
- var fail = (code) => {
19862
- throw new CreationClientError("installation." + code);
19861
+ var InstallationError = class extends CreationClientError {
19862
+ constructor(code, details) {
19863
+ super("installation." + code);
19864
+ this.details = details;
19865
+ }
19866
+ };
19867
+ var fail = (code, details) => {
19868
+ throw new InstallationError(code, details);
19863
19869
  };
19870
+ var installationErrorDetails = (error2) => error2 instanceof InstallationError ? error2.details : void 0;
19871
+ function compareVersions(a, b) {
19872
+ const left = a.split(".").map(BigInt), right = b.split(".").map(BigInt);
19873
+ for (let i = 0; i < 3; i++) {
19874
+ if (left[i] > right[i]) return 1;
19875
+ if (left[i] < right[i]) return -1;
19876
+ }
19877
+ return 0;
19878
+ }
19864
19879
  var entries = ["package.json", "README.md", "LICENSE", "bin", "dist", "lib", "skills", "docs", ".codex-plugin", ".mcp.json"];
19865
19880
  var json = async (file) => JSON.parse(await readFile2(file, "utf8"));
19866
19881
  var pause = (ms) => new Promise((r) => setTimeout(r, ms));
@@ -20019,6 +20034,25 @@ async function runNode(root, version2) {
20019
20034
  fail("runtime_check_failed");
20020
20035
  }
20021
20036
  }
20037
+ async function checkInstalledRuntime(root, version2, command2, { env = process.env } = {}) {
20038
+ try {
20039
+ const runtime = await execute(command2, ["--version"], { env, encoding: "utf8", timeout: 1e4, maxBuffer: 8192 });
20040
+ const major = runtime.stdout.trim().match(/^v(\d+)\./);
20041
+ if (!major || Number(major[1]) < 20) throw Error("unsupported_node");
20042
+ const result = await execute(
20043
+ command2,
20044
+ [path2.join(root, "bin/promptframe-creation.mjs"), "--version"],
20045
+ { env, encoding: "utf8", timeout: 1e4, maxBuffer: 8192 }
20046
+ );
20047
+ if (result.stdout.trim() !== version2) throw Error("wrong_version");
20048
+ } catch {
20049
+ fail("recorded_node_unavailable", {
20050
+ installedVersion: version2,
20051
+ action: "restore_recorded_node_or_connect_newer_version",
20052
+ next: "\u6062\u590D\u8BE5\u63D2\u4EF6\u8BB0\u5F55\u7684 Node.js 20+\uFF1B\u6216\u4ECE Studio \u83B7\u53D6\u8F83\u65B0\u7684\u63A8\u8350\u7248 connect \u6307\u4EE4\uFF0C\u4E3A\u65B0\u6865\u51C6\u5907\u5F53\u524D Node\u3002\u4E0D\u8981\u5220\u9664\u65E7\u7248\u672C\u3001\u51ED\u636E\u6216\u91CD\u6D3E\u539F\u4EFB\u52A1\u3002"
20053
+ });
20054
+ }
20055
+ }
20022
20056
  async function installForUser({
20023
20057
  sourceRoot,
20024
20058
  profile = "default",
@@ -20026,6 +20060,7 @@ async function installForUser({
20026
20060
  configFile: configFile2 = profileCredentialsPath(profile, env),
20027
20061
  runCodex = (args2) => runCodexCommand(args2, { env }),
20028
20062
  checkRuntime = runNode,
20063
+ verifyInstalledRuntime = checkInstalledRuntime,
20029
20064
  signal
20030
20065
  } = {}) {
20031
20066
  validProfile(profile);
@@ -20057,13 +20092,40 @@ async function installForUser({
20057
20092
  const official = await officialNpmInstallation(state.installed ?? [], servers, env, profile, configFile2);
20058
20093
  if (official) {
20059
20094
  if (installed || previous) fail("existing_registration_requires_review");
20060
- return official;
20095
+ const compared = compareVersions(official.version, payload.version);
20096
+ if (compared < 0) {
20097
+ fail("npm_plugin_upgrade_required", {
20098
+ installedVersion: official.version,
20099
+ requestedVersion: payload.version,
20100
+ pluginId: official.pluginId,
20101
+ action: "upgrade_in_codex_after_active_bridges_finish",
20102
+ next: "\u5F53\u524D npm \u6765\u6E90\u63D2\u4EF6\u4ECD\u662F\u65E7\u7248\u3002\u786E\u8BA4\u4F7F\u7528\u8BE5\u63D2\u4EF6\u7684\u6D3B\u52A8\u804A\u5929\u548C\u6865\u5DF2\u7ED3\u675F\u540E\uFF0C\u5728 Codex \u66F4\u65B0\u539F\u63D2\u4EF6\u76EE\u5F55\u5E76\u5347\u7EA7\u540C\u4E00\u63D2\u4EF6\uFF1B\u6838\u5BF9\u5B9E\u9645\u7248\u672C\uFF0C\u518D\u8FD0\u884C connect\u3002\u5177\u4F53\u6B65\u9AA4\u89C1 docs/installing.md\uFF1B\u4E0D\u8981\u5220\u9664\u7F13\u5B58\u6216\u91CD\u65B0\u751F\u6210 Token\u3002"
20103
+ });
20104
+ }
20105
+ await verifyInstalledRuntime(official.versionRoot, official.version, "node", { env });
20106
+ return { ...official, requestedVersion: payload.version, versionStatus: compared > 0 ? "newer_retained" : "current" };
20061
20107
  }
20062
20108
  const recorded = await managedTransport(installed, versions, serverName, profile, configFile2);
20063
20109
  if (legacy.some((x) => {
20064
20110
  if (x.name !== serverName) return false;
20065
20111
  return !recorded || !sameTransport(x.transport, recorded);
20066
20112
  })) fail("legacy_mcp_entry_requires_review");
20113
+ if (installed && compareVersions(installed.version, payload.version) > 0) {
20114
+ if (!previous || previous.version !== installed.version || previous.versionRoot !== installed.source.path || installed.enabled !== true)
20115
+ fail("existing_registration_requires_review");
20116
+ await verifyInstalledRuntime(previous.versionRoot, previous.version, recorded.command, { env });
20117
+ return {
20118
+ ...previous,
20119
+ currentFile,
20120
+ reused: true,
20121
+ installedFiles: 0,
20122
+ registered: true,
20123
+ reloadRequired: false,
20124
+ requestedVersion: payload.version,
20125
+ versionStatus: "newer_retained",
20126
+ recordedRuntimeRetained: recorded.command !== process.execPath
20127
+ };
20128
+ }
20067
20129
  const target = await info(versionRoot);
20068
20130
  if (target) {
20069
20131
  if (!target.isDirectory() || target.isSymbolicLink()) fail("version_content_conflict");
@@ -20102,6 +20164,10 @@ async function installForUser({
20102
20164
  await rename2(temporary, versionRoot);
20103
20165
  newFiles = payload.files.length;
20104
20166
  }
20167
+ if (newFiles === 0) {
20168
+ const launch = (await json(path2.join(versionRoot, ".mcp.json"))).mcpServers?.[serverName];
20169
+ await verifyInstalledRuntime(versionRoot, payload.version, launch.command, { env });
20170
+ }
20105
20171
  const complete = { version: payload.version, profile, configFile: configFile2, pluginId, versionRoot, payloadDigest: payload.payloadDigest };
20106
20172
  const already = previous?.version === payload.version && previous.payloadDigest === payload.payloadDigest && installed?.version === payload.version && installed.enabled === true;
20107
20173
  if (!already) {
@@ -20123,6 +20189,8 @@ async function installForUser({
20123
20189
  return {
20124
20190
  ...complete,
20125
20191
  currentFile,
20192
+ requestedVersion: payload.version,
20193
+ versionStatus: "current",
20126
20194
  reused: newFiles === 0,
20127
20195
  installedFiles: newFiles,
20128
20196
  registered: true,
@@ -20352,6 +20420,8 @@ try {
20352
20420
  version: installed.version,
20353
20421
  installationReused: installed.reused,
20354
20422
  profile: installed.profile,
20423
+ requestedVersion: installed.requestedVersion,
20424
+ versionStatus: installed.versionStatus,
20355
20425
  recordedRuntimeRetained: installed.recordedRuntimeRetained ?? false,
20356
20426
  next: installed.recordedRuntimeRetained ? "This version retains its recorded Node path. Keep that Node available; a new version uses the installer's current Node." : installed.reloadRequired ? "Open a new Codex chat or reload plugins, then use the creation Skill." : "Use the creation Skill in a chat that has this plugin loaded.",
20357
20427
  hostThreadIdentity: "verified_by_the_platform_on_actual_host_tool_calls"
@@ -20378,6 +20448,7 @@ try {
20378
20448
  } catch (error2) {
20379
20449
  process.stderr.write(
20380
20450
  JSON.stringify({
20451
+ ...installationErrorDetails(error2),
20381
20452
  error: error2 instanceof CreationClientError ? error2.message : "creation.connection_failed"
20382
20453
  }) + "\n"
20383
20454
  );
@@ -31,7 +31,7 @@
31
31
 
32
32
  源码经 GitHub Actions 打包发行到 npm;插件目录记录包名/版本或源码位置。安装后,Codex 加载本地副本并按配置启动 Node 桥;桥通过 stdio 接收调用,读取独立安全配置,再通过 HTTPS MCP 连接所选平台。GitHub、npm 与目录索引负责获取版本,不进入正常工具调用链。Token 不进入源码、插件包或命令参数。
33
33
 
34
- 0.2.2公开目录固定npm来源;`connect`复用来源和缓存定义可核的已启用官方npm插件;尚未注册时才准备用户级受管版本。受管身份按installation记录和原MCP定义核实,允许安装器Node路径变化,不将未知同名手工入口当作自身安装。`scripts/build-runtime.mjs`显式bundle MCP SDK及必要依赖,拒绝除Node builtins之外的外部import并附第三方许可证。npm_source仍只pack/unpack,不执行npm install;因此`test/package-runtime.test.mjs`从无node_modules解包核可运行。宿主注册/实际Skill及MCP启动另核,普通npm install不代替。
34
+ 当前公开目录固定npm来源;`connect`复用来源和缓存定义可核的已启用官方npm插件;尚未注册时才准备用户级受管版本。受管身份按installation记录和原MCP定义核实,允许安装器Node路径变化,不将未知同名手工入口当作自身安装。`scripts/build-runtime.mjs`显式bundle MCP SDK及必要依赖,拒绝除Node builtins之外的外部import并附第三方许可证。npm_source仍只pack/unpack,不执行npm install;因此`test/package-runtime.test.mjs`从无node_modules解包核可运行。宿主注册/实际Skill及MCP启动另核,普通npm install不代替。
35
35
 
36
36
  ## 相称验证
37
37
 
@@ -44,3 +44,5 @@
44
44
  ## 公开范围
45
45
 
46
46
  使用说明保持公开且可移植。平台私有配置、真实端点默认值、用户样本、Token、内部协作材料和业务权限实现不进入本仓。组件创作需要的工具按 README 指向独立 authoring 仓;不在本仓维护第二套组件 CLI 参数手册或四包发行流程。
47
+
48
+ 安装器按 connect 的固定目标版本比较实际安装:同版复用、更新版不降级、受管旧版准备独立目录。官方 npm 插件旧版先返回明确的待升级错误:Codex 0.160 的升级会删除旧缓存,不能假称能保护其他桥并自动升级。受管与官方复用均实际检查启动 Node 与包版本。安装结果新增 requestedVersion/versionStatus;安全错误只输出本地构造的版本、动作和指引,不输出宿主原始错误、环境或凭据。
@@ -5,7 +5,7 @@
5
5
  从 Studio 的“连接与授权”复制当前环境的指引。在本机终端执行:
6
6
 
7
7
  ```bash
8
- npx --yes @promptframe/creation@0.2.2 connect --endpoint <Studio提供的API地址>
8
+ npx --yes @promptframe/creation@0.2.3 connect --endpoint <Studio提供的API地址>
9
9
  ```
10
10
 
11
11
  `/api` 会规范化到 `/api/mcp`;也可直接提供 `/api/mcp`。保留 Studio 实际可达的 HTTPS origin,包括私有网络域名,不把远程地址替换成本机 localhost。`0.1.1` 是历史基础包;它不支持此用户级插件引导。新版本是否已发行,以 registry 的实际版本和对应固定标签为准。
@@ -21,13 +21,15 @@ npx --yes @promptframe/creation@0.2.2 connect --endpoint <Studio提供的API地
21
21
  另一个环境或账号应由用户选择不同名称:
22
22
 
23
23
  ```bash
24
- npx --yes @promptframe/creation@0.2.2 connect --profile work-account --endpoint <另一环境API地址>
24
+ npx --yes @promptframe/creation@0.2.3 connect --profile work-account --endpoint <另一环境API地址>
25
25
  ```
26
26
 
27
27
  命名 profile 使用独立凭据和独立插件名;新桥配置固定具体凭据文件。已有文件绑定另一 endpoint 时拒绝覆盖,运行中的桥也不会热切环境。相同 endpoint 的不同账号同样用不同 profile;不要尝试从 Token 或作品名猜账号。`--config <安全文件>` 可指定已存在的私有配置,但不得把不同环境指向同一文件。
28
28
 
29
29
  ## 版本与失败
30
30
 
31
+ 推荐版本由 Studio 当前连接指引提供,入口每次对照命令中的固定版本检查安装。同版本复用;受管旧版准备新版并切换后续入口;已安装更新版返回 `newer_retained`,不降级。没有后台自动追踪 latest;再次连接时从 Studio 复制当前指令,不沿用旧聊天中的版本。
32
+
31
33
  每个 profile 的安装位于 `$XDG_DATA_HOME/promptframe-creation/<profile>`(默认用户 `.local/share`),版本在 `versions/<version>`。同版本完整内容复用,不再次下载运行依赖;两个入口串行合并。新版本先完整准备和检查,再注册并原子更新 `current.json`。旧版本及其依赖保留,不覆盖、不枚举或终止其它聊天。
32
34
 
33
35
  更新失败保留旧默认、旧文件及 Token。`registration_unconfirmed_keep_existing` 表示宿主命令结果未确认;先核 Codex 当前插件状态,不根据错误盲重发或删除缓存。普通重试会核原完整版本和实际宿主状态。只在确认本工具 `install.lock/owner.json` 的进程已退出后,才手动移除该精确安装锁并重试;活动或无法确认的进程不清锁。安装锁不决定平台编辑权。
@@ -44,6 +46,13 @@ npx --yes @promptframe/creation@0.2.2 connect --profile work-account --endpoint
44
46
 
45
47
  ## 已有官方插件与 Node 路径变更
46
48
 
47
- 已通过官方 npm 来源安装并启用的插件,`connect`核来源、缓存版本与实际MCP定义后复用现有入口和配置,不另注册第二个插件。未知手工MCP仍需明确核对;自定义配置或独立账号使用显式profile,不能借官方插件名切换其环境。
49
+ 已通过官方 npm 来源安装并启用的插件,`connect` 核来源、缓存、实际 MCP 定义及可执行运行环境。同版本复用;比指令更新的版本保留并返回 `newer_retained`;旧版明确返回 `installation.npm_plugin_upgrade_required`,附实际版本和请求版本,退出码为1,不报告升级成功,也不创建第二个入口。
50
+
51
+ Codex CLI 0.160.0 的 `plugin add` 升级 npm 插件会移除旧缓存,当前没有可保留旧缓存的升级选项。因此不能在不知道其他聊天是否仍用旧桥时自动执行该命令。处理步骤:
52
+
53
+ 1. 等使用该插件的活动聊天和桥结束。平台已受理的媒体任务保持原 task,升级后继续查询,不重派。
54
+ 2. 用 `codex plugin list --json` 和 `codex plugin marketplace list --json` 确认原插件 ID、目录来源和当前版本。
55
+ 3. Git 来源目录使用 `codex plugin marketplace upgrade <原目录名> --json` 更新目录;本地目录由其维护者更新到包含目标 npm 版本的目录。不要新注册一个同名插件来绕过升级。
56
+ 4. 确认目录中的版本是目标版本后,执行 `codex plugin add <原插件ID> --json`。再次 `codex plugin list --json` 核目标版本已启用,再运行 Studio 的 `connect` 指令并正常重载。目录未提供目标版或升级失败时保持待升级,不循环卸载重装。
48
57
 
49
- 受管入口按原安装记录核身份,不以当前Node可执行文件路径认领。相同版本继续使用已记录的Node路径;换Node后运行connect可复用原安装,需保留该旧Node以供新聊天启动。后继兼容版本采用安装该版本时的Node路径,旧版本和活动桥不被覆盖或终止。
58
+ 受管入口按原安装记录核身份,不以当前 Node 路径认领。每次复用会实际运行已记录的 Node 和该版本 `--version`(各最多10秒,无平台调用),缺失、低于20或无法启动时返回 `installation.recorded_node_unavailable`。可恢复原 Node.js 20+ 路径,或运行 Studio 提供的较新版本 connect:新的受管版本使用当前 Node,保留旧代码及原凭据。相同版本不会偷偷重写旧启动配置。官方 npm 插件的 `node` 按当前宿主环境的 PATH 检查;Desktop 重载后的真实 MCP 启动仍须单独确认。
@@ -0,0 +1,8 @@
1
+ # 0.2.3 — 安装版本与运行环境检查
2
+
3
+ - `connect` 返回实际 `version`、指令的 `requestedVersion` 和 `versionStatus`。同版本复用,已装更新版本保留,不默认降级。
4
+ - 受管旧版本沿独立版本目录升级,旧代码、凭据及原任务保持。复用时实际检查已记录 Node 和 CLI;缺失或不可用时返回明确恢复指引,较新版本可用当前 Node 准备新桥。
5
+ - 官方 npm 来源旧插件返回 `installation.npm_plugin_upgrade_required`,不再误报已升级。Codex CLI 0.160.0 升级 npm 插件会删除旧缓存,因此不能自动保证活动桥保留;按[安装说明](../installing.md)在活动桥结束后升级原插件并核回版本。
6
+ - 设置和创作 Skill 统一指向固定推荐版 `connect`;`setup` 只处理凭据。推荐版本由 Studio 连接入口提供,没有后台自动更新守护程序。
7
+
8
+ 以上不代表每台用户 Desktop 已加载新版,或完整视频创作旅程已验收。首次安装/升级后仍需按宿主正常方式重载,并确认两个 Skill 和 MCP 工具同时可见。
package/lib/cli.mjs CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  } from "./credentials.mjs";
17
17
  import { connectPlatform } from "./connection.mjs";
18
18
  import { createHostCallBridge } from "./host-context.mjs";
19
- import {installForUser,profileCredentialsPath} from './user-installation.mjs';
19
+ import {installForUser,profileCredentialsPath,installationErrorDetails} from './user-installation.mjs';
20
20
  import {fileURLToPath} from 'node:url';
21
21
  import path from 'node:path';
22
22
 
@@ -225,6 +225,7 @@ try {
225
225
  profile:value('--profile')??'default',configFile:configFile(),signal:signal.signal});
226
226
  log({...connection,pluginRegistered:installed.registered,version:installed.version,
227
227
  installationReused:installed.reused,profile:installed.profile,
228
+ requestedVersion:installed.requestedVersion,versionStatus:installed.versionStatus,
228
229
  recordedRuntimeRetained:installed.recordedRuntimeRetained??false,
229
230
  next:installed.recordedRuntimeRetained?'This version retains its recorded Node path. Keep that Node available; a new version uses the installer\'s current Node.':installed.reloadRequired?'Open a new Codex chat or reload plugins, then use the creation Skill.':'Use the creation Skill in a chat that has this plugin loaded.',
230
231
  hostThreadIdentity:'verified_by_the_platform_on_actual_host_tool_calls'});
@@ -249,6 +250,7 @@ try {
249
250
  // Never print raw SDK/fetch errors, response bodies or credentials.
250
251
  process.stderr.write(
251
252
  JSON.stringify({
253
+ ...installationErrorDetails(error),
252
254
  error:
253
255
  error instanceof CreationClientError
254
256
  ? error.message
@@ -7,7 +7,18 @@ import path from 'node:path';
7
7
  import {CreationClientError,credentialsPath} from './credentials.mjs';
8
8
 
9
9
  const execute=promisify(execFile),hash=b=>createHash('sha256').update(b).digest('hex');
10
- const fail=code=>{throw new CreationClientError('installation.'+code);};
10
+ class InstallationError extends CreationClientError {
11
+ constructor(code,details){super('installation.'+code);this.details=details;}
12
+ }
13
+ const fail=(code,details)=>{throw new InstallationError(code,details);};
14
+ // Only locally constructed, safe installer facts reach the CLI. Never forward a
15
+ // raw host error, environment, credential or response body.
16
+ export const installationErrorDetails=error=>error instanceof InstallationError?error.details:undefined;
17
+ function compareVersions(a,b){
18
+ const left=a.split('.').map(BigInt),right=b.split('.').map(BigInt);
19
+ for(let i=0;i<3;i++){if(left[i]>right[i])return 1;if(left[i]<right[i])return -1;}return 0;
20
+ }
21
+
11
22
  const entries=['package.json','README.md','LICENSE','bin','dist','lib','skills','docs','.codex-plugin','.mcp.json'];
12
23
  const json=async file=>JSON.parse(await readFile(file,'utf8'));
13
24
  const pause=ms=>new Promise(r=>setTimeout(r,ms));
@@ -130,12 +141,26 @@ async function runNode(root,version){
130
141
  }catch(e){if(e instanceof CreationClientError)throw e;fail('runtime_check_failed');}
131
142
  }
132
143
 
144
+ async function checkInstalledRuntime(root,version,command,{env=process.env}={}){
145
+ try{
146
+ const runtime=await execute(command,['--version'],{env,encoding:'utf8',timeout:10_000,maxBuffer:8192});
147
+ const major=runtime.stdout.trim().match(/^v(\d+)\./);
148
+ if(!major||Number(major[1])<20)throw Error('unsupported_node');
149
+ const result=await execute(command,[path.join(root,'bin/promptframe-creation.mjs'),'--version'],
150
+ {env,encoding:'utf8',timeout:10_000,maxBuffer:8192});
151
+ if(result.stdout.trim()!==version)throw Error('wrong_version');
152
+ }catch{
153
+ fail('recorded_node_unavailable',{installedVersion:version,action:'restore_recorded_node_or_connect_newer_version',
154
+ next:'恢复该插件记录的 Node.js 20+;或从 Studio 获取较新的推荐版 connect 指令,为新桥准备当前 Node。不要删除旧版本、凭据或重派原任务。'});
155
+ }
156
+ }
157
+
133
158
  /** No daemon or global environment switch. All writes are confined to this
134
159
  * user's managed profile. Host registration uses Codex's ordinary commands.
135
160
  * Completed versions are retained: a running bridge may still use any of them. */
136
161
  export async function installForUser({sourceRoot,profile='default',env=process.env,
137
162
  configFile=profileCredentialsPath(profile,env),runCodex=args=>runCodexCommand(args,{env}),
138
- checkRuntime=runNode,signal}={}){
163
+ checkRuntime=runNode,verifyInstalledRuntime=checkInstalledRuntime,signal}={}){
139
164
  validProfile(profile);
140
165
  const versionOutput=await runCodex(['--version']);
141
166
  const match=versionOutput.match(/codex-cli (\d+)\.(\d+)\.(\d+)/);
@@ -159,12 +184,32 @@ export async function installForUser({sourceRoot,profile='default',env=process.e
159
184
  const serverName='promptframe'+(profile==='default'?'':'-'+profile);
160
185
  const servers=legacy.filter(x=>x.name===serverName);
161
186
  const official=await officialNpmInstallation(state.installed??[],servers,env,profile,configFile);
162
- if(official){if(installed||previous)fail('existing_registration_requires_review');return official;}
187
+ if(official){
188
+ if(installed||previous)fail('existing_registration_requires_review');
189
+ const compared=compareVersions(official.version,payload.version);
190
+ if(compared<0){
191
+ // Codex 0.160 plugin add replaces npm caches and removes the old version.
192
+ // We cannot infer whether other chats still use it. Do not silently call it
193
+ // or claim the requested version is installed; leave host-owned files alone.
194
+ fail('npm_plugin_upgrade_required',{installedVersion:official.version,requestedVersion:payload.version,
195
+ pluginId:official.pluginId,action:'upgrade_in_codex_after_active_bridges_finish',
196
+ next:'当前 npm 来源插件仍是旧版。确认使用该插件的活动聊天和桥已结束后,在 Codex 更新原插件目录并升级同一插件;核对实际版本,再运行 connect。具体步骤见 docs/installing.md;不要删除缓存或重新生成 Token。'});
197
+ }
198
+ await verifyInstalledRuntime(official.versionRoot,official.version,'node',{env});
199
+ return{...official,requestedVersion:payload.version,versionStatus:compared>0?'newer_retained':'current'};
200
+ }
163
201
  const recorded=await managedTransport(installed,versions,serverName,profile,configFile);
164
202
  if(legacy.some(x=>{
165
203
  if(x.name!==serverName)return false;
166
204
  return !recorded||!sameTransport(x.transport,recorded);
167
205
  }))fail('legacy_mcp_entry_requires_review');
206
+ if(installed&&compareVersions(installed.version,payload.version)>0){
207
+ if(!previous||previous.version!==installed.version||previous.versionRoot!==installed.source.path||installed.enabled!==true)
208
+ fail('existing_registration_requires_review');
209
+ await verifyInstalledRuntime(previous.versionRoot,previous.version,recorded.command,{env});
210
+ return{...previous,currentFile,reused:true,installedFiles:0,registered:true,reloadRequired:false,
211
+ requestedVersion:payload.version,versionStatus:'newer_retained',recordedRuntimeRetained:recorded.command!==process.execPath};
212
+ }
168
213
  const target=await info(versionRoot);
169
214
  if(target){
170
215
  if(!target.isDirectory()||target.isSymbolicLink())fail('version_content_conflict');
@@ -190,6 +235,10 @@ export async function installForUser({sourceRoot,profile='default',env=process.e
190
235
  await atomicJSON(path.join(temporary,'installation.json'),{version:payload.version,profile,configFile,payloadDigest:payload.payloadDigest,files});
191
236
  signal?.throwIfAborted();await rename(temporary,versionRoot);newFiles=payload.files.length;
192
237
  }
238
+ if(newFiles===0){
239
+ const launch=(await json(path.join(versionRoot,'.mcp.json'))).mcpServers?.[serverName];
240
+ await verifyInstalledRuntime(versionRoot,payload.version,launch.command,{env});
241
+ }
193
242
  const complete={version:payload.version,profile,configFile,pluginId,versionRoot,payloadDigest:payload.payloadDigest};
194
243
  const already=previous?.version===payload.version&&previous.payloadDigest===payload.payloadDigest&&installed?.version===payload.version&&installed.enabled===true;
195
244
  if(!already){
@@ -202,7 +251,7 @@ export async function installForUser({sourceRoot,profile='default',env=process.e
202
251
  if(observed?.version!==payload.version||observed.enabled!==true)fail('registration_unconfirmed');
203
252
  await atomicJSON(currentFile,complete);
204
253
  }
205
- return{...complete,currentFile,reused:newFiles===0,installedFiles:newFiles,registered:true,reloadRequired:!already,
254
+ return{...complete,currentFile,requestedVersion:payload.version,versionStatus:'current',reused:newFiles===0,installedFiles:newFiles,registered:true,reloadRequired:!already,
206
255
  recordedRuntimeRetained:Boolean(already&&recorded&&recorded.command!==process.execPath)};
207
256
  }catch(error){
208
257
  if(registrationStarted){
package/lib/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const CLIENT_VERSION = "0.2.2";
1
+ export const CLIENT_VERSION = "0.2.3";
2
2
  export const CLIENT_PROTOCOL = "creation-client/v1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptframe/creation",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "private": false,
5
5
  "description": "PromptFrame video creation Skill, Codex plugin and MCP client bridge.",
6
6
  "repository": {
@@ -7,7 +7,7 @@ description: 安装、连接或升级 PromptFrame Creation 的 Codex 插件,
7
7
 
8
8
  使用 Studio“连接与授权”提供的完整 API 地址及公开安装入口。保留用户当前环境的 origin 和 `/api`,不替换成 localhost,不从旧聊天猜另一账号或环境。
9
9
 
10
- 在用户本机终端运行 `npx --yes @promptframe/creation connect --endpoint <Studio提供的API地址>`。需要隔离另一个环境或账号时显式加 `--profile <用户选择的名称>`;正在运行的桥不会切换。此命令管理用户级版本和 Codex 插件,不向当前项目安装依赖。
10
+ 在用户本机终端运行 `npx --yes @promptframe/creation@0.2.3 connect --endpoint <Studio提供的API地址>`。需要隔离另一个环境或账号时显式加 `--profile <用户选择的名称>`;正在运行的桥不会切换。此命令管理用户级版本和 Codex 插件,不向当前项目安装依赖。优先使用 Studio 当前提供的固定推荐版本;每次重新进入此入口比较已安装版本,不后台追踪 latest,也不把旧聊天里的命令当最新版本。已安装更新版不默认降级。
11
11
 
12
12
  命令会复用并验证有效凭据。首次授权或明确更换已失效凭据时,由用户在 Studio 登录并在终端的不回显输入框提供 Token;不要要求用户把 Token 粘进聊天,也不要把它写进命令参数、URL或日志。网络失败不等于授权失效,不自动轮换或覆盖凭据。
13
13
 
@@ -17,4 +17,6 @@ description: 安装、连接或升级 PromptFrame Creation 的 Codex 插件,
17
17
 
18
18
  如需自行开发组件,沿 README 的独立组件 authoring Skill/CLI;普通创作与平台组件复用不要求安装四个组件包。
19
19
 
20
+ 官方 npm 来源旧插件返回 `installation.npm_plugin_upgrade_required` 时,升级尚未完成;按包内安装说明处理原插件,不再创建第二个入口。`setup` 仅管理凭据,不能代替 `connect` 的插件安装和版本检查。
21
+
20
22
  出现 `installation.*` 或 `setup.*` 时保留旧版本、凭据及明确错误。不要删除不明配置、终止其它聊天或反复重装追绿。卸载和排障见包内[安装与排障](../../docs/installing.md)。
@@ -7,7 +7,7 @@ description: 在 PromptFrame 中调研、规划、制作和接续视频,复用
7
7
 
8
8
  ## 连接与选择作品
9
9
 
10
- 未连接时按仓库 README 运行 setup,提供用户选择的平台 API 地址。凭据只交本地 setup 的安全输入,不写聊天、源码、命令行参数或 MCP 业务参数。创作 Token 与组件上传凭据用途不同,也不是 OAuth `mcp login`。
10
+ 未连接时先按 creation-setup Skill 和 Studio 当前固定版本指引运行 `connect`,提供用户选择的平台 API 地址。`setup` 只处理凭据,不能代替插件注册。凭据只交本地连接流程的安全输入,不写聊天、源码、命令行参数或 MCP 业务参数。创作 Token 与组件上传凭据用途不同,也不是 OAuth `mcp login`。
11
11
 
12
12
  使用平台项目和作品列表选择目标。新作品使用稳定的幂等请求键;已有作品先读取最新历史、Plan、Spec、素材和在途任务,再申请编辑权,由本人在 Studio 确认。不要修改已有作品的运行时来换端。断线和思考不代表释放编辑权。
13
13