Skip to content

fix(cli): check publish command at argv[2] position only#468

Merged
jahooma merged 1 commit intoCodebuffAI:mainfrom
nil957:fix/publish-command-detection
Mar 9, 2026
Merged

fix(cli): check publish command at argv[2] position only#468
jahooma merged 1 commit intoCodebuffAI:mainfrom
nil957:fix/publish-command-detection

Conversation

@nil957
Copy link
Copy Markdown
Contributor

@nil957 nil957 commented Mar 9, 2026

Summary

Fixes publish command detection to only match when 'publish' is the actual subcommand, not anywhere in the arguments.

Problem

The CLI's publish command detection uses process.argv.includes('publish') which matches "publish" anywhere in the arguments, not just as a subcommand. A user prompt like "publish my changes" triggers the publish flow and exits the session.

const isLoginCommand = process.argv[2] === 'login'       // ← positional (correct)
const isPublishCommand = process.argv.includes('publish') // ← non-positional (bug)

isLoginCommand correctly checks only argv[2] (the subcommand position), but isPublishCommand uses includes() which matches any argument.

Reproduction

codebuff "publish my changes"
# Expected: starts a chat session with the prompt "publish my changes"
# Actual: triggers handlePublish() and exits

Fix

  const isLoginCommand = process.argv[2] === 'login'
- const isPublishCommand = process.argv.includes('publish')
+ const isPublishCommand = process.argv[2] === 'publish'

Consistent with how isLoginCommand is detected.

Fixes #465

The CLI's publish command detection used process.argv.includes('publish')
which matches 'publish' anywhere in the arguments, not just as a subcommand.

This means a user prompt like 'publish my changes' triggers the publish
flow and exits the session instead of starting a chat.

The fix makes isPublishCommand consistent with isLoginCommand by checking
only argv[2] (the subcommand position).

Before:
  codebuff "publish my changes"
  # triggers handlePublish() and exits

After:
  codebuff "publish my changes"
  # starts a chat session with the prompt

Fixes CodebuffAI#465
@jahooma jahooma merged commit cbd8af2 into CodebuffAI:main Mar 9, 2026
reillyse pushed a commit to reillyse/codebuff that referenced this pull request Mar 24, 2026
)

Co-authored-by: Javis <javis@JavisdeMacBook-Air.local>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: isPublishCommand matches any argv token — prompts starting with 'publish' hijack session

2 participants