New generation of tn-venv
New generation
Added
tn-venv --list-pluginsflag. Loads every plugin via the same discovery path asrun_session(built-ins + entry points +TN_VENV_PLUGINS) and prints a table of plugin name, registered hooks, and provenance. Hookless plugins (CLI shims, subcommand installers, …) appear as(no hooks)so they are not silently invisible.HookName.HELP_EPILOGhook. Plugins can now append text totn-venv --helpoutput via a public hook instead of monkey- patchingargparse. The listener takes no arguments and returns a string; tn-venv appends it after an auto-generatedPlugins:block. Plugins are loaded eagerly by :func:cli_runso a plugin that wrapstn_venv.cli.cli_run(e.g.tn-venv-guiinstalling itsguisubcommand) gets a chance to intercept argv liketn-venv gui --helpbefore argparse sees the help flag.PluginSourcedataclass exported fromtn_venv.plugins. Every loaded plugin instance now carries a_tn_venv_sourceattribute describing where it came from (built-in,entry-point: NAME=SPEC, orenv: TN_VENV_PLUGINS).--list-pluginsconsumes this; the attribute is private but the dataclass is part of the public API for callers who want to introspect plugins programmatically.
Changed
- The plugin loader is now invoked eagerly at the top of
tn_venv.cli.cli_runrather than lazily on--help. Plugins that replacetn_venv.cli.cli_run(e.g. thetn-venv-guipackage installing itsguisubcommand) now intercept argv liketn-venv gui --helpon the very first invocation that triggers plugin loading. The lazy--help` trigger (viaformat_help) is still in place as a belt-and- braces fallback for hosts that print help without going throughcli_run``. main()looks upcli_runon its own module at call time instead of binding the name at definition time, so the console-script entry point picks up a plugin's monkey-patch even whenmainwas imported before the patch was applied.
Fixed
-
tn-venv gui --helpprinted the full tn-venv help instead of the GUI subcommand's help. The cli_run monkey-patch installed by the plugin only ran on the next invocation, so argparse saw--helpfirst and short-circuited before the wrapper could dispatch. Fixed by capturing the originalcli_runreference at the top ofcli_runand re-invoking through the (now-patched) module attribute when the plugin has replaced the function. -
Plugin loader dropped every plugin past the first one. A module that declared
PLUGINS = [A, B, C]only ever loadedA; the same bug affected comma-separated entries inTN_VENV_PLUGINSand entry points that pointed at modules rather than classes. The loader now returnslist[Plugin]from every code path (_from_module_attr,_from_entry_point,_resolve_target) and propagates them up toload_plugins. vars()scan picked the firstPluginsubclass it found, so a module that definedclass _Base(Plugin)followed byclass Concrete(_Base)loaded the empty-named base class instead of the concrete one — a silent no-op that hid user plugins. The scan now skips classes whosenameis empty (the convention for abstract / helper bases) and exposes a dedicated_scan_module_for_pluginshelper for the rule.- Replaced
:class:~tn_venv.…` cross-references indocs/guide/plugins.mdanddocs/development/architecture.mdwith plain inline code. The docs site does not configuresphinx.ext.autodoc, so the references previously rendered as literal~tn_venv.…` (with the leading tilde) and provided no linkability.