@cursor/july 0.1.5 → 0.1.6

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 (169) hide show
  1. package/dist/ab.d.ts +8 -95
  2. package/dist/ab.d.ts.map +1 -1
  3. package/dist/ab.js +9 -150
  4. package/dist/bin/agent-serve.js +14 -6
  5. package/dist/docs/404.html +2 -2
  6. package/dist/docs/ab.html +4 -4
  7. package/dist/docs/assets/{app.DabPG-io.js → app.DMboGKUD.js} +1 -1
  8. package/dist/docs/assets/chunks/@localSearchIndexroot.O6eP7QZr.js +1 -0
  9. package/dist/docs/assets/chunks/{VPLocalSearchBox.jmyr0bU0.js → VPLocalSearchBox.DkEqEnJU.js} +1 -1
  10. package/dist/docs/assets/chunks/{theme.DysN9-VN.js → theme.ASugdMNm.js} +2 -2
  11. package/dist/docs/assets/deployment.md.BtfEsc9S.js +55 -0
  12. package/dist/docs/assets/deployment.md.BtfEsc9S.lean.js +1 -0
  13. package/dist/docs/assets/example-agents_approval-buddy.md.8R5phXb5.js +10 -0
  14. package/dist/docs/assets/example-agents_approval-buddy.md.8R5phXb5.lean.js +1 -0
  15. package/dist/docs/assets/example-agents_benny.md.B0gjhI-p.js +7 -0
  16. package/dist/docs/assets/example-agents_benny.md.B0gjhI-p.lean.js +1 -0
  17. package/dist/docs/assets/example-agents_bugbot.md.DelIdhxB.js +11 -0
  18. package/dist/docs/assets/example-agents_bugbot.md.DelIdhxB.lean.js +1 -0
  19. package/dist/docs/assets/example-agents_codebase-wiki.md.DC6sgwn0.js +8 -0
  20. package/dist/docs/assets/example-agents_codebase-wiki.md.DC6sgwn0.lean.js +1 -0
  21. package/dist/docs/assets/example-agents_codeowners-review.md.Ku_tG2RY.js +8 -0
  22. package/dist/docs/assets/example-agents_codeowners-review.md.Ku_tG2RY.lean.js +1 -0
  23. package/dist/docs/assets/example-agents_concierge.md.4rQTSMXt.js +23 -0
  24. package/dist/docs/assets/example-agents_concierge.md.4rQTSMXt.lean.js +1 -0
  25. package/dist/docs/assets/example-agents_fsd.md.CzgUrDfi.js +15 -0
  26. package/dist/docs/assets/example-agents_fsd.md.CzgUrDfi.lean.js +1 -0
  27. package/dist/docs/assets/example-agents_index.md.CRqJlnIf.js +2 -0
  28. package/dist/docs/assets/example-agents_index.md.CRqJlnIf.lean.js +1 -0
  29. package/dist/docs/assets/example-agents_knowledge-base.md.BPJiVueF.js +11 -0
  30. package/dist/docs/assets/example-agents_knowledge-base.md.BPJiVueF.lean.js +1 -0
  31. package/dist/docs/assets/example-agents_security-reviewer.md.D2rtwDTO.js +19 -0
  32. package/dist/docs/assets/example-agents_security-reviewer.md.D2rtwDTO.lean.js +1 -0
  33. package/dist/docs/assets/example-agents_slack-agent.md.buLbgvBf.js +5 -0
  34. package/dist/docs/assets/example-agents_slack-agent.md.buLbgvBf.lean.js +1 -0
  35. package/dist/docs/assets/example-agents_weather-agent.md.C9Qv-W0o.js +24 -0
  36. package/dist/docs/assets/example-agents_weather-agent.md.C9Qv-W0o.lean.js +1 -0
  37. package/dist/docs/assets/index.md.COiu-1jL.js +20 -0
  38. package/dist/docs/assets/{index.md.Cylk70gg.lean.js → index.md.COiu-1jL.lean.js} +1 -1
  39. package/dist/docs/assets/reference_cli.md.D189RBCH.js +60 -0
  40. package/dist/docs/assets/reference_cli.md.D189RBCH.lean.js +1 -0
  41. package/dist/docs/building-with-agents.html +4 -4
  42. package/dist/docs/concepts.html +4 -4
  43. package/dist/docs/deployment.html +58 -17
  44. package/dist/docs/evals.html +4 -4
  45. package/dist/docs/example-agents/approval-buddy.html +34 -0
  46. package/dist/docs/example-agents/benny.html +31 -0
  47. package/dist/docs/example-agents/bugbot.html +35 -0
  48. package/dist/docs/example-agents/codebase-wiki.html +32 -0
  49. package/dist/docs/example-agents/codeowners-review.html +32 -0
  50. package/dist/docs/example-agents/concierge.html +47 -0
  51. package/dist/docs/example-agents/fsd.html +39 -0
  52. package/dist/docs/example-agents/index.html +26 -0
  53. package/dist/docs/example-agents/knowledge-base.html +35 -0
  54. package/dist/docs/example-agents/security-reviewer.html +43 -0
  55. package/dist/docs/example-agents/slack-agent.html +29 -0
  56. package/dist/docs/example-agents/weather-agent.html +48 -0
  57. package/dist/docs/guides/agent-to-agent.html +4 -4
  58. package/dist/docs/guides/cloud-runtime.html +5 -5
  59. package/dist/docs/guides/github.html +4 -4
  60. package/dist/docs/guides/human-in-the-loop.html +4 -4
  61. package/dist/docs/guides/slack.html +4 -4
  62. package/dist/docs/guides/webhooks.html +4 -4
  63. package/dist/docs/hashmap.json +1 -1
  64. package/dist/docs/hillclimbing.html +4 -4
  65. package/dist/docs/index.html +7 -7
  66. package/dist/docs/quickstart.html +4 -4
  67. package/dist/docs/reference/agent-config.html +4 -4
  68. package/dist/docs/reference/channels.html +4 -4
  69. package/dist/docs/reference/cli.html +52 -30
  70. package/dist/docs/reference/connections.html +4 -4
  71. package/dist/docs/reference/hooks.html +4 -4
  72. package/dist/docs/reference/http-api.html +4 -4
  73. package/dist/docs/reference/instructions.html +4 -4
  74. package/dist/docs/reference/playground.html +4 -4
  75. package/dist/docs/reference/project-layout.html +4 -4
  76. package/dist/docs/reference/schedules.html +4 -4
  77. package/dist/docs/reference/sessions.html +4 -4
  78. package/dist/docs/reference/skills.html +4 -4
  79. package/dist/docs/reference/subagents.html +4 -4
  80. package/dist/docs/reference/tools.html +4 -4
  81. package/dist/docs/scaffolding-agents.html +4 -4
  82. package/dist/docs/storage.html +4 -4
  83. package/dist/docs/troubleshooting.html +4 -4
  84. package/dist/evals.d.ts +4 -61
  85. package/dist/evals.d.ts.map +1 -1
  86. package/dist/evals.js +3 -66
  87. package/dist/index.d.ts +1 -1
  88. package/dist/index.d.ts.map +1 -1
  89. package/dist/internal/ab-collector.d.ts +7 -5
  90. package/dist/internal/ab-collector.d.ts.map +1 -1
  91. package/dist/internal/ab-collector.js +3 -14
  92. package/dist/internal/ab-snapshot.d.ts +2 -4
  93. package/dist/internal/ab-snapshot.d.ts.map +1 -1
  94. package/dist/internal/cli-ax.d.ts +18 -3
  95. package/dist/internal/cli-ax.d.ts.map +1 -1
  96. package/dist/internal/cli-ax.js +80 -42
  97. package/dist/internal/cli-deploy.js +1 -1
  98. package/dist/internal/discovery.js +3 -3
  99. package/dist/internal/eval-run-store.d.ts +33 -30
  100. package/dist/internal/eval-run-store.d.ts.map +1 -1
  101. package/dist/internal/eval-run-store.js +84 -96
  102. package/dist/internal/init-project.d.ts.map +1 -1
  103. package/dist/internal/init-project.js +3 -2
  104. package/dist/internal/playground-proxy.d.ts +5 -5
  105. package/dist/internal/playground-proxy.js +3 -3
  106. package/dist/internal/resolve-prod-target.d.ts +30 -0
  107. package/dist/internal/resolve-prod-target.d.ts.map +1 -1
  108. package/dist/internal/resolve-prod-target.js +74 -2
  109. package/dist/internal/server.d.ts.map +1 -1
  110. package/dist/internal/server.js +5 -3
  111. package/dist/internal/session-engine.d.ts +1 -2
  112. package/dist/internal/session-engine.d.ts.map +1 -1
  113. package/dist/internal/session-engine.js +14 -31
  114. package/dist/internal/storage-coordinator.d.ts +16 -15
  115. package/dist/internal/storage-coordinator.d.ts.map +1 -1
  116. package/dist/internal/storage-coordinator.js +73 -80
  117. package/dist/playground/assets/cursor-icons-16-CQ50JpfO.woff2 +0 -0
  118. package/dist/playground/assets/index-7GJIUFQj.css +1 -0
  119. package/dist/playground/assets/index-mux9aj5P.js +319 -0
  120. package/dist/playground/index.html +2 -2
  121. package/dist/storage.d.ts +51 -10
  122. package/dist/storage.d.ts.map +1 -1
  123. package/dist/storage.js +27 -10
  124. package/docs/README.md +34 -5
  125. package/docs/deployment.md +352 -149
  126. package/docs/example-agents/approval-buddy.md +270 -0
  127. package/docs/example-agents/benny.md +186 -0
  128. package/docs/example-agents/bugbot.md +231 -0
  129. package/docs/example-agents/codebase-wiki.md +174 -0
  130. package/docs/example-agents/codeowners-review.md +195 -0
  131. package/docs/example-agents/concierge.md +205 -0
  132. package/docs/example-agents/fsd.md +330 -0
  133. package/docs/example-agents/index.md +102 -0
  134. package/docs/example-agents/knowledge-base.md +171 -0
  135. package/docs/example-agents/security-reviewer.md +296 -0
  136. package/docs/example-agents/slack-agent.md +146 -0
  137. package/docs/example-agents/weather-agent.md +302 -0
  138. package/docs/reference/cli.md +546 -147
  139. package/package.json +1 -1
  140. package/src/ab.ts +9 -261
  141. package/src/bin/agent-serve.ts +14 -6
  142. package/src/evals.ts +4 -118
  143. package/src/index.ts +2 -0
  144. package/src/internal/ab-collector.ts +12 -22
  145. package/src/internal/ab-snapshot.ts +2 -4
  146. package/src/internal/cli-ax.ts +101 -45
  147. package/src/internal/cli-deploy.ts +1 -1
  148. package/src/internal/discovery.ts +2 -2
  149. package/src/internal/eval-run-store.ts +86 -100
  150. package/src/internal/init-project.ts +3 -2
  151. package/src/internal/playground-proxy.ts +5 -5
  152. package/src/internal/resolve-prod-target.ts +101 -3
  153. package/src/internal/server.ts +5 -3
  154. package/src/internal/session-engine.ts +9 -29
  155. package/src/internal/storage-coordinator.ts +109 -101
  156. package/src/storage.ts +79 -14
  157. package/dist/docs/assets/chunks/@localSearchIndexroot.QwK5BtEH.js +0 -1
  158. package/dist/docs/assets/deployment.md.DTKwE15Z.js +0 -14
  159. package/dist/docs/assets/deployment.md.DTKwE15Z.lean.js +0 -1
  160. package/dist/docs/assets/index.md.Cylk70gg.js +0 -20
  161. package/dist/docs/assets/reference_cli.md.Bv6pOxcF.js +0 -38
  162. package/dist/docs/assets/reference_cli.md.Bv6pOxcF.lean.js +0 -1
  163. package/dist/internal/json-dir-store.d.ts +0 -32
  164. package/dist/internal/json-dir-store.d.ts.map +0 -1
  165. package/dist/internal/json-dir-store.js +0 -100
  166. package/dist/playground/assets/cursor-icons-outline-BxTT_FVJ.woff2 +0 -0
  167. package/dist/playground/assets/index-BEauYlII.css +0 -1
  168. package/dist/playground/assets/index-BtM0wEGg.js +0 -319
  169. package/src/internal/json-dir-store.ts +0 -109
