npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mashangjia

v0.3.8

Published

码上架官方 Agent-native 网站部署 CLI

Downloads

715

Readme

mashangjia

码上架面向 AI coding agent 的官方 CLI,要求 Node.js 20 或更高版本。

Agent 主入口

部署前先运行只读预检,Agent 读取同一份机器可读结论后再决定发布方式:

mashangjia preflight . --json

preflight 只扫描本地项目、检查 Node/npm/CLI、探测当前 base_url,不上传、不安装依赖、不修改项目目录。stdout 始终是一个 schema_version: 1 JSON 对象;并行任务进度以结构化 JSON 行写入 stderr。output.safety 复用发布打包的 ALLOW / REVIEW / BLOCK 语义。

默认不要求用户安装 Skill。用户可以直接告诉 AI:

根据 https://mashangjia.com/ai 帮我部署到码上架

AI 读取网页 Skill 后执行:

mashangjia deploy . --json

CLI 负责预检、登录状态判断、项目构建、安全打包、账号/匿名路由、上传、轮询、最终 URL 验证和临时 ZIP 清理。已有 dist / build / out / public 或纯静态产物会直接打包;需要构建时只在临时副本中执行依赖安装和 build,不污染用户工作区。

  • 已配置 CLI 登录的机器:本机 Bearer 只用于换取短期内存 Grant,后续部署动作使用 Grant。
  • 未配置 CLI 登录的机器:对通过预检的项目自动匿名部署,返回固定公开地址(url,认领后不变)、claim_available/claim_expires_at 非敏感认领状态和过期时间。一次性认领能力默认不进入输出,保存在本机 0600 recovery state;用户说「认领这个网站」时由 mashangjia claim <project_id> 使用本地能力和账号授权完成认领,认领后原地址不变。
  • Docker 动态项目例外:--mode auto 下即使本机已配置 CLI 登录,也默认匿名发布临时动态站(约 24 小时,可后续登录付费认领)——免费账号不必先撞账号 Docker 套餐门槛;显式 --mode account 才走账号发布。
  • Node SSR、后端服务信号或服务端数据项目(无 Dockerfile)不支持匿名静态降级;预检直接返回 ACCOUNT_REQUIRED,必须使用账号模式。
  • 浏览器里已经登录码上架,不等于当前终端已经配置 CLI 登录。CLI 只读取本机 CLI 配置、显式的 MASHANGJIA_TOKEN,或兼容场景下的 MASHANGJIA_DEPLOY_TOKEN。
  • 只有部署状态为 success 且最终 URL 实际可访问时,目录部署才返回 verified: true。

权威契约:

  • Agent 行为:https://mashangjia.com/ai
  • 完整 Skill 包:agent-skill/mashangjia-deploy/
  • HTTP API:docs/agent-api.openapi.yaml

安装(Mac / Windows)

前置:Node.js 20+(自带 npm)。没有就装:Mac 用 brew install node 或 nodejs.org 安装包;Windows 用 nodejs.org LTS 安装包或 winget install OpenJS.NodeJS.LTS(装完重开终端)。

npm install -g mashangjia   # 全局安装
mashangjia --version        # 确认版本(与 npm view mashangjia version 一致即为最新)
mashangjia --help           # 验证命令面(须含 preflight / deploy / resume)

升级到最新版:npm install -g mashangjia@latest。

免安装一次性用法:npx mashangjia deploy . --json。若装过旧版 scoped 包,先 npm uninstall -g @mashangjia/cli 再装(bin 名相同会冲突)。

本机 CLI 登录

现有登录能力继续保留,用于把当前终端机器绑定到码上架账号。后端当前签发的 Bearer 形如 MSJ-<高熵随机串>,CLI 同时兼容历史 msj_... 格式:

mashangjia login --token 'MSJ-...' --base-url 'https://mashangjia.com' --json

配置默认保存在 ~/.config/mashangjia/config.json,文件权限为 0600。也支持:

export MASHANGJIA_BASE_URL='https://mashangjia.com'
export MASHANGJIA_TOKEN='MSJ-...'

长期 Bearer 与服务 origin 绑定。CLI 不会把本机 Bearer 或短期 Grant 跟随重定向或服务端返回的绝对 URL 发送到其他 origin。

Agent 不应要求用户把 token 粘贴进聊天。

兼容命令

旧的显式站点 + ZIP 流程继续可用:

mashangjia sites list --json
mashangjia sites create --name '文档站' --slug docs-demo --json
mashangjia deploy docs-demo ./site.zip --timeout 600 --json
mashangjia status 123 --json
mashangjia url docs-demo --json

AI coding agent 的首选入口仍是 mashangjia deploy . --json。

deploy 退出码:0 成功、1 终态失败/CLI/API 错误、2 轮询超时。

审计修订:当前活动与匿名回执(源码候选,尚未发布)

本源码增加 activity 只读命令。它查询当前服务的 /api/public/activity/,不读取或发送本机部署凭证,不开通会员。

node bin/mashangjia.js activity --base-url http://localhost:8080 --json

只有返回 active=true 时才转述活动规则;活动失败不影响已完成的部署,也不能触发重新上传。活动失效或缺失时不宣传旧权益。进群后仍需按规则发送账号 UID 登记,以实际套餐和到期时间确认到账。

匿名成功回执增加 ownership 和 next_steps,用于解释临时归属、原任务恢复和同项目更新;不公开认领证明。--harness 可保留合法的第三方工具 slug;没有可靠来源线索时不猜测。已有的 other 历史记录无法仅靠本次更新恢复品牌。

包版本仍为 0.3.3,不代表 npm 已包含本轮修改。发布前须按项目正常版本和兼容流程处理。