stratagate-dsh 0.2.73 → 0.2.75

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/dist/plugin.js CHANGED
@@ -6042,11 +6042,68 @@ function workspaceDisplayName(cwd) {
6042
6042
  function feedbackText(value, maximum) {
6043
6043
  return typeof value === "string" ? value.trim().slice(0, maximum) : "";
6044
6044
  }
6045
+ var FEEDBACK_MARKDOWN_HEADINGS = {
6046
+ description: "\u95EE\u9898\u63CF\u8FF0",
6047
+ reproduction: "\u590D\u73B0\u6B65\u9AA4",
6048
+ expected: "\u9884\u671F\u884C\u4E3A",
6049
+ actual: "\u5B9E\u9645\u884C\u4E3A",
6050
+ errorContext: "\u76F8\u5173\u9519\u8BEF\u4FE1\u606F"
6051
+ };
6052
+ function patchFeedbackMarkdown(markdown, input) {
6053
+ let result = markdown.trim();
6054
+ for (const [key, heading] of Object.entries(FEEDBACK_MARKDOWN_HEADINGS)) {
6055
+ if (!Object.prototype.hasOwnProperty.call(input, key)) continue;
6056
+ const raw = input[key];
6057
+ const text3 = Array.isArray(raw) ? raw.map((item, index) => {
6058
+ const value = feedbackText(item, 2e3);
6059
+ return value ? `${index + 1}. ${value}` : "";
6060
+ }).filter(Boolean).join("\n") : feedbackText(raw, key === "description" ? 2e4 : key === "expected" || key === "actual" ? 1e4 : 2e4);
6061
+ const marker = `## ${heading}`;
6062
+ const lines = result.split("\n");
6063
+ let fence = null;
6064
+ let sectionStart = -1;
6065
+ let sectionEnd = lines.length;
6066
+ for (let index = 0; index < lines.length; index += 1) {
6067
+ const line = (lines[index] ?? "").replace(/\r$/, "");
6068
+ if (fence) {
6069
+ const closingFence = line.match(/^ {0,3}(`+|~+)[ \t]*$/);
6070
+ if (closingFence?.[1]?.[0] === fence.character && closingFence[1].length >= fence.length) fence = null;
6071
+ continue;
6072
+ }
6073
+ const openingFence = line.match(/^ {0,3}(`{3,}|~{3,})(.*)$/);
6074
+ if (openingFence?.[1] && (openingFence[1][0] === "~" || !openingFence[2]?.includes("`"))) {
6075
+ fence = { character: openingFence[1][0], length: openingFence[1].length };
6076
+ continue;
6077
+ }
6078
+ if (line === marker && sectionStart < 0) {
6079
+ sectionStart = index;
6080
+ continue;
6081
+ }
6082
+ if (sectionStart >= 0 && /^##\s+\S/.test(line)) {
6083
+ sectionEnd = index;
6084
+ break;
6085
+ }
6086
+ }
6087
+ if (sectionStart < 0) {
6088
+ if (text3) result = `${result ? `${result}
6089
+
6090
+ ` : ""}${marker}
6091
+
6092
+ ${text3}`;
6093
+ continue;
6094
+ }
6095
+ const replacement = text3 ? [marker, "", ...text3.split("\n")] : [];
6096
+ lines.splice(sectionStart, sectionEnd - sectionStart, ...replacement);
6097
+ result = lines.join("\n").trim();
6098
+ }
6099
+ return result.trim();
6100
+ }
6045
6101
  function normalizeFeedbackDraft(input, previous) {
6046
6102
  const has = (key) => Object.prototype.hasOwnProperty.call(input, key);
6047
6103
  const replacesStructuredBody = has("bodyMarkdown");
6104
+ const updatesStructuredBody = ["description", "reproduction", "expected", "actual", "errorContext"].some((key) => has(key));
6048
6105
  const reproduction = replacesStructuredBody ? [] : has("reproduction") ? (Array.isArray(input.reproduction) ? input.reproduction : []).map((value) => feedbackText(value, 2e3)).filter(Boolean).slice(0, 20) : previous?.reproduction ?? [];
6049
- const bodyMarkdown = has("bodyMarkdown") ? feedbackText(input.bodyMarkdown, 5e4) : previous?.bodyMarkdown;
6106
+ const bodyMarkdown = has("bodyMarkdown") ? feedbackText(input.bodyMarkdown, 5e4) : updatesStructuredBody && previous?.bodyMarkdown ? patchFeedbackMarkdown(previous.bodyMarkdown, input) : previous?.bodyMarkdown;
6050
6107
  return {
6051
6108
  title: has("title") ? feedbackText(input.title, 240) : previous?.title ?? "",
6052
6109
  description: replacesStructuredBody ? "" : has("description") ? feedbackText(input.description, 2e4) : previous?.description ?? "",
@@ -6704,7 +6761,8 @@ var StrataGateRuntime = class {
6704
6761
  }
6705
6762
  async prepareFeedback(session, input) {
6706
6763
  const namespace = this.namespaceFor(session);
6707
- const draft = normalizeFeedbackDraft(input);
6764
+ const previous = this.loadFeedbackDraft(namespace);
6765
+ const draft = normalizeFeedbackDraft(input, previous);
6708
6766
  this.saveFeedbackDraft(namespace, draft);
6709
6767
  const feedbackUrl = feedbackDraftUrl(namespace, this.feedbackOrigin());
6710
6768
  return {
@@ -8145,8 +8203,31 @@ function currentPluginVersion() {
8145
8203
  }
8146
8204
  var STRATAGATE_DSH_VERSION = currentPluginVersion();
8147
8205
  function graphProjectionIsProcessing(job) {
8148
- if (job.status === "running") return true;
8149
- return job.attempts < DERIVATION_MAX_ATTEMPTS && (job.status === "pending" || job.status === "failed" && job.nextRetryAt !== null);
8206
+ return derivationJobState(job, false) === "processing" || derivationJobState(job, false) === "retryable";
8207
+ }
8208
+ function derivationJobState(job, completed) {
8209
+ if (completed || job.status === "succeeded" || job.status === "skipped" || job.status === "completed") return "completed";
8210
+ if (job.status === "running") return "processing";
8211
+ if (job.status === "pending") return job.attempts < DERIVATION_MAX_ATTEMPTS ? "processing" : "blocked";
8212
+ if (job.status === "failed") {
8213
+ const retryable = job.attempts < DERIVATION_MAX_ATTEMPTS && job.nextRetryAt !== null && Number.isFinite(Date.parse(job.nextRetryAt));
8214
+ return retryable ? "retryable" : "terminal-failed";
8215
+ }
8216
+ return "blocked";
8217
+ }
8218
+ function summarizeDerivationJobs(jobs, completed) {
8219
+ const result = { processing: 0, retryable: 0, terminalFailed: 0, completed: 0, blocked: 0 };
8220
+ for (const job of jobs) {
8221
+ const state = derivationJobState(job, completed(job));
8222
+ if (state === "processing") result.processing += 1;
8223
+ else if (state === "retryable") {
8224
+ result.retryable += 1;
8225
+ result.processing += 1;
8226
+ } else if (state === "terminal-failed") result.terminalFailed += 1;
8227
+ else if (state === "completed") result.completed += 1;
8228
+ else result.blocked += 1;
8229
+ }
8230
+ return result;
8150
8231
  }
8151
8232
  function installedPackageVersion(names) {
8152
8233
  for (const name2 of names) {
@@ -8441,10 +8522,12 @@ async function overview(runtime, cachedEntries) {
8441
8522
  }] : [];
8442
8523
  });
8443
8524
  const describeBlockJob = (kind, job) => {
8525
+ const state = derivationJobState(job, kind === "block-summary" ? job.status === "succeeded" : job.status === "succeeded" || job.status === "skipped");
8444
8526
  const details = blockDetails([job.blockId]);
8445
8527
  return {
8446
8528
  id: job.blockId,
8447
8529
  kind,
8530
+ state,
8448
8531
  status: job.status,
8449
8532
  attempts: job.attempts,
8450
8533
  nextRetryAt: job.nextRetryAt,
@@ -8460,11 +8543,13 @@ async function overview(runtime, cachedEntries) {
8460
8543
  };
8461
8544
  };
8462
8545
  const describeGraphJob = (job) => {
8546
+ const state = derivationJobState(job, job.status === "completed");
8463
8547
  const blockIds = [...new Set(job.sourceEventIds.flatMap((eventId) => snapshot.events.find(({ id }) => id === eventId)?.sourceBlockId ?? []))];
8464
8548
  const details = blockDetails(blockIds);
8465
8549
  return {
8466
8550
  id: job.id,
8467
8551
  kind: "graph-projection",
8552
+ state,
8468
8553
  status: job.status,
8469
8554
  attempts: job.attempts,
8470
8555
  nextRetryAt: job.nextRetryAt,
@@ -8478,16 +8563,19 @@ async function overview(runtime, cachedEntries) {
8478
8563
  sourceEventIds: job.sourceEventIds
8479
8564
  };
8480
8565
  };
8481
- const failedJobs = snapshot.summaryJobs.filter(({ status }) => status === "failed").length + snapshot.extractionJobs.filter(({ status }) => status === "failed").length + snapshot.graphProjectionJobs.filter(({ status }) => status === "failed").length;
8482
- const processingJobs = snapshot.summaryJobs.filter(({ status, nextRetryAt }) => status === "pending" || status === "running" || status === "failed" && nextRetryAt !== null).length + snapshot.extractionJobs.filter(({ status, nextRetryAt }) => status === "running" || status === "failed" && nextRetryAt !== null).length + snapshot.graphProjectionJobs.filter(graphProjectionIsProcessing).length;
8566
+ const summaryStatus = summarizeDerivationJobs(snapshot.summaryJobs, (job) => job.status === "succeeded");
8567
+ const extractionStatus = summarizeDerivationJobs(snapshot.extractionJobs, (job) => job.status === "succeeded" || job.status === "skipped");
8568
+ const graphStatus = summarizeDerivationJobs(snapshot.graphProjectionJobs, (job) => job.status === "completed");
8569
+ const failedJobs = summaryStatus.terminalFailed + extractionStatus.terminalFailed + graphStatus.terminalFailed;
8570
+ const processingJobs = summaryStatus.processing + extractionStatus.processing + graphStatus.processing;
8483
8571
  const failedJobDetails = [
8484
8572
  ...snapshot.summaryJobs.filter(({ status }) => status === "failed").map((job) => describeBlockJob("block-summary", job)),
8485
8573
  ...snapshot.extractionJobs.filter(({ status }) => status === "failed").map((job) => describeBlockJob("event-extraction", job)),
8486
8574
  ...snapshot.graphProjectionJobs.filter(({ status }) => status === "failed").map(describeGraphJob)
8487
8575
  ];
8488
8576
  const processingJobDetails = [
8489
- ...snapshot.summaryJobs.filter(({ status, nextRetryAt }) => status === "pending" || status === "running" || status === "failed" && nextRetryAt !== null).map((job) => describeBlockJob("block-summary", job)),
8490
- ...snapshot.extractionJobs.filter(({ status, nextRetryAt }) => status === "running" || status === "failed" && nextRetryAt !== null).map((job) => describeBlockJob("event-extraction", job)),
8577
+ ...snapshot.summaryJobs.filter((job) => derivationJobState(job, job.status === "succeeded") === "processing" || derivationJobState(job, job.status === "succeeded") === "retryable").map((job) => describeBlockJob("block-summary", job)),
8578
+ ...snapshot.extractionJobs.filter((job) => derivationJobState(job, job.status === "succeeded" || job.status === "skipped") === "processing" || derivationJobState(job, job.status === "succeeded" || job.status === "skipped") === "retryable").map((job) => describeBlockJob("event-extraction", job)),
8491
8579
  ...snapshot.graphProjectionJobs.filter(graphProjectionIsProcessing).map(describeGraphJob)
8492
8580
  ];
8493
8581
  const timestamps = [
@@ -8511,12 +8599,27 @@ async function overview(runtime, cachedEntries) {
8511
8599
  elements: snapshot.elements.length,
8512
8600
  graphNodes: snapshot.graphNodes.length,
8513
8601
  graphEdges: snapshot.graphEdges.length,
8602
+ taskStatus: {
8603
+ blockSummary: summaryStatus,
8604
+ eventExtraction: extractionStatus,
8605
+ graphProjection: graphStatus
8606
+ },
8514
8607
  graphMigration: (() => {
8515
8608
  const projected = new Set(snapshot.graphProjectionJobs.filter(({ status, projectorVersion }) => status === "completed" && projectorVersion === KNOWLEDGE_GRAPH_PROJECTOR_VERSION).flatMap(({ sourceEventIds }) => sourceEventIds)).size;
8516
- const failed = snapshot.graphProjectionJobs.filter(({ status }) => status === "failed").length;
8517
- const running = snapshot.graphProjectionJobs.filter(({ status }) => status === "running").length;
8518
8609
  const total = snapshot.events.filter(({ status }) => status !== "forgotten" && status !== "archived").length;
8519
- return { projected, total, failed, running, complete: projected >= total };
8610
+ const complete = projected >= total;
8611
+ const state = complete ? "complete" : graphStatus.processing > 0 ? "processing" : graphStatus.terminalFailed > 0 ? "failed" : "incomplete";
8612
+ return {
8613
+ projected,
8614
+ total,
8615
+ pending: snapshot.graphProjectionJobs.filter(({ status }) => status === "pending").length,
8616
+ running: snapshot.graphProjectionJobs.filter(({ status }) => status === "running").length,
8617
+ failed: graphStatus.terminalFailed,
8618
+ retryable: graphStatus.retryable,
8619
+ processing: graphStatus.processing,
8620
+ state,
8621
+ complete
8622
+ };
8520
8623
  })(),
8521
8624
  usageReceipts: snapshot.usageReceipts.length,
8522
8625
  memoryUseCount: snapshot.usageReceipts.filter((receipt) => receipt.eventIds.length > 0 || receipt.elementIds.length > 0).length,
@@ -8855,13 +8958,19 @@ async function memories(runtime, url) {
8855
8958
  clusters: clusterKnowledgeGraph(snapshot.graphNodes, snapshot.graphEdges),
8856
8959
  migration: (() => {
8857
8960
  const projected = new Set(snapshot.graphProjectionJobs.filter(({ status, projectorVersion }) => status === "completed" && projectorVersion === KNOWLEDGE_GRAPH_PROJECTOR_VERSION).flatMap(({ sourceEventIds }) => sourceEventIds)).size;
8961
+ const graphStatus = summarizeDerivationJobs(snapshot.graphProjectionJobs, (job) => job.status === "completed");
8962
+ const total = snapshot.events.filter(({ status }) => status !== "forgotten" && status !== "archived").length;
8963
+ const complete = projected >= total;
8858
8964
  return {
8859
8965
  projected,
8860
- total: snapshot.events.filter(({ status }) => status !== "forgotten" && status !== "archived").length,
8966
+ total,
8861
8967
  pending: snapshot.graphProjectionJobs.filter(({ status }) => status === "pending").length,
8862
8968
  running: snapshot.graphProjectionJobs.filter(({ status }) => status === "running").length,
8863
- failed: snapshot.graphProjectionJobs.filter(({ status }) => status === "failed").length,
8864
- complete: projected >= snapshot.events.filter(({ status }) => status !== "forgotten" && status !== "archived").length
8969
+ failed: graphStatus.terminalFailed,
8970
+ retryable: graphStatus.retryable,
8971
+ processing: graphStatus.processing,
8972
+ state: complete ? "complete" : graphStatus.processing > 0 ? "processing" : graphStatus.terminalFailed > 0 ? "failed" : "incomplete",
8973
+ complete
8865
8974
  };
8866
8975
  })()
8867
8976
  };