Skip to content

[codex] add Go module entrypoint#45

Merged
Vasanthdev2004 merged 2 commits into
mainfrom
codex/go-m0-module-entrypoint
Jun 4, 2026
Merged

[codex] add Go module entrypoint#45
Vasanthdev2004 merged 2 commits into
mainfrom
codex/go-m0-module-entrypoint

Conversation

@Vasanthdev2004

@Vasanthdev2004 Vasanthdev2004 commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add the first Go module for Zero with cmd/zero as the entrypoint.
  • Add a minimal internal CLI surface for --help, --version, and unknown-command handling.
  • Add Go tests for that CLI behavior.
  • Add CI smoke coverage for go test ./... and go build ./cmd/zero across the existing OS matrix.
  • Narrow .gitignore so only root build artifacts /zero and /zero.exe are ignored, allowing cmd/zero to be tracked.

Why

This starts the Go M0 foundation from the merged PRD direction without rewriting the current TypeScript/Bun app. The slice gives Anandan/Gnanam/Vasanth a concrete Go baseline to build on.

Validation

Local:

  • git diff --cached --check passed before commit.
  • bun run typecheck passed.
  • bun test ./tests --timeout 15000 passed: 277 tests.
  • bun run build passed.
  • bun run smoke:build passed.

Blocked locally:

  • go test ./... and go build ./cmd/zero could not run because go is not installed on this Windows machine.

CI:

  • This PR adds actions/setup-go and runs the Go validation commands on Ubuntu, macOS, and Windows.

Summary by CodeRabbit

  • New Features
    • A new zero command-line tool with help (--help, -h) and version (--version, -v) output and proper unknown-command exit codes
  • Tests
    • Expanded CLI test coverage, including help, version, unknown-command, and failure cases for output errors
  • Chores
    • CI now runs Go tests and a Go build (with Go toolchain setup and caching)
  • Style
    • Repository ignore rules updated to only exclude built artifacts at repository root

@Vasanthdev2004
Vasanthdev2004 marked this pull request as ready for review June 4, 2026 06:56
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Zero automated PR review

Verdict: No blockers found

Blockers

  • None found.

Validation

  • [pass] Diff hygiene: git diff --check
  • [pass] Typecheck: bun run typecheck
  • [pass] Tests: bun run test
  • [pass] Build: bun run build
  • [pass] Smoke build: bun run smoke:build

Scope

Head: 7aee97f3e206
Changed files (6): .github/workflows/ci.yml, .gitignore, cmd/zero/main.go, go.mod, internal/cli/app.go, internal/cli/app_test.go

This deterministic review checks validation status and basic diff hygiene. A human reviewer still owns product judgment and design quality.

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 80bc025d-47e8-42d3-ab96-c647d4b939ff

📥 Commits

Reviewing files that changed from the base of the PR and between 3a0149a and 7aee97f.

📒 Files selected for processing (3)
  • .github/workflows/ci.yml
  • internal/cli/app.go
  • internal/cli/app_test.go
✅ Files skipped from review due to trivial changes (1)
  • .github/workflows/ci.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/cli/app.go

Walkthrough

This PR adds a Go module and CLI: a new go.mod, cmd/zero entrypoint that calls cli.Run, a Run implementation handling help/version/unknown commands with write-error handling, expanded tests (including write-failure cases), and CI steps to run go test and go build in the smoke job.

Changes

Go CLI Module with Help and Version Support

Layer / File(s) Summary
Go module and executable entrypoint
go.mod, cmd/zero/main.go, .gitignore
module github.com/Gitlawb/zero with go 1.24 is added; cmd/zero/main.go calls cli.Run(os.Args[1:], os.Stdout, os.Stderr) and exits with its code; .gitignore entries for zero and zero.exe are anchored to the repo root.
CLI application command dispatcher
internal/cli/app.go
Adds Run(args []string, stdout io.Writer, stderr io.Writer) int, a version constant, and writeHelp(io.Writer) error; handles help (--help/-h/help), version (--version/-v/version), unknown commands (writes error+usage to stderr and returns 2), and returns 1 on write errors.
CLI command dispatcher tests
internal/cli/app_test.go
Tests cover version output, help output for multiple arg variants, unknown-command behavior, and failure paths when stdout or stderr writes fail using a failingWriter test double.
CI verification and build steps
.github/workflows/ci.yml
In the smoke job, adds actions/setup-go (pinned) with go-version-file: go.mod and caching, then runs go test ./... and go build ./cmd/zero before the existing Bun-based install/test/typecheck/build/smoke steps.

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title '[codex] add Go module entrypoint' directly describes the main change: introducing a Go module with a CLI entrypoint at cmd/zero, which is the primary focus of all modifications.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/go-m0-module-entrypoint

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
internal/cli/app_test.go (1)

26-50: ⚡ Quick win

Add explicit coverage for the no-args help path (and optionally short flags).

Run([]string{}) is a distinct branch and should be locked down in tests alongside the existing --help/--version cases.

