@emmaneugene/pi-cursor-sdk 0.3.7 → 0.4.0

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 (79) hide show
  1. package/CHANGELOG.md +16 -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-provider-errors.js +3 -58
  7. package/dist/cursor-provider-live-run-drain.js +0 -3
  8. package/dist/cursor-provider-run-finalizer.js +4 -7
  9. package/dist/cursor-provider-run-outcome.js +1 -1
  10. package/dist/cursor-provider-turn-finalize.js +3 -55
  11. package/dist/cursor-provider-turn-prepare.js +8 -144
  12. package/dist/cursor-provider-turn-runner.js +9 -23
  13. package/dist/cursor-provider-turn-send.js +8 -35
  14. package/dist/cursor-runtime-state.js +6 -268
  15. package/dist/cursor-sdk-billed-usage.js +3 -18
  16. package/dist/cursor-sdk-platform-package.js +88 -0
  17. package/dist/cursor-session-agent.js +18 -14
  18. package/dist/cursor-skill-tool.js +12 -22
  19. package/dist/cursor-state.js +5 -8
  20. package/dist/cursor-usage-accounting.js +1 -1
  21. package/docs/cursor-dogfood-checklist.md +4 -4
  22. package/docs/cursor-live-smoke-checklist.md +23 -23
  23. package/docs/cursor-model-ux-spec.md +27 -30
  24. package/docs/cursor-native-tool-replay.md +4 -4
  25. package/docs/cursor-native-tool-visual-audit.md +7 -7
  26. package/docs/cursor-testing-lessons.md +23 -16
  27. package/docs/cursor-tool-surfaces.md +2 -4
  28. package/docs/platform-smoke-implementation.md +5 -5
  29. package/docs/platform-smoke.md +27 -72
  30. package/package.json +3 -17
  31. package/platform-smoke.config.mjs +2 -1
  32. package/scripts/lib/local-resume-smoke-harness.mjs +0 -18
  33. package/scripts/platform-smoke/card-detect.mjs +1 -1
  34. package/scripts/platform-smoke/local-resume-runner.mjs +1 -1
  35. package/scripts/platform-smoke/scenarios.mjs +1 -1
  36. package/scripts/platform-smoke/targets.mjs +14 -5
  37. package/src/cursor-agents-context-registration.ts +0 -5
  38. package/src/cursor-agents-context.ts +1 -3
  39. package/src/cursor-config.ts +8 -379
  40. package/src/cursor-provider-errors.ts +2 -62
  41. package/src/cursor-provider-live-run-drain.ts +0 -3
  42. package/src/cursor-provider-run-finalizer.ts +4 -12
  43. package/src/cursor-provider-run-outcome.ts +0 -3
  44. package/src/cursor-provider-turn-finalize.ts +3 -61
  45. package/src/cursor-provider-turn-prepare.ts +8 -165
  46. package/src/cursor-provider-turn-runner.ts +15 -31
  47. package/src/cursor-provider-turn-send.ts +7 -38
  48. package/src/cursor-provider-turn-types.ts +9 -30
  49. package/src/cursor-runtime-state.ts +6 -345
  50. package/src/cursor-sdk-billed-usage.ts +3 -24
  51. package/src/cursor-sdk-platform-package.ts +106 -0
  52. package/src/cursor-session-agent.ts +16 -12
  53. package/src/cursor-skill-tool.ts +10 -26
  54. package/src/cursor-state.ts +5 -10
  55. package/src/cursor-usage-accounting.ts +1 -3
  56. package/dist/cursor-cloud-lifecycle.js +0 -650
  57. package/dist/cursor-cloud-local-state.js +0 -460
  58. package/dist/cursor-cloud-options.js +0 -145
  59. package/dist/cursor-cloud-reporting.js +0 -222
  60. package/dist/cursor-ripgrep-path.js +0 -27
  61. package/scripts/cloud-runtime-smoke.d.mts +0 -42
  62. package/scripts/cloud-runtime-smoke.mjs +0 -623
  63. package/scripts/lib/cloud-smoke-artifacts.d.mts +0 -16
  64. package/scripts/lib/cloud-smoke-artifacts.mjs +0 -94
  65. package/scripts/lib/cloud-smoke-cleanup-evidence.d.mts +0 -209
  66. package/scripts/lib/cloud-smoke-cleanup-evidence.mjs +0 -585
  67. package/scripts/lib/cloud-smoke-github.d.mts +0 -78
  68. package/scripts/lib/cloud-smoke-github.mjs +0 -331
  69. package/scripts/lib/cloud-smoke-pi-runner.d.mts +0 -42
  70. package/scripts/lib/cloud-smoke-pi-runner.mjs +0 -214
  71. package/scripts/lib/cloud-smoke-shutdown.d.mts +0 -67
  72. package/scripts/lib/cloud-smoke-shutdown.mjs +0 -133
  73. package/shared/cursor-cloud-lifecycle-constants.d.mts +0 -3
  74. package/shared/cursor-cloud-lifecycle-constants.mjs +0 -7
  75. package/src/cursor-cloud-lifecycle.ts +0 -733
  76. package/src/cursor-cloud-local-state.ts +0 -536
  77. package/src/cursor-cloud-options.ts +0 -182
  78. package/src/cursor-cloud-reporting.ts +0 -267
  79. package/src/cursor-ripgrep-path.ts +0 -32
