mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-22 16:25:51 +00:00
feat: 完成大部分操作
This commit is contained in:
54
RECORD.md
54
RECORD.md
@@ -103,3 +103,57 @@ const feature = (_name: string) => false; // 所有 feature flag 分支被跳
|
||||
| `scripts/create-type-stubs.mjs` | 自动 stub 生成脚本 |
|
||||
| `scripts/fix-default-stubs.mjs` | 修复默认导出 stub |
|
||||
| `scripts/fix-missing-exports.mjs` | 补全缺失导出 |
|
||||
|
||||
---
|
||||
|
||||
## 五、Monorepo 改造(2026-03-31)
|
||||
|
||||
### 5.1 背景
|
||||
|
||||
`color-diff-napi` 原先是手工放在 `node_modules/` 下的 stub 文件,导出的是普通对象而非 class,导致 `new ColorDiff(...)` 报错:
|
||||
```
|
||||
ERROR Object is not a constructor (evaluating 'new ColorDiff(patch, firstLine, filePath, fileContent)')
|
||||
```
|
||||
同时 `@ant/*`、其他 `*-napi` 包也只有 `declare module` 类型声明,无运行时实现。
|
||||
|
||||
### 5.2 方案
|
||||
|
||||
将项目改造为 **Bun workspaces monorepo**,所有内部包统一放在 `packages/` 下,通过 `workspace:*` 依赖解析。
|
||||
|
||||
### 5.3 创建的 workspace 包
|
||||
|
||||
| 包名 | 路径 | 类型 |
|
||||
|------|------|------|
|
||||
| `color-diff-napi` | `packages/color-diff-napi/` | 完整实现(~1000行 TS,从 `src/native-ts/color-diff/` 移入) |
|
||||
| `modifiers-napi` | `packages/modifiers-napi/` | stub(macOS 修饰键检测) |
|
||||
| `audio-capture-napi` | `packages/audio-capture-napi/` | stub |
|
||||
| `image-processor-napi` | `packages/image-processor-napi/` | stub |
|
||||
| `url-handler-napi` | `packages/url-handler-napi/` | stub |
|
||||
| `@ant/claude-for-chrome-mcp` | `packages/@ant/claude-for-chrome-mcp/` | stub |
|
||||
| `@ant/computer-use-mcp` | `packages/@ant/computer-use-mcp/` | stub(含 subpath exports: sentinelApps, types) |
|
||||
| `@ant/computer-use-input` | `packages/@ant/computer-use-input/` | stub |
|
||||
| `@ant/computer-use-swift` | `packages/@ant/computer-use-swift/` | stub |
|
||||
|
||||
### 5.4 新增的 npm 依赖
|
||||
|
||||
| 包名 | 原因 |
|
||||
|------|------|
|
||||
| `@opentelemetry/semantic-conventions` | 构建报错缺失 |
|
||||
| `fflate` | `src/utils/dxt/zip.ts` 动态 import |
|
||||
| `vscode-jsonrpc` | `src/services/lsp/LSPClient.ts` import |
|
||||
| `@aws-sdk/credential-provider-node` | `src/utils/proxy.ts` 动态 import |
|
||||
|
||||
### 5.5 关键变更
|
||||
|
||||
- `package.json`:添加 `workspaces`,添加所有 workspace 包和缺失 npm 依赖
|
||||
- `src/types/internal-modules.d.ts`:删除已移入 monorepo 的 `declare module` 块,仅保留 `bun:bundle`、`bun:ffi`、`@anthropic-ai/mcpb`
|
||||
- `src/native-ts/color-diff/` → `packages/color-diff-napi/src/`:移动并内联了对 `stringWidth` 和 `logError` 的依赖
|
||||
- 删除 `node_modules/color-diff-napi/` 手工 stub
|
||||
|
||||
### 5.6 构建验证
|
||||
|
||||
```
|
||||
$ bun run build
|
||||
Bundled 5326 modules in 491ms
|
||||
cli.js 25.74 MB (entry point)
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user