@cursor/july 0.1.8 → 0.1.9

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 (119) hide show
  1. package/dist/bin/agent-serve.js +0 -0
  2. package/dist/channels/slack/post-update-delivery.d.ts +85 -0
  3. package/dist/channels/slack/post-update-delivery.d.ts.map +1 -0
  4. package/dist/channels/slack/post-update-delivery.js +318 -0
  5. package/dist/docs/404.html +2 -2
  6. package/dist/docs/ab.html +3 -3
  7. package/dist/docs/assets/{app.BP8mAVMW.js → app.Ciosf24M.js} +1 -1
  8. package/dist/docs/assets/chunks/@localSearchIndexroot.D154Detj.js +1 -0
  9. package/dist/docs/assets/chunks/{VPLocalSearchBox.1FXIZbz8.js → VPLocalSearchBox.BcRDly7n.js} +1 -1
  10. package/dist/docs/assets/chunks/{theme.Dm1R02v9.js → theme.CMpbjdfx.js} +2 -2
  11. package/dist/docs/assets/{deployment.md.BtfEsc9S.js → deployment.md.DC5-ImcM.js} +1 -1
  12. package/dist/docs/assets/{example-agents_approval-buddy.md.8R5phXb5.js → example-agents_approval-buddy.md.DFGBYLcc.js} +2 -2
  13. package/dist/docs/assets/{example-agents_approval-buddy.md.8R5phXb5.lean.js → example-agents_approval-buddy.md.DFGBYLcc.lean.js} +1 -1
  14. package/dist/docs/assets/{example-agents_index.md.CwtWu5ix.js → example-agents_index.md.BPXjUtRB.js} +2 -2
  15. package/dist/docs/assets/{example-agents_index.md.CwtWu5ix.lean.js → example-agents_index.md.BPXjUtRB.lean.js} +1 -1
  16. package/dist/docs/assets/{example-agents_security-reviewer.md.D2rtwDTO.js → example-agents_security-reviewer.md.CE9v-aKm.js} +2 -2
  17. package/dist/docs/assets/{example-agents_security-reviewer.md.D2rtwDTO.lean.js → example-agents_security-reviewer.md.CE9v-aKm.lean.js} +1 -1
  18. package/dist/docs/assets/{storage.md.Cu3MwM2a.js → storage.md.DRTdnFvd.js} +7 -1
  19. package/dist/docs/assets/{storage.md.Cu3MwM2a.lean.js → storage.md.DRTdnFvd.lean.js} +1 -1
  20. package/dist/docs/building-with-agents.html +3 -3
  21. package/dist/docs/concepts.html +3 -3
  22. package/dist/docs/deployment.html +5 -5
  23. package/dist/docs/evals.html +3 -3
  24. package/dist/docs/example-agents/approval-buddy.html +5 -5
  25. package/dist/docs/example-agents/benny.html +3 -3
  26. package/dist/docs/example-agents/bugbot.html +3 -3
  27. package/dist/docs/example-agents/codebase-wiki.html +3 -3
  28. package/dist/docs/example-agents/codeowners-review.html +3 -3
  29. package/dist/docs/example-agents/concierge.html +3 -3
  30. package/dist/docs/example-agents/fsd.html +3 -3
  31. package/dist/docs/example-agents/index.html +5 -5
  32. package/dist/docs/example-agents/knowledge-base.html +3 -3
  33. package/dist/docs/example-agents/oncall.html +3 -3
  34. package/dist/docs/example-agents/security-reviewer.html +6 -6
  35. package/dist/docs/example-agents/slack-agent.html +3 -3
  36. package/dist/docs/example-agents/weather-agent.html +3 -3
  37. package/dist/docs/guides/agent-to-agent.html +3 -3
  38. package/dist/docs/guides/cloud-runtime.html +3 -3
  39. package/dist/docs/guides/github.html +3 -3
  40. package/dist/docs/guides/human-in-the-loop.html +3 -3
  41. package/dist/docs/guides/slack.html +3 -3
  42. package/dist/docs/guides/webhooks.html +3 -3
  43. package/dist/docs/hashmap.json +1 -1
  44. package/dist/docs/hillclimbing.html +3 -3
  45. package/dist/docs/index.html +3 -3
  46. package/dist/docs/quickstart.html +3 -3
  47. package/dist/docs/reference/agent-config.html +3 -3
  48. package/dist/docs/reference/channels.html +3 -3
  49. package/dist/docs/reference/cli.html +3 -3
  50. package/dist/docs/reference/connections.html +3 -3
  51. package/dist/docs/reference/hooks.html +3 -3
  52. package/dist/docs/reference/http-api.html +3 -3
  53. package/dist/docs/reference/instructions.html +3 -3
  54. package/dist/docs/reference/playground.html +3 -3
  55. package/dist/docs/reference/project-layout.html +3 -3
  56. package/dist/docs/reference/schedules.html +3 -3
  57. package/dist/docs/reference/sessions.html +3 -3
  58. package/dist/docs/reference/skills.html +3 -3
  59. package/dist/docs/reference/subagents.html +3 -3
  60. package/dist/docs/reference/tools.html +3 -3
  61. package/dist/docs/scaffolding-agents.html +3 -3
  62. package/dist/docs/storage.html +11 -5
  63. package/dist/docs/troubleshooting.html +3 -3
  64. package/dist/internal/cli-deploy.d.ts.map +1 -1
  65. package/dist/internal/cli-deploy.js +45 -18
  66. package/dist/internal/deploy-client.d.ts +7 -1
  67. package/dist/internal/deploy-client.d.ts.map +1 -1
  68. package/dist/internal/deploy-client.js +3 -0
  69. package/dist/internal/deploy-source.d.ts +3 -0
  70. package/dist/internal/deploy-source.d.ts.map +1 -1
  71. package/dist/internal/deploy-source.js +25 -7
  72. package/dist/internal/discovery.js +1 -1
  73. package/dist/internal/distribution.d.ts.map +1 -1
  74. package/dist/internal/distribution.js +1 -0
  75. package/dist/internal/hosting.d.ts +12 -2
  76. package/dist/internal/hosting.d.ts.map +1 -1
  77. package/dist/internal/hosting.js +21 -4
  78. package/dist/internal/json-dir-store.d.ts +32 -0
  79. package/dist/internal/json-dir-store.d.ts.map +1 -0
  80. package/dist/internal/json-dir-store.js +100 -0
  81. package/dist/internal/logs-client.d.ts +16 -2
  82. package/dist/internal/logs-client.d.ts.map +1 -1
  83. package/dist/internal/logs-client.js +51 -16
  84. package/dist/internal/session-engine.d.ts.map +1 -1
  85. package/dist/internal/session-engine.js +29 -15
  86. package/dist/internal/workspace.d.ts +19 -0
  87. package/dist/internal/workspace.d.ts.map +1 -1
  88. package/dist/internal/workspace.js +47 -13
  89. package/dist/playground/assets/index-C0-QEG4O.js +86 -0
  90. package/dist/playground/assets/index-z3JY9O2x.css +1 -0
  91. package/dist/playground/index.html +2 -2
  92. package/dist/storage-backends/cursor-hosted.d.ts +65 -0
  93. package/dist/storage-backends/cursor-hosted.d.ts.map +1 -0
  94. package/dist/storage-backends/cursor-hosted.js +203 -0
  95. package/dist/storage-backends/postgres-kv.d.ts +5 -0
  96. package/dist/storage-backends/postgres-kv.d.ts.map +1 -1
  97. package/dist/storage-backends/postgres-kv.js +5 -0
  98. package/docs/.vitepress/cache/deps/package.json +3 -0
  99. package/docs/deployment.md +7 -3
  100. package/docs/example-agents/approval-buddy.md +1 -1
  101. package/docs/example-agents/index.md +1 -1
  102. package/docs/example-agents/security-reviewer.md +5 -5
  103. package/docs/storage.md +18 -4
  104. package/package.json +8 -1
  105. package/src/internal/cli-deploy.ts +58 -20
  106. package/src/internal/deploy-client.ts +11 -0
  107. package/src/internal/deploy-source.ts +24 -6
  108. package/src/internal/discovery.ts +1 -1
  109. package/src/internal/distribution.ts +1 -0
  110. package/src/internal/hosting.ts +24 -4
  111. package/src/internal/logs-client.ts +67 -21
  112. package/src/internal/session-engine.ts +28 -11
  113. package/src/internal/workspace.ts +48 -11
  114. package/src/storage-backends/cursor-hosted.ts +246 -0
  115. package/src/storage-backends/postgres-kv.ts +5 -0
  116. package/dist/docs/assets/chunks/@localSearchIndexroot.DevOabKJ.js +0 -1
  117. package/dist/playground/assets/index-7GJIUFQj.css +0 -1
  118. package/dist/playground/assets/index-Bpr4Th4M.js +0 -319
  119. /package/dist/docs/assets/{deployment.md.BtfEsc9S.lean.js → deployment.md.DC5-ImcM.lean.js} +0 -0
