dsh-github-copilot 0.4.0-alpha.82 → 0.4.0-alpha.83

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/lib/index.js CHANGED
@@ -1847,7 +1847,7 @@ function installContextEvidence(ctx) {
1847
1847
  //#endregion
1848
1848
  //#region package.json
1849
1849
  var name$1 = "dsh-github-copilot";
1850
- var version = "0.4.0-alpha.82";
1850
+ var version = "0.4.0-alpha.83";
1851
1851
  //#endregion
1852
1852
  //#region lib/types/probe.js
1853
1853
  /**
@@ -6790,22 +6790,51 @@ function user(message) {
6790
6790
  if (record$2(message.source) && message.source.kind === "model-selection") return false;
6791
6791
  return message.role === "user" || record$2(message.source) && message.source.kind === "user";
6792
6792
  }
6793
+ function difficult(current) {
6794
+ return /\b(prove|proof|theorem|debug|investigate|diagnose)\b|证明|定理|调试|排查|根因|调查/iu.test(current);
6795
+ }
6796
+ function continuation(current) {
6797
+ return /^(continue|please continue|go on|yes|ok|okay|继续|接着|嗯|好|好的|可以|执行吧|开始吧)[.!!。,,\s]*$/iu.test(current);
6798
+ }
6799
+ function boundedTransformation(current) {
6800
+ if (current.length > 1600) return false;
6801
+ const match = /^(?:convert the following (?:JSON to CSV|CSV to JSON)|sort the following lines|将以下 (?:JSON 转换为 CSV|CSV 转换为 JSON)|对以下行排序)[::][ \t]*\r?\n```[a-z]*\r?\n([\s\S]+)\r?\n```[ \t]*$/iu.exec(current);
6802
+ return match !== null && typeof match[1] === "string" && !match[1].includes("```");
6803
+ }
6793
6804
  function assessTaskLocally(messages) {
6794
6805
  const last = messages.findLast(user);
6795
6806
  const current = text(last).trim();
6796
- const hasWork = messages.slice(0, last === void 0 ? 0 : messages.lastIndexOf(last)).some((message) => record$2(message) && (message.role === "assistant" || message.role === "tool" || user(message) || record$2(message.source) && message.source.kind === "model"));
6807
+ const history = messages.slice(0, last === void 0 ? 0 : messages.lastIndexOf(last));
6808
+ const hasWork = history.some((message) => record$2(message) && (message.role === "assistant" || message.role === "tool" || user(message) || record$2(message.source) && message.source.kind === "model"));
6797
6809
  const nonText = record$2(last) && Array.isArray(last.content) && last.content.some((block) => !record$2(block) || block.type !== "text");
6798
6810
  if (!hasWork && !nonText && /^(hello|hi|hey|你好|您好|嗨)[!!。.\s]*$/iu.test(current)) return {
6799
6811
  demand: "simple",
6800
6812
  source: "local",
6801
6813
  signals: ["isolated-greeting"]
6802
6814
  };
6803
- if (/\b(prove|proof|theorem|debug|investigate|diagnose)\b|证明|定理|调试|排查|根因|调查/iu.test(current)) return {
6815
+ if (difficult(current)) return {
6804
6816
  demand: "complex",
6805
6817
  source: "local",
6806
6818
  signals: ["reasoning", "investigation"]
6807
6819
  };
6808
- if (/^(continue|go on|继续|接着)[.!!。\s]*$/iu.test(current) || hasWork && current.length < 80) return {
6820
+ if (!hasWork && !nonText && boundedTransformation(current)) return {
6821
+ demand: "routine",
6822
+ source: "local",
6823
+ signals: ["bounded-transformation"]
6824
+ };
6825
+ if (continuation(current)) {
6826
+ const anchor = history.filter(user).slice(-12).findLast((message) => !continuation(text(message).trim()));
6827
+ if (anchor && difficult(text(anchor))) return {
6828
+ demand: "complex",
6829
+ source: "local",
6830
+ signals: [
6831
+ "continuation",
6832
+ "reasoning",
6833
+ "investigation"
6834
+ ]
6835
+ };
6836
+ }
6837
+ if (continuation(current) || hasWork && current.length < 80) return {
6809
6838
  demand: "unknown",
6810
6839
  source: "local",
6811
6840
  signals: ["continuation", "insufficient-evidence"]
@@ -6820,11 +6849,20 @@ function assessTaskLocally(messages) {
6820
6849
  function assessmentInput(messages) {
6821
6850
  let omitted = false;
6822
6851
  const context = messages.filter((message) => !record$2(message) || message.role !== "system" && message.role !== "developer" && !(record$2(message.source) && message.source.kind === "model-selection"));
6823
- if (context.length > 12) omitted = true;
6824
- const serialized = context.slice(-12).map((message) => {
6852
+ const lastUser = context.findLastIndex(user);
6853
+ const priorUser = context.slice(0, lastUser < 0 ? 0 : lastUser).findLastIndex(user);
6854
+ const priority = [.../* @__PURE__ */ new Set([
6855
+ lastUser,
6856
+ priorUser,
6857
+ ...context.map((_, index) => index).reverse()
6858
+ ])].filter((index) => index >= 0);
6859
+ const rows = /* @__PURE__ */ new Map();
6860
+ let length = 0;
6861
+ for (const index of priority) {
6862
+ const message = context[index];
6825
6863
  if (!record$2(message)) {
6826
6864
  omitted = true;
6827
- return "";
6865
+ continue;
6828
6866
  }
6829
6867
  if (!Array.isArray(message.content)) omitted = true;
6830
6868
  const content = text(message);
@@ -6836,14 +6874,29 @@ function assessmentInput(messages) {
6836
6874
  "tool",
6837
6875
  "developer"
6838
6876
  ].includes(message.role) ? message.role : user(message) ? "user" : "context";
6839
- return JSON.stringify({
6877
+ let prefix = content.slice(0, 1600);
6878
+ let row = JSON.stringify({
6840
6879
  role,
6841
- text: content.slice(0, 1600)
6880
+ text: prefix
6842
6881
  });
6843
- }).join("\n");
6844
- if (serialized.length > 8e3) omitted = true;
6882
+ while (row.length > 8e3) {
6883
+ omitted = true;
6884
+ prefix = prefix.slice(0, Math.floor(prefix.length / 2));
6885
+ row = JSON.stringify({
6886
+ role,
6887
+ text: prefix
6888
+ });
6889
+ }
6890
+ const added = row.length + (rows.size ? 1 : 0);
6891
+ if (rows.size >= 12 || length + added > 8e3) {
6892
+ omitted = true;
6893
+ continue;
6894
+ }
6895
+ rows.set(index, row);
6896
+ length += added;
6897
+ }
6845
6898
  return {
6846
- text: serialized.slice(-8e3),
6899
+ text: [...rows].sort(([left], [right]) => left - right).map(([, row]) => row).join("\n"),
6847
6900
  omitted
6848
6901
  };
