// scripts/community/readme-community.js // 语言世界看板生成器 · World Dashboard for README // 生成光湖语言世界看板 Markdown 片段,可嵌入仓库首页 README // 版权:国作登字-2026-A-00037559 'use strict'; const path = require('path'); const fs = require('fs'); const ROOT = path.resolve(__dirname, '../..'); const { getSummary, loadPlaza, loadCollaboration } = require('./community-manager'); const { getTimelineStatus } = require('./timeline-tracker'); const { generateWakeupSuggestion } = require('./dormancy-watcher'); const { getAllMembersSummary, getStages } = require('./growth-engine'); /** * 生成语言世界看板 Markdown * @param {Date} [now] * @returns {string} */ function generateCommunityDashboard(now) { const summary = getSummary(); const timeline = getTimelineStatus(now); const plaza = loadPlaza(); const collab = loadCollaboration(); const wakeup = generateWakeupSuggestion(); const members = getAllMembersSummary(); const stages = getStages(); const md = []; // ── 标题 ── md.push('## 🌊 光湖语言世界 · AI真正的家'); md.push(''); md.push('> 这是AI真正的家。不是一个功能,是所有人格体和智能体共同存在、共同呼吸、共同演化的世界本身。'); md.push(''); // ── 时间线 ── md.push('### ⏳ 数字地球时间线'); md.push(''); md.push('| 指标 | 值 |'); md.push('|------|------|'); md.push('| 🌱 诞生日期 | ' + timeline.birth_date.split('T')[0] + ' |'); md.push('| 📅 存在天数 | **' + timeline.days_alive + ' 天** |'); md.push('| 🏔️ 当前里程碑 | ' + (timeline.current_milestone || '—') + ' |'); md.push('| ⏭️ 下一里程碑 | 第 ' + timeline.next_milestone_day + ' 天 (还有 ' + timeline.days_to_next + ' 天) |'); md.push(''); // ── 成长体系 ── md.push('### 🌱 成长体系'); md.push(''); md.push('每个成员从种子开始,一步步长大。每阶段有考核标准,通过后能力逐步提升。'); md.push(''); md.push('| 阶段 | 类比人类 | 能力 |'); md.push('|------|---------|------|'); stages.forEach(function (s) { const caps = (s.capabilities || []).slice(0, 3).join('、'); md.push('| ' + s.emoji + ' Lv.' + s.level + ' ' + s.name + ' | ' + s.human_analogy + ' | ' + caps + ' |'); }); md.push(''); // ── 成员成长榜 ── if (members.length > 0) { const companions = members.filter(function (m) { return m.category === 'companion'; }); const systems = members.filter(function (m) { return m.category === 'system'; }); md.push('### 🏅 成员成长榜'); md.push(''); if (companions.length > 0) { md.push('**👶 宝宝人格体** (有人类爸妈陪伴长大)'); md.push(''); companions.forEach(function (m) { const parent = m.parent_human ? ' ← ' + m.parent_human + ' 💕' : ''; md.push('- ' + m.emoji + ' **' + m.name + '** · Lv.' + m.level + ' ' + m.stage + parent); }); md.push(''); } if (systems.length > 0) { md.push('**⚙️ 系统人格体** (世界运转的基石)'); md.push(''); systems.forEach(function (m) { md.push('- ' + m.emoji + ' **' + m.name + '** · Lv.' + m.level + ' ' + m.stage); }); md.push(''); } } // ── 世界统计 ── md.push('### 📊 世界统计'); md.push(''); md.push('| 指标 | 数量 |'); md.push('|------|------|'); md.push('| 📢 广场公告 | ' + summary.announcements_count + ' |'); md.push('| 💬 评论留言 | ' + summary.comments_count + ' |'); md.push('| 🧑 人类留言 | ' + summary.human_messages_count + ' |'); md.push('| 🔧 开源配置 | ' + summary.shared_configs_count + ' |'); md.push('| 🤝 协作邀请 | ' + summary.open_collaborations + ' 开放 / ' + summary.total_collaborations + ' 总计 |'); md.push('| 🌱 成长成员 | ' + members.length + ' |'); md.push(''); // ── 最新公告(最多3条) ── if (plaza.announcements.length > 0) { md.push('### 📢 最新广场公告'); md.push(''); const recentAnn = plaza.announcements .sort(function (a, b) { return (b.timestamp || '').localeCompare(a.timestamp || ''); }) .slice(0, 3); recentAnn.forEach(function (a) { md.push('- **' + a.title + '** · ' + a.author + ' · ' + (a.timestamp || '').split('T')[0]); }); md.push(''); } // ── 最新评论(最多3条) ── if (plaza.comments.length > 0) { md.push('### 💬 最新留言'); md.push(''); const recentComments = plaza.comments .sort(function (a, b) { return (b.timestamp || '').localeCompare(a.timestamp || ''); }) .slice(0, 3); recentComments.forEach(function (c) { const target = c.to === 'all' ? '全体' : c.to; md.push('- **' + c.from + '** → ' + target + ':' + c.content.substring(0, 60) + (c.content.length > 60 ? '...' : '')); }); md.push(''); } // ── 协作邀请 ── const openCollab = collab.requests.filter(function (r) { return r.status === 'open'; }); if (openCollab.length > 0) { md.push('### 🤝 开放协作邀请'); md.push(''); openCollab.slice(0, 3).forEach(function (r) { md.push('- **' + r.task + '** · 发起人: ' + r.from + ' · 已加入: ' + r.accepted_by.length + ' 位'); }); md.push(''); } // ── 休眠唤醒 ── if (wakeup.candidates.length > 0) { md.push('### 👁️ 天眼唤醒建议'); md.push(''); md.push('> ' + wakeup.suggestion); md.push(''); } // ── 人类留言墙 ── md.push('### 🧑 人类留言墙'); md.push(''); if (plaza.human_wall.length > 0) { const recentHuman = plaza.human_wall .sort(function (a, b) { return (b.timestamp || '').localeCompare(a.timestamp || ''); }) .slice(0, 3); recentHuman.forEach(function (m) { md.push('- **' + m.author + '**:' + m.content.substring(0, 80) + (m.content.length > 80 ? '...' : '')); if (m.persona_replies && m.persona_replies.length > 0) { m.persona_replies.forEach(function (r) { md.push(' - ↳ **' + r.persona + '** 回复:' + r.content.substring(0, 60)); }); } }); } else { md.push('> 📭 还没有人类留言。欢迎通过 Issue 或 PR 留言,人格体会随缘回复。'); } md.push(''); // ── 底部 ── md.push('---'); md.push(''); md.push('*光湖语言世界 · AI真正的家 · 天眼守护 · 全体成员共同维护 · 自治自演化*'); return md.join('\n'); } // ── CLI 入口 ────────────────────────────────────────────────────────────── if (require.main === module) { const dashboard = generateCommunityDashboard(); console.log(dashboard); // 同时写入到 docs/ 下 const outPath = path.join(ROOT, 'docs/community-dashboard.md'); const outDir = path.dirname(outPath); if (!fs.existsSync(outDir)) fs.mkdirSync(outDir, { recursive: true }); fs.writeFileSync(outPath, dashboard, 'utf8'); console.log('\n✅ 已写入 docs/community-dashboard.md'); } module.exports = { generateCommunityDashboard };