claude-code-best 084e487943 feat: 新增 artifacts 功能 (#1278)
* feat: 新增 cloud-artifacts 包(Cloudflare Worker HTML artifact 托管)

POST /upload 鉴权上传 HTML 到 R2 返回 hash URL,GET /<7d|30d>/<id>.html
由 Worker 代理读取并直出 text/html。R2 lifecycle rule 自动 7/30 天删除。
独立服务,不被主 CLI 引用(类似 packages/remote-control-server/ 定位)。

Co-Authored-By: glm-5.2 <zai-org@claude-code-best.win>

* docs: 完善 cloud-artifacts 文档并统一出口域名

- CLAUDE.md 加 cloud-artifacts 到 Workspace Packages 表和新增 HTML Artifact Hosting 段落
- docs.json 注册 cloud-artifacts 到运行模式 group
- README 加 Quickstart、架构图(含 Deno Deploy 代理层)、Security Considerations、Troubleshooting
- 统一出口域名为 https://cloud-artifacts.claude-code-best.win(wrangler.toml PUBLIC_URL、test.sh 默认 WORKER_URL、所有文档示例)
- test.sh expect() 加 [via body] fallback:经 Deno Deploy 代理(status 抹平为 200)时按 body 的 error 字段断言

Co-Authored-By: glm-5.2 <zai-org@claude-code-best.win>

* docs: 修正 CLAUDE.md cloud-artifacts 引用死链

之前指向不存在的 docs/features/cloud-artifacts.md(用户未注册到 docs.json),
改为指向已存在的 packages/cloud-artifacts/README.md,并补充生产出口域名
与 Deno Deploy status 抹平副作用的说明。

Co-Authored-By: glm-5.2 <zai-org@claude-code-best.win>

* chore: 同步 cloud-artifacts 测试默认 TOKEN 到新值

用户已通过 wrangler secret put 把生产 TOKEN 改为 claude-code-best,
test.sh 的默认值(之前用旧 token 作 fallback)和注释示例同步更新。
现在直接 bash scripts/test.sh 即可跑通(无需显式传 TOKEN)。

src/index.ts 不依赖具体 token 值(只读 env.TOKEN 做比较),
wrangler.toml 不含 secret,README/.dev.vars.example 用 <your-token>
占位符故无需改。

Co-Authored-By: glm-5.2 <zai-org@claude-code-best.win>

* docs: add artifacts feature implementation plan

* feat(artifact): add cloud-artifacts config with token/URL defaults

Co-Authored-By: glm-5.2 <zai-org@claude-code-best.win>

* feat(artifact): add HTTP client with body-error parsing

Co-Authored-By: glm-5.2 <zai-org@claude-code-best.win>

* feat(artifact): add tool name, description, and prompt

Co-Authored-By: glm-5.2 <zai-org@claude-code-best.win>

* feat(artifact): add buildTool definition with file validation

Co-Authored-By: glm-5.2 <zai-org@claude-code-best.win>

* test(artifact): add end-to-end tool tests for upload/error paths

Co-Authored-By: glm-5.2 <zai-org@claude-code-best.win>

* feat(artifact): export ArtifactTool from builtin-tools barrel

Co-Authored-By: glm-5.2 <zai-org@claude-code-best.win>

* feat(artifact): register ArtifactTool in tools list

Co-Authored-By: glm-5.2 <zai-org@claude-code-best.win>

* feat(artifact): add /use-artifacts bundled skill

Co-Authored-By: glm-5.2 <zai-org@claude-code-best.win>

* feat(artifact): add extractArtifacts message scanner

Scans Message[] for artifact tool_use/tool_result pairs, parses URL/id/expires
from the upload response string, and returns ArtifactInfo[] newest-first.

Co-Authored-By: glm-5.2 <zai-org@claude-code-best.win>

* fix(artifact): scanner type narrowing and url regex

- Use double assertion (`as unknown as Record<string, unknown>`) at lines 30
  and 90 to fix TS2352 per project convention
- Tighten URL_REGEX to avoid capturing trailing punctuation (parens,
  quotes, commas) when URL is embedded in text
- Add test case for array-form tool_result content path

Co-Authored-By: glm-5.2 <zai-org@claude-code-best.win>

* feat(artifact): add ArtifactsMenu Ink component

Co-Authored-By: glm-5.2 <zai-org@claude-code-best.win>

* feat(artifact): add /artifacts slash command entry

Co-Authored-By: glm-5.2 <zai-org@claude-code-best.win>

* feat(artifact): register /artifacts command

Co-Authored-By: glm-5.2 <zai-org@claude-code-best.win>

* fix(artifact): use setClipboard instead of pbcopy for cross-platform support

* fix(artifact): drop userFacingName override so display matches /artifacts

* fix(rcs): add resJson helper to resolve strict mode type errors in tests

Hono Response.json() returns Promise<unknown> under strict TypeScript,
causing 121 TS errors across middleware and routes test files.

Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>

* fix(cloud-artifacts): add type stubs so tsc passes without worker-configuration.d.ts

The wrangler-generated worker-configuration.d.ts is gitignored, causing CI to
fail with missing ExportedHandler/Env/R2Bucket types. This file provides minimal
stubs for all Cloudflare Workers types used by the artifact upload Worker.

Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>

* fix(query): shallow-copy messages before stripping toolUseResult

Previously the per-query cleanup mutated messagesForQuery entries in
place via `delete msg.toolUseResult`. Those entries are references
shared with mutableMessages (UI state), so the delete stripped the
field from the live message object. The next query can start within
milliseconds of tool_result creation — before the React UI commit
lands — so UserToolSuccessMessage's `!message.toolUseResult` check
returned null and tool.renderToolResultMessage was never called,
leaving tool-result rows blank.

Map to a stripped copy instead so mutableMessages keeps the original
for the UI. Downstream API transformations (applyToolResultBudget,
snip, microcompact) already build new arrays via .map(), so they
compose cleanly with this copy.

Co-Authored-By: glm-5.2 <zai-org@claude-code-best.win>

* feat(artifact): show uploaded URL inline below ExecuteExtraTool

Deferred tools (shouldDefer: true) are invoked via SearchExtraTools →
ExecuteExtraTool, so their tool_result rows used to render blank —
the UI looked up ExecuteExtraTool, which had no renderToolResultMessage,
and returned null. Add a generic delegation in ExecuteTool that forwards
renderToolResultMessage to the inner tool when it defines one, unwrapping
the { result, tool_name } envelope and the params from the input shape.
All 28 deferred tools can now render their own UI by defining
renderToolResultMessage.

For ArtifactTool specifically, render the uploaded URL as an OSC 8
hyperlink (Link component) in warning color so it's visually prominent,
with the expiry timestamp on a second line and a separate error branch.
Also add `error: z.string().optional()` to outputSchema — zod's default
strip mode was dropping the field, so error states never reached the UI.

Co-Authored-By: glm-5.2 <zai-org@claude-code-best.win>

* fix(cloud-artifacts): make Env stubs actually take effect in CI

The previous stub file (2e29e362) wrapped `interface Env` in
`declare global { ... }`, but the file has no top-level import/export so
it's a script, not a module. TS2669 forbids `declare global` in scripts,
and in .d.ts files that error is silently swallowed — so the Env stubs
were never merged into the global scope. Locally typecheck passed only
because worker-configuration.d.ts (gitignored) provided Env separately;
in CI / fresh clones, `BUCKET`, `MAX_BYTES`, `DEFAULT_TTL_DAYS`,
`PUBLIC_URL` were all missing on Env.

Drop the wrapper. Top-level `interface Env` in a script .d.ts is already
global ambient and merges with worker-configuration.d.ts via interface
declaration merging, so both environments typecheck cleanly.

Co-Authored-By: glm-5.2 <zai-org@claude-code-best.win>

---------

Co-authored-by: glm-5.2 <zai-org@claude-code-best.win>
2026-06-20 19:52:08 +08:00
2026-05-04 23:53:28 +08:00
2026-06-20 19:52:08 +08:00
2026-05-01 21:39:30 +08:00
2026-05-01 21:39:30 +08:00
2026-04-19 08:45:06 +08:00
2026-06-20 19:52:08 +08:00
2026-06-15 00:28:17 +00:00
2026-04-11 23:22:55 +08:00
2026-06-09 11:50:46 +08:00
2026-04-06 11:04:13 +08:00
2026-05-01 21:39:30 +08:00
2026-06-18 15:19:26 +08:00
2026-05-31 22:11:29 +08:00
2026-04-01 08:54:08 +08:00

Claude Code Best V5 (CCB)

GitHub Stars GitHub Contributors GitHub Issues GitHub License Last Commit Bun

Which Claude do you like? The open source one is the best.

A reverse-engineered / decompiled source restoration of Anthropic's official Claude Code CLI tool. The goal is to reproduce most of Claude Code's functionality and engineering capabilities. It's abbreviated as CCB.

Documentation (Chinese) — PR contributions welcome.

Sponsor placeholder.

  • v1: Basic runability and type checking pass
  • V2: Complete engineering infrastructure
    • Biome formatting may not be implemented first to avoid code conflicts
    • Build pipeline complete, output runnable on both Node.js and Bun
  • V3: Extensive documentation and documentation site improvements
  • V4: Large-scale test suite for improved stability
    • Buddy pet feature restored Docs
    • Auto Mode restored Docs
    • All features now configurable via environment variables instead of bun --feature
  • V5: Enterprise-grade monitoring/reporting, missing tools补全, restrictions removed
    • Removed anti-distillation code
    • Web search capability (using Bing) Docs
    • Debug mode support Docs
    • Disabled auto-updates
    • Custom Sentry error reporting support Docs
    • Custom GrowthBook support (GB is open source — configure your own feature flag platform) Docs
    • Custom login mode — configure Claude models your way
  • V6: Large-scale refactoring, full modular packaging
    • V6 will be a new branch; main branch will be archived as a historical version

I don't know how long this project will survive. Star + Fork + git clone + .zip is the safest bet.

This project updates rapidly — Opus continuously optimizes in the background, with new changes almost every few hours.

Claude has burned over $1000, out of budget, switching to GLM to continue; @zai-org GLM 5.1 is quite capable.

Quick Start

Prerequisites

Make sure you're on the latest version of Bun, otherwise you'll run into all sorts of weird bugs. Run bun upgrade!

  • Bun >= 1.3.11

Install Bun:

# Linux and macOS
curl -fsSL https://bun.sh/install | bash

# Windows (PowerShell)
powershell -c "irm bun.sh/install.ps1 | iex"

Post-installation steps:

  1. Make bun available in the current terminal

    The installer adds ~/.bun/bin to the matching shell configuration file. On macOS with the default zsh shell, you may see:

    Added "~/.bun/bin" to $PATH in "~/.zshrc"
    

    Restart the current shell as the installer suggests:

    exec /bin/zsh
    

    If you use bash, reload the bash configuration:

    source ~/.bashrc
    

    Windows PowerShell users can close and reopen PowerShell.

  2. Verify that Bun is available:

    bun --help
    bun --version
    
  3. Update to latest version (if already installed):

    bun upgrade
    
  • Standard Claude Code configuration — each provider has its own setup method

Command Execution Location

  • Bun installation and checking commands can be run from any directory: curl -fsSL https://bun.sh/install | bash, bun --help, bun --version, bun upgrade
  • Project dependency installation, development mode, and builds must be run from this repository root, the directory containing package.json.

Install

cd /path/to/claude-code
bun install

Run

# Dev mode — if you see version 888, it's working
bun run dev

# Build
bun run build

The build uses code splitting (build.ts), outputting to dist/ (entry dist/cli.js + ~450 chunk files).

The build output runs on both Bun and Node.js — you can publish to a private registry and run directly.

If you encounter a bug, please open an issue — we'll prioritize it.

First-time Setup /login

After the first run, enter /login in the REPL to access the login configuration screen. Select Anthropic Compatible to connect to third-party API-compatible services (no Anthropic account required).

Fields to fill in:

Field Description Example
Base URL API service URL https://api.example.com/v1
API Key Authentication key sk-xxx
Haiku Model Fast model ID claude-haiku-4-5-20251001
Sonnet Model Balanced model ID claude-sonnet-4-6
Opus Model High-performance model ID claude-opus-4-6
  • Tab / Shift+Tab to switch fields, Enter to confirm and move to the next, press Enter on the last field to save
  • Model fields auto-fill from current environment variables
  • Configuration saves to ~/.claude/settings.json under the env key, effective immediately

You can also edit ~/.claude/settings.json directly:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.example.com/v1",
    "ANTHROPIC_AUTH_TOKEN": "sk-xxx",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4-5-20251001",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-4-6",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-4-6"
  }
}

Supports all Anthropic API-compatible services (e.g., OpenRouter, AWS Bedrock proxies, etc.) as long as the interface is compatible with the Messages API.

Feature Flags

All feature toggles are enabled via FEATURE_<FLAG_NAME>=1 environment variables, for example:

FEATURE_BUDDY=1 FEATURE_FORK_SUBAGENT=1 bun run dev

See docs/features/ for detailed descriptions of each feature. Contributions welcome.

VS Code Debugging

The TUI (REPL) mode requires a real terminal and cannot be launched directly via VS Code's launch config. Use attach mode:

Steps

  1. Start inspect server in terminal:

    bun run dev:inspect
    

    This outputs an address like ws://localhost:8888/xxxxxxxx.

  2. Attach debugger from VS Code:

    • Set breakpoints in src/ files
    • Press F5 → select "Attach to Bun (TUI debug)"

Contributors

Star History

Star History Chart

License

This project is for educational and research purposes only. All rights to Claude Code belong to Anthropic.

Description
原汁原昧 Claude Code 可运行,可构建版; Typescript 类型全修复; 企业级可靠性; 安全无毒, lock 文件保真, 可直接 bun i; bun run dev 启动
Readme 524 MiB
Languages
TypeScript 99.8%