playcanvas-agent-bridge-cli 0.6.1 → 0.7.0
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/README.md +148 -31
- package/README.zh-CN.md +137 -33
- package/dist/cli.js +514 -95
- package/dist/config.js +23 -1
- package/dist/daemon/server.js +336 -28
- package/dist/daemon/target-registry.js +3 -0
- package/dist/plugins/host.js +260 -0
- package/dist/plugins/store.js +567 -0
- package/dist/processing/manager.js +265 -0
- package/dist/processing/tools.js +97 -0
- package/dist/snippets.js +27 -0
- package/dist/updates.js +475 -0
- package/dist/workspace/json-sync.js +821 -0
- package/dist/workspace/manager.js +1973 -326
- package/extension/icons/icon-128.png +0 -0
- package/extension/icons/icon-16.png +0 -0
- package/extension/icons/icon-256.png +0 -0
- package/extension/icons/icon-32.png +0 -0
- package/extension/icons/icon-48.png +0 -0
- package/extension/isolated.js +59 -2
- package/extension/main.js +770 -275
- package/extension/manifest.json +60 -10
- package/extension/popup.html +115 -3
- package/extension/popup.js +398 -14
- package/extension/service-worker.js +221 -4
- package/package.json +18 -18
- package/plugins/index.json +14 -0
- package/plugins/tinyapp-builder/node/builder.js +589 -0
- package/plugins/tinyapp-builder/node/index.js +30 -0
- package/plugins/tinyapp-builder/package.json +13 -0
- package/plugins/tinyapp-builder/page/editor.js +249 -0
- package/plugins/tinyapp-builder/pcbridge-plugin.json +28 -0
- package/skills/claude/pcbridge-plugin-authoring/SKILL.md +220 -0
- package/skills/claude/playcanvas-agent-bridge-cli/SKILL.md +99 -43
- package/skills/codex/pcbridge-plugin-authoring/SKILL.md +220 -0
- package/skills/codex/pcbridge-plugin-authoring/agents/openai.yaml +4 -0
- package/skills/codex/playcanvas-agent-bridge-cli/SKILL.md +89 -62
- package/skills/cursor/pcbridge-plugin-authoring.mdc +221 -0
- package/skills/cursor/playcanvas-agent-bridge-cli.mdc +69 -33
- package/skills/windsurf/pcbridge-plugin-authoring.md +215 -0
- package/skills/windsurf/playcanvas-agent-bridge-cli.md +68 -33
- package/dist/builder/manager.js +0 -564
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/extension/isolated.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
|
+
if (window.__pcbridgeIsolatedWorld) return;
|
|
5
|
+
window.__pcbridgeIsolatedWorld = true;
|
|
6
|
+
|
|
4
7
|
const CHANNEL = "playcanvas-agent-bridge";
|
|
5
8
|
const DEFAULT_CONFIG = {
|
|
6
9
|
host: "127.0.0.1",
|
|
@@ -142,9 +145,10 @@
|
|
|
142
145
|
|
|
143
146
|
async function callDaemon(path, method, body) {
|
|
144
147
|
const allowed =
|
|
145
|
-
(path
|
|
148
|
+
(/^\/plugins\/[a-z0-9-]+\/actions\/[\w.-]+$/.test(path) && method === "POST") ||
|
|
146
149
|
(path === "/workspace/sync" && method === "POST") ||
|
|
147
|
-
(
|
|
150
|
+
(path === "/workspace/settings" && (method === "GET" || method === "POST")) ||
|
|
151
|
+
(/^\/processing\/(capabilities|begin|chunk|run|status|read|cancel|finish)$/.test(path) && method === "POST");
|
|
148
152
|
if (!allowed) throw new Error("Unsupported pcbridge browser request.");
|
|
149
153
|
const payload = body && typeof body === "object" ? { ...body } : {};
|
|
150
154
|
if (method === "POST" && !payload.target && Number.isInteger(tabInfo.tabId)) {
|
|
@@ -203,6 +207,22 @@
|
|
|
203
207
|
return;
|
|
204
208
|
}
|
|
205
209
|
|
|
210
|
+
if (message.type === "workspace-delta" && message.delta) {
|
|
211
|
+
if (!stopped && ws && ws.readyState === WebSocket.OPEN) {
|
|
212
|
+
try {
|
|
213
|
+
ws.send(JSON.stringify({
|
|
214
|
+
type: "workspace:delta",
|
|
215
|
+
clientId,
|
|
216
|
+
tabId: tabInfo.tabId,
|
|
217
|
+
delta: message.delta
|
|
218
|
+
}));
|
|
219
|
+
} catch {
|
|
220
|
+
// Reconnect loop handles broken sockets.
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
206
226
|
if (message.type === "ready") {
|
|
207
227
|
sendTargetUpdate().catch((error) => {
|
|
208
228
|
if (isExtensionContextInvalidated(error)) stopBridge();
|
|
@@ -267,7 +287,10 @@
|
|
|
267
287
|
async function sendTargetUpdate(force = false) {
|
|
268
288
|
if (stopped || !ws || ws.readyState !== WebSocket.OPEN) return;
|
|
269
289
|
try {
|
|
290
|
+
const site = await requestRuntime({ type: "pcbridge:siteStatus" });
|
|
291
|
+
if (!site || !site.enabled) { stopBridge(); return; }
|
|
270
292
|
const target = await describeTarget();
|
|
293
|
+
if (!["editor", "launch"].includes(target.kind)) { stopBridge(); return; }
|
|
271
294
|
const signature = JSON.stringify(target);
|
|
272
295
|
if (!force && signature === lastTargetSignature) return;
|
|
273
296
|
if (target.projectId) {
|
|
@@ -320,6 +343,14 @@
|
|
|
320
343
|
|
|
321
344
|
async function connect() {
|
|
322
345
|
if (stopped) return;
|
|
346
|
+
const site = await requestRuntime({ type: "pcbridge:siteStatus" });
|
|
347
|
+
if (!site || !site.enabled) { stopBridge(); return; }
|
|
348
|
+
const target = await describeTarget();
|
|
349
|
+
if (!["editor", "launch"].includes(target.kind) ||
|
|
350
|
+
(target.kind === "editor" ? !target.hasEditor : !target.hasRuntimeApp)) {
|
|
351
|
+
scheduleReconnect();
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
323
354
|
if (connecting) return;
|
|
324
355
|
if (ws && (ws.readyState === WebSocket.OPEN || ws.readyState === WebSocket.CONNECTING)) {
|
|
325
356
|
return;
|
|
@@ -355,6 +386,18 @@
|
|
|
355
386
|
socket.addEventListener("open", () => {
|
|
356
387
|
reconnectAttempt = 0;
|
|
357
388
|
setConnectionState("connected");
|
|
389
|
+
requestRuntime({ type: "pcbridge:getWorkspaceSettings" })
|
|
390
|
+
.then(async (settings) => {
|
|
391
|
+
if (settings && settings.pendingDaemonSync && Number.isFinite(Number(settings.eagerMaxMb))) {
|
|
392
|
+
await callDaemon("/workspace/settings", "POST", { eagerMaxMb: Number(settings.eagerMaxMb) });
|
|
393
|
+
await requestRuntime({
|
|
394
|
+
type: "pcbridge:setWorkspaceSettings",
|
|
395
|
+
eagerMaxMb: Number(settings.eagerMaxMb),
|
|
396
|
+
pendingDaemonSync: false
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
})
|
|
400
|
+
.catch(() => undefined);
|
|
358
401
|
sendTargetUpdate(true).catch((error) => {
|
|
359
402
|
if (isExtensionContextInvalidated(error)) stopBridge();
|
|
360
403
|
});
|
|
@@ -378,6 +421,16 @@
|
|
|
378
421
|
throw new Error((data && data.error) || "Could not focus the PlayCanvas tab.");
|
|
379
422
|
}
|
|
380
423
|
response = { data, meta: {} };
|
|
424
|
+
} else if (message.method === "bridge:reloadExtension") {
|
|
425
|
+
const reloadTabs = !message.params || message.params.reloadTabs !== false;
|
|
426
|
+
const data = await requestRuntime({
|
|
427
|
+
type: "pcbridge:reloadExtension",
|
|
428
|
+
reloadTabs
|
|
429
|
+
});
|
|
430
|
+
if (!data || !data.ok) {
|
|
431
|
+
throw new Error((data && data.error) || "Could not reload the Chrome extension.");
|
|
432
|
+
}
|
|
433
|
+
response = { data, meta: {} };
|
|
381
434
|
} else {
|
|
382
435
|
response = await callMain(message.method, message.params || {}, message.timeoutMs);
|
|
383
436
|
}
|
|
@@ -449,6 +502,10 @@
|
|
|
449
502
|
}, 2000);
|
|
450
503
|
}
|
|
451
504
|
|
|
505
|
+
chrome.runtime.onMessage?.addListener((message) => {
|
|
506
|
+
if (message?.type === "pcbridge:siteDisabled") stopBridge();
|
|
507
|
+
});
|
|
508
|
+
|
|
452
509
|
start().catch((error) => {
|
|
453
510
|
if (isExtensionContextInvalidated(error)) stopBridge();
|
|
454
511
|
});
|