@apso/cli

中文文档
0.47.2发布于 2026/11/05Apache-2.0TypeScriptCommonJS构建来源已验证近 30 天下载 3519

Apso CLI

原始使用文档
文档目录29 节
  1. Install
  2. MCP Server (AI editor integration)
  3. Connect
  4. Quick start
  5. Commands
  6. Command reference
  7. apso init
  8. apso generate
  9. apso dev
  10. apso migrate
  11. apso deploy
  12. apso login
  13. apso logout
  14. apso whoami
  15. apso link
  16. apso unlink
  17. apso status
  18. apso logs
  19. apso open
  20. apso projects
  21. apso config
  22. apso schema
  23. Global options
  24. Telemetry & privacy
  25. Supported languages
  26. Contribute
  27. Testing
  28. Debugging
  29. License

Apso CLI

Define a schema. Get a production API. Keep the code.

Apso generates production-ready backend services from a JSON schema file. You get real framework code (NestJS, FastAPI, or Gin) that you own, run anywhere, and extend with standard patterns. For the complete documentation, see Apso Docs.

Install

Homebrew (macOS / Linux)

brew install apsoai/tap/apso
# Installed before Homebrew 6? Trust the formula so upgrades work:
# brew trust --formula apsoai/tap/apso

npm

npm install -g @apso/cli

Requires Node.js 18.0 or higher.

MCP Server (AI editor integration)

Apso works as an MCP server inside Claude Code, Cursor, Windsurf, and other MCP-compatible editors. Your AI assistant can design schemas, generate APIs, and deploy backends through conversation.

Claude Code

claude mcp add apso -- apso mcp serve

Cursor / VS Code / Other editors

Add to your MCP configuration:

{
  "mcpServers": {
    "apso": {
      "command": "apso",
      "args": ["mcp", "serve"]
    }
  }
}

Available tools:

ToolDescription
design_schemaDesign a database schema from application requirements
validate_schemaValidate an .apsorc schema file
scaffold_apiGenerate API code from schema (TypeScript, Python, or Go)
setup_authConfigure authentication (BetterAuth, Auth0, Clerk, Cognito, API Keys)
start_dev_serverStart local dev environment via Docker Compose
deploy_apiDeploy to the Apso platform

Schema edit tools (from @apso/schema-tools) change the project's .apsorc one step at a time. Each write is linted with the rules apso generate enforces; a change that would add a lint error is rejected and the file is left as it was.

ToolDescription
get_schema, describe_entityRead the schema outline, or one entity and its relationships
add_entity, rename_entity, remove_entityEntities (relationships and foreign key indexes follow renames and removals)
add_field, update_field, rename_field, remove_fieldFields (indexes and uniques follow renames and removals)
add_relationship, remove_relationshipRelationships
add_indexIndex or unique index
lint_schemaLint report

Available resources:

ResourceURIDescription
Schema referenceapso://schema-guideSchema design guidelines and examples
Current schemaapso://current-schemaYour project's current .apsorc

Connect

Authenticate with the Apso platform:

apso login

This opens a browser window for OAuth authentication. For CI/CD environments, use a token:

apso login --token <api-token>

Quick start

# Create a new project
apso init --name my-app --language typescript

# Edit .apsorc to define your schema

# Generate code from schema
apso generate

# Start Postgres and run the API
apso dev

Your API is live at http://localhost:3000 with Swagger docs at /api. The generated code lives in src/autogen/ and is standard NestJS with TypeORM -- no Apso runtime dependency.

Commands

CommandSubcommandsDescription
initCreate a new project
generateGenerate code from .apsorc schema
devStart local dev server via Docker Compose
migrateTest schema migrations locally with PGlite
deployDeploy to Apso platform
loginAuthenticate with Apso
logoutClear stored credentials
whoamiShow current user
linkLink project to a platform service
unlinkRemove platform link
statusShow service and build status
logsView build logs
openOpen service dashboard in browser
projectsList services in a workspace
configget, set, resetView or modify CLI configuration
schemadiff, push, pull, validateManage schema sync with platform
mcp serveStart MCP server for AI editors

Command reference

apso init

Create a new Apso project from a language-specific template.

apso init
apso init --name my-app --language typescript
apso init --name my-app --language python --skip-platform
OptionDescriptionDefault
-n, --nameProject name(prompted)
-l, --languageTarget language (typescript, python, go)(prompted)
--skip-platformSkip platform linking (offline mode)false

When authenticated, apso init lets you create a new project or clone an existing one from the platform.

apso generate

Generate backend code from the .apsorc schema file.

apso generate
apso generate --language python
apso generate --skip-format
OptionDescriptionDefault
-l, --languageTarget language (typescript, python, go)(from .apsorc or prompted)
--skip-formatSkip Prettier formatting after generationfalse

Generated files are placed in src/autogen/. These files are overwritten on each run. Place custom code in src/extensions/ to avoid losing changes.

apso dev

Start the local development server using Docker Compose.

apso dev
apso dev --build
apso dev --detach
OptionDescriptionDefault
--buildRebuild images before startingfalse
-d, --detachRun containers in the backgroundfalse

Requires Docker and Docker Compose. Looks for docker-compose.yml in the current directory.

apso migrate

Write the migration for a schema change without losing data. apso migrate regenerates the code, compares .apsorc with the deployed schema, and asks about every change whose intent the schema can't show: was a missing field renamed or dropped, how does a field split, what replaces a removed enum value, what do existing rows get for a new required field. It then writes the migration from your answers (a TypeORM migration for TypeScript, an Alembic revision for Python, a goose file for Go), saves the answered plan beside it, and tests it on a local PGlite copy of the deployed schema.

