Skip to content

Commit 06d6504

Browse files
committed
feat(m1): collector pipeline, platform/shell/PATH collectors and JSON contract
Implements EnvDoctor M1 from docs/PLAN.md section 12. - collector interface, Part ownership and a parallel runner with a 2 s per-collector deadline; a failed collector is recorded, reported and yields exit code 3 without aborting the run - platform collector for windows/linux/darwin (version, arch, elevation) - shell collector (name, path when SHELL is set) - PATH collector with exists/isDir/position/duplicate flags, quote handling and no execution of PATH entries - home-directory redaction to ~ before any export - text report and versioned JSON document - committed snapshot and diagnose JSON schemas, validated by tests - golden-fixture harness that fails for unknown rules and for registered rules without a fixture - goreleaser configuration verified by a six-target snapshot build - ADR 0002, CHANGELOG 0.1.0, README roadmap and PLAN status updates Zero diagnostic rules are registered in this release, so diagnose never reports a finding; the report prints the rule count instead.
1 parent 339cc47 commit 06d6504

43 files changed

Lines changed: 3401 additions & 58 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.goreleaser.yaml‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# GoReleaser configuration for EnvDoctor.
2+
#
3+
# Releases are produced by CI only (see .github/workflows/release.yml once M6
4+
# exists). Locally this file is used for `goreleaser build --snapshot` and
5+
# `goreleaser check`, which is how the configuration is verified.
6+
version: 2
7+
8+
project_name: envdoctor
9+
10+
before:
11+
hooks:
12+
- go mod tidy
13+
- go test ./...
14+
15+
builds:
16+
- id: envdoctor
17+
main: ./cmd/envdoctor
18+
binary: envdoctor
19+
env:
20+
- CGO_ENABLED=0
21+
goos:
22+
- windows
23+
- linux
24+
- darwin
25+
goarch:
26+
- amd64
27+
- arm64
28+
ldflags:
29+
- -s -w
30+
- -X main.version={{ .Version }}
31+
32+
archives:
33+
- id: envdoctor
34+
formats: [tar.gz]
35+
format_overrides:
36+
- goos: windows
37+
formats: [zip]
38+
name_template: >-
39+
{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}
40+
41+
checksum:
42+
name_template: checksums.txt
43+
algorithm: sha256
44+
45+
snapshot:
46+
version_template: "{{ incpatch .Version }}-next"
47+
48+
changelog:
49+
use: git
50+
sort: asc
51+
filters:
52+
exclude:
53+
- "^docs:"
54+
- "^chore:"
55+
- "^test:"
56+
57+
release:
58+
# A local snapshot never publishes. A real release is drafted and reviewed.
59+
draft: true
60+
prerelease: auto

‎CHANGELOG.md‎

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,46 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
77

88
## [Unreleased]
99

10-
### Added
10+
### Planned
11+
12+
- M2: runtime, port and Git collectors, plus the first diagnostic rules with golden fixtures.
1113

12-
- Repository skeleton: build tooling, CI, documentation standards and the implementation plan.
14+
## [0.1.0] - 2026-11-13
15+
16+
### Added
1317

