---
phase: 47-library-records-deprecation-cleanup
plan: 002
type: execute
wave: 1
depends_on: []
files_modified:
  - paperforge/setup_wizard.py
  - command/pf-sync.md
  - command/pf-ocr.md
  - command/pf-status.md
  - command/pf-paper.md
  - command/pf-deep.md
  - paperforge/command_files/pf-sync.md
  - paperforge/command_files/pf-ocr.md
  - paperforge/command_files/pf-status.md
  - paperforge/command_files/pf-paper.md
  - paperforge/command_files/pf-deep.md
autonomous: true
requirements: [LEGACY-05, LEGACY-06]
must_haves:
  truths:
    - "setup_wizard.py post-install instructions describe single `paperforge sync` workflow (no two-phase --selection/--index)"
    - "`grep -r 'library.record' command/` returns zero hits"
    - "`grep -r 'library.record' paperforge/command_files/` returns zero hits"
    - "All 5 command files in both locations describe formal-note-only workflow"
  artifacts:
    - path: paperforge/setup_wizard.py
      provides: post-install instructions free of two-phase library-records workflow
      min_lines: 2260
    - path: command/pf-sync.md
      provides: single-command sync workflow description
      min_lines: 155
    - path: command/pf-ocr.md
      provides: formal-note-based OCR workflow
      min_lines: 140
    - path: command/pf-status.md
      provides: no library-records path mentions
      min_lines: 90
    - path: command/pf-paper.md
      provides: formal note prerequisite, not library-record
      min_lines: 140
    - path: command/pf-deep.md
      provides: formal-note-based deep reading workflow
      min_lines: 130
  key_links:
    - from: setup_wizard.py:1304-1308
      to: single-command workflow
      via: remove two-phase --selection/--index block
      pattern: paperforge sync --selection
---
<objective>
Eliminate all library-records references from user-facing documentation and post-install instructions.

