cursorconnect 0.1.10 → 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.
- package/bridge-runtime/connector-version.json +1 -1
- package/bridge-runtime/dist/agent-title-match.d.ts +4 -0
- package/bridge-runtime/dist/agent-title-match.js +61 -1
- package/bridge-runtime/dist/cdp-bridge.js +2 -1
- package/bridge-runtime/dist/chat-sync.js +3 -0
- package/bridge-runtime/dist/command-executor.d.ts +2 -0
- package/bridge-runtime/dist/command-executor.js +85 -56
- package/bridge-runtime/dist/composer-images.js +23 -6
- package/bridge-runtime/dist/cursor-window-kind.d.ts +10 -0
- package/bridge-runtime/dist/cursor-window-kind.js +10 -0
- package/bridge-runtime/dist/dom-extractor.d.ts +1 -1
- package/bridge-runtime/dist/dom-extractor.js +0 -1
- package/bridge-runtime/dist/editor-chat-list.d.ts +6 -0
- package/bridge-runtime/dist/editor-chat-list.js +79 -0
- package/bridge-runtime/dist/editor-list-sync.d.ts +3 -0
- package/bridge-runtime/dist/editor-list-sync.js +11 -0
- package/bridge-runtime/dist/editor-tab-focus-dom.d.ts +8 -0
- package/bridge-runtime/dist/editor-tab-focus-dom.js +80 -0
- package/bridge-runtime/dist/extract-page.d.ts +1 -1
- package/bridge-runtime/dist/extract-page.js +177 -30
- package/bridge-runtime/dist/generation-stop-dom.d.ts +5 -0
- package/bridge-runtime/dist/generation-stop-dom.js +67 -0
- package/bridge-runtime/dist/index.js +2 -0
- package/bridge-runtime/dist/queue-remove-dom.d.ts +11 -0
- package/bridge-runtime/dist/queue-remove-dom.js +88 -0
- package/bridge-runtime/dist/relay-upstream.js +2 -0
- package/bridge-runtime/dist/relay.js +35 -15
- package/bridge-runtime/dist/state-manager.d.ts +1 -1
- package/bridge-runtime/dist/types.d.ts +14 -0
- package/bridge-runtime/dist/window-monitor.js +6 -0
- package/bridge-runtime/selectors.json +8 -1
- package/dist/bridge-build.js +2 -1
- package/dist/bundled-bridge-check.js +2 -3
- package/dist/diagnose.js +26 -23
- package/dist/i18n.js +50 -0
- package/dist/index.js +31 -47
- package/dist/launch.js +9 -8
- package/dist/print-pairing.js +8 -7
- package/dist/run-service.js +5 -4
- package/dist/startup-check.js +32 -23
- package/dist/version-check.js +7 -3
- package/locales/en.json +128 -0
- package/locales/ru.json +128 -0
- package/package.json +2 -1
- package/version-policy.json +5 -5
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CdpClient } from './cdp-client.js';
|
|
2
|
+
import { windowKindFromTitle } from './cursor-window-kind.js';
|
|
2
3
|
import { extractPageState } from './extract-page.js';
|
|
3
4
|
/**
|
|
4
5
|
* Home window: continuous poll via main CDPBridge.
|
|
@@ -45,6 +46,8 @@ export class WindowMonitor {
|
|
|
45
46
|
messageCount: st.messages.length,
|
|
46
47
|
lastPreview: last?.text?.slice(0, 80),
|
|
47
48
|
agentStatus: st.agentStatus,
|
|
49
|
+
agentWorking: st.agentWorking,
|
|
50
|
+
tabs: st.tabs,
|
|
48
51
|
pendingApprovals: st.pendingApprovals?.length ?? 0,
|
|
49
52
|
updatedAt: Date.now(),
|
|
50
53
|
});
|
|
@@ -73,10 +76,13 @@ export class WindowMonitor {
|
|
|
73
76
|
return {
|
|
74
77
|
windowId,
|
|
75
78
|
title,
|
|
79
|
+
kind: windowKindFromTitle(title),
|
|
80
|
+
tabs: partial.tabs ?? [],
|
|
76
81
|
activeComposerId: partial.activeComposerId,
|
|
77
82
|
messageCount: partial.messages.length,
|
|
78
83
|
lastPreview: last?.text?.slice(0, 80),
|
|
79
84
|
agentStatus: partial.agentStatus,
|
|
85
|
+
agentWorking: partial.agentWorking,
|
|
80
86
|
pendingApprovals: partial.pendingApprovals?.length ?? 0,
|
|
81
87
|
updatedAt: Date.now(),
|
|
82
88
|
};
|
|
@@ -30,6 +30,11 @@
|
|
|
30
30
|
".glass-sidebar-agent-list-container li.ui-sidebar-menu-item > div.glass-sidebar-agent-menu-btn"
|
|
31
31
|
]
|
|
32
32
|
},
|
|
33
|
+
"editorAuxiliaryTabList": {
|
|
34
|
+
"strategies": [
|
|
35
|
+
"#workbench\\.parts\\.auxiliarybar div.tab[role=\"tab\"]"
|
|
36
|
+
]
|
|
37
|
+
},
|
|
33
38
|
"newChatButton": {
|
|
34
39
|
"strategies": [
|
|
35
40
|
"[data-command-id='composer.createNewComposerTab']",
|
|
@@ -67,7 +72,9 @@
|
|
|
67
72
|
"button.ui-prompt-input-submit-button[data-state=\"stop\"]",
|
|
68
73
|
"button[aria-label=\"Stop generation\"]",
|
|
69
74
|
"button.ui-prompt-input-submit-button[aria-label=\"Stop generation\"]",
|
|
70
|
-
"button[data-state=\"stop\"]"
|
|
75
|
+
"button[data-state=\"stop\"]",
|
|
76
|
+
".composer-button-area .anysphere-icon-button:has(.codicon-debug-stop)",
|
|
77
|
+
".send-with-mode .anysphere-icon-button:has(.codicon-debug-stop)"
|
|
71
78
|
]
|
|
72
79
|
}
|
|
73
80
|
}
|
package/dist/bridge-build.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { execSync } from 'child_process';
|
|
2
|
+
import { t } from './i18n.js';
|
|
2
3
|
import { existsSync, readdirSync, statSync } from 'fs';
|
|
3
4
|
import { join } from 'path';
|
|
4
5
|
function newestMtimeMs(dir) {
|
|
@@ -45,6 +46,6 @@ export function ensureBridgeBuilt(bridgeDir) {
|
|
|
45
46
|
return;
|
|
46
47
|
if (!isBridgeSrcNewerThanDist(bridgeDir))
|
|
47
48
|
return;
|
|
48
|
-
console.error('
|
|
49
|
+
console.error(t('bridge.rebuilding'));
|
|
49
50
|
buildBridge(bridgeDir);
|
|
50
51
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from 'fs';
|
|
2
2
|
import { join } from 'path';
|
|
3
3
|
import { resolveBridgeDir } from './bridge-dir.js';
|
|
4
|
+
import { t } from './i18n.js';
|
|
4
5
|
export function bundledBridgeHasClientVersion() {
|
|
5
6
|
let bridgeDir;
|
|
6
7
|
try {
|
|
@@ -18,8 +19,6 @@ export function bundledBridgeHasClientVersion() {
|
|
|
18
19
|
export function assertBundledBridgeSupportsRelay() {
|
|
19
20
|
if (bundledBridgeHasClientVersion())
|
|
20
21
|
return;
|
|
21
|
-
console.error('
|
|
22
|
-
' npm install -g cursorconnect@latest\n' +
|
|
23
|
-
' Если уже latest — дождитесь публикации fix или запускайте из клона: npm run bundle-bridge -w connect');
|
|
22
|
+
console.error(t('bridge.staleBundle'));
|
|
24
23
|
process.exit(1);
|
|
25
24
|
}
|
package/dist/diagnose.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { io } from 'socket.io-client';
|
|
2
2
|
import { resolveRelayConfig, DEFAULT_RELAY_URL } from './relay-config.js';
|
|
3
3
|
import { loadPairingIdentity } from './pairing-identity.js';
|
|
4
|
+
import { t } from './i18n.js';
|
|
4
5
|
function loadRelayUrl() {
|
|
5
6
|
return resolveRelayConfig().relayUrl || DEFAULT_RELAY_URL;
|
|
6
7
|
}
|
|
@@ -79,8 +80,8 @@ export async function runDiagnose() {
|
|
|
79
80
|
{
|
|
80
81
|
id: 'identity',
|
|
81
82
|
ok: false,
|
|
82
|
-
detail: '
|
|
83
|
-
hint: '
|
|
83
|
+
detail: t('diagnose.noIdentity'),
|
|
84
|
+
hint: t('diagnose.hintStart'),
|
|
84
85
|
},
|
|
85
86
|
],
|
|
86
87
|
};
|
|
@@ -95,7 +96,7 @@ export async function runDiagnose() {
|
|
|
95
96
|
id: 'relay.health',
|
|
96
97
|
ok: Boolean(j.ok),
|
|
97
98
|
detail: `ok=${j.ok} connector=${j.connector} peers=${JSON.stringify(j.peers)}`,
|
|
98
|
-
hint: j.connector ? undefined : '
|
|
99
|
+
hint: j.connector ? undefined : t('diagnose.hintStartMac'),
|
|
99
100
|
});
|
|
100
101
|
}
|
|
101
102
|
catch (e) {
|
|
@@ -103,7 +104,7 @@ export async function runDiagnose() {
|
|
|
103
104
|
id: 'relay.health',
|
|
104
105
|
ok: false,
|
|
105
106
|
detail: e.message,
|
|
106
|
-
hint: '
|
|
107
|
+
hint: t('diagnose.hintRelayUrl'),
|
|
107
108
|
});
|
|
108
109
|
}
|
|
109
110
|
// 2 Room diagnostics API
|
|
@@ -117,11 +118,11 @@ export async function runDiagnose() {
|
|
|
117
118
|
ok: ok && Boolean(j.connectorInRoom) && Boolean(j.tokenRegistered),
|
|
118
119
|
detail: JSON.stringify(j),
|
|
119
120
|
hint: !j.connectorInRoom
|
|
120
|
-
? '
|
|
121
|
+
? t('diagnose.notInRoom')
|
|
121
122
|
: !j.tokenRegistered
|
|
122
|
-
? '
|
|
123
|
+
? t('diagnose.tokenNotRegistered')
|
|
123
124
|
: !j.tokenAccepted
|
|
124
|
-
? '
|
|
125
|
+
? t('diagnose.tokenNotWhitelisted')
|
|
125
126
|
: undefined,
|
|
126
127
|
});
|
|
127
128
|
}
|
|
@@ -130,7 +131,7 @@ export async function runDiagnose() {
|
|
|
130
131
|
id: 'relay.room',
|
|
131
132
|
ok: false,
|
|
132
133
|
detail: e.message,
|
|
133
|
-
hint: '
|
|
134
|
+
hint: t('diagnose.hintDeployRelay'),
|
|
134
135
|
});
|
|
135
136
|
}
|
|
136
137
|
// 3 Local bridge
|
|
@@ -141,7 +142,7 @@ export async function runDiagnose() {
|
|
|
141
142
|
id: 'cursor-connect.local',
|
|
142
143
|
ok: Boolean(j.ok),
|
|
143
144
|
detail: `ok=${j.ok} cdp=${j.cdp}`,
|
|
144
|
-
hint: j.cdp ? undefined : '
|
|
145
|
+
hint: j.cdp ? undefined : t('diagnose.hintCdp9222'),
|
|
145
146
|
});
|
|
146
147
|
}
|
|
147
148
|
catch (e) {
|
|
@@ -149,7 +150,7 @@ export async function runDiagnose() {
|
|
|
149
150
|
id: 'cursor-connect.local',
|
|
150
151
|
ok: false,
|
|
151
152
|
detail: e.message,
|
|
152
|
-
hint: '
|
|
153
|
+
hint: t('diagnose.hintStart'),
|
|
153
154
|
});
|
|
154
155
|
}
|
|
155
156
|
// 4 Pairing code (не вызываем POST /api/pair — код одноразовый)
|
|
@@ -161,15 +162,15 @@ export async function runDiagnose() {
|
|
|
161
162
|
id: 'pair.code',
|
|
162
163
|
ok: true,
|
|
163
164
|
detail: `active ${code} (~${secLeft}s)`,
|
|
164
|
-
hint: '
|
|
165
|
+
hint: t('diagnose.hintEnterInApp'),
|
|
165
166
|
});
|
|
166
167
|
}
|
|
167
168
|
else {
|
|
168
169
|
checks.push({
|
|
169
170
|
id: 'pair.code',
|
|
170
171
|
ok: false,
|
|
171
|
-
detail: '
|
|
172
|
-
hint: '
|
|
172
|
+
detail: t('diagnose.codeExpired'),
|
|
173
|
+
hint: t('diagnose.hintStart'),
|
|
173
174
|
});
|
|
174
175
|
}
|
|
175
176
|
const auth = { token, roomId };
|
|
@@ -178,14 +179,14 @@ export async function runDiagnose() {
|
|
|
178
179
|
id: 'socket.ws+room',
|
|
179
180
|
ok: ws.ok,
|
|
180
181
|
detail: ws.detail,
|
|
181
|
-
hint: ws.ok ? undefined : '
|
|
182
|
+
hint: ws.ok ? undefined : t('diagnose.hintAppTransports'),
|
|
182
183
|
});
|
|
183
184
|
const poll = await socketProbe(relayUrl, auth, ['polling'], true);
|
|
184
185
|
checks.push({
|
|
185
186
|
id: 'socket.poll+room',
|
|
186
187
|
ok: poll.ok,
|
|
187
188
|
detail: poll.detail,
|
|
188
|
-
hint: poll.ok ? undefined : '
|
|
189
|
+
hint: poll.ok ? undefined : t('diagnose.hintPollingBlocked'),
|
|
189
190
|
});
|
|
190
191
|
const wrongRoom = await socketProbe(relayUrl, { token, roomId: 'default' }, ['websocket', 'polling'], true);
|
|
191
192
|
checks.push({
|
|
@@ -193,7 +194,7 @@ export async function runDiagnose() {
|
|
|
193
194
|
ok: !wrongRoom.ok,
|
|
194
195
|
detail: wrongRoom.detail,
|
|
195
196
|
hint: wrongRoom.ok
|
|
196
|
-
? '
|
|
197
|
+
? t('diagnose.wrongRoom')
|
|
197
198
|
: undefined,
|
|
198
199
|
});
|
|
199
200
|
const history = await historyProbe(relayUrl, auth, 'sidebar-0', 'Git repository creation and project deployment');
|
|
@@ -201,24 +202,26 @@ export async function runDiagnose() {
|
|
|
201
202
|
id: 'socket.history',
|
|
202
203
|
ok: history.ok,
|
|
203
204
|
detail: history.detail,
|
|
204
|
-
hint: history.ok ? undefined : '
|
|
205
|
+
hint: history.ok ? undefined : t('diagnose.hintHistory'),
|
|
205
206
|
});
|
|
206
207
|
return { at: new Date().toISOString(), relayUrl, roomId, checks };
|
|
207
208
|
}
|
|
208
209
|
export function formatDiagnoseReport(report) {
|
|
209
210
|
const lines = [
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
211
|
+
t('diagnose.header', { at: report.at }),
|
|
212
|
+
t('diagnose.relay', { url: report.relayUrl }),
|
|
213
|
+
t('diagnose.room', { id: report.roomId }),
|
|
213
214
|
'',
|
|
214
215
|
];
|
|
215
216
|
for (const c of report.checks) {
|
|
216
|
-
lines.push(`${c.ok ? '
|
|
217
|
+
lines.push(`${c.ok ? t('diagnose.pass') : t('diagnose.fail')} ${c.id}`);
|
|
217
218
|
lines.push(` ${c.detail}`);
|
|
218
219
|
if (c.hint)
|
|
219
|
-
lines.push(
|
|
220
|
+
lines.push(`${t('diagnose.hintPrefix')}${c.hint}`);
|
|
220
221
|
}
|
|
221
222
|
const failed = report.checks.filter((c) => !c.ok).length;
|
|
222
|
-
lines.push('', failed === 0
|
|
223
|
+
lines.push('', failed === 0
|
|
224
|
+
? t('diagnose.allPass')
|
|
225
|
+
: t('diagnose.problems', { count: failed }));
|
|
223
226
|
return lines.join('\n');
|
|
224
227
|
}
|
package/dist/i18n.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'fs';
|
|
2
|
+
import { dirname, join } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
const pkgRoot = join(dirname(fileURLToPath(import.meta.url)), '..');
|
|
5
|
+
function loadDict(locale) {
|
|
6
|
+
const path = join(pkgRoot, 'locales', `${locale}.json`);
|
|
7
|
+
if (!existsSync(path))
|
|
8
|
+
return {};
|
|
9
|
+
return JSON.parse(readFileSync(path, 'utf-8'));
|
|
10
|
+
}
|
|
11
|
+
function resolveLocale() {
|
|
12
|
+
const forced = process.env.CURSORCONNECT_LANG?.trim().toLowerCase();
|
|
13
|
+
if (forced === 'ru' || forced === 'en')
|
|
14
|
+
return forced;
|
|
15
|
+
const lang = (process.env.LANG ?? process.env.LC_ALL ?? 'en').toLowerCase();
|
|
16
|
+
if (lang.startsWith('ru'))
|
|
17
|
+
return 'ru';
|
|
18
|
+
return 'en';
|
|
19
|
+
}
|
|
20
|
+
const en = loadDict('en');
|
|
21
|
+
const ru = loadDict('ru');
|
|
22
|
+
let locale = resolveLocale();
|
|
23
|
+
export function getCliLocale() {
|
|
24
|
+
return locale;
|
|
25
|
+
}
|
|
26
|
+
export function setCliLocale(next) {
|
|
27
|
+
locale = next;
|
|
28
|
+
}
|
|
29
|
+
function lookup(dict, key) {
|
|
30
|
+
const parts = key.split('.');
|
|
31
|
+
let cur = dict;
|
|
32
|
+
for (const p of parts) {
|
|
33
|
+
if (cur == null || typeof cur !== 'object')
|
|
34
|
+
return undefined;
|
|
35
|
+
cur = cur[p];
|
|
36
|
+
}
|
|
37
|
+
return typeof cur === 'string' ? cur : undefined;
|
|
38
|
+
}
|
|
39
|
+
/** English first; Russian from device or CURSORCONNECT_LANG=ru */
|
|
40
|
+
export function t(key, params) {
|
|
41
|
+
const primary = locale === 'en' ? en : ru;
|
|
42
|
+
const fallback = locale === 'en' ? ru : en;
|
|
43
|
+
let out = lookup(primary, key) ?? lookup(fallback, key) ?? key;
|
|
44
|
+
if (params) {
|
|
45
|
+
for (const [k, v] of Object.entries(params)) {
|
|
46
|
+
out = out.replaceAll(`{{${k}}}`, String(v));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -15,14 +15,13 @@ import { CLI_VERSION } from './cli-version.js';
|
|
|
15
15
|
import { askYesNo } from './ask.js';
|
|
16
16
|
import { installCursorCdpLauncher, installMacAutostart, isAutostartInstalled, uninstallMacAutostart, } from './macos-autostart.js';
|
|
17
17
|
import { runServiceLoop } from './run-service.js';
|
|
18
|
+
import { t } from './i18n.js';
|
|
18
19
|
function bridgeEnv(identity) {
|
|
19
20
|
ensureUserConfig();
|
|
20
21
|
const bridgeDotEnv = join(resolveBridgeDir(), '.env');
|
|
21
22
|
const { relayUrl, relayToken } = resolveRelayConfig([bridgeDotEnv]);
|
|
22
23
|
if (!relayToken) {
|
|
23
|
-
console.error('
|
|
24
|
-
` Переустановите: npm install -g cursorconnect\n` +
|
|
25
|
-
` Или укажите RELAY_TOKEN в ${USER_CONFIG_ENV} (свой relay).`);
|
|
24
|
+
console.error(t('start.relayTokenMissing', { path: USER_CONFIG_ENV }));
|
|
26
25
|
process.exit(1);
|
|
27
26
|
}
|
|
28
27
|
const file = {
|
|
@@ -61,15 +60,15 @@ async function cmdStart(argv) {
|
|
|
61
60
|
});
|
|
62
61
|
if (!cdpPortOk) {
|
|
63
62
|
console.error('');
|
|
64
|
-
console.error('
|
|
65
|
-
console.error(
|
|
63
|
+
console.error(t('start.cdpRequired'));
|
|
64
|
+
console.error(t('start.cdpThenRetry'));
|
|
66
65
|
console.error(' cursorconnect start');
|
|
67
66
|
console.error('');
|
|
68
67
|
printManualCdpInstructions();
|
|
69
68
|
process.exit(1);
|
|
70
69
|
}
|
|
71
70
|
if (isBridgeRunning()) {
|
|
72
|
-
console.error('
|
|
71
|
+
console.error(t('start.restartingBridge'));
|
|
73
72
|
stopBridge();
|
|
74
73
|
}
|
|
75
74
|
startBridge(env);
|
|
@@ -82,23 +81,23 @@ async function cmdStart(argv) {
|
|
|
82
81
|
process.exit(1);
|
|
83
82
|
}
|
|
84
83
|
console.log('');
|
|
85
|
-
console.log(
|
|
84
|
+
console.log(` ${t('start.checksBeforePairing')}`);
|
|
86
85
|
for (const line of formatStartupChecklist(readiness)) {
|
|
87
86
|
console.log(` ${line}`);
|
|
88
87
|
}
|
|
89
88
|
console.log('');
|
|
90
89
|
printPairingToTerminal(refreshed);
|
|
91
90
|
if (process.stdin.isTTY && !isAutostartInstalled()) {
|
|
92
|
-
const yes = await askYesNo(
|
|
91
|
+
const yes = await askYesNo(t('start.askAutostart'));
|
|
93
92
|
if (yes) {
|
|
94
93
|
installMacAutostart();
|
|
95
94
|
const cdp = installCursorCdpLauncher();
|
|
96
95
|
console.log('');
|
|
97
|
-
console.log(
|
|
98
|
-
console.log(
|
|
96
|
+
console.log(` ${t('start.autostartEnabled')}`);
|
|
97
|
+
console.log(` ${t('start.openCursorFromDock')}`);
|
|
99
98
|
console.log(` ${cdp}`);
|
|
100
|
-
console.log(
|
|
101
|
-
console.log(
|
|
99
|
+
console.log(` ${t('start.dockHint')}`);
|
|
100
|
+
console.log(` ${t('start.pairingCodeViaStatus')}`);
|
|
102
101
|
}
|
|
103
102
|
}
|
|
104
103
|
}
|
|
@@ -108,37 +107,35 @@ async function cmdRunService() {
|
|
|
108
107
|
refreshPairingCode(identity);
|
|
109
108
|
const env = bridgeEnv(identity);
|
|
110
109
|
await ensureCliVersionForRelay(env.RELAY_URL);
|
|
111
|
-
console.log('
|
|
110
|
+
console.log(t('service.starting'));
|
|
112
111
|
await runServiceLoop(env);
|
|
113
112
|
}
|
|
114
113
|
async function cmdInstallAutostart() {
|
|
115
114
|
installMacAutostart();
|
|
116
115
|
const cdp = installCursorCdpLauncher();
|
|
117
|
-
console.log('
|
|
118
|
-
console.log(
|
|
119
|
-
console.log('
|
|
116
|
+
console.log(t('autostart.enabled'));
|
|
117
|
+
console.log(t('autostart.cursorCdpPath', { path: cdp }));
|
|
118
|
+
console.log(t('autostart.codeViaStatus'));
|
|
120
119
|
}
|
|
121
120
|
async function cmdUninstallAutostart() {
|
|
122
121
|
uninstallMacAutostart();
|
|
123
|
-
console.log('
|
|
122
|
+
console.log(t('autostart.disabled'));
|
|
124
123
|
}
|
|
125
124
|
async function cmdStop() {
|
|
126
125
|
stopBridge();
|
|
127
|
-
console.log('
|
|
126
|
+
console.log(t('stop.stopped'));
|
|
128
127
|
}
|
|
129
128
|
async function cmdInit(pathArg) {
|
|
130
129
|
const target = pathArg?.trim() || process.cwd();
|
|
131
130
|
const abs = resolve(target);
|
|
132
131
|
if (!isValidBridgeDir(join(abs, 'bridge'))) {
|
|
133
|
-
console.error(
|
|
134
|
-
'Нужен клон репозитория (bridge/).\n' +
|
|
135
|
-
'После npm install -g cursorconnect команда init не нужна.');
|
|
132
|
+
console.error(t('init.notRepo', { path: abs }));
|
|
136
133
|
process.exit(1);
|
|
137
134
|
}
|
|
138
135
|
saveInstallConfig(abs);
|
|
139
|
-
console.log(
|
|
140
|
-
console.log(
|
|
141
|
-
console.log(
|
|
136
|
+
console.log(t('init.saved', { path: configFilePath() }));
|
|
137
|
+
console.log(t('init.repoRoot', { path: abs }));
|
|
138
|
+
console.log(`\n${t('init.next')}`);
|
|
142
139
|
}
|
|
143
140
|
async function cmdDiagnose() {
|
|
144
141
|
const report = await runDiagnose();
|
|
@@ -150,25 +147,27 @@ async function cmdStatus() {
|
|
|
150
147
|
const identity = loadPairingIdentity();
|
|
151
148
|
ensureUserConfig();
|
|
152
149
|
if (!identity) {
|
|
153
|
-
console.error('
|
|
150
|
+
console.error(t('status.noIdentity'));
|
|
154
151
|
process.exit(1);
|
|
155
152
|
}
|
|
156
|
-
console.log(
|
|
153
|
+
console.log(t('status.cliVersion', { version: CLI_VERSION }));
|
|
157
154
|
console.log(bundledBridgeHasClientVersion()
|
|
158
|
-
? '
|
|
159
|
-
: '
|
|
160
|
-
console.log(
|
|
155
|
+
? t('status.bundleOk')
|
|
156
|
+
: t('status.bundleStale'));
|
|
157
|
+
console.log(t('status.bridgeProcess', {
|
|
158
|
+
state: isBridgeRunning() ? t('status.bridgeRunning') : t('status.bridgeStopped'),
|
|
159
|
+
}));
|
|
161
160
|
const { relayUrl: relayUrlRaw } = resolveRelayConfig([USER_CONFIG_ENV]);
|
|
162
161
|
const relayUrl = (relayUrlRaw || DEFAULT_RELAY_URL).replace(/\/$/, '');
|
|
163
162
|
const readiness = await snapshotStartupReadiness(relayUrl, identity);
|
|
164
163
|
console.log('');
|
|
165
|
-
console.log(
|
|
164
|
+
console.log(` ${t('status.stateHeader')}`);
|
|
166
165
|
for (const line of formatStartupChecklist(readiness)) {
|
|
167
166
|
console.log(` ${line}`);
|
|
168
167
|
}
|
|
169
168
|
if (!readiness.ready) {
|
|
170
169
|
console.log('');
|
|
171
|
-
console.warn('
|
|
170
|
+
console.warn(t('status.codeMayFail'));
|
|
172
171
|
}
|
|
173
172
|
console.log('');
|
|
174
173
|
printPairingToTerminal(identity);
|
|
@@ -203,22 +202,7 @@ async function main() {
|
|
|
203
202
|
await cmdUninstallAutostart();
|
|
204
203
|
break;
|
|
205
204
|
default:
|
|
206
|
-
console.log(
|
|
207
|
-
|
|
208
|
-
start — CDP (авто-перезапуск Cursor) + Cursor Connect + код
|
|
209
|
-
start -r — то же (явный перезапуск Cursor)
|
|
210
|
-
start --no-restart-cursor — не трогать Cursor (спросит y/n в TTY)
|
|
211
|
-
stop — остановить Cursor Connect
|
|
212
|
-
status — код и статус
|
|
213
|
-
install-autostart — Mac: Cursor Connect при входе (launchd)
|
|
214
|
-
uninstall-autostart — отключить автозапуск
|
|
215
|
-
diagnose — проверка relay / Cursor Connect / socket (без гаданий)
|
|
216
|
-
init [path] — только для разработки (клон репо)
|
|
217
|
-
|
|
218
|
-
Установка (из любой папки):
|
|
219
|
-
npm install -g cursorconnect
|
|
220
|
-
cursorconnect start # первый раз: код + опционально автозапуск
|
|
221
|
-
cursorconnect install-autostart # без консоли каждый день`);
|
|
205
|
+
console.log(t('usage.body'));
|
|
222
206
|
process.exit(cmd === 'help' ? 0 : 1);
|
|
223
207
|
}
|
|
224
208
|
}
|
package/dist/launch.js
CHANGED
|
@@ -4,6 +4,7 @@ import { closeSync, existsSync, openSync, readFileSync, writeFileSync } from 'fs
|
|
|
4
4
|
import { BRIDGE_LOG_FILE, BRIDGE_PID_FILE } from './paths.js';
|
|
5
5
|
import { resolveBridgeDir } from './bridge-dir.js';
|
|
6
6
|
import { ensureBridgeBuilt } from './bridge-build.js';
|
|
7
|
+
import { t } from './i18n.js';
|
|
7
8
|
export function isBridgeRunning() {
|
|
8
9
|
if (!existsSync(BRIDGE_PID_FILE))
|
|
9
10
|
return false;
|
|
@@ -185,7 +186,7 @@ export function isCursorRunning() {
|
|
|
185
186
|
export async function quitCursor(maxWaitMs = 20_000) {
|
|
186
187
|
if (!isCursorRunning())
|
|
187
188
|
return true;
|
|
188
|
-
console.log('
|
|
189
|
+
console.log(t('cdp.quitCursor'));
|
|
189
190
|
spawnSync('osascript', ['-e', 'tell application "Cursor" to quit'], {
|
|
190
191
|
stdio: 'ignore',
|
|
191
192
|
});
|
|
@@ -195,7 +196,7 @@ export async function quitCursor(maxWaitMs = 20_000) {
|
|
|
195
196
|
if (!isCursorRunning())
|
|
196
197
|
return true;
|
|
197
198
|
}
|
|
198
|
-
console.log('
|
|
199
|
+
console.log(t('cdp.forceQuitCursor'));
|
|
199
200
|
try {
|
|
200
201
|
spawnSync('killall', ['Cursor'], { stdio: 'ignore' });
|
|
201
202
|
}
|
|
@@ -207,9 +208,9 @@ export async function quitCursor(maxWaitMs = 20_000) {
|
|
|
207
208
|
}
|
|
208
209
|
const CDP_LAUNCH_CMD = 'open -a Cursor --args --remote-debugging-port=9222';
|
|
209
210
|
export function printManualCdpInstructions() {
|
|
210
|
-
console.log(
|
|
211
|
+
console.log(`\n${t('cdp.manualTitle')}`);
|
|
211
212
|
console.log(` ${CDP_LAUNCH_CMD}`);
|
|
212
|
-
console.log(
|
|
213
|
+
console.log(` ${t('cdp.manualQuitFirst')}\n`);
|
|
213
214
|
}
|
|
214
215
|
export function launchCursorWithCdp() {
|
|
215
216
|
spawn('open', ['-a', 'Cursor', '--args', '--remote-debugging-port=9222'], {
|
|
@@ -232,7 +233,7 @@ export async function ensureCursorCdp(opts = {}) {
|
|
|
232
233
|
}
|
|
233
234
|
const running = isCursorRunning();
|
|
234
235
|
if (!running) {
|
|
235
|
-
console.log('
|
|
236
|
+
console.log(t('cdp.notRunningLaunch'));
|
|
236
237
|
launchCursorWithCdp();
|
|
237
238
|
if (await waitCdp(cdpUrl, 50))
|
|
238
239
|
return true;
|
|
@@ -244,17 +245,17 @@ export async function ensureCursorCdp(opts = {}) {
|
|
|
244
245
|
if (!shouldRestart) {
|
|
245
246
|
shouldRestart = Boolean(opts.restartCursor);
|
|
246
247
|
if (!shouldRestart && process.stdin.isTTY) {
|
|
247
|
-
shouldRestart = await askYesNo('
|
|
248
|
+
shouldRestart = await askYesNo(t('cdp.askRestart'));
|
|
248
249
|
}
|
|
249
250
|
}
|
|
250
251
|
if (!shouldRestart) {
|
|
251
252
|
printManualCdpInstructions();
|
|
252
253
|
return false;
|
|
253
254
|
}
|
|
254
|
-
console.log('
|
|
255
|
+
console.log(t('cdp.restartingWithCdp'));
|
|
255
256
|
const quitOk = await quitCursor();
|
|
256
257
|
if (!quitOk) {
|
|
257
|
-
console.warn('
|
|
258
|
+
console.warn(t('cdp.quitFailed'));
|
|
258
259
|
printManualCdpInstructions();
|
|
259
260
|
return false;
|
|
260
261
|
}
|
package/dist/print-pairing.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { renderBigCode } from './big-code.js';
|
|
2
|
+
import { t } from './i18n.js';
|
|
2
3
|
import { PAIRING_CODE_TTL_MINUTES } from './pairing-ttl.js';
|
|
3
4
|
/** Pairing code: plain ASCII (A–Z, 0–9) for app input. */
|
|
4
5
|
function pairingCodeAscii(code) {
|
|
@@ -6,23 +7,23 @@ function pairingCodeAscii(code) {
|
|
|
6
7
|
}
|
|
7
8
|
export function printPairingToTerminal(identity) {
|
|
8
9
|
const code = pairingCodeAscii(identity.pairingCode);
|
|
9
|
-
console.log('
|
|
10
|
+
console.log(t('pairing.runningInBackground'));
|
|
10
11
|
console.log('');
|
|
11
12
|
console.log('────────────────────────────────────────');
|
|
12
13
|
console.log('');
|
|
13
|
-
console.log(
|
|
14
|
+
console.log(t('pairing.computer', { name: identity.machineLabel }));
|
|
14
15
|
console.log('');
|
|
15
|
-
console.log('
|
|
16
|
+
console.log(t('pairing.enterCodeInApp'));
|
|
16
17
|
console.log('');
|
|
17
18
|
console.log(` ${code}`);
|
|
18
19
|
console.log('');
|
|
19
20
|
console.log(renderBigCode(code));
|
|
20
21
|
console.log('');
|
|
21
|
-
console.log('
|
|
22
|
-
console.log(
|
|
22
|
+
console.log(t('pairing.codeSingleUse'));
|
|
23
|
+
console.log(t('pairing.codeValidMinutes', { minutes: PAIRING_CODE_TTL_MINUTES }));
|
|
23
24
|
console.log('');
|
|
24
25
|
console.log('────────────────────────────────────────');
|
|
25
|
-
console.log(
|
|
26
|
-
console.log(
|
|
26
|
+
console.log(` ${t('pairing.stopHint')}`);
|
|
27
|
+
console.log(` ${t('pairing.consoleCanClose')}`);
|
|
27
28
|
console.log('');
|
|
28
29
|
}
|
package/dist/run-service.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ensurePairingIdentity, refreshPairingCode, } from './pairing-identity.js';
|
|
2
2
|
import { ensureCursorCdp, isBridgeRunning, startBridge, } from './launch.js';
|
|
3
3
|
import { BRIDGE_LOG_FILE } from './paths.js';
|
|
4
|
+
import { t } from './i18n.js';
|
|
4
5
|
const WATCH_MS = 8_000;
|
|
5
6
|
function sleep(ms) {
|
|
6
7
|
return new Promise((r) => setTimeout(r, ms));
|
|
@@ -15,22 +16,22 @@ export async function runServiceLoop(bridgeEnv) {
|
|
|
15
16
|
const cdpUrl = bridgeEnv.CDP_URL ?? 'http://127.0.0.1:9222';
|
|
16
17
|
const cdpOk = await ensureCursorCdp({ cdpUrl, noRestartCursor: false });
|
|
17
18
|
if (!cdpOk) {
|
|
18
|
-
console.error('
|
|
19
|
+
console.error(t('service.cdpUnavailable'));
|
|
19
20
|
return;
|
|
20
21
|
}
|
|
21
22
|
try {
|
|
22
23
|
startBridge(bridgeEnv);
|
|
23
|
-
console.log(
|
|
24
|
+
console.log(t('service.bridgeStarted', { log: BRIDGE_LOG_FILE }));
|
|
24
25
|
}
|
|
25
26
|
catch (e) {
|
|
26
|
-
console.error('
|
|
27
|
+
console.error(t('service.startFailed'), e);
|
|
27
28
|
}
|
|
28
29
|
};
|
|
29
30
|
await boot();
|
|
30
31
|
for (;;) {
|
|
31
32
|
await sleep(WATCH_MS);
|
|
32
33
|
if (!isBridgeRunning()) {
|
|
33
|
-
console.error('
|
|
34
|
+
console.error(t('service.exitedRestarting'));
|
|
34
35
|
await boot();
|
|
35
36
|
}
|
|
36
37
|
}
|