0
0
Fork 0
Codesys-MCP-SP21-plus/src
phobicdotno 48fa83ccce
fix(create_project): correct prompt-suppression API + close project after swap (#12)
Two issues caught when Karstein noted suppression wasn't actually working:

1. Wrong API. The script was setting:
     script_engine.system.script_prompt_handling = ScriptPromptHandling.NoFlag
   but ScriptPromptHandling has no 'NoFlag' member (it's 'SuppressPrompts'),
   AND script_prompt_handling is a read-only property -- the settable one
   is the obsolete-but-still-functional 'prompt_handling' (with the
   obsolete PromptHandling enum, where PromptHandling.NONE = 0 is
   documented as equivalent to ScriptPromptHandling.SuppressPrompts).
   The bare AttributeError was silently swallowed by try/except so prompts
   stayed forwarded to UI -> intermittent code-1 crashes when the storage
   format dialog popped.
   Fix: set system.prompt_handling = PromptHandling.NONE, with int-literal
   fallback if the enum import doesn't resolve. Log when neither works.

2. After-swap stale state. Even after a successful update() that preserves
   the device subtree, CODESYS keeps the OLD device's library version
   pins in its in-memory project model. compile_project then errors with
     'Could not open library IoStandard, 3.1.3.1 (System)'
     'Device description for PLCWinNT is missing'
   Fix: project.close() at the end of create_project (drops in-memory
   state) + delete the precompilecache file. The next MCP tool call's
   ensure_project_open reopens fresh against the swapped XML and compile
   is clean.

Live verified on SP22 P1:
  - create_project WinV3Test deviceName='CODESYS Control Win V3 x64'
    -> succeeds, no UI dialog, project saved + closed.
  - compile_project (first call after creation) -> 0 errors, 0 warnings.
  - create_pou Application/FB_Counter + set_pou_code with real ST.
  - PLC_PRG references FB_Counter.
  - compile_project -> 0 errors, 0 warnings.

Co-authored-by: Karstein Phobic Nyvold Kvistad <karstein.kvistad@maritimerobotics.com>
2026-04-29 13:17:54 +02:00
..
scripts fix(create_project): correct prompt-suppression API + close project after swap (#12) 2026-04-29 13:17:54 +02:00
tui release: v0.8.0 -- phobiCS-tui v0.3 (inline live values) 2026-04-29 10:10:40 +02:00
approve-gate.ts feat(approve-gate): wire 9 modifying tools through phobiCS-tui 2026-04-29 08:22:09 +02:00
bin.ts feat(live-values): --live-values CLI flag + server pump wiring 2026-04-29 09:58:04 +02:00
detect.ts feat(open_project): pre-flight profile-mismatch check using offline .project inspection 2026-04-27 22:32:53 +02:00
headless.ts Initial release: MCP server for CODESYS with persistent UI instance 2026-02-08 18:59:16 +10:00
inspect.ts feat(cli): --inspect <project> reads CODESYS profile + mandatory libs offline (no CODESYS needed) 2026-04-27 21:47:31 +02:00
ipc.ts Initial release: MCP server for CODESYS with persistent UI instance 2026-02-08 18:59:16 +10:00
launcher.ts fix(launcher): only refuse double-spawn of the SAME --codesys-path 2026-04-27 20:57:59 +02:00
live-values-pump.ts feat(live-values): pump skeleton + VAR-block parser 2026-04-29 09:55:18 +02:00
live-values-write.ts feat(live-values): atomic writer for tui-live-values.json 2026-04-29 09:51:17 +02:00
logger.ts Initial release: MCP server for CODESYS with persistent UI instance 2026-02-08 18:59:16 +10:00
mirror-paths.ts fix(mirror): per-project mirror dir name when multiple .project files share a parent 2026-04-27 22:22:09 +02:00
preflight.ts feat(open_project): pre-flight profile-mismatch check using offline .project inspection 2026-04-27 22:32:53 +02:00
script-manager.ts fix(create_folder): try project.create_folder(name, SV_POU) first; drop ScriptManager cache 2026-04-26 17:16:44 +02:00
server.ts feat(create_project): optional deviceName arg swaps template default device (#8) 2026-04-29 10:17:10 +02:00
ssh-restart-runtime.ts feat(ssh): restart_runtime_ssh -- restart codesyscontrol over SSH (password auth + sudo -S + port-listen liveness probe) 2026-04-28 16:50:19 +02:00
ssh-version.ts feat(ssh): read_running_version_ssh -- read PLC project version over SSH, no CODESYS needed 2026-04-27 22:13:29 +02:00
state-read.ts feat(state): add CJS reader for phobiCS-tui state file 2026-04-28 22:26:15 +02:00
types.ts feat(live-values): --live-values CLI flag + server pump wiring 2026-04-29 09:58:04 +02:00