@promptframe/creation 0.2.3 → 0.2.4

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.
@@ -6,3 +6,40 @@ content-type/index.js:
6
6
  * Copyright(c) 2015 Douglas Christopher Wilson
7
7
  * MIT Licensed
8
8
  */
9
+
10
+ smol-toml/dist/error.js:
11
+ smol-toml/dist/primitive.js:
12
+ smol-toml/dist/date.js:
13
+ smol-toml/dist/extract.js:
14
+ smol-toml/dist/util.js:
15
+ smol-toml/dist/struct.js:
16
+ smol-toml/dist/parse.js:
17
+ smol-toml/dist/stringify.js:
18
+ smol-toml/dist/index.js:
19
+ /*!
20
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
21
+ * SPDX-License-Identifier: BSD-3-Clause
22
+ *
23
+ * Redistribution and use in source and binary forms, with or without
24
+ * modification, are permitted provided that the following conditions are met:
25
+ *
26
+ * 1. Redistributions of source code must retain the above copyright notice, this
27
+ * list of conditions and the following disclaimer.
28
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
29
+ * this list of conditions and the following disclaimer in the
30
+ * documentation and/or other materials provided with the distribution.
31
+ * 3. Neither the name of the copyright holder nor the names of its contributors
32
+ * may be used to endorse or promote products derived from this software without
33
+ * specific prior written permission.
34
+ *
35
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
36
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
37
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
39
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
40
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
41
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
42
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
43
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
44
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45
+ */
@@ -46,3 +46,7 @@
46
46
  使用说明保持公开且可移植。平台私有配置、真实端点默认值、用户样本、Token、内部协作材料和业务权限实现不进入本仓。组件创作需要的工具按 README 指向独立 authoring 仓;不在本仓维护第二套组件 CLI 参数手册或四包发行流程。
47
47
 
48
48
  安装器按 connect 的固定目标版本比较实际安装:同版复用、更新版不降级、受管旧版准备独立目录。官方 npm 插件旧版先返回明确的待升级错误:Codex 0.160 的升级会删除旧缓存,不能假称能保护其他桥并自动升级。受管与官方复用均实际检查启动 Node 与包版本。安装结果新增 requestedVersion/versionStatus;安全错误只输出本地构造的版本、动作和指引,不输出宿主原始错误、环境或凭据。
49
+
50
+ 后继安装发现使用 `$CODEX_HOME/config.toml` 的结构化插件登记 ID、`codex plugin marketplace list --json` 的本地根索引、有界目录 JSON 和 `plugin list --marketplace <name> --json`。TOML 使用随运行文件打包的成熟解析器,只保留相关插件身份;目录条目删除后仍查询原登记,读面无法解析该登记就保持 unknown。覆盖全部相关入口,不把不可读目录当未安装,也不调用必需全量远端插件查询。注册前持久保存精确 pending 身份;写回程未知后只观察该身份,不第二次 add 或自动降回旧注册。测试从 pack 的实际 npx/connect 入口核隔离配置、两个 profile、并发和失 ACK,不读个人配置。
51
+
52
+ 宿主插件已安装/启用、平台连接验证与聊天加载分别报告。外部安装器不接私有 app-server 生产刷新通道;当前使用官方新聊天/新 session 路径,选择 Local 和独立非 Git 目录即可。候选包、公共 registry 固定包和真实宿主新聊天工具/两个 Skill 的验收分开记录。
@@ -12,7 +12,11 @@ npx --yes @promptframe/creation@0.2.3 connect --endpoint <Studio提供的API地
12
12
 
13
13
  首次连接由用户在 Studio 生成创作授权,在终端隐藏输入框输入 Token。自动化可从受限管道使用 `--token-stdin`,不得把 Token 放在参数、聊天、URL、业务仓或日志中。已有有效凭据直接验证复用;失败时保留原凭据,不自动撤销或轮换。仅明确替换时使用 `setup --replace`。
14
14
 
