@cyanheads/mcp-ts-core 0.9.13 → 0.9.15

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 (79) hide show
  1. package/AGENTS.md +559 -0
  2. package/CLAUDE.md +8 -4
  3. package/README.md +33 -44
  4. package/changelog/0.9.x/0.9.14.md +31 -0
  5. package/changelog/0.9.x/0.9.15.md +52 -0
  6. package/changelog/template.md +1 -1
  7. package/dist/core/context.d.ts +119 -14
  8. package/dist/core/context.d.ts.map +1 -1
  9. package/dist/core/context.js +70 -1
  10. package/dist/core/context.js.map +1 -1
  11. package/dist/core/index.d.ts +1 -1
  12. package/dist/core/index.d.ts.map +1 -1
  13. package/dist/core/index.js.map +1 -1
  14. package/dist/linter/rules/enrichment-rules.d.ts +41 -0
  15. package/dist/linter/rules/enrichment-rules.d.ts.map +1 -0
  16. package/dist/linter/rules/enrichment-rules.js +204 -0
  17. package/dist/linter/rules/enrichment-rules.js.map +1 -0
  18. package/dist/linter/rules/index.d.ts +1 -0
  19. package/dist/linter/rules/index.d.ts.map +1 -1
  20. package/dist/linter/rules/index.js +1 -0
  21. package/dist/linter/rules/index.js.map +1 -1
  22. package/dist/linter/rules/schema-rules.d.ts +4 -0
  23. package/dist/linter/rules/schema-rules.d.ts.map +1 -1
  24. package/dist/linter/rules/schema-rules.js +2 -2
  25. package/dist/linter/rules/schema-rules.js.map +1 -1
  26. package/dist/linter/rules/tool-rules.d.ts.map +1 -1
  27. package/dist/linter/rules/tool-rules.js +4 -0
  28. package/dist/linter/rules/tool-rules.js.map +1 -1
  29. package/dist/mcp-server/tools/tool-registration.d.ts.map +1 -1
  30. package/dist/mcp-server/tools/tool-registration.js +7 -7
  31. package/dist/mcp-server/tools/tool-registration.js.map +1 -1
  32. package/dist/mcp-server/tools/utils/toolDefinition.d.ts +81 -7
  33. package/dist/mcp-server/tools/utils/toolDefinition.d.ts.map +1 -1
  34. package/dist/mcp-server/tools/utils/toolDefinition.js.map +1 -1
  35. package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts +23 -1
  36. package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts.map +1 -1
  37. package/dist/mcp-server/tools/utils/toolHandlerFactory.js +118 -9
  38. package/dist/mcp-server/tools/utils/toolHandlerFactory.js.map +1 -1
  39. package/dist/testing/index.d.ts +13 -0
  40. package/dist/testing/index.d.ts.map +1 -1
  41. package/dist/testing/index.js +21 -1
  42. package/dist/testing/index.js.map +1 -1
  43. package/dist/utils/internal/performance.d.ts +5 -1
  44. package/dist/utils/internal/performance.d.ts.map +1 -1
  45. package/dist/utils/internal/performance.js +10 -1
  46. package/dist/utils/internal/performance.js.map +1 -1
  47. package/dist/utils/telemetry/attributes.d.ts +2 -0
  48. package/dist/utils/telemetry/attributes.d.ts.map +1 -1
  49. package/dist/utils/telemetry/attributes.js +2 -0
  50. package/dist/utils/telemetry/attributes.js.map +1 -1
  51. package/package.json +5 -3
  52. package/scripts/build-changelog.ts +3 -1
  53. package/scripts/check-skills-sync.ts +42 -8
  54. package/skills/add-app-tool/SKILL.md +2 -2
  55. package/skills/add-export/SKILL.md +2 -2
  56. package/skills/add-service/SKILL.md +2 -2
  57. package/skills/add-tool/SKILL.md +85 -32
  58. package/skills/api-context/SKILL.md +68 -3
  59. package/skills/api-linter/SKILL.md +73 -2
  60. package/skills/design-mcp-server/SKILL.md +2 -1
  61. package/skills/git-wrapup/SKILL.md +22 -15
  62. package/skills/maintenance/SKILL.md +8 -7
  63. package/skills/orchestrations/SKILL.md +9 -5
  64. package/skills/orchestrations/workflows/maintenance-release.md +1 -1
  65. package/skills/polish-docs-meta/SKILL.md +1 -1
  66. package/skills/polish-docs-meta/references/agent-protocol.md +2 -2
  67. package/skills/polish-docs-meta/references/readme.md +3 -3
  68. package/skills/report-issue-framework/SKILL.md +8 -3
  69. package/skills/report-issue-local/SKILL.md +8 -3
  70. package/skills/setup/SKILL.md +5 -10
  71. package/templates/AGENTS.md +2 -1
  72. package/templates/CLAUDE.md +2 -1
  73. package/templates/_.mcpbignore +2 -0
  74. package/templates/changelog/template.md +1 -1
  75. package/templates/package.json +2 -1
  76. package/templates/src/mcp-server/tools/definitions/echo.tool.ts +10 -0
  77. package/dist/logs/combined.log +0 -4
  78. package/dist/logs/error.log +0 -2
  79. package/dist/logs/interactions.log +0 -0
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  <div align="center">
7
7
 
