agentty 0.8.11

Agentty is an ADE (Agentic Development Environment) for structured, controllable AI-assisted software development.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
//! Helpers for parsing and formatting roadmap-backed task content.

use ratatui::style::{Modifier, Style};
use ratatui::text::{Line, Span};

use crate::ui::style;
use crate::ui::text_util::wrapped_line_count;

/// Supported roadmap queues rendered in the `Tasks` page.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
enum RoadmapQueue {
    /// Fully expanded work ready for immediate execution.
    ReadyNow,
    /// Compact next-up work waiting for promotion.
    QueuedNext,
    /// Strategic backlog intentionally kept out of the active queue.
    Parked,
}

impl RoadmapQueue {
    /// Returns the queues in the rendered order.
    const ALL: [Self; 3] = [Self::ReadyNow, Self::QueuedNext, Self::Parked];

    /// Returns the exact roadmap section heading for one queue.
    fn title(self) -> &'static str {
        match self {
            Self::ReadyNow => "Ready Now",
            Self::QueuedNext => "Queued Next",
            Self::Parked => "Parked",
        }
    }

    /// Returns the accent color used for one queue heading.
    fn color(self) -> ratatui::style::Color {
        match self {
            Self::ReadyNow => style::palette::warning(),
            Self::QueuedNext => style::palette::accent(),
            Self::Parked => style::palette::text_muted(),
        }
    }
}

/// Parsed roadmap overview ready for queue-by-queue rendering.
struct RoadmapOverview {
    /// Cards from the `Ready Now` section.
    ready_now: Vec<RoadmapCard>,
    /// Cards from the `Queued Next` section.
    queued_next: Vec<RoadmapCard>,
    /// Cards from the `Parked` section.
    parked: Vec<RoadmapCard>,
}

impl RoadmapOverview {
    /// Returns the cards for one queue.
    fn items(&self, queue: RoadmapQueue) -> &[RoadmapCard] {
        match queue {
            RoadmapQueue::ReadyNow => &self.ready_now,
            RoadmapQueue::QueuedNext => &self.queued_next,
            RoadmapQueue::Parked => &self.parked,
        }
    }
}

/// One rendered roadmap card extracted from markdown headings and subsections.
struct RoadmapCard {
    /// Optional assignee shown for `Ready Now` work.
    assignee: Option<String>,
    /// Optional short identifier extracted from the roadmap UUID heading.
    short_id: Option<String>,
    /// Compact extra detail line rendered under the outcome summary.
    detail: Option<String>,
    /// Outcome-style summary shown as the primary description.
    outcome: Option<String>,
    /// Stream prefix from the markdown heading.
    stream: String,
    /// Human-readable task title from the markdown heading.
    title: String,
}

/// One parsed subsection body inside a roadmap card.
struct RoadmapSubsection {
    /// Subsection title without markdown heading markers.
    title: String,
    /// Trimmed subsection body content.
    body: String,
}

/// Builds styled queue-and-card lines from one roadmap markdown document.
pub(crate) fn roadmap_task_lines(content: &str) -> Vec<Line<'static>> {
    let overview = parse_roadmap_overview(content);
    let mut lines = vec![
        Line::from(Span::styled(
            "Source: docs/plan/roadmap.md",
            Style::default().fg(style::palette::text_muted()),
        )),
        Line::from(vec![
            Span::styled(
                "Ready Now ",
                Style::default().fg(RoadmapQueue::ReadyNow.color()),
            ),
            Span::styled(
                overview.ready_now.len().to_string(),
                Style::default()
                    .fg(style::palette::text())
                    .add_modifier(Modifier::BOLD),
            ),
            Span::raw("  "),
            Span::styled(
                "Queued Next ",
                Style::default().fg(RoadmapQueue::QueuedNext.color()),
            ),
            Span::styled(
                overview.queued_next.len().to_string(),
                Style::default()
                    .fg(style::palette::text())
                    .add_modifier(Modifier::BOLD),
            ),
            Span::raw("  "),
            Span::styled("Parked ", Style::default().fg(RoadmapQueue::Parked.color())),
            Span::styled(
                overview.parked.len().to_string(),
                Style::default()
                    .fg(style::palette::text())
                    .add_modifier(Modifier::BOLD),
            ),
        ]),
    ];

    for queue in RoadmapQueue::ALL {
        lines.push(Line::default());
        lines.push(queue_header_line(queue, overview.items(queue).len()));

        if overview.items(queue).is_empty() {
            lines.push(indented_line(
                "No roadmap items.",
                Style::default().fg(style::palette::text_muted()),
            ));

            continue;
        }

        for card in overview.items(queue) {
            lines.extend(card_lines(queue, card));
        }
    }

    lines
}

/// Returns the maximum vertical scroll offset for rendered roadmap lines in
/// one viewport.
pub(crate) fn roadmap_task_max_scroll_offset(
    lines: &[Line<'static>],
    inner_width: u16,
    viewport_height: u16,
) -> u16 {
    if viewport_height == 0 {
        return 0;
    }

    wrapped_line_count(lines, inner_width).saturating_sub(viewport_height)
}

/// Parses one roadmap markdown document into queue cards.
fn parse_roadmap_overview(content: &str) -> RoadmapOverview {
    RoadmapOverview {
        ready_now: parse_queue_cards(
            &queue_section_body(content, RoadmapQueue::ReadyNow),
            RoadmapQueue::ReadyNow,
        ),
        queued_next: parse_queue_cards(
            &queue_section_body(content, RoadmapQueue::QueuedNext),
            RoadmapQueue::QueuedNext,
        ),
        parked: parse_queue_cards(
            &queue_section_body(content, RoadmapQueue::Parked),
            RoadmapQueue::Parked,
        ),
    }
}

/// Returns the raw markdown body for one roadmap queue section.
fn queue_section_body(content: &str, queue: RoadmapQueue) -> String {
    let mut body_lines = Vec::new();
    let mut is_in_queue = false;

    for line in content.lines() {
        if let Some(section_title) = line.strip_prefix("## ").map(str::trim) {
            is_in_queue = section_title == queue.title();

            continue;
        }

        if is_in_queue {
            body_lines.push(line.to_string());
        }
    }

    body_lines.join("\n")
}

/// Parses all cards inside one queue body.
fn parse_queue_cards(content: &str, queue: RoadmapQueue) -> Vec<RoadmapCard> {
    let mut items = Vec::new();
    let mut current_heading: Option<String> = None;
    let mut current_body = Vec::new();

    for line in content.lines() {
        if let Some(heading) = line.strip_prefix("### ").map(str::trim) {
            if let Some(previous_heading) = current_heading.replace(heading.to_string()) {
                let card_body = current_body.join("\n");
                items.push(parse_card(queue, &previous_heading, &card_body));
                current_body.clear();
            }

            continue;
        }

        if current_heading.is_some() {
            current_body.push(line.to_string());
        }
    }

    if let Some(heading) = current_heading {
        let card_body = current_body.join("\n");
        items.push(parse_card(queue, &heading, &card_body));
    }

    items
}

/// Parses one queue card from its heading and subsection markdown body.
fn parse_card(queue: RoadmapQueue, heading: &str, content: &str) -> RoadmapCard {
    let (short_id, stream, title) = parse_card_heading(heading);
    let subsections = parse_subsections(content);
    let assignee = subsection_body(&subsections, "Assignee").map(clean_inline_text);
    let outcome = match queue {
        RoadmapQueue::ReadyNow => subsection_body(&subsections, "Usable outcome"),
        RoadmapQueue::QueuedNext | RoadmapQueue::Parked => subsection_body(&subsections, "Outcome"),
    }
    .map(clean_inline_text);
    let detail = match queue {
        RoadmapQueue::ReadyNow => subsection_body(&subsections, "Substeps")
            .map(checklist_summary)
            .filter(|summary| !summary.is_empty())
            .map(|summary| format!("Substeps: {summary}")),
        RoadmapQueue::QueuedNext | RoadmapQueue::Parked => {
            let promote_when = subsection_body(&subsections, "Promote when")
                .map(clean_inline_text)
                .filter(|text| !text.is_empty())
                .map(|text| format!("Promote when: {text}"));
            let depends_on = subsection_body(&subsections, "Depends on")
                .map(clean_inline_text)
                .filter(|text| !text.is_empty())
                .map(|text| format!("Depends on: {text}"));

            promote_when.or(depends_on)
        }
    };

    RoadmapCard {
        assignee,
        short_id,
        detail,
        outcome,
        stream,
        title,
    }
}

/// Parses `[UUID] Stream: Title` into a short id, stream, and title.
fn parse_card_heading(heading: &str) -> (Option<String>, String, String) {
    let mut short_id = None;
    let mut remainder = heading.trim();

    if remainder.starts_with('[')
        && let Some(close_bracket_index) = remainder.find(']')
    {
        let id = &remainder[1..close_bracket_index];
        short_id = Some(id.chars().take(8).collect());
        remainder = remainder[(close_bracket_index + 1)..].trim();
    }

    if let Some(separator_index) = remainder.find(": ") {
        return (
            short_id,
            remainder[..separator_index].trim().to_string(),
            remainder[(separator_index + 2)..].trim().to_string(),
        );
    }

    (short_id, String::new(), remainder.to_string())
}

/// Parses `####` subsection blocks inside one roadmap card body.
fn parse_subsections(content: &str) -> Vec<RoadmapSubsection> {
    let mut subsections = Vec::new();
    let mut current_title: Option<String> = None;
    let mut current_body = Vec::new();

    for line in content.lines() {
        if let Some(title) = line.strip_prefix("#### ").map(str::trim) {
            if let Some(previous_title) = current_title.replace(title.to_string()) {
                subsections.push(RoadmapSubsection {
                    title: previous_title,
                    body: current_body.join("\n").trim().to_string(),
                });
                current_body.clear();
            }

            continue;
        }

        if current_title.is_some() {
            current_body.push(line.to_string());
        }
    }

    if let Some(title) = current_title {
        subsections.push(RoadmapSubsection {
            title,
            body: current_body.join("\n").trim().to_string(),
        });
    }

    subsections
}

/// Returns the body for one subsection title.
fn subsection_body<'a>(subsections: &'a [RoadmapSubsection], title: &str) -> Option<&'a str> {
    subsections
        .iter()
        .find(|subsection| subsection.title == title)
        .map(|subsection| subsection.body.as_str())
}

/// Collapses markdown-ish inline text into one compact display line.
fn clean_inline_text(content: &str) -> String {
    content
        .replace("**", "")
        .split_whitespace()
        .collect::<Vec<_>>()
        .join(" ")
}

/// Collapses checklist bullets into one semicolon-delimited summary line.
fn checklist_summary(content: &str) -> String {
    content
        .lines()
        .filter_map(|line| {
            line.trim()
                .strip_prefix("- [ ] ")
                .or_else(|| line.trim().strip_prefix("- [x] "))
        })
        .map(clean_inline_text)
        .collect::<Vec<_>>()
        .join("; ")
}

/// Builds the styled header line for one queue.
fn queue_header_line(queue: RoadmapQueue, item_count: usize) -> Line<'static> {
    let noun = if item_count == 1 { "item" } else { "items" };

    Line::from(vec![
        Span::styled(
            queue.title(),
            Style::default()
                .fg(queue.color())
                .add_modifier(Modifier::BOLD),
        ),
        Span::styled(
            format!(" ({item_count} {noun})"),
            Style::default().fg(style::palette::text_muted()),
        ),
    ])
}

/// Builds the rendered lines for one roadmap card.
fn card_lines(queue: RoadmapQueue, card: &RoadmapCard) -> Vec<Line<'static>> {
    let mut lines = vec![card_heading_line(card)];
    let metadata_line = card_metadata_line(card);
    if let Some(line) = metadata_line {
        lines.push(line);
    }

    if let Some(outcome) = card.outcome.as_deref() {
        lines.push(indented_label_line("Outcome", outcome));
    }

    if let Some(detail) = card.detail.as_deref() {
        lines.push(indented_line(
            detail,
            Style::default().fg(style::palette::text_muted()),
        ));
    }

    if queue != RoadmapQueue::ReadyNow
        && card.detail.is_none()
        && let Some(card_id) = card.short_id.as_deref()
    {
        lines.push(indented_line(
            &format!("Roadmap id: {card_id}"),
            Style::default().fg(style::palette::text_muted()),
        ));
    }

    lines.push(Line::default());

    lines
}

/// Builds the styled bullet heading line for one roadmap card.
fn card_heading_line(card: &RoadmapCard) -> Line<'static> {
    let mut spans = vec![
        Span::raw("• "),
        Span::styled(
            card.stream.clone(),
            Style::default()
                .fg(style::palette::accent_soft())
                .add_modifier(Modifier::BOLD),
        ),
    ];

    if !card.stream.is_empty() {
        spans.push(Span::raw(": "));
    }

    spans.push(Span::styled(
        card.title.clone(),
        Style::default()
            .fg(style::palette::text())
            .add_modifier(Modifier::BOLD),
    ));

    Line::from(spans)
}

/// Builds the optional metadata line for one roadmap card.
fn card_metadata_line(card: &RoadmapCard) -> Option<Line<'static>> {
    let mut segments = Vec::new();

    if let Some(short_id) = card.short_id.as_deref() {
        segments.push(format!("[{short_id}]"));
    }

    if let Some(assignee) = card.assignee.as_deref() {
        segments.push(assignee.to_string());
    }

    if segments.is_empty() {
        return None;
    }

    Some(indented_line(
        &segments.join("  "),
        Style::default().fg(style::palette::text_muted()),
    ))
}

/// Builds one indented label-and-text line.
fn indented_label_line(label: &str, content: &str) -> Line<'static> {
    Line::from(vec![
        Span::raw("  "),
        Span::styled(
            format!("{label}: "),
            Style::default().fg(style::palette::text_muted()),
        ),
        Span::raw(content.to_string()),
    ])
}

/// Builds one indented text-only line.
fn indented_line(content: &str, style: Style) -> Line<'static> {
    Line::from(vec![
        Span::raw("  "),
        Span::styled(content.to_string(), style),
    ])
}

#[cfg(test)]
mod tests {
    use super::*;

    /// Converts styled lines to plain text for stable assertions.
    fn line_text(lines: Vec<Line<'static>>) -> Vec<String> {
        lines
            .into_iter()
            .map(|line| {
                line.spans
                    .into_iter()
                    .map(|span| span.content.to_string())
                    .collect::<String>()
            })
            .collect()
    }

    #[test]
    fn roadmap_task_lines_include_all_queue_summaries() {
        // Arrange
        let roadmap = r"
## Ready Now
### [ca014af3-5cd0-4567-bf11-3495765dcf6f] Forge: Add GitHub pull-request publish shortcut in session chat
#### Assignee
`@minev-dev`
#### Why now
Existing workflow pieces already exist.
#### Usable outcome
Pressing `p` creates or refreshes the pull request.
#### Substeps
- [ ] **Route review-request publishing through the `p` session-chat shortcut only.**
- [ ] **Reuse the existing review-request workflow for GitHub sessions.**
#### Tests
- [ ] Cover the new shortcut.
#### Docs
- [ ] Update workflow docs.

## Queued Next
### [17a9e2ba-0b7d-407d-9cd4-72807ef7bc1f] Delivery: Add project commit strategy selection
#### Outcome
Let each project stored in Agentty choose its expected landing path.
#### Promote when
Promote when maintainers want review and publish actions to respect project delivery flow.
#### Depends on
`[ca014af3] Forge`

## Parked
### [6bb0cae7-c07c-4fab-ae6b-e74444d3f0f0] Planning: Move roadmap tasks to a single canonical TOML plan
#### Outcome
Let Agentty manage roadmap tasks through one canonical `docs/plan/roadmap.toml` file.
#### Promote when
Promote when maintainers want direct task management in Agentty.
#### Depends on
`None`
";

        // Act
        let lines = line_text(roadmap_task_lines(roadmap));

        // Assert
        assert!(lines.iter().any(|line| line.contains("Ready Now 1")));
        assert!(lines.iter().any(|line| {
            line.contains("Forge: Add GitHub pull-request publish shortcut in session chat")
        }));
        assert!(
            lines
                .iter()
                .any(|line| line.contains("Substeps: Route review-request publishing"))
        );
        assert!(
            lines
                .iter()
                .any(|line| { line.contains("Delivery: Add project commit strategy selection") })
        );
        assert!(
            lines
                .iter()
                .any(|line| line.contains("Promote when: Promote when maintainers want"))
        );
        assert!(lines.iter().any(|line| {
            line.contains("Planning: Move roadmap tasks to a single canonical TOML plan")
        }));
    }

    #[test]
    fn roadmap_task_lines_show_empty_queue_state() {
        // Arrange
        let roadmap = "## Ready Now\n\n## Queued Next\n\n## Parked\n";

        // Act
        let lines = line_text(roadmap_task_lines(roadmap));

        // Assert
        assert_eq!(
            lines
                .iter()
                .filter(|line| line.contains("No roadmap items."))
                .count(),
            3
        );
    }

    #[test]
    fn roadmap_task_max_scroll_offset_counts_wrapped_lines() {
        // Arrange
        let lines = vec![Line::from("alpha beta gamma"), Line::from("delta epsilon")];

        // Act
        let max_scroll_offset = roadmap_task_max_scroll_offset(&lines, 5, 2);

        // Assert
        assert_eq!(max_scroll_offset, 3);
    }
}