From 26e9941b70ee8cf007db63dd5886268980385506 Mon Sep 17 00:00:00 2001 From: Karstein Phobic Nyvold Kvistad Date: Wed, 29 Apr 2026 19:25:58 +0200 Subject: [PATCH] feat: enable --approve-edits gate by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modifying MCP tools (set_pou_code, create_pou, rename, delete, etc.) now route through the phobiCS-tui y/n diff gate by default. The CLI flag flips form: --approve-edits → --no-approve-edits (opt-out). Bumps to 0.9.2. Why: gating writes-by-default makes set_pou_code/create_pou changes auditable in the TUI before they hit the binary .project file. Existing configs passing --approve-edits explicitly continue to work (commander accepts both forms when option is defined as --no-X); configs that want the old ungated behavior add --no-approve-edits. --- package.json | 2 +- src/bin.ts | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index c8453a1..9bed2f5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codesys-mcp-sp21-plus", - "version": "0.9.1", + "version": "0.9.2", "description": "Codesys-MCP-SP21+ -- fork of luke-harriman/Codesys-MCP carrying CODESYS V3.5 SP22 Patch 1 fixes (and forward-compat with later SPs): script-engine API drift, online/runtime tool auto-login, dual-SHA release classifier, set_pou_code omitted-decl wipe fix, add_library managed-overload, etc. MCP server for CODESYS with persistent UI instance and file-based IPC.", "main": "dist/server.js", "bin": { diff --git a/src/bin.ts b/src/bin.ts index c39b8e7..6d58da2 100644 --- a/src/bin.ts +++ b/src/bin.ts @@ -57,7 +57,7 @@ program .option('--fallback-headless', 'Fall back to headless if persistent fails', true) .option('--keep-alive', 'Keep CODESYS running after server stops', false) .option('--auto-mirror', 'Re-run mirror_export after every modifying tool so an external editor watching /mcp-mirror/ sees changes live', false) - .option('--approve-edits', 'Gate modifying MCP tools behind a phobiCS-tui y/n diff prompt', false) + .option('--no-approve-edits', 'Disable the phobiCS-tui y/n diff gate on modifying tools (default: gate ENABLED)') .option('--live-values', 'Pump runtime values for the selected POU into tui-live-values.json so phobiCS-tui can overlay them inline. Requires the runtime to be online; failures are silent.', false) .option('--live-values-interval ', 'Poll interval for --live-values in ms. Default 500. Clamped to [100, 60000].', '500') .option('--timeout ', 'Default command timeout in ms', '60000') @@ -210,7 +210,7 @@ if (opts.sshVersion) { debug: opts.debug || false, mode: (opts.mode === 'headless' ? 'headless' : 'persistent') as ExecutionMode, autoMirror: opts.autoMirror || false, - approveEdits: opts.approveEdits || false, + approveEdits: opts.approveEdits !== false, liveValues: opts.liveValues || false, liveValuesIntervalMs: clampInterval(opts.liveValuesInterval), }; @@ -223,9 +223,7 @@ if (opts.sshVersion) { if (config.autoMirror) { process.stderr.write(` Auto-mirror: ENABLED (mirror_export runs after every edit)\n`); } - if (config.approveEdits) { - process.stderr.write(` Approve edits: ENABLED (modifying tools will prompt via phobiCS-tui)\n`); - } + process.stderr.write(` Approve edits: ${config.approveEdits ? 'ENABLED (modifying tools will prompt via phobiCS-tui)' : 'disabled'}\n`); if (config.liveValues) { process.stderr.write(` Live values: ENABLED (poll ${config.liveValuesIntervalMs ?? 500}ms; writes tui-live-values.json)\n`); }