6849
6902
  }
@@ -6858,7 +6911,7 @@ var TaskAssessmentRevokedError = class extends Error {
6858
6911
  async function assessAutoTask(messages, dependencies) {
6859
6912
  const local = assessTaskLocally(messages);
6860
6913
  if (dependencies.signal.aborted) throw dependencies.signal.reason;
6861
- if (local.demand === "simple") return local;
6914
+ if (local.demand !== "unknown") return local;
6862
6915
  if (!dependencies.enabled) return {
6863
6916
  ...local,
6864
6917
  diagnostic: "disabled"
@@ -6901,13 +6954,6 @@ async function assessAutoTask(messages, dependencies) {
6901
6954
  diagnostic: "context-omitted"
6902
6955
  };
6903
6956
  }
6904
- if (local.demand === "complex" && parsed.data.demand !== "complex") {
6905
- dependencies.diagnostic("COPILOT_AUTO_ASSESSMENT_INVALID_RESULT");
6906
- return {
6907
- ...local,
6908
- diagnostic: "invalid-result"
6909
- };
6910
- }
6911
6957
  return {
6912
6958
  ...parsed.data,
6913
6959
  source: "semantic"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-github-copilot",
3
3
  "description": "DSH companion for GitHub Copilot sign-in, account-aware model profiles, tool compatibility, and provider-hosted search.",
4
- "version": "0.4.0-alpha.82",
4
+ "version": "0.4.0-alpha.83",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "registry": "https://registry.npmjs.org/",