capable-kit 0.0.1-alpha.5 → 0.0.1-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/internal/architecture.md +7 -1
- package/docs/internal/implementation-friction.md +37 -7
- package/docs/site/capable-orpc-and-trpc.mdx +1 -1
- package/docs/site/hosting/next-js.mdx +1 -1
- package/docs/site/introduction.mdx +2 -2
- package/docs/site/quickstart.mdx +4 -4
- package/docs/site/reference/packages-and-entry-points.mdx +13 -12
- package/docs/site/surfaces/react-query.mdx +6 -2
- package/docs/site/surfaces/swr.mdx +97 -0
- package/docs/site/surfaces.mdx +6 -2
- package/package.json +22 -2
- package/src/index.test.ts +6 -0
- package/src/next.ts +1 -0
- package/src/package.test.ts +57 -2
- package/src/react-query.ts +1 -0
- package/src/swr.ts +1 -0
|
@@ -27,13 +27,18 @@ App Definition ──────────────► createServer(defini
|
|
|
27
27
|
direct calls createCli await createMcp await createAiSdkTools
|
|
28
28
|
createEveTools
|
|
29
29
|
createReactQuery
|
|
30
|
+
createSWR
|
|
30
31
|
```
|
|
31
32
|
|
|
32
33
|
## Package responsibilities
|
|
33
34
|
|
|
35
|
+
The scoped `@capable/*` packages below are private workspace boundaries. The
|
|
36
|
+
public `capable-kit` package bundles user-facing APIs behind subpath exports such
|
|
37
|
+
as `capable-kit/server`, `capable-kit/next`, and `capable-kit/swr`.
|
|
38
|
+
|
|
34
39
|
| Package | Owns |
|
|
35
40
|
| ------------------- | -------------------------------------------------------------------- |
|
|
36
|
-
| `capable`
|
|
41
|
+
| `capable-kit` | Public facade and the user-installed `cap` command |
|
|
37
42
|
| `@capable/core` | Authoring, tree composition, validation, middleware, errors, execution |
|
|
38
43
|
| `@capable/app` | Callable local and remote Apps, merge, selection, manifests |
|
|
39
44
|
| `@capable/fetch` | Capable transport encoding and the HTTP/OpenAPI projection |
|
|
@@ -43,6 +48,7 @@ App Definition ──────────────► createServer(defini
|
|
|
43
48
|
| `@capable/ai-sdk` | Typed AI SDK v7 tool projection |
|
|
44
49
|
| `@capable/eve` | Native in-process Eve tool projection |
|
|
45
50
|
| `@capable/react-query` | Query keys, query options, mutations, live queries |
|
|
51
|
+
| `@capable/swr` | SWR keys, fetchers, mutations, and subscriptions |
|
|
46
52
|
| `@capable/next` | Method-export translation for the App Router |
|
|
47
53
|
| `@capable/nitro-host` | Development server, build, and preview for standalone projects |
|
|
48
54
|
| `@capable/toolchain` | Internal command implementation and project discovery |
|
|
@@ -3,6 +3,19 @@
|
|
|
3
3
|
This is a live engineering log. Record awkward, unexpectedly heavy,
|
|
4
4
|
duplicated, or leaky implementation work as it appears.
|
|
5
5
|
|
|
6
|
+
## 2026-08-05 — Markdown negotiation must run before static page matching
|
|
7
|
+
|
|
8
|
+
- **Observed:** The `dom-md` Next.js example returns a flat rewrite list, which
|
|
9
|
+
Next.js 16.2.6 places in `afterFiles`. Those rewrites never see this site's
|
|
10
|
+
statically prerendered MDX routes because filesystem routes win first.
|
|
11
|
+
- **Why it matters:** The Markdown Route Handler worked directly, but
|
|
12
|
+
`Accept: text/markdown` silently returned cached HTML at the public docs URL.
|
|
13
|
+
- **Current choice:** Register the same header-matched rewrite in
|
|
14
|
+
`beforeFiles`, ahead of static route matching. The route's internal request
|
|
15
|
+
explicitly accepts HTML, so it does not negotiate back into itself.
|
|
16
|
+
- **Follow-up:** Recheck whether a flat rewrite becomes safe if Next.js or the
|
|
17
|
+
`dom-md` guide changes its ordering guidance.
|
|
18
|
+
|
|
6
19
|
## 2026-07-31 — Rich presentation must be requested explicitly
|
|
7
20
|
|
|
8
21
|
- **Observed:** The App runtime previously derived Markdown after every call,
|
|
@@ -50,13 +63,13 @@ duplicated, or leaky implementation work as it appears.
|
|
|
50
63
|
required cross-file inference. The complete build now takes about 0.5–0.7
|
|
51
64
|
seconds and its declarations are equivalent to the TypeScript-generated
|
|
52
65
|
output. TypeScript 7 RC handles workspace typechecking separately.
|
|
53
|
-
- **
|
|
54
|
-
`capable-kit
|
|
55
|
-
|
|
66
|
+
- **Resolution (2026-08-05):** Scoped `@capable/*` packages are private
|
|
67
|
+
workspace boundaries. `capable-kit` is the only published package and exposes
|
|
68
|
+
user-facing surfaces through subpaths.
|
|
56
69
|
|
|
57
70
|
## 2026-07-29 — Bundling duplicated nominal App type identities
|
|
58
71
|
|
|
59
|
-
- **Observed:** The standalone `capable` facade bundles `@capable/app`, while
|
|
72
|
+
- **Observed:** The standalone `capable-kit` facade bundles `@capable/app`, while
|
|
60
73
|
surface packages such as `@capable/react-query` reference their own external
|
|
61
74
|
copy. A private `unique symbol` used only to carry Capability type information
|
|
62
75
|
therefore had two incompatible identities in a consuming application.
|
|
@@ -67,9 +80,10 @@ duplicated, or leaky implementation work as it appears.
|
|
|
67
80
|
Capability-call phantom metadata structural. React Query accepts the typed
|
|
68
81
|
callable object it actually projects instead of depending on runtime
|
|
69
82
|
ownership it never reads.
|
|
70
|
-
- **
|
|
71
|
-
|
|
72
|
-
|
|
83
|
+
- **Resolution (2026-08-05):** React Query and the other user-facing surfaces
|
|
84
|
+
now ship through bundled `capable-kit/*` subpaths. Keep an installed-package
|
|
85
|
+
consumer fixture so their declarations and optional peers are checked before
|
|
86
|
+
release.
|
|
73
87
|
|
|
74
88
|
## 2026-07-29 — Manifest discovery cannot be globally eager
|
|
75
89
|
|
|
@@ -383,6 +397,22 @@ duplicated, or leaky implementation work as it appears.
|
|
|
383
397
|
this only if a real App uses one of those names or callable Apps gain
|
|
384
398
|
synchronous leaf metadata.
|
|
385
399
|
|
|
400
|
+
## 2026-08-05 — SWR fetchers do not receive a cancellation signal
|
|
401
|
+
|
|
402
|
+
- **Observed:** SWR passes the cache key to a unary fetcher, but does not expose
|
|
403
|
+
an `AbortSignal` in that fetcher's contract. Capability subscriptions do have
|
|
404
|
+
an explicit cleanup boundary.
|
|
405
|
+
- **Why it matters:** `@capable/swr` cannot forward hook disposal to an in-flight
|
|
406
|
+
unary Capability call the way `@capable/react-query` can. Pretending to own a
|
|
407
|
+
controller would abort at the wrong time because SWR owns request deduplication
|
|
408
|
+
and revalidation.
|
|
409
|
+
- **Current choice:** Unary `swr()` fetchers call the Capability without a
|
|
410
|
+
signal. `subscription()` creates a controller and aborts it from SWR's
|
|
411
|
+
unsubscribe callback.
|
|
412
|
+
- **Follow-up:** Forward cancellation if SWR adds a fetcher lifecycle signal.
|
|
413
|
+
The projection's `key`, `swr`, `mutation`, and `subscription` member names are
|
|
414
|
+
reserved until App leaves have synchronous metadata.
|
|
415
|
+
|
|
386
416
|
## 2026-07-28 — A fresh Next.js build can race SQLite initialization
|
|
387
417
|
|
|
388
418
|
- **Observed:** Next.js page-data collection imports the authenticated Todo
|
|
@@ -40,7 +40,7 @@ You do not give up the normal full-stack experience by choosing Capable. A brows
|
|
|
40
40
|
```ts title="query.ts"
|
|
41
41
|
import { createRemoteApp } from "capable-kit";
|
|
42
42
|
import { createHttpTransport } from "capable-kit/http";
|
|
43
|
-
import { createReactQuery } from "
|
|
43
|
+
import { createReactQuery } from "capable-kit/react-query";
|
|
44
44
|
import type definition from "../capable.app";
|
|
45
45
|
|
|
46
46
|
const app = createRemoteApp<typeof definition>(
|
|
@@ -17,7 +17,7 @@ Compose the server once in a shared module. The adapter only maps methods; execu
|
|
|
17
17
|
|
|
18
18
|
```ts title="capable/server.ts"
|
|
19
19
|
// capable/server.ts
|
|
20
|
-
import { createNextRouteHandlers } from "
|
|
20
|
+
import { createNextRouteHandlers } from "capable-kit/next";
|
|
21
21
|
import { protocol, createServer, http } from "capable-kit/server";
|
|
22
22
|
import definition from "../capable.app";
|
|
23
23
|
|
|
@@ -88,7 +88,7 @@ MCP /mcp
|
|
|
88
88
|
Keep your existing Next.js application, authentication, and deployment. Mount a Capable server in App Router handlers.
|
|
89
89
|
|
|
90
90
|
```ts title="capable/server.ts"
|
|
91
|
-
import { createNextRouteHandlers } from "
|
|
91
|
+
import { createNextRouteHandlers } from "capable-kit/next";
|
|
92
92
|
import { mcp } from "capable-kit/mcp";
|
|
93
93
|
import { createServer, http, protocol } from "capable-kit/server";
|
|
94
94
|
import definition from "../capable.app";
|
|
@@ -210,7 +210,7 @@ export default createEveTools(app);
|
|
|
210
210
|
```tsx title="add-todo.tsx"
|
|
211
211
|
"use client";
|
|
212
212
|
|
|
213
|
-
import { createReactQuery } from "
|
|
213
|
+
import { createReactQuery } from "capable-kit/react-query";
|
|
214
214
|
import { useMutation } from "@tanstack/react-query";
|
|
215
215
|
import { createRemoteApp } from "capable-kit";
|
|
216
216
|
import { createHttpTransport } from "capable-kit/http";
|
package/docs/site/quickstart.mdx
CHANGED
|
@@ -230,7 +230,7 @@ Capable works two ways: as its own service, or embedded in an app you already ha
|
|
|
230
230
|
|
|
231
231
|
```sh title="terminal"
|
|
232
232
|
# inside your existing Next.js app
|
|
233
|
-
pnpm add capable-kit zod
|
|
233
|
+
pnpm add capable-kit zod
|
|
234
234
|
```
|
|
235
235
|
|
|
236
236
|
2. ### Define capabilities
|
|
@@ -292,7 +292,7 @@ Capable works two ways: as its own service, or embedded in an app you already ha
|
|
|
292
292
|
|
|
293
293
|
```ts title="capable/server.ts"
|
|
294
294
|
// capable/server.ts
|
|
295
|
-
import { createNextRouteHandlers } from "
|
|
295
|
+
import { createNextRouteHandlers } from "capable-kit/next";
|
|
296
296
|
import { protocol, createServer, http } from "capable-kit/server";
|
|
297
297
|
import definition from "./app";
|
|
298
298
|
|
|
@@ -347,12 +347,12 @@ Capable works two ways: as its own service, or embedded in an app you already ha
|
|
|
347
347
|
|
|
348
348
|
6. ### Call from React Query
|
|
349
349
|
|
|
350
|
-
|
|
350
|
+
`capable-kit/react-query` mirrors the app tree into query keys and options. The browser talks to the Capable transport at `/_capable`.
|
|
351
351
|
|
|
352
352
|
```ts title="app/query.ts"
|
|
353
353
|
import { createRemoteApp } from "capable-kit";
|
|
354
354
|
import { createHttpTransport } from "capable-kit/http";
|
|
355
|
-
import { createReactQuery } from "
|
|
355
|
+
import { createReactQuery } from "capable-kit/react-query";
|
|
356
356
|
import type definition from "../capable/app";
|
|
357
357
|
|
|
358
358
|
const app = createRemoteApp<typeof definition>(
|
|
@@ -13,7 +13,7 @@ Entry points are explicit so that a server mount, a UI projection, or an agent i
|
|
|
13
13
|
|
|
14
14
|
## The root entry point [#root]
|
|
15
15
|
|
|
16
|
-
`capable` is deliberately limited to authoring and composing apps. Everything you need to define capabilities lives here.
|
|
16
|
+
`capable-kit` is deliberately limited to authoring and composing apps. Everything you need to define capabilities lives here.
|
|
17
17
|
|
|
18
18
|
```ts title="import"
|
|
19
19
|
import {
|
|
@@ -37,17 +37,18 @@ import {
|
|
|
37
37
|
|
|
38
38
|
| Import | Contains |
|
|
39
39
|
| --- | --- |
|
|
40
|
-
| `capable` | Capability authoring, app definitions, executable and remote apps, composition, and the capable command |
|
|
41
|
-
| `capable/server` | `createServer()` plus the `protocol()` and `http()` mounts |
|
|
42
|
-
| `capable/http` | Capable transport client and server encoding: `createHttpTransport()`, `createHttpHandler()` |
|
|
43
|
-
| `capable/cli` | `createCli()` |
|
|
44
|
-
| `capable/mcp` | `createMcp()` and the `mcp()` server mount |
|
|
45
|
-
| `capable/eve` | `createEveTools()` |
|
|
46
|
-
| `capable/ai-sdk` | `createAiSdkTools()` |
|
|
47
|
-
| `capable/app` | App runtime internals: manifests, transport types, selection |
|
|
48
|
-
| `capable/core` | Execution and schema primitives for building your own surface |
|
|
49
|
-
|
|
|
50
|
-
|
|
|
40
|
+
| `capable-kit` | Capability authoring, app definitions, executable and remote apps, composition, and the capable command |
|
|
41
|
+
| `capable-kit/server` | `createServer()` plus the `protocol()` and `http()` mounts |
|
|
42
|
+
| `capable-kit/http` | Capable transport client and server encoding: `createHttpTransport()`, `createHttpHandler()` |
|
|
43
|
+
| `capable-kit/cli` | `createCli()` |
|
|
44
|
+
| `capable-kit/mcp` | `createMcp()` and the `mcp()` server mount |
|
|
45
|
+
| `capable-kit/eve` | `createEveTools()` |
|
|
46
|
+
| `capable-kit/ai-sdk` | `createAiSdkTools()` |
|
|
47
|
+
| `capable-kit/app` | App runtime internals: manifests, transport types, selection |
|
|
48
|
+
| `capable-kit/core` | Execution and schema primitives for building your own surface |
|
|
49
|
+
| `capable-kit/react-query` | `createReactQuery()` |
|
|
50
|
+
| `capable-kit/swr` | `createSWR()` |
|
|
51
|
+
| `capable-kit/next` | `createNextRouteHandlers()` |
|
|
51
52
|
|
|
52
53
|
> **Dependency direction**
|
|
53
54
|
>
|
|
@@ -9,16 +9,20 @@ export const metadata = docMetadata("/surfaces/react-query", frontmatter);
|
|
|
9
9
|
|
|
10
10
|
<DocsPage href="/surfaces/react-query" frontmatter={frontmatter}>
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
`capable-kit/react-query` mirrors the app tree into TanStack Query primitives. Keys, query functions, and mutation functions are derived, so components stop repeating endpoint names and cache keys.
|
|
13
13
|
|
|
14
14
|
## Create the client [#create]
|
|
15
15
|
|
|
16
16
|
Point it at any app. In the browser this is usually a remote app over the Capable transport; on the server it can be a local app. Both App creation and the React Query projection are synchronous. Manifest discovery is deferred until a query actually executes.
|
|
17
17
|
|
|
18
|
+
```sh title="terminal"
|
|
19
|
+
pnpm add capable-kit @tanstack/react-query
|
|
20
|
+
```
|
|
21
|
+
|
|
18
22
|
```ts title="query.ts"
|
|
19
23
|
import { createRemoteApp } from "capable-kit";
|
|
20
24
|
import { createHttpTransport } from "capable-kit/http";
|
|
21
|
-
import { createReactQuery } from "
|
|
25
|
+
import { createReactQuery } from "capable-kit/react-query";
|
|
22
26
|
import type definition from "../capable.app";
|
|
23
27
|
|
|
24
28
|
const app = createRemoteApp<typeof definition>(
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "SWR"
|
|
3
|
+
description: "Derive typed keys and hook arguments for SWR."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import { DocsPage, docMetadata } from "../../_components/docs-page";
|
|
7
|
+
|
|
8
|
+
export const metadata = docMetadata("/surfaces/swr", frontmatter);
|
|
9
|
+
|
|
10
|
+
<DocsPage href="/surfaces/swr" frontmatter={frontmatter}>
|
|
11
|
+
|
|
12
|
+
`capable-kit/swr` mirrors the app tree into SWR keys, fetchers, mutation fetchers,
|
|
13
|
+
and subscribers. Components keep using SWR's hooks and configuration directly,
|
|
14
|
+
without repeating Capability paths or input types.
|
|
15
|
+
|
|
16
|
+
## Create the projection [#create]
|
|
17
|
+
|
|
18
|
+
Point it at a local or remote App. Manifest discovery remains lazy and starts
|
|
19
|
+
only when SWR calls a generated fetcher.
|
|
20
|
+
|
|
21
|
+
```sh title="terminal"
|
|
22
|
+
pnpm add capable-kit swr
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```ts title="swr.ts"
|
|
26
|
+
import { createRemoteApp } from "capable-kit";
|
|
27
|
+
import { createHttpTransport } from "capable-kit/http";
|
|
28
|
+
import { createSWR } from "capable-kit/swr";
|
|
29
|
+
import type definition from "../capable.app";
|
|
30
|
+
|
|
31
|
+
const app = createRemoteApp<typeof definition>(
|
|
32
|
+
createHttpTransport({ url: "/_capable/" }),
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
export const capableSWR = createSWR(app);
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Use it in components [#use]
|
|
39
|
+
|
|
40
|
+
Each operation returns the arguments for its corresponding SWR hook, so the
|
|
41
|
+
generated types flow through a normal spread call.
|
|
42
|
+
|
|
43
|
+
```tsx title="todo-list.tsx"
|
|
44
|
+
import useSWR, { useSWRConfig } from "swr";
|
|
45
|
+
import useSWRMutation from "swr/mutation";
|
|
46
|
+
import { capableSWR } from "./swr";
|
|
47
|
+
|
|
48
|
+
export function TodoList() {
|
|
49
|
+
const { mutate } = useSWRConfig();
|
|
50
|
+
const todos = useSWR(...capableSWR.todos.list.swr({}));
|
|
51
|
+
const createTodo = useSWRMutation(
|
|
52
|
+
...capableSWR.todos.create.mutation({
|
|
53
|
+
onSuccess: () => mutate(capableSWR.todos.list.key()),
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
if (todos.isLoading) return <Spinner />;
|
|
58
|
+
if (todos.error) return <Error error={todos.error} />;
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<>
|
|
62
|
+
<ul>{todos.data?.map((todo) => <li key={todo.id}>{todo.title}</li>)}</ul>
|
|
63
|
+
<button onClick={() => createTodo.trigger({ title: "New" })}>Add</button>
|
|
64
|
+
</>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
| Method | Returns |
|
|
70
|
+
| --- | --- |
|
|
71
|
+
| `key(input?)` | `["capable", ...path, input?]`, for cache access and revalidation |
|
|
72
|
+
| `swr(input, options?)` | Typed arguments for `useSWR` |
|
|
73
|
+
| `mutation(options?)` | Typed arguments for `useSWRMutation`; `trigger` takes the Capability input |
|
|
74
|
+
| `subscription(input, options?)` | Typed arguments for `useSWRSubscription`, only on subscribable Capabilities |
|
|
75
|
+
|
|
76
|
+
Pass `keyPrefix` to `createSWR()` if the `capable` prefix collides with existing
|
|
77
|
+
keys.
|
|
78
|
+
|
|
79
|
+
## Subscriptions [#subscriptions]
|
|
80
|
+
|
|
81
|
+
When a Capability defines [subscribe](/patterns/subscriptions), the projection
|
|
82
|
+
adds `subscription()`. Unmounting aborts the Capability subscription.
|
|
83
|
+
|
|
84
|
+
```tsx title="live-todos.tsx"
|
|
85
|
+
import useSWRSubscription from "swr/subscription";
|
|
86
|
+
import { capableSWR } from "./swr";
|
|
87
|
+
|
|
88
|
+
const todos = useSWRSubscription(
|
|
89
|
+
...capableSWR.todos.list.subscription({}),
|
|
90
|
+
);
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
> SWR does not provide an `AbortSignal` to unary fetchers, so unary Capability
|
|
94
|
+
> calls cannot be cancelled by hook disposal. Subscription cleanup is wired to
|
|
95
|
+
> an `AbortController`.
|
|
96
|
+
|
|
97
|
+
</DocsPage>
|
package/docs/site/surfaces.mdx
CHANGED
|
@@ -36,12 +36,14 @@ A projection needs no server at all. It takes an executable app and returns comm
|
|
|
36
36
|
import { createCli } from "capable-kit/cli";
|
|
37
37
|
import { createAiSdkTools } from "capable-kit/ai-sdk";
|
|
38
38
|
import { createEveTools } from "capable-kit/eve";
|
|
39
|
-
import { createReactQuery } from "
|
|
39
|
+
import { createReactQuery } from "capable-kit/react-query";
|
|
40
|
+
import { createSWR } from "capable-kit/swr";
|
|
40
41
|
|
|
41
42
|
createCli(app); // process-level command tree
|
|
42
43
|
await createAiSdkTools(app); // typed AI SDK tools
|
|
43
44
|
createEveTools(app); // durable in-process agent tools
|
|
44
45
|
createReactQuery(app); // query keys and options for a UI
|
|
46
|
+
createSWR(app); // SWR keys and hook arguments for a UI
|
|
45
47
|
```
|
|
46
48
|
|
|
47
49
|
## Choosing surfaces [#choose]
|
|
@@ -55,7 +57,8 @@ createReactQuery(app); // query keys and options for a UI
|
|
|
55
57
|
| [MCP](/surfaces/mcp) | External agents connect over the network | `capable/mcp` |
|
|
56
58
|
| [Eve](/surfaces/eve) | An agent runs in your process | `capable/eve` |
|
|
57
59
|
| [AI SDK](/surfaces/ai-sdk) | An AI SDK model or agent calls your app | `capable/ai-sdk` |
|
|
58
|
-
| [React Query](/surfaces/react-query) | A React UI reads and mutates the app |
|
|
60
|
+
| [React Query](/surfaces/react-query) | A React UI reads and mutates the app | `capable-kit/react-query` |
|
|
61
|
+
| [SWR](/surfaces/swr) | A React UI reads, mutates, and subscribes with SWR | `capable-kit/swr` |
|
|
59
62
|
|
|
60
63
|
> **Nothing is implicit**
|
|
61
64
|
>
|
|
@@ -74,5 +77,6 @@ createReactQuery(app); // query keys and options for a UI
|
|
|
74
77
|
- [**AI SDK**](/surfaces/ai-sdk) — Typed tools for generateText, streamText, and agents.
|
|
75
78
|
- [**Eve**](/surfaces/eve) — Native in-process tools with approvals.
|
|
76
79
|
- [**React Query**](/surfaces/react-query) — Query keys, mutations, and live queries.
|
|
80
|
+
- [**SWR**](/surfaces/swr) — Keys and arguments for queries, mutations, and subscriptions.
|
|
77
81
|
|
|
78
82
|
</DocsPage>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "capable-kit",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"cap": "dist/bin.mjs",
|
|
@@ -39,9 +39,21 @@
|
|
|
39
39
|
"types": "./dist/mcp.d.mts",
|
|
40
40
|
"import": "./dist/mcp.mjs"
|
|
41
41
|
},
|
|
42
|
+
"./next": {
|
|
43
|
+
"types": "./dist/next.d.mts",
|
|
44
|
+
"import": "./dist/next.mjs"
|
|
45
|
+
},
|
|
46
|
+
"./react-query": {
|
|
47
|
+
"types": "./dist/react-query.d.mts",
|
|
48
|
+
"import": "./dist/react-query.mjs"
|
|
49
|
+
},
|
|
42
50
|
"./server": {
|
|
43
51
|
"types": "./dist/server.d.mts",
|
|
44
52
|
"import": "./dist/server.mjs"
|
|
53
|
+
},
|
|
54
|
+
"./swr": {
|
|
55
|
+
"types": "./dist/swr.d.mts",
|
|
56
|
+
"import": "./dist/swr.mjs"
|
|
45
57
|
}
|
|
46
58
|
},
|
|
47
59
|
"files": [
|
|
@@ -73,15 +85,23 @@
|
|
|
73
85
|
"nitro": "3.0.260610-beta"
|
|
74
86
|
},
|
|
75
87
|
"peerDependencies": {
|
|
88
|
+
"@tanstack/react-query": ">=5.80.2 <6",
|
|
76
89
|
"ai": "^7.0.0",
|
|
77
|
-
"eve": ">=0.27.1"
|
|
90
|
+
"eve": ">=0.27.1",
|
|
91
|
+
"swr": ">=2.3.0 <3"
|
|
78
92
|
},
|
|
79
93
|
"peerDependenciesMeta": {
|
|
94
|
+
"@tanstack/react-query": {
|
|
95
|
+
"optional": true
|
|
96
|
+
},
|
|
80
97
|
"ai": {
|
|
81
98
|
"optional": true
|
|
82
99
|
},
|
|
83
100
|
"eve": {
|
|
84
101
|
"optional": true
|
|
102
|
+
},
|
|
103
|
+
"swr": {
|
|
104
|
+
"optional": true
|
|
85
105
|
}
|
|
86
106
|
}
|
|
87
107
|
}
|
package/src/index.test.ts
CHANGED
|
@@ -7,7 +7,10 @@ import { executeCapability } from "./core.ts";
|
|
|
7
7
|
import { createEveTools } from "./eve.ts";
|
|
8
8
|
import { createHttpHandler, createHttpTransport } from "./http.ts";
|
|
9
9
|
import { createMcp, mcp } from "./mcp.ts";
|
|
10
|
+
import { createNextRouteHandlers } from "./next.ts";
|
|
11
|
+
import { createReactQuery } from "./react-query.ts";
|
|
10
12
|
import { createServer } from "./server.ts";
|
|
13
|
+
import { createSWR } from "./swr.ts";
|
|
11
14
|
|
|
12
15
|
describe("capable public entry points", () => {
|
|
13
16
|
test("ships cap as the primary command with the capable alias", async () => {
|
|
@@ -49,8 +52,11 @@ describe("capable public entry points", () => {
|
|
|
49
52
|
createEveTools,
|
|
50
53
|
createHttpHandler,
|
|
51
54
|
createMcp,
|
|
55
|
+
createNextRouteHandlers,
|
|
56
|
+
createReactQuery,
|
|
52
57
|
mcp,
|
|
53
58
|
createServer,
|
|
59
|
+
createSWR,
|
|
54
60
|
createHttpTransport,
|
|
55
61
|
].every((value) => typeof value === "function")).toBe(true);
|
|
56
62
|
});
|
package/src/next.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@capable/next";
|
package/src/package.test.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { execFileSync } from "node:child_process";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
existsSync,
|
|
4
|
+
mkdtempSync,
|
|
5
|
+
readdirSync,
|
|
6
|
+
readFileSync,
|
|
7
|
+
rmSync,
|
|
8
|
+
} from "node:fs";
|
|
3
9
|
import { tmpdir } from "node:os";
|
|
4
10
|
import { join } from "node:path";
|
|
5
11
|
import { fileURLToPath } from "node:url";
|
|
@@ -39,6 +45,11 @@ describe("published package", () => {
|
|
|
39
45
|
),
|
|
40
46
|
) as {
|
|
41
47
|
readonly directories?: { readonly doc?: string };
|
|
48
|
+
readonly exports?: Readonly<Record<string, unknown>>;
|
|
49
|
+
readonly peerDependenciesMeta?: Readonly<Record<
|
|
50
|
+
string,
|
|
51
|
+
{ readonly optional?: boolean }
|
|
52
|
+
>>;
|
|
42
53
|
readonly scripts?: Record<string, string>;
|
|
43
54
|
};
|
|
44
55
|
const quickstart = execFileSync(
|
|
@@ -66,9 +77,10 @@ describe("published package", () => {
|
|
|
66
77
|
(path) =>
|
|
67
78
|
path.startsWith("docs/site/") && path.endsWith(".mdx"),
|
|
68
79
|
),
|
|
69
|
-
).toHaveLength(
|
|
80
|
+
).toHaveLength(27);
|
|
70
81
|
expect(paths).toContain("docs/site/introduction.mdx");
|
|
71
82
|
expect(paths).toContain("docs/site/concepts/presentations.mdx");
|
|
83
|
+
expect(paths).toContain("docs/site/surfaces/swr.mdx");
|
|
72
84
|
expect(
|
|
73
85
|
[...paths].some(
|
|
74
86
|
(path) =>
|
|
@@ -86,6 +98,24 @@ describe("published package", () => {
|
|
|
86
98
|
expect(manifest.directories?.doc).toBe("./docs");
|
|
87
99
|
expect(manifest.scripts?.prepack).toBeUndefined();
|
|
88
100
|
expect(manifest.scripts?.postpack).toBeUndefined();
|
|
101
|
+
expect(Object.keys(manifest.exports ?? {})).toEqual([
|
|
102
|
+
".",
|
|
103
|
+
"./ai-sdk",
|
|
104
|
+
"./app",
|
|
105
|
+
"./cli",
|
|
106
|
+
"./core",
|
|
107
|
+
"./eve",
|
|
108
|
+
"./http",
|
|
109
|
+
"./mcp",
|
|
110
|
+
"./next",
|
|
111
|
+
"./react-query",
|
|
112
|
+
"./server",
|
|
113
|
+
"./swr",
|
|
114
|
+
]);
|
|
115
|
+
expect(manifest.peerDependenciesMeta).toMatchObject({
|
|
116
|
+
"@tanstack/react-query": { optional: true },
|
|
117
|
+
swr: { optional: true },
|
|
118
|
+
});
|
|
89
119
|
expect(quickstart).toMatch(
|
|
90
120
|
/^---\ntitle: "Quickstart"\ndescription: ".+"\n---/,
|
|
91
121
|
);
|
|
@@ -99,4 +129,29 @@ describe("published package", () => {
|
|
|
99
129
|
});
|
|
100
130
|
}
|
|
101
131
|
});
|
|
132
|
+
|
|
133
|
+
test("keeps scoped workspace packages private", () => {
|
|
134
|
+
const packagesDirectory = new URL("../../", import.meta.url);
|
|
135
|
+
|
|
136
|
+
for (const entry of readdirSync(packagesDirectory, {
|
|
137
|
+
withFileTypes: true,
|
|
138
|
+
})) {
|
|
139
|
+
if (!entry.isDirectory()) continue;
|
|
140
|
+
const manifestPath = new URL(
|
|
141
|
+
`./${entry.name}/package.json`,
|
|
142
|
+
packagesDirectory,
|
|
143
|
+
);
|
|
144
|
+
if (!existsSync(manifestPath)) continue;
|
|
145
|
+
|
|
146
|
+
const manifest = JSON.parse(readFileSync(manifestPath, "utf8")) as {
|
|
147
|
+
readonly name?: string;
|
|
148
|
+
readonly private?: boolean;
|
|
149
|
+
readonly publishConfig?: unknown;
|
|
150
|
+
};
|
|
151
|
+
if (!manifest.name?.startsWith("@capable/")) continue;
|
|
152
|
+
|
|
153
|
+
expect(manifest.private, manifest.name).toBe(true);
|
|
154
|
+
expect(manifest.publishConfig, manifest.name).toBeUndefined();
|
|
155
|
+
}
|
|
156
|
+
});
|
|
102
157
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@capable/react-query";
|
package/src/swr.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@capable/swr";
|