fix: sync CLI flags across analyze/pdf/unified commands and fix workflow JSON config
Flag/option synchronization fixes: - analyze: add --dry-run, --api-key, and all workflow flags (--enhance-workflow, --enhance-stage, --var, --workflow-dry-run) via WORKFLOW_ARGUMENTS merge - pdf: add --api-key to PDF_ARGUMENTS; replace 5 hardcoded add_argument() calls in pdf_scraper.py:main() with add_pdf_arguments() to activate all defined args - unified: add --api-key and --enhance-level (global override) to UNIFIED_ARGUMENTS and standalone parser; wire enhance_level CLI override into run() per-source loop - codebase_scraper: fix --enhance-workflow to use action="append" (was type=str), enabling multiple workflow chaining instead of silently dropping all but last ConfigManager test isolation fix: - __init__ now reads self.CONFIG_DIR/CONFIG_FILE/PROGRESS_DIR class variables instead of calling _get_config_dir()/_get_progress_dir() directly, enabling monkeypatching in tests (fixes pre-existing test_add_and_retrieve_github_profile) Workflow JSON config support in unified_scraper: - Phase 5 now reads workflows/workflow_stages/workflow_vars from top-level JSON config and merges them with CLI args (CLI-first ordering); supports running workflows even when unified scraper is called without CLI args (args=None) Tests: 1,949 passed, 0 failed (added 18 new tests across 3 test files) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,8 @@ Includes preset system support for #268.
|
||||
import argparse
|
||||
from typing import Any
|
||||
|
||||
from .workflow import WORKFLOW_ARGUMENTS
|
||||
|
||||
ANALYZE_ARGUMENTS: dict[str, dict[str, Any]] = {
|
||||
# Core options
|
||||
"directory": {
|
||||
@@ -169,8 +171,27 @@ ANALYZE_ARGUMENTS: dict[str, dict[str, Any]] = {
|
||||
"help": "Enable verbose logging",
|
||||
},
|
||||
},
|
||||
# Dry-run and API key (parity with scrape/github/pdf)
|
||||
"dry_run": {
|
||||
"flags": ("--dry-run",),
|
||||
"kwargs": {
|
||||
"action": "store_true",
|
||||
"help": "Preview what will be analyzed without creating output",
|
||||
},
|
||||
},
|
||||
"api_key": {
|
||||
"flags": ("--api-key",),
|
||||
"kwargs": {
|
||||
"type": str,
|
||||
"help": "Anthropic API key (or set ANTHROPIC_API_KEY env var)",
|
||||
"metavar": "KEY",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
# Add workflow arguments (enhance_workflow, enhance_stage, var, workflow_dry_run, workflow_history)
|
||||
ANALYZE_ARGUMENTS.update(WORKFLOW_ARGUMENTS)
|
||||
|
||||
|
||||
def add_analyze_arguments(parser: argparse.ArgumentParser) -> None:
|
||||
"""Add all analyze command arguments to a parser."""
|
||||
|
||||
@@ -81,6 +81,15 @@ PDF_ARGUMENTS: dict[str, dict[str, Any]] = {
|
||||
"help": "Preview workflow without executing (requires --enhance-workflow)",
|
||||
},
|
||||
},
|
||||
# API key (parity with scrape/github/analyze)
|
||||
"api_key": {
|
||||
"flags": ("--api-key",),
|
||||
"kwargs": {
|
||||
"type": str,
|
||||
"help": "Anthropic API key (or set ANTHROPIC_API_KEY env var)",
|
||||
"metavar": "KEY",
|
||||
},
|
||||
},
|
||||
# Enhancement level
|
||||
"enhance_level": {
|
||||
"flags": ("--enhance-level",),
|
||||
|
||||
@@ -72,6 +72,28 @@ UNIFIED_ARGUMENTS: dict[str, dict[str, Any]] = {
|
||||
"help": "Preview workflow stages without executing (requires --enhance-workflow)",
|
||||
},
|
||||
},
|
||||
# API key and enhance-level (parity with scrape/github/analyze/pdf)
|
||||
"api_key": {
|
||||
"flags": ("--api-key",),
|
||||
"kwargs": {
|
||||
"type": str,
|
||||
"help": "Anthropic API key (or set ANTHROPIC_API_KEY env var)",
|
||||
"metavar": "KEY",
|
||||
},
|
||||
},
|
||||
"enhance_level": {
|
||||
"flags": ("--enhance-level",),
|
||||
"kwargs": {
|
||||
"type": int,
|
||||
"choices": [0, 1, 2, 3],
|
||||
"default": None,
|
||||
"help": (
|
||||
"Global AI enhancement level override (0=off, 1=SKILL.md, "
|
||||
"2=+arch/config, 3=full). Overrides per-source enhance_level in config."
|
||||
),
|
||||
"metavar": "LEVEL",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2406,9 +2406,10 @@ Examples:
|
||||
# Workflow enhancement arguments
|
||||
parser.add_argument(
|
||||
"--enhance-workflow",
|
||||
type=str,
|
||||
action="append",
|
||||
help=(
|
||||
"Enhancement workflow to use (name or path to YAML file). "
|
||||
"Can be used multiple times to chain workflows. "
|
||||
"Examples: 'security-focus', 'architecture-comprehensive', "
|
||||
"'.skill-seekers/my-workflow.yaml'. "
|
||||
"Overrides --enhance-level when provided."
|
||||
|
||||
@@ -58,9 +58,9 @@ class ConfigManager:
|
||||
|
||||
def __init__(self):
|
||||
"""Initialize configuration manager."""
|
||||
self.config_dir = _get_config_dir()
|
||||
self.config_file = self.config_dir / "config.json"
|
||||
self.progress_dir = _get_progress_dir()
|
||||
self.config_dir = self.CONFIG_DIR
|
||||
self.config_file = self.CONFIG_FILE
|
||||
self.progress_dir = self.PROGRESS_DIR
|
||||
self._ensure_directories()
|
||||
|
||||
# Check if config file exists before loading
|
||||
|
||||
@@ -633,16 +633,14 @@ class PDFToSkillConverter:
|
||||
|
||||
|
||||
def main():
|
||||
from .arguments.pdf import add_pdf_arguments
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Convert PDF documentation to Claude skill",
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||
)
|
||||
|
||||
parser.add_argument("--config", help="PDF config JSON file")
|
||||
parser.add_argument("--pdf", help="Direct PDF file path")
|
||||
parser.add_argument("--name", help="Skill name (with --pdf)")
|
||||
parser.add_argument("--from-json", help="Build skill from extracted JSON")
|
||||
parser.add_argument("--description", help="Skill description")
|
||||
add_pdf_arguments(parser)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
@@ -561,8 +561,9 @@ class UnifiedScraper:
|
||||
extract_docs = source.get("extract_docs", True)
|
||||
# Note: Signal flow analysis is automatic for Godot projects (C3.10)
|
||||
|
||||
# AI enhancement settings
|
||||
enhance_level = source.get("enhance_level", 0)
|
||||
# AI enhancement settings (CLI --enhance-level overrides per-source config)
|
||||
cli_enhance_level = getattr(args, "enhance_level", None) if args is not None else None
|
||||
enhance_level = cli_enhance_level if cli_enhance_level is not None else source.get("enhance_level", 0)
|
||||
|
||||
# Run codebase analysis
|
||||
logger.info(f" Analysis depth: {analysis_depth}")
|
||||
@@ -972,14 +973,47 @@ class UnifiedScraper:
|
||||
self.build_skill(merged_data)
|
||||
|
||||
# Phase 5: Enhancement Workflow Integration
|
||||
if args is not None:
|
||||
# Support workflow fields in JSON config as well as CLI args.
|
||||
# JSON fields: "workflows" (list), "workflow_stages" (list), "workflow_vars" (dict)
|
||||
# CLI args always take precedence; JSON fields are appended after.
|
||||
json_workflows = self.config.get("workflows", [])
|
||||
json_stages = self.config.get("workflow_stages", [])
|
||||
json_vars = self.config.get("workflow_vars", {})
|
||||
has_json_workflows = bool(json_workflows or json_stages or json_vars)
|
||||
|
||||
if args is not None or has_json_workflows:
|
||||
import argparse
|
||||
|
||||
from skill_seekers.cli.workflow_runner import run_workflows
|
||||
|
||||
# Build effective args: use CLI args when provided, otherwise empty namespace
|
||||
effective_args = args if args is not None else argparse.Namespace(
|
||||
enhance_workflow=None,
|
||||
enhance_stage=None,
|
||||
var=None,
|
||||
workflow_dry_run=False,
|
||||
)
|
||||
|
||||
# Merge JSON workflow config into effective_args (JSON appended after CLI)
|
||||
if json_workflows:
|
||||
effective_args.enhance_workflow = (
|
||||
list(effective_args.enhance_workflow or []) + json_workflows
|
||||
)
|
||||
if json_stages:
|
||||
effective_args.enhance_stage = (
|
||||
list(effective_args.enhance_stage or []) + json_stages
|
||||
)
|
||||
if json_vars:
|
||||
effective_args.var = (
|
||||
list(effective_args.var or [])
|
||||
+ [f"{k}={v}" for k, v in json_vars.items()]
|
||||
)
|
||||
|
||||
unified_context = {
|
||||
"name": self.config.get("name", ""),
|
||||
"description": self.config.get("description", ""),
|
||||
}
|
||||
run_workflows(args, context=unified_context)
|
||||
run_workflows(effective_args, context=unified_context)
|
||||
|
||||
logger.info("\n" + "✅ " * 20)
|
||||
logger.info("Unified scraping complete!")
|
||||
@@ -1067,6 +1101,24 @@ Examples:
|
||||
dest="workflow_dry_run",
|
||||
help="Preview workflow stages without executing (requires --enhance-workflow)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--api-key",
|
||||
type=str,
|
||||
metavar="KEY",
|
||||
help="Anthropic API key (or set ANTHROPIC_API_KEY env var)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--enhance-level",
|
||||
type=int,
|
||||
choices=[0, 1, 2, 3],
|
||||
default=None,
|
||||
metavar="LEVEL",
|
||||
help=(
|
||||
"Global AI enhancement level override for all sources "
|
||||
"(0=off, 1=SKILL.md, 2=+arch/config, 3=full). "
|
||||
"Overrides per-source enhance_level in config."
|
||||
),
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user