mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-03 11:47:42 +01:00
Fix public Cursor asset ownership and add runtime-loss qualification
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
e2b89b6302
commit
37ba674378
16 files changed
+395
-12
No files matched your search
@@ -0,0 +1,12 @@
|
||||
import { dirname, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
/** Both public server vendoring and the standalone runner own their assets. */
|
||||
export function cursorProvisionerPackageRoot(moduleUrl) {
|
||||
const url = new URL(moduleUrl);
|
||||
if (url.protocol !== "file:" || url.search || url.hash) throw new Error("Cursor setup requires a published provisioner");
|
||||
const path = fileURLToPath(url);
|
||||
if (/\/dist\/vendor\/paperclip-runner\/cli\/provision-cursor\.(?:cjs|js)$/.test(path)) return resolve(dirname(path), "..");
|
||||
if (/\/dist\/cli\/provision-cursor\.(?:cjs|js)$/.test(path)) return resolve(dirname(path), "../..");
|
||||
throw new Error("Cursor setup requires a published provisioner");
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
import { cursorProvisionerPackageRoot } from "./cursor-provisioner-layout.mjs";
|
||||
|
||||
test("public server setup owns the same asset root as its vendored runtime", () => {
|
||||
assert.equal(cursorProvisionerPackageRoot("file:///consumer/node_modules/@paperclipai/server/dist/vendor/paperclip-runner/cli/provision-cursor.cjs"), "/consumer/node_modules/@paperclipai/server/dist/vendor/paperclip-runner");
|
||||
});
|
||||
test("standalone runner setup owns package assets", () => {
|
||||
assert.equal(cursorProvisionerPackageRoot("file:///consumer/node_modules/@paperclipai/paperclip-runner/dist/cli/provision-cursor.cjs"), "/consumer/node_modules/@paperclipai/paperclip-runner");
|
||||
});
|
||||
test("unbundled and foreign layouts cannot provision outside an owned package", () => {
|
||||
for (const url of ["file:///repo/packages/paperclip-runner/scripts/provision-cursor.mjs", "file:///tmp/provision-cursor.cjs", "https://example.com/dist/cli/provision-cursor.js", "file:///consumer/dist/cli/provision-cursor.js?redirect=1"]) assert.throws(() => cursorProvisionerPackageRoot(url), /published provisioner/);
|
||||
});
|
||||
@@ -1,13 +1,13 @@
|
||||
#!/usr/bin/env node
|
||||
import { lstat } from "node:fs/promises";
|
||||
import { dirname, join, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { join } from "node:path";
|
||||
import { cursorProvisionerPackageRoot } from "./cursor-provisioner-layout.mjs";
|
||||
import { cursorDistribution, materializePinnedCursorDistribution, verifyCursorDistribution } from "./materialize-cursor-distribution.mjs";
|
||||
|
||||
/** Explicit public installation; never invoked by an npm lifecycle hook. */
|
||||
export async function provisionCursorRuntime() {
|
||||
const distribution = await cursorDistribution();
|
||||
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "../..");
|
||||
const packageRoot = cursorProvisionerPackageRoot(import.meta.url);
|
||||
const destination = join(packageRoot, "provider-assets", "cursor", `${distribution.platform}-${distribution.architecture}`);
|
||||
const installed = await lstat(destination).catch(error => {
|
||||
if (error.code !== "ENOENT") throw error;
|
||||
|
||||
Reference in new issue
Block a user