Monorepo for Aesthetic.Computer
aesthetic.computer
1# Scripts Setup & Requirements
2
3## 🔧 How These Scripts Work
4
5All scripts in `scripts/` are designed to run from the **workspace root** (`/workspaces/aesthetic-computer/`).
6
7### Import Resolution
8- ✅ **Backend modules**: `import { connect } from "../../system/backend/database.mjs"`
9 - Scripts access backend utilities via relative paths
10 - Path goes up 2 levels from `scripts/atproto/` to root, then into `system/backend/`
11
12- ✅ **Node modules**: `import { AtpAgent } from "@atproto/api"`
13 - Installed in root `node_modules/` (shared with system/node_modules)
14 - Node.js walks up from script location to find packages
15 - Run `npm install` at root to ensure deps are available
16
17### Environment Variables
18
19Scripts load `.env` from `system/.env` using:
20```javascript
21import { config } from 'dotenv';
22config({ path: './system/.env' });
23```
24
25**Note**: Path is relative to where you run the script (workspace root).
26
27**Required in `system/.env`:**
28```bash
29# MongoDB
30MONGODB_CONNECTION_STRING=mongodb+srv://...
31MONGODB_NAME=aesthetic
32
33# ATProto PDS
34PDS_URL=https://at.aesthetic.computer
35
36# DigitalOcean Spaces (for recovery scripts)
37ART_SPACES_KEY=your_key
38ART_SPACES_SECRET=your_secret
39ART_SPACES_BUCKET=art-aesthetic-computer
40ART_SPACES_REGION=nyc3
41ART_SPACES_ENDPOINT=https://nyc3.digitaloceanspaces.com
42
43AT_BLOBS_SPACES_KEY=your_key
44AT_BLOBS_SPACES_SECRET=your_secret
45AT_BLOBS_SPACES_BUCKET=at-blobs-aesthetic-computer
46AT_BLOBS_SPACES_REGION=nyc3
47AT_BLOBS_SPACES_ENDPOINT=https://nyc3.digitaloceanspaces.com
48
49# Anonymous art account password
50ANON_PASSWORD=your_hash
51```
52
53**User ATProto Credentials** (stored in MongoDB `users` collection):
54```javascript
55{
56 "atproto": {
57 "did": "did:plc:...",
58 "handle": "user.at.aesthetic.computer",
59 "password": "encrypted_app_password"
60 }
61}
62```
63
64### Using aesthetic-computer-vault for Secrets
65
66The `aesthetic-computer-vault/` directory contains **actual secrets**:
67
68```bash
69# Instead of editing system/.env manually, use:
70cd aesthetic-computer-vault
71source devault.fish # Loads secrets from vault/.env
72
73# Or copy vault env to system:
74cp aesthetic-computer-vault/.env system/.env
75```
76
77**Vault contains:**
78- `ANON_PASSWORD` - Anonymous art account password hash
79- `OVEN_CALLBACK_SECRET` - Oven webhook authentication
80- SSH credentials for friend's server
81
82## 📦 Dependencies
83
84**Scripts share dependencies with the main workspace** - packages are installed at root level and duplicated in system/ for Netlify functions.
85
86### Installing Dependencies
87
88```bash
89# Install at root (needed for scripts)
90cd /workspaces/aesthetic-computer
91npm install
92
93# Key packages (already in package.json):
94# - @atproto/api ^0.17.2 (ATProto client)
95# - @aws-sdk/client-s3 ^3.896.0 (DigitalOcean Spaces)
96# - mongodb ^6.20.0 (MongoDB driver)
97# - dotenv ^16.4.7 (Environment variable loading)
98# - node-fetch ^3.3.2 (HTTP requests)
99```
100
101These same packages are also in `system/package.json` for Netlify functions, which is fine - small duplication for clean architecture.
102
103## 🚀 Running Scripts
104
105**Always run from workspace root** so paths resolve correctly:
106
107```bash
108# ✅ Correct (from /workspaces/aesthetic-computer/)
109node scripts/atproto/sync-atproto.mjs live --kidlisp-only
110node scripts/recovery/check-tape-zips-in-spaces.mjs @jeffrey
111
112# ❌ Wrong (wrong working directory)
113cd scripts/atproto
114node sync-atproto.mjs # Can't find system/.env or system/backend/
115```
116
117## 🔍 Troubleshooting
118
119### "Cannot find module '../system/backend/database.mjs'"
120- **Cause**: Running script from wrong directory
121- **Fix**: `cd /workspaces/aesthetic-computer && node scripts/...`
122
123### "MONGODB_CONNECTION_STRING is not set"
124- **Cause**: Missing or incorrect .env file
125- **Fix**:
126 1. Check `system/.env` exists
127 2. Verify it contains `MONGODB_CONNECTION_STRING`
128 3. Or copy from vault: `cp aesthetic-computer-vault/.env system/.env`
129
130### "Cannot use a session that has ended"
131- **Cause**: ATProto credentials invalid or expired
132- **Fix**:
133 1. Check user record in MongoDB has valid `atproto.password`
134 2. Regenerate app password at https://at.aesthetic.computer
135 3. Update MongoDB user record
136
137### "AccessDenied" from DigitalOcean Spaces
138- **Cause**: Missing or invalid DO Spaces credentials
139- **Fix**: Add `ART_SPACES_*` and `AT_BLOBS_SPACES_*` to `system/.env`
140
141## 🔐 Security Notes
142
143- ❌ **Never commit** `system/.env` (already in `.gitignore`)
144- ✅ **Always use** `aesthetic-computer-vault/.env` for secrets
145- 🔒 **Vault is private** - only accessible to authorized developers
146- 🚨 **Rotate credentials** if exposed in logs or commits