Skip to content

Add CodeFlow Card GitHub Action (v1)#53

Merged
braedonsaunders merged 2 commits into
mainfrom
add-codeflow-card
Apr 28, 2026
Merged

Add CodeFlow Card GitHub Action (v1)#53
braedonsaunders merged 2 commits into
mainfrom
add-codeflow-card

Conversation

@braedonsaunders
Copy link
Copy Markdown
Owner

Summary

Ships v1 of the CodeFlow Card — a same-repo subdirectory GitHub Action at card/ that drops a self-updating SVG card on any repo's README, recomputed on every merge.

The Action loads codeflow's analyzer directly out of index.html and runs it in a Node vm context. Same analyzer as the web app, zero drift, single source of truth.

What's in the card

  • Health grade (A+→F) with delta arrow vs the last run
  • Scale — files / functions / LOC / languages with 30-run sparklines
  • Fragility — top 3 highest blast-radius files (the numbers nobody usually shows)
  • Hidden costs — circular deps, dead code %, average coupling

Plus opt-in PR receipts: a thermal-receipt-style sticky comment on every merged PR itemizing the merge (+/- LOC, blast-radius before/after, grade delta).

Implementation notes

  • Sentinel comments: two pairs in index.htmlCODEFLOW_ANALYZER_* wraps Parser + buildAnalysisData, CODEFLOW_METRICS_* wraps calcBlast + calcHealth. The existing Worker bootstrap and tests/codeflow-golden.test.mjs both switch to these sentinels.
  • Zero npm deps. Plain Node 20 with built-ins only — no node_modules to maintain.
  • Same-repo subdir action: users install with uses: braedonsaunders/codeflow/card@v1. One repo, one star count, one analyzer.
  • README gets a promo section near the top + a Features bullet linking to card/README.md.

Test plan

  • node --test tests/codeflow-golden.test.mjs passes (sentinel switch is non-breaking)
  • Local Action dry-run on tests/fixtures/golden-world writes a valid SVG + JSON state
  • Local Action dry-run on the codeflow repo itself produces sensible output (grade B, 22 files, 493 fns, top blast index.html)
  • Live GitHub Actions run on a consumer repo (queued — bidwright PR opens against @main, will activate once this merges)
  • Tag v1 after merge so users can pin to a stable ref

Follow-ups (deferred to v1.1)

  • Light theme polish + auto theme via <picture> element
  • .github/codeflow-card.yml config file for power users
  • SVG receipt variant for richer PR comments

🤖 Generated with Claude Code

Ships a same-repo subdirectory action at card/ that runs codeflow's
analyzer headlessly and writes a self-updating SVG card to the consuming
repo's README. Same analyzer as the web app — the Action loads codeflow's
index.html and runs the analyzer block in a Node vm context, guaranteeing
zero drift.

- Sentinel comments wrap the analyzer block (CODEFLOW_ANALYZER_*) and the
  derived metrics block (CODEFLOW_METRICS_*) in index.html. The existing
  Worker bootstrap and golden test switch to the sentinels.
- Action panels: health grade w/ delta, scale (files/fns/LOC/langs) with
  sparklines, fragility (top blast radius), hidden costs.
- Optional opt-in PR receipts: sticky comment on each merged PR with a
  thermal-receipt-style itemization of the merge.
- State persists to .github/codeflow-card.json so sparklines and deltas
  populate after the second run.
- Zero npm deps — ships as plain Node 20 with built-ins only.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
codeflow Ready Ready Preview, Comment Apr 28, 2026 2:40am

Request Review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c60183ea49

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread card/lib/collect.js
return;
}
for (const entry of entries) {
if (entry.name.startsWith('.git')) continue;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Limit .git skip to the actual VCS directory

The repo walk currently skips any entry whose name starts with .git, which also excludes .github, .gitignore, .gitattributes, and .gitmodules. That means valid project files (for example scripts under .github/actions) are never analyzed, so file/function/LOC totals and dependency-derived metrics can be systematically underreported compared with the main analyzer behavior.

Useful? React with 👍 / 👎.

Comment thread card/index.js

const { Parser, buildAnalysisData, calcBlast, calcHealth } = loadAnalyzer(indexHtmlPath);

const { analyzed, allFns } = await buildAnalyzed(repoRoot, Parser);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Exclude generated state/output files from analysis

Analysis runs across the whole workspace before rendering, but the configured state/output paths are never excluded. If a user sets state outside a skipped directory (for example codeflow-card.json at repo root), the second run starts analyzing its own history file, and each subsequent run inflates LOC/language trends even when source code is unchanged.

Useful? React with 👍 / 👎.

Style variants (selected via the new `style:` input, default `compact`):
- compact   720x140  Grade left, scale stats right
- row       720x60   Status-bar strip
- minimal   720x40   Single mono text line
- hero      720x200  Splashy gradient + grade + 2x2 grid
- detailed  720x900+ Information-rich: grade, scale, languages bar,
            composition (connections, tests, folders, fn stats, patterns),
            top folders, fragility, hidden costs

Privacy controls so a public README doesn't have to display judgment:
- show-grade: false   hides the letter grade everywhere
- show-score: false   hides the /100 score, keeps the letter

Configurable accent (sparklines, link, pin):
- accent: <preset>    purple|teal|cyan|green|pink|blue|amber|red
- accent: <css color> any CSS color, e.g. #ff6b6b

Footer "powered by codeflow" is now wrapped in <a> linking to the codeflow
repo. Falls back to plain text in <img> contexts where SVG links don't fire.

State snapshot expanded to capture top folders, top languages with %,
function size stats, test file ratio, patterns, duplicates, layer
violations — all surfaced in `detailed`.

card/examples/ holds 10 ready-rendered SVGs (compact, compact-private,
compact-teal, compact-pink, row, minimal, hero, hero-private, detailed,
detailed-private) generated against this repo, embedded in the README
as a style gallery.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@braedonsaunders braedonsaunders merged commit 7bb3a1b into main Apr 28, 2026
3 checks passed
@braedonsaunders braedonsaunders deleted the add-codeflow-card branch April 28, 2026 02:40
braedonsaunders added a commit to braedonsaunders/bidwright that referenced this pull request Apr 28, 2026
* Add CodeFlow Card workflow

Installs braedonsaunders/codeflow/card on every merge to main and every
closed PR. Renders an auto-updating SVG card to .github/codeflow-card.svg
which can be embedded in the README.

Will only function once braedonsaunders/codeflow#53 (which adds the card/
subdirectory action) is merged.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Configure private compact card + initial SVG + README image

Workflow uses style: compact with show-grade/show-score: false so a
public README shows codebase scale (files, fns, LOC, langs, tests)
without a letter grade or score.

Pre-renders the initial SVG so the README image is live the moment
this PR merges; subsequent merges to main / closed PRs will overwrite
.github/codeflow-card.svg automatically.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Braedon Saunders <braedonsaunders@Braedons-MacBook-Pro.local>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant