# Week plan

> Ephemeral Mon–Sun planning per studio with automatic Calendar projection.

**Week plan** (`week-plan-app`) is lightweight weekly planning: what you want to do each day, without turning it into a task, habit, or meal.

It lives in the **Daily** section of the shell (theme `weekplan`, distinct from Today and Notebook). Route: `/week-plan?week=YYYY-MM-DD` (Monday of the week).

<Warning>
  **It is not** [Calendar](/workspace/calendar), [Activities](/workspace/activities), or [Goals](/apps/goals).  
  **It is not** the Nutrition meal planner (`/nutrition/planner`).  
  Every item assigned to a day appears in Calendar automatically. **Later** items have no date, so they stay out until assigned to a day.
</Warning>

## What it includes

- **Date control** first (the same one as Today / Activities / Nutrition): arrows, **Today**, Mon–Sun strip, and a calendar centered on the trigger. It changes the week (`?week=` Monday) and the focused day (`?day=` in Day view). In this planner the strip and arrows respect visible **Days**
- Three views (`?view=`): **Board** (Mon–Sun columns), **List** (grouped by day), and **Day** (focus on one day, `?day=YYYY-MM-DD`) — the `view` param is written on every tab change (including `view=board`)
- Long titles and notes are truncated on the board (2 + 1 lines) and in list/day (2 + 2); the full text appears on hover and in the sheet
- Create and edit in a **side sheet** (same pattern as Calendar / Tasks)
- Fields: title, notes, **day(s)** of the week or **Later** (no day), **week intent** (short text in the header)
- On create, **Days** supports multi-select: one submit creates one item per day (and a weekly series per day, if selected)
- **Later**: a tray under the intent to park items for *this* week until you know the day. Capture in a field + Enter. Drag onto a day to place them. They do not count toward progress, do not appear in Calendar, and cannot be marked done. Dragging a **Weekly** item here pauses the series (this occurrence stays in Later). **Carry over** also brings Later items from the previous week.
- **Add from tasks**: creation-only picker of open tasks; optionally stores `sourceTaskId`. Marking the item done completes the task; unmarking reopens it to `todo`.
- **Link a habit**: picker of active habits; stores `sourceActivityId` (XOR with the task). Marking done writes that day's log; unmarking deletes it. A Later item keeps the link but does not log until it has a day.
- **Repeat every week**: creates a series on the same weekday (e.g. every Wednesday) **from that week onward**. Opening an earlier week does not create copies. **Weekly** chip. Moving the item to another day (board drag or edit) updates the series weekday; already-materialized weeks stay put. Moving it to **Later** or turning the switch off in edit pauses the series (this occurrence stays; it does not reappear in future weeks). **Carry over** does not duplicate series items.
- **Calendar and email**: dated items appear in Calendar without an activation switch. They may be all-day or have a time; email is optional and supports one week, three days, or one day before, or the same day. A linked `calendarReminderId` stores only that optional time/email configuration. Moving an item to **Later** removes its date and linked notification.
- Mark done (`doneAt`) on the board, list, and day views, and from the day line on [Today](/workspace/today). **Hide done** filter (`?hideDone=1`)
- **Days** selector on board, list, and day: hides those weekdays from columns, sections, chips, and the Mon–Sun strip; keeps at least one day visible. The selection is saved in `user_preferences.appearance.weekPlanHiddenDays` (per user)
- **Carry over** unfinished items from the previous week (same weekday; Later still has no day)
- **Add tasks to this week with AI** evaluates up to 50 open tasks against the selected week and its saved intent, then adds up to five clear matches directly to **Later**. The created entries are ordinary task-linked items: they can be moved or deleted normally, and the action never schedules a day, changes a task deadline, creates recurrence, or enables email. The success toast offers Undo; Undo removes only items that have not since been moved, completed, edited, or attached to recurrence.
- Compact week progress (`done/total`; fades when there are no items)
- In board view: reorder with **drag and drop** within a day or between days (arrows as fallback)
- Confirmation on delete
- Deleted items remain in a bounded trash list and can be restored. Restoring an occurrence clears its tombstone but deliberately does not restart a weekly series that was paused when the occurrence was deleted.
- Week anchored to **Monday** (`weekStartsOn: 1`), same as Nutrition

Week plan items remain lightweight planning. Calendar projects their date directly; an optional linked reminder adds time/email metadata without controlling visibility.

