Skip to content

Add reposcan domain package#1304

Open
Klaney wants to merge 9 commits into
nextfrom
Klaney/repo-scan-env-builder
Open

Add reposcan domain package#1304
Klaney wants to merge 9 commits into
nextfrom
Klaney/repo-scan-env-builder

Conversation

@Klaney
Copy link
Copy Markdown
Contributor

@Klaney Klaney commented May 13, 2026

Summary

  • Adds internal/reposcan/ domain package: Result, SetupStep, Scanner interface, Render, and NewDefaultScanner backed by github.com/CircleCI-Public/chunk-cli/envbuilder
  • Scanner.Scan(ctx, dir) calls envbuilder.DetectEnvironment and maps the result to an insulating reposcan.Result type — keeps the public surface stable across env-builder upgrades
  • Render writes human-readable detection output to stderr (stack, image, setup steps, or fallback message for empty detection)
  • Full unit test coverage (offline); env-builder types don't appear in the package's public surface
  • Adds chunk-cli dependency to go.mod / go.sum

No 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 test passes (unit tests in internal/reposcan/)
  • task check passes (lint, license headers, mod tidy)
  • go test ./internal/reposcan/... green with no network calls

@Klaney
Copy link
Copy Markdown
Contributor Author

Klaney commented May 13, 2026

For temporary testing I exposed the functionality in a command

It has since been removed

Screenshot 2026-05-13 at 12 14 19 PM

Comment thread internal/reposcan/scanner.go Outdated
Comment thread internal/reposcan/scanner.go Outdated
Comment thread internal/reposcan/scanner.go Outdated
Klaney and others added 9 commits May 13, 2026 15:00
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>
@Klaney Klaney force-pushed the Klaney/repo-scan-env-builder branch from 3a69067 to c992f15 Compare May 13, 2026 22:00
@Klaney Klaney changed the title feat(reposcan): add reposcan domain package with env-builder detection Add reposcan domain package May 14, 2026
@Fab10-CircleCi Fab10-CircleCi changed the title Add reposcan domain package feat(init): scaffold circleci init + reposcan + env-builder test runner May 15, 2026
@Fab10-CircleCi Fab10-CircleCi changed the title feat(init): scaffold circleci init + reposcan + env-builder test runner Scaffold circleci init, reposcan, env-builder test runner, and auth signup May 15, 2026
@Fab10-CircleCi Fab10-CircleCi force-pushed the Klaney/repo-scan-env-builder branch from fb06394 to c992f15 Compare May 15, 2026 00:55
@Fab10-CircleCi Fab10-CircleCi changed the title Scaffold circleci init, reposcan, env-builder test runner, and auth signup Add reposcan domain package May 15, 2026
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.

2 participants