---
name: dream
description: "Manually trigger aiwiki consolidation. Merges duplicate notes, promotes raw → typed pages, prunes stale entries. Output is written to aiwiki/proposed/{dream_id}/ for review — input store is never modified. Use after a major refactor, a long session, or whenever aiwiki/ feels noisy. Optional argument: scope (default = full aiwiki/; alternatives = aiwiki/raw/, aiwiki/gotchas/, etc.)."
---

# /dream — Consolidate aiwiki

Manual trigger for `support-dream`. Produces a reviewable consolidation proposal in `aiwiki/proposed/{dream_id}/`; you accept or reject via the web view (`forge wiki ui`) or CLI (`forge wiki review {dream_id}`).

This is the user-driven trigger. Dream also fires automatically:
- **PreCompact** — `hooks/scripts/pre-compact.sh` appends a `**Dream directive (unconsumed)**` block to the active session file's `## Checkpoints` section (`aiwiki/sessions/{date}-{session_id_short}.md`, created lazily). The post-compact agent reads the session file, finds the directive, and invokes `support-dream`.
- **Phase-close** — `iterate-prototype`, `harden`, `build-pr-workflow`, and `deliver-deploy` dispatch `support-dream` after writing their respective `artifacts.{phase}.locked_at` lock signal.

The manual `/dream` invocation is the escape hatch for between-trigger consolidation.

## Steps

1. **Parse scope** from the user's argument:
   - No argument → scope is the full `aiwiki/` tree.
   - One token (`raw`, `gotchas`, `decisions`, `conventions`, `architecture`, `sessions`) → scope is `aiwiki/{token}/`.
   - Multiple tokens or explicit path → scope is the union of those paths.
2. **Verify aiwiki exists.** If `aiwiki/` is missing, dispatch `support-wiki-bootstrap` first.
3. **Check for pending dreams.** If `aiwiki/proposed/{dream_id}/` directories already exist with `review_status: pending` in their manifest, surface them to the user and ask whether to queue a new dream or review the pending ones first. Do not silently overwrite.
4. **Invoke `support-dream` skill** with the parsed scope and `trigger: manual`. The skill dispatches the `dreamer` subagent and writes the proposed output.
5. **Report to the user**: new `dream_id`, list of `changed_pages` / `new_pages` / `deleted_pages` counts, lint status, and the path to review:
   ```
   Dream complete: 2026-05-18-1742-manual
     Proposals: aiwiki/proposed/2026-05-18-1742-manual/
     Changed: 3   New: 1   Deleted: 0   Lint: passed
     Review: `forge wiki review 2026-05-18-1742-manual` or open `forge wiki ui`
   ```

## Example

User: `/dream`
→ Full aiwiki consolidation, dispatched as `trigger: manual`.

User: `/dream raw gotchas`
→ Scope limited to `aiwiki/raw/` + `aiwiki/gotchas/`.

User: `/dream after the auth refactor`
→ Free-form description folded into `trigger_detail`; scope defaults to full aiwiki.

## When to use

- After a **major refactor** or **branch merge** brought in lots of new wiki entries.
- When `aiwiki/raw/` has accumulated unclassified notes from `/note` invocations.
- When you suspect **duplicate gotchas** across recent debugging sessions.
- Before **handoff** to a new contributor — get the wiki into curated shape first.
- When `forge wiki status` shows no pending dreams but the aiwiki feels noisy.

## When NOT to use

- A dream is already pending review (`forge wiki status` lists it). Review the existing one first; queueing a new dream against the same source state produces overlapping proposals.
- `aiwiki/` has no recent activity — there's nothing to consolidate; the cycle would no-op.
- You want to **edit a single page**. Edit it directly. Dream is for *merging / promoting / pruning across pages*, not per-page revision.

## I/O Contract

| Field | Value |
|---|---|
| **Requires** | `aiwiki/` (scaffolded by `/setup`), `aiwiki/schemas/` |
| **Produces** | `aiwiki/proposed/{dream_id}/` (mirror structure) + `.dream-manifest.json` |
| **Dispatches** | `support-dream` skill → `dreamer` subagent |
| **Review surface** | `forge wiki ui` (web view at 127.0.0.1:8765) or `forge wiki review/accept/reject` CLI |

## Do NOT

- Do NOT modify `aiwiki/` directly inside this flow — that is `support-dream`'s invariant.
- Do NOT queue a new dream while one is pending review against the same source state.
- Do NOT skip the lint pass — `support-dream` runs lint on the proposed output before marking the dream complete.
