diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json index 117afbd..8917f70 100644 --- a/.claude-plugin/plugin.json +++ b/.claude-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "analysis-workflow", - "version": "0.4.0", + "version": "0.4.1", "description": "Conventions for analysis repos where humans (notebooks) and coding agents (scripts) work side by side: one task per session, worktree and directory; worktree-safe output paths; additive write-back to AnnData zarr working objects. Ships a skill, guard hooks and the analysis_workflow Python package.", "author": { "name": "quadbio" diff --git a/hooks/session_start.py b/hooks/session_start.py index ab1d6ea..4627851 100644 --- a/hooks/session_start.py +++ b/hooks/session_start.py @@ -69,7 +69,9 @@ def main() -> int: print(f"\nEvery Bash command runs on `{variables['CONDA_PREFIX']}`: run `python …` directly.") else: print(f"\nNo environment is active: run `pixi run --manifest-path {main_checkout}/pixi.toml --as-is …`.") - if deliverables := os.environ.get("CLAUDE_PLUGIN_OPTION_DELIVERABLES", "").strip(): + manifest = json.loads((Path(__file__).parents[1] / ".claude-plugin" / "plugin.json").read_text()) + default = manifest["userConfig"]["deliverables"]["default"] # Claude Code sets the variable only once it is saved + if deliverables := os.environ.get("CLAUDE_PLUGIN_OPTION_DELIVERABLES", default).strip(): print(f"Default deliverables, from the plugin settings: {deliverables}.") return 0 diff --git a/tests/test_hooks.py b/tests/test_hooks.py index 932fbf6..c466fc3 100644 --- a/tests/test_hooks.py +++ b/tests/test_hooks.py @@ -291,7 +291,9 @@ def test_guards_ignore_repos_that_have_not_adopted_the_plugin(unadopted_repo): def session_start(cwd: Path, **env: str) -> str: payload = json.dumps({"hook_event_name": "SessionStart", "cwd": str(cwd)}) - environ = {k: v for k, v in os.environ.items() if k != "CLAUDE_ENV_FILE"} | env + environ = { + k: v for k, v in os.environ.items() if k != "CLAUDE_ENV_FILE" and not k.startswith("CLAUDE_PLUGIN_OPTION_") + } | env return subprocess.run( [sys.executable, HOOKS / "session_start.py"], input=payload, @@ -310,10 +312,13 @@ def test_session_start_prints_the_rules_only_in_an_adopted_repo(repo, unadopted_ assert session_start(unadopted_repo[0]) == session_start(tmp_path) == "" -def test_session_start_lists_the_default_deliverables_when_set(repo): +def test_session_start_lists_the_default_deliverables(repo): main, _ = repo - line = "Default deliverables, from the plugin settings: a figure." - assert line in session_start(main, CLAUDE_PLUGIN_OPTION_DELIVERABLES="a figure") + manifest = json.loads((HOOKS.parent / ".claude-plugin" / "plugin.json").read_text()) + default = manifest["userConfig"]["deliverables"]["default"] + assert f"Default deliverables, from the plugin settings: {default}." in session_start(main) + line = "Default deliverables, from the plugin settings: a report." + assert line in session_start(main, CLAUDE_PLUGIN_OPTION_DELIVERABLES="a report") assert "Default deliverables" not in session_start(main, CLAUDE_PLUGIN_OPTION_DELIVERABLES="")