caplets 0.17.9 → 0.18.1

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 (3) hide show
  1. package/README.md +157 -62
  2. package/dist/index.js +2 -69911
  3. package/package.json +4 -4
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <div align="center">
2
- <img src="plugins/caplets/assets/icon.png" alt="Caplets logo" width="140" height="140" />
2
+ <img src="docs/assets/caplets-icon.png" alt="Caplets logo" width="140" height="140" />
3
3
 
4
4
  <h1>Caplets</h1>
5
5
 
@@ -12,7 +12,7 @@
12
12
  <a href="https://www.npmjs.com/package/caplets"><img alt="npm" src="https://img.shields.io/npm/v/caplets?style=flat-square&color=E0582F" /></a>
13
13
  <a href="https://github.com/spiritledsoftware/caplets/actions/workflows/ci.yml"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/spiritledsoftware/caplets/ci.yml?branch=main&style=flat-square&label=ci&color=E0582F" /></a>
14
14
  <a href="LICENSE"><img alt="MIT License" src="https://img.shields.io/badge/license-MIT-F6E8C8?style=flat-square&labelColor=1F2018" /></a>
15
- <img alt="Node 22+" src="https://img.shields.io/badge/node-%3E%3D22-F6E8C8?style=flat-square&labelColor=1F2018" />
15
+ <img alt="Node 24+" src="https://img.shields.io/badge/node-%3E%3D24-F6E8C8?style=flat-square&labelColor=1F2018" />
16
16
  </p>
17
17
 
18
18
  <p>
@@ -28,7 +28,7 @@
28
28
 
29
29
  Caplets turns MCP servers, APIs, and commands into focused agent capabilities: one card first, searchable tools next, inspectable schemas before calls, and preserved results after.
30
30
 
31
- Stop dumping every operation into context up front. Caplets wraps each tool source as a capability an agent can discover, inspect, call, and recover from one step at a time. Instead of exposing a giant flat wall of operations, Caplets shows a compact capability card with source, status, and next actions. The agent chooses a domain first, then uses scoped operations like `search_tools`, `get_tool`, and `call_tool` only when it needs more detail.
31
+ Stop dumping every operation into context up front. Caplets wraps each tool source as a capability an agent can discover, inspect, call, and recover from one step at a time. Instead of exposing a giant flat wall of operations, Caplets shows a compact capability card with source, status, and next actions. The agent chooses a domain first, then uses scoped operations like `search_tools`, `describe_tool`, and `call_tool` only when it needs more detail.
32
32
 
33
33
  For MCP-backed Caplets, the scoped operation set also includes resource discovery and reading, prompt listing and rendering, resource-template discovery, and completion for prompt or template arguments. Non-MCP backends expose focused tool and action operations.
34
34
 
@@ -43,11 +43,11 @@ caplets add mcp context7 --command npx --arg -y --arg @upstash/context7-mcp
43
43
  caplets serve
44
44
  ```
45
45
 
46
- In the deterministic benchmark, 106 flat tools became 3 top-level capabilities with an 87.9% smaller initial payload. Your agent starts with `context7`, then drills in through `inspect`, `search_tools`, `get_tool`, and `call_tool` only when needed.
46
+ In the deterministic benchmark, 106 flat tools became 3 top-level capabilities with an 87.9% smaller initial payload. Your agent starts with `context7`, then drills in through `inspect`, `search_tools`, `describe_tool`, and `call_tool` only when needed.
47
47
 
48
48
  ## Quick Start
49
49
 
50
- Caplets requires Node.js 22 or newer.
50
+ Caplets requires Node.js 24 or newer.
51
51
 
52
52
  ```sh
53
53
  npm install -g caplets
@@ -134,32 +134,100 @@ Completions include command names, options, common enum values, configured Caple
134
134
 
135
135
  Backends that require OAuth or token auth may need `caplets auth login <server>` before live downstream completions can return richer results. Completion never starts interactive login flows.
136
136
 
137
- ## Agent Plugins
137
+ ## Agent Integrations
138
138
 
139
139
  Use Caplets as a normal MCP server everywhere, or install a native agent integration when
140
140
  your coding agent supports one.
141
141
 
