Files
openhuman/scripts/review/cli.sh
T
c59b4289f1 refactor(config): extract env lookup seam for testability (#792)
## Summary

- Introduce an `EnvLookup` seam in `src/openhuman/config/schema/load.rs`.
- Route env-overlay reads through `EnvLookup`/`ProcessEnv` while preserving existing precedence and runtime behavior.
- Add focused parallel-safe unit coverage for config env overlay behavior without mutating process env.

## Problem

- `Config::apply_env_overrides` mixed environment access, override logic, and global side effects.
- That made precedence and parsing behavior harder to unit test in isolation and forced reliance on process-env mutation.

## Solution

- Add `pub(crate) trait EnvLookup` with `get`, `contains`, and `get_any`, plus a production `ProcessEnv` implementation.
- Delegate overlay logic through `apply_env_overlay_with(&ProcessEnv)` and keep side effects in the small wrapper.
- Add focused tests covering precedence, parsing, defaults, and legacy-migration interactions with no global env mutation.

## Submission Checklist

- [x] **Unit tests** — Targeted Rust config tests added and broader related module suites passed
- [ ] **E2E / integration** — Not applicable; this refactor preserves existing behavior and improves unit-level testability
- [x] **N/A** — E2E is not applicable because no user-visible or cross-process flow changed
- [ ] **Doc comments** — Not applicable; internal refactor in existing module only
- [ ] **Inline comments** — Not applicable; logic remains local and test coverage documents behavior

## Impact

- No intended runtime behavior change; refactor keeps config precedence intact.
- Improves maintainability and makes future config/workspace resolution seams easier to test safely.

## Related

- Issue(s):
- Follow-up PR(s)/TODOs: thread `EnvLookup` through runtime config directory resolution helpers

Co-authored-by: Steven Enamakel <enamakel@tinyhumans.ai>
2026-04-23 13:42:02 -07:00

55 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Dispatcher for `yarn review <cmd> <args…>`.
# Commands: sync | review | fix | merge
set -euo pipefail
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
usage() {
cat <<EOF
Usage: yarn review <command> <pr-number> [args]
Commands:
sync <pr> Check out PR as pr/<num>, merge main, wire remotes
review <pr> [--executor-llm <tool>] [extra-prompt]
Sync + pr-reviewer agent (review, comment, approve)
Default executor: claude
Trailing extra-prompt is appended to the executor prompt.
fix <pr> [--executor-llm <tool>] [extra-prompt]
Sync + pr-reviewer (apply fixes) + pr-manager-lite (push)
Default executor: claude
Trailing extra-prompt is appended to the executor prompt.
merge <pr> [--squash|--merge|--rebase] [--dry-run] [--force] [--admin|--auto] [--summary-llm <tool>]
Merge via gh (default --squash, deletes branch).
Requires reviewDecision=APPROVED and green required checks
(mergeStateStatus in CLEAN/UNSTABLE/HAS_HOOKS) — use --force to skip the local gate.
--admin bypasses branch protection (requires admin rights).
--auto queues the merge until checks/approvals are satisfied.
--dry-run prints the squash commit message and exits.
Default summary LLM: gemini (use 'none' to skip).
Env:
REVIEW_REPO=owner/name Override target repo (default: upstream remote)
REVIEW_BANNED_COAUTHOR_RE=<regex> Substrings filtered from Co-authored-by lines
(default includes copilot/codex/cursor/claude/…)
EOF
}
cmd="${1:-}"
if [ -z "$cmd" ] || [ "$cmd" = "-h" ] || [ "$cmd" = "--help" ]; then
usage
exit 0
fi
shift
case "$cmd" in
sync|review|fix|merge)
exec "$here/${cmd}.sh" "$@"
;;
*)
echo "[review] unknown command: $cmd" >&2
usage >&2
exit 1
;;
esac