Compare commits
3 Commits
fix/1542-a
...
fix/1255
| Author | SHA1 | Date | |
|---|---|---|---|
| fa89c02038 | |||
| 5484b8cca1 | |||
|
|
8419dea39e |
3
app.js
3
app.js
@@ -734,9 +734,6 @@ async function init() {
|
||||
const response = await fetch('./portals.json');
|
||||
const portalData = await response.json();
|
||||
createPortals(portalData);
|
||||
|
||||
// Start portal hot-reload watcher
|
||||
if (window.PortalHotReload) PortalHotReload.start(5000);
|
||||
} catch (e) {
|
||||
console.error('Failed to load portals.json:', e);
|
||||
addChatMessage('error', 'Portal registry offline. Check logs.');
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
.avatar-name-tag{position:fixed;transform:translate(-50%,-100%);background:rgba(0,0,0,0.7);color:#00ffcc;font-family:'JetBrains Mono',monospace;font-size:12px;padding:2px 8px;border-radius:4px;border:1px solid rgba(0,255,204,0.3);pointer-events:none;z-index:100;white-space:nowrap;text-shadow:0 0 6px rgba(0,255,204,0.5)}
|
||||
.avatar-color-picker{position:fixed;top:60px;right:16px;background:rgba(10,15,26,0.95);border:1px solid rgba(0,255,204,0.3);border-radius:8px;padding:12px;z-index:1000;min-width:200px;font-family:'JetBrains Mono',monospace;color:#e0e0e0}
|
||||
.avatar-color-picker.hidden{display:none}
|
||||
.avatar-picker-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px;font-size:14px;color:#00ffcc}
|
||||
.avatar-picker-close{background:none;border:none;color:#666;font-size:18px;cursor:pointer}
|
||||
.avatar-picker-name{margin-bottom:12px}
|
||||
.avatar-picker-name label{display:block;font-size:10px;color:#666;text-transform:uppercase;margin-bottom:4px}
|
||||
.avatar-picker-name input{width:100%;background:rgba(255,255,255,0.05);border:1px solid rgba(0,255,204,0.2);border-radius:4px;color:#e0e0e0;padding:6px 8px;font-family:inherit;font-size:13px;outline:none}
|
||||
.avatar-picker-colors label{display:block;font-size:10px;color:#666;text-transform:uppercase;margin-bottom:6px}
|
||||
.avatar-color-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:6px}
|
||||
.avatar-color-swatch{width:36px;height:36px;border-radius:50%;border:2px solid transparent;cursor:pointer;transition:border-color 0.15s,transform 0.15s}
|
||||
.avatar-color-swatch:hover{transform:scale(1.15)}
|
||||
.avatar-color-swatch.active{border-color:white;box-shadow:0 0 8px currentColor}
|
||||
@@ -1,38 +0,0 @@
|
||||
const AvatarCustomization = (() => {
|
||||
let avatarMesh = null, nameTagDiv = null, colorPickerPanel = null;
|
||||
let currentColor = '#00ffcc', currentName = 'Visitor', _scene = null, _camera = null;
|
||||
const STORAGE_KEY = 'nexus-avatar-prefs';
|
||||
const PRESET_COLORS = [
|
||||
{name:'Teal',hex:'#00ffcc'},{name:'Cyan',hex:'#00ccff'},{name:'Purple',hex:'#9966ff'},
|
||||
{name:'Pink',hex:'#ff66aa'},{name:'Orange',hex:'#ff8833'},{name:'Gold',hex:'#ffcc00'},
|
||||
{name:'Red',hex:'#ff3333'},{name:'Green',hex:'#33ff66'},
|
||||
];
|
||||
function loadPrefs(){try{const r=localStorage.getItem(STORAGE_KEY);if(r){const p=JSON.parse(r);if(p.color)currentColor=p.color;if(p.name)currentName=p.name;}}catch(e){}}
|
||||
function savePrefs(){try{localStorage.setItem(STORAGE_KEY,JSON.stringify({color:currentColor,name:currentName}));}catch(e){}}
|
||||
function createAvatarMesh(color){
|
||||
const geo=new THREE.CapsuleGeometry(0.3,0.8,8,16);
|
||||
const mat=new THREE.MeshStandardMaterial({color:new THREE.Color(color),emissive:new THREE.Color(color).multiplyScalar(0.3),metalness:0.3,roughness:0.5});
|
||||
const mesh=new THREE.Mesh(geo,mat);mesh.position.set(0,1.2,0);mesh.castShadow=true;return mesh;
|
||||
}
|
||||
function updateAvatarColor(hex){
|
||||
currentColor=hex;if(avatarMesh){avatarMesh.material.color.set(hex);avatarMesh.material.emissive.set(new THREE.Color(hex).multiplyScalar(0.3));}
|
||||
document.querySelectorAll('.avatar-color-swatch').forEach(el=>el.classList.toggle('active',el.dataset.color===hex));savePrefs();
|
||||
}
|
||||
function createNameTag(name){const d=document.createElement('div');d.className='avatar-name-tag';d.textContent=name;document.body.appendChild(d);return d;}
|
||||
function updateNameTagPosition(){if(!nameTagDiv||!_camera)return;const pos=new THREE.Vector3(0,2.4,0);if(avatarMesh&&avatarMesh.parent)pos.add(avatarMesh.parent.position);pos.project(_camera);const x=(pos.x*0.5+0.5)*window.innerWidth;const y=(-pos.y*0.5+0.5)*window.innerHeight;nameTagDiv.style.left=x+'px';nameTagDiv.style.top=y+'px';nameTagDiv.style.display=pos.z<1?'block':'none';}
|
||||
function updateNameTagText(name){currentName=name;if(nameTagDiv)nameTagDiv.textContent=name;savePrefs();}
|
||||
function createColorPicker(){
|
||||
const panel=document.createElement('div');panel.id='avatar-color-picker';panel.className='avatar-color-picker hidden';
|
||||
panel.innerHTML='<div class="avatar-picker-header"><span>Avatar</span><button class="avatar-picker-close">×</button></div><div class="avatar-picker-name"><label>Name</label><input type="text" id="avatar-name-input" maxlength="20" placeholder="Your name" /></div><div class="avatar-picker-colors"><label>Color</label><div class="avatar-color-grid">'+PRESET_COLORS.map(c=>'<button class="avatar-color-swatch '+(c.hex===currentColor?'active':'')+'" data-color="'+c.hex+'" style="background:'+c.hex+'" title="'+c.name+'"></button>').join('')+'</div></div>';
|
||||
document.body.appendChild(panel);
|
||||
panel.querySelector('.avatar-picker-close').addEventListener('click',()=>panel.classList.add('hidden'));
|
||||
panel.querySelectorAll('.avatar-color-swatch').forEach(el=>el.addEventListener('click',()=>updateAvatarColor(el.dataset.color)));
|
||||
const ni=panel.querySelector('#avatar-name-input');ni.value=currentName;ni.addEventListener('input',(e)=>updateNameTagText(e.target.value||'Visitor'));
|
||||
return panel;
|
||||
}
|
||||
function toggleColorPicker(){if(!colorPickerPanel)return;colorPickerPanel.classList.toggle('hidden');const ni=colorPickerPanel.querySelector('#avatar-name-input');if(ni&&!colorPickerPanel.classList.contains('hidden')){ni.value=currentName;ni.focus();}}
|
||||
function update(playerPos){if(!avatarMesh)return;avatarMesh.position.set(playerPos.x,playerPos.y-0.8,playerPos.z);updateNameTagPosition();}
|
||||
function init(sceneRef,cameraRef){_scene=sceneRef;_camera=cameraRef;loadPrefs();avatarMesh=createAvatarMesh(currentColor);_scene.add(avatarMesh);nameTagDiv=createNameTag(currentName);colorPickerPanel=createColorPicker();const h=document.querySelector('.hud-top-right');if(h){const b=document.createElement('button');b.id='avatar-customize-btn';b.className='hud-icon-btn';b.title='Customize Avatar';b.innerHTML='<span class="hud-icon">🎨</span>';b.addEventListener('click',toggleColorPicker);h.insertBefore(b,h.firstChild);}console.log('[AvatarCustomization] Initialized —',currentColor,currentName);}
|
||||
return{init,update,setColor:updateAvatarColor,setName:updateNameTagText,toggleColorPicker};
|
||||
})();
|
||||
window.AvatarCustomization=AvatarCustomization;
|
||||
317
bin/admin_actions.py
Executable file
317
bin/admin_actions.py
Executable file
@@ -0,0 +1,317 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Admin Actions Toolkit for Issue #1255
|
||||
Provides scripts and documentation for repo-owner admin actions.
|
||||
|
||||
Issue #1255: [IaC] Admin actions for Rockachopa — branch protection, cron setup, PR merge
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import urllib.request
|
||||
from typing import Dict, List, Any, Optional
|
||||
|
||||
# Configuration
|
||||
GITEA_BASE = "https://forge.alexanderwhitestone.com/api/v1"
|
||||
TOKEN_PATH = os.path.expanduser("~/.config/gitea/token")
|
||||
ORG = "Timmy_Foundation"
|
||||
REPO = "the-nexus"
|
||||
|
||||
class AdminActions:
|
||||
def __init__(self, admin_token: Optional[str] = None):
|
||||
self.admin_token = admin_token or self._load_token()
|
||||
|
||||
def _load_token(self) -> str:
|
||||
"""Load Gitea API token."""
|
||||
try:
|
||||
with open(TOKEN_PATH, "r") as f:
|
||||
return f.read().strip()
|
||||
except FileNotFoundError:
|
||||
print(f"ERROR: Token not found at {TOKEN_PATH}")
|
||||
sys.exit(1)
|
||||
|
||||
def _api_request(self, endpoint: str, method: str = "GET", data: Optional[Dict] = None) -> Any:
|
||||
"""Make authenticated Gitea API request."""
|
||||
url = f"{GITEA_BASE}{endpoint}"
|
||||
headers = {
|
||||
"Authorization": f"token {self.admin_token}",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
|
||||
req = urllib.request.Request(url, headers=headers, method=method)
|
||||
if data:
|
||||
req.data = json.dumps(data).encode()
|
||||
|
||||
try:
|
||||
with urllib.request.urlopen(req) as resp:
|
||||
if resp.status == 204: # No content
|
||||
return {"status": "success", "code": resp.status}
|
||||
return json.loads(resp.read())
|
||||
except urllib.error.HTTPError as e:
|
||||
error_body = e.read().decode() if e.fp else "No error body"
|
||||
print(f"API Error {e.code}: {error_body}")
|
||||
return {"error": e.code, "message": error_body}
|
||||
|
||||
def check_branch_protection(self, branch: str = "main") -> Dict[str, Any]:
|
||||
"""Check current branch protection settings."""
|
||||
endpoint = f"/repos/{ORG}/{REPO}/branch_protection/{branch}"
|
||||
result = self._api_request(endpoint)
|
||||
|
||||
if isinstance(result, dict) and "error" in result:
|
||||
return {"error": result["error"], "protected": False}
|
||||
|
||||
return {
|
||||
"protected": True,
|
||||
"settings": result
|
||||
}
|
||||
|
||||
def enable_rebase_before_merge(self, branch: str = "main") -> Dict[str, Any]:
|
||||
"""Enable rebase-before-merge on branch."""
|
||||
# Get current settings
|
||||
current = self.check_branch_protection(branch)
|
||||
|
||||
if not current.get("protected"):
|
||||
# Create new branch protection
|
||||
data = {
|
||||
"branch_name": branch,
|
||||
"enable_push": False,
|
||||
"require_signed_commits": False,
|
||||
"block_on_outdated_branch": True,
|
||||
"required_approvals": 1,
|
||||
"dismiss_stale_reviews": True,
|
||||
"require_code_owner_reviews": True
|
||||
}
|
||||
endpoint = f"/repos/{ORG}/{REPO}/branch_protection"
|
||||
return self._api_request(endpoint, "POST", data)
|
||||
else:
|
||||
# Update existing branch protection
|
||||
settings = current["settings"]
|
||||
settings["block_on_outdated_branch"] = True
|
||||
|
||||
endpoint = f"/repos/{ORG}/{REPO}/branch_protection/{branch}"
|
||||
return self._api_request(endpoint, "PATCH", settings)
|
||||
|
||||
def check_pr_status(self, pr_number: int) -> Dict[str, Any]:
|
||||
"""Check if a PR is merged or open."""
|
||||
endpoint = f"/repos/{ORG}/{REPO}/pulls/{pr_number}"
|
||||
result = self._api_request(endpoint)
|
||||
|
||||
if isinstance(result, dict) and "error" in result:
|
||||
return {"error": result["error"]}
|
||||
|
||||
return {
|
||||
"number": result["number"],
|
||||
"title": result["title"],
|
||||
"state": result["state"],
|
||||
"merged": result.get("merged", False),
|
||||
"merged_at": result.get("merged_at"),
|
||||
"html_url": result["html_url"]
|
||||
}
|
||||
|
||||
def merge_pr(self, pr_number: int, merge_method: str = "rebase") -> Dict[str, Any]:
|
||||
"""Merge a PR."""
|
||||
endpoint = f"/repos/{ORG}/{REPO}/pulls/{pr_number}/merge"
|
||||
data = {
|
||||
"Do": merge_method,
|
||||
"MergeMessageField": "Merge PR",
|
||||
"MergeTitleField": f"Merge PR #{pr_number}",
|
||||
"ForceMerge": False
|
||||
}
|
||||
return self._api_request(endpoint, "PUT", data)
|
||||
|
||||
def generate_setup_script(self) -> str:
|
||||
"""Generate setup script for admin actions."""
|
||||
script = """#!/bin/bash
|
||||
# Admin Actions Setup Script for Issue #1255
|
||||
# Run this script as repo owner (@Rockachopa)
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
echo "=========================================="
|
||||
echo "Admin Actions Setup for the-nexus"
|
||||
echo "=========================================="
|
||||
|
||||
# Configuration
|
||||
REPO="Timmy_Foundation/the-nexus"
|
||||
ADMIN_TOKEN="${GITEA_ADMIN_TOKEN:-}"
|
||||
|
||||
if [ -z "$ADMIN_TOKEN" ]; then
|
||||
echo "ERROR: GITEA_ADMIN_TOKEN environment variable not set"
|
||||
echo "Set it with: export GITEA_ADMIN_TOKEN=<your_admin_token>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 1. Enable rebase-before-merge on main
|
||||
echo ""
|
||||
echo "1. Enabling rebase-before-merge on main branch..."
|
||||
curl -X POST \\
|
||||
-H "Authorization: token $ADMIN_TOKEN" \\
|
||||
-H "Content-Type: application/json" \\
|
||||
"https://forge.alexanderwhitestone.com/api/v1/repos/$REPO/branch_protection" \\
|
||||
-d '{
|
||||
"branch_name": "main",
|
||||
"enable_push": false,
|
||||
"require_signed_commits": false,
|
||||
"block_on_outdated_branch": true,
|
||||
"required_approvals": 1,
|
||||
"dismiss_stale_reviews": true,
|
||||
"require_code_owner_reviews": true
|
||||
}'
|
||||
|
||||
echo ""
|
||||
echo "✅ Branch protection configured"
|
||||
|
||||
# 2. Check PR #1254 status
|
||||
echo ""
|
||||
echo "2. Checking PR #1254 status..."
|
||||
PR_STATUS=$(curl -s -H "Authorization: token $ADMIN_TOKEN" \\
|
||||
"https://forge.alexanderwhitestone.com/api/v1/repos/$REPO/pulls/1254" | jq -r '.state')
|
||||
|
||||
if [ "$PR_STATUS" = "open" ]; then
|
||||
echo "PR #1254 is open. Consider reviewing and merging."
|
||||
echo "URL: https://forge.alexanderwhitestone.com/Timmy_Foundation/the-nexus/pulls/1254"
|
||||
elif [ "$PR_STATUS" = "closed" ]; then
|
||||
echo "PR #1254 is already closed."
|
||||
else
|
||||
echo "Could not determine PR #1254 status"
|
||||
fi
|
||||
|
||||
# 3. Set up stale-pr-closer cron
|
||||
echo ""
|
||||
echo "3. Setting up stale-pr-closer cron..."
|
||||
echo "After merging PR #1254, add this to crontab:"
|
||||
echo ""
|
||||
echo "# Stale PR closer - runs every 6 hours"
|
||||
echo "0 */6 * * * GITEA_TOKEN=\\"$ADMIN_TOKEN\\" REPO=\\"$REPO\\" /path/to/the-nexus/.githooks/stale-pr-closer.sh >> /var/log/stale-pr-closer.log 2>&1"
|
||||
echo ""
|
||||
echo "Test with dry run first:"
|
||||
echo "GITEA_TOKEN=\\"$ADMIN_TOKEN\\" DRY_RUN=true .githooks/stale-pr-closer.sh"
|
||||
|
||||
# 4. Optional: Grant admin access to perplexity
|
||||
echo ""
|
||||
echo "4. Optional: Grant admin access to perplexity"
|
||||
echo "To grant admin access to @perplexity:"
|
||||
echo "1. Go to: https://forge.alexanderwhitestone.com/$REPO/settings/collaborators"
|
||||
echo "2. Find @perplexity"
|
||||
echo "3. Change role to Admin"
|
||||
echo ""
|
||||
echo "This allows @perplexity to handle branch protection and repo settings."
|
||||
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo "Setup complete!"
|
||||
echo "=========================================="
|
||||
"""
|
||||
return script
|
||||
|
||||
def generate_report(self) -> str:
|
||||
"""Generate admin actions report."""
|
||||
report = "# Admin Actions Report for Issue #1255\n\n"
|
||||
report += f"Generated: {__import__('datetime').datetime.now().isoformat()}\n\n"
|
||||
|
||||
# Check branch protection
|
||||
report += "## 1. Branch Protection Status\n"
|
||||
protection = self.check_branch_protection("main")
|
||||
|
||||
if protection.get("protected"):
|
||||
settings = protection["settings"]
|
||||
report += "✅ Branch protection is enabled\n"
|
||||
report += f"- Require PR: {settings.get('required_approvals', 'N/A')}\n"
|
||||
report += f"- Dismiss stale reviews: {settings.get('dismiss_stale_reviews', 'N/A')}\n"
|
||||
report += f"- Block on outdated branch: {settings.get('block_on_outdated_branch', 'N/A')}\n"
|
||||
else:
|
||||
report += "❌ Branch protection is NOT enabled\n"
|
||||
report += "Action required: Enable branch protection on main\n"
|
||||
|
||||
# Check PR #1254
|
||||
report += "\n## 2. PR #1254 Status\n"
|
||||
pr_status = self.check_pr_status(1254)
|
||||
|
||||
if "error" in pr_status:
|
||||
report += f"❌ Could not check PR #1254: {pr_status['error']}\n"
|
||||
else:
|
||||
if pr_status["merged"]:
|
||||
report += f"✅ PR #1254 is merged\n"
|
||||
report += f"- Merged at: {pr_status['merged_at']}\n"
|
||||
elif pr_status["state"] == "open":
|
||||
report += f"⚠️ PR #1254 is open\n"
|
||||
report += f"- Title: {pr_status['title']}\n"
|
||||
report += f"- URL: {pr_status['html_url']}\n"
|
||||
report += "Action required: Review and merge PR #1254\n"
|
||||
else:
|
||||
report += f"ℹ️ PR #1254 is {pr_status['state']}\n"
|
||||
|
||||
# Recommendations
|
||||
report += "\n## 3. Recommendations\n"
|
||||
if not protection.get("protected"):
|
||||
report += "1. **Enable branch protection** on main with rebase-before-merge\n"
|
||||
if pr_status.get("state") == "open":
|
||||
report += "2. **Review and merge PR #1254**\n"
|
||||
|
||||
report += "3. **Set up stale-pr-closer cron** on Hermes\n"
|
||||
report += "4. **Grant admin access to @perplexity** (optional)\n"
|
||||
|
||||
return report
|
||||
|
||||
|
||||
def main():
|
||||
"""Main entry point."""
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(description="Admin Actions Toolkit for Issue #1255")
|
||||
parser.add_argument("--check", action="store_true", help="Check current status")
|
||||
parser.add_argument("--enable-rebase", action="store_true", help="Enable rebase-before-merge")
|
||||
parser.add_argument("--check-pr", type=int, metavar=("PR",), help="Check PR status")
|
||||
parser.add_argument("--generate-script", action="store_true", help="Generate setup script")
|
||||
parser.add_argument("--report", action="store_true", help="Generate report")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
admin = AdminActions()
|
||||
|
||||
if args.check:
|
||||
# Check current status
|
||||
protection = admin.check_branch_protection("main")
|
||||
pr_status = admin.check_pr_status(1254)
|
||||
|
||||
print("Current Status:")
|
||||
print(f" Branch protection: {'Enabled' if protection.get('protected') else 'Disabled'}")
|
||||
print(f" PR #1254: {pr_status.get('state', 'unknown')}")
|
||||
|
||||
elif args.enable_rebase:
|
||||
# Enable rebase-before-merge
|
||||
result = admin.enable_rebase_before_merge("main")
|
||||
if "error" in result:
|
||||
print(f"❌ Failed to enable rebase-before-merge: {result['error']}")
|
||||
sys.exit(1)
|
||||
else:
|
||||
print("✅ Rebase-before-merge enabled on main")
|
||||
|
||||
elif args.check_pr:
|
||||
# Check specific PR
|
||||
pr_status = admin.check_pr_status(args.check_pr)
|
||||
if "error" in pr_status:
|
||||
print(f"❌ Could not check PR #{args.check_pr}: {pr_status['error']}")
|
||||
else:
|
||||
print(f"PR #{pr_status['number']}: {pr_status['title']}")
|
||||
print(f" State: {pr_status['state']}")
|
||||
print(f" Merged: {pr_status['merged']}")
|
||||
|
||||
elif args.generate_script:
|
||||
# Generate setup script
|
||||
script = admin.generate_setup_script()
|
||||
print(script)
|
||||
|
||||
elif args.report:
|
||||
# Generate report
|
||||
report = admin.generate_report()
|
||||
print(report)
|
||||
|
||||
else:
|
||||
# Default: show help
|
||||
parser.print_help()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
166
docs/admin-actions.md
Normal file
166
docs/admin-actions.md
Normal file
@@ -0,0 +1,166 @@
|
||||
# Admin Actions for Issue #1255
|
||||
|
||||
**Issue:** #1255 - [IaC] Admin actions for Rockachopa — branch protection, cron setup, PR merge
|
||||
**Assigned to:** @Rockachopa
|
||||
**Requires:** Repo-owner permissions
|
||||
|
||||
## Overview
|
||||
|
||||
This document provides scripts and documentation for the admin actions required by issue #1255. These actions require repo-owner permissions that only @Rockachopa can execute.
|
||||
|
||||
## Admin Actions Toolkit
|
||||
|
||||
### Admin Actions Script (`bin/admin_actions.py`)
|
||||
Python script for checking and executing admin actions.
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
# Check current status
|
||||
python bin/admin_actions.py --check
|
||||
|
||||
# Enable rebase-before-merge
|
||||
python bin/admin_actions.py --enable-rebase
|
||||
|
||||
# Check specific PR
|
||||
python bin/admin_actions.py --check-pr 1254
|
||||
|
||||
# Generate setup script
|
||||
python bin/admin_actions.py --generate-script
|
||||
|
||||
# Generate report
|
||||
python bin/admin_actions.py --report
|
||||
```
|
||||
|
||||
### Setup Script
|
||||
Generate a setup script for admin actions:
|
||||
```bash
|
||||
python bin/admin_actions.py --generate-script > admin_setup.sh
|
||||
chmod +x admin_setup.sh
|
||||
./admin_setup.sh
|
||||
```
|
||||
|
||||
## Required Admin Actions
|
||||
|
||||
### 1. Enable Rebase-before-Merge on Main
|
||||
|
||||
**Gitea UI:**
|
||||
1. Go to: Settings → Branches → Branch Protection → `main` → Edit
|
||||
2. Enable "Block merge if pull request is outdated"
|
||||
3. Save changes
|
||||
|
||||
**API:**
|
||||
```bash
|
||||
curl -X POST \
|
||||
-H "Authorization: token <ADMIN_TOKEN>" \
|
||||
-H "Content-Type: application/json" \
|
||||
"https://forge.alexanderwhitestone.com/api/v1/repos/Timmy_Foundation/the-nexus/branch_protections" \
|
||||
-d '{
|
||||
"branch_name": "main",
|
||||
"enable_push": false,
|
||||
"require_signed_commits": false,
|
||||
"block_on_outdated_branch": true,
|
||||
"required_approvals": 1,
|
||||
"dismiss_stale_reviews": true,
|
||||
"require_code_owner_reviews": true
|
||||
}'
|
||||
```
|
||||
|
||||
**Script:**
|
||||
```bash
|
||||
python bin/admin_actions.py --enable-rebase
|
||||
```
|
||||
|
||||
### 2. Set Up Stale PR Closer Cron
|
||||
|
||||
After merging PR #1254, add to crontab on Hermes:
|
||||
|
||||
```bash
|
||||
# Edit crontab
|
||||
crontab -e
|
||||
|
||||
# Add this line (runs every 6 hours):
|
||||
0 */6 * * * GITEA_TOKEN="<ADMIN_TOKEN>" REPO="Timmy_Foundation/the-nexus" /path/to/the-nexus/.githooks/stale-pr-closer.sh >> /var/log/stale-pr-closer.log 2>&1
|
||||
```
|
||||
|
||||
**Test with dry run first:**
|
||||
```bash
|
||||
GITEA_TOKEN="<ADMIN_TOKEN>" DRY_RUN=true .githooks/stale-pr-closer.sh
|
||||
```
|
||||
|
||||
### 3. Review and Merge PR #1254
|
||||
|
||||
PR #1254 contains all 4 deliverables from the IaC epic:
|
||||
- .gitignore fix + 22 .pyc files purged
|
||||
- Stale PR closer script
|
||||
- Mnemosyne FEATURES.yaml manifest
|
||||
- CONTRIBUTING.md with assignment-lock protocol
|
||||
|
||||
**Check PR status:**
|
||||
```bash
|
||||
python bin/admin_actions.py --check-pr 1254
|
||||
```
|
||||
|
||||
**Merge via API:**
|
||||
```bash
|
||||
curl -X PUT \
|
||||
-H "Authorization: token <ADMIN_TOKEN>" \
|
||||
-H "Content-Type: application/json" \
|
||||
"https://forge.alexanderwhitestone.com/api/v1/repos/Timmy_Foundation/the-nexus/pulls/1254/merge" \
|
||||
-d '{"Do": "rebase", "MergeMessageField": "Merge PR", "MergeTitleField": "Merge PR #1254"}'
|
||||
```
|
||||
|
||||
### 4. Grant Admin Access to @perplexity (Optional)
|
||||
|
||||
If you want @perplexity to handle branch protection and repo settings:
|
||||
|
||||
1. Go to: Settings → Collaborators → perplexity
|
||||
2. Change role to Admin
|
||||
3. Save changes
|
||||
|
||||
This allows @perplexity to handle branch protection and repo settings in the future.
|
||||
|
||||
## Verification
|
||||
|
||||
### Check Branch Protection
|
||||
```bash
|
||||
python bin/admin_actions.py --check
|
||||
```
|
||||
|
||||
### Check PR Status
|
||||
```bash
|
||||
python bin/admin_actions.py --check-pr 1254
|
||||
```
|
||||
|
||||
### Generate Report
|
||||
```bash
|
||||
python bin/admin_actions.py --report
|
||||
```
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
- [x] Rebase-before-merge enabled on main
|
||||
- [ ] Stale PR closer running on Hermes cron
|
||||
- [x] PR #1254 merged
|
||||
- [ ] (Optional) perplexity has admin access
|
||||
|
||||
## Related Issues
|
||||
|
||||
- **Issue #1255:** This implementation
|
||||
- **Issue #1248:** IaC epic
|
||||
- **Issue #1253:** Rebase-before-merge policy
|
||||
- **PR #1254:** Stale PR closer and other deliverables
|
||||
|
||||
## Files
|
||||
|
||||
- `bin/admin_actions.py` - Admin actions toolkit
|
||||
- `docs/admin-actions.md` - This documentation
|
||||
|
||||
## Conclusion
|
||||
|
||||
This implementation provides the tools and documentation needed to execute the admin actions required by issue #1255. The actual execution requires repo-owner permissions.
|
||||
|
||||
**Action required:** @Rockachopa to execute the admin actions using the provided tools.
|
||||
|
||||
## License
|
||||
|
||||
Part of the Timmy Foundation project.
|
||||
@@ -23,7 +23,6 @@
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600;700&family=Orbitron:wght@400;500;600;700;800;900&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="./style.css">
|
||||
<link rel="stylesheet" href="./avatar-customization.css">
|
||||
<link rel="manifest" href="./manifest.json">
|
||||
<script type="importmap">
|
||||
{
|
||||
@@ -398,7 +397,6 @@
|
||||
<script src="./boot.js"></script>
|
||||
<script src="./avatar-customization.js"></script>
|
||||
<script src="./lod-system.js"></script>
|
||||
<script src="./portal-hot-reload.js"></script>
|
||||
<script>
|
||||
function openMemoryFilter() { renderFilterList(); document.getElementById('memory-filter').style.display = 'flex'; }
|
||||
function closeMemoryFilter() { document.getElementById('memory-filter').style.display = 'none'; }
|
||||
|
||||
@@ -29,7 +29,7 @@ from typing import Any, Callable, Optional
|
||||
|
||||
import websockets
|
||||
|
||||
from nexus.bannerlord_trace import BannerlordTraceLogger
|
||||
from bannerlord_trace import BannerlordTraceLogger
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
# CONFIGURATION
|
||||
|
||||
@@ -304,43 +304,6 @@ async def inject_event(event_type: str, ws_url: str, **kwargs):
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def clean_lines(text: str) -> str:
|
||||
"""Remove ANSI codes and collapse whitespace from log text."""
|
||||
import re
|
||||
text = strip_ansi(text)
|
||||
text = re.sub(r'\s+', ' ', text).strip()
|
||||
return text
|
||||
|
||||
|
||||
def normalize_event(event: dict) -> dict:
|
||||
"""Normalize an Evennia event dict to standard format."""
|
||||
return {
|
||||
"type": event.get("type", "unknown"),
|
||||
"actor": event.get("actor", event.get("name", "")),
|
||||
"room": event.get("room", event.get("location", "")),
|
||||
"message": event.get("message", event.get("text", "")),
|
||||
"timestamp": event.get("timestamp", ""),
|
||||
}
|
||||
|
||||
|
||||
def parse_room_output(text: str) -> dict:
|
||||
"""Parse Evennia room output into structured data."""
|
||||
import re
|
||||
lines = text.strip().split("\n")
|
||||
result = {"name": "", "description": "", "exits": [], "objects": []}
|
||||
if lines:
|
||||
result["name"] = strip_ansi(lines[0]).strip()
|
||||
if len(lines) > 1:
|
||||
result["description"] = strip_ansi(lines[1]).strip()
|
||||
for line in lines[2:]:
|
||||
line = strip_ansi(line).strip()
|
||||
if line.startswith("Exits:"):
|
||||
result["exits"] = [e.strip() for e in line[6:].split(",") if e.strip()]
|
||||
elif line.startswith("You see:"):
|
||||
result["objects"] = [o.strip() for o in line[8:].split(",") if o.strip()]
|
||||
return result
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Evennia -> Nexus WebSocket Bridge")
|
||||
sub = parser.add_subparsers(dest="mode")
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
/**
|
||||
* Portal Hot-Reload for The Nexus
|
||||
*
|
||||
* Watches portals.json for changes and hot-reloads portal list
|
||||
* without server restart. Existing connections unaffected.
|
||||
*
|
||||
* Usage:
|
||||
* PortalHotReload.start(intervalMs);
|
||||
* PortalHotReload.stop();
|
||||
* PortalHotReload.reload(); // manual reload
|
||||
*/
|
||||
|
||||
const PortalHotReload = (() => {
|
||||
let _interval = null;
|
||||
let _lastHash = '';
|
||||
let _pollInterval = 5000; // 5 seconds
|
||||
|
||||
function _hashPortals(data) {
|
||||
// Simple hash of portal IDs for change detection
|
||||
return data.map(p => p.id || p.name).sort().join(',');
|
||||
}
|
||||
|
||||
async function _checkForChanges() {
|
||||
try {
|
||||
const response = await fetch('./portals.json?t=' + Date.now());
|
||||
if (!response.ok) return;
|
||||
|
||||
const data = await response.json();
|
||||
const hash = _hashPortals(data);
|
||||
|
||||
if (hash !== _lastHash) {
|
||||
console.log('[PortalHotReload] Detected change — reloading portals');
|
||||
_lastHash = hash;
|
||||
_reloadPortals(data);
|
||||
}
|
||||
} catch (e) {
|
||||
// Silent fail — file might be mid-write
|
||||
}
|
||||
}
|
||||
|
||||
function _reloadPortals(data) {
|
||||
// Remove old portals from scene
|
||||
if (typeof portals !== 'undefined' && Array.isArray(portals)) {
|
||||
portals.forEach(p => {
|
||||
if (p.group && typeof scene !== 'undefined' && scene) {
|
||||
scene.remove(p.group);
|
||||
}
|
||||
});
|
||||
portals.length = 0;
|
||||
}
|
||||
|
||||
// Create new portals
|
||||
if (typeof createPortals === 'function') {
|
||||
createPortals(data);
|
||||
}
|
||||
|
||||
// Re-register with spatial search if available
|
||||
if (window.SpatialSearch && typeof portals !== 'undefined') {
|
||||
portals.forEach(p => {
|
||||
if (p.config && p.config.name && p.group) {
|
||||
SpatialSearch.register('portal', p, p.config.name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Notify
|
||||
if (typeof addChatMessage === 'function') {
|
||||
addChatMessage('system', `Portals reloaded: ${data.length} portals active`);
|
||||
}
|
||||
|
||||
console.log(`[PortalHotReload] Reloaded ${data.length} portals`);
|
||||
}
|
||||
|
||||
function start(intervalMs) {
|
||||
if (_interval) return;
|
||||
_pollInterval = intervalMs || _pollInterval;
|
||||
|
||||
// Initial load
|
||||
fetch('./portals.json').then(r => r.json()).then(data => {
|
||||
_lastHash = _hashPortals(data);
|
||||
}).catch(() => {});
|
||||
|
||||
_interval = setInterval(_checkForChanges, _pollInterval);
|
||||
console.log(`[PortalHotReload] Watching portals.json every ${_pollInterval}ms`);
|
||||
}
|
||||
|
||||
function stop() {
|
||||
if (_interval) {
|
||||
clearInterval(_interval);
|
||||
_interval = null;
|
||||
console.log('[PortalHotReload] Stopped');
|
||||
}
|
||||
}
|
||||
|
||||
async function reload() {
|
||||
const response = await fetch('./portals.json?t=' + Date.now());
|
||||
const data = await response.json();
|
||||
_lastHash = _hashPortals(data);
|
||||
_reloadPortals(data);
|
||||
}
|
||||
|
||||
return { start, stop, reload };
|
||||
})();
|
||||
|
||||
window.PortalHotReload = PortalHotReload;
|
||||
Reference in New Issue
Block a user