@cursor/july 0.1.20 → 0.1.21

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 (212) hide show
  1. package/dist/bin/agent-serve.js +0 -0
  2. package/dist/channels/github/instrument.d.ts +20 -0
  3. package/dist/channels/github/instrument.d.ts.map +1 -0
  4. package/dist/channels/slack/api.d.ts +2 -0
  5. package/dist/channels/slack/api.d.ts.map +1 -1
  6. package/dist/channels/slack/api.js +3 -0
  7. package/dist/channels/slack/bot-mentions.d.ts +106 -0
  8. package/dist/channels/slack/bot-mentions.d.ts.map +1 -0
  9. package/dist/channels/slack/bot-mentions.js +243 -0
  10. package/dist/channels/slack/dispatch.d.ts +6 -0
  11. package/dist/channels/slack/dispatch.d.ts.map +1 -1
  12. package/dist/channels/slack/dispatch.js +24 -3
  13. package/dist/channels/slack/inbound.d.ts +10 -1
  14. package/dist/channels/slack/inbound.d.ts.map +1 -1
  15. package/dist/channels/slack/inbound.js +12 -4
  16. package/dist/channels/slack/index.d.ts +1 -0
  17. package/dist/channels/slack/index.d.ts.map +1 -1
  18. package/dist/channels/slack/index.js +1 -0
  19. package/dist/channels/slack/slack-channel.d.ts.map +1 -1
  20. package/dist/channels/slack/slack-channel.js +61 -22
  21. package/dist/channels/slack/types.d.ts +58 -0
  22. package/dist/channels/slack/types.d.ts.map +1 -1
  23. package/dist/docs/404.html +1 -1
  24. package/dist/docs/ab.html +2 -2
  25. package/dist/docs/assets/{app.T-5ImnM3.js → app.jDxLzWv4.js} +1 -1
  26. package/dist/docs/assets/chunks/@localSearchIndexroot.DoJHJjqF.js +1 -0
  27. package/dist/docs/assets/chunks/{VPLocalSearchBox.OMGMWH6H.js → VPLocalSearchBox.Y6bDR1-a.js} +1 -1
  28. package/dist/docs/assets/chunks/{theme.DLg4yB4D.js → theme.CLazCWlJ.js} +2 -2
  29. package/dist/docs/building-with-agents.html +2 -2
  30. package/dist/docs/concepts.html +2 -2
  31. package/dist/docs/deployment.html +2 -2
  32. package/dist/docs/evals.html +2 -2
  33. package/dist/docs/example-agents/approval-buddy.html +2 -2
  34. package/dist/docs/example-agents/benny.html +2 -2
  35. package/dist/docs/example-agents/bugbot.html +2 -2
  36. package/dist/docs/example-agents/codebase-wiki.html +2 -2
  37. package/dist/docs/example-agents/codeowners-review.html +2 -2
  38. package/dist/docs/example-agents/concierge.html +2 -2
  39. package/dist/docs/example-agents/fsd.html +2 -2
  40. package/dist/docs/example-agents/index.html +2 -2
  41. package/dist/docs/example-agents/knowledge-base.html +2 -2
  42. package/dist/docs/example-agents/oncall.html +2 -2
  43. package/dist/docs/example-agents/security-reviewer.html +2 -2
  44. package/dist/docs/example-agents/slack-agent.html +2 -2
  45. package/dist/docs/example-agents/weather-agent.html +2 -2
  46. package/dist/docs/guides/agent-to-agent.html +2 -2
  47. package/dist/docs/guides/cloud-runtime.html +2 -2
  48. package/dist/docs/guides/github.html +2 -2
  49. package/dist/docs/guides/human-in-the-loop.html +2 -2
  50. package/dist/docs/guides/mcp-oauth.html +2 -2
  51. package/dist/docs/guides/slack.html +2 -2
  52. package/dist/docs/guides/webhooks.html +2 -2
  53. package/dist/docs/hillclimbing.html +2 -2
  54. package/dist/docs/index.html +2 -2
  55. package/dist/docs/quickstart.html +2 -2
  56. package/dist/docs/reference/agent-config.html +2 -2
  57. package/dist/docs/reference/channels.html +2 -2
  58. package/dist/docs/reference/cli.html +2 -2
  59. package/dist/docs/reference/connections.html +2 -2
  60. package/dist/docs/reference/hooks.html +2 -2
  61. package/dist/docs/reference/http-api.html +2 -2
  62. package/dist/docs/reference/instructions.html +2 -2
  63. package/dist/docs/reference/playground.html +2 -2
  64. package/dist/docs/reference/project-layout.html +2 -2
  65. package/dist/docs/reference/prompt.html +2 -2
  66. package/dist/docs/reference/schedules.html +2 -2
  67. package/dist/docs/reference/sessions.html +2 -2
  68. package/dist/docs/reference/skills.html +2 -2
  69. package/dist/docs/reference/subagents.html +2 -2
  70. package/dist/docs/reference/tools.html +2 -2
  71. package/dist/docs/scaffolding-agents.html +2 -2
  72. package/dist/docs/storage.html +2 -2
  73. package/dist/docs/troubleshooting.html +2 -2
  74. package/dist/internal/json-dir-store.d.ts +32 -0
  75. package/dist/internal/json-dir-store.d.ts.map +1 -0
  76. package/dist/internal/json-dir-store.js +100 -0
  77. package/dist/internal/resolved-connections.d.ts +1 -1
  78. package/dist/internal/resolved-connections.d.ts.map +1 -1
  79. package/dist/internal/resolved-connections.js +10 -0
  80. package/dist/internal/session-engine.d.ts +4 -1
  81. package/dist/internal/session-engine.d.ts.map +1 -1
  82. package/dist/internal/session-engine.js +13 -2
  83. package/dist/playground/assets/index-CjOQ4hN9.css +1 -0
  84. package/dist/playground/assets/index-dshZQJCp.js +85 -0
  85. package/dist/playground/index.html +2 -2
  86. package/dist/types.d.ts +7 -0
  87. package/dist/types.d.ts.map +1 -1
  88. package/dist/types.js +9 -0
  89. package/package.json +24 -24
  90. package/src/bin/agent-serve.version.test.ts +62 -0
  91. package/src/channels/github/api.test.ts +64 -0
  92. package/src/channels/github/auth.test.ts +105 -0
  93. package/src/channels/github/cursor-account.test.ts +204 -0
  94. package/src/channels/github/forward.test.ts +457 -0
  95. package/src/channels/github/github.test.ts +937 -0
  96. package/src/channels/github/replay.test.ts +179 -0
  97. package/src/channels/slack/api.post-message.test.ts +148 -0
  98. package/src/channels/slack/api.ts +5 -0
  99. package/src/channels/slack/approvals.test.ts +328 -0
  100. package/src/channels/slack/block-actions.test.ts +452 -0
  101. package/src/channels/slack/bot-mentions.test.ts +217 -0
  102. package/src/channels/slack/bot-mentions.ts +315 -0
  103. package/src/channels/slack/channel-watch.test.ts +363 -0
  104. package/src/channels/slack/cursor-account.test.ts +253 -0
  105. package/src/channels/slack/defaults.final-post.test.ts +182 -0
  106. package/src/channels/slack/dispatch.test.ts +795 -0
  107. package/src/channels/slack/dispatch.ts +27 -1
  108. package/src/channels/slack/eval-directive.test.ts +273 -0
  109. package/src/channels/slack/inbound.ts +25 -4
  110. package/src/channels/slack/index.ts +1 -0
  111. package/src/channels/slack/message-body.test.ts +54 -0
  112. package/src/channels/slack/nudge-store.test.ts +143 -0
  113. package/src/channels/slack/slack-channel.ts +66 -8
  114. package/src/channels/slack/slack.test.ts +391 -0
  115. package/src/channels/slack/stop.test.ts +23 -0
  116. package/src/channels/slack/thread-context.test.ts +202 -0
  117. package/src/channels/slack/types.ts +60 -0
  118. package/src/evals/assertions.test.ts +580 -0
  119. package/src/evals/expect.test.ts +144 -0
  120. package/src/evals/judge.test.ts +181 -0
  121. package/src/evals/loaders.test.ts +132 -0
  122. package/src/evals/matchers.test.ts +95 -0
  123. package/src/evals/reporters.test.ts +303 -0
  124. package/src/evals/run-facts.test.ts +259 -0
  125. package/src/internal/ab-snapshot.test.ts +325 -0
  126. package/src/internal/approval-gate.test.ts +49 -0
  127. package/src/internal/approvals.integration.test.ts +383 -0
  128. package/src/internal/authored-loaders.test.ts +31 -0
  129. package/src/internal/builtin-tools/reminders.test.ts +201 -0
  130. package/src/internal/channel-route-schema.test.ts +294 -0
  131. package/src/internal/chat-attach.test.ts +262 -0
  132. package/src/internal/cli-deploy.test.ts +1991 -0
  133. package/src/internal/cli-mcp.test.ts +789 -0
  134. package/src/internal/cli-skills.test.ts +133 -0
  135. package/src/internal/cli-slack.test.ts +1647 -0
  136. package/src/internal/cloud-merge.test.ts +74 -0
  137. package/src/internal/cron.test.ts +22 -0
  138. package/src/internal/cursor/account-mcp.test.ts +807 -0
  139. package/src/internal/cursor/backend-client.test.ts +591 -0
  140. package/src/internal/cursor/credentials.test.ts +351 -0
  141. package/src/internal/cursor/github-credentials.test.ts +136 -0
  142. package/src/internal/cursor-account-mcp-auth.test.ts +310 -0
  143. package/src/internal/cursor-account.integration.test.ts +441 -0
  144. package/src/internal/cursor-event-relay.test.ts +746 -0
  145. package/src/internal/cursor-github-credentials.integration.test.ts +271 -0
  146. package/src/internal/cursor-slack-relay.test.ts +525 -0
  147. package/src/internal/deploy-source.test.ts +111 -0
  148. package/src/internal/discovery.builtin-tools.test.ts +94 -0
  149. package/src/internal/discovery.concurrency.test.ts +60 -0
  150. package/src/internal/discovery.cursor-account.test.ts +133 -0
  151. package/src/internal/discovery.cwd.test.ts +83 -0
  152. package/src/internal/discovery.hosting.test.ts +80 -0
  153. package/src/internal/discovery.identity.test.ts +44 -0
  154. package/src/internal/docs-site.test.ts +66 -0
  155. package/src/internal/duration.test.ts +29 -0
  156. package/src/internal/eval-judge-model.test.ts +187 -0
  157. package/src/internal/eval-run-store.cancel.test.ts +142 -0
  158. package/src/internal/eval-run-store.storage.test.ts +211 -0
  159. package/src/internal/eval-runner.http.test.ts +403 -0
  160. package/src/internal/eval-runner.run.test.ts +928 -0
  161. package/src/internal/evals-client.test.ts +307 -0
  162. package/src/internal/event-mapper.test.ts +243 -0
  163. package/src/internal/github-fanout.test.ts +213 -0
  164. package/src/internal/handleAgentServeTrigger.test.ts +179 -0
  165. package/src/internal/host-kv.test.ts +82 -0
  166. package/src/internal/host-platforms.test.ts +126 -0
  167. package/src/internal/http-channel.test.ts +402 -0
  168. package/src/internal/init-project.test.ts +269 -0
  169. package/src/internal/install-cursor-skills.test.ts +262 -0
  170. package/src/internal/local-env.test.ts +100 -0
  171. package/src/internal/log-ring.test.ts +31 -0
  172. package/src/internal/logs-client.test.ts +350 -0
  173. package/src/internal/mcp-endpoint.test.ts +436 -0
  174. package/src/internal/mcp-host.test.ts +298 -0
  175. package/src/internal/mcp-oauth.test.ts +148 -0
  176. package/src/internal/net.test.ts +17 -0
  177. package/src/internal/peer-connections.test.ts +128 -0
  178. package/src/internal/peer-mcp.integration.test.ts +289 -0
  179. package/src/internal/playground/toolchain.test.ts +53 -0
  180. package/src/internal/playground-cli.test.ts +187 -0
  181. package/src/internal/playground-proxy.test.ts +376 -0
  182. package/src/internal/prompt-context.integration.test.ts +232 -0
  183. package/src/internal/prompt-context.test.ts +127 -0
  184. package/src/internal/reminder-runner.test.ts +390 -0
  185. package/src/internal/reminder-store.test.ts +53 -0
  186. package/src/internal/request-headers.test.ts +27 -0
  187. package/src/internal/resolve-prod-target.test.ts +787 -0
  188. package/src/internal/resolved-connections.test.ts +295 -0
  189. package/src/internal/resolved-connections.ts +18 -1
  190. package/src/internal/router.test.ts +57 -0
  191. package/src/internal/sdk-runner.test.ts +290 -0
  192. package/src/internal/session-engine.coalesce.test.ts +169 -0
  193. package/src/internal/session-engine.concurrency.test.ts +250 -0
  194. package/src/internal/session-engine.host-oauth-mcp.test.ts +110 -0
  195. package/src/internal/session-engine.interrupt.test.ts +577 -0
  196. package/src/internal/session-engine.storage.test.ts +547 -0
  197. package/src/internal/session-engine.ts +15 -1
  198. package/src/internal/session-urls.test.ts +28 -0
  199. package/src/internal/sessions-client.test.ts +518 -0
  200. package/src/internal/storage-coordinator.test.ts +517 -0
  201. package/src/internal/tool-call.test.ts +458 -0
  202. package/src/internal/tool-result.test.ts +52 -0
  203. package/src/internal/trajectory.approvals.test.ts +83 -0
  204. package/src/internal/trajectory.subagents.test.ts +198 -0
  205. package/src/internal/turn-governor.test.ts +137 -0
  206. package/src/internal/update-check.test.ts +485 -0
  207. package/src/internal/workspace.test.ts +81 -0
  208. package/src/storage-backends/cursor-hosted.test.ts +121 -0
  209. package/src/types.ts +12 -0
  210. package/dist/docs/assets/chunks/@localSearchIndexroot.CvejISXF.js +0 -1
  211. package/dist/playground/assets/index-CidizGZv.css +0 -1
  212. package/dist/playground/assets/index-CuiAKZaP.js +0 -85
