Files
bj_power/bj_power_mes/AGENTS.md
T

1.6 KiB
Raw Blame History

Project Instructions

This file provides context for AI assistants working on this project.

Project Type: Go

Commands

  • Build: go build
  • Test: go test ./...
  • Run: go run .
  • Format: go fmt ./...

Version Control

This project uses Git. See .gitignore for excluded files.

Guidelines

  • Follow existing code style and patterns
  • Write tests for new functionality
  • Keep changes focused and atomic
  • Document public APIs
  • 防御式编程: 所有函数返回 error 不许直接 _ 忽略,必须日志告警或向上抛出
  • 校验前置: 外部输入(接口参数、PLC 信号地址、配置值)在边界处做合法性校验,防止非法参数进入内部逻辑

Frontend Build

前端代码位于 frontend/ 目录,使用 Vite + React + TypeScript。

构建流程

  1. cd frontend && npm run build — 前端构建,输出到 frontend/dist/
  2. frontend/dist/* 复制到 public/public/.gitignore 中,不提交到 git
  3. go build — Go 通过 //go:embed publicpublic/ 嵌入二进制

构建脚本

  • macOS/Linux: ./build.sh
  • Windows: build.bat

注意事项

  • vite.config.ts 不得设置 build.outDir,保持 Vite 默认行为(输出到 dist/
  • public/ 是纯构建产物,不与 frontend/public/Vite 静态资源目录)混淆
  • 开发时前端通过 npm run dev 独立运行,Vite proxy 代理 API 请求到 Go 后端

Important Notes

  • 每次对话开始时,必须先读取 agent约束.md。该文件包含项目架构、代码规范、启动顺序、数据流等核心约束,是 AI 辅助开发的最高优先级参考文档。