# Default Knowledge Base Configuration
#
# This file provides sensible defaults for a project-local knowledge base.
# Copy to `.kogral/config.ncl` and customize as needed.
#
# Usage:
#   nickel export --format json defaults.ncl > .kogral/config.json
# With custom TOOLS_PATH:
#   TOOLS_PATH=/opt/mytools nickel export --format json defaults.ncl > .kogral/config.json
#
# Paths use $TOOLS_PATH variable which resolves to:
# - Value of TOOLS_PATH environment variable if set
# - $HOME/Tools if TOOLS_PATH not set
# - /tmp/tools as final fallback

let Schema = import "../schemas/kogral-config.ncl" in

{
  graph = {
    name = "my-project",
    version = "1.0.0",
    description = "Project knowledge base",
  },

  inheritance = {
    # Inherit from shared KOGRAL (resolves via TOOLS_PATH env var)
    base = "$TOOLS_PATH/.kogral-shared",

    # Additional guideline paths (also resolve via TOOLS_PATH env var)
    guidelines = [
      "$TOOLS_PATH/.claude/guidelines/rust",
      "$TOOLS_PATH/.claude/guidelines/nushell",
    ],

    priority = 100,
  },

  storage = {
    # Primary storage: filesystem (git-friendly)
    primary = 'filesystem,

    # Secondary storage: disabled by default
    secondary = {
      enabled = false,
      type = 'surrealdb,
      url = "ws://localhost:8000",
      namespace = "kogral",
      database = "default",
    },
  },

  embeddings = {
    enabled = true,

    # Use local fastembed by default (no API key needed)
    provider = 'fastembed,
    model = "BAAI/bge-small-en-v1.5",
    dimensions = 384,

    # For API providers (openai, claude, ollama), specify API key env var
    api_key_env = "OPENAI_API_KEY",
  },

  blocks = {
    # Enable Logseq content blocks support (opt-in feature)
    enabled = false,

    # Auto-parse blocks when importing from Logseq
    parse_on_import = true,

    # Serialize blocks to outliner format on export
    serialize_on_export = true,

    # Enable block-related MCP tools (kogral/find_blocks, kogral/find_todos, kogral/find_cards)
    enable_mcp_tools = true,
  },

  templates = {
    templates_dir = "templates",

    # Node type templates
    templates = {
      note = "note.md.tera",
      decision = "decision.md.tera",
      guideline = "guideline.md.tera",
      pattern = "pattern.md.tera",
      journal = "journal.md.tera",
      execution = "execution.md.tera",
    },

    # Export templates
    export = {
      logseq_page = "export/logseq-page.md.tera",
      logseq_journal = "export/logseq-journal.md.tera",
      summary = "export/summary.md.tera",
      json = "export/graph.json.tera",
    },

    # Custom templates (add your own)
    custom = {},
  },

  query = {
    # Semantic search threshold (0.0 = any match, 1.0 = exact match)
    similarity_threshold = 0.4,

    # Maximum results to return
    max_results = 10,

    # Recency bias (higher = prefer newer content)
    recency_weight = 3.0,

    # Enable cross-graph queries (local + shared)
    cross_graph = true,
  },

  mcp = {
    server = {
      name = "kogral-mcp",
      version = "1.0.0",
      transport = 'stdio,
    },

    # Enable/disable MCP tools
    tools = {
      search = true,
      add_note = true,
      add_decision = true,
      link = true,
      get_guidelines = true,
      export = true,
    },

    # Expose resources via MCP
    resources = {
      expose_project = true,
      expose_shared = true,
    },
  },

  sync = {
    # Auto-sync filesystem changes to secondary storage
    auto_index = true,

    # Paths to watch for changes
    watch_paths = [
      "notes",
      "decisions",
      "guidelines",
      "patterns",
      "journal",
    ],

    # Debounce time (ms) before syncing
    debounce_ms = 500,
  },
} | Schema.KbConfig
