Λογότυπο Memory Gc

Memory Gc

Κοινότητα
exiao
memory-gc

Daily memory garbage collection for MEMORY.md / USER.md. Apply decay rules, drain .pending.md, consolidate near-duplicates, maintain canonical theme tags, prune old episode and session files. Invoke when asked to "run memory GC", "clean up memory", "apply memory decay", or from the scheduled cron job.

Επισκόπηση

Εκδότηςexiao
Αποθετήριοskills
Όνομα δεξιότηταςmemory-gc
Αστέρια
40
Forks
12
Συνοδευτικά αρχεία
Μόνο οδηγίες
Σύνδεσμοι
  • Οδηγίες σε Markdown

    Ένα αρχείο SKILL.md που το μοντέλο φορτώνει όταν χρειάζεται, ώστε να καταναλώνει token μόνο όταν ένα αίτημα είναι πράγματι σχετικό.

  • Λειτουργεί με οποιοδήποτε LLM

    Οι δεξιότητες AI είναι απλό Markdown, όχι κώδικας για συγκεκριμένο πάροχο, επομένως αυτή η δεξιότητα λειτουργεί με GPT, Claude, Gemini, Grok ή ένα τοπικό μοντέλο.

  • Αυτοτελής

    Όλα όσα χρειάζεται το μοντέλο περιλαμβάνονται στις οδηγίες — χωρίς επιπλέον αρχεία για συγχρονισμό.

  • Ανοιχτού κώδικα

    Δημοσιεύτηκε από exiao στο GitHub. Διαβάστε το πηγαίο περιεχόμενο πριν εγκαταστήσετε τη δεξιότητα.

Εγκατάσταση

Εγκαταστήστε τη δεξιότητα AI Memory Gc στο TypingMind για να τη χρησιμοποιείτε με οποιοδήποτε LLM ή προσθέστε τη σε άλλον πράκτορα AI που διαβάζει αρχεία SKILL.md.

1

Εγκατάσταση στο TypingMind

Το TypingMind εγκαθιστά μια δεξιότητα απευθείας από τον φάκελό της στο GitHub — διαβάζει το SKILL.md, συγκεντρώνει τα συνοδευτικά αρχεία σε πακέτο και αποθηκεύει το αποτέλεσμα τοπικά.

  1. Ανοίξτε την εφαρμογή και μεταβείτε στα Πρόσθετα → Δεξιότητες.
  2. Επιλέξτε «Εγκατάσταση από GitHub».
  3. Επικολλήστε το παρακάτω URL του φακέλου της δεξιότητας και επιβεβαιώστε.
    https://github.com/exiao/skills/tree/main/memory/memory-gc
  4. Ενεργοποιήστε τη δεξιότητα σε κάθε συνομιλία όπου θέλετε να είναι διαθέσιμη.
Πρόσθετα → Δεξιότητες → Νέα δεξιότητα → Από URL του GitHub, έπειτα επικολλήστε το URL του φακέλου και πατήστε «Συνέχεια».
2

Εγκατάσταση σε άλλον πράκτορα AI

Κάθε πράκτορας AI που διαβάζει τη μορφή Agent Skills μπορεί να χρησιμοποιήσει αυτή τη δεξιότητα — αντιγράψτε τον φάκελο στον κατάλογο δεξιοτήτων του.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/exiao/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/memory/memory-gc .claude/skills/memory-gc
Επανεκκινήστε το Claude Code μετά την αντιγραφή, ώστε να εντοπίσει τη νέα δεξιότητα.

Χρησιμοποιήστε τη στο TypingMind

Ενεργοποιήστε τη δεξιότητα Memory Gc σε οποιαδήποτε συνομιλία στο TypingMind και το μοντέλο αναλαμβάνει τα υπόλοιπα. Το όνομα και η περιγραφή της περιλαμβάνονται στην προτροπή συστήματος και, μόλις προκύψει ένα σχετικό αίτημα, το μοντέλο φορτώνει μόνο του τις πλήρεις οδηγίες — δεν χρειάζεται ποτέ να την καλείτε χειροκίνητα και δεν καταναλώνει token μέχρι να χρησιμοποιηθεί πραγματικά.

