feat: formatList numbers the tasks with { numbered: true } #14
main fromfeat/numbered-list·opened Intent
Why#
Issue #13 asks for numbered tasks in formatList. People paste the list into chats and want to be able to say "task 2". Today every line starts with a - bullet, so tasks carry no speakable numbers. The default output had to stay exactly as it was, because people already use the bullets.
What was asked#
The person asked the agent: "Issue #13 asks for numbered tasks in formatList. People paste the list into chats and want to say 'task 2'. Add an option for it, but keep the default output exactly as it is, because people use the bullets today. Add tests, run the checks, then push a branch and open the pull request that closes #13."
Decisions#
- Options object instead of a bare boolean.
formatList(list, options: FormatOptions = {})withnumbered?: boolean. A baretrueargument was rejected: "An options object keeps the call readable ({ numbered: true }, not a baretrue), and later options can join it without a breaking change." - Numbers come from list position, not task ids. Numbering by task id was rejected because "ids can have gaps after
removeTask, and a reader expects 1, 2, 3." The marker is therefore`${index + 1}.`and the numbers "follow the order of the list". - Tests written first. The numbered-list test was added before the implementation and was watched failing (
expected '- [ ] Ship it…' to be '1. [ ] Ship it…') to confirm it failed for the right reason — the option not existing yet. FormatOptionsis exported. It is re-exported fromsrc/index.tsso callers can type their options.- README documents the option. The API table row became
formatList(list, options?)with a note that{ numbered: true }numbers the tasks.
Architecture#
The change sits in one function: formatList in src/format.ts maps each task to a line whose marker is ${index + 1}. when { numbered: true } is passed and - otherwise, keeps the [x]/[ ] checkbox and title unchanged, joins the lines with \n, and takes an empty default options so existing calls are untouched; FormatOptions is re-exported from src/index.ts and documented in the README.
Review notes#
- Default output unchanged: the existing test still expects
formatList(list)to be- [x] Ship it\n- [ ] Docs, and the suite passed 9/9 after the change; verify the no-options path is byte-identical to before. - Numbering is positional: the numbers renumber whenever the list changes — after
removeTaskleaves gaps in ids, the lines still read 1, 2, 3. A "task 2" said in a chat refers to the current position, not a stable id; check this is the intended behavior. - Falsy handling untested:
numberedis read as a truthy flag, so{}and{ numbered: false }produce bullets; there is no explicit test for those inputs, only for the default call without a second argument. - Empty list:
formatList([], { numbered: true })returns''— covered by a test. - Only
pnpm testandpnpm typecheckwere run. The input contains only the author transcript and no reviewer feedback, so nothing has been second-read yet.
Open questions#
None.
formatList gets an option to number the tasks. With { numbered: true } each line starts with 1., 2., 3. in place of -, so people can say "task 2" when they paste a list into a chat. The default output does not change.
Closes #13
Before and after#


Demo#
What changed#
src/format.ts:formatList(list, options?)takesFormatOptions.numberedwrites<n>.in place of the bullet. The numbers follow the order of the list.src/index.ts: exports theFormatOptionstype.test/tasks.test.ts: two tests, for a numbered list and for an empty list.README.md: the API table shows the option.
How to test#
pnpm test
pnpm typecheck
Or install the package preview of this pull request from the Package previews card, and call formatList(list, { numbered: true }).
- 1
AlemTuzlak linked this to fix #13
tanstack-source published a comment(spam 3%, injection 9%)
Verdict: fixes ✅
I reproduced issue #13 on both commits with a vitest repro (
.factory-repro/repro.test.ts) built from the issue text:- Base
2025880— failed:formatList(list, { numbered: true })returned- [ ] Ship it\n- [x] Docs\n- [ ] Tests— bullets, with the option ignored. - Head
bfa31eb— passed: the output is1. [ ] Ship it\n2. [x] Docs\n3. [ ] Tests, and the default bullet output is unchanged.
The full test suite (11 tests) and
pnpm typecheckalso pass on the head, so the PR closes #13 as asked.TanStack Source bot, fixes-issue agent
- Base
tanstack-source published a comment(spam 1%, injection 24%)
Sign in to join this conversation.
Nice and tidy: this closes #13 exactly as asked, keeps the default output the same, and comes with tests and README docs. 👍
TanStack Source bot, value agent