feat(reference-curator): implement Python scripts + Gemini quality gate

Build the refcurator shared Python package and 7 CLI scripts that were
previously specification-only. Add Gemini CLI as an independent pre-distillation
quality evaluator, replacing the circular Claude-self-review pattern.

Key changes:
- shared/lib/src/refcurator/: 7-module package (config, db, models, utils,
  manifest, gemini) with PyMySQL + JSON file dual backend
- 7 Click CLI scripts: discover, crawl_mgr, repo, distiller, reviewer,
  exporter, pipeline — each with subcommands for data management
- Gemini quality gate: evaluates raw content BEFORE distillation using
  5 criteria (relevance, authority, completeness, freshness, distill_value)
- Pipeline reordered: discovery → crawl → store → evaluate → distill → export
- Bug fixes from Codex adversarial review:
  - FileBackend now hard-fails on JOIN/aggregate/GROUP BY queries
  - Exporter uses MAX(review_id) to prevent shipping stale approvals
  - Distiller updates existing rows on refactor instead of forking
- Updated all 7 CLAUDE.md directives with real script references
- install.sh updated with refcurator package install step

51/51 E2E tests passing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-12 18:19:52 +09:00
parent 133df68b81
commit f215c11c32
23 changed files with 3917 additions and 583 deletions

View File

@@ -51,6 +51,7 @@ COMMANDS=(
"content-distiller"
"quality-reviewer"
"markdown-exporter"
"reference-curator-pipeline"
)
# ============================================================================
@@ -541,6 +542,16 @@ check_status() {
print_info "MySQL not configured or client not installed"
fi
# Check Python package
print_substep "Python Package (refcurator)"
if uv run python3 -c "import refcurator; print(refcurator.__version__)" &>/dev/null; then
local pkg_version=$(uv run python3 -c "import refcurator; print(refcurator.__version__)" 2>/dev/null)
print_success "refcurator $pkg_version installed"
else
print_warning "refcurator package not installed — scripts will not work"
all_ok=false
fi
# Check Claude Code commands
print_substep "Claude Code Commands ($CLAUDE_COMMANDS_DIR)"
for cmd in "${COMMANDS[@]}"; do
@@ -670,11 +681,43 @@ install() {
setup_database
fi
install_python_package
register_commands
register_skills
post_install
}
# ============================================================================
# Install Python Package
# ============================================================================
install_python_package() {
print_step "Step 5b: Installing Python Package (refcurator)"
print_substep "Checking for uv package manager"
if command -v uv &> /dev/null; then
print_success "uv found: $(uv --version 2>/dev/null)"
else
print_warning "uv not found — install with: curl -LsSf https://astral.sh/uv/install.sh | sh"
print_info "Skipping Python package installation"
return 0
fi
print_substep "Installing refcurator package"
local pkg_dir="$SCRIPT_DIR/shared/lib"
if [[ -f "$pkg_dir/pyproject.toml" ]]; then
if uv pip install -e "$pkg_dir" 2>/dev/null; then
print_success "refcurator package installed (editable mode)"
else
print_warning "Failed to install refcurator — scripts may not work"
print_info "Try manually: uv pip install -e $pkg_dir"
fi
else
print_error "pyproject.toml not found at $pkg_dir"
fi
}
# ============================================================================
# Minimal Installation (Firecrawl only)
# ============================================================================
@@ -712,6 +755,7 @@ EOF
install_configs
create_directories
install_python_package
register_commands
register_skills
post_install