/** * 示例:使用Sisyphus编排机制的debatewiki功能 * * 此示例展示了如何使用sisyphus-debatewiki-plugin中的功能 * 通过Sisyphus编排机制,将任务委托给专门的智能体 */ import { startDiscussion, calculateVotingConsensus, createPage, createProject, performOpenCoding } from './index'; async function exampleUsage() { console.log('🚀 启动sisyphus-debatewiki-plugin示例'); // 1. 启动论坛辩论 console.log('\n📝 1. 启动论坛辩论...'); const debateSession = await startDiscussion( 'free_debate', ['proponent', 'opponent', 'moderator'], 'AI伦理与人类工作' ); console.log(` ✅ 辩论会话创建成功: ${debateSession.id}`); // 2. 计算投票共识 console.log('\n📊 2. 计算投票共识...'); const mockMessages = [ { agent_name: 'proponent', content: 'vote: yes', timestamp: new Date() }, { agent_name: 'opponent', content: 'vote: no', timestamp: new Date() }, { agent_name: 'moderator', content: 'vote: yes', timestamp: new Date() } ]; const consensusResult = await calculateVotingConsensus(mockMessages, 0.6); console.log(` ✅ 共识达成: ${consensusResult.achieved}`); console.log(` ✅ 同意率: ${(consensusResult.agreement_ratio * 100).toFixed(1)}%`); // 3. 创建维基页面 console.log('\n🌐 3. 创建维基页面...'); const wikiPage = await createPage( 'AI伦理与人类工作辩论总结', `# AI伦理与人类工作辩论总结 ## 辩论主题 AI伦理与人类工作 ## 主要观点 - 正方: AI将创造更多工作机会,提升人类生产力 - 反: AI将取代人类工作,导致大规模失业 ## 投票结果 - 同意: 2票 - 反对: 1票 - 同意率: ${(consensusResult.agreement_ratio * 100).toFixed(1)}% - 共识达成: ${consensusResult.achieved ? '是' : '否'} ## 结论 ${consensusResult.summary} `, 'moderator', 'published' ); console.log(` ✅ 维基页面创建成功: ${wikiPage.title}`); // 4. 创建扎根理论项目 console.log('\n🔬 4. 创建扎根理论项目...'); const gtProject = await createProject( 'AI对就业影响研究', '研究AI对不同类型工作岗位的影响', ['interview1.txt', 'interview2.txt', 'interview3.txt'], ['researcher1', 'researcher2', 'analyst1'] ); console.log(` ✅ 扎根理论项目创建成功: ${gtProject.name}`); // 5. 执行开放编码 console.log('\n🏷️ 5. 执行开放编码...'); const mockDocumentContent = '用户表达了对AI取代人工岗位的担忧,认为这将导致大规模失业'; const codingResult = await performOpenCoding( gtProject.id, 'interview1.txt', mockDocumentContent, 'researcher1' ); console.log(` ✅ 完成开放编码,创建了 ${codingResult.length} 个编码`); console.log('\n🎉 所有示例操作完成!'); console.log('\n📋 Sisyphus编排机制的优势:'); console.log(' • 任务委托给专业智能体'); console.log(' • 避免了类构造函数问题'); console.log(' • 与oh-my-opencode架构兼容'); console.log(' • 支持并行和后台任务执行'); console.log(' • 可扩展的智能体生态系统'); } // 运行示例 exampleUsage().catch(console.error);