chore(loop): update overnight plan with Archy integration and 17 tasks

6 phases: ContentPanel wiring, Archy service integration, extraction
hardening to 100+ tests, Archy integration tests, code mode UX, and
final verification. Prompt updated with full Archy service inventory.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-04 12:09:28 +00:00
co-authored by Claude Opus 4.6
parent 89885269f0
commit 705e184a5b
2 changed files with 69 additions and 16 deletions
+35 -13
View File
@@ -1,4 +1,4 @@
# Overnight Plan — Content Surfacing Hardening & Feature Completion
# Overnight Plan — Archy Integration, Content Hardening & Feature Completion
> **Format**: `- [ ]` = pending, `- [x]` = done.
> Make at least 30 attempts on any difficult task before moving on. Loop reads this file.
@@ -13,26 +13,48 @@
- [ ] **TEST:P1** — Run `cd packages/app && npx vitest run` and `pnpm typecheck && pnpm lint`. Fix all failures before proceeding.
## Phase 2: Content Extraction Hardening
## Phase 2: Archy Service Integration into AIUI
- [ ] **T4** — Expand extraction quality test suite to 100+ tests. Add tests for: podcast extraction (library `[[podcast:p1]]` tags + `[[podcast_ext:]]` tags), app extraction (`extractApps`), film extraction (library `[[film:f1]]` tags + `[[film_ext:]]` tags), magazine section extraction, websites/news detection from markdown links and bare domain extraction, edge cases (empty strings, very long text, unicode characters, special chars in titles), mixed content with 3+ types in one response, `filterTabsByContext` with every specialized path (news+TV, nostr+apps, app+code, etc). Each test should use realistic AI response text patterns. File: `packages/app/src/__tests__/extractionQuality.test.ts`
- [ ] **T4** — Extend useArchy composable to support richer context categories. Add new reactive refs and fetch methods for: `wallet` (Lightning balance, channel count, node pubkey), `files` (Nextcloud file listings — name, path, size, modified date), `media` (photo count, recent photos, music files). Update `buildArchyContext()` to include wallet balance, file counts, and media summary in the AI system prompt. Update `fetchPermittedContext()` to request these new categories from the bridge. The data format should match what Archy's contextBroker will return (see archyBridge.ts categories: 'apps' | 'system' | 'network' | 'wallet' | 'files'). File: `packages/app/src/composables/useArchy.ts`
- [ ] **T5**Fix any extraction bugs found during T4 testing. Run the expanded test suite, fix all failures in `contentExtraction.ts` and/or `contentFiltering.ts`. Iterate until all tests pass. Document any patterns that needed fixing.
- [ ] **T5**Create Archy app cards for AIUI. Build a data file at `packages/app/src/data/archy-apps.ts` that maps Archy service IDs to AIUI-friendly metadata: display name, description, icon (use emoji for now), category, default port, and deep-link URL pattern (e.g., `/app/nextcloud`, `/app/mempool`). Include all major services: bitcoin-core, lnd, core-lightning, btcpay-server, mempool, nextcloud, immich, nostr-rs-relay, home-assistant, grafana, searxng, ollama, penpot, onlyoffice, fedimint, meshtastic. When running in Archy, merge this with live `installedApps` data from useArchy to show actual status. File: `packages/app/src/data/archy-apps.ts`
- [ ] **T6**Verify filterTabsByContext prioritization is correct for all paths. The function was recently refactored to use a `prioritize()` helper that appends remaining content after priority tabs. Write specific tests ensuring: news queries show news/magazine first but include TV/books/etc if present, nostr queries show nostr first but include other content, app queries show apps first, preferred tab from `preferredFirstTab()` is always first in general case, no content type is ever silently dropped. File: `packages/app/src/__tests__/extractionQuality.test.ts`
- [ ] **T6**Create an ArchyAppsGrid component. Build `packages/app/src/components/content/ArchyAppsGrid.vue` that displays Archy node apps in a grid. Each card shows: app name, status (running/stopped/not installed), description snippet, and an action button (Open if running, Install if not). Use glass-card styling. On click, call `useArchy().requestAction('open-app', { appId })` for running apps. When not embedded in Archy, show the apps as informational cards without action buttons. Wire this into ContentPanel.vue under a new conditional: when the 'app' tab is active AND `useArchy().isEmbedded`, show ArchyAppsGrid above or instead of the generic AppsGrid.
- [ ] **TEST:P2**Run `cd packages/app && npx vitest run src/__tests__/extractionQuality.test.ts` — must have 100+ tests all passing. Then run `pnpm typecheck && pnpm lint`.
- [ ] **T7**Wire Archy wallet context into AI responses. When the AI mentions Bitcoin/Lightning and Archy wallet data is available, the system prompt should include: wallet balance (sats), number of channels, total capacity. This lets the AI say things like "Your node has 500,000 sats across 3 channels" when relevant. In `useArchy.ts`, add `walletInfo` ref with `{ balanceSats?: number, channelCount?: number, totalCapacitySats?: number, nodePubkey?: string }`. In `buildArchyContext()`, append wallet section when data exists.
## Phase 3: Code Mode UX Completion
- [ ] **T8** — Wire Archy file context for AI awareness. When files permission is granted, the AI should know what files the user has. In `useArchy.ts`, add `fileList` ref as `{ name: string, path: string, size?: number, modified?: string, type: 'file' | 'folder' }[]`. In `buildArchyContext()`, summarize: "You have X files in Nextcloud. Recent files: file1.pdf, file2.jpg, notes/todo.md". Limit to 20 most recent files to keep prompt concise. The AI can then reference user's files conversationally.
- [ ] **T7**Add Esc key to exit code mode on desktop. In ChatWindow.vue or ChatPage.vue, add a `keydown` event listener for Escape that calls `exitCodeMode()` from `useCodeContext` when code mode is active (`codeMode.value === true`). Only handle on desktop (not mobile). The listener should be added in `onMounted` and cleaned up in `onUnmounted`.
- [ ] **TEST:P2**Run `pnpm test && pnpm typecheck && pnpm lint`. Fix all failures before proceeding.
- [ ] **T8** — Show selected project indicator near chat input when in code mode. When `codeMode` is true and a project is selected (`currentProject` from `useCodeContext`), display the project name as a small pill/badge near the chat input area. Use accent/orange styling consistent with the code mode input styling (bg-accent/15, text-accent). Show in ChatInput.vue or as a banner above it in ChatWindow.vue.
## Phase 3: Content Extraction Hardening
- [ ] **T9**Wire selected design tokens + files into AI context. When sending a message in code mode, include any selected design tokens and selected file contents as context. In `useAI.ts` `sendMessage()`, check if code mode is active, read `selectedDesignTokens` and `selectedFiles` from `useCodeContext()`, read file contents for selected files, and prepend this context to the system prompt or as a prefixed user message section. Keep context concise — include file paths and key content, not full files.
- [ ] **T9**Expand extraction quality test suite to 100+ tests. Add tests for: podcast extraction (library `[[podcast:p1]]` tags + `[[podcast_ext:]]` tags), app extraction (`extractApps`), film extraction (library `[[film:f1]]` tags + `[[film_ext:]]` tags), magazine section extraction, websites/news detection from markdown links and bare domain extraction, edge cases (empty strings, very long text, unicode characters, special chars in titles), mixed content with 3+ types in one response, `filterTabsByContext` with every specialized path (news+TV, nostr+apps, app+code, etc). Each test should use realistic AI response text patterns. File: `packages/app/src/__tests__/extractionQuality.test.ts`
- [ ] **TEST:P3**Run `pnpm typecheck && pnpm lint`. Fix all failures before proceeding.
- [ ] **T10**Fix any extraction bugs found during T9 testing. Run the expanded test suite, fix all failures in `contentExtraction.ts` and/or `contentFiltering.ts`. Iterate until all tests pass.
## Phase 4: Final Verification
- [ ] **T11** — Verify filterTabsByContext prioritization for all paths. Write specific tests ensuring: news queries show news/magazine first but include TV/books/etc if present, nostr queries show nostr first, app queries show apps first, preferred tab from `preferredFirstTab()` is always first in general case, no content type is ever silently dropped. File: `packages/app/src/__tests__/extractionQuality.test.ts`
- [ ] **T10**Final verification pass. Run `pnpm test` (all tests pass), `pnpm typecheck` (no new type errors — archyBridge.ts error is pre-existing and acceptable), `pnpm lint` (0 errors). Fix any issues found. Commit all remaining changes with a summary commit message.
- [ ] **TEST:P3**Run `cd packages/app && npx vitest run src/__tests__/extractionQuality.test.ts` — must have 100+ tests all passing. Then run `pnpm typecheck && pnpm lint`.
## Phase 4: Archy Integration Tests
- [ ] **T12** — Create Archy integration test suite. File: `packages/app/src/__tests__/archyIntegration.test.ts`. Test: archyBridge message handling (mock postMessage for context:response, theme:response, permissions:update), useArchy composable (init when embedded, buildArchyContext output format with various data combinations, fetchPermittedContext with mocked bridge, requestAction delegation). Mock `window.parent` and `window.addEventListener`. Test wallet/file context formatting. Test base-aware API paths resolve correctly for both `/` and `/aiui/` base paths.
- [ ] **T13** — Test ArchyAppsGrid component. Write tests verifying: renders app cards from archy-apps.ts data, shows correct status when merged with live data, action buttons work (open-app calls requestAction), graceful fallback when not embedded (shows informational cards only), glass-card styling applied.
- [ ] **TEST:P4** — Run `pnpm test && pnpm typecheck && pnpm lint`. All tests must pass.
## Phase 5: Code Mode UX Completion
- [ ] **T14** — Add Esc key to exit code mode on desktop. In ChatWindow.vue or ChatPage.vue, add a `keydown` event listener for Escape that calls `exitCodeMode()` from `useCodeContext` when code mode is active (`codeMode.value === true`). Only handle on desktop (not mobile). Add/cleanup in onMounted/onUnmounted.
- [ ] **T15** — Show selected project indicator near chat input when in code mode. When `codeMode` is true and a project is selected (`currentProject` from `useCodeContext`), display the project name as a small pill/badge near the chat input area. Use accent/orange styling (bg-accent/15, text-accent).
- [ ] **T16** — Wire selected design tokens + files into AI context. When sending a message in code mode, include selected design tokens and file contents as context in the system prompt. Read from `useCodeContext()`. Keep concise.
- [ ] **TEST:P5** — Run `pnpm typecheck && pnpm lint`. Fix all failures before proceeding.
## Phase 6: Final Verification & Cleanup
- [ ] **T17** — Final verification pass. Run `pnpm test` (all tests pass), `pnpm typecheck` (no type errors), `pnpm lint` (0 errors). Fix any issues. Commit all remaining changes with a summary commit message. Push to remote.
+34 -3
View File
@@ -1,11 +1,11 @@
You are hardening the AIUI content extraction pipeline and completing incomplete features. Read these files first:
You are hardening the AIUI content extraction pipeline, integrating Archy services, and completing incomplete features. Read these files first:
1. `loop/plan.md` — Your task checklist (mark items `- [x]` as you complete them)
2. `CLAUDE.md` — Project conventions, design system rules, and coding standards
## Key Context
The content extraction pipeline lives in:
### Content Extraction Pipeline
- `packages/app/src/composables/contentExtraction.ts` — Extracts books, films, TV, songs, podcasts, places, images, code blocks, apps from AI response text
- `packages/app/src/composables/contentFiltering.ts` — Query/response classifiers (isBookQuery, isTVQuery, etc.) and tab routing (filterTabsByContext)
- `packages/app/src/composables/useContentPanel.ts` — Wires extraction functions to Vue reactive state and tab system
@@ -15,6 +15,35 @@ The content extraction pipeline lives in:
Content flows: AI response text → extraction functions → useContentPanel refs → filterTabsByContext → ContentPanel/ContentGridView rendering
### Archy Integration (CRITICAL — this is the main new work)
- `packages/app/src/services/archyBridge.ts` — PostMessage client for AIUI ↔ Archipelago IPC (already implemented)
- `packages/app/src/composables/useArchy.ts` — Reactive Vue wrapper (just created, needs extension)
- `packages/app/src/composables/useAI.ts` — Already injects Archy context via `buildArchyContext()` in `buildSystemPrompt()`
Archy is a self-hosted Linux node OS with 23+ apps. AIUI runs as an iframe inside Archy at `/aiui/`. Communication is via postMessage with 5 context categories: apps, system, network, wallet, files. The bridge is initialized when `?embedded=true` is in the URL.
**Archy Services Available** (that AIUI should know about):
- Bitcoin Core (blockchain data, UTXO, fee estimates)
- LND / Core Lightning / Lightning Stack (channels, payments, invoices)
- BTCPay Server (payment processing)
- Mempool (blockchain explorer)
- Nextcloud (files, notes, contacts, calendar via WebDAV)
- Immich (photos, ML-tagging)
- Nostr relays (nostr-rs-relay, strfry)
- Home Assistant (smart home)
- Grafana (monitoring)
- SearXNG (privacy search)
- Ollama (local LLM)
- Penpot (design)
- OnlyOffice (documents)
- Fedimint (federated custody)
- Meshtastic (mesh networking)
- DID Wallet (Web5 identity)
**Data Handshake**: AIUI requests context via `archyBridge.requestContext(category)`. Archy's contextBroker responds with sanitized data (no secrets, no IPs, no keys). Currently `wallet` and `files` categories are stubs in Archy — build the AIUI consumer side anyway so it's ready when Archy implements them. Use realistic mock shapes.
**API Path Note**: All API paths use `import.meta.env.BASE_URL` prefix so they work at both `/` (dev) and `/aiui/` (production). This was just implemented — don't change it.
## Design System Rules (must follow for every file you touch)
- **Glass morphism only** — use `.glass`, `.glass-card`, `.glass-button`, `.glass-button-sm` from `src/styles/main.css`
@@ -34,7 +63,7 @@ Content flows: AI response text → extraction functions → useContentPanel ref
4. Implement the feature/fix following conventions and design system rules
5. Run `pnpm typecheck && pnpm lint` — fix all errors before committing
6. Run `pnpm test` — fix any failing tests
7. If the task involves tests, run `cd packages/app && npx vitest run src/__tests__/extractionQuality.test.ts` specifically
7. If the task involves tests, run `cd packages/app && npx vitest run` specifically
8. Commit: `type(scope): description` (conventional commits)
9. Mark it done `- [x]` in `loop/plan.md`
10. Move to the next unchecked task immediately
@@ -50,3 +79,5 @@ Content flows: AI response text → extraction functions → useContentPanel ref
- Do not stop until all tasks are checked or you are rate limited
- When adding tests, aim for realistic AI response patterns, not trivial examples
- When wiring components into ContentPanel.vue, follow the exact same pattern used for existing content types (BookGrid/BookDetail, TVSeriesGrid/TVSeriesDetail, etc.)
- When building Archy integration, the AIUI side should be resilient — always handle the case where Archy doesn't respond or data is empty
- Commit and push after each completed phase (TEST: tasks)