Commit graph

3 commits

Author SHA1 Message Date
37933ccdc0 feat(orders): quote matching is AI-only
The rule-based matcher no longer writes or shows suggestions: on
2026-10-24 it had left 2,888 on unlinked orders, one quote suggested
to 309 of them.

- createOrder runs the AI order assistant (matchOrder) straight after
  intake when it is switched on, instead of the rule-based suggestion
- order page: Re-match / Try again and the rule-based suggestion card
  are gone; Match with AI is the action, and "Match by reference" saves
  the reference then runs the AI (the run route takes { reference })
- the unauthenticated /orders/[id]/quote-match route is removed
- the sweep route and MCP orders.quote_match_sweep run the AI batch
  (matchUnlinkedOrders, shared with the tick)
- scripts/2026-10-24-clear-rule-quote-suggestions.ts clears the old
  suggestions (dry run unless --apply); replaces the rematch script,
  which would have written rule-based ones again
- also fixes the setState-in-effect lint error on the order page

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 20:49:26 +02:00
34d3422586 docs(orders): order assistant runbook final pass
The runbook now matches the code as built.

- New section: filling the lines from the quote — which lines may be
  filled, what is written, the 5% price doubt, the purple review and
  how it ends, and the board badge.
- The "Fill lines from the quote" switch is no longer described as
  reserved for a later phase, and the tick's bounds now say what the
  code does: 10 orders matched, 10 orders filled, and an order with
  nothing to do does not use up that budget.
- Reading order_items.ai_fill is documented alongside orders.ai_quote_match.
- Live steps confirmed against the code: the migration is
  pb:migrate:order-assistant, ai_quote_match and ai_fill are both in
  IGNORED_FIELDS, the n8n tick is POST /api/v1/orders/assistant/tick,
  and the settings labels are "Order assistant enabled", "Run every
  (minutes)", "Auto-link when sure" and "Fill lines from the quote".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 15:34:00 +02:00
85533245bf feat(orders): order assistant routes, MCP tool and runbook
Task 7 of the AI order assistant plan.

- POST /api/v1/orders/assistant/tick (n8n, assertAgentAuth)
- POST /api/v1/orders/{id}/assistant/run (browser session; 409 for
  "AI is disabled" and "not set up yet")
- MCP orders.assistant_match { orderId } -> matchOrder(force) with a
  TOOL_HINTS entry; deliberately NOT in READ_TOOLS
- docs/order-assistant.md runbook and the AGENTS.md section

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 13:06:51 +02:00