Use when you have a written implementation plan to execute in a separate session with review checkpoints
0
0
# Install this skill:
npx skills add shuiyuan1223/skillfix_xuetang --skill "memory-system"
Install specific skill from multi-skill repository
# Description
Use when working on the memory/profile system - user profiles, memory search, daily logs, info collection.
# SKILL.md
name: memory-system
description: Use when working on the memory/profile system - user profiles, memory search, daily logs, info collection.
PHA Memory System
Architecture
MemoryManager (singleton)
├── UserStore (SQLite) — user records
├── Profile (file-based) — .pha/users/{uuid}/PROFILE.md
├── Memory (file + FTS) — .pha/users/{uuid}/MEMORY.md + chunks table
├── Daily Logs — .pha/users/{uuid}/memory/{date}.md
├── VectorStore (Vectra) — optional vector search
├── InfoCollector — profile extraction from messages
└── Soul — .pha/SOUL.md agent persona
Key Files
| File | Purpose |
|---|---|
src/memory/memory-manager.ts |
Main orchestrator, singleton via getMemoryManager() |
src/memory/profile.ts |
File I/O for PROFILE.md, MEMORY.md, daily logs |
src/memory/types.ts |
UserProfile, MemoryChunk, MemorySearchResult |
src/memory/info-collector.ts |
Extract profile fields from user messages |
src/memory/soul.ts |
SOUL.md agent persona, DEFAULT_SOUL constant |
src/memory/schema.ts |
SQLite schema (chunks, chunks_fts) |
src/memory/vector-store.ts |
Vectra vector search |
src/memory/hybrid.ts |
Hybrid search (vector + keyword merge) |
src/memory/user-store.ts |
SQLite user CRUD |
Common Operations
import { getMemoryManager } from "../memory/index.js";
import { getUserUuid } from "../utils/config.js";
const mm = getMemoryManager();
const uuid = getUserUuid();
// Profile
mm.getProfile(uuid); // → UserProfile
mm.updateProfile(uuid, { height: 175 });
mm.getProfileCompleteness(uuid); // → number (0-100)
mm.getAllMissingFields(uuid); // → RequiredField[]
mm.extractAndUpdateProfile(uuid, message); // → Partial<UserProfile>
// Memory
mm.appendMemory(uuid, content); // → writes MEMORY.md + indexes
mm.appendDailyLog(uuid, content); // → writes daily log + indexes
await mm.searchAsync(uuid, query, opts); // → MemorySearchResult[]
mm.getMemoryStats(uuid); // → { totalChunks, lastUpdated }
// System prompt
mm.buildSystemPrompt(uuid); // → full prompt with soul + profile + memory
UserProfile Interface
interface UserProfile {
nickname?: string;
gender?: "male" | "female";
birthYear?: number;
height?: number; // cm
weight?: number; // kg
conditions?: string[]; // chronic conditions
allergies?: string[];
medications?: string[];
goals?: { primary?: string; dailySteps?: number; sleepHours?: number; exercisePerWeek?: number };
lifestyle?: { sleepSchedule?: string; exercisePreference?: string; dietPreference?: string };
dataSources?: { huawei?: { connected: boolean; connectedAt?: number } };
}
File Storage Layout
.pha/
├── SOUL.md # Agent persona
├── memory.db # SQLite (chunks, FTS)
└── users/
└── {uuid}/
├── PROFILE.md # User health profile
├── MEMORY.md # Long-term memory
└── memory/
├── 2025-01-01.md # Daily logs
└── 2025-01-02.md
Adding New Profile Fields
src/memory/types.ts— Add toUserProfileinterfacesrc/memory/info-collector.ts— Add toREQUIRED_FIELDSwith parse/validatesrc/memory/profile.ts— UpdateparseProfileMd()andgenerateProfileMd()src/memory/memory-manager.ts— UpdateupdateProfile()deep merge if nested
# Supported AI Coding Agents
This skill is compatible with the SKILL.md standard and works with all major AI coding agents:
Amp
Antigravity
Claude Code
Clawdbot
Codex
Cursor
Droid
Gemini CLI
GitHub Copilot
Goose
Kilo Code
Kiro CLI
OpenCode
Roo Code
Trae
Windsurf
Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.