142
- | Agent | Install | What It Provides |
143
- | -------------- | --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
144
- | Any MCP client | Add `caplets serve` as a stdio MCP server | Universal progressive-disclosure gateway |
145
- | Claude Code | `claude plugin marketplace add spiritledsoftware/caplets && claude plugin install caplets@caplets` | Claude Code plugin metadata, MCP config, and shared skill guidance |
146
- | Codex | `codex plugin marketplace add spiritledsoftware/caplets`, then install `caplets` from Codex plugins | Codex plugin metadata, MCP config, and shared skill guidance |
147
- | OpenCode | Install [`@caplets/opencode`](packages/opencode/README.md) | Native `caplets_<id>` tools and prompt guidance hooks |
148
- | Pi | Install [`@caplets/pi`](packages/pi/README.md) | Native `caplets_<id>` tools with Pi prompt snippets/guidelines |
142
+ | Agent | Install | What It Provides |
143
+ | -------------- | -------------------------------------------------------------- | --------------------------------------------------------------- |
144
+ | Any MCP client | Add `caplets serve` or `caplets attach` manually in MCP config | Universal Code Mode gateway; progressive exposure is opt-in |
145
+ | Claude Code | Add `caplets serve` or `caplets attach` manually in MCP config | Local or remote/Cloud Code Mode gateway |
146
+ | Codex | Add `caplets serve` or `caplets attach` manually in MCP config | Local or remote/Cloud Code Mode gateway |
147
+ | OpenCode | Install [`@caplets/opencode`](packages/opencode/README.md) | Native `caplets__<id>` tools and prompt guidance hooks |
148
+ | Pi | Install [`@caplets/pi`](packages/pi/README.md) | Native `caplets__<id>` tools with Pi prompt snippets/guidelines |
149
149
 
150
- Codex and Claude Code plugins are plugin-native but MCP-backed. The installable plugin
151
- lives under `plugins/caplets/`, with agent-specific manifests in `.codex-plugin/` and
152
- `.claude-plugin/`, a shared `skills/` directory, and shared `mcp.json` config. The
153
- repo-level `.agents/plugins/marketplace.json` and `.claude-plugin/marketplace.json`
154
- files only advertise that installable plugin root.
150
+ Codex local MCP config (`~/.codex/config.toml`):
155
151
 
156
- The Claude Code and Codex commands install from this GitHub repository through each agent's
157
- plugin marketplace flow; users do not need to clone the repository manually. Plugin MCP
158
- configs run `caplets serve` directly, so install the Caplets CLI globally first.
152
+ ```toml
153
+ [mcp_servers.caplets]
154
+ command = "caplets"
155
+ args = ["serve"]
156
+ ```
157
+
158
+ Claude Code or generic JSON MCP config:
159
+
160
+ ```json
161
+ {
162
+ "mcpServers": {
163
+ "caplets": {
164
+ "command": "caplets",
165
+ "args": ["serve"]
166
+ }
167
+ }
168
+ }
169
+ ```
170
+
171
+ Codex remote or Cloud MCP config (`~/.codex/config.toml`):
172
+
173
+ ```toml
174
+ [mcp_servers.caplets]
175
+ command = "caplets"
176
+ args = ["attach"]
177
+ ```
178
+
179
+ Claude Code or generic JSON remote or Cloud MCP config:
180
+
181
+ ```json
182
+ {
183
+ "mcpServers": {
184
+ "caplets": {
185
+ "command": "caplets",
186
+ "args": ["attach"]
187
+ }
188
+ }
189
+ }
190
+ ```
191
+
192
+ For Caplets Cloud, authenticate once and set the remote selection environment for the agent:
193
+
194
+ ```sh
195
+ caplets cloud auth login
196
+ export CAPLETS_MODE=cloud
197
+ export CAPLETS_REMOTE_URL=https://cloud.caplets.dev
198
+ ```
199
+
200
+ For a self-hosted remote:
201
+
202
+ ```sh
203
+ export CAPLETS_MODE=remote
204
+ export CAPLETS_REMOTE_URL=https://caplets.example.com/caplets
205
+ export CAPLETS_REMOTE_TOKEN=...
206
+ ```
207
+
208
+ ## Core Alchemy
209
+
210
+ Core Alchemy deploys the public landing page from `apps/landing`. It does not deploy the private Cloud Worker or Cloud dashboard; those belong to the nested Cloud repository.
159
211
 
