@emmaneugene/pi-cursor-sdk 0.3.7 → 0.4.1

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 (91) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +99 -126
  3. package/dist/cursor-agents-context-registration.js +1 -3
  4. package/dist/cursor-agents-context.js +2 -2
  5. package/dist/cursor-config.js +2 -290
  6. package/dist/cursor-extension-factory-guard.js +31 -0
  7. package/dist/cursor-pi-tool-bridge-server.js +3 -0
  8. package/dist/cursor-pi-tool-bridge.js +5 -0
  9. package/dist/cursor-provider-errors.js +3 -58
  10. package/dist/cursor-provider-live-run-drain.js +0 -3
  11. package/dist/cursor-provider-run-finalizer.js +4 -7
  12. package/dist/cursor-provider-run-outcome.js +1 -1
  13. package/dist/cursor-provider-turn-finalize.js +3 -55
  14. package/dist/cursor-provider-turn-prepare.js +8 -144
  15. package/dist/cursor-provider-turn-runner.js +9 -23
  16. package/dist/cursor-provider-turn-send.js +8 -35
  17. package/dist/cursor-runtime-state.js +6 -268
  18. package/dist/cursor-sdk-billed-usage.js +3 -18
  19. package/dist/cursor-sdk-platform-package.js +88 -0
  20. package/dist/cursor-session-agent.js +18 -14
  21. package/dist/cursor-skill-tool.js +12 -22
  22. package/dist/cursor-state.js +5 -8
  23. package/dist/cursor-usage-accounting.js +1 -1
  24. package/dist/index.js +65 -49
  25. package/docs/cursor-dogfood-checklist.md +4 -4
  26. package/docs/cursor-live-smoke-checklist.md +24 -24
  27. package/docs/cursor-model-ux-spec.md +27 -30
  28. package/docs/cursor-native-tool-replay.md +4 -4
  29. package/docs/cursor-native-tool-visual-audit.md +10 -10
  30. package/docs/cursor-testing-lessons.md +38 -16
  31. package/docs/cursor-tool-surfaces.md +2 -4
  32. package/docs/platform-smoke-implementation.md +5 -5
  33. package/docs/platform-smoke.md +28 -73
  34. package/node_modules/cross-spawn/node_modules/which/CHANGELOG.md +166 -0
  35. package/package.json +3 -17
  36. package/platform-smoke.config.mjs +2 -1
  37. package/scripts/lib/cursor-visual-render.mjs +12 -2
  38. package/scripts/lib/local-resume-smoke-harness.mjs +0 -18
  39. package/scripts/platform-smoke/card-detect.mjs +1 -1
  40. package/scripts/platform-smoke/local-resume-runner.mjs +1 -1
  41. package/scripts/platform-smoke/scenarios.mjs +1 -1
  42. package/scripts/platform-smoke/targets.mjs +14 -5
  43. package/scripts/visual-tui-smoke-self-test.mjs +9 -33
  44. package/scripts/visual-tui-smoke.mjs +54 -11
  45. package/src/cursor-agents-context-registration.ts +0 -5
  46. package/src/cursor-agents-context.ts +1 -3
  47. package/src/cursor-config.ts +8 -379
  48. package/src/cursor-extension-factory-guard.ts +57 -0
  49. package/src/cursor-pi-tool-bridge-server.ts +4 -0
  50. package/src/cursor-pi-tool-bridge.ts +5 -0
  51. package/src/cursor-provider-errors.ts +2 -62
  52. package/src/cursor-provider-live-run-drain.ts +0 -3
  53. package/src/cursor-provider-run-finalizer.ts +4 -12
  54. package/src/cursor-provider-run-outcome.ts +0 -3
  55. package/src/cursor-provider-turn-finalize.ts +3 -61
  56. package/src/cursor-provider-turn-prepare.ts +8 -165
  57. package/src/cursor-provider-turn-runner.ts +15 -31
  58. package/src/cursor-provider-turn-send.ts +7 -38
  59. package/src/cursor-provider-turn-types.ts +9 -30
  60. package/src/cursor-runtime-state.ts +6 -345
  61. package/src/cursor-sdk-billed-usage.ts +3 -24
  62. package/src/cursor-sdk-platform-package.ts +106 -0
  63. package/src/cursor-session-agent.ts +16 -12
  64. package/src/cursor-skill-tool.ts +10 -26
  65. package/src/cursor-state.ts +5 -10
  66. package/src/cursor-usage-accounting.ts +1 -3
  67. package/src/index.ts +70 -49
  68. package/dist/cursor-cloud-lifecycle.js +0 -650
  69. package/dist/cursor-cloud-local-state.js +0 -460
  70. package/dist/cursor-cloud-options.js +0 -145
  71. package/dist/cursor-cloud-reporting.js +0 -222
  72. package/dist/cursor-ripgrep-path.js +0 -27
  73. package/scripts/cloud-runtime-smoke.d.mts +0 -42
  74. package/scripts/cloud-runtime-smoke.mjs +0 -623
  75. package/scripts/lib/cloud-smoke-artifacts.d.mts +0 -16
  76. package/scripts/lib/cloud-smoke-artifacts.mjs +0 -94
  77. package/scripts/lib/cloud-smoke-cleanup-evidence.d.mts +0 -209
  78. package/scripts/lib/cloud-smoke-cleanup-evidence.mjs +0 -585
  79. package/scripts/lib/cloud-smoke-github.d.mts +0 -78
  80. package/scripts/lib/cloud-smoke-github.mjs +0 -331
  81. package/scripts/lib/cloud-smoke-pi-runner.d.mts +0 -42
  82. package/scripts/lib/cloud-smoke-pi-runner.mjs +0 -214
  83. package/scripts/lib/cloud-smoke-shutdown.d.mts +0 -67
  84. package/scripts/lib/cloud-smoke-shutdown.mjs +0 -133
  85. package/shared/cursor-cloud-lifecycle-constants.d.mts +0 -3
  86. package/shared/cursor-cloud-lifecycle-constants.mjs +0 -7
  87. package/src/cursor-cloud-lifecycle.ts +0 -733
  88. package/src/cursor-cloud-local-state.ts +0 -536
  89. package/src/cursor-cloud-options.ts +0 -182
  90. package/src/cursor-cloud-reporting.ts +0 -267
  91. package/src/cursor-ripgrep-path.ts +0 -32
