@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.
Files changed (105) hide show
  1. package/bin/cursor-pool.mjs +9 -0
  2. package/bin/cursor-pool.ts +169 -0
  3. package/node_modules/@cursor-pool/extension/dist/extension.js +2910 -0
  4. package/node_modules/@cursor-pool/extension/package.json +64 -0
  5. package/node_modules/@cursor-pool/extension/resources/cursor-pool.svg +6 -0
  6. package/node_modules/@cursor-pool/extension/src/api.ts +545 -0
  7. package/node_modules/@cursor-pool/extension/src/extension.ts +104 -0
  8. package/node_modules/@cursor-pool/extension/src/index.ts +1 -0
  9. package/node_modules/@cursor-pool/extension/src/panel.ts +569 -0
  10. package/node_modules/@cursor-pool/extension/src/runtime.ts +22 -0
  11. package/node_modules/@cursor-pool/extension/test/panel.test.ts +1785 -0
  12. package/node_modules/@cursor-pool/patcher/package.json +17 -0
  13. package/node_modules/@cursor-pool/patcher/src/alwaysLocalMarker.ts +86 -0
  14. package/node_modules/@cursor-pool/patcher/src/hash.ts +7 -0
  15. package/node_modules/@cursor-pool/patcher/src/index.ts +55 -0
  16. package/node_modules/@cursor-pool/patcher/src/marker.ts +159 -0
  17. package/node_modules/@cursor-pool/patcher/src/patchCursorAgentExec.ts +154 -0
  18. package/node_modules/@cursor-pool/patcher/src/patchCursorAlwaysLocal.ts +142 -0
  19. package/node_modules/@cursor-pool/patcher/src/patchCursorWorkbenchAuthGate.ts +140 -0
  20. package/node_modules/@cursor-pool/patcher/src/restoreCursorAgentExec.ts +52 -0
  21. package/node_modules/@cursor-pool/patcher/src/restoreCursorAlwaysLocal.ts +52 -0
  22. package/node_modules/@cursor-pool/patcher/src/restoreCursorWorkbenchAuthGate.ts +70 -0
  23. package/node_modules/@cursor-pool/patcher/src/workbenchAuthGateMarker.ts +243 -0
  24. package/node_modules/@cursor-pool/patcher/test/patchCursorAgentExec.test.ts +630 -0
  25. package/node_modules/@cursor-pool/patcher/test/patchCursorAlwaysLocal.test.ts +144 -0
  26. package/node_modules/@cursor-pool/patcher/test/patchCursorWorkbench.test.ts +770 -0
  27. package/node_modules/@cursor-pool/patcher/test/restoreCursorAgentExec.test.ts +139 -0
  28. package/node_modules/@cursor-pool/service/package.json +17 -0
  29. package/node_modules/@cursor-pool/service/src/canary.ts +61 -0
  30. package/node_modules/@cursor-pool/service/src/diagnostics.ts +385 -0
  31. package/node_modules/@cursor-pool/service/src/entry.ts +161 -0
  32. package/node_modules/@cursor-pool/service/src/health.ts +10 -0
  33. package/node_modules/@cursor-pool/service/src/index.ts +29 -0
  34. package/node_modules/@cursor-pool/service/src/metadata.ts +22 -0
  35. package/node_modules/@cursor-pool/service/src/platformSession.ts +1178 -0
  36. package/node_modules/@cursor-pool/service/src/requestCheck.ts +81 -0
  37. package/node_modules/@cursor-pool/service/src/requestGate.ts +100 -0
  38. package/node_modules/@cursor-pool/service/src/requestGateway.ts +441 -0
  39. package/node_modules/@cursor-pool/service/src/runtime.ts +48 -0
  40. package/node_modules/@cursor-pool/service/src/server.ts +939 -0
  41. package/node_modules/@cursor-pool/service/src/takeover.ts +111 -0
  42. package/node_modules/@cursor-pool/service/test/canary.test.ts +140 -0
  43. package/node_modules/@cursor-pool/service/test/diagnostics.test.ts +506 -0
  44. package/node_modules/@cursor-pool/service/test/metadata.test.ts +63 -0
  45. package/node_modules/@cursor-pool/service/test/platformSession.test.ts +2428 -0
  46. package/node_modules/@cursor-pool/service/test/requestCheck.test.ts +152 -0
  47. package/node_modules/@cursor-pool/service/test/requestGate.test.ts +207 -0
  48. package/node_modules/@cursor-pool/service/test/requestGateway.test.ts +466 -0
  49. package/node_modules/@cursor-pool/service/test/runtime.test.ts +47 -0
  50. package/node_modules/@cursor-pool/service/test/server.test.ts +2570 -0
  51. package/node_modules/@cursor-pool/shared/package.json +17 -0
  52. package/node_modules/@cursor-pool/shared/src/clientConfig.ts +49 -0
  53. package/node_modules/@cursor-pool/shared/src/index.ts +14 -0
  54. package/node_modules/@cursor-pool/shared/src/manifest.ts +36 -0
  55. package/node_modules/@cursor-pool/shared/src/metadata.ts +19 -0
  56. package/node_modules/@cursor-pool/shared/src/paths.ts +5 -0
  57. package/node_modules/@cursor-pool/shared/src/runtime.ts +3 -0
  58. package/node_modules/@cursor-pool/shared/test/index.test.ts +56 -0
  59. package/node_modules/@cursor-pool/shared/test/manifest.test.ts +65 -0
  60. package/node_modules/@cursor-pool/shared/test/metadata.test.ts +25 -0
  61. package/node_modules/@cursor-pool/shared/test/runtime.test.ts +8 -0
  62. package/package.json +28 -0
  63. package/src/adHocResign.ts +65 -0
  64. package/src/autostart.ts +240 -0
  65. package/src/compat.ts +282 -0
  66. package/src/confirm.ts +76 -0
  67. package/src/cursor.ts +94 -0
  68. package/src/diagnostics.ts +558 -0
  69. package/src/environment.ts +18 -0
  70. package/src/extensionBundle.ts +111 -0
  71. package/src/extensionLink.ts +168 -0
  72. package/src/index.ts +23 -0
  73. package/src/install.ts +614 -0
  74. package/src/installRecord.ts +105 -0
  75. package/src/launch.ts +182 -0
  76. package/src/patchSet.ts +182 -0
  77. package/src/platform.ts +132 -0
  78. package/src/repair.ts +383 -0
  79. package/src/restore.ts +153 -0
  80. package/src/serviceCommands.ts +79 -0
  81. package/src/serviceProcess.ts +188 -0
  82. package/src/status.ts +241 -0
  83. package/src/target.ts +37 -0
  84. package/src/trial.ts +133 -0
  85. package/src/uninstall.ts +213 -0
  86. package/test/autostart.test.ts +151 -0
  87. package/test/compat.test.ts +192 -0
  88. package/test/confirm.test.ts +114 -0
  89. package/test/cursor-pool-bin.test.ts +658 -0
  90. package/test/cursor.test.ts +20 -0
  91. package/test/diagnostics.test.ts +709 -0
  92. package/test/e2e-install.test.ts +773 -0
  93. package/test/extensionBundle.test.ts +161 -0
  94. package/test/extensionLink.test.ts +209 -0
  95. package/test/install.test.ts +862 -0
  96. package/test/installRecord.test.ts +107 -0
  97. package/test/launch.test.ts +138 -0
  98. package/test/platform.test.ts +226 -0
  99. package/test/repair.test.ts +575 -0
  100. package/test/restore.test.ts +211 -0
  101. package/test/serviceCommands.test.ts +135 -0
  102. package/test/serviceProcess.test.ts +280 -0
  103. package/test/status.test.ts +615 -0
  104. package/test/target.test.ts +49 -0
  105. package/test/trial.test.ts +146 -0
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ import 'tsx/esm';
3
+
4
+ const { main } = await import('./cursor-pool.ts');
5
+
6
+ main().catch((error) => {
7
+ process.stderr.write(`${error.message}\n`);
8
+ process.exitCode = 1;
9
+ });
@@ -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
+ }