15
- 连接入口校验完整包,把自包含运行文件、插件声明及两个 Skill 放入用户级版本目录,通过 `codex plugin marketplace add` 和 `codex plugin add` 注册并核回已启用版本。无需在当前业务仓运行 npm install,也不依赖开发者的 node_modules。目录注册成功与当前聊天已加载分别报告:首次安装或升级后正常重载插件或开新聊天,确认 creation-setup、video-creation 和 MCP 工具均可见。
15
+ 连接入口校验完整包,把自包含运行文件、插件声明及两个 Skill 放入用户级版本目录,通过 `codex plugin marketplace add` 和 `codex plugin add` 注册并核回已启用版本。无需在当前业务仓运行 npm install,也不依赖开发者的 node_modules。目录注册成功与当前聊天已加载分别报告。
16
+
17
+ 安装后在同一主机开一个 **Local 新聊天**;CLI 使用新 session。选择独立的非 Git 创作目录即可,不必复制产品仓或创建 Worktree,也不用重装或更换 Token。在新聊天确认 `creation-setup`、`video-creation` 两个 Skill 和 PromptFrame MCP 工具一起可用,再开始创作。现有聊天不必关闭;安装器不重启宿主或其它聊天,也不承诺能从外部 npx 强刷原 GUI 会话。[官方插件说明](https://learn.chatgpt.com/docs/plugins)要求安装后使用新聊天/新 session。
18
+
19
+ 安装输出分别报告插件已安装、已启用、平台凭据连接已核验;`hostMcpConnected` 与 `sessionLoaded` 在安装器中仍为 `not_verified`。当前聊天是否已加载,要由该聊天实际发现 Skill 和调用 MCP 只读工具验证。若宿主将来提供明确受支持的同会话刷新入口,也须同时核回这两类能力后才能报告加载成功。
16
20
 
17
21
  ## 环境与账号
18
22
 
@@ -32,7 +36,9 @@ npx --yes @promptframe/creation@0.2.3 connect --profile work-account --endpoint
32
36
 
33
37
  每个 profile 的安装位于 `$XDG_DATA_HOME/promptframe-creation/<profile>`(默认用户 `.local/share`),版本在 `versions/<version>`。同版本完整内容复用,不再次下载运行依赖;两个入口串行合并。新版本先完整准备和检查,再注册并原子更新 `current.json`。旧版本及其依赖保留,不覆盖、不枚举或终止其它聊天。
34
38
 
35
- 更新失败保留旧默认、旧文件及 Token。`registration_unconfirmed_keep_existing` 表示宿主命令结果未确认;先核 Codex 当前插件状态,不根据错误盲重发或删除缓存。普通重试会核原完整版本和实际宿主状态。只在确认本工具 `install.lock/owner.json` 的进程已退出后,才手动移除该精确安装锁并重试;活动或无法确认的进程不清锁。安装锁不决定平台编辑权。
39
+ 更新失败保留旧默认、旧文件及 Token。`registration_unconfirmed_keep_existing` 表示宿主写命令结果未确认;先核 Codex 当前插件状态,不根据错误盲重发或删除缓存。安装器在写前保存该 profile 的 `registration-pending.json`;再次 connect 只观察同一插件和版本。确认已登记则正常完成,否则保留待核状态,不自动第二次 add 或用旧版 add 作补偿。只有原宿主登记责任核清后才安排后续处理。只在确认本工具 `install.lock/owner.json` 的进程已退出后,才手动移除该精确安装锁并重试;活动或无法确认的进程不清锁。安装锁不决定平台编辑权。
40
+
41
+ 源码后继的安装核验读取宿主结构化本地 marketplace 索引和有界目录文件,再仅查询全部相关 marketplace;无关远端目录不进入安装必需路径。目录不可读、JSON/输出超限、查询超时不代表“未安装”。错误只报告阶段、命令种类、耗时、期限、退出码/信号及下一动作,不透传子进程 stdout/stderr、环境或凭据。此行为属于后继源码/候选,不回填已发行 0.2.3。
36
42
 
37
43
  从旧手工 `codex mcp add promptframe` 迁移时,若发现同名定义,引导会停止并给出 `legacy_mcp_entry_requires_review`,不会删除不明配置。确认它是旧的 PromptFrame 手工入口后可用 `codex mcp remove promptframe` 移除定义,再重复 connect。移除定义不取消已接受平台任务、不撤销 Token;在途桥及原结果应沿原 task 观察。
38
44
 
@@ -51,8 +57,8 @@ npx --yes @promptframe/creation@0.2.3 connect --profile work-account --endpoint
51
57
  Codex CLI 0.160.0 的 `plugin add` 升级 npm 插件会移除旧缓存,当前没有可保留旧缓存的升级选项。因此不能在不知道其他聊天是否仍用旧桥时自动执行该命令。处理步骤:
52
58
 
53
59
  1. 等使用该插件的活动聊天和桥结束。平台已受理的媒体任务保持原 task,升级后继续查询,不重派。
54
- 2. 用 `codex plugin list --json` 和 `codex plugin marketplace list --json` 确认原插件 ID、目录来源和当前版本。
60
+ 2. 用 `codex plugin marketplace list --json` 和 `codex plugin list --marketplace <原准确目录名> --json` 确认原插件 ID、目录来源和当前版本。
55
61
  3. Git 来源目录使用 `codex plugin marketplace upgrade <原目录名> --json` 更新目录;本地目录由其维护者更新到包含目标 npm 版本的目录。不要新注册一个同名插件来绕过升级。
56
- 4. 确认目录中的版本是目标版本后,执行 `codex plugin add <原插件ID> --json`。再次 `codex plugin list --json` 核目标版本已启用,再运行 Studio 的 `connect` 指令并正常重载。目录未提供目标版或升级失败时保持待升级,不循环卸载重装。
62
+ 4. 确认目录中的版本是目标版本后,执行 `codex plugin add <原插件ID> --json`。再次 `codex plugin list --marketplace <原准确目录名> --json` 核目标版本已启用,再运行 Studio 的 `connect` 指令并开 Local 新聊天。目录未提供目标版或升级失败时保持待升级,不循环卸载重装。
57
63
 
58
64
  受管入口按原安装记录核身份,不以当前 Node 路径认领。每次复用会实际运行已记录的 Node 和该版本 `--version`(各最多10秒,无平台调用),缺失、低于20或无法启动时返回 `installation.recorded_node_unavailable`。可恢复原 Node.js 20+ 路径,或运行 Studio 提供的较新版本 connect:新的受管版本使用当前 Node,保留旧代码及原凭据。相同版本不会偷偷重写旧启动配置。官方 npm 插件的 `node` 按当前宿主环境的 PATH 检查;Desktop 重载后的真实 MCP 启动仍须单独确认。
@@ -0,0 +1,10 @@
1
+ # 0.2.4 安装发现候选
2
+
3
+ 发行状态以 registry、provenance 和固定 creation-v0.2.4 标签为准;源码和本地打包候选不等于已发行。候选准备阶段 main 的公开目录保留实际已发行的 0.2.3,候选分支同步 package、lock、插件、目录和 CLIENT_VERSION,正式发行沿发布手册合入并使用新标签。0.2.3 原包和标签不改。
4
+
5
+ - 安装前后从宿主本地 marketplace 索引发现全部相关目录,只做相关插件查询,无关远端目录不阻塞安装。
6
+ - 目录或读结果未知保持未知,保留版本/来源/Node/MCP/profile 验证;错误只报告安全阶段与退出事实。
7
+ - 宿主登记前持久保存精确 pending 身份,写回程未知后先观察原登记,不第二次 add 或自动补偿覆盖旧注册。
8
+ - 已安装、已启用、平台连接验证与当前聊天加载分开报告。在同一主机开 Local 新聊天或 CLI 新 session,复用 Token;纯 MCP 创作不需要产品仓或 Worktree。
9
+
10
+ 候选使用隔离 HOME/CODEX_HOME/XDG、匿名本地 MCP 与替身 Codex CLI,经真实打包产物 npx/connect 检查。公共 registry 固定包、真实桌面新聊天的两个 Skill/MCP tools/list 与完整创作另行验收,不以候选测试代替。
package/lib/cli.mjs CHANGED
@@ -224,10 +224,11 @@ try {
224
224
  const installed=await installForUser({sourceRoot:fileURLToPath(new URL('..',import.meta.url)),
225
225
  profile:value('--profile')??'default',configFile:configFile(),signal:signal.signal});
226
226
  log({...connection,pluginRegistered:installed.registered,version:installed.version,
227
+ pluginInstalled:true,pluginEnabled:true,hostMcpConnected:'not_verified',sessionLoaded:'not_verified',
227
228
  installationReused:installed.reused,profile:installed.profile,
228
229
  requestedVersion:installed.requestedVersion,versionStatus:installed.versionStatus,
229
230
  recordedRuntimeRetained:installed.recordedRuntimeRetained??false,
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.',
231
+ next:'On this host, open a new Local chat (CLI: start a new session). Check creation-setup, video-creation and the PromptFrame MCP tools together. Keep the existing Token; no reinstall or product repository is needed.'+(installed.recordedRuntimeRetained?' Keep this version\'s recorded Node path available.':''),
231
232
  hostThreadIdentity:'verified_by_the_platform_on_actual_host_tool_calls'});
232
233
  }finally{process.removeListener('SIGINT',abort);process.removeListener('SIGTERM',abort);}
233
234
  }