@@ -0,0 +1,262 @@
1
+ import { mkdir, mkdtemp, readFile, writeFile } from "node:fs/promises";
2
+ import { homedir, tmpdir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { PassThrough } from "node:stream";
5
+ import { describe, expect, it } from "vitest";
6
+ import { packageRootDir } from "./distribution.js";
7
+ import {
8
+ agentkitCursorSkillsDir,
9
+ cursorSkillsHome,
10
+ findMissingCursorSkills,
11
+ installCursorSkills,
12
+ listShippedPackageSkills,
13
+ offerInstallCursorSkills,
14
+ prepareSkillMarkdownForCursorInstall,
15
+ promptYesNo,
16
+ skillInstallPath,
17
+ } from "./install-cursor-skills.js";
18
+
19
+ async function makeTempDir(prefix: string): Promise<string> {
20
+ return mkdtemp(join(tmpdir(), prefix));
21
+ }
22
+
23
+ describe("listShippedPackageSkills", () => {
24
+ it("lists published package skills and skips operate", async () => {
25
+ const skills = await listShippedPackageSkills(packageRootDir());
26
+ const names = skills.map((skill) => skill.name);
27
+ const leaves = skills.map((skill) => skill.leafDir);
28
+
29
+ expect(names).toContain("agentkit-create-agent");
30
+ expect(names).toContain("agentkit-debug");
31
+ expect(leaves).toContain("create-agent");
32
+ expect(leaves).toContain("debug");
33
+ expect(names).not.toContain("agentkit-operate");
34
+ expect(leaves).not.toContain("operate");
35
+ });
36
+ });
37
+
38
+ describe("findMissingCursorSkills / installCursorSkills", () => {
39
+ it("installs under ~/.cursor/skills/agentkit/<leaf>", async () => {
40
+ const home = await makeTempDir("agentkit-skills-home-");
41
+ const missing = await findMissingCursorSkills({
42
+ packageRoot: packageRootDir(),
43
+ skillsHome: home,
44
+ });
45
+ expect(missing.length).toBeGreaterThan(0);
46
+
47
+ const { installed } = await installCursorSkills(missing.slice(0, 2), home);
48
+ expect(installed).toHaveLength(2);
49
+
50
+ for (const leaf of installed) {
51
+ const body = await readFile(
52
+ join(home, "agentkit", leaf, "SKILL.md"),
53
+ "utf8"
54
+ );
55
+ expect(body).toContain("name: agentkit-");
56
+ }
57
+
58
+ const stillMissing = await findMissingCursorSkills({
59
+ packageRoot: packageRootDir(),
60
+ skillsHome: home,
61
+ });
62
+ expect(stillMissing.map((skill) => skill.leafDir)).not.toContain(
63
+ installed[0]
64
+ );
65
+ });
66
+
67
+ it("treats an existing SKILL.md under agentkit/ as installed", async () => {
68
+ const home = await makeTempDir("agentkit-skills-present-");
69
+ const skills = await listShippedPackageSkills(packageRootDir());
70
+ const first = skills[0];
71
+ expect(first).toBeDefined();
72
+ const target = skillInstallPath(first!, home);
73
+ await mkdir(target, { recursive: true });
74
+ await writeFile(join(target, "SKILL.md"), "---\nname: x\n---\n");
75
+
76
+ const missing = await findMissingCursorSkills({
77
+ packageRoot: packageRootDir(),
78
+ skillsHome: home,
79
+ });
80
+ expect(missing.map((skill) => skill.leafDir)).not.toContain(first!.leafDir);
81
+ });
82
+
83
+ it("strips monorepo paths from installed SKILL.md", async () => {
84
+ const home = await makeTempDir("agentkit-skills-paths-");
85
+ const skills = await listShippedPackageSkills(packageRootDir());
86
+ const createAgent = skills.find((s) => s.leafDir === "create-agent");
87
+ expect(createAgent).toBeDefined();
88
+ await installCursorSkills([createAgent!], home);
89
+ const body = await readFile(
90
+ join(home, "agentkit", "create-agent", "SKILL.md"),
91
+ "utf8"
92
+ );
93
+ const frontmatter = body.match(/^---\r?\n([\s\S]*?)\r?\n---/)?.[1] ?? "";
94
+ expect(frontmatter).not.toContain("paths:");
95
+ });
96
+
97
+ it("removes orphan leaf dirs under agentkit/ and reports them", async () => {
98
+ const home = await makeTempDir("agentkit-skills-orphan-");
99
+ const skills = await listShippedPackageSkills(packageRootDir());
100
+ const first = skills[0]!;
101
+ await installCursorSkills([first], home);
102
+ const orphan = join(home, "agentkit", "removed-skill");
103
+ await mkdir(orphan, { recursive: true });
104
+ await writeFile(join(orphan, "SKILL.md"), "---\nname: x\n---\n");
105
+
106
+ const { removed } = await installCursorSkills(skills, home);
107
+ expect(removed).toEqual(["removed-skill"]);
108
+ await expect(readFile(join(orphan, "SKILL.md"), "utf8")).rejects.toThrow();
109
+ });
110
+ });
111
+
112
+ describe("offerInstallCursorSkills", () => {
113
+ it("skips when interactive is false", async () => {
114
+ const home = await makeTempDir("agentkit-skills-offer-");
115
+ const lines: string[] = [];
116
+ const result = await offerInstallCursorSkills({
117
+ interactive: false,
118
+ skillsHome: home,
119
+ packageRoot: packageRootDir(),
120
+ out: (text) => lines.push(text),
121
+ });
122
+ expect(result).toEqual({ installed: [], skipped: true });
123
+ expect(lines).toEqual([]);
124
+ });
125
+
126
+ it("installs after confirmation into the agentkit namespace", async () => {
127
+ const home = await makeTempDir("agentkit-skills-confirm-");
128
+ const lines: string[] = [];
129
+ const result = await offerInstallCursorSkills({
130
+ interactive: true,
131
+ skillsHome: home,
132
+ packageRoot: packageRootDir(),
133
+ confirm: async () => true,
134
+ out: (text) => lines.push(text),
135
+ });
136
+ expect(result.skipped).toBe(false);
137
+ expect(result.installed.length).toBeGreaterThan(0);
138
+ expect(lines.join("")).toContain("Installed");
139
+ expect(lines.join("")).toContain(
140
+ ` location: ${agentkitCursorSkillsDir(home)}`
141
+ );
142
+ });
143
+
144
+ it("overwrites existing skills on update", async () => {
145
+ const home = await makeTempDir("agentkit-skills-overwrite-");
146
+ const skills = await listShippedPackageSkills(packageRootDir());
147
+ const first = skills[0]!;
148
+ const target = skillInstallPath(first, home);
149
+ await mkdir(target, { recursive: true });
150
+ await writeFile(join(target, "SKILL.md"), "---\nname: stale\n---\nstale\n");
151
+
152
+ const lines: string[] = [];
153
+ const result = await offerInstallCursorSkills({
154
+ interactive: true,
155
+ skillsHome: home,
156
+ packageRoot: packageRootDir(),
157
+ confirm: async () => true,
158
+ out: (text) => lines.push(text),
159
+ });
160
+ expect(result.skipped).toBe(false);
161
+ expect(result.installed).toContain(first.leafDir);
162
+ expect(lines.join("")).toContain("Update");
163
+ expect(lines.join("")).toContain("overwrites");
164
+ const body = await readFile(join(target, "SKILL.md"), "utf8");
165
+ expect(body).toContain(`name: ${first.name}`);
166
+ expect(body).not.toContain("stale");
167
+ });
168
+
169
+ it("skips install when the user declines", async () => {
170
+ const home = await makeTempDir("agentkit-skills-decline-");
171
+ const lines: string[] = [];
172
+ const result = await offerInstallCursorSkills({
173
+ interactive: true,
174
+ skillsHome: home,
175
+ packageRoot: packageRootDir(),
176
+ confirm: async () => false,
177
+ out: (text) => lines.push(text),
178
+ });
179
+ expect(result).toEqual({ installed: [], skipped: true });
180
+ expect(lines.join("")).toContain(
181
+ `install-skills (${agentkitCursorSkillsDir(home)})`
182
+ );
183
+ const missing = await findMissingCursorSkills({
184
+ packageRoot: packageRootDir(),
185
+ skillsHome: home,
186
+ });
187
+ expect(missing.length).toBeGreaterThan(0);
188
+ });
189
+
190
+ it("skips install when the prompt goes unanswered", async () => {
191
+ const home = await makeTempDir("agentkit-skills-timeout-");
192
+ const lines: string[] = [];
193
+ const result = await offerInstallCursorSkills({
194
+ interactive: true,
195
+ skillsHome: home,
196
+ packageRoot: packageRootDir(),
197
+ confirm: async () => undefined,
198
+ out: (text) => lines.push(text),
199
+ });
200
+ expect(result).toEqual({ installed: [], skipped: true });
201
+ expect(lines.join("")).toContain("No answer");
202
+ expect(lines.join("")).toContain("install-skills");
203
+ const missing = await findMissingCursorSkills({
204
+ packageRoot: packageRootDir(),
205
+ skillsHome: home,
206
+ });
207
+ expect(missing.length).toBeGreaterThan(0);
208
+ });
209
+ });
210
+
211
+ describe("promptYesNo", () => {
212
+ // init prompts for login right after the skills offer, so a timed-out
213
+ // prompt has to leave the stream readable.
214
+ it("gives up when nobody answers, and the next prompt still reads", async () => {
215
+ const input = new PassThrough();
216
+ const timedOut = await promptYesNo("Install now?", {
217
+ defaultYes: true,
218
+ out: () => {},
219
+ timeoutMs: 20,
220
+ input,
221
+ });
222
+ expect(timedOut).toBeUndefined();
223
+ expect(input.listenerCount("data")).toBe(0);
224
+
225
+ const pending = promptYesNo("Sign in?", {
226
+ defaultYes: true,
227
+ out: () => {},
228
+ timeoutMs: 5_000,
229
+ input,
230
+ });
231
+ input.write("n\n");
232
+ expect(await pending).toBe(false);
233
+ });
234
+ });
235
+
236
+ describe("cursorSkillsHome", () => {
237
+ it("resolves the skills root and agentkit namespace", () => {
238
+ expect(cursorSkillsHome("/tmp/home")).toBe("/tmp/home/.cursor/skills");
239
+ expect(agentkitCursorSkillsDir("/tmp/home/.cursor/skills")).toBe(
240
+ "/tmp/home/.cursor/skills/agentkit"
241
+ );
242
+ });
243
+
244
+ it("uses homedir when HOME is empty", () => {
245
+ expect(cursorSkillsHome("")).toBe(join(homedir(), ".cursor", "skills"));
246
+ });
247
+ });
248
+
249
+ describe("prepareSkillMarkdownForCursorInstall", () => {
250
+ it("removes paths and rewrites monorepo doc links", () => {
251
+ const input = `---
252
+ name: test
253
+ paths:
254
+ - packages/agent-serve/**/*
255
+ ---
256
+ See [\`docs/ab.md\`](../../docs/ab.md).
257
+ `;
258
+ const out = prepareSkillMarkdownForCursorInstall(input);
259
+ expect(out).not.toContain("paths:");
260
+ expect(out).toContain("docs/ab.md in the @cursor/july package");
261
+ });
262
+ });
@@ -0,0 +1,100 @@
1
+ import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
2
+ import { tmpdir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { afterEach, describe, expect, it } from "vitest";
5
+ import { loadAgentLocalEnv } from "./local-env.js";
6
+
7
+ const tempDirs: string[] = [];
8
+ const setKeys: string[] = [];
9
+
10
+ afterEach(async () => {
11
+ while (tempDirs.length > 0) {
12
+ const dir = tempDirs.pop();
13
+ if (dir !== undefined) {
14
+ await rm(dir, { recursive: true, force: true });
15
+ }
16
+ }
17
+ while (setKeys.length > 0) {
18
+ const key = setKeys.pop();
19
+ if (key !== undefined) {
20
+ delete process.env[key];
21
+ }
22
+ }
23
+ });
24
+
25
+ async function makeDir(): Promise<string> {
26
+ const dir = await mkdtemp(join(tmpdir(), "agentkit-local-env-"));
27
+ tempDirs.push(dir);
28
+ return dir;
29
+ }
30
+
31
+ describe("loadAgentLocalEnv", () => {
32
+ it("loads the root and immediate-child .env.local files", async () => {
33
+ const dir = await makeDir();
34
+ await writeFile(join(dir, ".env.local"), "LOCALENV_ROOT=root\n");
35
+ await mkdir(join(dir, "child-agent"));
36
+ await writeFile(
37
+ join(dir, "child-agent", ".env.local"),
38
+ "LOCALENV_CHILD=child\n"
39
+ );
40
+ await mkdir(join(dir, "node_modules"));
41
+ await writeFile(
42
+ join(dir, "node_modules", ".env.local"),
43
+ "LOCALENV_NODE_MODULES=nope\n"
44
+ );
45
+ setKeys.push("LOCALENV_ROOT", "LOCALENV_CHILD", "LOCALENV_NODE_MODULES");
46
+
47
+ const loaded = loadAgentLocalEnv(dir);
48
+
49
+ expect(loaded).toEqual([
50
+ join(dir, ".env.local"),
51
+ join(dir, "child-agent", ".env.local"),
52
+ ]);
53
+ expect(process.env.LOCALENV_ROOT).toBe("root");
54
+ expect(process.env.LOCALENV_CHILD).toBe("child");
55
+ expect(process.env.LOCALENV_NODE_MODULES).toBeUndefined();
56
+ });
57
+
58
+ it("never overrides real environment variables", async () => {
59
+ const dir = await makeDir();
60
+ await writeFile(join(dir, ".env.local"), "LOCALENV_PRECEDENCE=fromfile\n");
61
+ setKeys.push("LOCALENV_PRECEDENCE");
62
+ process.env.LOCALENV_PRECEDENCE = "fromreal";
63
+
64
+ loadAgentLocalEnv(dir);
65
+
66
+ expect(process.env.LOCALENV_PRECEDENCE).toBe("fromreal");
67
+ });
68
+
69
+ it("picks up a value edited since the previous load", async () => {
70
+ const dir = await makeDir();
71
+ await writeFile(join(dir, ".env.local"), "LOCALENV_ROTATED=first\n");
72
+ setKeys.push("LOCALENV_ROTATED");
73
+
74
+ loadAgentLocalEnv(dir);
75
+ expect(process.env.LOCALENV_ROTATED).toBe("first");
76
+
77
+ await writeFile(join(dir, ".env.local"), "LOCALENV_ROTATED=second\n");
78
+ loadAgentLocalEnv(dir);
79
+
80
+ expect(process.env.LOCALENV_ROTATED).toBe("second");
81
+ });
82
+
83
+ it("still lets real env win on a reload", async () => {
84
+ const dir = await makeDir();
85
+ await writeFile(join(dir, ".env.local"), "LOCALENV_REAL_WINS=fromfile\n");
86
+ setKeys.push("LOCALENV_REAL_WINS");
87
+ process.env.LOCALENV_REAL_WINS = "fromreal";
88
+
89
+ loadAgentLocalEnv(dir);
90
+ loadAgentLocalEnv(dir);
91
+
92
+ expect(process.env.LOCALENV_REAL_WINS).toBe("fromreal");
93
+ });
94
+
95
+ it("returns empty for directories without env files", async () => {
96
+ const dir = await makeDir();
97
+ expect(loadAgentLocalEnv(dir)).toEqual([]);
98
+ expect(loadAgentLocalEnv(join(dir, "missing"))).toEqual([]);
99
+ });
100
+ });
@@ -0,0 +1,31 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { createLogRing } from "./log-ring.js";
3
+
4
+ describe("createLogRing", () => {
5
+ it("forwards to the inner logger and retains entries", () => {
6
+ const seen: string[] = [];
7
+ const ring = createLogRing({ capacity: 10 });
8
+ const log = ring.wrap((line) => {
9
+ seen.push(line);
10
+ });
11
+ log("one");
12
+ log("two");
13
+ expect(seen).toEqual(["one", "two"]);
14
+ const all = ring.since(-1);
15
+ expect(all.map((e) => e.line)).toEqual(["one", "two"]);
16
+ expect(all[0]?.index).toBe(0);
17
+ expect(all[1]?.index).toBe(1);
18
+ });
19
+
20
+ it("respects capacity and since(after)", () => {
21
+ const ring = createLogRing({ capacity: 3 });
22
+ const log = ring.wrap(() => {});
23
+ log("a");
24
+ log("b");
25
+ log("c");
26
+ log("d");
27
+ expect(ring.since(-1).map((e) => e.line)).toEqual(["b", "c", "d"]);
28
+ expect(ring.since(1).map((e) => e.line)).toEqual(["c", "d"]);
29
+ expect(ring.since(99)).toEqual([]);
30
+ });
31
+ });