{"version":3,"file":"index.mjs","names":[],"sources":["../../src/host/index.ts"],"sourcesContent":["/**\n * dsh-recommend host 半：四个模型可用工具。\n *\n * 契约：@deepseek-ai/dsh-tools 的 defineTool（官方 cookbook：adding-a-tool）。\n * 数据：只读 registry.json（config.dataUrl 指向的数据仓库产物），本地缓存于\n * config.cachePath（默认 $DSH_HOME/dsh-recommend/registry.json）。\n * 本插件从不执行任何被收录插件的代码（见 SECURITY.md）。\n */\nimport { mkdir, readFile, writeFile } from 'node:fs/promises'\nimport { dirname } from 'node:path'\nimport type { Context } from '@deepseek-ai/cordis'\nimport { defineTool } from '@deepseek-ai/dsh-tools'\n\nexport const name = 'dsh-recommend'\nexport const inject = ['tools']\n\nexport interface Config {\n  /** 数据仓库 registry.json 的下载地址。 */\n  dataUrl: string\n  /** 本地缓存路径；不存在时由 sync_registry 拉取。 */\n  cachePath: string\n}\n\n/** ISO 时间戳 → 本地可读格式，如 2026-08-14 05:27（UTC+8）。解析失败原样返回，缺省显示 —。 */\nfunction formatTime(iso: string | null | undefined): string {\n  if (!iso) return '—'\n  const d = new Date(iso)\n  if (Number.isNaN(d.getTime())) return iso\n  const p = (n: number) => String(n).padStart(2, '0')\n  const off = -d.getTimezoneOffset() / 60\n  const tz = off === 0 ? 'UTC' : `UTC${off > 0 ? '+' : ''}${off}`\n  return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}（${tz}）`\n}\n\nexport function apply(ctx: Context, config: Config) {\n  const cachePath = config.cachePath\n\n  /** 读缓存；缺失/损坏时返回 null（工具层提示先 sync）。 */\n  async function loadRegistry(): Promise<RegistryDoc | null> {\n    try {\n      const raw = await readFile(cachePath, 'utf8')\n      const doc: RegistryDoc = JSON.parse(raw)\n      if (!Array.isArray(doc.plugins)) throw new Error('registry 结构异常')\n      return doc\n    } catch {\n      return null\n    }\n  }\n\n  ctx.tools.register(defineTool({\n    name: 'sync_registry',\n    description: '下载最新插件 registry 到本地缓存。数据源：dsh-recommend 数据仓库（每日自动重算）。',\n    parameters: {},\n    output: {\n      schema: {\n        type: 'object',\n        additionalProperties: false,\n        properties: {\n          fetchedAt: { type: 'string' },\n          count: { type: 'number' },\n          excluded: { type: 'number' },\n        },\n      },\n      render: (_args, value) => [{\n        type: 'text',\n        text: `registry 已更新：${value.count} 个仓库（${formatTime(value.fetchedAt)}）`,\n      }],\n    },\n    async execute() {\n      const res = await fetch(config.dataUrl)\n      if (!res.ok) throw new Error(`下载 registry 失败: ${res.status}`)\n      const text = await res.text()\n      const doc: RegistryDoc = JSON.parse(text)\n      if (!Array.isArray(doc.plugins)) throw new Error('下载的 registry 结构异常')\n      await mkdir(dirname(cachePath), { recursive: true })\n      await writeFile(cachePath, text, 'utf8')\n      return {\n        fetchedAt: doc.meta.generatedAt,\n        count: doc.plugins.length,\n        excluded: doc.plugins.filter((p) => p.excluded).length,\n      }\n    },\n  }))\n\n  ctx.tools.register(defineTool({\n    name: 'rank_plugins',\n    description: '查询 DSH 插件榜单：按综合分排序，可过滤分类/维度，返回 top N。',\n    parameters: {\n      limit: { type: 'number', description: '返回条数，默认 10，最大 50' },\n      category: { type: 'string', description: '按 hub 分类过滤，如「UI 增强」' },\n      sortBy: { type: 'string', enum: ['score', 'stars', 'updated'], description: '排序维度，默认 score' },\n      includeExcluded: { type: 'boolean', description: '是否包含被排除（占位/空仓库）条目，默认 false' },\n    },\n    output: {\n      schema: {\n        type: 'object',\n        additionalProperties: false,\n        properties: {\n          rankings: {\n            type: 'array',\n            items: {\n              type: 'object',\n              additionalProperties: false,\n              properties: {\n                rank: { type: 'number' },\n                fullName: { type: 'string' },\n                url: { type: 'string' },\n                description: { type: 'string' },\n                stars: { type: 'number' },\n                score: { type: 'number' },\n                signals: {\n                  type: 'object',\n                  additionalProperties: false,\n                  properties: {\n                    maintenance: { type: 'number' },\n                    popularity: { type: 'number' },\n                    quality: { type: 'number' },\n                    ecosystem: { type: 'number' },\n                  },\n                },\n                pushedAt: { oneOf: [{ type: 'string' }, { type: 'null' }] },\n                excluded: { oneOf: [{ type: 'string' }, { type: 'null' }] },\n              },\n            },\n          },\n        },\n      },\n      render: (_args, value) => [{\n        type: 'text',\n        text: (value.rankings ?? [])\n          .map((r) => `#${r.rank} ${r.fullName}（score ${r.score}，★${r.stars}）${r.excluded ? ` [${r.excluded}]` : ''}\\n  ${r.description}`)\n          .join('\\n'),\n      }],\n    },\n    async execute(args) {\n      const doc = await loadRegistry()\n      if (!doc) throw new Error('本地缓存缺失，请先调用 sync_registry')\n      const limit = Math.min(args.limit ?? 10, 50)\n      let rows = doc.plugins\n        .filter((p) => args.includeExcluded || !p.excluded)\n        .filter((p) => !args.category || (p.category ?? '').includes(args.category))\n        .map((p) => ({\n          rank: 0,\n          fullName: p.fullName,\n          url: p.url,\n          description: p.description,\n          stars: p.stars,\n          score: p.score,\n          signals: p.signals,\n          pushedAt: p.pushedAt,\n          excluded: p.excluded,\n        }))\n      rows.sort((a, b) => {\n        if (args.sortBy === 'stars') return b.stars - a.stars\n        if (args.sortBy === 'updated') return (b.pushedAt ?? '').localeCompare(a.pushedAt ?? '')\n        return b.score - a.score\n      })\n      rows = rows.slice(0, limit).map((r, i) => ({ ...r, rank: i + 1 }))\n      return { rankings: rows }\n    },\n  }))\n\n  ctx.tools.register(defineTool({\n    name: 'search_plugins',\n    description: '在插件 registry 中按名称/描述/分类检索（包含被排除条目并标注原因）。',\n    parameters: {\n      query: { type: 'string', required: true, description: '检索词' },\n      limit: { type: 'number', description: '返回条数，默认 10，最大 50' },\n    },\n    output: {\n      schema: {\n        type: 'object',\n        additionalProperties: false,\n        properties: {\n          results: {\n            type: 'array',\n            items: {\n              type: 'object',\n              additionalProperties: false,\n              properties: {\n                fullName: { type: 'string' },\n                url: { type: 'string' },\n                description: { type: 'string' },\n                stars: { type: 'number' },\n                score: { type: 'number' },\n                excluded: { oneOf: [{ type: 'string' }, { type: 'null' }] },\n              },\n            },\n          },\n        },\n      },\n      render: (_args, value) => [{\n        type: 'text',\n        text: (value.results ?? []).length === 0\n          ? '无匹配结果'\n          : (value.results ?? []).map((r) => `${r.fullName}（score ${r.score}，★${r.stars}）${r.excluded ? ` [${r.excluded}]` : ''}\\n  ${r.description}`).join('\\n'),\n      }],\n    },\n    async execute(args) {\n      const doc = await loadRegistry()\n      if (!doc) throw new Error('本地缓存缺失，请先调用 sync_registry')\n      const q = args.query.toLowerCase()\n      const results = doc.plugins\n        .filter((p) => (p.fullName + ' ' + (p.description ?? '') + ' ' + (p.category ?? '')).toLowerCase().includes(q))\n        .sort((a, b) => b.score - a.score)\n        .slice(0, Math.min(args.limit ?? 10, 50))\n        .map((p) => ({ fullName: p.fullName, url: p.url, description: p.description, stars: p.stars, score: p.score, excluded: p.excluded }))\n      return { results }\n    },\n  }))\n\n  ctx.tools.register(defineTool({\n    name: 'recommend_plugins',\n    description: '按用户目标描述推荐插件（v0 关键词匹配，M3 升级为打分推荐）。',\n    parameters: {\n      goal: { type: 'string', required: true, description: '用户想做的事，如「给 Web 界面加侧边栏」' },\n      limit: { type: 'number', description: '返回条数，默认 5，最大 20' },\n    },\n    output: {\n      schema: {\n        type: 'object',\n        additionalProperties: false,\n        properties: {\n          recommendations: {\n            type: 'array',\n            items: {\n              type: 'object',\n              additionalProperties: false,\n              properties: {\n                fullName: { type: 'string' },\n                url: { type: 'string' },\n                description: { type: 'string' },\n                score: { type: 'number' },\n                reason: { type: 'string' },\n              },\n            },\n          },\n        },\n      },\n      render: (_args, value) => [{\n        type: 'text',\n        text: (value.recommendations ?? []).length === 0\n          ? '没有找到明显匹配的插件，试试 search_plugins 换关键词'\n          : (value.recommendations ?? []).map((r) => `${r.fullName}（score ${r.score}）\\n  理由：${r.reason}\\n  ${r.description}`).join('\\n'),\n      }],\n    },\n    async execute(args) {\n      const doc = await loadRegistry()\n      if (!doc) throw new Error('本地缓存缺失，请先调用 sync_registry')\n      // v0 规则式：分词（CJK 按字符二元组 + 英文词），对 name/description/category 打分\n      const tokens = tokenize(args.goal)\n      const scored = doc.plugins\n        .filter((p) => !p.excluded)\n        .map((p) => {\n          const haystack = `${p.fullName} ${p.description ?? ''} ${p.category ?? ''}`.toLowerCase()\n          let hits = 0\n          for (const t of tokens) if (haystack.includes(t)) hits += 1\n          const ratio = tokens.length === 0 ? 0 : hits / tokens.length\n          const relevance = Math.min(1, ratio) * 0.6 + p.score * 0.4\n          return { p, relevance, hits }\n        })\n        .filter((x) => x.hits > 0)\n        .sort((a, b) => b.relevance - a.relevance)\n        .slice(0, Math.min(args.limit ?? 5, 20))\n      return {\n        recommendations: scored.map(({ p, hits }) => ({\n          fullName: p.fullName,\n          url: p.url,\n          description: p.description,\n          score: p.score,\n          reason: `命中 ${hits}/${tokens.length} 个关键词；综合分 ${p.score}`,\n        })),\n      }\n    },\n  }))\n}\n\n/** v0 分词：英文词 + CJK 字符二元组。 */\nfunction tokenize(input: string): string[] {\n  const s = input.toLowerCase()\n  const tokens = [...(s.match(/[a-z0-9-]+/g) ?? [])]\n  for (let i = 0; i < s.length - 1; i += 1) {\n    const a = s[i] ?? ''\n    const b = s[i + 1] ?? ''\n    if (/[\\u4e00-\\u9fff]/.test(a) || /[\\u4e00-\\u9fff]/.test(b)) {\n      tokens.push(a + b)\n    }\n  }\n  return tokens\n}\n\ninterface RegistryDoc {\n  meta: { generatedAt: string; scoringVersion: number }\n  plugins: Array<{\n    fullName: string\n    url: string\n    description: string\n    stars: number\n    score: number\n    category: string | null\n    excluded: string | null\n    pushedAt: string | null\n    signals: Record<string, number>\n  }>\n}\n"],"mappings":";;;;;;;;;;;;AAaA,MAAa,OAAO;AACpB,MAAa,SAAS,CAAC,OAAO;;AAU9B,SAAS,WAAW,KAAwC;CAC1D,IAAI,CAAC,KAAK,OAAO;CACjB,MAAM,IAAI,IAAI,KAAK,GAAG;CACtB,IAAI,OAAO,MAAM,EAAE,QAAQ,CAAC,GAAG,OAAO;CACtC,MAAM,KAAK,MAAc,OAAO,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG;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