@phi-code-admin/phi-code 0.75.2 → 0.75.4

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.
@@ -411,6 +411,49 @@ export default function memoryExtension(pi: ExtensionAPI) {
411
411
  },
412
412
  });
413
413
 
414
+ /**
415
+ * Per-turn reminder injection (Combo strategy D).
416
+ *
417
+ * Pi LLMs (Claude, Kimi, GLM, MiniMax) consistently ignore "MANDATORY"
418
+ * guidelines buried in long system prompts. To enforce the
419
+ * memory_search/memory_write rules, we prepend a fresh <system-reminder>
420
+ * block to the system prompt at EVERY turn. This pattern is what Claude
421
+ * Code and Cursor use successfully in production for high-priority rules.
422
+ *
423
+ * The reminder is short and concrete (includes the user's current prompt
424
+ * truncated) so it grabs the LLM's attention even mid-conversation when
425
+ * the original critical_rule has receded due to context pressure.
426
+ */
427
+ pi.on("before_agent_start", async (event, _ctx) => {
428
+ // Skip during /plan orchestration: the orchestrator manages its own
429
+ // systemPrompt per phase via the same hook. Conflicting overrides would
430
+ // override the orchestrator's agent personas.
431
+ if ((globalThis as any).__phiOrchestrationActive) {
432
+ return {};
433
+ }
434
+ const userPrompt = (event.prompt ?? "").trim();
435
+ if (userPrompt.length === 0) {
436
+ return {};
437
+ }
438
+ const truncated = userPrompt.length > 200 ? `${userPrompt.slice(0, 200)}...` : userPrompt;
439
+ const reminder = `<system-reminder>
440
+ You are about to respond to a new user message:
441
+ "${truncated.replace(/"/g, '\\"')}"
442
+
443
+ REMINDER (project rule, applies every turn):
444
+ 1. Call \`memory_search\` FIRST with keywords from the user's intent. Recent
445
+ project context, prior decisions, and saved learnings are accessible
446
+ ONLY via this tool.
447
+ 2. AFTER completing significant work, call \`memory_write\` to save what
448
+ you did and learned.
449
+
450
+ These two tool calls are not optional. Skipping them violates project rules.
451
+ </system-reminder>
452
+
453
+ `;
454
+ return { systemPrompt: reminder + event.systemPrompt };
455
+ });
456
+
414
457
  /**
415
458
  * Auto-load AGENTS.md on session start
416
459
  * Checks both project directory and ~/.phi/memory/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phi-code-admin/phi-code",
3
- "version": "0.75.2",
3
+ "version": "0.75.4",
4
4
  "description": "Coding agent CLI with persistent memory, sub-agents, intelligent routing, and orchestration",
5
5
  "type": "module",
6
6
  "piConfig": {