@cloud411716/fancy-webnovel 4.12.0 → 4.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -144,6 +144,8 @@ FANCY_DOUYIN_SUBAGENTS=0 # 关闭子 Agent,回退单 Agent 串行
144
144
 
145
145
  子 Agent 不操作 Chrome,不修改 `crawled.json`,不运行 `import.js`,也不直接写素材数据库;数据库导入和采集状态只由父进程串行处理,避免并发覆盖。
146
146
 
147
+ 采集和分析重叠时,任务列表会同时把“采集作品”和“分析素材”标为进行中:采集行显示已扫描账号数和已入队作品数,分析行显示已分析/已入队和当前并发数。所有账号采集完成后,“采集作品”才标记完成,“分析素材”继续转圈直到子 Agent 队列清空。
148
+
147
149
  子 Agent 是独立的新会话,不继承父 Agent 当前对话。因此 `.tmp` 临时文件规则、完整分析提示词和“不要删除测试文件/不要执行 rm”的约束都会直接写进子 Agent 任务提示,而不是依赖父对话。
148
150
 
149
151
  有子 Agent 服务时,视觉能力自检和视频前 5 秒相关性判断也会交给子 Agent:
package/lib/task-list.js CHANGED
@@ -130,11 +130,35 @@ class TaskListController {
130
130
  * 只改文案,不改状态;用于长循环里让用户看到进度。
131
131
  */
132
132
  progress(text) {
133
+ return this.progressAt(this.index, text);
134
+ }
135
+
136
+ /**
137
+ * 修改指定步骤的文案,不改状态。
138
+ * 用于多个步骤同时进行时,各自刷新自己的进度。
139
+ */
140
+ progressAt(index, text) {
141
+ const target = Number(index);
142
+ if (!Number.isInteger(target) || target < 0 || target >= this.items.length) return this;
133
143
  const content = String(text == null ? '' : text).trim();
134
- if (!content || !this.items[this.index]) return this;
144
+ if (!content) return this;
135
145
  // content 不能和已有项重复(DSH 会拒绝整表)
136
- if (this.items.some((item, i) => i !== this.index && item.content === content)) return this;
137
- this.items[this.index].content = content;
146
+ if (this.items.some((item, i) => i !== target && item.content === content)) return this;
147
+ if (this.items[target].content === content) return this;
148
+ this.items[target].content = content;
149
+ this._write();
150
+ return this;
151
+ }
152
+
153
+ /**
154
+ * 把一个 pending 步骤也标记为 in_progress,不影响当前步骤。
155
+ * DSH 允许并行任务同时进行;用于“采集作品”和“分析素材”重叠的阶段。
156
+ */
157
+ activate(index) {
158
+ const target = Number(index);
159
+ if (!Number.isInteger(target) || target < 0 || target >= this.items.length) return this;
160
+ if (this.items[target].status !== 'pending') return this;
161
+ this.items[target].status = 'in_progress';
138
162
  this._write();
139
163
  return this;
140
164
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud411716/fancy-webnovel",
3
- "version": "4.12.0",
3
+ "version": "4.12.1",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -1053,14 +1053,13 @@ async function runCrawl(ctx, invocation, session, taskList) {
1053
1053
  let skippedMaterials = 0;
1054
1054
  let aborted = false;
1055
1055
 
1056
- const progressText = () => {
1057
- if (taskList.index <= 3) {
1058
- return `采集作品(已入队 ${queueStats.queued},已分析 ${queueStats.finished})`;
1059
- }
1060
- if (queue) {
1061
- return `分析素材(子 Agent 并行:${queueStats.finished}/${queueStats.queued},并发 ${subagentWorkers})`;
1062
- }
1063
- return `分析素材(${queueStats.finished}/${jobs.length})`;
1056
+ const collectText = () => `采集作品(已扫描 ${scannedAccounts}/${accounts.length},已入队 ${queueStats.queued})`;
1057
+ const analysisText = () => queue
1058
+ ? `分析素材(已分析 ${queueStats.finished}/${queueStats.queued},并发 ${subagentWorkers})`
1059
+ : `分析素材(${queueStats.finished}/${jobs.length})`;
1060
+ const refreshProgress = () => {
1061
+ if (taskList.index <= 3) taskList.progressAt(3, collectText());
1062
+ if (queue || taskList.index >= 4) taskList.progressAt(4, analysisText());
1064
1063
  };
1065
1064
 
1066
1065
  const jobRecord = (job, extra = {}) => ({
@@ -1101,7 +1100,7 @@ async function runCrawl(ctx, invocation, session, taskList) {
1101
1100
  failures.push({ id: job.id, url: job.url, reason });
1102
1101
  await markJobFailedLocked(job, reason);
1103
1102
  queueStats.finished += 1;
1104
- taskList.progress(progressText());
1103
+ refreshProgress();
1105
1104
  return;
1106
1105
  }
1107
1106
  if (analyzed.skipped) {
@@ -1142,7 +1141,7 @@ async function runCrawl(ctx, invocation, session, taskList) {
1142
1141
  }
1143
1142
  crawled[job.id] = true;
1144
1143
  queueStats.finished += 1;
1145
- taskList.progress(progressText());
1144
+ refreshProgress();
1146
1145
  });
1147
1146
  };
1148
1147
 
@@ -1160,11 +1159,13 @@ async function runCrawl(ctx, invocation, session, taskList) {
1160
1159
  }
1161
1160
  queueStats.queued += 1;
1162
1161
  if (queue) {
1162
+ // 子 Agent 已开始处理第一个作品:采集尚未结束,但分析也进入进行中。
1163
+ taskList.activate(4);
1163
1164
  queue.push(job);
1164
1165
  } else {
1165
1166
  jobs.push(job);
1166
1167
  }
1167
- taskList.progress(progressText());
1168
+ refreshProgress();
1168
1169
  };
1169
1170
 
1170
1171
  const runWorker = async () => {
@@ -1702,13 +1703,13 @@ async function runCrawl(ctx, invocation, session, taskList) {
1702
1703
  if (queue) {
1703
1704
  if (taskList.index < 4) {
1704
1705
  taskList.advance(4);
1705
- taskList.progress(progressText());
1706
+ refreshProgress();
1706
1707
  }
1707
1708
  queue.close();
1708
1709
  await Promise.all(workerPromises);
1709
1710
  } else if (jobs.length) {
1710
1711
  taskList.advance(4);
1711
- taskList.progress(progressText());
1712
+ refreshProgress();
1712
1713
  for (const job of jobs) {
1713
1714
  if (abortRequested(invocation)) { aborted = true; break; }
1714
1715
  const analyzed = await runLocalAnalysisJob(ctx, invocation, session, job, {