Skip to content

feat(cli): handover — generic ownership switch between the kit users - #47

Merged
steffenmaechtel merged 4 commits into
masterfrom
feature/handover
Aug 29, 2026
Merged

feat(cli): handover — generic ownership switch between the kit users#47
steffenmaechtel merged 4 commits into
masterfrom
feature/handover

Conversation

@steffenmaechtel

Copy link
Copy Markdown
Owner

New top-level CLI command:

opencode-permissions-kit handover me <path>...        # -> your user
opencode-permissions-kit handover opencode <path>...  # -> the agent user
opencode-permissions-kit handover me .gotmp --dry-run # plan only, no sudo

Also bumps VERSION to 0.0.24.

Why

Mixed-owner trees happen as soon as both the developer and the agent build
or work in the same checkout — for example ddev's .gotmp cache after
tests ran as both users (came up while working on the ddev upstream PR
around #46): chown then needs root, the exact usernames, and the right
group, and ddev's Makefile chmods make every build noisy. handover
wraps that into the kit: me/opencode resolve from the install config,
no usernames to remember.

Semantics

  • Recursive chown <user>:<sharing group> + g+w — identical to the ddev
    handovers (ddev-handover.sh): only the owner flips, the group stays
    the kit's sharing group, so both sides keep group access to the tree.
  • Auto-elevates via sudo (like config/update); validation and
    --dry-run run before the sudo hop, so argument errors and the plan
    work unprivileged.
  • Refuses system roots (/, /usr, /var, ...) and whole home
    directories — hand over trees, not systems.
  • Loop guard: a sudo that does not actually elevate aborts instead of
    recursing.

Distinct from config handover (the ddev project bootstrap repair): that
one is project-aware (.ddev + settings dirs), this one is a generic
owner switch for any path.

Tests

16 new assertions in tests/test-kit-cli.sh: usage/argument errors,
unknown target, nonexistent paths, the refusal cases (/, /usr, /etc,
/var, whole home), --dry-run plan output + no-sudo, sudo elevation hop,
and the loop guard (root test envs run the real chown and verify recursive
ownership). Full make test, make lint, make check-version green.

Docs

docs/reference/cli.md: new ## handover section + intro command list.

Recursive chown to <me|opencode>:<sharing-group> + g+w for mixed-owner
trees (e.g. ddev's .gotmp after builds by both users); same semantics as
the ddev handovers — only the owner flips, group access stays. Validation
and --dry-run run before the sudo hop; system roots and whole home
directories are refused; loop guard against non-elevating sudo.
…et test

CI runners have no /etc/opencode-permissions-kit/install.conf: the conf
check masked the unknown-target usage error, and the test read the real
/etc conf (passed only on installed machines). Usage errors now surface
before the conf requirement; the test pins OPK_INSTALL_CONF explicitly.
…kflow

The bare 'handover me .gotmp' line gave no context — show the chmod
EPERM symptom, the checkout cd, both directions and --dry-run.

@steffenmaechtel steffenmaechtel left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Reviewed

@steffenmaechtel
steffenmaechtel merged commit 2e730f7 into master Aug 29, 2026
3 checks passed
@steffenmaechtel
steffenmaechtel deleted the feature/handover branch August 29, 2026 19:35
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.

1 participant