@erosolaraijs/cure 3.0.5 → 3.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erosolaraijs/cure",
3
- "version": "3.0.5",
3
+ "version": "3.0.7",
4
4
  "description": "AI-powered unified cancer treatment framework with multi-provider support for medical research and patient care",
5
5
  "main": "dist/bin/cure.js",
6
6
  "type": "module",
package/src/bin/cure.ts CHANGED
@@ -755,40 +755,70 @@ async function processInput(input: string): Promise<void> {
755
755
  }
756
756
  console.log();
757
757
 
758
- // Run the comprehensive cure protocol
759
- await generateCureProtocol(detectedCancer, detectedStage, detectedMutations);
758
+ // AI-FIRST approach: Use AI as the PRIMARY treatment recommendation engine
759
+ if (getActiveApiKey()) {
760
+ console.log(`${colors.cyan}🤖 Consulting ${getActiveModel()} for treatment recommendations...${colors.reset}\n`);
760
761
 
761
- // Also run clinical trials search
762
- console.log(`\n${colors.cyan}🔬 Searching Clinical Trials...${colors.reset}\n`);
763
- await findClinicalTrials(detectedCancer, detectedMutations);
762
+ const aiPrompt = `You are an expert oncologist AI. Generate a comprehensive cancer treatment plan for:
764
763
 
765
- // Run drug discovery for key targets
766
- if (detectedMutations.length > 0) {
767
- console.log(`\n${colors.cyan}💊 Analyzing Drug Targets...${colors.reset}\n`);
768
- await discoverTargets(detectedMutations[0], detectedCancer);
769
- }
764
+ Cancer Type: ${detectedCancer}
765
+ Stage: ${detectedStage}
766
+ ${detectedMutations.length > 0 ? `Known Mutations/Biomarkers: ${detectedMutations.join(', ')}` : 'Mutations: Not specified - recommend testing'}
770
767
 
771
- // Try to enhance with AI analysis (optional - works without API credits)
772
- if (getActiveApiKey()) {
773
- console.log(`\n${colors.cyan}🤖 AI Analysis...${colors.reset}`);
774
- const enhancedPrompt = `Based on the cure protocol, clinical trials, and drug targets shown above for ${detectedCancer} cancer (stage ${detectedStage}${detectedMutations.length > 0 ? `, mutations: ${detectedMutations.join(', ')}` : ''}), provide a brief personalized summary with:
775
- 1. Top 3 recommended treatment approaches in order of priority
776
- 2. Most promising clinical trial categories to explore
777
- 3. Key biomarkers to test if not already done
778
- 4. Expected outcomes with current best treatments
779
- Keep it concise and actionable.`;
780
-
781
- const aiResponse = await callAI(enhancedPrompt);
782
- // Only show AI response if it's not an error
783
- if (!aiResponse.includes('API Error') && !aiResponse.includes('credits')) {
784
- console.log(`\n${aiResponse}`);
768
+ Provide a structured treatment plan with:
769
+
770
+ 1. **PRIMARY TREATMENT RECOMMENDATION**
771
+ - First-line therapy with specific drug names and regimens
772
+ - Rationale based on current guidelines (NCCN, ESMO, ASCO)
773
+
774
+ 2. **TARGETED THERAPIES** (if applicable)
775
+ - Specific FDA-approved drugs for any detected mutations
776
+ - Companion diagnostics to order
777
+
778
+ 3. **IMMUNOTHERAPY CONSIDERATIONS**
779
+ - Checkpoint inhibitors if appropriate (pembrolizumab, nivolumab, etc.)
780
+ - Biomarkers to test (PD-L1, MSI, TMB)
781
+
782
+ 4. **CLINICAL TRIALS TO CONSIDER**
783
+ - Mention specific trial categories or approaches worth exploring
784
+ - Note: Always verify on ClinicalTrials.gov
785
+
786
+ 5. **MONITORING & FOLLOW-UP**
787
+ - Response assessment schedule
788
+ - Key biomarkers to track
789
+
790
+ 6. **PROGNOSIS DISCUSSION**
791
+ - Realistic outcome expectations based on published data
792
+ - Important: Note this is general information, individual outcomes vary
793
+
794
+ Be evidence-based and cite specific landmark trials where relevant (e.g., KEYNOTE-189, CheckMate-067, DESTINY-Breast03). Keep response focused and clinically actionable.`;
795
+
796
+ const aiResponse = await callAI(aiPrompt);
797
+
798
+ // Check if AI response is valid
799
+ if (!aiResponse.includes('API Error') && !aiResponse.includes('credits') && !aiResponse.includes('API key not set') && !aiResponse.includes('Connection error')) {
800
+ console.log(`${colors.green}═══════════════════════════════════════════════════════════════${colors.reset}`);
801
+ console.log(`${colors.green} AI-GENERATED TREATMENT PLAN (${getActiveModel()})${colors.reset}`);
802
+ console.log(`${colors.green}═══════════════════════════════════════════════════════════════${colors.reset}\n`);
803
+ console.log(aiResponse);
804
+ console.log(`\n${colors.dim}⚠ This is AI-generated guidance. Always consult with treating oncologist.${colors.reset}`);
785
805
  } else {
786
- console.log(`\n${colors.dim}AI summary skipped (API quota). Protocol complete above.${colors.reset}`);
806
+ // AI failed - show the actual error
807
+ console.log(`${colors.red}AI Error: ${aiResponse}${colors.reset}`);
808
+ console.log(`${colors.yellow}Falling back to local treatment database...${colors.reset}\n`);
809
+ await generateCureProtocol(detectedCancer, detectedStage, detectedMutations);
787
810
  }
788
811
  } else {
789
- console.log(`\n${colors.dim}Set API key with /key for AI-powered insights.${colors.reset}`);
812
+ // No API key - use local protocol with clear disclaimer
813
+ console.log(`${colors.yellow}No API key set - using local treatment database${colors.reset}`);
814
+ console.log(`${colors.dim}Set API key with /key YOUR_KEY for AI-powered recommendations${colors.reset}\n`);
815
+ await generateCureProtocol(detectedCancer, detectedStage, detectedMutations);
790
816
  }
