Empirical failure: add_library('Standard') on a project that already had Standard, * (System) silently created a SECOND direct Standard reference, pulling in unresolved transitive deps (e.g. yellow-warning IoStandard 3.1.3.1).
Root cause: script always called add_library() without checking lm.references first; never called add_placeholder() so the result was a direct (non-* (System)) reference.
Fix: (1) walk lm.references for an existing entry by bare name and no-op with a confirmation message unless force=true; (2) default to add_placeholder() so transitive deps resolve at compile (matches the modern '<Name>, * (System)' convention); (3) keep add_library() reachable via direct=true; (4) on miss, dump dir(lm) so unknown SPs surface the actual API.
Docs: https://content.helpme-codesys.com/en/ScriptingEngine/ScriptLibManObject.html
Mildly breaking for callers: previous behaviour was always direct
add_library(); pass direct=true to restore. The dedup default also flips
'add second copy' to 'no-op' -- pass force=true to restore.
Test updated: tests/integration/e2e.test.ts now passes USE_DIRECT='0' and
FORCE_DUP='0' alongside LIBRARY_NAME, asserts add_placeholder + dedup
strings appear in the rendered script.
### Manual smoke test
1. mcp__codesys__add_library libraryName=Standard against a project that
already has Standard listed: expect SCRIPT_SUCCESS with body 'Library
Already Present: Standard' and NO second entry in the Library Manager.
2. mcp__codesys__add_library libraryName=Util on a project without Util:
expect a new entry rendered as 'Util, * (System)' (placeholder, not
direct).
3. mcp__codesys__add_library libraryName=Standard direct=true: expect a
direct (non-* (System)) reference even on dedup hit if also force=true.
4. mcp__codesys__list_project_libraries should reflect each result.
|
||
|---|---|---|
| .. | ||
| e2e.test.ts | ||
| README.md | ||
Manual CODESYS Integration Tests
These tests require a real CODESYS installation and cannot run in CI.
Prerequisites
- CODESYS 3.5 SP19 or SP21 installed
- No other CODESYS instances running
- Node.js 18+
Steps
1. Build the package
npm run build
2. Test persistent mode
node dist/bin.js \
--codesys-path "C:\path\to\CODESYS.exe" \
--codesys-profile "CODESYS V3.5 SP21 Patch 3" \
--mode persistent \
--verbose
Verify:
- CODESYS UI opens
- Console shows "CODESYS watcher is ready"
- The MCP server accepts connections
3. Test headless fallback
node dist/bin.js \
--codesys-path "C:\path\to\CODESYS.exe" \
--codesys-profile "CODESYS V3.5 SP21 Patch 3" \
--mode headless
4. Test --detect flag
node dist/bin.js --detect
Verify: Lists installed CODESYS versions.
5. Ctrl+C shutdown
- Press Ctrl+C during persistent mode
- Verify CODESYS shuts down cleanly