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>
7.8 KiB
7.8 KiB
phase, plan, type, wave, depends_on, files_modified, autonomous, requirements, must_haves
| phase | plan | type | wave | depends_on | files_modified | autonomous | requirements | must_haves | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 05-archive-directory | 01 | execute | 1 |
|
true |
|
|
Purpose: 为所有分析任务提供一致的中间文件存储位置,同时支持用户自定义路径 Output: 修改 Config、Pipeline 和 CLI 使用统一的中间目录路径
<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/05-archive-directory/05-CONTEXT.mdFrom kb_pipeline/config.py:
class KBSettings(BaseSettings):
base_path: str = Field(..., description="基础路径")
archive_path: str = Field(..., description="归档目录")
From kb_pipeline/pipeline.py:
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:
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()
```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
python3 -c "from kb_pipeline.config import get_settings; s = get_settings(); assert hasattr(s, 'intermediate_path'); print(s.intermediate_path)"
- KBSettings has intermediate_path field
- Default value is ~/work/intermediate/analysis/
- Field follows pydantic-settings naming convention (KB_INTERMEDIATE_PATH env var)
Task 2: Update Pipeline to use configurable intermediate directory
kb_pipeline/pipeline.py
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}/`
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"
- Pipeline uses settings.intermediate_path as default
- No hardcoded INTERMEDIATE_DIR constant
- Content directory naming unchanged
Task 3: Update CLI to use configurable intermediate directory default
kb-workflow/kb_workflow.py
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
python3 -c "from kb_workflow import process_command; import inspect; src = inspect.getsource(process_command); assert 'intermediate_path' in src"
- CLI uses settings.intermediate_path as default
- Default output directory is configurable via KB_INTERMEDIATE_PATH
- Help text updated to reflect default
1. Run existing tests to ensure no regression:
```bash
python3 -m pytest tests/ -v --tb=short
```
-
Verify intermediate path configuration works:
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)
-
Verify env var override works:
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
<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>