@@ -1,94 +0,0 @@
1
- import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
2
- import { dirname, join, resolve } from "node:path";
3
- import {
4
- CLOUD_AGENT_ID_PATTERN,
5
- CLOUD_LIFECYCLE_ENTRY_TYPE,
6
- CLOUD_LIFECYCLE_JOURNAL_PREFIX,
7
- } from "../../shared/cursor-cloud-lifecycle-constants.mjs";
8
-
9
- function walkFiles(dir, predicate) {
10
- const files = [];
11
- const stack = [dir];
12
- while (stack.length > 0) {
13
- const current = stack.pop();
14
- try {
15
- for (const entry of readdirSync(current, { withFileTypes: true })) {
16
- const path = join(current, entry.name);
17
- if (entry.isDirectory()) stack.push(path);
18
- else if (predicate(entry.name)) files.push(path);
19
- }
20
- } catch {}
21
- }
22
- return files.sort((left, right) => statSync(left).mtimeMs - statSync(right).mtimeMs);
23
- }
24
-
25
- export function readCloudSmokeMetadata(artifactDir) {
26
- return walkFiles(artifactDir, (name) => name === "metadata.json").flatMap((metadataPath) => {
27
- try {
28
- return [{ metadataPath, metadata: JSON.parse(readFileSync(metadataPath, "utf8")) }];
29
- } catch {
30
- return [];
31
- }
32
- });
33
- }
34
-
35
- export function readLatestCloudSmokeMetadata(artifactDir) {
36
- return readCloudSmokeMetadata(artifactDir).at(-1);
37
- }
38
-
39
- export function cloudAgentIdsFromMetadata(artifactDir) {
40
- const ids = new Set();
41
- for (const { metadata } of readCloudSmokeMetadata(artifactDir)) {
42
- const value = metadata.run?.agentId ?? metadata.providerMeta?.cloudAgentId;
43
- if (typeof value === "string" && CLOUD_AGENT_ID_PATTERN.test(value)) ids.add(value);
44
- }
45
- return [...ids];
46
- }
47
-
48
- export function cloudLifecycleRecords(artifactDir) {
49
- const records = [];
50
- const files = walkFiles(
51
- artifactDir,
52
- (name) => name.endsWith(".jsonl") || (name.startsWith(`${CLOUD_LIFECYCLE_JOURNAL_PREFIX}-`) && name.endsWith(".journal")),
53
- );
54
- for (const path of files) {
55
- const journal = path.split(/[\\/]/).at(-1)?.startsWith(`${CLOUD_LIFECYCLE_JOURNAL_PREFIX}-`) === true;
56
- let lines;
57
- try {
58
- lines = readFileSync(path, "utf8").split(/\r?\n/);
59
- } catch {
60
- continue;
61
- }
62
- for (const line of lines) {
63
- if (!line) continue;
64
- try {
65
- const entry = JSON.parse(line);
66
- const data = journal
67
- ? entry
68
- : entry?.type === "custom" && entry.customType === CLOUD_LIFECYCLE_ENTRY_TYPE
69
- ? entry.data
70
- : undefined;
71
- if (data && CLOUD_AGENT_ID_PATTERN.test(data.agentId)) records.push({ path, data });
72
- } catch {}
73
- }
74
- }
75
- return records;
76
- }
77
-
78
- export function cloudAgentIdsFromLifecycleArtifacts(artifactDir) {
79
- return [...new Set(cloudLifecycleRecords(artifactDir).map(({ data }) => data.agentId))];
80
- }
81
-
82
- function readJsonlIfPresent(path) {
83
- if (!path || !existsSync(path)) return [];
84
- return readFileSync(path, "utf8").split(/\n+/).filter(Boolean).map((line) => JSON.parse(line));
85
- }
86
-
87
- export function readCloudRunReport({ metadataPath, metadata }) {
88
- const artifactPath = metadata.artifacts?.providerEvents;
89
- if (!artifactPath) return undefined;
90
- const providerEventsPath = resolve(artifactPath) === artifactPath
91
- ? artifactPath
92
- : join(dirname(metadataPath), artifactPath);
93
- return readJsonlIfPresent(providerEventsPath).find((event) => event.phase === "cloud_run_report")?.payload;
94
- }
@@ -1,209 +0,0 @@
1
- export type CloudSmokeLaneName =
2
- | "cancel"
3
- | "explicit-https-repo-starting-ref-branch-pr-reporting"
4
- | "lifecycle-delete"
5
- | "direct-push-opt-in"
6
- | "missing-branch-failure"
7
- | "passive-artifacts-and-raw-usage";
8
-
9
- export type CloudSmokeEvidenceBranch = {
10
- branch: string | null;
11
- prUrl: string | null;
12
- };
13
-
14
- export type CloudSmokeCancelLaneEvidence = {
15
- name: "cancel";
16
- status: "passed";
17
- agentId: string;
18
- runId: string;
19
- runIdSource: "metadata" | "agent-list-runs";
20
- terminalStatus: "cancelled";
21
- idsCapturedBeforeAbort: true;
22
- };
23
-
24
- export type CloudSmokeBranchLaneEvidence = {
25
- name: "explicit-https-repo-starting-ref-branch-pr-reporting";
26
- status: "passed";
27
- agentId: string;
28
- runId: string;
29
- branchReportObserved: boolean;
30
- startingRefAncestryVerified: true;
31
- remoteContentVerified: true;
32
- prUrlReturned: boolean;
33
- branches: CloudSmokeEvidenceBranch[];
34
- artifactsObserved: boolean;
35
- rawUsageObserved: boolean;
36
- };
37
-
38
- export type CloudSmokeLifecycleDeleteLaneEvidence = {
39
- name: "lifecycle-delete";
40
- status: "passed";
41
- agentId: string;
42
- runId: string;
43
- lifecycleDeleteVerified: true;
44
- };
45
-
46
- export type CloudSmokeDirectPushLaneEvidence = {
47
- name: "direct-push-opt-in";
48
- status: "passed";
49
- agentId: string;
50
- runId: string;
51
- remoteContentChanged: true;
52
- branches: CloudSmokeEvidenceBranch[];
53
- artifactsObserved: boolean;
54
- rawUsageObserved: boolean;
55
- };
56
-
57
- export type CloudSmokeMissingBranchLaneEvidence = {
58
- name: "missing-branch-failure";
59
- status: "passed";
60
- expectedFailureObserved: true;
61
- agentIds: string[];
62
- };
63
-
64
- export type CloudSmokePassiveArtifactsLaneEvidence = {
65
- name: "passive-artifacts-and-raw-usage";
66
- status: "passed";
67
- artifactsObserved: boolean;
68
- rawUsageObserved: boolean;
69
- observationsValidated: true;
70
- };
71
-
72
- export type CloudSmokeLaneEvidence =
73
- | CloudSmokeCancelLaneEvidence
74
- | CloudSmokeBranchLaneEvidence
75
- | CloudSmokeLifecycleDeleteLaneEvidence
76
- | CloudSmokeDirectPushLaneEvidence
77
- | CloudSmokeMissingBranchLaneEvidence
78
- | CloudSmokePassiveArtifactsLaneEvidence;
79
-
80
- export type CloudSmokeCleanupEvidence =
81
- | { agentId: string; alreadyDeleted: true; archiveRequired: false; deleted: true; listExcluded: true }
82
- | { agentId: string; archived: true; deleted: true; listExcluded: true };
83
-
84
- export type CloudSmokeThrowawayRepositoryEvidence = {
85
- name: string;
86
- deleted: true;
87
- httpStatus: 404;
88
- };
89
-
90
- export type CloudSmokeEvidenceProvenance = {
91
- extensionVersion: string;
92
- cursorSdkVersion: string;
93
- gitRevision: string;
94
- packageSourceSha256: string;
95
- };
96
-
97
- export type CloudSmokeMatrixEvidence = {
98
- schemaVersion: 1;
99
- timestamp: string;
100
- model: string;
101
- provenance: CloudSmokeEvidenceProvenance;
102
- lanes: CloudSmokeLaneEvidence[];
103
- cleanup: CloudSmokeCleanupEvidence[];
104
- throwawayRepository: CloudSmokeThrowawayRepositoryEvidence;
105
- };
106
-
107
- export type CloudSmokeReleaseGateState = {
108
- lanes: unknown[];
109
- repository?: {
110
- fullName: string;
111
- repoUrl?: string;
112
- seedDir?: string;
113
- ownershipToken?: string;
114
- description?: string;
115
- };
116
- };
117
-
118
- export function isAgentNotFound(error: unknown): boolean;
119
-
120
- export function listCloudAgentIds(
121
- Agent: {
122
- list: (options: Record<string, unknown>) => Promise<{ items: Array<{ agentId: string }>; nextCursor?: string }>;
123
- },
124
- options?: { apiKey?: string },
125
- ): Promise<Set<string>>;
126
-
127
- export function assertAgentListExcludes(
128
- Agent: {
129
- list: (options: Record<string, unknown>) => Promise<{ items: Array<{ agentId: string }>; nextCursor?: string }>;
130
- },
131
- agentId: string,
132
- options?: { apiKey?: string },
133
- ): Promise<void>;
134
-
135
- export function assertAgentDeleted(
136
- Agent: {
137
- get: (agentId: string, options: Record<string, unknown>) => Promise<unknown>;
138
- list: (options: Record<string, unknown>) => Promise<{ items: Array<{ agentId: string }>; nextCursor?: string }>;
139
- },
140
- agentId: string,
141
- options?: { apiKey?: string },
142
- ): Promise<void>;
143
-
144
- export function cleanupCloudAgent(
145
- Agent: {
146
- get: (agentId: string, options: Record<string, unknown>) => Promise<{ archived?: boolean }>;
147
- archive: (agentId: string, options: Record<string, unknown>) => Promise<unknown>;
148
- delete: (agentId: string, options: Record<string, unknown>) => Promise<unknown>;
149
- list: (options: Record<string, unknown>) => Promise<{ items: Array<{ agentId: string }>; nextCursor?: string }>;
150
- },
151
- agentId: string,
152
- options?: { apiKey?: string },
153
- ): Promise<CloudSmokeCleanupEvidence>;
154
-
155
- export function assertCloudSmokeEvidenceSafe(summary: unknown, apiKey?: string): string;
156
-
157
- export function projectCloudSmokeMatrixEvidence(input?: {
158
- model?: string;
159
- lanes?: unknown[];
160
- cleanup?: unknown[];
161
- throwawayRepository?: unknown;
162
- provenance?: unknown;
163
- timestamp?: string;
164
- schemaVersion?: number;
165
- }): CloudSmokeMatrixEvidence;
166
-
167
- export function validateCloudSmokeMatrixEvidence(input: unknown): CloudSmokeMatrixEvidence;
168
-
169
- export function listCloudSmokePackageSourcePaths(options?: {
170
- root?: string;
171
- readFileSync?: typeof import("node:fs").readFileSync;
172
- lstatSync?: typeof import("node:fs").lstatSync;
173
- readdirSync?: typeof import("node:fs").readdirSync;
174
- }): string[];
175
-
176
- export function buildCloudSmokeEvidenceProvenance(options?: {
177
- root?: string;
178
- packageSourcePaths?: readonly string[];
179
- gitRevision?: string;
180
- readFileSync?: typeof import("node:fs").readFileSync;
181
- lstatSync?: typeof import("node:fs").lstatSync;
182
- readdirSync?: typeof import("node:fs").readdirSync;
183
- spawnSync?: typeof import("node:child_process").spawnSync;
184
- env?: NodeJS.ProcessEnv;
185
- timeoutMs?: number;
186
- }): CloudSmokeEvidenceProvenance;
187
-
188
- export function coordinateCloudSmokeReleaseGate(callbacks: {
189
- throwIfInterrupted?: () => void;
190
- run: (state: CloudSmokeReleaseGateState) => void | Promise<void>;
191
- harvestAgentIds: (state: CloudSmokeReleaseGateState) => Iterable<string> | Promise<Iterable<string>>;
192
- cleanupAgent: (agentId: string) => CloudSmokeCleanupEvidence | Promise<CloudSmokeCleanupEvidence>;
193
- cleanupRepository?: (repository: NonNullable<CloudSmokeReleaseGateState["repository"]>) =>
194
- | { deleted: true; httpStatus: 404 }
195
- | Promise<{ deleted: true; httpStatus: 404 }>;
196
- writeEvidence: (input: {
197
- lanes: unknown[];
198
- cleanup: CloudSmokeCleanupEvidence[];
199
- throwawayRepository?: { name: string; deleted: boolean; httpStatus?: number };
200
- repository?: CloudSmokeReleaseGateState["repository"];
201
- }) => void | Promise<void>;
202
- onAgentCleanupError?: (error: unknown, agentId: string) => void;
203
- onRepositoryCleanupError?: (error: unknown, repository: NonNullable<CloudSmokeReleaseGateState["repository"]>) => void;
204
- }): Promise<{
205
- lanes: unknown[];
206
- cleanup: CloudSmokeCleanupEvidence[];
207
- throwawayRepository?: { name: string; deleted: boolean; httpStatus?: number };
208
- repository?: CloudSmokeReleaseGateState["repository"];
209
- }>;