MCPcopy Create free account
hub / github.com/anus-dev/ANUS / createShowMemoryAction

Function createShowMemoryAction

packages/cli/src/ui/hooks/useShowMemoryCommand.ts:12–76  ·  view source on GitHub ↗
(
  config: Config | null,
  settings: LoadedSettings,
  addMessage: (message: Message) => void,
)

Source from the content-addressed store, hash-verified

10import { LoadedSettings } from '../../config/settings.js';
11
12export function createShowMemoryAction(
13 config: Config | null,
14 settings: LoadedSettings,
15 addMessage: (message: Message) => void,
16) {
17 return async () => {
18 if (!config) {
19 addMessage({
20 type: MessageType.ERROR,
21 content: 'Configuration not available. Cannot show memory.',
22 timestamp: new Date(),
23 });
24 return;
25 }
26
27 const debugMode = config.getDebugMode();
28
29 if (debugMode) {
30 console.log('[DEBUG] Show Memory command invoked.');
31 }
32
33 const currentMemory = config.getUserMemory();
34 const fileCount = config.getAnusMdFileCount();
35 const contextFileName = settings.merged.contextFileName;
36 const contextFileNames = Array.isArray(contextFileName)
37 ? contextFileName
38 : [contextFileName];
39
40 if (debugMode) {
41 console.log(
42 `[DEBUG] Showing memory. Content from config.getUserMemory() (first 200 chars): ${currentMemory.substring(0, 200)}...`,
43 );
44 console.log(`[DEBUG] Number of context files loaded: ${fileCount}`);
45 }
46
47 if (fileCount > 0) {
48 const allNamesTheSame = new Set(contextFileNames).size < 2;
49 const name = allNamesTheSame ? contextFileNames[0] : 'context';
50 addMessage({
51 type: MessageType.INFO,
52 content: `Loaded memory from ${fileCount} ${name} file${
53 fileCount > 1 ? 's' : ''
54 }.`,
55 timestamp: new Date(),
56 });
57 }
58
59 if (currentMemory && currentMemory.trim().length > 0) {
60 addMessage({
61 type: MessageType.INFO,
62 content: `Current combined memory content:\n\`\`\`markdown\n${currentMemory}\n\`\`\``,
63 timestamp: new Date(),
64 });
65 } else {
66 addMessage({
67 type: MessageType.INFO,
68 content:
69 fileCount > 0

Callers

nothing calls this directly

Calls 3

getDebugModeMethod · 0.80
getUserMemoryMethod · 0.80
getAnusMdFileCountMethod · 0.80

Tested by

no test coverage detected