In CODESYS v3, code lives inside the project — a binary file. AI cannot open or edit it.
In the AI era we need a way for AI to operate on the files inside the project.
Goal
Close the loop: project ⇄ text ⇄ AI.
Export POUs to text, let the AI edit them, import them back into the project.
Constraints
- CODESYS must stay the source of truth for the project structure
- Import must not corrupt an existing project
- Prefer a small, scriptable tool over a heavy IDE plugin
Approach
- Export selected POUs (declaration + implementation) to plain text files
- Edit the text (AI or human)
- Import: backup, compare, write back, save
Creating or deleting POUs is not supported in this pass — only updating existing ones.
Import pipeline
Import does four things before touching the live project:
- Backup — snapshot first
- Compare — diff bodies
- Write back — set POU code
- Save — persist the project
Notes
- Update only: creating or deleting POUs is not supported in this version
- Declarations and implementations are paired per POU
- After import, rebuild in CODESYS to verify
Repository and tooling details follow the same codesys-sync / codesys-connect series used elsewhere on this blog.



Top comments (1)
One test for the stale-export warning: on a disposable project, export a POU and leave the exported text untouched. Add a code comment to that POU's declaration in the IDE, save and close the project, then import the old export. The linked importer writes back when the texts differ, so even that untouched export can overwrite the newer edit. I'd assert that the import flags the stale export and the comment survives.