fix: allow global commands to resolve when a project is active#3
fix: allow global commands to resolve when a project is active#3Krashnicov wants to merge 2 commits into3clyp50:mainfrom
Conversation
When a project context is active, _validate_command_path and _load_yaml_command_file were only checking paths against the project scope directory. Global commands live in the global scope directory and were always rejected with 'Command path is outside the selected scope'. Fixes: - _validate_command_path: check all effective scope roots (_iter_precedence_scopes) instead of only the project scope root. This mirrors the same precedence list already used by list_effective_commands. - _load_yaml_command_file: validate content file against its own parent directory (directory_path) rather than the project scope root. Content files are always co-located with their config files. Reproduction: create a global command, activate any project, then try to invoke or resolve the global command — previously raised ValueError, now resolves correctly.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughUpdated command file and path validation in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Adds Google-style docstrings to all 22 public functions to satisfy the 80% docstring coverage CI threshold. Functions documented: - sanitize_command_name, normalize_command_type - command_file_name, command_content_file_name - parse_slash_invocation, parse_arguments - render_command_body, render_text_template - get_scope_key, get_scope_label, get_scope_directory - ensure_scope_directory, get_scope_payload, get_context_scope - list_scope_commands, list_effective_commands - get_command, save_command, delete_command - duplicate_command, resolve_command_invocation - strip_private_scope
Problem
When a project context is active, using any Global command fails with:
This affects both the slash picker invocation and the editor resolve path.
Root Cause
Two places in
helpers/commands.pyvalidated file paths exclusively against the project scope directory:_validate_command_path- raisesValueErrorif the command file is not inside the project commands dir._load_yaml_command_file- returnsNone(silent failure) if the content file is not inside the project scope root.Global commands live in the global scope directory, not the project directory, so they always fail these checks when any project is active.
Fix
_validate_command_pathInstead of checking against only the project scope root, check against all effective scope roots using the same
_iter_precedence_scopeslist already used bylist_effective_commands:_load_yaml_command_fileContent files are always co-located with their config file. Validate against the config file's own parent directory (
directory_path) rather than the project scope root:Reproduction
ValueError: Command path is outside the selected scopeChecklist
helpers/commands.pymodifiedast.parseclean)Summary by CodeRabbit