opencode-image 0.1.2 → 0.1.3
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/dist/index.js +8 -2
- package/dist/options.d.ts +3 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -295,6 +295,7 @@ function resolveOptions(options) {
|
|
|
295
295
|
serverPort: opts.serverPort ?? DEFAULT_SERVER_PORT,
|
|
296
296
|
serverIdleMs: opts.serverIdleMs ?? DEFAULT_SERVER_IDLE_MS,
|
|
297
297
|
updateCheck: opts.updateCheck ?? true,
|
|
298
|
+
injectPrompt: opts.injectPrompt ?? true,
|
|
298
299
|
cacheDir: opts.cacheDir ?? DEFAULT_CACHE_DIR,
|
|
299
300
|
cacheLimit: opts.cacheLimit ?? DEFAULT_CACHE_LIMIT,
|
|
300
301
|
timeoutMs: opts.timeoutMs ?? DEFAULT_TIMEOUT_MS
|
|
@@ -675,7 +676,7 @@ var OpenCodeImagePlugin = async (_input, rawOptions) => {
|
|
|
675
676
|
return {
|
|
676
677
|
tool: {
|
|
677
678
|
image_generate: tool({
|
|
678
|
-
description: "Generate
|
|
679
|
+
description: "Generate an image from a text prompt. This is the only supported way to create images in this session: " + "the endpoint and API key are already configured inside this plugin, so NEVER call the image API yourself " + "(no curl, no scripts) and never read the API key out of opencode.json. " + "The first line of the output is a Markdown image line (plus a separate 查看原图 link when displayMaxSize > 0); " + "you MUST copy those lines verbatim into your reply text, otherwise the user cannot see the picture. " + "If the output contains a line starting with [请转述给用户], relay that line to the user as well. " + "To refine a result, call image_edit with the returned path instead of generating a new image.",
|
|
679
680
|
args: {
|
|
680
681
|
prompt: z.string().describe("Detailed description of the image to generate"),
|
|
681
682
|
filename: z.string().optional().describe("Optional output file name or path; defaults to a timestamped name")
|
|
@@ -683,7 +684,7 @@ var OpenCodeImagePlugin = async (_input, rawOptions) => {
|
|
|
683
684
|
execute: generate
|
|
684
685
|
}),
|
|
685
686
|
image_edit: tool({
|
|
686
|
-
description: "Edit an existing image with a text instruction (image-to-image).
|
|
687
|
+
description: "Edit an existing image with a text instruction (image-to-image). Prefer this over generating a new image " + "when the user wants to adjust a picture: pass the exact path returned by a previous image_generate or " + "image_edit call to keep refining the same one. " + "Same rules: never call the image API yourself and never read the API key; copy the Markdown image line " + "(and the 查看原图 link, if present) from the output verbatim into your reply, and relay any line starting " + "with [请转述给用户].",
|
|
687
688
|
args: {
|
|
688
689
|
image: z.string().describe("Path to the source image, normally the file returned by image_generate/image_edit"),
|
|
689
690
|
prompt: z.string().describe("What to change, e.g. 'make the hat red, keep everything else identical'"),
|
|
@@ -726,6 +727,11 @@ var OpenCodeImagePlugin = async (_input, rawOptions) => {
|
|
|
726
727
|
}
|
|
727
728
|
})
|
|
728
729
|
},
|
|
730
|
+
"experimental.chat.system.transform": async (_input2, output) => {
|
|
731
|
+
if (!options.injectPrompt)
|
|
732
|
+
return;
|
|
733
|
+
output.system.push("Image generation/editing: always use the `image_generate` / `image_edit` tools provided by the " + "opencode-image plugin — the endpoint and API key are already configured there. Never call the image API " + "directly, never read the API key from config, and do not use the imagegen skill or its CLI. Copy the " + "Markdown image line from that tool's output verbatim into your reply so the user can see the picture.");
|
|
734
|
+
},
|
|
729
735
|
dispose: async () => {
|
|
730
736
|
server.stop();
|
|
731
737
|
}
|
package/dist/options.d.ts
CHANGED
|
@@ -30,6 +30,8 @@ export type PluginOptions = {
|
|
|
30
30
|
serverIdleMs?: number;
|
|
31
31
|
/** 首次出图时查一次 npm 最新版,落后则在工具输出末尾附升级提示。默认开启 */
|
|
32
32
|
updateCheck?: boolean;
|
|
33
|
+
/** 往系统提示里注入一条"用哪个工具生图"的规则。默认开启 */
|
|
34
|
+
injectPrompt?: boolean;
|
|
33
35
|
/** 对话里展示用的缩略图缓存目录,默认 <系统临时目录>/opencode-image */
|
|
34
36
|
cacheDir?: string;
|
|
35
37
|
/** 缩略图缓存最多保留多少个文件,超出按最久未访问淘汰;0 表示不限制 */
|
|
@@ -56,6 +58,7 @@ export type ResolvedOptions = {
|
|
|
56
58
|
serverPort: number;
|
|
57
59
|
serverIdleMs: number;
|
|
58
60
|
updateCheck: boolean;
|
|
61
|
+
injectPrompt: boolean;
|
|
59
62
|
cacheDir: string;
|
|
60
63
|
cacheLimit: number;
|
|
61
64
|
timeoutMs: number;
|