const fs = require('fs') const base = 'C:/Users/ASUS/Documents/deepseek-harness/default-workspace/desktop-pet/src/' function patch(file, pairs) { const p = base + file let c = fs.readFileSync(p, 'utf8') for (const [from, to] of pairs) { if (!c.includes(from)) { console.log('MISS in', file, '::', from.slice(0, 70).replace(/\n/g, '\\n')) continue } c = c.replace(from, to) } fs.writeFileSync(p, c, 'utf8') } patch('preload/index.ts', [ [ " dropFile: (file: unknown) => void", " dropFile: (file: unknown) => void\n getKb: () => Promise>\n addKb: (name: string) => Promise>\n delKb: (name: string) => Promise>" ], [ " dropFile: (file: unknown) => {", " getKb: () => ipcRenderer.invoke('pet:kb:list'),\n addKb: (name: string) => ipcRenderer.invoke('pet:kb:add', name),\n delKb: (name: string) => ipcRenderer.invoke('pet:kb:del', name),\n dropFile: (file: unknown) => {" ] ]) patch('renderer/src/api.ts', [ [ " dropFile: (file: unknown) => void", " dropFile: (file: unknown) => void\n getKb: () => Promise>\n addKb: (name: string) => Promise>\n delKb: (name: string) => Promise>" ] ]) // Panel:知识库状态 + 文件行按钮 + 设置区列表 patch('renderer/src/panel/Panel.tsx', [ [ " const [photoCat, setPhotoCat] = useState('全部')", " const [photoCat, setPhotoCat] = useState('全部')\n const [kbList, setKbList] = useState>([])" ], [ " void a?.getPhotos().then(setPhotos)", " void a?.getPhotos().then(setPhotos)\n void a?.getKb().then(setKbList)" ], [ ` `, ` {/\.(md|txt)$/i.test(f.name) && ( )} ` ], [ `

密钥只存在本机 \`data/llm.json\`。没配置时她会用本地台词回你。

`, `

密钥只存在本机 \`data/llm.json\`。没配置时她会用本地台词回你。

知识库
{kbList.length === 0 && (
还没有资料。把 .md/.txt 文件拖给小钠,再到「图库 → 文件袋」点「存知识库」。 聊天提到相关内容时她会自动查阅。
)}
{kbList.map((k) => (
📚 {k.name}
{k.chars} 字
))}
` ] ]) console.log('panel kb patched')