@contractkit/plugin-typescript 0.34.0 → 0.34.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.
- package/.turbo/turbo-build$colon$ci.log +4 -4
- package/.turbo/turbo-test$colon$ci.log +15 -15
- package/CHANGELOG.md +18 -0
- package/dist/codegen-mcp.d.ts.map +1 -1
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/llms.txt +14 -0
- package/package.json +1 -1
- package/src/codegen-mcp.ts +15 -4
- package/tests/codegen-mcp.test.ts +23 -1
|
@@ -5,9 +5,9 @@ $ tsup src/index.ts --format esm --sourcemap --dts && tsc --emitDeclarationOnly
|
|
|
5
5
|
[34mCLI[39m tsup v8.5.1
|
|
6
6
|
[34mCLI[39m Target: esnext
|
|
7
7
|
[34mESM[39m Build start
|
|
8
|
-
[32mESM[39m [1mdist/index.js [22m[
|
|
9
|
-
[32mESM[39m [1mdist/index.js.map [22m[32m514.
|
|
10
|
-
[32mESM[39m ⚡️ Build success in
|
|
8
|
+
[32mESM[39m [1mdist/index.js [22m[32m221.06 KB[39m
|
|
9
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m514.96 KB[39m
|
|
10
|
+
[32mESM[39m ⚡️ Build success in 514ms
|
|
11
11
|
[34mDTS[39m Build start
|
|
12
|
-
[32mDTS[39m ⚡️ Build success in
|
|
12
|
+
[32mDTS[39m ⚡️ Build success in 5728ms
|
|
13
13
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m5.14 KB[39m
|
|
@@ -3,29 +3,29 @@ $ vitest run --coverage
|
|
|
3
3
|
[1m[30m[46m RUN [49m[39m[22m [36mv4.1.5 [39m[90m/home/runner/work/ContractKit/ContractKit/packages/plugin-typescript[39m
|
|
4
4
|
[2mCoverage enabled with [22m[33mv8[39m
|
|
5
5
|
|
|
6
|
-
[32m✓[39m tests/codegen-
|
|
7
|
-
[32m✓[39m tests/codegen-
|
|
8
|
-
[32m✓[39m tests/codegen-
|
|
9
|
-
[32m✓[39m tests/
|
|
10
|
-
[32m✓[39m tests/codegen-server.test.ts [2m([22m[2m33 tests[22m[2m)[22m[32m
|
|
11
|
-
[32m✓[39m tests/
|
|
12
|
-
[32m✓[39m tests/ts-render.test.ts [2m([22m[2m5 tests[22m[2m)[22m[32m
|
|
13
|
-
[32m✓[39m tests/codegen-mcp.test.ts [2m([22m[
|
|
14
|
-
[32m✓[39m tests/escaping-security.test.ts [2m([22m[2m18 tests[22m[2m)[22m[32m
|
|
6
|
+
[32m✓[39m tests/codegen-contract.test.ts [2m([22m[2m147 tests[22m[2m)[22m[32m 222[2mms[22m[39m
|
|
7
|
+
[32m✓[39m tests/codegen-operation.test.ts [2m([22m[2m159 tests[22m[2m)[22m[32m 241[2mms[22m[39m
|
|
8
|
+
[32m✓[39m tests/codegen-sdk.test.ts [2m([22m[2m173 tests[22m[2m)[22m[33m 405[2mms[22m[39m
|
|
9
|
+
[32m✓[39m tests/codegen-plain-types.test.ts [2m([22m[2m67 tests[22m[2m)[22m[32m 63[2mms[22m[39m
|
|
10
|
+
[32m✓[39m tests/codegen-server.test.ts [2m([22m[2m33 tests[22m[2m)[22m[32m 149[2mms[22m[39m
|
|
11
|
+
[32m✓[39m tests/pipeline.test.ts [2m([22m[2m34 tests[22m[2m)[22m[33m 413[2mms[22m[39m
|
|
12
|
+
[32m✓[39m tests/ts-render.test.ts [2m([22m[2m5 tests[22m[2m)[22m[32m 8[2mms[22m[39m
|
|
13
|
+
[32m✓[39m tests/codegen-mcp.test.ts [2m([22m[2m31 tests[22m[2m)[22m[32m 49[2mms[22m[39m
|
|
14
|
+
[32m✓[39m tests/escaping-security.test.ts [2m([22m[2m18 tests[22m[2m)[22m[32m 30[2mms[22m[39m
|
|
15
15
|
|
|
16
16
|
[2m Test Files [22m [1m[32m9 passed[39m[22m[90m (9)[39m
|
|
17
|
-
[2m Tests [22m [1m[
|
|
18
|
-
[2m Start at [22m
|
|
19
|
-
[2m Duration [22m
|
|
17
|
+
[2m Tests [22m [1m[32m667 passed[39m[22m[90m (667)[39m
|
|
18
|
+
[2m Start at [22m 17:41:52
|
|
19
|
+
[2m Duration [22m 10.27s[2m (transform 6.12s, setup 0ms, import 20.30s, tests 1.58s, environment 24ms)[22m
|
|
20
20
|
|
|
21
21
|
[34m % [39m[2mCoverage report from [22m[33mv8[39m
|
|
22
22
|
-------------------|---------|----------|---------|---------|-------------------
|
|
23
23
|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
|
|
24
24
|
-------------------|---------|----------|---------|---------|-------------------
|
|
25
|
-
All files | 83.
|
|
26
|
-
src | 83.
|
|
25
|
+
All files | 83.37 | 77.38 | 86.64 | 86 |
|
|
26
|
+
src | 83.19 | 77.06 | 86.23 | 85.83 |
|
|
27
27
|
...n-contract.ts | 90.13 | 85.89 | 90.51 | 90.9 | ...1166,1171-1172
|
|
28
|
-
codegen-mcp.ts |
|
|
28
|
+
codegen-mcp.ts | 82.75 | 74.53 | 84.21 | 86.19 | ...99,304-305,390
|
|
29
29
|
...-operation.ts | 83.06 | 80.46 | 80.28 | 85.15 | ...1045,1050-1051
|
|
30
30
|
...lain-types.ts | 91.7 | 83.8 | 96.96 | 94.57 | ...79,204,316,322
|
|
31
31
|
...gen-revive.ts | 59.23 | 52.54 | 78.37 | 65.28 | ...85-316,398-404
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @contractkit/contractkit-plugin-typescript
|
|
2
2
|
|
|
3
|
+
## 0.34.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3e90488: Stop the MCP aggregator from calling `container.register`, and underscore the unused `args` parameter on no-argument tools.
|
|
8
|
+
|
|
9
|
+
`generateMcpAggregator` emitted `container.register(McpToolHandlerMap, { useValue: map })`. InjectKit's `Container` has no `register`; it exposes only `get`, `createScopedContainer`, `hasRegistration`, `disposeAsync`, and `[Symbol.asyncDispose]`. Registration belongs to `Registry`, the composition-phase object, while `Container` is the resolution-phase one. Every generated `mcp.tools.ts` therefore failed to compile with `TS2339`, and would have thrown at startup if it had.
|
|
10
|
+
|
|
11
|
+
`registerMcpTools` now only builds the map and returns it. Its doc comment shows the binding that supplies the `Container` in the first place:
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
registry.register(McpToolHandlerMap).useFactory(registerMcpTools).asSingleton();
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`generateMcpRouter`'s doc line told consumers to _call_ the aggregator at startup, which is the same mistake. It now points at the binding.
|
|
18
|
+
|
|
19
|
+
Separately, `renderToolClass` always named the handler's first parameter `args`. An operation with no path parameters and no request body destructures nothing, so the parameter went unread and tripped `@typescript-eslint/no-unused-vars` in consumers that lint generated output. It is now emitted as `_args` when there is nothing to destructure.
|
|
20
|
+
|
|
3
21
|
## 0.34.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen-mcp.d.ts","sourceRoot":"","sources":["../src/codegen-mcp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA8E,MAAM,mBAAmB,CAAC;AAUhI,MAAM,WAAW,iBAAiB;IAC9B,mFAAmF;IACnF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uFAAuF;IACvF,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,qDAAqD;IACrD,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9B,sDAAsD;IACtD,gBAAgB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,yFAAyF;IACzF,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,2DAA2D;IAC3D,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B;AASD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,eAAe,UAAQ,GAAG,O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415,7 +4415,8 @@ function renderToolClass(plan, file, options) {
|
|
|
4415
4415
|
const callArgs = buildArgs(route, op);
|
|
4416
4416
|
const isVoid = !primaryResponseBody(op);
|
|
4417
4417
|
const structured = !!outExpr;
|
|
4418
|
-
|
|
4418
|
+
const argsParam = destructure.length > 0 ? "args" : "_args";
|
|
4419
|
+
lines.push(` async handle(${argsParam}: Record<string, unknown>, _context: McpToolContext): Promise<CallToolResult> {`);
|
|
4419
4420
|
if (destructure.length > 0) {
|
|
4420
4421
|
lines.push(` const { ${destructure.join(", ")} } = await parseAndValidate(args, ${argsConstName});`);
|
|
4421
4422
|
}
|
|
@@ -4503,11 +4504,19 @@ function generateMcpAggregator(entries) {
|
|
|
4503
4504
|
lines.push(`import { McpToolHandlerMap } from '@maroonedsoftware/mcp';`);
|
|
4504
4505
|
for (const e of sorted) lines.push(`import { ${e.registerFn} } from '${e.importPath}';`);
|
|
4505
4506
|
lines.push("");
|
|
4506
|
-
lines.push("/**
|
|
4507
|
+
lines.push("/**");
|
|
4508
|
+
lines.push(" * Build the MCP tool catalog.");
|
|
4509
|
+
lines.push(" *");
|
|
4510
|
+
lines.push(" * Bind it to the `McpToolHandlerMap` token from a factory, which is what supplies the");
|
|
4511
|
+
lines.push(" * `Container` needed to resolve each handler:");
|
|
4512
|
+
lines.push(" *");
|
|
4513
|
+
lines.push(" * ```ts");
|
|
4514
|
+
lines.push(" * registry.register(McpToolHandlerMap).useFactory(registerMcpTools).asSingleton();");
|
|
4515
|
+
lines.push(" * ```");
|
|
4516
|
+
lines.push(" */");
|
|
4507
4517
|
lines.push("export function registerMcpTools(container: Container): McpToolHandlerMap {");
|
|
4508
4518
|
lines.push(" const map = new McpToolHandlerMap();");
|
|
4509
4519
|
for (const e of sorted) lines.push(` ${e.registerFn}(map, container);`);
|
|
4510
|
-
lines.push(" container.register(McpToolHandlerMap, { useValue: map });");
|
|
4511
4520
|
lines.push(" return map;");
|
|
4512
4521
|
lines.push("}");
|
|
4513
4522
|
return lines.join("\n") + "\n";
|
|
@@ -4518,7 +4527,7 @@ function generateMcpRouter(options = {}) {
|
|
|
4518
4527
|
return `import { ServerKitRouter, bodyParserMiddleware, requireSignature } from '@maroonedsoftware/koa';
|
|
4519
4528
|
import { McpDispatcher, createMcpRequestContext, MCP_AUTH_POLICY } from '@maroonedsoftware/mcp';
|
|
4520
4529
|
|
|
4521
|
-
/** Mount the MCP endpoint onto a ServerKit router.
|
|
4530
|
+
/** Mount the MCP endpoint onto a ServerKit router. Bind \`registerMcpTools\` to the \`McpToolHandlerMap\` token. */
|
|
4522
4531
|
export function mountMcp(router: ReturnType<typeof ServerKitRouter>): void {
|
|
4523
4532
|
router.post('${path}', bodyParserMiddleware(['json']), requireSignature('mcp', { policy: MCP_AUTH_POLICY }), async (ctx) => {
|
|
4524
4533
|
const dispatcher = ctx.container.get(McpDispatcher);
|