@@ -24,7 +24,9 @@ function isAborted(signal) {
24
24
  const PROGRESS_MESSAGES = {
25
25
  queued: "Waiting to start…",
26
26
  preparing: "Preparing runtime…",
27
- building: "Building and starting agent…",
27
+ creating: "Creating runtime…",
28
+ building: "Checking out source and installing dependencies…",
29
+ starting: "Starting agent and waiting for health…",
28
30
  finalizing: "Finishing deployment…",
29
31
  running: "Deployment running",
30
32
  failed: "Deploy failed",
@@ -32,7 +34,12 @@ const PROGRESS_MESSAGES = {
32
34
  stopped: "Deployment stopped",
33
35
  degraded: "Deployment degraded",
34
36
  };
35
- export function progressMessage(progress, lastError) {
37
+ /**
38
+ * Customer-facing line for the current deploy step. Prefer the live
39
+ * `statusMessage` from the API when present; otherwise the progress
40
+ * vocabulary. Failed/degraded always append sanitized `lastError`.
41
+ */
42
+ export function progressMessage(progress, lastError, statusMessage) {
36
43
  if (progress === "failed") {
37
44
  const detail = lastError === null || lastError === undefined || lastError.trim() === ""
38
45
  ? ""
@@ -45,6 +52,11 @@ export function progressMessage(progress, lastError) {
45
52
  : `: ${sanitizeCustomerError(lastError)}`;
46
53
  return `Deployment degraded${detail}`;
47
54
  }
55
+ if (statusMessage !== null &&
56
+ statusMessage !== undefined &&
57
+ statusMessage.trim() !== "") {
58
+ return statusMessage.trim();
59
+ }
48
60
  return PROGRESS_MESSAGES[progress];
49
61
  }
50
62
  /** Strip obvious hosting internals from error text shown to customers. */
@@ -56,7 +68,31 @@ export function sanitizeCustomerError(message) {
56
68
  .replace(/\bcursorvm\.com\b/gi, "host")
57
69
  .replace(/\bx-anyrun-[a-z0-9-]+\b/gi, "header")
58
70
  .replace(/\bPROVISIONING\b/g, "building")
59
- .replace(/\bPLANNED\b/g, "preparing");
71
+ .replace(/\bPLANNED\b/g, "preparing")
72
+ .replace(/\bgitCloneCheckout\b/gi, "git clone")
73
+ .replace(/\bgitFetchCheckout\b/gi, "git fetch")
74
+ .replace(/\bgitCheckout:clone\b/gi, "checkout")
75
+ .replace(/\bgitCheckout:fetch\b/gi, "checkout");
76
+ }
77
+ /**
78
+ * One-line label for `agentkit deploy` polling (TTY spinner / non-TTY
79
+ * transitions). Uses statusMessage → progress → raw status.
80
+ */
81
+ export function deployProgressLabel(detail) {
82
+ if (detail.statusMessage !== null &&
83
+ detail.statusMessage !== undefined &&
84
+ detail.statusMessage.trim() !== "") {
85
+ return detail.statusMessage
86
+ .trim()
87
+ .replace(/…$/, "")
88
+ .replace(/\.\.\.$/, "");
89
+ }
90
+ if (detail.progress !== undefined) {
91
+ return PROGRESS_MESSAGES[detail.progress]
92
+ .replace(/…$/, "")
93
+ .replace(/\.\.\.$/, "");
94
+ }
95
+ return detail.status;
60
96
  }
61
97
  export function fetchLogs(args) {
62
98
  return __awaiter(this, void 0, void 0, function* () {
@@ -139,7 +175,7 @@ function followProdLogs(args) {
139
175
  // cmdLogs (which wires deploy auth).
140
176
  throw new Error("Internal error: deploy progress requires a deployment lookup.");
141
177
  }));
142
- let lastProgress;
178
+ let lastEmittedKey;
143
179
  const slugHint = args.slug !== undefined && args.slug !== "" ? args.slug : "";
144
180
  if (args.once !== true) {
145
181
  const label = slugHint !== "" ? slugHint : "deployment";
@@ -157,27 +193,27 @@ function followProdLogs(args) {
157
193
  throw customerDeployLookupError(error);
158
194
  }
159
195
  const progress = resolveProgress(detail);
196
+ const message = progressMessage(progress, detail.lastError, detail.statusMessage);
197
+ const emitKey = `${progress}\0${message}`;
160
198
  if (progress === "failed") {
161
- const message = progressMessage(progress, detail.lastError);
162
- if (progress !== lastProgress) {
163
- lastProgress = progress;
199
+ if (emitKey !== lastEmittedKey) {
200
+ lastEmittedKey = emitKey;
164
201
  emitProgress(args.write, args.json === true, progress, message);
165
202
  }
166
203
  throw new Error(`Deployment "${detail.slug}" failed.`);
167
204
  }
168
205
  if (progress === "stopped") {
169
- const message = progressMessage(progress, detail.lastError);
170
- if (progress !== lastProgress) {
171
- lastProgress = progress;
206
+ if (emitKey !== lastEmittedKey) {
207
+ lastEmittedKey = emitKey;
172
208
  emitProgress(args.write, args.json === true, progress, message);
173
209
  }
174
210
  throw new Error(`Deployment "${detail.slug}" is stopped.`);
175
211
  }
176
212
  if (progress === "running" || progress === "degraded") {
177
213
  // Hand off to runtime logs. Print degraded once; skip a "running" line.
178
- if (progress === "degraded" && progress !== lastProgress) {
179
- lastProgress = progress;
180
- emitProgress(args.write, args.json === true, progress, progressMessage(progress, detail.lastError));
214
+ if (progress === "degraded" && emitKey !== lastEmittedKey) {
215
+ lastEmittedKey = emitKey;
216
+ emitProgress(args.write, args.json === true, progress, message);
181
217
  }
182
218
  const runtime = yield resolveRuntime();
183
219
  yield followRuntimeLogs({
@@ -196,9 +232,8 @@ function followProdLogs(args) {
196
232
  });
197
233
  return;
198
234
  }
199
- const message = progressMessage(progress, detail.lastError);
200
- if (progress !== lastProgress) {
201
- lastProgress = progress;
235
+ if (emitKey !== lastEmittedKey) {
236
+ lastEmittedKey = emitKey;
202
237
  emitProgress(args.write, args.json === true, progress, message);
203
238
  }
204
239
  if (args.once === true) {
@@ -1 +1 @@
1
- {"version":3,"file":"session-engine.d.ts","sourceRoot":"","sources":["../../src/internal/session-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAYH,OAAO,EACL,mBAAmB,EACnB,eAAe,EAChB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EAEtB,KAAK,cAAc,EAInB,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAG1B,KAAK,eAAe,EACpB,KAAK,YAAY,EAIjB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EAEjB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,cAAc,EAEnB,KAAK,eAAe,EAGpB,KAAK,WAAW,EACjB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,KAAK,UAAU,EAAmB,MAAM,kBAAkB,CAAC;AAQpE,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAe9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAQ9D,eAAO,MAAM,eAAe,SAAS,CAAC;AACtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,YAAY,SAAS,EAAE,MAAM,EAK5B;CACF;AAED,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,YAAY,SAAS,EAAE,MAAM,EAK5B;CACF;AAED,qBAAa,mBAAoB,SAAQ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AE,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAO/C;IAED,yEAAyE;IACnE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAU3B;CACF"}
@@ -46,12 +46,12 @@ import { createHostPlatforms } from "./host-platforms.js";
46
46
  import { formatContinuationToken, newContinuationKey, newSessionId, newToolCallId, } from "./ids.js";
47
47
  import { validateToolInput } from "./json-schema.js";
48
48
  import { McpHost } from "./mcp-host.js";
49
- import { buildIdentitySection, buildSessionContextBlock, SCHEDULE_CHANNEL_PREFIX, } from "./prompt-context.js";
49
+ import { buildSessionContextBlock, SCHEDULE_CHANNEL_PREFIX, } from "./prompt-context.js";
50
50
  import { assertCloudCanHonorAccountServersFilters } from "./resolved-connections.js";
51
51
  import { SessionStore } from "./session-store.js";
52
52
  import { StorageCoordinator } from "./storage-coordinator.js";
53
53
  import { normalizeToolResult, toolCallErrorMessage } from "./tool-result.js";
54
- import { buildAgentToolsCatalog, materializeWorkspace, writeWorkspaceFiles, } from "./workspace.js";
54
+ import { buildAgentsMdContent, isNestedInGitRepo, materializeWorkspace, writeWorkspaceFiles, } from "./workspace.js";
55
55
  export const HTTP_CHANNEL_ID = "http";
56
56
  export { SCHEDULE_CHANNEL_PREFIX } from "./prompt-context.js";
57
57
  export class SessionBusyError extends Error {
@@ -726,7 +726,15 @@ export class SessionEngine {
726
726
  return rest;
727
727
  });
728
728
  }
729
- const request = this.buildTurnRequest(record, agent, turnId, message, isFirstTurn, emit, (update) => __awaiter(this, void 0, void 0, function* () {
729
+ // The harness only loads the scaffolded AGENTS.md when the session
730
+ // workspace is its own project root. With a per-session cwd override
731
+ // (PR worktree) the scaffold lands elsewhere, and a workspace nested
732
+ // inside a git repo re-roots harness rules at that repo — in both
733
+ // cases deliver instructions inline on the first turn instead.
734
+ const instructionsInvisibleToHarness = isFirstTurn &&
735
+ (record.workspaceOverride !== undefined ||
736
+ (yield isNestedInGitRepo(harnessCwd)));
737
+ const request = this.buildTurnRequest(record, agent, turnId, message, isFirstTurn, instructionsInvisibleToHarness, emit, (update) => __awaiter(this, void 0, void 0, function* () {
730
738
  mapper.handleUpdate(update);
731
739
  // Yield so the HTTP NDJSON writer can flush tool start/result
732
740
  // events while sibling parallel tools are still executing.
@@ -797,9 +805,8 @@ export class SessionEngine {
797
805
  return Object.assign(Object.assign(Object.assign({}, outcome), (finalResult === undefined ? {} : { result: finalResult })), (finalUsage === undefined ? {} : { usage: finalUsage }));
798
806
  });
799
807
  }
800
- buildTurnRequest(record, agent, turnId, prompt, isFirstTurn, emit, onUpdate, signal) {
801
- var _a, _b, _c;
802
- var _d;
808
+ buildTurnRequest(record, agent, turnId, prompt, isFirstTurn, instructionsInvisibleToHarness, emit, onUpdate, signal) {
809
+ var _a, _b;
803
810
  // Per-session cloud attach (channel/tool handoff) forces cloud runtime
804
811
  // even when the agent defaults to local for chat server tools.
805
812
  const runtime = resolveSessionRuntime({
@@ -822,15 +829,22 @@ export class SessionEngine {
822
829
  });
823
830
  turnPrompt = `${contextBlock}\n\n${prompt}`;
824
831
  }
825
- if (runtime === "cloud" && isFirstTurn) {
826
- const preamble = [
827
- (_d = (_c = agent.instructions) === null || _c === void 0 ? void 0 : _c.trim()) !== null && _d !== void 0 ? _d : "",
828
- buildIdentitySection(agent),
829
- buildAgentToolsCatalog(agent.tools, { includeScripts: true }),
830
- ]
831
- .filter((part) => part !== "")
832
- .join("\n\n");
833
- turnPrompt = `${preamble}\n\n${turnPrompt}`;
832
+ if (isFirstTurn) {
833
+ if (runtime === "cloud") {
834
+ // Cloud VMs have no materialized workspace: ship the full context,
835
+ // including agent tool script bodies.
836
+ const preamble = buildAgentsMdContent(agent, { includeScripts: true });
837
+ turnPrompt = `${preamble}\n\n${turnPrompt}`;
838
+ }
839
+ else if (instructionsInvisibleToHarness) {
840
+ // Local workspace whose AGENTS.md the harness will not load. With a
841
+ // per-session harness cwd override, agent tool scripts live only in
842
+ // the durable scaffold dir — embed bodies like cloud. Otherwise the
843
+ // catalog can reference on-disk paths under the harness cwd.
844
+ const includeScripts = record.workspaceOverride !== undefined;
845
+ const preamble = buildAgentsMdContent(agent, { includeScripts });
846
+ turnPrompt = `${preamble}\n\n${turnPrompt}`;
847
+ }
834
848
  }
835
849
  return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ sessionId: record.sessionId }, (record.sdkAgentId === undefined
836
850
  ? {}
@@ -38,6 +38,25 @@ export declare function withIdentityPreamble(name: string, instructions: string
38
38
  export declare function buildAgentToolsCatalog(tools: DiscoveredTool[], options?: {
39
39
  includeScripts: boolean;
40
40
  }): string;
41
+ /**
42
+ * The full AGENTS.md-equivalent context for an agent: instructions, identity
43
+ * section, and the agent-side tool catalog. Written to the session workspace
44
+ * as `AGENTS.md`, and inlined into the first turn's prompt when the harness
45
+ * cannot discover that file (cloud runtime, or a local workspace the harness
46
+ * will not treat as the project root — see {@link isNestedInGitRepo}).
47
+ */
48
+ export declare function buildAgentsMdContent(agent: ResolvedAgent, options: {
49
+ includeScripts: boolean;
50
+ }): string;
51
+ /**
52
+ * True when `dir` sits strictly inside a git repository (a `.git` exists in
53
+ * an ancestor directory but not in `dir` itself). The Cursor harness resolves
54
+ * its project root by walking up to the nearest git root, so a nested session
55
+ * workspace loses its own `AGENTS.md` / `.cursor` scaffold: the enclosing
56
+ * repo's rules load instead, and the (necessarily gitignored) workspace files
57
+ * are skipped by nested rule discovery.
58
+ */
59
+ export declare function isNestedInGitRepo(dir: string): Promise<boolean>;
41
60
  export declare function materializeWorkspace(options: MaterializeWorkspaceOptions): Promise<void>;
42
61
  /**
43
62
  * Generate the SKILL.md the harness reads: `name` + `description`
@@ -1 +1 @@
1
- {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/internal/workspace.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,aAAa,EACd,MAAM,aAAa,CAAC;AAIrB,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,a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GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM1D;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,MAAM,GAAG,SAAS,CAapB;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,cAAc,EAAE,EACvB,OAAO,GAAE;IAAE,cAAc,EAAE,OAAO,CAAA;CAA8B,GAC/D,MAAM,CA6CR;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE;IAAE,cAAc,EAAE,OAAO,CAAA;CAAE,GACnC,MAAM,CAUR;AAED;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAcrE;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,IAAI,CAAC,CA4Bf;AAmDD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAO3D;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,OAAO,CAAC,IAAI,CAAC,CAMf"}
@@ -16,7 +16,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
16
16
  });
17
17
  };
18
18
  import { chmod, copyFile, mkdir, stat, writeFile } from "node:fs/promises";
19
- import { dirname, join, relative, resolve } from "node:path";
19
+ import { dirname, join, parse, relative, resolve } from "node:path";
20
20
  import { parseFrontmatter, serializeFrontmatter } from "./frontmatter.js";
21
21
  import { buildIdentitySection } from "./prompt-context.js";
22
22
  /** Relative path of an agent-side tool script inside the session workspace. */
@@ -103,22 +103,56 @@ export function buildAgentToolsCatalog(tools, options = { includeScripts: false
103
103
  }
104
104
  return `${parts.join("\n").trimEnd()}\n`;
105
105
  }
106
+ /**
107
+ * The full AGENTS.md-equivalent context for an agent: instructions, identity
108
+ * section, and the agent-side tool catalog. Written to the session workspace
109
+ * as `AGENTS.md`, and inlined into the first turn's prompt when the harness
110
+ * cannot discover that file (cloud runtime, or a local workspace the harness
111
+ * will not treat as the project root — see {@link isNestedInGitRepo}).
112
+ */
113
+ export function buildAgentsMdContent(agent, options) {
114
+ var _a;
115
+ var _b;
116
+ return [
117
+ (_b = (_a = agent.instructions) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : "",
118
+ buildIdentitySection(agent),
119
+ buildAgentToolsCatalog(agent.tools, {
120
+ includeScripts: options.includeScripts,
121
+ }),
122
+ ]
123
+ .filter((part) => part !== "")
124
+ .join("\n\n");
125
+ }
126
+ /**
127
+ * True when `dir` sits strictly inside a git repository (a `.git` exists in
128
+ * an ancestor directory but not in `dir` itself). The Cursor harness resolves
129
+ * its project root by walking up to the nearest git root, so a nested session
130
+ * workspace loses its own `AGENTS.md` / `.cursor` scaffold: the enclosing
131
+ * repo's rules load instead, and the (necessarily gitignored) workspace files
132
+ * are skipped by nested rule discovery.
133
+ */
134
+ export function isNestedInGitRepo(dir) {
135
+ return __awaiter(this, void 0, void 0, function* () {
136
+ let current = resolve(dir);
137
+ if (yield exists(join(current, ".git"))) {
138
+ // The workspace is itself a repo root; the harness roots rules here.
139
+ return false;
140
+ }
141
+ const { root } = parse(current);
142
+ while (current !== root) {
143
+ current = dirname(current);
144
+ if (yield exists(join(current, ".git"))) {
145
+ return true;
146
+ }
147
+ }
148
+ return false;
149
+ });
150
+ }
106
151
  export function materializeWorkspace(options) {
107
152
  return __awaiter(this, void 0, void 0, function* () {
108
- var _a;
109
- var _b;
110
153
  const { agent, workspaceDir, seed } = options;
111
154
  yield mkdir(workspaceDir, { recursive: true });
112
- const agentToolsSection = buildAgentToolsCatalog(agent.tools, {
113
- includeScripts: false,
114
- });
115
- const agentsMd = [
116
- (_b = (_a = agent.instructions) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : "",
117
- buildIdentitySection(agent),
118
- agentToolsSection,
119
- ]
120
- .filter((part) => part !== "")
121
- .join("\n\n");
155
+ const agentsMd = buildAgentsMdContent(agent, { includeScripts: false });
122
156
  yield writeFile(join(workspaceDir, "AGENTS.md"), agentsMd, "utf8");
123
157
  for (const tool of agent.tools) {
124
158
  if (tool.execution !== "agent" || tool.script === undefined) {