# /knowledge - Routing Guide v2.0.0

Mapeamento completo de categorias para notebooks NotebookLM.
Dify KB removido em 06-03-2026. NotebookLM e a fonte primaria.

---

## Regras de Routing

1. **Classificar tema** da query usando keywords
2. **Seleccionar 1-3 notebooks** por ordem de relevancia
3. **Query sequencial** ate score >70
4. **Enriquecer** com Supabase/Context7/Local se necessario
5. **Reportar lacunas** se score <50

---

## Codigo de Routing

### Analise de Query

```javascript
function classificarTema(query) {
  const temas = {
    wordpress: /wordpress|elementor|woocommerce|plugin|wp-cli|theme|widget|gutenberg/i,
    wordpress_seguranca: /seguranca\s*wp|malware|hardening|wordfence|sucuri/i,
    kivicare: /kivicare|ehr|clinica|medico|consulta/i,
    marketing: /marketing|digital|campanha|ads|publicidade|growth|funil/i,
    seo: /seo|keywords|ranking|google|search|organic|serp|indexacao/i,
    copywriting: /copywriting|persuasao|texto|headline|cta|conversao/i,
    social_media: /social\s*media|branding|instagram|facebook|linkedin|tiktok/i,
    video: /video|producao|youtube|monetizacao|canal/i,
    podcast: /podcast|audio|episodio/i,
    ecommerce: /ecommerce|loja\s*online|marketplace|shopify/i,
    programacao: /codigo|api|php|react|node|python|javascript|typescript|programacao/i,
    claude: /claude|claude\s*code|mcp|anthropic/i,
    mcp_dev: /mcp\s*server|mcp\s*dev|protocolo\s*mcp/i,
    ai_tools: /ai\s*editor|cursor|copilot|github\s*copilot/i,
    opensource: /open\s*source|foss|self-hosted/i,
    n8n: /n8n|automacao|workflow\s*automation/i,
    perfex: /perfex|perfexcrm|desk\s*crm/i,
    cwp: /cwp|centos|servidor\s*web|cpanel|hosting/i,
    cloud: /cloud|infraestrutura|devops|docker|kubernetes/i,
    proxmox: /proxmox|virtualizacao|vm|container\s*lxc/i,
    design: /design|branding\s*visual|ai\s*design|canva/i,
    uiux: /ui|ux|interface|usabilidade|wireframe|prototipo/i,
    tipografia: /tipografia|cores|paleta|web\s*design|fonte/i,
    gestao: /gestao\s*projectos|agile|scrum|kanban|sprint/i,
    operacoes: /operacoes|processos|kpi|workflow|sop/i,
    estrategia: /estrategia|empreendedorismo|negocio|plano/i,
    transformacao: /transformacao\s*digital|ia\s*negocio|inovacao/i,
    obsidian: /obsidian|vault|notas|pkm/i,
    decisao: /decisao|porque|contexto|historico/i,
    reonic: /reonic|solar\s*crm/i,
    carstuff: /carstuff|automovel/i,
    solar: /solar|fotovoltaico|engenharia\s*solar/i,
    zaia: /zaia|chatbot|whatsapp\s*bot/i,
    pessoal: /jung|taoismo|adhd|phda|autismo|kintsugi|estoicismo|somatica/i
  };

  const matches = [];
  for (const [tema, pattern] of Object.entries(temas)) {
    if (pattern.test(query)) matches.push(tema);
  }

  return matches.length > 0 ? matches : ['geral'];
}
```

### Notebooks por Tema

