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-CONTEXT.md
T
starmen1265 ae69878b59 fix(05): revise plan to include KB_INTERMEDIATE_PATH config support
- 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>
2026-03-16 23:08:27 +08:00

3.7 KiB

Phase 5: 归档与目录优化 - Context

Gathered: 2026-03-16 Status: Ready for planning Updated: 2026-03-16 (revision: 添加 INT-03 配置支持)

## Phase Boundary

统一中间目录结构,添加自动归档步骤,优化最终目录布局。包括:

  • 中间文件统一存放到 ~/work/intermediate/analysis/{platform}_{content_id}/(支持配置)
  • 分析完成后自动归档到最终目录
  • 最终目录按平台分组,文件名带时间戳前缀

此阶段不涉及代码整合(Phase 6),只处理文件组织和归档逻辑。

## Implementation Decisions

中间目录结构

  • 统一路径: 使用 KB_INTERMEDIATE_PATH 配置项,默认值为 ~/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 模式实现
  • 错误信息的具体格式

<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)
  • 配置项: pydantic-settings BaseSettings + Field + 环境变量

Integration Points

  • Pipeline.steps 配置: 添加 "archive" 到步骤列表
  • ArchiveProcessor 输入: content_id, platform, content_dir, output_file
  • ArchiveProcessor 输出: archive_file 路径
  • KBSettings: 使用 archive_path 配置项,新增 intermediate_path 配置项

</code_context>

## Specific Ideas
  • 中间目录: ~/work/intermediate/analysis/bilibili_BV1xxx/(可通过 KB_INTERMEDIATE_PATH 自定义)
  • 最终目录: ~/work/zq/30.资源/AI分析/bilibili/20260316_BV1xxx_analysis.md
  • 重复检测: 在归档目录下 glob *_{content_id}_analysis.md
  • 归档只复制 md 文件,不复制 json 和其他中间文件
## Deferred Ideas

None — discussion stayed within phase scope


Phase: 05-archive-directory Context gathered: 2026-03-16 Updated: 2026-03-16 (revision: INT-03 配置支持)