---
name: deploy-xpages
description: 将生成的静态网页、网站、小游戏等交互式内容发布为 X-Pages 在线链接，或管理已上线的应用。适用于发布、更新、取消发布、隐藏或恢复访问、设置或移除访问密码、要求飞书登录或允许匿名访问；支持单个 HTML 和可构建为静态文件的多文件项目（pages.xingshulin.com）。
metadata:
  version: "2.3.0"
---

# Publish with X-Pages

Publish the user's selected static files to `https://pages.xingshulin.com`. Sign-in availability is controlled by the Feishu application; users manage their own pages. This is a static hosting service, not a backend application runtime.

## Get the client

Use the bundled `scripts/xpages.py` with Python 3.9 or newer. The website publishes this same skill at `/skills/deploy-xpages/SKILL.md`, a versioned ZIP with supporting files, and a SHA-256 digest at `/.well-known/agent-skills/index.json`. If reading online, obtain and verify the complete package before invoking it. Follow the host Agent's normal download, installation and execution rules; reading this page alone does not install a skill.

Reuse an existing installation. For a new installation, use a skill directory supported by the host Agent: prefer its personal directory when writable, otherwise use its workspace directory. If permissions are known to cover only the current workspace, go directly to that workspace directory; do not request elevation or write outside the allowed roots. Use `scripts/skill_manager.py install` with the actual supported directory paths; it falls back from a permission-denied personal directory to the supplied workspace directory. See [installation and explicit upgrades](references/installation.md) for commands, restricted-environment state storage, and manual upgrade recovery.

**Never upgrade automatically.** Run the requested publication with the installed version. After publication or a management operation finishes, the client checks for updates and emits a `skill_version` notice on stderr only when a newer version exists. If that notice is present, briefly report `current_version` and `latest_version` after the task result. When there is no newer version or the check fails, omit all version commentary; do not say “no update” or “version check failed.” Upgrade only when the user explicitly requests it. Do not repeat the client's version check. If the user explicitly asks to check the version, use `check-update` and answer their query even when no update is available.

Do not request tokens in chat or print credentials. The client uses only personal credentials issued after Feishu sign-in. It reuses a valid saved credential; if none is available or it has expired, it starts Feishu sign-in. macOS defaults to Keychain; other systems use a 0700 directory and 0600 file at `~/.config/xpages/`. `--credential-store file` explicitly selects file storage if Keychain cannot be used. State is local to the machine/user; ephemeral runtimes cannot promise reuse after their storage disappears.

## Prepare the publication

For one self-contained HTML file, publish that file. For HTML with local assets or several pages, prepare one ZIP; see [multi-file preparation](references/preparation.md). Preserve the user's original files.

New publication: omit `--site-name`; the server generates a UUID and returns it. Both HTML and ZIP publications return `/app/{siteName}/` URLs. Existing root-level HTML URLs `/{siteName}` remain compatible; retain their ID when updating. Update: use the exact ID from the established page URL or prior receipt. If the update target is ambiguous, resolve it before uploading. To publish a new copy of an already completed identical input, omit the ID and add `--new`. An explicit existing ID overwrites that user's page.

## Publish

Run from this skill directory (or use the actual script path):

```bash
python3 scripts/xpages.py deploy /absolute/path/index.html --title '页面标题'
python3 scripts/xpages.py deploy /absolute/path/app.zip --title '应用标题'
# Update an existing publication:
python3 scripts/xpages.py deploy /absolute/path/app.zip --site-name '<returned-siteName>'
```

If no usable credential exists, the command prints `login_url`, `user_code`, and exits with code 2. Show the link and code to the user. They open the original X-Pages link. A valid website login is reused automatically; otherwise they sign in with Feishu. Success authorizes this tool request and also logs the browser into X-Pages, with homepage and My Applications links; there is no second confirmation button. Before successful authorization, the original link can be reopened in another browser within its 10-minute lifetime. Each browser has its own OAuth attempt; share the original X-Pages URL rather than a redirected Feishu URL. The first successful attempt fixes the account for this request. The URL can also be encoded as a QR code by an available local tool; never encode or display the private device code or token.