```javascript
const notebookRouting = {
  // --- WordPress e Web ---
  wordpress: [
    "fb2f26bd-8cb0-4d4c-bafc-4f1ebb51c51d", // WordPress Config CLI (268 fontes)
    "5be0d1a6-00f2-4cd9-b835-978cb7721601", // WordPress e Elementor (88)
    "bd06acff-4b9d-44aa-b3f7-60434bbd6b49"  // Documentacao WooCommerce (3)
  ],
  wordpress_seguranca: [
    "5f60adfd-2435-4725-8c12-9c11c5f51d75"  // Ciberseguranca WordPress (95)
  ],
  kivicare: [
    "78621405-a5bc-433f-856f-296260a80bd9"  // KiviCare EHR WP (145)
  ],

  // --- Marketing e Conteudo ---
  marketing: [
    "4c595973-ba10-420a-a3bf-e4389e424ad3", // Marketing Digital PT (189)
    "76647e0f-3ae2-4c00-a0a8-f457aebf5655"  // Marketing Digital Avancado (78)
  ],
  seo: [
    "4c595973-ba10-420a-a3bf-e4389e424ad3"  // Marketing Digital PT (189)
  ],
  copywriting: [
    "7b8fec17-d34f-4e3f-a8c6-8231e51f6323"  // Copywriting e Persuasao (50)
  ],
  social_media: [
    "9053d0e8-dd39-460b-b5ea-e67af3e9a675"  // Social Media e Branding (51)
  ],
  video: [
    "058a896e-6c9a-4e51-ae7d-9adb2738bc5f", // Producao de Video e Youtube (49)
    "60a209a7-e205-4d57-a6f3-fef3de61e87a"  // YouTube Monetizacao e Compliance (30)
  ],
  podcast: [
    "a5bef96b-a1af-4293-9979-5da46f8d2301"  // Podcast Descomplicar (33)
  ],
  ecommerce: [
    "226e384e-d4bc-48f4-bb82-7927360436cc", // E-commerce Pratico (63)
    "8a430cf2-ed99-413d-b4bf-a1400deaf49e"  // E-Commerce Portugal (24)
  ],

  // --- Desenvolvimento ---
  programacao: [
    "24947ffa-0019-448a-a340-2f4a275d2eb1"  // Programacao (53)
  ],
  claude: [
    "2876d1fe-5cea-4d98-8140-b0e1a81c6bc4", // Claude Code (132)
    "0be6f45b-8fd5-4a5e-8f80-e36a6f516ded"  // Claude Code mini (2)
  ],
  mcp_dev: [
    "73102308-70ef-403e-9be9-eae0cfc62d55", // Desenvolvimento de MCPs (22)
    "2876d1fe-5cea-4d98-8140-b0e1a81c6bc4"  // Claude Code (132)
  ],
  ai_tools: [
    "57d9c6c9-48ba-4d83-8f71-cc890f348a53"  // AI Code Editors (20)
  ],
  opensource: [
    "cabf9821-c1ff-44cb-9bfd-59bda3599792"  // Open Source Software and Platforms (163)
  ],
  n8n: [
    "f2c809b8-1cb5-4dd0-aa7e-be2cfb6704d1"  // n8n (66)
  ],
  perfex: [
    "df4688bb-c2c0-4aba-98c1-38c3b50a353c", // Perfex CRM (191)
    "80606de8-2783-4d36-b08d-5825e6f9a8da"  // Dev PerfexCRM (44)
  ],

  // --- Infraestrutura ---
  cwp: [
    "0ded7bd6-69b3-4c76-b327-452396bf7ea7"  // CWP (214)
  ],
  cloud: [
    "f9a79b5a-649f-4443-afaf-7ff562b6c2e7"  // Cloud e Infraestrutura TI (146)
  ],
  proxmox: [
    "276ccdde-6b95-42a3-ad96-4e64d64c8d52"  // Proxmox (120)
  ],

  // --- Design ---
  design: [
    "b568b13b-0eed-48c9-b513-5c5b7ec0b102"  // Design Profissional AItomatizado (244)
  ],
  uiux: [
    "081ca512-8279-4850-b2b9-dff090267482"  // UI/UX Design (28)
  ],
  tipografia: [
    "f97a0d2b-a5b3-4640-b941-3cbb184b1b81"  // Tipografia e Cor para Web (41)
  ],

  // --- Gestao e Estrategia ---
  gestao: [
    "0c9c079c-a426-486c-99eb-1564d42d37ad", // Gestao de Projectos e Agile (44)
    "f9dc59c2-718b-4b12-bd06-095d4bfa3e34"  // Gestao de Operacoes (41)
  ],
  operacoes: [
    "f9dc59c2-718b-4b12-bd06-095d4bfa3e34"  // Gestao de Operacoes (41)
  ],
  estrategia: [
    "79d43410-0e29-4be1-881d-84db6bdc239a", // Estrategia e Empreendedorismo (107)
    "ab876d0d-12a8-43d9-bc62-59c1c8e9d0f8"  // Transformacao Digital e IA (73)
  ],
  transformacao: [
    "ab876d0d-12a8-43d9-bc62-59c1c8e9d0f8", // Transformacao Digital e IA (73)
    "929ef67b-c131-4f01-abd0-8b078491a6b7", // AI Automation Stack (5)
    "f4be0e3f-4d9e-4c5c-a743-9f14427f2e43"  // AI Agents Intensive Course (5)
  ],

  // --- Sistema e Produtividade ---
  obsidian: [
    "ebee9fe1-78fd-4f85-8938-f19f3ea32131"  // Obsidian + Claude (117)
  ],
  decisao: [], // Supabase primeiro, depois Obsidian notebook

  // --- Produtos e Clientes ---
  reonic: [
    "b7e61158-0717-4582-8ef2-0301be3c73ae"  // Reonic (131)
  ],
  carstuff: [
    "90f0bc77-b5e4-4ddd-a07c-013a1a30b247"  // CarStuff (25)
  ],
  solar: [
    "03d54e00-aefa-45dc-ba01-f3864a7c3112", // Solar FV Engenharia (5)
    "0082bcaf-1e17-4b84-87cc-2256b1719b55"  // OpenSolar (4)
  ],
  zaia: [
    "087d76f1-e929-49da-9e3c-4edc22b42b3f"  // Zaia (28)
  ],

  // --- Pessoal ---
  pessoal: [
    "d5c67d7f-7fe8-4542-9e5c-22403f3193ee", // Jung (41)
    "8c6c8257-bda2-433c-bf55-f40d98bfde8f", // Emanuel Almeida (36)
    "aea85baf-9ddf-4d79-bf07-81391a275b09", // Taoism (28)
    "a4ff3fd7-fb7c-49a1-94ff-0433193e2338", // ADHD (17)
    "66eff78e-318f-4a8b-a3c7-039a4124b1ad", // Autismo (14)
    "6dcd08e8-79d9-4ae0-b6bf-b2ee96717bf2", // Essencia de Heroi (13)
    "82a95c2f-be56-4c4a-a96f-96f6677a6991", // Auto Kintsugi (10)
    "3410893b-16a3-4178-9091-42650a41086f", // Psicologia Somatica (10)
    "4b986ad4-49da-4604-a423-4fcdf20dd9da"  // Marcus Aurelius / Stoic (3)
  ],

  // --- Fallback generico ---
  geral: [
    "ebee9fe1-78fd-4f85-8938-f19f3ea32131", // Obsidian + Claude (sistema)
    "79d43410-0e29-4be1-881d-84db6bdc239a"  // Estrategia (amplo)
  ]
};
```