## Filters (planner exception)

Week plan **does not** filter by project or tag: items do not belong to Projects/Tags. Work taxonomy lives in [Tasks](/workspace/tasks). Here there is only:

- `?hideDone=1` (client)
- Visible days (persisted preference; applies to board, list, and day; not in the URL)
- **Add from tasks** picker during item creation; tasks never appear in the plan unless explicitly added

## Demo / seed

`bun run api:seed` (studio **Agata Full Demo**) creates the plan for the **current week (UTC Monday)** with Mon–Sun items, **Later**, week intent, a focus on “today”, and unfinished items from the previous week (incl. a Later item) for **Carry over**. Credential: `seed@agata.local` / `SeedDemo123!`.

## Mental model

| Concept | Role |
| --- | --- |
| **Week header** | One plan per `(studio, weekStartDateKey)` + optional `intent` |
| **Item** | Entry for a day (or **Later**, `dateKey` null): title, short notes, done, order, and optional Task / habit links |
| **Weekly series** | `week_plan_series` (one weekday 0–6); each week materializes at most one item |
| **Lazy create** | GET does not create the header; it is created when the first item is written (or when intent is saved). `POST /series/ensure` can create header+items when opening a week with active series |
| **Calendar projection** | `dateKey` controls visibility automatically. A linked reminder is internal optional time/email metadata and is removed when the item moves to Later |

## Routes

| Route | Use |
| --- | --- |
| `/week-plan` | Current-week planner (board view) |
| `/week-plan?week=YYYY-MM-DD` | Same UI for the given Monday |
| `/week-plan?view=board` | Board view (also written when you choose Board) |
| `/week-plan?view=list` | Week list view |
| `/week-plan?view=day&day=YYYY-MM-DD` | Day view |
| `/week-plan?hideDone=1` | Hides done items (client filter) |

## API

Prefix: `/week-plan/profiles/:studioId`.

| Method | Path | Notes |
| --- | --- |
| `GET` | `/by-week?weekStartDateKey=` | Plan + items; `id` is absent if there is no header yet |
| `PATCH` | `/by-week` | Updates `intent` (lazy-creates the header) |
| `POST` | `/items` | Creates item (+ lazy header); optional `dateKey` (Later); optional `sourceTaskId` / `sourceActivityId` / `calendarReminderId` / `repeatWeekly` |
| `PATCH` | `/items/:itemId` | title / notes / done / dateKey (`""` = Later) / sortOrder / links / `clearCalendarReminder` / `clearTaskId` / `clearActivityId` / `repeatWeekly` / `stopRepeating`. Changing `dateKey` on a repeating item updates the series weekday; Later pauses the series |
| `DELETE` | `/items/:itemId` | Soft-delete (does not rematerialize that series date) |
| `GET` | `/items/trash` | Up to 50 deleted items, including deletion time and whether the linked weekly series is paused |
| `POST` | `/items/:itemId/restore` | Restores the occurrence only; it never reactivates a paused weekly series |
| `POST` | `/items/reorder` | DnD: `{ id, sortOrder, dateKey? }[]`. A repeating item moved to another day updates the series weekday; Later pauses the series |
| `POST` | `/series/ensure` | Materializes occurrences of active series in the week (`weekStartDateKey`) |
| `GET` | `/ai-context?weekStartDateKey=` | Bounded authorized week intent, existing task links, and up to 50 open task candidates |
| `POST` | `/ai-add-tasks` | Conditionally creates selected task-linked Later items under an AI operation lease |
| `POST` | `/ai-effects/:operationId/undo` | Removes only unchanged items created by that operation |

Schema details: OpenAPI tag **Week plan**. Schema: [week-plan (DB)](/database/week-plan).

## Eve

Eve exposes five typed Week plan tools in the `daily.weekplan` capability group: read a week, create one logical item on up to seven days, update an item, mark an item done, and manage intent/carry-over/order/trash/restore/repeat. Calendar visibility follows the item's date automatically. Task and Activity synchronization is reported explicitly when the Week plan write succeeds but a linked write fails.

## Related

- [Notebook](/workspace/notebook) — Daily writing  
- [Tasks](/workspace/tasks) — work with project/tags; the plan only optionally references them  
- [Nutrition → Planner](/apps/nutrition) — meals only (`/nutrition/planner`)  
- [Calendar](/workspace/calendar) — canonical agenda; every dated plan item appears automatically
