Repository navigation
Description
Summary
editorProcesses() substring-matches the entire ps -axo comm= output instead of comparing process names. Under npx / npm exec, npm rewrites its own process title to the full command line — which contains capcut-cli — so the tool detects itself as a running editor and refuses every mutating command with refused [editor-open], even when CapCut and JianYing are both closed.
The README documents npx capcut-cli <command> as the "run any command without installing" path. On that path, no write can ever succeed.
Environment
- macOS (darwin 25.5.0), Node 24.18.0
- capcut-cli 0.21.0
- CapCut 9.1.0 (mac), not running during all steps below
Reproduction
$ pgrep -x CapCut ; echo "exit=$?"
exit=1 # CapCut is not running
$ ps -axo comm= | grep -ic capcut
0 # nothing matches at rest
$ npx -y [email protected] sync-timelines "<draft>" --nested --apply
{"error":"refused [editor-open]: CapCut is running. Close the editor before repairing this draft, or pass --force-write if you accept that the app may overwrite the change."}Sampling ps while that command runs shows what it matched — its own npm process:
$ ps -axo comm= | grep -i capcut
npm exec [email protected] sync-timelines /Users/<me>/Movies/CapCut/User Data/Projects/com.lveditor.draft/<project> --nested --applyThe same write succeeds when the process title does not contain the string:
$ node ./node_modules/capcut-cli/dist/index.js sync-timelines "<draft>" --nested --apply
{"ok":true,"applied":true,...,"in_sync":true}
$ ./bin/capcut sync-timelines "<draft>" --nested --apply # bin symlink, shebang node
{"ok":true,"applied":true,...,"in_sync":true}Scope
| Invocation | Process title seen by comm= |
Result |
|---|---|---|
npx capcut-cli … / npm exec capcut-cli … |
npm exec [email protected] … |
❌ always refused [editor-open] |
globally installed capcut bin (npm i -g) |
node |
✅ works |
node dist/index.js … |
node |
✅ works |
I checked one adjacent theory and it does not hold: a normal process that merely has the draft path (which contains Movies/CapCut/…) in its argv is not affected, because macOS ps -o comm= prints only the executable name for ordinary processes — verified with tail -f "<draft>/draft_info.json", which reports tail. The false positive is specific to npm overwriting its process title.
Cause
dist/store.js:453:
const result = spawnSync("ps", ["-axo", "comm="], { encoding: "utf-8", timeout: 3000 });
const output = result.stdout ?? "";
return ["CapCut", "JianyingPro"].filter((name) =>
output.toLowerCase().includes(name.toLowerCase()));output is the whole listing joined together, so the check is "does the string capcut appear anywhere in the process table", not "is there a process named CapCut".
Suggested fix
Split into lines, compare the basename exactly (case-insensitively), and skip the current process:
const self = process.pid;
const lines = output.split("\n").map((l) => basename(l.trim())).filter(Boolean);
return ["CapCut", "JianyingPro"].filter((name) =>
lines.some((l) => l.toLowerCase() === name.toLowerCase()));Excluding own PID additionally would need ps -axo pid=,comm=.
A regression test could feed editorProcesses a fixture listing that contains npm exec [email protected] … and assert it returns [].
Why it matters here
The guard itself is good, and stricter than what I had in my own pipeline — I am adopting the idea. But the false positive silently blocks the documented zero-install entry point, and the message points the user at closing an editor that is already closed, so it is hard to tell apart from a genuine [editor-open] refusal.
Activity
renezander030 commentedon Aug 30, 2026
Confirmed — and thank you for a report that already contains the diagnosis, the scope table, and the fix direction. You're right on all three.
The check joins the whole
ps -axo comm=listing and asks "doescapcutappear anywhere in it", so npm's rewritten process title trips it on everynpxrun, and the README's zero-install path can never complete a write. The Windows branch has the same shape (tasklistoutput substring-matched as one string); it doesn't false-positive under npx there — the image name isnode.exe— but an image name that merely containscapcut.exewould trip it, so both branches get the same fix.One deviation from your suggested snippet: whole-line equality would break real detection on macOS, where
comm=prints the executable's full path (/Applications/CapCut.app/Contents/MacOS/CapCut) — this repo's fake-editor test spawns by absolute path and relies on exactly that. So the comparison is per line, exact on the basename, case-insensitive; Windows compares the exacttasklistimage name from the first CSV field. Your regression fixture goes in as written: a listing containingnpm exec [email protected] …must return[].Fix is in progress; lands today as 0.21.1. I'll post here when it's on npm.
fix(store): compare editor process names exactly, never as substrings…
renezander030 commentedon Aug 30, 2026
Released —
[email protected]is on npm (release notes, fix in #101).Your exact failing invocation is the verification:
$ npx -y [email protected] sync-timelines "<draft>" --nested --applywrites now, with CapCut closed — the guard compares exact process names per process on all three platforms, and your
npm exec capcut-cli@…fixture is in the test suite (test/editor-processes.test.mjs) so this can't quietly come back. A really-running CapCut/JianYing still refuses, as before.One finding from verification you may care about, since you're adopting the guard idea: the false positive wasn't macOS-only. On Linux the kernel truncates the process name to 15 characters —
npm exec capcut— which the substring test also matched. Observed directly before posting this:npx -y [email protected] add-text <managed draft> …refuses with[editor-open]on a Linux machine that has never run CapCut; the identical command on 0.21.1 returns{"ok":true,…}.Thanks again for the report — diagnosis, scope table, disproved adjacent theory and fix direction included. Reports like this one are why the guard can stay strict.
fix(store): leave the CLI's own process chain out of the editor-open …