capable-kit 0.0.1-alpha.3 → 0.0.1-alpha.4

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 (57) hide show
  1. package/README.md +21 -3
  2. package/dist/bin.mjs +14 -13
  3. package/dist/bin.mjs.map +1 -1
  4. package/dist/http.d.mts +1 -1
  5. package/dist/http.mjs +1 -1
  6. package/dist/{index-AqKbVZ8Z.d.mts → index-DCrxWCTv.d.mts} +2 -2
  7. package/dist/{index-B2ru1zGQ.d.mts → index-DJ--zcWG.d.mts} +4 -4
  8. package/dist/mcp.d.mts +1 -1
  9. package/dist/mcp.mjs +1 -1
  10. package/dist/{mount--YHrgRHJ.mjs → mount-BEBJ2Tss.mjs} +13 -19
  11. package/dist/mount-BEBJ2Tss.mjs.map +1 -0
  12. package/dist/runtime-support.d.mts +1 -1
  13. package/dist/runtime-support.mjs +5 -5
  14. package/dist/runtime-support.mjs.map +1 -1
  15. package/dist/server.d.mts +2 -2
  16. package/dist/server.mjs +2 -2
  17. package/dist/{src-DtSY5fzY.mjs → src-ChDFqZaE.mjs} +6 -6
  18. package/dist/{src-DtSY5fzY.mjs.map → src-ChDFqZaE.mjs.map} +1 -1
  19. package/dist/{src-DX2xrplP.mjs → src-D9pLpfeO.mjs} +2 -2
  20. package/dist/src-D9pLpfeO.mjs.map +1 -0
  21. package/docs/CONTEXT.md +108 -0
  22. package/docs/README.md +28 -0
  23. package/docs/internal/README.md +16 -0
  24. package/docs/internal/adr/0001-capability-is-the-semantic-boundary.md +24 -0
  25. package/docs/internal/architecture.md +126 -0
  26. package/docs/internal/capability-first-model.md +154 -0
  27. package/docs/internal/implementation-friction.md +674 -0
  28. package/docs/internal/why-capable.md +94 -0
  29. package/docs/site/capable-orpc-and-trpc.mdx +133 -0
  30. package/docs/site/concepts/apps.mdx +217 -0
  31. package/docs/site/concepts/architecture.mdx +75 -0
  32. package/docs/site/concepts/capabilities.mdx +249 -0
  33. package/docs/site/concepts/errors.mdx +93 -0
  34. package/docs/site/hosting/any-fetch-host.mdx +74 -0
  35. package/docs/site/hosting/next-js.mdx +77 -0
  36. package/docs/site/hosting/standalone-server.mdx +94 -0
  37. package/docs/site/introduction.mdx +142 -0
  38. package/docs/site/patterns/composition.mdx +142 -0
  39. package/docs/site/patterns/remote-apps.mdx +117 -0
  40. package/docs/site/patterns/subscriptions.mdx +87 -0
  41. package/docs/site/quickstart.mdx +293 -0
  42. package/docs/site/reference/packages-and-entry-points.mdx +70 -0
  43. package/docs/site/reference/surface-metadata.mdx +84 -0
  44. package/docs/site/reference/the-cap-cli.mdx +81 -0
  45. package/docs/site/surfaces/ai-sdk.mdx +94 -0
  46. package/docs/site/surfaces/cli.mdx +138 -0
  47. package/docs/site/surfaces/eve.mdx +121 -0
  48. package/docs/site/surfaces/http-and-openapi.mdx +111 -0
  49. package/docs/site/surfaces/mcp.mdx +97 -0
  50. package/docs/site/surfaces/react-query.mdx +80 -0
  51. package/docs/site/surfaces/typescript.mdx +123 -0
  52. package/docs/site/surfaces.mdx +78 -0
  53. package/docs/site/why-capable.mdx +99 -0
  54. package/package.json +13 -3
  55. package/src/package.test.ts +101 -0
  56. package/dist/mount--YHrgRHJ.mjs.map +0 -1
  57. package/dist/src-DX2xrplP.mjs.map +0 -1
