[Bug] Daemon install writes the LaunchAgent plist without XML escaping and leaves spaces and % in the systemd unit unquoted
Description
buildLaunchAgentPlist writes the project path straight into XML, so & or < in the path makes the plist invalid. buildSystemdUnit writes the path unquoted in Environment= (a space splits it into two assignments) and leaves a single %, which systemd treats as a specifier. I checked the generated text only. I did not load either file with launchd or systemd.
Environment
- OS: Windows 11 Home 10.0.26300
- Node version: v22.22.3
- Nanocoder version: 1.32.0 (built from main at 5df35b3a)
- Provider: Not provider-specific
- Model: Not model-specific
Steps to Reproduce
- Call
buildLaunchAgentPlist('/Users/me/R&D <x>', 'abc', 'nanocoder'). - Call
buildSystemdUnit('/home/me/my proj/100%', 'abc', 'nanocoder').
Expected Behavior
- The plist contains
R&D <x>. - The unit writes
%as%%and quotes the value:Environment="NANOCODER_PROJECT_ROOT=/home/me/my proj/100%%".
Actual Behavior
<string>/Users/me/R&D <x></string>
Description=nanocoder daemon for /home/me/my proj/100%
WorkingDirectory=/home/me/my proj/100%
Environment=NANOCODER_PROJECT_ROOT=/home/me/my proj/100%
Additional Context
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] I can reproduce this issue consistently
- [x] This issue occurs with the latest version of nanocoder (main)
Suggested fix:
source/daemon/install.ts:131,:136and:140: wrap the values in the existingxmlEscape(defined at line 177 for the Task Scheduler manifest).source/daemon/install.ts:157-163: replace%with%%in all values and put theEnvironment=assignment in double quotes.- Add tests with
&,<, a space and%in the path.
I'd like to work on this. On main at 5df35b3a I ran the two calls from the issue: the plist has <string>/Users/me/R&D <x></string>, and macOS plutil -lint rejects it (Encountered unknown ampersand-escape sequence at line 14); the unit has Environment=NANOCODER_PROJECT_ROOT=/home/me/my proj/100%, as the issue shows. I'll try the suggested change with tests for &, <, a space and %, and post the result or a blocker here within two days.
Sure @hskl18, go ahead