@cursor/bdk 0.2.18 → 0.2.20

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 (213) hide show
  1. package/AGENTS.md +16 -6
  2. package/dist/channels/slack/slack-channel.d.ts +3 -2
  3. package/dist/channels/slack/slack-channel.d.ts.map +1 -1
  4. package/dist/channels/slack/slack-channel.js +9 -2
  5. package/dist/docs/404.html +2 -2
  6. package/dist/docs/assets/{app.CJ-XZTK5.js → app.BzgJFr_T.js} +4 -4
  7. package/dist/docs/assets/chunks/@localSearchIndexroot.gGwBYU3d.js +1 -0
  8. package/dist/docs/assets/chunks/{VPLocalSearchBox.CpbYgURZ.js → VPLocalSearchBox.Bn5QyUDM.js} +1 -1
  9. package/dist/docs/assets/chunks/{arc.B081PemO.js → arc.D734Gm5d.js} +1 -1
  10. package/dist/docs/assets/chunks/{architectureDiagram-Q4EWVU46.DPaT_hi-.js → architectureDiagram-Q4EWVU46.NX1jj-YX.js} +1 -1
  11. package/dist/docs/assets/chunks/{baseUniq.Buu61NLg.js → baseUniq.nd8dxdeO.js} +1 -1
  12. package/dist/docs/assets/chunks/{blockDiagram-DXYQGD6D.C6t63owh.js → blockDiagram-DXYQGD6D.DG8faTim.js} +1 -1
  13. package/dist/docs/assets/chunks/{c4Diagram-AHTNJAMY.BtKabdXR.js → c4Diagram-AHTNJAMY.zD31AJ3b.js} +1 -1
  14. package/dist/docs/assets/chunks/channel.DQLJQMi3.js +1 -0
  15. package/dist/docs/assets/chunks/{chunk-4BX2VUAB.DQpNaR8N.js → chunk-4BX2VUAB.BHQj6Rko.js} +1 -1
  16. package/dist/docs/assets/chunks/{chunk-4TB4RGXK.DrhL-6Rv.js → chunk-4TB4RGXK.Cs38Yh16.js} +1 -1
  17. package/dist/docs/assets/chunks/{chunk-55IACEB6.DRLIBfNR.js → chunk-55IACEB6.CFUR21JO.js} +1 -1
  18. package/dist/docs/assets/chunks/{chunk-EDXVE4YY.kuUuFkIg.js → chunk-EDXVE4YY.C80-Sneg.js} +1 -1
  19. package/dist/docs/assets/chunks/{chunk-FMBD7UC4.BlrVxprw.js → chunk-FMBD7UC4.CdT1MGza.js} +1 -1
  20. package/dist/docs/assets/chunks/{chunk-OYMX7WX6.CZCfYeQA.js → chunk-OYMX7WX6.BctEzab0.js} +1 -1
  21. package/dist/docs/assets/chunks/{chunk-QZHKN3VN.C7rwVEMV.js → chunk-QZHKN3VN.DTneeX3k.js} +1 -1
  22. package/dist/docs/assets/chunks/{chunk-YZCP3GAM.CGseJtT_.js → chunk-YZCP3GAM.Cz47F_-o.js} +1 -1
  23. package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.j55aerUT.js +1 -0
  24. package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.j55aerUT.js +1 -0
  25. package/dist/docs/assets/chunks/clone.XimRS84I.js +1 -0
  26. package/dist/docs/assets/chunks/{cose-bilkent-S5V4N54A.BWlczAK4.js → cose-bilkent-S5V4N54A.BPYgB-_O.js} +1 -1
  27. package/dist/docs/assets/chunks/{dagre-KV5264BT.Cw0tT0bB.js → dagre-KV5264BT.Cu6hECod.js} +1 -1
  28. package/dist/docs/assets/chunks/{diagram-5BDNPKRD.Cm96ah9V.js → diagram-5BDNPKRD.BMgp95Tz.js} +1 -1
  29. package/dist/docs/assets/chunks/{diagram-G4DWMVQ6.Cl0AoWYM.js → diagram-G4DWMVQ6.towWdhDi.js} +1 -1
  30. package/dist/docs/assets/chunks/{diagram-MMDJMWI5.Bp7mlzKs.js → diagram-MMDJMWI5.D9IfOvE9.js} +1 -1
  31. package/dist/docs/assets/chunks/{diagram-TYMM5635.ClVeqpcW.js → diagram-TYMM5635.NTX57RPu.js} +1 -1
  32. package/dist/docs/assets/chunks/{erDiagram-SMLLAGMA.Bi8dojF9.js → erDiagram-SMLLAGMA.DIQLqDqu.js} +1 -1
  33. package/dist/docs/assets/chunks/{flowDiagram-DWJPFMVM.Bb4urpfG.js → flowDiagram-DWJPFMVM.DhqpItRe.js} +1 -1
  34. package/dist/docs/assets/chunks/{ganttDiagram-T4ZO3ILL.whR4wFze.js → ganttDiagram-T4ZO3ILL.B998R3Ps.js} +1 -1
  35. package/dist/docs/assets/chunks/{gitGraphDiagram-UUTBAWPF.6oVMi6-3.js → gitGraphDiagram-UUTBAWPF.B45nTn8-.js} +1 -1
  36. package/dist/docs/assets/chunks/{graph.D8AJDOFK.js → graph.DPseWzzM.js} +1 -1
  37. package/dist/docs/assets/chunks/{infoDiagram-42DDH7IO.nTpsf5Vk.js → infoDiagram-42DDH7IO._GhhBBai.js} +1 -1
  38. package/dist/docs/assets/chunks/{ishikawaDiagram-UXIWVN3A.DhYDOwyB.js → ishikawaDiagram-UXIWVN3A.CTUMcaMM.js} +1 -1
  39. package/dist/docs/assets/chunks/{journeyDiagram-VCZTEJTY.Bg7Rudw3.js → journeyDiagram-VCZTEJTY.DkJBUddC.js} +1 -1
  40. package/dist/docs/assets/chunks/{kanban-definition-6JOO6SKY.D80D_ZAR.js → kanban-definition-6JOO6SKY.B5Q3uwhy.js} +1 -1
  41. package/dist/docs/assets/chunks/{layout.e9hmuC-K.js → layout.CDY13IKh.js} +1 -1
  42. package/dist/docs/assets/chunks/{linear.D6hEyqVB.js → linear.BPd1ql9p.js} +1 -1
  43. package/dist/docs/assets/chunks/{min.BPAdvB9D.js → min.dlGuqIBP.js} +1 -1
  44. package/dist/docs/assets/chunks/{mindmap-definition-QFDTVHPH.tm2Sov2Q.js → mindmap-definition-QFDTVHPH.Cp7zCtmb.js} +1 -1
  45. package/dist/docs/assets/chunks/{pieDiagram-DEJITSTG.BKHZ497m.js → pieDiagram-DEJITSTG.CRH034nu.js} +1 -1
  46. package/dist/docs/assets/chunks/{quadrantDiagram-34T5L4WZ.CPj7gSp6.js → quadrantDiagram-34T5L4WZ.BspgZ-pX.js} +1 -1
  47. package/dist/docs/assets/chunks/{requirementDiagram-MS252O5E._U68yVUd.js → requirementDiagram-MS252O5E.CQZqZ0nZ.js} +1 -1
  48. package/dist/docs/assets/chunks/{sankeyDiagram-XADWPNL6._6jrIQPb.js → sankeyDiagram-XADWPNL6.DllwFU3k.js} +1 -1
  49. package/dist/docs/assets/chunks/{sequenceDiagram-FGHM5R23.D9UlmB6F.js → sequenceDiagram-FGHM5R23.B5fTXycf.js} +1 -1
  50. package/dist/docs/assets/chunks/{stateDiagram-FHFEXIEX.BQSaiJCe.js → stateDiagram-FHFEXIEX.12GQjmbD.js} +1 -1
  51. package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.Ctv5WEMu.js +1 -0
  52. package/dist/docs/assets/chunks/{theme.25ZC61Iy.js → theme.BgocqONV.js} +2 -2
  53. package/dist/docs/assets/chunks/{timeline-definition-GMOUNBTQ.d-17NZ3L.js → timeline-definition-GMOUNBTQ.DXKUL5rH.js} +1 -1
  54. package/dist/docs/assets/chunks/{vennDiagram-DHZGUBPP.DE9AGEjG.js → vennDiagram-DHZGUBPP.BrsjYCjp.js} +1 -1
  55. package/dist/docs/assets/chunks/{wardley-RL74JXVD.BcY0KddE.js → wardley-RL74JXVD.DZDndEXQ.js} +1 -1
  56. package/dist/docs/assets/chunks/{wardleyDiagram-NUSXRM2D.D9SDNipV.js → wardleyDiagram-NUSXRM2D.C4oM69gv.js} +1 -1
  57. package/dist/docs/assets/chunks/{xychartDiagram-5P7HB3ND.DM1sIMf8.js → xychartDiagram-5P7HB3ND.qzHH9efW.js} +1 -1
  58. package/dist/docs/assets/{deployment.md.ajc3VM0m.js → deployment.md.D0uprX2p.js} +3 -3
  59. package/dist/docs/assets/{deployment.md.ajc3VM0m.lean.js → deployment.md.D0uprX2p.lean.js} +1 -1
  60. package/dist/docs/assets/{guides_agent-to-agent.md.Cps5NiCV.js → guides_agent-to-agent.md.CwL5cwuE.js} +6 -5
  61. package/dist/docs/assets/{guides_agent-to-agent.md.Cps5NiCV.lean.js → guides_agent-to-agent.md.CwL5cwuE.lean.js} +1 -1
  62. package/dist/docs/assets/guides_export-grokbot.md.qo5bxi4h.js +55 -0
  63. package/dist/docs/assets/guides_export-grokbot.md.qo5bxi4h.lean.js +1 -0
  64. package/dist/docs/assets/{guides_opentelemetry.md.jcPNrQbH.js → guides_opentelemetry.md.BHPm32OR.js} +3 -3
  65. package/dist/docs/assets/{guides_opentelemetry.md.jcPNrQbH.lean.js → guides_opentelemetry.md.BHPm32OR.lean.js} +1 -1
  66. package/dist/docs/assets/{index.md.CHAFTf6m.js → index.md.CAnsLl8D.js} +2 -2
  67. package/dist/docs/assets/{index.md.CHAFTf6m.lean.js → index.md.CAnsLl8D.lean.js} +1 -1
  68. package/dist/docs/assets/{reference_cli.md.Bt3sAfat.js → reference_cli.md.Bkrsce22.js} +7 -4
  69. package/dist/docs/assets/{reference_cli.md.Bt3sAfat.lean.js → reference_cli.md.Bkrsce22.lean.js} +1 -1
  70. package/dist/docs/assets/{reference_connections.md.CxbLpaaP.js → reference_connections.md.BJE2Zllp.js} +4 -4
  71. package/dist/docs/assets/{reference_connections.md.CxbLpaaP.lean.js → reference_connections.md.BJE2Zllp.lean.js} +1 -1
  72. package/dist/docs/assets/{reference_hooks.md.DbJC8mcZ.js → reference_hooks.md.CP3FENFJ.js} +1 -1
  73. package/dist/docs/assets/reference_memory.md.BwyJXYZe.js +4 -0
  74. package/dist/docs/assets/reference_memory.md.BwyJXYZe.lean.js +1 -0
  75. package/dist/docs/assets/{reference_skills.md.Ckddg6KX.js → reference_skills.md.C2GWh7g8.js} +3 -3
  76. package/dist/docs/building-with-agents.html +35 -35
  77. package/dist/docs/deployment.html +38 -38
  78. package/dist/docs/deployment.md +17 -0
  79. package/dist/docs/evals.html +35 -35
  80. package/dist/docs/guides/agent-to-agent.html +41 -40
  81. package/dist/docs/guides/agent-to-agent.md +34 -21
  82. package/dist/docs/guides/bitbucket.html +35 -35
  83. package/dist/docs/guides/cloud-agents.html +35 -35
  84. package/dist/docs/guides/convert-automation.html +35 -35
  85. package/dist/docs/guides/export-grokbot.html +114 -0
  86. package/dist/docs/guides/export-grokbot.md +239 -0
  87. package/dist/docs/guides/github.html +35 -35
  88. package/dist/docs/guides/gitlab.html +35 -35
  89. package/dist/docs/guides/grokbot-agents.html +35 -35
  90. package/dist/docs/guides/hooks.html +35 -35
  91. package/dist/docs/guides/improve.html +35 -35
  92. package/dist/docs/guides/jev.html +35 -35
  93. package/dist/docs/guides/mcp-oauth.html +35 -35
  94. package/dist/docs/guides/migrate.html +36 -36
  95. package/dist/docs/guides/opentelemetry.html +37 -37
  96. package/dist/docs/guides/opentelemetry.md +19 -0
  97. package/dist/docs/guides/slack.html +35 -35
  98. package/dist/docs/guides/webhooks.html +35 -35
  99. package/dist/docs/hashmap.json +1 -1
  100. package/dist/docs/hillclimbing.html +35 -35
  101. package/dist/docs/index.html +37 -37
  102. package/dist/docs/index.md +3 -0
  103. package/dist/docs/llms-full.txt +493 -29
  104. package/dist/docs/llms.txt +2 -0
  105. package/dist/docs/quickstart.html +35 -35
  106. package/dist/docs/reference/agent-config.html +35 -35
  107. package/dist/docs/reference/artifacts.html +35 -35
  108. package/dist/docs/reference/channels.html +35 -35
  109. package/dist/docs/reference/cli.html +41 -38
  110. package/dist/docs/reference/cli.md +39 -1
  111. package/dist/docs/reference/connections.html +38 -38
  112. package/dist/docs/reference/connections.md +16 -6
  113. package/dist/docs/reference/evals.html +36 -36
  114. package/dist/docs/reference/extensions.html +35 -35
  115. package/dist/docs/reference/hooks.html +38 -38
  116. package/dist/docs/reference/hooks.md +2 -1
  117. package/dist/docs/reference/http-api.html +35 -35
  118. package/dist/docs/reference/instructions.html +35 -35
  119. package/dist/docs/reference/memory.html +63 -0
  120. package/dist/docs/reference/memory.md +114 -0
  121. package/dist/docs/reference/playground.html +35 -35
  122. package/dist/docs/reference/project-layout.html +35 -35
  123. package/dist/docs/reference/prompt.html +35 -35
  124. package/dist/docs/reference/schedules.html +35 -35
  125. package/dist/docs/reference/sessions.html +35 -35
  126. package/dist/docs/reference/skills.html +38 -38
  127. package/dist/docs/reference/subagents.html +35 -35
  128. package/dist/docs/reference/tools.html +35 -35
  129. package/dist/docs/templates/agentic-owners.html +35 -35
  130. package/dist/docs/templates/grokbot-agents.html +35 -35
  131. package/dist/docs/templates/security-reviewer.html +35 -35
  132. package/dist/docs/templates/thermo-quality-review.html +35 -35
  133. package/dist/docs/templates/thermo-review.html +35 -35
  134. package/dist/docs/templates/triage.html +35 -35
  135. package/dist/docs/troubleshooting.html +35 -35
  136. package/dist/evals.d.ts +1 -1
  137. package/dist/evals.js +1 -1
  138. package/dist/extensions/cursor-cloud-agents/extension.d.ts +2 -2
  139. package/dist/extensions/cursor-cloud-agents/extension.d.ts.map +1 -1
  140. package/dist/extensions/cursor-cloud-agents/extension.js +1 -1
  141. package/dist/extensions/cursor-cloud-agents/lib/launch-agent.d.ts +8 -1
  142. package/dist/extensions/cursor-cloud-agents/lib/launch-agent.d.ts.map +1 -1
  143. package/dist/extensions/cursor-cloud-agents/lib/launch-agent.js +10 -1
  144. package/dist/internal/cli-ax.d.ts +7 -7
  145. package/dist/internal/cli-ax.d.ts.map +1 -1
  146. package/dist/internal/cli-ax.js +36 -15
  147. package/dist/internal/cloud-turn-usage.d.ts +34 -0
  148. package/dist/internal/cloud-turn-usage.d.ts.map +1 -0
  149. package/dist/internal/cloud-turn-usage.js +94 -0
  150. package/dist/internal/estimate-cost.d.ts +55 -0
  151. package/dist/internal/estimate-cost.d.ts.map +1 -0
  152. package/dist/internal/{turn-cost.js → estimate-cost.js} +15 -23
  153. package/dist/internal/event-log.d.ts +2 -2
  154. package/dist/internal/event-log.js +2 -2
  155. package/dist/internal/http-channel.js +1 -1
  156. package/dist/internal/init-scaffold.d.ts.map +1 -1
  157. package/dist/internal/init-scaffold.js +3 -4
  158. package/dist/internal/otel/collector.d.ts +3 -3
  159. package/dist/internal/otel/collector.d.ts.map +1 -1
  160. package/dist/internal/otel/collector.js +8 -21
  161. package/dist/internal/otel/computer-use-attrs.d.ts +13 -0
  162. package/dist/internal/otel/computer-use-attrs.d.ts.map +1 -0
  163. package/dist/internal/otel/computer-use-attrs.js +29 -0
  164. package/dist/internal/sdk-runner.d.ts.map +1 -1
  165. package/dist/internal/sdk-runner.js +5 -13
  166. package/dist/internal/session-cost.d.ts +21 -22
  167. package/dist/internal/session-cost.d.ts.map +1 -1
  168. package/dist/internal/session-cost.js +38 -46
  169. package/dist/internal/session-engine.d.ts +22 -40
  170. package/dist/internal/session-engine.d.ts.map +1 -1
  171. package/dist/internal/session-engine.js +62 -109
  172. package/dist/internal/sessions-client.d.ts +13 -1
  173. package/dist/internal/sessions-client.d.ts.map +1 -1
  174. package/dist/internal/sessions-client.js +24 -0
  175. package/dist/internal/trajectory.d.ts +5 -6
  176. package/dist/internal/trajectory.d.ts.map +1 -1
  177. package/dist/internal/trajectory.js +1 -13
  178. package/dist/memory.d.ts +5 -2
  179. package/dist/memory.d.ts.map +1 -1
  180. package/dist/memory.js +1 -1
  181. package/dist/playground/assets/cursor-icons-16-gwXtdAvu.woff2 +0 -0
  182. package/dist/playground/assets/index-C77_FdOx.css +1 -0
  183. package/dist/playground/assets/index-CvzI2lhj.js +71 -0
  184. package/dist/playground/index.html +2 -2
  185. package/dist/types.d.ts +17 -26
  186. package/dist/types.d.ts.map +1 -1
  187. package/docs/README.md +3 -0
  188. package/docs/deployment.md +17 -0
  189. package/docs/guides/agent-to-agent.md +34 -21
  190. package/docs/guides/export-grokbot.md +244 -0
  191. package/docs/guides/opentelemetry.md +19 -0
  192. package/docs/reference/cli.md +39 -1
  193. package/docs/reference/connections.md +16 -6
  194. package/docs/reference/hooks.md +2 -1
  195. package/docs/reference/memory.md +119 -0
  196. package/package.json +4 -3
  197. package/templates/agentic-owners/bot/lib/owners/matching.ts +57 -2
  198. package/dist/docs/assets/chunks/@localSearchIndexroot.ylB4B_Ud.js +0 -1
  199. package/dist/docs/assets/chunks/channel.BgjgeSqp.js +0 -1
  200. package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.CIVv63wE.js +0 -1
  201. package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.CIVv63wE.js +0 -1
  202. package/dist/docs/assets/chunks/clone.HcW7h-70.js +0 -1
  203. package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.B5d7jT7E.js +0 -1
  204. package/dist/internal/cloud-turn-cost.d.ts +0 -42
  205. package/dist/internal/cloud-turn-cost.d.ts.map +0 -1
  206. package/dist/internal/cloud-turn-cost.js +0 -120
  207. package/dist/internal/turn-cost.d.ts +0 -41
  208. package/dist/internal/turn-cost.d.ts.map +0 -1
  209. package/dist/playground/assets/cursor-icons-16-DBmD_cqy.woff2 +0 -0
  210. package/dist/playground/assets/index-BDPd0Sec.css +0 -1
  211. package/dist/playground/assets/index-BrXDwbrN.js +0 -71
  212. /package/dist/docs/assets/{reference_hooks.md.DbJC8mcZ.lean.js → reference_hooks.md.CP3FENFJ.lean.js} +0 -0
  213. /package/dist/docs/assets/{reference_skills.md.Ckddg6KX.lean.js → reference_skills.md.C2GWh7g8.lean.js} +0 -0
