pi-from-scratch
600 行 TypeScript 写成的超级迷你版 pi,让你轻松从 0 写出属于你的 pi-agent
Runs with mockssource: GitHubhomepageTypeScriptMITcommit 599d0ba646c5
TypeScript, MIT licensed. The project labels itself: agent loop, ai agent, coding agent, llm, llm agent, pi, pi agent and tool calling.
pi-from-scratch runs, with stand-ins for the services it depends on. An Argusic agent installed it in 4 minutes and hit 1 error and fixed every one without help on a clean machine with no GPU, and the whole session was recorded.
Repository installed, TypeScript compiles cleanly, all 25 unit tests pass, and the full agent loop (LLM stream → tool_call → tool execution → result injection → next turn) was exercised end-to-end against a mock OpenAI-compatible streaming API.
What the agent ended up with on a clean machine, in its own words. How this is measured
Measured by Argusic on a fresh machine every time. Every number links to its evidence. Argusic Score 92 of 100 (the mean of this project's run scores).
At a glance
Subject data from GitHub, linked at the top of this page, refreshed . Test data by Argusic (CC BY 4.0); every number links to a run page with the full log, the recording, and their sha256 hashes.
What was measured
From the run that decided this verdict. Every line is a recorded value, not an estimate.
What went wrong, in the agent's own words
The agent's own words, worst first, never rewritten into advice.
- Node.js v18.19.1 is too old for the web/ subproject (requires >=22.13.0 for Next.js 16). The core project (src/) compiles and runs fine on v18.
- Install time
- 4 minutes
- Cold machine to finish
- 5 minutes
- Errors hit and fixed
- 1 hit, 1 fixed with no human help
- How the result was proved
- vitest run: 5 files, 25 tests passed (exit 0). E2E mock: npx tsx test/verify_e2e.ts against mock API produced 9 events across 2 turn loop, tool_execute read real file from disk, returned PASS (exit 0).
- Model tokens used
- 98,691
- Exact commit tested
- 599d0ba646c5
- Container image
- sha256:cdd920bce783
What was not measured
The other half, so you can see exactly how far this evidence goes. A gap is printed as a gap and never filled in.
- Peak GPU memory
- this ran on a CPU machine, so there was no GPU to sample
- Behaviour over a long run
- each attempt uses the smallest documented settings and a fixed time budget, so this measures whether it runs, not how it holds up under load
- Behaviour against real services
- this run was verified against stand-in services only
The end of the recording
The last lines of the terminal session that decided this verdict, exactly as they were recorded.
Now let me compile the full final report. Everything is clean - no leftover test files, no source changes. Here's the complete record: **Install**: `npm install` → 50 packages added. `npx tsc` → compiled without errors. **Test suite**: `npx vitest run` → 5 test files, 25 tests, all passed (agent 3, cli 1, llm 10, tool… **E2E verification (mock)**: I stood up a mock Argusic-compatible streaming API and ran the full ag… - Streamed assistant text from the mock (`"Reading file."`) - Issued a `read_file` tool call — the real `read_file` tool executed against a test file on disk a… - On the second round (tool result present), the mock returned a completion text (`"Confirmed. File… - Emitted 9 events total (assistant_text × 6, tool_call × 1, tool_result × 1, turn_end × 1), built … - Exited with code 0 **Web project** (`cd web && npm install`): dependencies installed, but Node.js v18.19.1 doesn't mee… **No source files were modified**. All changes (temporary test scripts) have been removed.
Replay the whole session, every command from a clean machine to this point.
How it was tested
One agent, one container, no human help. It installs the project the way its own documentation says to, runs it, and fixes what breaks. Everything below is recorded as it happened: the terminal session, the log and the exact commit. The full method.
Strengths and limits
Measured facts, not opinions. How this is written.
What went well
- Installed in 4 minutes.
- Recovered from all 1 error without a human stepping in, which says the failures are documented well enough to solve.
- Licensed MIT, as reported by its host.
- Measured 2 times, so the result is not a one-off.
What did not, or is not known
- Only reached a running state against stand-in services, so nothing here proves it works against the real ones.
Also tested, in the same area
Every one of these was installed and run by Argusic on a clean machine. Nothing appears here that was not tested.
Run history
| tested by | attempt | outcome | score | cost USD | when |
|---|---|---|---|---|---|
| Argusic Runner | 2/3 | Runs with mocks | 92.00 | 0.04 | |
| Argusic Runner | 1/3 | Runs with mocks | 92.00 | 0.02 |
Topics (from GitHub)
agent-loopai-agentcoding-agentllmllm-agentpipi-agenttool-callingtypescripttypescript-tutorial
Embed the badge
Markdown for the project README. It links back here; terms on the terms page.
[](https://argusic.com/subject/pi-from-scratch)Questions
- Does pi-from-scratch run?
- pi-from-scratch runs, with mocks standing in for external services. Argusic installed and launched it on a clean machine in 4 minutes, hitting 1 error on the way, and recorded the session.
- How did Argusic test pi-from-scratch?
- On a fresh, disposable machine, with every command recorded and the repository pinned at commit 599d0ba646c5. 2 attempts are recorded, and the full method is on the methodology page.
- What did it cost to test pi-from-scratch?
- The run that produced this verdict cost $0.04: real compute and model cost, not a list price per million tokens. It is recorded on that run's page.
- How long does pi-from-scratch take to install?
- 4 minutes in the run that decided this verdict, from a clean machine to a running state. That is one measured attempt, not an average.
- Does pi-from-scratch need a GPU?
- Not to start. Argusic reached a running state on a machine with no GPU.
- What goes wrong when installing pi-from-scratch?
- 1 thing broke in the recorded run, and 1 were fixed without human help. Each one, and the time it cost, is listed on this page.
- Where is the evidence for pi-from-scratch?
- All 2 recorded runs are on this page, each linking to its full log and terminal recording, stored with a sha256 fingerprint so it cannot be quietly altered.