@capyclaw/plugin-generator 0.0.0-stage → 1.0.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.
@@ -0,0 +1,62 @@
1
+ /**
2
+ * MCP 工具面:能力声明 → 注册表 → 工具清单。
3
+ *
4
+ * 新增工具:在 impl.mjs 写实现,这里 defineTool 声明 schema,并加入能力。
5
+ */
6
+ import {
7
+ defineTool, defineCapability, createRegistry, createMcpHandler,
8
+ createCapabilityReport, buildInstructions,
9
+ } from './shared/tool-host.mjs'
10
+ import { echo, capabilities as capabilitiesImpl } from './impl.mjs'
11
+
12
+ export const contractVersion = '1.0.0'
13
+
14
+ const echoTool = defineTool({
15
+ name: '{{TOOL_PREFIX}}_echo',
16
+ description: '回显输入文本,用于验证服务连通性。',
17
+ inputSchema: {
18
+ type: 'object',
19
+ additionalProperties: false,
20
+ properties: {
21
+ text: { type: 'string', maxLength: 2000, description: '要回显的文本' },
22
+ },
23
+ required: ['text'],
24
+ },
25
+ handler: (args) => ({ content: [{ type: 'text', text: echo(args) }] }),
26
+ })
27
+
28
+ const capabilitiesTool = defineTool({
29
+ name: '{{TOOL_PREFIX}}_capabilities',
30
+ description: '返回契约版本、工具清单和能力说明。',
31
+ inputSchema: { type: 'object', additionalProperties: false, properties: {} },
32
+ kind: 'read',
33
+ handler: () => ({ content: [{ type: 'text', text: JSON.stringify(capabilitiesImpl(), null, 2) }] }),
34
+ })
35
+
36
+ const capability = defineCapability({
37
+ id: '{{SLUG}}',
38
+ title: '{{TITLE}}',
39
+ description: '{{DESCRIPTION}}',
40
+ tags: ['service'],
41
+ tools: [echoTool, capabilitiesTool],
42
+ })
43
+
44
+ export const registry = createRegistry([capability], {
45
+ report: ({ editorUrl = '', runtime = {}, ...rest }) => createCapabilityReport({
46
+ ...rest,
47
+ contractVersion,
48
+ packageVersion: '{{VERSION}}',
49
+ editorUrl,
50
+ runtime,
51
+ }),
52
+ })
53
+
54
+ export const tools = registry.TOOLS
55
+ export const callTool = (name, args) => registry.TOOL_IMPL[name]?.(args)
56
+ export function capabilities() { return registry.ctx.contract.report() }
57
+
58
+ export function createMcp(serverInfo, instructions) {
59
+ return createMcpHandler({ registry, serverInfo, instructions })
60
+ }
61
+
62
+ export { buildInstructions }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.