Skip to content

7inspire/learn-claude-code

Repository files navigation

learn-claude-code3

TypeScript 重构版 learn-claude-code。当前版本保留了原项目的阶段化结构,从 s01s12 再到 s_full,重点保持同一条 agent loop、文件系统状态层和工具分发模式。

环境要求

  • Node.js 20+
  • npm 10+
  • Git
  • 可选 .env

环境变量:

  • ANTHROPIC_API_KEY
  • MODEL_ID
  • ANTHROPIC_BASE_URL

可以直接参考 .env.example

安装与验证

npm install --cache .npm-cache
npm run typecheck
npm test
npm run build

阶段入口

以下命令都接受一个字符串任务输入:

npx tsx src/agents/s01_agent_loop.ts "list files"
npx tsx src/agents/s02_tool_use.ts "read package.json"
npx tsx src/agents/s03_todo_write.ts "plan the work"
npx tsx src/agents/s04_subagent.ts "investigate a subproblem"
npx tsx src/agents/s05_skill_loading.ts "load a relevant skill"
npx tsx src/agents/s06_context_compact.ts "compact the context"
npx tsx src/agents/s07_task_system.ts "create a persistent task"
npx tsx src/agents/s08_background_tasks.ts "run a long command"
npx tsx src/agents/s09_agent_teams.ts "add a teammate"
npx tsx src/agents/s10_team_protocols.ts "request plan approval"
npx tsx src/agents/s11_autonomous_agents.ts "idle until work appears"
npx tsx src/agents/s12_worktree_task_isolation.ts "create a worktree for a task"

统一入口:

npx tsx -e 'import { runSFull } from "./src/agents/s_full.ts"; await runSFull("review the repo");'

s_full 命令

s_full 额外支持:

  • /compact
  • /tasks
  • /team
  • /inbox

这些命令由 src/agents/s_full.tshandleFullCommand() 处理。

结构概览

  • src/core Agent loop、tool dispatch、runtime state injection、system prompt 组装
  • src/state Todo、skill、task、background、message bus、protocol、worktree 等状态层
  • src/tools 工具 schema 和 handler
  • src/agents s01s12s_full
  • tests 单元测试、集成测试、冒烟测试

兼容性约定

当前实现尽量保留以下命名:

  • messages
  • TOOLS
  • TOOL_HANDLERS
  • TodoManager
  • TaskManager
  • BackgroundManager
  • MessageBus
  • TeammateManager
  • blockedBy
  • request_id
  • base_ref

兼容别名:

更详细的映射、偏差项和后续增强建议见 docs/implementation-notes.md

About

learn-claude-code (https://github.com/shareAI-lab/learn-claude-code), typescript version

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors