diff --git a/AGENTS.md b/AGENTS.md index 3d1278e..4f87332 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -31,7 +31,13 @@ learning_ai_notes/ │ │ │ ├── request-context.ts # getUserId(req), getRequestProductId(req) │ │ │ ├── cosmos-init.ts # Cosmos container registration │ │ │ ├── datastore.ts # @bytelyst/datastore provider (Cosmos or memory) -│ │ │ └── errors.ts # Re-export from @bytelyst/errors +│ │ │ ├── errors.ts # Re-export from @bytelyst/errors +│ │ │ ├── llm.ts # @bytelyst/llm lazy singleton +│ │ │ ├── copilot-transform.ts # Copilot text transforms (shorten, expand, bulletize, etc.) +│ │ │ ├── embeddings.ts # Embedding utilities (duplicate detection, related notes) +│ │ │ ├── feature-flags.ts # 20 feature flags (core + Smart Actions) +│ │ │ ├── telemetry.ts # Telemetry event buffer +│ │ │ └── field-encrypt.ts # @bytelyst/field-encrypt singleton │ │ ├── modules/ │ │ │ ├── notes/ # Note CRUD (types, repository, routes, test) │ │ │ ├── workspaces/ # Workspace CRUD (types, repository, routes, test) @@ -39,13 +45,20 @@ learning_ai_notes/ │ │ │ ├── note-tasks/ # Task CRUD (types, repository, routes, test) │ │ │ ├── note-artifacts/ # Artifact CRUD (types, repository, routes, test) │ │ │ ├── note-agent-actions/ # Agent action audit trail + batch review (types, repository, routes, test) -│ │ │ └── saved-views/ # Persisted saved views CRUD (types, repository, routes) +│ │ │ ├── saved-views/ # Persisted saved views CRUD (types, repository, routes) +│ │ │ └── note-prompts/ # Smart Actions: prompt templates, runner, scheduler, webhooks +│ │ │ ├── types.ts # PromptTemplateDoc, CRUD + Run schemas +│ │ │ ├── repository.ts # Prompt template CRUD +│ │ │ ├── routes.ts # Template CRUD + run + reading-time + suggest-tags + duplicates + links + compare + merge + URL extract + knowledge gaps +│ │ │ ├── runner.ts # executePrompt() with retry + timeout +│ │ │ ├── scheduler.ts # Cron schedules + webhook triggers + routes +│ │ │ └── seed.ts # 20 built-in prompt templates │ │ ├── mcp/ │ │ │ ├── note-tool-contracts.ts # 8 MCP tool Zod schemas + definitions │ │ │ ├── note-tools.ts # 8 executable MCP tool implementations │ │ │ ├── register-note-tools.ts # Fastify plugin to register MCP tools │ │ │ └── *.test.ts # MCP test files -│ │ └── server.ts # Fastify entrypoint (7 route modules + MCP) +│ │ └── server.ts # Fastify entrypoint (11 route modules + MCP + scheduler) │ ├── package.json │ └── tsconfig.json │ @@ -146,7 +159,8 @@ learning_ai_notes/ | **Platform** | platform-service (port 4003) for auth, flags, telemetry, billing, blob | | **Extraction** | extraction-service (port 4005) for AI-powered task extraction | | **Database** | Azure Cosmos DB via `@bytelyst/datastore` — `productId: "notelett"` | -| **Tests** | Vitest — 80 backend tests (19 files), 14 web tests (7 files), 23 mobile tests (4 files), 7 Playwright E2E (scaffolded) | +| **LLM** | `@bytelyst/llm` (mock/openai/azure providers), retry + timeout hardening | +| **Tests** | Vitest — 157 backend tests (28 files), 14 web tests (7 files), 33 mobile tests (7 files), 9 Playwright E2E specs | ## 4. Coding Conventions @@ -201,6 +215,9 @@ learning_ai_notes/ - `note_artifacts` (partition: `/workspaceId`) - `note_agent_actions` (partition: `/workspaceId`) - `saved_views` (partition: `/userId`) +- `note_prompts` (partition: `/userId`) +- `note_prompt_schedules` (partition: `/userId`) +- `note_prompt_webhooks` (partition: `/userId`) ## 6. Build & Test Commands @@ -248,6 +265,26 @@ pnpm run verify | POST | `/api/note-agent-actions/batch-review` | Batch approve/reject (up to 50) | | GET/POST | `/api/saved-views` | List / create saved views | | GET/PATCH/DELETE | `/api/saved-views/:id` | Saved view CRUD | +| POST | `/api/notes/:id/copilot` | Copilot text transform (shorten, expand, bulletize, etc.) | +| POST | `/api/notes/:id/suggest-title` | AI-generated title suggestion | +| POST | `/api/notes/:id/suggest-tags` | AI-generated tag suggestions | +| POST | `/api/notes/:id/check-duplicates` | Duplicate/similar note detection | +| POST | `/api/notes/:id/suggest-links` | Related note suggestions | +| POST | `/api/notes/compare` | Compare 2-5 notes via LLM | +| POST | `/api/notes/merge` | Merge 2-10 notes via LLM | +| POST | `/api/notes/chat` | Workspace RAG chat | +| GET/POST | `/api/note-prompts` | List / create prompt templates | +| GET/PATCH/DELETE | `/api/note-prompts/:id` | Template CRUD | +| POST | `/api/note-prompts/run` | Run a prompt template against a note | +| POST | `/api/note-prompts/url-extract` | Extract + summarize URL content | +| GET/POST | `/api/prompt-schedules` | List / create scheduled actions | +| GET/PATCH/DELETE | `/api/prompt-schedules/:id` | Schedule CRUD | +| GET | `/api/prompt-schedules/diagnostics` | Scheduler health | +| GET/POST | `/api/prompt-webhooks` | List / create webhook triggers | +| GET/PATCH/DELETE | `/api/prompt-webhooks/:id` | Webhook CRUD | +| POST | `/api/prompt-webhooks/:id/trigger` | Manually trigger a webhook | +| POST | `/api/workspaces/:wsId/knowledge-gaps` | Knowledge gap detection | +| GET | `/api/notes/:id/reading-time` | Reading time estimate | | GET | `/health` | Health check | ## 8. MCP Tools diff --git a/README.md b/README.md index a2db794..0742c2d 100644 --- a/README.md +++ b/README.md @@ -29,17 +29,21 @@ pnpm --filter @notelett/mobile run start ## Key Features -- **6 backend modules**: notes, workspaces, relationships, tasks, artifacts, agent actions +- **8 backend modules**: notes, workspaces, relationships, tasks, artifacts, agent actions, saved views, note-prompts (Smart Actions) - **8 MCP tools**: list, get, search, create_draft, update, link_notes, extract_tasks, attach_artifact +- **Smart Actions**: 20 built-in prompt templates, copilot text transforms, scheduler, webhooks, URL extraction - **Agent audit trail**: every write tool records agent action history - **Datastore abstraction**: Cosmos DB in production, in-memory for tests - **Platform integrations**: auth (JWT), telemetry, diagnostics, feature flags, kill-switch, blob storage +- **LLM integration**: `@bytelyst/llm` with retry, timeout, and fallback heuristics ## Environment Copy `backend/.env.example` to `backend/.env` and fill in: - `JWT_SECRET` — shared secret with platform-service - `COSMOS_ENDPOINT` / `COSMOS_KEY` — Azure Cosmos DB credentials (or use `DB_PROVIDER=memory`) +- `LLM_PROVIDER` — `mock`, `openai`, or `azure` (default: `mock`) +- `OPENAI_API_KEY` — required if `LLM_PROVIDER=openai` ## Tests