@xiaoqiong0v0/opencode-file-tool 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,46 +1,42 @@
1
1
  # opencode-file-tool
2
2
 
3
- OpenCode 文件缓存与图片分析插件。自动缓存用户粘贴的文件,通过多模态模型分析图片,绕过主模型不支持视觉的限制。
3
+ OpenCode 文件缓存与图片分析插件。自动缓存用户粘贴的图片,通过多模态模型分析,绕过主模型不支持视觉的限制。
4
4
 
5
5
  ## 安装
6
6
 
7
- ```bash
8
- # 在 opencode 配置目录安装依赖
9
- cd ~/.config/opencode
10
- npm install @xiaoqiong0v0/opencode-file-tool @xiaoqiong0v0/opencode-plugin-logger
11
- ```
12
-
13
- 然后在 `opencode.json` 的 `plugin` 数组添加:
7
+ 在 `opencode.json` 的 `plugin` 数组添加包名:
14
8
 
15
9
  ```json
16
10
  "plugin": ["@xiaoqiong0v0/opencode-file-tool"]
17
11
  ```
18
12
 
19
- 重启 OpenCode 后,首次使用 `file_tool set-provider <模型名>` 配置视觉模型。
13
+ 重启 OpenCode 后自动安装。首次使用 `file_tool set-provider <模型名>` 配置视觉模型。
20
14
 
21
15
  ## 功能
22
16
 
23
- - **文件缓存** — 粘贴图片时自动缓存到 `~/.opencode/plugins-cache/{sessionId}/`
24
- - **图片分析** — 通过 `analyze_image file_id:N` 用视觉模型分析
25
- - **主/子会话隔离**缓存按会话独立存储,子会话完成自动清理
26
- - **主会话回退**子会话可通过 `list-cache main` 读取主会话缓存
17
+ - **文件缓存** — 粘贴图片时自动缓存到 `~/.opencode/plugins-cache/`
18
+ - **图片分析** — 通过 `analyze_image file_id:N` 调用视觉模型分析
19
+ - **会话父子链**子 agent 会话可通过 parent 链回退读取祖先会话的缓存
20
+ - **多语言**支持中/英文提示
27
21
 
28
22
  ## 工具
29
23
 
30
24
  | 工具 | 说明 |
31
25
  |------|------|
32
- | `file_tool list-provider` | 列出可用模型提供者 |
33
- | `file_tool set-provider <model>` | 切换视觉分析模型 |
34
- | `file_tool list-cache [all\|N\|main\|main N]` | 查看缓存文件列表 |
35
- | `analyze_image file_id:N` | 用视觉模型分析指定图片 |
26
+ | `file_tool list-provider` | 列出可用模型 |
27
+ | `file_tool set-provider <model>` | 切换视觉模型 |
28
+ | `file_tool list-cache [all\|N\|main\|main N]` | 查看缓存文件 |
29
+ | `analyze_image file_id:N` | 分析指定图片 |
36
30
 
37
- ## 配置
31
+ ## 命令
38
32
 
39
- `~/.config/opencode/file-tool.jsonc` 在首次启动时自动生成,也可手动编辑。
33
+ | 命令 | 说明 |
34
+ |------|------|
35
+ | `/file-tool` | 触发 file_tool 工具 |
40
36
 
41
- ## 依赖
37
+ ## 配置
42
38
 
43
- - `@xiaoqiong0v0/opencode-plugin-logger` — 文件日志库
39
+ `~/.config/opencode/file-tool.jsonc` 在首次启动时自动生成。
44
40
 
45
41
  ## GitHub
46
42
 
package/dist/file-tool.js CHANGED
@@ -6,7 +6,7 @@ import { join } from "node:path";
6
6
  const CONFIG_DIR = process.env.HOME || process.env.USERPROFILE || "";
7
7
  const CONFIG_PATH = join(CONFIG_DIR, ".config/opencode/file-tool.jsonc");
8
8
  const OPENCODE_CONFIG = join(CONFIG_DIR, ".config/opencode/opencode.json");
9
- const CACHE_DIR = join(CONFIG_DIR, ".opencode/plugins-cache");
9
+ const CACHE_DIR = join(CONFIG_DIR, ".opencode/plugins-cache", "file-tool");
10
10
  const log = createLogger("file-tool");
11
11
  let _cfg = null;
12
12
  const FILE_TOOL_CFG_SAMPLE = `{
@@ -403,3 +403,4 @@ export const FileTool = async () => {
403
403
  },
404
404
  };
405
405
  };
406
+ export { FileTool as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiaoqiong0v0/opencode-file-tool",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "type": "module",
5
5
  "description": "File cache & image analysis plugin for OpenCode. Auto-caches pasted images, analyzes via multimodal model.",
6
6
  "files": [
@@ -12,7 +12,7 @@
12
12
  ".": "./dist/file-tool.js"
13
13
  },
14
14
  "scripts": {
15
- "build": "tsc && node -e \"require('fs').copyFileSync('dist/file-tool.js', '.opencode/plugins/file-tool.js')\"",
15
+ "build": "tsc && node -e \"try{require('fs').copyFileSync('dist/file-tool.js', '.opencode/plugins/file-tool.js')}catch{}\"",
16
16
  "prepublishOnly": "npm run build"
17
17
  },
18
18
  "repository": {
@@ -24,11 +24,13 @@
24
24
  "url": "https://github.com/xiaoqiong0v0/opencode-file-tool/issues"
25
25
  },
26
26
  "license": "MIT",
27
+ "peerDependencies": {
28
+ "@opencode-ai/plugin": "*"
29
+ },
27
30
  "dependencies": {
28
31
  "@xiaoqiong0v0/opencode-plugin-logger": "^1.0.2"
29
32
  },
30
33
  "devDependencies": {
31
- "@opencode-ai/plugin": "^1.18.4",
32
34
  "@types/node": "^26.1.1",
33
35
  "typescript": "^7.0.2"
34
36
  }