diff --git a/tools/extract-prompts.mjs b/tools/extract-prompts.mjs new file mode 100644 index 0000000..6d2c47c --- /dev/null +++ b/tools/extract-prompts.mjs @@ -0,0 +1,31 @@ +// Extracts Capri's prompt constants verbatim into assets/prompts/*.txt. +// Usage: node tools/extract-prompts.mjs +import { readFileSync, writeFileSync } from 'node:fs'; +import path from 'node:path'; +const src = process.argv[2]; +const out = path.resolve(import.meta.dirname, '../assets/prompts'); +const read = (f) => readFileSync(path.join(src, f), 'utf8'); +const chat = read('apps/desktop/chat-service.mjs'); +const start = chat.indexOf('const audioChannelInstruction'); +const end = chat.indexOf('export function validateInput'); +const { CAPRI_SCREEN_SELF } = await import(path.join(src, 'apps/desktop/screen-identity.mjs')); +const names = ['audioChannelInstruction', 'interfaceInstruction', 'toolInstruction', 'chatOnlyInstruction', + 'conversationOnlyInstruction', 'dialogueOnlyInstruction', 'webAnswerInstruction']; +const values = new Function('CAPRI_SCREEN_SELF', `${chat.slice(start, end)}; return { ${names.join(',')} };`)(CAPRI_SCREEN_SELF); +values.interfaceInstruction = values.interfaceInstruction(); +// Linux wording (the Rust app runs on KDE Plasma and i3, not Windows). +const linux = (s) => s + .replaceAll("Capri's own Windows companion", "Capri's own Linux desktop companion") + .replaceAll("Capri's Windows desktop companion", "Capri's Linux desktop companion") + .replaceAll('a Windows window request', 'a visible window request') + .replaceAll('the Recycle Bin', 'the Trash').replaceAll('a Recycle Bin', 'a Trash').replaceAll('fictional Recycle Bin', 'fictional Trash') + .replaceAll('Chrome or Edge', 'Chrome or Firefox'); +const file = (n) => n.replace(/[A-Z]/g, (c) => '-' + c.toLowerCase()).replace(/-instruction$/, ''); +for (const n of names) if (n !== 'audioChannelInstruction') writeFileSync(path.join(out, file(n) + '.txt'), linux(values[n])); +// Dialogue continuity (no style observation suffix, see spec AG-12). +const { dialogueStyleInstruction } = await import(path.join(src, 'apps/desktop/dialogue-style.mjs')); +writeFileSync(path.join(out, 'dialogue-continuity.txt'), dialogueStyleInstruction([])); +const comm = await import(path.join(src, 'packages/runtime/src/communication.mjs')); +writeFileSync(path.join(out, 'communication-styles.json'), JSON.stringify(comm.COMMUNICATION_STYLES, null, 2) + '\n'); +writeFileSync(path.join(out, 'communication-suffix.txt'), comm.communicationInstruction('neutral').split('\n').slice(2).join('\n')); +console.log('ok', names.length);