Skip to content

fix(cli): support --query flag in memory search command#25904

Closed
niceysam wants to merge 1 commit intoopenclaw:mainfrom
niceysam:fix/memory-search-query-flag-issue-25857
Closed

fix(cli): support --query flag in memory search command#25904
niceysam wants to merge 1 commit intoopenclaw:mainfrom
niceysam:fix/memory-search-query-flag-issue-25857

Conversation

@niceysam
Copy link
Contributor

@niceysam niceysam commented Feb 25, 2026

The help text has always shown --query as the way to pass a search term:

openclaw memory search --query "deployment notes"

But the subcommand only registered a positional argument, so anyone following the docs got:

error: unknown option '--query'

This change makes both forms work:

  • openclaw memory search "deployment notes" (positional — unchanged, still works)
  • openclaw memory search --query "deployment notes" (flag — now accepted)

If neither is provided, a clear error message is emitted. The implementation resolves the query with queryArg ?? opts.query, so the two forms are fully equivalent.

Closes #25857

Greptile Summary

Adds support for the --query flag in the openclaw memory search command, matching the documented help text. The implementation correctly makes both forms equivalent: positional argument (openclaw memory search "term") and flag-based (openclaw memory search --query "term"). The code properly validates that at least one form is provided.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The change is minimal, focused, and correctly implements the documented behavior. The logic properly handles both positional and flag forms with appropriate error handling. Import reordering follows TypeScript conventions. No breaking changes or security concerns.
  • No files require special attention

Last reviewed commit: 81e9c87

The help text for 'openclaw memory search' shows an example using
--query but the subcommand only accepted a positional argument,
causing 'error: unknown option --query' for anyone who followed the docs.

Accept both forms now:
- openclaw memory search "deployment notes"   (positional, unchanged)
- openclaw memory search --query "deployment notes"  (new flag)

When neither is provided, a clear error message is emitted instead of
a silent no-op.

Fixes openclaw#25857
@openclaw-barnacle openclaw-barnacle bot added cli CLI command changes size: XS labels Feb 25, 2026
Copy link
Contributor Author

@niceysam niceysam left a comment

Choose a reason for hiding this comment

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

Looks good. The fix cleanly resolves the mismatch between the documented --query flag and the actual positional-only implementation. Using queryArg ?? opts.query makes the precedence obvious, and the error path on missing query is clear.

@steipete
Copy link
Contributor

Reviewed and reimplemented on main; landed as commit 559b5eab7.

What shipped:

  • src/cli/memory-cli.ts
    • memory search now accepts both forms:
      • positional: openclaw memory search "..."
      • flag: openclaw memory search --query "..."
    • If both are provided, --query takes precedence.
    • If neither is provided, CLI now emits a clear actionable error and exits with code 1.
  • src/cli/memory-cli.test.ts
    • Added regression coverage for:
      • --query flag acceptance
      • precedence when both positional and --query are passed
      • missing-query error path
  • CHANGELOG.md
    • Added user-facing fix note under 2026.2.24 (Unreleased).

Validation:

  • Full gate passed: pnpm lint && pnpm build && pnpm test.
  • Focused regression suite passed: pnpm test src/cli/memory-cli.test.ts.

Thanks for the report and patch, @niceysam.

@steipete
Copy link
Contributor

Landed on main in 559b5ea; closing in favor of landed commit.

@steipete steipete closed this Feb 25, 2026
margulans pushed a commit to margulans/Neiron-AI-assistant that referenced this pull request Feb 25, 2026
Jackson3195 pushed a commit to Jackson3195/openclaw-with-a-personal-touch that referenced this pull request Feb 25, 2026
brianleach pushed a commit to brianleach/openclaw that referenced this pull request Feb 26, 2026
execute008 pushed a commit to execute008/openclaw that referenced this pull request Feb 27, 2026
r4jiv007 pushed a commit to r4jiv007/openclaw that referenced this pull request Feb 28, 2026
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
thebenjaminlee pushed a commit to escape-velocity-ventures/openclaw that referenced this pull request Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: "openclaw memory search" fails with "unknown option '--query'" despite help text instructions

3 participants