From 47226340ac36a2fe18ae5e8850ab1d86027ec1e2 Mon Sep 17 00:00:00 2001 From: yusyus Date: Sat, 21 Feb 2026 23:51:04 +0300 Subject: [PATCH] feat: add CONFIG_ARGUMENTS and fix _route_config for unified scraper parity Previously _route_config only forwarded --dry-run, silently dropping all enhancement workflows, --merge-mode, and --skip-codebase-analysis. Changes: - arguments/create.py: add CONFIG_ARGUMENTS dict with merge_mode and skip_codebase_analysis; wire into get_source_specific_arguments(), get_compatible_arguments(), and add_create_arguments(mode='config') - create_command.py: fix _route_config to forward --fresh, --merge-mode, --skip-codebase-analysis, and all 4 workflow flags; add --help-config handler (skill-seekers create --help-config) matching other help modes - parsers/create_parser.py: add --help-config flag for unified CLI parity - tests/test_create_arguments.py: import CONFIG_ARGUMENTS; update config source tests to assert correct content instead of empty dict Co-Authored-By: Claude Sonnet 4.6 --- src/skill_seekers/cli/arguments/create.py | 28 ++++++++++++- src/skill_seekers/cli/create_command.py | 41 +++++++++++++++---- .../cli/parsers/create_parser.py | 6 +++ tests/test_create_arguments.py | 15 +++++-- 4 files changed, 78 insertions(+), 12 deletions(-) diff --git a/src/skill_seekers/cli/arguments/create.py b/src/skill_seekers/cli/arguments/create.py index 1b20329..c1aa7ad 100644 --- a/src/skill_seekers/cli/arguments/create.py +++ b/src/skill_seekers/cli/arguments/create.py @@ -389,6 +389,28 @@ PDF_ARGUMENTS: dict[str, dict[str, Any]] = { }, } +# Multi-source config specific (from unified_scraper.py) +CONFIG_ARGUMENTS: dict[str, dict[str, Any]] = { + "merge_mode": { + "flags": ("--merge-mode",), + "kwargs": { + "type": str, + "choices": ["rule-based", "claude-enhanced"], + "help": "Override merge mode from config (rule-based or claude-enhanced)", + "metavar": "MODE", + }, + }, + "skip_codebase_analysis": { + "flags": ("--skip-codebase-analysis",), + "kwargs": { + "action": "store_true", + "help": "Skip C3.x codebase analysis for GitHub sources in unified config", + }, + }, + # Note: --fresh is intentionally omitted here — it already lives in WEB_ARGUMENTS. + # For unified config files, use `skill-seekers unified --fresh` directly. +} + # ============================================================================= # TIER 3: ADVANCED/RARE ARGUMENTS # ============================================================================= @@ -449,7 +471,7 @@ def get_source_specific_arguments(source_type: str) -> dict[str, dict[str, Any]] "github": GITHUB_ARGUMENTS, "local": LOCAL_ARGUMENTS, "pdf": PDF_ARGUMENTS, - "config": {}, # Config files don't have extra args + "config": CONFIG_ARGUMENTS, } return source_args.get(source_type, {}) @@ -521,6 +543,10 @@ def add_create_arguments(parser: argparse.ArgumentParser, mode: str = "default") for arg_name, arg_def in PDF_ARGUMENTS.items(): parser.add_argument(*arg_def["flags"], **arg_def["kwargs"]) + if mode in ["config", "all"]: + for arg_name, arg_def in CONFIG_ARGUMENTS.items(): + parser.add_argument(*arg_def["flags"], **arg_def["kwargs"]) + # Add advanced arguments if requested if mode in ["advanced", "all"]: for arg_name, arg_def in ADVANCED_ARGUMENTS.items(): diff --git a/src/skill_seekers/cli/create_command.py b/src/skill_seekers/cli/create_command.py index ca4ab00..2c9dd1a 100644 --- a/src/skill_seekers/cli/create_command.py +++ b/src/skill_seekers/cli/create_command.py @@ -300,16 +300,31 @@ class CreateCommand: config_path = self.source_info.parsed["config_path"] argv.extend(["--config", config_path]) - # Add only the arguments that unified_scraper actually supports - # unified_scraper has its own config format that includes: - # name, description, output_dir, enhancement, etc. - # So we only pass behavioral flags here: - + # Behavioral flags supported by unified_scraper + # Note: name/output/enhance-level come from the JSON config file, not CLI if self.args.dry_run: argv.append("--dry-run") + if getattr(self.args, "fresh", False): + argv.append("--fresh") - # Note: unified_scraper gets name, output, enhancement from config file - # not from CLI args. The config format includes these fields. + # Config-specific flags (--merge-mode, --skip-codebase-analysis) + if getattr(self.args, "merge_mode", None): + argv.extend(["--merge-mode", self.args.merge_mode]) + if getattr(self.args, "skip_codebase_analysis", False): + argv.append("--skip-codebase-analysis") + + # Enhancement workflow flags (unified_scraper now supports these) + if getattr(self.args, "enhance_workflow", None): + for wf in self.args.enhance_workflow: + argv.extend(["--enhance-workflow", wf]) + if getattr(self.args, "enhance_stage", None): + for stage in self.args.enhance_stage: + argv.extend(["--enhance-stage", stage]) + if getattr(self.args, "var", None): + for var in self.args.var: + argv.extend(["--var", var]) + if getattr(self.args, "workflow_dry_run", False): + argv.append("--workflow-dry-run") # Call unified_scraper with modified argv logger.debug(f"Calling unified_scraper with argv: {argv}") @@ -456,6 +471,9 @@ Common Workflows: "--help-local", action="store_true", help=argparse.SUPPRESS, dest="_help_local" ) parser.add_argument("--help-pdf", action="store_true", help=argparse.SUPPRESS, dest="_help_pdf") + parser.add_argument( + "--help-config", action="store_true", help=argparse.SUPPRESS, dest="_help_config" + ) parser.add_argument( "--help-advanced", action="store_true", help=argparse.SUPPRESS, dest="_help_advanced" ) @@ -502,6 +520,15 @@ Common Workflows: add_create_arguments(parser_pdf, mode="pdf") parser_pdf.print_help() return 0 + elif args._help_config: + parser_config = argparse.ArgumentParser( + prog="skill-seekers create", + description="Create skill from multi-source config file (unified scraper)", + formatter_class=argparse.RawDescriptionHelpFormatter, + ) + add_create_arguments(parser_config, mode="config") + parser_config.print_help() + return 0 elif args._help_advanced: parser_advanced = argparse.ArgumentParser( prog="skill-seekers create", diff --git a/src/skill_seekers/cli/parsers/create_parser.py b/src/skill_seekers/cli/parsers/create_parser.py index 58c35a9..062be7b 100644 --- a/src/skill_seekers/cli/parsers/create_parser.py +++ b/src/skill_seekers/cli/parsers/create_parser.py @@ -83,6 +83,12 @@ Presets: -p quick (1-2min) | -p standard (5-10min) | -p comprehensive (20-60min) help="Show PDF extraction specific options", dest="_help_pdf", ) + parser.add_argument( + "--help-config", + action="store_true", + help="Show multi-source config file specific options", + dest="_help_config", + ) parser.add_argument( "--help-advanced", action="store_true", diff --git a/tests/test_create_arguments.py b/tests/test_create_arguments.py index 3553953..348d9d1 100644 --- a/tests/test_create_arguments.py +++ b/tests/test_create_arguments.py @@ -12,6 +12,7 @@ from skill_seekers.cli.arguments.create import ( GITHUB_ARGUMENTS, LOCAL_ARGUMENTS, PDF_ARGUMENTS, + CONFIG_ARGUMENTS, ADVANCED_ARGUMENTS, get_universal_argument_names, get_source_specific_arguments, @@ -158,9 +159,11 @@ class TestArgumentHelpers: assert args == PDF_ARGUMENTS def test_get_source_specific_config(self): - """Config should return empty dict (no extra args).""" + """Config should return CONFIG_ARGUMENTS (merge-mode, skip-codebase-analysis).""" args = get_source_specific_arguments("config") - assert args == {} + assert args == CONFIG_ARGUMENTS + assert "merge_mode" in args + assert "skip_codebase_analysis" in args def test_get_source_specific_unknown(self): """Unknown source should return empty dict.""" @@ -223,16 +226,20 @@ class TestCompatibleArguments: assert "ocr" in compatible def test_config_compatible_arguments(self): - """Config source should include universal + advanced only.""" + """Config source should include universal + config-specific + advanced.""" compatible = get_compatible_arguments("config") # Should include universal arguments assert "config" in compatible + # Should include config-specific arguments + assert "merge_mode" in compatible + assert "skip_codebase_analysis" in compatible + # Should include advanced arguments assert "no_preserve_code_blocks" in compatible - # Should not include source-specific arguments + # Should not include other source-specific arguments assert "repo" not in compatible assert "directory" not in compatible