# __APP_NAME__

A starter project generated by `create-askable-app`.

This template wires together:

- **askable-ui** for UI focus tracking with `useAskable()`
- **app-owned sources** for full deal data beyond the selected DOM row
- **CopilotKit** for the chat sidebar and runtime
- **React + Vite** for the frontend
- **Express + @copilotkit/runtime** for the local backend runtime

## Quick start

```bash
npm install
cp .env.example .env
npm run dev
```

The app opens at `http://localhost:5173` and the Copilot runtime listens on `http://localhost:3001/api/copilotkit`.

## Environment

Update `.env` with your own provider key:

```bash
OPENAI_API_KEY=<your key>
OPENAI_MODEL=gpt-4o-mini
```

If `OPENAI_API_KEY` is blank, the runtime still starts so the dashboard loads, but Copilot responses stay disabled until you add a real key.

## How Askable and CopilotKit fit together

1. Dashboard panels are annotated with `data-askable` metadata and curated `data-askable-text` summaries.
2. `useAskable()` observes the page and produces prompt-ready context like:
   - current focus
   - recent interaction history
3. `useAskableSource()` registers the full priority-deals dataset so CopilotKit can read app state that is not fully represented by the selected DOM row.
4. `useAskableRegionCapture()` adds region, circle, and lasso tools for visual page selection.
5. `useAskableTextSelectionCapture()` lets the user highlight text and send it as context.
6. `useCopilotReadable()` forwards those Askable strings and source summaries into CopilotKit.
7. CopilotKit sends the chat request to the local runtime at `/api/copilotkit`.
8. The runtime calls the LLM and answers with the current dashboard context already attached.

## Starter structure

- `src/App.tsx` — annotated dashboard, app-owned source, and `useCopilotReadable()` wiring
- `src/styles.css` — dashboard styling
- `server/index.ts` — local CopilotKit runtime
- `.env.example` — runtime URL, OpenAI key, model, and CORS settings

## Useful scripts

```bash
npm run dev         # Vite frontend + local Copilot runtime
npm run build       # Build the frontend and compile the runtime
npm run preview     # Preview the built frontend
npm run start       # Run the compiled runtime from dist-server/
```
