@wenaixi/cfbridge 0.1.0

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,46 @@
1
+ // cfbridge Skill 运行时注册插件(DSH Bundle 全局可见)
2
+ //
3
+ // 作为 host 组合的一行,随 bundle 安装后所有会话自动可见。
4
+ // 形态遵循 dsh-vision-toolkit 实践:inject: ['skills'] + ctx.skills.register()。
5
+ // 资源基座指向 bundle 内的 skills/cfbridge/ 目录,内容为 SKILL.md 全文。
6
+
7
+ const fs = require('fs')
8
+ const path = require('path')
9
+
10
+ // 本文件所在:<bundle-root>/src/cfbridge-skill.js
11
+ // 资源目录:<bundle-root>/skills/cfbridge/
12
+ const SKILL_DIR = path.resolve(__dirname, '..', 'skills', 'cfbridge')
13
+ const SKILL_MD = path.join(SKILL_DIR, 'SKILL.md')
14
+
15
+ let SKILL_CONTENT = ''
16
+ try {
17
+ SKILL_CONTENT = fs.readFileSync(SKILL_MD, 'utf8')
18
+ } catch (e) {
19
+ // 缺少 SKILL.md 时让 apply 抛异常,触发 loader 的响亮失败
20
+ throw new Error(`cfbridge-skill: cannot read SKILL.md at ${SKILL_MD}: ${e.message}`)
21
+ }
22
+
23
+ // 从首段提取 description,避免与文件内容重复维护。
24
+ // SKILL.md 首行是标题,第三段是全局可见声明,取其精简版作 catalog 描述。
25
+ const SKILL_DEFINITION = {
26
+ name: 'cfbridge',
27
+ description:
28
+ 'Cloudflare Code Mode MCP 全局 Bridge:装后所有会话自动获得 mcp__cloudflare__docs/search/execute 三工具与本操作指南;含 search-then-execute 工作流、写操作审批规范、Token 权限边界与 Wrangler 透传指引。',
29
+ whenToUse:
30
+ '任何涉及 Cloudflare API 的请求(Workers/KV/D1/Pages/Zones/DNS/R2/Analytics 等)都应先加载本 Skill;执行前用 mcp__cloudflare__docs 或 mcp__cloudflare__search 确认端点,再用 mcp__cloudflare__execute 执行。',
31
+ source: 'runtime',
32
+ resourceBase: {
33
+ kind: 'directory',
34
+ path: SKILL_DIR,
35
+ },
36
+ content: SKILL_CONTENT,
37
+ }
38
+
39
+ const name = 'cfbridge-skill'
40
+ const inject = ['skills']
41
+
42
+ function apply(ctx) {
43
+ ctx.skills.register(SKILL_DEFINITION)
44
+ }
45
+
46
+ module.exports = { name, inject, apply }