plotroom 0.1.0__py3-none-any.whl

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 (150) hide show
  1. plotroom/__init__.py +0 -0
  2. plotroom/__main__.py +8 -0
  3. plotroom/_secret_file.py +8 -0
  4. plotroom/adapters/__init__.py +0 -0
  5. plotroom/adapters/claude_desktop.py +219 -0
  6. plotroom/adapters/embedding_http.py +175 -0
  7. plotroom/adapters/github/__init__.py +337 -0
  8. plotroom/adapters/github/app_credential.py +209 -0
  9. plotroom/adapters/github/ci.py +738 -0
  10. plotroom/adapters/github/commit_statuses.py +63 -0
  11. plotroom/adapters/github/deployments.py +213 -0
  12. plotroom/adapters/github/details.py +867 -0
  13. plotroom/adapters/github/issue_details.py +368 -0
  14. plotroom/adapters/github/junit.py +210 -0
  15. plotroom/adapters/github/junit_xml.py +162 -0
  16. plotroom/adapters/github/kodus_review.py +347 -0
  17. plotroom/adapters/github/pr_details.py +192 -0
  18. plotroom/adapters/github/pull_comparison.py +108 -0
  19. plotroom/adapters/github/read.py +530 -0
  20. plotroom/adapters/github/ticket_tree.py +336 -0
  21. plotroom/adapters/mcp/__init__.py +5 -0
  22. plotroom/adapters/mcp/proxy.py +722 -0
  23. plotroom/adapters/mcp/server.py +931 -0
  24. plotroom/adapters/openrouter.py +151 -0
  25. plotroom/adapters/store_sqlite/__init__.py +6 -0
  26. plotroom/adapters/store_sqlite/actions_sql.py +148 -0
  27. plotroom/adapters/store_sqlite/asks_sql.py +153 -0
  28. plotroom/adapters/store_sqlite/backfill_sql.py +138 -0
  29. plotroom/adapters/store_sqlite/budgets_sql.py +102 -0
  30. plotroom/adapters/store_sqlite/checklists_sql.py +77 -0
  31. plotroom/adapters/store_sqlite/claims_sql.py +54 -0
  32. plotroom/adapters/store_sqlite/embedding_sql.py +275 -0
  33. plotroom/adapters/store_sqlite/github_sql.py +331 -0
  34. plotroom/adapters/store_sqlite/goals_sql.py +57 -0
  35. plotroom/adapters/store_sqlite/human_queue_sql.py +60 -0
  36. plotroom/adapters/store_sqlite/items_sql.py +129 -0
  37. plotroom/adapters/store_sqlite/lanes_sql.py +85 -0
  38. plotroom/adapters/store_sqlite/ledger_sql.py +506 -0
  39. plotroom/adapters/store_sqlite/migrate.py +194 -0
  40. plotroom/adapters/store_sqlite/migrations/env.py +36 -0
  41. plotroom/adapters/store_sqlite/migrations/script.py.mako +19 -0
  42. plotroom/adapters/store_sqlite/migrations/versions/0001_project_meta.py +23 -0
  43. plotroom/adapters/store_sqlite/migrations/versions/0002_event_log.py +40 -0
  44. plotroom/adapters/store_sqlite/migrations/versions/0003_next_items.py +49 -0
  45. plotroom/adapters/store_sqlite/migrations/versions/0004_actions.py +28 -0
  46. plotroom/adapters/store_sqlite/migrations/versions/0005_lanes.py +36 -0
  47. plotroom/adapters/store_sqlite/migrations/versions/0006_work_items.py +22 -0
  48. plotroom/adapters/store_sqlite/migrations/versions/0007_item_changes.py +33 -0
  49. plotroom/adapters/store_sqlite/migrations/versions/0008_claude_turn_aliases.py +30 -0
  50. plotroom/adapters/store_sqlite/migrations/versions/0009_github_projection.py +38 -0
  51. plotroom/adapters/store_sqlite/migrations/versions/0010_github_pull_freshness.py +37 -0
  52. plotroom/adapters/store_sqlite/migrations/versions/0011_github_resources.py +27 -0
  53. plotroom/adapters/store_sqlite/migrations/versions/0012_local_triggers_outbox.py +80 -0
  54. plotroom/adapters/store_sqlite/migrations/versions/0013_lane_claims.py +22 -0
  55. plotroom/adapters/store_sqlite/migrations/versions/0015_recurring_triggers.py +45 -0
  56. plotroom/adapters/store_sqlite/migrations/versions/0016_merge_controller.py +28 -0
  57. plotroom/adapters/store_sqlite/migrations/versions/0017_lane_checklists.py +36 -0
  58. plotroom/adapters/store_sqlite/migrations/versions/0018_guardrails.py +33 -0
  59. plotroom/adapters/store_sqlite/migrations/versions/0019_clerk_import_metadata.py +16 -0
  60. plotroom/adapters/store_sqlite/migrations/versions/0020_search.py +30 -0
  61. plotroom/adapters/store_sqlite/migrations/versions/0021_human_queue.py +46 -0
  62. plotroom/adapters/store_sqlite/migrations/versions/0022_search_records.py +77 -0
  63. plotroom/adapters/store_sqlite/migrations/versions/0023_operator_goals.py +25 -0
  64. plotroom/adapters/store_sqlite/migrations/versions/0024_embedding_rejections.py +36 -0
  65. plotroom/adapters/store_sqlite/outbox_sql.py +78 -0
  66. plotroom/adapters/store_sqlite/routes_sql.py +26 -0
  67. plotroom/adapters/store_sqlite/search_sql.py +116 -0
  68. plotroom/adapters/store_sqlite/store.py +623 -0
  69. plotroom/adapters/store_sqlite/triggers_sql.py +111 -0
  70. plotroom/adapters/store_sqlite/work_items_sql.py +36 -0
  71. plotroom/adapters/switchboard.py +152 -0
  72. plotroom/adapters/usage_fixture.py +11 -0
  73. plotroom/adapters/work_items_bmad.py +256 -0
  74. plotroom/adapters/work_items_github_issues.py +323 -0
  75. plotroom/app/__init__.py +0 -0
  76. plotroom/app/bridge.py +162 -0
  77. plotroom/app/clerk_import.py +349 -0
  78. plotroom/app/cli.py +290 -0
  79. plotroom/app/clock.py +12 -0
  80. plotroom/app/config.py +984 -0
  81. plotroom/app/daemon_start.py +453 -0
  82. plotroom/app/lock.py +77 -0
  83. plotroom/app/logging.py +93 -0
  84. plotroom/app/portfile.py +218 -0
  85. plotroom/app/runtime.py +518 -0
  86. plotroom/app/serve.py +671 -0
  87. plotroom/app/session_intake.py +51 -0
  88. plotroom/app/sqlite_floor.py +35 -0
  89. plotroom/app/tokens.py +265 -0
  90. plotroom/core/__init__.py +0 -0
  91. plotroom/core/actions.py +67 -0
  92. plotroom/core/ask_checks.py +124 -0
  93. plotroom/core/asks.py +123 -0
  94. plotroom/core/branch_updates.py +207 -0
  95. plotroom/core/bridge.py +112 -0
  96. plotroom/core/briefs.py +83 -0
  97. plotroom/core/budgets.py +182 -0
  98. plotroom/core/catalog.py +464 -0
  99. plotroom/core/checklists.py +151 -0
  100. plotroom/core/claims.py +296 -0
  101. plotroom/core/clerk_import.py +379 -0
  102. plotroom/core/commands.py +85 -0
  103. plotroom/core/deploy_window.py +21 -0
  104. plotroom/core/envelope.py +20 -0
  105. plotroom/core/events.py +227 -0
  106. plotroom/core/github.py +306 -0
  107. plotroom/core/github_projection.py +310 -0
  108. plotroom/core/goal_language.py +374 -0
  109. plotroom/core/goal_projection.py +146 -0
  110. plotroom/core/human_queue.py +119 -0
  111. plotroom/core/intake.py +106 -0
  112. plotroom/core/kodus_review.py +53 -0
  113. plotroom/core/lanes.py +281 -0
  114. plotroom/core/ledger.py +808 -0
  115. plotroom/core/merge_controller.py +344 -0
  116. plotroom/core/merge_flakes.py +422 -0
  117. plotroom/core/merge_gate.py +724 -0
  118. plotroom/core/merge_lane.py +70 -0
  119. plotroom/core/merge_overlap.py +76 -0
  120. plotroom/core/next_items.py +60 -0
  121. plotroom/core/operator_goals.py +103 -0
  122. plotroom/core/outbox.py +70 -0
  123. plotroom/core/pull_overlaps.py +152 -0
  124. plotroom/core/reports.py +62 -0
  125. plotroom/core/roles.py +100 -0
  126. plotroom/core/routing.py +55 -0
  127. plotroom/core/run_reports.py +53 -0
  128. plotroom/core/search.py +266 -0
  129. plotroom/core/search_sources.py +94 -0
  130. plotroom/core/snapshot.py +204 -0
  131. plotroom/core/trigger_actions.py +89 -0
  132. plotroom/core/triggers.py +550 -0
  133. plotroom/core/unit_of_work.py +541 -0
  134. plotroom/core/watchers.py +35 -0
  135. plotroom/core/work_items.py +23 -0
  136. plotroom/core/writer.py +164 -0
  137. plotroom/ports/__init__.py +6 -0
  138. plotroom/ports/clock.py +12 -0
  139. plotroom/ports/github_write.py +72 -0
  140. plotroom/ports/search.py +197 -0
  141. plotroom/ports/session_reader.py +23 -0
  142. plotroom/ports/store.py +323 -0
  143. plotroom/ports/usage_meter.py +35 -0
  144. plotroom/ports/work_items.py +22 -0
  145. plotroom/py.typed +0 -0
  146. plotroom-0.1.0.dist-info/METADATA +230 -0
  147. plotroom-0.1.0.dist-info/RECORD +150 -0
  148. plotroom-0.1.0.dist-info/WHEEL +4 -0
  149. plotroom-0.1.0.dist-info/entry_points.txt +2 -0
  150. plotroom-0.1.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,336 @@
