chore(llm): relocate skills to assets

This commit is contained in:
Elian Doran
2026-03-31 20:52:17 +03:00
parent a6b8785341
commit f528833232
5 changed files with 13 additions and 5 deletions

View File

@@ -153,6 +153,12 @@ Trilium provides powerful user scripting capabilities:
- Add migration scripts in `apps/server/src/migrations/`
- Update schema in `apps/server/src/assets/db/schema.sql`
### Server-Side Static Assets
- Static assets (templates, SQL, translations, etc.) go in `apps/server/src/assets/`
- Access them at runtime via `RESOURCE_DIR` from `apps/server/src/services/resource_dir.ts` (e.g. `path.join(RESOURCE_DIR, "llm", "skills", "file.md")`)
- **Do not use `import.meta.url`/`fileURLToPath`** to resolve file paths — the server is bundled into CJS for production, so `import.meta.url` will not point to the source directory
- **Do not use `__dirname` with relative paths** from source files — after bundling, `__dirname` points to the bundle output, not the original source tree
## Build System Notes
- Uses pnpm for monorepo management
- Vite for fast development builds

View File

@@ -4,13 +4,15 @@
* included in the system prompt; full content is fetched via the load_skill tool.
*/
import { tool } from "ai";
import { readFile } from "fs/promises";
import { dirname, join } from "path";
import { fileURLToPath } from "url";
import { join } from "path";
import { tool } from "ai";
import { z } from "zod";
const __dirname = dirname(fileURLToPath(import.meta.url));
import resourceDir from "../../resource_dir.js";
const SKILLS_DIR = join(resourceDir.RESOURCE_DIR, "llm", "skills");
interface SkillDefinition {
name: string;
@@ -41,7 +43,7 @@ async function loadSkillContent(name: string): Promise<string | null> {
if (!skill) {
return null;
}
return readFile(join(__dirname, skill.file), "utf-8");
return readFile(join(SKILLS_DIR, skill.file), "utf-8");
}
/**