@oxmumu3/dsh-plugin-finder 0.12.0-preview.1 → 0.12.0-preview.2

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ # 0.12.0-preview.2(2026-11-04)
2
+
3
+ 以下记录本版实现范围;实际公开发布、市场索引与可安装状态以精确发行回执为准。
4
+
5
+ - 搜索进行中新增真实进度事件:逐条显示每个来源读取到的条数,并显示当前阶段与已用时;超过 30 秒提示可能较慢,同时保留停止。
6
+ - 进度改为按请求代数隔离:旧请求的迟到事件、取消或失败后的收尾都不会写进新一代。
7
+ - 终态按真实结果记录:完成为「已完成」、取消为「已停止」、失败为「这一步失败了」;取消后不再被改写成「已完成」。
8
+ - 取消搜索或开始新搜索时清空进度状态,避免上一轮事件残留到界面。
9
+
1
10
  # 0.12.0-preview.1(2026-11-03)
2
11
 
3
12
  以下记录本版实现范围;实际公开发布、市场索引与可安装状态以精确发行回执为准。
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  Finder 把需求理解、现成能力选择、插件组合和缺口创造接在同一个工作区。能用现有能力完成,就直接用;现成插件只覆盖一部分,就保留这些能力,只为缺失部分创建插件。首页、精选和插件商店都是这位插件专家的入口。
6
6
 