Proposed test addition
 func TestRunPrintsHelp(t *testing.T) {
@@
 }
 
+func TestRunWithNoArgsPrintsHelp(t *testing.T) {
+	var stdout bytes.Buffer
+	var stderr bytes.Buffer
+
+	exitCode := Run([]string{}, &stdout, &stderr)
+	if exitCode != 0 {
+		t.Fatalf("expected exit code 0, got %d", exitCode)
+	}
+	if output := stdout.String(); !strings.Contains(output, "Usage:") {
+		t.Fatalf("expected help output, got %q", output)
+	}
+	if stderr.Len() != 0 {
+		t.Fatalf("expected empty stderr, got %q", stderr.String())
+	}
+}
+
 func TestRunRejectsUnknownCommand(t *testing.T) {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/cli/app_test.go` around lines 26 - 50, Add a test covering the
no-args help branch by calling Run([]string{}) (and optionally short flags like
"-h" and "-v") and asserting the same expectations as TestRunPrintsHelp: exit
code 0, stdout contains the help strings ("ZERO terminal coding agent",
"Usage:", "zero [command]", "--version"), and stderr is empty; implement this
either as a new TestRunNoArgsPrintsHelp or as subtests inside TestRunPrintsHelp
and reuse the same assertions against Run to lock down the distinct branch.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/ci.yml:
- Line 31: Replace the mutable GitHub Action reference "actions/setup-go@v5"
with the pinned commit SHA
"actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff" in the CI workflow;
update the single line containing uses: actions/setup-go@v5 (and any other
occurrences of that tag) so the workflow uses the fixed commit SHA for
supply-chain integrity.

In `@internal/cli/app.go`:
- Around line 23-27: The CLI currently ignores errors returned by
fmt.Fprintf/Fprintln in Run and printHelp, so update the Run and printHelp
functions to check each fmt.* call's (n, err) result and handle non-nil err by
returning an error (or non-zero exit) to the caller; specifically modify the
occurrences in Run (the version/default/unknown command branches that call
fmt.Fprintf to stdout/stderr) and the printHelp function (all
fmt.Fprintln/Fprint calls) to capture the error and immediately return it (or an
appropriate exit code) instead of discarding it so write failures are
propagated.

---

Nitpick comments:
In `@internal/cli/app_test.go`:
- Around line 26-50: Add a test covering the no-args help branch by calling
Run([]string{}) (and optionally short flags like "-h" and "-v") and asserting
the same expectations as TestRunPrintsHelp: exit code 0, stdout contains the
help strings ("ZERO terminal coding agent", "Usage:", "zero [command]",
"--version"), and stderr is empty; implement this either as a new
TestRunNoArgsPrintsHelp or as subtests inside TestRunPrintsHelp and reuse the
same assertions against Run to lock down the distinct branch.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: bd6b73a5-05b2-4b87-910e-f0968042d4c1

📥 Commits

Reviewing files that changed from the base of the PR and between b94812d and 3a0149a.

📒 Files selected for processing (6)
  • .github/workflows/ci.yml
  • .gitignore
  • cmd/zero/main.go
  • go.mod
  • internal/cli/app.go
  • internal/cli/app_test.go

Comment thread .github/workflows/ci.yml Outdated
Comment thread internal/cli/app.go Outdated

@gnanam1990 gnanam1990 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the Go M0 entrypoint slice. The shape is good and I validated the important paths locally: go test ./..., go build ./cmd/zero, and git diff --check origin/main...HEAD all pass; GitHub checks are also green across macOS, Ubuntu, Windows, Performance Smoke, CodeRabbit, and Zero Review.

Requesting a small changes pass before approval:

  • internal/cli/app.go: Run / printHelp ignore fmt.* write errors. Since the CLI accepts injected writers, failed stdout/stderr writes can still return success, especially for help/version paths. Please make printHelp return an error and map write failures to a non-zero exit.
  • .github/workflows/ci.yml: actions/setup-go@v5 should be pinned or otherwise aligned with repo supply-chain policy now that this PR introduces the Go action.
  • internal/cli/app_test.go: add explicit coverage for the no-args help branch with Run([]string{}); it is distinct from the --help branch and should stay locked down.

No larger blocker found beyond these small review items.

@gnanam1990 gnanam1990 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Rereviewed the updated head 7aee97f. The requested changes are addressed:

  • CLI write errors now return a non-zero exit.
  • No-args, short-help, and write-failure branches are covered in tests.
  • actions/setup-go is pinned in CI.

Validated locally with go test ./..., go build ./cmd/zero, git diff --check origin/main...HEAD, bun run test after frozen install, bun run typecheck, bun run build, and bun run smoke:build. GitHub checks are green across macOS, Ubuntu, Windows, Performance Smoke, CodeRabbit, and Zero Review.

Approved.

@Vasanthdev2004
Vasanthdev2004 merged commit 711a5f9 into main Jun 4, 2026
6 checks passed
@Vasanthdev2004
Vasanthdev2004 deleted the codex/go-m0-module-entrypoint branch June 28, 2026 08:27
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