经 AI Skill Hub 精选评估,PLC代码审查 获评「强烈推荐」。这款Agent工作流在功能完整性、社区活跃度和易用性方面表现出色,AI 评分 8.5 分,适合有一定技术背景的用户使用。
自动化IEC 61131-3结构化文本代码审查
PLC代码审查 是一套完整的 AI Agent 自动化工作流方案。通过可视化的节点编排,将复杂的多步骤任务拆解为清晰的自动化流程,实现全程无人值守的智能处理。支持与数百种外部服务和 API 无缝集成,适合构建数据处理管线、业务自动化和 AI 辅助决策系统。
自动化IEC 61131-3结构化文本代码审查
PLC代码审查 是一套完整的 AI Agent 自动化工作流方案。通过可视化的节点编排,将复杂的多步骤任务拆解为清晰的自动化流程,实现全程无人值守的智能处理。支持与数百种外部服务和 API 无缝集成,适合构建数据处理管线、业务自动化和 AI 辅助决策系统。
# 方式一:npm 全局安装 npm install -g plc-st-review # 方式二:npx 直接运行(无需安装) npx plc-st-review --help # 方式三:项目依赖安装 npm install plc-st-review # 方式四:从源码运行 git clone https://github.com/HeytalePazguato/plc-st-review cd plc-st-review npm install npm start
# 命令行使用
plc-st-review --help
# 基本用法
plc-st-review [options] <input>
# Node.js 代码中使用
const plc_st_review = require('plc-st-review');
const result = await plc_st_review.run(options);
console.log(result);
# plc-st-review 配置说明 # 查看配置选项 plc-st-review --config-example > config.yml # 常见配置项 # output_dir: ./output # log_level: info # workers: 4 # 环境变量(覆盖配置文件) export PLC_ST_REVIEW_CONFIG="/path/to/config.yml"
A semantic linter, code reviewer, and team-style enforcer for IEC 61131-3 Structured Text, built for CI on PLC codebases that can't be compiled outside the vendor IDE. Parses .st files with the tree-sitter-iec61131-3-st grammar and reports semantic problems, not textual diffs.
plc-st-review runs in three modes, each backed by the same 80-check engine:
--lint src/**/*.st), run on every push. 59 single-revision checks for ST bugs: division by zero, out-of-range array indices, infinite loops, TON/CTU/R_TRIG misuse, output reads, unused vars, naming-convention drift, forbidden_symbols, the full PLCopen-aligned set (forbidden statements, IF without ELSE, direct-address use, pointer arithmetic, parameter/global caps, …), an IEC 62443 cybersecurity set (hard-coded credentials / endpoints, unvalidated input, debug pragmas, persistent plaintext secrets), and more.SAFETY_* constant changes, and metric regressions (complexity, nesting, LOC growth). With --project-scope it also flags newly added POUs that nothing in the repo calls..plc-st-review.yml in the repo root listing your naming_conventions (prefix / suffix / pattern per declaration kind) and forbidden_symbols. Both modes pick it up automatically.Catches the bugs reviewers miss on visual scan:
TON.PT changed from T#5s to T#500ms (10× faster).CASE on an enum that gained a value but no ELSE branch.SAFETY_ had its value changed.npm install
That's the whole setup. The parser ships as WebAssembly: web-tree-sitter boots the tree-sitter runtime and loads the grammar's tree-sitter-iec61131_3_st.wasm (published inside the tree-sitter-iec61131-3-st package). There's no native addon to compile, so no C++ toolchain, no node-gyp, and no platform-specific prerequisites — npm install runs the same on Windows, Linux, and macOS, on any supported Node version.
The repo ships one opinionated preset: presets/plcopen.yml, tuned to PLCopen Coding Guidelines v1.0. Vendor-neutral, standards-body-published — use it as your baseline if your team doesn't already have a style guide:
```yaml
Create .plc-st-review.yml at the repo root:
case_sensitive: false # identifier casing rules; see "Case sensitivity" below
disabled_checks:
- COMMENT_ONLY
severity_overrides:
TIMER_VALUE_CHANGED: error # all timer changes block merge
ignore_paths:
- "deprecated/**"
- "third_party/**"
safety_critical_prefixes:
- SAFETY_
- INTERLOCK_
- SIL_
reporting:
fail_on_severity: error # exit-nonzero threshold
comment_style: inline # inline | summary | both (GitLab/GitHub)
metrics: # bands for the metric-regression checks
thresholds:
cyclomatic_complexity:
warn: 15
error: 25
nesting_depth:
warn: 5
error: 8
parsing:
max_file_size_bytes: 1000000 # per-file size cap; see "Source-size cap" below
limits: # numeric caps for the size-/count-checking PLCopen rules
max_identifier_length: 32 # PLCopen N6 — drives IDENTIFIER_TOO_LONG (null = off)
max_globals_used_per_pou: 10 # PLCopen CP18 — drives TOO_MANY_GLOBALS_USED (null = off)
max_parameters: 8 # PLCopen CP23 — drives TOO_MANY_PARAMETERS (null = off)
identifier_charset: null # PLCopen N8 — regex every identifier must match; null = off
# e.g. '^[A-Za-z_][A-Za-z0-9_]*$' restricts to ASCII + underscore
The metrics block is optional; the values shown are the defaults. COMPLEXITY_INCREASED and NESTING_INCREASED read these bands; LOC_SPIKE fires on any single-PR growth over 50%. See docs/checks-reference.md for the full block (the lines_of_code, comment_ratio, and fan_out keys are accepted now and consumed by the upcoming standalone --metrics mode).
naming_conventions: bool: { prefix: b } # we use b, not PLCopen's x ```
The full rule-by-rule mapping (which PLCopen rules the preset enforces, which would need new checks, which are out of scope) is on the Pages site under Presets → PLCopen Coding Guidelines.
name: lint on: [push] jobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: npx plc-st-review --lint "src/**/*.st" ```
--lint accepts file paths, directories, or globs (*, **, mixed). It parses each .st file in isolation and runs the 59 single-revision checks: the 21 diff-based ones are auto-disabled because there's no "before" state. Exit code is non-zero when any finding meets reporting.fail_on_severity (default error), so the job fails the pipeline on real bugs.
| Category | Default severity | Trigger |
|---|---|---|
SIGNATURE_CHANGED | warn (error on breaking) | A POU's inputs/outputs/in-outs changed. |
CALL_SITE_OUTDATED | error | A caller doesn't pass a required argument the callee now requires, or passes an unknown argument. |
TYPE_MISMATCH | error | A VAR_GLOBAL's declared type changed between revisions. |
ENUM_VALUE_REMOVED | error | A CASE statement references an enum value that was removed. |
ENUM_VALUE_ADDED | warn | An enum gained a value but a CASE on the enum has no matching branch and no ELSE. |
TIMER_VALUE_CHANGED | info/warn/error by ratio | TON/TOF/TP PT changed; severity scales with the change magnitude (≥2× = warn, ≥10× = error). |
CONSTANT_VALUE_CHANGED | info (warn for safety-prefixed names) | A VAR_GLOBAL CONSTANT's initial value changed. Prefixes like SAFETY_, INTERLOCK_, SIL_ elevate severity. |
COMMENT_ONLY | info | The AST is structurally identical between revisions; only comments/whitespace changed. |
ARRAY_BOUNDS_CHANGED | error (shrink) / warn (grow) | An array declaration's [lower..upper] bounds changed. |
LOOP_BOUNDS_CHANGED | info/warn by ratio | A FOR loop's bounds changed; severity rises when the iteration count moves ≥10×. |
POU_DELETED | error (with callers) / warn | A POU was deleted; severity depends on whether call sites in the new revision still reference it. |
POU_RENAMED | info | Heuristic: a POU was deleted and another with an identical signature was added; suggests a rename. |
METHOD_ADDED_TO_INTERFACE | error | An INTERFACE gained a method but a FUNCTION_BLOCK that IMPLEMENTS it doesn't have one. |
INHERITANCE_CHANGED | warn | An EXTENDS clause was added, removed, or changed. |
PRAGMA_CHANGED | info | The set of pragmas in a file changed (added or removed). |
UNUSED_VAR_INTRODUCED | info | A new local variable was declared but isn't referenced in its scope. |
COUNTER_VALUE_CHANGED | info / warn / error by ratio | CTU/CTD/CTUD PV changed; severity scales with the change magnitude. |
COMPLEXITY_INCREASED | warn (error on crossing threshold) | A POU's cyclomatic complexity rose by more than 5, or crossed the configured error threshold. |
NESTING_INCREASED | warn (error on crossing threshold) | A POU's max control-structure nesting depth rose beyond the configured warn threshold. |
LOC_SPIKE | info | A POU's lines of code grew by more than 50% in a single PR. |
DEAD_POU_INTRODUCED | info | A newly added FUNCTION/FUNCTION_BLOCK that nothing in the project calls. Needs [--project-scope](docs/project-scope.md). |
高质量的自动化代码审查工具
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。
AI Skill Hub 点评:PLC代码审查 的核心功能完整,质量优秀。对于自动化工程师和运维人员来说,这是一个值得纳入个人工具库的选择。建议先在非生产环境试用,再逐步推广。
| 原始名称 | plc-st-review |
| Topics | 代码审查CITypeScriptIEC 61131-3 |
| GitHub | https://github.com/HeytalePazguato/plc-st-review |
| License | MIT |
| 语言 | TypeScript |
收录时间:2026-06-09 · 更新时间:2026-06-09 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。
选择 Agent 类型,复制安装指令后粘贴到对应客户端