@@ -1,9 +1,10 @@
1
1
  import {execFile} from 'node:child_process';
2
2
  import {promisify} from 'node:util';
3
3
  import {createHash,randomBytes} from 'node:crypto';
4
- import {lstat,mkdir,readdir,readFile,writeFile,rename,rm} from 'node:fs/promises';
4
+ import {lstat,mkdir,readdir,readFile,writeFile,rename,rm,open} from 'node:fs/promises';
5
5
  import {homedir} from 'node:os';
6
6
  import path from 'node:path';
7
+ import {parse as parseToml} from 'smol-toml';
7
8
  import {CreationClientError,credentialsPath} from './credentials.mjs';
8
9
 
9
10
  const execute=promisify(execFile),hash=b=>createHash('sha256').update(b).digest('hex');
@@ -92,7 +93,12 @@ async function officialNpmInstallation(installed,servers,env,profile,configFile)
92
93
  }
93
94
  async function atomicJSON(file,value){
94
95
  const temp=file+'.'+randomBytes(12).toString('hex')+'.tmp';
95
- try{await writeFile(temp,JSON.stringify(value,null,2)+'\n',{flag:'wx',mode:0o600});await rename(temp,file);}
96
+ try{
97
+ const out=await open(temp,'wx',0o600);
98
+ try{await out.writeFile(JSON.stringify(value,null,2)+'\n');await out.sync();}finally{await out.close();}
99
+ await rename(temp,file);const directory=await open(path.dirname(file),'r');
100
+ try{await directory.sync();}finally{await directory.close();}
101
+ }
96
102
  finally{await rm(temp,{force:true});}
97
103
  }
