Files
83fb08926d feat: 补充构建配置,实现 Claude Code 源码编译
添加缺失的项目配置文件,使源码快照可以成功编译和运行:
- package.json: 85+ 依赖项 + 构建脚本
- tsconfig.json: TypeScript + JSX + src/ 路径别名
- globals.d.ts: MACRO 构建常量 + bun:bundle 类型声明
- scripts/build.ts: Bun 构建脚本(feature flag polyfill + MACRO 注入 + 内部包 stub + 缺失源文件自动 stub)
- BUILD_GUIDE.md: 中文编译文档
- 修 Commander.js v13 的 -d2e 短标志兼容问题

构建脚本通过 missingSourceStubPlugin 插件自动检测并 stub 缺失的源文件,
无需在源码树中手动创建 stub 文件。

构建结果:dist/cli.js (11.7 MB),CLI 可正常启动并显示交互式终端 UI。

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-01 12:01:06 +08:00

78 lines
2.0 KiB
TypeScript

/**
* Global type declarations for Claude Code build-time constants.
*
* MACRO is defined at bundle time via Bun's --define flag.
* bun:bundle provides compile-time feature flags for dead code elimination.
*/
// Build-time macro constants injected via --define
declare const MACRO: {
/** Application version string, e.g. "1.0.0" */
VERSION: string;
/** ISO 8601 build timestamp, e.g. "2026-03-31T00:00:00Z" */
BUILD_TIME: string;
/** npm package URL, e.g. "@anthropic-ai/claude-code" */
PACKAGE_URL: string;
/** Native package URL for platform-specific binaries */
NATIVE_PACKAGE_URL: string | undefined;
/** Feedback channel URL or description */
FEEDBACK_CHANNEL: string;
/** Instructions for reporting issues */
ISSUES_EXPLAINER: string;
/** Version changelog content */
VERSION_CHANGELOG: string;
};
// Bun's bundle-time feature flag module
declare module "bun:bundle" {
/**
* Returns true if the named feature flag is enabled at bundle time.
* Used for dead code elimination — disabled branches are stripped entirely.
*/
export function feature(name: string): boolean;
}
// Stub declarations for internal Anthropic packages that are not publicly available
declare module "@ant/claude-for-chrome-mcp" {
const mod: any;
export default mod;
export const runClaudeInChromeMcpServer: () => Promise<void>;
}
declare module "@ant/computer-use-input" {
const mod: any;
export default mod;
}
declare module "@ant/computer-use-mcp" {
const mod: any;
export default mod;
export const runComputerUseMcpServer: () => Promise<void>;
}
declare module "@ant/computer-use-swift" {
const mod: any;
export default mod;
}
declare module "@anthropic-ai/claude-agent-sdk" {
const mod: any;
export default mod;
}
declare module "@anthropic-ai/mcpb" {
const mod: any;
export default mod;
}
declare module "@anthropic-ai/sandbox-runtime" {
const mod: any;
export default mod;
}
declare module "color-diff-napi" {
export function diff(a: string, b: string): any;
const mod: any;
export default mod;
}