@@ -0,0 +1,674 @@
1
+ # Implementation friction log
2
+
3
+ This is a live engineering log. Record awkward, unexpectedly heavy,
4
+ duplicated, or leaky implementation work as it appears.
5
+
6
+ ## 2026-07-29 — Declaration builds repeated TypeScript analysis per package
7
+
8
+ - **Observed:** The root `tsdown` configuration launches thirteen package
9
+ builds with declaration generation enabled. JavaScript bundling took about
10
+ 0.4 seconds, while TypeScript-backed declaration generation raised the total
11
+ to 3.5–4.4 seconds. Some surfaces, including Eve, intentionally produce both
12
+ a scoped package and a bundled `capable-kit` entry, so removing a build target
13
+ alone would leave one public package contract without its declared `dist`.
14
+ - **Why it matters:** Optimizing Rolldown concurrency or deleting optional
15
+ surfaces would address the symptom while either retaining repeated semantic
16
+ analysis or silently breaking a publishable package.
17
+ - **Current choice:** Generate declarations with Oxc's isolated declaration
18
+ transform and annotate the small set of exported values whose types formerly
19
+ required cross-file inference. The complete build now takes about 0.5–0.7
20
+ seconds and its declarations are equivalent to the TypeScript-generated
21
+ output. TypeScript 7 RC handles workspace typechecking separately.
22
+ - **Follow-up:** Decide whether scoped surface packages and their
23
+ `capable-kit/*` facades should both remain public. Treat that as a package API
24
+ decision rather than a build-performance shortcut.
25
+
26
+ ## 2026-07-29 — Bundling duplicated nominal App type identities
27
+
28
+ - **Observed:** The standalone `capable` facade bundles `@capable/app`, while
29
+ surface packages such as `@capable/react-query` reference their own external
30
+ copy. A private `unique symbol` used only to carry Capability type information
31
+ therefore had two incompatible identities in a consuming application.
32
+ - **Why it matters:** An App imported from `capable/app` was rejected by a
33
+ surface imported from `@capable/react-query`, despite both packages sharing
34
+ the same runtime protocol through `Symbol.for`.
35
+ - **Current choice:** Keep runtime access symbol-based, but make the
36
+ Capability-call phantom metadata structural. React Query accepts the typed
37
+ callable object it actually projects instead of depending on runtime
38
+ ownership it never reads.
39
+ - **Follow-up:** Add an installed-package consumer fixture so declaration
40
+ identity is checked across the bundled facade and separately published
41
+ surfaces before release.
42
+
43
+ ## 2026-07-29 — Manifest discovery cannot be globally eager
44
+
45
+ - **Observed:** Moving manifest discovery into `await createRemoteApp()` made
46
+ AI SDK and MCP projection synchronous, but it also turned every browser
47
+ module that declared a remote React Query App into a network boundary.
48
+ - **Why it matters:** React Query does not need the manifest while creating its
49
+ typed proxy. Eager discovery delayed module evaluation and moved connection
50
+ failures outside React Query's loading, retry, and error lifecycle.
51
+ - **Current choice:** `createRemoteApp()` is synchronous and lazy. It validates
52
+ and caches a successful manifest on first use, deduplicates concurrent
53
+ discovery, and clears failed attempts so query retries can rediscover. Only
54
+ manifest-dependent projections such as AI SDK and MCP require `await`.
55
+ - **Follow-up:** Add an explicit eager connection primitive only if a concrete
56
+ host needs startup validation often enough to justify a second App state.
57
+
58
+ ## 2026-07-29 — Product identity is duplicated across semantic and transport seams
59
+
60
+ - **Observed:** Rebranding the framework touched package names, public imports,
61
+ factory and configuration names, filesystem discovery, Nitro aliases, the
62
+ internal HTTP path, environment variables, headers, documentation routes,
63
+ and examples. The compiler found import-map drift, while text search found
64
+ protocol and route residue.
65
+ - **Why it matters:** A partial identity change makes the public API look
66
+ finished while a generated route or CLI convention still exposes the old
67
+ product. These seams are easy to miss because they span source, build tools,
68
+ and user-facing documentation.
69
+ - **Current choice:** Treat the identity as a flag-day contract: `capability`,
70
+ `handler`, `capabilities`, and `capable` replace their prior names across
71
+ authored APIs and derived surfaces. No compatibility aliases are retained.
72
+ - **Follow-up:** Centralize future generated protocol names and discovery
73
+ conventions behind a small internal identity module before another full
74
+ product rename is needed.
75
+
76
+ ## 2026-07-29 — Open metadata widened default AI SDK tool names
77
+
78
+ - **Observed:** Capabilities without an explicit `meta` object expose their open
79
+ metadata index as `any`. A direct type-level read of `meta.aiSdk.name`
80
+ therefore widened a path-derived literal such as `todos__list` to `string`.
81
+ - **Why it matters:** The runtime tool was correct, but AI SDK tool calls lost
82
+ their literal name and Capability-specific input/output inference.
83
+ - **Current choice:** The projection treats `any` metadata as "no AI SDK
84
+ override" and derives the name from the typed callable App path. Explicit
85
+ `meta.aiSdk` literals still rename or exclude the corresponding tool.
86
+ - **Follow-up:** Consider making default open metadata precise enough that
87
+ surface packages do not need to detect `any`, without closing the registry to
88
+ custom surface keys.
89
+
90
+ ## 2026-07-29 — Tool surfaces repeat manifest traversal and name checks
91
+
92
+ - **Observed:** MCP, Eve, and AI SDK now each flatten manifest nodes, derive a
93
+ default `path.join("__")` name, and reject duplicate names locally.
94
+ - **Why it matters:** The code is small, but portable name validation and error
95
+ wording can drift between agent surfaces.
96
+ - **Current choice:** Keep compilation in each surface because their tool
97
+ contracts, naming constraints, output rules, and execution lifetimes differ.
98
+ - **Follow-up:** If another tool surface appears or a shared bug recurs, add a
99
+ manifest-capability iterator in `@capable/app`; do not add a generic tool model to
100
+ core.
101
+
102
+ ## 2026-07-28 — Documentation samples have no way to fail
103
+
104
+ - **Observed:** Every code sample on the docs site is a template literal in a
105
+ `page.tsx`. Rebuilding the site validated the model against the packages by
106
+ hand: derived HTTP routes (`/api/todos/list`, not `/api/todos`), `cli: false`,
107
+ MCP's `path.join("__")` naming, and the `mcp()` mount having no `selection`
108
+ option were each only discovered by reading the source.
109
+ - **Why it matters:** The docs claim to be the contract for every surface. A
110
+ sample that no longer type-checks is indistinguishable from a working one
111
+ until a reader copies it.
112
+ - **Current choice:** The rendered-HTML test asserts that key identifiers appear
113
+ on the right pages, which catches deletions but not signature drift.
114
+ - **Follow-up:** Extract samples into compiled fixtures under the workspace
115
+ `tsconfig` (or MDX with a typechecked code plugin) so `bun run typecheck`
116
+ covers them.
117
+
118
+ ## 2026-07-28 — Zod's JSON Schema output retained a hidden live-schema marker
119
+
120
+ - **Observed:** Zod 4.4 attaches a non-enumerable `~standard` property to the
121
+ object returned by `z.toJSONSchema()`. It disappears over HTTP JSON, but an
122
+ in-process consumer can still observe it with the `in` operator.
123
+ - **Why it matters:** Eve classified Capable's nominal JSON Schema as a live
124
+ Standard Schema from a foreign Zod instance, then its AI SDK integration
125
+ failed while preparing the tool. Application manifests promise JSON data,
126
+ so runtime-only schema properties are contract leakage.
127
+ - **Current choice:** `schemaToJsonSchema()` performs a JSON round trip before
128
+ returning, guaranteeing that local and remote manifest consumers receive the
129
+ same plain data.
130
+ - **Follow-up:** Replace the round trip with an upstream-supported plain-output
131
+ option if Zod adds one.
132
+
133
+ ## 2026-07-28 — Native Eve projection must resolve at the step boundary
134
+
135
+ - **Observed:** Eve's durable compiler transforms inline executors authored
136
+ inside `defineDynamic()`, but an adapter package necessarily creates those
137
+ executor functions in library code. Session- or turn-scoped generated tools
138
+ would otherwise need to serialize the live Capable App and its context provider.
139
+ - **Why it matters:** A Capable App contains handlers and provider functions that
140
+ cannot cross a JSON workflow boundary. Hiding an MCP or HTTP hop inside the
141
+ adapter would avoid that constraint but would not be a native integration.
142
+ - **Current choice:** `createEveTools(app)` returns step-scoped dynamic tools.
143
+ Eve resolves the manifest and live executors before each model step, then
144
+ checkpoints the selected tool call and result using its normal durability
145
+ semantics.
146
+ - **Follow-up:** Consider an Eve public adapter hook for programmatically
147
+ supplied durable executors if another in-process framework integration needs
148
+ session-scoped discovery or wants to avoid per-step resolution.
149
+
150
+ ## 2026-07-28 — Default Web Stream buffering can deadlock cancellation
151
+
152
+ - **Observed:** A default `ReadableStream` may pull the next subscription value
153
+ immediately after delivering the current SSE frame. Calling
154
+ `reader.cancel()` then queues async-generator cleanup behind that pending
155
+ `next()`, while the subscriber may be waiting for its abort signal.
156
+ - **Why it matters:** Remote `return()`, React Query unmounts, and CLI
157
+ interruption can hang even though every layer appears to forward iterator
158
+ cleanup.
159
+ - **Current choice:** The SSE response uses a zero high-water mark so one
160
+ downstream read creates exactly one Capability demand. It also owns an
161
+ AbortController and aborts before awaiting iterator cleanup.
162
+ - **Follow-up:** Keep an end-to-end cancellation regression test whenever the
163
+ Capable transport framing changes.
164
+
165
+ ## 2026-07-28 — A concrete HTTP adapter obscured App semantics
166
+
167
+ - **Observed:** `@capable/app` accumulated callable proxy behavior, local
168
+ execution, composition, manifest algorithms, and the concrete HTTP/SSE
169
+ transport in one 1,113-line module.
170
+ - **Why it matters:** Changes to Application manifests required navigating HTTP
171
+ frame parsing, while `@capable/app` appeared to own Fetch despite exposing a
172
+ transport-neutral `ApplicationTransport` seam.
173
+ - **Current choice:** Keep App runtime, composition, and manifest logic in
174
+ separate deep modules. Place both `createHttpTransport()` and
175
+ `createProtocolHandler()` in `@capable/fetch`, alongside their shared wire-error
176
+ normalization. Package index files remain public facades.
177
+ - **Follow-up:** Split at named domain concepts with real invariants. Avoid
178
+ generic `types.ts`, `utils.ts`, or one-export files that only replace
179
+ scrolling with cross-file navigation.
180
+
181
+ ## 2026-07-28 — Callable subscription methods collide with App navigation
182
+
183
+ - **Observed:** Adding `app.prices.get.subscribe()` to the lazy callable proxy
184
+ makes `subscribe` both a framework method and a valid Capability tree segment.
185
+ A remote App cannot resolve which meaning applies synchronously because its
186
+ manifest is asynchronous.
187
+ - **Why it matters:** Reserving another common domain word would leak proxy
188
+ implementation constraints into authored Application paths.
189
+ - **Current choice:** App call proxies expose private symbol metadata containing
190
+ their runtime and path. The typed top-level
191
+ `subscribe(app.prices.get, input)` helper accepts only calls whose Capability
192
+ declares the capability and dispatches through that metadata.
193
+ - **Follow-up:** Keep subscription invocation collision-free unless App leaves
194
+ stop being lazy callable proxies.
195
+
196
+ ## 2026-07-28 — Stream errors cross two response phases
197
+
198
+ - **Observed:** Validation, context, or authorization can fail before a
199
+ subscription yields, while later declared errors happen after SSE response
200
+ headers have already been sent.
201
+ - **Why it matters:** A Fetch adapter cannot change HTTP status after streaming
202
+ begins, but remote callers must receive the same typed error contract in both
203
+ phases.
204
+ - **Current choice:** The protocol handler pulls the first replacement before
205
+ constructing the SSE response, preserving ordinary HTTP errors during setup.
206
+ The client decodes that HTTP error envelope into the declared
207
+ `TransportError`; later failures are terminal `error` SSE frames decoded into
208
+ the same error type. Each Web Stream pull requests only one Capability
209
+ replacement.
210
+ - **Follow-up:** Add resume or retry framing only alongside an explicit
211
+ semantic contract; do not infer delivery guarantees from SSE.
212
+
213
+ ## 2026-07-27 — A parallel HTTP-shaped model was not a viable migration
214
+
215
+ - **Observed:** Every old surface depended statically on method/path identity,
216
+ located HTTP inputs, and route arrays.
217
+ - **Why it matters:** Making each field conditionally optional would preserve
218
+ HTTP as the center and spread compatibility branches throughout the repo.
219
+ - **Current choice:** Replace the model as a flag-day change. The new core has
220
+ one Capability type and downstream surfaces compile from it.
221
+ - **Follow-up:** Do not reintroduce route compatibility aliases.
222
+
223
+ ## 2026-07-27 — Group metadata needs location as well as ancestry
224
+
225
+ - **Observed:** An ordered list of parent Groups was enough for middleware but
226
+ not enough to replace the correct object-path segment with an HTTP prefix.
227
+ - **Why it matters:** A prefix on `admin` must not duplicate `admin` or erase
228
+ undecorated descendants such as `users`.
229
+ - **Current choice:** Located Capabilities retain parallel Group paths. Core
230
+ still performs no surface-specific merge; HTTP interprets those paths.
231
+ - **Follow-up:** Promote ancestry to a named located-group record if a second
232
+ surface needs both the Group and its path.
233
+
234
+ ## 2026-07-27 — Remote tree clients require runtime discovery
235
+
236
+ - **Observed:** A typed client can know its tree statically, but the transport
237
+ calls Capabilities by ID and only the manifest maps paths to IDs.
238
+ - **Why it matters:** Shipping handler-bearing Application definitions to
239
+ clients would violate the server boundary.
240
+ - **Current choice:** A lazy proxy records the navigational path and resolves
241
+ it against one cached manifest before calling by ID.
242
+ - **Follow-up:** Add generated static contracts only if manifest lookup or
243
+ proxy ergonomics become measurable problems.
244
+
245
+ ## 2026-07-27 — Context on Application prevented independent composition
246
+
247
+ - **Observed:** Keeping an `capabilities<TContext>()` witness on `defineApp()`
248
+ made a merged local-plus-remote tree appear to require one combined context,
249
+ even though remote execution and each local source resolve independently.
250
+ - **Why it matters:** CLI login/filesystem Capabilities should not force their
251
+ credentials and process state into the server application's context.
252
+ - **Current choice:** Application derives only a phantom context requirement
253
+ from its tree. `createApp()` satisfies and erases that requirement before
254
+ `mergeApps()`; the App resolved by `createRemoteApp()` is already
255
+ context-erased.
256
+ - **Follow-up:** Do not add context or provider options to merge or surface
257
+ constructors.
258
+
259
+ ## 2026-07-27 — Context typing needs a curried Capability definer
260
+
261
+ - **Observed:** TypeScript cannot pin a Capability's context generic while
262
+ continuing to infer that Capability's input, output, errors, and metadata.
263
+ The original `capabilities<TContext>().capability()` workaround sounded like a
264
+ collection even though it only produced a typed definer.
265
+ - **Why it matters:** Capabilities remain independently composable; their
266
+ authoring API should not imply grouping or make context a runtime framework
267
+ object.
268
+ - **Current choice:** Contextless Capabilities use `capability(config)`.
269
+ Contextual definers use `capability.withContext<Context>()`, with
270
+ `capability<Context>()` as a compact equivalent.
271
+ - **Follow-up:** Keep both contextual forms behaviorally and inferentially
272
+ identical.
273
+
274
+ ## 2026-07-27 — Strict async merge moves validation to manifest resolution
275
+
276
+ - **Observed:** Remote paths and IDs do not exist until an asynchronous
277
+ manifest resolves, so `mergeApps()` cannot validate synchronously.
278
+ - **Why it matters:** Silent shadowing or source-order dispatch would make local
279
+ and remote behavior dependent on composition order.
280
+ - **Current choice:** Memoize one merged manifest promise, collect strict ID,
281
+ path, double-mount, and leaf/subtree conflicts, and build the ID dispatch map
282
+ only after successful validation.
283
+ - **Follow-up:** Surfaces should resolve the manifest during startup. Add
284
+ explicit manifest cache policy only after remote startup costs are measured.
285
+
286
+ ## 2026-07-27 — Callable errors need a separate manifest contract
287
+
288
+ - **Observed:** The most direct authoring interface makes each member of an
289
+ Error set callable, but functions cannot be serialized into a remote
290
+ manifest.
291
+ - **Why it matters:** Treating the callable object itself as the contract would
292
+ either leak functions into manifests or make every consumer rediscover its
293
+ definitions.
294
+ - **Current choice:** `defineErrors()` brands the callable set and retains one
295
+ immutable definition map behind a symbol. Capability placement extracts and
296
+ merges only that map; handlers and middleware use the callable members.
297
+ - **Follow-up:** Do not make surfaces inspect Error factories directly.
298
+
299
+ ## 2026-07-27 — A separate Caller duplicated the executable App
300
+
301
+ - **Observed:** `createCaller(app)` projected the same typed object tree that
302
+ every local, remote, and merged executable already needed.
303
+ - **Why it matters:** The extra module added terminology and forced users to
304
+ distinguish an executable App from the object they actually called without
305
+ hiding any additional complexity.
306
+ - **Current choice:** `createApp()`, `createRemoteApp()`, and `mergeApps()`
307
+ return the directly callable App tree. The manifest/ID-call runtime lives
308
+ behind a symbol consumed by surfaces, avoiding collisions with authored
309
+ Capability keys.
310
+ - **Follow-up:** Reintroduce a separate projection only if a concrete consumer
311
+ needs behavior different from ordinary App calls.
312
+
313
+ ## 2026-07-27 — Callable App proxies must not become promises
314
+
315
+ - **Observed:** A proxy supplies the callable App tree, but any proxied `then`
316
+ property makes the App or a nested Group promise-like.
317
+ - **Why it matters:** `await app` or promise resolution could accidentally
318
+ invoke an authored `then` Capability with resolver functions as input.
319
+ - **Current choice:** App Definitions reject `then` at every tree level. The
320
+ root App proxy is object-shaped; only Capability-path proxies are callable.
321
+ - **Follow-up:** Keep this restriction unless Apps stop using callable proxies.
322
+
323
+ ## 2026-07-27 — An authored Fetch server is intentionally opaque to dev tooling
324
+
325
+ - **Observed:** `capable.server.ts` exports only a Fetch-compatible server, so the
326
+ toolchain cannot reliably enumerate custom, MCP, or disabled mounts without
327
+ changing the server abstraction.
328
+ - **Why it matters:** Hard-coded startup output can claim endpoints that an
329
+ authored server does not expose, while probing mutation-capable endpoints is
330
+ unsafe.
331
+ - **Current choice:** `cap dev` inspects only the Capable manifest and
332
+ OpenAPI document through safe GET requests. If neither exists, it identifies
333
+ the authored server without inventing surface metadata. The development host
334
+ reserves only `GET /` for the definition-backed Capability overview and
335
+ delegates every other request to the authored server.
336
+ - **Follow-up:** Add explicit server introspection only if another host or
337
+ development tool needs the same mount inventory.
338
+
339
+ ## 2026-07-28 — React Query options must be synchronous over an async App
340
+
341
+ - **Observed:** A remote App discovers Capability IDs asynchronously from its
342
+ manifest, while React Query requires `queryKey` and `queryOptions()` during
343
+ synchronous React rendering.
344
+ - **Why it matters:** Waiting for the manifest would make the query projection
345
+ unusable in ordinary hooks, while asking callers to author keys would
346
+ duplicate the App tree and allow cache drift.
347
+ - **Current choice:** `createReactQuery(app)` derives synchronous keys from the
348
+ typed App path and invokes the corresponding callable Capability. A custom
349
+ `keyPrefix` distinguishes multiple Apps sharing one QueryClient.
350
+ - **Follow-up:** The projection's `queryKey`, `queryOptions`, and
351
+ `mutationOptions` member names are reserved within that projection. Revisit
352
+ this only if a real App uses one of those names or callable Apps gain
353
+ synchronous leaf metadata.
354
+
355
+ ## 2026-07-28 — A fresh Next.js build can race SQLite initialization
356
+
357
+ - **Observed:** Next.js page-data collection imports the authenticated Todo
358
+ server in parallel workers. On a fresh database, those workers can contend
359
+ while the module applies its SQLite pragma and schema DDL.
360
+ - **Why it matters:** `next build` can fail once with `SQLITE_BUSY` even though
361
+ the application and its types compiled successfully.
362
+ - **Current choice:** Run the example's existing `auth:migrate` command before
363
+ its production build, matching the initialization already used by `dev`.
364
+ - **Follow-up:** Decide whether the example's `build` script should own that
365
+ migration or whether schema setup should move out of module evaluation.
366
+
367
+ ## 2026-07-28 — The MCP SDK conflicts with exact optional properties
368
+
369
+ - **Observed:** `@modelcontextprotocol/sdk@1.29.0` has incompatible `sessionId` optionality
370
+ between `StreamableHTTPClientTransport` and its base `Transport` when
371
+ `exactOptionalPropertyTypes` is enabled.
372
+ - **Why it matters:** The official client and server interoperate at runtime,
373
+ but TypeScript rejects passing the client transport to the SDK's own client.
374
+ - **Current choice:** Resolved on 2026-07-30 by migrating to the v2 split
375
+ `@modelcontextprotocol/client` and `@modelcontextprotocol/server` packages;
376
+ the official modern client now typechecks without a cast.
377
+ - **Follow-up:** None.
378
+
379
+ ## 2026-07-28 — Full MCP compliance has a sizable isolated dependency
380
+
381
+ - **Observed:** The official MCP TypeScript SDK brings server, client, Express,
382
+ Hono, OAuth, and validation dependencies even though Capable's mount uses only
383
+ the Web Standard server transport and low-level protocol server.
384
+ - **Why it matters:** Reimplementing initialization, negotiation, Streamable
385
+ HTTP, cancellation, and evolving protocol details would be shallow and
386
+ fragile, but consumers that never expose MCP should not pay for the SDK.
387
+ - **Current choice:** The v2 SDK resolved this on 2026-07-30. Keep only
388
+ `@modelcontextprotocol/server` in `@capable/mcp`; client code is confined to
389
+ tests and the authenticated example. The core, App, Fetch, server, CLI, and
390
+ HTTP packages remain independent of MCP.
391
+ - **Follow-up:** Measure the published install footprint if MCP adoption becomes
392
+ sensitive to package size.
393
+
394
+ ## 2026-07-30 — The modern MCP handler has a lifecycle that mounts cannot expose
395
+
396
+ - **Observed:** `createMcpHandler()` owns a subscription bus and exposes
397
+ `close()`, while `CompiledServerMount` only exposes `fetch()`.
398
+ - **Why it matters:** Today Capable advertises fixed unary tools, so each request
399
+ drains inside `fetch()`. If the MCP projection later advertises list-change
400
+ subscriptions, the host will need a way to close their streams during
401
+ shutdown.
402
+ - **Current choice:** Keep one handler per compiled mount so discovery and tool
403
+ calls stay stateless without rebuilding handler-level routing on every
404
+ request.
405
+ - **Follow-up:** Add an optional mount/server shutdown lifecycle before MCP
406
+ exposes subscriptions or other long-lived server state.
407
+
408
+ ## 2026-07-30 — Modern MCP clients do not negotiate the modern era by default
409
+
410
+ - **Observed:** The MCP 2026-07-28 lifecycle is available in the v2 SDK and
411
+ selected current harnesses, but several released clients still send the
412
+ legacy `initialize` handshake, and modern-capable clients commonly require an
413
+ explicit opt-in.
414
+ - **Why it matters:** Rejecting legacy requests would make the otherwise
415
+ stateless mount unusable from current Codex defaults, Claude Code, Cursor, and
416
+ VS Code.
417
+ - **Current choice:** Serve modern requests sessionlessly and route legacy
418
+ requests through the SDK's stateless adapter. Both paths rebuild application
419
+ context from each HTTP request and require no session storage.
420
+ - **Follow-up:** Reconsider rejecting legacy requests after the major harnesses
421
+ negotiate MCP 2026-07-28 by default.
422
+
423
+ ## 2026-07-28 — Bun crashes when Better Auth migrations load SQLite
424
+
425
+ - **Observed:** Bun 1.3.13 aborts in N-API when the Better Auth migration script
426
+ or integration test loads `better-sqlite3` directly.
427
+ - **Why it matters:** A first-run Todo demo must create Better Auth's session
428
+ and device-authorization tables before login works.
429
+ - **Current choice:** Keep Bun as package manager and command entry point, but
430
+ run the migration and auth integration test through Node with `tsx`.
431
+ - **Follow-up:** Retry the scripts under Bun after its native-addon crash is
432
+ fixed; no framework API depends on this runner choice.
433
+
434
+ ## 2026-07-28 — Documentation should not inherit its deployment runtime
435
+
436
+ - **Observed:** A hosting-oriented site scaffold brought Vinext, Cloudflare,
437
+ D1, Drizzle, and workspace-auth files into a documentation app that only
438
+ needed the Next.js App Router.
439
+ - **Why it matters:** Unused hosting concerns obscure the docs implementation,
440
+ add dependencies, and prematurely couple the site to one deployment target.
441
+ - **Current choice:** Keep `website/` as a regular Next.js application with no
442
+ hosting-specific runtime, database, or authentication code.
443
+ - **Follow-up:** Add deployment integration only when the documentation has an
444
+ explicit host and access model.
445
+
446
+ ## 2026-07-28 — The toolchain package leaked internal topology into installation
447
+
448
+ - **Observed:** The standalone quickstart required both `capable` and
449
+ `@capable/toolchain`, even though users understand the runtime and its command as
450
+ one product.
451
+ - **Why it matters:** A second install step makes the default path feel
452
+ assembled from optional pieces and forces users to learn a package boundary
453
+ that has no value at the call site.
454
+ - **Current choice:** The public `capable` package owns the `cap` binary and
455
+ depends on `@capable/toolchain` as an internal implementation package.
456
+ - **Follow-up:** Before publishing, verify the release pipeline either publishes
457
+ the internal workspace dependency or bundles the command implementation into
458
+ the `capable` artifact.
459
+
460
+ ## 2026-07-28 — Linked source packages are not a consumable internal canary
461
+
462
+ - **Observed:** Linking `packages/capable` into the pnpm-based `front` and
463
+ `internal-agents` monorepos exposes a private `0.0.0` package whose
464
+ transitive dependencies still use `workspace:*` and whose exports point at
465
+ raw TypeScript. The linked real path also resolves Capable's own Zod
466
+ installation instead of the consumer's compatible Zod 4 installation.
467
+ - **Why it matters:** A small external Capability produced recursive cross-Zod
468
+ type expansion: one package reported "Type instantiation is excessively
469
+ deep" and V's typecheck exhausted a 4 GB heap. A clean Front worktree also
470
+ could not validate the link without installing the entire unrelated
471
+ workspace, which requires private registry access. This makes package
472
+ plumbing dominate the capability experiment.
473
+ - **Current choice:** Keep the dogfood branches as explicit local-link proofs
474
+ and validate their runtime boundary with injectable focused tests. Do not
475
+ normalize casts, larger TypeScript heaps, or borrowed `node_modules` as the
476
+ consumer experience.
477
+ - **Follow-up:** Produce a packed or internally published canary containing
478
+ built JavaScript and declarations, resolvable versions for every internal
479
+ package, and one consumer fixture outside the Bun workspace. Verify that a
480
+ consumer-owned Zod 4 schema crosses the public Capability types without
481
+ duplicate-instance recursion.
482
+
483
+ ## 2026-07-28 — A static Eve App cannot carry the current user
484
+
485
+ - **Observed:** Eve authenticates a browser request before it creates the
486
+ durable session, while a static App passed to `createEveTools(app)` has
487
+ already fixed its context provider.
488
+ - **Why it matters:** An embedded agent must run the same Capabilities for the
489
+ signed-in user without copying Capability definitions or leaking Eve session
490
+ semantics into application code.
491
+ - **Current choice:** `createEveTools()` also accepts a step-scoped App factory.
492
+ The factory receives Eve's dynamic resolve context. The authenticated Todo
493
+ example returns a remote App with a short-lived signed user identity, keeping
494
+ SQLite and Capability execution in the Next.js service instead of copying a
495
+ native database binding into Eve's separate runtime.
496
+ - **Follow-up:** If other agent frameworks need the same pattern, move the
497
+ provider vocabulary inward to a surface-neutral projection context.
498
+
499
+ ## 2026-07-28 — Default Better Auth cookies collide across localhost apps
500
+
501
+ - **Observed:** After login, Better Auth tried to decode a stale
502
+ `better-auth.session_data` cookie from another localhost app using the
503
+ compact-cache decoder and failed on the JWT separator (`.`).
504
+ - **Why it matters:** A valid session created by this example could make every
505
+ server-rendered page fail before the user could sign out or clear the stale
506
+ cookie.
507
+ - **Current choice:** Give the Todo example the app-specific `capable-todo` cookie
508
+ prefix and cover coexistence with stale default Better Auth cookies in the
509
+ auth integration test.
510
+ - **Follow-up:** Use an explicit cookie prefix in every runnable Better Auth
511
+ example that can share a development hostname.
512
+
513
+ ## 2026-07-29 — A shipped Nitro server entry is never transformed
514
+
515
+ - **Observed:** `cap dev` worked from the repository but failed for an
516
+ installed package with `Package import specifier "#capable/app" is not
517
+ defined`. The four runtime entries (`runtime.ts`, `dev-runtime.ts`,
518
+ `server-runtime.ts`, `dev-server-runtime.ts`) lived inside the Capable
519
+ package, so Nitro pointed at a file it treats as an external dependency and
520
+ loaded it with Node instead of applying the `#capable/*` aliases. The same
521
+ paths also broke the source build, which pointed at `.ts` files that a
522
+ published `dist` never contains.
523
+ - **Why it matters:** Every host command depends on that entry, so the failure
524
+ only reproduces once the package is installed rather than run from source.
525
+ - **Current choice:** Provide an in-memory `#capable/entry` through Nitro's
526
+ virtual-module configuration and keep the shared behaviour in one
527
+ `runtime-support` module. Nitro transforms the virtual entry and resolves its
528
+ `#capable/*` aliases without writing generated files into the user's project;
529
+ the support module resolves to source TypeScript in the repository or bundled
530
+ JavaScript in an installed package.
531
+ - **Follow-up:** Framework-owned Nitro entries should use Nitro's virtual-module
532
+ boundary rather than package-local or generated project files.
533
+
534
+ ## 2026-07-29 — The bundled initializer cannot reliably read its public version
535
+
536
+ - **Observed:** `cap init` runs from `@capable/toolchain` in the source
537
+ workspace, but that implementation is bundled into `capable-kit` for users.
538
+ A package manifest resolved relative to the module therefore describes
539
+ different packages in development and production.
540
+ - **Why it matters:** A generated `package.json` should declare a compatible
541
+ `capable-kit` version without hard-coding a release number that will drift.
542
+ - **Current choice:** Generate `"capable-kit": "alpha"` and keep the starter
543
+ API small enough to follow the current release.
544
+ - **Follow-up:** Inject the public package name and version at build time so the
545
+ initializer can pin the exact release that generated the project.
546
+
547
+ ## 2026-07-29 — An explicit Nitro fallback disabled provider detection
548
+
549
+ - **Observed:** `cap build` always passed the `node-server` preset to Nitro.
550
+ Vercel therefore received a generic `.output/` server instead of its
551
+ `.vercel/output` Build Output API and treated the project as a static site
552
+ with a missing `public/` directory.
553
+ - **Why it matters:** A framework-level build should produce the host's native
554
+ deployment shape when Nitro recognizes the build environment.
555
+ - **Current choice:** Configure `node-server` as Nitro's `defaultPreset` rather
556
+ than its explicit `preset`. Local builds keep the standalone Node output,
557
+ while Vercel and other known providers can select their own presets.
558
+ - **Follow-up:** Add deployment smoke tests for other auto-detected Nitro
559
+ providers as Capable documents support for them.
560
+
561
+ ## 2026-08-05 — Input schemas are projected in output mode, so `.default()` reads as required
562
+
563
+ - **Observed:** Building a scratch `--watch` demo, every field declared with
564
+ `z.number().default(80)` came out of `cap cli` as
565
+ `Missing required option --width`. `schemaToJsonSchema` calls
566
+ `z.toJSONSchema(schema, { unrepresentable: "any" })` without `io: "input"`, so
567
+ a defaulted key is emitted as required with a `default` annotation, which is
568
+ correct for outputs and wrong for inputs.
569
+ - **Why it matters:** `.default()` is the obvious way to express an optional
570
+ argument, and every derived surface (CLI usage, OpenAPI request bodies, MCP
571
+ tool schemas) inherits the wrong requiredness from the manifest.
572
+ - **Current choice:** Callers use `.optional()` plus explicit fallbacks in the
573
+ handler so the CLI stays usable.
574
+ - **Follow-up:** Project Capability input schemas with `io: "input"` (and keep
575
+ outputs in output mode) so `.default()` means optional on every surface.
576
+
577
+ ## 2026-07-29 — Capability schemas need both Standard Schema contracts
578
+
579
+ - **Observed:** Standard Schema validation and Standard JSON Schema projection
580
+ are separate interfaces. Capability execution only needs `validate`, while
581
+ manifests, OpenAPI, HTTP coercion, MCP, and AI SDK tools also need
582
+ `jsonSchema.input()` and `jsonSchema.output()`. Structural schema inference
583
+ also made TypeScript's `const` type parameters deep-readonly the schema's
584
+ phantom input/output types.
585
+ - **Why it matters:** Accepting validation-only Standard Schemas would make some
586
+ Capabilities impossible to project onto the framework's promised surfaces.
587
+ - **Current choice:** A Capable `Schema` requires both `StandardSchemaV1` and
588
+ `StandardJSONSchemaV1`. JSON Schema projection explicitly selects the input
589
+ or output direction, preserving transforms without a schema-library adapter.
590
+ Schema type parameters use normal inference; literal metadata remains `const`.
591
+ - **Follow-up:** If validation-only Capabilities become useful, make projection
592
+ support an explicit surface-level requirement rather than adding
593
+ library-specific conversion in `@capable/core`.
594
+
595
+ ## 2026-07-29 — Public metadata needs cache and protection boundaries
596
+
597
+ - **Observed:** Vercel routed the manifest and OpenAPI document through the
598
+ server function without response cache headers. A protected deployment then
599
+ redirected remote CLI discovery to Vercel's HTML login page, which surfaced
600
+ as a JSON parse error.
601
+ - **Why it matters:** Deployment-invariant metadata should not invoke compute on
602
+ every request, but caching authored-server responses could bypass application
603
+ middleware. Protected deployments also need non-browser authentication.
604
+ - **Current choice:** Add Vercel CDN-only caching to manifest and OpenAPI
605
+ responses from Capable's built-in production server. Leave development and
606
+ authored servers untouched. For linked Vercel projects, remote CLI calls
607
+ resolve the automation-bypass secret from project settings using the local
608
+ Vercel CLI login. Explicit flags and `VERCEL_AUTOMATION_BYPASS_SECRET` take
609
+ precedence, and Vercel's login redirect is diagnosed explicitly.
610
+ - **Follow-up:** Generalize remote CLI credentials when Capable defines its own
611
+ authentication configuration rather than adding more provider-specific
612
+ environment variables.
613
+
614
+ ## 2026-07-30 — npm cannot package documentation outside the package directory
615
+
616
+ - **Observed:** The public package lives in `packages/capable`, while its
617
+ canonical public and internal documentation lives in top-level `website/`,
618
+ `docs/`, and `CONTEXT.md`. npm's package file allowlist cannot include parent
619
+ directories.
620
+ - **Why it matters:** Keeping a checked-in copy under the package would make the
621
+ npm artifact drift from the documentation site and framework decisions.
622
+ - **Current choice:** The package's `prepack` lifecycle assembles `docs/site` and
623
+ `docs/internal` from the canonical sources. `postpack` removes that staging
624
+ directory. The package README, generated docs index, and `directories.doc`
625
+ point agents at the installed-version docs, while a test inspects a real
626
+ tarball to guard both discovery metadata and published contents.
627
+ - **Follow-up:** The public site now uses canonical MDX pages, and the package
628
+ stages those files directly. Keep package tests asserting that every public
629
+ guide remains readable without the Next.js runtime.
630
+
631
+ ## 2026-07-30 — MDX drops fenced-code metadata unless it is forwarded
632
+
633
+ - **Observed:** Moving the guides from TSX to MDX turned code filenames into
634
+ separate paragraphs and lost the `emphasizeLines` arrays used by the
635
+ Capabilities guide. Styling the paragraph as a header also left both the
636
+ paragraph spacing and the renderer's title spacing in place.
637
+ - **Why it matters:** Code samples looked materially different even though the
638
+ surrounding documentation design was meant to remain unchanged.
639
+ - **Current choice:** Fences use readable `title="..."` and
640
+ `highlight="2,4-7"` metadata. A small local remark plugin forwards those
641
+ fields to the existing Shiki renderer, which remains the single owner of the
642
+ title row, copy button, and line emphasis.
643
+ - **Follow-up:** Keep rendered-HTML assertions for the title and emphasized-line
644
+ classes so future content-pipeline changes cannot silently flatten them.
645
+
646
+ ## 2026-07-30 — Navigation metadata made packaged MDX incomplete
647
+
648
+ - **Observed:** Titles and descriptions initially remained in the website's
649
+ navigation registry after the TSX-to-MDX migration. A bundled `page.mdx`
650
+ therefore had content but not its own name or summary.
651
+ - **Why it matters:** The website could join those sources at runtime, but an
652
+ agent reading one installed-package guide should not need a separate
653
+ application registry to understand the document.
654
+ - **Current choice:** Every page owns YAML `title` and `description`
655
+ frontmatter. The MDX pipeline exports it for Next.js metadata and the shared
656
+ page shell. `site.ts` now owns only navigation grouping, order, routes, and
657
+ short labels. Package staging also uses the title to replace Next.js's generic
658
+ `page.mdx` name with a descriptive installed-document filename.
659
+ - **Follow-up:** The site and tarball tests assert this boundary so page-owned
660
+ metadata cannot drift back into navigation configuration.
661
+
662
+ ## 2026-07-30 — Automatic heading slugs broke existing documentation links
663
+
664
+ - **Observed:** Replacing explicit React `Section` ids with ordinary Markdown
665
+ headings changed anchors to text-derived slugs. Cross-page links still
666
+ targeted the old stable ids, and the right-hand page outline disappeared
667
+ because it had been assembled by `Section`.
668
+ - **Why it matters:** A content-format migration must preserve public URLs and
669
+ navigation, even when the rendered heading text looks unchanged.
670
+ - **Current choice:** Existing headings carry a readable `[#stable-id]` suffix.
671
+ A local remark plugin turns it into the rendered heading id, and the shared
672
+ page shell derives the outline from those headings.
673
+ - **Follow-up:** Rendered-site tests now verify the outline and resolve every
674
+ internal hash link against the target page.