cursorconnect 0.1.2 → 0.1.5
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 +6 -5
- package/bridge-runtime/dist/agent-title-match.js +16 -0
- package/bridge-runtime/dist/chat-display-store.d.ts +13 -0
- package/bridge-runtime/dist/chat-display-store.js +29 -0
- package/bridge-runtime/dist/chat-display.d.ts +11 -0
- package/bridge-runtime/dist/chat-display.js +290 -0
- package/bridge-runtime/dist/chat-sync.d.ts +6 -0
- package/bridge-runtime/dist/chat-sync.js +88 -0
- package/bridge-runtime/dist/extract-page.js +99 -3
- package/bridge-runtime/dist/history-pipeline-log.d.ts +16 -0
- package/bridge-runtime/dist/history-pipeline-log.js +29 -0
- package/bridge-runtime/dist/jsonl-index.d.ts +15 -3
- package/bridge-runtime/dist/jsonl-index.js +48 -12
- package/bridge-runtime/dist/message-filter.d.ts +10 -0
- package/bridge-runtime/dist/message-filter.js +65 -5
- package/bridge-runtime/dist/pairing-code.d.ts +3 -0
- package/bridge-runtime/dist/pairing-code.js +17 -0
- package/bridge-runtime/dist/pairing-identity.js +4 -7
- package/bridge-runtime/dist/relay.d.ts +8 -0
- package/bridge-runtime/dist/relay.js +254 -25
- package/bridge-runtime/dist/sidebar-merge.js +2 -2
- package/bridge-runtime/dist/types.d.ts +9 -1
- package/config.env.defaults +3 -0
- package/dist/big-code.js +36 -5
- package/dist/bridge-dir.js +6 -1
- package/dist/cli-version.js +13 -0
- package/dist/diagnose.js +224 -0
- package/dist/index.js +56 -92
- package/dist/launch.js +52 -14
- package/dist/pairing-code.js +18 -0
- package/dist/pairing-identity.js +6 -8
- package/dist/pairing-ttl.js +3 -0
- package/dist/print-pairing.js +18 -25
- package/dist/relay-config.js +49 -0
- package/dist/repo-root.js +2 -2
- package/dist/semver.js +21 -0
- package/dist/version-check.js +31 -0
- package/package.json +7 -3
- package/version-policy.json +8 -0
package/dist/print-pairing.js
CHANGED
|
@@ -1,33 +1,26 @@
|
|
|
1
1
|
import { renderBigCode } from './big-code.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { PAIRING_CODE_TTL_MINUTES } from './pairing-ttl.js';
|
|
3
|
+
/** Pairing code: plain ASCII (A–Z, 0–9) for app input. */
|
|
4
|
+
function pairingCodeAscii(code) {
|
|
5
|
+
return code.replace(/[^A-Z0-9]/g, '').slice(0, 6);
|
|
6
|
+
}
|
|
7
|
+
export function printPairingToTerminal(identity) {
|
|
8
|
+
const code = pairingCodeAscii(identity.pairingCode);
|
|
9
|
+
console.log('Cursor Connect запущен в фоне');
|
|
10
|
+
console.log('');
|
|
11
|
+
console.log('────────────────────────────────────────');
|
|
8
12
|
console.log('');
|
|
9
|
-
console.log(
|
|
13
|
+
console.log(` Компьютер: ${identity.machineLabel}`);
|
|
14
|
+
console.log('');
|
|
15
|
+
console.log(' Введите код в приложении Cursor Connect:');
|
|
10
16
|
console.log('');
|
|
11
17
|
console.log(renderBigCode(code));
|
|
12
18
|
console.log('');
|
|
13
|
-
console.log(
|
|
14
|
-
console.log(` Действует
|
|
19
|
+
console.log(' Код одноразовый');
|
|
20
|
+
console.log(` Действует ${PAIRING_CODE_TTL_MINUTES} мин`);
|
|
15
21
|
console.log('');
|
|
16
|
-
if (!ok) {
|
|
17
|
-
const parts = [];
|
|
18
|
-
if (!status.bridge)
|
|
19
|
-
parts.push('bridge');
|
|
20
|
-
if (!status.cdp)
|
|
21
|
-
parts.push('Cursor');
|
|
22
|
-
if (!status.connector)
|
|
23
|
-
parts.push('сервер');
|
|
24
|
-
console.log(` Ожидание: ${parts.join(', ')}…`);
|
|
25
|
-
console.log(' Подождите 10–20 с и снова: cursorconnect status');
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
console.log(' Готово — введите код на телефоне.');
|
|
29
|
-
}
|
|
30
22
|
console.log('────────────────────────────────────────');
|
|
31
|
-
console.log('
|
|
32
|
-
console.log(' Консоль можно
|
|
23
|
+
console.log(' Для остановки Cursor Connect введите cursorconnect stop');
|
|
24
|
+
console.log(' Консоль можно закрыть.');
|
|
25
|
+
console.log('');
|
|
33
26
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { resolvePackageRoot } from './bridge-dir.js';
|
|
4
|
+
import { USER_CONFIG_ENV } from './bridge-dir.js';
|
|
5
|
+
/** Shipped with npm package (generated at publish from bridge/.env). */
|
|
6
|
+
export const BUNDLED_CONFIG_ENV = join(resolvePackageRoot(), 'config.env.defaults');
|
|
7
|
+
/** Public production relay (same as app `extra.bridgeUrl`). */
|
|
8
|
+
export const DEFAULT_RELAY_URL = 'https://cc.fanpay.online';
|
|
9
|
+
export function loadEnvFile(path) {
|
|
10
|
+
if (!existsSync(path))
|
|
11
|
+
return {};
|
|
12
|
+
const out = {};
|
|
13
|
+
for (const line of readFileSync(path, 'utf-8').split('\n')) {
|
|
14
|
+
const t = line.trim();
|
|
15
|
+
if (!t || t.startsWith('#'))
|
|
16
|
+
continue;
|
|
17
|
+
const i = t.indexOf('=');
|
|
18
|
+
if (i < 1)
|
|
19
|
+
continue;
|
|
20
|
+
out[t.slice(0, i).trim()] = t.slice(i + 1).trim();
|
|
21
|
+
}
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
function pickNonEmpty(...values) {
|
|
25
|
+
for (const v of values) {
|
|
26
|
+
const t = v?.trim();
|
|
27
|
+
if (t)
|
|
28
|
+
return t;
|
|
29
|
+
}
|
|
30
|
+
return '';
|
|
31
|
+
}
|
|
32
|
+
/** Relay URL + connector token: bundled defaults → user config → bridge .env → process.env. */
|
|
33
|
+
export function resolveRelayConfig(extraPaths = []) {
|
|
34
|
+
const layers = [];
|
|
35
|
+
if (existsSync(BUNDLED_CONFIG_ENV))
|
|
36
|
+
layers.push(loadEnvFile(BUNDLED_CONFIG_ENV));
|
|
37
|
+
for (const p of extraPaths) {
|
|
38
|
+
if (existsSync(p))
|
|
39
|
+
layers.push(loadEnvFile(p));
|
|
40
|
+
}
|
|
41
|
+
if (existsSync(USER_CONFIG_ENV))
|
|
42
|
+
layers.push(loadEnvFile(USER_CONFIG_ENV));
|
|
43
|
+
const merged = {};
|
|
44
|
+
for (const layer of layers)
|
|
45
|
+
Object.assign(merged, layer);
|
|
46
|
+
const relayUrl = pickNonEmpty(merged.RELAY_URL, process.env.RELAY_URL, DEFAULT_RELAY_URL);
|
|
47
|
+
const relayToken = pickNonEmpty(merged.RELAY_TOKEN, process.env.RELAY_TOKEN);
|
|
48
|
+
return { relayUrl, relayToken };
|
|
49
|
+
}
|
package/dist/repo-root.js
CHANGED
|
@@ -20,7 +20,7 @@ export function loadInstallConfig() {
|
|
|
20
20
|
export function saveInstallConfig(repoRoot) {
|
|
21
21
|
const abs = resolve(repoRoot);
|
|
22
22
|
if (!isValidRepoRoot(abs)) {
|
|
23
|
-
throw new Error(`Не найден bridge в ${abs} (ожидается …/bridge/package.json)`);
|
|
23
|
+
throw new Error(`Не найден Cursor Connect (bridge) в ${abs} (ожидается …/bridge/package.json)`);
|
|
24
24
|
}
|
|
25
25
|
mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });
|
|
26
26
|
writeFileSync(CONFIG_FILE, JSON.stringify({ repoRoot: abs }, null, 2), { mode: 0o600 });
|
|
@@ -59,7 +59,7 @@ export function resolveRepoRoot() {
|
|
|
59
59
|
const fromDev = devRepoRoot();
|
|
60
60
|
if (fromDev)
|
|
61
61
|
return fromDev;
|
|
62
|
-
throw new Error('Не найден bridge.\n' +
|
|
62
|
+
throw new Error('Не найден Cursor Connect (bridge).\n' +
|
|
63
63
|
' npm install -g cursorconnect && cursorconnect start');
|
|
64
64
|
}
|
|
65
65
|
export function configFilePath() {
|
package/dist/semver.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function parseSemver(v) {
|
|
2
|
+
const m = v.trim().match(/^(\d+)\.(\d+)\.(\d+)/);
|
|
3
|
+
if (!m)
|
|
4
|
+
return null;
|
|
5
|
+
return [Number(m[1]), Number(m[2]), Number(m[3])];
|
|
6
|
+
}
|
|
7
|
+
export function compareSemver(a, b) {
|
|
8
|
+
const pa = parseSemver(a);
|
|
9
|
+
const pb = parseSemver(b);
|
|
10
|
+
if (!pa || !pb)
|
|
11
|
+
return null;
|
|
12
|
+
for (let i = 0; i < 3; i++) {
|
|
13
|
+
if (pa[i] !== pb[i])
|
|
14
|
+
return pa[i] < pb[i] ? -1 : 1;
|
|
15
|
+
}
|
|
16
|
+
return 0;
|
|
17
|
+
}
|
|
18
|
+
export function isVersionAtLeast(current, minimum) {
|
|
19
|
+
const c = compareSemver(current, minimum);
|
|
20
|
+
return c !== null && c >= 0;
|
|
21
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { isVersionAtLeast } from './semver.js';
|
|
2
|
+
import { CLI_VERSION } from './cli-version.js';
|
|
3
|
+
export async function fetchRemoteVersionPolicy(relayUrl) {
|
|
4
|
+
const base = relayUrl.replace(/\/$/, '');
|
|
5
|
+
try {
|
|
6
|
+
const res = await fetch(`${base}/api/version-policy`, {
|
|
7
|
+
signal: AbortSignal.timeout(12_000),
|
|
8
|
+
});
|
|
9
|
+
if (!res.ok)
|
|
10
|
+
return null;
|
|
11
|
+
return (await res.json());
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export function assertCliVersionAllowed(policy, current = CLI_VERSION) {
|
|
18
|
+
if (isVersionAtLeast(current, policy.minCliVersion))
|
|
19
|
+
return;
|
|
20
|
+
console.error(`[cursorconnect] Версия ${current} устарела (нужна ≥ ${policy.minCliVersion}).\n` +
|
|
21
|
+
` ${policy.updateCliCommand}`);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
export async function ensureCliVersionForRelay(relayUrl) {
|
|
25
|
+
const policy = await fetchRemoteVersionPolicy(relayUrl);
|
|
26
|
+
if (!policy?.minCliVersion) {
|
|
27
|
+
console.warn('[cursorconnect] Не удалось проверить версию на relay — продолжаем без проверки.');
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
assertCliVersionAllowed(policy);
|
|
31
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cursorconnect",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "CLI:
|
|
3
|
+
"version": "0.1.5",
|
|
4
|
+
"description": "CLI: Cursor Connect on Mac + relay pairing — install once, run from anywhere",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
"dist/**/*.js",
|
|
12
12
|
"bridge-runtime/**",
|
|
13
|
+
"config.env.defaults",
|
|
14
|
+
"version-policy.json",
|
|
13
15
|
"README.md"
|
|
14
16
|
],
|
|
15
17
|
"scripts": {
|
|
@@ -29,7 +31,9 @@
|
|
|
29
31
|
"bridge",
|
|
30
32
|
"relay"
|
|
31
33
|
],
|
|
32
|
-
"dependencies": {
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"socket.io-client": "^4.8.0"
|
|
36
|
+
},
|
|
33
37
|
"devDependencies": {
|
|
34
38
|
"@types/node": "^22.0.0",
|
|
35
39
|
"tsx": "^4.19.0",
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"minCliVersion": "0.1.4",
|
|
3
|
+
"minAppVersion": "0.2.2",
|
|
4
|
+
"latestCliVersion": "0.1.4",
|
|
5
|
+
"latestAppVersion": "0.2.2",
|
|
6
|
+
"updateCliCommand": "npm install -g cursorconnect@latest",
|
|
7
|
+
"updateAppHint": "Обновите CursorConnect в App Store / TestFlight до последней сборки."
|
|
8
|
+
}
|