@forumone/throughline-components 0.2.0 → 0.2.2
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/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +37 -2
- package/dist/plugin.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @forumone/throughline-components
|
|
2
2
|
|
|
3
|
+
## 0.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`123d2ea`](https://github.com/forumone/throughline/commit/123d2ea0172d9495b9e2c8e8c6039e623f5fba66) Thanks [@briangraves](https://github.com/briangraves)! - The plugin now attaches an in-process composition validator to the Payload instance under `Symbol.for('@forumone/throughline/components-validator')`. The publishing server's pipeline reads that symbol to validate compositions during the publish flow without round-tripping through the MCP transport. Adds the `'composition-validation'` capability to the plugin's registry entry.
|
|
8
|
+
|
|
9
|
+
## 0.2.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`3ff1e9f`](https://github.com/forumone/throughline/commit/3ff1e9f43fad2e15fd42f67073227259ba7e78d4) Thanks [@briangraves](https://github.com/briangraves)! - Fix: drop the `/api` prefix from `componentsPlugin`'s default `routePrefix` so the endpoint registers at `/api/components/mcp` rather than `/api/api/components/mcp`. Payload mounts top-level endpoints under its API base (`config.routes.api`, default `/api`), which the previous default doubled. Consumers who pass an explicit `routePrefix` should also drop any leading `/api`.
|
|
14
|
+
|
|
3
15
|
## 0.2.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ MCP server that exposes a design system manifest as conversational primitives. D
|
|
|
4
4
|
|
|
5
5
|
## What this package provides
|
|
6
6
|
|
|
7
|
-
Seven MCP tools served at
|
|
7
|
+
Seven MCP tools served at `<api-base>/<routePrefix>/mcp`. With Payload's default API base (`/api`) and the plugin's default `routePrefix` (`/components`), the user-facing URL is `/api/components/mcp`.
|
|
8
8
|
|
|
9
9
|
| Tool | Purpose |
|
|
10
10
|
|---|---|
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAA;AAQvE,OAAO,EAAE,KAAK,uBAAuB,EAAmB,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAA;AAQvE,OAAO,EAAE,KAAK,uBAAuB,EAAmB,MAAM,cAAc,CAAA;AA+B5E,eAAO,MAAM,gBAAgB,EAAE,UAAU,CAAC,uBAAuB,CAyF9D,CAAA"}
|
package/dist/plugin.js
CHANGED
|
@@ -4,14 +4,26 @@ import { validateOptions } from './options.js';
|
|
|
4
4
|
import { createManifestLoader } from './manifest-source.js';
|
|
5
5
|
import { createTfidfMatcher } from './matching/index.js';
|
|
6
6
|
import { createFindAntiPatternTool, createGetContractTool, createGetTokensTool, createGetVariantsTool, createListComponentsTool, createSuggestForIntentTool, createValidateCompositionTool, } from './tools/index.js';
|
|
7
|
+
import { validateComposition, } from './validation/composition.js';
|
|
7
8
|
const PLUGIN_ID = '@forumone/throughline-components';
|
|
8
9
|
const PLUGIN_VERSION = '0.1.0';
|
|
9
10
|
const MCP_HANDLER_SYMBOL = Symbol.for('@forumone/throughline/components-mcp-handler');
|
|
11
|
+
/**
|
|
12
|
+
* Internal IPC point: peer plugins (publishing, etc.) read this symbol from
|
|
13
|
+
* the Payload instance to call composition validation directly without
|
|
14
|
+
* going through MCP. Keep this string in lockstep with the matching constant
|
|
15
|
+
* in the publishing package.
|
|
16
|
+
*/
|
|
17
|
+
const VALIDATOR_SYMBOL = Symbol.for('@forumone/throughline/components-validator');
|
|
10
18
|
export const componentsPlugin = (rawOptions) => (incomingConfig) => {
|
|
11
19
|
if (rawOptions.enabled === false)
|
|
12
20
|
return incomingConfig;
|
|
13
21
|
const options = validateOptions(rawOptions);
|
|
14
|
-
|
|
22
|
+
// Payload mounts top-level endpoints under its API base (default /api),
|
|
23
|
+
// so the path passed here MUST NOT include /api itself or it ends up
|
|
24
|
+
// doubled (e.g. /api/api/components/mcp). The user-facing URL is still
|
|
25
|
+
// /api/components/mcp.
|
|
26
|
+
const routePrefix = options.routePrefix ?? '/components';
|
|
15
27
|
const logger = createNamedLogger('components', options.logger ?? defaultLogger);
|
|
16
28
|
const maxRecommendations = options.matching?.maxRecommendations ?? 5;
|
|
17
29
|
return {
|
|
@@ -64,10 +76,16 @@ export const componentsPlugin = (rawOptions) => (incomingConfig) => {
|
|
|
64
76
|
logger,
|
|
65
77
|
});
|
|
66
78
|
attachMcpHandler(payload, handler);
|
|
79
|
+
attachValidator(payload, loader);
|
|
67
80
|
registry.register({
|
|
68
81
|
id: PLUGIN_ID,
|
|
69
82
|
version: PLUGIN_VERSION,
|
|
70
|
-
capabilities: [
|
|
83
|
+
capabilities: [
|
|
84
|
+
'component-server',
|
|
85
|
+
'manifest-loading',
|
|
86
|
+
'intent-matching',
|
|
87
|
+
'composition-validation',
|
|
88
|
+
],
|
|
71
89
|
});
|
|
72
90
|
},
|
|
73
91
|
};
|
|
@@ -80,4 +98,21 @@ function attachMcpHandler(payload, handler) {
|
|
|
80
98
|
configurable: false,
|
|
81
99
|
});
|
|
82
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Attaches a composition-validation function to the Payload instance under
|
|
103
|
+
* VALIDATOR_SYMBOL so peer plugins (the publishing server) can validate
|
|
104
|
+
* compositions in-process without going through the MCP transport.
|
|
105
|
+
*/
|
|
106
|
+
function attachValidator(payload, loader) {
|
|
107
|
+
const validator = async (input) => {
|
|
108
|
+
const manifest = await loader.get();
|
|
109
|
+
return validateComposition(input, manifest);
|
|
110
|
+
};
|
|
111
|
+
Object.defineProperty(payload, VALIDATOR_SYMBOL, {
|
|
112
|
+
value: validator,
|
|
113
|
+
enumerable: false,
|
|
114
|
+
writable: false,
|
|
115
|
+
configurable: false,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
83
118
|
//# sourceMappingURL=plugin.js.map
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAA;AACzE,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,cAAc,GACf,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAgC,eAAe,EAAE,MAAM,cAAc,CAAA;AAC5E,OAAO,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAA;AACzE,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,cAAc,GACf,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAgC,eAAe,EAAE,MAAM,cAAc,CAAA;AAC5E,OAAO,EAAE,oBAAoB,EAAuB,MAAM,sBAAsB,CAAA;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,EACxB,0BAA0B,EAC1B,6BAA6B,GAC9B,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAGL,mBAAmB,GACpB,MAAM,6BAA6B,CAAA;AAEpC,MAAM,SAAS,GAAG,kCAAkC,CAAA;AACpD,MAAM,cAAc,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