Autostar
  [![Platform]()](https://github.com/notch-ai/autosteer/releases) ](https://nodejs.org)
AutoSteer是一个桌面应用程序,它通过多工作区管理增强了您的Claude Code体验。它使用Electron构建,可跨macOS、Linux和Windows(通过WSL)工作,允许您通过持久会话和无缝上下文切换管理多个隔离的工作区。
演示
https://github.com/user-attachments/assets/9c86ef28-7167-41c9-b4e6-7d50ba586ca2
\[!注意\] 本项目不隶属于Anthropic,也不由Anthropics认可或赞助。克劳德是Anthropic,PBC的商标。这是一个使用Claude的独立项目。
特性
- 工作树优先架构-在具有独立文件系统和上下文的隔离工作区中组织项目
- 持久会话-按工作树保存和恢复对话,在工作会话中保持完整的上下文
- 多项目管理-在不同项目之间无缝切换,而不会丢失状态或上下文
- 每个项目选项卡管理-会话选项卡范围为具有自动选择行为和持久状态的项目
- 跨平台-对macOS、Linux和Windows的原生支持(通过WSL)
- 上下文保留-自动保存对话状态,使您能够准确地从中断的地方继续
- 快速上下文切换-在工作树和选项卡之间即时切换
- 令牌使用跟踪-监控令牌使用情况以及每条消息和每个工作树的成本
- 状态面板-查看会话信息、管理MCP服务器和处理MCP身份验证
- 协议跟踪查看器-检查详细的协议消息,以便调试和理解代理行为
- 自定义Slash命令-使用自定义命令模式扩展Claude代码功能(文件:src/commons/utils/slashCommandUtils.ts)
📦 安装
先决条件: 克劳德代码 必须先安装。
快速安装
从以下网址下载适用于您平台的最新版本 发布 页面:
- macOS:下载
.zip文件并提取到应用程序 - Linux:下载
.deb(Debian/Ubuntu)或.rpm(Fedora/RHEL) - 视窗:通过WSL2安装
平台特定说明
有关包括Windows WSL2设置在内的详细安装说明,请参阅 安装.md
🚀 入门指南
# Launch AutoSteer
autosteer
# Launch with debug logging
autosteer --debug启动后,在“设置”中配置您的首选项,并开始在AutoSteer中使用Claude Code!
AutoSteer将配置存储在 ~/.autosteer/ 在所有平台上。
🛠️ 发展
先决条件
- (v20或更高)
- (v9或更高)
- Git
- 特定于平台的构建工具:
- macOS:Xcode命令行工具 - Linux: build-essential 包裹 - 视窗:将WSL与Linux构建工具一起使用
从源头构建
# Clone the repository
git clone https://github.com/notch-ai/autosteer.git
cd autosteer
# Install dependencies
pnpm install
# Run in development mode
pnpm dev
# Run tests
pnpm test
# Build application
pnpm compile
# Package for distribution
pnpm make开发脚本
# Start development server
pnpm dev
# Run unit tests
pnpm test:unit
# Run integration tests
pnpm test:integration
# Run all tests
pnpm test
# Lint code
pnpm lint
# Format code
pnpm format
# Type check
pnpm typecheck
# Compile application (TypeScript + Webpack)
pnpm compile
# Package application for current platform
pnpm package
# Create distributable installers
pnpm make项目结构
autosteer/
├── src/
│ ├── main/ # Electron main process
│ │ └── ipc/ # Inter-process communication layer
│ │ ├── handlers/ # 4 consolidated domain handlers
│ │ │ ├── claude.handlers.ts # Agent, MCP, SlashCommand operations
│ │ │ ├── project.handlers.ts # File, Resource management
│ │ │ ├── git.handlers.ts # Git operations
│ │ │ └── system.handlers.ts # Terminal, Badge, Config, Log, Store, Update
│ │ ├── utils/handlerFactory.ts # Reusable error handling, logging, validation
│ │ └── IpcRegistrar.ts # Centralized handler registration
│ ├── features/ # Domain-based feature organization
│ │ ├── chat/ # Chat feature domain (15 components)
│ │ ├── monitoring/ # Monitoring feature domain (10 components)
│ │ ├── settings/ # Settings feature domain (4 components)
│ │ └── shared/ # Shared components across features (48 components)
│ │ └── components/ # Organized by subdomain
│ │ ├── agent/
│ │ ├── git/
│ │ ├── layout/
│ │ ├── projects/
│ │ ├── session/
│ │ ├── tasks/
│ │ ├── terminal/
│ │ └── ui/
│ ├── components/ # Common UI layer (shadcn/ui primitives)
│ ├── services/ # Application services
│ ├── stores/ # State management (Zustand)
│ ├── hooks/ # React hooks
│ │ └── useSessionTabs.ts # Tab management hook
│ ├── commons/
│ │ ├── utils/ # Utility functions
│ │ │ └── slash-commands/ # Slash command utilities
│ │ ├── contexts/ # React contexts
│ │ ├── constants/ # Constants and config
│ │ │ └── tabs.ts # Tab constants (MAX_TABS, system tab IDs)
│ │ └── config/ # Theme and styling
│ ├── entities/ # Data models (Lite Clean Architecture)
│ ├── types/ # TypeScript types
│ │ └── ui.types.ts # Tab type definitions (SessionTab, MaximizeTab, TabState)
│ └── docs/ # Documentation
│ └── tab-management.md # Tab management guide
├── assets/ # App icons and images
├── tests/
│ ├── unit/ # Unit tests (80% coverage target)
│ ├── integration/ # Integration tests
│ ├── component/ # Playwright component tests
│ └── factories/ # Test data factories
├── scripts/ # Build and release scripts
└── playwright-component.config.ts # Component testing config导入模式: @/features/[domain]/components/[Component]
选项卡管理
AutoSteer提供了强大的选项卡管理,并实现了每个项目的隔离。看 docs/tab-management.md 详细文档。
主要特点:
- 按项目选项卡隔离:只有所选项目的选项卡可见
- 自动选择行为:关闭时自动切换到另一个选项卡
- 持久状态:选项卡选择在应用程序重新启动后仍然有效
- 系统选项卡:终端和更改选项卡始终存在
- 最大化选项卡:用于最大化视图的动态选项卡
配置:
{
"settings": {
"confirmSessionTabDeletion": true
}
}🤝 贡献
我们欢迎捐款!请查看我们的 贡献指南 了解详细信息。
贡献者快速入门
# Fork and clone
git clone https://github.com/YOUR_USERNAME/autosteer.git
cd autosteer
# Install dependencies
pnpm install
# Start development
pnpm dev
# Run tests before committing
pnpm test
pnpm lint
pnpm typecheck🧪 测试
运行测试
我们使用Jest进行单元/集成测试,使用Playwright进行组件/可视化测试:
# Run all tests
pnpm test
# Run unit tests only
pnpm test:unit
# Run integration tests only
pnpm test:integration
# Run tests in watch mode
pnpm test:watch
# Run tests with coverage report
pnpm test:coverage测试覆盖率
涵盖关键功能的关键测试文件:
- 公用事业:
tests/unit/commons/utils/slash-commands/slash_command_utils.test.ts-自定义斜线命令格式 - 钩子:
tests/unit/hooks/useTerminalPool.test.ts-终端池管理 - IPC处理器:
tests/unit/main/ipc/handlers/-整合域处理程序 - 服务:
tests/unit/services/ClaudeCodeService.test.ts-核心Claude代码集成 - 商店:
tests/unit/stores/core.test.ts-国家管理 - 类型:
tests/unit/types/terminal.types.test.ts-终端类型安全 - 实体:
tests/unit/entities/SessionBlock.test.ts-数据模型验证
🔍 跟踪文件格式
AutoSteer为调试SDK消息流创建跟踪文件。这些文件存储在 ~/.autosteer/traces/ 并使用JSONL格式(每行一个JSON对象)。
跟踪文件位置
~/.autosteer/traces/{sessionId}.trace.jsonl跟踪条目格式
每个跟踪条目都是一个JSON对象,其结构如下:
{
"timestamp": "2025-11-09T18:51:35.123Z", // ISO 8601 timestamp
"sessionId": "session-abc123", // Session identifier
"direction": "to-claude" | "from-claude", // Message direction
"rawMessage": { /* SDK message object */ }, // Complete SDK message
"sdkVersion": "^0.1.0", // SDK version
"correlationId": "550e8400-e29b-41d4", // Request/response correlation
"sequenceNumber": 42 // Monotonic sequence per session
}跟踪文件生命周期
- 创造:记录SDK消息时会自动创建跟踪文件
- 旋转:当文件超过100MB时,会进行旋转,并带有时间戳后缀
- 清理:删除项目时,跟踪文件会自动删除
- 手动清理:删除中的文件
~/.autosteer/traces/释放磁盘空间
使用跟踪文件
跟踪文件可用于:
- 调试:检查发送和接收的确切SDK消息
- 性能分析:跟踪消息的时间和顺序
- 错误调查:查看导致错误的消息流
- SDK更新:验证SDK版本之间的消息格式更改
跟踪条目示例
{
"timestamp": "2025-11-09T18:51:35.123Z",
"sessionId": "session-abc123",
"direction": "from-claude",
"rawMessage": {
"type": "assistant",
"uuid": "550e8400-e29b-41d4-a716-446655440000",
"session_id": "session-abc123",
"message": {
"role": "assistant",
"content": [{ "type": "text", "text": "Hello!" }]
}
},
"sdkVersion": "^0.1.0",
"correlationId": "550e8400-e29b-41d4",
"sequenceNumber": 42,
"messageType": "assistant",
"messageSubtype": null
}🔄 SDK迁移指南
概述
本指南帮助开发人员在不破坏现有消息验证的情况下处理Anthropic Claude SDK更新和Pydantic模型更改。
SDK版本更新
更新时 @anthropic-ai/claude-agent-sdk:
- 检查是否有重大变化
- 查看SDK发行说明以了解重大更改 - 使用新的SDK类型进行测试验证 - 如果需要,更新Pydantic模型
- 更新Zod架构
- 地点: src/services/MessageValidator.ts - 将模式与新的SDK类型相匹配 - 通过宽松的验证保持向后兼容性
- 测试验证
pnpm test:unit -- MessageValidator.test.ts- 更新跟踪文档
- 在README中记录新的消息类型
Pydantic模型更改
添加新消息类型
- 更新Python模型
- 遵循现有的BaseModel模式 - 增添 SDKMessage 联合类型
- 更新TypeScript架构
- 在中添加相应的Zod模式 MessageValidator.ts - 加入受歧视的工会 - 更新类型防护装置
- 添加测试
- 为新消息类型添加测试用例 - 测试严格和宽松的验证 - 测试部分提取
例子:
// Add to MessageValidator.ts
const NewMessageTypeSchema = z.object({
type: z.literal('new_type'),
uuid: z.string().uuid(),
session_id: z.string(),
// ... other fields
});处理突发SDK更改
如果SDK更新中断了验证:
- 识别突破性变化
- 检查验证测试失败 - 查看跟踪日志以了解错误模式 - 比较新旧消息结构
- 逐步更新架构
// Old field (deprecated but still supported)
old_field: z.string().optional(),
// New field (preferred)
new_field: z.string().optional(),- 添加迁移逻辑
- 处理新旧格式 - 记录已弃用字段的警告 - 逐步淘汰旧格式
- 版本兼容性
- 在跟踪日志中跟踪SDK版本 - 如果需要,添加版本检查 - 文件版本要求
测试迁移
# Run all validation tests
pnpm test:unit -- MessageValidator
# Test with fixtures
pnpm test:integration -- message-validation
# Check type coverage
pnpm typecheck回滚策略
如果验证在生产中中断:
- 立即:恢复到以前的SDK版本
- 短期的:部署具有宽松验证的修补程序
- 长期:修复架构并重新部署
最佳实践
- 始终使用真实消息夹具进行测试 部署前
- 保持向后兼容性 至少2个SDK版本
- 文档中断更改 在公关描述中
- 使用宽松的验证 作为防止碰撞的后备方案
- 监控跟踪日志 更新后验证失败
🔒 安全
- 进程隔离:代理在单独的进程中运行
- 本地存储:所有数据都保留在您的机器上
- 无遥测:没有数据收集或跟踪
🔧 故障排除
获取帮助
- 通过以下方式报告错误
- 通过以下方式请求功能 讨论
📄 许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。
