Skip to content

Releases: zacxyonly/SimpleContext

v4.3.0 β€” App Commands: Official Plugin-to-Host Interface

16 Mar 21:25

Choose a tag to compare

πŸ”Œ App Commands β€” Kontrak Resmi Plugin ↔ Host

Rilis ini memperkenalkan app_commands sebagai kontrak resmi di BasePlugin
untuk mengekspos command ke aplikasi host (Telegram bot, Discord, CLI, web UI, dll).

Sebelumnya plugin komunitas tidak punya cara standar untuk mendeklarasikan
command β€” setiap host app punya convention sendiri. Mulai v4.3.0, semua
tersentralisasi di core.


✨ What's New

AppCommandContext β€” Interface Platform-Agnostic

from simplecontext.plugins.base import AppCommandContext

ctx = AppCommandContext.create(
    command  = "search",
    user_id  = "12345",
    args     = ["python", "error"],
    platform = "telegram",   # "discord" | "cli" | "web" | dll
    raw      = update,       # object asli platform (opsional)
    sc       = sc,           # SimpleContext instance (opsional)
)

app_commands di BasePlugin

class MyPlugin(BasePlugin):
    name = "my_plugin"

    app_commands = {
        "mycommand": {
            "description": "Deskripsi singkat",   # wajib
            "usage":       "/mycommand <query>",  # opsional
            "handler":     "handle_mycommand",    # nama method di class ini
            "args_hint":   "<query>",             # opsional
            "hidden":      False,                 # opsional, default False
        }
    }

    async def handle_mycommand(self, ctx: AppCommandContext) -> str:
        return f"Query: {ctx.args_str}, Platform: {ctx.platform}"

get_app_commands() di BasePlugin

Validasi handler exist sebelum return β€” command yang broken tidak didaftarkan.

on_app_command() di BasePlugin

Fallback hook untuk plugin yang ingin handle semua command di satu method.

app_info di BasePlugin

Dict yang diisi host saat plugin di-load. Plugin bisa tahu platform tempat dia berjalan.

PluginLoader β€” 3 method baru

Method Deskripsi
get_all_app_commands() Agregasi commands dari semua plugin, dengan conflict detection
fire_app_command(ctx) Eksekusi command ke plugin yang tepat via AppCommandContext
set_app_info(info) Inject metadata platform ke semua plugin sekaligus

πŸ”— Ecosystem

Repo Versi
SimpleContext v4.3.0 ←
SimpleContext-Plugin v1.1.0
SimpleContext-Bot v1.2.0
SimpleContext-Agents β€”

πŸ“‹ Full Changelog

  • feat(plugins): AppCommandContext dataclass β€” platform-agnostic command interface
  • feat(plugins): app_commands class attribute di BasePlugin
  • feat(plugins): get_app_commands() dengan handler validation
  • feat(plugins): on_app_command() fallback hook
  • feat(plugins): app_info dict β€” platform metadata injection
  • feat(loader): get_all_app_commands() dengan conflict detection
  • feat(loader): fire_app_command() dengan fallback ke on_app_command()
  • feat(loader): set_app_info() β€” inject ke semua plugin sekaligus
  • feat(loader): summary() sekarang include app_commands per plugin
  • feat: export AppCommandContext dari simplecontext package
  • chore: bump version 4.0.0 β†’ 4.3.0
  • docs: add Ecosystem section + Call for Contributors di README

v4.2.0 β€” Fuzzy Search, Memory Graph & Adaptive Scoring

16 Mar 16:55

Choose a tag to compare

🧠 SimpleContext v4.2.0

✨ New Features


πŸ” Fuzzy Search

Typo-tolerant search menggunakan Levenshtein distance murni Python.
Tidak membutuhkan dependency eksternal.

results = sc.fuzzy.search(user_id, "ptyhon debg")
# β†’ akan menemukan "python debug"

🧩 Memory Graph & Relationships

Menghubungkan node context dalam bentuk graph relationships sehingga fakta bisa saling terhubung dan ditelusuri.

sc.graph.link(node_a.id, node_b.id, "related_to", strength=0.8)
sc.graph.link(node_a.id, node_b.id, "causes")

sc.graph.get_neighbors(node_id)
sc.graph.get_path(start_id, end_id, max_hops=3)

Supported relationship types

  • related_to
  • causes
  • part_of
  • contradicts
  • precedes
  • supports

⏰ Pattern Detection

Mendeteksi pola perilaku dari histori interaksi user.

patterns = sc.detect_patterns(user_id, time_window_days=7)

Output contoh:

  • peak_hours
  • topics_frequency
  • sentiment_trend
  • activity_streak
  • most_used_agent
  • common_questions

πŸ”„ Smart Compression

Mengompres working memory dengan teknik chunking yang sadar topik
tanpa menggunakan LLM.

sc.smart_compress(user_id, strategy="semantic")  # topic boundary detection
sc.smart_compress(user_id, strategy="time")      # per session gap
sc.smart_compress(user_id, strategy="token")     # by estimated token count

πŸ“Š Adaptive Scoring

Bobot scoring context akan belajar dari feedback user secara adaptif.

sc.feedback(user_id, selected_nodes, score=1.0)   # helpful
sc.feedback(user_id, selected_nodes, score=-1.0)  # not helpful

sc.adaptive.get_weights(user_id)
sc.adaptive.reset_weights(user_id)

πŸ’Ύ Snapshot & Versioning

Export dan restore snapshot memory dengan label dan timestamp.

snap  = sc.snapshot(user_id, label="before_update")
snaps = sc.list_snapshots(user_id)

sc.restore_snapshot(snaps[0]["path"], merge=False)

πŸ“Š Stats

  • βœ… 161 tests passing
  • πŸ“¦ Zero external dependencies
  • πŸ” Fully backward compatible
    Semua API dari v3 / v4 / v4.1 tetap berjalan.

πŸ”„ Upgrade from v4.1.0

# Replace simplecontext/ folder with new version
# No config changes needed
# Fully backward compatible

πŸ”— Related Projects

  • SimpleContext-Agents β€” 9 agent definitions
  • SimpleContext-Bot β€” Telegram bot integration

v4.1.0 β€” Tiered Memory & Context Scoring

16 Mar 10:40

Choose a tag to compare

🧠 SimpleContext v4.1.0

First public release.

What's included

  • 3-Tier Memory (working / episodic / semantic)
  • Intent-aware ContextPlanner
  • Context scoring: relevance + importance + recency + path priority
  • Rule-based fact extraction
  • Jaccard dedup + conflict resolution
  • Importance decay
  • LRU cache (30s TTL)
  • Agent YAML with hot-reload
  • Agent chaining
  • Plugin system with persistent state
  • Multi-storage: SQLite / Redis / PostgreSQL
  • 135 tests passing
  • Zero external dependencies

Supported LLMs

Gemini, OpenAI, Anthropic Claude, Ollama, and any OpenAI-compatible API.

Full Changelog: https://github.com/zacxyonly/SimpleContext/commits/v4.1.0