Purpose: LEGACY-05 updates setup_wizard.py post-install text to describe single `paperforge sync` workflow. LEGACY-06 purges all library-records references from 10 command file copies (command/*.md and paperforge/command_files/*.md). After this plan, no user-facing text describes the deprecated two-phase library-records workflow.

Note: The primary skill files at `paperforge/skills/literature-qa/scripts/pf-*.md` were already cleaned in Phase 44. Only the `command/` and `paperforge/command_files/` copies retain stale library-records references.
</objective>

<execution_context>
@C:/Users/Lin/.opencode/get-shit-done/workflows/execute-plan.md
@C:/Users/Lin/.opencode/get-shit-done/templates/summary.md
</execution_context>

<context>
@.planning/phases/47-library-records-deprecation-cleanup/47-CONTEXT.md

<interfaces>
The `command/` and `paperforge/command_files/` directories contain standalone Markdown copies of the 5 command skill files. These are copy-synced from `paperforge/skills/literature-qa/scripts/` but were not updated during Phase 44. All 3 locations share the same filename set:
- pf-sync.md, pf-ocr.md, pf-status.md, pf-paper.md, pf-deep.md

The setup_wizard.py post-install text block (lines ~1299-1308) currently shows:
```markdown
**3. 同步 Zotero 文献并生成正式笔记**
```bash
paperforge sync
```

如需分阶段执行：
```bash
paperforge sync --selection  # 仅同步 Zotero 到 library-records
paperforge sync --index      # 仅根据现有 library-records 生成正式笔记
```
```
</interfaces>
</context>

<tasks>

<task type="auto">
  <name>Task 1: Update setup_wizard.py post-install instructions to single-command workflow</name>
  <files>paperforge/setup_wizard.py</files>
  <action>
    Edit the post-install instructions at lines ~1299-1308 (LEGACY-05).

    Current text:
    ```
    **3. 同步 Zotero 文献并生成正式笔记**
    ```bash
    paperforge sync
    ```

    如需分阶段执行：
    ```bash
    paperforge sync --selection  # 仅同步 Zotero 到 library-records
    paperforge sync --index      # 仅根据现有 library-records 生成正式笔记
    ```
    ```

    Replace with:
    ```
    **3. 同步 Zotero 并生成正式笔记**
    ```bash
    paperforge sync
    ```

    `paperforge sync` 自动完成所有同步操作（检测新文献、解析 PDF、生成正式笔记）。

    `--selection` 和 `--index` 参数已废弃——无需分阶段执行。
    ```

    Changes:
    1. Remove "文献" from heading (simplify) — OR keep minimal change: just remove the two-phase block
    2. Remove the "如需分阶段执行" code block entirely
    3. Add a single line explaining sync is automatic
    4. Note that --selection and --index are deprecated

    Key point: Zero references to "library-records" in the new text.
  </action>
  <verify>
    <automated>python -c "
source = open('paperforge/setup_wizard.py', encoding='utf-8').read()
assert 'library-records' not in source, 'setup_wizard.py still contains library-records'
assert '--selection' not in source.split('3. ')[1].split('4.')[0] if '3. 同步' in source else True, 'Two-phase block still present in step 3'
print('setup_wizard.py: library-records removed from post-install text')
"</automated>
  </verify>
  <done>
    setup_wizard.py post-install step 3 describes single `paperforge sync` workflow.
    No --selection/--index code block in step 3 text.
    Zero mentions of "library-records" in the entire file.
  </done>
</task>

<task type="auto">
  <name>Task 2: Purge library-records from all 10 command file copies (command/ + paperforge/command_files/)</name>
  <files>
    command/pf-sync.md
    command/pf-ocr.md
    command/pf-status.md
    command/pf-paper.md
    command/pf-deep.md
    paperforge/command_files/pf-sync.md
    paperforge/command_files/pf-ocr.md
    paperforge/command_files/pf-status.md
    paperforge/command_files/pf-paper.md
    paperforge/command_files/pf-deep.md
  </files>
  <action>
    Update all 10 command file copies (5 in `command/` and 5 in `paperforge/command_files/`) to replace library-records references with formal-notes-only workflow descriptions. Use the primary skill files at `paperforge/skills/literature-qa/scripts/` as the reference for correct wording (they were already cleaned in Phase 44).

    For each file pair (command/ and paperforge/command_files/), apply the same changes:

    === pf-sync.md (LEGACY-06) ===
    - Line 5 (Purpose): Change `导出到 library-records，并生成/更新正式文献笔记。` to `并生成/更新正式文献笔记。`
    - Lines 7-10: Remove or rewrite the two-phase description. Change:
      ```
      `paperforge sync` 是 `selection-sync` 和 `index-refresh` 的统一入口：
      
      1. **selection-sync 阶段**：检测 Zotero JSON 中的新条目，创建 library-records
      2. **index-refresh 阶段**：基于 library-records 和 Zotero 元数据生成正式文献笔记
      ```
      To:
      ```
      `paperforge sync` 自动检测 Zotero JSON 中的新条目并直接生成正式文献笔记。
      ```
    - Remove `--selection` and `--index` from the Arguments table (lines 40-41) OR mark them as deprecated
    - Remove the "分阶段执行" section (lines 44-56) entirely
    - Under Example, remove or update lines 76-80 to not reference --selection/--index
    - Lines 92-112 (Output section): Replace `library-records` output references:
      - Remove "### selection-sync 阶段" subsection
      - Change `[INFO] Created library-records/骨科/XXXXXXX.md` to `[INFO] Found 5 new items`
      - Change `- <resources_dir>/<control_dir>/library-records/<domain>/<key>.md` to `- <resources_dir>/<literature_dir>/<domain>/<key> - <Title>.md`
      - Keep the `index-refresh` content as the primary (merge into single output section)

    === pf-ocr.md (LEGACY-06) ===
    - Line 5 (Purpose): Change `处理 library-records 中` to `处理正式笔记 frontmatter 中`
    - Line 23: Change `library-record 中` to `formal note frontmatter 中`
    - Line 125: Change `library-record 的` to `正式笔记的`
    - Line 139 (See Also): Change `生成 library-records` to `生成正式笔记`

    === pf-status.md (LEGACY-06) ===
    - Line 11: Change `library-records、literature` to `literature` (remove library-records from the list)
    - Line 69: Change `✓ library-records: <resources_dir>/<control_dir>/library-records/` to `✓ literature: <resources_dir>/<literature_dir>/`
    - Line 75: Change `✓ library-records: 150 条记录` to `✓ 正式笔记: 150 篇`

    === pf-paper.md (LEGACY-06) ===
    - Line 19: Change `生成正式笔记和 library-records` to `生成正式笔记`
    - Line 27: Change `library-record 存在（用于定位论文）` to `正式笔记已生成（用于定位论文）`

    === pf-deep.md (LEGACY-06) ===
    - Line 21: Change `生成 library-records 和正式笔记` to `生成正式笔记`
    - Line 30: Change `library-record 已创建` to `正式笔记已生成`
    - Line 31: Change `在 library-record frontmatter 中` to `在正式笔记 frontmatter 中`
    - Line 78: Change `只扫描 \`library-records\`（Base 控制记录）` to `只扫描正式笔记 frontmatter`
    - Lines 123-124: In the template variables table, change `从 library-record` to `从`

    After editing each file, run syntax validation (basic check that file is valid UTF-8 markdown).
  </action>
  <verify>
    <automated>python -c "
import os, sys
errors = []
locations = ['command', 'paperforge/command_files']
files = ['pf-sync.md', 'pf-ocr.md', 'pf-status.md', 'pf-paper.md', 'pf-deep.md']
for loc in locations:
    for fname in files:
        fpath = os.path.join(loc, fname)
        if not os.path.exists(fpath):
            errors.append(f'MISSING: {fpath}')
            continue
        content = open(fpath, encoding='utf-8').read()
        # Check for library-record references (case-insensitive)
        import re
        matches = list(re.finditer(r'library.record', content, re.IGNORECASE))
        if matches:
            lines = [(m.group(), content[:m.start()].count(chr(10)) + 1) for m in matches]
            errors.append(f'{fpath}: {len(matches)} library-record reference(s) at lines {[l[1] for l in lines]}')
if errors:
    for e in errors:
        print(f'FAIL: {e}')
    sys.exit(1)
else:
    print(f'ALL 10 files clean: zero library-record references across {locations}')
    for loc in locations:
        for fname in files:
            fpath = os.path.join(loc, fname)
            size = os.path.getsize(fpath)
            print(f'  {fpath} ({size} bytes)')
"
</automated>
  </verify>
  <done>
    All 10 command file copies (command/*.md + paperforge/command_files/*.md) contain zero library-records references.
    Each file describes formal-note-only workflow.
    grep -- "library.record" returns zero hits across both directories.
  </done>
</task>

</tasks>

<verification>
1. `grep -rn "library.record" command/ paperforge/command_files/` returns zero hits
2. `grep -rn "library.record" paperforge/setup_wizard.py` returns zero hits
3. All 10 modified files are valid UTF-8 Markdown
4. Each file describes the sync/ocr/status workflow without mentioning library-records
</verification>

<success_criteria>
1. setup_wizard.py step 3 text shows single `paperforge sync` command
2. No --selection/--index code block in post-install text
3. Zero `grep "library.record"` hits in command/ or paperforge/command_files/
4. All 5 command files in both locations describe formal-note-only workflow
5. All files valid UTF-8
</success_criteria>

<output>
After completion, create `.planning/phases/47-library-records-deprecation-cleanup/47-002-SUMMARY.md`
</output>