Το μοντέλο φορτώνει αυτόματα τη δεξιότητα Memory Gc μόλις λάβει ένα σχετικό αίτημα.

Λειτουργεί με οποιοδήποτε μοντέλο AI

Οι δεξιότητες AI είναι απλές οδηγίες Markdown και όχι κώδικας για συγκεκριμένο πάροχο, οπότε η δεξιότητα Memory Gc δεν περιορίζεται στο μοντέλο για το οποίο γράφτηκε. Εγκαταστήστε τη μία φορά στο TypingMind και χρησιμοποιήστε τη με GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama ή ένα τοπικό μοντέλο που εκτελείτε εσείς — πάντα με τα δικά σας κλειδιά API.

  • Φόρτωση μόνο όταν χρειάζεται

    Η προτροπή συστήματος περιλαμβάνει μόνο το όνομα και την περιγραφή. Οι οδηγίες ανακτώνται με το πρώτο σχετικό αίτημα, οπότε μια δεξιότητα που δεν χρησιμοποιείται δεν έχει κόστος.

  • Αλλάξτε μοντέλα κατά τη συνομιλία

    Επειδή η δεξιότητα αποτελείται από οδηγίες και όχι από κώδικα, η αλλαγή μοντέλου δεν επηρεάζει τη λειτουργία της — το επόμενο μοντέλο διαβάζει το ίδιο αρχείο SKILL.md.

Οδηγίες δεξιότητας

Αυτό είναι το περιεχόμενο του αρχείου SKILL.md που φορτώνει το μοντέλο. Διαβάστε το πριν από την εγκατάσταση — μια δεξιότητα αποτελείται από οδηγίες που θα ακολουθήσει το μοντέλο σας.

memory-gc

Daily garbage collection pass for the Hermes memory system. Read this whole skill before taking any action. Execute steps in order. Use the memory tool for MEMORY.md / USER.md mutations; use the terminal for filesystem pruning.

Inputs you already have

  • MEMORY.md and USER.md are already in your system prompt (the snapshot shown at the top of this session). Read them there. Each entry looks like:
    [YYYY-MM-DD][cat] content

Tool availability

The memory tool (MemoryStore) may not be available in all environments (e.g., cron jobs). If it returns "Memory is not available", fall back to direct file editing via FilePatch on ~/.hermes/memories/MEMORY.md. When using FilePatch:

  • Remove entries by replacing the entry text AND its trailing § separator line together in one replacement (match <entry text>\n§ → empty string). This avoids orphaned separators.
  • If the entry is the LAST in the file (no trailing §), remove just the entry text and the preceding \n§\n from the entry above it.
  • Clean up resulting blank lines with sed -i '' '/^$/d' afterward.
  • The same safety rails apply: never touch [rule] or [meta] entries (except the step-8 protected-floor guard, which may losslessly shorten them, never remove).

Pitfall — multibyte characters: MEMORY.md may contain unicode (arrows, special chars in old entries). Use Python for age computation rather than awk, which chokes on multibyte sequences in some locales.

Pitfall — FilePatch § uniqueness: The § separator appears on every entry boundary. old_string containing just <text>\n§ will often match multiple locations. Always include enough surrounding context (adjacent entry text on both sides) to make the match unique. Alternatively, batch multiple adjacent removals into a single FilePatch that replaces the whole multi-entry block at once — this is more reliable than individual removals.

Pitfall — pending drain in cron: The memory tool (MemoryStore) is typically unavailable in cron. Pending entries accumulate across cron GC runs. Do NOT clear .pending.md unless entries were actually drained successfully. They will drain during the next interactive session.

Decay rules (from the [meta] Memory format entry)

cataction
fact, prefreview at 60d: still true? keep or remove
envreview at 30d: still accurate? keep or remove
proj:<path>review at 21d; remove if path no longer exists
rel:<name>review at 90d; remove if name unmentioned lately
taskreview at 14d; remove if completed or abandoned
tmphard remove at 7d — no review
rule, metanever decay

"Review" = a judgment call by you. Err on the side of keeping. When removing, log the removal in the final report.