apso migrate --baseline deployed.apsorc     # first time: the .apsorc that is deployed
apso migrate                                # later runs find the baseline from the last migration
apso migrate --answer field:Contact.phone=rename:mobilePhone
apso migrate --seed seed.sql --check checks.sql

In a terminal it asks each question. Without one (or with --json) it prints the open questions as JSON and exits 2, so a coding agent can answer them with --answer or in .apso/migration-plan.json and run it again. The same answers always produce the same SQL.

The steps are also separate commands: apso migrate plan, apso migrate generate and apso migrate verify. apso migrate sandbox is the older snapshot preview on an empty database (--apply, --reset, --sql).

apso deploy

Deploy the linked service to the Apso platform. Runs a local migration check before deploying.

apso deploy
apso deploy --yes
apso deploy --skip-migrate
apso deploy --no-wait
OptionDescriptionDefault
-y, --yesSkip confirmation promptfalse
--skip-migrateSkip local migration validationfalse
--no-waitTrigger deploy without waiting for completionfalse

If schema changes are detected, apso deploy shows the migration SQL and asks for confirmation before proceeding. If the migration fails locally, the deploy is blocked.

apso login

Authenticate with the Apso platform via browser-based OAuth or API token.

apso login
apso login --token <api-token>
OptionDescription
-t, --tokenAPI token for non-interactive login (CI/CD)

apso logout

Clear stored credentials.

apso logout

apso whoami

Display information about the current authenticated user and linked project.

apso whoami

Link the current project to a platform service.

apso link
apso link --workspace my-team --service my-api
apso link --force
OptionDescription
-w, --workspaceWorkspace slug
-s, --serviceService slug
-f, --forceOverwrite existing link without confirmation

Remove the link between the current project and the platform.

apso unlink

apso status

Show the current service and latest build status.

apso status

apso logs

View build logs for the linked service.

apso logs
apso logs <build-id>

apso open

Open the service dashboard or API endpoint in the browser.

apso open

apso projects

List services in a workspace.

apso projects

apso config

View or modify CLI configuration.

apso config                        # Show all settings
apso config get apiUrl             # Get a specific value
apso config set verbose true       # Set a value
apso config reset                  # Reset to defaults

Configuration keys:

KeyTypeDescription
apiUrlstringPlatform API URL
webUrlstringPlatform web URL
verbosebooleanEnable verbose output
noColorbooleanDisable colored output
telemetryDisabledbooleanOpt out of anonymous telemetry (or apso config set telemetry off)
defaultWorkspacestringDefault workspace slug

Boolean values accept true/false or 1/0.

Environment variables override config file values:

VariableOverrides
APSO_API_URLapiUrl
APSO_WEB_URLwebUrl
APSO_DEBUG=trueverbose
NO_COLOR or APSO_NO_COLOR=truenoColor
APSO_TELEMETRY=0 / DO_NOT_TRACK=1telemetryDisabled

apso schema

Manage schema synchronization between local .apsorc and the platform.

apso schema validate     # Validate local schema
apso schema diff         # Show diff between local and remote
apso schema push         # Push local schema to platform
apso schema pull         # Pull remote schema to local

Global options

These options work with any command:

apso [command] --help       # Show command help
apso [command] --version    # Show CLI version

Telemetry & privacy

The CLI sends anonymous usage data so we can see which commands are used and prioritize accordingly. It is opt-out and carries no personal data.

What is collected: command name (generate, init, deploy, …), CLI version, OS and architecture, Node version, command duration and success, and an anonymous install id (a random UUID stored in your CLI config — not derived from any machine identifier). If you are logged in, events attribute to your Apso account, the same as the web app.

What is never collected: your source code, your .apsorc or schema contents, file paths, environment variable values, or any other file contents.

Opt out any of these ways:

apso config set telemetry off     # persisted in your CLI config
export APSO_TELEMETRY=0            # per-shell
export DO_NOT_TRACK=1             # honors the consoledonottrack.com standard

On first run the CLI prints a one-time notice pointing at these opt-outs. See docs/telemetry.md for full detail. Aggregate public download stats (npm/PyPI) are available via node scripts/usage-stats.mjs.

Supported languages

LanguageFrameworkORMStatus
TypeScriptNestJSTypeORMStable
PythonFastAPISQLAlchemyIn development
GoGinGORMIn development

Contribute

git clone https://github.com/apsoai/cli.git
cd cli
npm install
npm run build

To run commands from the local build:

./bin/run generate
./bin/run migrate --sql

To develop continuously:

npm run build    # Rebuild after changes
npm link         # Make 'apso' command available globally

Testing

npm run test             # Run all tests
npm run test:watch       # Watch mode
npm run test:cov         # Coverage report

Debugging

env DEBUG=* ./bin/run generate

License

MIT

版本与发布记录

@apso/cli 共发布 98 个版本,首次发布于 2020/06/25;过去 12 个月发布了 80 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.47.2latest2026/11/051 天前
0.47.12026/11/051 天前
0.47.02026/11/051 天前
0.46.42026/11/051 天前
0.46.32026/11/042 天前
0.46.22026/11/042 天前

关于 @apso/cli 的常见问题

@apso/cli 是什么?

Apso CLI

如何安装 @apso/cli?

在项目目录运行 npm install @apso/cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 apso,可以用 npx apso 直接运行。

@apso/cli 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@apso/cli 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@apso/cli 需要什么版本的 Node.js?

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

@apso/cli 可以商用吗?

@apso/cli 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@apso/cli 的下载量有多少?

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

@apso/cli 还在维护吗?

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