Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c57ad65
支持buddy命令
Apr 1, 2026
f71530a
修复buddy rehatch的问题
Apr 1, 2026
8e9933e
Merge branch 'claude-code-best:main' into main
smallflyingpig Apr 1, 2026
4d1bc87
Merge branch 'claude-code-best:main' into main
smallflyingpig Apr 2, 2026
2e4d6e2
Update hooks.ts
programming-pupil Apr 2, 2026
e815002
Merge branch 'main' into main
smallflyingpig Apr 2, 2026
1086f68
docs: 增加测试及 auto mode 文档
claude-code-best Apr 2, 2026
8697c91
feat: 完成测试 16-17
claude-code-best Apr 2, 2026
799dacc
test: 新增一波测试文件
claude-code-best Apr 2, 2026
ac1f029
fix: 批量修正 external 字面量
claude-code-best Apr 2, 2026
6f5623b
docs: 完成新版测试文档
claude-code-best Apr 2, 2026
ce29527
test: 添加一大堆测试文件
claude-code-best Apr 2, 2026
4ab4506
fix: 修复 USER_TYPE=ant 时 TUI 无法启动的问题
claude-code-best Apr 2, 2026
68ccf28
feat: 尝试修复 auto mode
claude-code-best Apr 2, 2026
88b45e0
chore: 删除垃圾脚本
claude-code-best Apr 2, 2026
be82b71
feat: 补全 auto mode 分类器 prompt 模板,支持 FEATURE_* 环境变量注入
claude-code-best Apr 2, 2026
991ccc6
chore: 删除 src 下面的 src
claude-code-best Apr 2, 2026
87fdd45
chore: 删除调试代码
claude-code-best Apr 2, 2026
70f32e2
Merge branch 'main' into pr/smallflyingpig/36
claude-code-best Apr 2, 2026
47d8847
docs: 修正 feature 的正确用法
claude-code-best Apr 2, 2026
0d0304d
Merge branch 'pr/smallflyingpig/36'
claude-code-best Apr 2, 2026
7dfbcd0
feat: 更新 buddy 的一些功能
claude-code-best Apr 2, 2026
4337b82
Merge branch 'pr/programming-pupil/33'
claude-code-best Apr 2, 2026
b6f3708
Learn/20260401 (#39)
mingyangxu46-prog Apr 2, 2026
919cf55
feat: 添加开发者默认开启的 feature
claude-code-best Apr 2, 2026
22ca3a1
Merge remote-tracking branch 'origin/main'
claude-code-best Apr 2, 2026
5ee49fd
docs: 添加一大堆 feature 的描述
claude-code-best Apr 2, 2026
c252294
feat: 移除反蒸馏代码
claude-code-best Apr 2, 2026
d04e00f
feat: 调整预先检查的代码
claude-code-best Apr 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ bun run format # format all src/

### Entry & Bootstrap

1. **`src/entrypoints/cli.tsx`** — True entrypoint. Injects runtime polyfills at the top:
- `feature()` always returns `false` (all feature flags disabled, skipping unimplemented branches).
- `globalThis.MACRO` — simulates build-time macro injection (VERSION, BUILD_TIME, etc.).
- `BUILD_TARGET`, `BUILD_ENV`, `INTERFACE_TYPE` globals.
1. **`src/entrypoints/cli.tsx`** — True entrypoint. Sets up runtime globals:
- `globalThis.MACRO` — build-time macro values (VERSION, BUILD_TIME, etc.),通过 `scripts/dev.ts` 的 `-d` flags 注入。
- `BUILD_TARGET`, `BUILD_ENV`, `INTERFACE_TYPE` globals。
- `feature()` 由 `bun:bundle` 内置模块提供,不需要在此 polyfill。
2. **`src/main.tsx`** — Commander.js CLI definition. Parses args, initializes services (auth, analytics, policy), then launches the REPL or runs in pipe mode.
3. **`src/entrypoints/init.ts`** — One-time initialization (telemetry, config, trust dialog).

Expand Down Expand Up @@ -97,7 +97,17 @@ bun run format # format all src/

### Feature Flag System

All `feature('FLAG_NAME')` calls come from `bun:bundle` (a build-time API). In this decompiled version, `feature()` is polyfilled to always return `false` in `cli.tsx`. This means all Anthropic-internal features (COORDINATOR_MODE, KAIROS, PROACTIVE, etc.) are disabled.
Feature flags control which functionality is enabled at runtime. The system works as follows:

- **在代码中使用**: 统一通过 `import { feature } from 'bun:bundle'` 导入,调用 `feature('FLAG_NAME')` 返回 `boolean`。**不要**在 `cli.tsx` 或其他文件里自己定义 `feature` 函数或覆盖这个 import。
- **启用方式**: 通过环境变量 `FEATURE_<FLAG_NAME>=1`。例如 `FEATURE_BUDDY=1 bun run dev` 启用 BUDDY 功能。
- **Dev 模式**: `scripts/dev.ts` 自动扫描所有 `FEATURE_*` 环境变量,转换为 Bun 的 `--feature` 参数传递给运行时。
- **Build 模式**: `build.ts` 同样读取 `FEATURE_*` 环境变量,传入 `Bun.build({ features })` 数组。
- **默认行为**: 不设置任何 `FEATURE_*` 环境变量时,所有 `feature()` 调用返回 `false`,即所有 feature-gated 代码不执行。
- **常见 flag 名称**: `BUDDY`、`FORK_SUBAGENT`、`PROACTIVE`、`KAIROS`、`VOICE_MODE`、`DAEMON` 等(见 `src/commands.ts` 中的使用)。
- **类型声明**: `src/types/internal-modules.d.ts` 中声明了 `bun:bundle` 模块的 `feature` 函数签名。

**新增功能的正确做法**: 如果要让某个 feature-gated 模块(如 buddy)永久启用,应保留代码中 `import { feature } from 'bun:bundle'` + `feature('FLAG_NAME')` 的标准模式,在运行时通过环境变量或配置控制,而不是绕过 feature flag 直接 import。

### Stubbed/Deleted Modules

Expand Down Expand Up @@ -129,9 +139,9 @@ All `feature('FLAG_NAME')` calls come from `bun:bundle` (a build-time API). In t
## Working with This Codebase

- **Don't try to fix all tsc errors** — they're from decompilation and don't affect runtime.
- **`feature()` is always `false`** — any code behind a feature flag is dead code in this build.
- **Feature flags** — 默认全部关闭(`feature()` 返回 `false`)。启用方式见上方 Feature Flag System 章节。不要在 `cli.tsx` 中重定义 `feature` 函数。
- **React Compiler output** — Components have decompiled memoization boilerplate (`const $ = _c(N)`). This is normal.
- **`bun:bundle` import** — In `src/main.tsx` and other files, `import { feature } from 'bun:bundle'` works at build time. At dev-time, the polyfill in `cli.tsx` provides it.
- **`bun:bundle` import** — `import { feature } from 'bun:bundle'` 是 Bun 内置模块,由运行时/构建器解析。不要用自定义函数替代它。
- **`src/` path alias** — tsconfig maps `src/*` to `./src/*`. Imports like `import { ... } from 'src/utils/...'` are valid.
- **MACRO defines** — 集中管理在 `scripts/defines.ts`。Dev mode 通过 `bun -d` 注入,build 通过 `Bun.build({ define })` 注入。修改版本号等常量只改这个文件。
- **构建产物兼容 Node.js** — `build.ts` 会自动后处理 `import.meta.require`,产物可直接用 `node dist/cli.js` 运行。
65 changes: 65 additions & 0 deletions DEV-LOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# DEV-LOG

## 移除反蒸馏机制 (2026-04-02)

项目中发现三处 anti-distillation 相关代码,全部移除。

**移除内容:**
- `src/services/api/claude.ts` — 删除 fake_tools 注入逻辑(原第 302-314 行),该代码通过 `ANTI_DISTILLATION_CC` feature flag 在 API 请求中注入 `anti_distillation: ['fake_tools']`,使服务端在响应中混入虚假工具调用以污染蒸馏数据
- `src/utils/betas.ts` — 删除 connector-text summarization beta 注入块及 `SUMMARIZE_CONNECTOR_TEXT_BETA_HEADER` 导入,该机制让服务端缓冲工具调用间的 assistant 文本并摘要化返回
- `src/constants/betas.ts` — 删除 `SUMMARIZE_CONNECTOR_TEXT_BETA_HEADER` 常量定义(原第 23-25 行)
- `src/utils/streamlinedTransform.ts` — 注释从 "distillation-resistant" 改为 "compact",streamlined 模式本身是有效的输出压缩功能,仅修正描述

---

## Buddy 命令合入 + Feature Flag 规范修正 (2026-04-02)

合入 `pr/smallflyingpig/36` 分支(支持 buddy 命令 + 修复 rehatch),并修正 feature flag 使用方式。

**合入内容(来自 PR):**
- `src/commands/buddy/buddy.ts` — 新增 `/buddy` 命令,支持 hatch / rehatch / pet / mute / unmute 子命令
- `src/commands/buddy/index.ts` — 从 stub 改为正确的 `Command` 类型导出
- `src/buddy/companion.ts` — 新增 `generateSeed()`,`getCompanion()` 支持 seed 驱动的可复现 rolling
- `src/buddy/types.ts` — `CompanionSoul` 增加 `seed?` 字段

**合并后修正:**
- `src/entrypoints/cli.tsx` — PR 硬编码了 `const feature = (name) => name === "BUDDY"`,违反 feature flag 规范,恢复为标准 `import { feature } from 'bun:bundle'`
- `src/commands.ts` — PR 用静态 `import buddy` 绕过了 feature gate,恢复为 `feature('BUDDY') ? require(...) : null` + 条件展开
- `src/commands/buddy/buddy.ts` — 删除未使用的 `companionInfoText` 函数和多余的 `Roll`/`SPECIES` import
- `CLAUDE.md` — 重写 Feature Flag System 章节,明确规范:代码中统一用 `import { feature } from 'bun:bundle'`,启用走环境变量 `FEATURE_<NAME>=1`

**用法:** `FEATURE_BUDDY=1 bun run dev`

---

## Auto Mode 补全 (2026-04-02)

反编译丢失了 auto mode 分类器的三个 prompt 模板文件,代码逻辑完整但无法运行。

**新增:**
- `yolo-classifier-prompts/auto_mode_system_prompt.txt` — 主系统提示词
- `yolo-classifier-prompts/permissions_external.txt` — 外部权限模板(用户规则替换默认值)
- `yolo-classifier-prompts/permissions_anthropic.txt` — 内部权限模板(用户规则追加)

**改动:**
- `scripts/dev.ts` + `build.ts` — 扫描 `FEATURE_*` 环境变量注入 Bun `--feature`
- `cli.tsx` — 启动时打印已启用的 feature
- `permissionSetup.ts` — `AUTO_MODE_ENABLED_DEFAULT` 由 `feature('TRANSCRIPT_CLASSIFIER')` 决定,开 feature 即开 auto mode
- `docs/safety/auto-mode.mdx` — 补充 prompt 模板章节

**用法:** `FEATURE_TRANSCRIPT_CLASSIFIER=1 bun run dev`

**注意:** prompt 模板为重建产物。

---

## USER_TYPE=ant TUI 修复 (2026-04-02)

`global.d.ts` 声明的全局函数在反编译版本运行时未定义,导致 `USER_TYPE=ant` 时 TUI 崩溃。

修复方式:显式 import / 本地 stub / 全局 stub / 新建 stub 文件。涉及文件:
`cli.tsx`, `model.ts`, `context.ts`, `effort.ts`, `thinking.ts`, `undercover.ts`, `Spinner.tsx`, `AntModelSwitchCallout.tsx`(新建), `UndercoverAutoCallout.tsx`(新建)

注意:
- `USER_TYPE=ant` 启用 alt-screen 全屏模式,中心区域满屏是预期行为
- `global.d.ts` 中剩余未 stub 的全局函数(`getAntModels` 等)遇到 `X is not defined` 时按同样模式处理
Loading
Loading