fix(cli): preserve multi-word commit messages in CLI router
The commit case in the CLI router reads only args[1] for the message, which captures just the first word when the shell strips quotes before passing arguments to Node.js. This silently truncates every multi-word commit message (e.g. "docs(40): create phase plan" becomes "docs(40):"). Collect all positional args between the command name and the first flag (--files, --amend), then join them. Works correctly whether the shell preserves quotes (single arg) or strips them (multiple args). Closes #733 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -259,9 +259,13 @@ async function main() {
|
||||
|
||||
case 'commit': {
|
||||
const amend = args.includes('--amend');
|
||||
const message = args[1];
|
||||
// Parse --files flag (collect args after --files, stopping at other flags)
|
||||
const filesIndex = args.indexOf('--files');
|
||||
// Collect all positional args between command name and first flag,
|
||||
// then join them — handles both quoted ("multi word msg") and
|
||||
// unquoted (multi word msg) invocations from different shells
|
||||
const endIndex = filesIndex !== -1 ? filesIndex : args.length;
|
||||
const messageArgs = args.slice(1, endIndex).filter(a => !a.startsWith('--'));
|
||||
const message = messageArgs.join(' ') || undefined;
|
||||
const files = filesIndex !== -1 ? args.slice(filesIndex + 1).filter(a => !a.startsWith('--')) : [];
|
||||
commands.cmdCommit(cwd, message, files, raw, amend);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user