mirror of
https://github.com/zadam/trilium.git
synced 2026-05-07 06:35:39 +02:00
chore(llm): relocate skills to assets
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user