dsh-multigameassistant 2.1.0 → 2.1.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.
- package/cordis.patch.yml +1 -1
- package/lib/analyzer.js +3 -3
- package/lib/{chunk-77ZYHRN7.js → chunk-5PDYWE24.js} +1 -1
- package/lib/{chunk-YG4B5G7F.js → chunk-B4UT4NYH.js} +1 -0
- package/lib/{chunk-FH64SAZU.js → chunk-FBDVN6Q2.js} +1 -1
- package/lib/{chunk-MEKSHT6V.js → chunk-MQG5FLOG.js} +8 -4
- package/lib/{chunk-V2X4PLF5.js → chunk-NM6H6WCQ.js} +27 -4
- package/lib/{chunk-TWUATN5X.js → chunk-UQLHGLMP.js} +2 -2
- package/lib/{chunk-EOWM56PA.js → chunk-VOTN4IHB.js} +2 -2
- package/lib/emulator.js +2 -2
- package/lib/feishu.js +4 -4
- package/lib/game-intel.js +5 -5
- package/lib/gateway.js +5 -3
- package/lib/guard.js +1 -1
- package/lib/intervene.js +4 -4
- package/lib/low-context.js +2 -2
- package/lib/monitor.js +3 -3
- package/lib/notify.js +4 -4
- package/lib/orchestrator.js +6 -6
- package/lib/qqbot.js +4 -4
- package/lib/runner.js +3 -3
- package/lib/scheduler.js +1 -1
- package/lib/script-registry.js +167 -20
- package/package.json +1 -1
- package/web/assets/{index-CjtVfcDS.css → index-CL3SeTW9.css} +1 -1
- package/web/assets/{index-C-csjWiw.js → index-GYwpGP3f.js} +73 -73
- package/web/assets/index-GYwpGP3f.js.map +1 -0
- package/web/index.html +2 -2
- package/web/assets/index-C-csjWiw.js.map +0 -1
package/lib/script-registry.js
CHANGED
|
@@ -21,10 +21,11 @@ import {
|
|
|
21
21
|
probeProject,
|
|
22
22
|
readMirrorChanges,
|
|
23
23
|
runSetup,
|
|
24
|
+
satisfies,
|
|
24
25
|
setupExitText,
|
|
25
26
|
setupKind,
|
|
26
27
|
systemHost
|
|
27
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-B4UT4NYH.js";
|
|
28
29
|
import {
|
|
29
30
|
MANIFEST_FILE,
|
|
30
31
|
SKILL_FILE,
|
|
@@ -33,12 +34,14 @@ import {
|
|
|
33
34
|
guideView,
|
|
34
35
|
parseManifest,
|
|
35
36
|
versionOfTag
|
|
36
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-5PDYWE24.js";
|
|
37
38
|
import {
|
|
38
39
|
sessionConversations
|
|
39
|
-
} from "./chunk-
|
|
40
|
-
import
|
|
41
|
-
|
|
40
|
+
} from "./chunk-UQLHGLMP.js";
|
|
41
|
+
import {
|
|
42
|
+
pluginVersion
|
|
43
|
+
} from "./chunk-MQG5FLOG.js";
|
|
44
|
+
import "./chunk-FBDVN6Q2.js";
|
|
42
45
|
import {
|
|
43
46
|
ExeIcons,
|
|
44
47
|
writeFileAtomic
|
|
@@ -61,7 +64,7 @@ import {
|
|
|
61
64
|
optimizeScriptPrompt,
|
|
62
65
|
parseGitHubLink,
|
|
63
66
|
taskMessage
|
|
64
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-NM6H6WCQ.js";
|
|
65
68
|
import {
|
|
66
69
|
external_exports
|
|
67
70
|
} from "./chunk-SHTX4AGU.js";
|
|
@@ -2504,7 +2507,20 @@ var REFRESH_MS = 24 * 60 * 6e4;
|
|
|
2504
2507
|
var SKILL_FILE2 = "SKILL.md";
|
|
2505
2508
|
var NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
2506
2509
|
var Owner = external_exports.object({ games: external_exports.array(external_exports.string()).optional(), scripts: external_exports.array(external_exports.string()).optional() });
|
|
2507
|
-
var
|
|
2510
|
+
var Previous = external_exports.object({ hash: external_exports.string(), version: external_exports.string().optional(), at: external_exports.number() });
|
|
2511
|
+
var Installed = external_exports.object({
|
|
2512
|
+
repo: external_exports.string(),
|
|
2513
|
+
path: external_exports.string(),
|
|
2514
|
+
hash: external_exports.string(),
|
|
2515
|
+
at: external_exports.number(),
|
|
2516
|
+
owner: Owner.optional(),
|
|
2517
|
+
/** `hash` is of the whole folder; records from before were of SKILL.md alone. */
|
|
2518
|
+
folder: external_exports.literal(true).optional(),
|
|
2519
|
+
version: external_exports.string().optional(),
|
|
2520
|
+
previous: Previous.optional(),
|
|
2521
|
+
/** The repository's hash that was gone back from. */
|
|
2522
|
+
held: external_exports.string().optional()
|
|
2523
|
+
});
|
|
2508
2524
|
var State = external_exports.object({
|
|
2509
2525
|
repos: external_exports.array(external_exports.object({ repo: external_exports.string(), branch: external_exports.string() })).optional(),
|
|
2510
2526
|
installed: external_exports.record(external_exports.string(), Installed).default({}),
|
|
@@ -2517,7 +2533,10 @@ var Index = external_exports.object({
|
|
|
2517
2533
|
title: external_exports.string().optional(),
|
|
2518
2534
|
kind: external_exports.enum(["game", "script", "general"]).optional(),
|
|
2519
2535
|
games: external_exports.array(external_exports.string()).optional(),
|
|
2520
|
-
scripts: external_exports.array(external_exports.string()).optional()
|
|
2536
|
+
scripts: external_exports.array(external_exports.string()).optional(),
|
|
2537
|
+
version: external_exports.string().max(40).optional(),
|
|
2538
|
+
changes: external_exports.string().max(300).optional(),
|
|
2539
|
+
requires: external_exports.string().max(60).optional()
|
|
2521
2540
|
}))
|
|
2522
2541
|
});
|
|
2523
2542
|
var SkillHub = class {
|
|
@@ -2540,6 +2559,21 @@ var SkillHub = class {
|
|
|
2540
2559
|
} catch {
|
|
2541
2560
|
}
|
|
2542
2561
|
await rm2(join4(this.#options.dir, "base"), { recursive: true, force: true });
|
|
2562
|
+
let migrated = false;
|
|
2563
|
+
for (const [name, record] of Object.entries(this.#state.installed)) {
|
|
2564
|
+
if (record.folder === true)
|
|
2565
|
+
continue;
|
|
2566
|
+
const here = await folderHash(join4(this.skillsDir, name)).catch(() => void 0);
|
|
2567
|
+
if (here === void 0)
|
|
2568
|
+
continue;
|
|
2569
|
+
record.hash = here;
|
|
2570
|
+
record.folder = true;
|
|
2571
|
+
migrated = true;
|
|
2572
|
+
}
|
|
2573
|
+
if (migrated) {
|
|
2574
|
+
this.#state.read = {};
|
|
2575
|
+
await this.#save();
|
|
2576
|
+
}
|
|
2543
2577
|
for (const name of Object.keys(this.#state.installed))
|
|
2544
2578
|
await this.#register(name);
|
|
2545
2579
|
})();
|
|
@@ -2603,7 +2637,7 @@ var SkillHub = class {
|
|
|
2603
2637
|
continue;
|
|
2604
2638
|
const content = await readFile4(join4(this.skillsDir, name, SKILL_FILE2), "utf8").catch(() => "");
|
|
2605
2639
|
const front = frontmatter(content);
|
|
2606
|
-
items.push({ name, description: front?.description ?? "", kind: "general", games: [], scripts: [], repo: record.repo, path: record.path, hash: record.hash, installed:
|
|
2640
|
+
items.push({ name, description: front?.description ?? "", kind: "general", games: [], scripts: [], repo: record.repo, path: record.path, hash: record.hash, installed: installedOf(record, false) });
|
|
2607
2641
|
}
|
|
2608
2642
|
return { items, repos: this.repos(), errors, ...fetchedAt === void 0 ? {} : { fetchedAt } };
|
|
2609
2643
|
}
|
|
@@ -2613,6 +2647,7 @@ var SkillHub = class {
|
|
|
2613
2647
|
const blocked = (await this.#options.taken()).get(name);
|
|
2614
2648
|
if (blocked !== void 0)
|
|
2615
2649
|
throw new Error(`\u5DF2\u6709\u540C\u540D\u7684${blocked}\u300C${name}\u300D\uFF0C\u6CA1\u6709\u4E0B\u8F7D`);
|
|
2650
|
+
this.#checkCompatible(skill);
|
|
2616
2651
|
await this.#put(skill);
|
|
2617
2652
|
this.#options.log.info(`skill hub: downloaded ${name} from ${skill.repo}`);
|
|
2618
2653
|
return this.#item(skill, await this.#options.taken());
|
|
@@ -2623,12 +2658,34 @@ var SkillHub = class {
|
|
|
2623
2658
|
const skill = await this.#find(name, record.repo, signal);
|
|
2624
2659
|
if (skill.hash === record.hash)
|
|
2625
2660
|
return { state: "current", item: await this.#item(skill, await this.#options.taken()) };
|
|
2661
|
+
this.#checkCompatible(skill);
|
|
2626
2662
|
await this.#put(skill);
|
|
2627
2663
|
return { state: "updated", item: await this.#item(skill, await this.#options.taken()) };
|
|
2628
2664
|
}
|
|
2665
|
+
/** Go back to the version the last update replaced; the newer one is not offered again until the repository has another. */
|
|
2666
|
+
async rollback(name) {
|
|
2667
|
+
const record = this.#record(name);
|
|
2668
|
+
const kept = join4(this.#previousDir, name);
|
|
2669
|
+
const previous = record.previous;
|
|
2670
|
+
if (previous === void 0 || !await stat2(kept).then((st) => st.isDirectory(), () => false))
|
|
2671
|
+
throw new Error(`\u300C${name}\u300D\u6CA1\u6709\u4E0A\u4E00\u4E2A\u7248\u672C\u53EF\u4EE5\u56DE\u9000`);
|
|
2672
|
+
const held = record.hash;
|
|
2673
|
+
await rm2(join4(this.skillsDir, name), { recursive: true, force: true });
|
|
2674
|
+
await rename3(kept, join4(this.skillsDir, name));
|
|
2675
|
+
const { previous: _previous, version: _version, ...rest } = record;
|
|
2676
|
+
this.#state.installed[name] = { ...rest, hash: previous.hash, at: this.#now(), folder: true, held, ...previous.version === void 0 ? {} : { version: previous.version } };
|
|
2677
|
+
await this.#save();
|
|
2678
|
+
await this.#register(name);
|
|
2679
|
+
this.#options.log.info(`skill hub: ${name} back to ${previous.version ?? previous.hash}`);
|
|
2680
|
+
const listed = (await this.list()).items.find((i) => i.name === name);
|
|
2681
|
+
if (listed === void 0)
|
|
2682
|
+
throw new Error(`\u6280\u80FD\u5E93\u91CC\u6CA1\u6709\u300C${name}\u300D`);
|
|
2683
|
+
return listed;
|
|
2684
|
+
}
|
|
2629
2685
|
async remove(name) {
|
|
2630
2686
|
this.#record(name);
|
|
2631
2687
|
this.#options.register(name, void 0);
|
|
2688
|
+
await rm2(join4(this.#previousDir, name), { recursive: true, force: true });
|
|
2632
2689
|
await rm2(join4(this.skillsDir, name), { recursive: true, force: true });
|
|
2633
2690
|
delete this.#state.installed[name];
|
|
2634
2691
|
await this.#save();
|
|
@@ -2652,6 +2709,21 @@ var SkillHub = class {
|
|
|
2652
2709
|
return this.#state.installed[name] !== void 0;
|
|
2653
2710
|
}
|
|
2654
2711
|
// ── internals ──
|
|
2712
|
+
get #previousDir() {
|
|
2713
|
+
return join4(this.#options.dir, "previous");
|
|
2714
|
+
}
|
|
2715
|
+
/** Why this app cannot take the skill's version; undefined: it can. */
|
|
2716
|
+
#incompatible(skill) {
|
|
2717
|
+
const app = this.#options.appVersion?.();
|
|
2718
|
+
if (skill.requires === void 0 || app === void 0 || satisfies(app, skill.requires))
|
|
2719
|
+
return void 0;
|
|
2720
|
+
return `\u9700\u8981\u8F6F\u4EF6\u7248\u672C ${skill.requires}\uFF08\u73B0\u5728\u662F ${app}\uFF09\uFF0C\u5148\u66F4\u65B0\u8F6F\u4EF6`;
|
|
2721
|
+
}
|
|
2722
|
+
#checkCompatible(skill) {
|
|
2723
|
+
const why = this.#incompatible(skill);
|
|
2724
|
+
if (why !== void 0)
|
|
2725
|
+
throw new Error(`\u300C${skill.name}\u300D${skill.version === void 0 ? "" : ` ${skill.version}`}${why}`);
|
|
2726
|
+
}
|
|
2655
2727
|
#record(name) {
|
|
2656
2728
|
const record = this.#state.installed[name];
|
|
2657
2729
|
if (record === void 0)
|
|
@@ -2681,11 +2753,28 @@ var SkillHub = class {
|
|
|
2681
2753
|
async #put(skill) {
|
|
2682
2754
|
const from = join4(this.#options.dir, "repos", repoKey({ repo: skill.repo, branch: "" }), ...skill.path.split("/"));
|
|
2683
2755
|
const to = join4(this.skillsDir, skill.name);
|
|
2756
|
+
const before = this.#state.installed[skill.name];
|
|
2757
|
+
let previous;
|
|
2758
|
+
if (before !== void 0 && await stat2(to).then((st) => st.isDirectory(), () => false)) {
|
|
2759
|
+
await rm2(join4(this.#previousDir, skill.name), { recursive: true, force: true });
|
|
2760
|
+
await mkdir3(this.#previousDir, { recursive: true });
|
|
2761
|
+
await rename3(to, join4(this.#previousDir, skill.name));
|
|
2762
|
+
previous = { hash: before.hash, at: before.at, ...before.version === void 0 ? {} : { version: before.version } };
|
|
2763
|
+
}
|
|
2684
2764
|
await rm2(to, { recursive: true, force: true });
|
|
2685
2765
|
await mkdir3(this.skillsDir, { recursive: true });
|
|
2686
2766
|
await cp2(from, to, { recursive: true });
|
|
2687
|
-
const owner =
|
|
2688
|
-
this.#state.installed[skill.name] = {
|
|
2767
|
+
const owner = before?.owner;
|
|
2768
|
+
this.#state.installed[skill.name] = {
|
|
2769
|
+
repo: skill.repo,
|
|
2770
|
+
path: skill.path,
|
|
2771
|
+
hash: skill.hash,
|
|
2772
|
+
at: this.#now(),
|
|
2773
|
+
folder: true,
|
|
2774
|
+
...skill.version === void 0 ? {} : { version: skill.version },
|
|
2775
|
+
...owner === void 0 ? {} : { owner },
|
|
2776
|
+
...previous === void 0 ? {} : { previous }
|
|
2777
|
+
};
|
|
2689
2778
|
await this.#save();
|
|
2690
2779
|
await this.#register(skill.name);
|
|
2691
2780
|
}
|
|
@@ -2706,13 +2795,30 @@ var SkillHub = class {
|
|
|
2706
2795
|
const owner = games.length + scripts.length === 0 ? void 0 : { ...games.length === 0 ? {} : { games }, ...scripts.length === 0 ? {} : { scripts } };
|
|
2707
2796
|
this.#options.register(name, { description: front.description, content: front.body, path, dir: join4(this.skillsDir, name), ...owner === void 0 ? {} : { owner } });
|
|
2708
2797
|
}
|
|
2709
|
-
async #item(
|
|
2798
|
+
async #item(found, taken) {
|
|
2799
|
+
const { name, description, title, kind, games, scripts, repo, path, hash, version, changes, requires } = found;
|
|
2800
|
+
const skill = {
|
|
2801
|
+
name,
|
|
2802
|
+
description,
|
|
2803
|
+
kind,
|
|
2804
|
+
games,
|
|
2805
|
+
scripts,
|
|
2806
|
+
repo,
|
|
2807
|
+
path,
|
|
2808
|
+
hash,
|
|
2809
|
+
...title === void 0 ? {} : { title },
|
|
2810
|
+
...version === void 0 ? {} : { version },
|
|
2811
|
+
...changes === void 0 ? {} : { changes },
|
|
2812
|
+
...requires === void 0 ? {} : { requires }
|
|
2813
|
+
};
|
|
2814
|
+
const incompatible = this.#incompatible(skill);
|
|
2710
2815
|
const record = this.#state.installed[skill.name];
|
|
2711
2816
|
if (record === void 0) {
|
|
2712
2817
|
const blocked = taken.get(skill.name);
|
|
2713
|
-
return { ...skill, ...blocked === void 0 ? {} : { blocked: `\u5DF2\u6709\u540C\u540D\u7684${blocked}` } };
|
|
2818
|
+
return { ...skill, ...blocked === void 0 ? {} : { blocked: `\u5DF2\u6709\u540C\u540D\u7684${blocked}` }, ...incompatible === void 0 ? {} : { incompatible } };
|
|
2714
2819
|
}
|
|
2715
|
-
|
|
2820
|
+
const newer = skill.repo === record.repo && skill.hash !== record.hash && skill.hash !== record.held;
|
|
2821
|
+
return { ...skill, installed: installedOf(record, newer, skill.hash === record.held), ...newer && incompatible !== void 0 ? { incompatible } : {} };
|
|
2716
2822
|
}
|
|
2717
2823
|
/** Download the repository and list its skills; the copy replaces the one before. */
|
|
2718
2824
|
async #readRepo(repo, signal) {
|
|
@@ -2761,6 +2867,8 @@ async function readSkills(root, repo) {
|
|
|
2761
2867
|
continue;
|
|
2762
2868
|
const content = await readFile4(join4(full, SKILL_FILE2), "utf8").catch(() => void 0);
|
|
2763
2869
|
const front = content === void 0 ? void 0 : frontmatter(content);
|
|
2870
|
+
const version = entry.version ?? front?.version;
|
|
2871
|
+
const { changes, requires } = entry;
|
|
2764
2872
|
if (content === void 0 || front === void 0)
|
|
2765
2873
|
continue;
|
|
2766
2874
|
const name = entry.name ?? front.name;
|
|
@@ -2776,8 +2884,11 @@ async function readSkills(root, repo) {
|
|
|
2776
2884
|
scripts: entry.scripts ?? [],
|
|
2777
2885
|
repo,
|
|
2778
2886
|
path,
|
|
2779
|
-
hash:
|
|
2780
|
-
...entry.title === void 0 ? {} : { title: entry.title }
|
|
2887
|
+
hash: await folderHash(full),
|
|
2888
|
+
...entry.title === void 0 ? {} : { title: entry.title },
|
|
2889
|
+
...version === void 0 ? {} : { version },
|
|
2890
|
+
...changes === void 0 ? {} : { changes },
|
|
2891
|
+
...requires === void 0 ? {} : { requires }
|
|
2781
2892
|
});
|
|
2782
2893
|
}
|
|
2783
2894
|
return skills;
|
|
@@ -2816,10 +2927,39 @@ function frontmatter(text) {
|
|
|
2816
2927
|
if (description === void 0 || description === "")
|
|
2817
2928
|
return void 0;
|
|
2818
2929
|
const name = field("name");
|
|
2819
|
-
|
|
2930
|
+
const version = field("version");
|
|
2931
|
+
return { ...name === void 0 ? {} : { name }, ...version === void 0 ? {} : { version }, description, body: match[2] };
|
|
2820
2932
|
}
|
|
2821
|
-
function
|
|
2822
|
-
|
|
2933
|
+
async function folderHash(dir) {
|
|
2934
|
+
const files = [];
|
|
2935
|
+
const walk = async (sub) => {
|
|
2936
|
+
for (const entry of await readdir3(join4(dir, sub), { withFileTypes: true })) {
|
|
2937
|
+
const rel = sub === "" ? entry.name : `${sub}/${entry.name}`;
|
|
2938
|
+
if (entry.isDirectory()) {
|
|
2939
|
+
if (entry.name !== "__pycache__")
|
|
2940
|
+
await walk(rel);
|
|
2941
|
+
} else if (entry.isFile())
|
|
2942
|
+
files.push(rel);
|
|
2943
|
+
}
|
|
2944
|
+
};
|
|
2945
|
+
await walk("");
|
|
2946
|
+
if (!files.includes(SKILL_FILE2))
|
|
2947
|
+
throw new Error(`${dir} \u91CC\u6CA1\u6709 ${SKILL_FILE2}`);
|
|
2948
|
+
const digest = createHash("sha256");
|
|
2949
|
+
for (const rel of files.sort()) {
|
|
2950
|
+
const bytes = await readFile4(join4(dir, ...rel.split("/")));
|
|
2951
|
+
digest.update(rel).update("\0").update(bytes.includes(0) ? bytes : bytes.toString("utf8").replace(/\r\n/g, "\n")).update("\0");
|
|
2952
|
+
}
|
|
2953
|
+
return digest.digest("hex").slice(0, 16);
|
|
2954
|
+
}
|
|
2955
|
+
function installedOf(record, update, held = false) {
|
|
2956
|
+
return {
|
|
2957
|
+
at: record.at,
|
|
2958
|
+
update,
|
|
2959
|
+
...record.version === void 0 ? {} : { version: record.version },
|
|
2960
|
+
...record.previous === void 0 ? {} : { previous: { at: record.previous.at, ...record.previous.version === void 0 ? {} : { version: record.previous.version } } },
|
|
2961
|
+
...held ? { held: true } : {}
|
|
2962
|
+
};
|
|
2823
2963
|
}
|
|
2824
2964
|
function repoKey(repo) {
|
|
2825
2965
|
return repo.repo.toLowerCase().replace(/[^a-z0-9._-]+/g, "__");
|
|
@@ -2879,6 +3019,8 @@ function startSkillHub(ctx, library, ready, approve, log) {
|
|
|
2879
3019
|
entries.set(name, skill);
|
|
2880
3020
|
apply(name);
|
|
2881
3021
|
},
|
|
3022
|
+
// For a skill's `requires`: the desktop app passes its version; the dsh plugin has it in its manifest; from source, none.
|
|
3023
|
+
appVersion: () => process.env["ADG_APP_VERSION"] || pluginVersion(),
|
|
2882
3024
|
log
|
|
2883
3025
|
});
|
|
2884
3026
|
const started = ready.then(() => hub.start());
|
|
@@ -2907,6 +3049,11 @@ function startSkillHub(ctx, library, ready, approve, log) {
|
|
|
2907
3049
|
changed();
|
|
2908
3050
|
return result;
|
|
2909
3051
|
},
|
|
3052
|
+
"skillhub/rollback": async (params) => {
|
|
3053
|
+
const item = await hub.rollback(params.name);
|
|
3054
|
+
changed();
|
|
3055
|
+
return item;
|
|
3056
|
+
},
|
|
2910
3057
|
"skillhub/remove": async (params) => {
|
|
2911
3058
|
await hub.remove(params.name);
|
|
2912
3059
|
changed();
|
|
@@ -2973,7 +3120,7 @@ function hubTools(hub, approve, changed) {
|
|
|
2973
3120
|
const shown = items.filter((i) => (a.game == null || i.games.includes(a.game)) && (a.script == null || i.scripts.includes(a.script)));
|
|
2974
3121
|
return {
|
|
2975
3122
|
errors,
|
|
2976
|
-
skills: shown.map((i) => ({ name: i.name, description: i.description, kind: i.kind, games: i.games, scripts: i.scripts, repo: i.repo, installed: i.installed, blocked: i.blocked }))
|
|
3123
|
+
skills: shown.map((i) => ({ name: i.name, description: i.description, kind: i.kind, games: i.games, scripts: i.scripts, repo: i.repo, version: i.version, changes: i.changes, installed: i.installed, blocked: i.blocked, incompatible: i.incompatible }))
|
|
2977
3124
|
};
|
|
2978
3125
|
},
|
|
2979
3126
|
presentCall: () => ({ card: "generic", title: "\u67E5\u770B\u6280\u80FD\u5E93", kind: "read" })
|