MCPcopy Create free account
hub / github.com/IAmUnbounded/devctx / parseClaudeMemory

Function parseClaudeMemory

devctx/src/core/parser.ts:86–140  ·  view source on GitHub ↗
(memoryDir: string)

Source from the content-addressed store, hash-verified

84}
85
86function parseClaudeMemory(memoryDir: string): ExtractedContext | null {
87 const files = fs.readdirSync(memoryDir).filter((f) => f.endsWith(".md"));
88 if (files.length === 0) return null;
89
90 let task = "";
91 const decisions: string[] = [];
92 const approaches: string[] = [];
93 let currentState = "";
94 const nextSteps: string[] = [];
95
96 for (const file of files) {
97 const content = fs.readFileSync(path.join(memoryDir, file), "utf-8");
98
99 // Extract project description from memory
100 if (file === "MEMORY.md") {
101 const projectMatch = content.match(/##\s*Project\s*(?:Location|Overview)?\s*\n([\s\S]*?)(?=\n##|$)/i);
102 if (projectMatch) {
103 const lines = projectMatch[1].trim().split("\n").filter(Boolean);
104 task = lines[0]?.replace(/^[-*]\s*\*\*.*?\*\*:\s*/, "").trim() || "";
105 }
106 }
107
108 // Extract conventions as decisions
109 const conventionMatch = content.match(/##\s*Conventions?\s*\n([\s\S]*?)(?=\n##|$)/i);
110 if (conventionMatch) {
111 const lines = conventionMatch[1].trim().split("\n").filter(Boolean);
112 for (const line of lines.slice(0, 5)) {
113 const cleaned = line.replace(/^[-*]\s*/, "").trim();
114 if (cleaned.length > 10) decisions.push(cleaned);
115 }
116 }
117
118 // Extract patterns as approaches
119 const patternMatch = content.match(/##\s*Patterns?\s*\n([\s\S]*?)(?=\n##|$)/i);
120 if (patternMatch) {
121 const lines = patternMatch[1].trim().split("\n").filter(Boolean);
122 for (const line of lines.slice(0, 5)) {
123 const cleaned = line.replace(/^[-*]\s*/, "").trim();
124 if (cleaned.length > 10) approaches.push(cleaned);
125 }
126 }
127 }
128
129 if (!task && decisions.length === 0) return null;
130
131 return {
132 task: task || "Project session (from Claude Code memory)",
133 approaches,
134 decisions,
135 currentState: currentState || "Loaded from Claude Code memory files",
136 nextSteps,
137 blockers: [],
138 source: "claude-code-memory",
139 };
140}
141
142async function parseClaudeSession(
143 sessionPath: string

Callers 1

extractFromClaudeCodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected