1use std::path::Path;
8
9pub use crate::RunOptions;
10
11pub mod actions {
13 pub use crate::actions::{Dispatch, Interface, Offer, available, list, offered, perform};
14}
15
16pub mod person {
19 pub use crate::person::{Stream, TIMEOUT, open_terminal, run, sandboxed, shown, speccoder};
20}
21
22pub mod copy {
24 pub use crate::copy::block;
25 pub use crate::doctor::bug_report;
26}
27
28pub mod approvals {
30 pub use crate::approvals::{Answer, Approver, Presentation, Who, list};
31}
32
33pub mod progress {
35 pub use crate::progress::{Event, Progress, read_live};
36}
37
38pub mod status {
40 pub use crate::status::report;
41}
42
43pub mod shape {
46 pub use crate::shape::{FIELDS, findings, judge, shape};
47}
48
49pub mod ask {
52 pub use crate::ask::chips::{ChipRef, resolve as chip};
53 pub use crate::ask::proposal::revalidate as proposal;
54 pub use crate::ask::{Request, changed_since, conversations, new_id, stop, thread, turn};
55}
56
57pub mod explore {
59 pub use crate::explore::{list, session};
60}
61
62pub mod next {
64 pub use crate::next::attach;
65}
66
67pub mod review {
69 pub use crate::comments::list as comments;
71 pub use crate::review::{readiness, report};
72}
73
74pub mod planning {
77 pub use crate::planning_chain::{similar_command, similar_to, suggest};
78}
79
80pub mod new_project {
82 pub use crate::new_project::{Creation, creation, first_feature, plan, undo_offer};
83 pub use speccoder_core::new_project::{NewChoices, Stack, slug};
84}
85
86pub mod welcome {
88 pub use crate::welcome::{
89 Recent, RecentView, default_parent, folders, forget, is_project, remember, tilde, views,
90 };
91}
92
93pub mod sample {
95 pub use crate::sample::{available, copy, home, missing_tool};
96}
97
98pub mod inbox {
100 pub use crate::inbox::inbox;
101}
102
103pub mod bug {
105 pub use crate::bug::show;
106}
107
108pub mod evidence {
110 pub use crate::evidence::{account_of, banner, rows, statements};
111}
112
113pub mod tour {
115 use std::path::Path;
116
117 use speccoder_core::{CommandData, CommandResult, CommandStatus};
118
119 #[must_use]
123 pub fn of_task(root: &Path, feature: Option<&str>, task: &str) -> CommandResult {
124 let selected = || match crate::inspect(root, None).data() {
125 Some(CommandData::Inspect(snap)) => {
126 snap.feature.as_ref().map(|f| f.feature.name.clone())
127 }
128 _ => None,
129 };
130 let Some(feature) = feature.map(str::to_owned).or_else(selected) else {
131 return CommandResult::new(
132 "tour",
133 CommandStatus::SelectionNeeded,
134 "no feature selected",
135 );
136 };
137 crate::tour::command(
138 root,
139 &feature,
140 task,
141 &crate::attest::branch::Options::default(),
142 "tour",
143 )
144 }
145}
146
147pub mod documents {
149 pub use crate::documents::{of_feature, render};
150}
151
152pub mod doctor {
154 pub use crate::doctor::{agents, run};
155}
156
157pub mod settings {
159 pub use crate::approvals::coverage::show as coverage;
161 pub use crate::settings::{apply, commit, show};
162}
163
164pub mod controls {
166 pub use crate::controls::{SkillCost, cost, skill_cost};
167}
168
169pub mod code {
171 pub use crate::code::{changes, file, tree, worktree_file, worktree_view};
172}
173
174pub mod init {
176 pub use crate::init::{commit_written, finish, prepare, preview, root_of};
177}
178
179pub mod current {
181 pub use crate::current::list;
182}
183
184pub mod handoff {
186 pub use crate::handoff::{PrOptions, pr};
187}
188
189pub mod worktree {
191 pub use crate::worktree::state_dir;
192}
193
194pub mod github {
196 pub use crate::github::{
197 Ctx, RepoEntry, description, issue, issues, login_with_token, pr_for, reach, refused, repo,
198 repositories, started, status, valid_slug,
199 };
200
201 pub mod auth {
203 pub use crate::github::auth::{Pending, client_id, start, wait};
204 }
205
206 pub mod http {
208 pub use crate::github::http::oauth;
209 }
210}
211
212#[derive(Debug, Clone, Copy)]
214pub struct FormatWords {
215 pub name: &'static str,
217 pub unit: &'static str,
219}
220
221#[must_use]
223pub fn format_words(root: &Path) -> FormatWords {
224 let format = crate::format::at(root);
225 FormatWords {
226 name: format.wording().name,
227 unit: format.messages().unit,
228 }
229}
230
231#[derive(Debug, Clone, serde::Serialize)]
235pub struct PlanningWords {
236 pub creates: Option<String>,
238 pub toward: Vec<String>,
240 pub checks: Option<String>,
242 pub revises: Option<String>,
244}
245
246#[must_use]
248pub fn planning_words(root: &Path) -> PlanningWords {
249 let p = crate::format::at(root).planning();
250 let full = |s: &str| format!("{}{s}", p.prefix);
251 let creates = p.creates.first().map(|c| full(c));
252 PlanningWords {
253 toward: (p.toward_tasks)(false)
254 .iter()
255 .map(|s| full(s))
256 .filter(|s| Some(s) != creates.as_ref())
257 .collect(),
258 creates,
259 checks: p.checks.map(full),
260 revises: p.revises.map(full),
261 }
262}
263
264#[must_use]
266pub fn create_skill(root: &Path) -> Option<String> {
267 let planning = crate::format::at(root).planning();
268 planning
269 .creates
270 .first()
271 .map(|c| format!("{}{c}", planning.prefix))
272}
273
274#[must_use]
277pub fn commit_patch(root: &Path, commit: &str) -> String {
278 commit_patch_of(root, commit)
279}
280
281fn reachable(git: &crate::git::Git, id: &str) -> bool {
283 if git
284 .succeeds(&["merge-base", "--is-ancestor", id, "HEAD"])
285 .unwrap_or(false)
286 {
287 return true;
288 }
289 git.line(&[
290 "for-each-ref",
291 "--count=1",
292 "--format=%(refname)",
293 "--contains",
294 id,
295 "refs/heads",
296 "refs/speccoder/attempts",
297 ])
298 .is_ok_and(|l| !l.trim().is_empty())
299}
300
301fn commit_patch_of(root: &Path, commit: &str) -> String {
302 let git = crate::git::Git::at(root);
303 let Ok(id) = git.line(&[
305 "rev-parse",
306 "--verify",
307 "-q",
308 &format!("{commit}^{{commit}}"),
309 ]) else {
310 return String::new();
311 };
312 if !reachable(&git, &id) {
316 return String::new();
317 }
318 git.run(&["show", "--no-color", "--patch", "--format=%h %s%n%n%b", &id])
319 .map(|b| String::from_utf8_lossy(&b).into_owned())
320 .unwrap_or_default()
321}