@cursorpool-dev/cli 0.5.6
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/bin/cursor-pool.mjs +9 -0
- package/bin/cursor-pool.ts +169 -0
- package/node_modules/@cursor-pool/extension/dist/extension.js +2910 -0
- package/node_modules/@cursor-pool/extension/package.json +64 -0
- package/node_modules/@cursor-pool/extension/resources/cursor-pool.svg +6 -0
- package/node_modules/@cursor-pool/extension/src/api.ts +545 -0
- package/node_modules/@cursor-pool/extension/src/extension.ts +104 -0
- package/node_modules/@cursor-pool/extension/src/index.ts +1 -0
- package/node_modules/@cursor-pool/extension/src/panel.ts +569 -0
- package/node_modules/@cursor-pool/extension/src/runtime.ts +22 -0
- package/node_modules/@cursor-pool/extension/test/panel.test.ts +1785 -0
- package/node_modules/@cursor-pool/patcher/package.json +17 -0
- package/node_modules/@cursor-pool/patcher/src/alwaysLocalMarker.ts +86 -0
- package/node_modules/@cursor-pool/patcher/src/hash.ts +7 -0
- package/node_modules/@cursor-pool/patcher/src/index.ts +55 -0
- package/node_modules/@cursor-pool/patcher/src/marker.ts +159 -0
- package/node_modules/@cursor-pool/patcher/src/patchCursorAgentExec.ts +154 -0
- package/node_modules/@cursor-pool/patcher/src/patchCursorAlwaysLocal.ts +142 -0
- package/node_modules/@cursor-pool/patcher/src/patchCursorWorkbenchAuthGate.ts +140 -0
- package/node_modules/@cursor-pool/patcher/src/restoreCursorAgentExec.ts +52 -0
- package/node_modules/@cursor-pool/patcher/src/restoreCursorAlwaysLocal.ts +52 -0
- package/node_modules/@cursor-pool/patcher/src/restoreCursorWorkbenchAuthGate.ts +70 -0
- package/node_modules/@cursor-pool/patcher/src/workbenchAuthGateMarker.ts +243 -0
- package/node_modules/@cursor-pool/patcher/test/patchCursorAgentExec.test.ts +630 -0
- package/node_modules/@cursor-pool/patcher/test/patchCursorAlwaysLocal.test.ts +144 -0
- package/node_modules/@cursor-pool/patcher/test/patchCursorWorkbench.test.ts +770 -0
- package/node_modules/@cursor-pool/patcher/test/restoreCursorAgentExec.test.ts +139 -0
- package/node_modules/@cursor-pool/service/package.json +17 -0
- package/node_modules/@cursor-pool/service/src/canary.ts +61 -0
- package/node_modules/@cursor-pool/service/src/diagnostics.ts +385 -0
- package/node_modules/@cursor-pool/service/src/entry.ts +161 -0
- package/node_modules/@cursor-pool/service/src/health.ts +10 -0
- package/node_modules/@cursor-pool/service/src/index.ts +29 -0
- package/node_modules/@cursor-pool/service/src/metadata.ts +22 -0
- package/node_modules/@cursor-pool/service/src/platformSession.ts +1178 -0
- package/node_modules/@cursor-pool/service/src/requestCheck.ts +81 -0
- package/node_modules/@cursor-pool/service/src/requestGate.ts +100 -0
- package/node_modules/@cursor-pool/service/src/requestGateway.ts +441 -0
- package/node_modules/@cursor-pool/service/src/runtime.ts +48 -0
- package/node_modules/@cursor-pool/service/src/server.ts +939 -0
- package/node_modules/@cursor-pool/service/src/takeover.ts +111 -0
- package/node_modules/@cursor-pool/service/test/canary.test.ts +140 -0
- package/node_modules/@cursor-pool/service/test/diagnostics.test.ts +506 -0
- package/node_modules/@cursor-pool/service/test/metadata.test.ts +63 -0
- package/node_modules/@cursor-pool/service/test/platformSession.test.ts +2428 -0
- package/node_modules/@cursor-pool/service/test/requestCheck.test.ts +152 -0
- package/node_modules/@cursor-pool/service/test/requestGate.test.ts +207 -0
- package/node_modules/@cursor-pool/service/test/requestGateway.test.ts +466 -0
- package/node_modules/@cursor-pool/service/test/runtime.test.ts +47 -0
- package/node_modules/@cursor-pool/service/test/server.test.ts +2570 -0
- package/node_modules/@cursor-pool/shared/package.json +17 -0
- package/node_modules/@cursor-pool/shared/src/clientConfig.ts +49 -0
- package/node_modules/@cursor-pool/shared/src/index.ts +14 -0
- package/node_modules/@cursor-pool/shared/src/manifest.ts +36 -0
- package/node_modules/@cursor-pool/shared/src/metadata.ts +19 -0
- package/node_modules/@cursor-pool/shared/src/paths.ts +5 -0
- package/node_modules/@cursor-pool/shared/src/runtime.ts +3 -0
- package/node_modules/@cursor-pool/shared/test/index.test.ts +56 -0
- package/node_modules/@cursor-pool/shared/test/manifest.test.ts +65 -0
- package/node_modules/@cursor-pool/shared/test/metadata.test.ts +25 -0
- package/node_modules/@cursor-pool/shared/test/runtime.test.ts +8 -0
- package/package.json +28 -0
- package/src/adHocResign.ts +65 -0
- package/src/autostart.ts +240 -0
- package/src/compat.ts +282 -0
- package/src/confirm.ts +76 -0
- package/src/cursor.ts +94 -0
- package/src/diagnostics.ts +558 -0
- package/src/environment.ts +18 -0
- package/src/extensionBundle.ts +111 -0
- package/src/extensionLink.ts +168 -0
- package/src/index.ts +23 -0
- package/src/install.ts +614 -0
- package/src/installRecord.ts +105 -0
- package/src/launch.ts +182 -0
- package/src/patchSet.ts +182 -0
- package/src/platform.ts +132 -0
- package/src/repair.ts +383 -0
- package/src/restore.ts +153 -0
- package/src/serviceCommands.ts +79 -0
- package/src/serviceProcess.ts +188 -0
- package/src/status.ts +241 -0
- package/src/target.ts +37 -0
- package/src/trial.ts +133 -0
- package/src/uninstall.ts +213 -0
- package/test/autostart.test.ts +151 -0
- package/test/compat.test.ts +192 -0
- package/test/confirm.test.ts +114 -0
- package/test/cursor-pool-bin.test.ts +658 -0
- package/test/cursor.test.ts +20 -0
- package/test/diagnostics.test.ts +709 -0
- package/test/e2e-install.test.ts +773 -0
- package/test/extensionBundle.test.ts +161 -0
- package/test/extensionLink.test.ts +209 -0
- package/test/install.test.ts +862 -0
- package/test/installRecord.test.ts +107 -0
- package/test/launch.test.ts +138 -0
- package/test/platform.test.ts +226 -0
- package/test/repair.test.ts +575 -0
- package/test/restore.test.ts +211 -0
- package/test/serviceCommands.test.ts +135 -0
- package/test/serviceProcess.test.ts +280 -0
- package/test/status.test.ts +615 -0
- package/test/target.test.ts +49 -0
- package/test/trial.test.ts +146 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
import { realpathSync } from 'node:fs';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { resolve } from 'node:path';
|
|
5
|
+
import { install } from '../src/install';
|
|
6
|
+
import { repair } from '../src/repair';
|
|
7
|
+
import { restore } from '../src/restore';
|
|
8
|
+
import { status } from '../src/status';
|
|
9
|
+
import { uninstall } from '../src/uninstall';
|
|
10
|
+
import { clearDiagnostics, diagnostics } from '../src/diagnostics';
|
|
11
|
+
import { launchCommand, launchStatus } from '../src/launch';
|
|
12
|
+
import { heartbeat, login, logout, whoami } from '../src/platform';
|
|
13
|
+
import { startLocalServiceCommand, stopLocalServiceCommand } from '../src/serviceCommands';
|
|
14
|
+
|
|
15
|
+
function isDirectExecution() {
|
|
16
|
+
const scriptPath = process.argv[1];
|
|
17
|
+
if (!scriptPath) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
return (
|
|
23
|
+
realpathSync(fileURLToPath(import.meta.url)) ===
|
|
24
|
+
realpathSync(resolve(scriptPath))
|
|
25
|
+
);
|
|
26
|
+
} catch {
|
|
27
|
+
return resolve(fileURLToPath(import.meta.url)) === resolve(scriptPath);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function valueForArg(args: string[], name: string) {
|
|
32
|
+
const index = args.indexOf(name);
|
|
33
|
+
if (index === -1) {
|
|
34
|
+
return { provided: false, value: undefined, missing: false };
|
|
35
|
+
}
|
|
36
|
+
const value = args[index + 1];
|
|
37
|
+
if (!value || value.startsWith('--')) {
|
|
38
|
+
return { provided: true, value: undefined, missing: true };
|
|
39
|
+
}
|
|
40
|
+
return { provided: true, value, missing: false };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function missingReasonForOption(name: string) {
|
|
44
|
+
return `${name.slice(2).replaceAll('-', '_')}_missing_value`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function readOption(args: string[], name: string) {
|
|
48
|
+
const result = valueForArg(args, name);
|
|
49
|
+
if (result.missing) {
|
|
50
|
+
throw new Error(missingReasonForOption(name));
|
|
51
|
+
}
|
|
52
|
+
return result.value;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function hasFlag(args: string[], name: string) {
|
|
56
|
+
return args.includes(name);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function readPositiveIntegerOption(args: string[], name: string) {
|
|
60
|
+
const value = readOption(args, name);
|
|
61
|
+
if (value === undefined) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const parsed = Number(value);
|
|
66
|
+
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
67
|
+
throw new Error(`${name} must be a positive integer`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return parsed;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function parseCommonOptions(args: string[]) {
|
|
74
|
+
return {
|
|
75
|
+
appPath: readOption(args, '--app-path'),
|
|
76
|
+
realAppPath: readOption(args, '--real-app-path'),
|
|
77
|
+
runtimeFile: readOption(args, '--runtime-file'),
|
|
78
|
+
backupDir: readOption(args, '--backup-dir'),
|
|
79
|
+
installRecordFile: readOption(args, '--install-record-file'),
|
|
80
|
+
trialRecordDir: readOption(args, '--trial-record-dir'),
|
|
81
|
+
extensionInstallPath: readOption(args, '--extension-install-path'),
|
|
82
|
+
cursorExtensionsDir: readOption(args, '--cursor-extensions-dir'),
|
|
83
|
+
userDataDir: readOption(args, '--user-data-dir'),
|
|
84
|
+
serviceLogFile: readOption(args, '--service-log-file'),
|
|
85
|
+
configFile: readOption(args, '--config-file'),
|
|
86
|
+
diagnosticsFile: readOption(args, '--diagnostics-file'),
|
|
87
|
+
sessionFile: readOption(args, '--session-file'),
|
|
88
|
+
code: readOption(args, '--code'),
|
|
89
|
+
apiBaseUrl: readOption(args, '--api-base-url'),
|
|
90
|
+
compatManifestUrl: readOption(args, '--compat-manifest-url'),
|
|
91
|
+
yes: hasFlag(args, '--yes'),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function parseDiagnosticsOptions(
|
|
96
|
+
args: string[],
|
|
97
|
+
commonOptions: ReturnType<typeof parseCommonOptions>,
|
|
98
|
+
) {
|
|
99
|
+
return {
|
|
100
|
+
diagnosticsFile: commonOptions.diagnosticsFile,
|
|
101
|
+
limit: readPositiveIntegerOption(args, '--limit'),
|
|
102
|
+
json: hasFlag(args, '--json'),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export async function main() {
|
|
107
|
+
const [command = 'status', ...args] = process.argv.slice(2);
|
|
108
|
+
const commonOptions = parseCommonOptions(args);
|
|
109
|
+
|
|
110
|
+
const handlers: Record<string, () => Promise<string>> = {
|
|
111
|
+
install: () => install(commonOptions),
|
|
112
|
+
repair: () => repair(commonOptions),
|
|
113
|
+
start: () => startLocalServiceCommand(commonOptions),
|
|
114
|
+
stop: () => stopLocalServiceCommand(commonOptions),
|
|
115
|
+
status: () => status(commonOptions),
|
|
116
|
+
restore: () => restore(commonOptions),
|
|
117
|
+
uninstall: () => uninstall(commonOptions),
|
|
118
|
+
diagnostics: () => diagnostics(parseDiagnosticsOptions(args, commonOptions)),
|
|
119
|
+
'clear-diagnostics': () =>
|
|
120
|
+
clearDiagnostics({ diagnosticsFile: commonOptions.diagnosticsFile }),
|
|
121
|
+
'launch-command': () =>
|
|
122
|
+
launchCommand({
|
|
123
|
+
appPath: commonOptions.appPath,
|
|
124
|
+
userDataDir: commonOptions.userDataDir,
|
|
125
|
+
cursorExtensionsDir: commonOptions.cursorExtensionsDir,
|
|
126
|
+
}),
|
|
127
|
+
'launch-status': () =>
|
|
128
|
+
launchStatus({
|
|
129
|
+
appPath: commonOptions.appPath,
|
|
130
|
+
userDataDir: commonOptions.userDataDir,
|
|
131
|
+
cursorExtensionsDir: commonOptions.cursorExtensionsDir,
|
|
132
|
+
}),
|
|
133
|
+
login: () =>
|
|
134
|
+
login({
|
|
135
|
+
runtimeFile: commonOptions.runtimeFile,
|
|
136
|
+
sessionFile: commonOptions.sessionFile,
|
|
137
|
+
code: commonOptions.code,
|
|
138
|
+
apiBaseUrl: commonOptions.apiBaseUrl,
|
|
139
|
+
}),
|
|
140
|
+
whoami: () =>
|
|
141
|
+
whoami({
|
|
142
|
+
runtimeFile: commonOptions.runtimeFile,
|
|
143
|
+
sessionFile: commonOptions.sessionFile,
|
|
144
|
+
}),
|
|
145
|
+
heartbeat: () =>
|
|
146
|
+
heartbeat({
|
|
147
|
+
runtimeFile: commonOptions.runtimeFile,
|
|
148
|
+
sessionFile: commonOptions.sessionFile,
|
|
149
|
+
}),
|
|
150
|
+
logout: () =>
|
|
151
|
+
logout({
|
|
152
|
+
runtimeFile: commonOptions.runtimeFile,
|
|
153
|
+
sessionFile: commonOptions.sessionFile,
|
|
154
|
+
}),
|
|
155
|
+
};
|
|
156
|
+
const handler = handlers[command];
|
|
157
|
+
if (!handler) {
|
|
158
|
+
throw new Error(`Unknown command: ${command}`);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
process.stdout.write(`${await handler()}\n`);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (isDirectExecution()) {
|
|
165
|
+
main().catch((error) => {
|
|
166
|
+
process.stderr.write(`${(error as Error).message}\n`);
|
|
167
|
+
process.exitCode = 1;
|
|
168
|
+
});
|
|
169
|
+
}
|