mirror of
https://github.com/wiseguru/ReWrite-Voice-Notes.git
synced 2026-07-22 07:49:19 +00:00
This session's features: - Quick Record mode selector: third button on the floater opens a popover of templates, switchable mid-recording. Updates the controller's template in place; does not touch lastUsedTemplateId until completion. - Per-invocation destination override on the main modal: a Destination row under the template picker overrides insertMode and the new-file fields for one run, plumbed via PipelineParams.destinationOverride and shallow-merged onto a template copy before insertOutput. The template file on disk is never mutated. - Assistant prompt as a vault file: replaces the settings textarea with ReWrite/AssistantPrompt.md, loaded via src/assistant-prompt.ts and cached on plugin.assistantPrompt. AI/Agent labels standardized to "Assistant"; aiName -> assistantName; adHocInstructionsPrompt field removed. - Known Nouns list: ReWrite/KnownNouns.md with YAML guidance frontmatter and a Markdown body of nouns (optional misheard alternates after a colon). buildKnownNounsSystemPromptSection injects a "Known nouns" block into the LLM system prompt only when the list is non-empty. Frontmatter is for humans and is not sent to the LLM in v1. Cross-cutting: PipelineParams gains host: PipelineHost (narrow interface in src/types.ts) so the pipeline can read assistantPrompt and knownNouns without importing ReWritePlugin and forming a cycle. Pre-existing uncommitted work also rolled in: - Passphrase encryption for secrets.json.nosync via AES-GCM + PBKDF2 (src/secrets.ts), with PassphraseModal and a settings-tab banner/dropdown for mode selection. - WhisperHost adopt/external states + PID sidecar so an orphaned whisper-server from a previous session is adopted, and external ones are never killed by ReWrite (src/whisper-host.ts). - Whisper status bar (src/ui/whisper-status-bar.ts) and start/stop commands. - Audio persistence before transcription (src/audio-persist.ts) plus the reprocess-audio flow (src/ui/audio-source.ts, src/ui/audio-file-picker.ts). - Wake-name extraction (src/wake-name.ts). - Templates as vault Markdown files in a folder (src/templates-folder.ts). - Linux build script for whisper-server (scripts/build-whisper-linux.sh). - README, CLAUDE.md, docs/FEATURES.md, eslint.config.mts updates covering all of the above. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
62 lines
1.8 KiB
TypeScript
62 lines
1.8 KiB
TypeScript
import { App, Editor, MarkdownView, Notice } from 'obsidian';
|
|
import type ReWritePlugin from '../main';
|
|
import { NoteTemplate } from '../types';
|
|
import { resolveActiveProfile } from '../platform';
|
|
import { runPipeline } from '../pipeline';
|
|
import { isProfileConfiguredForText } from './setup-card';
|
|
import { ReWriteModal } from './modal';
|
|
|
|
export interface TextResolution {
|
|
text: string;
|
|
scope: 'selection' | 'note';
|
|
}
|
|
|
|
export function resolveTextFromEditor(editor: Editor): TextResolution {
|
|
const selection = editor.getSelection();
|
|
if (selection) return { text: selection, scope: 'selection' };
|
|
return { text: editor.getValue(), scope: 'note' };
|
|
}
|
|
|
|
export function resolveActiveTextSource(app: App): TextResolution | null {
|
|
const view = app.workspace.getActiveViewOfType(MarkdownView);
|
|
if (!view) return null;
|
|
return resolveTextFromEditor(view.editor);
|
|
}
|
|
|
|
export async function runTextPipeline(
|
|
plugin: ReWritePlugin,
|
|
template: NoteTemplate,
|
|
text: string,
|
|
): Promise<void> {
|
|
const settings = plugin.settings;
|
|
const { profile } = resolveActiveProfile(settings);
|
|
if (plugin.encryptionStatus.locked) {
|
|
new Notice('ReWrite: API keys are locked. Unlock to process text.');
|
|
plugin.promptUnlock();
|
|
return;
|
|
}
|
|
if (!isProfileConfiguredForText(profile)) {
|
|
new Notice('ReWrite: configure an LLM provider before processing text.');
|
|
new ReWriteModal(plugin.app, plugin).open();
|
|
return;
|
|
}
|
|
const progress = new Notice('ReWrite: processing text...', 0);
|
|
try {
|
|
await runPipeline({
|
|
app: plugin.app,
|
|
settings,
|
|
host: plugin,
|
|
profile,
|
|
template,
|
|
source: { kind: 'text', text },
|
|
});
|
|
progress.hide();
|
|
plugin.settings.lastUsedTemplateId = template.id;
|
|
await plugin.saveSettings();
|
|
new Notice('ReWrite complete.');
|
|
} catch (e) {
|
|
progress.hide();
|
|
const message = e instanceof Error ? e.message : String(e);
|
|
new Notice(`ReWrite: ${message}`);
|
|
}
|
|
}
|