98
104
  async function packageFiles(root){
@@ -131,9 +137,72 @@ async function acquire(root,signal){
131
137
  catch(e){await rm(lock,{recursive:true,force:true});throw e;}
132
138
  return()=>rm(lock,{recursive:true,force:true});
133
139
  }
140
+ function commandKind(args){
141
+ if(args[0]==='--version')return 'host_version';
142
+ if(args[0]==='mcp'&&args[1]==='list')return 'mcp_read';
143
+ if(args[1]==='marketplace')return args[2]==='list'?'marketplace_read':'marketplace_register';
144
+ return args[1]==='list'?'plugin_read':'plugin_register';
145
+ }
134
146
  export async function runCodexCommand(args,{env=process.env}={}){
135
- try{return(await execute('codex',args,{env,encoding:'utf8',timeout:30_000,maxBuffer:2*1024*1024})).stdout;}
136
- catch(e){throw new CreationClientError(e.code==='ENOENT'?'installation.codex_required':'installation.codex_command_unconfirmed');}
147
+ const kind=commandKind(args),write=kind.endsWith('_register'),timeoutMs=write?30_000:5_000,start=performance.now();
148
+ try{return(await execute('codex',args,{env,encoding:'utf8',timeout:timeoutMs,maxBuffer:2*1024*1024})).stdout;}
149
+ catch(e){
150
+ const cause=e.code==='ENOENT'?'codex_required':e.code==='ERR_CHILD_PROCESS_STDIO_MAXBUFFER'?'command_output_limit'
151
+ :e.killed?'command_timeout':'command_failed';
152
+ fail(cause,{phase:write?'registration':'local_check',commandKind:kind,elapsedMs:Math.round(performance.now()-start),timeoutMs,
153
+ exitCode:Number.isInteger(e.code)?e.code:null,signal:['SIGTERM','SIGKILL','SIGINT'].includes(e.signal)?e.signal:null,
154
+ localRegistrationState:'unknown',action:write?'observe_same_registration_before_retry':'retry_local_read'});
155
+ }
156
+ }
157
+ async function codexJSON(runCodex,args){
158
+ const body=await runCodex(args);
159
+ try{if(typeof body!=='string'||Buffer.byteLength(body)>2*1024*1024)throw Error();return JSON.parse(body);}
160
+ catch{fail('command_json_unconfirmed',{phase:'local_check',commandKind:commandKind(args),localRegistrationState:'unknown',action:'retry_local_read'});}
161
+ }
162
+ // Marketplace roots are the host's structured, local discovery index. Read only
163
+ // their bounded catalogs, then ask the supported CLI about every related entry.
164
+ // An unreadable catalog is unknown, never evidence that no plugin is installed.
165
+ async function relatedPlugins(runCodex,pluginName,env){
166
+ const related=new Set(),registered=new Set(),config=path.join(path.resolve(env.CODEX_HOME??path.join(homedir(),'.codex')),'config.toml');
167
+ try{
168
+ const s=await info(config);
169
+ if(s){
170
+ if(!s.isFile()||s.isSymbolicLink()||s.size>2*1024*1024)throw Error();
171
+ const plugins=parseToml(await readFile(config,'utf8')).plugins??{};
172
+ if(!plugins||typeof plugins!=='object'||Array.isArray(plugins)||Object.keys(plugins).length>1024)throw Error();
173
+ for(const id of Object.keys(plugins))if(id.startsWith(pluginName+'@')){
174
+ const market=id.slice(pluginName.length+1);
175
+ if(!/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,140}$/.test(market))throw Error();
176
+ related.add(market);registered.add(id);
177
+ }
178
+ }
179
+ }catch{fail('local_config_unconfirmed',{phase:'local_check',commandKind:'local_config_read',localRegistrationState:'unknown',action:'review_local_plugin_registration'});}
180
+ const state=await codexJSON(runCodex,['plugin','marketplace','list','--json']);
181
+ if(!Array.isArray(state?.marketplaces)||state.marketplaces.length>128)fail('local_catalog_unconfirmed');
182
+ for(const market of state.marketplaces){
183
+ if(typeof market.name!=='string'||!/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,140}$/.test(market.name)
184
+ ||typeof market.root!=='string'||!path.isAbsolute(market.root))fail('local_catalog_unconfirmed');
185
+ let catalog;
186
+ try{catalog=await packageJSON(path.join(market.root,'.agents/plugins/marketplace.json'));}
187
+ catch{fail('local_catalog_unconfirmed',{phase:'local_check',commandKind:'marketplace_read',localRegistrationState:'unknown',action:'restore_local_marketplace_catalog'});}
188
+ if(!Array.isArray(catalog?.plugins)||catalog.plugins.length>1024)fail('local_catalog_unconfirmed');
189
+ if(catalog.plugins.some(p=>p?.name===pluginName))related.add(market.name);
190
+ }
191
+ const installed=[];
192
+ for(const market of related){
193
+ const list=await codexJSON(runCodex,['plugin','list','--marketplace',market,'--json']);
194
+ if(!Array.isArray(list?.installed)||list.installed.length>1024)fail('local_registration_unconfirmed');
195
+ for(const p of list.installed){
196
+ if(typeof p?.pluginId!=='string'||typeof p.enabled!=='boolean')fail('local_registration_unconfirmed');
197
+ if(p?.pluginId!==pluginName+'@'+market)continue;
198
+ if(p.marketplaceName!==undefined&&p.marketplaceName!==market)fail('local_registration_unconfirmed');
199
+ installed.push(p);
200
+ }
201
+ }
202
+ if(new Set(installed.map(p=>p.pluginId)).size!==installed.length)fail('local_registration_unconfirmed');
203
+ if([...registered].some(id=>!installed.some(p=>p.pluginId===id)))fail('local_registration_unconfirmed',{
204
+ phase:'local_check',commandKind:'plugin_read',localRegistrationState:'unknown',action:'review_same_local_registration'});
205
+ return installed;
137
206
  }