791
817
 
818
+ // Also run clinical trials search (uses real NCT IDs)
819
+ console.log(`\n${colors.cyan}🔬 Searching Clinical Trials...${colors.reset}\n`);
820
+ await findClinicalTrials(detectedCancer, detectedMutations);
821
+
792
822
  console.log(`\n${colors.green}═══════════════════════════════════════════════════════════════${colors.reset}`);
793
823
  console.log(`${colors.green} ✅ CURE PROTOCOL COMPLETE${colors.reset}`);
794
824
  console.log(`${colors.green}═══════════════════════════════════════════════════════════════${colors.reset}`);
@@ -882,6 +912,71 @@ async function designTreatmentPlan(patientId: string, protocolId?: string): Prom
882
912
  async function generateCureProtocol(cancerType: string, stage: string, mutations: string[]): Promise<void> {
883
913
  console.log(`\n${colors.cyan}Generating cure protocol for ${cancerType} cancer, stage ${stage}...${colors.reset}\n`);
884
914
 
915
+ // AI-FIRST APPROACH: Use AI as primary treatment recommendation engine
916
+ const apiKey = getActiveApiKey();
917
+ if (apiKey) {
918
+ console.log(`${colors.cyan}🤖 Consulting ${getActiveModel()} for treatment recommendations...${colors.reset}\n`);
919
+
920
+ const aiPrompt = `You are an expert oncologist AI. Generate a comprehensive cancer treatment plan for:
921
+
922
+ Cancer Type: ${cancerType}
923
+ Stage: ${stage}
924
+ ${mutations.length > 0 ? `Known Mutations/Biomarkers: ${mutations.join(', ')}` : 'Mutations: Not specified - recommend testing'}
925
+
926
+ Provide a structured treatment plan with:
927
+
928
+ 1. **PRIMARY TREATMENT RECOMMENDATION**
929
+ - First-line therapy with specific drug names and regimens
930
+ - Rationale based on current guidelines (NCCN, ESMO, ASCO)
931
+
932
+ 2. **TARGETED THERAPIES** (if applicable)
933
+ - Specific FDA-approved drugs for any detected mutations
934
+ - Companion diagnostics to order
935
+
936
+ 3. **IMMUNOTHERAPY CONSIDERATIONS**
937
+ - Checkpoint inhibitors if appropriate (pembrolizumab, nivolumab, etc.)
938
+ - Biomarkers to test (PD-L1, MSI, TMB)
939
+
940
+ 4. **CLINICAL TRIALS TO CONSIDER**
941
+ - Mention specific trial categories or approaches worth exploring
942
+ - Note: Always verify on ClinicalTrials.gov
943
+
944
+ 5. **MONITORING & FOLLOW-UP**
945
+ - Response assessment schedule
946
+ - Key biomarkers to track
947
+
948
+ 6. **PROGNOSIS DISCUSSION**
949
+ - Realistic outcome expectations based on published data
950
+ - Important: Note this is general information, individual outcomes vary
951
+
952
+ Be evidence-based and cite specific landmark trials where relevant (e.g., KEYNOTE-189, CheckMate-067, DESTINY-Breast03). Keep response focused and clinically actionable.`;
953
+
954
+ try {
955
+ const aiResponse = await callAI(aiPrompt);
956
+
957
+ // Check if AI response is valid (not an error)
958
+ if (!aiResponse.includes('API Error') && !aiResponse.includes('credits') && !aiResponse.includes('API key not set') && !aiResponse.includes('Connection error')) {
959
+ console.log(`${colors.green}═══════════════════════════════════════════════════════════════${colors.reset}`);
960
+ console.log(`${colors.green} AI-GENERATED TREATMENT PLAN (${getActiveModel()})${colors.reset}`);
961
+ console.log(`${colors.green}═══════════════════════════════════════════════════════════════${colors.reset}\n`);
962
+ console.log(aiResponse);
963
+ console.log(`\n${colors.dim}⚠ This is AI-generated guidance. Always consult with treating oncologist.${colors.reset}`);
964
+ console.log(`\n${colors.green}✓ AI treatment plan generated${colors.reset}`);
965
+ return; // Success - exit early
966
+ } else {
967
+ // AI call failed - show the actual error
968
+ console.log(`${colors.red}AI Error: ${aiResponse}${colors.reset}`);
969
+ console.log(`${colors.yellow}Falling back to local database...${colors.reset}\n`);
970
+ }
971
+ } catch (error) {
972
+ console.log(`${colors.yellow}AI call failed - falling back to local database${colors.reset}\n`);
973
+ }
974
+ } else {
975
+ console.log(`${colors.yellow}No API key set - using local treatment database${colors.reset}`);
976
+ console.log(`${colors.dim}Set API key with: cure then /key YOUR_API_KEY for AI recommendations${colors.reset}\n`);
977
+ }
978
+
979
+ // FALLBACK: Local treatment database (only if AI unavailable)
885
980
  try {
886
981
  const genomicProfile = mutations.length > 0 ? {
887
982
  mutations,
@@ -894,7 +989,7 @@ async function generateCureProtocol(cancerType: string, stage: string, mutations
894
989
 
895
990
  const result = await cancerTreatment.cureCancer('CLI-PATIENT', cancerType, stage, genomicProfile);
896
991
 
897
- console.log(`${colors.bold}${colors.green}CURE PROTOCOL${colors.reset}`);
992
+ console.log(`${colors.bold}${colors.yellow}LOCAL DATABASE PROTOCOL${colors.reset} ${colors.dim}(AI unavailable)${colors.reset}`);
898
993
  console.log(`${colors.dim}═══════════════════════════════════════════${colors.reset}`);
899
994
  console.log(` Cancer Type: ${colors.yellow}${result.cancerType}${colors.reset}`);
900
995
  console.log(` Stage: ${colors.yellow}${result.stage}${colors.reset}`);
@@ -921,20 +1016,20 @@ async function generateCureProtocol(cancerType: string, stage: string, mutations
921
1016
  console.log(` Drugs: ${result.immunotherapy.drugs.join(', ')}`);
922
1017
  }
923
1018
 
924
- console.log(`\n${colors.bold}Projected Outcomes${colors.reset} ${colors.dim}(model estimates, not clinical data)${colors.reset}`);
1019
+ console.log(`\n${colors.bold}Projected Outcomes${colors.reset} ${colors.dim}(database estimates, not clinical data)${colors.reset}`);
925
1020
  console.log(` Response Rate: ${colors.green}${(result.projectedOutcome.responseRate * 100).toFixed(1)}%${colors.reset}`);
926
1021
  console.log(` 5-Year Survival: ${colors.green}${(result.projectedOutcome.fiveYearSurvival * 100).toFixed(1)}%${colors.reset}`);
927
1022
  console.log(` Quality of Life: ${colors.green}${(result.projectedOutcome.qualityOfLife * 100).toFixed(1)}%${colors.reset}`);
928
1023
  console.log(` Cure Confidence: ${colors.green}${colors.bold}${(result.projectedOutcome.cureConfidence * 100).toFixed(1)}%${colors.reset}`);
929
- console.log(` ${colors.dim}⚠ These projections are algorithmic estimates based on published data.${colors.reset}`);
930
- console.log(` ${colors.dim} Actual outcomes vary. Consult oncologist for personalized prognosis.${colors.reset}`);
1024
+ console.log(` ${colors.dim}⚠ These are database estimates, not AI-generated predictions.${colors.reset}`);
1025
+ console.log(` ${colors.dim} Set API key for personalized AI recommendations.${colors.reset}`);
931
1026
 
932
1027
  console.log(`\n${colors.bold}Breakthroughs${colors.reset}`);
933
1028
  result.breakthroughs.forEach((bt) => {
934
1029
  console.log(` ${bt}`);
935
1030
  });
936
1031
 
937
- console.log(`\n${colors.green}✓ Cure protocol generated${colors.reset}`);
1032
+ console.log(`\n${colors.green}✓ Local protocol generated (set API key for AI recommendations)${colors.reset}`);
938
1033
  } catch (error) {
939
1034
  console.error(`${colors.red}✗ Protocol generation failed:${colors.reset}`, error);
940
1035
  }