ae69878b59
- Add INT-03 requirement to 05-01-PLAN.md requirements field - Add Task 1 for KB_INTERMEDIATE_PATH config in KBSettings - Update Task 2 and Task 3 to use configurable path instead of hardcoded - Update 05-CONTEXT.md to reflect new decision (config support vs hardcoded) Addresses checker issue: requirement_coverage for INT-03 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
228 lines
7.8 KiB
Markdown
228 lines
7.8 KiB
Markdown
---
|
|
phase: 05-archive-directory
|
|
plan: 01
|
|
type: execute
|
|
wave: 1
|
|
depends_on: []
|
|
files_modified:
|
|
- kb_pipeline/config.py
|
|
- kb_pipeline/pipeline.py
|
|
- kb-workflow/kb_workflow.py
|
|
autonomous: true
|
|
requirements:
|
|
- INT-01
|
|
- INT-02
|
|
- INT-03
|
|
|
|
must_haves:
|
|
truths:
|
|
- "Pipeline uses configurable intermediate directory (KB_INTERMEDIATE_PATH or default)"
|
|
- "Content directory follows {platform}_{content_id}/ naming convention"
|
|
- "CLI defaults to intermediate directory when no output_dir specified"
|
|
- "Users can customize intermediate path via KB_INTERMEDIATE_PATH env var"
|
|
artifacts:
|
|
- path: "kb_pipeline/config.py"
|
|
provides: "KB_INTERMEDIATE_PATH configuration"
|
|
contains: "intermediate_path"
|
|
- path: "kb_pipeline/pipeline.py"
|
|
provides: "Intermediate directory path logic"
|
|
contains: "intermediate"
|
|
- path: "kb-workflow/kb_workflow.py"
|
|
provides: "CLI default output directory"
|
|
contains: "intermediate"
|
|
key_links:
|
|
- from: "kb-workflow/kb_workflow.py"
|
|
to: "kb_pipeline/pipeline.py"
|
|
via: "output_dir parameter"
|
|
pattern: "output_dir.*intermediate"
|
|
- from: "kb_pipeline/pipeline.py"
|
|
to: "kb_pipeline/config.py"
|
|
via: "get_settings().intermediate_path"
|
|
pattern: "settings.intermediate_path"
|
|
---
|
|
|
|
<objective>
|
|
统一中间目录结构,支持通过 KB_INTERMEDIATE_PATH 配置自定义路径
|
|
|
|
Purpose: 为所有分析任务提供一致的中间文件存储位置,同时支持用户自定义路径
|
|
Output: 修改 Config、Pipeline 和 CLI 使用统一的中间目录路径
|
|
</objective>
|
|
|
|
<execution_context>
|
|
@/home/starmen1265/.claude/get-shit-done/workflows/execute-plan.md
|
|
@/home/starmen1265/.claude/get-shit-done/templates/summary.md
|
|
</execution_context>
|
|
|
|
<context>
|
|
@.planning/PROJECT.md
|
|
@.planning/ROADMAP.md
|
|
@.planning/STATE.md
|
|
@.planning/phases/05-archive-directory/05-CONTEXT.md
|
|
|
|
<interfaces>
|
|
<!-- Key interfaces from existing codebase -->
|
|
|
|
From kb_pipeline/config.py:
|
|
```python
|
|
class KBSettings(BaseSettings):
|
|
base_path: str = Field(..., description="基础路径")
|
|
archive_path: str = Field(..., description="归档目录")
|
|
```
|
|
|
|
From kb_pipeline/pipeline.py:
|
|
```python
|
|
class Pipeline:
|
|
def __init__(
|
|
self,
|
|
processors: List[BaseProcessor],
|
|
config: Optional[PipelineConfig] = None,
|
|
output_dir: Optional[Path] = None,
|
|
):
|
|
self.output_dir = output_dir or Path.cwd()
|
|
|
|
def _get_content_dir(self, parsed: ParsedLink) -> Path:
|
|
content_dir = self.output_dir / f"{parsed.platform}_{parsed.content_id}"
|
|
content_dir.mkdir(parents=True, exist_ok=True)
|
|
return content_dir
|
|
```
|
|
|
|
From kb-workflow/kb_workflow.py:
|
|
```python
|
|
def process_command(
|
|
url: str,
|
|
output_dir: Optional[str] = None,
|
|
skip_completed: bool = True
|
|
) -> Dict[str, Any]:
|
|
out_dir = Path(output_dir) if output_dir else Path.cwd()
|
|
```
|
|
</interfaces>
|
|
</context>
|
|
|
|
<tasks>
|
|
|
|
<task type="auto">
|
|
<name>Task 1: Add KB_INTERMEDIATE_PATH config to KBSettings</name>
|
|
<files>kb_pipeline/config.py</files>
|
|
<action>
|
|
Add intermediate_path field to KBSettings class:
|
|
|
|
```python
|
|
class KBSettings(BaseSettings):
|
|
base_path: str = Field(..., description="基础路径")
|
|
archive_path: str = Field(..., description="归档目录")
|
|
intermediate_path: str = Field(
|
|
default_factory=lambda: str(Path.home() / "work" / "intermediate" / "analysis"),
|
|
description="中间文件存储目录"
|
|
)
|
|
```
|
|
|
|
Key points:
|
|
- Use Field with default_factory for lazy evaluation
|
|
- Default path is `~/work/intermediate/analysis/`
|
|
- Users can override via `KB_INTERMEDIATE_PATH` environment variable (pydantic-settings convention)
|
|
- Follow existing config pattern for archive_path
|
|
</action>
|
|
<verify>
|
|
<automated>python3 -c "from kb_pipeline.config import get_settings; s = get_settings(); assert hasattr(s, 'intermediate_path'); print(s.intermediate_path)"</automated>
|
|
</verify>
|
|
<done>
|
|
- KBSettings has intermediate_path field
|
|
- Default value is ~/work/intermediate/analysis/
|
|
- Field follows pydantic-settings naming convention (KB_INTERMEDIATE_PATH env var)
|
|
</done>
|
|
</task>
|
|
|
|
<task type="auto">
|
|
<name>Task 2: Update Pipeline to use configurable intermediate directory</name>
|
|
<files>kb_pipeline/pipeline.py</files>
|
|
<action>
|
|
1. Remove module-level INTERMEDIATE_DIR constant (if exists) or don't add it
|
|
|
|
2. Modify `Pipeline.__init__` to use settings.intermediate_path as default:
|
|
- Import get_settings if not already imported
|
|
- Change `self.output_dir = output_dir or Path.cwd()`
|
|
- To: `self.output_dir = output_dir or Path(self.settings.intermediate_path)`
|
|
|
|
3. Ensure settings is available in __init__:
|
|
- BaseProcessor already sets self.settings = get_settings()
|
|
- Pipeline may need to call get_settings() if not inheriting
|
|
|
|
Key points:
|
|
- Use settings.intermediate_path instead of hardcoded path
|
|
- output_dir parameter still allows override for testing
|
|
- Content directory naming stays as `{platform}_{content_id}/`
|
|
</action>
|
|
<verify>
|
|
<automated>python3 -c "from kb_pipeline.pipeline import Pipeline; from kb_pipeline.config import get_settings; s = get_settings(); p = Pipeline([]); assert str(p.output_dir) == s.intermediate_path"</automated>
|
|
</verify>
|
|
<done>
|
|
- Pipeline uses settings.intermediate_path as default
|
|
- No hardcoded INTERMEDIATE_DIR constant
|
|
- Content directory naming unchanged
|
|
</done>
|
|
</task>
|
|
|
|
<task type="auto">
|
|
<name>Task 3: Update CLI to use configurable intermediate directory default</name>
|
|
<files>kb-workflow/kb_workflow.py</files>
|
|
<action>
|
|
1. Get settings at the start of process_command:
|
|
```python
|
|
from kb_pipeline.config import get_settings
|
|
settings = get_settings()
|
|
```
|
|
|
|
2. Modify `process_command` to use intermediate_path as default:
|
|
- Change: `out_dir = Path(output_dir) if output_dir else Path.cwd()`
|
|
- To: `out_dir = Path(output_dir) if output_dir else Path(settings.intermediate_path)`
|
|
|
|
3. Update docstring to document the default output directory behavior
|
|
|
|
Key points:
|
|
- When no -o/--output-dir specified, content goes to configured intermediate path
|
|
- User can still override with -o flag for testing or special cases
|
|
- Users can customize via KB_INTERMEDIATE_PATH env var
|
|
</action>
|
|
<verify>
|
|
<automated>python3 -c "from kb_workflow import process_command; import inspect; src = inspect.getsource(process_command); assert 'intermediate_path' in src"</automated>
|
|
</verify>
|
|
<done>
|
|
- CLI uses settings.intermediate_path as default
|
|
- Default output directory is configurable via KB_INTERMEDIATE_PATH
|
|
- Help text updated to reflect default
|
|
</done>
|
|
</task>
|
|
|
|
</tasks>
|
|
|
|
<verification>
|
|
1. Run existing tests to ensure no regression:
|
|
```bash
|
|
python3 -m pytest tests/ -v --tb=short
|
|
```
|
|
|
|
2. Verify intermediate path configuration works:
|
|
```bash
|
|
python3 -c "from kb_pipeline.config import get_settings; s = get_settings(); print(f'intermediate_path: {s.intermediate_path}')"
|
|
```
|
|
Expected: /home/{user}/work/intermediate/analysis (or custom if KB_INTERMEDIATE_PATH is set)
|
|
|
|
3. Verify env var override works:
|
|
```bash
|
|
KB_INTERMEDIATE_PATH=/tmp/test_intermediate python3 -c "from kb_pipeline.config import get_settings; s = get_settings(); print(s.intermediate_path)"
|
|
```
|
|
Expected: /tmp/test_intermediate
|
|
</verification>
|
|
|
|
<success_criteria>
|
|
- INT-01: All analysis tasks use configurable intermediate directory
|
|
- INT-02: Content directory naming is `{platform}_{content_id}/`
|
|
- INT-03: Users can customize intermediate path via KB_INTERMEDIATE_PATH env var
|
|
- Existing tests pass
|
|
- Default path is ~/work/intermediate/analysis/ when no env var is set
|
|
</success_criteria>
|
|
|
|
<output>
|
|
After completion, create `.planning/phases/05-archive-directory/05-01-SUMMARY.md`
|
|
</output>
|