- Store captureMetadata (OCR text, window/app/element info) with each step at capture time so AI always has the original rich context. - Add buildCaptureContext() to TextIntelService; capture.js uses it instead of buildCaptureTitle() so both title and metadata come from one pass. - generateStepPatch() prefers stored captureMetadata over re-running OCR, giving the AI the best possible context when the user clicks an AI button later. - Add autoDoc setting: when enabled every capture (shoot, region, and session hotkey/click) is automatically documented by AI. Manual captures await AI before returning; session captures fire-and-forget and push a step:updated event so the renderer reloads seamlessly. - Add ai:rewriteText IPC and rewriteText() method for plain-text polishing via a separate callOllamaText() that skips JSON mode. - Add "AI Rewrite" section in the editor right panel: textarea + AI button that rewrites whatever the user types in place. - Improve buildAiPrompt() rules: action-focused title instructions, explicit anti-junk rules (no "Capture the screen / OCR" blocks), and a context-quality gate that suppresses blocks when context is thin. - Add autoDoc checkbox to AI settings dialog. - Renderer handles step:updated to reload the selected step after background auto-doc finishes. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
107 lines
3.2 KiB
JavaScript
107 lines
3.2 KiB
JavaScript
'use strict';
|
|
|
|
const { contextBridge, ipcRenderer } = require('electron');
|
|
|
|
/**
|
|
* The complete privileged API exposed to the sandboxed renderer. Every call
|
|
* is an explicit invoke; no raw ipcRenderer or Node access leaks through.
|
|
*/
|
|
|
|
const invoke = (channel) => (args) => ipcRenderer.invoke(channel, args);
|
|
|
|
const api = {
|
|
library: {
|
|
list: invoke('library:list'),
|
|
create: invoke('library:create'),
|
|
duplicate: invoke('library:duplicate'),
|
|
delete: invoke('library:delete'),
|
|
setFavorite: invoke('library:setFavorite'),
|
|
trashList: invoke('library:trash:list'),
|
|
trashRestore: invoke('library:trash:restore'),
|
|
trashPurge: invoke('library:trash:purge'),
|
|
},
|
|
folders: {
|
|
create: invoke('folders:create'),
|
|
rename: invoke('folders:rename'),
|
|
delete: invoke('folders:delete'),
|
|
moveGuide: invoke('folders:moveGuide'),
|
|
},
|
|
guide: {
|
|
get: invoke('guide:get'),
|
|
save: invoke('guide:save'),
|
|
},
|
|
step: {
|
|
add: invoke('step:add'),
|
|
save: invoke('step:save'),
|
|
delete: invoke('step:delete'),
|
|
restore: invoke('step:restore'),
|
|
reorder: invoke('steps:reorder'),
|
|
imagePath: invoke('step:imagePath'),
|
|
setWorkingImage: invoke('step:setWorkingImage'),
|
|
resetWorkingImage: invoke('step:resetWorkingImage'),
|
|
fromClipboard: invoke('step:fromClipboard'),
|
|
importImage: invoke('step:importImage'),
|
|
},
|
|
search: {
|
|
query: invoke('search:query'),
|
|
titles: invoke('search:titles'),
|
|
},
|
|
settings: {
|
|
all: invoke('settings:all'),
|
|
set: invoke('settings:set'),
|
|
globalPlaceholders: invoke('placeholders:globals:get'),
|
|
setGlobalPlaceholders: invoke('placeholders:globals:set'),
|
|
},
|
|
ai: {
|
|
test: invoke('ai:test'),
|
|
fillStep: invoke('ai:fillStep'),
|
|
rewriteText: invoke('ai:rewriteText'),
|
|
},
|
|
capture: {
|
|
shoot: invoke('capture:shoot'),
|
|
region: invoke('capture:region'),
|
|
session: invoke('capture:session'),
|
|
state: invoke('capture:state'),
|
|
onAdded: (fn) => ipcRenderer.on('capture:added', (e, payload) => fn(payload)),
|
|
onState: (fn) => ipcRenderer.on('capture:state', (e, payload) => fn(payload)),
|
|
onStepUpdated: (fn) => ipcRenderer.on('step:updated', (e, payload) => fn(payload)),
|
|
},
|
|
archive: {
|
|
export: invoke('archive:export'),
|
|
open: invoke('archive:open'),
|
|
saveLinked: invoke('archive:saveLinked'),
|
|
},
|
|
snapshots: {
|
|
list: invoke('snapshots:list'),
|
|
create: invoke('snapshots:create'),
|
|
restore: invoke('snapshots:restore'),
|
|
},
|
|
templates: {
|
|
list: invoke('templates:list'),
|
|
load: invoke('templates:load'),
|
|
save: invoke('templates:save'),
|
|
delete: invoke('templates:delete'),
|
|
rename: invoke('templates:rename'),
|
|
duplicate: invoke('templates:duplicate'),
|
|
export: invoke('templates:export'),
|
|
import: invoke('templates:import'),
|
|
},
|
|
export: {
|
|
formats: invoke('export:formats'),
|
|
defaults: invoke('export:defaults'),
|
|
run: invoke('export:run'),
|
|
chooseDir: invoke('export:chooseDir'),
|
|
preview: invoke('export:preview'),
|
|
cleanupPreviews: invoke('preview:cleanup'),
|
|
},
|
|
shell: {
|
|
openPath: invoke('shell:openPath'),
|
|
showItemInFolder: invoke('shell:showItemInFolder'),
|
|
},
|
|
app: {
|
|
info: invoke('app:info'),
|
|
},
|
|
};
|
|
|
|
contextBridge.exposeInMainWorld('stepforge', api);
|