8
- [![Version](https://img.shields.io/badge/Version-0.9.13-blue.svg?style=flat-square)](./CHANGELOG.md) [![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg?style=flat-square)](./LICENSE) [![MCP Spec](https://img.shields.io/badge/MCP%20Spec-2025--11--25-8A2BE2.svg?style=flat-square)](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/docs/specification/2025-11-25/changelog.mdx)
8
+ [![Version](https://img.shields.io/badge/Version-0.9.15-blue.svg?style=flat-square)](./CHANGELOG.md) [![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg?style=flat-square)](./LICENSE) [![MCP Spec](https://img.shields.io/badge/MCP%20Spec-2025--11--25-8A2BE2.svg?style=flat-square)](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/docs/specification/2025-11-25/changelog.mdx)
9
9
 
10
10
  [![MCP SDK](https://img.shields.io/badge/MCP%20SDK-^1.29.0-green.svg?style=flat-square)](https://modelcontextprotocol.io/) [![TypeScript](https://img.shields.io/badge/TypeScript-^6.0.3-3178C6.svg?style=flat-square)](https://www.typescriptlang.org/) [![Bun](https://img.shields.io/badge/Bun-v1.3.0%2B-blueviolet.svg?style=flat-square)](https://bun.sh/)
11
11
 
@@ -25,33 +25,45 @@ The framework handles the plumbing: transports, auth, config, logging, telemetry
25
25
  import { createApp, tool, z } from '@cyanheads/mcp-ts-core';
26
26
  import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
27
27
 
28
- const greet = tool('greet', {
29
- description: 'Greet someone by name and return a personalized message.',
28
+ const search = tool('search', {
29
+ description: 'Search the catalog and return ranked matches.',
30
30
  annotations: { readOnlyHint: true },
31
31
  input: z.object({
32
- name: z.string().describe('Name of the person to greet'),
32
+ query: z.string().describe('Search terms'),
33
+ limit: z.number().default(10).describe('Max results'),
33
34
  }),
34
35
  output: z.object({
35
- message: z.string().describe('The greeting message'),
36
+ items: z.array(z.string()).describe('Matching item names, best first'),
36
37
  }),
38
+ enrichment: {
39
+ effectiveQuery: z.string().describe('Query as the server parsed it'),
40
+ totalCount: z.number().describe('Total matches before the limit'),
41
+ notice: z.string().optional().describe('Guidance when nothing matched'),
42
+ },
37
43
  errors: [
38
44
  {
39
- reason: 'name_blocked',
40
- code: JsonRpcErrorCode.Forbidden,
41
- when: 'The provided name is on the configured block list.',
42
- recovery: 'Use a different name that is not on the block list.',
45
+ reason: 'index_unavailable',
46
+ code: JsonRpcErrorCode.ServiceUnavailable,
47
+ when: 'The upstream search index is unreachable.',
48
+ retryable: true,
49
+ recovery: 'Retry in a few seconds — the index may be briefly unavailable.',
43
50
  },
44
51
  ],
45
52
  handler: async (input, ctx) => {
46
- if (isBlocked(input.name)) throw ctx.fail('name_blocked', `"${input.name}" is blocked`);
47
- return { message: `Hello, ${input.name}!` };
53
+ const res = await runSearch(input.query, input.limit);
54
+ if (!res) throw ctx.fail('index_unavailable'); // genuine failure → typed error contract
55
+ ctx.enrich({ effectiveQuery: res.parsed, totalCount: res.total });
56
+ if (res.items.length === 0) {
57
+ ctx.enrich({ notice: `No matches for "${input.query}". Try broader terms.` }); // empty result → notice, not a throw
58
+ }
59
+ return { items: res.items }; // enrichment never rides in the domain return
48
60
  },
49
61
  });
50
62
 
51
- await createApp({ tools: [greet] });
63
+ await createApp({ tools: [search] });
52
64
  ```
53
65
 
54
- That's a complete MCP server. Every tool call is automatically logged with duration, payload sizes, and request correlation — no instrumentation code needed. `createApp()` handles config parsing, logger init, transport startup, signal handlers, and graceful shutdown.
66
+ That's a complete MCP server, showing both flagship contracts. **`enrichment`** carries the context an agent reasons with — the parsed query, the true total, an empty-result notice — which the framework merges into `structuredContent` *and* mirrors into `content[]`, so `structuredContent`-only clients (Claude Code) and `content[]`-only clients (Claude Desktop) both see it, no `format()` needed. The typed **`errors[]`** contract handles genuine failures (an empty result is a `notice`, not a throw). The linter cross-checks both against the handler body, and both publish in `tools/list` so clients preview a tool's success *and* failure shapes. Every tool call is automatically logged with duration, payload sizes, and request correlation — no instrumentation code needed; `createApp()` handles config parsing, logger init, transport startup, signal handlers, and graceful shutdown.
55
67
 
56
68
  ## Quick start
57
69
 
@@ -61,18 +73,18 @@ cd my-mcp-server
61
73
  bun install
62
74
  ```
63
75
 
64
- You get a scaffolded project with `CLAUDE.md`, Agent Skills, plugin metadata (Codex + Claude Code), and a `src/` tree ready for your tools. Infrastructure — transports, auth, storage, telemetry, lifecycle, linting — lives in `node_modules`. What's left is domain: which APIs to wrap, which workflows to expose.
76
+ You get a scaffolded project with `CLAUDE.md`/`AGENTS.md`, Agent Skills, plugin metadata (Codex + Claude Code), and a `src/` tree ready for your tools. Infrastructure — transports, auth, storage, telemetry, lifecycle, linting — lives in `node_modules`. What's left is domain: which APIs to wrap, which workflows to expose.
65
77
 
66
78
  Start your coding agent (i.e. Claude Code, Codex) and describe what you want. The agent knows what to do from there. The included Agent Skills cover the full cycle: `setup`, `design-mcp-server`, scaffolding, testing, `security-pass`, `release-and-publish`, `maintenance`, & more.
67
79
 
68
80
  ### What you get
69
81
 
70
- Here's what tool definitions look like. Add `format()` to render structured output as markdown different MCP clients read different surfaces (`structuredContent` vs `content[]`), and `format()` ensures both carry the same data:
82
+ The headline tool returns structured output clients that read `structuredContent` (Claude Code) get it directly. To also render markdown for clients that read `content[]` (Claude Desktop), add a `format()`. The `format-parity` linter checks it renders every `output` field, so the two surfaces never drift:
71
83
 
72
84
  ```ts
73
85
  import { tool, z } from '@cyanheads/mcp-ts-core';
74
86
 
75
- export const search = tool('search', {
87
+ export const itemSearch = tool('item_search', {
76
88
  description: 'Search for items by query.',
77
89
  input: z.object({
78
90
  query: z.string().describe('Search query'),
@@ -85,6 +97,9 @@ export const search = tool('search', {
85
97
  const results = await doSearch(input.query, input.limit);
86
98
  return { items: results };
87
99
  },
100
+ format: (result) => [
101
+ { type: 'text', text: result.items.map((name) => `- ${name}`).join('\n') },
102
+ ],
88
103
  });
89
104
  ```
90
105
 
@@ -104,32 +119,6 @@ export const itemData = resource('items://{itemId}', {
104
119
  });
105
120
  ```
106
121
 
107
- And contracts for failure modes — typed at compile time, surfaced to clients with recovery hints the model can act on:
108
-
109
- ```ts
110
- import { tool, z } from '@cyanheads/mcp-ts-core';
111
- import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
112
-
113
- export const search = tool('search', {
114
- // ...input, output as above
115
- errors: [
116
- {
117
- reason: 'no_match',
118
- code: JsonRpcErrorCode.NotFound,
119
- when: 'The query returned zero items from the upstream index.',
120
- recovery: 'Broaden the query — close matches by edit distance are in `data.suggestions`.',
121
- },
122
- ],
123
- async handler(input, ctx) {
124
- const { items, suggestions } = await doSearch(input.query, input.limit);
125
- if (items.length === 0) throw ctx.fail('no_match', `No matches for "${input.query}"`, { suggestions });
126
- return { items };
127
- },
128
- });
129
- ```
130
-
131
- The linter cross-checks `errors[]` against the handler body, contracts publish in `tools/list` so clients can preview failure modes, and `data.recovery.hint` mirrors into the markdown `content[]` so tool-only clients see it too.
132
-
133
122
  Everything registers through `createApp()` in your entry point:
134
123
 
135
124
  ```ts
@@ -177,7 +166,7 @@ my-mcp-server/
177
166
  prompts/definitions/ # Prompt definitions (.prompt.ts)
178
167
  package.json
179
168
  tsconfig.json # extends @cyanheads/mcp-ts-core/tsconfig.base.json
180
- CLAUDE.md # Points to core's CLAUDE.md for framework docs
169
+ CLAUDE.md / AGENTS.md # Point to core's CLAUDE.md / AGENTS.md for framework docs
181
170
  ```
182
171
 
183
172
  No `src/utils/`, no `src/storage/`, no `src/types-global/`, no `src/mcp-server/transports/` — infrastructure lives in `node_modules`.
@@ -198,7 +187,7 @@ All core config is Zod-validated from environment variables. Server-specific con
198
187
  | `OTEL_ENABLED` | Enable OpenTelemetry | `false` |
199
188
  | `OPENROUTER_API_KEY` | OpenRouter LLM API key | — |
200
189
 
201
- See [CLAUDE.md](CLAUDE.md) for the full configuration reference.
190
+ See [CLAUDE.md/AGENTS.md](CLAUDE.md) for the full configuration reference.
202
191
 
203
192
  ## API overview
204
193
 
@@ -0,0 +1,31 @@
1
+ ---
2
+ summary: "The enrichment block on tool(): a typed, success-path contract for agent-facing context — empty-result notices, query echo, pagination totals — populated via ctx.enrich() and surfaced to both structuredContent and content[] without a format() entry. The success-path counterpart to errors[]."
3
+ breaking: false
4
+ agent-notes: |
5
+ Skills updated this release (Phase A picks these up): add-tool 2.9 → 2.10, design-mcp-server 2.12 → 2.13, api-context 1.3 → 1.4, api-linter 1.3 → 1.4.
6
+ New optional builder field `enrichment` + `ctx.enrich(...)` API — adopt it to move agent-facing context (empty-result notices, query/filter echo, pagination totals) out of `format()`-only authoring (invisible to structuredContent-only clients) into a typed block that reaches both surfaces. No migration required; existing tools are unaffected.
7
+ New testing helper `getEnrichment(ctx)` from `@cyanheads/mcp-ts-core/testing` reads what a handler accumulated via `ctx.enrich`.
8
+ New advisory lint `enrichment-prefer-block` may flag existing `output` fields named `notice` / `effectiveQuery` / `queryEcho` — a warning suggesting they move to `enrichment`. Ignore if the field is genuinely domain data.
9
+ ---
10
+
11
+ # 0.9.14 — 2026-05-29
12
+
13
+ ## Added
14
+
15
+ - **`enrichment` block on `tool()`** — the success-path counterpart to `errors[]`. Declare `enrichment: { <name>: <ZodType> }` and populate it via `ctx.enrich(...)` (or the kind-tagged helpers `ctx.enrich.notice()` / `.total()` / `.echo()`) from the handler or service layer. The framework merges enrichment into `structuredContent`, advertises `output.extend(enrichment)` as the tool's `outputSchema` in `tools/list`, and mirrors it into a `content[]` trailer — so agent-facing context (empty-result notices, the query/filter as the server parsed it, pagination totals) reaches both `structuredContent`-only and `content[]`-only clients without a `format()` entry. Enrichment never rides in the domain return; a required enrichment field the handler never populates fails the effective-output parse, surfacing the bug. Applies to standard and auto-task (`task: true`) tools; the `TaskToolDefinition` escape hatch is unchanged. ([#173](https://github.com/cyanheads/mcp-ts-core/issues/173))
16
+ - **`ctx.enrich`** on `Context` — always present and callable from the service layer (like `ctx.log`/`ctx.state`); strictly typed on `HandlerContext<R, E>` to a `Partial` of the declared enrichment fields when a block is present.
17
+ - **`getEnrichment(ctx)`** test helper (`@cyanheads/mcp-ts-core/testing`) — reads the enrichment a handler accumulated on a mock context, for assertions.
18
+ - **`mcp.tool.enriched`** span attribute — set when a tool populates enrichment on a call, alongside the existing `mcp.tool.partial_success`.
19
+ - **Enrichment lint rules** — `enrichment-output-collision` and `enrichment-field-type` / `enrichment-type` (errors guarding the block's shape and its disjointness from `output`, which `output.extend` would otherwise silently override), `enrichment-empty` (warning), and the advisory `enrichment-prefer-block` (nudges meta-looking `output` fields toward enrichment).
20
+ - **`Enrich`, `EnrichHelpers`, `TypedEnrich`** exported from the main entry for typing against `ctx.enrich`.
21
+
22
+ ## Changed
23
+
24
+ - **`ToolDefinition` / `tool()`** gain a 4th type parameter `TEnrich` (defaulted to `undefined`); **`HandlerContext<R, E>`** gains the enrichment dimension `E` (defaulted). Both additive — existing `HandlerContext<R>` and three-argument `ToolDefinition` usages are unchanged.
25
+ - **`ToolDefinition.format`** is now declared as a method (bivariant parameters) rather than an arrow property, so concrete tools stay assignable to the type-erased `AnyToolDefinition` once the enrichment type dimension is in play. Internal — no call-site change; `format: (result) => [...]` is unaffected.
26
+ - **Skills** — `add-tool` 2.9 → 2.10, `design-mcp-server` 2.12 → 2.13, `api-context` 1.3 → 1.4, `api-linter` 1.3 → 1.4: document the `enrichment` block / `ctx.enrich`, add the named "agent-facing context belongs in `enrichment`" rule, and revise the empty-results and operational-metadata examples to use enrichment as the primary home.
27
+
28
+ ## Docs
29
+
30
+ - **README** — the headline example replaces `greet` with a complete `search` showing the `enrichment` block and the typed error contract side by side (an empty result is a `notice`, not a throw); "What you get" pivots to `format()` and the redundant lower error-contract example folds into the headline.
31
+ - **Init scaffold** — the echo starter tool gains an `enrichment` block so freshly scaffolded servers mirror the README.
@@ -0,0 +1,52 @@
1
+ ---
2
+ summary: "enrichmentTrailer per-field rendering, ctx.enrich.delta, three new enrichment lint rules, skill-sync prune for upstream-deleted skills, AGENTS.md shipped in npm package, safe format script"
3
+ breaking: false
4
+ security: false
5
+ agent-notes: |
6
+ Skills synced in this release (version bumps — propagate to project skills/ and mirrors):
7
+ - add-app-tool: 1.3 → 1.4
8
+ - add-export: 1.0 → 1.1
9
+ - add-service: 1.5 → 1.6
10
+ - add-tool: 2.10 → 2.11 (enrichment trailer guidance + ctx.enrich.delta mutator pattern)
11
+ - api-context: 1.4 → 1.5 (ctx.enrich.delta added; trailer rendering note)
12
+ - api-linter: 1.4 → 1.5 (enrichment-trailer-render, enrichment-trailer-orphan, enrichment-trailer-unknown-field rule entries)
13
+ - design-mcp-server: 2.13 → 2.14 (enrichmentTrailer per-tool note)
14
+ - git-wrapup: 1.1 → 1.2 (commit-structure rewrite: group by concern, release commit on top)
15
+ - maintenance: 2.4 → 2.5 (prune framework skills deleted upstream)
16
+ - orchestrations/workflows/maintenance-release.md updated (commit structure aligned with git-wrapup)
17
+ - polish-docs-meta: 2.4 → 2.5
18
+ - setup: 1.7 → 1.8 (keep-both guidance replaces delete-one)
19
+
20
+ The format script is now safe-by-default (biome --write, no --unsafe). Scaffolded servers should update their format script too (templates/package.json already updated — adoption on next maintenance pass).
21
+ ---
22
+
23
+ # 0.9.15 — 2026-05-29
24
+
25
+ ## Added
26
+
27
+ - **`enrichmentTrailer`** per-field `content[]` rendering config on `ToolDefinition`. Each declared enrichment field can supply a `render` (maps the validated value to markdown — stops structured fields from JSON-blobbing in the trailer) and/or a `label` (overrides the field-name shown in generic/delta rendering). `structuredContent` always keeps the full structured value, unaffected by trailer config. Resolves to `never` when no `enrichment` block is declared. ([#175](https://github.com/cyanheads/mcp-ts-core/issues/175))
28
+ - **`ctx.enrich.delta({ field, before, after })`** kind-tag helper for raw mutation before/after state. Writes `{ before, after }` to `structuredContent` and renders `**field:** before → after` in the `content[]` trailer. Declare the field in `enrichment` as `z.object({ before, after })` — the linter recognizes the delta shape and exempts it from the `enrichment-trailer-render` requirement. ([#176](https://github.com/cyanheads/mcp-ts-core/issues/176))
29
+ - **`enrichment-trailer-render`** lint rule (error): fires when a non-scalar (object/array) enrichment field has no `enrichmentTrailer.render`. The delta shape (`z.object({ before, after })`) is exempt. ([#175](https://github.com/cyanheads/mcp-ts-core/issues/175))
30
+ - **`enrichment-trailer-orphan`** lint rule (error): fires when `enrichmentTrailer` is declared without an `enrichment` block. ([#175](https://github.com/cyanheads/mcp-ts-core/issues/175))
31
+ - **`enrichment-trailer-unknown-field`** lint rule (error): fires when an `enrichmentTrailer` key doesn't match any declared enrichment field. ([#175](https://github.com/cyanheads/mcp-ts-core/issues/175))
32
+ - **`format:unsafe` script** added to root and `templates/package.json` — `biome check --write --unsafe .`. Unsafe autofixes now require a deliberate, reviewed step rather than running with the default `format`. ([#166](https://github.com/cyanheads/mcp-ts-core/issues/166))
33
+ - **`scripts/check-skills-sync.ts`** stale-framework-skill detection: a skill dir present only in a mirror that carries `metadata.audience: external` is flagged as stale (a framework skill removed upstream but never pruned from the mirror). User-authored skills (no marker) are left alone. ([#170](https://github.com/cyanheads/mcp-ts-core/issues/170))
34
+ - **`templates/_.mcpbignore`** now anchors `/skills/` and `/.agents/` — dev skills no longer surface in MCPB bundles published to the Claude Directory. ([#172](https://github.com/cyanheads/mcp-ts-core/issues/172))
35
+
36
+ ## Changed
37
+
38
+ - **`format` script** changed from `biome check --write --unsafe .` to `biome check --write .` in root and `templates/package.json` — safe autofixes only by default, preventing silent behavior changes from unsafe rules like `noUselessConstructor`. ([#166](https://github.com/cyanheads/mcp-ts-core/issues/166))
39
+ - **`package.json` `files[]`** now ships `AGENTS.md` alongside `CLAUDE.md` — previously only `CLAUDE.md` was included in the published package. Every agent reading `node_modules/@cyanheads/mcp-ts-core/AGENTS.md` now resolves correctly. ([#171](https://github.com/cyanheads/mcp-ts-core/issues/171))
40
+ - **`skills/maintenance`** v2.5: Phase A skill-sync step now prunes framework skills deleted upstream — a skill carrying `metadata.audience: external` absent from the package is deleted from `skills/` and agent mirrors. User skills (no marker) are never touched. Phase B mirror sync updated accordingly. ([#170](https://github.com/cyanheads/mcp-ts-core/issues/170))
41
+ - **`skills/setup`** v1.8: keep-both guidance replaces delete-one. Both `CLAUDE.md` and `AGENTS.md` are now recommended to be kept; the delete-one instruction removed. ([#171](https://github.com/cyanheads/mcp-ts-core/issues/171))
42
+ - **`skills/git-wrapup`** v1.2: Step 7 rewritten — commit-structure model changed from "one atomic commit" to "group by concern, release artifacts on top." Work commits are per-concern, release commit (version bumps + changelog + tree) lands last. File is the atomic boundary. ([approved pre-existing edit])
43
+ - **`skills/orchestrations/workflows/maintenance-release.md`**: commit-structure section updated to align with `git-wrapup` v1.2. ([approved pre-existing edit])
44
+ - **`skills/add-tool`** v2.11, **`skills/api-context`** v1.5, **`skills/api-linter`** v1.5, **`skills/design-mcp-server`** v2.14: enrichment trailer rendering guidance added; `enrichment-trailer-*` rules documented. ([#175](https://github.com/cyanheads/mcp-ts-core/issues/175), [#176](https://github.com/cyanheads/mcp-ts-core/issues/176))
45
+ - **`skills/add-app-tool`** v1.4, **`skills/add-export`** v1.1, **`skills/add-service`** v1.6, **`skills/polish-docs-meta`** v2.5: `CLAUDE.md` references paired with `AGENTS.md` throughout. ([#171](https://github.com/cyanheads/mcp-ts-core/issues/171))
46
+ - **`changelog/template.md`** and **`templates/changelog/template.md`**: `AGENTS.md` reference paired with `CLAUDE.md`. ([#171](https://github.com/cyanheads/mcp-ts-core/issues/171))
47
+ - **`README.md`**: scaffold description updated to name both `CLAUDE.md`/`AGENTS.md`. ([#171](https://github.com/cyanheads/mcp-ts-core/issues/171))
48
+ - **`@cloudflare/workers-types`** `^4.20260529.1 → ^4.20260530.1`
49
+
50
+ ## Fixed
51
+
52
+ - **`renderEnrichmentTrailer`** now skips keys stripped by the effective-output parse (enriched but not declared in the block), preventing ghost trailer lines. ([#175](https://github.com/cyanheads/mcp-ts-core/issues/175))
@@ -43,7 +43,7 @@ security: false
43
43
  name the symbol, state what changed, stop. Use a second sentence only when
44
44
  it carries weight. If a bullet feels long, it is.
45
45
 
46
- Cut: mechanism walkthroughs (those belong in JSDoc, AGENTS.md, or the
46
+ Cut: mechanism walkthroughs (those belong in JSDoc, CLAUDE.md/AGENTS.md, or the
47
47
  relevant skill), ceremonial framings ("This release introduces…",
48
48
  backwards-compat paragraphs), file-by-file test enumerations, internal
49
49
  implementation notes. Prefer code/symbol names over English re-explanations.
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import type { RequestTaskStore } from '@modelcontextprotocol/sdk/shared/protocol.js';
9
9
  import type { CreateMessageResult, ElicitResult, ModelPreferences, SamplingMessage } from '@modelcontextprotocol/sdk/types.js';
10
- import type { ZodType, z } from 'zod';
10
+ import type { ZodObject, ZodRawShape, ZodType, z } from 'zod';
11
11
  import type { StorageService } from '../storage/core/StorageService.js';
12
12
  import { type ErrorContract, McpError } from '../types-global/errors.js';
13
13
  import type { Logger } from '../utils/internal/logger.js';
@@ -88,6 +88,18 @@ export interface Context {
88
88
  readonly auth?: AuthContext | undefined;
89
89
  /** Ask the human user a question. Present when client supports elicitation. */
90
90
  readonly elicit?: ((message: string, schema: z.ZodObject<z.ZodRawShape>) => Promise<ElicitResult>) | undefined;
91
+ /**
92
+ * Accumulates agent-facing enrichment fields onto this request — empty-result
93
+ * notices, query/filter echo, pagination totals. Values reach `structuredContent`
94
+ * (merged into the validated output) and `content[]` (a trailer), exactly as the
95
+ * error path surfaces `recovery.hint` across both surfaces. Always present and
96
+ * callable from the handler and the service layer (mirrors `ctx.log`/`ctx.state`);
97
+ * when the tool declares no `enrichment` block the merge is a no-op (values are
98
+ * stripped by the effective-output parse). The strict, typed variant — keyed to
99
+ * the declared fields — lives on `HandlerContext<R, E>`. Field-helpers
100
+ * (`enrich.notice` / `enrich.total` / `enrich.echo`) kind-tag the content[] trailer.
101
+ */
102
+ readonly enrich: Enrich;
91
103
  /** Logger scoped to this request. Auto-includes requestId, traceId, tenantId. */
92
104
  readonly log: ContextLogger;
93
105
  /** Notify clients that the prompt list has changed (prompts added/removed). */
@@ -212,24 +224,99 @@ export type TypedRecoveryFor<R extends string> = (reason: R) => {
212
224
  };
213
225
  };
214
226
  /**
215
- * Handler context. When a definition declares `errors[]`, the handler receives
216
- * `Context & { fail: TypedFail<R>; recoveryFor: TypedRecoveryFor<R> }` where
217
- * `R` is the declared reason union. When no contract is declared, the handler
218
- * receives plain `Context` (its loose `recoveryFor` is still callable but
219
- * always returns `{}`) and must throw `McpError` directly.
227
+ * Render kind recorded by an `enrich` field-helper, used only to format the
228
+ * `content[]` trailer at hand-written quality:
229
+ * - `notice` markdown blockquote
230
+ * - `total` "N total"
231
+ * - `echo` "Query: …"
232
+ * - `delta` → "field: before → after" (raw mutation before/after state)
233
+ * Fields populated via the bare `enrich({...})` call carry no kind and render
234
+ * generically (`**key:** value`), optionally customized per-field by the
235
+ * definition's `enrichmentTrailer` (`render`/`label`).
236
+ */
237
+ export type EnrichKind = 'notice' | 'total' | 'echo' | 'delta';
238
+ /**
239
+ * Per-request enrichment accumulator. Created in `createContext`, populated by
240
+ * `ctx.enrich(...)` during handler/service execution, and read by the tool
241
+ * handler factory after the handler returns to merge into `structuredContent`
242
+ * and render the `content[]` trailer.
220
243
  *
221
- * The conditional `[R] extends [never]` distinguishes "no contract declared"
222
- * (R = never) from "contract declared with reasons" (R = literal union).
244
+ * @internal
245
+ */
246
+ export interface EnrichmentStore {
247
+ /** Per-key render kind set by the field-helpers. Absent keys render generically. */
248
+ kinds: Map<string, EnrichKind>;
249
+ /** Accumulated field values, insertion-ordered. Merged into the effective output. */
250
+ values: Record<string, unknown>;
251
+ }
252
+ /**
253
+ * Convenience field-helpers hanging off `ctx.enrich`. Each writes a
254
+ * conventionally-named field and tags its trailer rendering; use the bare
255
+ * `enrich({...})` call for any other field names.
256
+ */
257
+ export interface EnrichHelpers {
258
+ /**
259
+ * Raw before/after observable state for a mutation. Writes `{ before, after }`
260
+ * under `field` (→ `structuredContent`) and renders as "field: before → after"
261
+ * in the `content[]` trailer. Surface raw state and let the agent judge the
262
+ * change against intent — never synthesize a verdict (a shrink may be intended
263
+ * truncation or a bug; only the agent knows). Declare `field` in the
264
+ * `enrichment` block as `z.object({ before, after })` — the linter recognizes
265
+ * the shape, so it needs no custom trailer renderer.
266
+ */
267
+ delta(args: {
268
+ field: string;
269
+ before: unknown;
270
+ after: unknown;
271
+ }): void;
272
+ /** The query as the server actually parsed it. Writes `effectiveQuery`; renders as "Query: …". */
273
+ echo(query: string): void;
274
+ /** Guidance when a result set is empty (or otherwise needs a caveat). Writes `notice`; renders as a blockquote. */
275
+ notice(text: string): void;
276
+ /** Total matches before a limit/pagination was applied. Writes `totalCount`; renders as "N total". */
277
+ total(count: number): void;
278
+ }
279
+ /**
280
+ * The `ctx.enrich` callable: merge a partial of the declared enrichment fields
281
+ * onto the request (accumulating across calls), plus the kind-tagging
282
+ * {@link EnrichHelpers}. The loose form (`T = Record<string, unknown>`) sits on
283
+ * the base {@link Context} so service-layer code can call it without the tool's
284
+ * type; the strict {@link TypedEnrich} form is attached to `HandlerContext<R, E>`.
285
+ */
286
+ export type Enrich<T = Record<string, unknown>> = ((fields: T) => void) & EnrichHelpers;
287
+ /**
288
+ * Strict, typed `enrich` attached to `HandlerContext<R, E>` when a tool declares
289
+ * an `enrichment` block. `E` is the declared `ZodRawShape`; `enrich` accepts a
290
+ * `Partial` of the inferred fields so it can be called incrementally — the
291
+ * effective-output parse enforces that required fields end up populated.
292
+ */
293
+ export type TypedEnrich<E extends ZodRawShape> = Enrich<Partial<z.infer<ZodObject<E>>>>;
294
+ /**
295
+ * Handler context. Two independent contract dimensions narrow the base
296
+ * {@link Context}:
297
+ * - **Errors.** When `errors[]` is declared, `R` is the reason union and the
298
+ * handler gains `fail: TypedFail<R>` plus a strict `recoveryFor`. Without a
299
+ * contract (`R = never`), `recoveryFor` stays the loose always-`{}` resolver
300
+ * and the handler throws `McpError` directly.
301
+ * - **Enrichment.** When an `enrichment` block is declared, `E` is its
302
+ * `ZodRawShape` and `enrich` is typed to a `Partial` of the inferred fields.
303
+ * Without one (`E = undefined`), `enrich` stays the loose base form.
223
304
  *
224
- * The contract branch uses `Omit<Context, 'recoveryFor'>` because intersecting
225
- * the loose `Context.recoveryFor(string)` with the strict `TypedRecoveryFor<R>`
226
- * would create an overload that widens `parameter(0)` back to `string` — losing
227
- * the typo-catching benefit. Omit-and-replace narrows cleanly.
305
+ * Both dimensions use `Omit`-and-replace rather than intersection: intersecting
306
+ * the loose `Context.recoveryFor(string)` / `enrich(Record)` with their strict
307
+ * variants would create overloads that widen the parameters back, losing the
308
+ * typo-catching and field-typing benefits. Omit-and-replace narrows cleanly.
228
309
  */
229
- export type HandlerContext<R extends string = never> = [R] extends [never] ? Context : Omit<Context, 'recoveryFor'> & {
310
+ export type HandlerContext<R extends string = never, E extends ZodRawShape | undefined = undefined> = Omit<Context, 'recoveryFor' | 'enrich'> & ([R] extends [never] ? {
311
+ recoveryFor: Context['recoveryFor'];
312
+ } : {
230
313
  fail: TypedFail<R>;
231
314
  recoveryFor: TypedRecoveryFor<R>;
232
- };
315
+ }) & (E extends ZodRawShape ? {
316
+ enrich: TypedEnrich<E>;
317
+ } : {
318
+ enrich: Context['enrich'];
319
+ });
233
320
  /**
234
321
  * @internal
235
322
  *
@@ -272,6 +359,24 @@ export declare function createRecoveryFor(errors: readonly ErrorContract[]): (re
272
359
  * @internal
273
360
  */
274
361
  export declare function attachTypedFail(ctx: Context, errors: readonly ErrorContract[] | undefined): Context;
362
+ /** Fresh, empty enrichment accumulator. @internal */
363
+ export declare function createEnrichmentStore(): EnrichmentStore;
364
+ /**
365
+ * Builds the always-present `ctx.enrich` callable bound to a store. The bare
366
+ * call merges arbitrary fields; the field-helpers write conventional keys and
367
+ * tag their trailer render kind.
368
+ * @internal
369
+ */
370
+ export declare function createEnrich(store: EnrichmentStore): Enrich;
371
+ /** Stashes the store on a Context under the private symbol (non-enumerable). @internal */
372
+ export declare function stashEnrichmentStore(ctx: Context, store: EnrichmentStore): void;
373
+ /**
374
+ * Reads the enrichment store wired by `createContext` (or a test mock). Returns
375
+ * `undefined` when none was stashed — defensive, though every factory-built
376
+ * Context has one.
377
+ * @internal
378
+ */
379
+ export declare function readEnrichmentStore(ctx: Context): EnrichmentStore | undefined;
275
380
  /** @internal */
276
381
  export interface ContextDeps {
277
382
  appContext: RequestContext;
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/core/context.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AACrF,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,eAAe,EAChB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAEtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EACL,KAAK,aAAa,EAGlB,QAAQ,EACT,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGtF,YAAY,EAAE,WAAW,EAAE,CAAC;AAM5B;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACzD,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,EAA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AAM,WAAW,WAAW;IAC1B,UAAU,EAAE,cAAc,CAAC;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,uBAAuB,CAAC,EAAE,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAC7D,yBAAyB,CAAC,EAAE,OAAO,CAAC,2BAA2B,CAAC,CAAC;IACjE,qBAAqB,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACzD,qBAAqB,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACzD,MAAM,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3B;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,MAAM,EAAE,WAAW,CAAC;IACpB,OAAO,EAAE,cAAc,CAAC;IACxB,OAAO,CAAC,EAAE;QAAE,KAAK,EAAE,gBAAgB,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;IAClE,GAAG,CAAC,EAAE,GAAG,GAAG,SAAS,CAAC;CACvB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CA4DxD"}
@@ -78,6 +78,66 @@ export function attachTypedFail(ctx, errors) {
78
78
  recoveryFor: createRecoveryFor(errors),
79
79
  });
80
80
  }
81
+ // ---------------------------------------------------------------------------
82
+ // Enrichment runtime — accumulator wiring (internal)
83
+ // ---------------------------------------------------------------------------
84
+ /**
85
+ * Symbol stashing the per-request {@link EnrichmentStore} on a Context. A symbol
86
+ * key keeps it invisible to `JSON.stringify`, `Object.keys`, and consumers — the
87
+ * store is framework plumbing the handler factory reads, never wire data.
88
+ * @internal
89
+ */
90
+ const ENRICHMENT_STORE = Symbol('mcp.enrichmentStore');
91
+ /** Fresh, empty enrichment accumulator. @internal */
92
+ export function createEnrichmentStore() {
93
+ return { values: {}, kinds: new Map() };
94
+ }
95
+ /**
96
+ * Builds the always-present `ctx.enrich` callable bound to a store. The bare
97
+ * call merges arbitrary fields; the field-helpers write conventional keys and
98
+ * tag their trailer render kind.
99
+ * @internal
100
+ */
101
+ export function createEnrich(store) {
102
+ const enrich = ((fields) => {
103
+ Object.assign(store.values, fields);
104
+ });
105
+ enrich.notice = (text) => {
106
+ store.values.notice = text;
107
+ store.kinds.set('notice', 'notice');
108
+ };
109
+ enrich.total = (count) => {
110
+ store.values.totalCount = count;
111
+ store.kinds.set('totalCount', 'total');
112
+ };
113
+ enrich.echo = (query) => {
114
+ store.values.effectiveQuery = query;
115
+ store.kinds.set('effectiveQuery', 'echo');
116
+ };
117
+ enrich.delta = ({ field, before, after }) => {
118
+ store.values[field] = { before, after };
119
+ store.kinds.set(field, 'delta');
120
+ };
121
+ return enrich;
122
+ }
123
+ /** Stashes the store on a Context under the private symbol (non-enumerable). @internal */
124
+ export function stashEnrichmentStore(ctx, store) {
125
+ Object.defineProperty(ctx, ENRICHMENT_STORE, {
126
+ value: store,
127
+ enumerable: false,
128
+ writable: false,
129
+ configurable: false,
130
+ });
131
+ }
132
+ /**
133
+ * Reads the enrichment store wired by `createContext` (or a test mock). Returns
134
+ * `undefined` when none was stashed — defensive, though every factory-built
135
+ * Context has one.
136
+ * @internal
137
+ */
138
+ export function readEnrichmentStore(ctx) {
139
+ return ctx[ENRICHMENT_STORE];
140
+ }
81
141
  /**
82
142
  * Constructs a Context from internal dependencies.
83
143
  * Called by handler factories — not exposed to consumers.
@@ -103,7 +163,13 @@ export function createContext(deps) {
103
163
  const progress = deps.taskCtx
104
164
  ? createContextProgress(deps.taskCtx.store, deps.taskCtx.taskId)
105
165
  : undefined;
106
- return {
166
+ // Per-request enrichment accumulator + always-present `enrich` (mirrors
167
+ // ctx.log/ctx.state — created here, callable from handler and service layer).
168
+ // Stashed on ctx under a private symbol for the handler factory to read after
169
+ // the handler returns; tools with no `enrichment` block accumulate harmlessly
170
+ // (values are stripped by the effective-output parse).
171
+ const enrichmentStore = createEnrichmentStore();
172
+ const ctx = {
107
173
  requestId: effectiveContext.requestId,
108
174
  timestamp: effectiveContext.timestamp,
109
175
  log,
@@ -122,6 +188,7 @@ export function createContext(deps) {
122
188
  notifyToolListChanged: deps.notifyToolListChanged,
123
189
  progress,
124
190
  uri: deps.uri,
191
+ enrich: createEnrich(enrichmentStore),
125
192
  // No-op resolver for definitions without a contract. `attachTypedFail`
126
193
  // overwrites with a contract-aware resolver when `errors[]` is declared.
127
194
  // Always-present so service code can spread `...ctx.recoveryFor('x')`
@@ -129,6 +196,8 @@ export function createContext(deps) {
129
196
  // declared a contract.
130
197
  recoveryFor: () => ({}),
131
198
  };
199
+ stashEnrichmentStore(ctx, enrichmentStore);
200
+ return ctx;
132
201
  }
133
202
  // ---------------------------------------------------------------------------
134
203
  // ContextLogger implementation
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/core/context.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAYH,OAAO,EAEL,cAAc,EACd,gBAAgB,EAChB,QAAQ,GACT,MAAM,0BAA0B,CAAC;AAkQlC;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,UAAU,CAAC,MAAgC;IACzD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAyB,CAAC;IAClD,KAAK,MAAM,KAAK,IAAI,MAAM;QAAE,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAE9D,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;QACxC,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACnC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,oEAAoE;YACpE,wEAAwE;YACxE,+DAA+D;YAC/D,OAAO,IAAI,QAAQ,CACjB,gBAAgB,CAAC,aAAa,EAC9B,0CAA0C,MAAM,+BAA+B,E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,CAAC,GAAG,UAAU,YAAY,CAAC,CAAC,CAAC,SAAS,CACjE,CAAC;QACJ,CAAC;QACD,KAAK,CAAC,MAAM,CAAC,OAAO;YAClB,MAAM,KAAK,CAAC,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QAC3D,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -9,7 +9,7 @@ export type { ContextOptions, CoreServices, CreateAppOptions, ServerHandle, } fr
9
9
  export { createApp } from '../core/app.js';
10
10
  export type { LandingConfig, LandingLink } from '../core/serverManifest.js';
11
11
  export { z } from 'zod';
12
- export type { AuthContext, Context, ContextLogger, ContextProgress, ContextState, HandlerContext, ReasonOf, SamplingOpts, TypedFail, TypedRecoveryFor, } from '../core/context.js';
12
+ export type { AuthContext, Context, ContextLogger, ContextProgress, ContextState, Enrich, EnrichHelpers, HandlerContext, ReasonOf, SamplingOpts, TypedEnrich, TypedFail, TypedRecoveryFor, } from '../core/context.js';
13
13
  export { createFail, createRecoveryFor } from '../core/context.js';
14
14
  export { APP_RESOURCE_MIME_TYPE, appResource, appTool } from '../mcp-server/apps/appBuilders.js';
15
15
  export type { AnyPromptDefinition, PromptDefinition, } from '../mcp-server/prompts/utils/promptDefinition.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,YAAY,EACV,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,YAAY,GACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAM1C,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAM3E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,YAAY,EACV,WAAW,EACX,OAAO,EACP,aAAa,EACb,eAAe,EACf,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,SAAS,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