After the user completes login, continue with:

```bash
python3 scripts/xpages.py login --wait 45
```

If still pending (exit 2), preserve state and continue after the user responds. A login link lasts 10 minutes. Successful login saves a fixed 30-day X-Pages credential; rerun the original deploy command. The script never prints the credential. This token does not grant Feishu API access.

If the user cancelled browser sign-in, chose the wrong company account, or the callback failed, use `python3 scripts/xpages.py login --restart` to obtain a fresh link immediately. Do not restart a healthy pending sign-in while the user is still completing it.

## Batches and interrupted requests

The script automatically splits ZIPs into batches of at most eight files: the root entry plus at most seven other files, preserving their relative paths. Up to eight files need one batch; nine files need two batches with the entry repeated. Each batch is a complete ZIP sent as raw binary bytes with `Content-Type: application/zip`, without `x-zip-encoding`. The first batch may omit the ID; later batches reuse the first response's ID. Each batch has its own persistent `Idempotency-Key`. Send batches sequentially and stop at the first failure.

On a network timeout, rerun the **same command with the same prepared file and metadata**, on the same machine/user. Pending state and successful batches are stored under `~/.config/xpages/`; the script reuses the pending key and continues from the last acknowledged batch. Do not delete state, regenerate a ZIP with changed contents, choose a different ID, or create a new operation to bypass an uncertain result. A changed file during an unresolved publication is rejected.

- HTTP 401: personal credential invalid; the deploy command clears it and starts sign-in. Resume after login.
- HTTP 403: insufficient permissions to manage this page; report it. Repeated login cannot grant ownership.
- HTTP 409: operation in progress or conflicting request; stop concurrent attempts. Retry later with the same request; persistent in-progress operations require administrator diagnosis.
- HTTP 503 with `Legacy ownership import required`: keep the personal credential and pending request; the administrator must complete verified legacy registration. Do not restart login, request administrator secrets in chat, or call the completion endpoint to bypass the check. Retry the same deployment after the administrator finishes.
- HTTP 502/503 or upload failure: preserve state. Some earlier batches/files may already be visible; report partial publication. Fix availability before retrying the same command.
- An unknown KV/COS write outcome retains the operation lock. A later 409 requires an administrator to verify the upstream writer has stopped before recovery; a timeout alone does not prove cancellation.
- Rerunning an identical completed command returns its saved receipt without another upload, including when terminal output was lost. Use `--new` to explicitly create another copy. Changed input after a completed operation starts a new operation; use `--site-name` if it should update the existing page. An unresolved operation must be recovered first.

Automatic ID generation does not require the Agent to generate an HTML ID. The script generates request keys using a runtime UUID generator; these keys are separate from the server's page ID.

## Verify and report

Publication is complete when all upload batches succeed and the published entry URL returns HTTP 200. Use the client's entry-page HTTP readback for this check; no additional request is needed when it already reports success. Then return the publication result and stop. If the URL returns 404, another error status, or cannot be reached, report that publication access verification failed and preserve the server receipt and retry state. Browser review, screenshots, visual inspection, asset-by-asset checks, navigation tests, and console/network inspection are outside this publishing task; perform them only when the user separately requests them.

Return the accessible URL and `siteName`, and keep them for updates. For prepared multi-file inputs, also report the original entry and any material path repairs. Do not report an incomplete batch sequence as a fully published application.

## Manage published applications

Use the same saved personal Feishu credential for publication and management. Only manage the user's own applications. Resolve the exact `siteName` from a known URL, publication receipt or `sites` results; do not guess a target from an ambiguous title. Use [application management](references/management.md) for password input, pagination, error recovery and direct API requests.

```bash
python3 scripts/xpages.py sites
python3 scripts/xpages.py hide '<siteName>'
python3 scripts/xpages.py show '<siteName>'
python3 scripts/xpages.py require-login '<siteName>'
python3 scripts/xpages.py allow-anonymous '<siteName>'
python3 scripts/xpages.py password '<siteName>' --file /private/path/access-password.txt
python3 scripts/xpages.py password '<siteName>' --clear
python3 scripts/xpages.py unpublish '<siteName>'
```

