@phi-code-admin/phi-code 0.56.6 → 0.57.1

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.
@@ -45,6 +45,12 @@ export default function memoryExtension(pi: ExtensionAPI) {
45
45
  name: "memory_search",
46
46
  label: "Memory Search",
47
47
  description: "Search for content in memory using unified search (notes + ontology + QMD vector search)",
48
+ promptSnippet: "Search project memory (notes, ontology, vector search). ALWAYS call before answering questions about prior work, decisions, or project context.",
49
+ promptGuidelines: [
50
+ "Before answering questions about prior work, architecture, decisions, or project context: call memory_search first.",
51
+ "When starting work on a topic, search memory for existing notes and learnings.",
52
+ "After completing important work or learning something new, use memory_write to save it.",
53
+ ],
48
54
  parameters: Type.Object({
49
55
  query: Type.String({ description: "Search query to find in memory" }),
50
56
  }),
@@ -255,31 +261,43 @@ export default function memoryExtension(pi: ExtensionAPI) {
255
261
 
256
262
  /**
257
263
  * Auto-load AGENTS.md on session start
264
+ * Checks both project directory and ~/.phi/memory/
258
265
  */
259
266
  pi.on("session_start", async (_event, ctx) => {
260
267
  try {
261
- // Try to find AGENTS.md in current directory
262
- const agentsPath = join(process.cwd(), "AGENTS.md");
263
-
264
- try {
265
- await access(agentsPath);
266
- const agentsContent = readFileSync(agentsPath, 'utf-8');
267
-
268
- // Send the content as a system message to provide context
269
- ctx.ui.notify("Loaded AGENTS.md context for this session", "info");
270
-
271
- // Optionally inject into the session context
272
- await pi.sendHookMessage({
273
- role: "system",
274
- content: `Session context loaded from AGENTS.md:\n\n${agentsContent}`,
275
- }, { source: "extension" });
268
+ const locations = [
269
+ join(process.cwd(), "AGENTS.md"),
270
+ join(process.cwd(), ".phi", "AGENTS.md"),
271
+ join(sigmaMemory.config.memoryDir, "AGENTS.md"),
272
+ ];
276
273
 
277
- } catch {
278
- // AGENTS.md doesn't exist, that's fine
274
+ for (const agentsPath of locations) {
275
+ try {
276
+ await access(agentsPath);
277
+ const content = readFileSync(agentsPath, "utf-8");
278
+ if (content.trim()) {
279
+ // Notify user that persistent instructions were loaded
280
+ const lineCount = content.split("\n").length;
281
+ ctx.ui.notify(`📝 Loaded AGENTS.md (${lineCount} lines) from ${agentsPath}`, "info");
282
+ // The content is available via memory_read tool — the model can access it
283
+ break;
284
+ }
285
+ } catch {
286
+ // File doesn't exist at this location, try next
287
+ }
279
288
  }
280
289
 
290
+ // Show memory status
291
+ const status = await sigmaMemory.status();
292
+ const parts: string[] = [];
293
+ if (status.notes.count > 0) parts.push(`${status.notes.count} notes`);
294
+ if (status.ontology.entities > 0) parts.push(`${status.ontology.entities} entities`);
295
+ if (status.qmd.available) parts.push("QMD active");
296
+ if (parts.length > 0) {
297
+ ctx.ui.notify(`🧠 Memory: ${parts.join(", ")}`, "info");
298
+ }
281
299
  } catch (error) {
282
- console.warn("Failed to initialize memory extension:", error);
300
+ // Non-critical, don't spam errors
283
301
  }
284
302
  });
285
303
  }