增加新命令及部分功能优化 - #88
Conversation
… CLI and docs ### Motivation - Provide a batch automation entrypoint to run write/heal/nightly pipelines across chapter ranges to reduce manual orchestration. - Provide a tool to detect and optionally mark ASCII snake_case (pinyin/English) dirty entities for downstream cleanup. - Expose these features through the unified CLI and document common plugin/CLI workflows for everyday and ops use. ### Description - Extended the CLI in `webnovel-writer/scripts/data_modules/webnovel.py` to add `orchestrate` and `entity-clean` subcommands and forward them to new scripts. - Added `webnovel-writer/scripts/orchestrate.py` which implements range parsing, runs `preflight`, optional `review-pipeline`, `chapter-commit`, and optional vector indexing repair, and emits a JSON report. - Added `webnovel-writer/scripts/entity_cleanup.py` which scans the `entities` table for ASCII snake_case IDs/names and optionally writes rows into an `invalid_facts` table for later handling. - Updated `README.md` and `docs/guides/commands.md` to include an overview of the new plugin commands, unified CLI examples, `orchestrate` usage, and a recommended repair workflow for large projects. ### Testing - Ran basic CLI smoke checks by invoking `python -X utf8 "<CLAUDE_PLUGIN_ROOT>/scripts/webnovel.py" orchestrate --help` and `python -X utf8 "<CLAUDE_PLUGIN_ROOT>/scripts/webnovel.py" entity-clean --help`, which returned help text successfully. - Executed `orchestrate` locally against a sample project with `--chapters 1-3` and `--json-report-out` to verify report generation and the script exit behavior, and the run completed and produced a JSON report. - Ran `entity_cleanup.py` against a test SQLite `index.db` and validated that it listed dirty entities and inserted `invalid_facts` rows when `--mark-invalid` was passed.
feat:新增一键 autofix 修复链与实体脏数据治理
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d3f3c07a6a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if isinstance(data.get("blocking_count"), int): | ||
| return data.get("blocking_count", 0) > 0 | ||
| issues = data.get("issues") or [] | ||
| return any(bool(item.get("blocking")) for item in issues if isinstance(item, dict)) |
There was a problem hiding this comment.
Treat critical review issues as blocking
When a reviewer emits a critical issue without an explicit blocking field, review_pipeline parses it as blocking via ReviewIssue.__post_init__, but this check rereads the raw JSON and only tests item.get("blocking"). In that valid review-result shape, orchestrate write/nightly continues to chapter-commit even though the parsed review has blocking_count > 0, so chapters with critical blockers can be accepted and projected.
Useful? React with 👍 / 👎.
| ) | ||
| for item in rows: | ||
| cur.execute( | ||
| "INSERT INTO invalid_facts (source_type, source_id, reason, marked_by, chapter, status) VALUES (?, ?, ?, ?, ?, 'pending')", |
There was a problem hiding this comment.
Insert invalid facts using the project schema
On initialized projects, invalid_facts is already created by index_manager with chapter_discovered and confirmed_at, not chapter/resolved_at; because CREATE TABLE IF NOT EXISTS leaves that table unchanged, entity-clean --mark-invalid fails with no column named chapter as soon as it finds a dirty entity. The insert should use the existing schema (or the shared mark_invalid_fact helper) so the advertised cleanup command works on real project databases.
Useful? React with 👍 / 👎.
feat: 增强章节管理与仪表盘文档
/webnovel-delete和/webnovel-rewrite,支持按范围删除/重写章节并自动清理派生数据