同步 enhance/bridge/smoke/retire 模块、vendor 3.3.34、增强面板与 PRD 文档, Hub 接入 hub-routes-prd,含安装/经验/模块说明与 co-integration 运维脚本。 Co-authored-by: Cursor <cursoragent@cursor.com>
39 lines
1.4 KiB
JavaScript
39 lines
1.4 KiB
JavaScript
'use strict';
|
||
|
||
const fs = require('fs');
|
||
const path = require('path');
|
||
|
||
const MODE_BADGES = { A: 'A·续跑', B: 'B·增强', 'A+B': 'A+B·已桥接' };
|
||
|
||
function detectRulesConflict(workspace) {
|
||
const rulesDir = path.join(workspace, '.cursor', 'rules');
|
||
const hits = [];
|
||
if (!fs.existsSync(rulesDir)) return { conflict: false, hits, message: '无 rules 目录' };
|
||
const files = fs.readdirSync(rulesDir).filter((f) => f.endsWith('.mdc') && !/\.retired$/i.test(f));
|
||
const hasPchat = files.some((f) => /persistent-chat/i.test(f));
|
||
const hasCochat = files.some((f) => /^co-chat\.mdc$/i.test(f));
|
||
if (hasPchat && hasCochat) {
|
||
hits.push('co-chat.mdc', 'persistent-chat.mdc');
|
||
return {
|
||
conflict: true,
|
||
hits,
|
||
message: '同一工作区同时加载 co-chat.mdc 与 persistent-chat.mdc — 请用双 Chat 模板分离(FR-TPL)',
|
||
};
|
||
}
|
||
return { conflict: false, hits: files, message: hasPchat ? '仅 persistent-chat(模式 A OK)' : (hasCochat ? '仅 co-chat(建议迁移到 pchat)' : '未检测到 pchat/co-chat 规则') };
|
||
}
|
||
|
||
function sessionBadge(session) {
|
||
const mode = session?.mode || 'A';
|
||
if (session?.bridged && mode === 'A') return MODE_BADGES['A+B'];
|
||
return MODE_BADGES[mode] || MODE_BADGES.A;
|
||
}
|
||
|
||
function setSessionMode(session, mode) {
|
||
if (!['A', 'B', 'A+B'].includes(mode)) return false;
|
||
session.mode = mode;
|
||
return true;
|
||
}
|
||
|
||
module.exports = { detectRulesConflict, sessionBadge, setSessionMode, MODE_BADGES };
|