同步 enhance/bridge/smoke/retire 模块、vendor 3.3.34、增强面板与 PRD 文档, Hub 接入 hub-routes-prd,含安装/经验/模块说明与 co-integration 运维脚本。 Co-authored-by: Cursor <cursoragent@cursor.com>
57 lines
1.8 KiB
JavaScript
57 lines
1.8 KiB
JavaScript
'use strict';
|
||
|
||
const fs = require('fs');
|
||
const path = require('path');
|
||
const os = require('os');
|
||
|
||
const RETIRE_SCRIPT_CANDIDATES = [
|
||
path.join(__dirname, '../../开发文档/脚本/retire_cochat.sh'),
|
||
path.join(process.cwd(), '开发文档/脚本/retire_cochat.sh'),
|
||
];
|
||
|
||
function findRetireScript() {
|
||
const ws = process.env.PCHAT_WORKSPACE || '/Users/karuo/Documents/个人';
|
||
const candidates = [
|
||
path.join(ws, '开发文档/脚本/retire_cochat.sh'),
|
||
...RETIRE_SCRIPT_CANDIDATES,
|
||
];
|
||
for (const p of candidates) {
|
||
if (fs.existsSync(p)) return p;
|
||
}
|
||
return null;
|
||
}
|
||
|
||
function coChatInstalled() {
|
||
const extGlob = path.join(os.homedir(), '.cursor/extensions');
|
||
if (!fs.existsSync(extGlob)) return { installed: false, paths: [] };
|
||
const paths = fs.readdirSync(extGlob).filter((d) => d.startsWith('co-chat.co-chat-panel')).map((d) => path.join(extGlob, d));
|
||
return { installed: paths.length > 0, paths };
|
||
}
|
||
|
||
function checkRetirePreconditions(enhanceState) {
|
||
const script = findRetireScript();
|
||
const co = coChatInstalled();
|
||
const patchPass = !!(enhanceState?.patchOk || enhanceState?.patchNativeOk);
|
||
const gates = {
|
||
permOk: !!enhanceState?.permOk,
|
||
patchOk: !!enhanceState?.patchOk,
|
||
patchNativeOk: !!enhanceState?.patchNativeOk,
|
||
cursorPrefOk: !!enhanceState?.cursorPrefOk,
|
||
scriptReady: !!script,
|
||
coChatPresent: co.installed,
|
||
};
|
||
const ready = gates.scriptReady && gates.permOk && patchPass && gates.cursorPrefOk;
|
||
return {
|
||
ok: true,
|
||
script,
|
||
coChat: co,
|
||
gates,
|
||
canExecute: ready,
|
||
message: ready
|
||
? '前置全绿,可执行 retire_cochat.sh(需人工确认)'
|
||
: '未满足卸载前置:需 W2 + W8(patchOk 或 patchNativeOk)+ W6 + retire 脚本就绪',
|
||
};
|
||
}
|
||
|
||
module.exports = { findRetireScript, checkRetirePreconditions, coChatInstalled };
|