`unpublish` (also available as `delete`) removes the published application and its serving mappings. Use it for an explicit cancellation/deletion request. `hide` temporarily disables public access while retaining the application in the owner's list; `show` restores visibility but preserves any password. When the user asks only to temporarily disable access, use `hide`. If cancellation versus temporary hiding is unclear, clarify the intended effect before changing anything.

Passwords require 6–128 characters. Provide them through stdin, a private file, or an interactive terminal prompt; never as command-line arguments. Do not echo passwords or include them in the final report. Removing a password does not unhide the application. Report management success from the server response; hidden/deleted pages returning 404 and password-protected pages returning 401 and login-required pages redirecting to login are expected effects, not publication failures. Do not undo those settings to obtain HTTP 200.

```bash
python3 scripts/xpages.py status
python3 scripts/xpages.py logout
```

Logout revokes the current personal credential and removes its local copy. Credentials belong to users, not projects; another login for the same Feishu identity can still manage that identity's pages.

For another authorized X-Pages environment, put `--base-url https://host` before the command. Credentials and pending operations are separated by service origin and account; a renewed credential for the same user can resume that user's operation.

## Direct API clients

Use [OpenAPI](https://pages.xingshulin.com/openapi.json) for request/response details. Authenticate with `Authorization: Bearer <personal-token>` using the credential obtained through the Feishu login flow. Never send the browser cookie as publishing authentication. Missing `htmlkey` creates a new ID; retain the response's `siteName`. Use a stable `Idempotency-Key` per request to recover uncertain writes.

For ZIP publication, send each complete ZIP batch as the raw binary request body to `/html/deploy-zip`, with `Content-Type: application/zip` and no `x-zip-encoding` header. With curl, use `--data-binary @batch.zip`; send the file contents, not its path, JSON or multipart. Single HTML uploads remain raw HTML. The server retains Base64 compatibility for ZIPs up to 4 MiB decoded, but the bundled client uses binary to avoid Base64 expansion and EdgeOne CPU overhead. Larger Base64 requests return HTTP 413 with instructions to use binary.

Clients from version 2.0.0 used Base64 and could encounter HTTP 545 on EdgeOne. Binary upload is available from 2.0.1. If using an affected version, explain the issue and recommend an upgrade; do not silently upgrade. After the user requests and completes the upgrade, rerun the same command with the same file, metadata and saved state. Transport encoding is not part of the server's publication fingerprint: keep the pending request key and page ID. A 545 does not prove that no write happened; if retry returns 409, follow the operation-recovery guidance above.

Before using this client against an older deployment, confirm that the new authentication/idempotency endpoints have actually been deployed. Local code or a downloaded skill does not establish server rollout.


## View published applications

Users can sign in from the site's homepage and open `/my` to see their avatar and recent applications as preview cards. This browser session is separate from the Agent credential: never read browser cookies as a publishing token. Agents can use `sites` or call `GET /auth/sites?limit=20` with their personal Bearer credential, then follow `next_cursor`. The list includes only the current user's successful, non-deleted publications; legacy administrator-owned pages are not automatically claimed. A failed update keeps the previous successful item. Card previews are sandboxed and may not show features requiring cookies/storage/CORS; open `deployUrl` for the actual application.

Users can manage their own applications through the skill commands or the card menu in `/my`: hide/restore, delete, set/change/remove a shared access password, and require/disable visitor Feishu login. Use `require-login <siteName>` to require login and `allow-anonymous <siteName>` to remove that login requirement; neither command changes passwords or hidden state. Any enabled user with a valid X-Pages browser session can view a login-restricted site; only its owner can manage it. Hidden means unavailable to visitors, not removed from the owner list. `GET /auth/sites` includes `hidden`, `hasPassword` and `requireLogin`; never ask for or read the browser session cookie. Republishing preserves access settings. If an existing application is deliberately hidden, password-protected or requires Feishu login, anonymous verification can return 404, 401 or a login redirect respectively; report the successful deployment receipt and restricted access separately after checking the owner's site-list metadata. Do not remove restrictions or request the visitor password merely to make a verification request pass. Public applications still require HTTP 200 for access verification.
