FN-5850: add AI goal description drafting

Add AI-assisted goal description drafting from the Goals view add form.

- add a readonly AI drafting flow for goal descriptions with title validation and shared rate limiting
- expose a new /api/ai/draft-goal-description endpoint and dashboard API helper for requesting drafts
- add Goals view UI, styling, tests, and dashboard docs covering the draft workflow

Files changed:
 docs/dashboard-guide.md                            |   6 +
 packages/dashboard/app/api/legacy.ts               |  24 +++-
 packages/dashboard/app/components/GoalsView.css    |  14 ++
 packages/dashboard/app/components/GoalsView.tsx    |  46 +++++-
 packages/dashboard/app/components/__tests__/GoalsView.test.tsx    |  50 +++++++
 packages/dashboard/src/__tests__/ai-refine.test.ts |  75 ++++++++++
 packages/dashboard/src/__tests__/routes-agents.test.ts  |  92 ++++++++++++
 packages/dashboard/src/ai-refine.ts                | 155 ++++++++++++++++++---
 packages/dashboard/src/routes.ts                   |  58 ++++++++
 9 files changed, 489 insertions(+), 31 deletions(-)

Fusion-Task-Id: FN-5850

Fusion-Task-Lineage: $#%
!

This commit is contained in:
gsxdsm
2026-06-01 22:50:41 -07:00
parent 70e7a6b30a
commit 41c891d7d8
9 changed files with 489 additions and 31 deletions

View File

@@ -470,9 +470,15 @@ What it shows:
Data behavior:
- Initial load: `GET /api/goals` (returns `{ goals }`)
- Create: inline Add Goal form posts `title` (required) + `description` (optional) to `POST /api/goals`
- Add-form drafting: **Draft with AI** sends the typed goal title to `POST /api/ai/draft-goal-description` and drops the returned `{ description }` into the description textarea for review/editing before save
- Edit: per-card inline form patches title/description via `PATCH /api/goals/:id`
- Archive/unarchive: `POST /api/goals/:id/archive` and `POST /api/goals/:id/unarchive`
AI drafting behavior:
- The add-goal form enables **Draft with AI** once the title is non-empty
- Draft requests are readonly and use the same shared AI-text rate limiter as `/api/ai/refine-text` (10 requests per hour per IP)
- The backend drafts a concise plain-text strategic goal description from the title only; users can freely edit the generated description before saving
Active-goal cap behavior:
- Hard cap of 5 active goals (server-enforced)
- Warning banner appears when active goals are in the 35 range