Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

Overview

Refactor /compact command to support multiline continue messages. Everything after the first line becomes the continue message, making it much more ergonomic than the old -c "message" syntax.

Old syntax (still works for backwards compat):

/compact -c "Continue implementing auth"

New syntax:

/compact
Continue implementing the auth system.
Make sure to add tests for edge cases.

Changes

Parser Infrastructure

  • Added rawInput field to SlashCommandHandlerArgs to pass raw input with newlines preserved
  • Updated parser to extract raw input after command name, preserving newlines
  • Only trim leading spaces on first line, not newlines

Compact Command Handler

  • Parse multiline continue messages from lines after the first line
  • Prioritize -c flag if present (backwards compatibility)
  • Otherwise use multiline content as continue message

Tests

  • Added 9 new test cases for multiline parsing:
    • Basic multiline continue message
    • Multiline with -t flag
    • Multiple lines preservation
    • Empty lines handling
    • Whitespace preservation
    • -c flag takes precedence (backwards compat)
    • Trailing newline handling
  • All 23 tests passing

Documentation

  • Updated docs/context-management.md with multiline syntax examples
  • Updated docs/prompting-tips.md to show multiline usage
  • Removed -c flag from documented syntax (but it still works)

Benefits

  1. Ergonomics: Much easier to type natural language without quotes/escaping
  2. Readability: Multiline messages are easier to read and edit
  3. Consistency: Follows natural "command on first line, args below" pattern
  4. Backwards compatible: -c flag still works (just undocumented)

Testing

  • ✅ All unit tests passing (511 pass)
  • ✅ TypeScript compilation passes
  • ✅ Linting passes
  • ✅ 9 new test cases for multiline parsing

Files Changed

  • src/utils/slashCommands/types.ts - Add rawInput to handler args
  • src/utils/slashCommands/parser.ts - Pass rawInput to handlers
  • src/utils/slashCommands/registry.ts - Update compact handler
  • src/utils/slashCommands/compact.test.ts - Add multiline tests
  • docs/context-management.md - Update syntax and examples
  • docs/prompting-tips.md - Update examples

Net change: +132 lines / -21 lines = +111 lines

Generated with cmux

- Add rawInput to parser infrastructure to preserve newlines
- Update /compact handler to parse multiline continue messages
  - Lines after first line become the continue message
  - -c flag still works for backwards compatibility (undocumented)
- Add 9 new test cases for multiline parsing
- Update docs to show multiline syntax (removed -c from examples)

Benefits:
- More ergonomic: no need for quotes or escaping
- More readable: natural multiline format
- Fully backwards compatible: -c flag still works

Example:
  /compact -t 5000
  Continue implementing the auth system.
  Make sure to add tests for edge cases.
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

The previous commit broke multiline support for commands like /providers
by only parsing tokens from the first line. This commit fixes the issue:

- Parse tokens from full input (as before) to support all commands
- /compact handler checks for newlines in rawInput to distinguish
  between single-line positional args (error) vs multiline content (valid)
- Add 4 new tests to ensure /providers, /model, /truncate work with newlines

The fix:
- Parser: parse tokens from full string (newlines treated as whitespace)
- /compact: detect multiline via rawInput.includes('\n'), skip positional
  arg check if multiline (since multiline content appears as positional args)

This preserves backwards compatibility while enabling multiline /compact.
@ammario ammario added this pull request to the merge queue Oct 15, 2025
Merged via the queue into main with commit 8e4c425 Oct 15, 2025
13 of 14 checks passed
@ammario ammario deleted the compact-multiline-continue branch October 15, 2025 00:36
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.

2 participants