src / config.ts

/**
 * @file config.ts
 * Plugin configuration schema — generates the LM Studio settings UI.
 */

import { createConfigSchematics } from "@lmstudio/sdk";

export const configSchematics = createConfigSchematics()
  .field(
    "autoInjectMemories",
    "select",
    {
      displayName: "Auto-Inject Memories",
      subtitle:
        "Automatically add relevant memories to every conversation (via prompt preprocessor)",
      options: [
        {
          value: "on",
          displayName:
            "On — inject relevant memories automatically (recommended)",
        },
        {
          value: "off",
          displayName: "Off — only recall when explicitly asked via tools",
        },
      ],
    },
    "on",
  )
  .field(
    "contextMemoryCount",
    "numeric",
    {
      displayName: "Context Memory Count",
      subtitle:
        "How many memories to inject per message when auto-inject is on (1–15)",
      min: 1,
      max: 15,
      int: true,
      slider: { step: 1, min: 1, max: 15 },
    },
    5,
  )
  .field(
    "enableAIExtraction",
    "select",
    {
      displayName: "AI Fact Extraction",
      subtitle:
        "Use the loaded model to automatically extract facts from conversations",
      options: [
        {
          value: "on",
          displayName: "On — AI extracts facts from your messages",
        },
        {
          value: "off",
          displayName:
            "Off — only store what you explicitly tell it to remember",
        },
      ],
    },
    "on",
  )
  .field(
    "enableConflictDetection",
    "select",
    {
      displayName: "Conflict Detection",
      subtitle:
        "Use AI to detect contradictions between new and existing memories",
      options: [
        {
          value: "on",
          displayName: "On — detect and handle conflicting memories",
        },
        {
          value: "off",
          displayName: "Off — store everything without checking",
        },
      ],
    },
    "on",
  )
  .field(
    "decayHalfLifeDays",
    "numeric",
    {
      displayName: "Memory Decay Half-Life (days)",
      subtitle:
        "How many days until an un-accessed memory loses half its retrieval priority (7–365)",
      min: 7,
      max: 365,
      int: true,
      slider: { step: 7, min: 7, max: 365 },
    },
    30,
  )
  .field(
    "memoryStoragePath",
    "string",
    {
      displayName: "Storage Path (advanced)",
      subtitle:
        "Custom directory for the memory database. Leave empty for default (~/.lmstudio/plugin-data/persistent-memory/)",
    },
    "",
  )
  .field(
    "activeProject",
    "string",
    {
      displayName: "Active Project",
      subtitle:
        "Stable project slug for project-scoped retrieval and writes. When set, project memories for this project are auto-injected and AI-extracted durable facts inherit this project.",
    },
    "",
  )
  .build();