09. Study Exercises and Skill Gains
What This Source Can Improve
- Designing serious terminal products rather than simple scripts.
- Structuring tool contracts and permission contexts.
- Building safer shell execution layers.
- Designing model adapter layers that survive real auth and provider complexity.
- Managing long-session state, history, compacting, and UX continuity.
Exercises
- Draw the startup flow from
main.tsxin your own diagram with “before first render” and “after first render” lanes. - List every check that stands between a model-generated shell command and actual execution.
- Recreate a simplified
Tool.tscontract for your own agent project. - Write a mini decision table for
allow / ask / denyaround one dangerous tool. - Summarize the difference between “UI shell,” “tool bus,” and “model adapter” in one paragraph each.
If You Already Have Your Own Agent Framework
If you already have something like a local Qwen-powered terminal agent, the most transferable parts of this source are not the model calls. The best parts to learn from are:
- How the CLI shell is organized as a product
- How Bash and file tools are fenced with policy
- How session state is made durable and recoverable
- How trust and approvals are built into the workflow
Final Study Rule
Do not read this source as “secret sauce.” Read it as a mature example of system decomposition. The skill gain comes from seeing how
a large CLI agent product is partitioned into boot flow, contracts, tools, permissions, adapters, UI, and long-session state.
Source Navigation
Recommended Source Files
source/main.tsxsource/tools/BashTool/BashTool.tsxsource/services/api/client.tssource/tools/FileReadTool/FileReadTool.tssource/services/SessionMemory/sessionMemory.ts
Next Files to Read
source/tools/FileEditTool/FileEditTool.tssource/tools/AgentTool/AgentTool.tsxsource/services/mcp/auth.ts