claude-brain 0.4.1 → 0.5.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/cli/bin.ts +12 -6
- package/src/cli/commands/chroma.ts +146 -16
- package/src/cli/commands/serve.ts +6 -0
- package/src/cli/commands/start.ts +42 -0
- package/src/config/defaults.ts +1 -1
- package/src/config/schema.ts +1 -1
- package/src/memory/chroma/client.ts +5 -1
- package/src/memory/index.ts +91 -0
- package/src/memory/store.ts +136 -4
- package/src/server/handlers/tools/analyze-decision-evolution.ts +76 -6
- package/src/server/handlers/tools/detect-trends.ts +60 -6
- package/src/server/handlers/tools/find-cross-project-patterns.ts +91 -6
- package/src/server/handlers/tools/get-decision-timeline.ts +91 -15
- package/src/server/handlers/tools/get-episode.ts +11 -1
- package/src/server/handlers/tools/get-recommendations.ts +76 -6
- package/src/server/handlers/tools/list-episodes.ts +11 -1
- package/src/server/handlers/tools/rate-memory.ts +8 -2
- package/src/server/handlers/tools/smart-context.ts +23 -1
- package/src/server/handlers/tools/update-progress.ts +18 -13
- package/src/server/handlers/tools/what-if-analysis.ts +58 -7
|
@@ -25,13 +25,64 @@ export async function handleWhatIfAnalysis(
|
|
|
25
25
|
const memory = getMemoryService()
|
|
26
26
|
|
|
27
27
|
if (!memory.isChromaDBEnabled()) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
// SQLite fallback: use searchRaw for semantic search + knowledge graph if available
|
|
29
|
+
const results = await memory.searchRaw(change, {
|
|
30
|
+
project: project_name,
|
|
31
|
+
limit: max_results || 10,
|
|
32
|
+
minSimilarity: 0.2
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
const parts: string[] = []
|
|
36
|
+
parts.push(`## What-If: "${change}" (SQLite)`)
|
|
37
|
+
parts.push('')
|
|
38
|
+
|
|
39
|
+
if (results.length === 0) {
|
|
40
|
+
parts.push('No related decisions found to assess impact.')
|
|
41
|
+
return ResponseFormatter.text(parts.join('\n'))
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Assess impact based on similarity
|
|
45
|
+
const affectedDecisions = results.map(r => {
|
|
46
|
+
const similarity = r.similarity || 0
|
|
47
|
+
const impact = similarity > 0.7 ? 'high' : similarity > 0.4 ? 'medium' : 'low'
|
|
48
|
+
return {
|
|
49
|
+
decision: r.decision?.decision || r.memory?.content?.slice(0, 150) || '',
|
|
50
|
+
impact,
|
|
51
|
+
similarity,
|
|
52
|
+
reason: `${Math.round(similarity * 100)}% similarity — ${r.decision?.reasoning?.slice(0, 100) || 'related context found'}`
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
parts.push(`Analyzed ${results.length} related decisions.\n`)
|
|
57
|
+
|
|
58
|
+
parts.push('### Affected Decisions')
|
|
59
|
+
for (const d of affectedDecisions) {
|
|
60
|
+
const icon = d.impact === 'high' ? '🔴' : d.impact === 'medium' ? '🟡' : '🟢'
|
|
61
|
+
parts.push(`${icon} **[${d.impact}]** ${d.decision}`)
|
|
62
|
+
parts.push(` *${d.reason}*`)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Try knowledge graph if available
|
|
66
|
+
try {
|
|
67
|
+
const kgService = getKnowledgeGraphService()
|
|
68
|
+
if (kgService?.graph) {
|
|
69
|
+
const graphResults = await kgService.graph.search(change, { limit: 5 })
|
|
70
|
+
if (graphResults && graphResults.length > 0) {
|
|
71
|
+
const technologies = graphResults
|
|
72
|
+
.filter((n: any) => n.type === 'technology')
|
|
73
|
+
.map((n: any) => n.name || n.label)
|
|
74
|
+
if (technologies.length > 0) {
|
|
75
|
+
parts.push(`\n### Connected Technologies`)
|
|
76
|
+
parts.push(technologies.map((t: string) => `- ${t}`).join('\n'))
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
} catch {
|
|
81
|
+
// Knowledge graph not available, skip
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const content = parts.join('\n')
|
|
85
|
+
return ResponseFormatter.text(withMemoryIndicator(content, results.length))
|
|
35
86
|
}
|
|
36
87
|
|
|
37
88
|
const kgService = getKnowledgeGraphService()
|