dsh-multigameassistant 2.3.0 → 2.3.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.
@@ -35,13 +35,13 @@ import {
35
35
  parseJsonc,
36
36
  parseManifest,
37
37
  versionOfTag
38
- } from "./chunk-TXW3NMBH.js";
38
+ } from "./chunk-C7X2KJ5C.js";
39
39
  import {
40
40
  sessionConversations
41
- } from "./chunk-VG32XPZH.js";
41
+ } from "./chunk-4QXRDWGS.js";
42
42
  import {
43
43
  pluginVersion
44
- } from "./chunk-VBWSM7LF.js";
44
+ } from "./chunk-QSETYM2Y.js";
45
45
  import {
46
46
  ExeIcons,
47
47
  writeFileAtomic
@@ -64,7 +64,7 @@ import {
64
64
  optimizeScriptPrompt,
65
65
  parseGitHubLink,
66
66
  taskMessage
67
- } from "./chunk-7EFZ5KR6.js";
67
+ } from "./chunk-34VNH3YS.js";
68
68
  import {
69
69
  NEVER,
70
70
  ZodIssueCode,
@@ -606,6 +606,7 @@ var SCRIPT_ROLE = {
606
606
  id: "scripts",
607
607
  name: "\u811A\u672C",
608
608
  description: "\u5B89\u88C5\u548C\u4ECB\u7ECD\u811A\u672C\u3001\u68C0\u67E5\u811A\u672C\u5305\u3001\u5408\u5E76\u6280\u80FD",
609
+ handles: "\u811A\u672C\u7684\u4E8B\u90FD\u4EA4\u7ED9\u5B83\uFF1A\u5B89\u88C5\u3001\u66F4\u65B0\u3001\u4ECB\u7ECD\u811A\u672C\uFF1B\u6E38\u620F\u91CC\u8981\u505A\u7684\u4E8B\u6709\u811A\u672C\u80FD\u505A\u65F6\uFF0C\u7528\u90A3\u4E2A\u811A\u672C\u7684\u4EFB\u52A1\u53BB\u505A\uFF08\u8FD0\u884C\u3001\u505C\u6B62\u3001\u770B\u8FD0\u884C\u7ED3\u679C\uFF09\uFF1B\u6539\u811A\u672C\u8BBE\u7F6E\u3001\u4FEE\u8FD0\u884C\u73AF\u5883\uFF1B\u5206\u6790\u811A\u672C\u3001\u5199\u548C\u6539\u811A\u672C\u5305\uFF1B\u5B89\u88C5\u3001\u5408\u5E76\u6280\u80FD\uFF1B\u6309\u811A\u672C\u6DFB\u52A0\u65E5\u5E38\u5468\u5E38\u3002\u4E0D\u8BFB\u6E38\u620F\u6D3B\u52A8\u3001\u4E0D\u6539\u6D41\u6C34\u7EBF\u3002",
609
610
  order: 30,
610
611
  titles: ["\u5B89\u88C5\u811A\u672C", "\u811A\u672C\u4ECB\u7ECD", "\u68C0\u67E5\u811A\u672C\u5305", "\u5408\u5E76\u6280\u80FD"],
611
612
  // Scripts, their packs and environment, skills; the screen for setup programs. No game reading or pipelines.
@@ -2986,7 +2987,7 @@ function packReview(ctx, library, log) {
2986
2987
  `\u300C${script.name}\u300D\uFF08\u811A\u672C id ${id}\uFF09\u4ECE ${from} \u66F4\u65B0\u5230\u4E86 ${to}\uFF0C\u5B83\u7684\u811A\u672C\u5305 ${script.packId ?? ""} \u662F\u6309 ${from} \u5199\u7684\u3002`,
2987
2988
  "\u8BF7\u6309\u6280\u80FD script-analysis \u91CC\u300C\u811A\u672C\u66F4\u65B0\u540E\u68C0\u67E5\u811A\u672C\u5305\u300D\u7684\u6B65\u9AA4\u505A\uFF1A",
2988
2989
  `1. \u5148\u7528 script_changelog\uFF08id=${id}\uFF09\u8BFB\u8FD9\u51E0\u4E2A\u7248\u672C\u7684\u66F4\u65B0\u65E5\u5FD7\uFF0C\u6311\u51FA\u53EF\u80FD\u5F71\u54CD\u811A\u672C\u5305\u7684\u6539\u52A8\uFF08\u4EFB\u52A1\u3001\u53C2\u6570\u3001\u914D\u7F6E\u6587\u4EF6\u548C\u952E\u3001\u542F\u52A8\u65B9\u5F0F\u3001\u65E5\u5FD7\u91CC\u7684\u5B8C\u6210\u548C\u51FA\u9519\u6587\u5B57\u3001\u8FD0\u884C\u73AF\u5883\uFF09\uFF1B`,
2989
- "2. \u53EA\u9488\u5BF9\u8FD9\u4E9B\u6539\u52A8\u6838\u5BF9\u65B0\u7248\u672C\u7684\u6587\u4EF6\uFF0C\u66F4\u65B0\u65E5\u5FD7\u6CA1\u5199\u6E05\u695A\u7684\u518D\u770B\u4EE3\u7801\uFF1B",
2990
+ "2. \u53EA\u9488\u5BF9\u8FD9\u4E9B\u6539\u52A8\u6838\u5BF9\u65B0\u7248\u672C\u7684\u6587\u4EF6\uFF0C\u66F4\u65B0\u65E5\u5FD7\u6CA1\u5199\u6E05\u695A\u7684\u518D\u770B\u4EE3\u7801\uFF1B\u754C\u9762\u4E0A\u7684\u6539\u52A8\uFF08\u529F\u80FD\u632A\u4E86\u4F4D\u7F6E\u3001\u9009\u9879\u6539\u4E86\u540D\uFF09\u53EF\u4EE5\u6253\u5F00\u811A\u672C\u7A0B\u5E8F\u770B\uFF1Ascript_settings \u6253\u5F00\u8BBE\u7F6E\u754C\u9762\uFF08\u547D\u4EE4\u884C\u811A\u672C\u7528 script_help\uFF09\uFF0Cwindow_list \u627E\u7A97\u53E3\uFF0Cscreen_capture\uFF08target=window\uFF09\u622A\u56FE\u5BF9\u7167\uFF0C\u770B\u5B8C\u7528 script_stop \u5173\u6389\uFF1B\u4E0D\u8981\u8DD1\u4EFB\u52A1\u3001\u4E0D\u8981\u6539\u914D\u7F6E\uFF1B",
2990
2991
  "3. \u8981\u6539\u5C31\u7528\u539F\u6765\u7684\u811A\u672C\u5305 id \u8C03\u7528 pack_propose \u4FDD\u5B58\uFF08\u76F4\u63A5\u751F\u6548\uFF1Bsummary \u5199\u660E\u4F9D\u636E\u66F4\u65B0\u65E5\u5FD7\u6539\u4E86\u4EC0\u4E48\uFF09\uFF1B\u4E0D\u7528\u6539\u5C31\u8C03\u7528 pack_reviewed \u8BF4\u660E\u7406\u7531\uFF1B",
2991
2992
  "4. \u6700\u540E\u7528\u4E24\u4E09\u53E5\u8BDD\u544A\u8BC9\u7528\u6237\u7ED3\u8BBA\u3002"
2992
2993
  ].join("\n");
@@ -22481,7 +22482,7 @@ function mcpTools(library, integrations, approve) {
22481
22482
  }),
22482
22483
  tool2({
22483
22484
  name: MCP_TOOL_NAMES.skills,
22484
- description: "\u5217\u51FA\u811A\u672C\u81EA\u5DF1\u5E26\u7684\u6280\u80FD\uFF08\u811A\u672C\u76EE\u5F55\u91CC skills/\u3001.claude/skills/\u3001.agents/skills/ \u7B49\u5904\u7684 SKILL.md\uFF09\uFF0C\u4EE5\u53CA\u54EA\u4E9B\u5DF2\u7ECF\u653E\u8FDB\u4E86\u672C\u8F6F\u4EF6\u7684\u6280\u80FD\u5E93\uFF08\u300C\u6280\u80FD\u300D\u9875\uFF0C\u53EA\u5728\u5904\u7406\u8FD9\u4E2A\u811A\u672C\u65F6\u53EF\u89C1\uFF09\u3002",
22485
+ description: "\u5217\u51FA\u811A\u672C\u81EA\u5DF1\u5E26\u7684\u6280\u80FD\uFF08\u811A\u672C\u76EE\u5F55\u91CC skills/\u3001.claude/skills/\u3001.agents/skills/\u3001assets/agent/skills/ \u7B49\u5904\u7684 SKILL.md\uFF09\uFF0C\u4EE5\u53CA\u54EA\u4E9B\u5DF2\u7ECF\u653E\u8FDB\u4E86\u672C\u8F6F\u4EF6\u7684\u6280\u80FD\u5E93\uFF08\u300C\u6280\u80FD\u300D\u9875\uFF0C\u53EA\u5728\u5904\u7406\u8FD9\u4E2A\u811A\u672C\u65F6\u53EF\u89C1\uFF09\u3002\u8F6F\u4EF6\u627E\u5230\u6280\u80FD\u5C31\u4F1A\u81EA\u52A8\u653E\u8FDB\u53BB\uFF1B\u7528\u6237\u5728\u300C\u6280\u80FD\u300D\u9875\u5220\u6389\u7684\u4E0D\u4F1A\u81EA\u52A8\u653E\u56DE\u3002",
22485
22486
  properties: { id },
22486
22487
  required: ["id"],
22487
22488
  kind: "read",
@@ -22494,7 +22495,7 @@ function mcpTools(library, integrations, approve) {
22494
22495
  }),
22495
22496
  tool2({
22496
22497
  name: MCP_TOOL_NAMES.importSkills,
22497
- description: "\u628A\u811A\u672C\u81EA\u5E26\u7684\u6280\u80FD\u653E\u8FDB\u672C\u8F6F\u4EF6\u7684\u6280\u80FD\u5E93\uFF08\u300C\u6280\u80FD\u300D\u9875\uFF09\uFF1A\u590D\u5236\u6574\u4E2A\u6280\u80FD\u6587\u4EF6\u5939\uFF0C\u5F52\u5230\u8FD9\u4E2A\u811A\u672C\u4E0B\uFF0C\u53EA\u6709\u5904\u7406\u8FD9\u4E2A\u811A\u672C\u7684\u4F1A\u8BDD\u80FD\u770B\u5230\u548C\u8C03\u7528\u3002\u518D\u6B21\u5BFC\u5165\u4F1A\u7528\u811A\u672C\u91CC\u73B0\u5728\u7684\u7248\u672C\u66FF\u6362\uFF1B\u811A\u672C\u66F4\u65B0\u540E\uFF0C\u6280\u80FD\u6587\u4EF6\u5939\u6709\u53D8\u5316\u3001\u4E14\u5728\u8FD9\u91CC\u6CA1\u88AB\u6539\u8FC7\u7684\u4F1A\u81EA\u52A8\u91CD\u65B0\u5BFC\u5165\u3002",
22498
+ description: "\u628A\u811A\u672C\u81EA\u5E26\u7684\u6280\u80FD\u653E\u8FDB\u672C\u8F6F\u4EF6\u7684\u6280\u80FD\u5E93\uFF08\u300C\u6280\u80FD\u300D\u9875\uFF09\uFF1A\u590D\u5236\u6574\u4E2A\u6280\u80FD\u6587\u4EF6\u5939\uFF0C\u5F52\u5230\u8FD9\u4E2A\u811A\u672C\u4E0B\uFF0C\u53EA\u6709\u5904\u7406\u8FD9\u4E2A\u811A\u672C\u7684\u4F1A\u8BDD\u80FD\u770B\u5230\u548C\u8C03\u7528\u3002\u7528\u6237\u6216\u811A\u672C\u7684\u8BF4\u660E\u8BA9\u4F60\u628A\u5B83\u7684\u6280\u80FD\u590D\u5236\u5230\u300C\u4F60\u7684\u7528\u6237\u7EA7\u6280\u80FD\u76EE\u5F55\u300D\uFF08~/.agents/skills\u3001~/.claude/skills \u4E4B\u7C7B\uFF09\u65F6\uFF0C\u5C31\u7528\u8FD9\u4E2A\u3002\u518D\u6B21\u5BFC\u5165\u4F1A\u7528\u811A\u672C\u91CC\u73B0\u5728\u7684\u7248\u672C\u66FF\u6362\uFF1B\u811A\u672C\u66F4\u65B0\u540E\uFF0C\u6280\u80FD\u6587\u4EF6\u5939\u6709\u53D8\u5316\u3001\u4E14\u5728\u8FD9\u91CC\u6CA1\u88AB\u6539\u8FC7\u7684\u4F1A\u81EA\u52A8\u91CD\u65B0\u5BFC\u5165\u3002",
22498
22499
  properties: {
22499
22500
  id,
22500
22501
  names: { type: "array", items: { type: "string" }, description: "\u8981\u5BFC\u5165\u7684\u6280\u80FD\u540D\u6216\u8DEF\u5F84\uFF08script_skills \u5217\u51FA\u7684\uFF09\uFF1B\u7701\u7565\u5BFC\u5165\u5168\u90E8\u3002" }
@@ -22511,6 +22512,10 @@ function mcpTools(library, integrations, approve) {
22511
22512
  ];
22512
22513
  }
22513
22514
 
22515
+ // packages/script-registry/lib/script-integrations.js
22516
+ import { mkdir as mkdir4, readFile as readFile7 } from "node:fs/promises";
22517
+ import { dirname as dirname4 } from "node:path";
22518
+
22514
22519
  // packages/script-registry/lib/script-skills.js
22515
22520
  import { createHash as createHash3 } from "node:crypto";
22516
22521
  import { readdir as readdir4, readFile as readFile6, stat as stat3 } from "node:fs/promises";
@@ -22553,9 +22558,30 @@ async function discoverSkills(scriptDir) {
22553
22558
  for (const rel of await skillFolders(scriptDir, place, 3))
22554
22559
  await add(rel, false);
22555
22560
  }
22561
+ for (const place of await skillsDirs(scriptDir, "", 3)) {
22562
+ if (SKILL_PLACES.includes(place))
22563
+ continue;
22564
+ for (const rel of await skillFolders(scriptDir, place, 3))
22565
+ await add(rel, false);
22566
+ }
22556
22567
  await add("", true);
22557
22568
  return out;
22558
22569
  }
22570
+ var NOT_THE_SCRIPTS = /* @__PURE__ */ new Set(["node_modules", ".git", "__pycache__", "site-packages", "dist-packages", "lib", "libs", "venv", ".venv", "env", "python", "runtime", "logs", "log", "cache", "temp", "tmp"]);
22571
+ async function skillsDirs(root, sub, depth) {
22572
+ const entries = await readdir4(sub === "" ? root : join7(root, ...sub.split("/")), { withFileTypes: true }).catch(() => []);
22573
+ const out = [];
22574
+ for (const entry of entries) {
22575
+ if (!entry.isDirectory() || NOT_THE_SCRIPTS.has(entry.name.toLowerCase()))
22576
+ continue;
22577
+ const rel = sub === "" ? entry.name : `${sub}/${entry.name}`;
22578
+ if (entry.name === "skills" || entry.name === ".skills")
22579
+ out.push(rel);
22580
+ else if (depth > 1)
22581
+ out.push(...await skillsDirs(root, rel, depth - 1));
22582
+ }
22583
+ return out;
22584
+ }
22559
22585
  async function skillFolders(root, sub, depth) {
22560
22586
  const entries = await readdir4(join7(root, ...sub.split("/")), { withFileTypes: true }).catch(() => []);
22561
22587
  if (entries.some((e) => e.isFile() && e.name === SKILL_FILE3))
@@ -22602,11 +22628,16 @@ var ScriptIntegrations = class {
22602
22628
  #library;
22603
22629
  #keeper;
22604
22630
  #log;
22605
- constructor(library, mcp, keeper, log) {
22631
+ /** The script skills put in once (`<script>\0<path>`): one the user takes out again is not brought back. */
22632
+ #seenFile;
22633
+ #seen;
22634
+ #auto = Promise.resolve();
22635
+ constructor(library, mcp, keeper, log, options = {}) {
22606
22636
  this.#library = library;
22607
22637
  this.mcp = mcp;
22608
22638
  this.#keeper = keeper;
22609
22639
  this.#log = log;
22640
+ this.#seenFile = options.seenFile;
22610
22641
  }
22611
22642
  #installed(id) {
22612
22643
  const script = this.#library.get(id);
@@ -22698,7 +22729,7 @@ var ScriptIntegrations = class {
22698
22729
  description: skill.description,
22699
22730
  path: skill.path,
22700
22731
  ...skill.problem === void 0 ? {} : { problem: skill.problem },
22701
- ...copy === void 0 ? {} : { imported: { name: copy.name, current: copy.origin["hash"] === skill.hash, changed: copy.changed } }
22732
+ ...copy === void 0 ? {} : { imported: { name: copy.name, current: copy.origin["hash"] === skill.hash, changed: copy.changed, ...copy.origin["auto"] === true ? { auto: true } : {} } }
22702
22733
  };
22703
22734
  });
22704
22735
  }
@@ -22767,6 +22798,78 @@ var ScriptIntegrations = class {
22767
22798
  this.#log.info(`skills taken again after ${id} changed: ${again.join(", ")}`);
22768
22799
  return again;
22769
22800
  }
22801
+ /**
22802
+ * Put a script's skills among this app's skills as soon as they are found
22803
+ * (installed, imported, updated, or already there when the app starts):
22804
+ * each belongs to the script, like 放进技能库 on the 脚本 page. Each is put
22805
+ * in once; one the user removed from the 技能 page stays out until taken by hand.
22806
+ * @returns the names put in.
22807
+ */
22808
+ autoImportSkills(id) {
22809
+ const next = this.#auto.then(() => this.#autoImport(id));
22810
+ this.#auto = next.catch(() => void 0);
22811
+ return next;
22812
+ }
22813
+ async #autoImport(id) {
22814
+ const keeper = this.#keeper();
22815
+ if (keeper === void 0)
22816
+ return [];
22817
+ let script;
22818
+ try {
22819
+ script = this.#installed(id);
22820
+ } catch {
22821
+ return [];
22822
+ }
22823
+ const found = (await discoverSkills(script.dir)).filter((s) => s.problem === void 0);
22824
+ if (found.length === 0)
22825
+ return [];
22826
+ const seen = await this.#seenSet();
22827
+ const key = (skill) => `${id}\0${skill.path}`;
22828
+ const imported = await keeper.importedSkills().catch(() => []);
22829
+ const here = (skill) => imported.some((item) => item.origin.kind === "script" && item.origin["script"] === id && item.origin["path"] === skill.path);
22830
+ const names = [];
22831
+ let grew = false;
22832
+ for (const skill of found) {
22833
+ if (seen.has(key(skill)))
22834
+ continue;
22835
+ if (!here(skill)) {
22836
+ try {
22837
+ const input = this.#importInput(script, skill);
22838
+ names.push((await keeper.importSkill({ ...input, origin: { ...input.origin, auto: true } })).name);
22839
+ } catch (error) {
22840
+ this.#log.warn(`skill ${skill.name} of ${id} not put in: ${error instanceof Error ? error.message : String(error)}`);
22841
+ continue;
22842
+ }
22843
+ }
22844
+ seen.add(key(skill));
22845
+ grew = true;
22846
+ }
22847
+ if (grew)
22848
+ await this.#saveSeen(seen);
22849
+ if (names.length > 0)
22850
+ this.#log.info(`skills of ${id} put in the skill library: ${names.join(", ")}`);
22851
+ return names;
22852
+ }
22853
+ #seenSet() {
22854
+ this.#seen ??= (async () => {
22855
+ if (this.#seenFile === void 0)
22856
+ return /* @__PURE__ */ new Set();
22857
+ try {
22858
+ const saved = JSON.parse(await readFile7(this.#seenFile, "utf8"));
22859
+ return new Set(Array.isArray(saved) ? saved.filter((v) => typeof v === "string") : []);
22860
+ } catch {
22861
+ return /* @__PURE__ */ new Set();
22862
+ }
22863
+ })();
22864
+ return this.#seen;
22865
+ }
22866
+ async #saveSeen(seen) {
22867
+ if (this.#seenFile === void 0)
22868
+ return;
22869
+ await mkdir4(dirname4(this.#seenFile), { recursive: true });
22870
+ await writeFileAtomic(this.#seenFile, `${JSON.stringify([...seen].sort(), null, 1)}
22871
+ `);
22872
+ }
22770
22873
  #importInput(script, skill) {
22771
22874
  const pack = this.#library.packOf(script.id);
22772
22875
  return {
@@ -22820,7 +22923,7 @@ var AdgScripts = class extends Service {
22820
22923
  clearTimeout(syncing.get(id));
22821
22924
  const timer = setTimeout(() => {
22822
22925
  syncing.delete(id);
22823
- void this.ready.then(() => this.integrations.syncSkills(id)).then((names) => {
22926
+ void this.ready.then(async () => [...await this.integrations.syncSkills(id), ...await this.integrations.autoImportSkills(id)]).then((names) => {
22824
22927
  if (names.length > 0)
22825
22928
  ctx.get("adgGateway")?.broadcast("skills/changed", {});
22826
22929
  }, (error) => log.warn(`skills of ${id} not synced: ${error instanceof Error ? error.message : String(error)}`));
@@ -22858,7 +22961,7 @@ var AdgScripts = class extends Service {
22858
22961
  log: { info: (message2) => log.info(message2), warn: (message2) => log.warn(message2) }
22859
22962
  });
22860
22963
  const library = this.library;
22861
- this.integrations = new ScriptIntegrations(library, new ScriptMcp({ dataDir: spec.dataDir, log: { info: (message2) => log.info(message2), warn: (message2) => log.warn(message2) } }), () => ctx.get("adgGateway"), { info: (message2) => log.info(message2), warn: (message2) => log.warn(message2) });
22964
+ this.integrations = new ScriptIntegrations(library, new ScriptMcp({ dataDir: spec.dataDir, log: { info: (message2) => log.info(message2), warn: (message2) => log.warn(message2) } }), () => ctx.get("adgGateway"), { info: (message2) => log.info(message2), warn: (message2) => log.warn(message2) }, { seenFile: join8(spec.dataDir, "script-skills.json") });
22862
22965
  const integrations = this.integrations;
22863
22966
  ctx.effect(() => () => void integrations.mcp.dispose(), "adg-scripts MCP connections");
22864
22967
  this.ready = library.start();
@@ -22905,6 +23008,15 @@ var AdgScripts = class extends Service {
22905
23008
  const summaries = scriptSummaries(ctx, library, { warn: (message2) => log.warn(message2) });
22906
23009
  ctx.inject(["adgGateway"], (scoped) => {
22907
23010
  scoped.effect(() => scoped.adgGateway.role(SCRIPT_ROLE), "adg-script-registry role");
23011
+ void this.ready.then(async () => {
23012
+ let put = false;
23013
+ for (const script of library.list().scripts) {
23014
+ if (script.dir !== void 0)
23015
+ put = (await integrations.autoImportSkills(script.id).catch(() => [])).length > 0 || put;
23016
+ }
23017
+ if (put)
23018
+ scoped.adgGateway.broadcast("skills/changed", {});
23019
+ });
22908
23020
  scoped.adgGateway.skillScope.resolveScripts((id) => {
22909
23021
  let pack;
22910
23022
  try {
@@ -22957,4 +23069,4 @@ export {
22957
23069
  AdgScripts,
22958
23070
  lib_default
22959
23071
  };
22960
- /*! For license information please see chunk-AJMAUHPI.js.LEGAL.txt */
23072
+ /*! For license information please see chunk-KW36B7DT.js.LEGAL.txt */
@@ -4,7 +4,7 @@ import {
4
4
  LOW_CONTEXT_WINDOW_MS,
5
5
  MAX_ARCHIVE_DAYS,
6
6
  MIN_ARCHIVE_DAYS
7
- } from "./chunk-7EFZ5KR6.js";
7
+ } from "./chunk-34VNH3YS.js";
8
8
 
9
9
  // packages/gateway/lib/low-context.js
10
10
  import { appendFile, mkdir, readFile, stat } from "node:fs/promises";