添加缺失的项目配置文件,使源码快照可以成功编译和运行: - 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>buddy
parent
16a676ffa3
commit
83fb08926d
@ -0,0 +1,2 @@ |
|||||||
|
dist |
||||||
|
node_modules |
||||||
@ -0,0 +1,77 @@ |
|||||||
|
/** |
||||||
|
* 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; |
||||||
|
} |
||||||
@ -0,0 +1,104 @@ |
|||||||
|
{ |
||||||
|
"name": "@anthropic-ai/claude-code", |
||||||
|
"version": "1.0.0-research", |
||||||
|
"description": "Claude Code CLI - Source snapshot for research", |
||||||
|
"type": "module", |
||||||
|
"main": "src/entrypoints/cli.tsx", |
||||||
|
"bin": { |
||||||
|
"claude": "dist/cli.js" |
||||||
|
}, |
||||||
|
"scripts": { |
||||||
|
"build": "bun run scripts/build.ts", |
||||||
|
"dev": "bun run src/entrypoints/cli.tsx", |
||||||
|
"typecheck": "bun x tsc --noEmit" |
||||||
|
}, |
||||||
|
"dependencies": { |
||||||
|
"@alcalzone/ansi-tokenize": "^0.1.0", |
||||||
|
"@anthropic-ai/bedrock-sdk": "^0.12.0", |
||||||
|
"@anthropic-ai/sdk": "^0.39.0", |
||||||
|
"@anthropic-ai/vertex-sdk": "^0.6.0", |
||||||
|
"@aws-sdk/client-bedrock": "^3.750.0", |
||||||
|
"@aws-sdk/client-bedrock-runtime": "^3.750.0", |
||||||
|
"@aws-sdk/client-sts": "^3.750.0", |
||||||
|
"@azure/identity": "^4.6.0", |
||||||
|
"@commander-js/extra-typings": "^13.1.0", |
||||||
|
"@growthbook/growthbook": "^1.4.0", |
||||||
|
"@modelcontextprotocol/sdk": "^1.11.0", |
||||||
|
"@opentelemetry/api": "^1.9.0", |
||||||
|
"@opentelemetry/api-logs": "^0.200.0", |
||||||
|
"@opentelemetry/core": "^2.0.0", |
||||||
|
"@opentelemetry/resources": "^2.0.0", |
||||||
|
"@opentelemetry/sdk-logs": "^0.200.0", |
||||||
|
"@opentelemetry/sdk-metrics": "^2.0.0", |
||||||
|
"@opentelemetry/sdk-trace-base": "^2.0.0", |
||||||
|
"@opentelemetry/semantic-conventions": "^1.28.0", |
||||||
|
"ajv": "^8.17.0", |
||||||
|
"asciichart": "^1.5.0", |
||||||
|
"auto-bind": "^5.0.0", |
||||||
|
"axios": "^1.7.0", |
||||||
|
"bidi-js": "^1.0.0", |
||||||
|
"chalk": "^5.4.0", |
||||||
|
"chokidar": "^4.0.0", |
||||||
|
"cli-boxes": "^3.0.0", |
||||||
|
"code-excerpt": "^4.0.0", |
||||||
|
"commander": "^13.1.0", |
||||||
|
"diff": "^7.0.0", |
||||||
|
"emoji-regex": "^10.4.0", |
||||||
|
"env-paths": "^3.0.0", |
||||||
|
"execa": "^9.5.0", |
||||||
|
"fflate": "^0.8.0", |
||||||
|
"figures": "^6.1.0", |
||||||
|
"fuse.js": "^7.0.0", |
||||||
|
"get-east-asian-width": "^1.3.0", |
||||||
|
"google-auth-library": "^9.15.0", |
||||||
|
"highlight.js": "^11.11.0", |
||||||
|
"https-proxy-agent": "^7.0.0", |
||||||
|
"ignore": "^7.0.0", |
||||||
|
"indent-string": "^5.0.0", |
||||||
|
"jsonc-parser": "^3.3.0", |
||||||
|
"lodash-es": "^4.17.0", |
||||||
|
"lru-cache": "^11.0.0", |
||||||
|
"marked": "^15.0.0", |
||||||
|
"p-map": "^7.0.0", |
||||||
|
"picomatch": "^4.0.0", |
||||||
|
"proper-lockfile": "^4.1.0", |
||||||
|
"qrcode": "^1.5.0", |
||||||
|
"react": "^19.0.0", |
||||||
|
"react-reconciler": "0.33.0", |
||||||
|
"semver": "^7.6.0", |
||||||
|
"sharp": "^0.33.0", |
||||||
|
"shell-quote": "^1.8.0", |
||||||
|
"signal-exit": "^4.1.0", |
||||||
|
"stack-utils": "^2.0.0", |
||||||
|
"strip-ansi": "^7.1.0", |
||||||
|
"supports-hyperlinks": "^3.1.0", |
||||||
|
"tree-kill": "^1.2.0", |
||||||
|
"turndown": "^7.2.0", |
||||||
|
"type-fest": "^4.30.0", |
||||||
|
"undici": "^7.3.0", |
||||||
|
"usehooks-ts": "^3.1.0", |
||||||
|
"vscode-jsonrpc": "^8.2.0", |
||||||
|
"vscode-languageserver-protocol": "^3.17.0", |
||||||
|
"vscode-languageserver-types": "^3.17.0", |
||||||
|
"wrap-ansi": "^9.0.0", |
||||||
|
"ws": "^8.18.0", |
||||||
|
"xss": "^1.0.0", |
||||||
|
"yaml": "^2.7.0", |
||||||
|
"zod": "^3.25.0" |
||||||
|
}, |
||||||
|
"devDependencies": { |
||||||
|
"@types/bun": "^1.2.0", |
||||||
|
"@types/diff": "^7.0.0", |
||||||
|
"@types/lodash-es": "^4.17.0", |
||||||
|
"@types/node": "^22.0.0", |
||||||
|
"@types/proper-lockfile": "^4.1.0", |
||||||
|
"@types/qrcode": "^1.5.0", |
||||||
|
"@types/react": "^19.0.0", |
||||||
|
"@types/react-reconciler": "^0.28.0", |
||||||
|
"@types/semver": "^7.5.0", |
||||||
|
"@types/shell-quote": "^1.7.0", |
||||||
|
"@types/stack-utils": "^2.0.0", |
||||||
|
"@types/ws": "^8.5.0", |
||||||
|
"typescript": "^5.7.0" |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,28 @@ |
|||||||
|
{ |
||||||
|
"compilerOptions": { |
||||||
|
"target": "ESNext", |
||||||
|
"module": "ESNext", |
||||||
|
"moduleResolution": "bundler", |
||||||
|
"jsx": "react-jsx", |
||||||
|
"strict": true, |
||||||
|
"esModuleInterop": true, |
||||||
|
"allowImportingTsExtensions": true, |
||||||
|
"noEmit": true, |
||||||
|
"skipLibCheck": true, |
||||||
|
"forceConsistentCasingInFileNames": true, |
||||||
|
"resolveJsonModule": true, |
||||||
|
"isolatedModules": true, |
||||||
|
"declaration": true, |
||||||
|
"declarationMap": true, |
||||||
|
"sourceMap": true, |
||||||
|
"lib": ["ESNext"], |
||||||
|
"types": ["bun-types", "node"], |
||||||
|
"paths": { |
||||||
|
"src/*": ["./src/*"] |
||||||
|
}, |
||||||
|
"baseUrl": ".", |
||||||
|
"rootDir": "." |
||||||
|
}, |
||||||
|
"include": ["src/**/*.ts", "src/**/*.tsx", "scripts/**/*.ts", "globals.d.ts"], |
||||||
|
"exclude": ["node_modules", "dist"] |
||||||
|
} |
||||||
Loading…
Reference in new issue