Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 65 additions & 72 deletions scratchpad/architecture.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,59 @@
# Architecture Diagram

> Last updated: 2026-04-18 · Source: [Run §24601274706](https://github.com/github/gh-aw/actions/runs/24601274706)
> Last updated: 2026-04-19 · Source: [Run §24625358414](https://github.com/github/gh-aw/actions/runs/24625358414)

## Overview

This diagram shows the package structure and dependencies of the `gh-aw` codebase.

```
┌────────────────────────────────────────────────────────────────────────────────────────────┐
│ ENTRY POINTS │
│ │
│ ┌──────────────────────────────────────────┐ ┌────────────────────────────────────┐ │
│ │ cmd/gh-aw │ │ cmd/gh-aw-wasm │ │
│ │ Main CLI binary │ │ WebAssembly target │ │
│ │ imports: cli,console,constants, │ │ imports: parser, workflow │ │
│ │ parser, workflow │ │ │ │
│ └────────────┬─────────────────────────────┘ └──────────────┬─────────────────────┘ │
│ │ │ │
├─────────────────┼─────────────────────────────────────────────────┼─────────────────────────┤
│ │ CORE PACKAGES │ │
│ ▼ ▼ │
│ ┌──────────────────────────────────┐ ┌────────────────────────────────────────────┐ │
│ │ pkg/cli │ │ pkg/workflow │ │
│ │ Command dispatch, flag handling,│────▶│ Workflow compilation and GitHub Actions │ │
│ │ and CLI command execution │ │ YAML generation │ │
│ └───┬───────────────────────────┬──┘ └───────────────────┬────────────────┬───────┘ │
│ │ │ │ │ │
│ │ │ ▼ ▼ │
│ │ │ ┌─────────────────┐ ┌──────────────────┐ │
│ │ │ │ pkg/parser │ │ pkg/actionpins │ │
│ │ │ │ Markdown/YAML │ │ GitHub Actions │ │
│ │ │ │ frontmatter & │ │ pin version │ │
│ │ │ │ schema parsing │ │ resolution │ │
│ │ │ └────────┬────────┘ └──────────┬───────┘ │
│ │ ┌──────────────────────┼──────────────────────┘ │ │
│ │ │ │ │ │
│ │ ▼ ▼ ▼ │
│ │ ┌──────────────────────────────────────────────────────────────────────────┐ │
│ ├─▶│ pkg/console │ │
│ │ │ Terminal UI: spinners, message formatting, styled output rendering │ │
│ │ └──────────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ │ ┌──────────────────────────────────────────┐ │
│ ├─▶│ pkg/agentdrain │ │
│ │ │ Agent log streaming and drain for CI │ │
│ │ └──────────────────────────────────────────┘ │
│ │ ┌──────────────────────────────────────────┐ │
│ └─▶│ pkg/stats │ │
│ │ Numerical statistics and metrics │ │
│ └──────────────────────────────────────────┘ │
├────────────────────────────────────────────────────────────────────────────────────────────┤
│ UTILITY PACKAGES │
│ ┌──────────┐ ┌────────┐ ┌────────┐ ┌──────────┐ ┌─────────┐ ┌──────────┐ ┌──────┐ │
│ │constants │ │ types │ │ logger │ │ fileutil │ │ gitutil │ │ repoutil │ │envutil│ │
│ └──────────┘ └────────┘ └────────┘ └──────────┘ └─────────┘ └──────────┘ └──────┘ │
│ ┌────────────┐ ┌──────────┐ ┌──────────┐ ┌────────────┐ ┌───────┐ ┌────────┐ │
│ │ stringutil │ │ sliceutil│ │ typeutil │ │ semverutil │ │ tty │ │ styles │ │
│ └────────────┘ └──────────┘ └──────────┘ └────────────┘ └───────┘ └────────┘ │
│ ┌──────────┐ ┌──────────┐ │
│ │ timeutil │ │ testutil │ (consumed by all core packages above) │
│ └──────────┘ └──────────┘ │
└────────────────────────────────────────────────────────────────────────────────────────────┘
┌──────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ENTRY POINTS │
│ │
│ ┌─────────────────────────┐ ┌───────────────────────────┐ │
│ │ cmd/gh-aw │ │ cmd/gh-aw-wasm │ │
│ │ (main CLI binary) │ │ (WebAssembly target) │ │
│ └─────────────┬───────────┘ └─────────────┬─────────────┘ │
│ │ │ │
├─────────────────────┼───────────────────────────────────────────────┼────────────────────────────┤
│ CORE PACKAGES ▼ ▼ │
│ │
│ ┌─────────────────────────┐ ┌─────────────────────────┐ ┌──────────────────────────┐ │
│ │ pkg/cli │───▶│ pkg/workflow │───▶│ pkg/parser │ │
│ │ Command implementations │ │ Workflow compile engine │ │ Markdown/YAML parsing │ │
│ └──────────┬───────────────┘ └───────────┬─────────────┘ └──────────────────────────┘ │
│ │ │ │
Comment on lines +24 to +25
Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diagram implies pkg/parser is only reached via pkg/workflow (pkg/cli → pkg/workflow → pkg/parser), but pkg/cli directly imports pkg/parser in many files (e.g., pkg/cli/commands.go). Consider adding a direct pkg/cli → pkg/parser edge (or otherwise adjusting the diagram) so direct dependencies are accurately represented.

Suggested change
│ └──────────┬───────────────┘ └───────────┬─────────────┘ └──────────────────────────┘ │
│ │ │ │
│ └──────────┬───────────────┘ └───────────┬─────────────┘ └────────────▲─────────────┘ │
│ │ │ │ │
│ └────────────────────────────────────────────────────────────────▶│ │

Copilot uses AI. Check for mistakes.
│ ┌──────────▼──────────────┐ ┌────────────▼────────────┐ │
│ │ pkg/agentdrain │ │ pkg/actionpins │ │
│ │ Agent log drain/cluster│ │ Action pin resolution │ │
│ └─────────────────────────┘ └─────────────────────────┘ │
│ │ │ │
│ └──────────────────┬─────────────┘ │
│ ▼ │
│ ┌──────────────────────────────────────────────┐ │
│ │ pkg/console │ │
│ │ Terminal UI & message formatting │ │
│ └──────────────────────────────────────────────┘ │
Comment on lines +26 to +36
Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This merged connector suggests pkg/agentdrain depends on pkg/console, but pkg/agentdrain does not import pkg/console (while pkg/actionpins does). Update the arrows/layout so the diagram doesn’t imply an agentdrain → console dependency that doesn’t exist.

Copilot uses AI. Check for mistakes.
│ │ │
├────────────────────────────────┼──────────────────────────────────────────────────────────────────┤
│ UTILITY PACKAGES ▼ │
│ │
│ Rendering: ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ logger │ │ styles │ │ tty │ │
│ └──────────┘ └──────────┘ └──────────┘ │
│ │
│ Data: ┌──────────┐ ┌──────────┐ ┌───────────┐ ┌───────────┐ ┌─────────┐ │
│ │ types │ │ typeutil │ │ constants │ │ sliceutil │ │ stats │ │
│ └──────────┘ └──────────┘ └───────────┘ └───────────┘ └─────────┘ │
│ │
│ Files/Git: ┌──────────┐ ┌──────────┐ ┌───────────┐ ┌───────────┐ ┌───────────┐ │
│ │ fileutil │ │ gitutil │ │ repoutil │ │ semverutil│ │ stringutil│ │
│ └──────────┘ └──────────┘ └───────────┘ └───────────┘ └───────────┘ │
│ │
│ Others: ┌──────────┐ ┌──────────┐ ┌───────────┐ │
│ │ envutil │ │ timeutil │ │ testutil │ │
│ └──────────┘ └──────────┘ └───────────┘ │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘
```

## Package Reference
Expand All @@ -69,25 +62,25 @@ This diagram shows the package structure and dependencies of the `gh-aw` codebas
|---------|-------|-------------|
| cmd/gh-aw | Entry | Main CLI binary — imports cli, console, constants, parser, workflow |
| cmd/gh-aw-wasm | Entry | WebAssembly compilation target — imports parser, workflow |
| pkg/cli | Core | Command dispatch, flag handling, and CLI command execution |
| pkg/workflow | Core | Workflow compilation and GitHub Actions YAML generation |
| pkg/parser | Core | Markdown/YAML/frontmatter parsing and schema validation |
| pkg/console | Core | Terminal UI: spinners, message formatting, styled output rendering |
| pkg/agentdrain | Core | Agent log streaming and drain for CI workflows |
| pkg/actionpins | Core | GitHub Actions pin version resolution |
| pkg/stats | Core | Numerical statistics and metrics collection |
| pkg/cli | Core | Command implementations for all gh-aw CLI commands |
| pkg/workflow | Core | Workflow compilation engine (markdown → GitHub Actions YAML) |
| pkg/parser | Core | Markdown frontmatter parsing and content extraction |
Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pkg/parser is described as only doing “Markdown frontmatter parsing and content extraction”, but the package also performs YAML parsing/validation (e.g., uses goccy/go-yaml and has YAML import helpers). Consider expanding this description to reflect the YAML-related responsibilities as well.

Suggested change
| pkg/parser | Core | Markdown frontmatter parsing and content extraction |
| pkg/parser | Core | Markdown frontmatter parsing, content extraction, and YAML parsing/validation helpers |

Copilot uses AI. Check for mistakes.
| pkg/console | Core | Terminal UI rendering and message formatting |
| pkg/agentdrain | Core | Agent log drain and cluster template detection |
| pkg/actionpins | Core | GitHub Actions version pin resolution |
| pkg/logger | Utility | Namespace-based debug logging with zero overhead |
Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The table claims pkg/logger has “zero overhead”, but constructing a logger and calling Print/Printf still incurs some overhead even when disabled (early return avoids formatting/output, but not the call itself). Consider rewording to something like “minimal overhead when disabled” or restoring the previous phrasing to avoid overstating the guarantee.

Suggested change
| pkg/logger | Utility | Namespace-based debug logging with zero overhead |
| pkg/logger | Utility | Namespace-based debug logging with minimal overhead when disabled |

Copilot uses AI. Check for mistakes.
| pkg/styles | Utility | Centralized style and color definitions for terminal output |
| pkg/tty | Utility | TTY (terminal) detection utilities |
| pkg/types | Utility | Shared type definitions used across gh-aw packages |
| pkg/typeutil | Utility | General-purpose type conversion utilities |
| pkg/constants | Utility | Shared constants and semantic type aliases |
| pkg/types | Utility | Shared type definitions used across packages |
| pkg/logger | Utility | Namespace-based debug logging with zero overhead when disabled |
| pkg/sliceutil | Utility | Utility functions for working with slices |
| pkg/stats | Utility | Numerical statistics utilities for metric collection |
| pkg/fileutil | Utility | File path and file operation utilities |
| pkg/gitutil | Utility | Git repository utility functions |
| pkg/gitutil | Utility | Git and GitHub API utility functions |
Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pkg/gitutil is described as “Git and GitHub API utility functions”, but the package appears to focus on git CLI helpers plus GitHub-related string/error parsing (no GitHub API client calls). Consider rewording to “Git and GitHub-related utilities” (or similar) to avoid implying it wraps the GitHub API.

Suggested change
| pkg/gitutil | Utility | Git and GitHub API utility functions |
| pkg/gitutil | Utility | Git and GitHub-related utility functions |

Copilot uses AI. Check for mistakes.
| pkg/stringutil | Utility | String manipulation utility functions |
| pkg/repoutil | Utility | GitHub repository slug and URL utilities |
| pkg/semverutil | Utility | Semantic versioning primitives |
| pkg/envutil | Utility | Environment variable reading and validation utilities |
| pkg/stringutil | Utility | String manipulation utilities including ANSI stripping |
| pkg/sliceutil | Utility | Generic slice operation utilities |
| pkg/typeutil | Utility | General-purpose type conversion utilities |
| pkg/semverutil | Utility | Shared semantic versioning primitives |
| pkg/tty | Utility | TTY (terminal) detection utilities |
| pkg/styles | Utility | Terminal style definitions (no-op for WASM builds) |
| pkg/timeutil | Utility | Time formatting and duration utilities |
| pkg/timeutil | Utility | Duration and time formatting utilities |
| pkg/testutil | Utility | Shared test helper utilities |
Loading