From d9a182c2ff2db56a8bd3a36666f0022cd29ebb5b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 5 Mar 2026 12:11:38 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B9=BF=E6=92=AD=E5=88=86=E5=8F=91?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8C=96=20=E2=80=94=20distribute-broadcasts?= =?UTF-8?q?=20workflow,=20script,=20and=20outbox=20structure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com> --- .github/workflows/distribute-broadcasts.yml | 35 ++++++++ broadcasts-outbox/.gitkeep | 0 broadcasts-outbox/DEV-001/.gitkeep | 0 broadcasts-outbox/DEV-002/.gitkeep | 0 broadcasts-outbox/DEV-003/.gitkeep | 0 broadcasts-outbox/DEV-004/.gitkeep | 0 broadcasts-outbox/DEV-005/.gitkeep | 0 broadcasts-outbox/DEV-009/.gitkeep | 0 broadcasts-outbox/DEV-010/.gitkeep | 0 broadcasts-outbox/DEV-011/.gitkeep | 0 package.json | 3 +- scripts/distribute-broadcasts.js | 88 +++++++++++++++++++++ 12 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/distribute-broadcasts.yml create mode 100644 broadcasts-outbox/.gitkeep create mode 100644 broadcasts-outbox/DEV-001/.gitkeep create mode 100644 broadcasts-outbox/DEV-002/.gitkeep create mode 100644 broadcasts-outbox/DEV-003/.gitkeep create mode 100644 broadcasts-outbox/DEV-004/.gitkeep create mode 100644 broadcasts-outbox/DEV-005/.gitkeep create mode 100644 broadcasts-outbox/DEV-009/.gitkeep create mode 100644 broadcasts-outbox/DEV-010/.gitkeep create mode 100644 broadcasts-outbox/DEV-011/.gitkeep create mode 100644 scripts/distribute-broadcasts.js diff --git a/.github/workflows/distribute-broadcasts.yml b/.github/workflows/distribute-broadcasts.yml new file mode 100644 index 00000000..7db2a234 --- /dev/null +++ b/.github/workflows/distribute-broadcasts.yml @@ -0,0 +1,35 @@ +name: 铸渊 · 广播分发 + +on: + push: + branches: [main] + paths: + - 'broadcasts-outbox/**' + workflow_dispatch: + +jobs: + distribute: + name: 📡 分发广播到开发者目录 + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + with: + ref: main + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Distribute broadcasts + run: node scripts/distribute-broadcasts.js + + - name: Commit distribution + run: | + git config user.name "铸渊 (ZhùYuān)" + git config user.email "zhuyuan@guanghulab.com" + git add . + git diff --cached --quiet || git commit -m "📡 铸渊广播分发 · $(date -u +%Y-%m-%d\ %H:%M\ UTC)" + git push diff --git a/broadcasts-outbox/.gitkeep b/broadcasts-outbox/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/broadcasts-outbox/DEV-001/.gitkeep b/broadcasts-outbox/DEV-001/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/broadcasts-outbox/DEV-002/.gitkeep b/broadcasts-outbox/DEV-002/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/broadcasts-outbox/DEV-003/.gitkeep b/broadcasts-outbox/DEV-003/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/broadcasts-outbox/DEV-004/.gitkeep b/broadcasts-outbox/DEV-004/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/broadcasts-outbox/DEV-005/.gitkeep b/broadcasts-outbox/DEV-005/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/broadcasts-outbox/DEV-009/.gitkeep b/broadcasts-outbox/DEV-009/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/broadcasts-outbox/DEV-010/.gitkeep b/broadcasts-outbox/DEV-010/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/broadcasts-outbox/DEV-011/.gitkeep b/broadcasts-outbox/DEV-011/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/package.json b/package.json index a56c069e..06f33f0c 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "start:test": "NODE_ENV=test node src/index.js", "brain:sync": "node scripts/process-broadcasts.js", "brain:daily-check": "node scripts/daily-check.js", - "brain:update-memory": "node scripts/update-memory.js" + "brain:update-memory": "node scripts/update-memory.js", + "broadcast:distribute": "node scripts/distribute-broadcasts.js" }, "dependencies": { "next": "15.3.2", diff --git a/scripts/distribute-broadcasts.js b/scripts/distribute-broadcasts.js new file mode 100644 index 00000000..38441af9 --- /dev/null +++ b/scripts/distribute-broadcasts.js @@ -0,0 +1,88 @@ +// scripts/distribute-broadcasts.js +// 铸渊广播分发引擎 +// 检测 broadcasts-outbox/DEV-00X/ 中的新广播 → 复制到各开发者模块目录的 LATEST-BROADCAST.md + +const fs = require('fs'); +const path = require('path'); + +const OUTBOX = 'broadcasts-outbox'; +const ARCHIVE = '.github/broadcasts/distributed'; + +// ========== 开发者 → 模块目录 路由映射表 ========== +// 新增开发者时,在此表新增一行即可 +const DEV_ROUTES = { + 'DEV-001': { name: '页页', dirs: ['backend', 'src'] }, + 'DEV-002': { name: '肥猫', dirs: ['frontend', 'persona-selector', 'chat-bubble'] }, + 'DEV-003': { name: '燕樊', dirs: ['settings', 'cloud-drive'] }, + 'DEV-004': { name: '之之', dirs: ['dingtalk-bot'] }, + 'DEV-005': { name: '小草莓', dirs: ['status-board'] }, + 'DEV-009': { name: '花尔', dirs: ['user-center'] }, + 'DEV-010': { name: '桔子', dirs: ['ticket-system'] }, + 'DEV-011': { name: '匆匆那年', dirs: [] }, // 待分配模块后补充 +}; + +if (!fs.existsSync(OUTBOX)) { + console.log('📭 无 broadcasts-outbox 目录'); + process.exit(0); +} + +// 扫描 outbox 下每个 DEV-00X 子目录 +const devDirs = fs.readdirSync(OUTBOX, { withFileTypes: true }) + .filter(entry => entry.isDirectory() && entry.name.startsWith('DEV-')) + .map(entry => entry.name); + +if (devDirs.length === 0) { + console.log('📭 无新广播待分发'); + process.exit(0); +} + +let totalDistributed = 0; + +devDirs.forEach(devId => { + const outboxDir = path.join(OUTBOX, devId); + const files = fs.readdirSync(outboxDir).filter(f => + f.endsWith('.md') || f.endsWith('.json') + ); + + if (files.length === 0) return; + + const route = DEV_ROUTES[devId]; + if (!route || route.dirs.length === 0) { + console.warn('⚠️ ' + devId + ' 无模块目录映射,广播保留在 outbox'); + return; + } + + files.forEach(file => { + const rawContent = fs.readFileSync(path.join(outboxDir, file), 'utf8'); + + // 对 JSON 格式广播做基础校验 + if (file.endsWith('.json')) { + try { + JSON.parse(rawContent); + } catch (e) { + console.error('❌ [INVALID JSON] ' + path.join(outboxDir, file) + ' → ' + e.message + ',跳过分发'); + return; + } + } + + // 写入该开发者的每个模块目录 + route.dirs.forEach(dir => { + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir, { recursive: true }); + } + const targetFile = path.join(dir, 'LATEST-BROADCAST.md'); + fs.writeFileSync(targetFile, rawContent); + console.log('📡 ' + devId + '(' + route.name + ') → ' + targetFile); + }); + + // 归档已分发广播(使用 UTC 时间戳确保跨时区一致性) + if (!fs.existsSync(ARCHIVE)) fs.mkdirSync(ARCHIVE, { recursive: true }); + const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19); + const archivePath = path.join(ARCHIVE, timestamp + '-' + devId + '-' + file); + fs.renameSync(path.join(outboxDir, file), archivePath); + + totalDistributed++; + }); +}); + +console.log('\n✅ 广播分发完成,共 ' + totalDistributed + ' 条');