From ba46258845aacbcc3b4799d3062edb62eeb8c871 Mon Sep 17 00:00:00 2001 From: Huarch Date: Sun, 7 Jun 2026 17:08:17 +0800 Subject: [PATCH] style(opencode): format tool definitions --- .opencode/tools/apply_layer_style.ts | 34 ++++++++++++++++++++++------ .opencode/tools/locate_features.ts | 8 +++++-- .opencode/tools/render_junctions.ts | 4 +++- .opencode/tools/session_search.ts | 25 +++++++++++--------- .opencode/tools/show_chart.ts | 10 ++++++-- .opencode/tools/store_render_ref.ts | 30 ++++++++++++++---------- .opencode/tools/tjwater_cli.ts | 30 +++++++++++++----------- .opencode/tools/view_history.ts | 14 +++++++++--- .opencode/tools/view_scada.ts | 15 +++++++++--- 9 files changed, 116 insertions(+), 54 deletions(-) diff --git a/.opencode/tools/apply_layer_style.ts b/.opencode/tools/apply_layer_style.ts index 6bc20d9..39fbd16 100644 --- a/.opencode/tools/apply_layer_style.ts +++ b/.opencode/tools/apply_layer_style.ts @@ -6,7 +6,9 @@ export default tool({ args: { reason: tool.schema .string() - .describe("Why this style action is needed for the current user request."), + .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'."), @@ -16,14 +18,26 @@ export default tool({ .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."), + 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."), + 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() @@ -43,8 +57,14 @@ export default tool({ 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."), + 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() diff --git a/.opencode/tools/locate_features.ts b/.opencode/tools/locate_features.ts index 0290b9a..1ff3b49 100644 --- a/.opencode/tools/locate_features.ts +++ b/.opencode/tools/locate_features.ts @@ -5,8 +5,12 @@ export default tool({ args: { reason: tool.schema .string() - .describe("Why this map positioning action is needed for the user request."), - ids: tool.schema.array(tool.schema.string()).describe("Feature ids to locate."), + .describe( + "Why this map positioning action is needed for the user request.", + ), + ids: tool.schema + .array(tool.schema.string()) + .describe("Feature ids to locate."), feature_type: tool.schema .enum(["junction", "pipe", "valve", "reservoir", "pump", "tank"]) .describe("Type of feature to locate."), diff --git a/.opencode/tools/render_junctions.ts b/.opencode/tools/render_junctions.ts index b92792f..d141d77 100644 --- a/.opencode/tools/render_junctions.ts +++ b/.opencode/tools/render_junctions.ts @@ -6,7 +6,9 @@ export default tool({ args: { reason: tool.schema .string() - .describe("Why this junction rendering action is needed for the user request."), + .describe( + "Why this junction rendering action is needed for the user request.", + ), render_ref: tool.schema .string() .describe( diff --git a/.opencode/tools/session_search.ts b/.opencode/tools/session_search.ts index f3b3b42..50dcea9 100644 --- a/.opencode/tools/session_search.ts +++ b/.opencode/tools/session_search.ts @@ -22,18 +22,21 @@ export default tool({ .describe("Optional maximum number of hits to return."), }, async execute(args, context) { - const response = await fetch(`${internalBaseUrl}/internal/tools/session-search`, { - method: "POST", - headers: { - "Content-Type": "application/json", - "x-agent-internal-token": internalToken, + const response = await fetch( + `${internalBaseUrl}/internal/tools/session-search`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + "x-agent-internal-token": internalToken, + }, + body: JSON.stringify({ + max_results: args.max_results, + query: args.query, + session_id: context.sessionID, + }), }, - body: JSON.stringify({ - max_results: args.max_results, - query: args.query, - session_id: context.sessionID, - }), - }); + ); const text = await response.text(); if (!response.ok) { throw new Error(text); diff --git a/.opencode/tools/show_chart.ts b/.opencode/tools/show_chart.ts index a8e3423..e17503e 100644 --- a/.opencode/tools/show_chart.ts +++ b/.opencode/tools/show_chart.ts @@ -21,8 +21,14 @@ export default tool({ }), ) .describe("Series data."), - x_axis_name: tool.schema.string().optional().describe("X-axis display name."), - y_axis_name: tool.schema.string().optional().describe("Y-axis display name."), + x_axis_name: tool.schema + .string() + .optional() + .describe("X-axis display name."), + y_axis_name: tool.schema + .string() + .optional() + .describe("Y-axis display name."), }, async execute() { // 图表数据已经在工具参数里,前端收到 tool_call 后直接渲染,不再二次请求后端。 diff --git a/.opencode/tools/store_render_ref.ts b/.opencode/tools/store_render_ref.ts index ddf2767..d1ba141 100644 --- a/.opencode/tools/store_render_ref.ts +++ b/.opencode/tools/store_render_ref.ts @@ -1,6 +1,7 @@ import { tool } from "@opencode-ai/plugin"; -const internalBaseUrl = process.env.TJWATER_AGENT_INTERNAL_BASE_URL ?? "http://127.0.0.1:8787"; +const internalBaseUrl = + process.env.TJWATER_AGENT_INTERNAL_BASE_URL ?? "http://127.0.0.1:8787"; const internalToken = process.env.TJWATER_AGENT_INTERNAL_TOKEN ?? ""; export default tool({ @@ -9,7 +10,9 @@ export default tool({ args: { reason: tool.schema .string() - .describe("Why this local render payload should be persisted as a render_ref."), + .describe( + "Why this local render payload should be persisted as a render_ref.", + ), file_path: tool.schema .string() .describe( @@ -17,17 +20,20 @@ export default tool({ ), }, async execute(args, context) { - const response = await fetch(`${internalBaseUrl}/internal/tools/store-render-ref`, { - method: "POST", - headers: { - "Content-Type": "application/json", - "x-agent-internal-token": internalToken, + const response = await fetch( + `${internalBaseUrl}/internal/tools/store-render-ref`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + "x-agent-internal-token": internalToken, + }, + body: JSON.stringify({ + session_id: context.sessionID, + file_path: args.file_path, + }), }, - body: JSON.stringify({ - session_id: context.sessionID, - file_path: args.file_path, - }), - }); + ); const text = await response.text(); if (!response.ok) { diff --git a/.opencode/tools/tjwater_cli.ts b/.opencode/tools/tjwater_cli.ts index f0af482..e72a0f6 100644 --- a/.opencode/tools/tjwater_cli.ts +++ b/.opencode/tools/tjwater_cli.ts @@ -1,6 +1,7 @@ import { tool } from "@opencode-ai/plugin"; -const internalBaseUrl = process.env.TJWATER_AGENT_INTERNAL_BASE_URL ?? "http://127.0.0.1:8787"; +const internalBaseUrl = + process.env.TJWATER_AGENT_INTERNAL_BASE_URL ?? "http://127.0.0.1:8787"; const internalToken = process.env.TJWATER_AGENT_INTERNAL_TOKEN ?? ""; export default tool({ @@ -21,19 +22,22 @@ export default tool({ .describe("超时秒数,默认 120。大结果集建议设 300+。"), }, async execute(args, context) { - const response = await fetch(`${internalBaseUrl}/internal/tools/tjwater-cli-call`, { - method: "POST", - headers: { - "Content-Type": "application/json", - "x-agent-internal-token": internalToken, + const response = await fetch( + `${internalBaseUrl}/internal/tools/tjwater-cli-call`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + "x-agent-internal-token": internalToken, + }, + body: JSON.stringify({ + session_id: context.sessionID, + reason: args.reason, + command: args.command, + timeout: args.timeout, + }), }, - body: JSON.stringify({ - session_id: context.sessionID, - reason: args.reason, - command: args.command, - timeout: args.timeout, - }), - }); + ); const text = await response.text(); if (!response.ok) { diff --git a/.opencode/tools/view_history.ts b/.opencode/tools/view_history.ts index 9d4f07f..29c68a9 100644 --- a/.opencode/tools/view_history.ts +++ b/.opencode/tools/view_history.ts @@ -5,15 +5,23 @@ export default tool({ args: { reason: tool.schema .string() - .describe("Why this history panel should be opened for the current task."), + .describe( + "Why this history panel should be opened for the current task.", + ), feature_infos: tool.schema .array(tool.schema.tuple([tool.schema.string(), tool.schema.string()])) .describe("List of [id, type] pairs."), data_type: tool.schema .enum(["realtime", "scheme", "none"]) .describe("History data source type."), - start_time: tool.schema.string().optional().describe("Optional ISO8601 start time."), - end_time: tool.schema.string().optional().describe("Optional ISO8601 end time."), + start_time: tool.schema + .string() + .optional() + .describe("Optional ISO8601 start time."), + end_time: tool.schema + .string() + .optional() + .describe("Optional ISO8601 end time."), }, async execute() { // 返回短确认即可;面板打开动作由前端根据 tool_call 参数完成。 diff --git a/.opencode/tools/view_scada.ts b/.opencode/tools/view_scada.ts index 904f363..ad05355 100644 --- a/.opencode/tools/view_scada.ts +++ b/.opencode/tools/view_scada.ts @@ -10,9 +10,18 @@ export default tool({ .array(tool.schema.string()) .optional() .describe("Preferred SCADA device ids."), - device_id: tool.schema.string().optional().describe("Single SCADA device id."), - start_time: tool.schema.string().optional().describe("Optional ISO8601 start time."), - end_time: tool.schema.string().optional().describe("Optional ISO8601 end time."), + device_id: tool.schema + .string() + .optional() + .describe("Single SCADA device id."), + start_time: tool.schema + .string() + .optional() + .describe("Optional ISO8601 start time."), + end_time: tool.schema + .string() + .optional() + .describe("Optional ISO8601 end time."), }, async execute() { // SCADA 面板仍在浏览器侧执行,工具结果不承载实际监测数据。