1
+ """Read BMad ticket data from a pinned default-branch commit."""
2
+
3
+ import asyncio
4
+ import base64
5
+ import re
6
+ import tempfile
7
+ from collections import OrderedDict
8
+ from collections.abc import Awaitable, Callable
9
+ from dataclasses import dataclass
10
+ from datetime import UTC, datetime
11
+ from pathlib import Path, PurePosixPath
12
+ from typing import Self, cast
13
+ from urllib.parse import quote
14
+
15
+ import httpx
16
+
17
+ from plotroom.adapters.github import (
18
+ GitHubCredential,
19
+ GitHubRateLimited,
20
+ GitHubUnavailable,
21
+ repository_client,
22
+ )
23
+ from plotroom.adapters.github.read import GitHubReadClient, Row, obj
24
+ from plotroom.ports.work_items import MAX_WORK_ITEM_BODY_BYTES, WorkItem
25
+
26
+ _STORE_CONFIG = PurePosixPath("_bmad/custom/ticketing-store-config.toml")
27
+ _MAX_ENTRIES = 512
28
+ _MAX_FILE_BYTES = MAX_WORK_ITEM_BODY_BYTES
29
+ _MAX_TREE_BYTES = 16 * 1024 * 1024
30
+ _MAX_DIRECTORY_ENTRIES = 4096
31
+ _BLOB_BATCH = 8
32
+ _BODY_CACHE_ENTRIES = 16
33
+ _FETCH_TIMEOUT = 60
34
+ _SHA = re.compile(r"(?:[0-9a-f]{40}|[0-9a-f]{64})")
35
+
36
+
37
+ class GitHubTicketTreeError(ValueError):
38
+ """The pinned ticket tree cannot be read safely or completely."""
39
+
40
+
41
+ def validate_tree_path(value: str) -> PurePosixPath:
42
+ path = PurePosixPath(value)
43
+ if (
44
+ path.is_absolute()
45
+ or path.as_posix() != value
46
+ or ".." in path.parts
47
+ or ":" in value
48
+ or "\\" in value
49
+ or any(not char.isprintable() for char in value)
50
+ or len(value.encode("utf-8")) > 1024
51
+ or len(path.parts) > 32
52
+ ):
53
+ raise GitHubTicketTreeError("the GitHub ticket tree needs a repository-relative path")
54
+ return path
55
+
56
+
57
+ def _destination(checkout: Path, relative: PurePosixPath) -> Path:
58
+ destination = (checkout / relative).resolve()
59
+ if not destination.is_relative_to(checkout):
60
+ raise GitHubTicketTreeError("the ticket tree path leaves its temporary checkout")
61
+ return destination
62
+
63
+
64
+ def _object(value: object) -> Row:
65
+ try:
66
+ return obj(value)
67
+ except ValueError:
68
+ raise GitHubTicketTreeError("GitHub returned invalid ticket tree metadata") from None
69
+
70
+
71
+ def _sha(value: object) -> str:
72
+ if not isinstance(value, str) or not _SHA.fullmatch(value):
73
+ raise GitHubTicketTreeError("GitHub returned an invalid Git object ID")
74
+ return value
75
+
76
+
77
+ def _ticket_directory(path: PurePosixPath) -> bool:
78
+ """Folder layouts the local BMad reader scans inside a ticket scope."""
79
+ parts = path.parts
80
+ return parts in ((), ("tickets",)) or (
81
+ len(parts) >= 2
82
+ and parts[0] == "tickets"
83
+ and parts[1].startswith("epic-")
84
+ and parts[2:] in ((), ("tickets",))
85
+ )
86
+
87
+
88
+ @dataclass(frozen=True)
89
+ class _Blob:
90
+ sha: str
91
+ size: int
92
+
93
+ @classmethod
94
+ def from_entry(cls, entry: Row) -> Self:
95
+ if entry.get("type") != "blob" or entry.get("mode") not in ("100644", "100755"):
96
+ raise GitHubTicketTreeError("GitHub ticket data must be stored as regular files")
97
+ size = entry.get("size")
98
+ if type(size) is not int or not 0 <= size <= _MAX_FILE_BYTES:
99
+ raise GitHubTicketTreeError("a GitHub ticket tree file exceeds the size limit")
100
+ return cls(_sha(entry.get("sha")), size)
101
+
102
+
103
+ class _GitObjects:
104
+ def __init__(self, api: GitHubReadClient, client: httpx.AsyncClient, token: str) -> None:
105
+ self._api = api
106
+ self._client = client
107
+ self._token = token
108
+ self._directories: dict[str, dict[str, Row]] = {}
109
+
110
+ async def _get(self, path: str, params: dict[str, str] | None = None) -> Row:
111
+ try:
112
+ value = await self._api.get(self._client, self._token, path, params)
113
+ except ValueError:
114
+ raise GitHubTicketTreeError("GitHub returned invalid ticket tree metadata") from None
115
+ return _object(value)
116
+
117
+ async def default_commit(self) -> tuple[str, str]:
118
+ branch = (await self._get("")).get("default_branch")
119
+ if not isinstance(branch, str) or not branch or branch == "." or branch == "..":
120
+ raise GitHubTicketTreeError("GitHub did not report a default branch")
121
+ details = await self._get(f"/branches/{quote(branch, safe='')}")
122
+ commit = _object(details.get("commit"))
123
+ tree = _object(_object(commit.get("commit")).get("tree"))
124
+ return _sha(commit.get("sha")), _sha(tree.get("sha"))
125
+
126
+ async def _entries(self, sha: str, *, recursive: bool) -> dict[str, Row]:
127
+ tree = await self._get(f"/git/trees/{sha}", {"recursive": "1"} if recursive else None)
128
+ raw = tree.get("tree")
129
+ if tree.get("truncated") is not False or not isinstance(raw, list):
130
+ raise GitHubTicketTreeError("GitHub returned an incomplete ticket tree")
131
+ values = cast("list[object]", raw)
132
+ if not recursive and len(values) > _MAX_DIRECTORY_ENTRIES:
133
+ raise GitHubTicketTreeError("a GitHub ticket tree directory exceeds the entry limit")
134
+ entries: dict[str, Row] = {}
135
+ for value in values:
136
+ entry = _object(value)
137
+ path = entry.get("path")
138
+ if not isinstance(path, str) or path == "." or path in entries:
139
+ raise GitHubTicketTreeError("GitHub returned an invalid ticket tree path")
140
+ parts = validate_tree_path(path).parts
141
+ if not recursive and len(parts) != 1:
142
+ raise GitHubTicketTreeError("GitHub returned an invalid directory entry")
143
+ entries[path] = entry
144
+ return entries
145
+
146
+ async def locate(self, root: str, path: PurePosixPath) -> Row | None:
147
+ entry: Row = {"type": "tree", "sha": root}
148
+ for part in path.parts:
149
+ if entry.get("type") != "tree":
150
+ raise GitHubTicketTreeError("a GitHub ticket directory is not a Git tree")
151
+ sha = _sha(entry.get("sha"))
152
+ if sha not in self._directories:
153
+ self._directories[sha] = await self._entries(sha, recursive=False)
154
+ candidate = self._directories[sha].get(part)
155
+ if candidate is None:
156
+ return None
157
+ entry = candidate
158
+ return entry
159
+
160
+ async def files(
161
+ self, sha: str, scope: PurePosixPath
162
+ ) -> tuple[tuple[PurePosixPath, ...], dict[PurePosixPath, _Blob]]:
163
+ directories: list[PurePosixPath] = []
164
+ files: dict[PurePosixPath, _Blob] = {}
165
+ for path, entry in (await self._entries(sha, recursive=True)).items():
166
+ relative = PurePosixPath(path)
167
+ if entry.get("type") == "tree":
168
+ # Keep old-layout epic folders so the reader can still reject that layout.
169
+ if _ticket_directory(relative) or (
170
+ len(relative.parts) == 1 and relative.name.startswith("epic-")
171
+ ):
172
+ directories.append(scope / relative)
173
+ continue
174
+ if _ticket_directory(relative.parent) and (
175
+ relative.suffix == ".md" or relative.name == "tickets.toml"
176
+ ):
177
+ files[scope / relative] = _Blob.from_entry(entry)
178
+ return tuple(directories), files
179
+
180
+ async def config(self, sha: str, tree: PurePosixPath) -> tuple[PurePosixPath, _Blob] | None:
181
+ # Match the local reader's nearest BMad project root, including in a monorepo.
182
+ for directory in (tree, *tree.parents):
183
+ bmad = await self.locate(sha, directory / "_bmad")
184
+ if bmad is not None and bmad.get("type") == "tree":
185
+ path = directory / _STORE_CONFIG
186
+ entry = await self.locate(sha, path)
187
+ return (path, _Blob.from_entry(entry)) if entry is not None else None
188
+ return None
189
+
190
+ async def blob(self, blob: _Blob) -> bytes:
191
+ item = await self._get(f"/git/blobs/{blob.sha}")
192
+ content = item.get("content")
193
+ if (
194
+ item.get("encoding") != "base64"
195
+ or not isinstance(content, str)
196
+ or item.get("size") != blob.size
197
+ or len(content) > blob.size * 2 + 16
198
+ ):
199
+ raise GitHubTicketTreeError("GitHub returned an invalid ticket file")
200
+ try:
201
+ decoded = base64.b64decode(content.replace("\n", ""), validate=True)
202
+ except ValueError:
203
+ raise GitHubTicketTreeError("GitHub returned invalid ticket file encoding") from None
204
+ if len(decoded) != blob.size:
205
+ raise GitHubTicketTreeError("GitHub returned an incomplete ticket file")
206
+ return decoded
207
+
208
+
209
+ class GitHubTicketTree:
210
+ def __init__(
211
+ self,
212
+ api: GitHubReadClient,
213
+ credential: GitHubCredential,
214
+ tree: str,
215
+ read_tree: Callable[[Path, Path], Awaitable[tuple[WorkItem, ...]]],
216
+ *,
217
+ read_body: Callable[[Path, Path, str], Awaitable[str | None]],
218
+ transport: httpx.AsyncBaseTransport | None = None,
219
+ cooling_down: Callable[[], Awaitable[bool]] | None = None,
220
+ report_rate_limit: Callable[[GitHubRateLimited], Awaitable[None]] | None = None,
221
+ ) -> None:
222
+ self._api = api
223
+ self._credential = credential
224
+ self._tree = validate_tree_path(tree)
225
+ self._read_tree = read_tree
226
+ self._read_body = read_body
227
+ self._transport = transport
228
+ self._cooling_down = cooling_down
229
+ self._report_rate_limit = report_rate_limit
230
+ self._cached: tuple[str, tuple[WorkItem, ...]] | None = None
231
+ self._body_cache: OrderedDict[tuple[str, str], str] = OrderedDict()
232
+ self._retry_until: datetime | None = None
233
+
234
+ async def ready_items(self) -> tuple[WorkItem, ...]:
235
+ return await self._fetch(self._read_commit)
236
+
237
+ async def body(self, ref: str) -> str | None:
238
+ async def read(git: _GitObjects) -> str | None:
239
+ commit, root_sha = await git.default_commit()
240
+ key = (commit, ref)
241
+ if key in self._body_cache:
242
+ self._body_cache.move_to_end(key)
243
+ return self._body_cache[key]
244
+ body = await self._read_tree_at(
245
+ git, root_sha, lambda tree, root: self._read_body(tree, root, ref)
246
+ )
247
+ if body is not None:
248
+ self._body_cache[key] = body
249
+ self._body_cache.move_to_end(key)
250
+ if len(self._body_cache) > _BODY_CACHE_ENTRIES:
251
+ self._body_cache.popitem(last=False)
252
+ return body
253
+
254
+ return await self._fetch(read)
255
+
256
+ async def _fetch[T](self, read: Callable[[_GitObjects], Awaitable[T]]) -> T:
257
+ if self._cooling_down is not None and await self._cooling_down():
258
+ raise GitHubTicketTreeError("GitHub rate limit reached")
259
+ if self._retry_until is not None and datetime.now(UTC) < self._retry_until:
260
+ raise GitHubTicketTreeError("GitHub rate limit reached")
261
+ try:
262
+ token = await self._credential.token()
263
+ async with (
264
+ repository_client(self._credential, transport=self._transport) as client,
265
+ asyncio.timeout(_FETCH_TIMEOUT),
266
+ ):
267
+ return await read(_GitObjects(self._api, client, token))
268
+ except GitHubRateLimited as exc:
269
+ if self._report_rate_limit is not None:
270
+ await self._report_rate_limit(exc)
271
+ else:
272
+ self._retry_until = exc.retry_at(datetime.now(UTC), 60)
273
+ raise GitHubTicketTreeError("GitHub rate limit reached") from None
274
+ except GitHubUnavailable, httpx.RequestError, TimeoutError:
275
+ raise GitHubTicketTreeError("GitHub ticket tree request failed") from None
276
+
277
+ async def _read_commit(self, git: _GitObjects) -> tuple[WorkItem, ...]:
278
+ commit, root_sha = await git.default_commit()
279
+ if self._cached is not None and self._cached[0] == commit:
280
+ return self._cached[1]
281
+ items = await self._read_tree_at(git, root_sha, self._read_tree)
282
+ self._cached = (commit, items)
283
+ return items
284
+
285
+ async def _read_tree_at[T](
286
+ self, git: _GitObjects, root_sha: str, read: Callable[[Path, Path], Awaitable[T]]
287
+ ) -> T:
288
+ scope = self._tree.parent if self._tree.name == "tickets" else self._tree
289
+ if scope.name.startswith("epic-") and scope.parent.name == "tickets":
290
+ scope = scope.parent.parent
291
+ selected = await git.locate(root_sha, self._tree)
292
+ if selected is None or selected.get("type") != "tree":
293
+ raise GitHubTicketTreeError("the configured GitHub ticket tree does not exist")
294
+ root = selected if scope == self._tree else await git.locate(root_sha, scope)
295
+ if root is None or root.get("type") != "tree":
296
+ raise GitHubTicketTreeError(
297
+ "the configured GitHub ticket tree has no enclosing Git tree"
298
+ )
299
+ directories, files = await git.files(_sha(root.get("sha")), scope)
300
+ config = await git.config(root_sha, self._tree)
301
+ project = self._tree
302
+ if config is not None:
303
+ path, blob = config
304
+ files[path] = blob
305
+ project = path.parents[2]
306
+ if (
307
+ len(directories) + len(files) > _MAX_ENTRIES
308
+ or sum(blob.size for blob in files.values()) > _MAX_TREE_BYTES
309
+ ):
310
+ raise GitHubTicketTreeError("the GitHub ticket tree exceeds the snapshot limit")
311
+ with tempfile.TemporaryDirectory(prefix="plotroom-tickets-") as directory:
312
+ checkout = await asyncio.to_thread(Path(directory).resolve)
313
+ tree = _destination(checkout, self._tree)
314
+ tree.mkdir(parents=True, exist_ok=True)
315
+ for child in directories:
316
+ _destination(checkout, child).mkdir(parents=True, exist_ok=True)
317
+ await self._materialize(git, checkout, files)
318
+ return await read(tree, _destination(checkout, project))
319
+
320
+ @staticmethod
321
+ async def _materialize(
322
+ git: _GitObjects, checkout: Path, files: dict[PurePosixPath, _Blob]
323
+ ) -> None:
324
+ entries = list(files.items())
325
+ for offset in range(0, len(entries), _BLOB_BATCH):
326
+ batch = entries[offset : offset + _BLOB_BATCH]
327
+ bodies = await asyncio.gather(
328
+ *(git.blob(blob) for _, blob in batch), return_exceptions=True
329
+ )
330
+ for (relative, _), content in zip(batch, bodies, strict=True):
331
+ if isinstance(content, BaseException):
332
+ raise content
333
+ path = _destination(checkout, relative)
334
+ path.parent.mkdir(parents=True, exist_ok=True)
335
+ with path.open("xb") as file:
336
+ file.write(content)
@@ -0,0 +1,5 @@
1
+ """MCP adapter: the tool surface over stateless HTTP and the stdio proxy."""
2
+
3
+ from plotroom.adapters.mcp.server import build_app
4
+
5
+ __all__ = ["build_app"]