This repository has been archived on 2026-08-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
kb-skills/.planning/phases/05-archive-directory/05-01-PLAN.md
T

172 lines
5.4 KiB
Markdown

---
phase: 05-archive-directory
plan: 01
type: execute
wave: 1
depends_on: []
files_modified:
- kb_pipeline/pipeline.py
- kb-workflow/kb_workflow.py
autonomous: true
requirements:
- INT-01
- INT-02
must_haves:
truths:
- "Pipeline uses ~/work/intermediate/analysis/ as intermediate directory"
- "Content directory follows {platform}_{content_id}/ naming convention"
- "CLI defaults to intermediate directory when no output_dir specified"
artifacts:
- 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"
---
<objective>
统一中间目录结构到 `~/work/intermediate/analysis/`
Purpose: 为所有分析任务提供一致的中间文件存储位置,便于管理和清理
Output: 修改 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/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 intermediate directory constant and update Pipeline</name>
<files>kb_pipeline/pipeline.py</files>
<action>
1. Add module-level constant for intermediate directory:
```python
INTERMEDIATE_DIR = Path.home() / "work" / "intermediate" / "analysis"
```
2. Modify `Pipeline.__init__` to use intermediate directory as default:
- Change `self.output_dir = output_dir or Path.cwd()` to use `INTERMEDIATE_DIR`
- The output_dir parameter still allows override for testing
3. Update `_get_content_dir` to ensure it follows `{platform}_{content_id}/` naming:
- Current implementation already does this: `f"{parsed.platform}_{parsed.content_id}"`
- Verify no changes needed
Key points:
- Hard-code path as `~/work/intermediate/analysis/` (per user decision)
- Do NOT add KB_INTERMEDIATE_PATH config option (user explicitly decided against this)
- Content directory naming stays as `{platform}_{content_id}/`
</action>
<verify>
<automated>python3 -c "from kb_pipeline.pipeline import INTERMEDIATE_DIR; assert str(INTERMEDIATE_DIR) == str(Path.home() / 'work' / 'intermediate' / 'analysis')"</automated>
</verify>
<done>
- INTERMEDIATE_DIR constant defined in pipeline.py
- Pipeline defaults to intermediate directory
- Content directory naming unchanged
</done>
</task>
<task type="auto">
<name>Task 2: Update CLI to use intermediate directory default</name>
<files>kb-workflow/kb_workflow.py</files>
<action>
1. Import INTERMEDIATE_DIR from kb_pipeline.pipeline:
```python
from kb_pipeline.pipeline import Pipeline, INTERMEDIATE_DIR
```
2. Modify `process_command` to use intermediate directory as default:
- Change: `out_dir = Path(output_dir) if output_dir else Path.cwd()`
- To: `out_dir = Path(output_dir) if output_dir else INTERMEDIATE_DIR`
3. Update docstring to document the default output directory behavior
Key points:
- When no -o/--output-dir specified, content goes to ~/work/intermediate/analysis/
- User can still override with -o flag for testing or special cases
</action>
<verify>
<automated>python3 -c "from kb_workflow import process_command; import inspect; src = inspect.getsource(process_command); assert 'INTERMEDIATE_DIR' in src"</automated>
</verify>
<done>
- CLI imports INTERMEDIATE_DIR
- Default output directory is ~/work/intermediate/analysis/
- 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 directory path is correct:
```bash
python3 -c "from kb_pipeline.pipeline import INTERMEDIATE_DIR; print(INTERMEDIATE_DIR)"
```
Expected: /home/{user}/work/intermediate/analysis
</verification>
<success_criteria>
- INT-01: All analysis tasks use `~/work/intermediate/analysis/` as intermediate directory
- INT-02: Content directory naming is `{platform}_{content_id}/`
- No KB_INTERMEDIATE_PATH config option added (per user decision)
- Existing tests pass
</success_criteria>
<output>
After completion, create `.planning/phases/05-archive-directory/05-01-SUMMARY.md`
</output>