donate: source agent from skill checkout so donate works from a non-git cwd#2461
Draft
boweiliu wants to merge 1 commit into
Draft
donate: source agent from skill checkout so donate works from a non-git cwd#2461boweiliu wants to merge 1 commit into
boweiliu wants to merge 1 commit into
Conversation
… a non-git cwd mngr donate raised 'Not inside a git repository' when run from a non-git directory (the common case for users who install mngr from a wheel/PR rather than a monorepo checkout). build_create_argv built the mngr create invocation with no --from, so mngr create fell back to sourcing the agent from the current directory and failed when the caller wasn't in a git repo. build_create_argv now passes --from <skill_dir> (the skill checkout, which is always a git clone), so the donation agent sources from the skill repo instead of the caller's cwd and mngr donate works from any directory. The donation agent only talks to the skill's coordination server, so the skill checkout is the correct source anyway. _clear_stale_worktree now runs git -C <skill_dir> (where the agent worktree is now rooted) instead of git in the caller's cwd, so stale-worktree cleanup still works when the caller's cwd isn't a git repo.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
mngr donateraisedNot inside a git repository. Either run from within a git repo, or specify --from to set the source explicitly.when run from a non-git directory — the common case for users who install mngr from a wheel/PR rather than a monorepo checkout (e.g. someone who installed from themngr/donate-auth-fixbranch viauv tool install).Root cause
build_create_argvbuilt themngr createinvocation with no--from. With no--from,mngr createfalls back to sourcing the agent from the current directory (_resolve_source_location->find_git_worktree_root(cwd)), which returnsNoneoutside a git repo and raisesUserInputError. The donate README even stated the assumption ("Run it from a trusted git repo, since the created agent is sourced from the current directory") — that assumption is the bug for installed-from-source users.Fix
build_create_argvnow passes--from <skill_dir>. The skill checkout (prepare_skill_dirclones the skill repo into~/.mngr/donate-skills/<skill>/) is always a git repo, so the agent sources from it regardless of the caller's cwd. The donation agent only talks to the skill's coordination server (its own message says so), so the skill checkout is the correct source anyway._clear_stale_worktreenow runsgit -C <skill_dir>(where the agent worktree is now rooted) instead ofgitin the caller's cwd, so stale-worktree cleanup still works when the caller's cwd isn't a git repo.Verification
libs/mngr_donate).build_create_argvfrom a non-git cwd — pre-fix hit "Not inside a git repository", post-fix passes source resolution and reaches the auth stage.mngr donatetick from/tmp/repro_not_a_git(a non-git dir) with a real token — exit 0, the agent launched, leased 10 papers, and reviewed them. Confirmed the agent worktree was rooted in the skill cache and that_clear_stale_worktreecleans up the leftovermngr/<agent>branch against the skill dir.Stacking
Stacked on top of #2460 (
mngr/donate-auth-fix, the--pass-envauth fix), which is itself stacked on #2417 (the basemngr_donateplugin). Merge order: 2417 -> 2460 -> this PR.