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

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