@@ -1,133 +0,0 @@
1
- export function createCloudSmokeShutdownController(terminate) {
2
- if (typeof terminate !== "function") throw new TypeError("terminate must be a function");
3
- const activeChildren = new Set();
4
- const abortController = new AbortController();
5
- let shutdownPromise;
6
- let reason;
7
- let requestedSignal;
8
- let terminationFailureReason;
9
-
10
- const terminationFailure = (error) => {
11
- if (terminationFailureReason) return terminationFailureReason;
12
- terminationFailureReason = new Error(`cloud smoke ${requestedSignal} child termination failed`, { cause: error });
13
- terminationFailureReason.signal = requestedSignal;
14
- reason = terminationFailureReason;
15
- return terminationFailureReason;
16
- };
17
-
18
- const track = async (child) => {
19
- if (abortController.signal.aborted) {
20
- try {
21
- await terminate(child);
22
- } catch (error) {
23
- throw terminationFailure(error);
24
- }
25
- throw reason;
26
- }
27
- activeChildren.add(child);
28
- const untrack = () => activeChildren.delete(child);
29
- child.once?.("close", untrack);
30
- return untrack;
31
- };
32
-
33
- const request = async (signalName) => {
34
- if (!abortController.signal.aborted) {
35
- requestedSignal = signalName;
36
- const interruptReason = new Error(`cloud smoke interrupted by ${signalName}`);
37
- interruptReason.signal = signalName;
38
- reason = interruptReason;
39
- const terminations = [...activeChildren].map((child) => Promise.resolve().then(() => terminate(child)));
40
- shutdownPromise = Promise.allSettled(terminations).then((results) => {
41
- const failed = results.find((result) => result.status === "rejected");
42
- if (failed) throw terminationFailure(failed.reason);
43
- });
44
- abortController.abort(interruptReason);
45
- }
46
- await shutdownPromise;
47
- return reason;
48
- };
49
-
50
- return {
51
- signal: abortController.signal,
52
- track,
53
- request,
54
- get reason() { return reason; },
55
- wait: () => shutdownPromise ?? Promise.resolve(),
56
- throwIfRequested() {
57
- if (abortController.signal.aborted) throw reason;
58
- },
59
- };
60
- }
61
-
62
- export async function awaitCloudSmokeShutdown(shutdown, tracking = Promise.resolve()) {
63
- const results = await Promise.allSettled([shutdown.wait(), tracking]);
64
- const failed = results.find((result) => result.status === "rejected");
65
- const outcome = failed?.reason ?? shutdown.reason;
66
- return outcome instanceof Error ? outcome : new Error("cloud smoke shutdown failed", { cause: outcome });
67
- }
68
-
69
- export async function checkpointCloudSmokeShutdown(shutdown) {
70
- await new Promise((resolve) => setImmediate(resolve));
71
- shutdown.throwIfRequested();
72
- }
73
-
74
- export function createCloudSmokeTerminalFailureState(rejectPending) {
75
- let failure;
76
- return {
77
- record(error) {
78
- failure ??= error;
79
- rejectPending(failure);
80
- },
81
- throwIfFailed() {
82
- if (failure) throw failure;
83
- },
84
- };
85
- }
86
-
87
- export async function stopCloudSmokeTrackedChild(shutdown, tracking, terminateChild) {
88
- const termination = Promise.resolve().then(terminateChild);
89
- const [terminationResult] = await Promise.allSettled([termination]);
90
- if (shutdown.signal.aborted) {
91
- const results = await Promise.allSettled([shutdown.wait(), tracking, termination]);
92
- const failed = results.find((result) => result.status === "rejected");
93
- if (failed) throw failed.reason instanceof Error ? failed.reason : new Error("cloud smoke child termination failed", { cause: failed.reason });
94
- return shutdown.reason;
95
- }
96
- if (terminationResult.status === "rejected") throw terminationResult.reason;
97
- return undefined;
98
- }
99
-
100
- export function routeCloudSmokeChildError(shutdown, onShutdown, onError, error) {
101
- if (shutdown.signal.aborted) onShutdown();
102
- else onError(error);
103
- }
104
-
105
- export function installCloudSmokeChildErrorHandlers(child, shutdown, onShutdown, onError) {
106
- const routeError = (error) => routeCloudSmokeChildError(shutdown, onShutdown, onError, error);
107
- child.once("error", routeError);
108
- child.stdin?.on?.("error", routeError);
109
- return routeError;
110
- }
111
-
112
- export function routeCloudSmokeChildClose(shutdown, timedOut, onShutdown, onClose, result) {
113
- if (shutdown.signal.aborted) onShutdown();
114
- else if (!timedOut) onClose(result);
115
- }
116
-
117
- export function installCloudSmokeSignalHandlers(shutdown, processLike = process, onSignal) {
118
- const handlers = new Map();
119
- for (const signalName of ["SIGINT", "SIGTERM"]) {
120
- const handler = () => {
121
- try {
122
- onSignal?.(signalName);
123
- } finally {
124
- void shutdown.request(signalName).catch(() => {});
125
- }
126
- };
127
- handlers.set(signalName, handler);
128
- processLike.on(signalName, handler);
129
- }
130
- return () => {
131
- for (const [signalName, handler] of handlers) processLike.off(signalName, handler);
132
- };
133
- }
@@ -1,3 +0,0 @@
1
- export declare const CLOUD_AGENT_ID_PATTERN: RegExp;
2
- export declare const CLOUD_LIFECYCLE_ENTRY_TYPE: "cursor-cloud-lifecycle";
3
- export declare const CLOUD_LIFECYCLE_JOURNAL_PREFIX: ".cursor-cloud-lifecycle";
@@ -1,7 +0,0 @@
1
- /** Canonical Cursor Cloud lifecycle contract shared by the runtime and maintainer scripts. */
2
-
3
- export const CLOUD_AGENT_ID_PATTERN = /^bc-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
4
-
5
- export const CLOUD_LIFECYCLE_ENTRY_TYPE = "cursor-cloud-lifecycle";
6
-
7
- export const CLOUD_LIFECYCLE_JOURNAL_PREFIX = ".cursor-cloud-lifecycle";