Command-line client for the Polyant management API
翻译准备中
正在加载完整 README。
查看完整 README ↗polyant-cli is the transport between a local coding agent and a Polyant instance.
It resolves a target and its credential, forwards requests to the management
API, and reports results with stable exit codes.
It wraps the management API's routes as commands, but stops short of the request
bodies: a structured payload arrives as --file <path|-> and is forwarded as
given. The engine owns those schemas, and duplicating them here would guarantee
drift. What the CLI does own is everything around the call — resolving the target
and the credential, recapping a write before it happens, and turning the answer
into an exit code.
The selected target serves interactive API documentation at /api/docs and the
raw OpenAPI contract at /api/openapi.json. Some request body schemas are not
yet published there; use the route documentation or engine source for those
payloads instead of guessing them.
Requires Node 20 or newer (engines enforces it). The CLI is distributed
from this repository over https, and nowhere else: there is no npm registry
package. Each release is a v<version> tag with a GitHub Release.
Install the release tarball attached to the GitHub Release:
npm install -g https://github.com/polyant-ai/polyant-cli/releases/download/v0.9.1/polyant-ai-cli-0.9.1.tgz
Then polyant-cli --version works in any shell. The tarball carries the
compiled dist/. Installing the git URL globally (npm install -g git+https://…) does not work: npm prepares a git dependency with the global flag
still set, so the build tools never reach the clone and the install fails with
tsc: command not found. Bear in mind the trade a global install makes: one
version talks to every instance, including ones whose API has moved on — see
Compatibility.
The CLI's version should follow the API version of the instance it talks to, so a project that scripts against one instance can pin the release tag as a dev dependency:
npm install -D git+https://github.com/polyant-ai/polyant-cli.git#v0.9.1
This one compiles on install: prepare runs tsc, so dist/ is built for you
and no committed build can go stale. Pin the tag rather than a branch, so the CLI
does not move under the project on the next push. The executable lands in
node_modules/.bin, which npm scripts and npx already have on their PATH:
npx polyant-cli --version
Inside package.json scripts, plain polyant-cli works with no prefix:
{ "scripts": { "agents": "polyant-cli agent list" } }
For working on the CLI itself, or installing an unreleased revision:
git clone https://github.com/polyant-ai/polyant-cli.git && cd polyant-cli && npm install && npm run build
npm install already builds through prepare; the explicit npm run build is
there for the rebuild after each edit. Then pick one:
npm link
Links polyant-cli onto your PATH pointing at the clone, so a npm run build is enough to pick up a change — no reinstall. This is the one to use while
developing.
npm i -g .
Installs a copy instead: a snapshot that does not follow your edits.
If neither appeals, or npm link wants permissions you would rather not give it,
an alias needs nothing installed at all:
alias polyant-cli='node /absolute/path/to/polyant-cli/dist/bin.js'
polyant-cli --version
Prints the package version and the Node version. If the command is not found
after a global install, the bin directory under npm prefix -g has to be on your
PATH.
The CLI talks to the engine's management API, so its version has to follow the
instance's. There is no negotiation: a route the engine has not shipped answers
404, which the CLI reports as a usage error.
以上为 README 的开头部分。其余内容请阅读原文。 查看完整 README ↗