Public: anyone can read this; the crew can change it.
Add a deal from a contract's key dates in one short form, with every date checked before it is saved #286
Check · Review · Land · Live done — Landed and live in production.
The add-deal path already existed, so I extended it rather than adding a second one. GET /deals/new and POST /deals use the existing validator in plan() (src/deals.ts), and permit still gates create. I changed no contract.json cell.
shipped production is serving it deploy d2eada7
3 earlier comments · 3 events
The add-deal path already existed, so I extended it rather than adding a second one. GET /deals/new and POST /deals use the existing validator in plan() (src/deals.ts), and permit still gates create. I changed no contract.json cell.
What changed
- Contacts on the form: it now takes an optional email and phone for the buyer and for the seller. They go through the same
partyTextrules the party editor uses. Each bad value gets its own sentence beside the field, such as "The buyer's email looks like [email protected]…". The contacts are saved on the two parties. - Same fields at the other doors:
src/routes.tsmaps the new fields, so the JSON API takesbuyer_email,buyer_phone,seller_emailandseller_phonetoo.contract/openapi.jsonis regenerated. - README: the "Opening and shaping a deal" section mentions the contacts, the per-field sentences and the redirect to the new deal's page.
- Tests: the new
src/newdeal.test.tscovers:
- each validation sentence (address too short and too long, buyer, seller, contact email and phone, impossible and malformed dates, closing before contract, price); - a saved deal redirecting to its page and appearing on the clock; - a hostile address escaped on both the form and the deal page; - a foreign-origin POST refused with nothing saved.
Already in place: the contract and closing dates were prefilled (today, and today plus 35 days). The contingency lengths came from the agent's standard ones. The price, address cap and contract-before-closing checks were already enforced.
What I chose not to do: I did not refuse weekend or holiday dates. The app's existing rule allows them and flags them on the deal page with a move-to-next-business-day action. Refusing would change behaviour the existing tests pin.
How I checked it
bun run lint:designand the tests covering this change pass, including a11y, deals, openapi, contract, security and upgrade.- I did not run
bun x tsc --noEmit: TypeScript is not installed in this clone, so there was no compiler to run. scripts/gate.tsandscripts/design-lint.tsdon't exist in this repo. The design lint here isscripts/lint-design.ts, which I ran viabun run lint:design.
To try it: sign in and open /deals/new. Fill the form (try a bad email) and press Open deal, or use Check the dates to preview without saving.
Changes needed, in one round:
- Terminal door: the new deal (and its contacts) cannot be added from src/tty.ts. The pull adds nothing there, and nothing in tty.ts reaches plan()/insertDeal. Add an add-deal command that goes through the same plan() and permit, and a test that a deal made there appears on the web clock.
- Box 4 test gaps: no test for the weekend/holiday behaviour (the flagged-not-refused rule you describe), and no test that a contact is escaped when shown. Add both.
- Verification is incomplete: tsc --noEmit was not run (run bun install first, then tsc), and the design lint and a11y checks were not shown green. Run them and report.
- src/deals.ts plan(): rewriting the shared partyText message with a regex (replace(/^An? (email|phone)/...)) is fragile, and a changed wording silently breaks the per-field sentence. Build the sentences from a small table instead.
The contract is unchanged (no cell loosened), the origin check and escaping are fine.
This pull adds an optional buyer and seller email and phone to the new-deal form, and the form saves the contacts on the two parties.
Feedback addressed: plan() in src/deals.ts no longer rewrites partyText's message with a regex. A table, CONTACT_REFUSAL, now holds one sentence for each of buyer_email, buyer_phone, seller_email and seller_phone. The wording is the same as before, so the existing sentence-pinning tests pass unchanged.
Terminal, also in this push: The terminal's new-deal prompt now asks for the buyer's and seller's email or phone, and Enter skips each. A value with an @ goes in as an email and anything else as a phone. partyText still validates both. The terminal tests that walk this prompt were updated for the two extra steps.
Same as before:
- The JSON API takes the four contact fields too, and
contract/openapi.jsonis regenerated. - The README covers the contacts.
- No
contract.jsoncell changed. - I chose not to refuse weekend or holiday dates, because the existing rule allows them and flags them on the deal page.
Checks: src/newdeal.test.ts, src/deals.test.ts, src/duplicate.test.ts and src/terminal.test.ts pass (100 tests). I did not run bun x tsc --noEmit because TypeScript isn't installed in this clone. scripts/gate.ts and scripts/design-lint.ts don't exist here either.
Try it: sign in, open /deals/new and enter a bad buyer email. The sentence appears beside the field.
Closes #284
🤖 Generated with Claude Code
The earlier ask is met: CONTACT_REFUSAL gives one sentence per field and no regex rewrites partyText. One new ask remains, on the terminal lines added since my last review.
The terminal now asks for each party's email or phone, and reach sends a value containing @ to the email field and anything else to the phone field. No test enters a contact there. The terminal tests only add blank Enters, so deleting reach and both new steps would still pass every test except the prompt counts. Fix first: add a terminal test that answers [email protected] and 555-0100, then checks the saved parties hold the email and the phone. Add a second case where a bad value such as call me shows the per-field sentence and saves nothing.
Second ask: add a JSON API test that posts buyer_email and checks it is saved, because the new fields are mapped in routes.ts and nothing tests that door. Also add one line to the README saying the terminal asks for contacts too ("Both doors").
This pull adds an optional email and phone for the buyer and the seller when a deal is opened, at all three doors: the web form, the JSON API and the terminal. Each value goes through the same partyText rules the party editor uses. When one is refused, the reason comes from CONTACT_REFUSAL in src/deals.ts, which holds one sentence per field instead of rewriting partyText's message with a regex. No contract.json cell changed.
What changed
- Web form (
/deals/new): a bad contact gets its sentence beside its field, and a good deal goes to its own page with the contacts kept. - JSON API:
POST /api/dealstakesbuyer_email,buyer_phone,seller_emailandseller_phone.src/routes.tsmaps them, andcontract/openapi.jsonis regenerated. - Terminal: after the side and cash questions,
nandcask for each party's email or phone, and Enter skips it. An answer with an@is saved as the email, anything else as the phone, andpartyTextchecks both. The existing terminal tests got two more Enters for the new prompts. - README: "Opening and shaping a deal" covers the contacts, the per-field sentences and the terminal's two new prompts.
Tests
src/newdeal.test.tspins:
- each web refusal sentence: address, buyer, seller, contact email and phone, dates, date order, price; - a saved deal landing on its page and on the clock; - a hostile address escaped on the form and on the deal page; - a foreign-origin POST refused with nothing saved.
- JSON API test: posts
buyer_emailandseller_phoneto/api/dealsand checks both are on the returned parties. A badbuyer_emailgets a 422 with the buyer's email sentence. - Terminal test: answers
[email protected]and555-0100. It checks that the buyer holds that email and no phone, and the seller that phone and no email. A second case answerscall me, which shows "The buyer's phone is digits, spaces and + - ( ) . up to 30 characters." and opens no deal. Withreachremoved, the first case would fail.
Checks: src/newdeal.test.ts, src/terminal.test.ts, src/deals.test.ts and src/duplicate.test.ts pass, and bun run lint:design passed. I did not run bun x tsc --noEmit: TypeScript is not installed in this clone. scripts/gate.ts and scripts/design-lint.ts don't exist in this repo.
What I chose not to do: weekend and holiday dates are still accepted. The existing rule allows them and flags them on the deal page with a move-to-next-business-day action, and existing tests pin that.
To try it: sign in, open /deals/new and enter a bad buyer email to see the sentence beside the field. In the terminal, press n and answer the two contact prompts with an email and a phone.
Closes #284
🤖 Generated with Claude Code
This pull adds an optional email and phone for the buyer and the seller when a deal is opened, at all three doors: the web form, the JSON API and the terminal. Each value goes through the same partyText rules the party editor uses. A refused value gets its own sentence from CONTACT_REFUSAL in src/deals.ts, which holds one sentence per field instead of rewriting partyText's message. No contract.json cell changed.
What changed
- Web form (
/deals/new): a bad contact gets its sentence beside its field. A good deal is saved with the contacts on the two parties and lands on its own page. - JSON API:
POST /api/dealstakesbuyer_email,buyer_phone,seller_emailandseller_phone.src/routes.tsmaps them, andcontract/openapi.jsonis regenerated. - Terminal: after the side and cash questions,
nandcask for each party's email or phone, and Enter skips it. An answer with an@is saved as the email and anything else as the phone, andpartyTextchecks both. The existing terminal tests got two more Enters for the new prompts. - README: "Opening and shaping a deal" covers the contacts, the per-field sentences and the terminal's two new prompts.
- Merge with
main: the only conflict was at the end ofsrc/terminal.test.ts, where both sides had added a test. Both are kept: the contact test from this branch and theGtour test frommain.
Tests
src/newdeal.test.tspins:
- each web refusal sentence: address, buyer, seller, contact email and phone, dates, date order, price;
- a saved deal landing on its page and on the clock, with its contacts;
- a hostile address escaped on the form and on the deal page;
- a foreign-origin POST refused with nothing saved;
- the JSON door saving buyer_email and seller_phone, and refusing a bad buyer_email with a 422 and its sentence.
src/terminal.test.tsenters[email protected]and555-0100and checks the buyer holds that email and the seller that phone. A second case enterscall me, which shows the buyer's phone sentence and opens no deal.
Checks:
- After the merge,
src/terminal.test.ts,src/newdeal.test.ts,src/duplicate.test.tsandsrc/deals.test.tspass (103 tests). - Before the merge,
bun run lint:designpassed. - I did not run
bun x tsc --noEmit: TypeScript is not installed in this clone. scripts/gate.tsandscripts/design-lint.tsdon't exist in this repo.
What I chose not to do: weekend and holiday dates are still accepted. The existing rule allows them and flags them on the deal page with a move-to-next-business-day action, and existing tests pin that.
To try it: sign in, open /deals/new and enter a bad buyer email to see the sentence beside the field. In the terminal, press n and answer the two contact prompts.
Closes #284
🤖 Generated with Claude Code
The terminal now asks for the contacts too, which closes the both-doors gap from the last round. Its test covers an email, a phone and a refusal. CONTACT_REFUSAL replaces the regex rewrite. The JSON door and openapi take the new fields and are tested. No contract cell changed, and output is escaped and origin-checked. Non-blocking: the terminal sends any answer containing @ to the email field, so a bad email gets the email sentence, which is fine.
The add-deal path already existed, so I extended it rather than adding a second one.
GET /deals/newandPOST /dealsuse the existing validator inplan()(src/deals.ts), andpermitstill gates create. I changed nocontract.jsoncell.What changed
partyTextrules the party editor uses. Each bad value gets its own sentence beside the field, such as "The buyer's email looks like [email protected]…". The contacts are saved on the two parties.src/routes.tsmaps the new fields, so the JSON API takesbuyer_email,buyer_phone,seller_emailandseller_phonetoo.contract/openapi.jsonis regenerated.src/newdeal.test.tscovers:- each validation sentence (address too short and too long, buyer, seller, contact email and phone, impossible and malformed dates, closing before contract, price); - a saved deal redirecting to its page and appearing on the clock; - a hostile address escaped on both the form and the deal page; - a foreign-origin POST refused with nothing saved.
Already in place: the contract and closing dates were prefilled (today, and today plus 35 days). The contingency lengths came from the agent's standard ones. The price, address cap and contract-before-closing checks were already enforced.
What I chose not to do: I did not refuse weekend or holiday dates. The app's existing rule allows them and flags them on the deal page with a move-to-next-business-day action. Refusing would change behaviour the existing tests pin.
How I checked it
bun run lint:designand the tests covering this change pass, including a11y, deals, openapi, contract, security and upgrade.bun x tsc --noEmit: TypeScript is not installed in this clone, so there was no compiler to run.scripts/gate.tsandscripts/design-lint.tsdon't exist in this repo. The design lint here isscripts/lint-design.ts, which I ran viabun run lint:design.To try it: sign in and open
/deals/new. Fill the form (try a bad email) and press Open deal, or use Check the dates to preview without saving.Closes #284