138
207
  async function runNode(root,version){
139
208
  try{const result=await execute(process.execPath,[path.join(root,'bin/promptframe-creation.mjs'),'--version'],{encoding:'utf8',timeout:10_000,maxBuffer:8192});
@@ -168,21 +237,34 @@ export async function installForUser({sourceRoot,profile='default',env=process.e
168
237
  const payload=await packageFiles(path.resolve(sourceRoot));
169
238
  const root=path.resolve(env.XDG_DATA_HOME??path.join(homedir(),'.local/share'),'promptframe-creation',profile);
170
239
  await privateDirectory(root);const release=await acquire(root,signal);
171
- const versions=path.join(root,'versions'),currentFile=path.join(root,'current.json');
240
+ const versions=path.join(root,'versions'),currentFile=path.join(root,'current.json'),pendingFile=path.join(root,'registration-pending.json');
172
241
  const marketplaceFile=path.join(root,'.agents/plugins/marketplace.json');
173
242
  const pluginName='promptframe-creation'+(profile==='default'?'':'-'+profile),marketplace='promptframe-creation-user'+(profile==='default'?'':'-'+profile);
174
243
  const pluginId=pluginName+'@'+marketplace;
175
244
  const versionRoot=path.join(versions,payload.version),temporary=path.join(versions,'.partial-'+randomBytes(12).toString('hex'));
176
- let previousCatalog,previous,registrationStarted=false,newFiles=0;
245
+ let previous,registrationStarted=false,newFiles=0;
177
246
  try{
178
247
  signal?.throwIfAborted();await privateDirectory(versions);await privateDirectory(path.dirname(marketplaceFile));
179
- previous=await privateRead(currentFile);previousCatalog=await privateRead(marketplaceFile);
248
+ previous=await privateRead(currentFile);
180
249
  if(previous&&(previous.profile!==profile||previous.pluginId!==pluginId||previous.configFile!==configFile))fail('profile_binding_conflict');
181
- const state=JSON.parse(await runCodex(['plugin','list','--json']));
182
- const installed=state.installed?.find(x=>x.pluginId===pluginId);
183
- const legacy=JSON.parse(await runCodex(['mcp','list','--json']));
250
+ const state={installed:await relatedPlugins(runCodex,pluginName,env)};
251
+ const installed=state.installed.find(x=>x.pluginId===pluginId);
252
+ const legacy=await codexJSON(runCodex,['mcp','list','--json']);
253
+ if(!Array.isArray(legacy))fail('local_registration_unconfirmed');
184
254
  const serverName='promptframe'+(profile==='default'?'':'-'+profile);
185
255
  const servers=legacy.filter(x=>x.name===serverName);
256
+ const pending=await privateRead(pendingFile);
257
+ if(pending){
258
+ if(pending.profile!==profile||pending.pluginId!==pluginId||pending.configFile!==configFile
259
+ ||pending.versionRoot!==path.join(versions,pending.version))fail('profile_binding_conflict');
260
+ if(installed?.version!==pending.version||installed.enabled!==true||installed.source?.path!==pending.versionRoot)
261
+ fail('registration_unconfirmed_keep_existing',{phase:'registration_observation',localRegistrationState:'unknown',action:'inspect_same_registration_no_second_add'});
262
+ const transport=await managedTransport(installed,versions,serverName,profile,configFile);
263
+ if(servers.length!==1||servers[0].enabled===false||!sameTransport(servers[0].transport,transport))fail('registration_unconfirmed_keep_existing');
264
+ const ready=await privateRead(path.join(pending.versionRoot,'installation.json'));
265
+ if(ready?.payloadDigest!==pending.payloadDigest)fail('installed_files_invalid');
266
+ previous=pending;await atomicJSON(currentFile,pending);await rm(pendingFile);
267
+ }
186
268
  const official=await officialNpmInstallation(state.installed??[],servers,env,profile,configFile);
187
269
  if(official){
188
270
  if(installed||previous)fail('existing_registration_requires_review');
@@ -203,6 +285,7 @@ export async function installForUser({sourceRoot,profile='default',env=process.e
203
285
  if(x.name!==serverName)return false;
204
286
  return !recorded||!sameTransport(x.transport,recorded);
205
287
  }))fail('legacy_mcp_entry_requires_review');
288
+ if(state.installed.some(p=>p.pluginId!==pluginId))fail('existing_registration_requires_review');
206
289
  if(installed&&compareVersions(installed.version,payload.version)>0){
207
290
  if(!previous||previous.version!==installed.version||previous.versionRoot!==installed.source.path||installed.enabled!==true)
208
291
  fail('existing_registration_requires_review');
@@ -244,31 +327,30 @@ export async function installForUser({sourceRoot,profile='default',env=process.e
244
327
  if(!already){
245
328
  const catalog={name:marketplace,interface:{displayName:'PromptFrame Creation'},plugins:[{name:pluginName,
246
329
  source:{source:'local',path:'./versions/'+payload.version},policy:{installation:'AVAILABLE',authentication:'ON_USE'},category:'Productivity'}]};
247
- await atomicJSON(marketplaceFile,catalog);signal?.throwIfAborted();registrationStarted=true;
330
+ await atomicJSON(marketplaceFile,catalog);signal?.throwIfAborted();
331
+ // Persist the exact identity before either registration write. An unknown
332
+ // reply is reconciled by reads on the next connect, never another add here.
333
+ await atomicJSON(pendingFile,complete);registrationStarted=true;
248
334
  await runCodex(['plugin','marketplace','add',root,'--json']);
249
335
  await runCodex(['plugin','add',pluginId,'--json']);
250
- const observed=JSON.parse(await runCodex(['plugin','list','--json'])).installed?.find(x=>x.pluginId===pluginId);
336
+ const observed=(await relatedPlugins(runCodex,pluginName,env)).find(x=>x.pluginId===pluginId);
251
337
  if(observed?.version!==payload.version||observed.enabled!==true)fail('registration_unconfirmed');
252
- await atomicJSON(currentFile,complete);
338
+ const launch=await managedTransport(observed,versions,serverName,profile,configFile);
339
+ const hostMcp=await codexJSON(runCodex,['mcp','list','--json']);
340
+ if(!Array.isArray(hostMcp))fail('registration_unconfirmed');
341
+ const effective=hostMcp.filter(x=>x.name===serverName);
342
+ if(effective.length!==1||effective[0].enabled===false||!sameTransport(effective[0].transport,launch))fail('registration_unconfirmed');
343
+ await atomicJSON(currentFile,complete);await rm(pendingFile);
253
344
  }
254
345
  return{...complete,currentFile,requestedVersion:payload.version,versionStatus:'current',reused:newFiles===0,installedFiles:newFiles,registered:true,reloadRequired:!already,
255
346
  recordedRuntimeRetained:Boolean(already&&recorded&&recorded.command!==process.execPath)};
256
347
  }catch(error){
257
348
  if(registrationStarted){
258
- // A lost command result may already have installed the complete candidate.
259
- // Keep all versions and the old default; never delete a possibly running copy.
260
- if(previousCatalog){
261
- await atomicJSON(marketplaceFile,previousCatalog);
262
- // Compensate only our exact earlier registration. If the command outcome
263
- // cannot be verified, report pending; the old files/default remain intact.
264
- if(previous){try{
265
- await runCodex(['plugin','add',pluginId,'--json']);
266
- const restored=JSON.parse(await runCodex(['plugin','list','--json'])).installed?.find(x=>x.pluginId===pluginId);
267
- if(restored?.version!==previous.version||restored.enabled!==true)fail('registration_unconfirmed');
268
- }catch{ /* No deletion, retry loop, token replacement or claim of restoration. */ }}
269
- }
270
- else await rm(marketplaceFile,{force:true});
271
- fail('registration_unconfirmed_keep_existing');
349
+ // Preserve the candidate catalog, old default, files and exact pending
350
+ // identity. Restoring a catalog and adding again could replay a committed
351
+ // write whose ACK was lost. Only a read may settle this attempt.
352
+ fail('registration_unconfirmed_keep_existing',{...installationErrorDetails(error),
353
+ phase:'registration_observation',localRegistrationState:'unknown',action:'inspect_same_registration_no_second_add'});
272
354
  }
273
355
  if(error instanceof CreationClientError)throw error;
274
356
  if(signal?.aborted)fail('interrupted_keep_existing');
package/lib/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const CLIENT_VERSION = "0.2.3";
1
+ export const CLIENT_VERSION = "0.2.4";
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.3",
3
+ "version": "0.2.4",
4
4
  "private": false,
5
5
  "description": "PromptFrame video creation Skill, Codex plugin and MCP client bridge.",
6
6
  "repository": {
@@ -35,6 +35,7 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "@modelcontextprotocol/sdk": "1.32.1",
38
- "esbuild": "0.27.7"
38
+ "esbuild": "0.27.7",
39
+ "smol-toml": "1.9.1"
39
40
  }
40
41
  }
@@ -39,6 +39,12 @@ CLI 的端点与组件上传授权按其公开说明配置,创作 Token 不代
39
39
 
40
40
  费用以平台原 receipt/账务读面为准,区分实计、预留、待结算和未知。成功媒体、工具终态和财务终态可以不同;未知不是免费。平台工具调用与外部自费推理/素材费用分开说明。
41
41
 
42
+ ## 旁白与字幕
43
+
44
+ 整篇旁白先发现当前平台的规划与绑定工具,提交完整正文并核其真实能力限制。平台支持时,默认按句/段语义规划,短旁白可整段;音频段、字幕行和分镜不必一一对应。按计划使用同一音色版本及公共参数,每个合成调用只对应一个明确段和原报价。
45
+
46
+ 保存每段原文范围、有效发声文本、原计划及已采用资产/operation。局部改文案沿原计划保持音色版本、seed 和公共参数,优先复用未改的成功段;结果未知只核原任务,不能重新生成追结果。字幕分块、样式或时序修复只绑定现有音频,不重TTS;仅凭时长估算仍标明estimated,不能冒精确逐字时间。当前目录未提供相关工具时准确说明限制,不在客户端另建合成队列或参数副本。
47
+
42
48
  ## 接回与完成
43
49
 
44
50
  交接前可保存简明外部报告,随后释放自己当前代次的编辑权。没有报告也不阻止本人从 Studio 接回。旧订单可按原事实收尾、晚结果入素材与原账;旧客户端不能覆盖新 Spec。