14-
Nothing functional yet. See [docs/PLAN.md](docs/PLAN.md) for what is scheduled.
18+
- `envdoctor diagnose` with `--json`, `--component`, `--rule` and `--verbose`.
19+
- `envdoctor version` and `--version`.
20+
- Collector interface, parallel runner and a 2 s per-collector deadline. A failed collector is
21+
recorded in the snapshot, printed in the report and makes the run exit 3 without aborting the
22+
other collectors.
23+
- Platform collector: operating system, version, architecture and elevation on Windows, Linux and
24+
macOS. An unavailable version is reported as empty rather than guessed.
25+
- Shell collector: shell name, and path when the shell exposes `SHELL`.
26+
- PATH collector: one entry per element with existence, directory, position and duplicate flags.
27+
Existence comes from file metadata; nothing on PATH is executed.
28+
- Home-directory redaction to `~` in every exported string, case-insensitive and
29+
separator-insensitive, applied before the snapshot is written anywhere.
30+
- Text report and a versioned JSON document.
31+
- Exit codes: `0` clean, `1` warning, `2` error or critical, `3` tool failure (including a
32+
degraded collector), `4` invalid usage.
33+
- Committed JSON schemas in `docs/schema/` for the snapshot and the diagnose document, enforced by
34+
a test that validates real CLI output.
35+
- Golden-fixture harness (`internal/diagnostic/fixture.go`, `tests/golden/`): a fixture for a rule
36+
that is not registered fails, and a registered rule without a fixture fails.
37+
- `.goreleaser.yaml` covering six targets, verified with `goreleaser build --snapshot --clean`.
38+
- CI workflow with a Windows/Ubuntu/macOS test matrix, gofmt, `go vet`, `go test -race`, build and
39+
lint jobs.
40+
41+
### Known limitations
42+
43+
- Zero diagnostic rules are registered, so `diagnose` never reports a finding and exit codes 1 and
44+
2 are unreachable in this release. The report states the rule count instead of implying a clean
45+
bill of health.
46+
- No runtime, port, Git, Docker or dependency collectors.
47+
- No bundles, no fixes, no Bubble Tea renderer.
48+
- The CI matrix is configured but has never executed: the repository has no remote yet.
49+
- `goreleaser check` fails without a git remote; only the snapshot build was verified.
1550

1651
## [0.0.0] - 2026-11-13
1752

‎README.md‎

