7.9 KiB
phase, plan, type, wave, depends_on, files_modified, autonomous, requirements, user_setup, must_haves
| phase | plan | type | wave | depends_on | files_modified | autonomous | requirements | user_setup | must_haves | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 04-analysis-orchestration | 03 | execute | 3 |
|
|
true |
|
|
Purpose: Provide AI-powered content analysis that generates structured reports as Markdown files. Output: AnalyzeProcessor implementation with DeepAnalyzer integration.
<execution_context> @/home/starmen1265/.claude/get-shit-done/workflows/execute-plan.md @/home/starmen1265/.claude/get-shit-done/templates/summary.md </execution_context>
@.planning/PROJECT.md @.planning/ROADMAP.md @.planning/STATE.md @.planning/phases/04-analysis-orchestration/04-CONTEXT.md @.planning/phases/04-analysis-orchestration/04-RESEARCH.md @.planning/phases/04-analysis-orchestration/04-01-SUMMARY.md @.planning/phases/04-analysis-orchestration/04-02-SUMMARY.mdFrom kb-deep-analyzer/deep_analyzer.py:
class SimpleAIClient:
def __init__(self, api_key: str = None, provider: str = None, model: str = None, base_url: str = None):
...
def generate(self, prompt: str, max_tokens: int = 16000) -> str:
...
class DeepAnalyzer:
def __init__(self, ai_client: SimpleAIClient = None):
...
def analyze(self, metadata: Dict[str, Any], content: Dict[str, Any], content_type: str = "video") -> AnalysisResult:
...
@dataclass
class AnalysisResult:
summary: str = ""
main_topics: List[str] = field(default_factory=list)
key_insights: List[str] = field(default_factory=list)
recommended_tags: List[str] = field(default_factory=list)
full_analysis: str = ""
original_text: str = ""
def generate_frontmatter(metadata: Dict, result: AnalysisResult, content_type: str = "video") -> str:
...
From kb_pipeline/schemas.py (after 04-01 and 04-02):
class StepInput(BaseModel):
content_id: str
platform: Literal["bilibili", "zhihu"]
class StepOutput(BaseModel):
success: bool
error_message: Optional[str]
completed_at: datetime
From kb_pipeline/processors/base.py (from 04-01):
class BaseProcessor(ABC):
STEP_NAME: str
async def process(self, input_data: StepInput) -> StepOutput
AnalyzeInput fields (extends StepInput):
- metadata_file: str - Path to metadata JSON file
- content_file: str - Path to content file (subtitle JSON or article content)
- content_type: str - Type of content (video or article)
- output_file: str - Path to output analysis Markdown file
AnalyzeOutput fields (extends StepOutput):
- analysis_file: str - Path to generated analysis report
- summary: str - Content summary
- main_topics: List[str] - Main topics extracted
- key_insights: List[str] - Key insights
- tags: List[str] - Recommended tags
- stats: Dict[str, Any] - Statistics about analysis
Create test file with schema validation tests. pytest tests/test_processors/test_analyze.py -v -x -k "test_schema" AnalyzeInput/AnalyzeOutput schemas defined and validated
Task 2: Create AnalyzeProcessor with DeepAnalyzer integration kb_pipeline/processors/analyze.py, tests/test_processors/test_analyze.py - Test 1: AnalyzeProcessor loads metadata and content from files - Test 2: AnalyzeProcessor calls DeepAnalyzer.analyze() with correct parameters - Test 3: AnalyzeProcessor saves analysis report as Markdown - Test 4: AnalyzeProcessor records state on success - Test 5: AnalyzeProcessor records state on failure Create `kb_pipeline/processors/analyze.py` with AnalyzeProcessor class.Implementation:
- Import BaseProcessor from .base
- Import DeepAnalyzer, SimpleAIClient, AnalysisResult, generate_frontmatter from kb_deep_analyzer
- Import AnalyzeInput, AnalyzeOutput from ..schemas
- Create AnalyzeProcessor(BaseProcessor):
- STEP_NAME = "analyze"
- init with state_manager, settings (initialize AI client lazily)
- process() method that: a. Checks if step already completed (skip if done) b. Loads metadata JSON file c. Loads content JSON/text file d. Initializes SimpleAIClient with settings e. Creates DeepAnalyzer instance f. Calls analyzer.analyze(metadata, content, content_type) g. Generates frontmatter using generate_frontmatter() h. Writes analysis report as Markdown i. Records state on success/failure
Output file format:
---
title: "..."
date: ...
author: ...
tags: [...]
---
## 标题
...
## 摘要
...
## 主要主题
...
## 关键见解
...
## 时间轴 (for video only)
...
Create comprehensive tests with mocked DeepAnalyzer. pytest tests/test_processors/test_analyze.py -v -x AnalyzeProcessor generates analysis reports using DeepAnalyzer
Task 3: Update processors __init__.py kb_pipeline/processors/__init__.py Update `kb_pipeline/processors/__init__.py` to export AnalyzeProcessor.from .base import BaseProcessor
from .parse import ParseProcessor
from .download import DownloadProcessor
from .asr import ASRProcessor
from .analyze import AnalyzeProcessor
__all__ = ["BaseProcessor", "ParseProcessor", "DownloadProcessor", "ASRProcessor", "AnalyzeProcessor"]
<success_criteria>
- AnalyzeProcessor inherits from BaseProcessor
- AnalyzeInput/AnalyzeOutput schemas exist and validate
- DeepAnalyzer is integrated correctly (no modifications to existing code)
- Analysis reports are saved with proper frontmatter
- All tests pass </success_criteria>