Skip to content

Load configured includes in execute() - #954

Merged
bobthecow merged 2 commits into
bobthecow:mainfrom
binaryfire:feature/include-extension-point
Aug 26, 2026
Merged

Load configured includes in execute()#954
bobthecow merged 2 commits into
bobthecow:mainfrom
binaryfire:feature/include-extension-point

Conversation

@binaryfire

@binaryfire binaryfire commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Laravel and Hypervel Tinker set include files on the shell before calling execute(), but PsySH only loads them when run() is used. Switching to run() isn’t equivalent because it treats input as PsySH commands and prints return values.

This makes execute() load configured includes itself. They’re loaded once for the outer call, so calls made while PsySH is already running don’t load them again.

Keep include loading out of the public API while allowing Shell subclasses to use it before direct execution.

Add coverage that loads an include through a subclass and reads its variable from executed code.
@bobthecow

Copy link
Copy Markdown
Owner

thanks!

i’m not sure loadIncludes() is the right extension point here. it still requires integrations to subclass Shell and know the correct output/boot/include/execute lifecycle ordering.

is there a reason we'd want to execute without honoring configured includes? what if we keep it private and have execute() load configured includes when it’s the outermost execution? we’d need to track nesting so inner calls from run(), timeit, reflection commands, etc. don’t load them again. that would make setIncludes() work consistently and fix the Laravel/Hypervel type cases without requiring a custom shell subclass.

Load configured includes when a top-level execute call owns shell execution, while sharing one depth counter with run so internal execute calls do not load them again.

Keep the include loader private, preserve the existing run ordering, and reset nesting in finally. Cover nested execute calls, commands run inside a shell session, and run re-entry.
@binaryfire binaryfire changed the title Allow Shell subclasses to load configured includes Honor configured includes in execute() Aug 26, 2026
@binaryfire binaryfire changed the title Honor configured includes in execute() Load configured includes in execute() Aug 26, 2026
@binaryfire

binaryfire commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

@bobthecow Done. Could you please check it out when you have a moment and let me know what you think?

@bobthecow

Copy link
Copy Markdown
Owner

Looks great, thank you!

@bobthecow
bobthecow merged commit 357f8cd into bobthecow:main Aug 26, 2026
36 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