@codeworksh/cli

中文文档
0.9.0发布于 2026/11/15MITES Module构建来源已验证近 30 天下载 1.6万

CLI for running CodeWork coding agent harness.

原始使用文档
文档目录12 节
  1. Installation
  2. Development
  3. Commands
  4. codework run
  5. codework thread
  6. codework serve
  7. codework auth login|status|refresh|logout
  8. codework models
  9. codework models refresh
  10. codework plugin add / codework plugin remove
  11. Environment Variables
  12. License

@codeworksh/cli

Run coding-agent sessions in your repo or a sandbox.

Installation

pnpm add -g @codeworksh/cli
# or run directly
pnpm dlx @codeworksh/cli <command>

After install, every command is codework <command>.

Development

From packages/codework, or pnpm cli at the repo root:

pnpm start -- --help
pnpm start -- models
pnpm start -- run "Inspect the failing tests"

start runs src/index.ts with --conditions=development so workspace packages resolve to source. The published codework binary is the packed dist build.


Commands

codework run

Run an agent session with a prompt.

# Start a new session
codework run "Inspect and fix the failing tests"

# Create a session with explicit provider and model
codework run --provider openai --model gpt-5.5 --thinking high "Plan database migration"

# Continue an existing session (its main thread)
codework run --session ses_01a070f0 "Now implement the migration script"

# Continue one of its threads
codework run --session ses_01a070f0 --thread thr_01a071c2 "Try it without the cache"

# Run in an isolated sandbox (local, daytona, vercel, memory, sqldb)
codework run --sandbox-driver daytona "Inspect repository"
codework run --sandbox-driver daytona --sandbox-provider-id <remote-id> "Continue in sandbox"

Flags:

  • --server <url> — Connect to a running RPC server, e.g. ws://127.0.0.1:7433/rpc/v1.
  • -s, --session <id> — Continue an existing session.
  • --thread <id> — Thread of --session to continue: a thread ID, or main (default).
  • -C, --cwd <path> — Working directory for a new session.
  • --sandbox-driver <driver> — Sandbox driver (local, daytona, vercel, memory, sqldb). Default: local.
  • --sandbox-id <id> — Reuse an existing sandbox instance; mutually exclusive with driver/provider coordinates.
  • --sandbox-provider-id <id> — Provider ID of an existing remote sandbox.
  • --provider <id> — Model catalog provider ID.
  • --model <id> — Model ID.
  • --thinking <level> — Reasoning effort the model uses before answering (off, minimal, low, medium, high, xhigh, max).

Global flags: --user-config-dir, --home, --database.


codework thread

