@openyida/yidacli 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/env.js +1 -1
- package/package.json +1 -1
package/dist/env.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let fs=require("fs"),path=require("path"),os=require("os"),
|
|
1
|
+
let fs=require("fs"),path=require("path"),os=require("os"),{loadCookieData,resolveBaseUrl,extractInfoFromCookies}=require("./utils"),home=os.homedir();function detectActiveTool(){var o=process.env,e=process.cwd();return o.QODER_IDE||o.QODER_AGENT?{tool:"qoder",displayName:"Qoder",dirName:".qoder",workspaceRoot:path.join(e,"openyida")}:o.CLAUDE_CODE?{tool:"claude-code",displayName:"Claude Code",dirName:".claudecode",workspaceRoot:path.join(e,"openyida")}:o.OPENCODE?{tool:"opencode",displayName:"OpenCode",dirName:".opencode",workspaceRoot:path.join(e,"openyida")}:o.CURSOR_TRACE_ID||(o.VSCODE_GIT_ASKPASS_NODE||"").includes("Cursor")?{tool:"cursor",displayName:"Cursor",dirName:".cursor",workspaceRoot:path.join(e,"openyida")}:o.IFLOW_ACTIVE||o.IFLOW_IDE?{tool:"iflow",displayName:"iFlow",dirName:".iflow",workspaceRoot:path.join(e,"openyida")}:o.AGENT_WORK_ROOT&&o.AGENT_WORK_ROOT.includes(".real")?{tool:"wukong",displayName:"悟空(Wukong)",dirName:".real",workspaceRoot:path.join(home,".real","workspace","openyida")}:"vscode"===o.TERM_PROGRAM?{tool:"aone-copilot",displayName:"Aone Copilot",dirName:".aone_copilot",workspaceRoot:path.join(e,"openyida")}:null}function getInstalledTools(){return[{dirName:".real",displayName:"悟空(Wukong)"},{dirName:".opencode",displayName:"OpenCode"},{dirName:".claudecode",displayName:"Claude Code"},{dirName:".aone_copilot",displayName:"Aone Copilot"},{dirName:".cursor",displayName:"Cursor"},{dirName:".qoder",displayName:"Qoder"},{dirName:".iflow",displayName:"iFlow"}].filter(({dirName:o})=>fs.existsSync(path.join(home,o)))}function detectEnvironment(){let s=detectActiveTool();var o=getInstalledTools();let r=path.join(process.cwd(),"openyida");o=o.map(({dirName:o,displayName:e})=>{var l=".real"===o,a=s&&s.dirName===o,l=l?path.join(home,".real","workspace","openyida"):r;return{displayName:e,dirName:o,isActive:!!a,hasProject:fs.existsSync(l),workspaceRoot:l}});return{activeToolName:s?s.displayName:null,activeProjectRoot:s?s.workspaceRoot:null,results:o}}function detectLoginStatus(o){var e,l,a,o=loadCookieData(o);return o&&o.cookies?({csrfToken:e,corpId:l,userId:a}=extractInfoFromCookies(o.cookies),{loggedIn:!!e,csrfToken:e,corpId:l,userId:a,baseUrl:resolveBaseUrl(o)}):{loggedIn:!1,csrfToken:null,corpId:null,userId:null,baseUrl:null}}function run(){var o="=".repeat(55),{activeToolName:e,activeProjectRoot:l,results:a}=(console.log(o),console.log(" yidacli env - 环境检测"),console.log(o),console.log("\n📋 系统信息"),console.log(` 操作系统: ${process.platform} (${os.arch()})`),console.log(" Node.js: "+process.version),console.log(" 主目录: "+os.homedir()),console.log(" 工作目录: "+process.cwd()),console.log("\n🤖 AI 工具检测"),detectEnvironment());if(0===a.length)console.log(" ⚠️ 未检测到任何已知 AI 工具");else for(var{displayName:s,isActive:r,hasProject:n,workspaceRoot:i}of a){let o,e;e=r&&n?(o="✅","← 当前活跃,项目已就绪"):r&&!n?(o="🟡","← 当前活跃,但无 openyida 项目"):!r&&n?(o="⬜","(已安装,项目存在,但未活跃)"):(o="⬜","(已安装,未活跃)"),console.log(` ${o} ${s.padEnd(18)} `+e)}console.log("\n🎯 当前生效环境"),e&&l?(console.log(" AI 工具: "+e),console.log(" 项目根目录: "+l)):(0<(e=a.filter(o=>o.isActive)).length?console.log(` AI 工具: ${e.map(o=>o.displayName).join(", ")} (活跃,但无 openyida 项目)`):console.log(" AI 工具: 未检测到活跃工具"),console.log(` 项目根目录: ${process.cwd()} (fallback)`)),console.log("\n🔐 登录态检测");a=detectLoginStatus(l||process.cwd());a.loggedIn?(console.log(" 状态: ✅ 已登录"),console.log(" 域名: "+a.baseUrl),console.log(" 组织 ID: "+(a.corpId||"(未知)")),console.log(" 用户 ID: "+(a.userId||"(未知)")),console.log(` csrf_token: ${a.csrfToken.slice(0,16)}...`)):console.log(" 状态: ❌ 未登录(运行 yidacli login 进行登录)"),console.log("\n"+o)}module.exports={run:run,detectEnvironment:detectEnvironment,detectLoginStatus:detectLoginStatus};
|