@asiyst/cli

中文文档
1.1.29发布于 2026/11/05MITES Module零依赖近 30 天下载 2571

Connect a local website project to Asiyst

原始使用文档
文档目录7 节
  1. Installation and Execution
  2. Global Installation
  3. Project-Local Installation
  4. On-Demand Execution
  5. Commands
  6. Contract and limitations
  7. Development

Asiyst CLI

The asiyst CLI connects a website that uses @asiyst/sdk to an Asiyst project. It does not render the avatar, chatbot, dashboard, or analytics UI.

Installation and Execution

Global Installation

To use asiyst as a global command:

npm install --global @asiyst/cli
# or with Bun:
bun add -g @asiyst/cli

# Run:
asiyst --version
asiyst connect

Project-Local Installation

To install @asiyst/cli inside a specific project:

npm install --save-dev @asiyst/cli
# or with Bun:
bun add -d @asiyst/cli

Supported project-local invocations:

  • npx:
    npx asiyst --version
    
  • Binary shim:
    # macOS / Linux:
    ./node_modules/.bin/asiyst --version
    
    # Windows PowerShell:
    .\node_modules\.bin\asiyst --version
    
    # Windows CMD:
    node_modules\.bin\asiyst --version
    
  • npm scripts: In package.json:
    "scripts": {
      "asiyst": "asiyst"
    }
    
    Then run:
    npm run asiyst -- status
    
  • Bun:
    bunx asiyst --version
    

On-Demand Execution

npx @asiyst/cli@latest

Commands

The Asiyst CLI behaves like a standard developer tool (such as Git or Supabase CLI). Running asiyst with no arguments displays concise usage information and exits. Each operation is invoked directly as asiyst <command>.

Use asiyst connect --project-id <PROJECT_ID> or asiyst connect to start the authentication and project connection flow. Without --project-id, the authenticated flow uses an arrow-key selector to choose an existing project or create a new one through the secure web handoff, then asks for the public Project ID. The CLI never prompts for a User ID or substitutes the authenticated account ID for a project ID.

Standard commands are login, logout, connect, disconnect, status, project, avatar, sdk, verify, doctor, health, config, update, and restart.

asiyst restart checks the latest available version on npm for the CLI itself, compares semantic versions, prompts for confirmation, safely installs the update for the active environment (global/npx/local), verifies the installed version, and restarts the CLI process automatically while preserving all existing credentials and preventing restart loops.

asiyst sdk displays the status of @asiyst/sdk installed in the current project (declared, installed, latest published npm version). asiyst sdk update checks npm registry for the latest @asiyst/sdk, detects the project package manager (npm, pnpm, yarn, bun), prompts for confirmation, updates @asiyst/sdk in the target project/workspace, and verifies node_modules/@asiyst/sdk/package.json.

asiyst login checks the existing CLI session with the authenticated session endpoint before acting. A valid session is reused without opening the browser; an expired or rejected session is cleared and replaced through browser authorization. If the API cannot be reached, the existing session is preserved and login reports that it could not be verified. With no valid session, browser authorization uses a randomly assigned localhost callback: the CLI registers the callback and state with POST /cli/auth/challenge, opens the returned Asiyst authorization URL, validates the one-time callback code and state, consumes the challenge, and securely stores the verified CLI session. Approval in the browser alone is not treated as a successful login. No User ID, project ID, or API key is requested by login.

asiyst connect --project-id K8mP2xQ7_vL4N9cR5T1zB6Y3
asiyst status
asiyst avatar import --avatar-id A7K9M2QX4P
asiyst disconnect

The connection flow verifies the authenticated account, selected 24-character Project ID, API key, and selected 10-character Avatar ID. The API verifies that the account, key, selected project, and avatar belong together before the connection is saved. Use asiyst connect --project-id <PROJECT_ID> --avatar-id <AVATAR_ID> to bypass project selection and provide both IDs non-interactively; otherwise the CLI opens the relevant dashboard pages and prompts for them. Invalid project IDs can be corrected and retried, while expired sessions and unauthorized projects report actionable errors.

Avatar verification uses the approved CLI contract. Avatar import is currently blocked after verification because the approved contract does not specify the asset upload or file-reference mechanism. The CLI does not send an incomplete import request or modify website files while that information is missing.

GitHub is not part of this CLI flow. GitHub repository authorization and Knowledge Base configuration are managed by Asiyst Web and Supabase. The web dashboard may connect a Knowledge Base to an avatar, but asiyst avatar import does not request GitHub credentials, download repository content, or block an import when GitHub is not connected. The website only receives the SDK integration; the avatar retrieves configured knowledge through the Asiyst backend.

The separation is:

GitHub repository
  -> Asiyst Knowledge Base
  -> Avatar knowledge configuration
  -> Asiyst backend
  -> @asiyst/sdk
  -> Website visitor

The CLI connection flow proceeds as:

Step 1: Authenticated account
  -> Step 2: Existing project selection or secure project creation / verification
  -> Step 3: Domain verification
  -> Step 4: API key verification
  -> Step 5: SDK install & setup
  -> Step 6: Avatar configuration & import
  -> Step 7: Knowledge source connection
  -> Final verification

Interactive startup performs a lightweight npm version check. If a newer release exists, the CLI only displays a notification. It never installs or restarts automatically; run update and confirm to install it. Global installations are updated in place. For npx invocations, the latest package is downloaded and verified for that invocation without changing the website project.

The CLI uses canonical /api/v1/cli/... paths for API-key verification, owner status, avatar verification, and knowledge operations described by docs/sdk-cli-contract.md. Other existing login, onboarding, project-selection, and diagnostic operations have not yet been compared with the Web-published contract. Passwords, AI provider keys, Supabase keys, and private API credentials must never be placed in URLs or logged.

The CLI creates a persistent onboarding session with POST /cli/onboarding/session using the authenticated CLI session. Browser pages are opened through POST /cli/onboarding/handoff, authenticated with that reference in request headers. The response must contain a short-lived, single-use handoffToken; only that token is placed in https://asiyst.com/cli/onboarding/handoff?token=.... The web handoff endpoint must validate and consume the token, establish the existing web session for its verified user, and redirect directly to the requested page (for example /project/new) without routing through /register. Invalid or expired sessions must return SESSION_EXPIRED, so the CLI can ask the user to reconnect rather than silently restarting registration.

Production API defaults to https://nqhxpgsjofzqudyqkqib.supabase.co/functions/v1/api.

Contract and limitations

The local approved design is documented in docs/ASIYST_API_Contract_v1_for_approval.md; it is not yet a code-accurate Web-published contract. Before staging, compare it against the Web-published contract and document differences. Avatar import additionally requires the Web team to specify the actual upload or file-reference mechanism.

Development

npm run build
npm test
npm pack --dry-run

版本与发布记录

@asiyst/cli 共发布 37 个版本,首次发布于 2026/08/28;过去 12 个月发布了 37 个版本。

版本发布日期距今
1.1.29latest2026/11/052 天前
1.1.282026/10/317 天前
1.1.272026/10/2018 天前
1.1.262026/10/1820 天前
1.1.252026/10/1721 天前
1.1.242026/10/1721 天前

关于 @asiyst/cli 的常见问题

@asiyst/cli 是什么?

Connect a local website project to Asiyst

如何安装 @asiyst/cli?

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

@asiyst/cli 支持 TypeScript 吗?

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

@asiyst/cli 支持 ESM 还是 CommonJS?

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

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

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

@asiyst/cli 可以商用吗?

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

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

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

@asiyst/cli 还在维护吗?

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