Skip to content

[分享] TypeScript 移植版/A TypeScript port - 同时补强日志可观测性和可测试性 #454

Description

@imzyf

首先感谢作者,这个仓库对我理解 harness 工程帮助很大。我把 s01–s20 完整移植成了 TypeScript,方便习惯 TS / Node 生态的小伙伴跟着学:

  • 官方 SDK + pnpm:LLM 调用走官方 @anthropic-ai/sdk,依赖在根目录用 pnpm 统一管理。
  • 跟上游同步make sync 会从原仓库刷新 Python 参考源码,git diff 正好显示每章要移植的内容——原版更新我也能跟上,不是一次性搬运。
  • 可观测性:每次运行落一对带时间戳的日志——原始 API 流(增量记录、jq 友好)+ 人类可读的会话记录(带每次调用的 token 用量和成本)。
  • 可测试性:用 Vitest + 依赖注入(而不是 mock 模块),测试快、免费、不调真实 API,harness 的机制在代码里始终看得见。

定位是原版的姊妹移植版,不是替代——概念和章节结构完全对齐,只是换成 TS 表达。欢迎看看:

👉 https://github.com/imzyf/learn-claude-code


Thanks for this repo — it really helped me understand harness engineering. I ported all of s01–s20 to TypeScript for folks in the TS / Node world:

  • Official @anthropic-ai/sdk, pnpm workspace
  • make sync refreshes the upstream Python sources, so git diff shows exactly what each chapter migrates — it stays in sync with the original
  • Observability: per-run timestamped logs (incremental, jq-friendly) + a human-readable transcript with token usage & cost
  • Testability: Vitest + dependency injection (no module mocking) — fast, free, never calls the real API

It's a companion port, not a replacement — same concepts, same chapter structure, just in TS.

👉 https://github.com/imzyf/learn-claude-code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions