Skip to main content

osp_cli/completion/
mod.rs

1//! Completion exists to turn a partially typed line plus cursor position into a
2//! ranked suggestion set.
3//!
4//! This module stays deliberately free of terminal state, network access, and
5//! REPL/editor concerns. The core flow is:
6//!
7//! - `tree`: build a static command/config completion tree
8//! - `parse`: tokenize and analyze a partially typed command line
9//! - `suggest`: rank and shape suggestions from the parsed cursor context
10//!
11//! Outer layers such as [`crate::cli`] and [`crate::repl`] inject dynamic
12//! command catalogs, shell scope, alias expansion, and live prompt behavior on
13//! top of this pure engine.
14//!
15//! Contract:
16//!
17//! - completion logic may depend on structured command metadata and cursor
18//!   state
19//! - it should not depend on terminal painting, network I/O, plugin process
20//!   execution, or interactive host state
21//!
22//! Public API shape:
23//!
24//! - `tree` exposes builder/factory-style entrypoints such as
25//!   [`crate::completion::CompletionTreeBuilder`] and
26//!   [`crate::completion::CommandSpec`]
27//! - `model` stays mostly plain semantic data so parsers, suggesters, and
28//!   embedders can exchange completion state without hauling builder objects
29//!   around
30//! - terminal/editor integration belongs in outer layers like [`crate::repl`]
31
32mod context;
33/// High-level orchestration that combines parsing, context resolution, and suggestion ranking.
34pub mod engine;
35/// Shared completion data structures passed between the parser and suggester.
36pub mod model;
37/// Tokenization and cursor-aware command-line parsing.
38pub mod parse;
39/// Suggestion ranking and output shaping from parsed cursor state.
40pub mod suggest;
41/// Declarative completion-tree builders derived from command and config metadata.
42pub mod tree;
43
44pub use engine::CompletionEngine;
45pub use model::{
46    ArgNode, CommandLine, CompletionAnalysis, CompletionContext, CompletionNode, CompletionRequest,
47    CompletionTree, ContextScope, CursorState, FlagHints, FlagNode, FlagOccurrence, MatchKind,
48    OsVersions, ParsedLine, QuoteStyle, RequestHintSet, RequestHints, Suggestion, SuggestionEntry,
49    SuggestionOutput, TailItem, ValueType,
50};
51pub use parse::{CommandLineParser, ParsedCursorLine, TokenSpan};
52pub use suggest::SuggestionEngine;
53pub use tree::{CommandSpec, CompletionTreeBuildError, CompletionTreeBuilder, ConfigKeySpec};