A session holds one or more threads: its main thread, and the forks made from it. These commands talk to a running server (--server, default http://127.0.0.1:7433).

# List a session's threads with their model and usage
codework thread list ses_01a070f0

# Start a new thread through an entry, or just before a prompt to send it again
codework thread fork ses_01a070f0 --at <entry-id>
codework thread fork ses_01a070f0 --thread thr_01a071c2 --before <entry-id>

# Move one thread into another checkout of the project, keeping its position under it;
# the rest of the session stays where it is
codework session relink ses_01a070f0 --thread thr_01a071c2 -C ~/work/api

thread fork prints the new thread ID, then for --before the text of the prompt it left out. --json prints the wire form.


codework serve

Start a persistent server that owns sessions and sandboxes:

codework serve --host 127.0.0.1 --port 7433
codework run --server ws://127.0.0.1:7433/rpc/v1 "Inspect the failing tests"
codework run --server ws://127.0.0.1:7433/rpc/v1 --session <id> "Now fix them"
codework run --server ws://127.0.0.1:7433/rpc/v1 --sandbox-id <sandbox-id> "Start another session in this sandbox"

The default address is 127.0.0.1:7433; --port 0 picks an available port and prints the actual URL. Set --home, --database, and --user-config-dir on the server. Model credentials, plugins, and working directories are resolved by the server. A remote run does not boot a local harness.

Events are live and not replayed. The client subscribes before admitting its prompt and waits for execution completion after rendering. Lost connections and overflow fail the command; disconnecting leaves server work running. Ctrl-C sends thread.interrupt, which stops the thread the run prompted. Remote runs print the sandbox ID for reuse. thread.interrupt returns { interrupted } as soon as the stop is accepted; thread.wait is the separate cleanup barrier, and session.interrupt stops every thread of a session. A busy period reports itself as session.execution.started followed by exactly one of succeeded, failed, or interrupted -- a failure carries a category (provider-authentication-error, model-not-found-error, sandbox-mount-error, ...) that the client renders, and an interruption carries whether it was the user or a server shutdown. Managed sandboxes remain available until explicitly stopped or server shutdown; external sandboxes are not stopped.

The v0 endpoint has no authentication; its default binding is loopback. Plugins publish their own event types by declaring them (Plugin.define({ events: [...] }), namespaced plugin.<plugin-id>.*); the feed carries those and skips types nothing declared. Invalid payloads for declared types fail with a typed encoding error.


codework auth login|status|refresh|logout

Sign in to OpenAI Codex with your ChatGPT account, or to GitHub Copilot with your GitHub account. Credentials are stored under the selected Codework home and are loaded automatically when a run uses an openai-codex or github-copilot model.

# Sign in
codework auth login --openai-codex
codework auth login --github-copilot

# Codex without a local callback port (SSH, containers, port 1455 in use)
codework auth login --openai-codex --device

# Inspect credential metadata without printing tokens
codework auth status --openai-codex
codework auth status --github-copilot

# Renew an expired login, or clear one
codework auth refresh --openai-codex
codework auth logout --github-copilot

# Authenticate the home owned by a running RPC server
codework auth login --openai-codex --server ws://127.0.0.1:7433/rpc/v1

--home keeps authentication alongside the rest of that Codework installation; --auth-file overrides the credential file directly. Both providers share one auth.json, keyed by provider, so signing out of one leaves the other alone. With --server, the CLI runs the interactive login locally -- a browser callback and a device prompt both need this terminal -- and sends only the resulting credentials to the RPC server for storage.

OpenAI Codex has two flows. The default keeps Aikit's registered http://localhost:1455/auth/callback redirect, and falls back to asking for the redirect URL if the callback never arrives. --device instead prints a code to enter at auth.openai.com/codex/device and needs no local port at all — use it over SSH, inside a container, or when another sign-in already holds 1455. That port is fixed by the redirect registered against the OAuth client, so it cannot move.

GitHub Copilot uses the GitHub device flow: the CLI prints a user code, opens github.com/login/device, and waits. The token does not expire, so there is no --refresh -- sign in again on persistent 401s. --enterprise <domain> logs into a GitHub Enterprise host, and --enable-models turns on catalog models the account has left unconfigured. Login records the plan-specific Copilot API host, which later runs use in place of the catalog default.


codework models

List catalog models as provider/model, one per line.

# List all models across all providers
codework models

# List models for a specific provider
codework models --provider openai

# List all supported provider IDs
codework models providers

codework models refresh

The model catalog lives at <home>/models.gen.json (~/.codework unless --home says otherwise). Every local command checks it before use and downloads a new one once it is older than 15 minutes (CODEWORK_MODELS_TTL, e.g. "1 hour"); codework serve also re-checks every minute and reloads the file whenever it changes. A failed download keeps the previous catalog.

# Download the catalog if it is missing or stale; no network call otherwise
codework models refresh

# Download it now
codework models refresh --force

codework plugin add / codework plugin remove

Install a plugin and record it in a settings file, or take it back out. Scoping follows npm: the project is the default, -g is user-wide.

# This project: edits .codework/settings.jsonc, creating .codework/ here if no ancestor has one
codework plugin add @acme/[email protected]

# Every project this user runs: writes ~/.codework/settings.jsonc
codework plugin add @acme/[email protected] -g

# Remove it, along with any configuration written against it
codework plugin remove @acme/codework-tool-proc

The project is found the way the harness finds it, and the way git finds a repository: the nearest ancestor holding a .codework directory. Run from packages/app, the command edits the repository's own .codework/settings.jsonc rather than starting a second project beside it. An empty .codework/ is enough — the marker is the directory, so creating it is how you say a project begins here. When no ancestor has one, add creates .codework/ in the directory you are in and prints the path, because that decides where every later plugin entry lands.

add installs and imports the module before writing anything, so a spec that is not a plugin fails with its own error and leaves the file untouched; the line it prints names the plugin ID the module actually declared. Adding a plugin that is already configured under another spelling — a different version, or the path instead of the package — rewrites that entry in place rather than leaving a second loader behind, the way npm install pkg@2 updates the spec already recorded. Configuration written against the plugin is left where it is. Edits preserve comments, key order and formatting, and are written through a temp file so an interrupted run cannot truncate your settings.

remove drops the module entry and any configuration object naming the same plugin, whichever spelling each was written with: the version it was added with is not part of its identity, and the ID a module declares removes the entry that loads it. Resolving an ID reads what is installed and never fetches anything. A plugin can also be kept but switched off without removing it, with { "plugin": "acme.tool.proc", "enabled": false }.

Flags:

FlagDescription
-g, --globalEdit the user-wide settings file instead of this project's
--homeWhere that user-wide file lives (default: CODEWORK_HOME_DIR, else ~/.codework)
--user-config-dirEdit <dir>/settings.jsonc; outranks both of the above

Plugin entries accumulate across settings layers, so a user-wide plugin still applies inside a project that declares its own. A project that wants an inherited plugin gone says so in its own file, with { "plugin": "<id>", "enabled": false }.


Environment Variables

VariableDescription
CODEWORK_MODELS_FILEPin the catalog to a file you manage; never refreshed automatically
CODEWORK_MODELS_TTLHow old the catalog may get before a refresh (default 15 minutes)
OPENAI_API_KEYAPI key for OpenAI models
ANTHROPIC_API_KEYAPI key for Anthropic models
OPENROUTER_API_KEYAPI key for OpenRouter models
GOOGLE_GENERATIVE_AI_API_KEYAPI key for Google models
XAI_API_KEYAPI key for xAI models

License

MIT

版本与发布记录

@codeworksh/cli 共发布 172 个版本,首次发布于 2026/09/18;过去 12 个月发布了 172 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.9.0latest2026/11/15今天
0.9.0-dev.20261115060350dev2026/11/15今天
0.8.0-canary.154.1.g51a2e58acanary2026/11/15今天
0.8.0-canary.153.1.gb9173fe62026/11/151 天前
0.8.0-canary.152.1.g0c0579e72026/11/151 天前
0.8.0-canary.151.1.g648247082026/11/141 天前

关于 @codeworksh/cli 的常见问题

@codeworksh/cli 是什么?

CLI for running CodeWork coding agent harness.

如何安装 @codeworksh/cli?

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

@codeworksh/cli 支持 TypeScript 吗?

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

@codeworksh/cli 支持 ESM 还是 CommonJS?

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

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

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

@codeworksh/cli 可以商用吗?

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

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

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

@codeworksh/cli 还在维护吗?

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