Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
397 changes: 397 additions & 0 deletions CLAUDE.l10n.md

Large diffs are not rendered by default.

125 changes: 125 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# CLAUDE.md PauseAI Website Project Context

This project focuses on the PauseAI.info website, with particular attention to the email composition tool that helps volunteers craft effective outreach messages. Ignore the fact that "pauseai-l10n" features in the directory path.

## Website Architecture

The website is built with:

- **Framework**: SvelteKit
- **Hosting**: Netlify
- **Rendering**: Primarily static with some dynamic content
- **Data Source**: AirTable for dynamic content
- **API Routes**: Mix of serverless and edge functions

## Key Components

### Server Functions & API Routes

The website includes several API endpoints, including:

- the one of concern, `/api/write` - Email composition tool with web search capabilities
- as an arbitrary other example, `/api/teams` - Team/national groups information

### Function Types & Timeout Constraints

**Edge Functions:**

- 50ms compute limit and 30-50s request timeout
- Single 3MB function file when `edge: true`
- Cannot be used with `split: true`

**Serverless Functions:**

- 30-second execution limit (standard: can fluctuate)
- 15-minute limit for background functions (paid tier, which we have just enabled and not yet used)
- Individual function files when using `split: true`
- Automatically created for API routes called during prerendering

### Configuration Options

**SvelteKit Configuration** (`svelte.config.js`):

```javascript
adapter: adapterPatchPrerendered(
adapterNetlify({
edge: false,
split: true // Split into individual serverless functions
})
),
```

**Key Trade-offs:**

- Edge functions are faster but have stricter timeout limits
- Serverless functions allow longer execution but may have cold starts
- `split: true` creates smaller, more manageable function files
- Cannot combine `edge: true` with `split: true`

## Email Composition Tool

### Current Status (2025-08-04)

#### Architecture Refactor in Progress

- **Migration**: Moving from array-based forms to DOM-driven data-attribute pattern
- **Stage 1 (discover)**: ✅ Migrated to new pattern using `<fieldset name="discover">` with `data-prompt` attributes
- **Stages 2-5**: Still using array-based system, working but not yet migrated
- **Dual system**: Both patterns coexist during migration period

#### Form Pattern (New)

```html
<fieldset name="discover">
<label
>Field Label:
<input name="search" data-prompt="Contact Search" />
</label>
</fieldset>
```

- Fields with `data-prompt` are collected for LLM prompts
- Path derived from `fieldset[name] + input[name]` → `info.discover.search`
- Generic handlers: `handleInfoField()`, `buildPromptFromStage()`

#### Testing Status

- Stage 1-2: Working with current changes
- UK volunteer use case: Ready for DeepMind campaign
- Local dev: Use `pnpm dev` (no timeouts)
- Production testing: Use `netlify serve`

### Functionality

- Helps users craft personalized outreach emails
- Incorporates web search for relevant information
- Multi-step workflow with conversation-style interaction

### API Usage Pattern

The `/api/write` endpoint follows this pattern:

1. **Initial request**: Conversation array format to get `stateToken`
```json
[{ "content": "[1]Target info:\nEdinburgh AI safety\n\n", "role": "user" }]
```
2. **Continue request**: Use `stateToken` to proceed with workflow
```json
{ "stateToken": "...", "continue": true }
```

### Known Challenges

- Web search functionality requires ~67 seconds processing time
- Currently hits 30-second serverless function timeout
- Previously hit 10-second edge function timeout
- Requires optimization or alternate implementation approaches

## Code Quality Checks

**IMPORTANT**: Before committing and pushing changes, ALWAYS run:

- `pnpm check` - Runs svelte-check for TypeScript and Svelte errors
- `pnpm lint` - Checks ESLint rules

Both commands must pass without errors before pushing. Warnings can be addressed separately but errors must be fixed.
69 changes: 69 additions & 0 deletions logs/20250904.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@

> pause-ai@ build /home/anthony/repos/pauseai-l10n/notes/references/pauseai-website
> cross-env NODE_ENV=production node scripts/filter-build-log.js "tsx scripts/l10n/run && vite build --emptyOutDir=false && run-s _postbuild:*"

(node:337800) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated.
(Use `node --trace-deprecation ...` to show where the warning was created)
Regenerating inlang settings...
Using locales: en
Generated settings.json with 1 locales
🔄 Compiling Paraglide runtime from settings...
✅ Paraglide runtime compiled successfully!