160
212
  ### Remote Caplets service
161
213
 
162
- OpenCode and Pi can use native `caplets_<id>` tools backed by a remote Caplets HTTP service. Codex, Claude Code, and any MCP client can connect to the same remote MCP endpoint directly.
214
+ OpenCode and Pi can use native `caplets__<id>` tools backed by a remote Caplets HTTP service. Codex, Claude Code, and any MCP client can connect to the same remote MCP endpoint directly.
215
+
216
+ Hosted Caplets Cloud uses browser-mediated Cloud Auth:
217
+
218
+ ```sh
219
+ caplets cloud auth login --workspace personal
220
+ caplets cloud auth status
221
+ caplets cloud auth workspaces
222
+ caplets cloud auth switch team
223
+ caplets cloud auth logout
224
+ ```
225
+
226
+ Cloud Auth stores one Selected Workspace locally. `caplets attach --workspace <workspace>` must match that saved workspace; switch explicitly before attaching another hosted workspace. Self-hosted remotes continue to use `CAPLETS_REMOTE_URL`, `CAPLETS_REMOTE_TOKEN`, or Basic Auth credentials.
227
+
228
+ Access tokens are short-lived. The CLI refreshes expired hosted credentials before attach, persists the rotated refresh token returned by Cloud, and treats revoked refresh credentials as a fresh-login requirement. `caplets cloud auth logout` clears local credentials; Cloud logout revokes the refresh credential family so rotated refresh tokens stop working together.
229
+
230
+ Use `caplets attach --once` for a finite Project Binding smoke test, or `caplets attach` to run a remote-backed MCP server over stdio or HTTP with Project Binding and local overlay.
163
231
 
164
232
  Start a local HTTP service. `--path` is the service base path; Caplets mounts MCP,
165
233
  control, and health endpoints underneath it:
@@ -260,38 +328,54 @@ Flat tool lists make agents guess before they understand. If every downstream se
260
328
  Caplets turns that flat wall into a staged path:
261
329
 
262
330
  1. **Choose** a capability, such as `GitHub`.
263
- 2. **Inspect** matching operations with `search_tools` or `list_tools`.
264
- 3. **Resolve** the exact schema with `get_tool`.
331
+ 2. **Inspect** matching operations with `search_tools` or `tools`.
332
+ 3. **Resolve** the exact schema with `describe_tool`.
265
333
  4. **Invoke** with `call_tool` while preserving downstream content, structured data, and error state.
266
334
 
267
335
  A backend enters agent context as a focused card with source, status, and next actions, not a wall of operations.
268
336
 
269
337
  ## Benchmark
270
338
 
271
- In Caplets' reproducible coding-agent benchmark, the same three mock MCP servers are
339
+ Caplets reduces the tool surface an agent has to carry while preserving access to the
340
+ same downstream operations.
341
+
342
+ In Caplets' deterministic coding-agent benchmark, the same seven mock MCP servers are
272
343
  exposed two ways: direct flat MCP aggregation versus Caplets progressive disclosure.
273
344
 
274
345
  | Initial Agent Surface | Direct Flat MCP | Caplets | Reduction |
275
346
  | ------------------------- | ----------------: | -----------: | ------------: |
276
- | Visible tools | 106 | 3 | 97.2% fewer |
277
- | Serialized MCP payload | 32,090 bytes | 8,442 bytes | 73.7% smaller |
278
- | Approx. context surface | 8,023 tokens | 2,111 tokens | 5,912 fewer |
347
+ | Visible tools | 215 | 7 | 96.7% fewer |
348
+ | Serialized MCP payload | 63,250 bytes | 12,720 bytes | 79.9% smaller |
349
+ | Approx. context surface | 15,813 tokens | 3,180 tokens | 12,633 fewer |
279
350
  | Top-level name collisions | 3 duplicate names | 0 | eliminated |
280
351
 
281
352
  Caplets does not remove access to downstream tools. It places them behind scoped
282
353
  discovery operations, so the agent sees less up front while retaining access to the same
283
354
  capabilities when needed.
284
355
 
