Appendix B · section 1 of 32
The Finished Pipeline
Every complete file the chapters ask you to create, in its finished state.
These listings are generated from the chapter sources by scripts/build-appendix.mjs rather than written by hand, so they cannot disagree with the chapters: if a listing here differs from the one you typed, the chapter is where the difference came from.
Where a file grew across several chapters, the version below is the last one — the one the finished pipeline runs. The chapter each listing was completed in is noted beside it.
The pipeline itself — everything under ask/ — is 28 TypeScript files and 2618 lines, the corpus and the tests included. Both numbers are counted from the listings below when this page is generated, so the sentence cannot drift away from the table.
To run the stages that call a model you need ANTHROPIC_API_KEY exported and @anthropic-ai/sdk installed; the stage that embeds needs a Cloudflare account as well, and runs without one as Chapter 5 says. The corpus, the retrieval, the fusion, the check, the chunker, the manifest and every test file call no model and need no credential.
What is here
| File | Completed in | Lines |
|---|---|---|
package.json | Introduction | 18 |
tsconfig.json | Introduction | 14 |
.gitignore | Introduction | 1 |
ask/talk.ts | Talking to a Model | 38 |
ask/setup.ts | Talking to a Model | 33 |
ask/scope.ts | Talking to a Model | 70 |
ask/corpus.ts | Writing From a Book | 278 |
ask/answer.ts | Writing From a Book | 175 |
ask/figures.ts | The Check That Is Not the Model | 81 |
ask/check.ts | The Check That Is Not the Model | 99 |
ask/check.test.ts | The Check That Is Not the Model | 90 |
ask/retrieve.ts | Finding It by Its Words | 137 |
ask/retrieve.test.ts | Finding It by Its Words | 38 |
ask/vectors.ts | Finding It by Meaning | 139 |
ask/fuse.ts | Finding It by Meaning | 52 |
ask/fuse.test.ts | Finding It by Meaning | 33 |
ask/rephrase.ts | Saying It the Law’s Way | 85 |
ask/rerank.ts | Choosing What It Reads | 128 |
ask/schedule.ts | Once Found, Look It Up | 141 |
ask/sections.ts | Once Found, Look It Up | 110 |
ask/widen.test.ts | Once Found, Look It Up | 53 |
ask/chunk.ts | A Corpus You Can Trust | 123 |
ask/manifest.ts | A Corpus You Can Trust | 80 |
ask/corpus.test.ts | A Corpus You Can Trust | 77 |
ask/pipeline.ts | Failing Closed | 128 |
ask/live.ts | Failing Closed | 24 |
ask/ask.ts | Failing Closed | 51 |
ask/eval-cases.ts | Measuring the Whole Thing | 40 |
ask/register.ts | Measuring the Whole Thing | 53 |
ask/eval.ts | Measuring the Whole Thing | 99 |
ask/pipeline.test.ts | Tests That Never Call the Model | 163 |