@@ -0,0 +1,174 @@
1
+ ---
2
+ title: "Build a feature wiki from merged pull requests"
3
+ description: "Ingest every merged PR into per-feature wiki pages, consolidate with a daily digest schedule, and answer codebase questions with page citations."
4
+ ---
5
+
6
+ # Build a feature wiki from merged pull requests
7
+
8
+ Codebase wiki keeps a living, feature-organized wiki of a repository.
9
+ The GitHub channel acknowledges every closed pull request instantly,
10
+ fetches a compact digest on the host, and spends a model turn only on
11
+ merged PRs. The turn maps the change onto feature pages; a daily
12
+ schedule writes a digest of what changed and rebuilds the index. Chat
13
+ sessions answer codebase questions from the wiki with page citations.
14
+
15
+ Use this project when documentation should accumulate from merges
16
+ instead of being regenerated from scratch. Use
17
+ [Knowledge base](./knowledge-base.md) when people should curate
18
+ organizational context through conversation.
19
+
20
+ [Browse the codebase wiki source.](../../examples/codebase-wiki/)
21
+
22
+ ## Treat PRs as evidence and features as pages
23
+
24
+ The wiki refuses to become a merge log:
25
+
26
+ - The page tree is rigid: `index`, `features/<slug>`, and
27
+ `digests/<yyyy-mm-dd>`. The store rejects anything else, so the wiki
28
+ can't sprawl.
29
+ - The `feature-mapping` skill requires a `wiki_search` before every
30
+ write. A PR updates the page that owns its feature; a new page needs
31
+ a genuinely new feature; chores change nothing.
32
+ - Every touched page gets a dated changelog entry citing the PR
33
+ number, so each fact traces back to a merge.
34
+
35
+ The wiki itself is markdown on the serve host, in `.agent-serve/wiki/`
36
+ by default with a `CODEBASE_WIKI_DIR` override. Sessions are
37
+ disposable; the wiki is the durable state.
38
+
39
+ ## Follow a merged PR
40
+
41
+ 1. GitHub delivers `pull_request` with action `closed`. The channel
42
+ returns a task acknowledgement immediately.
43
+ 2. The task fetches the digest with the host `gh` CLI: title, body,
44
+ labels, changed files, and a bounded diff excerpt. No checkout.
45
+ 3. The webhook payload can't say whether the PR merged, so the host
46
+ checks `mergedAt` and skips abandoned PRs without a model turn.
47
+ 4. For merged PRs, the task starts the turn with `pr/DIGEST.md` seeded
48
+ through `workspaceFiles` and a `pr:<owner/repo#N>` continuation
49
+ token, so redeliveries resume instead of double-ingesting.
50
+ 5. The model follows `feature-mapping`: search, update or create
51
+ feature pages, add changelog entries, and refresh `index` when pages
52
+ were added.
53
+
54
+ In chat, "ingest PR #123" runs the same flow through the `ingest_pr`
55
+ tool, which writes the digest into the active session workspace.
56
+
57
+ ## Map the wiki files
58
+
59
+ | File | Purpose |
60
+ | --- | --- |
61
+ | [`agent/agent.ts`](../../examples/codebase-wiki/agent/agent.ts) | Selects the cloud runtime and model. |
62
+ | [`agent/instructions.md`](../../examples/codebase-wiki/agent/instructions.md) | Splits the job into merge ingestion and wiki-cited Q&A. |
63
+ | [`agent/lib/wiki-store.ts`](../../examples/codebase-wiki/agent/lib/wiki-store.ts) | Enforces the rigid page tree and owns reads, writes, and search. |
64
+ | [`agent/lib/pr-digest.ts`](../../examples/codebase-wiki/agent/lib/pr-digest.ts) | Fetches PR metadata and diff, and formats `pr/DIGEST.md`. |
65
+ | [`agent/tools/ingest_pr.ts`](../../examples/codebase-wiki/agent/tools/ingest_pr.ts) | Exposes host digest preparation for chat-driven backfills. |
66
+ | [`agent/tools/wiki_read.ts`](../../examples/codebase-wiki/agent/tools/wiki_read.ts), [`wiki_search.ts`](../../examples/codebase-wiki/agent/tools/wiki_search.ts), [`wiki_write.ts`](../../examples/codebase-wiki/agent/tools/wiki_write.ts) | Read, search, and rewrite wiki pages. |
67
+ | [`agent/skills/feature-mapping.md`](../../examples/codebase-wiki/agent/skills/feature-mapping.md) | Maps changes onto features and fixes the page and changelog shape. |
68
+ | [`agent/schedules/daily-digest.md`](../../examples/codebase-wiki/agent/schedules/daily-digest.md) | Writes `digests/<date>`, rebuilds the index, and flags stale pages. |
69
+ | [`agent/channels/github.ts`](../../examples/codebase-wiki/agent/channels/github.ts) | Acknowledges closed PRs and starts merged-only ingest turns. |
70
+ | [`evals/ingest.eval.ts`](../../examples/codebase-wiki/evals/ingest.eval.ts) | Gates ingest decisions against the wiki filesystem. |
71
+
72
+ There is no MCP connection, subagent, hook, A/B experiment, or custom
73
+ storage.
74
+
75
+ ## Prepare credentials and services
76
+
77
+ You need:
78
+
79
+ - Node 22.13 or newer.
80
+ - An agent-runtime credential for model turns.
81
+ - `gh` on `PATH` with read access to the PRs you ingest.
82
+
83
+ The channel verifies webhook signatures when `GITHUB_WEBHOOK_SECRET` is
84
+ set and narrows repositories with
85
+ `CODEBASE_WIKI_REPOS=owner/repo,owner/other`. The agent never writes to
86
+ GitHub. Its only side effects are wiki files on the serve host.
87
+
88
+ ## Validate the surface
89
+
90
+ ```bash
91
+ agentkit validate --dir examples/codebase-wiki
92
+ agentkit info --dir examples/codebase-wiki --json
93
+ ```
94
+
95
+ The manifest should report four server tools, one skill, one schedule,
96
+ and the authored GitHub channel.
97
+
98
+ ## Ingest without webhook plumbing
99
+
100
+ Replay a real merged PR as a closed delivery:
101
+
102
+ ```bash
103
+ agentkit dev examples/codebase-wiki
104
+
105
+ agentkit github replay https://github.com/owner/repo/pull/123 \
106
+ --dir examples/codebase-wiki --action closed
107
+ ```
108
+
109
+ The reply is a 202 acknowledgement; the ingest continues in the task.
110
+ Watch the session in the playground, then read the result on disk:
111
+
112
+ ```bash
113
+ ls examples/codebase-wiki/.agent-serve/wiki/features/
114
+ ```
115
+
116
+ Each ingested feature page carries an overview, a "How it works"
117
+ section, and a changelog line citing the PR. Deterministic digest
118
+ preparation works without a model turn:
119
+
120
+ ```bash
121
+ agentkit call ingest_pr \
122
+ --dir examples/codebase-wiki \
123
+ --input '{"pr":"https://github.com/owner/repo/pull/123"}'
124
+ ```
125
+
126
+ A PR closed without merging returns `merged: false` and a note telling
127
+ the model to change nothing.
128
+
129
+ ## Run the daily digest
130
+
131
+ The schedule fires at 07:00 UTC. Under `agentkit dev`, trigger it by
132
+ hand:
133
+
134
+ ```bash
135
+ curl -s -X POST http://127.0.0.1:3000/codebase-wiki/v1/dev/schedules/daily-digest
136
+ ```
137
+
138
+ The turn reads every feature changelog, writes
139
+ `digests/<today>` grouped by feature with PR citations, rebuilds
140
+ `index`, and reports one line per page it wrote. Entries dated today
141
+ always count; a digest only claims a quiet day when no entry qualifies.
142
+
143
+ ## Run the evals
144
+
145
+ ```bash
146
+ agentkit eval --dir examples/codebase-wiki --list
147
+ agentkit eval --dir examples/codebase-wiki ingest/update-existing
148
+ ```
149
+
150
+ The cases seed a temp wiki through `CODEBASE_WIKI_DIR` and build
151
+ digests with the same formatter the channel uses, so they run without
152
+ GitHub or network access. The gates check the filesystem, not prose:
153
+ a new feature page lands on a new slug, a related PR updates the
154
+ existing page instead of duplicating it, an unmerged PR changes
155
+ nothing, and the daily pass writes a digest naming both seeded
156
+ features.
157
+
158
+ ## Reuse the merge-ingestion pattern
159
+
160
+ Copy this shape when events should accumulate into curated state:
161
+
162
+ - Acknowledge webhooks with a task and decide host-side whether a
163
+ model turn is worth spending.
164
+ - Seed evidence through `workspaceFiles` so the model never fetches.
165
+ - Constrain the durable store's shape in code and its content in a
166
+ skill.
167
+ - Add a consolidation schedule so incremental writes stay coherent.
168
+
169
+ ## Where to go next
170
+
171
+ - [GitHub webhooks](../guides/github.md)
172
+ - [Schedules](../reference/schedules.md)
173
+ - [Tools](../reference/tools.md)
174
+ - [Evals](../evals.md)
@@ -0,0 +1,195 @@
1
+ ---
2
+ title: "Route PR reviews by code ownership"
3
+ description: "Map changed paths to per-area review playbooks, fan one reviewer subagent out per area, and aggregate verdicts into a single approval decision."
4
+ ---
5
+
6
+ # Route PR reviews by code ownership
7
+
8
+ Codeowners review gives each part of a codebase its own review. A
9
+ CODEOWNERS-style table maps changed paths to review areas; each area
10
+ has a markdown playbook with the team's rules for that domain; and one
11
+ `area-reviewer` subagent runs per routed area, in parallel. A billing
12
+ change gets the billing review, a migration gets the migration review,
13
+ and an author's personal style rides along as advisory notes. The lead
14
+ aggregates: approve only when every area approves.
15
+
16
+ Use this project when review quality depends on domain-specific values
17
+ instead of one generic checklist.
18
+
19
+ [Browse the codeowners review source.](../../examples/codeowners-review/)
20
+
21
+ ## Keep routing in code and judgment in playbooks
22
+
23
+ The pipeline separates three concerns:
24
+
25
+ - `reviews/REVIEWERS` routes. Host code matches every changed path
26
+ against the table; every matching rule applies, and unmatched paths
27
+ fall back to the `general` playbook. Routing is glob code with unit
28
+ tests, not model judgment.
29
+ - `reviews/<area>.md` judges. Each playbook is a severity-ordered rule
30
+ list the team owns: billing mandates integer cents and idempotent
31
+ webhooks, migrations forbid destructive DDL beside code changes,
32
+ background jobs demand idempotency and dead-letter paths.
33
+ - Subagents review. The lead reads nothing but the manifest and
34
+ routes; each `area-reviewer` reads one playbook plus its files' diff
35
+ hunks and returns a mechanical verdict: request changes on any High
36
+ finding or two Mediums.
37
+
38
+ Personal styles extend the same mechanism. `reviews/people/<login>.md`
39
+ attaches automatically, as advisory notes, whenever that person authors
40
+ the PR. Adding an area or a style is a markdown file plus at most one
41
+ routing line.
42
+
43
+ ## Follow a review
44
+
45
+ 1. A PR arrives: a GitHub `pull_request` event, a chat message, or a
46
+ bundled fixture reference.
47
+ 2. `prepare_review` fetches metadata and the diff with the host `gh`
48
+ CLI, routes every changed file, and writes the `pr/` evidence tree:
49
+ `MANIFEST.md`, `ROUTES.md`, `diff.patch`, and a copy of each matched
50
+ playbook.
51
+ 3. The lead follows the `review-process` skill and issues one
52
+ `area-reviewer` delegation per routed area, plus one per personal
53
+ style, all in one step so they run in parallel.
54
+ 4. Each reviewer reads its playbook, reviews only its files, and
55
+ returns a verdict line with at most three findings.
56
+ 5. The lead aggregates per-area sections and the overall verdict:
57
+ APPROVE only when every non-advisory area approved.
58
+
59
+ Nothing posts to GitHub. Verdicts live in the session; the
60
+ [Approval Buddy guide](./approval-buddy.md) shows how to wire a real
61
+ APPROVE and commit statuses on top of the same shape.
62
+
63
+ ## Map the review files
64
+
65
+ | File | Purpose |
66
+ | --- | --- |
67
+ | [`reviews/REVIEWERS`](../../examples/codeowners-review/reviews/REVIEWERS) | Routes path patterns to review areas. |
68
+ | [`reviews/`](../../examples/codeowners-review/reviews/) | Holds the area playbooks and `people/<login>.md` styles. |
69
+ | [`agent/lib/routing.ts`](../../examples/codeowners-review/agent/lib/routing.ts) | Parses the table, matches globs, and unions areas per file. |
70
+ | [`agent/lib/prepare-review.ts`](../../examples/codeowners-review/agent/lib/prepare-review.ts) | Fetches PRs or fixtures and builds the evidence tree. |
71
+ | [`agent/tools/prepare_review.ts`](../../examples/codeowners-review/agent/tools/prepare_review.ts) | Exposes host preparation as a typed server tool. |
72
+ | [`agent/tools/list_review_areas.ts`](../../examples/codeowners-review/agent/tools/list_review_areas.ts) | Answers routing questions deterministically. |
73
+ | [`agent/skills/review-process.md`](../../examples/codeowners-review/agent/skills/review-process.md) | Fixes the fan-out procedure and the verdict rule. |
74
+ | [`agent/subagents/area-reviewer/`](../../examples/codeowners-review/agent/subagents/area-reviewer/) | Defines the one-area, one-playbook reviewer contract. |
75
+ | [`agent/channels/github.ts`](../../examples/codeowners-review/agent/channels/github.ts) | Reviews opened, reopened, synchronized, and undrafted PRs. |
76
+ | [`fixtures/`](../../examples/codeowners-review/fixtures/) | Ships two reviewable PRs with known planted findings. |
77
+ | [`evals/review.eval.ts`](../../examples/codeowners-review/evals/review.eval.ts) | Gates routing, fan-out, planted bugs, and verdicts. |
78
+
79
+ There is no MCP connection, schedule, hook, A/B experiment, or custom
80
+ storage.
81
+
82
+ ## Prepare credentials and services
83
+
84
+ You need:
85
+
86
+ - Node 22.13 or newer.
87
+ - An agent-runtime credential for model turns.
88
+ - `gh` on `PATH` with read access to real PRs you review. The bundled
89
+ fixtures need no network at all.
90
+
91
+ The channel verifies webhook signatures when `GITHUB_WEBHOOK_SECRET` is
92
+ set and narrows repositories with
93
+ `CODEOWNERS_REVIEW_REPOS=owner/repo,owner/other`. Pushes re-review in
94
+ the same session through the `pr:<label>` continuation token.
95
+
96
+ ## Validate the surface
97
+
98
+ ```bash
99
+ agentkit validate --dir examples/codeowners-review
100
+ agentkit info --dir examples/codeowners-review --json
101
+ ```
102
+
103
+ The manifest should report two server tools, one skill, one subagent,
104
+ and the authored GitHub channel.
105
+
106
+ ## Inspect routing without a model turn
107
+
108
+ ```bash
109
+ agentkit call list_review_areas --dir examples/codeowners-review --input '{}'
110
+
111
+ agentkit call prepare_review \
112
+ --dir examples/codeowners-review \
113
+ --input '{"pr":"fixture:multi-area"}'
114
+ ```
115
+
116
+ The fixture routes to `billing`, `database-migrations`, and `frontend`,
117
+ attaches `people/alice` because alice authored it, and returns the full
118
+ evidence map. Point the same tool at a real PR URL and the routing runs
119
+ against the live file list. The example table maps a hypothetical
120
+ `src/` layout, so most real repositories route to `general` until you
121
+ adapt `reviews/REVIEWERS`.
122
+
123
+ ## Review the planted fixture
124
+
125
+ ```bash
126
+ agentkit dev examples/codeowners-review
127
+ ```
128
+
129
+ In the playground:
130
+
131
+ > Review fixture:multi-area
132
+
133
+ The fixture plants one violation per area: float dollar math in
134
+ `src/billing/invoice.ts`, a `DROP COLUMN` plus a non-concurrent index
135
+ in the migration, and a clickable `div` without loading states in the
136
+ UI. The trace shows `prepare_review`, the evidence reads, four parallel
137
+ `area-reviewer` cards, and an aggregated CHANGES REQUESTED verdict with
138
+ each planted bug filed under its own area. The second fixture,
139
+ `fixture:jobs-clean`, routes to `background-jobs` alone and ends in
140
+ APPROVE.
141
+
142
+ Review a real PR the same way:
143
+
144
+ > Review https://github.com/owner/repo/pull/123
145
+
146
+ Or replay one as a webhook delivery:
147
+
148
+ ```bash
149
+ agentkit github replay https://github.com/owner/repo/pull/123 \
150
+ --dir examples/codeowners-review --action opened
151
+ ```
152
+
153
+ ## See how the verdict stays mechanical
154
+
155
+ The reviewer contract computes verdicts from findings instead of
156
+ letting the model pick a mood: findings first, then
157
+ `request-changes` if any High exists or two Mediums do, otherwise
158
+ `approve`. Pre-existing issues visible in context are scoped out, at
159
+ most one advisory Low. The lead applies one rule on top: the PR is
160
+ APPROVE only when every non-advisory area approved.
161
+
162
+ ## Run the evals
163
+
164
+ ```bash
165
+ agentkit eval --dir examples/codeowners-review --list
166
+ agentkit eval --dir examples/codeowners-review review/multi-area
167
+ ```
168
+
169
+ `review/multi-area` gates the whole pipeline: `prepare_review` runs, at
170
+ least three subagent delegations happen, the reply carries every area
171
+ section plus alice's advisory notes, the planted billing and migration
172
+ bugs surface, and the verdict requests changes. `review/clean-approve`
173
+ proves the approval path on the clean fixture, and
174
+ `review/routing-question` gates that routing answers come from
175
+ `list_review_areas`.
176
+
177
+ ## Reuse the ownership-routing pattern
178
+
179
+ Copy this shape when different code deserves different judgment:
180
+
181
+ - Route with data and code, not prompt instructions. Tables and globs
182
+ are testable.
183
+ - Write one playbook per domain and keep each reviewer blind to the
184
+ others.
185
+ - Make verdicts mechanical so aggregation is arithmetic, not
186
+ negotiation.
187
+ - Ship fixtures with planted findings so the review quality itself is
188
+ testable offline.
189
+
190
+ ## Where to go next
191
+
192
+ - [Approval Buddy](./approval-buddy.md) for posting real approvals
193
+ - [Subagents](../reference/subagents.md)
194
+ - [GitHub webhooks](../guides/github.md)
195
+ - [Evals](../evals.md)
@@ -0,0 +1,205 @@
1
+ ---
2
+ title: "Compose agents with a concierge"
3
+ description: "Delegate weather requests through a peer MCP connection while each agent keeps its own instructions, tools, context, and sessions."
4
+ ---
5
+
6
+ # Compose agents with a concierge
7
+
8
+ Concierge answers general questions itself and sends every weather question
9
+ to the weather agent. The connection is one file. Agentkit turns the target
10
+ agent's MCP endpoint into tools the concierge can call.
11
+
12
+ Use this example when two agents are useful on their own and one should
13
+ delegate a narrow class of work to the other.
14
+
15
+ [Browse the Concierge source.](../../examples/concierge/)
16
+
17
+ ## Delegate through a peer MCP connection
18
+
19
+ Concierge has no domain tool of its own. Its capability comes from a peer MCP
20
+ connection:
21
+
22
+ ```ts
23
+ export default defineConnection({
24
+ agent: "weather-agent",
25
+ description:
26
+ "The weather-agent peer: delegate weather questions with ask; it runs its own tools (live Open-Meteo data) in its own context.",
27
+ });
28
+ ```
29
+
30
+ The filename
31
+ [`weather.ts`](../../examples/concierge/agent/mcp-connections/weather.ts)
32
+ makes the MCP server name `weather`. The `agent` field points to the sibling
33
+ project's mount slug.
34
+
35
+ This differs from a subagent. A peer keeps its own:
36
+
37
+ - root instructions,
38
+ - tools and MCP connections,
39
+ - durable sessions,
40
+ - playground, and
41
+ - public MCP endpoint.
42
+
43
+ An SDK subagent inherits the parent's execution surface and only its parent
44
+ can invoke it. See [Agent-to-agent](../guides/agent-to-agent.md) for the full
45
+ comparison.
46
+
47
+ ## Follow a delegated request
48
+
49
+ 1. A user asks Concierge what to pack for Paris.
50
+ 2. [`instructions.md`](../../examples/concierge/agent/instructions.md)
51
+ classifies packing advice as weather-related.
52
+ 3. The model calls `weather.ask` with the city, timeframe, units, and the
53
+ complete question.
54
+ 4. Agentkit creates an MCP-channel session inside `weather-agent`.
55
+ 5. Weather agent calls its own Open-Meteo tools and returns a reply.
56
+ 6. If the turn exceeds the bounded MCP wait, `ask` returns
57
+ `status: "running"`. Concierge calls `weather.check` with the returned
58
+ `sessionId`.
59
+ 7. Concierge relays the result and may add one sentence of travel advice.
60
+
61
+ The weather session appears in the weather agent's playground. It doesn't
62
+ share Concierge's conversation history.
63
+
64
+ ## Map the delegation files
65
+
66
+ | File | Purpose |
67
+ | --- | --- |
68
+ | [`agent/agent.ts`](../../examples/concierge/agent/agent.ts) | Describes the root agent and selects the local runtime. |
69
+ | [`agent/instructions.md`](../../examples/concierge/agent/instructions.md) | Draws a strict weather-only delegation boundary. |
70
+ | [`agent/mcp-connections/weather.ts`](../../examples/concierge/agent/mcp-connections/weather.ts) | Resolves the peer by its `weather-agent` slug. |
71
+
72
+ Concierge doesn't author channels, tools, skills, subagents, schedules,
73
+ hooks, A/B experiments, or evals. The built-in HTTP and MCP surfaces still
74
+ exist.
75
+
76
+ Its own MCP endpoint exposes `ask` and `check`. It doesn't expose
77
+ `call_tool` because Concierge has no server tools. The target weather agent
78
+ does expose `call_tool`, so that tool also appears under Concierge's
79
+ `weather` connection.
80
+
81
+ ## Mount both agents
82
+
83
+ A peer can only resolve within a multi-agent serve host. Validating Concierge
84
+ alone checks its files, but serving it alone fails because `weather-agent`
85
+ isn't mounted.
86
+
87
+ From `packages/agent-serve`, validate both projects:
88
+
89
+ ```bash
90
+ agentkit validate --dir examples/concierge
91
+ agentkit validate --dir examples/weather-agent
92
+ ```
93
+
94
+ Don't serve the repository's whole `examples/` directory for this proof.
95
+ Several advanced examples subscribe to live GitHub events. Create an ignored
96
+ two-project mount instead. Copy only the authored files needed for this proof,
97
+ leaving Weather's Slack channels out:
98
+
99
+ ```bash
100
+ mkdir -p "$PWD/.agent-serve"
101
+ PAIR_DIR=$(mktemp -d "$PWD/.agent-serve/concierge-weather.XXXXXX")
102
+ mkdir -p "$PAIR_DIR/concierge" "$PAIR_DIR/weather-agent/agent"
103
+ cp -R examples/concierge/agent "$PAIR_DIR/concierge/"
104
+ cp examples/concierge/package.json "$PAIR_DIR/concierge/"
105
+ cp examples/weather-agent/agent/{agent.ts,instructions.md,ab.ts,ab.config.ts} \
106
+ "$PAIR_DIR/weather-agent/agent/"
107
+ cp -R examples/weather-agent/agent/{tools,skills,mcp-connections,subagents,schedules,hooks,lib} \
108
+ "$PAIR_DIR/weather-agent/agent/"
109
+ cp -R examples/weather-agent/mcp "$PAIR_DIR/weather-agent/"
110
+ cp examples/weather-agent/package.json "$PAIR_DIR/weather-agent/"
111
+ agentkit dev "$PAIR_DIR"
112
+ ```
113
+
114
+ The host resolves the peer after it knows every mount. The local peer URL is
115
+ `http://127.0.0.1:3000/weather-agent/v1/mcp`. You still need an agent-runtime
116
+ credential for both model turns.
117
+
118
+ ## Exercise delegation
119
+
120
+ Send a weather request to the running Concierge:
121
+
122
+ ```bash
123
+ agentkit chat \
124
+ --url http://127.0.0.1:3000/concierge \
125
+ --message "What should I pack for Paris tomorrow?"
126
+ ```
127
+
128
+ Open both playgrounds:
129
+
130
+ - `http://127.0.0.1:3000/concierge/playground`
131
+ - `http://127.0.0.1:3000/weather-agent/playground`
132
+
133
+ The Concierge transcript shows the MCP call. The weather playground shows a
134
+ separate session on the `mcp` channel with live weather tool calls.
135
+
136
+ Now send a general request:
137
+
138
+ ```bash
139
+ agentkit chat \
140
+ --url http://127.0.0.1:3000/concierge \
141
+ --message "Give me three ideas for a quiet weekend."
142
+ ```
143
+
144
+ The instructions tell Concierge to answer without delegating. This contrast is
145
+ the proof loop: weather goes to the peer, unrelated work stays local.
146
+
147
+ ## Preserve peer context
148
+
149
+ `weather.ask` returns a peer `sessionId`. Passing it back to a later `ask`
150
+ continues the same weather conversation. Concierge's instructions require
151
+ this for follow-ups dependent on an earlier answer.
152
+
153
+ Use a fresh call when the tasks are independent. Reuse the peer session when
154
+ the second question needs facts or choices from the first.
155
+
156
+ ## Keep delegation bounded
157
+
158
+ Agentkit rejects unknown peer slugs and self-references during startup. It
159
+ doesn't stop a cycle across several valid peers. If agent A delegates all work
160
+ to B and B delegates all work to A, they can recurse.
161
+
162
+ The prompt provides the guardrail here:
163
+
164
+ - delegate every weather request,
165
+ - include complete context, and
166
+ - never delegate unrelated work.
167
+
168
+ Write similarly narrow routing rules for each peer. A tool description helps
169
+ the model choose the connection, but the always-on instructions own the
170
+ policy.
171
+
172
+ ## Use peers from cloud turns
173
+
174
+ Local turns reach peers over loopback. A cloud VM can't reach the serve
175
+ host's loopback address. Set a public URL when a cloud agent needs the peer:
176
+
177
+ ```bash
178
+ agentkit serve --dir "$PAIR_DIR" \
179
+ --public-url https://agents.example.com \
180
+ --bearer-token "$AGENT_TOKEN"
181
+ ```
182
+
183
+ Agentkit attaches the bearer token to peer calls. Without `--public-url`,
184
+ cloud turns omit peer connections and the server logs a warning.
185
+
186
+ ## Compose your own pair
187
+
188
+ To compose your own agents:
189
+
190
+ 1. Give each project a stable directory slug.
191
+ 2. Add `agent/mcp-connections/<name>.ts` to the caller.
192
+ 3. Set `agent` to the target slug.
193
+ 4. Describe the exact work the peer owns.
194
+ 5. Mount both projects from their parent directory.
195
+ 6. Add evals for delegated and non-delegated requests.
196
+
197
+ Keep the peer independently useful. If the specialist only makes sense inside
198
+ one parent and needs no independent sessions, use a subagent instead.
199
+
200
+ ## Where to go next
201
+
202
+ - [Agent-to-agent](../guides/agent-to-agent.md)
203
+ - [MCP connections](../reference/connections.md)
204
+ - [Subagents](../reference/subagents.md)
205
+ - [Sessions and streaming](../reference/sessions.md)