Add reposcan domain package#1304
Open
Klaney wants to merge 9 commits into
Open
Conversation
Contributor
Author
pete-woods
reviewed
May 13, 2026
Introduces the reposcan domain package with a backend-agnostic Result type and a pure Render function. Render emits a "Detected <stack>" summary with per-step setup commands, falling back to a friendly notice when the scan returns an empty/unknown stack. JSON tags are present on the types so the command layer can marshal results directly with cmdutil.WriteJSON. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adds a Scanner interface and an env-builder–backed default implementation that maps envbuilder.Environment into reposcan.Result. The interface lets command-layer tests inject a fake scanner; the default is constructed only at the command surface so the reposcan package itself remains testable without network access. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Introduces a top-level 'repo' command group with a 'scan' subcommand that detects the language stack, recommended container image, and install/test commands for the current working directory via env-builder. The command supports --json for scripting, prints a friendly fallback when no stack is detected (exit 0), and surfaces scanner failures as structured CLIErrors with exit code 1. Acceptance tests cover the empty-dir fallback, the --json contract, end-to-end Go module detection (skipped if Docker Hub is unreachable), and the --help text. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Three of the four acceptance tests duplicated coverage that already exists at the unit and snapshot layers: - Empty-dir fallback: covered by TestRunScan_EmptyResult_PrintsFallback_ExitZero. - JSON output shape: covered by TestRunScan_JSONFlag_* with a stdout/stderr separation assertion. - Help text contents: covered by the recursive TestUsage golden snapshot in internal/cmd/root. The remaining DetectsGoModule test is the only one that exercises the real env-builder library against a real filesystem through the compiled binary — coverage no other test layer provides. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The reposcan domain package is the part we want to keep: it's the reusable detection primitive that future commands (e.g. init, config generate) will call into. Exposing 'circleci repo scan' as a standalone user command was a premature commitment to a UX we haven't decided on. internal/reposcan/ stays — Result, Render, Scanner interface, and the env-builder–backed default implementation are all still importable by other internal commands. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
3a69067 to
c992f15
Compare
fb06394 to
c992f15
Compare
9 tasks
pete-woods
approved these changes
May 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
internal/reposcan/domain package:Result,SetupStep,Scannerinterface,Render, andNewDefaultScannerbacked bygithub.com/CircleCI-Public/chunk-cli/envbuilderScanner.Scan(ctx, dir)callsenvbuilder.DetectEnvironmentand maps the result to an insulatingreposcan.Resulttype — keeps the public surface stable across env-builder upgradesRenderwrites human-readable detection output to stderr (stack, image, setup steps, or fallback message for empty detection)chunk-clidependency togo.mod/go.sumNo user-facing command is wired up in this PR — this is the reusable library that
circleci init(and other commands) will call into.Test plan
task testpasses (unit tests ininternal/reposcan/)task checkpasses (lint, license headers, mod tidy)go test ./internal/reposcan/...green with no network calls