From 20329bb771dbff1d99f128d39ef5fa07fb6e4397 Mon Sep 17 00:00:00 2001 From: Huarch Date: Fri, 29 May 2026 10:28:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=BA=94=E7=94=A8=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .opencode/tools/apply_layer_style.ts | 74 ++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 .opencode/tools/apply_layer_style.ts diff --git a/.opencode/tools/apply_layer_style.ts b/.opencode/tools/apply_layer_style.ts new file mode 100644 index 0000000..6bc20d9 --- /dev/null +++ b/.opencode/tools/apply_layer_style.ts @@ -0,0 +1,74 @@ +import { tool } from "@opencode-ai/plugin"; + +export default tool({ + description: + "在前端地图上对节点或管道图层应用样式,或重置为默认样式。样式参数应尽量与前端样式编辑器字段保持一致。", + args: { + reason: tool.schema + .string() + .describe("Why this style action is needed for the current user request."), + layer_id: tool.schema + .enum(["junctions", "pipes"]) + .describe("Target layer id. Must be exactly 'junctions' or 'pipes'."), + reset_to_default: tool.schema + .boolean() + .optional() + .describe("Whether to reset the target layer to its default style."), + style_config: tool.schema + .object({ + property: tool.schema.string().optional().describe("Data property to render."), + classification_method: tool.schema + .enum(["pretty_breaks", "custom_breaks"]) + .optional() + .describe("Classification method."), + segments: tool.schema.number().optional().describe("Number of segments."), + min_size: tool.schema.number().optional().describe("Minimum point radius."), + max_size: tool.schema.number().optional().describe("Maximum point radius."), + min_stroke_width: tool.schema + .number() + .optional() + .describe("Minimum line width."), + max_stroke_width: tool.schema + .number() + .optional() + .describe("Maximum line width."), + fixed_stroke_width: tool.schema + .number() + .optional() + .describe("Fixed line width when width is not data-driven."), + color_type: tool.schema + .enum(["single", "gradient", "rainbow", "custom"]) + .optional() + .describe("Color strategy."), + single_palette_index: tool.schema.number().optional(), + gradient_palette_index: tool.schema.number().optional(), + rainbow_palette_index: tool.schema.number().optional(), + show_labels: tool.schema.boolean().optional().describe("Whether to show labels."), + show_id: tool.schema.boolean().optional().describe("Whether to show ids."), + opacity: tool.schema.number().optional().describe("Opacity in [0, 1]."), + adjust_width_by_property: tool.schema + .boolean() + .optional() + .describe("Whether line width is driven by the rendered property."), + custom_breaks: tool.schema + .array(tool.schema.number()) + .optional() + .describe("Custom break values."), + custom_colors: tool.schema + .array(tool.schema.string()) + .optional() + .describe("Custom rgba colors."), + }) + .optional() + .describe( + "Optional style config overrides. Omit when reset_to_default is true.", + ), + }, + async execute(args) { + const layerLabel = args.layer_id === "junctions" ? "节点" : "管道"; + if (args.reset_to_default) { + return `已将${layerLabel}图层重置为默认样式。`; + } + return `已对${layerLabel}图层应用样式。`; + }, +});