Skip to content

fix(output)!: omit environment variables from the full --json report - #262

Merged
pranshuparmar merged 1 commit into
pranshuparmar:stagingfrom
mabhub:fix/json-omit-env
Nov 23, 2026
Merged

pranshuparmar merged 1 commit into
pranshuparmar:stagingfrom
mabhub:fix/json-omit-env

Conversation

@mabhub

@mabhub mabhub commented Nov 22, 2026

Copy link
Copy Markdown

Refs #261.

The full --json report serialized Env for the target, every ancestor and every child. Agents that follow the README run witr --port <PORT> --json and read the environment of your shell and session into their context. I tagged model.Process.Env with json:"-". --env --json keeps printing the target's environment, since ToEnvJSON builds its own struct.

Changes:

  • pkg/model/process.go: Env []string `json:"-"` , with a comment saying why
  • internal/app/testdata/json_contract.golden: regenerated with -update, without Process.Env, Ancestry[].Env and Children[].Env
  • internal/output/json_test.go: TestToJSONOmitsEnv checks the full report carries neither the Env key nor a value from the fixture. It fails on staging and passes with this change.
  • README.md section 7.3: the full report row says environment variables are left out and points to --env --json
  • plugins/witr/skills/witr/SKILL.md: the "Found" shape says the same, and warns that environment variables often hold secrets

I also ran the binary on Linux against a process started with a dummy variable. witr --port <PORT> --json returns no Env array, and witr --port <PORT> --env --json lists the variable.

The change removes three fields from the JSON contract, so you'll want to call it out in the release notes. If you'd rather keep them behind a flag, I can rework the PR that way.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (may affect existing functionality)
  • This change requires a documentation update

Checklist

  • I have opened this PR against the staging branch, with a Conventional Commits title
  • I have performed a self-review of my own code
  • make lint and make test pass, and my changes add no new compiler, go vet or lint warnings
  • Platform-specific changes are checked in every platform's file (_linux, _darwin, _freebsd, _windows): the change sits in the shared model, so every platform gets it
  • Features that exist in both the CLI and the TUI are updated in both: the TUI reads Env from the struct and doesn't go through JSON, so it still shows the environment
  • Output changes are mirrored in the playground (docs/js/engine.js, fixtures regenerated): the playground's toJSON never emitted Env, and node docs/scripts/check-fixtures.mjs passes (26/26)
  • New --json fields are recorded in the JSON contract golden file: no new field, the golden file records the removal instead
  • I have made corresponding changes to the documentation (README, agent skill): README and agent skill updated

The full report serialized Env for the target, every ancestor and every
child. Agents that follow the README run `witr --port <PORT> --json`, so
the environment of the user's shell and session ended up in their
context. Tag model.Process.Env with json:"-". --env --json keeps printing
the target's environment through ToEnvJSON, which builds its own struct.

BREAKING CHANGE: Process.Env, Ancestry[].Env and Children[].Env are no
longer part of `witr <target> --json`. Use `--env --json` to get a
process's environment.

Fixes pranshuparmar#261
@pranshuparmar pranshuparmar added this to the 0.3.5 milestone Nov 23, 2026

@pranshuparmar pranshuparmar left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

LGTM.

@pranshuparmar
pranshuparmar merged commit ad105c1 into pranshuparmar:staging Nov 23, 2026
20 checks passed
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