@@ -0,0 +1,244 @@
1
+ ---
2
+ title: "Export a Grok Bot"
3
+ description: "Turn a Grok Bot recipe into a BDK project, preview what maps, and finish secrets and connector sign-ins."
4
+ ---
5
+
6
+ # Export a Grok Bot to a BDK project
7
+
8
+ `bdk init --from-grokbot` turns a Grok Bot recipe into a project you can
9
+ review, run locally, and keep in source control. It carries over the bot's
10
+ profile, selected skills and routines, memory, and connectors where BDK has a
11
+ matching project surface.
12
+
13
+ ## Preview the export
14
+
15
+ Start with `--dry-run`. The command resolves the same defaults as a real
16
+ export and shows every planned file, warning, secret name, and follow-up
17
+ without creating the target directory or installing packages.
18
+
19
+ ```bash
20
+ bdk init ./launch-desk \
21
+ --from-grokbot ./launch-desk.recipe.json \
22
+ --dry-run
23
+ ```
24
+
25
+ Selected lines from the example recipe's non-interactive preview look like
26
+ this:
27
+
28
+ ```text
29
+ Dry run: "Launch Desk" → ./launch-desk (nothing written)
30
+
31
+ bot/agent.ts profile
32
+ bot/channels/slack.ts routines/launch-questions, routines/blocker-watch, routines/ship-it
33
+ bot/instructions.md profile, gettingStarted, routines/launch-questions, routines/blocker-watch, routines/ship-it, memory
34
+ bot/mcp-connections/linear.ts plugins/linear
35
+ bot/schedules/morning-launch-brief.md routines/morning-launch-brief
36
+ bot/skills/release-checklist/SKILL.md skills/release-checklist
37
+ SECRETS.md answers
38
+ ...
39
+
40
+ Defaulted without asking:
41
+ - name
42
+ - description
43
+ - model
44
+ ...
45
+
46
+ Not carried over:
47
+ - profile.avatar: BDK agents have no avatar; kept in grokbot-export.json for the Slack app icon.
48
+
49
+ Secrets to set (names only; see SECRETS.md):
50
+ - LAUNCH_DESK_SLACK_APP_TOKEN
51
+ - LAUNCH_DESK_SLACK_BOT_TOKEN
52
+ ```
53
+
54
+ Each file row names the recipe parts that produced it. The remaining sections
55
+ list defaults, answers the recipe ignored, excluded items, unmapped behavior,
56
+ routine placeholders, fresh connector sign-ins, warnings, and setup steps.
57
+
58
+ Add `--json` when a script needs the preview:
59
+
60
+ ```bash
61
+ bdk init ./launch-desk \
62
+ --from-grokbot ./launch-desk.recipe.json \
63
+ --dry-run \
64
+ --json
65
+ ```
66
+
67
+ The core JSON shape is:
68
+
69
+ ```json
70
+ {
71
+ "ok": true,
72
+ "dryRun": true,
73
+ "directory": "/work/launch-desk",
74
+ "preview": {
75
+ "files": [],
76
+ "defaulted": [],
77
+ "ignored": [],
78
+ "excluded": [],
79
+ "unmapped": [],
80
+ "fillIns": [],
81
+ "secrets": { "names": [], "reauth": [] },
82
+ "warnings": [],
83
+ "setupSteps": []
84
+ }
85
+ }
86
+ ```
87
+
88
+ See [`bdk init`](../reference/cli.md#init) for the complete preview fields and
89
+ flag behavior.
90
+
91
+ ## Choose an answers file or the terminal interview
92
+
93
+ Run the command in a terminal when you want to review each choice once. Press
94
+ Enter to accept a default.
95
+
96
+ ```bash
97
+ bdk init ./launch-desk \
98
+ --from-grokbot ./launch-desk.recipe.json
99
+ ```
100
+
101
+ Use `--answers` for a repeatable export or a non-interactive environment. This
102
+ minimal file validates against the published schema and accepts every recipe
103
+ default:
104
+
105
+ ```json
106
+ {
107
+ "$schema": "./node_modules/@cursor/bdk/schemas/grokbot-answers.schema.json",
108
+ "version": 1
109
+ }
110
+ ```
111
+
112
+ Save it as `grokbot-answers.json`, then run:
113
+
114
+ ```bash
115
+ bdk init ./launch-desk \
116
+ --from-grokbot ./launch-desk.recipe.json \
117
+ --answers ./grokbot-answers.json
118
+ ```
119
+
120
+ The `$schema` property is an optional editor hint. Add only the choices you
121
+ want to override; any answer present in the file is not asked again. A
122
+ positional directory such as `./launch-desk` overrides `location` in the
123
+ answers file.
124
+
125
+ When stdin or stdout is not a TTY, the command never prompts. `--json` also
126
+ uses this non-interactive path. Missing fields take their defaults and appear
127
+ under **Defaulted without asking** or `preview.defaulted`. If a required
128
+ conditional answer has no default, such as the time for a scheduled decision,
129
+ the command stops and names the field to add to the answers file.
130
+
131
+ ## Write and check the project
132
+
133
+ Remove `--dry-run` after the preview matches your intent. The command writes
134
+ the project, installs its npm dependencies, and prints the next commands.
135
+ Export into a fresh directory; a project previously created with
136
+ `bdk init --template` is rejected.
137
+
138
+ ```bash
139
+ bdk init ./launch-desk \
140
+ --from-grokbot ./launch-desk.recipe.json \
141
+ --answers ./grokbot-answers.json
142
+
143
+ cd ./launch-desk
144
+ bdk validate
145
+ bdk dev
146
+ ```
147
+
148
+ Open the playground from `bdk dev` and try the routines you plan to keep
149
+ before connecting live channels.
150
+
151
+ ## Review what maps where
152
+
153
+ | Grok Bot recipe part | BDK project result |
154
+ | --- | --- |
155
+ | Profile or persona | The name and description become `bot/agent.ts` and the opening of `bot/instructions.md`. |
156
+ | Skills | Each selected skill becomes `bot/skills/<slug>/SKILL.md`. An enabled, valid skill schedule also becomes `bot/schedules/<slug>.md` when the schedule channel is on. |
157
+ | Getting-started skill | `bot/instructions.md` tells the agent to use this skill for a new conversation. |
158
+ | Cron routines | A selected routine with a valid, enabled cron trigger becomes `bot/schedules/<slug>.md` when the schedule channel is on. |
159
+ | Slack routines | When the Slack channel is on, the routine text becomes a section in `bot/instructions.md`; mentions, channel watches, keywords, and reactions are wired in `bot/channels/slack.ts`. Missing trigger values remain as warnings or TODOs. |
160
+ | GitHub or webhook routines | When the corresponding channel is on, the preview adds a setup step to wire the trigger. A routine with no other wired trigger also becomes an on-request skill. |
161
+ | Other routines | A routine without a wired trigger becomes an on-request skill. The preview explains which trigger still needs work. |
162
+ | Memory | The default is `bot/skills/knowledge/SKILL.md`. Choose `memory: "kv"` for `bot/lib/memory-seed.json`, or `memory: "drop"` to leave it out. |
163
+ | Plugins and connectors | Each selected plugin becomes `bot/mcp-connections/<slug>.ts` using Cursor-account auth, OAuth, or a named bearer-token secret. |
164
+ | Routine placeholders | Values under `fillIns.<routine-slug>` replace placeholders such as `{slack_channel}`. Unfilled placeholders remain visible and produce warnings. |
165
+ | Export decisions | Resolved answers and recipe metadata are recorded in `grokbot-export.json`. |
166
+
167
+ The generated project also includes the standard package, TypeScript, eval,
168
+ memory-hook, and ignore files needed to run it.
169
+
170
+ ## Resolve what does not map
171
+
172
+ The preview separates choices you made from behavior the converter could not
173
+ carry over:
174
+
175
+ | Preview result | What it means | What to do |
176
+ | --- | --- | --- |
177
+ | **Left out** | An answer excluded a skill, routine, plugin, or memory. | Change the matching `include` or `exclude` answer, or change `memory` from `"drop"`, then rerun; otherwise leave the item behind. |
178
+ | `BDK agents have no avatar` | The profile avatar is not an agent setting. Its metadata remains in `grokbot-export.json`. | Set an icon separately if the destination needs one. |
179
+ | `Unknown recipe field; ignored.` | The recipe contains a field this BDK version does not map. | Inspect the field and add its behavior to the generated project when needed. |
180
+ | `Paused schedule ...` | A paused cron trigger does not produce a schedule file. | Leave it paused, or add a schedule under `bot/schedules/`. |
181
+ | `trigger dropped: the ... channel is off.` | The answers disabled the channel used by a trigger. | Enable the channel in the answers or add the trigger manually after export. |
182
+ | `trigger has no BDK channel.` | The trigger type has no direct BDK channel mapping. | Add a supported channel or custom wake; use the generated on-request skill when one is present. |
183
+ | `is not a five-field cron expression.` | The source cron cannot become a BDK schedule. | Correct the expression and add the schedule before enabling it. |
184
+ | `placeholders ... are unfilled` | A routine still contains values such as `{slack_channel}`. | Set `fillIns.<routine-slug>` in the answers or edit the generated text. |
185
+ | `BDK has no built-in KV seed` | `memory: "kv"` writes data but does not load it into hosted KV. | Add your own `ctx.host.kv` seeding code, or use `memory: "skill"`. |
186
+
187
+ Treat setup steps and warnings as the checklist for restoring the source
188
+ behavior. A generated project is ready for review, not automatically ready for
189
+ live traffic.
190
+
191
+ ## Set secrets and reconnect OAuth
192
+
193
+ The export carries secret names only, never values. `SECRETS.md` lists each
194
+ name, where it is read, and every connector that needs a fresh sign-in.
195
+
196
+ Set local values in the environment where you run `bdk dev`. For a hosted
197
+ deployment, let `bdk` prompt for each value:
198
+
199
+ ```bash
200
+ bdk secrets set launch-desk LINEAR_API_KEY
201
+ ```
202
+
203
+ OAuth tokens do not move with the recipe. Sign in to each OAuth connector
204
+ again:
205
+
206
+ ```bash
207
+ bdk mcp oauth notion
208
+ ```
209
+
210
+ Add `--store` when the sign-in is for a hosted deployment.
211
+
212
+ ## Check cron schedules in UTC
213
+
214
+ BDK evaluates cron schedules in UTC. A recipe routine that asks for a
215
+ timezone produces a warning like:
216
+
217
+ ```text
218
+ routines/morning-launch-brief: BDK runs `0 8 * * 1-5` in UTC, not America/Los_Angeles; adjust the cron in bot/schedules/morning-launch-brief.md if the time matters.
219
+ ```
220
+
221
+ The timezone answer documents the source intent; it does not rewrite the cron.
222
+ Check each generated file under `bot/schedules/` and translate local
223
+ wall-clock times to UTC. For locations that observe daylight saving time,
224
+ also decide how you will handle the offset change.
225
+
226
+ ## Use the handoff files
227
+
228
+ | File | Purpose |
229
+ | --- | --- |
230
+ | `AGENTS.md` | Gives a coding agent the project commands and points it to the export handoff. |
231
+ | `SECRETS.md` | Lists secret names and connector sign-ins, without values. |
232
+ | `SLACK.md` | When Slack is selected, holds the Slack app setup notes. |
233
+ | `.cursor/skills/finish-grokbot-export/SKILL.md` | Guides a coding agent through the remaining setup, warnings, validation, and local test. |
234
+ | `.cursor/environment.json` | Tells a Cursor cloud agent to install the project with `npm install`. |
235
+
236
+ Server-side secret transfer, automatic moves of existing Slack apps, and
237
+ self-deploy are not shipped, so this guide does not cover those flows.
238
+
239
+ ## Related
240
+
241
+ - [`bdk init`](../reference/cli.md#init): flags, JSON output, and failures
242
+ - [Project layout](../reference/project-layout.md): generated project files
243
+ - [Schedules and reminders](../reference/schedules.md): cron behavior
244
+ - [MCP connections](../reference/connections.md): connector auth choices
@@ -74,6 +74,25 @@ turn: agent_sdk.turn
74
74
  A conversation can produce several turn traces, so use the session ID
75
75
  as the join key instead of expecting one long-lived session span.
76
76
 
77
+ ### Computer use
78
+
79
+ Each computer use batch is an `agent_sdk.tool` span with
80
+ `cursor.tool.name` set to `computerUse`. Batches that the computer use
81
+ subagent runs sit under its `agent_sdk.subagent` span. Four attributes
82
+ describe each batch without typed text, coordinates, or screenshots:
83
+
84
+ | Attribute | Value |
85
+ | --- | --- |
86
+ | `agent_sdk.computer.actions` | Action types in order, such as `click,type,screenshot` |
87
+ | `agent_sdk.computer.action_count` | Number of actions the agent requested |
88
+ | `agent_sdk.computer.completed_action_count` | Number of actions that ran |
89
+ | `agent_sdk.computer.executor_duration_ms` | Time the executor spent on the batch |
90
+
91
+ To export the full actions, turn on tool content as shown in
92
+ [Control what leaves the process](#control-what-leaves-the-process).
93
+ Tool content includes the text the agent typed, which can contain
94
+ passwords.
95
+
77
96
  ## Add domain telemetry
78
97
 
79
98
  Use `ctx.host.otel` when your dashboard should answer questions the
@@ -136,6 +136,7 @@ bdk serve [--dir <path>] [--port <n>] [--host <host>]
136
136
  [--allow-anonymous-cursor-account-mcp]
137
137
  [--allow-anonymous-grokbot]
138
138
  [--public-url <url>]
139
+ [--peers-url <url>]
139
140
  [--no-schedules] [--no-playground] [--no-docs]
140
141
  [--cursor-events --repo <owner/name>]...
141
142
  ```
@@ -145,7 +146,7 @@ bdk serve [--dir <path>] [--port <n>] [--host <host>]
145
146
  | `--port <n>` | Listen on this port. The default is `3000`; `0` selects an available port. When an omitted default is occupied, the CLI selects the next port. An occupied explicit port fails with a next-port hint. |
146
147
  | `--host <host>` | Bind this host. The default is loopback-only `127.0.0.1`. |
147
148
  | `--mode multi` | Mount projects at `/<slug>/v1/*` and `/<slug>/playground`, with an index at `/`. This is the default. |
148
- | `--mode single` | Mount one project at `/v1/*` and `/playground`. |
149
+ | `--mode single` | Mount one project at `/v1/*` and `/playground`. Declared peers are omitted with a warning unless `--peers-url` is set. |
149
150
  | `--dev` | Disable automatic schedule and reminder firing, admit unsigned loopback GitHub deliveries, and enable local playground access. |
150
151
  | `--state-root <path>` | Store local sessions, streams, workspaces, and channel state here. Keep durable state outside a repository whose rules shouldn't reach agent workspaces. |
151
152
  | `--bearer-token <secret>` | Require this token on routes without authored authentication. Mutually exclusive with `--allow-anonymous`. |
@@ -154,6 +155,7 @@ bdk serve [--dir <path>] [--port <n>] [--host <host>]
154
155
  | `--allow-anonymous-cursor-account-mcp` | Let anonymous callers use Cursor account MCP connections. Requires an authenticating proxy. |
155
156
  | `--allow-anonymous-grokbot` | Let anonymous callers drive hosted Grok Bot runtime agents. Requires an authenticating proxy. |
156
157
  | `--public-url <url>` | Set the externally reachable base URL that turns running off the serve host use for peer MCP and host bridges. It does not expose the server; configure the listener or proxy separately. Local-runtime peers use loopback. |
158
+ | `--peers-url <url>` | Resolve declared peers for a single-agent serve through a hosting-provided peer service. Cursor-managed hosting sets this option automatically; a multi-agent serve rejects it. |
157
159
  | `--no-schedules` | Disable schedule firing outside dev mode. |
158
160
  | `--no-playground` | Skip the playground. |
159
161
  | `--no-docs` | Skip the documentation site at `/docs`. |
@@ -447,6 +449,8 @@ requires an ID. The `status` and `cancel` subcommands require `--url`.
447
449
 
448
450
  ```text
449
451
  bdk init [directory] [--template <name>] [--var id=value]... [--json]
452
+ bdk init [directory] --from-grokbot <recipe.json>
453
+ [--answers <file>] [--dry-run] [--json]
450
454
  ```
451
455
 
452
456
  Without a directory, `init` prints the setup guide and changes no files. With
@@ -463,6 +467,40 @@ On a TTY, templates with questions run their interview before writing files.
463
467
  `init` also offers to refresh the bundled coding-agent skills and starts login
464
468
  when the host has no Cursor credential.
465
469
 
470
+ #### Export a Grok Bot recipe
471
+
472
+ `--from-grokbot` reads a Grok Bot recipe and maps its profile, selected skills
473
+ and routines, memory, channels, and connectors into a BDK project. The target
474
+ directory defaults to the resolved `location` answer; a positional directory
475
+ overrides it. A target previously created with `bdk init --template` is
476
+ rejected; export into a fresh directory instead.
477
+
478
+ | Option | Contract |
479
+ | --- | --- |
480
+ | `--from-grokbot <recipe.json>` | Read the recipe to export. |
481
+ | `--answers <file>` | Read export decisions from a JSON object. Fields present in the file are not asked again. The published schema is `schemas/grokbot-answers.schema.json`. |
482
+ | `--dry-run` | Print the planned files, defaults, exclusions, unmapped behavior, placeholders, secret names, warnings, and setup steps without writing files or installing dependencies. |
483
+ | `--json` | Never prompt and print machine-readable output. Combine it with `--dry-run` for a machine-readable preview. |
484
+
485
+ On a TTY, the command asks for missing decisions and offers recipe-derived
486
+ defaults. Off a TTY, it never prompts, takes defaults where possible, and
487
+ lists the fields it defaulted.
488
+
489
+ `--dry-run --json` prints `{ ok, dryRun, directory, preview }`. The preview
490
+ contains `version`, `name`, resolved `answers`, `defaulted`, `ignored`, `files`
491
+ as `{ path, from }`, `excluded`, `unmapped` as `{ from, reason }`, `fillIns`,
492
+ `secrets` as `{ names, reauth }`, `warnings`, and `setupSteps`. A write with
493
+ `--json` also reports `files`, `installed`, and `installError`. A dependency
494
+ install failure leaves `ok: true`, sets `installed: false`, reports
495
+ `installError`, and exits `0`. Other errors print `{ ok: false, error }` and
496
+ exit nonzero.
497
+
498
+ `--answers` and `--dry-run` require `--from-grokbot`. This export mode does
499
+ not accept `--template` or `--var`.
500
+
501
+ See [Export a Grok Bot](../guides/export-grokbot.md) for the preview-first
502
+ workflow, mapping table, and post-export checklist.
503
+
466
504
  ### Convert an Automation {#convert-automation}
467
505
 
468
506
  ```text
@@ -9,8 +9,8 @@ An MCP connection gives the agent tools from an MCP server. Define one
9
9
  file per server under `bot/mcp-connections/`; the filename becomes the
10
10
  server name. Default-export `defineConnection` from
11
11
  `@cursor/bdk/connections`. The transport is remote HTTP, local stdio,
12
- the signed-in Cursor account's connectors, or a peer agent on the same
13
- host.
12
+ the signed-in Cursor account's connectors, or a peer agent addressed by
13
+ slug.
14
14
 
15
15
  Put a server in `bot/host-connections/` when only host tools should
16
16
  call it. Host connections use the same `defineConnection` shape and
@@ -254,9 +254,14 @@ Use a `{ command }` connection for stdio servers.
254
254
 
255
255
  ## Peer MCP connection {#peer-mcp-connection}
256
256
 
257
- `{ agent: "<slug>" }` addresses another agent mounted on the same serve
258
- host. The model gets the peer's `ask` and `check` tools, plus
259
- `call_tool` when the peer has server tools, and can delegate work to it:
257
+ `{ agent: "<slug>" }` addresses another agent without configuring a URL,
258
+ headers, or secrets. On a local multi-agent serve, the target is another
259
+ mount slug. On Cursor-managed hosting, it is the lowercase deployment slug
260
+ of another agent on the same team.
261
+
262
+ On a local multi-agent serve, the model gets the peer's `ask` and `check`
263
+ tools, plus `call_tool` when the peer has server tools, and can delegate work
264
+ to it:
260
265
 
261
266
  ```ts
262
267
  export default defineConnection({
@@ -265,7 +270,12 @@ export default defineConnection({
265
270
  });
266
271
  ```
267
272
 
268
- Unknown slugs and self-references fail `serve` at startup. Walkthrough:
273
+ Declare the connection only on the caller. The specialist needs no matching
274
+ configuration.
275
+
276
+ In a local multi-agent serve, unknown slugs and self-references fail at
277
+ startup. A single-agent serve omits peers with a warning unless its hosting
278
+ platform sets `--peers-url`. Walkthrough:
269
279
  [Peer agents](../guides/agent-to-agent.md#delegate-a-question-to-a-specialist).
270
280
 
271
281
  ## Call MCP from host code
@@ -58,7 +58,8 @@ reports all three. An extension mounts its hooks as `<ns>__<name>`, and
58
58
 
59
59
  `bdk init` scaffolds `bot/hooks/memory.ts`, which exports
60
60
  `memoryHook()` from `@cursor/bdk/memory` and journals every turn for
61
- later sessions to read. Delete the file to opt out.
61
+ later sessions to read. Delete the file to opt out. See
62
+ [Memory](./memory.md).
62
63
 
63
64
  ## Events and payloads
64
65
 
@@ -0,0 +1,119 @@
1
+ ---
2
+ title: "Memory"
3
+ description: "Journal every turn so later sessions can read what earlier ones did."
4
+ ---
5
+
6
+ # Memory
7
+
8
+ Memory lets an agent recall work from earlier sessions. A memory hook
9
+ appends one record per turn to a shared journal, and the model reads
10
+ that journal with its normal file tools when its instructions send it
11
+ there. Every session and every user of the agent shares one journal.
12
+
13
+ ## Memory is on by default
14
+
15
+ `bdk init` scaffolds `bot/hooks/memory.ts`:
16
+
17
+ ```ts
18
+ // bot/hooks/memory.ts
19
+ import { memoryHook } from "@cursor/bdk/memory";
20
+
21
+ export default memoryHook();
22
+ ```
23
+
24
+ It also adds a `## Memory` section to `bot/instructions.md`. The model
25
+ has no recall tool, so that section is what sends it to the journal:
26
+ it says when to read `memory/`, and it tells the model to treat records
27
+ as untrusted history. To add memory to an existing project, create the
28
+ hook file and copy the `## Memory` section from a fresh `bdk init`
29
+ project into your instructions. To turn memory off, delete the hook
30
+ file and the `## Memory` section.
31
+
32
+ ## Journal records
33
+
34
+ The hook appends one JSON line to `memory/journal.jsonl` after each
35
+ turn completes or fails:
36
+
37
+ ```json
38
+ {"at":"2026-10-01T16:42:09.118Z","sessionId":"5f0c2a9e-7d1b-4c43-9a6e-2b8f1e0d7c35","channelId":"slack","status":"completed","title":"Checkout flaky test","userMessage":"Why does acme/checkout fail on main?","result":"The cart test races the price service mock...","usage":{"inputTokens":18234,"outputTokens":912,"cacheReadTokens":15002,"cacheWriteTokens":0}}
39
+ ```
40
+
41
+ | Field | Contract |
42
+ | --- | --- |
43
+ | `at` | ISO-8601 time the turn finished |
44
+ | `sessionId` | Session that ran the turn |
45
+ | `channelId` | Channel that started the session, such as `http` for the session API |
46
+ | `status` | `"completed"` or `"failed"` |
47
+ | `title` | Session title, when the channel set one |
48
+ | `userMessage` | The message that started the turn, truncated to `maxTextLength` |
49
+ | `result` | Final assistant text, or the failure message, truncated to `maxTextLength` |
50
+ | `usage` | Token usage for completed turns; see [Events and payloads](./hooks.md#events-and-payloads) |
51
+
52
+ As the journal grows, older records move to `journal-*.jsonl` files
53
+ beside it. Point the model at the whole `memory/` directory when it
54
+ needs history beyond the latest segment.
55
+
56
+ ## Read memory
57
+
58
+ Local turns find the journal at `memory/` in the session workspace. On
59
+ a Cursor-hosted deployment, the first prompt of each session names the
60
+ journal's path on that machine. A session on a server you run yourself
61
+ can't reach the journal.
62
+
63
+ `memory` is a reserved workspace path. BDK rejects per-send
64
+ `workspaceFiles` and `sandbox/workspace/` seed files under `memory/`,
65
+ so callers can't write records through the workspace.
66
+
67
+ Local servers keep the journal in the project state directory. `bdk
68
+ run` and `bdk eval` start an ephemeral server with a fresh state
69
+ directory unless you pass `--state-root`, so each run starts with
70
+ empty memory. Use `bdk serve` or `bdk dev`, or pass the same
71
+ `--state-root`, to keep memory across runs. Hosted deployments keep
72
+ the journal across redeploys.
73
+
74
+ ## Who sees memory
75
+
76
+ Records from every session and every user land in the same journal, so
77
+ one person's messages and the agent's replies to them can surface in
78
+ another person's session. Turn memory off for an agent whose users
79
+ shouldn't see each other's requests. Turning it off stops new records,
80
+ but the journal keeps the records it already has. On a local server,
81
+ delete the `memory/` directory in the project state directory to clear
82
+ them. On Cursor-managed hosting, the journal is deployment data, so
83
+ [Privacy Mode](../deployment.md#privacy-mode) applies to it.
84
+
85
+ Anyone who can message the agent can put text in the journal. The
86
+ scaffolded instructions tell the model never to follow instructions
87
+ found inside records; keep that rule if you write your own section.
88
+
89
+ ## Memory and host state
90
+
91
+ Memory is advisory. A record can be dropped, and records written by
92
+ concurrent sessions can show up only in a later session. Keep state
93
+ your code depends on, such as dedupe records and cursors, in
94
+ `ctx.host.kv` or `ctx.host.files`; see
95
+ [Handler context](./hooks.md#handler-context).
96
+
97
+ ## Options
98
+
99
+ `memoryHook(options?)` accepts:
100
+
101
+ | Option | Contract |
102
+ | --- | --- |
103
+ | `maxTextLength` | Truncation cap for `userMessage` and `result`. Default `2000` characters. |
104
+ | `backend` | A `MemoryBackend` that replaces the default journal |
105
+
106
+ A `MemoryBackend` has `appendTurn(record, { stateRoot, agentName })`,
107
+ which receives each record, and an optional
108
+ `prepareSession({ stateRoot, agentName })`, which runs when a session
109
+ starts. Records go only where `appendTurn` sends them, but the
110
+ `memory/` directory and the hosted first-prompt path still point at the
111
+ default journal. Give the model a tool or file to read your records,
112
+ and write instructions that send it there instead of `memory/`.
113
+
114
+ ## Related
115
+
116
+ - [Hooks](./hooks.md)
117
+ - [Instructions](./instructions.md)
118
+ - [Sessions](./sessions.md)
119
+ - [Deployment](../deployment.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cursor/bdk",
3
- "version": "0.2.18",
3
+ "version": "0.2.20",
4
4
  "description": "Build, test, and deploy BDK bots and agents as code on Cursor's agent harness.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "repository": {
@@ -35,6 +35,7 @@
35
35
  "!templates/pr-autofixer/README.md",
36
36
  "docs/**/*.md",
37
37
  "!docs/.cursor/**",
38
+ "!docs/design/**",
38
39
  "!docs/templates/pr-autofixer.md",
39
40
  "scripts/install-cursor-skills.mjs",
40
41
  "package.json",
@@ -299,7 +300,7 @@
299
300
  },
300
301
  "dependencies": {
301
302
  "@bazel/runfiles": "6.5.0",
302
- "@cursor/sdk": "1.0.35",
303
+ "@cursor/sdk": "1.0.36",
303
304
  "@modelcontextprotocol/sdk": "1.30.0",
304
305
  "@octokit/auth-app": "^7.2.0",
305
306
  "@octokit/rest": "^21.1.1",
@@ -363,9 +364,9 @@
363
364
  "vitest": "^4.0.18",
364
365
  "yaml": "^2.4.2",
365
366
  "zustand": "^5.0.9",
366
- "@anysphere/agent-exec": "1.0.0",
367
367
  "@anysphere/agent-store-sync": "1.0.0",
368
368
  "@anysphere/context": "1.0.0",
369
+ "@anysphere/agent-exec": "1.0.0",
369
370
  "@anysphere/proto": "1.0.0",
370
371
  "@anysphere/ui": "1.0.0"
371
372
  },
@@ -3,11 +3,43 @@
3
3
 
4
4
  import { minimatch } from "minimatch";
5
5
 
6
+ export type PatternMatchOptions = {
7
+ /**
8
+ * When true, a `dir/` pattern whose directory is a glob claims the files
9
+ * under every directory the glob matches, as gitignore does. A directory
10
+ * that starts with `!` stays literal either way.
11
+ */
12
+ readonly globDirectoryPatterns?: boolean;
13
+ };
14
+
15
+ export const AO_GLOB_DIRECTORY_PATTERNS_ENV = "AO_GLOB_DIRECTORY_PATTERNS";
16
+
6
17
  /**
7
- * CODEOWNERS-style path matching. Complex prefixes before a terminal `/**`
18
+ * The glob-directory switch from `AO_GLOB_DIRECTORY_PATTERNS`: `1`, `true` or
19
+ * `yes` turns it on, and anything else, unset included, leaves it off. Turn it
20
+ * on only after the Origin shadow counter
21
+ * `origin.agentic_owners.glob_dir_shadow_mismatch` has run and its owner has
22
+ * reviewed the repos, files and patterns it reports.
23
+ */
24
+ export function globDirectoryPatternsFromEnv(
25
+ env: Readonly<Record<string, string | undefined>> = process.env,
26
+ ): PatternMatchOptions {
27
+ const value = env[AO_GLOB_DIRECTORY_PATTERNS_ENV]?.trim().toLowerCase();
28
+ return { globDirectoryPatterns: value === "1" || value === "true" || value === "yes" };
29
+ }
30
+
31
+ /**
32
+ * CODEOWNERS-style path matching. While the glob-directory switch is off, a
33
+ * `dir/` pattern is read literally, a glob included: `src/d?cs/` claims only
34
+ * files under a directory named `src/d?cs`. With it on, the glob matches
35
+ * directories as in gitignore. Complex prefixes before a terminal `/**`
8
36
  * deliberately fall through to minimatch below.
9
37
  */
10
- export function patternMatchesFile(pattern: string, filepath: string): boolean {
38
+ export function patternMatchesFile(
39
+ pattern: string,
40
+ filepath: string,
41
+ options: PatternMatchOptions = globDirectoryPatternsFromEnv(),
42
+ ): boolean {
11
43
  const patternIsRooted = pattern.startsWith("/");
12
44
  const normalizedPattern = pattern.replace(/^\/+/, "");
13
45
  const normalizedPath = filepath.replace(/^\/+/, "");
@@ -32,6 +64,16 @@ export function patternMatchesFile(pattern: string, filepath: string): boolean {
32
64
  return globMatches(normalizedPath, `${literalPrefix}*`);
33
65
  }
34
66
 
67
+ const globDirectory =
68
+ options.globDirectoryPatterns === true ? globDirectoryOf(normalizedPattern) : undefined;
69
+ if (globDirectory !== undefined) {
70
+ const rootLevelOnly = patternIsRooted && !globDirectory.includes("/");
71
+ return ancestorDirectories(normalizedPath).some(
72
+ (ancestor) =>
73
+ !(rootLevelOnly && ancestor.includes("/")) && globMatches(ancestor, globDirectory),
74
+ );
75
+ }
76
+
35
77
  if (normalizedPattern.endsWith("/")) {
36
78
  const prefix = normalizedPattern.replace(/\\(.)/g, "$1").replace(/\/+$/, "");
37
79
  if (!patternIsRooted && !prefix.includes("/")) {
@@ -63,6 +105,19 @@ function hasComplexGlob(pattern: string): boolean {
63
105
  return /[*?[\]{}!()+@]/.test(pattern);
64
106
  }
65
107
 
108
+ function globDirectoryOf(normalizedPattern: string): string | undefined {
109
+ if (!normalizedPattern.endsWith("/")) {
110
+ return undefined;
111
+ }
112
+ const directory = normalizedPattern.replace(/\/+$/, "");
113
+ return hasComplexGlob(directory) && !directory.startsWith("!") ? directory : undefined;
114
+ }
115
+
116
+ function ancestorDirectories(filepath: string): string[] {
117
+ const segments = filepath.split("/").slice(0, -1);
118
+ return segments.map((_, index) => segments.slice(0, index + 1).join("/"));
119
+ }
120
+
66
121
  /** Higher score means a more specific pattern (used to break ties within one policy.yml). */
67
122
  export function patternSpecificity(pattern: string): number {
68
123
  const normalized = pattern.replace(/^\/+/, "");