V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
taowen
V2EX  ›  分享创造

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

  •  
  •   taowen · 47 天前 · 801 次点击
    这是一个创建于 47 天前的主题,其中的信息可能已经有所发展或是发生改变。

    安装地址 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('<file path="' + file.path + '">')
        lines.push(new TextDecoder().decode(await vscode.workspace.fs.readFile(file)))
        lines.push('</file>')
    }
    await vscode.env.clipboard.writeText(lines.join('\n'))
    vscode.window.showInformationMessage('copied to clipboard')
    

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

    2 条回复    2024-03-11 18:23:34 +08:00
    maymay5
        1
    maymay5  
       47 天前
    token 墙怎么解决呢,chatgpt 的 token 极限对于 code 来说还是太少了,并且还是多个 code 文件
    taowen
        2
    taowen  
    OP
       47 天前
    @maymay5 我用 perplexity pro 提供的 claude 3 sonnet 模型,context 要大很多
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   918 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 19:46 · PVG 03:46 · LAX 12:46 · JFK 15:46
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.