From 45a8bc676ea8675dea032cc11d07bcfd42a73d7f Mon Sep 17 00:00:00 2001 From: Apple Date: Mon, 16 Feb 2026 07:44:56 -0800 Subject: [PATCH] docs: expand lint scope batch49 (2 files) --- docs/cursor/11_llm_integration.md | 137 ++++++++++----------- docs/cursor/17_comemory_knowledge_space.md | 79 ++++++------ docs/standards/lint_scope.txt | 2 + 3 files changed, 109 insertions(+), 109 deletions(-) diff --git a/docs/cursor/11_llm_integration.md b/docs/cursor/11_llm_integration.md index fe05d173..e02e2371 100644 --- a/docs/cursor/11_llm_integration.md +++ b/docs/cursor/11_llm_integration.md @@ -20,7 +20,7 @@ --- -# 1. Принцип інтеграції +## 1. Принцип інтеграції Усі виклики до LLM здійснюються **на бекенді**, не з фронтенду. @@ -38,9 +38,9 @@ --- -# 2. Високорівнева архітектура +## 2. Високорівнева архітектура -``` +```text Frontend (React SPA) | | POST /agents/{id}/chat @@ -56,15 +56,15 @@ Backend | ↓ OpenAI API (або інша модель) -``` +```text --- -# 3. Структура директорій для LLM +## 3. Структура директорій для LLM Додайте на бекенд: -``` +```text src/ llm/ openaiClient.ts @@ -73,7 +73,7 @@ prompts/ system_agent.txt system_onboarding.txt system_evolution.txt -``` +```text - `openaiClient.ts` — клієнт OpenAI / GPT. @@ -89,7 +89,7 @@ system_evolution.txt --- -# 4. Реалізація базового клієнта OpenAI +## 4. Реалізація базового клієнта OpenAI **Файл: `src/llm/openaiClient.ts`** @@ -109,11 +109,11 @@ export async function callLLM(messages: any[], model = "gpt-4.1-mini") { return res.choices[0]?.message?.content ?? ""; } -``` +```text --- -# 5. Model Router +## 5. Model Router **Файл: `src/llm/modelRouter.ts`** @@ -130,17 +130,17 @@ export function pickModel(agentProfile: string) { return "gpt-4.1-mini"; } } -``` +```text У майбутньому це місце для: -* локальних моделей (Ollama, vLLM), -* кластеру DAGI, -* автоматичного підбору моделі. +- локальних моделей (Ollama, vLLM), +- кластеру DAGI, +- автоматичного підбору моделі. --- -# 6. Запит до LLM для агентського чату +## 6. Запит до LLM для агентського чату **Файл: `src/controllers/agentsController.ts`** @@ -173,11 +173,11 @@ export async function chatWithAgent(req, res) { res.json({ reply }); } -``` +```text --- -# 7. Інтеграція з Agent Chat у фронтенді +## 7. Інтеграція з Agent Chat у фронтенді **Файл: `api/agents.ts`** @@ -185,7 +185,7 @@ export async function chatWithAgent(req, res) { export async function agentChat(agentId: string, messages: ChatMessage[]) { return api.post(`/agents/${agentId}/chat`, { messages }); } -``` +```text **У `AgentChatWindow.tsx`:** @@ -200,17 +200,17 @@ const onSend = async (text: string) => { addMessage({ role: "assistant", content: response.reply }); }; -``` +```text --- -# 8. Agent-First Onboarding Integration +## 8. Agent-First Onboarding Integration Використовує той самий LLM-клієнт, але з іншим системним промптом: **`prompts/system_onboarding.txt`:** -``` +```text You are MicroDAO Guide Agent. Your job is to ask the user questions one-by-one to configure their microDAO. @@ -218,7 +218,7 @@ Your job is to ask the user questions one-by-one to configure their microDAO. NEVER skip steps. NEVER jump too far. Be friendly, minimalistic and precise. -``` +```text У онбордингу: @@ -227,25 +227,25 @@ const reply = await callLLM([ { role: "system", content: onboardingSystemPrompt }, ...conversation ]); -``` +```text Але state-machine керує реальними діями (API), LLM — тільки текстом. --- -# 9. Integration with Evolutionary Agent (09_evolutionary_agent.md) +## 9. Integration with Evolutionary Agent (09_evolutionary_agent.md) Meta-Agent (self-review) використовує **ще один промпт**: `prompts/system_evolution.txt`: -``` +```text You are Meta-Agent responsible for analyzing logs of conversations. Find mistakes, weak answers, missing rules, and propose improvements. Always output JSON with `["type", "value", "explanation"]`. -``` +```text Self-review: @@ -254,21 +254,21 @@ const improvements = await callLLM([ { role: "system", content: evolutionPrompt }, { role: "user", content: JSON.stringify(conversationLog) } ]); -``` +```text --- -# 10. Як передавати пам'ять агента в LLM +## 10. Як передавати пам'ять агента в LLM У LLM-запит можна додати: -* `short-term memory` (останні X повідомлень) +- `short-term memory` (останні X повідомлень) -* `long-term memory` (витяг з Co-Memory) +- `long-term memory` (витяг з Co-Memory) -* `agent profile` +- `agent profile` -* інструкції агента (структура з DB) +- інструкції агента (структура з DB) Приклад у messages: @@ -280,23 +280,23 @@ const llmMessages = [ ...history, { role: "user", content: question } ]; -``` +```text --- -# 11. Безпека +## 11. Безпека -* API key зберігати у `.env` на сервері. +- API key зберігати у `.env` на сервері. -* Ніколи не відправляти ключ у фронтенд. +- Ніколи не відправляти ключ у фронтенд. -* Додавати rate limit. +- Додавати rate limit. -* Додавати аудит використання агента. +- Додавати аудит використання агента. --- -# 12. Кешування та оптимізація +## 12. Кешування та оптимізація ## 12.1. Кешування відповідей @@ -310,7 +310,7 @@ if (cached) return cached; const reply = await callLLM(messages); await cache.set(cacheKey, reply, { ttl: 3600 }); return reply; -``` +```text ## 12.2. Streaming відповідей @@ -329,7 +329,7 @@ for await (const chunk of stream) { res.write(content); } } -``` +```text ## 12.3. Rate Limiting @@ -343,11 +343,11 @@ const agentLimiter = rateLimit({ max: 10, // 10 запитів на хвилину keyGenerator: (req) => req.user.id, }); -``` +```text --- -# 13. Альтернативні провайдери +## 13. Альтернативні провайдери ## 13.1. Anthropic Claude @@ -367,7 +367,7 @@ export async function callClaude(messages: any[]) { return response.content[0].text; } -``` +```text ## 13.2. Локальні моделі (Ollama) @@ -384,7 +384,7 @@ export async function callOllama(messages: any[], model = "llama2") { const data = await response.json(); return data.message.content; } -``` +```text ## 13.3. Уніфікований інтерфейс @@ -417,11 +417,11 @@ export function getLLMProvider(provider: string): LLMProvider { return new OpenAIProvider(); } } -``` +```text --- -# 14. Обробка помилок +## 14. Обробка помилок ## 14.1. Retry Logic @@ -441,7 +441,7 @@ async function callLLMWithRetry( } throw new Error("LLM call failed after retries"); } -``` +```text ## 14.2. Fallback моделі @@ -454,11 +454,11 @@ async function callLLMWithFallback(messages: any[], primaryModel: string) { return await callLLM(messages, "gpt-3.5-turbo"); } } -``` +```text --- -# 15. Моніторинг та логування +## 15. Моніторинг та логування ## 15.1. Логування викликів @@ -489,7 +489,7 @@ async function callLLM(messages: any[], model: string) { throw error; } } -``` +```text ## 15.2. Метрики @@ -503,9 +503,9 @@ async function callLLM(messages: any[], model: string) { --- -# 16. Завдання для Cursor +## 16. Завдання для Cursor -``` +```text You are a senior backend + frontend engineer. Integrate OpenAI LLM into the MicroDAO Agents system using: @@ -528,11 +528,11 @@ Output: - list of modified files - diff - summary -``` +```text --- -# 17. Типи та інтерфейси +## 17. Типи та інтерфейси ## 17.1. ChatMessage @@ -542,7 +542,7 @@ interface ChatMessage { content: string; timestamp?: string; } -``` +```text ## 17.2. LLMResponse @@ -557,7 +557,7 @@ interface LLMResponse { }; finishReason?: string; } -``` +```text ## 17.3. AgentChatRequest @@ -575,11 +575,11 @@ interface AgentChatRequest { stream?: boolean; }; } -``` +```text --- -# 18. Тестування +## 18. Тестування ## 18.1. Unit Tests @@ -596,7 +596,7 @@ describe("openaiClient", () => { expect(typeof response).toBe("string"); }); }); -``` +```text ## 18.2. Integration Tests @@ -612,23 +612,23 @@ describe("Agent Chat Integration", () => { expect(response.reply).toBeDefined(); }); }); -``` +```text --- -# 19. Результат +## 19. Результат Після інтеграції: -* будь-який агент microDAO працює на GPT/LLM, -* онбординг веде агент-гіда, -* Team Assistant відповідає у чаті, -* Meta-Agent генерує покращення, -* вся система стає справжньою OS на базі ШІ. +- будь-який агент microDAO працює на GPT/LLM, +- онбординг веде агент-гіда, +- Team Assistant відповідає у чаті, +- Meta-Agent генерує покращення, +- вся система стає справжньою OS на базі ШІ. --- -# 20. Наступні кроки +## 20. Наступні кроки Після базової інтеграції можна додати: @@ -643,4 +643,3 @@ describe("Agent Chat Integration", () => { **Готово.** Це **повна специфікація інтеграції LLM**, готова до використання в Cursor. - diff --git a/docs/cursor/17_comemory_knowledge_space.md b/docs/cursor/17_comemory_knowledge_space.md index 2c938c55..67366571 100644 --- a/docs/cursor/17_comemory_knowledge_space.md +++ b/docs/cursor/17_comemory_knowledge_space.md @@ -11,7 +11,7 @@ Knowledge Space — це структурована навігація по ці --- -# 1. Призначення +## 1. Призначення Co-Memory вирішує три завдання: @@ -41,7 +41,7 @@ Knowledge Space — це не "Google Drive". --- -# 2. Що таке Knowledge Space +## 2. Що таке Knowledge Space Knowledge Space — це: @@ -67,7 +67,7 @@ Knowledge Space — це: --- -# 3. Структура Co-Memory +## 3. Структура Co-Memory Co-Memory складається з: @@ -115,7 +115,7 @@ Co-Memory складається з: --- -# 4. Агенти, пов'язані з Co-Memory +## 4. Агенти, пов'язані з Co-Memory ## 4.1. Memory Agent (основний) @@ -153,7 +153,7 @@ Co-Memory складається з: --- -# 5. Життєвий цикл знань +## 5. Життєвий цикл знань ### Етап 1: Створення @@ -190,7 +190,7 @@ Co-Memory складається з: --- -# 6. Структура даних +## 6. Структура даних ## 6.1. Таблиця `knowledge_spaces` @@ -233,7 +233,7 @@ Co-Memory складається з: --- -# 7. Tools (сумісні з Runtime Core) +## 7. Tools (сумісні з Runtime Core) ### 7.1. add_document @@ -263,7 +263,7 @@ RAG-пошук: --- -# 8. Інтеграція з Runtime Core (12) +## 8. Інтеграція з Runtime Core (12) Memory Agent підключається як: @@ -284,58 +284,58 @@ const memoryAgentConfig: AgentConfig = { "link_knowledge" ] }; -``` +```text --- -# 9. Інтеграція з Projects, Messenger, Followups +## 9. Інтеграція з Projects, Messenger, Followups ### Projects Agent -* додає факти про проєкт у Knowledge Space проєкту. +- додає факти про проєкт у Knowledge Space проєкту. ### Messenger Agent -* зберігає важливі уривки обговорень. +- зберігає важливі уривки обговорень. ### Followups Agent -* формує історію ритму та задач у вигляді нотаток. +- формує історію ритму та задач у вигляді нотаток. --- -# 10. UI +## 10. UI ## 10.1. Sidebar → Knowledge -* Список Knowledge Spaces. -* Кнопка "Створити новий простір знань". +- Список Knowledge Spaces. +- Кнопка "Створити новий простір знань". ## 10.2. Основний екран Knowledge Space -* Заголовок. -* Опис. -* Documents. -* Facts. -* Relations. -* Кнопка "Додати документ". -* Кнопка "Додати факт". +- Заголовок. +- Опис. +- Documents. +- Facts. +- Relations. +- Кнопка "Додати документ". +- Кнопка "Додати факт". ## 10.3. Правий сайдбар Knowledge -* Рекомендації від агентів. -* Семантичні групи. -* Контекстні звʼязки. +- Рекомендації від агентів. +- Семантичні групи. +- Контекстні звʼязки. ## 10.4. Чат взаємодії з Knowledge Guide -* "Поясни мені цей документ…" -* "Що ми знаємо про governance?" -* "Покажи всі визначення, повʼязані з DAGI." +- "Поясни мені цей документ…" +- "Що ми знаємо про governance?" +- "Покажи всі визначення, повʼязані з DAGI." --- -# 11. API +## 11. API ### 11.1. Knowledge Spaces @@ -361,9 +361,9 @@ const memoryAgentConfig: AgentConfig = { --- -# 12. Інструкції для Cursor +## 12. Інструкції для Cursor -``` +```text Implement the Co-Memory & Knowledge Space module using: - 17_comemory_knowledge_space.md @@ -409,18 +409,17 @@ Output: - list of changed files - diff - summary -``` +```text --- -# 13. Результат +## 13. Результат Після впровадження цього модуля: -* кожне microDAO отримує повноцінну еволюційну памʼять, -* агенти знають, що створює спільнота, -* знання не губляться в чатах — вони структуруються, -* DAGI отримує основу для глибинного reasoning, -* MicroDAO перетворюється на справжній "живий простір розуму". - +- кожне microDAO отримує повноцінну еволюційну памʼять, +- агенти знають, що створює спільнота, +- знання не губляться в чатах — вони структуруються, +- DAGI отримує основу для глибинного reasoning, +- MicroDAO перетворюється на справжній "живий простір розуму". diff --git a/docs/standards/lint_scope.txt b/docs/standards/lint_scope.txt index 78c9761c..51707dbb 100644 --- a/docs/standards/lint_scope.txt +++ b/docs/standards/lint_scope.txt @@ -127,3 +127,5 @@ docs/cursor/20_integrations_bridges_agent.md docs/cursor/22_agent_only_interface_tasks.md docs/cursor/08_agent_first_onboarding.md docs/cursor/24_agent_cards_tasks.md +docs/cursor/11_llm_integration.md +docs/cursor/17_comemory_knowledge_space.md