@promptframe/creation 0.3.11 → 0.3.12
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 +5 -1
- package/dist/cli.mjs +220 -160
- package/docs/install-guidance.json +1 -1
- package/docs/installing.md +3 -3
- package/lib/account-bridge.mjs +1 -1
- package/lib/cli.mjs +2 -2
- package/lib/connection.mjs +14 -3
- package/lib/local-accounts.mjs +29 -1
- package/lib/version.mjs +1 -1
- package/package.json +1 -1
- package/skills/creation-setup/SKILL.md +2 -2
package/dist/cli.mjs
CHANGED
|
@@ -3259,8 +3259,8 @@ var require_utils = __commonJS({
|
|
|
3259
3259
|
}
|
|
3260
3260
|
return ind;
|
|
3261
3261
|
}
|
|
3262
|
-
function removeDotSegments(
|
|
3263
|
-
let input =
|
|
3262
|
+
function removeDotSegments(path21) {
|
|
3263
|
+
let input = path21;
|
|
3264
3264
|
const output = [];
|
|
3265
3265
|
let nextSlash = -1;
|
|
3266
3266
|
let len = 0;
|
|
@@ -3669,8 +3669,8 @@ var require_schemes = __commonJS({
|
|
|
3669
3669
|
}
|
|
3670
3670
|
if (wsComponent.resourceName) {
|
|
3671
3671
|
const queryIndex = wsComponent.resourceName.indexOf("?");
|
|
3672
|
-
const
|
|
3673
|
-
wsComponent.path =
|
|
3672
|
+
const path21 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
|
|
3673
|
+
wsComponent.path = path21 && path21 !== "/" ? path21 : void 0;
|
|
3674
3674
|
wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
|
|
3675
3675
|
wsComponent.resourceName = void 0;
|
|
3676
3676
|
}
|
|
@@ -8429,7 +8429,7 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
|
|
|
8429
8429
|
}
|
|
8430
8430
|
|
|
8431
8431
|
// lib/version.mjs
|
|
8432
|
-
var CLIENT_VERSION = "0.3.
|
|
8432
|
+
var CLIENT_VERSION = "0.3.12";
|
|
8433
8433
|
var CLIENT_PROTOCOL = "creation-client/v1";
|
|
8434
8434
|
|
|
8435
8435
|
// lib/cli.mjs
|
|
@@ -8673,10 +8673,10 @@ function mergeDefs(...defs) {
|
|
|
8673
8673
|
function cloneDef(schema) {
|
|
8674
8674
|
return mergeDefs(schema._zod.def);
|
|
8675
8675
|
}
|
|
8676
|
-
function getElementAtPath(obj,
|
|
8677
|
-
if (!
|
|
8676
|
+
function getElementAtPath(obj, path21) {
|
|
8677
|
+
if (!path21)
|
|
8678
8678
|
return obj;
|
|
8679
|
-
return
|
|
8679
|
+
return path21.reduce((acc, key) => acc?.[key], obj);
|
|
8680
8680
|
}
|
|
8681
8681
|
function promiseAllObject(promisesObj) {
|
|
8682
8682
|
const keys = Object.keys(promisesObj);
|
|
@@ -9016,11 +9016,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
9016
9016
|
}
|
|
9017
9017
|
return false;
|
|
9018
9018
|
}
|
|
9019
|
-
function prefixIssues(
|
|
9019
|
+
function prefixIssues(path21, issues) {
|
|
9020
9020
|
return issues.map((iss) => {
|
|
9021
9021
|
var _a3;
|
|
9022
9022
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
9023
|
-
iss.path.unshift(
|
|
9023
|
+
iss.path.unshift(path21);
|
|
9024
9024
|
return iss;
|
|
9025
9025
|
});
|
|
9026
9026
|
}
|
|
@@ -9481,16 +9481,16 @@ function flattenError(error5, mapper = (issue2) => issue2.message) {
|
|
|
9481
9481
|
}
|
|
9482
9482
|
function formatError(error5, mapper = (issue2) => issue2.message) {
|
|
9483
9483
|
const fieldErrors = { _errors: [] };
|
|
9484
|
-
const processError = (error6,
|
|
9484
|
+
const processError = (error6, path21 = []) => {
|
|
9485
9485
|
for (const issue2 of error6.issues) {
|
|
9486
9486
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
9487
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
9487
|
+
issue2.errors.map((issues) => processError({ issues }, [...path21, ...issue2.path]));
|
|
9488
9488
|
} else if (issue2.code === "invalid_key") {
|
|
9489
|
-
processError({ issues: issue2.issues }, [...
|
|
9489
|
+
processError({ issues: issue2.issues }, [...path21, ...issue2.path]);
|
|
9490
9490
|
} else if (issue2.code === "invalid_element") {
|
|
9491
|
-
processError({ issues: issue2.issues }, [...
|
|
9491
|
+
processError({ issues: issue2.issues }, [...path21, ...issue2.path]);
|
|
9492
9492
|
} else {
|
|
9493
|
-
const fullpath = [...
|
|
9493
|
+
const fullpath = [...path21, ...issue2.path];
|
|
9494
9494
|
if (fullpath.length === 0) {
|
|
9495
9495
|
fieldErrors._errors.push(mapper(issue2));
|
|
9496
9496
|
} else {
|
|
@@ -20827,7 +20827,7 @@ var declaredHostContentTypes = (capabilities) => declaredHostContentCapabilities
|
|
|
20827
20827
|
|
|
20828
20828
|
// lib/local-accounts.mjs
|
|
20829
20829
|
import { constants as constants3 } from "node:fs";
|
|
20830
|
-
import { open as open4, lstat as lstat4, mkdir as mkdir3, rename as rename3, unlink as unlink3, opendir } from "node:fs/promises";
|
|
20830
|
+
import { open as open4, lstat as lstat4, mkdir as mkdir3, rename as rename3, unlink as unlink3, opendir, link } from "node:fs/promises";
|
|
20831
20831
|
import { homedir as homedir2 } from "node:os";
|
|
20832
20832
|
import path5 from "node:path";
|
|
20833
20833
|
import { createHash as createHash3, randomUUID } from "node:crypto";
|
|
@@ -21118,8 +21118,49 @@ var readLocalAuthorizations = accountIO(readAuthorizations);
|
|
|
21118
21118
|
var listLocalAccounts = accountIO(listAccounts);
|
|
21119
21119
|
var selectLocalAccount = accountIO(selectAccount);
|
|
21120
21120
|
var readSelectedLocalAccount = accountIO(readSelectedAccount);
|
|
21121
|
+
async function clientObservationInstance({ root = localAccountsRoot(), identity, configFile: configFile2 }) {
|
|
21122
|
+
identity = parseAccountIdentity(identity);
|
|
21123
|
+
if (typeof configFile2 !== "string" || !path5.isAbsolute(configFile2)) throw failure3("reference_invalid");
|
|
21124
|
+
const parent = await ownedPath(root, ["client-observations", "v1", identity.platformDigest.slice(7), identity.accountDigest.slice(7)], true);
|
|
21125
|
+
const file = path5.join(parent, localReferenceId("creation", path5.resolve(configFile2)).slice(7) + ".json");
|
|
21126
|
+
const parse4 = (value3) => {
|
|
21127
|
+
if (!plain(value3) || Object.keys(value3).sort().join(",") !== "contractVersion,instanceId" || value3.contractVersion !== "promptframe-client-instance/v1" || typeof value3.instanceId !== "string" || !/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(value3.instanceId)) throw failure3("record_invalid");
|
|
21128
|
+
return value3.instanceId;
|
|
21129
|
+
};
|
|
21130
|
+
const existing = await readJson(file);
|
|
21131
|
+
if (existing) return parse4(existing);
|
|
21132
|
+
const value2 = { contractVersion: "promptframe-client-instance/v1", instanceId: randomUUID() };
|
|
21133
|
+
const temporary = path5.join(parent, "." + randomUUID() + ".tmp");
|
|
21134
|
+
let fd;
|
|
21135
|
+
try {
|
|
21136
|
+
fd = await open4(temporary, constants3.O_WRONLY | constants3.O_CREAT | constants3.O_EXCL | constants3.O_NOFOLLOW, 384);
|
|
21137
|
+
await fd.writeFile(JSON.stringify(value2) + "\n");
|
|
21138
|
+
await fd.sync();
|
|
21139
|
+
await fd.close();
|
|
21140
|
+
fd = void 0;
|
|
21141
|
+
await link(temporary, file);
|
|
21142
|
+
const directoryHandle = await open4(parent, constants3.O_RDONLY | constants3.O_DIRECTORY | constants3.O_NOFOLLOW);
|
|
21143
|
+
try {
|
|
21144
|
+
privateOwner(await directoryHandle.stat(), true);
|
|
21145
|
+
await directoryHandle.sync();
|
|
21146
|
+
} finally {
|
|
21147
|
+
await directoryHandle.close();
|
|
21148
|
+
}
|
|
21149
|
+
return value2.instanceId;
|
|
21150
|
+
} catch (error5) {
|
|
21151
|
+
if (error5.code === "EEXIST") return parse4(await readJson(file));
|
|
21152
|
+
throw error5;
|
|
21153
|
+
} finally {
|
|
21154
|
+
await fd?.close();
|
|
21155
|
+
await unlink3(temporary).catch((error5) => {
|
|
21156
|
+
if (error5.code !== "ENOENT") throw error5;
|
|
21157
|
+
});
|
|
21158
|
+
}
|
|
21159
|
+
}
|
|
21160
|
+
var localClientObservationInstance = accountIO(clientObservationInstance);
|
|
21121
21161
|
|
|
21122
21162
|
// lib/connection.mjs
|
|
21163
|
+
import path6 from "node:path";
|
|
21123
21164
|
function connectionAccountIdentity(client, expected) {
|
|
21124
21165
|
const raw = client.getServerCapabilities()?.experimental?.["promptframe.accountIdentity"];
|
|
21125
21166
|
if (raw === void 0) {
|
|
@@ -21134,7 +21175,8 @@ function connectionAccountIdentity(client, expected) {
|
|
|
21134
21175
|
}
|
|
21135
21176
|
return actual;
|
|
21136
21177
|
}
|
|
21137
|
-
async function connectPlatform(credentials, { host = resolveHostIdentity(), contentTypes = () => ["text"], contentSource = () => "text-fallback", enforceMinimum = true, signal, expectedIdentity } = {}) {
|
|
21178
|
+
async function connectPlatform(credentials, { host = resolveHostIdentity(), contentTypes = () => ["text"], contentSource = () => "text-fallback", enforceMinimum = true, signal, expectedIdentity, clientConfigFile, observationRoot } = {}) {
|
|
21179
|
+
let observation;
|
|
21138
21180
|
const client = new Client(
|
|
21139
21181
|
{ name: "promptframe-creation-bridge", version: CLIENT_VERSION },
|
|
21140
21182
|
{ capabilities: {} }
|
|
@@ -21147,6 +21189,7 @@ async function connectPlatform(credentials, { host = resolveHostIdentity(), cont
|
|
|
21147
21189
|
const types = declaredHostContentTypes({ experimental: { "promptframe.contentTypes": contentTypes() } });
|
|
21148
21190
|
headers.set("X-PromptFrame-Content-Types", JSON.stringify(types));
|
|
21149
21191
|
headers.set("X-PromptFrame-Content-Source", contentSource());
|
|
21192
|
+
if (observation) headers.set("X-PromptFrame-Client-Observation", encodeURIComponent(JSON.stringify(observation)));
|
|
21150
21193
|
return fetch(url2, { ...init, headers, ...signal ? { signal: init?.signal ? AbortSignal.any([init.signal, signal]) : signal } : {} });
|
|
21151
21194
|
},
|
|
21152
21195
|
requestInit: {
|
|
@@ -21165,7 +21208,23 @@ async function connectPlatform(credentials, { host = resolveHostIdentity(), cont
|
|
|
21165
21208
|
);
|
|
21166
21209
|
try {
|
|
21167
21210
|
await client.connect(transport2, signal ? { signal } : void 0);
|
|
21168
|
-
connectionAccountIdentity(client, expectedIdentity);
|
|
21211
|
+
const identity = connectionAccountIdentity(client, expectedIdentity);
|
|
21212
|
+
if (identity && clientConfigFile) try {
|
|
21213
|
+
const instanceId = await localClientObservationInstance({
|
|
21214
|
+
identity,
|
|
21215
|
+
configFile: clientConfigFile,
|
|
21216
|
+
root: observationRoot ?? path6.join(path6.dirname(clientConfigFile), "client-observations")
|
|
21217
|
+
});
|
|
21218
|
+
const systemFamily = process.platform === "win32" ? "Windows" : process.platform === "darwin" ? "macOS" : process.platform === "linux" ? process.env.WSL_INTEROP || process.env.WSL_DISTRO_NAME ? "WSL" : "Linux" : "unknown";
|
|
21219
|
+
observation = {
|
|
21220
|
+
contractVersion: "promptframe-client-observation/v1",
|
|
21221
|
+
instanceId,
|
|
21222
|
+
systemFamily,
|
|
21223
|
+
application: host.kind === "claude-code" ? "Claude Code" : host.kind === "codex" ? "Codex" : "Creation",
|
|
21224
|
+
applicationVersion: CLIENT_VERSION
|
|
21225
|
+
};
|
|
21226
|
+
} catch {
|
|
21227
|
+
}
|
|
21169
21228
|
if (enforceMinimum) assertBridgeCompatible(client.getServerCapabilities(), CLIENT_VERSION);
|
|
21170
21229
|
else readPlatformBridgePolicy(client.getServerCapabilities());
|
|
21171
21230
|
return client;
|
|
@@ -21177,7 +21236,7 @@ async function connectPlatform(credentials, { host = resolveHostIdentity(), cont
|
|
|
21177
21236
|
}
|
|
21178
21237
|
|
|
21179
21238
|
// lib/account-bridge.mjs
|
|
21180
|
-
import
|
|
21239
|
+
import path10 from "node:path";
|
|
21181
21240
|
|
|
21182
21241
|
// lib/host-context.mjs
|
|
21183
21242
|
import { createHash as createHash6 } from "node:crypto";
|
|
@@ -21185,13 +21244,13 @@ import { createHash as createHash6 } from "node:crypto";
|
|
|
21185
21244
|
// lib/claude-host-session.mjs
|
|
21186
21245
|
import { constants as constants4 } from "node:fs";
|
|
21187
21246
|
import { open as open5, mkdir as mkdir4, lstat as lstat5, rename as rename4, unlink as unlink4, rmdir as rmdir2 } from "node:fs/promises";
|
|
21188
|
-
import
|
|
21247
|
+
import path8 from "node:path";
|
|
21189
21248
|
import { homedir as homedir4 } from "node:os";
|
|
21190
21249
|
import { createHash as createHash5, randomBytes as randomBytes3 } from "node:crypto";
|
|
21191
21250
|
|
|
21192
21251
|
// lib/claude-host-process.mjs
|
|
21193
21252
|
import { readFile as readFile3, readlink, stat } from "node:fs/promises";
|
|
21194
|
-
import
|
|
21253
|
+
import path7 from "node:path";
|
|
21195
21254
|
import { homedir as homedir3 } from "node:os";
|
|
21196
21255
|
import { createHash as createHash4 } from "node:crypto";
|
|
21197
21256
|
var hash2 = (value2) => createHash4("sha256").update(JSON.stringify(value2)).digest("hex");
|
|
@@ -21225,8 +21284,8 @@ async function claudeHostProcess({
|
|
|
21225
21284
|
if (visited.has(child.ppid)) return null;
|
|
21226
21285
|
visited.add(child.ppid);
|
|
21227
21286
|
const host = await readBirth(child.ppid);
|
|
21228
|
-
const roots2 = [
|
|
21229
|
-
if (roots2.some((root) =>
|
|
21287
|
+
const roots2 = [path7.join(home, ".claude", "remote", "ccd-cli"), path7.join(home, ".local", "share", "claude", "versions")];
|
|
21288
|
+
if (roots2.some((root) => path7.dirname(host.exe) === root)) {
|
|
21230
21289
|
const executable = await readExecutable(host.exe);
|
|
21231
21290
|
if (host.uid !== uid || ![uid, 0].includes(executable.uid) || !executable.isFile() || executable.mode & 18 || host.inode !== executable.ino || host.device !== executable.dev) return null;
|
|
21232
21291
|
if (purpose === "hook") {
|
|
@@ -21291,9 +21350,9 @@ async function privateRead(file) {
|
|
|
21291
21350
|
}
|
|
21292
21351
|
async function createClaudeHostSession({ configFile: configFile2, env = process.env, root, association, hookProcess = false } = {}) {
|
|
21293
21352
|
const owner = association === void 0 ? await claudeHostProcess({ env, purpose: hookProcess ? "hook" : "bridge" }) : association;
|
|
21294
|
-
const base = root ??
|
|
21295
|
-
const namespace = owner ?
|
|
21296
|
-
const stateFile = namespace &&
|
|
21353
|
+
const base = root ?? path8.join(env.CLAUDE_CONFIG_DIR ?? path8.join(homedir4(), ".claude"), "promptframe-host-sessions");
|
|
21354
|
+
const namespace = owner ? path8.join(base, digest2([owner.digest, path8.resolve(configFile2)])) : null;
|
|
21355
|
+
const stateFile = namespace && path8.join(namespace, "state.json");
|
|
21297
21356
|
async function state() {
|
|
21298
21357
|
if (!owner || !await owner.isCurrent()) return null;
|
|
21299
21358
|
const value2 = await privateRead(stateFile);
|
|
@@ -21305,7 +21364,7 @@ async function createClaudeHostSession({ configFile: configFile2, env = process.
|
|
|
21305
21364
|
if (!owner || !await owner.isCurrent()) throw error2("host_identity_unavailable");
|
|
21306
21365
|
await privateDirectory(base);
|
|
21307
21366
|
await privateDirectory(namespace);
|
|
21308
|
-
const lock =
|
|
21367
|
+
const lock = path8.join(namespace, "write.lock");
|
|
21309
21368
|
let acquired = false;
|
|
21310
21369
|
for (let count = 0; count < 100; count++) try {
|
|
21311
21370
|
await mkdir4(lock, { mode: 448 });
|
|
@@ -21327,7 +21386,7 @@ async function createClaudeHostSession({ configFile: configFile2, env = process.
|
|
|
21327
21386
|
}
|
|
21328
21387
|
const body = JSON.stringify(next);
|
|
21329
21388
|
if (Buffer.byteLength(body) > 196608) throw error2("host_identity_unavailable");
|
|
21330
|
-
temporary =
|
|
21389
|
+
temporary = path8.join(namespace, "state-" + randomBytes3(16).toString("hex") + ".partial");
|
|
21331
21390
|
const file = await open5(temporary, constants4.O_WRONLY | constants4.O_CREAT | constants4.O_EXCL | constants4.O_NOFOLLOW, 384);
|
|
21332
21391
|
try {
|
|
21333
21392
|
await file.writeFile(body);
|
|
@@ -21451,12 +21510,12 @@ async function runClaudeHostHook({ configFile: configFile2, input = process.stdi
|
|
|
21451
21510
|
// lib/development-pairing.mjs
|
|
21452
21511
|
import { open as open6, stat as stat2 } from "node:fs/promises";
|
|
21453
21512
|
import { constants as constants5 } from "node:fs";
|
|
21454
|
-
import
|
|
21513
|
+
import path9 from "node:path";
|
|
21455
21514
|
async function readDevelopmentPairingFile(filePath, { signal } = {}) {
|
|
21456
21515
|
const fail8 = () => {
|
|
21457
21516
|
throw new CreationClientError("creation.development_pairing.private_file_unavailable");
|
|
21458
21517
|
};
|
|
21459
|
-
if (typeof filePath !== "string" || filePath.length > 4096 || !
|
|
21518
|
+
if (typeof filePath !== "string" || filePath.length > 4096 || !path9.isAbsolute(filePath)) fail8();
|
|
21460
21519
|
let file;
|
|
21461
21520
|
try {
|
|
21462
21521
|
signal?.throwIfAborted();
|
|
@@ -21808,7 +21867,7 @@ function createAccountAwareBridge(defaultClient, {
|
|
|
21808
21867
|
return sessionId ? { kind: binding.host.kind, sessionId } : void 0;
|
|
21809
21868
|
}
|
|
21810
21869
|
async function context(identity, agent, referenceId) {
|
|
21811
|
-
if (sameIdentity(identity, primaryIdentity) && (!referenceId || referenceId === localReferenceId("creation",
|
|
21870
|
+
if (sameIdentity(identity, primaryIdentity) && (!referenceId || referenceId === localReferenceId("creation", path10.resolve(configFile2)))) return primary;
|
|
21812
21871
|
const refs = await readLocalAuthorizations({ root, identity, client: "creation" });
|
|
21813
21872
|
if (!refs.length) throw error3("creation_authorization_missing");
|
|
21814
21873
|
let ref = referenceId ? refs.find((value2) => value2.referenceId === referenceId) : refs.length === 1 ? refs[0] : void 0;
|
|
@@ -21819,7 +21878,7 @@ function createAccountAwareBridge(defaultClient, {
|
|
|
21819
21878
|
const pending = (async () => {
|
|
21820
21879
|
const saved = await readCredentials(ref.configFile);
|
|
21821
21880
|
if (!saved || localCredentialDigest(saved.token) !== ref.credentialDigest || normalizeEndpoint(saved.endpoint) !== normalizeEndpoint(ref.endpoint)) throw error3("reference_changed");
|
|
21822
|
-
const client = await connect(saved, { ...connectionOptions, host, expectedIdentity: identity });
|
|
21881
|
+
const client = await connect(saved, { ...connectionOptions, host, expectedIdentity: identity, clientConfigFile: ref.configFile });
|
|
21823
21882
|
try {
|
|
21824
21883
|
connectionAccountIdentity(client, identity);
|
|
21825
21884
|
return { client, bridge: makeBridge(client, saved, createLocalUploads?.({ identity, agent, configFile: ref.configFile })), identity, owned: true };
|
|
@@ -24887,12 +24946,12 @@ var To = (s3) => {
|
|
|
24887
24946
|
import { lstat as lstat7, mkdir as mkdir5, open as open7, readFile as readFile5, readdir as readdir3, rename as rename5, rm, statfs } from "node:fs/promises";
|
|
24888
24947
|
import { execFile } from "node:child_process";
|
|
24889
24948
|
import { promisify } from "node:util";
|
|
24890
|
-
import
|
|
24949
|
+
import path12 from "node:path";
|
|
24891
24950
|
|
|
24892
24951
|
// lib/runtime-package.mjs
|
|
24893
24952
|
import { lstat as lstat6, readdir as readdir2, readFile as readFile4 } from "node:fs/promises";
|
|
24894
24953
|
import { createHash as createHash7 } from "node:crypto";
|
|
24895
|
-
import
|
|
24954
|
+
import path11 from "node:path";
|
|
24896
24955
|
var RUNTIME_PACKAGE_ENTRIES = Object.freeze(["package.json", "README.md", "LICENSE", "bin", "dist", "lib", "skills", "docs", ".codex-plugin", ".mcp.json"]);
|
|
24897
24956
|
var OPTIONAL_HOST_ENTRIES = Object.freeze([".claude-plugin", ".claude-mcp.json"]);
|
|
24898
24957
|
var hash3 = (b2) => createHash7("sha256").update(b2).digest("hex");
|
|
@@ -24904,7 +24963,7 @@ async function inspectRuntimePackage(root, { entries: entries2 } = {}) {
|
|
|
24904
24963
|
entries2 = [...RUNTIME_PACKAGE_ENTRIES];
|
|
24905
24964
|
for (const name of OPTIONAL_HOST_ENTRIES) {
|
|
24906
24965
|
try {
|
|
24907
|
-
await lstat6(
|
|
24966
|
+
await lstat6(path11.join(root, name));
|
|
24908
24967
|
entries2.push(name);
|
|
24909
24968
|
} catch (e) {
|
|
24910
24969
|
if (e.code !== "ENOENT") throw e;
|
|
@@ -24916,19 +24975,19 @@ async function inspectRuntimePackage(root, { entries: entries2 } = {}) {
|
|
|
24916
24975
|
async function walk(relative) {
|
|
24917
24976
|
let s3;
|
|
24918
24977
|
try {
|
|
24919
|
-
s3 = await lstat6(
|
|
24978
|
+
s3 = await lstat6(path11.join(root, relative));
|
|
24920
24979
|
} catch (error5) {
|
|
24921
24980
|
if (error5.code !== "ENOENT") throw error5;
|
|
24922
24981
|
}
|
|
24923
24982
|
if (!s3 || s3.isSymbolicLink()) invalid("package_file_invalid");
|
|
24924
24983
|
if (s3.isDirectory()) {
|
|
24925
|
-
for (const name of (await readdir2(
|
|
24984
|
+
for (const name of (await readdir2(path11.join(root, relative))).sort()) {
|
|
24926
24985
|
if (name === "node_modules" || name === "credentials.json" || name.startsWith(".env")) invalid("package_file_invalid");
|
|
24927
|
-
await walk(
|
|
24986
|
+
await walk(path11.join(relative, name));
|
|
24928
24987
|
}
|
|
24929
24988
|
} else if (s3.isFile()) {
|
|
24930
24989
|
if (s3.size > 32 * 1024 * 1024) invalid("package_too_large");
|
|
24931
|
-
const body = await readFile4(
|
|
24990
|
+
const body = await readFile4(path11.join(root, relative));
|
|
24932
24991
|
bytes2 += body.length;
|
|
24933
24992
|
if (files.length >= 1024 || bytes2 > 32 * 1024 * 1024) invalid("package_too_large");
|
|
24934
24993
|
files.push({ path: relative, bytes: body.length, sha256: hash3(body), body });
|
|
@@ -24945,7 +25004,7 @@ async function inspectRuntimePackage(root, { entries: entries2 } = {}) {
|
|
|
24945
25004
|
files,
|
|
24946
25005
|
version: pkg.version,
|
|
24947
25006
|
hosts: claude ? ["codex", "claude-code"] : ["codex"],
|
|
24948
|
-
payloadDigest: hash3(JSON.stringify(files.map(({ path:
|
|
25007
|
+
payloadDigest: hash3(JSON.stringify(files.map(({ path: path21, bytes: bytes3, sha256 }) => ({ path: path21, bytes: bytes3, sha256 }))))
|
|
24949
25008
|
};
|
|
24950
25009
|
}
|
|
24951
25010
|
|
|
@@ -24980,7 +25039,7 @@ var snapshot = (payload) => ({
|
|
|
24980
25039
|
version: payload.version,
|
|
24981
25040
|
hosts: payload.hosts,
|
|
24982
25041
|
payloadDigest: payload.payloadDigest,
|
|
24983
|
-
files: payload.files.map(({ path:
|
|
25042
|
+
files: payload.files.map(({ path: path21, bytes: bytes2, sha256 }) => ({ path: path21, bytes: bytes2, sha256 }))
|
|
24984
25043
|
});
|
|
24985
25044
|
async function info(file) {
|
|
24986
25045
|
try {
|
|
@@ -25100,7 +25159,7 @@ async function readRuntimeArchive(archive, metadata) {
|
|
|
25100
25159
|
return files;
|
|
25101
25160
|
}
|
|
25102
25161
|
async function cacheLock(root, signal) {
|
|
25103
|
-
const name =
|
|
25162
|
+
const name = path12.join(root, "prepare.lock"), end = Date.now() + 5e3;
|
|
25104
25163
|
let fd;
|
|
25105
25164
|
while (!fd) {
|
|
25106
25165
|
signal?.throwIfAborted();
|
|
@@ -25133,7 +25192,7 @@ async function cacheLock(root, signal) {
|
|
|
25133
25192
|
async function verifyCached(target, metadata, hostKind) {
|
|
25134
25193
|
if (!await info(target)) return null;
|
|
25135
25194
|
await privateDirectory2(target);
|
|
25136
|
-
const manifest = await privateJSON(
|
|
25195
|
+
const manifest = await privateJSON(path12.join(target, "runtime.json"));
|
|
25137
25196
|
if (!manifest || manifest.contractVersion !== "creation-verified-runtime/v1" || manifest.version !== metadata.version || manifest.integrity !== metadata.integrity)
|
|
25138
25197
|
throw error4("runtime_cache_invalid");
|
|
25139
25198
|
const names = (await readdir3(target)).filter((name) => name !== "runtime.json").sort();
|
|
@@ -25144,21 +25203,21 @@ async function verifyCached(target, metadata, hostKind) {
|
|
|
25144
25203
|
return { version: payload.version, root: target, integrity: metadata.integrity, reused: true };
|
|
25145
25204
|
}
|
|
25146
25205
|
async function checkedVersionIndex(cacheRoot, metadata) {
|
|
25147
|
-
const old = await privateJSON(
|
|
25206
|
+
const old = await privateJSON(path12.join(cacheRoot, "version-" + metadata.version + ".json"));
|
|
25148
25207
|
if (old && JSON.stringify(old) !== JSON.stringify(metadata)) throw error4("runtime_registry_identity_conflict");
|
|
25149
25208
|
return old;
|
|
25150
25209
|
}
|
|
25151
25210
|
async function prepareVerifiedRuntime(metadata, { cacheRoot, fetchImpl = fetch, signal, checkRuntime, hostKind = "codex" } = {}) {
|
|
25152
25211
|
if (!["codex", "claude-code"].includes(hostKind)) throw error4("runtime_host_unsupported");
|
|
25153
|
-
if (!
|
|
25212
|
+
if (!path12.isAbsolute(cacheRoot ?? "")) throw error4("runtime_cache_owner_invalid");
|
|
25154
25213
|
metadata = checkedRuntimeMetadata({ name: PACKAGE, version: metadata.version, dist: metadata }, metadata.version);
|
|
25155
25214
|
await privateDirectory2(cacheRoot);
|
|
25156
25215
|
await checkedVersionIndex(cacheRoot, metadata);
|
|
25157
|
-
const target =
|
|
25216
|
+
const target = path12.join(cacheRoot, metadata.version + "-" + hash4(metadata.integrity)), existing = await verifyCached(target, metadata, hostKind);
|
|
25158
25217
|
if (existing) return existing;
|
|
25159
25218
|
const archive = await boundedGet(metadata.tarball, { fetchImpl, signal, maxBytes: MAX_ARCHIVE, timeoutMs: 15e3 });
|
|
25160
25219
|
const files = await readRuntimeArchive(archive, metadata), release = await cacheLock(cacheRoot, signal);
|
|
25161
|
-
const temporary =
|
|
25220
|
+
const temporary = path12.join(cacheRoot, ".partial-" + randomBytes4(12).toString("hex"));
|
|
25162
25221
|
try {
|
|
25163
25222
|
const index = await checkedVersionIndex(cacheRoot, metadata);
|
|
25164
25223
|
const found = await verifyCached(target, metadata, hostKind);
|
|
@@ -25168,8 +25227,8 @@ async function prepareVerifiedRuntime(metadata, { cacheRoot, fetchImpl = fetch,
|
|
|
25168
25227
|
await mkdir5(temporary, { mode: 448 });
|
|
25169
25228
|
for (const file of files) {
|
|
25170
25229
|
signal?.throwIfAborted();
|
|
25171
|
-
const dest =
|
|
25172
|
-
await mkdir5(
|
|
25230
|
+
const dest = path12.join(temporary, ...file.path.split("/"));
|
|
25231
|
+
await mkdir5(path12.dirname(dest), { recursive: true, mode: 448 });
|
|
25173
25232
|
const fd = await open7(dest, "wx", 384);
|
|
25174
25233
|
try {
|
|
25175
25234
|
await fd.writeFile(file.body);
|
|
@@ -25189,16 +25248,16 @@ async function prepareVerifiedRuntime(metadata, { cacheRoot, fetchImpl = fetch,
|
|
|
25189
25248
|
else {
|
|
25190
25249
|
const result = await execute(
|
|
25191
25250
|
process.execPath,
|
|
25192
|
-
[
|
|
25251
|
+
[path12.join(temporary, "bin/promptframe-creation.mjs"), "--version"],
|
|
25193
25252
|
{ timeout: 5e3, maxBuffer: 65536, windowsHide: true, signal, env: {
|
|
25194
25253
|
...process.env,
|
|
25195
|
-
PROMPTFRAME_CREATION_CONFIG:
|
|
25254
|
+
PROMPTFRAME_CREATION_CONFIG: path12.join(temporary, "no-credentials.json")
|
|
25196
25255
|
} }
|
|
25197
25256
|
);
|
|
25198
25257
|
if (result.stdout.trim() !== metadata.version || result.stderr.trim()) throw error4("runtime_package_version_invalid");
|
|
25199
25258
|
}
|
|
25200
25259
|
signal?.throwIfAborted();
|
|
25201
|
-
await exclusiveJSON(
|
|
25260
|
+
await exclusiveJSON(path12.join(temporary, "runtime.json"), {
|
|
25202
25261
|
contractVersion: "creation-verified-runtime/v1",
|
|
25203
25262
|
version: metadata.version,
|
|
25204
25263
|
integrity: metadata.integrity,
|
|
@@ -25206,7 +25265,7 @@ async function prepareVerifiedRuntime(metadata, { cacheRoot, fetchImpl = fetch,
|
|
|
25206
25265
|
});
|
|
25207
25266
|
await syncDirectory2(temporary);
|
|
25208
25267
|
if (!index) {
|
|
25209
|
-
await exclusiveJSON(
|
|
25268
|
+
await exclusiveJSON(path12.join(cacheRoot, "version-" + metadata.version + ".json"), metadata);
|
|
25210
25269
|
await syncDirectory2(cacheRoot);
|
|
25211
25270
|
}
|
|
25212
25271
|
await rename5(temporary, target);
|
|
@@ -25248,7 +25307,7 @@ async function selectBridgeRuntime({ policy, currentVersion, lockedVersion, reso
|
|
|
25248
25307
|
const raw = await boundedGet(REGISTRY + "/@promptframe%2fcreation/" + target, { fetchImpl, signal, maxBytes: 256 * 1024, timeoutMs: 5e3 });
|
|
25249
25308
|
metadata = checkedRuntimeMetadata(JSON.parse(raw), target);
|
|
25250
25309
|
} catch (e) {
|
|
25251
|
-
const prior = await privateJSON(
|
|
25310
|
+
const prior = await privateJSON(path12.join(cacheRoot, "version-" + target + ".json"));
|
|
25252
25311
|
if (!prior) throw e;
|
|
25253
25312
|
metadata = checkedRuntimeMetadata({ name: PACKAGE, version: target, dist: prior }, target);
|
|
25254
25313
|
metadataSource = "previously-verified-cache";
|
|
@@ -25274,16 +25333,16 @@ async function selectBridgeRuntime({ policy, currentVersion, lockedVersion, reso
|
|
|
25274
25333
|
|
|
25275
25334
|
// lib/runtime-launch.mjs
|
|
25276
25335
|
import { spawn } from "node:child_process";
|
|
25277
|
-
import
|
|
25336
|
+
import path13 from "node:path";
|
|
25278
25337
|
async function launchSelectedBridge(selection, { host, configFile: configFile2, spawnImpl = spawn, env = process.env } = {}) {
|
|
25279
|
-
if (!
|
|
25338
|
+
if (!path13.isAbsolute(selection.root ?? "") || !path13.isAbsolute(configFile2 ?? "") || !["codex", "claude-code"].includes(host?.kind))
|
|
25280
25339
|
throw new CreationClientError("creation.runtime_launch_invalid");
|
|
25281
25340
|
let child;
|
|
25282
25341
|
try {
|
|
25283
25342
|
child = spawnImpl(
|
|
25284
25343
|
process.execPath,
|
|
25285
25344
|
[
|
|
25286
|
-
|
|
25345
|
+
path13.join(selection.root, "bin/promptframe-creation.mjs"),
|
|
25287
25346
|
"bridge",
|
|
25288
25347
|
"--config",
|
|
25289
25348
|
configFile2,
|
|
@@ -25328,7 +25387,7 @@ import { promisify as promisify2 } from "node:util";
|
|
|
25328
25387
|
import { createHash as createHash9, randomBytes as randomBytes5 } from "node:crypto";
|
|
25329
25388
|
import { lstat as lstat8, mkdir as mkdir6, readdir as readdir4, readFile as readFile6, writeFile as writeFile2, rename as rename6, rm as rm2, open as open8 } from "node:fs/promises";
|
|
25330
25389
|
import { homedir as homedir5 } from "node:os";
|
|
25331
|
-
import
|
|
25390
|
+
import path14 from "node:path";
|
|
25332
25391
|
|
|
25333
25392
|
// node_modules/smol-toml/dist/error.js
|
|
25334
25393
|
function getLineColFromPtr(string4, ptr) {
|
|
@@ -26129,8 +26188,8 @@ function validProfile(profile) {
|
|
|
26129
26188
|
}
|
|
26130
26189
|
function profileCredentialsPath(profile = "default", env = process.env) {
|
|
26131
26190
|
validProfile(profile);
|
|
26132
|
-
return profile === "default" ? credentialsPath(env) :
|
|
26133
|
-
env.XDG_CONFIG_HOME ??
|
|
26191
|
+
return profile === "default" ? credentialsPath(env) : path14.resolve(
|
|
26192
|
+
env.XDG_CONFIG_HOME ?? path14.join(homedir5(), ".config"),
|
|
26134
26193
|
"promptframe-creation",
|
|
26135
26194
|
"profiles",
|
|
26136
26195
|
profile,
|
|
@@ -26162,20 +26221,20 @@ async function packageJSON(file) {
|
|
|
26162
26221
|
return json(file);
|
|
26163
26222
|
}
|
|
26164
26223
|
function sameTransport(actual, expected) {
|
|
26165
|
-
return actual?.type === "stdio" && actual.command === expected.command && typeof actual.cwd === "string" &&
|
|
26224
|
+
return actual?.type === "stdio" && actual.command === expected.command && typeof actual.cwd === "string" && path14.resolve(actual.cwd) === path14.resolve(expected.cwd) && JSON.stringify(actual.args) === JSON.stringify(expected.args) && JSON.stringify(actual.env_vars ?? []) === JSON.stringify(expected.env_vars ?? []) && !Object.keys(actual.env ?? {}).length;
|
|
26166
26225
|
}
|
|
26167
26226
|
async function managedTransport(installed, versions, serverName, profile, configFile2) {
|
|
26168
26227
|
if (!installed) return null;
|
|
26169
26228
|
const root = installed.source?.path;
|
|
26170
|
-
if (installed.source?.source !== "local" || typeof root !== "string" || !/^\d+\.\d+\.\d+$/.test(installed.version ?? "") || root !==
|
|
26171
|
-
const directory3 = await info2(root), definition = await info2(
|
|
26229
|
+
if (installed.source?.source !== "local" || typeof root !== "string" || !/^\d+\.\d+\.\d+$/.test(installed.version ?? "") || root !== path14.join(versions, installed.version)) fail4("existing_registration_requires_review");
|
|
26230
|
+
const directory3 = await info2(root), definition = await info2(path14.join(root, ".mcp.json"));
|
|
26172
26231
|
if (!directory3?.isDirectory() || directory3.isSymbolicLink() || !definition?.isFile() || definition.isSymbolicLink()) fail4("installed_files_invalid");
|
|
26173
|
-
const ready = await privateRead2(
|
|
26232
|
+
const ready = await privateRead2(path14.join(root, "installation.json"));
|
|
26174
26233
|
if (!ready || ready.profile !== profile || ready.configFile !== configFile2 || ready.version !== installed.version) fail4("existing_registration_requires_review");
|
|
26175
|
-
const bytes2 = await readFile6(
|
|
26234
|
+
const bytes2 = await readFile6(path14.join(root, ".mcp.json")), entry = ready.files?.find((x) => x.path === ".mcp.json");
|
|
26176
26235
|
if (!entry || entry.bytes !== bytes2.length || entry.sha256 !== hash5(bytes2)) fail4("installed_files_invalid");
|
|
26177
26236
|
const mcp = JSON.parse(bytes2).mcpServers?.[serverName];
|
|
26178
|
-
if (!mcp || typeof mcp.command !== "string" || !mcp.command || mcp.cwd !== root || JSON.stringify(mcp.args) !== JSON.stringify([
|
|
26237
|
+
if (!mcp || typeof mcp.command !== "string" || !mcp.command || mcp.cwd !== root || JSON.stringify(mcp.args) !== JSON.stringify([path14.join(root, "bin/promptframe-creation.mjs"), "bridge", "--config", configFile2])) fail4("existing_registration_requires_review");
|
|
26179
26238
|
return mcp;
|
|
26180
26239
|
}
|
|
26181
26240
|
async function officialNpmInstallation(installed, servers, env, profile, configFile2) {
|
|
@@ -26183,12 +26242,12 @@ async function officialNpmInstallation(installed, servers, env, profile, configF
|
|
|
26183
26242
|
const candidates = installed.filter((p3) => p3.enabled === true && p3.name === "promptframe-creation" && p3.pluginId === "promptframe-creation@" + p3.marketplaceName && /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,140}$/.test(p3.marketplaceName ?? "") && /^\d+\.\d+\.\d+$/.test(p3.version ?? "") && p3.source?.source === "npm" && p3.source.package === "@promptframe/creation" && p3.source.version === p3.version && ["https://registry.npmjs.org", "https://registry.npmjs.org/"].includes(p3.source.registry));
|
|
26184
26243
|
if (candidates.length > 1) fail4("existing_registration_requires_review");
|
|
26185
26244
|
if (!candidates.length) return null;
|
|
26186
|
-
const p2 = candidates[0], root =
|
|
26245
|
+
const p2 = candidates[0], root = path14.join(path14.resolve(env.CODEX_HOME ?? path14.join(homedir5(), ".codex")), "plugins/cache", p2.marketplaceName, p2.name, p2.version);
|
|
26187
26246
|
const directory3 = await info2(root);
|
|
26188
26247
|
if (!directory3?.isDirectory() || directory3.isSymbolicLink()) fail4("installed_files_invalid");
|
|
26189
|
-
const pkg = await packageJSON(
|
|
26248
|
+
const pkg = await packageJSON(path14.join(root, "package.json")), manifest = await packageJSON(path14.join(root, ".codex-plugin/plugin.json"));
|
|
26190
26249
|
if (pkg.name !== "@promptframe/creation" || pkg.version !== p2.version || manifest.name !== p2.name || manifest.version !== p2.version) fail4("installed_files_invalid");
|
|
26191
|
-
const definition = (await packageJSON(
|
|
26250
|
+
const definition = (await packageJSON(path14.join(root, ".mcp.json"))).mcpServers?.promptframe;
|
|
26192
26251
|
if (!definition || definition.command !== "node" || definition.cwd !== "." || JSON.stringify(definition.args) !== JSON.stringify(["bin/promptframe-creation.mjs", "bridge"]) || JSON.stringify(definition.env_vars) !== JSON.stringify(["PROMPTFRAME_CREATION_CONFIG", "XDG_CONFIG_HOME"])) fail4("legacy_mcp_entry_requires_review");
|
|
26193
26252
|
if (servers.length !== 1 || servers[0].enabled !== true || !sameTransport(servers[0].transport, { ...definition, cwd: root }) || JSON.stringify(servers[0].transport.env_vars) !== JSON.stringify(definition.env_vars)) fail4("legacy_mcp_entry_requires_review");
|
|
26194
26253
|
return {
|
|
@@ -26215,7 +26274,7 @@ async function atomicJSON(file, value2) {
|
|
|
26215
26274
|
await out.close();
|
|
26216
26275
|
}
|
|
26217
26276
|
await rename6(temp, file);
|
|
26218
|
-
const directory3 = await open8(
|
|
26277
|
+
const directory3 = await open8(path14.dirname(file), "r");
|
|
26219
26278
|
try {
|
|
26220
26279
|
await directory3.sync();
|
|
26221
26280
|
} finally {
|
|
@@ -26226,7 +26285,7 @@ async function atomicJSON(file, value2) {
|
|
|
26226
26285
|
}
|
|
26227
26286
|
}
|
|
26228
26287
|
async function acquire(root, signal) {
|
|
26229
|
-
const lock =
|
|
26288
|
+
const lock = path14.join(root, "install.lock");
|
|
26230
26289
|
const end = Date.now() + 3e4;
|
|
26231
26290
|
let owned = false;
|
|
26232
26291
|
while (!owned) {
|
|
@@ -26241,7 +26300,7 @@ async function acquire(root, signal) {
|
|
|
26241
26300
|
}
|
|
26242
26301
|
}
|
|
26243
26302
|
try {
|
|
26244
|
-
await writeFile2(
|
|
26303
|
+
await writeFile2(path14.join(lock, "owner.json"), JSON.stringify({ pid: process.pid, startedAt: (/* @__PURE__ */ new Date()).toISOString() }), { flag: "wx", mode: 384 });
|
|
26245
26304
|
} catch (e) {
|
|
26246
26305
|
await rm2(lock, { recursive: true, force: true });
|
|
26247
26306
|
throw e;
|
|
@@ -26282,7 +26341,7 @@ async function codexJSON(runCodex, args2) {
|
|
|
26282
26341
|
}
|
|
26283
26342
|
}
|
|
26284
26343
|
async function relatedPlugins(runCodex, pluginName, env) {
|
|
26285
|
-
const related = /* @__PURE__ */ new Set(), registered = /* @__PURE__ */ new Set(), pinnedMarketplaces = /* @__PURE__ */ new Map(), config2 =
|
|
26344
|
+
const related = /* @__PURE__ */ new Set(), registered = /* @__PURE__ */ new Set(), pinnedMarketplaces = /* @__PURE__ */ new Map(), config2 = path14.join(path14.resolve(env.CODEX_HOME ?? path14.join(homedir5(), ".codex")), "config.toml");
|
|
26286
26345
|
try {
|
|
26287
26346
|
const s3 = await info2(config2);
|
|
26288
26347
|
if (s3) {
|
|
@@ -26302,10 +26361,10 @@ async function relatedPlugins(runCodex, pluginName, env) {
|
|
|
26302
26361
|
const state = await codexJSON(runCodex, ["plugin", "marketplace", "list", "--json"]);
|
|
26303
26362
|
if (!Array.isArray(state?.marketplaces) || state.marketplaces.length > 128) fail4("local_catalog_unconfirmed");
|
|
26304
26363
|
for (const market of state.marketplaces) {
|
|
26305
|
-
if (typeof market.name !== "string" || !/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,140}$/.test(market.name) || typeof market.root !== "string" || !
|
|
26364
|
+
if (typeof market.name !== "string" || !/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,140}$/.test(market.name) || typeof market.root !== "string" || !path14.isAbsolute(market.root)) fail4("local_catalog_unconfirmed");
|
|
26306
26365
|
let catalog;
|
|
26307
26366
|
try {
|
|
26308
|
-
catalog = await packageJSON(
|
|
26367
|
+
catalog = await packageJSON(path14.join(market.root, ".agents/plugins/marketplace.json"));
|
|
26309
26368
|
} catch {
|
|
26310
26369
|
fail4("local_catalog_unconfirmed", { phase: "local_check", commandKind: "marketplace_read", localRegistrationState: "unknown", action: "restore_local_marketplace_catalog" });
|
|
26311
26370
|
}
|
|
@@ -26336,7 +26395,7 @@ async function relatedPlugins(runCodex, pluginName, env) {
|
|
|
26336
26395
|
}
|
|
26337
26396
|
async function runNode(root, version3) {
|
|
26338
26397
|
try {
|
|
26339
|
-
const result = await execute2(process.execPath, [
|
|
26398
|
+
const result = await execute2(process.execPath, [path14.join(root, "bin/promptframe-creation.mjs"), "--version"], { encoding: "utf8", timeout: 1e4, maxBuffer: 8192 });
|
|
26340
26399
|
if (result.stdout.trim() !== version3) fail4("runtime_version_mismatch");
|
|
26341
26400
|
} catch (e) {
|
|
26342
26401
|
if (e instanceof CreationClientError) throw e;
|
|
@@ -26350,7 +26409,7 @@ async function checkInstalledRuntime(root, version3, command2, { env = process.e
|
|
|
26350
26409
|
if (!major || Number(major[1]) < 20) throw Error("unsupported_node");
|
|
26351
26410
|
const result = await execute2(
|
|
26352
26411
|
command2,
|
|
26353
|
-
[
|
|
26412
|
+
[path14.join(root, "bin/promptframe-creation.mjs"), "--version"],
|
|
26354
26413
|
{ env, encoding: "utf8", timeout: 1e4, maxBuffer: 8192 }
|
|
26355
26414
|
);
|
|
26356
26415
|
if (result.stdout.trim() !== version3) throw Error("wrong_version");
|
|
@@ -26387,20 +26446,20 @@ async function installForUser({
|
|
|
26387
26446
|
const versionOutput = await runCodex(["--version"]);
|
|
26388
26447
|
const match = versionOutput.match(/codex-cli (\d+)\.(\d+)\.(\d+)/);
|
|
26389
26448
|
if (!match || Number(match[1]) === 0 && Number(match[2]) < 160) fail4("codex_0160_required");
|
|
26390
|
-
const payload = await inspectRuntimePackage(
|
|
26391
|
-
const root =
|
|
26449
|
+
const payload = await inspectRuntimePackage(path14.resolve(sourceRoot));
|
|
26450
|
+
const root = path14.resolve(env.XDG_DATA_HOME ?? path14.join(homedir5(), ".local/share"), "promptframe-creation", profile);
|
|
26392
26451
|
await privateDirectory3(root);
|
|
26393
26452
|
const release = await acquire(root, signal);
|
|
26394
|
-
const versions =
|
|
26395
|
-
const marketplaceFile =
|
|
26453
|
+
const versions = path14.join(root, "versions"), currentFile = path14.join(root, "current.json"), pendingFile = path14.join(root, "registration-pending.json");
|
|
26454
|
+
const marketplaceFile = path14.join(root, ".agents/plugins/marketplace.json");
|
|
26396
26455
|
const pluginName = "promptframe-creation" + (profile === "default" ? "" : "-" + profile), marketplace = "promptframe-creation-user" + (profile === "default" ? "" : "-" + profile);
|
|
26397
26456
|
const pluginId = pluginName + "@" + marketplace;
|
|
26398
|
-
const versionRoot =
|
|
26457
|
+
const versionRoot = path14.join(versions, payload.version), temporary = path14.join(versions, ".partial-" + randomBytes5(12).toString("hex"));
|
|
26399
26458
|
let previous, registrationStarted = false, newFiles = 0;
|
|
26400
26459
|
try {
|
|
26401
26460
|
signal?.throwIfAborted();
|
|
26402
26461
|
await privateDirectory3(versions);
|
|
26403
|
-
await privateDirectory3(
|
|
26462
|
+
await privateDirectory3(path14.dirname(marketplaceFile));
|
|
26404
26463
|
previous = await privateRead2(currentFile);
|
|
26405
26464
|
if (previous && (previous.profile !== profile || previous.pluginId !== pluginId || previous.configFile !== configFile2)) fail4("profile_binding_conflict");
|
|
26406
26465
|
const state = { installed: await relatedPlugins(runCodex, pluginName, env) };
|
|
@@ -26411,12 +26470,12 @@ async function installForUser({
|
|
|
26411
26470
|
const servers = legacy.filter((x) => x.name === serverName);
|
|
26412
26471
|
const pending = await privateRead2(pendingFile);
|
|
26413
26472
|
if (pending) {
|
|
26414
|
-
if (pending.profile !== profile || pending.pluginId !== pluginId || pending.configFile !== configFile2 || pending.versionRoot !==
|
|
26473
|
+
if (pending.profile !== profile || pending.pluginId !== pluginId || pending.configFile !== configFile2 || pending.versionRoot !== path14.join(versions, pending.version)) fail4("profile_binding_conflict");
|
|
26415
26474
|
if (installed?.version !== pending.version || installed.enabled !== true || installed.source?.path !== pending.versionRoot)
|
|
26416
26475
|
fail4("registration_unconfirmed_keep_existing", { phase: "registration_observation", localRegistrationState: "unknown", action: "inspect_same_registration_no_second_add" });
|
|
26417
26476
|
const transport2 = await managedTransport(installed, versions, serverName, profile, configFile2);
|
|
26418
26477
|
if (servers.length !== 1 || servers[0].enabled === false || !sameTransport(servers[0].transport, transport2)) fail4("registration_unconfirmed_keep_existing");
|
|
26419
|
-
const ready = await privateRead2(
|
|
26478
|
+
const ready = await privateRead2(path14.join(pending.versionRoot, "installation.json"));
|
|
26420
26479
|
if (ready?.payloadDigest !== pending.payloadDigest) fail4("installed_files_invalid");
|
|
26421
26480
|
previous = pending;
|
|
26422
26481
|
await atomicJSON(currentFile, pending);
|
|
@@ -26471,11 +26530,11 @@ async function installForUser({
|
|
|
26471
26530
|
const target = await info2(versionRoot);
|
|
26472
26531
|
if (target) {
|
|
26473
26532
|
if (!target.isDirectory() || target.isSymbolicLink()) fail4("version_content_conflict");
|
|
26474
|
-
const ready = await privateRead2(
|
|
26533
|
+
const ready = await privateRead2(path14.join(versionRoot, "installation.json"));
|
|
26475
26534
|
if (!ready || ready.payloadDigest !== payload.payloadDigest || ready.profile !== profile || ready.configFile !== configFile2) fail4("version_content_conflict");
|
|
26476
26535
|
for (const f2 of ready.files) {
|
|
26477
26536
|
if (!payload.files.some((p2) => p2.path === f2.path)) fail4("installed_files_invalid");
|
|
26478
|
-
const file =
|
|
26537
|
+
const file = path14.join(versionRoot, f2.path), s3 = await info2(file);
|
|
26479
26538
|
if (!s3?.isFile() || s3.isSymbolicLink() || s3.size !== f2.bytes || hash5(await readFile6(file)) !== f2.sha256) fail4("installed_files_invalid");
|
|
26480
26539
|
}
|
|
26481
26540
|
if (ready.files.length !== payload.files.length) fail4("installed_files_invalid");
|
|
@@ -26483,31 +26542,31 @@ async function installForUser({
|
|
|
26483
26542
|
await mkdir6(temporary, { mode: 448 });
|
|
26484
26543
|
for (const f2 of payload.files) {
|
|
26485
26544
|
signal?.throwIfAborted();
|
|
26486
|
-
await mkdir6(
|
|
26487
|
-
await writeFile2(
|
|
26545
|
+
await mkdir6(path14.dirname(path14.join(temporary, f2.path)), { recursive: true, mode: 448 });
|
|
26546
|
+
await writeFile2(path14.join(temporary, f2.path), f2.body, { flag: "wx", mode: 384 });
|
|
26488
26547
|
}
|
|
26489
|
-
const manifest = await json(
|
|
26548
|
+
const manifest = await json(path14.join(temporary, ".codex-plugin/plugin.json"));
|
|
26490
26549
|
manifest.name = pluginName;
|
|
26491
|
-
await writeFile2(
|
|
26550
|
+
await writeFile2(path14.join(temporary, ".codex-plugin/plugin.json"), JSON.stringify(manifest, null, 2) + "\n");
|
|
26492
26551
|
const mcp = { mcpServers: { ["promptframe" + (profile === "default" ? "" : "-" + profile)]: {
|
|
26493
26552
|
command: process.execPath,
|
|
26494
|
-
args: [
|
|
26553
|
+
args: [path14.join(versionRoot, "bin/promptframe-creation.mjs"), "bridge", "--config", configFile2],
|
|
26495
26554
|
cwd: versionRoot
|
|
26496
26555
|
} } };
|
|
26497
|
-
await writeFile2(
|
|
26556
|
+
await writeFile2(path14.join(temporary, ".mcp.json"), JSON.stringify(mcp, null, 2) + "\n");
|
|
26498
26557
|
await checkRuntime(temporary, payload.version);
|
|
26499
26558
|
const files = [];
|
|
26500
26559
|
for (const f2 of payload.files) {
|
|
26501
|
-
const body = await readFile6(
|
|
26560
|
+
const body = await readFile6(path14.join(temporary, f2.path));
|
|
26502
26561
|
files.push({ path: f2.path, bytes: body.length, sha256: hash5(body) });
|
|
26503
26562
|
}
|
|
26504
|
-
await atomicJSON(
|
|
26563
|
+
await atomicJSON(path14.join(temporary, "installation.json"), { version: payload.version, profile, configFile: configFile2, payloadDigest: payload.payloadDigest, files });
|
|
26505
26564
|
signal?.throwIfAborted();
|
|
26506
26565
|
await rename6(temporary, versionRoot);
|
|
26507
26566
|
newFiles = payload.files.length;
|
|
26508
26567
|
}
|
|
26509
26568
|
if (newFiles === 0) {
|
|
26510
|
-
const launch = (await json(
|
|
26569
|
+
const launch = (await json(path14.join(versionRoot, ".mcp.json"))).mcpServers?.[serverName];
|
|
26511
26570
|
await verifyInstalledRuntime(versionRoot, payload.version, launch.command, { env });
|
|
26512
26571
|
}
|
|
26513
26572
|
const complete = { version: payload.version, profile, configFile: configFile2, pluginId, versionRoot, payloadDigest: payload.payloadDigest };
|
|
@@ -26568,7 +26627,7 @@ async function installForUser({
|
|
|
26568
26627
|
import { createHash as createHash12, randomBytes as randomBytes7 } from "node:crypto";
|
|
26569
26628
|
import { mkdir as mkdir8, open as open11, readFile as readFile9, rename as rename8, rm as rm5 } from "node:fs/promises";
|
|
26570
26629
|
import { homedir as homedir10 } from "node:os";
|
|
26571
|
-
import
|
|
26630
|
+
import path19 from "node:path";
|
|
26572
26631
|
|
|
26573
26632
|
// lib/claude-hook-definition.mjs
|
|
26574
26633
|
function claudeHostHooks({ pluginName = "promptframe-creation", serverName, configFile: configFile2, nodeCommand = "node", runtimeRoot = "${CLAUDE_PLUGIN_ROOT}" } = {}) {
|
|
@@ -26594,7 +26653,7 @@ import { promisify as promisify3 } from "node:util";
|
|
|
26594
26653
|
import { access, lstat as lstat9, readdir as readdir5 } from "node:fs/promises";
|
|
26595
26654
|
import { constants as constants6 } from "node:fs";
|
|
26596
26655
|
import { homedir as homedir6 } from "node:os";
|
|
26597
|
-
import
|
|
26656
|
+
import path15 from "node:path";
|
|
26598
26657
|
var execute3 = promisify3(execFile3);
|
|
26599
26658
|
var ClaudeCommandError = class extends CreationClientError {
|
|
26600
26659
|
constructor(code, details) {
|
|
@@ -26606,12 +26665,12 @@ var claudeErrorDetails = (error5) => error5 instanceof ClaudeCommandError ? erro
|
|
|
26606
26665
|
async function resolveClaudeCommand({ env = process.env, homeDirectory = homedir6(), executable } = {}) {
|
|
26607
26666
|
const selected = executable ?? env.PROMPTFRAME_CLAUDE_BIN;
|
|
26608
26667
|
if (selected) {
|
|
26609
|
-
if (!
|
|
26668
|
+
if (!path15.isAbsolute(selected)) throw new CreationClientError("installation.claude_executable_invalid");
|
|
26610
26669
|
await access(selected, constants6.X_OK);
|
|
26611
26670
|
return selected;
|
|
26612
26671
|
}
|
|
26613
|
-
for (const directory3 of (env.PATH ?? "").split(
|
|
26614
|
-
const file =
|
|
26672
|
+
for (const directory3 of (env.PATH ?? "").split(path15.delimiter).filter(path15.isAbsolute)) {
|
|
26673
|
+
const file = path15.join(directory3, process.platform === "win32" ? "claude.exe" : "claude");
|
|
26615
26674
|
try {
|
|
26616
26675
|
await access(file, constants6.X_OK);
|
|
26617
26676
|
return file;
|
|
@@ -26619,7 +26678,7 @@ async function resolveClaudeCommand({ env = process.env, homeDirectory = homedir
|
|
|
26619
26678
|
if (!["ENOENT", "EACCES", "ENOTDIR"].includes(e.code)) throw e;
|
|
26620
26679
|
}
|
|
26621
26680
|
}
|
|
26622
|
-
const root =
|
|
26681
|
+
const root = path15.join(homeDirectory, ".claude/remote/ccd-cli");
|
|
26623
26682
|
let entries2;
|
|
26624
26683
|
try {
|
|
26625
26684
|
entries2 = await readdir5(root);
|
|
@@ -26632,7 +26691,7 @@ async function resolveClaudeCommand({ env = process.env, homeDirectory = homedir
|
|
|
26632
26691
|
for (const name of entries2) {
|
|
26633
26692
|
const match = name.match(/^(\d+)\.(\d+)\.(\d+)-[a-f0-9]{6,40}$/);
|
|
26634
26693
|
if (!match) continue;
|
|
26635
|
-
const file =
|
|
26694
|
+
const file = path15.join(root, name), s3 = await lstat9(file);
|
|
26636
26695
|
if (s3.isFile() && !s3.isSymbolicLink() && s3.uid === process.getuid?.()) {
|
|
26637
26696
|
await access(file, constants6.X_OK);
|
|
26638
26697
|
candidates.push({ file, version: match.slice(1).map(Number) });
|
|
@@ -26672,12 +26731,12 @@ function createClaudeRunner({ env = process.env, executable, signal, resolve = r
|
|
|
26672
26731
|
// lib/claude-local-state.mjs
|
|
26673
26732
|
import { readFile as readFile7, lstat as lstat10 } from "node:fs/promises";
|
|
26674
26733
|
import { homedir as homedir7 } from "node:os";
|
|
26675
|
-
import
|
|
26734
|
+
import path16 from "node:path";
|
|
26676
26735
|
function claudeConfigRoot(env = process.env) {
|
|
26677
|
-
return
|
|
26736
|
+
return path16.resolve(env.CLAUDE_CONFIG_DIR ?? path16.join(homedir7(), ".claude"));
|
|
26678
26737
|
}
|
|
26679
26738
|
async function readClaudeUserServer(serverName, env = process.env) {
|
|
26680
|
-
const file = env.CLAUDE_CONFIG_DIR ?
|
|
26739
|
+
const file = env.CLAUDE_CONFIG_DIR ? path16.join(claudeConfigRoot(env), ".claude.json") : path16.join(homedir7(), ".claude.json");
|
|
26681
26740
|
let info5;
|
|
26682
26741
|
try {
|
|
26683
26742
|
info5 = await lstat10(file);
|
|
@@ -26703,13 +26762,13 @@ async function readClaudeUserServer(serverName, env = process.env) {
|
|
|
26703
26762
|
import { createHash as createHash11, randomBytes as randomBytes6 } from "node:crypto";
|
|
26704
26763
|
import { mkdir as mkdir7, open as open10, readFile as readFile8, readdir as readdir6, rename as rename7, rm as rm4, lstat as lstat11 } from "node:fs/promises";
|
|
26705
26764
|
import { homedir as homedir9 } from "node:os";
|
|
26706
|
-
import
|
|
26765
|
+
import path18 from "node:path";
|
|
26707
26766
|
|
|
26708
26767
|
// lib/claude-hook-registration.mjs
|
|
26709
26768
|
import { createHash as createHash10 } from "node:crypto";
|
|
26710
26769
|
import { open as open9, rm as rm3 } from "node:fs/promises";
|
|
26711
26770
|
import { constants as constants7 } from "node:fs";
|
|
26712
|
-
import
|
|
26771
|
+
import path17 from "node:path";
|
|
26713
26772
|
import { homedir as homedir8 } from "node:os";
|
|
26714
26773
|
var { privateDirectory: privateDirectory4, privateRead: privateRead3, atomicJSON: atomicJSON2, acquire: acquire2 } = installationFiles;
|
|
26715
26774
|
var digest4 = (value2) => createHash10("sha256").update(JSON.stringify(value2)).digest("hex");
|
|
@@ -26734,20 +26793,20 @@ async function settings(file) {
|
|
|
26734
26793
|
}
|
|
26735
26794
|
var contains = (value2, entries2) => Object.entries(entries2).every(([event, wanted]) => Array.isArray(value2.hooks?.[event]) && wanted.every((entry) => value2.hooks[event].filter((actual) => digest4(actual) === digest4(entry)).length === 1));
|
|
26736
26795
|
async function verifyClaudeFallbackHooks(record2, env) {
|
|
26737
|
-
if (!record2?.settingsFile || record2.settingsFile !==
|
|
26796
|
+
if (!record2?.settingsFile || record2.settingsFile !== path17.join(claudeConfigRoot(env), "settings.json") || !record2.entries) fail5();
|
|
26738
26797
|
if (!contains(await settings(record2.settingsFile), record2.entries)) fail5();
|
|
26739
26798
|
return true;
|
|
26740
26799
|
}
|
|
26741
26800
|
async function registerClaudeFallbackHooks({ record: record2, root, env, nodeCommand, signal }) {
|
|
26742
|
-
const directory3 = claudeConfigRoot(env), file =
|
|
26743
|
-
const guard =
|
|
26744
|
-
env.XDG_DATA_HOME ??
|
|
26801
|
+
const directory3 = claudeConfigRoot(env), file = path17.join(directory3, "settings.json");
|
|
26802
|
+
const guard = path17.resolve(
|
|
26803
|
+
env.XDG_DATA_HOME ?? path17.join(homedir8(), ".local/share"),
|
|
26745
26804
|
"promptframe-creation",
|
|
26746
26805
|
"claude-hook-writer-" + digest4(directory3)
|
|
26747
26806
|
);
|
|
26748
26807
|
await privateDirectory4(guard);
|
|
26749
26808
|
const release = await acquire2(guard, signal);
|
|
26750
|
-
const markerFile =
|
|
26809
|
+
const markerFile = path17.join(root, "hooks-current.json"), pendingFile = path17.join(root, "hooks-pending.json");
|
|
26751
26810
|
try {
|
|
26752
26811
|
await privateDirectory4(directory3);
|
|
26753
26812
|
const entries2 = claudeHostHooks({ serverName: record2.serverName, configFile: record2.configFile, nodeCommand, runtimeRoot: record2.versionRoot });
|
|
@@ -26823,7 +26882,7 @@ async function atomicText(file, body) {
|
|
|
26823
26882
|
await fd.close();
|
|
26824
26883
|
}
|
|
26825
26884
|
await rename7(temporary, file);
|
|
26826
|
-
const dir = await open10(
|
|
26885
|
+
const dir = await open10(path18.dirname(file), "r");
|
|
26827
26886
|
try {
|
|
26828
26887
|
await dir.sync();
|
|
26829
26888
|
} finally {
|
|
@@ -26836,15 +26895,15 @@ async function atomicText(file, body) {
|
|
|
26836
26895
|
async function verifyVersion(root, record2) {
|
|
26837
26896
|
const directory3 = await info3(root);
|
|
26838
26897
|
if (!directory3?.isDirectory() || directory3.isSymbolicLink() || directory3.uid !== process.getuid?.() || directory3.mode & 63) fail6("claude_installed_files_invalid");
|
|
26839
|
-
const marker = await privateRead4(
|
|
26840
|
-
if (!marker || marker.host !== "claude-code" || marker.mode !== "mcp-and-skills" || marker.profile !== record2.profile || marker.configFile !== record2.configFile || marker.version !== record2.version || marker.payloadDigest !== record2.payloadDigest || payload.payloadDigest !== marker.payloadDigest || !
|
|
26898
|
+
const marker = await privateRead4(path18.join(root, "installation.json")), payload = await inspectRuntimePackage(root);
|
|
26899
|
+
if (!marker || marker.host !== "claude-code" || marker.mode !== "mcp-and-skills" || marker.profile !== record2.profile || marker.configFile !== record2.configFile || marker.version !== record2.version || marker.payloadDigest !== record2.payloadDigest || payload.payloadDigest !== marker.payloadDigest || !path18.isAbsolute(marker.nodeCommand ?? "")) fail6("claude_installed_files_invalid");
|
|
26841
26900
|
return marker;
|
|
26842
26901
|
}
|
|
26843
26902
|
function mcpDefinition(record2, nodeCommand) {
|
|
26844
26903
|
return {
|
|
26845
26904
|
type: "stdio",
|
|
26846
26905
|
command: nodeCommand,
|
|
26847
|
-
args: [
|
|
26906
|
+
args: [path18.join(record2.versionRoot, "bin/promptframe-creation.mjs"), "bridge", "--config", record2.configFile, "--host", "claude-code"]
|
|
26848
26907
|
};
|
|
26849
26908
|
}
|
|
26850
26909
|
function skillBody(payload, sourceName, name) {
|
|
@@ -26860,7 +26919,7 @@ async function observedSkill(plan, record2, { allowBefore = false } = {}) {
|
|
|
26860
26919
|
if (!directory3.isDirectory() || directory3.isSymbolicLink() || directory3.uid !== process.getuid?.() || directory3.mode & 63) fail6("claude_skill_requires_review");
|
|
26861
26920
|
const names = await readdir6(plan.root);
|
|
26862
26921
|
if (names.some((n) => !["SKILL.md", "promptframe-installation.json"].includes(n))) fail6("claude_skill_requires_review");
|
|
26863
|
-
const marker = await privateRead4(
|
|
26922
|
+
const marker = await privateRead4(path18.join(plan.root, "promptframe-installation.json")), file = path18.join(plan.root, "SKILL.md"), s3 = await info3(file);
|
|
26864
26923
|
if (!marker || marker.host !== "claude-code" || marker.profile !== record2.profile || marker.configFile !== record2.configFile || marker.name !== plan.name)
|
|
26865
26924
|
fail6("claude_skill_requires_review");
|
|
26866
26925
|
if (!s3 && allowBefore && plan.beforeSHA === null && marker.sha256 === null) return false;
|
|
@@ -26882,13 +26941,13 @@ async function installClaudeMcpFallback({
|
|
|
26882
26941
|
nodeCommand,
|
|
26883
26942
|
writeSkill = atomicText
|
|
26884
26943
|
}) {
|
|
26885
|
-
const payload = await inspectRuntimePackage(
|
|
26944
|
+
const payload = await inspectRuntimePackage(path18.resolve(sourceRoot)), suffix = profile === "default" ? "" : "-" + profile, serverName = "promptframe" + suffix, root = path18.resolve(env.XDG_DATA_HOME ?? path18.join(homedir9(), ".local/share"), "promptframe-creation", profile, "claude-code-mcp");
|
|
26886
26945
|
await privateDirectory5(root);
|
|
26887
|
-
const release = await acquire3(root, signal), versions =
|
|
26946
|
+
const release = await acquire3(root, signal), versions = path18.join(root, "versions"), currentFile = path18.join(root, "current.json"), pendingFile = path18.join(root, "registration-pending.json"), versionRoot = path18.join(versions, payload.version), temporary = path18.join(versions, ".partial-" + randomBytes6(12).toString("hex"));
|
|
26888
26947
|
let writeStarted = false, newFiles = 0;
|
|
26889
26948
|
const complete = { host: "claude-code", mode: "mcp-and-skills", profile, configFile: configFile2, serverName, version: payload.version, versionRoot, payloadDigest: payload.payloadDigest };
|
|
26890
26949
|
const checkBinding = (record2) => {
|
|
26891
|
-
if (record2 && (record2.host !== "claude-code" || record2.mode !== "mcp-and-skills" || record2.profile !== profile || record2.configFile !== configFile2 || record2.serverName !== serverName || !/^\d+\.\d+\.\d+$/.test(record2.version ?? "") || record2.versionRoot !==
|
|
26950
|
+
if (record2 && (record2.host !== "claude-code" || record2.mode !== "mcp-and-skills" || record2.profile !== profile || record2.configFile !== configFile2 || record2.serverName !== serverName || !/^\d+\.\d+\.\d+$/.test(record2.version ?? "") || record2.versionRoot !== path18.join(versions, record2.version))) fail6("profile_binding_conflict");
|
|
26892
26951
|
};
|
|
26893
26952
|
try {
|
|
26894
26953
|
await privateDirectory5(versions);
|
|
@@ -26905,7 +26964,7 @@ async function installClaudeMcpFallback({
|
|
|
26905
26964
|
if (!Array.isArray(record2.skills) || record2.skills.length !== 2) fail6("claude_skill_requires_review");
|
|
26906
26965
|
for (const [i, skill] of record2.skills.entries()) {
|
|
26907
26966
|
const name = ["creation-setup", "video-creation"][i] + suffix;
|
|
26908
|
-
if (skill.name !== name || skill.root !==
|
|
26967
|
+
if (skill.name !== name || skill.root !== path18.join(claudeConfigRoot(env), "skills", name) || !/^[a-f0-9]{64}$/.test(skill.sha256 ?? ""))
|
|
26909
26968
|
fail6("claude_skill_requires_review");
|
|
26910
26969
|
if (!await observedSkill(skill, record2)) return false;
|
|
26911
26970
|
}
|
|
@@ -26948,8 +27007,8 @@ async function installClaudeMcpFallback({
|
|
|
26948
27007
|
await mkdir7(temporary, { mode: 448 });
|
|
26949
27008
|
for (const file of payload.files) {
|
|
26950
27009
|
signal?.throwIfAborted();
|
|
26951
|
-
const dest =
|
|
26952
|
-
await mkdir7(
|
|
27010
|
+
const dest = path18.join(temporary, file.path);
|
|
27011
|
+
await mkdir7(path18.dirname(dest), { recursive: true, mode: 448 });
|
|
26953
27012
|
const fd = await open10(dest, "wx", 384);
|
|
26954
27013
|
try {
|
|
26955
27014
|
await fd.writeFile(file.body);
|
|
@@ -26959,7 +27018,7 @@ async function installClaudeMcpFallback({
|
|
|
26959
27018
|
}
|
|
26960
27019
|
}
|
|
26961
27020
|
await checkRuntime(temporary, payload.version);
|
|
26962
|
-
await atomicJSON3(
|
|
27021
|
+
await atomicJSON3(path18.join(temporary, "installation.json"), { ...complete, nodeCommand });
|
|
26963
27022
|
signal?.throwIfAborted();
|
|
26964
27023
|
await rename7(temporary, versionRoot);
|
|
26965
27024
|
newFiles = payload.files.length;
|
|
@@ -26967,13 +27026,13 @@ async function installClaudeMcpFallback({
|
|
|
26967
27026
|
const ready = await verifyVersion(versionRoot, complete);
|
|
26968
27027
|
complete.server = mcpDefinition(complete, ready.nodeCommand);
|
|
26969
27028
|
if (newFiles === 0) await verifyInstalledRuntime(versionRoot, payload.version, ready.nodeCommand, { env });
|
|
26970
|
-
const skillRoot =
|
|
27029
|
+
const skillRoot = path18.join(claudeConfigRoot(env), "skills");
|
|
26971
27030
|
await mkdir7(skillRoot, { recursive: true, mode: 448 });
|
|
26972
27031
|
const parent = await lstat11(skillRoot);
|
|
26973
27032
|
if (!parent.isDirectory() || parent.isSymbolicLink() || parent.uid !== process.getuid?.()) fail6("claude_skill_requires_review");
|
|
26974
27033
|
const plans = [];
|
|
26975
27034
|
for (const sourceName of ["creation-setup", "video-creation"]) {
|
|
26976
|
-
const name = sourceName + suffix, body = skillBody(payload, sourceName, name), skill = { name, root:
|
|
27035
|
+
const name = sourceName + suffix, body = skillBody(payload, sourceName, name), skill = { name, root: path18.join(skillRoot, name), sha256: hash6(body) };
|
|
26977
27036
|
if (pending) {
|
|
26978
27037
|
const old = pending.skills?.find((s3) => s3.name === name);
|
|
26979
27038
|
if (!old || old.root !== skill.root || old.sha256 !== skill.sha256) fail6("registration_unconfirmed_keep_existing");
|
|
@@ -26982,7 +27041,7 @@ async function installClaudeMcpFallback({
|
|
|
26982
27041
|
const existing = await info3(skill.root);
|
|
26983
27042
|
let beforeSHA = null;
|
|
26984
27043
|
if (existing) {
|
|
26985
|
-
const marker = await privateRead4(
|
|
27044
|
+
const marker = await privateRead4(path18.join(skill.root, "promptframe-installation.json"));
|
|
26986
27045
|
if (!marker || marker.profile !== profile || marker.configFile !== configFile2 || marker.name !== name) fail6("claude_skill_requires_review");
|
|
26987
27046
|
const old = { ...skill, sha256: marker.sha256 };
|
|
26988
27047
|
if (!await observedSkill(old, complete)) fail6("claude_skill_requires_review");
|
|
@@ -27003,10 +27062,10 @@ async function installClaudeMcpFallback({
|
|
|
27003
27062
|
} else {
|
|
27004
27063
|
if (plan.beforeSHA !== null) fail6("claude_skill_requires_review");
|
|
27005
27064
|
await claimSkillDirectory(plan.root);
|
|
27006
|
-
await atomicJSON3(
|
|
27065
|
+
await atomicJSON3(path18.join(plan.root, "promptframe-installation.json"), { host: "claude-code", profile, configFile: configFile2, name: plan.name, sha256: null });
|
|
27007
27066
|
}
|
|
27008
|
-
await writeSkill(
|
|
27009
|
-
await atomicJSON3(
|
|
27067
|
+
await writeSkill(path18.join(plan.root, "SKILL.md"), plan.body);
|
|
27068
|
+
await atomicJSON3(path18.join(plan.root, "promptframe-installation.json"), { host: "claude-code", profile, configFile: configFile2, name: plan.name, sha256: plan.sha256 });
|
|
27010
27069
|
}
|
|
27011
27070
|
signal?.throwIfAborted();
|
|
27012
27071
|
if (compareVersions2(payload.version, "0.3.1") >= 0) complete.hostHooks = await registerClaudeFallbackHooks({ record: complete, root, env, nodeCommand: ready.nodeCommand, signal });
|
|
@@ -27075,7 +27134,7 @@ async function registrations(run, pluginName, marketplace, root) {
|
|
|
27075
27134
|
if (plugins.some((p2) => !p2 || typeof p2.id !== "string" || !p2.id || p2.id.length > 256 || typeof p2.scope !== "string" || typeof p2.version !== "string" || typeof p2.enabled !== "boolean" || typeof p2.installPath !== "string") || markets.some((p2) => !p2 || typeof p2.name !== "string" || !p2.name || typeof p2.source !== "string"))
|
|
27076
27135
|
fail7("claude_local_registration_unconfirmed");
|
|
27077
27136
|
const related = plugins.filter((p2) => typeof p2?.id === "string" && p2.id.startsWith(pluginName + "@"));
|
|
27078
|
-
if (related.length > 1 || related.some((p2) => p2.id !== pluginName + "@" + marketplace || p2.scope !== "user" || typeof p2.enabled !== "boolean" || !/^\d+\.\d+\.\d+$/.test(p2.version ?? "") || !
|
|
27137
|
+
if (related.length > 1 || related.some((p2) => p2.id !== pluginName + "@" + marketplace || p2.scope !== "user" || typeof p2.enabled !== "boolean" || !/^\d+\.\d+\.\d+$/.test(p2.version ?? "") || !path19.isAbsolute(p2.installPath ?? "") || p2.readFromFolder !== void 0 && (!path19.isAbsolute(p2.readFromFolder) || !/^\d+\.\d+\.\d+$/.test(p2.folderVersion ?? ""))))
|
|
27079
27138
|
fail7("claude_existing_registration_requires_review");
|
|
27080
27139
|
const found = markets.filter((p2) => p2?.name === marketplace);
|
|
27081
27140
|
if (found.length > 1 || found.some((p2) => p2.source !== "directory" || p2.path !== root || p2.installLocation !== root))
|
|
@@ -27095,19 +27154,19 @@ async function verifyVersion2(root, { version: version3, profile, configFile: co
|
|
|
27095
27154
|
const directory3 = await info4(root);
|
|
27096
27155
|
if (!directory3?.isDirectory() || directory3.isSymbolicLink() || directory3.uid !== process.getuid?.() || directory3.mode & 63)
|
|
27097
27156
|
fail7("claude_installed_files_invalid");
|
|
27098
|
-
const ready = await privateRead5(
|
|
27157
|
+
const ready = await privateRead5(path19.join(root, "installation.json"));
|
|
27099
27158
|
if (!ready || ready.host !== "claude-code" || ready.version !== version3 || ready.profile !== profile || ready.configFile !== configFile2 || ready.payloadDigest !== payloadDigest || !Array.isArray(ready.files) || ready.files.length > 1024) fail7("claude_installed_files_invalid");
|
|
27100
27159
|
const actual = await inspectRuntimePackage(root);
|
|
27101
|
-
if (actual.version !== version3 || JSON.stringify(actual.files.map(({ path:
|
|
27160
|
+
if (actual.version !== version3 || JSON.stringify(actual.files.map(({ path: path21, bytes: bytes2, sha256 }) => ({ path: path21, bytes: bytes2, sha256 }))) !== JSON.stringify(ready.files))
|
|
27102
27161
|
fail7("claude_installed_files_invalid");
|
|
27103
|
-
const manifest = JSON.parse(await readFile9(
|
|
27162
|
+
const manifest = JSON.parse(await readFile9(path19.join(root, ".claude-plugin/plugin.json"), "utf8"));
|
|
27104
27163
|
if (manifest.name !== pluginName || manifest.version !== version3 || manifest.skills !== "./skills/" || manifest.mcpServers !== "./.claude-mcp.json")
|
|
27105
27164
|
fail7("claude_installed_files_invalid");
|
|
27106
27165
|
let runtimeCommand;
|
|
27107
27166
|
for (const file of [".mcp.json", ".claude-mcp.json"]) {
|
|
27108
|
-
const mcp = JSON.parse(await readFile9(
|
|
27167
|
+
const mcp = JSON.parse(await readFile9(path19.join(root, file), "utf8"));
|
|
27109
27168
|
const command2 = mcp.mcpServers?.[serverName]?.command;
|
|
27110
|
-
if (!
|
|
27169
|
+
if (!path19.isAbsolute(command2 ?? "") || runtimeCommand !== void 0 && command2 !== runtimeCommand || JSON.stringify(mcp) !== JSON.stringify(transport(serverName, configFile2, command2))) fail7("claude_installed_files_invalid");
|
|
27111
27170
|
runtimeCommand = command2;
|
|
27112
27171
|
}
|
|
27113
27172
|
if (compareVersions3(version3, "0.3.1") >= 0 && JSON.stringify(manifest.hooks) !== JSON.stringify(claudeHostHooks({ pluginName, configFile: configFile2, nodeCommand: runtimeCommand })))
|
|
@@ -27117,7 +27176,7 @@ async function verifyVersion2(root, { version: version3, profile, configFile: co
|
|
|
27117
27176
|
async function installForClaudeUser(options = {}) {
|
|
27118
27177
|
const profile = options.profile ?? "default", env = options.env ?? process.env;
|
|
27119
27178
|
validProfile2(profile);
|
|
27120
|
-
const modeRoot =
|
|
27179
|
+
const modeRoot = path19.resolve(env.XDG_DATA_HOME ?? path19.join(homedir10(), ".local/share"), "promptframe-creation", profile, "claude-code-mode");
|
|
27121
27180
|
await privateDirectory6(modeRoot);
|
|
27122
27181
|
const release = await acquire4(modeRoot, options.signal);
|
|
27123
27182
|
try {
|
|
@@ -27139,37 +27198,37 @@ async function installClaudeUserLocked({
|
|
|
27139
27198
|
nodeCommand = process.execPath
|
|
27140
27199
|
} = {}) {
|
|
27141
27200
|
validProfile2(profile);
|
|
27142
|
-
if (!
|
|
27201
|
+
if (!path19.isAbsolute(nodeCommand)) fail7("runtime_command_invalid");
|
|
27143
27202
|
const hostVersion = (await runClaude(["--version"])).trim().match(/^(\d+\.\d+\.\d+) \(Claude Code\)$/);
|
|
27144
27203
|
if (!hostVersion || compareVersions3(hostVersion[1], "2.1.295") < 0) fail7("claude_21295_required");
|
|
27145
27204
|
const help = await runClaude(["--help"]);
|
|
27146
27205
|
if (typeof help !== "string" || Buffer.byteLength(help) > 128 * 1024) fail7("claude_capabilities_unconfirmed");
|
|
27147
27206
|
const hasPlugin = /^\s+plugin(?:\|plugins)?\s/m.test(help), hasMcp = /^\s+mcp\s/m.test(help);
|
|
27148
|
-
const base =
|
|
27149
|
-
const pluginPending = await info4(
|
|
27207
|
+
const base = path19.resolve(env.XDG_DATA_HOME ?? path19.join(homedir10(), ".local/share"), "promptframe-creation", profile), fallbackRoot = path19.join(base, "claude-code-mcp"), pluginRoot = path19.join(base, "claude-code");
|
|
27208
|
+
const pluginPending = await info4(path19.join(pluginRoot, "registration-pending.json")), pluginCurrent = await info4(path19.join(pluginRoot, "current.json")), fallbackState = await info4(path19.join(fallbackRoot, "current.json")) || await info4(path19.join(fallbackRoot, "registration-pending.json"));
|
|
27150
27209
|
if ((!hasPlugin || fallbackState) && (pluginPending || pluginCurrent)) fail7("registration_unconfirmed_keep_existing");
|
|
27151
27210
|
if (!hasPlugin || fallbackState) {
|
|
27152
27211
|
if (!hasMcp) fail7("claude_capabilities_unconfirmed");
|
|
27153
27212
|
return installClaudeMcpFallback({ sourceRoot, profile, env, configFile: configFile2, signal, runClaude, checkRuntime, verifyInstalledRuntime, nodeCommand });
|
|
27154
27213
|
}
|
|
27155
|
-
const payload = await inspectRuntimePackage(
|
|
27214
|
+
const payload = await inspectRuntimePackage(path19.resolve(sourceRoot));
|
|
27156
27215
|
if (!payload.files.some((f2) => f2.path === ".claude-plugin/plugin.json") || !payload.files.some((f2) => f2.path === ".claude-mcp.json"))
|
|
27157
27216
|
fail7("claude_package_incomplete");
|
|
27158
|
-
const root =
|
|
27217
|
+
const root = path19.resolve(env.XDG_DATA_HOME ?? path19.join(homedir10(), ".local/share"), "promptframe-creation", profile, "claude-code");
|
|
27159
27218
|
await privateDirectory6(root);
|
|
27160
27219
|
const release = await acquire4(root, signal);
|
|
27161
27220
|
const suffix = profile === "default" ? "" : "-" + profile, pluginName = "promptframe-creation" + suffix, marketplace = "promptframe-creation-user" + suffix, pluginId = pluginName + "@" + marketplace, serverName = "promptframe" + suffix;
|
|
27162
|
-
const versions =
|
|
27221
|
+
const versions = path19.join(root, "versions"), currentFile = path19.join(root, "current.json"), pendingFile = path19.join(root, "registration-pending.json"), catalogFile = path19.join(root, ".claude-plugin/marketplace.json"), versionRoot = path19.join(versions, payload.version), temporary = path19.join(versions, ".partial-" + randomBytes7(12).toString("hex"));
|
|
27163
27222
|
let registrationStarted = false, newFiles = 0;
|
|
27164
27223
|
try {
|
|
27165
27224
|
signal?.throwIfAborted();
|
|
27166
27225
|
await privateDirectory6(versions);
|
|
27167
|
-
await privateDirectory6(
|
|
27226
|
+
await privateDirectory6(path19.dirname(catalogFile));
|
|
27168
27227
|
await legacyUserMcp(env, serverName);
|
|
27169
27228
|
let previous = await privateRead5(currentFile), pending = await privateRead5(pendingFile), state = await registrations(runClaude, pluginName, marketplace, root);
|
|
27170
27229
|
const binding = { profile, configFile: configFile2, pluginId, pluginName, serverName, host: "claude-code" };
|
|
27171
27230
|
const checkBinding = (record2) => {
|
|
27172
|
-
if (record2 && (record2.profile !== profile || record2.configFile !== configFile2 || record2.pluginId !== pluginId || record2.host !== "claude-code" || !/^\d+\.\d+\.\d+$/.test(record2.version ?? "") || record2.versionRoot !==
|
|
27231
|
+
if (record2 && (record2.profile !== profile || record2.configFile !== configFile2 || record2.pluginId !== pluginId || record2.host !== "claude-code" || !/^\d+\.\d+\.\d+$/.test(record2.version ?? "") || record2.versionRoot !== path19.join(versions, record2.version))) fail7("profile_binding_conflict");
|
|
27173
27232
|
};
|
|
27174
27233
|
checkBinding(previous);
|
|
27175
27234
|
checkBinding(pending);
|
|
@@ -27216,8 +27275,8 @@ async function installClaudeUserLocked({
|
|
|
27216
27275
|
await mkdir8(temporary, { mode: 448 });
|
|
27217
27276
|
for (const file of payload.files) {
|
|
27218
27277
|
signal?.throwIfAborted();
|
|
27219
|
-
const dest =
|
|
27220
|
-
await mkdir8(
|
|
27278
|
+
const dest = path19.join(temporary, file.path);
|
|
27279
|
+
await mkdir8(path19.dirname(dest), { recursive: true, mode: 448 });
|
|
27221
27280
|
const fd = await open11(dest, "wx", 384);
|
|
27222
27281
|
try {
|
|
27223
27282
|
await fd.writeFile(file.body);
|
|
@@ -27226,18 +27285,18 @@ async function installClaudeUserLocked({
|
|
|
27226
27285
|
await fd.close();
|
|
27227
27286
|
}
|
|
27228
27287
|
}
|
|
27229
|
-
const manifest = JSON.parse(await readFile9(
|
|
27288
|
+
const manifest = JSON.parse(await readFile9(path19.join(temporary, ".claude-plugin/plugin.json"), "utf8"));
|
|
27230
27289
|
manifest.name = pluginName;
|
|
27231
27290
|
if (manifest.hooks) manifest.hooks = claudeHostHooks({ pluginName, configFile: configFile2, nodeCommand });
|
|
27232
|
-
await atomicJSON4(
|
|
27233
|
-
for (const file of [".mcp.json", ".claude-mcp.json"]) await atomicJSON4(
|
|
27291
|
+
await atomicJSON4(path19.join(temporary, ".claude-plugin/plugin.json"), manifest);
|
|
27292
|
+
for (const file of [".mcp.json", ".claude-mcp.json"]) await atomicJSON4(path19.join(temporary, file), transport(serverName, configFile2, nodeCommand));
|
|
27234
27293
|
await checkRuntime(temporary, payload.version);
|
|
27235
27294
|
const installed = await inspectRuntimePackage(temporary);
|
|
27236
|
-
await atomicJSON4(
|
|
27295
|
+
await atomicJSON4(path19.join(temporary, "installation.json"), {
|
|
27237
27296
|
...binding,
|
|
27238
27297
|
version: payload.version,
|
|
27239
27298
|
payloadDigest: payload.payloadDigest,
|
|
27240
|
-
files: installed.files.map(({ path:
|
|
27299
|
+
files: installed.files.map(({ path: path21, bytes: bytes2, sha256 }) => ({ path: path21, bytes: bytes2, sha256 }))
|
|
27241
27300
|
});
|
|
27242
27301
|
signal?.throwIfAborted();
|
|
27243
27302
|
await rename8(temporary, versionRoot);
|
|
@@ -27292,7 +27351,7 @@ async function installClaudeUserLocked({
|
|
|
27292
27351
|
|
|
27293
27352
|
// lib/cli.mjs
|
|
27294
27353
|
import { fileURLToPath } from "node:url";
|
|
27295
|
-
import
|
|
27354
|
+
import path20 from "node:path";
|
|
27296
27355
|
var args = process.argv.slice(2);
|
|
27297
27356
|
var command = args.shift();
|
|
27298
27357
|
var value = (key) => {
|
|
@@ -27300,9 +27359,9 @@ var value = (key) => {
|
|
|
27300
27359
|
return i < 0 ? void 0 : args[i + 1];
|
|
27301
27360
|
};
|
|
27302
27361
|
var log = (value2) => process.stdout.write(JSON.stringify(value2) + "\n");
|
|
27303
|
-
var configFile = () => value("--config") ?
|
|
27362
|
+
var configFile = () => value("--config") ? path20.resolve(value("--config")) : profileCredentialsPath(value("--profile") ?? "default");
|
|
27304
27363
|
async function probe(credentials) {
|
|
27305
|
-
const client = await connectPlatform(credentials, { host: resolveHostIdentity({ host: value("--host") }) });
|
|
27364
|
+
const client = await connectPlatform(credentials, { host: resolveHostIdentity({ host: value("--host") }), clientConfigFile: configFile() });
|
|
27306
27365
|
try {
|
|
27307
27366
|
return { tools: (await client.listTools()).tools.length, accountIdentity: connectionAccountIdentity(client) };
|
|
27308
27367
|
} finally {
|
|
@@ -27447,7 +27506,8 @@ async function bridge() {
|
|
|
27447
27506
|
contentTypes: () => contentTypes,
|
|
27448
27507
|
contentSource: () => contentSource,
|
|
27449
27508
|
enforceMinimum: false,
|
|
27450
|
-
signal: startup.signal
|
|
27509
|
+
signal: startup.signal,
|
|
27510
|
+
clientConfigFile: configFile()
|
|
27451
27511
|
});
|
|
27452
27512
|
upstream = client.getServerCapabilities() ?? {};
|
|
27453
27513
|
policy = readPlatformBridgePolicy(upstream);
|
|
@@ -27458,7 +27518,7 @@ async function bridge() {
|
|
|
27458
27518
|
resolvedVersion: value("--resolved-runtime-version"),
|
|
27459
27519
|
signal: startup.signal,
|
|
27460
27520
|
hostKind: identity.kind,
|
|
27461
|
-
cacheRoot:
|
|
27521
|
+
cacheRoot: path20.join(path20.dirname(configFile()), "runtime-cache")
|
|
27462
27522
|
});
|
|
27463
27523
|
startup.signal.throwIfAborted();
|
|
27464
27524
|
} catch (error5) {
|
|
@@ -27497,9 +27557,9 @@ async function bridge() {
|
|
|
27497
27557
|
hostSession,
|
|
27498
27558
|
connectionOptions: { contentTypes: () => contentTypes, contentSource: () => contentSource },
|
|
27499
27559
|
createLocalUploads: ({ identity: account, agent, configFile: file }) => createLocalUploadManager({
|
|
27500
|
-
stateRoot:
|
|
27560
|
+
stateRoot: path20.join(path20.dirname(file), "local-upload-state", "accounts", localAccountKey(account), localAgentDigest(agent).slice(7))
|
|
27501
27561
|
}),
|
|
27502
|
-
localUploads: createLocalUploadManager({ stateRoot:
|
|
27562
|
+
localUploads: createLocalUploadManager({ stateRoot: path20.join(path20.dirname(configFile()), "local-upload-state") }),
|
|
27503
27563
|
onCatalogChange: () => server.sendToolListChanged(),
|
|
27504
27564
|
onKnowledgeChange: (kind) => kind === "resources" ? server.sendResourceListChanged() : server.sendPromptListChanged()
|
|
27505
27565
|
});
|