claude-brain 0.9.2 → 0.10.0
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/VERSION +1 -1
- package/package.json +1 -1
- package/src/config/defaults.ts +1 -1
- package/src/config/schema.ts +1 -1
- package/src/memory/chroma/store.ts +6 -1
- package/src/memory/index.ts +29 -15
- package/src/routing/intent-classifier.ts +94 -6
- package/src/routing/response-filter.ts +50 -17
- package/src/routing/router.ts +447 -221
- package/src/routing/search-engine.ts +455 -0
- package/src/routing/types.ts +84 -0
- package/src/server/handlers/call-tool.ts +4 -49
- package/src/server/handlers/tools/index.ts +5 -7
- package/src/server/services.ts +28 -0
- package/src/tools/schemas.ts +6 -328
package/src/tools/schemas.ts
CHANGED
|
@@ -568,337 +568,15 @@ export const TOOLS = {
|
|
|
568
568
|
}
|
|
569
569
|
},
|
|
570
570
|
|
|
571
|
-
/**
|
|
572
|
-
* RATE_MEMORY
|
|
573
|
-
* Provide feedback on retrieved memories for adaptive learning
|
|
574
|
-
*
|
|
575
|
-
* Use this when:
|
|
576
|
-
* - A retrieved memory was helpful or not helpful
|
|
577
|
-
* - You want to improve future retrieval quality
|
|
578
|
-
* - The system should learn from retrieval feedback
|
|
579
|
-
*
|
|
580
|
-
* Feedback is used to adapt retrieval thresholds and weights
|
|
581
|
-
*/
|
|
582
|
-
RATE_MEMORY: {
|
|
583
|
-
name: 'rate_memory',
|
|
584
|
-
description: 'Rate how helpful a retrieved memory was. This feedback helps improve future retrieval quality through adaptive learning. Rate 1-5 where 1=not helpful and 5=very helpful.',
|
|
585
|
-
inputSchema: {
|
|
586
|
-
type: 'object' as const,
|
|
587
|
-
properties: {
|
|
588
|
-
memory_id: {
|
|
589
|
-
type: 'string',
|
|
590
|
-
description: 'ID of the memory to rate (from recall_similar or smart_context results)'
|
|
591
|
-
},
|
|
592
|
-
rating: {
|
|
593
|
-
type: 'number',
|
|
594
|
-
enum: [1, 2, 3, 4, 5],
|
|
595
|
-
description: 'Rating from 1 (not helpful) to 5 (very helpful)'
|
|
596
|
-
},
|
|
597
|
-
query: {
|
|
598
|
-
type: 'string',
|
|
599
|
-
description: 'The original query that retrieved this memory'
|
|
600
|
-
},
|
|
601
|
-
was_used: {
|
|
602
|
-
type: 'boolean',
|
|
603
|
-
description: 'Whether you actually used this memory in your response',
|
|
604
|
-
default: true
|
|
605
|
-
},
|
|
606
|
-
feedback_text: {
|
|
607
|
-
type: 'string',
|
|
608
|
-
description: 'Optional text explaining why this rating was given'
|
|
609
|
-
},
|
|
610
|
-
project_name: {
|
|
611
|
-
type: 'string',
|
|
612
|
-
description: 'Project this feedback relates to (optional)'
|
|
613
|
-
}
|
|
614
|
-
},
|
|
615
|
-
required: ['memory_id', 'rating', 'query']
|
|
616
|
-
}
|
|
617
|
-
},
|
|
618
|
-
|
|
619
|
-
/**
|
|
620
|
-
* SEARCH_KNOWLEDGE_GRAPH
|
|
621
|
-
* Search the knowledge graph for related entities, decisions, and relationships
|
|
622
|
-
*
|
|
623
|
-
* Use this when:
|
|
624
|
-
* - You want to find how technologies/decisions are connected
|
|
625
|
-
* - You need to explore relationships between entities
|
|
626
|
-
* - You want to find related decisions for a technology
|
|
627
|
-
*/
|
|
628
|
-
SEARCH_KNOWLEDGE_GRAPH: {
|
|
629
|
-
name: 'search_knowledge_graph',
|
|
630
|
-
description: 'Searches the knowledge graph for related nodes and edges. Use this to explore relationships between technologies, decisions, and concepts.',
|
|
631
|
-
inputSchema: {
|
|
632
|
-
type: 'object' as const,
|
|
633
|
-
properties: {
|
|
634
|
-
query: {
|
|
635
|
-
type: 'string',
|
|
636
|
-
description: 'Search query (technology name, concept, etc.)'
|
|
637
|
-
},
|
|
638
|
-
node_type: {
|
|
639
|
-
type: 'string',
|
|
640
|
-
enum: ['project', 'technology', 'concept', 'person', 'file', 'decision', 'pattern', 'correction', 'date'],
|
|
641
|
-
description: 'Filter by node type (optional)'
|
|
642
|
-
},
|
|
643
|
-
start_node_id: {
|
|
644
|
-
type: 'string',
|
|
645
|
-
description: 'Start from a specific node ID for graph expansion (optional)'
|
|
646
|
-
},
|
|
647
|
-
hops: {
|
|
648
|
-
type: 'number',
|
|
649
|
-
description: 'Number of hops to expand from matching nodes (default 2)',
|
|
650
|
-
default: 2
|
|
651
|
-
},
|
|
652
|
-
limit: {
|
|
653
|
-
type: 'number',
|
|
654
|
-
description: 'Maximum number of results (default 20)',
|
|
655
|
-
default: 20
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
},
|
|
660
|
-
|
|
661
|
-
/**
|
|
662
|
-
* GET_EPISODE
|
|
663
|
-
* Get a specific episode or the active episode for a project
|
|
664
|
-
*
|
|
665
|
-
* Use this when:
|
|
666
|
-
* - You want to review a past conversation session
|
|
667
|
-
* - You need to find what was discussed in an episode
|
|
668
|
-
* - You want to see the active episode for a project
|
|
669
|
-
*/
|
|
670
|
-
GET_EPISODE: {
|
|
671
|
-
name: 'get_episode',
|
|
672
|
-
description: 'Get episode by ID or get active episode for project. Episodes represent conversation sessions with summaries and linked decisions.',
|
|
673
|
-
inputSchema: {
|
|
674
|
-
type: 'object' as const,
|
|
675
|
-
properties: {
|
|
676
|
-
episode_id: {
|
|
677
|
-
type: 'string',
|
|
678
|
-
description: 'Specific episode ID to retrieve'
|
|
679
|
-
},
|
|
680
|
-
project_name: {
|
|
681
|
-
type: 'string',
|
|
682
|
-
description: 'Get active episode for this project'
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
},
|
|
687
|
-
|
|
688
|
-
/**
|
|
689
|
-
* LIST_EPISODES
|
|
690
|
-
* List recent episodes, filtered by project or status
|
|
691
|
-
*
|
|
692
|
-
* Use this when:
|
|
693
|
-
* - You want to see recent conversation sessions
|
|
694
|
-
* - You need to find past episodes for a project
|
|
695
|
-
* - You want to review episode summaries
|
|
696
|
-
*/
|
|
697
|
-
LIST_EPISODES: {
|
|
698
|
-
name: 'list_episodes',
|
|
699
|
-
description: 'List recent episodes with summaries. Filter by project or status to find past conversation sessions.',
|
|
700
|
-
inputSchema: {
|
|
701
|
-
type: 'object' as const,
|
|
702
|
-
properties: {
|
|
703
|
-
project_name: {
|
|
704
|
-
type: 'string',
|
|
705
|
-
description: 'Filter episodes by project (optional)'
|
|
706
|
-
},
|
|
707
|
-
limit: {
|
|
708
|
-
type: 'number',
|
|
709
|
-
description: 'Maximum number of episodes to return (default 10)',
|
|
710
|
-
default: 10
|
|
711
|
-
},
|
|
712
|
-
status: {
|
|
713
|
-
type: 'string',
|
|
714
|
-
enum: ['active', 'completed'],
|
|
715
|
-
description: 'Filter by episode status (optional)'
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
},
|
|
720
|
-
// =========================================================================
|
|
721
|
-
// Phase 15 - Advanced Intelligence & Temporal Reasoning
|
|
722
|
-
// =========================================================================
|
|
723
|
-
|
|
724
|
-
/**
|
|
725
|
-
* GET_DECISION_TIMELINE
|
|
726
|
-
* Build a chronological timeline of decisions
|
|
727
|
-
*/
|
|
728
|
-
GET_DECISION_TIMELINE: {
|
|
729
|
-
name: 'get_decision_timeline',
|
|
730
|
-
description: 'Builds a chronological timeline of decisions, patterns, and corrections. Supports temporal expressions like "last month", "since January", etc. Use this to see how a project or topic has evolved over time.',
|
|
731
|
-
inputSchema: {
|
|
732
|
-
type: 'object' as const,
|
|
733
|
-
properties: {
|
|
734
|
-
project_name: {
|
|
735
|
-
type: 'string',
|
|
736
|
-
description: 'Filter timeline by project (optional)'
|
|
737
|
-
},
|
|
738
|
-
topic: {
|
|
739
|
-
type: 'string',
|
|
740
|
-
description: 'Filter timeline by topic via semantic search (optional)'
|
|
741
|
-
},
|
|
742
|
-
time_range: {
|
|
743
|
-
type: 'string',
|
|
744
|
-
description: 'Natural language time range, e.g. "last month", "since January 2025", "this week" (optional)'
|
|
745
|
-
},
|
|
746
|
-
limit: {
|
|
747
|
-
type: 'number',
|
|
748
|
-
description: 'Maximum number of entries (default 50)',
|
|
749
|
-
default: 50
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
},
|
|
754
|
-
|
|
755
|
-
/**
|
|
756
|
-
* ANALYZE_DECISION_EVOLUTION
|
|
757
|
-
* Track how decisions on a topic change over time
|
|
758
|
-
*/
|
|
759
|
-
ANALYZE_DECISION_EVOLUTION: {
|
|
760
|
-
name: 'analyze_decision_evolution',
|
|
761
|
-
description: 'Tracks how decisions on a specific topic have evolved over time. Shows changes, stability assessment, and current state. Use this to understand decision drift or consistency.',
|
|
762
|
-
inputSchema: {
|
|
763
|
-
type: 'object' as const,
|
|
764
|
-
properties: {
|
|
765
|
-
topic: {
|
|
766
|
-
type: 'string',
|
|
767
|
-
description: 'The topic to analyze evolution for (e.g., "database choice", "authentication")'
|
|
768
|
-
},
|
|
769
|
-
project_name: {
|
|
770
|
-
type: 'string',
|
|
771
|
-
description: 'Filter by project (optional)'
|
|
772
|
-
},
|
|
773
|
-
limit: {
|
|
774
|
-
type: 'number',
|
|
775
|
-
description: 'Maximum decisions to analyze (default 20)',
|
|
776
|
-
default: 20
|
|
777
|
-
}
|
|
778
|
-
},
|
|
779
|
-
required: ['topic']
|
|
780
|
-
}
|
|
781
|
-
},
|
|
782
|
-
|
|
783
|
-
/**
|
|
784
|
-
* DETECT_TRENDS
|
|
785
|
-
* Detect emerging and declining technology/pattern trends
|
|
786
|
-
*/
|
|
787
|
-
DETECT_TRENDS: {
|
|
788
|
-
name: 'detect_trends',
|
|
789
|
-
description: 'Detects emerging, stable, and declining trends across decisions. Identifies frequently mentioned technologies, concepts, and approaches, and whether they are gaining or losing momentum.',
|
|
790
|
-
inputSchema: {
|
|
791
|
-
type: 'object' as const,
|
|
792
|
-
properties: {
|
|
793
|
-
project_name: {
|
|
794
|
-
type: 'string',
|
|
795
|
-
description: 'Filter by project (optional, analyzes all projects if omitted)'
|
|
796
|
-
},
|
|
797
|
-
period_days: {
|
|
798
|
-
type: 'number',
|
|
799
|
-
description: 'Analysis period in days (default 90)',
|
|
800
|
-
default: 90
|
|
801
|
-
},
|
|
802
|
-
min_occurrences: {
|
|
803
|
-
type: 'number',
|
|
804
|
-
description: 'Minimum occurrences to include (default 2)',
|
|
805
|
-
default: 2
|
|
806
|
-
},
|
|
807
|
-
limit: {
|
|
808
|
-
type: 'number',
|
|
809
|
-
description: 'Maximum trends to return (default 20)',
|
|
810
|
-
default: 20
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
},
|
|
815
|
-
|
|
816
|
-
/**
|
|
817
|
-
* WHAT_IF_ANALYSIS
|
|
818
|
-
* Counterfactual what-if analysis
|
|
819
|
-
*/
|
|
820
|
-
WHAT_IF_ANALYSIS: {
|
|
821
|
-
name: 'what_if_analysis',
|
|
822
|
-
description: 'Performs what-if analysis: "What would happen if we changed X?" Finds all affected decisions, connected technologies, and assesses risk level. Uses knowledge graph for impact analysis.',
|
|
823
|
-
inputSchema: {
|
|
824
|
-
type: 'object' as const,
|
|
825
|
-
properties: {
|
|
826
|
-
change: {
|
|
827
|
-
type: 'string',
|
|
828
|
-
description: 'The hypothetical change to analyze (e.g., "switch from React to Vue", "remove TypeScript")'
|
|
829
|
-
},
|
|
830
|
-
project_name: {
|
|
831
|
-
type: 'string',
|
|
832
|
-
description: 'Filter by project (optional)'
|
|
833
|
-
},
|
|
834
|
-
max_results: {
|
|
835
|
-
type: 'number',
|
|
836
|
-
description: 'Maximum affected decisions to return (default 20)',
|
|
837
|
-
default: 20
|
|
838
|
-
}
|
|
839
|
-
},
|
|
840
|
-
required: ['change']
|
|
841
|
-
}
|
|
842
|
-
},
|
|
843
|
-
|
|
844
|
-
/**
|
|
845
|
-
* GET_RECOMMENDATIONS
|
|
846
|
-
* Get intelligent recommendations based on history
|
|
847
|
-
*/
|
|
848
|
-
GET_RECOMMENDATIONS: {
|
|
849
|
-
name: 'get_recommendations',
|
|
850
|
-
description: 'Provides intelligent recommendations based on past decisions, patterns, and corrections. Combines multiple knowledge sources to suggest best approaches for a given situation.',
|
|
851
|
-
inputSchema: {
|
|
852
|
-
type: 'object' as const,
|
|
853
|
-
properties: {
|
|
854
|
-
query: {
|
|
855
|
-
type: 'string',
|
|
856
|
-
description: 'What you need recommendations for (e.g., "how to implement caching", "error handling approach")'
|
|
857
|
-
},
|
|
858
|
-
project_name: {
|
|
859
|
-
type: 'string',
|
|
860
|
-
description: 'Filter by project (optional)'
|
|
861
|
-
},
|
|
862
|
-
limit: {
|
|
863
|
-
type: 'number',
|
|
864
|
-
description: 'Maximum recommendations (default 10)',
|
|
865
|
-
default: 10
|
|
866
|
-
}
|
|
867
|
-
},
|
|
868
|
-
required: ['query']
|
|
869
|
-
}
|
|
870
|
-
},
|
|
871
|
-
|
|
872
|
-
/**
|
|
873
|
-
* FIND_CROSS_PROJECT_PATTERNS
|
|
874
|
-
* Find patterns common across multiple projects
|
|
875
|
-
*/
|
|
876
|
-
FIND_CROSS_PROJECT_PATTERNS: {
|
|
877
|
-
name: 'find_cross_project_patterns',
|
|
878
|
-
description: 'Finds patterns and approaches that appear across multiple projects. Identifies shared technologies, common decisions, and transferable knowledge between projects.',
|
|
879
|
-
inputSchema: {
|
|
880
|
-
type: 'object' as const,
|
|
881
|
-
properties: {
|
|
882
|
-
min_projects: {
|
|
883
|
-
type: 'number',
|
|
884
|
-
description: 'Minimum number of projects a pattern must appear in (default 2)',
|
|
885
|
-
default: 2
|
|
886
|
-
},
|
|
887
|
-
limit: {
|
|
888
|
-
type: 'number',
|
|
889
|
-
description: 'Maximum patterns to return (default 20)',
|
|
890
|
-
default: 20
|
|
891
|
-
},
|
|
892
|
-
query: {
|
|
893
|
-
type: 'string',
|
|
894
|
-
description: 'Optional query to focus the search (e.g., "authentication", "deployment")'
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
}
|
|
898
|
-
},
|
|
899
571
|
// =========================================================================
|
|
900
572
|
// Phase 16 - Unified Brain Tool
|
|
901
573
|
// =========================================================================
|
|
574
|
+
// Phase 19: Removed 9 redundant MCP tools whose functionality is now
|
|
575
|
+
// absorbed into brain(). Removed: rate_memory, search_knowledge_graph,
|
|
576
|
+
// get_episode, list_episodes, get_decision_timeline,
|
|
577
|
+
// analyze_decision_evolution, detect_trends, what_if_analysis,
|
|
578
|
+
// get_recommendations, find_cross_project_patterns.
|
|
579
|
+
// The underlying modules are still available internally.
|
|
902
580
|
|
|
903
581
|
/**
|
|
904
582
|
* BRAIN
|