case_study
Analyze I Ching and Bazi case studies to understand traditional Chinese metaphysics applications. Retrieve specific cases by ID or browse categories like historical figures and modern examples for divination and fortune-telling insights.
Instructions
分析易经和八字案例
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| case_id | No | 案例ID(可选,不提供则返回案例列表) | |
| system | Yes | 案例类型 | |
| category | No | 案例分类(如历史人物、现代案例等) | |
| analysis_focus | No | 分析重点 |
Implementation Reference
- src/engines/knowledge-engine.js:67-92 (handler)Main handler function that implements the core logic for the 'case_study' tool. Handles both specific case analysis (via case_id) and listing cases.async analyzeCases({ case_id, system, category, analysis_focus = [] }) { try { this.logger.info('开始分析案例', { case_id, system, category, analysis_focus }); let result; if (case_id) { // 分析特定案例 const case_data = await this.getCaseById(case_id); result = await this.studyCase({ case_type: system, case_data: case_data, analysis_focus: analysis_focus.join(',') || 'comprehensive', study_purpose: 'analysis' }); } else { // 返回案例列表 result = await this.getCasesList(system, category, analysis_focus); } this.logger.info('案例分析完成'); return result; } catch (error) { this.logger.error('案例分析失败', { error: error.message }); throw error; }
- src/index.js:456-458 (registration)Registration of the 'case_study' tool handler in the main CallToolRequest switch statement, delegating to KnowledgeEngine.analyzeCases.case 'case_study': result = await knowledgeEngine.analyzeCases(args); break;
- src/index.js:348-375 (schema)Tool registration in ListToolsResponse, including the input schema definition for the 'case_study' tool.name: 'case_study', description: '分析易经和八字案例', inputSchema: { type: 'object', properties: { case_id: { type: 'string', description: '案例ID(可选,不提供则返回案例列表)' }, system: { type: 'string', enum: ['yijing', 'bazi', 'combined'], description: '案例类型' }, category: { type: 'string', description: '案例分类(如历史人物、现代案例等)' }, analysis_focus: { type: 'array', items: { type: 'string' }, description: '分析重点' } }, required: ['system'] }
- src/utils/validator.js:244-256 (schema)Joi validation schema used for input validation of the 'case_study' tool parameters.function createCaseStudySchema() { return Joi.object({ case_id: Joi.alternatives().try( Joi.string(), Joi.number().integer().positive() ).optional(), system: Joi.string().valid('yijing', 'bazi', 'combined').default('combined'), category: Joi.string().valid( 'career', 'relationship', 'health', 'wealth', 'general' ).default('general'), analysis_focus: Joi.string().optional() }); }
- Key helper function called by analyzeCases for in-depth case study analysis when a specific case_id is provided.async studyCase({ case_type, case_data, analysis_focus = 'comprehensive', study_purpose = 'learning' }) { try { this.logger.info('开始案例研究', { case_type, analysis_focus, study_purpose }); // 获取案例库中的相关案例 const similarCases = await this.findSimilarCases(case_type, case_data); // 进行案例分析 const caseAnalysis = await this.analyzeCaseData(case_data, case_type, analysis_focus); // 提取学习要点 const learningPoints = await this.extractLearningPoints(caseAnalysis, similarCases); // 生成对比分析 const comparativeAnalysis = await this.generateComparativeAnalysis(case_data, similarCases); // 总结经验教训 const lessonsLearned = await this.extractLessonsLearned(caseAnalysis, comparativeAnalysis); // 生成应用指导 const applicationGuidance = await this.generateApplicationGuidance(learningPoints, study_purpose); const result = { timestamp: new Date().toISOString(), case_type: case_type, analysis_focus: analysis_focus, study_purpose: study_purpose, case_analysis: caseAnalysis, similar_cases: similarCases, learning_points: learningPoints, comparative_analysis: comparativeAnalysis, lessons_learned: lessonsLearned, application_guidance: applicationGuidance, research_insights: this.generateResearchInsights(caseAnalysis, comparativeAnalysis), follow_up_studies: this.suggestFollowUpStudies(case_type, learningPoints) }; this.logger.info('案例研究完成'); return result; } catch (error) { this.logger.error('案例研究失败', { error: error.message }); throw error; } }