Procedure

1. Compute ages

For each entry in MEMORY.md and USER.md, parse the leading [YYYY-MM-DD] and compute the age in days relative to today. Skip any entry without a parseable date — report it as unparseable.

2. Apply hard drops (no review, no judgment)

  • [tmp] entries older than 7 days → memory tool, action: remove, old_text = shortest unique substring.
  • [proj:<path>] entries where the path does not exist on disk → remove.

3. Apply review rules

For each entry past its review threshold (from the table above):

  • If it's still plausibly accurate / still used → keep.
  • If it is obviously stale (refers to resolved tmp state, abandoned project, superseded decision) → remove.

Do not remove anything you are not confident is stale. "Unsure" = keep.

4. Drain .pending.md

bash
test -s ~/.hermes/episodes/.pending.md && cat ~/.hermes/episodes/.pending.md

Each non-empty line is TARGET\tLINE. For each line:

  • Try to add via memory tool (target = first field, content = second field).
  • If it still fails for capacity, either (a) consolidate with an existing similar entry via replace, or (b) skip and report.

Once ALL entries are processed successfully, clear the file:

bash
: > ~/.hermes/episodes/.pending.md

If memory tool is unavailable (cron), skip this step entirely. Do not clear the file. Pending entries will accumulate and drain during the next interactive session where the memory tool works.

5. Consolidate near-duplicates

Scan MEMORY.md and USER.md for entries that say essentially the same thing (different dates or phrasing). Merge into one entry using memory tool action: replace. Keep the earliest creation date.

6. Maintain canonical themes

Collect every tag used in episode files:

bash
grep -h "^tags:" ~/.hermes/episodes/*.md 2>/dev/null \
  | sed 's/^tags:[[:space:]]*//' | tr ',' '\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' \
  | sort | uniq -c | sort -rn

Read the current canonical list from MEMORY.md (the [meta] Episode tags (canonical) entry).

  • Any tag used in ≥3 episodes but missing from the canonical list → memory replace to add it to the [meta] entry.
  • Near-duplicate tags in use (debug/debugging, cron/crons, skill/skills) → pick one canonical spelling. Note the merge in your final report (episode-file rewrite is future work, not this pass).

Keep the [meta] Episode tags line under ~250 characters. If it starts to bust, drop themes that have not been used in the last 30 days.

Optimization: If the tag output is large and the canonical list hasn't changed recently, scan only the top ~30 tags for missing canonicals. Don't waste tokens on the long tail.

7. Prune old files

bash
find ~/.hermes/episodes -name "*.md" -mtime +90 -delete
find ~/.hermes/sessions -name "*.jsonl" -mtime +180 -delete

8. Enforce capacity target

After all removals and drains, check the current size of MEMORY.md and read the configured limit from config (do NOT hardcode it — it has changed over time, e.g. 6000 → 8000):

bash
wc -c ~/.hermes/memories/MEMORY.md
LIMIT=$(grep -E '^\s*memory_char_limit:' ~/.hermes/config.yaml 2>/dev/null | grep -oE '[0-9]+' | head -1)
LIMIT=${LIMIT:-8000}
echo "limit=$LIMIT target(70%)=$((LIMIT*70/100))"

The target is 70% of the configured limit (limit 8000 → target 5600). Compute it from $LIMIT, never from a memorized number. GC must always leave the file below 100% of the limit — parking at 99% is the exact failure mode this step exists to prevent.

If the file exceeds the target, evict entries. Eviction priority (evict from top priority first):

  1. [env] entries older than 21 days (even if still accurate; they can be re-added if needed)
  2. [proj:*] entries older than 14 days
  3. [fact] entries older than 45 days
  4. Longest entries first (within the same priority tier)

When no entries meet age thresholds but file is over target: Fall back to evicting the longest [env] entries first, then longest [proj:*] entries, regardless of age. Prefer entries whose content is also captured in a dedicated memory file (e.g., ~/.hermes/memories/cpe-research.md) or in a skill, since those can be re-derived.

