diff --git a/.opencode/agents/instruction.md b/.opencode/agents/instruction.md index f10d5b9..fe04ccd 100644 --- a/.opencode/agents/instruction.md +++ b/.opencode/agents/instruction.md @@ -31,7 +31,7 @@ Skills 树是**动态生长的**——工作流不是预置的,而是从实际 | 获取后端数据(数据源、推理、分析) | `tjwater_cli` | | 发现可用命令 | `tjwater_cli(command="help")` | | UI 操作 / 可视化 | `locate_features`、`view_scada`、`show_chart`、`render_junctions`、`view_history`、`apply_layer_style` | -| 持久化渲染数据 | `store_render_ref` → `render_junctions` | +| 持久化渲染数据 | ①准备 { node_area_map } JSON → ②`store_render_ref` 存为受控 ref → ③`render_junctions` 渲染到前端 | **前端工具仅做显示,不返回数据**,不要假设其返回内容。 diff --git a/.opencode/tools/render_junctions.ts b/.opencode/tools/render_junctions.ts index d141d77..49043f2 100644 --- a/.opencode/tools/render_junctions.ts +++ b/.opencode/tools/render_junctions.ts @@ -2,7 +2,7 @@ import { tool } from "@opencode-ai/plugin"; export default tool({ description: - "在前端地图上对 junctions 图层应用分区渲染。优先直接传入 render_ref(指向已持久化的渲染结果引用,格式应为 res-...),也不要先把 ref 内容完整读出再重组;前端会自行根据 render_ref 拉取完整 payload 并渲染,这样可以避免 LLM 读取大型 node_area_map。若当前只有本地 JSON 文件,请先调用 store_render_ref 把它迁移为受控 render_ref。供 render_ref 引用的 JSON 结构必须为 { node_area_map: Record, area_ids?: string[], area_colors?: Record },其中 node_area_map 的 key 是 junction/node id,value 是 area id。", + "在前端地图上对 junctions 图层应用分区渲染。使用前必须完成两步:① 准备数据结构(JSON 文件,结构为 { node_area_map: Record, area_ids?: string[], area_colors?: Record },其中 node_area_map 的 key 是 junction/node id,value 是 area id);② 调用 store_render_ref 将 JSON 文件存储到受控路径,获取 render_ref(格式为 res-...);③ 将 render_ref 传入本工具完成前端渲染。注意:不要先把 ref 内容完整读出再传给前端,也不要直接传本地文件路径。", args: { reason: tool.schema .string() @@ -12,7 +12,7 @@ export default tool({ render_ref: tool.schema .string() .describe( - "渲染引用 ID。必须是持久化结果引用(res-...)。前端会按该引用读取完整 payload.data 并渲染。render_ref 对应的数据结构必须是 { node_area_map: { [junctionId]: areaId }, area_ids?: string[], area_colors?: { [areaId]: color } };node_area_map 必填,area_ids / area_colors 可选。", + "上一步通过 store_render_ref 获得的渲染引用 ID(res-...)。前端会按该引用拉取完整 payload 并渲染。不可直接传入本地文件路径或完整 JSON 数据。", ), }, async execute() { diff --git a/.opencode/tools/store_render_ref.ts b/.opencode/tools/store_render_ref.ts index d1ba141..e9fab74 100644 --- a/.opencode/tools/store_render_ref.ts +++ b/.opencode/tools/store_render_ref.ts @@ -6,17 +6,17 @@ const internalToken = process.env.TJWATER_AGENT_INTERNAL_TOKEN ?? ""; export default tool({ description: - "把本地 JSON 渲染文件迁移成受控的 render_ref。仅适用于需要通过链接引用传递的大型 junction render payload。", + "将本地 JSON 渲染数据文件存储到受控路径,返回可供 render_junctions 使用的 render_ref(res-...)。前置步骤:先准备好符合 render_junctions 数据结构的 JSON 文件 { node_area_map, area_ids?, area_colors? },写入本地路径后再调用本工具传入该路径,获取 render_ref 后传给 render_junctions 完成前端渲染。", args: { reason: tool.schema .string() .describe( - "Why this local render payload should be persisted as a render_ref.", + "为何需要将此本地渲染数据持久化为 render_ref,以便后续通过 render_junctions 渲染到前端。", ), file_path: tool.schema .string() .describe( - "Absolute path to a local JSON file containing the raw render payload, or a wrapper object with data, metadata, and location. If wrapper metadata/location is missing or stale, the resolver will normalize and write it back before storing the render_ref.", + "本地 JSON 文件的绝对路径,内容为 render_junctions 所需的数据结构 { node_area_map, area_ids?, area_colors? }。", ), }, async execute(args, context) {