@morehao/dsh-github-trending 0.6.1 → 0.7.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.
@@ -1611,6 +1611,8 @@ function buildCoreArgs(channelPath, options) {
1611
1611
  if (options.date !== void 0 && options.date !== "") args.push("--date", options.date);
1612
1612
  if (options.period !== void 0) args.push("--period", options.period);
1613
1613
  if (options.stages !== void 0 && options.stages.length > 0) args.push("--stages", options.stages.join(","));
1614
+ if (options.force === true) args.push("--force");
1615
+ if (options.repo !== void 0 && options.repo !== "") args.push("--repo", options.repo);
1614
1616
  return args;
1615
1617
  }
1616
1618
  async function runCore(options) {
@@ -1625,7 +1627,9 @@ async function runCore(options) {
1625
1627
  dryRun: options.dryRun,
1626
1628
  date: options.date,
1627
1629
  period: options.period,
1628
- stages: options.stages
1630
+ stages: options.stages,
1631
+ force: options.force,
1632
+ ...options.repo === void 0 ? {} : { repo: options.repo }
1629
1633
  });
1630
1634
  const child = spawn2(options.core.path, args, {
1631
1635
  env: sanitizedEnv(process.env, {
@@ -2722,9 +2726,34 @@ async function runSubscribe(input, deps) {
2722
2726
  }
2723
2727
  }
2724
2728
 
2729
+ // src/host/version.ts
2730
+ var version_exports = {};
2731
+ __export(version_exports, {
2732
+ versionAtLeast: () => versionAtLeast
2733
+ });
2734
+ function parseTriplet(value) {
2735
+ const match = /^v?(\d+)\.(\d+)\.(\d+)/.exec(value.trim());
2736
+ if (match === null) return void 0;
2737
+ return [Number(match[1]), Number(match[2]), Number(match[3])];
2738
+ }
2739
+ function versionAtLeast(a, b) {
2740
+ const left = parseTriplet(a);
2741
+ const right = parseTriplet(b);
2742
+ if (left === void 0 || right === void 0) return false;
2743
+ for (let i = 0; i < 3; i += 1) {
2744
+ const l = left[i];
2745
+ const r = right[i];
2746
+ if (l > r) return true;
2747
+ if (l < r) return false;
2748
+ }
2749
+ return true;
2750
+ }
2751
+
2725
2752
  // src/host/runner.ts
2726
2753
  var runner_exports = {};
2727
2754
  __export(runner_exports, {
2755
+ FORCE_MIN_CORE_VERSION: () => FORCE_MIN_CORE_VERSION,
2756
+ REPO_MIN_CORE_VERSION: () => REPO_MIN_CORE_VERSION,
2728
2757
  Runner: () => Runner,
2729
2758
  isoWeekName: () => isoWeekName,
2730
2759
  periodFileBase: () => periodFileBase,
@@ -2733,6 +2762,8 @@ __export(runner_exports, {
2733
2762
  import { createHash as createHash2 } from "crypto";
2734
2763
  import { existsSync as existsSync4, readFileSync as readFileSync3, realpathSync, statSync as statSync5 } from "fs";
2735
2764
  import path9 from "path";
2765
+ var FORCE_MIN_CORE_VERSION = "0.7.1";
2766
+ var REPO_MIN_CORE_VERSION = "0.8.0";
2736
2767
  function repoProblem(repoPath) {
2737
2768
  if (repoPath.trim() === "") return { code: "CONFIG_INVALID", message: "\u8FD8\u6CA1\u6709\u9009\u62E9\u5F52\u6863\u4ED3\u5E93" };
2738
2769
  if (!existsSync4(repoPath)) return { code: "REPO_NOT_GIT", message: `\u76EE\u5F55\u4E0D\u5B58\u5728\uFF1A${repoPath}` };
@@ -2851,6 +2882,15 @@ var Runner = class {
2851
2882
  `\u6838\u5FC3\u4E0D\u652F\u6301 provider\u300C${settings.model.provider}\u300D\uFF1B\u53EF\u7528\uFF1A${handshakeResult.supportedProviders.join(" / ")}`
2852
2883
  );
2853
2884
  }
2885
+ const forceRequested = options.force === true;
2886
+ const forceSupported = versionAtLeast(handshakeResult.version.version, FORCE_MIN_CORE_VERSION);
2887
+ const effectiveForce = forceRequested && forceSupported;
2888
+ if (forceRequested && !forceSupported) {
2889
+ store.appendLog(
2890
+ logFile,
2891
+ `[force] \u6838\u5FC3 ${handshakeResult.version.version} \u4F4E\u4E8E ${FORCE_MIN_CORE_VERSION}\uFF0C\u4E0D\u652F\u6301 --force\uFF0C\u5DF2\u964D\u7EA7\u4E3A\u666E\u901A\u91CD\u8DD1`
2892
+ );
2893
+ }
2854
2894
  const model = await this.openModelChannel({ settings, credentials, env, logFile });
2855
2895
  const apiKey = model.apiKey;
2856
2896
  proxy = model.proxy;
@@ -2868,6 +2908,7 @@ var Runner = class {
2868
2908
  period,
2869
2909
  dryRun,
2870
2910
  trigger: options.trigger === "schedule" ? "schedule" : "manual",
2911
+ ...effectiveForce ? { force: true } : {},
2871
2912
  ...model.baseURLOverride === void 0 ? {} : { baseURLOverride: model.baseURLOverride },
2872
2913
  signal: controller.signal,
2873
2914
  secrets: [apiKey, github.token],
@@ -2884,7 +2925,8 @@ var Runner = class {
2884
2925
  channel: result.channelKind,
2885
2926
  proxy: proxy !== void 0,
2886
2927
  coreSource: core.source,
2887
- ...core.tag === void 0 ? {} : { coreTag: core.tag }
2928
+ ...core.tag === void 0 ? {} : { coreTag: core.tag },
2929
+ ...effectiveForce ? { forced: true } : {}
2888
2930
  });
2889
2931
  const preview = this.capturePreview({
2890
2932
  id,
@@ -2892,7 +2934,8 @@ var Runner = class {
2892
2934
  period,
2893
2935
  settings,
2894
2936
  outcome,
2895
- secrets: [apiKey, github.token]
2937
+ secrets: [apiKey, github.token],
2938
+ ...effectiveForce ? { force: true } : {}
2896
2939
  });
2897
2940
  if (preview !== void 0) summary.preview = preview;
2898
2941
  this.record(summary, settings);
@@ -2971,6 +3014,7 @@ var Runner = class {
2971
3014
  this.active = { id, controller, startedAt };
2972
3015
  const logFile = store.newLogPath(id);
2973
3016
  let proxy;
3017
+ const requestedRepo = options.repo !== void 0 && options.repo !== "" ? options.repo : void 0;
2974
3018
  try {
2975
3019
  const core = await locateCore({ settings, env, allowDownload: settings.coreAutoDownload });
2976
3020
  if (core.downloaded === true) {
@@ -2983,6 +3027,14 @@ var Runner = class {
2983
3027
  `\u6838\u5FC3\u4E0D\u652F\u6301 provider\u300C${settings.model.provider}\u300D\uFF1B\u53EF\u7528\uFF1A${handshakeResult.supportedProviders.join(" / ")}`
2984
3028
  );
2985
3029
  }
3030
+ let effectiveRepo = requestedRepo;
3031
+ if (requestedRepo !== void 0 && !versionAtLeast(handshakeResult.version.version, REPO_MIN_CORE_VERSION)) {
3032
+ store.appendLog(
3033
+ logFile,
3034
+ `[release] \u6838\u5FC3 ${handshakeResult.version.version} \u4F4E\u4E8E ${REPO_MIN_CORE_VERSION}\uFF0C\u5355\u4ED3\u5206\u6790\u964D\u7EA7\u4E3A\u5168\u91CF`
3035
+ );
3036
+ effectiveRepo = void 0;
3037
+ }
2986
3038
  const model = await this.openModelChannel({ settings, credentials, env, logFile });
2987
3039
  proxy = model.proxy;
2988
3040
  const github = await resolveGithubToken(credentials, settings.github.authMode, settings.github.tokenRef, { env });
@@ -3002,6 +3054,7 @@ var Runner = class {
3002
3054
  dryRun: false,
3003
3055
  trigger: options.trigger === "schedule" ? "schedule" : "manual",
3004
3056
  stages: ["releases"],
3057
+ ...effectiveRepo === void 0 ? {} : { repo: effectiveRepo },
3005
3058
  repoCount,
3006
3059
  ...model.baseURLOverride === void 0 ? {} : { baseURLOverride: model.baseURLOverride },
3007
3060
  signal: controller.signal,
@@ -3014,11 +3067,12 @@ var Runner = class {
3014
3067
  settings,
3015
3068
  startedAt,
3016
3069
  logFile,
3017
- cancelled: controller.signal.aborted
3070
+ cancelled: controller.signal.aborted,
3071
+ ...requestedRepo === void 0 ? {} : { scopeRepo: requestedRepo }
3018
3072
  });
3019
3073
  } catch (error) {
3020
3074
  const aborted = controller.signal.aborted || error instanceof IpcError && error.code === "CORE_CANCELLED";
3021
- return this.recordReleaseFailure({ id, error, aborted, settings, startedAt, startedMs, logFile });
3075
+ return this.recordReleaseFailure({ id, error, aborted, settings, startedAt, startedMs, logFile, ...requestedRepo === void 0 ? {} : { scopeRepo: requestedRepo } });
3022
3076
  } finally {
3023
3077
  if (proxy !== void 0) {
3024
3078
  const port = proxy.port;
@@ -3096,9 +3150,10 @@ var Runner = class {
3096
3150
  ...outcome.prUrl === void 0 ? {} : { prUrl: outcome.prUrl },
3097
3151
  ...outcome.branch === void 0 ? {} : { branch: outcome.branch },
3098
3152
  ...outcome.error === void 0 ? input.cancelled ? { errorCode: "CORE_CANCELLED", errorMessage: "\u8FD0\u884C\u5DF2\u53D6\u6D88\uFF1A\u6838\u5FC3\u8FDB\u7A0B\u5DF2\u7EC8\u6B62\uFF0C\u672A\u63D0\u4EA4\u4EFB\u4F55\u72B6\u6001" } : {} : { errorCode: outcome.error.code, errorMessage: redact(outcome.error.message) },
3099
- ...outcome.coreVersion === "" ? {} : { coreVersion: outcome.coreVersion }
3153
+ ...outcome.coreVersion === "" ? {} : { coreVersion: outcome.coreVersion },
3154
+ ...input.scopeRepo === void 0 ? {} : { scopeRepo: input.scopeRepo }
3100
3155
  };
3101
- this.persistReleaseRun(record, settings, input.logFile);
3156
+ this.persistReleaseRun(record, settings, input.logFile, { advanceWeek: input.scopeRepo === void 0 });
3102
3157
  return record;
3103
3158
  }
3104
3159
  /** 运行在拿到信封之前就失败(定位/握手/模型/代理/超时/取消):也要留一条可复盘记录。 */
@@ -3119,20 +3174,24 @@ var Runner = class {
3119
3174
  rateLimited: 0,
3120
3175
  durationMs: Date.now() - input.startedMs,
3121
3176
  errorCode: code,
3122
- errorMessage: message
3177
+ errorMessage: message,
3178
+ ...input.scopeRepo === void 0 ? {} : { scopeRepo: input.scopeRepo }
3123
3179
  };
3124
- this.persistReleaseRun(record, input.settings, input.logFile);
3180
+ this.persistReleaseRun(record, input.settings, input.logFile, { advanceWeek: input.scopeRepo === void 0 });
3125
3181
  return record;
3126
3182
  }
3127
3183
  /**
3128
3184
  * 落盘发版运行:只写 state(history.json 是榜单的),顺带推进 lastReleaseAt;
3129
3185
  * 只有 ok/skipped 才锁 `lastReleaseWeek`——失败不锁,调度下一 tick 才有机会重试。
3186
+ * `advanceWeek=false`(单仓手动触发)时:仍写 releaseRuns 与 lastReleaseAt,但**不**锁
3187
+ * lastReleaseWeek——否则会把本周标记为已检查,导致周调度跳过本周真正的检查。
3130
3188
  */
3131
- persistReleaseRun(record, settings, logFile) {
3189
+ persistReleaseRun(record, settings, logFile, opts = {}) {
3132
3190
  const store = this.deps.store;
3191
+ const advanceWeek = opts.advanceWeek !== false;
3133
3192
  const succeeded = record.status === "ok" || record.status === "skipped";
3134
3193
  let week;
3135
- if (succeeded) {
3194
+ if (succeeded && advanceWeek) {
3136
3195
  try {
3137
3196
  week = isoWeekKey(new Date(record.finishedAt), settings.releases.schedule.timezone);
3138
3197
  } catch {
@@ -3192,7 +3251,8 @@ var Runner = class {
3192
3251
  ...input.channel === void 0 ? {} : { channel: input.channel },
3193
3252
  proxy: input.proxy,
3194
3253
  ...input.coreSource === void 0 ? {} : { coreSource: input.coreSource },
3195
- ...input.coreTag === void 0 ? {} : { coreTag: input.coreTag }
3254
+ ...input.coreTag === void 0 ? {} : { coreTag: input.coreTag },
3255
+ ...input.forced === true ? { forced: true } : {}
3196
3256
  };
3197
3257
  }
3198
3258
  failureSummary(input) {
@@ -3223,7 +3283,8 @@ var Runner = class {
3223
3283
  */
3224
3284
  capturePreview(input) {
3225
3285
  const { outcome, settings, date, period, id } = input;
3226
- if (!outcome.ok || outcome.dryRun || outcome.skipped || date === void 0) return void 0;
3286
+ if (!outcome.ok || outcome.dryRun || date === void 0) return void 0;
3287
+ if (outcome.skipped && input.force !== true) return void 0;
3227
3288
  const skip = (reason, extra = {}) => {
3228
3289
  this.deps.logger?.("preview.skip", { id, reason, ...extra });
3229
3290
  return void 0;
@@ -3294,6 +3355,7 @@ var Runner = class {
3294
3355
  ...summary.error.reason === void 0 ? {} : { errorReason: summary.error.reason }
3295
3356
  },
3296
3357
  ...summary.skipReason === void 0 ? {} : { skipReason: summary.skipReason },
3358
+ ...summary.forced === true ? { forced: true } : {},
3297
3359
  durationMs: summary.durationMs,
3298
3360
  files: summary.files,
3299
3361
  ...summary.date === void 0 ? {} : { date: summary.date },
@@ -3319,7 +3381,9 @@ var Runner = class {
3319
3381
  ...summary.ok ? { lastSuccessAt: record.at } : {},
3320
3382
  ...summary.ok && summary.period !== void 0 ? { periodSuccess } : {},
3321
3383
  ...summary.ok && summary.prUrl !== void 0 ? { pendingPr: { url: summary.prUrl, createdAt: record.at, ...summary.date === void 0 ? {} : { date: summary.date } } } : {},
3322
- ...summary.ok && !summary.skipped && summary.contentHash !== void 0 ? {
3384
+ // 幂等:内容未变(skipped)通常不刷新 lastDigest;但显式 force 时即便 core 判定
3385
+ // unchanged,也要把本次作为最新展示(contentHash 仍是真实 hash,不伪造)。
3386
+ ...summary.ok && summary.contentHash !== void 0 && (!summary.skipped || summary.forced === true) ? {
3323
3387
  lastDigest: {
3324
3388
  date: summary.date ?? (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
3325
3389
  contentHash: summary.contentHash,
@@ -3994,7 +4058,10 @@ function createRoutes(deps) {
3994
4058
  const code = error instanceof IpcError ? error.code : "INTERNAL";
3995
4059
  const message = redact(error instanceof Error ? error.message : String(error));
3996
4060
  deps.logger?.("route.error", { pathname, method, code, message });
3997
- const status = code === "CONFIG_INVALID" ? 400 : code === "NOT_FOUND" ? 404 : 500;
4061
+ const status = code === "CONFIG_INVALID" ? (
4062
+ // 「已有一次运行在进行中」是并发冲突而非参数错误:用 409,前端据此禁用按钮并提示。
4063
+ message.includes("\u8FD0\u884C\u5728\u8FDB\u884C\u4E2D") ? 409 : 400
4064
+ ) : code === "NOT_FOUND" ? 404 : 500;
3998
4065
  sendJson2(response, status, { ok: false, code, message });
3999
4066
  }
4000
4067
  };
@@ -4060,6 +4127,7 @@ async function dispatch(method, pathname, url, request, deps) {
4060
4127
  const base = {
4061
4128
  dryRun: body.dryRun === true,
4062
4129
  ...typeof body.date === "string" && body.date !== "" ? { date: body.date } : {},
4130
+ ...body.force === true ? { force: true } : {},
4063
4131
  trigger: "manual"
4064
4132
  };
4065
4133
  if (isPeriod(body.period)) {
@@ -4072,6 +4140,18 @@ async function dispatch(method, pathname, url, request, deps) {
4072
4140
  if (method === "POST" && pathname === "/run/cancel") {
4073
4141
  return { cancelled: deps.runner.cancel() };
4074
4142
  }
4143
+ if (method === "POST" && pathname === "/releases/run") {
4144
+ const body = await readBody2(request);
4145
+ let repo;
4146
+ if (body.repo !== void 0) {
4147
+ if (typeof body.repo !== "string" || !isValidRepo(body.repo.trim())) {
4148
+ throw new IpcError("CONFIG_INVALID", `repo \u5FC5\u987B\u662F owner/repo \u5F62\u6001\uFF1A${String(body.repo)}`);
4149
+ }
4150
+ repo = body.repo.trim();
4151
+ }
4152
+ const release = await deps.runner.runReleases({ trigger: "manual", ...repo === void 0 ? {} : { repo } });
4153
+ return { release };
4154
+ }
4075
4155
  if (method === "GET" && pathname === "/repo/branch") {
4076
4156
  const repoPath = url.searchParams.get("path") ?? settings.repo.path;
4077
4157
  return { repo: await readDefaultBranch(repoPath, { env }) };
@@ -4333,6 +4413,7 @@ var RUN_OUTPUT_SCHEMA = {
4333
4413
  ok: { type: "boolean" },
4334
4414
  skipped: { type: "boolean" },
4335
4415
  dryRun: { type: "boolean" },
4416
+ forced: { type: "boolean" },
4336
4417
  durationMs: { type: "number" },
4337
4418
  coreVersion: { type: "string" },
4338
4419
  files: { type: "number" },
@@ -4393,11 +4474,12 @@ function describeRecord(record) {
4393
4474
  function createTrendingRunTool(runner) {
4394
4475
  return {
4395
4476
  name: "trending_run",
4396
- description: "\u6267\u884C GitHub \u8D8B\u52BF\u699C\u5355\uFF1A\u5B9A\u4F4D\u5E76\u63E1\u624B\u672C\u5730\u6838\u5FC3\uFF0Cspawn \u6838\u5FC3 run\uFF0C\u8FD4\u56DE\u7ED3\u6784\u5316\u6458\u8981\uFF08\u6587\u4EF6\u6570\u3001commit\u3001PR\u3001\u9519\u8BEF\u7801\uFF09\u3002\u7701\u7565 period \u65F6\u9ED8\u8BA4\u4EA7\u51FA\u65E5/\u5468/\u6708\u4E09\u699C\uFF08\u4F9D\u6B21\u8FD0\u884C\u4E09\u6B21\uFF0C\u8FD4\u56DE summaries\uFF09\u3002dryRun=true \u53EA\u6293\u53D6\u4E0E\u6E32\u67D3\u3001\u4E0D\u5199\u6587\u4EF6\u4E5F\u4E0D\u63D0\u4EA4\u3002\u540C\u65E5\u540C\u5185\u5BB9\u91CD\u8DD1\u4F1A\u8FD4\u56DE skipped=true\uFF08\u96F6\u65B0\u589E commit\uFF09\u3002",
4477
+ description: "\u6267\u884C GitHub \u8D8B\u52BF\u699C\u5355\uFF1A\u5B9A\u4F4D\u5E76\u63E1\u624B\u672C\u5730\u6838\u5FC3\uFF0Cspawn \u6838\u5FC3 run\uFF0C\u8FD4\u56DE\u7ED3\u6784\u5316\u6458\u8981\uFF08\u6587\u4EF6\u6570\u3001commit\u3001PR\u3001\u9519\u8BEF\u7801\uFF09\u3002\u7701\u7565 period \u65F6\u9ED8\u8BA4\u4EA7\u51FA\u65E5/\u5468/\u6708\u4E09\u699C\uFF08\u4F9D\u6B21\u8FD0\u884C\u4E09\u6B21\uFF0C\u8FD4\u56DE summaries\uFF09\u3002dryRun=true \u53EA\u6293\u53D6\u4E0E\u6E32\u67D3\u3001\u4E0D\u5199\u6587\u4EF6\u4E5F\u4E0D\u63D0\u4EA4\u3002force=true \u5FFD\u7565\u6458\u8981\u7F13\u5B58\u3001\u5F3A\u5236\u91CD\u65B0\u751F\u6210\uFF08\u5185\u5BB9\u65E0\u53D8\u5316\u65F6\u4E0D\u65B0\u589E\u63D0\u4EA4\uFF0C\u4F46\u4F1A\u5237\u65B0\u9884\u89C8\uFF09\u3002\u540C\u65E5\u540C\u5185\u5BB9\u91CD\u8DD1\u4F1A\u8FD4\u56DE skipped=true\uFF08\u96F6\u65B0\u589E commit\uFF09\u3002",
4397
4478
  parameters: {
4398
4479
  dryRun: { type: "boolean", description: "\u53EA\u8BD5\u8DD1\uFF1A\u4E0D\u5199\u6587\u4EF6\u3001\u4E0D\u63D0\u4EA4\u3001\u4E0D\u5F00 PR" },
4399
4480
  date: { type: "string", description: "\u6307\u5B9A\u65E5\u671F\uFF08YYYY-MM-DD\uFF09\uFF1B\u7701\u7565\u5219\u7528\u8C03\u5EA6\u65F6\u533A\u7684\u4ECA\u5929" },
4400
- period: { type: "string", enum: ["daily", "weekly", "monthly"], description: "\u53EA\u8DD1\u6307\u5B9A\u5468\u671F\uFF1B\u7701\u7565\u5219\u9ED8\u8BA4\u4EA7\u51FA\u65E5/\u5468/\u6708\u4E09\u699C" }
4481
+ period: { type: "string", enum: ["daily", "weekly", "monthly"], description: "\u53EA\u8DD1\u6307\u5B9A\u5468\u671F\uFF1B\u7701\u7565\u5219\u9ED8\u8BA4\u4EA7\u51FA\u65E5/\u5468/\u6708\u4E09\u699C" },
4482
+ force: { type: "boolean", description: "\u5FFD\u7565\u6458\u8981\u7F13\u5B58\u3001\u5F3A\u5236\u91CD\u65B0\u751F\u6210\uFF08\u5185\u5BB9\u65E0\u53D8\u5316\u65F6\u4E0D\u65B0\u589E\u63D0\u4EA4\uFF0C\u4F46\u4F1A\u5237\u65B0\u9884\u89C8\uFF09" }
4401
4483
  },
4402
4484
  output: {
4403
4485
  schema: RUN_OUTPUT_SCHEMA,
@@ -4408,13 +4490,14 @@ function createTrendingRunTool(runner) {
4408
4490
  const base = {
4409
4491
  dryRun: args.dryRun === true,
4410
4492
  ...typeof args.date === "string" && args.date !== "" ? { date: args.date } : {},
4493
+ ...args.force === true ? { force: true } : {},
4411
4494
  trigger: "tool"
4412
4495
  };
4413
4496
  const summaries = isPeriod(args.period) ? [await runner.run({ ...base, period: args.period })] : await runner.runMany(base);
4414
4497
  const lines = [];
4415
4498
  for (const summary of summaries) {
4416
4499
  const periodLabel = summary.period ?? "\u2014";
4417
- const head = summary.ok ? summary.skipped ? "\u65E0\u53D8\u66F4\uFF08skipped\uFF09" : summary.dryRun ? "\u8BD5\u8DD1\u5B8C\u6210" : "\u8FD0\u884C\u6210\u529F" : `\u8FD0\u884C\u5931\u8D25\uFF1A${summary.error?.code ?? "INTERNAL"}`;
4500
+ const head = summary.ok ? summary.skipped ? summary.forced ? "\u65E0\u53D8\u5316\uFF08\u5F3A\u5236\u91CD\u8DD1\uFF0C\u672A\u65B0\u589E\u63D0\u4EA4\uFF09" : "\u65E0\u53D8\u66F4\uFF08skipped\uFF09" : summary.dryRun ? "\u8BD5\u8DD1\u5B8C\u6210" : "\u8FD0\u884C\u6210\u529F" : `\u8FD0\u884C\u5931\u8D25\uFF1A${summary.error?.code ?? "INTERNAL"}`;
4418
4501
  lines.push(`${summary.ok ? "\u2713" : "\u2717"} [${periodLabel}] ${head}`);
4419
4502
  lines.push(`\xB7 \u6838\u5FC3 ${summary.coreVersion || "(\u672A\u77E5)"} \xB7 ${formatDuration(summary.durationMs)} \xB7 ${summary.files} \u4E2A\u6587\u4EF6`);
4420
4503
  if (summary.tokens !== void 0) {
@@ -4444,6 +4527,7 @@ function createTrendingRunTool(runner) {
4444
4527
  ok: summary.ok,
4445
4528
  skipped: summary.skipped,
4446
4529
  dryRun: summary.dryRun,
4530
+ ...summary.forced === true ? { forced: true } : {},
4447
4531
  durationMs: summary.durationMs,
4448
4532
  files: summary.files,
4449
4533
  ...summary.tokens === void 0 ? {} : { tokens: summary.tokens },
@@ -4455,6 +4539,7 @@ function createTrendingRunTool(runner) {
4455
4539
  id: primary?.id,
4456
4540
  skipped: summaries.every((summary) => summary.skipped),
4457
4541
  dryRun: base.dryRun,
4542
+ ...base.force === true ? { forced: true } : {},
4458
4543
  durationMs: summaries.reduce((sum, summary) => sum + summary.durationMs, 0),
4459
4544
  files: summaries.reduce((sum, summary) => sum + summary.files, 0),
4460
4545
  ...(() => {
@@ -4530,6 +4615,7 @@ export {
4530
4615
  Scheduler,
4531
4616
  schedule_exports,
4532
4617
  subscribe_exports,
4618
+ version_exports,
4533
4619
  Runner,
4534
4620
  runner_exports,
4535
4621
  readPluginInfo,
package/lib/index.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  createTrendingRunTool,
9
9
  createUpdateService,
10
10
  readPluginInfo
11
- } from "./chunk-WDBZAMWN.js";
11
+ } from "./chunk-R3EDPRRO.js";
12
12
  import "./chunk-R7BK7SJK.js";
13
13
 
14
14
  // src/index.ts
package/lib/internal.d.ts CHANGED
@@ -555,6 +555,8 @@ interface RunRecord {
555
555
  errorReason?: string;
556
556
  /** 跳过原因:merged / pr-closed / unchanged。 */
557
557
  skipReason?: string;
558
+ /** 本次是显式「强制重跑(忽略缓存)」;调度永不置位。仅用于展示与区分幂等。 */
559
+ forced?: boolean;
558
560
  durationMs: number;
559
561
  files: number;
560
562
  /** 运行所属的调度时区日期(YYYY-MM-DD);旧记录可能没有。 */
@@ -629,6 +631,8 @@ interface ReleaseRunRecord {
629
631
  errorCode?: string;
630
632
  errorMessage?: string;
631
633
  coreVersion?: string;
634
+ /** 单仓手动触发时记录该仓库(owner/repo);全量运行缺省。仅展示用。 */
635
+ scopeRepo?: string;
632
636
  }
633
637
  /** 发版运行记录上限:一周一次的话正好留半年,够复盘又不会让 state.json 膨胀。 */
634
638
  declare const RELEASE_RUN_LIMIT = 30;
@@ -973,6 +977,8 @@ interface RunCoreOptions {
973
977
  dryRun: boolean;
974
978
  /** 谁触发的运行:核心用它在定时运行时尊重「人工关闭的 PR」。 */
975
979
  trigger?: 'manual' | 'schedule';
980
+ /** 忽略摘要缓存、强制重新生成(核心 `run --force`);不影响 append-only 提交判断。 */
981
+ force?: boolean;
976
982
  /** 回环代理地址:覆盖配置里的 model.baseURL(代理模式专用)。 */
977
983
  baseURLOverride?: string;
978
984
  /**
@@ -980,6 +986,8 @@ interface RunCoreOptions {
980
986
  * `['releases']` 就是「只跑发版订阅」——不抓榜单、不渲染 digest、也不合并订阅 pending。
981
987
  */
982
988
  stages?: string[];
989
+ /** 单仓发版分析(核心 `run --stages releases --repo owner/repo`):只处理该仓库;须与 stages=['releases'] 搭配。 */
990
+ repo?: string;
983
991
  /** 订阅仓库数:用于把配置里的 `auto` 并发/预算解析成数字(发版运行传入)。 */
984
992
  repoCount?: number;
985
993
  signal?: AbortSignal;
@@ -999,6 +1007,8 @@ declare function buildCoreArgs(channelPath: string, options: {
999
1007
  date?: string;
1000
1008
  period?: Period;
1001
1009
  stages?: string[];
1010
+ force?: boolean;
1011
+ repo?: string;
1002
1012
  }): string[];
1003
1013
  declare function runCore(options: RunCoreOptions): Promise<RunCoreResult>;
1004
1014
 
@@ -1436,6 +1446,16 @@ declare namespace pendingPr {
1436
1446
  export { type pendingPr_CheckPendingPrOptions as CheckPendingPrOptions, type pendingPr_ParsedPullUrl as ParsedPullUrl, type pendingPr_PendingPrStatus as PendingPrStatus, type pendingPr_PullState as PullState, pendingPr_checkPendingPr as checkPendingPr, pendingPr_clearPendingPrCache as clearPendingPrCache, pendingPr_parsePullUrl as parsePullUrl };
1437
1447
  }
1438
1448
 
1449
+ /**
1450
+ * 支持 `run --force`(忽略摘要缓存重新生成)的最低核心版本。
1451
+ * 与 core patch 发版 `0.7.1` 对齐;`dsh.core.version` 应 >= 它,dev override 指向更旧核心时靠闸门降级。
1452
+ */
1453
+ declare const FORCE_MIN_CORE_VERSION = "0.7.1";
1454
+ /**
1455
+ * 支持 `run --stages releases --repo`(单仓发版分析)的最低核心版本。
1456
+ * 与 core v0.8.0 对齐;核心更旧时单仓触发降级为全量(不传 --repo)。
1457
+ */
1458
+ declare const REPO_MIN_CORE_VERSION = "0.8.0";
1439
1459
  interface RunSummary {
1440
1460
  id: string;
1441
1461
  ok: boolean;
@@ -1454,6 +1474,8 @@ interface RunSummary {
1454
1474
  preview?: PreviewMeta;
1455
1475
  /** 核心给出的跳过原因(merged / pr-closed / unchanged)。 */
1456
1476
  skipReason?: string;
1477
+ /** 本次是显式「强制重跑(忽略缓存)」;调度永不置位。 */
1478
+ forced?: boolean;
1457
1479
  error?: {
1458
1480
  code: string;
1459
1481
  message: string;
@@ -1481,6 +1503,8 @@ interface RunRequestOptions {
1481
1503
  date?: string;
1482
1504
  /** 标的周期;缺省取 settings.trending.since(手动/工具运行)。 */
1483
1505
  period?: Period;
1506
+ /** 强制重跑:忽略摘要缓存、重新生成(核心 `run --force`);仅手动/工具触发,调度永不设置。 */
1507
+ force?: boolean;
1484
1508
  trigger: 'manual' | 'schedule' | 'tool';
1485
1509
  }
1486
1510
  interface RunnerDeps {
@@ -1539,6 +1563,7 @@ declare class Runner {
1539
1563
  */
1540
1564
  runReleases(options: {
1541
1565
  trigger: 'manual' | 'schedule';
1566
+ repo?: string;
1542
1567
  }): Promise<ReleaseRunRecord>;
1543
1568
  /** 发版运行用哪一天:发版调度时区下的「今天」(不是榜单调度时区,两者可独立配置)。 */
1544
1569
  private releaseDate;
@@ -1558,6 +1583,8 @@ declare class Runner {
1558
1583
  /**
1559
1584
  * 落盘发版运行:只写 state(history.json 是榜单的),顺带推进 lastReleaseAt;
1560
1585
  * 只有 ok/skipped 才锁 `lastReleaseWeek`——失败不锁,调度下一 tick 才有机会重试。
1586
+ * `advanceWeek=false`(单仓手动触发)时:仍写 releaseRuns 与 lastReleaseAt,但**不**锁
1587
+ * lastReleaseWeek——否则会把本周标记为已检查,导致周调度跳过本周真正的检查。
1561
1588
  */
1562
1589
  private persistReleaseRun;
1563
1590
  private summarize;
@@ -1577,6 +1604,8 @@ declare class Runner {
1577
1604
  coreStatus(fresh?: boolean): Promise<CoreStatus>;
1578
1605
  }
1579
1606
 
1607
+ declare const runner_FORCE_MIN_CORE_VERSION: typeof FORCE_MIN_CORE_VERSION;
1608
+ declare const runner_REPO_MIN_CORE_VERSION: typeof REPO_MIN_CORE_VERSION;
1580
1609
  type runner_RunRequestOptions = RunRequestOptions;
1581
1610
  type runner_RunSummary = RunSummary;
1582
1611
  type runner_Runner = Runner;
@@ -1586,7 +1615,7 @@ declare const runner_isoWeekName: typeof isoWeekName;
1586
1615
  declare const runner_periodFileBase: typeof periodFileBase;
1587
1616
  declare const runner_projectUsage: typeof projectUsage;
1588
1617
  declare namespace runner {
1589
- export { type runner_RunRequestOptions as RunRequestOptions, type runner_RunSummary as RunSummary, runner_Runner as Runner, type runner_RunnerDeps as RunnerDeps, runner_isoWeekName as isoWeekName, runner_periodFileBase as periodFileBase, runner_projectUsage as projectUsage };
1618
+ export { runner_FORCE_MIN_CORE_VERSION as FORCE_MIN_CORE_VERSION, runner_REPO_MIN_CORE_VERSION as REPO_MIN_CORE_VERSION, type runner_RunRequestOptions as RunRequestOptions, type runner_RunSummary as RunSummary, runner_Runner as Runner, type runner_RunnerDeps as RunnerDeps, runner_isoWeekName as isoWeekName, runner_periodFileBase as periodFileBase, runner_projectUsage as projectUsage };
1590
1619
  }
1591
1620
 
1592
1621
  /** 订阅命令超时:核心只做一次 GitHub 请求/本地文件读写,8 s 足够。 */
@@ -1769,6 +1798,23 @@ declare namespace schedule {
1769
1798
  export { schedule_RELEASE_CATCH_UP_MINUTES as RELEASE_CATCH_UP_MINUTES, type schedule_ReleaseScheduleConfig as ReleaseScheduleConfig, type schedule_ScheduleConfig as ScheduleConfig, schedule_Scheduler as Scheduler, type schedule_SchedulerDeps as SchedulerDeps, schedule_daysInMonth as daysInMonth, schedule_isDue as isDue, schedule_isPeriodTriggerDay as isPeriodTriggerDay, schedule_isReleaseDue as isReleaseDue, schedule_isoWeekKey as isoWeekKey, schedule_nextOccurrence as nextOccurrence, schedule_nextOccurrenceFor as nextOccurrenceFor, schedule_nextReleaseOccurrence as nextReleaseOccurrence, schedule_parseClock as parseClock, schedule_zonedDateString as zonedDateString, schedule_zonedTimeToUtc as zonedTimeToUtc };
1770
1799
  }
1771
1800
 
1801
+ /**
1802
+ * 版本比较:只用于「核心是否足够新到支持某个 CLI flag」这类能力闸门。
1803
+ *
1804
+ * 核心的 `version --json` 只给 `x.y.z`(偶带预发布后缀),这里按三段数字比较,
1805
+ * 后缀忽略。不做完整 semver 区间——项目只需要「>= 阈值」这一种判断,够用且不易错。
1806
+ */
1807
+ /**
1808
+ * `a >= b` 时返回 true。任一方不可解析时返回 false(保守:当作「不满足」,
1809
+ * 让调用方降级为不带新 flag 的行为,避免向旧核心传未知参数)。
1810
+ */
1811
+ declare function versionAtLeast(a: string, b: string): boolean;
1812
+
1813
+ declare const version_versionAtLeast: typeof versionAtLeast;
1814
+ declare namespace version {
1815
+ export { version_versionAtLeast as versionAtLeast };
1816
+ }
1817
+
1772
1818
  /**
1773
1819
  * Host HTTP 面:`/api/morehao/github-trending/*`。
1774
1820
  *
@@ -1875,6 +1921,10 @@ declare function createTrendingRunTool(runner: Runner): {
1875
1921
  enum: string[];
1876
1922
  description: string;
1877
1923
  };
1924
+ force: {
1925
+ type: string;
1926
+ description: string;
1927
+ };
1878
1928
  };
1879
1929
  output: {
1880
1930
  schema: {
@@ -1893,6 +1943,9 @@ declare function createTrendingRunTool(runner: Runner): {
1893
1943
  readonly dryRun: {
1894
1944
  readonly type: "boolean";
1895
1945
  };
1946
+ readonly forced: {
1947
+ readonly type: "boolean";
1948
+ };
1896
1949
  readonly durationMs: {
1897
1950
  readonly type: "number";
1898
1951
  };
@@ -1943,6 +1996,7 @@ declare function createTrendingRunTool(runner: Runner): {
1943
1996
  dryRun?: boolean;
1944
1997
  date?: string;
1945
1998
  period?: string;
1999
+ force?: boolean;
1946
2000
  }, exec?: {
1947
2001
  signal?: AbortSignal;
1948
2002
  }): Promise<{
@@ -1952,6 +2006,9 @@ declare function createTrendingRunTool(runner: Runner): {
1952
2006
  errorHint?: string | undefined;
1953
2007
  warnings: string[];
1954
2008
  tokens: number;
2009
+ durationMs: number;
2010
+ files: number;
2011
+ forced?: boolean | undefined;
1955
2012
  ok: boolean;
1956
2013
  summaries: {
1957
2014
  errorCode?: string | undefined;
@@ -1960,19 +2017,18 @@ declare function createTrendingRunTool(runner: Runner): {
1960
2017
  branch?: string | undefined;
1961
2018
  releases?: ReleasesSummary | undefined;
1962
2019
  tokens?: number | undefined;
2020
+ durationMs: number;
2021
+ files: number;
2022
+ forced?: boolean | undefined;
1963
2023
  id: string;
1964
2024
  period: Period | undefined;
1965
2025
  ok: boolean;
1966
2026
  skipped: boolean;
1967
2027
  dryRun: boolean;
1968
- durationMs: number;
1969
- files: number;
1970
2028
  }[];
1971
2029
  id: string | undefined;
1972
2030
  skipped: boolean;
1973
2031
  dryRun: boolean;
1974
- durationMs: number;
1975
- files: number;
1976
2032
  } | {
1977
2033
  markdown: string;
1978
2034
  errorCode?: string | undefined;
@@ -1980,6 +2036,9 @@ declare function createTrendingRunTool(runner: Runner): {
1980
2036
  errorHint?: string | undefined;
1981
2037
  warnings: string[];
1982
2038
  tokens?: undefined;
2039
+ durationMs: number;
2040
+ files: number;
2041
+ forced?: boolean | undefined;
1983
2042
  ok: boolean;
1984
2043
  summaries: {
1985
2044
  errorCode?: string | undefined;
@@ -1988,19 +2047,18 @@ declare function createTrendingRunTool(runner: Runner): {
1988
2047
  branch?: string | undefined;
1989
2048
  releases?: ReleasesSummary | undefined;
1990
2049
  tokens?: number | undefined;
2050
+ durationMs: number;
2051
+ files: number;
2052
+ forced?: boolean | undefined;
1991
2053
  id: string;
1992
2054
  period: Period | undefined;
1993
2055
  ok: boolean;
1994
2056
  skipped: boolean;
1995
2057
  dryRun: boolean;
1996
- durationMs: number;
1997
- files: number;
1998
2058
  }[];
1999
2059
  id: string | undefined;
2000
2060
  skipped: boolean;
2001
2061
  dryRun: boolean;
2002
- durationMs: number;
2003
- files: number;
2004
2062
  }>;
2005
2063
  };
2006
2064
  declare function createTrendingHistoryTool(store: Store, scheduler: Scheduler): {
@@ -2104,4 +2162,4 @@ declare namespace tools {
2104
2162
  export { tools_createTrendingHistoryTool as createTrendingHistoryTool, tools_createTrendingRunTool as createTrendingRunTool };
2105
2163
  }
2106
2164
 
2107
- export { channel, config, core, credentials, errors, exec, github, handshake$1 as handshake, importCli, ipc, locate, paths, pendingPr, pluginInfo, preflight, proxy, quickfill, release, repo, routes, run, runner, schedule, state, subscribe, tools, update as updateService };
2165
+ export { channel, config, core, credentials, errors, exec, github, handshake$1 as handshake, importCli, ipc, locate, paths, pendingPr, pluginInfo, preflight, proxy, quickfill, release, repo, routes, run, runner, schedule, state, subscribe, tools, update as updateService, version };
package/lib/internal.js CHANGED
@@ -24,8 +24,9 @@ import {
24
24
  state_exports,
25
25
  subscribe_exports,
26
26
  tools_exports,
27
- update_exports
28
- } from "./chunk-WDBZAMWN.js";
27
+ update_exports,
28
+ version_exports
29
+ } from "./chunk-R3EDPRRO.js";
29
30
  import {
30
31
  exec_exports
31
32
  } from "./chunk-R7BK7SJK.js";
@@ -56,5 +57,6 @@ export {
56
57
  state_exports as state,
57
58
  subscribe_exports as subscribe,
58
59
  tools_exports as tools,
59
- update_exports as updateService
60
+ update_exports as updateService,
61
+ version_exports as version
60
62
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@morehao/dsh-github-trending",
3
- "version": "0.6.1",
3
+ "version": "0.7.1",
4
4
  "description": "GitHub 趋势日报插件:每天定时 spawn 本地 trendradar 核心,抓取 Trending、生成中文简介与总结,提交到你的仓库并自动合并 PR。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -51,7 +51,7 @@
51
51
  },
52
52
  "dependencies": {
53
53
  "@morehao/dsh-plugin-kit": "0.1.0",
54
- "@morehao/trendradar-contract": "0.4.0"
54
+ "@morehao/trendradar-contract": "0.5.0"
55
55
  },
56
56
  "dsh": {
57
57
  "bundle": {
@@ -59,7 +59,7 @@
59
59
  },
60
60
  "core": {
61
61
  "repo": "morehao/trendradar",
62
- "version": "0.7.0"
62
+ "version": "0.8.0"
63
63
  },
64
64
  "client": {
65
65
  "platform": "web",