285
- A local OpenCode live benchmark also completed the full benchmark matrix successfully:
286
-
287
- | Agent | Mode | Tasks Passed |
288
- | ------------------------------ | --------------- | -----------: |
289
- | OpenCode `openai/gpt-5.5-fast` | Direct flat MCP | 2/2 |
290
- | OpenCode `openai/gpt-5.5-fast` | Caplets | 2/2 |
291
-
292
- Live results are intentionally not committed as product claims because they depend on
293
- local agent CLIs, credentials, models, providers, and agent behavior. The deterministic
294
- surface benchmark is the reproducible claim.
356
+ In a live Pi eval on a real-world large MCP stack, Caplets Code Mode completed the same
357
+ 10/10 tasks as direct MCP and Executor while using far fewer total tokens. The stack used
358
+ GitHub, Context7, DeepWiki, Git, filesystem, Playwright, ast-grep, language-server, and
359
+ web-search MCP servers. The run used `openai-codex/gpt-5.5` as both the main model and
360
+ judge model, with 2 runs per task per mode.
361
+
362
+ | Mode | Tasks Passed | Avg request + output tokens | Avg provider tokens |
363
+ | ------------------------------- | -----------: | --------------------------: | ------------------: |
364
+ | Caplets Code Mode | 10/10 | 236,803 | 126,877 |
365
+ | Caplets progressive + Code Mode | 10/10 | 422,861 | 264,624 |
366
+ | Caplets progressive | 10/10 | 461,171 | 294,217 |
367
+ | Executor MCP | 10/10 | 675,842 | 369,992 |
368
+ | Direct vanilla MCP | 10/10 | 846,048 | 544,121 |
369
+
370
+ Against the same pass-rate baseline, Caplets Code Mode used 72.0% fewer request+output
371
+ tokens than direct vanilla MCP and 65.0% fewer than Executor MCP. Caplets progressive
372
+ disclosure also beat direct vanilla MCP by 45.5% and Executor MCP by 31.8% on
373
+ request+output tokens.
374
+
375
+ Live results depend on local agent CLIs, credentials, model/provider behavior, and the
376
+ date of the run. The deterministic surface benchmark remains the reproducible,
377
+ credential-free claim; the live eval demonstrates the same trend in a realistic large
378
+ MCP harness.
295
379
 
296
380
  See [`docs/benchmarks/coding-agent.md`](docs/benchmarks/coding-agent.md) for methodology,
297
381
  limitations, and reproduction commands.
@@ -300,7 +384,7 @@ limitations, and reproduction commands.
300
384
  pnpm benchmark
301
385
  pnpm benchmark:check
302
386
  pnpm build
303
- CAPLETS_BENCH_LIVE=1 pnpm benchmark:live:opencode -- --model openai/gpt-5.5-fast
387
+ CAPLETS_BENCH_LIVE=1 pnpm benchmark:live:pi-eval -- --task-suite mcp-real-world-large --mode caplets-code-mode,caplets-progressive,vanilla-mcp,executor-mcp --model openai-codex/gpt-5.5 --runs 2
304
388
  ```
305
389
 
306
390
  ## Design Model
@@ -338,7 +422,7 @@ If a backend fails, Caplets keeps the error scoped to the capability, preserves
338
422
  - Uses the configured `name` and `description` as the capability card shown to agents.
339
423
  - Starts downstream MCP servers and loads OpenAPI specs lazily when an operation needs them.
340
424
  - Supports stdio, Streamable HTTP, and legacy HTTP+SSE downstream servers.
341
- - Lets agents `list_tools`, `search_tools`, `get_tool`, and `call_tool` within one selected Caplet namespace.
425
+ - Lets agents `tools`, `search_tools`, `describe_tool`, and `call_tool` within one selected Caplet namespace.
342
426
  - Converts OpenAPI operations into MCP-style tool metadata and executes HTTP calls directly.
343
427
  - Converts configured GraphQL operations into MCP-style tool metadata, and can auto-generate GraphQL tools from schema root query and mutation fields.
344
428
  - Converts explicitly configured HTTP actions into MCP-style tool metadata and executes HTTP calls directly.
@@ -728,7 +812,7 @@ OpenAPI auth is explicit and supports:
728
812
  - `{"type": "oauth2", ...}`
729
813
  - `{"type": "oidc", ...}`
730
814
 
731
- OpenAPI `call_tool.arguments` uses grouped HTTP inputs:
815
+ OpenAPI `call_tool.args` uses grouped HTTP inputs:
732
816
 
733
817
  ```json
