@promptframe/creation 0.3.13 → 0.3.15
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.
- package/.agents/plugins/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/README.md +1 -1
- package/dist/cli.mjs +261 -119
- package/docs/install-guidance.json +1 -1
- package/docs/installing.md +6 -4
- package/lib/antigravity-host-session.mjs +76 -25
- package/lib/antigravity-installation.mjs +91 -14
- package/lib/cli.mjs +8 -4
- package/lib/version.mjs +1 -1
- package/package.json +1 -1
- package/skills/creation-setup/SKILL.md +3 -3
package/docs/installing.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
<!-- creation-install-command -->
|
|
8
8
|
```bash
|
|
9
|
-
npx --yes @promptframe/creation@0.3.
|
|
9
|
+
npx --yes @promptframe/creation@0.3.15 connect --endpoint <Studio提供的API地址>
|
|
10
10
|
```
|
|
11
11
|
<!-- /creation-install-command -->
|
|
12
12
|
|
|
@@ -26,7 +26,7 @@ npx --yes @promptframe/creation@0.3.13 connect --endpoint <Studio提供的API地
|
|
|
26
26
|
|
|
27
27
|
<!-- creation-install-command -->
|
|
28
28
|
```bash
|
|
29
|
-
npx --yes @promptframe/creation@0.3.
|
|
29
|
+
npx --yes @promptframe/creation@0.3.15 connect --host claude-code --endpoint <Studio提供的API地址>
|
|
30
30
|
```
|
|
31
31
|
<!-- /creation-install-command -->
|
|
32
32
|
|
|
@@ -44,12 +44,14 @@ CLI 优先使用 PATH 中的 Claude;桌面版远程连接 WSL 时,也识别
|
|
|
44
44
|
|
|
45
45
|
<!-- creation-install-command -->
|
|
46
46
|
```bash
|
|
47
|
-
npx --yes @promptframe/creation@0.3.
|
|
47
|
+
npx --yes @promptframe/creation@0.3.15 connect --host antigravity --endpoint <Studio提供的API地址>
|
|
48
48
|
```
|
|
49
49
|
<!-- /creation-install-command -->
|
|
50
50
|
|
|
51
51
|
安装后检查 Antigravity 的 Customizations 中是否启用 PromptFrame Creation,再打开新对话。插件通过 `PreToolUse` 将调用绑定到实际对话,两个 Skill 和 MCP 工具由宿主加载。首次授权在终端隐藏输入,已有有效授权可复用。
|
|
52
52
|
|
|
53
|
+
0.3.14 支持 Antigravity 默认的懒加载 MCP 调用。已有插件需重跑本段命令以更新注册的 hook,再开独立对话。如果安装报告 `installation.legacy_mcp_entry_requires_review`,在 Antigravity 的 MCP 设置核对清单所列的旧手工 PromptFrame 条目,移除冲突条目后重试。安装器保留全局文件和其他 MCP 配置。
|
|
54
|
+
|
|
53
55
|
## 环境与账号
|
|
54
56
|
|
|
55
57
|
默认凭据沿用 `$XDG_CONFIG_HOME/promptframe-creation/credentials.json`(未配置 XDG 时位于用户 `.config`)。旧的 `PROMPTFRAME_CREATION_CONFIG` 仍可显式引用安全文件。
|
|
@@ -58,7 +60,7 @@ npx --yes @promptframe/creation@0.3.13 connect --host antigravity --endpoint <St
|
|
|
58
60
|
|
|
59
61
|
<!-- creation-install-command -->
|
|
60
62
|
```bash
|
|
61
|
-
npx --yes @promptframe/creation@0.3.
|
|
63
|
+
npx --yes @promptframe/creation@0.3.15 connect --profile work-account --endpoint <另一环境API地址>
|
|
62
64
|
```
|
|
63
65
|
<!-- /creation-install-command -->
|
|
64
66
|
|
|
@@ -9,7 +9,11 @@ import {threadFormat} from './host-identity.mjs';
|
|
|
9
9
|
|
|
10
10
|
const hex=/^[0-9a-f]{64}$/;
|
|
11
11
|
const TICKET_TTL_MS=120_000;
|
|
12
|
+
const SESSION_TTL_MS=24*60*60*1000;
|
|
12
13
|
const MAX_TICKETS=256;
|
|
14
|
+
const MAX_SESSIONS=256;
|
|
15
|
+
const DEFAULT_SERVER='promptframe_pf';
|
|
16
|
+
const mcpToolName=/^[A-Za-z0-9_.:-]{1,200}$/;
|
|
13
17
|
const error=code=>new CreationClientError('creation.'+code);
|
|
14
18
|
const canonical=value=>{
|
|
15
19
|
if(value===null||typeof value==='string'||typeof value==='boolean'||typeof value==='number'&&Number.isFinite(value))return JSON.stringify(value);
|
|
@@ -21,9 +25,33 @@ const canonical=value=>{
|
|
|
21
25
|
const digest=value=>createHash('sha256').update(canonical(value)).digest('hex');
|
|
22
26
|
const withoutProof=args=>Object.fromEntries(Object.entries(args??{}).filter(([key])=>key!==CLAUDE_HOST_PROOF));
|
|
23
27
|
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
function objectArgs(value){
|
|
29
|
+
return value&&typeof value==='object'&&!Array.isArray(value)?value:null;
|
|
30
|
+
}
|
|
31
|
+
function promptFrameCall(toolCall,serverName){
|
|
32
|
+
if(typeof toolCall?.name!=='string')return null;
|
|
33
|
+
const args=objectArgs(toolCall.args)??{};
|
|
34
|
+
if(toolCall.name==='call_mcp_tool'){
|
|
35
|
+
if(args.ServerName!==serverName||typeof args.ToolName!=='string'||!mcpToolName.test(args.ToolName))return null;
|
|
36
|
+
const inner=args.Arguments===undefined?{}:objectArgs(args.Arguments);
|
|
37
|
+
return inner?{name:args.ToolName,args:inner,lazy:true}:null;
|
|
38
|
+
}
|
|
39
|
+
// Match the namespaced server, the former eager prefix, or a native
|
|
40
|
+
// PromptFrame tool name already reduced by the host.
|
|
41
|
+
const namespacedPrefix=`mcp_${serverName}_`,oldPrefix=`mcp_${serverName.split('_')[0]}_`;
|
|
42
|
+
if(toolCall.name.startsWith(namespacedPrefix)){
|
|
43
|
+
const name=toolCall.name.slice(namespacedPrefix.length);
|
|
44
|
+
return mcpToolName.test(name)?{name,args,lazy:false}:null;
|
|
45
|
+
}
|
|
46
|
+
const name=toolCall.name.startsWith(oldPrefix)?toolCall.name.slice(oldPrefix.length):toolCall.name;
|
|
47
|
+
return /^(?:platform_|promptframe_local_)[a-z0-9_]+$/i.test(name)&&mcpToolName.test(name)?{name,args,lazy:false}:null;
|
|
48
|
+
}
|
|
49
|
+
function sessionId(value){
|
|
50
|
+
return typeof value==='string'&&threadFormat.test(value)?value.toLowerCase():null;
|
|
51
|
+
}
|
|
52
|
+
function transcriptDigest(input){
|
|
53
|
+
const file=input?.transcriptPath;
|
|
54
|
+
return typeof file==='string'&&file.length<=4096&&path.isAbsolute(file)?digest(path.normalize(file)):null;
|
|
27
55
|
}
|
|
28
56
|
function toolNameMatches(hookToolName,bridgeToolName){
|
|
29
57
|
if(typeof hookToolName!=='string'||typeof bridgeToolName!=='string'||!bridgeToolName)return false;
|
|
@@ -51,7 +79,7 @@ export function antigravityConfigRoot(env=process.env){
|
|
|
51
79
|
/** Local host provenance for Antigravity. Supports multiple concurrent
|
|
52
80
|
* conversations sharing one plugin MCP server process by binding each
|
|
53
81
|
* one-use PreToolUse ticket to its conversationId UUID and exact arguments. */
|
|
54
|
-
export async function createAntigravityHostSession({configFile,env=process.env,root,now=()=>Date.now()}={}){
|
|
82
|
+
export async function createAntigravityHostSession({configFile,env=process.env,root,serverName=DEFAULT_SERVER,now=()=>Date.now()}={}){
|
|
55
83
|
const base=root??path.join(antigravityConfigRoot(env),'promptframe-host-sessions');
|
|
56
84
|
const namespace=path.join(base,digest(path.resolve(configFile)));
|
|
57
85
|
const stateFile=path.join(namespace,'state.json');
|
|
@@ -96,6 +124,19 @@ export async function createAntigravityHostSession({configFile,env=process.env,r
|
|
|
96
124
|
return kept;
|
|
97
125
|
}
|
|
98
126
|
|
|
127
|
+
function pruneSessions(sessions,currentTime){
|
|
128
|
+
const active=Object.entries(sessions??{}).filter(([id,value])=>sessionId(id)
|
|
129
|
+
&&Number.isSafeInteger(value?.expiresAt)&&value.expiresAt>currentTime);
|
|
130
|
+
return Object.fromEntries(active.slice(-MAX_SESSIONS));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function bindSession(sessions,id,transcript,currentTime){
|
|
134
|
+
const previous=sessions[id];
|
|
135
|
+
delete sessions[id];
|
|
136
|
+
sessions[id]={transcriptDigest:transcript??previous?.transcriptDigest??null,expiresAt:currentTime+SESSION_TTL_MS};
|
|
137
|
+
return pruneSessions(sessions,currentTime);
|
|
138
|
+
}
|
|
139
|
+
|
|
99
140
|
async function begin(raw){
|
|
100
141
|
const proof=raw.arguments?.[CLAUDE_HOST_PROOF],args=withoutProof(raw.arguments);
|
|
101
142
|
if(proof===undefined)return {host:{kind:'antigravity'},assertCurrent:async()=>{},arguments:args};
|
|
@@ -106,7 +147,8 @@ export async function createAntigravityHostSession({configFile,env=process.env,r
|
|
|
106
147
|
await transaction(current=>{
|
|
107
148
|
const ticket=current.tickets[proof];
|
|
108
149
|
if(!ticket||ticket.expiresAt<=currentTime||ticket.argsDigest!==argsHash
|
|
109
|
-
||!
|
|
150
|
+
||!(ticket.exactToolName?ticket.toolName===raw.name:toolNameMatches(ticket.toolName,raw.name))
|
|
151
|
+
||!threadFormat.test(ticket.conversationId??''))
|
|
110
152
|
throw error('host_identity_invalid');
|
|
111
153
|
accepted={threadId:ticket.conversationId.toLowerCase()};
|
|
112
154
|
delete current.tickets[proof];
|
|
@@ -117,29 +159,38 @@ export async function createAntigravityHostSession({configFile,env=process.env,r
|
|
|
117
159
|
return {host:{kind:'antigravity',threadId:accepted.threadId},arguments:args,assertCurrent:async()=>{}};
|
|
118
160
|
}
|
|
119
161
|
|
|
120
|
-
async function hook(input){
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const conversationId=typeof input.conversationId==='string'&&threadFormat.test(input.conversationId)
|
|
130
|
-
?input.conversationId.toLowerCase():null;
|
|
131
|
-
if(!conversationId){
|
|
132
|
-
return Object.hasOwn(rawArgs,CLAUDE_HOST_PROOF)?{decision:'deny',reason:'Missing valid Antigravity conversationId for PromptFrame proof.'}:{decision:'allow'};
|
|
162
|
+
async function hook(input,event=input?.hookEventName??'PreToolUse'){
|
|
163
|
+
if(input?.hookEventName!==undefined&&input.hookEventName!==event)return {};
|
|
164
|
+
const id=sessionId(input?.conversationId),transcript=transcriptDigest(input),currentTime=now();
|
|
165
|
+
if(event==='SessionStart'){
|
|
166
|
+
if(id)await transaction(current=>{
|
|
167
|
+
current.sessions=bindSession(pruneSessions(current.sessions,currentTime),id,transcript,currentTime);
|
|
168
|
+
return current;
|
|
169
|
+
});
|
|
170
|
+
return {};
|
|
133
171
|
}
|
|
134
|
-
|
|
172
|
+
if(event!=='PreToolUse')return {};
|
|
173
|
+
const call=promptFrameCall(input?.toolCall,serverName);
|
|
174
|
+
if(!call)return {decision:'allow'};
|
|
175
|
+
const args=withoutProof(call.args),argsHash=digest(args);
|
|
135
176
|
let token;
|
|
136
177
|
await transaction(current=>{
|
|
178
|
+
const sessions=pruneSessions(current.sessions,currentTime);
|
|
179
|
+
// SessionStart is a fallback only for an exact, unambiguous transcript.
|
|
180
|
+
// A shared bridge must never choose the most recently opened conversation.
|
|
181
|
+
const matches=!id&&input?.conversationId===undefined&&transcript
|
|
182
|
+
?Object.keys(sessions).filter(key=>sessions[key].transcriptDigest===transcript):[];
|
|
183
|
+
const conversationId=id??(matches.length===1?matches[0]:null);
|
|
184
|
+
if(!conversationId)return;
|
|
137
185
|
const tickets=pruneTickets(current.tickets,currentTime);
|
|
138
186
|
token=randomBytes(32).toString('hex');
|
|
139
|
-
tickets[token]={toolName:
|
|
140
|
-
return {contractVersion:'antigravity-host-session/v1',tickets};
|
|
187
|
+
tickets[token]={toolName:call.name,exactToolName:true,argsDigest:argsHash,conversationId,expiresAt:currentTime+TICKET_TTL_MS};
|
|
188
|
+
return {contractVersion:'antigravity-host-session/v1',tickets,sessions:bindSession(sessions,conversationId,transcript,currentTime)};
|
|
141
189
|
});
|
|
142
|
-
return
|
|
190
|
+
if(!token)return Object.hasOwn(call.args,CLAUDE_HOST_PROOF)
|
|
191
|
+
?{decision:'deny',reason:'Missing valid Antigravity conversationId for PromptFrame proof.'}:{decision:'allow'};
|
|
192
|
+
return {decision:'allow',overwrite:call.lazy
|
|
193
|
+
?{Arguments:{...args,[CLAUDE_HOST_PROOF]:token}}:{[CLAUDE_HOST_PROOF]:token}};
|
|
143
194
|
}
|
|
144
195
|
|
|
145
196
|
return {begin,hook};
|
|
@@ -152,8 +203,8 @@ export async function readAntigravityHookInput(input){
|
|
|
152
203
|
return JSON.parse(new TextDecoder('utf-8',{fatal:true}).decode(Buffer.concat(chunks,bytes)));
|
|
153
204
|
}
|
|
154
205
|
|
|
155
|
-
export async function runAntigravityHostHook({configFile,input=process.stdin,output=process.stdout,env=process.env}={}){
|
|
206
|
+
export async function runAntigravityHostHook({configFile,serverName,event,input=process.stdin,output=process.stdout,env=process.env}={}){
|
|
156
207
|
const body=await readAntigravityHookInput(input);
|
|
157
|
-
const store=await createAntigravityHostSession({configFile,env});
|
|
158
|
-
output.write(JSON.stringify(await store.hook(body))+'\n');
|
|
208
|
+
const store=await createAntigravityHostSession({configFile,serverName,env});
|
|
209
|
+
output.write(JSON.stringify(await store.hook(body,event))+'\n');
|
|
159
210
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {lstat,mkdir,open,readFile,rename,rm} from 'node:fs/promises';
|
|
2
|
+
import {constants} from 'node:fs';
|
|
2
3
|
import {createHash,randomBytes} from 'node:crypto';
|
|
3
4
|
import {homedir} from 'node:os';
|
|
4
5
|
import path from 'node:path';
|
|
@@ -8,14 +9,70 @@ import {inspectRuntimePackage} from './runtime-package.mjs';
|
|
|
8
9
|
import {antigravityConfigRoot} from './antigravity-host-session.mjs';
|
|
9
10
|
|
|
10
11
|
const hash=b=>createHash('sha256').update(b).digest('hex');
|
|
11
|
-
|
|
12
|
+
class AntigravityInstallationError extends CreationClientError{
|
|
13
|
+
constructor(code,details){super('installation.'+code);this.details=details;}
|
|
14
|
+
}
|
|
15
|
+
export const antigravityInstallationDetails=error=>error instanceof AntigravityInstallationError?error.details:undefined;
|
|
16
|
+
const fail=(code,details)=>{throw new AntigravityInstallationError(code,details);};
|
|
12
17
|
const profileFormat=/^[a-z0-9][a-z0-9-]{0,39}$/;
|
|
18
|
+
const ANTIGRAVITY_MCP_SERVER_KEY='pf';
|
|
19
|
+
const antigravityPluginName=profile=>'promptframe'+(profile==='default'?'':'-'+profile);
|
|
20
|
+
const legacyAntigravityPluginName=profile=>'promptframe-creation'+(profile==='default'?'':'-'+profile);
|
|
21
|
+
const antigravityServerName=profile=>`${antigravityPluginName(profile)}_${ANTIGRAVITY_MCP_SERVER_KEY}`;
|
|
22
|
+
const object=value=>value!==null&&typeof value==='object'&&!Array.isArray(value);
|
|
23
|
+
|
|
24
|
+
function usesCreationBridge(server,{profile,configFile}){
|
|
25
|
+
if(!object(server)||typeof server.command!=='string'||!Array.isArray(server.args))return false;
|
|
26
|
+
const args=server.args;
|
|
27
|
+
const bridgeIndex=args.indexOf('bridge');
|
|
28
|
+
if(bridgeIndex<0)return false;
|
|
29
|
+
const isCreationExecutable=value=>typeof value==='string'&&/^promptframe-creation(?:\.mjs|\.cmd|\.exe)?$/.test(path.win32.basename(value));
|
|
30
|
+
const command=path.win32.basename(server.command);
|
|
31
|
+
const bridgeLauncher=isCreationExecutable(command)||
|
|
32
|
+
(/^(?:node|nodejs|bun)(?:\.exe)?$/.test(command)&&isCreationExecutable(args[bridgeIndex-1]))||
|
|
33
|
+
(/^(?:npx|npm|pnpm|yarn|bunx)(?:\.cmd|\.exe)?$/.test(command)&&
|
|
34
|
+
typeof args[bridgeIndex-1]==='string'&&/^@promptframe\/creation(?:@[^\s]+)?$/.test(args[bridgeIndex-1]));
|
|
35
|
+
if(!bridgeLauncher)return false;
|
|
36
|
+
|
|
37
|
+
const configIndex=args.indexOf('--config',bridgeIndex+1);
|
|
38
|
+
const profileIndex=args.indexOf('--profile',bridgeIndex+1);
|
|
39
|
+
const configuredProfile=profileIndex<0?'default':args[profileIndex+1];
|
|
40
|
+
const configuredFile=configIndex>=0?args[configIndex+1]:configuredProfile==='default'?server.env?.PROMPTFRAME_CREATION_CONFIG:undefined;
|
|
41
|
+
if(typeof configuredFile==='string'&&path.isAbsolute(configuredFile))return path.resolve(configuredFile)===configFile;
|
|
42
|
+
return configuredProfile===profile;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function checkAntigravityMcpConflicts({profile='default',configFile,env=process.env}={}){
|
|
46
|
+
const mcpConfigFile=path.join(antigravityConfigRoot(env),'mcp_config.json');
|
|
47
|
+
const unreadable=()=>fail('antigravity_mcp_config_unreadable',{mcpConfigFile,
|
|
48
|
+
action:'Check that the Antigravity MCP configuration is readable and contains a valid JSON object, then retry connect.'});
|
|
49
|
+
let file;
|
|
50
|
+
try{file=await open(mcpConfigFile,constants.O_RDONLY|constants.O_NONBLOCK);}
|
|
51
|
+
catch(error){if(error.code==='ENOENT')return;unreadable();}
|
|
52
|
+
let config;
|
|
53
|
+
try{
|
|
54
|
+
const info=await file.stat();
|
|
55
|
+
if(!info.isFile()||info.size>4*1024*1024)unreadable();
|
|
56
|
+
config=JSON.parse(await file.readFile('utf8'));
|
|
57
|
+
}catch{unreadable();}finally{await file.close();}
|
|
58
|
+
if(!object(config)||config.mcpServers!==undefined&&!object(config.mcpServers))unreadable();
|
|
59
|
+
const pluginName=antigravityPluginName(profile);
|
|
60
|
+
const legacyPluginName=legacyAntigravityPluginName(profile);
|
|
61
|
+
const serverName=antigravityServerName(profile);
|
|
62
|
+
const mcpServerNames=Object.entries(config.mcpServers??{})
|
|
63
|
+
.filter(([name,server])=>name===pluginName||name===serverName
|
|
64
|
+
||name===legacyPluginName||name===`${legacyPluginName}_${legacyPluginName}`
|
|
65
|
+
||usesCreationBridge(server,{profile,configFile}))
|
|
66
|
+
.map(([name])=>name);
|
|
67
|
+
if(mcpServerNames.length)fail('legacy_mcp_entry_requires_review',{mcpConfigFile,mcpServerNames,
|
|
68
|
+
action:'In Antigravity MCP settings, review the listed entries and remove the conflicting manual PromptFrame entries, then rerun connect with the existing Token.'});
|
|
69
|
+
}
|
|
13
70
|
|
|
14
71
|
function shellQuote(value){
|
|
15
72
|
return '"'+String(value).replace(/(["\\$`])/g,'\\$1')+'"';
|
|
16
73
|
}
|
|
17
74
|
|
|
18
|
-
export function antigravityPluginManifest({version,name='promptframe
|
|
75
|
+
export function antigravityPluginManifest({version,name='promptframe',displayName='PromptFrame Creation'}){
|
|
19
76
|
return {
|
|
20
77
|
name,
|
|
21
78
|
displayName,
|
|
@@ -30,10 +87,10 @@ export function antigravityPluginManifest({version,name='promptframe-creation',d
|
|
|
30
87
|
};
|
|
31
88
|
}
|
|
32
89
|
|
|
33
|
-
export function antigravityMcpConfig({
|
|
90
|
+
export function antigravityMcpConfig({serverKey=ANTIGRAVITY_MCP_SERVER_KEY,nodeCommand,runtimeRoot,configFile}){
|
|
34
91
|
return {
|
|
35
92
|
mcpServers:{
|
|
36
|
-
[
|
|
93
|
+
[serverKey]:{
|
|
37
94
|
command:nodeCommand,
|
|
38
95
|
args:[path.join(runtimeRoot,'bin','promptframe-creation.mjs'),'bridge','--config',configFile,'--host','antigravity'],
|
|
39
96
|
},
|
|
@@ -41,15 +98,17 @@ export function antigravityMcpConfig({serverName,nodeCommand,runtimeRoot,configF
|
|
|
41
98
|
};
|
|
42
99
|
}
|
|
43
100
|
|
|
44
|
-
export function antigravityHooksConfig({nodeCommand,runtimeRoot,configFile}){
|
|
101
|
+
export function antigravityHooksConfig({nodeCommand,runtimeRoot,configFile,serverName}){
|
|
45
102
|
const cliPath=path.join(runtimeRoot,'bin','promptframe-creation.mjs');
|
|
46
|
-
const command=[shellQuote(nodeCommand),shellQuote(cliPath),'antigravity-host-hook','--config',shellQuote(configFile)
|
|
103
|
+
const command=[shellQuote(nodeCommand),shellQuote(cliPath),'antigravity-host-hook','--config',shellQuote(configFile),
|
|
104
|
+
'--mcp-server',shellQuote(serverName)].join(' ');
|
|
47
105
|
return {
|
|
48
106
|
'promptframe-host-identity':{
|
|
107
|
+
SessionStart:[{type:'command',command:command+' --hook-event SessionStart',timeout:5}],
|
|
49
108
|
PreToolUse:[
|
|
50
109
|
{
|
|
51
|
-
matcher:'(.*promptframe.*|^platform_
|
|
52
|
-
hooks:[{type:'command',command,timeout:5}],
|
|
110
|
+
matcher:'(.*promptframe.*|^platform_.*|^call_mcp_tool$)',
|
|
111
|
+
hooks:[{type:'command',command:command+' --hook-event PreToolUse',timeout:5}],
|
|
53
112
|
},
|
|
54
113
|
],
|
|
55
114
|
},
|
|
@@ -83,6 +142,18 @@ async function copyPackagePayload(payload,destRoot){
|
|
|
83
142
|
}
|
|
84
143
|
}
|
|
85
144
|
|
|
145
|
+
async function cleanupLegacyPluginDirectory({pluginsRoot,profile,configFile}){
|
|
146
|
+
const legacyDir=path.join(pluginsRoot,legacyAntigravityPluginName(profile));
|
|
147
|
+
let status;
|
|
148
|
+
try{status=await lstat(legacyDir);}catch(e){if(e.code==='ENOENT')return false;throw e;}
|
|
149
|
+
if(!status.isDirectory()||status.isSymbolicLink())return false;
|
|
150
|
+
const legacyMarker=await readJsonOrNull(path.join(legacyDir,'promptframe-installation.json'));
|
|
151
|
+
if(!legacyMarker||legacyMarker.host!=='antigravity'||legacyMarker.profile!==profile
|
|
152
|
+
||legacyMarker.configFile!==configFile)return false;
|
|
153
|
+
await rm(legacyDir,{recursive:true,force:true});
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
|
|
86
157
|
/** Install PromptFrame Creation as a native Antigravity plugin once.
|
|
87
158
|
* Subsequent bridge upgrades happen automatically on startup via
|
|
88
159
|
* runtime-bootstrap.mjs without requiring plugin reinstallation. */
|
|
@@ -97,10 +168,11 @@ export async function installForAntigravityUser({
|
|
|
97
168
|
if(!profileFormat.test(profile))fail('profile_invalid');
|
|
98
169
|
if(!path.isAbsolute(configFile??''))fail('config_path_invalid');
|
|
99
170
|
signal?.throwIfAborted();
|
|
171
|
+
await checkAntigravityMcpConflicts({profile,configFile,env});
|
|
100
172
|
const payload=await inspectRuntimePackage(sourceRoot);
|
|
101
|
-
const
|
|
102
|
-
const
|
|
103
|
-
const serverName=
|
|
173
|
+
const pluginDirName=antigravityPluginName(profile);
|
|
174
|
+
const serverKey=ANTIGRAVITY_MCP_SERVER_KEY;
|
|
175
|
+
const serverName=antigravityServerName(profile);
|
|
104
176
|
const dataRoot=path.resolve(env.XDG_DATA_HOME??path.join(homedir(),'.local','share'),'promptframe-creation',profile,'antigravity');
|
|
105
177
|
const versionRoot=path.join(dataRoot,'versions',payload.version);
|
|
106
178
|
const pluginsRoot=path.join(antigravityConfigRoot(env),'plugins');
|
|
@@ -120,12 +192,15 @@ export async function installForAntigravityUser({
|
|
|
120
192
|
||typeof existing.version!=='string'||!/^\d+\.\d+\.\d+$/.test(existing.version))fail('managed_installation_invalid');
|
|
121
193
|
const cmp=compareBridgeVersions(existing.version,payload.version);
|
|
122
194
|
if(cmp>0){
|
|
195
|
+
await cleanupLegacyPluginDirectory({pluginsRoot,profile,configFile});
|
|
123
196
|
return {registered:true,pluginInstalled:true,pluginEnabled:true,reused:true,host:'antigravity',
|
|
124
197
|
installationMode:'antigravity-plugin',profile,version:existing.version,requestedVersion:payload.version,
|
|
125
198
|
versionStatus:'newer_installed_kept',recordedRuntimeRetained:true,pluginDir,serverName,
|
|
126
199
|
skillsInstalled:true,skills:[{name:'creation-setup'},{name:'video-creation'}]};
|
|
127
200
|
}
|
|
128
|
-
if(cmp===0&&existing.payloadDigest===payload.payloadDigest&&existing.versionRoot===versionRoot
|
|
201
|
+
if(cmp===0&&existing.payloadDigest===payload.payloadDigest&&existing.versionRoot===versionRoot
|
|
202
|
+
&&existing.serverName===serverName){
|
|
203
|
+
await cleanupLegacyPluginDirectory({pluginsRoot,profile,configFile});
|
|
129
204
|
return {registered:true,pluginInstalled:true,pluginEnabled:true,reused:true,host:'antigravity',
|
|
130
205
|
installationMode:'antigravity-plugin',profile,version:payload.version,requestedVersion:payload.version,
|
|
131
206
|
versionStatus:'already_current',recordedRuntimeRetained:false,pluginDir,serverName,
|
|
@@ -150,8 +225,8 @@ export async function installForAntigravityUser({
|
|
|
150
225
|
name:pluginDirName,
|
|
151
226
|
displayName:profile==='default'?'PromptFrame Creation':'PromptFrame Creation ('+profile+')',
|
|
152
227
|
}),null,2)+'\n';
|
|
153
|
-
const mcpJson=JSON.stringify(antigravityMcpConfig({
|
|
154
|
-
const hooksJson=JSON.stringify(antigravityHooksConfig({nodeCommand,runtimeRoot:versionRoot,configFile}),null,2)+'\n';
|
|
228
|
+
const mcpJson=JSON.stringify(antigravityMcpConfig({serverKey,nodeCommand,runtimeRoot:versionRoot,configFile}),null,2)+'\n';
|
|
229
|
+
const hooksJson=JSON.stringify(antigravityHooksConfig({nodeCommand,runtimeRoot:versionRoot,configFile,serverName}),null,2)+'\n';
|
|
155
230
|
|
|
156
231
|
await writeFileAtomic(path.join(pluginDir,'plugin.json'),pluginJson,0o644);
|
|
157
232
|
await writeFileAtomic(path.join(pluginDir,'mcp_config.json'),mcpJson,0o600);
|
|
@@ -169,6 +244,7 @@ export async function installForAntigravityUser({
|
|
|
169
244
|
profile,
|
|
170
245
|
configFile,
|
|
171
246
|
pluginDirName,
|
|
247
|
+
serverKey,
|
|
172
248
|
serverName,
|
|
173
249
|
version:payload.version,
|
|
174
250
|
versionRoot,
|
|
@@ -179,6 +255,7 @@ export async function installForAntigravityUser({
|
|
|
179
255
|
installedAt:new Date().toISOString(),
|
|
180
256
|
};
|
|
181
257
|
await writeFileAtomic(markerFile,JSON.stringify(record,null,2)+'\n',0o600);
|
|
258
|
+
await cleanupLegacyPluginDirectory({pluginsRoot,profile,configFile});
|
|
182
259
|
|
|
183
260
|
return {
|
|
184
261
|
registered:true,
|
package/lib/cli.mjs
CHANGED
|
@@ -33,7 +33,7 @@ import {selectBridgeRuntime,runtimeErrorDetails} from './runtime-bootstrap.mjs';
|
|
|
33
33
|
import {launchSelectedBridge} from './runtime-launch.mjs';
|
|
34
34
|
import {installForUser,profileCredentialsPath,installationErrorDetails} from './user-installation.mjs';
|
|
35
35
|
import {installForClaudeUser,claudeInstallationDetails} from './claude-installation.mjs';
|
|
36
|
-
import {installForAntigravityUser} from './antigravity-installation.mjs';
|
|
36
|
+
import {antigravityInstallationDetails,checkAntigravityMcpConflicts,installForAntigravityUser} from './antigravity-installation.mjs';
|
|
37
37
|
import {claudeErrorDetails} from './claude-command.mjs';
|
|
38
38
|
import {fallbackErrorDetails} from './claude-mcp-installation.mjs';
|
|
39
39
|
import {fileURLToPath} from 'node:url';
|
|
@@ -310,14 +310,16 @@ async function bridge() {
|
|
|
310
310
|
try {
|
|
311
311
|
if (command === "setup") await setup();
|
|
312
312
|
else if(command==='connect'||command==='install'){
|
|
313
|
+
const host=resolveHostIdentity({host:value('--host')});
|
|
314
|
+
const profile=value('--profile')??'default';
|
|
315
|
+
if(host.kind==='antigravity')await checkAntigravityMcpConflicts({profile,configFile:configFile()});
|
|
313
316
|
const connection=await setup({silent:true});
|
|
314
317
|
const signal=new AbortController();
|
|
315
318
|
const abort=()=>signal.abort();process.once('SIGINT',abort);process.once('SIGTERM',abort);
|
|
316
319
|
try{
|
|
317
|
-
const host=resolveHostIdentity({host:value('--host')});
|
|
318
320
|
const installer=host.kind==='claude-code'?installForClaudeUser:host.kind==='antigravity'?installForAntigravityUser:installForUser;
|
|
319
321
|
const installed=await installer({sourceRoot:fileURLToPath(new URL('..',import.meta.url)),
|
|
320
|
-
executable:value('--claude-bin'),profile
|
|
322
|
+
executable:value('--claude-bin'),profile,configFile:configFile(),signal:signal.signal});
|
|
321
323
|
const skillNames=installed.skills?.map(skill=>skill.name)??['creation-setup','video-creation'];
|
|
322
324
|
const nextStep=host.kind==='claude-code'
|
|
323
325
|
?'On this host, start a new Claude Code session.'
|
|
@@ -339,7 +341,8 @@ try {
|
|
|
339
341
|
}
|
|
340
342
|
else if (command === "bridge") await bridge();
|
|
341
343
|
else if(command==='claude-host-hook')await runClaudeHostHook({configFile:configFile()});
|
|
342
|
-
else if(command==='antigravity-host-hook')await runAntigravityHostHook({configFile:configFile()
|
|
344
|
+
else if(command==='antigravity-host-hook')await runAntigravityHostHook({configFile:configFile(),
|
|
345
|
+
serverName:value('--mcp-server'),event:value('--hook-event')});
|
|
343
346
|
else if(command==='--version')process.stdout.write(CLIENT_VERSION+'\n');
|
|
344
347
|
else if(command==='accounts'){
|
|
345
348
|
if(args[0]==='refresh'){
|
|
@@ -372,6 +375,7 @@ try {
|
|
|
372
375
|
process.stderr.write(
|
|
373
376
|
JSON.stringify({
|
|
374
377
|
...installationErrorDetails(error),
|
|
378
|
+
...antigravityInstallationDetails(error),
|
|
375
379
|
...claudeInstallationDetails(error),
|
|
376
380
|
...claudeErrorDetails(error),
|
|
377
381
|
...fallbackErrorDetails(error),
|
package/lib/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const CLIENT_VERSION = "0.3.
|
|
1
|
+
export const CLIENT_VERSION = "0.3.15";
|
|
2
2
|
export const CLIENT_PROTOCOL = "creation-client/v1";
|
package/package.json
CHANGED
|
@@ -10,15 +10,15 @@ description: 安装、连接或升级 PromptFrame Creation,复用平台创作
|
|
|
10
10
|
先确认使用 Codex、Claude Code 或 Antigravity。各宿主可共用同一 profile 凭据,插件登记分别核实。使用 Studio 对当前环境提供的固定版本。Claude 桌面版远程连接 WSL 时,在同一 WSL 安装;没有终端命令时可通过 `--claude-bin <实际可执行文件>` 指定桌面版提供的入口。
|
|
11
11
|
|
|
12
12
|
<!-- creation-install-command -->
|
|
13
|
-
在用户本机终端运行 `npx --yes @promptframe/creation@0.3.
|
|
13
|
+
在用户本机终端运行 `npx --yes @promptframe/creation@0.3.15 connect --endpoint <Studio提供的API地址>`。需要隔离另一个环境或账号时显式加 `--profile <用户选择的名称>`;正在运行的桥不会切换。此命令管理用户级版本和 Codex 插件,不向当前项目安装依赖。优先使用 Studio 当前提供的固定推荐版本;每次重新进入此入口比较已安装版本,不后台追踪 latest,也不把旧聊天里的命令当最新版本。已安装更新版不默认降级。
|
|
14
14
|
<!-- /creation-install-command -->
|
|
15
15
|
|
|
16
16
|
<!-- creation-install-command -->
|
|
17
|
-
Claude Code 使用 `npx --yes @promptframe/creation@0.3.
|
|
17
|
+
Claude Code 使用 `npx --yes @promptframe/creation@0.3.15 connect --host claude-code --endpoint <Studio提供的API地址>`。桌面版远程连接 WSL 时,在该 WSL 执行;保留相同 profile 和有效凭据。
|
|
18
18
|
<!-- /creation-install-command -->
|
|
19
19
|
|
|
20
20
|
<!-- creation-install-command -->
|
|
21
|
-
Antigravity 使用 `npx --yes @promptframe/creation@0.3.
|
|
21
|
+
Antigravity 使用 `npx --yes @promptframe/creation@0.3.15 connect --host antigravity --endpoint <Studio提供的API地址>`。在同一主机核对插件已启用,再打开新对话。
|
|
22
22
|
<!-- /creation-install-command -->
|
|
23
23
|
|
|
24
24
|
命令会复用并验证有效凭据。首次授权或明确更换已失效凭据时,由用户在 Studio 登录并在终端的不回显输入框提供 Token;不要要求用户把 Token 粘进聊天,也不要把它写进命令参数、URL或日志。网络失败不等于授权失效,不自动轮换或覆盖凭据。
|