feat: support multiple --enhance-workflow flags with shared workflow_runner

- Change --enhance-workflow from type:str to action:append in all argument
  files (workflow, create, scrape, github, pdf) so the flag can be given
  multiple times to chain workflows in sequence
- Add workflow_runner.py: shared utility used by all 4 scrapers
  - collect_workflow_vars(): merges extra context then user --var flags
    (user flags take precedence over scraper metadata)
  - run_workflows(): executes named workflows in order, then any inline
    --enhance-stage workflow; handles dry-run/preview mode
- Remove duplicate ~115-130 line workflow blocks from doc_scraper,
  github_scraper, pdf_scraper, and codebase_scraper; replace with
  single run_workflows() call each
- Remove mutual exclusivity between workflows and AI enhancement:
  workflows now run first, then traditional enhancement continues
  independently (--enhance-level 0 to disable)
- Add tests/test_workflow_runner.py: 21 tests covering no-flags, single
  workflow, multiple/chained workflows, inline stages, mixed mode,
  variable precedence, and dry-run
- Fix test_markdown_parsing: accept "text" or "unknown" for unlabelled
  code blocks (unified MarkdownParser returns "text" by default)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
yusyus
2026-02-17 22:05:27 +03:00
parent 9fd6cdcd5c
commit 60c46673ed
13 changed files with 959 additions and 16 deletions

View File

@@ -24,8 +24,8 @@ class TestUniversalArguments:
"""Test universal argument definitions."""
def test_universal_count(self):
"""Should have exactly 13 universal arguments (after Phase 1 consolidation)."""
assert len(UNIVERSAL_ARGUMENTS) == 13
"""Should have exactly 17 universal arguments (after Phase 2 workflow integration)."""
assert len(UNIVERSAL_ARGUMENTS) == 17
def test_universal_argument_names(self):
"""Universal arguments should have expected names."""
@@ -43,6 +43,11 @@ class TestUniversalArguments:
"chunk_overlap", # Phase 2: RAG args from common.py
"preset",
"config",
# Phase 2: Workflow arguments (universal workflow support)
"enhance_workflow",
"enhance_stage",
"var",
"workflow_dry_run",
}
assert set(UNIVERSAL_ARGUMENTS.keys()) == expected_names
@@ -123,9 +128,13 @@ class TestArgumentHelpers:
"""Should return set of universal argument names."""
names = get_universal_argument_names()
assert isinstance(names, set)
assert len(names) == 13
assert len(names) == 17 # Phase 2: added 4 workflow arguments
assert "name" in names
assert "enhance_level" in names # Phase 1: consolidated flag
assert "enhance_workflow" in names # Phase 2: workflow support
assert "enhance_stage" in names
assert "var" in names
assert "workflow_dry_run" in names
def test_get_source_specific_web(self):
"""Should return web-specific arguments."""