@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,144 @@
1
+ import assert from 'node:assert/strict';
2
+ import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
3
+ import { tmpdir } from 'node:os';
4
+ import { join } from 'node:path';
5
+ import test from 'node:test';
6
+ import { sha256File } from '../src/hash';
7
+ import {
8
+ buildCursorAlwaysLocalTakeoverPatchSnippet,
9
+ CURSOR_POOL_ALWAYS_LOCAL_TAKEOVER_MARKER,
10
+ CURSOR_POOL_ALWAYS_LOCAL_TAKEOVER_SIGNATURE,
11
+ hasCursorAlwaysLocalTakeoverMarker,
12
+ } from '../src/alwaysLocalMarker';
13
+ import {
14
+ backupPathForCursorAlwaysLocal,
15
+ patchCursorAlwaysLocal,
16
+ resolveCursorAlwaysLocalPath,
17
+ } from '../src/patchCursorAlwaysLocal';
18
+ import { restoreCursorAlwaysLocal } from '../src/restoreCursorAlwaysLocal';
19
+
20
+ const targetRelativePath =
21
+ 'Contents/Resources/app/extensions/cursor-always-local/dist/main.js';
22
+
23
+ async function createFixture(content = 'async function streamUnifiedChat() { return "cursor"; }\n') {
24
+ const base = await mkdtemp(join(tmpdir(), 'cursor-pool-always-local-'));
25
+ const appPath = join(base, `Fixture-${Date.now()}-${Math.random()}.app`);
26
+ await mkdir(join(appPath, 'Contents/Resources/app/extensions/cursor-always-local/dist'), {
27
+ recursive: true,
28
+ });
29
+ await writeFile(join(appPath, targetRelativePath), content, 'utf8');
30
+ return { appPath, targetPath: join(appPath, targetRelativePath) };
31
+ }
32
+
33
+ test('always-local patch changes target hash and writes takeover marker', async () => {
34
+ const fixture = await createFixture();
35
+ const backupDir = join(tmpdir(), `cursor-pool-always-local-backups-${Date.now()}-${Math.random()}`);
36
+
37
+ try {
38
+ assert.equal(resolveCursorAlwaysLocalPath(fixture.appPath), fixture.targetPath);
39
+ const beforeHash = await sha256File(fixture.targetPath);
40
+ const result = await patchCursorAlwaysLocal(fixture.appPath, { backupDir });
41
+ const content = await readFile(fixture.targetPath, 'utf8');
42
+
43
+ assert.equal(result.beforeHash, beforeHash);
44
+ assert.notEqual(result.afterHash, beforeHash);
45
+ assert.equal(content.includes(CURSOR_POOL_ALWAYS_LOCAL_TAKEOVER_MARKER), true);
46
+ assert.equal(content.includes(CURSOR_POOL_ALWAYS_LOCAL_TAKEOVER_SIGNATURE), true);
47
+ assert.equal(await hasCursorAlwaysLocalTakeoverMarker(fixture.targetPath), true);
48
+ assert.match(result.backupPath, new RegExp(`^${backupDir.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`));
49
+ } finally {
50
+ await rm(fixture.appPath, { recursive: true, force: true });
51
+ await rm(backupDir, { recursive: true, force: true });
52
+ }
53
+ });
54
+
55
+ test('always-local patch supports Linux Cursor relative paths', async () => {
56
+ const base = await mkdtemp(join(tmpdir(), 'cursor-pool-always-local-linux-'));
57
+ const appPath = join(base, 'squashfs-root');
58
+ const linuxTargetRelativePath =
59
+ 'usr/share/cursor/resources/app/extensions/cursor-always-local/dist/main.js';
60
+ const targetPath = join(appPath, linuxTargetRelativePath);
61
+ const backupDir = join(tmpdir(), `cursor-pool-always-local-linux-backups-${Date.now()}-${Math.random()}`);
62
+
63
+ try {
64
+ await mkdir(join(appPath, 'usr/share/cursor/resources/app/extensions/cursor-always-local/dist'), {
65
+ recursive: true,
66
+ });
67
+ await writeFile(targetPath, 'async function streamUnifiedChat() { return "cursor"; }\n', 'utf8');
68
+
69
+ assert.equal(resolveCursorAlwaysLocalPath(appPath, linuxTargetRelativePath), targetPath);
70
+ const beforeHash = await sha256File(targetPath);
71
+ const patch = await patchCursorAlwaysLocal(appPath, {
72
+ backupDir,
73
+ targetRelativePath: linuxTargetRelativePath,
74
+ });
75
+ const restore = await restoreCursorAlwaysLocal(appPath, {
76
+ backupDir,
77
+ targetRelativePath: linuxTargetRelativePath,
78
+ });
79
+
80
+ assert.equal(patch.targetPath, targetPath);
81
+ assert.notEqual(patch.afterHash, beforeHash);
82
+ assert.equal(restore.targetPath, targetPath);
83
+ assert.equal(restore.afterHash, beforeHash);
84
+ assert.equal(await hasCursorAlwaysLocalTakeoverMarker(targetPath), false);
85
+ } finally {
86
+ await rm(base, { recursive: true, force: true });
87
+ await rm(backupDir, { recursive: true, force: true });
88
+ }
89
+ });
90
+
91
+ test('always-local restore returns patched target to original hash and removes marker', async () => {
92
+ const fixture = await createFixture();
93
+ const backupDir = join(tmpdir(), `cursor-pool-always-local-restore-${Date.now()}-${Math.random()}`);
94
+
95
+ try {
96
+ const beforeHash = await sha256File(fixture.targetPath);
97
+ const patch = await patchCursorAlwaysLocal(fixture.appPath, { backupDir });
98
+ assert.equal(await hasCursorAlwaysLocalTakeoverMarker(fixture.targetPath), true);
99
+
100
+ const restore = await restoreCursorAlwaysLocal(fixture.appPath, { backupDir });
101
+
102
+ assert.equal(patch.beforeHash, beforeHash);
103
+ assert.equal(restore.beforeHash, patch.afterHash);
104
+ assert.equal(restore.afterHash, beforeHash);
105
+ assert.equal(await sha256File(fixture.targetPath), beforeHash);
106
+ assert.equal(await hasCursorAlwaysLocalTakeoverMarker(fixture.targetPath), false);
107
+ } finally {
108
+ await rm(fixture.appPath, { recursive: true, force: true });
109
+ await rm(backupDir, { recursive: true, force: true });
110
+ }
111
+ });
112
+
113
+ test('always-local restore refuses a backup that contains takeover marker text', async () => {
114
+ const fixture = await createFixture();
115
+ const backupDir = join(tmpdir(), `cursor-pool-always-local-bad-backup-${Date.now()}-${Math.random()}`);
116
+
117
+ try {
118
+ await patchCursorAlwaysLocal(fixture.appPath, { backupDir });
119
+ const patchedHash = await sha256File(fixture.targetPath);
120
+ const backupPath = await backupPathForCursorAlwaysLocal(fixture.appPath, fixture.targetPath, backupDir);
121
+ await writeFile(backupPath, await readFile(fixture.targetPath, 'utf8'), 'utf8');
122
+
123
+ await assert.rejects(
124
+ restoreCursorAlwaysLocal(fixture.appPath, { backupDir }),
125
+ /backup.*patch marker/i,
126
+ );
127
+
128
+ assert.equal(await sha256File(fixture.targetPath), patchedHash);
129
+ assert.equal(await hasCursorAlwaysLocalTakeoverMarker(fixture.targetPath), true);
130
+ } finally {
131
+ await rm(fixture.appPath, { recursive: true, force: true });
132
+ await rm(backupDir, { recursive: true, force: true });
133
+ }
134
+ });
135
+
136
+ test('always-local snippet calls takeover endpoint without prompt or token literals', () => {
137
+ const snippet = buildCursorAlwaysLocalTakeoverPatchSnippet();
138
+ assert.equal(snippet.includes('/agent/takeover'), true);
139
+ assert.equal(snippet.includes('CURSOR_POOL_RUNTIME_FILE'), true);
140
+ assert.equal(snippet.includes('cursor-always-local'), true);
141
+ assert.equal(snippet.includes('prompt'), false);
142
+ assert.equal(snippet.includes('messages:'), false);
143
+ assert.equal(snippet.includes('routeToken'), false);
144
+ });