WARN [paraglide-js] PluginImportError: Couldn't import the plugin "https://cdn.jsdelivr.net/npm/@inlang/plugin-paraglide-js-adapter@latest/dist/index.js":

SyntaxError: Unexpected identifier 'to'

🌐 L10n Mode: en-only: Can copy English files to build directory

vite v5.4.19 building SSR bundle for production...
transforming...
node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]_@types+node_246x4hx5xt5tvfsqblmewa63w4/node_modules/@sveltejs/kit/src/runtime/client/client.js (6:23): "untrack" is not exported by "node_modules/.pnpm/[email protected]/node_modules/svelte/src/runtime/ssr.js", imported by "node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]_@types+node_246x4hx5xt5tvfsqblmewa63w4/node_modules/@sveltejs/kit/src/runtime/client/client.js".
"join" is imported from external module "path" but never used in "src/routes/api/debug-export/+server.ts".
✓ 627 modules transformed.
rendering chunks...
vite v5.4.19 building for production...
transforming...
node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]_@types+node_246x4hx5xt5tvfsqblmewa63w4/node_modules/@sveltejs/kit/src/runtime/client/client.js (6:23): "untrack" is not exported by "node_modules/.pnpm/[email protected]/node_modules/svelte/src/runtime/index.js", imported by "node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]_@types+node_246x4hx5xt5tvfsqblmewa63w4/node_modules/@sveltejs/kit/src/runtime/client/client.js".
✓ 694 modules transformed.
rendering chunks...
✓ built in 19.84s
Fetching from URL: https://api.airtable.com/v0/appWPTGqZmUcs3NWu/tbl2emfOWNWoVz1kW
Fetching from URL: https://api.airtable.com/v0/appWPTGqZmUcs3NWu/tbl2emfOWNWoVz1kW?offset=itrMUsQSScXclFiub/rec8m64fDXfzW2ciy
Fetching from URL: https://api.airtable.com/v0/appWPTGqZmUcs3NWu/tbl2emfOWNWoVz1kW?offset=itrMUsQSScXclFiub/recHChZ1wq1AwugO0
Fetching from URL: https://api.airtable.com/v0/appWPTGqZmUcs3NWu/tbl2emfOWNWoVz1kW?offset=itrMUsQSScXclFiub/recRQceRn2XeM8bWH
Fetching from URL: https://api.airtable.com/v0/appWPTGqZmUcs3NWu/tbl2emfOWNWoVz1kW?offset=itrMUsQSScXclFiub/recaipbihJWJ5ddoO
Fetching from URL: https://api.airtable.com/v0/appWPTGqZmUcs3NWu/tbl2emfOWNWoVz1kW?offset=itrMUsQSScXclFiub/reciiCoNgLCrdRhlA
Fetching from URL: https://api.airtable.com/v0/appWPTGqZmUcs3NWu/tbl2emfOWNWoVz1kW?offset=itrMUsQSScXclFiub/recspsfSRpnEHqMd3
Total records: 683, Verified records: 578
Fetching from URL: https://api.airtable.com/v0/appWPTGqZmUcs3NWu/tblYLOPzJ32QOdBLg
✓ built in 33.40s

Run npm run preview to preview your production build locally.

> Using @sveltejs/adapter-netlify
✔ done

> pause-ai@ _postbuild:pagefind /home/anthony/repos/pauseai-l10n/notes/references/pauseai-website
> tsx scripts/create-pagefind-index.ts


> pause-ai@ _postbuild:exclude /home/anthony/repos/pauseai-l10n/notes/references/pauseai-website
> tsx scripts/exclude-from-edge-function.ts


> pause-ai@ _postbuild:caching /home/anthony/repos/pauseai-l10n/notes/references/pauseai-website
> tsx scripts/opt-in-to-caching.ts


> pause-ai@ _postbuild:l10ntamer /home/anthony/repos/pauseai-l10n/notes/references/pauseai-website
> tsx scripts/l10ntamer.ts

⏭️ Skipping l10ntamer - English routes not prefixed

📊 Complete build summary:
Client: 279 chunks (9341.17 kB)
Server: 266 chunks (5745.48 kB)
Total: 545 chunks (15086.65 kB)

🏁 Build process completed with code 0
Empty file added logs/20251112.1
Empty file.
Loading
Loading