@phi-code-admin/phi-code 0.63.1 → 0.63.2
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/extensions/phi/memory.ts +27 -27
- package/package.json +2 -2
- package/scripts/postinstall.cjs +12 -1
package/extensions/phi/memory.ts
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* Now powered by sigma-memory package which provides:
|
|
5
5
|
* - NotesManager: Markdown files management
|
|
6
6
|
* - OntologyManager: Knowledge graph with entities and relations
|
|
7
|
-
* -
|
|
7
|
+
* - VectorStore: Embedded vector search (sql.js + local embeddings)
|
|
8
8
|
*
|
|
9
9
|
* Features:
|
|
10
|
-
* - memory_search: Unified search across notes, ontology, and
|
|
10
|
+
* - memory_search: Unified search across notes, ontology, and vector store
|
|
11
11
|
* - memory_write: Write content to memory files
|
|
12
12
|
* - memory_read: Read specific memory files or list available ones
|
|
13
13
|
* - memory_status: Get status of all memory subsystems
|
|
@@ -26,16 +26,12 @@ import { readFileSync } from "node:fs";
|
|
|
26
26
|
import { SigmaMemory } from "sigma-memory";
|
|
27
27
|
|
|
28
28
|
export default function memoryExtension(pi: ExtensionAPI) {
|
|
29
|
-
// Initialize sigma-memory
|
|
30
|
-
const sigmaMemory = new SigmaMemory(
|
|
31
|
-
// Default configuration, can be overridden
|
|
32
|
-
qmdEnabled: true,
|
|
33
|
-
qmdCommand: 'qmd'
|
|
34
|
-
});
|
|
29
|
+
// Initialize sigma-memory with embedded vector store
|
|
30
|
+
const sigmaMemory = new SigmaMemory();
|
|
35
31
|
|
|
36
|
-
// Initialize memory
|
|
37
|
-
sigmaMemory.init().catch(
|
|
38
|
-
|
|
32
|
+
// Initialize memory + vector store (lazy model download on first search)
|
|
33
|
+
sigmaMemory.init().catch(() => {
|
|
34
|
+
// Non-critical — memory works without vectors
|
|
39
35
|
});
|
|
40
36
|
|
|
41
37
|
/**
|
|
@@ -44,12 +40,15 @@ export default function memoryExtension(pi: ExtensionAPI) {
|
|
|
44
40
|
pi.registerTool({
|
|
45
41
|
name: "memory_search",
|
|
46
42
|
label: "Memory Search",
|
|
47
|
-
description: "Search for content in memory using unified search (notes + ontology +
|
|
43
|
+
description: "Search for content in memory using unified search (notes + ontology + vector search)",
|
|
48
44
|
promptSnippet: "Search project memory (notes, ontology, vector search). ALWAYS call before answering questions about prior work, decisions, or project context.",
|
|
49
45
|
promptGuidelines: [
|
|
50
46
|
"Before answering questions about prior work, architecture, decisions, or project context: call memory_search first.",
|
|
51
47
|
"When starting work on a topic, search memory for existing notes and learnings.",
|
|
52
48
|
"After completing important work or learning something new, use memory_write to save it.",
|
|
49
|
+
"When a command fails or produces an unexpected error, document the error and fix in memory_write (self-improvement).",
|
|
50
|
+
"When the user corrects you, save the correction in memory_write so you never repeat the mistake.",
|
|
51
|
+
"After a significant debugging session, write a summary of root cause and solution to memory.",
|
|
53
52
|
],
|
|
54
53
|
parameters: Type.Object({
|
|
55
54
|
query: Type.String({ description: "Search query to find in memory" }),
|
|
@@ -96,7 +95,7 @@ export default function memoryExtension(pi: ExtensionAPI) {
|
|
|
96
95
|
resultText += `Relation: ${data.type} (${data.from} → ${data.to})\n`;
|
|
97
96
|
resultText += `Properties: ${JSON.stringify(data.properties)}\n\n`;
|
|
98
97
|
}
|
|
99
|
-
} else if (result.source === '
|
|
98
|
+
} else if (result.source === 'vectors') {
|
|
100
99
|
const data = result.data;
|
|
101
100
|
resultText += `File: ${data.file} (line ${data.line})\n`;
|
|
102
101
|
resultText += `> ${data.content}\n\n`;
|
|
@@ -136,14 +135,18 @@ export default function memoryExtension(pi: ExtensionAPI) {
|
|
|
136
135
|
const { content, file } = params as { content: string; file?: string };
|
|
137
136
|
|
|
138
137
|
try {
|
|
139
|
-
//
|
|
138
|
+
// Write to notes
|
|
140
139
|
sigmaMemory.notes.write(content, file);
|
|
141
|
-
|
|
142
140
|
const filename = file || new Date().toISOString().split('T')[0] + '.md';
|
|
141
|
+
|
|
142
|
+
// Auto-index in vector store (non-blocking)
|
|
143
|
+
sigmaMemory.vectors.addDocument(filename, content).catch(() => {
|
|
144
|
+
// Vector indexing failed silently — notes still saved
|
|
145
|
+
});
|
|
143
146
|
|
|
144
147
|
return {
|
|
145
|
-
content: [{ type: "text", text: `Content written to ${filename}` }],
|
|
146
|
-
details: { filename, contentLength: content.length }
|
|
148
|
+
content: [{ type: "text", text: `Content written to ${filename} (indexed for vector search)` }],
|
|
149
|
+
details: { filename, contentLength: content.length, vectorIndexed: true }
|
|
147
150
|
};
|
|
148
151
|
|
|
149
152
|
} catch (error) {
|
|
@@ -214,7 +217,7 @@ export default function memoryExtension(pi: ExtensionAPI) {
|
|
|
214
217
|
pi.registerTool({
|
|
215
218
|
name: "memory_status",
|
|
216
219
|
label: "Memory Status",
|
|
217
|
-
description: "Get status of all memory subsystems (notes, ontology,
|
|
220
|
+
description: "Get status of all memory subsystems (notes, ontology, vector search)",
|
|
218
221
|
parameters: Type.Object({}),
|
|
219
222
|
|
|
220
223
|
async execute(_toolCallId, _params, _signal, _onUpdate, _ctx) {
|
|
@@ -236,14 +239,11 @@ export default function memoryExtension(pi: ExtensionAPI) {
|
|
|
236
239
|
statusText += `- Entities by type: ${JSON.stringify(status.ontology.entitiesByType)}\n`;
|
|
237
240
|
statusText += `- Relations by type: ${JSON.stringify(status.ontology.relationsByType)}\n\n`;
|
|
238
241
|
|
|
239
|
-
//
|
|
240
|
-
statusText += `##
|
|
241
|
-
statusText += `-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
statusText += `- Chunks: ${status.qmd.status.chunks}\n`;
|
|
245
|
-
statusText += `- Last update: ${status.qmd.status.lastUpdate || 'Never'}\n`;
|
|
246
|
-
}
|
|
242
|
+
// Vector store status
|
|
243
|
+
statusText += `## Vector Search (embedded)\n`;
|
|
244
|
+
statusText += `- Documents: ${status.vectors.documentCount}\n`;
|
|
245
|
+
statusText += `- Chunks: ${status.vectors.chunkCount}\n`;
|
|
246
|
+
statusText += `- Last update: ${status.vectors.lastUpdate || 'Never'}\n`;
|
|
247
247
|
|
|
248
248
|
return {
|
|
249
249
|
content: [{ type: "text", text: statusText }],
|
|
@@ -292,7 +292,7 @@ export default function memoryExtension(pi: ExtensionAPI) {
|
|
|
292
292
|
const parts: string[] = [];
|
|
293
293
|
if (status.notes.count > 0) parts.push(`${status.notes.count} notes`);
|
|
294
294
|
if (status.ontology.entities > 0) parts.push(`${status.ontology.entities} entities`);
|
|
295
|
-
if (status.
|
|
295
|
+
if (status.vectors.chunkCount > 0) parts.push(`${status.vectors.chunkCount} vectors`);
|
|
296
296
|
if (parts.length > 0) {
|
|
297
297
|
ctx.ui.notify(`🧠 Memory: ${parts.join(", ")}`, "info");
|
|
298
298
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phi-code-admin/phi-code",
|
|
3
|
-
"version": "0.63.
|
|
3
|
+
"version": "0.63.2",
|
|
4
4
|
"description": "Coding agent CLI with read, bash, edit, write tools and session management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"piConfig": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"phi-code-tui": "^0.56.3",
|
|
62
62
|
"proper-lockfile": "^4.1.2",
|
|
63
63
|
"sigma-agents": "^0.1.6",
|
|
64
|
-
"sigma-memory": "
|
|
64
|
+
"sigma-memory": "0.2.0",
|
|
65
65
|
"sigma-skills": "^0.1.2",
|
|
66
66
|
"strip-ansi": "^7.1.0",
|
|
67
67
|
"undici": "^7.19.1",
|
package/scripts/postinstall.cjs
CHANGED
|
@@ -58,7 +58,18 @@ for (const pkg of sigmaPackages) {
|
|
|
58
58
|
createLink(srcPkg, destLink, pkg);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
// 3. Ensure
|
|
61
|
+
// 3. Ensure memory directories exist (vector store DB created on first use)
|
|
62
|
+
const memoryDir = join(homedir(), ".phi", "memory");
|
|
63
|
+
const memoryNotesDir = join(memoryDir, "notes");
|
|
64
|
+
const memoryOntologyDir = join(memoryDir, "ontology");
|
|
65
|
+
for (const dir of [memoryDir, memoryNotesDir, memoryOntologyDir]) {
|
|
66
|
+
if (!existsSync(dir)) {
|
|
67
|
+
mkdirSync(dir, { recursive: true });
|
|
68
|
+
console.log(` Φ Created ${dir}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// 4. Ensure settings.json has quietStartup: true
|
|
62
73
|
const settingsPath = join(agentDir, "settings.json");
|
|
63
74
|
try {
|
|
64
75
|
let settings = {};
|