pub struct PlanSession { /* private fields */ }Expand description
An interactive planning session wrapping a ClaudeClient with the
Planner profile for multi-turn feature planning conversations.
§Usage
- Create via
PlanSession::new - Call
sendrepeatedly for conversation turns - Call
approveto formalize the approved design - Call
finalizeto write specs and create a worktree
Implementations§
Source§impl PlanSession
impl PlanSession
Sourcepub fn new(
feature_slug: String,
project_root: PathBuf,
pm: &PromptManager,
config: &CodaConfig,
git: Arc<dyn GitOps>,
) -> Result<Self, CoreError>
pub fn new( feature_slug: String, project_root: PathBuf, pm: &PromptManager, config: &CodaConfig, git: Arc<dyn GitOps>, ) -> Result<Self, CoreError>
Creates a new planning session for the given feature.
Initializes a ClaudeClient with the Planner profile and renders
the planning system prompt with repository context.
§Errors
Returns CoreError if the system prompt cannot be rendered.
Sourcepub async fn connect(&mut self) -> Result<(), CoreError>
pub async fn connect(&mut self) -> Result<(), CoreError>
Connects the underlying ClaudeClient to the Claude process.
§Errors
Returns CoreError::AgentError if the connection fails.
Sourcepub async fn disconnect(&mut self)
pub async fn disconnect(&mut self)
Disconnects the underlying ClaudeClient.
Safe to call multiple times or when not connected.
Sourcepub async fn send(&mut self, message: &str) -> Result<String, CoreError>
pub async fn send(&mut self, message: &str) -> Result<String, CoreError>
Sends a user message and collects the agent’s response.
Automatically connects on the first call.
§Errors
Returns CoreError::AgentError if the query or response
streaming fails.
Sourcepub async fn approve(&mut self) -> Result<(String, String), CoreError>
pub async fn approve(&mut self) -> Result<(String, String), CoreError>
Formalizes the approved design and generates a verification plan.
First asks the agent to produce a structured design specification
document, then generates a verification plan based on the design.
Both are stored so finalize can write them
directly without re-generating.
Returns (design, verification) so the UI can display both.
§Errors
Returns CoreError if template rendering or agent communication fails.
Sourcepub fn is_approved(&self) -> bool
pub fn is_approved(&self) -> bool
Returns true if both design and verification have been approved
via approve.
Sourcepub async fn finalize(&mut self) -> Result<PlanOutput, CoreError>
pub async fn finalize(&mut self) -> Result<PlanOutput, CoreError>
Finalizes the planning session by creating a worktree and writing specs.
This method:
- Creates a git worktree from the base branch
- Writes the approved design spec into the worktree
- Writes the approved verification plan into the worktree
- Writes the initial
state.ymlinto the worktree
All feature artifacts are written under <worktree>/.coda/<slug>/
so they travel with the feature branch and merge cleanly into main.
§Errors
Returns CoreError if git operations, directory creation, or
file writes fail.
Sourcepub fn feature_dir_name(&self) -> &str
pub fn feature_dir_name(&self) -> &str
Returns the directory name for this feature (the slug itself).
Sourcepub fn feature_slug(&self) -> &str
pub fn feature_slug(&self) -> &str
Returns the feature slug.