mirror of
https://github.com/andy-stack/vaultkeeper-ai.git
synced 2026-07-22 06:42:03 +00:00
Add Exception helper class for consistent error handling and logging. Replace throw statements and console.error calls with Exception methods. Update service methods to return Error | T instead of mixed success/failure objects. Improve type safety in Claude.extractContents with explicit return type. Add WikiLinks helper to VaultCacheService for managing wiki link references. Update unit tests.
35 lines
No EOL
1.1 KiB
TypeScript
35 lines
No EOL
1.1 KiB
TypeScript
import { Resolve } from "Services/DependencyService";
|
|
import { Services } from "Services/Services";
|
|
import { SystemInstruction } from "./SystemPrompt";
|
|
import type { FileSystemService } from "Services/FileSystemService";
|
|
import type { SettingsService } from "Services/SettingsService";
|
|
import { Notice } from "obsidian";
|
|
|
|
export interface IPrompt {
|
|
systemInstruction(): string;
|
|
userInstruction(): Promise<string>;
|
|
}
|
|
|
|
export class AIPrompt implements IPrompt {
|
|
|
|
private readonly settingsService: SettingsService;
|
|
private readonly fileSystemService: FileSystemService;
|
|
|
|
public constructor() {
|
|
this.settingsService = Resolve<SettingsService>(Services.SettingsService);
|
|
this.fileSystemService = Resolve<FileSystemService>(Services.FileSystemService);
|
|
}
|
|
|
|
public systemInstruction(): string {
|
|
return SystemInstruction;
|
|
}
|
|
|
|
public async userInstruction(): Promise<string> {
|
|
const result = await this.fileSystemService.readFile(this.settingsService.settings.userInstruction, true);
|
|
if (result instanceof Error) {
|
|
new Notice("Failed to load user instructions!");
|
|
return "";
|
|
}
|
|
return result;
|
|
}
|
|
} |