跪拜 Guibai
← Back to the summary

A TypeScript Monorepo Builds a Coding Agent from an Empty Directory, No Frameworks

Hello everyone, I'm Xiaoyue. It's been a while since I wrote a column series tutorial — the last time I wrote a column was, well, last time. I recently left my job, so I have some free time, and I'm taking this opportunity to write a column: Developing a Coding Agent from Scratch. Agent is one of the hottest directions right now. While learning myself, I'm also sharing with everyone, and we can discuss related knowledge together.

image.png

This column will take you from an empty directory to gradually developing a truly runnable Coding Agent. We won't just wrap a single large model API request; instead, we will fully implement core capabilities such as model interfaces, Agent Loop, tool invocation, file operations, command execution, session storage, context compression, terminal UI, extension systems, and RPC.

The project uses TypeScript, Node.js, npm workspaces, Vitest, and Biome. It adopts an npm workspaces monorepo (single repository, multiple packages) architecture, splitting the system into four software packages with clear responsibilities:

image.png

The tutorial adopts a progressive development approach: first, use a faux provider to build deterministic tests that don't depend on an API Key, then connect to a real large model Provider; first, complete the smallest command-line loop, then gradually add file tools, session recovery, and an interactive terminal interface. This project will not integrate third-party libraries like LangChain or LangGraph for now. I think before learning third-party frameworks, one should first become familiar with how the Agent itself is developed.

After completing the project, you will not only have a Coding Agent that can read and modify code, execute commands, and maintain continuous conversations, but you will also understand how a user prompt sequentially passes through the CLI, Agent Loop, Provider, tool system, session storage, and terminal interface.

If you are also interested in Agent development, welcome to like, bookmark, and follow. Column: Developing a Coding Agent from Scratch - Dongfang Xiaoyue's Column - Juejin

Project address: qddidi/di-code: A programming agent based on TypeScript, Node.js, and large language models, supporting streaming conversations, tool invocation, session persistence, and terminal interaction.

Comments

Top 1 of 2 from juejin.cn, machine-translated. The original thread is authoritative.

练手路过

1. Why not use pnpm to manage the monorepo?

东方小月

2. npm workspaces are already sufficient.