feat: Phase 3 — wire panel modules (heatmap, agent-board, dual-brain, LoRA, sovereignty, earth)
- core/theme.js: export NEXUS with full NEXUS.theme.* properties used by all 6 panels - core/ticker.js: add subscribe() convenience export so panels can self-register - data/gitea.js: also write state.agentStatus, activeAgentCount, zoneIntensity, commits, commitHashes - data/loaders.js: also write state.sovereignty - data/bitcoin.js: also write state.blockHeight, lastBlockHeight, newBlockDetected, starPulseIntensity - data/weather.js: also write state.weather - app.js: import + init all 6 panel modules, bootstrap data polling, call globalTicker.tick() Fixes #412 Refs #409 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,17 @@
|
||||
// modules/data/gitea.js — All Gitea API calls
|
||||
// Writes to S: _activeAgentCount, _matrixCommitHashes, agentStatus
|
||||
// Writes to S: _activeAgentCount, _matrixCommitHashes (legacy)
|
||||
// Writes to state: agentStatus, activeAgentCount, zoneIntensity, commits, commitHashes
|
||||
import { S } from '../state.js';
|
||||
import { state } from '../core/state.js';
|
||||
|
||||
// Zone intensity — agent name → author regex (mirrors panels/heatmap.js HEATMAP_ZONES)
|
||||
const _ZONE_PATTERNS = [
|
||||
{ name: 'Claude', pattern: /^claude$/i },
|
||||
{ name: 'Timmy', pattern: /^timmy/i },
|
||||
{ name: 'Kimi', pattern: /^kimi/i },
|
||||
{ name: 'Perplexity', pattern: /^perplexity/i },
|
||||
];
|
||||
const _ZONE_MAX_WEIGHT = 8;
|
||||
|
||||
const GITEA_BASE = 'http://143.198.27.163:3000/api/v1';
|
||||
const GITEA_TOKEN = 'dc0517a965226b7a0c5ffdd961b1ba26521ac592';
|
||||
@@ -119,22 +130,49 @@ export async function fetchAgentStatus() {
|
||||
|
||||
export async function refreshCommitData() {
|
||||
const commits = await fetchNexusCommits();
|
||||
S._matrixCommitHashes = commits.slice(0, 20)
|
||||
.map(c => (c.sha || '').slice(0, 7))
|
||||
.filter(h => h.length > 0);
|
||||
const hashes = commits.slice(0, 20).map(c => (c.sha || '').slice(0, 7)).filter(Boolean);
|
||||
|
||||
// Legacy write
|
||||
S._matrixCommitHashes = hashes;
|
||||
|
||||
// Core state writes
|
||||
state.commits = commits;
|
||||
state.commitHashes = hashes;
|
||||
|
||||
// Compute per-zone intensity (24 h decay window)
|
||||
const now = Date.now();
|
||||
const rawWeights = {};
|
||||
for (const c of commits) {
|
||||
const author = c.commit?.author?.name || c.author?.login || '';
|
||||
const age = now - new Date(c.commit?.author?.date || 0).getTime();
|
||||
if (age > DAY_MS) continue;
|
||||
const weight = 1 - age / DAY_MS;
|
||||
for (const { name, pattern } of _ZONE_PATTERNS) {
|
||||
if (pattern.test(author)) { rawWeights[name] = (rawWeights[name] || 0) + weight; break; }
|
||||
}
|
||||
}
|
||||
state.zoneIntensity = Object.fromEntries(
|
||||
_ZONE_PATTERNS.map(z => [z.name, Math.min((rawWeights[z.name] || 0) / _ZONE_MAX_WEIGHT, 1)])
|
||||
);
|
||||
|
||||
return commits;
|
||||
}
|
||||
|
||||
export async function refreshAgentData() {
|
||||
try {
|
||||
const data = await fetchAgentStatus();
|
||||
S._activeAgentCount = data.agents.filter(a => a.status === 'working').length;
|
||||
const count = data.agents.filter(a => a.status === 'working').length;
|
||||
S._activeAgentCount = count;
|
||||
state.agentStatus = data;
|
||||
state.activeAgentCount = count;
|
||||
return data;
|
||||
} catch {
|
||||
const fallback = { agents: AGENT_NAMES.map(n => ({
|
||||
name: n.toLowerCase(), status: 'unreachable', issue: null, prs_today: 0, local: false,
|
||||
})) };
|
||||
S._activeAgentCount = 0;
|
||||
state.agentStatus = fallback;
|
||||
state.activeAgentCount = 0;
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user