@computesdk/pi-morph

中文文档
1.0.7发布于 2026/10/31MITES Module零依赖近 30 天下载 2116

Morph for Pi: open-weight coding models (Kimi K3, GLM 5.3, DeepSeek V4) on Morph's OpenAI-compatible API, plus Fast Apply, Compact, and WarpGrep as tools.

原始使用文档
文档目录4 节
  1. Models
  2. Tools
  3. Not included
  4. Development

@computesdk/pi-morph

Morph for Pi: the open-weight coding models as a provider, and Morph's single-purpose models as tools.

pi install npm:@computesdk/pi-morph      # or: pi -e /path/to/pi-extensions/packages/pi-morph

Run /login morph and paste your key, or set MORPH_API_KEY in your environment; one credential covers both halves (the models and the tools). When both are set the stored key wins, which is what the models do too, so /login is the one that decides — unset it, or point PI_CODING_AGENT_DIR at another directory, to switch back to the environment variable.

Models

Set the key and the models show up in /model as morph/morph-kimik3 and friends.

ModelInputContext$/1M in$/1M out
morph-kimik3 — Kimi K3text1M2.5014.00
morph-kimik3-fast — Kimi K3 Fasttext1M6.0022.50
morph-glm53-744b — GLM-5.3 744Btext1M1.196.00
morph-glm53flash — GLM-5.3 Flashtext, image1M0.200.70
morph-dsv41flash — DeepSeek V4.1 Flashtext, image1M0.120.80
morph-dsv41flash-1017 — DeepSeek V4.1 Flash 1017text, image1M0.120.80
morph-dsv4flash — DeepSeek V4 Flash 0731text1M0.140.40

Endpoint https://api.morphllm.com/v1, bearer auth, api: "openai-completions" — Pi's built-in implementation does the request, stream and tool-call plumbing, so the provider is one pi.registerProvider call with the catalog above. Prices are per 1M tokens from morphllm.com/pricing; cacheWrite is not billed. service_tier: "standby" halves the price on supported models — Pi can send it through samplingParams.

Pi's thinking levels map onto Morph's reasoning_effort ladder (none | low | high | xhigh | max). DeepSeek documents none, so off maps to it; for the other models off is marked unsupported (null) rather than sent.

The -1017 in DeepSeek's ID is a snapshot date — October 17 — matching 0731 for July 31 in morph-dsv4flash. So morph-dsv41flash-1017 is pinned to those weights while morph-dsv41flash follows whatever Morph serves today; the two share a serving pool and list prices.

Tools

The same package adds three tools. Morph's single-purpose models take request shapes of their own rather than chat completions, so they are tools here, not entries in the catalog above.

ToolWhat it doesEndpoint
morph_applyApplies an edit to a file with Fast Apply (~10.5k tok/s, ~98% accuracy)POST /v1/code/apply
morph_compactCompresses long text, keeping the parts a follow-up question needsPOST /v1/compact
morph_searchAnswers a code question with the WarpGrep search subagent (~6s)POST /v1/chat/completions with morph-warp-grep-v2.1

morph_apply rewrites the file it is given: you pass the lines that change plus // ... existing code ... markers for the unchanged spans, and Morph merges the edit in. It is marked destructiveHint, so a permission extension can gate it. The other two only read.

morph_apply offers the models /v1/code/apply actually serves — morph-v3-fast (the default), morph-v2, morph-v0. Morph's docs also list auto and morph-v3-large, but the deployed endpoint rejects both with 400 invalid_request_error, so they are not offered here.

morph_compact filters line by line, so an input with nothing worth keeping for the question comes back as (filtered N lines) rather than as text — a one-line input always does. The tool explains that instead of echoing the marker bare.

morph_search is a subagent, not a grep wrapper. It explores the repository in its own context window for up to six turns and returns only the file/line spans it settled on, with their code, so the dead ends never reach your context. Its search tools (grep_search, read, list_directory, glob, finish) are built into Morph's model; this package executes them locally and feeds the results back.

That local implementation never runs a shell. Morph asks for directory listings as shell commands (ls -la src), which are parsed here rather than executed, and every read is confined to the directory the search was given. node_modules, .git, and build or virtualenv trees are skipped.

Usage from these endpoints is reported to Pi without a cost, because Morph does not publish per-token prices for them.

Not included

The Model Router (/v1/router/classify, /v1/router/multimodel) labels how complex a prompt is so a caller can choose a model. It is left out because Pi already picks the model for a session, so there is nothing for a tool to decide.

Development

pnpm test        # tsc --noEmit && node test.ts — offline unit tests
bash scripts/smoke.sh morph   # real requests, from the repo root; needs a key

test.ts loads both extensions with a fake Pi. It checks the provider config and every registered model — id, name, modalities, context and output limits, costs, uniqueness, and that each Pi thinking level is either mapped to a provider value or explicitly unsupported — then exercises the tools' local search implementation against a scratch directory: the repo structure WarpGrep is handed, argument coercion for grep/read/list_directory/glob, the text form of WarpGrep's tool calls, span parsing, path confinement, and usage mapping. Nothing in the suite touches the network.

Because it cannot notice a vendor changing under us, scripts/smoke.sh (or pnpm smoke) covers that: it checks every declared model ID against the IDs Morph serves, sends one chat request per model, and calls each tool endpoint — including every model in APPLY_MODELS, which is what broke when Morph stopped serving auto.

MIT licensed.

版本与发布记录

@computesdk/pi-morph 共发布 12 个版本,首次发布于 2026/10/30;过去 12 个月发布了 12 个版本。

版本发布日期距今
1.0.7latest2026/10/3113 天前
1.0.62026/10/3113 天前
1.0.52026/10/3114 天前
1.0.42026/10/3114 天前
1.0.32026/10/3114 天前
1.1.12026/10/3114 天前

关于 @computesdk/pi-morph 的常见问题

@computesdk/pi-morph 是什么?

Morph for Pi: open-weight coding models (Kimi K3, GLM 5.3, DeepSeek V4) on Morph's OpenAI-compatible API, plus Fast Apply, Compact, and WarpGrep as tools.

如何安装 @computesdk/pi-morph?

在项目目录运行 npm install @computesdk/pi-morph,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:typebox(*)、@earendil-works/pi-ai(*)、@earendil-works/pi-coding-agent(*)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@computesdk/pi-morph 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/computesdk__pi-morph 是否存在。

@computesdk/pi-morph 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@computesdk/pi-morph 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.18.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@computesdk/pi-morph 可以商用吗?

@computesdk/pi-morph 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@computesdk/pi-morph 的下载量有多少?

根据 npm 官方下载统计,@computesdk/pi-morph 在 2026/10/11 – 2026/11/09 这 30 天内被下载 2,116 次,日均约 71 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@computesdk/pi-morph 还在维护吗?

最新版本 1.0.7 发布于 2026/10/31(13 天前);至今共发布 12 个版本,其中过去 12 个月发布了 12 个;首次发布于 2026/10/30。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。