把多个源文件合并复制粘贴给 chatgpt 的 vscode 插件

19次阅读

共计 513 个字符,预计需要花费 2 分钟才能阅读完成。

安装地址 https://marketplace.visualstudio.com/items?itemName=taowen.repo-to-prompt 右键执行 Repo to Prompt 会执行自定义的 repo-to-prompt.codemod.js 文件。传入 selectedFiles 就是 vscode explorer 中当前选中的文件

// repo-to-prompt.codemod.js
const lines = [];
for (const file of selectedFiles) {lines.push('')
    lines.push(new TextDecoder().decode(await vscode.workspace.fs.readFile(file)))
    lines.push('')
}
await vscode.env.clipboard.writeText(lines.join('n'))
vscode.window.showInformationMessage('copied to clipboard')

通过 javascript 执行实现多个源文件合并复制。粘贴给 chatgpt 就可以 chat with your code repo 了。

正文完
 0