fix: handle --agent-name flag by resolving and reviving target session - #17
Merged
Conversation
The --agent-name flag was registered but never acted upon, since
the postinstall patch that handled it was removed. This fix makes
the extension itself resolve the flag value during session_start.
- Adds resolveTargetSession() to daemon-client.ts for flag-to-session
resolution with guard against re-entry (skips when flag matches
current agent name).
- In session_start, checks pi.getFlag("agent-name") and when the
value names a different agent registered in the daemon, spawns a
new pi --session <file> process (mirroring the daemon's own
resumeSession) and exits the current process.
- Adds 5 tests for resolveTargetSession covering all edge cases
(undefined, boolean, self-match, found, not-found).
Co-authored-by: swift-badger-66 <swift-badger-66@pi-agent.local>
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
pi --agent-name solar-falcon-55registered the flag but never acted on it. The--agent-nameflag was registered viapi.registerFlag()but the extension never calledpi.getFlag("agent-name")to process it. The flag was originally handled by a postinstall patch (patch-pi.mjs) that was later removed, leaving the flag orphaned.This caused users to land in a new random agent instead of reviving the named one.
Fix
resolveTargetSession()(new indaemon-client.ts): resolves a flag value to a session file, guarding against re-entry (skips when flag matches current agent name).session_starthandler: checkspi.getFlag("agent-name"), and when it names a different agent registered in the daemon, spawns a newpi --session <file>process (mirroring the daemon's ownresumeSession) and exits the current process.How it works
— swift-badger-66