Code2Skill:從已有代碼生成 Function、MCP 和 Agent Skill

前言

在 DeepSeek Harness(DSH)裏搭智能體能力時,一個問題很常見:業務邏輯已經分散在前端、後端或全棧源碼中,但要讓其他智能體穩定調用,還需要把它們整理成 Function、MCP tool 和 Skill。

leechen298/Code2Skill 針對這個場景提供一套 DSH 插件形式的能力:在用戶授權的源碼範圍內生成 Function、MCP tool、workflow Skill 和 offline tests,並默認只做 offline technical validation,不調用 live business APIs。

這是什麼

Code2Skill 是一個用於生成和審查可移植 Function、MCP、Agent Skill 包的插件。它由 leechen298 維護,許可證爲 MIT。

它的核心目標不是直接替代業務系統,而是把已有代碼中可識別的業務入口和調用鏈路,整理成可供其他智能體調用、複用和審查的能力包。

核心功能

  • 從已有代碼生成 Functions、MCP tools、workflow Skills 和 offline tests。
  • 適用於用戶授權的前端、後端或全棧源碼。
  • 在用戶指定的 page、directory、feature 或 public entry point 內,識別可以獨立完成的目標。
  • 把字段來源、工具間記錄交接、請求組裝和確定性轉換放到 Functions 中。
  • 爲每個主要目標生成一個 Skill,並複用必要的 Functions 和 MCP tools。
  • 默認執行 offline technical validation,不調用 live business APIs。
  • 提供 review Skills,用於檢查 workflow completion 和 source semantics。
  • 可作爲 DeepSeek Harness bundle 安裝到指定 profile。

安裝與啓用

安裝前,先確認你要安裝到哪個 DSH profile,並檢查插件源碼和許可證。當前示例安裝到 web profile,版本爲 v1.2.0:

dsh plugin --profile web add github:leechen298/Code2Skill#v1.2.0

注意:插件會以當前 dsh 進程擁有的權限運行,所以授權範圍、源碼訪問和後續生成範圍都應在你能夠控制的邊界內。

典型用法

生成能力時,可以指定要轉換的入口,並明確授權源碼根目錄:

Use $code2skill-generate to turn <page, directory, feature path, or public entry point> into runnable Functions, MCP tools, and Skills.
Authorized source roots: <frontend>, <backend>, <protocol>, and <service/message/task directories>.

如果你只想檢查生成包能否完成主要目標:

Use $code2skill-review-flow to review whether the primary goals in <generated package path> can be completed.

如果你想覈對某個 Skill 或能力是否匹配授權源碼:

Use $code2skill-review-source to review whether <specific Skill or capability> in <generated package path> matches the authorized source code.

適用場景與注意

適合從已有前端、後端或全棧代碼中提煉可複用能力的團隊。它適合生成 Function、MCP tool、Skill 和 offline tests 的初始結構,再配合 review 能力檢查主流程和關鍵語義。

使用前要注意:

  • 它不證明所有業務規則或真實環境已經完成驗證。
  • 默認是 offline technical validation,不會調用 live business APIs。
  • 離線測試不替代 real API 或 deployment acceptance。
  • 生成結果依賴 generation model、source completeness 和用戶授權範圍。
  • 如果需要 live business operations,需要按照對應生成包中的 MCP-SETUP.md 註冊生成的 MCP server。

鏈接

GitHub 倉庫:https://github.com/leechen298/Code2Skill

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

小夜