Lines changed: 68 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
> A cross-platform CLI that detects, diagnoses and helps resolve development environment problems.
44
5-
![status](https://img.shields.io/badge/status-skeleton-lightgrey)
5+
![status](https://img.shields.io/badge/status-M1_collectors-orange)
66
[![license](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
77
![Go](https://img.shields.io/badge/go-1.23-00ADD8?logo=go&logoColor=white)
88

9-
**Status: skeleton (v0.0.0).** This repository contains the project structure, architecture decisions and
10-
an implementation plan. **Nothing is functional yet.** The word "works" does not appear below unless it is
11-
true.
9+
**Status: M1 (v0.1.0).** EnvDoctor collects platform, shell and PATH facts and prints them as text or JSON,
10+
with a documented exit-code contract. **There are no diagnostic rules yet**, so it cannot tell you that
11+
anything is wrong: `diagnose` lists facts and then reports zero findings. Nothing is modified on your machine.
1212

1313
## Why this exists
1414

@@ -22,17 +22,17 @@ explains the cause instead of dumping raw output.
2222
| Capability | Milestone | Status |
2323
|---|---|---|
2424
| Detect conflicting Python and Node versions | M2 | Not started |
25-
| Identify broken PATH entries | M2 | Not started |
25+
| Identify broken PATH entries | M2 | Facts reported; no rule yet |
2626
| Detect port conflicts | M2 | Not started |
2727
| Diagnose Docker daemon problems | M3 | Not started |
2828
| Identify missing system dependencies | M3 | Not started |
2929
| Detect incompatible package managers | M3 | Not started |
3030
| Check Git configuration | M2 | Not started |
3131
| Generate diagnostic bundles | M4 | Not started |
32-
| Human-readable reports | M4 | Not started |
33-
| JSON export | M4 | Not started |
32+
| Human-readable reports | M4 | Basic text report (M1); polish is M4 |
33+
| JSON export | M1 | **Done** |
3434
| Safe, opt-in automated remediation | M5 | Not started |
35-
| Windows, Linux and macOS support | M6 | Not started |
35+
| Windows, Linux and macOS support | M6 | Collectors build for all three; CI matrix not yet run |
3636

3737
## Architecture
3838

@@ -64,38 +64,86 @@ might not exist, and no fix may run without explicit confirmation.
6464

6565
## Quickstart
6666

67-
Not runnable yet. The skeleton builds and prints its version:
67+
Requires Go 1.23+.
6868

6969
```bash
7070
make build
71-
./bin/envdoctor version
71+
./bin/envdoctor diagnose
7272
```
7373

74-
Full local stack (build and test tooling) arrives with
75-
milestone M1.
74+
```
75+
EnvDoctor 0.1.0 - environment diagnosis
76+
Generated 2026-11-13T01:41:49Z
77+
78+
Platform windows 11 (build 26300) amd64
79+
Elevated no
80+
Shell powershell
81+
PATH 26 entries, 2 missing, 0 duplicate
82+
83+
Missing PATH entries:
84+
- C:\Windows\System32
85+
- ~\AppData\Local\Programs\Antigravity\bin
86+
87+
Rules 0 registered in this build
88+
89+
No findings.
90+
```
91+
92+
That output is real, captured from `goreleaser build --snapshot` on Windows 11 while developing M1. The
93+
leading space in the first entry is part of the value: it is a malformed PATH element, and that is exactly
94+
what the collector is for.
95+
96+
Machine-readable output, for an editor or CI:
97+
98+
```bash
99+
./bin/envdoctor diagnose --json
100+
```
101+
102+
The JSON document is validated against [docs/schema/diagnose-v1.schema.json](docs/schema/diagnose-v1.schema.json)
103+
in the test suite; the snapshot inside it is described by
104+
[docs/schema/snapshot-v1.schema.json](docs/schema/snapshot-v1.schema.json). Home directories are replaced
105+
with `~` before anything is written.
106+
107+
Exit codes: `0` nothing at or above warning, `1` warnings, `2` at least one error, `3` the tool itself failed
108+
(including a collector timeout), `4` invalid usage. Today only `0`, `3` and `4` are reachable, because zero
109+
rules are registered.
110+
111+
`--component` and `--rule` narrow which rules are evaluated. With no rules, either flag can only produce an
112+
empty result or an "unknown rule" error.
113+
114+
A local release build of all six targets:
115+
116+
```bash
117+
goreleaser build --snapshot --clean
118+
```
119+
120+
`goreleaser check` additionally wants a git remote, so it only passes once the repository is pushed.
76121

77122
## Repository layout
78123

79124
| Path | Purpose |
80125
|---|---|
81126
| `cmd/envdoctor` | CLI entry point |
82-
| `internal/collector` | Collector interface and registry |
83-
| `internal/collector/{windows,linux,darwin}` | Platform-specific collectors behind build tags |
84-
| `internal/diagnostic` | Rule engine, severity model, explanation composition |
85-
| `internal/report` | Terminal renderer, JSON renderer, bundle writer |
86-
| `internal/fix` | Remediation plans, dry-run by default |
127+
| `internal/cli` | Command wiring, flags, exit codes |
128+
| `internal/config` | Resolved options, schema version, collector timeout |
129+
| `internal/collector` | Collector interface, registry, parallel runner |
130+
| `internal/collector/{windows,linux,darwin}` | Reserved for build-tagged collectors (empty in M1) |
131+
| `internal/diagnostic` | Rule engine, severity model, fixture harness |
132+
| `internal/report` | Terminal renderer, JSON renderer |
133+
| `internal/fix` | Remediation plans, dry-run by default (empty until M5) |
87134
| `internal/system` | Thin wrappers over OS facilities, the only place syscalls live |
135+
| `docs/schema` | Committed JSON schemas, enforced by tests |
88136
| `tests/golden` | Snapshot-to-diagnosis fixtures, one per rule |
89137
| `deploy` | Release and packaging notes |
90138

91139
## Roadmap
92140

93141
| Milestone | Deliverable | Status |
94142
|---|---|---|
95-
| M1 | CLI foundation, collector interface, system information | Not started |
143+
| M1 | CLI foundation, collector interface, system information | **Done** (v0.1.0) |
96144
| M2 | Cross-platform collectors: runtimes, PATH, ports, Git | Not started |
97-
| M3 | Diagnostic rule engine and Docker/dependency rules | Not started |
98-
| M4 | Human-readable reports, JSON export, diagnostic bundles | Not started |
145+
| M3 | Rules ENV007–ENV012, Docker and dependency inspectors, `explain` | Not started |
146+
| M4 | Polished terminal output, Markdown export, diagnostic bundles | Not started |
99147
| M5 | Safe, confirmed automated remediation | Not started |
100148
| M6 | Windows, Linux, macOS packaging and signed releases | Not started |
101149

‎cmd/envdoctor/main.go‎

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
// Command envdoctor is the entry point for EnvDoctor.
1+
// Command envdoctor diagnoses development environment problems.
22
//
3-
// It serves the public API and the admin dashboard API.
4-
//
5-
// Status: skeleton. Nothing is implemented yet. See docs/PLAN.md.
3+
// M1 scope: collect platform, shell and PATH facts, print them, and render an
4+
// empty rule set. No rule exists yet, so `diagnose` never reports a finding and
5+
// never modifies anything.
66
package main
77

88
import (
9-
"fmt"
109
"os"
10+
11+
"github.com/shellghostt/envdoctor/internal/cli"
1112
)
1213

1314
// version is overridden at build time with:
@@ -16,12 +17,10 @@ import (
1617
var version = "dev"
1718

1819
func main() {
19-
if len(os.Args) > 1 && (os.Args[1] == "version" || os.Args[1] == "--version") {
20-
fmt.Printf("%s %s\n", "envdoctor", version)
21-
return
22-
}
23-
24-
fmt.Println("envdoctor EnvDoctor - skeleton, not implemented")
25-
fmt.Println("Read docs/PLAN.md before running this binary.")
26-
os.Exit(0)
20+
os.Exit(cli.Main(os.Args, cli.App{
21+
Version: version,
22+
Stdout: os.Stdout,
23+
Stderr: os.Stderr,
24+
Getenv: os.Getenv,
25+
}))
2726
}

‎deploy/README.md‎

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,36 @@ EnvDoctor ships as a single static binary per platform via GoReleaser.
44

55
- No Docker image for end users: the tool inspects the *host* environment, so running it in a
66
container would report the container.
7-
- Release matrix at M6: windows/amd64, windows/arm64, linux/amd64, linux/arm64, darwin/amd64,
7+
- Target matrix: windows/amd64, windows/arm64, linux/amd64, linux/arm64, darwin/amd64,
88
darwin/arm64.
9+
10+
## Configuration
11+
12+
[`.goreleaser.yaml`](../.goreleaser.yaml) is the single source of truth. It builds all six targets
13+
with `CGO_ENABLED=0`, names archives `<project>_<version>_<os>_<arch>` (zip on Windows, tar.gz
14+
elsewhere), writes `checksums.txt` with SHA-256, and drafts releases rather than publishing them.
15+
16+
Verified locally (M1, 2026-11-13):
17+
18+
```bash
19+
goreleaser build --snapshot --clean
20+
```
21+
22+
This produced all six binaries; the Windows build reported `envdoctor.exe` at roughly 3.7 MB.
23+
24+
`goreleaser check` additionally validates the release configuration against the git remote, so it
25+
fails while the repository has no remote configured. That is a missing prerequisite, not a broken
26+
configuration.
27+
28+
## Release workflow
29+
30+
Not implemented yet (M6). The intended shape:
31+
32+
1. A `vX.Y.Z` tag pushed by a maintainer triggers `.github/workflows/release.yml`.
33+
2. CI re-runs `gofmt`, `go vet`, `go test -race ./...` and `go build ./...` before releasing.
34+
3. GoReleaser drafts the release; a human reviews the notes and publishes.
35+
4. Checksums are published alongside the archives. Signing is M6 and will be documented here only
36+
once it exists.
37+
38+
Do not publish a binary whose `version` was not injected through `-X main.version`; the default is
39+
`dev`.

‎docs/ARCHITECTURE.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# EnvDoctor Architecture
22

3-
**Status: planned. No implementation exists yet.** This document describes intended structure, not
4-
delivered behaviour. The authoritative specification is [PLAN.md](PLAN.md).
3+
**Status: partially implemented (M1).** The collector pipeline, platform, shell and PATH collection, and
4+
the JSON contract exist. There are no diagnostic rules yet, so EnvDoctor reports no findings on any machine.
5+
This document describes intended structure, not delivered behaviour. The authoritative specification is
6+
[PLAN.md](PLAN.md), and section 0 there is the current truth.
57

68
## Context
79

0 commit comments

Comments
 (0)