opencode-dashscope-imagegen 0.1.0 → 0.1.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 WhiteBite
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,52 +1,94 @@
1
1
  # opencode-dashscope-imagegen
2
2
 
3
- [OpenCode](https://opencode.ai) plugin: text-to-image generation via **Alibaba DashScope**
4
- (`qwen-image-2.0`, `qwen-image-3.0`, `wan2.7-image` and compatible models).
5
- Adds an `image_generate` tool that saves the PNG to disk and returns its path.
3
+ > Text-to-image generation for [OpenCode](https://opencode.ai) via **Alibaba DashScope**
4
+ > `qwen-image-2.0`, `qwen-image-3.0` and `wan2.7-image` exposed as an `image_generate` tool
5
+ > your coding agent can call.
6
6
 
7
- ## Install
7
+ [![npm version](https://img.shields.io/npm/v/opencode-dashscope-imagegen)](https://www.npmjs.com/package/opencode-dashscope-imagegen)
8
+ [![npm downloads](https://img.shields.io/npm/dm/opencode-dashscope-imagegen)](https://www.npmjs.com/package/opencode-dashscope-imagegen)
9
+ [![license](https://img.shields.io/npm/l/opencode-dashscope-imagegen)](LICENSE)
10
+ [![OpenCode plugin](https://img.shields.io/badge/OpenCode-plugin-4f46e5)](https://opencode.ai/docs/plugins/)
8
11
 
9
- Add to your `opencode.json` (local path or npm spec once published):
12
+ ![Example output: generated with qwen-image-2.0](docs/example.png)
13
+
14
+ ## Highlights
15
+
16
+ - Adds a single `image_generate` tool to any OpenCode agent — no extra server, no MCP setup.
17
+ - Uses the native DashScope multimodal-generation endpoint (the OpenAI-compatible
18
+ `/v1/images/generations` route is not served by DashScope).
19
+ - Saves the PNG to disk and returns the absolute path, so vision models
20
+ (`qwen3-vl-plus`, `kimi-k3`, …) can inspect the result via normal image attachments.
21
+ - Works with any DashScope text-to-image model, including the Wan series (`wan2.7-image`).
22
+
23
+ ## Supported models
24
+
25
+ | Model | Notes |
26
+ |-------|-------|
27
+ | `qwen-image-2.0` (default) | fast general-purpose text-to-image |
28
+ | `qwen-image-3.0` | newer Qwen-Image generation |
29
+ | `wan2.7-image` | Wan (Tongyi Wanxiang) image models |
30
+
31
+ ## Prerequisites
32
+
33
+ - [OpenCode](https://opencode.ai) installed.
34
+ - A DashScope API key from [Alibaba Cloud Model Studio](https://dashscope.console.aliyun.com/)
35
+ (Bailian console). Key resolution order:
36
+ 1. `DASHSCOPE_IMAGEGEN_API_KEY` env
37
+ 2. `DASHSCOPE_API_KEY` env
38
+ 3. `apiKey` of any `dashscope*` provider in your `opencode.json`
39
+
40
+ ## Installation
41
+
42
+ Add the npm package name to your `opencode.json` — OpenCode installs it on next launch:
10
43
 
11
44
  ```json
12
45
  {
13
- "plugin": ["D:/Sources/WhiteBite/opencode-dashscope-imagegen/src/index.ts"]
46
+ "plugin": ["opencode-dashscope-imagegen"]
14
47
  }
15
48
  ```
16
49
 
17
- When referencing the plugin by **local path**, run `npm install` inside this repo once —
18
- the plugin imports `@opencode-ai/plugin`, which must resolve from the plugin's own
19
- directory (OpenCode does not provide it for out-of-tree plugins).
50
+ ### Developing locally
20
51
 
21
- ## Auth
52
+ To run from a checkout instead of npm, reference the plugin directory and install its
53
+ dependencies once (`@opencode-ai/plugin` must resolve from the plugin's own directory):
22
54
 
23
- Key resolution order:
55
+ ```json
56
+ {
57
+ "plugin": ["file:///path/to/opencode-dashscope-imagegen"]
58
+ }
59
+ ```
24
60
 
25
- 1. `DASHSCOPE_IMAGEGEN_API_KEY` env
26
- 2. `DASHSCOPE_API_KEY` env
27
- 3. `apiKey` of any `dashscope*` provider in your `opencode.json`
61
+ ```bash
62
+ npm install
63
+ npm run build # tsc dist/ (js + d.ts)
64
+ ```
28
65
 
29
66
  ## Usage
30
67
 
31
- The agent gets a tool:
68
+ Just ask your agent: *"generate an image of a lighthouse at dusk"* — it will call the tool:
32
69
 
33
70
  | Arg | Default | Description |
34
71
  |-----|---------|-------------|
35
72
  | `prompt` | required | image description |
36
- | `model` | `qwen-image-2.0` | any DashScope text2image model |
37
- | `size` | `1024*1024` | `W*H` (star, not `x`) |
38
- | `output_path` | auto | absolute path; default `~/.config/opencode/gen-images/gen-<ts>.png` |
73
+ | `model` | `qwen-image-2.0` | any DashScope text-to-image model |
74
+ | `size` | `1024*1024` | `W*H` with a star, e.g. `1280*720` |
75
+ | `output_path` | auto | absolute path; default `<config>/gen-images/gen-<ts>.png` |
76
+
77
+ Output directory override: `DASHSCOPE_IMAGEGEN_DIR` env.
78
+
79
+ ## Troubleshooting
39
80
 
40
- Output dir override: `DASHSCOPE_IMAGEGEN_DIR` env.
81
+ - **`InvalidApiKey` / 401** — no key found; check the resolution order above.
82
+ - **Tool not appearing** — restart OpenCode after editing `opencode.json`; plugins load at startup.
83
+ - **`size` rejected** — use `W*H` with `*` (star), not `x`: `1024*1024`.
84
+ - **Model not supported** — the key's account must have the model enabled in Model Studio.
41
85
 
42
- ## Notes
86
+ ## Related
43
87
 
44
- - Uses the native DashScope endpoint
45
- `POST /api/v1/services/aigc/multimodal-generation/generation`
46
- (the OpenAI-compatible `/v1/images/generations` is not served by DashScope).
47
- - Vision models (kimi-k3, qwen3.8-max, qwen-vl-*) can then inspect the saved PNG
48
- via normal image attachments.
88
+ - [OpenCode plugin docs](https://opencode.ai/docs/plugins/)
89
+ - [OpenCode ecosystem](https://opencode.ai/docs/ecosystem/)
90
+ - [awesome-opencode](https://github.com/awesome-opencode/awesome-opencode)
49
91
 
50
92
  ## License
51
93
 
52
- MIT
94
+ [MIT](LICENSE)
@@ -0,0 +1,2 @@
1
+ import type { Plugin } from "@opencode-ai/plugin";
2
+ export declare const DashscopeImagegenPlugin: Plugin;