Fix Windows nmem.cmd invocation in Copilot CLI hook#257
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✅ Files skipped from review due to trivial changes (3)
📝 WalkthroughWalkthroughbuild_nmem_command now invokes Windows ChangesWindows CMD execution
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Return cmd.exe and nmem.cmd arguments as argv entries so subprocess performs command-line conversion only once on Windows. This fixes nmem.CMD invocation failures when cmd.exe receives escaped quotes as part of the command name.
4c22d28 to
624dcb3
Compare
|
Thank you @mxi-box, this was a sharp Windows compatibility fix. Really appreciate you catching the nmem.cmd quoting edge case and helping make Copilot CLI smoother for users. |
Summary
nmem.cmdinvocation failure in the Copilot CLI hook.cmd.exe,nmem.cmd, and the remaining CLI arguments as separate argv entries.subprocess.list2cmdline, becausesubprocess.run([...])performs Windows command-line conversion again.Original Error
Reproduction
Use Windows with the Nowledge Mem desktop app installed, so
nmem.CMDresolves to a path like:Run the Copilot CLI plugin hook path that saves or imports a session through
nowledge-mem-copilot-cli-plugin/hooks/copilot-stop-save.py.The hook builds the
.cmdinvocation withsubprocess.list2cmdline(...), then passes that preformatted command string inside an argv list tosubprocess.run(...).On Windows,
subprocess.run([...])converts argv to a command line again, socmd.exereceives an over-quoted command name and fails with the error above.Testing
The targeted command-building tests pass.
Note: running the full
tests/test_copilot_plugin.pyfile locally on Windows also passes the updated command-building tests, but one unrelated existing test fails becausehooks.jsonis read with the default GBK locale instead of UTF-8.Summary by CodeRabbit
Bug Fixes
Chores