Skip to content

feat(mongo): add completion package for auto-complete#10

Merged
h3n4l merged 6 commits intomainfrom
feature/mongo-completion
Apr 2, 2026
Merged

feat(mongo): add completion package for auto-complete#10
h3n4l merged 6 commits intomainfrom
feature/mongo-completion

Conversation

@h3n4l
Copy link
Copy Markdown
Member

@h3n4l h3n4l commented Apr 2, 2026

Summary

  • Add mongo/catalog/ package — minimal collection-name store for completion context
  • Add mongo/completion/ package — lexer-based auto-complete for mongosh commands
    • 12 completion contexts (top-level, db., db.coll., cursor chain, agg stages, query operators, show targets, rs/sh methods, bracket access, document keys)
    • Hardcoded candidate lists for collection methods, cursor methods, db methods, aggregation stages, query operators, BSON helpers, show targets, rs/sh methods
    • $-prefixed completion support, case-sensitive filtering
    • Handles incomplete input (unterminated strings, unclosed braces, trailing dots)
  • Export minimal token constants from mongo/parser (TokEOF, TokString, TokIdent, IsWord())

Design spec: docs/superpowers/specs/2026-04-02-mongo-completion-design.md

Test plan

  • 32 passing tests covering all 12 context types, prefix extraction, filtering, end-to-end completion, edge cases (nil catalog, cursor overshoot, multi-statement, deeply nested queries)
  • go vet ./mongo/... clean
  • No regressions in existing parser/analysis tests

🤖 Generated with Claude Code

h3n4l and others added 6 commits April 2, 2026 18:01
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ntext stub

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add comprehensive tests for the Complete() function covering all context
types, prefix extraction, prefix filtering, edge cases, and negative cases.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add comment explaining contextCursorChain default fallback rationale
- Add edge case tests: multi-statement, deeply nested query operators,
  document key after colon

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@h3n4l h3n4l force-pushed the feature/mongo-completion branch from abf437a to 0476e1f Compare April 2, 2026 10:01
@h3n4l h3n4l marked this pull request as ready for review April 2, 2026 10:09
@h3n4l h3n4l merged commit de2123e into main Apr 2, 2026
1 check passed
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.

1 participant