huskies: merge 950
This commit is contained in:
@@ -52,35 +52,6 @@ impl std::fmt::Display for Error {
|
||||
}
|
||||
}
|
||||
|
||||
// ── Public API — used by HTTP handlers ────────────────────────────────────────
|
||||
|
||||
/// Load and return the current wizard state.
|
||||
///
|
||||
/// # Errors
|
||||
/// - [`Error::NotActive`] if `wizard_state.json` does not exist.
|
||||
pub fn get_state(root: &Path) -> Result<WizardState, Error> {
|
||||
io::load(root).ok_or(Error::NotActive)
|
||||
}
|
||||
|
||||
/// Set content for `step` and mark it as awaiting confirmation.
|
||||
///
|
||||
/// Content is staged in `wizard_state.json` but **not** written to disk until
|
||||
/// [`confirm`] is called.
|
||||
///
|
||||
/// # Errors
|
||||
/// - [`Error::NotActive`] if no wizard is active.
|
||||
/// - [`Error::PersistenceFailure`] if saving state fails.
|
||||
pub fn set_step_content(
|
||||
root: &Path,
|
||||
step: WizardStep,
|
||||
content: Option<String>,
|
||||
) -> Result<WizardState, Error> {
|
||||
let mut state = io::load(root).ok_or(Error::NotActive)?;
|
||||
state.set_step_status(step, StepStatus::AwaitingConfirmation, content);
|
||||
io::save(&state, root)?;
|
||||
Ok(state)
|
||||
}
|
||||
|
||||
/// Mark `step` as confirmed and advance the wizard.
|
||||
///
|
||||
/// Enforces sequential ordering — only the current step may be confirmed.
|
||||
@@ -113,18 +84,6 @@ pub fn mark_step_skipped(root: &Path, step: WizardStep) -> Result<WizardState, E
|
||||
Ok(state)
|
||||
}
|
||||
|
||||
/// Mark `step` as generating (agent is working on it).
|
||||
///
|
||||
/// # Errors
|
||||
/// - [`Error::NotActive`] if no wizard is active.
|
||||
/// - [`Error::PersistenceFailure`] if saving state fails.
|
||||
pub fn mark_step_generating(root: &Path, step: WizardStep) -> Result<WizardState, Error> {
|
||||
let mut state = io::load(root).ok_or(Error::NotActive)?;
|
||||
state.set_step_status(step, StepStatus::Generating, None);
|
||||
io::save(&state, root)?;
|
||||
Ok(state)
|
||||
}
|
||||
|
||||
// ── Public API — used by MCP tool handlers ─────────────────────────────────
|
||||
|
||||
/// Return the current wizard state as a human-readable summary.
|
||||
@@ -300,6 +259,34 @@ pub fn retry(root: &Path) -> Result<String, Error> {
|
||||
))
|
||||
}
|
||||
|
||||
/// Return the current wizard state.
|
||||
///
|
||||
/// # Errors
|
||||
/// - [`Error::NotActive`] if no wizard is active.
|
||||
#[cfg(test)]
|
||||
pub fn get_state(root: &Path) -> Result<WizardState, Error> {
|
||||
io::load(root).ok_or(Error::NotActive)
|
||||
}
|
||||
|
||||
/// Stage `content` for `step` and transition its status to `AwaitingConfirmation`.
|
||||
///
|
||||
/// Content is not written to disk until [`confirm`] is called.
|
||||
///
|
||||
/// # Errors
|
||||
/// - [`Error::NotActive`] if no wizard is active.
|
||||
/// - [`Error::PersistenceFailure`] if saving state fails.
|
||||
#[cfg(test)]
|
||||
pub fn set_step_content(
|
||||
root: &Path,
|
||||
step: WizardStep,
|
||||
content: Option<String>,
|
||||
) -> Result<WizardState, Error> {
|
||||
let mut state = io::load(root).ok_or(Error::NotActive)?;
|
||||
state.set_step_status(step, StepStatus::AwaitingConfirmation, content);
|
||||
io::save(&state, root)?;
|
||||
Ok(state)
|
||||
}
|
||||
|
||||
/// Write `content` to `path` if no real content already exists there.
|
||||
///
|
||||
/// Thin public wrapper around `io::write_step_file` for use by HTTP/chat
|
||||
|
||||
Reference in New Issue
Block a user