From 76b7cf485abc6580fd5780864cd38431a019982b Mon Sep 17 00:00:00 2001 From: Karstein Phobic Nyvold Kvistad Date: Sat, 25 Apr 2026 22:59:25 +0200 Subject: [PATCH] feat(mirror_export): switch mirror file extension to .st Match the de-facto community convention. .st (IEC 61131-3 Structured Text) is what the existing PLC tooling around forge.codesys.com, ArthurkaX/cds-text-sync, and the VS Code "IEC Structured Text" extension already syntax-highlight by default. The previous .iecst was specific but unhelpful: nothing else in the toolchain knew what to do with it. User asked for the switch right after Phase 1 landed (commit 7a6e725). Re-ran the export against MRCodesysX33_0021 (X33) on disk: 91 files re-emitted as .st, identical content + tree shape, total 254 KB. --- src/scripts/mirror_export.py | 4 ++-- src/server.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/scripts/mirror_export.py b/src/scripts/mirror_export.py index d01e24b..5d44130 100644 --- a/src/scripts/mirror_export.py +++ b/src/scripts/mirror_export.py @@ -5,7 +5,7 @@ import sys, scriptengine as script_engine, os, traceback, time, codecs # # - Structural nodes (Device, Application, Folder, ...) become directories. # - Code-bearing nodes (Program, FB, Function, Method, Property, DUT, GVL, -# Interface, ...) become .iecst files in their parent directory. +# Interface, ...) become .st files in their parent directory. # - If a code-bearing node has child code objects (e.g. an FB with methods) # those children land in a sibling subdirectory with the parent's name. # - Filesystem-illegal characters in CODESYS object names are replaced with @@ -95,7 +95,7 @@ def write_one(parent_dir, name, decl, impl, project_path): if not os.path.exists(parent_dir): os.makedirs(parent_dir) kind = classify(decl) - fname = sanitise(name) + '.iecst' + fname = sanitise(name) + '.st' fpath = os.path.join(parent_dir, fname) lines = [] diff --git a/src/server.ts b/src/server.ts index a3e3321..02371a7 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1350,7 +1350,7 @@ export async function startMcpServer(config: ServerConfig): Promise { s.tool( 'mirror_export', - "Walks the CODESYS project tree and writes one .iecst file per code-bearing object into a filesystem mirror, preserving the project tree as nested directories. Programs / Function Blocks / Functions / Methods / Properties / DUTs / GVLs / Interfaces all become text files; structural nodes (Devices, Applications, Folders) become directories. Each file carries a header comment with its original CODESYS project path so a future write-back tool can map it back to set_pou_code's pouPath. Read-only -- does NOT modify the CODESYS project. UTF-8 output. If mirrorRoot is omitted, defaults to '/MCP/mirror'.", + "Walks the CODESYS project tree and writes one .st file per code-bearing object into a filesystem mirror, preserving the project tree as nested directories. Programs / Function Blocks / Functions / Methods / Properties / DUTs / GVLs / Interfaces all become text files; structural nodes (Devices, Applications, Folders) become directories. Each file carries a header comment with its original CODESYS project path so a future write-back tool can map it back to set_pou_code's pouPath. Read-only -- does NOT modify the CODESYS project. UTF-8 output. If mirrorRoot is omitted, defaults to '/MCP/mirror'.", { projectFilePath: z.string().describe("Path to the project file."), mirrorRoot: z.string().optional().describe("Filesystem path where the mirror tree gets written. If omitted, defaults to '/MCP/mirror'. Created automatically if missing; existing files at the same paths are overwritten."),