docs(05): capture phase context
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
# Phase 5: 归档与目录优化 - Context
|
||||
|
||||
**Gathered:** 2026-03-16
|
||||
**Status:** Ready for planning
|
||||
|
||||
<domain>
|
||||
## Phase Boundary
|
||||
|
||||
统一中间目录结构,添加自动归档步骤,优化最终目录布局。包括:
|
||||
- 中间文件统一存放到 `~/work/intermediate/analysis/{platform}_{content_id}/`
|
||||
- 分析完成后自动归档到最终目录
|
||||
- 最终目录按平台分组,文件名带时间戳前缀
|
||||
|
||||
此阶段不涉及代码整合(Phase 6),只处理文件组织和归档逻辑。
|
||||
|
||||
</domain>
|
||||
|
||||
<decisions>
|
||||
## Implementation Decisions
|
||||
|
||||
### 中间目录结构
|
||||
- **统一路径**: 硬编码 `~/work/intermediate/analysis/`
|
||||
- **内容目录命名**: `{platform}_{content_id}/` 格式
|
||||
- **无需配置项**: 不添加 KB_INTERMEDIATE_PATH,使用固定路径
|
||||
|
||||
### 归档触发时机
|
||||
- **自动归档**: 分析完成后自动执行 ArchiveProcessor
|
||||
- **步骤顺序**: parse → download → asr → analyze → archive
|
||||
- **归档只复制**: md 文件复制到最终目录,不移动
|
||||
|
||||
### 归档目标目录
|
||||
- **配置项**: 使用现有 `KB_ARCHIVE_PATH` 配置
|
||||
- **目录结构**: `{KB_ARCHIVE_PATH}/{platform}/`
|
||||
- **文件命名**: `{YYYYMMDD}_{content_id}_analysis.md`
|
||||
- **时间戳来源**: 归档执行时的日期
|
||||
|
||||
### 归档重复检测
|
||||
- **判断策略**: 按 content_id 匹配,搜索 `*_{content_id}_analysis.md`
|
||||
- **发现重复时**: 询问用户是否覆盖
|
||||
- **用户确认方式**: 复用现有 rich.prompt.Confirm 模式
|
||||
|
||||
### 中间文件清理
|
||||
- **不自动清理**: 归档后保留中间文件
|
||||
- **手动维护**: 用户需要定期手动清理
|
||||
|
||||
### 错误处理
|
||||
- **归档失败**: 标记步骤为失败,记录错误信息
|
||||
- **后续操作**: 用户可重新执行归档步骤
|
||||
|
||||
### Claude's Discretion
|
||||
- ArchiveProcessor 的具体实现结构
|
||||
- 重复检测的 glob 模式实现
|
||||
- 错误信息的具体格式
|
||||
|
||||
</decisions>
|
||||
|
||||
<code_context>
|
||||
## Existing Code Insights
|
||||
|
||||
### Reusable Assets
|
||||
- `kb_pipeline/config.py`: KBSettings 类,包含 base_path 和 archive_path 配置
|
||||
- `kb_pipeline/pipeline.py`: Pipeline 编排引擎,可扩展添加 archive 步骤
|
||||
- `kb_pipeline/schemas.py`: StepInput/StepOutput 基类,可扩展 ArchiveInput/ArchiveOutput
|
||||
- `kb_pipeline/processors/base.py`: BaseProcessor 基类,可继承实现 ArchiveProcessor
|
||||
- `kb_pipeline/state.py`: WorkflowStateManager,支持 archive 步骤状态记录
|
||||
- `kb_pipeline/processors/analyze.py`: AnalyzeProcessor,输出文件在 content_dir
|
||||
|
||||
### Established Patterns
|
||||
- 处理器模式: BaseProcessor + process(input) -> output
|
||||
- 状态管理: state.mark_step_completed/failed
|
||||
- 用户确认: rich.prompt.Confirm.ask() 或 input() fallback
|
||||
- 目录创建: Path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
### Integration Points
|
||||
- Pipeline.steps 配置: 添加 "archive" 到步骤列表
|
||||
- ArchiveProcessor 输入: content_id, platform, content_dir, output_file
|
||||
- ArchiveProcessor 输出: archive_file 路径
|
||||
- KBSettings: 使用 archive_path 配置项
|
||||
|
||||
</code_context>
|
||||
|
||||
<specifics>
|
||||
## Specific Ideas
|
||||
|
||||
- 中间目录: `~/work/intermediate/analysis/bilibili_BV1xxx/`
|
||||
- 最终目录: `~/work/zq/30.资源/AI分析/bilibili/20260316_BV1xxx_analysis.md`
|
||||
- 重复检测: 在归档目录下 glob `*_{content_id}_analysis.md`
|
||||
- 归档只复制 md 文件,不复制 json 和其他中间文件
|
||||
|
||||
</specifics>
|
||||
|
||||
<deferred>
|
||||
## Deferred Ideas
|
||||
|
||||
None — discussion stayed within phase scope
|
||||
|
||||
</deferred>
|
||||
|
||||
---
|
||||
|
||||
*Phase: 05-archive-directory*
|
||||
*Context gathered: 2026-03-16*
|
||||
Reference in New Issue
Block a user