Skip to content

Phase 1: Foundation (Chapters 1-4)

Tasks

CH01: Project Overview & Architecture

  • [x] CH01-CN: 第1章 - 项目总览与架构设计 — 已写成;覆盖技术栈总览、35 模块目录逐一讲解、Tool<Input,Output> 接口、ToolUseContext 依赖注入容器、数据流六阶段、Feature Flag 编译时/运行时用途;含 Mermaid 数据流图
  • [x] CH01-EN: Chapter 01 - Project Overview & Architecture — Written; covers stack, 35-module directory walkthrough, data flow, Tool interface, feature flags, and Mermaid architecture diagrams
  • Acceptance: Reader can explain the overall architecture and locate any module by purpose

CH02: Startup & Bootstrap

  • [x] CH02-CN: 第2章 - 启动流程与初始化 — 已写成;覆盖 cli.tsx 快速路径分发、init.ts 两阶段初始化(信任前/后)、bootstrap/state.ts 单例 vs AppState 对比、模式树分支、ToolUseContext 组装、迁移系统、延迟预取、replLauncher.tsx REPL 渲染;含 Mermaid 启动流程图
  • [x] CH02-EN: Chapter 02 - Startup & Bootstrap — Written; covers cli.tsx fast-path dispatcher, init.ts two-phase initialization (pre/post trust), bootstrap/state.ts singleton vs AppState, mode tree branching, ToolUseContext assembly, migration system, deferred prefetches, and replLauncher.tsx REPL render; includes Mermaid startup flow diagram
  • Acceptance: Reader can trace the full startup path from CLI invocation to REPL rendering

CH03: Core Type System

  • [x] CH03-CN: 第3章 - 核心类型体系 — 已写成;覆盖 Tool<Input,Output,P> 泛型、ToolUseContext 40+ 字段、buildTool() 工厂函数、Command 辨别联合(3 变体)、Task/TaskType/TaskStatus、权限类型系统(PermissionDecisionReason 实际 11 变体)、AppState DeepImmutable 分割、品牌类型;含 Mermaid 类型关系图和任务状态机图
  • [x] CH03-EN: Chapter 03 - Core Type System — Written; covers Tool<Input,Output,P> generics, ToolUseContext 40+ fields, buildTool() BuiltTool<D> type spread, Command discriminated union (3 variants), Task/TaskType/TaskStatus, permission type system (11 PermissionDecisionReason variants, not 9), AppState DeepImmutable split, Branded types, Zod v4 dual-role; includes Mermaid class diagram
  • Acceptance: Reader understands all core type contracts and how they interconnect

CH04: State Management

  • [x] CH04-CN: 第4章 - 状态管理机制 — 已写成;覆盖两层状态架构(bootstrap/state.ts 进程级单例 vs AppState 会话级 store)、35 行 store.ts 的 Object.is 短路与有序通知设计、AppStateStore.ts 的 DeepImmutable<> 分割线及 tasks/mcp 排除原因、AppState.tsx 的 useSyncExternalStore 桥接与 selector 细粒度响应性、selectors.ts 的纯推导函数、onChangeAppState.ts 作为统一副作用汇聚点(权限模式陈旧 Bug 修复历史)、bootstrap/state.ts 的字段分类与"三思而后加"原则;含两层状态架构 Mermaid 图和新增字段的完整实践步骤
  • [x] CH04-EN: Chapter 04 - State Management — Written; covers two-tier architecture (bootstrap/state.ts vs AppState), the 35-line store.ts with Object.is bail-out and ordered notification, AppStateStore.ts DeepImmutable<> split and the tasks/mcp exclusion rationale, AppState.tsx useSyncExternalStore integration and selector-based fine-grained reactivity, selectors.ts pure derivations, onChangeAppState.ts as the side-effect hub (permission-mode stale-state bug fix), bootstrap/state.ts categories and the DO NOT ADD MORE STATE heuristic; includes Mermaid two-tier architecture diagram and complete step-by-step new-field walkthrough
  • Acceptance: Reader can explain the dual-tier state model and implement a new state field

Notes

  • CH01 has no dependencies, can start immediately
  • CH02 and CH03 can run in parallel after CH01
  • CH04 depends on CH03

Built for learners who want to read Claude Code like a real system.