[pref] relocation (the file-stays-at-98% failure mode). A hot-memory file dominated by [rule] + [meta] + long project [pref] entries cannot be brought to target by the env/proj/fact ladder above — those are a small slice of the bytes. When the file is still over target after that ladder, treat long project-scoped [pref] entries as relocation candidates (NOT eviction — prefs encode user-approved decisions, so move them, don't drop them): append the content as a dated bullet to the project's dedicated memory file (e.g. Bloom prefs → bloom-architecture.md) via the memory tool (target = the filename, like Step 4 — never a raw shell append, which would trip the filesystem-scope safety rail), archive the original to ~/.hermes/episodes/.gc.log, then remove it from MEMORY.md. Generic cross-project prefs stay hot but get a lossless shortening pass. Never relocate a [rule] — rules are behavioral constraints that must stay in the system prompt every session.

Protected-floor guard (never silently park at 98%). Compute the byte total of [rule] + [meta] entries alone. If that floor already exceeds the 70% target, the target is unreachable without shortening protected entries:

  1. Losslessly shorten the longest [rule]/[meta] entries (preserve dates, categories, force, and behavioral meaning) until the file is under 100% of the limit.
  2. Relocate every project-scoped [pref] per the rule above.
  3. If still over the 70% target, do not loop forever — stop at the lowest achievable byte count and flag it in the final report ("protected floor N chars exceeds 70% target M; durable rule set has outgrown hot memory, consider raising memory_char_limit"). Parking just-under-limit with a flag is correct here; parking at 98% with no flag is the bug this guard prevents.

Before removing, archive evicted entries to ~/.hermes/episodes/.gc.log. Do NOT copy evicted entries back to .pending.md — that creates a feedback loop where entries bounce between MEMORY.md and pending indefinitely.

Keep evicting/relocating until the file is at or below the 70% target, or only [rule] and [meta] entries remain.

9. Log and report

Append a one-line summary to ~/.hermes/episodes/.gc.log:

bash
echo "$(date -u +%Y-%m-%dT%H:%M:%SZ) memory-gc removed=N drained=N consolidated=N themes_added=N files_pruned=N" \
  >> ~/.hermes/episodes/.gc.log

Your final response:

  • One short paragraph summarizing what changed.
  • Only mention anomalies (parse failures, unexpected state, consolidations you are unsure about). If everything was routine, say "routine pass, N entries removed, M drained, K pruned" and stop.

Safety rails

  • Never remove a [rule] or [meta] entry. They may be losslessly shortened (preserving date, category, and behavioral meaning) only under the protected-floor guard in step 8 — shortened, never removed.
  • Never remove something whose content you do not understand. Keep it.
  • If MEMORY.md / USER.md is malformed (no entries parse), stop immediately and report. Do not attempt repair.
  • All filesystem writes/deletes target only ~/.hermes/episodes and ~/.hermes/sessions. Never modify hermes-agent, skills, plans, config.yaml, .env, or anything outside those two directories. Read-only reads needed by this skill are exempt: reading config.yaml for the size limit (step 8) and reading ~/.hermes/memories/*.md for byte counts is fine — the rail forbids writing outside the two dirs, not reading.

Συχνές ερωτήσεις

Τι κάνει η δεξιότητα AI Memory Gc;

Daily memory garbage collection for MEMORY.md / USER.md. Apply decay rules, drain .pending.md, consolidate near-duplicates, maintain canonical theme tags, prune old episode and session files. Invoke when asked to "run memory GC", "clean up memory", "apply memory decay", or from the scheduled cron job.

Γιατί να χρησιμοποιήσετε τη δεξιότητα Memory Gc στο TypingMind;

Επειδή την εγκαθιστάτε μία φορά και τη χρησιμοποιείτε με οποιοδήποτε μοντέλο. Η Memory Gc είναι απλό Markdown και όχι κώδικας ειδικά για κάποιον πάροχο, επομένως η ίδια δεξιότητα λειτουργεί με GPT-5, Claude, Gemini, Grok ή ένα τοπικό μοντέλο — και μπορείτε να αλλάξετε μοντέλο κατά τη διάρκεια της συνομιλίας χωρίς να διακοπεί η λειτουργία της. Το TypingMind λειτουργεί με τα δικά σας κλειδιά API, οπότε πληρώνετε απευθείας τους παρόχους αντί για συνδρομή ανά θέση χρήστη, ενώ οι δεξιότητες και οι συνομιλίες σας παραμένουν στον δικό σας χώρο αποθήκευσης.

Πώς εγκαθιστώ τη Memory Gc στο TypingMind;

Στο TypingMind, ανοίξτε Πρόσθετα → Δεξιότητες → Εγκατάσταση από το GitHub και επικολλήστε το https://github.com/exiao/skills/tree/main/memory/memory-gc. Το TypingMind διαβάζει το αρχείο SKILL.md και εγκαθιστά τη δεξιότητα, την οποία μπορείτε να ενεργοποιείτε ανά συνομιλία.

Ποια μοντέλα AI μπορούν να χρησιμοποιήσουν τη δεξιότητα Memory Gc;

Οποιοδήποτε μοντέλο συνδέετε στο TypingMind. Οι δεξιότητες AI είναι απλές οδηγίες Markdown και όχι κώδικας ειδικά για κάποιον πάροχο, επομένως τα GPT, Claude, Gemini, Grok και τα τοπικά μοντέλα μπορούν όλα να φορτώσουν αυτή τη δεξιότητα όταν ένα αίτημα αντιστοιχεί σε αυτή.

Με πόσα μοντέλα AI μπορώ να χρησιμοποιήσω τη Memory Gc;

Με όσα θέλετε. Εφόσον ένα μοντέλο υποστηρίζει δεξιότητες, μπορείτε να χρησιμοποιήσετε τη Memory Gc με αυτό — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama και άλλα — όλα στο TypingMind με τα δικά σας κλειδιά API.

Είναι δωρεάν η δεξιότητα AI Memory Gc;

Δημοσιεύεται στο GitHub από τον χρήστη exiao. Ελέγξτε το αποθετήριο για τους όρους αδειοδότησης. Πληρώνετε μόνο τον δικό σας πάροχο AI για τα token που χρησιμοποιείτε.

Τι είναι οι δεξιότητες AI;

Μια δεξιότητα AI είναι ένα επαναχρησιμοποιήσιμο πακέτο οδηγιών που διδάσκει σε ένα μοντέλο AI πώς να εκτελεί μια συγκεκριμένη εργασία. Ακολουθεί την ανοιχτή μορφή Agent Skills: ένα αρχείο SKILL.md με όνομα και περιγραφή, μαζί με τυχόν σενάρια κώδικα, πρότυπα ή αρχεία αναφοράς που μπορεί να χρειαστεί το μοντέλο. Το μοντέλο διαβάζει τις οδηγίες μόνο όταν το αίτημά σας αντιστοιχεί στη δεξιότητα, οπότε μια εγκατεστημένη δεξιότητα δεν κοστίζει τίποτα μέχρι να χρησιμοποιηθεί.

Σε τι διαφέρουν οι δεξιότητες AI από τα πρόσθετα ή τους συνδέσμους MCP;

Ένα πρόσθετο ή ένας σύνδεσμος MCP παρέχει στο μοντέλο νέα εργαλεία που μπορεί να καλέσει — κώδικα που εκτελείται κάπου και επιστρέφει ένα αποτέλεσμα. Μια δεξιότητα AI παρέχει αντί γι’ αυτό γνώσεις και διαδικασίες στο μοντέλο: πώς να προσεγγίσει μια εργασία, ποια βήματα να ακολουθήσει και ποια χαρακτηριστικά έχει ένα καλό αποτέλεσμα. Οι δεξιότητες είναι απλό Markdown, επομένως δεν χρειάζονται διακομιστή, κλειδί API ή περιβάλλον εκτέλεσης και λειτουργούν με οποιοδήποτε μοντέλο.

Προβολή όλων

Στήστε δικό σας χώρο εργασίας AI τώρα

Εγγραφείτε στο ενημερωτικό μας δελτίο για να ενημερώνεστε για νέες λειτουργίες και μελλοντικές κληρώσεις δώρων 👇