Move from GitHub to Tangled
1# Tangled Sync - Setup & Troubleshooting Guide 2 3## Quick Setup Checklist 4 5### 1. Install Dependencies 6```bash 7npm install 8``` 9 10### 2. Configure Environment Variables 11```bash 12# Copy the example env file 13cp src/.env.example src/.env 14 15# Edit with your actual values 16nano src/.env # or use your preferred editor 17``` 18 19**Required values:** 20- `BASE_DIR`: Where to clone repos (e.g., `/Users/you/tangled-repos`) 21- `GITHUB_USER`: Your GitHub username 22- `ATPROTO_DID`: Your AT Proto DID (get from Bluesky settings) 23- `BLUESKY_PDS`: Usually `https://bsky.social` 24- `BLUESKY_USERNAME`: Your Bluesky handle (e.g., `you.bsky.social`) 25- `BLUESKY_PASSWORD`: Use an **app password**, not your main password! 26 27### 3. Get Your AT Proto DID 28 29Your DID can be found by: 301. Go to https://bsky.app 312. Click your profile 323. Settings → Advanced → Account 334. Look for "DID" (starts with `did:plc:`) 34 35Alternatively, visit: `https://bsky.social/xrpc/com.atproto.identity.resolveHandle?handle=YOUR_HANDLE.bsky.social` 36 37### 4. Create an App Password 38 39**IMPORTANT:** Do NOT use your main Bluesky password! 40 411. Go to https://bsky.app/settings 422. Navigate to "App Passwords" 433. Click "Add App Password" 444. Give it a name (e.g., "Tangled Sync") 455. Copy the generated password to your `.env` file 46 47### 5. Test AT Proto Connection 48```bash 49npm run test-atproto 50``` 51 52Expected output: 53``` 54✓ Login successful! 55 DID: did:plc:... 56 Handle: you.bsky.social 57 Email: your@email.com 58 59✓ Found X existing Tangled repo records 60``` 61 62### 6. Verify SSH to Tangled 63```bash 64ssh git@tangled.sh 65``` 66 67You should see a message confirming your SSH key is configured. 68 69### 7. Run the Sync 70```bash 71npm run sync 72``` 73 74--- 75 76## Common Issues & Solutions 77 78### Issue: "Missing Bluesky credentials" 79**Solution:** Check that `src/.env` exists and contains `BLUESKY_USERNAME` and `BLUESKY_PASSWORD` 80 81### Issue: "Login failed" or "Invalid credentials" 82**Solution:** 83- Ensure you're using an **app password**, not your main password 84- Check your username includes the full handle (e.g., `you.bsky.social`) 85- Verify credentials are correct 86 87### Issue: "DID mismatch" 88**Solution:** 89- Run `npm run test-atproto` to see your actual DID 90- Update `ATPROTO_DID` in `src/.env` to match 91 92### Issue: "Could not push to Tangled" 93**Solution:** 94- Verify SSH key is added to Tangled: https://tangled.org/settings/keys 95- Test SSH connection: `ssh git@tangled.sh` 96- Ensure the repository exists on Tangled first 97 98### Issue: "Failed to create ATProto record" 99**Solution:** 100- Check that the schema matches (required fields: `name`, `knot`, `createdAt`) 101- Verify your app password has write permissions 102- Check PDS is reachable: `curl https://bsky.social` 103 104### Issue: Rate limiting from GitHub API 105**Solution:** 106- GitHub has a rate limit of 60 requests/hour for unauthenticated requests 107- Consider adding GitHub authentication if syncing many repos 108- Wait an hour and try again 109 110--- 111 112## Understanding the Workflow 113 1141. **Login to AT Proto**: Authenticates with Bluesky PDS using your credentials 1152. **Fetch GitHub Repos**: Retrieves all public repos from your GitHub account 1163. **Clone Locally**: Downloads repos to `BASE_DIR` if not already present 1174. **Add Tangled Remote**: Adds `tangled` as a git remote 1185. **Push to Tangled**: Pushes the `main` branch to Tangled 1196. **Update README**: Adds a Tangled mirror link to the README 1207. **Create AT Proto Record**: Publishes metadata to the AT Proto network 121 122Each repository gets a record in the `sh.tangled.repo` collection with: 123- Repository name and description 124- Source URL (GitHub) 125- Creation timestamp 126- Knot server reference 127- Optional labels and topics 128 129--- 130 131## Verifying Success 132 133After running the sync, you can verify: 134 1351. **Local repos**: Check `BASE_DIR` for cloned repositories 1362. **Tangled remotes**: Run `git remote -v` in any repo directory 1373. **AT Proto records**: Run `npm run test-atproto` to list records 1384. **Tangled website**: Visit `https://tangled.org/YOUR_DID/REPO_NAME` 139 140--- 141 142## Advanced Configuration 143 144### Using a Different PDS 145If you're not using the default Bluesky PDS: 146```bash 147BLUESKY_PDS=https://your-pds.example.com 148``` 149 150### Syncing Specific Repos Only 151Modify the `getGitHubRepos()` function to filter repos: 152```typescript 153return json 154 .filter((r: any) => r.name.startsWith('my-prefix-')) 155 .map(...); 156``` 157 158### Changing the Default Branch 159If your repos use `master` instead of `main`, update: 160```typescript 161run(`git push tangled master`, repoDir); 162``` 163 164--- 165 166## Support 167 168For issues with: 169- **Tangled**: https://github.com/tangled-dev/tangled 170- **AT Proto**: https://atproto.com/docs 171- **This tool**: Open an issue in the repository 172 173--- 174 175**Happy syncing! 🚀**