diff --git a/examples/basic-usage.ts b/examples/basic-usage.ts index ff3b77f..1f1d69a 100644 --- a/examples/basic-usage.ts +++ b/examples/basic-usage.ts @@ -4,7 +4,6 @@ * Demonstrates how to add memories, search them, and list results * using the LocalMemoryClient API. */ - import { memoryClient } from "../src/services/client.js"; import { log } from "../src/services/logger.js"; @@ -29,9 +28,9 @@ async function main() { ); if (addResult.success) { - console.log(`Memory added with ID: ${addResult.id}`); + log(`Memory added with ID: ${addResult.id}`); } else { - console.error("Failed to add memory:", addResult.error); + log("Failed to add memory", { error: addResult.error }); return; } @@ -59,22 +58,22 @@ async function main() { ); if (searchResult.success) { - console.log(`\nSearch returned ${searchResult.total} results:`); + log(`\nSearch returned ${searchResult.total} results:`); for (const result of searchResult.results) { - console.log(` - ${result.memory} (score: ${result.similarity?.toFixed(3)})`); + log(` - ${result.memory} (score: ${result.similarity?.toFixed(3)})`); } } else { - console.error("Search failed:", searchResult.error); + log("Search failed", { error: searchResult.error }); } // --- List all memories --- const listResult = await memoryClient.listMemories(containerTag, 20, "project"); if (listResult.success) { - console.log(`\nListed ${listResult.memories.length} memories:`); + log(`\nListed ${listResult.memories.length} memories:`); for (const memory of listResult.memories) { - console.log(` [${memory.id}] ${memory.summary}`); - console.log( + log(` [${memory.id}] ${memory.summary}`); + log( ` Strength: ${memory.strength?.toFixed(3)} | Store: ${memory.storeType || "stm"}` ); } @@ -82,7 +81,7 @@ async function main() { // --- Clean up --- memoryClient.close(); - console.log("\nDone!"); + log("\nDone!"); } main().catch((error) => { diff --git a/examples/custom-scoring.ts b/examples/custom-scoring.ts index 4579576..77525cb 100644 --- a/examples/custom-scoring.ts +++ b/examples/custom-scoring.ts @@ -43,15 +43,6 @@ function main() { const confidence = calculateConfidence("manual", "refactor"); const interference = calculateInterference(content, conflictingMemories); - console.log("=== Individual Scores ==="); - console.log(`Recency: ${recency.toFixed(3)}`); - console.log(`Frequency: ${frequency.toFixed(3)}`); - console.log(`Importance: ${importance.toFixed(3)}`); - console.log(`Utility: ${utility.toFixed(3)}`); - console.log(`Novelty: ${novelty.toFixed(3)}`); - console.log(`Confidence: ${confidence.toFixed(3)}`); - console.log(`Interference: ${interference.toFixed(3)}`); - // --- Compute overall strength --- const scores: ScoreComponents = { recency, @@ -64,7 +55,6 @@ function main() { }; const strength = computeStrength(scores); - console.log(`\n=== Overall Strength: ${strength.toFixed(3)} ===`); // --- Calculate all scores in one call --- const allScores = calculateAllScores({ @@ -80,21 +70,21 @@ function main() { utilityHalfLifeDays: 3, }); - console.log("\n=== Batch Calculation ==="); - console.log(JSON.stringify(allScores, null, 2)); - // --- Score interpretation --- - console.log("\n=== Interpretation ==="); if (strength > 0.8) { - console.log("High-strength memory → eligible for automatic LTM promotion."); + // High-strength memory → eligible for automatic LTM promotion. + // You may trigger a UI update here. } else if (strength > 0.5) { - console.log("Medium-strength memory → remains in STM with standard decay."); + // Medium-strength memory → remains in STM with standard decay. + // You may trigger a UI update here. } else { - console.log("Low-strength memory → may be archived after prolonged inactivity."); + // Low-strength memory → may be archived after prolonged inactivity. + // You may trigger a UI update here. } if (interference > 0.3) { - console.log("⚠️ High interference detected — consider conflict resolution."); + // ⚠️ High interference detected — consider conflict resolution. + // You may trigger a UI warning here. } }