AISpecWriter

Struct AISpecWriter 

Source
pub struct AISpecWriter;
Expand description

Manages AI-assisted spec writing with phase guidance and approval gates

Implementations§

Source§

impl AISpecWriter

Source

pub fn new() -> Self

Creates a new AI spec writer

Source

pub fn initialize_session(spec_id: &str, spec_name: &str) -> SpecWritingSession

Initializes a new spec writing session

Creates a new session with initial spec and approval gates. Session starts in Discovery phase.

§Arguments
  • spec_id - Unique identifier for the spec
  • spec_name - Human-readable name for the spec
§Returns

New spec writing session ready for phase guidance

Source

pub fn add_message( session: &mut SpecWritingSession, role: MessageRole, content: &str, ) -> Result<(), SpecError>

Adds a message to the conversation history

Records user or assistant messages in the session for context.

§Arguments
  • session - The spec writing session
  • role - Role of the message sender (User, Assistant, System)
  • content - Message content
§Returns

Updated session with message added

Source

pub fn get_phase_guidance(session: &SpecWritingSession) -> String

Gets phase-specific guidance for the current phase

Provides guidance on what to focus on in the current phase.

§Arguments
  • session - The spec writing session
§Returns

Guidance text for the current phase

Source

pub fn analyze_gaps(session: &SpecWritingSession, spec: &Spec) -> GapAnalysis

Analyzes gaps in the current spec

Identifies missing sections, incomplete sections, and suggests improvements based on the current phase.

§Arguments
  • session - The spec writing session
  • spec - The spec being written
§Returns

Gap analysis with missing sections and suggestions

Source

pub fn validate_spec(spec: &Spec) -> Result<(), SpecError>

Validates spec against EARS and INCOSE rules

Runs validation engine to check EARS compliance and INCOSE semantic rules.

§Arguments
  • spec - The spec to validate
§Returns

Ok if validation passes, Err with validation errors if it fails

Source

pub fn request_approval( session: &mut SpecWritingSession, approver: &str, feedback: Option<String>, ) -> Result<(), SpecError>

Requests approval for the current phase

Records approval with timestamp and approver information. Prevents phase transitions without explicit approval.

§Arguments
  • session - The spec writing session
  • approver - Name of the person approving
  • feedback - Optional feedback on the phase
§Returns

Ok if approval is recorded, Err if approval fails

Source

pub fn transition_to_next_phase( session: &mut SpecWritingSession, ) -> Result<(), SpecError>

Transitions to the next phase

Enforces sequential phase progression. Only allows transition if current phase has been explicitly approved.

§Arguments
  • session - The spec writing session
§Returns

Ok if transition succeeds, Err if transition is not allowed

Source

pub fn can_transition(session: &SpecWritingSession) -> bool

Checks if phase transition is allowed

Returns true if current phase is approved and next phase exists.

Source

pub fn get_conversation_history( session: &SpecWritingSession, ) -> &[ConversationMessage]

Gets the conversation history for context

Returns all messages in the session for AI context.

Source

pub fn get_current_phase(session: &SpecWritingSession) -> SpecPhase

Gets the current phase

Source

pub fn are_phases_approved_up_to( session: &SpecWritingSession, target_phase: SpecPhase, ) -> bool

Checks if all phases up to a target phase are approved

Useful for validating that a session has completed required phases.

Source

pub fn build_prompt_with_steering_context( session: &SpecWritingSession, global_steering: &Steering, project_steering: &Steering, user_input: &str, ) -> Result<String, SpecError>

Builds an AI prompt with steering context included

Generates a prompt for AI spec writing that includes steering rules, standards, and templates. Project steering takes precedence over global steering.

§Arguments
  • session - The spec writing session
  • global_steering - Global steering document (workspace-level)
  • project_steering - Project steering document (project-level)
  • user_input - The user’s input or question
§Returns

A formatted prompt string with steering context included

Source

pub fn validate_spec_against_steering( spec: &Spec, steering: &Steering, ) -> Result<Vec<String>, SpecError>

Applies steering rules to generated specs

Validates that generated specs conform to steering standards. Returns a list of violations if any steering rules are not followed.

§Arguments
  • spec - The generated spec to validate
  • steering - The steering document with rules and standards
§Returns

Ok with list of violations (empty if all rules are followed), or Err if validation fails

Source

pub fn format_steering_context(steering: &Steering) -> String

Gets steering context as a formatted string for display

Useful for showing users what steering rules are active.

§Arguments
  • steering - The steering document
§Returns

Formatted string representation of steering context

Trait Implementations§

Source§

impl Clone for AISpecWriter

Source§

fn clone(&self) -> AISpecWriter

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AISpecWriter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AISpecWriter

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more