TaskContext

Enum TaskContext 

Source
pub enum TaskContext {
    Staged {
        include_unstaged: bool,
    },
    Commit {
        commit_id: String,
    },
    Range {
        from: String,
        to: String,
    },
    Changelog {
        from: String,
        to: String,
        version_name: Option<String>,
        date: String,
    },
    Amend {
        original_message: String,
    },
    Discover,
}
Expand description

Validated, structured context for agent tasks.

This enum represents the different modes of operation for code analysis, with validation built into the constructors.

Variants§

§

Staged

Analyze staged changes (optionally including unstaged)

Fields

§include_unstaged: bool

Whether to include unstaged changes in analysis

§

Commit

Analyze a single commit

Fields

§commit_id: String

The commit ID (hash, branch name, or commitish like HEAD~1)

§

Range

Analyze a range of commits or branch comparison

Fields

§from: String

Starting reference (exclusive)

§to: String

Ending reference (inclusive)

§

Changelog

Generate changelog or release notes with version metadata

Fields

§from: String

Starting reference (exclusive)

§to: String

Ending reference (inclusive)

§version_name: Option<String>

Explicit version name (e.g., “1.2.0”)

§date: String

Release date in YYYY-MM-DD format

§

Amend

Amend the previous commit with staged changes The agent sees the combined diff from HEAD^1 to staged state

Fields

§original_message: String

The original commit message being amended

§

Discover

Let the agent discover context via tools (default for gen command)

Implementations§

Source§

impl TaskContext

Source

pub fn for_gen() -> Self

Create context for the gen (commit message) command. Always uses staged changes only.

Source

pub fn for_amend(original_message: String) -> Self

Create context for amending the previous commit. The agent will see the combined diff from HEAD^1 to staged state.

Source

pub fn for_review( commit: Option<String>, from: Option<String>, to: Option<String>, include_unstaged: bool, ) -> Result<Self>

Create context for the review command with full parameter validation.

Validates:

  • --from requires --to for range comparison
  • --commit is mutually exclusive with --from/--to
  • --include-unstaged is incompatible with range comparisons
Source

pub fn for_pr(from: Option<String>, to: Option<String>) -> Self

Create context for the PR command.

PR command is more flexible - all parameter combinations are valid:

  • from + to: Explicit range/branch comparison
  • from only: Compare from..HEAD
  • to only: Compare main..to
  • Neither: Compare main..HEAD
Source

pub fn for_changelog( from: String, to: Option<String>, version_name: Option<String>, date: Option<String>, ) -> Self

Create context for changelog/release-notes commands.

These always require a from reference; to defaults to HEAD. Automatically sets today’s date if not provided.

Source

pub fn to_prompt_context(&self) -> String

Generate a human-readable prompt context string for the agent.

Source

pub fn diff_hint(&self) -> String

Generate a hint for which git_diff call the agent should make.

Source

pub fn is_range(&self) -> bool

Check if this context represents a range comparison (vs staged/single commit)

Source

pub fn includes_unstaged(&self) -> bool

Check if this context involves unstaged changes

Source

pub fn is_amend(&self) -> bool

Check if this is an amend operation

Source

pub fn original_message(&self) -> Option<&str>

Get the original commit message if this is an amend context

Trait Implementations§

Source§

impl Clone for TaskContext

Source§

fn clone(&self) -> TaskContext

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 TaskContext

Source§

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

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

impl Default for TaskContext

Source§

fn default() -> TaskContext

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

impl<'de> Deserialize<'de> for TaskContext

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for TaskContext

Source§

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

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

impl Serialize for TaskContext

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToCompactString for T
where T: Display,

Source§

impl<T> ToLine for T
where T: Display,

Source§

fn to_line(&self) -> Line<'_>

Converts the value to a Line.
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> ToSpan for T
where T: Display,

Source§

fn to_span(&self) -> Span<'_>

Converts the value to a Span.
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

impl<T> ToText for T
where T: Display,

Source§

fn to_text(&self) -> Text<'_>

Converts the value to a Text.
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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
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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> WasmCompatSend for T
where T: Send,

Source§

impl<T> WasmCompatSync for T
where T: Sync,