7
- **版本:`@oxmumu3/dsh-plugin-finder@0.12.0-preview.1`。** 准确目标仅为官方 Harness `0.2.1-rc.5`,Node `^22.19.0 || >=24.0.0`。正式安装状态以 [Release 列表](https://github.com/oxmumu3/dsh-plugin-finder/releases)、npm 精确版本和最终验收记录为准。
7
+ **版本:`@oxmumu3/dsh-plugin-finder@0.12.0-preview.2`。** 准确目标仅为官方 Harness `0.2.1-rc.5`,Node `^22.19.0 || >=24.0.0`。正式安装状态以 [Release 列表](https://github.com/oxmumu3/dsh-plugin-finder/releases)、npm 精确版本和最终验收记录为准。
8
8
 
9
9
  [安装说明](docs/install.md) · [当前工作区流程](docs/workspace-flow-preview.md) · [主 Agent 调用](docs/agent-entry.md) · [数据与回传](docs/data-sharing.md) · [反馈](https://github.com/oxmumu3/dsh-plugin-finder/issues)
10
10
 
@@ -46,7 +46,7 @@ Finder 把需求理解、现成能力选择、插件组合和缺口创造接在
46
46
 
47
47
  ## 安装与兼容
48
48
 
49
- 通过当前官方 Harness 原生「插件 → 添加插件」安装精确 npm 来源 `@oxmumu3/dsh-plugin-finder@0.12.0-preview.1`。发布状态以 npm 精确版本与 Release 回读为准;尚未同步时保留当前安装。已有预览包不得仅因版本号较大就覆盖另一条有效修复线。
49
+ 通过当前官方 Harness 原生「插件 → 添加插件」安装精确 npm 来源 `@oxmumu3/dsh-plugin-finder@0.12.0-preview.2`。发布状态以 npm 精确版本与 Release 回读为准;尚未同步时保留当前安装。已有预览包不得仅因版本号较大就覆盖另一条有效修复线。
50
50
 
51
51
  本版目标为官方 `0.2.1-rc.5`;四个官方 SDK peer 均固定同一版本:`@deepseek-ai/dsh-app-boot`、`@deepseek-ai/dsh-storage-domain`、`@deepseek-ai/dsh-tools`、`@deepseek-ai/dsh-sandbox`。Node 要求为 `^22.19.0 || >=24.0.0`。其他 RC、next 或实验 alpha 不据此推断兼容;安装、启用、卸载/重启与最终包的真实验证范围,以对应发行版的验收记录为准。
52
52
 
package/dist/client.js CHANGED
@@ -2477,6 +2477,9 @@ function createExperienceView(React2) {
2477
2477
  "creation-refine": "\u6B63\u5728\u6839\u636E\u4F60\u7684\u8865\u5145\u4FEE\u6539\u65B9\u6848",
2478
2478
  reset: "\u6B63\u5728\u4FDD\u7559\u539F\u4EFB\u52A1\u5E76\u5F00\u59CB\u65B0\u9700\u6C42"
2479
2479
  }[state.busy] || (state.searching ? "\u6B63\u5728\u67E5\u627E\u53EF\u884C\u8DEF\u5F84" : state.followupPending ? "\u6B63\u5728\u66F4\u65B0\u8FD9\u4EFD\u65B9\u6848" : "\u6B63\u5728\u5904\u7406");
2480
+ const waited = state.searchingSince && state.clock ? Math.max(0, Math.round((state.clock - state.searchingSince) / 1e3)) : 0;
2481
+ const liveEvents = busy && Array.isArray(state.searchProgress?.events) ? state.searchProgress.events.filter((item) => item && typeof item.text === "string" && item.text).slice(-4) : [];
2482
+ const clockSuffix = waited >= 30 ? ` \u5DF2\u7B49\u5F85 ${waited} \u79D2\uFF0C\u6BD4\u5E73\u65F6\u4E45\uFF1B\u53EF\u4EE5\u7EE7\u7EED\u7B49\uFF0C\u6216\u70B9\u4E0A\u9762\u7684\u300C\u505C\u6B62\u300D\u3002` : waited >= 3 ? ` \u5DF2\u7528\u65F6 ${waited} \u79D2\u3002` : "";
2480
2483
  const submitFollowup = (event) => {
2481
2484
  event.preventDefault();
2482
2485
  if (!followupBusy && modelReady && text6(state.followupText).trim()) void controller.submitFollowup();
@@ -2681,7 +2684,8 @@ function createExperienceView(React2) {
2681
2684
  "div",
2682
2685
  { className: "pfv_outcome_empty" },
2683
2686
  h("h2", null, busy ? "\u65B9\u6848\u6B63\u5728\u5F62\u6210" : "\u7EE7\u7EED\u67E5\u627E\u65B9\u6848"),
2684
- h("p", { className: "pfv_hint" }, busy ? "\u9700\u6C42\u5DF2\u4FDD\u7559\uFF0C\u627E\u5230\u7684\u65B9\u6848\u4F1A\u663E\u793A\u5728\u8FD9\u91CC\u3002" : "\u4E0A\u6B21\u67E5\u627E\u5C1A\u672A\u5B8C\u6210\uFF0C\u4F60\u53EF\u4EE5\u4ECE\u8FD9\u91CC\u7EE7\u7EED\u3002"),
2687
+ h("p", { className: "pfv_hint" }, busy ? `\u9700\u6C42\u5DF2\u4FDD\u7559\uFF0C\u627E\u5230\u7684\u65B9\u6848\u4F1A\u663E\u793A\u5728\u8FD9\u91CC\u3002${clockSuffix}` : "\u4E0A\u6B21\u67E5\u627E\u5C1A\u672A\u5B8C\u6210\uFF0C\u4F60\u53EF\u4EE5\u4ECE\u8FD9\u91CC\u7EE7\u7EED\u3002"),
2688
+ liveEvents.length ? h("ul", { className: "pfv_hint", "aria-live": "polite" }, liveEvents.map((item, index) => h("li", { key: `${item.seq || index}` }, item.text))) : null,
2685
2689
  !busy && state.intent ? primary("\u91CD\u8BD5\u67E5\u627E", () => controller.recommend(), { disabled: !modelReady }) : null,
2686
2690
  !busy && !state.intent && request ? primary("\u91CD\u8BD5\u67E5\u627E", () => {
2687
2691
  controller.setHomeRequest(request);
@@ -2815,11 +2819,22 @@ var experienceCss = `
2815
2819
  .pf_root.pf_v2:has(.pfv_home) { background: var(--pfv_canvas); }
2816
2820
  .pf_v2:has(.pfv_home) .pf_header { margin-bottom: 20px; border-bottom: 0; padding-bottom: 0; }
2817
2821
  .pfv_home { max-width: 1120px; margin: 0 auto; }
2818
- .pfv_home_start { display: grid; grid-template-columns: minmax(0, 2fr) minmax(250px, .85fr); gap: 0 28px; align-items: stretch; padding: 22px 0 34px; }
2822
+ .pfv_home_start { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px 0; align-items: stretch; padding: 22px 0 34px; }
2819
2823
  .pfv_home_intro, .pfv_home_scenario { display: grid; grid-template-rows: subgrid; grid-row: 1 / 4; min-width: 0; padding: 0; margin: 0; }
2820
2824
  .pfv_home_intro { grid-column: 1; }
2821
2825
  .pfv_home_scenario { grid-column: 2; }
2822
- .pfv_home_extras { grid-area: 4 / 1; min-width: 0; padding-bottom: 4px; }
2826
+ .pfv_home_extras { grid-area: auto; min-width: 0; padding-bottom: 4px; }
2827
+ .pfv_opportunity_column { grid-column: 1; grid-row: auto; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
2828
+ .pfv_opportunity .pfv_home_lead, .pfv_opportunity .pfv_scenario_reason { display: none; }
2829
+ .pfv_opportunity .pfv_home_heading { font-size: 12px; font-weight: 500; color: var(--pfv_muted); margin: 0; }
2830
+ .pfv_opportunity .pfv_scenario_card { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border-radius: 10px; }
2831
+ .pfv_opportunity .pfv_scenario_card h3 { margin: 0; font-size: 13px; }
2832
+ .pfv_opportunity .pfv_scenario_card > p { margin: 0; font-size: 12.5px; color: var(--pfv_muted); flex: 1 1 240px; }
2833
+ .pfv_opportunity .pfv_scenario_card .pfv_composer_bottom { margin: 0 0 0 auto; }
2834
+ .pf_v2 .pfv_opportunity .pfv_home_card { min-height: 0; padding: 10px 14px; border-radius: 10px; flex-direction: row; align-items: center; gap: 14px; }
2835
+ .pf_v2 .pfv_opportunity .pfv_scenario_card h3 { font-size: 13px; }
2836
+ .pf_v2 .pfv_opportunity .pfv_scenario_card .pfv_prose { font-size: 12.5px; line-height: 1.6; margin: 0; }
2837
+ .pf_v2 .pfv_opportunity .pfv_home_card .pfv_composer_bottom { padding-top: 0; }
2823
2838
  .pf_v2 .pfv_home_heading { margin: 0; font-size: 32px; line-height: 1.35; letter-spacing: -.8px; font-weight: 650; }
2824
2839
  .pf_v2 .pfv_home_lead { font-size: 14px; color: var(--pfv_muted); margin: 8px 0 22px; line-height: 1.75; }
2825
2840
  .pf_v2 .pfv_scenario_card h3 { margin: 0; font-size: 20px; line-height: 1.55; letter-spacing: -.3px; font-weight: 600; text-wrap: balance; }
@@ -3046,6 +3061,7 @@ var experienceCss = `
3046
3061
  .pfv_home_intro, .pfv_home_scenario { display: block; grid-area: auto; }
3047
3062
  .pfv_home_extras { grid-area: auto; }
3048
3063
  .pfv_home_scenario { margin-top: 28px; }
3064
+ .pfv_opportunity_column { grid-area: auto; }
3049
3065
  .pf_v2 .pfv_home_heading { font-size: 28px; letter-spacing: -.6px; }
3050
3066
  .pf_v2 .pfv_home_lead { margin: 8px 0 16px; }
3051
3067
  .pfv_home_card { padding: 20px; }
@@ -3572,7 +3588,7 @@ function createFinderController(ctx, options = {}) {
3572
3588
  opportunityEditing: false,
3573
3589
  opportunityFiles: [],
3574
3590
  opportunityDraft: null,
3575
- productIntroVisible: true,
3591
+ productIntroVisible: false,
3576
3592
  execution: null,
3577
3593
  executionReference: null,
3578
3594
  executions: [],
@@ -3771,7 +3787,7 @@ function createFinderController(ctx, options = {}) {
3771
3787
  const draftStorage = options.draftStorage ?? globalThis.localStorage;
3772
3788
  const introKey = "dsh.plugin-finder.product-intro.v1";
3773
3789
  try {
3774
- publish({ productIntroVisible: draftStorage?.getItem(introKey) !== "hidden" });
3790
+ publish({ productIntroVisible: draftStorage?.getItem(introKey) === "visible" });
3775
3791
  } catch {
3776
3792
  }
3777
3793
  const followupCache = /* @__PURE__ */ new Map();
@@ -4367,7 +4383,7 @@ function createFinderController(ctx, options = {}) {
4367
4383
  draftStorage?.setItem(introKey, "visible");
4368
4384
  } catch {
4369
4385
  }
4370
- publish({ view: "home", productIntroVisible: true });
4386
+ publish({ view: "home", productIntroVisible: false });
4371
4387
  },
4372
4388
  hideProductIntro() {
4373
4389
  try {
@@ -4393,7 +4409,22 @@ function createFinderController(ctx, options = {}) {
4393
4409
  if (!savedWithoutEdits && !parkFeaturedDraft()) return false;
4394
4410
  const generation = ++searchGeneration;
4395
4411
  const current = () => !closed && generation === searchGeneration;
4396
- publish({ searching: true, error: "", notice: "" });
4412
+ publish({ searching: true, error: "", notice: "", searchingSince: Date.now(), clock: Date.now(), searchProgress: null });
4413
+ const pollProgress = async () => {
4414
+ try {
4415
+ const response = await fetch(endpoint2 + "search-progress", { headers: { accept: "application/json" } });
4416
+ if (!response.ok || !current()) return;
4417
+ const data = await response.json();
4418
+ if (data && current()) publish({ searchProgress: data });
4419
+ } catch {
4420
+ }
4421
+ };
4422
+ const scheduleClock = typeof globalThis.setInterval === "function" ? globalThis.setInterval : null;
4423
+ const clockTimer = scheduleClock ? scheduleClock(() => {
4424
+ if (!current()) return;
4425
+ publish({ clock: Date.now() });
4426
+ void pollProgress();
4427
+ }, 1e3) : 0;
4397
4428
  try {
4398
4429
  if (!current() || !await this.newRequest() || !current()) return false;
4399
4430
  if (!await this.analyze(request, { communityEntryId }) || !current()) return false;
@@ -4401,7 +4432,8 @@ function createFinderController(ctx, options = {}) {
4401
4432
  saveHomeInput("");
4402
4433
  return true;
4403
4434
  } finally {
4404
- if (current()) publish({ searching: false });
4435
+ if (clockTimer && typeof globalThis.clearInterval === "function") globalThis.clearInterval(clockTimer);
4436
+ if (current()) publish({ searching: false, searchingSince: 0, searchProgress: null });
4405
4437
  }
4406
4438
  },
4407
4439
  async analyze(request = state.request, selection = {}) {
@@ -5053,7 +5085,7 @@ function createFinderController(ctx, options = {}) {
5053
5085
  searchGeneration += 1;
5054
5086
  if (operation) operation.controller.abort("cancelled");
5055
5087
  operation = null;
5056
- publish({ busy: null, searching: false, followupPending: false, notice: cancelledKind === "reset" ? "\u5F00\u59CB\u65B0\u9700\u6C42\u5C1A\u672A\u786E\u8BA4\uFF0C\u539F\u5185\u5BB9\u4ECD\u4FDD\u7559\uFF0C\u53EF\u91CD\u8BD5\u3002" : "\u5DF2\u53D6\u6D88\u8FD9\u4E00\u6B65\u3002\u5DF2\u586B\u5199\u7684\u5185\u5BB9\u4ECD\u4FDD\u7559\u3002", error: "" });
5088
+ publish({ busy: null, searching: false, searchingSince: 0, searchProgress: null, followupPending: false, notice: cancelledKind === "reset" ? "\u5F00\u59CB\u65B0\u9700\u6C42\u5C1A\u672A\u786E\u8BA4\uFF0C\u539F\u5185\u5BB9\u4ECD\u4FDD\u7559\uFF0C\u53EF\u91CD\u8BD5\u3002" : "\u5DF2\u53D6\u6D88\u8FD9\u4E00\u6B65\u3002\u5DF2\u586B\u5199\u7684\u5185\u5BB9\u4ECD\u4FDD\u7559\u3002", error: "" });
5057
5089
  },
5058
5090
  notify(message) {
5059
5091
  publish({ notice: text7(message), error: "" });
package/docs/install.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # 安装、首次使用与卸载
2
2
 
3
- 本说明对应 `@oxmumu3/dsh-plugin-finder@0.12.0-preview.1`。精确发布状态以 npm 与 GitHub Release 为准;尚未同步时保留当前安装,不用其他版本或本地路径冒充公开包。
3
+ 本说明对应 `@oxmumu3/dsh-plugin-finder@0.12.0-preview.2`。精确发布状态以 npm 与 GitHub Release 为准;尚未同步时保留当前安装,不用其他版本或本地路径冒充公开包。
4
4
 
5
5
  正式发行记录见 [GitHub Releases](https://github.com/oxmumu3/dsh-plugin-finder/releases)。新版本附件及哈希确认存在前,不提供推测的下载地址。
6
6
 
@@ -22,7 +22,7 @@
22
22
  公开发布并回读精确 npm 版本后,在正在使用的官方 Harness 原生「插件 → 添加插件」中填入:
23
23
 
24
24
  ```text
25
- @oxmumu3/dsh-plugin-finder@0.12.0-preview.1
25
+ @oxmumu3/dsh-plugin-finder@0.12.0-preview.2
26
26
  ```
27
27
 
28
28
  这是本版的精确 npm 安装身份。若注册表尚未返回该版本,请查看正式 Release 并保留当前安装。通过本地 TGZ 安装时,应核对发行哈希;绝对路径必须位于目标宿主机器,不能使用另一台机器的路径。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxmumu3/dsh-plugin-finder",
3
- "version": "0.12.0-preview.1",
3
+ "version": "0.12.0-preview.2",
4
4
  "description": "Describe a need, find a usable plan, and run or create in the same DeepSeek Harness workspace",
5
5
  "author": "牛村木木山",
6
6
  "license": "MIT",
@@ -81,6 +81,7 @@
81
81
  "src/opportunity-view.js",
82
82
  "src/plugin-detail-view.js",
83
83
  "src/plugin-installation.js",
84
+ "src/progress.js",
84
85
  "src/provenance.js",
85
86
  "src/routes.js",
86
87
  "src/runtime-context.js",
package/src/client.js CHANGED
@@ -153,7 +153,7 @@ export function createFinderController(ctx, options = {}) {
153
153
  const catalogInstalls = new Map();
154
154
  let state = Object.freeze({
155
155
  catalogOpen: false, catalogSelection: null, catalogDetail: null, catalogBusy: '', catalogError: '',
156
- opportunity: null, opportunityBusy: '', opportunityError: '', opportunityEditing: false, opportunityFiles: [], opportunityDraft: null, productIntroVisible: true,
156
+ opportunity: null, opportunityBusy: '', opportunityError: '', opportunityEditing: false, opportunityFiles: [], opportunityDraft: null, productIntroVisible: false,
157
157
  execution: null, executionReference: null, executions: [], executionWorkspaceLabel: '',
158
158
  creation: null, creationForm: null, creationDirty: false, localOnly: false, creatorAttempts: [], creatorHandoff: null, pendingCreatorRecord: null,
159
159
  conversation: [], followupText: '', followupWarning: '', followupPending: false, followupRetry: null, pendingOutcome: null,
@@ -281,7 +281,7 @@ export function createFinderController(ctx, options = {}) {
281
281
  const editorCache = new Map();
282
282
  const draftStorage = options.draftStorage ?? globalThis.localStorage;
283
283
  const introKey = 'dsh.plugin-finder.product-intro.v1';
284
- try { publish({ productIntroVisible: draftStorage?.getItem(introKey) !== 'hidden' }); } catch {}
284
+ try { publish({ productIntroVisible: draftStorage?.getItem(introKey) === 'visible' }); } catch {}
285
285
  const followupCache = new Map();
286
286
  const followupRecovery = new Map();
287
287
  const followupKey = (taskId, revisionId) => taskId && revisionId ? `dsh.plugin-finder.followup.${taskId}.${revisionId}` : null;
@@ -697,7 +697,7 @@ export function createFinderController(ctx, options = {}) {
697
697
  publish({ view: 'home', featuredId: null, notice: '' });
698
698
  return opportunityClient.methods.refreshOpportunityStatus();
699
699
  },
700
- showProductIntro() { if (closed || operation || state.searching) return; try { draftStorage?.setItem(introKey, 'visible'); } catch {} publish({ view: 'home', productIntroVisible: true }); },
700
+ showProductIntro() { if (closed || operation || state.searching) return; try { draftStorage?.setItem(introKey, 'visible'); } catch {} publish({ view: 'home', productIntroVisible: false }); },
701
701
  hideProductIntro() { try { draftStorage?.setItem(introKey, 'hidden'); } catch {} publish({ productIntroVisible: false }); },
702
702
  async searchHome() {
703
703
  if (closed || operation || state.searching) return false;
@@ -710,13 +710,16 @@ export function createFinderController(ctx, options = {}) {
710
710
  if (!savedWithoutEdits && !parkFeaturedDraft()) return false;
711
711
  const generation = ++searchGeneration;
712
712
  const current = () => !closed && generation === searchGeneration;
713
- publish({ searching: true, error: '', notice: '' });
713
+ publish({ searching: true, error: '', notice: '', searchingSince: Date.now(), clock: Date.now(), searchProgress: null });
714
+ const pollProgress = async () => { try { const response = await fetch(endpoint + 'search-progress', { headers: { accept: 'application/json' } }); if (!response.ok || !current()) return; const data = await response.json(); if (data && current()) publish({ searchProgress: data }); } catch {} };
715
+ const scheduleClock = typeof globalThis.setInterval === 'function' ? globalThis.setInterval : null;
716
+ const clockTimer = scheduleClock ? scheduleClock(() => { if (!current()) return; publish({ clock: Date.now() }); void pollProgress(); }, 1000) : 0;
714
717
  try {
715
718
  if (!current() || !await this.newRequest() || !current()) return false;
716
719
  if (!await this.analyze(request, { communityEntryId }) || !current()) return false;
717
720
  if (!await this.recommend() || !current()) return false;
718
721
  saveHomeInput(''); return true;
719
- } finally { if (current()) publish({ searching: false }); }
722
+ } finally { if (clockTimer && typeof globalThis.clearInterval === 'function') globalThis.clearInterval(clockTimer); if (current()) publish({ searching: false, searchingSince: 0, searchProgress: null }); }
720
723
  },
721
724
  async analyze(request = state.request, selection = {}) {
722
725
  if (closed || operation) return false;
@@ -1188,7 +1191,7 @@ export function createFinderController(ctx, options = {}) {
1188
1191
  sequence += 1; searchGeneration += 1;
1189
1192
  if (operation) operation.controller.abort('cancelled');
1190
1193
  operation = null;
1191
- publish({ busy: null, searching: false, followupPending: false, notice: cancelledKind === 'reset' ? '开始新需求尚未确认,原内容仍保留,可重试。' : '已取消这一步。已填写的内容仍保留。', error: '' });
1194
+ publish({ busy: null, searching: false, searchingSince: 0, searchProgress: null, followupPending: false, notice: cancelledKind === 'reset' ? '开始新需求尚未确认,原内容仍保留,可重试。' : '已取消这一步。已填写的内容仍保留。', error: '' });
1192
1195
  },
1193
1196
  notify(message) { publish({ notice: text(message), error: '' }); },
1194
1197
  reportError(message) { publish({ error: text(message).slice(0, 600), notice: '' }); },
package/src/discovery.js CHANGED
@@ -2,6 +2,7 @@ import { createHash } from 'node:crypto';
2
2
  import { assessCompatibility, inferCapabilities } from '../catalog/index.mjs';
3
3
  import {fullCatalog,repositoryOf,safeRepositoryPath as safePath} from './supply.js';
4
4
  import {getCommunityEntry} from './community-catalog.js';
5
+ import {recordProgress, currentProgressId} from './progress.js';
5
6
 
6
7
  const INDEX_URL = 'https://awesome-dsh-plugin.com/index.json';
7
8
  const FULL_URL = 'https://awesome-dsh-plugin.com/plugins.json';
@@ -300,6 +301,9 @@ export function createDiscovery({ market, fetchImpl = fetch, now = () => new Dat
300
301
  const queryGroups=unique((intent?.queries??[]).map(value=>termsFor({queries:[value]}).sort().join('\n'))).slice(0,8).map(value=>value.split('\n'));
301
302
  const primaryTerms=termsFor({queries:intent?.queries??[]});const secondaryTerms=termsFor({capabilities:intent?.capabilities??[]});const terms=unique([...primaryTerms,...secondaryTerms]); const query = String((intent?.queries ?? []).find(value => /[a-z]/i.test(value)) ?? intent?.queries?.[0] ?? intent?.goal ?? '').slice(0, 80);
302
303
  const rows = []; const sources = []; const warnings = [];const sourceCounts=new Map();
304
+ // 绑定发起这次搜索时的进度代数:旧请求的迟到事件不会写进新一代。
305
+ const progressId = currentProgressId();
306
+ sources.push = function (item) { try { const count = Number(item?.total) || 0; recordProgress({ text: `${item?.title || '来源'}:${item?.status === 'failed' ? '读取失败' : `读到 ${count} 条`}` }, progressId); } catch {} return Array.prototype.push.call(this, item); };
303
307
  const counts=source=>{if(!sourceCounts.has(source))sourceCounts.set(source,{matched:0,inspected:0,resolved:0,excluded:0});return sourceCounts.get(source);};
304
308
  const addRows = (entries, origin, forced = false) => {
305
309
  for (const entry of entries) {
@@ -40,11 +40,22 @@ export const experienceCss = `
40
40
  .pf_root.pf_v2:has(.pfv_home) { background: var(--pfv_canvas); }
41
41
  .pf_v2:has(.pfv_home) .pf_header { margin-bottom: 20px; border-bottom: 0; padding-bottom: 0; }
42
42
  .pfv_home { max-width: 1120px; margin: 0 auto; }
43
- .pfv_home_start { display: grid; grid-template-columns: minmax(0, 2fr) minmax(250px, .85fr); gap: 0 28px; align-items: stretch; padding: 22px 0 34px; }
43
+ .pfv_home_start { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px 0; align-items: stretch; padding: 22px 0 34px; }
44
44
  .pfv_home_intro, .pfv_home_scenario { display: grid; grid-template-rows: subgrid; grid-row: 1 / 4; min-width: 0; padding: 0; margin: 0; }
45
45
  .pfv_home_intro { grid-column: 1; }
46
46
  .pfv_home_scenario { grid-column: 2; }
47
- .pfv_home_extras { grid-area: 4 / 1; min-width: 0; padding-bottom: 4px; }
47
+ .pfv_home_extras { grid-area: auto; min-width: 0; padding-bottom: 4px; }
48
+ .pfv_opportunity_column { grid-column: 1; grid-row: auto; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
49
+ .pfv_opportunity .pfv_home_lead, .pfv_opportunity .pfv_scenario_reason { display: none; }
50
+ .pfv_opportunity .pfv_home_heading { font-size: 12px; font-weight: 500; color: var(--pfv_muted); margin: 0; }
51
+ .pfv_opportunity .pfv_scenario_card { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border-radius: 10px; }
52
+ .pfv_opportunity .pfv_scenario_card h3 { margin: 0; font-size: 13px; }
53
+ .pfv_opportunity .pfv_scenario_card > p { margin: 0; font-size: 12.5px; color: var(--pfv_muted); flex: 1 1 240px; }
54
+ .pfv_opportunity .pfv_scenario_card .pfv_composer_bottom { margin: 0 0 0 auto; }
55
+ .pf_v2 .pfv_opportunity .pfv_home_card { min-height: 0; padding: 10px 14px; border-radius: 10px; flex-direction: row; align-items: center; gap: 14px; }
56
+ .pf_v2 .pfv_opportunity .pfv_scenario_card h3 { font-size: 13px; }
57
+ .pf_v2 .pfv_opportunity .pfv_scenario_card .pfv_prose { font-size: 12.5px; line-height: 1.6; margin: 0; }
58
+ .pf_v2 .pfv_opportunity .pfv_home_card .pfv_composer_bottom { padding-top: 0; }
48
59
  .pf_v2 .pfv_home_heading { margin: 0; font-size: 32px; line-height: 1.35; letter-spacing: -.8px; font-weight: 650; }
49
60
  .pf_v2 .pfv_home_lead { font-size: 14px; color: var(--pfv_muted); margin: 8px 0 22px; line-height: 1.75; }
50
61
  .pf_v2 .pfv_scenario_card h3 { margin: 0; font-size: 20px; line-height: 1.55; letter-spacing: -.3px; font-weight: 600; text-wrap: balance; }
@@ -271,6 +282,7 @@ export const experienceCss = `
271
282
  .pfv_home_intro, .pfv_home_scenario { display: block; grid-area: auto; }
272
283
  .pfv_home_extras { grid-area: auto; }
273
284
  .pfv_home_scenario { margin-top: 28px; }
285
+ .pfv_opportunity_column { grid-area: auto; }
274
286
  .pf_v2 .pfv_home_heading { font-size: 28px; letter-spacing: -.6px; }
275
287
  .pf_v2 .pfv_home_lead { margin: 8px 0 16px; }
276
288
  .pfv_home_card { padding: 20px; }
@@ -117,6 +117,11 @@ export function createExperienceView(React) {
117
117
  'creation-start': '正在整理要创建的插件', 'creation-update': '正在更新插件方案',
118
118
  'creation-refine': '正在根据你的补充修改方案', reset: '正在保留原任务并开始新需求',
119
119
  }[state.busy] || (state.searching ? '正在查找可行路径' : state.followupPending ? '正在更新这份方案' : '正在处理');
120
+ const waited = state.searchingSince && state.clock ? Math.max(0, Math.round((state.clock - state.searchingSince) / 1000)) : 0;
121
+ const liveEvents = busy && Array.isArray(state.searchProgress?.events) ? state.searchProgress.events.filter(item => item && typeof item.text === 'string' && item.text).slice(-4) : [];
122
+ const clockSuffix = waited >= 30
123
+ ? ` 已等待 ${waited} 秒,比平时久;可以继续等,或点上面的「停止」。`
124
+ : waited >= 3 ? ` 已用时 ${waited} 秒。` : '';
120
125
  const submitFollowup = event => { event.preventDefault(); if (!followupBusy && modelReady && text(state.followupText).trim()) void controller.submitFollowup(); };
121
126
  const statusLine = followupBusy && !execution ? h('div', { className: 'pfv_progress', role: 'status' },
122
127
  h('span', { className: 'pfv_progress_dot', 'aria-hidden': true }), h('span', null, progress),
@@ -228,7 +233,8 @@ export function createExperienceView(React) {
228
233
 
229
234
  const planView = () => {
230
235
  if (!plan) return h('div', { className: 'pfv_outcome_empty' }, h('h2', null, busy ? '方案正在形成' : '继续查找方案'),
231
- h('p', { className: 'pfv_hint' }, busy ? '需求已保留,找到的方案会显示在这里。' : '上次查找尚未完成,你可以从这里继续。'),
236
+ h('p', { className: 'pfv_hint' }, busy ? `需求已保留,找到的方案会显示在这里。${clockSuffix}` : '上次查找尚未完成,你可以从这里继续。'),
237
+ liveEvents.length ? h('ul', { className: 'pfv_hint', 'aria-live': 'polite' }, liveEvents.map((item, index) => h('li', { key: `${item.seq || index}` }, item.text))) : null,
232
238
  !busy && state.intent ? primary('重试查找', () => controller.recommend(), { disabled: !modelReady }) : null,
233
239
  !busy && !state.intent && request ? primary('重试查找', () => { controller.setHomeRequest(request); void controller.searchHome(); }, { disabled: !modelReady }) : null);
234
240
  const limits = prerequisites(plan, outcome.candidates);
@@ -0,0 +1,73 @@
1
+ // 搜索进度事件流:只记录宿主真实发生的事,不预测、不伪造。
2
+ // 以「代数(generation)」隔离并发请求:只有当前代的记录会被采纳,
3
+ // 旧请求的迟到事件、取消或失败后的收尾都不会污染新一代。
4
+ const LIMIT = 40;
5
+
6
+ let current = null;
7
+ let lastId = 0;
8
+
9
+ const TERMINALS = {
10
+ done: { kind: 'done', text: '已完成' },
11
+ stopped: { kind: 'stopped', text: '已停止' },
12
+ failed: { kind: 'failed', text: '这一步失败了' },
13
+ };
14
+
15
+ function push(entry) {
16
+ try {
17
+ current.events.push({ ...entry, at: Date.now(), seq: ++current.seq });
18
+ if (current.events.length > LIMIT) current.events.shift();
19
+ } catch {}
20
+ }
21
+
22
+ /** 开启一代进度,返回代数;上一代若仍在运行,直接作废。 */
23
+ export function beginProgress(label) {
24
+ lastId += 1;
25
+ current = {
26
+ id: lastId,
27
+ label: String(label || '正在准备'),
28
+ events: [],
29
+ seq: 0,
30
+ running: true,
31
+ outcome: null,
32
+ startedAt: Date.now(),
33
+ };
34
+ push({ kind: 'phase', text: current.label });
35
+ return current.id;
36
+ }
37
+
38
+ /** 记录一条真实事件;id 缺省表示「当前代」。 */
39
+ export function recordProgress(entry, id) {
40
+ if (!current) return;
41
+ if (id !== undefined && id !== null && id !== current.id) return;
42
+ if (!current.running) return;
43
+ push({ kind: entry?.kind || 'step', text: String(entry?.text || '') });
44
+ }
45
+
46
+ /** 收尾:只有当前代、且尚未收尾时才写终态,避免取消后又被写成「已完成」。 */
47
+ export function endProgress(id, outcome = 'done') {
48
+ if (!current || id !== current.id || !current.running) return;
49
+ current.running = false;
50
+ current.outcome = TERMINALS[outcome] ? outcome : 'done';
51
+ push(TERMINALS[current.outcome]);
52
+ }
53
+
54
+ export function currentProgressId() {
55
+ return current ? current.id : 0;
56
+ }
57
+
58
+ export function progressSnapshot() {
59
+ if (!current) return { id: 0, running: false, outcome: null, startedAt: 0, events: [] };
60
+ return {
61
+ id: current.id,
62
+ running: current.running,
63
+ outcome: current.outcome,
64
+ startedAt: current.startedAt,
65
+ events: current.events.map(({ kind, text, at, seq }) => ({ kind, text, at, seq })),
66
+ };
67
+ }
68
+
69
+ /** 仅用于测试与插件关闭时清场。 */
70
+ export function resetProgress() {
71
+ current = null;
72
+ lastId = 0;
73
+ }
package/src/routes.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import {FinderError} from './contracts.js';
2
+ import {beginProgress,endProgress,progressSnapshot} from './progress.js';
2
3
  const headers={'Cache-Control':'no-store','X-Content-Type-Options':'nosniff'};
3
4
  const reply=(data,status=200)=>Response.json(data,{status,headers});
4
5
  export function registerFinderRoutes(ctx,service){
5
6
  let closed=false;const disposers=[];
6
7
  const connection=ctx.get('connection');
7
- for(const [endpoint,method,action] of [['catalog-detail','POST',body=>service.catalogDetail(body)],['catalog-install','POST',body=>service.catalogInstall(body)],['catalog-status','POST',body=>service.catalogStatus(body)],['opportunity-status','GET',()=>service.opportunityStatus()],['opportunity-grant','POST',body=>service.opportunityGrant(body)],['opportunity-discover','POST',body=>service.opportunityDiscover(body)],['opportunity-feedback','POST',body=>service.opportunityFeedback(body)],['opportunity-context','POST',body=>service.opportunityContext(body)],['opportunity-adopt','POST',body=>service.opportunityAdopt(body)],['bootstrap','GET',()=>service.bootstrap()],['telemetry-status','GET',()=>service.telemetryStatus()],['telemetry-consent','POST',body=>service.telemetryConsent(body)],['telemetry-delete','POST',()=>service.telemetryDelete()],['select-plan','POST',body=>service.selectPlan(body)],['analyze','POST',body=>service.analyze(body)],['recommend','POST',body=>service.recommend(body)],['feedback','POST',body=>service.feedback(body)],['reset','POST',body=>service.reset(body)],['history','POST',body=>service.history(body)],['open','POST',body=>service.open(body)],['refine','POST',body=>service.refine(body)],['creation-start','POST',body=>service.creationStart(body)],['creation-refine','POST',body=>service.creationRefine(body)],['creation-update','POST',body=>service.creationUpdate(body)],['creator-claim','POST',body=>service.creatorClaim(body)],['creator-record','POST',body=>service.creatorRecord(body)],['execution-claim','POST',body=>service.executionClaim(body)],['execution-prepare','POST',body=>service.executionPrepare(body)],['execution-submit-claim','POST',body=>service.executionSubmitClaim(body)],['execution-cancel-claim','POST',body=>service.executionCancelClaim(body)],['execution-record','POST',body=>service.executionRecord(body)],['handoff','POST',body=>service.handoff(body)],['import','POST',body=>service.importBackup(body)],['export','POST',body=>service.exportTask(body)]]){
8
+ for(const [endpoint,method,action] of [['search-progress','GET',()=>progressSnapshot()],['catalog-detail','POST',body=>service.catalogDetail(body)],['catalog-install','POST',body=>service.catalogInstall(body)],['catalog-status','POST',body=>service.catalogStatus(body)],['opportunity-status','GET',()=>service.opportunityStatus()],['opportunity-grant','POST',body=>service.opportunityGrant(body)],['opportunity-discover','POST',body=>service.opportunityDiscover(body)],['opportunity-feedback','POST',body=>service.opportunityFeedback(body)],['opportunity-context','POST',body=>service.opportunityContext(body)],['opportunity-adopt','POST',body=>service.opportunityAdopt(body)],['bootstrap','GET',()=>service.bootstrap()],['telemetry-status','GET',()=>service.telemetryStatus()],['telemetry-consent','POST',body=>service.telemetryConsent(body)],['telemetry-delete','POST',()=>service.telemetryDelete()],['select-plan','POST',body=>service.selectPlan(body)],['analyze','POST',body=>service.analyze(body)],['recommend','POST',body=>service.recommend(body)],['feedback','POST',body=>service.feedback(body)],['reset','POST',body=>service.reset(body)],['history','POST',body=>service.history(body)],['open','POST',body=>service.open(body)],['refine','POST',body=>service.refine(body)],['creation-start','POST',body=>service.creationStart(body)],['creation-refine','POST',body=>service.creationRefine(body)],['creation-update','POST',body=>service.creationUpdate(body)],['creator-claim','POST',body=>service.creatorClaim(body)],['creator-record','POST',body=>service.creatorRecord(body)],['execution-claim','POST',body=>service.executionClaim(body)],['execution-prepare','POST',body=>service.executionPrepare(body)],['execution-submit-claim','POST',body=>service.executionSubmitClaim(body)],['execution-cancel-claim','POST',body=>service.executionCancelClaim(body)],['execution-record','POST',body=>service.executionRecord(body)],['handoff','POST',body=>service.handoff(body)],['import','POST',body=>service.importBackup(body)],['export','POST',body=>service.exportTask(body)]]){
8
9
  const off=connection.fetch.register({path:`/api/plugin_finder/${endpoint}`,methods:[method],requestBody:'buffered',async fetch(request){
9
10
  if(closed)return reply({error:{code:'CLOSED',message:'插件已关闭,请重新打开。'}},503);
10
11
  if(request.method!==method)return reply({error:{code:'METHOD_NOT_ALLOWED',message:'请求方法不支持。'}},405);
@@ -17,7 +18,10 @@ export function registerFinderRoutes(ctx,service){
17
18
  const bytes=await request.arrayBuffer();if(bytes.byteLength>bodyLimit)return reply({error:{code:'BODY_TOO_LARGE',message:endpoint==='import'?'备份文件过大,请分任务导入。':'请求过长,请缩短。'}},413);
18
19
  try{body=JSON.parse(new TextDecoder().decode(bytes));if(!body||typeof body!=='object'||Array.isArray(body))throw Error();}catch{return reply({error:{code:'INVALID_INPUT',message:'请求不是有效 JSON 对象。'}},400);}
19
20
  }
20
- try{return reply(await action({...body,signal:request.signal}));}catch(error){const safe=error instanceof FinderError?error:new FinderError('MODEL_REQUEST_FAILED');return reply({error:{code:safe.code,message:safe.message,...(safe.details?{details:safe.details}:{})}},safe.status);}
21
+ const tracked=endpoint==='analyze'||endpoint==='recommend';
22
+ const progressId=tracked?beginProgress(endpoint==='analyze'?'理解目标与约束':'查找来源并整理方案'):0;
23
+ let outcome='done';
24
+ try{return reply(await action({...body,signal:request.signal}));}catch(error){outcome=request.signal?.aborted?'stopped':'failed';const safe=error instanceof FinderError?error:new FinderError('MODEL_REQUEST_FAILED');return reply({error:{code:safe.code,message:safe.message,...(safe.details?{details:safe.details}:{})}},safe.status);}finally{if(tracked)endProgress(progressId,outcome);}
21
25
  }});disposers.push(off);
22
26
  }
23
27
  const stop=()=>{if(closed)return;closed=true;for(const off of disposers)off();};