### Pesquisa Sequencial

```javascript
async function pesquisar(query) {
  const temas = classificarTema(query);
  let resultados = [];

  // 1. Recolher notebooks unicos (max 3)
  const notebookIds = new Set();
  for (const tema of temas) {
    const ids = notebookRouting[tema] || notebookRouting.geral;
    ids.forEach(id => notebookIds.add(id));
  }
  const notebooks = [...notebookIds].slice(0, 3);

  // 2. Query NotebookLM sequencial
  for (const id of notebooks) {
    const resultado = await mcp__notebooklm__notebook_query({
      notebook_id: id,
      query: query
    });

    const score = avaliarRelevancia(resultado, query);
    if (score > 70) {
      return { resultado, fonte: `NotebookLM (${id})`, score };
    }
    if (score > 30) {
      resultados.push({ resultado, id, score });
    }
  }

  // 3. Enriquecer com outras fontes
  const supabase = await mcp__memory_supabase__search_memories({
    query, tags: temas
  });
  if (supabase.length > 0) resultados.push({ resultado: supabase, fonte: 'Supabase' });

  // 4. Context7 para temas dev
  if (temas.some(t => ['programacao', 'claude', 'mcp_dev', 'wordpress'].includes(t))) {
    // Tentar resolver biblioteca
    const lib = await mcp__plugin_context7_context7__resolve_library_id({
      libraryName: extractLibName(query)
    });
    if (lib) {
      const docs = await mcp__plugin_context7_context7__query_docs({
        context7CompatibleLibraryID: lib.id,
        topic: query
      });
      resultados.push({ resultado: docs, fonte: 'Context7' });
    }
  }

  // 5. Resultado
  if (resultados.length === 0) {
    // Lacuna detectada
    await mcp__memory_supabase__save_memory({
      content: `LACUNA: Query "${query}" sem informacao.`,
      metadata: { type: 'lacuna-kb', temas, query }
    });
    return { lacuna: true, query, temas };
  }

  return {
    resultados: resultados.sort((a, b) => (b.score || 0) - (a.score || 0)),
    fonte: 'multiplas'
  };
}
```

---

## Fontes Complementares (Fallback)

| Fonte | MCP | Quando Usar |
|-------|-----|-------------|
| **Supabase** | memory-supabase | Decisoes, contexto, historico sessoes |
| **Context7** | context7 | Docs bibliotecas externas (npm, pip, etc.) |
| **Docs Locais** | filesystem (Grep/Glob) | Codigo em /Dev/, docs em /Hub/ |

---

## Estatisticas

- **58 notebooks** (49 profissional + 9 pessoal)
- **~3200 fontes** total
- **32 temas** mapeados
- **Limite:** 500 notebooks, 300 fontes/notebook (Plus)

Inventario completo: `~/.claude/projects/-media-ealmeida-Dados-Hub/memory/notebooklm-inventory.md`
