# Production Knowledge Base Configuration
#
# Configuration for a shared/production KB with SurrealDB backend.
# Suitable for team-wide knowledge bases or central documentation.
#
# Usage:
#   nickel export --format json production.ncl > config.json
# With custom TOOLS_PATH:
#   TOOLS_PATH=/opt/mytools nickel export --format json production.ncl > 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 = "tools-ecosystem",
    version = "1.0.0",
    description = "Shared knowledge base for Tools ecosystem",
  },

  inheritance = {
    # This is the central KOGRAL, no inheritance (this path is itself the shared store)
    base = "$TOOLS_PATH/.kogral-shared",
    guidelines = [],
    priority = 200,  # Higher priority (wins over project-local)
  },

  storage = {
    # Primary: still filesystem for git-friendly versioning
    primary = 'filesystem,

    # Secondary: SurrealDB for scalable queries
    secondary = {
      enabled = true,
      type = 'surrealdb,
      url = "ws://localhost:8000",
      namespace = "tools_kogral",
      database = "production",
    },
  },

  embeddings = {
    enabled = true,

    # Use API provider for better quality
    provider = 'openai,
    model = "text-embedding-3-small",
    dimensions = 1536,
    api_key_env = "OPENAI_API_KEY",

    # Alternative: use Claude
    # provider = 'claude,
    # model = "claude-3-haiku",
    # api_key_env = "ANTHROPIC_API_KEY",
  },

  blocks = {
    # Enable blocks for Logseq compatibility in production
    enabled = true,
    parse_on_import = true,
    serialize_on_export = true,
    enable_mcp_tools = true,
  },

  templates = {
    templates_dir = "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 = {
      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 = {},
  },

  query = {
    # Stricter threshold for production
    similarity_threshold = 0.5,
    max_results = 20,
    recency_weight = 2.0,
    cross_graph = false,  # Only search this graph
  },

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

    tools = {
      search = true,
      add_note = true,
      add_decision = true,
      link = true,
      get_guidelines = true,
      export = true,
    },

    resources = {
      expose_project = true,
      expose_shared = true,
    },
  },

  sync = {
    # Active sync to SurrealDB
    auto_index = true,

    watch_paths = [
      "notes",
      "decisions",
      "guidelines",
      "patterns",
      "journal",
    ],

    # Faster sync for production
    debounce_ms = 300,
  },
} | Schema.KbConfig
