scalemax 0.1.11 → 0.1.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.
|
@@ -21,6 +21,7 @@ export interface CursorBundlePatchResult {
|
|
|
21
21
|
backupRoot?: string;
|
|
22
22
|
}
|
|
23
23
|
export declare function cursorAppPath(platform: NodeJS.Platform, env: NodeJS.ProcessEnv): string;
|
|
24
|
+
export declare function resolveCursorAppPath(platform: NodeJS.Platform, env: NodeJS.ProcessEnv, home: string): Promise<string>;
|
|
24
25
|
export declare function cursorBundlePaths(appPath: string): string[];
|
|
25
26
|
export declare function sha256Buffer(value: Buffer | string): string;
|
|
26
27
|
export declare function inspectCursorBundle(file: string): Promise<CursorBundleInspection>;
|
|
@@ -18,6 +18,39 @@ export function cursorAppPath(platform, env) {
|
|
|
18
18
|
return '/Applications/Cursor.app';
|
|
19
19
|
throw new Error(`Automatic Cursor BYOK setup is currently verified on macOS only (${platform} is not modified).`);
|
|
20
20
|
}
|
|
21
|
+
async function appLooksLikeCursor(appPath) {
|
|
22
|
+
if (!appPath.endsWith('.app'))
|
|
23
|
+
return false;
|
|
24
|
+
return (await Promise.all(CURSOR_BUNDLE_RELATIVE_PATHS.map(p => fs.pathExists(path.join(appPath, p))))).every(Boolean);
|
|
25
|
+
}
|
|
26
|
+
async function cursorAppCandidates(home, env) {
|
|
27
|
+
const roots = env.SCALEMAX_CURSOR_SEARCH_ROOTS ? env.SCALEMAX_CURSOR_SEARCH_ROOTS.split(path.delimiter).filter(Boolean) : ['/Applications', path.join(home, 'Applications')];
|
|
28
|
+
const candidates = roots.map(root => path.join(root, 'Cursor.app'));
|
|
29
|
+
for (const root of roots) {
|
|
30
|
+
let entries = [];
|
|
31
|
+
try {
|
|
32
|
+
entries = await fs.readdir(root);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
for (const entry of entries) {
|
|
38
|
+
if (/cursor/i.test(entry) && entry.endsWith('.app'))
|
|
39
|
+
candidates.push(path.join(root, entry));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return Array.from(new Set(candidates));
|
|
43
|
+
}
|
|
44
|
+
export async function resolveCursorAppPath(platform, env, home) {
|
|
45
|
+
if (platform !== 'darwin')
|
|
46
|
+
throw new Error(`Automatic Cursor BYOK setup is currently verified on macOS only (${platform} is not modified).`);
|
|
47
|
+
if (env.SCALEMAX_CURSOR_APP_PATH)
|
|
48
|
+
return path.resolve(env.SCALEMAX_CURSOR_APP_PATH);
|
|
49
|
+
for (const candidate of await cursorAppCandidates(home, env))
|
|
50
|
+
if (await appLooksLikeCursor(candidate))
|
|
51
|
+
return candidate;
|
|
52
|
+
return '/Applications/Cursor.app';
|
|
53
|
+
}
|
|
21
54
|
export function cursorBundlePaths(appPath) { return CURSOR_BUNDLE_RELATIVE_PATHS.map(p => path.join(appPath, p)); }
|
|
22
55
|
export function sha256Buffer(value) { return crypto.createHash('sha256').update(value).digest('hex'); }
|
|
23
56
|
function count(text, needle) { let n = 0, from = 0; while ((from = text.indexOf(needle, from)) !== -1) {
|
package/dist/configure/cursor.js
CHANGED
|
@@ -3,7 +3,7 @@ import fs from 'fs-extra';
|
|
|
3
3
|
import { execa } from 'execa';
|
|
4
4
|
import { scaleMaxDir, timestamp } from '../utils/paths.js';
|
|
5
5
|
import { writeJsonAtomic, readJson } from '../utils/fs.js';
|
|
6
|
-
import {
|
|
6
|
+
import { resolveCursorAppPath, inspectCursorBundles, patchCursorBundles, restoreCursorBundles } from './cursor-bundle.js';
|
|
7
7
|
import { configureCursorState, restoreCursorState } from './cursor-state.js';
|
|
8
8
|
const id = 'cursor', name = 'Cursor';
|
|
9
9
|
function manifestPath(ctx) { return path.join(scaleMaxDir(ctx.home, ctx.platform, ctx.env), 'cursor', 'manifest.json'); }
|
|
@@ -13,8 +13,9 @@ async function cursorVersion(appPath) { try {
|
|
|
13
13
|
catch {
|
|
14
14
|
return undefined;
|
|
15
15
|
} }
|
|
16
|
-
|
|
17
|
-
async function
|
|
16
|
+
function appDisplayName(appPath) { return path.basename(appPath, '.app'); }
|
|
17
|
+
export async function isCursorRunning(appPath) { const r = await execa('/usr/bin/pgrep', ['-f', `${appPath}/Contents/MacOS/`], { reject: false }); return r.exitCode === 0 && Boolean(r.stdout.trim()); }
|
|
18
|
+
async function stopCursor(appPath) { await execa('/usr/bin/osascript', ['-e', `tell application "${appDisplayName(appPath)}" to quit`], { reject: false }); for (let i = 0; i < 30; i++) {
|
|
18
19
|
if (!(await isCursorRunning(appPath)))
|
|
19
20
|
return;
|
|
20
21
|
await new Promise(r => setTimeout(r, 500));
|
|
@@ -23,7 +24,7 @@ async function launchCursor(appPath) { await execa('/usr/bin/open', ['-a', appPa
|
|
|
23
24
|
export async function configure(ctx) {
|
|
24
25
|
if (ctx.platform !== 'darwin')
|
|
25
26
|
return { id, name, changed: false, message: `automatic Cursor BYOK setup is currently verified on macOS only; ${ctx.platform} was not modified` };
|
|
26
|
-
const appPath =
|
|
27
|
+
const appPath = await resolveCursorAppPath(ctx.platform, ctx.env, ctx.home);
|
|
27
28
|
if (!(await fs.pathExists(appPath)))
|
|
28
29
|
return { id, name, changed: false, path: appPath, message: 'Cursor.app was not found' };
|
|
29
30
|
const inspection = await inspectCursorBundles(appPath);
|
|
@@ -69,7 +70,7 @@ export async function configure(ctx) {
|
|
|
69
70
|
export async function verify(ctx) {
|
|
70
71
|
if (ctx.platform !== 'darwin')
|
|
71
72
|
return { id, name, changed: false, message: 'verification is currently available on macOS only' };
|
|
72
|
-
const appPath =
|
|
73
|
+
const appPath = await resolveCursorAppPath(ctx.platform, ctx.env, ctx.home), inspection = await inspectCursorBundles(appPath), manifest = await readJson(manifestPath(ctx), undefined);
|
|
73
74
|
if (inspection.status !== 'patched' || !manifest?.state?.modelIds?.length)
|
|
74
75
|
throw new Error('Cursor local BYOK patch or protected model state is incomplete.');
|
|
75
76
|
const live = new Set((ctx.models || []).map(m => m.id)), configured = new Set(manifest.state.modelIds), missing = [...live].filter(x => !configured.has(x));
|
package/dist/detect/cursor.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import fs from 'fs-extra';
|
|
3
3
|
import { scaleMaxDir } from '../utils/paths.js';
|
|
4
|
-
import {
|
|
4
|
+
import { resolveCursorAppPath, inspectCursorBundles } from '../configure/cursor-bundle.js';
|
|
5
5
|
export async function detect(ctx) {
|
|
6
6
|
if (ctx.platform !== 'darwin')
|
|
7
7
|
return { id: 'cursor', name: 'Cursor', installed: false, configured: false, paths: [], reason: `automatic BYOK setup currently supports macOS only (${ctx.platform})` };
|
|
8
|
-
const appPath =
|
|
8
|
+
const appPath = await resolveCursorAppPath(ctx.platform, ctx.env, ctx.home), manifest = path.join(scaleMaxDir(ctx.home, ctx.platform, ctx.env), 'cursor', 'manifest.json');
|
|
9
9
|
if (!(await fs.pathExists(appPath)))
|
|
10
10
|
return { id: 'cursor', name: 'Cursor', installed: false, configured: false, paths: [appPath], reason: 'Cursor.app not found' };
|
|
11
11
|
try {
|