init
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
---
|
||||
description: TJWater default assistant for water-network analysis and operator workflows
|
||||
mode: primary
|
||||
model: anthropic/claude-sonnet-4-5
|
||||
temperature: 0.2
|
||||
---
|
||||
You are the default TJWater assistant running on opencode.
|
||||
|
||||
Operate with these rules:
|
||||
|
||||
1. Follow the loaded TJWater instructions, skills index, runbook, and examples as the primary domain guidance.
|
||||
2. Prefer `dynamic_http_call` when you need backend data for reasoning, summaries, diagnosis, or analysis.
|
||||
3. Prefer frontend tools (`locate_features`, `view_history`, `view_scada`, `show_chart`) when the user mainly needs UI actions or visualization.
|
||||
4. Treat frontend tools as display/interaction tools only. Do not assume they return data.
|
||||
5. Keep replies accurate, concise, and operationally useful for water-network users.
|
||||
6. Respect user authorization and project isolation. Never invent backend results when a tool call fails or no data is available.
|
||||
@@ -0,0 +1,41 @@
|
||||
import { tool } from "@opencode-ai/plugin";
|
||||
|
||||
const internalBaseUrl = process.env.TJWATER_AGENT_INTERNAL_BASE_URL ?? "http://127.0.0.1:8788";
|
||||
const internalToken = process.env.TJWATER_AGENT_INTERNAL_TOKEN ?? "";
|
||||
|
||||
export default tool({
|
||||
description:
|
||||
"Call the TJWater backend API through the local agent bridge. Provide path, optional method, and query arguments.",
|
||||
args: {
|
||||
path: tool.schema.string().describe("Target backend API path, starting with '/'."),
|
||||
method: tool.schema
|
||||
.string()
|
||||
.optional()
|
||||
.describe("HTTP method. Defaults to GET."),
|
||||
arguments: tool.schema
|
||||
.record(tool.schema.string(), tool.schema.unknown())
|
||||
.optional()
|
||||
.describe("Query arguments object."),
|
||||
},
|
||||
async execute(args, context) {
|
||||
const response = await fetch(`${internalBaseUrl}/internal/tools/dynamic-http-call`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-agent-internal-token": internalToken,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
sessionId: context.sessionID,
|
||||
path: args.path,
|
||||
method: args.method,
|
||||
arguments: args.arguments,
|
||||
}),
|
||||
});
|
||||
|
||||
const text = await response.text();
|
||||
if (!response.ok) {
|
||||
throw new Error(text);
|
||||
}
|
||||
return text;
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
import { tool } from "@opencode-ai/plugin";
|
||||
|
||||
export default tool({
|
||||
description: "Locate and highlight TJWater map features in the frontend.",
|
||||
args: {
|
||||
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."),
|
||||
},
|
||||
async execute() {
|
||||
return "已在地图上定位到指定要素。";
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
import { tool } from "@opencode-ai/plugin";
|
||||
|
||||
export default tool({
|
||||
description: "Render a chart in the frontend chat UI.",
|
||||
args: {
|
||||
title: tool.schema.string().optional().describe("Chart title."),
|
||||
chart_type: tool.schema
|
||||
.enum(["line", "bar", "pie"])
|
||||
.optional()
|
||||
.describe("Chart type."),
|
||||
x_data: tool.schema.array(tool.schema.string()).describe("X-axis labels."),
|
||||
series: tool.schema
|
||||
.array(
|
||||
tool.schema.object({
|
||||
name: tool.schema.string(),
|
||||
data: tool.schema.array(tool.schema.number()),
|
||||
type: tool.schema.enum(["line", "bar"]).optional(),
|
||||
}),
|
||||
)
|
||||
.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."),
|
||||
},
|
||||
async execute() {
|
||||
return "图表将在对话中显示。";
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
import { tool } from "@opencode-ai/plugin";
|
||||
|
||||
export default tool({
|
||||
description: "Open the frontend history panel for selected features.",
|
||||
args: {
|
||||
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."),
|
||||
},
|
||||
async execute() {
|
||||
return "已打开计算结果面板。";
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
import { tool } from "@opencode-ai/plugin";
|
||||
|
||||
export default tool({
|
||||
description: "Open the frontend SCADA history panel.",
|
||||
args: {
|
||||
device_ids: tool.schema
|
||||
.array(tool.schema.string())
|
||||
.optional()
|
||||
.describe("Preferred SCADA device ids."),
|
||||
device_id: tool.schema.string().optional().describe("Single SCADA device id."),
|
||||
feature_infos: tool.schema
|
||||
.array(tool.schema.tuple([tool.schema.string(), tool.schema.string()]))
|
||||
.optional()
|
||||
.describe("Legacy [id, type] pairs."),
|
||||
start_time: tool.schema.string().optional().describe("Optional ISO8601 start time."),
|
||||
end_time: tool.schema.string().optional().describe("Optional ISO8601 end time."),
|
||||
},
|
||||
async execute() {
|
||||
return "已打开 SCADA 监测面板。";
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"types": ["node"]
|
||||
},
|
||||
"include": ["tools/**/*.ts", "plugins/**/*.ts"]
|
||||
}
|
||||
Reference in New Issue
Block a user