opencode无网环境-引用上下文失效问题

问题

由于公司在内网环境开发,没有网络,安装了 opencode 后发现用 @ 无法自动索引出项目文件,导致每次要指定项目文件的时候都得复制全路径。

环境

opencode=1.3.6

原因

opencode 是用 ripgrep 扫描和索引文件系统的,启动 opencode 的时候会从网上自动下载 ripgrep 并进行安装,会安装到 ${xdgCache}/opencode/bin 里

我1.3.6 window版放的目录是 %USERPROFILE%/.cache/opencode/bin 里即 c:/Users/${username}/.cache/opencode/bin ,相关代码在 packages\opencode\src\global\index.ts 里

最新版的 dev 相关代码在 packages\opencode\src\file\ripgrep.ts

解压路径的代码如下图所示

解决

自己从网上下载 ripgrep,下面为下载链接,我下载的是 ripgrep-15.1.0-x86_64-pc-windows-msvc.zip

https://github.com/BurntSushi/ripgrep/releases

下载完后有两种配置方法

方法1

解压到上面提到的 %USERPROFILE%/.cache/opencode/bin 目录下,如下图所示,然后重启opencode 就可以搜索引用项目文件了。

方法2

解压到自己想要的文件夹,然后在环境变量 path 配置解压文件夹的路径,怎么配我就不多说了,懂的都懂。

注意: 如果用 opencode 桌面版的,配完环境变量需要重启电脑才能生效,可能任务管理器结束某个进程也行,但我没找到

相关推荐
我才是银古9 天前
单模型Agent配置的工程化笔记 —— 四档思考、权限顺序与静态校验
deepseek·opencode
VIP_CQCRE14 天前
在 VS Code 等编辑器里用 OpenCode 接入 Ace Data Cloud:Provider 配置与 IDE 验证
大模型·ai编程·vs code·opencode·ace data cloud
王小希ww15 天前
【Agent & RSI】OpenCode离线部署:终端版 & Web 版
llm·agent·opencode
长不大的杨瑞杰15 天前
OpenCode v2 GitLab 集成实战:Issue 驱动开发、MR 审查与 CI/CD 最小权限
人工智能·ci/cd·gitlab·ai编程·opencode
长不大的杨瑞杰16 天前
OpenCode v2 Custom Tools 实战:开发数据库、工单与发布工具
人工智能·typescript·开发工具·opencode·custom tools
长不大的杨瑞杰17 天前
OpenCode v2 LSP 实战:内置语言服务器、自定义配置与诊断闭环
java·人工智能·typescript·lsp·opencode
ELI_He99920 天前
Opencode 2.0
opencode
长不大的杨瑞杰1 个月前
Windows 安装 OpenCode v2:原生、WSL、Desktop 怎么选?完整配置与避坑指南
人工智能·windows·ai agent·opencode
薛定谔的猫-菜鸟程序员1 个月前
22 分 10 秒 vs 2 小时 44 分:AtomCode 与 opencode 项目开发对比实测,国产agent Atomcode 这么猛吗?
agent·opencode·atomcode
guslegend1 个月前
AI 编程范式转换与 Memory 工程:从无状态模型到 AGENTS.md 声明式配置
人工智能·大模型·agent·ai编程·opencode