feat(cli): add --approve-edits flag (off by default; v0.1 plumbing)
Adds the user-facing --approve-edits surface area: - ServerConfig.approveEdits?: boolean - bin.ts: --approve-edits commander option, plumbs into config, emits 'Approve edits: ENABLED' banner when on - server.ts: logs 'Approve edits: ON|off' at startup v0.1 stops here. The actual gating wiring (set_pou_code -> phobiCS-tui approve, only proceed on exit 0) lands in the next commit. Landing the surface area now keeps the user-visible CLI stable while the internals catch up.
This commit is contained in:
parent
d6999c21bf
commit
67384a7dd7
3 changed files with 12 additions and 0 deletions
|
|
@ -47,6 +47,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 <projectDir>/mcp-mirror/ sees changes live', false)
|
||||
.option('--approve-edits', 'Gate modifying MCP tools behind a phobiCS-tui y/n diff prompt', false)
|
||||
.option('--timeout <ms>', 'Default command timeout in ms', '60000')
|
||||
.option('--verbose', 'Enable verbose logging')
|
||||
.option('--debug', 'Enable debug logging (more verbose)')
|
||||
|
|
@ -197,6 +198,7 @@ if (opts.sshVersion) {
|
|||
debug: opts.debug || false,
|
||||
mode: (opts.mode === 'headless' ? 'headless' : 'persistent') as ExecutionMode,
|
||||
autoMirror: opts.autoMirror || false,
|
||||
approveEdits: opts.approveEdits || false,
|
||||
};
|
||||
|
||||
process.stderr.write(`Starting CODESYS MCP Server v${version}\n`);
|
||||
|
|
@ -207,6 +209,9 @@ 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`);
|
||||
}
|
||||
|
||||
startMcpServer(config).catch((err) => {
|
||||
process.stderr.write(`FATAL: ${err.message}\n`);
|
||||
|
|
|
|||
|
|
@ -726,6 +726,7 @@ export async function startMcpServer(config: ServerConfig): Promise<void> {
|
|||
|
||||
serverLog.info(`Starting CODESYS Persistent MCP Server v0.1.0`);
|
||||
serverLog.info(`Mode: ${config.mode}`);
|
||||
serverLog.info(`Approve edits: ${config.approveEdits ? 'ON' : 'off'}`);
|
||||
serverLog.info(`CODESYS Path: ${config.codesysPath}`);
|
||||
serverLog.info(`Profile: ${config.profileName}`);
|
||||
serverLog.info(`Workspace: ${config.workspaceDir}`);
|
||||
|
|
|
|||
|
|
@ -67,6 +67,12 @@ export interface ServerConfig extends LauncherConfig {
|
|||
* as a hard error -- the underlying edit already succeeded.
|
||||
*/
|
||||
autoMirror: boolean;
|
||||
/**
|
||||
* If true, modifying tools (set_pou_code et al.) will shell out to
|
||||
* phobiCS-tui in approve mode and only proceed on exit 0. Off by default
|
||||
* so existing scripted flows are not regressed.
|
||||
*/
|
||||
approveEdits?: boolean;
|
||||
}
|
||||
|
||||
/** Script template parameters */
|
||||
|
|
|
|||
Loading…
Reference in a new issue