734
818
  {
@@ -772,7 +856,7 @@ endpoint and exactly one schema source: `schemaPath`, `schemaUrl`, or `introspec
772
856
 
773
857
  When `operations` is omitted or empty, Caplets auto-generates tools from schema root
774
858
  fields: `query_<field>` and `mutation_<field>`. Generated tools use bounded scalar
775
- selection sets and pass `call_tool.arguments` directly as GraphQL variables/root-field
859
+ selection sets and pass `call_tool.args` directly as GraphQL variables/root-field
776
860
  arguments.
777
861
 
778
862
  Every GraphQL endpoint can set:
@@ -826,7 +910,7 @@ must start with `/` and be URL paths that cannot change origin or escape the bas
826
910
  Action mappings can set `query`, `headers`, and `jsonBody`. `query` and `headers` must resolve
827
911
  to object maps whose values are strings, numbers, or booleans. `jsonBody` may use literals,
828
912
  nested arrays/objects, `$input.field` references, or `$input` for the whole argument object.
829
- Path placeholders such as `{service}` are read directly from `call_tool.arguments` and URL-encoded.
913
+ Path placeholders such as `{service}` are read directly from `call_tool.args` and URL-encoded.
830
914
  Configured action headers cannot set managed headers such as `authorization`, `host`,
831
915
  `content-length`, `connection`, or `content-type`; JSON bodies set `content-type` automatically.
832
916
 
@@ -887,8 +971,8 @@ an existing destination file.
887
971
  ### Caplet Sets
888
972
 
889
973
  Use `capletSets` to expose another Caplets collection as nested Caplets. Each child Caplet appears
890
- as one downstream tool and supports the full Caplets operation set: `inspect`, `check_backend`,
891
- `list_tools`, `search_tools`, `get_tool`, and `call_tool`.
974
+ as one downstream tool and supports the full Caplets operation set: `inspect`, `check`,
975
+ `tools`, `search_tools`, `describe_tool`, and `call_tool`.
892
976
 
893
977
  ```json
894
978
  {
@@ -1029,7 +1113,13 @@ their downstream connections keep running.
1029
1113
 
1030
1114
  ## Quick Integration Setup
1031
1115
 
1032
- Use `caplets setup` to install or configure an agent integration:
1116
+ Run the interactive setup flow to choose one or more agent integrations:
1117
+
1118
+ ```bash
1119
+ caplets setup
1120
+ ```
1121
+
1122
+ For scripted setup, pass the integration explicitly:
1033
1123
 
1034
1124
  ```bash
1035
1125
  caplets setup codex
@@ -1048,17 +1138,21 @@ caplets setup codex --dry-run
1048
1138
  For native integrations that should connect to a remote Caplets HTTP service:
1049
1139
 
1050
1140
  ```bash
1051
- caplets setup opencode --remote --server-url https://caplets.example.com/caplets
1141
+ caplets setup codex --remote-url https://caplets.example.com/caplets
1142
+ caplets setup claude-code --remote-url https://caplets.example.com/caplets
1143
+ caplets setup opencode --remote-url https://caplets.example.com/caplets
1052
1144
  ```
1053
1145
 
1054
- `caplets setup` runs the supported agent installer commands or writes the explicit config
1055
- path you pass with `--output`. It does not store secrets, edit unknown MCP client config
1056
- locations, or start `caplets serve`.
1146
+ For Codex and Claude Code, `caplets setup` uses each harness's MCP configuration command:
1147
+ `codex mcp add caplets -- caplets serve` and
1148
+ `claude mcp add --transport stdio --scope user caplets -- caplets serve`. Generic MCP
1149
+ clients still require an explicit `--output` path because their config locations are not
1150
+ standardized. The setup command does not store secrets or start `caplets serve`.
1057
1151
 
1058
1152
  ## Additional Native Integrations
1059
1153
 
1060
1154
  OpenCode and Pi support true native tool registration. Those integrations expose one
1061
- prefixed tool per configured Caplet, such as `caplets_github`, while reusing the same
1155
+ prefixed tool per configured Caplet, such as `caplets__github`, while reusing the same
1062
1156
  Caplets config and backend runtime.
1063
1157
 
1064
1158
  - [`@caplets/opencode`](packages/opencode/README.md): OpenCode plugin that injects prompt guidance through plugin hooks instead of editing `opencode.json`.
@@ -1083,7 +1177,7 @@ Each generated Caplet tool accepts an `operation`:
1083
1177
 
1084
1178
  ```json
1085
1179
  {
1086
- "operation": "list_tools"
1180
+ "operation": "tools"
1087
1181
  }
1088
1182
  ```
1089
1183
 
@@ -1101,7 +1195,7 @@ Inspect one exact downstream tool:
1101
1195
 
1102
1196
  ```json
1103
1197
  {
1104
- "operation": "get_tool",
1198
+ "operation": "describe_tool",
1105
1199
  "tool": "read_file"
1106
1200
  }
1107
1201
  ```
@@ -1121,23 +1215,23 @@ Call one exact downstream tool:
1121
1215
  Available operations:
1122
1216
 
1123
1217
  - `inspect`: return the configured capability card without starting the downstream server.
1124
- - `check_backend`: verify the selected backend, whether MCP, OpenAPI, GraphQL, HTTP, CLI, or nested Caplets.
1125
- - `list_tools`: return compact downstream tool metadata.
1218
+ - `check`: verify the selected backend, whether MCP, OpenAPI, GraphQL, HTTP, CLI, or nested Caplets.
1219
+ - `tools`: return compact downstream tool metadata.
1126
1220
  - `search_tools`: search downstream tool names and descriptions within this Caplet.
1127
- - `get_tool`: return full metadata for one exact downstream tool.
1221
+ - `describe_tool`: return full metadata for one exact downstream tool.
1128
1222
  - `call_tool`: invoke one exact downstream tool with JSON object arguments.
1129
1223
 
1130
1224
  Requests are strict: operation-specific extra fields are rejected, and `call_tool` requires
1131
1225
  `arguments` to be a JSON object.
1132
1226
 
1133
- Discovery operations (`inspect`, `check_backend`, `list_tools`, `search_tools`, and
1134
- `get_tool`) return wrapper-generated results whose `structuredContent.caplets` field
1227
+ Discovery operations (`inspect`, `check`, `tools`, `search_tools`, and
1228
+ `describe_tool`) return wrapper-generated results whose `structuredContent.caplets` field
1135
1229
  identifies the Caplet with `id`, plus backend, operation, status, and elapsed time when
1136
1230
  available. Discovery result objects and compact tool entries also use `id` for the
1137
- configured Caplet identity. Compact `list_tools` and `search_tools` entries may include
1231
+ configured Caplet identity. Compact `tools` and `search_tools` entries may include
1138
1232
  input/output schema hashes; treat those
1139
1233
  hashes as reuse hints for a schema you have already inspected, not as a replacement for
1140
- `get_tool` when arguments, output, or semantics are unclear.
1234
+ `describe_tool` when arguments, output, or semantics are unclear.
1141
1235
 
1142
1236
  Direct `call_tool` preserves the downstream tool result shape instead of wrapping it in
1143
1237
  `structuredContent.result`. When the result can carry MCP metadata, Caplets adds
@@ -1147,8 +1241,9 @@ or other saved files. Artifact `displayPath` values are either absolute local pa
1147
1241
  relative to the downstream MCP server process, not necessarily relative to the current
1148
1242
  project or Caplets process.
1149
1243
 
1150
- For first use, the explicit progressive-discovery path is still safest: choose a Caplet,
1151
- `search_tools` or `list_tools`, inspect uncertain tools with `get_tool`, then `call_tool`.
1244
+ Code Mode is the default exposure because it keeps discovery, filtering, execution, and
1245
+ summary work inside one compact tool call. To expose the older progressive wrapper tools,
1246
+ set `options.exposure` to `progressive` or `progressive_and_code_mode`.
1152
1247
 
1153
1248
  ## Development
1154
1249