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.