1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// SPDX-License-Identifier: Apache-2.0
//! `oo` (double-o) — a context-efficient command runner for AI coding agents.
//!
//! This library helps AI agents run shell commands efficiently by classifying output
//! and reducing context usage. Commands are executed, their output is analyzed, and
//! results are compressed using pattern matching and intelligent categorization.
//!
//! # Core Concepts
//!
//! - **Classification**: Commands are categorized into four tiers based on success/failure
//! and output size. Small successful outputs pass through verbatim, while large outputs
//! are pattern-matched to extract terse summaries or indexed for later recall.
//! - **Patterns**: Regular expressions define how to extract summaries from command output.
//! Built-in patterns exist for common tools (pytest, cargo test, npm test, etc.).
//! Custom patterns can be loaded from project-local `<git-root>/.oo/patterns/` or
//! user-global TOML files in the user patterns directory (project patterns take precedence).
//! - **Storage**: Large unpatterned outputs are stored in a searchable database (SQLite by
//! default, with optional Vipune semantic search). Stored outputs can be recalled with
//! full-text search.
//! - **Categories**: Commands are auto-detected as Status (tests, builds, linters),
//! Content (git show, diff, cat), Data (git log, ls, gh), or Unknown. This determines
//! default behavior when no pattern matches.
//!
//! # Example
//!
//! ```
//! use double_o::{classify, Classification, CommandOutput, Pattern};
//! use double_o::pattern::builtins;
//!
//! // Run a command
//! let args = vec!["echo".into(), "hello".into()];
//! let output = double_o::exec::run(&args).unwrap();
//!
//! // Classify the output
//! let command = "echo hello";
//! let patterns = builtins(); // or load_user_patterns(&path)
//! let result = classify(&output, command, &patterns);
//!
//! match result {
//! Classification::Passthrough { output } => {
//! println!("Output: {}", output);
//! }
//! Classification::Success { label, summary } => {
//! println!("✓ {}: {}", label, summary);
//! }
//! Classification::Failure { label, output, .. } => {
//! println!("✗ {}: {}", label, output);
//! }
//! Classification::Bounded { label, size, .. } => {
//! println!("Bounded: {} ({} bytes)", label, size);
//! }
//! Classification::Large { label, size, .. } => {
//! println!("Indexed: {} ({} bytes)", label, size);
//! }
//! }
//! ```
/// API key presence check for `oo learn`.
/// OS-string argv helpers: lossy display and UTF-8-or-reject conversion (issue #213).
/// Command output classification and intelligent truncation.
/// Byte-bounded head+tail truncation, re-exported from [`classify`].
/// Config and data directory resolution (`OO_CONFIG_DIR`, `OO_DATA_DIR`, or the platform dirs).
/// Savings suffix for compressed indicator lines (shared by the render arms).
/// Error types for oo operations.
/// Command execution and output capture.
/// Failure-tier display and recall notice (used by `render_classification`).
/// Indexing of raw command output for `oo recall` (shared by the render arms).
/// LLM-powered pattern learning.
/// Pattern matching and output compression.
/// Canonical pattern-set assembly (project/user/builtins precedence) shared
/// by the dispatch layer and the rewrite/hook feature modules.
/// Page-based project drain and stale cleanup for backends without bulk
/// delete or pagination offset (Vipune adapter).
/// Retention of indexed output (`[store] retention` in config.toml).
/// Session tracking and management.
/// Storage backends for indexed output.
/// Claude Code PreToolUse hook processor + settings.json installer (issue #172).
/// Static usage text for reserved subcommands (`--help` and `oo help <sub>`).
// CLI internals - hidden from documentation but accessible to binary crate
// Re-exports for library users
pub use ;
pub use warn_ignored_overrides;
pub use Error;
pub use CommandOutput;
pub use ;
pub use ;
// CLI internals - re-exported for binary crate but hidden from documentation
pub use ;
// Internal type re-exported for learn module
pub use FailureSection;