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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
//! xchecker - Spec pipeline with receipts and gateable JSON contracts
//!
//! This crate provides a deterministic, token-efficient pipeline that transforms rough ideas
//! into detailed implementation plans through a structured phase-based approach.
//!
//! xchecker can be used in two ways:
//! - **CLI**: Install via `cargo install xchecker` and run from command line
//! - **Library**: Add as a dependency and use internal APIs to embed in your application
//!
//! # Quick Start (CLI)
//!
//! Install xchecker from crates.io:
//!
//! ```bash
//! cargo install xchecker
//! ```
//!
//! Run a spec generation workflow:
//!
//! ```bash
//! # Initialize a new spec
//! xchecker init my-feature
//!
//! # Run all phases (dry-run mode for testing)
//! xchecker spec my-feature --dry-run
//!
//! # Check spec status
//! xchecker status my-feature --json
//!
//! # Run environment health checks
//! xchecker doctor --json
//! ```
//!
//! # Quick Start (Library)
//!
//! Add xchecker to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! xchecker = "1"
//! tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
//! ```
//!
//! Use [`OrchestratorHandle`] as the stable embedding facade for phase execution.
//! Avoid reaching into internal orchestrator modules directly; those are not covered
//! by semver guarantees.
//!
//! # JSON Contracts
//!
//! xchecker emits JSON in JCS (RFC 8785) canonical form for deterministic output:
//!
//! - Receipts: `schemas/receipt.v1.json`
//! - Status: `schemas/status.v1.json`
//! - Doctor: `schemas/doctor.v1.json`
//!
//! Use [`emit_jcs`] to emit JSON in canonical form for your own integrations.
//!
//! # Stable Public API
//!
//! The following types are part of stable public API for 1.x releases:
//!
//! - [`PhaseId`] - Phase identifiers (Requirements, Design, Tasks, etc.)
//! - [`Config`] and [`ConfigBuilder`] - Configuration management
//! - [`XCheckerError`] - Library error type
//! - [`ExitCode`] - CLI exit codes
//! - [`StatusOutput`] - Spec status information
//! - [`emit_jcs`] - JCS canonical JSON emission
//!
//! Internal modules are accessible via module paths but are marked `#[doc(hidden)]`
//! and are not covered by semver stability guarantees.
// ============================================================================
// Stable Public API - covered by semver guarantees for 1.x
// ============================================================================
// Re-export orchestrator types for backward compatibility
pub use ;
/// Phase identifiers for the spec generation workflow.
///
/// `PhaseId` represents different phases in xchecker's spec generation pipeline:
/// Requirements → Design → Tasks → Review → Fixup → Final.
///
/// See [`PhaseId`] documentation for phase dependencies and serialization details.
pub use PhaseId;
/// Configuration for xchecker operations.
///
/// `Config` provides hierarchical configuration with discovery and precedence:
/// CLI arguments > config file > built-in defaults.
///
/// Use [`Config::discover()`] for CLI-like behavior or [`Config::builder()`]
/// for programmatic configuration in embedding scenarios.
pub use Config;
/// Builder for programmatic configuration.
///
/// `ConfigBuilder` allows constructing a [`Config`] programmatically without
/// relying on environment variables or config files. This is useful for
/// embedding xchecker where deterministic behavior is required.
///
/// # Example
///
/// ```rust,no_run
/// use xchecker::Config;
/// use std::time::Duration;
///
/// let config = Config::builder()
/// .state_dir("/custom/state")
/// .packet_max_bytes(65536)
/// .phase_timeout(Duration::from_secs(600))
/// .build()
/// .expect("Failed to build config");
/// ```
pub use ConfigBuilder;
/// Library-level error type with rich context.
///
/// `XCheckerError` provides detailed error information including:
/// - Error kind for programmatic handling
/// - User-friendly messages via [`display_for_user()`](XCheckerError::display_for_user)
/// - Exit code mapping via [`to_exit_code()`](XCheckerError::to_exit_code)
///
/// Library code returns `XCheckerError` and does NOT call `std::process::exit()`.
pub use XCheckerError;
/// Exit codes matching the documented exit code table.
///
/// `ExitCode` provides type-safe exit code handling for xchecker operations.
/// Use named constants (e.g., [`ExitCode::SUCCESS`], [`ExitCode::PACKET_OVERFLOW`])
/// or [`as_i32()`](ExitCode::as_i32) to get the numeric value.
///
/// This is a stable public type. The numeric values are part of the public API
/// and will not change in 1.x releases.
pub use ExitCode;
/// Status output for a spec, matching `schemas/status.v1.json`.
///
/// `StatusOutput` provides comprehensive status information about a spec's current state,
/// including artifacts, configuration, and any detected drift from locked values.
///
/// This is a stable public type. Changes in 1.x releases are additive only.
pub use StatusOutput;
/// JCS (RFC 8785) canonical JSON emission for JSON contracts.
///
/// Use this function to emit JSON in canonical form for receipts, status, and
/// other JSON contracts. Canonical JSON ensures deterministic output for
/// stable diffs and hash verification.
pub use emit_jcs;
// Additional stable re-exports for convenience
/// CLI argument structure for configuration override.
///
/// Used internally by the CLI and for programmatic configuration via
/// [`Config::discover()`].
pub use CliArgs;
/// Error categories for grouping similar errors.
///
/// Used with [`XCheckerError`] for programmatic error handling.
pub use ErrorCategory;
/// Trait for providing user-friendly error reporting.
///
/// Implemented by [`XCheckerError`] and its component error types.
pub use UserFriendlyError;
// ============================================================================
// Internal modules - accessible but not stable
// ============================================================================
// NOTE: cli module is NOT exported here - it's only used by main.rs via `mod cli;`
/// Returns xchecker version with embedded git revision
/// Format: "{`CARGO_PKG_VERSION}+{GIT_SHA`}"
pub use test_support;
pub use xchecker_redaction as redaction;
pub use ;
pub use xchecker_config as config;
pub use xchecker_llm as llm;
pub use ;
pub use xchecker_status as status;
// Re-export artifact module from status crate for tests
pub use artifact;
// Re-export wsl module from doctor crate for tests
pub use wsl;
// Legacy wrapper; follow-up spec (V19+) to delete once tests migrate
pub use claude;
// CLI module - internal implementation detail, not part of stable public API
// Exported with #[doc(hidden)] to allow white-box testing of CLI flag parsing
// External consumers should use OrchestratorHandle, not CLI internals
// Legacy re-exports for backward compatibility (will be deprecated)
pub use write_error_receipt_and_exit;
pub use ;